Browse Source

try to improve gb printer support

Thomas B 1 month ago
parent
commit
13c6ef566e
4 changed files with 27 additions and 14 deletions
  1. 4
    1
      src/gbprinter.c
  2. 13
    7
      src/main.c
  3. 9
    5
      src/window.c
  4. 1
    1
      src/window.h

+ 4
- 1
src/gbprinter.c View File

@@ -365,6 +365,9 @@ uint8_t gbprinter_screenshot(uint8_t win) BANKED {
365 365
     static uint8_t map_buff[2 * DEVICE_SCREEN_WIDTH];
366 366
     static uint8_t tile_buff[2 * DEVICE_SCREEN_WIDTH * 16];
367 367
 
368
+    printer_init();
369
+    printer_status = 0x00;
370
+
368 371
     uint8_t r = PRN_STATUS_OK;
369 372
 
370 373
     for (int y = 0; y < DEVICE_SCREEN_HEIGHT; y += 2) {
@@ -383,7 +386,7 @@ uint8_t gbprinter_screenshot(uint8_t win) BANKED {
383 386
 
384 387
         r = gbprinter_print_image(map_buff, tile_buff, 0, DEVICE_SCREEN_WIDTH, 2,
385 388
                                   (y == (DEVICE_SCREEN_HEIGHT - 2)) ? 1 : 0);
386
-        if (r != PRN_STATUS_OK) {
389
+        if ((r & ~PRN_STATUS_UNTRAN) != PRN_STATUS_OK) {
387 390
             break;
388 391
         }
389 392
     }

+ 13
- 7
src/main.c View File

@@ -64,20 +64,24 @@ const struct debug_entry debug_entries[DEBUG_ENTRY_COUNT] = {
64 64
     { .name = "0 scores", .flag = DBG_ZERO_SCORE,  .max = 1 }, // 8
65 65
 };
66 66
 
67
+static void list_scores(uint8_t is_black) NONBANKED {
68
+    for (uint8_t i = 0; i < SCORE_NUM; i++) {
69
+        struct scores score;
70
+        is_black ? score_lowest(i, &score) : score_highest(i, &score);
71
+        win_score_draw(score, i, is_black);
72
+    }
73
+}
74
+
67 75
 static void highscore(uint8_t is_black) NONBANKED {
68 76
     HIDE_WIN;
69 77
 
70 78
     move_win(MINWNDPOSX, MINWNDPOSY);
71 79
     hide_sprites_range(SPR_NUM_START, MAX_HARDWARE_SPRITES);
72
-    win_score_clear(is_black ? 1 : 0);
80
+    win_score_clear(is_black ? 1 : 0, 0);
73 81
 
74 82
     SHOW_WIN;
75 83
 
76
-    for (uint8_t i = 0; i < SCORE_NUM; i++) {
77
-        struct scores score;
78
-        is_black ? score_lowest(i, &score) : score_highest(i, &score);
79
-        win_score_draw(score, i, is_black);
80
-    }
84
+    list_scores(is_black);
81 85
 
82 86
     while (1) {
83 87
         key_read();
@@ -87,10 +91,12 @@ static void highscore(uint8_t is_black) NONBANKED {
87 91
         } else if (key_pressed(J_SELECT)) {
88 92
             uint8_t status = gbprinter_detect(PRINTER_DETECT_TIMEOUT);
89 93
             if (status == PRN_STATUS_OK) {
94
+                win_score_clear(is_black, 1);
95
+                list_scores(is_black);
90 96
                 status = gbprinter_screenshot(1);
91 97
             }
92 98
 
93
-            win_score_clear(2);
99
+            win_score_clear(2, 0);
94 100
             win_score_print(status);
95 101
             while (1) {
96 102
                 key_read();

+ 9
- 5
src/window.c View File

@@ -270,10 +270,14 @@ void win_splash_mp(void) BANKED {
270 270
     }
271 271
 }
272 272
 
273
-void win_score_clear(uint8_t is_black) BANKED {
274
-    set_win_based(0, 0,
275
-                  title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
276
-                  title_map_map, 0, BANK(title_map), title_map_MAP_ATTRIBUTES, BANK(title_map));
273
+void win_score_clear(uint8_t is_black, uint8_t no_bg) BANKED {
274
+    if (no_bg) {
275
+        fill_win(0, 0, DEVICE_SCREEN_WIDTH, DEVICE_SCREEN_HEIGHT, 1, 0x00);
276
+    } else {
277
+        set_win_based(0, 0,
278
+                      title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
279
+                      title_map_map, 0, BANK(title_map), title_map_MAP_ATTRIBUTES, BANK(title_map));
280
+    }
277 281
 
278 282
     if (is_black < 2) {
279 283
         str_center(is_black ? "black" : "white", 1, is_black);
@@ -296,7 +300,7 @@ void win_score_print(uint8_t status) BANKED {
296 300
         if (status == PRN_STATUS_OK) {
297 301
             str_ascii("success", 0, 7, 0);
298 302
         } else {
299
-            sprintf(buff, "error: %d", status);
303
+            sprintf(buff, "error: 0x%hx", (uint8_t)status);
300 304
             str_ascii(buff, 0, 7, 0);
301 305
         }
302 306
 

+ 1
- 1
src/window.h View File

@@ -27,7 +27,7 @@
27 27
 void win_init(uint8_t is_splash);
28 28
 void win_splash_draw(int32_t lowest, int32_t highest) BANKED;
29 29
 void win_splash_mp(void) BANKED;
30
-void win_score_clear(uint8_t is_black) BANKED;
30
+void win_score_clear(uint8_t is_black, uint8_t no_bg) BANKED;
31 31
 void win_score_draw(struct scores score, uint8_t off, uint8_t is_black) BANKED;
32 32
 void win_score_print(uint8_t status) BANKED;
33 33
 void win_about(void) BANKED;

Loading…
Cancel
Save