diff --git a/Makefile b/Makefile index 89eeb21d27..6394f8daac 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ MKLDSCRIPT := tools/buildtools/mkldscript YAZ0 := tools/buildtools/yaz0 ZAPD := tools/ZAPD/ZAPD.out FADO := tools/fado/fado.elf +MAKEYAR := tools/buildtools/makeyar OPTFLAGS := -O2 -g3 ASFLAGS := -march=vr4300 -32 -Iinclude @@ -184,9 +185,11 @@ C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard S_FILES := $(shell grep -F "build/asm" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') \ $(shell grep -F "build/data" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') BASEROM_FILES := $(shell grep -F "build/baserom" spec | sed 's/.*build\/// ; s/\.o\".*//') +ARCHIVES_O := $(shell grep -F ".yar.o" spec | sed 's/.*include "// ; s/\.o\".*/.o/') O_FILES := $(foreach f,$(S_FILES:.s=.o),build/$f) \ $(foreach f,$(C_FILES:.c=.o),build/$f) \ - $(foreach f,$(BASEROM_FILES),build/$f.o) + $(foreach f,$(BASEROM_FILES),build/$f.o) \ + $(ARCHIVES_O) OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | grep -o '[^"]*_reloc.o' ) @@ -303,6 +306,7 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py + python3 tools/decompress_yars.py assets: python3 extract_assets.py -j $(N_THREADS) @@ -344,6 +348,10 @@ build/assets/%.o: assets/%.c $(OBJCOPY_BIN) $(RM_MDEBUG) +build/assets/archives/%.yar.o: build/assets/archives/%.o + $(MAKEYAR) $< $(@:.yar.o=.yar.bin) $(@:.yar.o=.symbols.o) + $(OBJCOPY) -I binary -O elf32-big $(@:.yar.o=.yar.bin) $@ + build/baserom/%.o: baserom/% $(OBJCOPY) -I binary -O elf32-big $< $@ @@ -392,3 +400,6 @@ build/assets/%.jpg.inc.c: assets/%.jpg $(ZAPD) bren -eh -i $< -o $@ -include $(DEP_FILES) + +# Print target for debugging +print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true diff --git a/assets/xml/archives/icon_item_24_static.xml b/assets/xml/archives/icon_item_24_static.xml new file mode 100644 index 0000000000..7b3b338a36 --- /dev/null +++ b/assets/xml/archives/icon_item_24_static.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/icon_item_static.xml b/assets/xml/archives/icon_item_static.xml new file mode 100644 index 0000000000..3084ab2a51 --- /dev/null +++ b/assets/xml/archives/icon_item_static.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/item_name_static.xml b/assets/xml/archives/item_name_static.xml new file mode 100644 index 0000000000..280d8862a5 --- /dev/null +++ b/assets/xml/archives/item_name_static.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/map_grand_static.xml b/assets/xml/archives/map_grand_static.xml new file mode 100644 index 0000000000..d5d80bdd6d --- /dev/null +++ b/assets/xml/archives/map_grand_static.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/map_i_static.xml b/assets/xml/archives/map_i_static.xml new file mode 100644 index 0000000000..dbb64185d8 --- /dev/null +++ b/assets/xml/archives/map_i_static.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/map_name_static.xml b/assets/xml/archives/map_name_static.xml new file mode 100644 index 0000000000..980eb890e2 --- /dev/null +++ b/assets/xml/archives/map_name_static.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/schedule_dma_static.xml b/assets/xml/archives/schedule_dma_static.xml new file mode 100644 index 0000000000..f3b7ba834e --- /dev/null +++ b/assets/xml/archives/schedule_dma_static.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/segment_symbols.h b/include/segment_symbols.h index d7c959d232..214970933b 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -52,12 +52,12 @@ DECLARE_ROM_SEGMENT(map_i_static) DECLARE_ROM_SEGMENT(map_grand_static) DECLARE_ROM_SEGMENT(item_name_static) DECLARE_ROM_SEGMENT(map_name_static) -DECLARE_ROM_SEGMENT(icon_item_static_test) -DECLARE_ROM_SEGMENT(icon_item_static_old) -DECLARE_ROM_SEGMENT(icon_item_24_static_test) -DECLARE_ROM_SEGMENT(icon_item_24_static_old) -DECLARE_ROM_SEGMENT(schedule_dma_static_test) -DECLARE_ROM_SEGMENT(schedule_dma_static_old) +DECLARE_ROM_SEGMENT(icon_item_static_yar) +DECLARE_ROM_SEGMENT(icon_item_static_syms) +DECLARE_ROM_SEGMENT(icon_item_24_static_yar) +DECLARE_ROM_SEGMENT(icon_item_24_static_syms) +DECLARE_ROM_SEGMENT(schedule_dma_static_yar) +DECLARE_ROM_SEGMENT(schedule_dma_static_syms) DECLARE_ROM_SEGMENT(schedule_static) DECLARE_ROM_SEGMENT(story_static) DECLARE_ROM_SEGMENT(do_action_static) diff --git a/include/tables/bombers_notebook/person_table.h b/include/tables/bombers_notebook/person_table.h index 71771956b0..e6ef49b273 100644 --- a/include/tables/bombers_notebook/person_table.h +++ b/include/tables/bombers_notebook/person_table.h @@ -9,23 +9,23 @@ * - Argument 4: Message id for the event meeting this person * - Argument 5: WeekEventFlag for the event meeting this person */ -/* 0x00 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMBERS, D_07009800, 0x21DD, BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS, 0x2147, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS) -/* 0x01 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJU, D_07000000, 0x21CA, BOMBERS_NOTEBOOK_EVENT_MET_ANJU, 0x2134, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJU) -/* 0x02 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAFEI, D_07000800, 0x21CB, BOMBERS_NOTEBOOK_EVENT_MET_KAFEI, 0x2135, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAFEI) -/* 0x03 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CURIOSITY_SHOP_MAN, D_07001000, 0x21CC, BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN, 0x2136, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN) -/* 0x04 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMB_SHOP_LADY, D_07001800, 0x21CD, BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY, 0x2137, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY) -/* 0x05 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROMANI, D_07002000, 0x21CE, BOMBERS_NOTEBOOK_EVENT_MET_ROMANI, 0x2138, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROMANI) -/* 0x06 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CREMIA, D_07002800, 0x21CF, BOMBERS_NOTEBOOK_EVENT_MET_CREMIA, 0x2139, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CREMIA) -/* 0x07 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MAYOR_DOTOUR, D_07003000, 0x21D0, BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR, 0x213A, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR) -/* 0x08 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MADAME_AROMA, D_07003800, 0x21D1, BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA, 0x213B, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA) -/* 0x09 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOTO, D_07004000, 0x21D2, BOMBERS_NOTEBOOK_EVENT_MET_TOTO, 0x213C, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOTO) -/* 0x0A */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN, D_07004800, 0x21D3, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN, 0x213D, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN) -/* 0x0B */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_POSTMAN, D_07005000, 0x21D4, BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN, 0x213E, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN) -/* 0x0C */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROSA_SISTERS, D_07005800, 0x21D5, BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS, 0x213F, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS) -/* 0x0D */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOILET_HAND, D_07006000, 0x21D6, BOMBERS_NOTEBOOK_EVENT_MET_TOLIET_HAND, 0x2140, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOILET_HAND) -/* 0x0E */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJUS_GRANDMOTHER, D_07006800, 0x21D7, BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER, 0x2141, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER) -/* 0x0F */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAMARO, D_07007000, 0x21D8, BOMBERS_NOTEBOOK_EVENT_MET_KAMARO, 0x2142, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAMARO) -/* 0x10 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GROG, D_07007800, 0x21D9, BOMBERS_NOTEBOOK_EVENT_MET_GROG, 0x2143, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GROG) -/* 0x11 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN_BROTHERS, D_07008000, 0x21DA, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS, 0x2144, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS) -/* 0x12 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_SHIRO, D_07008800, 0x21DB, BOMBERS_NOTEBOOK_EVENT_MET_SHIRO, 0x2145, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_SHIRO) -/* 0x13 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GURU_GURU, D_07009000, 0x21DC, BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU, 0x2146, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU) +/* 0x00 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMBERS, schedule_dma_static_yar_Blob_009800, 0x21DD, BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS, 0x2147, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS) +/* 0x01 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJU, schedule_dma_static_yar_Blob_000000, 0x21CA, BOMBERS_NOTEBOOK_EVENT_MET_ANJU, 0x2134, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJU) +/* 0x02 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAFEI, schedule_dma_static_yar_Blob_000800, 0x21CB, BOMBERS_NOTEBOOK_EVENT_MET_KAFEI, 0x2135, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAFEI) +/* 0x03 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CURIOSITY_SHOP_MAN, schedule_dma_static_yar_Blob_001000, 0x21CC, BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN, 0x2136, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN) +/* 0x04 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMB_SHOP_LADY, schedule_dma_static_yar_Blob_001800, 0x21CD, BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY, 0x2137, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY) +/* 0x05 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROMANI, schedule_dma_static_yar_Blob_002000, 0x21CE, BOMBERS_NOTEBOOK_EVENT_MET_ROMANI, 0x2138, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROMANI) +/* 0x06 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CREMIA, schedule_dma_static_yar_Blob_002800, 0x21CF, BOMBERS_NOTEBOOK_EVENT_MET_CREMIA, 0x2139, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CREMIA) +/* 0x07 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MAYOR_DOTOUR, schedule_dma_static_yar_Blob_003000, 0x21D0, BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR, 0x213A, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR) +/* 0x08 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MADAME_AROMA, schedule_dma_static_yar_Blob_003800, 0x21D1, BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA, 0x213B, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA) +/* 0x09 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOTO, schedule_dma_static_yar_Blob_004000, 0x21D2, BOMBERS_NOTEBOOK_EVENT_MET_TOTO, 0x213C, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOTO) +/* 0x0A */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN, schedule_dma_static_yar_Blob_004800, 0x21D3, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN, 0x213D, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN) +/* 0x0B */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_POSTMAN, schedule_dma_static_yar_Blob_005000, 0x21D4, BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN, 0x213E, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN) +/* 0x0C */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROSA_SISTERS, schedule_dma_static_yar_Blob_005800, 0x21D5, BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS, 0x213F, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS) +/* 0x0D */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOILET_HAND, schedule_dma_static_yar_Blob_006000, 0x21D6, BOMBERS_NOTEBOOK_EVENT_MET_TOLIET_HAND, 0x2140, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOILET_HAND) +/* 0x0E */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJUS_GRANDMOTHER, schedule_dma_static_yar_Blob_006800, 0x21D7, BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER, 0x2141, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER) +/* 0x0F */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAMARO, schedule_dma_static_yar_Blob_007000, 0x21D8, BOMBERS_NOTEBOOK_EVENT_MET_KAMARO, 0x2142, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAMARO) +/* 0x10 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GROG, schedule_dma_static_yar_Blob_007800, 0x21D9, BOMBERS_NOTEBOOK_EVENT_MET_GROG, 0x2143, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GROG) +/* 0x11 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN_BROTHERS, schedule_dma_static_yar_Blob_008000, 0x21DA, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS, 0x2144, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS) +/* 0x12 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_SHIRO, schedule_dma_static_yar_Blob_008800, 0x21DB, BOMBERS_NOTEBOOK_EVENT_MET_SHIRO, 0x2145, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_SHIRO) +/* 0x13 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GURU_GURU, schedule_dma_static_yar_Blob_009000, 0x21DC, BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU, 0x2146, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU) diff --git a/spec b/spec index a7b3ee5dcb..8d23d42dd8 100644 --- a/spec +++ b/spec @@ -276,15 +276,17 @@ beginseg endseg beginseg - name "icon_item_static_old" + name "icon_item_static_syms" romalign 0x1000 - include "build/baserom/icon_item_static_old.o" + include "build/assets/archives/icon_item_static/icon_item_static_yar.symbols.o" + number 8 endseg beginseg - name "icon_item_24_static_old" + name "icon_item_24_static_syms" romalign 0x1000 - include "build/baserom/icon_item_24_static_old.o" + include "build/assets/archives/icon_item_24_static/icon_item_24_static_yar.symbols.o" + number 9 endseg beginseg @@ -329,43 +331,47 @@ endseg beginseg name "map_i_static" - include "build/baserom/map_i_static.o" + include "build/assets/archives/map_i_static/map_i_static.yar.o" endseg beginseg name "map_grand_static" - include "build/baserom/map_grand_static.o" + include "build/assets/archives/map_grand_static/map_grand_static.yar.o" endseg beginseg name "item_name_static" - include "build/baserom/item_name_static.o" + include "build/assets/archives/item_name_static/item_name_static.yar.o" endseg beginseg name "map_name_static" - include "build/baserom/map_name_static.o" + include "build/assets/archives/map_name_static/map_name_static.yar.o" endseg beginseg - name "icon_item_static_test" - include "build/baserom/icon_item_static_test.o" + name "icon_item_static_yar" + include "build/assets/archives/icon_item_static/icon_item_static_yar.yar.o" + number 8 endseg beginseg - name "icon_item_24_static_test" - include "build/baserom/icon_item_24_static_test.o" + name "icon_item_24_static_yar" + include "build/assets/archives/icon_item_24_static/icon_item_24_static_yar.yar.o" + number 9 endseg beginseg - name "schedule_dma_static_old" - include "build/baserom/schedule_dma_static_old.o" + name "schedule_dma_static_syms" + include "build/assets/archives/schedule_dma_static/schedule_dma_static_yar.symbols.o" + number 7 endseg beginseg - name "schedule_dma_static_test" + name "schedule_dma_static_yar" increment 0x1000 - include "build/baserom/schedule_dma_static_test.o" + include "build/assets/archives/schedule_dma_static/schedule_dma_static_yar.yar.o" + number 7 endseg beginseg diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index e10290356f..1fbce712d0 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -1,5 +1,7 @@ #include "global.h" #include "interface/parameter_static/parameter_static.h" +#include "archives/icon_item_static/icon_item_static_yar.h" +#include "archives/icon_item_24_static/icon_item_24_static_yar.h" // Bit Flag array in which gBitFlags[n] is (1 << n) u32 gBitFlags[] = { @@ -95,139 +97,138 @@ u32 gGsFlagsShift[] = { 24, }; -// TODO: use symbols for these icon textures once textures are properly in C TexturePtr gItemIcons[] = { - 0x08000000, // ITEM_OCARINA - 0x08001000, // ITEM_BOW - 0x08002000, // ITEM_ARROW_FIRE - 0x08003000, // ITEM_ARROW_ICE - 0x08004000, // ITEM_ARROW_LIGHT - 0x08005000, // ITEM_OCARINA_FAIRY - 0x08006000, // ITEM_BOMB - 0x08007000, // ITEM_BOMBCHU - 0x08008000, // ITEM_STICK - 0x08009000, // ITEM_NUT - 0x0800A000, // ITEM_MAGIC_BEANS - 0x0800B000, // ITEM_SLINGSHOT - 0x0800C000, // ITEM_POWDER_KEG - 0x0800D000, // ITEM_PICTO_BOX - 0x0800E000, // ITEM_LENS - 0x0800F000, // ITEM_HOOKSHOT - 0x08010000, // ITEM_SWORD_GREAT_FAIRY - 0x08011000, // ITEM_LONGSHOT - 0x08012000, // ITEM_BOTTLE - 0x08013000, // ITEM_POTION_RED - 0x08014000, // ITEM_POTION_GREEN - 0x08015000, // ITEM_POTION_BLUE - 0x08016000, // ITEM_FAIRY - 0x08017000, // ITEM_DEKU_PRINCESS - 0x08018000, // ITEM_MILK_BOTTLE - 0x08019000, // ITEM_MILK_HALF - 0x0801A000, // ITEM_FISH - 0x0801B000, // ITEM_BUG - 0x0801C000, // ITEM_BLUE_FIRE - 0x0801D000, // ITEM_POE - 0x0801E000, // ITEM_BIG_POE - 0x0801F000, // ITEM_SPRING_WATER - 0x08020000, // ITEM_HOT_SPRING_WATER - 0x08021000, // ITEM_ZORA_EGG - 0x08022000, // ITEM_GOLD_DUST - 0x08023000, // ITEM_MUSHROOM - 0x08024000, // ITEM_SEAHORSE - 0x08025000, // ITEM_CHATEAU - 0x08026000, // ITEM_HYLIAN_LOACH - 0x08027000, // ITEM_OBABA_DRINK - 0x08028000, // ITEM_MOON_TEAR - 0x08029000, // ITEM_DEED_LAND - 0x0802A000, // ITEM_DEED_SWAMP - 0x0802B000, // ITEM_DEED_MOUNTAIN - 0x0802C000, // ITEM_DEED_OCEAN - 0x0802D000, // ITEM_ROOM_KEY - 0x0802E000, // ITEM_LETTER_MAMA - 0x0802F000, // ITEM_LETTER_TO_KAFEI - 0x08030000, // ITEM_PENDANT_OF_MEMORIES - 0x08031000, // ITEM_TINGLE_MAP - 0x08032000, // ITEM_MASK_DEKU - 0x08033000, // ITEM_MASK_GORON - 0x08034000, // ITEM_MASK_ZORA - 0x08035000, // ITEM_MASK_FIERCE_DEITY - 0x08036000, // ITEM_MASK_TRUTH - 0x08037000, // ITEM_MASK_KAFEIS_MASK - 0x08038000, // ITEM_MASK_ALL_NIGHT - 0x08039000, // ITEM_MASK_BUNNY - 0x0803A000, // ITEM_MASK_KEATON - 0x0803B000, // ITEM_MASK_GARO - 0x0803C000, // ITEM_MASK_ROMANI - 0x0803D000, // ITEM_MASK_CIRCUS_LEADER - 0x0803E000, // ITEM_MASK_POSTMAN - 0x0803F000, // ITEM_MASK_COUPLE - 0x08040000, // ITEM_MASK_GREAT_FAIRY - 0x08041000, // ITEM_MASK_GIBDO - 0x08042000, // ITEM_MASK_DON_GERO - 0x08043000, // ITEM_MASK_KAMARO - 0x08044000, // ITEM_MASK_CAPTAIN - 0x08045000, // ITEM_MASK_STONE - 0x08046000, // ITEM_MASK_BREMEN - 0x08047000, // ITEM_MASK_BLAST - 0x08048000, // ITEM_MASK_SCENTS - 0x08049000, // ITEM_MASK_GIANT - 0x0804A000, // ITEM_BOW_ARROW_FIRE - 0x0804B000, // ITEM_BOW_ARROW_ICE - 0x0804C000, // ITEM_BOW_ARROW_LIGHT - 0x0804D000, // ITEM_SWORD_KOKIRI - 0x0804E000, // ITEM_SWORD_RAZOR - 0x0804F000, // ITEM_SWORD_GILDED - 0x08050000, // ITEM_SWORD_DEITY - 0x08051000, // ITEM_SHIELD_HERO - 0x08052000, // ITEM_SHIELD_MIRROR - 0x08053000, // ITEM_QUIVER_30 - 0x08054000, // ITEM_QUIVER_40 - 0x08055000, // ITEM_QUIVER_50 - 0x08056000, // ITEM_BOMB_BAG_20 - 0x08057000, // ITEM_BOMB_BAG_30 - 0x08058000, // ITEM_BOMB_BAG_40 - 0x08059000, // ITEM_WALLET_DEFAULT - 0x0805A000, // ITEM_WALLET_ADULT - 0x0805B000, // ITEM_WALLET_GIANT - 0x0805C000, // ITEM_FISHING_ROD - 0x0805D000, // ITEM_REMAINS_ODOLWA - 0x0805E000, // ITEM_REMAINS_GOHT - 0x0805F000, // ITEM_REMAINS_GYORG - 0x08060000, // ITEM_REMAINS_TWINMOLD - 0x08062000, // ITEM_SONG_SONATA - 0x08062000, // ITEM_SONG_LULLABY - 0x08062000, // ITEM_SONG_NOVA - 0x08062000, // ITEM_SONG_ELEGY - 0x08062000, // ITEM_SONG_OATH - 0x08062000, // ITEM_SONG_SARIA - 0x08062000, // ITEM_SONG_TIME - 0x08062000, // ITEM_SONG_HEALING - 0x08062000, // ITEM_SONG_EPONA - 0x08062000, // ITEM_SONG_SOARING - 0x08062000, // ITEM_SONG_STORMS - 0x08062000, // ITEM_SONG_SUN - 0x08061000, // ITEM_BOMBERS_NOTEBOOK - 0x09000000, // ITEM_SKULL_TOKEN - 0x09000900, // ITEM_HEART_CONTAINER - 0x09001200, // ITEM_HEART_PIECE - 0x08062000, // - 0x08062000, // - 0x08062000, // ITEM_SONG_LULLABY_INTRO - 0x09003600, // ITEM_KEY_BOSS - 0x09004800, // ITEM_COMPASS - 0x09003F00, // ITEM_DUNGEON_MAP - 0x09005100, // ITEM_STRAY_FAIRIES - 0x09005A00, // ITEM_KEY_SMALL - 0x09006300, // ITEM_MAGIC_SMALL - 0x09006C00, // ITEM_MAGIC_LARGE - 0x08062180, // ITEM_HEART_PIECE_2 - 0x08062A80, // ITEM_INVALID_1 - 0x08063380, // ITEM_INVALID_2 - gOcarinaCUpTex, // ITEM_INVALID_3 - gOcarinaCDownTex, // ITEM_INVALID_4 - gOcarinaCLeftTex, // ITEM_INVALID_5 - gOcarinaCRightTex, // ITEM_INVALID_6 - gOcarinaATex, // ITEM_INVALID_7 + icon_item_static_yar_Blob_000000, // ITEM_OCARINA + icon_item_static_yar_Blob_001000, // ITEM_BOW + icon_item_static_yar_Blob_002000, // ITEM_ARROW_FIRE + icon_item_static_yar_Blob_003000, // ITEM_ARROW_ICE + icon_item_static_yar_Blob_004000, // ITEM_ARROW_LIGHT + icon_item_static_yar_Blob_005000, // ITEM_OCARINA_FAIRY + icon_item_static_yar_Blob_006000, // ITEM_BOMB + icon_item_static_yar_Blob_007000, // ITEM_BOMBCHU + icon_item_static_yar_Blob_008000, // ITEM_STICK + icon_item_static_yar_Blob_009000, // ITEM_NUT + icon_item_static_yar_Blob_00A000, // ITEM_MAGIC_BEANS + icon_item_static_yar_Blob_00B000, // ITEM_SLINGSHOT + icon_item_static_yar_Blob_00C000, // ITEM_POWDER_KEG + icon_item_static_yar_Blob_00D000, // ITEM_PICTO_BOX + icon_item_static_yar_Blob_00E000, // ITEM_LENS + icon_item_static_yar_Blob_00F000, // ITEM_HOOKSHOT + icon_item_static_yar_Blob_010000, // ITEM_SWORD_GREAT_FAIRY + icon_item_static_yar_Blob_011000, // ITEM_LONGSHOT + icon_item_static_yar_Blob_012000, // ITEM_BOTTLE + icon_item_static_yar_Blob_013000, // ITEM_POTION_RED + icon_item_static_yar_Blob_014000, // ITEM_POTION_GREEN + icon_item_static_yar_Blob_015000, // ITEM_POTION_BLUE + icon_item_static_yar_Blob_016000, // ITEM_FAIRY + icon_item_static_yar_Blob_017000, // ITEM_DEKU_PRINCESS + icon_item_static_yar_Blob_018000, // ITEM_MILK_BOTTLE + icon_item_static_yar_Blob_019000, // ITEM_MILK_HALF + icon_item_static_yar_Blob_01A000, // ITEM_FISH + icon_item_static_yar_Blob_01B000, // ITEM_BUG + icon_item_static_yar_Blob_01C000, // ITEM_BLUE_FIRE + icon_item_static_yar_Blob_01D000, // ITEM_POE + icon_item_static_yar_Blob_01E000, // ITEM_BIG_POE + icon_item_static_yar_Blob_01F000, // ITEM_SPRING_WATER + icon_item_static_yar_Blob_020000, // ITEM_HOT_SPRING_WATER + icon_item_static_yar_Blob_021000, // ITEM_ZORA_EGG + icon_item_static_yar_Blob_022000, // ITEM_GOLD_DUST + icon_item_static_yar_Blob_023000, // ITEM_MUSHROOM + icon_item_static_yar_Blob_024000, // ITEM_SEAHORSE + icon_item_static_yar_Blob_025000, // ITEM_CHATEAU + icon_item_static_yar_Blob_026000, // ITEM_HYLIAN_LOACH + icon_item_static_yar_Blob_027000, // ITEM_OBABA_DRINK + icon_item_static_yar_Blob_028000, // ITEM_MOON_TEAR + icon_item_static_yar_Blob_029000, // ITEM_DEED_LAND + icon_item_static_yar_Blob_02A000, // ITEM_DEED_SWAMP + icon_item_static_yar_Blob_02B000, // ITEM_DEED_MOUNTAIN + icon_item_static_yar_Blob_02C000, // ITEM_DEED_OCEAN + icon_item_static_yar_Blob_02D000, // ITEM_ROOM_KEY + icon_item_static_yar_Blob_02E000, // ITEM_LETTER_MAMA + icon_item_static_yar_Blob_02F000, // ITEM_LETTER_TO_KAFEI + icon_item_static_yar_Blob_030000, // ITEM_PENDANT_OF_MEMORIES + icon_item_static_yar_Blob_031000, // ITEM_TINGLE_MAP + icon_item_static_yar_Blob_032000, // ITEM_MASK_DEKU + icon_item_static_yar_Blob_033000, // ITEM_MASK_GORON + icon_item_static_yar_Blob_034000, // ITEM_MASK_ZORA + icon_item_static_yar_Blob_035000, // ITEM_MASK_FIERCE_DEITY + icon_item_static_yar_Blob_036000, // ITEM_MASK_TRUTH + icon_item_static_yar_Blob_037000, // ITEM_MASK_KAFEIS_MASK + icon_item_static_yar_Blob_038000, // ITEM_MASK_ALL_NIGHT + icon_item_static_yar_Blob_039000, // ITEM_MASK_BUNNY + icon_item_static_yar_Blob_03A000, // ITEM_MASK_KEATON + icon_item_static_yar_Blob_03B000, // ITEM_MASK_GARO + icon_item_static_yar_Blob_03C000, // ITEM_MASK_ROMANI + icon_item_static_yar_Blob_03D000, // ITEM_MASK_CIRCUS_LEADER + icon_item_static_yar_Blob_03E000, // ITEM_MASK_POSTMAN + icon_item_static_yar_Blob_03F000, // ITEM_MASK_COUPLE + icon_item_static_yar_Blob_040000, // ITEM_MASK_GREAT_FAIRY + icon_item_static_yar_Blob_041000, // ITEM_MASK_GIBDO + icon_item_static_yar_Blob_042000, // ITEM_MASK_DON_GERO + icon_item_static_yar_Blob_043000, // ITEM_MASK_KAMARO + icon_item_static_yar_Blob_044000, // ITEM_MASK_CAPTAIN + icon_item_static_yar_Blob_045000, // ITEM_MASK_STONE + icon_item_static_yar_Blob_046000, // ITEM_MASK_BREMEN + icon_item_static_yar_Blob_047000, // ITEM_MASK_BLAST + icon_item_static_yar_Blob_048000, // ITEM_MASK_SCENTS + icon_item_static_yar_Blob_049000, // ITEM_MASK_GIANT + icon_item_static_yar_Blob_04A000, // ITEM_BOW_ARROW_FIRE + icon_item_static_yar_Blob_04B000, // ITEM_BOW_ARROW_ICE + icon_item_static_yar_Blob_04C000, // ITEM_BOW_ARROW_LIGHT + icon_item_static_yar_Blob_04D000, // ITEM_SWORD_KOKIRI + icon_item_static_yar_Blob_04E000, // ITEM_SWORD_RAZOR + icon_item_static_yar_Blob_04F000, // ITEM_SWORD_GILDED + icon_item_static_yar_Blob_050000, // ITEM_SWORD_DEITY + icon_item_static_yar_Blob_051000, // ITEM_SHIELD_HERO + icon_item_static_yar_Blob_052000, // ITEM_SHIELD_MIRROR + icon_item_static_yar_Blob_053000, // ITEM_QUIVER_30 + icon_item_static_yar_Blob_054000, // ITEM_QUIVER_40 + icon_item_static_yar_Blob_055000, // ITEM_QUIVER_50 + icon_item_static_yar_Blob_056000, // ITEM_BOMB_BAG_20 + icon_item_static_yar_Blob_057000, // ITEM_BOMB_BAG_30 + icon_item_static_yar_Blob_058000, // ITEM_BOMB_BAG_40 + icon_item_static_yar_Blob_059000, // ITEM_WALLET_DEFAULT + icon_item_static_yar_Blob_05A000, // ITEM_WALLET_ADULT + icon_item_static_yar_Blob_05B000, // ITEM_WALLET_GIANT + icon_item_static_yar_Blob_05C000, // ITEM_FISHING_ROD + icon_item_static_yar_Blob_05D000, // ITEM_REMAINS_ODOLWA + icon_item_static_yar_Blob_05E000, // ITEM_REMAINS_GOHT + icon_item_static_yar_Blob_05F000, // ITEM_REMAINS_GYORG + icon_item_static_yar_Blob_060000, // ITEM_REMAINS_TWINMOLD + icon_item_static_yar_Blob_062000, // ITEM_SONG_SONATA + icon_item_static_yar_Blob_062000, // ITEM_SONG_LULLABY + icon_item_static_yar_Blob_062000, // ITEM_SONG_NOVA + icon_item_static_yar_Blob_062000, // ITEM_SONG_ELEGY + icon_item_static_yar_Blob_062000, // ITEM_SONG_OATH + icon_item_static_yar_Blob_062000, // ITEM_SONG_SARIA + icon_item_static_yar_Blob_062000, // ITEM_SONG_TIME + icon_item_static_yar_Blob_062000, // ITEM_SONG_HEALING + icon_item_static_yar_Blob_062000, // ITEM_SONG_EPONA + icon_item_static_yar_Blob_062000, // ITEM_SONG_SOARING + icon_item_static_yar_Blob_062000, // ITEM_SONG_STORMS + icon_item_static_yar_Blob_062000, // ITEM_SONG_SUN + icon_item_static_yar_Blob_061000, // ITEM_BOMBERS_NOTEBOOK + icon_item_24_static_yar_Blob_000000, // ITEM_SKULL_TOKEN + icon_item_24_static_yar_Blob_000900, // ITEM_HEART_CONTAINER + icon_item_24_static_yar_Blob_001200, // ITEM_HEART_PIECE + icon_item_static_yar_Blob_062000, // + icon_item_static_yar_Blob_062000, // + icon_item_static_yar_Blob_062000, // ITEM_SONG_LULLABY_INTRO + icon_item_24_static_yar_Blob_003600, // ITEM_KEY_BOSS + icon_item_24_static_yar_Blob_004800, // ITEM_COMPASS + icon_item_24_static_yar_Blob_003F00, // ITEM_DUNGEON_MAP + icon_item_24_static_yar_Blob_005100, // ITEM_STRAY_FAIRIES + icon_item_24_static_yar_Blob_005A00, // ITEM_KEY_SMALL + icon_item_24_static_yar_Blob_006300, // ITEM_MAGIC_SMALL + icon_item_24_static_yar_Blob_006C00, // ITEM_MAGIC_LARGE + icon_item_static_yar_Blob_062180, // ITEM_HEART_PIECE_2 + icon_item_static_yar_Blob_062A80, // ITEM_INVALID_1 + icon_item_static_yar_Blob_063380, // ITEM_INVALID_2 + gOcarinaCUpTex, // ITEM_INVALID_3 + gOcarinaCDownTex, // ITEM_INVALID_4 + gOcarinaCLeftTex, // ITEM_INVALID_5 + gOcarinaCRightTex, // ITEM_INVALID_6 + gOcarinaATex, // ITEM_INVALID_7 }; // Used to map item IDs to inventory slots diff --git a/src/code/z_play_hireso.c b/src/code/z_play_hireso.c index b995028ca3..24dcaca552 100644 --- a/src/code/z_play_hireso.c +++ b/src/code/z_play_hireso.c @@ -1,31 +1,7 @@ #include "global.h" #include "z64bombers_notebook.h" #include "interface/schedule_static/schedule_static.h" - -// TODO: Needs YAZ0 -// Segment 0x07 schedule_dma_static_test -extern TexturePtr D_07000000; -extern TexturePtr D_07000800; -extern TexturePtr D_07001000; -extern TexturePtr D_07001800; -extern TexturePtr D_07002000; -extern TexturePtr D_07002800; -extern TexturePtr D_07003000; -extern TexturePtr D_07003800; -extern TexturePtr D_07004000; -extern TexturePtr D_07004800; -extern TexturePtr D_07005000; -extern TexturePtr D_07005800; -extern TexturePtr D_07006000; -extern TexturePtr D_07006800; -extern TexturePtr D_07007000; -extern TexturePtr D_07007800; -extern TexturePtr D_07008000; -extern TexturePtr D_07008800; -extern TexturePtr D_07009000; -extern TexturePtr D_07009800; -extern TexturePtr D_0700AC00; -extern TexturePtr D_0700AEA0; +#include "archives/schedule_dma_static/schedule_dma_static_yar.h" #define BOMBERS_NOTEBOOK_ENTRY_SIZE 3 #define BOMBERS_NOTEBOOK_ENTRY_MAX 10 @@ -395,8 +371,8 @@ void BombersNotebook_DrawColumns(Gfx** gfxP) { TexturePtr sBombersNotebookEventIconTextures[] = { gBombersNotebookEntryIconExclamationPointTex, - &D_0700AC00, - &D_0700AEA0, + schedule_dma_static_yar_Blob_00AC00, + schedule_dma_static_yar_Blob_00AEA0, }; s16 sBombersNotebookEntryIconColors[][3] = { { 255, 255, 0 }, @@ -1163,8 +1139,8 @@ void BombersNotebook_Update(PlayState* play, BombersNotebook* this, Input* input s32 stickAdjY = input->rel.stick_y; s32 cursorEntryScan; - this->scheduleDmaSegmentStart = SEGMENT_ROM_START(schedule_dma_static_test); - this->scheduleDmaSegmentSize = SEGMENT_ROM_SIZE(schedule_dma_static_old); + this->scheduleDmaSegmentStart = SEGMENT_ROM_START(schedule_dma_static_yar); + this->scheduleDmaSegmentSize = SEGMENT_ROM_SIZE(schedule_dma_static_syms); this->scheduleSegmentStart = SEGMENT_ROM_START(schedule_static); this->scheduleSegmentSize = SEGMENT_ROM_SIZE(schedule_static); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index b60a00f9e6..60d79536ef 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -2857,8 +2857,8 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->roll = -314.0f; pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); - size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + size0 = SEGMENT_ROM_SIZE(icon_item_static_syms); + CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_static_yar), pauseCtx->iconItemSegment, size0); gSegments[0x08] = VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); @@ -2869,8 +2869,8 @@ void KaleidoScope_Update(PlayState* play) { } pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); - size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); - CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, + size1 = SEGMENT_ROM_SIZE(icon_item_24_static_syms); + CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_yar), pauseCtx->iconItem24Segment, size1); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); @@ -3184,12 +3184,12 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItemSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); // Messed up ALIGN64 - size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + size0 = SEGMENT_ROM_SIZE(icon_item_static_syms); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_yar), pauseCtx->iconItemSegment, size0); pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); - size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); - CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); + size1 = SEGMENT_ROM_SIZE(icon_item_24_static_syms); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_24_static_yar), pauseCtx->iconItem24Segment, size1); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); size2 = SEGMENT_ROM_SIZE(icon_item_gameover_static); @@ -3432,8 +3432,8 @@ void KaleidoScope_Update(PlayState* play) { sPauseCursorRightX = 155; pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); - size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + size0 = SEGMENT_ROM_SIZE(icon_item_static_syms); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_yar), pauseCtx->iconItemSegment, size0); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); sInDungeonScene = false; diff --git a/tools/buildtools/.gitignore b/tools/buildtools/.gitignore index ecf2dd8519..1119d97869 100644 --- a/tools/buildtools/.gitignore +++ b/tools/buildtools/.gitignore @@ -5,3 +5,4 @@ makeromfs mkldscript reloc_prereq yaz0 +makeyar diff --git a/tools/buildtools/Makefile b/tools/buildtools/Makefile index 6f34b5cfa3..57c5d05426 100644 --- a/tools/buildtools/Makefile +++ b/tools/buildtools/Makefile @@ -1,6 +1,5 @@ -CC := gcc -CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2 -PROGRAMS := elf2rom makeromfs mkldscript reloc_prereq yaz0 +CFLAGS := -Wall -Wextra -Wpedantic -std=c99 -g -Os +PROGRAMS := elf2rom makeromfs mkldscript reloc_prereq yaz0 makeyar ifeq ($(shell command -v clang >/dev/null 2>&1; echo $$?),0) CC := clang @@ -8,15 +7,6 @@ else CC := gcc endif -LLD ?= 0 - -ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) - LLD := 1 -endif - -ifneq ($(LLD),0) - CFLAGS += -fuse-ld=lld -endif all: $(PROGRAMS) clean: @@ -27,6 +17,7 @@ makeromfs_SOURCES := makeromfs.c n64chksum.c util.c mkldscript_SOURCES := mkldscript.c spec.c util.c reloc_prereq_SOURCES := reloc_prereq.c spec.c util.c yaz0_SOURCES := yaz0tool.c yaz0.c util.c +makeyar_SOURCES := makeyar.c elf32.c yaz0.c util.c define COMPILE = $(1): $($1_SOURCES) diff --git a/tools/buildtools/elf32.c b/tools/buildtools/elf32.c index 7540406fb4..64e6a9a1b4 100644 --- a/tools/buildtools/elf32.c +++ b/tools/buildtools/elf32.c @@ -138,6 +138,7 @@ bool elf32_get_section(struct Elf32* e, struct Elf32_Section* sec, int secnum) { sec->flags = e->read32(sechdr + 0x08); sec->addr = e->read32(sechdr + 0x0C); sec->offset = e->read32(sechdr + 0x10); + sec->size = e->read32(sechdr + 0x14); sec->addralign = e->read32(sechdr + 0x20); sec->entsize = e->read32(sechdr + 0x24); return true; @@ -162,5 +163,8 @@ bool elf32_get_symbol(struct Elf32* e, struct Elf32_Symbol* sym, int symnum) { sym->name = strings + e->read32(symtab + symnum * 0x10); sym->value = e->read32(symtab + symnum * 0x10 + 4); + sym->size = e->read32(symtab + symnum * 0x10 + 8); + sym->st_type = symtab[symnum * 0x10 + 0xC] & 0xF; + sym->shndx = e->read16(symtab + symnum * 0x10 + 0xE); return true; } diff --git a/tools/buildtools/elf32.h b/tools/buildtools/elf32.h index 0dae635f26..f3de313581 100644 --- a/tools/buildtools/elf32.h +++ b/tools/buildtools/elf32.h @@ -3,6 +3,7 @@ #include #include +#include enum { ELF_MACHINE_NONE = 0, @@ -52,14 +53,31 @@ struct Elf32_Section { uint32_t type; uint32_t flags; uint32_t addr; + uint32_t size; uint32_t offset; uint32_t addralign; uint32_t entsize; }; +#define SHN_UNDEF 0 +#define SHN_ABS 0xFFF1 +#define SHN_COMMON 0xFFF2 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 +#define STT_NUM 7 + struct Elf32_Symbol { const char* name; uint32_t value; + uint32_t size; + uint8_t st_type; + uint16_t shndx; }; bool elf32_init(struct Elf32* e, const void* data, size_t size); diff --git a/tools/buildtools/makeyar.c b/tools/buildtools/makeyar.c new file mode 100644 index 0000000000..6a241f6f5b --- /dev/null +++ b/tools/buildtools/makeyar.c @@ -0,0 +1,267 @@ +/* SPDX-FileCopyrightText: © 2023 ZeldaRET */ +/* SPDX-License-Identifier: MIT */ + +/** + * Program to generate compressed yar (Yaz0 ARchive) files. + * + * The program expects an .o elf file and outputs a raw yar binary file and a + * "symbols" elf. + * + * A yar file consists of multiple Yaz0 files compressed individually. The + * archive begins with a header of non-fixed size, which describes the + * location of each individual Yaz0 block within the archive itself. This + * header is followed by each Yaz0 file. + * + * The first word (a 4 byte group) of the header indicates the size in bytes of + * the header itself (also describes the offset of the first Yaz0 block). The + * rest of the header consists of words describing the offsets of each Yaz0 + * block relative to the end of the header, because the first Yaz0 + * block is omitted from the offsets in the header. + * + * Each Yaz0 block is 0xFF-padded to a multiple of 0x10 in size. + * + * The entire archive is 0-padded to a multiple of 0x10 in size. + * + * The program works by compressing each .data symbol in the input elf file as + * its own Yaz0 compressed file, appending them in order for the generated + * archive. Other elf sections are ignored for the resulting yar file. + * + * The program also outputs an elf file that's identical to the elf input, + * but with its .data section zero'ed out completely. This "symbols" elf can be + * used for referencing each symbol as the whole file were completely + * uncompressed. + */ + + +#include +#include +#include +#include +#include +#include + +#include "elf32.h" +#include "yaz0.h" +#include "util.h" + + +typedef struct Bytearray { + uint8_t *bytes; + size_t size; +} Bytearray; + +typedef struct SymbolList { + struct Elf32_Symbol *symbols; + size_t size; // allocated size + size_t len; // elements in the list +} SymbolList; + +typedef struct DataSection { + Bytearray data; + uint32_t dataOffset; + SymbolList symbols; +} DataSection; + + +void Bytearray_Init(Bytearray *bytearr, const uint8_t *bytes, size_t size) { + bytearr->bytes = malloc(size); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memcpy(bytearr->bytes, bytes, size); + bytearr->size = size; +} + +void Bytearray_InitValue(Bytearray *bytearr, uint8_t val, size_t count) { + bytearr->bytes = malloc(count * sizeof(uint8_t)); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memset(bytearr->bytes, val, count); + bytearr->size = count; +} + +void Bytearray_ExtendValue(Bytearray *bytearr, uint8_t val, size_t count) { + size_t newSize = bytearr->size + count; + + bytearr->bytes = realloc(bytearr->bytes, newSize); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memset(&bytearr->bytes[bytearr->size], val, count); + bytearr->size = newSize; +} + +void Bytearray_Extend(Bytearray *bytearr, const uint8_t *bytes, size_t size) { + size_t newSize = bytearr->size + size; + + bytearr->bytes = realloc(bytearr->bytes, newSize); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memcpy(&bytearr->bytes[bytearr->size], bytes, size); + bytearr->size = newSize; +} + +void Bytearray_Destroy(Bytearray *bytearr) { + free(bytearr->bytes); +} + +void SymbolList_Init(SymbolList *list, size_t initialAmount) { + list->symbols = malloc(initialAmount * sizeof(struct Elf32_Symbol)); + if (list->symbols == NULL) { + util_fatal_error("memory error"); + } + list->size = initialAmount; + list->len = 0; +} + +void SymbolList_Destroy(SymbolList *list) { + free(list->symbols); +} + +void DataSection_FromElf(DataSection *dst, const Bytearray *elfBytes){ + struct Elf32 elf; + size_t i; + int symIndex; + size_t dataShndx = 0; + + if (!elf32_init(&elf, elfBytes->bytes, elfBytes->size) || (elf.machine != ELF_MACHINE_MIPS)) { + util_fatal_error("not a valid 32-bit MIPS ELF file"); + } + + for (i = 0; i < elf.shnum; i++) { + struct Elf32_Section sec; + + if (!elf32_get_section(&elf, &sec, i)) { + util_fatal_error("invalid or corrupt ELF file"); + } + + if (strcmp(sec.name, ".data") == 0) { + dst->dataOffset = sec.offset; + Bytearray_Init(&dst->data, &elfBytes->bytes[sec.offset], sec.size); + dataShndx = i; + break; + } + } + + SymbolList_Init(&dst->symbols, elf.numsymbols); + for (symIndex = 0; symIndex < elf.numsymbols; symIndex++) { + struct Elf32_Symbol sym; + + if (!elf32_get_symbol(&elf, &sym, symIndex)) { + util_fatal_error("invalid or corrupt ELF file"); + } + + if (sym.shndx != dataShndx) { + continue; + } + if (sym.st_type != STT_OBJECT) { + continue; + } + + dst->symbols.symbols[dst->symbols.len++] = sym; + } +} + +void DataSection_Destroy(DataSection *dataSect) { + Bytearray_Destroy(&dataSect->data); + SymbolList_Destroy(&dataSect->symbols); +} + +#define ALIGN16(val) (((val) + 0xF) & ~0xF) + +void createArchive(Bytearray *archive, const DataSection *dataSect) { + uint32_t firstEntryOffset = (dataSect->symbols.len + 1) * sizeof(uint32_t); + size_t i; + size_t offset; + + // Fill with zeroes until the compressed data start + Bytearray_InitValue(archive, 0, firstEntryOffset); + + util_write_uint32_be(&archive->bytes[0], firstEntryOffset); + + offset = firstEntryOffset; + for (i = 0; i < dataSect->symbols.len; i++) { + const struct Elf32_Symbol *sym = &dataSect->symbols.symbols[i]; + size_t uncompressedSize = sym->size; + uint8_t *output = malloc(uncompressedSize * sizeof(uint8_t)); // assume compressed shouldn't be bigger than uncompressed + size_t compressedSize; + + output[0] = 'Y'; + output[1] = 'a'; + output[2] = 'z'; + output[3] = '0'; + util_write_uint32_be(&output[4], uncompressedSize); + memset(&output[8], 0, 8); + compressedSize = 0x10; + + assert(sym->value + uncompressedSize <= dataSect->data.size); + compressedSize += yaz0_encode(&dataSect->data.bytes[sym->value], &output[0x10], uncompressedSize); + + // Pad to 0x10 + while (compressedSize % 0x10 != 0) { + output[compressedSize++] = 0xFF; + } + + Bytearray_Extend(archive, output, compressedSize); + + if (i > 0) { + util_write_uint32_be(&archive->bytes[i * sizeof(uint32_t)], offset - firstEntryOffset); + } + + offset += compressedSize; + free(output); + } + + util_write_uint32_be(&archive->bytes[i * sizeof(uint32_t)], offset - firstEntryOffset); + + if (archive->size % 16 != 0) { + size_t extraPad = ALIGN16(archive->size) - archive->size; + + Bytearray_ExtendValue(archive, 0, extraPad); + } +} + + +int main(int argc, char *argv[]) { + const char *inPath; + const char *binPath; + const char *symPath; + Bytearray elfBytes; + DataSection dataSect; + Bytearray archive; + + if (argc != 4) { + fprintf(stderr, "%s in_file out_bin out_sym\n", argv[0]); + exit(1); + } + + inPath = argv[1]; + binPath = argv[2]; + symPath = argv[3]; + + elfBytes.bytes = util_read_whole_file(inPath, &elfBytes.size); + + DataSection_FromElf(&dataSect, &elfBytes); + + createArchive(&archive, &dataSect); + + // Write the compressed archive file as a raw binary + util_write_whole_file(binPath, archive.bytes, archive.size); + + // Zero out data + memset(&elfBytes.bytes[dataSect.dataOffset], 0, dataSect.data.size); + + util_write_whole_file(symPath, elfBytes.bytes, elfBytes.size); + + Bytearray_Destroy(&archive); + DataSection_Destroy(&dataSect); + Bytearray_Destroy(&elfBytes); + + return 0; +} diff --git a/tools/buildtools/yaz0.h b/tools/buildtools/yaz0.h index 97656aac53..50ac586bb7 100644 --- a/tools/buildtools/yaz0.h +++ b/tools/buildtools/yaz0.h @@ -1,8 +1,6 @@ #ifndef YAZ0_H #define YAZ0_H -int yaz0_encode2(uint8_t* src, uint8_t* dest, int uncompressedSize); - void yaz0_decode(uint8_t* src, uint8_t* dst, int uncompressedSize); int yaz0_encode(uint8_t* src, uint8_t* dest, int srcSize); diff --git a/tools/decompress_yars.py b/tools/decompress_yars.py new file mode 100755 index 0000000000..404a50c56d --- /dev/null +++ b/tools/decompress_yars.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: © 2023 ZeldaRET +# SPDX-License-Identifier: MIT + +# yar (Yaz0 ARchive) decompressor +# +# This program decompresses every raw yar binary file listed in +# `tools/filelists/{version}/archives.csv` to a corresponding +# `baserom/{file}.unarchive` raw file. +# +# It works by decompressing every Yaz0 block and appending them one by one into +# a new raw binary file so it can be processed normally by other tools. + + +from __future__ import annotations + +import argparse +import dataclasses +import libyaz0 +from pathlib import Path +import struct + + +PRINT_XML = False + +@dataclasses.dataclass +class ArchiveMeta: + start: int + end: int + + +def readFileAsBytearray(filepath: Path) -> bytearray: + with filepath.open(mode="rb") as f: + return bytearray(f.read()) + + +def readBytesAsWord(array_of_bytes: bytearray, offset: int) -> int: + return struct.unpack_from(f">I", array_of_bytes, offset)[0] + + +def getOffsetsList(archiveBytes: bytearray) -> list[ArchiveMeta]: + archivesOffsets: list[ArchiveMeta] = [] + + firstEntryOffset = readBytesAsWord(archiveBytes, 0) + firstEntrySize = readBytesAsWord(archiveBytes, 4) + + archivesOffsets.append(ArchiveMeta(firstEntryOffset, firstEntryOffset + firstEntrySize)) + + offset = 4 + while offset < firstEntryOffset - 4: + entry = readBytesAsWord(archiveBytes, offset) + nextEntry = readBytesAsWord(archiveBytes, offset + 4) + entryStart = entry + firstEntryOffset + entryEnd = nextEntry + firstEntryOffset + archivesOffsets.append(ArchiveMeta(entryStart, entryEnd)) + + offset += 4 + + return archivesOffsets + + +def extractArchive(archivePath: Path, outPath: Path): + archiveBytes = readFileAsBytearray(archivePath) + + if readBytesAsWord(archiveBytes, 0) == 0: + # Empty file, ignore it + return + + print(f"Extracting '{archivePath}' -> '{outPath}'") + archivesOffsets = getOffsetsList(archiveBytes) + + if PRINT_XML: + print('') + print(f' ') + + with outPath.open("wb") as out: + currentOffset = 0 + for meta in archivesOffsets: + decompressedBytes = libyaz0.decompress(archiveBytes[meta.start:meta.end]) + decompressedSize = len(decompressedBytes) + out.write(decompressedBytes) + + if PRINT_XML: + print(f' ') + + currentOffset += decompressedSize + + if PRINT_XML: + print(f' ') + print('') + + +def main(): + parser = argparse.ArgumentParser(description="MM archives extractor") + parser.add_argument("-v", "--version", help="version to process", default="mm.us.rev1") + parser.add_argument("--xml", help="Generate xml to stdout", action="store_true") + + args = parser.parse_args() + + global PRINT_XML + PRINT_XML = args.xml + + archivesCsvPath = Path(f"tools/filelists/{args.version}/archives.csv") + + with archivesCsvPath.open() as f: + for line in f: + archiveName = line.strip().split(",")[1] + archivePath = Path(f"baserom/{archiveName}") + + extractedPath = Path(str(archivePath) + ".unarchive") + extractArchive(archivePath, extractedPath) + +if __name__ == "__main__": + main() diff --git a/tools/disasm/dma_filenames.txt b/tools/disasm/dma_filenames.txt index aaa17ab6d8..798a8b366d 100644 --- a/tools/disasm/dma_filenames.txt +++ b/tools/disasm/dma_filenames.txt @@ -7,8 +7,8 @@ 'Audiotable', 'kanji', 'link_animetion', - 'icon_item_static_old', - 'icon_item_24_static_old', + 'icon_item_static_syms', + 'icon_item_24_static_syms', 'icon_item_field_static', 'icon_item_dungeon_static', 'icon_item_gameover_static', @@ -18,10 +18,10 @@ 'map_grand_static', 'item_name_static', 'map_name_static', - 'icon_item_static_test', - 'icon_item_24_static_test', - 'schedule_dma_static_old', - 'schedule_dma_static_test', + 'icon_item_static_yar', + 'icon_item_24_static_yar', + 'schedule_dma_static_syms', + 'schedule_dma_static_yar', 'schedule_static', 'story_static', 'do_action_static', diff --git a/tools/extract_baserom.py b/tools/extract_baserom.py index 03d230e80a..c631a63923 100755 --- a/tools/extract_baserom.py +++ b/tools/extract_baserom.py @@ -14,8 +14,8 @@ FILE_NAMES = [ 'Audiotable', 'kanji', 'link_animetion', - 'icon_item_static_old', - 'icon_item_24_static_old', + 'icon_item_static_syms', + 'icon_item_24_static_syms', 'icon_item_field_static', 'icon_item_dungeon_static', 'icon_item_gameover_static', @@ -25,10 +25,10 @@ FILE_NAMES = [ 'map_grand_static', 'item_name_static', 'map_name_static', - 'icon_item_static_test', - 'icon_item_24_static_test', - 'schedule_dma_static_old', - 'schedule_dma_static_test', + 'icon_item_static_yar', + 'icon_item_24_static_yar', + 'schedule_dma_static_syms', + 'schedule_dma_static_yar', 'schedule_static', 'story_static', 'do_action_static', diff --git a/tools/filelists/mm.us.rev1/all.csv b/tools/filelists/mm.us.rev1/all.csv index c23622330c..7c98a7cf3e 100644 --- a/tools/filelists/mm.us.rev1/all.csv +++ b/tools/filelists/mm.us.rev1/all.csv @@ -6,8 +6,8 @@ 5,Audiotable 6,kanji 7,link_animetion -8,icon_item_static_old -9,icon_item_24_static_old +8,icon_item_static_syms +9,icon_item_24_static_syms 10,icon_item_field_static 11,icon_item_dungeon_static 12,icon_item_gameover_static @@ -17,10 +17,10 @@ 16,map_grand_static 17,item_name_static 18,map_name_static -19,icon_item_static_test -20,icon_item_24_static_test -21,schedule_dma_static_old -22,schedule_dma_static_test +19,icon_item_static_yar +20,icon_item_24_static_yar +21,schedule_dma_static_syms +22,schedule_dma_static_yar 23,schedule_static 24,story_static 25,do_action_static diff --git a/tools/filelists/mm.us.rev1/archives.csv b/tools/filelists/mm.us.rev1/archives.csv index a0b758dfd0..3053456d0b 100644 --- a/tools/filelists/mm.us.rev1/archives.csv +++ b/tools/filelists/mm.us.rev1/archives.csv @@ -2,6 +2,6 @@ 16,map_grand_static 17,item_name_static 18,map_name_static -19,icon_item_static_test -20,icon_item_24_static_test -22,schedule_dma_static_test +19,icon_item_static_yar +20,icon_item_24_static_yar +22,schedule_dma_static_yar diff --git a/tools/filelists/mm.us.rev1/deleted.csv b/tools/filelists/mm.us.rev1/deleted.csv index 12e60f6ee3..2fca3fbe82 100644 --- a/tools/filelists/mm.us.rev1/deleted.csv +++ b/tools/filelists/mm.us.rev1/deleted.csv @@ -1,3 +1,3 @@ -8,icon_item_static_old -9,icon_item_24_static_old -21,schedule_dma_static_old +8,icon_item_static_syms +9,icon_item_24_static_syms +21,schedule_dma_static_syms diff --git a/tools/progress.py b/tools/progress.py index 5a2958cd85..9096715aae 100755 --- a/tools/progress.py +++ b/tools/progress.py @@ -136,7 +136,6 @@ if not args.matching: # The order of this list should not change to prevent breaking the graph of the website # New stuff shall be appended at the end of the list assetsCategories = [ - "archives", "audio", "interface", "misc", @@ -148,6 +147,11 @@ assetsCategories = [ ] assetsTracker = dict() +# Assets that we don't have a proper way of tracking right now +ignoredAssets = { + "archives", +} + # Manual fixer for files that would be counted in wrong categories # "filename": "correctSection" fileSectionFixer = { @@ -203,12 +207,12 @@ for line in map_file: file_size = int(line_split[2], 16) obj_file = line_split[3].strip() objFileSplit = obj_file.split("/") + objFileName = objFileSplit[-1].split(".o")[0] fileData = {"name": obj_file, "vram": obj_vram, "size": file_size, "section": section, "symbols": []} mapFileList.append(fileData) if (section == ".text"): - objFileName = objFileSplit[-1].split(".o")[0] srcCat = obj_file.split("/")[2] if srcCat in srcCategoriesFixer: srcCat = srcCategoriesFixer[srcCat] @@ -229,6 +233,8 @@ for line in map_file: assetCat = obj_file.split("/")[2] if assetCat in assetsTracker: assetsTracker[assetCat]["currentSize"] += file_size + elif assetCat in ignoredAssets: + pass else: eprint(f"Found file '{obj_file}' in unknown asset category '{assetCat}'") eprint("I'll ignore this for now, but please fix it!") diff --git a/undefined_syms.txt b/undefined_syms.txt index e586991ff4..9dd07f6235 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1098,32 +1098,6 @@ D_06000B70 = 0x06000B70; D_06000D60 = 0x06000D60; -// segment 0x07 - -D_07000000 = 0x07000000; -D_07000800 = 0x07000800; -D_07001000 = 0x07001000; -D_07001800 = 0x07001800; -D_07002000 = 0x07002000; -D_07002800 = 0x07002800; -D_07003000 = 0x07003000; -D_07003800 = 0x07003800; -D_07004000 = 0x07004000; -D_07004800 = 0x07004800; -D_07005000 = 0x07005000; -D_07005800 = 0x07005800; -D_07006000 = 0x07006000; -D_07006800 = 0x07006800; -D_07007000 = 0x07007000; -D_07007800 = 0x07007800; -D_07008000 = 0x07008000; -D_07008800 = 0x07008800; -D_07009000 = 0x07009000; -D_07009800 = 0x07009800; -D_0700AC00 = 0x0700AC00; -D_0700AEA0 = 0x0700AEA0; - - // segment 0x08 D_08000000 = 0x08000000;