all repos — mgba @ bb5e14ea2df872cd2e3f70747a44cd32c82c1196

mGBA Game Boy Advance Emulator

PSP2, Wii: Use a higher-resolution font
Jeffrey Pfau jeffrey@endrift.com
Tue, 05 Jan 2016 21:11:31 -0800
commit

bb5e14ea2df872cd2e3f70747a44cd32c82c1196

parent

7b090aa0d129514f9af6cf6f0e3c3d385e35060f

M src/platform/psp2/CMakeLists.txtsrc/platform/psp2/CMakeLists.txt

@@ -25,7 +25,7 @@ set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")

target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${OS_LIB}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/font.o - COMMAND ${OBJCOPY_CMD} font.png ${CMAKE_CURRENT_BINARY_DIR}/font.o + COMMAND ${OBJCOPY_CMD} font2x.png ${CMAKE_CURRENT_BINARY_DIR}/font.o WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/backdrop.o
M src/platform/psp2/gui-font.csrc/platform/psp2/gui-font.c

@@ -8,11 +8,11 @@ #include "util/gui/font-metrics.h"

#include <vita2d.h> -#define CELL_HEIGHT 16 -#define CELL_WIDTH 16 -#define GLYPH_HEIGHT 12 +#define CELL_HEIGHT 32 +#define CELL_WIDTH 32 +#define GLYPH_HEIGHT 24 -extern const uint8_t _binary_font_png_start[]; +extern const uint8_t _binary_font2x_png_start[]; struct GUIFont { vita2d_texture* tex;

@@ -23,7 +23,7 @@ struct GUIFont* font = malloc(sizeof(struct GUIFont));

if (!font) { return 0; } - font->tex = vita2d_load_PNG_buffer(_binary_font_png_start); + font->tex = vita2d_load_PNG_buffer(_binary_font2x_png_start); return font; }

@@ -34,7 +34,7 @@ }

unsigned GUIFontHeight(const struct GUIFont* font) { UNUSED(font); - return GLYPH_HEIGHT * 2; + return GLYPH_HEIGHT; } unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {

@@ -50,10 +50,10 @@ if (glyph > 0x7F) {

glyph = '?'; } struct GUIFontGlyphMetric metric = defaultFontMetrics[glyph]; - vita2d_draw_texture_tint_part_scale(font->tex, x, y + (-GLYPH_HEIGHT + metric.padding.top) * 2, - (glyph & 15) * CELL_WIDTH + metric.padding.left, - (glyph >> 4) * CELL_HEIGHT + metric.padding.top, - CELL_WIDTH - (metric.padding.left + metric.padding.right), - CELL_HEIGHT - (metric.padding.top + metric.padding.bottom), - 2, 2, color); + vita2d_draw_texture_tint_part_scale(font->tex, x, y - GLYPH_HEIGHT + metric.padding.top * 2, + (glyph & 15) * CELL_WIDTH + metric.padding.left * 2, + (glyph >> 4) * CELL_HEIGHT + metric.padding.top * 2, + CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2, + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom) * 2, + 1, 1, color); }
M src/platform/wii/CMakeLists.txtsrc/platform/wii/CMakeLists.txt

@@ -24,6 +24,7 @@ target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${OS_LIB})

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/font.c COMMAND ${RAW2C} ${CMAKE_SOURCE_DIR}/src/platform/wii/font.tpl + MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/src/platform/wii/font.tpl WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) add_custom_target(${BINARY_NAME}.dol ALL
M src/platform/wii/gui-font.csrc/platform/wii/gui-font.c

@@ -10,9 +10,9 @@

#include <malloc.h> #include <ogc/tpl.h> -#define GLYPH_HEIGHT 12 -#define CELL_HEIGHT 16 -#define CELL_WIDTH 16 +#define GLYPH_HEIGHT 24 +#define CELL_HEIGHT 32 +#define CELL_WIDTH 32 struct GUIFont { TPLFile tdf;

@@ -50,7 +50,7 @@ UNUSED(font);

if (glyph > 0x7F) { glyph = '?'; } - return defaultFontMetrics[glyph].width; + return defaultFontMetrics[glyph].width * 2; } void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color, uint32_t glyph) {

@@ -69,23 +69,23 @@ if (glyph > 0x7F) {

glyph = '?'; } struct GUIFontGlyphMetric metric = defaultFontMetrics[glyph]; - s16 tx = (glyph & 15) * CELL_WIDTH + metric.padding.left; - s16 ty = (glyph >> 4) * CELL_HEIGHT + metric.padding.top; + s16 tx = (glyph & 15) * CELL_WIDTH + metric.padding.left * 2; + s16 ty = (glyph >> 4) * CELL_HEIGHT + metric.padding.top * 2; GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x, y - GLYPH_HEIGHT + metric.padding.top); + GX_Position2s16(x, y - GLYPH_HEIGHT + metric.padding.top * 2); GX_Color1u32(color); - GX_TexCoord2f32(tx / 256.f, ty / 128.f); + GX_TexCoord2f32(tx / 512.f, ty / 256.f); - GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + metric.padding.top); + GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2, y - GLYPH_HEIGHT + metric.padding.top * 2); GX_Color1u32(color); - GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, ty / 128.f); + GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2) / 512.f, ty / 256.f); - GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom); + GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2, y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom * 2); GX_Color1u32(color); - GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f); + GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2) / 512.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom) * 2) / 256.f); - GX_Position2s16(x, y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom); + GX_Position2s16(x, y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom * 2); GX_Color1u32(color); - GX_TexCoord2f32(tx / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f); + GX_TexCoord2f32(tx / 512.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom) * 2) / 256.f); GX_End(); }
M src/platform/wii/main.csrc/platform/wii/main.c

@@ -196,7 +196,7 @@ rotation.readGyroZ = _readGyroZ;

struct GBAGUIRunner runner = { .params = { - vmode->fbWidth * 0.9, vmode->efbHeight * 0.9, + vmode->fbWidth * 1.6, vmode->efbHeight * 1.6, font, "", _drawStart, _drawEnd, _pollInput, _pollCursor,

@@ -374,21 +374,22 @@ guOrtho(proj, -top, top + h, -left, left + w, 0, 300);

GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); } +void _reproj2(int w, int h) { + Mtx44 proj; + s16 top = 20; + guOrtho(proj, -top, top + h, 0, w, 0, 300); + GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); +} + void _guiPrepare(void) { - int w = vmode->fbWidth * 0.9; - int h = vmode->efbHeight * 0.9; - _reproj(w, h); + _reproj2(vmode->fbWidth * 1.6, vmode->efbHeight * 1.6); } void _guiFinish(void) { if (screenMode == SM_PA) { _reproj(VIDEO_HORIZONTAL_PIXELS * scaleFactor, VIDEO_VERTICAL_PIXELS * scaleFactor); } else { - Mtx44 proj; - short top = (CONF_GetAspectRatio() == CONF_ASPECT_16_9) ? 10 : 20; - short bottom = VIDEO_VERTICAL_PIXELS + top; - guOrtho(proj, -top, bottom, 0, VIDEO_HORIZONTAL_PIXELS, 0, 300); - GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); + _reproj2(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); } }