diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/game_init.c | 3 | ||||
-rw-r--r-- | arm9/src/unk_02022450.c | 43 |
2 files changed, 44 insertions, 2 deletions
diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c index 1c6098ea..020d4b75 100644 --- a/arm9/src/game_init.c +++ b/arm9/src/game_init.c @@ -7,6 +7,7 @@ #include "MWC_string.h" #include "tp.h" #include "unk_0201B4E8.h" +#include "unk_02022450.h" #include "game_init.h" #include "registers.h" #include "heap.h" @@ -14,8 +15,6 @@ #pragma thumb on -extern void FUN_02022450(void); - typedef volatile struct { u8 sys_and_irq_stack[0x3F80]; diff --git a/arm9/src/unk_02022450.c b/arm9/src/unk_02022450.c new file mode 100644 index 00000000..2c69342c --- /dev/null +++ b/arm9/src/unk_02022450.c @@ -0,0 +1,43 @@ +#include "global.h" +#include "FS_file.h" +#include "OS_terminate_proc.h" +#include "CARD_rom.h" +#include "MI_memory.h" + +#include "unk_02022450.h" + +static const char string_saying_rom[] = "rom"; + +THUMB_FUNC void FUN_02022450 () { + if (!FS_IsAvailable()) { + OS_Terminate(); + } + else { + if (!*(u32*)0x027FF00C) { + CARD_Init(); + MI_CpuCopy8((u8*)0x027FFE00, (u8*)0x027FF000, 22 * 16); + MI_CpuCopy8((u8*)0x027FFE00, (u8*)0x027FFA80, 22 * 16); + *(u32*)0x027FF00C = 0x4A414441; + } + FSArchive * const r0 = FS_FindArchive(string_saying_rom, 3); + u32 *r1 = (u32*)0x027FF000; + r0->fat = r1[18]; + r0->fat_size = r1[19]; + r0->fnt = r1[16]; + r0->fnt_size = r1[17]; + if (*(u32*)0x027FF00C != 0x4A414441 || *(u16*)0x027FF010 != 0x3130) { + OS_Terminate(); + } + } + return; +} + +THUMB_FUNC void Reset_To_File (const char* path) { + FSFile file; + FS_InitFile(&file); + if (FS_OpenFile(&file, path)) { + *(u32*)HW_ROM_BASE_OFFSET_BUF = file.prop.file.top; + OS_ResetSystem(0); + } + return; +} |