diff --git a/.gitignore b/.gitignore index 067dfa0e19..e08969475e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,16 +8,17 @@ venv/ .DS_Store ctx.c expected/ - -# Assets -assets +settings.mk # Build artifacts *.ld *.z64 *.bin +*.i +*.Yay0 bin/ build/ docs/doxygen/ +include/ld_addrs.h .vscode/launch.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 4ad1bf0a99..34ede7fb44 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -3,6 +3,13 @@ "configurations": [ { "name": "papermario", + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "${workspaceFolder}/include", + "${workspaceFolder}/src" + ] + }, "includePath": [ "${workspaceFolder}/include", "${workspaceFolder}/src" diff --git a/.vscode/settings.json b/.vscode/settings.json index 2ee09d6a34..b9a9ded7bd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,4 +12,8 @@ ], "python.pythonPath": "/usr/bin/python3", "git.ignoreLimitWarning": true, + "search.exclude": { + "build": true, + "docs/doxygen": true, + }, } diff --git a/Makefile b/Makefile index f73c870e2d..0bb9ba311e 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BASEROM = baserom.z64 TARGET = papermario COMPARE = 1 NON_MATCHING = 0 +WATCH_INCLUDES = 1 -include settings.mk @@ -14,33 +15,29 @@ ifeq ($(wildcard $(BASEROM)),) $(error Baserom `$(BASEROM)' not found.) endif - -### Sources ### - -include sources.mk +# NON_MATCHING=1 implies COMPARE=0 +ifeq ($(NON_MATCHING),1) +override COMPARE=0 +endif ### Output ### -BUILD_DIR = build -ROM = $(TARGET).z64 -ELF = $(BUILD_DIR)/$(TARGET).elf -LD_SCRIPT = $(TARGET).ld -LD_MAP = $(BUILD_DIR)/$(TARGET).map - -ifdef ASSETS_FS -ASSETS_FS_OBJ = $(BUILD_DIR)/$(ASSETS_FS).o -endif +BUILD_DIR := build +ROM := $(TARGET).z64 +ELF := $(BUILD_DIR)/$(TARGET).elf +LD_SCRIPT := $(TARGET).ld +LD_MAP := $(BUILD_DIR)/$(TARGET).map +ASSETS_BIN := $(BUILD_DIR)/bin/assets/assets.bin ### Tools ### -PYTHON = python3 -N64CKSUM = tools/n64crc -SPLAT_YAML = tools/splat.yaml +PYTHON := python3 +N64CKSUM := tools/n64crc +SPLAT_YAML := tools/splat.yaml SPLAT = $(PYTHON) tools/n64splat/split.py $(BASEROM) $(SPLAT_YAML) . YAY0COMPRESS = tools/Yay0compress -BUILD_ASSETS_FS := $(PYTHON) tools/build_assets_fs.py $(ASSETS_FS) $(BUILD_DIR)/$(ASSETS_FS) ifndef EMULATOR ifneq ($(shell which mupen64plus-gui),) @@ -53,25 +50,36 @@ endif ### Compiler Options ### -CROSS = mips-linux-gnu- -AS = $(CROSS)as -OLD_AS = tools/mips-nintendo-nu64-as -CC = tools/cc1 -CPP = cpp -LD = $(CROSS)ld -OBJCOPY = $(CROSS)objcopy +CROSS := mips-linux-gnu- +AS := $(CROSS)as +OLD_AS := tools/mips-nintendo-nu64-as +CC := tools/cc1 +CPP := cpp +LD := $(CROSS)ld +OBJCOPY := $(CROSS)objcopy -CPPFLAGS = -Iinclude -Isrc -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 -ASFLAGS = -EB -Iinclude -march=vr4300 -mtune=vr4300 -OLDASFLAGS = -EB -Iinclude -G 0 -CFLAGS = -O2 -quiet -G 0 -mcpu=vr4300 -mfix4300 -mips3 -mgp32 -mfp32 -Wimplicit -Wuninitialized -Wshadow -LDFLAGS = -T undefined_syms.txt -T undefined_funcs.txt -T $(LD_SCRIPT) -Map $(LD_MAP) --no-check-sections +CPPFLAGS := -Iinclude -Isrc -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 -D_MIPS_SZLONG=32 -Wundef -Wcomment -MP -MD +ASFLAGS := -EB -Iinclude -march=vr4300 -mtune=vr4300 +OLDASFLAGS := -EB -Iinclude -G 0 +CFLAGS := -O2 -quiet -G 0 -mcpu=vr4300 -mfix4300 -mips3 -mgp32 -mfp32 -Wimplicit -Wuninitialized -Wshadow +LDFLAGS := -T undefined_syms.txt -T undefined_funcs.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(LD_MAP) --no-check-sections ifeq ($(NON_MATCHING),1) CPPFLAGS += -DNON_MATCHING endif +### Sources ### + +include sources.mk + +%.d: ; + +ifeq ($(WATCH_INCLUDES),1) +-include $(foreach obj, $(OBJECTS), $(obj).mk) +endif + + ### Targets ### clean: @@ -87,11 +95,14 @@ submodules: git submodule update --init --recursive split: - rm -rf bin assets + rm -rf bin $(SPLAT) --modes ld bin Yay0 PaperMarioMapFS +split-bin: + $(SPLAT) --modes ld bin + split-all: - rm -rf bin assets + rm -rf bin $(SPLAT) --modes all test: $(ROM) @@ -101,9 +112,61 @@ else @echo "N64 emulator not detected." && false endif +# Compressed files +%.Yay0: % + @mkdir -p $(shell dirname $@) + $(YAY0COMPRESS) $< $@ +$(BUILD_DIR)/%.bin.Yay0: %.bin + @mkdir -p $(shell dirname $@) + $(YAY0COMPRESS) $< $@ + +# Data objects +$(BUILD_DIR)/%.bin.o: %.bin + @mkdir -p $(shell dirname $@) + $(LD) -r -b binary -o $@ $< + +# Compressed data objects +$(BUILD_DIR)/%.Yay0.o: $(BUILD_DIR)/%.bin.Yay0 + @mkdir -p $(shell dirname $@) + $(LD) -r -b binary -o $@ $< + +# Compile C files +$(BUILD_DIR)/%.c.o: %.c $(BUILD_DIR)/%.d + @mkdir -p $(shell dirname $@) + $(CPP) $(CPPFLAGS) -o - $< -MF $@.mk -MT $(BUILD_DIR)/$*.d | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - + +# Compile C files (with DSL macros) +$(foreach cfile, $(DSL_C_FILES), $(BUILD_DIR)/$(cfile).o): $(BUILD_DIR)/%.c.o: %.c $(BUILD_DIR)/%.d + @mkdir -p $(shell dirname $@) + $(CPP) $(CPPFLAGS) -o - $< -MF $@.mk -MT $(BUILD_DIR)/$*.d | tools/compile_dsl_macros.py | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - + +# Assemble handwritten ASM +$(BUILD_DIR)/%.s.o: %.s + @mkdir -p $(shell dirname $@) + $(AS) $(ASFLAGS) -o $@ $< + +ASSET_FILES := $(foreach asset, $(ASSETS), $(BUILD_DIR)/bin/assets/$(asset)) +YAY0_ASSET_FILES := $(foreach asset, $(filter-out %_tex, $(ASSET_FILES)), $(asset).Yay0) + +$(BUILD_DIR)/bin/assets/%: bin/assets/%.bin + @mkdir -p $(shell dirname $@) + @cp $< $@ + +$(ASSETS_BIN): $(ASSET_FILES) $(YAY0_ASSET_FILES) + @mkdir -p $(shell dirname $@) + @echo "building $@" + @$(PYTHON) tools/build_assets_bin.py $@ $(ASSET_FILES) + +$(ASSETS_BIN:.bin=.o): $(ASSETS_BIN) + $(LD) -r -b binary -o $@ $< + $(LD_SCRIPT): $(SPLAT_YAML) $(SPLAT) --modes ld +$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) + @mkdir -p $(shell dirname $@) + $(CPP) -P -DBUILD_DIR=$(BUILD_DIR) -o $@ $< + $(ROM): $(BUILD_DIR)/$(TARGET).bin @cp $< $@ ifeq ($(COMPARE),1) @@ -113,70 +176,16 @@ endif $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf $(OBJCOPY) $< $@ -O binary -$(BUILD_DIR)/$(TARGET).elf: $(LD_SCRIPT) $(OBJECTS) $(ASSETS_FS_OBJ) +$(BUILD_DIR)/$(TARGET).elf: $(BUILD_DIR)/$(LD_SCRIPT) $(OBJECTS) $(LD) $(LDFLAGS) -o $@ -# `make print-VARNAME' to print the value of $(VARNAME) -print-%: ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true - - -### Object Targets (see sources.mk) ### - -ifndef OBJECTS -$(warning OBJECTS is not defined by `sources.mk'.) -else - -# C -$(filter %.c.o,$(OBJECTS)): $(BUILD_DIR)/%.c.o: %.c - @mkdir -p $(shell dirname $@) - - cpp $(CPPFLAGS) $< > $(BUILD_DIR)/$*.i - @grep -cF "SCRIPT(" $(BUILD_DIR)/$*.i | tools/compile_dsl_macros.py $(BUILD_DIR)/$*.i - $(CC) $(CFLAGS) -o - $(BUILD_DIR)/$*.i | $(OLD_AS) $(OLDASFLAGS) - -o $@ - -# Assembly -$(filter %.s.o,$(OBJECTS)): $(BUILD_DIR)/%.s.o: %.s - @mkdir -p $(shell dirname $@) - $(AS) $(ASFLAGS) -o $@ $< - -# Uncompressed data -$(filter %.bin.o,$(OBJECTS)): $(BUILD_DIR)/%.bin.o: %.bin - @mkdir -p $(shell dirname $@) - $(LD) -r -b binary -o $@ $< - -# Compressed data -$(filter %.Yay0.o,$(OBJECTS)): $(BUILD_DIR)/%.Yay0.o: %.bin - @mkdir -p $(shell dirname $@) - $(YAY0COMPRESS) $< $(BUILD_DIR)/$*.Yay0 - $(LD) -r -b binary -o $@ $(BUILD_DIR)/$*.Yay0 - -endif - - -### Asset Filesystem (see sources.mk) ### - -# Complain if ASSETS_FS_SOURCES is undefined but ASSETS_FS is. -ifndef ASSETS_FS_SOURCES -ifdef ASSETS_FS -$(warning ASSETS_FS_SOURCES is not defined by `sources.mk' but ASSETS_FS is.) -endif -else - -$(BUILD_DIR)/$(ASSETS_FS)/%: $(ASSETS_FS)/% - @mkdir -p $(shell dirname $@) - @rm -f $@ - $(BUILD_ASSETS_FS) $* - -$(ASSETS_FS_OBJ): $(ASSETS_FS).json $(foreach file,$(ASSETS_FS_SOURCES),$(BUILD_DIR)/$(file)) - $(BUILD_ASSETS_FS) - $(LD) -r -b binary -o $@ $(BUILD_DIR)/$(ASSETS_FS).bin - -endif - ### Make Settings ### .PHONY: clean test setup submodules split $(ROM) +.DELETE_ON_ERROR: +.SECONDARY: +.PRECIOUS: $(ROM) %.Yay0 .DEFAULT_GOAL := $(ROM) # Remove built-in implicit rules to improve performance diff --git a/README.md b/README.md index 99848b732f..67b6c4f8ff 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,6 @@ We provide [windows_terminal.bat](tools/windows_terminal.bat) to open a [Windows ### Rebuilding -Setting the `PM_HEADER_REBUILD` environment variable will cause `make` to rebuild all `.c` files whenever a `.h` file is modified. - -```sh -$ PM_HEADER_REBUILD=1 make -``` - If you use Visual Studio Code, you can use _Run Build Task_ (Ctrl+Shift+B) to run `make`. Any errors or warnings generated by the compiler will show up in the _Problems_ tab. ### Matching a function diff --git a/asm/boot.s b/asm/boot.s index ef7ab17def..e78799c793 100644 --- a/asm/boot.s +++ b/asm/boot.s @@ -5,7 +5,7 @@ .set noreorder # don't insert nops after branches .set gp=64 # allow use of 64-bit general purpose registers -.section .text_40, "ax" +.section .text, "ax" glabel func_A4000040 /* 40 A4000040 40806800 */ mtc0 $zero, $13 @@ -15,7 +15,7 @@ glabel func_A4000040 /* 50 A4000050 25080000 */ addiu $t0, $t0, 0 /* 54 A4000054 8D09000C */ lw $t1, 0xc($t0) /* 58 A4000058 152000ED */ bnez $t1, .LA4000410 -/* 5C A400005C 00000000 */ nop +/* 5C A400005C 00000000 */ nop /* 60 A4000060 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 64 A4000064 AFB30000 */ sw $s3, ($sp) /* 68 A4000068 AFB40004 */ sw $s4, 4($sp) @@ -32,20 +32,20 @@ glabel func_A4000040 /* 94 A4000094 AD090004 */ sw $t1, 4($t0) /* 98 A4000098 24112260 */ addiu $s1, $zero, 0x2260 .LA400009C: -/* 9C A400009C 00000000 */ nop +/* 9C A400009C 00000000 */ nop /* A0 A40000A0 2231FFFF */ addi $s1, $s1, -1 /* A4 A40000A4 1620FFFD */ bnez $s1, .LA400009C -/* A8 A40000A8 00000000 */ nop +/* A8 A40000A8 00000000 */ nop /* AC A40000AC AD000008 */ sw $zero, 8($t0) /* B0 A40000B0 34090014 */ ori $t1, $zero, 0x14 /* B4 A40000B4 AD09000C */ sw $t1, 0xc($t0) /* B8 A40000B8 AD000000 */ sw $zero, ($t0) /* BC A40000BC 24110004 */ addiu $s1, $zero, 4 .LA40000C0: -/* C0 A40000C0 00000000 */ nop +/* C0 A40000C0 00000000 */ nop /* C4 A40000C4 2231FFFF */ addi $s1, $s1, -1 /* C8 A40000C8 1620FFFD */ bnez $s1, .LA40000C0 -/* CC A40000CC 00000000 */ nop +/* CC A40000CC 00000000 */ nop /* D0 A40000D0 3409000E */ ori $t1, $zero, 0xe /* D4 A40000D4 AD090000 */ sw $t1, ($t0) /* D8 A40000D8 24110020 */ addiu $s1, $zero, 0x20 @@ -78,11 +78,11 @@ glabel func_A4000040 /* 140 A4000140 3C110101 */ lui $s1, 0x101 /* 144 A4000144 26310101 */ addiu $s1, $s1, 0x101 /* 148 A4000148 16110005 */ bne $s0, $s1, .LA4000160 -/* 14C A400014C 00000000 */ nop +/* 14C A400014C 00000000 */ nop /* 150 A4000150 24100200 */ addiu $s0, $zero, 0x200 /* 154 A4000154 35714000 */ ori $s1, $t3, 0x4000 /* 158 A4000158 10000003 */ b .LA4000168 -/* 15C A400015C 00000000 */ nop +/* 15C A400015C 00000000 */ nop .LA4000160: /* 160 A4000160 24100400 */ addiu $s0, $zero, 0x400 /* 164 A4000164 35718000 */ ori $s1, $t3, 0x8000 @@ -90,9 +90,9 @@ glabel func_A4000040 /* 168 A4000168 AE2E0004 */ sw $t6, 4($s1) /* 16C A400016C 25F5000C */ addiu $s5, $t7, 0xc /* 170 A4000170 0D0001DB */ jal func_A400076C -/* 174 A4000174 00000000 */ nop +/* 174 A4000174 00000000 */ nop /* 178 A4000178 10400038 */ beqz $v0, .LA400025C -/* 17C A400017C 00000000 */ nop +/* 17C A400017C 00000000 */ nop /* 180 A4000180 AFA20000 */ sw $v0, ($sp) /* 184 A4000184 24092000 */ addiu $t1, $zero, 0x2000 /* 188 A4000188 AD890000 */ sw $t1, ($t4) @@ -105,7 +105,7 @@ glabel func_A4000040 /* 1A4 A40001A4 AD890000 */ sw $t1, ($t4) /* 1A8 A40001A8 3C08B019 */ lui $t0, 0xb019 /* 1AC A40001AC 1568000C */ bne $t3, $t0, .LA40001E0 -/* 1B0 A40001B0 00000000 */ nop +/* 1B0 A40001B0 00000000 */ nop /* 1B4 A40001B4 3C080800 */ lui $t0, 0x800 /* 1B8 A40001B8 0308C020 */ add $t8, $t8, $t0 /* 1BC A40001BC 0330C820 */ add $t9, $t9, $s0 @@ -116,7 +116,7 @@ glabel func_A4000040 /* 1D0 A40001D0 00129040 */ sll $s2, $s2, 1 /* 1D4 A40001D4 22520001 */ addi $s2, $s2, 1 /* 1D8 A40001D8 10000003 */ b .LA40001E8 -/* 1DC A40001DC 00000000 */ nop +/* 1DC A40001DC 00000000 */ nop .LA40001E0: /* 1E0 A40001E0 3C080010 */ lui $t0, 0x10 /* 1E4 A40001E4 0288A020 */ add $s4, $s4, $t0 @@ -130,11 +130,11 @@ glabel func_A4000040 /* 200 A4000200 3129FFFF */ andi $t1, $t1, 0xffff /* 204 A4000204 24080500 */ addiu $t0, $zero, 0x500 /* 208 A4000208 15280009 */ bne $t1, $t0, .LA4000230 -/* 20C A400020C 00000000 */ nop +/* 20C A400020C 00000000 */ nop /* 210 A4000210 3C1B0100 */ lui $k1, 0x100 /* 214 A4000214 035BD024 */ and $k0, $k0, $k1 /* 218 A4000218 17400005 */ bnez $k0, .LA4000230 -/* 21C A400021C 00000000 */ nop +/* 21C A400021C 00000000 */ nop /* 220 A4000220 3C08101C */ lui $t0, 0x101c /* 224 A4000224 35080A04 */ ori $t0, $t0, 0xa04 /* 228 A4000228 ADE80018 */ sw $t0, 0x18($t7) @@ -151,7 +151,7 @@ glabel func_A4000040 /* 24C A400024C 25AD0001 */ addiu $t5, $t5, 1 /* 250 A4000250 2DA80008 */ sltiu $t0, $t5, 8 /* 254 A4000254 1500FFC4 */ bnez $t0, .LA4000168 -/* 258 A4000258 00000000 */ nop +/* 258 A4000258 00000000 */ nop .LA400025C: /* 25C A400025C 3C08C400 */ lui $t0, 0xc400 /* 260 A4000260 AD48000C */ sw $t0, 0xc($t2) @@ -163,14 +163,14 @@ glabel func_A4000040 /* 274 A4000274 8FA90004 */ lw $t1, 4($sp) /* 278 A4000278 3C08B009 */ lui $t0, 0xb009 /* 27C A400027C 15280016 */ bne $t1, $t0, .LA40002D8 -/* 280 A4000280 00000000 */ nop +/* 280 A4000280 00000000 */ nop /* 284 A4000284 AE380004 */ sw $t8, 4($s1) /* 288 A4000288 2735000C */ addiu $s5, $t9, 0xc /* 28C A400028C 8FA40000 */ lw $a0, ($sp) /* 290 A4000290 23BD0008 */ addi $sp, $sp, 8 /* 294 A4000294 24050001 */ addiu $a1, $zero, 1 /* 298 A4000298 0D00028D */ jal func_A4000A34 -/* 29C A400029C 00000000 */ nop +/* 29C A400029C 00000000 */ nop /* 2A0 A40002A0 8EC80000 */ lw $t0, ($s6) /* 2A4 A40002A4 3C080008 */ lui $t0, 8 /* 2A8 A40002A8 01164020 */ add $t0, $t0, $s6 @@ -192,7 +192,7 @@ glabel func_A4000040 /* 2E4 A40002E4 23BD0008 */ addi $sp, $sp, 8 /* 2E8 A40002E8 24050001 */ addiu $a1, $zero, 1 /* 2EC A40002EC 0D00028D */ jal func_A4000A34 -/* 2F0 A40002F0 00000000 */ nop +/* 2F0 A40002F0 00000000 */ nop /* 2F4 A40002F4 8CE80000 */ lw $t0, ($a3) /* 2F8 A40002F8 3C080008 */ lui $t0, 8 /* 2FC A40002FC 01074020 */ add $t0, $t0, $a3 @@ -223,7 +223,7 @@ glabel func_A4000040 /* 35C A400035C 24630001 */ addiu $v1, $v1, 1 /* 360 A4000360 006D402A */ slt $t0, $v1, $t5 /* 364 A4000364 1500FFC3 */ bnez $t0, .LA4000274 -/* 368 A4000368 00000000 */ nop +/* 368 A4000368 00000000 */ nop /* 36C A400036C 3C0AA470 */ lui $t2, 0xa470 /* 370 A4000370 001294C0 */ sll $s2, $s2, 0x13 /* 374 A4000374 3C090006 */ lui $t1, 6 @@ -266,7 +266,7 @@ glabel func_A4000040 /* 400 A4000400 1420FFFD */ bnez $at, .LA40003F8 /* 404 A4000404 25080010 */ addiu $t0, $t0, 0x10 /* 408 A4000408 10000013 */ b .LA4000458 -/* 40C A400040C 00000000 */ nop +/* 40C A400040C 00000000 */ nop .LA4000410: /* 410 A4000410 3C088000 */ lui $t0, 0x8000 /* 414 A4000414 25080000 */ addiu $t0, $t0, 0 @@ -315,7 +315,7 @@ glabel func_A4000040 /* 4B0 A40004B0 3C0C8000 */ lui $t4, 0x8000 /* 4B4 A40004B4 258C0000 */ addiu $t4, $t4, 0 /* 4B8 A40004B8 01800008 */ jr $t4 -/* 4BC A40004BC 00000000 */ nop +/* 4BC A40004BC 00000000 */ nop glabel func_A40004C0 /* 4C0 A40004C0 3C0BB000 */ lui $t3, 0xb000 @@ -343,23 +343,23 @@ glabel func_A40004C0 /* 514 A4000514 3C01A460 */ lui $at, 0xa460 /* 518 A4000518 AC2A000C */ sw $t2, 0xc($at) .LA400051C: -/* 51C A400051C 00000000 */ nop -/* 520 A4000520 00000000 */ nop -/* 524 A4000524 00000000 */ nop -/* 528 A4000528 00000000 */ nop -/* 52C A400052C 00000000 */ nop -/* 530 A4000530 00000000 */ nop -/* 534 A4000534 00000000 */ nop -/* 538 A4000538 00000000 */ nop -/* 53C A400053C 00000000 */ nop -/* 540 A4000540 00000000 */ nop -/* 544 A4000544 00000000 */ nop -/* 548 A4000548 00000000 */ nop +/* 51C A400051C 00000000 */ nop +/* 520 A4000520 00000000 */ nop +/* 524 A4000524 00000000 */ nop +/* 528 A4000528 00000000 */ nop +/* 52C A400052C 00000000 */ nop +/* 530 A4000530 00000000 */ nop +/* 534 A4000534 00000000 */ nop +/* 538 A4000538 00000000 */ nop +/* 53C A400053C 00000000 */ nop +/* 540 A4000540 00000000 */ nop +/* 544 A4000544 00000000 */ nop +/* 548 A4000548 00000000 */ nop /* 54C A400054C 3C0BA460 */ lui $t3, 0xa460 /* 550 A4000550 8D6B0010 */ lw $t3, 0x10($t3) /* 554 A4000554 316B0001 */ andi $t3, $t3, 1 /* 558 A4000558 1560FFF0 */ bnez $t3, .LA400051C -/* 55C A400055C 00000000 */ nop +/* 55C A400055C 00000000 */ nop /* 560 A4000560 3C0BB000 */ lui $t3, 0xb000 /* 564 A4000564 8D640008 */ lw $a0, 8($t3) /* 568 A4000568 3C010010 */ lui $at, 0x10 @@ -420,15 +420,15 @@ glabel func_A40004C0 /* 634 A4000634 3C0BB000 */ lui $t3, 0xb000 /* 638 A4000638 8D680010 */ lw $t0, 0x10($t3) /* 63C A400063C 14E80006 */ bne $a3, $t0, .LA4000658 -/* 640 A4000640 00000000 */ nop +/* 640 A4000640 00000000 */ nop /* 644 A4000644 8D680014 */ lw $t0, 0x14($t3) /* 648 A4000648 16080003 */ bne $s0, $t0, .LA4000658 -/* 64C A400064C 00000000 */ nop +/* 64C A400064C 00000000 */ nop /* 650 A4000650 04110003 */ bal .LA4000660 -/* 654 A4000654 00000000 */ nop +/* 654 A4000654 00000000 */ nop .LA4000658: /* 658 A4000658 0411FFFF */ bal .LA4000658 -/* 65C A400065C 00000000 */ nop +/* 65C A400065C 00000000 */ nop .LA4000660: /* 660 A4000660 3C09A408 */ lui $t1, 0xa408 /* 664 A4000664 8D290000 */ lw $t1, ($t1) @@ -500,8 +500,8 @@ glabel func_A40004C0 /* 758 A4000758 3C010010 */ lui $at, 0x10 /* 75C A400075C 01214823 */ subu $t1, $t1, $at /* 760 A4000760 01200008 */ jr $t1 -/* 764 A4000764 00000000 */ nop -/* 768 A4000768 00000000 */ nop +/* 764 A4000764 00000000 */ nop +/* 768 A4000768 00000000 */ nop glabel func_A400076C /* 76C A400076C 27BDFF60 */ addiu $sp, $sp, -0xa0 @@ -535,7 +535,7 @@ glabel func_A400076C /* 7DC A40007DC AFBF0064 */ sw $ra, 0x64($sp) .LA40007E0: /* 7E0 A40007E0 0D00021D */ jal func_A4000874 -/* 7E4 A40007E4 00000000 */ nop +/* 7E4 A40007E4 00000000 */ nop /* 7E8 A40007E8 26100001 */ addiu $s0, $s0, 1 /* 7EC A40007EC 2A090004 */ slti $t1, $s0, 4 /* 7F0 A40007F0 1520FFFB */ bnez $t1, .LA40007E0 @@ -591,7 +591,7 @@ glabel func_A4000874 /* 8AC A40008AC 00404825 */ or $t1, $v0, $zero /* 8B0 A40008B0 0000D012 */ mflo $k0 /* 8B4 A40008B4 017A5821 */ addu $t3, $t3, $k0 -/* 8B8 A40008B8 00000000 */ nop +/* 8B8 A40008B8 00000000 */ nop /* 8BC A40008BC 293A0050 */ slti $k0, $t1, 0x50 .LA40008C0: /* 8C0 A40008C0 1740FFF1 */ bnez $k0, .LA4000888 @@ -611,7 +611,7 @@ glabel func_A4000874 .LA40008F4: /* 8F4 A40008F4 27BD0020 */ addiu $sp, $sp, 0x20 /* 8F8 A40008F8 03E00008 */ jr $ra -/* 8FC A40008FC 00000000 */ nop +/* 8FC A40008FC 00000000 */ nop glabel func_A4000900 /* 900 A4000900 27BDFFD8 */ addiu $sp, $sp, -0x28 @@ -645,7 +645,7 @@ glabel func_A4000900 /* 964 A4000964 8FBF001C */ lw $ra, 0x1c($sp) /* 968 A4000968 27BD0028 */ addiu $sp, $sp, 0x28 /* 96C A400096C 03E00008 */ jr $ra -/* 970 A4000970 00000000 */ nop +/* 970 A4000970 00000000 */ nop glabel func_A4000974 /* 974 A4000974 27BDFFD8 */ addiu $sp, $sp, -0x28 @@ -701,7 +701,7 @@ glabel func_A4000974 /* A24 A4000A24 8FBF001C */ lw $ra, 0x1c($sp) /* A28 A4000A28 27BD0028 */ addiu $sp, $sp, 0x28 /* A2C A4000A2C 03E00008 */ jr $ra -/* A30 A4000A30 00000000 */ nop +/* A30 A4000A30 00000000 */ nop glabel func_A4000A34 /* A34 A4000A34 27BDFFD8 */ addiu $sp, $sp, -0x28 @@ -741,7 +741,7 @@ glabel func_A4000A34 /* AB4 A4000AB4 8FBF001C */ lw $ra, 0x1c($sp) /* AB8 A4000AB8 27BD0028 */ addiu $sp, $sp, 0x28 /* ABC A4000ABC 03E00008 */ jr $ra -/* AC0 A4000AC0 00000000 */ nop +/* AC0 A4000AC0 00000000 */ nop glabel func_A4000AC4 /* AC4 A4000AC4 27BDFFD8 */ addiu $sp, $sp, -0x28 @@ -782,8 +782,8 @@ glabel func_A4000AC4 /* B50 A4000B50 8FBF001C */ lw $ra, 0x1c($sp) /* B54 A4000B54 27BD0028 */ addiu $sp, $sp, 0x28 /* B58 A4000B58 03E00008 */ jr $ra -/* B5C A4000B5C 00000000 */ nop -/* B60 A4000B60 00000000 */ nop -/* B64 A4000B64 00000000 */ nop -/* B68 A4000B68 00000000 */ nop -/* B6C A4000B6C 00000000 */ nop +/* B5C A4000B5C 00000000 */ nop +/* B60 A4000B60 00000000 */ nop +/* B64 A4000B64 00000000 */ nop +/* B68 A4000B68 00000000 */ nop +/* B6C A4000B6C 00000000 */ nop diff --git a/asm/os/code_45df0_len_970.s b/asm/os/code_45df0_len_970.s index e86d69c867..4d7d315b0f 100644 --- a/asm/os/code_45df0_len_970.s +++ b/asm/os/code_45df0_len_970.s @@ -5,13 +5,13 @@ .set noreorder # don't insert nops after branches .set gp=64 # allow use of 64-bit general purpose registers -.section .text_1000, "ax" +.section .text, "ax" glabel func_8006A9F0 /* 45DF0 8006A9F0 3C1A8007 */ lui $k0, 0x8007 /* 45DF4 8006A9F4 275AAA00 */ addiu $k0, $k0, -0x5600 /* 45DF8 8006A9F8 03400008 */ jr $k0 -/* 45DFC 8006A9FC 00000000 */ nop +/* 45DFC 8006A9FC 00000000 */ nop glabel osExceptionPreamble /* 45E00 8006AA00 3C1A800B */ lui $k0, 0x800b @@ -74,7 +74,7 @@ glabel func_8006AA34 /* 45EDC 8006AADC 8F5B0118 */ lw $k1, 0x118($k0) /* 45EE0 8006AAE0 3369FF00 */ andi $t1, $k1, 0xff00 /* 45EE4 8006AAE4 11200013 */ beqz $t1, .L8006AB34 -/* 45EE8 8006AAE8 00000000 */ nop +/* 45EE8 8006AAE8 00000000 */ nop /* 45EEC 8006AAEC 3C088009 */ lui $t0, 0x8009 /* 45EF0 8006AAF0 25085900 */ addiu $t0, $t0, 0x5900 /* 45EF4 8006AAF4 8D080000 */ lw $t0, ($t0) @@ -97,7 +97,7 @@ glabel func_8006AA34 /* 45F34 8006AB34 3C09A430 */ lui $t1, 0xa430 /* 45F38 8006AB38 8D29000C */ lw $t1, 0xc($t1) /* 45F3C 8006AB3C 1120000B */ beqz $t1, .L8006AB6C -/* 45F40 8006AB40 00000000 */ nop +/* 45F40 8006AB40 00000000 */ nop /* 45F44 8006AB44 3C088009 */ lui $t0, 0x8009 /* 45F48 8006AB48 25085900 */ addiu $t0, $t0, 0x5900 /* 45F4C 8006AB4C 8D080000 */ lw $t0, ($t0) @@ -114,9 +114,9 @@ glabel func_8006AA34 /* 45F74 8006AB74 AF48011C */ sw $t0, 0x11c($k0) /* 45F78 8006AB78 8F480018 */ lw $t0, 0x18($k0) /* 45F7C 8006AB7C 11000014 */ beqz $t0, .L8006ABD0 -/* 45F80 8006AB80 00000000 */ nop +/* 45F80 8006AB80 00000000 */ nop /* 45F84 8006AB84 4448F800 */ cfc1 $t0, $31 -/* 45F88 8006AB88 00000000 */ nop +/* 45F88 8006AB88 00000000 */ nop /* 45F8C 8006AB8C AF48012C */ sw $t0, 0x12c($k0) /* 45F90 8006AB90 F7400130 */ sdc1 $f0, 0x130($k0) /* 45F94 8006AB94 F7420138 */ sdc1 $f2, 0x138($k0) @@ -142,19 +142,19 @@ glabel func_8006AA34 /* 45FE0 8006ABE0 3109007C */ andi $t1, $t0, 0x7c /* 45FE4 8006ABE4 240A0024 */ addiu $t2, $zero, 0x24 /* 45FE8 8006ABE8 112A00BF */ beq $t1, $t2, .L8006AEE8 -/* 45FEC 8006ABEC 00000000 */ nop +/* 45FEC 8006ABEC 00000000 */ nop /* 45FF0 8006ABF0 240A002C */ addiu $t2, $zero, 0x2c /* 45FF4 8006ABF4 112A0110 */ beq $t1, $t2, handle_CPU -/* 45FF8 8006ABF8 00000000 */ nop +/* 45FF8 8006ABF8 00000000 */ nop /* 45FFC 8006ABFC 240A0000 */ addiu $t2, $zero, 0 /* 46000 8006AC00 152A00D2 */ bne $t1, $t2, .L8006AF4C -/* 46004 8006AC04 00000000 */ nop +/* 46004 8006AC04 00000000 */ nop /* 46008 8006AC08 03688024 */ and $s0, $k1, $t0 .L8006AC0C: /* 4600C 8006AC0C 3209FF00 */ andi $t1, $s0, 0xff00 /* 46010 8006AC10 00095302 */ srl $t2, $t1, 0xc /* 46014 8006AC14 15400003 */ bnez $t2, .L8006AC24 -/* 46018 8006AC18 00000000 */ nop +/* 46018 8006AC18 00000000 */ nop /* 4601C 8006AC1C 00095202 */ srl $t2, $t1, 8 /* 46020 8006AC20 214A0010 */ addi $t2, $t2, 0x10 .L8006AC24: @@ -165,7 +165,7 @@ glabel func_8006AA34 /* 46034 8006AC34 002A0821 */ addu $at, $at, $t2 /* 46038 8006AC38 8C2A9DA0 */ lw $t2, -0x6260($at) /* 4603C 8006AC3C 01400008 */ jr $t2 -/* 46040 8006AC40 00000000 */ nop +/* 46040 8006AC40 00000000 */ nop /* 46044 8006AC44 2401DFFF */ addiu $at, $zero, -0x2001 /* 46048 8006AC48 1000FFF0 */ b .L8006AC0C /* 4604C 8006AC4C 02018024 */ and $s0, $s0, $at @@ -176,7 +176,7 @@ glabel func_8006AA34 /* 46060 8006AC60 40895800 */ mtc0 $t1, $11 /* 46064 8006AC64 24040018 */ addiu $a0, $zero, 0x18 /* 46068 8006AC68 0C01ABDF */ jal send_mesg -/* 4606C 8006AC6C 00000000 */ nop +/* 4606C 8006AC6C 00000000 */ nop /* 46070 8006AC70 3C01FFFF */ lui $at, 0xffff /* 46074 8006AC74 34217FFF */ ori $at, $at, 0x7fff /* 46078 8006AC78 1000FFE4 */ b .L8006AC0C @@ -188,18 +188,18 @@ glabel func_8006AA34 /* 46090 8006AC90 21290008 */ addi $t1, $t1, 8 /* 46094 8006AC94 8D2A0000 */ lw $t2, ($t1) /* 46098 8006AC98 11400007 */ beqz $t2, .L8006ACB8 -/* 4609C 8006AC9C 00000000 */ nop +/* 4609C 8006AC9C 00000000 */ nop /* 460A0 8006ACA0 0140F809 */ jalr $t2 /* 460A4 8006ACA4 8D3D0004 */ lw $sp, 4($t1) /* 460A8 8006ACA8 10400003 */ beqz $v0, .L8006ACB8 -/* 460AC 8006ACAC 00000000 */ nop +/* 460AC 8006ACAC 00000000 */ nop /* 460B0 8006ACB0 10000093 */ b .L8006AF00 -/* 460B4 8006ACB4 00000000 */ nop +/* 460B4 8006ACB4 00000000 */ nop .L8006ACB8: /* 460B8 8006ACB8 0C01ABDF */ jal send_mesg /* 460BC 8006ACBC 24040010 */ addiu $a0, $zero, 0x10 /* 460C0 8006ACC0 1000FFD2 */ b .L8006AC0C -/* 460C4 8006ACC4 00000000 */ nop +/* 460C4 8006ACC4 00000000 */ nop /* 460C8 8006ACC8 3C11A430 */ lui $s1, 0xa430 /* 460CC 8006ACCC 8E310008 */ lw $s1, 8($s1) /* 460D0 8006ACD0 3C088009 */ lui $t0, 0x8009 @@ -209,7 +209,7 @@ glabel func_8006AA34 /* 460E0 8006ACE0 02288824 */ and $s1, $s1, $t0 /* 460E4 8006ACE4 32290001 */ andi $t1, $s1, 1 /* 460E8 8006ACE8 11200014 */ beqz $t1, .L8006AD3C -/* 460EC 8006ACEC 00000000 */ nop +/* 460EC 8006ACEC 00000000 */ nop /* 460F0 8006ACF0 3231003E */ andi $s1, $s1, 0x3e /* 460F4 8006ACF4 3C0CA404 */ lui $t4, 0xa404 /* 460F8 8006ACF8 8D8C0010 */ lw $t4, 0x10($t4) @@ -218,33 +218,33 @@ glabel func_8006AA34 /* 46104 8006AD04 AC290010 */ sw $t1, 0x10($at) /* 46108 8006AD08 318C0300 */ andi $t4, $t4, 0x300 /* 4610C 8006AD0C 11800007 */ beqz $t4, .L8006AD2C -/* 46110 8006AD10 00000000 */ nop +/* 46110 8006AD10 00000000 */ nop /* 46114 8006AD14 0C01ABDF */ jal send_mesg /* 46118 8006AD18 24040020 */ addiu $a0, $zero, 0x20 /* 4611C 8006AD1C 12200044 */ beqz $s1, .L8006AE30 -/* 46120 8006AD20 00000000 */ nop +/* 46120 8006AD20 00000000 */ nop /* 46124 8006AD24 10000005 */ b .L8006AD3C -/* 46128 8006AD28 00000000 */ nop +/* 46128 8006AD28 00000000 */ nop .L8006AD2C: /* 4612C 8006AD2C 0C01ABDF */ jal send_mesg /* 46130 8006AD30 24040058 */ addiu $a0, $zero, 0x58 /* 46134 8006AD34 1220003E */ beqz $s1, .L8006AE30 -/* 46138 8006AD38 00000000 */ nop +/* 46138 8006AD38 00000000 */ nop .L8006AD3C: /* 4613C 8006AD3C 32290008 */ andi $t1, $s1, 8 /* 46140 8006AD40 11200008 */ beqz $t1, .L8006AD64 -/* 46144 8006AD44 00000000 */ nop +/* 46144 8006AD44 00000000 */ nop /* 46148 8006AD48 32310037 */ andi $s1, $s1, 0x37 /* 4614C 8006AD4C 3C01A440 */ lui $at, 0xa440 /* 46150 8006AD50 AC200010 */ sw $zero, 0x10($at) /* 46154 8006AD54 0C01ABDF */ jal send_mesg /* 46158 8006AD58 24040038 */ addiu $a0, $zero, 0x38 /* 4615C 8006AD5C 12200034 */ beqz $s1, .L8006AE30 -/* 46160 8006AD60 00000000 */ nop +/* 46160 8006AD60 00000000 */ nop .L8006AD64: /* 46164 8006AD64 32290004 */ andi $t1, $s1, 4 /* 46168 8006AD68 11200009 */ beqz $t1, .L8006AD90 -/* 4616C 8006AD6C 00000000 */ nop +/* 4616C 8006AD6C 00000000 */ nop /* 46170 8006AD70 3231003B */ andi $s1, $s1, 0x3b /* 46174 8006AD74 24090001 */ addiu $t1, $zero, 1 /* 46178 8006AD78 3C01A450 */ lui $at, 0xa450 @@ -252,22 +252,22 @@ glabel func_8006AA34 /* 46180 8006AD80 0C01ABDF */ jal send_mesg /* 46184 8006AD84 24040030 */ addiu $a0, $zero, 0x30 /* 46188 8006AD88 12200029 */ beqz $s1, .L8006AE30 -/* 4618C 8006AD8C 00000000 */ nop +/* 4618C 8006AD8C 00000000 */ nop .L8006AD90: /* 46190 8006AD90 32290002 */ andi $t1, $s1, 2 /* 46194 8006AD94 11200008 */ beqz $t1, .L8006ADB8 -/* 46198 8006AD98 00000000 */ nop +/* 46198 8006AD98 00000000 */ nop /* 4619C 8006AD9C 3231003D */ andi $s1, $s1, 0x3d /* 461A0 8006ADA0 3C01A480 */ lui $at, 0xa480 /* 461A4 8006ADA4 AC200018 */ sw $zero, 0x18($at) /* 461A8 8006ADA8 0C01ABDF */ jal send_mesg /* 461AC 8006ADAC 24040028 */ addiu $a0, $zero, 0x28 /* 461B0 8006ADB0 1220001F */ beqz $s1, .L8006AE30 -/* 461B4 8006ADB4 00000000 */ nop +/* 461B4 8006ADB4 00000000 */ nop .L8006ADB8: /* 461B8 8006ADB8 32290010 */ andi $t1, $s1, 0x10 /* 461BC 8006ADBC 11200013 */ beqz $t1, .L8006AE0C -/* 461C0 8006ADC0 00000000 */ nop +/* 461C0 8006ADC0 00000000 */ nop /* 461C4 8006ADC4 3231002F */ andi $s1, $s1, 0x2f /* 461C8 8006ADC8 24090002 */ addiu $t1, $zero, 2 /* 461CC 8006ADCC 3C01A460 */ lui $at, 0xa460 @@ -276,22 +276,22 @@ glabel func_8006AA34 /* 461D8 8006ADD8 25295938 */ addiu $t1, $t1, 0x5938 /* 461DC 8006ADDC 8D2A0000 */ lw $t2, ($t1) /* 461E0 8006ADE0 11400006 */ beqz $t2, .L8006ADFC -/* 461E4 8006ADE4 00000000 */ nop +/* 461E4 8006ADE4 00000000 */ nop /* 461E8 8006ADE8 8D3D0004 */ lw $sp, 4($t1) /* 461EC 8006ADEC 0140F809 */ jalr $t2 /* 461F0 8006ADF0 00402021 */ addu $a0, $v0, $zero /* 461F4 8006ADF4 14400003 */ bnez $v0, .L8006AE04 -/* 461F8 8006ADF8 00000000 */ nop +/* 461F8 8006ADF8 00000000 */ nop .L8006ADFC: /* 461FC 8006ADFC 0C01ABDF */ jal send_mesg /* 46200 8006AE00 24040040 */ addiu $a0, $zero, 0x40 .L8006AE04: /* 46204 8006AE04 1220000A */ beqz $s1, .L8006AE30 -/* 46208 8006AE08 00000000 */ nop +/* 46208 8006AE08 00000000 */ nop .L8006AE0C: /* 4620C 8006AE0C 32290020 */ andi $t1, $s1, 0x20 /* 46210 8006AE10 11200007 */ beqz $t1, .L8006AE30 -/* 46214 8006AE14 00000000 */ nop +/* 46214 8006AE14 00000000 */ nop /* 46218 8006AE18 3231001F */ andi $s1, $s1, 0x1f /* 4621C 8006AE1C 24090800 */ addiu $t1, $zero, 0x800 /* 46220 8006AE20 3C01A430 */ lui $at, 0xa430 @@ -310,7 +310,7 @@ glabel func_8006AA34 /* 46250 8006AE50 252958FC */ addiu $t1, $t1, 0x58fc /* 46254 8006AE54 8D2A0000 */ lw $t2, ($t1) /* 46258 8006AE58 11400004 */ beqz $t2, .L8006AE6C -/* 4625C 8006AE5C 00000000 */ nop +/* 4625C 8006AE5C 00000000 */ nop /* 46260 8006AE60 2401EFFF */ addiu $at, $zero, -0x1001 /* 46264 8006AE64 10000026 */ b .L8006AF00 /* 46268 8006AE68 02018024 */ and $s0, $s0, $at @@ -333,7 +333,7 @@ glabel func_8006AA34 /* 462A8 8006AEA8 40886800 */ mtc0 $t0, $13 /* 462AC 8006AEAC 24040008 */ addiu $a0, $zero, 8 /* 462B0 8006AEB0 0C01ABDF */ jal send_mesg -/* 462B4 8006AEB4 00000000 */ nop +/* 462B4 8006AEB4 00000000 */ nop /* 462B8 8006AEB8 2401FDFF */ addiu $at, $zero, -0x201 /* 462BC 8006AEBC 1000FF53 */ b .L8006AC0C /* 462C0 8006AEC0 02018024 */ and $s0, $s0, $at @@ -342,7 +342,7 @@ glabel func_8006AA34 /* 462CC 8006AECC 40886800 */ mtc0 $t0, $13 /* 462D0 8006AED0 24040000 */ addiu $a0, $zero, 0 /* 462D4 8006AED4 0C01ABDF */ jal send_mesg -/* 462D8 8006AED8 00000000 */ nop +/* 462D8 8006AED8 00000000 */ nop /* 462DC 8006AEDC 2401FEFF */ addiu $at, $zero, -0x101 /* 462E0 8006AEE0 1000FF4A */ b .L8006AC0C /* 462E4 8006AEE4 02018024 */ and $s0, $s0, $at @@ -352,7 +352,7 @@ glabel func_8006AA34 /* 462F0 8006AEF0 0C01ABDF */ jal send_mesg /* 462F4 8006AEF4 24040050 */ addiu $a0, $zero, 0x50 /* 462F8 8006AEF8 10000001 */ b .L8006AF00 -/* 462FC 8006AEFC 00000000 */ nop +/* 462FC 8006AEFC 00000000 */ nop .L8006AF00: /* 46300 8006AF00 8F490004 */ lw $t1, 4($k0) /* 46304 8006AF04 3C0A8009 */ lui $t2, 0x8009 @@ -360,13 +360,13 @@ glabel func_8006AA34 /* 4630C 8006AF0C 8D4B0004 */ lw $t3, 4($t2) /* 46310 8006AF10 012B082A */ slt $at, $t1, $t3 /* 46314 8006AF14 10200007 */ beqz $at, .L8006AF34 -/* 46318 8006AF18 00000000 */ nop +/* 46318 8006AF18 00000000 */ nop /* 4631C 8006AF1C 03402821 */ addu $a1, $k0, $zero /* 46320 8006AF20 3C048009 */ lui $a0, 0x8009 /* 46324 8006AF24 0C01AC5D */ jal osEnqueueThread /* 46328 8006AF28 24844658 */ addiu $a0, $a0, 0x4658 /* 4632C 8006AF2C 0801AC75 */ j osDispatchThread -/* 46330 8006AF30 00000000 */ nop +/* 46330 8006AF30 00000000 */ nop .L8006AF34: /* 46334 8006AF34 3C098009 */ lui $t1, 0x8009 /* 46338 8006AF38 25294658 */ addiu $t1, $t1, 0x4658 @@ -386,7 +386,7 @@ glabel func_8006AA34 /* 4636C 8006AF6C 0C01ABDF */ jal send_mesg /* 46370 8006AF70 24040060 */ addiu $a0, $zero, 0x60 /* 46374 8006AF74 0801AC75 */ j osDispatchThread -/* 46378 8006AF78 00000000 */ nop +/* 46378 8006AF78 00000000 */ nop glabel send_mesg /* 4637C 8006AF7C 03E09021 */ addu $s2, $ra, $zero @@ -395,24 +395,24 @@ glabel send_mesg /* 46388 8006AF88 01445021 */ addu $t2, $t2, $a0 /* 4638C 8006AF8C 8D490000 */ lw $t1, ($t2) /* 46390 8006AF90 11200027 */ beqz $t1, .L8006B030 -/* 46394 8006AF94 00000000 */ nop +/* 46394 8006AF94 00000000 */ nop /* 46398 8006AF98 8D2B0008 */ lw $t3, 8($t1) /* 4639C 8006AF9C 8D2C0010 */ lw $t4, 0x10($t1) /* 463A0 8006AFA0 016C082A */ slt $at, $t3, $t4 /* 463A4 8006AFA4 10200022 */ beqz $at, .L8006B030 -/* 463A8 8006AFA8 00000000 */ nop +/* 463A8 8006AFA8 00000000 */ nop /* 463AC 8006AFAC 8D2D000C */ lw $t5, 0xc($t1) /* 463B0 8006AFB0 01AB6821 */ addu $t5, $t5, $t3 /* 463B4 8006AFB4 01AC001A */ div $zero, $t5, $t4 /* 463B8 8006AFB8 15800002 */ bnez $t4, .L8006AFC4 -/* 463BC 8006AFBC 00000000 */ nop +/* 463BC 8006AFBC 00000000 */ nop /* 463C0 8006AFC0 0007000D */ break 7 .L8006AFC4: /* 463C4 8006AFC4 2401FFFF */ addiu $at, $zero, -1 /* 463C8 8006AFC8 15810004 */ bne $t4, $at, .L8006AFDC /* 463CC 8006AFCC 3C018000 */ lui $at, 0x8000 /* 463D0 8006AFD0 15A10002 */ bne $t5, $at, .L8006AFDC -/* 463D4 8006AFD4 00000000 */ nop +/* 463D4 8006AFD4 00000000 */ nop /* 463D8 8006AFD8 0006000D */ break 6 .L8006AFDC: /* 463DC 8006AFDC 00006810 */ mfhi $t5 @@ -428,7 +428,7 @@ glabel send_mesg /* 46404 8006B004 8D2A0000 */ lw $t2, ($t1) /* 46408 8006B008 8D4B0000 */ lw $t3, ($t2) /* 4640C 8006B00C 11600008 */ beqz $t3, .L8006B030 -/* 46410 8006B010 00000000 */ nop +/* 46410 8006B010 00000000 */ nop /* 46414 8006B014 0C01AC6F */ jal osPopThread /* 46418 8006B018 01202021 */ addu $a0, $t1, $zero /* 4641C 8006B01C 00405021 */ addu $t2, $v0, $zero @@ -438,7 +438,7 @@ glabel send_mesg /* 4642C 8006B02C 24844658 */ addiu $a0, $a0, 0x4658 .L8006B030: /* 46430 8006B030 02400008 */ jr $s2 -/* 46434 8006B034 00000000 */ nop +/* 46434 8006B034 00000000 */ nop glabel handle_CPU /* 46438 8006B038 3C013000 */ lui $at, 0x3000 @@ -446,7 +446,7 @@ glabel handle_CPU /* 46440 8006B040 00094F02 */ srl $t1, $t1, 0x1c /* 46444 8006B044 240A0001 */ addiu $t2, $zero, 1 /* 46448 8006B048 152AFFC0 */ bne $t1, $t2, .L8006AF4C -/* 4644C 8006B04C 00000000 */ nop +/* 4644C 8006B04C 00000000 */ nop /* 46450 8006B050 24090001 */ addiu $t1, $zero, 1 /* 46454 8006B054 AF490018 */ sw $t1, 0x18($k0) /* 46458 8006B058 8F5B0118 */ lw $k1, 0x118($k0) @@ -476,9 +476,9 @@ glabel osEnqueueAndYield /* 464B0 8006B0B0 ACBF011C */ sw $ra, 0x11c($a1) /* 464B4 8006B0B4 8CBB0018 */ lw $k1, 0x18($a1) /* 464B8 8006B0B8 1360000A */ beqz $k1, .L8006B0E4 -/* 464BC 8006B0BC 00000000 */ nop +/* 464BC 8006B0BC 00000000 */ nop /* 464C0 8006B0C0 445BF800 */ cfc1 $k1, $31 -/* 464C4 8006B0C4 00000000 */ nop +/* 464C4 8006B0C4 00000000 */ nop /* 464C8 8006B0C8 ACBB012C */ sw $k1, 0x12c($a1) /* 464CC 8006B0CC F4B40180 */ sdc1 $f20, 0x180($a1) /* 464D0 8006B0D0 F4B60188 */ sdc1 $f22, 0x188($a1) @@ -490,7 +490,7 @@ glabel osEnqueueAndYield /* 464E4 8006B0E4 8CBB0118 */ lw $k1, 0x118($a1) /* 464E8 8006B0E8 3369FF00 */ andi $t1, $k1, 0xff00 /* 464EC 8006B0EC 1120000D */ beqz $t1, .L8006B124 -/* 464F0 8006B0F0 00000000 */ nop +/* 464F0 8006B0F0 00000000 */ nop /* 464F4 8006B0F4 3C088009 */ lui $t0, 0x8009 /* 464F8 8006B0F8 25085900 */ addiu $t0, $t0, 0x5900 /* 464FC 8006B0FC 8D080000 */ lw $t0, ($t0) @@ -507,7 +507,7 @@ glabel osEnqueueAndYield /* 46524 8006B124 3C1BA430 */ lui $k1, 0xa430 /* 46528 8006B128 8F7B000C */ lw $k1, 0xc($k1) /* 4652C 8006B12C 1360000B */ beqz $k1, .L8006B15C -/* 46530 8006B130 00000000 */ nop +/* 46530 8006B130 00000000 */ nop /* 46534 8006B134 3C1A8009 */ lui $k0, 0x8009 /* 46538 8006B138 275A5900 */ addiu $k0, $k0, 0x5900 /* 4653C 8006B13C 8F5A0000 */ lw $k0, ($k0) @@ -522,10 +522,10 @@ glabel osEnqueueAndYield /* 4655C 8006B15C 10800003 */ beqz $a0, .L8006B16C /* 46560 8006B160 ACBB0128 */ sw $k1, 0x128($a1) /* 46564 8006B164 0C01AC5D */ jal osEnqueueThread -/* 46568 8006B168 00000000 */ nop +/* 46568 8006B168 00000000 */ nop .L8006B16C: /* 4656C 8006B16C 0801AC75 */ j osDispatchThread -/* 46570 8006B170 00000000 */ nop +/* 46570 8006B170 00000000 */ nop glabel osEnqueueThread /* 46574 8006B174 0080C821 */ addu $t9, $a0, $zero @@ -534,14 +534,14 @@ glabel osEnqueueThread /* 46580 8006B180 8F0E0004 */ lw $t6, 4($t8) /* 46584 8006B184 01CF082A */ slt $at, $t6, $t7 /* 46588 8006B188 14200007 */ bnez $at, .L8006B1A8 -/* 4658C 8006B18C 00000000 */ nop +/* 4658C 8006B18C 00000000 */ nop .L8006B190: /* 46590 8006B190 0300C821 */ addu $t9, $t8, $zero /* 46594 8006B194 8F180000 */ lw $t8, ($t8) /* 46598 8006B198 8F0E0004 */ lw $t6, 4($t8) /* 4659C 8006B19C 01CF082A */ slt $at, $t6, $t7 /* 465A0 8006B1A0 1020FFFB */ beqz $at, .L8006B190 -/* 465A4 8006B1A4 00000000 */ nop +/* 465A4 8006B1A4 00000000 */ nop .L8006B1A8: /* 465A8 8006B1A8 8F380000 */ lw $t8, ($t9) /* 465AC 8006B1AC ACB80000 */ sw $t8, ($a1) @@ -555,7 +555,7 @@ glabel osPopThread /* 465C4 8006B1C4 03E00008 */ jr $ra /* 465C8 8006B1C8 AC990000 */ sw $t9, ($a0) /* 465CC 8006B1CC 03E00008 */ jr $ra -/* 465D0 8006B1D0 00000000 */ nop +/* 465D0 8006B1D0 00000000 */ nop glabel osDispatchThread /* 465D4 8006B1D4 3C048009 */ lui $a0, 0x8009 @@ -615,7 +615,7 @@ glabel osDispatchThread /* 466AC 8006B2AC 409B7000 */ mtc0 $k1, $14 /* 466B0 8006B2B0 8F5B0018 */ lw $k1, 0x18($k0) /* 466B4 8006B2B4 13600013 */ beqz $k1, .L8006B304 -/* 466B8 8006B2B8 00000000 */ nop +/* 466B8 8006B2B8 00000000 */ nop /* 466BC 8006B2BC 8F5B012C */ lw $k1, 0x12c($k0) /* 466C0 8006B2C0 44DBF800 */ ctc1 $k1, $31 /* 466C4 8006B2C4 D7400130 */ ldc1 $f0, 0x130($k0) @@ -649,12 +649,12 @@ glabel osDispatchThread /* 46730 8006B330 3C1AA430 */ lui $k0, 0xa430 /* 46734 8006B334 375A000C */ ori $k0, $k0, 0xc /* 46738 8006B338 AF5B0000 */ sw $k1, ($k0) -/* 4673C 8006B33C 00000000 */ nop -/* 46740 8006B340 00000000 */ nop -/* 46744 8006B344 00000000 */ nop -/* 46748 8006B348 00000000 */ nop -/* 4674C 8006B34C 42000018 */ eret +/* 4673C 8006B33C 00000000 */ nop +/* 46740 8006B340 00000000 */ nop +/* 46744 8006B344 00000000 */ nop +/* 46748 8006B348 00000000 */ nop +/* 4674C 8006B34C 42000018 */ eret /* 46750 8006B350 00002021 */ addu $a0, $zero, $zero /* 46754 8006B354 0C01B254 */ jal osDestroyThread -/* 46758 8006B358 00000000 */ nop -/* 4675C 8006B35C 00000000 */ nop +/* 46758 8006B358 00000000 */ nop +/* 4675C 8006B35C 00000000 */ nop diff --git a/diff_settings.py b/diff_settings.py index 9a3533337a..52c1cfe713 100644 --- a/diff_settings.py +++ b/diff_settings.py @@ -5,3 +5,4 @@ def apply(config, args): config['myimg'] = 'papermario.z64' config['mapfile'] = 'build/papermario.map' config['source_directories'] = ['.'] + config['makeflags'] = ['COMPARE=0', 'WATCH_INCLUDES=0'] diff --git a/sources.mk b/sources.mk index 9706dbe917..47d7169a4c 100644 --- a/sources.mk +++ b/sources.mk @@ -1,35 +1,57 @@ -### ASSETS_FS and ASSETS_FS_SOURCES ### +OBJECTS := $(subst BUILD_DIR, $(BUILD_DIR), $(shell grep -E 'BUILD_DIR.+\.o' papermario.ld -o)) -# The asset filesystem path. -ASSETS_FS = assets/fs +DSL_C_FILES := $(shell grep -lrF "SCRIPT" src) -# Source files to build the asset filesystem with. Each of these must be configured in `assets/fs.json'. -ASSETS_FS_SOURCES = $(wildcard $(ASSETS_FS)/*.bin) +MAPS := \ + dro_01 dro_02 \ + hos_00 hos_01 hos_02 hos_03 hos_04 hos_05 hos_06 hos_10 hos_20 \ + isk_01 isk_02 isk_03 isk_04 isk_05 isk_06 isk_07 isk_08 isk_09 isk_10 isk_11 isk_12 isk_13 isk_14 isk_16 isk_18 isk_19 \ + iwa_00 iwa_01 iwa_02 iwa_03 iwa_04 iwa_10 iwa_11 \ + osr_00 osr_01 osr_02 osr_03 kkj_00 kkj_01 kkj_02 kkj_03 kkj_10 kkj_11 kkj_12 kkj_13 kkj_14 kkj_15 kkj_16 kkj_17 kkj_18 kkj_19 kkj_20 kkj_21 kkj_22 kkj_23 kkj_24 kkj_25 kkj_26 kkj_27 kkj_28 kkj_29 \ + kmr_00 kmr_02 kmr_03 kmr_04 kmr_05 kmr_06 kmr_07 kmr_09 kmr_10 kmr_11 kmr_12 kmr_20 kmr_30 \ + kpa_01 kpa_03 kpa_04 kpa_08 kpa_09 kpa_10 kpa_11 kpa_12 kpa_13 kpa_14 kpa_15 kpa_16 kpa_17 kpa_32 kpa_33 kpa_40 kpa_41 kpa_50 kpa_52 kpa_60 kpa_61 kpa_62 kpa_63 kpa_70 kpa_80 kpa_90 kpa_91 kpa_94 kpa_95 kpa_96 kpa_102 kpa_111 kpa_112 kpa_113 kpa_115 kpa_116 kpa_117 kpa_118 kpa_119 kpa_121 kpa_130 kpa_133 kpa_134 \ + machi mac_00 mac_01 mac_02 mac_03 mac_04 mac_05 mac_06 \ + tik_01 tik_02 tik_03 tik_04 tik_05 tik_06 tik_07 tik_08 tik_09 tik_10 tik_12 tik_14 tik_15 tik_17 tik_18 tik_19 tik_20 tik_21 tik_22 tik_23 tik_25 \ + kgr_01 kgr_02 \ + nok_01 nok_02 nok_03 nok_04 nok_11 nok_12 nok_13 nok_14 nok_15 \ + sbk_00 sbk_01 sbk_02 sbk_03 sbk_04 sbk_05 sbk_06 sbk_10 sbk_11 sbk_12 sbk_13 sbk_14 sbk_15 sbk_16 sbk_20 sbk_21 sbk_22 sbk_23 sbk_24 sbk_25 sbk_26 sbk_30 sbk_31 sbk_32 sbk_33 sbk_34 sbk_35 sbk_36 sbk_40 sbk_41 sbk_42 sbk_43 sbk_44 sbk_45 sbk_46 sbk_50 sbk_51 sbk_52 sbk_53 sbk_54 sbk_55 sbk_56 sbk_60 sbk_61 sbk_62 sbk_63 sbk_64 sbk_65 sbk_66 sbk_99 \ + trd_00 trd_01 trd_02 trd_03 trd_04 trd_05 trd_06 trd_07 trd_08 trd_09 trd_10 \ + tst_01 tst_02 tst_03 tst_04 tst_10 tst_11 tst_12 tst_13 tst_20 \ + jan_00 jan_01 jan_02 jan_03 jan_04 jan_05 jan_06 jan_07 jan_08 jan_09 jan_10 jan_11 jan_12 jan_13 jan_14 jan_15 jan_16 jan_17 jan_18 jan_19 jan_22 jan_23 \ + mim_01 mim_02 mim_03 mim_04 mim_05 mim_06 mim_07 mim_08 mim_09 mim_10 mim_11 mim_12 \ + obk_01 obk_02 obk_03 obk_04 obk_05 obk_06 obk_07 obk_08 obk_09 \ + arn_02 arn_03 arn_04 arn_05 arn_07 arn_08 arn_09 arn_10 arn_11 arn_12 arn_13 arn_20 \ + dgb_01 dgb_02 dgb_03 dgb_04 dgb_05 dgb_06 dgb_07 dgb_08 dgb_09 dgb_10 dgb_11 dgb_12 dgb_13 dgb_14 dgb_15 dgb_16 dgb_17 dgb_18 \ + kzn_01 kzn_02 kzn_03 kzn_04 kzn_05 kzn_06 kzn_07 kzn_08 kzn_09 kzn_10 kzn_11 kzn_17 kzn_18 kzn_19 kzn_20 kzn_22 kzn_23 \ + flo_00 flo_03 flo_07 flo_08 flo_09 flo_10 flo_11 flo_12 flo_13 flo_14 flo_15 flo_16 flo_17 flo_18 flo_19 flo_21 flo_22 flo_23 flo_24 flo_25 \ + sam_01 sam_02 sam_03 sam_04 sam_05 sam_06 sam_07 sam_08 sam_09 sam_10 sam_11 sam_12 \ + pra_01 pra_02 pra_03 pra_04 pra_05 pra_09 pra_10 pra_11 pra_13 pra_14 pra_15 pra_16 pra_18 pra_19 pra_20 pra_21 pra_22 pra_29 pra_31 pra_32 pra_33 pra_34 pra_35 pra_40 \ + omo_01 omo_02 omo_03 omo_04 omo_05 omo_06 omo_07 omo_08 omo_09 omo_10 omo_11 omo_12 omo_13 omo_14 omo_15 omo_16 omo_17 \ + end_00 end_01 \ + mgm_00 mgm_01 mgm_02 mgm_03 \ + gv_01 \ + kmr_bt03 kmr_bt04 kmr_bt05 kmr_bt06 \ + nok_bt01 nok_bt02 nok_bt03 nok_bt04 \ + trd_bt00 trd_bt01 trd_bt02 trd_bt03 trd_bt04 trd_bt05 \ + iwa_bt01 iwa_bt02 \ + sbk_bt02 \ + isk_bt01 isk_bt02 isk_bt03 isk_bt04 isk_bt05 isk_bt06 isk_bt07 isk_bt08 \ + arn_bt01 arn_bt02 arn_bt03 arn_bt04 arn_bt05 arn_bt06 \ + dgb_bt01 dgb_bt02 dgb_bt03 dgb_bt04 dgb_bt05 \ + mim_bt01 \ + omo_bt01 omo_bt02 omo_bt03 omo_bt04 omo_bt05 omo_bt06 omo_bt07 \ + kgr_bt01 flo_bt01 flo_bt02 flo_bt03 flo_bt04 flo_bt05 flo_bt06 \ + jan_bt00 jan_bt01 jan_bt02 jan_bt03 jan_bt04 \ + kzn_bt01 kzn_bt02 kzn_bt04 kzn_bt05 sam_bt01 sam_bt02 sam_bt03 sam_bt04 \ + tik_bt01 tik_bt02 tik_bt03 tik_bt04 tik_bt05 \ + pra_bt01 pra_bt02 pra_bt03 pra_bt04 mac_bt01 mac_bt02 \ + kpa_bt01 kpa_bt02 kpa_bt03 kpa_bt04 kpa_bt05 kpa_bt07 kpa_bt08 kpa_bt09 kpa_bt11 kpa_bt13 kpa_bt14 \ + hos_bt01 hos_bt02 \ + kkj_bt01 kkj_bt02 - -### OBJECTS ### - -C_FILES = $(shell find src -type f -name "*.c" -not -name "*.inc.c") -S_FILES = $(wildcard asm/*.s asm/os/*.s) - -BIN_FILES = $(foreach dir, $(shell mkdir -p bin && find bin -type d -not -name Yay0), $(wildcard $(dir)/*.bin)) -COMPRESSED_BIN_FILES = $(wildcard bin/Yay0/*.bin) - -# The OBJECTS variable holds the filenames of all object files to be linked. -# Each of these objects should appear in `papermario.ld' (generated by n64splat). -# -# The extension of each object file specifies its source type (and, therefore, how it should be built): -# -# Object ext | Source ext | Description -# ------------+------------+------------- -# .o | | Special; must have build steps declared here -# .c.o | .c | C sourcecode -# .s.o | .s | Assembly (built with modern assembler) -# .bin.o | .bin | Uncompressed data -# .Yay0.o | .bin | Compressed data -# -# Note that ASSETS_FS is linked implicitly and does not need to be listed here. - -OBJECTS = \ - $(foreach file, $(C_FILES) $(S_FILES) $(BIN_FILES), $(BUILD_DIR)/$(file).o) \ - $(foreach file, $(COMPRESSED_BIN_FILES), $(BUILD_DIR)/$(file:.bin=.Yay0.o)) +ASSETS := \ + $(foreach map, $(MAPS), $(map)_shape $(map)_hit) \ + mac_tex tik_tex kgr_tex kmr_tex iwa_tex sbk_tex dro_tex isk_tex trd_tex nok_tex hos_tex kpa_tex osr_tex kkj_tex tst_tex jan_tex mim_tex obk_tex arn_tex dgb_tex kzn_tex flo_tex sam_tex pra_tex omo_tex end_tex mgm_tex gv__tex \ + kmr_bg nok_bg sbk_bg sbk3_bg iwa_bg hos_bg arn_bg obk_bg omo_bg yos_bg jan_bg fla_bg flb_bg sra_bg yki_bg sam_bg kpa_bg title_bg \ + title_data \ + party_kurio party_kameki party_pinki party_pareta party_resa party_akari party_opuku party_pokopi diff --git a/tools/build_assets_fs.py b/tools/build_assets_bin.py similarity index 52% rename from tools/build_assets_fs.py rename to tools/build_assets_bin.py index 2830691963..cd986890fc 100755 --- a/tools/build_assets_fs.py +++ b/tools/build_assets_bin.py @@ -1,43 +1,40 @@ #! /usr/bin/python3 import os -import json -import sys -from subprocess import call +from sys import argv from pathlib import Path -import shutil - -tools_dir = Path(__file__).parent.absolute() def next_multiple(pos, multiple): return pos + pos % multiple -def build_mapfs(src_dir, build_dir, out_bin): - with open(src_dir + ".json", "r") as f: - config = json.loads(f.read()) - +def build_mapfs(out_bin, assets): # every TOC entry's name field has data after the null terminator made up from all the previous name fields. # we probably don't have to do this for the game to read the data properly (it doesn't read past the null terminator # of `string`), but the original devs' equivalent to build_assets_fs.py had this bug so we need to replicate it to match. written_names = [] with open(out_bin, "wb") as f: - f.write(config["title"].encode("ascii")) + f.write("Map Ver.00/11/07 15:36".encode("ascii")) - next_data_pos = (len(config["assets"]) + 1) * 0x1C + next_data_pos = (len(assets) + 1) * 0x1C asset_idx = 0 - for asset in config["assets"]: + for decompressed in assets: toc_entry_pos = 0x20 + asset_idx * 0x1C - src_path = Path(src_dir, asset["path"]) - build_path = Path(build_dir, asset["path"]) + decompressed = Path(decompressed) + compressed = decompressed.with_suffix(".Yay0") + + # non-texture assets should be compressed + if not decompressed.stem.endswith("_tex") and not compressed.exists(): + print(f"uncompressed asset: {decompressed} (expected {compressed} to exist)") + exit(1) # data for TOC entry - name = asset["name"] + "\0" + name = decompressed.stem + "\0" offset = next_data_pos - size = next_multiple(build_path.stat().st_size, 2) - decompressed_size = src_path.stat().st_size + decompressed_size = decompressed.stat().st_size + size = next_multiple(compressed.stat().st_size, 2) if compressed.exists() else decompressed_size #print(f"{name} {offset:08X} {size:08X} {decompressed_size:08X}") @@ -55,7 +52,7 @@ def build_mapfs(src_dir, build_dir, out_bin): # write data. f.seek(0x20 + next_data_pos) - f.write(build_path.read_bytes()) + f.write(compressed.read_bytes() if compressed.exists() else decompressed.read_bytes()) next_data_pos += size asset_idx += 1 @@ -71,36 +68,8 @@ def build_mapfs(src_dir, build_dir, out_bin): f.seek(toc_entry_pos + 0x18) f.write((0x903F0000).to_bytes(4, byteorder="big")) # TODO: figure out purpose -def build_file(src_dir, out_dir, filename): - with open(src_dir + ".json", "r") as f: - config = json.loads(f.read()) - - asset = None - for a in config["assets"]: - if (a["path"] == filename): - asset = a - - if not asset: - print("asset not configured in {}.json".format(src_dir)) - exit(1) - - src_path = Path(src_dir, filename) - out_path = Path(out_dir, filename) - - if asset["compress"]: - call([f"{tools_dir}/Yay0compress", src_path, out_path]) - else: - shutil.copy(src_path, out_path) - if __name__ == "__main__": - sys.argv.pop(0) - src = sys.argv.pop(0) - dest = sys.argv.pop(0) + argv.pop(0) # python3 + out = argv.pop(0) - if len(sys.argv) > 0: - # copy (and compress if required) the given file(s) - while len(sys.argv) > 0: - build_file(src, dest, sys.argv.pop()) - else: - # build the aggregate file - build_mapfs(src, dest, dest + ".bin") + build_mapfs(out, argv) diff --git a/tools/compile_dsl_macros.py b/tools/compile_dsl_macros.py index de4976a835..d62cab7d29 100755 --- a/tools/compile_dsl_macros.py +++ b/tools/compile_dsl_macros.py @@ -8,11 +8,11 @@ import traceback def eprint(*args, **kwargs): print(*args, file=stderr, **kwargs) -write_buf = "" +#write_buf = "" def write(s): - global write_buf - write_buf += s - #print(s, end="") + #global write_buf + #write_buf += s + print(s, end="") ANSI_RED = "\033[1;31;40m" ANSI_RESET = "\u001b[0m" @@ -436,7 +436,7 @@ def read_until_closing_paren(depth=1, lex_strings=False): string_escape = False while True: - char = f.read(1) + char = stdin.read(1) if len(char) == 0: # EOF @@ -463,7 +463,7 @@ def read_line(): line = "" while True: - char = f.read(1) + char = stdin.read(1) if len(char) == 0: # EOF @@ -501,115 +501,107 @@ if __name__ == "__main__": file_info = [] error = False - num_scripts = int(stdin.read()) - if num_scripts == 0: - exit(0) - print(f"compiling {num_scripts} scripts") + macro_name = "" # captures recent UPPER_CASE identifier + prev_char = "" + while True: + char = stdin.read(1) - with open(argv[1], 'r') as f: - macro_name = "" # captures recent UPPER_CASE identifier - prev_char = "" - while True: - char = f.read(1) + if len(char) == 0: + # EOF + write(macro_name) + break - if len(char) == 0: - # EOF - write(macro_name) - break + if char == "#" and (prev_char == "\n" or prev_char == ""): + # cpp line/file marker + line = read_line() + line_split = line[1:].split(" ") - if char == "#" and (prev_char == "\n" or prev_char == ""): - # cpp line/file marker - line = read_line() - line_split = line[1:].split(" ") + line_no = int(line_split[0]) + file_info = line_split[1:] - line_no = int(line_split[0]) - file_info = line_split[1:] + write("#" + line + "\n") + elif char == "(": + filename = file_info[0][1:-1] - write("#" + line + "\n") - elif char == "(": - filename = file_info[0][1:-1] + # SCRIPT(...) + if macro_name == "SCRIPT": + script_source, line_map = gen_line_map(read_until_closing_paren(lex_strings=True), source_line_no=line_no) - # SCRIPT(...) - if macro_name == "SCRIPT": - script_source, line_map = gen_line_map(read_until_closing_paren(lex_strings=True), source_line_no=line_no) + try: + commands = compile_script(script_source) - try: - commands = compile_script(script_source) + write("{\n") + for command in commands: + if command.meta: + write(f"# {line_map[command.meta.line]} {file_info[0]}\n") + write(" ") + for word in command.to_bytecode(): + if type(word) == str: + write(word) + elif type(word) == int: + write(f"0x{word & 0xFFFFFFFF:X}") + else: + raise Exception(f"{command}.to_bytecode() gave {type(word)} {word}") + write(", ") + write("\n") + write("}") + except exceptions.UnexpectedEOF as e: + eprint(f"{filename}:{line_no}: {ANSI_RED}error{ANSI_RESET}: unterminated SCRIPT(...) macro") + error = True + except exceptions.UnexpectedCharacters as e: + line = line_map[e.line] + char = script_source[e.pos_in_stream] + allowed = e.allowed - write("{\n") - for command in commands: - if command.meta: - write(f"# {line_map[command.meta.line]} {file_info[0]}\n") - write(" ") - for word in command.to_bytecode(): - if type(word) == str: - write(word) - elif type(word) == int: - write(f"0x{word & 0xFFFFFFFF:X}") - else: - raise Exception(f"{command}.to_bytecode() gave {type(word)} {word}") - write(", ") - write("\n") - write("}") - except exceptions.UnexpectedEOF as e: - eprint(f"{filename}:{line_no}: {ANSI_RED}error{ANSI_RESET}: unterminated SCRIPT(...) macro") - error = True - except exceptions.UnexpectedCharacters as e: - line = line_map[e.line] - char = script_source[e.pos_in_stream] - allowed = e.allowed + eprint(f"{filename}:{line}: {ANSI_RED}script parse error{ANSI_RESET}: unexpected `{char}', expected {' or '.join(allowed)}") + eprint(e.get_context(script_source)) - eprint(f"{filename}:{line}: {ANSI_RED}script parse error{ANSI_RESET}: unexpected `{char}', expected {' or '.join(allowed)}") - eprint(e.get_context(script_source)) + error = True + except exceptions.UnexpectedToken as e: + line = line_map[e.line] - error = True - except exceptions.UnexpectedToken as e: - line = line_map[e.line] + eprint(f"{filename}:{line}: {ANSI_RED}script parse error{ANSI_RESET}: unexpected `{e.token}'") + eprint(e.get_context(script_source)) - eprint(f"{filename}:{line}: {ANSI_RED}script parse error{ANSI_RESET}: unexpected `{e.token}'") - eprint(e.get_context(script_source)) - - error = True - except exceptions.VisitError as e: - if type(e.orig_exc) == CompileError: - line = line_map[e.orig_exc.meta.line] - eprint(f"{filename}:{line}: {ANSI_RED}script compile error{ANSI_RESET}: {e.orig_exc}") - else: - eprint(f"{filename}:{line_no}: {ANSI_RED}internal script transform error{ANSI_RESET}") - traceback.print_exc() - error = True - except CompileError as e: - line = line_map[e.meta.line] - eprint(f"{filename}:{line}: {ANSI_RED}script compile error{ANSI_RESET}: {e}") - error = True - except Exception as e: - eprint(f"{filename}:{line_no}: {ANSI_RED}internal script compilation error{ANSI_RESET}") + error = True + except exceptions.VisitError as e: + if type(e.orig_exc) == CompileError: + line = line_map[e.orig_exc.meta.line] + eprint(f"{filename}:{line}: {ANSI_RED}script compile error{ANSI_RESET}: {e.orig_exc}") + else: + eprint(f"{filename}:{line_no}: {ANSI_RED}internal script transform error{ANSI_RESET}") traceback.print_exc() - error = True + error = True + except CompileError as e: + line = line_map[e.meta.line] + eprint(f"{filename}:{line}: {ANSI_RED}script compile error{ANSI_RESET}: {e}") + error = True + except Exception as e: + eprint(f"{filename}:{line_no}: {ANSI_RED}internal script compilation error{ANSI_RESET}") + traceback.print_exc() + error = True - line_no += script_source.count("\n") - write(f"\n# {line_no} {file_info[0]}\n") - else: - # leave non-macro in source - write(macro_name + char) - - macro_name = "" - elif char == "_" or (char >= 'A' and char <= 'Z'): - macro_name += char + line_no += script_source.count("\n") + write(f"\n# {line_no} {file_info[0]}\n") else: + # leave non-macro in source write(macro_name + char) - macro_name = "" - if char == "\n": - char_no = 0 - line_no += 1 + macro_name = "" + elif char == "_" or (char >= 'A' and char <= 'Z'): + macro_name += char + else: + write(macro_name + char) + macro_name = "" - char_no += 1 - prev_char = char + if char == "\n": + char_no = 0 + line_no += 1 + + char_no += 1 + prev_char = char if error: exit(1) else: - with open(argv[1], "w") as f: - f.write(write_buf) exit(0) diff --git a/tools/n64splat b/tools/n64splat index 895abeff31..037d80e00c 160000 --- a/tools/n64splat +++ b/tools/n64splat @@ -1 +1 @@ -Subproject commit 895abeff31cc0bd5de3a05a55715d3457f8425eb +Subproject commit 037d80e00cb3aeae37bdad77bfac871036982456 diff --git a/tools/splat.yaml b/tools/splat.yaml index 2413914564..68395935ff 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -4,7 +4,8 @@ options: find-file-boundaries: True compiler: "GCC" mnemonic_ljust: 10 - ld_o_replace_extension: no + ld_o_replace_extension: False + ld_addrs_header: include/ld_addrs.h segments: - name: header type: header @@ -19,8 +20,7 @@ segments: files: - [0x0040, "asm", "boot"] - [0x0B70, "bin", "bootcode_font"] - - name: code - type: code + - type: code start: 0x1000 vram: 0x80025C00 files: @@ -198,8 +198,7 @@ segments: - [0x4ac90, "c", "os/code_4ac90_len_3910"] - [0x4E5A0, "bin"] - [0x6E8F0, "bin", "world/area_table"] - - name: code - type: code + - type: code start: 0x759B0 vram: 0x800DC500 files: @@ -213,8 +212,7 @@ segments: - [0x8a860, "c", "code_8a860_len_3f30"] - [0x8e790, "c", "code_8e790_len_2850"] - [0x90fe0, "bin"] - - name: code - type: code + - type: code start: 0xA5DD0 vram: 0x8010F6D0 files: @@ -233,8 +231,7 @@ segments: - [0xe16b0, "bin"] - [0xE5820, ".data", "code_dc470_len_14c0"] - [0xE5830, "bin"] - - name: code - type: code + - type: code start: 0xE79B0 vram: 0x802C3000 files: @@ -253,16 +250,14 @@ segments: - [0xFE660, "bin"] - [0xFE730, ".rodata", "code_e79b0_len_1920"] - [0xFE748, "bin"] # rodata chunk for above overlay; here to avoid the 0x10 alignment - - name: code - type: code + - type: code start: 0xFEE30 vram: 0x802DBD40 files: - [0xfee30, "c", "code_fee30_len_2d60"] - [0x101b90, "c", "code_101b90_len_8f0"] - [0x102480, "bin"] - - name: code - type: code + - type: code start: 0x102610 vram: 0x802E0D90 files: @@ -275,8 +270,7 @@ segments: - [0x10A8D0, "c", "code_10A8D0"] - [0x10A9F0, "bin"] # todo split this further - [0x131340, "bin"] # 0x8023E000 - - name: code - type: code + - type: code start: 0x135EE0 vram: 0x80242BA0 files: @@ -286,8 +280,7 @@ segments: - [0x140C70, "c"] - [0x1421C0, "c"] - [0x1422A0, "bin"] - - name: code - type: code + - type: code start: 0x163400 vram: 0x80242BA0 files: @@ -297,8 +290,7 @@ segments: - [0x168590, "c"] - [0x169BE0, "c"] - [0x16A3E0, "bin"] - - name: code - type: code + - type: code start: 0x16C8E0 vram: 0x8023E000 files: @@ -321,112 +313,96 @@ segments: - [0x1AF230, "c"] - [0x1AF2D0, "bin"] - [0x1CC310, "bin"] # icon images and palettes, vram unknown - - name: code - type: code + - type: code start: 0x3169F0 vram: 0x80200000 files: - [0x3169f0, "c", "code_3169f0"] - [0x316a70, "c", "code_316a70"] - [0x316c00, "bin"] # 0x802AE000 - - name: code - type: code + - type: code start: 0x316D90 vram: 0x802AE000 files: - [0x316d90, "c", "code_316d90"] - - name: code - type: code + - type: code start: 0x316f30 vram: 0x802B2000 files: - [0x316f30, "c", "code_316f30"] - - name: code - type: code + - type: code start: 0x317020 vram: 0x802BD100 files: - [0x317020, "c"] - [0x317b60, "bin"] - - name: code - type: code + - type: code start: 0x317e50 vram: 0x802BD100 files: - [0x317e50, "c"] - [0x3195d0, "bin"] - - name: code - type: code + - type: code start: 0x319670 vram: 0x802BD100 files: - [0x319670, "c"] - [0x31b000, "bin"] - - name: code - type: code + - type: code start: 0x31b120 vram: 0x802BD100 files: - [0x31b120, "c"] - [0x31cb60, "bin"] - - name: code - type: code + - type: code start: 0x31cc70 vram: 0x802BD100 files: - [0x31cc70, "c"] - [0x31ddc0, "bin"] - - name: code - type: code + - type: code start: 0x31de70 vram: 0x802BD100 files: - [0x31de70, "c"] - [0x320b20, "bin"] - - name: code - type: code + - type: code start: 0x320c50 vram: 0x802BD100 files: - [0x320c50, "c"] - [0x3239b0, "bin"] - - name: code - type: code + - type: code start: 0x323A50 vram: 0x802BD100 files: - [0x323A50, "c"] - [0x324930, "bin"] - - name: code - type: code + - type: code start: 0x324a10 vram: 0x802BD100 files: - [0x324a10, "c", "world_goompa"] - [0x324e80, "bin"] - - name: code - type: code + - type: code start: 0x324f10 vram: 0x802BD100 files: - [0x324f10, "c", "world_goombaria"] - [0x325000, "bin"] - - name: code - type: code + - type: code start: 0x325070 vram: 0x802BD100 files: - [0x325070, "c", "world_twink"] - [0x325160, "bin"] - - name: code - type: code + - type: code start: 0x3251d0 vram: 0x802BD100 files: - [0x3251d0, "c"] - [0x3255e0, "bin"] - - name: code - type: code + - type: code start: 0x325ad0 vram: 0xE0200000 files: @@ -434,23 +410,20 @@ segments: - [0x325ee0, "c"] - [0x326160, "bin"] - [0x326410, "bin"] - - name: code - type: code + - type: code start: 0x3278f0 vram: 0xE0002000 files: - [0x3278f0, "c"] - [0x328050, "bin"] - - name: code - type: code + - type: code start: 0x328110 vram: 0xE000C000 files: - [0x328110, "c"] - [0x328d20, "bin"] - [0x328EA0, "bin"] - - name: code - type: code + - type: code start: 0x32C110 vram: 0xE000E000 files: @@ -468,179 +441,156 @@ segments: - [0x330440, "bin"] # data/rodata section for above. - [0x330910, "bin"] # code, unknown VRAM addr. Leaving as bin for now. - [0x330ef0, "bin"] # data/rodata section for above. - - name: code - type: code + - type: code start: 0x331940 vram: 0xE001E000 files: - [0x331940, "c"] - [0x332690, "bin"] - [0x3326A0, "bin"] - - name: code - type: code + - type: code start: 0x333ec0 vram: 0xE0020000 files: - [0x333ec0, "c"] - [0x334b50, "bin"] - [0x334C70, "bin"] - - name: code - type: code + - type: code start: 0x337240 vram: 0xE0022000 files: - [0x337240, "c"] - [0x337f10, "bin"] - [0x337FC0, "bin"] - - name: code - type: code + - type: code start: 0x339250 vram: 0xE0024000 files: - [0x339250, "c"] - [0x339f10, "bin"] - [0x339F60, "bin"] - - name: code - type: code + - type: code start: 0x33B180 vram: 0xE0026000 files: - [0x33B180, "c"] - [0x33bb70, "bin"] - [0x33BBD0, "bin"] - - name: code - type: code + - type: code start: 0x33CDF0 vram: 0xE0028000 files: - [0x33CDF0, "c"] - [0x33d5d0, "bin"] - - name: code - type: code + - type: code start: 0x33E8C0 vram: 0xE002A000 files: - [0x33E8C0, "c"] - [0x33efe0, "bin"] - [0x33D610, "bin"] - - name: code - type: code + - type: code start: 0x33FE80 vram: 0xE002C000 files: - [0x33FE80, "c"] - [0x3407c0, "bin"] - [0x340880, "bin"] - - name: code - type: code + - type: code start: 0x3419E0 vram: 0xE002E000 files: - [0x3419E0, "c"] - [0x342120, "bin"] - - name: code - type: code + - type: code start: 0x342140 vram: 0xE0030000 files: - [0x342140, "c"] - [0x342fd0, "bin"] - [0x343040, "bin"] - - name: code - type: code + - type: code start: 0x343680 vram: 0xE0032000 files: - [0x343680, "c"] - [0x343f30, "bin"] - [0x343F70, "bin"] - - name: code - type: code + - type: code start: 0x344a10 vram: 0xE0034000 files: - [0x344a10, "c"] - [0x345190, "bin"] - [0x3451E0, "bin"] - - name: code - type: code + - type: code start: 0x3454E0 vram: 0xE0036000 files: - [0x3454E0, "c"] - [0x345b10, "bin"] - [0x345B40, "bin"] - - name: code - type: code + - type: code start: 0x34EC80 vram: 0xE003A000 files: - [0x34EC80, "c"] - [0x34f480, "bin"] - - name: code - type: code + - type: code start: 0x34F4C0 vram: 0xE003C000 files: - [0x34F4C0, "c"] - [0x350160, "bin"] - [0x350220, "bin"] - - name: code - type: code + - type: code start: 0x352440 vram: 0xE003E000 files: - [0x352440, "c"] - [0x352cb0, "bin"] - [0x352CE0, "bin"] - - name: code - type: code + - type: code start: 0x354F60 vram: 0xE0044000 files: - [0x354F60, "c"] - [0x355d10, "bin"] - - name: code - type: code + - type: code start: 0x355EE0 vram: 0xE0046000 files: - [0x355EE0, "c"] - [0x3564e0, "bin"] - [0x356530, "bin"] - - name: code - type: code + - type: code start: 0x356980 vram: 0xE0048000 files: - [0x356980, "c"] - [0x357380, "bin"] - [0x3573A0, "bin"] - - name: code - type: code + - type: code start: 0x3584C0 vram: 0xE004A000 files: - [0x3584C0, "c"] - [0x359320, "bin"] - [0x3593B0, "bin"] - - name: code - type: code + - type: code start: 0x35B9D0 vram: 0xE004E000 files: - [0x35B9D0, "c"] - [0x35bfb0, "bin"] - - name: code - type: code + - type: code start: 0x35BFD0 vram: 0xE0050000 files: - [0x35BFD0, "c"] - [0x35c530, "bin"] - [0x35C550, "bin"] - - name: code - type: code + - type: code start: 0x3602C0 vram: 0xE005A000 files: @@ -657,78 +607,68 @@ segments: - [0x364bc0, "bin"] # data/rodata for the above, and some extra unknown data. - [0x364f10, "bin"] # code, unknown VRAM addr. Leaving as bin for now. - [0x365970, "bin"] # data/rodata for the above, and some extra unknown data. - - name: code - type: code + - type: code start: 0x366030 vram: 0xE0066000 files: - [0x366030, "c"] - [0x366c80, "bin"] - [0x366D60, "bin"] - - name: code - type: code + - type: code start: 0x36A8D0 vram: 0xE0068000 files: - [0x36A8D0, "c"] - [0x36ae80, "bin"] - [0x36AEE0, "bin"] - - name: code - type: code + - type: code start: 0x36D020 vram: 0xE006A000 files: - [0x36D020, "c"] - [0x36de10, "bin"] - [0x36DF90, "bin"] - - name: code - type: code + - type: code start: 0x36E1D0 vram: 0xE006C000 files: - [0x36E1D0, "c"] - [0x36ed30, "bin"] - [0x36ED60, "bin"] - - name: code - type: code + - type: code start: 0x372790 vram: 0xE006E000 files: - [0x372790, "c"] - [0x373390, "bin"] - [0x3733E0, "bin"] - - name: code - type: code + - type: code start: 0x3740B0 vram: 0xE0070000 files: - [0x3740B0, "c"] - [0x374d80, "bin"] - - name: code - type: code + - type: code start: 0x374E50 vram: 0xE0072000 files: - [0x374E50, "c"] - [0x375500, "bin"] - [0x375510, "bin"] - - name: code - type: code + - type: code start: 0x376460 vram: 0xE0074000 files: - [0x376460, "c"] - [0x376fc0, "bin"] - - name: code - type: code + - type: code start: 0x377070 vram: 0xE0076000 files: - [0x377070, "c"] - [0x377f00, "bin"] - [0x377F80, "bin"] - - name: code - type: code + - type: code start: 0x37A3F0 vram: 0xE0078000 files: @@ -736,79 +676,69 @@ segments: - [0x37acf0, "bin"] - [0x37ADD0, "bin"] - [0x37D9D0, "bin"] - - name: code - type: code + - type: code start: 0x37F720 vram: 0xE007E000 files: - [0x37F720, "c"] - [0x380350, "bin"] - [0x3803A0, "bin"] - - name: code - type: code + - type: code start: 0x3812C0 vram: 0xE0080000 files: - [0x3812C0, "c"] - [0x381d80, "bin"] - [0x381E00, "bin"] - - name: code - type: code + - type: code start: 0x385640 vram: 0xE0082000 files: - [0x385640, "c"] - [0x386340, "bin"] - [0x3863B0, "bin"] - - name: code - type: code + - type: code start: 0x3889D0 vram: 0xE0084000 files: - [0x3889D0, "c"] - [0x3897e0, "bin"] - - name: code - type: code + - type: code start: 0x389850 vram: 0xE0086000 files: - [0x389850, "c"] - [0x38a2f0, "bin"] - [0x38A350, "bin"] - - name: code - type: code + - type: code start: 0x38ADF0 vram: 0xE0088000 files: - [0x38ADF0, "c"] - [0x38bab0, "bin"] - [0x38BBA0, "bin"] - - name: code - type: code + - type: code start: 0x38EE60 vram: 0xE008E000 files: - [0x38EE60, "c"] - [0x38f6f0, "bin"] - [0x38F710, "bin"] - - name: code - type: code + - type: code start: 0x38F900 vram: 0xE0090000 files: - [0x38F900, "c"] - [0x390340, "bin"] - [0x3903D0, "bin"] - - name: code - type: code + - type: code start: 0x391D30 vram: 0xE0092000 files: - [0x391D30, "c"] - [0x3923c0, "bin"] - [0x392440, "bin"] - - name: code - type: code + - type: code start: 0x3928D0 vram: 0xE0094000 files: @@ -829,78 +759,68 @@ segments: - [0x3a2440, "bin"] # data/rodata for the above, and some extra unknown data. - [0x3a2990, "bin"] # code, unknown VRAM addr. Leaving as bin for now. - [0x3a3360, "bin"] # data/rodata for the above, and some extra unknown data. - - name: code - type: code + - type: code start: 0x3A37E0 vram: 0xE00A4000 files: - [0x3A37E0, "c"] - [0x3a42b0, "bin"] - [0x3A4320, "bin"] - - name: code - type: code + - type: code start: 0x3A70F0 vram: 0xE00A8000 files: - [0x3A70F0, "c"] - [0x3A7710, "bin"] - [0x3A77A0, "bin"] # split further - - name: code - type: code + - type: code start: 0x3AA920 vram: 0xE00AA000 files: - [0x3AA920, "c"] - [0x3AAFE0, "bin"] - [0x3AB030, "bin"] # todo split this further - - name: code - type: code + - type: code start: 0x3AEE20 vram: 0xE00AC000 files: - [0x3AEE20, "c"] - [0x3AF5D0, "bin"] - [0x3AF700, "bin"] # todo split this further - - name: code - type: code + - type: code start: 0x3B2350 vram: 0xE00AE000 files: - [0x3B2350, "c"] - [0x3B2D90, "bin"] # todo split this further - - name: code - type: code + - type: code start: 0x3B3EB0 vram: 0xE00B0000 files: - [0x3B3EB0, "c"] - [0x3B4690, "bin"] - [0x3B46A0, "bin"] # todo split this further - - name: code - type: code + - type: code start: 0x3B7B80 vram: 0xE00B8000 files: - [0x3B7B80, "c"] - [0x3B8470, "bin"] - [0x3B8860, "bin"] # todo split this further - - name: code - type: code + - type: code start: 0x3BA030 vram: 0xE00BC000 files: - [0x3BA030, "c"] - [0x3BAC60, "bin"] - [0x3BAEA0, "bin"] # todo split this further ADD STUFF AFTER HERE - - name: code - type: code + - type: code start: 0x415D90 vram: 0x802A1000 files: - [0x415D90, "c"] - [0x4200C0, "bin"] # todo split this further - - name: code - type: code + - type: code start: 0x7E0E80 vram: 0x80280000 files: @@ -4031,17 +3951,6 @@ segments: - [0xB13500, "bin"] - [0xB13A40, "bin"] - [0xB13D50, "bin"] # rodata - - name: world/area_kkj/kkj_26/ - type: code - overlay: True - start: 0xB13120 - vram: 0x80240000 - files: - - [0xB13120, "c"] - - [0xB13150, "bin"] - - [0xB13500, "bin"] - - [0xB13A40, "bin"] - - [0xB13D50, "bin"] # rodata - name: world/area_kkj/kkj_27/ type: code overlay: True @@ -6590,16 +6499,14 @@ segments: - [0xE1E460, "c"] - [0xE1EC20, "bin"] - [0xE20110, "bin"] - - name: code - type: code + - type: code overlay: True start: 0xE20EB0 vram: 0x802B7000 files: - [0xe20eb0, "c", "code_e20eb0"] - [0xE215C0, "bin"] - - name: code - type: code + - type: code overlay: True start: 0xE21870 vram: 0x802B7000 @@ -6999,8 +6906,6 @@ segments: - [0x1B81E88, "Yay0"] - [0x1B82058, "Yay0"] - [0x1B82202, "bin"] - - name: assets/fs - type: PaperMarioMapFS - start: 0x1E40000 + - [0x1E40000, "PaperMarioMapFS"] - [0x27FEE22, "bin"] - [0x2800000]