|
@@ -22,22 +22,32 @@
|
22
|
22
|
#include "maps.h"
|
23
|
23
|
|
24
|
24
|
#include "gb/gb.h"
|
|
25
|
+#include "score.h"
|
25
|
26
|
#include "title_map.h"
|
26
|
27
|
#include "bg_map.h"
|
27
|
|
-#include "numbers.h"
|
|
28
|
+#include "numbers_fnt.h"
|
|
29
|
+#include "text_fnt.h"
|
28
|
30
|
|
29
|
31
|
#define MAX_DIGITS 7
|
30
|
32
|
|
31
|
33
|
// TODO inverted score color not visible on DMG
|
32
|
34
|
|
33
|
|
-const unsigned char num_attr_1[40] = {
|
|
35
|
+const unsigned char num_attr_1[104] = {
|
34
|
36
|
0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
35
|
37
|
0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
|
38
|
+ 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
|
39
|
+ 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
|
40
|
+ 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
|
41
|
+ 0x81,0x81,0x81,0x81,
|
36
|
42
|
};
|
37
|
43
|
|
38
|
|
-const unsigned char num_attr_2[40] = {
|
|
44
|
+const unsigned char num_attr_2[104] = {
|
|
45
|
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
|
|
46
|
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
|
|
47
|
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
|
39
|
48
|
0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
|
40
|
49
|
0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
|
|
50
|
+ 0x82,0x82,0x82,0x82,
|
41
|
51
|
};
|
42
|
52
|
|
43
|
53
|
const palette_color_t num_pal_inv[4] = {
|
|
@@ -45,6 +55,8 @@ const palette_color_t num_pal_inv[4] = {
|
45
|
55
|
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8(248,252,248), RGB8( 0, 0, 0)
|
46
|
56
|
};
|
47
|
57
|
|
|
58
|
+static uint8_t fnt_off = 0;
|
|
59
|
+
|
48
|
60
|
void map_title(void) NONBANKED {
|
49
|
61
|
SWITCH_ROM(BANK(title_map));
|
50
|
62
|
set_bkg_palette(OAMF_CGB_PAL0, title_map_PALETTE_COUNT, title_map_palettes);
|
|
@@ -61,11 +73,18 @@ void map_game(void) NONBANKED {
|
61
|
73
|
set_bkg_tiles(0, 0, bg_map_WIDTH / bg_map_TILE_W, bg_map_HEIGHT / bg_map_TILE_H, bg_map_map);
|
62
|
74
|
}
|
63
|
75
|
|
64
|
|
-void win_init(void) NONBANKED {
|
65
|
|
- SWITCH_ROM(BANK(numbers));
|
66
|
|
- set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT, numbers_PALETTE_COUNT, numbers_palettes);
|
67
|
|
- set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT + 1, numbers_PALETTE_COUNT, num_pal_inv);
|
68
|
|
- set_win_data(bg_map_TILE_COUNT, numbers_TILE_COUNT, numbers_tiles);
|
|
76
|
+void win_init(uint8_t is_splash) NONBANKED {
|
|
77
|
+ fnt_off = is_splash ? title_map_TILE_COUNT : bg_map_TILE_COUNT;
|
|
78
|
+
|
|
79
|
+ SWITCH_ROM(BANK(numbers_fnt));
|
|
80
|
+ set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, numbers_fnt_palettes);
|
|
81
|
+ set_bkg_palette(OAMF_CGB_PAL0 + bg_map_PALETTE_COUNT + numbers_fnt_PALETTE_COUNT, numbers_fnt_PALETTE_COUNT, num_pal_inv);
|
|
82
|
+ set_win_data(fnt_off, numbers_fnt_TILE_COUNT, numbers_fnt_tiles);
|
|
83
|
+
|
|
84
|
+ if (is_splash) {
|
|
85
|
+ SWITCH_ROM(BANK(text_fnt));
|
|
86
|
+ set_win_data(fnt_off + numbers_fnt_TILE_COUNT, text_fnt_TILE_COUNT, text_fnt_tiles);
|
|
87
|
+ }
|
69
|
88
|
}
|
70
|
89
|
|
71
|
90
|
static void set_win_based(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
|
|
@@ -76,18 +95,47 @@ static void set_win_based(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
|
76
|
95
|
set_win_based_tiles(x, y, w, h, tiles, base_tile);
|
77
|
96
|
}
|
78
|
97
|
|
79
|
|
-static void digit(uint8_t val, uint8_t digit, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
|
80
|
|
- SWITCH_ROM(BANK(numbers));
|
81
|
|
- uint8_t off = val * numbers_WIDTH / numbers_TILE_W;
|
|
98
|
+static void character(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
|
|
99
|
+ SWITCH_ROM(BANK(text_fnt));
|
|
100
|
+ uint8_t off = c * text_fnt_WIDTH / text_fnt_TILE_W;
|
|
101
|
+
|
|
102
|
+ set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off,
|
|
103
|
+ text_fnt_WIDTH / text_fnt_TILE_W, 1,
|
|
104
|
+ text_fnt_map + off, fnt_off + numbers_fnt_TILE_COUNT,
|
|
105
|
+ (is_black ? num_attr_2 : num_attr_1) + off);
|
|
106
|
+
|
|
107
|
+ set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off + 1,
|
|
108
|
+ text_fnt_WIDTH / text_fnt_TILE_W, 1,
|
|
109
|
+ text_fnt_map + off + (sizeof(text_fnt_map) / 2), fnt_off + numbers_fnt_TILE_COUNT,
|
|
110
|
+ (is_black ? num_attr_2 : num_attr_1) + off);
|
|
111
|
+}
|
|
112
|
+
|
|
113
|
+static void str3(uint16_t name, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
|
|
114
|
+ character((name >> 10) & 0x1F, 0, x_off, y_off, is_black);
|
|
115
|
+ character((name >> 5) & 0x1F, 1, x_off, y_off, is_black);
|
|
116
|
+ character((name >> 0) & 0x1F, 2, x_off, y_off, is_black);
|
|
117
|
+}
|
82
|
118
|
|
83
|
|
- set_win_based(x_off + (digit * numbers_WIDTH / numbers_TILE_W), y_off,
|
84
|
|
- numbers_WIDTH / numbers_TILE_W, 1,
|
85
|
|
- numbers_map + off, bg_map_TILE_COUNT,
|
|
119
|
+static void str(const char *s, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
|
|
120
|
+ uint8_t n = 0;
|
|
121
|
+ while (*s) {
|
|
122
|
+ character(*s - 'a', n++, x_off, y_off, is_black);
|
|
123
|
+ s++;
|
|
124
|
+ }
|
|
125
|
+}
|
|
126
|
+
|
|
127
|
+static void digit(uint8_t val, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
|
|
128
|
+ SWITCH_ROM(BANK(numbers_fnt));
|
|
129
|
+ uint8_t off = val * numbers_fnt_WIDTH / numbers_fnt_TILE_W;
|
|
130
|
+
|
|
131
|
+ set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off,
|
|
132
|
+ numbers_fnt_WIDTH / numbers_fnt_TILE_W, 1,
|
|
133
|
+ numbers_fnt_map + off, fnt_off,
|
86
|
134
|
(is_black ? num_attr_2 : num_attr_1) + off);
|
87
|
135
|
|
88
|
|
- set_win_based(x_off + (digit * numbers_WIDTH / numbers_TILE_W), y_off + 1,
|
89
|
|
- numbers_WIDTH / numbers_TILE_W, 1,
|
90
|
|
- numbers_map + off + (sizeof(numbers_map) / 2), bg_map_TILE_COUNT,
|
|
136
|
+ set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off + 1,
|
|
137
|
+ numbers_fnt_WIDTH / numbers_fnt_TILE_W, 1,
|
|
138
|
+ numbers_fnt_map + off + (sizeof(numbers_fnt_map) / 2), fnt_off,
|
91
|
139
|
(is_black ? num_attr_2 : num_attr_1) + off);
|
92
|
140
|
}
|
93
|
141
|
|
|
@@ -134,20 +182,22 @@ void win_splash_draw(int32_t lowest, int32_t highest) NONBANKED {
|
134
|
182
|
number(highest, 0xFE, 0, 0);
|
135
|
183
|
}
|
136
|
184
|
|
137
|
|
-void win_score_clear(void) NONBANKED {
|
|
185
|
+void win_score_clear(uint8_t is_black) NONBANKED {
|
138
|
186
|
SWITCH_ROM(BANK(title_map));
|
139
|
187
|
set_win_based(0, 0,
|
140
|
188
|
title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
|
141
|
189
|
title_map_map, 0, title_map_MAP_ATTRIBUTES);
|
|
190
|
+
|
|
191
|
+ str(is_black ? "black" : "white", 10 - 5, 1, is_black);
|
142
|
192
|
}
|
143
|
193
|
|
144
|
|
-void win_score_draw(int32_t score, uint8_t off, uint8_t is_black) NONBANKED {
|
145
|
|
- number(off, 1, 4 + off * 3, is_black);
|
146
|
|
- number(score, 5, 4 + off * 3, is_black);
|
|
194
|
+void win_score_draw(struct scores score, uint8_t off, uint8_t is_black) NONBANKED {
|
|
195
|
+ str3(score.name, 0, 4 + off * 3, is_black);
|
|
196
|
+ number(is_black ? -score.score : score.score, 7, 4 + off * 3, is_black);
|
147
|
197
|
}
|
148
|
198
|
|
149
|
199
|
uint8_t win_game_draw(int32_t score) NONBANKED {
|
150
|
|
- fill_win(0, 0, 10, 2, (uint8_t)bg_map_TILE_COUNT + (uint8_t)numbers_TILE_COUNT, 0x81);
|
|
200
|
+ fill_win(0, 0, 10, 2, fnt_off + numbers_fnt_TILE_COUNT, 0x81);
|
151
|
201
|
|
152
|
202
|
uint8_t is_black = 0;
|
153
|
203
|
if (score < 0) {
|