From dea08446d3a81843e15da714a0aa3770af15cc07 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 17:29:25 -0700 Subject: [PATCH 01/16] 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 02/16] 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 03/16] 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 86c2917cc08e343ea5797c6b3afa04b71a6fb471 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 04:25:16 +0100 Subject: [PATCH 04/16] match load_map_bg Also added three new symbols to `undefined_syms.h`. Two of these are almost certainly string literals in `load_map_bg`, but we don't have rodata capability yet so they have to be declared in a different way. --- .../code_dc470_len_14c0/load_map_bg.s | 42 ------------------- include/variables.h | 3 ++ src/code_dc470_len_14c0.c | 35 ++++++++-------- undefined_syms.txt | 3 ++ 4 files changed, 24 insertions(+), 59 deletions(-) delete mode 100644 asm/nonmatchings/code_dc470_len_14c0/load_map_bg.s diff --git a/asm/nonmatchings/code_dc470_len_14c0/load_map_bg.s b/asm/nonmatchings/code_dc470_len_14c0/load_map_bg.s deleted file mode 100644 index 6e3b92dec3..0000000000 --- a/asm/nonmatchings/code_dc470_len_14c0/load_map_bg.s +++ /dev/null @@ -1,42 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel load_map_bg -/* 0DC470 80145D70 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0DC474 80145D74 AFBF001C */ sw $ra, 0x1c($sp) -/* 0DC478 80145D78 1080001B */ beqz $a0, .L80145DE8 -/* 0DC47C 80145D7C AFB00018 */ sw $s0, 0x18($sp) -/* 0DC480 80145D80 0080802D */ daddu $s0, $a0, $zero -/* 0DC484 80145D84 0000202D */ daddu $a0, $zero, $zero -/* 0DC488 80145D88 3C05F5DE */ lui $a1, 0xf5de -/* 0DC48C 80145D8C 0C0B1EAF */ jal get_variable -/* 0DC490 80145D90 34A50180 */ ori $a1, $a1, 0x180 -/* 0DC494 80145D94 28420035 */ slti $v0, $v0, 0x35 -/* 0DC498 80145D98 1440000A */ bnez $v0, .L80145DC4 -/* 0DC49C 80145D9C 0200202D */ daddu $a0, $s0, $zero -/* 0DC4A0 80145DA0 3C058015 */ lui $a1, 0x8015 -/* 0DC4A4 80145DA4 24A5F120 */ addiu $a1, $a1, -0xee0 -/* 0DC4A8 80145DA8 0C01BB5C */ jal strcmp -/* 0DC4AC 80145DAC 0200202D */ daddu $a0, $s0, $zero -/* 0DC4B0 80145DB0 54400004 */ bnel $v0, $zero, .L80145DC4 -/* 0DC4B4 80145DB4 0200202D */ daddu $a0, $s0, $zero -/* 0DC4B8 80145DB8 3C108015 */ lui $s0, 0x8015 -/* 0DC4BC 80145DBC 2610F128 */ addiu $s0, $s0, -0xed8 -/* 0DC4C0 80145DC0 0200202D */ daddu $a0, $s0, $zero -.L80145DC4: -/* 0DC4C4 80145DC4 0C016B3A */ jal load_asset_by_name -/* 0DC4C8 80145DC8 27A50010 */ addiu $a1, $sp, 0x10 -/* 0DC4CC 80145DCC 0040802D */ daddu $s0, $v0, $zero -/* 0DC4D0 80145DD0 3C058020 */ lui $a1, 0x8020 -/* 0DC4D4 80145DD4 24A50000 */ addiu $a1, $a1, 0 -/* 0DC4D8 80145DD8 0C01BB7C */ jal decode_yay0 -/* 0DC4DC 80145DDC 0200202D */ daddu $a0, $s0, $zero -/* 0DC4E0 80145DE0 0C00AB1E */ jal general_heap_free -/* 0DC4E4 80145DE4 0200202D */ daddu $a0, $s0, $zero -.L80145DE8: -/* 0DC4E8 80145DE8 8FBF001C */ lw $ra, 0x1c($sp) -/* 0DC4EC 80145DEC 8FB00018 */ lw $s0, 0x18($sp) -/* 0DC4F0 80145DF0 03E00008 */ jr $ra -/* 0DC4F4 80145DF4 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/include/variables.h b/include/variables.h index e4039c8b0f..fdd8d32246 100644 --- a/include/variables.h +++ b/include/variables.h @@ -15,6 +15,9 @@ extern s16* D_80151328; extern s16 D_8010CD10; extern s16 D_8010CD12; extern s32 D_801595A0; +extern u8 gCloudyFlowerFieldsBg; // "fla_bg" +extern u8 gSunnyFlowerFieldsBg; // "flb_bg" +extern UNK_TYPE gBackgroundImage; extern s8 D_8014F12F; // Triggers diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index 802dbe547a..8658e02fbb 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -1,25 +1,26 @@ #include "common.h" -INCLUDE_ASM(code_dc470_len_14c0, load_map_bg); -/* close match -void load_map_bg (s32 arg0) { - s32 tempvar0 = arg0; - s32 flowerfields_bg1 = 0x80140EE0; - s32 tempvar3 = get_variable(0, 0xF5DE0180); - if (tempvar0 == 0) { - return; - }else{ - if (tempvar3 > 0x0034) { - if (strcmp(tempvar0, 0x8014F120) == 0) { - tempvar0 = flowerfields_bg1; - } - load_asset_by_name (tempvar0, 0); +void load_map_bg(u8* optAssetName) { + UNK_PTR compressedData; + u32 assetSize; + u8* assetName; + + if (!optAssetName) return; + assetName = optAssetName; + + // StoryProgress check + if (get_variable(0, 0xF5DE0180) >= 0x35) { + // Use sunny Flower Fields bg rather than cloudy + // TODO: these globals should be string literals + if (!strcmp(assetName, &gCloudyFlowerFieldsBg)) { + assetName = &gSunnyFlowerFieldsBg; } } - decode_yay0(tempvar0, 0x80200000); - general_heap_free(tempvar0); + + compressedData = load_asset_by_name(assetName, &assetSize); + decode_yay0(compressedData, &gBackgroundImage); + general_heap_free(compressedData); } -*/ void func_80145DF8(void) { game_status* gameStatus = *gGameStatusPtr; diff --git a/undefined_syms.txt b/undefined_syms.txt index 0965e25b8e..d919d30ecf 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -36,6 +36,7 @@ D_8009A650 = 0x8009A650; D_800A0900 = 0x800A0900; D_800DC500 = 0x800DC500; D_8010F6D0 = 0x8010F6D0; +gBackgroundImage = 0x80200000; D_802C3000 = 0x802C3000; D_802DBD40 = 0x802DBD40; D_802E0D90 = 0x802E0D90; @@ -52,6 +53,8 @@ D_00316D90 = 0x00316D90; D_00316F30 = 0x00316F30; D_8010D000 = 0x8010D000; +gCloudyFlowerFieldsBg = 0x8014F120; +gSunnyFlowerFieldsBg = 0x8014F128; D_8014F12F = 0x8014F12F; D_8014F140 = 0x8014F140; D_80151308 = 0x80151308; From 15f3d1a5652392c977fb87c2f82d5c7ed1207f15 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 04:37:24 +0100 Subject: [PATCH 05/16] use bg_header type for gBackgroundImage --- include/variables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/variables.h b/include/variables.h index fdd8d32246..8ed697f621 100644 --- a/include/variables.h +++ b/include/variables.h @@ -17,7 +17,7 @@ extern s16 D_8010CD12; extern s32 D_801595A0; extern u8 gCloudyFlowerFieldsBg; // "fla_bg" extern u8 gSunnyFlowerFieldsBg; // "flb_bg" -extern UNK_TYPE gBackgroundImage; +extern bg_header gBackgroundImage; extern s8 D_8014F12F; // Triggers From 78d23805e00b77109c90b3f57d812cfea44f98f2 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 05:08:55 +0100 Subject: [PATCH 06/16] wip: update game_status struct Non-matching right now, I probably made an alignment/sizing error somewhere - proofreading would be appreciated. --- include/common_structs.h | 84 ++++++++++++++++++++++++++------------- src/code_111f0_len_860.c | 10 ++--- src/code_6000.c | 4 +- src/code_80850_len_3060.c | 8 ++-- src/code_dbd70_len_700.c | 2 +- src/code_dc470_len_14c0.c | 26 ++++++------ 6 files changed, 82 insertions(+), 52 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 9d14cb123e..28a8517fec 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -5,19 +5,33 @@ #include "types.h" typedef struct { - /* 0x000 */ s16 unk_00; - /* 0x002 */ s16 unk_02; - /* 0x004 */ char unk_04[0x44]; + /* 0x000 */ u32 currentButtons; + /* 0x004 */ u32 altCurrentButtons; /* used for battle when flag 80000 set */ + /* 0x008 */ char unk_08[4]; + /* 0x010 */ u32 pressedButtons; /* 1 for the frame button begins to be held */ + /* 0x014 */ u32 altPressedButtons; /* used for battle when flag 80000 set */ + /* 0x018 */ char unk_18[4]; + /* 0x020 */ u32 heldButtons; /* 1 every 4th frame during hold */ + /* 0x024 */ u32 altHeldButtons; /* used for battle when flag 80000 set */ + /* 0x028 */ char unk_28[4]; + /* 0x030 */ u32 prevButtons; /* from previous frame */ + /* 0x034 */ char unk_34[8]; + /* 0x040 */ u8 stickX; /* with deadzone */ + /* 0x041 */ u8 altStickX; /* used for battle when flag 80000 set */ + /* 0x042 */ char unk_42[2]; + /* 0x044 */ u8 stickY; /* with deadzone */ + /* 0x045 */ u8 altStickY; /* used for battle when flag 80000 set */ + /* 0x046 */ char unk_46[2]; /* 0x048 */ u16 unk_48[4]; /* 0x050 */ u16 unk_50[4]; /* 0x058 */ char unk_58[0x10]; /* 0x068 */ u16 demoButtonInput; /* 0x06A */ s8 demoStickX; /* 0x06B */ s8 demoStickY; - /* 0x06C */ char unk_6C[0x4]; - /* 0x070 */ s8 unk_70; - /* 0x071 */ s8 demoState; - /* 0x072 */ s8 unk_72; + /* 0x06C */ u32* mainScriptID; + /* 0x070 */ u8 isBattle; + /* 0x071 */ u8 demoState; /* 0 = not demo, 1 = map demo, 2 = demo transition */ + /* 0x072 */ u8 nextDemoScene; /* 0x073 */ char unk_73[2]; /* 0x075 */ s8 unk_75; /* 0x076 */ char unk_76[3]; @@ -25,42 +39,58 @@ typedef struct { /* 0x07A */ s8 musicEnabled; /* 0x07B */ char unk_7B; /* 0x07C */ s8 unk_7C; - /* 0x07D */ char unk_7D[4]; + /* 0x07D */ char unk_7D; + /* 0x07E */ u8 peachFlags; /* 1 = peach, 2 = transformed, 4 = has umbrella */ + /* 0x07F */ u8 peachDisguise; /* 1 = koopatrol, 2 = hammer bros, 3 = clubba */ + /* 0x080 */ char unk_80; /* 0x081 */ s8 unk_81; /* 0x082 */ s8 unk_82; /* 0x083 */ s8 unk_83; /* 0x084 */ char unk_84[2]; - /* 0x086 */ s16 unk_86; - /* 0x088 */ s16 unk_88; - /* 0x08A */ s16 unk_8A; + /* 0x086 */ s16 areaID; + /* 0x088 */ s16 prevArea; + /* 0x089 */ char unk_89; + /* 0x08A */ u8 changedArea; /* 0x08C */ s16 mapID; - /* 0x08E */ char unk_8E[0x1A]; + /* 0x08E */ s16 entryID; + /* 0x090 */ char unk_90[3]; + /* 0x094 */ f32 exitAngle; + /* 0x098 */ f32 playerPos[3]; + /* 0x0A4 */ f32 playerYaw; /* 0x0A8 */ s8 unk_A8; /* 0x0A9 */ char unk_A9; /* 0x0AA */ s8 unk_AA; /* 0x0AB */ char unk_AB[1]; - /* 0x0AC */ s8 unk_AC; - /* 0x0AD */ char unk_AD[0x09]; + /* 0x0AC */ u8 loadMenuState; + /* 0x0AD */ u8 menuCounter; + /* 0x0AE */ char unk_AE[0x08]; /* 0x0B6 */ s16 boot_alpha; /* 0x0B8 */ s16 boot_blue; /* 0x0BA */ s16 boot_green; /* 0x0BC */ s16 boot_red; - /* 0x0BE */ char unk_BE[0x76]; - /* 0x134 */ u16 unk_134; - /* 0x136 */ char unk_136[0x6]; + /* 0x0BE */ char unk_BE[0x6A]; + /* 0x128 */ f32 playerTraceNormal[3]; + /* 0x134 */ u16 frameCounter; + /* 0x136 */ s32 nextRNG; + /* 0x13A */ char unk_136[0x2]; /* 0x13C */ s16 unk_13C; - /* 0x13E */ char unk_13E[0xA]; - /* 0x148 */ s16 unk_148; - /* 0x14A */ s16 unk_14A; - /* 0x14C */ s16 unk_14C; - /* 0x14E */ s16 unk_14E; - /* 0x150 */ s16 unk_150; - /* 0x152 */ char unk_152[2]; - /* 0x154 */ s32 unk_154; - /* 0x158 */ s32 unk_158; + /* 0x13E */ char unk_13E[0x2]; + /* 0x140 */ UNK_PTR shopItemData; + /* 0x144 */ UNK_PTR mapShop; + /* 0x148 */ s16 backgroundFlags; + /* 0x14A */ s16 backgroundMinW; + /* 0x14C */ s16 backgroundMinH; + /* 0x14E */ s16 backgroundMaxW; + /* 0x150 */ s16 backgroundMaxH; + /* 0x152 */ u16 backgroundXOffset; + /* 0x154 */ UNK_PTR backgroundRaster; + /* 0x158 */ UNK_PTR backgroundPalette; /* 0x15C */ s16 unk_15C; /* 0x15E */ char unk_15E[0xA]; - /* 0x168 */ s32 unk_168; + /* 0x160 */ s16 savedPos[3]; + /* 0x166 */ s8 saveSlot; + /* 0x167 */ u8 loadType; /* 0 = from map, 1 = from main menu */ + /* 0x168 */ s32 saveCount; } game_status; typedef enum eItemEntityState { diff --git a/src/code_111f0_len_860.c b/src/code_111f0_len_860.c index fb62baaec7..ac9fe471b2 100644 --- a/src/code_111f0_len_860.c +++ b/src/code_111f0_len_860.c @@ -16,7 +16,7 @@ INCLUDE_ASM(code_111f0_len_860, func_80035EEC); void func_800360FC(void) { game_status* gameStatus = *gGameStatusPtr; - if (gameStatus->unk_AC == 2) { + if (gameStatus->loadMenuState == 2) { func_800E973C(); } } @@ -28,11 +28,11 @@ void func_80036130(void) { D_800A0942 = 0x14; D_800A0944 = 0x00; - if (gameStatus->unk_88 != gameStatus->unk_86) { - gameStatus->unk_8A = 0x01; - gameStatus->unk_88 = gameStatus->unk_86; + if (gameStatus->prevArea != gameStatus->areaID) { + gameStatus->changedArea = 1; + gameStatus->prevArea = gameStatus->areaID; } else { - gameStatus->unk_8A = 0; + gameStatus->changedArea = 0; } } diff --git a/src/code_6000.c b/src/code_6000.c index 3f1cecb566..9f465f8d06 100644 --- a/src/code_6000.c +++ b/src/code_6000.c @@ -35,7 +35,7 @@ s32 func_8002ACDC(void) { } s32 heap_malloc(s32 size) { - if ((*gGameStatusPtr)->unk_70 == 0) { + if ((*gGameStatusPtr)->isBattle == 0) { return general_heap_malloc(size); } else { return _heap_malloc(&D_803DA800, size); @@ -43,7 +43,7 @@ s32 heap_malloc(s32 size) { } s32 heap_free(s32 size) { - if ((*gGameStatusPtr)->unk_70 != 0) { + if ((*gGameStatusPtr)->isBattle != 0) { return _heap_free(&D_803DA800, size); } else { return general_heap_free(size); diff --git a/src/code_80850_len_3060.c b/src/code_80850_len_3060.c index 5f0d001039..83fb6317b8 100644 --- a/src/code_80850_len_3060.c +++ b/src/code_80850_len_3060.c @@ -283,7 +283,7 @@ void coin_counter_draw_content(UNK_TYPE arg0, s32 posX, s32 posY) { ui_status* uiStatus = &gUIStatus; s32 iconIndex; - if ((gPlayerData.coins != uiStatus->displayCoins) && (((*gGameStatusPtr)->unk_134 % 3) == 0)) { + if ((gPlayerData.coins != uiStatus->displayCoins) && (((*gGameStatusPtr)->frameCounter % 3) == 0)) { play_sound(0x211); } @@ -521,7 +521,7 @@ void status_menu_start_blinking_hp(void) { ui_status* uiStatus = &gUIStatus; ui_status* uiStatus2 = &gUIStatus; - if (gameStatus->unk_70 == 0) { + if (gameStatus->isBattle == 0) { uiStatus->hpBlinkTimer = 120; } @@ -546,7 +546,7 @@ void status_menu_start_blinking_fp(void) { ui_status* uiStatus = &gUIStatus; ui_status* uiStatus2 = &gUIStatus; - if (gameStatus->unk_70 == 0) { + if (gameStatus->isBattle == 0) { uiStatus->fpBlinkTimer = 120; } @@ -570,7 +570,7 @@ void status_menu_start_blinking_coins(void) { ui_status* uiStatus = &gUIStatus; ui_status* uiStatus2 = &gUIStatus; - if (gameStatus->unk_70 == 0) { + if (gameStatus->isBattle == 0) { uiStatus->coinsBlinkTimer = 120; } diff --git a/src/code_dbd70_len_700.c b/src/code_dbd70_len_700.c index 7925f5f8b3..3276454963 100644 --- a/src/code_dbd70_len_700.c +++ b/src/code_dbd70_len_700.c @@ -9,7 +9,7 @@ INCLUDE_ASM(code_dbd70_len_700, clear_trigger_data); //INCLUDE_ASM(code_dbd70_len_700, init_trigger_list); void init_trigger_list(void) { - if ((*gGameStatusPtr)->unk_70 == 0) { + if ((*gGameStatusPtr)->isBattle == 0) { *gCurrentTriggerListPtr = gTriggerList1; } else { *gCurrentTriggerListPtr = gTriggerList2; diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index 802dbe547a..4a712de0c9 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -27,29 +27,29 @@ void func_80145DF8(void) { D_8014F12F = 0; gameStatus->unk_15C = 0xB4; - gameStatus->unk_148 &= 0xF0; + gameStatus->backgroundFlags &= 0xF0; } void read_background_size(bg_header *bg) { game_status* gameStatus = *gGameStatusPtr; - gameStatus->unk_14E = bg->width; - gameStatus->unk_150 = bg->height; - gameStatus->unk_14A = bg->startX; - gameStatus->unk_14C = bg->startY; - gameStatus->unk_154 = bg->palette; - gameStatus->unk_158 = bg->raster; - gameStatus->unk_148 |= 1; + gameStatus->backgroundMaxW = bg->width; + gameStatus->backgroundMaxH = bg->height; + gameStatus->backgroundMinW = bg->startX; + gameStatus->backgroundMinH = bg->startY; + gameStatus->backgroundPalette = bg->palette; + gameStatus->backgroundRaster = bg->raster; + gameStatus->backgroundFlags |= 1; } void set_background_size(s16 startX, s16 startY, s16 sizeX, s16 sizeY) { game_status* gameStatus = *gGameStatusPtr; - gameStatus->unk_148 &= ~1; - gameStatus->unk_14E = startX; - gameStatus->unk_150 = startY; - gameStatus->unk_14A = sizeX; - gameStatus->unk_14C = sizeY; + gameStatus->backgroundFlags &= ~1; + gameStatus->backgroundMinW = startX; + gameStatus->backgroundMinH = startY; + gameStatus->backgroundMaxW = sizeX; + gameStatus->backgroundMaxH = sizeY; } u16 func_80145E98(s32 arg0, s32 arg1, s32 arg2) { From d041f520abce4394a1d7211b1ae601e1866915e8 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 05:15:00 +0100 Subject: [PATCH 07/16] explicitly check for NULL --- src/code_dc470_len_14c0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index 8658e02fbb..291dd60e2b 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -5,7 +5,7 @@ void load_map_bg(u8* optAssetName) { u32 assetSize; u8* assetName; - if (!optAssetName) return; + if (optAssetName == NULL) return; assetName = optAssetName; // StoryProgress check From 357220cf92245d11d6523a24160a5a8824291ebc Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 05:22:59 +0100 Subject: [PATCH 08/16] fix some mis-sized unknown fields --- include/common_structs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 28a8517fec..1f1c57893f 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -7,15 +7,15 @@ typedef struct { /* 0x000 */ u32 currentButtons; /* 0x004 */ u32 altCurrentButtons; /* used for battle when flag 80000 set */ - /* 0x008 */ char unk_08[4]; + /* 0x008 */ char unk_08[8]; /* 0x010 */ u32 pressedButtons; /* 1 for the frame button begins to be held */ /* 0x014 */ u32 altPressedButtons; /* used for battle when flag 80000 set */ - /* 0x018 */ char unk_18[4]; + /* 0x018 */ char unk_18[8]; /* 0x020 */ u32 heldButtons; /* 1 every 4th frame during hold */ /* 0x024 */ u32 altHeldButtons; /* used for battle when flag 80000 set */ - /* 0x028 */ char unk_28[4]; + /* 0x028 */ char unk_28[8]; /* 0x030 */ u32 prevButtons; /* from previous frame */ - /* 0x034 */ char unk_34[8]; + /* 0x034 */ char unk_34[12]; /* 0x040 */ u8 stickX; /* with deadzone */ /* 0x041 */ u8 altStickX; /* used for battle when flag 80000 set */ /* 0x042 */ char unk_42[2]; From 9eb74da229123d509ae0291eb0451e3975505e49 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 05:25:13 +0100 Subject: [PATCH 09/16] use `char[]` type for string externs --- include/variables.h | 4 ++-- src/code_dc470_len_14c0.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/variables.h b/include/variables.h index 8ed697f621..34ec16f1d7 100644 --- a/include/variables.h +++ b/include/variables.h @@ -15,8 +15,8 @@ extern s16* D_80151328; extern s16 D_8010CD10; extern s16 D_8010CD12; extern s32 D_801595A0; -extern u8 gCloudyFlowerFieldsBg; // "fla_bg" -extern u8 gSunnyFlowerFieldsBg; // "flb_bg" +extern char gCloudyFlowerFieldsBg[]; // "fla_bg" +extern char gSunnyFlowerFieldsBg[]; // "flb_bg" extern bg_header gBackgroundImage; extern s8 D_8014F12F; diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index 291dd60e2b..4e3bc4a1db 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -1,9 +1,9 @@ #include "common.h" -void load_map_bg(u8* optAssetName) { +void load_map_bg(char* optAssetName) { UNK_PTR compressedData; u32 assetSize; - u8* assetName; + char* assetName; if (optAssetName == NULL) return; assetName = optAssetName; @@ -12,8 +12,8 @@ void load_map_bg(u8* optAssetName) { if (get_variable(0, 0xF5DE0180) >= 0x35) { // Use sunny Flower Fields bg rather than cloudy // TODO: these globals should be string literals - if (!strcmp(assetName, &gCloudyFlowerFieldsBg)) { - assetName = &gSunnyFlowerFieldsBg; + if (!strcmp(assetName, gCloudyFlowerFieldsBg)) { + assetName = gSunnyFlowerFieldsBg; } } From a2f974711210d7010bdd623d7fc2c16ac6a084b3 Mon Sep 17 00:00:00 2001 From: Jdog Date: Thu, 13 Aug 2020 22:22:16 -0700 Subject: [PATCH 10/16] 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 652d2ada46e60109821891a39ec6c1c4d0b2aa25 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Fri, 14 Aug 2020 12:47:54 +0100 Subject: [PATCH 11/16] match game_status --- include/common_structs.h | 44 +++++++++++++++++++-------------------- src/code_dc470_len_14c0.c | 10 ++++----- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 1f1c57893f..8a42c8d6a3 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -7,21 +7,21 @@ typedef struct { /* 0x000 */ u32 currentButtons; /* 0x004 */ u32 altCurrentButtons; /* used for battle when flag 80000 set */ - /* 0x008 */ char unk_08[8]; + /* 0x008 */ char unk_08[0x8]; /* 0x010 */ u32 pressedButtons; /* 1 for the frame button begins to be held */ /* 0x014 */ u32 altPressedButtons; /* used for battle when flag 80000 set */ - /* 0x018 */ char unk_18[8]; + /* 0x018 */ char unk_18[0x8]; /* 0x020 */ u32 heldButtons; /* 1 every 4th frame during hold */ /* 0x024 */ u32 altHeldButtons; /* used for battle when flag 80000 set */ - /* 0x028 */ char unk_28[8]; + /* 0x028 */ char unk_28[0x8]; /* 0x030 */ u32 prevButtons; /* from previous frame */ - /* 0x034 */ char unk_34[12]; + /* 0x034 */ char unk_34[0xC]; /* 0x040 */ u8 stickX; /* with deadzone */ /* 0x041 */ u8 altStickX; /* used for battle when flag 80000 set */ - /* 0x042 */ char unk_42[2]; + /* 0x042 */ char unk_42[0x2]; /* 0x044 */ u8 stickY; /* with deadzone */ /* 0x045 */ u8 altStickY; /* used for battle when flag 80000 set */ - /* 0x046 */ char unk_46[2]; + /* 0x046 */ char unk_46[0x2]; /* 0x048 */ u16 unk_48[4]; /* 0x050 */ u16 unk_50[4]; /* 0x058 */ char unk_58[0x10]; @@ -29,12 +29,12 @@ typedef struct { /* 0x06A */ s8 demoStickX; /* 0x06B */ s8 demoStickY; /* 0x06C */ u32* mainScriptID; - /* 0x070 */ u8 isBattle; + /* 0x070 */ s8 isBattle; /* 0x071 */ u8 demoState; /* 0 = not demo, 1 = map demo, 2 = demo transition */ /* 0x072 */ u8 nextDemoScene; - /* 0x073 */ char unk_73[2]; + /* 0x073 */ char unk_73[0x2]; /* 0x075 */ s8 unk_75; - /* 0x076 */ char unk_76[3]; + /* 0x076 */ char unk_76[0x3]; /* 0x079 */ s8 unk_79; /* 0x07A */ s8 musicEnabled; /* 0x07B */ char unk_7B; @@ -46,22 +46,21 @@ typedef struct { /* 0x081 */ s8 unk_81; /* 0x082 */ s8 unk_82; /* 0x083 */ s8 unk_83; - /* 0x084 */ char unk_84[2]; + /* 0x084 */ char unk_84[0x2]; /* 0x086 */ s16 areaID; /* 0x088 */ s16 prevArea; - /* 0x089 */ char unk_89; - /* 0x08A */ u8 changedArea; + /* 0x08A */ s16 changedArea; /* 0x08C */ s16 mapID; /* 0x08E */ s16 entryID; - /* 0x090 */ char unk_90[3]; + /* 0x090 */ char unk_90[0x3]; /* 0x094 */ f32 exitAngle; /* 0x098 */ f32 playerPos[3]; /* 0x0A4 */ f32 playerYaw; /* 0x0A8 */ s8 unk_A8; /* 0x0A9 */ char unk_A9; /* 0x0AA */ s8 unk_AA; - /* 0x0AB */ char unk_AB[1]; - /* 0x0AC */ u8 loadMenuState; + /* 0x0AB */ char unk_AB[0x1]; + /* 0x0AC */ s8 loadMenuState; /* 0x0AD */ u8 menuCounter; /* 0x0AE */ char unk_AE[0x08]; /* 0x0B6 */ s16 boot_alpha; @@ -71,10 +70,8 @@ typedef struct { /* 0x0BE */ char unk_BE[0x6A]; /* 0x128 */ f32 playerTraceNormal[3]; /* 0x134 */ u16 frameCounter; - /* 0x136 */ s32 nextRNG; - /* 0x13A */ char unk_136[0x2]; - /* 0x13C */ s16 unk_13C; - /* 0x13E */ char unk_13E[0x2]; + /* 0x138 */ s32 nextRNG; + /* 0x13A */ char unk_13A[0x4]; /* 0x140 */ UNK_PTR shopItemData; /* 0x144 */ UNK_PTR mapShop; /* 0x148 */ s16 backgroundFlags; @@ -86,12 +83,13 @@ typedef struct { /* 0x154 */ UNK_PTR backgroundRaster; /* 0x158 */ UNK_PTR backgroundPalette; /* 0x15C */ s16 unk_15C; - /* 0x15E */ char unk_15E[0xA]; + /* 0x15E */ char unk_15E[0x2]; /* 0x160 */ s16 savedPos[3]; /* 0x166 */ s8 saveSlot; /* 0x167 */ u8 loadType; /* 0 = from map, 1 = from main menu */ /* 0x168 */ s32 saveCount; -} game_status; + /* 0x16C */ char unk_16C[0x10]; +} game_status; // size = 0x178 typedef enum eItemEntityState { CollisionWithPlayer=3, @@ -513,8 +511,8 @@ typedef struct { } script_context; // size = 0x168; typedef struct { - /* 0x00 */ u32 palette; - /* 0x04 */ u32 raster; + /* 0x00 */ u32 raster; + /* 0x04 */ u32 palette; /* 0x08 */ u16 startX; /* 0x0A */ u16 startY; /* 0x0C */ u16 width; diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index 4a712de0c9..4689943303 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -37,8 +37,8 @@ void read_background_size(bg_header *bg) { gameStatus->backgroundMaxH = bg->height; gameStatus->backgroundMinW = bg->startX; gameStatus->backgroundMinH = bg->startY; - gameStatus->backgroundPalette = bg->palette; gameStatus->backgroundRaster = bg->raster; + gameStatus->backgroundPalette = bg->palette; gameStatus->backgroundFlags |= 1; } @@ -46,10 +46,10 @@ void set_background_size(s16 startX, s16 startY, s16 sizeX, s16 sizeY) { game_status* gameStatus = *gGameStatusPtr; gameStatus->backgroundFlags &= ~1; - gameStatus->backgroundMinW = startX; - gameStatus->backgroundMinH = startY; - gameStatus->backgroundMaxW = sizeX; - gameStatus->backgroundMaxH = sizeY; + gameStatus->backgroundMaxW = startX; + gameStatus->backgroundMaxH = startY; + gameStatus->backgroundMinW = sizeX; + gameStatus->backgroundMinH = sizeY; } u16 func_80145E98(s32 arg0, s32 arg1, s32 arg2) { From 73e1eff76e3f7a211a97a99faeec153246ee6af4 Mon Sep 17 00:00:00 2001 From: Jdog Date: Fri, 14 Aug 2020 07:25:33 -0700 Subject: [PATCH 12/16] 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 13/16] 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 14/16] 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); From bc5fa0f5bfad605a3ed95429e4ee4331ef8b60b2 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Fri, 14 Aug 2020 11:05:28 -0400 Subject: [PATCH 15/16] fix master --- include/common_structs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/common_structs.h b/include/common_structs.h index 8a42c8d6a3..40e08b8ded 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -30,7 +30,7 @@ typedef struct { /* 0x06B */ s8 demoStickY; /* 0x06C */ u32* mainScriptID; /* 0x070 */ s8 isBattle; - /* 0x071 */ u8 demoState; /* 0 = not demo, 1 = map demo, 2 = demo transition */ + /* 0x071 */ s8 demoState; /* 0 = not demo, 1 = map demo, 2 = demo transition */ /* 0x072 */ u8 nextDemoScene; /* 0x073 */ char unk_73[0x2]; /* 0x075 */ s8 unk_75; From 6ad458178874d15ca64419177978c5cdbc183e1b Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Fri, 14 Aug 2020 11:24:31 -0400 Subject: [PATCH 16/16] fix --- src/code_e940_len_290.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_e940_len_290.c b/src/code_e940_len_290.c index a389d9fba9..49a725861d 100644 --- a/src/code_e940_len_290.c +++ b/src/code_e940_len_290.c @@ -2,7 +2,7 @@ void func_80033540(void) { D_8009A650[0] |= 8; - (*gGameStatusPtr)->unk_AC = 3; + (*gGameStatusPtr)->loadMenuState = 3; } INCLUDE_ASM(code_e940_len_290, func_80033568);