summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/GX_layers.c3
-rw-r--r--arm9/src/WIFI_stubsmd5_dummy.c17
-rw-r--r--arm9/src/error_handling.c5
-rw-r--r--arm9/src/error_message_reset.c41
-rw-r--r--arm9/src/filesystem.c20
-rw-r--r--arm9/src/game_init.c62
-rw-r--r--arm9/src/gf_gfx_loader.c349
-rw-r--r--arm9/src/gf_rtc.c183
-rw-r--r--arm9/src/heap.c69
-rw-r--r--arm9/src/itemtool.c2
-rw-r--r--arm9/src/list_menu.c572
-rw-r--r--arm9/src/list_menu_items.c92
-rw-r--r--arm9/src/main.c94
-rw-r--r--arm9/src/math_util.c609
-rw-r--r--arm9/src/overlay_manager.c4
-rw-r--r--arm9/src/poke_overlay.c16
-rw-r--r--arm9/src/pokedex.c46
-rw-r--r--arm9/src/pokemon.c10
-rw-r--r--arm9/src/sav_chatot.c98
-rw-r--r--arm9/src/save.c2
-rw-r--r--arm9/src/save_arrays.c6
-rw-r--r--arm9/src/scrcmd.c83
-rw-r--r--arm9/src/scrcmd_20.c35
-rw-r--r--arm9/src/scrcmd_24.c276
-rw-r--r--arm9/src/scrcmd_8.c88
-rw-r--r--arm9/src/scrcmd_berry_trees.c (renamed from arm9/src/scrcmd_11.c)18
-rw-r--r--arm9/src/scrcmd_coins.c6
-rw-r--r--arm9/src/scrcmd_daycare.c10
-rw-r--r--arm9/src/scrcmd_flags.c284
-rw-r--r--arm9/src/scrcmd_fossils.c (renamed from arm9/src/scrcmd_19.c)38
-rw-r--r--arm9/src/scrcmd_mart.c442
-rw-r--r--arm9/src/scrcmd_money.c6
-rw-r--r--arm9/src/scrcmd_names.c18
-rw-r--r--arm9/src/scrcmd_prizes.c36
-rw-r--r--arm9/src/scrcmd_sound.c266
-rw-r--r--arm9/src/scrcmd_underground.c (renamed from arm9/src/scrcmd_23.c)32
-rw-r--r--arm9/src/script.c2
-rw-r--r--arm9/src/script_buffers.c23
-rw-r--r--arm9/src/script_pokemon_util.c2
-rw-r--r--arm9/src/sound.c95
-rw-r--r--arm9/src/text.c246
-rw-r--r--arm9/src/text_02054590.c51
-rw-r--r--arm9/src/unk_0200BA78.c36
-rw-r--r--arm9/src/unk_0200BB14.c1323
-rw-r--r--arm9/src/unk_0200CA44.c10
-rw-r--r--arm9/src/unk_02015E30.c30
-rw-r--r--arm9/src/unk_02016B94.c8110
-rw-r--r--arm9/src/unk_02021934.c46
-rw-r--r--arm9/src/unk_02022504.c32
-rw-r--r--arm9/src/unk_02024E64.c6
-rw-r--r--arm9/src/unk_02025484.c4
-rw-r--r--arm9/src/unk_020286F8.c9
-rw-r--r--arm9/src/unk_0202ABBC.c6
-rw-r--r--arm9/src/unk_0202D858.c96
-rw-r--r--arm9/src/unk_0202E29C.c1087
-rw-r--r--arm9/src/unk_0202F150.c84
-rw-r--r--arm9/src/unk_02031480.c213
-rw-r--r--arm9/src/unk_02031734.c2173
-rw-r--r--arm9/src/unk_02033778.c33
-rw-r--r--arm9/src/unk_020337E8.c50
-rw-r--r--arm9/src/unk_0204639C.c11
-rw-r--r--arm9/src/unk_0204AEA8.c4
-rw-r--r--arm9/src/unk_0204B0A0.c198
-rw-r--r--arm9/src/unk_0205FA2C.c52
-rw-r--r--arm9/src/unk_0206015C.c149
-rw-r--r--arm9/src/unk_0206439C.c16
-rw-r--r--arm9/src/unk_0208890C.c53
-rw-r--r--arm9/src/unk_0208A300.c38
68 files changed, 17360 insertions, 866 deletions
diff --git a/arm9/src/GX_layers.c b/arm9/src/GX_layers.c
index ce188876..f0ac9472 100644
--- a/arm9/src/GX_layers.c
+++ b/arm9/src/GX_layers.c
@@ -1,4 +1,7 @@
#include "GX_layers.h"
+#include "GX_vramcnt.h"
+#include "gx.h"
+#include "main.h"
struct GX_LayerData layer_data;
diff --git a/arm9/src/WIFI_stubsmd5_dummy.c b/arm9/src/WIFI_stubsmd5_dummy.c
new file mode 100644
index 00000000..6de2edca
--- /dev/null
+++ b/arm9/src/WIFI_stubsmd5_dummy.c
@@ -0,0 +1,17 @@
+#include "function_target.h"
+#include "WIFI_stubsmd5_dummy.h"
+
+ARM_FUNC void MD5Final(u8 *digest, struct DGTHash1Context *context)
+{
+ DGT_Hash1GetDigest_R(digest, context);
+}
+
+ARM_FUNC void MD5Update(struct DGTHash1Context *context, u8 *input, u32 length)
+{
+ DGT_Hash1SetSource(context, input, length);
+}
+
+ARM_FUNC void MD5Init(struct DGTHash1Context *context)
+{
+ DGT_Hash1Reset(context);
+}
diff --git a/arm9/src/error_handling.c b/arm9/src/error_handling.c
index a01894f6..0b76ccff 100644
--- a/arm9/src/error_handling.c
+++ b/arm9/src/error_handling.c
@@ -1,10 +1,11 @@
#include "global.h"
#include "error_handling.h"
#include "error_message_reset.h"
+#include "unk_02031734.h"
-extern u32 FUN_02031810(void);
-THUMB_FUNC void ErrorHandling(void)
+
+THUMB_FUNC void GF_AssertFail(void)
{
if (FUN_02031810())
{
diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c
index 3a727924..28627d6b 100644
--- a/arm9/src/error_message_reset.c
+++ b/arm9/src/error_message_reset.c
@@ -1,36 +1,29 @@
#include "error_message_reset.h"
#include "GX_layers.h"
+#include "unk_02031734.h"
+#include "unk_0202F150.h"
+#include "unk_02016B94.h"
-const u32 UNK_020FF49C[2] = { 0x1a030300, 0x00230112 };
+
+
+const struct UnkStruct_02016B94_4 UNK_020FF49C = { 0, 3, 3, 0x1a, 0x12, 1, 0x23 };
const u32 UNK_020FF4A4[2] = { 0x00020000, 0x00000000 };
const struct GraphicsModes UNK_020FF4AC = { mode1 : 1 };
-const u32 UNK_020FF4BC[7] = { 0x00, 0x00, 0x0800, 0x00, 0x06000001, 0x0100, 0x00 };
+const struct UnkStruct_02016B94_1 UNK_020FF4BC = { 0, 0, 0x800, 0, 1, 0, 0, 6, 0, 1, 0, 0, 0 };
const struct GraphicsBanks UNK_020FF4D8 = { bg : 3 };
u32 sErrorMessagePrinterLock;
extern void FUN_0200E3A0(PMLCDTarget, int);
-extern u32 *FUN_02016B94(u32 param0);
-extern void FUN_02016BBC(const struct GraphicsModes *modes);
-extern void FUN_02016C18(u32 *param0, u32 param1, void *param2, u32 param3);
-extern void FUN_02018744(u32 *param0, u32 param1);
-extern void FUN_0200CB00(u32 *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5);
+extern void FUN_0200CB00(struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5);
extern void FUN_02002ED0(u32 param0, u32 param1, u32 param2);
-extern void FUN_02017F18(u32 param0, u32 param1, u32 param2, u32 param3);
-extern void FUN_02017FE4(u32 param0, u32 param1);
-extern void FUN_02019150(u32 *param0, u32 *param1, const u32 *param2);
-extern void FUN_020196F4(u32 *, u8, u16, u16, u16, u16);
-extern void FUN_0200CCA4(u32 *param0, u32 param1, u32 param2, u32 param3);
+extern void FUN_0200CCA4(struct Window *param0, u32 param1, u32 param2, u32 param3);
extern void FUN_0200E394(u32 param0);
extern void FUN_0200A274(u32 param0, u32 param1, u32 param2);
-extern BOOL FUN_02032DAC(void);
-extern BOOL FUN_0202FB80(void);
-extern BOOL FUN_02033678(void);
-extern void FUN_02019178(u32 *param0);
THUMB_FUNC void VBlankHandler()
{
@@ -42,8 +35,8 @@ THUMB_FUNC void VBlankHandler()
THUMB_FUNC void PrintErrorMessageAndReset()
{
- u32 *ptr;
- u32 buf[4];
+ struct UnkStruct_02016B94_2 *ptr;
+ struct Window buf;
if (sErrorMessagePrinterLock != 1)
{
@@ -82,7 +75,7 @@ THUMB_FUNC void PrintErrorMessageAndReset()
ptr = FUN_02016B94(0);
FUN_02016BBC(&UNK_020FF4AC);
- FUN_02016C18(ptr, 0, UNK_020FF4BC, 0);
+ FUN_02016C18(ptr, 0, &UNK_020FF4BC, 0);
FUN_02018744(ptr, 0);
FUN_0200CB00(ptr, 0, 503, 2, 0, 0);
@@ -96,13 +89,13 @@ THUMB_FUNC void PrintErrorMessageAndReset()
struct String *str = String_ctor(6 << 6, 0);
FUN_0201BD5C();
- FUN_02019150(ptr, buf, UNK_020FF49C);
- FUN_020196F4(buf, 15, 0, 0, 0xd0, 0x90);
- FUN_0200CCA4(buf, 0, 0x1f7, 2);
+ FUN_02019150(ptr, &buf, &UNK_020FF49C);
+ FillWindowPixelRect(&buf, 15, 0, 0, 0xd0, 0x90);
+ FUN_0200CCA4(&buf, 0, 0x1f7, 2);
ReadMsgDataIntoString(msg_data, 3, str);
- AddTextPrinterParameterized((u32)buf, 0, (const u16 *)str, 0, 0, 0, NULL); // wtf
+ AddTextPrinterParameterized(&buf, 0, str, 0, 0, 0, NULL);
String_dtor(str);
GX_BothDispOn();
@@ -132,7 +125,7 @@ THUMB_FUNC void PrintErrorMessageAndReset()
FUN_0200E3A0(PM_LCD_TOP, 0x7FFF);
FUN_0200E3A0(PM_LCD_BOTTOM, 0x7FFF);
- FUN_02019178(buf);
+ FUN_02019178(&buf);
DestroyMsgData(msg_data);
FreeToHeap(ptr);
diff --git a/arm9/src/filesystem.c b/arm9/src/filesystem.c
index 3775b0b8..ed82acb9 100644
--- a/arm9/src/filesystem.c
+++ b/arm9/src/filesystem.c
@@ -176,7 +176,7 @@ THUMB_FUNC void ReadFromNarcMemberByPathAndId(void * dest, const char * path, s3
FS_ReadFile(&file, &chunk_size, 4);
FS_ReadFile(&file, &num_files, 2);
if (num_files <= file_idx)
- ErrorHandling();
+ GF_AssertFail();
chunk_starts[1] = chunk_starts[0] + chunk_size;
FS_SeekFile(&file, (s32)(chunk_starts[1] + 4), FS_SEEK_SET);
FS_ReadFile(&file, &chunk_size, 4);
@@ -191,7 +191,7 @@ THUMB_FUNC void ReadFromNarcMemberByPathAndId(void * dest, const char * path, s3
else
chunk_size = size;
if (chunk_size == 0)
- ErrorHandling();
+ GF_AssertFail();
FS_ReadFile(&file, dest, (s32)chunk_size);
FS_CloseFile(&file);
}
@@ -217,7 +217,7 @@ THUMB_FUNC void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 f
FS_ReadFile(&file, &chunk_size, 4);
FS_ReadFile(&file, &num_files, 2);
if (num_files <= file_idx)
- ErrorHandling();
+ GF_AssertFail();
chunk_starts[1] = chunk_starts[0] + chunk_size;
FS_SeekFile(&file, (s32)(chunk_starts[1] + 4), FS_SEEK_SET);
FS_ReadFile(&file, &chunk_size, 4);
@@ -232,7 +232,7 @@ THUMB_FUNC void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 f
else
chunk_size = size;
if (chunk_size == 0)
- ErrorHandling();
+ GF_AssertFail();
switch (r4)
{
case 0:
@@ -297,7 +297,7 @@ THUMB_FUNC u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx)
FS_ReadFile(&file, &chunk_size, 4);
FS_ReadFile(&file, &num_files, 2);
if (num_files <= file_idx)
- ErrorHandling();
+ GF_AssertFail();
chunk_starts[1] = chunk_starts[0] + chunk_size;
FS_SeekFile(&file, (s32)(chunk_starts[1] + 4), FS_SEEK_SET);
FS_ReadFile(&file, &chunk_size, 4);
@@ -309,7 +309,7 @@ THUMB_FUNC u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx)
FS_SeekFile(&file, (s32)(chunk_starts[2] + 8 + file_start + 0), FS_SEEK_SET);
chunk_size = file_end - file_start;
if (chunk_size == 0)
- ErrorHandling();
+ GF_AssertFail();
// Bug: File is never closed
return chunk_size;
}
@@ -349,7 +349,7 @@ THUMB_FUNC void * NARC_AllocAndReadWholeMember(NARC * narc, u32 file_id, u32 hea
u32 file_end;
void * dest;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_ReadFile(&narc->file, &file_end, 4);
@@ -367,7 +367,7 @@ THUMB_FUNC void NARC_ReadWholeMember(NARC * narc, u32 file_id, void * dest)
u32 file_start;
u32 file_end;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_ReadFile(&narc->file, &file_end, 4);
@@ -380,7 +380,7 @@ THUMB_FUNC u32 NARC_GetMemberSize(NARC * narc, u32 file_id)
u32 file_start;
u32 file_end;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_ReadFile(&narc->file, &file_end, 4);
@@ -391,7 +391,7 @@ THUMB_FUNC void NARC_ReadFromMember(NARC * narc, u32 file_id, u32 pos, u32 size,
{
u32 file_start;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_SeekFile(&narc->file, (s32)(narc->gmif_start + 8 + file_start + pos), FS_SEEK_SET);
diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c
index a7508fab..64ea7a54 100644
--- a/arm9/src/game_init.c
+++ b/arm9/src/game_init.c
@@ -141,7 +141,7 @@ void FUN_02015FC8(void)
{
csum++;
}
- FUN_020166C8((u32 *)UNK_020EDB10, 4, 92, (int)csum);
+ FUN_020166C8((u32 *)UNK_020EDB10, 4, 92, csum);
}
void InitSystemForTheGame(void)
@@ -181,12 +181,12 @@ void InitSystemForTheGame(void)
void InitGraphicMemory(void)
{
GX_SetBankForLCDC(0x1FF);
- MIi_CpuClearFast(0, (void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
+ MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
GX_DisableBankForLCDC();
- MIi_CpuClearFast(0xC0, (void *)HW_OAM, HW_OAM_SIZE);
- MIi_CpuClearFast(0xC0, (void *)HW_DB_OAM, HW_DB_OAM_SIZE);
- MIi_CpuClearFast(0, (void *)HW_PLTT, HW_PLTT_SIZE);
- MIi_CpuClearFast(0, (void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
+ MI_CpuFillFast((void *)HW_OAM, 0xC0, HW_OAM_SIZE);
+ MI_CpuFillFast((void *)HW_DB_OAM, 0xC0, HW_DB_OAM_SIZE);
+ MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE);
+ MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
}
void * FUN_020161A4(u32 heap_id, const char * path)
@@ -203,7 +203,7 @@ void * FUN_020161A4(u32 heap_id, const char * path)
{
if (size != FS_ReadFile(&file, ret, (s32)size))
{
- FUN_02016A8C(heap_id, ret);
+ FreeToHeapExplicit(heap_id, ret);
ret = NULL;
}
}
@@ -344,8 +344,8 @@ void FUN_020163BC(void)
gMain.unk3C = 0;
gMain.unk40 = 0;
gMain.unk44 = 0;
- gMain.unk48 = 0;
- gMain.unk4C = 0;
+ gMain.newKeys = 0;
+ gMain.newAndRepeatedKeys = 0;
gMain.unk50 = 0;
gMain.unk54 = 8;
gMain.unk58 = 15;
@@ -387,9 +387,9 @@ void FUN_02016464(void)
TPData raw, calib;
if (PAD_DetectFold())
{
- gMain.unk48 = 0;
+ gMain.newKeys = 0;
gMain.unk44 = 0;
- gMain.unk4C = 0;
+ gMain.newAndRepeatedKeys = 0;
gMain.unk60 = 0;
gMain.unk62 = 0;
return;
@@ -409,9 +409,9 @@ void FUN_02016464(void)
gMain.unk50 = gMain.unk58;
}
gMain.unk38 = r0;
- gMain.unk48 = gMain.unk3C;
+ gMain.newKeys = gMain.unk3C;
gMain.unk44 = r0;
- gMain.unk4C = gMain.unk40;
+ gMain.newAndRepeatedKeys = gMain.unk40;
FUN_02016568();
if (gMain.unk64 == 0)
{
@@ -453,26 +453,26 @@ void FUN_02016568(void)
case 0: // Normal
break;
case 1: // Start = X
- if (gMain.unk48 & PAD_BUTTON_START)
- gMain.unk48 |= PAD_BUTTON_X;
+ if (gMain.newKeys & PAD_BUTTON_START)
+ gMain.newKeys |= PAD_BUTTON_X;
if (gMain.unk44 & PAD_BUTTON_START)
gMain.unk44 |= PAD_BUTTON_X;
- if (gMain.unk4C & PAD_BUTTON_START)
- gMain.unk4C |= PAD_BUTTON_X;
+ if (gMain.newAndRepeatedKeys & PAD_BUTTON_START)
+ gMain.newAndRepeatedKeys |= PAD_BUTTON_X;
break;
case 2: // Swap X and Y; unused in the retail game
{
u32 r1 = 0;
- if (gMain.unk48 & PAD_BUTTON_X)
+ if (gMain.newKeys & PAD_BUTTON_X)
{
r1 |= PAD_BUTTON_Y;
}
- if (gMain.unk48 & PAD_BUTTON_Y)
+ if (gMain.newKeys & PAD_BUTTON_Y)
{
r1 |= PAD_BUTTON_X;
}
- gMain.unk48 &= 0xF3FF;
- gMain.unk48 |= r1;
+ gMain.newKeys &= 0xF3FF;
+ gMain.newKeys |= r1;
}
{
u32 r1 = 0;
@@ -489,28 +489,28 @@ void FUN_02016568(void)
}
{
u32 r1 = 0;
- if (gMain.unk4C & PAD_BUTTON_X)
+ if (gMain.newAndRepeatedKeys & PAD_BUTTON_X)
{
r1 |= PAD_BUTTON_Y;
}
- if (gMain.unk4C & PAD_BUTTON_Y)
+ if (gMain.newAndRepeatedKeys & PAD_BUTTON_Y)
{
r1 |= PAD_BUTTON_X;
}
- gMain.unk4C &= 0xF3FF;
- gMain.unk4C |= r1;
+ gMain.newAndRepeatedKeys &= 0xF3FF;
+ gMain.newAndRepeatedKeys |= r1;
}
break;
case 3: // L = A
- if (gMain.unk48 & PAD_BUTTON_L)
- gMain.unk48 |= PAD_BUTTON_A;
+ if (gMain.newKeys & PAD_BUTTON_L)
+ gMain.newKeys |= PAD_BUTTON_A;
if (gMain.unk44 & PAD_BUTTON_L)
gMain.unk44 |= PAD_BUTTON_A;
- if (gMain.unk4C & PAD_BUTTON_L)
- gMain.unk4C |= PAD_BUTTON_A;
- gMain.unk48 &= 0xFCFF;
+ if (gMain.newAndRepeatedKeys & PAD_BUTTON_L)
+ gMain.newAndRepeatedKeys |= PAD_BUTTON_A;
+ gMain.newKeys &= 0xFCFF;
gMain.unk44 &= 0xFCFF;
- gMain.unk4C &= 0xFCFF;
+ gMain.newAndRepeatedKeys &= 0xFCFF;
}
}
diff --git a/arm9/src/gf_gfx_loader.c b/arm9/src/gf_gfx_loader.c
new file mode 100644
index 00000000..769c90d9
--- /dev/null
+++ b/arm9/src/gf_gfx_loader.c
@@ -0,0 +1,349 @@
+#include "global.h"
+#include "filesystem.h"
+#include "NNS_g2d.h"
+#include "gf_gfx_loader.h"
+
+THUMB_FUNC u32 GfGfxLoader_LoadCharData(NarcId narcId, s32 memberNo, struct UnkStruct_02016B94_2 * unkStruct02016B94_2, u32 a3, u32 a4, u32 szByte, BOOL isCompressed, u32 heap_id)
+{
+ NNSG2dCharacterData * pCharData;
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, isCompressed, heap_id, FALSE);
+ if (pFile != NULL)
+ {
+ if (NNS_G2dGetUnpackedBGCharacterData(pFile, &pCharData))
+ {
+ if (szByte == 0)
+ szByte = pCharData->szByte;
+ FUN_02017E14(unkStruct02016B94_2, (u8)a3, pCharData->pRawData, szByte, a4);
+ }
+ FreeToHeap(pFile);
+ }
+ return szByte;
+}
+
+THUMB_FUNC void GfGfxLoader_LoadScrnData(NarcId narcId, s32 memberNo, struct UnkStruct_02016B94_2 * unkStruct02016B94_2, u32 a3, u32 a4, u32 szByte, BOOL isCompressed, u32 heap_id)
+{
+ NNSG2dScreenData * pScreenData;
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, isCompressed, heap_id, TRUE);
+ if (pFile != NULL)
+ {
+ if (NNS_G2dGetUnpackedScreenData(pFile, &pScreenData))
+ {
+ if (szByte == 0)
+ szByte = pScreenData->szByte;
+ if (FUN_0201886C(unkStruct02016B94_2, (u8)a3) != NULL)
+ FUN_02017DFC(unkStruct02016B94_2, (u8)a3, pScreenData->rawData, szByte);
+ FUN_02017CE8(unkStruct02016B94_2, (u8)a3, pScreenData->rawData, szByte, a4);
+ }
+ FreeToHeap(pFile);
+ }
+}
+
+THUMB_FUNC void GfGfxLoader_GXLoadPal(NarcId narcId, s32 memberNo, u32 whichRoutine, u32 baseAddr, u32 szByte, u32 heap_id)
+{
+ GfGfxLoader_GXLoadPalWithSrcOffset(narcId, memberNo, whichRoutine, 0, baseAddr, szByte, heap_id);
+}
+
+THUMB_FUNC void GfGfxLoader_GXLoadPalWithSrcOffset(NarcId narcId, s32 memberNo, u32 whichRoutine, u32 srcOffset, u32 baseAddr, u32 szByte, u32 heap_id)
+{
+ static void (*const load_funcs[])(void *, u32, u32) = {
+ GX_LoadBGPltt,
+ GX_LoadOBJPltt,
+ GX_LoadBGExtPltt,
+ GX_LoadOBJExtPltt,
+ GXS_LoadBGPltt,
+ GXS_LoadOBJPltt,
+ GXS_LoadBGExtPltt,
+ GXS_LoadOBJExtPltt
+ };
+ NNSG2dPaletteData * pPltData;
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, FALSE, heap_id, TRUE);
+ if (pFile != NULL)
+ {
+ if (NNS_G2dGetUnpackedPaletteData(pFile, &pPltData))
+ {
+ pPltData->pRawData = (void *)((u32)pPltData->pRawData + srcOffset);
+ if (szByte == 0)
+ szByte = pPltData->szByte - srcOffset;
+ DC_FlushRange(pPltData->pRawData, szByte);
+ switch (whichRoutine)
+ {
+ case 2:
+ GX_BeginLoadBGExtPltt();
+ load_funcs[whichRoutine](pPltData->pRawData, baseAddr, szByte);
+ GX_EndLoadBGExtPltt();
+ break;
+ case 6:
+ GXS_BeginLoadBGExtPltt();
+ load_funcs[whichRoutine](pPltData->pRawData, baseAddr, szByte);
+ GXS_EndLoadBGExtPltt();
+ break;
+ case 3:
+ GX_BeginLoadOBJExtPltt();
+ load_funcs[whichRoutine](pPltData->pRawData, baseAddr, szByte);
+ GX_EndLoadOBJExtPltt();
+ break;
+ case 7:
+ GXS_BeginLoadOBJExtPltt();
+ load_funcs[whichRoutine](pPltData->pRawData, baseAddr, szByte);
+ GXS_EndLoadOBJExtPltt();
+ break;
+ default:
+ load_funcs[whichRoutine](pPltData->pRawData, baseAddr, szByte);
+ break;
+ }
+ }
+ FreeToHeap(pFile);
+ }
+}
+
+THUMB_FUNC u32 GfGfxLoader_LoadWholePalette(NarcId narcId, s32 memberId, u32 whichRoutine, u32 baseAddr, u32 szByte, BOOL isCompressed, u32 heap_id)
+{
+ static void (*const load_funcs[])(void *, u32, u32) = {
+ GX_LoadOBJ,
+ GXS_LoadOBJ
+ };
+
+ NNSG2dCharacterData* pCharData;
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, TRUE);
+ if (pFile != NULL)
+ {
+ if (NNS_G2dGetUnpackedCharacterData(pFile, &pCharData))
+ {
+ if (szByte == 0)
+ szByte = pCharData->szByte;
+ DC_FlushRange(pCharData->pRawData, szByte);
+ load_funcs[whichRoutine](pCharData->pRawData, baseAddr, szByte);
+ }
+ FreeToHeap(pFile);
+ }
+ return szByte;
+}
+
+THUMB_FUNC void GfGfxLoader_PartiallyLoadPalette(NarcId narcId, s32 memberId, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, u32 heap_id, NNSG2dImagePaletteProxy * pPltProxy)
+{
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, FALSE, heap_id, TRUE);
+ NNSG2dPaletteData* pPlttData;
+ NNSG2dPaletteCompressInfo* pCompressInfo;
+ if (pFile != NULL)
+ {
+ BOOL isCompressed = NNS_G2dGetUnpackedPaletteCompressInfo(pFile, &pCompressInfo);
+ if (NNS_G2dGetUnpackedPaletteData(pFile, &pPlttData))
+ {
+ if (isCompressed)
+ {
+ NNS_G2dLoadPaletteEx(pPlttData, pCompressInfo, baseAddr, vramType, pPltProxy);
+ }
+ else
+ {
+ NNS_G2dLoadPalette(pPlttData, baseAddr, vramType, pPltProxy);
+ }
+ }
+ FreeToHeap(pFile);
+ }
+}
+
+THUMB_FUNC u32 GfGfxLoader_LoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed, u32 whichRoutine, u32 szByte, NNS_G2D_VRAM_TYPE type, u32 baseAddr, u32 heap_id, NNSG2dImageProxy *pImgProxy)
+{
+ static void (*const load_funcs[])(const NNSG2dCharacterData *, u32, NNS_G2D_VRAM_TYPE, NNSG2dImageProxy *) = {
+ NNS_G2dLoadImage1DMapping,
+ NNS_G2dLoadImage2DMapping
+ };
+
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, TRUE);
+ u32 retSize = 0;
+ NNSG2dCharacterData * pSrcData;
+ if (pFile != NULL)
+ {
+ if (NNS_G2dGetUnpackedCharacterData(pFile, &pSrcData))
+ {
+ if (szByte != 0)
+ pSrcData->szByte = szByte;
+ load_funcs[whichRoutine](pSrcData, baseAddr, type, pImgProxy);
+ retSize = pSrcData->szByte;
+ }
+ FreeToHeap(pFile);
+ }
+ return retSize;
+}
+
+THUMB_FUNC void GfGfxLoader_SetObjCntFlagsAndLoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed, u32 whichRoutine, u32 szByte, NNS_G2D_VRAM_TYPE type, u32 baseAddr, u32 heap_id, NNSG2dImageProxy * pImageProxy)
+{
+ static void (*const load_funcs[])(const NNSG2dCharacterData *, u32, NNS_G2D_VRAM_TYPE, NNSG2dImageProxy *) = {
+ NNS_G2dLoadImage1DMapping,
+ NNS_G2dLoadImage2DMapping
+ };
+ NNSG2dCharacterData * pCharacterData;
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, TRUE);
+ if (pFile != NULL)
+ {
+ if (NNS_G2dGetUnpackedCharacterData(pFile, &pCharacterData))
+ {
+ if (szByte != 0)
+ pCharacterData->szByte = szByte;
+ switch (type)
+ {
+ case NNS_G2D_VRAM_TYPE_2DMAIN:
+ pCharacterData->mapingType = (GXOBJVRamModeChar)(reg_GX_DISPCNT & (REG_GX_DISPCNT_EXOBJ_CH_MASK | REG_GX_DISPCNT_OBJMAP_CH_MASK));
+ break;
+ case NNS_G2D_VRAM_TYPE_2DSUB:
+ pCharacterData->mapingType = (GXOBJVRamModeChar)(reg_GXS_DB_DISPCNT & (REG_GXS_DB_DISPCNT_EXOBJ_MASK | REG_GXS_DB_DISPCNT_OBJMAP_CH_MASK));
+ break;
+ default:
+ ;
+ }
+ load_funcs[whichRoutine](pCharacterData, baseAddr, type, pImageProxy);
+ }
+ FreeToHeap(pFile);
+ }
+}
+
+THUMB_FUNC void * GfGfxLoader_GetCharData(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dCharacterData ** ppCharData, u32 heap_id)
+{
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, FALSE);
+ if (pFile != NULL)
+ {
+ if (!NNS_G2dGetUnpackedBGCharacterData(pFile, ppCharData))
+ {
+ FreeToHeap(pFile);
+ return NULL;
+ }
+ }
+ return pFile;
+}
+
+THUMB_FUNC void * GfGfxLoader_GetScrnData(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dScreenData ** ppScrData, u32 heap_id)
+{
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, FALSE);
+ if (pFile != NULL)
+ {
+ if (!NNS_G2dGetUnpackedScreenData(pFile, ppScrData))
+ {
+ FreeToHeap(pFile);
+ return NULL;
+ }
+ }
+ return pFile;
+}
+
+THUMB_FUNC void * GfGfxLoader_GetPlttData(NarcId narcId, s32 memberId, NNSG2dPaletteData ** ppPltData, u32 heap_id)
+{
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, FALSE, heap_id, FALSE);
+ if (pFile != NULL)
+ {
+ if (!NNS_G2dGetUnpackedPaletteData(pFile, ppPltData))
+ {
+ FreeToHeap(pFile);
+ return NULL;
+ }
+ }
+ return pFile;
+}
+
+THUMB_FUNC void * GfGfxLoader_GetCellBank(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dCellDataBank ** ppCellBank, u32 heap_id)
+{
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, FALSE);
+ if (pFile != NULL)
+ {
+ if (!NNS_G2dGetUnpackedCellBank(pFile, ppCellBank))
+ {
+ FreeToHeap(pFile);
+ return NULL;
+ }
+ }
+ return pFile;
+}
+
+THUMB_FUNC void * GfGfxLoader_GetAnimBank(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dAnimBankData ** ppAnimBank, u32 heap_id)
+{
+ void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heap_id, FALSE);
+ if (pFile != NULL)
+ {
+ if (!NNS_G2dGetUnpackedAnimBank(pFile, ppAnimBank))
+ {
+ FreeToHeap(pFile);
+ return NULL;
+ }
+ }
+ return pFile;
+}
+
+THUMB_FUNC void * GfGfxLoader_UncompressFromNarc(NarcId narcId, s32 memberId, u32 heap_id)
+{
+ return GfGfxLoader_LoadFromNarc(narcId, memberId, TRUE, heap_id, FALSE);
+}
+
+THUMB_FUNC void * GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, u32 heap_id, BOOL allocAtEnd)
+{
+ void * dest;
+ void * dest2;
+ if (isCompressed || allocAtEnd == TRUE)
+ {
+ u32 size = GetNarcMemberSizeByIdPair(narcId, memberNo);
+ dest = AllocFromHeapAtEnd(heap_id, size);
+ }
+ else
+ {
+ u32 size = GetNarcMemberSizeByIdPair(narcId, memberNo);
+ dest = AllocFromHeap(heap_id, size);
+ }
+ if (dest != NULL)
+ {
+ ReadWholeNarcMemberByIdPair(dest, narcId, memberNo);
+ if (isCompressed)
+ {
+ if (allocAtEnd == FALSE)
+ {
+ dest2 = AllocFromHeap(heap_id, (*(u32 *)dest) >> 8);
+ }
+ else
+ {
+ dest2 = AllocFromHeapAtEnd(heap_id, (*(u32 *)dest) >> 8);
+ }
+ if (dest2 != NULL)
+ {
+ MI_UncompressLZ8(dest, dest2);
+ FreeToHeap(dest);
+ }
+ dest = dest2; // UB: if dest2 is NULL, dest is never freed
+ }
+ }
+ return dest;
+}
+
+THUMB_FUNC void * GfGfxLoader_LoadFromNarc_GetSizeOut(NarcId narcId, s32 memberNo, BOOL isCompressed, u32 heap_id, BOOL allocAtEnd, u32 *size_p)
+{
+ void * dest;
+ void * dest2;
+ *size_p = GetNarcMemberSizeByIdPair(narcId, memberNo);
+ if (isCompressed || allocAtEnd == TRUE)
+ {
+ dest = AllocFromHeapAtEnd(heap_id, *size_p);
+ }
+ else
+ {
+ dest = AllocFromHeap(heap_id, *size_p);
+ }
+ if (dest != NULL)
+ {
+ ReadWholeNarcMemberByIdPair(dest, narcId, memberNo);
+ if (isCompressed)
+ {
+ *size_p = (*(u32 *)dest) >> 8;
+ if (allocAtEnd == FALSE)
+ {
+ dest2 = AllocFromHeap(heap_id, *size_p);
+ }
+ else
+ {
+ dest2 = AllocFromHeapAtEnd(heap_id, *size_p);
+ }
+ if (dest2 != NULL)
+ {
+ MI_UncompressLZ8(dest, dest2);
+ FreeToHeap(dest);
+ }
+ dest = dest2; // UB: if dest2 is NULL, dest is never freed
+ }
+ }
+ return dest;
+}
diff --git a/arm9/src/gf_rtc.c b/arm9/src/gf_rtc.c
new file mode 100644
index 00000000..02fa735f
--- /dev/null
+++ b/arm9/src/gf_rtc.c
@@ -0,0 +1,183 @@
+#include "global.h"
+#include "MI_memory.h"
+#include "gf_rtc.h"
+#include "RTC_convert.h"
+
+typedef struct GF_RTC_Work
+{
+ BOOL getDateTimeSuccess;
+ BOOL getDateTimeLock;
+ s32 getDateTimeSleep;
+ RTCResult getDateTimeErrorCode;
+ RTCDate date; // 10
+ RTCTime time; // 20
+ RTCDate date_async; // 2C
+ RTCTime time_async; // 3C
+} GF_RTC_Work;
+
+GF_RTC_Work sGFRTCWork;
+
+#define MAX_SECONDS (3155759999ll)
+
+void GF_RTC_GetDateTime(GF_RTC_Work * work);
+
+THUMB_FUNC void GF_InitRTCWork(void)
+{
+ RTC_Init();
+ __builtin__clear(&sGFRTCWork, sizeof(sGFRTCWork));
+ sGFRTCWork.getDateTimeSuccess = FALSE;
+ sGFRTCWork.getDateTimeLock = FALSE;
+ sGFRTCWork.getDateTimeSleep = 0;
+ GF_RTC_GetDateTime(&sGFRTCWork);
+}
+
+THUMB_FUNC void GF_RTC_UpdateOnFrame(void)
+{
+ if (!sGFRTCWork.getDateTimeLock)
+ {
+ if (++sGFRTCWork.getDateTimeSleep > 10)
+ {
+ sGFRTCWork.getDateTimeSleep = 0;
+ GF_RTC_GetDateTime(&sGFRTCWork);
+ }
+ }
+}
+
+THUMB_FUNC void GF_RTC_GetDateTime_Callback(RTCResult result, void * data)
+{
+ GF_RTC_Work * work = (GF_RTC_Work *)data;
+ work->getDateTimeErrorCode = result;
+ GF_ASSERT(result == RTC_RESULT_SUCCESS);
+ work->getDateTimeSuccess = TRUE;
+ work->date = work->date_async;
+ work->time = work->time_async;
+ work->getDateTimeLock = FALSE;
+}
+
+THUMB_FUNC void GF_RTC_GetDateTime(GF_RTC_Work * work)
+{
+ work->getDateTimeLock = TRUE;
+ RTCResult result = RTC_GetDateTimeAsync(&work->date_async, &work->time_async, GF_RTC_GetDateTime_Callback, work);
+ work->getDateTimeErrorCode = result;
+ GF_ASSERT(result == RTC_RESULT_SUCCESS);
+}
+
+THUMB_FUNC void GF_RTC_CopyDateTime(RTCDate * date, RTCTime * time)
+{
+ GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
+ *date = sGFRTCWork.date;
+ *time = sGFRTCWork.time;
+}
+
+THUMB_FUNC void GF_RTC_CopyTime(RTCTime * time)
+{
+ GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
+ *time = sGFRTCWork.time;
+}
+
+THUMB_FUNC void GF_RTC_CopyDate(RTCDate * date)
+{
+ GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
+ *date = sGFRTCWork.date;
+}
+
+THUMB_FUNC s32 GF_RTC_TimeToSec(void)
+{
+ RTCTime* time = &sGFRTCWork.time;
+ return 60 * time->minute + 3600 * time->hour + time->second;
+}
+
+THUMB_FUNC s64 GF_RTC_DateTimeToSec(void)
+{
+ return RTC_ConvertDateTimeToSecond(&sGFRTCWork.date, &sGFRTCWork.time);
+}
+
+static inline BOOL IsLeapYear(s32 year)
+{
+ return ((year % 4) == 0 && (year % 100) != 0) || ((year % 400) == 0);
+}
+
+THUMB_FUNC s32 GF_RTC_GetDayOfYear(const RTCDate * date)
+{
+ RTCDate date_stack;
+ s32 days;
+ static const u16 sGF_DaysPerMonth[] = {
+ 0, // Jan
+ 31, // Feb
+ 59, // Mar
+ 90, // Apr
+ 120, // May
+ 151, // Jun
+ 181, // Jul
+ 212, // Aug
+ 243, // Sep
+ 273, // Oct
+ 304, // Nov
+ 334, // Dec
+ };
+
+ days = date->day;
+ days += sGF_DaysPerMonth[date->month - 1];
+ if (date->month >= RTC_MONTH_MARCH && IsLeapYear(date->year))
+ days++;
+ date_stack = *date;
+ date_stack.month = RTC_MONTH_JANUARY;
+ date_stack.day = 1;
+ RTC_ConvertDateToDay(&date_stack);
+ RTC_ConvertDateToDay(date);
+ return days;
+}
+
+enum RTC_TimeOfDay GF_RTC_GetTimeOfDay(void);
+enum RTC_TimeOfDay GF_RTC_GetTimeOfDayByHour(s32 hour);
+
+THUMB_FUNC BOOL IsNighttime(void)
+{
+ switch (GF_RTC_GetTimeOfDay())
+ {
+ case RTC_TIMEOFDAY_NITE:
+ case RTC_TIMEOFDAY_LATE:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+THUMB_FUNC enum RTC_TimeOfDay GF_RTC_GetTimeOfDay(void)
+{
+ RTCTime time;
+ GF_RTC_CopyTime(&time);
+ return GF_RTC_GetTimeOfDayByHour(time.hour);
+}
+
+THUMB_FUNC enum RTC_TimeOfDay GF_RTC_GetTimeOfDayByHour(s32 hour)
+{
+ static const u8 sTimeOfDayByHour[] = {
+ // 00:00 - 03:59
+ RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE,
+ // 04:00 - 09:59
+ RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN,
+ // 10:00 - 16:59
+ RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY,
+ // 17:00 - 19:59
+ RTC_TIMEOFDAY_EVE, RTC_TIMEOFDAY_EVE, RTC_TIMEOFDAY_EVE,
+ // 20:00 - 23:59
+ RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE,
+ };
+
+ GF_ASSERT(hour >= 0 && hour < 24);
+ return sTimeOfDayByHour[hour];
+}
+
+THUMB_FUNC s64 GF_RTC_TimeDelta(s64 first, s64 last)
+{
+ RTCDate maxDate = { 99, 12, 31, 0 };
+ RTCTime maxTime = { 23, 59, 59 };
+
+ s64 check = RTC_ConvertDateTimeToSecond(&maxDate, &maxTime);
+ GF_ASSERT(check == MAX_SECONDS);
+ if (first < last)
+ return last - first;
+ else
+ return last + (MAX_SECONDS - first);
+}
diff --git a/arm9/src/heap.c b/arm9/src/heap.c
index 84abc834..7f35fdcc 100644
--- a/arm9/src/heap.c
+++ b/arm9/src/heap.c
@@ -1,15 +1,16 @@
#include "heap.h"
#include "error_message_reset.h"
+#include "unk_02031734.h"
-extern void *tempName_NNS_FndCreateExpHeapEx(void *param0, u32 param1, u32 param2);
-extern void *tempName_NNS_FndAllocFromExpHeapEx(void *param0, u32 param1, s32 param2);
-extern void thunk_FUN_020adc8c();
-extern void FUN_020ADDF0(void *ptr1, void *ptr2);
-extern u32 FUN_02031810(void);
-extern u32 FUN_020ADDC8(void *param0);
-extern void FUN_020AE82C(u32 param0, void *param1, u32 param2);
-extern u32 FUN_020ADDC0(void *param0);
-extern void FUN_020ADE2C(void *ptr1, void *ptr2, u32 param2);
+
+extern void *NNS_FndCreateExpHeapEx(void *param0, u32 param1, u32 param2);
+extern void *NNS_FndAllocFromExpHeapEx(void *param0, u32 param1, s32 param2);
+extern void NNS_FndDestroyExpHeap();
+extern void NNS_FndFreeToExpHeap(void *ptr1, void *ptr2);
+extern u32 NNS_FndGetTotalFreeSizeForExpHeap(void *param0);
+extern void NNS_FndInitAllocatorForExpHeap(u32 param0, void *param1, u32 param2);
+extern u32 NNS_FndGetSizeForMBlockExpHeap(void *param0);
+extern void NNS_FndResizeForMBlockExpHeap(void *ptr1, void *ptr2, u32 param2);
struct UnkStruct_020166C8 UNK_021C4D28;
@@ -67,12 +68,12 @@ THUMB_FUNC void FUN_020166C8(u32 *param0, u32 param1, u32 param2, u32 pre_size)
if (ptr != 0)
{
- UNK_021C4D28.unk00[r7] = tempName_NNS_FndCreateExpHeapEx(ptr, param0[0], 0);
+ UNK_021C4D28.unk00[r7] = NNS_FndCreateExpHeapEx(ptr, param0[0], 0);
UNK_021C4D28.unk10[r7] = (u8)r7;
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
param0 += 2;
@@ -142,13 +143,13 @@ THUMB_FUNC u32 FUN_02016834(u32 param0, u32 param1, u32 param2, s32 param3)
void *ptr2 = UNK_021C4D28.unk00[ptr[param0]];
if (ptr2 != 0)
{
- void *ptr3 = tempName_NNS_FndAllocFromExpHeapEx(ptr2, param2, param3);
+ void *ptr3 = NNS_FndAllocFromExpHeapEx(ptr2, param2, param3);
if (ptr3 != 0)
{
param3 = FUN_020167F4();
if (param3 >= 0)
{
- UNK_021C4D28.unk00[param3] = tempName_NNS_FndCreateExpHeapEx(ptr3, param2, 0);
+ UNK_021C4D28.unk00[param3] = NNS_FndCreateExpHeapEx(ptr3, param2, 0);
if (UNK_021C4D28.unk00[param3] != 0)
@@ -161,27 +162,27 @@ THUMB_FUNC u32 FUN_02016834(u32 param0, u32 param1, u32 param2, s32 param3)
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
return 0;
}
@@ -192,18 +193,18 @@ THUMB_FUNC void FUN_020168D0(u32 heap_id)
if (UNK_021C4D28.unk00[UNK_021C4D28.unk10[heap_id]] != 0)
{
- thunk_FUN_020adc8c();
+ NNS_FndDestroyExpHeap();
u8 index = UNK_021C4D28.unk10[heap_id];
void *ptr1 = UNK_021C4D28.unk04[index];
void *ptr2 = UNK_021C4D28.unk08[index];
if (ptr1 != 0 && ptr2 != 0)
{
- FUN_020ADDF0(ptr1, ptr2);
+ NNS_FndFreeToExpHeap(ptr1, ptr2);
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
UNK_021C4D28.unk00[UNK_021C4D28.unk10[heap_id]] = 0;
@@ -220,7 +221,7 @@ THUMB_FUNC u32 *FUN_02016944(void *param0, u32 param1, s32 param2, u32 param3)
OSIntrMode intr_mode = OS_DisableInterrupts();
param1 += 16;
- u32 *ptr = (u32 *)tempName_NNS_FndAllocFromExpHeapEx(param0, param1, param2);
+ u32 *ptr = (u32 *)NNS_FndAllocFromExpHeapEx(param0, param1, param2);
OS_RestoreInterrupts(intr_mode);
if (ptr != 0)
@@ -300,15 +301,15 @@ void FreeToHeap(void *ptr)
UNK_021C4D28.unk0c[heap_id]--;
OSIntrMode intr_mode = OS_DisableInterrupts();
- FUN_020ADDF0(ptr2, ptr - 16);
+ NNS_FndFreeToExpHeap(ptr2, ptr - 16);
OS_RestoreInterrupts(intr_mode);
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
-void FUN_02016A8C(u32 param0, void *param1)
+void FreeToHeapExplicit(u32 param0, void *param1)
{
GF_ASSERT (OS_GetProcMode() != OS_PROCMODE_IRQ);
@@ -321,14 +322,14 @@ void FUN_02016A8C(u32 param0, void *param1)
u8 heap_id = (u8)((u32 *)param1)[-1];
GF_ASSERT (heap_id == param0);
- FUN_020ADDF0(ptr, param1 - 16);
+ NNS_FndFreeToExpHeap(ptr, param1 - 16);
GF_ASSERT (UNK_021C4D28.unk0c[param0]);
UNK_021C4D28.unk0c[param0]--;
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC u32 FUN_02016AF8(u32 param0)
@@ -336,10 +337,10 @@ THUMB_FUNC u32 FUN_02016AF8(u32 param0)
if (param0 < UNK_021C4D28.unk14)
{
u8 index = UNK_021C4D28.unk10[param0];
- return FUN_020ADDC8(UNK_021C4D28.unk00[index]);
+ return NNS_FndGetTotalFreeSizeForExpHeap(UNK_021C4D28.unk00[index]);
}
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
@@ -349,11 +350,11 @@ THUMB_FUNC void FUN_02016B20(u32 param0, u32 param1, u32 param2)
{
u8 index = UNK_021C4D28.unk10[param1];
- FUN_020AE82C(param0, UNK_021C4D28.unk00[index], param2);
+ NNS_FndInitAllocatorForExpHeap(param0, UNK_021C4D28.unk00[index], param2);
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC void FUN_02016B44(void *ptr, u32 param1)
@@ -361,16 +362,16 @@ THUMB_FUNC void FUN_02016B44(void *ptr, u32 param1)
GF_ASSERT (OS_GetProcMode() != OS_PROCMODE_IRQ);
param1 += 16;
- if (FUN_020ADDC0(ptr - 16) >= param1)
+ if (NNS_FndGetSizeForMBlockExpHeap(ptr - 16) >= param1)
{
u8 heap_id = (u8)((u32 *)ptr)[-1];
u8 index = UNK_021C4D28.unk10[heap_id];
- FUN_020ADE2C(UNK_021C4D28.unk00[index], ptr - 16, param1);
+ NNS_FndResizeForMBlockExpHeap(UNK_021C4D28.unk00[index], ptr - 16, param1);
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC u32 FUN_02016B90(u32 param0)
diff --git a/arm9/src/itemtool.c b/arm9/src/itemtool.c
index 6b892d6d..9982ff40 100644
--- a/arm9/src/itemtool.c
+++ b/arm9/src/itemtool.c
@@ -778,7 +778,7 @@ u32 GetItemAttr(u16 item, u32 attr, u32 heap_id)
u32 ret;
struct ItemData * itemData = (struct ItemData *)LoadItemDataOrGfx(item, 0, heap_id);
ret = GetItemAttr_PreloadedItemData(itemData, attr);
- FUN_02016A8C(heap_id, itemData);
+ FreeToHeapExplicit(heap_id, itemData);
return ret;
}
diff --git a/arm9/src/list_menu.c b/arm9/src/list_menu.c
new file mode 100644
index 00000000..033d06f9
--- /dev/null
+++ b/arm9/src/list_menu.c
@@ -0,0 +1,572 @@
+#include "global.h"
+#include "heap.h"
+#include "main.h"
+#include "list_menu.h"
+#include "text.h"
+
+void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count);
+void ListMenuDrawCursor(struct ListMenu * list);
+BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown);
+void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit);
+
+static inline u32 MakeFontColor(u32 fgPal, u32 shdwPal, u32 bgPal)
+{
+ return (u32)(
+ ((u32)(fgPal << 24) >> 8)
+ | ((u32)(shdwPal << 24) >> 16)
+ | ((u32)(bgPal << 24) >> 24)
+ );
+}
+
+THUMB_FUNC struct ListMenu * ListMenuInit(const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u32 heap_id)
+{
+ struct ListMenu * list = AllocFromHeap(heap_id, sizeof(struct ListMenu));
+ list->template = *template;
+ list->cursor = ListMenuCursorNew(heap_id);
+ list->cursorPos = cursorPos;
+ list->itemsAbove = itemsAbove;
+ list->unk_30 = 0;
+ list->unk_31 = 0;
+ list->taskId = 0xFF;
+ list->unk_33 = 0;
+ list->heap_id = (u8)heap_id;
+ list->cursorPal = list->template.cursorPal;
+ list->fillValue = list->template.fillValue;
+ list->cursorShadowPal = list->template.cursorShadowPal;
+ list->lettersSpacing = list->template.lettersSpacing;
+ list->fontId = list->template.fontId;
+ list->overrideEnabled = FALSE;
+ if (list->template.totalItems < list->template.maxShowed)
+ list->template.maxShowed = list->template.totalItems;
+ ListMenuCursorSetColor(
+ list->cursor,
+// MakeFontColor(list->template.cursorPal, list->template.cursorShadowPal, list->fillValue)
+ (u32)(
+ ((u32)(list->template.cursorPal << 24) >> 8)
+ | ((u32)(list->template.cursorShadowPal << 24) >> 16)
+ | ((u32)(list->template.fillValue << 24) >> 24)
+ )
+ );
+ FillWindowPixelBuffer(list->template.window, list->template.fillValue);
+ ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed);
+ ListMenuDrawCursor(list);
+ ListMenuCallSelectionChangedCallback(list, TRUE);
+ CopyWindowToVram(template->window);
+ return list;
+}
+
+THUMB_FUNC s32 ListMenu_ProcessInput(struct ListMenu * list)
+{
+ list->unk_33 = 0;
+
+ if (gMain.newKeys & REG_PAD_KEYINPUT_A_MASK) {
+ return list->template.items[list->cursorPos + list->itemsAbove].value;
+ }
+ else if (gMain.newKeys & REG_PAD_KEYINPUT_B_MASK) {
+ return LIST_CANCEL;
+ }
+ else if (gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_UP_MASK) {
+ if (!ListMenuChangeSelection(list, TRUE, 1, FALSE))
+ list->unk_33 = 1;
+ return LIST_NOTHING_CHOSEN;
+ }
+ else if (gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_DOWN_MASK) {
+ if (!ListMenuChangeSelection(list, TRUE, 1, TRUE))
+ list->unk_33 = 2;
+ return LIST_NOTHING_CHOSEN;
+ }
+ else
+ {
+ u16 rightButton, leftButton;
+ switch (list->template.scrollMultiple)
+ {
+ case LIST_NO_MULTIPLE_SCROLL:
+ default:
+ leftButton = FALSE;
+ rightButton = FALSE;
+ break;
+ case LIST_MULTIPLE_SCROLL_DPAD:
+ leftButton = (u16)(gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_LEFT_MASK);
+ rightButton = (u16)(gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_RIGHT_MASK);
+ break;
+ case LIST_MULTIPLE_SCROLL_L_R:
+ leftButton = (u16)(gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_L_MASK);
+ rightButton = (u16)(gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_R_MASK);
+ break;
+ }
+ if (leftButton)
+ {
+ if (!ListMenuChangeSelection(list, TRUE, (u8)list->template.maxShowed, FALSE))
+ list->unk_33 = 3;
+ return LIST_NOTHING_CHOSEN;
+ }
+ else if (rightButton)
+ {
+ if (!ListMenuChangeSelection(list, TRUE, (u8)list->template.maxShowed, TRUE))
+ list->unk_33 = 4;
+ return LIST_NOTHING_CHOSEN;
+ }
+ else
+ {
+ return LIST_NOTHING_CHOSEN;
+ }
+ }
+}
+
+THUMB_FUNC void DestroyListMenu(struct ListMenu * list, u16 * cursorPos, u16 * itemsAbove)
+{
+ if (cursorPos != NULL)
+ *cursorPos = list->cursorPos;
+ if (itemsAbove != NULL)
+ *itemsAbove = list->itemsAbove;
+ DestroyListMenuCursorObj(list->cursor);
+ FreeToHeapExplicit(list->heap_id, list);
+}
+
+THUMB_FUNC void RedrawListMenu(struct ListMenu * list)
+{
+ FillWindowPixelBuffer(list->template.window, list->template.fillValue);
+ ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed);
+ ListMenuDrawCursor(list);
+ CopyWindowToVram(list->template.window);
+}
+
+THUMB_FUNC s32 ListMenuTestInputInternal(struct ListMenu * list, const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u16 updateFlag, u16 input, u16 *newCursorPos, u16 *newItemsAbove)
+{
+ if (template != NULL)
+ list->template = *template;
+ list->cursorPos = cursorPos;
+ list->itemsAbove = itemsAbove;
+ list->unk_30 = 0;
+ list->unk_31 = 0;
+
+ if (input == REG_PAD_KEYINPUT_UP_MASK)
+ {
+ ListMenuChangeSelection(list, (u8)updateFlag, 1, FALSE);
+ }
+ else if (input == REG_PAD_KEYINPUT_DOWN_MASK)
+ {
+ ListMenuChangeSelection(list, (u8)updateFlag, 1, TRUE);
+ }
+ if (newCursorPos != NULL)
+ {
+ *newCursorPos = list->cursorPos;
+ }
+ if (newItemsAbove != NULL)
+ {
+ *newItemsAbove = list->itemsAbove;
+ }
+ return -1;
+}
+
+THUMB_FUNC s32 ListMenuTestInput(struct ListMenu * list, const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u16 input, u16 *newCursorPos, u16 *newItemsAbove)
+{
+ return ListMenuTestInputInternal(list, template, cursorPos, itemsAbove, FALSE, input, newCursorPos, newItemsAbove);
+}
+
+THUMB_FUNC void ListMenuOverrideSetColors(struct ListMenu * list, u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
+{
+ list->cursorPal = cursorPal;
+ list->fillValue = fillValue;
+ list->cursorShadowPal = cursorShadowPal;
+ list->overrideEnabled = TRUE;
+}
+
+THUMB_FUNC void ListMenuGetCurrentItemArrayId(struct ListMenu * list, u16 * index_p)
+{
+ *index_p = (u16)(list->cursorPos + list->itemsAbove);
+}
+
+THUMB_FUNC void ListMenuGetScrollAndRow(struct ListMenu * list, u16 * cursorPos_p, u16 * itemsAbove_p)
+{
+ if (cursorPos_p != NULL)
+ *cursorPos_p = list->cursorPos;
+ if (itemsAbove_p != NULL)
+ *itemsAbove_p = list->itemsAbove;
+}
+
+THUMB_FUNC u8 ListMenuGetUnk33(struct ListMenu * list)
+{
+ return list->unk_33;
+}
+
+THUMB_FUNC s32 ListMenuGetValueByArrayId(struct ListMenu * list, s32 index)
+{
+ return list->template.items[index].value;
+}
+
+THUMB_FUNC s32 ListMenuGetTemplateField(struct ListMenu * list, u32 attr)
+{
+ switch (attr)
+ {
+ case 0:
+ return (s32)list->template.moveCursorFunc;
+ case 1:
+ return (s32)list->template.itemPrintFunc;
+ case 2:
+ return (s32)list->template.totalItems;
+ case 3:
+ return (s32)list->template.maxShowed;
+ case 4:
+ break;
+ case 5:
+ return (s32)list->template.header_X;
+ case 6:
+ return (s32)list->template.item_X;
+ case 7:
+ return (s32)list->template.cursor_X;
+ case 8:
+ return (s32)list->template.upText_Y;
+ case 9:
+ return GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding;
+ case 10:
+ return (s32)list->template.cursorPal;
+ case 11:
+ return (s32)list->template.fillValue;
+ case 12:
+ return (s32)list->template.cursorShadowPal;
+ case 13:
+ return (s32)list->template.lettersSpacing;
+ case 14:
+ return (s32)list->template.itemVerticalPadding;
+ case 15:
+ return (s32)list->template.scrollMultiple;
+ case 16:
+ return (s32)list->template.fontId;
+ case 17:
+ return (s32)list->template.cursorKind;
+ case 18:
+ return (s32)list->template.window;
+ case 19:
+ return (s32)list->template.unk_1C;
+ }
+
+ return -1;
+}
+
+THUMB_FUNC void ListMenuSetTemplateField(struct ListMenu * list, u32 attr, s32 value)
+{
+ switch (attr)
+ {
+ case 0:
+ list->template.moveCursorFunc = (LM_MoveCursorFunc_t)value;
+ break;
+ case 1:
+ list->template.itemPrintFunc = (LM_ItemPrintFunc_t)value;
+ break;
+ case 2:
+ list->template.totalItems = (u16)value;
+ break;
+ case 3:
+ list->template.maxShowed = (u16)value;
+ break;
+ case 4:
+ break;
+ case 5:
+ list->template.header_X = (u8)value;
+ break;
+ case 6:
+ list->template.item_X = (u8)value;
+ break;
+ case 7:
+ list->template.cursor_X = (u8)value;
+ break;
+ case 8:
+ list->template.upText_Y = (u8)value;
+ break;
+ case 9:
+ break;
+ case 10:
+ list->template.cursorPal = (u8)value;
+ break;
+ case 11:
+ list->template.fillValue = (u8)value;
+ break;
+ case 12:
+ list->template.cursorShadowPal = (u8)value;
+ break;
+ case 13:
+ list->template.lettersSpacing = (u8)value;
+ break;
+ case 14:
+ list->template.itemVerticalPadding = (u8)value;
+ break;
+ case 15:
+ list->template.scrollMultiple = (u8)value;
+ break;
+ case 16:
+ list->template.fontId = (u8)value;
+ break;
+ case 17:
+ list->template.cursorKind = (u8)value;
+ break;
+ case 18:
+ list->template.window = (struct Window *)value;
+ break;
+ case 19:
+ list->template.unk_1C = (u32)value;
+ break;
+ }
+}
+
+THUMB_FUNC void ListMenuGetItemStr(struct ListMenu * list, struct ListMenuItem * items)
+{
+ list->template.items = items;
+}
+
+THUMB_FUNC void ListMenuPrint(struct ListMenu * list, struct String * str, u8 x, u8 y)
+{
+ if (str != NULL)
+ {
+ if (list->overrideEnabled)
+ {
+ AddTextPrinterParameterized3(list->template.window, list->fontId, str, x, y, 0xFF, MakeFontColor(list->cursorPal, list->cursorShadowPal, list->fillValue), list->lettersSpacing, 0, NULL);
+ }
+ else
+ {
+ AddTextPrinterParameterized3(list->template.window, list->template.fontId, str, x, y, 0xFF, MakeFontColor(list->template.cursorPal, list->template.cursorShadowPal, list->template.fillValue), list->template.lettersSpacing, 0, NULL);
+ }
+ }
+}
+
+THUMB_FUNC void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count)
+{
+ s32 i;
+ u8 x, y;
+ u8 yMultiplier = (u8)(GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding);
+
+ for (i = 0; i < count; i++)
+ {
+ if (list->template.items[startIndex].value != LIST_HEADER)
+ x = list->template.item_X;
+ else
+ x = list->template.header_X;
+ y = (u8)((yOffset + i) * yMultiplier + list->template.upText_Y);
+ if (list->template.itemPrintFunc != NULL)
+ list->template.itemPrintFunc(list, list->template.items[startIndex].value, y);
+ ListMenuPrint(list, list->template.items[startIndex].text, x, y);
+ startIndex++;
+ }
+}
+
+THUMB_FUNC void ListMenuDrawCursor(struct ListMenu * list)
+{
+ u8 yMultiplier = (u8)(GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding);
+ u8 x = list->template.cursor_X;
+ u8 y = (u8)(list->itemsAbove * yMultiplier + list->template.upText_Y);
+ switch (list->template.cursorKind)
+ {
+ case 0:
+ ListMenuUpdateCursorObj(list->cursor, list->template.window, x, y);
+ break;
+ case 1:
+ case 2: // leftover
+ case 3: // leftover
+ break;
+ }
+}
+
+THUMB_FUNC void ListMenuErasePrintedCursor(struct ListMenu * list, u16 itemsAbove)
+{
+ switch (list->template.cursorKind)
+ {
+ case 0:
+ u8 yMultiplier = (u8)(GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding);
+ u8 width = 8;
+ u8 height = 16;
+ FillWindowPixelRect(list->template.window,
+ list->template.fillValue,
+ list->template.cursor_X,
+ (u16)(itemsAbove * yMultiplier + list->template.upText_Y),
+ width,
+ height);
+ break;
+ case 1:
+ case 2: // leftover
+ case 3: // leftover
+ break;
+ }
+}
+
+THUMB_FUNC u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, u8 movingDown)
+{
+ u32 cursorPos;
+ u16 itemsAbove;
+ u16 newRow;
+
+ itemsAbove = list->itemsAbove;
+ cursorPos = list->cursorPos;
+
+ if (!movingDown)
+ {
+ if (list->template.maxShowed == 1)
+ newRow = 0;
+ else
+ newRow = (u16)(list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1);
+
+ if (cursorPos == 0)
+ {
+ while (itemsAbove != 0)
+ {
+ itemsAbove--;
+ if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
+ {
+ list->itemsAbove = itemsAbove;
+ return 1;
+ }
+ }
+ return 0;
+ }
+ else
+ {
+ while (itemsAbove > newRow)
+ {
+ itemsAbove--;
+ if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
+ {
+ list->itemsAbove = itemsAbove;
+ return 1;
+ }
+ }
+ list->itemsAbove = newRow;
+ list->cursorPos = (u16)(cursorPos - 1);
+ }
+ }
+ else
+ {
+ if (list->template.maxShowed == 1)
+ newRow = 0;
+ else
+ newRow = (u16)((list->template.maxShowed / 2) + (list->template.maxShowed % 2));
+
+ if (cursorPos == list->template.totalItems - list->template.maxShowed)
+ {
+ while (itemsAbove < list->template.maxShowed - 1)
+ {
+ itemsAbove++;
+ if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
+ {
+ list->itemsAbove = itemsAbove;
+ return 1;
+ }
+ }
+ return 0;
+ }
+ else
+ {
+ while (itemsAbove < newRow)
+ {
+ itemsAbove++;
+ if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
+ {
+ list->itemsAbove = itemsAbove;
+ return 1;
+ }
+ }
+ list->itemsAbove = newRow;
+ list->cursorPos = (u16)(cursorPos + 1);
+ }
+ }
+ return 2;
+}
+
+THUMB_FUNC void ListMenuScroll(struct ListMenu * list, u8 count, u8 movingDown)
+{
+ if (count >= list->template.maxShowed)
+ {
+ FillWindowPixelBuffer(list->template.window, list->template.fillValue);
+ ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed);
+ }
+ else
+ {
+ u8 yMultiplier = (u8)(GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding);
+
+ if (!movingDown)
+ {
+ u16 y, width, height;
+
+ ScrollWindow(list->template.window, 1, (u8)(count * yMultiplier), (u8)((list->template.fillValue << 4) | list->template.fillValue));
+ ListMenuPrintEntries(list, list->cursorPos, 0, count);
+
+ y = (u16)((list->template.maxShowed * yMultiplier) + list->template.upText_Y);
+ width = GetWindowWidth(list->template.window);
+ height = GetWindowHeight(list->template.window);
+ FillWindowPixelRect(list->template.window,
+ list->template.fillValue,
+ 0, y, (u16)(width * 8), (u16)(height * 8 - y));
+ }
+ else
+ {
+ u32 width;
+
+ ScrollWindow(list->template.window, 0, (u8)(count * yMultiplier), (u8)((list->template.fillValue << 4) | list->template.fillValue));
+ ListMenuPrintEntries(list, (u16)(list->cursorPos + (list->template.maxShowed - count)), (u16)(list->template.maxShowed - count), count);
+
+ width = GetWindowWidth(list->template.window);
+ FillWindowPixelRect(list->template.window,
+ list->template.fillValue,
+ 0, 0, (u16)(width * 8), list->template.upText_Y);
+ }
+ }
+}
+
+THUMB_FUNC BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown)
+{
+ u16 oldSelectedRow;
+ u8 selectionChange, i, cursorCount;
+
+ oldSelectedRow = list->itemsAbove;
+ cursorCount = 0;
+ selectionChange = 0;
+ for (i = 0; i < count; i++)
+ {
+ do
+ {
+ u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown);
+
+ selectionChange |= ret;
+ if (ret != 2)
+ break;
+ cursorCount++;
+ }
+ while (list->template.items[list->cursorPos + list->itemsAbove].value == LIST_HEADER);
+ }
+
+ if (updateCursorAndCallCallback)
+ {
+ switch (selectionChange)
+ {
+ case 0:
+ default:
+ return TRUE;
+ case 1:
+ ListMenuErasePrintedCursor(list, oldSelectedRow);
+ ListMenuDrawCursor(list);
+ ListMenuCallSelectionChangedCallback(list, FALSE);
+ CopyWindowToVram(list->template.window);
+ break;
+ case 2:
+ case 3:
+ ListMenuErasePrintedCursor(list, oldSelectedRow);
+ ListMenuScroll(list, cursorCount, movingDown);
+ ListMenuDrawCursor(list);
+ ListMenuCallSelectionChangedCallback(list, FALSE);
+ CopyWindowToVram(list->template.window);
+ break;
+ }
+ }
+ return FALSE;
+}
+
+THUMB_FUNC void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit)
+{
+ if (list->template.moveCursorFunc != NULL)
+ {
+ list->template.moveCursorFunc(list, list->template.items[list->cursorPos + list->itemsAbove].value, onInit);
+ }
+}
+
+THUMB_FUNC void ListMenuCopyToVram(struct ListMenu * list)
+{
+ CopyWindowToVram(list->template.window);
+}
diff --git a/arm9/src/list_menu_items.c b/arm9/src/list_menu_items.c
new file mode 100644
index 00000000..3aa5b0a0
--- /dev/null
+++ b/arm9/src/list_menu_items.c
@@ -0,0 +1,92 @@
+#include "global.h"
+#include "list_menu_items.h"
+#include "msgdata.h"
+#include "heap.h"
+
+void ListMenuItems_DestroyMenuStrings(struct ListMenuItem * items);
+
+THUMB_FUNC struct ListMenuItem * ListMenuItems_ctor(u32 count, u32 heap_id)
+{
+ s32 i;
+ struct ListMenuItem * ret = AllocFromHeap(heap_id, (count + 1) * sizeof(struct ListMenuItem));
+ if (ret != NULL)
+ {
+ for (i = 0; i < count; i++)
+ {
+ ret[i].text = NULL;
+ ret[i].value = 0;
+ }
+ ret[i].text = (struct String *)-1u;
+ ret[i].value = (s32)heap_id;
+ }
+ return ret;
+}
+
+THUMB_FUNC void ListMenuItems_dtor(struct ListMenuItem * items)
+{
+ ListMenuItems_DestroyMenuStrings(items);
+ FreeToHeap(items);
+}
+
+THUMB_FUNC void ListMenuItems_AppendFromMsgData(struct ListMenuItem * items, struct MsgData * msgData, u32 msgNo, s32 value)
+{
+ u32 heap_id;
+ struct ListMenuItem * newItem = ListMenuItems_SeekEnd(items, &heap_id);
+ if (newItem != NULL)
+ {
+ newItem->text = NewString_ReadMsgData(msgData, msgNo);
+ newItem->value = value;
+ }
+}
+
+THUMB_FUNC void ListMenuItems_AddItem(struct ListMenuItem * items, struct String * str, s32 value)
+{
+ u32 heap_id;
+ struct ListMenuItem * newItem = ListMenuItems_SeekEnd(items, &heap_id);
+ if (newItem != NULL)
+ {
+ newItem->text = StringDup(str, heap_id);
+ newItem->value = value;
+ }
+}
+
+THUMB_FUNC void ListMenuItems_CopyItem(struct ListMenuItem * items, struct ListMenuItem * src)
+{
+ u32 heap_id;
+ struct ListMenuItem * newItem = ListMenuItems_SeekEnd(items, &heap_id);
+ if (newItem != NULL)
+ {
+ newItem->text = src->text;
+ newItem->value = src->value;
+ }
+}
+
+THUMB_FUNC struct ListMenuItem * ListMenuItems_SeekEnd(struct ListMenuItem * items, u32 * heap_id_p)
+{
+ struct ListMenuItem * ret;
+ for (; items->text != NULL; items++)
+ {
+ if (items->text == (struct String *)-1u)
+ {
+ GF_ASSERT(0);
+ return NULL;
+ }
+ }
+ ret = items;
+ for (; items->text != (struct String *)-1u; items++)
+ ;
+ *heap_id_p = (u32)items->value;
+ return ret;
+}
+
+THUMB_FUNC void ListMenuItems_DestroyMenuStrings(struct ListMenuItem * items)
+{
+ s32 i;
+ for (i = 0; items[i].text != (struct String *)-1u; i++)
+ {
+ if (items[i].text == NULL)
+ break;
+ String_dtor(items[i].text);
+ items[i].text = NULL;
+ }
+}
diff --git a/arm9/src/main.c b/arm9/src/main.c
index c50fbaff..749bec41 100644
--- a/arm9/src/main.c
+++ b/arm9/src/main.c
@@ -12,32 +12,25 @@
#include "player_data.h"
#include "sound.h"
#include "timer3.h"
+#include "unk_02031734.h"
+#include "unk_0202F150.h"
+#include "module_52.h"
FS_EXTERN_OVERLAY(MODULE_52);
FS_EXTERN_OVERLAY(MODULE_63);
#define SOFT_RESET_KEY (PAD_BUTTON_L | PAD_BUTTON_R | PAD_BUTTON_START | PAD_BUTTON_SELECT)
-struct Unk2106FA0 gBacklightTop;
+s32 UNK_02016FA4;
+PMBackLightSwitch gBacklightTop;
+struct UnkStruct_02016FA8 UNK_02016FA8;
-extern BOOL OverlayManager_new(struct Unk21DBE18 *, s32 *, int);
-extern BOOL OverlayManager_Run(int);
-extern void OverlayManager_delete(int);
-extern BOOL FUN_02033678(void);
-extern u32 FUN_020335B8(void);
-extern BOOL FUN_0202FB80(void);
-
-extern void InitSystemForTheGame(void);
-extern void InitGraphicMemory(void);
extern void FUN_02022294(void);
extern void GF_InitRTCWork(void);
extern void FUN_02002C14(void);
extern void FUN_02002C50(int, int);
-extern struct SaveBlock2 * SaveBlock2_new(void);
-extern void * FUN_02029EF8(struct SaveBlock2 *);
extern int FUN_020337E8(int);
extern void FUN_02034188(int, int);
-extern int FUN_020227FC(struct SaveBlock2 *);
extern void FUN_02089D90(int);
extern void FUN_0200A2AC(void);
extern void FUN_02015E30(void);
@@ -49,13 +42,13 @@ extern void FUN_0200A318(void);
extern void FUN_0200E2D8(void);
extern struct Unk21DBE18 MOD63_021DBE18;
-extern struct Unk21DBE18 MOD52_021D76C8;
extern u8 SDK_STATIC_BSS_START[];
-const int gGameVersion = GAME_VERSION;
const int gGameLanguage = GAME_LANGUAGE;
+const int gGameVersion = GAME_VERSION;
+__declspec(noreturn)
THUMB_FUNC void NitroMain(void)
{
InitSystemForTheGame();
@@ -72,13 +65,13 @@ THUMB_FUNC void NitroMain(void)
FUN_02002C50(0, 3);
FUN_02002C50(1, 3);
FUN_02002C50(3, 3);
- gBacklightTop.unk18 = -1;
- gBacklightTop.unk20 = SaveBlock2_new();
- InitSoundData(FUN_02029EF8(gBacklightTop.unk20), Sav2_PlayerData_GetOptionsAddr(gBacklightTop.unk20));
+ UNK_02016FA8.unk10 = -1;
+ UNK_02016FA8.unk18 = SaveBlock2_new();
+ InitSoundData(Sav2_Chatot_get(UNK_02016FA8.unk18), Sav2_PlayerData_GetOptionsAddr(UNK_02016FA8.unk18));
Init_Timer3();
if (FUN_020337E8(3) == 3)
FUN_02034188(3, 0);
- if (FUN_020227FC(gBacklightTop.unk20) == 0)
+ if (FUN_020227FC(UNK_02016FA8.unk18) == 0)
{
FUN_02089D90(0);
}
@@ -88,12 +81,12 @@ THUMB_FUNC void NitroMain(void)
{
case 0:
// Title Demo
- gBacklightTop.unk1C = 0;
+ UNK_02016FA8.unk14 = 0;
RegisterMainOverlay(FS_OVERLAY_ID(MODULE_63), &MOD63_021DBE18);
break;
case 1:
// Reset transition?
- gBacklightTop.unk1C = 1;
+ UNK_02016FA8.unk14 = 1;
RegisterMainOverlay(FS_OVERLAY_ID(MODULE_52), &MOD52_021D76C8);
break;
default:
@@ -106,7 +99,7 @@ THUMB_FUNC void NitroMain(void)
InitializeMainRNG();
FUN_0200A2AC();
FUN_02015E30();
- gBacklightTop.unk4 = 0;
+ UNK_02016FA4 = 0;
for (;;)
{
FUN_02000EE8();
@@ -145,40 +138,40 @@ THUMB_FUNC void NitroMain(void)
THUMB_FUNC void FUN_02000DF4(void)
{
- gBacklightTop.unk8 = (FSOverlayID)-1;
- gBacklightTop.unkC = 0;
- gBacklightTop.unk10 = (FSOverlayID)-1; // overlay invalid
- gBacklightTop.unk14 = NULL;
+ UNK_02016FA8.unk0 = SDK_OVERLAY_INVALID_ID;
+ UNK_02016FA8.unk4 = NULL;
+ UNK_02016FA8.unk8 = SDK_OVERLAY_INVALID_ID; // overlay invalid
+ UNK_02016FA8.unkC = NULL;
}
THUMB_FUNC void Main_RunOverlayManager(void)
{
- if (!gBacklightTop.unkC)
+ if (UNK_02016FA8.unk4 == NULL)
{
- if (gBacklightTop.unk14 == NULL)
+ if (UNK_02016FA8.unkC == NULL)
return;
- if (gBacklightTop.unk10 != SDK_OVERLAY_INVALID_ID)
- HandleLoadOverlay(gBacklightTop.unk10, 0);
- gBacklightTop.unk8 = gBacklightTop.unk10;
- gBacklightTop.unkC = OverlayManager_new(gBacklightTop.unk14, &gBacklightTop.unk18, 0);
- gBacklightTop.unk10 = SDK_OVERLAY_INVALID_ID;
- gBacklightTop.unk14 = NULL;
+ if (UNK_02016FA8.unk8 != SDK_OVERLAY_INVALID_ID)
+ HandleLoadOverlay(UNK_02016FA8.unk8, 0);
+ UNK_02016FA8.unk0 = UNK_02016FA8.unk8;
+ UNK_02016FA8.unk4 = OverlayManager_new(UNK_02016FA8.unkC, &UNK_02016FA8.unk10, 0);
+ UNK_02016FA8.unk8 = SDK_OVERLAY_INVALID_ID;
+ UNK_02016FA8.unkC = NULL;
}
- if (OverlayManager_Run(gBacklightTop.unkC))
+ if (OverlayManager_Run(UNK_02016FA8.unk4))
{
- OverlayManager_delete(gBacklightTop.unkC);
- gBacklightTop.unkC = 0;
- if (gBacklightTop.unk8 != SDK_OVERLAY_INVALID_ID)
- UnloadOverlayByID(gBacklightTop.unk8);
+ OverlayManager_delete(UNK_02016FA8.unk4);
+ UNK_02016FA8.unk4 = NULL;
+ if (UNK_02016FA8.unk0 != SDK_OVERLAY_INVALID_ID)
+ UnloadOverlayByID(UNK_02016FA8.unk0);
}
}
-THUMB_FUNC void RegisterMainOverlay(FSOverlayID id, struct Unk21DBE18 * arg1)
+THUMB_FUNC void RegisterMainOverlay(FSOverlayID id, const struct Unk21DBE18 * arg1)
{
- if (gBacklightTop.unk14 != NULL)
- ErrorHandling();
- gBacklightTop.unk10 = id;
- gBacklightTop.unk14 = arg1;
+ if (UNK_02016FA8.unkC != NULL)
+ GF_AssertFail();
+ UNK_02016FA8.unk8 = id;
+ UNK_02016FA8.unkC = arg1;
}
THUMB_FUNC void FUN_02000E9C(void)
@@ -218,9 +211,8 @@ THUMB_FUNC void FUN_02000EE8(void)
}
extern void FUN_0200E3A0(PMLCDTarget, int);
-extern BOOL FUN_02032DAC(void);
-// No Return
+__declspec(noreturn)
THUMB_FUNC void DoSoftReset(u32 parameter)
{
FUN_0200E3A0(PM_LCD_TOP, 0x7FFF);
@@ -257,7 +249,7 @@ THUMB_FUNC void FUN_02000F4C(u32 arg0, u32 arg1)
{
HandleDSLidAction();
FUN_02016464();
- if (gMain.unk48 & 1)
+ if (gMain.newKeys & 1)
break;
FUN_02000E9C();
}
@@ -294,10 +286,10 @@ THUMB_FUNC void HandleDSLidAction(void)
FUN_0201CE04();
if (CTRDG_IsPulledOut() == TRUE)
{
- gBacklightTop.unk4 = 1;
+ UNK_02016FA4 = 1;
}
{
- int r1 = gBacklightTop.unk4;
+ int r1 = UNK_02016FA4;
while (1)
{
PMWakeUpTrigger trigger = PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD;
@@ -311,7 +303,7 @@ THUMB_FUNC void HandleDSLidAction(void)
}
else if (PAD_DetectFold())
{
- r1 = gBacklightTop.unk4 = 1;
+ r1 = UNK_02016FA4 = 1;
}
else
break;
@@ -331,6 +323,6 @@ THUMB_FUNC void HandleDSLidAction(void)
{
PM_GetBackLight(&top, &bottom);
if (top == PM_BACKLIGHT_OFF)
- PM_SetBackLight(PM_LCD_ALL, gBacklightTop.unk0);
+ PM_SetBackLight(PM_LCD_ALL, gBacklightTop);
}
}
diff --git a/arm9/src/math_util.c b/arm9/src/math_util.c
index 5aeb4f8e..ac3b77f0 100644
--- a/arm9/src/math_util.c
+++ b/arm9/src/math_util.c
@@ -1,129 +1,466 @@
#include "global.h"
#include "math_util.h"
-extern const s16 UNK_020FFA38[]; // temporary until further notice
+extern const s16 FX_SinCosTable_[]; // temporary until further notice
/*
* Constant tables
*/
-const s32 gSineTable[] =
+const fx32 gSineTable[] =
{
- 0x00000000, 0x00000047, 0x0000008F, 0x000000D6,
- 0x0000011E, 0x00000165, 0x000001AC, 0x000001F3,
- 0x0000023A, 0x00000281, 0x000002C7, 0x0000030E,
- 0x00000354, 0x00000399, 0x000003DF, 0x00000424,
- 0x00000469, 0x000004AE, 0x000004F2, 0x00000536,
- 0x00000579, 0x000005BC, 0x000005FE, 0x00000640,
- 0x00000682, 0x000006C3, 0x00000704, 0x00000744,
- 0x00000783, 0x000007C2, 0x00000800, 0x0000083E,
- 0x0000087B, 0x000008B7, 0x000008F2, 0x0000092D,
- 0x00000968, 0x000009A1, 0x000009DA, 0x00000A12,
- 0x00000A49, 0x00000A7F, 0x00000AB5, 0x00000AE9,
- 0x00000B1D, 0x00000B50, 0x00000B82, 0x00000BB4,
- 0x00000BE4, 0x00000C13, 0x00000C42, 0x00000C6F,
- 0x00000C9C, 0x00000CC7, 0x00000CF2, 0x00000D1B,
- 0x00000D44, 0x00000D6B, 0x00000D92, 0x00000DB7,
- 0x00000DDB, 0x00000DFE, 0x00000E21, 0x00000E42,
- 0x00000E61, 0x00000E80, 0x00000E9E, 0x00000EBA,
- 0x00000ED6, 0x00000EF0, 0x00000F09, 0x00000F21,
- 0x00000F38, 0x00000F4D, 0x00000F61, 0x00000F74,
- 0x00000F86, 0x00000F97, 0x00000FA6, 0x00000FB5,
- 0x00000FC2, 0x00000FCE, 0x00000FD8, 0x00000FE1,
- 0x00000FEA, 0x00000FF0, 0x00000FF6, 0x00000FFA,
- 0x00000FFE, 0x00000FFF, 0x00001000, 0x00000FFF,
- 0x00000FFE, 0x00000FFA, 0x00000FF6, 0x00000FF0,
- 0x00000FEA, 0x00000FE1, 0x00000FD8, 0x00000FCE,
- 0x00000FC2, 0x00000FB5, 0x00000FA6, 0x00000F97,
- 0x00000F86, 0x00000F74, 0x00000F61, 0x00000F4D,
- 0x00000F38, 0x00000F21, 0x00000F09, 0x00000EF0,
- 0x00000ED6, 0x00000EBA, 0x00000E9E, 0x00000E80,
- 0x00000E61, 0x00000E42, 0x00000E21, 0x00000DFE,
- 0x00000DDB, 0x00000DB7, 0x00000D92, 0x00000D6B,
- 0x00000D44, 0x00000D1B, 0x00000CF2, 0x00000CC7,
- 0x00000C9C, 0x00000C6F, 0x00000C42, 0x00000C13,
- 0x00000BE4, 0x00000BB4, 0x00000B82, 0x00000B50,
- 0x00000B1D, 0x00000AE9, 0x00000AB5, 0x00000A7F,
- 0x00000A49, 0x00000A12, 0x000009DA, 0x000009A1,
- 0x00000968, 0x0000092D, 0x000008F2, 0x000008B7,
- 0x0000087B, 0x0000083E, 0x00000800, 0x000007C2,
- 0x00000783, 0x00000744, 0x00000704, 0x000006C3,
- 0x00000682, 0x00000640, 0x000005FE, 0x000005BC,
- 0x00000579, 0x00000536, 0x000004F2, 0x000004AE,
- 0x00000469, 0x00000424, 0x000003DF, 0x00000399,
- 0x00000354, 0x0000030E, 0x000002C7, 0x00000281,
- 0x0000023A, 0x000001F3, 0x000001AC, 0x00000165,
- 0x0000011E, 0x000000D6, 0x0000008F, 0x00000047,
- 0x00000000, 0xFFFFFFB9, 0xFFFFFF71, 0xFFFFFF2A,
- 0xFFFFFEE2, 0xFFFFFE9B, 0xFFFFFE54, 0xFFFFFE0D,
- 0xFFFFFDC6, 0xFFFFFD7F, 0xFFFFFD39, 0xFFFFFCF2,
- 0xFFFFFCAC, 0xFFFFFC67, 0xFFFFFC21, 0xFFFFFBDC,
- 0xFFFFFB97, 0xFFFFFB52, 0xFFFFFB0E, 0xFFFFFACA,
- 0xFFFFFA87, 0xFFFFFA44, 0xFFFFFA02, 0xFFFFF9C0,
- 0xFFFFF97E, 0xFFFFF93D, 0xFFFFF8FC, 0xFFFFF8BC,
- 0xFFFFF87D, 0xFFFFF83E, 0xFFFFF800, 0xFFFFF7C2,
- 0xFFFFF785, 0xFFFFF749, 0xFFFFF70E, 0xFFFFF6D3,
- 0xFFFFF698, 0xFFFFF65F, 0xFFFFF626, 0xFFFFF5EE,
- 0xFFFFF5B7, 0xFFFFF581, 0xFFFFF54B, 0xFFFFF517,
- 0xFFFFF4E3, 0xFFFFF4B0, 0xFFFFF47E, 0xFFFFF44C,
- 0xFFFFF41C, 0xFFFFF3ED, 0xFFFFF3BE, 0xFFFFF391,
- 0xFFFFF364, 0xFFFFF339, 0xFFFFF30E, 0xFFFFF2E5,
- 0xFFFFF2BC, 0xFFFFF295, 0xFFFFF26E, 0xFFFFF249,
- 0xFFFFF225, 0xFFFFF202, 0xFFFFF1DF, 0xFFFFF1BE,
- 0xFFFFF19F, 0xFFFFF180, 0xFFFFF162, 0xFFFFF146,
- 0xFFFFF12A, 0xFFFFF110, 0xFFFFF0F7, 0xFFFFF0DF,
- 0xFFFFF0C8, 0xFFFFF0B3, 0xFFFFF09F, 0xFFFFF08C,
- 0xFFFFF07A, 0xFFFFF069, 0xFFFFF05A, 0xFFFFF04B,
- 0xFFFFF03E, 0xFFFFF032, 0xFFFFF028, 0xFFFFF01F,
- 0xFFFFF016, 0xFFFFF010, 0xFFFFF00A, 0xFFFFF006,
- 0xFFFFF002, 0xFFFFF001, 0xFFFFF000, 0xFFFFF001,
- 0xFFFFF002, 0xFFFFF006, 0xFFFFF00A, 0xFFFFF010,
- 0xFFFFF016, 0xFFFFF01F, 0xFFFFF028, 0xFFFFF032,
- 0xFFFFF03E, 0xFFFFF04B, 0xFFFFF05A, 0xFFFFF069,
- 0xFFFFF07A, 0xFFFFF08C, 0xFFFFF09F, 0xFFFFF0B3,
- 0xFFFFF0C8, 0xFFFFF0DF, 0xFFFFF0F7, 0xFFFFF110,
- 0xFFFFF12A, 0xFFFFF146, 0xFFFFF162, 0xFFFFF180,
- 0xFFFFF19F, 0xFFFFF1BE, 0xFFFFF1DF, 0xFFFFF202,
- 0xFFFFF225, 0xFFFFF249, 0xFFFFF26E, 0xFFFFF295,
- 0xFFFFF2BC, 0xFFFFF2E5, 0xFFFFF30E, 0xFFFFF339,
- 0xFFFFF364, 0xFFFFF391, 0xFFFFF3BE, 0xFFFFF3ED,
- 0xFFFFF41C, 0xFFFFF44C, 0xFFFFF47E, 0xFFFFF4B0,
- 0xFFFFF4E3, 0xFFFFF517, 0xFFFFF54B, 0xFFFFF581,
- 0xFFFFF5B7, 0xFFFFF5EE, 0xFFFFF626, 0xFFFFF65F,
- 0xFFFFF698, 0xFFFFF6D3, 0xFFFFF70E, 0xFFFFF749,
- 0xFFFFF785, 0xFFFFF7C2, 0xFFFFF800, 0xFFFFF83E,
- 0xFFFFF87D, 0xFFFFF8BC, 0xFFFFF8FC, 0xFFFFF93D,
- 0xFFFFF97E, 0xFFFFF9C0, 0xFFFFFA02, 0xFFFFFA44,
- 0xFFFFFA87, 0xFFFFFACA, 0xFFFFFB0E, 0xFFFFFB52,
- 0xFFFFFB97, 0xFFFFFBDC, 0xFFFFFC21, 0xFFFFFC67,
- 0xFFFFFCAC, 0xFFFFFCF2, 0xFFFFFD39, 0xFFFFFD7F,
- 0xFFFFFDC6, 0xFFFFFE0D, 0xFFFFFE54, 0xFFFFFE9B,
- 0xFFFFFEE2, 0xFFFFFF2A, 0xFFFFFF71, 0xFFFFFFB9,
- 0x00000000, 0x00000047, 0x0000008F, 0x000000D6,
- 0x0000011E, 0x00000165, 0x000001AC, 0x000001F3,
- 0x0000023A, 0x00000281, 0x000002C7, 0x0000030E,
- 0x00000354, 0x00000399, 0x000003DF, 0x00000424,
- 0x00000469, 0x000004AE, 0x000004F2, 0x00000536,
- 0x00000579, 0x000005BC, 0x000005FE, 0x00000640,
- 0x00000682, 0x000006C3, 0x00000704, 0x00000744,
- 0x00000783, 0x000007C2, 0x00000800, 0x0000083E,
- 0x0000087B, 0x000008B7, 0x000008F2, 0x0000092D,
- 0x00000968, 0x000009A1, 0x000009DA, 0x00000A12,
- 0x00000A49, 0x00000A7F, 0x00000AB5, 0x00000AE9,
- 0x00000B1D, 0x00000B50, 0x00000B82, 0x00000BB4,
- 0x00000BE4, 0x00000C13, 0x00000C42, 0x00000C6F,
- 0x00000C9C, 0x00000CC7, 0x00000CF2, 0x00000D1B,
- 0x00000D44, 0x00000D6B, 0x00000D92, 0x00000DB7,
- 0x00000DDB, 0x00000DFE, 0x00000E21, 0x00000E42,
- 0x00000E61, 0x00000E80, 0x00000E9E, 0x00000EBA,
- 0x00000ED6, 0x00000EF0, 0x00000F09, 0x00000F21,
- 0x00000F38, 0x00000F4D, 0x00000F61, 0x00000F74,
- 0x00000F86, 0x00000F97, 0x00000FA6, 0x00000FB5,
- 0x00000FC2, 0x00000FCE, 0x00000FD8, 0x00000FE1,
- 0x00000FEA, 0x00000FF0, 0x00000FF6, 0x00000FFA,
- 0x00000FFE, 0x00000FFF
+ FX32_CONST(0.0), // sin(0)
+ FX32_CONST(0.017333984375), // sin(1)
+ FX32_CONST(0.034912109375), // sin(2)
+ FX32_CONST(0.05224609375), // sin(3)
+ FX32_CONST(0.06982421875), // sin(4)
+ FX32_CONST(0.087158203125), // sin(5)
+ FX32_CONST(0.1044921875), // sin(6)
+ FX32_CONST(0.121826171875), // sin(7)
+ FX32_CONST(0.13916015625), // sin(8)
+ FX32_CONST(0.156494140625), // sin(9)
+ FX32_CONST(0.173583984375), // sin(10)
+ FX32_CONST(0.19091796875), // sin(11)
+ FX32_CONST(0.2080078125), // sin(12)
+ FX32_CONST(0.224853515625), // sin(13)
+ FX32_CONST(0.241943359375), // sin(14)
+ FX32_CONST(0.2587890625), // sin(15)
+ FX32_CONST(0.275634765625), // sin(16)
+ FX32_CONST(0.29248046875), // sin(17)
+ FX32_CONST(0.30908203125), // sin(18)
+ FX32_CONST(0.32568359375), // sin(19)
+ FX32_CONST(0.342041015625), // sin(20)
+ FX32_CONST(0.3583984375), // sin(21)
+ FX32_CONST(0.37451171875), // sin(22)
+ FX32_CONST(0.390625), // sin(23)
+ FX32_CONST(0.40673828125), // sin(24)
+ FX32_CONST(0.422607421875), // sin(25)
+ FX32_CONST(0.4384765625), // sin(26)
+ FX32_CONST(0.4541015625), // sin(27)
+ FX32_CONST(0.469482421875), // sin(28)
+ FX32_CONST(0.48486328125), // sin(29)
+ FX32_CONST(0.5), // sin(30)
+ FX32_CONST(0.51513671875), // sin(31)
+ FX32_CONST(0.530029296875), // sin(32)
+ FX32_CONST(0.544677734375), // sin(33)
+ FX32_CONST(0.55908203125), // sin(34)
+ FX32_CONST(0.573486328125), // sin(35)
+ FX32_CONST(0.587890625), // sin(36)
+ FX32_CONST(0.601806640625), // sin(37)
+ FX32_CONST(0.61572265625), // sin(38)
+ FX32_CONST(0.62939453125), // sin(39)
+ FX32_CONST(0.642822265625), // sin(40)
+ FX32_CONST(0.656005859375), // sin(41)
+ FX32_CONST(0.669189453125), // sin(42)
+ FX32_CONST(0.681884765625), // sin(43)
+ FX32_CONST(0.694580078125), // sin(44)
+ FX32_CONST(0.70703125), // sin(45)
+ FX32_CONST(0.71923828125), // sin(46)
+ FX32_CONST(0.7314453125), // sin(47)
+ FX32_CONST(0.7431640625), // sin(48)
+ FX32_CONST(0.754638671875), // sin(49)
+ FX32_CONST(0.76611328125), // sin(50)
+ FX32_CONST(0.777099609375), // sin(51)
+ FX32_CONST(0.7880859375), // sin(52)
+ FX32_CONST(0.798583984375), // sin(53)
+ FX32_CONST(0.80908203125), // sin(54)
+ FX32_CONST(0.819091796875), // sin(55)
+ FX32_CONST(0.8291015625), // sin(56)
+ FX32_CONST(0.838623046875), // sin(57)
+ FX32_CONST(0.84814453125), // sin(58)
+ FX32_CONST(0.857177734375), // sin(59)
+ FX32_CONST(0.865966796875), // sin(60)
+ FX32_CONST(0.87451171875), // sin(61)
+ FX32_CONST(0.883056640625), // sin(62)
+ FX32_CONST(0.89111328125), // sin(63)
+ FX32_CONST(0.898681640625), // sin(64)
+ FX32_CONST(0.90625), // sin(65)
+ FX32_CONST(0.91357421875), // sin(66)
+ FX32_CONST(0.92041015625), // sin(67)
+ FX32_CONST(0.92724609375), // sin(68)
+ FX32_CONST(0.93359375), // sin(69)
+ FX32_CONST(0.939697265625), // sin(70)
+ FX32_CONST(0.945556640625), // sin(71)
+ FX32_CONST(0.951171875), // sin(72)
+ FX32_CONST(0.956298828125), // sin(73)
+ FX32_CONST(0.961181640625), // sin(74)
+ FX32_CONST(0.9658203125), // sin(75)
+ FX32_CONST(0.97021484375), // sin(76)
+ FX32_CONST(0.974365234375), // sin(77)
+ FX32_CONST(0.97802734375), // sin(78)
+ FX32_CONST(0.981689453125), // sin(79)
+ FX32_CONST(0.98486328125), // sin(80)
+ FX32_CONST(0.98779296875), // sin(81)
+ FX32_CONST(0.990234375), // sin(82)
+ FX32_CONST(0.992431640625), // sin(83)
+ FX32_CONST(0.99462890625), // sin(84)
+ FX32_CONST(0.99609375), // sin(85)
+ FX32_CONST(0.99755859375), // sin(86)
+ FX32_CONST(0.99853515625), // sin(87)
+ FX32_CONST(0.99951171875), // sin(88)
+ FX32_CONST(0.999755859375), // sin(89)
+ FX32_CONST(1.0), // sin(90)
+ FX32_CONST(0.999755859375), // sin(91)
+ FX32_CONST(0.99951171875), // sin(92)
+ FX32_CONST(0.99853515625), // sin(93)
+ FX32_CONST(0.99755859375), // sin(94)
+ FX32_CONST(0.99609375), // sin(95)
+ FX32_CONST(0.99462890625), // sin(96)
+ FX32_CONST(0.992431640625), // sin(97)
+ FX32_CONST(0.990234375), // sin(98)
+ FX32_CONST(0.98779296875), // sin(99)
+ FX32_CONST(0.98486328125), // sin(100)
+ FX32_CONST(0.981689453125), // sin(101)
+ FX32_CONST(0.97802734375), // sin(102)
+ FX32_CONST(0.974365234375), // sin(103)
+ FX32_CONST(0.97021484375), // sin(104)
+ FX32_CONST(0.9658203125), // sin(105)
+ FX32_CONST(0.961181640625), // sin(106)
+ FX32_CONST(0.956298828125), // sin(107)
+ FX32_CONST(0.951171875), // sin(108)
+ FX32_CONST(0.945556640625), // sin(109)
+ FX32_CONST(0.939697265625), // sin(110)
+ FX32_CONST(0.93359375), // sin(111)
+ FX32_CONST(0.92724609375), // sin(112)
+ FX32_CONST(0.92041015625), // sin(113)
+ FX32_CONST(0.91357421875), // sin(114)
+ FX32_CONST(0.90625), // sin(115)
+ FX32_CONST(0.898681640625), // sin(116)
+ FX32_CONST(0.89111328125), // sin(117)
+ FX32_CONST(0.883056640625), // sin(118)
+ FX32_CONST(0.87451171875), // sin(119)
+ FX32_CONST(0.865966796875), // sin(120)
+ FX32_CONST(0.857177734375), // sin(121)
+ FX32_CONST(0.84814453125), // sin(122)
+ FX32_CONST(0.838623046875), // sin(123)
+ FX32_CONST(0.8291015625), // sin(124)
+ FX32_CONST(0.819091796875), // sin(125)
+ FX32_CONST(0.80908203125), // sin(126)
+ FX32_CONST(0.798583984375), // sin(127)
+ FX32_CONST(0.7880859375), // sin(128)
+ FX32_CONST(0.777099609375), // sin(129)
+ FX32_CONST(0.76611328125), // sin(130)
+ FX32_CONST(0.754638671875), // sin(131)
+ FX32_CONST(0.7431640625), // sin(132)
+ FX32_CONST(0.7314453125), // sin(133)
+ FX32_CONST(0.71923828125), // sin(134)
+ FX32_CONST(0.70703125), // sin(135)
+ FX32_CONST(0.694580078125), // sin(136)
+ FX32_CONST(0.681884765625), // sin(137)
+ FX32_CONST(0.669189453125), // sin(138)
+ FX32_CONST(0.656005859375), // sin(139)
+ FX32_CONST(0.642822265625), // sin(140)
+ FX32_CONST(0.62939453125), // sin(141)
+ FX32_CONST(0.61572265625), // sin(142)
+ FX32_CONST(0.601806640625), // sin(143)
+ FX32_CONST(0.587890625), // sin(144)
+ FX32_CONST(0.573486328125), // sin(145)
+ FX32_CONST(0.55908203125), // sin(146)
+ FX32_CONST(0.544677734375), // sin(147)
+ FX32_CONST(0.530029296875), // sin(148)
+ FX32_CONST(0.51513671875), // sin(149)
+ FX32_CONST(0.5), // sin(150)
+ FX32_CONST(0.48486328125), // sin(151)
+ FX32_CONST(0.469482421875), // sin(152)
+ FX32_CONST(0.4541015625), // sin(153)
+ FX32_CONST(0.4384765625), // sin(154)
+ FX32_CONST(0.422607421875), // sin(155)
+ FX32_CONST(0.40673828125), // sin(156)
+ FX32_CONST(0.390625), // sin(157)
+ FX32_CONST(0.37451171875), // sin(158)
+ FX32_CONST(0.3583984375), // sin(159)
+ FX32_CONST(0.342041015625), // sin(160)
+ FX32_CONST(0.32568359375), // sin(161)
+ FX32_CONST(0.30908203125), // sin(162)
+ FX32_CONST(0.29248046875), // sin(163)
+ FX32_CONST(0.275634765625), // sin(164)
+ FX32_CONST(0.2587890625), // sin(165)
+ FX32_CONST(0.241943359375), // sin(166)
+ FX32_CONST(0.224853515625), // sin(167)
+ FX32_CONST(0.2080078125), // sin(168)
+ FX32_CONST(0.19091796875), // sin(169)
+ FX32_CONST(0.173583984375), // sin(170)
+ FX32_CONST(0.156494140625), // sin(171)
+ FX32_CONST(0.13916015625), // sin(172)
+ FX32_CONST(0.121826171875), // sin(173)
+ FX32_CONST(0.1044921875), // sin(174)
+ FX32_CONST(0.087158203125), // sin(175)
+ FX32_CONST(0.06982421875), // sin(176)
+ FX32_CONST(0.05224609375), // sin(177)
+ FX32_CONST(0.034912109375), // sin(178)
+ FX32_CONST(0.017333984375), // sin(179)
+ FX32_CONST(0.0), // sin(180)
+ FX32_CONST(-0.017333984375), // sin(181)
+ FX32_CONST(-0.034912109375), // sin(182)
+ FX32_CONST(-0.05224609375), // sin(183)
+ FX32_CONST(-0.06982421875), // sin(184)
+ FX32_CONST(-0.087158203125), // sin(185)
+ FX32_CONST(-0.1044921875), // sin(186)
+ FX32_CONST(-0.121826171875), // sin(187)
+ FX32_CONST(-0.13916015625), // sin(188)
+ FX32_CONST(-0.156494140625), // sin(189)
+ FX32_CONST(-0.173583984375), // sin(190)
+ FX32_CONST(-0.19091796875), // sin(191)
+ FX32_CONST(-0.2080078125), // sin(192)
+ FX32_CONST(-0.224853515625), // sin(193)
+ FX32_CONST(-0.241943359375), // sin(194)
+ FX32_CONST(-0.2587890625), // sin(195)
+ FX32_CONST(-0.275634765625), // sin(196)
+ FX32_CONST(-0.29248046875), // sin(197)
+ FX32_CONST(-0.30908203125), // sin(198)
+ FX32_CONST(-0.32568359375), // sin(199)
+ FX32_CONST(-0.342041015625), // sin(200)
+ FX32_CONST(-0.3583984375), // sin(201)
+ FX32_CONST(-0.37451171875), // sin(202)
+ FX32_CONST(-0.390625), // sin(203)
+ FX32_CONST(-0.40673828125), // sin(204)
+ FX32_CONST(-0.422607421875), // sin(205)
+ FX32_CONST(-0.4384765625), // sin(206)
+ FX32_CONST(-0.4541015625), // sin(207)
+ FX32_CONST(-0.469482421875), // sin(208)
+ FX32_CONST(-0.48486328125), // sin(209)
+ FX32_CONST(-0.5), // sin(210)
+ FX32_CONST(-0.51513671875), // sin(211)
+ FX32_CONST(-0.530029296875), // sin(212)
+ FX32_CONST(-0.544677734375), // sin(213)
+ FX32_CONST(-0.55908203125), // sin(214)
+ FX32_CONST(-0.573486328125), // sin(215)
+ FX32_CONST(-0.587890625), // sin(216)
+ FX32_CONST(-0.601806640625), // sin(217)
+ FX32_CONST(-0.61572265625), // sin(218)
+ FX32_CONST(-0.62939453125), // sin(219)
+ FX32_CONST(-0.642822265625), // sin(220)
+ FX32_CONST(-0.656005859375), // sin(221)
+ FX32_CONST(-0.669189453125), // sin(222)
+ FX32_CONST(-0.681884765625), // sin(223)
+ FX32_CONST(-0.694580078125), // sin(224)
+ FX32_CONST(-0.70703125), // sin(225)
+ FX32_CONST(-0.71923828125), // sin(226)
+ FX32_CONST(-0.7314453125), // sin(227)
+ FX32_CONST(-0.7431640625), // sin(228)
+ FX32_CONST(-0.754638671875), // sin(229)
+ FX32_CONST(-0.76611328125), // sin(230)
+ FX32_CONST(-0.777099609375), // sin(231)
+ FX32_CONST(-0.7880859375), // sin(232)
+ FX32_CONST(-0.798583984375), // sin(233)
+ FX32_CONST(-0.80908203125), // sin(234)
+ FX32_CONST(-0.819091796875), // sin(235)
+ FX32_CONST(-0.8291015625), // sin(236)
+ FX32_CONST(-0.838623046875), // sin(237)
+ FX32_CONST(-0.84814453125), // sin(238)
+ FX32_CONST(-0.857177734375), // sin(239)
+ FX32_CONST(-0.865966796875), // sin(240)
+ FX32_CONST(-0.87451171875), // sin(241)
+ FX32_CONST(-0.883056640625), // sin(242)
+ FX32_CONST(-0.89111328125), // sin(243)
+ FX32_CONST(-0.898681640625), // sin(244)
+ FX32_CONST(-0.90625), // sin(245)
+ FX32_CONST(-0.91357421875), // sin(246)
+ FX32_CONST(-0.92041015625), // sin(247)
+ FX32_CONST(-0.92724609375), // sin(248)
+ FX32_CONST(-0.93359375), // sin(249)
+ FX32_CONST(-0.939697265625), // sin(250)
+ FX32_CONST(-0.945556640625), // sin(251)
+ FX32_CONST(-0.951171875), // sin(252)
+ FX32_CONST(-0.956298828125), // sin(253)
+ FX32_CONST(-0.961181640625), // sin(254)
+ FX32_CONST(-0.9658203125), // sin(255)
+ FX32_CONST(-0.97021484375), // sin(256)
+ FX32_CONST(-0.974365234375), // sin(257)
+ FX32_CONST(-0.97802734375), // sin(258)
+ FX32_CONST(-0.981689453125), // sin(259)
+ FX32_CONST(-0.98486328125), // sin(260)
+ FX32_CONST(-0.98779296875), // sin(261)
+ FX32_CONST(-0.990234375), // sin(262)
+ FX32_CONST(-0.992431640625), // sin(263)
+ FX32_CONST(-0.99462890625), // sin(264)
+ FX32_CONST(-0.99609375), // sin(265)
+ FX32_CONST(-0.99755859375), // sin(266)
+ FX32_CONST(-0.99853515625), // sin(267)
+ FX32_CONST(-0.99951171875), // sin(268)
+ FX32_CONST(-0.999755859375), // sin(269)
+ FX32_CONST(-1.0), // sin(270)
+ FX32_CONST(-0.999755859375), // sin(271)
+ FX32_CONST(-0.99951171875), // sin(272)
+ FX32_CONST(-0.99853515625), // sin(273)
+ FX32_CONST(-0.99755859375), // sin(274)
+ FX32_CONST(-0.99609375), // sin(275)
+ FX32_CONST(-0.99462890625), // sin(276)
+ FX32_CONST(-0.992431640625), // sin(277)
+ FX32_CONST(-0.990234375), // sin(278)
+ FX32_CONST(-0.98779296875), // sin(279)
+ FX32_CONST(-0.98486328125), // sin(280)
+ FX32_CONST(-0.981689453125), // sin(281)
+ FX32_CONST(-0.97802734375), // sin(282)
+ FX32_CONST(-0.974365234375), // sin(283)
+ FX32_CONST(-0.97021484375), // sin(284)
+ FX32_CONST(-0.9658203125), // sin(285)
+ FX32_CONST(-0.961181640625), // sin(286)
+ FX32_CONST(-0.956298828125), // sin(287)
+ FX32_CONST(-0.951171875), // sin(288)
+ FX32_CONST(-0.945556640625), // sin(289)
+ FX32_CONST(-0.939697265625), // sin(290)
+ FX32_CONST(-0.93359375), // sin(291)
+ FX32_CONST(-0.92724609375), // sin(292)
+ FX32_CONST(-0.92041015625), // sin(293)
+ FX32_CONST(-0.91357421875), // sin(294)
+ FX32_CONST(-0.90625), // sin(295)
+ FX32_CONST(-0.898681640625), // sin(296)
+ FX32_CONST(-0.89111328125), // sin(297)
+ FX32_CONST(-0.883056640625), // sin(298)
+ FX32_CONST(-0.87451171875), // sin(299)
+ FX32_CONST(-0.865966796875), // sin(300)
+ FX32_CONST(-0.857177734375), // sin(301)
+ FX32_CONST(-0.84814453125), // sin(302)
+ FX32_CONST(-0.838623046875), // sin(303)
+ FX32_CONST(-0.8291015625), // sin(304)
+ FX32_CONST(-0.819091796875), // sin(305)
+ FX32_CONST(-0.80908203125), // sin(306)
+ FX32_CONST(-0.798583984375), // sin(307)
+ FX32_CONST(-0.7880859375), // sin(308)
+ FX32_CONST(-0.777099609375), // sin(309)
+ FX32_CONST(-0.76611328125), // sin(310)
+ FX32_CONST(-0.754638671875), // sin(311)
+ FX32_CONST(-0.7431640625), // sin(312)
+ FX32_CONST(-0.7314453125), // sin(313)
+ FX32_CONST(-0.71923828125), // sin(314)
+ FX32_CONST(-0.70703125), // sin(315)
+ FX32_CONST(-0.694580078125), // sin(316)
+ FX32_CONST(-0.681884765625), // sin(317)
+ FX32_CONST(-0.669189453125), // sin(318)
+ FX32_CONST(-0.656005859375), // sin(319)
+ FX32_CONST(-0.642822265625), // sin(320)
+ FX32_CONST(-0.62939453125), // sin(321)
+ FX32_CONST(-0.61572265625), // sin(322)
+ FX32_CONST(-0.601806640625), // sin(323)
+ FX32_CONST(-0.587890625), // sin(324)
+ FX32_CONST(-0.573486328125), // sin(325)
+ FX32_CONST(-0.55908203125), // sin(326)
+ FX32_CONST(-0.544677734375), // sin(327)
+ FX32_CONST(-0.530029296875), // sin(328)
+ FX32_CONST(-0.51513671875), // sin(329)
+ FX32_CONST(-0.5), // sin(330)
+ FX32_CONST(-0.48486328125), // sin(331)
+ FX32_CONST(-0.469482421875), // sin(332)
+ FX32_CONST(-0.4541015625), // sin(333)
+ FX32_CONST(-0.4384765625), // sin(334)
+ FX32_CONST(-0.422607421875), // sin(335)
+ FX32_CONST(-0.40673828125), // sin(336)
+ FX32_CONST(-0.390625), // sin(337)
+ FX32_CONST(-0.37451171875), // sin(338)
+ FX32_CONST(-0.3583984375), // sin(339)
+ FX32_CONST(-0.342041015625), // sin(340)
+ FX32_CONST(-0.32568359375), // sin(341)
+ FX32_CONST(-0.30908203125), // sin(342)
+ FX32_CONST(-0.29248046875), // sin(343)
+ FX32_CONST(-0.275634765625), // sin(344)
+ FX32_CONST(-0.2587890625), // sin(345)
+ FX32_CONST(-0.241943359375), // sin(346)
+ FX32_CONST(-0.224853515625), // sin(347)
+ FX32_CONST(-0.2080078125), // sin(348)
+ FX32_CONST(-0.19091796875), // sin(349)
+ FX32_CONST(-0.173583984375), // sin(350)
+ FX32_CONST(-0.156494140625), // sin(351)
+ FX32_CONST(-0.13916015625), // sin(352)
+ FX32_CONST(-0.121826171875), // sin(353)
+ FX32_CONST(-0.1044921875), // sin(354)
+ FX32_CONST(-0.087158203125), // sin(355)
+ FX32_CONST(-0.06982421875), // sin(356)
+ FX32_CONST(-0.05224609375), // sin(357)
+ FX32_CONST(-0.034912109375), // sin(358)
+ FX32_CONST(-0.017333984375), // sin(359)
+ FX32_CONST(0.0), // sin(360)
+ FX32_CONST(0.017333984375), // sin(361)
+ FX32_CONST(0.034912109375), // sin(362)
+ FX32_CONST(0.05224609375), // sin(363)
+ FX32_CONST(0.06982421875), // sin(364)
+ FX32_CONST(0.087158203125), // sin(365)
+ FX32_CONST(0.1044921875), // sin(366)
+ FX32_CONST(0.121826171875), // sin(367)
+ FX32_CONST(0.13916015625), // sin(368)
+ FX32_CONST(0.156494140625), // sin(369)
+ FX32_CONST(0.173583984375), // sin(370)
+ FX32_CONST(0.19091796875), // sin(371)
+ FX32_CONST(0.2080078125), // sin(372)
+ FX32_CONST(0.224853515625), // sin(373)
+ FX32_CONST(0.241943359375), // sin(374)
+ FX32_CONST(0.2587890625), // sin(375)
+ FX32_CONST(0.275634765625), // sin(376)
+ FX32_CONST(0.29248046875), // sin(377)
+ FX32_CONST(0.30908203125), // sin(378)
+ FX32_CONST(0.32568359375), // sin(379)
+ FX32_CONST(0.342041015625), // sin(380)
+ FX32_CONST(0.3583984375), // sin(381)
+ FX32_CONST(0.37451171875), // sin(382)
+ FX32_CONST(0.390625), // sin(383)
+ FX32_CONST(0.40673828125), // sin(384)
+ FX32_CONST(0.422607421875), // sin(385)
+ FX32_CONST(0.4384765625), // sin(386)
+ FX32_CONST(0.4541015625), // sin(387)
+ FX32_CONST(0.469482421875), // sin(388)
+ FX32_CONST(0.48486328125), // sin(389)
+ FX32_CONST(0.5), // sin(390)
+ FX32_CONST(0.51513671875), // sin(391)
+ FX32_CONST(0.530029296875), // sin(392)
+ FX32_CONST(0.544677734375), // sin(393)
+ FX32_CONST(0.55908203125), // sin(394)
+ FX32_CONST(0.573486328125), // sin(395)
+ FX32_CONST(0.587890625), // sin(396)
+ FX32_CONST(0.601806640625), // sin(397)
+ FX32_CONST(0.61572265625), // sin(398)
+ FX32_CONST(0.62939453125), // sin(399)
+ FX32_CONST(0.642822265625), // sin(400)
+ FX32_CONST(0.656005859375), // sin(401)
+ FX32_CONST(0.669189453125), // sin(402)
+ FX32_CONST(0.681884765625), // sin(403)
+ FX32_CONST(0.694580078125), // sin(404)
+ FX32_CONST(0.70703125), // sin(405)
+ FX32_CONST(0.71923828125), // sin(406)
+ FX32_CONST(0.7314453125), // sin(407)
+ FX32_CONST(0.7431640625), // sin(408)
+ FX32_CONST(0.754638671875), // sin(409)
+ FX32_CONST(0.76611328125), // sin(410)
+ FX32_CONST(0.777099609375), // sin(411)
+ FX32_CONST(0.7880859375), // sin(412)
+ FX32_CONST(0.798583984375), // sin(413)
+ FX32_CONST(0.80908203125), // sin(414)
+ FX32_CONST(0.819091796875), // sin(415)
+ FX32_CONST(0.8291015625), // sin(416)
+ FX32_CONST(0.838623046875), // sin(417)
+ FX32_CONST(0.84814453125), // sin(418)
+ FX32_CONST(0.857177734375), // sin(419)
+ FX32_CONST(0.865966796875), // sin(420)
+ FX32_CONST(0.87451171875), // sin(421)
+ FX32_CONST(0.883056640625), // sin(422)
+ FX32_CONST(0.89111328125), // sin(423)
+ FX32_CONST(0.898681640625), // sin(424)
+ FX32_CONST(0.90625), // sin(425)
+ FX32_CONST(0.91357421875), // sin(426)
+ FX32_CONST(0.92041015625), // sin(427)
+ FX32_CONST(0.92724609375), // sin(428)
+ FX32_CONST(0.93359375), // sin(429)
+ FX32_CONST(0.939697265625), // sin(430)
+ FX32_CONST(0.945556640625), // sin(431)
+ FX32_CONST(0.951171875), // sin(432)
+ FX32_CONST(0.956298828125), // sin(433)
+ FX32_CONST(0.961181640625), // sin(434)
+ FX32_CONST(0.9658203125), // sin(435)
+ FX32_CONST(0.97021484375), // sin(436)
+ FX32_CONST(0.974365234375), // sin(437)
+ FX32_CONST(0.97802734375), // sin(438)
+ FX32_CONST(0.981689453125), // sin(439)
+ FX32_CONST(0.98486328125), // sin(440)
+ FX32_CONST(0.98779296875), // sin(441)
+ FX32_CONST(0.990234375), // sin(442)
+ FX32_CONST(0.992431640625), // sin(443)
+ FX32_CONST(0.99462890625), // sin(444)
+ FX32_CONST(0.99609375), // sin(445)
+ FX32_CONST(0.99755859375), // sin(446)
+ FX32_CONST(0.99853515625), // sin(447)
+ FX32_CONST(0.99951171875), // sin(448)
+ FX32_CONST(0.999755859375), // sin(449)
};
-const u16 UNK_020EDC7E[] = // rotations?
+static const u16 UNK_020EDC7E[] = // rotations?
{
0x0000, 0x00B7, 0x016D, 0x0223, 0x02D9, 0x038F, 0x0445, 0x04FB, 0x05B1, 0x0667,
0x071D, 0x07D3, 0x0889, 0x093F, 0x09F5, 0x0AAB, 0x0B61, 0x0C17, 0x0CCD, 0x0D83,
@@ -255,31 +592,41 @@ THUMB_FUNC s32 Sin32(s32 degrees)
* Random number generators
*/
static u32 sMTRNG_State[624]; // Mersenne Twister seed storage/buffer
+#ifdef NONMATCHING
+// Using -ipa file makes the following hack unnecessary,
+// but for some reason forces UNK_020EDC7E to align to
+// word rather than short...
+static u32 sLCRNG_State;
+#define sMTRNG_State_2 sMTRNG_State
+#else
static union
{
u32 LC_State; // Linear-congruential seed storage/buffer
u32 MTRNG_State[]; // Don't bother asking why Game Freak did this. Just don't.
} sRNGHack;
+#define sLCRNG_State sRNGHack.LC_State
+#define sMTRNG_State_2 (sRNGHack.MTRNG_State + 1)
+#endif
// Returns the Linear-congruential buffer in full.
THUMB_FUNC u32 GetLCRNGSeed()
{
- return sRNGHack.LC_State;
+ return sLCRNG_State;
}
// Initializes the Linear-congruential buffer with a 32-bit seed.
THUMB_FUNC void SetLCRNGSeed(u32 seed)
{
- sRNGHack.LC_State = seed;
+ sLCRNG_State = seed;
}
// Calculates an unsigned 16-bit random integer using the Linear-congruential algorithm.
THUMB_FUNC u16 LCRandom(void)
{
// cycle the RNG
- sRNGHack.LC_State *= 0x41C64E6D;
- sRNGHack.LC_State += 0x6073;
- return (u16)(sRNGHack.LC_State / 65536); // shut up the compiler
+ sLCRNG_State *= 0x41C64E6D;
+ sLCRNG_State += 0x6073;
+ return (u16)(sLCRNG_State / 65536); // shut up the compiler
}
// Returns a cheap, psuedo-random unsigned 32-bit random integer from a seed.
@@ -294,7 +641,7 @@ static u32 sMTRNG_XOR[2] = {0, 0x9908b0df}; // Mersenne Twister XOR mask table
// Initializes the Mersenne Twister buffer with a 32-bit seed.
THUMB_FUNC void SetMTRNGSeed(u32 seed)
{
- sRNGHack.MTRNG_State[0+1] = seed;
+ sMTRNG_State_2[0] = seed;
for (sMTRNG_Cycles = 1; sMTRNG_Cycles < 624; sMTRNG_Cycles++)
sMTRNG_State[sMTRNG_Cycles] = 1812433253 * (sMTRNG_State[sMTRNG_Cycles - 1] ^ (sMTRNG_State[sMTRNG_Cycles - 1] >> 30)) + sMTRNG_Cycles;
@@ -310,7 +657,7 @@ THUMB_FUNC u32 MTRandom(void)
{
if (sMTRNG_Cycles == 625)
SetMTRNGSeed(5489);
-
+
for (i = 0; i < 227; i++)
{
val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff);
@@ -321,20 +668,20 @@ THUMB_FUNC u32 MTRandom(void)
val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff);
sMTRNG_State[i] = sMTRNG_State[i + -227] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1];
}
-
- val = (sRNGHack.MTRNG_State[623+1] & 0x80000000) | (sRNGHack.MTRNG_State[0+1] & 0x7fffffff);
- sRNGHack.MTRNG_State[623+1] = sRNGHack.MTRNG_State[396+1] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1];
+
+ val = (sMTRNG_State_2[623] & 0x80000000) | (sMTRNG_State_2[0] & 0x7fffffff);
+ sMTRNG_State_2[623] = sMTRNG_State_2[396] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1];
sMTRNG_Cycles = 0;
}
-
+
val = sMTRNG_State[sMTRNG_Cycles++]; // has to be this way in order to match
-
+
val ^= val >> 11;
val ^= (val << 7) & 0x9d2c5680;
val ^= (val << 15) & 0xefc60000;
val ^= val >> 18;
-
+
return val;
}
@@ -350,8 +697,8 @@ THUMB_FUNC void MTX22_2DAffine(struct Mtx22 * mtx, u16 radians, fx32 x, fx32 y,
radians = (u16)((u32)(radians * 65535) / 360); // shut up the compiler
MTX_Rot22_(mtx,
- UNK_020FFA38[((radians >> 4) * 2)], // TODO: macros
- UNK_020FFA38[((radians >> 4) * 2) + 1]); // TODO: macros
+ FX_SinCosTable_[((radians >> 4) * 2)], // TODO: macros
+ FX_SinCosTable_[((radians >> 4) * 2) + 1]); // TODO: macros
MTX_ScaleApply22(mtx, mtx, x, y);
}
diff --git a/arm9/src/overlay_manager.c b/arm9/src/overlay_manager.c
index a59e15ac..0a03a87d 100644
--- a/arm9/src/overlay_manager.c
+++ b/arm9/src/overlay_manager.c
@@ -4,7 +4,7 @@
#include "heap.h"
#include "overlay_manager.h"
-THUMB_FUNC struct UnkStruct_02006234 * OverlayManager_new(struct Unk21DBE18 * ovly_mgr, int * a1, u32 heap_id)
+THUMB_FUNC struct UnkStruct_02006234 * OverlayManager_new(const struct Unk21DBE18 * ovly_mgr, s32 * a1, u32 heap_id)
{
struct UnkStruct_02006234 * ret = (struct UnkStruct_02006234 *)AllocFromHeap(heap_id, sizeof(struct UnkStruct_02006234));
ret->ovly_mgr = *ovly_mgr;
@@ -38,7 +38,7 @@ THUMB_FUNC void OverlayManager_FreeData(struct UnkStruct_02006234 * a0)
a0->unk1C = NULL;
}
-THUMB_FUNC int * OverlayManager_GetField18(struct UnkStruct_02006234 * a0)
+THUMB_FUNC s32 * OverlayManager_GetField18(struct UnkStruct_02006234 * a0)
{
return a0->unk18;
}
diff --git a/arm9/src/poke_overlay.c b/arm9/src/poke_overlay.c
index 4dd98670..e11ecbb6 100644
--- a/arm9/src/poke_overlay.c
+++ b/arm9/src/poke_overlay.c
@@ -9,9 +9,9 @@ static struct LoadedOverlay gLoadedOverlays[3][8];
THUMB_FUNC void FreeOverlayAllocation(struct LoadedOverlay * loaded)
{
if (loaded->active != TRUE)
- ErrorHandling();
+ GF_AssertFail();
if (FS_UnloadOverlay(MI_PROCESSOR_ARM9, loaded->id) != TRUE)
- ErrorHandling();
+ GF_AssertFail();
loaded->active = FALSE;
}
@@ -35,7 +35,7 @@ THUMB_FUNC s32 GetOverlayLoadDestination(FSOverlayID id)
u8 *end;
u8 *start;
if (FS_LoadOverlayInfo(&info, MI_PROCESSOR_ARM9, id) != TRUE)
- ErrorHandling();
+ GF_AssertFail();
start = (u8 *)HW_ITCM_IMAGE;
end = (u8 *)HW_ITCM_END;
if (info.header.ram_address <= end && info.header.ram_address >= start)
@@ -72,7 +72,7 @@ THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1)
}
if (r6 >= 8)
{
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
if (r7 == OVERLAY_LOAD_ITCM || r7 == OVERLAY_LOAD_DTCM)
@@ -91,7 +91,7 @@ THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1)
result = LoadOverlayNoInitAsync(MI_PROCESSOR_ARM9, id);
break;
default:
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
if (r7 == OVERLAY_LOAD_ITCM || r7 == OVERLAY_LOAD_DTCM)
@@ -100,7 +100,7 @@ THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1)
}
if (result == 0)
{
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
return TRUE;
@@ -120,7 +120,7 @@ THUMB_FUNC BOOL CanOverlayBeLoaded(FSOverlayID id)
{
if ((start >= start2 && start < end2) || (end > start2 && end <= end2) || (start <= start2 && end >= end2))
{
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
}
@@ -146,7 +146,7 @@ THUMB_FUNC BOOL GetOverlayRamBounds(FSOverlayID id, void ** start, void ** end)
{
FSOverlayInfo info;
if (!FS_LoadOverlayInfo(&info, MI_PROCESSOR_ARM9, id)) {
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
*start = (void *)info.header.ram_address;
diff --git a/arm9/src/pokedex.c b/arm9/src/pokedex.c
index bd1ea254..d86afa6a 100644
--- a/arm9/src/pokedex.c
+++ b/arm9/src/pokedex.c
@@ -226,12 +226,11 @@ void Pokedex_InitSeenDeoxysFormesArray(struct Pokedex * pokedex)
static inline BOOL HasUnownLetterBeenSeen(struct Pokedex * pokedex, u8 letter)
{
- u8 * arr;
s32 i;
+ u8 * arr;
for (i = 0, arr = (u8 *)pokedex; i < 28; i++, arr++)
{
- u8 val = arr[0x010C];
- if (letter == val)
+ if (letter == *(arr + 0x10C))
return TRUE;
}
return FALSE;
@@ -239,12 +238,11 @@ static inline BOOL HasUnownLetterBeenSeen(struct Pokedex * pokedex, u8 letter)
static inline s32 FindFirstAvailableUnownLetterSlot(struct Pokedex * pokedex)
{
- u8 * arr;
s32 i;
+ u8 * arr;
for (i = 0, arr = (u8 *)pokedex; i < 28; i++, arr++)
{
- u8 val = arr[0x010C];
- if (val == 0xFF)
+ if (*(arr + 0x10C) == 0xFF)
break;
}
return i;
@@ -320,26 +318,26 @@ s32 FUN_020242C8(struct Pokedex * pokedex, u16 species, s32 r4)
return r1;
}
-const u16 sSinnohDexMythicalMons[] = {
- SPECIES_MANAPHY
-};
-
-const u16 sNationalDexMythicalMons[] = {
- SPECIES_MEW,
- SPECIES_LUGIA,
- SPECIES_HO_OH,
- SPECIES_CELEBI,
- SPECIES_JIRACHI,
- SPECIES_DEOXYS,
- SPECIES_PHIONE,
- SPECIES_MANAPHY,
- SPECIES_DARKRAI,
- SPECIES_SHAYMIN,
- SPECIES_ARCEUS
-};
-
BOOL Pokedex_SpeciesIsNotMythical(u16 species)
{
+ static const u16 sSinnohDexMythicalMons[] = {
+ SPECIES_MANAPHY
+ };
+
+ static const u16 sNationalDexMythicalMons[] = {
+ SPECIES_MEW,
+ SPECIES_LUGIA,
+ SPECIES_HO_OH,
+ SPECIES_CELEBI,
+ SPECIES_JIRACHI,
+ SPECIES_DEOXYS,
+ SPECIES_PHIONE,
+ SPECIES_MANAPHY,
+ SPECIES_DARKRAI,
+ SPECIES_SHAYMIN,
+ SPECIES_ARCEUS
+ };
+
s32 i;
BOOL ret = TRUE;
for (i = 0; i < (s32)NELEMS(sNationalDexMythicalMons); i++)
diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c
index b3e53d1a..29075833 100644
--- a/arm9/src/pokemon.c
+++ b/arm9/src/pokemon.c
@@ -176,14 +176,14 @@ const s8 sNatureStatMods[][5] = {
void ZeroMonData(struct Pokemon * pokemon)
{
- MIi_CpuClearFast(0, pokemon, sizeof(struct Pokemon));
+ MI_CpuClearFast(pokemon, sizeof(struct Pokemon));
ENCRYPT_BOX(&pokemon->box);
ENCRYPT_PTY(pokemon);
}
void ZeroBoxMonData(struct BoxPokemon * boxmon)
{
- MIi_CpuClearFast(0, boxmon, sizeof(struct BoxPokemon));
+ MI_CpuClearFast(boxmon, sizeof(struct BoxPokemon));
ENCRYPT_BOX(boxmon);
}
@@ -272,7 +272,7 @@ void CreateMon(struct Pokemon * pokemon, int species, int level, int fixedIV, in
FreeToHeap(mail);
capsule = 0;
SetMonData(pokemon, MON_DATA_CAPSULE, &capsule);
- MIi_CpuClearFast(0, seal_coords, sizeof(seal_coords));
+ MI_CpuClearFast(seal_coords, sizeof(seal_coords));
SetMonData(pokemon, MON_DATA_SEAL_COORDS, seal_coords);
CalcMonLevelAndStats(pokemon);
}
@@ -3004,7 +3004,7 @@ void CopyBoxPokemonToPokemon(struct BoxPokemon * src, struct Pokemon * dest)
SetMonData(dest, MON_DATA_MAIL_STRUCT, mail);
FreeToHeap(mail);
SetMonData(dest, MON_DATA_CAPSULE, &sp0);
- MIi_CpuClearFast(0, &sp4, sizeof(sp4));
+ MI_CpuClearFast(&sp4, sizeof(sp4));
SetMonData(dest, MON_DATA_SEAL_COORDS, &sp4);
CalcMonLevelAndStats(dest);
}
@@ -3724,7 +3724,7 @@ void Pokemon_RemoveCapsule(struct Pokemon * pokemon)
{
u8 sp0 = 0;
CapsuleArray sp1;
- MIi_CpuClearFast(0, &sp1, sizeof(sp1));
+ MI_CpuClearFast(&sp1, sizeof(sp1));
SetMonData(pokemon, MON_DATA_CAPSULE, &sp0);
SetMonData(pokemon, MON_DATA_SEAL_COORDS, &sp1);
}
diff --git a/arm9/src/sav_chatot.c b/arm9/src/sav_chatot.c
new file mode 100644
index 00000000..86786e66
--- /dev/null
+++ b/arm9/src/sav_chatot.c
@@ -0,0 +1,98 @@
+#include "global.h"
+#include "MI_memory.h"
+#include "heap.h"
+#include "sav_chatot.h"
+
+THUMB_FUNC u32 Sav2_Chatot_sizeof(void)
+{
+ return sizeof(struct SaveChatotSoundClip);
+}
+
+THUMB_FUNC void Sav2_Chatot_init(struct SaveChatotSoundClip * chatot)
+{
+ MI_CpuClear32(chatot, sizeof(struct SaveChatotSoundClip));
+ chatot->exists = FALSE;
+}
+
+THUMB_FUNC struct SaveChatotSoundClip * Chatot_new(u32 heap_id)
+{
+ struct SaveChatotSoundClip * ret = (struct SaveChatotSoundClip *)AllocFromHeap(heap_id, sizeof(struct SaveChatotSoundClip));
+ Sav2_Chatot_init(ret);
+ return ret;
+}
+
+THUMB_FUNC struct SaveChatotSoundClip * Sav2_Chatot_get(struct SaveBlock2 * sav2)
+{
+ return (struct SaveChatotSoundClip *) SavArray_get(sav2, 22);
+}
+
+THUMB_FUNC BOOL Chatot_exists(struct SaveChatotSoundClip * chatot)
+{
+ return chatot->exists;
+}
+
+THUMB_FUNC void Chatot_invalidate(struct SaveChatotSoundClip * chatot)
+{
+ chatot->exists = FALSE;
+}
+
+THUMB_FUNC s8 * Chatot_GetData(struct SaveChatotSoundClip * chatot)
+{
+ return chatot->data;
+}
+
+static inline s8 transform(u8 value)
+{
+ return (s8)(value - 8);
+}
+
+THUMB_FUNC void Chatot_Decode(s8 * dest, const s8 * data)
+{
+ s32 i;
+ s32 dest_i;
+ u8 val;
+ s8 val2;
+
+ for (dest_i = 0, i = 0; i < 1000; i++, dest_i += 2)
+ {
+ val = (u8)(data[i] & 0xF);
+ val2 = transform(val);
+ dest[dest_i + 0] = (s8)(val2 << 4);
+ val = (u8)(data[i] >> 4);
+ val2 = transform(val);
+ dest[dest_i + 1] = (s8)(val2 << 4);
+ }
+}
+
+static inline u8 untransform(s8 val)
+{
+ val /= 16;
+ return (u8)(val + 8);
+}
+
+THUMB_FUNC void Chatot_Encode(struct SaveChatotSoundClip * chatot, const s8 * data)
+{
+ s32 src_i;
+ s32 i = 0;
+ u8 val2;
+ s8 val;
+ chatot->exists = TRUE;
+
+ for (src_i = 0; src_i < 2000; src_i += 2)
+ {
+ val = data[src_i + 0];
+ val2 = untransform(val);
+ chatot->data[i] = (s8)val2;
+
+ val = data[src_i + 1];
+ val2 = untransform(val);
+ chatot->data[i] |= val2 << 4;
+
+ i++;
+ }
+}
+
+THUMB_FUNC void Chatot_copy(struct SaveChatotSoundClip * dest, const struct SaveChatotSoundClip * src)
+{
+ MI_CpuCopyFast(src, dest, sizeof(struct SaveChatotSoundClip));
+}
diff --git a/arm9/src/save.c b/arm9/src/save.c
index 85d18d06..89bd8374 100644
--- a/arm9/src/save.c
+++ b/arm9/src/save.c
@@ -82,7 +82,7 @@ BOOL FUN_0202263C(struct SaveBlock2 * sav2)
FlashClobberChunkFooter(sav2, 1, (u32)(sav2->unk_20220[1] == 0 ? 1 : 0));
FlashClobberChunkFooter(sav2, 0, (u32)(sav2->unk_20220[0]));
FlashClobberChunkFooter(sav2, 1, (u32)(sav2->unk_20220[1]));
- MIi_CpuClearFast(-1u, r6, 0x1000);
+ MI_CpuFillFast(r6, -1u, 0x1000);
for (int i = 0; i < 64; i++)
{
FlashWriteChunk((u32)(0x1000 * i), r6, 0x1000);
diff --git a/arm9/src/save_arrays.c b/arm9/src/save_arrays.c
index 8520f2c1..f4b18b86 100644
--- a/arm9/src/save_arrays.c
+++ b/arm9/src/save_arrays.c
@@ -15,6 +15,7 @@
#include "seal.h"
#include "unk_020139D8.h"
#include "unk_02024E64.h"
+#include "sav_chatot.h"
extern u32 FUN_0202AC20(void);
extern u32 FUN_02034D7C(void);
@@ -26,7 +27,7 @@ extern u32 FUN_02028054(void);
extern u32 FUN_02028980(void);
extern u32 FUN_02029A84(void);
extern u32 FUN_02029FB0(void);
-extern u32 FUN_02029EC4(void);
+extern u32 Sav2_Chatot_sizeof(void);
extern u32 FUN_0202A89C(void);
extern u32 FUN_0202A8F4(void);
extern u32 FUN_0202A924(void);
@@ -47,7 +48,6 @@ extern void FUN_0202805C(void *);
extern void FUN_02028994(void *);
extern void FUN_02029A8C(void *);
extern void FUN_02029FB8(void *);
-extern void FUN_02029ECC(void *);
extern void FUN_0202A8A4(void *);
extern void FUN_0202A8F8(void *);
extern void FUN_0202A92C(void *);
@@ -87,7 +87,7 @@ const struct SaveChunkHeader UNK_020EE700[] = {
{ 19, 0, (SAVSIZEFN)FUN_02029A84, (SAVINITFN)FUN_02029A8C },
{ 20, 0, (SAVSIZEFN)FUN_02029FB0, (SAVINITFN)FUN_02029FB8 },
{ 21, 0, (SAVSIZEFN)Sav2_SealCase_sizeof, (SAVINITFN)Sav2_SealCase_init },
- { 22, 0, (SAVSIZEFN)FUN_02029EC4, (SAVINITFN)FUN_02029ECC },
+ { 22, 0, (SAVSIZEFN)Sav2_Chatot_sizeof, (SAVINITFN)Sav2_Chatot_init },
{ 23, 0, (SAVSIZEFN)FUN_0202A89C, (SAVINITFN)FUN_0202A8A4 },
{ 24, 0, (SAVSIZEFN)FUN_0202A8F4, (SAVINITFN)FUN_0202A8F8 },
{ 25, 0, (SAVSIZEFN)FUN_0202A924, (SAVINITFN)FUN_0202A92C },
diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c
index 4ad17e51..7adb1fe8 100644
--- a/arm9/src/scrcmd.c
+++ b/arm9/src/scrcmd.c
@@ -4,6 +4,7 @@
#include "options.h"
#include "player_data.h"
#include "text.h"
+#include "unk_02016B94.h"
extern void *FUN_02039438(struct UnkSavStruct80* arg, u32 id);
extern void *CreateScriptContext(struct UnkSavStruct80* arg, u16 id);
@@ -27,16 +28,14 @@ extern void FUN_02055304(u32 param0, u32 param1);
extern void FUN_02039460(struct UnkSavStruct80 *arg);
extern void FUN_020545B8(u32 param0, u8 *param1, u32 param2);
extern void FUN_02054608(u8 *param0, struct Options *options);
-extern void FUN_0200D0E0(u32 *param0, u32 param1);
-extern void FUN_02019178(u32 *param0);
-extern void FUN_020179E0(u32 param0, u32 param1, u32 param2, u16 val);
+extern void FUN_0200D0E0(struct Window *param0, u32 param1);
extern u32 FUN_02058510(u32 param0, u32 param1);
extern void MOD05_021E8128(u32 param0, u8 type, u16 map);
extern void MOD05_021E8130(u32 param0, u32 param1);
extern void MOD05_021E8158(struct UnkSavStruct80 *unk80);
-extern u32 MOD05_021E8140(u32 param0);
+extern struct Window * MOD05_021E8140(u32 param0);
extern BOOL MOD05_021E8148(u32 param0);
-extern u8 FUN_02054658(u32 param0, struct String *str, struct Options *opt, u32 param3);
+extern u8 FUN_02054658(struct Window * param0, struct String *str, struct Options *opt, u32 param3);
extern void MOD05_021E8144(u32 param0);
extern void FUN_0200CB00(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5);
extern u32 Std_CreateYesNoMenu(u32 param0, u8 **param1, u32 param2, u32 param3, u32 param4);
@@ -55,6 +54,10 @@ extern void MOD05_021E26CC(u32 param0, u8 param1);
extern void MOD05_021E2B80(u32 param0, u8 param1);
extern void MOD05_021E2B9C(u32 param0, u8 param1);
+extern u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1);
+extern u32 FUN_0205AEA4(u32 param0, const u8 *ptr);
+extern void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, u32 param2);
+
extern u8 *UNK_020F34E0;
static BOOL RunPauseTimer(struct ScriptContext *ctx);
@@ -575,7 +578,7 @@ THUMB_FUNC BOOL ScrCmd_Unk01FF(struct ScriptContext *ctx)
return TRUE;
}
-THUMB_FUNC BOOL ScrCmd_Unk026D(struct ScriptContext *ctx) //message unown font?
+THUMB_FUNC BOOL ScrCmd_MessageUnown(struct ScriptContext *ctx)
{
struct UnkStruct_0203A288 myLocalStruct;
u16 msg = ScriptReadHalfword(ctx);
@@ -672,7 +675,7 @@ THUMB_FUNC BOOL ScrCmd_WaitButtonAB(struct ScriptContext *ctx)
THUMB_FUNC static BOOL FUN_0203A46C(struct ScriptContext *ctx)
{
#pragma unused(ctx)
- if (gMain.unk48 & 0x3) // Mask (A | B) ?
+ if (gMain.newKeys & 0x3) // Mask (A | B) ?
{
return TRUE;
}
@@ -688,7 +691,7 @@ THUMB_FUNC BOOL ScrCmd_WaitButtonABTime(struct ScriptContext *ctx)
THUMB_FUNC static BOOL FUN_0203A4AC(struct ScriptContext *ctx)
{
- if (gMain.unk48 & 0x3) // Mask (A | B) ?
+ if (gMain.newKeys & 0x3) // Mask (A | B) ?
{
return TRUE;
}
@@ -709,27 +712,27 @@ THUMB_FUNC BOOL ScrCmd_WaitButton(struct ScriptContext *ctx)
THUMB_FUNC static BOOL FUN_0203A4E0(struct ScriptContext *ctx)
{
- if (gMain.unk48 & 3)
+ if (gMain.newKeys & 3)
{
return TRUE;
}
- else if (gMain.unk48 & 0x40)
+ else if (gMain.newKeys & 0x40)
{
FUN_02055304(ctx->unk80->unk38, 0);
}
- else if (gMain.unk48 & 0x80)
+ else if (gMain.newKeys & 0x80)
{
FUN_02055304(ctx->unk80->unk38, 1);
}
- else if (gMain.unk48 & 0x20)
+ else if (gMain.newKeys & 0x20)
{
FUN_02055304(ctx->unk80->unk38, 2);
}
- else if (gMain.unk48 & 0x10)
+ else if (gMain.newKeys & 0x10)
{
FUN_02055304(ctx->unk80->unk38, 3);
}
- else if (gMain.unk48 & 0x400)
+ else if (gMain.newKeys & 0x400)
{
FUN_02039460(ctx->unk80);
}
@@ -740,7 +743,7 @@ THUMB_FUNC static BOOL FUN_0203A4E0(struct ScriptContext *ctx)
return TRUE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0032(struct ScriptContext *ctx)
+THUMB_FUNC BOOL ScrCmd_WaitButtonABPad(struct ScriptContext *ctx)
{
SetupNativeScript(ctx, FUN_0203A570);
return TRUE;
@@ -749,11 +752,11 @@ THUMB_FUNC BOOL ScrCmd_Unk0032(struct ScriptContext *ctx)
THUMB_FUNC static BOOL FUN_0203A570(struct ScriptContext *ctx)
{
#pragma unused(ctx)
- if (gMain.unk48 & 0x3)
+ if (gMain.newKeys & 0x3)
{
return TRUE;
}
- else if (gMain.unk48 & 0xf0)
+ else if (gMain.newKeys & 0xf0)
{
return TRUE;
}
@@ -770,10 +773,10 @@ THUMB_FUNC BOOL ScrCmd_Unk0033(struct ScriptContext *ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0034(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_CloseMessageBox(struct ScriptContext* ctx)
{
struct UnkSavStruct80 *unk80 = ctx->unk80;
- u32 *unk = FUN_02039438(unk80, 0x1); //windowID?
+ struct Window *unk = FUN_02039438(unk80, 0x1);
u8 *unk2 = FUN_02039438(unk80, 0x6);
FUN_0200D0E0(unk, 0); //clear window?
FUN_02019178(unk);
@@ -784,7 +787,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0034(struct ScriptContext* ctx)
THUMB_FUNC BOOL ScrCmd_Unk0035(struct ScriptContext* ctx)
{
struct UnkSavStruct80 *unk80 = ctx->unk80;
- u32 *unk = FUN_02039438(unk80, 0x1); //windowID?
+ struct Window *unk = FUN_02039438(unk80, 0x1);
u8 *unk2 = FUN_02039438(unk80, 0x6);
FUN_02019178(unk);
*unk2 = 0;
@@ -889,7 +892,7 @@ THUMB_FUNC BOOL ScrCmd_CreateMessageBox(struct ScriptContext* ctx)
MOD05_021E8158(unk80);
ReadMsgDataIntoString(ctx->msgData, msg, *unk1);
StringExpandPlaceholders(*unk3, *unk2, *unk1);
- AddTextPrinterParameterized(MOD05_021E8140(unk80->unk60), 1, (u16 *)*unk2, 0, 0, 0, NULL);
+ AddTextPrinterParameterized(MOD05_021E8140(unk80->unk60), 1, *unk2, 0, 0, 0, NULL);
return TRUE;
}
@@ -969,19 +972,19 @@ THUMB_FUNC static BOOL FUN_0203A94C(struct ScriptContext *ctx)
return TRUE;
}
- if (gMain.unk48 & 0x40)
+ if (gMain.newKeys & 0x40)
{
tmp = 0;
}
- else if (gMain.unk48 & 0x80)
+ else if (gMain.newKeys & 0x80)
{
tmp = 1;
}
- else if (gMain.unk48 & 0x20)
+ else if (gMain.newKeys & 0x20)
{
tmp = 2;
}
- else if (gMain.unk48 & 0x10)
+ else if (gMain.newKeys & 0x10)
{
tmp = 3;
}
@@ -995,7 +998,7 @@ THUMB_FUNC static BOOL FUN_0203A94C(struct ScriptContext *ctx)
}
else
{
- if (gMain.unk48 & 0x400)
+ if (gMain.newKeys & 0x400)
{
FUN_0201BD7C(*unk1);
*varPtr = 1;
@@ -1018,24 +1021,24 @@ THUMB_FUNC static BOOL FUN_0203AA0C(struct ScriptContext *ctx)
u16 *unk = GetVarPointer(ctx->unk80, (u16)ctx->data[0]);
u32 tmp = 0xFFFF;
- if (gMain.unk48 & 0x3)
+ if (gMain.newKeys & 0x3)
{
*unk = 0;
return TRUE;
}
- else if (gMain.unk48 & 0x40)
+ else if (gMain.newKeys & 0x40)
{
tmp = 0;
}
- else if (gMain.unk48 & 0x80)
+ else if (gMain.newKeys & 0x80)
{
tmp = 1;
}
- else if (gMain.unk48 & 0x20)
+ else if (gMain.newKeys & 0x20)
{
tmp = 2;
}
- else if (gMain.unk48 & 0x10)
+ else if (gMain.newKeys & 0x10)
{
tmp = 3;
}
@@ -1048,7 +1051,7 @@ THUMB_FUNC static BOOL FUN_0203AA0C(struct ScriptContext *ctx)
}
else
{
- if (gMain.unk48 & 0x400)
+ if (gMain.newKeys & 0x400)
{
*unk = 1;
return TRUE;
@@ -1298,3 +1301,19 @@ THUMB_FUNC BOOL ScrCmd_Unk02D0(struct ScriptContext *ctx)
MOD05_021E2B9C(*unk, ScriptReadByte(ctx));
return TRUE;
}
+
+THUMB_FUNC BOOL ScrCmd_Unk005E(struct ScriptContext *ctx) //ApplyMovement?
+{
+ u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u32 unk2 = ScriptReadWord(ctx);
+
+ u32 unk3 = FUN_0203B120(ctx->unk80, unk);
+ GF_ASSERT(unk3);
+
+ u32 unk4 = FUN_0205AEA4(unk3, ctx->scriptPtr + unk2);
+ u8 *unk5 = FUN_02039438(ctx->unk80, 4);
+ (*unk5)++;
+
+ FUN_0203B174(ctx->unk80, unk4, 0);
+ return FALSE;
+}
diff --git a/arm9/src/scrcmd_20.c b/arm9/src/scrcmd_20.c
deleted file mode 100644
index 882126a0..00000000
--- a/arm9/src/scrcmd_20.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "scrcmd.h"
-
-const u16 UNK_020F452A[19][2] = {
- { 0x00FB, 0x03E8 },
- { 0x0109, 0x03E8 },
- { 0x0114, 0x03E8 },
- { 0x0115, 0x03E8 },
- { 0x01A1, 0x07D0 },
- { 0x0181, 0x07D0 },
- { 0x0192, 0x0FA0 },
- { 0x0167, 0x0FA0 },
- { 0x0173, 0x1770 },
- { 0x01A0, 0x1770 },
- { 0x0151, 0x1770 },
- { 0x0162, 0x1F40 },
- { 0x015C, 0x1F40 },
- { 0x016A, 0x2710 },
- { 0x015F, 0x2710 },
- { 0x0154, 0x2710 },
- { 0x0164, 0x2710 },
- { 0x0191, 0x3A98 },
- { 0x018B, 0x4E20 },
-};
-
-THUMB_FUNC BOOL ScrCmd_Unk02A6(struct ScriptContext * ctx)
-{
- u16 idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
- u16 * ret_ptr1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
- u16 * ret_ptr2 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
-
- *ret_ptr1 = UNK_020F452A[idx][0];
- *ret_ptr2 = UNK_020F452A[idx][1];
-
- return FALSE;
-}
diff --git a/arm9/src/scrcmd_24.c b/arm9/src/scrcmd_24.c
new file mode 100644
index 00000000..9c8f8d4b
--- /dev/null
+++ b/arm9/src/scrcmd_24.c
@@ -0,0 +1,276 @@
+#include "scrcmd.h"
+#include "heap.h"
+#include "party.h"
+#include "unk_020377F0.h"
+#include "unk_02088DD8.h"
+
+extern void* FUN_02039438(struct UnkSavStruct80*, int idx);
+
+extern struct UnkStruct_02037CF0* FUN_02037CF0(u32 heap_id, struct UnkSavStruct80*, u8);
+extern u8 FUN_02037D5C(struct UnkStruct_02037CF0*);
+extern void FUN_02038864(struct UnkSavStruct80*, struct UnkStruct_02088DD8*);
+extern BOOL FUN_0203BC04(struct ScriptContext* ctx);
+extern struct UnkStruct_02088DD8* FUN_02088DD8(u32 heap_id);
+extern void FUN_02088DF0(struct UnkStruct_02037CF0*);
+extern void* FUN_02088DF8(struct Pokemon* pokemon, u32 heap_id);
+extern BOOL FUN_02088EF8(void*);
+
+THUMB_FUNC BOOL ScrCmd_Unk01C6(struct ScriptContext* ctx)
+{
+ u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct UnkStruct_02037CF0** unk_ret_ptr = FUN_02039438(ctx->unk80, 19);
+ *unk_ret_ptr = FUN_02037CF0(32, ctx->unk80, (u8)unk);
+
+ SetupNativeScript(ctx, FUN_0203BC04);
+ return TRUE;
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct UnkStruct_02037CF0** unk_ptr = FUN_02039438(ctx->unk80, 19);
+ GF_ASSERT(*unk_ptr != NULL);
+
+ *ret_ptr = FUN_02037D5C(*unk_ptr);
+ if (*ret_ptr == 4)
+ {
+ *ret_ptr = 0xFF;
+ }
+
+ FreeToHeap(*unk_ptr);
+ *unk_ptr = NULL;
+ return FALSE;
+}
+#else
+THUMB_FUNC asm BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx)
+{
+ push {r3-r5, lr}
+ add r4, r0, #0x0
+ bl ScriptReadHalfword
+ add r1, r0, #0x0
+ add r0, r4, #0x0
+ add r0, #0x80
+ ldr r0, [r0, #0x0]
+ bl GetVarPointer
+ add r4, #0x80
+ add r5, r0, #0x0
+ ldr r0, [r4, #0x0]
+ mov r1, #0x13
+ bl FUN_02039438
+ add r4, r0, #0x0
+ ldr r0, [r4, #0x0]
+ cmp r0, #0x0
+ bne _02045DFC
+ bl GF_AssertFail
+_02045DFC:
+ ldr r0, [r4, #0x0]
+ bl FUN_02037D5C
+ strh r0, [r5, #0x0]
+ ldrh r0, [r5, #0x0]
+ cmp r0, #0x4
+ bne _02045E0E
+ mov r0, #0xff
+ strh r0, [r5, #0x0]
+_02045E0E:
+ ldr r0, [r4, #0x0]
+ bl FreeToHeap
+ mov r0, #0x0
+ str r0, [r4, #0x0]
+ pop {r3-r5, pc}
+}
+#endif
+
+THUMB_FUNC BOOL ScrCmd_Unk021E(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk021F(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx);
+ void* unk_ptr = FUN_02088DF8(pokemon, 32);
+
+ *ret_ptr = (u16)FUN_02088EF8(unk_ptr);
+ FreeToHeap(unk_ptr);
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_02045E74(struct ScriptContext* ctx, u8 a1, struct Pokemon* pokemon, void* a3)
+{
+ struct UnkStruct_02088DD8** unk = FUN_02039438(ctx->unk80, 19);
+ struct UnkStruct_02088DD8* unk2 = FUN_02088DD8(32);
+ *unk = unk2;
+
+ unk2->pokemon = pokemon;
+
+ struct SaveBlock2* sav2 = ScriptEnvironment_GetSav2Ptr(ctx->unk80);
+ unk2->player = Sav2_PlayerData_GetProfileAddr(sav2);
+
+ unk2->options = Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2);
+ unk2->unkC = a3;
+ unk2->unk15 = a1;
+ FUN_02038864(ctx->unk80, unk2);
+
+ SetupNativeScript(ctx, FUN_0203BC04);
+ FreeToHeap(a3);
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0220(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0221(struct ScriptContext* ctx)
+{
+ u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx);
+ void* unk_ptr = FUN_02088DF8(pokemon, 32);
+
+ FUN_02045E74(ctx, 1, pokemon, unk_ptr);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0224(struct ScriptContext* ctx)
+{
+ u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2);
+ struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx);
+
+ u16* unk_array = AllocFromHeap(32, 2 * sizeof(u16));
+ unk_array[0] = unk2;
+ unk_array[1] = 0xFFFF;
+
+ FUN_02045E74(ctx, 0, pokemon, unk_array);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0222(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ return FALSE;
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC BOOL ScrCmd_Unk0223(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct UnkStruct_02037CF0** unk = FUN_02039438(ctx->unk80, 19);
+ struct UnkStruct_02037CF0* unk_sub = *unk;
+
+ GF_ASSERT(unk_sub != NULL);
+
+ if (unk_sub->unk16 == 0)
+ {
+ *ret_ptr = 0;
+ }
+ else
+ {
+ *ret_ptr = 0xFF;
+ }
+
+ FUN_02088DF0(unk_sub);
+ return FALSE;
+}
+#else
+THUMB_FUNC asm BOOL ScrCmd_Unk0223(struct ScriptContext* ctx)
+{
+ push {r3-r5, lr}
+ add r4, r0, #0x0
+ bl ScriptReadHalfword
+ add r1, r0, #0x0
+ add r0, r4, #0x0
+ add r0, #0x80
+ ldr r0, [r0, #0x0]
+ bl GetVarPointer
+ add r4, #0x80
+ add r5, r0, #0x0
+ ldr r0, [r4, #0x0]
+ mov r1, #0x13
+ bl FUN_02039438
+ ldr r4, [r0, #0x0]
+ cmp r4, #0x0
+ bne _02045FB2
+ bl GF_AssertFail
+_02045FB2:
+ ldrb r0, [r4, #0x16]
+ cmp r0, #0x0
+ bne _02045FBC
+ mov r0, #0x0
+ b _02045FBE
+_02045FBC:
+ mov r0, #0xff
+_02045FBE:
+ strh r0, [r5, #0x0]
+ add r0, r4, #0x0
+ bl FUN_02088DF0
+ mov r0, #0x0
+ pop {r3-r5, pc}
+}
+#endif
+
+#ifdef NONMATCHING
+THUMB_FUNC BOOL ScrCmd_Unk0225(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct UnkStruct_02037CF0** unk = FUN_02039438(ctx->unk80, 19);
+ struct UnkStruct_02037CF0* unk_sub = *unk;
+
+ GF_ASSERT(unk_sub != NULL);
+
+ if (unk_sub->unk16 == 0)
+ {
+ *ret_ptr = 0;
+ }
+ else
+ {
+ *ret_ptr = 0xFF;
+ }
+
+ FUN_02088DF0(unk_sub);
+ return FALSE;
+}
+#else
+THUMB_FUNC asm BOOL ScrCmd_Unk0225(struct ScriptContext* ctx)
+{
+ push {r3-r5, lr}
+ add r4, r0, #0x0
+ bl ScriptReadHalfword
+ add r1, r0, #0x0
+ add r0, r4, #0x0
+ add r0, #0x80
+ ldr r0, [r0, #0x0]
+ bl GetVarPointer
+ add r4, #0x80
+ add r5, r0, #0x0
+ ldr r0, [r4, #0x0]
+ mov r1, #0x13
+ bl FUN_02039438
+ ldr r4, [r0, #0x0]
+ cmp r4, #0x0
+ bne _02045FB2
+ bl GF_AssertFail
+_02045FB2:
+ ldrb r0, [r4, #0x16]
+ cmp r0, #0x0
+ bne _02045FBC
+ mov r0, #0x0
+ b _02045FBE
+_02045FBC:
+ mov r0, #0xff
+_02045FBE:
+ strh r0, [r5, #0x0]
+ add r0, r4, #0x0
+ bl FUN_02088DF0
+ mov r0, #0x0
+ pop {r3-r5, pc}
+}
+#endif
diff --git a/arm9/src/scrcmd_8.c b/arm9/src/scrcmd_8.c
new file mode 100644
index 00000000..0c47594b
--- /dev/null
+++ b/arm9/src/scrcmd_8.c
@@ -0,0 +1,88 @@
+#include "scrcmd.h"
+#include "math_util.h"
+#include "unk_020286F8.h"
+
+extern void* FUN_02039438(struct UnkSavStruct80*, u8 idx);
+
+extern void FUN_020385CC(struct UnkStruct_0204639C*, u32, u32, u32, u32, u16*, u16* ret_ptr);
+extern BOOL FUN_020612EC(struct UnkSavStruct80*);
+extern BOOL FUN_020612F8(struct UnkSavStruct80*);
+
+THUMB_FUNC BOOL ScrCmd_Unk021D(struct ScriptContext* ctx) //docs has this command as ScrCmd_Group, with a comment saying
+ //"This command is the devil"
+{
+ struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
+ struct UnkSaveStruct_020286F8* unk_sav_ptr = FUN_0202881C(ctx->unk80->saveBlock2);
+ struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
+
+ u16 option = ScriptReadHalfword(ctx);
+ switch (option)
+ {
+ case 0: { //check if group ID exists
+ u16 unk_var = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ *ret_ptr = (u16)FUN_02028828(unk_sav_ptr, unk_var);
+ return FALSE;
+ }
+ case 1: { //check if group ID is accessible
+ u16 unk_var = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ *ret_ptr = (u16)FUN_02028840(unk_sav_ptr, unk_var);
+ return FALSE;
+ }
+ case 2: { //writes group ID to string buffer
+ u16 unk_var = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+
+ BufferEasyChatWord(*mgr, sav2, unk_var, idx, 0);
+ break;
+ }
+ case 3: { //writes group leader name to string buffer
+ u16 unk_var = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+
+ BufferEasyChatWord(*mgr, sav2, unk_var, idx, 1);
+ break;
+ }
+ case 4: { //opens keyboard, 2 if group id exists, 1 if cancel, 0 otherwise
+ u16* unk_str_ptr = FUN_020287A8(unk_sav_ptr, 0, 0);
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ FUN_020385CC(ctx->unk74, 5, 0, 7, 0, unk_str_ptr, ret_ptr);
+ return TRUE;
+ }
+ case 5: { //enter in group id (whatever this means, needs more investigation)
+ u16 src_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ BOOL unk_bool = FUN_02028828(unk_sav_ptr, 1);
+
+ FUN_02028700(unk_sav_ptr, src_idx, 1);
+ if (unk_bool != FALSE)
+ {
+ FUN_020612F8(ctx->unk80);
+ }
+
+ return FALSE;
+ }
+ case 6: { //create a group
+ struct String* player_name = String_ctor(64, 32);
+ struct PlayerData* player = Sav2_PlayerData_GetProfileAddr(ctx->unk80->saveBlock2);
+
+ PlayerName_FlatToString(player, player_name);
+ FUN_020287C0(unk_sav_ptr, 0, 1, player_name);
+ FUN_020287EC(unk_sav_ptr, 0, PlayerProfile_GetTrainerGender(player));
+ FUN_02028810(unk_sav_ptr, 0, 2);
+ FUN_02028788(unk_sav_ptr, 0, MTRandom());
+
+ String_dtor(player_name);
+
+ FUN_02028700(unk_sav_ptr, 0, 1);
+ FUN_020612EC(ctx->unk80);
+
+ break;
+ }
+ }
+
+ return FALSE;
+}
diff --git a/arm9/src/scrcmd_11.c b/arm9/src/scrcmd_berry_trees.c
index 8553adfa..53715ca1 100644
--- a/arm9/src/scrcmd_11.c
+++ b/arm9/src/scrcmd_berry_trees.c
@@ -16,7 +16,7 @@ extern void FUN_0204B5A8(struct UnkSavStruct80*, void*, u16);
extern void FUN_0204B9A0(struct UnkSavStruct80*);
extern void FUN_0204B4FC(struct UnkSavStruct80*, void*);
-THUMB_FUNC BOOL ScrCmd_Unk017D(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetBerryTreeGrowth(struct ScriptContext* ctx)
{
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
void** unk = FUN_02039438(ctx->unk80, 10);
@@ -26,7 +26,7 @@ THUMB_FUNC BOOL ScrCmd_Unk017D(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk017E(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetBerryTreeType(struct ScriptContext* ctx)
{
void** unk = FUN_02039438(ctx->unk80, 10);
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
@@ -36,7 +36,7 @@ THUMB_FUNC BOOL ScrCmd_Unk017E(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk017F(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetBerryTreeMulch(struct ScriptContext* ctx)
{
void** unk = FUN_02039438(ctx->unk80, 10);
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
@@ -46,7 +46,7 @@ THUMB_FUNC BOOL ScrCmd_Unk017F(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0180(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetBerryTreeWater(struct ScriptContext* ctx)
{
void** unk = FUN_02039438(ctx->unk80, 10);
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
@@ -56,7 +56,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0180(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0181(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetBerryTreeAmount(struct ScriptContext* ctx)
{
void** unk = FUN_02039438(ctx->unk80, 10);
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
@@ -66,7 +66,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0181(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0182(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_SetBerryTreeMulch(struct ScriptContext* ctx)
{
void** unk = FUN_02039438(ctx->unk80, 10);
u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -76,7 +76,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0182(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0183(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_SetBerryTreeType(struct ScriptContext* ctx)
{
void** unk = FUN_02039438(ctx->unk80, 10);
struct UnkStruct_02029FB0* unk2 = FUN_02029FC8(ctx->unk80->saveBlock2);
@@ -88,7 +88,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0183(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0184(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_Unk0184(struct ScriptContext* ctx) //SetBerryTreeWater/WaterBerryTree, or just the animation?
{
u16 unk = ScriptReadHalfword(ctx);
@@ -108,7 +108,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0184(struct ScriptContext* ctx)
return TRUE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0185(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_TakeBerryTreeBerries(struct ScriptContext* ctx)
{
struct UnkStruct_02029FB0* unk = FUN_02029FC8(ctx->unk80->saveBlock2);
void** unk2 = FUN_02039438(ctx->unk80, 10);
diff --git a/arm9/src/scrcmd_coins.c b/arm9/src/scrcmd_coins.c
index 59638c83..f4fea1de 100644
--- a/arm9/src/scrcmd_coins.c
+++ b/arm9/src/scrcmd_coins.c
@@ -7,7 +7,7 @@ extern u32 MOD05_021E2950(struct UnkSavStruct80* arg, u8, u8);
extern MOD05_021E29B4();
extern MOD05_021E29C8();
-THUMB_FUNC BOOL ScrCmd_Unk0075(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_ShowCoinBox(struct ScriptContext * ctx)
{
struct UnkSavStruct80* sav_ptr = ctx->unk80;
u32 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -20,7 +20,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0075(struct ScriptContext * ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0076(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_HideCoinBox(struct ScriptContext * ctx)
{
u16 ** unk = FUN_02039438(ctx->unk80, 0x26);
MOD05_021E29B4(*unk);
@@ -28,7 +28,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0076(struct ScriptContext * ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0077(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_UpdateCoinBox(struct ScriptContext * ctx)
{
u16 ** unk = FUN_02039438(ctx->unk80, 0x26);
MOD05_021E29C8(ctx->unk80, *unk);
diff --git a/arm9/src/scrcmd_daycare.c b/arm9/src/scrcmd_daycare.c
index 4e2f925e..34abab1e 100644
--- a/arm9/src/scrcmd_daycare.c
+++ b/arm9/src/scrcmd_daycare.c
@@ -17,7 +17,7 @@ extern u16 MOD05_021ED5C4(struct PlayerParty* party, int idx, struct ScrStrBufs*
extern u16 MOD05_021ED5EC(struct DayCare* daycare);
extern u32 MOD05_021ED644(struct DayCare* daycare);
-THUMB_FUNC BOOL ScrCmd_Unk016D(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetDaycarePokemonNames(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
@@ -28,7 +28,7 @@ THUMB_FUNC BOOL ScrCmd_Unk016D(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk016E(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetDaycareStatus(struct ScriptContext* ctx)
{
struct UnkSavStruct80* sav_ptr = ctx->unk80;
struct SaveBlock2* sav2 = sav_ptr->saveBlock2;
@@ -40,7 +40,7 @@ THUMB_FUNC BOOL ScrCmd_Unk016E(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk01A8(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_DeleteDaycareEgg(struct ScriptContext* ctx)
{
struct DayCare* daycare = SavArray_get(ctx->unk80->saveBlock2, 8);
MOD05_021ECD64(daycare);
@@ -48,7 +48,7 @@ THUMB_FUNC BOOL ScrCmd_Unk01A8(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk01A9(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GiveDaycareEgg(struct ScriptContext* ctx)
{
struct UnkSavStruct80* sav_ptr = ctx->unk80;
struct DayCare* daycare = SavArray_get(sav_ptr->saveBlock2, 8);
@@ -90,7 +90,7 @@ THUMB_FUNC BOOL ScrCmd_Unk01AA(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk01AE(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetDaycareLevel(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
diff --git a/arm9/src/scrcmd_flags.c b/arm9/src/scrcmd_flags.c
new file mode 100644
index 00000000..ee13ebc0
--- /dev/null
+++ b/arm9/src/scrcmd_flags.c
@@ -0,0 +1,284 @@
+#include "scrcmd.h"
+#include "event_data.h"
+#include "pokedex.h"
+
+extern void* FUN_02034E20(void*);
+extern void* FUN_02034E30(void*);
+extern BOOL FUN_02055474(void*);
+extern void FUN_02055488(void*, u32);
+extern void FUN_0205ECD4(struct ScriptState* state);
+extern BOOL FUN_0205ECE0(struct ScriptState* state);
+extern void FUN_0205ECFC(struct ScriptState* state);
+extern BOOL FUN_0205ED0C(struct ScriptState* state);
+extern void FUN_0205ED1C(struct ScriptState* state);
+extern void FUN_0205ED2C(struct ScriptState* state);
+extern BOOL FUN_0205ED3C(struct ScriptState* state);
+extern void FUN_0205ED4C(struct ScriptState* state);
+extern void FUN_0205ED5C(struct ScriptState* state);
+extern BOOL FUN_0205ED6C(struct ScriptState* state);
+extern BOOL FUN_0205F264(struct ScriptState* state, u32);
+extern void FUN_0205F274(struct ScriptState* state);
+extern void FUN_0205F284(struct ScriptState* state);
+extern BOOL FUN_0205F294(struct ScriptState* state);
+extern void FUN_0205F2A4(struct ScriptState* state);
+extern void FUN_0205F2B4(struct ScriptState* state);
+extern BOOL FUN_0205F2C4(struct ScriptState* state);
+
+const u8 UNK_020F457F[8] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+};
+
+THUMB_FUNC BOOL ScrCmd_HasSinnohDex(struct ScriptContext* ctx)
+{
+ struct Pokedex* pokedex = Sav2_Pokedex_get(ctx->unk80->saveBlock2);
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ *ret_ptr = (u16)Pokedex_GetSinnohDexFlag(pokedex);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GiveSinnohDex(struct ScriptContext* ctx)
+{
+ struct Pokedex* pokedex = Sav2_Pokedex_get(ctx->unk80->saveBlock2);
+
+ Pokedex_SetSinnohDexFlag(pokedex);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_HasRunningShoes(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ void* unk_sav_ptr = FUN_02034E30(ctx->unk80->saveBlock2);
+ void* unk = FUN_02034E20(unk_sav_ptr);
+
+ *ret_ptr = (u16)FUN_02055474(unk);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GiveRunningShoes(struct ScriptContext* ctx)
+{
+ void* unk_sav_ptr = FUN_02034E30(ctx->unk80->saveBlock2);
+ void* unk = FUN_02034E20(unk_sav_ptr);
+
+ FUN_02055488(unk, 1);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_HasBadge(struct ScriptContext* ctx)
+{
+ u16 badge_no = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ GF_ASSERT(badge_no < 8);
+ struct PlayerData* player = Sav2_PlayerData_GetProfileAddr(ctx->unk80->saveBlock2);
+
+ *ret_ptr = (u16)PlayerProfile_TestBadgeFlag(player, badge_no);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GiveBadge(struct ScriptContext* ctx)
+{
+ u16 badge_no = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ GF_ASSERT(badge_no < 8);
+ struct PlayerData* player = Sav2_PlayerData_GetProfileAddr(ctx->unk80->saveBlock2);
+
+ PlayerProfile_SetBadgeFlag(player, badge_no);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GiveBag(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ *ret_ptr = (u16)FUN_0205ECE0(state);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetTotalEarnedBadges(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ u16 i;
+ u16 badges;
+ for (i = 0, badges = 0; i < 8; i++)
+ {
+ struct PlayerData* player = Sav2_PlayerData_GetProfileAddr(ctx->unk80->saveBlock2);
+ BOOL has_badge = PlayerProfile_TestBadgeFlag(player, UNK_020F457F[i]);
+ if (has_badge == TRUE)
+ {
+ badges++;
+ }
+ }
+
+ *ret_ptr = badges;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_HasBag(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205ECD4(state);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0160(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ *ret_ptr = (u16)FUN_0205ED3C(state);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0161(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205ED1C(state);
+
+ return 0;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0162(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205ED2C(state);
+
+ return 0;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0163(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ *ret_ptr = (u16)FUN_0205ED6C(state);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0164(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205ED4C(state);
+
+ return 0;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0165(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205ED5C(state);
+
+ return 0;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckGameCompleted(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ *ret_ptr = (u16)FUN_0205ED0C(state);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetGameCompleted(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205ECFC(state);
+
+ return 0;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetSetStrength(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+ u8 option = ScriptReadByte(ctx);
+ u16* ret_ptr;
+
+ switch (option)
+ {
+ case 1: //set strength to on
+ FUN_0205F264(state, 1);
+ break;
+ case 0: //set strength to off
+ FUN_0205F264(state, 0);
+ break;
+ case 2: //get whether strength is on or off
+ ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ *ret_ptr = (u16)FUN_0205F264(state, 2);
+ break;
+ default:
+ GF_ASSERT(FALSE);
+ break;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetSetFlash(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+ u8 option = ScriptReadByte(ctx);
+ u16* ret_ptr;
+
+ switch (option)
+ {
+ case 1: //set flash to on
+ FUN_0205F274(state);
+ break;
+ case 0: //set flash to off
+ FUN_0205F284(state);
+ break;
+ case 2: //get whether flash is on or off
+ ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ *ret_ptr = (u16)FUN_0205F294(state);
+ break;
+ default:
+ GF_ASSERT(FALSE);
+ break;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetSetDefog(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+ u8 option = ScriptReadByte(ctx);
+ u16* ret_ptr;
+
+ switch (option)
+ {
+ case 1: //set defog to on
+ FUN_0205F2A4(state);
+ break;
+ case 0: //set defog to off
+ FUN_0205F2B4(state);
+ break;
+ case 2: //get whether defog is on or off
+ ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ *ret_ptr = (u16)FUN_0205F2C4(state);
+ break;
+ default:
+ GF_ASSERT(FALSE);
+ break;
+ }
+
+ return FALSE;
+}
diff --git a/arm9/src/scrcmd_19.c b/arm9/src/scrcmd_fossils.c
index b0a201b7..e4177382 100644
--- a/arm9/src/scrcmd_19.c
+++ b/arm9/src/scrcmd_fossils.c
@@ -1,45 +1,45 @@
#include "scrcmd.h"
#include "bag.h"
-const u16 UNK_020F450C[7][2] = {
- { 0x0067, 0x008E },
- { 0x0065, 0x008A },
- { 0x0066, 0x008C },
- { 0x0063, 0x0159 },
- { 0x0064, 0x015B },
- { 0x0068, 0x019A },
- { 0x0069, 0x0198 },
+const u16 gFossilPokemonMap[7][2] = {
+ { ITEM_OLD_AMBER, SPECIES_AERODACTYL },
+ { ITEM_HELIX_FOSSIL, SPECIES_OMANYTE },
+ { ITEM_DOME_FOSSIL, SPECIES_KABUTO },
+ { ITEM_ROOT_FOSSIL, SPECIES_LILEEP },
+ { ITEM_CLAW_FOSSIL, SPECIES_ANORITH },
+ { ITEM_ARMOR_FOSSIL, SPECIES_SHIELDON },
+ { ITEM_SKULL_FOSSIL, SPECIES_CRANIDOS },
};
-THUMB_FUNC BOOL ScrCmd_Unk01F1(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_CountFossils(struct ScriptContext * ctx)
{
struct UnkSavStruct80 * sav_ptr = ctx->unk80;
- u16 * ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 *ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
u8 i;
u16 total;
for (i = 0, total = 0; i < 7; i++)
{
- total += Bag_GetQuantity(Sav2_Bag_get(sav_ptr->saveBlock2), UNK_020F450C[i][0], 4);
+ total += Bag_GetQuantity(Sav2_Bag_get(sav_ptr->saveBlock2), gFossilPokemonMap[i][0], 4);
}
*ret_ptr = total;
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk01F4(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_GetFossilPokemon(struct ScriptContext * ctx)
{
- u16 * ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
- u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 *ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 fossilId = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
*ret_ptr = 0;
for (u16 i = 0; i < 7; i++)
{
- if (UNK_020F450C[i][0] == unk)
+ if (gFossilPokemonMap[i][0] == fossilId)
{
- *ret_ptr = UNK_020F450C[i][1];
+ *ret_ptr = gFossilPokemonMap[i][1];
break;
}
}
@@ -47,7 +47,7 @@ THUMB_FUNC BOOL ScrCmd_Unk01F4(struct ScriptContext * ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk01F5(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_GetFossilMinimumAmount(struct ScriptContext * ctx)
{
struct UnkSavStruct80* sav_ptr = ctx->unk80;
u16 * ret_ptr1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
@@ -61,10 +61,10 @@ THUMB_FUNC BOOL ScrCmd_Unk01F5(struct ScriptContext * ctx)
u16 total = 0;
for (; i < 7; i++)
{
- total += Bag_GetQuantity(Sav2_Bag_get(sav_ptr->saveBlock2), UNK_020F450C[i][0], 4);
+ total += Bag_GetQuantity(Sav2_Bag_get(sav_ptr->saveBlock2), gFossilPokemonMap[i][0], 4);
if (total >= needed_amount)
{
- *ret_ptr1 = UNK_020F450C[i][0];
+ *ret_ptr1 = gFossilPokemonMap[i][0];
*ret_ptr2 = i;
break;
}
diff --git a/arm9/src/scrcmd_mart.c b/arm9/src/scrcmd_mart.c
new file mode 100644
index 00000000..6803617c
--- /dev/null
+++ b/arm9/src/scrcmd_mart.c
@@ -0,0 +1,442 @@
+#include "global.h"
+#include "constants/items.h"
+#include "constants/seal_constants.h"
+#include "constants/decorations.h"
+#include "scrcmd.h"
+#include "module_06.h"
+
+extern void FUN_02038AD0(struct UnkStruct_0204639C *);
+
+static const u16 UNK_020F40A6[] = {
+ ITEM_AIR_MAIL,
+ ITEM_HEAL_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40A0[] = {
+ ITEM_STEEL_MAIL,
+ ITEM_LUXURY_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40B4[] = {
+ ITEM_TUNNEL_MAIL,
+ ITEM_HEAL_BALL,
+ ITEM_NET_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40AC[] = {
+ ITEM_BLOOM_MAIL,
+ ITEM_HEAL_BALL,
+ ITEM_NET_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40BC[] = {
+ ITEM_AIR_MAIL,
+ ITEM_HEAL_BALL,
+ ITEM_NET_BALL,
+ ITEM_NEST_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40F8[] = {
+ ITEM_HEART_MAIL,
+ ITEM_HEAL_BALL,
+ ITEM_NET_BALL,
+ ITEM_NEST_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4102[] = {
+ ITEM_AIR_MAIL,
+ ITEM_QUICK_BALL,
+ ITEM_TIMER_BALL,
+ ITEM_REPEAT_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40DA[] = {
+ ITEM_AIR_MAIL,
+ ITEM_NET_BALL,
+ ITEM_NEST_BALL,
+ ITEM_DUSK_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40EE[] = {
+ ITEM_AIR_MAIL,
+ ITEM_DUSK_BALL,
+ ITEM_QUICK_BALL,
+ ITEM_TIMER_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40D0[] = {
+ ITEM_SNOW_MAIL,
+ ITEM_DUSK_BALL,
+ ITEM_QUICK_BALL,
+ ITEM_TIMER_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40C6[] = {
+ ITEM_HEAL_POWDER,
+ ITEM_ENERGYPOWDER,
+ ITEM_ENERGY_ROOT,
+ ITEM_REVIVAL_HERB,
+ 0xFFFF
+};
+
+static const u16 UNK_020F40E4[] = {
+ ITEM_AIR_MAIL,
+ ITEM_NEST_BALL,
+ ITEM_DUSK_BALL,
+ ITEM_QUICK_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F410C[] = {
+ DECORATION_YELLOW_CUSHION,
+ DECORATION_CUPBOARD,
+ DECORATION_TV,
+ DECORATION_REFRIGERATOR,
+ DECORATION_PRETTY_SINK,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4118[] = {
+ DECORATION_MUNCHLAX_DOLL,
+ DECORATION_BONSLY_DOLL,
+ DECORATION_MIME_JR__DOLL,
+ DECORATION_MANTYKE_DOLL,
+ DECORATION_BUIZEL_DOLL,
+ DECORATION_CHATOT_DOLL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4126[] = {
+ ITEM_PROTEIN,
+ ITEM_IRON,
+ ITEM_CALCIUM,
+ ITEM_ZINC,
+ ITEM_CARBOS,
+ ITEM_HP_UP,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4134[] = {
+ ITEM_TM38,
+ ITEM_TM25,
+ ITEM_TM14,
+ ITEM_TM22,
+ ITEM_TM52,
+ ITEM_TM15,
+ 0xFFFF
+};
+
+static const u16 UNK_020F41B2[] = {
+ SEAL_STAR_A,
+ SEAL_A,
+ SEAL_FIRE_A,
+ SEAL_SONG_A,
+ SEAL_LINE_B,
+ SEAL_ELE_B,
+ SEAL_PARTY_D,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4142[] = {
+ SEAL_HEART_B,
+ SEAL_STAR_C,
+ SEAL_FIRE_C,
+ SEAL_FLORA_B,
+ SEAL_SONG_C,
+ SEAL_SMOKE_A,
+ SEAL_ELE_D,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4152[] = {
+ SEAL_FOAMY_D,
+ SEAL_PARTY_C,
+ SEAL_FLORA_F,
+ SEAL_SONG_G,
+ SEAL_HEART_F,
+ SEAL_LINE_A,
+ SEAL_ELE_A,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4162[] = {
+ SEAL_HEART_C,
+ SEAL_STAR_D,
+ SEAL_FIRE_D,
+ SEAL_FLORA_C,
+ SEAL_SONG_D,
+ SEAL_SMOKE_B,
+ SEAL_FOAMY_A,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4172[] = {
+ SEAL_HEART_D,
+ SEAL_FOAMY_B,
+ SEAL_PARTY_A,
+ SEAL_FLORA_D,
+ SEAL_SONG_E,
+ SEAL_STAR_E,
+ SEAL_SMOKE_C,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4182[] = {
+ ITEM_TM83,
+ ITEM_TM17,
+ ITEM_TM54,
+ ITEM_TM20,
+ ITEM_TM33,
+ ITEM_TM16,
+ ITEM_TM70,
+ 0xFFFF
+};
+
+static const u16 UNK_020F4192[] = {
+ SEAL_HEART_A,
+ SEAL_STAR_B,
+ SEAL_FIRE_B,
+ SEAL_SONG_B,
+ SEAL_LINE_C,
+ SEAL_ELE_C,
+ SEAL_FLORA_A,
+ 0xFFFF
+};
+
+static const u16 UNK_020F41A2[] = {
+ SEAL_FOAMY_C,
+ SEAL_PARTY_B,
+ SEAL_FLORA_E,
+ SEAL_SONG_F,
+ SEAL_HEART_E,
+ SEAL_STAR_F,
+ SEAL_SMOKE_D,
+ 0xFFFF
+};
+
+static const u16 UNK_020F41D4[] = {
+ ITEM_X_SPEED,
+ ITEM_X_ATTACK,
+ ITEM_X_DEFENSE,
+ ITEM_GUARD_SPEC_,
+ ITEM_DIRE_HIT,
+ ITEM_X_ACCURACY,
+ ITEM_X_SPECIAL,
+ ITEM_X_SP__DEF,
+ 0xFFFF
+};
+
+static const u16 UNK_020F41C2[] = {
+ ITEM_HEAL_BALL,
+ ITEM_NET_BALL,
+ ITEM_NEST_BALL,
+ ITEM_DUSK_BALL,
+ ITEM_QUICK_BALL,
+ ITEM_TIMER_BALL,
+ ITEM_REPEAT_BALL,
+ ITEM_LUXURY_BALL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F41E6[] = {
+ ITEM_POTION,
+ ITEM_SUPER_POTION,
+ ITEM_HYPER_POTION,
+ ITEM_MAX_POTION,
+ ITEM_REVIVE,
+ ITEM_ANTIDOTE,
+ ITEM_PARLYZ_HEAL,
+ ITEM_BURN_HEAL,
+ ITEM_ICE_HEAL,
+ ITEM_AWAKENING,
+ ITEM_FULL_HEAL,
+ 0xFFFF
+};
+
+static const u16 UNK_020F41FE[] = {
+ ITEM_POKE_BALL,
+ ITEM_GREAT_BALL,
+ ITEM_ULTRA_BALL,
+ ITEM_ESCAPE_ROPE,
+ ITEM_POKE_DOLL,
+ ITEM_REPEL,
+ ITEM_SUPER_REPEL,
+ ITEM_MAX_REPEL,
+ ITEM_GRASS_MAIL,
+ ITEM_FLAME_MAIL,
+ ITEM_BUBBLE_MAIL,
+ ITEM_SPACE_MAIL,
+ 0xFFFF
+};
+
+static const u16 sNormalMartBadgeThresholds[][2] = {
+ // Balls
+ {ITEM_POKE_BALL, 1},
+ {ITEM_GREAT_BALL, 3},
+ {ITEM_ULTRA_BALL, 4},
+ // Potions
+ {ITEM_POTION, 1},
+ {ITEM_SUPER_POTION, 2},
+ {ITEM_HYPER_POTION, 4},
+ {ITEM_MAX_POTION, 5},
+ {ITEM_FULL_RESTORE, 6},
+ // Revives
+ {ITEM_REVIVE, 3},
+ // Status heal
+ {ITEM_ANTIDOTE, 1},
+ {ITEM_PARLYZ_HEAL, 1},
+ {ITEM_AWAKENING, 2},
+ {ITEM_BURN_HEAL, 2},
+ {ITEM_ICE_HEAL, 2},
+ {ITEM_FULL_HEAL, 4},
+ // Dungeon items
+ {ITEM_ESCAPE_ROPE, 2},
+ // Repels
+ {ITEM_REPEL, 2},
+ {ITEM_SUPER_REPEL, 3},
+ {ITEM_MAX_REPEL, 4},
+};
+
+const u16 *sDecorationMartPointers[] = {
+ UNK_020F410C,
+ UNK_020F4118,
+};
+
+const u16 *sSpecialMartPointers[] = {
+ UNK_020F40A6,
+ UNK_020F40B4,
+ UNK_020F40AC,
+ UNK_020F40BC,
+ UNK_020F40C6,
+ UNK_020F40F8,
+ UNK_020F40DA,
+ UNK_020F40E4,
+ UNK_020F41E6,
+ UNK_020F41FE,
+ UNK_020F41D4,
+ UNK_020F4126,
+ UNK_020F4182,
+ UNK_020F4134,
+ UNK_020F40EE,
+ UNK_020F40D0,
+ UNK_020F4102,
+ UNK_020F40A0,
+ UNK_020F41C2,
+};
+
+const u16 *sSealsMartPointers[] = {
+ UNK_020F4192,
+ UNK_020F4142,
+ UNK_020F4162,
+ UNK_020F4172,
+ UNK_020F41A2,
+ UNK_020F4152,
+ UNK_020F41B2,
+};
+
+THUMB_FUNC BOOL ScrCmd_NormalMart(struct ScriptContext * ctx)
+{
+ u16 whichMart = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ s32 param;
+ u16 martItems[64];
+ u8 martIdx = 0;
+ u8 badgeCount = 0;
+ u8 i;
+
+ for (i = 0; i < 8; i++)
+ {
+ if (PlayerProfile_TestBadgeFlag(Sav2_PlayerData_GetProfileAddr(ctx->unk80->saveBlock2), i) == TRUE)
+ badgeCount++;
+ }
+ switch (badgeCount)
+ {
+ case 0:
+ param = 1;
+ break;
+ case 1:
+ case 2:
+ param = 2;
+ break;
+ case 3:
+ case 4:
+ param = 3;
+ break;
+ case 5:
+ case 6:
+ param = 4;
+ break;
+ case 7:
+ param = 5;
+ break;
+ case 8:
+ param = 6;
+ break;
+ default:
+ param = 1;
+ break;
+ }
+ for (i = 0; i < NELEMS(sNormalMartBadgeThresholds); i++)
+ {
+ if (param >= sNormalMartBadgeThresholds[i][1])
+ {
+ martItems[martIdx] = sNormalMartBadgeThresholds[i][0];
+ martIdx++;
+ }
+ }
+ martItems[martIdx] = 0xFFFF; // terminator
+ MOD06_0223D3D0(ctx->unk74, ctx->unk80, martItems, MART_ITEMS, 0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SpecialMart(struct ScriptContext * ctx)
+{
+ u16 whichMart = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u32 sp0;
+
+ // Fakematch?
+ if ((u16)(whichMart + (u16)(-8u)) <= 5)
+ sp0 = 1;
+ else
+ sp0 = 0;
+
+ MOD06_0223D3D0(ctx->unk74, ctx->unk80, sSpecialMartPointers[whichMart], MART_ITEMS, sp0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GoodsMart(struct ScriptContext * ctx)
+{
+ u16 whichMart = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u32 sp0;
+
+ if (whichMart <= 1)
+ sp0 = 1;
+ else
+ sp0 = 0;
+
+ MOD06_0223D3D0(ctx->unk74, ctx->unk80, sDecorationMartPointers[whichMart], MART_DECORATIONS, sp0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SealsMart(struct ScriptContext * ctx)
+{
+ u16 whichMart = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+
+ MOD06_0223D3D0(ctx->unk74, ctx->unk80, sSealsMartPointers[whichMart], MART_SEALS, 0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_AccessoriesShop(struct ScriptContext * ctx)
+{
+ FUN_02038AD0(ctx->unk80->unk10);
+ return TRUE;
+}
diff --git a/arm9/src/scrcmd_money.c b/arm9/src/scrcmd_money.c
index d2254844..6f18d65d 100644
--- a/arm9/src/scrcmd_money.c
+++ b/arm9/src/scrcmd_money.c
@@ -82,7 +82,7 @@ THUMB_FUNC BOOL ScrCmd_HasEnoughMoneyAddress(struct ScriptContext * ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0072(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_ShowMoneyBox(struct ScriptContext * ctx)
{
struct UnkSavStruct80 * sav_ptr = ctx->unk80;
u32 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -94,7 +94,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0072(struct ScriptContext * ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0073(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_HideMoneyBox(struct ScriptContext * ctx)
{
u32 ** unk = FUN_02039438(ctx->unk80, 0x27);
MOD05_021E288C(*unk);
@@ -102,7 +102,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0073(struct ScriptContext * ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0074(struct ScriptContext * ctx)
+THUMB_FUNC BOOL ScrCmd_UpdateMoneyBox(struct ScriptContext * ctx)
{
u32 ** unk = FUN_02039438(ctx->unk80, 0x27);
MOD05_021E28A0(ctx->unk80, *unk);
diff --git a/arm9/src/scrcmd_names.c b/arm9/src/scrcmd_names.c
index cf721328..ec1d8c92 100644
--- a/arm9/src/scrcmd_names.c
+++ b/arm9/src/scrcmd_names.c
@@ -53,7 +53,7 @@ THUMB_FUNC BOOL ScrCmd_GetFriendName(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk00D0(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetPokemonName(struct ScriptContext* ctx)
{
struct UnkSavStruct80* sav_ptr = ctx->unk80;
struct ScrStrBufs** mgr = FUN_02039438(sav_ptr, 15);
@@ -145,7 +145,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0280(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk00D6(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetPokemonNickname(struct ScriptContext* ctx)
{
struct UnkSavStruct80* sav_ptr = ctx->unk80;
struct ScrStrBufs** mgr = FUN_02039438(sav_ptr, 15);
@@ -237,7 +237,7 @@ THUMB_FUNC struct String* FUN_02040AE4(u32 msg_no, u32 heap_id)
return ret;
}
-THUMB_FUNC BOOL ScrCmd_Unk00DB(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetPlayerStarterName(struct ScriptContext* ctx)
{
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
u8 idx = ScriptReadByte(ctx);
@@ -251,7 +251,7 @@ THUMB_FUNC BOOL ScrCmd_Unk00DB(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk00DC(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetRivalStarterName(struct ScriptContext* ctx)
{
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
u8 idx = ScriptReadByte(ctx);
@@ -265,7 +265,7 @@ THUMB_FUNC BOOL ScrCmd_Unk00DC(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk00DD(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetCounterpartStarterName(struct ScriptContext* ctx)
{
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
u8 idx = ScriptReadByte(ctx);
@@ -312,7 +312,7 @@ THUMB_FUNC BOOL ScrCmd_GetUndergroundItemName(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk00E2(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetMapName(struct ScriptContext* ctx)
{
struct String* str = String_ctor(22, 4);
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
@@ -326,7 +326,7 @@ THUMB_FUNC BOOL ScrCmd_Unk00E2(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk017B(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetBerryName(struct ScriptContext* ctx)
{
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
u8 idx = ScriptReadByte(ctx);
@@ -362,7 +362,7 @@ THUMB_FUNC BOOL ScrCmd_GetFashionName(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0272(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetWhiteRockInscription(struct ScriptContext* ctx)
{
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
u8 idx = ScriptReadByte(ctx);
@@ -393,7 +393,7 @@ THUMB_FUNC BOOL ScrCmd_GetPokemonMoveName(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0232(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetRibbonName(struct ScriptContext* ctx)
{
struct ScrStrBufs** mgr = FUN_02039438(ctx->unk80, 15);
u8 idx = ScriptReadByte(ctx);
diff --git a/arm9/src/scrcmd_prizes.c b/arm9/src/scrcmd_prizes.c
new file mode 100644
index 00000000..9a6cde41
--- /dev/null
+++ b/arm9/src/scrcmd_prizes.c
@@ -0,0 +1,36 @@
+#include "scrcmd.h"
+#include "constants/items.h"
+
+const u16 gGameCornerPrizes[19][2] = {
+ { ITEM_SILK_SCARF, 1000 },
+ { ITEM_WIDE_LENS, 1000 },
+ { ITEM_ZOOM_LENS, 1000 },
+ { ITEM_METRONOME, 1000 },
+ { ITEM_TM90, 2000 },
+ { ITEM_TM58, 2000 },
+ { ITEM_TM75, 4000 },
+ { ITEM_TM32, 4000 },
+ { ITEM_TM44, 6000 },
+ { ITEM_TM89, 6000 },
+ { ITEM_TM10, 6000 },
+ { ITEM_TM27, 8000 },
+ { ITEM_TM21, 8000 },
+ { ITEM_TM35, 10000 },
+ { ITEM_TM24, 10000 },
+ { ITEM_TM13, 10000 },
+ { ITEM_TM29, 10000 },
+ { ITEM_TM74, 15000 },
+ { ITEM_TM68, 20000 },
+};
+
+THUMB_FUNC BOOL ScrCmd_GetPrizeItemIdAndCost(struct ScriptContext* ctx)
+{
+ u16 idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* prize_item_id = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16* prize_cost_in_coins = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ *prize_item_id = gGameCornerPrizes[idx][0];
+ *prize_cost_in_coins = gGameCornerPrizes[idx][1];
+
+ return FALSE;
+}
diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c
new file mode 100644
index 00000000..ec5ab7f8
--- /dev/null
+++ b/arm9/src/scrcmd_sound.c
@@ -0,0 +1,266 @@
+#include "scrcmd.h"
+
+extern void* Sav2_Chatot_get(struct SaveBlock2* sav2);
+extern u32 FUN_02005D20(void *);
+extern void FUN_02005E6C(void *);
+extern void FUN_0200433C(u32, u32, u32);
+extern u32 FUN_02005E28(void);
+extern void FUN_02005E64(void);
+extern BOOL FUN_02005CBC(void);
+extern void PlaySound(u16);
+extern u32 FUN_02004124(u16);
+extern void FUN_0204AB20(struct UnkSavStruct80 *ctx, u16);
+extern u16 FUN_0204ABA8(struct UnkSavStruct80 *ctx, u32);
+extern void FUN_0200521C(u16);
+extern void FUN_02005308(u32, u16);
+extern void FUN_02005350(u32, u32);
+extern void FUN_0200538C(u32, u16, u32);
+extern void FUN_020053CC(u16, u16);
+extern BOOL FUN_02005404(void);
+extern u16 FUN_02005410(u16);
+extern void FUN_020054C8(u16);
+extern void FUN_020054F0(u16, u32);
+extern void FUN_020047C8(u8, u8);
+extern void FUN_020040F4(u8);
+extern BOOL FUN_02005508(u16);
+extern void FUN_02005578(u16);
+extern BOOL FUN_02005670(void);
+extern void FUN_0200488C(u16, u16);
+
+
+THUMB_FUNC BOOL ScrCmd_Unk02AE(struct ScriptContext *ctx)
+{
+ u16 unk0 = ScriptReadHalfword(ctx);
+ u16 *unk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ *unk1 = FUN_02005410(unk0);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlayBgm(struct ScriptContext *ctx)
+{
+ FUN_0200521C(ScriptReadHalfword(ctx));
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_StopBgm(struct ScriptContext *ctx)
+{
+ u32 unk0 = FUN_02004124(ScriptReadHalfword(ctx));
+ FUN_02005350(unk0, 0);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlayDefaultBgm(struct ScriptContext *ctx)
+{
+ u16 unk0 = FUN_0204ABA8(ctx->unk80, *ctx->unk80->mapId);
+ FUN_0200521C(unk0);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0053(struct ScriptContext *ctx) //Special BGM?
+{
+ FUN_0204AB20(ctx->unk80, ScriptReadHalfword(ctx));
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_FadeOutBgm(struct ScriptContext *ctx)
+{
+ u16 unk1 = ScriptReadHalfword(ctx);
+ u16 unk2 = ScriptReadHalfword(ctx);
+
+ FUN_020053CC(unk1, unk2);
+ SetupNativeScript(ctx, FUN_02041464);
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL FUN_02041464(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+
+ if(!FUN_02005404())
+ return TRUE;
+ else
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_FadeInBgm(struct ScriptContext* ctx)
+{
+ u16 unk = ScriptReadHalfword(ctx);
+
+ FUN_0200538C(0x7F, unk, 0);
+ SetupNativeScript(ctx, FUN_02041464);
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0056(struct ScriptContext* ctx)
+{
+
+ u8 PtrIndx0 = ScriptReadByte(ctx);
+
+ u8 PtrIndx1 = ScriptReadByte(ctx);
+
+ FUN_020047C8(PtrIndx0, PtrIndx1);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0057(struct ScriptContext* ctx)
+{
+ FUN_02005308(4, ScriptReadHalfword(ctx));
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk0058(struct ScriptContext* ctx)
+{
+ u8 PtrIndx0 = ScriptReadByte(ctx);
+ FUN_020040F4(PtrIndx0);
+ return FALSE;
+}
+
+
+THUMB_FUNC BOOL ScrCmd_PlayFanfare(struct ScriptContext* ctx)
+{
+ u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ FUN_020054C8(unk);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_StopFanfare(struct ScriptContext* ctx)
+{
+ u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ FUN_020054F0(unk, 0);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlayFanfareWait(struct ScriptContext* ctx)
+{
+ u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+
+ ctx->data[0] = unk;
+ SetupNativeScript(ctx, FUN_02041540);
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL FUN_02041540(struct ScriptContext* ctx)
+{
+ if(!FUN_02005508((u16)ctx->data[0]))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlayCry(struct ScriptContext* ctx)
+{
+ u16 unk0 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 unused = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ FUN_02005578(unk0);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlayCryWait(struct ScriptContext* ctx)
+{
+ SetupNativeScript(ctx, FUN_02041598);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL FUN_02041598(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+
+ if(!FUN_02005670())
+ return TRUE;
+ else
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlaySound(struct ScriptContext* ctx)
+{
+ u16 bgm_id = ScriptReadHalfword(ctx);
+ PlaySound(bgm_id);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_PlaySoundWait(struct ScriptContext* ctx)
+{
+ SetupNativeScript(ctx, FUN_020415CC);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL FUN_020415CC(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ if (!FUN_02005CBC())
+ return TRUE;
+ else
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckChatotCry(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2);
+ if (FUN_02005D20(unk) == 1)
+ {
+ *ret_ptr = 1;
+ return FALSE;
+ }
+ else
+ {
+ *ret_ptr = 0;
+ return FALSE;
+ }
+}
+
+THUMB_FUNC BOOL ScrCmd_StartChatotRecord(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+
+ if (FUN_02005E28() == 0)
+ {
+ *ret_ptr = 1;
+ return FALSE;
+ }
+ else
+ {
+ *ret_ptr = 0;
+ return FALSE;
+ }
+}
+
+THUMB_FUNC BOOL ScrCmd_StopChatotRecord(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ FUN_02005E64();
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SaveChatotCry(struct ScriptContext* ctx)
+{
+ void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2);
+ FUN_02005E6C(unk);
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk005D(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ FUN_0200433C(0x3F, 0, 0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetVolume(struct ScriptContext* ctx)
+{
+ u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+
+ FUN_0200488C(unk1, unk2);
+
+ return FALSE;
+}
+
diff --git a/arm9/src/scrcmd_23.c b/arm9/src/scrcmd_underground.c
index 0c9907a5..5d273c9b 100644
--- a/arm9/src/scrcmd_23.c
+++ b/arm9/src/scrcmd_underground.c
@@ -6,7 +6,7 @@ extern BOOL FUN_02026298(void*, u16);
extern void* FUN_02026CC4(struct SaveBlock2* sav2);
extern BOOL FUN_020260C4(void*, u16, u16);
-THUMB_FUNC BOOL ScrCmd_Unk0083(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GiveSecretBaseDecoration(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -19,7 +19,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0083(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0084(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_TakeSecretBaseDecoration(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -28,7 +28,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0084(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0085(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_HasSpaceForDecoration(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -41,7 +41,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0085(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0086(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetDecorationCount(struct ScriptContext* ctx) //somewhat unsure on name, was originally CheckGoods
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -50,7 +50,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0086(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0087(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GiveUndergroundTrap(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -63,7 +63,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0087(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0088(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_TakeUndergroundTrap(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -72,7 +72,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0088(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0089(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_HasSpaceForTrap(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -81,7 +81,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0089(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk008A(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetTrapCount(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -90,7 +90,7 @@ THUMB_FUNC BOOL ScrCmd_Unk008A(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk008B(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GiveTreasure(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -101,7 +101,7 @@ THUMB_FUNC BOOL ScrCmd_Unk008B(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk008C(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_TakeTreasure(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -110,7 +110,7 @@ THUMB_FUNC BOOL ScrCmd_Unk008C(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk008D(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_HasSpaceForTreasure(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -119,7 +119,7 @@ THUMB_FUNC BOOL ScrCmd_Unk008D(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk008E(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetTreasureCount(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -128,7 +128,7 @@ THUMB_FUNC BOOL ScrCmd_Unk008E(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk008F(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GiveUndergroundSphere(struct ScriptContext* ctx)
{
struct SaveBlock2* sav2 = ctx->unk80->saveBlock2;
u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -141,7 +141,7 @@ THUMB_FUNC BOOL ScrCmd_Unk008F(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0090(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_TakeUndergroundSphere(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -150,7 +150,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0090(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0091(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_HasSpaceForSphere(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
@@ -159,7 +159,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0091(struct ScriptContext* ctx)
return FALSE;
}
-THUMB_FUNC BOOL ScrCmd_Unk0092(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GetSphereCount(struct ScriptContext* ctx)
{
u16 unused1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 unused2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
diff --git a/arm9/src/script.c b/arm9/src/script.c
index 2fa80058..3de2ee73 100644
--- a/arm9/src/script.c
+++ b/arm9/src/script.c
@@ -76,7 +76,7 @@ THUMB_FUNC u8 RunScriptCommand(struct ScriptContext *ctx)
cmdCode = ScriptReadHalfword(ctx);
if (cmdCode >= ctx->cmdCount)
{
- ErrorHandling();
+ GF_AssertFail();
ctx->mode = 0;
return FALSE;
}
diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c
index e9a55051..1242d550 100644
--- a/arm9/src/script_buffers.c
+++ b/arm9/src/script_buffers.c
@@ -12,6 +12,7 @@
#include "trainer_data.h"
#include "script_buffers.h"
#include "unk_02024E64.h"
+#include "text.h"
#pragma thumb on
@@ -19,10 +20,8 @@ extern u32 GetCityNamesMsgdataIdByCountry(u32);
extern void GetECWordIntoStringByIndex(u32 a0, struct String * a1);
extern void StringCat_HandleTrainerName(struct String * dest, const struct String * src);
extern void StrAddChar(struct String * str, u16 val);
-extern void * FUN_02006BB0(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32);
-extern BOOL UncompressFromNarc(NarcId narcId, s32 memberNo, BOOL a2, u32 heap_id, BOOL a4);
-extern void FUN_02019658(int, u8 *, u16, u16, u16, u16, u16, u16, u16, u16);
-extern void FUN_020196F4(int, u8, u16, u16, u16, u16);
+extern void * GfGfxLoader_GetCharData(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32);
+extern void * GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, u32 heap_id, BOOL allocAtEnd);
const u16 UNK_020ECE6C[][2] = {
{ 0x0140, 0x0008 },
@@ -752,7 +751,7 @@ struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4)
struct UnkStruct_0200B870 * sp8 = AllocFromHeap(r4, sizeof(struct UnkStruct_0200B870));
if (sp8 != NULL)
{
- sp8->unk_0 = FUN_02006BB0(NARC_GRAPHIC_FONT, 4, 1, &sp8->unk_4, r4);
+ sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 4, 1, &sp8->unk_4, r4);
int i;
u8 * ptr = sp8->unk_4->unk_14;
for (i = 0; i < sp8->unk_4->unk_10; i++)
@@ -803,24 +802,24 @@ void MessagePrinter_delete(struct UnkStruct_0200B870 * a0)
}
}
-void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, int a2, int a3, int a4)
+void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, struct Window *a2, int a3, int a4)
{
- FUN_02019658(a2, a0->unk_4->unk_14 + UNK_020ECE6C[a1][0], 0, 0, UNK_020ECE6C[a1][1], 8, (u16)a3, (u16)a4, UNK_020ECE6C[a1][1], 8);
+ BlitBitmapRectToWindow(a2, a0->unk_4->unk_14 + UNK_020ECE6C[a1][0], 0, 0, UNK_020ECE6C[a1][1], 8, (u16)a3, (u16)a4, UNK_020ECE6C[a1][1], 8);
}
-void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, int sp30, int r5, int r7)
+void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y)
{
ConvertUIntToDecimalString(string->data, value, mode, n);
for (int i = 0; string->data[i] != EOS; i++)
{
- if (string->data[i] >= 0x00A2 && string->data[i] <= 0x00AB)
+ if (string->data[i] >= CHAR_0 && string->data[i] <= CHAR_9)
{
- FUN_02019658(sp30, string->unk_4->unk_14 + (string->data[i] - 0x00A2) * 32, 0, 0, 8, 8, (u16)r5, (u16)r7, 8, 8);
+ BlitBitmapRectToWindow(window, string->unk_4->unk_14 + (string->data[i] - CHAR_0) * 32, 0, 0, 8, 8, (u16)x, (u16)y, 8, 8);
}
else
{
- FUN_020196F4(sp30, (u8)string->unk_28, (u16)r5, (u16)r7, 8, 8);
+ FillWindowPixelRect(window, (u8)string->unk_28, (u16)x, (u16)y, 8, 8);
}
- r5 += 8;
+ x += 8;
}
}
diff --git a/arm9/src/script_pokemon_util.c b/arm9/src/script_pokemon_util.c
index a3518bf4..55519ca3 100644
--- a/arm9/src/script_pokemon_util.c
+++ b/arm9/src/script_pokemon_util.c
@@ -109,7 +109,7 @@ struct Pokemon * GetFirstAliveMonInParty_CrashIfNone(struct PlayerParty * party)
if(MonNotFaintedOrEgg(mon))
return mon;
}
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
diff --git a/arm9/src/sound.c b/arm9/src/sound.c
index a1e31bbd..a5228dab 100644
--- a/arm9/src/sound.c
+++ b/arm9/src/sound.c
@@ -6,12 +6,13 @@
#pragma thumb on
static struct SoundData sSoundDataBuffer;
-static u32 UNK_02107070[2];
+static u32 UNK_02107070;
+static u32 UNK_02107074;
void FUN_02003C40(void);
BOOL FUN_02003D04(void);
-void FUN_020040C8(void);
-void FUN_02004064(struct SoundData *);
+void GF_InitMic(void);
+void GF_SoundDataInit(struct SoundData *);
void FUN_02004088(struct SoundData *);
void FUN_020040A4(struct SoundData *);
void FUN_02003CE8(int);
@@ -25,20 +26,20 @@ extern void FUN_0200538C(int, int, int);
extern BOOL FUN_02005404(void);
extern void FUN_02005CFC(void);
-void InitSoundData(void * a0, struct Options * a1)
+void InitSoundData(struct SaveChatotSoundClip * chatot, struct Options * options)
{
struct SoundData * sdat = GetSoundDataPointer();
- SDAT_Init();
- FUN_020040C8();
- FUN_02004064(sdat);
- sdat->unk_00090 = FUN_020C2A94(sdat->unk_00094, sizeof(sdat->unk_00094));
- SDAT_Open(&sdat->header, "data/sound/sound_data.sdat", sdat->unk_00090, 0);
- FUN_020C39CC(sdat->unk_00090);
+ NNS_SndInit();
+ GF_InitMic();
+ GF_SoundDataInit(sdat);
+ sdat->heap = NNS_SndHeapCreate(sdat->heapBuffer, sizeof(sdat->heapBuffer));
+ NNS_SndArcInit(&sdat->header, "data/sound/sound_data.sdat", sdat->heap, 0);
+ NNS_SndArcPlayerSetup(sdat->heap);
FUN_02004088(sdat);
FUN_020040A4(sdat);
- UNK_02107070[1] = 0;
- sdat->unk_BCD4C = a0;
- FUN_02004D60(a1->soundMethod);
+ UNK_02107074 = 0;
+ sdat->chatot = chatot;
+ FUN_02004D60(options->soundMethod);
}
void DoSoundUpdateFrame(void)
@@ -51,13 +52,13 @@ void DoSoundUpdateFrame(void)
FUN_02003C40();
}
FUN_02005CFC();
- FUN_020C01A0();
+ NNS_SndMain();
}
void FUN_02003C40(void)
{
struct SoundData * sdat = GetSoundDataPointer();
- switch (UNK_02107070[0])
+ switch (UNK_02107070)
{
case 1:
FUN_02003CE8(2);
@@ -92,7 +93,7 @@ void FUN_02003CE8(int a0)
{
struct SoundData * sdat = GetSoundDataPointer();
sdat->unk_BCCFC = 0;
- UNK_02107070[0] = (u32)a0;
+ UNK_02107070 = (u32)a0;
}
BOOL FUN_02003D04(void)
@@ -184,7 +185,7 @@ void * FUN_02003D38(u32 a0)
case 34:
return &sdat->unk_BCD48;
case 35:
- return &sdat->unk_BCD4C;
+ return &sdat->chatot;
case 36:
return &sdat->unk_BCD50;
case 37:
@@ -199,61 +200,61 @@ void * FUN_02003D38(u32 a0)
}
}
-int FUN_02003F3C(int * a0)
+int GF_Snd_SaveState(int * level_p)
{
struct SoundData * sdat = GetSoundDataPointer();
- int r4 = FUN_020C290C(sdat->unk_00090);
- GF_ASSERT(r4 != -1);
- if (a0 != NULL)
- *a0 = r4;
- return r4;
+ int level = NNS_SndHeapSaveState(sdat->heap);
+ GF_ASSERT(level != -1);
+ if (level_p != NULL)
+ *level_p = level;
+ return level;
}
-void FUN_02003F64(int a0)
+void GF_Snd_RestoreState(int level)
{
struct SoundData * sdat = GetSoundDataPointer();
- FUN_020C2828(sdat->unk_00090, a0);
+ NNS_SndHeapLoadState(sdat->heap, level);
}
-BOOL FUN_02003F78(u32 * a0)
+BOOL GF_Snd_LoadGroup(int groupNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return FUN_020C36A8(a0, sdat->unk_00090);
+ return NNS_SndArcLoadGroup(groupNo, sdat->heap);
}
-BOOL FUN_02003F90(u32 * a0)
+BOOL GF_Snd_LoadSeq(int seqNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return FUN_020C3674(a0, sdat->unk_00090);
+ return NNS_SndArcLoadSeq(seqNo, sdat->heap);
}
-BOOL FUN_02003FA8(u32 * a0, u32 * a1)
+BOOL GF_Snd_LoadSeqEx(int seqNo, u32 loadFlag)
{
struct SoundData * sdat = GetSoundDataPointer();
- return FUN_020C35E0(a0, a1, sdat->unk_00090);
+ return NNS_SndArcLoadSeqEx(seqNo, loadFlag, sdat->heap);
}
-BOOL FUN_02003FC4(u32 * a0)
+BOOL GF_Snd_LoadWaveArc(int waveArcNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return FUN_020C360C(a0, sdat->unk_00090);
+ return NNS_SndArcLoadWaveArc(waveArcNo, sdat->heap);
}
-BOOL FUN_02003FDC(u32 * a0)
+BOOL GF_Snd_LoadBank(int bankNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return FUN_020C3640(a0, sdat->unk_00090);
+ return NNS_SndArcLoadBank(bankNo, sdat->heap);
}
-u32 * FUN_02003FF4(int a0)
+u32 * FUN_02003FF4(int playerNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- if (a0 >= 9)
+ if (playerNo >= (s32)NELEMS(sdat->players))
{
GF_ASSERT(0);
- a0 = 0;
+ playerNo = 0;
}
- return &sdat->unk_BBC94[a0];
+ return &sdat->players[playerNo];
}
u32 FUN_02004018(u32 a0)
@@ -282,7 +283,7 @@ u32 FUN_02004018(u32 a0)
}
}
-void FUN_02004064(struct SoundData * sdat)
+void GF_SoundDataInit(struct SoundData * sdat)
{
int i;
memset(sdat, 0, sizeof(*sdat));
@@ -295,18 +296,18 @@ void FUN_02004088(struct SoundData * sdat)
int i;
for (i = 0; i < 9; i++)
{
- FUN_020C0F80(&sdat->unk_BBC94[i]);
+ NNS_SndHandleInit(&sdat->players[i]);
}
}
void FUN_020040A4(struct SoundData * sdat)
{
- FUN_02003F3C(&sdat->unk_BCD1C[0]);
- FUN_02003F78(NULL);
- FUN_02003F3C(&sdat->unk_BCD1C[1]);
+ GF_Snd_SaveState(&sdat->unk_BCD1C[0]);
+ GF_Snd_LoadGroup(0);
+ GF_Snd_SaveState(&sdat->unk_BCD1C[1]);
}
-void FUN_020040C8(void)
+void GF_InitMic(void)
{
MIC_Init();
PM_SetAmp(1);
@@ -315,7 +316,7 @@ void FUN_020040C8(void)
void FUN_020040DC(void)
{
- FUN_020C1040(7, 0);
+ NNS_SndPlayerStopSeqByPlayerNo(7, 0);
FUN_02003FF4(7);
- FUN_020C0F68();
+ NNS_SndHandleReleaseSeq();
}
diff --git a/arm9/src/text.c b/arm9/src/text.c
index aadb84c0..36349b8b 100644
--- a/arm9/src/text.c
+++ b/arm9/src/text.c
@@ -2,27 +2,26 @@
#include "heap.h"
#include "string16.h"
#include "MI_memory.h"
+#include "filesystem.h"
+#include "script_buffers.h"
+#include "unk_0200CA44.h"
const struct FontInfo *gFonts = NULL;
u16 UNK_021C5734[0x100];
-u32 UNK_021C5714[8];
-u8 UNK_021C570C[8];
-
-extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2);
+BOOL UNK_021C5714[8];
+u16 UNK_021C570E;
+u16 UNK_021C5710;
+u16 UNK_021C5712;
+u8 UNK_021C570C;
extern struct TextPrinter *FUN_0201B6C8(void);
-extern void FUN_0200CAB4(u32 param0);
extern void FUN_0201C1A8(struct TextPrinter *printer);
-extern void CopyWindowToVram(u32 windowId);
extern u32 FontFunc(u8 fontId, struct TextPrinter *printer);
-extern void *FUN_02006BB0(u32 param0, u32 param1, u32 param2, struct TextPrinter **param3, u32 param4);
-
-extern u32 FUN_0201AB0C(u32 windowId);
-extern void FUN_02019658(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5, u32 param6, u32 param7, u32 param8, u32 param9);
+extern void * GfGfxLoader_GetCharData(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32);
THUMB_FUNC void SetFontsPointer(const struct FontInfo *fonts)
@@ -96,12 +95,12 @@ THUMB_FUNC void FUN_0201BD7C(u32 param0)
FUN_0201BCFC(param0);
}
-THUMB_FUNC u16 AddTextPrinterParameterized(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u8 (*callback)(struct TextPrinterTemplate *, u16))
+THUMB_FUNC u16 AddTextPrinterParameterized(struct Window * window, u8 fontId, struct String *str, u32 x, u32 y, u32 speed, u8 (*callback)(struct TextPrinterTemplate *, u16))
{
struct TextPrinterTemplate printerTemplate;
- printerTemplate.windowId = windowId;
- printerTemplate.currentChar = str;
+ printerTemplate.window = window;
+ printerTemplate.currentChar.wrapped = str;
printerTemplate.fontId = fontId;
printerTemplate.x = (u8)x;
printerTemplate.y = (u8)y;
@@ -119,12 +118,12 @@ THUMB_FUNC u16 AddTextPrinterParameterized(u32 windowId, u8 fontId, const u16 *s
return AddTextPrinter(&printerTemplate, speed, callback);
}
-THUMB_FUNC u16 AddTextPrinterParameterized2(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u8 (*callback)(struct TextPrinterTemplate *, u16))
+THUMB_FUNC u16 AddTextPrinterParameterized2(struct Window * window, u8 fontId, struct String *str, u32 x, u32 y, u32 speed, u32 colors, u8 (*callback)(struct TextPrinterTemplate *, u16))
{
struct TextPrinterTemplate printerTemplate;
- printerTemplate.windowId = windowId;
- printerTemplate.currentChar = str;
+ printerTemplate.window = window;
+ printerTemplate.currentChar.wrapped = str;
printerTemplate.fontId = fontId;
printerTemplate.x = (u8)x;
printerTemplate.y = (u8)y;
@@ -142,13 +141,13 @@ THUMB_FUNC u16 AddTextPrinterParameterized2(u32 windowId, u8 fontId, const u16 *
return AddTextPrinter(&printerTemplate, speed, callback);
}
-THUMB_FUNC u16 AddTextPrinterParameterized3(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u32 letterSpacing, u32 lineSpacing, u8 (*callback)(struct TextPrinterTemplate *, u16))
+THUMB_FUNC u16 AddTextPrinterParameterized3(struct Window * window, u32 fontId, struct String *str, u32 x, u32 y, u32 speed, u32 colors, u32 letterSpacing, u32 lineSpacing, u8 (*callback)(struct TextPrinterTemplate *, u16))
{
struct TextPrinterTemplate printerTemplate;
- printerTemplate.windowId = windowId;
- printerTemplate.currentChar = str;
- printerTemplate.fontId = fontId;
+ printerTemplate.window = window;
+ printerTemplate.currentChar.wrapped = str;
+ printerTemplate.fontId = (u8)fontId;
printerTemplate.x = (u8)x;
printerTemplate.y = (u8)y;
printerTemplate.currentX = (u8)x;
@@ -185,13 +184,13 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s
}
printer->printerTemplate = *printerTemplate;
- printer->printerTemplate.currentChar = String_c_str((struct String *)printer->printerTemplate.currentChar); //TODO clean up
+ printer->printerTemplate.currentChar.raw = String_c_str(printer->printerTemplate.currentChar.wrapped);
printer->callback = callback;
- UNK_021C570C[0] = 0;
+ UNK_021C570C = 0;
FUN_0201C1A8(printer);
if (speed != 0xff && speed != 0)
{
- printer->textSpeedBottom += 0xff;
+ printer->textSpeedBottom--;
printer->textSpeedTop = 1;
printer->minLetterSpacing = FUN_0201BCC8(RunTextPrinter, printer, 1);
return printer->minLetterSpacing;
@@ -211,7 +210,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s
}
if (speed != 0xff)
{
- CopyWindowToVram(printer->printerTemplate.windowId); // CopyWindowToVram?
+ CopyWindowToVram(printer->printerTemplate.window);
}
FUN_0201C238(printer);
FreeToHeap((void *)printer);
@@ -222,7 +221,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s
THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer)
{
#pragma unused(param0)
- if (UNK_021C570C[0] == 0)
+ if (UNK_021C570C == 0)
{
if (printer->Unk29 == 0)
{
@@ -232,7 +231,7 @@ THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer)
switch (temp)
{
case 0:
- CopyWindowToVram(printer->printerTemplate.windowId);
+ CopyWindowToVram(printer->printerTemplate.window);
//fallthrough
case 3:
if (printer->callback == NULL)
@@ -268,156 +267,39 @@ THUMB_FUNC u32 RenderFont(struct TextPrinter *printer)
}
}
-#ifdef NONMATCHING
THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
{
- u32 fg12, bg12, shadow12;
- u32 temp;
-
- u16 *current = UNK_021C570C;
-
- bg12 = bgColor << 12;
- fg12 = fgColor << 12;
- shadow12 = shadowColor << 12;
-
- temp = (bgColor << 8) | (bgColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (bgColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (bgColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (fgColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (fgColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (fgColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (shadowColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (shadowColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (shadowColor << 4) | bgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (bgColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (bgColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (bgColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (fgColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (fgColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (fgColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (shadowColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (shadowColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (shadowColor << 4) | fgColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (bgColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (bgColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (bgColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (fgColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (fgColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (fgColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (bgColor << 8) | (shadowColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (fgColor << 8) | (shadowColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
-
- temp = (shadowColor << 8) | (shadowColor << 4) | shadowColor;
- *(current++) = (bg12) | temp;
- *(current++) = (fg12) | temp;
- *(current++) = (shadow12) | temp;
+ s32 r5 = 0;
+ u32 sp20[4];
+ s32 i; // sp14
+ s32 j; // sp10
+ s32 k; // spC
+ s32 l; // r3
+
+ sp20[0] = 0;
+ sp20[1] = fgColor;
+ sp20[2] = shadowColor;
+ sp20[3] = bgColor;
+
+ // FIXME: Need these to be accessed by a pointer to UNK_021C570C
+ UNK_021C5712 = bgColor;
+ UNK_021C570E = fgColor;
+ UNK_021C5710 = shadowColor;
+
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ for (k = 0; k < 4; k++)
+ {
+ for (l = 0; l < 4; l++)
+ {
+ UNK_021C5734[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0));
+ }
+ }
+ }
+ }
}
-#else
-GLOBAL_ASM("asm/nonmatchings/GenerateFontHalfRowLookupTable.s")
-#endif
THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst)
{
@@ -444,12 +326,12 @@ THUMB_FUNC void FUN_0201C1A8(struct TextPrinter *printer)
printer->Unk2C = NULL;
}
-THUMB_FUNC void *FUN_0201C1B0(void)
+THUMB_FUNC u16 *FUN_0201C1B0(void)
{
- void *res = AllocFromHeap(0, sizeof(struct TextPrinter) * 32);
- struct TextPrinter *var;
- void *tmp = FUN_02006BB0(14, 5, 0, &var, 0);
- MIi_CpuCopy32((void *)var->printerTemplate.Unk20, res, sizeof(struct TextPrinter) * 32); //todo Unk20 can't be right here
+ void *res = AllocFromHeap(0, 32 * 24 * sizeof(u16));
+ struct UnkStruct_0200B870_sub * var;
+ void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 5, 0, &var, 0);
+ MI_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16));
FreeToHeap(tmp);
return res;
}
@@ -457,14 +339,14 @@ THUMB_FUNC void *FUN_0201C1B0(void)
THUMB_FUNC void FUN_0201C1EC(struct TextPrinter *printer, u32 param1, u32 param2, u32 param3)
{
#pragma unused (param1, param2)
- u32 windowId = printer->printerTemplate.windowId;
+ struct Window * window = printer->printerTemplate.window;
if (printer->Unk2C == NULL)
{
printer->Unk2C = FUN_0201C1B0();
}
- u32 r6 = (u32)printer->Unk2C + param3 * (sizeof(struct TextPrinter) * 8);
- u32 r2 = ((FUN_0201AB0C(windowId) - 3) << 0x13) >> 0x10;
- FUN_02019658(windowId, r6, 0, 0, 24, 32, r2, 0, 24, 32);
+ u16 * r6 = printer->Unk2C + param3 * 24 * 8;
+ u16 r2 = (u16)((GetWindowWidth(window) - 3) * 8);
+ BlitBitmapRectToWindow(window, r6, 0, 0, 24, 32, r2, 0, 24, 32);
}
THUMB_FUNC void FUN_0201C238(struct TextPrinter *printer)
diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c
index 470a2fe3..dcbad024 100644
--- a/arm9/src/text_02054590.c
+++ b/arm9/src/text_02054590.c
@@ -1,25 +1,27 @@
#include "text_02054590.h"
#include "text.h"
+#include "unk_02016B94.h"
extern void FUN_0201BD5C(void);
extern void FUN_02002ED0(u32 param0, u32 param1, u32 param2);
extern void FUN_02002EEC(u32 param0, u32 param1, u32 param2);
-extern void FUN_02019064(u32 param0, u32 param1, u32 param2, u8 param3, u32 param4, u8 param5, u32 param6, u32 param7, u32 param8);
-
-extern void FUN_0200CD68(u32 param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5);
-extern u32 FUN_0201AB08(u32 *param0);
-extern void FUN_0200D0BC(u32 *param0, u32 param1, u32 param2, u32 param3);
-
-extern void FUN_02019620(u32 *param0, u32 param1);
+extern void FUN_0200CD68(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5);
+extern void FUN_0200D0BC(struct Window *param0, u32 param1, u32 param2, u32 param3);
extern void FUN_02002B60(u8 param0);
extern void FUN_02002B7C(u32 param0);
extern void FUN_02002BB8(u32 param0);
-extern void FUN_0200D300(u32 param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5, u32 param6);
-extern void FUN_0200D6F8(u32 *param0, u32 param1, u32 param2, u32 param3, u8 param4);
-
+extern void FUN_0200D300(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ u32 param2,
+ u32 param3,
+ u8 param4,
+ u32 param5,
+ u32 param6);
+extern void FUN_0200D6F8(struct Window *param0, u32 param1, u32 param2, u32 param3, u8 param4);
THUMB_FUNC void FUN_02054590(u32 param0, u32 param1)
{
@@ -31,7 +33,7 @@ THUMB_FUNC void FUN_02054590(u32 param0, u32 param1)
FUN_02002EEC(param0, 384, 4);
}
-THUMB_FUNC void FUN_020545B8(u32 param0, u32 param1, u32 param2)
+THUMB_FUNC void FUN_020545B8(struct UnkStruct_02016B94_2 *param0, struct Window *param1, u32 param2)
{
if (param2 == 3)
{
@@ -43,40 +45,41 @@ THUMB_FUNC void FUN_020545B8(u32 param0, u32 param1, u32 param2)
}
}
-THUMB_FUNC void FUN_02054608(u32 *param0, struct Options *options)
+THUMB_FUNC void FUN_02054608(struct Window *param0, struct Options *options)
{
- FUN_0200CD68(*param0, FUN_0201AB08(param0), 994, 10, (u8)Options_GetFrame(options), 4);
+ FUN_0200CD68(param0->unk00, FUN_0201AB08(param0), 994, 10, (u8)Options_GetFrame(options), 4);
FUN_0205464C(param0);
FUN_0200D0BC(param0, 0, 994, 10);
}
-THUMB_FUNC void FUN_0205464C(u32 *param0)
+THUMB_FUNC void FUN_0205464C(struct Window *param0)
{
- FUN_02019620(param0, 15);
+ FillWindowPixelBuffer(param0, 15);
}
-THUMB_FUNC u16 FUN_02054658(u8 windowId, const u16 *str, struct Options *options, u8 param3)
+THUMB_FUNC u16 FUN_02054658(struct Window * window, struct String *str, struct Options *options, u8 param3)
{
FUN_02002B60(param3);
FUN_02002B7C(0);
FUN_02002BB8(0);
- return AddTextPrinterParameterized(windowId, 1, str, 0, 0, (u32)Options_GetTextFrameDelay(options), NULL);
+ return AddTextPrinterParameterized(window, 1, str, 0, 0, (u32)Options_GetTextFrameDelay(options), NULL);
}
-THUMB_FUNC u16 DrawFieldMessage(u8 windowId, const u16 *str, u8 fontId, u32 speed, u8 a4, u32 a5)
+THUMB_FUNC u16 DrawFieldMessage(struct Window * window, struct String *str, u8 fontId, u32 speed, u8 a4, u32 a5)
{
FUN_02002B60(a4);
FUN_02002B7C(a5);
FUN_02002BB8(0);
- return AddTextPrinterParameterized(windowId, fontId, str, 0, 0, speed, NULL);
+ return AddTextPrinterParameterized(window, fontId, str, 0, 0, speed, NULL);
}
-THUMB_FUNC u8 FUN_020546C8(u32 param0) //bool8?
+THUMB_FUNC u8 FUN_020546C8(u32 param0) // bool8?
{
return !FUN_0201BD70(param0);
}
-THUMB_FUNC void FUN_020546E0(u32 param0, u32 param1, u32 param2, u32 param3)
+THUMB_FUNC void FUN_020546E0(
+ struct UnkStruct_02016B94_2 *param0, struct Window *param1, u32 param2, u32 param3)
{
u32 r4 = 0;
u32 r5 = 0;
@@ -100,9 +103,9 @@ THUMB_FUNC void FUN_020546E0(u32 param0, u32 param1, u32 param2, u32 param3)
}
}
-THUMB_FUNC void FUN_02054744(u32 *param0, u32 param1, u32 param2)
+THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u32 param2)
{
- FUN_0200D300(*param0, FUN_0201AB08(param0), 0x399, 9, (u8)param1, param2, 4);
- FUN_02019620(param0, 15);
+ FUN_0200D300(param0->unk00, FUN_0201AB08(param0), 0x399, 9, (u8)param1, param2, 4);
+ FillWindowPixelBuffer(param0, 15);
FUN_0200D6F8(param0, 0, 0x399, 9, (u8)param1);
}
diff --git a/arm9/src/unk_0200BA78.c b/arm9/src/unk_0200BA78.c
new file mode 100644
index 00000000..457001ef
--- /dev/null
+++ b/arm9/src/unk_0200BA78.c
@@ -0,0 +1,36 @@
+#include "global.h"
+#include "unk_0200BA78.h"
+#include "script_buffers.h"
+
+THUMB_FUNC void FUN_0200BA78(struct UnkStruct_0200B870 *param0,
+ int param1,
+ u32 value,
+ u32 n,
+ enum PrintingMode mode,
+ struct Window *window,
+ int x,
+ int y)
+{
+ FUN_0200B9A8(param0, param1, window, x, y);
+ FUN_0200B9EC(param0, value, n, mode, window, x + 16, y);
+}
+
+THUMB_FUNC void FUN_0200BAAC(
+ struct UnkStruct_0200B870 *param0, u32 value, u32 n, enum PrintingMode mode, void *dest)
+{
+ u8 st0 = (u8)((param0->unk_28 << 4) | param0->unk_28);
+ ConvertUIntToDecimalString(param0->data, value, mode, n);
+
+ for (int i = 0; param0->data[i] != 0xffff; i++)
+ {
+ if (param0->data[i] >= 0xa2 && param0->data[i] <= 0xab)
+ {
+ MI_CpuCopy32(
+ &param0->unk_4->unk_14[(param0->data[i] - 0xa2) << 5], dest + i * 0x20, 0x20);
+ }
+ else
+ {
+ MI_CpuFill8(dest + i * 0x20, st0, 0x20);
+ }
+ }
+}
diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c
new file mode 100644
index 00000000..45850885
--- /dev/null
+++ b/arm9/src/unk_0200BB14.c
@@ -0,0 +1,1323 @@
+#include "global.h"
+#include "unk_0200BB14.h"
+#include "game_init.h"
+#include "heap.h"
+
+extern void FUN_0201D060(u32 *param0, u32 param1, u32 param2);
+extern void FUN_0201E00C(u32 param0, u32 param1);
+extern void NNS_G2dInitOamManagerModule();
+extern void FUN_02009EAC(u32 param0,
+ u32 param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7,
+ u32 param8);
+extern u32 FUN_0201C328(u32 param0, u32 param1);
+extern void FUN_0201D168();
+extern void FUN_0201E0BC();
+extern u32 FUN_02008C9C(u32 param0, void *param1, u32 param2);
+extern void FUN_0201FFC8(u32 param0);
+extern void FUN_0201FDEC(u32 param0);
+extern void FUN_02009F80();
+extern void FUN_0201C348();
+extern void FUN_0201FD58(u32 param0);
+extern void FUN_02008C80(u32 param0);
+extern u32 FUN_02009660(u32 *param0, s32 param1);
+extern void FUN_020096B4(u32 param0);
+extern void FUN_02009C30(u32 *param0);
+extern void FUN_02009E28(u32 *param0);
+extern void FUN_02009448(u32 *param0);
+extern void FUN_02008E2C(u32 param0);
+extern void FUN_0201C350(u32 param0);
+extern void FUN_0201D12C();
+extern void FUN_0201E08C();
+extern void FUN_02009FA0();
+extern u32 FUN_0200965C(s32 param0);
+extern void FUN_02009668(void *param0, u32 param1, u32 param2);
+extern u32 FUN_020096CC(u32 param0);
+extern u32 FUN_02008DEC(u32 param0, s32 param1, u32 param2);
+extern u32 *FUN_02009424(u32 param0, u32 param1);
+extern u32 FUN_020093A8(u32 param0, u32 param1, u32 *param2, u32 param3);
+extern void FUN_02009A90(u32 *param0);
+extern void FUN_02009D34(u32 *param0);
+extern u32 FUN_02008BE0(void *param0,
+ u32 param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7);
+extern u32 FUN_0201FE94(struct UnkStruct_0200BB14_4 *param0);
+extern void FUN_02020130(u32 param0, u32 param1);
+extern void FUN_02020248(u32 param0, u32 param1);
+extern u32 FUN_0200945C(u32 param0, s32 param1);
+extern u32 FUN_02008F34(
+ u32 param0, u32 param1, u32 param2, u32 param3, s32 param4, u32 param5, u32 param6);
+extern void FUN_02009B04(u32 param0);
+extern u32 FUN_02008FEC(
+ u32 param0, u32 param1, u32 param2, u32 param3, s32 param4, u32 param5, u32 param6, u32 param7);
+extern u32 FUN_02009D68(u32 param0);
+extern u32 FUN_02009E88(u32 param0, u32 param1);
+extern void FUN_02003108(u32 param0, u32 param1, u16 param2, u32 param3);
+extern void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0,
+ s32 param1,
+ s32 param2,
+ s32 param3,
+ s32 param4,
+ s32 param5,
+ s32 param6,
+ u32 param7,
+ u32 param8,
+ u32 param9,
+ u32 param10,
+ u32 param11,
+ u32 param12,
+ u32 param13,
+ u32 param14);
+extern u8 FUN_020202A0(u32 param0);
+extern u32 FUN_020094F0(u32 param0, u32 param1);
+extern u32 FUN_02009E54(u32 param0, u32 param1);
+extern void FUN_02009CDC(u32 param0);
+extern u32 FUN_020090AC(
+ u32 param0, u32 param1, u32 param2, u32 param3, s32 param4, u32 param5, u32 param6);
+extern u32 FUN_02009530(u32 param0);
+extern void FUN_02009490(u32 param0, u32 param1);
+extern void FUN_0201D324(u32 param0);
+extern void FUN_0201E1C8(u32 param0);
+extern void FUN_020201E4(u32 param0, u32 param1);
+extern u32 FUN_020201DC(u32 param0);
+extern void FUN_020200BC(u32 param0, u32 param1);
+extern void FUN_020200D8(u32 param0, u32 param1);
+extern u32 FUN_02020388(u32 param0);
+extern void FUN_02020208(u32 param0);
+extern void FUN_0202022C(u32 param0);
+extern void FUN_020200A0(u32 param0, u32 param1);
+extern u8 FUN_02020128(u32 param0);
+extern void FUN_020202A8(u32 param0, u32 param1);
+extern u8 FUN_02020300(u32 param0);
+extern void FUN_02020238(u32 param0, u8 param1);
+extern u8 FUN_02020240(u32 param0);
+extern void FUN_02020310(u32 param0, u32 param1);
+extern u16 FUN_0202032C(u32 param0);
+extern u32 FUN_02020380(u32 param0);
+extern void FUN_02020044(u32 param0, u32 *param1);
+extern u32 *FUN_0202011C(u32 param0, u16 *param1, u16 *param2);
+extern void FUN_020200EC(u32 param0, u32 param1);
+extern u32 *FUN_02020120(u32 param0);
+extern void FUN_02020064(u32 param0, s32 *param1);
+extern void FUN_02020088(u32 param0, u16 param1);
+extern u16 FUN_02020124(u32 param0);
+extern void FUN_02020100(u32 param0, u32 param1);
+extern void FUN_02020054(u32 param0, u32 *param1);
+extern void FUN_02020358(u32 param0, u32 param1);
+extern void FUN_02020398(u32 param0, u32 param1);
+extern void FUN_02009AC4(u32 param0);
+extern void FUN_02009B78(u32 param0);
+extern void FUN_020090FC(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5);
+extern void FUN_02009BE8(u32 param0);
+extern void FUN_02009168(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5);
+extern void FUN_02009DE0(u32 param0);
+
+THUMB_FUNC struct UnkStruct_0200BB14_1 *FUN_0200BB14(u32 heap_id)
+{
+ struct UnkStruct_0200BB14_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200BB14_1));
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
+ ptr->unk000 = heap_id;
+ ptr->unk004 = 0;
+ ptr->unk008 = 1;
+
+ return ptr;
+}
+
+THUMB_FUNC struct UnkStruct_0200BB14_2 *FUN_0200BB34(struct UnkStruct_0200BB14_1 *param0)
+{
+ GF_ASSERT(param0 != NULL);
+
+ struct UnkStruct_0200BB14_2 *ptr =
+ AllocFromHeap(param0->unk000, sizeof(struct UnkStruct_0200BB14_2));
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
+ param0->unk004++;
+
+ for (s32 i = 0; i < 6; i++)
+ {
+ ptr->unk0c[i] = 0;
+ }
+
+ return ptr;
+}
+
+THUMB_FUNC u32 FUN_0200BB68(u32 param0)
+{
+ return param0 + 0x10;
+}
+
+THUMB_FUNC BOOL FUN_0200BB6C(
+ struct UnkStruct_0200BB14_1 *param0, u32 *param1, u32 *param2, u32 param3)
+{
+ GF_ASSERT(param0 != NULL);
+
+ if (param0 == NULL)
+ {
+ return FALSE;
+ }
+
+ u32 st14[4] = { param2[0], param2[1], param2[2], param0->unk000 };
+
+ FUN_0201D060(st14, param2[3], param2[4]);
+ FUN_0201E00C(param3, param0->unk000);
+ NNS_G2dInitOamManagerModule();
+
+ if (param0->unk008 == 1)
+ {
+ FUN_02009EAC(param1[0],
+ param1[1],
+ param1[2],
+ param1[3],
+ param1[4],
+ param1[5],
+ param1[6],
+ param1[7],
+ param0->unk000);
+ }
+
+ param0->unk00c = FUN_0201C328(0x20, param0->unk000);
+ FUN_0201D168();
+ FUN_0201E0BC();
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL FUN_0200BBF0(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, u32 param2)
+{
+ if (param0 == NULL || param1 == NULL)
+ {
+ return FALSE;
+ }
+
+ param1->unk00 = FUN_02008C9C(param2, param0->unk010, param0->unk000);
+
+ return TRUE;
+}
+
+THUMB_FUNC void FUN_0200BC14(u32 param0)
+{
+ FUN_0201FFC8(param0);
+}
+
+THUMB_FUNC void FUN_0200BC1C(u32 *param0)
+{
+ GF_ASSERT(param0 != NULL);
+
+ FUN_0201FDEC(*param0);
+}
+
+THUMB_FUNC void FUN_0200BC30()
+{
+ FUN_02009F80();
+}
+
+THUMB_FUNC void FUN_0200BC38()
+{
+ FUN_0201C348();
+}
+
+THUMB_FUNC void FUN_0200BC40(struct UnkStruct_0200BB14_2 *param0)
+{
+ FUN_0201FD58(param0->unk00);
+}
+
+THUMB_FUNC void FUN_0200BC4C(struct UnkStruct_0200BB14_2 *param0)
+{
+ if (param0->unk04 != 0)
+ {
+ FUN_02008C80(param0->unk04);
+ }
+}
+
+THUMB_FUNC void FUN_0200BC5C(struct UnkStruct_0200BB14_2 *param0)
+{
+ for (s32 i = 0; i < param0->unk54; i++)
+ {
+ FUN_020096B4(FUN_02009660(param0->unk08, i));
+ }
+
+ FreeToHeap(param0->unk08);
+ FUN_02009C30(param0->unk24[0]);
+ FUN_02009E28(param0->unk24[1]);
+
+ for (s32 i = 0; i < param0->unk54; i++)
+ {
+ FUN_02009448(param0->unk24[i]);
+ FUN_02008E2C(param0->unk0c[i]);
+ }
+}
+
+THUMB_FUNC void FUN_0200BCB0(u32 *param0)
+{
+ FUN_0201C350(param0[3]);
+ FUN_0201D12C();
+ FUN_0201E08C();
+
+ if (param0[2] == 1)
+ {
+ FUN_02009FA0();
+ }
+}
+
+THUMB_FUNC void FUN_0200BCD0(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1)
+{
+ param0->unk004--;
+ FreeToHeap(param1);
+}
+
+THUMB_FUNC void FUN_0200BCE0(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1)
+{
+ FUN_0200BC40(param1);
+ FUN_0200BC4C(param1);
+ FUN_0200BC5C(param1);
+ FUN_0200BCD0(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200BD04(u32 *param0)
+{
+ GF_ASSERT(param0[1] == 0);
+ FUN_0200BCB0(param0);
+ FreeToHeap(param0);
+}
+
+THUMB_FUNC BOOL FUN_0200BD20(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, const char **param2)
+{
+ s32 st14 = 6;
+ const char **st10 = param2;
+
+ if (param0 == NULL || param1 == NULL)
+ {
+ return FALSE;
+ }
+
+ if (param2[4] == 0)
+ {
+ st14 = 4;
+ }
+
+ param1->unk54 = st14;
+ u32 r2 = FUN_0200965C(st14);
+ param1->unk08 = AllocFromHeap(param0->unk000, r2 * st14);
+
+ for (s32 i = 0; i < st14; i++)
+ {
+ u32 st18 = FUN_02009660(param1->unk08, i);
+ void *st1c = FUN_020161A4(param0->unk000, st10[i]);
+
+ FUN_02009668(st1c, st18, param0->unk000);
+ FreeToHeap(st1c);
+ }
+
+ for (s32 i = 0; i < st14; i++)
+ {
+ param1->unk0c[i] =
+ FUN_02008DEC(FUN_020096CC(FUN_02009660(param1->unk08, i)), i, param0->unk000);
+ }
+
+ for (s32 i = 0; i < st14; i++)
+ {
+ u32 st20 = FUN_02009660(param1->unk08, i);
+ param1->unk24[i] = FUN_02009424(FUN_020096CC(st20), param0->unk000);
+ param1->unk3c[i] = FUN_020093A8(param1->unk0c[i], st20, param1->unk24[i], param0->unk000);
+ }
+
+ FUN_02009A90(param1->unk24[0]);
+ FUN_02009D34(param1->unk24[1]);
+ void *r6 = FUN_020161A4(param0->unk000, st10[6]);
+ param1->unk04 = FUN_02008BE0(r6,
+ param0->unk000,
+ param1->unk0c[0],
+ param1->unk0c[1],
+ param1->unk0c[2],
+ param1->unk0c[3],
+ param1->unk0c[4],
+ param1->unk0c[5]);
+ FreeToHeap(r6);
+
+ return TRUE;
+}
+
+THUMB_FUNC u32 FUN_0200BE38(u32 *param0, u32 *param1, struct UnkStruct_0200BB14_3 *param2)
+{
+ return FUN_0200BE74(param0,
+ param1,
+ param2->unk00,
+ param2->unk04,
+ param2->unk06,
+ param2->unk04,
+ param2->unk0a,
+ param2->unk0c,
+ param2->unk10,
+ param2->unk14,
+ param2->unk18,
+ param2->unk1c,
+ param2->unk20,
+ param2->unk24);
+}
+
+THUMB_FUNC u32 FUN_0200BE74(u32 *param0,
+ u32 *param1,
+ u32 param2,
+ s16 param3,
+ s16 param4,
+ s16 param5,
+ u16 param6,
+ u32 param7,
+ u32 param8,
+ u32 param9,
+ u32 param10,
+ u32 param11,
+ u32 param12,
+ u32 param13)
+{
+#pragma unused(param10)
+#pragma unused(param11)
+#pragma unused(param12)
+#pragma unused(param13)
+
+ struct UnkStruct_0200BB14_4 st0;
+ st0.unk00 = param1[0];
+ st0.unk04 = &(*(struct UnkStruct_0200BB14_sub **)(param1[1]))[param2];
+
+ f32 r0;
+ if (param3 > 0)
+ {
+ r0 = ((f32)(param3 * 0x1000) + (f32)0.5);
+ }
+ else
+ {
+ r0 = ((f32)(param3 * 0x1000) - (f32)0.5);
+ }
+ st0.unk08 = (s32)r0;
+
+ if (param4 > 0)
+ {
+ r0 = ((f32)(param4 * 0x1000) + (f32)0.5);
+ }
+ else
+ {
+ r0 = ((f32)(param4 * 0x1000) - (f32)0.5);
+ }
+ st0.unk0c = (s32)r0;
+
+ if (param5 > 0)
+ {
+ r0 = ((f32)(param5 * 0x1000) + (f32)0.5);
+ }
+ else
+ {
+ r0 = ((f32)(param5 * 0x1000) - (f32)0.5);
+ }
+ st0.unk10 = (s32)r0;
+
+ if (param9 == 2)
+ {
+ st0.unk0c += 0xC0000;
+ }
+
+ st0.unk14 = 0x1000;
+ st0.unk18 = 0x1000;
+ st0.unk1c = 0x1000;
+ st0.unk20 = 0;
+ st0.unk24 = param7;
+ st0.unk28 = param9;
+ st0.unk2c = param0[0];
+
+ u32 r4 = FUN_0201FE94(&st0);
+ if (r4 != 0)
+ {
+ FUN_02020130(r4, param6);
+
+ FUN_02020248(r4, param8);
+ }
+
+ return r4;
+}
+
+THUMB_FUNC BOOL FUN_0200BF60(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, u32 *param2)
+{
+ struct UnkStruct_0200BB14_1 *st0 = param0;
+ s32 i;
+ s32 st4 = 6;
+
+ if (st0 == NULL || param1 == NULL)
+ {
+ return FALSE;
+ }
+
+ if (param2[4] == 0 || param2[5] == 0)
+ {
+ st4 = 4;
+ }
+
+ param1->unk54 = st4;
+
+ for (i = 0; i < st4; i++)
+ {
+ param1->unk0c[i] = FUN_02008DEC(param2[i], i, st0->unk000);
+ }
+
+ for (i = 0; i < st4; i++)
+ {
+ if (param2[i] != 0)
+ {
+ param1->unk24[i] = FUN_02009424(param2[i], st0->unk000);
+ param1->unk3c[i] = 0;
+
+ for (s32 j = 0; j < (s32)param1->unk24[i][1]; j++)
+ {
+ ((u32 *)param1->unk24[i][0])[j] = 0;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL FUN_0200C00C(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ s32 param6)
+{
+ if (FUN_0200945C(param1->unk0c[0], param6) == 0)
+ {
+ return FALSE;
+ }
+
+ u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != 0)
+ {
+ FUN_02009B04(r5);
+ FUN_0200C474(param1->unk24[0], r5);
+ return TRUE;
+ }
+
+ GF_AssertFail();
+ if (r5 != 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC s32 FUN_0200C06C(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ s32 param7)
+{
+ if (FUN_0200945C(param1->unk0c[1], param7) == 0)
+ {
+ return -1;
+ }
+
+ u32 r5 =
+ FUN_02008FEC(param1->unk0c[1], param2, param3, param4, param7, param6, param5, param0[0]);
+ if (r5 != 0)
+ {
+ GF_ASSERT(FUN_02009D68(r5) == 1);
+ FUN_0200C474(param1->unk24[1], r5);
+ return (s8)FUN_02009E88(r5, param6);
+ }
+
+ GF_AssertFail();
+ return -1;
+}
+
+THUMB_FUNC u8 FUN_0200C0DC(u32 param0,
+ u32 param1,
+ u32 *param2,
+ struct UnkStruct_0200BB14_2 *param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7,
+ u32 param8,
+ s32 param9)
+{
+ s32 r4 = FUN_0200C06C(param2, param3, param4, param5, param6, param7, param8, param9);
+ if (r4 != -1)
+ {
+ FUN_02003108(param0, param1, (u16)(r4 << 4), param7 << 5);
+ }
+
+ return (u8)r4;
+}
+
+THUMB_FUNC u32 FUN_0200C124(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ s32 param5)
+{
+ return FUN_0200C404(param0, param1, param2, param3, param4, 2, param5);
+}
+
+THUMB_FUNC u32 FUN_0200C13C(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ s32 param5)
+{
+ return FUN_0200C404(param0, param1, param2, param3, param4, 3, param5);
+}
+
+THUMB_FUNC struct UnkStruct_0200BB14_5 *FUN_0200C154(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, u32 *param2)
+{
+ struct UnkStruct_0200BB14_4 st44;
+ s32 st2c[6];
+
+ struct UnkStruct_0200BB14_5 *ptr =
+ AllocFromHeap(param0->unk000, sizeof(struct UnkStruct_0200BB14_5));
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
+ ptr->unk08 = AllocFromHeap(param0->unk000, sizeof(struct UnkStruct_0200BB14_6));
+ if (ptr->unk08 == 0)
+ {
+ return NULL;
+ }
+
+ ptr->unk08->unk0 = AllocFromHeap(param0->unk000, sizeof(struct UnkStruct_0200BB14_sub));
+ ptr->unk04 = ptr->unk08->unk0;
+ if (ptr->unk08->unk0 == NULL)
+ {
+ if (ptr->unk08 != NULL)
+ {
+ FreeToHeap(ptr->unk08);
+ }
+
+ return NULL;
+ }
+
+ for (s32 i = 0; i < 6; i++)
+ {
+ st2c[i] = (s32)param2[5 + i];
+ }
+
+ if (param1->unk0c[4] == 0 || param1->unk0c[5] == 0)
+ {
+ st2c[4] = -1;
+ st2c[5] = -1;
+ }
+ else
+ {
+ if (st2c[4] != -1 && FUN_0200945C(param1->unk0c[4], st2c[4]) == 0)
+ {
+ st2c[4] = -1;
+ }
+
+ if (st2c[5] != -1 && FUN_0200945C(param1->unk0c[5], st2c[5]) == 0)
+ {
+ st2c[5] = -1;
+ }
+ }
+
+ FUN_02008AA4(ptr->unk04,
+ st2c[0],
+ st2c[1],
+ st2c[2],
+ st2c[3],
+ st2c[4],
+ st2c[5],
+ param2[12],
+ param2[11],
+ param1->unk0c[0],
+ param1->unk0c[1],
+ param1->unk0c[2],
+ param1->unk0c[3],
+ param1->unk0c[4],
+ param1->unk0c[5]);
+
+ st44.unk00 = param1->unk00;
+ st44.unk04 = ptr->unk04;
+ f32 r0;
+ if (((s16 *)param2)[0] > 0)
+ {
+ r0 = ((f32)(((s16 *)param2)[0] << 0xc) + (f32)0.5);
+ }
+ else
+ {
+ r0 = ((f32)(((s16 *)param2)[0] << 0xc) - (f32)0.5);
+ }
+ st44.unk08 = (s32)r0;
+
+ if (((s16 *)param2)[1] > 0)
+ {
+ r0 = ((f32)(((s16 *)param2)[1] << 0xc) + (f32)0.5);
+ }
+ else
+ {
+ r0 = ((f32)(((s16 *)param2)[1] << 0xc) - (f32)0.5);
+ }
+ st44.unk0c = (s32)r0;
+
+ if (((s16 *)param2)[2] > 0)
+ {
+ r0 = ((f32)(((s16 *)param2)[2] << 0xc) + (f32)0.5);
+ }
+ else
+ {
+ r0 = ((f32)(((s16 *)param2)[2] << 0xc) - (f32)0.5);
+ }
+ st44.unk10 = (s32)r0;
+
+ if (param2[4] == 2)
+ {
+ st44.unk0c += 0xC0000;
+ }
+
+ st44.unk14 = 0x1000;
+ st44.unk18 = 0x1000;
+ st44.unk1c = 0x1000;
+ st44.unk20 = 0;
+ st44.unk24 = param2[2];
+ st44.unk28 = param2[4];
+ st44.unk2c = param0->unk000;
+
+ ptr->unk00 = FUN_0201FE94(&st44);
+ ptr->unk0c = param2[12];
+
+ if (ptr->unk00 != 0)
+ {
+ u8 r6 = FUN_020202A0(ptr->unk00);
+
+ FUN_02020130(ptr->unk00, ((u16 *)param2)[3]);
+ FUN_02020248(ptr->unk00, r6 + param2[3]);
+ }
+ else
+ {
+ GF_AssertFail();
+ }
+
+ return ptr;
+}
+
+THUMB_FUNC u32 FUN_0200C334(u32 *param0, u32 param1)
+{
+ return FUN_02009E54(FUN_020094F0(param0[4], param1), 0);
+}
+
+THUMB_FUNC u32 FUN_0200C344(u32 *param0, u32 param1, u32 param2)
+{
+ return FUN_02009E88(FUN_020094F0(param0[4], param1), param2);
+}
+
+THUMB_FUNC u32 FUN_0200C358(struct UnkStruct_0200BB14_2 *param0, u32 param1)
+{
+ return FUN_0200C4F4(param0->unk0c[0], param0->unk24[0], param1);
+}
+
+THUMB_FUNC u32 FUN_0200C368(struct UnkStruct_0200BB14_2 *param0, u32 param1)
+{
+ return FUN_0200C548(param0->unk0c[1], param0->unk24[1], param1);
+}
+
+THUMB_FUNC u32 FUN_0200C378(struct UnkStruct_0200BB14_2 *param0, u32 param1)
+{
+ return FUN_0200C4A8(param0->unk0c[2], param0->unk24[2], param1);
+}
+
+THUMB_FUNC u32 FUN_0200C388(struct UnkStruct_0200BB14_2 *param0, u32 param1)
+{
+ return FUN_0200C4A8(param0->unk0c[3], param0->unk24[3], param1);
+}
+
+THUMB_FUNC void FUN_0200C398(
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1)
+{
+ FUN_0200BC40(param1);
+ FUN_02009C30(param1->unk24[0]);
+ FUN_02009E28(param1->unk24[1]);
+
+ for (s32 i = 0; i < param1->unk54; i++)
+ {
+ FUN_02009448(param1->unk24[i]);
+ FUN_02008E2C(param1->unk0c[i]);
+ }
+
+ FUN_0200BCD0(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C3DC(u32 *param0)
+{
+ if (param0[3] != 0)
+ {
+ FUN_02009CDC(*(u32 *)param0[1]);
+ }
+
+ FUN_0201FFC8(param0[0]);
+ FUN_02008C80(param0[2]);
+ FreeToHeap(param0);
+}
+
+THUMB_FUNC BOOL FUN_0200C404(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ s32 param6)
+{
+ if (FUN_0200945C(param1->unk0c[param5], param6) == 0)
+ {
+ return FALSE;
+ }
+
+ u32 r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != 0)
+ {
+ u32 r4 = FUN_0200C474(param1->unk24[param5], r5);
+ GF_ASSERT(r4 == 1);
+ return r4;
+ }
+ GF_AssertFail();
+ if (r5 != 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0200C474(u32 *param0, u32 param1)
+{
+ for (s32 i = 0; i < (s32)param0[1]; i++)
+ {
+ if (((u32 *)param0[0])[i] == 0)
+ {
+ ((u32 *)param0[0])[i] = param1;
+ param0[2]++;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0200C4A8(u32 param0, u32 *param1, u32 param2)
+{
+ for (s32 i = 0; i < (s32)param1[1]; i++)
+ {
+ if (((u32 *)param1[0])[i] != 0)
+ {
+ u32 r0 = FUN_02009530(((u32 *)param1[0])[i]);
+ if (r0 == param2)
+ {
+
+ FUN_02009490(param0, ((u32 *)param1[0])[i]);
+ ((u32 *)param1[0])[i] = 0;
+ param1[2]--;
+
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0200C4F4(u32 param0, u32 *param1, u32 param2)
+{
+ for (s32 i = 0; i < (s32)param1[1]; i++)
+ {
+ if (((u32 *)param1[0])[i] != 0)
+ {
+ u32 r0 = FUN_02009530(((u32 *)param1[0])[i]);
+ if (r0 == param2)
+ {
+ FUN_0201D324(param2);
+
+ FUN_02009490(param0, ((u32 *)param1[0])[i]);
+ ((u32 *)param1[0])[i] = 0;
+ param1[2]--;
+
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0200C548(u32 param0, u32 *param1, u32 param2)
+{
+ for (s32 i = 0; i < (s32)param1[1]; i++)
+ {
+ if (((u32 *)param1[0])[i] != 0)
+ {
+ u32 r0 = FUN_02009530(((u32 *)param1[0])[i]);
+ if (r0 == param2)
+ {
+ FUN_0201E1C8(param2);
+
+ FUN_02009490(param0, ((u32 *)param1[0])[i]);
+ ((u32 *)param1[0])[i] = 0;
+ param1[2]--;
+
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_0200C59C(u32 param0)
+{
+ FUN_020201E4(param0, 0x1000);
+}
+
+THUMB_FUNC void FUN_0200C5A8(u32 *param0)
+{
+ FUN_0200C59C(param0[0]);
+}
+
+THUMB_FUNC void FUN_0200C5B4(u32 *param0, u32 param1)
+{
+ FUN_020201E4(param0[0], param1);
+}
+
+THUMB_FUNC void FUN_0200C5C0(u32 *param0, u32 param1)
+{
+ FUN_02020130(param0[0], param1);
+}
+
+THUMB_FUNC u32 FUN_0200C5CC(u32 *param0)
+{
+ return FUN_020201DC(param0[0]);
+}
+
+THUMB_FUNC void FUN_0200C5D8(u32 param0, u32 param1)
+{
+ FUN_020200BC(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C5E0(u32 *param0, u32 param1)
+{
+ FUN_0200C5D8(param0[0], param1);
+}
+
+THUMB_FUNC void FUN_0200C5EC(u32 param0, u32 param1)
+{
+ FUN_020200D8(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C5F4(u32 *param0, u32 param1)
+{
+ FUN_0200C5EC(*param0, param1);
+}
+
+THUMB_FUNC u32 FUN_0200C600(u32 param0)
+{
+ return FUN_02020388(param0);
+}
+
+THUMB_FUNC u32 FUN_0200C608(u32 *param0)
+{
+ return FUN_0200C600(*param0);
+}
+
+THUMB_FUNC void FUN_0200C614(u32 param0)
+{
+ FUN_02020208(param0);
+}
+
+THUMB_FUNC void FUN_0200C61C(u32 *param0)
+{
+ FUN_0200C614(*param0);
+}
+
+THUMB_FUNC void FUN_0200C628(u32 param0)
+{
+ FUN_0202022C(param0);
+}
+
+THUMB_FUNC void FUN_0200C630(u32 *param0)
+{
+ FUN_0200C628(*param0);
+}
+
+THUMB_FUNC void FUN_0200C63C(u32 param0, u32 param1)
+{
+ FUN_020200A0(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C644(u32 *param0, u32 param1)
+{
+ FUN_0200C63C(*param0, param1);
+}
+
+THUMB_FUNC u8 FUN_0200C650(u32 param0)
+{
+ return FUN_02020128(param0);
+}
+
+THUMB_FUNC u8 FUN_0200C658(u32 *param0)
+{
+ return FUN_0200C650(*param0);
+}
+
+THUMB_FUNC void FUN_0200C664(u32 param0, u32 param1)
+{
+ FUN_02020248(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C66C(u32 *param0, u32 param1)
+{
+ FUN_0200C664(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C678(u32 param0, u32 param1)
+{
+ FUN_020202A8(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C680(u32 *param0, u32 param1)
+{
+ FUN_0200C678(*param0, param1);
+}
+
+THUMB_FUNC u8 FUN_0200C68C(u32 *param0)
+{
+ return FUN_02020300(*param0);
+}
+
+THUMB_FUNC void FUN_0200C698(u32 param0, u32 param1)
+{
+ FUN_02020238(param0, (u8)param1);
+}
+
+THUMB_FUNC u8 FUN_0200C6A4(u32 *param0)
+{
+ return FUN_02020240(*param0);
+}
+
+THUMB_FUNC void FUN_0200C6B0(u32 *param0, u32 param1)
+{
+ FUN_0200C698(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C6BC(u32 param0, u32 param1)
+{
+ FUN_02020310(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C6C4(u32 *param0, u32 param1)
+{
+ FUN_0200C6BC(*param0, param1);
+}
+
+THUMB_FUNC u16 FUN_0200C6D0(u32 param0)
+{
+ return FUN_0202032C(param0);
+}
+
+THUMB_FUNC u16 FUN_0200C6D8(u32 *param0)
+{
+ return FUN_0200C6D0(*param0);
+}
+
+THUMB_FUNC void FUN_0200C6E4(u32 param0, u32 param1, u32 param2)
+{
+ u32 st0[3];
+ st0[0] = param1 << 12;
+ st0[1] = param2 << 12;
+ if (FUN_02020380(param0) == 2)
+ {
+ st0[1] += 0xc0000;
+ }
+ st0[2] = 0;
+
+ FUN_02020044(param0, st0);
+}
+
+THUMB_FUNC void FUN_0200C714(u32 *param0, u32 param1, u32 param2)
+{
+ FUN_0200C6E4(*param0, param1, param2);
+}
+
+THUMB_FUNC void FUN_0200C720(u32 param0, u32 param1, u32 param2, u32 param3)
+{
+ u32 st0[3];
+
+ st0[0] = param1 << 12;
+ st0[1] = param2 << 12;
+ if (FUN_02020380(param0) == 2)
+ {
+ st0[1] += param3;
+ }
+ st0[2] = 0;
+
+ FUN_02020044(param0, st0);
+}
+
+THUMB_FUNC void FUN_0200C750(u32 *param0, u32 param1, u32 param2, u32 param3)
+{
+ FUN_0200C720(*param0, param1, param2, param3);
+}
+
+THUMB_FUNC void FUN_0200C75C(u32 param0, u16 *param1, u16 *param2)
+{
+ s32 *r4 = FUN_0202011C(param0, param1, param2);
+
+ param1[0] = r4[0] / 0x1000;
+
+ if (FUN_02020380(param0) == 2)
+ {
+ s32 r1 = r4[1] - 0xc0000;
+
+ param2[0] = r1 / 0x1000;
+
+ return;
+ }
+
+ param2[0] = r4[1] / 0x1000;
+}
+
+THUMB_FUNC void FUN_0200C7A0(u32 *param0, u16 *param1, u16 *param2)
+{
+ FUN_0200C75C(*param0, param1, param2);
+}
+
+THUMB_FUNC void FUN_0200C7AC(u32 param0, u16 *param1, u16 *param2, u32 param3)
+{
+ s32 *r4 = FUN_0202011C(param0, param1, param2);
+
+ param1[0] = r4[0] / 0x1000;
+
+ if (FUN_02020380(param0) == 2)
+ {
+ s32 r1 = r4[1] - param3;
+
+ param2[0] = r1 / 0x1000;
+
+ return;
+ }
+
+ param2[0] = r4[1] / 0x1000;
+}
+
+THUMB_FUNC void FUN_0200C7F0(u32 *param0, u16 *param1, u16 *param2, u32 param3)
+{
+ FUN_0200C7AC(*param0, param1, param2, param3);
+}
+
+THUMB_FUNC void FUN_0200C7FC(u32 param0, u16 *param1, u16 *param2)
+{
+ u32 st0[3];
+
+ u32 *r0 = FUN_0202011C(param0, param1, param2);
+
+ st0[0] = r0[0] + ((u32)param1 << 0xc);
+ st0[1] = r0[1] + ((u32)param2 << 0xc);
+ st0[2] = r0[2];
+
+ FUN_02020044(param0, st0);
+}
+
+THUMB_FUNC void FUN_0200C82C(u32 *param0, u16 *param1, u16 *param2)
+{
+ FUN_0200C7FC(*param0, param1, param2);
+}
+
+THUMB_FUNC void FUN_0200C838(u32 param0, u32 param1)
+{
+ FUN_020200EC(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C840(u32 *param0, u32 param1)
+{
+ FUN_0200C838(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C84C(u32 param0, f32 param1, f32 param2)
+{
+ s32 *r4 = FUN_02020120(param0);
+
+ r4[0] = (s32)(param1 * 0x1000);
+ r4[1] = (s32)(param2 * 0x1000);
+
+ FUN_02020064(param0, r4);
+}
+
+THUMB_FUNC void FUN_0200C884(u32 *param0, f32 param1, f32 param2)
+{
+ FUN_0200C84C(*param0, param1, param2);
+}
+
+THUMB_FUNC void FUN_0200C890(u32 param0, u16 param1)
+{
+ FUN_02020088(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C898(u32 *param0, u16 param1)
+{
+ FUN_0200C890(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C8A4(u32 param0, u32 param1)
+{
+ u16 r0 = FUN_02020124(param0);
+ r0 += param1;
+ FUN_02020088(param0, r0);
+}
+
+THUMB_FUNC void FUN_0200C8BC(u32 *param0, u32 param1)
+{
+ FUN_0200C8A4(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C8C8(u32 param0, u32 param1)
+{
+ FUN_02020100(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C8D0(u32 *param0, u32 param1)
+{
+ FUN_0200C8C8(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C8DC(u32 *param0, u32 param1, u32 param2)
+{
+ u32 st0[3];
+ st0[0] = param1 << 12;
+ st0[1] = param2 << 12;
+ st0[2] = 0;
+
+ FUN_02020054(*param0, st0);
+}
+
+THUMB_FUNC void FUN_0200C8F8(u32 *param0, u32 param1)
+{
+ FUN_02020358(*param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C904(u32 param0, u32 param1)
+{
+ FUN_02020398(param0, param1);
+}
+
+THUMB_FUNC void FUN_0200C90C(u32 *param0, u32 param1)
+{
+ FUN_0200C904(*param0, param1);
+}
+
+THUMB_FUNC BOOL FUN_0200C918(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ s32 param6)
+{
+ if (FUN_0200945C(param1->unk0c[0], param6) == 0)
+ {
+ return FALSE;
+ }
+
+ u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != 0)
+ {
+ FUN_02009AC4(r5);
+ FUN_0200C474(param1->unk24[0], r5);
+
+ return TRUE;
+ }
+
+ GF_AssertFail();
+ if (r5 != 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0200C978(u32 *param0,
+ struct UnkStruct_0200BB14_2 *param1,
+ u32 param2,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ s32 param6)
+{
+ if (FUN_0200945C(param1->unk0c[0], param6) == 0)
+ {
+ return FALSE;
+ }
+
+ u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != 0)
+ {
+ FUN_02009B78(r5);
+ FUN_0200C474(param1->unk24[0], r5);
+
+ return TRUE;
+ }
+
+ GF_AssertFail();
+ if (r5 != 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_0200C9D8(
+ u32 *param0, u32 *param1, u32 param2, u32 param3, u32 param4, u32 param5)
+{
+ u32 r6 = FUN_020094F0(param1[3], param5);
+ FUN_020090FC(param1[3], r6, param2, param3, param4, param0[0]);
+
+ FUN_02009BE8(r6);
+}
+
+THUMB_FUNC void FUN_0200CA0C(
+ u32 *param0, u32 *param1, u32 param2, u32 param3, u32 param4, u32 param5)
+{
+ u32 r6 = FUN_020094F0(param1[4], param5);
+ FUN_02009168(param1[4], r6, param2, param3, param4, param0[0]);
+
+ FUN_02009DE0(r6);
+}
+
+THUMB_FUNC u32 FUN_0200CA40(u32 *param0)
+{
+ return *param0;
+}
diff --git a/arm9/src/unk_0200CA44.c b/arm9/src/unk_0200CA44.c
index fd703cd3..6ffed8be 100644
--- a/arm9/src/unk_0200CA44.c
+++ b/arm9/src/unk_0200CA44.c
@@ -2,25 +2,25 @@
#include "main.h"
#include "unk_0200CA44.h"
-extern BOOL FUN_0201B60C(void *, void (*)(u32, void *), void *, void *);
+extern BOOL FUN_0201B60C(void *, void (*)(u32, struct TextPrinter *), struct TextPrinter *, u32);
extern void FUN_0201B6A0(s32);
-THUMB_FUNC BOOL FUN_0200CA44(void (*r0)(u32, void *), void * r1, void * r2)
+THUMB_FUNC BOOL FUN_0200CA44(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2)
{
return FUN_0201B60C(gMain.unk18, r0, r1, r2);
}
-THUMB_FUNC BOOL FUN_0200CA60(void (*r0)(u32, void *), void * r1, void * r2)
+THUMB_FUNC BOOL FUN_0200CA60(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2)
{
return FUN_0201B60C(gMain.unk1C, r0, r1, r2);
}
-THUMB_FUNC BOOL FUN_0200CA7C(void (*r0)(u32, void *), void * r1, void * r2)
+THUMB_FUNC BOOL FUN_0200CA7C(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2)
{
return FUN_0201B60C(gMain.unk24, r0, r1, r2);
}
-THUMB_FUNC BOOL FUN_0200CA98(void (*r0)(u32, void *), void * r1, void * r2)
+THUMB_FUNC BOOL FUN_0200CA98(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2)
{
return FUN_0201B60C(gMain.unk20, r0, r1, r2);
}
diff --git a/arm9/src/unk_02015E30.c b/arm9/src/unk_02015E30.c
index 8be466fb..2f7b5bb5 100644
--- a/arm9/src/unk_02015E30.c
+++ b/arm9/src/unk_02015E30.c
@@ -1,35 +1,37 @@
#include "unk_02015E30.h"
-struct UnkStruct_02015E30 UNK_021C4898;
+u64 UNK_021C48B0;
+u64 UNK_021C48A8;
+u64 UNK_021C48A0;
+struct IGT * UNK_021C489C;
+u32 UNK_021C4898;
THUMB_FUNC void FUN_02015E30()
{
- UNK_021C4898.unk00 = 0;
+ UNK_021C4898 = 0;
}
THUMB_FUNC void FUN_02015E3C(struct IGT *igt)
{
- struct UnkStruct_02015E30 *unk1 = &UNK_021C4898;
- UNK_021C4898.unk00 = 1;
- UNK_021C4898.unk10 = 0;
- UNK_021C4898.unk14 = 0;
- UNK_021C4898.unk08 = 0;
- UNK_021C4898.unk04 = igt;
+ UNK_021C4898 = 1;
+ UNK_021C48A8 = 0;
+ UNK_021C48A0 = 0;
+ UNK_021C489C = igt;
- UNK_021C4898.unk18 = GetTimer3Count();
+ UNK_021C48B0 = GetTimer3Count();
}
THUMB_FUNC void FUN_02015E60()
{
- if (UNK_021C4898.unk00 != 0)
+ if (UNK_021C4898 != 0)
{
- u64 res = Timer3CountToSeconds(GetTimer3Count() - UNK_021C4898.unk18);
+ u64 res = Timer3CountToSeconds(GetTimer3Count() - UNK_021C48B0);
- if (UNK_021C4898.unk08 < res)
+ if (UNK_021C48A0 < res)
{
- AddIGTSeconds(UNK_021C4898.unk04, (u32)(res - UNK_021C4898.unk08));
- UNK_021C4898.unk08 = res;
+ AddIGTSeconds(UNK_021C489C, (u32)(res - UNK_021C48A0));
+ UNK_021C48A0 = res;
}
}
}
diff --git a/arm9/src/unk_02016B94.c b/arm9/src/unk_02016B94.c
new file mode 100644
index 00000000..6a9dd194
--- /dev/null
+++ b/arm9/src/unk_02016B94.c
@@ -0,0 +1,8110 @@
+#include "global.h"
+#include "unk_02016B94.h"
+#include "GX_layers.h"
+#include "game_init.h"
+#include "gx.h"
+#include "heap.h"
+
+extern void NNS_G2dGetUnpackedBGCharacterData(void *param0, u32 *param1);
+extern void NNS_G2dGetUnpackedPaletteData(void *param0, u32 *param1);
+
+const u8 UNK_020EDB30[8] = {
+ 0x10,
+ 0x20,
+ 0x20,
+ 0x20,
+ 0x20,
+ 0x20,
+ 0x00,
+ 0x00,
+};
+
+void (*const UNK_020EDB5C[])(struct Window *) = {
+ FUN_020194C8,
+ FUN_0201951C,
+ FUN_020194C8,
+};
+
+void (*const UNK_020EDB50[])(struct Window *) = {
+ FUN_020195A8,
+ FUN_020195E4,
+ FUN_020195A8,
+};
+
+void (*const UNK_020EDB44[])(struct Window *) = {
+ FUN_020195D0,
+ FUN_0201960C,
+ FUN_020195D0,
+};
+
+void (*const UNK_020EDB38[])(struct Window *) = {
+ FUN_020192D4,
+ FUN_02019358,
+ FUN_020192D4,
+};
+
+void (*const UNK_020EDB68[])(struct Window *) = {
+ FUN_0201949C,
+ FUN_020194E0,
+ FUN_0201949C,
+};
+
+void (*const UNK_020EDB74[])(struct Window *) = {
+ FUN_020193B4,
+ FUN_02019444,
+ FUN_020193B4,
+};
+
+THUMB_FUNC struct UnkStruct_02016B94_2 *FUN_02016B94(u32 heap_id)
+{
+ struct UnkStruct_02016B94_2 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_02016B94_2));
+ memset(ptr, 0, sizeof(struct UnkStruct_02016B94_2));
+ ptr->unk00 = heap_id;
+ ptr->unk04 = 0;
+ ptr->unk06 = 0;
+
+ return ptr;
+}
+
+THUMB_FUNC u32 FUN_02016BB8(u32 *param0)
+{
+ return *param0;
+}
+
+THUMB_FUNC void FUN_02016BBC(const struct GraphicsModes *modes)
+{
+ GX_SetGraphicsMode(modes->mode1, modes->mode2, modes->mode4);
+ GXS_SetGraphicsMode(modes->mode3);
+ reg_GX_DISPCNT &= 0xC7FFFFFF;
+ reg_GX_DISPCNT &= 0xF8FFFFFF;
+
+ GX_DisableEngineALayers();
+ GX_DisableEngineBLayers();
+}
+
+THUMB_FUNC void FUN_02016BF4(u32 *param0, u32 param1)
+{
+ if (param1 == 0)
+ {
+ GX_SetGraphicsMode(param0[0], param0[1], param0[3]);
+ GX_DisableEngineALayers();
+ }
+ else
+ {
+ GXS_SetGraphicsMode(param0[2]);
+ GX_DisableEngineBLayers();
+ }
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC void FUN_02016C18(
+ struct UnkStruct_02016B94_2 *param0, u8 param1, struct UnkStruct_02016B94_1 *param2, u8 param3)
+{
+ u8 res = FUN_020177DC(param2->unk10, param3);
+ switch (param1)
+ {
+ case 0:
+ GX_EngineAToggleLayers(1, GX_LAYER_TOGGLE_ON);
+
+ reg_G2_BG0CNT = (reg_G2_BG0CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk14 << 13) | (param2->unk13 << 2);
+ reg_G2_BG0CNT = (reg_G2_BG0CNT & ~3) | (param2->unk15);
+
+ if (param2->unk18 != 0)
+ {
+ reg_G2_BG0CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2_BG0CNT &= ~0x40;
+ }
+
+ break;
+
+ case 1:
+ GX_EngineAToggleLayers(2, GX_LAYER_TOGGLE_ON);
+ reg_G2_BG1CNT = (reg_G2_BG1CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk14 << 13) | (param2->unk13 << 2);
+ reg_G2_BG1CNT = (reg_G2_BG1CNT & ~3) | (param2->unk15);
+
+ if (param2->unk18 != 0)
+ {
+ reg_G2_BG1CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2_BG1CNT &= ~0x40;
+ }
+
+ break;
+
+ case 2:
+ GX_EngineAToggleLayers(4, GX_LAYER_TOGGLE_ON);
+ switch (param3)
+ {
+ default:
+ case 0:
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk13 << 2);
+ break;
+ case 1:
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ case 2:
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ }
+
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & ~3) | (param2->unk15);
+
+ if (param2->unk18 != 0)
+ {
+ reg_G2_BG2CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2_BG2CNT &= ~0x40;
+ }
+
+ break;
+
+ case 3:
+ GX_EngineAToggleLayers(8, GX_LAYER_TOGGLE_ON);
+
+ switch (param3)
+ {
+ default:
+ case 0:
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk13 << 2);
+ break;
+ case 1:
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ case 2:
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ }
+
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & ~3) | (param2->unk15);
+ if (param2->unk18 != 0)
+ {
+ reg_G2_BG3CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2_BG3CNT &= ~0x40;
+ }
+ break;
+
+ case 4:
+ GX_EngineBToggleLayers(1, GX_LAYER_TOGGLE_ON);
+
+ reg_G2S_DB_BG0CNT = (reg_G2S_DB_BG0CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk14 << 13) | (param2->unk13 << 2);
+
+ reg_G2S_DB_BG0CNT = (reg_G2S_DB_BG0CNT & ~3) | (param2->unk15);
+
+ if (param2->unk18 != 0)
+ {
+ reg_G2S_DB_BG0CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2S_DB_BG0CNT &= ~0x40;
+ }
+
+ break;
+
+ case 5:
+ GX_EngineBToggleLayers(2, GX_LAYER_TOGGLE_ON);
+
+ reg_G2S_DB_BG1CNT = (reg_G2S_DB_BG1CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk14 << 13) | (param2->unk13 << 2);
+
+ reg_G2S_DB_BG1CNT = (reg_G2S_DB_BG1CNT & ~3) | (param2->unk15);
+
+ if (param2->unk18 != 0)
+ {
+ reg_G2S_DB_BG1CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2S_DB_BG1CNT &= ~0x40;
+ }
+
+ break;
+
+ case 6:
+ GX_EngineBToggleLayers(4, GX_LAYER_TOGGLE_ON);
+
+ switch (param3)
+ {
+ default:
+ case 0:
+ reg_G2S_DB_BG2CNT = (reg_G2S_DB_BG2CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk13 << 2);
+ break;
+ case 1:
+ reg_G2S_DB_BG2CNT = (reg_G2S_DB_BG2CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ case 2:
+ reg_G2S_DB_BG2CNT = (reg_G2S_DB_BG2CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ }
+
+ reg_G2S_DB_BG2CNT = (reg_G2S_DB_BG2CNT & ~3) | (param2->unk15);
+
+ if (param2->unk18 != 0)
+ {
+ reg_G2S_DB_BG2CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2S_DB_BG2CNT &= ~0x40;
+ }
+
+ break;
+ case 7:
+ GX_EngineBToggleLayers(8, GX_LAYER_TOGGLE_ON);
+ switch (param3)
+ {
+ default:
+ case 0:
+ reg_G2S_DB_BG3CNT = (reg_G2S_DB_BG3CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk11 << 7) | (param2->unk13 << 2);
+ break;
+ case 1:
+ reg_G2S_DB_BG3CNT = (reg_G2S_DB_BG3CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ case 2:
+ reg_G2S_DB_BG3CNT = (reg_G2S_DB_BG3CNT & 0x43) | (res << 14) | (param2->unk12 << 8) |
+ (param2->unk16 << 13) | (param2->unk13 << 2);
+ break;
+ }
+
+ reg_G2S_DB_BG3CNT = (reg_G2S_DB_BG3CNT & ~3) | (param2->unk15);
+ if (param2->unk18 != 0)
+ {
+ reg_G2S_DB_BG3CNT |= 0x40;
+ }
+ else
+ {
+ reg_G2S_DB_BG3CNT &= ~0x40;
+ }
+ break;
+ }
+
+ param0->unk08[param1].unk20 = 0;
+ param0->unk08[param1].unk24 = 0x1000;
+ param0->unk08[param1].unk28 = 0x1000;
+ param0->unk08[param1].unk2c = 0;
+ param0->unk08[param1].unk30 = 0;
+
+ if (param2->unk08 != 0)
+ {
+ param0->unk08[param1].unk08 = AllocFromHeap(param0->unk00, param2->unk08);
+
+ MI_CpuClear16(param0->unk08[param1].unk08, param2->unk08);
+
+ param0->unk08[param1].unk0c = param2->unk08;
+ param0->unk08[param1].unk10 = param2->unk0c;
+ }
+ else
+ {
+ param0->unk08[param1].unk08 = 0;
+ param0->unk08[param1].unk0c = 0;
+ param0->unk08[param1].unk10 = 0;
+ }
+
+ param0->unk08[param1].unk1d = param2->unk10;
+ param0->unk08[param1].unk1c = param3;
+ param0->unk08[param1].unk1e = param2->unk11;
+
+ if (param3 == 0 && param2->unk11 == 0)
+ {
+ param0->unk08[param1].unk1f = 0x20;
+ }
+ else
+ {
+ param0->unk08[param1].unk1f = 0x40;
+ }
+
+ FUN_020179E0(param0, param1, 0, param2->unk00);
+ FUN_020179E0(param0, param1, 3, param2->unk04);
+}
+#else
+THUMB_FUNC asm void FUN_02016C18(
+ struct UnkStruct_02016B94_2 *param0, u8 param1, struct UnkStruct_02016B94_1 *param2, u8 param3)
+{
+ // clang-format off
+ push {r3-r7, lr}
+ sub sp, #0x18
+ str r1, [sp, #0x4]
+ str r3, [sp, #0x8]
+ add r4, r2, #0x0
+ str r0, [sp, #0x0]
+ ldrb r0, [r4, #0x10]
+ ldr r1, [sp, #0x8]
+ bl FUN_020177DC
+ add r5, r0, #0x0
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x7
+ bls _02016C36
+ b _0201705A
+_02016C36:
+ add r0, r0, r0
+ add r0, pc
+ ldrh r0, [r0, #0x6]
+ lsl r0, r0, #0x10
+ asr r0, r0, #0x10
+ add pc, r0
+_02016C42:
+ // jump table (using 16-bit offset)
+ // .short _02016C52 - _02016C42 - 2; case 0
+ // .short _02016CAA - _02016C42 - 2; case 1
+ // .short _02016D02 - _02016C42 - 2; case 2
+ // .short _02016DA4 - _02016C42 - 2; case 3
+ // .short _02016E46 - _02016C42 - 2; case 4
+ // .short _02016E9E - _02016C42 - 2; case 5
+ // .short _02016EF6 - _02016C42 - 2; case 6
+ // .short _02016F98 - _02016C42 - 2; case 7
+
+ lsl r6, r1, #0
+ lsl r6, r4, #1
+ lsl r6, r7, #2
+ lsl r0, r4, #5
+ lsl r2, r0, #8
+ lsl r2, r3, #9
+ lsl r2, r6, #10
+ lsl r4, r2, #13
+_02016C52:
+ mov r0, #0x1
+ add r1, r0, #0x0
+ bl GX_EngineAToggleLayers
+ ldrb r3, [r4, #0x14]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x11]
+ ldrb r2, [r4, #0x13]
+ lsl r6, r3, #0xd
+ lsl r0, r0, #0x7
+ lsl r3, r2, #0x2
+ str r0, [sp, #0xc]
+ ldr r2, =0x04000008
+ lsl r7, r1, #0x8
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r1, r0
+ ldr r0, [sp, #0xc]
+ orr r0, r1
+ orr r0, r7
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r2, #0x0]
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x3
+ bic r1, r0
+ ldrb r0, [r4, #0x15]
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ ldr r0, [r4, #0x18]
+ cmp r0, #0x0
+ beq _02016CA0
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ b _0201705A
+_02016CA0:
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ bic r1, r0
+ strh r1, [r2, #0x0]
+ b _0201705A
+_02016CAA:
+ mov r0, #0x2
+ mov r1, #0x1
+ bl GX_EngineAToggleLayers
+ ldrb r3, [r4, #0x14]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x11]
+ ldrb r2, [r4, #0x13]
+ lsl r6, r3, #0xd
+ lsl r0, r0, #0x7
+ lsl r3, r2, #0x2
+ str r0, [sp, #0x10]
+ ldr r2, =0x0400000A
+ lsl r7, r1, #0x8
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r1, r0
+ ldr r0, [sp, #0x10]
+ orr r0, r1
+ orr r0, r7
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r2, #0x0]
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x3
+ bic r1, r0
+ ldrb r0, [r4, #0x15]
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ ldr r0, [r4, #0x18]
+ cmp r0, #0x0
+ beq _02016CF8
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ b _0201705A
+_02016CF8:
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ bic r1, r0
+ strh r1, [r2, #0x0]
+ b _0201705A
+_02016D02:
+ mov r0, #0x4
+ mov r1, #0x1
+ bl GX_EngineAToggleLayers
+ ldr r0, [sp, #0x8]
+ cmp r0, #0x0
+ beq _02016D18
+ cmp r0, #0x1
+ beq _02016D3A
+ cmp r0, #0x2
+ beq _02016D5C
+_02016D18:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400000C
+ ldrb r2, [r4, #0x13]
+ lsl r3, r1, #0x8
+ ldrb r0, [r4, #0x11]
+ lsl r6, r2, #0x2
+ ldrh r1, [r7, #0x0]
+ lsl r2, r0, #0x7
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02016D7C
+_02016D3A:
+ ldrb r2, [r4, #0x13]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x16]
+ lsl r3, r2, #0x2
+ ldr r7, =0x0400000C
+ lsl r2, r1, #0x8
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02016D7C
+_02016D5C:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400000C
+ ldrb r0, [r4, #0x16]
+ lsl r3, r1, #0x8
+ ldrb r2, [r4, #0x13]
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ lsl r2, r2, #0x2
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+_02016D7C:
+ ldr r0, =0x0400000C
+ mov r1, #0x3
+ ldrh r2, [r0, #0x0]
+ bic r2, r1
+ ldrb r1, [r4, #0x15]
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ ldr r1, [r4, #0x18]
+ cmp r1, #0x0
+ beq _02016D9A
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ b _0201705A
+_02016D9A:
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ bic r2, r1
+ strh r2, [r0, #0x0]
+ b _0201705A
+_02016DA4:
+ mov r0, #0x8
+ mov r1, #0x1
+ bl GX_EngineAToggleLayers
+ ldr r0, [sp, #0x8]
+ cmp r0, #0x0
+ beq _02016DBA
+ cmp r0, #0x1
+ beq _02016DDC
+ cmp r0, #0x2
+ beq _02016DFE
+_02016DBA:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400000E
+ ldrb r2, [r4, #0x13]
+ lsl r3, r1, #0x8
+ ldrb r0, [r4, #0x11]
+ lsl r6, r2, #0x2
+ ldrh r1, [r7, #0x0]
+ lsl r2, r0, #0x7
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02016E1E
+_02016DDC:
+ ldrb r2, [r4, #0x13]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x16]
+ lsl r3, r2, #0x2
+ ldr r7, =0x0400000E
+ lsl r2, r1, #0x8
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02016E1E
+_02016DFE:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400000E
+ ldrb r0, [r4, #0x16]
+ lsl r3, r1, #0x8
+ ldrb r2, [r4, #0x13]
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ lsl r2, r2, #0x2
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+_02016E1E:
+ ldr r0, =0x0400000E
+ mov r1, #0x3
+ ldrh r2, [r0, #0x0]
+ bic r2, r1
+ ldrb r1, [r4, #0x15]
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ ldr r1, [r4, #0x18]
+ cmp r1, #0x0
+ beq _02016E3C
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ b _0201705A
+_02016E3C:
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ bic r2, r1
+ strh r2, [r0, #0x0]
+ b _0201705A
+_02016E46:
+ mov r0, #0x1
+ add r1, r0, #0x0
+ bl GX_EngineBToggleLayers
+ ldrb r3, [r4, #0x14]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x11]
+ ldrb r2, [r4, #0x13]
+ lsl r6, r3, #0xd
+ lsl r0, r0, #0x7
+ lsl r3, r2, #0x2
+ str r0, [sp, #0x14]
+ ldr r2, =0x04001008
+ lsl r7, r1, #0x8
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r1, r0
+ ldr r0, [sp, #0x14]
+ orr r0, r1
+ orr r0, r7
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r2, #0x0]
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x3
+ bic r1, r0
+ ldrb r0, [r4, #0x15]
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ ldr r0, [r4, #0x18]
+ cmp r0, #0x0
+ beq _02016E94
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ b _0201705A
+_02016E94:
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ bic r1, r0
+ strh r1, [r2, #0x0]
+ b _0201705A
+_02016E9E:
+ mov r0, #0x2
+ mov r1, #0x1
+ bl GX_EngineBToggleLayers
+ ldrb r2, [r4, #0x13]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x11]
+ lsl r6, r2, #0x2
+ ldrb r3, [r4, #0x14]
+ lsl r0, r0, #0x7
+ mov r12, r0
+ ldr r2, =0x0400100A
+ lsl r7, r1, #0x8
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x43
+ lsl r3, r3, #0xd
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ mov r1, r12
+ orr r0, r1
+ orr r0, r7
+ orr r0, r6
+ orr r0, r3
+ strh r0, [r2, #0x0]
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x3
+ bic r1, r0
+ ldrb r0, [r4, #0x15]
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ ldr r0, [r4, #0x18]
+ cmp r0, #0x0
+ beq _02016EEC
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ b _0201705A
+_02016EEC:
+ ldrh r1, [r2, #0x0]
+ mov r0, #0x40
+ bic r1, r0
+ strh r1, [r2, #0x0]
+ b _0201705A
+_02016EF6:
+ mov r0, #0x4
+ mov r1, #0x1
+ bl GX_EngineBToggleLayers
+ ldr r0, [sp, #0x8]
+ cmp r0, #0x0
+ beq _02016F0C
+ cmp r0, #0x1
+ beq _02016F2E
+ cmp r0, #0x2
+ beq _02016F50
+_02016F0C:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400100C
+ ldrb r2, [r4, #0x13]
+ lsl r3, r1, #0x8
+ ldrb r0, [r4, #0x11]
+ lsl r6, r2, #0x2
+ ldrh r1, [r7, #0x0]
+ lsl r2, r0, #0x7
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02016F70
+_02016F2E:
+ ldrb r2, [r4, #0x13]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x16]
+ lsl r3, r2, #0x2
+ ldr r7, =0x0400100C
+ lsl r2, r1, #0x8
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02016F70
+_02016F50:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400100C
+ ldrb r0, [r4, #0x16]
+ lsl r3, r1, #0x8
+ ldrb r2, [r4, #0x13]
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ lsl r2, r2, #0x2
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+_02016F70:
+ ldr r0, =0x0400100C
+ mov r1, #0x3
+ ldrh r2, [r0, #0x0]
+ bic r2, r1
+ ldrb r1, [r4, #0x15]
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ ldr r1, [r4, #0x18]
+ cmp r1, #0x0
+ beq _02016F8E
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ b _0201705A
+_02016F8E:
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ bic r2, r1
+ strh r2, [r0, #0x0]
+ b _0201705A
+_02016F98:
+ mov r0, #0x8
+ mov r1, #0x1
+ bl GX_EngineBToggleLayers
+ ldr r0, [sp, #0x8]
+ cmp r0, #0x0
+ beq _02016FAE
+ cmp r0, #0x1
+ beq _02016FF2
+ cmp r0, #0x2
+ beq _02017014
+_02016FAE:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400100E
+ b _02016FD4
+_02016FD4:
+ ldrb r2, [r4, #0x13]
+ lsl r3, r1, #0x8
+ ldrb r0, [r4, #0x11]
+ lsl r6, r2, #0x2
+ ldrh r1, [r7, #0x0]
+ lsl r2, r0, #0x7
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02017034
+_02016FF2:
+ ldrb r2, [r4, #0x13]
+ ldrb r1, [r4, #0x12]
+ ldrb r0, [r4, #0x16]
+ lsl r3, r2, #0x2
+ ldr r7, =0x0400100E
+ lsl r2, r1, #0x8
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+ b _02017034
+_02017014:
+ ldrb r1, [r4, #0x12]
+ ldr r7, =0x0400100E
+ ldrb r0, [r4, #0x16]
+ lsl r3, r1, #0x8
+ ldrb r2, [r4, #0x13]
+ lsl r6, r0, #0xd
+ ldrh r1, [r7, #0x0]
+ mov r0, #0x43
+ lsl r2, r2, #0x2
+ and r0, r1
+ lsl r1, r5, #0xe
+ orr r0, r1
+ orr r0, r2
+ orr r0, r3
+ orr r0, r6
+ strh r0, [r7, #0x0]
+_02017034:
+ ldr r0, =0x0400100E
+ mov r1, #0x3
+ ldrh r2, [r0, #0x0]
+ bic r2, r1
+ ldrb r1, [r4, #0x15]
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ ldr r1, [r4, #0x18]
+ cmp r1, #0x0
+ beq _02017052
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ orr r1, r2
+ strh r1, [r0, #0x0]
+ b _0201705A
+_02017052:
+ ldrh r2, [r0, #0x0]
+ mov r1, #0x40
+ bic r2, r1
+ strh r2, [r0, #0x0]
+_0201705A:
+ ldr r0, [sp, #0x4]
+ mov r1, #0x2c
+ add r5, r0, #0x0
+ ldr r0, [sp, #0x0]
+ mul r5, r1
+ add r2, r0, r5
+ mov r3, #0x0
+ mov r0, #0x1
+ strh r3, [r2, #0x20]
+ lsl r0, r0, #0xc
+ str r0, [r2, #0x24]
+ str r0, [r2, #0x28]
+ str r3, [r2, #0x2c]
+ str r3, [r2, #0x30]
+ ldr r1, [r4, #0x8]
+ cmp r1, #0x0
+ beq _020170A2
+ ldr r0, [sp, #0x0]
+ ldr r6, [sp, #0x0]
+ ldr r0, [r0, #0x0]
+ add r6, #0x8
+ bl AllocFromHeap
+ str r0, [r6, r5]
+ ldr r1, [r6, r5]
+ ldr r2, [r4, #0x8]
+ mov r0, #0x0
+ bl MIi_CpuClear16
+ ldr r0, [sp, #0x0]
+ ldr r2, [r4, #0x8]
+ add r1, r0, r5
+ str r2, [r1, #0xc]
+ ldr r0, [r4, #0xc]
+ str r0, [r1, #0x10]
+ b _020170A8
+_020170A2:
+ str r3, [r2, #0x8]
+ str r3, [r2, #0xc]
+ str r3, [r2, #0x10]
+_020170A8:
+ ldr r0, [sp, #0x0]
+ ldrb r1, [r4, #0x10]
+ add r0, r0, r5
+ strb r1, [r0, #0x1d]
+ ldr r1, [sp, #0x8]
+ strb r1, [r0, #0x1c]
+ ldrb r1, [r4, #0x11]
+ strb r1, [r0, #0x1e]
+ ldr r1, [sp, #0x8]
+ cmp r1, #0x0
+ bne _020170CA
+ ldrb r1, [r4, #0x11]
+ cmp r1, #0x0
+ bne _020170CA
+ mov r1, #0x20
+ strb r1, [r0, #0x1f]
+ b _020170D2
+_020170CA:
+ ldr r0, [sp, #0x0]
+ mov r1, #0x40
+ add r0, r0, r5
+ strb r1, [r0, #0x1f]
+_020170D2:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0x4]
+ ldr r3, [r4, #0x0]
+ mov r2, #0x0
+ bl FUN_020179E0
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0x4]
+ ldr r3, [r4, #0x4]
+ mov r2, #0x3
+ bl FUN_020179E0
+ add sp, #0x18
+ pop {r3-r7, pc}
+ // clang-format on
+}
+#endif
+
+#ifdef NONMATCHING
+THUMB_FUNC void FUN_020170F4(struct UnkStruct_02016B94_2 *param0, u8 param1, u32 param2, u8 param3)
+{
+ if (param2 == 0)
+ {
+ param0->unk08[param1].unk1e = param3;
+ }
+
+ switch (param1)
+ {
+ case 0:
+ u16 bg0cnt = reg_G2_BG0CNT;
+ if (param2 == 1)
+ {
+ bg0cnt = bg0cnt & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg0cnt = bg0cnt & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2_BG0CNT = (reg_G2_BG0CNT & 0x43) | ((u32)(bg0cnt << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 | ((u32)(bg0cnt << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg0cnt << 0x1a) >> 0x1c) << 2 |
+ ((u32)(bg0cnt << 0x12) >> 0x1f) << 0xd;
+
+ break;
+ case 1:
+ u16 bg1cnt = reg_G2_BG1CNT;
+ if (param2 == 1)
+ {
+ bg1cnt = bg1cnt & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg1cnt = bg1cnt & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2_BG1CNT = (reg_G2_BG1CNT & 0x43) | (((u32)bg1cnt << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 | ((u32)(bg1cnt << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg1cnt << 0x1a) >> 0x1c) << 2 |
+ ((u32)(bg1cnt << 0x12) >> 0x1f) << 0xd;
+
+ break;
+ case 2:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ u16 bg2cnt_0 = reg_G2_BG2CNT;
+ if (param2 == 1)
+ {
+ bg2cnt_0 = bg2cnt_0 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg2cnt_0 = bg2cnt_0 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & 0x43) | ((u32)(bg2cnt_0 << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 |
+ ((u32)(bg2cnt_0 << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg2cnt_0 << 0x1a) >> 0x1c) << 2;
+
+ break;
+ case 1:
+ u16 bg2cnt_1 = reg_G2_BG2CNT;
+ if (param2 == 1)
+ {
+ bg2cnt_1 = bg2cnt_1 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg2cnt_1 = bg2cnt_1 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & 0x43) | ((u32)(bg2cnt_1 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(bg2cnt_1 << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg2cnt_1 << 0x1a) >> 0x1c) << 2 |
+ ((u32)(bg2cnt_1 << 0x12) >> 0x1f) << 0xd;
+ break;
+ case 2:
+ u16 bg2cnt_2 = reg_G2_BG2CNT;
+ if (param2 == 1)
+ {
+ bg2cnt_2 = bg2cnt_2 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg2cnt_2 = bg2cnt_2 & ~0x38 | ((u32)(param3 << 0x1d) >> 0x1a);
+ }
+
+ reg_G2_BG2CNT = (reg_G2_BG2CNT & 0x43) | ((u32)(bg2cnt_2 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(bg2cnt_2 << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg2cnt_2 << 0x1a) >> 0x1d) << 2 |
+ ((u32)(bg2cnt_2 << 0x12) >> 0x1f) << 0xd;
+ break;
+ }
+ break;
+ case 3:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ u16 bg3cnt_0 = reg_G2_BG3CNT;
+ if (param2 == 1)
+ {
+ bg3cnt_0 = bg3cnt_0 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg3cnt_0 = bg3cnt_0 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & 0x43) | ((u32)(bg3cnt_0 << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 |
+ ((u32)(bg3cnt_0 << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg3cnt_0 << 0x1a) >> 0x1c) << 2;
+
+ break;
+ case 1:
+ u16 bg3cnt_1 = reg_G2_BG3CNT;
+ if (param2 == 1)
+ {
+ bg3cnt_1 = bg3cnt_1 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg3cnt_1 = bg3cnt_1 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & 0x43) | ((u32)(bg3cnt_1 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(bg3cnt_1 << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg3cnt_1 << 0x1a) >> 0x1c) << 2 |
+ ((u32)(bg3cnt_1 << 0x12) >> 0x1f) << 0xd;
+ break;
+ case 2:
+ u16 bg3cnt_2 = reg_G2_BG3CNT;
+ if (param2 == 1)
+ {
+ bg3cnt_2 = bg3cnt_2 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ bg3cnt_2 = bg3cnt_2 & ~0x38 | ((u32)(param3 << 0x1d) >> 0x1a);
+ }
+
+ reg_G2_BG3CNT = (reg_G2_BG3CNT & 0x43) | ((u32)(bg3cnt_2 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(bg3cnt_2 << 0x13) >> 0x1b) << 8 |
+ ((u32)(bg3cnt_2 << 0x1a) >> 0x1d) << 2 |
+ ((u32)(bg3cnt_2 << 0x12) >> 0x1f) << 0xd;
+ break;
+ }
+ break;
+ case 4:
+ u16 db_bg0cnt = reg_G2S_DB_BG0CNT;
+ if (param2 == 1)
+ {
+ db_bg0cnt = db_bg0cnt & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg0cnt = db_bg0cnt & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG0CNT =
+ (reg_G2S_DB_BG0CNT & 0x43) | ((u32)(db_bg0cnt << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 | ((u32)(db_bg0cnt << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg0cnt << 0x1a) >> 0x1c) << 2 | ((u32)(db_bg0cnt << 0x12) >> 0x1f) << 0xd;
+
+ break;
+ case 5:
+ u16 db_bg1cnt = reg_G2S_DB_BG1CNT;
+ if (param2 == 1)
+ {
+ db_bg1cnt = db_bg1cnt & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg1cnt = db_bg1cnt & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG1CNT =
+ (reg_G2S_DB_BG1CNT & 0x43) | ((u32)(db_bg1cnt << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 | ((u32)(db_bg1cnt << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg1cnt << 0x1a) >> 0x1c) << 2 | ((u32)(db_bg1cnt << 0x12) >> 0x1f) << 0xd;
+
+ break;
+ case 6:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ u16 db_bg2cnt_0 = reg_G2S_DB_BG2CNT;
+ if (param2 == 1)
+ {
+ db_bg2cnt_0 = db_bg2cnt_0 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg2cnt_0 = db_bg2cnt_0 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG2CNT =
+ (reg_G2S_DB_BG2CNT & 0x43) | ((u32)(db_bg2cnt_0 << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 | ((u32)(db_bg2cnt_0 << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg2cnt_0 << 0x1a) >> 0x1c) << 2;
+
+ break;
+ case 1:
+ u16 db_bg2cnt_1 = reg_G2S_DB_BG2CNT;
+ if (param2 == 1)
+ {
+ db_bg2cnt_1 = db_bg2cnt_1 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg2cnt_1 = db_bg2cnt_1 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG2CNT = (reg_G2S_DB_BG2CNT & 0x43) |
+ ((u32)(db_bg2cnt_1 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(db_bg2cnt_1 << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg2cnt_1 << 0x1a) >> 0x1c) << 2 |
+ ((u32)(db_bg2cnt_1 << 0x12) >> 0x1f) << 0xd;
+ break;
+ case 2:
+ u16 db_bg2cnt_2 = reg_G2S_DB_BG2CNT;
+ if (param2 == 1)
+ {
+ db_bg2cnt_2 = db_bg2cnt_2 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg2cnt_2 = db_bg2cnt_2 & ~0x38 | ((u32)(param3 << 0x1d) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG2CNT = (reg_G2S_DB_BG2CNT & 0x43) |
+ ((u32)(db_bg2cnt_2 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(db_bg2cnt_2 << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg2cnt_2 << 0x1a) >> 0x1d) << 2 |
+ ((u32)(db_bg2cnt_2 << 0x12) >> 0x1f) << 0xd;
+ break;
+ }
+ break;
+ case 7:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ u16 db_bg3cnt_0 = reg_G2S_DB_BG3CNT;
+ if (param2 == 1)
+ {
+ db_bg3cnt_0 = db_bg3cnt_0 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg3cnt_0 = db_bg3cnt_0 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG3CNT =
+ (reg_G2S_DB_BG3CNT & 0x43) | ((u32)(db_bg3cnt_0 << 0x10) >> 0x1e) << 0xe |
+ param0->unk08[param1].unk1e << 7 | ((u32)(db_bg3cnt_0 << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg3cnt_0 << 0x1a) >> 0x1c) << 2;
+
+ break;
+ case 1:
+ u16 db_bg3cnt_1 = reg_G2S_DB_BG3CNT;
+ if (param2 == 1)
+ {
+ db_bg3cnt_1 = db_bg3cnt_1 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg3cnt_1 = db_bg3cnt_1 & ~0x3c | ((u32)(param3 << 0x1c) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG3CNT = (reg_G2S_DB_BG3CNT & 0x43) |
+ ((u32)(db_bg3cnt_1 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(db_bg3cnt_1 << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg3cnt_1 << 0x1a) >> 0x1c) << 2 |
+ ((u32)(db_bg3cnt_1 << 0x12) >> 0x1f) << 0xd;
+ break;
+ case 2:
+ u16 db_bg3cnt_2 = reg_G2S_DB_BG3CNT;
+ if (param2 == 1)
+ {
+ db_bg3cnt_2 = db_bg3cnt_2 & 0xFFFFE0FF | ((u32)(param3 << 0x1b) >> 0x13);
+ }
+ else if (param2 == 2)
+ {
+ db_bg3cnt_2 = db_bg3cnt_2 & ~0x38 | ((u32)(param3 << 0x1d) >> 0x1a);
+ }
+
+ reg_G2S_DB_BG3CNT = (reg_G2S_DB_BG3CNT & 0x43) |
+ ((u32)(db_bg3cnt_2 << 0x10) >> 0x1e) << 0xe |
+ ((u32)(db_bg3cnt_2 << 0x13) >> 0x1b) << 8 |
+ ((u32)(db_bg3cnt_2 << 0x1a) >> 0x1d) << 2 |
+ ((u32)(db_bg3cnt_2 << 0x12) >> 0x1f) << 0xd;
+ break;
+ }
+ break;
+ }
+}
+#else
+THUMB_FUNC asm void FUN_020170F4(
+ struct UnkStruct_02016B94_2 *param0, u8 param1, u32 param2, u8 param3)
+{
+ // clang-format off
+ push {r3-r7, lr}
+ sub sp, #0x20
+ add r4, r1, #0x0
+ add r5, r0, #0x0
+ add r1, r2, #0x0
+ add r0, r3, #0x0
+ cmp r1, #0x0
+ bne _0201710C
+ mov r2, #0x2c
+ mul r2, r4
+ add r2, r5, r2
+ strb r0, [r2, #0x1e]
+_0201710C:
+ cmp r4, #0x7
+ bls _02017112
+ b _020177C4
+_02017112:
+ add r2, r4, r4
+ add r2, pc
+ ldrh r2, [r2, #0x6]
+ lsl r2, r2, #0x10
+ asr r2, r2, #0x10
+ add pc, r2
+_0201711E: //; jump table (using 16-bit offset)
+ // .short _0201712E - _0201711E - 2; case 0
+ // .short _0201719A - _0201711E - 2; case 1
+ // .short _02017206 - _0201711E - 2; case 2
+ // .short _0201733A - _0201711E - 2; case 3
+ // .short _0201746E - _0201711E - 2; case 4
+ // .short _020174F4 - _0201711E - 2; case 5
+ // .short _02017560 - _0201711E - 2; case 6
+ // .short _02017694 - _0201711E - 2; case 7
+
+ lsl r6, r1, #0
+ lsl r2, r7, #1
+ lsl r6, r4, #3
+ lsl r2, r3, #8
+ lsl r6, r1, #13
+ lsl r4, r2, #15
+ lsl r0, r0, #17
+ lsl r4, r6, #21
+_0201712E:
+ ldr r2, =0x04000008
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x1e]
+ bne _0201714A
+ ldrh r3, [r2, #0x1e]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x1e]
+ b _0201715C
+_0201714A:
+ cmp r1, #0x2
+ bne _0201715C
+ ldrh r3, [r2, #0x1e]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x1e]
+_0201715C:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x1e]
+ add sp, #0x20
+ lsl r0, r3, #0x12
+ lsr r6, r0, #0x1f
+ lsl r0, r3, #0x1a
+ lsr r2, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsr r1, r0, #0x1b
+ mov r0, #0x2c
+ mul r0, r4
+ add r0, r5, r0
+ lsl r3, r3, #0x10
+ lsr r5, r3, #0x1e
+ lsl r3, r2, #0x2
+ ldrb r0, [r0, #0x1e]
+ lsl r2, r1, #0x8
+ lsl r4, r6, #0xd
+ lsl r1, r0, #0x7
+ ldr r0, =0x04000008
+ mov r6, #0x43
+ ldrh r7, [r0, #0x0]
+ lsl r5, r5, #0xe
+ and r6, r7
+ orr r5, r6
+ orr r1, r5
+ orr r1, r2
+ orr r1, r3
+ orr r1, r4
+ strh r1, [r0, #0x0]
+ pop {r3-r7, pc}
+_0201719A:
+ ldr r2, =0x0400000A
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x1c]
+ bne _020171B6
+ ldrh r3, [r2, #0x1c]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x1c]
+ b _020171C8
+_020171B6:
+ cmp r1, #0x2
+ bne _020171C8
+ ldrh r3, [r2, #0x1c]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x1c]
+_020171C8:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x1c]
+ add sp, #0x20
+ lsl r0, r3, #0x12
+ lsr r6, r0, #0x1f
+ lsl r0, r3, #0x1a
+ lsr r2, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsr r1, r0, #0x1b
+ mov r0, #0x2c
+ mul r0, r4
+ add r0, r5, r0
+ lsl r3, r3, #0x10
+ lsr r5, r3, #0x1e
+ lsl r3, r2, #0x2
+ ldrb r0, [r0, #0x1e]
+ lsl r2, r1, #0x8
+ lsl r4, r6, #0xd
+ lsl r1, r0, #0x7
+ ldr r0, =0x0400000A
+ mov r6, #0x43
+ ldrh r7, [r0, #0x0]
+ lsl r5, r5, #0xe
+ and r6, r7
+ orr r5, r6
+ orr r1, r5
+ orr r1, r2
+ orr r1, r3
+ orr r1, r4
+ strh r1, [r0, #0x0]
+ pop {r3-r7, pc}
+_02017206:
+ mov r2, #0x2c
+ mul r2, r4
+ add r3, r5, r2
+ ldrb r3, [r3, #0x1c]
+ cmp r3, #0x0
+ beq _0201721A
+ cmp r3, #0x1
+ beq _0201727A
+ cmp r3, #0x2
+ beq _020172DA
+_0201721A:
+ ldr r3, =0x0400000C
+ cmp r1, #0x1
+ ldrh r4, [r3, #0x0]
+ add r3, sp, #0x0
+ strh r4, [r3, #0x1a]
+ bne _02017236
+ ldrh r4, [r3, #0x1a]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r4
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r3, #0x1a]
+ b _02017248
+_02017236:
+ cmp r1, #0x2
+ bne _02017248
+ ldrh r4, [r3, #0x1a]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r4, r1
+ lsr r0, r0, #0x1a
+ orr r0, r4
+ strh r0, [r3, #0x1a]
+_02017248:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x1a]
+ add r2, r5, r2
+ ldr r6, =0x0400000C
+ lsl r0, r3, #0x1a
+ ldrb r4, [r2, #0x1e]
+ lsr r1, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsl r2, r3, #0x10
+ lsr r3, r2, #0x1e
+ ldrh r5, [r6, #0x0]
+ lsr r0, r0, #0x1b
+ lsl r2, r1, #0x2
+ lsl r1, r0, #0x8
+ lsl r0, r4, #0x7
+ mov r4, #0x43
+ and r4, r5
+ lsl r3, r3, #0xe
+ orr r3, r4
+ orr r0, r3
+ orr r0, r1
+ orr r0, r2
+ add sp, #0x20
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_0201727A:
+ ldr r2, =0x0400000C
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x18]
+ bne _02017296
+ ldrh r3, [r2, #0x18]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x18]
+ b _020172A8
+_02017296:
+ cmp r1, #0x2
+ bne _020172A8
+ ldrh r3, [r2, #0x18]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x18]
+_020172A8:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x18]
+ ldr r6, =0x0400000C
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsl r0, r3, #0x1a
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsr r0, r0, #0x1c
+ lsl r1, r0, #0x2
+ lsl r0, r4, #0x8
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_020172DA:
+ ldr r2, =0x0400000C
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x16]
+ bne _020172F6
+ ldrh r3, [r2, #0x16]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x16]
+ b _02017308
+_020172F6:
+ cmp r1, #0x2
+ bne _02017308
+ ldrh r3, [r2, #0x16]
+ mov r1, #0x38
+ lsl r0, r0, #0x1d
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x16]
+_02017308:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x16]
+ ldr r6, =0x0400000C
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r0, r3, #0x1a
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsl r1, r4, #0x8
+ lsr r0, r0, #0x1d
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ lsl r0, r0, #0x2
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_0201733A:
+ mov r2, #0x2c
+ mul r2, r4
+ add r3, r5, r2
+ ldrb r3, [r3, #0x1c]
+ cmp r3, #0x0
+ beq _0201734E
+ cmp r3, #0x1
+ beq _020173AE
+ cmp r3, #0x2
+ beq _0201740E
+_0201734E:
+ ldr r3, =0x0400000E
+ cmp r1, #0x1
+ ldrh r4, [r3, #0x0]
+ add r3, sp, #0x0
+ strh r4, [r3, #0x14]
+ bne _0201736A
+ ldrh r4, [r3, #0x14]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r4
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r3, #0x14]
+ b _0201737C
+_0201736A:
+ cmp r1, #0x2
+ bne _0201737C
+ ldrh r4, [r3, #0x14]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r4, r1
+ lsr r0, r0, #0x1a
+ orr r0, r4
+ strh r0, [r3, #0x14]
+_0201737C:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x14]
+ add r2, r5, r2
+ ldr r6, =0x0400000E
+ lsl r0, r3, #0x1a
+ ldrb r4, [r2, #0x1e]
+ lsr r1, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsl r2, r3, #0x10
+ lsr r3, r2, #0x1e
+ ldrh r5, [r6, #0x0]
+ lsr r0, r0, #0x1b
+ lsl r2, r1, #0x2
+ lsl r1, r0, #0x8
+ lsl r0, r4, #0x7
+ mov r4, #0x43
+ and r4, r5
+ lsl r3, r3, #0xe
+ orr r3, r4
+ orr r0, r3
+ orr r0, r1
+ orr r0, r2
+ add sp, #0x20
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_020173AE:
+ ldr r2, =0x0400000E
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x12]
+ bne _020173CA
+ ldrh r3, [r2, #0x12]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x12]
+ b _020173DC
+_020173CA:
+ cmp r1, #0x2
+ bne _020173DC
+ ldrh r3, [r2, #0x12]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x12]
+_020173DC:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x12]
+ ldr r6, =0x0400000E
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsl r0, r3, #0x1a
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsr r0, r0, #0x1c
+ lsl r1, r0, #0x2
+ lsl r0, r4, #0x8
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_0201740E:
+ ldr r2, =0x0400000E
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x10]
+ bne _0201742A
+ ldrh r3, [r2, #0x10]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x10]
+ b _0201743C
+_0201742A:
+ cmp r1, #0x2
+ bne _0201743C
+ ldrh r3, [r2, #0x10]
+ mov r1, #0x38
+ lsl r0, r0, #0x1d
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x10]
+_0201743C:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x10]
+ ldr r6, =0x0400000E
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r0, r3, #0x1a
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsl r1, r4, #0x8
+ lsr r0, r0, #0x1d
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ lsl r0, r0, #0x2
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_0201746E:
+ ldr r2, =0x04001008
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0xe]
+ bne _020174A4
+ ldrh r3, [r2, #0xe]
+ ldr r1, =0xFFFFE0FF
+ b _02017498
+_02017498:
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0xe]
+ b _020174B6
+_020174A4:
+ cmp r1, #0x2
+ bne _020174B6
+ ldrh r3, [r2, #0xe]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0xe]
+_020174B6:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0xe]
+ add sp, #0x20
+ lsl r0, r3, #0x12
+ lsr r6, r0, #0x1f
+ lsl r0, r3, #0x1a
+ lsr r2, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsr r1, r0, #0x1b
+ mov r0, #0x2c
+ mul r0, r4
+ add r0, r5, r0
+ lsl r3, r3, #0x10
+ lsr r5, r3, #0x1e
+ lsl r3, r2, #0x2
+ ldrb r0, [r0, #0x1e]
+ lsl r2, r1, #0x8
+ lsl r4, r6, #0xd
+ lsl r1, r0, #0x7
+ ldr r0, =0x04001008
+ mov r6, #0x43
+ ldrh r7, [r0, #0x0]
+ lsl r5, r5, #0xe
+ and r6, r7
+ orr r5, r6
+ orr r1, r5
+ orr r1, r2
+ orr r1, r3
+ orr r1, r4
+ strh r1, [r0, #0x0]
+ pop {r3-r7, pc}
+_020174F4:
+ ldr r2, =0x0400100A
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0xc]
+ bne _02017510
+ ldrh r3, [r2, #0xc]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0xc]
+ b _02017522
+_02017510:
+ cmp r1, #0x2
+ bne _02017522
+ ldrh r3, [r2, #0xc]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0xc]
+_02017522:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0xc]
+ add sp, #0x20
+ lsl r0, r3, #0x12
+ lsr r6, r0, #0x1f
+ lsl r0, r3, #0x1a
+ lsr r2, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsr r1, r0, #0x1b
+ mov r0, #0x2c
+ mul r0, r4
+ add r0, r5, r0
+ lsl r3, r3, #0x10
+ lsr r5, r3, #0x1e
+ lsl r3, r2, #0x2
+ ldrb r0, [r0, #0x1e]
+ lsl r2, r1, #0x8
+ lsl r4, r6, #0xd
+ lsl r1, r0, #0x7
+ ldr r0, =0x0400100A
+ mov r6, #0x43
+ ldrh r7, [r0, #0x0]
+ lsl r5, r5, #0xe
+ and r6, r7
+ orr r5, r6
+ orr r1, r5
+ orr r1, r2
+ orr r1, r3
+ orr r1, r4
+ strh r1, [r0, #0x0]
+ pop {r3-r7, pc}
+_02017560:
+ mov r2, #0x2c
+ mul r2, r4
+ add r3, r5, r2
+ ldrb r3, [r3, #0x1c]
+ cmp r3, #0x0
+ beq _02017574
+ cmp r3, #0x1
+ beq _020175D4
+ cmp r3, #0x2
+ beq _02017634
+_02017574:
+ ldr r3, =0x0400100C
+ cmp r1, #0x1
+ ldrh r4, [r3, #0x0]
+ add r3, sp, #0x0
+ strh r4, [r3, #0xa]
+ bne _02017590
+ ldrh r4, [r3, #0xa]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r4
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r3, #0xa]
+ b _020175A2
+_02017590:
+ cmp r1, #0x2
+ bne _020175A2
+ ldrh r4, [r3, #0xa]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r4, r1
+ lsr r0, r0, #0x1a
+ orr r0, r4
+ strh r0, [r3, #0xa]
+_020175A2:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0xa]
+ add r2, r5, r2
+ ldr r6, =0x0400100C
+ lsl r0, r3, #0x1a
+ ldrb r4, [r2, #0x1e]
+ lsr r1, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsl r2, r3, #0x10
+ lsr r3, r2, #0x1e
+ ldrh r5, [r6, #0x0]
+ lsr r0, r0, #0x1b
+ lsl r2, r1, #0x2
+ lsl r1, r0, #0x8
+ lsl r0, r4, #0x7
+ mov r4, #0x43
+ and r4, r5
+ lsl r3, r3, #0xe
+ orr r3, r4
+ orr r0, r3
+ orr r0, r1
+ orr r0, r2
+ add sp, #0x20
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_020175D4:
+ ldr r2, =0x0400100C
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x8]
+ bne _020175F0
+ ldrh r3, [r2, #0x8]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x8]
+ b _02017602
+_020175F0:
+ cmp r1, #0x2
+ bne _02017602
+ ldrh r3, [r2, #0x8]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x8]
+_02017602:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x8]
+ ldr r6, =0x0400100C
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsl r0, r3, #0x1a
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsr r0, r0, #0x1c
+ lsl r1, r0, #0x2
+ lsl r0, r4, #0x8
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_02017634:
+ ldr r2, =0x0400100C
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x6]
+ bne _02017650
+ ldrh r3, [r2, #0x6]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x6]
+ b _02017662
+_02017650:
+ cmp r1, #0x2
+ bne _02017662
+ ldrh r3, [r2, #0x6]
+ mov r1, #0x38
+ lsl r0, r0, #0x1d
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x6]
+_02017662:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x6]
+ ldr r6, =0x0400100C
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r0, r3, #0x1a
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsl r1, r4, #0x8
+ lsr r0, r0, #0x1d
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ lsl r0, r0, #0x2
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_02017694:
+ mov r2, #0x2c
+ mul r2, r4
+ add r3, r5, r2
+ ldrb r3, [r3, #0x1c]
+ cmp r3, #0x0
+ beq _020176A8
+ cmp r3, #0x1
+ beq _02017708
+ cmp r3, #0x2
+ beq _02017768
+_020176A8:
+ ldr r3, =0x0400100E
+ cmp r1, #0x1
+ ldrh r4, [r3, #0x0]
+ add r3, sp, #0x0
+ strh r4, [r3, #0x4]
+ bne _020176C4
+ ldrh r4, [r3, #0x4]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r4
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r3, #0x4]
+ b _020176D6
+_020176C4:
+ cmp r1, #0x2
+ bne _020176D6
+ ldrh r4, [r3, #0x4]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r4, r1
+ lsr r0, r0, #0x1a
+ orr r0, r4
+ strh r0, [r3, #0x4]
+_020176D6:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x4]
+ add r2, r5, r2
+ ldr r6, =0x0400100E
+ lsl r0, r3, #0x1a
+ ldrb r4, [r2, #0x1e]
+ lsr r1, r0, #0x1c
+ lsl r0, r3, #0x13
+ lsl r2, r3, #0x10
+ lsr r3, r2, #0x1e
+ ldrh r5, [r6, #0x0]
+ lsr r0, r0, #0x1b
+ lsl r2, r1, #0x2
+ lsl r1, r0, #0x8
+ lsl r0, r4, #0x7
+ mov r4, #0x43
+ and r4, r5
+ lsl r3, r3, #0xe
+ orr r3, r4
+ orr r0, r3
+ orr r0, r1
+ orr r0, r2
+ add sp, #0x20
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_02017708:
+ ldr r2, =0x0400100E
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x2]
+ bne _02017724
+ ldrh r3, [r2, #0x2]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x2]
+ b _02017736
+_02017724:
+ cmp r1, #0x2
+ bne _02017736
+ ldrh r3, [r2, #0x2]
+ mov r1, #0x3c
+ lsl r0, r0, #0x1c
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x2]
+_02017736:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x2]
+ ldr r6, =0x0400100E
+ add sp, #0x20
+ lsl r1, r3, #0x13
+ lsl r0, r3, #0x1a
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsr r0, r0, #0x1c
+ lsl r1, r0, #0x2
+ lsl r0, r4, #0x8
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+ pop {r3-r7, pc}
+_02017768:
+ ldr r2, =0x0400100E
+ cmp r1, #0x1
+ ldrh r3, [r2, #0x0]
+ add r2, sp, #0x0
+ strh r3, [r2, #0x0]
+ bne _02017784
+ ldrh r3, [r2, #0x0]
+ ldr r1, =0xFFFFE0FF
+ lsl r0, r0, #0x1b
+ and r1, r3
+ lsr r0, r0, #0x13
+ orr r0, r1
+ strh r0, [r2, #0x0]
+ b _02017796
+_02017784:
+ cmp r1, #0x2
+ bne _02017796
+ ldrh r3, [r2, #0x0]
+ mov r1, #0x38
+ lsl r0, r0, #0x1d
+ bic r3, r1
+ lsr r0, r0, #0x1a
+ orr r0, r3
+ strh r0, [r2, #0x0]
+_02017796:
+ add r0, sp, #0x0
+ ldrh r3, [r0, #0x0]
+ ldr r6, =0x0400100E
+ lsl r1, r3, #0x13
+ lsr r4, r1, #0x1b
+ lsl r1, r3, #0x12
+ lsr r2, r1, #0x1f
+ lsl r0, r3, #0x1a
+ lsl r1, r3, #0x10
+ lsr r3, r1, #0x1e
+ lsl r1, r4, #0x8
+ lsr r0, r0, #0x1d
+ ldrh r5, [r6, #0x0]
+ mov r4, #0x43
+ lsl r3, r3, #0xe
+ and r4, r5
+ lsl r0, r0, #0x2
+ orr r3, r4
+ orr r0, r3
+ lsl r2, r2, #0xd
+ orr r0, r1
+ orr r0, r2
+ strh r0, [r6, #0x0]
+_020177C4:
+ add sp, #0x20
+ pop {r3-r7, pc}
+ // clang-format on
+}
+#endif
+
+THUMB_FUNC u8 FUN_020177DC(u8 param0, u32 param1)
+{
+ switch (param1)
+ {
+ case 0:
+
+ if (param0 == 1)
+ {
+ return 0;
+ }
+ else if (param0 == 2)
+ {
+ return 2;
+ }
+ else if (param0 == 3)
+ {
+ return 1;
+ }
+ else if (param0 == 4)
+ {
+ return 3;
+ }
+ break;
+
+ case 1:
+
+ if (param0 == 0)
+ {
+ return 0;
+ }
+ else if (param0 == 1)
+ {
+ return 1;
+ }
+ else if (param0 == 4)
+ {
+ return 2;
+ }
+ else if (param0 == 5)
+ {
+ return 3;
+ }
+ break;
+
+ case 2:
+
+ if (param0 == 0)
+ {
+ return 0;
+ }
+ else if (param0 == 1)
+ {
+ return 1;
+ }
+ else if (param0 == 4)
+ {
+ return 2;
+ }
+ else if (param0 == 5)
+ {
+ return 3;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_02017850(u32 param0, u8 *param1, u8 *param2)
+{
+ switch (param0)
+ {
+ case 0:
+ *param1 = 0x10;
+ *param2 = 0x10;
+ break;
+ case 1:
+ *param1 = 0x20;
+ *param2 = 0x20;
+ break;
+ case 2:
+ *param1 = 0x20;
+ *param2 = 0x40;
+ break;
+ case 3:
+ *param1 = 0x40;
+ *param2 = 0x20;
+ break;
+ case 4:
+ *param1 = 0x40;
+ *param2 = 0x40;
+ break;
+ case 5:
+ *param1 = 0x80;
+ *param2 = 0x80;
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_020178A0(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ if (param0->unk08[param1].unk08 != NULL)
+ {
+ FreeToHeap(param0->unk08[param1].unk08);
+ param0->unk08[param1].unk08 = NULL;
+ }
+}
+
+THUMB_FUNC void FUN_020178BC(u32 param0, u16 param1)
+{
+ switch (param0)
+ {
+ case 0:
+ reg_G2_BG0CNT = (u16)(reg_G2_BG0CNT & ~3 | param1);
+ break;
+ case 1:
+ reg_G2_BG1CNT = (u16)(reg_G2_BG1CNT & ~3 | param1);
+ break;
+ case 2:
+ reg_G2_BG2CNT = (u16)(reg_G2_BG2CNT & ~3 | param1);
+ break;
+ case 3:
+ reg_G2_BG3CNT = (u16)(reg_G2_BG3CNT & ~3 | param1);
+ break;
+ case 4:
+ reg_G2S_DB_BG0CNT = (u16)(reg_G2S_DB_BG0CNT & ~3 | param1);
+ break;
+ case 5:
+ reg_G2S_DB_BG1CNT = (u16)(reg_G2S_DB_BG1CNT & ~3 | param1);
+ break;
+ case 6:
+ reg_G2S_DB_BG2CNT = (u16)(reg_G2S_DB_BG2CNT & ~3 | param1);
+ break;
+ case 7:
+ reg_G2S_DB_BG3CNT = (u16)(reg_G2S_DB_BG3CNT & ~3 | param1);
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_0201797C(u32 param0, GX_LayerToggle toggle)
+{
+ switch (param0)
+ {
+ case 0:
+ GX_EngineAToggleLayers(1, toggle);
+ break;
+ case 1:
+ GX_EngineAToggleLayers(2, toggle);
+ break;
+ case 2:
+ GX_EngineAToggleLayers(4, toggle);
+ break;
+ case 3:
+ GX_EngineAToggleLayers(8, toggle);
+ break;
+ case 4:
+ GX_EngineBToggleLayers(1, toggle);
+ break;
+ case 5:
+ GX_EngineBToggleLayers(2, toggle);
+ break;
+ case 6:
+ GX_EngineBToggleLayers(4, toggle);
+ break;
+ case 7:
+ GX_EngineBToggleLayers(8, toggle);
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_020179E0(struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, fx32 val)
+{
+ FUN_02017B8C(&param0->unk08[param1], param2, val);
+
+ u32 r1 = (u32)param0->unk08[param1].unk14;
+ u32 r0 = (u32)param0->unk08[param1].unk18;
+ switch (param1)
+ {
+ case 0:
+
+ reg_G2_BG0OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ break;
+ case 1:
+
+ reg_G2_BG1OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ break;
+
+ case 2:
+ if (param0->unk08[2].unk1c == 0)
+ {
+ reg_G2_BG2OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ }
+ else
+ {
+ FUN_02017C6C(param0, 2);
+ }
+
+ break;
+
+ case 3:
+ if (param0->unk08[3].unk1c == 0)
+ {
+ reg_G2_BG3OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ }
+ else
+ {
+ FUN_02017C6C(param0, 3);
+ }
+
+ break;
+
+ case 4:
+
+ reg_G2S_DB_BG0OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ break;
+ case 5:
+
+ reg_G2S_DB_BG1OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ break;
+
+ case 6:
+ if (param0->unk08[6].unk1c == 0)
+ {
+ reg_G2S_DB_BG2OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ }
+ else
+ {
+ FUN_02017C6C(param0, 6);
+ }
+
+ break;
+
+ case 7:
+ if (param0->unk08[7].unk1c == 0)
+ {
+ reg_G2S_DB_BG3OFS = (r1 & 0x1FF) | ((r0 << 16) & 0x1FF0000);
+ }
+ else
+ {
+ FUN_02017C6C(param0, 7);
+ }
+
+ break;
+ }
+}
+
+THUMB_FUNC fx32 FUN_02017B48(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ return param0->unk08[param1].unk14;
+}
+
+THUMB_FUNC fx32 FUN_02017B54(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ return param0->unk08[param1].unk18;
+}
+
+THUMB_FUNC void FUN_02017B60(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ u32 param2,
+ fx32 param3,
+ struct Mtx22 *param4,
+ fx32 param5,
+ fx32 param6)
+{
+ FUN_02017B8C(&param0->unk08[param1], param2, param3);
+ FUN_02017BD0(param0, param1, param4, param5, param6);
+}
+
+THUMB_FUNC void FUN_02017B8C(struct UnkStruct_02016B94_2_sub *param0, u32 param1, fx32 val)
+{
+ switch (param1)
+ {
+ case 0:
+ param0->unk14 = val;
+ break;
+ case 1:
+ param0->unk14 += val;
+ break;
+ case 2:
+ param0->unk14 -= val;
+ break;
+ case 3:
+ param0->unk18 = val;
+ break;
+ case 4:
+ param0->unk18 += val;
+ break;
+ case 5:
+ param0->unk18 -= val;
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_02017BD0(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, struct Mtx22 *param2, fx32 param3, fx32 param4)
+{
+ switch (param1)
+ {
+ case 2:
+ G2x_SetBGyAffine_(reg_G2_BG2P,
+ param2,
+ param3,
+ param4,
+ param0->unk08[param1].unk14,
+ param0->unk08[param1].unk18);
+ break;
+ case 3:
+ G2x_SetBGyAffine_(reg_G2_BG3P,
+ param2,
+ param3,
+ param4,
+ param0->unk08[param1].unk14,
+ param0->unk08[param1].unk18);
+ break;
+ case 6:
+ G2x_SetBGyAffine_(reg_G2S_DB_BG2P,
+ param2,
+ param3,
+ param4,
+ param0->unk08[param1].unk14,
+ param0->unk08[param1].unk18);
+ break;
+ case 7:
+ G2x_SetBGyAffine_(reg_G2S_DB_BG3P,
+ param2,
+ param3,
+ param4,
+ param0->unk08[param1].unk14,
+ param0->unk08[param1].unk18);
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_02017C6C(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ struct Mtx22 mtx;
+ MTX22_2DAffine(&mtx, 0, 0x1000, 0x1000, 0);
+ FUN_02017BD0(param0, param1, &mtx, 0, 0);
+}
+
+THUMB_FUNC void FUN_02017C98(const void *param0, void *param1, u32 param2)
+{
+ if (param2 == 0)
+ {
+ MI_UncompressLZ8(param0, param1);
+ return;
+ }
+
+ if (((u32)param0 % 4) == 0 && ((u32)param1 % 4) == 0 && ((u16)param2 % 4) == 0)
+ {
+ MI_CpuCopy32(param0, param1, param2);
+ return;
+ }
+
+ MI_CpuCopy16(param0, param1, param2);
+}
+
+THUMB_FUNC void FUN_02017CD0(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ FUN_02017CE8(param0,
+ param1,
+ param0->unk08[param1].unk08,
+ param0->unk08[param1].unk0c,
+ param0->unk08[param1].unk10);
+}
+
+THUMB_FUNC void FUN_02017CE8(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 *param2, u32 param3, u32 param4)
+{
+ u32 st0 = param3;
+ if (param3 == 0)
+ {
+ void *st4 = param0->unk08[param1].unk08;
+ if (st4 != 0)
+ {
+ FUN_02017C98(param2, st4, param3);
+ FUN_02017D68(param1, st4, param0->unk08[param1].unk10 * 2, param0->unk08[param1].unk0c);
+ return;
+ }
+
+ u32 r7 = param2[0] >> 8;
+ void *ptr = AllocFromHeapAtEnd(param0->unk00, r7);
+ FUN_02017C98(param2, ptr, st0);
+ FUN_02017D68(param1, ptr, param4 * 2, r7);
+ FreeToHeap(ptr);
+ return;
+ }
+
+ FUN_02017D68(param1, param2, param4 * 2, param3);
+}
+
+THUMB_FUNC void FUN_02017D68(u32 param0, void *param1, u32 offset, u32 size)
+{
+ DC_FlushRange(param1, size);
+
+ switch (param0)
+ {
+ case 0:
+ GX_LoadBG0Scr(param1, offset, size);
+ break;
+ case 1:
+ GX_LoadBG1Scr(param1, offset, size);
+ break;
+ case 2:
+ GX_LoadBG2Scr(param1, offset, size);
+ break;
+ case 3:
+ GX_LoadBG3Scr(param1, offset, size);
+ break;
+ case 4:
+ GXS_LoadBG0Scr(param1, offset, size);
+ break;
+ case 5:
+ GXS_LoadBG1Scr(param1, offset, size);
+ break;
+ case 6:
+ GXS_LoadBG2Scr(param1, offset, size);
+ break;
+ case 7:
+ GXS_LoadBG3Scr(param1, offset, size);
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_02017DFC(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, void *param2, u32 param3)
+{
+ FUN_02017C98(param2, param0->unk08[param1].unk08, param3);
+}
+
+THUMB_FUNC void FUN_02017E14(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 *param2, u32 param3, u32 param4)
+{
+ if (param0->unk08[param1].unk1e == 0)
+ {
+ FUN_02017E40(param0, param1, param2, param3, param4 << 5);
+ return;
+ }
+ FUN_02017E40(param0, param1, param2, param3, param4 << 6);
+}
+
+THUMB_FUNC void FUN_02017E40(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 *param2, u32 param3, u32 param4)
+{
+ u32 st0 = param3;
+ if (param3 == 0)
+ {
+
+ u32 r4 = param2[0] >> 8;
+ void *ptr = AllocFromHeapAtEnd(param0->unk00, r4);
+ FUN_02017C98(param2, ptr, st0);
+ FUN_02017E84(param1, ptr, param4, r4);
+ FreeToHeap(ptr);
+ return;
+ }
+
+ FUN_02017E84(param1, param2, param4, param3);
+}
+
+THUMB_FUNC void FUN_02017E84(u32 param0, void *param1, u32 offset, u32 size)
+{
+ DC_FlushRange(param1, size);
+
+ switch (param0)
+ {
+ case 0:
+ GX_LoadBG0Char(param1, offset, size);
+ break;
+ case 1:
+ GX_LoadBG1Char(param1, offset, size);
+ break;
+ case 2:
+ GX_LoadBG2Char(param1, offset, size);
+ break;
+ case 3:
+ GX_LoadBG3Char(param1, offset, size);
+ break;
+ case 4:
+ GXS_LoadBG0Char(param1, offset, size);
+ break;
+ case 5:
+ GXS_LoadBG1Char(param1, offset, size);
+ break;
+ case 6:
+ GXS_LoadBG2Char(param1, offset, size);
+ break;
+ case 7:
+ GXS_LoadBG3Char(param1, offset, size);
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_02017F18(u32 param0, u32 size, u32 offset, u32 heap_id)
+{
+ void *ptr = AllocFromHeapAtEnd(heap_id, size);
+ memset(ptr, 0, size);
+
+ FUN_02017E84(param0, ptr, offset, size);
+ FreeToHeapExplicit(heap_id, ptr);
+}
+
+THUMB_FUNC void FUN_02017F48(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, u32 param3, u32 param4)
+{
+ void *st4;
+ u32 st0 = param3 * param0->unk08[param1].unk1f;
+ u32 r5 = param2;
+ st4 = AllocFromHeapAtEnd(param0->unk00, st0);
+
+ if (param0->unk08[param1].unk1f == 0x20)
+ {
+ r5 = (r5 << 0xc | r5 << 0x8 | r5 << 0x4 | r5);
+ r5 |= r5 << 0x10;
+ }
+ else
+ {
+ r5 = r5 << 0x18 | r5 << 0x10 | r5 << 8 | r5;
+ }
+
+ MI_CpuFillFast(st4, r5, st0);
+
+ FUN_02017E84((u8)param1, st4, param0->unk08[param1].unk1f * param4, st0);
+ FreeToHeap(st4);
+}
+
+THUMB_FUNC void FUN_02017FB4(u32 param0, void *param1, u32 offset, u32 size)
+{
+ DC_FlushRange(param1, offset);
+ if (param0 < 4)
+ {
+ GX_LoadBGPltt(param1, size, offset);
+ return;
+ }
+
+ GXS_LoadBGPltt(param1, size, offset);
+}
+
+THUMB_FUNC void FUN_02017FE4(u32 param0, u32 param1)
+{
+ FUN_02017FB4(param0, &param1, 2, 0);
+}
+
+THUMB_FUNC u16 FUN_02017FFC(u8 param0, u8 param1, u8 param2)
+{
+ switch (param2)
+ {
+ case 0:
+ return (u16)(param0 + (param1 << 4));
+ case 1:
+ case 2:
+ return (u16)(param0 + (param1 << 5));
+ case 3:
+ return (u16)((param0 & 0x1f) + ((param1 + (param0 & ~0x1f)) << 5));
+ case 4:
+ u16 res = (u16)(((u16)((param0 >> 5) + (param1 >> 5) * 2)) << 10);
+ res += (param0 & 0x1f) + ((param1 & 0x1f) << 5);
+ return res;
+ case 5:
+ return 0;
+ }
+
+ return param0;
+}
+
+THUMB_FUNC u16 FUN_02018068(u8 param0, u8 param1, u8 param2, u8 param3)
+{
+ u8 r2 = 0;
+ u16 r3 = 0;
+ s16 r4 = (s16)(param2 - 32);
+ s16 r5 = (s16)(param3 - 32);
+
+ if (((u32)param0 >> 5) != 0)
+ {
+ r2++;
+ }
+
+ if (((u32)param1 >> 5) != 0)
+ {
+ r2 += 2;
+ }
+
+ switch (r2)
+ {
+ case 0:
+ if (r4 >= 0)
+ {
+ r3 += param0 + (param1 << 5);
+ }
+ else
+ {
+ r3 += param0 + param1 * param2;
+ }
+ break;
+ case 1:
+ if (r5 >= 0)
+ {
+ r3 += 0x400;
+ }
+ else
+ {
+ r3 += (param3 << 5);
+ }
+
+ r3 += (param0 & 0x1f) + param1 * r4;
+ break;
+ case 2:
+ r3 += param2 << 5;
+ if (r4 >= 0)
+ {
+ r3 += param0 + ((param1 & 0x1f) << 5);
+ }
+ else
+ {
+ r3 += param0 + (param1 & 0x1f) * param2;
+ }
+ break;
+ case 3:
+ r3 += (param2 + r5) << 5;
+ r3 += (param0 & 0x1f) + (param1 & 0x1f) * r4;
+ break;
+ }
+
+ return r3;
+}
+
+THUMB_FUNC void FUN_02018148(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ void *param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ u8 param6)
+{
+ FUN_02018170(param0, param1, param3, param4, param5, param6, param2, 0, 0, param5, param6);
+}
+
+THUMB_FUNC void FUN_02018170(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ void *param6,
+ u8 param7,
+ u8 param8,
+ u8 param9,
+ u8 param10)
+{
+ if (param0->unk08[param1].unk1c != 1)
+ {
+ FUN_02018268(&param0->unk08[param1],
+ param2,
+ param3,
+ param4,
+ param5,
+ (u16 *)param6,
+ param7,
+ param8,
+ param9,
+ param10,
+ 0);
+ }
+ else
+ {
+ FUN_020183DC(&param0->unk08[param1],
+ param2,
+ param3,
+ param4,
+ param5,
+ (u8 *)param6,
+ param7,
+ param8,
+ param9,
+ param10,
+ 0);
+ }
+}
+
+THUMB_FUNC void FUN_020181EC(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ void *param6,
+ u8 param7,
+ u8 param8,
+ u8 param9,
+ u8 param10)
+{
+ if (param0->unk08[param1].unk1c != 1)
+ {
+ FUN_02018268(&param0->unk08[param1],
+ param2,
+ param3,
+ param4,
+ param5,
+ (u16 *)param6,
+ param7,
+ param8,
+ param9,
+ param10,
+ 1);
+ }
+ else
+ {
+ FUN_020183DC(&param0->unk08[param1],
+ param2,
+ param3,
+ param4,
+ param5,
+ (u8 *)param6,
+ param7,
+ param8,
+ param9,
+ param10,
+ 1);
+ }
+}
+
+THUMB_FUNC void FUN_02018268(struct UnkStruct_02016B94_2_sub *param0,
+ u8 param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u16 *param5,
+ u8 param6,
+ u8 param7,
+ u8 param8,
+ u8 param9,
+ u8 param10)
+{
+ void *st2c = param0->unk08;
+
+ if (st2c == 0)
+ {
+ return;
+ }
+
+ u8 st41;
+ u8 st40;
+ FUN_02017850(param0->unk1d, &st41, &st40);
+
+ u8 i;
+ u8 j;
+ if (param10 == 0)
+ {
+ for (i = 0; i < param4; i++)
+ {
+
+ if (param2 + i >= st40)
+ {
+ break;
+ }
+
+ if (param7 + i >= param9)
+ {
+ break;
+ }
+
+ for (j = 0; j < param3; j++)
+ {
+
+ if (param1 + j >= st41)
+ {
+ break;
+ }
+
+ if (param6 + j >= param8)
+ {
+ break;
+ }
+
+ ((u16 *)st2c)[FUN_02017FFC((u8)(param1 + j), (u8)(param2 + i), param0->unk1d)] =
+ param5[param6 + param8 * (param7 + i) + j];
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < param4; i++)
+ {
+
+ if (param2 + i >= st40)
+ {
+ break;
+ }
+
+ if (param7 + i >= param9)
+ {
+ break;
+ }
+
+ for (j = 0; j < param3; j++)
+ {
+
+ if (param1 + j >= st41)
+ {
+ break;
+ }
+
+ if (param6 + j >= param8)
+ {
+ break;
+ }
+
+ ((u16 *)st2c)[FUN_02017FFC((u8)(param1 + j), (u8)(param2 + i), param0->unk1d)] =
+ param5[FUN_02018068((u8)(param6 + j), (u8)(param7 + i), param8, param9)];
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_020183DC(struct UnkStruct_02016B94_2_sub *param0,
+ u8 param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u8 *param5,
+ u8 param6,
+ u8 param7,
+ u8 param8,
+ u8 param9,
+ u8 param10)
+{
+ void *st2c = param0->unk08;
+
+ if (st2c == 0)
+ {
+ return;
+ }
+
+ u8 st41;
+ u8 st40;
+ FUN_02017850(param0->unk1d, &st41, &st40);
+
+ u8 i;
+ u8 j;
+ if (param10 == 0)
+ {
+ for (i = 0; i < param4; i++)
+ {
+
+ if (param2 + i >= st40)
+ {
+ break;
+ }
+
+ if (param7 + i >= param9)
+ {
+ break;
+ }
+
+ for (j = 0; j < param3; j++)
+ {
+
+ if (param1 + j >= st41)
+ {
+ break;
+ }
+
+ if (param6 + j >= param8)
+ {
+ break;
+ }
+
+ ((u8 *)st2c)[FUN_02017FFC((u8)(param1 + j), (u8)(param2 + i), param0->unk1d)] =
+ param5[param6 + param8 * (param7 + i) + j];
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < param4; i++)
+ {
+
+ if (param2 + i >= st40)
+ {
+ break;
+ }
+
+ if (param7 + i >= param9)
+ {
+ break;
+ }
+
+ for (j = 0; j < param3; j++)
+ {
+
+ if (param1 + j >= st41)
+ {
+ break;
+ }
+
+ if (param6 + j >= param8)
+ {
+ break;
+ }
+
+ ((u8 *)st2c)[FUN_02017FFC((u8)(param1 + j), (u8)(param2 + i), param0->unk1d)] =
+ param5[FUN_02018068((u8)(param6 + j), (u8)(param7 + i), param8, param9)];
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02018540(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ u16 param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ u8 param6,
+ u8 param7)
+{
+ if (param0->unk08[param1].unk1c != 1)
+ {
+
+ FUN_02018590(&param0->unk08[param1], param2, param3, param4, param5, param6, param7);
+ }
+ else
+ {
+ FUN_02018640(&param0->unk08[param1], (u8)param2, param3, param4, param5, param6);
+ }
+}
+
+THUMB_FUNC void FUN_02018590(struct UnkStruct_02016B94_2_sub *param0,
+ u16 param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ u8 param6)
+{
+ void *r4 = param0->unk08;
+
+ if (r4 != 0)
+ {
+
+ u8 st19;
+ u8 st18;
+ FUN_02017850(param0->unk1d, &st19, &st18);
+
+ u8 i;
+ u8 j;
+ for (i = param3; i < param3 + param5; i++)
+ {
+ if (i >= st18)
+ {
+ break;
+ }
+
+ for (j = param2; j < param2 + param4; j++)
+ {
+ if (j >= st19)
+ {
+ break;
+ }
+
+ u16 idx = FUN_02017FFC(j, i, param0->unk1d);
+
+ if (param6 == 0x11)
+ {
+ ((u16 *)r4)[idx] = param1;
+ }
+ else if (param6 == 0x10)
+ {
+ ((u16 *)r4)[idx] = (u16)((((u16 *)r4)[idx] & 0xF000) + param1);
+ }
+ else
+ {
+ ((u16 *)r4)[idx] = (u16)((param6 << 0xc) + param1);
+ }
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02018640(
+ struct UnkStruct_02016B94_2_sub *param0, u8 param1, u8 param2, u8 param3, u8 param4, u8 param5)
+{
+ void *r4 = param0->unk08;
+
+ if (r4 != 0)
+ {
+
+ u8 st19;
+ u8 st18;
+ FUN_02017850(param0->unk1d, &st19, &st18);
+
+ u8 i;
+ u8 j;
+ for (i = param3; i < param3 + param5; i++)
+ {
+ if (i >= st18)
+ {
+ break;
+ }
+
+ for (j = param2; j < param2 + param4; j++)
+ {
+ if (j >= st19)
+ {
+ break;
+ }
+
+ ((u8 *)r4)[FUN_02017FFC(j, i, param0->unk1d)] = param1;
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_020186B4(struct UnkStruct_02016B94_2 *param0,
+ u32 param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ u8 param6)
+{
+ void *r4 = param0->unk08[param1].unk08;
+
+ if (r4 != NULL)
+ {
+ u8 st11;
+ u8 st10;
+ FUN_02017850(param0->unk08[param1].unk1d, &st11, &st10);
+
+ u8 i;
+ u8 j;
+ for (i = param3; i < param3 + param5; i++)
+ {
+ if (i >= st10)
+ {
+ break;
+ }
+
+ for (j = param2; j < param2 + param4; j++)
+ {
+ if (j >= st11)
+ {
+ break;
+ }
+
+ u16 idx = FUN_02017FFC(j, i, param0->unk08[param1].unk1d);
+ ((u16 *)r4)[idx] = (u16)((((u16 *)r4)[idx] & 0xfff) | (param6 << 0xc));
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02018744(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ if (param0->unk08[param1].unk08 != NULL)
+ {
+ MI_CpuClear16(param0->unk08[param1].unk08, param0->unk08[param1].unk0c);
+ FUN_02017CD0(param0, param1);
+ }
+}
+
+THUMB_FUNC void FUN_02018768(struct UnkStruct_02016B94_2 *param0, u32 param1, u16 param2)
+{
+ if (param0->unk08[param1].unk08 != NULL)
+ {
+ MI_CpuFill16(param0->unk08[param1].unk08, param2, param0->unk08[param1].unk0c);
+ FUN_02017CD0(param0, param1);
+ }
+}
+
+THUMB_FUNC void FUN_0201878C(struct UnkStruct_02016B94_2 *param0, u32 param1, u16 param2)
+{
+ if (param0->unk08[param1].unk08 != NULL)
+ {
+ MI_CpuFill16(param0->unk08[param1].unk08, param2, param0->unk08[param1].unk0c);
+ FUN_0201AC68(param0, param1);
+ }
+}
+
+THUMB_FUNC void *FUN_020187B0(u32 param0)
+{
+ switch (param0)
+ {
+ case 0:
+ return G2_GetBG0CharPtr();
+ case 1:
+ return G2_GetBG1CharPtr();
+ case 2:
+ return G2_GetBG2CharPtr();
+ case 3:
+ return G2_GetBG3CharPtr();
+ case 4:
+ return G2S_GetBG0CharPtr();
+ case 5:
+ return G2S_GetBG1CharPtr();
+ case 6:
+ return G2S_GetBG2CharPtr();
+ case 7:
+ return G2S_GetBG3CharPtr();
+ }
+
+ return NULL;
+}
+
+THUMB_FUNC void FUN_02018808(u8 *param0, u32 param1, u8 (*param2)[2], u8 param3)
+{
+ param3 <<= 4;
+ for (int i = 0; i < param1; i++)
+ {
+ param2[i][0] = (u8)(param0[i] & 0xf);
+ if (param2[i][0] != 0)
+ {
+ param2[i][0] += param3;
+ }
+
+ param2[i][1] = (u8)((param0[i] >> 4) & 0xf);
+ if (param2[i][1] != 0)
+ {
+ param2[i][1] += param3;
+ }
+ }
+}
+
+THUMB_FUNC u8 (*FUN_02018848(u8 *param0, u32 param1, u8 param2, u32 heap_id))[2]
+{
+ u8(*ptr)[2] = (u8(*)[2])AllocFromHeap(heap_id, param1 * 2);
+
+ FUN_02018808(param0, param1, ptr, param2);
+
+ return ptr;
+}
+
+THUMB_FUNC void *FUN_0201886C(struct UnkStruct_02016B94_2 *param0, u8 param1)
+{
+ return param0->unk08[param1].unk08;
+}
+
+THUMB_FUNC u16 FUN_02018878(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ return param0->unk08[param1].unk20;
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC u8 FUN_02018884(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+
+ // the compiler keeps optimizing the stack away :(
+ u16 st0[16];
+ switch (param1)
+ {
+ case 0:
+ st0[15] = reg_G2_BG0CNT;
+ return (u32)(st0[15] << 0x1e) >> 0x1e;
+ case 1:
+ st0[14] = reg_G2_BG1CNT;
+ return (u32)(st0[14] << 0x1e) >> 0x1e;
+
+ case 2:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ st0[13] = reg_G2_BG2CNT;
+ return (u32)(st0[13] << 0x1e) >> 0x1e;
+ case 1:
+ st0[12] = reg_G2_BG2CNT;
+ return (u32)(st0[12] << 0x1e) >> 0x1e;
+ case 2:
+ st0[11] = reg_G2_BG2CNT;
+ return (u32)(st0[11] << 0x1e) >> 0x1e;
+ }
+ break;
+ case 3:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ st0[10] = reg_G2_BG3CNT;
+ return (u32)(st0[10] << 0x1e) >> 0x1e;
+ case 1:
+ st0[9] = reg_G2_BG3CNT;
+ return (u32)(st0[9] << 0x1e) >> 0x1e;
+ case 2:
+ st0[8] = reg_G2_BG3CNT;
+ return (u32)(st0[8] << 0x1e) >> 0x1e;
+ }
+ break;
+
+ case 4:
+ st0[7] = reg_G2S_DB_BG0CNT;
+ return (u32)(st0[7] << 0x1e) >> 0x1e;
+ case 5:
+ st0[6] = reg_G2S_DB_BG1CNT;
+ return (u32)(st0[6] << 0x1e) >> 0x1e;
+
+ case 6:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ st0[5] = reg_G2S_DB_BG2CNT;
+ return (u32)(st0[5] << 0x1e) >> 0x1e;
+ case 1:
+ st0[4] = reg_G2S_DB_BG2CNT;
+ return (u32)(st0[4] << 0x1e) >> 0x1e;
+ case 2:
+ st0[3] = reg_G2S_DB_BG2CNT;
+ return (u32)(st0[3] << 0x1e) >> 0x1e;
+ }
+ break;
+ case 7:
+ switch (param0->unk08[param1].unk1c)
+ {
+ default:
+ case 0:
+ st0[2] = reg_G2S_DB_BG3CNT;
+ return (u32)(st0[2] << 0x1e) >> 0x1e;
+ case 1:
+ st0[1] = reg_G2S_DB_BG3CNT;
+ return (u32)(st0[1] << 0x1e) >> 0x1e;
+ case 2:
+ st0[0] = reg_G2S_DB_BG3CNT;
+ return (u32)(st0[0] << 0x1e) >> 0x1e;
+ }
+ break;
+ }
+
+ return 0;
+}
+#else
+THUMB_FUNC asm u8 FUN_02018884(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ // clang-format off
+ sub sp, #0x20
+ cmp r1, #0x7
+ bls _0201888C
+ b _02018A38
+_0201888C:
+ add r2, r1, r1
+ add r2, pc
+ ldrh r2, [r2, #0x6]
+ lsl r2, r2, #0x10
+ asr r2, r2, #0x10
+ add pc, r2
+_02018898:
+ // jump table (using 16-bit offset)
+ // .short _020188A8 - _02018898 - 2; case 0
+ // .short _020188BC - _02018898 - 2; case 1
+ // .short _020188D0 - _02018898 - 2; case 2
+ // .short _02018920 - _02018898 - 2; case 3
+ // .short _02018970 - _02018898 - 2; case 4
+ // .short _02018984 - _02018898 - 2; case 5
+ // .short _02018998 - _02018898 - 2; case 6
+ // .short _020189E8 - _02018898 - 2; case 7
+
+ lsl r6, r1, #0
+ lsl r2, r4, #0
+ lsl r6, r6, #0
+ lsl r6, r0, #2
+ lsl r6, r2, #3
+ lsl r2, r5, #3
+ lsl r6, r7, #3
+ lsl r6, r1, #5
+_020188A8:
+ ldr r0, =0x04000008
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x1e]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_020188BC:
+ ldr r0, =0x0400000A
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x1c]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_020188D0:
+ mov r2, #0x2c
+ mul r2, r1
+ add r0, r0, r2
+ ldrb r0, [r0, #0x1c]
+ cmp r0, #0x0
+ beq _020188E4
+ cmp r0, #0x1
+ beq _020188F8
+ cmp r0, #0x2
+ beq _0201890C
+_020188E4:
+ ldr r0, =0x0400000C
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x1a]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_020188F8:
+ ldr r0, =0x0400000C
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x18]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_0201890C:
+ ldr r0, =0x0400000C
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x16]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018920:
+ mov r2, #0x2c
+ mul r2, r1
+ add r0, r0, r2
+ ldrb r0, [r0, #0x1c]
+ cmp r0, #0x0
+ beq _02018934
+ cmp r0, #0x1
+ beq _02018948
+ cmp r0, #0x2
+ beq _0201895C
+_02018934:
+ ldr r0, =0x0400000E
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x14]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018948:
+ ldr r0, =0x0400000E
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x12]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_0201895C:
+ ldr r0, =0x0400000E
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x10]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018970:
+ ldr r0, =0x04001008
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0xe]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018984:
+ ldr r0, =0x0400100A
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0xc]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018998:
+ mov r2, #0x2c
+ mul r2, r1
+ add r0, r0, r2
+ ldrb r0, [r0, #0x1c]
+ cmp r0, #0x0
+ beq _020189AC
+ cmp r0, #0x1
+ beq _020189C0
+ cmp r0, #0x2
+ beq _020189D4
+_020189AC:
+ ldr r0, =0x0400100C
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0xa]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_020189C0:
+ ldr r0, =0x0400100C
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x8]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_020189D4:
+ ldr r0, =0x0400100C
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x6]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_020189E8:
+ mov r2, #0x2c
+ mul r2, r1
+ add r0, r0, r2
+ ldrb r0, [r0, #0x1c]
+ cmp r0, #0x0
+ beq _020189FC
+ cmp r0, #0x1
+ beq _02018A10
+ cmp r0, #0x2
+ beq _02018A24
+_020189FC:
+ ldr r0, =0x0400100E
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x4]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018A10:
+ ldr r0, =0x0400100E
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x2]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018A24:
+ ldr r0, =0x0400100E
+ ldrh r1, [r0, #0x0]
+ add r0, sp, #0x0
+ add sp, #0x20
+ strh r1, [r0, #0x0]
+ lsl r0, r1, #0x1e
+ lsr r0, r0, #0x1e
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ bx lr
+_02018A38:
+ mov r0, #0x0
+ add sp, #0x20
+ bx lr
+ // clang-format on
+}
+#endif
+
+#ifdef NONMATCHING
+THUMB_FUNC void BlitBitmapRect4Bit(struct UnkStruct_02016B94_3 *param0,
+ struct UnkStruct_02016B94_3 *param1,
+ u16 param2,
+ u16 param3,
+ u16 param4,
+ u16 param5,
+ u16 param6,
+ u16 param7,
+ u16 param8)
+{
+
+ u8 *unk1;
+ u8 *unk2;
+
+ int st50;
+ if (param1->unk04 - param4 < param6)
+ {
+ st50 = param2 + param1->unk04 - param4;
+ }
+ else
+ {
+ st50 = param2 + param6;
+ }
+
+ int st4c;
+ if (param1->unk06 - param5 < param7)
+ {
+ st4c = param3 + param1->unk06 - param5;
+ }
+ else
+ {
+ st4c = param3 + param7;
+ }
+
+ int st48 = (param0->unk04 + (param0->unk04 & 7)) >> 3;
+
+ int st44 = (param1->unk04 + (param1->unk04 & 7)) >> 3;
+
+ u32 i, i1;
+ u32 j, j1;
+ if (param8 == 0xFFFF)
+ {
+ i1 = param5;
+ for (i = param3; i < st4c; i++)
+ {
+ j1 = param4;
+ for (j = param2; j < st50; j++)
+ {
+
+ unk1 =
+ (u32)(param1->unk00) + (j1 >> 1) &
+ 0x3 + ((j1 << 2) & 0x3fe0) + st44 * ((i1 << 2) & 0x3fe0) + ((i1 << 2) & 0x1c);
+ unk2 = (u32)(param0->unk00) + (j >> 1) &
+ 0x3 + ((j << 2) & 0x3fe0) + st48 * ((i << 2) & 0x3FE0) + ((i << 2) & 0x1c);
+
+ u8 r1 = *unk2;
+
+ u32 r2 = (j1 << 0x1f) >> 0x1d;
+ u32 r7 = ((r1 >> ((j << 0x1f) >> 0x1d)) & 0xf) << r2;
+
+ *unk1 = r7 | (*unk1 & (0xf0 >> r2));
+
+ j1++;
+ }
+ i1++;
+ }
+ }
+ else
+ {
+
+ i1 = param5;
+ for (i = param3; i < st4c; i++)
+ {
+ j1 = param4;
+ for (j = param2; j < st50; j++)
+ {
+
+ unk1 = (u32)param1->unk00 + ((j1 >> 1) & 3) + ((j1 << 2) & 0x3fe0) +
+ st44 * ((i1 << 2) & 0x3fe0) + (i1 << 2) &
+ 0x1c;
+ unk2 = (u32)param0->unk00 + ((j >> 1) & 3) + ((j << 2) & 0x3fe0) +
+ st48 * ((i << 2) & 0x3fe0) + ((i << 2) & 0x1c);
+ u8 r0 = ((*unk2) >> ((j << 0x1f) >> 0x1d)) & 0xf;
+
+ if (r0 != param8)
+ {
+ u32 r7 = ((j1 << 0x1f) >> 0x1d);
+ *unk1 = (r0 << r7) | (*unk1 & (0xf0 >> r7));
+ }
+
+ j1++;
+ }
+ i1++;
+ }
+ }
+}
+#else
+THUMB_FUNC asm void BlitBitmapRect4Bit(struct UnkStruct_02016B94_3 *param0,
+ struct UnkStruct_02016B94_3 *param1,
+ u16 param2,
+ u16 param3,
+ u16 param4,
+ u16 param5,
+ u16 param6,
+ u16 param7,
+ u16 param8)
+{
+ // clang-format off
+ push {r3-r7, lr}
+ sub sp, #0x68
+ str r2, [sp, #0x8]
+ str r3, [sp, #0xc]
+ add r2, sp, #0x70
+ str r0, [sp, #0x0]
+ ldrh r0, [r2, #0x10]
+ str r1, [sp, #0x4]
+ ldrh r2, [r2, #0x18]
+ str r0, [sp, #0x10]
+ add r0, r1, #0x0
+ ldrh r1, [r0, #0x4]
+ ldr r0, [sp, #0x10]
+ sub r3, r1, r0
+ cmp r3, r2
+ bge _02018A88
+ ldr r0, [sp, #0x8]
+ add r0, r0, r3
+ str r0, [sp, #0x50]
+ b _02018A8E
+_02018A88:
+ ldr r0, [sp, #0x8]
+ add r0, r2, r0
+ str r0, [sp, #0x50]
+_02018A8E:
+ ldr r2, [sp, #0x4]
+ add r3, sp, #0x70
+ ldrh r0, [r3, #0x14]
+ ldrh r2, [r2, #0x6]
+ ldrh r3, [r3, #0x1c]
+ sub r4, r2, r0
+ cmp r4, r3
+ bge _02018AA6
+ ldr r2, [sp, #0xc]
+ add r2, r2, r4
+ str r2, [sp, #0x4c]
+ b _02018AAC
+_02018AA6:
+ ldr r2, [sp, #0xc]
+ add r2, r3, r2
+ str r2, [sp, #0x4c]
+_02018AAC:
+ ldr r2, [sp, #0x0]
+ mov r3, #0x7
+ ldrh r4, [r2, #0x4]
+ add r2, r4, #0x0
+ and r2, r3
+ add r2, r4, r2
+ asr r2, r2, #0x3
+ str r2, [sp, #0x48]
+ add r2, r1, #0x0
+ and r2, r3
+ add r1, r1, r2
+ asr r1, r1, #0x3
+ str r1, [sp, #0x44]
+ add r1, sp, #0x70
+ ldrh r1, [r1, #0x20]
+ ldr r2, =0x0000FFFF
+ str r1, [sp, #0x38]
+ cmp r1, r2
+ bne _02018BB4
+ ldr r2, [sp, #0xc]
+ ldr r1, [sp, #0x4c]
+ cmp r2, r1
+ bge _02018ADE
+ cmp r2, r1
+ blt _02018AE0
+_02018ADE:
+ b _02018C92
+_02018AE0:
+ add r1, r2, #0x0
+ lsl r1, r1, #0x2
+ lsl r0, r0, #0x2
+ str r1, [sp, #0x28]
+ str r0, [sp, #0x24]
+_02018AEA:
+ ldr r3, [sp, #0x8]
+ ldr r0, [sp, #0x50]
+ add r1, r3, #0x0
+ ldr r4, [sp, #0x10]
+ cmp r1, r0
+ bge _02018B96
+ cmp r1, r0
+ bge _02018B96
+ add r0, r3, #0x0
+ lsl r5, r0, #0x2
+ add r0, r4, #0x0
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r1, [sp, #0x28]
+ ldr r2, [sp, #0x48]
+ and r1, r0
+ mul r2, r1
+ str r2, [sp, #0x20]
+ ldr r2, [sp, #0x28]
+ mov r1, #0x1c
+ and r2, r1
+ str r2, [sp, #0x1c]
+ ldr r2, [sp, #0x24]
+ and r0, r2
+ ldr r2, [sp, #0x44]
+ mul r2, r0
+ ldr r0, [sp, #0x24]
+ str r2, [sp, #0x18]
+ and r0, r1
+ str r0, [sp, #0x14]
+_02018B26:
+ ldr r0, [sp, #0x4]
+ asr r2, r4, #0x1
+ mov r1, #0x3
+ ldr r0, [r0, #0x0]
+ and r1, r2
+ add r1, r0, r1
+ ldr r0, =0x00003FE0
+ and r0, r6
+ add r1, r1, r0
+ ldr r0, [sp, #0x18]
+ add r6, r6, #0x4
+ add r0, r1, r0
+ str r0, [sp, #0x64]
+ lsl r0, r4, #0x1f
+ lsr r2, r0, #0x1d
+ ldr r0, [sp, #0x0]
+ asr r1, r3, #0x1
+ ldr r7, [r0, #0x0]
+ mov r0, #0x3
+ and r0, r1
+ ldr r1, =0x00003FE0
+ add r4, r4, #0x1
+ and r1, r5
+ str r1, [sp, #0x54]
+ add r1, r7, r0
+ ldr r0, [sp, #0x54]
+ add r5, r5, #0x4
+ add r1, r0, r1
+ ldr r0, [sp, #0x20]
+ add r1, r0, r1
+ ldr r0, [sp, #0x1c]
+ ldrb r1, [r0, r1]
+ lsl r0, r3, #0x1f
+ lsr r0, r0, #0x1d
+ asr r1, r0
+ mov r0, #0xf
+ and r0, r1
+ add r7, r0, #0x0
+ ldr r1, [sp, #0x14]
+ ldr r0, [sp, #0x64]
+ lsl r7, r2
+ ldrb r0, [r0, r1]
+ add r3, r3, #0x1
+ str r0, [sp, #0x58]
+ mov r0, #0xf0
+ asr r0, r2
+ ldr r1, [sp, #0x58]
+ add r2, r7, #0x0
+ and r0, r1
+ orr r2, r0
+ ldr r1, [sp, #0x14]
+ ldr r0, [sp, #0x64]
+ strb r2, [r0, r1]
+ ldr r0, [sp, #0x50]
+ cmp r3, r0
+ blt _02018B26
+_02018B96:
+ ldr r0, [sp, #0x28]
+ add r0, r0, #0x4
+ str r0, [sp, #0x28]
+ ldr r0, [sp, #0xc]
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ ldr r0, [sp, #0x24]
+ ldr r1, [sp, #0xc]
+ add r0, r0, #0x4
+ str r0, [sp, #0x24]
+ ldr r0, [sp, #0x4c]
+ cmp r1, r0
+ blt _02018AEA
+ add sp, #0x68
+ pop {r3-r7, pc}
+_02018BB4:
+ ldr r2, [sp, #0xc]
+ ldr r1, [sp, #0x4c]
+ cmp r2, r1
+ bge _02018C92
+ cmp r2, r1
+ bge _02018C92
+ add r1, r2, #0x0
+ lsl r1, r1, #0x2
+ lsl r0, r0, #0x2
+ str r1, [sp, #0x40]
+ str r0, [sp, #0x3c]
+_02018BCA:
+ ldr r3, [sp, #0x8]
+ ldr r0, [sp, #0x50]
+ add r1, r3, #0x0
+ ldr r4, [sp, #0x10]
+ cmp r1, r0
+ bge _02018C78
+ cmp r1, r0
+ bge _02018C78
+ add r0, r3, #0x0
+ lsl r1, r0, #0x2
+ add r0, r4, #0x0
+ lsl r2, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x40]
+ ldr r6, [sp, #0x48]
+ and r5, r0
+ mul r6, r5
+ str r6, [sp, #0x34]
+ ldr r6, [sp, #0x40]
+ mov r5, #0x1c
+ and r6, r5
+ str r6, [sp, #0x30]
+ ldr r6, [sp, #0x3c]
+ and r0, r6
+ ldr r6, [sp, #0x44]
+ mul r6, r0
+ ldr r0, [sp, #0x3c]
+ str r6, [sp, #0x2c]
+ and r0, r5
+ str r0, [sp, #0x60]
+_02018C06:
+ ldr r0, [sp, #0x4]
+ asr r6, r4, #0x1
+ mov r5, #0x3
+ and r5, r6
+ ldr r0, [r0, #0x0]
+ asr r6, r3, #0x1
+ add r5, r0, r5
+ ldr r0, =0x00003FE0
+ and r0, r2
+ add r5, r5, r0
+ ldr r0, [sp, #0x2c]
+ add r5, r5, r0
+ ldr r0, [sp, #0x0]
+ ldr r7, [r0, #0x0]
+ mov r0, #0x3
+ and r0, r6
+ ldr r6, =0x00003FE0
+ and r6, r1
+ str r6, [sp, #0x5c]
+ add r6, r7, r0
+ ldr r0, [sp, #0x5c]
+ add r6, r0, r6
+ ldr r0, [sp, #0x34]
+ add r6, r0, r6
+ ldr r0, [sp, #0x30]
+ ldrb r6, [r0, r6]
+ lsl r0, r3, #0x1f
+ lsr r0, r0, #0x1d
+ asr r6, r0
+ mov r0, #0xf
+ and r0, r6
+ ldr r6, [sp, #0x38]
+ cmp r0, r6
+ beq _02018C6A
+ lsl r6, r4, #0x1f
+ lsr r7, r6, #0x1d
+ lsl r0, r7
+ mov lr, r0
+ ldr r0, [sp, #0x60]
+ ldrb r0, [r5, r0]
+ mov r12, r0
+ mov r0, #0xf0
+ add r6, r0, #0x0
+ asr r6, r7
+ mov r0, r12
+ and r0, r6
+ mov r6, lr
+ orr r6, r0
+ ldr r0, [sp, #0x60]
+ strb r6, [r5, r0]
+_02018C6A:
+ ldr r0, [sp, #0x50]
+ add r3, r3, #0x1
+ add r1, r1, #0x4
+ add r2, r2, #0x4
+ add r4, r4, #0x1
+ cmp r3, r0
+ blt _02018C06
+_02018C78:
+ ldr r0, [sp, #0x40]
+ add r0, r0, #0x4
+ str r0, [sp, #0x40]
+ ldr r0, [sp, #0xc]
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ ldr r0, [sp, #0x3c]
+ ldr r1, [sp, #0xc]
+ add r0, r0, #0x4
+ str r0, [sp, #0x3c]
+ ldr r0, [sp, #0x4c]
+ cmp r1, r0
+ blt _02018BCA
+_02018C92:
+ add sp, #0x68
+ pop {r3-r7, pc}
+ // clang-format on
+}
+#endif
+
+#ifdef NONMATCHING
+THUMB_FUNC void BlitBitmapRect8Bit(struct UnkStruct_02016B94_3 *param0,
+ struct UnkStruct_02016B94_3 *param1,
+ u16 param2,
+ u16 param3,
+ u16 param4,
+ u16 param5,
+ u16 param6,
+ u16 param7,
+ u16 param8)
+{
+ // horrible for loops like the one above
+}
+#else
+THUMB_FUNC asm void BlitBitmapRect8Bit(struct UnkStruct_02016B94_3 *param0,
+ struct UnkStruct_02016B94_3 *param1,
+ u16 param2,
+ u16 param3,
+ u16 param4,
+ u16 param5,
+ u16 param6,
+ u16 param7,
+ u16 param8)
+{
+ // clang-format off
+ push {r3-r7, lr}
+ sub sp, #0x50
+ str r2, [sp, #0x8]
+ str r3, [sp, #0xc]
+ add r2, sp, #0x58
+ str r0, [sp, #0x0]
+ ldrh r0, [r2, #0x10]
+ str r1, [sp, #0x4]
+ ldrh r2, [r2, #0x18]
+ str r0, [sp, #0x10]
+ add r0, r1, #0x0
+ ldrh r1, [r0, #0x4]
+ ldr r0, [sp, #0x10]
+ sub r3, r1, r0
+ cmp r3, r2
+ bge _02018CC6
+ ldr r0, [sp, #0x8]
+ add r0, r0, r3
+ b _02018CCA
+_02018CC6:
+ ldr r0, [sp, #0x8]
+ add r0, r2, r0
+_02018CCA:
+ ldr r2, [sp, #0x4]
+ add r3, sp, #0x58
+ mov r12, r0
+ ldrh r0, [r3, #0x14]
+ ldrh r2, [r2, #0x6]
+ ldrh r3, [r3, #0x1c]
+ sub r4, r2, r0
+ cmp r4, r3
+ bge _02018CE2
+ ldr r2, [sp, #0xc]
+ add r2, r2, r4
+ b _02018CE6
+_02018CE2:
+ ldr r2, [sp, #0xc]
+ add r2, r3, r2
+_02018CE6:
+ mov lr, r2
+ ldr r2, [sp, #0x0]
+ mov r3, #0x7
+ ldrh r4, [r2, #0x4]
+ add r2, r4, #0x0
+ and r2, r3
+ add r2, r4, r2
+ asr r2, r2, #0x3
+ str r2, [sp, #0x4c]
+ add r2, r1, #0x0
+ and r2, r3
+ add r1, r1, r2
+ asr r1, r1, #0x3
+ str r1, [sp, #0x48]
+ add r1, sp, #0x58
+ ldrh r1, [r1, #0x20]
+ ldr r2, =0x0000FFFF
+ str r1, [sp, #0x3c]
+ cmp r1, r2
+ bne _02018DC6
+ ldr r2, [sp, #0xc]
+ mov r1, lr
+ cmp r2, r1
+ bge _02018D1C
+ mov r1, lr
+ cmp r2, r1
+ blt _02018D1E
+_02018D1C:
+ b _02018E7C
+_02018D1E:
+ add r1, r2, #0x0
+ lsl r1, r1, #0x3
+ lsl r0, r0, #0x3
+ str r1, [sp, #0x28]
+ str r0, [sp, #0x24]
+_02018D28:
+ ldr r1, [sp, #0x8]
+ mov r0, r12
+ add r2, r1, #0x0
+ ldr r7, [sp, #0x10]
+ cmp r2, r0
+ bge _02018DA8
+ mov r0, r12
+ cmp r2, r0
+ bge _02018DA8
+ add r0, r1, #0x0
+ lsl r2, r0, #0x3
+ add r0, r7, #0x0
+ lsl r3, r0, #0x3
+ ldr r6, =0x00007FC0
+ ldr r0, [sp, #0x28]
+ ldr r4, [sp, #0x4c]
+ and r0, r6
+ mul r4, r0
+ str r4, [sp, #0x20]
+ ldr r0, [sp, #0x28]
+ mov r5, #0x38
+ and r0, r5
+ str r0, [sp, #0x1c]
+ ldr r0, [sp, #0x24]
+ ldr r4, [sp, #0x48]
+ and r0, r6
+ mul r4, r0
+ ldr r0, [sp, #0x24]
+ str r4, [sp, #0x18]
+ and r0, r5
+ str r0, [sp, #0x14]
+_02018D66:
+ ldr r0, [sp, #0x0]
+ add r5, r1, #0x0
+ mov r4, #0x7
+ and r5, r4
+ ldr r0, [r0, #0x0]
+ ldr r4, =0x00007FC0
+ add r0, r0, r5
+ and r4, r2
+ add r4, r4, r0
+ ldr r0, [sp, #0x20]
+ add r5, r7, #0x0
+ add r4, r0, r4
+ ldr r0, [sp, #0x1c]
+ add r1, r1, #0x1
+ ldrb r6, [r0, r4]
+ ldr r0, [sp, #0x4]
+ mov r4, #0x7
+ and r5, r4
+ ldr r0, [r0, #0x0]
+ ldr r4, =0x00007FC0
+ add r0, r0, r5
+ and r4, r3
+ add r4, r4, r0
+ ldr r0, [sp, #0x18]
+ add r2, #0x8
+ add r4, r0, r4
+ ldr r0, [sp, #0x14]
+ add r3, #0x8
+ strb r6, [r0, r4]
+ mov r0, r12
+ add r7, r7, #0x1
+ cmp r1, r0
+ blt _02018D66
+_02018DA8:
+ ldr r0, [sp, #0x28]
+ add r0, #0x8
+ str r0, [sp, #0x28]
+ ldr r0, [sp, #0xc]
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ ldr r0, [sp, #0x24]
+ ldr r1, [sp, #0xc]
+ add r0, #0x8
+ str r0, [sp, #0x24]
+ mov r0, lr
+ cmp r1, r0
+ blt _02018D28
+ add sp, #0x50
+ pop {r3-r7, pc}
+_02018DC6:
+ ldr r2, [sp, #0xc]
+ mov r1, lr
+ cmp r2, r1
+ bge _02018E7C
+ mov r1, lr
+ cmp r2, r1
+ bge _02018E7C
+ add r1, r2, #0x0
+ lsl r1, r1, #0x3
+ lsl r0, r0, #0x3
+ str r1, [sp, #0x44]
+ str r0, [sp, #0x40]
+_02018DDE:
+ ldr r2, [sp, #0x8]
+ mov r0, r12
+ add r1, r2, #0x0
+ ldr r3, [sp, #0x10]
+ cmp r1, r0
+ bge _02018E62
+ mov r0, r12
+ cmp r1, r0
+ bge _02018E62
+ add r0, r2, #0x0
+ lsl r6, r0, #0x3
+ add r0, r3, #0x0
+ lsl r1, r0, #0x3
+ ldr r7, =0x00007FC0
+ ldr r0, [sp, #0x44]
+ ldr r4, [sp, #0x4c]
+ and r0, r7
+ mul r4, r0
+ str r4, [sp, #0x38]
+ ldr r0, [sp, #0x44]
+ mov r5, #0x38
+ and r0, r5
+ str r0, [sp, #0x34]
+ ldr r0, [sp, #0x40]
+ ldr r4, [sp, #0x48]
+ and r0, r7
+ mul r4, r0
+ ldr r0, [sp, #0x40]
+ str r4, [sp, #0x30]
+ and r0, r5
+ str r0, [sp, #0x2c]
+_02018E1C:
+ ldr r0, [sp, #0x4]
+ mov r4, #0x7
+ ldr r0, [r0, #0x0]
+ and r4, r3
+ add r0, r0, r4
+ ldr r4, =0x00007FC0
+ add r5, r2, #0x0
+ and r4, r1
+ add r4, r0, r4
+ ldr r0, [sp, #0x30]
+ add r7, r4, r0
+ ldr r0, [sp, #0x0]
+ mov r4, #0x7
+ and r5, r4
+ ldr r0, [r0, #0x0]
+ ldr r4, =0x00007FC0
+ add r0, r0, r5
+ and r4, r6
+ add r4, r4, r0
+ ldr r0, [sp, #0x38]
+ add r4, r0, r4
+ ldr r0, [sp, #0x34]
+ ldrb r0, [r0, r4]
+ ldr r4, [sp, #0x3c]
+ cmp r0, r4
+ beq _02018E54
+ ldr r4, [sp, #0x2c]
+ strb r0, [r7, r4]
+_02018E54:
+ add r2, r2, #0x1
+ mov r0, r12
+ add r6, #0x8
+ add r1, #0x8
+ add r3, r3, #0x1
+ cmp r2, r0
+ blt _02018E1C
+_02018E62:
+ ldr r0, [sp, #0x44]
+ add r0, #0x8
+ str r0, [sp, #0x44]
+ ldr r0, [sp, #0xc]
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ ldr r0, [sp, #0x40]
+ ldr r1, [sp, #0xc]
+ add r0, #0x8
+ str r0, [sp, #0x40]
+ mov r0, lr
+ cmp r1, r0
+ blt _02018DDE
+_02018E7C:
+ add sp, #0x50
+ pop {r3-r7, pc}
+ // clang-format on
+}
+#endif
+
+THUMB_FUNC void FUN_02018E88(
+ struct UnkStruct_02016B94_3 *param0, u16 param1, u16 param2, u16 param3, u16 param4, u8 param5)
+{
+
+ int r6 = param1 + param3;
+ if (r6 > param0->unk04)
+ {
+ r6 = param0->unk04;
+ }
+
+ int r12 = param2 + param4;
+ if (r12 > param0->unk06)
+ {
+ r12 = param0->unk06;
+ }
+
+ int lr = (((param0->unk04) + (param0->unk04 & 7)) >> 3);
+
+ for (int i = param2; i < r12; i++)
+ {
+
+ for (int j = param1; j < r6; j++)
+ {
+
+ u8 *unk = (u8 *)((u8 *)param0->unk00 + ((j >> 1) & 3) + ((j << 2) & 0x3fe0) +
+ (((i << 2) & 0x3fe0) * lr) + ((i << 2) & 0x1c));
+
+ if ((j & 1) != 0)
+ {
+ *unk &= 0xf;
+ *unk |= (param5 << 4);
+ }
+ else
+ {
+ *unk &= 0xf0;
+ *unk |= param5;
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02018F4C(
+ struct UnkStruct_02016B94_3 *param0, u16 param1, u16 param2, u16 param3, u16 param4, u8 param5)
+{
+
+ int r6 = param1 + param3;
+ if (r6 > param0->unk04)
+ {
+ r6 = param0->unk04;
+ }
+
+ int r12 = param2 + param4;
+ if (r12 > param0->unk06)
+ {
+ r12 = param0->unk06;
+ }
+
+ int lr = (((param0->unk04) + (param0->unk04 & 7)) >> 3);
+
+ for (int i = param2; i < r12; i++)
+ {
+
+ for (int j = param1; j < r6; j++)
+ {
+
+ u8 *unk = (u8 *)((u8 *)param0->unk00 + (j & 7) + ((j << 3) & 0x7fc0) +
+ (((i << 3) & 0x7fc0) * lr) + ((i << 3) & 0x38));
+
+ *unk = param5;
+ }
+ }
+}
+
+THUMB_FUNC void *AllocWindows(u32 heap_id, s32 size)
+{
+ struct Window *ptr = AllocFromHeap(heap_id, (u32)(size << 4));
+
+ for (u16 i = 0; i < size; i++)
+ {
+ InitWindow(&ptr[i]);
+ }
+
+ return ptr;
+}
+
+THUMB_FUNC void InitWindow(struct Window *param0)
+{
+ param0->unk00 = 0;
+ param0->unk04 = 0xff;
+ param0->unk05 = 0;
+ param0->unk06 = 0;
+ param0->width = 0;
+ param0->height = 0;
+ param0->unk09 = 0;
+
+ param0->unk0a_0 = 0;
+ param0->unk0c = 0;
+
+ param0->unk0b_15 = 0;
+}
+
+THUMB_FUNC BOOL FUN_02019048(struct Window *param0)
+{
+ if (param0->unk00 == 0 || param0->unk04 == 0xff || param0->unk0c == 0)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+enum UnkEnum1
+{
+ UnkEnum1_0 = 0,
+ UnkEnum1_1 = 1
+};
+
+THUMB_FUNC void FUN_02019064(struct UnkStruct_02016B94_2 *param0,
+ struct Window *param1,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u8 param5,
+ u8 param6,
+ u8 param7,
+ u16 param8)
+{
+ if (param0->unk08[param2].unk08 == NULL)
+ {
+ return;
+ }
+
+ void *ptr = AllocFromHeap(param0->unk00, (u32)(param5 * param6 * param0->unk08[param2].unk1f));
+
+ if (ptr == NULL)
+ {
+ return;
+ }
+ param1->unk00 = param0;
+ param1->unk04 = param2;
+ param1->unk05 = param3;
+ param1->unk06 = param4;
+ param1->width = param5;
+ param1->height = param6;
+ param1->unk09 = param7;
+
+ param1->unk0a_0 = param8;
+ param1->unk0c = ptr;
+
+ enum UnkEnum1 r2;
+ if (param0->unk08[param2].unk1e == 0)
+ {
+ r2 = UnkEnum1_0;
+ }
+ else
+ {
+ r2 = UnkEnum1_1;
+ }
+
+ param1->unk0b_15 = r2;
+}
+
+THUMB_FUNC void FUN_020190EC(struct UnkStruct_02016B94_2 *param0,
+ struct Window *param1,
+ u8 param2,
+ u8 param3,
+ u16 param4,
+ u8 param5)
+{
+ u32 size = (u32)(param2 * param3 * 32);
+
+ void *ptr = AllocFromHeap(param0->unk00, size);
+
+ param5 |= (param5 * 16);
+ memset(ptr, param5, size);
+
+ if (ptr != NULL)
+ {
+ param1->unk00 = param0;
+ param1->width = param2;
+ param1->height = param3;
+ param1->unk0a_0 = param4;
+ param1->unk0c = ptr;
+ param1->unk0b_15 = 0;
+ }
+}
+
+THUMB_FUNC void FUN_02019150(
+ struct UnkStruct_02016B94_2 *param0, struct Window *param1, struct UnkStruct_02016B94_4 *param2)
+{
+
+ FUN_02019064(param0,
+ param1,
+ param2->unk0,
+ param2->unk1,
+ param2->unk2,
+ param2->unk3,
+ param2->unk4,
+ param2->unk5,
+ param2->unk6);
+}
+
+THUMB_FUNC void FUN_02019178(struct Window *param0)
+{
+ FreeToHeap(param0->unk0c);
+
+ param0->unk00 = 0;
+ param0->unk04 = 0xff;
+ param0->unk05 = 0;
+ param0->unk06 = 0;
+ param0->width = 0;
+ param0->height = 0;
+ param0->unk09 = 0;
+ param0->unk0a_0 = 0;
+ param0->unk0c = 0;
+}
+
+THUMB_FUNC void FUN_020191A4(struct Window *param0, int param1)
+{
+ for (u16 i = 0; i < param1; i++)
+ {
+ if (param0[i].unk0c != NULL)
+ {
+ FreeToHeap(param0[i].unk0c);
+ }
+ }
+
+ FreeToHeap(param0);
+}
+
+THUMB_FUNC void CopyWindowToVram(struct Window *param0)
+{
+
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk00);
+ GF_ASSERT(param0->unk04 < 8);
+ GF_ASSERT(param0->unk00->unk08[param0->unk04].unk1c < 3);
+
+ UNK_020EDB68[param0->unk00->unk08[param0->unk04].unk1c](param0);
+}
+
+THUMB_FUNC void FUN_02019220(struct Window *param0)
+{
+
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk00);
+ GF_ASSERT(param0->unk04 < 8);
+ GF_ASSERT(param0->unk00->unk08[param0->unk04].unk1c < 3);
+
+ UNK_020EDB5C[param0->unk00->unk08[param0->unk04].unk1c](param0);
+}
+
+THUMB_FUNC void FUN_02019270(struct Window *param0)
+{
+ UNK_020EDB38[param0->unk00->unk08[param0->unk04].unk1c](param0);
+}
+
+THUMB_FUNC void FUN_0201928C(struct Window *param0, u8 param1, u8 param2)
+{
+ u8 unk07 = param0->width;
+ u8 unk08 = param0->height;
+
+ param0->width = param1;
+ param0->height = param2;
+ UNK_020EDB38[param0->unk00->unk08[param0->unk04].unk1c](param0);
+
+ param0->width = unk07;
+ param0->height = unk08;
+}
+
+THUMB_FUNC void FUN_020192B8(struct Window *param0)
+{
+ UNK_020EDB74[param0->unk00->unk08[param0->unk04].unk1c](param0);
+}
+
+THUMB_FUNC void FUN_020192D4(struct Window *param0)
+{
+ u32 i, j;
+ u32 r3;
+ u32 iCount, jCount;
+ u16 *st4 = param0->unk00->unk08[param0->unk04].unk08;
+
+ if (st4 == NULL)
+ {
+ return;
+ }
+
+ r3 = param0->unk0a_0;
+ jCount = (u32)(param0->unk05 + param0->width);
+ iCount = (u32)(param0->unk06 + param0->height);
+
+ for (i = param0->unk06; i < iCount; i++)
+ {
+ for (j = param0->unk05; j < jCount; j++)
+ {
+ st4[((i & 0x20) * 32) + ((j & 0x20) * 32) + ((i & 0x1f) << 5) + (j & 0x1f)] =
+ (u16)(r3 | (param0->unk09 << 12));
+
+ r3++;
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02019358(struct Window *param0)
+{
+ int j, i;
+ u8 *r4;
+
+ int r5;
+ int r6;
+
+ if (param0->unk00->unk08[param0->unk04].unk08 == NULL)
+ {
+ return;
+ }
+
+ r6 = UNK_020EDB30[param0->unk00->unk08[param0->unk04].unk1d];
+
+ r4 = param0->unk00->unk08[param0->unk04].unk08 + param0->unk06 * r6 + param0->unk05;
+ r5 = param0->unk0a_0;
+
+ for (i = 0; i < param0->height; i++)
+ {
+ for (j = 0; j < param0->width; j++)
+ {
+ r4[j] = (u8)r5;
+ r5++;
+ }
+ r4 += r6;
+ }
+}
+
+THUMB_FUNC void FUN_020193B4(struct Window *param0)
+{
+
+ u32 i, j;
+
+ u32 iCount, jCount;
+ u32 st8;
+
+ u16 *st4;
+
+ if (param0->unk00->unk08[param0->unk04].unk08 == NULL)
+ {
+ return;
+ }
+ st4 = param0->unk00->unk08[param0->unk04].unk08;
+
+ st8 = UNK_020EDB30[param0->unk00->unk08[param0->unk04].unk1d];
+ jCount = (u32)(param0->unk05 + param0->width);
+ iCount = (u32)(param0->unk06 + param0->height);
+
+ for (i = param0->unk06; i < iCount; i++)
+ {
+ for (j = param0->unk05; j < jCount; j++)
+ {
+ st4[((i & 0x20) * 32) + ((j & 0x20) * 32) + ((i & 0x1f) * st8) + (j & 0x1f)] = 0;
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02019444(struct Window *param0)
+{
+
+ int j, i;
+ u8 *r5;
+
+ int r6;
+
+ if (param0->unk00->unk08[param0->unk04].unk08 == NULL)
+ {
+ return;
+ }
+
+ r6 = UNK_020EDB30[param0->unk00->unk08[param0->unk04].unk1d];
+ r5 = param0->unk00->unk08[param0->unk04].unk08 + param0->unk06 * r6 + param0->unk05;
+
+ for (i = 0; i < param0->height; i++)
+ {
+ for (j = 0; j < param0->width; j++)
+ {
+ r5[j] = 0;
+ }
+ r5 += r6;
+ }
+}
+
+THUMB_FUNC void FUN_0201949C(struct Window *window)
+{
+ FUN_020192D4(window);
+ FUN_02019548(window);
+ FUN_02017CE8(window->unk00,
+ window->unk04,
+ window->unk00->unk08[window->unk04].unk08,
+ window->unk00->unk08[window->unk04].unk0c,
+ window->unk00->unk08[window->unk04].unk10);
+}
+
+THUMB_FUNC void FUN_020194C8(struct Window *window)
+{
+ FUN_020192D4(window);
+ FUN_0201AC68(window->unk00, window->unk04);
+ FUN_02019548(window);
+}
+
+THUMB_FUNC void FUN_020194E0(struct Window *window)
+{
+ FUN_02019358(window);
+ FUN_02017CE8(window->unk00,
+ window->unk04,
+ window->unk00->unk08[window->unk04].unk08,
+ window->unk00->unk08[window->unk04].unk0c,
+ window->unk00->unk08[window->unk04].unk10);
+
+ FUN_02017E14(window->unk00,
+ window->unk04,
+ window->unk0c,
+ (u32)(window->width * window->height * 64),
+ window->unk0a_0);
+}
+
+THUMB_FUNC void FUN_0201951C(struct Window *window)
+{
+ FUN_02019358(window);
+ FUN_0201AC68(window->unk00, window->unk04);
+ FUN_02017E14(window->unk00,
+ window->unk04,
+ window->unk0c,
+ (u32)(window->width * window->height * 64),
+ window->unk0a_0);
+}
+
+THUMB_FUNC void FUN_02019548(struct Window *window)
+{
+ FUN_02017E14(window->unk00,
+ window->unk04,
+ window->unk0c,
+ (u32)(window->width * window->height * window->unk00->unk08[window->unk04].unk1f),
+ window->unk0a_0);
+}
+
+THUMB_FUNC void FUN_02019570(struct Window *window)
+{
+ UNK_020EDB50[window->unk00->unk08[window->unk04].unk1c](window);
+}
+
+THUMB_FUNC void FUN_0201958C(struct Window *window)
+{
+ UNK_020EDB44[window->unk00->unk08[window->unk04].unk1c](window);
+}
+
+THUMB_FUNC void FUN_020195A8(struct Window *window)
+{
+ FUN_020193B4(window);
+ FUN_02017CE8(window->unk00,
+ window->unk04,
+ window->unk00->unk08[window->unk04].unk08,
+ window->unk00->unk08[window->unk04].unk0c,
+ window->unk00->unk08[window->unk04].unk10);
+}
+
+THUMB_FUNC void FUN_020195D0(struct Window *window)
+{
+ FUN_020193B4(window);
+ FUN_0201AC68(window->unk00, window->unk04);
+}
+
+THUMB_FUNC void FUN_020195E4(struct Window *window)
+{
+ FUN_02019444(window);
+ FUN_02017CE8(window->unk00,
+ window->unk04,
+ window->unk00->unk08[window->unk04].unk08,
+ window->unk00->unk08[window->unk04].unk0c,
+ window->unk00->unk08[window->unk04].unk10);
+}
+
+THUMB_FUNC void FUN_0201960C(struct Window *window)
+{
+ FUN_02019444(window);
+ FUN_0201AC68(window->unk00, window->unk04);
+}
+
+THUMB_FUNC void FillWindowPixelBuffer(struct Window *window, u8 param1)
+{
+ if (window->unk00->unk08[window->unk04].unk1f == 0x20)
+ {
+ param1 |= param1 << 4;
+ }
+
+ MI_CpuFillFast(
+ window->unk0c,
+ (u32)((param1 << 0x18) | (param1 << 0x10) | (param1 << 0x8) | param1),
+ (u32)(window->unk00->unk08[window->unk04].unk1f * window->width * window->height));
+}
+
+THUMB_FUNC void BlitBitmapRectToWindow(struct Window *window,
+ const void *src,
+ u16 srcX,
+ u16 srcY,
+ u16 srcWidth,
+ u16 srcHeight,
+ u16 dstX,
+ u16 dstY,
+ u16 dstWidth,
+ u16 dstHeight)
+{
+ BlitBitmapRect(
+ window, src, srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, 0);
+}
+
+THUMB_FUNC void BlitBitmapRect(struct Window *window,
+ void *param1,
+ u16 param2,
+ u16 param3,
+ u16 param4,
+ u16 param5,
+ u16 param6,
+ u16 param7,
+ u16 param8,
+ u16 param9,
+ u16 param10)
+{
+ struct UnkStruct_02016B94_3 st1c = { param1, param4, param5 };
+ struct UnkStruct_02016B94_3 st14 = {
+ window->unk0c, (u16)(window->width << 3), (u16)(window->height << 3)
+ };
+
+ if (window->unk00->unk08[window->unk04].unk1e == 0)
+ {
+ BlitBitmapRect4Bit(&st1c, &st14, param2, param3, param6, param7, param8, param9, param10);
+ }
+ else
+ {
+ BlitBitmapRect8Bit(&st1c, &st14, param2, param3, param6, param7, param8, param9, param10);
+ }
+}
+
+THUMB_FUNC void FillWindowPixelRect(
+ struct Window *window, u8 fillValue, u16 x, u16 y, u16 width, u16 height)
+{
+ struct UnkStruct_02016B94_3 st8 = {
+ window->unk0c, (u16)(window->width << 3), (u16)(window->height << 3)
+ };
+
+ if (window->unk00->unk08[window->unk04].unk1e == 0)
+ {
+ FUN_02018E88(&st8, x, y, width, height, fillValue);
+ }
+ else
+ {
+ FUN_02018F4C(&st8, x, y, width, height, fillValue);
+ }
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC void FUN_0201974C(
+ struct Window *window, u32 *param1, u32 param2, u32 param3, u16 param4, u16 param5, u32 param6)
+{
+ u32 str330 = param6;
+ u32 *st0 = param1;
+ u16 st5c = param4;
+
+ void *st278 = window->unk0c;
+ u16 st58 = window->width << 3;
+
+ int st8 = st58 - st5c;
+
+ if (st8 >= param2)
+ {
+ st8 = param2;
+ }
+
+ int st4 = (u16)(window->height << 3) - param5;
+ u16 st48 = param5;
+
+ if (st4 >= param3)
+ {
+ st4 = param3;
+ }
+
+ u8 r4 = 0;
+ if (st8 > 8)
+ {
+ r4 |= 1;
+ }
+
+ if (st4 > 8)
+ {
+ r4 |= 2;
+ }
+
+ if (window->unk0b_15 == 0)
+ {
+ switch (r4)
+ {
+ case 0:
+ u8 st70 = param6;
+ for (u32 st274 = 0; st274 < st4; st274++)
+ {
+ u32 st6c = (st58 + (st58 & 7)) >> 3;
+
+ u32 st26c = st0[0];
+ u8 st270 = (u8)((st70 >> st274) & 1);
+ u32 r2 = st5c;
+
+ for (u32 r1 = 0; r1 < st8; r1++)
+ {
+ u32 r3 = st5c << 2;
+ u32 st68 = ((st48 << 2) & 0x3fe0) * st6c;
+ u32 r7 = (st48 << 2) & 0x1c;
+ u32 st64 = (((st48 + 1) << 2) & 0x3fe0) * st6c;
+ u32 st60 = ((st48 + 1) << 2) & 0x1c;
+ u32 r4 = r1;
+
+ void *st27c = st278 + ((r2 >> 1) & 3) + (r3 & 0x3fe0);
+ u8 *r0 = st27c + st68;
+
+ u8 r5 = (u8)((st26c >> r4) & 0xf);
+ if (r5 != 0)
+ {
+ u32 st280 = (r5 << ((r2 & 1) << 2));
+ u32 st284 = r0[r7];
+
+ u8 r5 = ((0xf0 >> ((r2 & 1) << 2)) & st284) | st280;
+ r0[r7] = r5;
+
+ if (st270 != 0)
+ {
+ *(u8 *)(st27c + st64 + st60) = r5;
+ }
+ }
+
+ r4 += 4;
+ r3 += 4;
+ r2 += 1;
+ }
+
+ if (st270 != 0)
+ {
+ st48 += 2;
+ }
+ else
+ {
+ st48++;
+ }
+
+ st0++;
+ }
+
+ break;
+
+ case 1:
+ u32 *st25c = st0;
+ u32 st264 = st48;
+ u8 st54 = param6;
+ u8 st84 = param6;
+
+ for (u32 st268 = 0; st268 < st4; st268++)
+ {
+ u32 st80 = (st58 + (st58 & 7)) >> 3;
+
+ u32 st258 = *st25c;
+ u32 r2 = st5c;
+ u8 st260 = (st84 >> st268) & 1;
+ u32 r3 = st5c << 2;
+ u32 st7c = ((st264 << 2) & 0x3fe0) * st80;
+ u32 r7 = (st264 << 2) & 0x1c;
+ u32 st78 = (((st264 + 1) << 2) & 0x3fe0) * st80;
+ u32 st74 = ((st264 + 1) << 2) & 0x1c;
+ u32 r4 = 0;
+
+ for (u32 r1 = 0; r1 < 8; r1++)
+ {
+ void *st288 = st278 + ((r2 >> 1) & 3) + (r3 & 0x3fe0);
+ u8 *r0 = st288 + st7c;
+ u8 r5 = (st258 >> r4) & 0xf;
+ if (r5 != 0)
+ {
+ u32 st28c = r5 << ((r2 & 1) << 2);
+ u32 st290 = r0[r7];
+ u8 r5 = ((0xf0 >> ((r2 & 1) << 2)) & st290) | st28c;
+ r0[r7] = r5;
+
+ if (st260 != 0)
+ {
+ *(u8 *)(st288 + st78 + st74) = r5;
+ }
+ }
+
+ r4 += 4;
+ r3 += 4;
+ r2++;
+ }
+
+ if (st260 != 0)
+ {
+ st264 += 2;
+ }
+ else
+ {
+ st264++;
+ }
+
+ st25c++;
+ }
+
+ st0 += 0x20;
+ u8 st98 = st54;
+
+ for (u32 st254 = 0; st254 < st4; st254++)
+ {
+ st5c += 8;
+ u32 st94 = (st58 + (st58 & 7)) >> 3;
+
+ //_02019A00
+ }
+
+ break;
+
+ case 2:
+ // TODO
+ break;
+ case 3:
+ // TODO
+ break;
+ }
+ }
+ else
+ {
+ // TODO: FUN_0201A12C
+ }
+}
+#else
+asm void FUN_0201974C(
+ struct Window *window, u32 *param1, u32 param2, u32 param3, u16 param4, u16 param5, u32 param6)
+{
+ // clang-format off
+ push {r4-r7, lr}
+ sub sp, #0x1fc
+ sub sp, #0x118
+ add r5, r0, #0x0
+ ldr r0, [sp, #0x330]
+ str r1, [sp, #0x0]
+ str r0, [sp, #0x330]
+ add r1, sp, #0x318
+ ldrh r1, [r1, #0x10]
+ ldr r0, [r5, #0xc]
+ str r1, [sp, #0x5c]
+ ldrb r1, [r5, #0x7]
+ str r0, [sp, #0x278]
+ ldrb r0, [r5, #0x8]
+ lsl r1, r1, #0x13
+ lsr r4, r1, #0x10
+ ldr r1, [sp, #0x5c]
+ lsl r0, r0, #0x13
+ sub r1, r4, r1
+ lsr r0, r0, #0x10
+ str r4, [sp, #0x58]
+ str r1, [sp, #0x8]
+ cmp r1, r2
+ blt _0201977E
+ str r2, [sp, #0x8]
+_0201977E:
+ add r1, sp, #0x318
+ ldrh r1, [r1, #0x14]
+ sub r0, r0, r1
+ str r1, [sp, #0x48]
+ str r0, [sp, #0x4]
+ cmp r0, r3
+ blt _0201978E
+ str r3, [sp, #0x4]
+_0201978E:
+ ldr r0, [sp, #0x8]
+ mov r4, #0x0
+ cmp r0, #0x8
+ ble _0201979E
+ mov r0, #0x1
+ orr r0, r4
+ lsl r0, r0, #0x18
+ lsr r4, r0, #0x18
+_0201979E:
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x8
+ ble _020197AC
+ mov r0, #0x2
+ orr r0, r4
+ lsl r0, r0, #0x18
+ lsr r4, r0, #0x18
+_020197AC:
+ ldrh r0, [r5, #0xa]
+ lsl r0, r0, #0x10
+ lsr r0, r0, #0x1f
+ beq _020197B8
+ bl FUN_0201A12C
+_020197B8:
+ cmp r4, #0x3
+ bls _020197C0
+ bl FUN_0201A8BC
+_020197C0:
+ add r0, r4, r4
+ add r0, pc
+ ldrh r0, [r0, #0x6]
+ lsl r0, r0, #0x10
+ asr r0, r0, #0x10
+ add pc, r0
+_020197CC:
+ lsl r6, r0, #0
+ lsl r0, r1, #4
+ lsl r0, r3, #12
+ lsl r0, r7, #20
+ // jump table (using 16-bit offset)
+ // .short _020197D4 - _020197CC - 2; case 0
+ // .short _020198D6 - _020197CC - 2; case 1
+ // .short _02019AE6 - _020197CC - 2; case 2
+ // .short _02019D06 - _020197CC - 2; case 3
+_020197D4:
+ ldr r0, [sp, #0x330]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x70]
+ mov r0, #0x0
+ str r0, [sp, #0x274]
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x0
+ bgt _020197EA
+ bl FUN_0201A8BC
+_020197EA:
+ ldr r0, [sp, #0x58]
+ mov r1, #0x7
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x6c]
+_020197F6:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0x70]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x26c]
+ ldr r0, [sp, #0x274]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x270]
+ ldr r0, [sp, #0x8]
+ mov r1, #0x0
+ cmp r0, #0x0
+ ble _020198AA
+ ble _020198AA
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x48]
+ ldr r6, [sp, #0x6c]
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x48]
+ str r6, [sp, #0x68]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x6c]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0x64]
+ str r0, [sp, #0x60]
+_02019848:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0x68]
+ str r5, [sp, #0x27c]
+ add r0, r5, r0
+ ldr r5, [sp, #0x26c]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _0201989C
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x280]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x284]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x284]
+ and r6, r5
+ ldr r5, [sp, #0x280]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x270]
+ cmp r0, #0x0
+ beq _0201989C
+ ldr r6, [sp, #0x27c]
+ ldr r0, [sp, #0x64]
+ add r6, r6, r0
+ ldr r0, [sp, #0x60]
+ strb r5, [r0, r6]
+_0201989C:
+ ldr r0, [sp, #0x8]
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, r0
+ blt _02019848
+_020198AA:
+ ldr r0, [sp, #0x270]
+ cmp r0, #0x0
+ beq _020198B8
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _020198BE
+_020198B8:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_020198BE:
+ ldr r0, [sp, #0x0]
+ add r0, r0, #0x4
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x274]
+ add r1, r0, #0x1
+ ldr r0, [sp, #0x4]
+ str r1, [sp, #0x274]
+ cmp r1, r0
+ blt _020197F6
+ add sp, #0x1fc
+ add sp, #0x118
+ pop {r4-r7, pc}
+_020198D6:
+ ldr r0, [sp, #0x0]
+ str r0, [sp, #0x25c]
+ ldr r0, [sp, #0x48]
+ str r0, [sp, #0x264]
+ ldr r0, [sp, #0x330]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x54]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x84]
+ mov r0, #0x0
+ str r0, [sp, #0x268]
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x0
+ ble _020199D2
+ ldr r0, [sp, #0x58]
+ mov r1, #0x7
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x80]
+_02019902:
+ ldr r0, [sp, #0x25c]
+ ldr r1, [sp, #0x84]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x258]
+ ldr r0, [sp, #0x268]
+ ldr r6, [sp, #0x80]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x260]
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x264]
+ mov r1, #0x0
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x264]
+ str r6, [sp, #0x7c]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x80]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0x78]
+ str r0, [sp, #0x74]
+_0201994C:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0x7c]
+ str r5, [sp, #0x288]
+ add r0, r5, r0
+ ldr r5, [sp, #0x258]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _020199A0
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x28c]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x290]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x290]
+ and r6, r5
+ ldr r5, [sp, #0x28c]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x260]
+ cmp r0, #0x0
+ beq _020199A0
+ ldr r6, [sp, #0x288]
+ ldr r0, [sp, #0x78]
+ add r6, r6, r0
+ ldr r0, [sp, #0x74]
+ strb r5, [r0, r6]
+_020199A0:
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, #0x8
+ blt _0201994C
+ ldr r0, [sp, #0x260]
+ cmp r0, #0x0
+ beq _020199BA
+ ldr r0, [sp, #0x264]
+ add r0, r0, #0x2
+ str r0, [sp, #0x264]
+ b _020199C0
+_020199BA:
+ ldr r0, [sp, #0x264]
+ add r0, r0, #0x1
+ str r0, [sp, #0x264]
+_020199C0:
+ ldr r0, [sp, #0x25c]
+ add r0, r0, #0x4
+ str r0, [sp, #0x25c]
+ ldr r0, [sp, #0x268]
+ add r1, r0, #0x1
+ ldr r0, [sp, #0x4]
+ str r1, [sp, #0x268]
+ cmp r1, r0
+ blt _02019902
+_020199D2:
+ ldr r0, [sp, #0x0]
+ add r0, #0x20
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x54]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x98]
+ mov r0, #0x0
+ str r0, [sp, #0x254]
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x0
+ bgt _020199EE
+ bl FUN_0201A8BC
+_020199EE:
+ ldr r0, [sp, #0x5c]
+ mov r1, #0x7
+ add r0, #0x8
+ str r0, [sp, #0x5c]
+ ldr r0, [sp, #0x58]
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x94]
+_02019A00:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0x98]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x24c]
+ ldr r0, [sp, #0x254]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x250]
+ ldr r0, [sp, #0x8]
+ mov r1, #0x0
+ str r0, [sp, #0x294]
+ sub r0, #0x8
+ str r0, [sp, #0x294]
+ cmp r0, #0x0
+ ble _02019ABA
+ ble _02019ABA
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x48]
+ ldr r6, [sp, #0x94]
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x48]
+ str r6, [sp, #0x90]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x94]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0x8c]
+ str r0, [sp, #0x88]
+_02019A58:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0x90]
+ str r5, [sp, #0x298]
+ add r0, r5, r0
+ ldr r5, [sp, #0x24c]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _02019AAC
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x29c]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x2a0]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x2a0]
+ and r6, r5
+ ldr r5, [sp, #0x29c]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x250]
+ cmp r0, #0x0
+ beq _02019AAC
+ ldr r6, [sp, #0x298]
+ ldr r0, [sp, #0x8c]
+ add r6, r6, r0
+ ldr r0, [sp, #0x88]
+ strb r5, [r0, r6]
+_02019AAC:
+ ldr r0, [sp, #0x294]
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, r0
+ blt _02019A58
+_02019ABA:
+ ldr r0, [sp, #0x250]
+ cmp r0, #0x0
+ beq _02019AC8
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _02019ACE
+_02019AC8:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_02019ACE:
+ ldr r0, [sp, #0x0]
+ add r0, r0, #0x4
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x254]
+ add r1, r0, #0x1
+ ldr r0, [sp, #0x4]
+ str r1, [sp, #0x254]
+ cmp r1, r0
+ blt _02019A00
+ add sp, #0x1fc
+ add sp, #0x118
+ pop {r4-r7, pc}
+_02019AE6:
+ ldr r0, [sp, #0x0]
+ mov r1, #0x7
+ str r0, [sp, #0x23c]
+ ldr r0, [sp, #0x48]
+ str r0, [sp, #0x244]
+ mov r0, #0x0
+ str r0, [sp, #0x248]
+ ldr r0, [sp, #0x330]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0xa8]
+ ldr r0, [sp, #0x58]
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x40]
+_02019B06:
+ ldr r0, [sp, #0x23c]
+ ldr r1, [sp, #0xa8]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x238]
+ ldr r0, [sp, #0x248]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x240]
+ ldr r0, [sp, #0x8]
+ mov r1, #0x0
+ cmp r0, #0x0
+ ble _02019BC2
+ ble _02019BC2
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x244]
+ ldr r6, [sp, #0x40]
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x244]
+ str r6, [sp, #0xa4]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x40]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0xa0]
+ str r0, [sp, #0x9c]
+_02019B58:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+// b _02019B6C
+// nop
+// _02019B68: .word 0x00003FE0
+// _02019B6C:
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0xa4]
+ str r5, [sp, #0x2a4]
+ add r0, r5, r0
+ ldr r5, [sp, #0x238]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _02019BB4
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x2a8]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x2ac]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x2ac]
+ and r6, r5
+ ldr r5, [sp, #0x2a8]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x240]
+ cmp r0, #0x0
+ beq _02019BB4
+ ldr r6, [sp, #0x2a4]
+ ldr r0, [sp, #0xa0]
+ add r6, r6, r0
+ ldr r0, [sp, #0x9c]
+ strb r5, [r0, r6]
+_02019BB4:
+ ldr r0, [sp, #0x8]
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, r0
+ blt _02019B58
+_02019BC2:
+ ldr r0, [sp, #0x240]
+ cmp r0, #0x0
+ beq _02019BD0
+ ldr r0, [sp, #0x244]
+ add r0, r0, #0x2
+ str r0, [sp, #0x244]
+ b _02019BD6
+_02019BD0:
+ ldr r0, [sp, #0x244]
+ add r0, r0, #0x1
+ str r0, [sp, #0x244]
+_02019BD6:
+ ldr r0, [sp, #0x23c]
+ add r0, r0, #0x4
+ str r0, [sp, #0x23c]
+ ldr r0, [sp, #0x248]
+ add r0, r0, #0x1
+ str r0, [sp, #0x248]
+ cmp r0, #0x8
+ blt _02019B06
+ ldr r0, [sp, #0x0]
+ mov r2, #0x0
+ add r0, #0x40
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x48]
+ mov r1, #0x1
+ add r0, #0x8
+ str r0, [sp, #0x48]
+_02019BF6:
+ ldr r0, [sp, #0x330]
+ asr r0, r2
+ tst r0, r1
+ beq _02019C04
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_02019C04:
+ add r2, r2, #0x1
+ cmp r2, #0x8
+ blt _02019BF6
+ ldr r0, [sp, #0x330]
+ asr r0, r0, #0x8
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0xb8]
+ mov r0, #0x0
+ str r0, [sp, #0x20]
+ ldr r0, [sp, #0x4]
+ sub r0, #0x8
+ cmp r0, #0x0
+ bgt _02019C24
+ bl FUN_0201A8BC
+_02019C24:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0xb8]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x230]
+ ldr r0, [sp, #0x20]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x234]
+ ldr r0, [sp, #0x8]
+ mov r1, #0x0
+ cmp r0, #0x0
+ ble _02019CD8
+ ble _02019CD8
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x48]
+ ldr r6, [sp, #0x40]
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x48]
+ str r6, [sp, #0xb4]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x40]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0xb0]
+ str r0, [sp, #0xac]
+_02019C76:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0xb4]
+ str r5, [sp, #0x2b0]
+ add r0, r5, r0
+ ldr r5, [sp, #0x230]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _02019CCA
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x2b4]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x2b8]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x2b8]
+ and r6, r5
+ ldr r5, [sp, #0x2b4]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x234]
+ cmp r0, #0x0
+ beq _02019CCA
+ ldr r6, [sp, #0x2b0]
+ ldr r0, [sp, #0xb0]
+ add r6, r6, r0
+ ldr r0, [sp, #0xac]
+ strb r5, [r0, r6]
+_02019CCA:
+ ldr r0, [sp, #0x8]
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, r0
+ blt _02019C76
+_02019CD8:
+ ldr r0, [sp, #0x234]
+ cmp r0, #0x0
+ beq _02019CE6
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _02019CEC
+_02019CE6:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_02019CEC:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0x4]
+ add r0, r0, #0x4
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x20]
+ sub r1, #0x8
+ add r0, r0, #0x1
+ str r0, [sp, #0x20]
+ cmp r0, r1
+ blt _02019C24
+ add sp, #0x1fc
+ add sp, #0x118
+ pop {r4-r7, pc}
+_02019D06:
+ ldr r0, [sp, #0x0]
+ str r0, [sp, #0x220]
+ ldr r0, [sp, #0x48]
+ str r0, [sp, #0x228]
+ ldr r0, [sp, #0x330]
+ lsl r0, r0, #0x18
+ lsr r1, r0, #0x18
+ mov r0, #0x0
+ str r0, [sp, #0x22c]
+ lsl r0, r1, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x3c]
+ ldr r0, [sp, #0x58]
+ mov r1, #0x7
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x38]
+_02019D2A:
+ ldr r0, [sp, #0x220]
+ ldr r1, [sp, #0x3c]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x21c]
+ ldr r0, [sp, #0x22c]
+ ldr r6, [sp, #0x38]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x224]
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x228]
+ mov r1, #0x0
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x228]
+ str r6, [sp, #0xc4]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x38]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ str r3, [sp, #0x34]
+ add r4, r1, #0x0
+ str r5, [sp, #0xc0]
+ str r0, [sp, #0xbc]
+_02019D76:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0xc4]
+ str r5, [sp, #0x2bc]
+ add r0, r5, r0
+ ldr r5, [sp, #0x21c]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _02019DCA
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x2c0]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x2c4]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x2c4]
+ and r6, r5
+ ldr r5, [sp, #0x2c0]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x224]
+ cmp r0, #0x0
+ beq _02019DCA
+ ldr r6, [sp, #0x2bc]
+ ldr r0, [sp, #0xc0]
+ add r6, r6, r0
+ ldr r0, [sp, #0xbc]
+ strb r5, [r0, r6]
+_02019DCA:
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, #0x8
+ blt _02019D76
+ ldr r0, [sp, #0x224]
+ cmp r0, #0x0
+ beq _02019DE4
+ ldr r0, [sp, #0x228]
+ add r0, r0, #0x2
+ str r0, [sp, #0x228]
+ b _02019DEA
+_02019DE4:
+ ldr r0, [sp, #0x228]
+ add r0, r0, #0x1
+ str r0, [sp, #0x228]
+_02019DEA:
+ ldr r0, [sp, #0x220]
+ add r0, r0, #0x4
+ str r0, [sp, #0x220]
+ ldr r0, [sp, #0x22c]
+ add r0, r0, #0x1
+ str r0, [sp, #0x22c]
+ cmp r0, #0x8
+ blt _02019D2A
+ ldr r0, [sp, #0x0]
+ str r0, [sp, #0x20c]
+ add r0, #0x20
+ str r0, [sp, #0x20c]
+ ldr r0, [sp, #0x48]
+ str r0, [sp, #0x214]
+ mov r0, #0x0
+ str r0, [sp, #0x218]
+ ldr r0, [sp, #0x5c]
+ str r0, [sp, #0xd4]
+ add r0, #0x8
+ str r0, [sp, #0xd4]
+_02019E12:
+ ldr r0, [sp, #0x20c]
+ ldr r1, [sp, #0x3c]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0xd4]
+ str r0, [sp, #0x208]
+ ldr r0, [sp, #0x218]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x210]
+ ldr r0, [sp, #0x8]
+ mov r1, #0x0
+ str r0, [sp, #0x2c8]
+ sub r0, #0x8
+ str r0, [sp, #0x2c8]
+ cmp r0, #0x0
+ ble _02019ECC
+ ble _02019ECC
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x214]
+ ldr r6, [sp, #0x38]
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x214]
+ str r6, [sp, #0xd0]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x38]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0xcc]
+ str r0, [sp, #0xc8]
+_02019E6A:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0xd0]
+ str r5, [sp, #0x2cc]
+ add r0, r5, r0
+ ldr r5, [sp, #0x208]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _02019EBE
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x2d0]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x2d4]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x2d4]
+ and r6, r5
+ ldr r5, [sp, #0x2d0]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x210]
+ cmp r0, #0x0
+ beq _02019EBE
+ ldr r6, [sp, #0x2cc]
+ ldr r0, [sp, #0xcc]
+ add r6, r6, r0
+ ldr r0, [sp, #0xc8]
+ strb r5, [r0, r6]
+_02019EBE:
+ ldr r0, [sp, #0x2c8]
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, r0
+ blt _02019E6A
+_02019ECC:
+ ldr r0, [sp, #0x210]
+ cmp r0, #0x0
+ beq _02019EDA
+ ldr r0, [sp, #0x214]
+ add r0, r0, #0x2
+ str r0, [sp, #0x214]
+ b _02019EE0
+_02019EDA:
+ ldr r0, [sp, #0x214]
+ add r0, r0, #0x1
+ str r0, [sp, #0x214]
+_02019EE0:
+ ldr r0, [sp, #0x20c]
+ add r0, r0, #0x4
+ str r0, [sp, #0x20c]
+ ldr r0, [sp, #0x218]
+ add r0, r0, #0x1
+ str r0, [sp, #0x218]
+ cmp r0, #0x8
+ blt _02019E12
+ ldr r0, [sp, #0x0]
+ mov r2, #0x0
+ str r0, [sp, #0x1fc]
+ add r0, #0x40
+ str r0, [sp, #0x1fc]
+ ldr r0, [sp, #0x48]
+ mov r1, #0x1
+ add r0, #0x8
+ str r0, [sp, #0x48]
+ str r0, [sp, #0x204]
+_02019F04:
+ ldr r0, [sp, #0x330]
+ asr r0, r2
+ tst r0, r1
+ beq _02019F12
+ ldr r0, [sp, #0x204]
+ add r0, r0, #0x1
+ str r0, [sp, #0x204]
+_02019F12:
+ add r2, r2, #0x1
+ cmp r2, #0x8
+ blt _02019F04
+ ldr r0, [sp, #0x330]
+ asr r0, r0, #0x8
+ str r0, [sp, #0x50]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0xe4]
+ mov r0, #0x0
+ str r0, [sp, #0x1c]
+ ldr r0, [sp, #0x4]
+ sub r0, #0x8
+ cmp r0, #0x0
+ ble _0201A008
+_02019F30:
+ ldr r0, [sp, #0x1fc]
+ ldr r1, [sp, #0xe4]
+ ldr r0, [r0, #0x0]
+ ldr r6, [sp, #0x38]
+ str r0, [sp, #0x1f8]
+ ldr r0, [sp, #0x1c]
+ ldr r2, [sp, #0x5c]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x200]
+ ldr r0, [sp, #0x204]
+ mov r1, #0x0
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x204]
+ str r6, [sp, #0xe0]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x38]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ ldr r3, [sp, #0x34]
+ add r4, r1, #0x0
+ str r5, [sp, #0xdc]
+ str r0, [sp, #0xd8]
+_02019F78:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+// b _02019F8C
+// nop
+// _02019F88: .word 0x00003FE0
+// _02019F8C:
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0xe0]
+ str r5, [sp, #0x2d8]
+ add r0, r5, r0
+ ldr r5, [sp, #0x1f8]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _02019FD4
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x2dc]
+ ldrb r5, [r0, r7]
+ str r5, [sp, #0x2e0]
+ mov r5, #0xf0
+ asr r5, r6
+ ldr r6, [sp, #0x2e0]
+ and r6, r5
+ ldr r5, [sp, #0x2dc]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x200]
+ cmp r0, #0x0
+ beq _02019FD4
+ ldr r6, [sp, #0x2d8]
+ ldr r0, [sp, #0xdc]
+ add r6, r6, r0
+ ldr r0, [sp, #0xd8]
+ strb r5, [r0, r6]
+_02019FD4:
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, #0x8
+ blt _02019F78
+ ldr r0, [sp, #0x200]
+ cmp r0, #0x0
+ beq _02019FEE
+ ldr r0, [sp, #0x204]
+ add r0, r0, #0x2
+ str r0, [sp, #0x204]
+ b _02019FF4
+_02019FEE:
+ ldr r0, [sp, #0x204]
+ add r0, r0, #0x1
+ str r0, [sp, #0x204]
+_02019FF4:
+ ldr r0, [sp, #0x1fc]
+ ldr r1, [sp, #0x4]
+ add r0, r0, #0x4
+ str r0, [sp, #0x1fc]
+ ldr r0, [sp, #0x1c]
+ sub r1, #0x8
+ add r0, r0, #0x1
+ str r0, [sp, #0x1c]
+ cmp r0, r1
+ blt _02019F30
+_0201A008:
+ ldr r0, [sp, #0x0]
+ mov r2, #0x0
+ add r0, #0x60
+ str r0, [sp, #0x0]
+ mov r1, #0x1
+_0201A012:
+ ldr r0, [sp, #0x330]
+ asr r0, r2
+ tst r0, r1
+ beq _0201A020
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A020:
+ add r2, r2, #0x1
+ cmp r2, #0x8
+ blt _0201A012
+ ldr r0, [sp, #0x50]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0xf4]
+ mov r0, #0x0
+ str r0, [sp, #0x18]
+ ldr r0, [sp, #0x4]
+ sub r0, #0x8
+ cmp r0, #0x0
+ bgt _0201A03E
+ bl FUN_0201A8BC
+_0201A03E:
+ ldr r0, [sp, #0x5c]
+ add r0, #0x8
+ str r0, [sp, #0x5c]
+_0201A044:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0xf4]
+ ldr r0, [r0, #0x0]
+ ldr r2, [sp, #0x5c]
+ str r0, [sp, #0x1f0]
+ ldr r0, [sp, #0x18]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x1f4]
+ ldr r0, [sp, #0x8]
+ mov r1, #0x0
+ str r0, [sp, #0x2e4]
+ sub r0, #0x8
+ str r0, [sp, #0x2e4]
+ cmp r0, #0x0
+ ble _0201A0FE
+ ble _0201A0FE
+ add r0, r2, #0x0
+ lsl r3, r0, #0x2
+ ldr r0, [sp, #0x48]
+ ldr r6, [sp, #0x38]
+ lsl r5, r0, #0x2
+ ldr r0, =0x00003FE0
+ add r7, r5, #0x0
+ and r0, r5
+ mul r6, r0
+ mov r0, #0x1c
+ and r7, r0
+ ldr r0, [sp, #0x48]
+ str r6, [sp, #0xf0]
+ add r0, r0, #0x1
+ lsl r6, r0, #0x2
+ ldr r0, =0x00003FE0
+ ldr r5, [sp, #0x38]
+ and r0, r6
+ mul r5, r0
+ mov r0, #0x1c
+ and r0, r6
+ add r4, r1, #0x0
+ str r5, [sp, #0xec]
+ str r0, [sp, #0xe8]
+_0201A09C:
+ asr r5, r2, #0x1
+ mov r0, #0x3
+ and r5, r0
+ ldr r0, [sp, #0x278]
+ add r0, r0, r5
+ ldr r5, =0x00003FE0
+ and r5, r3
+ add r5, r0, r5
+ ldr r0, [sp, #0xf0]
+ str r5, [sp, #0x2e8]
+ add r0, r5, r0
+ ldr r5, [sp, #0x1f0]
+ add r6, r5, #0x0
+ lsr r6, r4
+ mov r5, #0xf
+ and r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ beq _0201A0F0
+ lsl r6, r2, #0x1f
+ lsr r6, r6, #0x1d
+ lsl r5, r6
+ str r5, [sp, #0x2ec]
+ ldrb r5, [r0, r7]
+ mov r12, r5
+ mov r5, #0xf0
+ asr r5, r6
+ mov r6, r12
+ and r6, r5
+ ldr r5, [sp, #0x2ec]
+ orr r5, r6
+ lsl r5, r5, #0x18
+ lsr r5, r5, #0x18
+ strb r5, [r0, r7]
+ ldr r0, [sp, #0x1f4]
+ cmp r0, #0x0
+ beq _0201A0F0
+ ldr r6, [sp, #0x2e8]
+ ldr r0, [sp, #0xec]
+ add r6, r6, r0
+ ldr r0, [sp, #0xe8]
+ strb r5, [r0, r6]
+_0201A0F0:
+ ldr r0, [sp, #0x2e4]
+ add r1, r1, #0x1
+ add r4, r4, #0x4
+ add r3, r3, #0x4
+ add r2, r2, #0x1
+ cmp r1, r0
+ blt _0201A09C
+_0201A0FE:
+ ldr r0, [sp, #0x1f4]
+ cmp r0, #0x0
+ beq _0201A10C
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _0201A112
+_0201A10C:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A112:
+ ldr r0, [sp, #0x0]
+ ldr r1, [sp, #0x4]
+ add r0, r0, #0x4
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x18]
+ sub r1, #0x8
+ add r0, r0, #0x1
+ str r0, [sp, #0x18]
+ cmp r0, r1
+ blt _0201A044
+ add sp, #0x1fc
+ add sp, #0x118
+ pop {r4-r7, pc}
+
+FUN_0201A12C: // 0x0201A12C
+ lsl r1, r2, #0x2
+ mul r1, r3
+ ldr r3, [r5, #0x0]
+ ldrb r2, [r5, #0x9]
+ ldr r0, [sp, #0x0]
+ ldr r3, [r3, #0x0]
+ lsl r1, r1, #0x3
+ bl FUN_02018848
+ str r0, [sp, #0x1ec]
+ cmp r4, #0x3
+ bhi _0201A21E
+ add r0, r4, r4
+ add r0, pc
+ ldrh r0, [r0, #0x6]
+ lsl r0, r0, #0x10
+ asr r0, r0, #0x10
+ add pc, r0
+_0201A150:
+
+ lsl r6, r0, #0
+ lsl r6, r1, #3
+ lsl r0, r7, #9
+ lsl r4, r3, #16
+ // jump table (using 16-bit offset)
+ // .short _0201A158 - _0201A150 - 2; case 0
+ // .short _0201A220 - _0201A150 - 2; case 1
+ // .short _0201A3CA - _0201A150 - 2; case 2
+ // .short _0201A56E - _0201A150 - 2; case 3
+_0201A158:
+ ldr r0, [sp, #0x330]
+ ldr r7, [sp, #0x1ec]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x10c]
+ mov r0, #0x0
+ str r0, [sp, #0x1e8]
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x0
+ ble _0201A21E
+ ldr r0, [sp, #0x58]
+ mov r1, #0x7
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x108]
+_0201A178:
+ ldr r1, [sp, #0x10c]
+ ldr r0, [sp, #0x1e8]
+ mov r4, #0x0
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x310]
+ ldr r0, [sp, #0x8]
+ ldr r5, [sp, #0x5c]
+ cmp r0, #0x0
+ ble _0201A1FC
+ ble _0201A1FC
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x48]
+ ldr r2, [sp, #0x108]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x100]
+ ldr r0, [sp, #0x48]
+ str r2, [sp, #0x104]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x108]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r2, [sp, #0xfc]
+ str r0, [sp, #0xf8]
+_0201A1C4:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x104]
+ ldrb r1, [r7, r4]
+ add r2, r3, r0
+ cmp r1, #0x0
+ beq _0201A1F0
+ ldr r0, [sp, #0x100]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x310]
+ cmp r0, #0x0
+ beq _0201A1F0
+ ldr r0, [sp, #0xfc]
+ add r2, r3, r0
+ ldr r0, [sp, #0xf8]
+ strb r1, [r0, r2]
+_0201A1F0:
+ ldr r0, [sp, #0x8]
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, r0
+ blt _0201A1C4
+_0201A1FC:
+ ldr r0, [sp, #0x310]
+ cmp r0, #0x0
+ beq _0201A20A
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _0201A210
+_0201A20A:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A210:
+ ldr r0, [sp, #0x1e8]
+ add r7, #0x8
+ add r1, r0, #0x1
+ ldr r0, [sp, #0x4]
+ str r1, [sp, #0x1e8]
+ cmp r1, r0
+ blt _0201A178
+_0201A21E:
+ b _0201A8B6
+_0201A220:
+ ldr r0, [sp, #0x48]
+ ldr r7, [sp, #0x1ec]
+ str r0, [sp, #0x1e0]
+ ldr r0, [sp, #0x330]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x4c]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x124]
+ mov r0, #0x0
+ str r0, [sp, #0x1e4]
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x0
+ ble _0201A2E6
+ ldr r0, [sp, #0x58]
+ mov r1, #0x7
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x120]
+_0201A24A:
+ ldr r1, [sp, #0x124]
+ ldr r0, [sp, #0x1e4]
+ ldr r5, [sp, #0x5c]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x30c]
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x1e0]
+ ldr r2, [sp, #0x120]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x118]
+ ldr r0, [sp, #0x1e0]
+ str r2, [sp, #0x11c]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x120]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ mov r4, #0x0
+ str r2, [sp, #0x114]
+ str r0, [sp, #0x110]
+_0201A28E:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x11c]
+ ldrb r1, [r7, r4]
+ add r2, r3, r0
+ cmp r1, #0x0
+ beq _0201A2BA
+ ldr r0, [sp, #0x118]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x30c]
+ cmp r0, #0x0
+ beq _0201A2BA
+ ldr r0, [sp, #0x114]
+ add r2, r3, r0
+ ldr r0, [sp, #0x110]
+ strb r1, [r0, r2]
+_0201A2BA:
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, #0x8
+ blt _0201A28E
+ ldr r0, [sp, #0x30c]
+ cmp r0, #0x0
+ beq _0201A2D2
+ ldr r0, [sp, #0x1e0]
+ add r0, r0, #0x2
+ str r0, [sp, #0x1e0]
+ b _0201A2D8
+_0201A2D2:
+ ldr r0, [sp, #0x1e0]
+ add r0, r0, #0x1
+ str r0, [sp, #0x1e0]
+_0201A2D8:
+ ldr r0, [sp, #0x1e4]
+ add r7, #0x8
+ add r1, r0, #0x1
+ ldr r0, [sp, #0x4]
+ str r1, [sp, #0x1e4]
+ cmp r1, r0
+ blt _0201A24A
+_0201A2E6:
+ ldr r0, [sp, #0x1ec]
+ str r0, [sp, #0x308]
+ add r0, #0x40
+ str r0, [sp, #0x308]
+ ldr r0, [sp, #0x4c]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x13c]
+ mov r0, #0x0
+ str r0, [sp, #0x1dc]
+ ldr r0, [sp, #0x4]
+ cmp r0, #0x0
+ ble _0201A3C8
+ ldr r0, [sp, #0x5c]
+ mov r1, #0x7
+ add r0, #0x8
+ str r0, [sp, #0x5c]
+ ldr r0, [sp, #0x58]
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x138]
+_0201A312:
+ ldr r1, [sp, #0x13c]
+ ldr r0, [sp, #0x1dc]
+ ldr r7, [sp, #0x8]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ sub r7, #0x8
+ mov r4, #0x0
+ str r0, [sp, #0x1d8]
+ ldr r5, [sp, #0x5c]
+ cmp r7, #0x0
+ ble _0201A398
+ ble _0201A398
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x48]
+ ldr r2, [sp, #0x138]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x130]
+ ldr r0, [sp, #0x48]
+ str r2, [sp, #0x134]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x138]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r2, [sp, #0x12c]
+ str r0, [sp, #0x128]
+_0201A360:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x134]
+ add r2, r3, r0
+ ldr r0, [sp, #0x308]
+ ldrb r1, [r0, r4]
+ cmp r1, #0x0
+ beq _0201A38E
+ ldr r0, [sp, #0x130]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x1d8]
+ cmp r0, #0x0
+ beq _0201A38E
+ ldr r0, [sp, #0x12c]
+ add r2, r3, r0
+ ldr r0, [sp, #0x128]
+ strb r1, [r0, r2]
+_0201A38E:
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, r7
+ blt _0201A360
+_0201A398:
+ ldr r0, [sp, #0x1d8]
+ cmp r0, #0x0
+ beq _0201A3B0
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _0201A3B6
+// nop
+// _0201A3A8: .word 0x00003FE0
+// _0201A3AC: .word 0x00007FC0
+_0201A3B0:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A3B6:
+ ldr r0, [sp, #0x308]
+ add r0, #0x8
+ str r0, [sp, #0x308]
+ ldr r0, [sp, #0x1dc]
+ add r1, r0, #0x1
+ ldr r0, [sp, #0x4]
+ str r1, [sp, #0x1dc]
+ cmp r1, r0
+ blt _0201A312
+_0201A3C8:
+ b _0201A8B6
+_0201A3CA:
+ ldr r0, [sp, #0x48]
+ mov r1, #0x7
+ str r0, [sp, #0x1d0]
+ mov r0, #0x0
+ str r0, [sp, #0x1d4]
+ ldr r0, [sp, #0x330]
+ ldr r7, [sp, #0x1ec]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x150]
+ ldr r0, [sp, #0x58]
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x30]
+_0201A3E8:
+ ldr r1, [sp, #0x150]
+ ldr r0, [sp, #0x1d4]
+ mov r4, #0x0
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x304]
+ ldr r0, [sp, #0x8]
+ ldr r5, [sp, #0x5c]
+ cmp r0, #0x0
+ ble _0201A46C
+ ble _0201A46C
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x1d0]
+ ldr r2, [sp, #0x30]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x148]
+ ldr r0, [sp, #0x1d0]
+ str r2, [sp, #0x14c]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x30]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r2, [sp, #0x144]
+ str r0, [sp, #0x140]
+_0201A434:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x14c]
+ ldrb r1, [r7, r4]
+ add r2, r3, r0
+ cmp r1, #0x0
+ beq _0201A460
+ ldr r0, [sp, #0x148]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x304]
+ cmp r0, #0x0
+ beq _0201A460
+ ldr r0, [sp, #0x144]
+ add r2, r3, r0
+ ldr r0, [sp, #0x140]
+ strb r1, [r0, r2]
+_0201A460:
+ ldr r0, [sp, #0x8]
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, r0
+ blt _0201A434
+_0201A46C:
+ ldr r0, [sp, #0x304]
+ cmp r0, #0x0
+ beq _0201A47A
+ ldr r0, [sp, #0x1d0]
+ add r0, r0, #0x2
+ str r0, [sp, #0x1d0]
+ b _0201A480
+_0201A47A:
+ ldr r0, [sp, #0x1d0]
+ add r0, r0, #0x1
+ str r0, [sp, #0x1d0]
+_0201A480:
+ ldr r0, [sp, #0x1d4]
+ add r7, #0x8
+ add r0, r0, #0x1
+ str r0, [sp, #0x1d4]
+ cmp r0, #0x8
+ blt _0201A3E8
+ ldr r0, [sp, #0x48]
+ ldr r7, [sp, #0x1ec]
+ add r0, #0x8
+ str r0, [sp, #0x48]
+ add r7, #0x80
+ mov r0, #0x0
+ mov r2, #0x1
+_0201A49A:
+ ldr r1, [sp, #0x330]
+ asr r1, r0
+ tst r1, r2
+ beq _0201A4A8
+ ldr r1, [sp, #0x48]
+ add r1, r1, #0x1
+ str r1, [sp, #0x48]
+_0201A4A8:
+ add r0, r0, #0x1
+ cmp r0, #0x8
+ blt _0201A49A
+ ldr r0, [sp, #0x330]
+ asr r0, r0, #0x8
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x164]
+ mov r0, #0x0
+ str r0, [sp, #0x14]
+ ldr r0, [sp, #0x4]
+ sub r0, #0x8
+ cmp r0, #0x0
+ ble _0201A56C
+_0201A4C4:
+ ldr r1, [sp, #0x164]
+ ldr r0, [sp, #0x14]
+ mov r4, #0x0
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x300]
+ ldr r0, [sp, #0x8]
+ ldr r5, [sp, #0x5c]
+ cmp r0, #0x0
+ ble _0201A548
+ ble _0201A548
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x48]
+ ldr r2, [sp, #0x30]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x15c]
+ ldr r0, [sp, #0x48]
+ str r2, [sp, #0x160]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x30]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r2, [sp, #0x158]
+ str r0, [sp, #0x154]
+_0201A510:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x160]
+ ldrb r1, [r7, r4]
+ add r2, r3, r0
+ cmp r1, #0x0
+ beq _0201A53C
+ ldr r0, [sp, #0x15c]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x300]
+ cmp r0, #0x0
+ beq _0201A53C
+ ldr r0, [sp, #0x158]
+ add r2, r3, r0
+ ldr r0, [sp, #0x154]
+ strb r1, [r0, r2]
+_0201A53C:
+ ldr r0, [sp, #0x8]
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, r0
+ blt _0201A510
+_0201A548:
+ ldr r0, [sp, #0x300]
+ cmp r0, #0x0
+ beq _0201A556
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _0201A55C
+_0201A556:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A55C:
+ ldr r0, [sp, #0x14]
+ ldr r1, [sp, #0x4]
+ add r0, r0, #0x1
+ sub r1, #0x8
+ add r7, #0x8
+ str r0, [sp, #0x14]
+ cmp r0, r1
+ blt _0201A4C4
+_0201A56C:
+ b _0201A8B6
+_0201A56E:
+ ldr r0, [sp, #0x48]
+ ldr r7, [sp, #0x1ec]
+ str r0, [sp, #0x1c8]
+ ldr r0, [sp, #0x330]
+ lsl r0, r0, #0x18
+ lsr r1, r0, #0x18
+ mov r0, #0x0
+ str r0, [sp, #0x1cc]
+ lsl r0, r1, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x2c]
+ ldr r0, [sp, #0x58]
+ mov r1, #0x7
+ and r1, r0
+ add r0, r0, r1
+ asr r0, r0, #0x3
+ str r0, [sp, #0x28]
+_0201A590:
+ ldr r1, [sp, #0x2c]
+ ldr r0, [sp, #0x1cc]
+ ldr r5, [sp, #0x5c]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x2fc]
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x1c8]
+ ldr r2, [sp, #0x28]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x170]
+ ldr r0, [sp, #0x1c8]
+ str r2, [sp, #0x174]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x28]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ mov r4, #0x0
+ str r6, [sp, #0x24]
+ str r2, [sp, #0x16c]
+ str r0, [sp, #0x168]
+_0201A5D6:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x174]
+ ldrb r1, [r7, r4]
+ add r2, r3, r0
+ cmp r1, #0x0
+ beq _0201A602
+ ldr r0, [sp, #0x170]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x2fc]
+ cmp r0, #0x0
+ beq _0201A602
+ ldr r0, [sp, #0x16c]
+ add r2, r3, r0
+ ldr r0, [sp, #0x168]
+ strb r1, [r0, r2]
+_0201A602:
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, #0x8
+ blt _0201A5D6
+ ldr r0, [sp, #0x2fc]
+ cmp r0, #0x0
+ beq _0201A61A
+ ldr r0, [sp, #0x1c8]
+ add r0, r0, #0x2
+ str r0, [sp, #0x1c8]
+ b _0201A620
+_0201A61A:
+ ldr r0, [sp, #0x1c8]
+ add r0, r0, #0x1
+ str r0, [sp, #0x1c8]
+_0201A620:
+ ldr r0, [sp, #0x1cc]
+ add r7, #0x8
+ add r0, r0, #0x1
+ str r0, [sp, #0x1cc]
+ cmp r0, #0x8
+ blt _0201A590
+ ldr r0, [sp, #0x1ec]
+ str r0, [sp, #0x2f8]
+ add r0, #0x40
+ str r0, [sp, #0x2f8]
+ ldr r0, [sp, #0x48]
+ str r0, [sp, #0x1c0]
+ mov r0, #0x0
+ str r0, [sp, #0x1c4]
+ ldr r0, [sp, #0x5c]
+ str r0, [sp, #0x188]
+ add r0, #0x8
+ str r0, [sp, #0x188]
+_0201A644:
+ ldr r1, [sp, #0x2c]
+ ldr r0, [sp, #0x1c4]
+ ldr r7, [sp, #0x8]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ sub r7, #0x8
+ mov r4, #0x0
+ str r0, [sp, #0x1bc]
+ ldr r5, [sp, #0x188]
+ cmp r7, #0x0
+ ble _0201A6CA
+ ble _0201A6CA
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x1c0]
+ ldr r2, [sp, #0x28]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x180]
+ ldr r0, [sp, #0x1c0]
+ str r2, [sp, #0x184]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x28]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r2, [sp, #0x17c]
+ str r0, [sp, #0x178]
+_0201A692:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x184]
+ add r2, r3, r0
+ ldr r0, [sp, #0x2f8]
+ ldrb r1, [r0, r4]
+ cmp r1, #0x0
+ beq _0201A6C0
+ ldr r0, [sp, #0x180]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x1bc]
+ cmp r0, #0x0
+ beq _0201A6C0
+ ldr r0, [sp, #0x17c]
+ add r2, r3, r0
+ ldr r0, [sp, #0x178]
+ strb r1, [r0, r2]
+_0201A6C0:
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, r7
+ blt _0201A692
+_0201A6CA:
+ ldr r0, [sp, #0x1bc]
+ cmp r0, #0x0
+ beq _0201A6D8
+ ldr r0, [sp, #0x1c0]
+ add r0, r0, #0x2
+ str r0, [sp, #0x1c0]
+ b _0201A6DE
+_0201A6D8:
+ ldr r0, [sp, #0x1c0]
+ add r0, r0, #0x1
+ str r0, [sp, #0x1c0]
+_0201A6DE:
+ ldr r0, [sp, #0x2f8]
+ add r0, #0x8
+ str r0, [sp, #0x2f8]
+ ldr r0, [sp, #0x1c4]
+ add r0, r0, #0x1
+ str r0, [sp, #0x1c4]
+ cmp r0, #0x8
+ blt _0201A644
+ ldr r0, [sp, #0x48]
+ ldr r7, [sp, #0x1ec]
+ add r0, #0x8
+ add r7, #0x80
+ str r0, [sp, #0x48]
+ str r0, [sp, #0x1b8]
+ mov r0, #0x0
+ mov r2, #0x1
+_0201A6FE:
+ ldr r1, [sp, #0x330]
+ asr r1, r0
+ tst r1, r2
+ beq _0201A70C
+ ldr r1, [sp, #0x1b8]
+ add r1, r1, #0x1
+ str r1, [sp, #0x1b8]
+_0201A70C:
+ add r0, r0, #0x1
+ cmp r0, #0x8
+ blt _0201A6FE
+ ldr r0, [sp, #0x330]
+ asr r0, r0, #0x8
+ str r0, [sp, #0x44]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x19c]
+ mov r0, #0x0
+ str r0, [sp, #0x10]
+ ldr r0, [sp, #0x4]
+ sub r0, #0x8
+ cmp r0, #0x0
+ ble _0201A7CE
+_0201A72A:
+ ldr r1, [sp, #0x19c]
+ ldr r0, [sp, #0x10]
+ ldr r2, [sp, #0x28]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x2f4]
+ ldr r0, [sp, #0x1b8]
+ mov r3, #0x38
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+// b _0201A74C
+// nop
+// _0201A748: .word 0x00007FC0
+// _0201A74C:
+ ldr r5, [sp, #0x5c]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x194]
+ ldr r0, [sp, #0x1b8]
+ str r2, [sp, #0x198]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x28]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ ldr r6, [sp, #0x24]
+ mov r4, #0x0
+ str r2, [sp, #0x190]
+ str r0, [sp, #0x18c]
+_0201A774:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x198]
+ ldrb r1, [r7, r4]
+ add r2, r3, r0
+ cmp r1, #0x0
+ beq _0201A7A0
+ ldr r0, [sp, #0x194]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x2f4]
+ cmp r0, #0x0
+ beq _0201A7A0
+ ldr r0, [sp, #0x190]
+ add r2, r3, r0
+ ldr r0, [sp, #0x18c]
+ strb r1, [r0, r2]
+_0201A7A0:
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, #0x8
+ blt _0201A774
+ ldr r0, [sp, #0x2f4]
+ cmp r0, #0x0
+ beq _0201A7B8
+ ldr r0, [sp, #0x1b8]
+ add r0, r0, #0x2
+ str r0, [sp, #0x1b8]
+ b _0201A7BE
+_0201A7B8:
+ ldr r0, [sp, #0x1b8]
+ add r0, r0, #0x1
+ str r0, [sp, #0x1b8]
+_0201A7BE:
+ ldr r0, [sp, #0x10]
+ ldr r1, [sp, #0x4]
+ add r0, r0, #0x1
+ sub r1, #0x8
+ add r7, #0x8
+ str r0, [sp, #0x10]
+ cmp r0, r1
+ blt _0201A72A
+_0201A7CE:
+ ldr r0, [sp, #0x1ec]
+ mov r2, #0x0
+ str r0, [sp, #0x2f0]
+ add r0, #0xc0
+ str r0, [sp, #0x2f0]
+ mov r1, #0x1
+_0201A7DA:
+ ldr r0, [sp, #0x330]
+ asr r0, r2
+ tst r0, r1
+ beq _0201A7E8
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A7E8:
+ add r2, r2, #0x1
+ cmp r2, #0x8
+ blt _0201A7DA
+ ldr r0, [sp, #0x44]
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ str r0, [sp, #0x1b0]
+ mov r0, #0x0
+ str r0, [sp, #0xc]
+ ldr r0, [sp, #0x4]
+ sub r0, #0x8
+ cmp r0, #0x0
+ ble _0201A8B6
+ ldr r0, [sp, #0x5c]
+ add r0, #0x8
+ str r0, [sp, #0x5c]
+_0201A808:
+ ldr r1, [sp, #0x1b0]
+ ldr r0, [sp, #0xc]
+ ldr r7, [sp, #0x8]
+ asr r1, r0
+ mov r0, #0x1
+ and r0, r1
+ lsl r0, r0, #0x18
+ lsr r0, r0, #0x18
+ sub r7, #0x8
+ mov r4, #0x0
+ str r0, [sp, #0x1b4]
+ ldr r5, [sp, #0x5c]
+ cmp r7, #0x0
+ ble _0201A88E
+ ble _0201A88E
+ add r0, r5, #0x0
+ lsl r6, r0, #0x3
+ ldr r0, [sp, #0x48]
+ ldr r2, [sp, #0x28]
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ mov r3, #0x38
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r0, [sp, #0x1a8]
+ ldr r0, [sp, #0x48]
+ str r2, [sp, #0x1ac]
+ add r0, r0, #0x1
+ lsl r1, r0, #0x3
+ ldr r0, =0x00007FC0
+ ldr r2, [sp, #0x28]
+ and r0, r1
+ mul r2, r0
+ add r0, r1, #0x0
+ and r0, r3
+ str r2, [sp, #0x1a4]
+ str r0, [sp, #0x1a0]
+_0201A856:
+ mov r0, #0x7
+ add r1, r5, #0x0
+ and r1, r0
+ ldr r0, [sp, #0x278]
+ add r1, r0, r1
+ ldr r0, =0x00007FC0
+ and r0, r6
+ add r3, r1, r0
+ ldr r0, [sp, #0x1ac]
+ add r2, r3, r0
+ ldr r0, [sp, #0x2f0]
+ ldrb r1, [r0, r4]
+ cmp r1, #0x0
+ beq _0201A884
+ ldr r0, [sp, #0x1a8]
+ strb r1, [r2, r0]
+ ldr r0, [sp, #0x1b4]
+ cmp r0, #0x0
+ beq _0201A884
+ ldr r0, [sp, #0x1a4]
+ add r2, r3, r0
+ ldr r0, [sp, #0x1a0]
+ strb r1, [r0, r2]
+_0201A884:
+ add r4, r4, #0x1
+ add r6, #0x8
+ add r5, r5, #0x1
+ cmp r4, r7
+ blt _0201A856
+_0201A88E:
+ ldr r0, [sp, #0x1b4]
+ cmp r0, #0x0
+ beq _0201A89C
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x2
+ str r0, [sp, #0x48]
+ b _0201A8A2
+_0201A89C:
+ ldr r0, [sp, #0x48]
+ add r0, r0, #0x1
+ str r0, [sp, #0x48]
+_0201A8A2:
+ ldr r0, [sp, #0x2f0]
+ ldr r1, [sp, #0x4]
+ add r0, #0x8
+ str r0, [sp, #0x2f0]
+ ldr r0, [sp, #0xc]
+ sub r1, #0x8
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ cmp r0, r1
+ blt _0201A808
+_0201A8B6:
+ ldr r0, [sp, #0x1ec]
+ bl FreeToHeap
+
+FUN_0201A8BC: // 0x0201A8BC
+ add sp, #0x1fc
+ add sp, #0x118
+ pop {r4-r7, pc}
+ // clang-format on
+}
+#endif
+
+THUMB_FUNC void ScrollWindow(struct Window *window, u32 param1, u8 param2, u8 param3)
+{
+ if (window->unk00->unk08[window->unk04].unk1e == 0)
+ {
+ FUN_0201A8E8(window, param1, param2, param3);
+ }
+ else
+ {
+ FUN_0201A9D4(window, param1, param2, param3);
+ }
+}
+
+THUMB_FUNC void FUN_0201A8E8(struct Window *window, u32 param1, u8 param2, u8 param3)
+{
+ void *r2;
+ int r5, r1, r3;
+ int st4, stc;
+ u32 st8;
+ int i, j;
+
+ r2 = window->unk0c;
+ st4 = (param3 << 0x18) | (param3 << 0x10) | (param3 << 0x8) | param3;
+ stc = window->height * window->width * 32;
+ st8 = window->width;
+
+ switch (param1)
+ {
+ case 0:
+ for (i = 0; i < stc; i += 32)
+ {
+ r3 = param2;
+ for (j = 0; j < 8; j++)
+ {
+ r5 = i + (j << 2);
+ r1 = i + (int)(((st8 * (r3 & ~7)) | (r3 & 7)) << 2);
+
+ if (r1 < stc)
+ {
+ *(u32 *)(r2 + r5) = *(u32 *)(r2 + r1);
+ }
+ else
+ {
+ *(u32 *)(r2 + r5) = (u32)st4;
+ }
+
+ r3++;
+ }
+ }
+
+ break;
+ case 1:
+ r2 += stc - 4;
+ for (i = 0; i < stc; i += 32)
+ {
+ r3 = param2;
+ for (j = 0; j < 8; j++)
+ {
+ r5 = i + (j << 2);
+ r1 = i + (int)(((st8 * (r3 & ~7)) | (r3 & 7)) << 2);
+
+ if (r1 < stc)
+ {
+ *(u32 *)(r2 - r5) = *(u32 *)(r2 - r1);
+ }
+ else
+ {
+ *(u32 *)(r2 - r5) = (u32)st4;
+ }
+
+ r3++;
+ }
+ }
+
+ break;
+ case 2:
+ case 3:
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_0201A9D4(struct Window *window, u32 param1, u8 param2, u8 param3)
+{
+
+ void *r2;
+ int r5, r1, r3;
+ int st4, stc;
+ u32 st8;
+ int i, j;
+
+ r2 = (u8 *)window->unk0c;
+ st4 = (param3 << 0x18) | (param3 << 0x10) | (param3 << 0x8) | param3;
+ stc = window->height * window->width * 64;
+ st8 = window->width;
+
+ switch (param1)
+ {
+ case 0:
+ for (i = 0; i < stc; i += 64)
+ {
+ r3 = param2;
+ for (j = 0; j < 8; j++)
+ {
+ r5 = i + (j << 3);
+ r1 = i + (int)(((st8 * (r3 & ~7)) | (r3 & 7)) << 3);
+
+ if (r1 < stc)
+ {
+ *(u32 *)(r2 + r5) = *(u32 *)(r2 + r1);
+ }
+ else
+ {
+ *(u32 *)(r2 + r5) = (u32)st4;
+ }
+
+ r5 += 4;
+ r1 += 4;
+ if (r1 < stc + 4)
+ {
+ *(u32 *)(r2 + r5) = *(u32 *)(r2 + r1);
+ }
+ else
+ {
+ *(u32 *)(r2 + r5) = (u32)st4;
+ }
+
+ r3++;
+ }
+ }
+
+ break;
+ case 1:
+ r2 += stc - 8;
+ for (i = 0; i < stc; i += 64)
+ {
+ r3 = param2;
+ for (j = 0; j < 8; j++)
+ {
+ r5 = i + (j << 3);
+ r1 = i + (int)(((st8 * (r3 & ~7)) | (r3 & 7)) << 3);
+
+ if (r1 < stc)
+ {
+ *(u32 *)(r2 - r5) = *(u32 *)(r2 - r1);
+ }
+ else
+ {
+ *(u32 *)(r2 - r5) = (u32)st4;
+ }
+
+ r5 -= 4;
+ r1 -= 4;
+ if (r1 < stc - 4)
+ {
+ *(u32 *)(r2 - r5) = *(u32 *)(r2 - r1);
+ }
+ else
+ {
+ *(u32 *)(r2 - r5) = (u32)st4;
+ }
+
+ r3++;
+ }
+ }
+
+ break;
+ case 2:
+ case 3:
+ break;
+ }
+}
+
+THUMB_FUNC u8 FUN_0201AB08(struct Window *window)
+{
+ return window->unk04;
+}
+
+THUMB_FUNC u8 GetWindowWidth(struct Window *window)
+{
+ return window->width;
+}
+THUMB_FUNC u8 GetWindowHeight(struct Window *window)
+{
+ return window->height;
+}
+THUMB_FUNC u8 FUN_0201AB14(struct Window *window)
+{
+ return window->unk05;
+}
+THUMB_FUNC u8 FUN_0201AB18(struct Window *window)
+{
+ return window->unk06;
+}
+THUMB_FUNC void FUN_0201AB1C(struct Window *window, u8 param1)
+{
+ window->unk05 = param1;
+}
+THUMB_FUNC void FUN_0201AB20(struct Window *window, u8 param1)
+{
+ window->unk06 = param1;
+}
+THUMB_FUNC void FUN_0201AB24(struct Window *window, u8 param1)
+{
+ window->unk09 = param1;
+}
+
+THUMB_FUNC u32 FUN_0201AB28(struct Window *window, u32 heap_id, const char *path)
+{
+ void *ptr = FUN_020161A4(heap_id, path);
+ window->unk00 = ptr;
+ u32 st0;
+ NNS_G2dGetUnpackedBGCharacterData(ptr, &st0);
+
+ return st0;
+}
+
+THUMB_FUNC u32 FUN_0201AB44(struct Window *window, u32 heap_id, const char *path)
+{
+ void *ptr = FUN_020161A4(heap_id, path);
+ window->unk00 = ptr;
+ u32 st0;
+ NNS_G2dGetUnpackedPaletteData(ptr, &st0);
+
+ return st0;
+}
+
+THUMB_FUNC void FUN_0201AB60(struct UnkStruct_02016B94_2 *param0)
+{
+ FUN_0201AC78(param0);
+ FUN_0201AB78(param0);
+
+ param0->unk04 = 0;
+ param0->unk06 = 0;
+}
+
+THUMB_FUNC void FUN_0201AB78(struct UnkStruct_02016B94_2 *param0)
+{
+ if ((param0->unk06 & 1) != 0)
+ {
+ FUN_02017D68(0, param0->unk08[0].unk08, param0->unk08[0].unk10 * 2, param0->unk08[0].unk0c);
+ }
+
+ if ((param0->unk06 & 2) != 0)
+ {
+ FUN_02017D68(1, param0->unk08[1].unk08, param0->unk08[1].unk10 * 2, param0->unk08[1].unk0c);
+ }
+
+ if ((param0->unk06 & 4) != 0)
+ {
+ FUN_02017D68(2, param0->unk08[2].unk08, param0->unk08[2].unk10 * 2, param0->unk08[2].unk0c);
+ }
+
+ if ((param0->unk06 & 8) != 0)
+ {
+ FUN_02017D68(3, param0->unk08[3].unk08, param0->unk08[3].unk10 * 2, param0->unk08[3].unk0c);
+ }
+
+ if ((param0->unk06 & 0x10) != 0)
+ {
+ FUN_02017D68(4, param0->unk08[4].unk08, param0->unk08[4].unk10 * 2, param0->unk08[4].unk0c);
+ }
+
+ if ((param0->unk06 & 0x20) != 0)
+ {
+ FUN_02017D68(5, param0->unk08[5].unk08, param0->unk08[5].unk10 * 2, param0->unk08[5].unk0c);
+ }
+
+ if ((param0->unk06 & 0x40) != 0)
+ {
+ FUN_02017D68(6, param0->unk08[6].unk08, param0->unk08[6].unk10 * 2, param0->unk08[6].unk0c);
+ }
+
+ if ((param0->unk06 & 0x80) != 0)
+ {
+ FUN_02017D68(7, param0->unk08[7].unk08, param0->unk08[7].unk10 * 2, param0->unk08[7].unk0c);
+ }
+}
+
+THUMB_FUNC void FUN_0201AC68(struct UnkStruct_02016B94_2 *param0, u32 param1)
+{
+ param0->unk06 |= 1 << param1;
+}
+
+THUMB_FUNC void FUN_0201AC78(struct UnkStruct_02016B94_2 *param0)
+{
+ if ((param0->unk04 & 1) != 0)
+ {
+ reg_G2_BG0OFS = (u32)(
+ (param0->unk08[0].unk14 & 0x1ff) | ((param0->unk08[0].unk18 << 0x10) & 0x1ff0000));
+ }
+
+ if ((param0->unk04 & 2) != 0)
+ {
+ reg_G2_BG1OFS = (u32)(
+ (param0->unk08[1].unk14 & 0x1ff) | ((param0->unk08[1].unk18 << 0x10) & 0x1ff0000));
+ }
+
+ if ((param0->unk04 & 4) != 0)
+ {
+ if (param0->unk08[2].unk1c == 0)
+ {
+ reg_G2_BG2OFS = (u32)(
+ (param0->unk08[2].unk14 & 0x1ff) | ((param0->unk08[2].unk18 << 0x10) & 0x1ff0000));
+ }
+ else
+ {
+ struct Mtx22 st38;
+ MTX22_2DAffine(
+ &st38, param0->unk08[2].unk20, param0->unk08[2].unk24, param0->unk08[2].unk28, 2);
+ G2x_SetBGyAffine_(reg_G2_BG2P,
+ &st38,
+ param0->unk08[2].unk2c,
+ param0->unk08[2].unk30,
+ param0->unk08[2].unk14,
+ param0->unk08[2].unk18);
+ }
+ }
+
+ if ((param0->unk04 & 8) != 0)
+ {
+ if (param0->unk08[3].unk1c == 0)
+ {
+ reg_G2_BG3OFS = (u32)(
+ (param0->unk08[3].unk14 & 0x1ff) | ((param0->unk08[3].unk18 << 0x10) & 0x1ff0000));
+ }
+ else
+ {
+ struct Mtx22 st28;
+ MTX22_2DAffine(
+ &st28, param0->unk08[3].unk20, param0->unk08[3].unk24, param0->unk08[3].unk28, 2);
+ G2x_SetBGyAffine_(reg_G2_BG3P,
+ &st28,
+ param0->unk08[3].unk2c,
+ param0->unk08[3].unk30,
+ param0->unk08[3].unk14,
+ param0->unk08[3].unk18);
+ }
+ }
+
+ if ((param0->unk04 & 0x10) != 0)
+ {
+ reg_G2S_DB_BG0OFS = (u32)(
+ (param0->unk08[4].unk14 & 0x1ff) | ((param0->unk08[4].unk18 << 0x10) & 0x1ff0000));
+ }
+
+ if ((param0->unk04 & 0x20) != 0)
+ {
+ reg_G2S_DB_BG1OFS = (u32)(
+ (param0->unk08[5].unk14 & 0x1ff) | ((param0->unk08[5].unk18 << 0x10) & 0x1ff0000));
+ }
+
+ if ((param0->unk04 & 0x40) != 0)
+ {
+ if (param0->unk08[6].unk1c == 0)
+ {
+ reg_G2S_DB_BG2OFS = (u32)(
+ (param0->unk08[6].unk14 & 0x1ff) | ((param0->unk08[6].unk18 << 0x10) & 0x1ff0000));
+ }
+ else
+ {
+ struct Mtx22 st18;
+ MTX22_2DAffine(
+ &st18, param0->unk08[6].unk20, param0->unk08[6].unk24, param0->unk08[6].unk28, 2);
+ G2x_SetBGyAffine_(reg_G2S_DB_BG2P,
+ &st18,
+ param0->unk08[6].unk2c,
+ param0->unk08[6].unk30,
+ param0->unk08[6].unk14,
+ param0->unk08[6].unk18);
+ }
+ }
+
+ if ((param0->unk04 & 0x80) != 0)
+ {
+ if (param0->unk08[7].unk1c == 0)
+ {
+ reg_G2S_DB_BG3OFS = (u32)(
+ (param0->unk08[7].unk14 & 0x1ff) | ((param0->unk08[7].unk18 << 0x10) & 0x1ff0000));
+ }
+ else
+ {
+ struct Mtx22 st08;
+ MTX22_2DAffine(
+ &st08, param0->unk08[7].unk20, param0->unk08[7].unk24, param0->unk08[7].unk28, 2);
+ G2x_SetBGyAffine_(reg_G2S_DB_BG3P,
+ &st08,
+ param0->unk08[7].unk2c,
+ param0->unk08[7].unk30,
+ param0->unk08[7].unk14,
+ param0->unk08[7].unk18);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_0201AEE4(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, fx32 param3)
+{
+ FUN_02017B8C(&param0->unk08[param1], param2, param3);
+ param0->unk04 |= 1 << param1;
+}
+
+THUMB_FUNC void FUN_0201AF08(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, u16 param3)
+{
+ FUN_0201AF2C(&param0->unk08[param1], param2, param3);
+ param0->unk04 |= 1 << param1;
+}
+
+THUMB_FUNC void FUN_0201AF2C(struct UnkStruct_02016B94_2_sub *param0, u32 param1, u16 val)
+{
+ switch (param1)
+ {
+ case 0:
+ param0->unk20 = val;
+ break;
+ case 1:
+ param0->unk20 += val;
+ break;
+ case 2:
+ param0->unk20 -= val;
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_0201AF50(
+ struct UnkStruct_02016B94_2 *param0, u32 param1, u32 param2, fx32 param3)
+{
+ FUN_0201AF74(&param0->unk08[param1], param2, param3);
+ param0->unk04 |= 1 << param1;
+}
+
+THUMB_FUNC void FUN_0201AF74(struct UnkStruct_02016B94_2_sub *param0, u32 param1, fx32 val)
+{
+ switch (param1 - 9)
+ {
+ case 0:
+ param0->unk2c = val;
+ break;
+ case 1:
+ param0->unk2c += val;
+ break;
+ case 2:
+ param0->unk2c -= val;
+ break;
+ case 3:
+ param0->unk30 = val;
+ break;
+ case 4:
+ param0->unk30 += val;
+ break;
+ case 5:
+ param0->unk30 -= val;
+ break;
+ }
+}
+
+THUMB_FUNC u32 FUN_0201AFBC(
+ struct UnkStruct_02016B94_2 *param0, u8 param1, u8 param2, u8 param3, u16 *param4)
+{
+ void *st18;
+ u16 r6;
+ u8 st14;
+ u8 st10;
+ u8 r5;
+ u8 i;
+
+ if (param0->unk08[param1].unk08 == NULL)
+ {
+ return 0;
+ }
+
+ r6 = FUN_02017FFC((u8)(param2 >> 3), (u8)(param3 >> 3), param0->unk08[param1].unk1d);
+ st18 = FUN_020187B0(param1);
+
+ st14 = (u8)(param2 & 7);
+ st10 = (u8)(param3 & 7);
+
+ if (param0->unk08[param1].unk1e == 0)
+ {
+ u16 *stc = param0->unk08[param1].unk08;
+ u8 *ptr = AllocFromHeapAtEnd(param0->unk00, 0x40);
+
+ st18 += ((stc[r6] & 0x3ff) << 5);
+ for (i = 0; i < 0x20; i++)
+ {
+ ptr[(i << 1)] = (u8)(((u8 *)st18)[i] & 0xf);
+ ptr[(i << 1) + 1] = (u8)(((u8 *)st18)[i] >> 4);
+ }
+
+ FUN_0201B118(param0, (u8)((stc[r6] >> 0xa) & 3), ptr);
+
+ r5 = ptr[st14 + (st10 << 3)];
+ FreeToHeap(ptr);
+
+ if ((param4[0] & (1 << r5)) != 0)
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ if (param0->unk08[param1].unk1c != 1)
+ {
+ u16 *r4 = param0->unk08[param1].unk08;
+ u8 *ptr = AllocFromHeapAtEnd(param0->unk00, 0x40);
+
+ memcpy(ptr, st18 + ((r4[r6] & 0x3ff) << 6), 0x40);
+
+ FUN_0201B118(param0, (u8)((r4[r6] >> 0xa) & 3), ptr);
+
+ r5 = ptr[st14 + (st10 << 3)];
+ FreeToHeap(ptr);
+ }
+ else
+ {
+ r5 = ((u8 *)st18)[(((u8 *)param0->unk08[param1].unk08)[r6] << 6) + st14 + (st10 << 3)];
+ }
+
+ while (TRUE)
+ {
+ if (param4[0] == 0xffff)
+ {
+ break;
+ }
+ if (r5 == (u8)(param4[0]))
+ {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+THUMB_FUNC void FUN_0201B118(struct UnkStruct_02016B94_2 *param0, u8 param1, u8 *param2)
+{
+ u8 i, j;
+ if (param1 != 0)
+ {
+ u8 *ptr = AllocFromHeapAtEnd(param0->unk00, 0x40);
+
+ if ((param1 & 1) != 0)
+ {
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ ptr[i * 8 + j] = param2[i * 8 + (7 - j)];
+ }
+ }
+
+ memcpy(param2, ptr, 0x40);
+ }
+
+ if ((param1 & 2) != 0)
+ {
+ for (i = 0; i < 8; i++)
+ {
+ u8 *r3 = &ptr[i * 8];
+ u8 *r2 = &param2[(7 - i) * 8];
+ for (u32 j = 8; j > 0; j--)
+ {
+ *r3++ = *r2++;
+ }
+ }
+
+ memcpy(param2, ptr, 0x40);
+ }
+
+ FreeToHeap(ptr);
+ }
+}
diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c
index cd66a136..ebc600fa 100644
--- a/arm9/src/unk_02021934.c
+++ b/arm9/src/unk_02021934.c
@@ -109,31 +109,31 @@ struct String * StringDup(struct String * src, u32 heap_id)
return dest;
}
-static const u16 sCharset_JP[10] = {
- 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
- 0xA7, 0xA8, 0xA9, 0xAA, 0xAB
-};
-
-static const u16 sCharset_EN[10] = {
- 0x121, 0x122, 0x123, 0x124, 0x125,
- 0x126, 0x127, 0x128, 0x129, 0x12A
-};
-
-static const u32 sPowersOfTen[10] = {
- 1,
- 10,
- 100,
- 1000,
- 10000,
- 100000,
- 1000000,
- 10000000,
- 100000000,
- 1000000000
-};
-
void String16_FormatInteger(struct String * str, int num, u32 ndigits, int strConvMode, BOOL whichCharset)
{
+ static const u16 sCharset_EN[10] = {
+ 0x121, 0x122, 0x123, 0x124, 0x125,
+ 0x126, 0x127, 0x128, 0x129, 0x12A
+ };
+
+ static const u16 sCharset_JP[10] = {
+ 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
+ 0xA7, 0xA8, 0xA9, 0xAA, 0xAB
+ };
+
+ static const u32 sPowersOfTen[10] = {
+ 1,
+ 10,
+ 100,
+ 1000,
+ 10000,
+ 100000,
+ 1000000,
+ 10000000,
+ 100000000,
+ 1000000000
+ };
+
ASSERT_STR16(str);
const u16 * charbase;
diff --git a/arm9/src/unk_02022504.c b/arm9/src/unk_02022504.c
new file mode 100644
index 00000000..7f50815b
--- /dev/null
+++ b/arm9/src/unk_02022504.c
@@ -0,0 +1,32 @@
+#include "global.h"
+#include "unk_02022504.h"
+
+THUMB_FUNC void *FUN_02022504(struct SaveBlock2 *sav2)
+{
+ return SavArray_get(sav2, 27);
+}
+
+THUMB_FUNC struct PCStorage *GetStoragePCPointer(struct SaveBlock2 *sav2)
+{
+ return SavArray_get(sav2, 35);
+}
+
+THUMB_FUNC void *FUN_0202251C(struct SaveBlock2 *sav2)
+{
+ return SavArray_get(sav2, 31);
+}
+
+THUMB_FUNC void *FUN_02022528(struct SaveBlock2 *sav2)
+{
+ return SavArray_get(sav2, 32);
+}
+
+THUMB_FUNC u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p)
+{
+ return ReadSaveFileFromFlash(sav2, heap_id, 0, ret_p);
+}
+
+THUMB_FUNC s32 SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data)
+{
+ return WriteSaveFileToFlash(sav2, 0, data);
+}
diff --git a/arm9/src/unk_02024E64.c b/arm9/src/unk_02024E64.c
index d8682531..ad6a7eac 100644
--- a/arm9/src/unk_02024E64.c
+++ b/arm9/src/unk_02024E64.c
@@ -10,14 +10,14 @@ THUMB_FUNC u32 FUN_02024E64()
THUMB_FUNC void FUN_02024E6C(struct UnkStruct_02024E64 *param0)
{
- MIi_CpuClearFast(0, param0, sizeof(struct UnkStruct_02024E64));
+ MI_CpuClearFast(param0, sizeof(struct UnkStruct_02024E64));
FUN_020250A4(param0->unk0);
FUN_02025484(param0->unk700);
- MIi_CpuClear16(0xFFFF, param0->rival_name_buf, sizeof(param0->rival_name_buf) / sizeof(u16));
- MIi_CpuClear16(0xFFFF, param0->unk734, sizeof(param0->unk734) / sizeof(u16));
+ MI_CpuFill16(param0->rival_name_buf, EOS, sizeof(param0->rival_name_buf) / sizeof(u16));
+ MI_CpuFill16(param0->unk734, EOS, sizeof(param0->unk734) / sizeof(u16));
}
THUMB_FUNC struct UnkStruct_02024E64 *FUN_02024EB4(struct SaveBlock2 *sav2)
diff --git a/arm9/src/unk_02025484.c b/arm9/src/unk_02025484.c
index 733ac23a..96da04c9 100644
--- a/arm9/src/unk_02025484.c
+++ b/arm9/src/unk_02025484.c
@@ -3,14 +3,14 @@
#include "error_handling.h"
#include "unk_02025484.h"
-THUMB_FUNC void FUN_02025484(struct unk_2025484 *r0, u32 r1)
+THUMB_FUNC void FUN_02025484(struct unk_2025484 *r0)
{
MI_CpuFill8(r0, 0, sizeof(struct unk_2025484));
}
THUMB_FUNC u32 *FUN_02025490(struct unk_2025484 *r0, u32 r1)
{
- FUN_02025484(r0, r1);
+ FUN_02025484(r0);
r0->unk0 = r1;
return &r0->unk4;
}
diff --git a/arm9/src/unk_020286F8.c b/arm9/src/unk_020286F8.c
index f54d1e2e..a23a94ff 100644
--- a/arm9/src/unk_020286F8.c
+++ b/arm9/src/unk_020286F8.c
@@ -75,9 +75,9 @@ void FUN_020287C0(struct UnkSaveStruct_020286F8 * ptr, u32 i, u32 j, struct Stri
CopyStringToU16Array(k, ptr[i].unk_10, 8);
}
-void FUN_020287EC(struct UnkSaveStruct_020286F8 * ptr, u32 i, u8 j)
+void FUN_020287EC(struct UnkSaveStruct_020286F8 * ptr, u32 i, u32 j)
{
- ptr[i].unk_20 = j;
+ ptr[i].unk_20 = (u8)j;
}
u8 FUN_020287F8(struct UnkSaveStruct_020286F8 * ptr, u32 i)
@@ -90,10 +90,9 @@ u8 FUN_02028804(struct UnkSaveStruct_020286F8 * ptr, u32 i)
return ptr[i].unk_21;
}
-
-void FUN_02028810(struct UnkSaveStruct_020286F8 * ptr, u32 i, u8 j)
+void FUN_02028810(struct UnkSaveStruct_020286F8 * ptr, u32 i, u32 j)
{
- ptr[i].unk_21 = j;
+ ptr[i].unk_21 = (u8)j;
}
struct UnkSaveStruct_020286F8 * FUN_0202881C(struct SaveBlock2 * sav2)
diff --git a/arm9/src/unk_0202ABBC.c b/arm9/src/unk_0202ABBC.c
index 7bc9d3fc..75a43f60 100644
--- a/arm9/src/unk_0202ABBC.c
+++ b/arm9/src/unk_0202ABBC.c
@@ -15,7 +15,7 @@ THUMB_FUNC u32 FUN_0202ABC8()
THUMB_FUNC void FUN_0202ABCC(struct Unk0202ABBC* unk)
{
- MIi_CpuClearFast(0, unk, 0xf4);
+ MI_CpuClearFast(unk, sizeof(struct Unk0202ABBC));
}
THUMB_FUNC u16 FUN_0202ABDC(struct Unk0202ABBC* unk)
@@ -30,12 +30,12 @@ THUMB_FUNC void FUN_0202ABE4(struct Unk0202ABBC* unk, u16 data)
THUMB_FUNC void FUN_0202ABEC(void *srcp, void *destp)
{
- MIi_CpuCopyFast(srcp, destp, 0xec);
+ MI_CpuCopyFast(srcp, destp, 0xec);
}
THUMB_FUNC void FUN_0202ABF8(void *destp, void *srcp)
{
- MIi_CpuCopyFast(srcp, destp, 0xec);
+ MI_CpuCopyFast(srcp, destp, 0xec);
}
THUMB_FUNC u32 FUN_0202AC08(struct Unk0202ABBC* unk)
diff --git a/arm9/src/unk_0202D858.c b/arm9/src/unk_0202D858.c
new file mode 100644
index 00000000..45c7c776
--- /dev/null
+++ b/arm9/src/unk_0202D858.c
@@ -0,0 +1,96 @@
+#include "unk_0202D858.h"
+
+struct UnkStruct_0202D858
+{
+ u8 unk00[0x1a];
+};
+
+static const struct UnkStruct_0202D858 UNK_020EEB04 = { {
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x03,
+ 0x03,
+ 0x03,
+ 0x04,
+ 0x03,
+ 0x04,
+ 0x07,
+ 0x03,
+ 0x07,
+ 0x04,
+ 0x01,
+ 0x04,
+ 0x01,
+ 0x01,
+ 0x04,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x00,
+ 0x00,
+} };
+
+static const struct UnkStruct_0202D858 UNK_020EEB1E = { {
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x03,
+ 0x03,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x00,
+ 0x00,
+} };
+
+THUMB_FUNC u8 FUN_0202D858(u16 param0)
+{
+ struct UnkStruct_0202D858 st0 = UNK_020EEB04;
+
+ GF_ASSERT(param0 < 0x1a);
+
+ return st0.unk00[param0];
+}
+
+THUMB_FUNC u8 FUN_0202D884(u16 param0)
+{
+ struct UnkStruct_0202D858 st0 = UNK_020EEB1E;
+
+ GF_ASSERT(param0 < 0x1a);
+
+ return st0.unk00[param0];
+}
+
+THUMB_FUNC u32 FUN_0202D8B0(int param0)
+{
+ switch (param0)
+ {
+ case 0x7:
+ case 0x9:
+ case 0xd:
+ case 0x12:
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/arm9/src/unk_0202E29C.c b/arm9/src/unk_0202E29C.c
new file mode 100644
index 00000000..2b088d6f
--- /dev/null
+++ b/arm9/src/unk_0202E29C.c
@@ -0,0 +1,1087 @@
+#include "global.h"
+#include "unk_0202E29C.h"
+#include "MI_memory.h"
+#include "OS_cache.h"
+#include "game_init.h"
+#include "heap.h"
+#include "mail_message.h"
+#include "player_data.h"
+#include "unk_0202D858.h"
+#include "unk_0202F150.h"
+#include "unk_02031734.h"
+
+struct UnkStruct_0202E29C_const
+{
+ u8 unk0[6];
+};
+
+const struct UnkStruct_0202E29C_const UNK_020EEC40 = { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
+
+u16 UNK_021C59E8;
+struct UnkStruct_0202E29C *UNK_021C59F0;
+u32 UNK_021C59EC;
+
+extern u32 FUN_0202CEEC();
+extern u32 FUN_02023AC4();
+extern u32 FUN_02090DB8(u32 param0, void (*param1)(u32, u32), u32 param2);
+extern void FUN_02090CC8(void (*param0)(), u32 param1);
+extern void FUN_0202CE64(void *param0);
+extern void FUN_0202CB70(u32 param0);
+extern void FUN_0202D2F4();
+extern void FUN_0202D0A0(void (*param0)(u32, u8 *, u32), u32 param1);
+extern u32 FUN_0202CBD4();
+extern u32 FUN_0202CBFC();
+extern u32 FUN_0202C570(void (*param0)(struct UnkStruct_0202E29C_sub *, u32), u8 *param1, u32 param2);
+extern u32 FUN_0202D21C();
+extern void FUN_0202C770();
+extern u32 FUN_0202D1E4();
+extern void FUN_0202D100();
+extern u32 FUN_0202D1C8();
+extern u32 FUN_0202D200();
+extern void FUN_0202C4D8(u32 param0, u8 *param1, u32 param2);
+extern void FUN_0202D034(u32 param0, struct UnkStruct_0202E29C_sub *param1);
+extern u32 FUN_0202D358();
+extern void FUN_0202CB7C(void *param0, u32 param1);
+extern void FUN_0202D240(void *param0, u32 size, u32 param2, u32 param3);
+extern void FUN_0202DF54();
+extern u16 FUN_0202D19C();
+extern u32 FUN_0202CBE8();
+extern u32 FUN_0202D178();
+extern u16 FUN_0202CDA4();
+extern void FUN_0202CF84(u32 param0, u16 param1, u16 param2, u32 param3, u32 param4, u32 param5);
+extern u32 FUN_0202CB8C();
+extern u16 WM_GetDispersionBeaconPeriod();
+extern BOOL FUN_0202D2D0();
+
+THUMB_FUNC void FUN_0202E29C(struct PlayerData *player_data)
+{
+ if (UNK_021C59F0 == NULL)
+ {
+ UNK_021C59F0 = AllocFromHeap(0xf, sizeof(struct UnkStruct_0202E29C));
+ MI_CpuFill8(UNK_021C59F0, 0, sizeof(struct UnkStruct_0202E29C));
+
+ UNK_021C59F0->unkCA4 = AllocFromHeap(0xf, FUN_0202CEEC());
+ MI_CpuFill8(UNK_021C59F0->unkCA4, 0, FUN_0202CEEC());
+
+ UNK_021C59F0->unkCBC = AllocFromHeap(0xf, FUN_02023AC4());
+ MI_CpuFill8(UNK_021C59F0->unkCBC, 0, FUN_02023AC4());
+
+ UNK_021C59F0->unkCC0 = 0x333;
+ UNK_021C59F0->unkCB8 = player_data;
+
+ MailMsg_init(&UNK_021C59F0->unkCA8);
+ FUN_0202E500();
+ }
+}
+
+THUMB_FUNC BOOL FUN_0202E344()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0202E358(u8 *param0, u8 *param1, s32 param2)
+{
+ int i = 0;
+ while (i < param2)
+ {
+ if (*param0 != *param1)
+ {
+ return FALSE;
+ }
+
+ i++;
+ param0++;
+ param1++;
+ }
+
+ return TRUE;
+}
+
+THUMB_FUNC void FUN_0202E380(struct UnkStruct_0202E29C_sub *param0, u32 param1)
+{
+#pragma unused(param1)
+ s32 r5 = FUN_02033534();
+ u8 r6 = FUN_0203354C();
+ struct UnkStruct_0202E29C_sub4 *r4 = &param0->unk50;
+
+ if (r5 != 0xe)
+ {
+ if (FUN_0202D8B0(r4->unk04) == 0 || FUN_0202D8B0(r5) == 0)
+ {
+ if (r4->unk30[0x24] != 0)
+ {
+ if (r4->unk04 == 0xa)
+ {
+ return;
+ }
+ }
+
+ if (r4->unk04 != r5)
+ {
+ return;
+ }
+ }
+ }
+
+ if (r5 != 0xe)
+ {
+ if (r4->unk05 != r6)
+ {
+ return;
+ }
+ }
+
+ for (int i = 0; i < 0x10; i++)
+ {
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ continue;
+ }
+
+ if (!FUN_0202E358(UNK_021C59F0->unk054[i].unk04, param0->unk04, 6))
+ {
+ continue;
+ }
+
+ UNK_021C59F0->unkC84[i] = 0x96;
+
+ MI_CpuCopy8(param0, &UNK_021C59F0->unk054[i], sizeof(struct UnkStruct_0202E29C_sub));
+ return;
+ }
+
+ int i;
+ for (i = 0; i < 0x10; i++)
+ {
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ break;
+ }
+ }
+
+ if (i < 0x10)
+ {
+ UNK_021C59F0->unkC84[i] = 0x96;
+ MI_CpuCopy8(param0, &UNK_021C59F0->unk054[i], sizeof(struct UnkStruct_0202E29C_sub));
+ UNK_021C59F0->unkCB4 = 1;
+ }
+}
+
+THUMB_FUNC void FUN_0202E470(u32 param0, u32 param1)
+{
+#pragma unused(param0)
+ if (param1 != 0)
+ {
+ OS_Terminate();
+ }
+
+ UNK_021C59EC = 2;
+}
+
+THUMB_FUNC void FUN_0202E488()
+{
+ UNK_021C59EC = 0;
+ FUN_02016454(4);
+}
+
+THUMB_FUNC void FUN_0202E49C()
+{
+ FUN_02016444(4);
+ UNK_021C59EC = 1;
+ if (FUN_02090DB8(8, FUN_0202E470, 0) != 1)
+ {
+ OS_Terminate();
+ }
+}
+
+THUMB_FUNC BOOL FUN_0202E4C8()
+{
+ if (UNK_021C59EC == 2)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0202E4DC()
+{
+ if (UNK_021C59EC != 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_0202E4F0()
+{
+ FUN_02090CC8(FUN_0202E488, 0);
+}
+
+THUMB_FUNC void FUN_0202E500()
+{
+ UNK_021C59F0->unkCB0 = 0;
+ FUN_0202CE64(UNK_021C59F0->unkCA4 + (32 - (u32)(UNK_021C59F0->unkCA4) % 32));
+
+ FUN_0202CB70(UNK_021C59F0->unkCC0);
+}
+
+THUMB_FUNC void FUN_0202E538()
+{
+ for (int i = 0; i < 0x10; i++)
+ {
+ UNK_021C59F0->unkC84[i] = 0;
+ }
+
+ MI_CpuFill8(UNK_021C59F0->unk054, 0, 0xC00);
+}
+
+THUMB_FUNC void FUN_0202E56C(u32 param0)
+{
+ UNK_021C59F0->unkDAD_3 = (u8)param0;
+}
+
+THUMB_FUNC void FUN_0202E594()
+{
+ UNK_021C59F0->unkCB4 = 0;
+
+ UNK_021C59F0->unkDAD_0 = 0;
+
+ UNK_021C59F0->unkDAD_2 = 0;
+
+ UNK_021C59F0->unkDAA = 0;
+
+ UNK_021C59F0->unkDAD_4 = 0;
+
+ UNK_021C59F0->unkDAC = 0;
+
+ UNK_021C59F0->unkDAB = 0;
+}
+
+THUMB_FUNC BOOL FUN_0202E5F8(u32 param0, u32 param1, u32 param2)
+{
+#pragma unused(param0)
+ FUN_0202E594();
+ FUN_0202E56C(param1);
+ FUN_0202D2F4();
+
+ if (UNK_021C59F0->unkDAB == 0)
+ {
+ FUN_0202D0A0(FUN_020303BC, 0xe);
+ UNK_021C59F0->unkDAB = 1;
+ }
+
+ UNK_021C59F0->unkDAD_5 = (u8)param2;
+ if (FUN_0202CBD4() == 1 && FUN_0202CBFC() != 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC u32 FUN_0202E66C(u32 param0, u32 param1)
+{
+#pragma unused(param0)
+ FUN_0202E594();
+ if (param1 != 0)
+ {
+ FUN_0202E538();
+ }
+
+ if (UNK_021C59F0->unkDAB == 0)
+ {
+ FUN_0202D0A0(FUN_02030238, 0xe);
+ UNK_021C59F0->unkDAB = 1;
+ }
+
+ if (FUN_0202CBD4() == 1)
+ {
+ struct UnkStruct_0202E29C_const st0 = UNK_020EEC40;
+
+ if (FUN_0202C570(FUN_0202E380, st0.unk0, 0) != 0)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+THUMB_FUNC u32 FUN_0202E6F0()
+{
+ if (UNK_021C59F0 == NULL)
+ {
+ return 1;
+ }
+
+ switch (UNK_021C59F0->unkDAC)
+ {
+ case 0:
+ if (FUN_0202D21C() != 0)
+ {
+ FUN_0202C770();
+ UNK_021C59F0->unkDAC = 1;
+ }
+ else if (FUN_0202D1E4() == 0)
+ {
+ FUN_0202D100();
+ UNK_021C59F0->unkDAC = 2;
+ }
+ break;
+
+ case 1:
+ if (FUN_0202D1E4() == 0)
+ {
+ FUN_0202D100();
+ UNK_021C59F0->unkDAC = 2;
+ }
+ break;
+ case 2:
+ if (FUN_0202D1C8() != 0)
+ {
+ return 1;
+ }
+
+ if (FUN_0202D200() != 0)
+ {
+ UNK_021C59F0->unkDAC = 1;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC BOOL FUN_0202E784()
+{
+ if (UNK_021C59F0 != NULL && UNK_021C59F0->unkDAA == 0)
+ {
+ UNK_021C59F0->unkDAA = 1;
+ FUN_0202D100();
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_0202E7B0(u32 param0)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ if (param0 != 0)
+ {
+ UNK_021C59F0->unkDAA = 2;
+ return;
+ }
+
+ UNK_021C59F0->unkDAA = 0;
+ FUN_0202E500();
+ }
+}
+
+THUMB_FUNC void FUN_0202E7D8()
+{
+ FreeToHeap(UNK_021C59F0->unkCBC);
+ FreeToHeap(UNK_021C59F0->unkCA4);
+ FreeToHeap(UNK_021C59F0);
+
+ UNK_021C59F0 = NULL;
+}
+
+THUMB_FUNC u32 FUN_0202E810()
+{
+ if (FUN_02030F40() == 0)
+ {
+ return 0;
+ }
+
+ u32 count = 0;
+ for (int i = 0; i < 0x10; i++)
+ {
+ if (UNK_021C59F0->unkC84[i] != 0)
+ {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+THUMB_FUNC s32 FUN_0202E844(u32 param0)
+{
+ int i;
+ u32 count = 0;
+ for (i = 0; i < 0x10; i++)
+ {
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ continue;
+ }
+
+ if (count == param0)
+ {
+ return i;
+ }
+
+ count++;
+ }
+
+ GF_AssertFail();
+ return 0;
+}
+
+THUMB_FUNC u8 FUN_0202E878()
+{
+ return UNK_021C59F0->unkCB4;
+}
+
+THUMB_FUNC void FUN_0202E88C()
+{
+ UNK_021C59F0->unkCB4 = 0;
+}
+
+THUMB_FUNC s32 FUN_0202E8A0(s32 param0)
+{
+ if (UNK_021C59F0->unkC84[param0] != 0)
+ {
+ if (UNK_021C59F0->unk054[param0].unk50.unk06 == 0)
+ {
+ return 1;
+ }
+ else
+ {
+ return UNK_021C59F0->unk054[param0].unk50.unk06;
+ }
+ }
+
+ return 0;
+}
+
+THUMB_FUNC s32 FUN_0202E8D0(s32 param0)
+{
+ for (int i = 0xf; i >= 0; i--)
+ {
+ s32 ret = FUN_0202E8A0(i);
+ if (ret > param0 && 8 > ret)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+THUMB_FUNC s32 FUN_0202E8F4()
+{
+ if (FUN_0202E810() == 0)
+ {
+ return -1;
+ }
+
+ for (int i = 0xf; i >= 0; i--)
+ {
+ if (UNK_021C59F0->unkC84[i] != 0 && FUN_0202EFE4(UNK_021C59F0->unk054[i].unk04))
+ {
+ s32 ret2 = FUN_0202E8A0(i);
+ if (ret2 > 1 && ret2 < 8)
+ {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+}
+
+THUMB_FUNC s32 FUN_0202E950()
+{
+ if (FUN_0202E810() == 0)
+ {
+ return -1;
+ }
+
+ for (int i = 0xf; i >= 0; i--)
+ {
+ if (UNK_021C59F0->unkC84[i] != 0 && FUN_0202EFE4(UNK_021C59F0->unk054[i].unk04))
+ {
+
+ return i;
+ }
+ }
+
+ s32 ret = FUN_0202E8D0(1);
+ if (ret == -1)
+ {
+ return FUN_0202E8D0(0);
+ }
+
+ return ret;
+}
+
+THUMB_FUNC void FUN_0202E9AC(u32 param0, struct PlayerData *player_data)
+{
+ int i;
+ u32 count = 0;
+ for (i = 0; i < 0x10; i++)
+ {
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ continue;
+ }
+
+ if (param0 == count)
+ {
+
+ PlayerProfile_Copy(FUN_0202EF84(i), player_data);
+ return;
+ }
+
+ count++;
+ }
+}
+
+THUMB_FUNC u32 FUN_0202E9E8(u32 param0)
+{
+ if (FUN_0202CBD4() == 2)
+ {
+ FUN_0202C770();
+ return 0;
+ }
+
+ if (FUN_0202CBD4() == 1)
+ {
+ s32 ret = FUN_02033534();
+ UNK_021C59F0->unkDA8 = (u8)UNK_021C59F0->unk054[param0].unk36;
+ if (FUN_0202D8B0(ret) != 0)
+ {
+ FUN_0202C4D8(1, UNK_021C59F0->unk054[param0].unk04, 0);
+ }
+ else
+ {
+ FUN_0202D034(1, &UNK_021C59F0->unk054[param0]);
+ }
+
+ return 1;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_0202EA54()
+{
+ for (int i = 0; i < 0x10; i++)
+ {
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ continue;
+ }
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ continue;
+ }
+
+ UNK_021C59F0->unkC84[i]--;
+
+ if (UNK_021C59F0->unkC84[i] == 0)
+ {
+ UNK_021C59F0->unkCB4 = 1;
+ }
+ }
+}
+
+THUMB_FUNC void FUN_0202EA9C()
+{
+ s32 res = FUN_02033534();
+ struct PlayerData *player_data = FUN_0202EF70();
+
+ if (res != 0xf)
+ {
+ struct UnkStruct_0202E29C_sub2 *res = &UNK_021C59F0->unkCC4;
+ GF_ASSERT((s32)FUN_02023AC4() <= 0x20);
+ GF_ASSERT(PlayerProfile_sizeof() == 0x20);
+
+ MI_CpuCopy8(player_data, &res->unk08.unk08, PlayerProfile_sizeof());
+
+ MI_CpuCopy8(UNK_021C59F0->unkCBC, res->unk08.unk28, FUN_02023AC4());
+
+ res->unk00 = PlayerProfile_GetTrainerID(player_data);
+ res->unk04 = (u8)FUN_02033534();
+ res->unk05 = FUN_0203354C();
+
+ MI_CpuCopy8(&UNK_021C59F0->unkCA8, &res->unk08.unk00, sizeof(struct MailMessage));
+ res->unk08.unk4C = (u8)FUN_0202D358();
+ }
+ else
+ {
+ struct UnkStruct_0202E29C_sub2 *res = &UNK_021C59F0->unkCC4;
+ res->unk00 = PlayerProfile_GetTrainerID(player_data);
+ res->unk04 = (u8)FUN_02033534();
+ res->unk05 = FUN_0203354C();
+
+ MI_CpuCopy8(&UNK_021C59F0->unk000, &res->unk08, sizeof(struct UnkStruct_0202E29C_sub3));
+ }
+
+ DC_FlushRange(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2));
+ FUN_0202CB7C(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2));
+}
+
+THUMB_FUNC void FUN_0202EB7C()
+{
+ struct UnkStruct_0202E29C_sub2 *r4 = &UNK_021C59F0->unkCC4;
+ if (r4->unk06 != FUN_0202EDB8())
+ {
+ r4->unk06 = (u8)FUN_0202EDB8();
+ DC_FlushRange(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2));
+ FUN_0202CB7C(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2));
+
+ FUN_0202D240(&UNK_021C59F0->unkCC4,
+ sizeof(struct UnkStruct_0202E29C_sub2),
+ UNK_021C59F0->unkCC0,
+ UNK_021C59E8);
+ }
+}
+
+THUMB_FUNC void FUN_0202EBD0(u16 param0)
+{
+ u32 r5 = FUN_0202CBD4();
+ FUN_0202DF54();
+ FUN_0202EB7C();
+
+ if (FUN_0202D19C() == 0 && FUN_0202EE24() == 0 && UNK_021C59F0->unkDAD_2)
+ {
+ UNK_021C59F0->unkDAD_0 = 1;
+ }
+
+ if (UNK_021C59F0->unkDA6 == 0xFFFF)
+ {
+ UNK_021C59F0->unkDA6 = param0;
+ }
+
+ if (UNK_021C59F0->unkDAD_1 &&
+ UNK_021C59F0->unkDA6 > param0)
+ {
+ UNK_021C59F0->unkDAD_0 = 1;
+ }
+
+ if (FUN_0202CBE8() == 25)
+ {
+ FUN_020335D0(0);
+ }
+
+ switch (r5)
+ {
+ case 0:
+ if (UNK_021C59F0->unkDAA == 1)
+ {
+ FUN_0202E7D8();
+ return;
+ }
+ else if (UNK_021C59F0->unkDAA == 2)
+ {
+ UNK_021C59F0->unkDAA = 3;
+ }
+ break;
+
+ case 1:
+ if (UNK_021C59F0->unkDAA == 1 && FUN_0202D178() != 0)
+ {
+ return;
+ }
+
+ if (UNK_021C59F0->unkDAA == 2 && FUN_0202D178() != 0)
+ {
+ return;
+ }
+
+ break;
+
+ case 8:
+ case 9:
+
+ if (UNK_021C59F0 != NULL)
+ {
+ UNK_021C59F0->unkDAD_0 = 1;
+ return;
+ }
+ break;
+
+ case 7:
+ u16 r0 = FUN_0202CDA4();
+ if (UNK_021C59F0->unkDA9 == 0)
+ {
+ UNK_021C59F0->unkDA4 = r0;
+ UNK_021C59F0->unkDA9 = 5;
+ }
+ else
+ {
+ UNK_021C59F0->unkDA9--;
+ }
+
+ u16 r5 = UNK_021C59F0->unkDA4;
+ if (UNK_021C59F0->unkDAD_3)
+ {
+ UNK_021C59E8++;
+ }
+
+ FUN_0202EA9C();
+
+ FUN_0202CF84(0,
+ UNK_021C59E8,
+ r5,
+ FUN_0202D858((u16)FUN_02033534()),
+ FUN_0202EEE8((u16)FUN_02033534()),
+ UNK_021C59F0->unkDAD_5);
+
+ UNK_021C59F0->unkDA8 = (u8)r5;
+
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_0202ED70(u16 param0)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ FUN_0202EBD0(param0);
+ }
+}
+
+THUMB_FUNC u32 FUN_0202ED84(u16 param0)
+{
+ if (UNK_021C59F0 == NULL)
+ {
+ return 0;
+ }
+
+ if (FUN_0202CBD4() != 4)
+ {
+ return 0;
+ }
+
+ if ((FUN_0202CB8C() & (1 << param0)) == 0)
+ {
+ return 0;
+ }
+
+ return 1;
+}
+
+THUMB_FUNC u32 FUN_0202EDB8()
+{
+ u32 count = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ if (FUN_0202ED84((u16)i) != 0)
+ {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+THUMB_FUNC BOOL FUN_0202EDD8()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ if (UNK_021C59F0->unkDAA == 3)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0202EDF8()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC u32 FUN_0202EE0C()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ return FUN_0202D1C8();
+ }
+
+ return 1;
+}
+
+THUMB_FUNC u32 FUN_0202EE24()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ return FUN_0202CB8C() & 0xFFFE;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC BOOL FUN_0202EE44()
+{
+ if (FUN_0202EE60() && FUN_0202CBE8() == 0x14)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL FUN_0202EE60()
+{
+ if (UNK_021C59F0 != NULL && UNK_021C59F0->unkDAD_0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_0202EE84(u32 param0)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ UNK_021C59F0->unkDAD_2 = (u8)param0;
+ }
+}
+
+THUMB_FUNC void FUN_0202EEB0(u32 param0)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ UNK_021C59F0->unkDAD_1 = (u8)param0;
+
+ UNK_021C59F0->unkDA6 = 0xFFFF;
+ }
+}
+
+THUMB_FUNC u32 FUN_0202EEE8(u16 param0)
+{
+ u16 r4 = WM_GetDispersionBeaconPeriod();
+ GF_ASSERT(param0 < 0x1a);
+
+ if (param0 == 0xa)
+ {
+ return (u32)(r4 << 0xe) >> 0x10;
+ }
+
+ if (param0 == 9 || param0 == 0xd)
+ {
+ return (u32)(r4 << 0xe) >> 0x10;
+ }
+
+ return r4;
+}
+
+THUMB_FUNC struct UnkStruct_0202E29C_sub *FUN_0202EF18(u32 param0)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ if (UNK_021C59F0->unkC84[param0] != 0)
+ {
+ return &UNK_021C59F0->unk054[param0];
+ }
+ }
+
+ return NULL;
+}
+
+THUMB_FUNC struct UnkStruct_0202E29C_sub4 *FUN_0202EF44(s32 param0)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ if (UNK_021C59F0->unkC84[param0] != 0)
+ {
+ return &UNK_021C59F0->unk054[param0].unk50;
+ }
+ }
+
+ return NULL;
+}
+
+THUMB_FUNC struct PlayerData *FUN_0202EF70()
+{
+ return UNK_021C59F0->unkCB8;
+}
+
+THUMB_FUNC struct PlayerData *FUN_0202EF84(int param0)
+{
+ if (UNK_021C59F0->unkC84[param0] == 0)
+ {
+ return NULL;
+ }
+
+ struct UnkStruct_0202E29C_sub4 *r0 = &UNK_021C59F0->unk054[param0].unk50;
+
+ return &r0->unk10;
+}
+
+THUMB_FUNC void FUN_0202EFAC(u8 *param0, s32 param1)
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ GF_ASSERT(param1 < 8);
+
+ MI_CpuCopy8(param0, UNK_021C59F0->unkC54[param1], 6);
+ }
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC BOOL FUN_0202EFE4(u8 *param0)
+{
+ u8 (*ptr)[6] = UNK_021C59F0->unkC54;
+ for (int i = 0; i < 8; i++)
+ {
+ if (ptr[i][0] != param0[0])
+ continue;
+ if (ptr[i][1] != param0[1])
+ continue;
+ if (ptr[i][2] != param0[2])
+ continue;
+ if (ptr[i][3] != param0[3])
+ continue;
+ if (ptr[i][4] != param0[4])
+ continue;
+ if (ptr[i][5] != param0[5])
+ continue;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+#else
+THUMB_FUNC asm BOOL FUN_0202EFE4(u8 *param0)
+{
+ // clang-format off
+ push {r4-r5}
+ ldr r2, =UNK_021C59E8
+ mov r1, #0x0
+ ldr r3, [r2, #0x8]
+ ldr r2, =0x00000C54
+ add r2, r3, r2
+ ldrb r3, [r0, #0x0]
+_0202EFF2:
+ ldrb r4, [r2, #0x0]
+ cmp r4, r3
+ bne _0202F026
+ ldrb r5, [r2, #0x1]
+ ldrb r4, [r0, #0x1]
+ cmp r5, r4
+ bne _0202F026
+ ldrb r5, [r2, #0x2]
+ ldrb r4, [r0, #0x2]
+ cmp r5, r4
+ bne _0202F026
+ ldrb r5, [r2, #0x3]
+ ldrb r4, [r0, #0x3]
+ cmp r5, r4
+ bne _0202F026
+ ldrb r5, [r2, #0x4]
+ ldrb r4, [r0, #0x4]
+ cmp r5, r4
+ bne _0202F026
+ ldrb r5, [r2, #0x5]
+ ldrb r4, [r0, #0x5]
+ cmp r5, r4
+ bne _0202F026
+ mov r0, #0x1
+ pop {r4-r5}
+ bx lr
+_0202F026:
+ add r1, r1, #0x1
+ add r2, r2, #0x6
+ cmp r1, #0x8
+ blt _0202EFF2
+ mov r0, #0x0
+ pop {r4-r5}
+ bx lr
+ // clang-format on
+}
+#endif
+
+THUMB_FUNC u32 FUN_0202F03C()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ return UNK_021C59F0->unkDAD_4;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_0202F05C()
+{
+ if (UNK_021C59F0 != NULL)
+ {
+ UNK_021C59F0->unkDAD_4 = 1;
+ }
+}
+
+THUMB_FUNC void FUN_0202F078(struct MailMessage *mail_message)
+{
+ MI_CpuCopy8(mail_message, &UNK_021C59F0->unkCA8, sizeof(struct MailMessage));
+}
+
+THUMB_FUNC void FUN_0202F094(void *param0)
+{
+ MI_CpuCopy8(param0, UNK_021C59F0->unkCBC, FUN_02023AC4());
+}
+
+THUMB_FUNC void FUN_0202F0B8()
+{
+ FUN_0202EA9C();
+ FUN_0202D240(&UNK_021C59F0->unkCC4,
+ sizeof(struct UnkStruct_0202E29C_sub2),
+ UNK_021C59F0->unkCC0,
+ UNK_021C59E8);
+}
+
+THUMB_FUNC u32 FUN_0202F0DC(u8 param0)
+{
+ int i;
+ u32 r5 = 0;
+ for (i = 0; i < 0x10; i++)
+ {
+ struct UnkStruct_0202E29C_sub4 *res = FUN_0202EF44(i);
+ if (res != 0 && res->unk04 == param0)
+ {
+ r5 += res->unk06;
+ }
+ }
+
+ return r5;
+}
+
+THUMB_FUNC BOOL FUN_0202F104()
+{
+ return FUN_0202D2D0();
+}
+
+THUMB_FUNC void FUN_0202F10C(struct UnkStruct_0202E29C_sub3 *param0)
+{
+ MI_CpuCopy8(param0, &UNK_021C59F0->unk000, sizeof(struct UnkStruct_0202E29C_sub3));
+ FUN_0202F0B8();
+}
+
+THUMB_FUNC u8 *FUN_0202F124(u32 param0)
+{
+ if (UNK_021C59F0 != NULL && UNK_021C59F0->unkC84[param0] != 0)
+ {
+ struct UnkStruct_0202E29C_sub4 *r0 = &UNK_021C59F0->unk054[param0].unk50;
+ return r0->unk08;
+ }
+
+ return NULL;
+}
diff --git a/arm9/src/unk_0202F150.c b/arm9/src/unk_0202F150.c
index 23a7de85..09b5b56f 100644
--- a/arm9/src/unk_0202F150.c
+++ b/arm9/src/unk_0202F150.c
@@ -1,38 +1,27 @@
#include "unk_0202F150.h"
+#include "unk_02031480.h"
+#include "unk_02031734.h"
+#include "unk_0202E29C.h"
+
+
struct
{
u8 unk00;
struct UnkStruct0202F150 *unk04;
} UNK_021C59F4;
-vu8 UNK_02105D58 = 4;
vu8 UNK_02105D59 = 4;
+vu8 UNK_02105D58 = 4;
-extern int FUN_02033534();
-extern u32 FUN_0202D858(u16 param0);
-extern void FUN_02031480(u32 param0);
extern void FUN_0202D7D8(u8 *param0, u32 param1, struct UnkStruct0202F150_sub1 *param2);
extern u32 FUN_0200CA60(void (*param0)(), u32 param1, u32 param2);
extern void FUN_0202D394(struct UnkStruct0202F150_sub1 *param0, u8 *param1, u32 param2);
extern void FUN_0202D804(u8 *param0);
-extern u32 FUN_0202E5F8(u32 param0, u32 param1, u32 param2);
extern void FUN_0202D330(void (*param0)(int));
-extern u32 FUN_0202E66C(u32 param0, u32 param1);
extern void MOD04_021D83C0();
-extern u32 FUN_0202E784();
-extern void FUN_020314D0();
extern void FUN_0202DBA4();
extern void FUN_0200CAB4(u32 param0);
extern void FUN_0202D824(u8 *param0);
-extern u32 FUN_0202E9E8(u32 param0);
-extern u32 FUN_0202F03C();
-extern u32 FUN_0202EE24();
-extern void FUN_02031CDC();
-extern void FUN_0202EBD0(u16 param0);
-extern void FUN_0202ED70(u32 param0);
-extern void FUN_020335F4(u32 param0);
-extern void FUN_020315A4();
-extern void FUN_0202E538();
extern u32 MOD04_021D78FC(void *param0, u32 param1);
extern u32 FUN_0202CBD4();
extern void FUN_0202D4BC(void *param0);
@@ -53,12 +42,7 @@ extern s16 FUN_0202D9A0(u32 param0);
extern u32 FUN_0202DA04(u32 param0);
extern void *FUN_0202DA40(u32 param0, u32 param1, u16 param2);
extern u32 MOD04_021D8018();
-extern u32 FUN_0202EDF8();
extern u16 FUN_0202D19C();
-extern void FUN_020334E8(u32 param0, u32 param1);
-extern u32 FUN_0202EE60();
-extern u32 FUN_0202D884(u16 param0);
-extern void FUN_0202F05C();
extern void GF_RTC_CopyDateTime(RTCDate *, RTCTime *);
extern void FUN_0202D830(u8 *param0, u32 param1);
extern u32 MOD04_021D8624();
@@ -69,7 +53,7 @@ THUMB_FUNC u32 FUN_0202F150(u32 param0, u32 param1)
UNK_021C59F4.unk00 = 0;
if (param0 != 0)
{
- u32 res = FUN_0202D858((u16)FUN_02033534()) + 1;
+ int res = FUN_0202D858((u16)FUN_02033534()) + 1;
if (UNK_021C59F4.unk04 != 0)
{
@@ -111,7 +95,7 @@ THUMB_FUNC u32 FUN_0202F150(u32 param0, u32 param1)
r4 = 1;
if (UNK_021C59F4.unk04 == 0)
{
- ErrorHandling();
+ GF_AssertFail();
}
}
@@ -148,7 +132,7 @@ THUMB_FUNC void FUN_0202F2F0()
UNK_021C59F4.unk04->unk67F = 0;
UNK_021C59F4.unk04->unk680 = 0;
- int res = (int)FUN_0202D858((u16)FUN_02033534()) + 1;
+ int res = FUN_0202D858((u16)FUN_02033534()) + 1;
MI_CpuFill8(UNK_021C59F4.unk04->unk458, 0, UNK_021C59F4.unk04->unk658 * res);
@@ -236,7 +220,7 @@ THUMB_FUNC void FUN_0202F5A4()
UNK_021C59F4.unk04->unk62C = 0;
UNK_021C59F4.unk04->unk62D = 0;
- int res = (int)FUN_0202D858((u16)FUN_02033534()) + 1;
+ int res = FUN_0202D858((u16)FUN_02033534()) + 1;
MI_CpuFill8(UNK_021C59F4.unk04->unk458, 0, UNK_021C59F4.unk04->unk658 * res);
@@ -352,9 +336,9 @@ THUMB_FUNC void FUN_0202F910(int param0)
FUN_0202F820(param0);
}
-THUMB_FUNC u32 FUN_0202F918(u32 param0, u32 param1, u32 param2, u32 param3)
+THUMB_FUNC BOOL FUN_0202F918(u32 param0, u32 param1, u32 param2, u32 param3)
{
- u32 ret = 1;
+ BOOL ret = TRUE;
if (FUN_02033534() < 0x13)
{
ret = FUN_0202E5F8(param0, param1, param3);
@@ -478,7 +462,7 @@ THUMB_FUNC void FUN_0202FA5C()
}
else
{
- if (FUN_0202E784() != 0)
+ if (FUN_0202E784())
{
r4 = 1;
}
@@ -541,7 +525,7 @@ THUMB_FUNC void FUN_0202FB58()
}
}
-THUMB_FUNC u32 FUN_0202FB80()
+THUMB_FUNC BOOL FUN_0202FB80()
{
FUN_02031CDC();
@@ -591,7 +575,7 @@ THUMB_FUNC u32 FUN_0202FB80()
FUN_020335F4(0);
FUN_020315A4();
- return 1;
+ return TRUE;
}
THUMB_FUNC void FUN_0202FC60()
@@ -883,7 +867,7 @@ THUMB_FUNC void FUN_0202FEEC()
}
int st0 = FUN_02031228((u16)FUN_02033534());
- int r6 = (int)FUN_0202D858((u16)FUN_02033534()) + 1;
+ int r6 = FUN_0202D858((u16)FUN_02033534()) + 1;
if (UNK_02105D59 == 2 || UNK_02105D59 == 0)
{
@@ -1050,7 +1034,7 @@ THUMB_FUNC void FUN_02030074()
}
}
-THUMB_FUNC void FUN_02030238(u32 param0, void *param1, u32 param2)
+THUMB_FUNC void FUN_02030238(u32 param0, u8 *param1, u32 param2)
{
if (UNK_021C59F4.unk04->unk66F[0] != 0)
{
@@ -1100,7 +1084,7 @@ THUMB_FUNC void FUN_0203026C(u32 param0, u8 *param1, u32 param2)
if (FUN_0202FA28() == 1)
{
int r6 = FUN_02031228((u16)FUN_02033534());
- int st4 = (int)FUN_0202D858((u16)FUN_02033534()) + 1;
+ int st4 = FUN_0202D858((u16)FUN_02033534()) + 1;
int r4 = 0;
while (r4 < st4)
@@ -1149,7 +1133,7 @@ THUMB_FUNC void FUN_0203026C(u32 param0, u8 *param1, u32 param2)
FUN_0202D3A4(&UNK_021C59F4.unk04->unk470, param1 + 4, param1[3], 0x5FF);
}
-THUMB_FUNC void FUN_020303BC(u32 param0, u8 *param1, u16 param2)
+THUMB_FUNC void FUN_020303BC(u32 param0, u8 *param1, u32 param2)
{
if (UNK_021C59F4.unk04->unk66F[param0] != 0)
{
@@ -1162,7 +1146,7 @@ THUMB_FUNC void FUN_020303BC(u32 param0, u8 *param1, u16 param2)
FUN_020303F4(param0, param1, param2);
}
-THUMB_FUNC void FUN_020303F4(u32 param0, u8 *param1, u16 param2)
+THUMB_FUNC void FUN_020303F4(u32 param0, u8 *param1, u32 param2)
{
#pragma unused(param2)
UNK_021C59F4.unk04->unk638[param0]--;
@@ -1207,7 +1191,7 @@ THUMB_FUNC void FUN_020304D4(u32 param0)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC void FUN_020304F0(u32 param0)
@@ -1218,7 +1202,7 @@ THUMB_FUNC void FUN_020304F0(u32 param0)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC void FUN_0203050C()
@@ -1757,7 +1741,7 @@ THUMB_FUNC u32 FUN_02030B3C(u32 param0, u8 *param1, u32 param2)
{
if (FUN_02031190() != 0)
{
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
@@ -1946,7 +1930,7 @@ THUMB_FUNC void FUN_02030DFC()
{
if (UNK_021C59F4.unk04->unk68B == 0)
{
- int r7 = (int)FUN_0202D858((u16)FUN_02033534()) + 1;
+ int r7 = FUN_0202D858((u16)FUN_02033534()) + 1;
int r4;
for (r4 = 0; r4 < r7; r4++)
{
@@ -2025,9 +2009,9 @@ THUMB_FUNC u32 FUN_02030E7C(u16 param0)
return 0;
}
-THUMB_FUNC u32 FUN_02030F20()
+THUMB_FUNC s32 FUN_02030F20()
{
- u32 r4 = 0;
+ s32 r4 = 0;
for (int i = 0; i < 8; i++)
{
if (FUN_02030E7C((u16)i) != 0)
@@ -2039,11 +2023,11 @@ THUMB_FUNC u32 FUN_02030F20()
return r4;
}
-THUMB_FUNC u32 FUN_02030F40()
+THUMB_FUNC BOOL FUN_02030F40()
{
if (UNK_021C59F4.unk04 != NULL && FUN_02033534() >= 0x13)
{
- return 1;
+ return TRUE;
}
return FUN_0202EDF8();
@@ -2227,17 +2211,17 @@ THUMB_FUNC u32 FUN_020311E8()
return FUN_0202EE24();
}
-THUMB_FUNC u32 FUN_020311F0()
+THUMB_FUNC BOOL FUN_020311F0()
{
if (FUN_02031280() != 0)
{
- return 0;
+ return FALSE;
}
if (UNK_021C59F4.unk04 != NULL && UNK_021C59F4.unk04->unk689 != 0)
{
FUN_020334E8(1, 1);
- return 1;
+ return TRUE;
}
return FUN_0202EE60();
@@ -2258,12 +2242,12 @@ THUMB_FUNC int FUN_02031228(u16 param0)
return 0x26;
}
-THUMB_FUNC u32 FUN_02031248(u32 param0)
+THUMB_FUNC int FUN_02031248(u32 param0)
{
return FUN_0202D858((u16)param0) + 1;
}
-THUMB_FUNC u32 FUN_02031258(u32 param0)
+THUMB_FUNC int FUN_02031258(u32 param0)
{
return FUN_0202D884((u16)param0) + 1;
}
@@ -2475,4 +2459,4 @@ THUMB_FUNC void FUN_02031468()
{
UNK_021C59F4.unk04->unk68A = 1;
}
-} \ No newline at end of file
+}
diff --git a/arm9/src/unk_02031480.c b/arm9/src/unk_02031480.c
new file mode 100644
index 00000000..9639cd74
--- /dev/null
+++ b/arm9/src/unk_02031480.c
@@ -0,0 +1,213 @@
+#include "unk_02031480.h"
+
+struct UnkStruct_02031480
+{
+ u8 unk000[8][2];
+ u8 unk010[8];
+ u8 unk018[8][70];
+ u8 unk248[8];
+ u8 unk250;
+ u8 unk251;
+ u8 unk252;
+};
+
+static struct UnkStruct_02031480 *UNK_021C59FC;
+
+THUMB_FUNC void FUN_02031480(u32 heap_id)
+{
+ if (UNK_021C59FC == NULL)
+ {
+ UNK_021C59FC = AllocFromHeap(heap_id, sizeof(struct UnkStruct_02031480));
+ MI_CpuFill8(UNK_021C59FC, 0, sizeof(struct UnkStruct_02031480));
+ }
+
+ for (int i = 0; i < 8; i++)
+ {
+ UNK_021C59FC->unk010[i] = 0xff;
+ }
+ UNK_021C59FC->unk250 = 0xff;
+ UNK_021C59FC->unk251 = 0xff;
+ UNK_021C59FC->unk252 = 0x00;
+}
+
+THUMB_FUNC void FUN_020314D0()
+{
+ FreeToHeap(UNK_021C59FC);
+ UNK_021C59FC = NULL;
+}
+
+THUMB_FUNC BOOL FUN_020314E8()
+{
+ if (UNK_021C59FC != NULL)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_020314FC(u8 param0, u32 unused, u8 *param2)
+{
+#pragma unused(unused)
+ u8 st0[3];
+
+ st0[0] = param2[0];
+
+ if (FUN_02031190() == 0)
+ {
+
+ st0[1] = param0;
+ st0[2] = st0[0];
+
+ FUN_02030C4C(0x12, &st0[1]);
+
+ UNK_021C59FC->unk010[param0] = st0[0];
+
+ for (int i = 0; i < 8; i++)
+ {
+ if (FUN_02030E7C((u16)i) != 0)
+ {
+ if (st0[0] != UNK_021C59FC->unk010[i])
+ {
+ return;
+ }
+ }
+ }
+
+ FUN_02030C4C(0x11, &st0[0]);
+ }
+}
+
+THUMB_FUNC void FUN_02031560(u32 unused1, u32 unused2, u8 *param2)
+{
+#pragma unused(unused1)
+#pragma unused(unused2)
+ UNK_021C59FC->unk010[param2[0]] = param2[1];
+}
+
+THUMB_FUNC void FUN_02031574(u32 unused1, u32 unused2, u8 *param2)
+{
+#pragma unused(unused1)
+#pragma unused(unused2)
+ UNK_021C59FC->unk250 = *param2;
+}
+
+THUMB_FUNC void FUN_02031588(u8 param0)
+{
+ UNK_021C59FC->unk251 = param0;
+ UNK_021C59FC->unk252 = 1;
+}
+
+THUMB_FUNC void FUN_020315A4()
+{
+ if (UNK_021C59FC != NULL && UNK_021C59FC->unk252 != 0 &&
+ FUN_020311D0(0x10, &UNK_021C59FC->unk251))
+ {
+ UNK_021C59FC->unk252 = 0;
+ }
+}
+
+THUMB_FUNC BOOL FUN_020315D8(u8 param0)
+{
+ if (UNK_021C59FC == NULL)
+ {
+ return TRUE;
+ }
+
+ if (UNK_021C59FC->unk250 == param0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC u8 FUN_020315FC(u8 index)
+{
+ return UNK_021C59FC->unk010[index];
+}
+
+THUMB_FUNC void FUN_0203160C(u32 param0, u32 unused, u8 *param2)
+{
+#pragma unused(unused)
+ UNK_021C59FC->unk000[param0][0] = param2[0];
+ UNK_021C59FC->unk000[param0][1] = param2[1];
+}
+
+THUMB_FUNC u32 FUN_02031628()
+{
+ return 2;
+}
+
+THUMB_FUNC void FUN_0203162C(u8 param0, u8 param1)
+{
+ u8 st0[2] = { param0, param1 };
+
+ FUN_020311D0(0x13, st0);
+}
+
+THUMB_FUNC int FUN_02031640(u32 param0, u8 param1)
+{
+ if (UNK_021C59FC == NULL)
+ {
+ return -1;
+ }
+
+ if (UNK_021C59FC->unk000[param0][0] == param1)
+ {
+ return UNK_021C59FC->unk000[param0][1];
+ }
+
+ return -1;
+}
+
+THUMB_FUNC void FUN_02031668()
+{
+ for (int i = 0; i < 8; i++)
+ {
+ MI_CpuFill8(UNK_021C59FC->unk000[i], 0, 2);
+ }
+}
+
+THUMB_FUNC void FUN_0203168C()
+{
+ for (int i = 0; i < 8; i++)
+ {
+ UNK_021C59FC->unk248[i] = 0;
+ }
+}
+
+THUMB_FUNC BOOL FUN_020316AC(u32 param0, void *param1)
+{
+ if (UNK_021C59FC != NULL)
+ {
+ MI_CpuCopy8(param1, UNK_021C59FC->unk018[param0], 0x46);
+ FUN_020311D0(0x14, UNK_021C59FC->unk018[param0]);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC u8 *FUN_020316E0(int param0)
+{
+ if (UNK_021C59FC->unk248[param0] != 0)
+ {
+ return UNK_021C59FC->unk018[param0];
+ }
+
+ return NULL;
+}
+
+THUMB_FUNC void FUN_02031704(u32 param0, u32 unused, void *param2)
+{
+#pragma unused(unused)
+ UNK_021C59FC->unk248[param0] = 1;
+ MI_CpuCopy8(param2, UNK_021C59FC->unk018[param0], 0x46);
+}
+
+THUMB_FUNC u32 FUN_02031730()
+{
+ return 0x46;
+}
diff --git a/arm9/src/unk_02031734.c b/arm9/src/unk_02031734.c
new file mode 100644
index 00000000..57764b82
--- /dev/null
+++ b/arm9/src/unk_02031734.c
@@ -0,0 +1,2173 @@
+#include "global.h"
+#include "unk_02031734.h"
+#include "MI_memory.h"
+#include "game_init.h"
+#include "heap.h"
+#include "player_data.h"
+#include "unk_0202F150.h"
+#include "unk_0202E29C.h"
+
+
+const struct UnkStruct_02031734_const2 UNK_020EEC48 = { { (u32)FUN_02032B84, 0 } };
+
+const struct UnkStruct_02031734_const1 UNK_020EEC50 = {
+ { (u32)FUN_0203213C, (u32)FUN_02032138, 0 }
+};
+
+const struct UnkStruct_02031734_const1 UNK_020EEC5C = {
+ { (u32)FUN_02032234, (u32)FUN_0203234C, 0 }
+};
+
+char UNK_02105D64[] = " FULL";
+char UNK_02105D5C[] = "FREAK";
+char UNK_02105D6C[] = " GAME";
+
+struct UnkStruct_02031734 *UNK_021C5A00;
+
+extern void FUN_0202D8D0(u32 param0, u32 param1, u32 param2);
+extern void FUN_02033E74();
+extern void FUN_0202D918();
+extern void FUN_02033ED0();
+extern void FUN_0202D298();
+extern void FUN_0202D344(u32 param0);
+extern void FUN_0202D1B0(u8 param0);
+extern void FUN_0202D36C(u32 param0);
+extern u32 MOD04_021DDB08();
+extern void FUN_02033EEC(u32 param0);
+extern u32 WM_GetLinkLevel();
+extern void FUN_0202DB14(struct SaveBlock2 *sav2, u32 param1);
+extern s64 _ll_mul(s64, s64);
+extern void FUN_0202DBE0();
+extern void FUN_0202DDE8();
+extern void FUN_0202D308(void (*param0)(u32, u32));
+extern void MOD04_021D83C0();
+extern s32 MOD04_021D7F8C();
+extern s32 MOD04_021D7800(u32 param0);
+extern u32 MOD04_021D8494(s32 param0);
+extern void MOD04_021D77C4(void (*param0)(u32, u8 *, u32), void (*param1)(u32, u8 *, u32));
+extern u32 MOD04_021D82BC(u8 param0);
+extern void MOD04_021D836C();
+extern u32 MOD04_021DD718(u32 *param0, u32 *param1);
+extern void MOD04_021DD6F0();
+extern s32 MOD04_021D76AC();
+extern MOD05_021D74E0(struct SaveBlock2 *sav2, u32 param1);
+extern void MOD04_021D83A8(void (*param0)(s32));
+extern void FUN_02033F70(int, int, int);
+extern void FUN_0200541C();
+
+THUMB_FUNC void FUN_02031734(struct SaveBlock2 *sav2, u8 param1)
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ FUN_0202E49C();
+ struct UnkStruct_02031734 *ptr = AllocFromHeap(0xf, sizeof(struct UnkStruct_02031734));
+ UNK_021C5A00 = ptr;
+ MI_CpuFill8(ptr, 0, sizeof(struct UnkStruct_02031734));
+
+ UNK_021C5A00->unk3A = 0x32;
+ UNK_021C5A00->unk43 = 1;
+ UNK_021C5A00->unk28 = sav2;
+
+ UNK_021C5A00->unk2C = Sav2_PlayerData_GetProfileAddr(sav2);
+
+ UNK_021C5A00->unk3C = 2;
+ UNK_021C5A00->unk3D = 0;
+ UNK_021C5A00->unk48 = 0;
+ UNK_021C5A00->unk3F = param1;
+
+ FUN_020312BC(UNK_021C5A00->unk0C);
+ FUN_0202D8D0(0, 0, 0);
+
+ if (param1 != 9 && param1 != 0x11 && param1 != 0xf)
+ {
+ FUN_02033E74();
+ }
+ }
+}
+
+THUMB_FUNC void FUN_020317C0()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_0202D918();
+ if (UNK_021C5A00->unk00 != NULL)
+ {
+ FreeToHeap(UNK_021C5A00->unk00);
+ }
+
+ if (UNK_021C5A00->unk3F >= 0x13)
+ {
+ FUN_020168D0(0x31);
+ }
+
+ FUN_02033ED0();
+ FUN_0202E4F0();
+
+ FreeToHeap(UNK_021C5A00);
+ FUN_020168D0(0xf);
+
+ UNK_021C5A00 = NULL;
+ }
+}
+
+THUMB_FUNC BOOL FUN_02031810()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_02031824(struct SaveBlock2 *sav2)
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ FUN_02016828(3, 0xf, 0xe000);
+ FUN_02031734(sav2, 0xa);
+
+ UNK_021C5A00->unk40 = 0;
+ FUN_02031D20(FUN_02031D30, 0x32);
+ }
+}
+
+THUMB_FUNC void FUN_02031860()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_02031468();
+ FUN_02031D20(FUN_020323CC, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031880()
+{
+ FUN_0202FC60();
+ UNK_021C5A00->unk38 = FUN_02031190();
+
+ FUN_02031D20(FUN_020321B8, 0);
+}
+
+THUMB_FUNC void FUN_020318A4(u8 param0)
+{
+ UNK_021C5A00->unk4F = param0;
+}
+
+THUMB_FUNC void FUN_020318B4()
+{
+ FUN_02031D20(FUN_02032028, 0);
+}
+
+THUMB_FUNC BOOL FUN_020318C4()
+{
+ struct UnkStruct_02031734_const1 st0 = UNK_020EEC50;
+
+ u32 r1 = (u32)UNK_021C5A00->unk24;
+
+ if (UNK_021C5A00 == NULL)
+ {
+ return FALSE;
+ }
+
+ for (u32 i = 0; st0.unk00[i] != 0; i++)
+ {
+
+ if (r1 == st0.unk00[i])
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_02031914()
+{
+ FUN_02031D20(FUN_02032178, 0);
+}
+
+THUMB_FUNC void FUN_02031924()
+{
+ UNK_021C5A00->unk4C = 1;
+}
+
+THUMB_FUNC void FUN_02031934()
+{
+ FUN_0202E49C();
+ FUN_02031D20(FUN_02032194, 0);
+}
+
+THUMB_FUNC void FUN_02031948(struct SaveBlock2 *sav2, u8 param1, u8 param2, u32 param3)
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02016828(3, 0xf, 0x7080);
+ FUN_02031734(sav2, param1);
+ UNK_021C5A00->unk40 = param2;
+ UNK_021C5A00->unk30 = param3;
+ FUN_02031D20(FUN_020321D0, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031990(struct SaveBlock2 *sav2, u8 param1, u8 param2, u32 param3)
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02016828(3, 0xf, 0x7080);
+ FUN_02031734(sav2, param1);
+ UNK_021C5A00->unk40 = param2;
+ UNK_021C5A00->unk30 = param3;
+ FUN_02031D20(FUN_0203224C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020319D8(u8 param0)
+{
+ UNK_021C5A00->unk3E = param0;
+ FUN_02031D20(FUN_02032298, 0);
+}
+
+THUMB_FUNC void FUN_020319F4()
+{
+ FUN_0202FCA8();
+ FUN_02031D20(FUN_02032364, 0);
+}
+
+THUMB_FUNC void FUN_02031A08()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_02031D20(FUN_02032440, 5);
+ }
+}
+
+THUMB_FUNC void FUN_02031A24()
+{
+ FUN_0202D298();
+}
+
+THUMB_FUNC BOOL FUN_02031A2C()
+{
+ struct UnkStruct_02031734_const1 st0 = UNK_020EEC5C;
+
+ u32 r1 = (u32)UNK_021C5A00->unk24;
+
+ if (UNK_021C5A00 == NULL)
+ {
+ return FALSE;
+ }
+
+ for (u32 i = 0; st0.unk00[i] != 0; i++)
+ {
+
+ if (r1 == st0.unk00[i])
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_02031A7C(struct SaveBlock2 *sav2)
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ if (FUN_02016828(3, 0xf, 0x7080) == 0)
+ {
+ FUN_020335E0();
+ }
+
+ FUN_02031734(sav2, 9);
+ UNK_021C5A00->unk3F = 9;
+ UNK_021C5A00->unk40 = 0;
+ FUN_02031D20(FUN_02032478, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031AC8(u8 param0)
+{
+ UNK_021C5A00->unk3E = param0;
+ UNK_021C5A00->unk38 = 3;
+ FUN_0202D344(1);
+ FUN_02033E74();
+ FUN_02031D20(FUN_02032628, 0);
+}
+
+THUMB_FUNC s32 FUN_02031AF4()
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ return -1;
+ }
+ if (UNK_021C5A00->unk24 == FUN_0203279C)
+ {
+ return 1;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_020327B4)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC BOOL FUN_02031B2C()
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ return FALSE;
+ }
+ if (UNK_021C5A00->unk24 == FUN_020327FC)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_02031B50()
+{
+ FUN_0202D344(0);
+ if (UNK_021C5A00->unk44 != 1 || UNK_021C5A00->unk45 != 1 || UNK_021C5A00->unk3F == 9)
+ {
+ FUN_020334E8(0, 0);
+ }
+
+ FUN_02033ED0();
+ UNK_021C5A00->unk3F = 9;
+ UNK_021C5A00->unk48 = 0;
+ FUN_0202D1B0(UNK_021C5A00->unk3C);
+
+ if (FUN_02031190() == 0)
+ {
+ FUN_0202D36C(1);
+ FUN_02031D20(FUN_020323DC, 0xf);
+ return;
+ }
+
+ FUN_02031D20(FUN_02032424, 5);
+}
+
+THUMB_FUNC u32 FUN_02031BD0()
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ return 1;
+ }
+
+ if (UNK_021C5A00->unk24 != FUN_020324F8)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_02031BF4()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_02031D20(FUN_02032440, 5);
+ }
+}
+
+THUMB_FUNC void FUN_02031C10()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk48 = 1;
+ FUN_0202D344(1);
+ }
+}
+
+THUMB_FUNC void FUN_02031C2C()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk48 = 1;
+ FUN_0202D344(1);
+ FUN_02031D20(FUN_02032850, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031C54()
+{
+ UNK_021C5A00->unk3F = 0x12;
+}
+
+THUMB_FUNC void FUN_02031C64()
+{
+ UNK_021C5A00->unk3F = 0x9;
+}
+
+THUMB_FUNC void FUN_02031C74(struct SaveBlock2 *sav2, u8 param1)
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02016828(3, 0xf, 0x7080);
+ FUN_02031734(sav2, param1);
+ FUN_02031D20(FUN_02032E00, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031CA8(struct SaveBlock2 *sav2, u8 param1)
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02016828(3, 0xf, 0x7080);
+ FUN_02031734(sav2, param1);
+ FUN_02031D20(FUN_02032E48, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031CDC()
+{
+ if (UNK_021C5A00 != NULL && UNK_021C5A00->unk24 != 0)
+ {
+ ((void (*)(void))(UNK_021C5A00->unk24))();
+ }
+ if (FUN_02033590() != 0)
+ {
+ FUN_02033EEC(3 - MOD04_021DDB08());
+ return;
+ }
+
+ if (FUN_0202EDF8())
+ {
+ FUN_02033EEC(3 - WM_GetLinkLevel());
+ }
+}
+
+THUMB_FUNC void FUN_02031D20(void (*param0)(), u32 param1)
+{
+ UNK_021C5A00->unk24 = param0;
+ UNK_021C5A00->unk3A = (u16)param1;
+}
+
+THUMB_FUNC void FUN_02031D30()
+{
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ if (!FUN_0202E4C8())
+ {
+ return;
+ }
+
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, 0);
+ FUN_02031268(1);
+ FUN_02030FA8();
+
+ if (UNK_021C5A00->unk4A != 0)
+ {
+ if (FUN_0202F918(1, UNK_021C5A00->unk43, 0x1F4, 1) == 0)
+ {
+ return;
+ }
+
+ u32 r1 = compute(UNK_021C5A00->unk0C, 0x14);
+
+ UNK_021C5A00->unk43 = 0;
+ FUN_02031D20(FUN_020320C4, r1 + 0x14);
+ return;
+ }
+
+ if (FUN_0202F950(1, 1, 0x1F4) != 0)
+ {
+ if (UNK_021C5A00->unk4C != 0)
+ {
+ FUN_02031D20(FUN_020323B8, 0);
+ }
+ else
+ {
+ FUN_02031D20(FUN_02031EE0, 0x40);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02031E08()
+{
+ if (FUN_0202EE0C() != 0)
+ {
+ FUN_02031268(1);
+ FUN_02030FA8();
+
+ if (UNK_021C5A00->unk4A != 0)
+ {
+ FUN_02031D20(FUN_02032058, 0);
+ return;
+ }
+
+ if (FUN_0202F950(0, 1, 0x1F4) != 0)
+ {
+
+ u32 r1 = compute(UNK_021C5A00->unk0C, 0x40);
+
+ if (UNK_021C5A00->unk38 != 0)
+ {
+ r1 = (u32)(UNK_021C5A00->unk38 << 6);
+ UNK_021C5A00->unk38 = 0;
+ }
+ FUN_02031D20(FUN_02031EE0, r1);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02031E8C()
+{
+ if (FUN_0202EE0C() != 0)
+ {
+ if (FUN_0202F950(0, 0, 0x1F4) != 0)
+ {
+
+ u32 r1 = compute(UNK_021C5A00->unk0C, 0x20);
+
+ FUN_02031D20(FUN_02031EE0, r1 + 0x10);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02031EE0()
+{
+ FUN_0202EA54();
+ if (UNK_021C5A00->unk4F == 0 && UNK_021C5A00->unk4B == 0)
+ {
+ s32 r0 = FUN_0202E8F4();
+ if (r0 != -1)
+ {
+ UNK_021C5A00->unk3E = (u8)r0;
+ FUN_02031D20(FUN_02031F60, 0x20);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ r0 = FUN_0202E950();
+ if (r0 != -1)
+ {
+ UNK_021C5A00->unk3E = (u8)r0;
+ FUN_02031D20(FUN_02031F60, 0x20);
+ return;
+ }
+
+ FUN_02031D20(FUN_02032028, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02031F60()
+{
+ FUN_0202EA54();
+ if (FUN_0202E8A0(UNK_021C5A00->unk3E) != 0 && FUN_0202FB18(UNK_021C5A00->unk3E) != 0)
+ {
+ FUN_02031D20(FUN_02031FC8, 0x64);
+ return;
+ }
+
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_02032028, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ FUN_02031D20(FUN_02032028, 0);
+}
+
+THUMB_FUNC void FUN_02031FC8()
+{
+ if (FUN_02030E7C(FUN_02031190()) != 0)
+ {
+ FUN_0202FC60();
+ FUN_02031268(0);
+ FUN_02030FA8();
+ FUN_02031D20(FUN_0203213C, 0);
+ return;
+ }
+
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_02032028, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ FUN_02031D20(FUN_02032028, 0);
+}
+
+THUMB_FUNC void FUN_02032028()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02032058, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032040()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02031E8C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032058()
+{
+ if (FUN_0202EE0C() != 0)
+ {
+ FUN_02031268(1);
+ if (FUN_0202F918(0, UNK_021C5A00->unk43, 0x1F4, 1) != 0)
+ {
+ u32 r1 = compute(UNK_021C5A00->unk0C, 0x14);
+
+ UNK_021C5A00->unk43 = 0;
+ FUN_02031D20(FUN_020320C4, r1 + 0x14);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_020320C4()
+{
+ if (FUN_020311E8() != 0)
+ {
+ UNK_021C5A00->unk43 = 1;
+ FUN_02031D20(FUN_02032118, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ if (UNK_021C5A00->unk4A == 0 && FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02032040, 2);
+ }
+}
+
+THUMB_FUNC void FUN_02032118()
+{
+ FUN_02031268(0);
+ FUN_0202EE84(1);
+ FUN_02030FA8();
+ FUN_02031D20(FUN_02032138, 0);
+}
+
+THUMB_FUNC void FUN_02032138()
+{
+}
+THUMB_FUNC void FUN_0203213C()
+{
+}
+
+THUMB_FUNC void FUN_02032140()
+{
+ if (UNK_021C5A00->unk3F < 0x13)
+ {
+ if (FUN_0202EE0C() == 0)
+ {
+ return;
+ }
+
+ FUN_02031268(1);
+ FUN_02030FA8();
+ FUN_0202E7B0(1);
+ }
+
+ FUN_02031D20(FUN_020323B8, 0);
+}
+
+THUMB_FUNC void FUN_02032178()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_0202FC60();
+ FUN_02031D20(FUN_02032140, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032194()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E7B0(0);
+ FUN_0202FC60();
+ FUN_02031D20(FUN_02031E08, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020321B8()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02031E08, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020321D0()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, UNK_021C5A00->unk30);
+ if (FUN_0202F918(1, 1, 0x200, 1) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032218, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032218()
+{
+ if (FUN_02030E7C(FUN_02031190()) != 0)
+ {
+ FUN_02031D20(FUN_02032234, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032234()
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02031D20(FUN_020323BC, 0);
+ }
+}
+
+THUMB_FUNC void FUN_0203224C()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, UNK_021C5A00->unk30);
+ if (FUN_0202F950(1, 1, 0x200) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032290, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032290()
+{
+ FUN_0202EA54();
+}
+
+THUMB_FUNC void FUN_02032298()
+{
+ FUN_0202EA54();
+ if (FUN_0202FB18(UNK_021C5A00->unk3E) != 0)
+ {
+ FUN_02031D20(FUN_020322C0, 0xa);
+ }
+}
+
+THUMB_FUNC void FUN_020322C0()
+{
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_020322F8, 0);
+ }
+
+ if (FUN_02030E7C(FUN_02031190()) != 0 && FUN_02031190() != 0)
+ {
+ FUN_02031D20(FUN_0203234C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020322F8()
+{
+ FUN_0202E6F0();
+ FUN_02031D20(FUN_0203230C, 2);
+}
+
+THUMB_FUNC void FUN_0203230C()
+{
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ if (FUN_0202EE0C() != 0 && FUN_0202F950(0, 1, 0x200) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032298, 0xa);
+ }
+}
+
+THUMB_FUNC void FUN_0203234C()
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02031D20(FUN_020323BC, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032364()
+{
+ FUN_0202E6F0();
+ FUN_02031D20(FUN_02032378, 2);
+}
+
+THUMB_FUNC void FUN_02032378()
+{
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ if (FUN_0202EE0C() != 0 && FUN_0202F950(0, 1, 0x200) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032290, 0xa);
+ }
+}
+
+THUMB_FUNC void FUN_020323B8()
+{
+}
+
+THUMB_FUNC void FUN_020323BC()
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_020317C0();
+ }
+}
+
+THUMB_FUNC void FUN_020323CC()
+{
+ FUN_02031D20(FUN_02032440, 5);
+}
+
+THUMB_FUNC void FUN_020323DC()
+{
+ if (FUN_02030F20() <= 1)
+ {
+ FUN_0202D36C(0);
+ FUN_0202FC80();
+ FUN_02031D20(FUN_020324F8, 0);
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ FUN_0202D36C(0);
+ FUN_0202FC80();
+ FUN_02031D20(FUN_020324F8, 0);
+}
+
+THUMB_FUNC void FUN_02032424()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_0202FC60();
+ FUN_02031D20(FUN_020324F8, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032440()
+{
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ }
+
+ if (FUN_0202E6F0() != 0 && UNK_021C5A00->unk3A == 0)
+ {
+ FUN_0202FA5C();
+ FUN_02031D20(FUN_020323BC, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032478()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202D1B0(UNK_021C5A00->unk3C);
+ FUN_0202DB14(UNK_021C5A00->unk28, 0);
+ if (FUN_0202F950(1, 1, 0x200) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_020324C8, 0x40);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_020324C8()
+{
+ FUN_0202EA54();
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02032510, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020324F8()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02032510, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032510()
+{
+ if (FUN_0202EE0C() != 0 && FUN_0202F918(0, UNK_021C5A00->unk43, 0x200, 1) != 0)
+ {
+ // the compiler optimizes away the result of this function because it's not used, so any
+ // second parameter value matches
+ compute(UNK_021C5A00->unk0C, 0);
+
+ FUN_0202FA10();
+ UNK_021C5A00->unk43 = 0;
+
+ FUN_02031D20(FUN_02032578, 0x2710);
+ }
+}
+
+THUMB_FUNC void FUN_02032578()
+{
+ if (!FUN_0202F104())
+ {
+ if (FUN_020311E8() != 0)
+ {
+ UNK_021C5A00->unk43 = 1;
+ FUN_02033E74();
+ FUN_02031D20(FUN_020327FC, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+ }
+
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_020325D0, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020325D0()
+{
+ if (FUN_0202EE0C() != 0 && FUN_0202F950(0, 0, 0x200) != 0)
+ {
+ FUN_0202FA10();
+
+ u32 r1 = compute(UNK_021C5A00->unk0C, 0x20);
+
+ FUN_02031D20(FUN_020324C8, r1);
+ }
+}
+
+THUMB_FUNC void FUN_02032628()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_02032640, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032640()
+{
+ if (FUN_0202EE0C() != 0 && FUN_0202F950(0, 0, 0x200))
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_0203266C, 0x64);
+ }
+}
+
+THUMB_FUNC void FUN_0203266C()
+{
+ if (FUN_0202E8A0(UNK_021C5A00->unk3E) != 0 && FUN_0202FB18(UNK_021C5A00->unk3E) != 0)
+ {
+ FUN_02031D20(FUN_020326D0, 0x64);
+ return;
+ }
+
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_020327B8, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ FUN_02031D20(FUN_020327B8, 0);
+}
+
+THUMB_FUNC void FUN_020326D0()
+{
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_020327B8, 0);
+ return;
+ }
+
+ if (FUN_02030E7C(FUN_02031190()) != 0)
+ {
+ UNK_021C5A00->unk3D = 0;
+ FUN_020311D0(6, UNK_02105D5C);
+ FUN_02031D20(FUN_02032738, 0x78);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ FUN_02031D20(FUN_020327B8, 0);
+}
+
+THUMB_FUNC void FUN_02032738()
+{
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_020327B8, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3D == 2)
+ {
+ FUN_02031D20(FUN_020327B4, 0);
+ return;
+ }
+ else if (UNK_021C5A00->unk3D == 1)
+ {
+ FUN_0202DBE0();
+ FUN_02031D20(FUN_0203279C, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ FUN_02031D20(FUN_020327B8, 0);
+}
+
+THUMB_FUNC void FUN_0203279C()
+{
+ if (FUN_020311F0() != 0)
+ {
+ FUN_02031D20(FUN_020327B8, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020327B4()
+{
+}
+
+THUMB_FUNC void FUN_020327B8()
+{
+ UNK_021C5A00->unk3D = 0;
+ if (FUN_0202E6F0() != 0)
+ {
+ if (UNK_021C5A00->unk38 != 0)
+ {
+ UNK_021C5A00->unk38--;
+ FUN_02031D20(FUN_02032640, 0);
+ return;
+ }
+
+ FUN_02031D20(FUN_020327B4, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020327FC()
+{
+ if (FUN_020311E8() == 0)
+ {
+ if (FUN_02033510() == 0 && FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_020325D0, 0);
+ }
+ }
+ else if (FUN_02031190() == 0)
+ {
+ FUN_0202DDE8();
+ }
+
+ if (FUN_020311F0() != 0 && FUN_02033510() == 0)
+ {
+ FUN_02031D20(FUN_020327B8, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032850()
+{
+ if (FUN_0202EE0C() != 0)
+ {
+ if (FUN_0202F918(0, UNK_021C5A00->unk43, 0x200, 0) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_020323B8, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032888()
+{
+ u8 st0[4];
+ UNK_021C5A00->unk3F = 0xd;
+ if (FUN_02031190() == 0)
+ {
+ st0[1] = 0;
+ FUN_020311D0(0xa, &st0[1]);
+ return;
+ }
+
+ st0[0] = 0;
+ FUN_020311D0(0xa, st0);
+}
+
+THUMB_FUNC void FUN_020328C0(u8 param0)
+{
+ UNK_021C5A00->unk3E = param0;
+ UNK_021C5A00->unk38 = 3;
+ FUN_02031D20(FUN_02032924, 0);
+}
+
+THUMB_FUNC void FUN_020328E4()
+{
+ UNK_021C5A00->unk3F = 7;
+}
+
+THUMB_FUNC void FUN_020328F4(u8 param0)
+{
+ UNK_021C5A00->unk3E = param0;
+ UNK_021C5A00->unk3F = 7;
+ UNK_021C5A00->unk38 = 3;
+ FUN_02033E74();
+ FUN_02031D20(FUN_02032628, 0);
+}
+
+THUMB_FUNC void FUN_02032924()
+{
+ if (FUN_0202E6F0() != 0)
+ {
+ FUN_02031D20(FUN_0203293C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_0203293C()
+{
+ if (FUN_0202EE0C() != 0)
+ {
+ UNK_021C5A00->unk3F = 0xd;
+ if (FUN_0202F950(0, 0, 0x200) != 0)
+ {
+ FUN_0202FA1C();
+ FUN_02031D20(FUN_02032978, 0x64);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032978()
+{
+ if (FUN_0202E8A0(UNK_021C5A00->unk3E) != 0 && FUN_0202FB18(UNK_021C5A00->unk3E) != 0)
+ {
+ FUN_02031D20(FUN_020329F4, 0x64);
+ return;
+ }
+
+ if (FUN_020311F0() != 0 || UNK_021C5A00->unk3A == 0)
+ {
+ UNK_021C5A00->unk38--;
+ if (UNK_021C5A00->unk38 == 0)
+ {
+ FUN_02031D20(FUN_020327B4, 0);
+ return;
+ }
+
+ FUN_02031D20(FUN_02032924, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+}
+
+THUMB_FUNC void FUN_020329F4()
+{
+ if (UNK_021C5A00->unk3A > 0x5a)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ if (FUN_020311F0() != 0)
+ {
+ UNK_021C5A00->unk38--;
+ if (UNK_021C5A00->unk38 == 0)
+ {
+ FUN_02031D20(FUN_020327B4, 0);
+ return;
+ }
+
+ FUN_02031D20(FUN_02032924, 0);
+ return;
+ }
+
+ if (FUN_02030E7C(FUN_02031190()) != 0)
+ {
+ FUN_02031D20(FUN_0203279C, 0);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3A != 0)
+ {
+ UNK_021C5A00->unk3A--;
+ return;
+ }
+
+ UNK_021C5A00->unk38--;
+ if (UNK_021C5A00->unk38 == 0)
+ {
+ FUN_02031D20(FUN_020327B4, 0);
+ return;
+ }
+
+ FUN_02031D20(FUN_02032924, 0);
+}
+
+THUMB_FUNC void FUN_02032A8C(u8 param0, u32 param1, u8 *param2)
+{
+#pragma unused(param1)
+ if (FUN_02031190() == 0)
+ {
+
+ u32 i;
+ BOOL r3 = TRUE;
+ for (i = 0; i < 6; i++)
+ {
+ if (UNK_02105D5C[i] != param2[i])
+ {
+ r3 = FALSE;
+ break;
+ }
+ }
+
+ if (r3 && UNK_021C5A00->unk48 == 0)
+ {
+ UNK_02105D6C[0] = param0;
+ FUN_02030C4C(7, UNK_02105D6C);
+ return;
+ }
+
+ UNK_02105D64[0] = param0;
+ FUN_02030C4C(7, UNK_02105D64);
+ }
+}
+
+THUMB_FUNC void FUN_02032AEC(u32 param0, u32 param1, u8 *param2)
+{
+#pragma unused(param0)
+#pragma unused(param1)
+ u32 i;
+ BOOL r4 = TRUE;
+ for (i = 1; i < 6; i++)
+ {
+ if (param2[i] != UNK_02105D6C[i])
+ {
+ r4 = FALSE;
+ break;
+ }
+ }
+
+ if (r4)
+ {
+ u8 first = param2[0];
+ if (first != FUN_02031190())
+ {
+ return;
+ }
+
+ UNK_021C5A00->unk3D = 1;
+ return;
+ }
+
+ r4 = TRUE;
+ for (i = 1; i < 6; i++)
+ {
+ if (param2[i] != UNK_02105D64[i])
+ {
+ r4 = FALSE;
+ break;
+ }
+ }
+
+ if (r4)
+ {
+ u8 first = param2[0];
+ if (first != (u8)FUN_02031190())
+ {
+ return;
+ }
+
+ UNK_021C5A00->unk3D = 2;
+ }
+}
+
+THUMB_FUNC u32 FUN_02032B68()
+{
+ return 6;
+}
+
+THUMB_FUNC void FUN_02032B6C(u8 param0)
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk3C = param0;
+ FUN_0202D1B0(param0);
+ }
+}
+
+THUMB_FUNC void FUN_02032B84()
+{
+ FUN_0202EA54();
+}
+
+THUMB_FUNC void FUN_02032B8C()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, 0);
+ if (FUN_0202F950(1, 1, 0x20) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032B84, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032BD0(struct SaveBlock2 *sav2)
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02016828(3, 0xf, 0x7000);
+ FUN_02031734(sav2, 0xe);
+ UNK_021C5A00->unk40 = 0;
+ FUN_02031D20(FUN_02032B8C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032C0C()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_02031D20(FUN_02032440, 5);
+ }
+}
+
+THUMB_FUNC u32 FUN_02032C28()
+{
+ struct UnkStruct_02031734_const2 st0 = UNK_020EEC48;
+
+ u32 fun = (u32)UNK_021C5A00->unk24;
+ if (UNK_021C5A00 == NULL)
+ {
+ return 0;
+ }
+
+ u32 i = 0;
+ while (st0.unk00[i] != 0)
+ {
+ if (st0.unk00[i] == fun)
+ {
+ return 1;
+ }
+
+ i++;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_02032C6C(u32 param0, u32 param1)
+{
+ switch (param0)
+ {
+ case 0x333:
+ if (param1 != 0xf)
+ {
+ return;
+ }
+ UNK_021C5A00->unk49 |= 1;
+ break;
+ case 0x400318:
+
+ UNK_021C5A00->unk49 |= 1;
+ break;
+
+ case 0x400131:
+
+ UNK_021C5A00->unk49 |= 2;
+ break;
+
+ case 0x400286:
+
+ UNK_021C5A00->unk49 |= 4;
+ break;
+ }
+}
+
+THUMB_FUNC void FUN_02032CF4()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, 0);
+ FUN_0202D308(FUN_02032C6C);
+ if (FUN_0202F950(1, 1, 0x20) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032B84, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032D44(struct SaveBlock2 *sav2)
+{
+ if (FUN_02030F40() == 0)
+ {
+ FUN_02016828(3, 0xf, 0x7000);
+ FUN_02031734(sav2, 0x11);
+ UNK_021C5A00->unk40 = 0;
+ FUN_02031D20(FUN_02032CF4, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032D80()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_02031D20(FUN_02032440, 5);
+ }
+}
+
+THUMB_FUNC u8 FUN_02032D9C()
+{
+ return UNK_021C5A00->unk49;
+}
+
+THUMB_FUNC BOOL FUN_02032DAC()
+{
+ FUN_02031468();
+
+ if (UNK_021C5A00 == NULL)
+ {
+ return TRUE;
+ }
+
+ if ((u8)(UNK_021C5A00->unk3F + 0xe8) <= 1)
+ {
+ MOD04_021D83C0();
+ return TRUE;
+ };
+
+ if (FUN_02033590() != 0)
+ {
+ FUN_02031D20(FUN_0203318C, 0);
+ }
+ else
+ {
+ FUN_02031D20(FUN_02032178, 0);
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC void FUN_02032E00()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, 0);
+ if (FUN_0202F918(1, 1, 0x200, 1) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032218, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032E48()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_0202E29C(UNK_021C5A00->unk2C);
+ FUN_0202DB14(UNK_021C5A00->unk28, 0);
+ if (FUN_0202F950(1, 1, 0x200) != 0)
+ {
+ FUN_0202FA10();
+ FUN_02031D20(FUN_02032290, 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02032E8C()
+{
+}
+
+THUMB_FUNC void FUN_02032E90()
+{
+ if (MOD04_021D7F8C() < 0)
+ {
+ FUN_02031D20(FUN_02032E8C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02032EA8()
+{
+}
+
+THUMB_FUNC void FUN_02032EAC()
+{
+}
+
+THUMB_FUNC void FUN_02032EB0()
+{
+ FUN_020313A0(1);
+
+ s32 res = MOD04_021D7F8C();
+ if (res >= 0xa)
+ {
+ FUN_02031D20(FUN_02032EAC, 0);
+ return;
+ }
+
+ if (res < 0)
+ {
+ FUN_02031D20(FUN_02032E8C, 0);
+ return;
+ }
+
+ if (res == 1)
+ {
+ FUN_02031D20(FUN_02032E90, 0);
+ return;
+ }
+
+ if (res == 2)
+ {
+ if (UNK_021C5A00->unk44 != 0)
+ {
+ FUN_02031D20(FUN_02032E8C, 0);
+ return;
+ }
+ FUN_02031D20(FUN_02032EA8, 0);
+ return;
+ }
+}
+
+THUMB_FUNC void FUN_02032F20(u32 param0)
+{
+ if (param0 + 2 > 1)
+ {
+ param0 = -param0;
+ }
+
+ UNK_021C5A00->unk34 = param0;
+}
+
+THUMB_FUNC void FUN_02032F34()
+{
+ s32 res = MOD04_021D7800(0);
+ if (res >= 0xa)
+ {
+ FUN_02031D20(FUN_02032EAC, 0);
+ return;
+ }
+
+ if (res < 0)
+ {
+ FUN_02032F20((u32)res);
+ FUN_02031D20(FUN_02032E8C, 0);
+ return;
+ }
+
+ if (res == 1)
+ {
+ FUN_02031D20(FUN_02032EB0, 0);
+ return;
+ }
+
+ if (res == 2)
+ {
+ FUN_02031D20(FUN_02032EA8, 0);
+ return;
+ }
+
+ if (res == 3)
+ {
+ FUN_02031D20(FUN_02032EAC, 0);
+ return;
+ }
+}
+
+THUMB_FUNC void FUN_02032F98()
+{
+ s32 res = MOD04_021D7800(1);
+ if (res < 0)
+ {
+ FUN_02032F20((u32)res);
+ FUN_02031D20(FUN_02032E8C, 0);
+ return;
+ }
+
+ if (MOD04_021D8494(UNK_021C5A00->unk42) != 0)
+ {
+ FUN_0202FC60();
+ FUN_02031D20(FUN_02032F34, 0);
+ }
+}
+
+THUMB_FUNC u32 FUN_02032FDC(u8 param0)
+{
+ MOD04_021D77C4(FUN_020303BC, FUN_02030238);
+ UNK_021C5A00->unk42 = param0;
+ FUN_02031D20(FUN_02032F98, 0);
+
+ return 1;
+}
+
+THUMB_FUNC u32 FUN_0203300C()
+{
+ if (UNK_021C5A00->unk24 == FUN_02032F34)
+ {
+ return 0;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_02032EB0)
+ {
+ return 1;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_02032E90)
+ {
+ return 3;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_02032EA8)
+ {
+ return 4;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_02032EAC)
+ {
+ return 5;
+ }
+
+ return 2;
+}
+
+THUMB_FUNC void FUN_02033060()
+{
+ MOD04_021D77C4(FUN_020303BC, FUN_02030238);
+ if (MOD04_021D8494(-1) != 0)
+ {
+ UNK_021C5A00->unk4D = 0;
+ FUN_0202FC60();
+ FUN_02031D20(FUN_02032F34, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020330A0()
+{
+ FUN_020313A0(0);
+ if (MOD04_021D82BC(UNK_021C5A00->unk41) != 0)
+ {
+ MOD04_021D836C();
+ FUN_02031D20(FUN_02033060, 0);
+ return;
+ }
+
+ if (MOD04_021D7F8C() < 0)
+ {
+ FUN_02031D20(FUN_02032E8C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020330E4()
+{
+ if (FUN_02031190() == 0)
+ {
+ UNK_021C5A00->unk41 = 0;
+ FUN_02031D20(FUN_020330A0, 0);
+ }
+ else
+ {
+ UNK_021C5A00->unk41 = 1;
+ FUN_02031D20(FUN_020330A0, 0);
+ }
+
+ UNK_021C5A00->unk4D = 1;
+}
+
+THUMB_FUNC u8 FUN_02033128()
+{
+ return UNK_021C5A00->unk4D;
+}
+
+THUMB_FUNC u32 FUN_02033138()
+{
+ if (UNK_021C5A00->unk24 == FUN_02033060)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC u32 FUN_02033154()
+{
+ if (UNK_021C5A00->unk24 == FUN_02032F34)
+ {
+ return 1;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_02033060)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC u32 FUN_02033180()
+{
+ return UNK_021C5A00->unk34;
+}
+
+THUMB_FUNC void FUN_0203318C()
+{
+ FUN_020313A0(0);
+ if (MOD04_021D82BC(0) != 0)
+ {
+ MOD04_021D836C();
+ FUN_02031D20(FUN_02032440, 0);
+ }
+
+ if (MOD04_021D7F8C() < 0)
+ {
+ FUN_02031D20(FUN_02032E8C, 0);
+ }
+}
+
+THUMB_FUNC void FUN_020331C4()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ FUN_020166B8(1);
+ FUN_02031D20(FUN_02032440, 5);
+ }
+}
+
+THUMB_FUNC void FUN_020331E8()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk41 = 0;
+ FUN_02031D20(FUN_020330A0, 0);
+ }
+}
+
+THUMB_FUNC void FUN_02033208()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ if (FUN_02031190() == 0)
+ {
+ UNK_021C5A00->unk41 = 0;
+ }
+ else
+ {
+ UNK_021C5A00->unk41 = 1;
+ }
+
+ FUN_02031D20(FUN_020330A0, 0);
+ }
+}
+
+THUMB_FUNC void FUN_0203323C()
+{
+ u8 res = (u8)FUN_02031190();
+ FUN_020311D0(0x15, &res);
+}
+
+THUMB_FUNC u32 FUN_02033250()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ if (UNK_021C5A00->unk24 == FUN_02032E8C)
+ {
+ return 1;
+ }
+
+ if (UNK_021C5A00->unk24 == FUN_02032E90 && UNK_021C5A00->unk44 != 0)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_02033288(struct SaveBlock2 *sav2)
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ FUN_02016828(3, 0xf, 0x100);
+ UNK_021C5A00 =
+ (struct UnkStruct_02031734 *)AllocFromHeap(0xf, sizeof(struct UnkStruct_02031734));
+ MI_CpuFill8(UNK_021C5A00, 0, sizeof(struct UnkStruct_02031734));
+
+ UNK_021C5A00->unk3F = 0x18;
+ UNK_021C5A00->unk46 = 1;
+ UNK_021C5A00->unk28 = sav2;
+ FUN_020334E8(0, 1);
+ FUN_020166A8(1);
+ }
+}
+
+THUMB_FUNC void FUN_020332DC()
+{
+ if (UNK_021C5A00 != 0)
+ {
+ FUN_020166B8(1);
+ FUN_020334E8(0, 0);
+ FreeToHeap(UNK_021C5A00);
+ UNK_021C5A00 = NULL;
+ FUN_020168D0(0xf);
+ }
+}
+
+THUMB_FUNC void FUN_02033310(struct SaveBlock2 *sav2)
+{
+ if (UNK_021C5A00 == NULL)
+ {
+ FUN_02016828(3, 0xf, 0x100);
+ UNK_021C5A00 =
+ (struct UnkStruct_02031734 *)AllocFromHeap(0xf, sizeof(struct UnkStruct_02031734));
+ MI_CpuFill8(UNK_021C5A00, 0, sizeof(struct UnkStruct_02031734));
+ UNK_021C5A00->unk3F = 0x19;
+ UNK_021C5A00->unk46 = 1;
+ UNK_021C5A00->unk28 = sav2;
+ FUN_020334E8(0, 1);
+ FUN_020166A8(1);
+ }
+}
+
+THUMB_FUNC void FUN_02033364()
+{
+ if (UNK_021C5A00 != 0)
+ {
+ FUN_020166B8(1);
+ FUN_020334E8(0, 0);
+ FreeToHeap(UNK_021C5A00);
+ UNK_021C5A00 = NULL;
+ FUN_020168D0(0xf);
+ }
+}
+
+THUMB_FUNC u32 FUN_02033398()
+{
+ u32 st4;
+ u32 st0;
+ if (UNK_021C5A00 == NULL)
+ {
+ return 0;
+ }
+
+ if (UNK_021C5A00->unk3F == 0x18)
+ {
+ if (MOD04_021DD718(&st4, &st0) != 0)
+ {
+ MOD04_021DD6F0();
+ return 1;
+ }
+ }
+ else if (UNK_021C5A00->unk3F == 0x19)
+ {
+ if (MOD04_021DD718(&st4, &st0) != 0 && st0 == 7)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_020333F0()
+{
+ s32 res = MOD04_021D76AC();
+ if (res < 0)
+ {
+ FUN_02032F20((u32)res);
+ FUN_02031D20(FUN_02032E8C, 0);
+ return;
+ }
+ else if (res > 0)
+ {
+ FUN_02031D20(FUN_02033060, 0);
+ }
+}
+
+THUMB_FUNC void FUN_0203341C()
+{
+ if (FUN_0202E4C8())
+ {
+ FUN_02016828(3, 0x31, 0x31000);
+ if (FUN_0202F918(1, 1, 0x200, 1) != 0)
+ {
+ MOD05_021D74E0(UNK_021C5A00->unk28, 0x31);
+ MOD04_021D83A8(FUN_020335D0);
+ FUN_0202FA10();
+ FUN_02031D20(FUN_020333F0, 0);
+ }
+ }
+}
+
+THUMB_FUNC void *FUN_0203346C(struct SaveBlock2 *sav2, u32 param1)
+{
+ Sav2_PlayerData_GetProfileAddr(sav2);
+ if (FUN_02030F40() != 0)
+ {
+ return 0;
+ }
+
+ FUN_020166A8(1);
+ FUN_02016828(3, 0xf, 0x7080);
+ FUN_02031734(sav2, 0x17);
+ UNK_021C5A00->unk00 = AllocFromHeap(0xf, param1);
+ MI_CpuFill8(UNK_021C5A00->unk00, 0, param1);
+
+ UNK_021C5A00->unk40 = 0;
+ UNK_021C5A00->unk28 = sav2;
+ FUN_02031D20(FUN_0203341C, 0);
+
+ return UNK_021C5A00->unk00;
+}
+
+THUMB_FUNC void *FUN_020334DC()
+{
+ return UNK_021C5A00->unk00;
+}
+
+THUMB_FUNC void FUN_020334E8(u8 param0, u8 param1)
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk44 = param0;
+ UNK_021C5A00->unk45 = param1;
+ }
+
+ FUN_0202EE84(param0);
+ FUN_0202EEB0(param0);
+}
+
+THUMB_FUNC u8 FUN_02033510()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ if (UNK_021C5A00->unk4E != 0)
+ {
+ return 1;
+ }
+
+ return UNK_021C5A00->unk45;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC s32 FUN_02033534()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ return UNK_021C5A00->unk3F;
+ }
+
+ return 1;
+}
+
+THUMB_FUNC u8 FUN_0203354C()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ return UNK_021C5A00->unk40;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_02033564(void *src)
+{
+ MI_CpuCopy8(src, UNK_021C5A00->unk04, 0x6);
+}
+
+THUMB_FUNC void FUN_02033578(void *dst)
+{
+ MI_CpuCopy8(UNK_021C5A00->unk04, dst, 0x6);
+}
+
+THUMB_FUNC u32 FUN_02033590()
+{
+ if (FUN_02033534() >= 0x13)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_020335A4(u8 param0)
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk47 = param0;
+ }
+}
+
+THUMB_FUNC u8 FUN_020335B8()
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ return UNK_021C5A00->unk47;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_020335D0(s32 param0)
+{
+ FUN_02033F70(0, 1, param0);
+ while (TRUE)
+ {
+ }
+}
+
+THUMB_FUNC void FUN_020335E0()
+{
+ FUN_02033F70(0, 4, 0);
+ while (TRUE)
+ {
+ }
+}
+
+THUMB_FUNC void FUN_020335F0()
+{
+}
+
+THUMB_FUNC void FUN_020335F4()
+{
+ if (FUN_02033510() != 0)
+ {
+ if (FUN_020311F0() == 0 && FUN_02033250() == 0 && FUN_02033398() == 0)
+ {
+ if (UNK_021C5A00->unk4E == 0)
+ {
+ return;
+ }
+ }
+
+ if (FUN_020335B8() != 0)
+ {
+ return;
+ }
+
+ FUN_0200541C();
+ FUN_0202287C(UNK_021C5A00->unk28);
+ gMain.unk64 = 1;
+ if (UNK_021C5A00->unk4E == 3)
+ {
+ FUN_020335A4(3);
+ return;
+ }
+
+ if (UNK_021C5A00->unk3F == 0x19 || UNK_021C5A00->unk3F == 0xf)
+ {
+ FUN_020335A4(2);
+ }
+ else
+ {
+ FUN_020335A4(1);
+ }
+ }
+}
+
+THUMB_FUNC BOOL FUN_02033678()
+{
+ if (FUN_0202EDD8() || !FUN_02031810())
+ {
+ return TRUE;
+ }
+
+ if (!FUN_0202E344())
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC u32 FUN_020336A0(u8 param0)
+{
+ if (UNK_021C5A00 != NULL)
+ {
+ UNK_021C5A00->unk4E = param0;
+ FUN_02031468();
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/arm9/src/unk_02033778.c b/arm9/src/unk_02033778.c
new file mode 100644
index 00000000..fa2a67da
--- /dev/null
+++ b/arm9/src/unk_02033778.c
@@ -0,0 +1,33 @@
+#include "global.h"
+#include "unk_02033778.h"
+#include "unk_0202F150.h"
+#include "player_data.h"
+
+extern struct PlayerData *FUN_0202DFA4(s32 param0);
+extern u32 FUN_0202E020(s32 param0);
+extern u32 FUN_0202E044(s32 param0);
+extern u32 FUN_02029B40(u32 param0, u32 param1, u32 param2, u32 language);
+extern void FUN_02029B90(u32 param0, u32 param1, u32 param2, u32 param3);
+
+THUMB_FUNC void FUN_02033778(u32 param0)
+{
+ s32 unk = FUN_02030F20();
+ if (FUN_0202DFA4(0) != NULL)
+ {
+ for (s32 i = 0; i < unk; i++)
+ {
+ if (FUN_02031190() != i)
+ {
+ FUN_020337C8(param0, FUN_0202E020(i), FUN_0202E044(i), PlayerProfile_GetLanguage(FUN_0202DFA4(i)));
+ }
+ }
+ }
+}
+
+THUMB_FUNC void FUN_020337C8(u32 param0, u32 param1, u32 param2, u32 language)
+{
+ if (FUN_02029B40(param0, param1, param2, language) == 0)
+ {
+ FUN_02029B90(param0, param1, param2, 1);
+ }
+}
diff --git a/arm9/src/unk_020337E8.c b/arm9/src/unk_020337E8.c
new file mode 100644
index 00000000..856ba3b8
--- /dev/null
+++ b/arm9/src/unk_020337E8.c
@@ -0,0 +1,50 @@
+#include "unk_020337E8.h"
+#include "heap.h"
+
+extern struct DWC_Struct *FUN_020286EC(struct SaveBlock2 *sav2);
+extern struct DWC_Struct *FUN_02028228(struct DWC_Struct *);
+
+// DWC_init
+extern s32 DWC_Init(s32);
+
+// DWC_account
+extern void DWC_CreateExchangeToken(struct DWC_Struct *, struct DWC_token *);
+extern void DWC_CreateUserData(struct DWC_Struct *, s32);
+extern void DWC_ClearDirtyFlag(struct DWC_Struct *);
+extern BOOL DWC_CheckHasProfile(struct DWC_Struct *);
+extern BOOL DWC_CheckValidConsole(struct DWC_Struct *);
+extern BOOL DWC_CheckUserData(struct DWC_Struct *);
+extern s32 DWC_GetGsProfileId(struct DWC_Struct *, struct DWC_token *);
+
+THUMB_FUNC s32 FUN_020337E8(u32 heap_id)
+{
+ s32 ret = (s32)AllocFromHeap(heap_id, 0x720);
+ s32 ret1 = DWC_Init((ret + 0x1F) & ~0x1F);
+ FreeToHeap((void*)ret);
+ return ret1;
+}
+
+THUMB_FUNC void FUN_0203380C(struct DWC_Struct *dwc)
+{
+ struct DWC_Struct * dwc1 = FUN_02028228(dwc);
+ if(!DWC_CheckUserData(dwc1))
+ {
+ DWC_CreateUserData(dwc1, 0x4144414A);
+ DWC_ClearDirtyFlag(dwc1);
+ }
+}
+
+THUMB_FUNC s32 FUN_02033830(struct DWC_Struct *dwc)
+{
+ struct DWC_token token;
+
+ struct DWC_Struct * dwc1 = FUN_02028228(dwc);
+ DWC_CreateExchangeToken(dwc1, &token);
+ return DWC_GetGsProfileId(dwc1, &token);
+}
+
+THUMB_FUNC BOOL FUN_0203384C(struct SaveBlock2 *sav2)
+{
+ struct DWC_Struct * dwc = FUN_02028228(FUN_020286EC(sav2));
+ return (DWC_CheckHasProfile(dwc) && DWC_CheckValidConsole(dwc));
+}
diff --git a/arm9/src/unk_0204639C.c b/arm9/src/unk_0204639C.c
index 50aae8fa..c8291f5a 100644
--- a/arm9/src/unk_0204639C.c
+++ b/arm9/src/unk_0204639C.c
@@ -4,7 +4,7 @@
#pragma thumb on
-struct UnkStruct_0204639C * FUN_0204639C(struct UnkStruct_0204639C * r5, UnkStruct_0204639C_cb r6, u32 * r7)
+struct UnkStruct_0204639C * FUN_0204639C(struct UnkSavStruct80 * r5, UnkStruct_0204639C_cb r6, u32 * r7)
{
struct UnkStruct_0204639C * ret = AllocFromHeapAtEnd(32, sizeof(struct UnkStruct_0204639C));
ret->unk0 = 0;
@@ -18,10 +18,9 @@ struct UnkStruct_0204639C * FUN_0204639C(struct UnkStruct_0204639C * r5, UnkStru
return ret;
}
-void FUN_020463CC(struct UnkStruct_0204639C * r5, UnkStruct_0204639C_cb r4, u32 * r6)
+void FUN_020463CC(struct UnkSavStruct80 * r5, UnkStruct_0204639C_cb r4, u32 * r6)
{
- if (r5->unk10 != NULL)
- ErrorHandling();
+ GF_ASSERT(r5->unk10 == NULL);
r5->unk10 = FUN_0204639C(r5, r4, r6);
}
@@ -85,7 +84,7 @@ BOOL FUN_020464A4(void * r0)
BOOL FUN_020464B8(struct UnkStruct_0204639C * r4)
{
- struct UnkStruct_0204639C * r5 = FUN_02046528(r4);
+ struct UnkSavStruct80 * r5 = FUN_02046528(r4);
u32 * r4_2 = FUN_0204652C(r4);
switch (r4_2[0])
{
@@ -113,7 +112,7 @@ void FUN_02046500(struct UnkStruct_0204639C * r6, u32 r5, u32 r4)
FUN_0204640C(r6, FUN_020464B8, r2);
}
-struct UnkStruct_0204639C * FUN_02046528(struct UnkStruct_0204639C * r0)
+struct UnkSavStruct80 * FUN_02046528(struct UnkStruct_0204639C * r0)
{
return r0->unk18;
}
diff --git a/arm9/src/unk_0204AEA8.c b/arm9/src/unk_0204AEA8.c
index 9c572a8e..a2b2dd71 100644
--- a/arm9/src/unk_0204AEA8.c
+++ b/arm9/src/unk_0204AEA8.c
@@ -3,12 +3,12 @@
#include "unk_0204639C.h"
#include "unk_0204AEA8.h"
-extern void MOD05_021E3444(u32, struct UnkStruct_0204639C *, u32);
+extern void MOD05_021E3444(u32, struct UnkSavStruct80 *, u32);
extern void FUN_0200433C(u32, u16, u32);
THUMB_FUNC BOOL FUN_0204AEA8(struct UnkStruct_0204639C *a0)
{
- struct UnkStruct_0204639C *v0 = FUN_02046528(a0);
+ struct UnkSavStruct80 *v0 = FUN_02046528(a0);
u32 *v1 = FUN_0204652C(a0);
switch (v1[0])
diff --git a/arm9/src/unk_0204B0A0.c b/arm9/src/unk_0204B0A0.c
new file mode 100644
index 00000000..15a9111d
--- /dev/null
+++ b/arm9/src/unk_0204B0A0.c
@@ -0,0 +1,198 @@
+#include "global.h"
+#include "event_data.h"
+#include "unk_0204B0A0.h"
+#include "unk_0205FA2C.h"
+
+extern void GF_RTC_CopyDateTime(struct RTCDate* date, struct RTCTime* time);
+extern void FUN_02029C08(void*);
+extern void FUN_0202B3C4(void*, s32, u32);
+extern u8 GF_RTC_GetTimeOfDayByHour(u32 hour);
+extern s64 GF_RTC_DateTimeToSec(void);
+extern void* FUN_02029AFC(struct SaveBlock2* sav2);
+extern void* FUN_02022504(struct SaveBlock2* sav2);
+extern void FUN_02025B60(struct SaveBlock2* sav2, s32, BOOL);
+extern BOOL FUN_0205F668(struct SaveBlock2* sav2);
+extern void FUN_0202A9D0(struct SaveBlock2* sav2, s32);
+extern BOOL FUN_0205F618(struct SaveBlock2* sav2, u16);
+extern void FUN_0204B3D0(struct UnkSavStruct80*, s32);
+extern void FUN_0205F5A4(struct ScriptState* state, u16);
+extern s32 FUN_0205F594(struct ScriptState* state);
+extern void FUN_0202A988(void*, u32);
+extern void* FUN_0202A9B0(struct SaveBlock2* sav2);
+extern void FUN_02060344(struct SaveBlock2* sav2, s32);
+extern void FUN_0203959C(struct UnkSavStruct80*);
+extern void FUN_02025A60(struct SaveBlock2* sav2, s32);
+extern struct SaveBlock2* ScriptEnvironment_GetSav2Ptr(struct UnkSavStruct80*);
+
+THUMB_FUNC void FUN_0204B0F8(struct UnkSavStruct80* unk)
+{
+ RTCDate date;
+ RTCTime time;
+
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+ if (rtc_info->field_00 != 0)
+ {
+ GF_RTC_CopyDateTime(&date, &time);
+ FUN_0204B130(unk, rtc_info, &date);
+ FUN_0204B158(unk, rtc_info, &date, &time);
+ }
+}
+
+THUMB_FUNC void FUN_0204B130(struct UnkSavStruct80* unk, struct UnkSaveStruct_0202376C_sub* rtc_info, struct RTCDate* date)
+{
+ u32 days = (u32)RTC_ConvertDateToDay(date);
+ u32 days_since_nitro_epoch = (u32)rtc_info->daysSinceNitroEpoch;
+
+ if (days < days_since_nitro_epoch)
+ {
+ rtc_info->daysSinceNitroEpoch = (s32)days;
+ }
+ else if (days > days_since_nitro_epoch)
+ {
+ FUN_0204B1DC(unk, (s32)(days - days_since_nitro_epoch));
+ rtc_info->daysSinceNitroEpoch = (s32)days;
+ }
+}
+
+THUMB_FUNC void FUN_0204B158(struct UnkSavStruct80* unk, struct UnkSaveStruct_0202376C_sub* rtc_info, struct RTCDate* date, struct RTCTime* time)
+{
+ s64 unk1 = RTC_ConvertDateTimeToSecond(date, time);
+ s64 unk2 = RTC_ConvertDateTimeToSecond(&rtc_info->date, &rtc_info->time);
+
+ if (unk2 > unk1)
+ {
+ rtc_info->date = *date;
+ rtc_info->time = *time;
+ return;
+ }
+
+ s32 minutes = (s32)((unk1 - unk2) / 60);
+ if (minutes > 0)
+ {
+ FUN_02023884(rtc_info, (u32)minutes);
+ FUN_0204B270(unk, minutes, time);
+
+ rtc_info->date = *date;
+ rtc_info->time = *time;
+ }
+}
+
+THUMB_FUNC void FUN_0204B1DC(struct UnkSavStruct80* unk, s32 a1)
+{
+ struct SaveBlock2* sav2 = ScriptEnvironment_GetSav2Ptr(unk);
+ FUN_02025A60(sav2, a1);
+ FUN_0203959C(unk);
+ FUN_02060344(unk->saveBlock2, a1);
+
+ void* unk_sav_ptr1 = FUN_0202881C(unk->saveBlock2);
+ FUN_02028754(unk_sav_ptr1, (u32)a1);
+
+ void* unk_sav_ptr2 = FUN_0202A9B0(unk->saveBlock2);
+ unk_sav_ptr1 = FUN_0202881C(unk->saveBlock2);
+ u32 unk1 = FUN_020287A4(unk_sav_ptr1);
+ FUN_0202A988(unk_sav_ptr2, unk1);
+
+ struct PlayerParty* party = SavArray_PlayerParty_get(unk->saveBlock2);
+ Party_UpdatePokerus(party, a1);
+
+ struct ScriptState* state = SavArray_Flags_get(unk->saveBlock2);
+ s32 unk2 = FUN_0205F594(state);
+
+ u16 unk3;
+ if (unk2 > a1)
+ {
+ unk3 = (u16)(unk2 - a1);
+ }
+ else
+ {
+ unk3 = 0;
+ }
+
+ FUN_0205F5A4(state, unk3);
+ FUN_0205F618(unk->saveBlock2, (u16)a1);
+ FUN_0205F668(unk->saveBlock2);
+ FUN_0206007C(unk->saveBlock2);
+
+ void* unk_sav_ptr3 = FUN_02029AFC(unk->saveBlock2);
+ FUN_02029C08(unk_sav_ptr3);
+}
+
+THUMB_FUNC void FUN_0204B270(struct UnkSavStruct80* unk, s32 a1, struct RTCTime* time)
+{
+ FUN_0204B3D0(unk, a1);
+ FUN_0202A9D0(unk->saveBlock2, a1);
+ BOOL unk_bool = FUN_0204B33C(unk);
+ FUN_02025B60(unk->saveBlock2, a1, unk_bool);
+ void* unk_sav_ptr = FUN_02022504(unk->saveBlock2);
+ FUN_0202B3C4(unk_sav_ptr, a1, time->minute);
+}
+
+THUMB_FUNC u32 Script_GetTimeOfDay(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return GF_RTC_GetTimeOfDayByHour(rtc_info->time.hour);
+}
+
+THUMB_FUNC u32 Script_GetMonth(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return rtc_info->date.month;
+}
+
+THUMB_FUNC u32 Script_GetDay(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return rtc_info->date.day;
+}
+
+THUMB_FUNC RTCWeek Script_GetWeekday(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return rtc_info->date.week;
+}
+
+THUMB_FUNC u32 Script_GetHour(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return rtc_info->time.hour;
+}
+
+THUMB_FUNC u32 Script_GetMinute(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return rtc_info->time.minute;
+}
+
+THUMB_FUNC void Script_SavRTC_x24toDateTime(struct UnkSavStruct80* unk, struct RTCDate* date, struct RTCTime* time)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ RTC_ConvertSecondToDateTime(date, time, rtc_info->secondsSinceNitroEpoch);
+}
+
+THUMB_FUNC void Script_SavRTC_x2CtoDateTime(struct UnkSavStruct80* unk, struct RTCDate* date, struct RTCTime* time)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ RTC_ConvertSecondToDateTime(date, time, rtc_info->field_2C);
+}
+
+THUMB_FUNC void Script_SavRTC_DateTimeTox2C(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ rtc_info->field_2C = GF_RTC_DateTimeToSec();
+}
+
+THUMB_FUNC BOOL FUN_0204B33C(struct UnkSavStruct80* unk)
+{
+ struct UnkSaveStruct_0202376C_sub* rtc_info = Sav2_SysInfo_RTC_get(unk->saveBlock2);
+
+ return FUN_02023874(rtc_info);
+}
diff --git a/arm9/src/unk_0205FA2C.c b/arm9/src/unk_0205FA2C.c
index 7bcdf950..cabd756e 100644
--- a/arm9/src/unk_0205FA2C.c
+++ b/arm9/src/unk_0205FA2C.c
@@ -1,18 +1,16 @@
#include "unk_0205FA2C.h"
+#include "unk_020337E8.h"
extern void *UNK_020F96DC;
extern void *UNK_020FA6E8;
extern u32 FUN_02079C70(struct SaveBlock2 *sav2);
extern void FUN_0207B000(struct UnkPlayerStruct2_0205FA2C *ptr, const u8 param1[12]);
extern void FUN_0207C2A4(struct UnkPlayerStruct2_0205FA2C *ptr, struct PlayerData *player_data);
-extern u32 FUN_0203384C(u32 *param0);
-extern u32 *FUN_02038790(struct UnkStruct_0204639C *param0, u16 param1, u16 param2);
+extern u32 *FUN_02038790(struct UnkSavStruct80 *param0, u16 param1, u16 param2);
extern u16 *GetVarPointer(struct UnkSavStruct80 *arg, u16);
-extern u32 FUN_02031190();
-extern u32 FUN_020316E0(u32 param0);
-extern u16 MOD06_02244660(struct UnkStruct_0204639C *param0, u32 param1);
-extern u16 MOD06_022446BC(struct UnkStruct_0204639C *param0, u32 param1);
-extern u16 MOD06_022446E0(struct UnkStruct_0204639C *param0, u32 param1);
+extern u16 MOD06_02244660(struct UnkSavStruct80 *param0, u8 *param1);
+extern u16 MOD06_022446BC(struct UnkSavStruct80 *param0, u8 *param1);
+extern u16 MOD06_022446E0(struct UnkSavStruct80 *param0, u8 *param1);
extern void FUN_0202A5CC(u32 param0, u32 param1);
extern u32 FUN_0202A5D0(u32 param0);
extern u32 FUN_0202A150(struct UnkStruct_02029FB0 *param0, u32 param1);
@@ -38,12 +36,12 @@ const u8 UNK_020F7454[] = {
};
THUMB_FUNC u32 FUN_0205FA2C(
- struct UnkCallbackStruct1_0205FA2C *param0, struct UnkStruct_0204639C *param1, u32 heap_id)
+ struct UnkCallbackStruct1_0205FA2C *param0, struct UnkSavStruct80 *param1, u32 heap_id)
{
struct UnkPlayerStruct1_0205FA2C *ptr = (struct UnkPlayerStruct1_0205FA2C *)AllocFromHeapAtEnd(
heap_id, sizeof(struct UnkPlayerStruct1_0205FA2C));
- struct SaveBlock2 *sav2 = (struct SaveBlock2 *)(param1->unkC);
+ struct SaveBlock2 *sav2 = param1->saveBlock2;
MI_CpuFill8(ptr, 0, sizeof(struct UnkPlayerStruct1_0205FA2C));
ptr->options = Sav2_PlayerData_GetOptionsAddr(sav2);
@@ -72,7 +70,7 @@ THUMB_FUNC u32 FUN_0205FA2C(
}
THUMB_FUNC u32 FUN_0205FAD8(
- struct UnkCallbackStruct1_0205FA2C *param0, struct UnkStruct_0204639C *param1)
+ struct UnkCallbackStruct1_0205FA2C *param0, struct UnkSavStruct80 *param1)
{
if (FUN_0204647C(param1))
{
@@ -107,9 +105,9 @@ THUMB_FUNC u32 FUN_0205FAD8(
}
THUMB_FUNC u32 FUN_0205FB34(
- struct UnkCallbackStruct1_0205FA2C *param0, struct UnkStruct_0204639C *param1, u32 heap_id)
+ struct UnkCallbackStruct1_0205FA2C *param0, struct UnkSavStruct80 *param1, u32 heap_id)
{
- struct SaveBlock2 *sav2 = (struct SaveBlock2 *)(param1->unkC);
+ struct SaveBlock2 *sav2 = param1->saveBlock2;
struct UnkPlayerStruct2_0205FA2C *ptr = (struct UnkPlayerStruct2_0205FA2C *)AllocFromHeapAtEnd(
heap_id, sizeof(struct UnkPlayerStruct2_0205FA2C));
@@ -142,7 +140,7 @@ THUMB_FUNC u32 FUN_0205FB34(
}
THUMB_FUNC u32 FUN_0205FBC0(
- struct UnkCallbackStruct1_0205FA2C *param0, struct UnkStruct_0204639C *param1)
+ struct UnkCallbackStruct1_0205FA2C *param0, struct UnkSavStruct80 *param1)
{
if (FUN_0204647C(param1))
{
@@ -160,7 +158,7 @@ THUMB_FUNC u32 FUN_0205FBC0(
THUMB_FUNC int FUN_0205FBE8(struct UnkStruct_0204639C *param0)
{
- struct UnkStruct_0204639C *res = FUN_02046528(param0);
+ struct UnkSavStruct80 *res = FUN_02046528(param0);
struct UnkCallbackStruct1_0205FA2C *res2 =
(struct UnkCallbackStruct1_0205FA2C *)FUN_0204652C(param0);
switch (res2->unk04)
@@ -194,7 +192,7 @@ THUMB_FUNC void FUN_0205FC50(struct UnkStruct_0204639C *param0,
u8 param6,
u8 param7)
{
- struct UnkStruct_0204639C *res = FUN_02046528(param0);
+ struct UnkSavStruct80 *res = FUN_02046528(param0);
struct UnkCallbackStruct1_0205FA2C *ptr = (struct UnkCallbackStruct1_0205FA2C *)AllocFromHeap(
0xb, sizeof(struct UnkCallbackStruct1_0205FA2C));
@@ -212,9 +210,9 @@ THUMB_FUNC void FUN_0205FC50(struct UnkStruct_0204639C *param0,
}
THUMB_FUNC u32 FUN_0205FC9C(
- struct UnkCallbackStruct2_0205FA2C *param0, struct UnkStruct_0204639C *param1)
+ struct UnkCallbackStruct2_0205FA2C *param0, struct UnkSavStruct80 *param1)
{
- if (FUN_0203384C(param1->unkC))
+ if (FUN_0203384C(param1->saveBlock2))
{
param0->unk08 = FUN_02038790(param1, param0->unk12, param0->unk14);
@@ -226,7 +224,7 @@ THUMB_FUNC u32 FUN_0205FC9C(
}
THUMB_FUNC u32 FUN_0205FCC4(
- struct UnkCallbackStruct2_0205FA2C *param0, struct UnkStruct_0204639C *param1)
+ struct UnkCallbackStruct2_0205FA2C *param0, struct UnkSavStruct80 *param1)
{
if (FUN_0204647C(param1))
{
@@ -241,7 +239,7 @@ THUMB_FUNC u32 FUN_0205FCC4(
THUMB_FUNC int FUN_0205FCE8(struct UnkStruct_0204639C *param0)
{
- struct UnkStruct_0204639C *res = FUN_02046528(param0);
+ struct UnkSavStruct80 *res = FUN_02046528(param0);
struct UnkCallbackStruct2_0205FA2C *res2 =
(struct UnkCallbackStruct2_0205FA2C *)FUN_0204652C(param0);
@@ -254,7 +252,7 @@ THUMB_FUNC int FUN_0205FCE8(struct UnkStruct_0204639C *param0)
res2->unk04 = FUN_0205FCC4(res2, res);
break;
case 2:
- u16 *var = GetVarPointer((struct UnkSavStruct80 *)res, res2->unk10);
+ u16 *var = GetVarPointer(res, res2->unk10);
*var = (u16)res2->unk00;
FreeToHeap(res2);
@@ -266,7 +264,7 @@ THUMB_FUNC int FUN_0205FCE8(struct UnkStruct_0204639C *param0)
THUMB_FUNC void FUN_0205FD38(struct UnkStruct_0204639C *param0, u16 param1, u16 param2, u16 param3)
{
- struct UnkStruct_0204639C *res = FUN_02046528(param0);
+ struct UnkSavStruct80 *res = FUN_02046528(param0);
struct UnkCallbackStruct2_0205FA2C *ptr = (struct UnkCallbackStruct2_0205FA2C *)AllocFromHeap(
0xb, sizeof(struct UnkCallbackStruct2_0205FA2C));
MI_CpuFill8(ptr, 0, sizeof(struct UnkCallbackStruct2_0205FA2C));
@@ -280,15 +278,15 @@ THUMB_FUNC void FUN_0205FD38(struct UnkStruct_0204639C *param0, u16 param1, u16
THUMB_FUNC int FUN_0205FD70(struct UnkStruct_0204639C *param0)
{
- struct UnkStruct_0204639C *res = FUN_02046528(param0);
+ struct UnkSavStruct80 *res = FUN_02046528(param0);
u16 *res2 = (u16 *)FUN_0204652C(param0);
- u32 res3 = FUN_020316E0(1 - FUN_02031190());
- if (res3 == 0)
+ u8 *res3 = FUN_020316E0(1 - FUN_02031190());
+ if (res3 == NULL)
{
return 0;
}
- u16 *var = GetVarPointer((struct UnkSavStruct80 *)res, res2[1]);
+ u16 *var = GetVarPointer(res, res2[1]);
switch (res2[0])
{
case 0:
@@ -296,11 +294,9 @@ THUMB_FUNC int FUN_0205FD70(struct UnkStruct_0204639C *param0)
break;
case 1:
*var = MOD06_022446BC(res, res3);
-
break;
case 2:
*var = MOD06_022446E0(res, res3);
-
break;
}
@@ -311,7 +307,7 @@ THUMB_FUNC int FUN_0205FD70(struct UnkStruct_0204639C *param0)
THUMB_FUNC void FUN_0205FDDC(struct UnkStruct_0204639C *param0, u16 param1, u16 param2)
{
- struct UnkStruct_0204639C *res = FUN_02046528(param0);
+ struct UnkSavStruct80 *res = FUN_02046528(param0);
u16 *ptr = AllocFromHeap(0xb, 2 * sizeof(u16));
MI_CpuFill8(ptr, 0, 2 * sizeof(u16));
diff --git a/arm9/src/unk_0206015C.c b/arm9/src/unk_0206015C.c
new file mode 100644
index 00000000..a217f52c
--- /dev/null
+++ b/arm9/src/unk_0206015C.c
@@ -0,0 +1,149 @@
+#include "unk_0206015C.h"
+
+#include "heap.h"
+#include "event_data.h"
+#include "main.h"
+
+/* Note to future reader, there might be some errors
+ in the return type / parameters. They are right for this code
+ but they might not be for every code, please do not blindly
+ trust these prototypes if you are decompiling these functions. */
+extern THUMB_FUNC u32 MOD06_02244DB0(u32);
+extern THUMB_FUNC void MOD06_02244DBC(void*);
+extern THUMB_FUNC void MOD06_02244DC4(void*, void*);
+extern THUMB_FUNC void MOD06_02244EF8(void*);
+extern THUMB_FUNC void MOD06_02244F18(void*);
+extern THUMB_FUNC BOOL MOD06_02244F24(void*);
+extern THUMB_FUNC void MOD06_02244F2C(void*);
+extern THUMB_FUNC void* MOD06_02245088(struct UnkSavStruct80 * savStruct);
+extern THUMB_FUNC u32 MOD06_02245114(u32, struct UnkSavStruct80*);
+extern THUMB_FUNC void MOD06_02245190(u32);
+extern THUMB_FUNC void MOD06_02245198(u8, u32);
+extern THUMB_FUNC u32 MOD06_022451F0(u32);
+
+extern THUMB_FUNC void FUN_020054C8(u32);
+extern THUMB_FUNC void FUN_02049160(struct UnkStruct_0204639C*, u32);
+extern THUMB_FUNC void FUN_0204AF84(struct UnkStruct_0204639C*);
+extern THUMB_FUNC void FUN_0204AF3C(struct UnkStruct_0204639C *);
+extern THUMB_FUNC void FUN_0204AFC8(struct UnkStruct_0204639C *);
+extern THUMB_FUNC void FUN_0204B00C(struct UnkStruct_0204639C *);
+extern THUMB_FUNC void FUN_0204C1B4(struct UnkStruct_0204639C*, u32,u32,u32,u32,u32,u32,u32);
+extern THUMB_FUNC u32 FUN_020553A0(u32);
+extern THUMB_FUNC void FUN_0205889C(u32, u32);
+extern THUMB_FUNC void FUN_0205F1C4(struct ScriptState *);
+extern THUMB_FUNC void FUN_0205F1D4(struct ScriptState *);
+extern THUMB_FUNC void FUN_0206367C(struct UnkSavStruct80 *, u32);
+
+
+
+THUMB_FUNC void FUN_0206015C(struct UnkSavStruct80 *savStruct)
+{
+ struct UnkStruct_0206015C *unkStruct = AllocFromHeapAtEnd(0xb, 0x10);
+ unkStruct->unk0 = MOD06_02244DB0(0xb);
+ unkStruct->unk4 = MOD06_02245114(0xb, savStruct);
+ unkStruct->unkC = 0;
+ unkStruct->unkD = 0;
+
+ FUN_0204640C(savStruct->unk10, FUN_02060194, (u32 *)unkStruct);
+}
+
+THUMB_FUNC BOOL FUN_02060194(struct UnkStruct_0204639C *unkStruct0)
+{
+ struct UnkSavStruct80 *savStruct = FUN_02046528(unkStruct0);
+ struct UnkStruct_0204652C *unkStruct1 = (struct UnkStruct_0204652C *)FUN_0204652C(unkStruct0);
+
+ switch (unkStruct1->action)
+ {
+ case 0:
+ FUN_0206367C(savStruct, 1);
+ MOD06_02245198(unkStruct1->unkD, unkStruct1->unk4);
+ unkStruct1->unk8 = MOD06_022451F0(unkStruct1->unk4);
+ FUN_0204AFC8(unkStruct0);
+ unkStruct1->action = 1;
+ break;
+
+ case 1:
+ FUN_0204AF3C(unkStruct0);
+ unkStruct1->action = 2;
+ break;
+
+ case 2:
+ struct ScriptState *scrState = SavArray_Flags_get(savStruct->saveBlock2);
+ u8 unkD = unkStruct1->unkD;
+ if (unkD == 0)
+ {
+ FUN_0205F1C4(scrState);
+ }
+ else if (unkD == 5)
+ {
+ FUN_0205F1D4(scrState);
+ }
+ FUN_02049160(unkStruct0, unkStruct1->unk8);
+ unkStruct1->action = 3;
+ break;
+
+ case 3:
+ FUN_0204AF84(unkStruct0);
+ unkStruct1->action = 4;
+ break;
+
+ case 4:
+ u32 unk0 = FUN_020553A0(savStruct->unk38);
+ unkStruct1->unkD += 1;
+ if (unkStruct1->unkD <= 5)
+ {
+ void *unkAddr = MOD06_02245088(savStruct);
+ FUN_0205889C(unk0, 1);
+ MOD06_02244DC4(unkStruct1->unk0, unkAddr);
+ MOD06_02244EF8(unkStruct1->unk0);
+ unkStruct1->unkE = 0;
+ FUN_020054C8(1657);
+ FUN_0204C1B4(unkStruct0, 0x3, 0x11, 0x0000FFFF, 0, 6, 1, 0xb);
+ unkStruct1->action = 5;
+ }
+ else
+ {
+ FUN_0205889C(unk0, 0);
+ FUN_0204B00C(unkStruct0);
+ unkStruct1->action = 8;
+ }
+ break;
+
+ case 5:
+ unkStruct1->unkE += 1;
+ if (unkStruct1->unkE < 0x3c && !(gMain.newKeys & 1))
+ break;
+
+ MOD06_02245198(unkStruct1->unkD, unkStruct1->unk4);
+ unkStruct1->unk8 = MOD06_022451F0(unkStruct1->unk4);
+
+ FUN_020054C8(1657);
+ FUN_0204C1B4(unkStruct0, 0x3, 0x10, 0x0000FFFF, 0, 6, 1, 0xb);
+ unkStruct1->action = 6;
+ break;
+
+ case 6:
+ MOD06_02244F18(unkStruct1->unk0);
+ unkStruct1->action = 7;
+ break;
+
+ case 7:
+ if (MOD06_02244F24(unkStruct1->unk0))
+ {
+ MOD06_02244F2C(unkStruct1->unk0);
+ unkStruct1->action = 1;
+ }
+ break;
+
+ case 8:
+ FUN_0206367C(savStruct, 0);
+ MOD06_02245190(unkStruct1->unk4);
+ MOD06_02244DBC(unkStruct1->unk0);
+ FreeToHeap(unkStruct1);
+ return TRUE;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
diff --git a/arm9/src/unk_0206439C.c b/arm9/src/unk_0206439C.c
new file mode 100644
index 00000000..80d93557
--- /dev/null
+++ b/arm9/src/unk_0206439C.c
@@ -0,0 +1,16 @@
+#include "global.h"
+#include "heap.h"
+#include "party.h"
+#include "save_block_2.h"
+#include "unk_0206439C.h"
+
+THUMB_FUNC struct UnkStruct_0206439C* FUN_0206439C(u32 heap_id, u8 mon_idx, struct SaveBlock2* sav2)
+{
+ struct UnkStruct_0206439C* ret = AllocFromHeapAtEnd(heap_id, sizeof(struct UnkStruct_0206439C));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav2);
+
+ ret->pokemon = GetPartyMonByIndex(party, mon_idx);
+ ret->unk4 = NULL;
+
+ return ret;
+}
diff --git a/arm9/src/unk_0208890C.c b/arm9/src/unk_0208890C.c
new file mode 100644
index 00000000..0bc8803f
--- /dev/null
+++ b/arm9/src/unk_0208890C.c
@@ -0,0 +1,53 @@
+#include "global.h"
+#include "bag.h"
+#include "heap.h"
+#include "main.h"
+#include "MI_memory.h"
+#include "player_data.h"
+#include "script.h"
+#include "unk_0208890C.h"
+
+extern struct SaveBlock2* ScriptEnvironment_GetSav2Ptr(struct UnkSavStruct80*);
+extern void* FUN_02028048(struct SaveBlock2* sav2);
+extern void FUN_020373D4(struct UnkSavStruct80*, struct Unk21DBE18*, void*);
+extern BOOL FUN_020889B0(struct UnkStruct_02006234*, u32*);
+extern BOOL FUN_02088A00(struct UnkStruct_02006234*, u32*);
+extern BOOL FUN_02088A78(struct UnkStruct_02006234*, u32*);
+
+const struct Unk21DBE18 UNK_020FD6E4 = {
+ FUN_020889B0,
+ FUN_02088A00,
+ FUN_02088A78,
+ 0xFFFFFFFF,
+};
+
+THUMB_FUNC struct UnkStruct_0208890C* FUN_0208890C(void* a0, struct SaveBlock2* sav2, u32 heap_id, void* a3)
+{
+ struct UnkStruct_0208890C* ret = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0208890C));
+ MI_CpuFill8(ret, 0, sizeof(struct UnkStruct_0208890C));
+
+ ret->sav2 = sav2;
+ ret->unk8 = FUN_02028048(sav2);
+ ret->player = Sav2_PlayerData_GetProfileAddr(sav2);
+ ret->bag = Sav2_Bag_get(sav2);
+ ret->options = Sav2_PlayerData_GetOptionsAddr(sav2);
+ ret->unk1C = a3;
+ ret->unk4 = a0;
+
+ return ret;
+}
+
+THUMB_FUNC void FUN_02088950(struct UnkSavStruct80* unk, struct UnkStruct_0208890C* unk2)
+{
+ FUN_020373D4(unk, (struct Unk21DBE18*)&UNK_020FD6E4, unk2);
+}
+
+THUMB_FUNC struct UnkStruct_0208890C* FUN_02088960(struct UnkSavStruct80* unk, void* a1, u32 heap_id)
+{
+ struct SaveBlock2* sav2 = ScriptEnvironment_GetSav2Ptr(unk);
+ struct UnkStruct_0208890C* ret = FUN_0208890C(a1, sav2, heap_id, unk->unk98);
+
+ FUN_02088950(unk, ret);
+
+ return ret;
+}
diff --git a/arm9/src/unk_0208A300.c b/arm9/src/unk_0208A300.c
new file mode 100644
index 00000000..3c4a496b
--- /dev/null
+++ b/arm9/src/unk_0208A300.c
@@ -0,0 +1,38 @@
+#include "global.h"
+#include "heap.h"
+#include "unk_0208A300.h"
+
+THUMB_FUNC struct UnkStruct_0208A300* FUN_0208A300(u32 heap_id)
+{
+ struct UnkStruct_0208A300* ret = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0208A300));
+
+ __builtin__clear(ret, sizeof(struct UnkStruct_0208A300));
+ ret->unk4 = 2;
+
+ return ret;
+}
+
+THUMB_FUNC void FUN_0208A320(struct UnkStruct_0208A300* unk)
+{
+ FreeToHeap(unk);
+}
+
+THUMB_FUNC u32 FUN_0208A328(struct UnkStruct_0208A300* unk)
+{
+ return unk->unk0;
+}
+
+THUMB_FUNC void FUN_0208A32C(struct UnkStruct_0208A300* unk, u32 a1)
+{
+ unk->unk0 = a1;
+}
+
+THUMB_FUNC u32 FUN_0208A330(struct UnkStruct_0208A300* unk)
+{
+ return unk->unk4;
+}
+
+THUMB_FUNC void FUN_0208A334(struct UnkStruct_0208A300* unk, u32 a1)
+{
+ unk->unk4 = a1;
+}