From 1b00b9d7bfda7a2a445957ec08209b917341ac01 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 12 Aug 2023 13:16:09 +1000 Subject: [PATCH] Dreamcast: Fix system font rendering --- src/SystemFonts.c | 6 ++++-- src/Window_Dreamast.c | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SystemFonts.c b/src/SystemFonts.c index db6e37b75..48bf0ac80 100644 --- a/src/SystemFonts.c +++ b/src/SystemFonts.c @@ -1065,6 +1065,7 @@ int SysFont_TextWidth(struct DrawTextArgs* args) { } return max(1, width); } + static void DrawSpan(struct Bitmap* bmp, int x, int y, int row, BitmapCol color) { if (y < 0 || y >= bmp->height) return; @@ -1073,13 +1074,14 @@ static void DrawSpan(struct Bitmap* bmp, int x, int y, int row, BitmapCol color) int dstX = x + glyphX; if (dstX < 0 || dstX >= bmp->width) continue; - int bit = BFONT_THIN_WIDTH - glyphX; - if ((row >> bit) & 1) { + // row encodes 12 "1 bit values", starting from hi to lo + if (row & (0x800 >> glyphX)) { Bitmap_GetPixel(bmp, dstX, y) = color; } } } + static void DrawGlyph(struct Bitmap* bmp, int x, int y, uint8* cell, BitmapCol color) { // Each font glyph row contains 12 "1 bit" values horizontally // as 3 bytes = 24 bits, it therefore encodes 2 rows diff --git a/src/Window_Dreamast.c b/src/Window_Dreamast.c index 37bc08942..6a8164169 100644 --- a/src/Window_Dreamast.c +++ b/src/Window_Dreamast.c @@ -66,6 +66,7 @@ static void HandleButtons_Launcher(int mods) { Input_SetNonRepeatable(CCPAD_UP, mods & CONT_DPAD_UP); Input_SetNonRepeatable(CCPAD_DOWN, mods & CONT_DPAD_DOWN); } + static void HandleButtons_Game(int mods) { // TODO CONT_Z @@ -82,11 +83,12 @@ static void HandleButtons_Game(int mods) { Input_SetNonRepeatable(CCPAD_UP, mods & CONT_DPAD_UP); Input_SetNonRepeatable(CCPAD_DOWN, mods & CONT_DPAD_DOWN); } + static void HandleController(cont_state_t* state) { Input_SetNonRepeatable(CCPAD_L, state->ltrig > 10); Input_SetNonRepeatable(CCPAD_R, state->rtrig > 10); // TODO CONT_Z, joysticks - // TODO: verify values are write + // TODO: verify values are right if (Input.RawMode) { int dx = state->joyx, dy = state->joyy; @@ -141,10 +143,6 @@ void Window_DrawFramebuffer(Rect2D r) { // TODO: Don't redraw everything int size = fb_bmp.width * fb_bmp.height * 4; - cc_uint32* row = Bitmap_GetRow(&fb_bmp, 20); - bfont_draw_str_ex(row, fb_bmp.width, 0xFFEEDDCC, 0x55667788, 32, - true, "ABC III LLL"); - // TODO: double buffering ?? // https://dcemulation.org/phpBB/viewtopic.php?t=99999 // https://dcemulation.org/phpBB/viewtopic.php?t=43214