Browse Source

add curly braces to bank-switch macros

Thomas B 1 month ago
parent
commit
541666aeb9
9 changed files with 75 additions and 62 deletions
  1. 2
    2
      src/banks.h
  2. 2
    2
      src/input.c
  3. 12
    12
      src/main.c
  4. 17
    8
      src/maps.c
  5. 2
    2
      src/sample.c
  6. 2
    2
      src/score.c
  7. 10
    8
      src/sound.c
  8. 6
    6
      src/sprites.c
  9. 22
    20
      src/window.c

+ 2
- 2
src/banks.h View File

22
 
22
 
23
 #include <gbdk/platform.h>
23
 #include <gbdk/platform.h>
24
 
24
 
25
-#define START_ROM_BANK_2(x) __previous__bank = CURRENT_BANK; SWITCH_ROM(x)
25
+#define START_ROM_BANK_2(x) __xyz_previous__bank = CURRENT_BANK; SWITCH_ROM(x); do
26
 #define START_ROM_BANK(x) uint8_t START_ROM_BANK_2(x)
26
 #define START_ROM_BANK(x) uint8_t START_ROM_BANK_2(x)
27
-#define END_ROM_BANK() SWITCH_ROM(__previous__bank)
27
+#define END_ROM_BANK while (0); SWITCH_ROM(__xyz_previous__bank);
28
 
28
 
29
 #endif // __BANKS_H__
29
 #endif // __BANKS_H__

+ 2
- 2
src/input.c View File

41
     joyp = joypad();
41
     joyp = joypad();
42
 
42
 
43
     if (debug_cnt < DEBUG_SEQUENCE_COUNT) {
43
     if (debug_cnt < DEBUG_SEQUENCE_COUNT) {
44
-        START_ROM_BANK(BANK(input));
44
+        START_ROM_BANK(BANK(input)) {
45
             if (key_pressed(key_debug_sequence[debug_cnt])) {
45
             if (key_pressed(key_debug_sequence[debug_cnt])) {
46
                 debug_cnt++;
46
                 debug_cnt++;
47
             } else if (key_pressed(0xFF)) {
47
             } else if (key_pressed(0xFF)) {
48
                 debug_cnt = 0;
48
                 debug_cnt = 0;
49
             }
49
             }
50
-        END_ROM_BANK();
50
+        } END_ROM_BANK
51
     } else {
51
     } else {
52
         if (key_pressed(0xFF ^ J_START)) {
52
         if (key_pressed(0xFF ^ J_START)) {
53
             debug_cnt = 0;
53
             debug_cnt = 0;

+ 12
- 12
src/main.c View File

138
             }
138
             }
139
             win_conf();
139
             win_conf();
140
         } else if (key_pressed(J_LEFT)) {
140
         } else if (key_pressed(J_LEFT)) {
141
-            START_ROM_BANK(BANK(main));
141
+            START_ROM_BANK(BANK(main)) {
142
                 if (*conf_entries[debug_menu_index].var > 0) {
142
                 if (*conf_entries[debug_menu_index].var > 0) {
143
                     (*conf_entries[debug_menu_index].var)--;
143
                     (*conf_entries[debug_menu_index].var)--;
144
                 } else {
144
                 } else {
145
                     *conf_entries[debug_menu_index].var = conf_entries[debug_menu_index].max;
145
                     *conf_entries[debug_menu_index].var = conf_entries[debug_menu_index].max;
146
                 }
146
                 }
147
                 conf_write_crc();
147
                 conf_write_crc();
148
-            END_ROM_BANK();
148
+            } END_ROM_BANK
149
             win_conf();
149
             win_conf();
150
         } else if (key_pressed(J_RIGHT)) {
150
         } else if (key_pressed(J_RIGHT)) {
151
-            START_ROM_BANK(BANK(main));
151
+            START_ROM_BANK(BANK(main)) {
152
                 if (*conf_entries[debug_menu_index].var < conf_entries[debug_menu_index].max) {
152
                 if (*conf_entries[debug_menu_index].var < conf_entries[debug_menu_index].max) {
153
                     (*conf_entries[debug_menu_index].var)++;
153
                     (*conf_entries[debug_menu_index].var)++;
154
                 } else {
154
                 } else {
155
                     *conf_entries[debug_menu_index].var = 0;
155
                     *conf_entries[debug_menu_index].var = 0;
156
                 }
156
                 }
157
                 conf_write_crc();
157
                 conf_write_crc();
158
-            END_ROM_BANK();
158
+            } END_ROM_BANK
159
             win_conf();
159
             win_conf();
160
         } else if (key_pressed(J_A) || key_pressed(J_B) || key_pressed(J_START)) {
160
         } else if (key_pressed(J_A) || key_pressed(J_B) || key_pressed(J_START)) {
161
             break;
161
             break;
353
                     snd_note_off();
353
                     snd_note_off();
354
                     splash_win();
354
                     splash_win();
355
                 } else if (key_pressed(J_LEFT)) {
355
                 } else if (key_pressed(J_LEFT)) {
356
-                    START_ROM_BANK(BANK(main));
356
+                    START_ROM_BANK(BANK(main)) {
357
                         if (debug_entries[debug_menu_index].flag != DBG_NONE) {
357
                         if (debug_entries[debug_menu_index].flag != DBG_NONE) {
358
                             conf_get()->debug_flags ^= debug_entries[debug_menu_index].flag;
358
                             conf_get()->debug_flags ^= debug_entries[debug_menu_index].flag;
359
                             conf_write_crc();
359
                             conf_write_crc();
365
                             }
365
                             }
366
                             switch_special = 1;
366
                             switch_special = 1;
367
                         }
367
                         }
368
-                    END_ROM_BANK();
368
+                    } END_ROM_BANK
369
                     splash_win();
369
                     splash_win();
370
                 } else if (key_pressed(J_RIGHT)) {
370
                 } else if (key_pressed(J_RIGHT)) {
371
-                    START_ROM_BANK(BANK(main));
371
+                    START_ROM_BANK(BANK(main)) {
372
                         if (debug_entries[debug_menu_index].flag != DBG_NONE) {
372
                         if (debug_entries[debug_menu_index].flag != DBG_NONE) {
373
                             conf_get()->debug_flags ^= debug_entries[debug_menu_index].flag;
373
                             conf_get()->debug_flags ^= debug_entries[debug_menu_index].flag;
374
                             conf_write_crc();
374
                             conf_write_crc();
380
                             }
380
                             }
381
                             switch_special = 1;
381
                             switch_special = 1;
382
                         }
382
                         }
383
-                    END_ROM_BANK();
383
+                    } END_ROM_BANK
384
                     splash_win();
384
                     splash_win();
385
                 } else if (key_pressed(J_A)) {
385
                 } else if (key_pressed(J_A)) {
386
-                    START_ROM_BANK(BANK(main));
386
+                    START_ROM_BANK(BANK(main)) {
387
                         if (debug_entries[debug_menu_index].flag != DBG_NONE) {
387
                         if (debug_entries[debug_menu_index].flag != DBG_NONE) {
388
                             conf_get()->debug_flags ^= debug_entries[debug_menu_index].flag;
388
                             conf_get()->debug_flags ^= debug_entries[debug_menu_index].flag;
389
                             conf_write_crc();
389
                             conf_write_crc();
395
                             }
395
                             }
396
                             switch_special = 1;
396
                             switch_special = 1;
397
                         }
397
                         }
398
-                    END_ROM_BANK();
398
+                    } END_ROM_BANK
399
                     splash_win();
399
                     splash_win();
400
                 } else if (key_pressed(J_B)) {
400
                 } else if (key_pressed(J_B)) {
401
                     conf_get()->debug_flags &= ~DBG_MENU;
401
                     conf_get()->debug_flags &= ~DBG_MENU;
530
 
530
 
531
     DISPLAY_ON;
531
     DISPLAY_ON;
532
 
532
 
533
-    START_ROM_BANK(BANK(border_sgb));
533
+    START_ROM_BANK(BANK(border_sgb)) {
534
         set_sgb_border((const uint8_t *)border_sgb_tiles, sizeof(border_sgb_tiles),
534
         set_sgb_border((const uint8_t *)border_sgb_tiles, sizeof(border_sgb_tiles),
535
                        (const uint8_t *)border_sgb_map, sizeof(border_sgb_map),
535
                        (const uint8_t *)border_sgb_map, sizeof(border_sgb_map),
536
                        (const uint8_t *)border_sgb_palettes, sizeof(border_sgb_palettes));
536
                        (const uint8_t *)border_sgb_palettes, sizeof(border_sgb_palettes));
537
-    END_ROM_BANK();
537
+    } END_ROM_BANK
538
 
538
 
539
     DISPLAY_OFF;
539
     DISPLAY_OFF;
540
 }
540
 }

+ 17
- 8
src/maps.c View File

4
  *
4
  *
5
  * Copyright (C) 2025 Thomas Buck <thomas@xythobuz.de>
5
  * Copyright (C) 2025 Thomas Buck <thomas@xythobuz.de>
6
  *
6
  *
7
+ * Based on examples from gbdk-2020:
8
+ * https://github.com/gbdk-2020/gbdk-2020/blob/develop/gbdk-lib/examples/cross-platform/large_map
9
+ *
7
  * This program is free software: you can redistribute it and/or modify
10
  * This program is free software: you can redistribute it and/or modify
8
  * it under the terms of the GNU General Public License as published by
11
  * it under the terms of the GNU General Public License as published by
9
  * the Free Software Foundation, either version 3 of the License, or
12
  * the Free Software Foundation, either version 3 of the License, or
17
  * See <http://www.gnu.org/licenses/>.
20
  * See <http://www.gnu.org/licenses/>.
18
  */
21
  */
19
 
22
 
23
+#include <assert.h>
24
+
20
 #include "banks.h"
25
 #include "banks.h"
21
 #include "title_map.h"
26
 #include "title_map.h"
22
 #include "bg_map.h"
27
 #include "bg_map.h"
23
 #include "util.h"
28
 #include "util.h"
24
 #include "maps.h"
29
 #include "maps.h"
25
 
30
 
31
+// currently this assumption is hard-coded
32
+static_assert(bg_map_WIDTH == 256, "bg_map needs to be 256x256");
33
+static_assert(bg_map_HEIGHT == 256, "bg_map needs to be 256x256");
34
+
26
 #define POS_SCALE_BG 6
35
 #define POS_SCALE_BG 6
27
 
36
 
28
 // define this to disable mirrored map scaling support
37
 // define this to disable mirrored map scaling support
52
 static uint8_t map_pos_x, map_pos_y, old_map_pos_x, old_map_pos_y;
61
 static uint8_t map_pos_x, map_pos_y, old_map_pos_x, old_map_pos_y;
53
 
62
 
54
 void map_title(void) NONBANKED {
63
 void map_title(void) NONBANKED {
55
-    START_ROM_BANK(BANK(title_map));
64
+    START_ROM_BANK(BANK(title_map)) {
56
 
65
 
57
         set_bkg_palette(OAMF_CGB_PAL0, title_map_PALETTE_COUNT, title_map_palettes);
66
         set_bkg_palette(OAMF_CGB_PAL0, title_map_PALETTE_COUNT, title_map_palettes);
58
         set_bkg_data(0, title_map_TILE_COUNT, title_map_tiles);
67
         set_bkg_data(0, title_map_TILE_COUNT, title_map_tiles);
76
                       title_map_HEIGHT / title_map_TILE_H,
85
                       title_map_HEIGHT / title_map_TILE_H,
77
                       title_map_map);
86
                       title_map_map);
78
 
87
 
79
-    END_ROM_BANK();
88
+    } END_ROM_BANK
80
 
89
 
81
     move_bkg(0, 0);
90
     move_bkg(0, 0);
82
 }
91
 }
83
 
92
 
84
 void map_game(void) NONBANKED {
93
 void map_game(void) NONBANKED {
85
-    START_ROM_BANK(BANK(bg_map));
94
+    START_ROM_BANK(BANK(bg_map)) {
86
 
95
 
87
         set_bkg_palette(OAMF_CGB_PAL0, bg_map_PALETTE_COUNT, bg_map_palettes);
96
         set_bkg_palette(OAMF_CGB_PAL0, bg_map_PALETTE_COUNT, bg_map_palettes);
88
         set_bkg_data(0, bg_map_TILE_COUNT, bg_map_tiles);
97
         set_bkg_data(0, bg_map_TILE_COUNT, bg_map_tiles);
130
 
139
 
131
 #endif // WRAP_BG
140
 #endif // WRAP_BG
132
 
141
 
133
-    END_ROM_BANK();
142
+    } END_ROM_BANK
134
 }
143
 }
135
 
144
 
136
 void map_move(int16_t delta_x, int16_t delta_y) NONBANKED {
145
 void map_move(int16_t delta_x, int16_t delta_y) NONBANKED {
148
     map_pos_y = (uint8_t)(camera_y >> 3u);
157
     map_pos_y = (uint8_t)(camera_y >> 3u);
149
     map_pos_x = (uint8_t)(camera_x >> 3u);
158
     map_pos_x = (uint8_t)(camera_x >> 3u);
150
 
159
 
151
-    START_ROM_BANK(BANK(bg_map));
160
+    START_ROM_BANK(BANK(bg_map)) {
152
 
161
 
153
         // up or down
162
         // up or down
154
         if (map_pos_y != old_map_pos_y) {
163
         if (map_pos_y != old_map_pos_y) {
155
             if (camera_y < old_camera_y) {
164
             if (camera_y < old_camera_y) {
156
                 set_bkg_sub(map_pos_x, map_pos_y,
165
                 set_bkg_sub(map_pos_x, map_pos_y,
157
-                            MIN(DEVICE_SCREEN_WIDTH + 1, bg_map_mapWidth-map_pos_x), 1,
166
+                            MIN(DEVICE_SCREEN_WIDTH + 1, bg_map_mapWidth - map_pos_x), 1,
158
                             bg_map_map, bg_map_MAP_ATTRIBUTES, bg_map_mapWidth);
167
                             bg_map_map, bg_map_MAP_ATTRIBUTES, bg_map_mapWidth);
159
             } else if ((bg_map_mapHeight - DEVICE_SCREEN_HEIGHT) > map_pos_y) {
168
             } else if ((bg_map_mapHeight - DEVICE_SCREEN_HEIGHT) > map_pos_y) {
160
                 set_bkg_sub(map_pos_x, map_pos_y + DEVICE_SCREEN_HEIGHT,
169
                 set_bkg_sub(map_pos_x, map_pos_y + DEVICE_SCREEN_HEIGHT,
161
-                            MIN(DEVICE_SCREEN_WIDTH + 1, bg_map_mapWidth-map_pos_x), 1,
170
+                            MIN(DEVICE_SCREEN_WIDTH + 1, bg_map_mapWidth - map_pos_x), 1,
162
                             bg_map_map, bg_map_MAP_ATTRIBUTES, bg_map_mapWidth);
171
                             bg_map_map, bg_map_MAP_ATTRIBUTES, bg_map_mapWidth);
163
             }
172
             }
164
             old_map_pos_y = map_pos_y;
173
             old_map_pos_y = map_pos_y;
178
             old_map_pos_x = map_pos_x;
187
             old_map_pos_x = map_pos_x;
179
         }
188
         }
180
 
189
 
181
-    END_ROM_BANK();
190
+    } END_ROM_BANK
182
 
191
 
183
     // set old camera position to current camera position
192
     // set old camera position to current camera position
184
     old_camera_x = camera_x;
193
     old_camera_x = camera_x;

+ 2
- 2
src/sample.c View File

80
     NR51_REG = 0xBB; // turn CH3 off in left and right pan
80
     NR51_REG = 0xBB; // turn CH3 off in left and right pan
81
     NR30_REG = 0x00; // turn DAC off
81
     NR30_REG = 0x00; // turn DAC off
82
 
82
 
83
-    START_ROM_BANK(play_bank);
83
+    START_ROM_BANK(play_bank) {
84
         // load waveforms
84
         // load waveforms
85
         for (uint8_t i = 0; i < 16; i++) {
85
         for (uint8_t i = 0; i < 16; i++) {
86
             _AUD3WAVERAM[i] = *(play_sample++);
86
             _AUD3WAVERAM[i] = *(play_sample++);
87
         }
87
         }
88
-    END_ROM_BANK();
88
+    } END_ROM_BANK
89
 
89
 
90
     NR30_REG = 0x80; // turn DAC on
90
     NR30_REG = 0x80; // turn DAC on
91
     NR31_REG = 0xFE; // length of wave, 2nd shortest
91
     NR31_REG = 0xFE; // length of wave, 2nd shortest

+ 2
- 2
src/score.c View File

128
 }
128
 }
129
 
129
 
130
 void score_reset(void) NONBANKED {
130
 void score_reset(void) NONBANKED {
131
-    START_ROM_BANK(BANK(score));
131
+    START_ROM_BANK(BANK(score)) {
132
         memcpy(conf_scores(), initial_scores, sizeof(struct scores) * SCORE_NUM * 2);
132
         memcpy(conf_scores(), initial_scores, sizeof(struct scores) * SCORE_NUM * 2);
133
-    END_ROM_BANK();
133
+    } END_ROM_BANK
134
     conf_write_crc();
134
     conf_write_crc();
135
 }
135
 }
136
 
136
 

+ 10
- 8
src/sound.c View File

65
 
65
 
66
 static void play_note(enum notes note) NONBANKED {
66
 static void play_note(enum notes note) NONBANKED {
67
     if (note < SILENCE) {
67
     if (note < SILENCE) {
68
-        START_ROM_BANK(BANK(sound));
69
-            uint16_t freq = frequencies[note];
70
-        END_ROM_BANK();
68
+        uint16_t freq;
69
+        START_ROM_BANK(BANK(sound)) {
70
+            freq = frequencies[note];
71
+        } END_ROM_BANK
71
 
72
 
72
         NR11_REG = 0x80 | duration; // 50% duty, higher value is shorter time (up to 0x3F)
73
         NR11_REG = 0x80 | duration; // 50% duty, higher value is shorter time (up to 0x3F)
73
         NR12_REG = (conf_get()->music_vol << 4) | 0x00; // given volume, no change
74
         NR12_REG = (conf_get()->music_vol << 4) | 0x00; // given volume, no change
78
 
79
 
79
 static void play_note2(enum notes note) NONBANKED {
80
 static void play_note2(enum notes note) NONBANKED {
80
     if (note < SILENCE) {
81
     if (note < SILENCE) {
81
-        START_ROM_BANK(BANK(sound));
82
-            uint16_t freq = frequencies[note];
83
-        END_ROM_BANK();
82
+        uint16_t freq;
83
+        START_ROM_BANK(BANK(sound)) {
84
+            freq = frequencies[note];
85
+        } END_ROM_BANK
84
 
86
 
85
         NR21_REG = 0x80 | duration; // 50% duty, higher value is shorter time (up to 0x3F)
87
         NR21_REG = 0x80 | duration; // 50% duty, higher value is shorter time (up to 0x3F)
86
         NR22_REG = (conf_get()->music_vol << 4) | 0x00; // given volume, no change
88
         NR22_REG = (conf_get()->music_vol << 4) | 0x00; // given volume, no change
151
         return;
153
         return;
152
     }
154
     }
153
 
155
 
154
-    START_ROM_BANK(bank);
156
+    START_ROM_BANK(bank) {
155
 
157
 
156
         uint16_t diff = timer_get() - last_t;
158
         uint16_t diff = timer_get() - last_t;
157
         if (diff >= music->duration) {
159
         if (diff >= music->duration) {
199
         }
201
         }
200
 
202
 
201
 end:
203
 end:
202
-    END_ROM_BANK();
204
+    } END_ROM_BANK
203
 }
205
 }

+ 6
- 6
src/sprites.c View File

26
 void spr_init(void) NONBANKED {
26
 void spr_init(void) NONBANKED {
27
     uint8_t off = TILE_NUM_START;
27
     uint8_t off = TILE_NUM_START;
28
     for (uint8_t i = 0; i < SPRITE_COUNT; i++) {
28
     for (uint8_t i = 0; i < SPRITE_COUNT; i++) {
29
-        START_ROM_BANK(metasprites[i].bank);
29
+        START_ROM_BANK(metasprites[i].bank) {
30
             if (metasprites[i].off == TILE_NUM_START) {
30
             if (metasprites[i].off == TILE_NUM_START) {
31
                 metasprites[i].off = off;
31
                 metasprites[i].off = off;
32
                 off += metasprites[i].cnt;
32
                 off += metasprites[i].cnt;
34
             } else {
34
             } else {
35
                 metasprites[i].off = metasprites[metasprites[i].off].off;
35
                 metasprites[i].off = metasprites[metasprites[i].off].off;
36
             }
36
             }
37
-        END_ROM_BANK();
37
+        } END_ROM_BANK
38
     }
38
     }
39
 }
39
 }
40
 
40
 
45
             bank = BANK(power_palettes);
45
             bank = BANK(power_palettes);
46
         }
46
         }
47
 
47
 
48
-        START_ROM_BANK(bank);
48
+        START_ROM_BANK(bank) {
49
             if ((metasprites[i].pa != NULL) && ((metasprites[i].pa_i & PALETTE_ALL_FLAGS) == PALETTE_PRELOAD)) {
49
             if ((metasprites[i].pa != NULL) && ((metasprites[i].pa_i & PALETTE_ALL_FLAGS) == PALETTE_PRELOAD)) {
50
                 set_sprite_palette(metasprites[i].pa_i, metasprites[i].pa_n, metasprites[i].pa);
50
                 set_sprite_palette(metasprites[i].pa_i, metasprites[i].pa_n, metasprites[i].pa);
51
             }
51
             }
52
-        END_ROM_BANK();
52
+        } END_ROM_BANK
53
     }
53
     }
54
 }
54
 }
55
 
55
 
60
         return;
60
         return;
61
     }
61
     }
62
 
62
 
63
-    START_ROM_BANK(metasprites[sprite].bank);
63
+    START_ROM_BANK(metasprites[sprite].bank) {
64
 
64
 
65
     if (frame >= metasprites[sprite].ms_n) {
65
     if (frame >= metasprites[sprite].ms_n) {
66
         frame = 0;
66
         frame = 0;
119
             break;
119
             break;
120
     }
120
     }
121
 
121
 
122
-    END_ROM_BANK();
122
+    } END_ROM_BANK
123
 }
123
 }
124
 
124
 
125
 void spr_ship(enum SPRITE_ROT rot, uint8_t moving, uint8_t *hiwater) NONBANKED {
125
 void spr_ship(enum SPRITE_ROT rot, uint8_t moving, uint8_t *hiwater) NONBANKED {

+ 22
- 20
src/window.c View File

49
 void win_init(uint8_t is_splash) NONBANKED {
49
 void win_init(uint8_t is_splash) NONBANKED {
50
     fnt_off = is_splash ? title_map_TILE_COUNT : bg_map_TILE_COUNT;
50
     fnt_off = is_splash ? title_map_TILE_COUNT : bg_map_TILE_COUNT;
51
 
51
 
52
-    START_ROM_BANK(BANK(numbers_fnt));
52
+    START_ROM_BANK(BANK(numbers_fnt)) {
53
         set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, numbers_fnt_palettes);
53
         set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, numbers_fnt_palettes);
54
         set_win_data(fnt_off, numbers_fnt_TILE_COUNT, numbers_fnt_tiles);
54
         set_win_data(fnt_off, numbers_fnt_TILE_COUNT, numbers_fnt_tiles);
55
-    END_ROM_BANK();
55
+    } END_ROM_BANK
56
 
56
 
57
-    START_ROM_BANK_2(BANK(window));
57
+    START_ROM_BANK_2(BANK(window)) {
58
         set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT + numbers_fnt_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, num_pal_inv);
58
         set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT + numbers_fnt_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, num_pal_inv);
59
-    END_ROM_BANK();
59
+    } END_ROM_BANK
60
 
60
 
61
     if (is_splash) {
61
     if (is_splash) {
62
-        START_ROM_BANK_2(BANK(text_fnt));
62
+        START_ROM_BANK_2(BANK(text_fnt)) {
63
             set_win_data(fnt_off + numbers_fnt_TILE_COUNT, text_fnt_TILE_COUNT, text_fnt_tiles);
63
             set_win_data(fnt_off + numbers_fnt_TILE_COUNT, text_fnt_TILE_COUNT, text_fnt_tiles);
64
-        END_ROM_BANK();
64
+        } END_ROM_BANK
65
     }
65
     }
66
 }
66
 }
67
 
67
 
69
                           const uint8_t *tiles, uint8_t base_tile, uint8_t tile_bank,
69
                           const uint8_t *tiles, uint8_t base_tile, uint8_t tile_bank,
70
                           const uint8_t *attributes, uint8_t attr_bank) NONBANKED {
70
                           const uint8_t *attributes, uint8_t attr_bank) NONBANKED {
71
     if (attributes != NULL) {
71
     if (attributes != NULL) {
72
-        START_ROM_BANK(attr_bank);
72
+        START_ROM_BANK(attr_bank) {
73
             VBK_REG = VBK_ATTRIBUTES;
73
             VBK_REG = VBK_ATTRIBUTES;
74
             set_win_tiles(x, y, w, h, attributes);
74
             set_win_tiles(x, y, w, h, attributes);
75
-        END_ROM_BANK();
75
+        } END_ROM_BANK
76
     } else {
76
     } else {
77
         VBK_REG = VBK_ATTRIBUTES;
77
         VBK_REG = VBK_ATTRIBUTES;
78
         fill_win_rect(x, y, w, h, 0x00);
78
         fill_win_rect(x, y, w, h, 0x00);
79
     }
79
     }
80
 
80
 
81
-    START_ROM_BANK(tile_bank);
81
+    START_ROM_BANK(tile_bank) {
82
         VBK_REG = VBK_TILES;
82
         VBK_REG = VBK_TILES;
83
         set_win_based_tiles(x, y, w, h, tiles, base_tile);
83
         set_win_based_tiles(x, y, w, h, tiles, base_tile);
84
-    END_ROM_BANK();
84
+    } END_ROM_BANK
85
 }
85
 }
86
 
86
 
87
 static void set_win_based_attr(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
87
 static void set_win_based_attr(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
90
     VBK_REG = VBK_ATTRIBUTES;
90
     VBK_REG = VBK_ATTRIBUTES;
91
     fill_win_rect(x, y, w, h, attr);
91
     fill_win_rect(x, y, w, h, attr);
92
 
92
 
93
-    START_ROM_BANK(tile_bank);
93
+    START_ROM_BANK(tile_bank) {
94
         VBK_REG = VBK_TILES;
94
         VBK_REG = VBK_TILES;
95
         set_win_based_tiles(x, y, w, h, tiles, base_tile);
95
         set_win_based_tiles(x, y, w, h, tiles, base_tile);
96
-    END_ROM_BANK();
96
+    } END_ROM_BANK
97
 }
97
 }
98
 
98
 
99
 static void character(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) {
99
 static void character(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) {
227
 }
227
 }
228
 
228
 
229
 static void get_git(char *line_buff) NONBANKED {
229
 static void get_git(char *line_buff) NONBANKED {
230
-    START_ROM_BANK(BANK(git));
230
+    START_ROM_BANK(BANK(git)) {
231
         strncpy(line_buff, git_version, 2 * LINE_WIDTH);
231
         strncpy(line_buff, git_version, 2 * LINE_WIDTH);
232
-    END_ROM_BANK();
232
+    } END_ROM_BANK
233
 }
233
 }
234
 
234
 
235
 void win_about(void) BANKED {
235
 void win_about(void) BANKED {
253
 }
253
 }
254
 
254
 
255
 static uint8_t get_debug(char *name_buff, uint8_t i) NONBANKED {
255
 static uint8_t get_debug(char *name_buff, uint8_t i) NONBANKED {
256
-    START_ROM_BANK(BANK(main));
256
+    uint8_t n_len;
257
+    START_ROM_BANK(BANK(main)) {
257
         strncpy(name_buff, debug_entries[i].name, ENTRY_NAME_LEN + 1);
258
         strncpy(name_buff, debug_entries[i].name, ENTRY_NAME_LEN + 1);
258
 
259
 
259
-        uint8_t n_len = strlen(name_buff);
260
+        n_len = strlen(name_buff);
260
         name_buff[n_len] = ' ';
261
         name_buff[n_len] = ' ';
261
         if (debug_entries[i].flag == DBG_NONE) {
262
         if (debug_entries[i].flag == DBG_NONE) {
262
             if (debug_menu_index == i) {
263
             if (debug_menu_index == i) {
269
         }
270
         }
270
         name_buff[n_len + 2] = '\0';
271
         name_buff[n_len + 2] = '\0';
271
         n_len += 2;
272
         n_len += 2;
272
-    END_ROM_BANK();
273
+    } END_ROM_BANK
273
     return n_len;
274
     return n_len;
274
 }
275
 }
275
 
276
 
292
 }
293
 }
293
 
294
 
294
 static uint8_t get_conf(char *name_buff, uint8_t i) NONBANKED {
295
 static uint8_t get_conf(char *name_buff, uint8_t i) NONBANKED {
295
-    START_ROM_BANK(BANK(main));
296
+    uint8_t n_len;
297
+    START_ROM_BANK(BANK(main)) {
296
         strncpy(name_buff, conf_entries[i].name, ENTRY_NAME_LEN + 1);
298
         strncpy(name_buff, conf_entries[i].name, ENTRY_NAME_LEN + 1);
297
 
299
 
298
-        uint8_t n_len = strlen(name_buff);
300
+        n_len = strlen(name_buff);
299
         name_buff[n_len] = ' ';
301
         name_buff[n_len] = ' ';
300
         if (*conf_entries[i].var < 10) {
302
         if (*conf_entries[i].var < 10) {
301
             name_buff[n_len + 1] = *conf_entries[i].var + '0';
303
             name_buff[n_len + 1] = *conf_entries[i].var + '0';
304
         }
306
         }
305
         name_buff[n_len + 2] = '\0';
307
         name_buff[n_len + 2] = '\0';
306
         n_len += 2;
308
         n_len += 2;
307
-    END_ROM_BANK();
309
+    } END_ROM_BANK
308
     return n_len;
310
     return n_len;
309
 }
311
 }
310
 
312
 

Loading…
Cancel
Save