From 6aa628f3acb63e3271966cc523575fc4a8709788 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 19:53:38 -0700 Subject: [PATCH] Added gCurrentScriptList and some more matching funcs --- .../code_e79b0_len_1920/get_script_by_index.s | 12 ------ .../code_e940_len_290/func_80033540.s | 16 -------- .../code_e940_len_290/func_80033788.s | 26 ------------- .../code_f8f60_len_1560/MakeLerp.s | 37 ------------------- include/variables.h | 1 + src/code_e79b0_len_1920.c | 33 +++++++++++++++-- undefined_syms.txt | 1 + 7 files changed, 32 insertions(+), 94 deletions(-) delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/get_script_by_index.s delete mode 100644 asm/nonmatchings/code_e940_len_290/func_80033540.s delete mode 100644 asm/nonmatchings/code_e940_len_290/func_80033788.s delete mode 100644 asm/nonmatchings/code_f8f60_len_1560/MakeLerp.s diff --git a/asm/nonmatchings/code_e79b0_len_1920/get_script_by_index.s b/asm/nonmatchings/code_e79b0_len_1920/get_script_by_index.s deleted file mode 100644 index 1d4d5a1af1..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/get_script_by_index.s +++ /dev/null @@ -1,12 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel get_script_by_index -/* 0E9140 802C4790 3C02802E */ lui $v0, 0x802e -/* 0E9144 802C4794 8C42A890 */ lw $v0, -0x5770($v0) -/* 0E9148 802C4798 00042080 */ sll $a0, $a0, 2 -/* 0E914C 802C479C 00822021 */ addu $a0, $a0, $v0 -/* 0E9150 802C47A0 03E00008 */ jr $ra -/* 0E9154 802C47A4 8C820000 */ lw $v0, ($a0) - diff --git a/asm/nonmatchings/code_e940_len_290/func_80033540.s b/asm/nonmatchings/code_e940_len_290/func_80033540.s deleted file mode 100644 index 10c212fd08..0000000000 --- a/asm/nonmatchings/code_e940_len_290/func_80033540.s +++ /dev/null @@ -1,16 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel func_80033540 -/* 00E940 80033540 3C03800A */ lui $v1, 0x800a -/* 00E944 80033544 2463A650 */ addiu $v1, $v1, -0x59b0 -/* 00E948 80033548 8C620000 */ lw $v0, ($v1) -/* 00E94C 8003354C 34420008 */ ori $v0, $v0, 8 -/* 00E950 80033550 AC620000 */ sw $v0, ($v1) -/* 00E954 80033554 3C038007 */ lui $v1, 0x8007 -/* 00E958 80033558 8C63419C */ lw $v1, 0x419c($v1) -/* 00E95C 8003355C 24020003 */ addiu $v0, $zero, 3 -/* 00E960 80033560 03E00008 */ jr $ra -/* 00E964 80033564 A06200AC */ sb $v0, 0xac($v1) - diff --git a/asm/nonmatchings/code_e940_len_290/func_80033788.s b/asm/nonmatchings/code_e940_len_290/func_80033788.s deleted file mode 100644 index bd85dcce08..0000000000 --- a/asm/nonmatchings/code_e940_len_290/func_80033788.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel func_80033788 -/* 00EB88 80033788 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 00EB8C 8003378C 240200FF */ addiu $v0, $zero, 0xff -/* 00EB90 80033790 0000202D */ daddu $a0, $zero, $zero -/* 00EB94 80033794 0080282D */ daddu $a1, $a0, $zero -/* 00EB98 80033798 2406013F */ addiu $a2, $zero, 0x13f -/* 00EB9C 8003379C 240700EF */ addiu $a3, $zero, 0xef -/* 00EBA0 800337A0 AFBF0020 */ sw $ra, 0x20($sp) -/* 00EBA4 800337A4 AFA00010 */ sw $zero, 0x10($sp) -/* 00EBA8 800337A8 AFA00014 */ sw $zero, 0x14($sp) -/* 00EBAC 800337AC AFA00018 */ sw $zero, 0x18($sp) -/* 00EBB0 800337B0 0C00AAD7 */ jal func_8002AB5C -/* 00EBB4 800337B4 AFA2001C */ sw $v0, 0x1c($sp) -/* 00EBB8 800337B8 8FBF0020 */ lw $ra, 0x20($sp) -/* 00EBBC 800337BC 03E00008 */ jr $ra -/* 00EBC0 800337C0 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 00EBC4 800337C4 00000000 */ nop -/* 00EBC8 800337C8 00000000 */ nop -/* 00EBCC 800337CC 00000000 */ nop - - diff --git a/asm/nonmatchings/code_f8f60_len_1560/MakeLerp.s b/asm/nonmatchings/code_f8f60_len_1560/MakeLerp.s deleted file mode 100644 index bb7c3327e8..0000000000 --- a/asm/nonmatchings/code_f8f60_len_1560/MakeLerp.s +++ /dev/null @@ -1,37 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel MakeLerp -/* 0F8F60 802D45B0 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F8F64 802D45B4 AFB10014 */ sw $s1, 0x14($sp) -/* 0F8F68 802D45B8 0080882D */ daddu $s1, $a0, $zero -/* 0F8F6C 802D45BC AFBF0018 */ sw $ra, 0x18($sp) -/* 0F8F70 802D45C0 AFB00010 */ sw $s0, 0x10($sp) -/* 0F8F74 802D45C4 8E30000C */ lw $s0, 0xc($s1) -/* 0F8F78 802D45C8 8E050000 */ lw $a1, ($s0) -/* 0F8F7C 802D45CC 0C0B1EAF */ jal get_variable -/* 0F8F80 802D45D0 26100004 */ addiu $s0, $s0, 4 -/* 0F8F84 802D45D4 AE2200B4 */ sw $v0, 0xb4($s1) -/* 0F8F88 802D45D8 8E050000 */ lw $a1, ($s0) -/* 0F8F8C 802D45DC 26100004 */ addiu $s0, $s0, 4 -/* 0F8F90 802D45E0 0C0B1EAF */ jal get_variable -/* 0F8F94 802D45E4 0220202D */ daddu $a0, $s1, $zero -/* 0F8F98 802D45E8 AE2200B8 */ sw $v0, 0xb8($s1) -/* 0F8F9C 802D45EC 8E050000 */ lw $a1, ($s0) -/* 0F8FA0 802D45F0 26100004 */ addiu $s0, $s0, 4 -/* 0F8FA4 802D45F4 0C0B1EAF */ jal get_variable -/* 0F8FA8 802D45F8 0220202D */ daddu $a0, $s1, $zero -/* 0F8FAC 802D45FC AE2200C0 */ sw $v0, 0xc0($s1) -/* 0F8FB0 802D4600 8E050000 */ lw $a1, ($s0) -/* 0F8FB4 802D4604 0C0B1EAF */ jal get_variable -/* 0F8FB8 802D4608 0220202D */ daddu $a0, $s1, $zero -/* 0F8FBC 802D460C AE2200B0 */ sw $v0, 0xb0($s1) -/* 0F8FC0 802D4610 AE2000BC */ sw $zero, 0xbc($s1) -/* 0F8FC4 802D4614 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F8FC8 802D4618 8FB10014 */ lw $s1, 0x14($sp) -/* 0F8FCC 802D461C 8FB00010 */ lw $s0, 0x10($sp) -/* 0F8FD0 802D4620 24020002 */ addiu $v0, $zero, 2 -/* 0F8FD4 802D4624 03E00008 */ jr $ra -/* 0F8FD8 802D4628 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/include/variables.h b/include/variables.h index e4039c8b0f..96fcaa02f5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -10,6 +10,7 @@ extern player_data gPlayerData; extern player_status gPlayerStatus; extern game_status* gGameStatusPtr[1]; extern item_table_entry gItemTable[364]; +extern s32* gCurrentScriptList; extern s8 D_800A0900; extern s16* D_80151328; extern s16 D_8010CD10; diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index 7b81798610..f7528868d9 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -26,7 +26,19 @@ INCLUDE_ASM(code_e79b0_len_1920, func_802C3EE4); INCLUDE_ASM(code_e79b0_len_1920, kill_script); -INCLUDE_ASM(code_e79b0_len_1920, kill_script_by_ID); +void* kill_script_by_ID(s32 id) { + s32 i; + script_context* scriptContextPtr; + + for (i=0; i < 128; i++) { + if (gCurrentScriptList[i] != 0) { + scriptContextPtr = (script_context*) gCurrentScriptList[i]; + if (scriptContextPtr->uniqueID == id) { + kill_script(scriptContextPtr); + } + } + } +} INCLUDE_ASM(code_e79b0_len_1920, kill_all_scripts); @@ -68,9 +80,24 @@ INCLUDE_ASM(code_e79b0_len_1920, suspend_group_others); INCLUDE_ASM(code_e79b0_len_1920, resume_group_others); -INCLUDE_ASM(code_e79b0_len_1920, get_script_by_index); +s32 get_script_by_index(s32 index) { + return gCurrentScriptList[index]; +} -INCLUDE_ASM(code_e79b0_len_1920, get_script_by_id); +void* get_script_by_id(s32 id) { + s32 i; + script_context* scriptContextPtr; + + for (i=0; i < 128; i++) { + if (gCurrentScriptList[i] != 0) { + scriptContextPtr = (script_context*) gCurrentScriptList[i]; + if (scriptContextPtr->uniqueID == id) { + return scriptContextPtr; + } + } + } + return 0; +} INCLUDE_ASM(code_e79b0_len_1920, set_script_flags); diff --git a/undefined_syms.txt b/undefined_syms.txt index 0965e25b8e..ee9a9bbcf9 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3,6 +3,7 @@ gUIStatus = 0x8010EF58; gPlayerData = 0x8010F290; gPlayerStatus = 0x8010EFC8; gItemTable = 0x800878E0; +gCurrentScriptList = 0x802DA890; D_80147574 = 0x80147574; gMapTransitionAlpha = 0x800A0940;