Skip to content

Commit

Permalink
Merge branch 'porymap-6' into generate-map-constants
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards authored Dec 18, 2024
2 parents 94b8dc7 + b10c2f7 commit 587d494
Show file tree
Hide file tree
Showing 101 changed files with 822 additions and 986 deletions.
108 changes: 50 additions & 58 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,20 @@ ifneq (,$(MAKECMDGOALS))
endif
endif

.SHELLSTATUS ?= 0

ifeq ($(SETUP_PREREQS),1)
# If set on: Default target or a rule requiring a scan
# Forcibly execute `make tools` since we need them for what we are doing.
$(call infoshell, $(MAKE) -f make_tools.mk)
$(foreach line, $(shell $(MAKE) -f make_tools.mk | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
ifneq ($(.SHELLSTATUS),0)
$(error Errors occurred while building tools. See error messages above for more details)
endif
# Oh and also generate mapjson sources before we use `SCANINC`.
$(call infoshell, $(MAKE) generated)
$(foreach line, $(shell $(MAKE) generated | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
ifneq ($(.SHELLSTATUS),0)
$(error Errors occurred while generating map-related sources. See error messages above for more details)
endif
endif

# Collect sources
Expand Down Expand Up @@ -237,7 +245,10 @@ include spritesheet_rules.mk
include json_data_rules.mk
include audio_rules.mk

# NOTE: Tools must have been built prior (FIXME)
# so you can't really call this rule directly
generated: $(AUTO_GEN_TARGETS)
@: # Silence the "Nothing to be done for `generated'" message, which some people were confusing for an error.

%.s: ;
%.png: ;
Expand All @@ -252,8 +263,6 @@ generated: $(AUTO_GEN_TARGETS)
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@

# NOTE: Tools must have been built prior (FIXME)
generated: tools $(AUTO_GEN_TARGETS)
clean-generated:
@rm -f $(AUTO_GEN_TARGETS)
@echo "rm -f <AUTO_GEN_TARGETS>"
Expand Down Expand Up @@ -288,71 +297,52 @@ endif
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
# It doesn't look like $(shell) can be deferred so there might not be a better way (Icedude_907: there is soon).

# For C dependencies.
# Args: $1 = Output file without extension (build/assets/src/data), $2 = Input file (src/data.c)
define C_DEP
$(call C_DEP_IMPL,$1,$2,$1)
endef
# Internal implementation details.
# $1: Output file without extension, $2 input file, $3 temp path (if keeping)
define C_DEP_IMPL
$1.o: $2
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c
ifneq ($(KEEP_TEMPS),1)
@echo "$$(CC1) <flags> -o $$@ $$<"
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) -i $$< charmap.txt | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
@echo "$(CC1) <flags> -o $@ $<"
@$(CPP) $(CPPFLAGS) $< | $(PREPROC) -i $< charmap.txt | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
else
@$$(CPP) $$(CPPFLAGS) $$< -o $3.i
@$$(PREPROC) $3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $3.s
@echo -e ".text\n\t.align\t2, 0 @ Don't pad with nop\n" >> $3.s
$$(AS) $$(ASFLAGS) -o $$@ $3.s
@$(CPP) $(CPPFLAGS) $< -o $*.i
@$(PREPROC) $*.i charmap.txt | $(CC1) $(CFLAGS) -o $*.s
@echo -e ".text\n\t.align\t2, 0\n" >> $*.s
$(AS) $(ASFLAGS) -o $@ $*.s
endif
$1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2

$(C_BUILDDIR)/%.d: $(C_SUBDIR)/%.c
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $<

ifneq ($(NODEP),1)
$1.o: $1.d
-include $1.d
-include $(addprefix $(OBJ_DIR)/,$(C_SRCS:.c=.d))
endif
endef

# Create generic rules if no dependency scanning, else create the real rules
ifeq ($(NODEP),1)
$(eval $(call C_DEP,$(C_BUILDDIR)/%,$(C_SUBDIR)/%.c))
else
$(foreach src,$(C_SRCS),$(eval $(call C_DEP,$(OBJ_DIR)/$(basename $(src)),$(src))))
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s
$(AS) $(ASFLAGS) -o $@ $<

$(ASM_BUILDDIR)/%.d: $(ASM_SUBDIR)/%.s
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<

ifneq ($(NODEP),1)
-include $(addprefix $(OBJ_DIR)/,$(ASM_SRCS:.s=.d))
endif

# Similar methodology for Assembly files
# $1: Output path without extension, $2: Input file (`*.s`)
define ASM_DEP
$1.o: $2
$$(AS) $$(ASFLAGS) -o $$@ $$<
$(call ASM_SCANINC,$1,$2)
endef
# As above but first doing a preprocessor pass
define ASM_DEP_PREPROC
$1.o: $2
$$(PREPROC) $$< charmap.txt | $$(CPP) $(INCLUDE_SCANINC_ARGS) - | $$(PREPROC) -ie $$< charmap.txt | $$(AS) $$(ASFLAGS) -o $$@
$(call ASM_SCANINC,$1,$2)
endef

define ASM_SCANINC
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s
$(PREPROC) $< charmap.txt | $(CPP) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@

$(C_BUILDDIR)/%.d: $(C_SUBDIR)/%.s
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<

ifneq ($(NODEP),1)
$1.o: $1.d
$1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2
-include $1.d
-include $(addprefix $(OBJ_DIR)/,$(C_ASM_SRCS:.s=.d))
endif
endef

# Dummy rules or real rules
ifeq ($(NODEP),1)
$(eval $(call ASM_DEP,$(ASM_BUILDDIR)/%,$(ASM_SUBDIR)/%.s))
$(eval $(call ASM_DEP_PREPROC,$(C_BUILDDIR)/%,$(C_SUBDIR)/%.s))
$(eval $(call ASM_DEP_PREPROC,$(DATA_ASM_BUILDDIR)/%,$(DATA_ASM_SUBDIR)/%.s))
else
$(foreach src, $(ASM_SRCS), $(eval $(call ASM_DEP,$(src:%.s=$(OBJ_DIR)/%),$(src))))
$(foreach src, $(C_ASM_SRCS), $(eval $(call ASM_DEP_PREPROC,$(src:%.s=$(OBJ_DIR)/%),$(src))))
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call ASM_DEP_PREPROC,$(src:%.s=$(OBJ_DIR)/%),$(src))))
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
$(PREPROC) $< charmap.txt | $(CPP) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@

$(DATA_ASM_BUILDDIR)/%.d: $(DATA_ASM_SUBDIR)/%.s
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<

ifneq ($(NODEP),1)
-include $(addprefix $(OBJ_DIR)/,$(REGULAR_DATA_ASM_SRCS:.s=.d))
endif

$(OBJ_DIR)/sym_bss.ld: sym_bss.txt
Expand All @@ -376,8 +366,10 @@ endif
# Final rules

# Elf from object files
LDFLAGS = -Map ../../$(MAP)
$(ELF): $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(OBJS)
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat
@echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ <objs> <libs> | cat"
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION) --silent

# Builds the rom from the elf file
Expand Down
1 change: 0 additions & 1 deletion common_syms/AgbRfu_LinkManager.txt

This file was deleted.

10 changes: 0 additions & 10 deletions common_syms/agb_flash.txt

This file was deleted.

3 changes: 0 additions & 3 deletions common_syms/battle_anim_special.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/battle_controller_pokedude.txt

This file was deleted.

9 changes: 0 additions & 9 deletions common_syms/battle_main.txt

This file was deleted.

4 changes: 0 additions & 4 deletions common_syms/berry_fix_program.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/bg.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/cable_club.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/ereader_screen.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/event_data.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/evolution_scene.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/fame_checker.txt

This file was deleted.

3 changes: 0 additions & 3 deletions common_syms/field_camera.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/field_control_avatar.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/field_specials.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/fieldmap.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/help_system.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/help_system_util.txt

This file was deleted.

10 changes: 0 additions & 10 deletions common_syms/image_processing_effects.txt

This file was deleted.

5 changes: 0 additions & 5 deletions common_syms/librfu_rfu.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/librfu_sio32id.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/librfu_stwi.txt

This file was deleted.

35 changes: 0 additions & 35 deletions common_syms/link.txt

This file was deleted.

3 changes: 0 additions & 3 deletions common_syms/link_rfu_2.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/list_menu.txt

This file was deleted.

4 changes: 0 additions & 4 deletions common_syms/load_save.txt

This file was deleted.

12 changes: 0 additions & 12 deletions common_syms/m4a.txt

This file was deleted.

12 changes: 0 additions & 12 deletions common_syms/main.txt

This file was deleted.

8 changes: 0 additions & 8 deletions common_syms/overworld.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/party_menu.txt

This file was deleted.

4 changes: 0 additions & 4 deletions common_syms/quest_log.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/random.txt

This file was deleted.

12 changes: 0 additions & 12 deletions common_syms/save.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/save_failed_screen.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/scrcmd.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/sound.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/sprite.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/task.txt

This file was deleted.

1 change: 0 additions & 1 deletion common_syms/text.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/text_printer.txt

This file was deleted.

2 changes: 0 additions & 2 deletions common_syms/window.txt

This file was deleted.

1 change: 1 addition & 0 deletions include/constants/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Will be moved to build/ eventually
map_groups.h
layouts.h
region_map_sections.h
map_event_ids.h
Loading

0 comments on commit 587d494

Please sign in to comment.