diff --git a/Makefile b/Makefile index 3457bf2128..9ac7f25dc5 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ NM := $(MIPS_BINUTILS_PREFIX)nm OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump -IINC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I. +IINC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I. -I$(EXTRACTED_DIR) ifeq ($(KEEP_MDEBUG),0) RM_MDEBUG = $(OBJCOPY) --remove-section .mdebug $@ @@ -286,20 +286,34 @@ SEQUENCE_DEP_FILES := $(foreach f,$(SEQUENCE_O_FILES),$(f:.o=.d)) SEQUENCE_TABLE := include/tables/sequence_table.h -## Assets binaries (PNGs, JPGs, etc) -ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/audio*" -not -path "assets/c/*" -not -name "c" -not -path "assets/text") -# Prevents building C files that will be #include'd -ASSET_BIN_DIRS_C_FILES := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/code*" -not -path "assets/overlays*") +# create extracted directory +$(shell mkdir -p $(EXTRACTED_DIR)) +ifneq ($(wildcard $(EXTRACTED_DIR)/assets),) + ASSET_BIN_DIRS_EXTRACTED := $(shell find $(EXTRACTED_DIR)/assets -type d) +else + ASSET_BIN_DIRS_EXTRACTED := +endif +ASSET_BIN_DIRS_COMMITTED := $(shell find assets -type d -not -path "assets/xml*" -not -path "assets/audio*" -not -path assets/text) +ASSET_BIN_DIRS := $(ASSET_BIN_DIRS_EXTRACTED) $(ASSET_BIN_DIRS_COMMITTED) -ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin)) -ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_BIN:.bin=.bin.inc.c),$(BUILD_DIR)/$f) +ASSET_FILES_BIN_EXTRACTED := $(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.bin)) +ASSET_FILES_BIN_COMMITTED := $(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.bin)) +ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_BIN_EXTRACTED:.bin=.bin.inc.c),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \ + $(foreach f,$(ASSET_FILES_BIN_COMMITTED:.bin=.bin.inc.c),$(BUILD_DIR)/$f) \ + $(foreach f,$(wildcard assets/text/*.c),$(BUILD_DIR)/$(f:.c=.o)) -TEXTURE_FILES_PNG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.png)) -TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg)) -TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),$(BUILD_DIR)/$f) \ - $(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),$(BUILD_DIR)/$f) \ +TEXTURE_FILES_PNG_EXTRACTED := $(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.png)) +TEXTURE_FILES_PNG_COMMITTED := $(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.png)) +TEXTURE_FILES_JPG_EXTRACTED := $(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.jpg)) +TEXTURE_FILES_JPG_COMMITTED := $(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.jpg)) +TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG_EXTRACTED:.png=.inc.c),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \ + $(foreach f,$(TEXTURE_FILES_PNG_COMMITTED:.png=.inc.c),$(BUILD_DIR)/$f) \ + $(foreach f,$(TEXTURE_FILES_JPG_EXTRACTED:.jpg=.jpg.inc.c),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \ + $(foreach f,$(TEXTURE_FILES_JPG_COMMITTED:.jpg=.jpg.inc.c),$(BUILD_DIR)/$f) +ASSET_C_FILES_EXTRACTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.c))) +ASSET_C_FILES_COMMITTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.c))) C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard $(dir)/*.c)) S_FILES := $(shell grep -F "\$$(BUILD_DIR)/asm" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/') \ $(shell grep -F "\$$(BUILD_DIR)/data" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/') @@ -308,6 +322,8 @@ BASEROM_FILES := $(shell grep -F "\$$(BUILD_DIR)/baserom" spec | sed 's/.*$$(BU ARCHIVES_O := $(shell grep -F ".yar.o" spec | sed 's/.*include "// ; s/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.o/') O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \ $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \ + $(foreach f,$(ASSET_C_FILES_EXTRACTED:.c=.o),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \ + $(foreach f,$(ASSET_C_FILES_COMMITTED:.c=.o),$(BUILD_DIR)/$f) \ $(foreach f,$(BASEROM_FILES),$(BUILD_DIR)/$f.o) \ $(foreach f,$(ARCHIVES_O),$(BUILD_DIR)/$f) @@ -325,7 +341,7 @@ LD_FINAL_FILES := $(foreach f,$(shell find linker_scripts/final/*.ld),$(BUILD_DI DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d) # Other directories that need to be created in the build directory -OTHER_DIRS := baserom dmadata $(shell find linker_scripts -type d) +OTHER_DIRS := assets/text baserom dmadata $(shell find linker_scripts -type d) # create build directories $(shell mkdir -p $(foreach dir, \ @@ -339,14 +355,16 @@ $(shell mkdir -p $(foreach dir, \ $(SAMPLE_DIRS) \ $(SAMPLEBANK_DIRS) \ $(SOUNDFONT_DIRS) \ - $(SEQUENCE_DIRS), \ + $(SEQUENCE_DIRS) \ + $(ASSET_BIN_DIRS_COMMITTED),\ $(BUILD_DIR)/$(dir))) ifneq ($(wildcard $(EXTRACTED_DIR)/assets),) $(shell mkdir -p $(foreach dir, \ $(SAMPLE_EXTRACT_DIRS) \ $(SAMPLEBANK_EXTRACT_DIRS) \ $(SOUNDFONT_EXTRACT_DIRS) \ - $(SEQUENCE_EXTRACT_DIRS), \ + $(SEQUENCE_EXTRACT_DIRS) \ + $(ASSET_BIN_DIRS_EXTRACTED),\ $(dir:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%))) endif @@ -453,10 +471,9 @@ clean: $(RM) -r $(BUILD_DIR) assetclean: - $(RM) -r $(ASSET_BIN_DIRS) + $(RM) -r $(EXTRACTED_DIR)/assets + $(RM) -r $(EXTRACTED_DIR)/text $(RM) -r $(BUILD_DIR)/assets - $(RM) -r assets/text/*.h - $(RM) -r $(EXTRACTED_DIR)/.extracted-assets.json distclean: assetclean clean $(RM) -r asm data extracted @@ -480,8 +497,8 @@ setup-audio: $(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml assets: - $(PYTHON) tools/extract_assets.py $(EXTRACTED_DIR)/baserom assets -j$(N_THREADS) -Z Wno-hardcoded-pointer -v $(VERSION) - $(PYTHON) tools/text/msgdis.py $(EXTRACTED_DIR)/baserom assets/text -v $(VERSION) + $(PYTHON) tools/extract_assets.py $(EXTRACTED_DIR)/baserom $(EXTRACTED_DIR)/assets -j$(N_THREADS) -Z Wno-hardcoded-pointer -v $(VERSION) + $(PYTHON) tools/text/msgdis.py $(EXTRACTED_DIR)/baserom $(EXTRACTED_DIR)/text -v $(VERSION) $(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml ## Assembly generation @@ -544,6 +561,11 @@ $(BUILD_DIR)/assets/%.o: assets/%.c $(OBJCOPY_BIN) $(RM_MDEBUG) +$(BUILD_DIR)/assets/%.o: $(EXTRACTED_DIR)/assets/%.c + $(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $< + $(OBJCOPY_BIN) + $(RM_MDEBUG) + $(BUILD_DIR)/%.yar.o: $(BUILD_DIR)/%.o $(MAKEYAR) $< $(@:.yar.o=.yar.bin) $(@:.yar.o=.symbols.o) $(OBJCOPY) -I binary -O elf32-big $(@:.yar.o=.yar.bin) $@ @@ -603,12 +625,18 @@ $(BUILD_DIR)/%.o: %.c # Build C files from assets -$(BUILD_DIR)/%.inc.c: %.png +$(BUILD_DIR)/assets/%.inc.c: assets/%.png + $(ZAPD) btex -eh -tt $(subst .,,$(suffix $*)) -i $< -o $@ + +$(BUILD_DIR)/assets/%.inc.c: $(EXTRACTED_DIR)/assets/%.png $(ZAPD) btex -eh -tt $(subst .,,$(suffix $*)) -i $< -o $@ $(BUILD_DIR)/assets/%.bin.inc.c: assets/%.bin $(ZAPD) bblb -eh -i $< -o $@ +$(BUILD_DIR)/assets/%.bin.inc.c: $(EXTRACTED_DIR)/assets/%.bin + $(ZAPD) bblb -eh -i $< -o $@ + $(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg $(ZAPD) bren -eh -i $< -o $@ diff --git a/assets/.gitignore b/assets/.gitignore deleted file mode 100644 index 7e53529fcc..0000000000 --- a/assets/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -*.bin -*.c -*.h -*.cfg -*.vtx.inc -*.dlist.inc diff --git a/assets/c/archives/map_grand_static/map_grand_static.c b/assets/archives/map_grand_static/map_grand_static.c similarity index 100% rename from assets/c/archives/map_grand_static/map_grand_static.c rename to assets/archives/map_grand_static/map_grand_static.c diff --git a/assets/c/archives/map_grand_static/map_grand_static.h b/assets/archives/map_grand_static/map_grand_static.h similarity index 100% rename from assets/c/archives/map_grand_static/map_grand_static.h rename to assets/archives/map_grand_static/map_grand_static.h diff --git a/assets/c/archives/map_i_static/map_i_static.c b/assets/archives/map_i_static/map_i_static.c similarity index 100% rename from assets/c/archives/map_i_static/map_i_static.c rename to assets/archives/map_i_static/map_i_static.c diff --git a/assets/c/archives/map_i_static/map_i_static.h b/assets/archives/map_i_static/map_i_static.h similarity index 100% rename from assets/c/archives/map_i_static/map_i_static.h rename to assets/archives/map_i_static/map_i_static.h diff --git a/assets/c/.gitignore b/assets/c/.gitignore deleted file mode 100644 index 66dbd2b82e..0000000000 --- a/assets/c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -!*.c -!*.h diff --git a/assets/text/message_data.h b/assets/text/message_data.h new file mode 100644 index 0000000000..1b0ab444f7 --- /dev/null +++ b/assets/text/message_data.h @@ -0,0 +1,20 @@ +#include "text/message_data.h" + +/* + * The following two messages should be kept last and in this order. + * Message 0xFFFD must be last to not break the message debugger. + * Message 0xFFFC must be immediately before message 0xFFFD to not break Font_LoadOrderedFont. + */ + +DEFINE_MESSAGE(0xFFFC, 0x00, 0x00, +MSG( +HEADER(0x0000, 0xFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF) +) +) + +DEFINE_MESSAGE(0xFFFD, 0x00, 0x00, +MSG( +HEADER(0x0000, 0xFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF) +"end!" +) +) diff --git a/assets/text/message_data_staff.h b/assets/text/message_data_staff.h new file mode 100644 index 0000000000..c282d7f7d3 --- /dev/null +++ b/assets/text/message_data_staff.h @@ -0,0 +1 @@ +#include "text/message_data_staff.h" diff --git a/spec b/spec index 4491b07563..89c0766c8b 100644 --- a/spec +++ b/spec @@ -502,12 +502,12 @@ endseg beginseg name "map_i_static" - include "$(BUILD_DIR)/assets/c/archives/map_i_static/map_i_static.yar.o" + include "$(BUILD_DIR)/assets/archives/map_i_static/map_i_static.yar.o" endseg beginseg name "map_grand_static" - include "$(BUILD_DIR)/assets/c/archives/map_grand_static/map_grand_static.yar.o" + include "$(BUILD_DIR)/assets/archives/map_grand_static/map_grand_static.yar.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 23df30d9dd..be8ddcaa71 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -3,7 +3,7 @@ * Overlay: ovl_En_Thiefbird * Description: Takkuri */ - +#include "prevent_bss_reordering.h" #include "z_en_thiefbird.h" #include "overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h" diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index b343e14197..fe406ffaf8 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3,7 +3,7 @@ * Overlay: ovl_player_actor * Description: Player */ - +#include "prevent_bss_reordering.h" #include "z64player.h" #include "global.h" diff --git a/tools/extract_assets.py b/tools/extract_assets.py index 1bb345ab3b..8d5262ec73 100755 --- a/tools/extract_assets.py +++ b/tools/extract_assets.py @@ -104,6 +104,8 @@ def main(): baseromSegmentsDir: Path = args.baserom_segments_dir outputDir: Path = args.output_dir + args.output_dir.mkdir(parents=True, exist_ok=True) + global ZAPDArgs ZAPDArgs = "" if args.Z is not None: diff --git a/tools/progress.py b/tools/progress.py index 0ca0e707b8..e48656b7c1 100755 --- a/tools/progress.py +++ b/tools/progress.py @@ -108,11 +108,7 @@ def CalculateNonNamedAssets(mapFileList, assetsTracker): if not mapFile["name"].startswith("build/n64-us/assets/"): continue - if mapFile["name"].startswith("build/n64-us/assets/c"): - assetCat = mapFile["name"].split("/")[4] - else: - assetCat = mapFile["name"].split("/")[3] - + assetCat = mapFile["name"].split("/")[3] for symbol in mapFile["symbols"]: symbolName = symbol["name"] @@ -234,10 +230,8 @@ for line in map_file: if section == ".data" or section == ".rodata": if obj_file.startswith("build/n64-us/assets/"): - if obj_file.startswith("build/n64-us/assets/c"): - assetCat = obj_file.split("/")[4] - else: - assetCat = obj_file.split("/")[3] + + assetCat = obj_file.split("/")[3] if objFileName in fileSectionFixer: assetCat = fileSectionFixer[objFileName] diff --git a/tools/text/msgdis.py b/tools/text/msgdis.py index 264fdfb125..f11f9afbdb 100755 --- a/tools/text/msgdis.py +++ b/tools/text/msgdis.py @@ -3145,6 +3145,8 @@ def main(): baserom_segments_dir : Path = args.baserom_segments_dir output_dir : Path = args.output_dir + args.output_dir.mkdir(parents=True, exist_ok=True) + # TODO: use version config instead to get code vram code_vram = 0x800A5AC0 @@ -3171,10 +3173,9 @@ def main(): message_data = [] for text_id in sorted(messages.keys()): - # TODO: Add back when we start extracting assets to extracted - # if text_id in (0xFFFC,0xFFFD): - # # Skip committed text ids - # continue + if text_id in (0xFFFC,0xFFFD): + # Skip committed text ids + continue message_data.append(messages[text_id].decode()) message_data = "\n".join(message_data)