From dea08446d3a81843e15da714a0aa3770af15cc07 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 17:29:25 -0700 Subject: [PATCH 1/7] random stuff --- src/code_3169f0.c | 2 +- src/code_e940_len_290.c | 150 +++++++++++++++++++++++++++++++++++++- src/code_f8f60_len_1560.c | 18 ++++- undefined_syms.txt | 1 + 4 files changed, 167 insertions(+), 4 deletions(-) diff --git a/src/code_3169f0.c b/src/code_3169f0.c index 7784b9053f..80be62706c 100644 --- a/src/code_3169f0.c +++ b/src/code_3169f0.c @@ -1,3 +1,3 @@ #include "common.h" -INCLUDE_ASM(code_3169f0, func_80200000); +INCLUDE_ASM(code_3169f0, func_80200000); \ No newline at end of file diff --git a/src/code_e940_len_290.c b/src/code_e940_len_290.c index 4bb8d102be..8268cecb06 100644 --- a/src/code_e940_len_290.c +++ b/src/code_e940_len_290.c @@ -1,7 +1,153 @@ #include "common.h" -INCLUDE_ASM(code_e940_len_290, func_80033540); +void func_80033540(void) { + D_8009A650[0] |= 8; + (*gGameStatusPtr)->unk_AC = 3; +} INCLUDE_ASM(code_e940_len_290, func_80033568); +/* +s8 func_80033568(void) { + game_status* gameStatus = gGameStatusPtr; + s8 value = gameStatus->unk_AC - 1; -INCLUDE_ASM(code_e940_len_290, func_80033788); + if (gameStatus->unk_AC != 0) { + gameStatus->unk_AC = value; + } + + D_8009A650[0] = 0; + + gameStatus->unk_86 = 0; + gameStatus->unk_70 = 0; + gameStatus->unk_88 = -1; + gameStatus->mapID = 0; + + gameStatus->unk_8E[0] = 0; + + gameStatus->unk_76[0] = 0; + gameStatus->unk_76[2] = 0; + + gameStatus->unk_7D[0] = 0; + + gameStatus->unk_A8 = -1; + gameStatus->unk_AA = 0; + gameStatus->unk_A9 = -1; + gameStatus->demoState = 0; + + general_heap_create(gameStatus); + func_8011D890(); + func_801230B8(); + clear_script_list(); + create_cameras_a(); + func_802DD8F8(0); + func_80120BB0(); + func_8011E224(); + clear_model_data(); + func_80148040(); + func_80145DF8(); + func_801452E8(0, 0); + func_80141100(); + clear_trigger_data(); + clear_printers(); + func_80110CB8(0); + func_80138108(); + clear_player_status(); + func_800384BC(); + clear_player_data(); + func_80072B30(); + func_8003E338(); + func_80059C9C(); + clear_item_entity_data(); + clear_saved_variables(); + initialize_collision(); + func_8014AC08(); + func_801473F0(); + func_800EB580(); + func_80149618(); + func_8014A52C(); + func_8002BA40(); + +// s32 temp_a0_2; +// s8 temp_v0; +// void *temp_a0; +// void *phi_v1; +// s32 phi_a0; + +// temp_a0 = *(void *)0x8007419C; +// temp_v0 = (u8) temp_a0->unkAC - 1; +// if (temp_a0->unkAC != 0) { +// temp_a0->unkAC = temp_v0; +// return temp_v0; +// } +// *(void *)0x8009A650 = 0; +// temp_a0->unk86 = (u16)0; +// temp_a0->unk70 = (u8)0; +// temp_a0->unk88 = (u16)-1; +// temp_a0->unk8C = (u16)0; +// temp_a0->unk8E = (u16)0; +// (*(void *)0x8007419C)->unk76 = (u8)0; +// (*(void *)0x8007419C)->unk78 = (u8)0; +// (*(void *)0x8007419C)->unk7D = (u8)0; +// (*(void *)0x8007419C)->unkA8 = (s8) (u16)-1; +// (*(void *)0x8007419C)->unkAA = (u8)0; +// (*(void *)0x8007419C)->unkA9 = (s8) (u16)-1; +// (*(void *)0x8007419C)->unk71 = (u8)0; +// general_heap_create(temp_a0); +// func_8011D890(); +// func_801230B8(); +// clear_script_list(); +// create_cameras_a(); +// func_802DD8F8(0); +// func_80120BB0(); +// func_8011E224(); +// clear_model_data(); +// func_80148040(); +// func_80145DF8(); +// func_801452E8(0, 0); +// func_80141100(); +// clear_trigger_data(); +// clear_printers(); +// func_80110CB8(0); +// func_80138108(); +// clear_player_status(); +// func_800384BC(); +// clear_player_data(); +// func_80072B30(); +// func_8003E338(); +// func_80059C9C(); +// clear_item_entity_data(); +// clear_saved_variables(); +// initialize_collision(); +// func_8014AC08(); +// func_801473F0(); +// func_800EB580(); +// func_80149618(); +// func_8014A52C(); +// func_8002BA40(); +// phi_v1 = *(void *)0x8007419C; +// phi_a0 = 0; +// loop_3: +// phi_v1->unk50 = (u16)4; +// phi_v1->unk48 = (u16)0xF; +// temp_a0_2 = phi_a0 + 1; +// phi_v1 = phi_v1 + 2; +// phi_a0 = temp_a0_2; +// if (temp_a0_2 < 4) { +// goto loop_3; +// } +// fio_has_valid_backup(temp_a0_2, (u16)0xF, (u16)4); +// if (*(void *)0x800D9620 == 0) { +// (*(void *)0x8007419C)->unkAB = (u8)1; +// func_8005615C(); +// } else { +// (*(void *)0x8007419C)->unkAB = (u8)0; +// func_80056180(); +// } +// *(void *)0x8009A650 = (s32) (*(void *)0x8009A650 & -9); +// return set_game_mode(1, -9); +} +*/ + +void func_80033788(void) { + func_8002AB5C(0, 0, 0x13F, 0xEF, 0, 0, 0, 0xFF); +} diff --git a/src/code_f8f60_len_1560.c b/src/code_f8f60_len_1560.c index 392db12fe1..5dda100036 100644 --- a/src/code_f8f60_len_1560.c +++ b/src/code_f8f60_len_1560.c @@ -1,6 +1,22 @@ #include "common.h" -INCLUDE_ASM(code_f8f60_len_1560, MakeLerp); +s32 MakeLerp(script_context* script, s32 initialCall) { + s32* ptrReadPos = script->ptrReadPos; + s32* ptrNextPos = *ptrReadPos++; + s32* ptrNextPos2; + s32* ptrNextPos3; + s32* ptrNextPos4; + + script->varTable[12] = get_variable(script, ptrNextPos); + ptrNextPos2 = *ptrReadPos++; + script->varTable[13] = get_variable(script, ptrNextPos2); + ptrNextPos3 = *ptrReadPos++; + script->varTable[15] = get_variable(script, ptrNextPos3); + ptrNextPos4 = *ptrReadPos++; + script->varTable[11] = get_variable(script, ptrNextPos4); + script->varTable[14] = 0; + return 2; +} INCLUDE_ASM(code_f8f60_len_1560, UpdateLerp); diff --git a/undefined_syms.txt b/undefined_syms.txt index 0965e25b8e..4a5ddf547f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1,3 +1,4 @@ + gGameStatusPtr = 0x8007419C; gUIStatus = 0x8010EF58; gPlayerData = 0x8010F290; From ef4f2e34ec39d35c88b14b453ff11aae612b43d1 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 17:31:27 -0700 Subject: [PATCH 2/7] blorp --- src/code_3169f0.c | 2 +- undefined_syms.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/code_3169f0.c b/src/code_3169f0.c index 80be62706c..7784b9053f 100644 --- a/src/code_3169f0.c +++ b/src/code_3169f0.c @@ -1,3 +1,3 @@ #include "common.h" -INCLUDE_ASM(code_3169f0, func_80200000); \ No newline at end of file +INCLUDE_ASM(code_3169f0, func_80200000); diff --git a/undefined_syms.txt b/undefined_syms.txt index 4a5ddf547f..0965e25b8e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1,4 +1,3 @@ - gGameStatusPtr = 0x8007419C; gUIStatus = 0x8010EF58; gPlayerData = 0x8010F290; From 6aa628f3acb63e3271966cc523575fc4a8709788 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 19:53:38 -0700 Subject: [PATCH 3/7] 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; From a2f974711210d7010bdd623d7fc2c16ac6a084b3 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 22:22:16 -0700 Subject: [PATCH 4/7] Some tidying and more functions --- src/code_e79b0_len_1920.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index f7528868d9..6f584598d9 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -31,18 +31,38 @@ void* kill_script_by_ID(s32 id) { 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); - } + scriptContextPtr = (script_context*) gCurrentScriptList[i]; + if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { + kill_script(scriptContextPtr); } } } -INCLUDE_ASM(code_e79b0_len_1920, kill_all_scripts); +s32 kill_all_scripts(void) { + s32 i; + script_context* scriptContextPtr; -INCLUDE_ASM(code_e79b0_len_1920, does_script_exist); + for(i=0; i < 128; i++) { + scriptContextPtr = (script_context*) gCurrentScriptList[i]; + if (scriptContextPtr != NULL) { + kill_script(scriptContextPtr); + } + } + return; +} + +s32 does_script_exist(s32 id) { + s32 i; + script_context* scriptContextPtr; + + for(i=0; i < 128; i++) { + scriptContextPtr = (script_context*) gCurrentScriptList[i]; + if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { + return 1; + } + } + return 0; +} INCLUDE_ASM(code_e79b0_len_1920, does_script_exist_by_ref); @@ -80,11 +100,11 @@ INCLUDE_ASM(code_e79b0_len_1920, suspend_group_others); INCLUDE_ASM(code_e79b0_len_1920, resume_group_others); -s32 get_script_by_index(s32 index) { +script_context* get_script_by_index(s32 index) { return gCurrentScriptList[index]; } -void* get_script_by_id(s32 id) { +script_context* get_script_by_id(s32 id) { s32 i; script_context* scriptContextPtr; @@ -99,6 +119,7 @@ void* get_script_by_id(s32 id) { return 0; } + INCLUDE_ASM(code_e79b0_len_1920, set_script_flags); INCLUDE_ASM(code_e79b0_len_1920, clear_script_flags); From 73e1eff76e3f7a211a97a99faeec153246ee6af4 Mon Sep 17 00:00:00 2001 From: Jdog Date: Fri, 14 Aug 2020 07:25:33 -0700 Subject: [PATCH 5/7] more refinements on script list stuff --- .../code_e79b0_len_1920/does_script_exist.s | 26 -------------- .../code_e79b0_len_1920/get_script_by_id.s | 26 -------------- .../code_e79b0_len_1920/kill_all_scripts.s | 28 --------------- .../code_e79b0_len_1920/kill_script_by_ID.s | 34 ------------------- include/variables.h | 8 ++++- src/code_e79b0_len_1920.c | 20 +++++------ undefined_syms.txt | 4 ++- 7 files changed, 20 insertions(+), 126 deletions(-) delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/does_script_exist.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/get_script_by_id.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/kill_all_scripts.s delete mode 100644 asm/nonmatchings/code_e79b0_len_1920/kill_script_by_ID.s diff --git a/asm/nonmatchings/code_e79b0_len_1920/does_script_exist.s b/asm/nonmatchings/code_e79b0_len_1920/does_script_exist.s deleted file mode 100644 index a139b48c0c..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/does_script_exist.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel does_script_exist -/* 0E8B14 802C4164 0000282D */ daddu $a1, $zero, $zero -/* 0E8B18 802C4168 3C03802E */ lui $v1, 0x802e -/* 0E8B1C 802C416C 8C63A890 */ lw $v1, -0x5770($v1) -.L802C4170: -/* 0E8B20 802C4170 8C620000 */ lw $v0, ($v1) -/* 0E8B24 802C4174 10400006 */ beqz $v0, .L802C4190 -/* 0E8B28 802C4178 24A50001 */ addiu $a1, $a1, 1 -/* 0E8B2C 802C417C 8C420144 */ lw $v0, 0x144($v0) -/* 0E8B30 802C4180 14440004 */ bne $v0, $a0, .L802C4194 -/* 0E8B34 802C4184 28A20080 */ slti $v0, $a1, 0x80 -/* 0E8B38 802C4188 03E00008 */ jr $ra -/* 0E8B3C 802C418C 24020001 */ addiu $v0, $zero, 1 - -.L802C4190: -/* 0E8B40 802C4190 28A20080 */ slti $v0, $a1, 0x80 -.L802C4194: -/* 0E8B44 802C4194 1440FFF6 */ bnez $v0, .L802C4170 -/* 0E8B48 802C4198 24630004 */ addiu $v1, $v1, 4 -/* 0E8B4C 802C419C 03E00008 */ jr $ra -/* 0E8B50 802C41A0 0000102D */ daddu $v0, $zero, $zero - diff --git a/asm/nonmatchings/code_e79b0_len_1920/get_script_by_id.s b/asm/nonmatchings/code_e79b0_len_1920/get_script_by_id.s deleted file mode 100644 index 9e79481109..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/get_script_by_id.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel get_script_by_id -/* 0E9158 802C47A8 0000302D */ daddu $a2, $zero, $zero -/* 0E915C 802C47AC 3C05802E */ lui $a1, 0x802e -/* 0E9160 802C47B0 8CA5A890 */ lw $a1, -0x5770($a1) -.L802C47B4: -/* 0E9164 802C47B4 8CA30000 */ lw $v1, ($a1) -/* 0E9168 802C47B8 10600006 */ beqz $v1, .L802C47D4 -/* 0E916C 802C47BC 24C60001 */ addiu $a2, $a2, 1 -/* 0E9170 802C47C0 8C620144 */ lw $v0, 0x144($v1) -/* 0E9174 802C47C4 14440004 */ bne $v0, $a0, .L802C47D8 -/* 0E9178 802C47C8 28C20080 */ slti $v0, $a2, 0x80 -/* 0E917C 802C47CC 03E00008 */ jr $ra -/* 0E9180 802C47D0 0060102D */ daddu $v0, $v1, $zero - -.L802C47D4: -/* 0E9184 802C47D4 28C20080 */ slti $v0, $a2, 0x80 -.L802C47D8: -/* 0E9188 802C47D8 1440FFF6 */ bnez $v0, .L802C47B4 -/* 0E918C 802C47DC 24A50004 */ addiu $a1, $a1, 4 -/* 0E9190 802C47E0 03E00008 */ jr $ra -/* 0E9194 802C47E4 0000102D */ daddu $v0, $zero, $zero - diff --git a/asm/nonmatchings/code_e79b0_len_1920/kill_all_scripts.s b/asm/nonmatchings/code_e79b0_len_1920/kill_all_scripts.s deleted file mode 100644 index 59d1c542ae..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/kill_all_scripts.s +++ /dev/null @@ -1,28 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel kill_all_scripts -/* 0E8AC4 802C4114 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0E8AC8 802C4118 AFB00010 */ sw $s0, 0x10($sp) -/* 0E8ACC 802C411C 0000802D */ daddu $s0, $zero, $zero -/* 0E8AD0 802C4120 AFBF0014 */ sw $ra, 0x14($sp) -.L802C4124: -/* 0E8AD4 802C4124 3C03802E */ lui $v1, 0x802e -/* 0E8AD8 802C4128 8C63A890 */ lw $v1, -0x5770($v1) -/* 0E8ADC 802C412C 00101080 */ sll $v0, $s0, 2 -/* 0E8AE0 802C4130 00431021 */ addu $v0, $v0, $v1 -/* 0E8AE4 802C4134 8C440000 */ lw $a0, ($v0) -/* 0E8AE8 802C4138 10800003 */ beqz $a0, .L802C4148 -/* 0E8AEC 802C413C 26100001 */ addiu $s0, $s0, 1 -/* 0E8AF0 802C4140 0C0B0FCF */ jal kill_script -/* 0E8AF4 802C4144 00000000 */ nop -.L802C4148: -/* 0E8AF8 802C4148 2A020080 */ slti $v0, $s0, 0x80 -/* 0E8AFC 802C414C 1440FFF5 */ bnez $v0, .L802C4124 -/* 0E8B00 802C4150 00000000 */ nop -/* 0E8B04 802C4154 8FBF0014 */ lw $ra, 0x14($sp) -/* 0E8B08 802C4158 8FB00010 */ lw $s0, 0x10($sp) -/* 0E8B0C 802C415C 03E00008 */ jr $ra -/* 0E8B10 802C4160 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_e79b0_len_1920/kill_script_by_ID.s b/asm/nonmatchings/code_e79b0_len_1920/kill_script_by_ID.s deleted file mode 100644 index 05d2f2b48b..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/kill_script_by_ID.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel kill_script_by_ID -/* 0E8A5C 802C40AC 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0E8A60 802C40B0 AFB10014 */ sw $s1, 0x14($sp) -/* 0E8A64 802C40B4 0080882D */ daddu $s1, $a0, $zero -/* 0E8A68 802C40B8 AFB00010 */ sw $s0, 0x10($sp) -/* 0E8A6C 802C40BC 0000802D */ daddu $s0, $zero, $zero -/* 0E8A70 802C40C0 AFBF0018 */ sw $ra, 0x18($sp) -.L802C40C4: -/* 0E8A74 802C40C4 3C03802E */ lui $v1, 0x802e -/* 0E8A78 802C40C8 8C63A890 */ lw $v1, -0x5770($v1) -/* 0E8A7C 802C40CC 00101080 */ sll $v0, $s0, 2 -/* 0E8A80 802C40D0 00431021 */ addu $v0, $v0, $v1 -/* 0E8A84 802C40D4 8C440000 */ lw $a0, ($v0) -/* 0E8A88 802C40D8 10800006 */ beqz $a0, .L802C40F4 -/* 0E8A8C 802C40DC 26100001 */ addiu $s0, $s0, 1 -/* 0E8A90 802C40E0 8C820144 */ lw $v0, 0x144($a0) -/* 0E8A94 802C40E4 14510003 */ bne $v0, $s1, .L802C40F4 -/* 0E8A98 802C40E8 00000000 */ nop -/* 0E8A9C 802C40EC 0C0B0FCF */ jal kill_script -/* 0E8AA0 802C40F0 00000000 */ nop -.L802C40F4: -/* 0E8AA4 802C40F4 2A020080 */ slti $v0, $s0, 0x80 -/* 0E8AA8 802C40F8 1440FFF2 */ bnez $v0, .L802C40C4 -/* 0E8AAC 802C40FC 00000000 */ nop -/* 0E8AB0 802C4100 8FBF0018 */ lw $ra, 0x18($sp) -/* 0E8AB4 802C4104 8FB10014 */ lw $s1, 0x14($sp) -/* 0E8AB8 802C4108 8FB00010 */ lw $s0, 0x10($sp) -/* 0E8ABC 802C410C 03E00008 */ jr $ra -/* 0E8AC0 802C4110 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/include/variables.h b/include/variables.h index 96fcaa02f5..bc800334bf 100644 --- a/include/variables.h +++ b/include/variables.h @@ -5,12 +5,18 @@ #include "common_structs.h" #include "types.h" +#define MAX_SCRIPT_LIST_LENGTH 128 + extern ui_status gUIStatus; extern player_data gPlayerData; extern player_status gPlayerStatus; extern game_status* gGameStatusPtr[1]; extern item_table_entry gItemTable[364]; -extern s32* gCurrentScriptList; + +extern script_context* gWorldScriptList[MAX_SCRIPT_LIST_LENGTH]; +extern script_context* gBattleScriptList[MAX_SCRIPT_LIST_LENGTH]; +extern script_context** gCurrentScriptListPtr; + 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 6f584598d9..b77d2e2105 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -30,8 +30,8 @@ void* kill_script_by_ID(s32 id) { s32 i; script_context* scriptContextPtr; - for (i=0; i < 128; i++) { - scriptContextPtr = (script_context*) gCurrentScriptList[i]; + for (i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { + scriptContextPtr = gCurrentScriptListPtr[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { kill_script(scriptContextPtr); } @@ -42,8 +42,8 @@ s32 kill_all_scripts(void) { s32 i; script_context* scriptContextPtr; - for(i=0; i < 128; i++) { - scriptContextPtr = (script_context*) gCurrentScriptList[i]; + for(i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { + scriptContextPtr = gCurrentScriptListPtr[i]; if (scriptContextPtr != NULL) { kill_script(scriptContextPtr); } @@ -55,8 +55,8 @@ s32 does_script_exist(s32 id) { s32 i; script_context* scriptContextPtr; - for(i=0; i < 128; i++) { - scriptContextPtr = (script_context*) gCurrentScriptList[i]; + for(i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { + scriptContextPtr = gCurrentScriptListPtr[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { return 1; } @@ -101,16 +101,16 @@ INCLUDE_ASM(code_e79b0_len_1920, suspend_group_others); INCLUDE_ASM(code_e79b0_len_1920, resume_group_others); script_context* get_script_by_index(s32 index) { - return gCurrentScriptList[index]; + return gCurrentScriptListPtr[index]; } script_context* 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]; + for (i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { + if (gCurrentScriptListPtr[i] != NULL) { + scriptContextPtr = gCurrentScriptListPtr[i]; if (scriptContextPtr->uniqueID == id) { return scriptContextPtr; } diff --git a/undefined_syms.txt b/undefined_syms.txt index ee9a9bbcf9..32f85a9d6e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3,7 +3,9 @@ gUIStatus = 0x8010EF58; gPlayerData = 0x8010F290; gPlayerStatus = 0x8010EFC8; gItemTable = 0x800878E0; -gCurrentScriptList = 0x802DA890; +gWorldScriptList = 0x802DA490; +gBattleScriptList = 0x802DA690; +gCurrentScriptListPtr = 0x802DA890; D_80147574 = 0x80147574; gMapTransitionAlpha = 0x800A0940; From c179e51a88070d3b2de20d133c445c77e6daee0e Mon Sep 17 00:00:00 2001 From: Jdog Date: Fri, 14 Aug 2020 07:50:44 -0700 Subject: [PATCH 6/7] Change to use ARRAY_COUNT for script list stuff --- include/variables.h | 8 +++----- src/code_e79b0_len_1920.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/variables.h b/include/variables.h index bc800334bf..1dbe05b68a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -5,17 +5,15 @@ #include "common_structs.h" #include "types.h" -#define MAX_SCRIPT_LIST_LENGTH 128 - extern ui_status gUIStatus; extern player_data gPlayerData; extern player_status gPlayerStatus; extern game_status* gGameStatusPtr[1]; extern item_table_entry gItemTable[364]; -extern script_context* gWorldScriptList[MAX_SCRIPT_LIST_LENGTH]; -extern script_context* gBattleScriptList[MAX_SCRIPT_LIST_LENGTH]; -extern script_context** gCurrentScriptListPtr; +extern script_context* gWorldScriptList[128]; +extern script_context* gBattleScriptList[128]; +extern script_context** gCurrentScriptListPtr[128]; extern s8 D_800A0900; extern s16* D_80151328; diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index b77d2e2105..9093b6bd64 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -30,8 +30,8 @@ void* kill_script_by_ID(s32 id) { s32 i; script_context* scriptContextPtr; - for (i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { - scriptContextPtr = gCurrentScriptListPtr[i]; + for (i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { kill_script(scriptContextPtr); } @@ -42,8 +42,8 @@ s32 kill_all_scripts(void) { s32 i; script_context* scriptContextPtr; - for(i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { - scriptContextPtr = gCurrentScriptListPtr[i]; + for(i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { kill_script(scriptContextPtr); } @@ -55,8 +55,8 @@ s32 does_script_exist(s32 id) { s32 i; script_context* scriptContextPtr; - for(i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { - scriptContextPtr = gCurrentScriptListPtr[i]; + for(i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { return 1; } @@ -101,16 +101,16 @@ INCLUDE_ASM(code_e79b0_len_1920, suspend_group_others); INCLUDE_ASM(code_e79b0_len_1920, resume_group_others); script_context* get_script_by_index(s32 index) { - return gCurrentScriptListPtr[index]; + return (*gCurrentScriptListPtr)[index]; } script_context* get_script_by_id(s32 id) { s32 i; script_context* scriptContextPtr; - for (i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) { - if (gCurrentScriptListPtr[i] != NULL) { - scriptContextPtr = gCurrentScriptListPtr[i]; + for (i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + if ((*gCurrentScriptListPtr)[i] != NULL) { + scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr->uniqueID == id) { return scriptContextPtr; } From 27407e07f80ff22d66b1b37220eb19bf4ac10746 Mon Sep 17 00:00:00 2001 From: Jdog Date: Fri, 14 Aug 2020 08:01:23 -0700 Subject: [PATCH 7/7] Remove WIP function --- src/code_e940_len_290.c | 141 ---------------------------------------- 1 file changed, 141 deletions(-) diff --git a/src/code_e940_len_290.c b/src/code_e940_len_290.c index 8268cecb06..a389d9fba9 100644 --- a/src/code_e940_len_290.c +++ b/src/code_e940_len_290.c @@ -6,147 +6,6 @@ void func_80033540(void) { } INCLUDE_ASM(code_e940_len_290, func_80033568); -/* -s8 func_80033568(void) { - game_status* gameStatus = gGameStatusPtr; - s8 value = gameStatus->unk_AC - 1; - - if (gameStatus->unk_AC != 0) { - gameStatus->unk_AC = value; - } - - D_8009A650[0] = 0; - - gameStatus->unk_86 = 0; - gameStatus->unk_70 = 0; - gameStatus->unk_88 = -1; - gameStatus->mapID = 0; - - gameStatus->unk_8E[0] = 0; - - gameStatus->unk_76[0] = 0; - gameStatus->unk_76[2] = 0; - - gameStatus->unk_7D[0] = 0; - - gameStatus->unk_A8 = -1; - gameStatus->unk_AA = 0; - gameStatus->unk_A9 = -1; - gameStatus->demoState = 0; - - general_heap_create(gameStatus); - func_8011D890(); - func_801230B8(); - clear_script_list(); - create_cameras_a(); - func_802DD8F8(0); - func_80120BB0(); - func_8011E224(); - clear_model_data(); - func_80148040(); - func_80145DF8(); - func_801452E8(0, 0); - func_80141100(); - clear_trigger_data(); - clear_printers(); - func_80110CB8(0); - func_80138108(); - clear_player_status(); - func_800384BC(); - clear_player_data(); - func_80072B30(); - func_8003E338(); - func_80059C9C(); - clear_item_entity_data(); - clear_saved_variables(); - initialize_collision(); - func_8014AC08(); - func_801473F0(); - func_800EB580(); - func_80149618(); - func_8014A52C(); - func_8002BA40(); - -// s32 temp_a0_2; -// s8 temp_v0; -// void *temp_a0; -// void *phi_v1; -// s32 phi_a0; - -// temp_a0 = *(void *)0x8007419C; -// temp_v0 = (u8) temp_a0->unkAC - 1; -// if (temp_a0->unkAC != 0) { -// temp_a0->unkAC = temp_v0; -// return temp_v0; -// } -// *(void *)0x8009A650 = 0; -// temp_a0->unk86 = (u16)0; -// temp_a0->unk70 = (u8)0; -// temp_a0->unk88 = (u16)-1; -// temp_a0->unk8C = (u16)0; -// temp_a0->unk8E = (u16)0; -// (*(void *)0x8007419C)->unk76 = (u8)0; -// (*(void *)0x8007419C)->unk78 = (u8)0; -// (*(void *)0x8007419C)->unk7D = (u8)0; -// (*(void *)0x8007419C)->unkA8 = (s8) (u16)-1; -// (*(void *)0x8007419C)->unkAA = (u8)0; -// (*(void *)0x8007419C)->unkA9 = (s8) (u16)-1; -// (*(void *)0x8007419C)->unk71 = (u8)0; -// general_heap_create(temp_a0); -// func_8011D890(); -// func_801230B8(); -// clear_script_list(); -// create_cameras_a(); -// func_802DD8F8(0); -// func_80120BB0(); -// func_8011E224(); -// clear_model_data(); -// func_80148040(); -// func_80145DF8(); -// func_801452E8(0, 0); -// func_80141100(); -// clear_trigger_data(); -// clear_printers(); -// func_80110CB8(0); -// func_80138108(); -// clear_player_status(); -// func_800384BC(); -// clear_player_data(); -// func_80072B30(); -// func_8003E338(); -// func_80059C9C(); -// clear_item_entity_data(); -// clear_saved_variables(); -// initialize_collision(); -// func_8014AC08(); -// func_801473F0(); -// func_800EB580(); -// func_80149618(); -// func_8014A52C(); -// func_8002BA40(); -// phi_v1 = *(void *)0x8007419C; -// phi_a0 = 0; -// loop_3: -// phi_v1->unk50 = (u16)4; -// phi_v1->unk48 = (u16)0xF; -// temp_a0_2 = phi_a0 + 1; -// phi_v1 = phi_v1 + 2; -// phi_a0 = temp_a0_2; -// if (temp_a0_2 < 4) { -// goto loop_3; -// } -// fio_has_valid_backup(temp_a0_2, (u16)0xF, (u16)4); -// if (*(void *)0x800D9620 == 0) { -// (*(void *)0x8007419C)->unkAB = (u8)1; -// func_8005615C(); -// } else { -// (*(void *)0x8007419C)->unkAB = (u8)0; -// func_80056180(); -// } -// *(void *)0x8009A650 = (s32) (*(void *)0x8009A650 & -9); -// return set_game_mode(1, -9); -} -*/ void func_80033788(void) { func_8002AB5C(0, 0, 0x13F, 0xEF, 0, 0, 0, 0xFF);