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

+ 13
- 7
src/main.c View File

64
     { .name = "0 scores", .flag = DBG_ZERO_SCORE,  .max = 1 }, // 8
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
 static void highscore(uint8_t is_black) NONBANKED {
75
 static void highscore(uint8_t is_black) NONBANKED {
68
     HIDE_WIN;
76
     HIDE_WIN;
69
 
77
 
70
     move_win(MINWNDPOSX, MINWNDPOSY);
78
     move_win(MINWNDPOSX, MINWNDPOSY);
71
     hide_sprites_range(SPR_NUM_START, MAX_HARDWARE_SPRITES);
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
     SHOW_WIN;
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
     while (1) {
86
     while (1) {
83
         key_read();
87
         key_read();
87
         } else if (key_pressed(J_SELECT)) {
91
         } else if (key_pressed(J_SELECT)) {
88
             uint8_t status = gbprinter_detect(PRINTER_DETECT_TIMEOUT);
92
             uint8_t status = gbprinter_detect(PRINTER_DETECT_TIMEOUT);
89
             if (status == PRN_STATUS_OK) {
93
             if (status == PRN_STATUS_OK) {
94
+                win_score_clear(is_black, 1);
95
+                list_scores(is_black);
90
                 status = gbprinter_screenshot(1);
96
                 status = gbprinter_screenshot(1);
91
             }
97
             }
92
 
98
 
93
-            win_score_clear(2);
99
+            win_score_clear(2, 0);
94
             win_score_print(status);
100
             win_score_print(status);
95
             while (1) {
101
             while (1) {
96
                 key_read();
102
                 key_read();

+ 9
- 5
src/window.c View File

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
     if (is_black < 2) {
282
     if (is_black < 2) {
279
         str_center(is_black ? "black" : "white", 1, is_black);
283
         str_center(is_black ? "black" : "white", 1, is_black);
296
         if (status == PRN_STATUS_OK) {
300
         if (status == PRN_STATUS_OK) {
297
             str_ascii("success", 0, 7, 0);
301
             str_ascii("success", 0, 7, 0);
298
         } else {
302
         } else {
299
-            sprintf(buff, "error: %d", status);
303
+            sprintf(buff, "error: 0x%hx", (uint8_t)status);
300
             str_ascii(buff, 0, 7, 0);
304
             str_ascii(buff, 0, 7, 0);
301
         }
305
         }
302
 
306
 

+ 1
- 1
src/window.h View File

27
 void win_init(uint8_t is_splash);
27
 void win_init(uint8_t is_splash);
28
 void win_splash_draw(int32_t lowest, int32_t highest) BANKED;
28
 void win_splash_draw(int32_t lowest, int32_t highest) BANKED;
29
 void win_splash_mp(void) BANKED;
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
 void win_score_draw(struct scores score, uint8_t off, uint8_t is_black) BANKED;
31
 void win_score_draw(struct scores score, uint8_t off, uint8_t is_black) BANKED;
32
 void win_score_print(uint8_t status) BANKED;
32
 void win_score_print(uint8_t status) BANKED;
33
 void win_about(void) BANKED;
33
 void win_about(void) BANKED;

Loading…
Cancel
Save