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

+ 18
- 16
src/maps.c View File

32
 
32
 
33
 // TODO inverted score color not visible on DMG
33
 // TODO inverted score color not visible on DMG
34
 
34
 
35
+BANKREF(maps)
36
+
35
 const unsigned char num_attr_1[104] = {
37
 const unsigned char num_attr_1[104] = {
36
     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,
37
     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,
88
 }
90
 }
89
 
91
 
90
 static void set_win_based(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
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
     VBK_REG = VBK_ATTRIBUTES;
96
     VBK_REG = VBK_ATTRIBUTES;
93
     set_win_tiles(x, y, w, h, attributes);
97
     set_win_tiles(x, y, w, h, attributes);
98
+
99
+    SWITCH_ROM(tile_bank);
94
     VBK_REG = VBK_TILES;
100
     VBK_REG = VBK_TILES;
95
     set_win_based_tiles(x, y, w, h, tiles, base_tile);
101
     set_win_based_tiles(x, y, w, h, tiles, base_tile);
96
 }
102
 }
97
 
103
 
98
 static void character(uint8_t c, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
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
     uint8_t off = c * text_fnt_WIDTH / text_fnt_TILE_W;
105
     uint8_t off = c * text_fnt_WIDTH / text_fnt_TILE_W;
101
 
106
 
102
     set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off,
107
     set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off,
103
                   text_fnt_WIDTH / text_fnt_TILE_W, 1,
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
     set_win_based(x_off + (pos * text_fnt_WIDTH / text_fnt_TILE_W), y_off + 1,
112
     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,
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
 static void str3(uint16_t name, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
118
 static void str3(uint16_t name, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
132
 }
137
 }
133
 
138
 
134
 static void digit(uint8_t val, uint8_t pos, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
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
     uint8_t off = val * numbers_fnt_WIDTH / numbers_fnt_TILE_W;
140
     uint8_t off = val * numbers_fnt_WIDTH / numbers_fnt_TILE_W;
137
 
141
 
138
     set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off,
142
     set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off,
139
                   numbers_fnt_WIDTH / numbers_fnt_TILE_W, 1,
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
     set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off + 1,
147
     set_win_based(x_off + (pos * numbers_fnt_WIDTH / numbers_fnt_TILE_W), y_off + 1,
144
                   numbers_fnt_WIDTH / numbers_fnt_TILE_W, 1,
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
 static uint8_t number(int32_t score, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
153
 static uint8_t number(int32_t score, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
190
 }
194
 }
191
 
195
 
192
 void win_score_clear(uint8_t is_black) NONBANKED {
196
 void win_score_clear(uint8_t is_black) NONBANKED {
193
-    SWITCH_ROM(BANK(title_map));
194
     set_win_based(0, 0,
197
     set_win_based(0, 0,
195
                   title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
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
     str(is_black ? "black" : "white", 10 - 5, 1, is_black);
201
     str(is_black ? "black" : "white", 10 - 5, 1, is_black);
199
 }
202
 }
204
 }
207
 }
205
 
208
 
206
 void win_name(int32_t score) NONBANKED {
209
 void win_name(int32_t score) NONBANKED {
207
-    SWITCH_ROM(BANK(title_map));
208
     set_win_based(0, 0,
210
     set_win_based(0, 0,
209
                   title_map_WIDTH / title_map_TILE_W, title_map_HEIGHT / title_map_TILE_H,
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
     str("score", 10 - 5, 1, score < 0);
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
     str("enter", 10 - 5, 6, score < 0);
217
     str("enter", 10 - 5, 6, score < 0);
216
     str("name", 10 - 4, 8, score < 0);
218
     str("name", 10 - 4, 8, score < 0);

+ 2
- 0
src/maps.h View File

33
 void win_name(int32_t score);
33
 void win_name(int32_t score);
34
 uint8_t win_game_draw(int32_t score);
34
 uint8_t win_game_draw(int32_t score);
35
 
35
 
36
+BANKREF_EXTERN(maps)
37
+
36
 #endif // __MAPS_H__
38
 #endif // __MAPS_H__

+ 1
- 1
src/obj.c View File

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

Loading…
Cancel
Save