Browse Source

use custom palettes to print scores

Thomas B 1 month ago
parent
commit
efed27d979
3 changed files with 9 additions and 7 deletions
  1. 2
    5
      src/gbprinter.c
  2. 6
    1
      src/gbprinter.h
  3. 1
    1
      src/main.c

+ 2
- 5
src/gbprinter.c View File

38
 #define PRN_BUSY_TIMEOUT   (2 * 60) // 2s
38
 #define PRN_BUSY_TIMEOUT   (2 * 60) // 2s
39
 #define PRN_PRINT_TIMEOUT  (20 * 60) // 20s
39
 #define PRN_PRINT_TIMEOUT  (20 * 60) // 20s
40
 
40
 
41
-#define PRN_PALETTE_NORMAL 0b11100100u
42
-#define PRN_PALETTE_INV    0b00011011u
43
-
44
 #define PRN_NO_MARGINS     0x00
41
 #define PRN_NO_MARGINS     0x00
45
 #define PRN_FINAL_MARGIN   0x03
42
 #define PRN_FINAL_MARGIN   0x03
46
 
43
 
172
     win_str_center(line_buff, y_pos, 0);
169
     win_str_center(line_buff, y_pos, 0);
173
 }
170
 }
174
 
171
 
175
-enum PRN_STATUS gbprinter_screenshot(uint8_t win) BANKED {
172
+enum PRN_STATUS gbprinter_screenshot(uint8_t win, uint8_t palette) BANKED {
176
     static uint8_t tile_buff[2 * DEVICE_SCREEN_WIDTH * 16];
173
     static uint8_t tile_buff[2 * DEVICE_SCREEN_WIDTH * 16];
177
     static struct prn_config params;
174
     static struct prn_config params;
178
     enum PRN_STATUS r = PRN_STATUS_OK;
175
     enum PRN_STATUS r = PRN_STATUS_OK;
222
 
219
 
223
     params.sheets = 1;
220
     params.sheets = 1;
224
     params.margins = PRN_FINAL_MARGIN;
221
     params.margins = PRN_FINAL_MARGIN;
225
-    params.palette = PRN_PALETTE_NORMAL;
222
+    params.palette = palette;
226
     params.exposure = PRN_EXPO_DARK;
223
     params.exposure = PRN_EXPO_DARK;
227
 
224
 
228
     printer_send_command(PRN_CMD_PRINT, (uint8_t *)&params, sizeof(struct prn_config));
225
     printer_send_command(PRN_CMD_PRINT, (uint8_t *)&params, sizeof(struct prn_config));

+ 6
- 1
src/gbprinter.h View File

45
     PRN_STATUS_MASK_ANY    = 0x7FF,
45
     PRN_STATUS_MASK_ANY    = 0x7FF,
46
 };
46
 };
47
 
47
 
48
+#define PRN_PALETTE_NORMAL 0b11100100u
49
+#define PRN_PALETTE_INV    0b00011011u
50
+#define PRN_PALETTE_SC_W   0b00110100u
51
+#define PRN_PALETTE_SC_B   0b00011100u
52
+
48
 enum PRN_STATUS gbprinter_detect(void) BANKED;
53
 enum PRN_STATUS gbprinter_detect(void) BANKED;
49
-enum PRN_STATUS gbprinter_screenshot(uint8_t win) BANKED;
54
+enum PRN_STATUS gbprinter_screenshot(uint8_t win, uint8_t palette) BANKED;
50
 
55
 
51
 uint8_t gbprinter_error(enum PRN_STATUS status, char *buff);
56
 uint8_t gbprinter_error(enum PRN_STATUS status, char *buff);
52
 
57
 

+ 1
- 1
src/main.c View File

93
             if (status == PRN_STATUS_OK) {
93
             if (status == PRN_STATUS_OK) {
94
                 win_score_clear(is_black, 1);
94
                 win_score_clear(is_black, 1);
95
                 list_scores(is_black);
95
                 list_scores(is_black);
96
-                status = gbprinter_screenshot(1);
96
+                status = gbprinter_screenshot(1, is_black ? PRN_PALETTE_SC_B : PRN_PALETTE_SC_W);
97
             }
97
             }
98
 
98
 
99
             win_score_clear(2, 0);
99
             win_score_clear(2, 0);

Loading…
Cancel
Save