diff --git a/.gitmodules b/.gitmodules index 8c18c84a..dd9459f5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "tools/ido-static-recomp"] path = tools/ido-static-recomp url = https://github.com/decompals/ido-static-recomp +[submodule "tools/asm_processor"] + path = tools/asm_processor + url = https://github.com/simonlindholm/asm-processor.git diff --git a/Makefile b/Makefile index 201f408e..c62a6a63 100755 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ endif # NOTE: If you are adding a tool here, make sure to update the Makefile in `/tools/ido-static-recomp/`! RECOMP_TOOLS := cc cfe uopt ugen as1 ujoin uld usplit umerge -RECOMP_DIR := $(RECOMP_PROJECT)build5.3/out/ +RECOMP_DIR := $(RECOMP_PROJECT)build/5.3/out/ RECOMP_TOOLS_PATHS = $(addprefix $(RECOMP_DIR),$(RECOMP_TOOLS)) # Checks if all the recomp tools exist. @@ -107,7 +107,7 @@ $(foreach p,$(RECOMP_TOOLS_PATHS),$(if $(wildcard $(p)),,$(info $(p) does not ex # If any of the tools do not exist, then recomp needs to run to build them. ifeq ($(runRecomp),yes) - DUMMY != cd $(RECOMP_PROJECT) && python3 build.py ido/5.3 -O2 && cp build5.3/out/usr/bin/cc build5.3/out/cc && cp build5.3/out/usr/lib/* build5.3/out/ && cd ../../ >&2 || echo FAIL + DUMMY != cd $(RECOMP_PROJECT) && make setup && make VERSION=5.3 && cp build/5.3/out/usr/bin/cc build/5.3/out/cc && cp build/5.3/out/usr/lib/* build/5.3/out/ && cd ../../ >&2 || echo FAIL endif ######## Extract Assets & Microcode ######## @@ -428,7 +428,7 @@ $(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).z64 $(BUILD_DIR)/$(TARGET).objdump: $(BUILD_DIR)/$(TARGET).elf $(OBJDUMP) -D $< > $@ -$(GLOBAL_ASM_O_FILES): CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +$(GLOBAL_ASM_O_FILES): CC := python3 tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- test: $(BUILD_DIR)/$(TARGET).z64 $(EMULATOR) $(EMU_FLAGS) $< diff --git a/asm/non_matchings/camera/func_80068FA8.s b/asm/non_matchings/camera/func_80068FA8.s deleted file mode 100644 index a82cfc7e..00000000 --- a/asm/non_matchings/camera/func_80068FA8.s +++ /dev/null @@ -1,313 +0,0 @@ -glabel func_80068FA8 -/* 069BA8 80068FA8 27BDFED8 */ addiu $sp, $sp, -0x128 -/* 069BAC 80068FAC AFBF004C */ sw $ra, 0x4c($sp) -/* 069BB0 80068FB0 AFB10048 */ sw $s1, 0x48($sp) -/* 069BB4 80068FB4 AFB00044 */ sw $s0, 0x44($sp) -/* 069BB8 80068FB8 E7BF0038 */ swc1 $f31, 0x38($sp) -/* 069BBC 80068FBC E7BE003C */ swc1 $f30, 0x3c($sp) -/* 069BC0 80068FC0 E7BD0030 */ swc1 $f29, 0x30($sp) -/* 069BC4 80068FC4 E7BC0034 */ swc1 $f28, 0x34($sp) -/* 069BC8 80068FC8 E7BB0028 */ swc1 $f27, 0x28($sp) -/* 069BCC 80068FCC E7BA002C */ swc1 $f26, 0x2c($sp) -/* 069BD0 80068FD0 E7B90020 */ swc1 $f25, 0x20($sp) -/* 069BD4 80068FD4 E7B80024 */ swc1 $f24, 0x24($sp) -/* 069BD8 80068FD8 E7B70018 */ swc1 $f23, 0x18($sp) -/* 069BDC 80068FDC E7B6001C */ swc1 $f22, 0x1c($sp) -/* 069BE0 80068FE0 E7B50010 */ swc1 $f21, 0x10($sp) -/* 069BE4 80068FE4 E7B40014 */ swc1 $f20, 0x14($sp) -/* 069BE8 80068FE8 AFA40128 */ sw $a0, 0x128($sp) -/* 069BEC 80068FEC AFA5012C */ sw $a1, 0x12c($sp) -/* 069BF0 80068FF0 84C40002 */ lh $a0, 2($a2) -/* 069BF4 80068FF4 00E08025 */ move $s0, $a3 -/* 069BF8 80068FF8 0C01C1FE */ jal coss_f -/* 069BFC 80068FFC 00C08825 */ move $s1, $a2 -/* 069C00 80069000 86240002 */ lh $a0, 2($s1) -/* 069C04 80069004 0C01C1F1 */ jal sins_f -/* 069C08 80069008 46000786 */ mov.s $f30, $f0 -/* 069C0C 8006900C E7A00118 */ swc1 $f0, 0x118($sp) -/* 069C10 80069010 86240000 */ lh $a0, ($s1) -/* 069C14 80069014 0C01C1FE */ jal coss_f -/* 069C18 80069018 00000000 */ nop -/* 069C1C 8006901C 86240000 */ lh $a0, ($s1) -/* 069C20 80069020 0C01C1F1 */ jal sins_f -/* 069C24 80069024 46000586 */ mov.s $f22, $f0 -/* 069C28 80069028 C624000C */ lwc1 $f4, 0xc($s1) -/* 069C2C 8006902C 46000606 */ mov.s $f24, $f0 -/* 069C30 80069030 E7A400F4 */ swc1 $f4, 0xf4($sp) -/* 069C34 80069034 C62A0010 */ lwc1 $f10, 0x10($s1) -/* 069C38 80069038 00000000 */ nop -/* 069C3C 8006903C E7AA00F0 */ swc1 $f10, 0xf0($sp) -/* 069C40 80069040 C6280014 */ lwc1 $f8, 0x14($s1) -/* 069C44 80069044 00000000 */ nop -/* 069C48 80069048 E7A800EC */ swc1 $f8, 0xec($sp) -/* 069C4C 8006904C 86040004 */ lh $a0, 4($s0) -/* 069C50 80069050 0C01C1FE */ jal coss_f -/* 069C54 80069054 00000000 */ nop -/* 069C58 80069058 86040004 */ lh $a0, 4($s0) -/* 069C5C 8006905C 0C01C1F1 */ jal sins_f -/* 069C60 80069060 46000506 */ mov.s $f20, $f0 -/* 069C64 80069064 86040002 */ lh $a0, 2($s0) -/* 069C68 80069068 0C01C1FE */ jal coss_f -/* 069C6C 8006906C 46000686 */ mov.s $f26, $f0 -/* 069C70 80069070 86040002 */ lh $a0, 2($s0) -/* 069C74 80069074 0C01C1F1 */ jal sins_f -/* 069C78 80069078 46000706 */ mov.s $f28, $f0 -/* 069C7C 8006907C 86040000 */ lh $a0, ($s0) -/* 069C80 80069080 0C01C1FE */ jal coss_f -/* 069C84 80069084 E7A00100 */ swc1 $f0, 0x100($sp) -/* 069C88 80069088 86040000 */ lh $a0, ($s0) -/* 069C8C 8006908C 0C01C1F1 */ jal sins_f -/* 069C90 80069090 E7A000FC */ swc1 $f0, 0xfc($sp) -/* 069C94 80069094 C606000C */ lwc1 $f6, 0xc($s0) -/* 069C98 80069098 C7B00138 */ lwc1 $f16, 0x138($sp) -/* 069C9C 8006909C E7A600E8 */ swc1 $f6, 0xe8($sp) -/* 069CA0 800690A0 C6040010 */ lwc1 $f4, 0x10($s0) -/* 069CA4 800690A4 C7AE0100 */ lwc1 $f14, 0x100($sp) -/* 069CA8 800690A8 E7A400E4 */ swc1 $f4, 0xe4($sp) -/* 069CAC 800690AC C60A0014 */ lwc1 $f10, 0x14($s0) -/* 069CB0 800690B0 C7AC00FC */ lwc1 $f12, 0xfc($sp) -/* 069CB4 800690B4 E7AA00E0 */ swc1 $f10, 0xe0($sp) -/* 069CB8 800690B8 C6220008 */ lwc1 $f2, 8($s1) -/* 069CBC 800690BC 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 069CC0 800690C0 46028402 */ mul.s $f16, $f16, $f2 -/* 069CC4 800690C4 3C108012 */ lui $s0, %hi(D_801210A0) # $s0, 0x8012 -/* 069CC8 800690C8 261010A0 */ addiu $s0, %lo(D_801210A0) # addiu $s0, $s0, 0x10a0 -/* 069CCC 800690CC 3C058012 */ lui $a1, %hi(D_80120F20) # $a1, 0x8012 -/* 069CD0 800690D0 46007202 */ mul.s $f8, $f14, $f0 -/* 069CD4 800690D4 24A50F20 */ addiu $a1, %lo(D_80120F20) # addiu $a1, $a1, 0xf20 -/* 069CD8 800690D8 02003025 */ move $a2, $s0 -/* 069CDC 800690DC 27A400A0 */ addiu $a0, $sp, 0xa0 -/* 069CE0 800690E0 460CA182 */ mul.s $f6, $f20, $f12 -/* 069CE4 800690E4 E7A80098 */ swc1 $f8, 0x98($sp) -/* 069CE8 800690E8 C7A40098 */ lwc1 $f4, 0x98($sp) -/* 069CEC 800690EC 00000000 */ nop -/* 069CF0 800690F0 4604D282 */ mul.s $f10, $f26, $f4 -/* 069CF4 800690F4 4600C207 */ neg.s $f8, $f24 -/* 069CF8 800690F8 E7A80090 */ swc1 $f8, 0x90($sp) -/* 069CFC 800690FC E7A40050 */ swc1 $f4, 0x50($sp) -/* 069D00 80069100 460A3480 */ add.s $f18, $f6, $f10 -/* 069D04 80069104 C7AA0090 */ lwc1 $f10, 0x90($sp) -/* 069D08 80069108 4600E182 */ mul.s $f6, $f28, $f0 -/* 069D0C 8006910C E7AA0058 */ swc1 $f10, 0x58($sp) -/* 069D10 80069110 E7A6008C */ swc1 $f6, 0x8c($sp) -/* 069D14 80069114 C7A8008C */ lwc1 $f8, 0x8c($sp) -/* 069D18 80069118 00000000 */ nop -/* 069D1C 8006911C 46085182 */ mul.s $f6, $f10, $f8 -/* 069D20 80069120 E7A80054 */ swc1 $f8, 0x54($sp) -/* 069D24 80069124 46169102 */ mul.s $f4, $f18, $f22 -/* 069D28 80069128 46062100 */ add.s $f4, $f4, $f6 -/* 069D2C 8006912C 46022182 */ mul.s $f6, $f4, $f2 -/* 069D30 80069130 00000000 */ nop -/* 069D34 80069134 461CD102 */ mul.s $f4, $f26, $f28 -/* 069D38 80069138 E7A600A0 */ swc1 $f6, 0xa0($sp) -/* 069D3C 8006913C 46007187 */ neg.s $f6, $f14 -/* 069D40 80069140 E7A60084 */ swc1 $f6, 0x84($sp) -/* 069D44 80069144 E7A40088 */ swc1 $f4, 0x88($sp) -/* 069D48 80069148 C7A40084 */ lwc1 $f4, 0x84($sp) -/* 069D4C 8006914C C7A80088 */ lwc1 $f8, 0x88($sp) -/* 069D50 80069150 46045182 */ mul.s $f6, $f10, $f4 -/* 069D54 80069154 00000000 */ nop -/* 069D58 80069158 46164282 */ mul.s $f10, $f8, $f22 -/* 069D5C 8006915C 46065280 */ add.s $f10, $f10, $f6 -/* 069D60 80069160 46025182 */ mul.s $f6, $f10, $f2 -/* 069D64 80069164 46000287 */ neg.s $f10, $f0 -/* 069D68 80069168 E7AA0074 */ swc1 $f10, 0x74($sp) -/* 069D6C 8006916C C7AA0074 */ lwc1 $f10, 0x74($sp) -/* 069D70 80069170 E7A600A4 */ swc1 $f6, 0xa4($sp) -/* 069D74 80069174 460C7182 */ mul.s $f6, $f14, $f12 -/* 069D78 80069178 E7A60080 */ swc1 $f6, 0x80($sp) -/* 069D7C 8006917C 46145182 */ mul.s $f6, $f10, $f20 -/* 069D80 80069180 C7AA0080 */ lwc1 $f10, 0x80($sp) -/* 069D84 80069184 00000000 */ nop -/* 069D88 80069188 460AD282 */ mul.s $f10, $f26, $f10 -/* 069D8C 8006918C 460A3180 */ add.s $f6, $f6, $f10 -/* 069D90 80069190 460CE282 */ mul.s $f10, $f28, $f12 -/* 069D94 80069194 E7A60070 */ swc1 $f6, 0x70($sp) -/* 069D98 80069198 C7A60058 */ lwc1 $f6, 0x58($sp) -/* 069D9C 8006919C E7A40058 */ swc1 $f4, 0x58($sp) -/* 069DA0 800691A0 E7AA007C */ swc1 $f10, 0x7c($sp) -/* 069DA4 800691A4 C7AA007C */ lwc1 $f10, 0x7c($sp) -/* 069DA8 800691A8 00000000 */ nop -/* 069DAC 800691AC 460A3182 */ mul.s $f6, $f6, $f10 -/* 069DB0 800691B0 C7AA0070 */ lwc1 $f10, 0x70($sp) -/* 069DB4 800691B4 00000000 */ nop -/* 069DB8 800691B8 46165282 */ mul.s $f10, $f10, $f22 -/* 069DBC 800691BC 46065280 */ add.s $f10, $f10, $f6 -/* 069DC0 800691C0 46025182 */ mul.s $f6, $f10, $f2 -/* 069DC4 800691C4 44805000 */ mtc1 $zero, $f10 -/* 069DC8 800691C8 00000000 */ nop -/* 069DCC 800691CC E7AA00AC */ swc1 $f10, 0xac($sp) -/* 069DD0 800691D0 E7A600A8 */ swc1 $f6, 0xa8($sp) -/* 069DD4 800691D4 4600D187 */ neg.s $f6, $f26 -/* 069DD8 800691D8 E7A60078 */ swc1 $f6, 0x78($sp) -/* 069DDC 800691DC C7AA0078 */ lwc1 $f10, 0x78($sp) -/* 069DE0 800691E0 00000000 */ nop -/* 069DE4 800691E4 460C5182 */ mul.s $f6, $f10, $f12 -/* 069DE8 800691E8 C7AA0050 */ lwc1 $f10, 0x50($sp) -/* 069DEC 800691EC 00000000 */ nop -/* 069DF0 800691F0 460AA282 */ mul.s $f10, $f20, $f10 -/* 069DF4 800691F4 460A3180 */ add.s $f6, $f6, $f10 -/* 069DF8 800691F8 4612C282 */ mul.s $f10, $f24, $f18 -/* 069DFC 800691FC E7A60064 */ swc1 $f6, 0x64($sp) -/* 069E00 80069200 C7A60054 */ lwc1 $f6, 0x54($sp) -/* 069E04 80069204 E7A80054 */ swc1 $f8, 0x54($sp) -/* 069E08 80069208 4606B102 */ mul.s $f4, $f22, $f6 -/* 069E0C 8006920C 46045280 */ add.s $f10, $f10, $f4 -/* 069E10 80069210 C7A40118 */ lwc1 $f4, 0x118($sp) -/* 069E14 80069214 E7AA0060 */ swc1 $f10, 0x60($sp) -/* 069E18 80069218 C7AA0060 */ lwc1 $f10, 0x60($sp) -/* 069E1C 8006921C 00000000 */ nop -/* 069E20 80069220 460A2102 */ mul.s $f4, $f4, $f10 -/* 069E24 80069224 C7AA0064 */ lwc1 $f10, 0x64($sp) -/* 069E28 80069228 00000000 */ nop -/* 069E2C 8006922C 461E5282 */ mul.s $f10, $f10, $f30 -/* 069E30 80069230 46045280 */ add.s $f10, $f10, $f4 -/* 069E34 80069234 46105102 */ mul.s $f4, $f10, $f16 -/* 069E38 80069238 00000000 */ nop -/* 069E3C 8006923C 461CA302 */ mul.s $f12, $f20, $f28 -/* 069E40 80069240 E7A400B0 */ swc1 $f4, 0xb0($sp) -/* 069E44 80069244 C7A40058 */ lwc1 $f4, 0x58($sp) -/* 069E48 80069248 E7A60058 */ swc1 $f6, 0x58($sp) -/* 069E4C 8006924C 4608C282 */ mul.s $f10, $f24, $f8 -/* 069E50 80069250 C7A80058 */ lwc1 $f8, 0x58($sp) -/* 069E54 80069254 4604B182 */ mul.s $f6, $f22, $f4 -/* 069E58 80069258 46065680 */ add.s $f26, $f10, $f6 -/* 069E5C 8006925C C7A60118 */ lwc1 $f6, 0x118($sp) -/* 069E60 80069260 461E6282 */ mul.s $f10, $f12, $f30 -/* 069E64 80069264 00000000 */ nop -/* 069E68 80069268 461A3182 */ mul.s $f6, $f6, $f26 -/* 069E6C 8006926C 46065280 */ add.s $f10, $f10, $f6 -/* 069E70 80069270 46105182 */ mul.s $f6, $f10, $f16 -/* 069E74 80069274 C7AA0078 */ lwc1 $f10, 0x78($sp) -/* 069E78 80069278 E7A600B4 */ swc1 $f6, 0xb4($sp) -/* 069E7C 8006927C C7A60074 */ lwc1 $f6, 0x74($sp) -/* 069E80 80069280 00000000 */ nop -/* 069E84 80069284 46065282 */ mul.s $f10, $f10, $f6 -/* 069E88 80069288 C7A60080 */ lwc1 $f6, 0x80($sp) -/* 069E8C 8006928C 00000000 */ nop -/* 069E90 80069290 4606A182 */ mul.s $f6, $f20, $f6 -/* 069E94 80069294 46065380 */ add.s $f14, $f10, $f6 -/* 069E98 80069298 C7AA0070 */ lwc1 $f10, 0x70($sp) -/* 069E9C 8006929C E7AE006C */ swc1 $f14, 0x6c($sp) -/* 069EA0 800692A0 460AC182 */ mul.s $f6, $f24, $f10 -/* 069EA4 800692A4 C7AA007C */ lwc1 $f10, 0x7c($sp) -/* 069EA8 800692A8 C7B4006C */ lwc1 $f20, 0x6c($sp) -/* 069EAC 800692AC 460AB282 */ mul.s $f10, $f22, $f10 -/* 069EB0 800692B0 460A3180 */ add.s $f6, $f6, $f10 -/* 069EB4 800692B4 C7AA0118 */ lwc1 $f10, 0x118($sp) -/* 069EB8 800692B8 E7A60068 */ swc1 $f6, 0x68($sp) -/* 069EBC 800692BC C7A60068 */ lwc1 $f6, 0x68($sp) -/* 069EC0 800692C0 00000000 */ nop -/* 069EC4 800692C4 46065282 */ mul.s $f10, $f10, $f6 -/* 069EC8 800692C8 00000000 */ nop -/* 069ECC 800692CC 461E7182 */ mul.s $f6, $f14, $f30 -/* 069ED0 800692D0 C7AE0118 */ lwc1 $f14, 0x118($sp) -/* 069ED4 800692D4 460A3180 */ add.s $f6, $f6, $f10 -/* 069ED8 800692D8 46103282 */ mul.s $f10, $f6, $f16 -/* 069EDC 800692DC 44803000 */ mtc1 $zero, $f6 -/* 069EE0 800692E0 46007387 */ neg.s $f14, $f14 -/* 069EE4 800692E4 E7A600BC */ swc1 $f6, 0xbc($sp) -/* 069EE8 800692E8 E7AA00B8 */ swc1 $f10, 0xb8($sp) -/* 069EEC 800692EC C7AA0064 */ lwc1 $f10, 0x64($sp) -/* 069EF0 800692F0 C7B000F4 */ lwc1 $f16, 0xf4($sp) -/* 069EF4 800692F4 460A7182 */ mul.s $f6, $f14, $f10 -/* 069EF8 800692F8 C7AA0060 */ lwc1 $f10, 0x60($sp) -/* 069EFC 800692FC 00000000 */ nop -/* 069F00 80069300 460AF282 */ mul.s $f10, $f30, $f10 -/* 069F04 80069304 460A3180 */ add.s $f6, $f6, $f10 -/* 069F08 80069308 46023282 */ mul.s $f10, $f6, $f2 -/* 069F0C 8006930C 00000000 */ nop -/* 069F10 80069310 460C7182 */ mul.s $f6, $f14, $f12 -/* 069F14 80069314 E7AA00C0 */ swc1 $f10, 0xc0($sp) -/* 069F18 80069318 461AF282 */ mul.s $f10, $f30, $f26 -/* 069F1C 8006931C 460A3180 */ add.s $f6, $f6, $f10 -/* 069F20 80069320 46023282 */ mul.s $f10, $f6, $f2 -/* 069F24 80069324 E7AA00C4 */ swc1 $f10, 0xc4($sp) -/* 069F28 80069328 46147182 */ mul.s $f6, $f14, $f20 -/* 069F2C 8006932C C7AA0068 */ lwc1 $f10, 0x68($sp) -/* 069F30 80069330 C7AE00F0 */ lwc1 $f14, 0xf0($sp) -/* 069F34 80069334 460AF282 */ mul.s $f10, $f30, $f10 -/* 069F38 80069338 460A3180 */ add.s $f6, $f6, $f10 -/* 069F3C 8006933C 46023282 */ mul.s $f10, $f6, $f2 -/* 069F40 80069340 44803000 */ mtc1 $zero, $f6 -/* 069F44 80069344 C7A200EC */ lwc1 $f2, 0xec($sp) -/* 069F48 80069348 E7A600CC */ swc1 $f6, 0xcc($sp) -/* 069F4C 8006934C E7AA00C8 */ swc1 $f10, 0xc8($sp) -/* 069F50 80069350 C7AA00F0 */ lwc1 $f10, 0xf0($sp) -/* 069F54 80069354 C7A60064 */ lwc1 $f6, 0x64($sp) -/* 069F58 80069358 00000000 */ nop -/* 069F5C 8006935C 46065282 */ mul.s $f10, $f10, $f6 -/* 069F60 80069360 C7A600F4 */ lwc1 $f6, 0xf4($sp) -/* 069F64 80069364 00000000 */ nop -/* 069F68 80069368 46069182 */ mul.s $f6, $f18, $f6 -/* 069F6C 8006936C 460A3180 */ add.s $f6, $f6, $f10 -/* 069F70 80069370 C7AA00EC */ lwc1 $f10, 0xec($sp) -/* 069F74 80069374 00000000 */ nop -/* 069F78 80069378 46085282 */ mul.s $f10, $f10, $f8 -/* 069F7C 8006937C 460A3200 */ add.s $f8, $f6, $f10 -/* 069F80 80069380 C7A600E8 */ lwc1 $f6, 0xe8($sp) -/* 069F84 80069384 00000000 */ nop -/* 069F88 80069388 46064280 */ add.s $f10, $f8, $f6 -/* 069F8C 8006938C C7A80054 */ lwc1 $f8, 0x54($sp) -/* 069F90 80069390 E7AA00D0 */ swc1 $f10, 0xd0($sp) -/* 069F94 80069394 46104182 */ mul.s $f6, $f8, $f16 -/* 069F98 80069398 00000000 */ nop -/* 069F9C 8006939C 460C7282 */ mul.s $f10, $f14, $f12 -/* 069FA0 800693A0 460A3200 */ add.s $f8, $f6, $f10 -/* 069FA4 800693A4 46041182 */ mul.s $f6, $f2, $f4 -/* 069FA8 800693A8 C7A400E4 */ lwc1 $f4, 0xe4($sp) -/* 069FAC 800693AC 46064280 */ add.s $f10, $f8, $f6 -/* 069FB0 800693B0 C7A60070 */ lwc1 $f6, 0x70($sp) -/* 069FB4 800693B4 46045200 */ add.s $f8, $f10, $f4 -/* 069FB8 800693B8 46103282 */ mul.s $f10, $f6, $f16 -/* 069FBC 800693BC C7A6007C */ lwc1 $f6, 0x7c($sp) -/* 069FC0 800693C0 E7A800D4 */ swc1 $f8, 0xd4($sp) -/* 069FC4 800693C4 46147102 */ mul.s $f4, $f14, $f20 -/* 069FC8 800693C8 46045200 */ add.s $f8, $f10, $f4 -/* 069FCC 800693CC 46061282 */ mul.s $f10, $f2, $f6 -/* 069FD0 800693D0 C7A600E0 */ lwc1 $f6, 0xe0($sp) -/* 069FD4 800693D4 460A4100 */ add.s $f4, $f8, $f10 -/* 069FD8 800693D8 44815000 */ mtc1 $at, $f10 -/* 069FDC 800693DC 46062200 */ add.s $f8, $f4, $f6 -/* 069FE0 800693E0 E7AA00DC */ swc1 $f10, 0xdc($sp) -/* 069FE4 800693E4 0C01BDDA */ jal f32_matrix_mult -/* 069FE8 800693E8 E7A800D8 */ swc1 $f8, 0xd8($sp) -/* 069FEC 800693EC 8FAB012C */ lw $t3, 0x12c($sp) -/* 069FF0 800693F0 02002025 */ move $a0, $s0 -/* 069FF4 800693F4 8D650000 */ lw $a1, ($t3) -/* 069FF8 800693F8 0C01BE1C */ jal f32_matrix_to_s16_matrix -/* 069FFC 800693FC 00000000 */ nop -/* 06A000 80069400 8FA50128 */ lw $a1, 0x128($sp) -/* 06A004 80069404 8FA4012C */ lw $a0, 0x12c($sp) -/* 06A008 80069408 8CA30000 */ lw $v1, ($a1) -/* 06A00C 8006940C 3C0D0140 */ lui $t5, (0x01400040 >> 16) # lui $t5, 0x140 -/* 06A010 80069410 246C0008 */ addiu $t4, $v1, 8 -/* 06A014 80069414 35AD0040 */ ori $t5, (0x01400040 & 0xFFFF) # ori $t5, $t5, 0x40 -/* 06A018 80069418 ACAC0000 */ sw $t4, ($a1) -/* 06A01C 8006941C AC6D0000 */ sw $t5, ($v1) -/* 06A020 80069420 8C8E0000 */ lw $t6, ($a0) -/* 06A024 80069424 3C018000 */ lui $at, 0x8000 -/* 06A028 80069428 01C17821 */ addu $t7, $t6, $at -/* 06A02C 8006942C AC6F0004 */ sw $t7, 4($v1) -/* 06A030 80069430 8C980000 */ lw $t8, ($a0) -/* 06A034 80069434 00000000 */ nop -/* 06A038 80069438 27190040 */ addiu $t9, $t8, 0x40 -/* 06A03C 8006943C AC990000 */ sw $t9, ($a0) -/* 06A040 80069440 8FBF004C */ lw $ra, 0x4c($sp) -/* 06A044 80069444 8FB10048 */ lw $s1, 0x48($sp) -/* 06A048 80069448 8FB00044 */ lw $s0, 0x44($sp) -/* 06A04C 8006944C C7BE003C */ lwc1 $f30, 0x3c($sp) -/* 06A050 80069450 C7BF0038 */ lwc1 $f31, 0x38($sp) -/* 06A054 80069454 C7BC0034 */ lwc1 $f28, 0x34($sp) -/* 06A058 80069458 C7BD0030 */ lwc1 $f29, 0x30($sp) -/* 06A05C 8006945C C7BA002C */ lwc1 $f26, 0x2c($sp) -/* 06A060 80069460 C7BB0028 */ lwc1 $f27, 0x28($sp) -/* 06A064 80069464 C7B80024 */ lwc1 $f24, 0x24($sp) -/* 06A068 80069468 C7B90020 */ lwc1 $f25, 0x20($sp) -/* 06A06C 8006946C C7B6001C */ lwc1 $f22, 0x1c($sp) -/* 06A070 80069470 C7B70018 */ lwc1 $f23, 0x18($sp) -/* 06A074 80069474 C7B40014 */ lwc1 $f20, 0x14($sp) -/* 06A078 80069478 C7B50010 */ lwc1 $f21, 0x10($sp) -/* 06A07C 8006947C 03E00008 */ jr $ra -/* 06A080 80069480 27BD0128 */ addiu $sp, $sp, 0x128 - diff --git a/asm/non_matchings/camera/func_80069790.s b/asm/non_matchings/camera/func_80069790.s deleted file mode 100644 index 45d9db96..00000000 --- a/asm/non_matchings/camera/func_80069790.s +++ /dev/null @@ -1,151 +0,0 @@ -glabel func_80069790 -/* 06A390 80069790 27BDFF00 */ addiu $sp, $sp, -0x100 -/* 06A394 80069794 AFBF0024 */ sw $ra, 0x24($sp) -/* 06A398 80069798 E7B70018 */ swc1 $f23, 0x18($sp) -/* 06A39C 8006979C E7B6001C */ swc1 $f22, 0x1c($sp) -/* 06A3A0 800697A0 E7B50010 */ swc1 $f21, 0x10($sp) -/* 06A3A4 800697A4 E7B40014 */ swc1 $f20, 0x14($sp) -/* 06A3A8 800697A8 AFA40100 */ sw $a0, 0x100($sp) -/* 06A3AC 800697AC AFA50104 */ sw $a1, 0x104($sp) -/* 06A3B0 800697B0 AFA7010C */ sw $a3, 0x10c($sp) -/* 06A3B4 800697B4 84D90016 */ lh $t9, 0x16($a2) -/* 06A3B8 800697B8 00000000 */ nop -/* 06A3BC 800697BC 44992000 */ mtc1 $t9, $f4 -/* 06A3C0 800697C0 00000000 */ nop -/* 06A3C4 800697C4 468021A0 */ cvt.s.w $f6, $f4 -/* 06A3C8 800697C8 E7A600F4 */ swc1 $f6, 0xf4($sp) -/* 06A3CC 800697CC 84C80018 */ lh $t0, 0x18($a2) -/* 06A3D0 800697D0 00000000 */ nop -/* 06A3D4 800697D4 44884000 */ mtc1 $t0, $f8 -/* 06A3D8 800697D8 00000000 */ nop -/* 06A3DC 800697DC 468042A0 */ cvt.s.w $f10, $f8 -/* 06A3E0 800697E0 E7AA00F0 */ swc1 $f10, 0xf0($sp) -/* 06A3E4 800697E4 84C9001A */ lh $t1, 0x1a($a2) -/* 06A3E8 800697E8 00000000 */ nop -/* 06A3EC 800697EC 44892000 */ mtc1 $t1, $f4 -/* 06A3F0 800697F0 00000000 */ nop -/* 06A3F4 800697F4 468021A0 */ cvt.s.w $f6, $f4 -/* 06A3F8 800697F8 E7A600EC */ swc1 $f6, 0xec($sp) -/* 06A3FC 800697FC 84C4001C */ lh $a0, 0x1c($a2) -/* 06A400 80069800 0C01C1FE */ jal coss_f -/* 06A404 80069804 AFA60108 */ sw $a2, 0x108($sp) -/* 06A408 80069808 8FA60108 */ lw $a2, 0x108($sp) -/* 06A40C 8006980C 46000506 */ mov.s $f20, $f0 -/* 06A410 80069810 84C4001C */ lh $a0, 0x1c($a2) -/* 06A414 80069814 0C01C1F1 */ jal sins_f -/* 06A418 80069818 00000000 */ nop -/* 06A41C 8006981C 87A4010E */ lh $a0, 0x10e($sp) -/* 06A420 80069820 0C01C1FE */ jal coss_f -/* 06A424 80069824 E7A000E4 */ swc1 $f0, 0xe4($sp) -/* 06A428 80069828 87A4010E */ lh $a0, 0x10e($sp) -/* 06A42C 8006982C 0C01C1F1 */ jal sins_f -/* 06A430 80069830 46000586 */ mov.s $f22, $f0 -/* 06A434 80069834 4614B482 */ mul.s $f18, $f22, $f20 -/* 06A438 80069838 C7B000E4 */ lwc1 $f16, 0xe4($sp) -/* 06A43C 8006983C C7AE00F4 */ lwc1 $f14, 0xf4($sp) -/* 06A440 80069840 C7AC00F0 */ lwc1 $f12, 0xf0($sp) -/* 06A444 80069844 4610B282 */ mul.s $f10, $f22, $f16 -/* 06A448 80069848 46000207 */ neg.s $f8, $f0 -/* 06A44C 8006984C C7A600EC */ lwc1 $f6, 0xec($sp) -/* 06A450 80069850 E7A000F8 */ swc1 $f0, 0xf8($sp) -/* 06A454 80069854 46140102 */ mul.s $f4, $f0, $f20 -/* 06A458 80069858 44801000 */ mtc1 $zero, $f2 -/* 06A45C 8006985C E7AE0028 */ swc1 $f14, 0x28($sp) -/* 06A460 80069860 E7A60030 */ swc1 $f6, 0x30($sp) -/* 06A464 80069864 46007387 */ neg.s $f14, $f14 -/* 06A468 80069868 E7AE002C */ swc1 $f14, 0x2c($sp) -/* 06A46C 8006986C 46003187 */ neg.s $f6, $f6 -/* 06A470 80069870 E7A60054 */ swc1 $f6, 0x54($sp) -/* 06A474 80069874 46100182 */ mul.s $f6, $f0, $f16 -/* 06A478 80069878 46008407 */ neg.s $f16, $f16 -/* 06A47C 8006987C E7A8006C */ swc1 $f8, 0x6c($sp) -/* 06A480 80069880 C7A8002C */ lwc1 $f8, 0x2c($sp) -/* 06A484 80069884 E7AC002C */ swc1 $f12, 0x2c($sp) -/* 06A488 80069888 46006307 */ neg.s $f12, $f12 -/* 06A48C 8006988C 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 06A490 80069890 E7A20070 */ swc1 $f2, 0x70($sp) -/* 06A494 80069894 46124082 */ mul.s $f2, $f8, $f18 -/* 06A498 80069898 E7B20064 */ swc1 $f18, 0x64($sp) -/* 06A49C 8006989C 44809000 */ mtc1 $zero, $f18 -/* 06A4A0 800698A0 E7AA0068 */ swc1 $f10, 0x68($sp) -/* 06A4A4 800698A4 E7B2007C */ swc1 $f18, 0x7c($sp) -/* 06A4A8 800698A8 46106482 */ mul.s $f18, $f12, $f16 -/* 06A4AC 800698AC E7B00074 */ swc1 $f16, 0x74($sp) -/* 06A4B0 800698B0 44808000 */ mtc1 $zero, $f16 -/* 06A4B4 800698B4 E7B40078 */ swc1 $f20, 0x78($sp) -/* 06A4B8 800698B8 46121480 */ add.s $f18, $f2, $f18 -/* 06A4BC 800698BC C7A20054 */ lwc1 $f2, 0x54($sp) -/* 06A4C0 800698C0 E7B00080 */ swc1 $f16, 0x80($sp) -/* 06A4C4 800698C4 46041082 */ mul.s $f2, $f2, $f4 -/* 06A4C8 800698C8 44808000 */ mtc1 $zero, $f16 -/* 06A4CC 800698CC E7A40084 */ swc1 $f4, 0x84($sp) -/* 06A4D0 800698D0 C7A40028 */ lwc1 $f4, 0x28($sp) -/* 06A4D4 800698D4 460A4282 */ mul.s $f10, $f8, $f10 -/* 06A4D8 800698D8 46029080 */ add.s $f2, $f18, $f2 -/* 06A4DC 800698DC C7B20054 */ lwc1 $f18, 0x54($sp) -/* 06A4E0 800698E0 3C058012 */ lui $a1, %hi(D_801210A0) # $a1, 0x8012 -/* 06A4E4 800698E4 46041100 */ add.s $f4, $f2, $f4 -/* 06A4E8 800698E8 C7A2002C */ lwc1 $f2, 0x2c($sp) -/* 06A4EC 800698EC E7B00090 */ swc1 $f16, 0x90($sp) -/* 06A4F0 800698F0 46146402 */ mul.s $f16, $f12, $f20 -/* 06A4F4 800698F4 E7AE0058 */ swc1 $f14, 0x58($sp) -/* 06A4F8 800698F8 C7AE00F8 */ lwc1 $f14, 0xf8($sp) -/* 06A4FC 800698FC E7AC003C */ swc1 $f12, 0x3c($sp) -/* 06A500 80069900 46069482 */ mul.s $f18, $f18, $f6 -/* 06A504 80069904 46105400 */ add.s $f16, $f10, $f16 -/* 06A508 80069908 C7AA0054 */ lwc1 $f10, 0x54($sp) -/* 06A50C 8006990C 44816000 */ mtc1 $at, $f12 -/* 06A510 80069910 46165282 */ mul.s $f10, $f10, $f22 -/* 06A514 80069914 46128480 */ add.s $f18, $f16, $f18 -/* 06A518 80069918 C7B00030 */ lwc1 $f16, 0x30($sp) -/* 06A51C 8006991C E7A60088 */ swc1 $f6, 0x88($sp) -/* 06A520 80069920 46029080 */ add.s $f2, $f18, $f2 -/* 06A524 80069924 E7B6008C */ swc1 $f22, 0x8c($sp) -/* 06A528 80069928 46007387 */ neg.s $f14, $f14 -/* 06A52C 8006992C 460E4382 */ mul.s $f14, $f8, $f14 -/* 06A530 80069930 E7A40094 */ swc1 $f4, 0x94($sp) -/* 06A534 80069934 E7A20098 */ swc1 $f2, 0x98($sp) -/* 06A538 80069938 E7AC00A0 */ swc1 $f12, 0xa0($sp) -/* 06A53C 8006993C 460A7280 */ add.s $f10, $f14, $f10 -/* 06A540 80069940 27A40064 */ addiu $a0, $sp, 0x64 -/* 06A544 80069944 46105400 */ add.s $f16, $f10, $f16 -/* 06A548 80069948 24A510A0 */ addiu $a1, %lo(D_801210A0) # addiu $a1, $a1, 0x10a0 -/* 06A54C 8006994C E7B0009C */ swc1 $f16, 0x9c($sp) -/* 06A550 80069950 0C01BDDA */ jal f32_matrix_mult -/* 06A554 80069954 27A600A4 */ addiu $a2, $sp, 0xa4 -/* 06A558 80069958 8FAA0104 */ lw $t2, 0x104($sp) -/* 06A55C 8006995C 27A400A4 */ addiu $a0, $sp, 0xa4 -/* 06A560 80069960 8D450000 */ lw $a1, ($t2) -/* 06A564 80069964 0C01BE1C */ jal f32_matrix_to_s16_matrix -/* 06A568 80069968 00000000 */ nop -/* 06A56C 8006996C 8FA50100 */ lw $a1, 0x100($sp) -/* 06A570 80069970 8FA60104 */ lw $a2, 0x104($sp) -/* 06A574 80069974 8CA20000 */ lw $v0, ($a1) -/* 06A578 80069978 3C0C0180 */ lui $t4, (0x01800040 >> 16) # lui $t4, 0x180 -/* 06A57C 8006997C 244B0008 */ addiu $t3, $v0, 8 -/* 06A580 80069980 358C0040 */ ori $t4, (0x01800040 & 0xFFFF) # ori $t4, $t4, 0x40 -/* 06A584 80069984 ACAB0000 */ sw $t3, ($a1) -/* 06A588 80069988 AC4C0000 */ sw $t4, ($v0) -/* 06A58C 8006998C 8CCD0000 */ lw $t5, ($a2) -/* 06A590 80069990 3C018000 */ lui $at, 0x8000 -/* 06A594 80069994 01A17021 */ addu $t6, $t5, $at -/* 06A598 80069998 AC4E0004 */ sw $t6, 4($v0) -/* 06A59C 8006999C 8CCF0000 */ lw $t7, ($a2) -/* 06A5A0 800699A0 3C08BC00 */ lui $t0, (0xBC00000A >> 16) # lui $t0, 0xbc00 -/* 06A5A4 800699A4 25F80040 */ addiu $t8, $t7, 0x40 -/* 06A5A8 800699A8 ACD80000 */ sw $t8, ($a2) -/* 06A5AC 800699AC 8CA20000 */ lw $v0, ($a1) -/* 06A5B0 800699B0 3508000A */ ori $t0, (0xBC00000A & 0xFFFF) # ori $t0, $t0, 0xa -/* 06A5B4 800699B4 24590008 */ addiu $t9, $v0, 8 -/* 06A5B8 800699B8 ACB90000 */ sw $t9, ($a1) -/* 06A5BC 800699BC 24090040 */ li $t1, 64 -/* 06A5C0 800699C0 AC490004 */ sw $t1, 4($v0) -/* 06A5C4 800699C4 AC480000 */ sw $t0, ($v0) -/* 06A5C8 800699C8 8FBF0024 */ lw $ra, 0x24($sp) -/* 06A5CC 800699CC C7B6001C */ lwc1 $f22, 0x1c($sp) -/* 06A5D0 800699D0 C7B70018 */ lwc1 $f23, 0x18($sp) -/* 06A5D4 800699D4 C7B40014 */ lwc1 $f20, 0x14($sp) -/* 06A5D8 800699D8 C7B50010 */ lwc1 $f21, 0x10($sp) -/* 06A5DC 800699DC 03E00008 */ jr $ra -/* 06A5E0 800699E0 27BD0100 */ addiu $sp, $sp, 0x100 - diff --git a/asm/non_matchings/objects/func_80010994.s b/asm/non_matchings/objects/func_80010994.s index d7bac426..16467e0e 100644 --- a/asm/non_matchings/objects/func_80010994.s +++ b/asm/non_matchings/objects/func_80010994.s @@ -43,9 +43,9 @@ glabel func_80010994 /* 011630 80010A30 3C018012 */ lui $at, %hi(D_8011ADB0) # $at, 0x8012 /* 011634 80010A34 AC20ADB0 */ sw $zero, %lo(D_8011ADB0)($at) .L80010A38: -/* 011638 80010A38 3C028012 */ lui $v0, %hi(D_8011AD20+1) # $v0, 0x8012 +/* 011638 80010A38 3C028012 */ lui $v0, %hi(D_8011AD21) # $v0, 0x8012 /* 01163C 80010A3C 3C018012 */ lui $at, %hi(D_8011AD3D) # $at, 0x8012 -/* 011640 80010A40 2442AD21 */ addiu $v0, %lo(D_8011AD20+1) # addiu $v0, $v0, -0x52df +/* 011640 80010A40 2442AD21 */ addiu $v0, %lo(D_8011AD21) # addiu $v0, $v0, -0x52df /* 011644 80010A44 A020AD3D */ sb $zero, %lo(D_8011AD3D)($at) /* 011648 80010A48 80480000 */ lb $t0, ($v0) /* 01164C 80010A4C 24090001 */ li $t1, 1 diff --git a/asm/non_matchings/objects/func_800113CC.s b/asm/non_matchings/objects/func_800113CC.s deleted file mode 100644 index cd40074e..00000000 --- a/asm/non_matchings/objects/func_800113CC.s +++ /dev/null @@ -1,110 +0,0 @@ -glabel func_800113CC -/* 011FCC 800113CC 27BDFF90 */ addiu $sp, $sp, -0x70 -/* 011FD0 800113D0 AFBF004C */ sw $ra, 0x4c($sp) -/* 011FD4 800113D4 AFB70048 */ sw $s7, 0x48($sp) -/* 011FD8 800113D8 AFB60044 */ sw $s6, 0x44($sp) -/* 011FDC 800113DC AFB50040 */ sw $s5, 0x40($sp) -/* 011FE0 800113E0 AFB4003C */ sw $s4, 0x3c($sp) -/* 011FE4 800113E4 AFB30038 */ sw $s3, 0x38($sp) -/* 011FE8 800113E8 AFB20034 */ sw $s2, 0x34($sp) -/* 011FEC 800113EC AFB10030 */ sw $s1, 0x30($sp) -/* 011FF0 800113F0 AFB0002C */ sw $s0, 0x2c($sp) -/* 011FF4 800113F4 E7B70020 */ swc1 $f23, 0x20($sp) -/* 011FF8 800113F8 E7B60024 */ swc1 $f22, 0x24($sp) -/* 011FFC 800113FC E7B50018 */ swc1 $f21, 0x18($sp) -/* 012000 80011400 E7B4001C */ swc1 $f20, 0x1c($sp) -/* 012004 80011404 8C820040 */ lw $v0, 0x40($a0) -/* 012008 80011408 00808825 */ move $s1, $a0 -/* 01200C 8001140C 904E005B */ lbu $t6, 0x5b($v0) -/* 012010 80011410 00C09825 */ move $s3, $a2 -/* 012014 80011414 00AE082A */ slt $at, $a1, $t6 -/* 012018 80011418 00E0B825 */ move $s7, $a3 -/* 01201C 8001141C 10200040 */ beqz $at, .L80011520 -/* 012020 80011420 00001825 */ move $v1, $zero -/* 012024 80011424 00457821 */ addu $t7, $v0, $a1 -/* 012028 80011428 91E4005C */ lbu $a0, 0x5c($t7) -/* 01202C 8001142C 0C0078A7 */ jal get_misc_asset -/* 012030 80011430 AFA00050 */ sw $zero, 0x50($sp) -/* 012034 80011434 80580001 */ lb $t8, 1($v0) -/* 012038 80011438 80480002 */ lb $t0, 2($v0) -/* 01203C 8001143C 331900FF */ andi $t9, $t8, 0xff -/* 012040 80011440 44992000 */ mtc1 $t9, $f4 -/* 012044 80011444 3C014100 */ li $at, 0x41000000 # 8.000000 -/* 012048 80011448 468021A0 */ cvt.s.w $f6, $f4 -/* 01204C 8001144C 44814000 */ mtc1 $at, $f8 -/* 012050 80011450 86340018 */ lh $s4, 0x18($s1) -/* 012054 80011454 80520000 */ lb $s2, ($v0) -/* 012058 80011458 44885000 */ mtc1 $t0, $f10 -/* 01205C 8001145C 8FA30050 */ lw $v1, 0x50($sp) -/* 012060 80011460 00134903 */ sra $t1, $s3, 4 -/* 012064 80011464 46083502 */ mul.s $f20, $f6, $f8 -/* 012068 80011468 00145103 */ sra $t2, $s4, 4 -/* 01206C 8001146C 0040B025 */ move $s6, $v0 -/* 012070 80011470 01209825 */ move $s3, $t1 -/* 012074 80011474 0140A025 */ move $s4, $t2 -/* 012078 80011478 00008025 */ move $s0, $zero -/* 01207C 8001147C 1A400028 */ blez $s2, .L80011520 -/* 012080 80011480 468055A0 */ cvt.s.w $f22, $f10 -/* 012084 80011484 8FB50080 */ lw $s5, 0x80($sp) -/* 012088 80011488 00000000 */ nop -/* 01208C 8001148C 02165821 */ addu $t3, $s0, $s6 -.L80011490: -/* 012090 80011490 81620003 */ lb $v0, 3($t3) -/* 012094 80011494 00000000 */ nop -/* 012098 80011498 0282082A */ slt $at, $s4, $v0 -/* 01209C 8001149C 14200002 */ bnez $at, .L800114A8 -/* 0120A0 800114A0 0262082A */ slt $at, $s3, $v0 -/* 0120A4 800114A4 14200005 */ bnez $at, .L800114BC -.L800114A8: -/* 0120A8 800114A8 0054082A */ slt $at, $v0, $s4 -/* 0120AC 800114AC 14200018 */ bnez $at, .L80011510 -/* 0120B0 800114B0 0053082A */ slt $at, $v0, $s3 -/* 0120B4 800114B4 10200016 */ beqz $at, .L80011510 -/* 0120B8 800114B8 00000000 */ nop -.L800114BC: -/* 0120BC 800114BC C62C000C */ lwc1 $f12, 0xc($s1) -/* 0120C0 800114C0 C62E0010 */ lwc1 $f14, 0x10($s1) -/* 0120C4 800114C4 8E260014 */ lw $a2, 0x14($s1) -/* 0120C8 800114C8 4407A000 */ mfc1 $a3, $f20 -/* 0120CC 800114CC 0C01A785 */ jal set_camera_shake_by_distance -/* 0120D0 800114D0 E7B60010 */ swc1 $f22, 0x10($sp) -/* 0120D4 800114D4 320C0001 */ andi $t4, $s0, 1 -/* 0120D8 800114D8 11800003 */ beqz $t4, .L800114E8 -/* 0120DC 800114DC 240D0004 */ li $t5, 4 -/* 0120E0 800114E0 10000002 */ b .L800114EC -/* 0120E4 800114E4 02E01025 */ move $v0, $s7 -.L800114E8: -/* 0120E8 800114E8 02A01025 */ move $v0, $s5 -.L800114EC: -/* 0120EC 800114EC 8E25000C */ lw $a1, 0xc($s1) -/* 0120F0 800114F0 8E260010 */ lw $a2, 0x10($s1) -/* 0120F4 800114F4 8E270014 */ lw $a3, 0x14($s1) -/* 0120F8 800114F8 AFA00014 */ sw $zero, 0x14($sp) -/* 0120FC 800114FC AFAD0010 */ sw $t5, 0x10($sp) -/* 012100 80011500 0C002556 */ jal play_sound_at_position -/* 012104 80011504 3044FFFF */ andi $a0, $v0, 0xffff -/* 012108 80011508 26030001 */ addiu $v1, $s0, 1 -/* 01210C 8001150C 02408025 */ move $s0, $s2 -.L80011510: -/* 012110 80011510 26100001 */ addiu $s0, $s0, 1 -/* 012114 80011514 0212082A */ slt $at, $s0, $s2 -/* 012118 80011518 1420FFDD */ bnez $at, .L80011490 -/* 01211C 8001151C 02165821 */ addu $t3, $s0, $s6 -.L80011520: -/* 012120 80011520 8FBF004C */ lw $ra, 0x4c($sp) -/* 012124 80011524 C7B50018 */ lwc1 $f21, 0x18($sp) -/* 012128 80011528 C7B4001C */ lwc1 $f20, 0x1c($sp) -/* 01212C 8001152C C7B70020 */ lwc1 $f23, 0x20($sp) -/* 012130 80011530 C7B60024 */ lwc1 $f22, 0x24($sp) -/* 012134 80011534 8FB0002C */ lw $s0, 0x2c($sp) -/* 012138 80011538 8FB10030 */ lw $s1, 0x30($sp) -/* 01213C 8001153C 8FB20034 */ lw $s2, 0x34($sp) -/* 012140 80011540 8FB30038 */ lw $s3, 0x38($sp) -/* 012144 80011544 8FB4003C */ lw $s4, 0x3c($sp) -/* 012148 80011548 8FB50040 */ lw $s5, 0x40($sp) -/* 01214C 8001154C 8FB60044 */ lw $s6, 0x44($sp) -/* 012150 80011550 8FB70048 */ lw $s7, 0x48($sp) -/* 012154 80011554 27BD0070 */ addiu $sp, $sp, 0x70 -/* 012158 80011558 03E00008 */ jr $ra -/* 01215C 8001155C 00601025 */ move $v0, $v1 - diff --git a/asm/non_matchings/objects/func_80011AD0.s b/asm/non_matchings/objects/func_80011AD0.s deleted file mode 100644 index d99bcbb1..00000000 --- a/asm/non_matchings/objects/func_80011AD0.s +++ /dev/null @@ -1,128 +0,0 @@ -.late_rodata -glabel D_800E5550 -.float 0.01 - -.text -glabel func_80011AD0 -/* 0126D0 80011AD0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 0126D4 80011AD4 AFBF002C */ sw $ra, 0x2c($sp) -/* 0126D8 80011AD8 84820048 */ lh $v0, 0x48($a0) -/* 0126DC 80011ADC 24010003 */ li $at, 3 -/* 0126E0 80011AE0 10410034 */ beq $v0, $at, .L80011BB4 -/* 0126E4 80011AE4 24060006 */ li $a2, 6 -/* 0126E8 80011AE8 2401002F */ li $at, 47 -/* 0126EC 80011AEC 10410008 */ beq $v0, $at, .L80011B10 -/* 0126F0 80011AF0 2401003D */ li $at, 61 -/* 0126F4 80011AF4 10410018 */ beq $v0, $at, .L80011B58 -/* 0126F8 80011AF8 24060006 */ li $a2, 6 -/* 0126FC 80011AFC 24010059 */ li $at, 89 -/* 012700 80011B00 1041004D */ beq $v0, $at, .L80011C38 -/* 012704 80011B04 00000000 */ nop -/* 012708 80011B08 1000005F */ b .L80011C88 -/* 01270C 80011B0C 8FBF002C */ lw $ra, 0x2c($sp) -.L80011B10: -/* 012710 80011B10 8C8E007C */ lw $t6, 0x7c($a0) -/* 012714 80011B14 24060004 */ li $a2, 4 -/* 012718 80011B18 05C0005A */ bltz $t6, .L80011C84 -/* 01271C 80011B1C 240F0002 */ li $t7, 2 -/* 012720 80011B20 8C870064 */ lw $a3, 0x64($a0) -/* 012724 80011B24 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 012728 80011B28 8CE50020 */ lw $a1, 0x20($a3) -/* 01272C 80011B2C AFAF0010 */ sw $t7, 0x10($sp) -/* 012730 80011B30 8CF80024 */ lw $t8, 0x24($a3) -/* 012734 80011B34 44812000 */ mtc1 $at, $f4 -/* 012738 80011B38 2419000B */ li $t9, 11 -/* 01273C 80011B3C AFB90018 */ sw $t9, 0x18($sp) -/* 012740 80011B40 AFA0001C */ sw $zero, 0x1c($sp) -/* 012744 80011B44 AFB80014 */ sw $t8, 0x14($sp) -/* 012748 80011B48 0C004658 */ jal func_80011960 -/* 01274C 80011B4C E7A40020 */ swc1 $f4, 0x20($sp) -/* 012750 80011B50 1000004D */ b .L80011C88 -/* 012754 80011B54 8FBF002C */ lw $ra, 0x2c($sp) -.L80011B58: -/* 012758 80011B58 8C870064 */ lw $a3, 0x64($a0) -/* 01275C 80011B5C 240B0008 */ li $t3, 8 -/* 012760 80011B60 90E800FC */ lbu $t0, 0xfc($a3) -/* 012764 80011B64 AFAB0010 */ sw $t3, 0x10($sp) -/* 012768 80011B68 00084880 */ sll $t1, $t0, 2 -/* 01276C 80011B6C 01284823 */ subu $t1, $t1, $t0 -/* 012770 80011B70 00094840 */ sll $t1, $t1, 1 -/* 012774 80011B74 8CEC00F8 */ lw $t4, 0xf8($a3) -/* 012778 80011B78 00095080 */ sll $t2, $t1, 2 -/* 01277C 80011B7C 01495021 */ addu $t2, $t2, $t1 -/* 012780 80011B80 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 012784 80011B84 44813000 */ mtc1 $at, $f6 -/* 012788 80011B88 000A5040 */ sll $t2, $t2, 1 -/* 01278C 80011B8C 240D000A */ li $t5, 10 -/* 012790 80011B90 00EA2821 */ addu $a1, $a3, $t2 -/* 012794 80011B94 24A50080 */ addiu $a1, $a1, 0x80 -/* 012798 80011B98 AFAD0018 */ sw $t5, 0x18($sp) -/* 01279C 80011B9C AFA0001C */ sw $zero, 0x1c($sp) -/* 0127A0 80011BA0 AFAC0014 */ sw $t4, 0x14($sp) -/* 0127A4 80011BA4 0C004658 */ jal func_80011960 -/* 0127A8 80011BA8 E7A60020 */ swc1 $f6, 0x20($sp) -/* 0127AC 80011BAC 10000036 */ b .L80011C88 -/* 0127B0 80011BB0 8FBF002C */ lw $ra, 0x2c($sp) -.L80011BB4: -/* 0127B4 80011BB4 8C8E003C */ lw $t6, 0x3c($a0) -/* 0127B8 80011BB8 8C870064 */ lw $a3, 0x64($a0) -/* 0127BC 80011BBC 91CF000D */ lbu $t7, 0xd($t6) -/* 0127C0 80011BC0 24090008 */ li $t1, 8 -/* 0127C4 80011BC4 448F4000 */ mtc1 $t7, $f8 -/* 0127C8 80011BC8 05E10005 */ bgez $t7, .L80011BE0 -/* 0127CC 80011BCC 46804020 */ cvt.s.w $f0, $f8 -/* 0127D0 80011BD0 3C014F80 */ li $at, 0x4F800000 # 4294967296.000000 -/* 0127D4 80011BD4 44815000 */ mtc1 $at, $f10 -/* 0127D8 80011BD8 00000000 */ nop -/* 0127DC 80011BDC 460A0000 */ add.s $f0, $f0, $f10 -.L80011BE0: -/* 0127E0 80011BE0 90F800FC */ lbu $t8, 0xfc($a3) -/* 0127E4 80011BE4 3C01800E */ lui $at, %hi(D_800E5550) # $at, 0x800e -/* 0127E8 80011BE8 0018C880 */ sll $t9, $t8, 2 -/* 0127EC 80011BEC 0338C823 */ subu $t9, $t9, $t8 -/* 0127F0 80011BF0 C4305550 */ lwc1 $f16, %lo(D_800E5550)($at) -/* 0127F4 80011BF4 0019C840 */ sll $t9, $t9, 1 -/* 0127F8 80011BF8 AFA90010 */ sw $t1, 0x10($sp) -/* 0127FC 80011BFC 8CEA00F8 */ lw $t2, 0xf8($a3) -/* 012800 80011C00 00194080 */ sll $t0, $t9, 2 -/* 012804 80011C04 46100002 */ mul.s $f0, $f0, $f16 -/* 012808 80011C08 01194021 */ addu $t0, $t0, $t9 -/* 01280C 80011C0C 00084040 */ sll $t0, $t0, 1 -/* 012810 80011C10 00E82821 */ addu $a1, $a3, $t0 -/* 012814 80011C14 240B001A */ li $t3, 26 -/* 012818 80011C18 AFAB0018 */ sw $t3, 0x18($sp) -/* 01281C 80011C1C 24A50080 */ addiu $a1, $a1, 0x80 -/* 012820 80011C20 E7A00020 */ swc1 $f0, 0x20($sp) -/* 012824 80011C24 AFA0001C */ sw $zero, 0x1c($sp) -/* 012828 80011C28 0C004658 */ jal func_80011960 -/* 01282C 80011C2C AFAA0014 */ sw $t2, 0x14($sp) -/* 012830 80011C30 10000015 */ b .L80011C88 -/* 012834 80011C34 8FBF002C */ lw $ra, 0x2c($sp) -.L80011C38: -/* 012838 80011C38 8C8C0078 */ lw $t4, 0x78($a0) -/* 01283C 80011C3C 00000000 */ nop -/* 012840 80011C40 11800011 */ beqz $t4, .L80011C88 -/* 012844 80011C44 8FBF002C */ lw $ra, 0x2c($sp) -/* 012848 80011C48 8C820064 */ lw $v0, 0x64($a0) -/* 01284C 80011C4C 00000000 */ nop -/* 012850 80011C50 904D0070 */ lbu $t5, 0x70($v0) -/* 012854 80011C54 00000000 */ nop -/* 012858 80011C58 1DA00008 */ bgtz $t5, .L80011C7C -/* 01285C 80011C5C 00000000 */ nop -/* 012860 80011C60 44809000 */ mtc1 $zero, $f18 -/* 012864 80011C64 C4440074 */ lwc1 $f4, 0x74($v0) -/* 012868 80011C68 00000000 */ nop -/* 01286C 80011C6C 4604903C */ c.lt.s $f18, $f4 -/* 012870 80011C70 00000000 */ nop -/* 012874 80011C74 45000004 */ bc1f .L80011C88 -/* 012878 80011C78 8FBF002C */ lw $ra, 0x2c($sp) -.L80011C7C: -/* 01287C 80011C7C 0C004D6E */ jal func_800135B8 -/* 012880 80011C80 00000000 */ nop -.L80011C84: -/* 012884 80011C84 8FBF002C */ lw $ra, 0x2c($sp) -.L80011C88: -/* 012888 80011C88 27BD0030 */ addiu $sp, $sp, 0x30 -/* 01288C 80011C8C 03E00008 */ jr $ra -/* 012890 80011C90 00000000 */ nop - diff --git a/asm/non_matchings/objects/func_800138A8.s b/asm/non_matchings/objects/func_800138A8.s deleted file mode 100644 index f09c6a00..00000000 --- a/asm/non_matchings/objects/func_800138A8.s +++ /dev/null @@ -1,92 +0,0 @@ -glabel func_800138A8 -/* 0144A8 800138A8 27BDFFC8 */ addiu $sp, $sp, -0x38 -/* 0144AC 800138AC AFBF0024 */ sw $ra, 0x24($sp) -/* 0144B0 800138B0 AFB00020 */ sw $s0, 0x20($sp) -/* 0144B4 800138B4 AFA5003C */ sw $a1, 0x3c($sp) -/* 0144B8 800138B8 00C08025 */ move $s0, $a2 -/* 0144BC 800138BC AFA70044 */ sw $a3, 0x44($sp) -/* 0144C0 800138C0 24C5000C */ addiu $a1, $a2, 0xc -/* 0144C4 800138C4 0C01C0C8 */ jal f32_vec3_apply_object_rotation -/* 0144C8 800138C8 AFA40038 */ sw $a0, 0x38($sp) -/* 0144CC 800138CC 8FA40038 */ lw $a0, 0x38($sp) -/* 0144D0 800138D0 C604000C */ lwc1 $f4, 0xc($s0) -/* 0144D4 800138D4 C486000C */ lwc1 $f6, 0xc($a0) -/* 0144D8 800138D8 C60A0010 */ lwc1 $f10, 0x10($s0) -/* 0144DC 800138DC 46062200 */ add.s $f8, $f4, $f6 -/* 0144E0 800138E0 C6060014 */ lwc1 $f6, 0x14($s0) -/* 0144E4 800138E4 E608000C */ swc1 $f8, 0xc($s0) -/* 0144E8 800138E8 C4920010 */ lwc1 $f18, 0x10($a0) -/* 0144EC 800138EC 00000000 */ nop -/* 0144F0 800138F0 46125100 */ add.s $f4, $f10, $f18 -/* 0144F4 800138F4 E6040010 */ swc1 $f4, 0x10($s0) -/* 0144F8 800138F8 C4880014 */ lwc1 $f8, 0x14($a0) -/* 0144FC 800138FC 00000000 */ nop -/* 014500 80013900 46083280 */ add.s $f10, $f6, $f8 -/* 014504 80013904 0C01A748 */ jal get_active_camera_segment -/* 014508 80013908 E60A0014 */ swc1 $f10, 0x14($s0) -/* 01450C 8001390C C452000C */ lwc1 $f18, 0xc($v0) -/* 014510 80013910 C604000C */ lwc1 $f4, 0xc($s0) -/* 014514 80013914 C4460010 */ lwc1 $f6, 0x10($v0) -/* 014518 80013918 46049081 */ sub.s $f2, $f18, $f4 -/* 01451C 8001391C C6080010 */ lwc1 $f8, 0x10($s0) -/* 014520 80013920 46021102 */ mul.s $f4, $f2, $f2 -/* 014524 80013924 46083381 */ sub.s $f14, $f6, $f8 -/* 014528 80013928 C6120014 */ lwc1 $f18, 0x14($s0) -/* 01452C 8001392C C44A0014 */ lwc1 $f10, 0x14($v0) -/* 014530 80013930 460E7182 */ mul.s $f6, $f14, $f14 -/* 014534 80013934 46125401 */ sub.s $f16, $f10, $f18 -/* 014538 80013938 E7AE0030 */ swc1 $f14, 0x30($sp) -/* 01453C 8001393C E7B0002C */ swc1 $f16, 0x2c($sp) -/* 014540 80013940 46108282 */ mul.s $f10, $f16, $f16 -/* 014544 80013944 46062200 */ add.s $f8, $f4, $f6 -/* 014548 80013948 E7A20034 */ swc1 $f2, 0x34($sp) -/* 01454C 8001394C 0C0326B4 */ jal sqrtf -/* 014550 80013950 460A4300 */ add.s $f12, $f8, $f10 -/* 014554 80013954 44809800 */ mtc1 $zero, $f19 -/* 014558 80013958 44809000 */ mtc1 $zero, $f18 -/* 01455C 8001395C 46000121 */ cvt.d.s $f4, $f0 -/* 014560 80013960 4624903C */ c.lt.d $f18, $f4 -/* 014564 80013964 C7A20034 */ lwc1 $f2, 0x34($sp) -/* 014568 80013968 C7AE0030 */ lwc1 $f14, 0x30($sp) -/* 01456C 8001396C C7B0002C */ lwc1 $f16, 0x2c($sp) -/* 014570 80013970 4500000E */ bc1f .L800139AC -/* 014574 80013974 3C048012 */ lui $a0, %hi(gObjectCurrDisplayList) # $a0, 0x8012 -/* 014578 80013978 860E001A */ lh $t6, 0x1a($s0) -/* 01457C 8001397C 00000000 */ nop -/* 014580 80013980 448E3000 */ mtc1 $t6, $f6 -/* 014584 80013984 00000000 */ nop -/* 014588 80013988 46803220 */ cvt.s.w $f8, $f6 -/* 01458C 8001398C 00000000 */ nop -/* 014590 80013990 46004303 */ div.s $f12, $f8, $f0 -/* 014594 80013994 460C1082 */ mul.s $f2, $f2, $f12 -/* 014598 80013998 00000000 */ nop -/* 01459C 8001399C 460C7382 */ mul.s $f14, $f14, $f12 -/* 0145A0 800139A0 00000000 */ nop -/* 0145A4 800139A4 460C8402 */ mul.s $f16, $f16, $f12 -/* 0145A8 800139A8 00000000 */ nop -.L800139AC: -/* 0145AC 800139AC C60A000C */ lwc1 $f10, 0xc($s0) -/* 0145B0 800139B0 C6040010 */ lwc1 $f4, 0x10($s0) -/* 0145B4 800139B4 C6080014 */ lwc1 $f8, 0x14($s0) -/* 0145B8 800139B8 46025480 */ add.s $f18, $f10, $f2 -/* 0145BC 800139BC 3C058012 */ lui $a1, %hi(gObjectCurrMatrix) # $a1, 0x8012 -/* 0145C0 800139C0 460E2180 */ add.s $f6, $f4, $f14 -/* 0145C4 800139C4 E612000C */ swc1 $f18, 0xc($s0) -/* 0145C8 800139C8 46104280 */ add.s $f10, $f8, $f16 -/* 0145CC 800139CC E6060010 */ swc1 $f6, 0x10($s0) -/* 0145D0 800139D0 E60A0014 */ swc1 $f10, 0x14($s0) -/* 0145D4 800139D4 8FB80044 */ lw $t8, 0x44($sp) -/* 0145D8 800139D8 8FAF003C */ lw $t7, 0x3c($sp) -/* 0145DC 800139DC 3C068012 */ lui $a2, %hi(gObjectCurrVertexList) # $a2, 0x8012 -/* 0145E0 800139E0 24C6AE94 */ addiu $a2, %lo(gObjectCurrVertexList) # addiu $a2, $a2, -0x516c -/* 0145E4 800139E4 24A5AE90 */ addiu $a1, %lo(gObjectCurrMatrix) # addiu $a1, $a1, -0x5170 -/* 0145E8 800139E8 2484AE8C */ addiu $a0, %lo(gObjectCurrDisplayList) # addiu $a0, $a0, -0x5174 -/* 0145EC 800139EC 02003825 */ move $a3, $s0 -/* 0145F0 800139F0 AFB80014 */ sw $t8, 0x14($sp) -/* 0145F4 800139F4 0C01A145 */ jal render_sprite_billboard -/* 0145F8 800139F8 AFAF0010 */ sw $t7, 0x10($sp) -/* 0145FC 800139FC 8FBF0024 */ lw $ra, 0x24($sp) -/* 014600 80013A00 8FB00020 */ lw $s0, 0x20($sp) -/* 014604 80013A04 03E00008 */ jr $ra -/* 014608 80013A08 27BD0038 */ addiu $sp, $sp, 0x38 - diff --git a/asm/non_matchings/objects/func_800155B8.s b/asm/non_matchings/objects/func_800155B8.s deleted file mode 100644 index cee76354..00000000 --- a/asm/non_matchings/objects/func_800155B8.s +++ /dev/null @@ -1,284 +0,0 @@ -glabel func_800155B8 -/* 0161B8 800155B8 27BDFB70 */ addiu $sp, $sp, -0x490 -/* 0161BC 800155BC AFB30034 */ sw $s3, 0x34($sp) -/* 0161C0 800155C0 3C138012 */ lui $s3, %hi(D_8011AE60) # $s3, 0x8012 -/* 0161C4 800155C4 3C038012 */ lui $v1, %hi(objCount) # $v1, 0x8012 -/* 0161C8 800155C8 8C63AE5C */ lw $v1, %lo(objCount)($v1) -/* 0161CC 800155CC 8E73AE60 */ lw $s3, %lo(D_8011AE60)($s3) -/* 0161D0 800155D0 AFB5003C */ sw $s5, 0x3c($sp) -/* 0161D4 800155D4 0263082A */ slt $at, $s3, $v1 -/* 0161D8 800155D8 AFBF004C */ sw $ra, 0x4c($sp) -/* 0161DC 800155DC AFBE0048 */ sw $fp, 0x48($sp) -/* 0161E0 800155E0 AFB70044 */ sw $s7, 0x44($sp) -/* 0161E4 800155E4 AFB60040 */ sw $s6, 0x40($sp) -/* 0161E8 800155E8 AFB40038 */ sw $s4, 0x38($sp) -/* 0161EC 800155EC AFB20030 */ sw $s2, 0x30($sp) -/* 0161F0 800155F0 AFB1002C */ sw $s1, 0x2c($sp) -/* 0161F4 800155F4 AFB00028 */ sw $s0, 0x28($sp) -/* 0161F8 800155F8 E7B70020 */ swc1 $f23, 0x20($sp) -/* 0161FC 800155FC E7B60024 */ swc1 $f22, 0x24($sp) -/* 016200 80015600 E7B50018 */ swc1 $f21, 0x18($sp) -/* 016204 80015604 E7B4001C */ swc1 $f20, 0x1c($sp) -/* 016208 80015608 10200026 */ beqz $at, .L800156A4 -/* 01620C 8001560C 0000A825 */ move $s5, $zero -/* 016210 80015610 3C048012 */ lui $a0, %hi(gObjPtrList) # $a0, 0x8012 -/* 016214 80015614 2484AE58 */ addiu $a0, %lo(gObjPtrList) # addiu $a0, $a0, -0x51a8 -/* 016218 80015618 00131080 */ sll $v0, $s3, 2 -/* 01621C 8001561C 241E0002 */ li $fp, 2 -/* 016220 80015620 27B60064 */ addiu $s6, $sp, 0x64 -/* 016224 80015624 240600FF */ li $a2, 255 -/* 016228 80015628 2405FFB7 */ li $a1, -73 -.L8001562C: -/* 01622C 8001562C 8C8E0000 */ lw $t6, ($a0) -/* 016230 80015630 26730001 */ addiu $s3, $s3, 1 -/* 016234 80015634 01C27821 */ addu $t7, $t6, $v0 -/* 016238 80015638 8DF10000 */ lw $s1, ($t7) -/* 01623C 8001563C 00000000 */ nop -/* 016240 80015640 86380006 */ lh $t8, 6($s1) -/* 016244 80015644 00000000 */ nop -/* 016248 80015648 33198000 */ andi $t9, $t8, 0x8000 -/* 01624C 8001564C 17200013 */ bnez $t9, .L8001569C -/* 016250 80015650 0263082A */ slt $at, $s3, $v1 -/* 016254 80015654 8E32004C */ lw $s2, 0x4c($s1) -/* 016258 80015658 00154080 */ sll $t0, $s5, 2 -/* 01625C 8001565C 1240000E */ beqz $s2, .L80015698 -/* 016260 80015660 02C84821 */ addu $t1, $s6, $t0 -/* 016264 80015664 AD310000 */ sw $s1, ($t1) -/* 016268 80015668 924A0011 */ lbu $t2, 0x11($s2) -/* 01626C 8001566C 26B50001 */ addiu $s5, $s5, 1 -/* 016270 80015670 13CA000A */ beq $fp, $t2, .L8001569C -/* 016274 80015674 0263082A */ slt $at, $s3, $v1 -/* 016278 80015678 864B0014 */ lh $t3, 0x14($s2) -/* 01627C 8001567C AE400000 */ sw $zero, ($s2) -/* 016280 80015680 01656024 */ and $t4, $t3, $a1 -/* 016284 80015684 A64C0014 */ sh $t4, 0x14($s2) -/* 016288 80015688 A2460013 */ sb $a2, 0x13($s2) -/* 01628C 8001568C 3C038012 */ lui $v1, %hi(objCount) # $v1, 0x8012 -/* 016290 80015690 8C63AE5C */ lw $v1, %lo(objCount)($v1) -/* 016294 80015694 00000000 */ nop -.L80015698: -/* 016298 80015698 0263082A */ slt $at, $s3, $v1 -.L8001569C: -/* 01629C 8001569C 1420FFE3 */ bnez $at, .L8001562C -/* 0162A0 800156A0 24420004 */ addiu $v0, $v0, 4 -.L800156A4: -/* 0162A4 800156A4 3C018012 */ lui $at, %hi(D_8011AE70) # $at, 0x8012 -/* 0162A8 800156A8 27B60064 */ addiu $s6, $sp, 0x64 -/* 0162AC 800156AC 241E0002 */ li $fp, 2 -/* 0162B0 800156B0 AC20AE70 */ sw $zero, %lo(D_8011AE70)($at) -/* 0162B4 800156B4 1AA0006B */ blez $s5, .L80015864 -/* 0162B8 800156B8 00009825 */ move $s3, $zero -/* 0162BC 800156BC 3C014880 */ li $at, 0x48800000 # 262144.000000 -/* 0162C0 800156C0 4481B000 */ mtc1 $at, $f22 -/* 0162C4 800156C4 3C014A80 */ li $at, 0x4A800000 # 4194304.000000 -/* 0162C8 800156C8 4481A000 */ mtc1 $at, $f20 -/* 0162CC 800156CC 27B70064 */ addiu $s7, $sp, 0x64 -/* 0162D0 800156D0 24140003 */ li $s4, 3 -.L800156D4: -/* 0162D4 800156D4 8EF10000 */ lw $s1, ($s7) -/* 0162D8 800156D8 3C028012 */ lui $v0, %hi(D_8011AE70) # $v0, 0x8012 -/* 0162DC 800156DC 8E32004C */ lw $s2, 0x4c($s1) -/* 0162E0 800156E0 00000000 */ nop -/* 0162E4 800156E4 924D0011 */ lbu $t5, 0x11($s2) -/* 0162E8 800156E8 00000000 */ nop -/* 0162EC 800156EC 17CD000E */ bne $fp, $t5, .L80015728 -/* 0162F0 800156F0 00000000 */ nop -/* 0162F4 800156F4 8C42AE70 */ lw $v0, %lo(D_8011AE70)($v0) -/* 0162F8 800156F8 3C0E8012 */ lui $t6, %hi(D_8011AE6C) # $t6, 0x8012 -/* 0162FC 800156FC 28410014 */ slti $at, $v0, 0x14 -/* 016300 80015700 10200009 */ beqz $at, .L80015728 -/* 016304 80015704 00027880 */ sll $t7, $v0, 2 -/* 016308 80015708 8DCEAE6C */ lw $t6, %lo(D_8011AE6C)($t6) -/* 01630C 8001570C 3C198012 */ lui $t9, %hi(D_8011AE70) # $t9, 0x8012 -/* 016310 80015710 01CFC021 */ addu $t8, $t6, $t7 -/* 016314 80015714 AF110000 */ sw $s1, ($t8) -/* 016318 80015718 8F39AE70 */ lw $t9, %lo(D_8011AE70)($t9) -/* 01631C 8001571C 3C018012 */ lui $at, %hi(D_8011AE70) # $at, 0x8012 -/* 016320 80015720 27280001 */ addiu $t0, $t9, 1 -/* 016324 80015724 AC28AE70 */ sw $t0, %lo(D_8011AE70)($at) -.L80015728: -/* 016328 80015728 86420014 */ lh $v0, 0x14($s2) -/* 01632C 8001572C 00000000 */ nop -/* 016330 80015730 30490004 */ andi $t1, $v0, 4 -/* 016334 80015734 11200033 */ beqz $t1, .L80015804 -/* 016338 80015738 304E0100 */ andi $t6, $v0, 0x100 -/* 01633C 8001573C 1AA00030 */ blez $s5, .L80015800 -/* 016340 80015740 00008025 */ move $s0, $zero -.L80015744: -/* 016344 80015744 12700029 */ beq $s3, $s0, .L800157EC -/* 016348 80015748 00105080 */ sll $t2, $s0, 2 -/* 01634C 8001574C 02CA5821 */ addu $t3, $s6, $t2 -/* 016350 80015750 8D650000 */ lw $a1, ($t3) -/* 016354 80015754 00000000 */ nop -/* 016358 80015758 8CA2004C */ lw $v0, 0x4c($a1) -/* 01635C 8001575C 00000000 */ nop -/* 016360 80015760 84430014 */ lh $v1, 0x14($v0) -/* 016364 80015764 00000000 */ nop -/* 016368 80015768 306C0003 */ andi $t4, $v1, 3 -/* 01636C 8001576C 1180001F */ beqz $t4, .L800157EC -/* 016370 80015770 00000000 */ nop -/* 016374 80015774 90440011 */ lbu $a0, 0x11($v0) -/* 016378 80015778 00000000 */ nop -/* 01637C 8001577C 16840005 */ bne $s4, $a0, .L80015794 -/* 016380 80015780 00000000 */ nop -/* 016384 80015784 0C0059D2 */ jal func_80016748 -/* 016388 80015788 02202025 */ move $a0, $s1 -/* 01638C 8001578C 10000018 */ b .L800157F0 -/* 016390 80015790 26100001 */ addiu $s0, $s0, 1 -.L80015794: -/* 016394 80015794 13C40015 */ beq $fp, $a0, .L800157EC -/* 016398 80015798 306D0020 */ andi $t5, $v1, 0x20 -/* 01639C 8001579C C624000C */ lwc1 $f4, 0xc($s1) -/* 0163A0 800157A0 C4A6000C */ lwc1 $f6, 0xc($a1) -/* 0163A4 800157A4 C6280014 */ lwc1 $f8, 0x14($s1) -/* 0163A8 800157A8 C4AA0014 */ lwc1 $f10, 0x14($a1) -/* 0163AC 800157AC 46062001 */ sub.s $f0, $f4, $f6 -/* 0163B0 800157B0 11A00003 */ beqz $t5, .L800157C0 -/* 0163B4 800157B4 460A4081 */ sub.s $f2, $f8, $f10 -/* 0163B8 800157B8 10000002 */ b .L800157C4 -/* 0163BC 800157BC 4600A306 */ mov.s $f12, $f20 -.L800157C0: -/* 0163C0 800157C0 4600B306 */ mov.s $f12, $f22 -.L800157C4: -/* 0163C4 800157C4 46000402 */ mul.s $f16, $f0, $f0 -/* 0163C8 800157C8 00000000 */ nop -/* 0163CC 800157CC 46021482 */ mul.s $f18, $f2, $f2 -/* 0163D0 800157D0 46128100 */ add.s $f4, $f16, $f18 -/* 0163D4 800157D4 460C203C */ c.lt.s $f4, $f12 -/* 0163D8 800157D8 00000000 */ nop -/* 0163DC 800157DC 45000003 */ bc1f .L800157EC -/* 0163E0 800157E0 00000000 */ nop -/* 0163E4 800157E4 0C005672 */ jal func_800159C8 -/* 0163E8 800157E8 02202025 */ move $a0, $s1 -.L800157EC: -/* 0163EC 800157EC 26100001 */ addiu $s0, $s0, 1 -.L800157F0: -/* 0163F0 800157F0 1615FFD4 */ bne $s0, $s5, .L80015744 -/* 0163F4 800157F4 00000000 */ nop -/* 0163F8 800157F8 86420014 */ lh $v0, 0x14($s2) -/* 0163FC 800157FC 00000000 */ nop -.L80015800: -/* 016400 80015800 304E0100 */ andi $t6, $v0, 0x100 -.L80015804: -/* 016404 80015804 11C00013 */ beqz $t6, .L80015854 -/* 016408 80015808 00000000 */ nop -/* 01640C 8001580C 1AA00011 */ blez $s5, .L80015854 -/* 016410 80015810 00008025 */ move $s0, $zero -.L80015814: -/* 016414 80015814 1270000C */ beq $s3, $s0, .L80015848 -/* 016418 80015818 00107880 */ sll $t7, $s0, 2 -/* 01641C 8001581C 02CFC021 */ addu $t8, $s6, $t7 -/* 016420 80015820 8F050000 */ lw $a1, ($t8) -/* 016424 80015824 00000000 */ nop -/* 016428 80015828 8CA2004C */ lw $v0, 0x4c($a1) -/* 01642C 8001582C 00000000 */ nop -/* 016430 80015830 90590011 */ lbu $t9, 0x11($v0) -/* 016434 80015834 00000000 */ nop -/* 016438 80015838 16990003 */ bne $s4, $t9, .L80015848 -/* 01643C 8001583C 00000000 */ nop -/* 016440 80015840 0C0059D2 */ jal func_80016748 -/* 016444 80015844 02202025 */ move $a0, $s1 -.L80015848: -/* 016448 80015848 26100001 */ addiu $s0, $s0, 1 -/* 01644C 8001584C 1615FFF1 */ bne $s0, $s5, .L80015814 -/* 016450 80015850 00000000 */ nop -.L80015854: -/* 016454 80015854 26730001 */ addiu $s3, $s3, 1 -/* 016458 80015858 1675FF9E */ bne $s3, $s5, .L800156D4 -/* 01645C 8001585C 26F70004 */ addiu $s7, $s7, 4 -/* 016460 80015860 00009825 */ move $s3, $zero -.L80015864: -/* 016464 80015864 1AA00048 */ blez $s5, .L80015988 -/* 016468 80015868 32A30003 */ andi $v1, $s5, 3 -/* 01646C 8001586C 10600011 */ beqz $v1, .L800158B4 -/* 016470 80015870 00601025 */ move $v0, $v1 -/* 016474 80015874 00134080 */ sll $t0, $s3, 2 -/* 016478 80015878 27A90064 */ addiu $t1, $sp, 0x64 -/* 01647C 8001587C 0109B821 */ addu $s7, $t0, $t1 -.L80015880: -/* 016480 80015880 8EF10000 */ lw $s1, ($s7) -/* 016484 80015884 26730001 */ addiu $s3, $s3, 1 -/* 016488 80015888 8E32004C */ lw $s2, 0x4c($s1) -/* 01648C 8001588C C626000C */ lwc1 $f6, 0xc($s1) -/* 016490 80015890 26F70004 */ addiu $s7, $s7, 4 -/* 016494 80015894 E6460004 */ swc1 $f6, 4($s2) -/* 016498 80015898 C6280010 */ lwc1 $f8, 0x10($s1) -/* 01649C 8001589C 00000000 */ nop -/* 0164A0 800158A0 E6480008 */ swc1 $f8, 8($s2) -/* 0164A4 800158A4 C62A0014 */ lwc1 $f10, 0x14($s1) -/* 0164A8 800158A8 1453FFF5 */ bne $v0, $s3, .L80015880 -/* 0164AC 800158AC E64A000C */ swc1 $f10, 0xc($s2) -/* 0164B0 800158B0 12750035 */ beq $s3, $s5, .L80015988 -.L800158B4: -/* 0164B4 800158B4 27AB0064 */ addiu $t3, $sp, 0x64 -/* 0164B8 800158B8 00135080 */ sll $t2, $s3, 2 -/* 0164BC 800158BC 00156080 */ sll $t4, $s5, 2 -/* 0164C0 800158C0 018B1021 */ addu $v0, $t4, $t3 -/* 0164C4 800158C4 014BB821 */ addu $s7, $t2, $t3 -.L800158C8: -/* 0164C8 800158C8 8EF10000 */ lw $s1, ($s7) -/* 0164CC 800158CC 26F70010 */ addiu $s7, $s7, 0x10 -/* 0164D0 800158D0 8E32004C */ lw $s2, 0x4c($s1) -/* 0164D4 800158D4 C630000C */ lwc1 $f16, 0xc($s1) -/* 0164D8 800158D8 00000000 */ nop -/* 0164DC 800158DC E6500004 */ swc1 $f16, 4($s2) -/* 0164E0 800158E0 C6320010 */ lwc1 $f18, 0x10($s1) -/* 0164E4 800158E4 00000000 */ nop -/* 0164E8 800158E8 E6520008 */ swc1 $f18, 8($s2) -/* 0164EC 800158EC C6240014 */ lwc1 $f4, 0x14($s1) -/* 0164F0 800158F0 00000000 */ nop -/* 0164F4 800158F4 E644000C */ swc1 $f4, 0xc($s2) -/* 0164F8 800158F8 8EF1FFF4 */ lw $s1, -0xc($s7) -/* 0164FC 800158FC 00000000 */ nop -/* 016500 80015900 8E32004C */ lw $s2, 0x4c($s1) -/* 016504 80015904 C626000C */ lwc1 $f6, 0xc($s1) -/* 016508 80015908 00000000 */ nop -/* 01650C 8001590C E6460004 */ swc1 $f6, 4($s2) -/* 016510 80015910 C6280010 */ lwc1 $f8, 0x10($s1) -/* 016514 80015914 00000000 */ nop -/* 016518 80015918 E6480008 */ swc1 $f8, 8($s2) -/* 01651C 8001591C C62A0014 */ lwc1 $f10, 0x14($s1) -/* 016520 80015920 00000000 */ nop -/* 016524 80015924 E64A000C */ swc1 $f10, 0xc($s2) -/* 016528 80015928 8EF1FFF8 */ lw $s1, -8($s7) -/* 01652C 8001592C 00000000 */ nop -/* 016530 80015930 8E32004C */ lw $s2, 0x4c($s1) -/* 016534 80015934 C630000C */ lwc1 $f16, 0xc($s1) -/* 016538 80015938 00000000 */ nop -/* 01653C 8001593C E6500004 */ swc1 $f16, 4($s2) -/* 016540 80015940 C6320010 */ lwc1 $f18, 0x10($s1) -/* 016544 80015944 00000000 */ nop -/* 016548 80015948 E6520008 */ swc1 $f18, 8($s2) -/* 01654C 8001594C C6240014 */ lwc1 $f4, 0x14($s1) -/* 016550 80015950 00000000 */ nop -/* 016554 80015954 E644000C */ swc1 $f4, 0xc($s2) -/* 016558 80015958 8EF1FFFC */ lw $s1, -4($s7) -/* 01655C 8001595C 00000000 */ nop -/* 016560 80015960 8E32004C */ lw $s2, 0x4c($s1) -/* 016564 80015964 C626000C */ lwc1 $f6, 0xc($s1) -/* 016568 80015968 00000000 */ nop -/* 01656C 8001596C E6460004 */ swc1 $f6, 4($s2) -/* 016570 80015970 C6280010 */ lwc1 $f8, 0x10($s1) -/* 016574 80015974 00000000 */ nop -/* 016578 80015978 E6480008 */ swc1 $f8, 8($s2) -/* 01657C 8001597C C62A0014 */ lwc1 $f10, 0x14($s1) -/* 016580 80015980 16E2FFD1 */ bne $s7, $v0, .L800158C8 -/* 016584 80015984 E64A000C */ swc1 $f10, 0xc($s2) -.L80015988: -/* 016588 80015988 8FBF004C */ lw $ra, 0x4c($sp) -/* 01658C 8001598C C7B50018 */ lwc1 $f21, 0x18($sp) -/* 016590 80015990 C7B4001C */ lwc1 $f20, 0x1c($sp) -/* 016594 80015994 C7B70020 */ lwc1 $f23, 0x20($sp) -/* 016598 80015998 C7B60024 */ lwc1 $f22, 0x24($sp) -/* 01659C 8001599C 8FB00028 */ lw $s0, 0x28($sp) -/* 0165A0 800159A0 8FB1002C */ lw $s1, 0x2c($sp) -/* 0165A4 800159A4 8FB20030 */ lw $s2, 0x30($sp) -/* 0165A8 800159A8 8FB30034 */ lw $s3, 0x34($sp) -/* 0165AC 800159AC 8FB40038 */ lw $s4, 0x38($sp) -/* 0165B0 800159B0 8FB5003C */ lw $s5, 0x3c($sp) -/* 0165B4 800159B4 8FB60040 */ lw $s6, 0x40($sp) -/* 0165B8 800159B8 8FB70044 */ lw $s7, 0x44($sp) -/* 0165BC 800159BC 8FBE0048 */ lw $fp, 0x48($sp) -/* 0165C0 800159C0 03E00008 */ jr $ra -/* 0165C4 800159C4 27BD0490 */ addiu $sp, $sp, 0x490 - diff --git a/asm/non_matchings/objects/func_8001BC54.s b/asm/non_matchings/objects/func_8001BC54.s deleted file mode 100644 index 29e6450f..00000000 --- a/asm/non_matchings/objects/func_8001BC54.s +++ /dev/null @@ -1,89 +0,0 @@ -glabel func_8001BC54 -/* 01C854 8001BC54 3C078012 */ lui $a3, %hi(D_8011AEE0) # $a3, 0x8012 -/* 01C858 8001BC58 24E7AEE0 */ addiu $a3, %lo(D_8011AEE0) # addiu $a3, $a3, -0x5120 -/* 01C85C 8001BC5C ACE00000 */ sw $zero, ($a3) -/* 01C860 8001BC60 3C038012 */ lui $v1, %hi(objCount) # $v1, 0x8012 -/* 01C864 8001BC64 8C63AE5C */ lw $v1, %lo(objCount)($v1) -/* 01C868 8001BC68 00001025 */ move $v0, $zero -/* 01C86C 8001BC6C 18600026 */ blez $v1, .L8001BD08 -/* 01C870 8001BC70 00002825 */ move $a1, $zero -/* 01C874 8001BC74 3C0A8012 */ lui $t2, %hi(D_8011AEDC) # $t2, 0x8012 -/* 01C878 8001BC78 3C088012 */ lui $t0, %hi(gObjPtrList) # $t0, 0x8012 -/* 01C87C 8001BC7C 2508AE58 */ addiu $t0, %lo(gObjPtrList) # addiu $t0, $t0, -0x51a8 -/* 01C880 8001BC80 254AAEDC */ addiu $t2, %lo(D_8011AEDC) # addiu $t2, $t2, -0x5124 -/* 01C884 8001BC84 2409000A */ li $t1, 10 -.L8001BC88: -/* 01C888 8001BC88 8D0E0000 */ lw $t6, ($t0) -/* 01C88C 8001BC8C 24420001 */ addiu $v0, $v0, 1 -/* 01C890 8001BC90 01C57821 */ addu $t7, $t6, $a1 -/* 01C894 8001BC94 8DE40000 */ lw $a0, ($t7) -/* 01C898 8001BC98 00000000 */ nop -/* 01C89C 8001BC9C 84980006 */ lh $t8, 6($a0) -/* 01C8A0 8001BCA0 00000000 */ nop -/* 01C8A4 8001BCA4 33198000 */ andi $t9, $t8, 0x8000 -/* 01C8A8 8001BCA8 17200015 */ bnez $t9, .L8001BD00 -/* 01C8AC 8001BCAC 0043082A */ slt $at, $v0, $v1 -/* 01C8B0 8001BCB0 848B0048 */ lh $t3, 0x48($a0) -/* 01C8B4 8001BCB4 00000000 */ nop -/* 01C8B8 8001BCB8 152B0011 */ bne $t1, $t3, .L8001BD00 -/* 01C8BC 8001BCBC 0043082A */ slt $at, $v0, $v1 -/* 01C8C0 8001BCC0 8CE60000 */ lw $a2, ($a3) -/* 01C8C4 8001BCC4 00000000 */ nop -/* 01C8C8 8001BCC8 28C10014 */ slti $at, $a2, 0x14 -/* 01C8CC 8001BCCC 1020000C */ beqz $at, .L8001BD00 -/* 01C8D0 8001BCD0 0043082A */ slt $at, $v0, $v1 -/* 01C8D4 8001BCD4 8D4C0000 */ lw $t4, ($t2) -/* 01C8D8 8001BCD8 00066880 */ sll $t5, $a2, 2 -/* 01C8DC 8001BCDC 018D7021 */ addu $t6, $t4, $t5 -/* 01C8E0 8001BCE0 ADC40000 */ sw $a0, ($t6) -/* 01C8E4 8001BCE4 8CEF0000 */ lw $t7, ($a3) -/* 01C8E8 8001BCE8 3C038012 */ lui $v1, %hi(objCount) # $v1, 0x8012 -/* 01C8EC 8001BCEC 25F80001 */ addiu $t8, $t7, 1 -/* 01C8F0 8001BCF0 ACF80000 */ sw $t8, ($a3) -/* 01C8F4 8001BCF4 8C63AE5C */ lw $v1, %lo(objCount)($v1) -/* 01C8F8 8001BCF8 00000000 */ nop -/* 01C8FC 8001BCFC 0043082A */ slt $at, $v0, $v1 -.L8001BD00: -/* 01C900 8001BD00 1420FFE1 */ bnez $at, .L8001BC88 -/* 01C904 8001BD04 24A50004 */ addiu $a1, $a1, 4 -.L8001BD08: -/* 01C908 8001BD08 3C068012 */ lui $a2, %hi(D_8011AEE0) # $a2, 0x8012 -/* 01C90C 8001BD0C 8CC6AEE0 */ lw $a2, %lo(D_8011AEE0)($a2) -/* 01C910 8001BD10 3C0A8012 */ lui $t2, %hi(D_8011AEDC) # $t2, 0x8012 -/* 01C914 8001BD14 254AAEDC */ addiu $t2, %lo(D_8011AEDC) # addiu $t2, $t2, -0x5124 -/* 01C918 8001BD18 24C6FFFF */ addiu $a2, $a2, -1 -/* 01C91C 8001BD1C 24030001 */ li $v1, 1 -.L8001BD20: -/* 01C920 8001BD20 18C00018 */ blez $a2, .L8001BD84 -/* 01C924 8001BD24 00001025 */ move $v0, $zero -/* 01C928 8001BD28 00002825 */ move $a1, $zero -.L8001BD2C: -/* 01C92C 8001BD2C 8D590000 */ lw $t9, ($t2) -/* 01C930 8001BD30 24420001 */ addiu $v0, $v0, 1 -/* 01C934 8001BD34 03253821 */ addu $a3, $t9, $a1 -/* 01C938 8001BD38 8CE80004 */ lw $t0, 4($a3) -/* 01C93C 8001BD3C 8CE90000 */ lw $t1, ($a3) -/* 01C940 8001BD40 8D0B0078 */ lw $t3, 0x78($t0) -/* 01C944 8001BD44 8D2C0078 */ lw $t4, 0x78($t1) -/* 01C948 8001BD48 00000000 */ nop -/* 01C94C 8001BD4C 016C082A */ slt $at, $t3, $t4 -/* 01C950 8001BD50 1020000A */ beqz $at, .L8001BD7C -/* 01C954 8001BD54 0046082A */ slt $at, $v0, $a2 -/* 01C958 8001BD58 ACE80000 */ sw $t0, ($a3) -/* 01C95C 8001BD5C 8D4D0000 */ lw $t5, ($t2) -/* 01C960 8001BD60 3C068012 */ lui $a2, %hi(D_8011AEE0) # $a2, 0x8012 -/* 01C964 8001BD64 01A57021 */ addu $t6, $t5, $a1 -/* 01C968 8001BD68 ADC90004 */ sw $t1, 4($t6) -/* 01C96C 8001BD6C 8CC6AEE0 */ lw $a2, %lo(D_8011AEE0)($a2) -/* 01C970 8001BD70 00001825 */ move $v1, $zero -/* 01C974 8001BD74 24C6FFFF */ addiu $a2, $a2, -1 -/* 01C978 8001BD78 0046082A */ slt $at, $v0, $a2 -.L8001BD7C: -/* 01C97C 8001BD7C 1420FFEB */ bnez $at, .L8001BD2C -/* 01C980 8001BD80 24A50004 */ addiu $a1, $a1, 4 -.L8001BD84: -/* 01C984 8001BD84 1060FFE6 */ beqz $v1, .L8001BD20 -/* 01C988 8001BD88 24030001 */ li $v1, 1 -/* 01C98C 8001BD8C 03E00008 */ jr $ra -/* 01C990 8001BD90 00000000 */ nop - diff --git a/asm/non_matchings/objects/func_8001BDD4.s b/asm/non_matchings/objects/func_8001BDD4.s deleted file mode 100644 index 7b72d6d7..00000000 --- a/asm/non_matchings/objects/func_8001BDD4.s +++ /dev/null @@ -1,91 +0,0 @@ -glabel func_8001BDD4 -/* 01C9D4 8001BDD4 3C028012 */ lui $v0, %hi(D_8011AEE0) # $v0, 0x8012 -/* 01C9D8 8001BDD8 8C42AEE0 */ lw $v0, %lo(D_8011AEE0)($v0) -/* 01C9DC 8001BDDC 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 01C9E0 8001BDE0 14400003 */ bnez $v0, .L8001BDF0 -/* 01C9E4 8001BDE4 AFA40028 */ sw $a0, 0x28($sp) -/* 01C9E8 8001BDE8 1000004B */ b .L8001BF18 -/* 01C9EC 8001BDEC 00001025 */ move $v0, $zero -.L8001BDF0: -/* 01C9F0 8001BDF0 8CA40000 */ lw $a0, ($a1) -/* 01C9F4 8001BDF4 8FAC0028 */ lw $t4, 0x28($sp) -/* 01C9F8 8001BDF8 24830001 */ addiu $v1, $a0, 1 -/* 01C9FC 8001BDFC 0062082A */ slt $at, $v1, $v0 -/* 01CA00 8001BE00 14200002 */ bnez $at, .L8001BE0C -/* 01CA04 8001BE04 2486FFFF */ addiu $a2, $a0, -1 -/* 01CA08 8001BE08 00001825 */ move $v1, $zero -.L8001BE0C: -/* 01CA0C 8001BE0C 04C10002 */ bgez $a2, .L8001BE18 -/* 01CA10 8001BE10 00047080 */ sll $t6, $a0, 2 -/* 01CA14 8001BE14 2446FFFF */ addiu $a2, $v0, -1 -.L8001BE18: -/* 01CA18 8001BE18 3C028012 */ lui $v0, %hi(D_8011AEDC) # $v0, 0x8012 -/* 01CA1C 8001BE1C 8C42AEDC */ lw $v0, %lo(D_8011AEDC)($v0) -/* 01CA20 8001BE20 C582000C */ lwc1 $f2, 0xc($t4) -/* 01CA24 8001BE24 004E7821 */ addu $t7, $v0, $t6 -/* 01CA28 8001BE28 8DE70000 */ lw $a3, ($t7) -/* 01CA2C 8001BE2C C58E0010 */ lwc1 $f14, 0x10($t4) -/* 01CA30 8001BE30 C4E4000C */ lwc1 $f4, 0xc($a3) -/* 01CA34 8001BE34 C4E60010 */ lwc1 $f6, 0x10($a3) -/* 01CA38 8001BE38 46022001 */ sub.s $f0, $f4, $f2 -/* 01CA3C 8001BE3C C5920014 */ lwc1 $f18, 0x14($t4) -/* 01CA40 8001BE40 46000282 */ mul.s $f10, $f0, $f0 -/* 01CA44 8001BE44 460E3301 */ sub.s $f12, $f6, $f14 -/* 01CA48 8001BE48 C4E80014 */ lwc1 $f8, 0x14($a3) -/* 01CA4C 8001BE4C 0003C080 */ sll $t8, $v1, 2 -/* 01CA50 8001BE50 460C6102 */ mul.s $f4, $f12, $f12 -/* 01CA54 8001BE54 46124401 */ sub.s $f16, $f8, $f18 -/* 01CA58 8001BE58 00065080 */ sll $t2, $a2, 2 -/* 01CA5C 8001BE5C 0058C821 */ addu $t9, $v0, $t8 -/* 01CA60 8001BE60 46108202 */ mul.s $f8, $f16, $f16 -/* 01CA64 8001BE64 46045180 */ add.s $f6, $f10, $f4 -/* 01CA68 8001BE68 8F280000 */ lw $t0, ($t9) -/* 01CA6C 8001BE6C 004A5821 */ addu $t3, $v0, $t2 -/* 01CA70 8001BE70 46083280 */ add.s $f10, $f6, $f8 -/* 01CA74 8001BE74 8D690000 */ lw $t1, ($t3) -/* 01CA78 8001BE78 E7AA0004 */ swc1 $f10, 4($sp) -/* 01CA7C 8001BE7C C504000C */ lwc1 $f4, 0xc($t0) -/* 01CA80 8001BE80 C5060010 */ lwc1 $f6, 0x10($t0) -/* 01CA84 8001BE84 46022001 */ sub.s $f0, $f4, $f2 -/* 01CA88 8001BE88 C5080014 */ lwc1 $f8, 0x14($t0) -/* 01CA8C 8001BE8C 46000102 */ mul.s $f4, $f0, $f0 -/* 01CA90 8001BE90 460E3301 */ sub.s $f12, $f6, $f14 -/* 01CA94 8001BE94 460C6182 */ mul.s $f6, $f12, $f12 -/* 01CA98 8001BE98 46124401 */ sub.s $f16, $f8, $f18 -/* 01CA9C 8001BE9C 46062200 */ add.s $f8, $f4, $f6 -/* 01CAA0 8001BEA0 46108102 */ mul.s $f4, $f16, $f16 -/* 01CAA4 8001BEA4 46044180 */ add.s $f6, $f8, $f4 -/* 01CAA8 8001BEA8 E7A60000 */ swc1 $f6, ($sp) -/* 01CAAC 8001BEAC C528000C */ lwc1 $f8, 0xc($t1) -/* 01CAB0 8001BEB0 460A303C */ c.lt.s $f6, $f10 -/* 01CAB4 8001BEB4 46024001 */ sub.s $f0, $f8, $f2 -/* 01CAB8 8001BEB8 C5240010 */ lwc1 $f4, 0x10($t1) -/* 01CABC 8001BEBC C5280014 */ lwc1 $f8, 0x14($t1) -/* 01CAC0 8001BEC0 460E2301 */ sub.s $f12, $f4, $f14 -/* 01CAC4 8001BEC4 45000005 */ bc1f .L8001BEDC -/* 01CAC8 8001BEC8 46124401 */ sub.s $f16, $f8, $f18 -/* 01CACC 8001BECC ACA30000 */ sw $v1, ($a1) -/* 01CAD0 8001BED0 C7A40000 */ lwc1 $f4, ($sp) -/* 01CAD4 8001BED4 01003825 */ move $a3, $t0 -/* 01CAD8 8001BED8 E7A40004 */ swc1 $f4, 4($sp) -.L8001BEDC: -/* 01CADC 8001BEDC 46000202 */ mul.s $f8, $f0, $f0 -/* 01CAE0 8001BEE0 00000000 */ nop -/* 01CAE4 8001BEE4 460C6182 */ mul.s $f6, $f12, $f12 -/* 01CAE8 8001BEE8 00000000 */ nop -/* 01CAEC 8001BEEC 46108102 */ mul.s $f4, $f16, $f16 -/* 01CAF0 8001BEF0 46064280 */ add.s $f10, $f8, $f6 -/* 01CAF4 8001BEF4 C7A60004 */ lwc1 $f6, 4($sp) -/* 01CAF8 8001BEF8 46045200 */ add.s $f8, $f10, $f4 -/* 01CAFC 8001BEFC 4606403C */ c.lt.s $f8, $f6 -/* 01CB00 8001BF00 00000000 */ nop -/* 01CB04 8001BF04 45000003 */ bc1f .L8001BF14 -/* 01CB08 8001BF08 00000000 */ nop -/* 01CB0C 8001BF0C ACA60000 */ sw $a2, ($a1) -/* 01CB10 8001BF10 01203825 */ move $a3, $t1 -.L8001BF14: -/* 01CB14 8001BF14 00E01025 */ move $v0, $a3 -.L8001BF18: -/* 01CB18 8001BF18 03E00008 */ jr $ra -/* 01CB1C 8001BF1C 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/asm/non_matchings/objects/func_8001E13C.s b/asm/non_matchings/objects/func_8001E13C.s deleted file mode 100644 index 8cf198a0..00000000 --- a/asm/non_matchings/objects/func_8001E13C.s +++ /dev/null @@ -1,93 +0,0 @@ -glabel func_8001E13C -/* 01ED3C 8001E13C 27BDFFF0 */ addiu $sp, $sp, -0x10 -/* 01ED40 8001E140 3C0B8012 */ lui $t3, %hi(objCount) # $t3, 0x8012 -/* 01ED44 8001E144 256BAE5C */ addiu $t3, %lo(objCount) # addiu $t3, $t3, -0x51a4 -/* 01ED48 8001E148 AFB00008 */ sw $s0, 8($sp) -/* 01ED4C 8001E14C 8D630000 */ lw $v1, ($t3) -/* 01ED50 8001E150 00048400 */ sll $s0, $a0, 0x10 -/* 01ED54 8001E154 00107403 */ sra $t6, $s0, 0x10 -/* 01ED58 8001E158 AFB1000C */ sw $s1, 0xc($sp) -/* 01ED5C 8001E15C 00A08825 */ move $s1, $a1 -/* 01ED60 8001E160 01C08025 */ move $s0, $t6 -/* 01ED64 8001E164 AFA40010 */ sw $a0, 0x10($sp) -/* 01ED68 8001E168 18600048 */ blez $v1, .L8001E28C -/* 01ED6C 8001E16C 00001025 */ move $v0, $zero -/* 01ED70 8001E170 3C0C8012 */ lui $t4, %hi(gObjPtrList) # $t4, 0x8012 -/* 01ED74 8001E174 8FAA0028 */ lw $t2, 0x28($sp) -/* 01ED78 8001E178 8FA90024 */ lw $t1, 0x24($sp) -/* 01ED7C 8001E17C 8FA80020 */ lw $t0, 0x20($sp) -/* 01ED80 8001E180 258CAE58 */ addiu $t4, %lo(gObjPtrList) # addiu $t4, $t4, -0x51a8 -/* 01ED84 8001E184 240D0001 */ li $t5, 1 -.L8001E188: -/* 01ED88 8001E188 8D8F0000 */ lw $t7, ($t4) -/* 01ED8C 8001E18C 0002C080 */ sll $t8, $v0, 2 -/* 01ED90 8001E190 01F8C821 */ addu $t9, $t7, $t8 -/* 01ED94 8001E194 8F240000 */ lw $a0, ($t9) -/* 01ED98 8001E198 00000000 */ nop -/* 01ED9C 8001E19C 848E0006 */ lh $t6, 6($a0) -/* 01EDA0 8001E1A0 00000000 */ nop -/* 01EDA4 8001E1A4 31CF8000 */ andi $t7, $t6, 0x8000 -/* 01EDA8 8001E1A8 15E00034 */ bnez $t7, .L8001E27C -/* 01EDAC 8001E1AC 00000000 */ nop -/* 01EDB0 8001E1B0 84980048 */ lh $t8, 0x48($a0) -/* 01EDB4 8001E1B4 00000000 */ nop -/* 01EDB8 8001E1B8 15B80030 */ bne $t5, $t8, .L8001E27C -/* 01EDBC 8001E1BC 00000000 */ nop -/* 01EDC0 8001E1C0 8C850064 */ lw $a1, 0x64($a0) -/* 01EDC4 8001E1C4 00000000 */ nop -/* 01EDC8 8001E1C8 84B90000 */ lh $t9, ($a1) -/* 01EDCC 8001E1CC 00000000 */ nop -/* 01EDD0 8001E1D0 1619002B */ bne $s0, $t9, .L8001E280 -/* 01EDD4 8001E1D4 24420001 */ addiu $v0, $v0, 1 -/* 01EDD8 8001E1D8 444EF800 */ cfc1 $t6, $31 -/* 01EDDC 8001E1DC C484000C */ lwc1 $f4, 0xc($a0) -/* 01EDE0 8001E1E0 35C10003 */ ori $at, $t6, 3 -/* 01EDE4 8001E1E4 38210002 */ xori $at, $at, 2 -/* 01EDE8 8001E1E8 44C1F800 */ ctc1 $at, $31 -/* 01EDEC 8001E1EC 00000000 */ nop -/* 01EDF0 8001E1F0 460021A4 */ cvt.w.s $f6, $f4 -/* 01EDF4 8001E1F4 44CEF800 */ ctc1 $t6, $31 -/* 01EDF8 8001E1F8 440F3000 */ mfc1 $t7, $f6 -/* 01EDFC 8001E1FC 00000000 */ nop -/* 01EE00 8001E200 4458F800 */ cfc1 $t8, $31 -/* 01EE04 8001E204 A62F0000 */ sh $t7, ($s1) -/* 01EE08 8001E208 37010003 */ ori $at, $t8, 3 -/* 01EE0C 8001E20C 38210002 */ xori $at, $at, 2 -/* 01EE10 8001E210 44C1F800 */ ctc1 $at, $31 -/* 01EE14 8001E214 C4880010 */ lwc1 $f8, 0x10($a0) -/* 01EE18 8001E218 35C10003 */ ori $at, $t6, 3 -/* 01EE1C 8001E21C 460042A4 */ cvt.w.s $f10, $f8 -/* 01EE20 8001E220 38210002 */ xori $at, $at, 2 -/* 01EE24 8001E224 44195000 */ mfc1 $t9, $f10 -/* 01EE28 8001E228 44D8F800 */ ctc1 $t8, $31 -/* 01EE2C 8001E22C A4D90000 */ sh $t9, ($a2) -/* 01EE30 8001E230 C4900014 */ lwc1 $f16, 0x14($a0) -/* 01EE34 8001E234 44C1F800 */ ctc1 $at, $31 -/* 01EE38 8001E238 00000000 */ nop -/* 01EE3C 8001E23C 460084A4 */ cvt.w.s $f18, $f16 -/* 01EE40 8001E240 440F9000 */ mfc1 $t7, $f18 -/* 01EE44 8001E244 44CEF800 */ ctc1 $t6, $31 -/* 01EE48 8001E248 A4EF0000 */ sh $t7, ($a3) -/* 01EE4C 8001E24C 84980004 */ lh $t8, 4($a0) -/* 01EE50 8001E250 00000000 */ nop -/* 01EE54 8001E254 A5180000 */ sh $t8, ($t0) -/* 01EE58 8001E258 84990002 */ lh $t9, 2($a0) -/* 01EE5C 8001E25C 00000000 */ nop -/* 01EE60 8001E260 A5390000 */ sh $t9, ($t1) -/* 01EE64 8001E264 848E0000 */ lh $t6, ($a0) -/* 01EE68 8001E268 00000000 */ nop -/* 01EE6C 8001E26C A54E0000 */ sh $t6, ($t2) -/* 01EE70 8001E270 8D630000 */ lw $v1, ($t3) -/* 01EE74 8001E274 00000000 */ nop -/* 01EE78 8001E278 00601025 */ move $v0, $v1 -.L8001E27C: -/* 01EE7C 8001E27C 24420001 */ addiu $v0, $v0, 1 -.L8001E280: -/* 01EE80 8001E280 0043082A */ slt $at, $v0, $v1 -/* 01EE84 8001E284 1420FFC0 */ bnez $at, .L8001E188 -/* 01EE88 8001E288 00000000 */ nop -.L8001E28C: -/* 01EE8C 8001E28C 8FB00008 */ lw $s0, 8($sp) -/* 01EE90 8001E290 8FB1000C */ lw $s1, 0xc($sp) -/* 01EE94 8001E294 03E00008 */ jr $ra -/* 01EE98 8001E298 27BD0010 */ addiu $sp, $sp, 0x10 diff --git a/asm/non_matchings/objects/func_8002125C.s b/asm/non_matchings/objects/func_8002125C.s index d747bcd4..74a2dc5e 100644 --- a/asm/non_matchings/objects/func_8002125C.s +++ b/asm/non_matchings/objects/func_8002125C.s @@ -96,10 +96,10 @@ glabel func_8002125C /* 021FC0 800213C0 00000000 */ nop .L800213C4: /* 021FC4 800213C4 80B90028 */ lb $t9, 0x28($a1) -/* 021FC8 800213C8 3C088012 */ lui $t0, %hi(D_8011AD20+1) # $t0, 0x8012 +/* 021FC8 800213C8 3C088012 */ lui $t0, %hi(D_8011AD21) # $t0, 0x8012 /* 021FCC 800213CC 07200008 */ bltz $t9, .L800213F0 /* 021FD0 800213D0 3C098012 */ lui $t1, %hi(D_8011AD22) # $t1, 0x8012 -/* 021FD4 800213D4 8108AD21 */ lb $t0, %lo(D_8011AD20+1)($t0) +/* 021FD4 800213D4 8108AD21 */ lb $t0, %lo(D_8011AD21)($t0) /* 021FD8 800213D8 2529AD22 */ addiu $t1, %lo(D_8011AD22) # addiu $t1, $t1, -0x52de /* 021FDC 800213DC 01091021 */ addu $v0, $t0, $t1 /* 021FE0 800213E0 804A0000 */ lb $t2, ($v0) diff --git a/asm/non_matchings/unknown_0255E0/func_800278E8.s b/asm/non_matchings/unknown_0255E0/func_800278E8.s index 91d8e9d2..8039afcf 100644 --- a/asm/non_matchings/unknown_0255E0/func_800278E8.s +++ b/asm/non_matchings/unknown_0255E0/func_800278E8.s @@ -75,7 +75,7 @@ glabel func_800278E8 /* 0285F0 800279F0 00000000 */ nop .L800279F4: /* 0285F4 800279F4 822401FD */ lb $a0, 0x1fd($s1) -/* 0285F8 800279F8 0C006F65 */ jal objGetObject +/* 0285F8 800279F8 0C006F65 */ jal get_camera_object /* 0285FC 800279FC AFA50054 */ sw $a1, 0x54($sp) /* 028600 80027A00 3C0F8012 */ lui $t7, %hi(D_8011B104) # $t7, 0x8012 /* 028604 80027A04 8DEFB104 */ lw $t7, %lo(D_8011B104)($t7) diff --git a/asm/non_matchings/unknown_0255E0/func_8002A31C.s b/asm/non_matchings/unknown_0255E0/func_8002A31C.s deleted file mode 100644 index c581cf8e..00000000 --- a/asm/non_matchings/unknown_0255E0/func_8002A31C.s +++ /dev/null @@ -1,187 +0,0 @@ -glabel func_8002A31C -/* 02AF1C 8002A31C 27BDFF30 */ addiu $sp, $sp, -0xd0 -/* 02AF20 8002A320 AFBF007C */ sw $ra, 0x7c($sp) -/* 02AF24 8002A324 AFBE0078 */ sw $fp, 0x78($sp) -/* 02AF28 8002A328 AFB70074 */ sw $s7, 0x74($sp) -/* 02AF2C 8002A32C AFB60070 */ sw $s6, 0x70($sp) -/* 02AF30 8002A330 AFB5006C */ sw $s5, 0x6c($sp) -/* 02AF34 8002A334 AFB40068 */ sw $s4, 0x68($sp) -/* 02AF38 8002A338 AFB30064 */ sw $s3, 0x64($sp) -/* 02AF3C 8002A33C AFB20060 */ sw $s2, 0x60($sp) -/* 02AF40 8002A340 AFB1005C */ sw $s1, 0x5c($sp) -/* 02AF44 8002A344 AFB00058 */ sw $s0, 0x58($sp) -/* 02AF48 8002A348 E7BF0050 */ swc1 $f31, 0x50($sp) -/* 02AF4C 8002A34C E7BE0054 */ swc1 $f30, 0x54($sp) -/* 02AF50 8002A350 E7BD0048 */ swc1 $f29, 0x48($sp) -/* 02AF54 8002A354 E7BC004C */ swc1 $f28, 0x4c($sp) -/* 02AF58 8002A358 E7BB0040 */ swc1 $f27, 0x40($sp) -/* 02AF5C 8002A35C E7BA0044 */ swc1 $f26, 0x44($sp) -/* 02AF60 8002A360 E7B90038 */ swc1 $f25, 0x38($sp) -/* 02AF64 8002A364 E7B8003C */ swc1 $f24, 0x3c($sp) -/* 02AF68 8002A368 E7B70030 */ swc1 $f23, 0x30($sp) -/* 02AF6C 8002A36C E7B60034 */ swc1 $f22, 0x34($sp) -/* 02AF70 8002A370 E7B50028 */ swc1 $f21, 0x28($sp) -/* 02AF74 8002A374 0C01A769 */ jal func_80069DA4 -/* 02AF78 8002A378 E7B4002C */ swc1 $f20, 0x2c($sp) -/* 02AF7C 8002A37C 3C10800E */ lui $s0, %hi(D_800DC8AC) # $s0, 0x800e -/* 02AF80 8002A380 3C118012 */ lui $s1, %hi(D_8011D0F8) # $s1, 0x8012 -/* 02AF84 8002A384 00409025 */ move $s2, $v0 -/* 02AF88 8002A388 2631D0F8 */ addiu $s1, %lo(D_8011D0F8) # addiu $s1, $s1, -0x2f08 -/* 02AF8C 8002A38C 2610C8AC */ addiu $s0, %lo(D_800DC8AC) # addiu $s0, $s0, -0x3754 -/* 02AF90 8002A390 27BE00B8 */ addiu $fp, $sp, 0xb8 -/* 02AF94 8002A394 27B700BC */ addiu $s7, $sp, 0xbc -/* 02AF98 8002A398 27B600C0 */ addiu $s6, $sp, 0xc0 -/* 02AF9C 8002A39C 27B500C4 */ addiu $s5, $sp, 0xc4 -/* 02AFA0 8002A3A0 27B400C8 */ addiu $s4, $sp, 0xc8 -/* 02AFA4 8002A3A4 27B300CC */ addiu $s3, $sp, 0xcc -.L8002A3A8: -/* 02AFA8 8002A3A8 C6000000 */ lwc1 $f0, ($s0) -/* 02AFAC 8002A3AC C6020004 */ lwc1 $f2, 4($s0) -/* 02AFB0 8002A3B0 C60C0008 */ lwc1 $f12, 8($s0) -/* 02AFB4 8002A3B4 44050000 */ mfc1 $a1, $f0 -/* 02AFB8 8002A3B8 44061000 */ mfc1 $a2, $f2 -/* 02AFBC 8002A3BC 44076000 */ mfc1 $a3, $f12 -/* 02AFC0 8002A3C0 02402025 */ move $a0, $s2 -/* 02AFC4 8002A3C4 AFB30010 */ sw $s3, 0x10($sp) -/* 02AFC8 8002A3C8 AFB40014 */ sw $s4, 0x14($sp) -/* 02AFCC 8002A3CC AFB50018 */ sw $s5, 0x18($sp) -/* 02AFD0 8002A3D0 E7A000CC */ swc1 $f0, 0xcc($sp) -/* 02AFD4 8002A3D4 E7A200C8 */ swc1 $f2, 0xc8($sp) -/* 02AFD8 8002A3D8 0C01BD93 */ jal guMtxXFMF -/* 02AFDC 8002A3DC E7AC00C4 */ swc1 $f12, 0xc4($sp) -/* 02AFE0 8002A3E0 C60E000C */ lwc1 $f14, 0xc($s0) -/* 02AFE4 8002A3E4 C6100010 */ lwc1 $f16, 0x10($s0) -/* 02AFE8 8002A3E8 C6120014 */ lwc1 $f18, 0x14($s0) -/* 02AFEC 8002A3EC 44057000 */ mfc1 $a1, $f14 -/* 02AFF0 8002A3F0 44068000 */ mfc1 $a2, $f16 -/* 02AFF4 8002A3F4 44079000 */ mfc1 $a3, $f18 -/* 02AFF8 8002A3F8 02402025 */ move $a0, $s2 -/* 02AFFC 8002A3FC AFB60010 */ sw $s6, 0x10($sp) -/* 02B000 8002A400 AFB70014 */ sw $s7, 0x14($sp) -/* 02B004 8002A404 AFBE0018 */ sw $fp, 0x18($sp) -/* 02B008 8002A408 E7AE00C0 */ swc1 $f14, 0xc0($sp) -/* 02B00C 8002A40C E7B000BC */ swc1 $f16, 0xbc($sp) -/* 02B010 8002A410 0C01BD93 */ jal guMtxXFMF -/* 02B014 8002A414 E7B200B8 */ swc1 $f18, 0xb8($sp) -/* 02B018 8002A418 C61A0018 */ lwc1 $f26, 0x18($s0) -/* 02B01C 8002A41C C61C001C */ lwc1 $f28, 0x1c($s0) -/* 02B020 8002A420 C61E0020 */ lwc1 $f30, 0x20($s0) -/* 02B024 8002A424 27AE00B4 */ addiu $t6, $sp, 0xb4 -/* 02B028 8002A428 27AF00B0 */ addiu $t7, $sp, 0xb0 -/* 02B02C 8002A42C 27B800AC */ addiu $t8, $sp, 0xac -/* 02B030 8002A430 4405D000 */ mfc1 $a1, $f26 -/* 02B034 8002A434 4406E000 */ mfc1 $a2, $f28 -/* 02B038 8002A438 4407F000 */ mfc1 $a3, $f30 -/* 02B03C 8002A43C AFB80018 */ sw $t8, 0x18($sp) -/* 02B040 8002A440 AFAF0014 */ sw $t7, 0x14($sp) -/* 02B044 8002A444 AFAE0010 */ sw $t6, 0x10($sp) -/* 02B048 8002A448 02402025 */ move $a0, $s2 -/* 02B04C 8002A44C E7BA00B4 */ swc1 $f26, 0xb4($sp) -/* 02B050 8002A450 E7BC00B0 */ swc1 $f28, 0xb0($sp) -/* 02B054 8002A454 0C01BD93 */ jal guMtxXFMF -/* 02B058 8002A458 E7BE00AC */ swc1 $f30, 0xac($sp) -/* 02B05C 8002A45C C7B200B8 */ lwc1 $f18, 0xb8($sp) -/* 02B060 8002A460 C7BE00AC */ lwc1 $f30, 0xac($sp) -/* 02B064 8002A464 C7A200C8 */ lwc1 $f2, 0xc8($sp) -/* 02B068 8002A468 461E9101 */ sub.s $f4, $f18, $f30 -/* 02B06C 8002A46C C7AC00C4 */ lwc1 $f12, 0xc4($sp) -/* 02B070 8002A470 46022182 */ mul.s $f6, $f4, $f2 -/* 02B074 8002A474 C7B000BC */ lwc1 $f16, 0xbc($sp) -/* 02B078 8002A478 C7BC00B0 */ lwc1 $f28, 0xb0($sp) -/* 02B07C 8002A47C C7AE00C0 */ lwc1 $f14, 0xc0($sp) -/* 02B080 8002A480 460CF201 */ sub.s $f8, $f30, $f12 -/* 02B084 8002A484 C7BA00B4 */ lwc1 $f26, 0xb4($sp) -/* 02B088 8002A488 46088282 */ mul.s $f10, $f16, $f8 -/* 02B08C 8002A48C 46126201 */ sub.s $f8, $f12, $f18 -/* 02B090 8002A490 C7A000CC */ lwc1 $f0, 0xcc($sp) -/* 02B094 8002A494 460A3100 */ add.s $f4, $f6, $f10 -/* 02B098 8002A498 4608E182 */ mul.s $f6, $f28, $f8 -/* 02B09C 8002A49C 461A7281 */ sub.s $f10, $f14, $f26 -/* 02B0A0 8002A4A0 460C5202 */ mul.s $f8, $f10, $f12 -/* 02B0A4 8002A4A4 46062500 */ add.s $f20, $f4, $f6 -/* 02B0A8 8002A4A8 4600D101 */ sub.s $f4, $f26, $f0 -/* 02B0AC 8002A4AC 46049182 */ mul.s $f6, $f18, $f4 -/* 02B0B0 8002A4B0 460E0101 */ sub.s $f4, $f0, $f14 -/* 02B0B4 8002A4B4 46064280 */ add.s $f10, $f8, $f6 -/* 02B0B8 8002A4B8 4604F202 */ mul.s $f8, $f30, $f4 -/* 02B0BC 8002A4BC 461C8181 */ sub.s $f6, $f16, $f28 -/* 02B0C0 8002A4C0 46003102 */ mul.s $f4, $f6, $f0 -/* 02B0C4 8002A4C4 46085580 */ add.s $f22, $f10, $f8 -/* 02B0C8 8002A4C8 4602E281 */ sub.s $f10, $f28, $f2 -/* 02B0CC 8002A4CC 460A7202 */ mul.s $f8, $f14, $f10 -/* 02B0D0 8002A4D0 46101281 */ sub.s $f10, $f2, $f16 -/* 02B0D4 8002A4D4 46082180 */ add.s $f6, $f4, $f8 -/* 02B0D8 8002A4D8 460AD102 */ mul.s $f4, $f26, $f10 -/* 02B0DC 8002A4DC 00000000 */ nop -/* 02B0E0 8002A4E0 4614A202 */ mul.s $f8, $f20, $f20 -/* 02B0E4 8002A4E4 46043600 */ add.s $f24, $f6, $f4 -/* 02B0E8 8002A4E8 4616B282 */ mul.s $f10, $f22, $f22 -/* 02B0EC 8002A4EC 00000000 */ nop -/* 02B0F0 8002A4F0 4618C102 */ mul.s $f4, $f24, $f24 -/* 02B0F4 8002A4F4 460A4180 */ add.s $f6, $f8, $f10 -/* 02B0F8 8002A4F8 0C0326B4 */ jal sqrtf -/* 02B0FC 8002A4FC 46043300 */ add.s $f12, $f6, $f4 -/* 02B100 8002A500 3C013FF0 */ li $at, 0x3FF00000 # 1.875000 -/* 02B104 8002A504 44814800 */ mtc1 $at, $f9 -/* 02B108 8002A508 44804000 */ mtc1 $zero, $f8 -/* 02B10C 8002A50C 460002A1 */ cvt.d.s $f10, $f0 -/* 02B110 8002A510 00000000 */ nop -/* 02B114 8002A514 462A4183 */ div.d $f6, $f8, $f10 -/* 02B118 8002A518 44802800 */ mtc1 $zero, $f5 -/* 02B11C 8002A51C 44802000 */ mtc1 $zero, $f4 -/* 02B120 8002A520 C7A000CC */ lwc1 $f0, 0xcc($sp) -/* 02B124 8002A524 462030A0 */ cvt.s.d $f2, $f6 -/* 02B128 8002A528 46001221 */ cvt.d.s $f8, $f2 -/* 02B12C 8002A52C 4628203C */ c.lt.d $f4, $f8 -/* 02B130 8002A530 00000000 */ nop -/* 02B134 8002A534 45000007 */ bc1f .L8002A554 -/* 02B138 8002A538 00000000 */ nop -/* 02B13C 8002A53C 4602A502 */ mul.s $f20, $f20, $f2 -/* 02B140 8002A540 00000000 */ nop -/* 02B144 8002A544 4602B582 */ mul.s $f22, $f22, $f2 -/* 02B148 8002A548 00000000 */ nop -/* 02B14C 8002A54C 4602C602 */ mul.s $f24, $f24, $f2 -/* 02B150 8002A550 00000000 */ nop -.L8002A554: -/* 02B154 8002A554 46140282 */ mul.s $f10, $f0, $f20 -/* 02B158 8002A558 C7A200C8 */ lwc1 $f2, 0xc8($sp) -/* 02B15C 8002A55C C7AC00C4 */ lwc1 $f12, 0xc4($sp) -/* 02B160 8002A560 3C198012 */ lui $t9, %hi(D_8011D128) # $t9, 0x8012 -/* 02B164 8002A564 46161182 */ mul.s $f6, $f2, $f22 -/* 02B168 8002A568 2739D128 */ addiu $t9, %lo(D_8011D128) # addiu $t9, $t9, -0x2ed8 -/* 02B16C 8002A56C 26310010 */ addiu $s1, $s1, 0x10 -/* 02B170 8002A570 E634FFF0 */ swc1 $f20, -0x10($s1) -/* 02B174 8002A574 46186202 */ mul.s $f8, $f12, $f24 -/* 02B178 8002A578 46065100 */ add.s $f4, $f10, $f6 -/* 02B17C 8002A57C E636FFF4 */ swc1 $f22, -0xc($s1) -/* 02B180 8002A580 E638FFF8 */ swc1 $f24, -8($s1) -/* 02B184 8002A584 46082280 */ add.s $f10, $f4, $f8 -/* 02B188 8002A588 26100024 */ addiu $s0, $s0, 0x24 -/* 02B18C 8002A58C 46005187 */ neg.s $f6, $f10 -/* 02B190 8002A590 1639FF85 */ bne $s1, $t9, .L8002A3A8 -/* 02B194 8002A594 E626FFFC */ swc1 $f6, -4($s1) -/* 02B198 8002A598 8FBF007C */ lw $ra, 0x7c($sp) -/* 02B19C 8002A59C C7B50028 */ lwc1 $f21, 0x28($sp) -/* 02B1A0 8002A5A0 C7B4002C */ lwc1 $f20, 0x2c($sp) -/* 02B1A4 8002A5A4 C7B70030 */ lwc1 $f23, 0x30($sp) -/* 02B1A8 8002A5A8 C7B60034 */ lwc1 $f22, 0x34($sp) -/* 02B1AC 8002A5AC C7B90038 */ lwc1 $f25, 0x38($sp) -/* 02B1B0 8002A5B0 C7B8003C */ lwc1 $f24, 0x3c($sp) -/* 02B1B4 8002A5B4 C7BB0040 */ lwc1 $f27, 0x40($sp) -/* 02B1B8 8002A5B8 C7BA0044 */ lwc1 $f26, 0x44($sp) -/* 02B1BC 8002A5BC C7BD0048 */ lwc1 $f29, 0x48($sp) -/* 02B1C0 8002A5C0 C7BC004C */ lwc1 $f28, 0x4c($sp) -/* 02B1C4 8002A5C4 C7BF0050 */ lwc1 $f31, 0x50($sp) -/* 02B1C8 8002A5C8 C7BE0054 */ lwc1 $f30, 0x54($sp) -/* 02B1CC 8002A5CC 8FB00058 */ lw $s0, 0x58($sp) -/* 02B1D0 8002A5D0 8FB1005C */ lw $s1, 0x5c($sp) -/* 02B1D4 8002A5D4 8FB20060 */ lw $s2, 0x60($sp) -/* 02B1D8 8002A5D8 8FB30064 */ lw $s3, 0x64($sp) -/* 02B1DC 8002A5DC 8FB40068 */ lw $s4, 0x68($sp) -/* 02B1E0 8002A5E0 8FB5006C */ lw $s5, 0x6c($sp) -/* 02B1E4 8002A5E4 8FB60070 */ lw $s6, 0x70($sp) -/* 02B1E8 8002A5E8 8FB70074 */ lw $s7, 0x74($sp) -/* 02B1EC 8002A5EC 8FBE0078 */ lw $fp, 0x78($sp) -/* 02B1F0 8002A5F0 03E00008 */ jr $ra -/* 02B1F4 8002A5F4 27BD00D0 */ addiu $sp, $sp, 0xd0 - diff --git a/generate_ctx.sh b/generate_ctx.sh index 09aedabc..85c20430 100755 --- a/generate_ctx.sh +++ b/generate_ctx.sh @@ -1,3 +1,2 @@ #!/bin/bash -python3 tools/python/m2ctx.py - +python3 tools/python/m2ctx.py \ No newline at end of file diff --git a/include/level_object_entries.h b/include/level_object_entries.h index fc2c7d08..cf0e09cb 100644 --- a/include/level_object_entries.h +++ b/include/level_object_entries.h @@ -22,6 +22,8 @@ typedef struct LevelObjectEntry_Scenery { typedef struct LevelObjectEntry_Fish { /* 0x00 */ LevelObjectEntryCommon common; + /* 0x08 */ u8 pad8[0x4]; + /* 0x0C */ u8 unkC[1]; //Unknown size } LevelObjectEntry_Fish; typedef struct LevelObjectEntry_Animator { diff --git a/include/structs.h b/include/structs.h index cdcff8f4..e71e1f22 100644 --- a/include/structs.h +++ b/include/structs.h @@ -50,6 +50,18 @@ typedef struct Vec3i { }; } Vec3i; +typedef struct Vec4f { + union { + struct { + f32 x; + f32 y; + f32 z; + f32 w; + }; + f32 f[4]; + }; +} Vec4f; + /* Size: 0x20 bytes */ typedef struct TextureHeader { /* 0x00 */ u8 width; @@ -452,7 +464,12 @@ typedef struct Vertex { /* Size: 4 bytes */ typedef struct TexCoords { - s16 u, v; + union { + struct { + s16 u, v; + }; + u32 texCoords; // For convenience? + }; } TexCoords; /* Size: 16 bytes */ @@ -638,19 +655,20 @@ typedef struct ObjectHeader { u8 pad38[5]; /* 0x3D */ u8 unk3D; u8 pad3E[12]; - s16 unk4A; - s16 unk4C; - s16 drawDistance; + /* 0x4A */ s16 unk4A; + /* 0x4C */ s16 unk4C; + /* 0x4E */ s16 drawDistance; u8 pad50[3]; /* 0x53 */ s8 modelType; /* 0x54 */ s8 behaviorId; /* 0x55 */ s8 numberOfModelIds; // size of array pointed by Object->unk68 - u8 pad56; + /* 0x56 */ u8 pad56; /* 0x57 */ s8 unk57; - s8 unk58; - u8 pad59; + /* 0x58 */ s8 unk58; + /* 0x59 */ u8 pad59; /* 0x5A */ s8 unk5A; - u8 pad5B[0x2]; + /* 0x5B */ u8 unk5B; + /* 0x5C */ u8 unk5C; /* 0x5D */ u8 unk5D; //Misc Asset index? /* 0x5E */ u8 pad5E[0x2]; /* 0x60 */ char internalName[16]; @@ -758,7 +776,7 @@ typedef struct Object_5C { typedef struct Object_60 { s32 unk0; - s32 *unk4; // Object* pointer + struct Object *unk4; u8 unk8[0x24]; s8 *unk2C; } Object_60; @@ -835,6 +853,26 @@ typedef struct Object_Butterfly { /* 0x108 */ f32 unk108; } Object_Butterfly; +typedef struct Object_Fish { + /* 0x000 */ Triangle triangles[8]; + /* 0x080 */ Vertex vertices[12]; + /* 0x0F8 */ TextureHeader *texture; + /* 0x0FC */ u8 unkFC; + /* 0x0FD */ u8 unkFD; + /* 0x0FE */ u8 unkFE; + /* 0x0FF */ u8 unkFF; + /* 0x100 */ s32 unk100; + /* 0x104 */ s16 unk104; + /* 0x106 */ s16 unk106; + /* 0x108 */ f32 unk108; +} Object_Fish; + +typedef struct Object_Boost { + /* 0x000 */ u8 pad[0x70]; + /* 0x070 */ u8 unk70; + /* 0x074 */ f32 unk74; +} Object_Boost; + typedef struct Object_EffectBox { /* 0x000 */ u8 pad0[0x1FE]; /* 0x1FE */ u8 unk1FE; @@ -860,16 +898,9 @@ typedef struct Object_UnkId58 { } Object_UnkId58; typedef struct Object_CharacterFlag { - /* 0x00 */ s32 unk0; - /* 0x04 */ s32 unk4; - /* 0x08 */ s32 unk8; - /* 0x0C */ s32 unkC; - /* 0x10 */ s32 unk10; - /* 0x14 */ s32 unk14; - /* 0x18 */ s32 unk18; - /* 0x1C */ s32 unk1C; - /* 0x20 */ u16 *unk20; - /* 0x24 */ u8 *unk24; + /* 0x00 */ Triangle triangles[2]; + /* 0x20 */ Vertex *vertices; + /* 0x24 */ TextureHeader *texture; } Object_CharacterFlag; typedef struct Object_Snowball { @@ -1413,6 +1444,8 @@ typedef struct Object_64 { Object_WeaponBalloon weapon_balloon; Object_Weapon weapon; Object_Butterfly butterfly; + Object_Fish fish; + Object_Boost boost; Object_EffectBox effect_box; Object_EggCreator egg_creator; Object_CollectEgg egg; @@ -1462,7 +1495,11 @@ typedef struct Object_68 { }; /* 0x04 */ s32 *unk4[3]; /* 0x10 */ s16 unk10; - /* 0x14 */ u8 pad14[12]; + /* 0x12 */ u8 pad12[4]; + /* 0x16 */ s16 unk16; + /* 0x18 */ s16 unk18; + /* 0x1A */ s16 unk1A; + /* 0x1C */ s16 unk1C; /* 0x1E */ s8 unk1E; /* 0x1F */ s8 unk1F; /* 0x20 */ s8 unk20; @@ -1642,7 +1679,7 @@ typedef struct ObjectSegment { struct { /* 0x0038 */ u8 unk38; /* 0x0039 */ u8 unk39; - /* 0x003A */ s8 unk3A; + /* 0x003A */ s8 unk3A; // Index value for unk68 array /* 0x003B */ s8 unk3B; } byte; struct { diff --git a/src/camera.c b/src/camera.c index 28e364ea..26e882de 100644 --- a/src/camera.c +++ b/src/camera.c @@ -52,28 +52,31 @@ Vertex D_800DD138 = { 0, 0, 0, 255, 255, 255, 255 }; +//The viewport z-range below is half of the max (511) +#define G_HALFZ (G_MAXZ / 2) /* 9 bits of integer screen-Z precision */ + // RSP Viewports Vp gViewportStack[20] = { - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, - { { { 0, 0, 511, 0 }, { 0, 0, 511, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, }; ObjectTransform D_800DD288 = { @@ -155,6 +158,7 @@ void func_80065EA0(void) { gAntiPiracyViewport = 0; while (IO_READ(PI_STATUS_REG) & PI_STATUS_ERROR) { } + //0xB0000578 is a direct read from the ROM as opposed to RAM if ((D_B0000578 & 0xFFFF) != 0x8965) { gAntiPiracyViewport = TRUE; } @@ -193,6 +197,7 @@ void func_800660D0(void) { /** * Unused function that will return the current camera's FoV. + * Official Name: camGetFOV */ UNUSED f32 get_current_camera_fov(void) { return gCurCamFOV; @@ -200,6 +205,7 @@ UNUSED f32 get_current_camera_fov(void) { /** * Set the FoV of the viewspace, then recalculate the perspective matrix. + * Official Name: camSetFOV */ void update_camera_fov(f32 camFieldOfView) { if (CAMERA_MIN_FOV < camFieldOfView && camFieldOfView < CAMERA_MAX_FOV && camFieldOfView != gCurCamFOV) { @@ -329,6 +335,7 @@ void write_to_object_render_stack(s32 stackPos, f32 xPos, f32 yPos, f32 zPos, s1 /** * Check if the misc camera view is active. + * Official name: camIsUserView */ s8 check_if_showing_cutscene_camera(void) { return gCutsceneCameraActive; @@ -336,6 +343,7 @@ s8 check_if_showing_cutscene_camera(void) { /** * Disable the cutscene camera, returning it to the conventional mode. + * Official name: camSetUserView */ void disable_cutscene_camera(void) { gCutsceneCameraActive = FALSE; @@ -375,6 +383,7 @@ s32 set_active_viewports_and_max(s32 num) { /** * Sets the active viewport ID to the passed number. * If it's not within 1-4, then it's set to 0. + * Official name: camSetView */ void set_active_camera(s32 num) { if (num >= 0 && num < 4) { @@ -467,7 +476,6 @@ void camDisableUserView(s32 viewPortIndex, s32 arg1) { /** * Return's the current viewport's flag status for extended backgrounds. * Required to draw some extra things used in menus. - * Official name: camIsUserView */ s32 check_viewport_background_flag(s32 viewPortIndex) { return gScreenViewports[viewPortIndex].flags & VIEWPORT_EXTRA_BG; @@ -531,7 +539,6 @@ void resize_viewport(s32 viewPortIndex, s32 x1, s32 y1, s32 x2, s32 y2) { /** * Set the selected viewport's coordinate offsets and view size. * If you pass VIEWPORT_AUTO through, then the property will be automatically set when the game creates the viewports. - * Official name: camSetUserViewSpecial */ void set_viewport_properties(s32 viewPortIndex, s32 posX, s32 posY, s32 width, s32 height) { if (posX != VIEWPORT_AUTO) { @@ -592,6 +599,7 @@ void copy_viewport_frame_size_to_coords(s32 viewPortIndex, s32 *x1, s32 *y1, s32 /** * Unused function that sets the passed values to the framebuffer's size in coordinates. + * Official name: camGetWindowLimits */ UNUSED void copy_framebuffer_size_to_coords(s32 *x1, s32 *y1, s32 *x2, s32 *y2) { u32 widthAndHeight = get_video_width_and_height_as_s32(); @@ -609,26 +617,24 @@ UNUSED void copy_framebuffer_size_to_coords(s32 *x1, s32 *y1, s32 *x2, s32 *y2) #define SCISSOR_INTERLACE G_SC_NON_INTERLACE void func_80066CDC(Gfx **dlist, MatrixS **mats) { - u32 sp58; - u32 sp54; - u32 sp4C; - u32 temp_a2; - u32 temp_a3; - u32 temp_t0; - u32 width; + u32 sp58_vidHeight; + u32 sp54_vidWidth; + u32 sp50_altPosY; + u32 sp4C_altPosX; + u32 posX; + u32 posY; + u32 videoWidthHalf; + u32 videoHeightHalf; + u32 videoHeight; + u32 videoWidth; u32 widthAndHeight; - u32 temp_v0_6; - u32 phi_a1; - u32 phi_t3; - u32 phi_t5; - u32 phi_t4; - if (func_8000E184() && !gNumberOfViewports) { + if (func_8000E184() && gNumberOfViewports == 0) { gActiveCameraID = 1; } widthAndHeight = get_video_width_and_height_as_s32(); - temp_t0 = widthAndHeight >> 16; - temp_a3 = temp_t0 >> 1; + videoHeight = GET_VIDEO_HEIGHT(widthAndHeight); + videoWidth = GET_VIDEO_WIDTH(widthAndHeight); if (gScreenViewports[gActiveCameraID].flags & VIEWPORT_EXTRA_BG) { gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, gScreenViewports[gActiveCameraID].scissorX1, @@ -642,109 +648,109 @@ void func_80066CDC(Gfx **dlist, MatrixS **mats) { } return; } - width = GET_VIDEO_WIDTH(widthAndHeight); if (gNumberOfViewports == VIEWPORTS_COUNT_3_PLAYERS) { gNumberOfViewports = VIEWPORTS_COUNT_4_PLAYERS; } - temp_a2 = width >> 1; - sp54 = temp_a2; - sp58 = temp_a3; + videoHeightHalf = videoHeight >> 1; + videoWidthHalf = videoWidth >> 1; + sp54_vidWidth = videoWidthHalf; + sp58_vidHeight = videoHeightHalf; if (osTvType == TV_TYPE_PAL) { - sp58 = 0x91; + sp58_vidHeight = 145; } switch (gNumberOfViewports) { case VIEWPORTS_COUNT_1_PLAYER: - phi_t3 = sp58; + posY = sp58_vidHeight; if (osTvType == TV_TYPE_PAL) { - phi_t3 = sp58 - 0x12; + posY -= 18; } - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, width, temp_t0); - sp4C = temp_a2; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, videoWidth, videoHeight); + posX = videoWidthHalf; break; case VIEWPORTS_COUNT_2_PLAYERS: if (gActiveCameraID == 0) { - temp_v0_6 = temp_t0 >> 2; - phi_t3 = temp_v0_6; + posY = videoHeight >> 2; if (osTvType == TV_TYPE_PAL) { - phi_t3 = temp_v0_6 - 0xC; + posY -= 12; } - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, width, (temp_a3 - (temp_t0 >> 7))); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, videoWidth, (videoHeightHalf - (videoHeight >> 7))); } else { - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, (temp_a3 + (temp_t0 >> 7)), width, (temp_t0 - (temp_t0 >> 7))); - phi_t3 = temp_a3 + (temp_t0 >> 2); + posY = videoHeightHalf; + posY += videoHeight >> 2; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, (videoHeightHalf + (videoHeight >> 7)), videoWidth, (videoHeight - (videoHeight >> 7))); } - sp4C = temp_a2; + posX = videoWidthHalf; break; case VIEWPORTS_COUNT_3_PLAYERS: if (gActiveCameraID == 0) { - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_a2 - (width >> 8), temp_t0); - phi_a1 = width >> 2; + posY = sp58_vidHeight; + posX = videoWidth >> 2; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, videoWidthHalf - (videoWidth >> 8), videoHeight); } else { - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, temp_a2 + (width >> 8), 0, width - (width >> 8), temp_t0); - phi_a1 = temp_a2 + (width >> 2); + posY = sp58_vidHeight; + posX = videoWidthHalf; + posX += videoWidth >> 2; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, videoWidthHalf + (videoWidth >> 8), 0, videoWidth - (videoWidth >> 8), videoHeight); } - sp4C = phi_a1; - phi_t3 = sp58; break; case VIEWPORTS_COUNT_4_PLAYERS: - sp58 = sp58 >> 1; - sp54 = temp_a2 >> 1; + sp58_vidHeight >>= 1; + sp54_vidWidth = videoWidthHalf >> 1; + posY = 0; + posX = 0; switch (gActiveCameraID) { case 0: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0.0f, 0.0f, (temp_a2 - (width >> 8)), (temp_a3 - (temp_t0 >> 7))); - phi_t5 = 0; - phi_t4 = 0; + //Using posX and posY here is not smart since IDO can't optimize out the zero now. + //Why here of all places did they do this instead of just setting zero like everywhere else? + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, posX, posY, (videoWidthHalf - (videoWidth >> 8)), (videoHeightHalf - (videoHeight >> 7))); case 1: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (temp_a2 + (width >> 8)), 0, ((temp_a2 * 2) - (width >> 8)), (temp_a3 - (temp_t0 >> 7))); - phi_t5 = 0; - phi_t4 = temp_a2; + posX += videoWidthHalf; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (videoWidthHalf + (videoWidth >> 8)), 0, ((videoWidthHalf * 2) - (videoWidth >> 8)), (videoHeightHalf - (videoHeight >> 7))); break; case 2: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, temp_a3 + (temp_t0 >> 7), temp_a2 - (width >> 8), (temp_a3 * 2) - (temp_t0 >> 7)); - phi_t5 = temp_a3; - phi_t4 = 0; + posY += videoHeightHalf; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, videoHeightHalf + (videoHeight >> 7), videoWidthHalf - (videoWidth >> 8), (videoHeightHalf * 2) - (videoHeight >> 7)); break; case 3: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, temp_a2 + (width >> 8), temp_a3 + (temp_t0 >> 7), (temp_a2 * 2) - (width >> 8), (temp_a3 * 2) - (temp_t0 >> 7)); - phi_t5 = temp_a3; - phi_t4 = temp_a2; + posY += videoHeightHalf; + posX += videoWidthHalf; + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, videoWidthHalf + (videoWidth >> 8), videoHeightHalf + (videoHeight >> 7), (videoWidthHalf * 2) - (videoWidth >> 8), (videoHeightHalf * 2) - (videoHeight >> 7)); break; default: - phi_t5 = 0; - phi_t4 = 0; break; } - phi_t3 = phi_t5 + sp58; - sp4C = phi_t4 + sp54; + posY += sp58_vidHeight; + posX += sp54_vidWidth; if (osTvType == TV_TYPE_PAL) { - phi_t3 -= 6; + posY -= 6; if (gActiveCameraID < 2) { - phi_t3 -= 0x14; + posY -= 20; } } break; default: - //phi_t3 = sp50; - phi_t3 = sp54; + //@bug These values are unset! + posY = sp50_altPosY; + posX = sp4C_altPosX; break; } if (osTvType == TV_TYPE_PAL) { - sp4C -= 4; + posX -= 4; } - func_80068158(dlist, sp54, sp58, sp4C, phi_t3); - if (mats != 0) { + func_80068158(dlist, sp54_vidWidth, sp58_vidHeight, posX, posY); + if (mats != NULL) { func_80067D3C(dlist, mats); } } - #else GLOBAL_ASM("asm/non_matchings/camera/func_80066CDC.s") #endif /** * Takes the size of the screen as depicted by an active screen viewport, then sets the RDP scissor to match it. + * Official Name: camSetScissor */ void set_viewport_scissor(Gfx **dlist) { s32 size; @@ -837,6 +843,7 @@ void set_viewport_scissor(Gfx **dlist) { gDPSetScissor((*dlist)++, 0, 0, 0, width, height); } +//Official Name: camGetPlayerProjMtx / camSetProjMtx - ?? void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) { s32 temp; @@ -881,6 +888,7 @@ void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) { /** * Sets the Y value of the Y axis in the matrix to the passed value. * This is used to vertically scale ortho geometry to look identical across NTSC and PAL systems. + * Official Name: camOrthoYAspect */ void set_ortho_matrix_height(f32 value) { gOrthoMatrix[1][1] = value; @@ -889,6 +897,7 @@ void set_ortho_matrix_height(f32 value) { /** * Sets the current matrix to represent an orthogonal view. * Used for drawing triangles on screen as HUD. + * Official Name: camStandardOrtho */ void set_ortho_matrix_view(Gfx **dlist, MatrixS **mtx) { u32 widthAndHeight; @@ -917,6 +926,7 @@ void set_ortho_matrix_view(Gfx **dlist, MatrixS **mtx) { } } +//Official Name: camStandardPersp? void func_8006807C(Gfx **dlist, MatrixS **mtx) { object_transform_to_matrix_2(D_80121060, &D_800DD288); f32_matrix_mult(&D_80121060, &gPerspectiveMatrixF, &D_80120F20); @@ -928,6 +938,7 @@ void func_8006807C(Gfx **dlist, MatrixS **mtx) { D_80120D08 = 0; } +//Official Name: camSetViewport? void func_80068158(Gfx **dlist, s32 width, s32 height, s32 posX, s32 posY) { s32 tempWidth = (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) ? -width : width; // Antipiracy measure. Flips the screen upside down. @@ -946,6 +957,7 @@ void func_80068158(Gfx **dlist, s32 width, s32 height, s32 posX, s32 posY) { } } +//Official Name: camResetView? void func_800682AC(Gfx **dlist) { u32 widthAndHeight, width, height; gActiveCameraID = 4; @@ -962,6 +974,7 @@ void func_800682AC(Gfx **dlist) { gActiveCameraID = 0; } +//Official Name: camOffsetZero? void func_80068408(Gfx **dlist, MatrixS **mtx) { f32_matrix_from_position(D_80120D70[D_80120D1C], 0.0f, 0.0f, 0.0f); f32_matrix_mult(D_80120D70[D_80120D1C], &D_80120F20, &D_80121060); @@ -1033,9 +1046,9 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj gCameraTransform.z_position = obj->segment.trans.z_position; object_transform_to_matrix(D_80121060, &gCameraTransform); D_80120D1C++; - f32_matrix_mult((Matrix *) D_80121060, (Matrix *) &D_80120D70[D_80120D1C-1][0][0], (Matrix *) &D_80120D70[D_80120D1C][0][0]); - f32_matrix_mult(D_80120D70[D_80120D1C], (Matrix *) D_80120F20, (Matrix *) D_80121060); - f32_matrix_to_s16_matrix((Matrix *) D_80121060, *mtx); + f32_matrix_mult(&D_80121060, D_80120D70[D_80120D1C-1], D_80120D70[D_80120D1C]); + f32_matrix_mult(D_80120D70[D_80120D1C], &D_80120F20, &D_80121060); + f32_matrix_to_s16_matrix(&D_80121060, *mtx); D_80120D88[D_80120D1C] = *mtx; gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0((*mtx)++), 0x80); gSPVertexDKR((*dlist)++, OS_K0_TO_PHYSICAL(&D_800DD138), 1, 0); @@ -1149,7 +1162,66 @@ void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, Objec } } -GLOBAL_ASM("asm/non_matchings/camera/func_80068FA8.s") +void func_80068FA8(Gfx **dlist, MatrixS **mtx, Object *arg2, Object *arg3, f32 shear) { + UNUSED s32 pad; + f32 cossf_x_arg2; + f32 cossf_y_arg2; + f32 sinsf_x_arg2; + f32 sinsf_y_arg2; + f32 sinsf_y_arg3; + f32 sinsf_z_arg3; + f32 arg2_scale; + f32 cossf_x_arg3; + f32 sinsf_x_arg3; + f32 cossf_y_arg3; + f32 cossf_z_arg3; + f32 arg2_xPos; + f32 arg2_yPos; + f32 arg2_zPos; + f32 arg3_xPos; + f32 arg3_yPos; + f32 arg3_zPos; + Matrix matrix_mult; + + cossf_x_arg2 = coss_f(arg2->segment.trans.x_rotation); + sinsf_x_arg2 = sins_f(arg2->segment.trans.x_rotation); + cossf_y_arg2 = coss_f(arg2->segment.trans.y_rotation); + sinsf_y_arg2 = sins_f(arg2->segment.trans.y_rotation); + arg2_xPos = arg2->segment.trans.x_position; + arg2_yPos = arg2->segment.trans.y_position; + arg2_zPos = arg2->segment.trans.z_position; + cossf_z_arg3 = coss_f(arg3->segment.trans.z_rotation); + sinsf_z_arg3 = sins_f(arg3->segment.trans.z_rotation); + cossf_x_arg3 = coss_f(arg3->segment.trans.x_rotation); + sinsf_x_arg3 = sins_f(arg3->segment.trans.x_rotation); + cossf_y_arg3 = coss_f(arg3->segment.trans.y_rotation); + sinsf_y_arg3 = sins_f(arg3->segment.trans.y_rotation); + arg3_xPos = arg3->segment.trans.x_position; + arg3_yPos = arg3->segment.trans.y_position; + arg3_zPos = arg3->segment.trans.z_position; + arg2_scale = arg2->segment.trans.scale; + shear *= arg2_scale; + matrix_mult[0][0] = ((((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * cossf_y_arg2) + (-sinsf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))) * arg2_scale; + matrix_mult[0][1] = (((sinsf_z_arg3 * cossf_x_arg3) * cossf_y_arg2) + (-sinsf_y_arg2 * -sinsf_x_arg3)) * arg2_scale; + matrix_mult[0][2] = ((((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * cossf_y_arg2) + (-sinsf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))) * arg2_scale; + matrix_mult[0][3] = 0.0f; + matrix_mult[1][0] = ((((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * cossf_x_arg2) + (sinsf_x_arg2 * ((sinsf_y_arg2 * ((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))))) * shear; + matrix_mult[1][1] = (((cossf_z_arg3 * cossf_x_arg3) * cossf_x_arg2) + (sinsf_x_arg2 * ((sinsf_y_arg2 * (sinsf_z_arg3 * cossf_x_arg3)) + (cossf_y_arg2 * -sinsf_x_arg3)))) * shear; + matrix_mult[1][2] = ((((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * cossf_x_arg2) + (sinsf_x_arg2 * ((sinsf_y_arg2 * ((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))))) * shear; + matrix_mult[1][3] = 0.0f; + matrix_mult[2][0] = ((-sinsf_x_arg2 * ((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (cossf_x_arg2 * ((sinsf_y_arg2 * ((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))))) * arg2_scale; + matrix_mult[2][1] = ((-sinsf_x_arg2 * (cossf_z_arg3 * cossf_x_arg3)) + (cossf_x_arg2 * ((sinsf_y_arg2 * (sinsf_z_arg3 * cossf_x_arg3)) + (cossf_y_arg2 * -sinsf_x_arg3)))) * arg2_scale; + matrix_mult[2][2] = ((-sinsf_x_arg2 * ((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (cossf_x_arg2 * ((sinsf_y_arg2 * ((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))))) * arg2_scale; + matrix_mult[2][3] = 0.0f; + matrix_mult[3][0] = (((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * arg2_xPos) + (arg2_yPos * ((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (arg2_zPos * (cossf_x_arg3 * sinsf_y_arg3)) + arg3_xPos; + matrix_mult[3][1] = ((sinsf_z_arg3 * cossf_x_arg3) * arg2_xPos) + (arg2_yPos * (cossf_z_arg3 * cossf_x_arg3)) + (arg2_zPos * -sinsf_x_arg3) + arg3_yPos; + matrix_mult[3][2] = (((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * arg2_xPos) + (arg2_yPos * ((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (arg2_zPos * (cossf_x_arg3 * cossf_y_arg3)) + arg3_zPos; + matrix_mult[3][3] = 1.0f; + + f32_matrix_mult(&matrix_mult, &D_80120F20, &D_801210A0); + f32_matrix_to_s16_matrix(&D_801210A0, *mtx); + gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_DKR_INDEX_1); +} void func_80069484(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f32 scale, f32 scaleY) { f32 tempX; @@ -1201,7 +1273,45 @@ void func_80069484(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f32 scale D_80120D58[index] = tempZ; } -GLOBAL_ASM("asm/non_matchings/camera/func_80069790.s") +void func_80069790(Gfx **dlist, MatrixS **mtx, Object_68 *obj68, s16 headAngle) { + f32 coss_headAngle; + f32 sins_headAngle; + f32 f_unk16; + f32 f_unk18; + f32 f_unk1A; + f32 coss_unk1C; + f32 sins_unk1C; + Matrix spA4_mat; + Matrix sp64_mat; + + f_unk16 = (f32) obj68->unk16; + f_unk18 = (f32) obj68->unk18; + f_unk1A = (f32) obj68->unk1A; + coss_unk1C = coss_f(obj68->unk1C); + sins_unk1C = sins_f(obj68->unk1C); + coss_headAngle = coss_f(headAngle); + sins_headAngle = sins_f(headAngle); + sp64_mat[0][0] = (coss_headAngle * coss_unk1C); + sp64_mat[0][1] = (coss_headAngle * sins_unk1C); + sp64_mat[0][2] = -sins_headAngle; + sp64_mat[0][3] = 0.0f; + sp64_mat[1][0] = -sins_unk1C; + sp64_mat[1][1] = coss_unk1C; + sp64_mat[1][2] = 0.0f; + sp64_mat[1][3] = 0.0f; + sp64_mat[2][0] = (sins_headAngle * coss_unk1C); + sp64_mat[2][1] = (sins_headAngle * sins_unk1C); + sp64_mat[2][2] = coss_headAngle; + sp64_mat[2][3] = 0.0f; + sp64_mat[3][0] = (-f_unk16 * (coss_headAngle * coss_unk1C)) + (-f_unk18 * -sins_unk1C) + (-f_unk1A * (sins_headAngle * coss_unk1C)) + f_unk16; + sp64_mat[3][1] = (-f_unk16 * (coss_headAngle * sins_unk1C)) + (-f_unk18 * coss_unk1C) + (-f_unk1A * (sins_headAngle * sins_unk1C)) + f_unk18; + sp64_mat[3][2] = (-f_unk16 * -sins_headAngle) + (-f_unk1A * coss_headAngle) + f_unk1A; + sp64_mat[3][3] = 1.0f; + f32_matrix_mult(&sp64_mat, &D_801210A0, &spA4_mat); + f32_matrix_to_s16_matrix(&spA4_mat, *mtx); + gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_DKR_INDEX_2); + gDkrInsertMatrix((*dlist)++, G_MWO_MATRIX_XX_XY_I, G_MTX_DKR_INDEX_1); +} UNUSED void func_800699E4(f32 *arg0, f32 *arg1, f32 *arg2) { *arg0 = D_80120D28[D_80120D20]; @@ -1219,7 +1329,7 @@ void func_80069A40(Gfx **dlist) { gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0(D_80120D88[D_80120D1C]), G_MTX_DKR_INDEX_1); } else { - gDkrInsertMatrix((*dlist)++, G_MWO_MATRIX_XX_XY_I, 0); + gDkrInsertMatrix((*dlist)++, G_MWO_MATRIX_XX_XY_I, G_MTX_DKR_INDEX_0); } } diff --git a/src/camera.h b/src/camera.h index 7b4240f9..f3deb67f 100644 --- a/src/camera.h +++ b/src/camera.h @@ -127,6 +127,8 @@ void func_80069484(Gfx **arg0, MatrixS **arg1, ObjectTransform *arg2, f32 arg3, void set_viewport_scissor(Gfx **dlist); void func_80069A40(Gfx **dlist); void copy_viewports_to_stack(void); +void func_80069790(Gfx **dlist, MatrixS **mtx, Object_68 *obj68, s16 headAngle); +void func_80068FA8(Gfx **dlist, MatrixS **mtx, Object *arg2, Object *arg3, f32 shear); // Non Matching void func_80065EA0(void); diff --git a/src/controller.c b/src/controller.c index 2bf48ea2..2af2a212 100644 --- a/src/controller.c +++ b/src/controller.c @@ -20,6 +20,7 @@ u8 sPlayerID[16]; /** * Return the serial interface message queue. + * Official name: joyMessageQ */ OSMesgQueue *get_si_mesg_queue(void) { return &sSIMesgQueue; @@ -27,6 +28,7 @@ OSMesgQueue *get_si_mesg_queue(void) { /** * Initialise the player controllers, and return the status when finished. + * Official name: joyInit */ s32 init_controllers(void) { UNUSED s32 *temp1; @@ -55,6 +57,7 @@ s32 init_controllers(void) { /** * Reads arg0 for a set of flags on whether to read, write, or erase any save data. * Also reads the latest inputs from the controllers, and sets their values. + * Official name: joyRead */ s32 handle_save_data_and_read_controller(s32 saveDataFlags, s32 updateRate) { Settings **allSaves; @@ -176,6 +179,7 @@ u16 get_buttons_held_from_player(s32 player) { /** * Returns the buttons that are newly pressed during that frame. * NOTE: This was a u16, but we only got a match in menu_ghost_data_loop when it was a u32 for some reason + * Official name: joyGetPressed */ u32 get_buttons_pressed_from_player(s32 player) { return gControllerButtonsPressed[sPlayerID[player]]; @@ -183,6 +187,7 @@ u32 get_buttons_pressed_from_player(s32 player) { /** * Returns the buttons that are no longer pressed in that frame. + * Official name: joyGetReleased */ u16 get_buttons_released_from_player(s32 player) { return gControllerButtonsReleased[sPlayerID[player]]; @@ -190,6 +195,7 @@ u16 get_buttons_released_from_player(s32 player) { /** * Clamps the X joystick axis of the selected player to 70 and returns it. + * Official name: joyGetStickX */ s8 clamp_joystick_x_axis(s32 player) { return clamp_joystick(sControllerCurrData[sPlayerID[player]].stick_x); @@ -197,6 +203,7 @@ s8 clamp_joystick_x_axis(s32 player) { /** * Clamps the Y joystick axis of the selected player to 70 and returns it. + * Official name: joyGetStickY */ s8 clamp_joystick_y_axis(s32 player) { return clamp_joystick(sControllerCurrData[sPlayerID[player]].stick_y); @@ -226,6 +233,7 @@ s8 clamp_joystick(s8 stickMag) { /** * Used when anti-cheat/anti-tamper has failed in func_8006A6B0() + * Official Name: joySetSecurity */ void disable_button_mask(void) { gButtonMask = 0; diff --git a/src/fade_transition.c b/src/fade_transition.c index 5a730741..d5df14d8 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -491,26 +491,29 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C15D4.s") GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C1EE8.s") #ifdef NON_EQUIVALENT -void render_fade_circle(Gfx **dList, MatrixS **mats, Vertex **verts) { - u8 *addr, *addr2; +#define NUM_OF_VERTS 18 +#define NUM_OF_TRIS 16 +void render_fade_circle(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { + Vertex *vertsToRender; + Triangle *trisToRender; reset_render_settings(dList); + vertsToRender = (Vertex *) sTransitionVtx[sTransitionTaskNum[0]]; + trisToRender = (Triangle *) sTransitionTris[sTransitionTaskNum[0]]; gSPDisplayList((*dList)++, dTransitionShapeSettings); - addr = OS_PHYSICAL_TO_K0(sTransitionVtx[sTransitionTaskNum[0]]); - addr2 = OS_PHYSICAL_TO_K0(sTransitionTris[sTransitionTaskNum[0]]); - gSPVertexDKR((*dList)++, addr, 18, 0); - gSPPolygon((*dList)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); - addr += 0xB4; - addr2 += 0x100; - gSPVertexDKR((*dList)++, addr, 18, 0); - gSPPolygon((*dList)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); - addr += 0xB4; - addr2 += 0x100; - gSPVertexDKR((*dList)++, addr, 18, 0); - gSPPolygon((*dList)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); - addr += 0xB4; - addr2 += 0x100; - gSPVertexDKR((*dList)++, addr, 18, 0); - gSPPolygon((*dList)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); + gSPVertexDKR((*dList)++, OS_PHYSICAL_TO_K0(vertsToRender), NUM_OF_VERTS, 0); + gSPPolygon((*dList)++, OS_PHYSICAL_TO_K0(trisToRender), NUM_OF_TRIS, TRIN_DISABLE_TEXTURE); + vertsToRender += NUM_OF_VERTS; + trisToRender += NUM_OF_TRIS; + gSPVertexDKR((*dList)++, OS_PHYSICAL_TO_K0(vertsToRender), NUM_OF_VERTS, 0); + gSPPolygon((*dList)++, OS_PHYSICAL_TO_K0(trisToRender), NUM_OF_TRIS, TRIN_DISABLE_TEXTURE); + vertsToRender += NUM_OF_VERTS; + trisToRender += NUM_OF_TRIS; + gSPVertexDKR((*dList)++, OS_PHYSICAL_TO_K0(vertsToRender), NUM_OF_VERTS, 0); + gSPPolygon((*dList)++, OS_PHYSICAL_TO_K0(trisToRender), NUM_OF_TRIS, TRIN_DISABLE_TEXTURE); + vertsToRender += NUM_OF_VERTS; + trisToRender += NUM_OF_TRIS; + gSPVertexDKR((*dList)++, OS_PHYSICAL_TO_K0(vertsToRender), NUM_OF_VERTS, 0); + gSPPolygon((*dList)++, OS_PHYSICAL_TO_K0(trisToRender), NUM_OF_TRIS, TRIN_DISABLE_TEXTURE); reset_render_settings(dList); } #else diff --git a/src/game.c b/src/game.c index 5fa1d629..af5ac149 100644 --- a/src/game.c +++ b/src/game.c @@ -785,9 +785,7 @@ void func_8006BFC8(s8 *arg0) { phi_s0 = arg0[phi_s0]; - // Check if CHEAT_ULTIMATE_AI is active - // This check works because a << 6 will but a 1 in the sign bit making it negative - if ((get_filtered_cheats() << 6) < 0) { + if (get_filtered_cheats() & CHEAT_ULTIMATE_AI) { phi_s0 = 9; } if (get_render_context() == DRAW_MENU) { @@ -1502,11 +1500,16 @@ void func_8006D968(s8 *arg0) { } } -s32 get_render_context(void) { +/** + * Gets the render context from outside this file + */ +RenderContext get_render_context(void) { return sRenderContext; } -/* Unused function used to set the render context from outside this file */ +/** + * Unused function used to set the render context from outside this file + */ UNUSED void set_render_context(s32 changeTo) { sRenderContext = changeTo; } @@ -2101,18 +2104,18 @@ void func_8006F140(s32 arg0) { gLevelLoadTimer = 40; D_80123524 = 0; D_80123526 = 0; - if (arg0 == 1) { + if (arg0 == 1) { //FADE_BARNDOOR_HORIZONTAL? transition_begin(&D_800DD41C); } - if (arg0 == 3) { + if (arg0 == 3) { //FADE_CIRCLE? gLevelLoadTimer = 282; transition_begin(&D_800DD424); } - if (arg0 == 4) { + if (arg0 == 4) { //FADE_WAVES? gLevelLoadTimer = 360; transition_begin(&D_800DD424); } - if (arg0 == 0) { + if (arg0 == 0) { //FADE_FULLSCREEN? gLevelLoadTimer = 2; } } @@ -2219,7 +2222,7 @@ s32 is_controller_missing(void) { * A false read, meaning you're caught running an illegitimate copy, will force the game to pause when you enter the world. */ s32 check_imem_validity(void) { - if (IO_READ(SP_IMEM_START) != 0x17D7) { + if (IO_READ(SP_IMEM_START) != CIC_ID) { return FALSE; } return TRUE; diff --git a/src/game.h b/src/game.h index 6a61a9be..47aca92e 100644 --- a/src/game.h +++ b/src/game.h @@ -8,7 +8,7 @@ #include "libc/math.h" #include "racer.h" -enum RenderContext { +typedef enum RenderContext { DRAW_INTRO = -1, DRAW_GAME, DRAW_MENU, @@ -16,7 +16,7 @@ enum RenderContext { DRAW_UNK_03, DRAW_UNK_04, DRAW_CRASH_SCREEN -}; +} RenderContext; /* Size: 6 bytes */ typedef struct unk8012117C { @@ -103,7 +103,7 @@ void func_8006D8A4(void); void func_8006D8E0(s32 arg0); void func_8006D8F0(s32 arg0); void func_8006D968(s8 *arg0); -s32 get_render_context(void); +RenderContext get_render_context(void); UNUSED void func_8006DA1C(s32 arg0); void load_menu_with_level_background(s32 menuId, s32 levelId, s32 cutsceneId); void set_level_default_vehicle(Vehicle arg0); diff --git a/src/menu.c b/src/menu.c index 11f2f82a..9a7f3121 100644 --- a/src/menu.c +++ b/src/menu.c @@ -4080,7 +4080,7 @@ void render_magic_codes_ui(s32 arg0) { } render_dialogue_box(&sMenuCurrDisplayList, 0, 0, 6); } - if ((get_filtered_cheats() << 3) < 0) { + if (get_filtered_cheats() & CHEAT_ROM_CHECKSUM) { calculate_and_display_rom_checksum(); } } diff --git a/src/object_functions.c b/src/object_functions.c index 15bfbf88..ebd2e181 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -38,13 +38,13 @@ FadeTransition D_800DC970 = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_UNK1, FADE_COLOR_WHITE, 7, 3); FadeTransition D_800DC978 = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 30, 0xFFFF); -u16 D_800DC980[20] = { - 0xFF00, 0x0100, 0x0000, 0xFFFF, - 0xFFFF, 0x0100, 0x0100, 0x0000, - 0xFFFF, 0xFFFF, 0x0100, 0xFF00, - 0x0000, 0xFFFF, 0xFFFF, 0xFF00, - 0xFF00, 0x0000, 0xFFFF, 0xFFFF, +Vertex D_800DC980[4] = { + { -256, 256, 0, 255, 255, 255, 255 }, + { 256, 256, 0, 255, 255, 255, 255 }, + { 256, -256, 0, 255, 255, 255, 255 }, + { -256, -256, 0, 255, 255, 255, 255 }, }; + u16 D_800DC9A8[20] = { 0x0000, 0x0040, 0xFFC0, 0x0000, 0xFFC0, 0xFFC0, 0x0000, 0x0040, @@ -98,14 +98,14 @@ s8 D_800DCA9C[12] = { }; Triangle D_800DCAA8[8] = { - { {{ 0, 0, 3, 1 }}, { 0, 0 }, { -1, -1 }, { 0, -1 } }, - { {{ 0, 0, 2, 3 }}, { 0, 0 }, { -1, 0 }, { -1, -1 } }, - { {{ 0, 2, 5, 3 }}, { -1, 0 }, { 0, -1 }, { -1, -1 } }, - { {{ 0, 2, 4, 5 }}, { -1, 0 }, { 0, 0 }, { 0, -1 } }, - { {{ 0, 0, 1, 3 }}, { 0, 0 }, { 0, -1 }, { -1, -1 } }, - { {{ 0, 0, 3, 2 }}, { 0, 0 }, { -1, -1 }, { -1, 0 } }, - { {{ 0, 2, 3, 5 }}, { -1, 0 }, { -1, -1 }, { 0, -1 } }, - { {{ 0, 2, 5, 4 }}, { -1, 0 }, { 0, -1 }, { 0, 0 } }, + { {{ 0, 0, 3, 1 }}, {{{ 0, 0 }}}, {{{ -1, -1 }}}, {{{ 0, -1 }}} }, + { {{ 0, 0, 2, 3 }}, {{{ 0, 0 }}}, {{{ -1, 0 }}}, {{{ -1, -1 }}} }, + { {{ 0, 2, 5, 3 }}, {{{ -1, 0 }}}, {{{ 0, -1 }}}, {{{ -1, -1 }}} }, + { {{ 0, 2, 4, 5 }}, {{{ -1, 0 }}}, {{{ 0, 0 }}}, {{{ 0, -1 }}} }, + { {{ 0, 0, 1, 3 }}, {{{ 0, 0 }}}, {{{ 0, -1 }}}, {{{ -1, -1 }}} }, + { {{ 0, 0, 3, 2 }}, {{{ 0, 0 }}}, {{{ -1, -1 }}}, {{{ -1, 0 }}} }, + { {{ 0, 2, 3, 5 }}, {{{ -1, 0 }}}, {{{ -1, -1 }}}, {{{ 0, -1 }}} }, + { {{ 0, 2, 5, 4 }}, {{{ -1, 0 }}}, {{{ 0, -1 }}}, {{{ 0, 0 }}} }, }; VertexPosition D_800DCB28[6] = { @@ -1028,21 +1028,22 @@ void obj_loop_characterflag(Object *obj, UNUSED s32 updateRate) { obj64 = &obj->unk64->character_flag; someObj64 = &someObj->unk64->racer; obj->unk7C.word = someObj64->characterId; - if (obj->unk7C.word < 0 || obj->unk7C.word >= 0xA) { + if (obj->unk7C.word < 0 || obj->unk7C.word >= 10) { obj->unk7C.word = 0; } - obj64->unk20 = D_800DC980; - obj64->unk24 = (u8 *) obj->unk68[obj->unk7C.word]; - temp_t4 = (obj64->unk24[0] - 1) << 0x15; - temp_t5 = (obj64->unk24[1] - 1) << 5; - obj64->unk0 = 0x40000103; - obj64->unk4 = 0; - obj64->unk8 = temp_t4; - obj64->unkC = temp_t5; - obj64->unk10 = 0x40010203; - obj64->unk14 = temp_t4; - obj64->unk18 = (s32)(temp_t4 | temp_t5); - obj64->unk1C = temp_t5; + obj64->vertices = D_800DC980; + obj64->texture = (TextureHeader *) &obj->unk68[obj->unk7C.word]->texHeader; + temp_t4 = (obj64->texture->width - 1) << 21; + temp_t5 = (obj64->texture->height - 1) << 5; + //0x40 = Draw backface + obj64->triangles[0].vertices = (0x40 << 24) | (0 << 16) | (1 << 8) | 3; + obj64->triangles[0].uv0.texCoords = 0; + obj64->triangles[0].uv1.texCoords = temp_t4; + obj64->triangles[0].uv2.texCoords = temp_t5; + obj64->triangles[1].vertices = (0x40 << 24) | (1 << 16) | (2 << 8) | 3; + obj64->triangles[1].uv0.texCoords = temp_t4; + obj64->triangles[1].uv1.texCoords = (temp_t4 | temp_t5); + obj64->triangles[1].uv2.texCoords = temp_t5; } } } @@ -3967,7 +3968,7 @@ void obj_loop_weapon(Object *obj, s32 updateRate) { break; case WEAPON_TRIPMINE: case WEAPON_OIL_SLICK: - case WEAOON_BUBBLE_TRAP: + case WEAPON_BUBBLE_TRAP: case WEAPON_UNK_11: func_8003F2E8(obj, updateRate); break; diff --git a/src/object_functions.h b/src/object_functions.h index 8478bf09..25acff40 100644 --- a/src/object_functions.h +++ b/src/object_functions.h @@ -246,7 +246,6 @@ typedef struct Object_LevelName_78 { } Object_LevelName_78; // Unsure about the signed/unsigned with these arrays. -extern u16 D_800DC980[20]; extern u16 D_800DC9A8[20]; extern u16 D_800DC9D0[64]; extern s8 D_800DCA50[8]; diff --git a/src/objects.c b/src/objects.c index fa1b8eee..bf2402ee 100644 --- a/src/objects.c +++ b/src/objects.c @@ -26,6 +26,7 @@ #include "unknown_032760.h" #include "game_ui.h" #include "unknown_008C40.h" +#include "controller.h" #define MAX_CHECKPOINTS 60 #define OBJECT_POOL_SIZE 0x15800 @@ -149,7 +150,8 @@ extern f32 D_800E5644; // Currently defined in unknown_005740. Might need to be defined here. extern s16 D_8011AC20[128]; -s8 D_8011AD20[2]; +s8 D_8011AD20; +s8 D_8011AD21; s8 D_8011AD22[2]; s8 D_8011AD24[2]; s8 D_8011AD26[2]; @@ -214,7 +216,7 @@ s32 objCount; s32 D_8011AE60; s32 D_8011AE64; Object *gObjectMemoryPool; -s32 *D_8011AE6C; +Object **D_8011AE6C; s32 D_8011AE70; Object **D_8011AE74; s16 D_8011AE78; @@ -241,8 +243,8 @@ CheckpointNode *gTrackCheckpoints; // Array of structs, unknown number of member s32 gNumberOfCheckpoints; s32 D_8011AED4; s16 gTajChallengeType; -u32 (*D_8011AEDC)[64]; // Not sure about the number of elements -s32 D_8011AEE0; +Object *(*gCameraObjList)[20]; // Camera objects with a maximum of 20 +s32 gCameraObjCount; //The number of camera objects in the above list Object *(*gRacers)[8]; // Similar to gRacers, but sorts the pointer by the players' current position in the race. Object **gRacersByPosition; @@ -355,10 +357,10 @@ void allocate_object_pools(void) { func_8001D258(0.67f, 0.33f, 0, -0x2000, 0); gObjectMemoryPool = (Object *) new_sub_memory_pool(OBJECT_POOL_SIZE, OBJECT_SLOT_COUNT); gParticlePtrList = (Object **) allocate_from_main_pool_safe(sizeof(uintptr_t) * 200, COLOUR_TAG_BLUE); - D_8011AE6C = (s32 *) allocate_from_main_pool_safe(0x50, COLOUR_TAG_BLUE); + D_8011AE6C = (Object **) allocate_from_main_pool_safe(0x50, COLOUR_TAG_BLUE); D_8011AE74 = (Object **) allocate_from_main_pool_safe(0x200, COLOUR_TAG_BLUE); gTrackCheckpoints = (CheckpointNode *) allocate_from_main_pool_safe(sizeof(CheckpointNode) * MAX_CHECKPOINTS, COLOUR_TAG_BLUE); - D_8011AEDC = allocate_from_main_pool_safe(0x50, COLOUR_TAG_BLUE); + gCameraObjList = allocate_from_main_pool_safe(0x50, COLOUR_TAG_BLUE); gRacers = allocate_from_main_pool_safe(sizeof(uintptr_t) * 10, COLOUR_TAG_BLUE); gRacersByPort = (Object **) allocate_from_main_pool_safe(sizeof(uintptr_t) * 10, COLOUR_TAG_BLUE); gRacersByPosition = (Object **) allocate_from_main_pool_safe(sizeof(uintptr_t) * 10, COLOUR_TAG_BLUE); @@ -439,7 +441,7 @@ void func_8000C460(void) { D_8011AED4 = 0; gNumRacers = 0; D_8011AE78 = 0; - D_8011AD20[1] = 0; + D_8011AD21 = 0; D_8011AD22[0] = 0; D_8011AD22[1] = 0; @@ -587,7 +589,7 @@ void instShowBearBar(void) { } s8 func_8000E138() { - return D_8011AD20[0]; + return D_8011AD20; } s8 func_8000E148() { @@ -777,13 +779,11 @@ Object **objGetObjList(s32 *arg0, s32 *cnt) { return gObjPtrList; } -// Unused? -s32 getObjectCount(void) { +UNUSED s32 getObjectCount(void) { return objCount; } -// Unused? -s32 func_8000E9C0(void) { +UNUSED s32 func_8000E9C0(void) { return D_8011AE64; } @@ -860,7 +860,7 @@ s32 func_8000FBCC(Object *arg0, Object_60 *arg1) { arg1->unk4 = NULL; objHeader = ((ObjectSegment*) arg0)->header; if (objHeader->unk32) { - arg1->unk4 = (s32 *) load_texture((s32) ((ObjectHeader *) objHeader)->unk34); + arg1->unk4 = (Object *) load_texture((s32) ((ObjectHeader *) objHeader)->unk34); objHeader = ((ObjectSegment*)arg0)->header; } ((Object_50*) arg1)->unk0 = (f32) objHeader->unk4; @@ -952,7 +952,166 @@ void gParticlePtrList_flush(void) { } GLOBAL_ASM("asm/non_matchings/objects/func_800101AC.s") + +#ifdef NON_MATCHING +//Minor regalloc diffs +void func_80010994(s32 updateRate) { + s32 i; + s32 tempVal; + Object_Racer *racer; + Object *obj; + s32 sp54; + Object_68 *obj68; + Object_64 *obj64; + + func_800245B4(-1); + gRaceStartCountdown = D_8011ADB0; + if ((D_8011ADB0 > 0) && (func_800A0190() != 0)) { + D_8011ADB0 -= updateRate; + D_8011ADBC = 0; + } else { + D_8011ADBC += updateRate; + } + if (D_8011ADB0 <= 0) { + D_8011ADB0 = 0; + } + D_8011AD3D = 0; + D_8011AD21 = 1 - D_8011AD21; + D_8011AD22[D_8011AD21] = 0; + for (i = 0; i < gNumRacers; i++) { + obj = (*gRacers)[i]; + racer = &obj->unk64->racer; + racer->prev_x_position = (f32) (*gRacers)[i]->segment.trans.x_position; + racer->prev_y_position = (f32) (*gRacers)[i]->segment.trans.y_position; + racer->prev_z_position = (f32) (*gRacers)[i]->segment.trans.z_position; + } + i = 1; //FAKEMATCH + func_800142B8(); + func_800155B8(); + func_8001E89C(); + for (i = 0; i < D_8011AE70; i++) { + run_object_loop_func(D_8011AE6C[i], updateRate); + } + func_8001E6EC(1); + for (i = 0; i < D_8011AE70; i++) { + func_8001709C(D_8011AE6C[i]); + } + tempVal = objCount; + for (i = D_8011AE60; i < tempVal; i++) { + obj = gObjPtrList[i]; + if (!(obj->segment.trans.unk6 & 0x8000)) { + if ((obj->behaviorId != BHV_LIGHT_RGBA) && (obj->behaviorId != BHV_WEAPON) && (obj->behaviorId != BHV_FOG_CHANGER)) { + if (obj->interactObj != NULL) { + if (obj->interactObj->unk11 != 2) { + run_object_loop_func(obj, updateRate); + } + } else { + run_object_loop_func(obj, updateRate); + } + if (obj->segment.header->modelType == OBJECT_MODEL_TYPE_3D_MODEL) { + for (sp54 = 0; sp54 < obj->segment.header->numberOfModelIds; sp54++) { + obj68 = obj->unk68[sp54]; + + //FAKEMATCH + if (!gObjPtrList){} + + if (obj68 != NULL) { + if (1){ } //FAKEMATCH + obj68->objModel->unk52 = updateRate; + } + } + if (obj->segment.header->unk72 != 0xFF) { + func_80014090(obj, updateRate, obj->segment.header); + } + } + } + } + } + for (i = 0; i < gNumRacers; i++) { + update_player_racer((*gRacers)[i], updateRate); + } + if (get_current_level_race_type() == 0) { + for (i = 0; i < gNumRacers; i++) { + racer = &gRacersByPosition[i]->unk64->racer; + if (racer->playerIndex != -1) { + func_80043ECC(gRacersByPosition[i], racer, updateRate); + i = gNumRacers; //Why not just break? + } + } + } + func_8000BADC(updateRate); + for (i = D_8011AE60; i < tempVal; i++) { + obj = gObjPtrList[i]; + if ((!(obj->segment.trans.unk6 & 0x8000) && (obj->behaviorId == BHV_WEAPON)) || (obj->behaviorId == BHV_FOG_CHANGER)) { + run_object_loop_func(obj, updateRate); + } + } + if (D_8011AE64 > 0) { + for (i = D_8011AE60; i < tempVal; i++) { + obj = gObjPtrList[i]; + if (obj->segment.trans.unk6 & 0x8000) { + //Why is this object being treated as a Particle2? + func_800B22FC((Particle2 *) obj, updateRate); + } + } + } + do { //FAKEMATCH + lightUpdateLights(updateRate); + if (func_80032C6C() > 0) { + for (i = D_8011AE60; i < objCount; i++) { + obj = gObjPtrList[i]; + if (!(obj->segment.trans.unk6 & 0x8000) && (obj->unk54 != NULL)) { + func_80032C7C(obj); + } + } + } + func_8001E6EC(0); + if (D_8011AEF7 != 0) { + func_80022948(); + } + if (D_8011ADAC == 0) { + gParticlePtrList_flush(); + func_80017E98(); + func_8001BC54(); + func_8001E93C(); + } + if (gNumRacers != 0) { + if (D_8011AD4E == 0) { + func_80019808(updateRate); + } else { + func_8001A8F4(updateRate); + } + } + func_80008438(gRacersByPort, gNumRacers, updateRate); + D_8011ADAC = 1; + D_8011ADA8 = (f32) updateRate; + D_8011AD24[0] = 0; + D_8011AD53 = 0; + func_8000E2B4(); + func_8009CFB0(); + func_800179D0(); + } while(0); //FAKEMATCH + if (D_8011AF00 == 1) { + if ((D_8011ADB0 == 0x50) && (D_8011AE7A == 0)) { + sp54 = 0; + for (i = 0; i < MAXCONTROLLERS; i++) { + tempVal = get_buttons_pressed_from_player(i); + sp54 |= tempVal; + } + + if (sp54 & A_BUTTON) { + func_8001E45C(100); + } else if ((sp54 & B_BUTTON) && (get_trophy_race_world_id() == 0) && (is_in_tracks_mode() == 0)) { + func_8006F140(1); //FADE_BARNDOOR_HORIZONTAL? + } + } + } else if (D_8011AF00 == 0) { + D_8011AF00 = 1; + } +} +#else GLOBAL_ASM("asm/non_matchings/objects/func_80010994.s") +#endif #ifdef NON_EQUIVALENT void func_80011134(Object *arg0, s32 arg1) { @@ -985,7 +1144,35 @@ void func_80011134(Object *arg0, s32 arg1) { GLOBAL_ASM("asm/non_matchings/objects/func_80011134.s") #endif +#ifdef NON_EQUIVALENT +//This is a function for doors +void func_80011264(ObjectModel *model, Object *obj) { + s32 temp_a2; + s32 i; + u8 textureIndex; + Object_Door *door; + + if (model->unk50 > 0) { + door = &obj->unk64->door; + temp_a2 = (door->unk10 / 10) - 1; + for (i = 0; i < model->numberOfBatches; i++) { + if (model->batches[i].flags & 0x10000) { + textureIndex = model->batches[i].textureIndex; + if (textureIndex != 0xFF) { // 0xFF = No Texture + if (model->textures[textureIndex].texture->numOfTextures > 0x900) { + model->batches[i].unk7 = (door->unk10 % 10) * 4; + } + if (!(temp_a2 & 0x20000000)) { + model->batches[i].unk7 = temp_a2 * 4; + } + } + } + } + } +} +#else GLOBAL_ASM("asm/non_matchings/objects/func_80011264.s") +#endif void func_80011390(void) { D_8011ADAC = 0; @@ -1009,7 +1196,45 @@ UNUSED s32 func_800113BC() { return D_8011ADBC; } -GLOBAL_ASM("asm/non_matchings/objects/func_800113CC.s") +s32 func_800113CC(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 evenSoundId) { + s8 *asset; + f32 shakeDist; + f32 shakeMagnitude; + s32 animFrame; + s32 asset0; + s8 nextAsset; + s32 i; + s32 ret; + s32 soundId; + + ret = 0; + if (arg1 < obj->segment.header->unk5B) { + //TODO: Figure this one out better. The index could be something like this: obj->segment.header->internalName[arg1 - 4] + asset = (s8 *) get_misc_asset(*(&obj->segment.header->unk5C + arg1)); + asset0 = asset[0]; + shakeDist = (asset[1] & 0xFF) * 8.0f; + shakeMagnitude = asset[2]; + frame >>= 4; + animFrame = obj->segment.animFrame >> 4; + for (i = 0; i < asset0; i++) { + nextAsset = asset[i+3]; + if (((animFrame >= nextAsset) && (frame < nextAsset)) || ((nextAsset >= animFrame) && (nextAsset < frame))) { + set_camera_shake_by_distance(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, shakeDist, shakeMagnitude); + if (i & 1) { + soundId = oddSoundId; //Always set to SOUND_STOMP2 + } else { + soundId = evenSoundId; //Always set to SOUND_STOMP3 + } + play_sound_at_position(soundId, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); + ret = i + 1; + i = asset0; //Come on, just use break! + } + } + } + return ret; +} s32 func_80011560(void) { //! @bug The developers probably intended this to be a void function. D_800DC848 = 1; @@ -1123,49 +1348,37 @@ void func_80011960(Object *obj, Vertex *verts, u32 numVertices, Triangle *triang func_80069A40(&gObjectCurrDisplayList); } - -#ifdef NON_EQUIVALENT -//f32 D_800E5550 = 0.01f; void func_80011AD0(Object *this) { f32 tmp_f0; - s32 offset; + Object_64 *obj64; + switch (this->behaviorId) { - case 47: - //L80011B10 + case BHV_CHARACTER_FLAG: if (this->unk7C.word >= 0) { - func_80011960(this, this->unk64->obj80011AD0.unk20, 4, this->unk64, - 2, this->unk64->obj80011AD0.unk24, 11, 0, 1.0f); + obj64 = this->unk64; + func_80011960(this, obj64->character_flag.vertices, 4, obj64->character_flag.triangles, + 2, obj64->character_flag.texture, 11, 0, 1.0f); } break; - - case 61: - //L80011B58 - offset = (this->unk64->obj80011AD0.unkFC * 6); - offset *= 5; - offset *= 2; - offset += 128; - func_80011960(this, offset, 6, this->unk64, 8, this->unk64->obj80011AD0.unkF8, 10, 0, 1.0f); + case BHV_BUTTERFLY: + obj64 = this->unk64; + func_80011960(this, &obj64->butterfly.vertices[obj64->butterfly.unkFC * 6], 6, obj64->butterfly.triangles, 8, obj64->butterfly.texture, 10, 0, 1.0f); break; - case 3: //L80011BB4 - tmp_f0 = this->segment.unk3C_a.level_entry->unk80011AD0.unkD; - offset = (this->unk64->obj80011AD0.unkFC * 6); - offset *= 5; - offset *= 2; - offset += 128; - func_80011960(this, offset, 6, this->unk64, 8, this->unk64->obj80011AD0.unkF8, 26, 0, tmp_f0 * 0.01f); + case BHV_FISH: + obj64 = this->unk64; + tmp_f0 = this->segment.unk3C_a.level_entry->fish.unkC[1]; + tmp_f0 *= 0.01f; + func_80011960(this, &obj64->fish.vertices[obj64->fish.unkFC * 6], 6, obj64->fish.triangles, 8, obj64->fish.texture, 26, 0, tmp_f0); break; - case 89: //L80011C38 - if ((this->unk78 != 0) && (this->unk64->obj80011AD0.unk70 > 0 || this->unk64->obj80011AD0.unk74 > 0.0f)) { + case BHV_BOOST: + if ((this->unk78 != 0) && ((this->unk64->boost.unk70 > 0) || (this->unk64->boost.unk74 > 0.0f))) { func_800135B8(this); } break; - } //L80011C88 + } } -#else -GLOBAL_ASM("asm/non_matchings/objects/func_80011AD0.s") -#endif /** * Render an object as a billboard. @@ -1185,7 +1398,7 @@ void render_3d_billboard(Object *obj) { intensity = 255; hasPrimCol = FALSE; hasEnvCol = FALSE; - flags = obj->segment.trans.unk6 | 0x100 | 0x8; + flags = obj->segment.trans.unk6 | RENDER_Z_UPDATE | RENDER_FOG_ACTIVE; if (obj->unk54 != NULL) { hasPrimCol = TRUE; hasEnvCol = TRUE; @@ -1244,7 +1457,7 @@ void render_3d_billboard(Object *obj) { } // 5 = OilSlick, SmokeCloud, Bomb, BubbleWeapon - if(var_a0 != NULL || !(obj->behaviorId != BHV_WEAPON || obj->unk64->weapon.weaponID != WEAOON_BUBBLE_TRAP)) { + if(var_a0 != NULL || !(obj->behaviorId != BHV_WEAPON || obj->unk64->weapon.weaponID != WEAPON_BUBBLE_TRAP)) { sp60.trans.z_rotation = 0; sp60.trans.x_rotation = 0; sp60.trans.y_rotation = 0; @@ -1260,9 +1473,10 @@ void render_3d_billboard(Object *obj) { var_a0 = obj; } } - func_800138A8(var_a0, sp58, &sp60, 0x106); + func_800138A8(&var_a0->segment.trans, sp58, (Object *) &sp60, + RENDER_Z_COMPARE | RENDER_SEMI_TRANSPARENT | RENDER_Z_UPDATE); } else { - render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, (Vertex **) &gObjectCurrVertexList, obj, sp58, flags); + render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, obj, sp58, flags); } if (hasPrimCol) { gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); @@ -1272,8 +1486,230 @@ void render_3d_billboard(Object *obj) { } } +#ifdef NON_EQUIVALENT +void render_3d_model(Object *obj) { + s32 intensity; + s32 spB0; + s32 obj60_unk0; + s32 hasPrimCol; + s32 hasEnvCol; + ObjectModel *objModel; + Object *loopObj; + Object *heldObj; + Object_64 *obj64; + Object_68 *obj68; + Vertex *temp_v0_14; + f32 posX; + f32 posZ; + f32 posY; + s32 cicFailed; + s32 var_t1; + s32 billboardFlags; + s32 i; + s32 var_v0; + s8 index; + s8 var_t0_2; + s32 var_v0_2; + s32 alpha; + unk80068514_arg4 *temp_t4; + obj68 = obj->unk68[obj->segment.unk38.byte.unk3A]; + if (obj68 != NULL) { + hasPrimCol = FALSE; + hasEnvCol = FALSE; + intensity = 255; + objModel = obj68->objModel; + if (obj->unk54 != NULL) { + hasPrimCol = TRUE; + hasEnvCol = TRUE; + intensity = (s32) (obj->unk54->unk0 * 255.0f * D_8011AD30); + } + if (obj->behaviorId == BHV_RACER) { + obj64 = obj->unk64; + func_80012E28(obj); + } else { + obj64 = NULL; + } + if (obj68->unk20 <= 0) { + obj->unk44 = (Vertex *) obj68->unk4[obj68->unk1F]; + if (obj68->unk1E == 2) { + func_80061D30(obj); + } + if ((obj68->unk1E != 0) && (objModel->unk40 != NULL)) { + var_t1 = TRUE; + if (obj64 != NULL && obj64->racer.vehicleID < VEHICLE_TRICKY && obj64->racer.playerIndex == PLAYER_COMPUTER) { + var_t1 = FALSE; + } + if (get_viewport_count() != VIEWPORTS_COUNT_1_PLAYER) { + var_t1 = FALSE; + } + if (obj->behaviorId == BHV_UNK_3F) { + calc_dyn_light_and_env_map_for_object(objModel, obj, 0, D_8011AD30); + } else if (var_t1) { + calc_dyn_light_and_env_map_for_object(objModel, obj, -1, D_8011AD30); + } else { + func_800245F0(objModel, obj, D_8011AD30); + } + } + if ((obj64 != NULL) && (obj64->racer.playerIndex == PLAYER_COMPUTER) && (obj64->racer.vehicleID < VEHICLE_TRICKY)) { + obj68->unk20 = 2; + } else { + obj68->unk20 = 1; + } + } + obj->unk44 = (Vertex *) obj68->unk4[obj68->unk1F]; + if (obj->behaviorId == BHV_DOOR) { + func_80011264(objModel, obj); + } + if ((objModel->unk52 != 0) && (objModel->unk50 > 0)) { + func_80011134(obj, (s32) objModel->unk52); + obj68->objModel->unk52 = 0; + } + func_80069484(&gObjectCurrDisplayList, &gObjectCurrMatrix, &obj->segment.trans, D_8011AD28, 0.0f); + spB0 = 0; + if (obj64 != NULL) { + objUndoPlayerTumble(obj); + if ((obj->segment.unk38.byte.unk3B == 0) || (obj64->racer.vehicleID >= VEHICLE_TRICKY)) { + func_80069790(&gObjectCurrDisplayList, &gObjectCurrMatrix, obj68, obj64->racer.headAngle); + spB0 = 1; + } else { + obj64->racer.headAngle = 0; + } + } + alpha = obj->segment.unk38.byte.unk39; + if (alpha > 255) { + alpha = 255; + } + // If the behavior is a water zipper, then halve it's transparency. + if (obj->behaviorId == BHV_ZIPPER_WATER) { + alpha >>= 1; + } + if (alpha < 255) { + hasPrimCol = TRUE; + } + if (hasEnvCol) { + gDPSetEnvColor(gObjectCurrDisplayList++, obj->unk54->unk4, obj->unk54->unk5, obj->unk54->unk6, obj->unk54->unk7); + } else { + gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 255, 0); + } + if (obj->segment.header->unk71 != 0) { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, obj->unk54->unk18, obj->unk54->unk19, obj->unk54->unk1A, alpha); + func_8007B43C(); + } else if (hasPrimCol) { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, intensity, intensity, intensity, alpha); + } else { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); + } + if (alpha < 255) { + var_v0 = func_800143A8(objModel, obj, 0, 4, spB0); + } else { + var_v0 = func_800143A8(objModel, obj, 0, 0, spB0); + } + if (obj->segment.header->unk71 != 0) { + if (hasPrimCol) { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, intensity, intensity, intensity, alpha); + } else { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); + } + func_8007B454(); + } + if (obj->unk60 != NULL) { + obj60_unk0 = obj->unk60->unk0; + if (obj64 != NULL && (obj64->racer.vehicleID == VEHICLE_FLYING_CAR)) { + obj60_unk0 = 0; + } + for (i = 0; i < obj60_unk0; i++) { + //This line right here breaks this function. Loading unk60 as an array is broken. + loopObj = obj->unk60[i].unk4; + if (!(loopObj->segment.trans.unk6 & 0x4000)) { + index = obj->unk60->unk2C[i]; + if ((index >= 0) && (index < objModel->unk18)) { + temp_t4 = (unk80068514_arg4 *) loopObj->unk68[loopObj->segment.unk38.byte.unk3A]; + posX = obj->unk44[objModel->unk14[index]].x; + posY = obj->unk44[objModel->unk14[index]].y; + posZ = obj->unk44[objModel->unk14[index]].z; + loopObj->segment.trans.x_position += posX; + loopObj->segment.trans.y_position += posY; + loopObj->segment.trans.z_position += posZ; + if (loopObj->segment.header->modelType == OBJECT_MODEL_TYPE_SPRITE_BILLBOARD) { + billboardFlags = (RENDER_Z_COMPARE | RENDER_FOG_ACTIVE | RENDER_Z_UPDATE); + } else { + billboardFlags = (RENDER_Z_COMPARE | RENDER_FOG_ACTIVE | RENDER_Z_UPDATE | RENDER_ANTI_ALIASING); + } + if (alpha < 255) { + billboardFlags |= RENDER_SEMI_TRANSPARENT; + } + cicFailed = FALSE; + //Anti-Piracy check + if (osCicId != CIC_ID) { + cicFailed = TRUE; + } + if (!cicFailed) { + var_v0_2 = (loopObj->segment.trans.unk6 & 0x80) != 0; + if (var_v0_2) { + var_v0_2 = obj60_unk0 == 3; + } + var_t0_2 = var_v0_2; + if ((obj64 != NULL) && (obj64->racer.transparency < 255)) { + var_t0_2 = FALSE; + } + if (var_t0_2) { + func_80012C98(&gObjectCurrDisplayList); + gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 255, 0); + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, intensity, intensity, intensity, alpha); + } + loopObj->unk78 = render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, loopObj, temp_t4, billboardFlags); + if (var_t0_2) { + gDkrInsertMatrix(gObjectCurrDisplayList++, 0, 0); + func_80012CE8(&gObjectCurrDisplayList); + } + } + loopObj->segment.trans.x_position -= posX; + loopObj->segment.trans.y_position -= posY; + loopObj->segment.trans.z_position -= posZ; + } + } + } + } + if (obj64 != NULL) { + heldObj = obj64->racer.held_obj; + if (heldObj != NULL) { + if ((obj->segment.header->unk58 >= 0) && (obj->segment.header->unk58 < objModel->unk18)) { + billboardFlags = (RENDER_Z_COMPARE | RENDER_FOG_ACTIVE | RENDER_Z_UPDATE); + temp_t4 = (unk80068514_arg4 *) heldObj->unk68[heldObj->segment.unk38.byte.unk3A]; + temp_v0_14 = &obj->unk44[objModel->unk14[obj->segment.header->unk58]]; + heldObj->segment.trans.x_position += (temp_v0_14->x - heldObj->segment.trans.x_position) * 0.25; + heldObj->segment.trans.y_position += (temp_v0_14->y - heldObj->segment.trans.y_position) * 0.25; + heldObj->segment.trans.z_position += (temp_v0_14->z - heldObj->segment.trans.z_position) * 0.25; + if (heldObj->segment.header->modelType == OBJECT_MODEL_TYPE_SPRITE_BILLBOARD) { + render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, heldObj, + temp_t4, billboardFlags); + } + } + } + } + if (var_v0 != -1) { + if (obj->segment.header->unk71 != 0) { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, obj->unk54->unk18, obj->unk54->unk19, obj->unk54->unk1A, alpha); + func_8007B43C(); + } + func_800143A8(objModel, obj, var_v0, 4, spB0); + if (obj->segment.header->unk71 != 0) { + func_8007B454(); + } + } + if ((hasPrimCol) || (obj->segment.header->unk71 != 0)) { + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); + } + if (hasEnvCol) { + gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 255, 0); + } + func_80069A40(&gObjectCurrDisplayList); + } +} +#else GLOBAL_ASM("asm/non_matchings/objects/render_3d_model.s") +#endif void func_80012C30(void) { D_8011ADA4 = 0; @@ -1386,7 +1822,34 @@ void func_80013548(Object *obj) { } GLOBAL_ASM("asm/non_matchings/objects/func_800135B8.s") -GLOBAL_ASM("asm/non_matchings/objects/func_800138A8.s") + +void func_800138A8(ObjectTransform *trans, unk80068514_arg4 *arg1, Object *obj, s32 flags) { + f32 x; + f32 y; + f32 z; + ObjectSegment *cameraSegment; + f32 posSq; + + f32_vec3_apply_object_rotation(trans, &obj->segment.trans.x_position); + obj->segment.trans.x_position += trans->x_position; + obj->segment.trans.y_position += trans->y_position; + obj->segment.trans.z_position += trans->z_position; + cameraSegment = get_active_camera_segment(); + x = cameraSegment->trans.x_position - obj->segment.trans.x_position; + y = cameraSegment->trans.y_position - obj->segment.trans.y_position; + z = cameraSegment->trans.z_position - obj->segment.trans.z_position; + posSq = sqrtf((x * x) + (y * y ) + (z * z)); + if (posSq > 0.0) { + posSq = obj->segment.unk1A / posSq; + x *= posSq; + y *= posSq; + z *= posSq; + } + obj->segment.trans.x_position += x; + obj->segment.trans.y_position += y; + obj->segment.trans.z_position += z; + render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, obj, arg1, flags); +} /** * Get the racer object data, and fetch set visual shield properties based on that racer. @@ -1548,7 +2011,92 @@ GLOBAL_ASM("asm/non_matchings/objects/func_800143A8.s") GLOBAL_ASM("asm/non_matchings/objects/func_80014814.s") GLOBAL_ASM("asm/non_matchings/objects/func_80014B50.s") GLOBAL_ASM("asm/non_matchings/objects/func_80015348.s") -GLOBAL_ASM("asm/non_matchings/objects/func_800155B8.s") + +void func_800155B8(void) { + Object *obj2; + Object *obj; + ObjectInteraction *objInteract; + ObjectInteraction *objInteract2; + f32 xDiff; + f32 zDiff; + f32 var_f12; + s32 j; + s32 i; + s32 objsWithInteractives; + Object *objList[257]; //257 seems random, but it works for now. + + objsWithInteractives = 0; + for (i = D_8011AE60; i < objCount; i++) { + obj = gObjPtrList[i]; + if (!(obj->segment.trans.unk6 & 0x8000)) { + objInteract = obj->interactObj; + if (objInteract != NULL) { + objList[objsWithInteractives] = obj; + objsWithInteractives++; + if (objInteract->unk11 != 2) { + objInteract->obj = NULL; + objInteract->unk14 &= ~0x48; + objInteract->distance = 0xFF; + } + } + } + } + + D_8011AE70 = 0; + + for (i = 0; i < objsWithInteractives; i++) { + obj = objList[i]; + objInteract = obj->interactObj; + if ((objInteract->unk11 == 2) && (D_8011AE70 < 20)) { + D_8011AE6C[D_8011AE70] = obj; + D_8011AE70++; + } + if (objInteract->unk14 & 4) { + for (j = 0; j < objsWithInteractives; j++) { + if (i != j) { + obj2 = objList[j]; + objInteract2 = obj2->interactObj; + if (objInteract2->unk14 & 3) { + if (objInteract2->unk11 == 3) { + func_80016748(obj, obj2); + } else if (objInteract2->unk11 != 2) { + xDiff = obj->segment.trans.x_position - obj2->segment.trans.x_position; + zDiff = obj->segment.trans.z_position - obj2->segment.trans.z_position; + if (objInteract2->unk14 & 0x20) { + var_f12 = 0x400000; //4194304.0f; + } else { + var_f12 = 0x40000; //262144.0f; + } + if (((xDiff * xDiff) + (zDiff * zDiff)) < var_f12) { + func_800159C8(obj, obj2); + } + } + } + } + } + } + if (objInteract->unk14 & 0x100) { + for (j = 0; j < objsWithInteractives; j++) { + if (i != j) { + obj2 = objList[j]; + objInteract2 = obj2->interactObj; + if (objInteract2->unk11 == 3) { + func_80016748(obj, obj2); + } + } + } + } + } + + for (i = 0; i < objsWithInteractives; i++) { + obj = objList[i]; + objInteract = obj->interactObj; + objInteract->x_position = obj->segment.trans.x_position; + objInteract->y_position = obj->segment.trans.y_position; + objInteract->z_position = obj->segment.trans.z_position; + } +} + GLOBAL_ASM("asm/non_matchings/objects/func_800159C8.s") GLOBAL_ASM("asm/non_matchings/objects/func_80016500.s") GLOBAL_ASM("asm/non_matchings/objects/func_80016748.s") @@ -2019,16 +2567,101 @@ UNUSED void debug_render_checkpoints(Gfx **dlist, MatrixS **mtx, Vertex **vtx) { UNUSED void debug_render_checkpoint_node(UNUSED s32 checkpointID, UNUSED s32 pathID, UNUSED Gfx **dList, UNUSED MatrixS **mtx, UNUSED Vertex **vtx) { } -GLOBAL_ASM("asm/non_matchings/objects/func_8001BC54.s") +void func_8001BC54(void) { + Object *objPtr; + Object *temp; + s32 continueLoop; + s32 i; -u32 objGetObject(s32 arg0) { - if (arg0 < 0 || arg0 >= D_8011AEE0) { - return 0; + gCameraObjCount = 0; + for (i = 0; i < objCount; i++) { + objPtr = gObjPtrList[i]; + if (!(objPtr->segment.trans.unk6 & 0x8000)) { + if (objPtr->behaviorId == BHV_CAMERA_CONTROL) { + if (gCameraObjCount < 20) { + (*gCameraObjList)[gCameraObjCount] = objPtr; + gCameraObjCount++; + } + } + } } - return D_8011AEDC[0][arg0]; + + do { + continueLoop = TRUE; + for (i = 0; i < gCameraObjCount - 1; i++) { + objPtr = (*gCameraObjList)[i+1]; + temp = (*gCameraObjList)[i]; + if (temp->unk78 > objPtr->unk78) { + (*gCameraObjList)[i] = (*gCameraObjList)[i+1]; + (*gCameraObjList)[i+1] = temp; + continueLoop = FALSE; + } + } + } while (!continueLoop); +} + +Object *get_camera_object(s32 cameraIndex) { + if (cameraIndex < 0 || cameraIndex >= gCameraObjCount) { + return NULL; + } + return (*gCameraObjList)[cameraIndex]; +} + +Object *func_8001BDD4(Object *obj, s32 *cameraId) { + Object *nextCamera; + Object *prevCamera; + Object *currCamera; + s32 *cameraIndex; + f32 x; + f32 y; + f32 z; + f32 prevCameraXYZ; + f32 currCameraXYZ; + f32 nextCameraXYZ; + s32 cameraIndex_Curr; + s32 cameraIndex_Prev; + s32 cameraIndex_Next; + cameraIndex = cameraId; + if (gCameraObjCount == 0) { + return NULL; + } + cameraIndex_Next = *cameraIndex + 1; + cameraIndex_Curr = *cameraIndex; + cameraIndex_Prev = *cameraIndex - 1; + if (cameraIndex_Next >= gCameraObjCount) { + cameraIndex_Next = 0; + } + if (cameraIndex_Prev < 0) { + cameraIndex_Prev = gCameraObjCount - 1; + } + currCamera = (*gCameraObjList)[cameraIndex_Curr]; + nextCamera = (*gCameraObjList)[cameraIndex_Next]; + prevCamera = (*gCameraObjList)[cameraIndex_Prev]; + x = currCamera->segment.trans.x_position - obj->segment.trans.x_position; + y = currCamera->segment.trans.y_position - obj->segment.trans.y_position; + z = currCamera->segment.trans.z_position - obj->segment.trans.z_position; + currCameraXYZ = (x * x) + (y * y) + (z * z); + x = nextCamera->segment.trans.x_position - obj->segment.trans.x_position; + y = nextCamera->segment.trans.y_position - obj->segment.trans.y_position; + z = nextCamera->segment.trans.z_position - obj->segment.trans.z_position; + nextCameraXYZ = (x * x) + (y * y) + (z * z); + x = prevCamera->segment.trans.x_position - obj->segment.trans.x_position; + y = prevCamera->segment.trans.y_position - obj->segment.trans.y_position; + z = prevCamera->segment.trans.z_position - obj->segment.trans.z_position; + prevCameraXYZ = (x * x) + (y * y) + (z * z); + + if (nextCameraXYZ < currCameraXYZ) { + *cameraId = cameraIndex_Next; + currCamera = nextCamera; + currCameraXYZ = nextCameraXYZ; + } + if (prevCameraXYZ < currCameraXYZ) { + *cameraId = cameraIndex_Prev; + currCamera = prevCamera; + } + return currCamera; } -GLOBAL_ASM("asm/non_matchings/objects/func_8001BDD4.s") GLOBAL_ASM("asm/non_matchings/objects/func_8001BF20.s") s16 func_8001C418(f32 yPos) { @@ -2189,7 +2822,30 @@ void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s GLOBAL_ASM("asm/non_matchings/objects/calc_dynamic_lighting_for_object_1.s") GLOBAL_ASM("asm/non_matchings/objects/calc_env_mapping_for_object.s") -GLOBAL_ASM("asm/non_matchings/objects/func_8001E13C.s") + +UNUSED void func_8001E13C(s16 arg0, s16 *arg1, s16 *arg2, s16 *arg3, s16 *arg4, s16 *arg5, s16 *arg6) { + Object *obj; + Object_Racer *racer; + s32 i; + + for (i = 0; i < objCount; i++) { + obj = gObjPtrList[i]; + if (!(obj->segment.trans.unk6 & 0x8000)) { + if (obj->behaviorId == BHV_RACER) { + racer = &obj->unk64->racer; + if (arg0 == racer->playerIndex) { + *arg1 = obj->segment.trans.x_position; + *arg2 = obj->segment.trans.y_position; + *arg3 = obj->segment.trans.z_position; + *arg4 = obj->segment.trans.z_rotation; + *arg5 = obj->segment.trans.x_rotation; + *arg6 = obj->segment.trans.y_rotation; + i = objCount; //Feels like it should be a break instead. + } + } + } + } +} /** * Returns a pointer to the asset in the misc. section. If index is out of range, then this @@ -2333,7 +2989,7 @@ void func_80021400(s32 arg0) { } s8 func_800214C4(void) { - return D_8011AD22[1 - D_8011AD20[1]]; + return D_8011AD22[1 - D_8011AD21]; } s8 func_800214E4(Object *obj, s32 updateRate) { diff --git a/src/objects.h b/src/objects.h index 2d25518b..6344384e 100644 --- a/src/objects.h +++ b/src/objects.h @@ -57,7 +57,7 @@ enum ObjectBehaviours { BHV_COLLECT_EGG, BHV_EGG_CREATOR, BHV_CHARACTER_FLAG, - BHV_UNK_2F, + BHV_UNK_30, BHV_ANIMATION, BHV_ANIMATED_OBJECT, BHV_CAMERA_ANIMATION, @@ -278,6 +278,9 @@ typedef struct unk8001A7D8_arg0 { u8 unk49; } unk8001A7D8_arg0; +#define CIC_ID 6103 +extern s32 osCicId; // Used for an Anti-Piracy check in render_3d_model + Object *func_8000BF44(s32 arg0); void allocate_object_pools(void); void func_8000C460(void); @@ -345,7 +348,7 @@ Object **get_racer_objects_by_port(s32 *numRacers); Object **get_racer_objects_by_position(s32 *numRacers); Object *get_racer_object(s32 index); void debug_render_checkpoint_node(s32 checkpointID, s32 pathID, Gfx** dList, MatrixS **mtx, Vertex **vtx); -u32 objGetObject(s32 arg0); +Object *get_camera_object(s32 cameraIndex); void func_8001D1AC(void); void func_8001D1BC(s32 arg0); Object *func_8001D1E4(s32 *arg0); @@ -404,13 +407,15 @@ s32 func_8000FD34(Object *arg0, Object_5C *arg1); void func_8000E4E8(s32 index); void objFreeAssets(Object *obj, s32 count, s32 objType); void func_8001709C(Object *obj); +s32 func_800113CC(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 evenSoundId); +void func_80011AD0(Object *this); +Object *func_8001BDD4(Object *obj, s32 *cameraID); //Non Matching void calc_dynamic_lighting_for_object_1(Object *, ObjectModel *, s16, Object *, f32, f32); void calc_dynamic_lighting_for_object_2(Object *, ObjectModel *, s16, f32); void gParticlePtrList_flush(void); void decrypt_magic_codes(s32 *arg0, s32 length); -void func_80011AD0(Object *this); s32 func_80014814(s32 *); void func_80015348(s32, s32); Object *spawn_object(void *entry, s32); @@ -422,16 +427,13 @@ void func_80022E18(s32); /* extern */ void func_80018CE0(Object* obj, f32 xPos, f32 yPos, f32 zPos, s32 updateRate); /* extern */ s32 func_800185E4(s8, Object* obj, f32 xPos, f32 yPos, f32 zPos, f32* checkpointDistance, u8*); /* extern */ void func_80011134(Object *, s32); -void func_800113CC(Object *, s32, s32, s32, s32); s32 func_800143A8(ObjectModel*, Object*, s32, s32, s32); /* extern */ -void func_80068FA8(Gfx**, MatrixS**, Object*, Object*, f32); /* extern */ -void func_800138A8(Object*, unk80068514_arg4*, ObjectTransformExt *, s32); +void func_800138A8(ObjectTransform*, unk80068514_arg4*, Object *, s32); Object *func_8002342C(f32 x, f32 z); void func_8006017C(s32); void func_80012F94(Object *); void render_3d_model(Object *); void func_800101AC(Object *, s32); -Object *func_8001BDD4(Object *obj, s32 *cameraID); void func_800135B8(Object *); void func_8000CC7C(Vehicle, u32, s32); void func_8000B020(s32, s32); @@ -450,5 +452,10 @@ void func_800155B8(void); void func_800230D0(Object*, Object_Racer*); s32 func_8001955C(Object*, s8, u8, s16, s32, f32, f32*, f32*, f32*); void func_80010994(s32 updateRate); +void func_800159C8(Object *, Object *); +void func_80016748(Object *, Object *); +void func_80011264(ObjectModel *, Object *); +void func_800245F0(ObjectModel *, Object *, f32); //asm func in unknown_0251F0 +void func_80061D30(Object *); //asm func in unknown_062930 #endif diff --git a/src/racer.c b/src/racer.c index b495e567..eb951ee9 100644 --- a/src/racer.c +++ b/src/racer.c @@ -547,7 +547,7 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate) { GLOBAL_ASM("asm/non_matchings/racer/func_80042D20.s") #endif -void func_80043ECC(s32 arg0, Object_Racer *racer, s32 updateRate) { +void func_80043ECC(Object *obj, Object_Racer *racer, s32 updateRate) { TempStruct5 *temp_v0; s8 *test; s8 phi_a0; @@ -556,7 +556,7 @@ void func_80043ECC(s32 arg0, Object_Racer *racer, s32 updateRate) { static s8 D_8011D5BB; static s8 D_8011D5BC; - if (!arg0) { + if (!obj) { D_8011D5BA = 0; D_8011D5BB = 0; D_8011D5BC = 0; @@ -2184,7 +2184,7 @@ void obj_init_racer(Object *obj, LevelObjectEntry_CharacterFlag *racer) { D_8011D58C[i] = 0; } if (1) {} if (1) {} // Fakematch - func_80043ECC(0, NULL, 0); + func_80043ECC(NULL, NULL, 0); D_8011D583 = i; gStartBoostTime = 0; tempRacer->lightFlags = 0; @@ -2330,8 +2330,8 @@ void update_player_racer(Object *obj, s32 updateRate) { tempRacer->unk84 -= tempRacer->unk84 * 0.0625 * updateRateF; tempRacer->unk88 -= tempRacer->unk88 * 0.0625 * updateRateF; } - gCurrentRacerMiscAssetPtr = (f32*) get_misc_asset(obj->segment.header->pad5B[1]); - D_8011D568 = (f32 *) get_misc_asset(obj->segment.header->pad5B[2]); + gCurrentRacerMiscAssetPtr = (f32*) get_misc_asset(obj->segment.header->unk5C); + D_8011D568 = (f32 *) get_misc_asset(obj->segment.header->unk5D); if (obj->segment.y_velocity < 4.0 && (tempRacer->unk1E2 >= 3 || tempRacer->buoyancy != 0.0)) { tempRacer->unk1F1 = 0; @@ -4457,7 +4457,7 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) objDist = 10.0f; velocity = -2.0f; break; - case WEAOON_BUBBLE_TRAP: + case WEAPON_BUBBLE_TRAP: objDist = 10.0f; velocity = -2.0f; objID = 46; @@ -4589,7 +4589,7 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) } soundID = SOUND_SPLOINK2; break; - case WEAOON_BUBBLE_TRAP: + case WEAPON_BUBBLE_TRAP: soundID = SOUND_PLOP; break; case WEAPON_UNK_11: diff --git a/src/racer.h b/src/racer.h index 88e67cd4..2cd88855 100644 --- a/src/racer.h +++ b/src/racer.h @@ -85,7 +85,7 @@ typedef enum WeaponType { WEAPON_MAGNET_LEVEL_2, WEAPON_NITRO_LEVEL_2, WEAPON_UNK_09, - WEAOON_BUBBLE_TRAP, + WEAPON_BUBBLE_TRAP, WEAPON_UNK_11, WEAPON_SHIELD_LEVEL_1, WEAPON_SHIELD_LEVEL_2, @@ -195,7 +195,7 @@ void handle_racer_head_turning(Object *obj, Object_Racer *racer, s32 updateRate) void racer_approach_object(Object *obj, Object_Racer *racer, f32 divisor); void obj_init_racer(Object *obj, LevelObjectEntry_CharacterFlag *racer); void racer_AI_pathing_inputs(Object *obj, Object_Racer *racer, s32 updateRate); -void func_80043ECC(s32 arg0, Object_Racer *racer, s32 updateRate); +void func_80043ECC(Object *obj, Object_Racer *racer, s32 updateRate); void func_80055A84(Object *obj, Object_Racer *racer, s32 updateRate); void update_player_camera(Object *obj, Object_Racer *racer, f32 updateRate); void racer_spinout_car(Object* obj, Object_Racer* racer, s32 updateRate, f32 updateRateF); diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 53a1737c..b062c5b8 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -159,8 +159,9 @@ void func_800B7460(s32 *epc, s32 size, s32 mask) { s16 *v0; s32 i; - if ((get_filtered_cheats() << 4) < 0) { // This is checking if the EPC cheat is active - bzero(&sp840, 0x1B0); + // This is checking if the EPC cheat is active + if (get_filtered_cheats() & CHEAT_EPC_LOCK_UP_DISPLAY) { + bzero(&sp840, sizeof(epcInfo)); sp840.a0 = size; sp840.a1 = mask; sp840.epc = epc; @@ -168,7 +169,7 @@ void func_800B7460(s32 *epc, s32 size, s32 mask) { sp840.unk130[0] = D_80129FB0[0]; sp840.unk130[1] = D_80129FB0[1]; sp840.unk130[2] = D_80129FB0[2]; - bcopy(&sp840, &sp40, 0x1B0); + bcopy(&sp840, &sp40, sizeof(epcInfo)); bzero(&sp240, 0x200); v0 = func_80024594(&sp38, &size); for (i = 0; i < size; i++) { diff --git a/src/unknown_0255E0.c b/src/unknown_0255E0.c index d6267173..cf1b6c4b 100644 --- a/src/unknown_0255E0.c +++ b/src/unknown_0255E0.c @@ -37,14 +37,10 @@ f32 D_800DC884[10] = { 0.0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f }; -f32 D_800DC8AC[27] = { - 50.0f, 0.0f, 32.0f, -50.0f, - 0.0f, 32.0f, -50.0f, 100.0f, - 32.0f, 0.0f, 0.0f, 32.0f, - 130.0f, 60.0f, -68.0f, 130.0f, - -60.0f, -68.0f, 0.0f, 0.0f, - 32.0f, -130.0f, -60.0f, -68.0f, - -130.0f, 60.0f, -68.0f, +Vec3f D_800DC8AC[3][3] = { + { {{{ 50.0f, 0.0f, 32.0f }}}, {{{ -50.0f, 0.0f, 32.0f }}}, {{{ -50.0f, 100.0f, 32.0f }}} }, + { {{{ 0.0f, 0.0f, 32.0f }}}, {{{ 130.0f, 60.0f, -68.0f }}}, {{{ 130.0f, -60.0f, -68.0f }}} }, + { {{{ 0.0f, 0.0f, 32.0f }}}, {{{ -130.0f, -60.0f, -68.0f }}}, {{{ -130.0f, 60.0f, -68.0f }}} }, }; LevelModel *gCurrentLevelModel = NULL; @@ -132,8 +128,8 @@ s32 D_8011D0E8; s32 D_8011D0EC; s32 D_8011D0F0; s32 D_8011D0F4; -unk8011D0F8 D_8011D0F8[3]; -unk8011D0F8 D_8011D128[3]; +Vec4f D_8011D0F8[3]; +Vec4f D_8011D128[3]; s32 D_8011D158[3]; // Unused? Or part of something bigger above? s32 D_8011D164; s32 D_8011D168[84]; @@ -1153,7 +1149,64 @@ LevelModelSegmentBoundingBox *get_segment_bounding_box(s32 segmentID) { return &gCurrentLevelModel->segmentsBoundingBoxes[segmentID]; } -GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002A31C.s") +void func_8002A31C(void) { + f32 ox1; + f32 oy1; + f32 oz1; + f32 ox2; + f32 oy2; + f32 oz2; + f32 ox3; + f32 oy3; + f32 oz3; + Matrix *cameraMatrix; + f32 inverseMagnitude; + f32 x; + f32 y; + f32 z; + s32 i; + f32 w; + + cameraMatrix = func_80069DA4(); + for (i = 0; i < ARRAY_COUNT(D_8011D0F8);) { + x = D_800DC8AC[i][0].x; + y = D_800DC8AC[i][0].y; + z = D_800DC8AC[i][0].z; + ox1 = x; + oy1 = y; + oz1 = z; + guMtxXFMF(*cameraMatrix, x, y, z, &ox1, &oy1, &oz1); + x = D_800DC8AC[i][1].x; + y = D_800DC8AC[i][1].y; + z = D_800DC8AC[i][1].z; + ox2 = x; + oy2 = y; + oz2 = z; + guMtxXFMF(*cameraMatrix, x, y, z, &ox2, &oy2, &oz2); + x = D_800DC8AC[i][2].x; + y = D_800DC8AC[i][2].y; + z = D_800DC8AC[i][2].z; + ox3 = x; + oy3 = y; + oz3 = z; + guMtxXFMF(*cameraMatrix, x, y, z, &ox3, &oy3, &oz3); + x = ((oz2 - oz3) * oy1) + (oy2 * (oz3 - oz1)) + (oy3 * (oz1 - oz2)); + y = ((ox2 - ox3) * oz1) + (oz2 * (ox3 - ox1)) + (oz3 * (ox1 - ox2)); + z = ((oy2 - oy3) * ox1) + (ox2 * (oy3 - oy1)) + (ox3 * (oy1 - oy2)); + inverseMagnitude = (1.0 / sqrtf((x * x) + (y * y) + (z * z))); + if (inverseMagnitude > 0.0) { + x *= inverseMagnitude; + y *= inverseMagnitude; + z *= inverseMagnitude; + } + w = -((ox1 * x) + (oy1 * y) + (oz1 * z)); + D_8011D0F8[i].x = x; + D_8011D0F8[i].y = y; + D_8011D0F8[i].z = z; + D_8011D0F8[i].w = w; + i++; + } +} /** * Takes a normalised (0-1) face direction of the active camera, then adds together a magnitude @@ -1169,10 +1222,10 @@ s32 should_segment_be_visible(LevelModelSegmentBoundingBox *bb) { f32 x, y, z; for (j = 0; j < 3; j++) { - dirX = D_8011D0F8[j].unk0; - dirY = D_8011D0F8[j].unk4; - dirZ = D_8011D0F8[j].unk8; - dirW = D_8011D0F8[j].unkC; + dirX = D_8011D0F8[j].x; + dirY = D_8011D0F8[j].y; + dirZ = D_8011D0F8[j].z; + dirW = D_8011D0F8[j].w; for (i = 0, isVisible = FALSE; i < 8 && !isVisible; i++) { if (i & 1) { @@ -1286,10 +1339,10 @@ s32 check_if_in_draw_range(Object *obj) { break; } for (i = 0; i < 3; i++) { - x = D_8011D0F8[i].unk0; - z = D_8011D0F8[i].unk8; - w = D_8011D0F8[i].unkC; - y = D_8011D0F8[i].unk4; + x = D_8011D0F8[i].x; + z = D_8011D0F8[i].z; + w = D_8011D0F8[i].w; + y = D_8011D0F8[i].y; accum = (x * obj->segment.trans.x_position) + (y * obj->segment.trans.y_position) + (z * obj->segment.trans.z_position) + w + obj->segment.unk34_a.unk34; if (accum < 0.0f) { return FALSE; diff --git a/src/unknown_0255E0.h b/src/unknown_0255E0.h index 2c8e6214..24df0696 100644 --- a/src/unknown_0255E0.h +++ b/src/unknown_0255E0.h @@ -55,14 +55,6 @@ typedef struct unknown800DC874 { s16 unk06; } unknown800DC874; -/* Size: 0x10 bytes */ -typedef struct unk8011D0F8 { - f32 unk0; - f32 unk4; - f32 unk8; - f32 unkC; -} unk8011D0F8; - /* Size: 0x10 bytes */ typedef struct unk8011D330 { u8 pad0[0x10]; @@ -121,8 +113,6 @@ extern unknown800DC874 D_800DC87C; extern f32 D_800DC884[10]; -extern f32 D_800DC8AC[27]; - extern LevelModel *gCurrentLevelModel; extern LevelHeader *gCurrentLevelHeader; diff --git a/src/unknown_032760.c b/src/unknown_032760.c index a544a761..9e1e9aac 100644 --- a/src/unknown_032760.c +++ b/src/unknown_032760.c @@ -10,7 +10,7 @@ /************ .data ************/ unk800DC950 **D_800DC950 = NULL; -unk800DC954 *D_800DC954 = NULL; +unk800DC950 *D_800DC954 = NULL; s32 D_800DC958 = 0; s32 D_800DC95C = 0; unk800DC960 *D_800DC960 = NULL; @@ -40,18 +40,18 @@ void func_80031B60(void) { D_800DC958 = 0; } -#ifdef NON_EQUIVALENT +#ifdef NON_MATCHING // Regalloc issues void func_80031BB8(s32 count) { s32 i; func_80031B60(); D_800DC958 = count; - D_800DC950 = allocate_from_main_pool_safe(D_800DC958 * (sizeof(s32 *) + sizeof(unk800DC954) + sizeof(unk800DC960) + sizeof(unk800DC964)), COLOUR_TAG_MAGENTA); - D_800DC954 = &D_800DC950[D_800DC958]; - D_800DC960 = &D_800DC954[D_800DC958]; - D_800DC964 = &D_800DC960[D_800DC958]; + D_800DC950 = (unk800DC950 **) allocate_from_main_pool_safe(D_800DC958 * (sizeof(s32 *) + sizeof(unk800DC950) + sizeof(unk800DC960) + sizeof(unk800DC964)), COLOUR_TAG_MAGENTA); + D_800DC954 = (unk800DC950 *) &D_800DC950[D_800DC958]; + D_800DC960 = (unk800DC960 *) &D_800DC954[D_800DC958]; + D_800DC964 = (unk800DC964 *) &D_800DC960[D_800DC958]; for (i = 0; i < D_800DC958; i++) { - D_800DC950[i] = &D_800DC954[i].unk0; + D_800DC950[i] = &D_800DC954[i]; } } #else @@ -97,8 +97,7 @@ void func_80032248(unk800DC950 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s3 } } -// Unused. -void func_80032344(unk800DC950 *arg0, s32 arg1, s32 arg2) { +UNUSED void func_80032344(unk800DC950 *arg0, s32 arg1, s32 arg2) { if (arg2 > 0) { arg0->unk42 = arg2; arg0->unk38 = ((arg1 << 0x10) - arg0->unk28) / arg2; diff --git a/src/unknown_032760.h b/src/unknown_032760.h index 253c4b0a..6f2e50d6 100644 --- a/src/unknown_032760.h +++ b/src/unknown_032760.h @@ -5,6 +5,7 @@ #include "structs.h" #include "libc/math.h" +/* Size: 0x88 bytes */ typedef struct unk800DC950 { u8 unk0; u8 unk1; @@ -58,12 +59,6 @@ typedef struct unk800DC950 { f32 unk84; } unk800DC950; -/* Size: 0x88 bytes */ -typedef struct unk800DC954 { - unk800DC950 unk0; - u8 unk20[0x68]; -} unk800DC954; - /* Size: 0x14 bytes */ typedef struct unk800DC960 { s32 unk0; diff --git a/src/vehicle_bluey.c b/src/vehicle_bluey.c index f6f604dc..e9d9f431 100644 --- a/src/vehicle_bluey.c +++ b/src/vehicle_bluey.c @@ -190,7 +190,7 @@ void update_bluey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *ra obj->segment.animFrame = racer->unkC; obj->unk74 = 0; if (obj->segment.unk38.byte.unk3B == 0) { - func_800113CC(obj, 2, sp5C, 172, 173); + func_800113CC(obj, 2, sp5C, SOUND_STOMP2, SOUND_STOMP3); obj->unk74 |= 3; } func_800AFC3C(obj, updateRate); diff --git a/src/vehicle_tricky.c b/src/vehicle_tricky.c index 4426284a..ff04881f 100644 --- a/src/vehicle_tricky.c +++ b/src/vehicle_tricky.c @@ -158,7 +158,7 @@ void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r obj->segment.animFrame = racer->unkC; obj->unk74 = 0; if (obj->segment.unk38.byte.unk3B == 1) { - func_800113CC(obj, 2, sp54, 172, 173); + func_800113CC(obj, 2, sp54, SOUND_STOMP2, SOUND_STOMP3); obj->unk74 |= 3; } func_800AFC3C(obj, updateRate); diff --git a/src/vehicle_wizpig.c b/src/vehicle_wizpig.c index e88d607b..f35d81fa 100644 --- a/src/vehicle_wizpig.c +++ b/src/vehicle_wizpig.c @@ -220,7 +220,7 @@ void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r obj->segment.animFrame = racer->unkC; obj->unk74 = 0; if (obj->segment.unk38.byte.unk3B == 2) { - func_800113CC(obj, 2, sp3C, 0xAC, 0xAD); + func_800113CC(obj, 2, sp3C, SOUND_STOMP2, SOUND_STOMP3); } if (racer->playerIndex == PLAYER_COMPUTER) { if (func_80023568() != 0) { diff --git a/tools/asm_processor b/tools/asm_processor new file mode 160000 index 00000000..bbd86ea1 --- /dev/null +++ b/tools/asm_processor @@ -0,0 +1 @@ +Subproject commit bbd86ea1faf84e6a7a0e101ab8068a00a3dfb2fc diff --git a/tools/asm_processor/asm_processor.py b/tools/asm_processor/asm_processor.py deleted file mode 100644 index 01148c7a..00000000 --- a/tools/asm_processor/asm_processor.py +++ /dev/null @@ -1,1236 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import tempfile -import struct -import copy -import sys -import re -import os -from collections import namedtuple -from io import StringIO - -MAX_FN_SIZE = 100 -SLOW_CHECKS = False - -EI_NIDENT = 16 -EI_CLASS = 4 -EI_DATA = 5 -EI_VERSION = 6 -EI_OSABI = 7 -EI_ABIVERSION = 8 -STN_UNDEF = 0 - -SHN_UNDEF = 0 -SHN_ABS = 0xfff1 -SHN_COMMON = 0xfff2 -SHN_XINDEX = 0xffff -SHN_LORESERVE = 0xff00 - -STT_NOTYPE = 0 -STT_OBJECT = 1 -STT_FUNC = 2 -STT_SECTION = 3 -STT_FILE = 4 -STT_COMMON = 5 -STT_TLS = 6 - -STB_LOCAL = 0 -STB_GLOBAL = 1 -STB_WEAK = 2 - -STV_DEFAULT = 0 -STV_INTERNAL = 1 -STV_HIDDEN = 2 -STV_PROTECTED = 3 - -SHT_NULL = 0 -SHT_PROGBITS = 1 -SHT_SYMTAB = 2 -SHT_STRTAB = 3 -SHT_RELA = 4 -SHT_HASH = 5 -SHT_DYNAMIC = 6 -SHT_NOTE = 7 -SHT_NOBITS = 8 -SHT_REL = 9 -SHT_SHLIB = 10 -SHT_DYNSYM = 11 -SHT_INIT_ARRAY = 14 -SHT_FINI_ARRAY = 15 -SHT_PREINIT_ARRAY = 16 -SHT_GROUP = 17 -SHT_SYMTAB_SHNDX = 18 -SHT_MIPS_GPTAB = 0x70000003 -SHT_MIPS_DEBUG = 0x70000005 -SHT_MIPS_REGINFO = 0x70000006 -SHT_MIPS_OPTIONS = 0x7000000d - -SHF_WRITE = 0x1 -SHF_ALLOC = 0x2 -SHF_EXECINSTR = 0x4 -SHF_MERGE = 0x10 -SHF_STRINGS = 0x20 -SHF_INFO_LINK = 0x40 -SHF_LINK_ORDER = 0x80 -SHF_OS_NONCONFORMING = 0x100 -SHF_GROUP = 0x200 -SHF_TLS = 0x400 - -R_MIPS_32 = 2 -R_MIPS_26 = 4 -R_MIPS_HI16 = 5 -R_MIPS_LO16 = 6 - -MIPS_DEBUG_ST_STATIC = 2 -MIPS_DEBUG_ST_STATIC_PROC = 14 - - -class ElfHeader: - """ - typedef struct { - unsigned char e_ident[EI_NIDENT]; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; - } Elf32_Ehdr; - """ - - def __init__(self, data): - self.e_ident = data[:EI_NIDENT] - self.e_type, self.e_machine, self.e_version, self.e_entry, self.e_phoff, self.e_shoff, self.e_flags, self.e_ehsize, self.e_phentsize, self.e_phnum, self.e_shentsize, self.e_shnum, self.e_shstrndx = struct.unpack('>HHIIIIIHHHHHH', data[EI_NIDENT:]) - assert self.e_ident[EI_CLASS] == 1 # 32-bit - assert self.e_ident[EI_DATA] == 2 # big-endian - assert self.e_type == 1 # relocatable - assert self.e_machine == 8 # MIPS I Architecture - assert self.e_phoff == 0 # no program header - assert self.e_shoff != 0 # section header - assert self.e_shstrndx != SHN_UNDEF - - def to_bin(self): - return self.e_ident + struct.pack('>HHIIIIIHHHHHH', self.e_type, - self.e_machine, self.e_version, self.e_entry, self.e_phoff, - self.e_shoff, self.e_flags, self.e_ehsize, self.e_phentsize, - self.e_phnum, self.e_shentsize, self.e_shnum, self.e_shstrndx) - - -class Symbol: - """ - typedef struct { - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf32_Half st_shndx; - } Elf32_Sym; - """ - - def __init__(self, data, strtab, name=None): - self.st_name, self.st_value, self.st_size, st_info, self.st_other, self.st_shndx = struct.unpack('>IIIBBH', data) - assert self.st_shndx != SHN_XINDEX, "too many sections (SHN_XINDEX not supported)" - self.bind = st_info >> 4 - self.type = st_info & 15 - self.name = name if name is not None else strtab.lookup_str(self.st_name) - self.visibility = self.st_other & 3 - - @staticmethod - def from_parts(st_name, st_value, st_size, st_info, st_other, st_shndx, strtab, name): - header = struct.pack('>IIIBBH', st_name, st_value, st_size, st_info, st_other, st_shndx) - return Symbol(header, strtab, name) - - def to_bin(self): - st_info = (self.bind << 4) | self.type - return struct.pack('>IIIBBH', self.st_name, self.st_value, self.st_size, st_info, self.st_other, self.st_shndx) - - -class Relocation: - def __init__(self, data, sh_type): - self.sh_type = sh_type - if sh_type == SHT_REL: - self.r_offset, self.r_info = struct.unpack('>II', data) - else: - self.r_offset, self.r_info, self.r_addend = struct.unpack('>III', data) - self.sym_index = self.r_info >> 8 - self.rel_type = self.r_info & 0xff - - def to_bin(self): - self.r_info = (self.sym_index << 8) | self.rel_type - if self.sh_type == SHT_REL: - return struct.pack('>II', self.r_offset, self.r_info) - else: - return struct.pack('>III', self.r_offset, self.r_info, self.r_addend) - - -class Section: - """ - typedef struct { - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; - } Elf32_Shdr; - """ - - def __init__(self, header, data, index): - self.sh_name, self.sh_type, self.sh_flags, self.sh_addr, self.sh_offset, self.sh_size, self.sh_link, self.sh_info, self.sh_addralign, self.sh_entsize = struct.unpack('>IIIIIIIIII', header) - assert not self.sh_flags & SHF_LINK_ORDER - if self.sh_entsize != 0: - assert self.sh_size % self.sh_entsize == 0 - if self.sh_type == SHT_NOBITS: - self.data = b'' - else: - self.data = data[self.sh_offset:self.sh_offset + self.sh_size] - self.index = index - self.relocated_by = [] - - @staticmethod - def from_parts(sh_name, sh_type, sh_flags, sh_link, sh_info, sh_addralign, sh_entsize, data, index): - header = struct.pack('>IIIIIIIIII', sh_name, sh_type, sh_flags, 0, 0, len(data), sh_link, sh_info, sh_addralign, sh_entsize) - return Section(header, data, index) - - def lookup_str(self, index): - assert self.sh_type == SHT_STRTAB - to = self.data.find(b'\0', index) - assert to != -1 - return self.data[index:to].decode('latin1') - - def add_str(self, string): - assert self.sh_type == SHT_STRTAB - ret = len(self.data) - self.data += string.encode('latin1') + b'\0' - return ret - - def is_rel(self): - return self.sh_type == SHT_REL or self.sh_type == SHT_RELA - - def header_to_bin(self): - if self.sh_type != SHT_NOBITS: - self.sh_size = len(self.data) - return struct.pack('>IIIIIIIIII', self.sh_name, self.sh_type, self.sh_flags, self.sh_addr, self.sh_offset, self.sh_size, self.sh_link, self.sh_info, self.sh_addralign, self.sh_entsize) - - def late_init(self, sections): - if self.sh_type == SHT_SYMTAB: - self.init_symbols(sections) - elif self.is_rel(): - self.rel_target = sections[self.sh_info] - self.rel_target.relocated_by.append(self) - self.init_relocs() - - def find_symbol(self, name): - assert self.sh_type == SHT_SYMTAB - for s in self.symbol_entries: - if s.name == name: - return (s.st_shndx, s.st_value) - return None - - def find_symbol_in_section(self, name, section): - pos = self.find_symbol(name) - assert pos is not None - assert pos[0] == section.index - return pos[1] - - def init_symbols(self, sections): - assert self.sh_type == SHT_SYMTAB - assert self.sh_entsize == 16 - self.strtab = sections[self.sh_link] - entries = [] - for i in range(0, self.sh_size, self.sh_entsize): - entries.append(Symbol(self.data[i:i+self.sh_entsize], self.strtab)) - self.symbol_entries = entries - - def init_relocs(self): - assert self.is_rel() - entries = [] - for i in range(0, self.sh_size, self.sh_entsize): - entries.append(Relocation(self.data[i:i+self.sh_entsize], self.sh_type)) - self.relocations = entries - - def local_symbols(self): - assert self.sh_type == SHT_SYMTAB - return self.symbol_entries[:self.sh_info] - - def global_symbols(self): - assert self.sh_type == SHT_SYMTAB - return self.symbol_entries[self.sh_info:] - - -class ElfFile: - def __init__(self, data): - self.data = data - assert data[:4] == b'\x7fELF', "not an ELF file" - - self.elf_header = ElfHeader(data[0:52]) - - offset, size = self.elf_header.e_shoff, self.elf_header.e_shentsize - null_section = Section(data[offset:offset + size], data, 0) - num_sections = self.elf_header.e_shnum or null_section.sh_size - - self.sections = [null_section] - for i in range(1, num_sections): - ind = offset + i * size - self.sections.append(Section(data[ind:ind + size], data, i)) - - symtab = None - for s in self.sections: - if s.sh_type == SHT_SYMTAB: - assert not symtab - symtab = s - assert symtab is not None - self.symtab = symtab - - shstr = self.sections[self.elf_header.e_shstrndx] - for s in self.sections: - s.name = shstr.lookup_str(s.sh_name) - s.late_init(self.sections) - - def find_section(self, name): - for s in self.sections: - if s.name == name: - return s - return None - - def add_section(self, name, sh_type, sh_flags, sh_link, sh_info, sh_addralign, sh_entsize, data): - shstr = self.sections[self.elf_header.e_shstrndx] - sh_name = shstr.add_str(name) - s = Section.from_parts(sh_name=sh_name, sh_type=sh_type, - sh_flags=sh_flags, sh_link=sh_link, sh_info=sh_info, - sh_addralign=sh_addralign, sh_entsize=sh_entsize, data=data, - index=len(self.sections)) - self.sections.append(s) - s.name = name - s.late_init(self.sections) - return s - - def drop_irrelevant_sections(self): - # We can only drop sections at the end, since otherwise section - # references might be wrong. Luckily, these sections typically are. - while self.sections[-1].sh_type in [SHT_MIPS_DEBUG, SHT_MIPS_GPTAB]: - self.sections.pop() - - def write(self, filename): - outfile = open(filename, 'wb') - outidx = 0 - def write_out(data): - nonlocal outidx - outfile.write(data) - outidx += len(data) - def pad_out(align): - if align and outidx % align: - write_out(b'\0' * (align - outidx % align)) - - self.elf_header.e_shnum = len(self.sections) - write_out(self.elf_header.to_bin()) - - for s in self.sections: - if s.sh_type != SHT_NOBITS and s.sh_type != SHT_NULL: - pad_out(s.sh_addralign) - s.sh_offset = outidx - write_out(s.data) - - pad_out(4) - self.elf_header.e_shoff = outidx - for s in self.sections: - write_out(s.header_to_bin()) - - outfile.seek(0) - outfile.write(self.elf_header.to_bin()) - outfile.close() - - -def is_temp_name(name): - return name.startswith('_asmpp_') - - -# https://stackoverflow.com/a/241506 -def re_comment_replacer(match): - s = match.group(0) - if s[0] in "/#": - return " " - else: - return s - - -re_comment_or_string = re.compile( - r'#.*|/\*.*?\*/|"(?:\\.|[^\\"])*"' -) - - -class Failure(Exception): - def __init__(self, message): - self.message = message - - def __str__(self): - return self.message - - -class GlobalState: - def __init__(self, min_instr_count, skip_instr_count, use_jtbl_for_rodata, mips1): - # A value that hopefully never appears as a 32-bit rodata constant (or we - # miscompile late rodata). Increases by 1 in each step. - self.late_rodata_hex = 0xE0123456 - self.namectr = 0 - self.min_instr_count = min_instr_count - self.skip_instr_count = skip_instr_count - self.use_jtbl_for_rodata = use_jtbl_for_rodata - self.mips1 = mips1 - - def next_late_rodata_hex(self): - dummy_bytes = struct.pack('>I', self.late_rodata_hex) - if (self.late_rodata_hex & 0xffff) == 0: - # Avoid lui - self.late_rodata_hex += 1 - self.late_rodata_hex += 1 - return dummy_bytes - - def make_name(self, cat): - self.namectr += 1 - return '_asmpp_{}{}'.format(cat, self.namectr) - - -Function = namedtuple('Function', ['text_glabels', 'asm_conts', 'late_rodata_dummy_bytes', 'jtbl_rodata_size', 'late_rodata_asm_conts', 'fn_desc', 'data']) - - -class GlobalAsmBlock: - def __init__(self, fn_desc): - self.fn_desc = fn_desc - self.cur_section = '.text' - self.asm_conts = [] - self.late_rodata_asm_conts = [] - self.late_rodata_alignment = 0 - self.late_rodata_alignment_from_content = False - self.text_glabels = [] - self.fn_section_sizes = { - '.text': 0, - '.data': 0, - '.bss': 0, - '.rodata': 0, - '.late_rodata': 0, - } - self.fn_ins_inds = [] - self.glued_line = '' - self.num_lines = 0 - - def fail(self, message, line=None): - context = self.fn_desc - if line: - context += ", at line \"" + line + "\"" - raise Failure(message + "\nwithin " + context) - - def count_quoted_size(self, line, z, real_line, output_enc): - line = line.encode(output_enc).decode('latin1') - in_quote = False - num_parts = 0 - ret = 0 - i = 0 - digits = "0123456789" # 0-7 would be more sane, but this matches GNU as - while i < len(line): - c = line[i] - i += 1 - if not in_quote: - if c == '"': - in_quote = True - num_parts += 1 - else: - if c == '"': - in_quote = False - continue - ret += 1 - if c != '\\': - continue - if i == len(line): - self.fail("backslash at end of line not supported", real_line) - c = line[i] - i += 1 - # (if c is in "bfnrtv", we have a real escaped literal) - if c == 'x': - # hex literal, consume any number of hex chars, possibly none - while i < len(line) and line[i] in digits + "abcdefABCDEF": - i += 1 - elif c in digits: - # octal literal, consume up to two more digits - it = 0 - while i < len(line) and line[i] in digits and it < 2: - i += 1 - it += 1 - - if in_quote: - self.fail("unterminated string literal", real_line) - if num_parts == 0: - self.fail(".ascii with no string", real_line) - return ret + num_parts if z else ret - - def align2(self): - while self.fn_section_sizes[self.cur_section] % 2 != 0: - self.fn_section_sizes[self.cur_section] += 1 - - def align4(self): - while self.fn_section_sizes[self.cur_section] % 4 != 0: - self.fn_section_sizes[self.cur_section] += 1 - - def add_sized(self, size, line): - if self.cur_section in ['.text', '.late_rodata']: - if size % 4 != 0: - self.fail("size must be a multiple of 4", line) - if size < 0: - self.fail("size cannot be negative", line) - self.fn_section_sizes[self.cur_section] += size - if self.cur_section == '.text': - if not self.text_glabels: - self.fail(".text block without an initial glabel", line) - self.fn_ins_inds.append((self.num_lines - 1, size // 4)) - - def process_line(self, line, output_enc): - self.num_lines += 1 - if line.endswith('\\'): - self.glued_line += line[:-1] - return - line = self.glued_line + line - self.glued_line = '' - - real_line = line - line = re.sub(re_comment_or_string, re_comment_replacer, line) - line = line.strip() - line = re.sub(r'^[a-zA-Z0-9_]+:\s*', '', line) - changed_section = False - emitting_double = False - if line.startswith('glabel ') and self.cur_section == '.text': - self.text_glabels.append(line.split()[1]) - if not line: - pass # empty line - elif line.startswith('glabel ') or (' ' not in line and line.endswith(':')): - pass # label - elif line.startswith('.section') or line in ['.text', '.data', '.rdata', '.rodata', '.bss', '.late_rodata']: - # section change - self.cur_section = '.rodata' if line == '.rdata' else line.split(',')[0].split()[-1] - if self.cur_section not in ['.data', '.text', '.rodata', '.late_rodata', '.bss']: - self.fail("unrecognized .section directive", real_line) - changed_section = True - elif line.startswith('.late_rodata_alignment'): - if self.cur_section != '.late_rodata': - self.fail(".late_rodata_alignment must occur within .late_rodata section", real_line) - value = int(line.split()[1]) - if value not in [4, 8]: - self.fail(".late_rodata_alignment argument must be 4 or 8", real_line) - if self.late_rodata_alignment and self.late_rodata_alignment != value: - self.fail(".late_rodata_alignment alignment assumption conflicts with earlier .double directive. Make sure to provide explicit alignment padding.") - self.late_rodata_alignment = value - changed_section = True - elif line.startswith('.incbin'): - self.add_sized(int(line.split(',')[-1].strip(), 0), real_line) - elif line.startswith('.word') or line.startswith('.float'): - self.align4() - self.add_sized(4 * len(line.split(',')), real_line) - elif line.startswith('.double'): - self.align4() - if self.cur_section == '.late_rodata': - align8 = self.fn_section_sizes[self.cur_section] % 8 - # Automatically set late_rodata_alignment, so the generated C code uses doubles. - # This gives us correct alignment for the transferred doubles even when the - # late_rodata_alignment is wrong, e.g. for non-matching compilation. - if not self.late_rodata_alignment: - self.late_rodata_alignment = 8 - align8 - self.late_rodata_alignment_from_content = True - elif self.late_rodata_alignment != 8 - align8: - if self.late_rodata_alignment_from_content: - self.fail("found two .double directives with different start addresses mod 8. Make sure to provide explicit alignment padding.", real_line) - else: - self.fail(".double at address that is not 0 mod 8 (based on .late_rodata_alignment assumption). Make sure to provide explicit alignment padding.", real_line) - self.add_sized(8 * len(line.split(',')), real_line) - emitting_double = True - elif line.startswith('.space'): - self.add_sized(int(line.split()[1], 0), real_line) - elif line.startswith('.balign') or line.startswith('.align'): - align = int(line.split()[1]) - if align != 4: - self.fail("only .balign 4 is supported", real_line) - self.align4() - elif line.startswith('.asci'): - z = (line.startswith('.asciz') or line.startswith('.asciiz')) - self.add_sized(self.count_quoted_size(line, z, real_line, output_enc), real_line) - elif line.startswith('.byte'): - self.add_sized(len(line.split(',')), real_line) - elif line.startswith('.half'): - self.align2() - self.add_sized(2*len(line.split(',')), real_line) - elif line.startswith('.'): - # .macro, ... - self.fail("asm directive not supported", real_line) - else: - # Unfortunately, macros are hard to support for .rodata -- - # we don't know how how space they will expand to before - # running the assembler, but we need that information to - # construct the C code. So if we need that we'll either - # need to run the assembler twice (at least in some rare - # cases), or change how this program is invoked. - # Similarly, we can't currently deal with pseudo-instructions - # that expand to several real instructions. - if self.cur_section != '.text': - self.fail("instruction or macro call in non-.text section? not supported", real_line) - self.add_sized(4, real_line) - if self.cur_section == '.late_rodata': - if not changed_section: - if emitting_double: - self.late_rodata_asm_conts.append(".align 0") - self.late_rodata_asm_conts.append(real_line) - if emitting_double: - self.late_rodata_asm_conts.append(".align 2") - else: - self.asm_conts.append(real_line) - - def finish(self, state): - src = [''] * (self.num_lines + 1) - late_rodata_dummy_bytes = [] - jtbl_rodata_size = 0 - late_rodata_fn_output = [] - - num_instr = self.fn_section_sizes['.text'] // 4 - - if self.fn_section_sizes['.late_rodata'] > 0: - # Generate late rodata by emitting unique float constants. - # This requires 3 instructions for each 4 bytes of rodata. - # If we know alignment, we can use doubles, which give 3 - # instructions for 8 bytes of rodata. - size = self.fn_section_sizes['.late_rodata'] // 4 - skip_next = False - needs_double = (self.late_rodata_alignment != 0) - extra_mips1_nop = False - jtbl_size = 11 if state.mips1 else 9 - for i in range(size): - if skip_next: - skip_next = False - continue - # Jump tables give 9 instructions (11 with -mips1) for >= 5 words of rodata, - # and should be emitted when: - # - -O2 or -O2 -g3 are used, which give the right codegen - # - we have emitted our first .float/.double (to ensure that we find the - # created rodata in the binary) - # - we have emitted our first .double, if any (to ensure alignment of doubles - # in shifted rodata sections) - # - we have at least 5 words of rodata left to emit (otherwise IDO does not - # generate a jump table) - # - we have at least 10 more instructions to go in this function (otherwise our - # function size computation will be wrong since the delay slot goes unused) - if (not needs_double and state.use_jtbl_for_rodata and i >= 1 and - size - i >= 5 and num_instr - len(late_rodata_fn_output) >= jtbl_size + 1): - cases = " ".join("case {}:".format(case) for case in range(size - i)) - late_rodata_fn_output.append("switch (*(volatile int*)0) { " + cases + " ; }") - late_rodata_fn_output.extend([""] * (jtbl_size - 1)) - jtbl_rodata_size = (size - i) * 4 - extra_mips1_nop = i != 2 - break - dummy_bytes = state.next_late_rodata_hex() - late_rodata_dummy_bytes.append(dummy_bytes) - if self.late_rodata_alignment == 4 * ((i + 1) % 2 + 1) and i + 1 < size: - dummy_bytes2 = state.next_late_rodata_hex() - late_rodata_dummy_bytes.append(dummy_bytes2) - fval, = struct.unpack('>d', dummy_bytes + dummy_bytes2) - late_rodata_fn_output.append('*(volatile double*)0 = {};'.format(fval)) - skip_next = True - needs_double = False - if state.mips1: - # mips1 does not have ldc1/sdc1 - late_rodata_fn_output.append('') - late_rodata_fn_output.append('') - extra_mips1_nop = False - else: - fval, = struct.unpack('>f', dummy_bytes) - late_rodata_fn_output.append('*(volatile float*)0 = {}f;'.format(fval)) - extra_mips1_nop = True - late_rodata_fn_output.append('') - late_rodata_fn_output.append('') - if state.mips1 and extra_mips1_nop: - late_rodata_fn_output.append('') - - text_name = None - if self.fn_section_sizes['.text'] > 0 or late_rodata_fn_output: - text_name = state.make_name('func') - src[0] = 'void {}(void) {{'.format(text_name) - src[self.num_lines] = '}' - instr_count = self.fn_section_sizes['.text'] // 4 - if instr_count < state.min_instr_count: - self.fail("too short .text block") - tot_emitted = 0 - tot_skipped = 0 - fn_emitted = 0 - fn_skipped = 0 - rodata_stack = late_rodata_fn_output[::-1] - for (line, count) in self.fn_ins_inds: - for _ in range(count): - if (fn_emitted > MAX_FN_SIZE and instr_count - tot_emitted > state.min_instr_count and - (not rodata_stack or rodata_stack[-1])): - # Don't let functions become too large. When a function reaches 284 - # instructions, and -O2 -framepointer flags are passed, the IRIX - # compiler decides it is a great idea to start optimizing more. - fn_emitted = 0 - fn_skipped = 0 - src[line] += ' }} void {}(void) {{ '.format(state.make_name('large_func')) - if fn_skipped < state.skip_instr_count: - fn_skipped += 1 - tot_skipped += 1 - elif rodata_stack: - src[line] += rodata_stack.pop() - else: - src[line] += '*(volatile int*)0 = 0;' - tot_emitted += 1 - fn_emitted += 1 - if rodata_stack: - size = len(late_rodata_fn_output) // 3 - available = instr_count - tot_skipped - self.fail( - "late rodata to text ratio is too high: {} / {} must be <= 1/3\n" - "add .late_rodata_alignment (4|8) to the .late_rodata " - "block to double the allowed ratio." - .format(size, available)) - - rodata_name = None - if self.fn_section_sizes['.rodata'] > 0: - rodata_name = state.make_name('rodata') - src[self.num_lines] += ' const char {}[{}] = {{1}};'.format(rodata_name, self.fn_section_sizes['.rodata']) - - data_name = None - if self.fn_section_sizes['.data'] > 0: - data_name = state.make_name('data') - src[self.num_lines] += ' char {}[{}] = {{1}};'.format(data_name, self.fn_section_sizes['.data']) - - bss_name = None - if self.fn_section_sizes['.bss'] > 0: - bss_name = state.make_name('bss') - src[self.num_lines] += ' char {}[{}];'.format(bss_name, self.fn_section_sizes['.bss']) - - fn = Function( - text_glabels=self.text_glabels, - asm_conts=self.asm_conts, - late_rodata_dummy_bytes=late_rodata_dummy_bytes, - jtbl_rodata_size=jtbl_rodata_size, - late_rodata_asm_conts=self.late_rodata_asm_conts, - fn_desc=self.fn_desc, - data={ - '.text': (text_name, self.fn_section_sizes['.text']), - '.data': (data_name, self.fn_section_sizes['.data']), - '.rodata': (rodata_name, self.fn_section_sizes['.rodata']), - '.bss': (bss_name, self.fn_section_sizes['.bss']), - }) - return src, fn - -cutscene_data_regexpr = re.compile(r"CutsceneData (.|\n)*\[\] = {") -float_regexpr = re.compile(r"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f") - -def repl_float_hex(m): - return str(struct.unpack(">I", struct.pack(">f", float(m.group(0).strip().rstrip("f"))))[0]) - -def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, print_source=None): - if opt in ['O2', 'O1']: - if framepointer: - min_instr_count = 6 - skip_instr_count = 5 - else: - min_instr_count = 2 - skip_instr_count = 1 - elif opt == 'g': - if framepointer: - min_instr_count = 7 - skip_instr_count = 7 - else: - min_instr_count = 4 - skip_instr_count = 4 - else: - if opt != 'g3': - raise Failure("must pass one of -g, -O1, -O2, -O2 -g3") - if framepointer: - min_instr_count = 4 - skip_instr_count = 4 - else: - min_instr_count = 2 - skip_instr_count = 2 - - use_jtbl_for_rodata = False - if opt in ['O2', 'g3'] and not framepointer: - use_jtbl_for_rodata = True - - state = GlobalState(min_instr_count, skip_instr_count, use_jtbl_for_rodata, mips1) - - global_asm = None - asm_functions = [] - output_lines = [ - '#line 1 "' + f.name + '"' - ] - - is_cutscene_data = False - - for line_no, raw_line in enumerate(f, 1): - raw_line = raw_line.rstrip() - line = raw_line.lstrip() - - # Print exactly one output line per source line, to make compiler - # errors have correct line numbers. These will be overridden with - # reasonable content further down. - output_lines.append('') - - if global_asm is not None: - if line.startswith(')'): - src, fn = global_asm.finish(state) - for i, line2 in enumerate(src): - output_lines[start_index + i] = line2 - asm_functions.append(fn) - global_asm = None - else: - global_asm.process_line(raw_line, output_enc) - else: - if line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: - global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) - start_index = len(output_lines) - elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) - and line.endswith('")')): - fname = line[line.index('(') + 2 : -2] - out_dependencies.append(fname) - global_asm = GlobalAsmBlock(fname) - with open(fname, encoding=input_enc) as f: - for line2 in f: - global_asm.process_line(line2.rstrip(), output_enc) - src, fn = global_asm.finish(state) - output_lines[-1] = ''.join(src) - asm_functions.append(fn) - global_asm = None - elif line.startswith('#include "') and line.endswith('" EARLY'): - # C includes qualified with EARLY (i.e. #include "file.c" EARLY) will be - # processed recursively when encountered - fpath = os.path.dirname(f.name) - fname = os.path.join(fpath, line[line.index(' ') + 2 : -7]) - out_dependencies.append(fname) - include_src = StringIO() - with open(fname, encoding=input_enc) as include_file: - parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) - include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') - output_lines[-1] = include_src.getvalue() - include_src.close() - else: - # This is a hack to replace all floating-point numbers in an array of a particular type - # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation - if cutscene_data_regexpr.search(line) is not None: - is_cutscene_data = True - elif line.endswith("};"): - is_cutscene_data = False - if is_cutscene_data: - raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) - output_lines[-1] = raw_line - - if print_source: - if isinstance(print_source, StringIO): - for line in output_lines: - print_source.write(line + '\n') - else: - for line in output_lines: - print_source.write(line.encode(output_enc) + b'\n') - print_source.flush() - if print_source != sys.stdout.buffer: - print_source.close() - - return asm_functions - -def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc): - SECTIONS = ['.data', '.text', '.rodata', '.bss'] - - with open(objfile_name, 'rb') as f: - objfile = ElfFile(f.read()) - - prev_locs = { - '.text': 0, - '.data': 0, - '.rodata': 0, - '.bss': 0, - } - to_copy = { - '.text': [], - '.data': [], - '.rodata': [], - '.bss': [], - } - asm = [] - all_late_rodata_dummy_bytes = [] - all_jtbl_rodata_size = [] - late_rodata_asm = [] - late_rodata_source_name_start = None - late_rodata_source_name_end = None - - # Generate an assembly file with all the assembly we need to fill in. For - # simplicity we pad with nops/.space so that addresses match exactly, so we - # don't have to fix up relocations/symbol references. - all_text_glabels = set() - func_sizes = {} - for function in functions: - ifdefed = False - for sectype, (temp_name, size) in function.data.items(): - if temp_name is None: - continue - assert size > 0 - loc = objfile.symtab.find_symbol(temp_name) - if loc is None: - ifdefed = True - break - loc = loc[1] - prev_loc = prev_locs[sectype] - if loc < prev_loc: - raise Failure("Wrongly computed size for section {} (diff {}). This is an asm-processor bug!".format(sectype, prev_loc- loc)) - if loc != prev_loc: - asm.append('.section ' + sectype) - if sectype == '.text': - for i in range((loc - prev_loc) // 4): - asm.append('nop') - else: - asm.append('.space {}'.format(loc - prev_loc)) - to_copy[sectype].append((loc, size, temp_name, function.fn_desc)) - if function.text_glabels: - func_sizes[function.text_glabels[0]] = size - prev_locs[sectype] = loc + size - if not ifdefed: - all_text_glabels.update(function.text_glabels) - all_late_rodata_dummy_bytes.append(function.late_rodata_dummy_bytes) - all_jtbl_rodata_size.append(function.jtbl_rodata_size) - late_rodata_asm.append(function.late_rodata_asm_conts) - for sectype, (temp_name, size) in function.data.items(): - if temp_name is not None: - asm.append('.section ' + sectype) - asm.append('glabel ' + temp_name + '_asm_start') - asm.append('.text') - for line in function.asm_conts: - asm.append(line) - for sectype, (temp_name, size) in function.data.items(): - if temp_name is not None: - asm.append('.section ' + sectype) - asm.append('glabel ' + temp_name + '_asm_end') - if any(late_rodata_asm): - late_rodata_source_name_start = '_asmpp_late_rodata_start' - late_rodata_source_name_end = '_asmpp_late_rodata_end' - asm.append('.rdata') - asm.append('glabel {}'.format(late_rodata_source_name_start)) - for conts in late_rodata_asm: - asm.extend(conts) - asm.append('glabel {}'.format(late_rodata_source_name_end)) - - o_file = tempfile.NamedTemporaryFile(prefix='asm-processor', suffix='.o', delete=False) - o_name = o_file.name - o_file.close() - s_file = tempfile.NamedTemporaryFile(prefix='asm-processor', suffix='.s', delete=False) - s_name = s_file.name - try: - s_file.write(asm_prelude + b'\n') - for line in asm: - s_file.write(line.encode(output_enc) + b'\n') - s_file.close() - ret = os.system(assembler + " " + s_name + " -o " + o_name) - if ret != 0: - raise Failure("failed to assemble") - with open(o_name, 'rb') as f: - asm_objfile = ElfFile(f.read()) - - # Remove some clutter from objdump output - mdebug_section = objfile.find_section('.mdebug') - objfile.drop_irrelevant_sections() - - # Unify reginfo sections - target_reginfo = objfile.find_section('.reginfo') - source_reginfo_data = list(asm_objfile.find_section('.reginfo').data) - data = list(target_reginfo.data) - for i in range(20): - data[i] |= source_reginfo_data[i] - target_reginfo.data = bytes(data) - - # Move over section contents - modified_text_positions = set() - jtbl_rodata_positions = set() - last_rodata_pos = 0 - for sectype in SECTIONS: - if not to_copy[sectype]: - continue - source = asm_objfile.find_section(sectype) - assert source is not None, "didn't find source section: " + sectype - for (pos, count, temp_name, fn_desc) in to_copy[sectype]: - loc1 = asm_objfile.symtab.find_symbol_in_section(temp_name + '_asm_start', source) - loc2 = asm_objfile.symtab.find_symbol_in_section(temp_name + '_asm_end', source) - assert loc1 == pos, "assembly and C files don't line up for section " + sectype + ", " + fn_desc - if loc2 - loc1 != count: - raise Failure("incorrectly computed size for section " + sectype + ", " + fn_desc + ". If using .double, make sure to provide explicit alignment padding.") - if sectype == '.bss': - continue - target = objfile.find_section(sectype) - assert target is not None, "missing target section of type " + sectype - data = list(target.data) - for (pos, count, _, _) in to_copy[sectype]: - data[pos:pos + count] = source.data[pos:pos + count] - if sectype == '.text': - assert count % 4 == 0 - assert pos % 4 == 0 - for i in range(count // 4): - modified_text_positions.add(pos + 4 * i) - elif sectype == '.rodata': - last_rodata_pos = pos + count - target.data = bytes(data) - - # Move over late rodata. This is heuristic, sadly, since I can't think - # of another way of doing it. - moved_late_rodata = {} - if any(all_late_rodata_dummy_bytes) or any(all_jtbl_rodata_size): - source = asm_objfile.find_section('.rodata') - target = objfile.find_section('.rodata') - source_pos = asm_objfile.symtab.find_symbol_in_section(late_rodata_source_name_start, source) - source_end = asm_objfile.symtab.find_symbol_in_section(late_rodata_source_name_end, source) - if source_end - source_pos != sum(map(len, all_late_rodata_dummy_bytes)) * 4 + sum(all_jtbl_rodata_size): - raise Failure("computed wrong size of .late_rodata") - new_data = list(target.data) - for dummy_bytes_list, jtbl_rodata_size in zip(all_late_rodata_dummy_bytes, all_jtbl_rodata_size): - for index, dummy_bytes in enumerate(dummy_bytes_list): - pos = target.data.index(dummy_bytes, last_rodata_pos) - # This check is nice, but makes time complexity worse for large files: - if SLOW_CHECKS and target.data.find(dummy_bytes, pos + 4) != -1: - raise Failure("multiple occurrences of late_rodata hex magic. Change asm-processor to use something better than 0xE0123456!") - if index == 0 and len(dummy_bytes_list) > 1 and target.data[pos+4:pos+8] == b'\0\0\0\0': - # Ugly hack to handle double alignment for non-matching builds. - # We were told by .late_rodata_alignment (or deduced from a .double) - # that a function's late_rodata started out 4 (mod 8), and emitted - # a float and then a double. But it was actually 0 (mod 8), so our - # double was moved by 4 bytes. To make them adjacent to keep jump - # tables correct, move the float by 4 bytes as well. - new_data[pos:pos+4] = b'\0\0\0\0' - pos += 4 - new_data[pos:pos+4] = source.data[source_pos:source_pos+4] - moved_late_rodata[source_pos] = pos - last_rodata_pos = pos + 4 - source_pos += 4 - if jtbl_rodata_size > 0: - assert dummy_bytes_list, "should always have dummy bytes before jtbl data" - pos = last_rodata_pos - new_data[pos : pos + jtbl_rodata_size] = \ - source.data[source_pos : source_pos + jtbl_rodata_size] - for i in range(0, jtbl_rodata_size, 4): - moved_late_rodata[source_pos + i] = pos + i - jtbl_rodata_positions.add(pos + i) - last_rodata_pos += jtbl_rodata_size - source_pos += jtbl_rodata_size - target.data = bytes(new_data) - - # Merge strtab data. - strtab_adj = len(objfile.symtab.strtab.data) - objfile.symtab.strtab.data += asm_objfile.symtab.strtab.data - - # Find relocated symbols - relocated_symbols = set() - for sectype in SECTIONS: - for obj in [asm_objfile, objfile]: - sec = obj.find_section(sectype) - if sec is None: - continue - for reltab in sec.relocated_by: - for rel in reltab.relocations: - relocated_symbols.add(obj.symtab.symbol_entries[rel.sym_index]) - - # Move over symbols, deleting the temporary function labels. - # Sometimes this naive procedure results in duplicate symbols, or UNDEF - # symbols that are also defined the same .o file. Hopefully that's fine. - # Skip over local symbols that aren't relocated against, to avoid - # conflicts. - new_local_syms = [s for s in objfile.symtab.local_symbols() if not is_temp_name(s.name)] - new_global_syms = [s for s in objfile.symtab.global_symbols() if not is_temp_name(s.name)] - for i, s in enumerate(asm_objfile.symtab.symbol_entries): - is_local = (i < asm_objfile.symtab.sh_info) - if is_local and s not in relocated_symbols: - continue - if is_temp_name(s.name): - continue - if s.st_shndx not in [SHN_UNDEF, SHN_ABS]: - section_name = asm_objfile.sections[s.st_shndx].name - if section_name not in SECTIONS: - raise Failure("generated assembly .o must only have symbols for .text, .data, .rodata, ABS and UNDEF, but found " + section_name) - s.st_shndx = objfile.find_section(section_name).index - # glabel's aren't marked as functions, making objdump output confusing. Fix that. - if s.name in all_text_glabels: - s.type = STT_FUNC - if s.name in func_sizes: - s.st_size = func_sizes[s.name] - if objfile.sections[s.st_shndx].name == '.rodata' and s.st_value in moved_late_rodata: - s.st_value = moved_late_rodata[s.st_value] - s.st_name += strtab_adj - if is_local: - new_local_syms.append(s) - else: - new_global_syms.append(s) - - # Add static symbols from .mdebug, so they can be referred to from GLOBAL_ASM - local_sym_replacements = {} - if mdebug_section: - strtab_index = len(objfile.symtab.strtab.data) - new_strtab_data = [] - ifd_max, cb_fd_offset = struct.unpack('>II', mdebug_section.data[18*4 : 20*4]) - cb_sym_offset, = struct.unpack('>I', mdebug_section.data[9*4 : 10*4]) - cb_ss_offset, = struct.unpack('>I', mdebug_section.data[15*4 : 16*4]) - for i in range(ifd_max): - offset = cb_fd_offset + 18*4*i - iss_base, _, isym_base, csym = struct.unpack('>IIII', objfile.data[offset + 2*4 : offset + 6*4]) - for j in range(csym): - offset2 = cb_sym_offset + 12 * (isym_base + j) - iss, value, st_sc_index = struct.unpack('>III', objfile.data[offset2 : offset2 + 12]) - st = (st_sc_index >> 26) - sc = (st_sc_index >> 21) & 0x1f - if st in [MIPS_DEBUG_ST_STATIC, MIPS_DEBUG_ST_STATIC_PROC]: - symbol_name_offset = cb_ss_offset + iss_base + iss - symbol_name_offset_end = objfile.data.find(b'\0', symbol_name_offset) - assert symbol_name_offset_end != -1 - symbol_name = objfile.data[symbol_name_offset : symbol_name_offset_end + 1] - symbol_name_str = symbol_name[:-1].decode('latin1') - section_name = {1: '.text', 2: '.data', 3: '.bss', 15: '.rodata'}[sc] - section = objfile.find_section(section_name) - symtype = STT_FUNC if sc == 1 else STT_OBJECT - sym = Symbol.from_parts( - st_name=strtab_index, - st_value=value, - st_size=0, - st_info=(STB_LOCAL << 4 | symtype), - st_other=STV_DEFAULT, - st_shndx=section.index, - strtab=objfile.symtab.strtab, - name=symbol_name_str) - local_sym_replacements[symbol_name_str] = len(new_local_syms) - strtab_index += len(symbol_name) - new_strtab_data.append(symbol_name) - new_local_syms.append(sym) - objfile.symtab.strtab.data += b''.join(new_strtab_data) - - # To get the linker to use the local symbols, we have to get rid of UNDEF - # global ones. - newer_global_syms = [] - for s in new_global_syms: - if s.st_shndx == SHN_UNDEF and s.name in local_sym_replacements: - s.new_index = local_sym_replacements[s.name] - else: - newer_global_syms.append(s) - new_global_syms = newer_global_syms - - new_syms = new_local_syms + new_global_syms - for i, s in enumerate(new_syms): - s.new_index = i - objfile.symtab.data = b''.join(s.to_bin() for s in new_syms) - objfile.symtab.sh_info = len(new_local_syms) - - # Move over relocations - for sectype in SECTIONS: - source = asm_objfile.find_section(sectype) - target = objfile.find_section(sectype) - - if target is not None: - # fixup relocation symbol indices, since we butchered them above - for reltab in target.relocated_by: - nrels = [] - for rel in reltab.relocations: - if (sectype == '.text' and rel.r_offset in modified_text_positions or - sectype == '.rodata' and rel.r_offset in jtbl_rodata_positions): - # don't include relocations for late_rodata dummy code - continue - # hopefully we don't have relocations for local or - # temporary symbols, so new_index exists - rel.sym_index = objfile.symtab.symbol_entries[rel.sym_index].new_index - nrels.append(rel) - reltab.relocations = nrels - reltab.data = b''.join(rel.to_bin() for rel in nrels) - - if not source: - continue - - target_reltab = objfile.find_section('.rel' + sectype) - target_reltaba = objfile.find_section('.rela' + sectype) - for reltab in source.relocated_by: - for rel in reltab.relocations: - rel.sym_index = asm_objfile.symtab.symbol_entries[rel.sym_index].new_index - if sectype == '.rodata' and rel.r_offset in moved_late_rodata: - rel.r_offset = moved_late_rodata[rel.r_offset] - new_data = b''.join(rel.to_bin() for rel in reltab.relocations) - if reltab.sh_type == SHT_REL: - if not target_reltab: - target_reltab = objfile.add_section('.rel' + sectype, - sh_type=SHT_REL, sh_flags=0, - sh_link=objfile.symtab.index, sh_info=target.index, - sh_addralign=4, sh_entsize=8, data=b'') - target_reltab.data += new_data - else: - if not target_reltaba: - target_reltaba = objfile.add_section('.rela' + sectype, - sh_type=SHT_RELA, sh_flags=0, - sh_link=objfile.symtab.index, sh_info=target.index, - sh_addralign=4, sh_entsize=12, data=b'') - target_reltaba.data += new_data - - objfile.write(objfile_name) - finally: - s_file.close() - os.remove(s_name) - try: - os.remove(o_name) - except: - pass - -def run_wrapped(argv, outfile, functions): - parser = argparse.ArgumentParser(description="Pre-process .c files and post-process .o files to enable embedding assembly into C.") - parser.add_argument('filename', help="path to .c code") - parser.add_argument('--post-process', dest='objfile', help="path to .o file to post-process") - parser.add_argument('--assembler', dest='assembler', help="assembler command (e.g. \"mips-linux-gnu-as -march=vr4300 -mabi=32\")") - parser.add_argument('--asm-prelude', dest='asm_prelude', help="path to a file containing a prelude to the assembly file (with .set and .macro directives, e.g.)") - parser.add_argument('--input-enc', default='latin1', help="Input encoding (default: latin1)") - parser.add_argument('--output-enc', default='latin1', help="Output encoding (default: latin1)") - parser.add_argument('-framepointer', dest='framepointer', action='store_true') - parser.add_argument('-mips1', dest='mips1', action='store_true') - parser.add_argument('-g3', dest='g3', action='store_true') - group = parser.add_mutually_exclusive_group(required=True) - group.add_argument('-O1', dest='opt', action='store_const', const='O1') - group.add_argument('-O2', dest='opt', action='store_const', const='O2') - group.add_argument('-g', dest='opt', action='store_const', const='g') - args = parser.parse_args(argv) - opt = args.opt - if args.g3: - if opt != 'O2': - raise Failure("-g3 is only supported together with -O2") - opt = 'g3' - if args.mips1 and (opt != 'O2' or args.framepointer): - raise Failure("-mips1 is only supported together with -O2") - - if args.objfile is None: - with open(args.filename, encoding=args.input_enc) as f: - deps = [] - functions = parse_source(f, opt=opt, framepointer=args.framepointer, mips1=args.mips1, input_enc=args.input_enc, output_enc=args.output_enc, out_dependencies=deps, print_source=outfile) - return functions, deps - else: - if args.assembler is None: - raise Failure("must pass assembler command") - if functions is None: - with open(args.filename, encoding=args.input_enc) as f: - functions = parse_source(f, opt=opt, framepointer=args.framepointer, mips1=args.mips1, input_enc=args.input_enc, out_dependencies=[], output_enc=args.output_enc) - if not functions: - return - asm_prelude = b'' - if args.asm_prelude: - with open(args.asm_prelude, 'rb') as f: - asm_prelude = f.read() - fixup_objfile(args.objfile, functions, asm_prelude, args.assembler, args.output_enc) - -def run(argv, outfile=sys.stdout.buffer, functions=None): - try: - return run_wrapped(argv, outfile, functions) - except Failure as e: - print("Error:", e, file=sys.stderr) - sys.exit(1) - -if __name__ == "__main__": - run(sys.argv[1:]) diff --git a/tools/asm_processor/build.py b/tools/asm_processor/build.py deleted file mode 100755 index 78aa7fb6..00000000 --- a/tools/asm_processor/build.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -import sys -import os -import shlex -import subprocess -import tempfile -import asm_processor - -dir_path = os.path.dirname(os.path.realpath(__file__)) -prelude = os.path.join(dir_path, "prelude.inc") - -all_args = sys.argv[1:] -sep1 = all_args.index('--') -sep2 = all_args.index('--', sep1+1) - -compiler = all_args[:sep1] - -assembler = all_args[sep1+1:sep2] -assembler_sh = ' '.join(shlex.quote(x) for x in assembler) - -compile_args = all_args[sep2+1:] -in_file = compile_args[-1] -out_ind = compile_args.index('-o') -out_file = compile_args[out_ind + 1] -del compile_args[-1] -del compile_args[out_ind + 1] -del compile_args[out_ind] - -in_dir = os.path.split(os.path.realpath(in_file))[0] -opt_flags = [x for x in compile_args if x in ['-g3', '-g', '-O1', '-O2', '-framepointer']] - -preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c', delete=False) - -try: - # Only want to apply -mips1 flag to certain files - if ('-O2' in opt_flags) and ((not 'lib/' in in_file) or ('lib/src/mips1' in in_file)): - opt_flags.append('-mips1') - asmproc_flags = opt_flags + [in_file, '--input-enc', 'utf-8', '--output-enc', 'euc-jp'] - compile_cmdline = compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name] - asm_processor.run(asmproc_flags, outfile=preprocessed_file) - try: - subprocess.check_call(compile_cmdline) - except subprocess.CalledProcessError as e: - print("Failed to compile file " + in_file + ". Command line:") - print() - print(' '.join(shlex.quote(x) for x in compile_cmdline)) - print() - sys.exit(55) - # To keep the preprocessed file: - # os._exit(1) - - asm_processor.run(asmproc_flags + ['--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude]) -finally: - os.remove(preprocessed_file.name) diff --git a/tools/asm_processor/compile.sh b/tools/asm_processor/compile.sh deleted file mode 100644 index f125ff89..00000000 --- a/tools/asm_processor/compile.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -e -set -o pipefail -INPUT="$1" -OUTPUT="${INPUT%.c}.o" - -CC="$QEMU_IRIX -silent -L $IRIX_ROOT $IRIX_ROOT/usr/bin/cc" -CFLAGS="-Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -fullwarn -wlint -woff 819,820,852,821 -signed -DVERSION_JP=1 -mips2" # -I include -AS="mips-linux-gnu-as" -ASFLAGS="-march=vr4300 -mabi=32 --defsym VERSION_JP=1" # -I include -set +e -OPTFLAGS=$(grep '^// COMPILE-FLAGS: ' $INPUT | sed 's#^// COMPILE-FLAGS: ##') -set -e -if [[ -z "$OPTFLAGS" ]]; then - OPTFLAGS="-g" -fi - -python3 asm_processor.py "$OPTFLAGS" "$INPUT" | $CC -c $CFLAGS include-stdin.c -o "$OUTPUT" "$OPTFLAGS" -python3 asm_processor.py "$OPTFLAGS" "$INPUT" --post-process "$OUTPUT" --assembler "$AS $ASFLAGS" --asm-prelude prelude.s diff --git a/tools/asm_processor/include-stdin.c b/tools/asm_processor/include-stdin.c deleted file mode 100644 index c21aa6f6..00000000 --- a/tools/asm_processor/include-stdin.c +++ /dev/null @@ -1,2 +0,0 @@ -// (this is used for piping input to the IRIX compiler without needing to make a temporary .c file) -#include "/dev/stdin" diff --git a/tools/asm_processor/prelude.inc b/tools/asm_processor/prelude.inc deleted file mode 100644 index 4ac5fd3d..00000000 --- a/tools/asm_processor/prelude.inc +++ /dev/null @@ -1,6 +0,0 @@ -.include "macros.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # dont insert nops after branches -.set gp=64 # 64-bit instructions are used \ No newline at end of file diff --git a/tools/asm_processor/prelude.s b/tools/asm_processor/prelude.s deleted file mode 100644 index 5118a5c6..00000000 --- a/tools/asm_processor/prelude.s +++ /dev/null @@ -1,8 +0,0 @@ -.set noat -.set noreorder -.set gp=64 -.macro glabel label - .global \label - \label: -.endm - diff --git a/tools/ido-static-recomp b/tools/ido-static-recomp index 794ca45a..a64576b8 160000 --- a/tools/ido-static-recomp +++ b/tools/ido-static-recomp @@ -1 +1 @@ -Subproject commit 794ca45aa00988a40c7a3a906bd6595a07860c85 +Subproject commit a64576b86967a503be84bfb473cd8d0e69e5ce3f diff --git a/tools/python/diff.py b/tools/python/diff.py index 1c036381..33f28c90 100644 --- a/tools/python/diff.py +++ b/tools/python/diff.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # PYTHON_ARGCOMPLETE_OK import argparse +import enum import sys from typing import ( Any, @@ -28,6 +29,14 @@ def static_assert_unreachable(x: NoReturn) -> NoReturn: raise Exception("Unreachable! " + repr(x)) +class DiffMode(enum.Enum): + SINGLE = "single" + SINGLE_BASE = "single_base" + NORMAL = "normal" + THREEWAY_PREV = "3prev" + THREEWAY_BASE = "3base" + + # ==== COMMAND-LINE ==== if __name__ == "__main__": @@ -228,6 +237,13 @@ if __name__ == "__main__": action="store_false", help="Don't visualize branches/branch targets.", ) + parser.add_argument( + "-R", + "--no-show-rodata-refs", + dest="show_rodata_refs", + action="store_false", + help="Don't show .rodata -> .text references (typically from jump tables).", + ) parser.add_argument( "-S", "--base-shift", @@ -248,21 +264,37 @@ if __name__ == "__main__": help="""Automatically update when source/object files change. Recommended in combination with -m.""", ) + parser.add_argument( + "-0", + "--diff_mode=single_base", + dest="diff_mode", + action="store_const", + const=DiffMode.SINGLE_BASE, + help="""View the base asm only (not a diff).""", + ) + parser.add_argument( + "-1", + "--diff_mode=single", + dest="diff_mode", + action="store_const", + const=DiffMode.SINGLE, + help="""View the current asm only (not a diff).""", + ) parser.add_argument( "-3", "--threeway=prev", - dest="threeway", + dest="diff_mode", action="store_const", - const="prev", + const=DiffMode.THREEWAY_PREV, help="""Show a three-way diff between target asm, current asm, and asm prior to -w rebuild. Requires -w.""", ) parser.add_argument( "-b", "--threeway=base", - dest="threeway", + dest="diff_mode", action="store_const", - const="base", + const=DiffMode.THREEWAY_BASE, help="""Show a three-way diff between target asm, current asm, and asm when diff.py was started. Requires -w.""", ) @@ -340,7 +372,6 @@ import ast from collections import Counter, defaultdict from dataclasses import asdict, dataclass, field, replace import difflib -import enum import html import itertools import json @@ -357,7 +388,7 @@ import traceback MISSING_PREREQUISITES = ( "Missing prerequisite python module {}. " - "Run `python3 -m pip install --user colorama watchdog python-Levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." + "Run `python3 -m pip install --user colorama watchdog levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." ) try: @@ -378,7 +409,6 @@ class ProjectSettings: map_format: str build_dir: str ms_map_address_offset: int - ms_ignore_missing_objfile: int baseimg: Optional[str] myimg: Optional[str] mapfile: Optional[str] @@ -387,6 +417,7 @@ class ProjectSettings: show_line_numbers_default: bool disassemble_all: bool reg_categories: Dict[str, int] + expected_dir: str @dataclass @@ -411,10 +442,11 @@ class Config: # Display options formatter: "Formatter" - threeway: Optional[str] + diff_mode: DiffMode base_shift: int skip_lines: int compress: Optional[Compress] + show_rodata_refs: bool show_branches: bool show_line_numbers: bool show_source: bool @@ -448,9 +480,9 @@ def create_project_settings(settings: Dict[str, Any]) -> ProjectSettings: ), objdump_executable=get_objdump_executable(settings.get("objdump_executable")), objdump_flags=settings.get("objdump_flags", []), + expected_dir=settings.get("expected_dir", "expected/"), map_format=settings.get("map_format", "gnu"), ms_map_address_offset=settings.get("ms_map_address_offset", 0), - ms_ignore_missing_objfile=settings.get("ms_ignore_missing_objfile", True), build_dir=settings.get("build_dir", settings.get("mw_build_dir", "build/")), show_line_numbers_default=settings.get("show_line_numbers_default", True), disassemble_all=settings.get("disassemble_all", False), @@ -500,12 +532,13 @@ def create_config(args: argparse.Namespace, project: ProjectSettings) -> Config: max_function_size_bytes=args.max_lines * 4, # Display options formatter=formatter, - threeway=args.threeway, + diff_mode=args.diff_mode or DiffMode.NORMAL, base_shift=eval_int( args.base_shift, "Failed to parse --base-shift (-S) argument as an integer." ), skip_lines=args.skip_lines, compress=compress, + show_rodata_refs=args.show_rodata_refs, show_branches=args.show_branches, show_line_numbers=show_line_numbers, show_source=args.show_source or args.source_old_binutils, @@ -671,11 +704,19 @@ class Text: @dataclass -class TableMetadata: +class TableLine: + key: Optional[str] + is_data_ref: bool + cells: Tuple[Tuple[Text, Optional["Line"]], ...] + + +@dataclass +class TableData: headers: Tuple[Text, ...] current_score: int max_score: int previous_score: Optional[int] + lines: List[TableLine] class Formatter(abc.ABC): @@ -685,7 +726,7 @@ class Formatter(abc.ABC): ... @abc.abstractmethod - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: + def table(self, data: TableData) -> str: """Format a multi-column table with metadata""" ... @@ -693,8 +734,8 @@ class Formatter(abc.ABC): return "".join(self.apply_format(chunk, f) for chunk, f in text.segments) @staticmethod - def outputline_texts(lines: Tuple["OutputLine", ...]) -> Tuple[Text, ...]: - return tuple([lines[0].base or Text()] + [line.fmt2 for line in lines[1:]]) + def outputline_texts(line: TableLine) -> Tuple[Text, ...]: + return tuple(cell[0] for cell in line.cells) @dataclass @@ -704,8 +745,8 @@ class PlainFormatter(Formatter): def apply_format(self, chunk: str, f: Format) -> str: return chunk - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: - rows = [meta.headers] + [self.outputline_texts(ls) for ls in lines] + def table(self, data: TableData) -> str: + rows = [data.headers] + [self.outputline_texts(line) for line in data.lines] return "\n".join( "".join(self.apply(x.ljust(self.column_width)) for x in row) for row in rows ) @@ -772,9 +813,13 @@ class AnsiFormatter(Formatter): static_assert_unreachable(f) return f"{ansi_code}{chunk}{undo_ansi_code}" - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: - rows = [(meta.headers, False)] + [ - (self.outputline_texts(line), line[1].is_data_ref) for line in lines + def table(self, data: TableData) -> str: + rows = [(data.headers, False)] + [ + ( + self.outputline_texts(line), + line.is_data_ref, + ) + for line in data.lines ] return "\n".join( "".join( @@ -806,7 +851,7 @@ class HtmlFormatter(Formatter): static_assert_unreachable(f) return f"{chunk}" - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: + def table(self, data: TableData) -> str: def table_row(line: Tuple[Text, ...], is_data_ref: bool, cell_el: str) -> str: tr_attrs = " class='data-ref'" if is_data_ref else "" output_row = f"