Browse Source

avoid flicker in debug frame display and format as hex for fixed width

Thomas B 3 weeks ago
parent
commit
570b0b67f8
4 changed files with 16 additions and 11 deletions
  1. 2
    2
      src/game.c
  2. 3
    3
      src/strings.c
  3. 10
    5
      src/window.c
  4. 1
    1
      src/window.h

+ 2
- 2
src/game.c View File

@@ -262,7 +262,7 @@ int32_t game(enum GAME_MODE mode) NONBANKED {
262 262
         }
263 263
     }
264 264
 
265
-    uint8_t x_off = win_game_draw(score);
265
+    uint8_t x_off = win_game_draw(score, 1);
266 266
     move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
267 267
 
268 268
     SHOW_WIN;
@@ -497,7 +497,7 @@ int32_t game(enum GAME_MODE mode) NONBANKED {
497 497
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
498 498
 
499 499
         if ((score != prev_score) || ((_cpu == CGB_TYPE) && (conf_get()->debug_flags))) {
500
-            uint8_t x_off = win_game_draw(score);
500
+            uint8_t x_off = win_game_draw(score, 0);
501 501
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
502 502
         }
503 503
 

+ 3
- 3
src/strings.c View File

@@ -49,9 +49,9 @@ static const char string_error[] = "error";
49 49
 static const char string_gb_printer[] = "GB Printer";
50 50
 static const char string_score_printout[] = "Score Printout";
51 51
 static const char string_result[] = "Result:";
52
-static const char string_printf_error[] = "error: 0x%04x";
53
-static const char string_printf_frames[] = "Frames: %u";
54
-static const char string_printf_timer[] = "Timer: %u";
52
+static const char string_printf_error[] = "error: 0x%x";
53
+static const char string_printf_frames[] = "Frames: 0x%x";
54
+static const char string_printf_timer[] = " Timer: 0x%x";
55 55
 
56 56
 static const char * const strings[COUNT_STRINGS] = {
57 57
     string_top,            // STR_TOP

+ 10
- 5
src/window.c View File

@@ -258,7 +258,7 @@ void win_name_draw(uint16_t name, uint8_t is_black, uint8_t pos) BANKED {
258 258
          (pos == 2) ? !is_black : is_black);
259 259
 }
260 260
 
261
-uint8_t win_game_draw(int32_t score) BANKED {
261
+uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED {
262 262
     uint8_t is_black = 0;
263 263
     if (score < 0) {
264 264
         score = -score;
@@ -266,16 +266,21 @@ uint8_t win_game_draw(int32_t score) BANKED {
266 266
     }
267 267
 
268 268
     if ((_cpu == CGB_TYPE) && (conf_get()->debug_flags)) {
269
-        // TODO hard-coded black bg tile
270
-        fill_win(0, 0, 20, 2, 0x80, BKGF_CGB_PAL3);
269
+        static int32_t prev_score = 0;
270
+        if (initial || (score != prev_score)) {
271
+            prev_score = score;
272
+
273
+            // TODO hard-coded black bg tile
274
+            fill_win(0, 0, 20, 2, 0x80, BKGF_CGB_PAL3);
275
+        }
271 276
 
272 277
         uint8_t x_off = number(score, 0, 0, is_black) >> 3;
273 278
 
274 279
         sprintf(str_buff, get_string(STR_PRINTF_FRAMES), (uint16_t)game_get_framecount());
275
-        str_ascii(str_buff, x_off + 1, 0, 1);
280
+        str_ascii(str_buff, x_off, 0, 1);
276 281
 
277 282
         sprintf(str_buff, get_string(STR_PRINTF_TIMER), (uint16_t)timer_get());
278
-        str_ascii(str_buff, x_off + 1, 1, 1);
283
+        str_ascii(str_buff, x_off, 1, 1);
279 284
 
280 285
         return DEVICE_SCREEN_PX_WIDTH;
281 286
     } else {

+ 1
- 1
src/window.h View File

@@ -37,7 +37,7 @@ void win_conf(void) BANKED;
37 37
 void win_debug(void) BANKED;
38 38
 void win_name(int32_t score) BANKED;
39 39
 void win_name_draw(uint16_t name, uint8_t is_black, uint8_t pos) BANKED;
40
-uint8_t win_game_draw(int32_t score) BANKED;
40
+uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED;
41 41
 
42 42
 void win_str_center(const char *s, uint8_t y_off, uint8_t is_black);
43 43
 

Loading…
Cancel
Save