From 75ab4b3ee76783d693be7ed8c27b12b3a1d93cc2 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 30 Oct 2024 23:48:25 -0400 Subject: [PATCH 1/7] Update webhook.sh, build.yml --- .github/calcrom/webhook.sh | 4 ++-- .github/workflows/build.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/calcrom/webhook.sh b/.github/calcrom/webhook.sh index ba8e941a1c..ff3f88830a 100644 --- a/.github/calcrom/webhook.sh +++ b/.github/calcrom/webhook.sh @@ -1,7 +1,7 @@ #!/bin/bash -ex -# Only run this script if it's the master branch build. -if [[ "$GITHUB_REF" != "refs/heads/master" || "$GITHUB_EVENT_NAME" != "push" ]]; then +# Only run this script if it's the main branch build. +if [[ "$GITHUB_REF" != "refs/heads/main" || "$GITHUB_EVENT_NAME" != "push" ]]; then exit 0 fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cde394844..0ff7696a94 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: build on: push: - branches: [ master ] + branches: [ main ] pull_request: workflow_dispatch: From 39dd3fc0530f2bc5d68293e786156ca4c8fb2c5f Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:40:14 -0400 Subject: [PATCH 2/7] typedef PhoneBook, decomp pt 1 --- ..._02_02251E74.s => overlay_02_02251E74_s.s} | 187 ------------------ include/gear_phone.h | 4 +- include/overlay_02.h | 2 - include/overlay_2/overlay_02_02251E74.h | 17 ++ main.lsf | 3 +- src/overlay_02_02251E74.c | 94 +++++++++ src/scrcmd_c.c | 1 + src/unk_02092BE8.c | 2 + 8 files changed, 118 insertions(+), 192 deletions(-) rename asm/{overlay_02_02251E74.s => overlay_02_02251E74_s.s} (93%) create mode 100644 include/overlay_2/overlay_02_02251E74.h create mode 100644 src/overlay_02_02251E74.c diff --git a/asm/overlay_02_02251E74.s b/asm/overlay_02_02251E74_s.s similarity index 93% rename from asm/overlay_02_02251E74.s rename to asm/overlay_02_02251E74_s.s index 59e8f281b7..3e6f1ba987 100644 --- a/asm/overlay_02_02251E74.s +++ b/asm/overlay_02_02251E74_s.s @@ -10,193 +10,6 @@ .text - thumb_func_start GetPhoneBookEntryName -GetPhoneBookEntryName: ; 0x02251E74 - push {r3, r4, r5, lr} - add r4, r1, #0 - ldrb r1, [r0] - lsl r1, r1, #0x1f - lsr r1, r1, #0x1f - beq _02251E86 - ldrb r0, [r0, #2] - cmp r0, #0x4b - blo _02251E92 -_02251E86: - mov r0, #8 - add r1, r4, #0 - bl String_New - add r5, r0, #0 - b _02251EB2 -_02251E92: - bl GetPhoneMessageGmm - add r2, r0, #0 - mov r0, #1 - mov r1, #0x1b - add r3, r4, #0 - bl NewMsgDataFromNarc - add r4, r0, #0 - mov r1, #0 - bl NewString_ReadMsgData - add r5, r0, #0 - add r0, r4, #0 - bl DestroyMsgData -_02251EB2: - add r0, r5, #0 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end GetPhoneBookEntryName - - thumb_func_start ov02_02251EB8 -ov02_02251EB8: ; 0x02251EB8 - push {r4, lr} - add r4, r0, #0 - cmp r1, #0x4b - blo _02251ED0 - mov r0, #0xff - strb r0, [r4, #2] - strb r0, [r4, #5] - mov r0, #0 - strb r0, [r4, #6] - bl GF_AssertFail - b _02251ED6 -_02251ED0: - strb r1, [r4, #2] - strb r2, [r4, #5] - strb r3, [r4, #6] -_02251ED6: - ldr r0, _02251EE4 ; =0xFFFFFFF8 - add r0, sp - ldrb r1, [r0, #0x10] - strb r1, [r4, #3] - ldrb r0, [r0, #0x14] - strb r0, [r4, #4] - pop {r4, pc} - .balign 4, 0 -_02251EE4: .word 0xFFFFFFF8 - thumb_func_end ov02_02251EB8 - - thumb_func_start ov02_02251EE8 -ov02_02251EE8: ; 0x02251EE8 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r0, r4, #0 - mov r1, #0 - mov r2, #5 - bl MI_CpuFill8 - ldrb r0, [r5, #2] - cmp r0, #0x4b - blo _02251F08 - bl GF_AssertFail - mov r0, #0xff - strb r0, [r4] - pop {r3, r4, r5, pc} -_02251F08: - ldrb r0, [r5, #5] - strb r0, [r4] - ldrb r0, [r5, #6] - strb r0, [r4, #1] - ldrb r0, [r5, #3] - strb r0, [r4, #3] - ldrb r0, [r5, #4] - strb r0, [r4, #4] - ldrb r0, [r5, #7] - strb r0, [r4, #2] - ldrb r0, [r5, #2] - pop {r3, r4, r5, pc} - thumb_func_end ov02_02251EE8 - - thumb_func_start ov02_02251F20 -ov02_02251F20: ; 0x02251F20 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - ldr r0, [r5, #0x38] - bl Save_LocalFieldData_Get - bl LocalFieldData_GetCurrentPosition - add r4, r0, #0 - ldr r0, [r4] - bl MapHeader_GetField14_1E - cmp r0, #0 - bne _02251F3E - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_02251F3E: - ldrb r0, [r5] - lsl r0, r0, #0x1f - lsr r0, r0, #0x1f - bne _02251F4E - ldr r1, [r5, #8] - ldr r0, [r5, #0xc] - cmp r1, r0 - bge _02251F52 -_02251F4E: - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_02251F52: - mov r0, #4 - bl AllocAndReadPhoneBook - add r6, r0, #0 - ldr r2, [r4] - add r0, r5, #0 - add r1, r6, #0 - bl ov02_022521C0 - add r7, r0, #0 - beq _02251F9C - add r0, r6, #0 - bl FreePhoneBook - cmp r7, #2 - bne _02251F90 - ldr r2, [r5, #0x3c] - add r0, r2, #0 - add r0, #0xd2 - ldrb r1, [r0] - mov r0, #0x80 - add r2, #0xd2 - orr r0, r1 - strb r0, [r2] - ldr r0, [r5, #0x3c] - ldr r1, _02251FD8 ; =0x000007FF - mov r2, #0 - bl StartMapSceneScript - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_02251F90: - add r0, r5, #0 - mov r1, #1 - bl ov02_022522AC - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_02251F9C: - bl MTRandom - mov r1, #0x64 - bl _u32_div_f - ldrh r0, [r5, #0x12] - cmp r1, r0 - bls _02251FB8 - add r0, r6, #0 - bl FreePhoneBook - mov r0, #0 - str r0, [r5, #8] - pop {r3, r4, r5, r6, r7, pc} -_02251FB8: - ldr r2, [r4] - add r0, r5, #0 - add r1, r6, #0 - bl ov02_02251FDC - add r4, r0, #0 - add r0, r6, #0 - bl FreePhoneBook - cmp r4, #0 - bne _02251FD2 - mov r0, #0 - str r0, [r5, #8] -_02251FD2: - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} - nop -_02251FD8: .word 0x000007FF - thumb_func_end ov02_02251F20 - thumb_func_start ov02_02251FDC ov02_02251FDC: ; 0x02251FDC push {r3, r4, r5, r6, r7, lr} diff --git a/include/gear_phone.h b/include/gear_phone.h index cbb4572527..3b4cbd69d1 100644 --- a/include/gear_phone.h +++ b/include/gear_phone.h @@ -16,9 +16,9 @@ typedef struct PhoneBookEntry { u8 unk10[4]; } PhoneBookEntry; -struct PhoneBook { +typedef struct PhoneBook { int count; struct PhoneBookEntry *entries; -}; +} PhoneBook; #endif // POKEHEARTGOLD_GEAR_PHONE_H diff --git a/include/overlay_02.h b/include/overlay_02.h index e31eae0286..60f4d50cad 100644 --- a/include/overlay_02.h +++ b/include/overlay_02.h @@ -49,7 +49,6 @@ BOOL Task_FieldTeleport(TaskManager *taskManager); BOOL Task_FieldDig(TaskManager *taskManager); BOOL ov02_0224C1F8(TaskManager *taskManager); void *ov02_0224C1D8(FieldSystem *fieldSystem, int a1, int a2); -u8 ov02_02251EE8(GearPhoneRingManager *a0, u8 *a1); // TODO: define the struct, figure out what a1 is void *ov02_02249458(FieldSystem *fieldSystem, int a1, Pokemon *mon, int gender); @@ -70,7 +69,6 @@ void ov02_0224BFCC(FieldSystem *fieldSystem, u8 a1); void ov02_0224CDB0(FieldSystem *fieldSystem, u8 a1); void ov02_0224E074(FieldSystem *fieldSystem, u16 *p_ret, int a2, HeapID heapId); void ov02_0224E0BC(LocalMapObject *obj1, LocalMapObject *obj2, TaskManager *taskManager); -void ov02_02251EB8(GearPhoneRingManager *phoneRingManager, u8 a1, u8 a2, u8 a3, u8 a4, u8 a5); void FieldSystem_FollowMonInteract(FieldSystem *fieldSystem); BOOL ov02_02250780(FieldSystem *fieldSystem, u8 a1); void ov02_022507B4(FieldSystem *fieldSystem, u8 a1); diff --git a/include/overlay_2/overlay_02_02251E74.h b/include/overlay_2/overlay_02_02251E74.h new file mode 100644 index 0000000000..0dc21dfbdf --- /dev/null +++ b/include/overlay_2/overlay_02_02251E74.h @@ -0,0 +1,17 @@ +#ifndef POKEHEARTGOLD_OVERLAY_02_02251E74_H +#define POKEHEARTGOLD_OVERLAY_02_02251E74_H + +#include "field_system.h" +#include "gear_phone.h" + +String *GetPhoneBookEntryName(GearPhoneRingManager *gearPhone, HeapID heapId); +void ov02_02251EB8(GearPhoneRingManager *phoneRingManager, u8 a1, u8 a2, u8 a3, u8 a4, u8 a5); +u8 ov02_02251EE8(GearPhoneRingManager *gearPhone, u8 *a1); +BOOL ov02_02251F20(GearPhoneRingManager *gearPhone); + +// the following is as of yet not decompiled +u32 ov02_022521C0(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId); +void ov02_022522AC(GearPhoneRingManager *gearPhone, BOOL a1); +u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId); + +#endif // POKEHEARTGOLD_OVERLAY_02_02251E74_H diff --git a/main.lsf b/main.lsf index 1db1e0489d..ae4727f0aa 100644 --- a/main.lsf +++ b/main.lsf @@ -523,7 +523,8 @@ Overlay OVY_2 After field Object asm/overlay_02_02245B80.o Object src/field/legend_cutscene_camera.o - Object asm/overlay_02_02251E74.o + Object src/overlay_02_02251E74.o + Object asm/overlay_02_02251E74_s.o } Overlay OVY_3 { diff --git a/src/overlay_02_02251E74.c b/src/overlay_02_02251E74.c new file mode 100644 index 0000000000..ff3974ac40 --- /dev/null +++ b/src/overlay_02_02251E74.c @@ -0,0 +1,94 @@ +#include "overlay_2/overlay_02_02251E74.h" + +#include "fieldmap.h" +#include "map_header.h" +#include "math_util.h" +#include "msgdata.h" +#include "phonebook_dat.h" +#include "sav_system_info.h" +#include "save_local_field_data.h" +#include "save_vars_flags.h" + +String *GetPhoneBookEntryName(GearPhoneRingManager *gearPhone, HeapID heapId) { + String *str; + if (!gearPhone->unk_var0_0 || gearPhone->unk_var2 >= 0x4b) { + str = String_New(8, heapId); + } else { + int phoneMsg = GetPhoneMessageGmm(gearPhone->unk_var2); + MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, phoneMsg, heapId); + str = NewString_ReadMsgData(msgData, 0); + DestroyMsgData(msgData); + } + return str; +} + +void ov02_02251EB8(GearPhoneRingManager *gearPhone, u8 a1, u8 a2, u8 a3, u8 a4, u8 a5) { + if (a1 >= 0x4b) { + gearPhone->unk_var2 = 0xFF; + gearPhone->unk_arr5[0] = 0xFF; + gearPhone->unk_arr5[1] = 0; + GF_ASSERT(FALSE); + } else { + gearPhone->unk_var2 = a1; + gearPhone->unk_arr5[0] = a2; + gearPhone->unk_arr5[1] = a3; + } + + gearPhone->unk_var3 = a4; + gearPhone->unk_var4 = a5; +} + +u8 ov02_02251EE8(GearPhoneRingManager *gearPhone, u8 *a1) { + MI_CpuFill8(a1, 0, 5); + if (gearPhone->unk_var2 >= 0x4b) { + GF_ASSERT(FALSE); + a1[0] = 0xFF; + return 0xFF; + } + a1[0] = gearPhone->unk_arr5[0]; + a1[1] = gearPhone->unk_arr5[1]; + a1[3] = gearPhone->unk_var3; + a1[4] = gearPhone->unk_var4; + a1[2] = gearPhone->unk_var7; + return gearPhone->unk_var2; +} + +BOOL ov02_02251F20(GearPhoneRingManager *gearPhone) { + Location *position = LocalFieldData_GetCurrentPosition(Save_LocalFieldData_Get(gearPhone->saveData)); + + if (MapHeader_GetField14_1E(position->mapId) == 0) { + return FALSE; + } + + if (gearPhone->unk_var0_0 || gearPhone->unk_var8 < gearPhone->unk_varC) { + return FALSE; + } + + PhoneBook *phoneBook = AllocAndReadPhoneBook(HEAP_ID_4); + u32 var = ov02_022521C0(gearPhone, phoneBook, position->mapId); + if (var) { + FreePhoneBook(phoneBook); + if (var == 2) { + gearPhone->sys->unkD2_7 = 1; + StartMapSceneScript(gearPhone->sys, 0x7FF, 0); + return TRUE; + } + ov02_022522AC(gearPhone, 1); + return FALSE; + } + u32 rand = MTRandom() % 0x64; + + if (rand > gearPhone->unk_var12) { + FreePhoneBook(phoneBook); + gearPhone->unk_var8 = 0; + return FALSE; + } + + var = ov02_02251FDC(gearPhone, phoneBook, position->mapId); + FreePhoneBook(phoneBook); + + if (var == 0) { + gearPhone->unk_var8 = 0; + } + return FALSE; +} diff --git a/src/scrcmd_c.c b/src/scrcmd_c.c index 266a0b4b8a..70990904d5 100644 --- a/src/scrcmd_c.c +++ b/src/scrcmd_c.c @@ -9,6 +9,7 @@ #include "frontier/frontier.h" #include "msgdata/msg.naix" #include "msgdata/msg/msg_0202.h" +#include "overlay_2/overlay_02_02251E74.h" #include "alph_puzzle.h" #include "bg_window.h" diff --git a/src/unk_02092BE8.c b/src/unk_02092BE8.c index bd0ec32ea4..81f304d00c 100644 --- a/src/unk_02092BE8.c +++ b/src/unk_02092BE8.c @@ -6,6 +6,8 @@ #include "constants/phone_contacts.h" #include "constants/sndseq.h" +#include "overlay_2/overlay_02_02251E74.h" + #include "field_system.h" #include "map_header.h" #include "overlay_02.h" From 547c7a413e338608479132662cc798e53abb0b87 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:45:53 -0500 Subject: [PATCH 3/7] PhoneBookEntry unk6->mapId, decomp pt 2 --- asm/overlay_02_02251E74_s.s | 1012 +---------------------- include/gear_phone.h | 2 +- include/overlay_01_021F467C.h | 6 + include/overlay_01_022053EC.h | 3 + include/overlay_02.h | 2 +- include/overlay_2/overlay_02_02251E74.h | 58 +- src/battle/overlay_12_0224E4FC.c | 4 +- src/field/scrcmd_pokemon_misc.c | 1 + src/overlay_02_02251E74.c | 381 +++++++++ 9 files changed, 453 insertions(+), 1016 deletions(-) create mode 100644 include/overlay_01_021F467C.h diff --git a/asm/overlay_02_02251E74_s.s b/asm/overlay_02_02251E74_s.s index 3e6f1ba987..16b21da3cb 100644 --- a/asm/overlay_02_02251E74_s.s +++ b/asm/overlay_02_02251E74_s.s @@ -10,1014 +10,6 @@ .text - thumb_func_start ov02_02251FDC -ov02_02251FDC: ; 0x02251FDC - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x30 - str r0, [sp, #8] - ldr r0, [r0, #0x38] - add r6, r1, #0 - str r2, [sp, #0xc] - bl Save_VarsFlags_Get - str r0, [sp, #0x1c] - ldr r0, [sp, #8] - ldr r0, [r0, #0x38] - bl Save_PlayerData_GetProfileAddr - ldr r0, [sp, #8] - ldr r0, [r0, #0x38] - bl Save_Misc_Get - str r0, [sp, #0x18] - ldr r0, [sp, #8] - ldr r0, [r0, #0x30] - bl GSPlayerMisc_FindEmptyGearPhonebookSlot - str r0, [sp, #0x2c] - ldr r0, [sp, #8] - mov r1, #4 - ldr r0, [r0, #0x30] - bl GSPlayerMisc_AllocAndCopyPhonebook - str r0, [sp, #0x20] - ldr r1, [sp, #0x2c] - mov r0, #4 - bl AllocFromHeapAtEnd - ldr r2, [sp, #0x2c] - mov r1, #0xff - add r4, r0, #0 - bl MI_CpuFill8 - bl LCRandom - mov r1, #0xfa - lsl r1, r1, #2 - bl _s32_div_f - lsl r0, r1, #0x10 - lsr r1, r0, #0x10 - mov r0, #0x7d - lsl r0, r0, #2 - cmp r1, r0 - bhs _02252046 - mov r0, #0 - str r0, [sp, #0x24] - b _02252058 -_02252046: - mov r0, #0x32 - lsl r0, r0, #4 - cmp r1, r0 - bhs _02252054 - mov r0, #1 - str r0, [sp, #0x24] - b _02252058 -_02252054: - mov r0, #2 - str r0, [sp, #0x24] -_02252058: - ldr r0, [sp, #0x2c] - mov r7, #0 - add r2, r7, #0 - cmp r0, #0 - bls _022520A2 -_02252062: - ldr r0, [sp, #0x20] - mov r1, #0x14 - ldrb r3, [r0, r2] - ldr r0, [r6, #4] - mul r1, r3 - add r5, r0, r1 - ldrb r1, [r5, #0xf] - ldr r0, [sp, #0x24] - cmp r0, r1 - bne _02252096 - ldrb r0, [r5, #1] - cmp r0, #0 - beq _0225208C - cmp r0, #0xc - beq _0225208C - cmp r0, #0xb - beq _0225208C - cmp r0, #0xa - beq _0225208C - cmp r0, #0xe - bne _02252096 -_0225208C: - add r1, r7, #1 - add r0, r7, #0 - lsl r1, r1, #0x18 - lsr r7, r1, #0x18 - strb r3, [r4, r0] -_02252096: - add r0, r2, #1 - lsl r0, r0, #0x18 - lsr r2, r0, #0x18 - ldr r0, [sp, #0x2c] - cmp r2, r0 - blo _02252062 -_022520A2: - cmp r7, #0 - bne _022520B8 - ldr r0, [sp, #0x20] - bl FreeToHeap - add r0, r4, #0 - bl FreeToHeap - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_022520B8: - ldr r0, [sp, #0x20] - ldr r2, [sp, #0x2c] - mov r1, #0xff - bl MI_CpuFill8 - ldr r0, [sp, #8] - ldr r0, [r0, #0x38] - bl Save_SysInfo_RTC_Get - ldr r0, [r0, #0x14] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - str r0, [sp, #0x14] - ldr r0, [sp, #0x1c] - bl Save_VarsFlags_CheckBugContestFlag - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - str r0, [sp, #0x10] - mov r0, #0 - str r0, [sp, #0x28] - ldr r0, [sp, #0x18] - ldr r1, [sp, #0x24] - bl sub_0202AAD4 - cmp r0, r7 - bne _022520F6 - ldr r0, [sp, #0x18] - ldr r1, [sp, #0x24] - bl sub_0202AA9C -_022520F6: - mov r5, #0 - cmp r7, #0 - bls _02252164 -_022520FC: - ldrb r2, [r4, r5] - mov r1, #0x14 - ldr r0, [r6, #4] - mul r1, r2 - add r0, r0, r1 - ldrh r1, [r0, #6] - ldr r0, [sp, #0xc] - cmp r0, r1 - beq _0225215A - ldr r0, [sp, #0x18] - ldr r1, [sp, #0x24] - bl sub_0202AA44 - cmp r0, #0 - bne _0225215A - ldrb r0, [r4, r5] - cmp r0, #8 - bne _02252134 - ldr r0, [sp, #0x14] - bl sub_02095FF8 - cmp r0, #0 - bne _0225215A - ldr r0, [sp, #0x1c] - bl Save_VarsFlags_IsInRocketTakeover - cmp r0, #0 - bne _0225215A -_02252134: - ldrb r1, [r4, r5] - mov r2, #0x14 - ldr r0, [r6, #4] - mul r2, r1 - add r0, r0, r2 - ldrh r0, [r0, #6] - cmp r0, #0x60 - bne _0225214A - ldr r0, [sp, #0x10] - cmp r0, #0 - bne _0225215A -_0225214A: - ldr r0, [sp, #0x28] - add r2, r0, #0 - add r2, r2, #1 - lsl r2, r2, #0x18 - lsr r2, r2, #0x18 - str r2, [sp, #0x28] - ldr r2, [sp, #0x20] - strb r1, [r2, r0] -_0225215A: - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, r7 - blo _022520FC -_02252164: - ldr r0, [sp, #0x28] - cmp r0, #0 - beq _022521AC - bl MTRandom - ldr r2, [sp, #0x28] - mov r1, #0x64 - mul r1, r2 - bl _u32_div_f - add r0, r1, #0 - mov r1, #0x64 - bl _u32_div_f - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - mov r0, #0 - lsl r1, r1, #0x18 - str r0, [sp] - lsr r2, r1, #0x18 - str r0, [sp, #4] - ldr r1, [sp, #0x20] - ldr r0, [sp, #8] - ldrb r1, [r1, r2] - ldr r2, [sp, #0x24] - add r3, r7, #0 - bl ov02_02251EB8 - ldr r0, [sp, #8] - bl sub_02092DF4 - ldr r0, [sp, #8] - mov r1, #1 - bl ov02_022522AC -_022521AC: - ldr r0, [sp, #0x20] - bl FreeToHeap - add r0, r4, #0 - bl FreeToHeap - ldr r0, [sp, #0x28] - add sp, #0x30 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov02_02251FDC - - thumb_func_start ov02_022521C0 -ov02_022521C0: ; 0x022521C0 - push {r4, r5, r6, lr} - sub sp, #8 - add r5, r0, #0 - bl ov02_02252218 - add r6, r0, #0 - cmp r6, #0xff - bne _022521D6 - add sp, #8 - mov r0, #0 - pop {r4, r5, r6, pc} -_022521D6: - mov r0, #6 - add r4, r6, #0 - mul r4, r0 - mov r0, #3 - str r0, [sp] - ldr r0, _0225220C ; =ov02_02253C86 - ldr r1, _02252210 ; =ov02_02253C84 - ldrh r0, [r0, r4] - ldrb r1, [r1, r4] - mov r2, #0xff - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - str r0, [sp, #4] - add r0, r5, #0 - mov r3, #0 - bl ov02_02251EB8 - add r0, r5, #0 - bl sub_02092DF4 - ldr r0, _02252214 ; =ov02_02253C88 - strb r6, [r5, #7] - ldrb r0, [r0, r4] - add r0, r0, #1 - add sp, #8 - pop {r4, r5, r6, pc} - nop -_0225220C: .word ov02_02253C86 -_02252210: .word ov02_02253C84 -_02252214: .word ov02_02253C88 - thumb_func_end ov02_022521C0 - - thumb_func_start ov02_02252218 -ov02_02252218: ; 0x02252218 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r7, r0, #0 - str r1, [sp] - mov r0, #4 - mov r1, #0xd - str r2, [sp, #4] - bl AllocFromHeapAtEnd - mov r1, #0 - mov r2, #0xd - str r0, [sp, #8] - bl MI_CpuFill8 - mov r5, #0 - ldr r6, _022522A8 ; =ov02_02253C84 - add r4, r5, #0 -_0225223A: - lsl r1, r4, #0x18 - ldr r0, [r7, #0x34] - lsr r1, r1, #0x18 - bl sub_0202F08C - cmp r0, #0 - beq _02252276 - ldr r0, [sp] - mov r1, #0x14 - ldr r2, [r0, #4] - ldrb r0, [r6] - mul r1, r0 - add r0, r2, r1 - ldrb r1, [r2, r1] - cmp r1, #6 - bne _02252268 - ldr r0, [r7, #0x30] - mov r1, #6 - bl GSPlayerMisc_IsGearNumberRegistered - cmp r0, #0xff - beq _02252276 - b _02252270 -_02252268: - ldrh r1, [r0, #6] - ldr r0, [sp, #4] - cmp r1, r0 - beq _02252276 -_02252270: - ldr r0, [sp, #8] - strb r4, [r0, r5] - add r5, r5, #1 -_02252276: - add r4, r4, #1 - add r6, r6, #6 - cmp r4, #0xd - blt _0225223A - cmp r5, #0 - bne _0225228E - ldr r0, [sp, #8] - bl FreeToHeap - add sp, #0xc - mov r0, #0xff - pop {r4, r5, r6, r7, pc} -_0225228E: - bl LCRandom - add r1, r5, #0 - bl _s32_div_f - ldr r0, [sp, #8] - ldrb r4, [r0, r1] - bl FreeToHeap - add r0, r4, #0 - add sp, #0xc - pop {r4, r5, r6, r7, pc} - nop -_022522A8: .word ov02_02253C84 - thumb_func_end ov02_02252218 - - thumb_func_start ov02_022522AC -ov02_022522AC: ; 0x022522AC - ldr r3, _022522B0 ; =GearPhone_ToggleRinging - bx r3 - .balign 4, 0 -_022522B0: .word GearPhone_ToggleRinging - thumb_func_end ov02_022522AC - - thumb_func_start GetRadioMusicPlayingSeq -GetRadioMusicPlayingSeq: ; 0x022522B4 - push {r3, lr} - bl SndRadio_GetSeqNo - lsl r0, r0, #0x10 - ldr r2, _0225232C ; =SEQ_GS_RADIO_R_201 - lsr r0, r0, #0x10 - cmp r0, r2 - bgt _022522F0 - bge _0225231C - add r1, r2, #0 - sub r1, #SEQ_GS_RADIO_R_201-SEQ_GS_HUE - cmp r0, r1 - bgt _022522E8 - sub r2, #SEQ_GS_RADIO_R_201-SEQ_GS_RADIO_KOMORIUTA - sub r1, r0, r2 - bmi _02252328 - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_022522E0: ; jump table - .short _02252314 - _022522E0 - 2 ; case SEQ_GS_RADIO_KOMORIUTA - .short _02252310 - _022522E0 - 2 ; case SEQ_GS_RADIO_MARCH - .short _02252320 - _022522E0 - 2 ; case SEQ_GS_RADIO_UNKNOWN - .short _02252324 - _022522E0 - 2 ; case SEQ_GS_HUE -_022522E8: - ldr r1, _02252330 ; =SEQ_GS_RADIO_R_101 - cmp r0, r1 - beq _02252318 - b _02252328 -_022522F0: - add r1, r2, #0 - add r1, #SEQ_GS_P_RADIO_MARCH-SEQ_GS_RADIO_R_201 - cmp r0, r1 - bgt _02252308 - add r1, r2, #0 - add r1, #SEQ_GS_P_RADIO_MARCH-SEQ_GS_RADIO_R_201 - cmp r0, r1 - bge _02252310 - add r2, #SEQ_GS_P_RADIO_KOMORIUTA-SEQ_GS_RADIO_R_201 - cmp r0, r2 - beq _02252314 - b _02252328 -_02252308: - add r2, #SEQ_GS_P_HUE-SEQ_GS_RADIO_R_201 - cmp r0, r2 - beq _02252324 - b _02252328 -_02252310: - mov r0, #1 - pop {r3, pc} -_02252314: - mov r0, #2 - pop {r3, pc} -_02252318: - mov r0, #3 - pop {r3, pc} -_0225231C: - mov r0, #4 - pop {r3, pc} -_02252320: - mov r0, #6 - pop {r3, pc} -_02252324: - mov r0, #5 - pop {r3, pc} -_02252328: - mov r0, #0 - pop {r3, pc} - .balign 4, 0 -_0225232C: .word SEQ_GS_RADIO_R_201 -_02252330: .word SEQ_GS_RADIO_R_101 - thumb_func_end GetRadioMusicPlayingSeq - - thumb_func_start ov02_02252334 -ov02_02252334: ; 0x02252334 - push {r4, r5, r6, lr} - add r5, r0, #0 - ldr r0, [r5, #0x40] - bl PlayerAvatar_GetMapObject - bl MapObject_AreBitsSetForMovementScriptInit - cmp r0, #0 - bne _0225234A - mov r0, #0 - pop {r4, r5, r6, pc} -_0225234A: - add r0, r5, #0 - bl FollowMon_IsActive - cmp r0, #0 - beq _022523B0 - add r0, r5, #0 - add r0, #0xf4 - ldr r1, [r0] - mov r0, #0x7b - lsl r0, r0, #2 - cmp r1, r0 - bne _022523B0 - ldr r0, [r5, #0xc] - bl SaveArray_Party_Get - bl GetFirstAliveMonInParty_CrashIfNone - add r6, r0, #0 - mov r1, #5 - mov r2, #0 - bl GetMonData - add r4, r0, #0 - add r0, r6, #0 - mov r1, #0x70 - mov r2, #0 - bl GetMonData - add r6, r0, #0 - add r0, r5, #0 - add r0, #0xf4 - ldr r0, [r0] - cmp r4, r0 - beq _02252392 - bl GF_AssertFail -_02252392: - add r0, r5, #0 - add r0, #0xf4 - ldr r0, [r0] - cmp r4, r0 - beq _022523A0 - mov r0, #0 - pop {r4, r5, r6, pc} -_022523A0: - add r5, #0xfc - ldrh r0, [r5] - cmp r0, #1 - bne _022523B0 - cmp r6, #0 - bne _022523B0 - mov r0, #1 - pop {r4, r5, r6, pc} -_022523B0: - mov r0, #0 - pop {r4, r5, r6, pc} - thumb_func_end ov02_02252334 - - thumb_func_start ov02_022523B4 -ov02_022523B4: ; 0x022523B4 - push {r4, lr} - add r4, r0, #0 - mov r0, #0xb - mov r1, #0xc - bl AllocFromHeapAtEnd - add r2, r0, #0 - ldr r1, _022523CC ; =ov02_022523D0 - add r0, r4, #0 - bl TaskManager_Call - pop {r4, pc} - .balign 4, 0 -_022523CC: .word ov02_022523D0 - thumb_func_end ov02_022523B4 - - thumb_func_start ov02_022523D0 -ov02_022523D0: ; 0x022523D0 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r6, r0, #0 - bl TaskManager_GetStatePtr - add r5, r0, #0 - add r0, r6, #0 - bl TaskManager_GetFieldSystem - add r4, r0, #0 - add r0, r6, #0 - bl TaskManager_GetEnvironment - add r6, r0, #0 - ldr r0, [r5] - cmp r0, #4 - bls _022523F4 - b _02252524 -_022523F4: - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_02252400: ; jump table - .short _0225240A - _02252400 - 2 ; case 0 - .short _02252426 - _02252400 - 2 ; case 1 - .short _0225246E - _02252400 - 2 ; case 2 - .short _022524D2 - _02252400 - 2 ; case 3 - .short _022524EE - _02252400 - 2 ; case 4 -_0225240A: - add r0, r4, #0 - bl FollowMon_GetMapObject - bl MapObject_UnpauseMovement - ldr r0, [r4, #0x10] - ldr r1, _0225252C ; =ov01_02205A60 - mov r2, #0 - bl TaskManager_Call - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252524 -_02252426: - add r0, r4, #0 - bl FollowMon_GetMapObject - add r1, sp, #0 - bl MapObject_GetPositionVec - add r0, r4, #0 - bl FollowMon_IsVisible - cmp r0, #0 - beq _0225244A - ldr r0, [r4, #0x44] - add r1, sp, #0 - bl ov01_022052C4 - str r0, [r6, #4] - mov r0, #1 - b _0225244E -_0225244A: - mov r0, #0 - str r0, [r6, #4] -_0225244E: - str r0, [r6, #8] - add r0, r4, #0 - mov r2, #0 - mov r1, #0x7b - str r2, [r6] - add r4, #0xfb - add r0, #0xe4 - ldrb r3, [r4] - ldr r0, [r0] - lsl r1, r1, #2 - bl FollowMon_SetObjectParams - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252524 -_0225246E: - ldr r0, [r6, #8] - cmp r0, #0 - beq _02252490 - ldr r0, [r6] - add r0, r0, #1 - str r0, [r6] - cmp r0, #4 - blt _02252524 - add r4, #0xe4 - ldr r0, [r4] - ldr r1, _02252530 ; =0x000003CE - bl ov01_021FA930 - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252524 -_02252490: - add r0, r4, #0 - add r0, #0xe4 - ldr r0, [r0] - bl MapObject_GetManager - add r6, r0, #0 - add r0, r4, #0 - add r0, #0xe4 - ldr r0, [r0] - bl MapObject_GetSpriteID - add r7, r0, #0 - add r0, r4, #0 - add r0, #0xe4 - ldr r0, [r0] - bl sub_0205E420 - add r2, r4, #0 - add r2, #0xe4 - ldr r2, [r2] - add r0, r6, #0 - add r1, r7, #0 - bl ov01_021FA108 - add r4, #0xe4 - ldr r0, [r4] - ldr r1, _02252530 ; =0x000003CE - bl sub_0205E38C - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252524 -_022524D2: - add r0, r4, #0 - add r0, #0xe4 - ldr r0, [r0] - bl ov01_021FA2D4 - cmp r0, #0 - bne _02252524 - mov r0, #0 - add r4, #0xfc - strh r0, [r4] - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252524 -_022524EE: - ldr r0, [r6, #4] - mov r5, #0 - cmp r0, #0 - bne _022524FA - mov r5, #1 - b _0225250A -_022524FA: - bl ov01_022052F4 - cmp r0, #0 - beq _0225250A - ldr r0, [r6, #4] - bl sub_02068B48 - mov r5, #1 -_0225250A: - cmp r5, #0 - beq _02252524 - add r0, r6, #0 - bl FreeToHeap - add r0, r4, #0 - bl FollowMon_GetMapObject - bl MapObject_PauseMovement - add sp, #0xc - mov r0, #1 - pop {r4, r5, r6, r7, pc} -_02252524: - mov r0, #0 - add sp, #0xc - pop {r4, r5, r6, r7, pc} - nop -_0225252C: .word ov01_02205A60 -_02252530: .word 0x000003CE - thumb_func_end ov02_022523D0 - - thumb_func_start ov02_02252534 -ov02_02252534: ; 0x02252534 - push {r3, r4, r5, lr} - add r5, r0, #0 - mov r0, #0xb - mov r1, #0xf4 - bl AllocFromHeapAtEnd - add r4, r0, #0 - mov r1, #0 - mov r2, #0xf4 - bl MI_CpuFill8 - str r5, [r4, #8] - ldr r0, [r5, #0x10] - ldr r1, _02252558 ; =ov02_0225255C - add r2, r4, #0 - bl TaskManager_Call - pop {r3, r4, r5, pc} - .balign 4, 0 -_02252558: .word ov02_0225255C - thumb_func_end ov02_02252534 - - thumb_func_start ov02_0225255C -ov02_0225255C: ; 0x0225255C - push {r4, r5, lr} - sub sp, #0xc - add r4, r0, #0 - bl TaskManager_GetStatePtr - add r5, r0, #0 - add r0, r4, #0 - bl TaskManager_GetFieldSystem - add r0, r4, #0 - bl TaskManager_GetEnvironment - ldr r1, [r5] - add r4, r0, #0 - cmp r1, #5 - bls _0225257E - b _02252698 -_0225257E: - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_0225258A: ; jump table - .short _02252596 - _0225258A - 2 ; case 0 - .short _022525B4 - _0225258A - 2 ; case 1 - .short _022525EA - _0225258A - 2 ; case 2 - .short _0225260C - _0225258A - 2 ; case 3 - .short _02252638 - _0225258A - 2 ; case 4 - .short _0225266E - _0225258A - 2 ; case 5 -_02252596: - mov r1, #4 - str r1, [sp] - mov r0, #1 - str r0, [sp, #4] - str r1, [sp, #8] - mov r1, #0 - ldr r3, _022526C4 ; =0x00007FFF - mov r0, #3 - add r2, r1, #0 - bl BeginNormalPaletteFade - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252698 -_022525B4: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _02252698 - add r0, r4, #0 - bl ov02_02252898 - ldr r0, [r4, #8] - bl FollowMon_GetMapObject - mov r1, #1 - bl sub_02069DC8 - mov r0, #4 - str r0, [sp] - mov r1, #1 - str r1, [sp, #4] - str r0, [sp, #8] - ldr r3, _022526C4 ; =0x00007FFF - mov r0, #3 - mov r2, #0 - bl BeginNormalPaletteFade - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252698 -_022525EA: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _02252698 - ldr r0, [r4, #8] - bl FollowMon_GetMapObject - bl sub_0205F484 - add r0, r4, #0 - mov r1, #1 - add r0, #0xf0 - strb r1, [r0] - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252698 -_0225260C: - add r1, r4, #0 - add r1, #0xf2 - ldrb r1, [r1] - add r2, r1, #1 - add r1, r4, #0 - add r1, #0xf2 - strb r2, [r1] - add r1, r4, #0 - add r1, #0xf2 - ldrb r1, [r1] - cmp r1, #0x1e - blo _02252698 - bl ov02_022526C8 - add r0, r4, #0 - mov r1, #0 - add r0, #0xf2 - strb r1, [r0] - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252698 -_02252638: - add r0, #0xf2 - ldrb r0, [r0] - add r1, r0, #1 - add r0, r4, #0 - add r0, #0xf2 - strb r1, [r0] - add r0, r4, #0 - add r0, #0xf2 - ldrb r0, [r0] - cmp r0, #0x50 - blo _02252698 - mov r0, #0x1e - str r0, [sp] - mov r0, #1 - str r0, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - mov r0, #0 - ldr r3, _022526C4 ; =0x00007FFF - add r1, r0, #0 - add r2, r0, #0 - bl BeginNormalPaletteFade - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252698 -_0225266E: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _02252698 - add r0, r4, #0 - bl ov02_022526EC - cmp r0, #0 - beq _02252698 - add r0, r4, #0 - bl ov02_0225296C - add r0, r4, #4 - bl ov01_021F46DC - add r0, r4, #0 - bl FreeToHeap - add sp, #0xc - mov r0, #1 - pop {r4, r5, pc} -_02252698: - add r0, r4, #0 - add r0, #0xf0 - ldrb r0, [r0] - cmp r0, #0 - beq _022526AA - add r0, r4, #0 - add r0, #0x2c - bl ov02_022529C4 -_022526AA: - add r0, r4, #0 - add r0, #0xf1 - ldrb r0, [r0] - cmp r0, #0 - beq _022526BC - add r4, #0x68 - add r0, r4, #0 - bl Field3dObject_Draw -_022526BC: - mov r0, #0 - add sp, #0xc - pop {r4, r5, pc} - nop -_022526C4: .word 0x00007FFF - thumb_func_end ov02_0225255C - - thumb_func_start ov02_022526C8 -ov02_022526C8: ; 0x022526C8 - push {r4, lr} - add r4, r0, #0 - mov r0, #3 - mov r1, #0xd - bl ov01_021F467C - str r0, [r4, #4] - ldr r0, _022526E8 ; =ov02_022526FC - add r1, r4, #0 - mov r2, #0 - bl SysTask_CreateOnMainQueue - mov r0, #0 - strb r0, [r4, #2] - pop {r4, pc} - nop -_022526E8: .word ov02_022526FC - thumb_func_end ov02_022526C8 - - thumb_func_start ov02_022526EC -ov02_022526EC: ; 0x022526EC - ldrb r0, [r0, #2] - cmp r0, #0 - beq _022526F6 - mov r0, #1 - bx lr -_022526F6: - mov r0, #0 - bx lr - .balign 4, 0 - thumb_func_end ov02_022526EC - - thumb_func_start ov02_022526FC -ov02_022526FC: ; 0x022526FC - push {r4, r5, lr} - sub sp, #0xc - add r4, r1, #0 - add r5, r0, #0 - add r0, r4, #0 - add r0, #0xee - ldrh r0, [r0] - cmp r0, #0 - beq _02252716 - cmp r0, #1 - beq _02252746 - add sp, #0xc - pop {r4, r5, pc} -_02252716: - ldr r3, _02252760 ; =ov02_02253CE0 - add r2, sp, #0 - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldr r0, [r3] - str r0, [r2] - ldr r0, [r4, #8] - ldr r0, [r0, #0x24] - bl Camera_GetPerspectiveAngle - add r1, sp, #0 - strh r0, [r1, #8] - add r0, r4, #0 - add r1, sp, #0 - bl ov02_02252764 - add r0, r4, #0 - add r0, #0xee - ldrh r0, [r0] - add r4, #0xee - add sp, #0xc - add r0, r0, #1 - strh r0, [r4] - pop {r4, r5, pc} -_02252746: - add r0, r4, #0 - bl ov02_02252888 - cmp r0, #0 - beq _0225275A - mov r0, #1 - strb r0, [r4, #2] - add r0, r5, #0 - bl SysTask_Destroy -_0225275A: - add sp, #0xc - pop {r4, r5, pc} - nop -_02252760: .word ov02_02253CE0 - thumb_func_end ov02_022526FC - - thumb_func_start ov02_02252764 -ov02_02252764: ; 0x02252764 - push {r3, r4, r5, lr} - add r5, r0, #0 - add r4, r1, #0 - mov r1, #0 - strb r1, [r5, #3] - add r0, #0xe6 - strh r1, [r0] - add r0, r5, #0 - ldr r1, [r4] - add r0, #0xe0 - str r1, [r0] - add r0, r5, #0 - ldrh r1, [r5] - add r0, #0xe4 - strh r1, [r0] - ldr r0, [r5, #8] - ldr r0, [r0, #0x24] - bl Camera_GetPerspectiveAngle - add r1, r5, #0 - add r1, #0xea - strh r0, [r1] - add r0, r5, #0 - ldrh r1, [r4, #8] - add r0, #0xec - mov r2, #1 - strh r1, [r0] - add r0, r5, #0 - ldr r1, [r4, #4] - add r0, #0xe8 - strh r1, [r0] - ldr r0, _022527AC ; =ov02_0225286C - add r1, r5, #0 - bl SysTask_CreateOnMainQueue - pop {r3, r4, r5, pc} - .balign 4, 0 -_022527AC: .word ov02_0225286C - thumb_func_end ov02_02252764 - thumb_func_start ov02_022527B0 ov02_022527B0: ; 0x022527B0 push {r3, r4, r5, r6, r7, lr} @@ -2377,12 +1369,15 @@ _02253206: .rodata +.public ov02_02253C84 ov02_02253C84: ; 0x02253C84 .byte 0x01, 0x00 +.public ov02_02253C86 ov02_02253C86: ; 0x02253C86 .byte 0x0D, 0x00 +.public ov02_02253C88 ov02_02253C88: ; 0x02253C88 .byte 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00 .byte 0x0F, 0x00, 0x55, 0x00, 0x01, 0x00, 0x09, 0x00, 0x5D, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00 @@ -2394,6 +1389,7 @@ ov02_02253C88: ; 0x02253C88 ov02_02253CD4: ; 0x02253CD4 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +.public ov02_02253CE0 ov02_02253CE0: ; 0x02253CE0 .byte 0x00, 0x00, 0xFF, 0xFF, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00 diff --git a/include/gear_phone.h b/include/gear_phone.h index 3b4cbd69d1..9dd966e6a5 100644 --- a/include/gear_phone.h +++ b/include/gear_phone.h @@ -9,7 +9,7 @@ typedef struct PhoneBookEntry { u8 unk2; u8 trainerClass; u16 trainerId; - u16 unk6; + u16 mapId; u16 gift; u8 unkA[5]; u8 unkF; diff --git a/include/overlay_01_021F467C.h b/include/overlay_01_021F467C.h new file mode 100644 index 0000000000..fad767ca2c --- /dev/null +++ b/include/overlay_01_021F467C.h @@ -0,0 +1,6 @@ +#ifndef POKEHEARTGOLD_OVERLAY_01_021F467C_H +#define POKEHEARTGOLD_OVERLAY_01_021F467C_H + +u32 ov01_021F467C(u32 a0, u32 a1); + +#endif // POKEHEARTGOLD_OVERLAY_01_021F467C_H diff --git a/include/overlay_01_022053EC.h b/include/overlay_01_022053EC.h index 299ca4e6cd..655e3b9145 100644 --- a/include/overlay_01_022053EC.h +++ b/include/overlay_01_022053EC.h @@ -6,5 +6,8 @@ void ov01_022057D0(FieldSystem *fieldSystem); void ov01_02205990(int a0, int x, int y, FollowMon *mon); BOOL ov01_0220553C(LocalMapObject *mapObject); +BOOL ov01_02205A60(TaskManager *taskMan); +u32 ov01_022052C4(void *a0, VecFx32 *a1); +BOOL ov01_022052F4(); #endif // POKEHEARTGOLD_OVERLAY_01_022053EC_H diff --git a/include/overlay_02.h b/include/overlay_02.h index 60f4d50cad..0bbe10e9f0 100644 --- a/include/overlay_02.h +++ b/include/overlay_02.h @@ -88,7 +88,7 @@ void ov02_02247F30(FieldSystem *fieldSystem, u16 mon, u8 level, BOOL shiny, Batt void ov02_02246714(TaskManager *man, u32 a1, u32 a2, u32 a3, u32 a4); void ov02_022469B4(TaskManager *man, LocalMapObject *obj1, LocalMapObject *obj2); void OpenAlphHiddenRoom(TaskManager *man, u32 a1); -int GetRadioMusicPlayingSeq(void); + SafariDecorationArgs *SafariDecoration_CreateArgs(FieldSystem *fieldSystem, HeapID heapId); #endif // POKEHEARTGOLD_OVERLAY_02_H diff --git a/include/overlay_2/overlay_02_02251E74.h b/include/overlay_2/overlay_02_02251E74.h index 0dc21dfbdf..9553029edf 100644 --- a/include/overlay_2/overlay_02_02251E74.h +++ b/include/overlay_2/overlay_02_02251E74.h @@ -1,6 +1,8 @@ #ifndef POKEHEARTGOLD_OVERLAY_02_02251E74_H #define POKEHEARTGOLD_OVERLAY_02_02251E74_H +#include "field/overlay_01_021FB878.h" + #include "field_system.h" #include "gear_phone.h" @@ -8,10 +10,60 @@ String *GetPhoneBookEntryName(GearPhoneRingManager *gearPhone, HeapID heapId); void ov02_02251EB8(GearPhoneRingManager *phoneRingManager, u8 a1, u8 a2, u8 a3, u8 a4, u8 a5); u8 ov02_02251EE8(GearPhoneRingManager *gearPhone, u8 *a1); BOOL ov02_02251F20(GearPhoneRingManager *gearPhone); - -// the following is as of yet not decompiled +u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId); u32 ov02_022521C0(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId); +u8 ov02_02252218(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId); void ov02_022522AC(GearPhoneRingManager *gearPhone, BOOL a1); -u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId); +int GetRadioMusicPlayingSeq(void); +BOOL ov02_02252334(FieldSystem *fieldSystem); +void ov02_022523B4(TaskManager *taskMan); +BOOL ov02_022523D0(TaskManager *taskMan); +void ov02_02252534(FieldSystem *fieldSystem); + +// the following is as of yet not decompiled +BOOL ov02_0225255C(TaskManager *taskMan); + +// the following functions are static +typedef struct UnkStruct_02252534 { + u16 unk0; + u8 unk2; + u8 unk3; + u32 unk4; + FieldSystem *fieldSystem; + u8 unkC[0x20]; + u32 unk2C; + u8 unk30[0x38]; + Field3dObject object3d; + u32 unkE0; + u16 unkE4; + u16 unkE6; + u16 unkE8; + u16 unkEA; + u16 unkEC; + u16 unkEE; + u8 unkF0; + u8 unkF1; + u8 unkF2; + u8 unkF3; +} UnkStruct_02252534; + +typedef struct UnkStruct_02253CE0 { + u32 unk0; + u32 unk4; + u16 unk8; + u16 unkA; +} UnkStruct_02253CE0; +void ov02_022526C8(UnkStruct_02252534 *data); +BOOL ov02_022526EC(UnkStruct_02252534 *data); +void ov02_022526FC(SysTask *task, void *data); +void ov02_02252764(UnkStruct_02252534 *a0, UnkStruct_02253CE0 *a1); + +// the following functions are static and not decompiled +void ov02_02252898(UnkStruct_02252534 *data); +void ov02_0225296C(UnkStruct_02252534 *data); +void ov01_021F46DC(u32 *a0); +void ov02_022529C4(u32 *a0); +void ov02_0225286C(SysTask *task, void *data); +BOOL ov02_02252888(UnkStruct_02252534 *data); #endif // POKEHEARTGOLD_OVERLAY_02_02251E74_H diff --git a/src/battle/overlay_12_0224E4FC.c b/src/battle/overlay_12_0224E4FC.c index 5d799d3063..faf648ad56 100644 --- a/src/battle/overlay_12_0224E4FC.c +++ b/src/battle/overlay_12_0224E4FC.c @@ -2221,9 +2221,7 @@ BOOL ov12_02251C74(BattleContext *ctx, int battlerIdAttacker, int battlerIdTarge return ret; } -// regswaps : -// sTypeEffectiveness[i][1] [0xc] <-> &(ctx + battlerId*sizeof(BATTLEMON)) [0x18] -// movePower[0x14] <-> ctx->battleMons[battlerIdTarget]? [0x18] + int ov12_02251D28(BattleSystem *bsys, BattleContext *ctx, int moveNo, int moveTypeDefault, int battlerIdAttacker, int battlerIdTarget, int damage, u32 *moveStatusFlag) { int i; int seffectMod; // this variable is not used but is required to match diff --git a/src/field/scrcmd_pokemon_misc.c b/src/field/scrcmd_pokemon_misc.c index ca3fad63d0..bb4ef21868 100644 --- a/src/field/scrcmd_pokemon_misc.c +++ b/src/field/scrcmd_pokemon_misc.c @@ -7,6 +7,7 @@ #include "msgdata/msg.naix" #include "msgdata/msg/msg_0066_D23R0102.h" #include "msgdata/msg/msg_0096_D31R0201.h" +#include "overlay_2/overlay_02_02251E74.h" #include "bag.h" #include "bug_contest.h" diff --git a/src/overlay_02_02251E74.c b/src/overlay_02_02251E74.c index ff3974ac40..b4f55bbcdb 100644 --- a/src/overlay_02_02251E74.c +++ b/src/overlay_02_02251E74.c @@ -1,13 +1,28 @@ #include "overlay_2/overlay_02_02251E74.h" +#include "constants/sndseq.h" + #include "fieldmap.h" +#include "follow_mon.h" #include "map_header.h" #include "math_util.h" #include "msgdata.h" +#include "overlay_01_021F467C.h" +#include "overlay_01_021F944C.h" +#include "overlay_01_022053EC.h" #include "phonebook_dat.h" #include "sav_system_info.h" #include "save_local_field_data.h" #include "save_vars_flags.h" +#include "script_pokemon_util.h" +#include "sound_radio.h" +#include "sys_flags.h" +#include "sys_vars.h" +#include "task.h" +#include "unk_0200FA24.h" +#include "unk_02062108.h" +#include "unk_020689C8.h" +#include "unk_02092BE8.h" String *GetPhoneBookEntryName(GearPhoneRingManager *gearPhone, HeapID heapId) { String *str; @@ -92,3 +107,369 @@ BOOL ov02_02251F20(GearPhoneRingManager *gearPhone) { } return FALSE; } + +#ifdef NONMATCHING +// FIXME: https://decomp.me/scratch/KW1m7 down to stack swaps between bugContestFlag and var -adrienn +u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId) { + u8 ret; + u8 var; + u8 bugContestFlag; + PhoneContact *contact; + + SaveVarsFlags *varsFlags = Save_VarsFlags_Get(gearPhone->saveData); + Save_PlayerData_GetProfileAddr(gearPhone->saveData); + SAVE_MISC_DATA *miscData = Save_Misc_Get(gearPhone->saveData); + u32 slot = GSPlayerMisc_FindEmptyGearPhonebookSlot(gearPhone->pokegearData); + contact = GSPlayerMisc_AllocAndCopyPhonebook(gearPhone->pokegearData, HEAP_ID_4); + u8 *ptr = AllocFromHeapAtEnd(HEAP_ID_4, slot); + MI_CpuFill8(ptr, 0xFF, slot); + u16 rand = LCRandom() % 1000; + + if (rand < 500) { + var = 0; + } else if (rand < 800) { + var = 1; + } else { + var = 2; + } + + u8 index = 0; + for (u8 i = 0; i < slot; i++) { + u8 id = contact[i].id; + if (phoneBook->entries[id].unkF == var) { + // doesn't match with a switch statement + if (phoneBook->entries[id].unk1 == 0 || phoneBook->entries[id].unk1 == 12 || phoneBook->entries[id].unk1 == 11 || phoneBook->entries[id].unk1 == 10 || phoneBook->entries[id].unk1 == 14) { + ptr[index++] = id; + } + } + } + + if (index == 0) { + FreeToHeap(contact); + FreeToHeap(ptr); + return 0; + } + + MI_CpuFill8(contact, 0xFF, slot); + SysInfo_RTC *rtc = Save_SysInfo_RTC_Get(gearPhone->saveData); + u8 hour = rtc->time.hour; + bugContestFlag = Save_VarsFlags_CheckBugContestFlag(varsFlags); + ret = 0; + + if (sub_0202AAD4(miscData, var) == index) { + sub_0202AA9C(miscData, var); + } + + for (u8 j = 0; j < index; j++) { + if (mapId == phoneBook->entries[ptr[j]].mapId || sub_0202AA44(miscData, var, ptr[j]) || ptr[j] == 8 && (sub_02095FF8(hour) || Save_VarsFlags_IsInRocketTakeover(varsFlags))) { + continue; + } + if (phoneBook->entries[ptr[j]].mapId != 0x60 || !bugContestFlag) { + contact[ret++].id = ptr[j]; + } + } + + if (ret != 0) { + slot = (MTRandom() % (ret * 100)); + rand = slot / 100; + ov02_02251EB8(gearPhone, contact[(u8)rand].id, var, index, 0, 0); + sub_02092DF4(gearPhone); + ov02_022522AC(gearPhone, 1); + } + + FreeToHeap(contact); + FreeToHeap(ptr); + + return ret; +} +#else +//clang-format off +extern u32 _u32_div_f(u32 a1, u32 a2); +extern s32 _s32_div_f(s32 a1, s32 a2); +asm u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId) { + push { r3, r4, r5, r6, r7, lr } sub sp, #0x30 str r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] add r6, r1, #0 str r2, [ sp, #0xc ] bl Save_VarsFlags_Get str r0, [ sp, #0x1c ] ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] bl Save_PlayerData_GetProfileAddr ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] bl Save_Misc_Get str r0, [ sp, #0x18 ] ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x30 ] bl GSPlayerMisc_FindEmptyGearPhonebookSlot str r0, [ sp, #0x2c ] ldr r0, [ sp, #8 ] mov r1, #4 ldr r0, [ r0, #0x30 ] bl GSPlayerMisc_AllocAndCopyPhonebook str r0, [ sp, #0x20 ] ldr r1, [ sp, #0x2c ] mov r0, #4 bl AllocFromHeapAtEnd ldr r2, [ sp, #0x2c ] mov r1, #0xff add r4, r0, #0 bl MI_CpuFill8 bl LCRandom mov r1, #0xfa lsl r1, r1, #2 bl _s32_div_f lsl r0, r1, #0x10 lsr r1, r0, #0x10 mov r0, #0x7d lsl r0, r0, #2 cmp r1, r0 bhs _02252046 mov r0, #0 str r0, [ sp, #0x24 ] b _02252058 _02252046 : mov r0, #0x32 lsl r0, r0, #4 cmp r1, r0 bhs _02252054 mov r0, #1 str r0, [ sp, #0x24 ] b _02252058 _02252054 : mov r0, #2 str r0, [ sp, #0x24 ] _02252058 : ldr r0, [ sp, #0x2c ] mov r7, #0 add r2, r7, #0 cmp r0, #0 bls _022520A2 _02252062 : ldr r0, [ sp, #0x20 ] mov r1, #0x14 ldrb r3, [ r0, r2 ] ldr r0, [ r6, #4 ] mul r1, r3 add r5, r0, r1 ldrb r1, [ r5, #0xf ] ldr r0, [ sp, #0x24 ] cmp r0, r1 bne _02252096 ldrb r0, [ r5, #1 ] cmp r0, #0 beq _0225208C cmp r0, #0xc beq _0225208C cmp r0, #0xb beq _0225208C cmp r0, #0xa beq _0225208C cmp r0, #0xe bne _02252096 _0225208C : add r1, r7, #1 add r0, r7, #0 lsl r1, r1, #0x18 lsr r7, r1, #0x18 strb r3, [ r4, r0 ] _02252096 : add r0, r2, #1 lsl r0, r0, #0x18 lsr r2, r0, #0x18 ldr r0, [ sp, #0x2c ] cmp r2, r0 blo _02252062 _022520A2 : cmp r7, #0 bne _022520B8 ldr r0, [ sp, #0x20 ] bl FreeToHeap add r0, r4, #0 bl FreeToHeap add sp, #0x30 mov r0, #0 pop { r3, r4, r5, r6, r7, pc } _022520B8 : ldr r0, [ sp, #0x20 ] ldr r2, [ sp, #0x2c ] mov r1, #0xff bl MI_CpuFill8 ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] bl Save_SysInfo_RTC_Get ldr r0, [ r0, #0x14 ] lsl r0, r0, #0x18 lsr r0, r0, #0x18 str r0, [ sp, #0x14 ] ldr r0, [ sp, #0x1c ] bl Save_VarsFlags_CheckBugContestFlag lsl r0, r0, #0x18 lsr r0, r0, #0x18 str r0, [ sp, #0x10 ] mov r0, #0 str r0, [ sp, #0x28 ] ldr r0, [ sp, #0x18 ] ldr r1, [ sp, #0x24 ] bl sub_0202AAD4 cmp r0, r7 bne _022520F6 ldr r0, [ sp, #0x18 ] ldr r1, [ sp, #0x24 ] bl sub_0202AA9C _022520F6 : mov r5, #0 cmp r7, #0 bls _02252164 _022520FC : ldrb r2, [ r4, r5 ] mov r1, #0x14 ldr r0, [ r6, #4 ] mul r1, r2 add r0, r0, r1 ldrh r1, [ r0, #6 ] ldr r0, [ sp, #0xc ] cmp r0, r1 beq _0225215A ldr r0, [ sp, #0x18 ] ldr r1, [ sp, #0x24 ] bl sub_0202AA44 cmp r0, #0 bne _0225215A ldrb r0, [ r4, r5 ] cmp r0, #8 bne _02252134 ldr r0, [ sp, #0x14 ] bl sub_02095FF8 cmp r0, #0 bne _0225215A ldr r0, [ sp, #0x1c ] bl Save_VarsFlags_IsInRocketTakeover cmp r0, #0 bne _0225215A _02252134 : ldrb r1, [ r4, r5 ] mov r2, #0x14 ldr r0, [ r6, #4 ] mul r2, r1 add r0, r0, r2 ldrh r0, [ r0, #6 ] cmp r0, #0x60 bne _0225214A ldr r0, [ sp, #0x10 ] cmp r0, #0 bne _0225215A _0225214A : ldr r0, [ sp, #0x28 ] add r2, r0, #0 add r2, r2, #1 lsl r2, r2, #0x18 lsr r2, r2, #0x18 str r2, [ sp, #0x28 ] ldr r2, [ sp, #0x20 ] strb r1, [ r2, r0 ] _0225215A : add r0, r5, #1 lsl r0, r0, #0x18 lsr r5, r0, #0x18 cmp r5, r7 blo _022520FC _02252164 : ldr r0, [ sp, #0x28 ] cmp r0, #0 beq _022521AC bl MTRandom ldr r2, [ sp, #0x28 ] mov r1, #0x64 mul r1, r2 bl _u32_div_f add r0, r1, #0 mov r1, #0x64 bl _u32_div_f add r1, r0, #0 lsl r1, r1, #0x10 lsr r1, r1, #0x10 mov r0, #0 lsl r1, r1, #0x18 str r0, [sp] lsr r2, r1, #0x18 str r0, [ sp, #4 ] ldr r1, [ sp, #0x20 ] ldr r0, [ sp, #8 ] ldrb r1, [ r1, r2 ] ldr r2, [ sp, #0x24 ] add r3, r7, #0 bl ov02_02251EB8 ldr r0, [ sp, #8 ] bl sub_02092DF4 ldr r0, [ sp, #8 ] mov r1, #1 bl ov02_022522AC _022521AC : ldr r0, [ sp, #0x20 ] bl FreeToHeap add r0, r4, #0 bl FreeToHeap ldr r0, [ sp, #0x28 ] add sp, #0x30 pop { + r3, r4, r5, r6, r7, pc + } +} +//clang-format on +#endif + +typedef struct UnkStruct_02253C86 { + u8 unk0; + u8 unk1; + u16 unk2; + u8 unk4; + u8 unk5; +} UnkStruct_02253C86; + +extern const UnkStruct_02253C86 ov02_02253C84[]; + +u32 ov02_022521C0(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId) { + u8 r6 = ov02_02252218(gearPhone, phoneBook, mapId); + if (r6 == 0xFF) { + return FALSE; + } + ov02_02251EB8(gearPhone, ov02_02253C84[r6].unk0, 0xFF, 0, 3, ov02_02253C84[r6].unk2); + sub_02092DF4(gearPhone); + gearPhone->unk_var7 = r6; + return ov02_02253C84[r6].unk4 + 1; +} + +// FIXME: This is a fakematch from decomp.me, it doesn't match locally without the label https://decomp.me/scratch/YdDak +u8 ov02_02252218(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId) { + u8 *ptr = AllocFromHeapAtEnd(HEAP_ID_4, 13); + MI_CpuFill8(ptr, 0, 13); + + int cnt = 0; + for (int i = 0; i < 13; i++) { + if (sub_0202F08C(gearPhone->savingsData, i) == 0) { + continue; + } + PhoneBookEntry *entry = &phoneBook->entries[ov02_02253C84[i].unk0]; + if (entry->unk0 == 6) { + if (GSPlayerMisc_IsGearNumberRegistered(gearPhone->pokegearData, 6) != 0xFF) { + // had to do this to match + goto LABEL; + } else { + continue; + } + } else if (entry->mapId == mapId) { + continue; + } +LABEL: + ptr[cnt++] = i; + } + + if (cnt == 0) { + FreeToHeap(ptr); + return 0xFF; + } + + u8 ret = ptr[LCRandom() % cnt]; + FreeToHeap(ptr); + return ret; +} + +void ov02_022522AC(GearPhoneRingManager *gearPhone, BOOL a1) { + GearPhone_ToggleRinging(gearPhone, a1); +} + +int GetRadioMusicPlayingSeq(void) { + u16 seq = SndRadio_GetSeqNo(); + switch (seq) { + case SEQ_GS_RADIO_MARCH: + case SEQ_GS_P_RADIO_MARCH: + return 1; + case SEQ_GS_RADIO_KOMORIUTA: + case SEQ_GS_P_RADIO_KOMORIUTA: + return 2; + case SEQ_GS_RADIO_R_101: + return 3; + case SEQ_GS_RADIO_R_201: + return 4; + case SEQ_GS_RADIO_UNKNOWN: + return 6; + case SEQ_GS_HUE: + case SEQ_GS_P_HUE: + return 5; + } + return 0; +} + +BOOL ov02_02252334(FieldSystem *fieldSystem) { + if (!MapObject_AreBitsSetForMovementScriptInit(PlayerAvatar_GetMapObject(fieldSystem->playerAvatar))) { + return FALSE; + } + if (FollowMon_IsActive(fieldSystem) && fieldSystem->followMon.species == SPECIES_SHAYMIN) { + Pokemon *mon = GetFirstAliveMonInParty_CrashIfNone(SaveArray_Party_Get(fieldSystem->saveData)); + u32 species = GetMonData(mon, MON_DATA_SPECIES, NULL); + u32 form = GetMonData(mon, MON_DATA_FORM, NULL); + GF_ASSERT(species == fieldSystem->followMon.species); + // yes, this is explicitly checked twice + if (species != fieldSystem->followMon.species) { + return FALSE; + } + if (fieldSystem->followMon.form == SHAYMIN_SKY && form == SHAYMIN_LAND) { + return TRUE; + } + } + return FALSE; +} + +void ov02_022523B4(TaskManager *taskMan) { + void *data = AllocFromHeapAtEnd(HEAP_ID_FIELD, 12); + TaskManager_Call(taskMan, ov02_022523D0, data); +} + +typedef struct UnkStruct_022523D0 { + int unk0; + u32 unk4; + u32 unk8; +} UnkStruct_022523D0; + +BOOL ov02_022523D0(TaskManager *taskMan) { + int *state = TaskManager_GetStatePtr(taskMan); + VecFx32 pos; + FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskMan); + UnkStruct_022523D0 *env = TaskManager_GetEnvironment(taskMan); + switch (*state) { + case 0: + MapObject_UnpauseMovement(FollowMon_GetMapObject(fieldSystem)); + TaskManager_Call(fieldSystem->taskman, ov01_02205A60, NULL); + (*state)++; + break; + case 1: + MapObject_GetPositionVec(FollowMon_GetMapObject(fieldSystem), &pos); + u32 res; + if (FollowMon_IsVisible(fieldSystem)) { + env->unk4 = ov01_022052C4(fieldSystem->unk_44, &pos); + res = 1; + } else { + env->unk4 = 0; + res = 0; + } + env->unk8 = res; + env->unk0 = 0; + FollowMon_SetObjectParams(fieldSystem->followMon.mapObject, SPECIES_SHAYMIN, 0, fieldSystem->followMon.shiny); + (*state)++; + break; + case 2: + if (env->unk8 != 0) { + if (++env->unk0 >= 4) { + ov01_021FA930(fieldSystem->followMon.mapObject, 974); + (*state)++; + } + break; + } + MapObjectManager *mapObjectMan = MapObject_GetManager(fieldSystem->followMon.mapObject); + u32 spriteId = MapObject_GetSpriteID(fieldSystem->followMon.mapObject); + sub_0205E420(fieldSystem->followMon.mapObject); + ov01_021FA108(mapObjectMan, spriteId, fieldSystem->followMon.mapObject); + sub_0205E38C(fieldSystem->followMon.mapObject, 974); + (*state)++; + break; + case 3: + if (ov01_021FA2D4(fieldSystem->followMon.mapObject) == 0) { + fieldSystem->followMon.form = 0; + (*state)++; + } + break; + case 4: + u32 var = 0; + if (env->unk4 == 0) { + var = 1; + } else if (ov01_022052F4()) { + sub_02068B48(env->unk4); + var = 1; + } + if (var != 0) { + FreeToHeap(env); + MapObject_PauseMovement(FollowMon_GetMapObject(fieldSystem)); + return TRUE; + } + break; + } + return FALSE; +} + +void ov02_02252534(FieldSystem *fieldSystem) { + UnkStruct_02252534 *ptr = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(UnkStruct_02252534)); + MI_CpuFill8(ptr, 0, sizeof(UnkStruct_02252534)); + ptr->fieldSystem = fieldSystem; + TaskManager_Call(fieldSystem->taskman, ov02_0225255C, ptr); +} + +BOOL ov02_0225255C(TaskManager *taskMan) { + int *state = TaskManager_GetStatePtr(taskMan); + FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskMan); + UnkStruct_02252534 *data = TaskManager_GetEnvironment(taskMan); + switch (*state) { + case 0: + BeginNormalPaletteFade(3, 0, 0, 0x7FFF, 4, 1, HEAP_ID_4); + (*state)++; + break; + case 1: + if (IsPaletteFadeFinished()) { + ov02_02252898(data); + sub_02069DC8(FollowMon_GetMapObject(data->fieldSystem), 1); + BeginNormalPaletteFade(3, 1, 0, 0x7FFF, 4, 1, HEAP_ID_4); + (*state)++; + } + break; + case 2: + if (IsPaletteFadeFinished()) { + sub_0205F484(FollowMon_GetMapObject(data->fieldSystem)); + data->unkF0 = 1; + (*state)++; + } + break; + case 3: + if (++data->unkF2 >= 30) { + ov02_022526C8(data); + data->unkF2 = 0; + (*state)++; + } + break; + case 4: + if (++data->unkF2 >= 80) { + BeginNormalPaletteFade(0, 0, 0, 0x7FFF, 30, 1, HEAP_ID_4); + (*state)++; + } + break; + case 5: + if (IsPaletteFadeFinished() && ov02_022526EC(data)) { + ov02_0225296C(data); + ov01_021F46DC(&data->unk4); + FreeToHeap(data); + return TRUE; + } + } + if (data->unkF0) { + ov02_022529C4(&data->unk2C); + } + if (data->unkF1) { + Field3dObject_Draw(&data->object3d); + } + + return FALSE; +} + +void ov02_022526C8(UnkStruct_02252534 *data) { + data->unk4 = ov01_021F467C(3, 13); + SysTask_CreateOnMainQueue(ov02_022526FC, data, 0); + data->unk2 = 0; +} + +BOOL ov02_022526EC(UnkStruct_02252534 *data) { + return data->unk2 != 0; +} + +extern const UnkStruct_02253CE0 ov02_02253CE0; + +void ov02_022526FC(SysTask *task, void *_data) { + UnkStruct_02252534 *data = _data; + switch (data->unkEE) { + case 0: + UnkStruct_02253CE0 unk = ov02_02253CE0; + unk.unk8 = Camera_GetPerspectiveAngle(data->fieldSystem->camera); + ov02_02252764(data, &unk); + data->unkEE++; + break; + case 1: + if (ov02_02252888(data)) { + data->unk2 = 1; + SysTask_Destroy(task); + } + } +} + +void ov02_02252764(UnkStruct_02252534 *a0, UnkStruct_02253CE0 *a1) { + a0->unk3 = 0; + a0->unkE6 = 0; + a0->unkE0 = a1->unk0; + a0->unkE4 = a0->unk0; + a0->unkEA = Camera_GetPerspectiveAngle(a0->fieldSystem->camera); + a0->unkEC = a1->unk8; + a0->unkE8 = a1->unk4; + SysTask_CreateOnMainQueue(ov02_0225286C, a0, 1); +} From 981aa1c4811c3421e7e1c403ac0362bfe3b0f76c Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 10 Nov 2024 03:43:58 -0500 Subject: [PATCH 4/7] Add MTX_RotZ33 decleration --- .github/calcrom/webhook.sh | 4 +- .github/workflows/build.yml | 2 +- asm/overlay_02_02251E74_s.s | 255 +------------------ include/overlay_2/overlay_02_02251E74.h | 22 +- lib/include/nitro/fx/fx_mtx33.h | 5 + src/overlay_02_02251E74.c | 310 +++++++++++++++++++++++- 6 files changed, 324 insertions(+), 274 deletions(-) diff --git a/.github/calcrom/webhook.sh b/.github/calcrom/webhook.sh index ff3f88830a..ba8e941a1c 100644 --- a/.github/calcrom/webhook.sh +++ b/.github/calcrom/webhook.sh @@ -1,7 +1,7 @@ #!/bin/bash -ex -# Only run this script if it's the main branch build. -if [[ "$GITHUB_REF" != "refs/heads/main" || "$GITHUB_EVENT_NAME" != "push" ]]; then +# Only run this script if it's the master branch build. +if [[ "$GITHUB_REF" != "refs/heads/master" || "$GITHUB_EVENT_NAME" != "push" ]]; then exit 0 fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1119928a54..6b9de8053a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: build on: push: - branches: [ main ] + branches: [ master ] pull_request: workflow_dispatch: diff --git a/asm/overlay_02_02251E74_s.s b/asm/overlay_02_02251E74_s.s index 16b21da3cb..d317cad937 100644 --- a/asm/overlay_02_02251E74_s.s +++ b/asm/overlay_02_02251E74_s.s @@ -9,258 +9,7 @@ .include "global.inc" .text - - thumb_func_start ov02_022527B0 -ov02_022527B0: ; 0x022527B0 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x40 - ldr r3, _02252864 ; =ov02_02253CD4 - add r5, r0, #0 - ldmia r3!, {r0, r1} - add r2, sp, #4 - stmia r2!, {r0, r1} - ldr r0, [r3] - str r0, [r2] - ldr r0, [r5, #8] - ldr r0, [r0, #0x24] - str r0, [sp] - add r0, r5, #0 - add r0, #0xe6 - ldrh r0, [r0] - add r1, r0, #1 - add r0, r5, #0 - add r0, #0xe6 - strh r1, [r0] - add r0, r5, #0 - add r0, #0xe6 - ldrh r6, [r0] - add r0, r5, #0 - add r0, #0xe8 - ldrh r7, [r0] - add r0, r5, #0 - add r0, #0xea - ldrh r4, [r0] - add r0, r5, #0 - add r0, #0xec - ldrh r0, [r0] - sub r1, r0, r4 - add r0, r1, #0 - mul r0, r6 - add r1, r7, #0 - bl _s32_div_f - add r4, r0, r4 - add r0, r5, #0 - add r0, #0xe0 - ldr r1, [r0] - add r0, r1, #0 - mul r0, r6 - add r1, r7, #0 - bl _s32_div_f - add r1, r5, #0 - add r1, #0xe4 - ldrh r1, [r1] - ldr r3, _02252868 ; =FX_SinCosTable_ - add r0, r1, r0 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - asr r0, r0, #4 - lsl r2, r0, #1 - lsl r1, r2, #1 - add r2, r2, #1 - lsl r2, r2, #1 - ldrsh r1, [r3, r1] - ldrsh r2, [r3, r2] - add r0, sp, #0x10 - bl MTX_RotZ33_ - add r0, sp, #4 - add r1, sp, #0x10 - add r2, sp, #0x34 - bl MTX_MultVec33 - ldr r1, [sp] - add r0, sp, #0x34 - bl Camera_SetLookAtCamUp - lsl r0, r4, #0x10 - ldr r1, [sp] - lsr r0, r0, #0x10 - bl Camera_SetPerspectiveAngle - add r0, r5, #0 - add r0, #0xe6 - add r5, #0xe8 - ldrh r1, [r0] - ldrh r0, [r5] - cmp r1, r0 - blo _0225285E - add sp, #0x40 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0225285E: - mov r0, #0 - add sp, #0x40 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_02252864: .word ov02_02253CD4 -_02252868: .word FX_SinCosTable_ - thumb_func_end ov02_022527B0 - - thumb_func_start ov02_0225286C -ov02_0225286C: ; 0x0225286C - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r0, r4, #0 - bl ov02_022527B0 - cmp r0, #0 - beq _02252886 - mov r0, #1 - strb r0, [r4, #3] - add r0, r5, #0 - bl SysTask_Destroy -_02252886: - pop {r3, r4, r5, pc} - thumb_func_end ov02_0225286C - - thumb_func_start ov02_02252888 -ov02_02252888: ; 0x02252888 - ldrb r0, [r0, #3] - cmp r0, #0 - beq _02252892 - mov r0, #1 - bx lr -_02252892: - mov r0, #0 - bx lr - .balign 4, 0 - thumb_func_end ov02_02252888 - - thumb_func_start ov02_02252898 -ov02_02252898: ; 0x02252898 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x28 - ldr r3, _02252968 ; =ov02_02253CEC - str r0, [sp, #8] - ldmia r3!, {r0, r1} - add r2, sp, #0x1c - stmia r2!, {r0, r1} - ldr r0, [r3] - mov r1, #4 - str r0, [r2] - ldr r0, [sp, #8] - mov r2, #0x20 - add r0, #0xc - bl GF_ExpHeap_FndInitAllocator - ldr r0, [sp, #8] - mov r1, #0xae - add r0, #0x1c - mov r2, #0x4b - mov r3, #4 - bl Field3dModel_LoadFromFilesystem - ldr r0, [sp, #8] - ldr r4, [sp, #8] - ldr r7, [sp, #8] - str r0, [sp, #0xc] - add r0, #0x1c - mov r5, #0 - add r4, #0xc - add r7, #0x2c - str r0, [sp, #0xc] -_022528D6: - mov r0, #4 - str r0, [sp] - mov r0, #0x14 - mul r0, r5 - str r4, [sp, #4] - lsl r6, r5, #2 - add r3, sp, #0x1c - ldr r1, [sp, #0xc] - ldr r3, [r3, r6] - add r0, r7, r0 - mov r2, #0xae - bl Field3dModelAnimation_LoadFromFilesystem - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #3 - blo _022528D6 - ldr r0, [sp, #8] - ldr r1, [sp, #8] - add r0, #0x68 - add r1, #0x1c - bl Field3dObject_InitFromModel - ldr r6, [sp, #8] - ldr r4, [sp, #8] - mov r5, #0 - add r6, #0x68 - add r4, #0x2c - mov r7, #0x14 -_02252912: - add r1, r5, #0 - mul r1, r7 - add r0, r6, #0 - add r1, r4, r1 - bl Field3dObject_AddAnimation - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #3 - blo _02252912 - ldr r0, [sp, #8] - mov r1, #1 - add r0, #0x68 - bl Field3dObject_SetActiveFlag - ldr r0, [sp, #8] - mov r1, #0 - add r0, #0x2c - bl ov02_022529A0 - ldr r0, [sp, #8] - ldr r0, [r0, #8] - bl FollowMon_GetMapObject - add r1, sp, #0x10 - bl MapObject_GetPositionVec - ldr r0, [sp, #8] - ldr r1, [sp, #0x10] - ldr r2, [sp, #0x14] - ldr r3, [sp, #0x18] - add r0, #0x68 - bl Field3dObject_SetPosEx - ldr r0, [sp, #8] - mov r1, #1 - add r0, #0xf1 - str r0, [sp, #8] - strb r1, [r0] - add sp, #0x28 - pop {r3, r4, r5, r6, r7, pc} - nop -_02252968: .word ov02_02253CEC - thumb_func_end ov02_02252898 - - thumb_func_start ov02_0225296C -ov02_0225296C: ; 0x0225296C - push {r3, r4, r5, r6, r7, lr} - add r4, r0, #0 - add r6, r0, #0 - str r0, [sp] - mov r5, #0 - add r4, #0x2c - add r6, #0xc - mov r7, #0x14 -_0225297C: - add r0, r5, #0 - mul r0, r7 - add r0, r4, r0 - add r1, r6, #0 - bl Field3dModelAnimation_Unload - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #3 - blo _0225297C - ldr r0, [sp] - add r0, #0x1c - str r0, [sp] - bl Field3dModel_Unload - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov02_0225296C + .public ov02_022527B0 thumb_func_start ov02_022529A0 ov02_022529A0: ; 0x022529A0 @@ -1386,6 +1135,7 @@ ov02_02253C88: ; 0x02253C88 .byte 0x18, 0x00, 0x91, 0x00, 0x01, 0x00, 0x18, 0x00, 0x92, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1B, 0x00 .byte 0x00, 0x00, 0x00, 0x00 +.public ov02_02253CD4 ov02_02253CD4: ; 0x02253CD4 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -1393,6 +1143,7 @@ ov02_02253CD4: ; 0x02253CD4 ov02_02253CE0: ; 0x02253CE0 .byte 0x00, 0x00, 0xFF, 0xFF, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00 +.public ov02_02253CEC ov02_02253CEC: ; 0x02253CEC .byte 0x4C, 0x00, 0x00, 0x00 .byte 0x4E, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x00, 0x00 diff --git a/include/overlay_2/overlay_02_02251E74.h b/include/overlay_2/overlay_02_02251E74.h index 9553029edf..05fba0cdda 100644 --- a/include/overlay_2/overlay_02_02251E74.h +++ b/include/overlay_2/overlay_02_02251E74.h @@ -29,12 +29,12 @@ typedef struct UnkStruct_02252534 { u8 unk2; u8 unk3; u32 unk4; - FieldSystem *fieldSystem; - u8 unkC[0x20]; - u32 unk2C; - u8 unk30[0x38]; + FieldSystem *fieldSystem; // 0x8 + NNSFndAllocator alloc; // 0xC + Field3dModel model; // 0x1C + Field3DModelAnimation animations[3]; Field3dObject object3d; - u32 unkE0; + s32 unkE0; u16 unkE4; u16 unkE6; u16 unkE8; @@ -57,13 +57,15 @@ void ov02_022526C8(UnkStruct_02252534 *data); BOOL ov02_022526EC(UnkStruct_02252534 *data); void ov02_022526FC(SysTask *task, void *data); void ov02_02252764(UnkStruct_02252534 *a0, UnkStruct_02253CE0 *a1); - -// the following functions are static and not decompiled +BOOL ov02_022527B0(UnkStruct_02252534 *data); +void ov02_0225286C(SysTask *task, void *data); +BOOL ov02_02252888(UnkStruct_02252534 *data); void ov02_02252898(UnkStruct_02252534 *data); void ov02_0225296C(UnkStruct_02252534 *data); + +// the following functions are static and not decompiled void ov01_021F46DC(u32 *a0); -void ov02_022529C4(u32 *a0); -void ov02_0225286C(SysTask *task, void *data); -BOOL ov02_02252888(UnkStruct_02252534 *data); +void ov02_022529C4(Field3DModelAnimation *animations); +void ov02_022529A0(Field3DModelAnimation *animations, u32 a1); #endif // POKEHEARTGOLD_OVERLAY_02_02251E74_H diff --git a/lib/include/nitro/fx/fx_mtx33.h b/lib/include/nitro/fx/fx_mtx33.h index c80df63280..144530938a 100644 --- a/lib/include/nitro/fx/fx_mtx33.h +++ b/lib/include/nitro/fx/fx_mtx33.h @@ -11,6 +11,7 @@ static inline void MTX_Copy33(const MtxFx33 *pSrc, MtxFx33 *pDst) { void MTX_Identity33_(register MtxFx33 *pDst); void MTX_RotX33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal); void MTX_RotY33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal); +void MTX_RotZ33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal); void MTX_Concat33(const MtxFx33 *a, const MtxFx33 *b, MtxFx33 *ab); void MTX_MultVec33(const VecFx32 *vec, const MtxFx33 *m, VecFx32 *dst); @@ -26,4 +27,8 @@ static inline void MTX_RotX33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal) { MTX_RotX33_(pDst, sinVal, cosVal); } +static inline void MTX_RotZ33(MtxFx33 *pDst, fx32 sinVal, fx32 cosVal) { + MTX_RotZ33_(pDst, sinVal, cosVal); +} + #endif //NITRO_FX_FX_MTX33_H_ diff --git a/src/overlay_02_02251E74.c b/src/overlay_02_02251E74.c index b4f55bbcdb..e8e14ce07f 100644 --- a/src/overlay_02_02251E74.c +++ b/src/overlay_02_02251E74.c @@ -26,7 +26,7 @@ String *GetPhoneBookEntryName(GearPhoneRingManager *gearPhone, HeapID heapId) { String *str; - if (!gearPhone->unk_var0_0 || gearPhone->unk_var2 >= 0x4b) { + if (!gearPhone->unk_var0_0 || gearPhone->unk_var2 >= 75) { str = String_New(8, heapId); } else { int phoneMsg = GetPhoneMessageGmm(gearPhone->unk_var2); @@ -38,7 +38,7 @@ String *GetPhoneBookEntryName(GearPhoneRingManager *gearPhone, HeapID heapId) { } void ov02_02251EB8(GearPhoneRingManager *gearPhone, u8 a1, u8 a2, u8 a3, u8 a4, u8 a5) { - if (a1 >= 0x4b) { + if (a1 >= 75) { gearPhone->unk_var2 = 0xFF; gearPhone->unk_arr5[0] = 0xFF; gearPhone->unk_arr5[1] = 0; @@ -55,7 +55,7 @@ void ov02_02251EB8(GearPhoneRingManager *gearPhone, u8 a1, u8 a2, u8 a3, u8 a4, u8 ov02_02251EE8(GearPhoneRingManager *gearPhone, u8 *a1) { MI_CpuFill8(a1, 0, 5); - if (gearPhone->unk_var2 >= 0x4b) { + if (gearPhone->unk_var2 >= 75) { GF_ASSERT(FALSE); a1[0] = 0xFF; return 0xFF; @@ -183,15 +183,241 @@ u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 map return ret; } #else -//clang-format off +// clang-format off extern u32 _u32_div_f(u32 a1, u32 a2); extern s32 _s32_div_f(s32 a1, s32 a2); asm u32 ov02_02251FDC(GearPhoneRingManager *gearPhone, PhoneBook *phoneBook, u32 mapId) { - push { r3, r4, r5, r6, r7, lr } sub sp, #0x30 str r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] add r6, r1, #0 str r2, [ sp, #0xc ] bl Save_VarsFlags_Get str r0, [ sp, #0x1c ] ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] bl Save_PlayerData_GetProfileAddr ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] bl Save_Misc_Get str r0, [ sp, #0x18 ] ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x30 ] bl GSPlayerMisc_FindEmptyGearPhonebookSlot str r0, [ sp, #0x2c ] ldr r0, [ sp, #8 ] mov r1, #4 ldr r0, [ r0, #0x30 ] bl GSPlayerMisc_AllocAndCopyPhonebook str r0, [ sp, #0x20 ] ldr r1, [ sp, #0x2c ] mov r0, #4 bl AllocFromHeapAtEnd ldr r2, [ sp, #0x2c ] mov r1, #0xff add r4, r0, #0 bl MI_CpuFill8 bl LCRandom mov r1, #0xfa lsl r1, r1, #2 bl _s32_div_f lsl r0, r1, #0x10 lsr r1, r0, #0x10 mov r0, #0x7d lsl r0, r0, #2 cmp r1, r0 bhs _02252046 mov r0, #0 str r0, [ sp, #0x24 ] b _02252058 _02252046 : mov r0, #0x32 lsl r0, r0, #4 cmp r1, r0 bhs _02252054 mov r0, #1 str r0, [ sp, #0x24 ] b _02252058 _02252054 : mov r0, #2 str r0, [ sp, #0x24 ] _02252058 : ldr r0, [ sp, #0x2c ] mov r7, #0 add r2, r7, #0 cmp r0, #0 bls _022520A2 _02252062 : ldr r0, [ sp, #0x20 ] mov r1, #0x14 ldrb r3, [ r0, r2 ] ldr r0, [ r6, #4 ] mul r1, r3 add r5, r0, r1 ldrb r1, [ r5, #0xf ] ldr r0, [ sp, #0x24 ] cmp r0, r1 bne _02252096 ldrb r0, [ r5, #1 ] cmp r0, #0 beq _0225208C cmp r0, #0xc beq _0225208C cmp r0, #0xb beq _0225208C cmp r0, #0xa beq _0225208C cmp r0, #0xe bne _02252096 _0225208C : add r1, r7, #1 add r0, r7, #0 lsl r1, r1, #0x18 lsr r7, r1, #0x18 strb r3, [ r4, r0 ] _02252096 : add r0, r2, #1 lsl r0, r0, #0x18 lsr r2, r0, #0x18 ldr r0, [ sp, #0x2c ] cmp r2, r0 blo _02252062 _022520A2 : cmp r7, #0 bne _022520B8 ldr r0, [ sp, #0x20 ] bl FreeToHeap add r0, r4, #0 bl FreeToHeap add sp, #0x30 mov r0, #0 pop { r3, r4, r5, r6, r7, pc } _022520B8 : ldr r0, [ sp, #0x20 ] ldr r2, [ sp, #0x2c ] mov r1, #0xff bl MI_CpuFill8 ldr r0, [ sp, #8 ] ldr r0, [ r0, #0x38 ] bl Save_SysInfo_RTC_Get ldr r0, [ r0, #0x14 ] lsl r0, r0, #0x18 lsr r0, r0, #0x18 str r0, [ sp, #0x14 ] ldr r0, [ sp, #0x1c ] bl Save_VarsFlags_CheckBugContestFlag lsl r0, r0, #0x18 lsr r0, r0, #0x18 str r0, [ sp, #0x10 ] mov r0, #0 str r0, [ sp, #0x28 ] ldr r0, [ sp, #0x18 ] ldr r1, [ sp, #0x24 ] bl sub_0202AAD4 cmp r0, r7 bne _022520F6 ldr r0, [ sp, #0x18 ] ldr r1, [ sp, #0x24 ] bl sub_0202AA9C _022520F6 : mov r5, #0 cmp r7, #0 bls _02252164 _022520FC : ldrb r2, [ r4, r5 ] mov r1, #0x14 ldr r0, [ r6, #4 ] mul r1, r2 add r0, r0, r1 ldrh r1, [ r0, #6 ] ldr r0, [ sp, #0xc ] cmp r0, r1 beq _0225215A ldr r0, [ sp, #0x18 ] ldr r1, [ sp, #0x24 ] bl sub_0202AA44 cmp r0, #0 bne _0225215A ldrb r0, [ r4, r5 ] cmp r0, #8 bne _02252134 ldr r0, [ sp, #0x14 ] bl sub_02095FF8 cmp r0, #0 bne _0225215A ldr r0, [ sp, #0x1c ] bl Save_VarsFlags_IsInRocketTakeover cmp r0, #0 bne _0225215A _02252134 : ldrb r1, [ r4, r5 ] mov r2, #0x14 ldr r0, [ r6, #4 ] mul r2, r1 add r0, r0, r2 ldrh r0, [ r0, #6 ] cmp r0, #0x60 bne _0225214A ldr r0, [ sp, #0x10 ] cmp r0, #0 bne _0225215A _0225214A : ldr r0, [ sp, #0x28 ] add r2, r0, #0 add r2, r2, #1 lsl r2, r2, #0x18 lsr r2, r2, #0x18 str r2, [ sp, #0x28 ] ldr r2, [ sp, #0x20 ] strb r1, [ r2, r0 ] _0225215A : add r0, r5, #1 lsl r0, r0, #0x18 lsr r5, r0, #0x18 cmp r5, r7 blo _022520FC _02252164 : ldr r0, [ sp, #0x28 ] cmp r0, #0 beq _022521AC bl MTRandom ldr r2, [ sp, #0x28 ] mov r1, #0x64 mul r1, r2 bl _u32_div_f add r0, r1, #0 mov r1, #0x64 bl _u32_div_f add r1, r0, #0 lsl r1, r1, #0x10 lsr r1, r1, #0x10 mov r0, #0 lsl r1, r1, #0x18 str r0, [sp] lsr r2, r1, #0x18 str r0, [ sp, #4 ] ldr r1, [ sp, #0x20 ] ldr r0, [ sp, #8 ] ldrb r1, [ r1, r2 ] ldr r2, [ sp, #0x24 ] add r3, r7, #0 bl ov02_02251EB8 ldr r0, [ sp, #8 ] bl sub_02092DF4 ldr r0, [ sp, #8 ] mov r1, #1 bl ov02_022522AC _022521AC : ldr r0, [ sp, #0x20 ] bl FreeToHeap add r0, r4, #0 bl FreeToHeap ldr r0, [ sp, #0x28 ] add sp, #0x30 pop { - r3, r4, r5, r6, r7, pc - } + push {r3, r4, r5, r6, r7, lr} + sub sp, #0x30 + str r0, [sp, #8] + ldr r0, [r0, #0x38] + add r6, r1, #0 + str r2, [sp, #0xc] + bl Save_VarsFlags_Get + str r0, [sp, #0x1c] + ldr r0, [sp, #8] + ldr r0, [r0, #0x38] + bl Save_PlayerData_GetProfileAddr + ldr r0, [sp, #8] + ldr r0, [r0, #0x38] + bl Save_Misc_Get + str r0, [sp, #0x18] + ldr r0, [sp, #8] + ldr r0, [r0, #0x30] + bl GSPlayerMisc_FindEmptyGearPhonebookSlot + str r0, [sp, #0x2c] + ldr r0, [sp, #8] + mov r1, #4 + ldr r0, [r0, #0x30] + bl GSPlayerMisc_AllocAndCopyPhonebook + str r0, [sp, #0x20] + ldr r1, [sp, #0x2c] + mov r0, #4 + bl AllocFromHeapAtEnd + ldr r2, [sp, #0x2c] + mov r1, #0xff + add r4, r0, #0 + bl MI_CpuFill8 + bl LCRandom + mov r1, #0xfa + lsl r1, r1, #2 + bl _s32_div_f + lsl r0, r1, #0x10 + lsr r1, r0, #0x10 + mov r0, #0x7d + lsl r0, r0, #2 + cmp r1, r0 + bhs _02252046 + mov r0, #0 + str r0, [sp, #0x24] + b _02252058 +_02252046: + mov r0, #0x32 + lsl r0, r0, #4 + cmp r1, r0 + bhs _02252054 + mov r0, #1 + str r0, [sp, #0x24] + b _02252058 +_02252054: + mov r0, #2 + str r0, [sp, #0x24] +_02252058: + ldr r0, [sp, #0x2c] + mov r7, #0 + add r2, r7, #0 + cmp r0, #0 + bls _022520A2 +_02252062: + ldr r0, [sp, #0x20] + mov r1, #0x14 + ldrb r3, [r0, r2] + ldr r0, [r6, #4] + mul r1, r3 + add r5, r0, r1 + ldrb r1, [r5, #0xf] + ldr r0, [sp, #0x24] + cmp r0, r1 + bne _02252096 + ldrb r0, [r5, #1] + cmp r0, #0 + beq _0225208C + cmp r0, #0xc + beq _0225208C + cmp r0, #0xb + beq _0225208C + cmp r0, #0xa + beq _0225208C + cmp r0, #0xe + bne _02252096 +_0225208C: + add r1, r7, #1 + add r0, r7, #0 + lsl r1, r1, #0x18 + lsr r7, r1, #0x18 + strb r3, [r4, r0] +_02252096: + add r0, r2, #1 + lsl r0, r0, #0x18 + lsr r2, r0, #0x18 + ldr r0, [sp, #0x2c] + cmp r2, r0 + blo _02252062 +_022520A2: + cmp r7, #0 + bne _022520B8 + ldr r0, [sp, #0x20] + bl FreeToHeap + add r0, r4, #0 + bl FreeToHeap + add sp, #0x30 + mov r0, #0 + pop {r3, r4, r5, r6, r7, pc} +_022520B8: + ldr r0, [sp, #0x20] + ldr r2, [sp, #0x2c] + mov r1, #0xff + bl MI_CpuFill8 + ldr r0, [sp, #8] + ldr r0, [r0, #0x38] + bl Save_SysInfo_RTC_Get + ldr r0, [r0, #0x14] + lsl r0, r0, #0x18 + lsr r0, r0, #0x18 + str r0, [sp, #0x14] + ldr r0, [sp, #0x1c] + bl Save_VarsFlags_CheckBugContestFlag + lsl r0, r0, #0x18 + lsr r0, r0, #0x18 + str r0, [sp, #0x10] + mov r0, #0 + str r0, [sp, #0x28] + ldr r0, [sp, #0x18] + ldr r1, [sp, #0x24] + bl sub_0202AAD4 + cmp r0, r7 + bne _022520F6 + ldr r0, [sp, #0x18] + ldr r1, [sp, #0x24] + bl sub_0202AA9C +_022520F6: + mov r5, #0 + cmp r7, #0 + bls _02252164 +_022520FC: + ldrb r2, [r4, r5] + mov r1, #0x14 + ldr r0, [r6, #4] + mul r1, r2 + add r0, r0, r1 + ldrh r1, [r0, #6] + ldr r0, [sp, #0xc] + cmp r0, r1 + beq _0225215A + ldr r0, [sp, #0x18] + ldr r1, [sp, #0x24] + bl sub_0202AA44 + cmp r0, #0 + bne _0225215A + ldrb r0, [r4, r5] + cmp r0, #8 + bne _02252134 + ldr r0, [sp, #0x14] + bl sub_02095FF8 + cmp r0, #0 + bne _0225215A + ldr r0, [sp, #0x1c] + bl Save_VarsFlags_IsInRocketTakeover + cmp r0, #0 + bne _0225215A +_02252134: + ldrb r1, [r4, r5] + mov r2, #0x14 + ldr r0, [r6, #4] + mul r2, r1 + add r0, r0, r2 + ldrh r0, [r0, #6] + cmp r0, #0x60 + bne _0225214A + ldr r0, [sp, #0x10] + cmp r0, #0 + bne _0225215A +_0225214A: + ldr r0, [sp, #0x28] + add r2, r0, #0 + add r2, r2, #1 + lsl r2, r2, #0x18 + lsr r2, r2, #0x18 + str r2, [sp, #0x28] + ldr r2, [sp, #0x20] + strb r1, [r2, r0] +_0225215A: + add r0, r5, #1 + lsl r0, r0, #0x18 + lsr r5, r0, #0x18 + cmp r5, r7 + blo _022520FC +_02252164: + ldr r0, [sp, #0x28] + cmp r0, #0 + beq _022521AC + bl MTRandom + ldr r2, [sp, #0x28] + mov r1, #0x64 + mul r1, r2 + bl _u32_div_f + add r0, r1, #0 + mov r1, #0x64 + bl _u32_div_f + add r1, r0, #0 + lsl r1, r1, #0x10 + lsr r1, r1, #0x10 + mov r0, #0 + lsl r1, r1, #0x18 + str r0, [sp] + lsr r2, r1, #0x18 + str r0, [sp, #4] + ldr r1, [sp, #0x20] + ldr r0, [sp, #8] + ldrb r1, [r1, r2] + ldr r2, [sp, #0x24] + add r3, r7, #0 + bl ov02_02251EB8 + ldr r0, [sp, #8] + bl sub_02092DF4 + ldr r0, [sp, #8] + mov r1, #1 + bl ov02_022522AC +_022521AC: + ldr r0, [sp, #0x20] + bl FreeToHeap + add r0, r4, #0 + bl FreeToHeap + ldr r0, [sp, #0x28] + add sp, #0x30 + pop {r3, r4, r5, r6, r7, pc} } -//clang-format on +// clang-format on #endif typedef struct UnkStruct_02253C86 { @@ -425,7 +651,7 @@ BOOL ov02_0225255C(TaskManager *taskMan) { } } if (data->unkF0) { - ov02_022529C4(&data->unk2C); + ov02_022529C4(&data->animations[0]); } if (data->unkF1) { Field3dObject_Draw(&data->object3d); @@ -473,3 +699,69 @@ void ov02_02252764(UnkStruct_02252534 *a0, UnkStruct_02253CE0 *a1) { a0->unkE8 = a1->unk4; SysTask_CreateOnMainQueue(ov02_0225286C, a0, 1); } + +extern const VecFx32 ov02_02253CD4; + +BOOL ov02_022527B0(UnkStruct_02252534 *data) { + VecFx32 vec; + MtxFx33 rotMatrix; + VecFx32 vec2 = ov02_02253CD4; + Camera *camera = data->fieldSystem->camera; + + data->unkE6++; + int e6 = data->unkE6; + int e8 = data->unkE8; + + int angle = data->unkEC - data->unkEA; + angle *= e6; + angle /= e8; + angle += data->unkEA; + u16 index = ((data->unkE0 * e6) / e8) + data->unkE4; + MTX_RotZ33(&rotMatrix, FX_SinIdx(index), FX_CosIdx(index)); + MTX_MultVec33(&vec2, &rotMatrix, &vec); + Camera_SetLookAtCamUp(&vec, camera); + Camera_SetPerspectiveAngle(angle, camera); + return data->unkE6 >= data->unkE8; +} + +void ov02_0225286C(SysTask *task, void *_data) { + UnkStruct_02252534 *data = _data; + if (ov02_022527B0(data)) { + data->unk3 = 1; + SysTask_Destroy(task); + } +} + +BOOL ov02_02252888(UnkStruct_02252534 *data) { + return data->unk3 != 0; +} + +extern const u32 ov02_02253CEC[3]; + +void ov02_02252898(UnkStruct_02252534 *data) { + u32 unk[3]; + unk = ov02_02253CEC; + GF_ExpHeap_FndInitAllocator(&data->alloc, HEAP_ID_4, 32); + Field3dModel_LoadFromFilesystem(&data->model, NARC_demo_legend, 75, HEAP_ID_4); + for (u8 i = 0; i < 3; i++) { + Field3dModelAnimation_LoadFromFilesystem(&data->animations[i], &data->model, NARC_demo_legend, unk[i], HEAP_ID_4, &data->alloc); + } + Field3dObject_InitFromModel(&data->object3d, &data->model); + for (u8 i = 0; i < 3; i++) { + Field3dObject_AddAnimation(&data->object3d, &data->animations[i]); + } + Field3dObject_SetActiveFlag(&data->object3d, 1); + ov02_022529A0(&data->animations[0], 0); + LocalMapObject *followMonObj = FollowMon_GetMapObject(data->fieldSystem); + VecFx32 pos; + MapObject_GetPositionVec(followMonObj, &pos); + Field3dObject_SetPosEx(&data->object3d, pos.x, pos.y, pos.z); + data->unkF1 = 1; +} + +void ov02_0225296C(UnkStruct_02252534 *data) { + for (u8 i = 0; i < 3; i++) { + Field3dModelAnimation_Unload(&data->animations[i], &data->alloc); + } + Field3dModel_Unload(&data->model); +} From 4337d019639ed17f802f897b42ea4b6d384063e3 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 10 Nov 2024 04:54:03 -0500 Subject: [PATCH 5/7] Begin documenting Celebi Cutscene task --- asm/include/overlay_02.inc | 2 +- asm/overlay_02_02251E74_s.s | 6 +- include/overlay_02.h | 2 +- include/overlay_2/overlay_02_02251E74.h | 30 ++++----- src/overlay_02_02251E74.c | 86 ++++++++++++------------- src/scrcmd_c.c | 2 +- 6 files changed, 64 insertions(+), 64 deletions(-) diff --git a/asm/include/overlay_02.inc b/asm/include/overlay_02.inc index b5898722cb..7b5784015a 100644 --- a/asm/include/overlay_02.inc +++ b/asm/include/overlay_02.inc @@ -531,7 +531,7 @@ .public GetRadioMusicPlayingSeq .public ov02_02252334 .public ov02_022523B4 -.public ov02_02252534 +.public FieldSystem_BeginCelebiTimeTravelCutsceneTask .public ov02_022529FC .public ov02_02252EE4 .public ov02_02253134 diff --git a/asm/overlay_02_02251E74_s.s b/asm/overlay_02_02251E74_s.s index d317cad937..ddd08edbba 100644 --- a/asm/overlay_02_02251E74_s.s +++ b/asm/overlay_02_02251E74_s.s @@ -9,7 +9,7 @@ .include "global.inc" .text - .public ov02_022527B0 + .public CelebiCutscene_SwirlEffect thumb_func_start ov02_022529A0 ov02_022529A0: ; 0x022529A0 @@ -1143,8 +1143,8 @@ ov02_02253CD4: ; 0x02253CD4 ov02_02253CE0: ; 0x02253CE0 .byte 0x00, 0x00, 0xFF, 0xFF, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00 -.public ov02_02253CEC -ov02_02253CEC: ; 0x02253CEC +.public sCelebiCutsceneAnimationFiles +sCelebiCutsceneAnimationFiles: ; 0x02253CEC .byte 0x4C, 0x00, 0x00, 0x00 .byte 0x4E, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x00, 0x00 diff --git a/include/overlay_02.h b/include/overlay_02.h index 0bbe10e9f0..7e074bf4b5 100644 --- a/include/overlay_02.h +++ b/include/overlay_02.h @@ -74,7 +74,7 @@ BOOL ov02_02250780(FieldSystem *fieldSystem, u8 a1); void ov02_022507B4(FieldSystem *fieldSystem, u8 a1); void ov02_022508B4(FieldSystem *fieldSystem); void ov02_022523B4(TaskManager *taskManager); -void ov02_02252534(FieldSystem *fieldSystem); +void FieldSystem_BeginCelebiTimeTravelCutsceneTask(FieldSystem *fieldSystem); void ov02_022529FC(FieldSystem *fieldSystem); void ov02_02252EE4(FieldSystem *fieldSystem, u8 a1); BOOL ov02_02253134(SaveData *saveData); diff --git a/include/overlay_2/overlay_02_02251E74.h b/include/overlay_2/overlay_02_02251E74.h index 05fba0cdda..be64a688d2 100644 --- a/include/overlay_2/overlay_02_02251E74.h +++ b/include/overlay_2/overlay_02_02251E74.h @@ -18,16 +18,16 @@ int GetRadioMusicPlayingSeq(void); BOOL ov02_02252334(FieldSystem *fieldSystem); void ov02_022523B4(TaskManager *taskMan); BOOL ov02_022523D0(TaskManager *taskMan); -void ov02_02252534(FieldSystem *fieldSystem); +void FieldSystem_BeginCelebiTimeTravelCutsceneTask(FieldSystem *fieldSystem); // the following is as of yet not decompiled -BOOL ov02_0225255C(TaskManager *taskMan); +BOOL Task_CelebiTimeTravelCutscene(TaskManager *taskMan); // the following functions are static -typedef struct UnkStruct_02252534 { +typedef struct CelebiTimeTravelCutsceneTaskData { u16 unk0; u8 unk2; - u8 unk3; + u8 isSwirlFinished; u32 unk4; FieldSystem *fieldSystem; // 0x8 NNSFndAllocator alloc; // 0xC @@ -38,14 +38,14 @@ typedef struct UnkStruct_02252534 { u16 unkE4; u16 unkE6; u16 unkE8; - u16 unkEA; + u16 perspective; u16 unkEC; u16 unkEE; u8 unkF0; u8 unkF1; u8 unkF2; u8 unkF3; -} UnkStruct_02252534; +} CelebiTimeTravelCutsceneTaskData; typedef struct UnkStruct_02253CE0 { u32 unk0; @@ -53,15 +53,15 @@ typedef struct UnkStruct_02253CE0 { u16 unk8; u16 unkA; } UnkStruct_02253CE0; -void ov02_022526C8(UnkStruct_02252534 *data); -BOOL ov02_022526EC(UnkStruct_02252534 *data); -void ov02_022526FC(SysTask *task, void *data); -void ov02_02252764(UnkStruct_02252534 *a0, UnkStruct_02253CE0 *a1); -BOOL ov02_022527B0(UnkStruct_02252534 *data); -void ov02_0225286C(SysTask *task, void *data); -BOOL ov02_02252888(UnkStruct_02252534 *data); -void ov02_02252898(UnkStruct_02252534 *data); -void ov02_0225296C(UnkStruct_02252534 *data); +void CelebiCutscene_StartSwirlTask(CelebiTimeTravelCutsceneTaskData *data); +BOOL ov02_022526EC(CelebiTimeTravelCutsceneTaskData *data); +void Task_CelebiCutsceneSwirl(SysTask *task, void *data); +void CelebiCutscene_InitSwirlData(CelebiTimeTravelCutsceneTaskData *a0, UnkStruct_02253CE0 *a1); +BOOL CelebiCutscene_SwirlEffect(CelebiTimeTravelCutsceneTaskData *data); +void Task_CelebiCutsceneSwirlEffect(SysTask *task, void *data); +BOOL CelebiCutscene_IsSwirlFinished(CelebiTimeTravelCutsceneTaskData *data); +void CelebiCutscene_LoadResources(CelebiTimeTravelCutsceneTaskData *data); +void CelebiCutscene_UnloadResources(CelebiTimeTravelCutsceneTaskData *data); // the following functions are static and not decompiled void ov01_021F46DC(u32 *a0); diff --git a/src/overlay_02_02251E74.c b/src/overlay_02_02251E74.c index e8e14ce07f..93c59489db 100644 --- a/src/overlay_02_02251E74.c +++ b/src/overlay_02_02251E74.c @@ -598,27 +598,27 @@ BOOL ov02_022523D0(TaskManager *taskMan) { return FALSE; } -void ov02_02252534(FieldSystem *fieldSystem) { - UnkStruct_02252534 *ptr = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(UnkStruct_02252534)); - MI_CpuFill8(ptr, 0, sizeof(UnkStruct_02252534)); +void FieldSystem_BeginCelebiTimeTravelCutsceneTask(FieldSystem *fieldSystem) { + CelebiTimeTravelCutsceneTaskData *ptr = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(CelebiTimeTravelCutsceneTaskData)); + MI_CpuFill8(ptr, 0, sizeof(CelebiTimeTravelCutsceneTaskData)); ptr->fieldSystem = fieldSystem; - TaskManager_Call(fieldSystem->taskman, ov02_0225255C, ptr); + TaskManager_Call(fieldSystem->taskman, Task_CelebiTimeTravelCutscene, ptr); } -BOOL ov02_0225255C(TaskManager *taskMan) { +BOOL Task_CelebiTimeTravelCutscene(TaskManager *taskMan) { int *state = TaskManager_GetStatePtr(taskMan); FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskMan); - UnkStruct_02252534 *data = TaskManager_GetEnvironment(taskMan); + CelebiTimeTravelCutsceneTaskData *data = TaskManager_GetEnvironment(taskMan); switch (*state) { case 0: - BeginNormalPaletteFade(3, 0, 0, 0x7FFF, 4, 1, HEAP_ID_4); + BeginNormalPaletteFade(3, 0, 0, RGB_WHITE, 4, 1, HEAP_ID_4); (*state)++; break; case 1: if (IsPaletteFadeFinished()) { - ov02_02252898(data); + CelebiCutscene_LoadResources(data); sub_02069DC8(FollowMon_GetMapObject(data->fieldSystem), 1); - BeginNormalPaletteFade(3, 1, 0, 0x7FFF, 4, 1, HEAP_ID_4); + BeginNormalPaletteFade(3, 1, 0, RGB_WHITE, 4, 1, HEAP_ID_4); (*state)++; } break; @@ -631,20 +631,20 @@ BOOL ov02_0225255C(TaskManager *taskMan) { break; case 3: if (++data->unkF2 >= 30) { - ov02_022526C8(data); + CelebiCutscene_StartSwirlTask(data); data->unkF2 = 0; (*state)++; } break; case 4: if (++data->unkF2 >= 80) { - BeginNormalPaletteFade(0, 0, 0, 0x7FFF, 30, 1, HEAP_ID_4); + BeginNormalPaletteFade(0, 0, 0, RGB_WHITE, 30, 1, HEAP_ID_4); (*state)++; } break; case 5: if (IsPaletteFadeFinished() && ov02_022526EC(data)) { - ov02_0225296C(data); + CelebiCutscene_UnloadResources(data); ov01_021F46DC(&data->unk4); FreeToHeap(data); return TRUE; @@ -660,49 +660,49 @@ BOOL ov02_0225255C(TaskManager *taskMan) { return FALSE; } -void ov02_022526C8(UnkStruct_02252534 *data) { +void CelebiCutscene_StartSwirlTask(CelebiTimeTravelCutsceneTaskData *data) { data->unk4 = ov01_021F467C(3, 13); - SysTask_CreateOnMainQueue(ov02_022526FC, data, 0); + SysTask_CreateOnMainQueue(Task_CelebiCutsceneSwirl, data, 0); data->unk2 = 0; } -BOOL ov02_022526EC(UnkStruct_02252534 *data) { +BOOL ov02_022526EC(CelebiTimeTravelCutsceneTaskData *data) { return data->unk2 != 0; } extern const UnkStruct_02253CE0 ov02_02253CE0; -void ov02_022526FC(SysTask *task, void *_data) { - UnkStruct_02252534 *data = _data; +void Task_CelebiCutsceneSwirl(SysTask *task, void *_data) { + CelebiTimeTravelCutsceneTaskData *data = _data; switch (data->unkEE) { case 0: UnkStruct_02253CE0 unk = ov02_02253CE0; unk.unk8 = Camera_GetPerspectiveAngle(data->fieldSystem->camera); - ov02_02252764(data, &unk); + CelebiCutscene_InitSwirlData(data, &unk); data->unkEE++; break; case 1: - if (ov02_02252888(data)) { + if (CelebiCutscene_IsSwirlFinished(data)) { data->unk2 = 1; SysTask_Destroy(task); } } } -void ov02_02252764(UnkStruct_02252534 *a0, UnkStruct_02253CE0 *a1) { - a0->unk3 = 0; - a0->unkE6 = 0; - a0->unkE0 = a1->unk0; - a0->unkE4 = a0->unk0; - a0->unkEA = Camera_GetPerspectiveAngle(a0->fieldSystem->camera); - a0->unkEC = a1->unk8; - a0->unkE8 = a1->unk4; - SysTask_CreateOnMainQueue(ov02_0225286C, a0, 1); +void CelebiCutscene_InitSwirlData(CelebiTimeTravelCutsceneTaskData *data, UnkStruct_02253CE0 *a1) { + data->isSwirlFinished = FALSE; + data->unkE6 = 0; + data->unkE0 = a1->unk0; + data->unkE4 = data->unk0; + data->perspective = Camera_GetPerspectiveAngle(data->fieldSystem->camera); + data->unkEC = a1->unk8; + data->unkE8 = a1->unk4; + SysTask_CreateOnMainQueue(Task_CelebiCutsceneSwirlEffect, data, 1); } extern const VecFx32 ov02_02253CD4; -BOOL ov02_022527B0(UnkStruct_02252534 *data) { +BOOL CelebiCutscene_SwirlEffect(CelebiTimeTravelCutsceneTaskData *data) { VecFx32 vec; MtxFx33 rotMatrix; VecFx32 vec2 = ov02_02253CD4; @@ -712,10 +712,10 @@ BOOL ov02_022527B0(UnkStruct_02252534 *data) { int e6 = data->unkE6; int e8 = data->unkE8; - int angle = data->unkEC - data->unkEA; + int angle = data->unkEC - data->perspective; angle *= e6; angle /= e8; - angle += data->unkEA; + angle += data->perspective; u16 index = ((data->unkE0 * e6) / e8) + data->unkE4; MTX_RotZ33(&rotMatrix, FX_SinIdx(index), FX_CosIdx(index)); MTX_MultVec33(&vec2, &rotMatrix, &vec); @@ -724,27 +724,27 @@ BOOL ov02_022527B0(UnkStruct_02252534 *data) { return data->unkE6 >= data->unkE8; } -void ov02_0225286C(SysTask *task, void *_data) { - UnkStruct_02252534 *data = _data; - if (ov02_022527B0(data)) { - data->unk3 = 1; +void Task_CelebiCutsceneSwirlEffect(SysTask *task, void *_data) { + CelebiTimeTravelCutsceneTaskData *data = _data; + if (CelebiCutscene_SwirlEffect(data)) { + data->isSwirlFinished = TRUE; SysTask_Destroy(task); } } -BOOL ov02_02252888(UnkStruct_02252534 *data) { - return data->unk3 != 0; +BOOL CelebiCutscene_IsSwirlFinished(CelebiTimeTravelCutsceneTaskData *data) { + return data->isSwirlFinished != FALSE; } -extern const u32 ov02_02253CEC[3]; +extern const u32 sCelebiCutsceneAnimationFiles[3]; // file ids 76-78 -void ov02_02252898(UnkStruct_02252534 *data) { - u32 unk[3]; - unk = ov02_02253CEC; +void CelebiCutscene_LoadResources(CelebiTimeTravelCutsceneTaskData *data) { + u32 files[3]; + files = sCelebiCutsceneAnimationFiles; GF_ExpHeap_FndInitAllocator(&data->alloc, HEAP_ID_4, 32); Field3dModel_LoadFromFilesystem(&data->model, NARC_demo_legend, 75, HEAP_ID_4); for (u8 i = 0; i < 3; i++) { - Field3dModelAnimation_LoadFromFilesystem(&data->animations[i], &data->model, NARC_demo_legend, unk[i], HEAP_ID_4, &data->alloc); + Field3dModelAnimation_LoadFromFilesystem(&data->animations[i], &data->model, NARC_demo_legend, files[i], HEAP_ID_4, &data->alloc); } Field3dObject_InitFromModel(&data->object3d, &data->model); for (u8 i = 0; i < 3; i++) { @@ -759,7 +759,7 @@ void ov02_02252898(UnkStruct_02252534 *data) { data->unkF1 = 1; } -void ov02_0225296C(UnkStruct_02252534 *data) { +void CelebiCutscene_UnloadResources(CelebiTimeTravelCutsceneTaskData *data) { for (u8 i = 0; i < 3; i++) { Field3dModelAnimation_Unload(&data->animations[i], &data->alloc); } diff --git a/src/scrcmd_c.c b/src/scrcmd_c.c index 70990904d5..f7b934a141 100644 --- a/src/scrcmd_c.c +++ b/src/scrcmd_c.c @@ -5323,7 +5323,7 @@ BOOL ScrCmd_806(ScriptContext *ctx) { } BOOL ScrCmd_810(ScriptContext *ctx) { - ov02_02252534(ctx->fieldSystem); + FieldSystem_BeginCelebiTimeTravelCutsceneTask(ctx->fieldSystem); return TRUE; } From da7355f632cf36d7adf710f710c6ba39505a23c2 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 14 Nov 2024 04:26:55 -0500 Subject: [PATCH 6/7] Commit before discord request --- asm/include/overlay_02.inc | 2 +- asm/include/unk_0205CB48.inc | 2 +- asm/overlay_02_02251E74_s.s | 273 +----------------------- asm/unk_0205CB48.s | 6 +- include/field_player_avatar.h | 2 +- include/field_system.h | 2 +- include/overlay_02.h | 3 +- include/overlay_2/overlay_02_02251E74.h | 27 ++- include/unk_0205CB48.h | 2 +- src/field_player_avatar.c | 6 +- src/field_system.c | 11 +- src/overlay_02_02251E74.c | 89 +++++++- src/scrcmd_c.c | 2 +- 13 files changed, 135 insertions(+), 292 deletions(-) diff --git a/asm/include/overlay_02.inc b/asm/include/overlay_02.inc index 7b5784015a..1ddcb761a7 100644 --- a/asm/include/overlay_02.inc +++ b/asm/include/overlay_02.inc @@ -532,7 +532,7 @@ .public ov02_02252334 .public ov02_022523B4 .public FieldSystem_BeginCelebiTimeTravelCutsceneTask -.public ov02_022529FC +.public FieldSystem_BeginSinjohCutsceneTask .public ov02_02252EE4 .public ov02_02253134 .public ov02_0225316C diff --git a/asm/include/unk_0205CB48.inc b/asm/include/unk_0205CB48.inc index cd455c1e66..0513a4bf31 100644 --- a/asm/include/unk_0205CB48.inc +++ b/asm/include/unk_0205CB48.inc @@ -63,7 +63,7 @@ .public sub_0205CB2C .public sub_0205CB48 .public sub_0205CBE4 -.public sub_0205CE68 +.public PlayerAvatar_UpdateMovement .public sub_0205CF44 .public sub_0205CF60 .public sub_0205CFBC diff --git a/asm/overlay_02_02251E74_s.s b/asm/overlay_02_02251E74_s.s index ddd08edbba..273b050484 100644 --- a/asm/overlay_02_02251E74_s.s +++ b/asm/overlay_02_02251E74_s.s @@ -11,269 +11,8 @@ .text .public CelebiCutscene_SwirlEffect - thumb_func_start ov02_022529A0 -ov02_022529A0: ; 0x022529A0 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - add r6, r1, #0 - mov r4, #0 - mov r7, #0x14 -_022529AA: - add r0, r4, #0 - mul r0, r7 - add r0, r5, r0 - add r1, r6, #0 - bl Field3dModelAnimation_FrameSet - add r0, r4, #1 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - cmp r4, #3 - blo _022529AA - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov02_022529A0 - - thumb_func_start ov02_022529C4 -ov02_022529C4: ; 0x022529C4 - push {r3, r4, r5, r6, r7, lr} - mov r5, #0 - add r6, r0, #0 - add r4, r5, #0 - mov r7, #0x14 -_022529CE: - add r0, r4, #0 - mul r0, r7 - mov r1, #1 - add r0, r6, r0 - lsl r1, r1, #0xc - bl Field3dModelAnimation_FrameAdvanceAndCheck - cmp r0, #0 - beq _022529E6 - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 -_022529E6: - add r0, r4, #1 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - cmp r4, #3 - blo _022529CE - cmp r5, #3 - bne _022529F8 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_022529F8: - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov02_022529C4 - - thumb_func_start ov02_022529FC -ov02_022529FC: ; 0x022529FC - push {r3, r4, r5, lr} - mov r1, #0x8a - add r5, r0, #0 - mov r0, #0xb - lsl r1, r1, #2 - bl AllocFromHeapAtEnd - mov r2, #0x8a - add r4, r0, #0 - mov r1, #0 - lsl r2, r2, #2 - bl MI_CpuFill8 - str r5, [r4] - ldr r0, [r5, #0x10] - ldr r1, _02252A24 ; =ov02_02252A28 - add r2, r4, #0 - bl TaskManager_Call - pop {r3, r4, r5, pc} - .balign 4, 0 -_02252A24: .word ov02_02252A28 - thumb_func_end ov02_022529FC - - thumb_func_start ov02_02252A28 -ov02_02252A28: ; 0x02252A28 - push {r4, r5, lr} - sub sp, #0xc - add r4, r0, #0 - bl TaskManager_GetStatePtr - add r5, r0, #0 - add r0, r4, #0 - bl TaskManager_GetFieldSystem - add r0, r4, #0 - bl TaskManager_GetEnvironment - add r4, r0, #0 - ldr r0, [r5] - cmp r0, #5 - bhi _02252B3A - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_02252A54: ; jump table - .short _02252A60 - _02252A54 - 2 ; case 0 - .short _02252A80 - _02252A54 - 2 ; case 1 - .short _02252AAC - _02252A54 - 2 ; case 2 - .short _02252AD2 - _02252A54 - 2 ; case 3 - .short _02252AF2 - _02252A54 - 2 ; case 4 - .short _02252B20 - _02252A54 - 2 ; case 5 -_02252A60: - mov r0, #2 - str r0, [sp] - mov r0, #1 - str r0, [sp, #4] - mov r0, #4 - mov r1, #0 - str r0, [sp, #8] - ldr r3, _02252B94 ; =0x00007FFF - mov r0, #3 - add r2, r1, #0 - bl BeginNormalPaletteFade - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252B3A -_02252A80: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _02252B3A - add r0, r4, #0 - bl ov02_02252BA4 - mov r0, #2 - str r0, [sp] - mov r1, #1 - str r1, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - ldr r3, _02252B94 ; =0x00007FFF - mov r0, #3 - mov r2, #0 - bl BeginNormalPaletteFade - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252B3A -_02252AAC: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _02252B3A - mov r2, #0x89 - lsl r2, r2, #2 - mov r1, #1 - strb r1, [r4, r2] - add r0, r2, #3 - mov r3, #0 - sub r2, #0x78 - strb r3, [r4, r0] - add r0, r4, r2 - bl Field3dObject_SetActiveFlag - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252B3A -_02252AD2: - ldr r1, _02252B98 ; =0x00000227 - ldrb r0, [r4, r1] - add r0, r0, #1 - strb r0, [r4, r1] - ldrb r0, [r4, r1] - cmp r0, #0x64 - blo _02252B3A - mov r2, #1 - sub r0, r1, #2 - strb r2, [r4, r0] - mov r0, #0 - strb r0, [r4, r1] - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252B3A -_02252AF2: - ldr r0, _02252B98 ; =0x00000227 - ldrb r1, [r4, r0] - add r1, r1, #1 - strb r1, [r4, r0] - ldrb r0, [r4, r0] - cmp r0, #0x96 - blo _02252B3A - mov r0, #2 - str r0, [sp] - mov r0, #1 - str r0, [sp, #4] - mov r0, #4 - mov r1, #0 - str r0, [sp, #8] - ldr r3, _02252B94 ; =0x00007FFF - mov r0, #3 - add r2, r1, #0 - bl BeginNormalPaletteFade - ldr r0, [r5] - add r0, r0, #1 - str r0, [r5] - b _02252B3A -_02252B20: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _02252B3A - add r0, r4, #0 - bl ov02_02252DF8 - add r0, r4, #0 - bl FreeToHeap - add sp, #0xc - mov r0, #1 - pop {r4, r5, pc} -_02252B3A: - mov r0, #0x89 - lsl r0, r0, #2 - ldrb r0, [r4, r0] - cmp r0, #0 - beq _02252B58 - add r0, r4, #0 - add r0, #0x34 - mov r1, #2 - bl ov02_02252EA8 - add r0, r4, #0 - add r0, #0x5c - mov r1, #2 - bl ov02_02252EA8 -_02252B58: - ldr r0, _02252B9C ; =0x00000225 - ldrb r1, [r4, r0] - cmp r1, #0 - beq _02252B6A - sub r0, #0xa1 - add r0, r4, r0 - mov r1, #2 - bl ov02_02252EA8 -_02252B6A: - ldr r0, _02252BA0 ; =0x00000226 - ldrb r0, [r4, r0] - cmp r0, #0 - beq _02252B8C - add r0, r4, #0 - add r0, #0x84 - bl Field3dObject_Draw - add r0, r4, #0 - add r0, #0xfc - bl Field3dObject_Draw - mov r0, #0x6b - lsl r0, r0, #2 - add r0, r4, r0 - bl Field3dObject_Draw -_02252B8C: - mov r0, #0 - add sp, #0xc - pop {r4, r5, pc} - nop -_02252B94: .word 0x00007FFF -_02252B98: .word 0x00000227 -_02252B9C: .word 0x00000225 -_02252BA0: .word 0x00000226 - thumb_func_end ov02_02252A28 - - thumb_func_start ov02_02252BA4 -ov02_02252BA4: ; 0x02252BA4 + thumb_func_start SinjohCutscene_LoadResources +SinjohCutscene_LoadResources: ; 0x02252BA4 push {r3, r4, r5, r6, r7, lr} sub sp, #0x50 ldr r3, _02252DEC ; =ov02_02253D14 @@ -562,10 +301,10 @@ _02252DB2: _02252DEC: .word ov02_02253D14 _02252DF0: .word ov02_02253CF8 _02252DF4: .word 0x00000226 - thumb_func_end ov02_02252BA4 + thumb_func_end SinjohCutscene_LoadResources - thumb_func_start ov02_02252DF8 -ov02_02252DF8: ; 0x02252DF8 + thumb_func_start SinjohCutscene_FreeResources +SinjohCutscene_FreeResources: ; 0x02252DF8 push {r4, r5, r6, r7, lr} sub sp, #0xc add r5, r0, #0 @@ -633,7 +372,7 @@ _02252E5C: bl Field3dModel_Unload add sp, #0xc pop {r4, r5, r6, r7, pc} - thumb_func_end ov02_02252DF8 + thumb_func_end SinjohCutscene_FreeResources thumb_func_start ov02_02252E80 ov02_02252E80: ; 0x02252E80 diff --git a/asm/unk_0205CB48.s b/asm/unk_0205CB48.s index e12586aac3..7706da8324 100644 --- a/asm/unk_0205CB48.s +++ b/asm/unk_0205CB48.s @@ -397,8 +397,8 @@ _0205CE60: .word SEQ_SE_GS_EDAPAKI _0205CE64: .word _020FCB98 + 2 thumb_func_end sub_0205CD70 - thumb_func_start sub_0205CE68 -sub_0205CE68: ; 0x0205CE68 + thumb_func_start PlayerAvatar_UpdateMovement +PlayerAvatar_UpdateMovement: ; 0x0205CE68 push {r3, r4, r5, r6, r7, lr} add r5, r0, #0 bl sub_0205C6CC @@ -503,7 +503,7 @@ _0205CF38: _0205CF40: pop {r3, r4, r5, r6, r7, pc} .balign 4, 0 - thumb_func_end sub_0205CE68 + thumb_func_end PlayerAvatar_UpdateMovement thumb_func_start sub_0205CF44 sub_0205CF44: ; 0x0205CF44 diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index bba1f50b1d..6ba77f6c0b 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -61,7 +61,7 @@ void sub_0205C6C8(PlayerAvatar *avatar, u32 unkA); u32 sub_0205C6CC(PlayerAvatar *avatar); void sub_0205C6D0(PlayerAvatar *avatar, u32 unkA); u32 sub_0205C6D4(PlayerAvatar *avatar); -void sub_0205C6D8(PlayerAvatar *avatar, LocalMapObject *obj); +void PlayerAvatar_SetMapObject(PlayerAvatar *avatar, LocalMapObject *obj); LocalMapObject *PlayerAvatar_GetMapObject(PlayerAvatar *avatar); LocalMapObject *PlayerAvatar_GetMapObjectConst(PlayerAvatar *avatar); void PlayerAvatar_SetState(PlayerAvatar *avatar, int state); diff --git a/include/field_system.h b/include/field_system.h index 39708d0df8..5b6907dcee 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -198,7 +198,7 @@ void FieldSystem_LaunchApplication(FieldSystem *fieldSystem, const OVY_MGR_TEMPL FieldSystem *FieldSystem_New(OVY_MANAGER *man); void FieldSystem_Delete(OVY_MANAGER *man); BOOL sub_0203E13C(FieldSystem *fieldSystem); -void sub_0203E15C(FieldSystem *fieldSystem); +void FieldSystem_Control(FieldSystem *fieldSystem); void sub_0203E2F4(); void sub_0203E30C(); int sub_0203E324(); diff --git a/include/overlay_02.h b/include/overlay_02.h index 7e074bf4b5..0ae3ca21de 100644 --- a/include/overlay_02.h +++ b/include/overlay_02.h @@ -74,8 +74,7 @@ BOOL ov02_02250780(FieldSystem *fieldSystem, u8 a1); void ov02_022507B4(FieldSystem *fieldSystem, u8 a1); void ov02_022508B4(FieldSystem *fieldSystem); void ov02_022523B4(TaskManager *taskManager); -void FieldSystem_BeginCelebiTimeTravelCutsceneTask(FieldSystem *fieldSystem); -void ov02_022529FC(FieldSystem *fieldSystem); + void ov02_02252EE4(FieldSystem *fieldSystem, u8 a1); BOOL ov02_02253134(SaveData *saveData); int ov02_0225316C(void); diff --git a/include/overlay_2/overlay_02_02251E74.h b/include/overlay_2/overlay_02_02251E74.h index be64a688d2..46e59a5aa3 100644 --- a/include/overlay_2/overlay_02_02251E74.h +++ b/include/overlay_2/overlay_02_02251E74.h @@ -19,6 +19,7 @@ BOOL ov02_02252334(FieldSystem *fieldSystem); void ov02_022523B4(TaskManager *taskMan); BOOL ov02_022523D0(TaskManager *taskMan); void FieldSystem_BeginCelebiTimeTravelCutsceneTask(FieldSystem *fieldSystem); +void FieldSystem_BeginSinjohCutsceneTask(FieldSystem *fieldSystem); // the following is as of yet not decompiled BOOL Task_CelebiTimeTravelCutscene(TaskManager *taskMan); @@ -53,6 +54,23 @@ typedef struct UnkStruct_02253CE0 { u16 unk8; u16 unkA; } UnkStruct_02253CE0; + +typedef struct SinjohCutsceneData { + FieldSystem *fieldSystem; + u8 unk4[0x30]; + Field3DModelAnimation animations[4]; + Field3dObject object84; + Field3dObject objectFC; + u8 unk174[0x10]; + Field3DModelAnimation animation184; + u8 unk194[0x14]; + Field3dObject object1AC; + u8 unk224; + u8 unk225; + u8 unk226; + u8 unk227; +} SinjohCutsceneData; + void CelebiCutscene_StartSwirlTask(CelebiTimeTravelCutsceneTaskData *data); BOOL ov02_022526EC(CelebiTimeTravelCutsceneTaskData *data); void Task_CelebiCutsceneSwirl(SysTask *task, void *data); @@ -62,10 +80,15 @@ void Task_CelebiCutsceneSwirlEffect(SysTask *task, void *data); BOOL CelebiCutscene_IsSwirlFinished(CelebiTimeTravelCutsceneTaskData *data); void CelebiCutscene_LoadResources(CelebiTimeTravelCutsceneTaskData *data); void CelebiCutscene_UnloadResources(CelebiTimeTravelCutsceneTaskData *data); +void CelebiCutsceneAnimations_FrameSet(Field3DModelAnimation *animations, u32 frame); +BOOL CelebiCutsceneAnimations_FrameAdvanceAndCheck(Field3DModelAnimation *animations); +BOOL Task_SinjohCutscene(TaskManager *taskMan); // the following functions are static and not decompiled void ov01_021F46DC(u32 *a0); -void ov02_022529C4(Field3DModelAnimation *animations); -void ov02_022529A0(Field3DModelAnimation *animations, u32 a1); +BOOL Task_SinjohCutscene(TaskManager *taskMan); +void SinjohCutscene_FreeResources(SinjohCutsceneData *data); +void SinjohCutscene_LoadResources(SinjohCutsceneData *data); +void ov02_02252EA8(Field3DModelAnimation *animation, u32 a1); #endif // POKEHEARTGOLD_OVERLAY_02_02251E74_H diff --git a/include/unk_0205CB48.h b/include/unk_0205CB48.h index d77c85410e..cde55631ae 100644 --- a/include/unk_0205CB48.h +++ b/include/unk_0205CB48.h @@ -4,7 +4,7 @@ #include "field_player_avatar.h" void PlayerAvatar_GetCoordsInFront(PlayerAvatar *playerAvatar, int *x, int *z); -void sub_0205CE68(PlayerAvatar *playerAvatar); +void PlayerAvatar_UpdateMovement(PlayerAvatar *playerAvatar); void sub_0205CB48(PlayerAvatar *playerAvatar, FieldSystemUnkSub2C *a1, int a2, u16 a3, u16 a4, int a5); void sub_0205CF44(PlayerAvatar *playerAvatar); BOOL sub_0205CF60(PlayerAvatar *playerAvatar); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 14aae88b85..e9fe36090d 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -162,7 +162,7 @@ PlayerAvatar *sub_0205C408(MapObjectManager *man, PlayerSaveData *playerSaveData MapObject_SetFlagsBits(mapObj, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK13 | MAPOBJECTFLAG_UNK10)); MapObject_ClearFlagsBits(mapObj, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK8 | MAPOBJECTFLAG_UNK7)); MapObject_SetFlag29(mapObj, TRUE); - sub_0205C6D8(avatar, mapObj); + PlayerAvatar_SetMapObject(avatar, mapObj); return avatar; } @@ -230,7 +230,7 @@ void CreatePlayerAvatarMapObject(PlayerAvatar *avatar, MapObjectManager *man, u3 MapObject_SetFlagsBits(mapObj, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK13 | MAPOBJECTFLAG_UNK10)); MapObject_ClearFlagsBits(mapObj, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK8 | MAPOBJECTFLAG_UNK7)); MapObject_SetFlag29(mapObj, TRUE); - sub_0205C6D8(avatar, mapObj); + PlayerAvatar_SetMapObject(avatar, mapObj); } LocalMapObject *sub_0205C600(MapObjectManager *man) { @@ -304,7 +304,7 @@ u32 sub_0205C6D4(PlayerAvatar *avatar) { return avatar->unk14; } -void sub_0205C6D8(PlayerAvatar *avatar, LocalMapObject *obj) { +void PlayerAvatar_SetMapObject(PlayerAvatar *avatar, LocalMapObject *obj) { avatar->mapObject = obj; } diff --git a/src/field_system.c b/src/field_system.c index 20b76bca9a..a9c270ed45 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -177,7 +177,7 @@ static void ppOverlayManager_RunFrame_DeleteIfFinished(OVY_MANAGER **man) { } static BOOL FieldSystem_Main(FieldSystem *fieldSystem) { - sub_0203E15C(fieldSystem); + FieldSystem_Control(fieldSystem); if (FieldSystem_RunTaskFrame(fieldSystem) == TRUE) { if (fieldSystem->unk4) { ov01_021F6830(fieldSystem, 0, 0); @@ -198,19 +198,16 @@ static BOOL FieldSystem_Main(FieldSystem *fieldSystem) { } BOOL sub_0203E13C(FieldSystem *fieldSystem) { - if (!fieldSystem->unk0->unk8 && fieldSystem->unk6C && !FieldSystem_TaskIsRunning(fieldSystem)) { - return TRUE; - } - return FALSE; + return !fieldSystem->unk0->unk8 && fieldSystem->unk6C && !FieldSystem_TaskIsRunning(fieldSystem); } -void sub_0203E15C(FieldSystem *fieldSystem) { +void FieldSystem_Control(FieldSystem *fieldSystem) { Unk_0203E15C unkStruct; BOOL flag = sub_0203E13C(fieldSystem); if (flag) { - sub_0205CE68(fieldSystem->playerAvatar); + PlayerAvatar_UpdateMovement(fieldSystem->playerAvatar); ov01_021E6928(&unkStruct, fieldSystem, gSystem.newKeys, gSystem.heldKeys); } diff --git a/src/overlay_02_02251E74.c b/src/overlay_02_02251E74.c index 93c59489db..11b8ca3e0f 100644 --- a/src/overlay_02_02251E74.c +++ b/src/overlay_02_02251E74.c @@ -651,7 +651,7 @@ BOOL Task_CelebiTimeTravelCutscene(TaskManager *taskMan) { } } if (data->unkF0) { - ov02_022529C4(&data->animations[0]); + CelebiCutsceneAnimations_FrameAdvanceAndCheck(&data->animations[0]); } if (data->unkF1) { Field3dObject_Draw(&data->object3d); @@ -751,7 +751,7 @@ void CelebiCutscene_LoadResources(CelebiTimeTravelCutsceneTaskData *data) { Field3dObject_AddAnimation(&data->object3d, &data->animations[i]); } Field3dObject_SetActiveFlag(&data->object3d, 1); - ov02_022529A0(&data->animations[0], 0); + CelebiCutsceneAnimations_FrameSet(&data->animations[0], 0); LocalMapObject *followMonObj = FollowMon_GetMapObject(data->fieldSystem); VecFx32 pos; MapObject_GetPositionVec(followMonObj, &pos); @@ -765,3 +765,88 @@ void CelebiCutscene_UnloadResources(CelebiTimeTravelCutsceneTaskData *data) { } Field3dModel_Unload(&data->model); } + +void CelebiCutsceneAnimations_FrameSet(Field3DModelAnimation *animations, u32 frame) { + for (u8 i = 0; i < 3; i++) { + Field3dModelAnimation_FrameSet(&animations[i], frame); + } +} + +BOOL CelebiCutsceneAnimations_FrameAdvanceAndCheck(Field3DModelAnimation *animations) { + u8 i; + u8 cnt = 0; + for (i = 0; i < 3; i++) { + if (Field3dModelAnimation_FrameAdvanceAndCheck(&animations[i], 0x1000) != 0) { + cnt++; + } + } + + return cnt == 3; +} + +void FieldSystem_BeginSinjohCutsceneTask(FieldSystem *fieldSystem) { + SinjohCutsceneData *data = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(SinjohCutsceneData)); + MI_CpuFill8(data, 0, sizeof(SinjohCutsceneData)); + data->fieldSystem = fieldSystem; + TaskManager_Call(fieldSystem->taskman, Task_SinjohCutscene, data); +} + +BOOL Task_SinjohCutscene(TaskManager *taskMan) { + int *state = TaskManager_GetStatePtr(taskMan); + FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskMan); + SinjohCutsceneData *data = TaskManager_GetEnvironment(taskMan); + switch (*state) { + case 0: + BeginNormalPaletteFade(3, 0, 0, RGB_WHITE, 2, 1, HEAP_ID_4); + (*state)++; + break; + case 1: + if (IsPaletteFadeFinished()) { + SinjohCutscene_LoadResources(data); + BeginNormalPaletteFade(3, 1, 0, RGB_WHITE, 2, 1, HEAP_ID_4); + (*state)++; + } + break; + case 2: + if (IsPaletteFadeFinished()) { + data->unk224 = 1; + data->unk227 = 0; + Field3dObject_SetActiveFlag(&data->object1AC, 1); + (*state)++; + } + break; + case 3: + if (++data->unk227 >= 100) { + data->unk225 = 1; + data->unk227 = 0; + (*state)++; + } + break; + case 4: + if (++data->unk227 >= 150) { + BeginNormalPaletteFade(3, 0, 0, RGB_WHITE, 2, 1, HEAP_ID_4); + (*state)++; + } + break; + case 5: + if (IsPaletteFadeFinished()) { + SinjohCutscene_FreeResources(data); + FreeToHeap(data); + return TRUE; + } + break; + } + if (data->unk224) { + ov02_02252EA8(&data->animations[0], 2); + ov02_02252EA8(&data->animations[2], 2); + } + if (data->unk225) { + ov02_02252EA8(&data->animation184, 2); + } + if (data->unk226) { + Field3dObject_Draw(&data->object84); + Field3dObject_Draw(&data->objectFC); + Field3dObject_Draw(&data->object1AC); + } + return FALSE; +} diff --git a/src/scrcmd_c.c b/src/scrcmd_c.c index f7b934a141..13abe7bfbf 100644 --- a/src/scrcmd_c.c +++ b/src/scrcmd_c.c @@ -5333,7 +5333,7 @@ BOOL ScrCmd_814(ScriptContext *ctx) { } BOOL ScrCmd_UnownCircle(ScriptContext *ctx) { - ov02_022529FC(ctx->fieldSystem); + FieldSystem_BeginSinjohCutsceneTask(ctx->fieldSystem); return TRUE; } From 07b9c4fd016172428775ee3057d1484dcaffa0ac Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 14 Nov 2024 04:51:28 -0500 Subject: [PATCH 7/7] Document Field_Control as per request in discord --- asm/include/overlay_01_021E6880.inc | 10 ++--- asm/include/overlay_27.inc | 2 +- asm/include/overlay_28.inc | 2 +- asm/include/unk_0205CB48.inc | 2 +- asm/overlay_01_021E6880.s | 30 +++++++------- asm/overlay_27.s | 6 +-- asm/overlay_28.s | 4 +- asm/unk_0205CB48.s | 6 +-- include/field_system.h | 8 ++-- include/overlay_01_021E6880.h | 10 ++--- include/unk_0205CB48.h | 2 +- src/field_system.c | 62 ++++++++++++++--------------- 12 files changed, 72 insertions(+), 72 deletions(-) diff --git a/asm/include/overlay_01_021E6880.inc b/asm/include/overlay_01_021E6880.inc index e43eb05a88..4c6acb1419 100644 --- a/asm/include/overlay_01_021E6880.inc +++ b/asm/include/overlay_01_021E6880.inc @@ -158,11 +158,11 @@ .public ov01_021E5924 .public ov01_021E5BE4 .public ov01_021E5C24 -.public ov01_021E6928 -.public ov01_021E6AF4 -.public ov01_021E6E00 -.public ov01_021E6EFC -.public ov01_021E6FD4 +.public FieldInput_Update +.public FieldInput_Process +.public FieldInput_Process_Colosseum +.public FieldInput_Process_UnionRoom +.public FieldInput_Process_BattleTower .public ov01_021E7F00 .public ov01_021E7F54 .public FieldSystem_FacingModelIsHeadbuttTree diff --git a/asm/include/overlay_27.inc b/asm/include/overlay_27.inc index 23ce894156..f4800f8b4a 100644 --- a/asm/include/overlay_27.inc +++ b/asm/include/overlay_27.inc @@ -96,7 +96,7 @@ .public FieldSystem_ShouldDrawStartMenuIcon .public FieldSystem_GetFacingObject .public sub_0203DF8C -.public sub_0203E13C +.public FieldSystem_IsPlayerMovementAllowed .public MapSceneScriptCheck .public Save_VarsFlags_Get .public FieldSystem_TaskIsRunning diff --git a/asm/include/overlay_28.inc b/asm/include/overlay_28.inc index d3581354ac..3e786d31f4 100644 --- a/asm/include/overlay_28.inc +++ b/asm/include/overlay_28.inc @@ -68,7 +68,7 @@ .public String_Delete .public FieldSystem_GetFacingObject .public sub_0203DF8C -.public sub_0203E13C +.public FieldSystem_IsPlayerMovementAllowed .public AllocAndFetchNearbyHiddenItems .public FieldSystem_TaskIsRunning .public PlayerAvatar_GetMapObject diff --git a/asm/include/unk_0205CB48.inc b/asm/include/unk_0205CB48.inc index 0513a4bf31..eb141560ba 100644 --- a/asm/include/unk_0205CB48.inc +++ b/asm/include/unk_0205CB48.inc @@ -61,7 +61,7 @@ .public sub_0205CB00 .public sub_0205CB14 .public sub_0205CB2C -.public sub_0205CB48 +.public PlayerAvatar_MoveControl .public sub_0205CBE4 .public PlayerAvatar_UpdateMovement .public sub_0205CF44 diff --git a/asm/overlay_01_021E6880.s b/asm/overlay_01_021E6880.s index eeb27b1c68..064aa1cc7d 100644 --- a/asm/overlay_01_021E6880.s +++ b/asm/overlay_01_021E6880.s @@ -105,8 +105,8 @@ ov01_021E6920: ; 0x021E6920 _021E6924: .word ov01_021F6B64 thumb_func_end ov01_021E6920 - thumb_func_start ov01_021E6928 -ov01_021E6928: ; 0x021E6928 + thumb_func_start FieldInput_Update +FieldInput_Update: ; 0x021E6928 push {r3, r4, r5, r6, r7, lr} sub sp, #0x10 add r4, r1, #0 @@ -347,10 +347,10 @@ _021E6AE4: strb r0, [r5, #4] add sp, #0x10 pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov01_021E6928 + thumb_func_end FieldInput_Update - thumb_func_start ov01_021E6AF4 -ov01_021E6AF4: ; 0x021E6AF4 + thumb_func_start FieldInput_Process +FieldInput_Process: ; 0x021E6AF4 push {r3, r4, r5, r6, r7, lr} add r5, r0, #0 ldrh r0, [r5] @@ -680,7 +680,7 @@ _021E6DB6: nop _021E6DBC: .word 0x0000FFFF _021E6DC0: .word SEQ_SE_DP_WIN_OPEN - thumb_func_end ov01_021E6AF4 + thumb_func_end FieldInput_Process thumb_func_start ov01_021E6DC4 ov01_021E6DC4: ; 0x021E6DC4 @@ -712,8 +712,8 @@ _021E6DF6: _021E6DFC: .word 0x0000FFFF thumb_func_end ov01_021E6DC4 - thumb_func_start ov01_021E6E00 -ov01_021E6E00: ; 0x021E6E00 + thumb_func_start FieldInput_Process_Colosseum +FieldInput_Process_Colosseum: ; 0x021E6E00 push {r3, r4, r5, lr} add r4, r0, #0 ldrh r0, [r4] @@ -810,7 +810,7 @@ _021E6ECA: nop _021E6ED0: .word std_colosseum_exit _021E6ED4: .word SEQ_SE_DP_WIN_OPEN - thumb_func_end ov01_021E6E00 + thumb_func_end FieldInput_Process_Colosseum thumb_func_start ov01_021E6ED8 ov01_021E6ED8: ; 0x021E6ED8 @@ -836,8 +836,8 @@ _021E6EF8: pop {r3, r4, r5, pc} thumb_func_end ov01_021E6ED8 - thumb_func_start ov01_021E6EFC -ov01_021E6EFC: ; 0x021E6EFC + thumb_func_start FieldInput_Process_UnionRoom +FieldInput_Process_UnionRoom: ; 0x021E6EFC push {r3, r4, r5, lr} add r4, r0, #0 add r5, r1, #0 @@ -932,10 +932,10 @@ _021E6FCC: pop {r3, r4, r5, pc} .balign 4, 0 _021E6FD0: .word SEQ_SE_DP_WIN_OPEN - thumb_func_end ov01_021E6EFC + thumb_func_end FieldInput_Process_UnionRoom - thumb_func_start ov01_021E6FD4 -ov01_021E6FD4: ; 0x021E6FD4 + thumb_func_start FieldInput_Process_BattleTower +FieldInput_Process_BattleTower: ; 0x021E6FD4 push {r3, r4, r5, r6, lr} sub sp, #4 add r5, r0, #0 @@ -1084,7 +1084,7 @@ _021E7106: .balign 4, 0 _021E710C: .word 0x0000FFFF _021E7110: .word SEQ_SE_DP_WIN_OPEN - thumb_func_end ov01_021E6FD4 + thumb_func_end FieldInput_Process_BattleTower thumb_func_start ov01_021E7114 ov01_021E7114: ; 0x021E7114 diff --git a/asm/overlay_27.s b/asm/overlay_27.s index f76698c2c1..c70e474c63 100644 --- a/asm/overlay_27.s +++ b/asm/overlay_27.s @@ -425,7 +425,7 @@ ov27_0225A320: ; 0x0225A320 bl ov27_0225A89C add r4, r0, #0 ldr r0, [r5, #0x10] - bl sub_0203E13C + bl FieldSystem_IsPlayerMovementAllowed add r6, r0, #0 ldr r0, [r5, #0x10] add r0, #0xd2 @@ -745,7 +745,7 @@ ov27_0225A594: ; 0x0225A594 pop {r3, r4, r5, r6, r7, pc} _0225A5A8: add r0, r4, #0 - bl sub_0203E13C + bl FieldSystem_IsPlayerMovementAllowed cmp r0, #0 bne _0225A5E6 add r0, r4, #0 @@ -1145,7 +1145,7 @@ ov27_0225A89C: ; 0x0225A89C lsr r0, r0, #0x1a bne _0225A8E0 add r0, r4, #0 - bl sub_0203E13C + bl FieldSystem_IsPlayerMovementAllowed cmp r0, #0 beq _0225A8E0 add r0, r4, #0 diff --git a/asm/overlay_28.s b/asm/overlay_28.s index 8dc8ac77c3..c27963c58c 100644 --- a/asm/overlay_28.s +++ b/asm/overlay_28.s @@ -894,7 +894,7 @@ ov28_0225DC2C: ; 0x0225DC2C lsl r1, r1, #0x18 lsr r1, r1, #0x1f beq _0225DC56 - bl sub_0203E13C + bl FieldSystem_IsPlayerMovementAllowed cmp r0, #0 beq _0225DC56 ldr r2, [r4, #0x18] @@ -2465,7 +2465,7 @@ ov28_0225E810: ; 0x0225E810 mov r4, #4 b _0225E890 _0225E828: - bl sub_0203E13C + bl FieldSystem_IsPlayerMovementAllowed cmp r0, #0 ldr r0, [r5, #0x18] bne _0225E860 diff --git a/asm/unk_0205CB48.s b/asm/unk_0205CB48.s index 7706da8324..ccbf78a267 100644 --- a/asm/unk_0205CB48.s +++ b/asm/unk_0205CB48.s @@ -14,8 +14,8 @@ .text - thumb_func_start sub_0205CB48 -sub_0205CB48: ; 0x0205CB48 + thumb_func_start PlayerAvatar_MoveControl +PlayerAvatar_MoveControl: ; 0x0205CB48 push {r3, r4, r5, r6, r7, lr} add r7, r1, #0 mov r1, #0 @@ -86,7 +86,7 @@ _0205CBC4: bl sub_0205CC94 _0205CBE2: pop {r3, r4, r5, r6, r7, pc} - thumb_func_end sub_0205CB48 + thumb_func_end PlayerAvatar_MoveControl thumb_func_start sub_0205CBE4 sub_0205CBE4: ; 0x0205CBE4 diff --git a/include/field_system.h b/include/field_system.h index 5b6907dcee..3bdc138dfd 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -76,7 +76,7 @@ typedef struct FieldSystemUnk108 { struct FieldSystemUnkSub0 { OVY_MANAGER *unk0; OVY_MANAGER *unk4; - BOOL unk8; + BOOL isPaused; BOOL unkC; }; @@ -176,12 +176,12 @@ struct FieldSystem { u32 judgeStatPosition; }; // size: 0x128 -typedef struct Unk_0203E15C { +typedef struct FieldInput { u8 unk0[6]; u16 unk6; u16 unk8; u16 unkA; -} Unk_0203E15C; +} FieldInput; BOOL Field_Continue_AppInit(OVY_MANAGER *man, int *unused); BOOL Field_NewGame_AppInit(OVY_MANAGER *man, int *unused); @@ -197,7 +197,7 @@ BOOL sub_0203DFA4(FieldSystem *fieldSystem); void FieldSystem_LaunchApplication(FieldSystem *fieldSystem, const OVY_MGR_TEMPLATE *template, void *parentWork); FieldSystem *FieldSystem_New(OVY_MANAGER *man); void FieldSystem_Delete(OVY_MANAGER *man); -BOOL sub_0203E13C(FieldSystem *fieldSystem); +BOOL FieldSystem_IsPlayerMovementAllowed(FieldSystem *fieldSystem); void FieldSystem_Control(FieldSystem *fieldSystem); void sub_0203E2F4(); void sub_0203E30C(); diff --git a/include/overlay_01_021E6880.h b/include/overlay_01_021E6880.h index 4100e01fb5..388e7d5c9e 100644 --- a/include/overlay_01_021E6880.h +++ b/include/overlay_01_021E6880.h @@ -3,11 +3,11 @@ #include "field_system.h" -void ov01_021E6928(Unk_0203E15C *a0, FieldSystem *fieldSystem, u16 newKeys, u16 heldKeys); -int ov01_021E6AF4(Unk_0203E15C *a0, FieldSystem *fieldSystem); -BOOL ov01_021E6E00(Unk_0203E15C *a0, FieldSystem *fieldSystem); -BOOL ov01_021E6EFC(Unk_0203E15C *a0, FieldSystem *fieldSystem); -BOOL ov01_021E6FD4(Unk_0203E15C *a0, FieldSystem *fieldSystem); +void FieldInput_Update(FieldInput *a0, FieldSystem *fieldSystem, u16 newKeys, u16 heldKeys); +int FieldInput_Process(FieldInput *a0, FieldSystem *fieldSystem); +BOOL FieldInput_Process_Colosseum(FieldInput *a0, FieldSystem *fieldSystem); +BOOL FieldInput_Process_UnionRoom(FieldInput *a0, FieldSystem *fieldSystem); +BOOL FieldInput_Process_BattleTower(FieldInput *a0, FieldSystem *fieldSystem); void ov01_021E7F00(FieldSystem *fieldSystem, BOOL a1); #endif diff --git a/include/unk_0205CB48.h b/include/unk_0205CB48.h index cde55631ae..6a08670c67 100644 --- a/include/unk_0205CB48.h +++ b/include/unk_0205CB48.h @@ -5,7 +5,7 @@ void PlayerAvatar_GetCoordsInFront(PlayerAvatar *playerAvatar, int *x, int *z); void PlayerAvatar_UpdateMovement(PlayerAvatar *playerAvatar); -void sub_0205CB48(PlayerAvatar *playerAvatar, FieldSystemUnkSub2C *a1, int a2, u16 a3, u16 a4, int a5); +void PlayerAvatar_MoveControl(PlayerAvatar *playerAvatar, FieldSystemUnkSub2C *a1, int a2, u16 a3, u16 a4, int a5); void sub_0205CF44(PlayerAvatar *playerAvatar); BOOL sub_0205CF60(PlayerAvatar *playerAvatar); void sub_0205CFBC(PlayerAvatar *playerAvatar, int direction); diff --git a/src/field_system.c b/src/field_system.c index a9c270ed45..146558e78f 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -94,7 +94,7 @@ void sub_0203DEF0(FieldSystem *fieldSystem) { HandleLoadOverlay(FS_OVERLAY_ID(field), OVY_LOAD_ASYNC); fieldSystem->unk6C = FALSE; - fieldSystem->unk0->unk8 = FALSE; + fieldSystem->unk0->isPaused = FALSE; fieldSystem->unk0->unk0 = OverlayManager_New(&ov01_02206378, fieldSystem, HEAP_ID_FIELD); } @@ -143,7 +143,7 @@ FieldSystem *FieldSystem_New(OVY_MANAGER *man) { fieldSystem->unk0->unk0 = NULL; fieldSystem->unk0->unk4 = NULL; - fieldSystem->unk0->unk8 = FALSE; + fieldSystem->unk0->isPaused = FALSE; fieldSystem->unk0->unkC = FALSE; HandleLoadOverlay(FS_OVERLAY_ID(OVY_124), OVY_LOAD_ASYNC); @@ -197,47 +197,47 @@ static BOOL FieldSystem_Main(FieldSystem *fieldSystem) { return FALSE; } -BOOL sub_0203E13C(FieldSystem *fieldSystem) { - return !fieldSystem->unk0->unk8 && fieldSystem->unk6C && !FieldSystem_TaskIsRunning(fieldSystem); +BOOL FieldSystem_IsPlayerMovementAllowed(FieldSystem *fieldSystem) { + return !fieldSystem->unk0->isPaused && fieldSystem->unk6C && !FieldSystem_TaskIsRunning(fieldSystem); } void FieldSystem_Control(FieldSystem *fieldSystem) { - Unk_0203E15C unkStruct; + FieldInput fieldInput; - BOOL flag = sub_0203E13C(fieldSystem); + BOOL movementAllowed = FieldSystem_IsPlayerMovementAllowed(fieldSystem); - if (flag) { + if (movementAllowed) { PlayerAvatar_UpdateMovement(fieldSystem->playerAvatar); - ov01_021E6928(&unkStruct, fieldSystem, gSystem.newKeys, gSystem.heldKeys); + FieldInput_Update(&fieldInput, fieldSystem, gSystem.newKeys, gSystem.heldKeys); } - int unkVar = fieldSystem->unk70; + int loadType = fieldSystem->unk70; if (fieldSystem->location->mapId == MAP_D31R0201) { - unkVar = 0; + loadType = 0; } - switch (unkVar) { + switch (loadType) { case 3: - if (flag) { + if (movementAllowed) { if (sub_02057A0C()) { - if (ov01_021E6E00(&unkStruct, fieldSystem) == TRUE) { - flag = FALSE; + if (FieldInput_Process_Colosseum(&fieldInput, fieldSystem) == TRUE) { + movementAllowed = FALSE; } } else { - flag = FALSE; + movementAllowed = FALSE; } } - sub_020573F0(fieldSystem, flag); + sub_020573F0(fieldSystem, movementAllowed); break; case 2: - if (flag && ov01_021E6EFC(&unkStruct, fieldSystem) != TRUE) { - sub_0205CB48(fieldSystem->playerAvatar, fieldSystem->unk2C, -1, unkStruct.unk6, unkStruct.unk8, 0); + if (movementAllowed && FieldInput_Process_UnionRoom(&fieldInput, fieldSystem) != TRUE) { + PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk2C, -1, fieldInput.unk6, fieldInput.unk8, 0); } break; case 4: - if (flag) { - if (ov01_021E6FD4(&unkStruct, fieldSystem) == TRUE) { + if (movementAllowed) { + if (FieldInput_Process_BattleTower(&fieldInput, fieldSystem) == TRUE) { ov01_021EFACC(fieldSystem->unk4->unk8); ov01_021F3DFC(fieldSystem, 4); ov01_021F2F24(fieldSystem->playerAvatar); @@ -247,34 +247,34 @@ void FieldSystem_Control(FieldSystem *fieldSystem) { if (gSystem.newKeys & PAD_BUTTON_A) { ov01_021EFACC(fieldSystem->unk4->unk8); } - flag = 0; + movementAllowed = 0; if (sub_0203E324()) { - flag = ov35_02259DB8(); + movementAllowed = ov35_02259DB8(); } - sub_0205CB48(fieldSystem->playerAvatar, fieldSystem->unk2C, -1, unkStruct.unk6, unkStruct.unk8, flag); + PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk2C, -1, fieldInput.unk6, fieldInput.unk8, movementAllowed); } break; default: - if (flag) { - flag = ov01_021E6AF4(&unkStruct, fieldSystem); - if (flag) { + if (movementAllowed) { + u32 newEvent = FieldInput_Process(&fieldInput, fieldSystem); + if (newEvent) { ov01_021EFACC(fieldSystem->unk4->unk8); ov01_021F3DFC(fieldSystem, 4); sub_0205CF44(fieldSystem->playerAvatar); ov01_021F2F24(fieldSystem->playerAvatar); ov01_021F6830(fieldSystem, 0, 1); - if (flag != 2) { + if (newEvent != 2) { sub_02092FA8(fieldSystem->phoneRingManager); } } else { if (gSystem.newKeys & PAD_BUTTON_A) { ov01_021EFACC(fieldSystem->unk4->unk8); } - flag = 0; + u32 flag = 0; if (sub_0203E324()) { flag = ov35_02259DB8(); } - sub_0205CB48(fieldSystem->playerAvatar, fieldSystem->unk2C, -1, unkStruct.unk6, unkStruct.unk8, flag); + PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk2C, -1, fieldInput.unk6, fieldInput.unk8, flag); } } break; @@ -282,12 +282,12 @@ void FieldSystem_Control(FieldSystem *fieldSystem) { } void sub_0203E2F4() { - sFieldSysPtr->unk0->unk8 = TRUE; + sFieldSysPtr->unk0->isPaused = TRUE; sub_02037504(); } void sub_0203E30C() { - sFieldSysPtr->unk0->unk8 = FALSE; + sFieldSysPtr->unk0->isPaused = FALSE; sub_020374E4(); }