From 0fb1e1ab307819a076de7c853bea188475b089cc Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Thu, 29 Oct 2020 16:58:34 -0400 Subject: [PATCH] :dog: --- Makefile | 6 +- asm/nonmatchings/code_FBE10/func_802D7CF8.s | 72 --------------------- include/variables.h | 1 + src/code_FBE10.c | 22 ++++++- tools/symbol_addrs.txt | 1 + undefined_syms.txt | 2 + 6 files changed, 28 insertions(+), 76 deletions(-) delete mode 100644 asm/nonmatchings/code_FBE10/func_802D7CF8.s diff --git a/Makefile b/Makefile index f838e6f178..0bb9ba311e 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ CPP := cpp LD := $(CROSS)ld OBJCOPY := $(CROSS)objcopy -CPPFLAGS := -Iinclude -Isrc -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 -D_MIPS_SZLONG=32 -Wundef -Wcomment +CPPFLAGS := -Iinclude -Isrc -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 -D_MIPS_SZLONG=32 -Wundef -Wcomment -MP -MD ASFLAGS := -EB -Iinclude -march=vr4300 -mtune=vr4300 OLDASFLAGS := -EB -Iinclude -G 0 CFLAGS := -O2 -quiet -G 0 -mcpu=vr4300 -mfix4300 -mips3 -mgp32 -mfp32 -Wimplicit -Wuninitialized -Wshadow @@ -133,12 +133,12 @@ $(BUILD_DIR)/%.Yay0.o: $(BUILD_DIR)/%.bin.Yay0 # Compile C files $(BUILD_DIR)/%.c.o: %.c $(BUILD_DIR)/%.d @mkdir -p $(shell dirname $@) - $(CPP) $(CPPFLAGS) -MP -MD -o - $< -MF $@.mk -MT $(BUILD_DIR)/$*.d | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - + $(CPP) $(CPPFLAGS) -o - $< -MF $@.mk -MT $(BUILD_DIR)/$*.d | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - # Compile C files (with DSL macros) $(foreach cfile, $(DSL_C_FILES), $(BUILD_DIR)/$(cfile).o): $(BUILD_DIR)/%.c.o: %.c $(BUILD_DIR)/%.d @mkdir -p $(shell dirname $@) - $(CPP) $(CPPFLAGS) -MP -MD -o - $< -MF $@.mk -MT $(BUILD_DIR)/$*.d | tools/compile_dsl_macros.py | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - + $(CPP) $(CPPFLAGS) -o - $< -MF $@.mk -MT $(BUILD_DIR)/$*.d | tools/compile_dsl_macros.py | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - # Assemble handwritten ASM $(BUILD_DIR)/%.s.o: %.s diff --git a/asm/nonmatchings/code_FBE10/func_802D7CF8.s b/asm/nonmatchings/code_FBE10/func_802D7CF8.s deleted file mode 100644 index 508e87c920..0000000000 --- a/asm/nonmatchings/code_FBE10/func_802D7CF8.s +++ /dev/null @@ -1,72 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802D7CF8 -/* FC6A8 802D7CF8 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* FC6AC 802D7CFC AFB10014 */ sw $s1, 0x14($sp) -/* FC6B0 802D7D00 0080882D */ daddu $s1, $a0, $zero -/* FC6B4 802D7D04 AFBF002C */ sw $ra, 0x2c($sp) -/* FC6B8 802D7D08 AFB60028 */ sw $s6, 0x28($sp) -/* FC6BC 802D7D0C AFB50024 */ sw $s5, 0x24($sp) -/* FC6C0 802D7D10 AFB40020 */ sw $s4, 0x20($sp) -/* FC6C4 802D7D14 AFB3001C */ sw $s3, 0x1c($sp) -/* FC6C8 802D7D18 AFB20018 */ sw $s2, 0x18($sp) -/* FC6CC 802D7D1C AFB00010 */ sw $s0, 0x10($sp) -/* FC6D0 802D7D20 8E30000C */ lw $s0, 0xc($s1) -/* FC6D4 802D7D24 8E050000 */ lw $a1, ($s0) -/* FC6D8 802D7D28 0C0B1EAF */ jal get_variable -/* FC6DC 802D7D2C 26100004 */ addiu $s0, $s0, 4 -/* FC6E0 802D7D30 8E050000 */ lw $a1, ($s0) -/* FC6E4 802D7D34 26100004 */ addiu $s0, $s0, 4 -/* FC6E8 802D7D38 0220202D */ daddu $a0, $s1, $zero -/* FC6EC 802D7D3C 0C0B1EAF */ jal get_variable -/* FC6F0 802D7D40 0040B02D */ daddu $s6, $v0, $zero -/* FC6F4 802D7D44 8E050000 */ lw $a1, ($s0) -/* FC6F8 802D7D48 26100004 */ addiu $s0, $s0, 4 -/* FC6FC 802D7D4C 0220202D */ daddu $a0, $s1, $zero -/* FC700 802D7D50 0C0B1EAF */ jal get_variable -/* FC704 802D7D54 0040A82D */ daddu $s5, $v0, $zero -/* FC708 802D7D58 8E050000 */ lw $a1, ($s0) -/* FC70C 802D7D5C 26100004 */ addiu $s0, $s0, 4 -/* FC710 802D7D60 0220202D */ daddu $a0, $s1, $zero -/* FC714 802D7D64 0C0B1EAF */ jal get_variable -/* FC718 802D7D68 0040A02D */ daddu $s4, $v0, $zero -/* FC71C 802D7D6C 8E050000 */ lw $a1, ($s0) -/* FC720 802D7D70 26100004 */ addiu $s0, $s0, 4 -/* FC724 802D7D74 0220202D */ daddu $a0, $s1, $zero -/* FC728 802D7D78 0C0B1EAF */ jal get_variable -/* FC72C 802D7D7C 0040982D */ daddu $s3, $v0, $zero -/* FC730 802D7D80 8E050000 */ lw $a1, ($s0) -/* FC734 802D7D84 26100004 */ addiu $s0, $s0, 4 -/* FC738 802D7D88 0220202D */ daddu $a0, $s1, $zero -/* FC73C 802D7D8C 0C0B1EAF */ jal get_variable -/* FC740 802D7D90 0040902D */ daddu $s2, $v0, $zero -/* FC744 802D7D94 0220202D */ daddu $a0, $s1, $zero -/* FC748 802D7D98 8E050000 */ lw $a1, ($s0) -/* FC74C 802D7D9C 0C0B1EAF */ jal get_variable -/* FC750 802D7DA0 0040882D */ daddu $s1, $v0, $zero -/* FC754 802D7DA4 3C04802E */ lui $a0, 0x802e -/* FC758 802D7DA8 24849D50 */ addiu $a0, $a0, -0x62b0 -/* FC75C 802D7DAC 24050001 */ addiu $a1, $zero, 1 -/* FC760 802D7DB0 0040802D */ daddu $s0, $v0, $zero -/* FC764 802D7DB4 0C0B0CF8 */ jal start_script -/* FC768 802D7DB8 0000302D */ daddu $a2, $zero, $zero -/* FC76C 802D7DBC 0040182D */ daddu $v1, $v0, $zero -/* FC770 802D7DC0 AC760084 */ sw $s6, 0x84($v1) -/* FC774 802D7DC4 AC750088 */ sw $s5, 0x88($v1) -/* FC778 802D7DC8 AC74008C */ sw $s4, 0x8c($v1) -/* FC77C 802D7DCC AC730090 */ sw $s3, 0x90($v1) -/* FC780 802D7DD0 AC720094 */ sw $s2, 0x94($v1) -/* FC784 802D7DD4 AC710098 */ sw $s1, 0x98($v1) -/* FC788 802D7DD8 AC70009C */ sw $s0, 0x9c($v1) -/* FC78C 802D7DDC 8FBF002C */ lw $ra, 0x2c($sp) -/* FC790 802D7DE0 8FB60028 */ lw $s6, 0x28($sp) -/* FC794 802D7DE4 8FB50024 */ lw $s5, 0x24($sp) -/* FC798 802D7DE8 8FB40020 */ lw $s4, 0x20($sp) -/* FC79C 802D7DEC 8FB3001C */ lw $s3, 0x1c($sp) -/* FC7A0 802D7DF0 8FB20018 */ lw $s2, 0x18($sp) -/* FC7A4 802D7DF4 8FB10014 */ lw $s1, 0x14($sp) -/* FC7A8 802D7DF8 8FB00010 */ lw $s0, 0x10($sp) -/* FC7AC 802D7DFC 24020002 */ addiu $v0, $zero, 2 -/* FC7B0 802D7E00 03E00008 */ jr $ra -/* FC7B4 802D7E04 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/include/variables.h b/include/variables.h index ccdc405f99..1adaf1c1ef 100644 --- a/include/variables.h +++ b/include/variables.h @@ -164,5 +164,6 @@ extern s32 mapScriptLibVram; extern Bytecode* SCRIPT_NpcDefeat; extern Bytecode* ShakeCam1; extern Bytecode* ShakeCamX; +extern Bytecode* D_802D9D50; #endif diff --git a/src/code_FBE10.c b/src/code_FBE10.c index 559197088e..c2ee2333cc 100644 --- a/src/code_FBE10.c +++ b/src/code_FBE10.c @@ -67,7 +67,27 @@ ApiStatus func_802D7B74(ScriptInstance* script, s32 isInitialCall) { INCLUDE_ASM(s32, "code_FBE10", func_802D7BA4); -INCLUDE_ASM(s32, "code_FBE10", func_802D7CF8); +ApiStatus func_802D7CF8(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 var0 = get_variable(script, *args++); + s32 var1 = get_variable(script, *args++); + s32 var2 = get_variable(script, *args++); + s32 var3 = get_variable(script, *args++); + s32 var4 = get_variable(script, *args++); + s32 var5 = get_variable(script, *args++); + s32 var6 = get_variable(script, *args++); + ScriptInstance* newScript = start_script(&D_802D9D50, 1, 0); + + newScript->varTable[0] = var0; + newScript->varTable[1] = var1; + newScript->varTable[2] = var2; + newScript->varTable[3] = var3; + newScript->varTable[4] = var4; + newScript->varTable[5] = var5; + newScript->varTable[6] = var6; + + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_FBE10", func_802D7E08); diff --git a/tools/symbol_addrs.txt b/tools/symbol_addrs.txt index 57d0da9329..b78c0e7827 100644 --- a/tools/symbol_addrs.txt +++ b/tools/symbol_addrs.txt @@ -1897,3 +1897,4 @@ gSpeakingActorPart;0x8029FA78 EnterWalk;0x80285960 EnemyNpcHit;0x80077F70 EnemyNpcDefeat;0x8007809C +D_802D9D50;0x802D9D50 diff --git a/undefined_syms.txt b/undefined_syms.txt index 6f335270e1..1574ba51ba 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -214,6 +214,8 @@ gWorldDynamicEntityList = 0x801543A0; gBattleDynamicEntityList = 0x801543E0; gCurrentDynamicEntityListPtr = 0x80154420; +D_802D9D50 = 0x802D9D50; + gScriptIndexList = 0x802DA898; gScriptIdList = 0x802DAA98; gScriptListCount = 0x802DAC98;