Browse Source

add single debug value printing for dmg

Thomas B 11 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
         spr_draw(SPR_PAUSE, FLIP_NONE, 0, 0, (n < (PAUSE_BLINK_FRAMES / 2)) ? 0 : 1, &hiwater);
121
         spr_draw(SPR_PAUSE, FLIP_NONE, 0, 0, (n < (PAUSE_BLINK_FRAMES / 2)) ? 0 : 1, &hiwater);
122
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
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
             uint8_t x_off = win_game_draw(game_state.score, 0);
125
             uint8_t x_off = win_game_draw(game_state.score, 0);
126
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off,
126
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off,
127
                      MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
127
                      MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
468
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
468
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
469
 
469
 
470
         if ((game_state.score != prev_score)
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
             uint8_t x_off = win_game_draw(game_state.score, 0);
472
             uint8_t x_off = win_game_draw(game_state.score, 0);
473
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off,
473
             move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off,
474
                      MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
474
                      MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);

+ 27
- 10
src/window.c View File

290
         is_black = 1;
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
         uint8_t redraw = 0;
294
         uint8_t redraw = 0;
296
 
295
 
297
         static int32_t prev_score = 0;
296
         static int32_t prev_score = 0;
306
         uint8_t x_off = number(score, 0, 0, is_black) >> 3;
305
         uint8_t x_off = number(score, 0, 0, is_black) >> 3;
307
         uint8_t y_off = 0;
306
         uint8_t y_off = 0;
308
 
307
 
308
+        uint8_t y_max = (_cpu == CGB_TYPE) ? 2 : 1;
309
+
309
         if ((conf_get()->debug_flags & DBG_SHOW_FPS) && (y_off < 2)) {
310
         if ((conf_get()->debug_flags & DBG_SHOW_FPS) && (y_off < 2)) {
310
             static uint8_t prev_fps = 0;
311
             static uint8_t prev_fps = 0;
311
             if ((game_fps != prev_fps) || redraw) {
312
             if ((game_fps != prev_fps) || redraw) {
312
                 prev_fps = game_fps;
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
             y_off++;
321
             y_off++;
317
         }
322
         }
320
             static uint16_t prev_framecount = 0;
325
             static uint16_t prev_framecount = 0;
321
             if ((frame_count != prev_framecount) || redraw) {
326
             if ((frame_count != prev_framecount) || redraw) {
322
                 prev_framecount = frame_count;
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
             y_off++;
335
             y_off++;
327
         }
336
         }
330
             static uint16_t prev_timer = 0;
339
             static uint16_t prev_timer = 0;
331
             uint16_t timer = timer_get();
340
             uint16_t timer = timer_get();
332
             if ((timer != prev_timer) || redraw) {
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
             y_off++;
349
             y_off++;
337
         }
350
         }
341
             get_sp();
354
             get_sp();
342
             if ((stack_pointer != prev_stack_pointer) || redraw) {
355
             if ((stack_pointer != prev_stack_pointer) || redraw) {
343
                 prev_stack_pointer = stack_pointer;
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
             y_off++;
364
             y_off++;
348
         }
365
         }

Loading…
Cancel
Save