From 430ff41bc6cccfff35ae85456405c5830cdc4f45 Mon Sep 17 00:00:00 2001 From: dark-samus Date: Mon, 12 Oct 2020 21:28:01 -0400 Subject: [PATCH] lots of stuff --- .../code_e79b0_len_1920/clear_script_list.s | 77 --- .../code_e79b0_len_1920/func_802C3390.s | 26 - .../code_e79b0_len_1920/func_802C39F8.s | 4 +- .../code_e79b0_len_1920/func_802C3C10.s | 68 --- .../code_e79b0_len_1920/func_802C3EE4.s | 8 +- .../get_global_timespace.s | 7 - .../code_e79b0_len_1920/init_script_list.s | 47 -- .../code_e79b0_len_1920/kill_script.s | 105 ---- .../set_global_timespace.s | 7 - .../code_e79b0_len_1920/sort_scripts.s | 16 +- .../code_e79b0_len_1920/start_child_script.s | 4 +- .../code_e79b0_len_1920/start_script.s | 4 +- .../start_script_in_group.s | 4 +- .../code_e79b0_len_1920/update_scripts.s | 4 +- include/common_structs.h | 7 +- include/functions.h | 3 + include/macros.h | 27 + include/variables.h | 23 +- papermario.ld | 11 +- src/code_42e0_len_1f60.c | 2 +- src/code_e79b0_len_1920.c | 505 +++++++++++++++--- src/code_e92d0_len_5da0.c | 3 +- tools/splat.yaml | 5 +- undefined_syms.txt | 12 +- 24 files changed, 525 insertions(+), 454 deletions(-) delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/init_script_list.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/kill_script.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s diff --git a/asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s b/asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s deleted file mode 100644 index 33ac82a572..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s +++ /dev/null @@ -1,77 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel clear_script_list -/* E7B8C 802C31DC 3C028007 */ lui $v0, %hi(gGameStatusPtr) -/* E7B90 802C31E0 8C42419C */ lw $v0, %lo(gGameStatusPtr)($v0) -/* E7B94 802C31E4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E7B98 802C31E8 AFBF0010 */ sw $ra, 0x10($sp) -/* E7B9C 802C31EC 80420070 */ lb $v0, 0x70($v0) -/* E7BA0 802C31F0 1440000D */ bnez $v0, .L802C3228 -/* E7BA4 802C31F4 00000000 */ nop -/* E7BA8 802C31F8 3C02802E */ lui $v0, %hi(gWorldScriptList) -/* E7BAC 802C31FC 2442A490 */ addiu $v0, $v0, %lo(gWorldScriptList) -/* E7BB0 802C3200 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7BB4 802C3204 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7BB8 802C3208 3C02802E */ lui $v0, 0x802e -/* E7BBC 802C320C 2442BCA8 */ addiu $v0, $v0, -0x4358 -/* E7BC0 802C3210 3C01802E */ lui $at, %hi(gMapVars) -/* E7BC4 802C3214 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7BC8 802C3218 3C02802E */ lui $v0, 0x802e -/* E7BCC 802C321C 2442BC70 */ addiu $v0, $v0, -0x4390 -/* E7BD0 802C3220 080B0C94 */ j .L802C3250 -/* E7BD4 802C3224 00000000 */ nop -.L802C3228: -/* E7BD8 802C3228 3C02802E */ lui $v0, %hi(gBattleScriptList) -/* E7BDC 802C322C 2442A690 */ addiu $v0, $v0, %lo(gBattleScriptList) -/* E7BE0 802C3230 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7BE4 802C3234 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7BE8 802C3238 3C02802E */ lui $v0, 0x802e -/* E7BEC 802C323C 2442BCE8 */ addiu $v0, $v0, -0x4318 -/* E7BF0 802C3240 3C01802E */ lui $at, %hi(gMapVars) -/* E7BF4 802C3244 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7BF8 802C3248 3C02802E */ lui $v0, 0x802e -/* E7BFC 802C324C 2442BD34 */ addiu $v0, $v0, -0x42cc -.L802C3250: -/* E7C00 802C3250 3C01802E */ lui $at, %hi(gMapFlags) -/* E7C04 802C3254 AC22A480 */ sw $v0, %lo(gMapFlags)($at) -/* E7C08 802C3258 3C02802E */ lui $v0, %hi(gCurrentScriptListPtr) -/* E7C0C 802C325C 8C42A890 */ lw $v0, %lo(gCurrentScriptListPtr)($v0) -/* E7C10 802C3260 2403007F */ addiu $v1, $zero, 0x7f -/* E7C14 802C3264 244201FC */ addiu $v0, $v0, 0x1fc -.L802C3268: -/* E7C18 802C3268 AC400000 */ sw $zero, ($v0) -/* E7C1C 802C326C 2463FFFF */ addiu $v1, $v1, -1 -/* E7C20 802C3270 0461FFFD */ bgez $v1, .L802C3268 -/* E7C24 802C3274 2442FFFC */ addiu $v0, $v0, -4 -/* E7C28 802C3278 3C02802E */ lui $v0, %hi(gMapVars) -/* E7C2C 802C327C 8C42A484 */ lw $v0, %lo(gMapVars)($v0) -/* E7C30 802C3280 2403000F */ addiu $v1, $zero, 0xf -/* E7C34 802C3284 3C01802E */ lui $at, %hi(gNumScripts) -/* E7C38 802C3288 AC20A488 */ sw $zero, %lo(gNumScripts)($at) -/* E7C3C 802C328C 3C01802E */ lui $at, %hi(gScriptListCount) -/* E7C40 802C3290 AC20AC98 */ sw $zero, %lo(gScriptListCount)($at) -/* E7C44 802C3294 3C01802E */ lui $at, %hi(D_802D9CA4) -/* E7C48 802C3298 AC209CA4 */ sw $zero, %lo(D_802D9CA4)($at) -/* E7C4C 802C329C 2442003C */ addiu $v0, $v0, 0x3c -.L802C32A0: -/* E7C50 802C32A0 AC400000 */ sw $zero, ($v0) -/* E7C54 802C32A4 2463FFFF */ addiu $v1, $v1, -1 -/* E7C58 802C32A8 0461FFFD */ bgez $v1, .L802C32A0 -/* E7C5C 802C32AC 2442FFFC */ addiu $v0, $v0, -4 -/* E7C60 802C32B0 3C02802E */ lui $v0, %hi(gMapFlags) -/* E7C64 802C32B4 8C42A480 */ lw $v0, %lo(gMapFlags)($v0) -/* E7C68 802C32B8 24030002 */ addiu $v1, $zero, 2 -/* E7C6C 802C32BC 24420008 */ addiu $v0, $v0, 8 -.L802C32C0: -/* E7C70 802C32C0 AC400000 */ sw $zero, ($v0) -/* E7C74 802C32C4 2463FFFF */ addiu $v1, $v1, -1 -/* E7C78 802C32C8 0461FFFD */ bgez $v1, .L802C32C0 -/* E7C7C 802C32CC 2442FFFC */ addiu $v0, $v0, -4 -/* E7C80 802C32D0 0C0B5122 */ jal func_802D4488 -/* E7C84 802C32D4 00000000 */ nop -/* E7C88 802C32D8 0C0B352D */ jal func_802CD4B4 -/* E7C8C 802C32DC 00000000 */ nop -/* E7C90 802C32E0 8FBF0010 */ lw $ra, 0x10($sp) -/* E7C94 802C32E4 03E00008 */ jr $ra -/* E7C98 802C32E8 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s deleted file mode 100644 index a44d4258fb..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802C3390 -/* E7D40 802C3390 3C03800A */ lui $v1, %hi(D_8009A5D8) -/* E7D44 802C3394 8C63A5D8 */ lw $v1, %lo(D_8009A5D8)($v1) -/* E7D48 802C3398 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E7D4C 802C339C 2C620005 */ sltiu $v0, $v1, 5 -/* E7D50 802C33A0 1040000C */ beqz $v0, .L802C33D4 -/* E7D54 802C33A4 AFBF0010 */ sw $ra, 0x10($sp) -/* E7D58 802C33A8 00031080 */ sll $v0, $v1, 2 -/* E7D5C 802C33AC 3C01802E */ lui $at, 0x802e -/* E7D60 802C33B0 00220821 */ addu $at, $at, $v0 -/* E7D64 802C33B4 8C229D80 */ lw $v0, -0x6280($at) -/* E7D68 802C33B8 00400008 */ jr $v0 -/* E7D6C 802C33BC 00000000 */ nop -/* E7D70 802C33C0 080B0CF3 */ j .L802C33CC -/* E7D74 802C33C4 24040001 */ addiu $a0, $zero, 1 -/* E7D78 802C33C8 24040002 */ addiu $a0, $zero, 2 -.L802C33CC: -/* E7D7C 802C33CC 0C0B117A */ jal suspend_all_group -/* E7D80 802C33D0 00000000 */ nop -.L802C33D4: -/* E7D84 802C33D4 8FBF0010 */ lw $ra, 0x10($sp) -/* E7D88 802C33D8 03E00008 */ jr $ra -/* E7D8C 802C33DC 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s index b4153908fc..6254775f2f 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s +++ b/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s @@ -124,9 +124,9 @@ glabel func_802C39F8 /* E8564 802C3BB4 8E030144 */ lw $v1, 0x144($s0) /* E8568 802C3BB8 24420001 */ addiu $v0, $v0, 1 /* E856C 802C3BBC ACA20000 */ sw $v0, ($a1) -/* E8570 802C3BC0 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E8570 802C3BC0 3C01802E */ lui $at, %hi(gScriptIdList) /* E8574 802C3BC4 00240821 */ addu $at, $at, $a0 -/* E8578 802C3BC8 AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E8578 802C3BC8 AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C3BCC: /* E857C 802C3BCC 3C03802E */ lui $v1, 0x802e /* E8580 802C3BD0 24639CA0 */ addiu $v1, $v1, -0x6360 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s deleted file mode 100644 index 6350130a99..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s +++ /dev/null @@ -1,68 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802C3C10 -/* E85C0 802C3C10 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* E85C4 802C3C14 AFB10014 */ sw $s1, 0x14($sp) -/* E85C8 802C3C18 0080882D */ daddu $s1, $a0, $zero -/* E85CC 802C3C1C AFBF0018 */ sw $ra, 0x18($sp) -/* E85D0 802C3C20 AFB00010 */ sw $s0, 0x10($sp) -/* E85D4 802C3C24 92220000 */ lbu $v0, ($s1) -/* E85D8 802C3C28 3C013F80 */ lui $at, 0x3f80 -/* E85DC 802C3C2C 44810000 */ mtc1 $at, $f0 -/* E85E0 802C3C30 8E240060 */ lw $a0, 0x60($s1) -/* E85E4 802C3C34 AE250008 */ sw $a1, 8($s1) -/* E85E8 802C3C38 AE25015C */ sw $a1, 0x15c($s1) -/* E85EC 802C3C3C AE250164 */ sw $a1, 0x164($s1) -/* E85F0 802C3C40 A2200002 */ sb $zero, 2($s1) -/* E85F4 802C3C44 AE200154 */ sw $zero, 0x154($s1) -/* E85F8 802C3C48 00461025 */ or $v0, $v0, $a2 -/* E85FC 802C3C4C A2220000 */ sb $v0, ($s1) -/* E8600 802C3C50 10800004 */ beqz $a0, .L802C3C64 -/* E8604 802C3C54 E6200150 */ swc1 $f0, 0x150($s1) -/* E8608 802C3C58 0C00AB4B */ jal heap_free -/* E860C 802C3C5C 00000000 */ nop -/* E8610 802C3C60 AE200060 */ sw $zero, 0x60($s1) -.L802C3C64: -/* E8614 802C3C64 8E240068 */ lw $a0, 0x68($s1) -/* E8618 802C3C68 10800003 */ beqz $a0, .L802C3C78 -/* E861C 802C3C6C 0000802D */ daddu $s0, $zero, $zero -/* E8620 802C3C70 0C0B0FCF */ jal kill_script -/* E8624 802C3C74 00000000 */ nop -.L802C3C78: -/* E8628 802C3C78 3C03802E */ lui $v1, %hi(gCurrentScriptListPtr) -/* E862C 802C3C7C 8C63A890 */ lw $v1, %lo(gCurrentScriptListPtr)($v1) -/* E8630 802C3C80 00101080 */ sll $v0, $s0, 2 -/* E8634 802C3C84 00431021 */ addu $v0, $v0, $v1 -/* E8638 802C3C88 8C440000 */ lw $a0, ($v0) -/* E863C 802C3C8C 10800006 */ beqz $a0, .L802C3CA8 -/* E8640 802C3C90 26100001 */ addiu $s0, $s0, 1 -/* E8644 802C3C94 8C82006C */ lw $v0, 0x6c($a0) -/* E8648 802C3C98 14510003 */ bne $v0, $s1, .L802C3CA8 -/* E864C 802C3C9C 00000000 */ nop -/* E8650 802C3CA0 0C0B0FCF */ jal kill_script -/* E8654 802C3CA4 00000000 */ nop -.L802C3CA8: -/* E8658 802C3CA8 2A020080 */ slti $v0, $s0, 0x80 -/* E865C 802C3CAC 1440FFF2 */ bnez $v0, .L802C3C78 -/* E8660 802C3CB0 2402FFFF */ addiu $v0, $zero, -1 -/* E8664 802C3CB4 A2220006 */ sb $v0, 6($s1) -/* E8668 802C3CB8 A2220007 */ sb $v0, 7($s1) -/* E866C 802C3CBC 3C01802E */ lui $at, 0x802e -/* E8670 802C3CC0 C4209CA8 */ lwc1 $f0, -0x6358($at) -/* E8674 802C3CC4 0220202D */ daddu $a0, $s1, $zero -/* E8678 802C3CC8 AE200064 */ sw $zero, 0x64($s1) -/* E867C 802C3CCC AE20006C */ sw $zero, 0x6c($s1) -/* E8680 802C3CD0 AE200068 */ sw $zero, 0x68($s1) -/* E8684 802C3CD4 AE200154 */ sw $zero, 0x154($s1) -/* E8688 802C3CD8 AE200158 */ sw $zero, 0x158($s1) -/* E868C 802C3CDC 0C0B0C52 */ jal find_script_labels -/* E8690 802C3CE0 E6200150 */ swc1 $f0, 0x150($s1) -/* E8694 802C3CE4 0C0B0CE4 */ jal func_802C3390 -/* E8698 802C3CE8 0220202D */ daddu $a0, $s1, $zero -/* E869C 802C3CEC 0220102D */ daddu $v0, $s1, $zero -/* E86A0 802C3CF0 8FBF0018 */ lw $ra, 0x18($sp) -/* E86A4 802C3CF4 8FB10014 */ lw $s1, 0x14($sp) -/* E86A8 802C3CF8 8FB00010 */ lw $s0, 0x10($sp) -/* E86AC 802C3CFC 03E00008 */ jr $ra -/* E86B0 802C3D00 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s index 02a85ee021..ca3c1d52e1 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s +++ b/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s @@ -9,10 +9,10 @@ glabel func_802C3EE4 /* E88A4 802C3EF4 3C08802E */ lui $t0, %hi(gCurrentScriptListPtr) /* E88A8 802C3EF8 8D08A890 */ lw $t0, %lo(gCurrentScriptListPtr)($t0) /* E88AC 802C3EFC 0040382D */ daddu $a3, $v0, $zero -/* E88B0 802C3F00 3C06802E */ lui $a2, %hi(gScriptIndexList) -/* E88B4 802C3F04 24C6AA98 */ addiu $a2, $a2, %lo(gScriptIndexList) -/* E88B8 802C3F08 3C05802E */ lui $a1, 0x802e -/* E88BC 802C3F0C 24A5A898 */ addiu $a1, $a1, -0x5768 +/* E88B0 802C3F00 3C06802E */ lui $a2, %hi(gScriptIdList) +/* E88B4 802C3F04 24C6AA98 */ addiu $a2, $a2, %lo(gScriptIdList) +/* E88B8 802C3F08 3C05802E */ lui $a1, %hi(gScriptIndexList) +/* E88BC 802C3F0C 24A5A898 */ addiu $a1, $a1, %lo(gScriptIndexList) .L802C3F10: /* E88C0 802C3F10 8CA20000 */ lw $v0, ($a1) /* E88C4 802C3F14 00021080 */ sll $v0, $v0, 2 diff --git a/asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s b/asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s deleted file mode 100644 index 18737723e5..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s +++ /dev/null @@ -1,7 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel get_global_timespace -/* E8BBC 802C420C 3C01802E */ lui $at, 0x802e -/* E8BC0 802C4210 03E00008 */ jr $ra -/* E8BC4 802C4214 C4209CA8 */ lwc1 $f0, -0x6358($at) diff --git a/asm/nonmatchings/code_e79b0_len_1920/init_script_list.s b/asm/nonmatchings/code_e79b0_len_1920/init_script_list.s deleted file mode 100644 index 5120057c73..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/init_script_list.s +++ /dev/null @@ -1,47 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel init_script_list -/* E7C9C 802C32EC 3C028007 */ lui $v0, %hi(gGameStatusPtr) -/* E7CA0 802C32F0 8C42419C */ lw $v0, %lo(gGameStatusPtr)($v0) -/* E7CA4 802C32F4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E7CA8 802C32F8 AFBF0010 */ sw $ra, 0x10($sp) -/* E7CAC 802C32FC 80420070 */ lb $v0, 0x70($v0) -/* E7CB0 802C3300 1440000D */ bnez $v0, .L802C3338 -/* E7CB4 802C3304 00000000 */ nop -/* E7CB8 802C3308 3C02802E */ lui $v0, %hi(gWorldScriptList) -/* E7CBC 802C330C 2442A490 */ addiu $v0, $v0, %lo(gWorldScriptList) -/* E7CC0 802C3310 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7CC4 802C3314 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7CC8 802C3318 3C02802E */ lui $v0, 0x802e -/* E7CCC 802C331C 2442BCA8 */ addiu $v0, $v0, -0x4358 -/* E7CD0 802C3320 3C01802E */ lui $at, %hi(gMapVars) -/* E7CD4 802C3324 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7CD8 802C3328 3C02802E */ lui $v0, 0x802e -/* E7CDC 802C332C 2442BC70 */ addiu $v0, $v0, -0x4390 -/* E7CE0 802C3330 080B0CD8 */ j .L802C3360 -/* E7CE4 802C3334 00000000 */ nop -.L802C3338: -/* E7CE8 802C3338 3C02802E */ lui $v0, %hi(gBattleScriptList) -/* E7CEC 802C333C 2442A690 */ addiu $v0, $v0, %lo(gBattleScriptList) -/* E7CF0 802C3340 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7CF4 802C3344 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7CF8 802C3348 3C02802E */ lui $v0, 0x802e -/* E7CFC 802C334C 2442BCE8 */ addiu $v0, $v0, -0x4318 -/* E7D00 802C3350 3C01802E */ lui $at, %hi(gMapVars) -/* E7D04 802C3354 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7D08 802C3358 3C02802E */ lui $v0, 0x802e -/* E7D0C 802C335C 2442BD34 */ addiu $v0, $v0, -0x42cc -.L802C3360: -/* E7D10 802C3360 3C01802E */ lui $at, %hi(gMapFlags) -/* E7D14 802C3364 AC22A480 */ sw $v0, %lo(gMapFlags)($at) -/* E7D18 802C3368 3C01802E */ lui $at, %hi(gNumScripts) -/* E7D1C 802C336C AC20A488 */ sw $zero, %lo(gNumScripts)($at) -/* E7D20 802C3370 3C01802E */ lui $at, %hi(D_802D9CA4) -/* E7D24 802C3374 0C0B5158 */ jal func_802D4560 -/* E7D28 802C3378 AC209CA4 */ sw $zero, %lo(D_802D9CA4)($at) -/* E7D2C 802C337C 0C0B355F */ jal func_802CD57C -/* E7D30 802C3380 00000000 */ nop -/* E7D34 802C3384 8FBF0010 */ lw $ra, 0x10($sp) -/* E7D38 802C3388 03E00008 */ jr $ra -/* E7D3C 802C338C 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e79b0_len_1920/kill_script.s b/asm/nonmatchings/code_e79b0_len_1920/kill_script.s deleted file mode 100644 index 95d2345aa5..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/kill_script.s +++ /dev/null @@ -1,105 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel kill_script -/* E88EC 802C3F3C 3C03802E */ lui $v1, %hi(gCurrentScriptListPtr) -/* E88F0 802C3F40 8C63A890 */ lw $v1, %lo(gCurrentScriptListPtr)($v1) -/* E88F4 802C3F44 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* E88F8 802C3F48 AFB20018 */ sw $s2, 0x18($sp) -/* E88FC 802C3F4C 0080902D */ daddu $s2, $a0, $zero -/* E8900 802C3F50 AFB00010 */ sw $s0, 0x10($sp) -/* E8904 802C3F54 0000802D */ daddu $s0, $zero, $zero -/* E8908 802C3F58 AFBF001C */ sw $ra, 0x1c($sp) -/* E890C 802C3F5C AFB10014 */ sw $s1, 0x14($sp) -.L802C3F60: -/* E8910 802C3F60 8C620000 */ lw $v0, ($v1) -/* E8914 802C3F64 10520006 */ beq $v0, $s2, .L802C3F80 -/* E8918 802C3F68 2A020080 */ slti $v0, $s0, 0x80 -/* E891C 802C3F6C 26100001 */ addiu $s0, $s0, 1 -/* E8920 802C3F70 2A020080 */ slti $v0, $s0, 0x80 -/* E8924 802C3F74 1440FFFA */ bnez $v0, .L802C3F60 -/* E8928 802C3F78 24630004 */ addiu $v1, $v1, 4 -/* E892C 802C3F7C 2A020080 */ slti $v0, $s0, 0x80 -.L802C3F80: -/* E8930 802C3F80 10400044 */ beqz $v0, .L802C4094 -/* E8934 802C3F84 00000000 */ nop -/* E8938 802C3F88 8E440068 */ lw $a0, 0x68($s2) -/* E893C 802C3F8C 10800003 */ beqz $a0, .L802C3F9C -/* E8940 802C3F90 0000882D */ daddu $s1, $zero, $zero -/* E8944 802C3F94 0C0B0FCF */ jal kill_script -/* E8948 802C3F98 00000000 */ nop -.L802C3F9C: -/* E894C 802C3F9C 3C03802E */ lui $v1, %hi(gCurrentScriptListPtr) -/* E8950 802C3FA0 8C63A890 */ lw $v1, %lo(gCurrentScriptListPtr)($v1) -/* E8954 802C3FA4 00111080 */ sll $v0, $s1, 2 -/* E8958 802C3FA8 00431021 */ addu $v0, $v0, $v1 -/* E895C 802C3FAC 8C440000 */ lw $a0, ($v0) -/* E8960 802C3FB0 10800006 */ beqz $a0, .L802C3FCC -/* E8964 802C3FB4 26310001 */ addiu $s1, $s1, 1 -/* E8968 802C3FB8 8C82006C */ lw $v0, 0x6c($a0) -/* E896C 802C3FBC 14520003 */ bne $v0, $s2, .L802C3FCC -/* E8970 802C3FC0 00000000 */ nop -/* E8974 802C3FC4 0C0B0FCF */ jal kill_script -/* E8978 802C3FC8 00000000 */ nop -.L802C3FCC: -/* E897C 802C3FCC 2A220080 */ slti $v0, $s1, 0x80 -/* E8980 802C3FD0 1440FFF2 */ bnez $v0, .L802C3F9C -/* E8984 802C3FD4 00000000 */ nop -/* E8988 802C3FD8 8E450064 */ lw $a1, 0x64($s2) -/* E898C 802C3FDC 10A00018 */ beqz $a1, .L802C4040 -/* E8990 802C3FE0 0000882D */ daddu $s1, $zero, $zero -/* E8994 802C3FE4 0240202D */ daddu $a0, $s2, $zero -/* E8998 802C3FE8 90A20000 */ lbu $v0, ($a1) -/* E899C 802C3FEC 00A0182D */ daddu $v1, $a1, $zero -/* E89A0 802C3FF0 ACA00068 */ sw $zero, 0x68($a1) -/* E89A4 802C3FF4 304200EF */ andi $v0, $v0, 0xef -/* E89A8 802C3FF8 A0A20000 */ sb $v0, ($a1) -.L802C3FFC: -/* E89AC 802C3FFC 8C820084 */ lw $v0, 0x84($a0) -/* E89B0 802C4000 24840004 */ addiu $a0, $a0, 4 -/* E89B4 802C4004 26310001 */ addiu $s1, $s1, 1 -/* E89B8 802C4008 AC620084 */ sw $v0, 0x84($v1) -/* E89BC 802C400C 2A220010 */ slti $v0, $s1, 0x10 -/* E89C0 802C4010 1440FFFA */ bnez $v0, .L802C3FFC -/* E89C4 802C4014 24630004 */ addiu $v1, $v1, 4 -/* E89C8 802C4018 0000882D */ daddu $s1, $zero, $zero -/* E89CC 802C401C 0240202D */ daddu $a0, $s2, $zero -/* E89D0 802C4020 00A0182D */ daddu $v1, $a1, $zero -.L802C4024: -/* E89D4 802C4024 8C8200C4 */ lw $v0, 0xc4($a0) -/* E89D8 802C4028 24840004 */ addiu $a0, $a0, 4 -/* E89DC 802C402C 26310001 */ addiu $s1, $s1, 1 -/* E89E0 802C4030 AC6200C4 */ sw $v0, 0xc4($v1) -/* E89E4 802C4034 2A220003 */ slti $v0, $s1, 3 -/* E89E8 802C4038 1440FFFA */ bnez $v0, .L802C4024 -/* E89EC 802C403C 24630004 */ addiu $v1, $v1, 4 -.L802C4040: -/* E89F0 802C4040 8E440060 */ lw $a0, 0x60($s2) -/* E89F4 802C4044 10800004 */ beqz $a0, .L802C4058 -/* E89F8 802C4048 00000000 */ nop -/* E89FC 802C404C 0C00AB4B */ jal heap_free -/* E8A00 802C4050 00000000 */ nop -/* E8A04 802C4054 AE400060 */ sw $zero, 0x60($s2) -.L802C4058: -/* E8A08 802C4058 3C11802E */ lui $s1, %hi(gCurrentScriptListPtr) -/* E8A0C 802C405C 2631A890 */ addiu $s1, $s1, %lo(gCurrentScriptListPtr) -/* E8A10 802C4060 8E220000 */ lw $v0, ($s1) -/* E8A14 802C4064 00108080 */ sll $s0, $s0, 2 -/* E8A18 802C4068 02021021 */ addu $v0, $s0, $v0 -/* E8A1C 802C406C 0C00AB4B */ jal heap_free -/* E8A20 802C4070 8C440000 */ lw $a0, ($v0) -/* E8A24 802C4074 3C04802E */ lui $a0, %hi(gNumScripts) -/* E8A28 802C4078 2484A488 */ addiu $a0, $a0, %lo(gNumScripts) -/* E8A2C 802C407C 8E230000 */ lw $v1, ($s1) -/* E8A30 802C4080 8C820000 */ lw $v0, ($a0) -/* E8A34 802C4084 02038021 */ addu $s0, $s0, $v1 -/* E8A38 802C4088 2442FFFF */ addiu $v0, $v0, -1 -/* E8A3C 802C408C AE000000 */ sw $zero, ($s0) -/* E8A40 802C4090 AC820000 */ sw $v0, ($a0) -.L802C4094: -/* E8A44 802C4094 8FBF001C */ lw $ra, 0x1c($sp) -/* E8A48 802C4098 8FB20018 */ lw $s2, 0x18($sp) -/* E8A4C 802C409C 8FB10014 */ lw $s1, 0x14($sp) -/* E8A50 802C40A0 8FB00010 */ lw $s0, 0x10($sp) -/* E8A54 802C40A4 03E00008 */ jr $ra -/* E8A58 802C40A8 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s b/asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s deleted file mode 100644 index cca1cb0612..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s +++ /dev/null @@ -1,7 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel set_global_timespace -/* E8BB0 802C4200 3C01802E */ lui $at, 0x802e -/* E8BB4 802C4204 03E00008 */ jr $ra -/* E8BB8 802C4208 E42C9CA8 */ swc1 $f12, -0x6358($at) diff --git a/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s b/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s index 602f3f5cc6..cab05f9a45 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s +++ b/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s @@ -5,12 +5,12 @@ glabel sort_scripts /* E79B0 802C3000 27BDFFF8 */ addiu $sp, $sp, -8 /* E79B4 802C3004 0000682D */ daddu $t5, $zero, $zero /* E79B8 802C3008 01A0482D */ daddu $t1, $t5, $zero -/* E79BC 802C300C 3C05802E */ lui $a1, %hi(gScriptIndexList) -/* E79C0 802C3010 24A5AA98 */ addiu $a1, $a1, %lo(gScriptIndexList) +/* E79BC 802C300C 3C05802E */ lui $a1, %hi(gScriptIdList) +/* E79C0 802C3010 24A5AA98 */ addiu $a1, $a1, %lo(gScriptIdList) /* E79C4 802C3014 3C06802E */ lui $a2, %hi(gCurrentScriptListPtr) /* E79C8 802C3018 8CC6A890 */ lw $a2, %lo(gCurrentScriptListPtr)($a2) -/* E79CC 802C301C 3C04802E */ lui $a0, 0x802e -/* E79D0 802C3020 2484A898 */ addiu $a0, $a0, -0x5768 +/* E79CC 802C301C 3C04802E */ lui $a0, %hi(gScriptIndexList) +/* E79D0 802C3020 2484A898 */ addiu $a0, $a0, %lo(gScriptIndexList) /* E79D4 802C3024 AFB00000 */ sw $s0, ($sp) .L802C3028: /* E79D8 802C3028 8CC30000 */ lw $v1, ($a2) @@ -37,11 +37,11 @@ glabel sort_scripts /* E7A28 802C3078 0000482D */ daddu $t1, $zero, $zero /* E7A2C 802C307C 3C10802E */ lui $s0, %hi(gCurrentScriptListPtr) /* E7A30 802C3080 2610A890 */ addiu $s0, $s0, %lo(gCurrentScriptListPtr) -/* E7A34 802C3084 3C0E802E */ lui $t6, %hi(gScriptIndexList) -/* E7A38 802C3088 25CEAA98 */ addiu $t6, $t6, %lo(gScriptIndexList) +/* E7A34 802C3084 3C0E802E */ lui $t6, %hi(gScriptIdList) +/* E7A38 802C3088 25CEAA98 */ addiu $t6, $t6, %lo(gScriptIdList) /* E7A3C 802C308C 01C0C82D */ daddu $t9, $t6, $zero -/* E7A40 802C3090 3C18802E */ lui $t8, 0x802e -/* E7A44 802C3094 2718A898 */ addiu $t8, $t8, -0x5768 +/* E7A40 802C3090 3C18802E */ lui $t8, %hi(gScriptIndexList) +/* E7A44 802C3094 2718A898 */ addiu $t8, $t8, %lo(gScriptIndexList) /* E7A48 802C3098 0300782D */ daddu $t7, $t8, $zero .L802C309C: /* E7A4C 802C309C 25280001 */ addiu $t0, $t1, 1 diff --git a/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s b/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s index 5904de2185..9cb10702eb 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s +++ b/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s @@ -129,9 +129,9 @@ glabel start_child_script /* E8348 802C3998 8E030144 */ lw $v1, 0x144($s0) /* E834C 802C399C 24420001 */ addiu $v0, $v0, 1 /* E8350 802C39A0 ACA20000 */ sw $v0, ($a1) -/* E8354 802C39A4 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E8354 802C39A4 3C01802E */ lui $at, %hi(gScriptIdList) /* E8358 802C39A8 00240821 */ addu $at, $at, $a0 -/* E835C 802C39AC AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E835C 802C39AC AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C39B0: /* E8360 802C39B0 0C0B0CE4 */ jal func_802C3390 /* E8364 802C39B4 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_e79b0_len_1920/start_script.s b/asm/nonmatchings/code_e79b0_len_1920/start_script.s index fabdad9d00..371bfd3a7d 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/start_script.s +++ b/asm/nonmatchings/code_e79b0_len_1920/start_script.s @@ -113,9 +113,9 @@ glabel start_script /* E7F20 802C3570 8E030144 */ lw $v1, 0x144($s0) /* E7F24 802C3574 24420001 */ addiu $v0, $v0, 1 /* E7F28 802C3578 ACA20000 */ sw $v0, ($a1) -/* E7F2C 802C357C 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E7F2C 802C357C 3C01802E */ lui $at, %hi(gScriptIdList) /* E7F30 802C3580 00240821 */ addu $at, $at, $a0 -/* E7F34 802C3584 AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E7F34 802C3584 AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C3588: /* E7F38 802C3588 0C0B0CE4 */ jal func_802C3390 /* E7F3C 802C358C 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s b/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s index 0a97ca5c66..022a1a52a4 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s +++ b/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s @@ -114,9 +114,9 @@ glabel start_script_in_group /* E8114 802C3764 8E030144 */ lw $v1, 0x144($s0) /* E8118 802C3768 24420001 */ addiu $v0, $v0, 1 /* E811C 802C376C ACA20000 */ sw $v0, ($a1) -/* E8120 802C3770 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E8120 802C3770 3C01802E */ lui $at, %hi(gScriptIdList) /* E8124 802C3774 00240821 */ addu $at, $at, $a0 -/* E8128 802C3778 AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E8128 802C3778 AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C377C: /* E812C 802C377C 0C0B0CE4 */ jal func_802C3390 /* E8130 802C3780 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s b/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s index 04e8a89585..f9dd62f99f 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s +++ b/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s @@ -30,8 +30,8 @@ glabel update_scripts /* E8788 802C3DD8 4481A800 */ mtc1 $at, $f21 /* E878C 802C3DDC 4480A000 */ mtc1 $zero, $f20 /* E8790 802C3DE0 2415FFFF */ addiu $s5, $zero, -1 -/* E8794 802C3DE4 3C14802E */ lui $s4, %hi(gScriptIndexList) -/* E8798 802C3DE8 2694AA98 */ addiu $s4, $s4, %lo(gScriptIndexList) +/* E8794 802C3DE4 3C14802E */ lui $s4, %hi(gScriptIdList) +/* E8798 802C3DE8 2694AA98 */ addiu $s4, $s4, %lo(gScriptIdList) /* E879C 802C3DEC 3C13802E */ lui $s3, 0x802e /* E87A0 802C3DF0 2673A898 */ addiu $s3, $s3, -0x5768 .L802C3DF4: diff --git a/include/common_structs.h b/include/common_structs.h index e536e75fa0..acc21fe13a 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1,6 +1,7 @@ #ifndef _COMMON_STRUCTS_H_ #define _COMMON_STRUCTS_H_ +#include "macros.h" #include "ultra64.h" #include "types.h" #include "si.h" @@ -238,9 +239,9 @@ typedef struct ScriptInstance { /* 0x007 */ s8 switchDepth; /* how many nested switches we are in, max = 8 */ /* 0x008 */ Bytecode* ptrNextLine; /* 0x00C */ Bytecode* ptrReadPos; - /* 0x010 */ u8 labelIndices[16]; + /* 0x010 */ s8 labelIndices[16]; /* 0x020 */ UNK_PTR labelPositions[16]; - /* 0x060 */ s32 deleted; /* set to zero in KillScript when malloc'd */ + /* 0x060 */ UNK_PTR unk_60; /* unknown pointer; allocated on the heap, free'd in kill_script() */ /* 0x064 */ struct ScriptInstance* blockingParent; /* parent? */ /* 0x068 */ struct ScriptInstance* childScript; /* 0x06C */ struct ScriptInstance* parentScript; /* brother? */ @@ -266,6 +267,8 @@ typedef struct ScriptInstance { /* 0x164 */ Bytecode* ptrCurrentLine; } ScriptInstance; // size = 0x168 +typedef ScriptInstance* ScriptList[MAX_SCRIPTS]; + typedef struct Entity { /* 0x00 */ s32 flags; /* 0x04 */ char unk_04[2]; diff --git a/include/functions.h b/include/functions.h index d341ad3357..b05ab55056 100644 --- a/include/functions.h +++ b/include/functions.h @@ -82,4 +82,7 @@ s32 set_music_track(s32 musicPlayer, s32 songID, s32 variation, s32 unk, s32 vol ScriptInstance* get_script_by_index(s32 index); +void suspend_all_group(s32 groupFlags); +void kill_script(ScriptInstance* instanceToKill); + #endif diff --git a/include/macros.h b/include/macros.h index 79b7384cb4..43e52c1882 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,6 +1,8 @@ #ifndef _MACROS_H_ #define _MACROS_H_ +#include "common.h" + #ifndef SPLAT #define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...) \ TYPE __attribute__((naked)) NAME(ARGS) { __asm__( ".include \"include/macro.inc\"\n.include \"asm/nonmatchings/"FOLDER"/"#NAME".s\"\n.set reorder\n.set at"); } @@ -16,6 +18,31 @@ #define GAME_STATUS (*gGameStatusPtr) +#define MAX_MAPVARS 16 +#define MAX_MAPFLAGS 3 + +#define MAX_SCRIPTS 128 + +//NOTE: SCRIPT_ALLOC is probably not quite correct, but this is the closest thing to matching for the functions its used in. Needs more work. +#define SCRIPT_ALLOC(new, index) \ +{ \ + ScriptList** temp = &gCurrentScriptListPtr; \ + s32 *numScripts = &gNumScripts; \ + new = heap_malloc(sizeof(ScriptInstance)); \ + (**temp)[index] = new; \ + (*numScripts)++; \ + ASSERT(new != NULL); \ +} + +#define SCRIPT_FREE(index) \ +{ \ + ScriptList** temp = &gCurrentScriptListPtr; \ + s32 *numScripts = &gNumScripts; \ + heap_free((**temp)[index]); \ + (**temp)[index] = NULL; \ + (*numScripts)--; \ +} + #define SQ(x) (x*x) #endif diff --git a/include/variables.h b/include/variables.h index 909c23c37a..a713ed7d9b 100644 --- a/include/variables.h +++ b/include/variables.h @@ -4,6 +4,7 @@ #include "ultra64.h" #include "common_structs.h" #include "types.h" +#include "macros.h" #include "enums.h" extern UiStatus gUIStatus; @@ -20,19 +21,17 @@ extern UNK_FUN_PTR(gCurrentUpdateFunction); extern BattleStatus gBattleStatus; -extern ScriptInstance* gWorldScriptList[128]; -extern ScriptInstance* gBattleScriptList[128]; -extern ScriptInstance** gCurrentScriptListPtr[128]; +extern ScriptList gWorldScriptList; +extern ScriptList gBattleScriptList; +extern ScriptList* gCurrentScriptListPtr; -extern s32 gStaticScriptCounter; -extern s32 D_802D9CA4; extern s32 gNumScripts; extern s32 D_802DAC98; extern s32 gScriptListCount; -extern s32 gScriptIdList[128]; -extern s32 gScriptIndexList[128]; +extern s32 gScriptIdList[MAX_SCRIPTS]; +extern s32 gScriptIndexList[MAX_SCRIPTS]; extern Model* gWorldModelList[256]; extern Model* gBattleModelList[256]; @@ -61,8 +60,6 @@ extern Shadow** gCurrentShadowListPtr[60]; extern Camera gCameras[4]; extern s32 gCurrentCameraID; -extern f32 gGlobalTimeSpace; - extern Npc* gPlayerNpcPtr; extern s8 D_800A0900; @@ -124,4 +121,12 @@ extern s32 gNumScripts; extern f32 D_80286540; +extern u32 gWorldMapVars[MAX_MAPVARS]; +extern u32 gBattleMapVars[MAX_MAPVARS]; + +extern u32 gWorldMapFlags[MAX_MAPFLAGS]; +extern u32 gBattleMapFlags[MAX_MAPFLAGS]; + +extern s32 D_8009A5D8; + #endif diff --git a/papermario.ld b/papermario.ld index 1252064ba6..e2d636069f 100644 --- a/papermario.ld +++ b/papermario.ld @@ -214,7 +214,7 @@ SECTIONS build/bin/code_E5830.o(.data); } - /* 0x802C3000 E79B0-FEE30 (len 17480) */ + /* 0x802C3000 E79B0-FE748 (len 16D98) */ .text_E79B0 0x802C3000 : AT(0xE79B0) { build/src/code_e79b0_len_1920.o(.text); build/src/code_e92d0_len_5da0.o(.text); @@ -225,7 +225,14 @@ SECTIONS build/src/code_f8f60_len_1560.o(.text); build/src/code_fa4c0_len_3bf0.o(.text); build/src/code_fe0b0_len_5a0.o(.text); - build/bin/code_FE650.o(.data); + build/src/code_e79b0_len_1920.o(.data); + build/bin/code_FE660.o(.data); + build/src/code_e79b0_len_1920.o(.rodata); + } + + /* 0x00000000 FE748-FEE30 [6E8] */ + .data_FE748 0xFE748 : AT(0xFE748) { + build/bin/FE748.o(.data); } /* 0x802DBD40 FEE30-102610 (len 37E0) */ diff --git a/src/code_42e0_len_1f60.c b/src/code_42e0_len_1f60.c index e2d578e7de..b0e810dfc3 100644 --- a/src/code_42e0_len_1f60.c +++ b/src/code_42e0_len_1f60.c @@ -88,7 +88,7 @@ f32 signF(f32 val) { return sign; } -INCLUDE_ASM(s32, "code_42e0_len_1f60", round); +INCLUDE_ASM(s16, "code_42e0_len_1f60", round, f32 arg0); INCLUDE_ASM(f32, "code_42e0_len_1f60", clamp_angle, f32 theta); diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index 6d0c44fcff..2369ae7513 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -1,54 +1,334 @@ #include "common.h" -INCLUDE_ASM(s32, "code_e79b0_len_1920", sort_scripts); +s32 gStaticScriptCounter = 1; +s32 D_802D9CA4 = 0; +f32 gGlobalTimeSpace = 1.0f; -INCLUDE_ASM(s32, "code_e79b0_len_1920", find_script_labels); - -INCLUDE_ASM(s32, "code_e79b0_len_1920", clear_script_list); - -INCLUDE_ASM(s32, "code_e79b0_len_1920", init_script_list); - -INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C3390); - -INCLUDE_ASM(s32, "code_e79b0_len_1920", start_script); - -INCLUDE_ASM(s32, "code_e79b0_len_1920", start_script_in_group); - -INCLUDE_ASM(s32, "code_e79b0_len_1920", start_child_script); - -<<<<<<< HEAD #ifdef NON_MATCHING -//appears to be functionally equivalent, some ordering and regalloc issues -ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, s32 newState) { - ScriptInstance** curScript = gCurrentScriptListPtr; - ScriptInstance* child; - ScriptInstance** temp3; - s32* temp6; - s32 temp2; - s32 temp7; +// regalloc issues. +void sort_scripts(void) { + s32 temp_a0; + s32 temp_a1; + s32 tempID; + ScriptInstance* curScript; + ScriptList** currentScriptListPtr; + s32 i; + s32 j; + s32 numValidScripts = 0; + s32 *scriptIndexList = gScriptIndexList; + s32 *scriptIdList = gScriptIdList; + + for(i = 0; i < MAX_SCRIPTS; i++) { + curScript = (*gCurrentScriptListPtr)[i]; + if (curScript != NULL) { + if (curScript->state != 0) { + scriptIndexList[numValidScripts] = i; + scriptIdList[numValidScripts] = curScript->uniqueID; + numValidScripts++; + } + } + } + + gScriptListCount = numValidScripts; + j = numValidScripts; + for(i = 0; i < (j - 1); i++) { + currentScriptListPtr = &gCurrentScriptListPtr; + scriptIdList = gScriptIdList; + scriptIndexList = gScriptIndexList; + for(j = i + 1; j < numValidScripts; j++) { + temp_a1 = scriptIndexList[i]; + temp_a0 = scriptIndexList[j]; + if ((**currentScriptListPtr)[temp_a1]->priority > (**currentScriptListPtr)[temp_a0]->priority) { + scriptIndexList[i] = temp_a0; + scriptIndexList[j] = temp_a1; + tempID = scriptIdList[i]; + scriptIdList[i] = scriptIdList[j]; + scriptIdList[j] = tempID; + } + } + } +} +#else +INCLUDE_ASM(s32, "code_e79b0_len_1920", sort_scripts); +#endif + +#ifdef NON_MATCHING +// Very close. Reordering/branch likely issues +void find_script_labels(ScriptInstance *script) { + Bytecode *curLine; + s32 type; + s32 label; + s32 numArgs; + s32 i; + s32 j; + + for(i = 0; i < ARRAY_COUNT(script->labelIndices); i++){ + script->labelIndices[i] = -1; + script->labelPositions[i] = 0; + } + + j = 0; + curLine = script->ptrNextLine; + for(j; j < ARRAY_COUNT(script->labelIndices); j++) { + type = *curLine++; + numArgs = *curLine++; + label = *curLine; + curLine += numArgs; + + if (type == 1) { + return; + } + + if (type == 3) { + script->labelIndices[j] = label; + script->labelPositions[j] = curLine; + } + } + PANIC(); +} +#else +INCLUDE_ASM(void, "code_e79b0_len_1920", find_script_labels); +#endif + +void clear_script_list(void) { s32 i; - for(i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++){ - if (curScript[i] == NULL) { + if (GAME_STATUS->isBattle == 0) { + gCurrentScriptListPtr = &gWorldScriptList; + gMapVars = gWorldMapVars; + gMapFlags = gWorldMapFlags; + } else { + gCurrentScriptListPtr = &gBattleScriptList; + gMapVars = gBattleMapVars; + gMapFlags = gBattleMapFlags; + } + + for(i = 0; i < MAX_SCRIPTS; i++) { + (*gCurrentScriptListPtr)[i] = NULL; + } + + gNumScripts = 0; + gScriptListCount = 0; + D_802D9CA4 = 0; + + for(i = 0; i < MAX_MAPVARS; i++) { + gMapVars[i] = 0; + } + + for(i = 0; i < MAX_MAPFLAGS; i++) { + gMapFlags[i] = 0; + } + + func_802D4488(); + func_802CD4B4(); +} + +void init_script_list(void) { + + if (GAME_STATUS->isBattle == 0) { + gCurrentScriptListPtr = &gWorldScriptList; + gMapVars = gWorldMapVars; + gMapFlags = gWorldMapFlags; + } else { + gCurrentScriptListPtr = &gBattleScriptList; + gMapVars = gBattleMapVars; + gMapFlags = gBattleMapFlags; + } + + gNumScripts = 0; + D_802D9CA4 = 0; + + func_802D4560(); + func_802CD57C(); +} + +void func_802C3390(ScriptInstance* script) { + s32 arg; + switch(D_8009A5D8) { + default: + case 0: + case 4: + return; + + case 1: + arg = 1; + break; + case 2: + case 3: + arg = 2; + break; + } + suspend_all_group(arg); +} + +#ifdef NON_MATCHING +ScriptInstance* start_script(Bytecode *initialLine, u8 priority, s32 initialState) { + ScriptInstance *newScript; + s32 curScriptIndex; + s32 scriptListCount; + s32 i; + + for(i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == NULL) { break; } } - temp3 = gCurrentScriptListPtr; - ASSERT(i < ARRAY_COUNT(gCurrentScriptListPtr)); - temp2 = i; + ASSERT(i < MAX_SCRIPTS); + curScriptIndex = i; - child = heap_malloc(sizeof(ScriptInstance)); - temp3[temp2] = child; - temp7 = gNumScripts++; - ASSERT(child != NULL); + SCRIPT_ALLOC(newScript, curScriptIndex); + + newScript->state = initialState | 1; + newScript->currentOpcode = 0; + newScript->priority = priority; + newScript->ptrNextLine = initialLine; + newScript->ptrFirstLine = initialLine; + newScript->ptrCurrentLine = initialLine; + newScript->unk_60 = NULL; + newScript->blockingParent = NULL; + newScript->childScript = NULL; + newScript->parentScript = NULL; + newScript->uniqueID = gStaticScriptCounter++; + newScript->ownerActorID = -1; + newScript->ownerID = -1; + newScript->loopDepth = -1; + newScript->switchDepth = -1; + newScript->groupFlags = ~0x10; + newScript->ptrSavedPosition = NULL; + newScript->frameCounter = 0.0f; + newScript->unk_158 = 0; + newScript->timeScale = gGlobalTimeSpace; + + scriptListCount = 0; + + for(i = 0; i < 16; i++) { + newScript->varTable[i] = 0; + } + + for(i = 0; i < 3; i++){ + newScript->varFlags[i] = 0; + } + + find_script_labels(newScript); + + if ((D_802D9CA4 != 0) && ((newScript->state & 0x20) != 0)) { + scriptListCount = gScriptListCount++; + gScriptIndexList[scriptListCount] = curScriptIndex; + gScriptIdList[scriptListCount] = newScript->uniqueID; + } + func_802C3390(newScript); + { + s32* tempCounter = &gStaticScriptCounter; + if (*tempCounter == 0) { + *tempCounter = 1; + } + } + return newScript; +} +#else +INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", start_script, Bytecode *initialLine, u8 priority, s32 initialState); +#endif + +#ifdef NON_MATCHING +ScriptInstance* start_script_in_group(Bytecode* initialLine, s8 priority, s32 initialState, s8 groupFlags) { + ScriptInstance *newScript; + s32 scriptListCount; + s32 i; + s32 curScriptIndex; + s32* tempCounter; + + for(i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == NULL) { + break; + } + } + + ASSERT(i < MAX_SCRIPTS); + curScriptIndex = i; + + SCRIPT_ALLOC(newScript, curScriptIndex); + + newScript->state = (initialState | 1); + newScript->ptrNextLine = initialLine; + newScript->ptrFirstLine = initialLine; + newScript->ptrCurrentLine = initialLine; + newScript->currentOpcode = 0; + newScript->priority = priority; + newScript->unk_60 = NULL; + newScript->blockingParent = NULL; + newScript->childScript = NULL; + newScript->parentScript = NULL; + newScript->uniqueID = gStaticScriptCounter++; + newScript->ownerActorID = -1; + newScript->ownerID = -1; + newScript->loopDepth = -1; + newScript->switchDepth = -1; + newScript->groupFlags = groupFlags; + newScript->ptrSavedPosition = NULL; + newScript->frameCounter = 0.0f; + newScript->unk_158 = 0; + newScript->timeScale = gGlobalTimeSpace; + + scriptListCount = 0; + + for(i = 0; i < 16; i++) { + newScript->varTable[i] = 0; + } + + for(i = 0; i < 3; i++){ + newScript->varFlags[i] = 0; + } + + find_script_labels(newScript); + + if ((D_802D9CA4 != 0) && ((newScript->state & 0x20) != 0)) { + scriptListCount = gScriptListCount++; + gScriptIndexList[scriptListCount] = curScriptIndex; + gScriptIdList[scriptListCount] = newScript->uniqueID; + } + + func_802C3390(newScript); + { + s32* tempCounter = &gStaticScriptCounter; + if (*tempCounter == 0) { + *tempCounter = 1; + } + } + + return newScript; +} +#else +INCLUDE_ASM(s32, "code_e79b0_len_1920", start_script_in_group); +#endif + +INCLUDE_ASM(s32, "code_e79b0_len_1920", start_child_script); + +#ifdef NON_MATCHING +// appears to be functionally equivalent, some ordering and regalloc issues +ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, s32 newState) { + ScriptInstance* child; + s32* temp6; + s32 curScriptIndex; + s32 i; + s32 scriptListCount; + + for(i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == NULL) { + break; + } + } + + ASSERT(i < MAX_SCRIPTS); + curScriptIndex = i; + SCRIPT_ALLOC(child, curScriptIndex); child->state = newState | 1; child->ptrNextLine = nextLine; child->ptrFirstLine = nextLine; child->ptrCurrentLine = nextLine; child->currentOpcode = 0; - child->deleted = 0; + child->unk_60 = NULL; child->blockingParent = NULL; child->parentScript = parentScript; child->childScript = NULL; @@ -63,9 +343,11 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, child->array = parentScript->array; child->flagArray = parentScript->flagArray; child->timeScale = gGlobalTimeSpace; - child->frameCounter = 0; + child->frameCounter = 0.0f; child->unk_158 = 0; + scriptListCount = 0; + for(i = 0; i < ARRAY_COUNT(child->varTable); i++) { child->varTable[i] = parentScript->varTable[i]; } @@ -76,9 +358,9 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, find_script_labels(child); if (D_802D9CA4 != 0) { - temp7 = D_802DAC98++; - gScriptIdList[temp7] = temp2; - gScriptIndexList[temp7] = child->uniqueID; + scriptListCount = gScriptListCount++; + gScriptIndexList[scriptListCount] = curScriptIndex; + gScriptIdList[scriptListCount] = child->uniqueID; } temp6 = &gStaticScriptCounter; @@ -92,12 +374,46 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", func_802C39F8, ScriptInstance* parentScript, Bytecode* nextLine, s32 newState); #endif -INCLUDE_ASM("code_e79b0_len_1920", func_802C3C10); -======= -INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C39F8); +ScriptInstance* func_802C3C10(ScriptInstance *script, Bytecode* line, s32 arg2) { + ScriptInstance *curScript; + s32 i; -INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C3C10); ->>>>>>> 3bf3c987d710d9a78dfbc0505eb69843053cda25 + script->ptrNextLine = line; + script->ptrFirstLine = line; + script->ptrCurrentLine = line; + script->currentOpcode = 0; + script->frameCounter = 0; + script->state |= arg2; + script->timeScale = 1.0f; + + if (script->unk_60 != NULL) { + heap_free(script->unk_60); + script->unk_60 = NULL; + } + + if (script->childScript != 0) { + kill_script(script->childScript); + } + + for(i = 0; i < MAX_SCRIPTS; i++) { + curScript = (*gCurrentScriptListPtr)[i]; + if ((curScript != 0) && (curScript->parentScript == script)) { + kill_script(curScript); + } + } + script->loopDepth = -1; + script->switchDepth = -1; + script->blockingParent = NULL; + script->parentScript = NULL; + script->childScript = NULL; + script->frameCounter = 0.0f; + script->unk_158 = 0; + script->timeScale = gGlobalTimeSpace; + find_script_labels(script); + func_802C3390(script); + + return script; +} ScriptInstance* restart_script(ScriptInstance* script) { Bytecode* ptrFirstLine = script->ptrFirstLine; @@ -116,7 +432,7 @@ ScriptInstance* restart_script(ScriptInstance* script) { script->timeScale = gGlobalTimeSpace; - find_script_labels(); + find_script_labels(script); func_802C3390(script); return script; @@ -124,15 +440,66 @@ ScriptInstance* restart_script(ScriptInstance* script) { INCLUDE_ASM(s32, "code_e79b0_len_1920", update_scripts); +// this function is evil. INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C3EE4); -INCLUDE_ASM(s32, "code_e79b0_len_1920", kill_script); +void kill_script(ScriptInstance* instanceToKill) { + ScriptInstance* childScript; + ScriptInstance* blockingParent; + s32 j; + s32 i; + + for(i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == instanceToKill) { + break; + } + } + + if (i >= MAX_SCRIPTS) { + return; + } + + childScript = instanceToKill->childScript; + if (childScript != NULL) { + kill_script(childScript); + } + + for(j = 0; j < MAX_SCRIPTS; j++) { + ScriptInstance* tempScriptInstance = (*gCurrentScriptListPtr)[j]; + if (tempScriptInstance != NULL) { + if (tempScriptInstance->parentScript == instanceToKill) { + kill_script(tempScriptInstance); + } + } + } + + blockingParent = instanceToKill->blockingParent; + if (blockingParent != NULL) { + blockingParent->childScript = NULL; + blockingParent->state &= ~0x10; + + for(j = 0; j < ARRAY_COUNT(blockingParent->varTable); j++) { + blockingParent->varTable[j] = instanceToKill->varTable[j]; + } + + for(j = 0; j < ARRAY_COUNT(blockingParent->varFlags); j++) { + blockingParent->varFlags[j] = instanceToKill->varFlags[j]; + } + } + + if (instanceToKill->unk_60 != NULL) { + heap_free(instanceToKill->unk_60); + instanceToKill->unk_60 = NULL; + } + + SCRIPT_FREE(i); +} void kill_script_by_ID(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { kill_script(scriptContextPtr); @@ -140,11 +507,12 @@ void kill_script_by_ID(s32 id) { } } + void kill_all_scripts(void) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { kill_script(scriptContextPtr); @@ -156,7 +524,7 @@ s32 does_script_exist(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { return 1; @@ -168,7 +536,7 @@ s32 does_script_exist(s32 id) { s32 does_script_exist_by_ref(ScriptInstance* script) { s32 i; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { if (script == (*gCurrentScriptListPtr)[i]) { return 1; } @@ -184,23 +552,13 @@ void set_script_timescale(ScriptInstance* script, f32 timescale) { script->timeScale = timescale * gGlobalTimeSpace; } -#ifdef NON_MATCHING -// TODO: figure out why compiler/assembler isn't putting SWC1 in delay slot void set_global_timespace(f32 timeScale) { gGlobalTimeSpace = timeScale; } -#else -INCLUDE_ASM(s32, "code_e79b0_len_1920", set_global_timespace); -#endif -#ifdef NON_MATCHING -// TODO: figure out why compiler/assembler isn't putting LWC1 in delay slot f32 get_global_timespace(void) { return gGlobalTimeSpace; } -#else -INCLUDE_ASM(s32, "code_e79b0_len_1920", get_global_timespace); -#endif void set_script_group(ScriptInstance* script, s8 groupFlags) { script->groupFlags = groupFlags; @@ -240,7 +598,7 @@ void suspend_group_script(ScriptInstance* script, s32 groupFlags) { suspend_group_script(childScript, groupFlags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { suspend_group_script(scriptContextPtr, groupFlags); @@ -261,7 +619,7 @@ void resume_group_script(ScriptInstance* script, s32 groupFlags) { resume_group_script(childScript, groupFlags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { suspend_group_script(scriptContextPtr, groupFlags); @@ -277,7 +635,7 @@ s32 suspend_all_script(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { suspend_group_script(scriptContextPtr, 0xEF); @@ -289,7 +647,7 @@ s32 resume_all_script(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { resume_group_script(scriptContextPtr, 0xEF); @@ -301,7 +659,7 @@ void suspend_group_script_index(s32 id, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { suspend_group_script(scriptContextPtr, groupFlags); @@ -313,7 +671,7 @@ void resume_group_script_index(s32 id, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { resume_group_script(scriptContextPtr, groupFlags); @@ -321,11 +679,11 @@ void resume_group_script_index(s32 id, s32 groupFlags) { } } -s32 suspend_all_group(s32 groupFlags) { +void suspend_all_group(s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { suspend_group_script(scriptContextPtr, groupFlags); @@ -337,7 +695,7 @@ s32 resume_all_group(s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { resume_group_script(scriptContextPtr, groupFlags); @@ -349,7 +707,7 @@ void suspend_group_others(ScriptInstance* script, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr != script) { suspend_group_script(scriptContextPtr, groupFlags); @@ -361,7 +719,7 @@ void resume_group_others(ScriptInstance* script, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr != script) { resume_group_script(scriptContextPtr, groupFlags); @@ -377,7 +735,7 @@ ScriptInstance* get_script_by_id(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { if ((*gCurrentScriptListPtr)[i] != NULL) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr->uniqueID == id) { @@ -398,7 +756,7 @@ void set_script_flags(ScriptInstance* script, s32 flags) { set_script_flags(childScript, flags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { set_script_flags(script->parentScript, flags); @@ -406,7 +764,6 @@ void set_script_flags(ScriptInstance* script, s32 flags) { } } - void clear_script_flags(ScriptInstance* script, s32 flags) { int i; ScriptInstance* scriptContextPtr; @@ -417,7 +774,7 @@ void clear_script_flags(ScriptInstance* script, s32 flags) { clear_script_flags(childScript, flags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { clear_script_flags(scriptContextPtr, flags); diff --git a/src/code_e92d0_len_5da0.c b/src/code_e92d0_len_5da0.c index 75ec46b6a5..49e3b1789a 100644 --- a/src/code_e92d0_len_5da0.c +++ b/src/code_e92d0_len_5da0.c @@ -737,12 +737,11 @@ ApiStatus func_802C73B0(ScriptInstance* script) { s32 func_802C73B8(ScriptInstance* script) { s32 i; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < 128; i++) { // replace with MAX_SCRIPTS define if (script == get_script_by_index(i)) { break; } } - return 1; } diff --git a/tools/splat.yaml b/tools/splat.yaml index c8960c5562..629218a1e7 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -236,7 +236,10 @@ segments: - [0xf8f60, "c", "code_f8f60_len_1560"] - [0xfa4c0, "c", "code_fa4c0_len_3bf0"] - [0xfe0b0, "c", "code_fe0b0_len_5a0"] - - [0xFE650, "bin"] + - [0xFE650, ".data", "code_e79b0_len_1920"] + - [0xFE660, "bin"] + - [0xFE730, ".rodata", "code_e79b0_len_1920"] + - [0xFE748, "bin"] # rodata chunk for above overlay; here to avoid the 0x10 alignment - name: code type: code start: 0xFEE30 diff --git a/undefined_syms.txt b/undefined_syms.txt index 1e345df74d..a194196492 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -11,7 +11,6 @@ gWorldScriptList = 0x802DA490; gBattleScriptList = 0x802DA690; gNumScripts = 0x802DA488; gCurrentScriptListPtr = 0x802DA890; -D_802DAC98 = 0x802DAC98; gStaticScriptCounter = 0x802D9CA0; D_802D9CA4 = 0x802D9CA4; gGlobalTimeSpace = 0x802D9CA8; @@ -21,6 +20,12 @@ D_8010EBB0 = 0x8010EBB0; D_8010F250 = 0x8010F250; D_80159D50 = 0x80159D50; +gWorldMapVars = 0x802DBCA8; +gBattleMapVars = 0x802DBCE8; + +gWorldMapFlags = 0x802DBC70; +gBattleMapFlags = 0x802DBD34; + gMapTransitionAlpha = 0x800A0940; D_800E92D8 = 0x800E92D8; D_80147474 = 0x80147474; @@ -41,7 +46,6 @@ gBattleStatus = 0x800DC070; gStaticScriptCounter = 0x802D9CA0; D_802D9CA4 = 0x802D9CA4; gNumScripts = 0x802DA488; -D_802DAC98 = 0x802DAC98; D_000759B0 = 0x000759B0; D_000759B0_end = 0x000A5DD0; @@ -138,8 +142,8 @@ gWorldDynamicEntityList = 0x801543A0; gBattleDynamicEntityList = 0x801543E0; gCurrentDynamicEntityListPtr = 0x80154420; -gScriptIdList = 0x802DA898; -gScriptIndexList = 0x802DAA98; +gScriptIndexList = 0x802DA898; +gScriptIdList = 0x802DAA98; gScriptListCount = 0x802DAC98; gCurrentSaveFile = 0x800DACC0;