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
+data/*.c
2
+data/*.h
1
 build
3
 build
2
 *.gb
4
 *.gb
3
 .cache
5
 .cache

+ 15
- 15
Makefile View File

28
 SRCS := $(wildcard $(SRC_DIR)/*.c)
28
 SRCS := $(wildcard $(SRC_DIR)/*.c)
29
 OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
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
 IMAGES := $(wildcard $(DATA_DIR)/*.png)
38
 IMAGES := $(wildcard $(DATA_DIR)/*.png)
39
 SPRITES := $(IMAGES:%.png=$(BUILD_DIR)/%.c)
39
 SPRITES := $(IMAGES:%.png=$(BUILD_DIR)/%.c)
57
 FLASHER := flashgbx
57
 FLASHER := flashgbx
58
 
58
 
59
 LCCFLAGS := -Wa-l -Wl-m -Wp-MMD -Wf--opt-code-speed
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
 LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1B -Wm-yoA -Wm-ya1 -Wm-yc -Wm-ys
61
 LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1B -Wm-yoA -Wm-ya1 -Wm-yc -Wm-ys
62
 LCCFLAGS += -autobank -Wb-ext=.rel -Wb-v -Wf-bo255
62
 LCCFLAGS += -autobank -Wb-ext=.rel -Wb-v -Wf-bo255
63
 
63
 
82
 DEPS=$(OBJS:%.o=%.d)
82
 DEPS=$(OBJS:%.o=%.d)
83
 -include $(DEPS)
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
 .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
86
 .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
87
 
87
 
88
 all: $(BIN)
88
 all: $(BIN)
99
 	@bear --config bear.cfg -- make -j4
99
 	@bear --config bear.cfg -- make -j4
100
 	@rm -rf bear.cfg
100
 	@rm -rf bear.cfg
101
 
101
 
102
-$(GIT): $(DATA_DIR)/git.c
102
+$(GIT_GEN): $(DATA_DIR)/git.c_template
103
 	@mkdir -p $(@D)
103
 	@mkdir -p $(@D)
104
 	@echo Generating $@ from $<
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
 	@mkdir -p $(@D)
108
 	@mkdir -p $(@D)
109
 	@echo Generating $@
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
 	@mkdir -p $(@D)
113
 	@mkdir -p $(@D)
114
 	@echo Generating $@
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
 usage: $(BUILD_DIR)/$(BIN)
117
 usage: $(BUILD_DIR)/$(BIN)
118
 	@echo Analyzing $<
118
 	@echo Analyzing $<
183
 	@echo Assembling $<
183
 	@echo Assembling $<
184
 	@$(LCC) $(LCCFLAGS) -c -o $@ $<
184
 	@$(LCC) $(LCCFLAGS) -c -o $@ $<
185
 
185
 
186
-$(BUILD_DIR)/$(BIN): $(OBJS) $(GIT) Makefile
186
+$(BUILD_DIR)/$(BIN): $(OBJS) Makefile
187
 	@echo Linking $@
187
 	@echo Linking $@
188
 	@$(LCC) $(LCCFLAGS) -o $@ $(OBJS)
188
 	@$(LCC) $(LCCFLAGS) -o $@ $(OBJS)
189
 
189
 
191
 	@cp $< $@
191
 	@cp $< $@
192
 
192
 
193
 clean:
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
 
21
 
22
 BANKREF(git)
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
     // TODO add shot
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
     START_ROM_BANK(BANK(table_speed_move)) {
177
     START_ROM_BANK(BANK(table_speed_move)) {
178
         *max_spd_x = table_speed_move[(rot * table_speed_move_WIDTH) + 0];
178
         *max_spd_x = table_speed_move[(rot * table_speed_move_WIDTH) + 0];
179
         *max_spd_y = -table_speed_move[(rot * table_speed_move_WIDTH) + 1];
179
         *max_spd_y = -table_speed_move[(rot * table_speed_move_WIDTH) + 1];
180
     } END_ROM_BANK;
180
     } END_ROM_BANK;
181
 }
181
 }
182
 
182
 
183
-static void handle_acceleration(void) BANKED {
183
+static inline void handle_acceleration(void) NONBANKED {
184
     int16_t max_spd_x;
184
     int16_t max_spd_x;
185
     int16_t max_spd_y;
185
     int16_t max_spd_y;
186
     get_max_spd(&max_spd_x, &max_spd_y);
186
     get_max_spd(&max_spd_x, &max_spd_y);

Loading…
Cancel
Save