Browse Source

add single debug value printing for dmg

Thomas B 7 hours ago
parent
commit
b22286dc16
2 changed files with 29 additions and 12 deletions
  1. 2
    2
      src/game.c
  2. 27
    10
      src/window.c

+ 2
- 2
src/game.c View File

@@ -121,7 +121,7 @@ static uint8_t pause_screen(void) {
121 121
         spr_draw(SPR_PAUSE, FLIP_NONE, 0, 0, (n < (PAUSE_BLINK_FRAMES / 2)) ? 0 : 1, &hiwater);
122 122
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
123 123
 
124
-        if ((_cpu == CGB_TYPE) && (conf_get()->debug_flags & DBG_OUT_ON)) {
124
+        if (conf_get()->debug_flags & DBG_OUT_ON) {
125 125
             uint8_t x_off = win_game_draw(game_state.score, 0);
126 126
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off,
127 127
                      MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
@@ -468,7 +468,7 @@ uint8_t game(enum GAME_MODE mode) BANKED {
468 468
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
469 469
 
470 470
         if ((game_state.score != prev_score)
471
-                || ((_cpu == CGB_TYPE) && (conf_get()->debug_flags & DBG_OUT_ON))) {
471
+                || (conf_get()->debug_flags & DBG_OUT_ON)) {
472 472
             uint8_t x_off = win_game_draw(game_state.score, 0);
473 473
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off,
474 474
                      MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);

+ 27
- 10
src/window.c View File

@@ -290,8 +290,7 @@ uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED {
290 290
         is_black = 1;
291 291
     }
292 292
 
293
-    // TODO support one debug value on DMG
294
-    if ((_cpu == CGB_TYPE) && (conf_get()->debug_flags & DBG_OUT_ON)) {
293
+    if (conf_get()->debug_flags & DBG_OUT_ON) {
295 294
         uint8_t redraw = 0;
296 295
 
297 296
         static int32_t prev_score = 0;
@@ -306,12 +305,18 @@ uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED {
306 305
         uint8_t x_off = number(score, 0, 0, is_black) >> 3;
307 306
         uint8_t y_off = 0;
308 307
 
308
+        uint8_t y_max = (_cpu == CGB_TYPE) ? 2 : 1;
309
+
309 310
         if ((conf_get()->debug_flags & DBG_SHOW_FPS) && (y_off < 2)) {
310 311
             static uint8_t prev_fps = 0;
311 312
             if ((game_fps != prev_fps) || redraw) {
312 313
                 prev_fps = game_fps;
313
-                sprintf(str_buff, get_string(STR_PRINTF_FPS), (uint8_t)game_fps);
314
-                str_ascii(str_buff, x_off, y_off, 1);
314
+                if (_cpu == CGB_TYPE) {
315
+                    sprintf(str_buff, get_string(STR_PRINTF_FPS), (uint8_t)game_fps);
316
+                    str_ascii(str_buff, x_off, y_off, 1);
317
+                } else {
318
+                    number(game_fps, x_off + 1, y_off, 1);
319
+                }
315 320
             }
316 321
             y_off++;
317 322
         }
@@ -320,8 +325,12 @@ uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED {
320 325
             static uint16_t prev_framecount = 0;
321 326
             if ((frame_count != prev_framecount) || redraw) {
322 327
                 prev_framecount = frame_count;
323
-                sprintf(str_buff, get_string(STR_PRINTF_FRAMES), (uint16_t)frame_count);
324
-                str_ascii(str_buff, x_off, y_off, 1);
328
+                if (_cpu == CGB_TYPE) {
329
+                    sprintf(str_buff, get_string(STR_PRINTF_FRAMES), (uint16_t)frame_count);
330
+                    str_ascii(str_buff, x_off, y_off, 1);
331
+                } else {
332
+                    number(frame_count, x_off + 1, y_off, 1);
333
+                }
325 334
             }
326 335
             y_off++;
327 336
         }
@@ -330,8 +339,12 @@ uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED {
330 339
             static uint16_t prev_timer = 0;
331 340
             uint16_t timer = timer_get();
332 341
             if ((timer != prev_timer) || redraw) {
333
-                sprintf(str_buff, get_string(STR_PRINTF_TIMER), (uint16_t)timer);
334
-                str_ascii(str_buff, x_off, y_off, 1);
342
+                if (_cpu == CGB_TYPE) {
343
+                    sprintf(str_buff, get_string(STR_PRINTF_TIMER), (uint16_t)timer);
344
+                    str_ascii(str_buff, x_off, y_off, 1);
345
+                } else {
346
+                    number(timer, x_off + 1, y_off, 1);
347
+                }
335 348
             }
336 349
             y_off++;
337 350
         }
@@ -341,8 +354,12 @@ uint8_t win_game_draw(int32_t score, uint8_t initial) BANKED {
341 354
             get_sp();
342 355
             if ((stack_pointer != prev_stack_pointer) || redraw) {
343 356
                 prev_stack_pointer = stack_pointer;
344
-                sprintf(str_buff, get_string(STR_PRINTF_STACK), (uint16_t)stack_pointer);
345
-                str_ascii(str_buff, x_off, y_off, 1);
357
+                if (_cpu == CGB_TYPE) {
358
+                    sprintf(str_buff, get_string(STR_PRINTF_STACK), (uint16_t)stack_pointer);
359
+                    str_ascii(str_buff, x_off, y_off, 1);
360
+                } else {
361
+                    number(stack_pointer, x_off + 1, y_off, 1);
362
+                }
346 363
             }
347 364
             y_off++;
348 365
         }

Loading…
Cancel
Save