Browse Source

fix explosion and negative score

Thomas B 1 month ago
parent
commit
a506ccad37
4 changed files with 23 additions and 20 deletions
  1. 2
    3
      src/game.c
  2. 18
    16
      src/maps.c
  3. 2
    0
      src/maps.h
  4. 1
    1
      src/obj.c

+ 2
- 3
src/game.c View File

@@ -75,7 +75,7 @@ static void status(uint8_t health, uint8_t power, uint8_t *hiwater) NONBANKED {
75 75
     }
76 76
 }
77 77
 
78
-static void show_explosion(uint16_t power) {
78
+static void show_explosion(uint16_t power) NONBANKED {
79 79
     for (uint8_t n = 0; n < (4 * 4); n++) {
80 80
         uint8_t hiwater = SPR_NUM_START;
81 81
         spr_draw(SPR_EXPL, FLIP_NONE, 0, 0, n >> 2, &hiwater);
@@ -113,8 +113,7 @@ int32_t game(void) NONBANKED {
113 113
 
114 114
     // TODO remove
115 115
     obj_add(SPR_LIGHT, 64, 64, 0, 0);
116
-    //obj_add(SPR_DARK, -64, -64, 0, 0);
117
-    //obj_add(SPR_DARK, -32, 0, 0, 0);
116
+    obj_add(SPR_DARK, -64, -64, 0, 0);
118 117
     obj_add(SPR_SHOT_LIGHT, 32, 32, 0, 0);
119 118
     obj_add(SPR_SHOT_DARK, -32, -32, 0, 0);
120 119
 

+ 18
- 16
src/maps.c View File

@@ -32,6 +32,8 @@
32 32
 
33 33
 // TODO inverted score color not visible on DMG
34 34
 
35
+BANKREF(maps)
36
+
35 37
 const unsigned char num_attr_1[104] = {
36 38
     0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
37 39
     0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
@@ -88,26 +90,29 @@ void win_init(uint8_t is_splash) NONBANKED {
88 90
 }
89 91
 
90 92
 static void set_win_based(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
91
-                          const uint8_t *tiles, uint8_t base_tile, const uint8_t *attributes) NONBANKED {
93
+                          const uint8_t *tiles, uint8_t base_tile, uint8_t tile_bank,
94
+                          const uint8_t *attributes, uint8_t attr_bank) NONBANKED {
95
+    SWITCH_ROM(attr_bank);
92 96
     VBK_REG = VBK_ATTRIBUTES;
93 97
     set_win_tiles(x, y, w, h, attributes);
98
+
99
+    SWITCH_ROM(tile_bank);
94 100
     VBK_REG = VBK_TILES;
95 101
     set_win_based_tiles(x, y, w, h, tiles, base_tile);
96 102
 }
97 103
 
98 104
 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 105
     uint8_t off = c * text_fnt_WIDTH / text_fnt_TILE_W;
101 106
 
102 107
     set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off,
103 108
                   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);
109
+                  text_fnt_map + off, fnt_off + numbers_fnt_TILE_COUNT, BANK(text_fnt),
110
+                  (is_black ? num_attr_2 : num_attr_1) + off, BANK(maps));
106 111
 
107 112
     set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off + 1,
108 113
                   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);
114
+                  text_fnt_map + off + (sizeof(text_fnt_map) / 2), fnt_off + numbers_fnt_TILE_COUNT, BANK(text_fnt),
115
+                  (is_black ? num_attr_2 : num_attr_1) + off, BANK(maps));
111 116
 }
112 117
 
113 118
 static void str3(uint16_t name, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
@@ -132,18 +137,17 @@ static void str(const char *s, uint8_t x_off, uint8_t y_off, uint8_t is_black) N
132 137
 }
133 138
 
134 139
 static void digit(uint8_t val, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
135
-    SWITCH_ROM(BANK(numbers_fnt));
136 140
     uint8_t off = val * numbers_fnt_WIDTH / numbers_fnt_TILE_W;
137 141
 
138 142
     set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off,
139 143
                   numbers_fnt_WIDTH / numbers_fnt_TILE_W, 1,
140
-                  numbers_fnt_map + off, fnt_off,
141
-                  (is_black ? num_attr_2 : num_attr_1) + off);
144
+                  numbers_fnt_map + off, fnt_off, BANK(numbers_fnt),
145
+                  (is_black ? num_attr_2 : num_attr_1) + off, BANK(maps));
142 146
 
143 147
     set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off + 1,
144 148
                   numbers_fnt_WIDTH / numbers_fnt_TILE_W, 1,
145
-                  numbers_fnt_map + off + (sizeof(numbers_fnt_map) / 2), fnt_off,
146
-                  (is_black ? num_attr_2 : num_attr_1) + off);
149
+                  numbers_fnt_map + off + (sizeof(numbers_fnt_map) / 2), fnt_off, BANK(numbers_fnt),
150
+                  (is_black ? num_attr_2 : num_attr_1) + off, BANK(maps));
147 151
 }
148 152
 
149 153
 static uint8_t number(int32_t score, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
@@ -190,10 +194,9 @@ void win_splash_draw(int32_t lowest, int32_t highest) NONBANKED {
190 194
 }
191 195
 
192 196
 void win_score_clear(uint8_t is_black) NONBANKED {
193
-    SWITCH_ROM(BANK(title_map));
194 197
     set_win_based(0, 0,
195 198
                   title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
196
-                  title_map_map, 0, title_map_MAP_ATTRIBUTES);
199
+                  title_map_map, 0, BANK(title_map), title_map_MAP_ATTRIBUTES, BANK(title_map));
197 200
 
198 201
     str(is_black ? "black" : "white", 10 - 5, 1, is_black);
199 202
 }
@@ -204,13 +207,12 @@ void win_score_draw(struct scores score, uint8_t off, uint8_t is_black) NONBANKE
204 207
 }
205 208
 
206 209
 void win_name(int32_t score) NONBANKED {
207
-    SWITCH_ROM(BANK(title_map));
208 210
     set_win_based(0, 0,
209 211
                   title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
210
-                  title_map_map, 0, title_map_MAP_ATTRIBUTES);
212
+                  title_map_map, 0, BANK(title_map), title_map_MAP_ATTRIBUTES, BANK(title_map));
211 213
 
212 214
     str("score", 10 - 5, 1, score < 0);
213
-    number(score, 0xFF, 3, score < 0);
215
+    number(score < 0 ? -score : score, 0xFF, 3, score < 0);
214 216
 
215 217
     str("enter", 10 - 5, 6, score < 0);
216 218
     str("name", 10 - 4, 8, score < 0);

+ 2
- 0
src/maps.h View File

@@ -33,4 +33,6 @@ void win_score_draw(struct scores score, uint8_t off, uint8_t is_black);
33 33
 void win_name(int32_t score);
34 34
 uint8_t win_game_draw(int32_t score);
35 35
 
36
+BANKREF_EXTERN(maps)
37
+
36 38
 #endif // __MAPS_H__

+ 1
- 1
src/obj.c View File

@@ -59,7 +59,7 @@
59 59
 #define GRAVITY_RANGE (32 << POS_SCALE_OBJS)
60 60
 #define GRAVITY_SHIFT (POS_SCALE_OBJS + 4)
61 61
 #define DAMAGE_RANGE (16 << POS_SCALE_OBJS)
62
-#define DAMAGE_INC 3
62
+#define DAMAGE_INC 5
63 63
 
64 64
 #define PICKUP_SMALL_RANGE (10 << POS_SCALE_OBJS)
65 65
 #define PICKUP_LARGE_RANGE (16 << POS_SCALE_OBJS)

Loading…
Cancel
Save