Browse Source

tweak makefile and put acceleration logic back in bank 0 (crashed real hardware but worked in most emulators)

Thomas B 3 weeks ago
parent
commit
3f81694840
4 changed files with 20 additions and 18 deletions
  1. 2
    0
      .gitignore
  2. 15
    15
      Makefile
  3. 1
    1
      data/git.c_template
  4. 2
    2
      src/game.c

+ 2
- 0
.gitignore View File

@@ -1,3 +1,5 @@
1
+data/*.c
2
+data/*.h
1 3
 build
2 4
 *.gb
3 5
 .cache

+ 15
- 15
Makefile View File

@@ -28,12 +28,12 @@ DATA_DIR := data
28 28
 SRCS := $(wildcard $(SRC_DIR)/*.c)
29 29
 OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
30 30
 
31
-GIT := $(BUILD_DIR)/$(DATA_DIR)/git.c
32
-OBJS += $(GIT:%.c=%.o)
31
+GIT_GEN := $(DATA_DIR)/git.c
32
+OBJS += $(GIT_GEN:%.c=$(BUILD_DIR)/%.o)
33 33
 
34
-GEN_SRCS := $(BUILD_DIR)/$(DATA_DIR)/table_speed_shot.c
35
-GEN_SRCS += $(BUILD_DIR)/$(DATA_DIR)/table_speed_move.c
36
-OBJS += $(GEN_SRCS:%.c=%.o)
34
+GEN_SRCS := $(DATA_DIR)/table_speed_shot.c
35
+GEN_SRCS += $(DATA_DIR)/table_speed_move.c
36
+OBJS += $(GEN_SRCS:%.c=$(BUILD_DIR)/%.o)
37 37
 
38 38
 IMAGES := $(wildcard $(DATA_DIR)/*.png)
39 39
 SPRITES := $(IMAGES:%.png=$(BUILD_DIR)/%.c)
@@ -57,7 +57,7 @@ GBE_EMU := ~/bin/gbe/gbe_plus_qt.exe
57 57
 FLASHER := flashgbx
58 58
 
59 59
 LCCFLAGS := -Wa-l -Wl-m -Wp-MMD -Wf--opt-code-speed
60
-LCCFLAGS += -I$(SRC_DIR) -I$(BUILD_DIR)/$(DATA_DIR)
60
+LCCFLAGS += -I$(SRC_DIR) -I$(BUILD_DIR)/$(DATA_DIR) -I$(DATA_DIR)
61 61
 LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1B -Wm-yoA -Wm-ya1 -Wm-yc -Wm-ys
62 62
 LCCFLAGS += -autobank -Wb-ext=.rel -Wb-v -Wf-bo255
63 63
 
@@ -82,7 +82,7 @@ $(info BUILD_TYPE is $(BUILD_TYPE))
82 82
 DEPS=$(OBJS:%.o=%.d)
83 83
 -include $(DEPS)
84 84
 
85
-.PHONY: all run cloc sgb_run bgb_run gbe_run flash clean compile_commands.json usage $(GIT)
85
+.PHONY: all run cloc sgb_run bgb_run gbe_run flash clean compile_commands.json usage $(GIT_GEN)
86 86
 .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
87 87
 
88 88
 all: $(BIN)
@@ -99,20 +99,20 @@ compile_commands.json:
99 99
 	@bear --config bear.cfg -- make -j4
100 100
 	@rm -rf bear.cfg
101 101
 
102
-$(GIT): $(DATA_DIR)/git.c
102
+$(GIT_GEN): $(DATA_DIR)/git.c_template
103 103
 	@mkdir -p $(@D)
104 104
 	@echo Generating $@ from $<
105
-	@sed 's|GIT_VERSION|$(shell git describe --abbrev=7 --dirty --always --tags)|g' $< > $@
105
+	@sed 's|GIT_VERSION|"$(shell git describe --abbrev=7 --dirty --always --tags)"|g' $< > $@
106 106
 
107
-$(BUILD_DIR)/$(DATA_DIR)/table_speed_shot.c $(BUILD_DIR)/$(DATA_DIR)/table_speed_shot.h: util/gen_angles.py Makefile
107
+$(DATA_DIR)/table_speed_shot.c: util/gen_angles.py Makefile
108 108
 	@mkdir -p $(@D)
109 109
 	@echo Generating $@
110
-	@util/gen_angles.py -n table_speed_shot -d $(BUILD_DIR)/$(DATA_DIR) -s 16 -w 2 -f 0 -m 42 -t int8_t
110
+	@util/gen_angles.py -n table_speed_shot -d $(DATA_DIR) -s 16 -w 2 -f 0 -m 42 -t int8_t
111 111
 
112
-$(BUILD_DIR)/$(DATA_DIR)/table_speed_move.c $(BUILD_DIR)/$(DATA_DIR)/table_speed_move.h: util/gen_angles.py Makefile
112
+$(DATA_DIR)/table_speed_move.c: util/gen_angles.py Makefile
113 113
 	@mkdir -p $(@D)
114 114
 	@echo Generating $@
115
-	@util/gen_angles.py -n table_speed_move -d $(BUILD_DIR)/$(DATA_DIR) -s 16 -w 2 -f 0 -m 23 -t int8_t
115
+	@util/gen_angles.py -n table_speed_move -d $(DATA_DIR) -s 16 -w 2 -f 0 -m 23 -t int8_t
116 116
 
117 117
 usage: $(BUILD_DIR)/$(BIN)
118 118
 	@echo Analyzing $<
@@ -183,7 +183,7 @@ $(BUILD_DIR)/%.o: %.s $(ASSETS) Makefile
183 183
 	@echo Assembling $<
184 184
 	@$(LCC) $(LCCFLAGS) -c -o $@ $<
185 185
 
186
-$(BUILD_DIR)/$(BIN): $(OBJS) $(GIT) Makefile
186
+$(BUILD_DIR)/$(BIN): $(OBJS) Makefile
187 187
 	@echo Linking $@
188 188
 	@$(LCC) $(LCCFLAGS) -o $@ $(OBJS)
189 189
 
@@ -191,4 +191,4 @@ $(BIN): $(BUILD_DIR)/$(BIN) usage
191 191
 	@cp $< $@
192 192
 
193 193
 clean:
194
-	rm -rf $(BUILD_DIR) $(BIN)
194
+	rm -rf $(BUILD_DIR) $(BIN) $(DATA_DIR)/*.c $(DATA_DIR)/*.h

data/git.c → data/git.c_template View File

@@ -21,4 +21,4 @@
21 21
 
22 22
 BANKREF(git)
23 23
 
24
-const char git_version[] = "GIT_VERSION";
24
+const char git_version[] = GIT_VERSION;

+ 2
- 2
src/game.c View File

@@ -173,14 +173,14 @@ void game_set_mp_shot(struct mp_shot_state *state) NONBANKED {
173 173
     // TODO add shot
174 174
 }
175 175
 
176
-static void get_max_spd(int16_t *max_spd_x, int16_t *max_spd_y) NONBANKED {
176
+static inline void get_max_spd(int16_t *max_spd_x, int16_t *max_spd_y) NONBANKED {
177 177
     START_ROM_BANK(BANK(table_speed_move)) {
178 178
         *max_spd_x = table_speed_move[(rot * table_speed_move_WIDTH) + 0];
179 179
         *max_spd_y = -table_speed_move[(rot * table_speed_move_WIDTH) + 1];
180 180
     } END_ROM_BANK;
181 181
 }
182 182
 
183
-static void handle_acceleration(void) BANKED {
183
+static inline void handle_acceleration(void) NONBANKED {
184 184
     int16_t max_spd_x;
185 185
     int16_t max_spd_y;
186 186
     get_max_spd(&max_spd_x, &max_spd_y);

Loading…
Cancel
Save