mirror of https://github.com/mgba-emu/mgba.git
PSP2, Wii: Use a higher-resolution font
This commit is contained in:
parent
7b090aa0d1
commit
bb5e14ea2d
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -25,7 +25,7 @@ set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DE
|
|||
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
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
#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* GUIFontCreate(void) {
|
|||
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 @@ void GUIFontDestroy(struct GUIFont* font) {
|
|||
|
||||
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 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color,
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
|
@ -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 @@ unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {
|
|||
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 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color,
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ int main() {
|
|||
|
||||
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 @@ void _reproj(int w, int h) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue