Decompile overlay 36

This commit is contained in:
tgsm 2022-03-13 04:46:40 -05:00
parent a6e8360f97
commit 77452b5683
3 changed files with 251 additions and 377 deletions

View File

@ -1,376 +0,0 @@
.include "asm/macros.inc"
.include "global.inc"
.text
thumb_func_start ov36_021E5900
ov36_021E5900: ; 0x021E5900
push {r3, lr}
mov r2, #2
mov r0, #3
mov r1, #0x4b
lsl r2, r2, #0x10
bl CreateHeap
bl InitializeMainRNG
mov r0, #1
pop {r3, pc}
.balign 4, 0
thumb_func_end ov36_021E5900
thumb_func_start ov36_021E5918
ov36_021E5918: ; 0x021E5918
push {r3, lr}
bl OverlayManager_GetParentWork
ldr r1, [r0, #8]
mov r0, #0x4b
bl ov36_021E5BC8
mov r0, #1
pop {r3, pc}
.balign 4, 0
thumb_func_end ov36_021E5918
.public _02106068
thumb_func_start ov36_TitleScreen_SwitchToNewGame
ov36_TitleScreen_SwitchToNewGame: ; 0x021E592C
push {r3, lr}
mov r0, #0x4b
bl DestroyHeap
mov r0, #0
ldr r1, _021E5944 ; =_02106068
mvn r0, r0
bl RegisterMainOverlay
mov r0, #1
pop {r3, pc}
nop
_021E5944: .word _02106068
thumb_func_end ov36_TitleScreen_SwitchToNewGame
thumb_func_start ov36_021E5948
ov36_021E5948: ; 0x021E5948
push {r3, lr}
mov r2, #2
mov r0, #3
mov r1, #0x4b
lsl r2, r2, #0x10
bl CreateHeap
bl InitializeMainRNG
mov r0, #1
pop {r3, pc}
.balign 4, 0
thumb_func_end ov36_021E5948
thumb_func_start ov36_021E5960
ov36_021E5960: ; 0x021E5960
push {r4, lr}
bl OverlayManager_GetParentWork
ldr r4, [r0, #8]
mov r0, #0x4b
add r1, r4, #0
mov r2, #1
bl ov36_021E5A38
add r0, r4, #0
bl Sav2_PlayerData_GetIGTAddr
bl sub_0201838C
mov r0, #1
pop {r4, pc}
thumb_func_end ov36_021E5960
.public _020FA15C
thumb_func_start ov36_021E5980
ov36_021E5980: ; 0x021E5980
push {r3, lr}
mov r0, #0x4b
bl DestroyHeap
mov r0, #0
ldr r1, _021E5998 ; =_020FA15C
mvn r0, r0
bl RegisterMainOverlay
mov r0, #1
pop {r3, pc}
nop
_021E5998: .word _020FA15C
thumb_func_end ov36_021E5980
thumb_func_start ov36_021E599C
ov36_021E599C: ; 0x021E599C
push {r3, lr}
mov r2, #2
mov r0, #3
mov r1, #0x4b
lsl r2, r2, #0x10
bl CreateHeap
bl InitializeMainRNG
mov r0, #1
pop {r3, pc}
.balign 4, 0
thumb_func_end ov36_021E599C
thumb_func_start ov36_021E59B4
ov36_021E59B4: ; 0x021E59B4
push {r3, r4, r5, lr}
bl OverlayManager_GetParentWork
ldr r4, [r0, #8]
add r0, r4, #0
bl Sav2_SysInfo_get
add r5, r0, #0
mov r0, #0x4b
add r1, r4, #0
bl ov36_021E5BB4
add r0, r4, #0
mov r1, #0
bl Options_SetButtonModeOnMain
add r0, r5, #0
bl Sav2_SysInfo_MacAddressIsMine
cmp r0, #0
beq _021E59E8
add r0, r5, #0
bl Sav2_SysInfo_RTCOffsetIsMine
cmp r0, #0
bne _021E5A0C
_021E59E8:
add r0, r4, #0
bl Sav2_SysInfo_RTC_get
bl sub_02028E4C
add r0, r4, #0
bl Sav2_BerryPotRTC_get
bl Sav2_BerryPotRTC_init
add r0, r5, #0
bl Sav2_SysInfo_InitFromSystem
add r0, r4, #0
bl SavArray_PlayerParty_get
bl Party_ResetAllShayminToLandForme
_021E5A0C:
add r0, r4, #0
bl Sav2_PlayerData_GetIGTAddr
bl sub_0201838C
mov r0, #1
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end ov36_021E59B4
.public _020FA16C
thumb_func_start ov36_021E5A1C
ov36_021E5A1C: ; 0x021E5A1C
push {r3, lr}
mov r0, #0x4b
bl DestroyHeap
mov r0, #0
ldr r1, _021E5A34 ; =_020FA16C
mvn r0, r0
bl RegisterMainOverlay
mov r0, #1
pop {r3, pc}
nop
_021E5A34: .word _020FA16C
thumb_func_end ov36_021E5A1C
thumb_func_start ov36_021E5A38
ov36_021E5A38: ; 0x021E5A38
push {r3, r4, r5, r6, r7, lr}
sub sp, #0x28
add r6, r1, #0
add r0, r6, #0
add r5, r2, #0
bl Sav2_SysInfo_get
bl Sav2_SysInfo_InitFromSystem
add r0, r6, #0
bl Sav2_SysInfo_RTC_get
bl Sav2_SysInfo_RTC_init
add r0, r6, #0
bl Sav2_BerryPotRTC_get
bl Sav2_BerryPotRTC_init
add r0, r6, #0
bl sub_0202C854
add r4, r0, #0
bl MTRandom
add r2, r0, #0
add r0, r4, #0
mov r1, #1
bl sub_0202C7C0
add r0, r6, #0
bl sub_020674BC
add r0, r6, #0
bl Sav2_PlayerData_GetProfileAddr
add r7, r0, #0
bl MTRandom
add r4, r0, #0
cmp r5, #0
beq _021E5A94
add r0, r7, #0
add r1, r4, #0
bl PlayerProfile_SetTrainerID
_021E5A94:
add r0, r6, #0
bl Save_SafariZone_get
add r1, r4, #0
bl SafariZone_ResetAreaSetToDefaultSet
add r0, r7, #0
bl PlayerProfile_GetTrainerGender
add r1, r0, #0
add r0, r4, #0
mov r2, #0
bl sub_0205B418
add r1, r0, #0
lsl r1, r1, #0x18
add r0, r7, #0
lsr r1, r1, #0x18
bl PlayerProfile_SetAvatar
add r0, r6, #0
bl Sav2_FieldApricornTrees_get
bl sub_0202AE0C
add r0, r6, #0
bl Sav2_Pokewalker_get
bl sub_02032728
add r5, r0, #0
mov r4, #0
_021E5AD4:
bl MTRandom
add r4, r4, #1
stmia r5!, {r0}
cmp r4, #0xa
blt _021E5AD4
ldr r2, _021E5BAC ; =0x000001BD
mov r0, #1
mov r1, #0x1b
mov r3, #3
bl NewMsgDataFromNarc
str r0, [sp, #0x1c]
add r0, r6, #0
bl Sav2_Mailbox_get
str r0, [sp, #0x14]
mov r0, #3
bl AllocMonZeroed
mov r3, #0
str r3, [sp]
str r3, [sp, #4]
str r3, [sp, #8]
mov r1, #0xb7
mov r2, #1
str r0, [sp, #0x10]
str r3, [sp, #0xc]
bl CreateMon
add r0, r7, #0
bl PlayerProfile_GetTrainerGender
cmp r0, #0
bne _021E5B36
ldr r0, [sp, #0x1c]
mov r1, #1
bl NewString_ReadMsgData
str r0, [sp, #0x18]
mov r0, #0
str r0, [sp]
ldr r0, [sp, #0x10]
ldr r3, [sp, #0x18]
mov r1, #9
mov r2, #1
bl CreateKenyaMail
b _021E5B4E
_021E5B36:
ldr r0, [sp, #0x1c]
mov r1, #0
bl NewString_ReadMsgData
str r0, [sp, #0x18]
mov r2, #0
ldr r0, [sp, #0x10]
ldr r3, [sp, #0x18]
mov r1, #9
str r2, [sp]
bl CreateKenyaMail
_021E5B4E:
ldr r4, _021E5BB0 ; =ov36_021E5C34
add r6, r0, #0
mov r5, #0
add r7, sp, #0x20
_021E5B56:
add r0, r7, #0
add r1, r4, #0
bl MailMsg_init_fromTemplate
lsl r2, r5, #0x18
add r0, r6, #0
add r1, r7, #0
lsr r2, r2, #0x18
bl Mail_CopyToUnk20Array
add r5, r5, #1
add r4, #8
cmp r5, #2
blt _021E5B56
add r0, sp, #0x20
bl MailMsg_init
add r0, r6, #0
add r1, sp, #0x20
mov r2, #2
bl Mail_CopyToUnk20Array
mov r1, #0
ldr r0, [sp, #0x14]
add r2, r1, #0
add r3, r6, #0
bl Mailbox_CopyMailToSlotI
ldr r0, [sp, #0x10]
bl FreeToHeap
ldr r0, [sp, #0x18]
bl String_dtor
add r0, r6, #0
bl FreeToHeap
ldr r0, [sp, #0x1c]
bl DestroyMsgData
add sp, #0x28
pop {r3, r4, r5, r6, r7, pc}
nop
_021E5BAC: .word 0x000001BD
_021E5BB0: .word ov36_021E5C34
thumb_func_end ov36_021E5A38
thumb_func_start ov36_021E5BB4
ov36_021E5BB4: ; 0x021E5BB4
push {r3, lr}
add r0, r1, #0
bl sub_020273B0
cmp r0, #0
bne _021E5BC6
mov r0, #0
bl OS_ResetSystem
_021E5BC6:
pop {r3, pc}
thumb_func_end ov36_021E5BB4
thumb_func_start ov36_021E5BC8
ov36_021E5BC8: ; 0x021E5BC8
push {r4, lr}
add r4, r1, #0
add r0, r4, #0
bl Sav2_InitDynamicRegion
add r0, r4, #0
bl Save_CurrentLocation_BackUp
add r0, r4, #0
bl Sav2_PlayerData_GetProfileAddr
ldr r1, _021E5BFC ; =3000
bl PlayerProfile_SetMoney
add r0, r4, #0
bl SavArray_Flags_get
ldr r1, _021E5C00 ; =56150
bl ScriptState_SetFishingCompetitionLengthRecord
add r0, r4, #0
bl SavArray_Flags_get
bl SetFlag960
pop {r4, pc}
.balign 4, 0
_021E5BFC: .word 3000
_021E5C00: .word 56150
thumb_func_end ov36_021E5BC8
.rodata
.public ov36_App_MainMenu_SelectOption_Continue
ov36_App_MainMenu_SelectOption_Continue:
.word ov36_021E599C, ov36_021E59B4, ov36_021E5A1C, 0xFFFFFFFF
.public ov36_021E5C14
ov36_021E5C14:
.word ov36_021E5948, ov36_021E5960, ov36_021E5980, 0xFFFFFFFF
.public ov36_App_MainMenu_SelectOption_NewGame
ov36_App_MainMenu_SelectOption_NewGame:
.word ov36_021E5900, ov36_021E5918, ov36_TitleScreen_SwitchToNewGame, 0xFFFFFFFF
ov36_021E5C34:
.byte 0x02, 0x04, 0x07, 0x08, 0x52, 0x00, 0x18, 0x00, 0x03, 0x01, 0x0A, 0xFF, 0x07, 0x00, 0x00, 0x00

View File

@ -596,7 +596,7 @@ Overlay OVY_35
Overlay OVY_36
{
After main
Object asm/overlay_36.o
Object src/overlay_36.o
}
Overlay OVY_37
{

250
src/overlay_36.c Normal file
View File

@ -0,0 +1,250 @@
#include "apricorn_tree.h"
#include "constants/easy_chat.h"
#include "constants/mail.h"
#include "constants/species.h"
#include "friend_group.h"
#include "heap.h"
#include "igt.h"
#include "mail.h"
#include "main.h"
#include "math_util.h"
#include "msgdata.h"
#include "msgdata/msg.naix"
#include "options.h"
#include "overlay_manager.h"
#include "party.h"
#include "pokemon.h"
#include "pokewalker.h"
#include "safari_zone.h"
#include "sav_system_info.h"
#include "sys_flags.h"
#include "sys_vars.h"
#include "unk_0205B3DC.h"
extern const OVY_MGR_TEMPLATE _020FA15C;
extern const OVY_MGR_TEMPLATE _020FA16C;
extern const OVY_MGR_TEMPLATE _02106068;
extern void sub_0201838C(IGT* igt);
extern u32 sub_020674BC(SAVEDATA* savedata);
extern void Save_CurrentLocation_BackUp(SAVEDATA* savedata);
extern void sub_0202C7C0(SAV_FRIEND_GRP* friend_groups, u32 group_idx, u32 a2);
static BOOL ov36_021E599C(OVY_MANAGER* man, int* state);
static BOOL ov36_021E59B4(OVY_MANAGER* man, int* state);
static BOOL ov36_021E5A1C(OVY_MANAGER* man, int* state);
static BOOL ov36_021E5948(OVY_MANAGER* man, int* state);
static BOOL ov36_021E5960(OVY_MANAGER* man, int* state);
static BOOL ov36_021E5980(OVY_MANAGER* man, int* state);
static BOOL ov36_021E5900(OVY_MANAGER* man, int* state);
static BOOL ov36_021E5918(OVY_MANAGER* man, int* state);
static BOOL ov36_TitleScreen_SwitchToNewGame(OVY_MANAGER* man, int* state);
static void ov36_021E5A38(HeapID heap_id, SAVEDATA* savedata, BOOL set_trainer_id);
static void ov36_021E5BB4(HeapID heap_id, SAVEDATA* savedata);
static void ov36_021E5BC8(HeapID heap_id, SAVEDATA* savedata);
const OVY_MGR_TEMPLATE ov36_App_MainMenu_SelectOption_NewGame = {
.init = ov36_021E5900,
.exec = ov36_021E5918,
.exit = ov36_TitleScreen_SwitchToNewGame,
.ovy_id = FS_OVERLAY_ID_NONE,
};
const OVY_MGR_TEMPLATE ov36_021E5C14 = {
.init = ov36_021E5948,
.exec = ov36_021E5960,
.exit = ov36_021E5980,
.ovy_id = FS_OVERLAY_ID_NONE,
};
const OVY_MGR_TEMPLATE ov36_App_MainMenu_SelectOption_Continue = {
.init = ov36_021E599C,
.exec = ov36_021E59B4,
.exit = ov36_021E5A1C,
.ovy_id = FS_OVERLAY_ID_NONE,
};
static const MAIL_MSG_TEMPLATE sMailMsgTemplates[2] = {
{
.msg_bank = 2,
.msg_no = 4,
.ec_groups = { EC_GROUP_FEELINGS, EC_GROUP_TOUGH_WORDS },
.ec_words = { EC_WORD_FEELINGS_ADVENTURE - EC_WORDS_FEELINGS_MIN, EC_WORD_TOUGH_WORDS_EXCITED - EC_WORDS_TOUGH_WORDS_MIN },
},
{
.msg_bank = 3,
.msg_no = 1,
.ec_groups = { EC_GROUP_QUESTION_MARKS, 0xFF },
.ec_words = { EC_WORD_QUESTION_MARKS_POKEMON - EC_WORDS_QUESTION_MARKS_MIN, 0 },
},
};
BOOL ov36_021E5900(OVY_MANAGER* man, int* state) {
#pragma unused(man, state)
CreateHeap(3, 75, 0x20000);
InitializeMainRNG();
return TRUE;
}
BOOL ov36_021E5918(OVY_MANAGER* man, int* state) {
#pragma unused(state)
SAVEDATA* savedata = ((struct UnkStruct_02111868_sub*)OverlayManager_GetParentWork(man))->savedata;
ov36_021E5BC8(75, savedata);
return TRUE;
}
BOOL ov36_TitleScreen_SwitchToNewGame(OVY_MANAGER* man, int* state) {
#pragma unused(man, state)
DestroyHeap(75);
RegisterMainOverlay(FS_OVERLAY_ID_NONE, &_02106068);
return TRUE;
}
BOOL ov36_021E5948(OVY_MANAGER* man, int* state) {
#pragma unused(man, state)
CreateHeap(3, 75, 0x20000);
InitializeMainRNG();
return TRUE;
}
BOOL ov36_021E5960(OVY_MANAGER* man, int* state) {
#pragma unused(state)
struct UnkStruct_02111868_sub* unk_work = OverlayManager_GetParentWork(man);
SAVEDATA* savedata = unk_work->savedata;
ov36_021E5A38(75, savedata, 1);
sub_0201838C(Sav2_PlayerData_GetIGTAddr(savedata));
return TRUE;
}
BOOL ov36_021E5980(OVY_MANAGER* man, int* state) {
#pragma unused(man, state)
DestroyHeap(75);
RegisterMainOverlay(FS_OVERLAY_ID_NONE, &_020FA15C);
return TRUE;
}
BOOL ov36_021E599C(OVY_MANAGER* man, int* state) {
#pragma unused(man, state)
CreateHeap(3, 75, 0x20000);
InitializeMainRNG();
return TRUE;
}
BOOL ov36_021E59B4(OVY_MANAGER* man, int* state) {
#pragma unused(state)
struct UnkStruct_02111868_sub* unk_work = OverlayManager_GetParentWork(man);
SAVEDATA* savedata = unk_work->savedata;
SYSINFO* sys_info = Sav2_SysInfo_get(savedata);
ov36_021E5BB4(75, savedata);
Options_SetButtonModeOnMain(savedata, 0);
if (!Sav2_SysInfo_MacAddressIsMine(sys_info) || !Sav2_SysInfo_RTCOffsetIsMine(sys_info)) {
sub_02028E4C(Sav2_SysInfo_RTC_get(savedata));
Sav2_BerryPotRTC_init(Sav2_BerryPotRTC_get(savedata));
Sav2_SysInfo_InitFromSystem(sys_info);
Party_ResetAllShayminToLandForme(SavArray_PlayerParty_get(savedata));
}
sub_0201838C(Sav2_PlayerData_GetIGTAddr(savedata));
return TRUE;
}
BOOL ov36_021E5A1C(OVY_MANAGER* man, int* state) {
#pragma unused(man, state)
DestroyHeap(75);
RegisterMainOverlay(FS_OVERLAY_ID_NONE, &_020FA16C);
return TRUE;
}
static void ov36_021E5A38(HeapID heap_id, SAVEDATA* savedata, BOOL set_trainer_id) {
#pragma unused(heap_id)
s32 i;
MSGDATA* friend_names_msgdata;
STRING* author_name;
Sav2_SysInfo_InitFromSystem(Sav2_SysInfo_get(savedata));
Sav2_SysInfo_RTC_init(Sav2_SysInfo_RTC_get(savedata));
Sav2_BerryPotRTC_init(Sav2_BerryPotRTC_get(savedata));
sub_0202C7C0(sub_0202C854(savedata), 1, MTRandom());
sub_020674BC(savedata);
PLAYERPROFILE* profile = Sav2_PlayerData_GetProfileAddr(savedata);
u32 rand = MTRandom();
if (set_trainer_id) {
PlayerProfile_SetTrainerID(profile, rand);
}
SAFARIZONE* safari_zone = Save_SafariZone_get(savedata);
SafariZone_ResetAreaSetToDefaultSet(safari_zone->area_sets, rand);
PlayerProfile_SetAvatar(profile, sub_0205B418(rand, PlayerProfile_GetTrainerGender(profile), 0));
sub_0202AE0C(Sav2_FieldApricornTrees_get(savedata));
u32* pokewalker_unk = sub_02032728(Sav2_Pokewalker_get(savedata));
for (i = 0; i < 10; i++) {
pokewalker_unk[i] = MTRandom();
}
friend_names_msgdata = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0445_bin, 3);
MAILBOX* mailbox = Sav2_Mailbox_get(savedata);
POKEMON* friend_pokemon = AllocMonZeroed(3);
CreateMon(friend_pokemon, SPECIES_MARILL, 1, 0, FALSE, 0, 0, 0);
MAIL* mail;
if (PlayerProfile_GetTrainerGender(profile) == PLAYER_GENDER_MALE) {
author_name = NewString_ReadMsgData(friend_names_msgdata, 1);
mail = CreateKenyaMail(friend_pokemon, MAIL_AIR, MON_FEMALE, author_name, 0);
} else {
author_name = NewString_ReadMsgData(friend_names_msgdata, 0);
mail = CreateKenyaMail(friend_pokemon, MAIL_AIR, MON_MALE, author_name, 0);
}
MAIL_MESSAGE mail_message;
for (i = 0; i < (s32)NELEMS(sMailMsgTemplates); i++) {
MailMsg_init_fromTemplate(&mail_message, &sMailMsgTemplates[i]);
Mail_CopyToUnk20Array(mail, &mail_message, (u8)i);
}
MailMsg_init(&mail_message);
Mail_CopyToUnk20Array(mail, &mail_message, 2);
Mailbox_CopyMailToSlotI(mailbox->msgs, FALSE, 0, mail);
FreeToHeap(friend_pokemon);
String_dtor(author_name);
FreeToHeap(mail);
DestroyMsgData(friend_names_msgdata);
}
static void ov36_021E5BB4(HeapID heap_id, SAVEDATA* savedata) {
#pragma unused(heap_id)
if (!sub_020273B0(savedata)) {
OS_ResetSystem(0);
}
}
static void ov36_021E5BC8(HeapID heap_id, SAVEDATA* savedata) {
#pragma unused(heap_id)
Sav2_InitDynamicRegion(savedata);
Save_CurrentLocation_BackUp(savedata);
PlayerProfile_SetMoney(Sav2_PlayerData_GetProfileAddr(savedata), 3000);
ScriptState_SetFishingCompetitionLengthRecord(SavArray_Flags_get(savedata), 56150); // 3'6"
SetFlag960(SavArray_Flags_get(savedata));
}