Browse Source

tweak connection status display

Thomas B 1 month ago
parent
commit
e55709b0f2
2 changed files with 36 additions and 37 deletions
  1. 1
    1
      src/main.c
  2. 35
    36
      src/window.c

+ 1
- 1
src/main.c View File

@@ -210,7 +210,7 @@ static void splash_win(void) NONBANKED {
210 210
 
211 211
         win_splash_draw(-low, high);
212 212
 
213
-        move_win(MINWNDPOSX, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - (8 * 4));
213
+        move_win(MINWNDPOSX, MINWNDPOSY);
214 214
     }
215 215
 
216 216
     SHOW_WIN;

+ 35
- 36
src/window.c View File

@@ -24,6 +24,7 @@
24 24
 
25 25
 #include "banks.h"
26 26
 #include "config.h"
27
+#include "gb/hardware.h"
27 28
 #include "score.h"
28 29
 #include "title_map.h"
29 30
 #include "bg_map.h"
@@ -127,10 +128,10 @@ static void character(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint
127 128
                        BANK(text_fnt16), is_black ? 0x82 : 0x81);
128 129
 }
129 130
 
130
-static void char_ascii(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off) {
131
+static void char_ascii(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t light) {
131 132
     set_win_based_attr(x_off + pos, y_off, 1, 1,
132 133
                        vincent_fnt8_map + c, 0,
133
-                       BANK(vincent_fnt8), 0x8B);
134
+                       BANK(vincent_fnt8), light ? 0x88 : 0x8B);
134 135
 }
135 136
 
136 137
 static void str3(uint16_t name, uint8_t x_off, uint8_t y_off,
@@ -172,15 +173,15 @@ static void str(const char *s, uint8_t x_off, uint8_t y_off, uint8_t is_black) {
172 173
     str_l(s, 0xFF, x_off, y_off, is_black);
173 174
 }
174 175
 
175
-static void str_ascii_l(const char *s, uint8_t len, uint8_t x_off, uint8_t y_off) {
176
+static void str_ascii_l(const char *s, uint8_t len, uint8_t x_off, uint8_t y_off, uint8_t light) {
176 177
     for (uint8_t n = 0; (*s) && (n < (2 * LINE_WIDTH)) && (n < len); n++) {
177 178
         char c = *(s++);
178
-        char_ascii(c, n, x_off, y_off);
179
+        char_ascii(c, n, x_off, y_off, light);
179 180
     }
180 181
 }
181 182
 
182
-static void str_ascii(const char *s, uint8_t x_off, uint8_t y_off) {
183
-    str_ascii_l(s, 0xFF, x_off, y_off);
183
+static void str_ascii(const char *s, uint8_t x_off, uint8_t y_off, uint8_t light) {
184
+    str_ascii_l(s, 0xFF, x_off, y_off, light);
184 185
 }
185 186
 
186 187
 static void str_center(const char *s, uint8_t y_off, uint8_t is_black) {
@@ -198,13 +199,13 @@ static void str_lines(const char *s, uint8_t y_off, uint8_t is_black) {
198 199
     }
199 200
 }
200 201
 
201
-static void str_ascii_lines(const char *s, uint8_t y_off) {
202
+static void str_ascii_lines(const char *s, uint8_t y_off, uint8_t light) {
202 203
     const char *nl = s;
203 204
     uint8_t lines = 0;
204 205
     do {
205 206
         // find next newline
206 207
         while (*nl && (*nl != '\n')) nl++;
207
-        str_ascii_l(s, nl - s, 0, y_off + lines);
208
+        str_ascii_l(s, nl - s, 0, y_off + lines, light);
208 209
         lines++;
209 210
         if (*nl) nl++;
210 211
         s = nl;
@@ -246,29 +247,27 @@ static void fill_win(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile, u
246 247
 }
247 248
 
248 249
 void win_splash_draw(int32_t lowest, int32_t highest) BANKED {
249
-    // reuse full black and white tiles at 0 and 1 from splash bg
250
-    fill_win(0, 0, 10, 4, 0, 0x00);
251
-    fill_win(10, 0, 10, 4, 1, 0x00);
250
+    set_win_based(0, 0,
251
+                  title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
252
+                  title_map_map, 0, BANK(title_map), title_map_MAP_ATTRIBUTES, BANK(title_map));
252 253
 
253 254
     // only show on splash if they fit
254 255
     if ((lowest <= 99999) && (highest <= 99999)) {
255
-        number(lowest, 0, 0, 1);
256
-        number(highest, 0xFE, 0, 0);
256
+        number(lowest, 0, DEVICE_SCREEN_HEIGHT - 4, 1);
257
+        number(highest, 0xFE, DEVICE_SCREEN_HEIGHT - 4, 0);
257 258
 
258
-        str("top", 0, 2, 1);
259
-        str("score", 10, 2, 0);
259
+        str("top", 0, DEVICE_SCREEN_HEIGHT - 2, 1);
260
+        str("score", 10, DEVICE_SCREEN_HEIGHT - 2, 0);
260 261
     }
261 262
 }
262 263
 
263 264
 void win_splash_mp(void) BANKED {
264
-    /*
265 265
     static uint8_t prev = 0;
266 266
     if ((_cpu == CGB_TYPE) && (mp_connection_status != prev)) {
267 267
         prev = mp_connection_status;
268
-        char c = (mp_connection_status & 0x01) ? 0x01 : 0x02;
269
-        str_ascii_l(&c, 1, 7, 2);
268
+        char c = mp_connection_status & 0x1F;
269
+        str_ascii_l(&c, 1, 19, 0, 1);
270 270
     }
271
-    */
272 271
 }
273 272
 
274 273
 void win_score_clear(uint8_t is_black) BANKED {
@@ -290,19 +289,19 @@ void win_score_print(uint8_t status) BANKED {
290 289
     static char buff[128];
291 290
 
292 291
     if (_cpu == CGB_TYPE) {
293
-        str_ascii("GB Printer", 0, 2);
294
-        str_ascii("Score Printout", 0, 3);
295
-        str_ascii("Result:", 0, 6);
292
+        str_ascii("GB Printer", 0, 2, 0);
293
+        str_ascii("Score Printout", 0, 3, 0);
294
+        str_ascii("Result:", 0, 6, 0);
296 295
 
297 296
         if (status == PRN_STATUS_OK) {
298
-            str_ascii("success", 0, 7);
297
+            str_ascii("success", 0, 7, 0);
299 298
         } else {
300 299
             sprintf(buff, "error: %d", status);
301
-            str_ascii(buff, 0, 7);
300
+            str_ascii(buff, 0, 7, 0);
302 301
         }
303 302
 
304 303
         gbprinter_error(status, buff);
305
-        str_ascii_lines(buff, 9);
304
+        str_ascii_lines(buff, 9, 0);
306 305
     } else {
307 306
         str("printout", 0, 4, 0);
308 307
         if (status == PRN_STATUS_OK) {
@@ -332,18 +331,18 @@ void win_about(void) BANKED {
332 331
     get_git(line_buff);
333 332
 
334 333
     if (_cpu == CGB_TYPE) {
335
-        str_ascii("Git Commit Hash:", 0, 6);
336
-        str_ascii(line_buff, 0, 7);
334
+        str_ascii("Git Commit Hash:", 0, 6, 0);
335
+        str_ascii(line_buff, 0, 7, 0);
337 336
 
338
-        str_ascii("Build Date:", 0, 10);
339
-        str_ascii(__DATE__, 0, 11);
340
-        str_ascii(__TIME__, 0, 12);
337
+        str_ascii("Build Date:", 0, 10, 0);
338
+        str_ascii(__DATE__, 0, 11, 0);
339
+        str_ascii(__TIME__, 0, 12, 0);
341 340
 
342
-        str_ascii("MP Tx:", 14, 11);
343
-        str_ascii("Wait", 14, 12);
341
+        str_ascii("MP Tx:", 14, 11, 1);
342
+        str_ascii("Wait", 14, 12, 1);
344 343
 
345
-        str_ascii("Visit:", 0, 15);
346
-        str_ascii("https://xythobuz.de", 0, 16);
344
+        str_ascii("Visit:", 0, 15, 0);
345
+        str_ascii("https://xythobuz.de", 0, 16, 0);
347 346
     } else {
348 347
         str_lines(line_buff, 7, 0);
349 348
 
@@ -359,8 +358,8 @@ void win_about_mp(void) BANKED {
359 358
     static uint8_t prev = 0;
360 359
     if ((_cpu == CGB_TYPE) && (mp_connection_status != prev)) {
361 360
         prev = mp_connection_status;
362
-        char c = (mp_connection_status & 0x01) ? 0x01 : 0x02;
363
-        str_ascii_l(&c, 1, 19, 12);
361
+        char c = mp_connection_status & 0x7F;
362
+        str_ascii_l(&c, 1, 19, 12, 1);
364 363
     }
365 364
 }
366 365
 

Loading…
Cancel
Save