|
@@ -19,7 +19,8 @@
|
19
|
19
|
|
20
|
20
|
#include <gbdk/platform.h>
|
21
|
21
|
#include <string.h>
|
22
|
|
-#include "gb/gb.h"
|
|
22
|
+
|
|
23
|
+#include "banks.h"
|
23
|
24
|
#include "score.h"
|
24
|
25
|
#include "title_map.h"
|
25
|
26
|
#include "bg_map.h"
|
|
@@ -62,47 +63,54 @@ const palette_color_t num_pal_inv[4] = {
|
62
|
63
|
static uint8_t fnt_off = 0;
|
63
|
64
|
|
64
|
65
|
void map_title(void) NONBANKED {
|
65
|
|
- SWITCH_ROM(BANK(title_map));
|
66
|
|
- set_bkg_palette(OAMF_CGB_PAL0, title_map_PALETTE_COUNT, title_map_palettes);
|
67
|
|
- set_bkg_data(0, title_map_TILE_COUNT, title_map_tiles);
|
68
|
|
- set_bkg_attributes(0, 0, title_map_MAP_ATTRIBUTES_WIDTH, title_map_MAP_ATTRIBUTES_HEIGHT, title_map_MAP_ATTRIBUTES);
|
69
|
|
- set_bkg_tiles(0, 0, title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H, title_map_map);
|
|
66
|
+ START_ROM_BANK(BANK(title_map));
|
|
67
|
+ set_bkg_palette(OAMF_CGB_PAL0, title_map_PALETTE_COUNT, title_map_palettes);
|
|
68
|
+ set_bkg_data(0, title_map_TILE_COUNT, title_map_tiles);
|
|
69
|
+ set_bkg_attributes(0, 0, title_map_MAP_ATTRIBUTES_WIDTH, title_map_MAP_ATTRIBUTES_HEIGHT, title_map_MAP_ATTRIBUTES);
|
|
70
|
+ set_bkg_tiles(0, 0, title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H, title_map_map);
|
|
71
|
+ END_ROM_BANK();
|
70
|
72
|
}
|
71
|
73
|
|
72
|
74
|
void map_game(void) NONBANKED {
|
73
|
|
- SWITCH_ROM(BANK(bg_map));
|
74
|
|
- set_bkg_palette(OAMF_CGB_PAL0, bg_map_PALETTE_COUNT, bg_map_palettes);
|
75
|
|
- set_bkg_data(0, bg_map_TILE_COUNT, bg_map_tiles);
|
76
|
|
- set_bkg_attributes(0, 0, bg_map_MAP_ATTRIBUTES_WIDTH, bg_map_MAP_ATTRIBUTES_HEIGHT, bg_map_MAP_ATTRIBUTES);
|
77
|
|
- set_bkg_tiles(0, 0, bg_map_WIDTH / bg_map_TILE_W, bg_map_HEIGHT / bg_map_TILE_H, bg_map_map);
|
|
75
|
+ START_ROM_BANK(BANK(bg_map));
|
|
76
|
+ set_bkg_palette(OAMF_CGB_PAL0, bg_map_PALETTE_COUNT, bg_map_palettes);
|
|
77
|
+ set_bkg_data(0, bg_map_TILE_COUNT, bg_map_tiles);
|
|
78
|
+ set_bkg_attributes(0, 0, bg_map_MAP_ATTRIBUTES_WIDTH, bg_map_MAP_ATTRIBUTES_HEIGHT, bg_map_MAP_ATTRIBUTES);
|
|
79
|
+ set_bkg_tiles(0, 0, bg_map_WIDTH / bg_map_TILE_W, bg_map_HEIGHT / bg_map_TILE_H, bg_map_map);
|
|
80
|
+ END_ROM_BANK();
|
78
|
81
|
}
|
79
|
82
|
|
80
|
83
|
void win_init(uint8_t is_splash) NONBANKED {
|
81
|
84
|
fnt_off = is_splash ? title_map_TILE_COUNT : bg_map_TILE_COUNT;
|
82
|
85
|
|
83
|
|
- SWITCH_ROM(BANK(numbers_fnt));
|
84
|
|
- set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, numbers_fnt_palettes);
|
85
|
|
- set_win_data(fnt_off, numbers_fnt_TILE_COUNT, numbers_fnt_tiles);
|
|
86
|
+ START_ROM_BANK(BANK(numbers_fnt));
|
|
87
|
+ set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, numbers_fnt_palettes);
|
|
88
|
+ set_win_data(fnt_off, numbers_fnt_TILE_COUNT, numbers_fnt_tiles);
|
|
89
|
+ END_ROM_BANK();
|
86
|
90
|
|
87
|
|
- SWITCH_ROM(BANK(maps));
|
88
|
|
- set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT + numbers_fnt_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, num_pal_inv);
|
|
91
|
+ START_ROM_BANK_2(BANK(maps));
|
|
92
|
+ set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT + numbers_fnt_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, num_pal_inv);
|
|
93
|
+ END_ROM_BANK();
|
89
|
94
|
|
90
|
95
|
if (is_splash) {
|
91
|
|
- SWITCH_ROM(BANK(text_fnt));
|
92
|
|
- set_win_data(fnt_off + numbers_fnt_TILE_COUNT, text_fnt_TILE_COUNT, text_fnt_tiles);
|
|
96
|
+ START_ROM_BANK_2(BANK(text_fnt));
|
|
97
|
+ set_win_data(fnt_off + numbers_fnt_TILE_COUNT, text_fnt_TILE_COUNT, text_fnt_tiles);
|
|
98
|
+ END_ROM_BANK();
|
93
|
99
|
}
|
94
|
100
|
}
|
95
|
101
|
|
96
|
102
|
static void set_win_based(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
|
97
|
103
|
const uint8_t *tiles, uint8_t base_tile, uint8_t tile_bank,
|
98
|
104
|
const uint8_t *attributes, uint8_t attr_bank) NONBANKED {
|
99
|
|
- SWITCH_ROM(attr_bank);
|
100
|
|
- VBK_REG = VBK_ATTRIBUTES;
|
101
|
|
- set_win_tiles(x, y, w, h, attributes);
|
102
|
|
-
|
103
|
|
- SWITCH_ROM(tile_bank);
|
104
|
|
- VBK_REG = VBK_TILES;
|
105
|
|
- set_win_based_tiles(x, y, w, h, tiles, base_tile);
|
|
105
|
+ START_ROM_BANK(attr_bank);
|
|
106
|
+ VBK_REG = VBK_ATTRIBUTES;
|
|
107
|
+ set_win_tiles(x, y, w, h, attributes);
|
|
108
|
+ END_ROM_BANK();
|
|
109
|
+
|
|
110
|
+ START_ROM_BANK_2(tile_bank);
|
|
111
|
+ VBK_REG = VBK_TILES;
|
|
112
|
+ set_win_based_tiles(x, y, w, h, tiles, base_tile);
|
|
113
|
+ END_ROM_BANK();
|
106
|
114
|
}
|
107
|
115
|
|
108
|
116
|
static void character(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
|
|
@@ -243,9 +251,11 @@ void win_about(void) NONBANKED {
|
243
|
251
|
str_center("Duality", 0, 1);
|
244
|
252
|
str_center("xythobuz", 2, 1);
|
245
|
253
|
|
246
|
|
- SWITCH_ROM(BANK(git));
|
247
|
254
|
char line_buff[2 * LINE_WIDTH + 1] = {0};
|
248
|
|
- strncpy(line_buff, git_version, 2 * LINE_WIDTH);
|
|
255
|
+
|
|
256
|
+ START_ROM_BANK(BANK(git));
|
|
257
|
+ strncpy(line_buff, git_version, 2 * LINE_WIDTH);
|
|
258
|
+ END_ROM_BANK();
|
249
|
259
|
|
250
|
260
|
str_lines(line_buff, 7, 0);
|
251
|
261
|
|
|
@@ -265,16 +275,18 @@ void win_debug(void) NONBANKED {
|
265
|
275
|
|
266
|
276
|
str_center("Debug Menu", 0, 0);
|
267
|
277
|
|
268
|
|
- char name_buff[DEBUG_ENTRY_NAME_LEN + 2 + 1] = {0};
|
269
|
278
|
for (uint8_t i = 0; (i < DEBUG_ENTRY_COUNT) && (i < 7); i++) {
|
270
|
|
- SWITCH_ROM(BANK(main));
|
271
|
|
- strncpy(name_buff, debug_entries[i].name, DEBUG_ENTRY_NAME_LEN + 1);
|
272
|
|
-
|
273
|
|
- uint8_t n_len = strlen(name_buff);
|
274
|
|
- name_buff[n_len] = ' ';
|
275
|
|
- name_buff[n_len + 1] = (debug_flags & debug_entries[i].flag) ? '1' : '0';
|
276
|
|
- name_buff[n_len + 2] = '\0';
|
277
|
|
- n_len += 2;
|
|
279
|
+ char name_buff[DEBUG_ENTRY_NAME_LEN + 2 + 1] = {0};
|
|
280
|
+
|
|
281
|
+ START_ROM_BANK(BANK(main));
|
|
282
|
+ strncpy(name_buff, debug_entries[i].name, DEBUG_ENTRY_NAME_LEN + 1);
|
|
283
|
+
|
|
284
|
+ uint8_t n_len = strlen(name_buff);
|
|
285
|
+ name_buff[n_len] = ' ';
|
|
286
|
+ name_buff[n_len + 1] = (debug_flags & debug_entries[i].flag) ? '1' : '0';
|
|
287
|
+ name_buff[n_len + 2] = '\0';
|
|
288
|
+ n_len += 2;
|
|
289
|
+ END_ROM_BANK();
|
278
|
290
|
|
279
|
291
|
str(name_buff, (LINE_WIDTH - n_len) * 2, (i * 2) + 3, (debug_menu_index == i) ? 1 : 0);
|
280
|
292
|
}
|