summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/GX_layers.c2
-rw-r--r--arm9/src/bg_window.c2
-rw-r--r--arm9/src/brightness.c198
-rw-r--r--arm9/src/communication_error.c12
-rw-r--r--arm9/src/error_message_reset.c11
-rw-r--r--arm9/src/font.c38
-rw-r--r--arm9/src/game_init.c2
-rw-r--r--arm9/src/main.c11
-rw-r--r--arm9/src/oam.c169
-rw-r--r--arm9/src/pokemon.c11
-rw-r--r--arm9/src/render_text.c2
-rw-r--r--arm9/src/render_window.c1027
-rw-r--r--arm9/src/rs_migrate_string.c327
-rw-r--r--arm9/src/save.c14
-rw-r--r--arm9/src/save_data_read_error.c185
-rw-r--r--arm9/src/save_data_write_error.c130
-rw-r--r--arm9/src/scrcmd.c54
-rw-r--r--arm9/src/scrcmd_amity_square.c200
-rw-r--r--arm9/src/scrcmd_sound.c17
-rw-r--r--arm9/src/script_buffers.c122
-rw-r--r--arm9/src/sound.c2
-rw-r--r--arm9/src/sound_chatot.c181
-rw-r--r--arm9/src/text.c41
-rw-r--r--arm9/src/text_02054590.c20
-rw-r--r--arm9/src/unk_020040F4.c31
-rw-r--r--arm9/src/unk_020051F4.c6
-rw-r--r--arm9/src/unk_02008AA4.c249
-rw-r--r--arm9/src/unk_02008DEC.c1118
-rw-r--r--arm9/src/unk_0200BB14.c272
-rw-r--r--arm9/src/unk_02021590.c212
-rw-r--r--arm9/src/unk_02021934.c9
-rw-r--r--arm9/src/wfc_user_info_warning.c11
32 files changed, 4302 insertions, 384 deletions
diff --git a/arm9/src/GX_layers.c b/arm9/src/GX_layers.c
index 28147dbd..348a398a 100644
--- a/arm9/src/GX_layers.c
+++ b/arm9/src/GX_layers.c
@@ -96,7 +96,7 @@ THUMB_FUNC void GX_BothDispOn()
THUMB_FUNC void GX_SwapDisplay()
{
- if (gMain.unk65 == 0)
+ if (gMain.screensFlipped == 0)
{
GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB);
}
diff --git a/arm9/src/bg_window.c b/arm9/src/bg_window.c
index 2986645f..f1a5e525 100644
--- a/arm9/src/bg_window.c
+++ b/arm9/src/bg_window.c
@@ -1366,7 +1366,7 @@ THUMB_FUNC void CopyBgTilemapRectAffine(struct Bg *bg,
}
THUMB_FUNC void FillBgTilemapRect(struct BgConfig *bgConfig,
- u32 bgId,
+ u8 bgId,
u16 fillValue,
u8 x,
u8 y,
diff --git a/arm9/src/brightness.c b/arm9/src/brightness.c
new file mode 100644
index 00000000..59e96fd3
--- /dev/null
+++ b/arm9/src/brightness.c
@@ -0,0 +1,198 @@
+#include "global.h"
+#include "brightness.h"
+#include "GX_g2.h"
+#include "MI_memory.h"
+
+struct BrightnessData mainScreenBrightnessData;
+
+struct BrightnessData subScreenBrightnessData;
+
+THUMB_FUNC void DoBrightnessTransitionStep(struct BrightnessData *brightness)
+{
+ BOOL transitionFinished = FALSE;
+
+ if (brightness->target_brightness !=
+ brightness->current_brightness +
+ brightness->transition_direction * brightness->step_size_integer &&
+ brightness->current_brightness != brightness->target_brightness)
+ {
+ brightness->current_brightness +=
+ brightness->transition_direction * brightness->step_size_integer;
+ brightness->fractional_count += brightness->step_size_fractional;
+
+ if (brightness->fractional_count >= brightness->step_count)
+ {
+ brightness->current_brightness += brightness->transition_direction;
+ if (brightness->current_brightness != brightness->target_brightness)
+ {
+ brightness->fractional_count -= brightness->step_count;
+ }
+ else
+ {
+ transitionFinished = TRUE;
+ }
+ }
+ }
+ else
+ {
+ brightness->current_brightness = brightness->target_brightness;
+ transitionFinished = TRUE;
+ }
+
+ if ((brightness->screenMask & 1) != 0)
+ {
+ G2x_SetBlendBrightness_(
+ &reg_G2_BLDCNT, brightness->surfaceMask, brightness->current_brightness);
+ }
+ else if ((brightness->screenMask & 2) != 0)
+ {
+ G2x_SetBlendBrightness_(
+ &reg_G2S_DB_BLDCNT, brightness->surfaceMask, brightness->current_brightness);
+ }
+
+ if (transitionFinished == TRUE)
+ {
+ brightness->transitionActive = FALSE;
+ }
+}
+
+THUMB_FUNC void InitBrightnessTransition(struct BrightnessData *brightnessData,
+ u16 step_count,
+ s16 target_brightness,
+ s16 start_brightness,
+ fx32 surfaceMask,
+ u32 screenMask)
+{
+ GF_ASSERT(!brightnessData->transitionActive);
+
+ brightnessData->transitionActive = TRUE;
+ brightnessData->surfaceMask = (u8)surfaceMask;
+ brightnessData->screenMask = (u8)screenMask;
+ brightnessData->step_count = step_count;
+ brightnessData->target_brightness = target_brightness;
+ brightnessData->current_brightness = start_brightness;
+ brightnessData->brightness_diff = (s16)(start_brightness - target_brightness);
+
+ if (brightnessData->brightness_diff > 0)
+ {
+ brightnessData->transition_direction = -1;
+ }
+ else
+ {
+ brightnessData->transition_direction = 1;
+ brightnessData->brightness_diff *= -1;
+ }
+
+ brightnessData->step_size_integer = (s16)(brightnessData->brightness_diff / step_count);
+ brightnessData->step_size_fractional = (u16)(brightnessData->brightness_diff % step_count);
+ brightnessData->fractional_count = 0;
+}
+
+THUMB_FUNC void StartBrightnessTransition(
+ u16 step_count, s16 target_brightness, s16 start_brightness, fx32 surfaceMask, u32 screenMask)
+{
+ if (step_count != 0)
+ {
+ if ((screenMask & 1) != 0)
+ {
+ G2x_SetBlendBrightness_(&reg_G2_BLDCNT, surfaceMask, start_brightness);
+ InitBrightnessTransition(&mainScreenBrightnessData,
+ step_count,
+ target_brightness,
+ start_brightness,
+ surfaceMask,
+ 1);
+ }
+
+ if ((screenMask & 2) != 0)
+ {
+ G2x_SetBlendBrightness_(&reg_G2S_DB_BLDCNT, surfaceMask, start_brightness);
+ InitBrightnessTransition(&subScreenBrightnessData,
+ step_count,
+ target_brightness,
+ start_brightness,
+ surfaceMask,
+ 2);
+ }
+ }
+}
+
+THUMB_FUNC void SetBrightness(fx32 brightness, fx32 surfaceMask, u32 screenMask)
+{
+
+ if ((screenMask & 1) != 0)
+ {
+ G2x_SetBlendBrightness_(&reg_G2_BLDCNT, surfaceMask, brightness);
+ }
+
+ if ((screenMask & 2) != 0)
+ {
+ G2x_SetBlendBrightness_(&reg_G2S_DB_BLDCNT, surfaceMask, brightness);
+ }
+
+ InitScreenBrightnessData(screenMask);
+}
+
+THUMB_FUNC void InitAllScreenBrightnessData(void)
+{
+ MI_CpuFill8(&mainScreenBrightnessData, 0, sizeof(struct BrightnessData));
+ MI_CpuFill8(&subScreenBrightnessData, 0, sizeof(struct BrightnessData));
+
+ mainScreenBrightnessData.transitionActive = FALSE;
+ subScreenBrightnessData.transitionActive = FALSE;
+}
+
+THUMB_FUNC void InitScreenBrightnessData(u32 screenMask)
+{
+ if (screenMask & 1)
+ {
+ MI_CpuFill8(&mainScreenBrightnessData, 0, sizeof(struct BrightnessData));
+ mainScreenBrightnessData.transitionActive = FALSE;
+ }
+
+ if (screenMask & 2)
+ {
+ MI_CpuFill8(&subScreenBrightnessData, 0, sizeof(struct BrightnessData));
+ subScreenBrightnessData.transitionActive = FALSE;
+ }
+}
+
+THUMB_FUNC void DoAllScreenBrightnessTransitionStep(void)
+{
+ if (mainScreenBrightnessData.transitionActive)
+ {
+ DoBrightnessTransitionStep(&mainScreenBrightnessData);
+ }
+
+ if (subScreenBrightnessData.transitionActive)
+ {
+ DoBrightnessTransitionStep(&subScreenBrightnessData);
+ }
+}
+
+THUMB_FUNC BOOL IsBrightnessTransitionActive(u32 screenMask)
+{
+ if (screenMask == 3)
+ {
+ if (!mainScreenBrightnessData.transitionActive && !subScreenBrightnessData.transitionActive)
+ {
+ return TRUE;
+ }
+ }
+ else if (screenMask == 1)
+ {
+ if (!mainScreenBrightnessData.transitionActive)
+ {
+ return TRUE;
+ }
+ }
+ else if (screenMask == 2)
+ {
+ if (!subScreenBrightnessData.transitionActive)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c
index 0ea26458..848e3d0a 100644
--- a/arm9/src/communication_error.c
+++ b/arm9/src/communication_error.c
@@ -6,11 +6,9 @@
#include "msgdata.h"
#include "msgdata/msg.naix"
#include "text.h"
+#include "brightness.h"
+#include "render_window.h"
-extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id);
-extern void FUN_0200A274(fx32 brightness, fx32, u32);
-extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id);
-extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num);
extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen);
extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32);
@@ -108,7 +106,7 @@ THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code)
SetKeyRepeatTimers(4, 8);
- gMain.unk65 = 0;
+ gMain.screensFlipped = 0;
GX_SwapDisplay();
reg_G2_BLDCNT = 0;
@@ -137,7 +135,7 @@ THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code)
AddWindow(bg_config, &window, &sCommunicationErrorWindowTemplate);
FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
- FUN_0200CCA4(&window, FALSE, 0x01F7, 2);
+ DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2);
BufferIntegerAsString(mgr, 0, (s32)error_code, 5, 2, 1);
ReadMsgDataIntoString(error_message_data, error_message_no, tmp_str);
@@ -150,7 +148,7 @@ THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code)
GX_BothDispOn();
FUN_0200E394(PM_LCD_TOP);
FUN_0200E394(PM_LCD_BOTTOM);
- FUN_0200A274(0, 0x3F, 3);
+ SetBrightness(0, 0x3F, 3);
RemoveWindow(&window);
DestroyMsgData(error_message_data);
diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c
index d49e8e51..12af3c6f 100644
--- a/arm9/src/error_message_reset.c
+++ b/arm9/src/error_message_reset.c
@@ -6,6 +6,8 @@
#include "bg_window.h"
#include "PAD_pad.h"
#include "font.h"
+#include "brightness.h"
+#include "render_window.h"
const struct WindowTemplate UNK_020FF49C = {
@@ -43,10 +45,7 @@ const struct GraphicsBanks UNK_020FF4D8 = { .bg = 3 };
u32 sErrorMessagePrinterLock;
extern void FUN_0200E3A0(PMLCDTarget, int);
-extern void FUN_0200CB00(struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5);
-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);
THUMB_FUNC void VBlankHandler()
{
@@ -85,7 +84,7 @@ THUMB_FUNC void PrintErrorMessageAndReset()
SetKeyRepeatTimers(4, 8);
- gMain.unk65 = 0;
+ gMain.screensFlipped = 0;
GX_SwapDisplay();
G2_BlendNone();
@@ -114,7 +113,7 @@ THUMB_FUNC void PrintErrorMessageAndReset()
FUN_0201BD5C();
AddWindow(ptr, &buf, &UNK_020FF49C);
FillWindowPixelRect(&buf, 15, 0, 0, 0xd0, 0x90);
- FUN_0200CCA4(&buf, 0, 0x1f7, 2);
+ DrawFrameAndWindow1(&buf, 0, 0x1f7, 2);
ReadMsgDataIntoString(msg_data, 3, str);
@@ -124,7 +123,7 @@ THUMB_FUNC void PrintErrorMessageAndReset()
GX_BothDispOn();
FUN_0200E394(0);
FUN_0200E394(1);
- FUN_0200A274(0, 0x3f, 3);
+ SetBrightness(0, 0x3f, 3);
FUN_02032DAC();
while (1)
diff --git a/arm9/src/font.c b/arm9/src/font.c
index 6c838892..5e46b237 100644
--- a/arm9/src/font.c
+++ b/arm9/src/font.c
@@ -4,6 +4,7 @@
#include "graphic/font.naix"
#include "render_text.h"
#include "string16.h"
+#include "unk_02021590.h"
#include "text.h"
#include "unk_0201B8B8.h"
@@ -11,7 +12,12 @@ struct UnkStruct_02002C14 *UNK_02106FC8;
struct UnkStruct_02002C14 UNK_02106FCC;
-const u16 UNK_020ECB54[4][2] = { { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 } };
+const u16 UNK_020ECB54[4][2] = {
+ { NARC_font_narc_0000_bin, FALSE },
+ { NARC_font_narc_0001_bin, FALSE },
+ { NARC_font_narc_0002_bin, FALSE },
+ { NARC_font_narc_0003_bin, FALSE }
+};
const struct FontInfo gFontInfos[5] = {
{ 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
@@ -21,12 +27,6 @@ const struct FontInfo gFontInfos[5] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
-extern struct UnkStruct_0202199C *FUN_02021590(u32, u16, u32, u16, u32);
-extern void FUN_020215E0(struct UnkStruct_0202199C *, u32, u32);
-extern void FUN_020215C8(struct UnkStruct_0202199C *param0);
-extern void FUN_02021750(struct UnkStruct_0202199C *, u32);
-extern u32 FUN_020218D8(struct UnkStruct_0202199C *, u16 *str, u32);
-
THUMB_FUNC void FUN_02002C14()
{
UNK_02106FC8 = &UNK_02106FCC;
@@ -40,10 +40,10 @@ THUMB_FUNC void FUN_02002C14()
SetFontsPointer(&gFontInfos[0]);
}
-THUMB_FUNC void FUN_02002C50(u32 param0, u32 param1)
+THUMB_FUNC void FUN_02002C50(u32 font_id, u32 heap_id)
{
- UNK_02106FC8->unk94[param0] =
- FUN_02021590(14, UNK_020ECB54[param0][0], 1, UNK_020ECB54[param0][1], param1);
+ UNK_02106FC8->unk94[font_id] =
+ FontData_new(NARC_GRAPHIC_FONT, UNK_020ECB54[font_id][0], 1, UNK_020ECB54[font_id][1], heap_id);
}
THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1)
@@ -51,7 +51,7 @@ THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1)
GF_ASSERT(param0 < 4);
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020215E0(UNK_02106FC8->unk94[param0], 0, param1);
+ FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 0, param1);
}
THUMB_FUNC void FUN_02002CC0(s32 param0)
@@ -59,7 +59,7 @@ THUMB_FUNC void FUN_02002CC0(s32 param0)
GF_ASSERT(param0 < 4);
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020215E0(UNK_02106FC8->unk94[param0], 1, 0);
+ FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 1, 0);
}
THUMB_FUNC void FUN_02002CF8(int param0)
@@ -89,16 +89,16 @@ THUMB_FUNC void FUN_02002CF8(int param0)
if (UNK_02106FC8->unk94[param0] != NULL)
{
- FUN_020215C8(UNK_02106FC8->unk94[param0]);
+ FontData_delete(UNK_02106FC8->unk94[param0]);
UNK_02106FC8->unk94[param0] = NULL;
}
}
-THUMB_FUNC struct UnkStruct_02002C14 *FUN_02002D94(u32 param0, u32 param1)
+THUMB_FUNC struct UnkStruct_02002C14_sub *FUN_02002D94(u32 param0, u32 param1)
{
- FUN_02021750(UNK_02106FC8->unk94[param0], param1);
+ TryLoadGlyph(UNK_02106FC8->unk94[param0], param1, &UNK_02106FC8->unk00);
- return UNK_02106FC8;
+ return &UNK_02106FC8->unk00;
}
THUMB_FUNC u32 FontFunc(u32 fontId, struct TextPrinter *printer)
@@ -119,14 +119,14 @@ THUMB_FUNC u32 FUN_02002DE0(u32 param0, u16 *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020218D8(UNK_02106FC8->unk94[param0], str, param2);
+ return GetStringWidth(UNK_02106FC8->unk94[param0], str, param2);
}
THUMB_FUNC u32 FUN_02002E14(u32 param0, struct String *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020218D8(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
+ return GetStringWidth(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
}
THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr)
@@ -163,7 +163,7 @@ THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr)
return ret;
}
-THUMB_FUNC void FUN_02002ED0(u32 layer, u32 baseAddr, u32 heap_id)
+THUMB_FUNC void FUN_02002ED0(enum GFBgLayer layer, u32 baseAddr, u32 heap_id)
{
GfGfxLoader_GXLoadPal(
NARC_GRAPHIC_FONT, NARC_font_narc_0006_NCLR, layer, baseAddr, 0x20, heap_id);
diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c
index 44dcc111..705ffbc9 100644
--- a/arm9/src/game_init.c
+++ b/arm9/src/game_init.c
@@ -163,7 +163,7 @@ void InitSystemForTheGame(void)
gMain.unk10 = 0;
gMain.unk14 = 0;
gMain.unk2C = 0;
- gMain.unk65 = 0;
+ gMain.screensFlipped = 0;
}
void InitGraphicMemory(void)
diff --git a/arm9/src/main.c b/arm9/src/main.c
index fb4f8707..3b3b0dd6 100644
--- a/arm9/src/main.c
+++ b/arm9/src/main.c
@@ -11,6 +11,7 @@
#include "game_init.h"
#include "poke_overlay.h"
#include "player_data.h"
+#include "save_data_read_error.h"
#include "sound.h"
#include "timer3.h"
#include "unk_02031734.h"
@@ -18,6 +19,7 @@
#include "wfc_user_info_warning.h"
#include "module_52.h"
#include "font.h"
+#include "brightness.h"
FS_EXTERN_OVERLAY(MODULE_52);
FS_EXTERN_OVERLAY(MODULE_63);
@@ -31,14 +33,11 @@ struct UnkStruct_02016FA8 UNK_02016FA8;
extern void FUN_02022294(void);
extern void GF_InitRTCWork(void);
extern int FUN_020337E8(int);
-extern void FUN_02089D90(int);
-extern void FUN_0200A2AC(void);
extern void FUN_02015E30(void);
extern void FUN_0201B5CC(void *);
extern void GF_RTC_UpdateOnFrame(void);
extern void FUN_02015E60(void);
extern void FUN_020222C4(void);
-extern void FUN_0200A318(void);
extern void FUN_0200E2D8(void);
extern struct Unk21DBE18 MOD63_021DBE18;
@@ -73,7 +72,7 @@ THUMB_FUNC void NitroMain(void)
ShowWFCUserInfoWarning(3, 0);
if (FUN_020227FC(UNK_02016FA8.unk18) == 0)
{
- FUN_02089D90(0);
+ ShowSaveDataReadError(0);
}
else
{
@@ -97,7 +96,7 @@ THUMB_FUNC void NitroMain(void)
gMain.unk6C = 1;
gMain.unk30 = 0;
InitializeMainRNG();
- FUN_0200A2AC();
+ InitAllScreenBrightnessData();
FUN_02015E30();
UNK_02016FA4 = 0;
for (;;)
@@ -127,7 +126,7 @@ THUMB_FUNC void NitroMain(void)
OS_WaitIrq(1, 1);
gMain.unk2C++;
gMain.unk30 = 0;
- FUN_0200A318();
+ DoAllScreenBrightnessTransitionStep();
FUN_0200E2D8();
if (gMain.vBlankIntr)
gMain.vBlankIntr(gMain.vBlankIntrArg);
diff --git a/arm9/src/oam.c b/arm9/src/oam.c
new file mode 100644
index 00000000..ff3405d4
--- /dev/null
+++ b/arm9/src/oam.c
@@ -0,0 +1,169 @@
+#include "global.h"
+#include "oam.h"
+#include "GX_g2.h"
+#include "MI_memory.h"
+#include "heap.h"
+
+extern void FUN_020213A0(void);
+extern void FUN_0202135C(void *param0,
+ u32 *param1,
+ u32 (*param2)(u32, u32),
+ u32 (*param3)(u32),
+ void (*param4)(void),
+ u32 param5,
+ u32 param6);
+extern void FUN_020203CC(u32 heap_id);
+extern void FUN_02020404(u32 heap_id);
+
+struct OamData *oamData;
+
+THUMB_FUNC void FUN_02009EAC(s32 param0,
+ s32 param1,
+ s32 param2,
+ s32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7,
+ u32 param8)
+{
+ s32 r0;
+ if (param0 < 4)
+ {
+ r0 = 4;
+ if (param1 > 0x7c)
+ {
+ param1 = param1 - (4 - param0);
+ }
+ }
+ else
+ {
+ r0 = param0;
+ }
+
+ s32 r2;
+ if (param2 < 1)
+ {
+ r2 = 1;
+ if (param3 > 0x1e)
+ {
+ param3 = param3 - (1 - param2);
+ }
+ }
+ else
+ {
+ r2 = param2;
+ }
+
+ InitOamData(r0, param1, r2, param3, param4, param5, param6, param7, param8);
+}
+
+THUMB_FUNC void InitOamData(s32 param0,
+ s32 param1,
+ s32 param2,
+ s32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7,
+ u32 heap_id)
+{
+ GF_ASSERT(oamData == NULL);
+ oamData = AllocFromHeap(heap_id, sizeof(struct OamData));
+ GF_ASSERT(oamData);
+
+ oamData->heap_id = heap_id;
+
+ GF_ASSERT(NNS_G2dGetNewOamManagerInstance(
+ &oamData->oamManagers[0], (u16)param0, (u16)param1, (u16)param2, (u16)param3, 0));
+ GF_ASSERT(NNS_G2dGetNewOamManagerInstance(
+ &oamData->oamManagers[1], (u16)param4, (u16)param5, (u16)param6, (u16)param7, 1));
+}
+
+THUMB_FUNC void ApplyAndResetOamManagerBuffer(void)
+{
+ if (oamData != NULL)
+ {
+ NNS_G2dApplyAndResetOamManagerBuffer(&oamData->oamManagers[0]);
+ NNS_G2dApplyAndResetOamManagerBuffer(&oamData->oamManagers[1]);
+ }
+}
+
+THUMB_FUNC void DeinitOamData(void)
+{
+ GF_ASSERT(oamData);
+
+ FUN_0200A064(oamData->heap_id);
+ FUN_0200A06C(oamData->heap_id);
+
+ FreeToHeap(oamData);
+ oamData = NULL;
+}
+
+THUMB_FUNC void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3)
+{
+ GF_ASSERT(oamData);
+
+ if (param2 == 1)
+ {
+ FUN_0202135C(param0, param1, EntryOamManagerOamWithAffineIdxMainScreen, EntryOamManagerAffineMainScreen, FUN_020213A0, param2, param3);
+ return;
+ }
+
+ FUN_0202135C(param0, param1, EntryOamManagerOamWithAffineIdxSubScreen, EntryOamManagerAffineSubScreen, FUN_020213A0, param2, param3);
+}
+
+THUMB_FUNC NNSG2dOamManager *GetOamManager(u32 screen)
+{
+ GF_ASSERT(oamData);
+ if (screen == 0)
+ {
+ return &oamData->oamManagers[0];
+ }
+ else
+ {
+ return &oamData->oamManagers[1];
+ }
+}
+
+THUMB_FUNC void FUN_0200A064(u32 heap_id)
+{
+ FUN_020203CC(heap_id);
+}
+
+THUMB_FUNC void FUN_0200A06C(u32 heap_id)
+{
+ FUN_02020404(heap_id);
+}
+
+THUMB_FUNC u32 EntryOamManagerOamWithAffineIdxMainScreen(u32 param0, u32 param1)
+{
+ u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&oamData->oamManagers[0], param0, param1);
+ GF_ASSERT(res);
+
+ return res;
+}
+
+THUMB_FUNC u32 EntryOamManagerOamWithAffineIdxSubScreen(u32 param0, u32 param1)
+{
+ u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&oamData->oamManagers[1], param0, param1);
+ GF_ASSERT(res);
+
+ return res;
+}
+
+THUMB_FUNC u32 EntryOamManagerAffineMainScreen(u32 param0)
+{
+ u32 res = NNS_G2dEntryOamManagerAffine(&oamData->oamManagers[0], param0);
+ GF_ASSERT(res != 0xFFFE);
+
+ return res;
+}
+
+THUMB_FUNC u32 EntryOamManagerAffineSubScreen(u32 param0)
+{
+ u32 res = NNS_G2dEntryOamManagerAffine(&oamData->oamManagers[1], param0);
+ GF_ASSERT(res != 0xFFFE);
+
+ return res;
+}
diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c
index 29075833..6139a21f 100644
--- a/arm9/src/pokemon.c
+++ b/arm9/src/pokemon.c
@@ -18,6 +18,9 @@
#include "constants/moves.h"
#include "constants/sinnoh_dex.h"
#include "constants/trainer_classes.h"
+#include "unk_020051F4.h"
+#include "sound_chatot.h"
+
#pragma thumb on
@@ -3303,25 +3306,25 @@ void LoadWotbl_HandleAlternateForme(int species, int forme, u16 * wotbl)
ReadWholeNarcMemberByIdPair(wotbl, NARC_POKETOOL_PERSONAL_WOTBL, ResolveMonForme(species, forme));
}
-void FUN_02069FB0(u32 r7, u32 r5, u32 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20)
+void FUN_02069FB0(struct SaveChatotSoundClip *r7, u32 r5, u16 r4, s32 r6, s32 sp18, u32 sp1C, u32 sp20)
{
if (r4 == SPECIES_CHATOT)
{
if (!FUN_02005F14((int)r5))
{
FUN_02005E80(1);
- FUN_020056AC((int)r5, (int)r4, (int)r6, (int)sp18, (int)sp20);
+ FUN_020056AC(r5, r4, r6, sp18, sp20);
}
else
{
if (sp1C)
FUN_02005E80(1);
- FUN_02005E90((int)r7, 0, (int)sp18, (int)r6);
+ FUN_02005E90(r7, 0, sp18, r6);
}
}
else
{
- FUN_020056AC((int)r5, (int)r4, (int)r6, (int)sp18, (int)sp20);
+ FUN_020056AC(r5, r4, r6, sp18, sp20);
}
}
diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c
index 34777739..aa29e82d 100644
--- a/arm9/src/render_text.c
+++ b/arm9/src/render_text.c
@@ -207,7 +207,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer)
return 3;
}
- struct UnkStruct_02002C14 *r5 = FUN_02002D94(subStruct->glyphId, currentChar);
+ struct UnkStruct_02002C14_sub *r5 = FUN_02002D94(subStruct->glyphId, currentChar);
CopyGlyphToWindow(printer->printerTemplate.window,
r5->buf,
r5->width,
diff --git a/arm9/src/render_window.c b/arm9/src/render_window.c
new file mode 100644
index 00000000..7a682eb6
--- /dev/null
+++ b/arm9/src/render_window.c
@@ -0,0 +1,1027 @@
+#include "global.h"
+#include "render_window.h"
+#include "filesystem.h"
+#include "gf_gfx_loader.h"
+#include "graphic/field_board.naix"
+#include "graphic/winframe.naix"
+#include "pokemon.h"
+#include "render_text.h"
+#include "unk_020061E8.h"
+#include "unk_0200BB14.h"
+#include "unk_0200CA44.h"
+
+const struct UnkStruct_0200CABC_3 UNK_020ECE88 = {
+ 10,
+ 0,
+ 10,
+ 10,
+};
+
+const struct UnkStruct_0200CABC_3 UNK_020ECE98 = {
+ 0,
+ 0,
+ 10,
+ 10,
+};
+
+extern void FUN_02020130(u32 param0, u32 param1);
+extern u32 FUN_0202022C(u32 param0);
+extern void FUN_020201E4(u32 param0, u32 param1);
+extern void FUN_0201FDEC(u32 param0);
+extern void MOD05_021D99F8(struct UnkStruct_0200CABC_2 *param0);
+extern void *FUN_0201B6C8(BOOL);
+extern void MOD05_021D959C(
+ struct UnkStruct_0200CABC_2 *param0, void *param1, u32 param2, u32 param3);
+extern void MOD05_021D967C(struct UnkStruct_0200CABC_2 *param0,
+ NarcId narcId,
+ s32 memberId,
+ u32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6);
+extern void MOD05_021D96F4(
+ struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4);
+extern void MOD05_021D9708(
+ struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4);
+extern void MOD05_021D971C(struct UnkStruct_0200CABC_2 *param0,
+ NarcId narcId,
+ s32 memberId,
+ u32 param3,
+ u32 param4,
+ u32 param5);
+extern u32 *MOD05_021D9820(struct UnkStruct_0200CABC_2 *param0, void *);
+extern struct UnkStruct63_021DB450 *FUN_02006D98(u32);
+extern void FUN_020072E8(struct UnkStruct63_021DB450 *param0);
+extern void FUN_02012400(u16, u16, u16, void *, void *);
+extern u32 NNS_G2dGetImageLocation(u32, u32);
+extern void *FUN_02012470(u16, u16, u16);
+extern u32 NNS_G2dGetImagePaletteLocation(u32, u32);
+
+THUMB_FUNC u32 FUN_0200CABC(
+ struct BgConfig *bgConfig, u32 layer, u32 numTiles, u32 param3, u32 heap_id)
+{
+ if (param3 == 0)
+ {
+ return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME,
+ NARC_winframe_narc_0000_NCGR,
+ bgConfig,
+ layer,
+ numTiles,
+ 0,
+ FALSE,
+ heap_id);
+ }
+
+ return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME,
+ NARC_winframe_narc_0001_NCGR,
+ bgConfig,
+ layer,
+ numTiles,
+ 0,
+ FALSE,
+ heap_id);
+}
+
+THUMB_FUNC s32 FUN_0200CAFC(void)
+{
+ return NARC_winframe_narc_0024_NCLR;
+}
+
+THUMB_FUNC void FUN_0200CB00(
+ struct BgConfig *bg_config, u32 layer, u32 num_tiles, u32 param3, u8 param4, u32 heap_id)
+{
+ s32 r1;
+ if (param4 != 0)
+ {
+ r1 = NARC_winframe_narc_0001_NCGR;
+ }
+ else
+ {
+ r1 = NARC_winframe_narc_0000_NCGR;
+ }
+
+ GfGfxLoader_LoadCharData(
+ NARC_GRAPHIC_WINFRAME, r1, bg_config, layer, num_tiles, 0, FALSE, heap_id);
+
+ if (param4 == 2)
+ {
+ r1 = NARC_winframe_narc_0045_NCLR;
+ }
+ else
+ {
+ r1 = NARC_winframe_narc_0024_NCLR;
+ }
+
+ if (layer < 4)
+ {
+ GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 0, param3 << 5, 32, heap_id);
+ return;
+ }
+
+ GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 4, param3 << 5, 32, heap_id);
+}
+
+THUMB_FUNC void DrawFrame1(struct BgConfig *bgConfig,
+ u8 bgId,
+ u8 x,
+ u8 y,
+ u8 width,
+ u8 height,
+ u8 paletteNum,
+ u16 fillValue)
+{
+ FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 1), x, (u8)(y - 1), width, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 2), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 3), (u8)(x - 1), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 7), x, (u8)(y + height), width, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 8), (u8)(x + width), (u8)(y + height), 1, 1, paletteNum);
+}
+
+THUMB_FUNC void DrawFrameAndWindow1(
+ struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num)
+{
+ DrawFrame1(window->bgConfig,
+ GetWindowBgId(window),
+ GetWindowX(window),
+ GetWindowY(window),
+ GetWindowWidth(window),
+ GetWindowHeight(window),
+ palette_num,
+ fill_value);
+
+ if (!copy_to_vram)
+ {
+ CopyWindowToVram(window);
+ }
+}
+
+THUMB_FUNC void ClearFrameAndWindow1(struct Window *window, BOOL copy_to_vram)
+{
+
+ FillBgTilemapRect(window->bgConfig,
+ GetWindowBgId(window),
+ 0,
+ (u8)(GetWindowX(window) - 1),
+ (u8)(GetWindowY(window) - 1),
+ (u8)(GetWindowWidth(window) + 2),
+ (u8)(GetWindowHeight(window) + 2),
+ 0);
+
+ if (!copy_to_vram)
+ {
+ ClearWindowTilemapAndCopyToVram(window);
+ }
+}
+
+THUMB_FUNC s32 FUN_0200CD60(s32 param0)
+{
+ return param0 + 2;
+}
+
+THUMB_FUNC s32 FUN_0200CD64(s32 param0)
+{
+ return param0 + 25;
+}
+
+THUMB_FUNC void FUN_0200CD68(
+ struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5)
+{
+
+ GfGfxLoader_LoadCharData(
+ NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), param0, param1, param2, 0, FALSE, param5);
+
+ if (param1 < 4)
+ {
+ GfGfxLoader_GXLoadPal(
+ NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 0, param3 << 5, 32, param5);
+ return;
+ }
+
+ GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 4, param3 << 5, 32, param5);
+}
+
+THUMB_FUNC void DrawFrame2(struct BgConfig *bgConfig,
+ u8 bgId,
+ u8 x,
+ u8 y,
+ u8 width,
+ u8 height,
+ u8 paletteNum,
+ u16 fillValue)
+{
+ FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 2), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 2), x, (u8)(y - 1), width, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 4), (u8)(x + width + 1), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width + 2), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 2), y, 1, height, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 1), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 2), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 14), x, (u8)(y + height), width, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 15), (u8)(x + width), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig,
+ bgId,
+ (u16)(fillValue + 16),
+ (u8)(x + width + 1),
+ (u8)(y + height),
+ 1,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(bgConfig,
+ bgId,
+ (u16)(fillValue + 17),
+ (u8)(x + width + 2),
+ (u8)(y + height),
+ 1,
+ 1,
+ paletteNum);
+}
+
+THUMB_FUNC void DrawWindowFrame2(struct Window *window, u32 fill_value, u32 palette_num)
+{
+ DrawFrame2(window->bgConfig,
+ GetWindowBgId(window),
+ GetWindowX(window),
+ GetWindowY(window),
+ GetWindowWidth(window),
+ GetWindowHeight(window),
+ (u8)palette_num,
+ (u16)fill_value);
+}
+
+THUMB_FUNC void DrawFrameAndWindow2(
+ struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num)
+{
+ DrawWindowFrame2(window, fill_value, palette_num);
+ if (!copy_to_vram)
+ {
+ CopyWindowToVram(window);
+ }
+
+ FUN_0200D18C(window, fill_value);
+}
+
+THUMB_FUNC void ClearFrameAndWindow2(struct Window *window, BOOL param1)
+{
+ FillBgTilemapRect(window->bgConfig,
+ GetWindowBgId(window),
+ 0,
+ (u8)(GetWindowX(window) - 2),
+ (u8)(GetWindowY(window) - 1),
+ (u8)(GetWindowWidth(window) + 5),
+ (u8)(GetWindowHeight(window) + 2),
+ 0);
+
+ if (!param1)
+ {
+ ClearWindowTilemapAndCopyToVram(window);
+ }
+}
+
+THUMB_FUNC void BlitRect4Bit(u8 *srcPixels,
+ u16 srcX,
+ u16 srcY,
+ u16 srcWidth,
+ u16 srcHeight,
+ u8 *dstPixels,
+ u16 dstWidth,
+ u16 dstHeight,
+ u16 dstX,
+ u16 dstY,
+ u16 width,
+ u16 height)
+{
+ struct Bitmap src;
+ src.pixels = srcPixels;
+ src.width = srcWidth;
+ src.height = srcHeight;
+
+ struct Bitmap dst;
+ dst.pixels = dstPixels;
+ dst.width = dstWidth;
+ dst.height = dstHeight;
+
+ BlitBitmapRect4Bit(&src, &dst, srcX, srcY, dstX, dstY, width, height, 0);
+}
+
+THUMB_FUNC void FUN_0200D18C(struct Window *window, u16 fill_value)
+{
+ u32 heap_id = BgConfig_GetHeapId(window->bgConfig);
+ u8 bg_id = GetWindowBgId(window);
+
+ void *ptr = AllocFromHeap(heap_id, 0x180);
+ void *charptr = BgGetCharPtr(bg_id);
+
+ NNSG2dCharacterData *pCharData;
+ void *st30;
+ void *st2c;
+ st2c = GfGfxLoader_GetCharData(
+ NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0022_NCGR, FALSE, &pCharData, heap_id);
+ st30 = pCharData->pRawData;
+
+ for (u8 i = 0; i < 3; i++)
+ {
+ memcpy(ptr + (i << 7), charptr + ((fill_value + 10) << 5), 0x20);
+ memcpy(ptr + ((i << 7) + 0x20), charptr + ((fill_value + 11) << 5), 0x20);
+ memcpy(ptr + ((i << 7) + 0x40), charptr + ((fill_value + 10) << 5), 0x20);
+ memcpy(ptr + ((i << 7) + 0x60), charptr + ((fill_value + 11) << 5), 0x20);
+ }
+
+ BlitRect4Bit(st30, 4, 0, 12, 0x30, ptr, 12, 0x30, 1, 0, 12, 0x30);
+ BG_LoadCharTilesData(window->bgConfig, bg_id, ptr, 0x180, (u32)(fill_value + 18));
+ FUN_02002840(fill_value);
+ FreeToHeap(st2c);
+ FreeToHeap(ptr);
+}
+
+THUMB_FUNC void FUN_0200D274(
+ struct BgConfig *bg_config, u8 bg_id, u16 param2, u8 param3, u8 param4, u32 heap_id)
+{
+
+ NNSG2dCharacterData *pCharData;
+ void *stc = GfGfxLoader_GetCharData(
+ NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), FALSE, &pCharData, heap_id);
+ u8 *ptr = AllocFromHeap(heap_id, 0x240);
+ memcpy(ptr, pCharData->pRawData, 0x240);
+
+ for (u32 r3 = 0; r3 < 0x240; r3++)
+ {
+ u8 r6 = (u8)(ptr[r3] >> 4);
+ u8 r2 = (u8)(ptr[r3] & 0xf);
+ if (r6 == 0)
+ {
+ r6 = param3;
+ }
+ if (r2 == 0)
+ {
+ r2 = param3;
+ }
+
+ ptr[r3] = (u8)(r2 | (r6 << 4));
+ }
+
+ BG_LoadCharTilesData(bg_config, bg_id, (u32 *)ptr, 0x240, param2);
+ FreeToHeap(stc);
+ FreeToHeap(ptr);
+}
+
+THUMB_FUNC void FUN_0200D300(struct BgConfig *bg_config,
+ u8 bg_id,
+ u16 numtiles,
+ u8 param3,
+ u8 param4,
+ u16 param5,
+ u32 heap_id)
+{
+ GfGfxLoader_LoadCharData(NARC_GRAPHIC_FIELD_BOARD,
+ NARC_field_board_narc_0000_NCGR,
+ bg_config,
+ bg_id,
+ numtiles,
+ 0x3C0,
+ FALSE,
+ heap_id);
+
+ NNSG2dPaletteData *pPltData;
+ void *st14;
+ st14 = AllocAndReadWholeNarcMemberByIdPair(
+ NARC_GRAPHIC_FIELD_BOARD, NARC_field_board_narc_0001_NCLR, heap_id);
+ NNS_G2dGetUnpackedPaletteData(st14, &pPltData);
+ BG_LoadPlttData(bg_id, pPltData->pRawData + param4 * 0x20, 0x20, (u16)(param3 << 5));
+ FreeToHeapExplicit(heap_id, st14);
+
+ if (param4 <= 1)
+ {
+ FUN_0200D378(bg_config, bg_id, (u16)(numtiles + 30), param4, param5, heap_id);
+ }
+}
+
+THUMB_FUNC void FUN_0200D378(
+ struct BgConfig *bg_config, u8 bg_id, u16 numtiles, u8 param3, u16 param4, u32 heap_id)
+{
+ if (param3 == 0)
+ {
+ param4 += 33;
+ }
+ else
+ {
+ param4 += 2;
+ }
+
+ GfGfxLoader_LoadCharData(
+ NARC_GRAPHIC_FIELD_BOARD, param4, bg_config, bg_id, numtiles, 0x300, FALSE, heap_id);
+}
+
+THUMB_FUNC void DrawFrame3(struct BgConfig *bgConfig,
+ u8 bgId,
+ u8 x,
+ u8 y,
+ u8 width,
+ u8 height,
+ u8 paletteNum,
+ u16 fillValue)
+{
+ FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 9), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 8), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig,
+ bgId,
+ (u16)(fillValue + 2),
+ (u8)(x - 7),
+ (u8)(y - 1),
+ (u8)(width + 7),
+ 1,
+ paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 4), (u8)(x + width + 1), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width + 2), (u8)(y - 1), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 9), y, 1, height, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 8), y, 1, height, paletteNum);
+ FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 8), (u8)(x - 1), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 9), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 8), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig,
+ bgId,
+ (u16)(fillValue + 14),
+ (u8)(x - 7),
+ (u8)(y + height),
+ (u8)(width + 7),
+ 1,
+ paletteNum);
+ FillBgTilemapRect(
+ bgConfig, bgId, (u16)(fillValue + 15), (u8)(x + width), (u8)(y + height), 1, 1, paletteNum);
+ FillBgTilemapRect(bgConfig,
+ bgId,
+ (u16)(fillValue + 16),
+ (u8)(x + width + 1),
+ (u8)(y + height),
+ 1,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(bgConfig,
+ bgId,
+ (u16)(fillValue + 17),
+ (u8)(x + width + 2),
+ (u8)(y + height),
+ 1,
+ 1,
+ paletteNum);
+}
+
+THUMB_FUNC void DrawWindowCorner(struct Window *window, u16 fillValue, u8 paletteNum)
+{
+ u16 i, j;
+ u16 x, y;
+ u8 bg_id;
+
+ bg_id = GetWindowBgId(window);
+ x = (u16)(GetWindowX(window) - 7);
+ y = GetWindowY(window);
+
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 6; j++)
+ {
+ FillBgTilemapRect(window->bgConfig,
+ bg_id,
+ (u16)(fillValue + 6 * i + j),
+ (u8)(x + j),
+ (u8)(y + i),
+ 1,
+ 1,
+ paletteNum);
+ }
+ }
+}
+
+THUMB_FUNC void DrawFrameAndWindow3(
+ struct Window *window, BOOL copy_to_vram, u16 fillValue, u8 paletteNum, u8 param4)
+{
+ u8 bg_id = GetWindowBgId(window);
+ if (param4 <= 1)
+ {
+ DrawFrame3(window->bgConfig,
+ bg_id,
+ GetWindowX(window),
+ GetWindowY(window),
+ GetWindowWidth(window),
+ GetWindowHeight(window),
+ paletteNum,
+ fillValue);
+ DrawWindowCorner(window, (u16)(fillValue + 30), paletteNum);
+ }
+ else
+ {
+ DrawFrame2(window->bgConfig,
+ bg_id,
+ GetWindowX(window),
+ GetWindowY(window),
+ GetWindowWidth(window),
+ GetWindowHeight(window),
+ paletteNum,
+ fillValue);
+ }
+
+ if (!copy_to_vram)
+ {
+ CopyWindowToVram(window);
+ }
+
+ FUN_0200D18C(window, fillValue);
+}
+
+THUMB_FUNC void ClearFrameAndWindow3(struct Window *window, u8 param1, BOOL copy_to_vram)
+{
+ u8 bg_id = GetWindowBgId(window);
+ if (param1 <= 1)
+ {
+ FillBgTilemapRect(window->bgConfig,
+ bg_id,
+ 0,
+ (u8)(GetWindowX(window) - 9),
+ (u8)(GetWindowY(window) - 1),
+ (u8)(GetWindowWidth(window) + 11),
+ (u8)(GetWindowHeight(window) + 2),
+ 0);
+ }
+ else
+ {
+ FillBgTilemapRect(window->bgConfig,
+ bg_id,
+ 0,
+ (u8)(GetWindowX(window) - 2),
+ (u8)(GetWindowY(window) - 1),
+ (u8)(GetWindowWidth(window) + 4),
+ (u8)(GetWindowHeight(window) + 2),
+ 0);
+ }
+
+ if (!copy_to_vram)
+ {
+ ClearWindowTilemapAndCopyToVram(window);
+ }
+}
+
+THUMB_FUNC struct UnkStruct_0200CABC_1 *FUN_0200D858(struct Window *window, u32 param1)
+{
+ u32 heap_id = BgConfig_GetHeapId(window->bgConfig);
+ void *charptr = BgGetCharPtr(GetWindowBgId(window));
+
+ struct UnkStruct_0200CABC_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200CABC_1));
+ memcpy(ptr->unk004[8], charptr + (param1 + 18) * 32, 0x80);
+ void *ptr2 = AllocFromHeap(heap_id, 0x80);
+ memcpy(ptr2, charptr + (param1 + 10) * 32, 0x20);
+ memcpy(ptr2 + 0x20, charptr + (param1 + 11) * 32, 0x20);
+ memcpy(ptr2 + 0x40, charptr + (param1 + 10) * 32, 0x20);
+ memcpy(ptr2 + 0x60, charptr + (param1 + 11) * 32, 0x20);
+
+ for (u8 i = 0; i < 8; i++)
+ {
+ memcpy(ptr->unk004[i], ptr2, 0x80);
+ }
+ FreeToHeap(ptr2);
+
+ NNSG2dCharacterData *pCharData;
+ void *r5 = GfGfxLoader_GetCharData(
+ NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0023_NCGR, FALSE, &pCharData, heap_id);
+ BlitRect4Bit(
+ pCharData->pRawData, 0, 0, 0x10, 0x80, ptr->unk004[0], 0x10, 0x80, 0, 0, 0x10, 0x80);
+ FreeToHeap(r5);
+
+ ptr->unk000 = window;
+ ptr->fillValue = (u16)param1;
+ ptr->unk486 = 0;
+ ptr->unk487 = 0;
+ ptr->unk488 = 0;
+
+ FUN_0200CA60(FUN_0200DB7C, ptr, 0);
+ FUN_0200D980(ptr, 1);
+
+ return ptr;
+}
+
+THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1)
+{
+ u8 bg_id = GetWindowBgId(param0->unk000);
+ u8 x = GetWindowX(param0->unk000);
+ u8 y = GetWindowY(param0->unk000);
+ u8 width = GetWindowWidth(param0->unk000);
+
+ if (param1 == 2)
+ {
+ BG_LoadCharTilesData(param0->unk000->bgConfig,
+ bg_id,
+ (u32 *)param0->unk004[8],
+ 0x80,
+ (u32)(param0->fillValue + 18));
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 10),
+ (u8)(x + width + 1),
+ (u8)(y + 2),
+ 1,
+ 1,
+ 0x10);
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 11),
+ (u8)(x + width + 2),
+ (u8)(y + 2),
+ 1,
+ 1,
+ 0x10);
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 10),
+ (u8)(x + width + 1),
+ (u8)(y + 3),
+ 1,
+ 1,
+ 0x10);
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 11),
+ (u8)(x + width + 2),
+ (u8)(y + 3),
+ 1,
+ 1,
+ 0x10);
+ BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id);
+ return;
+ }
+
+ BG_LoadCharTilesData(param0->unk000->bgConfig,
+ bg_id,
+ (u32 *)param0->unk004[param0->unk487],
+ 0x80,
+ (u32)(param0->fillValue + 18));
+ if (param1 != 0)
+ {
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 18),
+ (u8)(x + width + 1),
+ (u8)(y + 2),
+ 1,
+ 1,
+ 0x10);
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 19),
+ (u8)(x + width + 2),
+ (u8)(y + 2),
+ 1,
+ 1,
+ 0x10);
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 20),
+ (u8)(x + width + 1),
+ (u8)(y + 3),
+ 1,
+ 1,
+ 0x10);
+ FillBgTilemapRect(param0->unk000->bgConfig,
+ bg_id,
+ (u16)(param0->fillValue + 21),
+ (u8)(x + width + 2),
+ (u8)(y + 3),
+ 1,
+ 1,
+ 0x10);
+ BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id);
+ }
+}
+
+THUMB_FUNC void FUN_0200DB7C(u32 param0, void *param1)
+{
+ struct UnkStruct_0200CABC_1 *r1 = (struct UnkStruct_0200CABC_1 *)param1;
+
+ if (r1->unk488 != 0)
+ {
+ if (r1->unk488 == 1)
+ {
+ FUN_0200D980(r1, 2);
+ }
+ FUN_0200CAB4((s32)param0);
+ return;
+ }
+
+ r1->unk486++;
+ if (r1->unk486 == 16)
+ {
+ r1->unk486 = 0;
+ r1->unk487 = (r1->unk487 + 1) & 7;
+ FUN_0200D980(r1, 0);
+ }
+}
+
+THUMB_FUNC void FUN_0200DBE8(u32 param0, void *param1)
+{
+ FreeToHeap(param1);
+ FUN_0200CAB4((s32)param0);
+}
+
+THUMB_FUNC void FUN_0200DBFC(struct UnkStruct_0200CABC_1 *param0)
+{
+ FUN_0200CA98(FUN_0200DBE8, param0, 0);
+ param0->unk488 = 1;
+}
+
+THUMB_FUNC void FUN_0200DC24(struct UnkStruct_0200CABC_1 *param0)
+{
+ FUN_0200CA98(FUN_0200DBE8, param0, 0);
+ param0->unk488 = 2;
+}
+
+THUMB_FUNC u8 *FUN_0200DC4C(struct BgConfig *bg_config,
+ u8 bg_id,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u16 param5,
+ u16 param6,
+ u8 param7,
+ s32 param8)
+{
+ struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param8);
+ FUN_0200DDAC(r4, (u32)param8);
+ FUN_0200DDD8(r4);
+ FUN_0200DE30(r4, param2, param3);
+ FUN_0200DE80(r4, param6, param7);
+ DrawFramed10x10Square(r4, param4, param5);
+ BgCommitTilemapBufferToVram(bg_config, bg_id);
+
+ return &r4->unk16f;
+}
+
+THUMB_FUNC u8 *FUN_0200DCA4(struct BgConfig *bg_config,
+ u8 bg_id,
+ u8 param2,
+ u8 param3,
+ u8 param4,
+ u16 param5,
+ struct Pokemon *param6,
+ s32 param7)
+{
+ struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param7);
+ FUN_0200DDAC(r4, (u32)param7);
+ FUN_0200DDD8(r4);
+ FUN_0200DE30(r4, param2, param3);
+ FUN_0200DEC0(r4, param6);
+ DrawFramed10x10Square(r4, param4, param5);
+ BgCommitTilemapBufferToVram(bg_config, bg_id);
+
+ return &r4->unk16f;
+}
+
+THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1)
+{
+ struct UnkStruct_0200CABC_2 *unk = (struct UnkStruct_0200CABC_2 *)param1;
+ switch (unk->unk16f)
+ {
+ case 1:
+ ClearFramed10x10Square(unk);
+ FUN_0200C3DC(unk->unk164);
+ MOD05_021D99F8(unk);
+ FUN_0200621C((s32)param0);
+ return;
+ case 2:
+ unk->unk16f = 3;
+ FUN_02020130(*unk->unk164, 1);
+ break;
+ case 3:
+ if (FUN_0202022C(*unk->unk164) == 6)
+ {
+ unk->unk16f = 0;
+ }
+ }
+
+ FUN_020201E4(*unk->unk164, 0x1000);
+ FUN_0201FDEC(unk->unk000);
+}
+
+THUMB_FUNC struct UnkStruct_0200CABC_2 *FUN_0200DD70(
+ struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u32 param4)
+{
+ struct UnkStruct_0200CABC_2 *res = FUN_0201B6C8(FUN_020061E8(FUN_0200DCF8, 0x170, 0, param4));
+
+ res->unk16f = 0;
+ res->bgConfig = bg_config;
+ res->bgId = bg_id;
+ res->x = param2;
+ res->y = param3;
+
+ return res;
+}
+
+THUMB_FUNC void FUN_0200DDAC(struct UnkStruct_0200CABC_2 *param0, u32 param1)
+{
+
+ const u32 UNK_020ECEA8[] = {
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x01,
+ 0x00,
+ 0x00,
+ };
+ MOD05_021D959C(param0, UNK_020ECEA8, 1, param1);
+}
+
+THUMB_FUNC void FUN_0200DDD8(struct UnkStruct_0200CABC_2 *param0)
+{
+ MOD05_021D967C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0049_NCLR, 0, 1, 1, 0x15CD5);
+ MOD05_021D96F4(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0047_NCER, 0, 0x15CD5);
+ MOD05_021D9708(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0046_NANR, 0, 0x15CD5);
+ MOD05_021D971C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0048_NCGR, 0, 1, 0x15CD5);
+}
+
+THUMB_FUNC void FUN_0200DE30(struct UnkStruct_0200CABC_2 *param0, u8 param1, u8 param2)
+{
+ u32 UNK_020ECEC0[] = {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x01,
+ 0x015CD5,
+ 0x015CD5,
+ 0x015CD5,
+ 0x015CD5,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ };
+ ((u16 *)UNK_020ECEC0)[0] = (u16)((param1 + 5) * 8);
+ ((u16 *)UNK_020ECEC0)[1] = (u16)((param2 + 5) * 8);
+ param0->unk164 = MOD05_021D9820(param0, UNK_020ECEC0);
+ FUN_0201FDEC(param0->unk000);
+ GX_EngineBToggleLayers(0x10, GX_LAYER_TOGGLE_ON);
+}
+
+THUMB_FUNC void FUN_0200DE80(struct UnkStruct_0200CABC_2 *param0, u16 param1, u8 param2)
+{
+ struct UnkStruct63_021DB450 *r7 = FUN_02006D98(param0->unk162);
+ struct SomeDrawPokemonStruct stc;
+ FUN_02068C00(&stc, param1, param2, 2, 0, 0, 0);
+ FUN_0200DEF4(param0, &stc);
+ FUN_020072E8(r7);
+}
+
+THUMB_FUNC void FUN_0200DEC0(struct UnkStruct_0200CABC_2 *param0, struct Pokemon *param1)
+{
+ struct UnkStruct63_021DB450 *r6 = FUN_02006D98(param0->unk162);
+ struct SomeDrawPokemonStruct st0;
+ FUN_02068B68(&st0, param1, 2);
+ FUN_0200DEF4(param0, &st0);
+ FUN_020072E8(r6);
+}
+
+THUMB_FUNC void FUN_0200DEF4(
+ struct UnkStruct_0200CABC_2 *param0, struct SomeDrawPokemonStruct *param1)
+{
+ void *r4 = AllocFromHeap(param0->unk162, 0x1900);
+
+ struct UnkStruct_0200CABC_3 st18 = UNK_020ECE98;
+ FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st18, r4);
+
+ struct UnkStruct_0200CABC_3 st8 = UNK_020ECE88;
+ FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st8, r4 + 0xc80);
+
+ u32 st4 = FUN_02009C5C(FUN_020094F0(param0->unk130, 0x15CD5));
+
+ u32 r7 = NNS_G2dGetImageLocation(st4, 1);
+ DC_FlushRange(r4, 0x1900);
+ GX_LoadOBJ(r4, r7, 0x1900);
+ FreeToHeap(r4);
+ void *res = FUN_02012470(param1->unk0, param1->unk4, param0->unk162);
+
+ u32 r5 =
+ NNS_G2dGetImagePaletteLocation(FUN_02009E54(FUN_020094F0(param0->unk134, 0x15CD5), st4), 1);
+ DC_FlushRange(res, 0x20);
+ GX_LoadOBJPltt(res, r5, 0x20);
+ FreeToHeap(res);
+}
+
+THUMB_FUNC void DrawFramed10x10Square(
+ struct UnkStruct_0200CABC_2 *param0, u8 paletteNum, u16 fillValue)
+{
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ fillValue,
+ (u8)(param0->x - 1),
+ (u8)(param0->y - 1),
+ 1,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 1),
+ param0->x,
+ (u8)(param0->y - 1),
+ 10,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 2),
+ (u8)(param0->x + 10),
+ (u8)(param0->y - 1),
+ 1,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 4),
+ param0->x,
+ param0->y,
+ 10,
+ 10,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 3),
+ (u8)(param0->x - 1),
+ param0->y,
+ 1,
+ 10,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 5),
+ (u8)(param0->x + 10),
+ param0->y,
+ 1,
+ 10,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 6),
+ (u8)(param0->x - 1),
+ (u8)(param0->y + 10),
+ 1,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 7),
+ param0->x,
+ (u8)(param0->y + 10),
+ 10,
+ 1,
+ paletteNum);
+ FillBgTilemapRect(param0->bgConfig,
+ param0->bgId,
+ (u16)(fillValue + 8),
+ (u8)(param0->x + 10),
+ (u8)(param0->y + 10),
+ 1,
+ 1,
+ paletteNum);
+
+ ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId);
+}
+
+THUMB_FUNC void ClearFramed10x10Square(struct UnkStruct_0200CABC_2 *param0)
+{
+ FillBgTilemapRect(
+ param0->bgConfig, param0->bgId, 0, (u8)(param0->x - 1), (u8)(param0->y - 1), 12, 12, 0);
+ ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId);
+}
diff --git a/arm9/src/rs_migrate_string.c b/arm9/src/rs_migrate_string.c
new file mode 100644
index 00000000..46752374
--- /dev/null
+++ b/arm9/src/rs_migrate_string.c
@@ -0,0 +1,327 @@
+#include "global.h"
+#include "string_util.h"
+#include "rs_migrate_string.h"
+
+static const u16 conversion_table[][2] = {
+ {0x0001, 0x01DE}, // <space>
+ {0x0003, 0x0003}, // あ
+ {0x0005, 0x0005}, // い
+ {0x0007, 0x0007}, // う
+ {0x0009, 0x0009}, // え
+ {0x000B, 0x000B}, // お
+ {0x000C, 0x000C}, // か
+ {0x000E, 0x000E}, // き
+ {0x0010, 0x0010}, // く
+ {0x0012, 0x0012}, // け
+ {0x0014, 0x0014}, // こ
+ {0x0016, 0x0016}, // さ
+ {0x0018, 0x0018}, // し
+ {0x001A, 0x001A}, // す
+ {0x001C, 0x001C}, // せ
+ {0x001E, 0x001E}, // そ
+ {0x0020, 0x0020}, // た
+ {0x0022, 0x0022}, // ち
+ {0x0025, 0x0025}, // つ
+ {0x0027, 0x0027}, // て
+ {0x0029, 0x0029}, // と
+ {0x002B, 0x002B}, // な
+ {0x002C, 0x002C}, // に
+ {0x002D, 0x002D}, // ぬ
+ {0x002E, 0x002E}, // ね
+ {0x002F, 0x002F}, // の
+ {0x0030, 0x0030}, // は
+ {0x0033, 0x0033}, // ひ
+ {0x0036, 0x0036}, // ふ
+ {0x0039, 0x0039}, // へ
+ {0x003C, 0x003C}, // ほ
+ {0x003F, 0x003F}, // ま
+ {0x0040, 0x0040}, // み
+ {0x0041, 0x0041}, // む
+ {0x0042, 0x0042}, // め
+ {0x0043, 0x0043}, // も
+ {0x0045, 0x0045}, // や
+ {0x0047, 0x0047}, // ゆ
+ {0x0049, 0x0049}, // よ
+ {0x004A, 0x004A}, // ら
+ {0x004B, 0x004B}, // り
+ {0x004C, 0x004C}, // る
+ {0x004D, 0x004D}, // れ
+ {0x004E, 0x004E}, // ろ
+ {0x004F, 0x004F}, // わ
+ {0x0050, 0x0050}, // を
+ {0x0051, 0x0051}, // ん
+ {0x0002, 0x0002}, // ぁ
+ {0x0004, 0x0004}, // ぃ
+ {0x0006, 0x0006}, // ぅ
+ {0x0008, 0x0008}, // ぇ
+ {0x000A, 0x000A}, // ぉ
+ {0x0044, 0x0044}, // ゃ
+ {0x0046, 0x0046}, // ゅ
+ {0x0048, 0x0048}, // ょ
+ {0x000D, 0x000D}, // が
+ {0x000F, 0x000F}, // ぎ
+ {0x0011, 0x0011}, // ぐ
+ {0x0013, 0x0013}, // げ
+ {0x0015, 0x0015}, // ご
+ {0x0017, 0x0017}, // ざ
+ {0x0019, 0x0019}, // じ
+ {0x001B, 0x001B}, // ず
+ {0x001D, 0x001D}, // ぜ
+ {0x001F, 0x001F}, // ぞ
+ {0x0021, 0x0021}, // だ
+ {0x0023, 0x0023}, // ぢ
+ {0x0026, 0x0026}, // づ
+ {0x0028, 0x0028}, // で
+ {0x002A, 0x002A}, // ど
+ {0x0031, 0x0031}, // ば
+ {0x0034, 0x0034}, // び
+ {0x0037, 0x0037}, // ぶ
+ {0x003A, 0x003A}, // べ
+ {0x003D, 0x003D}, // ぼ
+ {0x0032, 0x0032}, // ぱ
+ {0x0035, 0x0035}, // ぴ
+ {0x0038, 0x0038}, // ぷ
+ {0x003B, 0x003B}, // ぺ
+ {0x003E, 0x003E}, // ぽ
+ {0x0024, 0x0024}, // っ
+ {0x0053, 0x0053}, // ア
+ {0x0055, 0x0055}, // イ
+ {0x0057, 0x0057}, // ウ
+ {0x0059, 0x0059}, // エ
+ {0x005B, 0x005B}, // オ
+ {0x005C, 0x005C}, // カ
+ {0x005E, 0x005E}, // キ
+ {0x0060, 0x0060}, // ク
+ {0x0062, 0x0062}, // ケ
+ {0x0064, 0x0064}, // コ
+ {0x0066, 0x0066}, // サ
+ {0x0068, 0x0068}, // シ
+ {0x006A, 0x006A}, // ス
+ {0x006C, 0x006C}, // セ
+ {0x006E, 0x006E}, // ソ
+ {0x0070, 0x0070}, // タ
+ {0x0072, 0x0072}, // チ
+ {0x0075, 0x0075}, // ツ
+ {0x0077, 0x0077}, // テ
+ {0x0079, 0x0079}, // ト
+ {0x007B, 0x007B}, // ナ
+ {0x007C, 0x007C}, // ニ
+ {0x007D, 0x007D}, // ヌ
+ {0x007E, 0x007E}, // ネ
+ {0x007F, 0x007F}, // ノ
+ {0x0080, 0x0080}, // ハ
+ {0x0083, 0x0083}, // ヒ
+ {0x0086, 0x0086}, // フ
+ {0x0089, 0x0089}, // ヘ
+ {0x008C, 0x008C}, // ホ
+ {0x008F, 0x008F}, // マ
+ {0x0090, 0x0090}, // ミ
+ {0x0091, 0x0091}, // ム
+ {0x0092, 0x0092}, // メ
+ {0x0093, 0x0093}, // モ
+ {0x0095, 0x0095}, // ヤ
+ {0x0097, 0x0097}, // ユ
+ {0x0099, 0x0099}, // ヨ
+ {0x009A, 0x009A}, // ラ
+ {0x009B, 0x009B}, // リ
+ {0x009C, 0x009C}, // ル
+ {0x009D, 0x009D}, // レ
+ {0x009E, 0x009E}, // ロ
+ {0x009F, 0x009F}, // ワ
+ {0x00A0, 0x00A0}, // ヲ
+ {0x00A1, 0x00A1}, // ン
+ {0x0052, 0x0052}, // ァ
+ {0x0054, 0x0054}, // ィ
+ {0x0056, 0x0056}, // ゥ
+ {0x0058, 0x0058}, // ェ
+ {0x005A, 0x005A}, // ォ
+ {0x0094, 0x0094}, // ャ
+ {0x0096, 0x0096}, // ュ
+ {0x0098, 0x0098}, // ョ
+ {0x005D, 0x005D}, // ガ
+ {0x005F, 0x005F}, // ギ
+ {0x0061, 0x0061}, // グ
+ {0x0063, 0x0063}, // ゲ
+ {0x0065, 0x0065}, // ゴ
+ {0x0067, 0x0067}, // ザ
+ {0x0069, 0x0069}, // ジ
+ {0x006B, 0x006B}, // ズ
+ {0x006D, 0x006D}, // ゼ
+ {0x006F, 0x006F}, // ゾ
+ {0x0071, 0x0071}, // ダ
+ {0x0073, 0x0073}, // ヂ
+ {0x0076, 0x0076}, // ヅ
+ {0x0078, 0x0078}, // デ
+ {0x007A, 0x007A}, // ド
+ {0x0081, 0x0081}, // バ
+ {0x0084, 0x0084}, // ビ
+ {0x0087, 0x0087}, // ブ
+ {0x008A, 0x008A}, // ベ
+ {0x008D, 0x008D}, // ボ
+ {0x0082, 0x0082}, // パ
+ {0x0085, 0x0085}, // ピ
+ {0x0088, 0x0088}, // プ
+ {0x008B, 0x008B}, // ペ
+ {0x008E, 0x008E}, // ポ
+ {0x0074, 0x0074}, // ッ
+ {0x00A2, 0x0121}, // 0
+ {0x00A3, 0x0122}, // 1
+ {0x00A4, 0x0123}, // 2
+ {0x00A5, 0x0124}, // 3
+ {0x00A6, 0x0125}, // 4
+ {0x00A7, 0x0126}, // 5
+ {0x00A8, 0x0127}, // 6
+ {0x00A9, 0x0128}, // 7
+ {0x00AA, 0x0129}, // 8
+ {0x00AB, 0x012A}, // 9
+ {0x00E1, 0x01AB}, // !
+ {0x00E2, 0x01AC}, // ?
+ {0x00E4, 0x01AE}, // .
+ {0x00F1, 0x01BE}, // -
+ {0x00E6, 0x01B0}, // ·
+ {0x00E5, 0x01AF}, // …
+ {0x00EA, 0x00EA}, // “
+ {0x00EB, 0x00EB}, // ”
+ {0x00E8, 0x01B2}, // ‘
+ {0x00E9, 0x01B3}, // '
+ {0x00EE, 0x01BB}, // ♂
+ {0x00EF, 0x01BC}, // ♀
+ {0x0112, 0x0112}, // ¥
+ {0x00E3, 0x01AD}, // ,
+ {0x00F2, 0x0176}, // ×
+ {0x00E7, 0x01B1}, // /
+ {0x00AC, 0x012B}, // A
+ {0x00AD, 0x012C}, // B
+ {0x00AE, 0x012D}, // C
+ {0x00AF, 0x012E}, // D
+ {0x00B0, 0x012F}, // E
+ {0x00B1, 0x0130}, // F
+ {0x00B2, 0x0131}, // G
+ {0x00B3, 0x0132}, // H
+ {0x00B4, 0x0133}, // I
+ {0x00B5, 0x0134}, // J
+ {0x00B6, 0x0135}, // K
+ {0x00B7, 0x0136}, // L
+ {0x00B8, 0x0137}, // M
+ {0x00B9, 0x0138}, // N
+ {0x00BA, 0x0139}, // O
+ {0x00BB, 0x013A}, // P
+ {0x00BC, 0x013B}, // Q
+ {0x00BD, 0x013C}, // R
+ {0x00BE, 0x013D}, // S
+ {0x00BF, 0x013E}, // T
+ {0x00C0, 0x013F}, // U
+ {0x00C1, 0x0140}, // V
+ {0x00C2, 0x0141}, // W
+ {0x00C3, 0x0142}, // X
+ {0x00C4, 0x0143}, // Y
+ {0x00C5, 0x0144}, // Z
+ {0x00C6, 0x0145}, // a
+ {0x00C7, 0x0146}, // b
+ {0x00C8, 0x0147}, // c
+ {0x00C9, 0x0148}, // d
+ {0x00CA, 0x0149}, // e
+ {0x00CB, 0x014A}, // f
+ {0x00CC, 0x014B}, // g
+ {0x00CD, 0x014C}, // h
+ {0x00CE, 0x014D}, // i
+ {0x00CF, 0x014E}, // j
+ {0x00D0, 0x014F}, // k
+ {0x00D1, 0x0150}, // l
+ {0x00D2, 0x0151}, // m
+ {0x00D3, 0x0152}, // n
+ {0x00D4, 0x0153}, // o
+ {0x00D5, 0x0154}, // p
+ {0x00D6, 0x0155}, // q
+ {0x00D7, 0x0156}, // r
+ {0x00D8, 0x0157}, // s
+ {0x00D9, 0x0158}, // t
+ {0x00DA, 0x0159}, // u
+ {0x00DB, 0x015A}, // v
+ {0x00DC, 0x015B}, // w
+ {0x00DD, 0x015C}, // x
+ {0x00DE, 0x015D}, // y
+ {0x00DF, 0x015E}, // z
+ {0x011F, 0x011F}, // ▶
+ {0x00F6, 0x01C4}, // :
+ {0x0163, 0x0163}, // Ä
+ {0x0175, 0x0175}, // Ö
+ {0x017B, 0x017B}, // Ü
+ {0x0183, 0x0183}, // ä
+ {0x0195, 0x0195}, // ö
+ {0x019B, 0x019B}, // ü
+};
+
+static THUMB_FUNC u16 GetOpeningQuote(u32 language)
+{
+ switch (language)
+ {
+ default:
+ return 0xEA;
+ case LANGUAGE_ENGLISH:
+ case LANGUAGE_ITALIAN:
+ case LANGUAGE_SPANISH:
+ return 0x1B4;
+ case LANGUAGE_FRENCH:
+ return 0x1B7;
+ case LANGUAGE_GERMAN:
+ return 0x1B6;
+ }
+}
+
+static THUMB_FUNC u16 GetClosingQuote(u32 language)
+{
+ switch (language)
+ {
+ default:
+ return 0xEB;
+ case LANGUAGE_ENGLISH:
+ case LANGUAGE_ITALIAN:
+ case LANGUAGE_SPANISH:
+ return 0x1B5;
+ case LANGUAGE_FRENCH:
+ return 0x1B8;
+ case LANGUAGE_GERMAN:
+ return 0x1B4;
+ }
+}
+
+THUMB_FUNC BOOL ConvertRSStringToDPStringInternational(const u8 * rs_str, u16 * dp_str, u32 length, u32 language)
+{
+ BOOL notFullWidth;
+ u32 i;
+
+ notFullWidth = (language != LANGUAGE_JAPANESE);
+ for (i = 0; i < length - 1; i++)
+ {
+ if (rs_str[i] == 0xFF) // RS: EOS
+ break;
+ if (rs_str[i] >= 0xF7) // RS: DYNAMIC
+ {
+ // If we're here, the provided name is corrupt.
+ // Fill it with question marks.
+ s32 r3 = (s32)((length - 1) < 10 ? (length - 1) : 10);
+ s32 r1;
+ for (r1 = 0; r1 < r3; r1++)
+ {
+ dp_str[r1] = 0x1AC; // DP: ?
+ }
+ dp_str[r1] = EOS;
+ return FALSE;
+ }
+ switch (conversion_table[rs_str[i]][notFullWidth])
+ {
+ case 0xEA: // RS: Opening double quote
+ dp_str[i] = GetOpeningQuote(language);
+ break;
+ case 0xEB: // RS: Closing double quote
+ dp_str[i] = GetClosingQuote(language);
+ break;
+ default:
+ dp_str[i] = conversion_table[rs_str[i]][notFullWidth];
+ break;
+ }
+ }
+ dp_str[i] = EOS;
+ return TRUE;
+}
diff --git a/arm9/src/save.c b/arm9/src/save.c
index 7eb523f6..524edfb7 100644
--- a/arm9/src/save.c
+++ b/arm9/src/save.c
@@ -4,6 +4,8 @@
#include "heap.h"
#include "CARD_backup.h"
#include "OS_spinLock.h"
+#include "save_data_read_error.h"
+#include "save_data_write_error.h"
#pragma thumb on
@@ -13,12 +15,6 @@
extern void FUN_02016444(u8 mask);
extern void FUN_02016454(u8 mask);
-// unk_02089D90.s
-extern void FUN_02089D90(int);
-
-// unk_02089F24.s
-extern void FUN_0208A0B8(int, int);
-
struct {
struct SaveBlock2 * ptr;
BOOL iswritten;
@@ -861,7 +857,7 @@ BOOL FlashLoadChunk(u32 src, void * dest, u32 size)
if (!r5)
{
FreeToHeap(UNK_021C59C8.ptr);
- FUN_02089D90(1);
+ ShowSaveDataReadError(1);
}
return r5;
}
@@ -910,10 +906,10 @@ BOOL WaitFlashWrite(int lock, BOOL * res)
return FALSE;
}
-void SaveErrorHandling(int lock, int errno)
+void SaveErrorHandling(int lock, u32 errno)
{
CARD_UnlockBackup((u16)lock);
OS_ReleaseLockID((u16)lock);
FreeToHeap(UNK_021C59C8.ptr);
- FUN_0208A0B8(1, errno);
+ ShowSaveDataWriteError(1, errno);
}
diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c
new file mode 100644
index 00000000..45a0c7bd
--- /dev/null
+++ b/arm9/src/save_data_read_error.c
@@ -0,0 +1,185 @@
+#include "global.h"
+#include "bg_window.h"
+#include "brightness.h"
+#include "game_init.h"
+#include "msgdata.h"
+#include "msgdata/msg.naix"
+#include "save_data_read_error.h"
+#include "text.h"
+#include "render_window.h"
+
+extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id);
+extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen);
+extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32);
+
+static const struct WindowTemplate sSaveDataReadErrorWindowTemplate = {
+ .bgId = GF_BG_LYR_MAIN_0,
+ .tilemapLeft = 3,
+ .tilemapTop = 3,
+ .width = 26,
+ .height = 18,
+ .paletteNum = 0x01,
+ .baseTile = 0x23,
+};
+
+static const struct GraphicsModes sSaveDataReadErrorGraphicsModes = {
+ .dispMode = GX_DISPMODE_GRAPHICS,
+ .bgMode = GX_BGMODE_0,
+ .subMode = GX_BGMODE_0,
+ ._2d3dMode = GX_BG0_AS_2D,
+};
+
+static const struct BgTemplate sSaveDataReadErrorBgTemplate = {
+ .x = 0,
+ .y = 0,
+ .bufferSize = 0x800,
+ .baseTile = 0,
+ .size = GF_BG_SCR_SIZE_256x256,
+ .colorMode = GX_BG_COLORMODE_16,
+ .screenBase = GX_BG_SCRBASE_0x0000,
+ .charBase = GX_BG_CHARBASE_0x18000,
+ .bgExtPltt = GX_BG_EXTPLTT_01,
+ .priority = 1,
+ .areaOver = GX_BG_AREAOVER_XLU,
+ .unk17 = 0,
+ .mosaic = FALSE,
+};
+
+static const struct GraphicsBanks sSaveDataReadErrorGraphicsBanks = {
+ .bg = 3,
+ .bgextpltt = 0,
+ .subbg = 0,
+ .subbgextpltt = 0,
+ .obj = 0,
+ .objextpltt = 0,
+ .subobj = 0,
+ .subobjextpltt = 0,
+ .tex = 0,
+ .texpltt = 0,
+};
+
+THUMB_FUNC void ShowSaveDataReadError(u32 heap_id)
+{
+ struct Window window;
+
+ FUN_0200E3A0(PM_LCD_TOP, 0);
+ FUN_0200E3A0(PM_LCD_BOTTOM, 0);
+
+ Main_SetVBlankIntrCB(NULL, NULL);
+ FUN_02015F34(NULL, NULL);
+
+ GX_DisableEngineALayers();
+ GX_DisableEngineBLayers();
+ reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK;
+ reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK;
+
+ SetKeyRepeatTimers(4, 8);
+
+ gMain.screensFlipped = 0;
+
+ GX_SwapDisplay();
+ reg_G2_BLDCNT = 0;
+ reg_G2S_DB_BLDCNT = 0;
+ reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK);
+ reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK);
+ GX_SetBanks(&sSaveDataReadErrorGraphicsBanks);
+
+ struct BgConfig* bg_config = BgConfig_Alloc(heap_id);
+
+ SetBothScreensModesAndDisable(&sSaveDataReadErrorGraphicsModes);
+
+ InitBgFromTemplate(bg_config, 0, &sSaveDataReadErrorBgTemplate, 0);
+ BgClearTilemapBufferAndCommit(bg_config, 0);
+ FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id);
+ FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id);
+ BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id);
+ BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21);
+ BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21);
+
+ struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0005_bin, heap_id);
+ struct String* str = String_ctor(384, heap_id);
+
+ FUN_0201BD5C();
+
+ AddWindow(bg_config, &window, &sSaveDataReadErrorWindowTemplate);
+ FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
+ DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2);
+
+ ReadMsgDataIntoString(msg_data, 0, str);
+ AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL);
+ String_dtor(str);
+
+ GX_BothDispOn();
+ FUN_0200E394(PM_LCD_TOP);
+ FUN_0200E394(PM_LCD_BOTTOM);
+ SetBrightness(0, 0x3F, 3);
+
+ while (TRUE)
+ {
+ HandleDSLidAction();
+ OS_WaitIrq(TRUE, OS_IE_V_BLANK);
+ }
+}
+
+THUMB_FUNC void ShowGBACartRemovedError(u32 heap_id)
+{
+ struct Window window;
+
+ FUN_0200E3A0(PM_LCD_TOP, 0);
+ FUN_0200E3A0(PM_LCD_BOTTOM, 0);
+
+ Main_SetVBlankIntrCB(NULL, NULL);
+ FUN_02015F34(NULL, NULL);
+
+ GX_DisableEngineALayers();
+ GX_DisableEngineBLayers();
+ reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK;
+ reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK;
+
+ SetKeyRepeatTimers(4, 8);
+
+ gMain.screensFlipped = 0;
+
+ GX_SwapDisplay();
+ reg_G2_BLDCNT = 0;
+ reg_G2S_DB_BLDCNT = 0;
+ reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK);
+ reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK);
+ GX_SetBanks(&sSaveDataReadErrorGraphicsBanks);
+
+ struct BgConfig* bg_config = BgConfig_Alloc(heap_id);
+
+ SetBothScreensModesAndDisable(&sSaveDataReadErrorGraphicsModes);
+
+ InitBgFromTemplate(bg_config, 0, &sSaveDataReadErrorBgTemplate, 0);
+ BgClearTilemapBufferAndCommit(bg_config, 0);
+ FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id);
+ FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id);
+ BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id);
+ BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21);
+ BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21);
+
+ struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0005_bin, heap_id);
+ struct String* str = String_ctor(384, heap_id);
+
+ FUN_0201BD5C();
+
+ AddWindow(bg_config, &window, &sSaveDataReadErrorWindowTemplate);
+ FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
+ DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2);
+
+ ReadMsgDataIntoString(msg_data, 1, str);
+ AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL);
+ String_dtor(str);
+
+ GX_BothDispOn();
+ FUN_0200E394(PM_LCD_TOP);
+ FUN_0200E394(PM_LCD_BOTTOM);
+ SetBrightness(0, 0x3F, 3);
+
+ while (TRUE)
+ {
+ HandleDSLidAction();
+ OS_WaitIrq(TRUE, OS_IE_V_BLANK);
+ }
+}
diff --git a/arm9/src/save_data_write_error.c b/arm9/src/save_data_write_error.c
new file mode 100644
index 00000000..3f03fb4b
--- /dev/null
+++ b/arm9/src/save_data_write_error.c
@@ -0,0 +1,130 @@
+#include "global.h"
+#include "bg_window.h"
+#include "brightness.h"
+#include "game_init.h"
+#include "msgdata.h"
+#include "msgdata/msg.naix"
+#include "save_data_write_error.h"
+#include "text.h"
+#include "render_window.h"
+
+extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id);
+extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen);
+extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32);
+
+static const struct WindowTemplate sSaveDataWriteErrorWindowTemplate = {
+ .bgId = GF_BG_LYR_MAIN_0,
+ .tilemapLeft = 3,
+ .tilemapTop = 3,
+ .width = 26,
+ .height = 18,
+ .paletteNum = 0x01,
+ .baseTile = 0x23,
+};
+
+static const struct GraphicsModes sSaveDataWriteErrorGraphicsModes = {
+ .dispMode = GX_DISPMODE_GRAPHICS,
+ .bgMode = GX_BGMODE_0,
+ .subMode = GX_BGMODE_0,
+ ._2d3dMode = GX_BG0_AS_2D,
+};
+
+static const struct BgTemplate sSaveDataWriteErrorBgTemplate = {
+ .x = 0,
+ .y = 0,
+ .bufferSize = 0x800,
+ .baseTile = 0,
+ .size = GF_BG_SCR_SIZE_256x256,
+ .colorMode = GX_BG_COLORMODE_16,
+ .screenBase = GX_BG_SCRBASE_0x0000,
+ .charBase = GX_BG_CHARBASE_0x18000,
+ .bgExtPltt = GX_BG_EXTPLTT_01,
+ .priority = 1,
+ .areaOver = GX_BG_AREAOVER_XLU,
+ .unk17 = 0,
+ .mosaic = FALSE,
+};
+
+static const struct GraphicsBanks sSaveDataWriteErrorGraphicsBanks = {
+ .bg = 3,
+ .bgextpltt = 0,
+ .subbg = 0,
+ .subbgextpltt = 0,
+ .obj = 0,
+ .objextpltt = 0,
+ .subobj = 0,
+ .subobjextpltt = 0,
+ .tex = 0,
+ .texpltt = 0,
+};
+
+THUMB_FUNC void ShowSaveDataWriteError(u32 heap_id, u32 err_no)
+{
+ struct Window window;
+
+ u32 msg_no;
+ if (err_no == 0) {
+ msg_no = 1;
+ } else {
+ msg_no = 0;
+ }
+
+ FUN_0200E3A0(PM_LCD_TOP, 0);
+ FUN_0200E3A0(PM_LCD_BOTTOM, 0);
+
+ FUN_02015EF4();
+ Main_SetVBlankIntrCB(NULL, NULL);
+ FUN_02015F34(NULL, NULL);
+
+ GX_DisableEngineALayers();
+ GX_DisableEngineBLayers();
+ reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK;
+ reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK;
+
+ SetKeyRepeatTimers(4, 8);
+
+ gMain.screensFlipped = 0;
+
+ GX_SwapDisplay();
+ reg_G2_BLDCNT = 0;
+ reg_G2S_DB_BLDCNT = 0;
+ reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK);
+ reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK);
+ GX_SetBanks(&sSaveDataWriteErrorGraphicsBanks);
+
+ struct BgConfig* bg_config = BgConfig_Alloc(heap_id);
+
+ SetBothScreensModesAndDisable(&sSaveDataWriteErrorGraphicsModes);
+
+ InitBgFromTemplate(bg_config, 0, &sSaveDataWriteErrorBgTemplate, 0);
+ BgClearTilemapBufferAndCommit(bg_config, 0);
+ FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id);
+ FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id);
+ BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id);
+ BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21);
+ BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21);
+
+ struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0006_bin, heap_id);
+ struct String* str = String_ctor(384, heap_id);
+
+ FUN_0201BD5C();
+
+ AddWindow(bg_config, &window, &sSaveDataWriteErrorWindowTemplate);
+ FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
+ DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2);
+
+ ReadMsgDataIntoString(msg_data, msg_no, str);
+ AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL);
+ String_dtor(str);
+
+ GX_BothDispOn();
+ FUN_0200E394(PM_LCD_TOP);
+ FUN_0200E394(PM_LCD_BOTTOM);
+ SetBrightness(0, 0x3F, 3);
+
+ while (TRUE)
+ {
+ HandleDSLidAction();
+ OS_WaitIrq(TRUE, OS_IE_V_BLANK);
+ }
+}
diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c
index c79684a0..2d57f0b1 100644
--- a/arm9/src/scrcmd.c
+++ b/arm9/src/scrcmd.c
@@ -1,10 +1,14 @@
#include "scrcmd.h"
+#include "unk_0200CA44.h"
#include "unk_0204639C.h"
#include "main.h"
#include "options.h"
#include "player_data.h"
#include "text.h"
#include "bg_window.h"
+#include "render_window.h"
+#include "text_02054590.h"
+
extern void *FUN_02039438(struct UnkSavStruct80* arg, u32 id);
extern void *CreateScriptContext(struct UnkSavStruct80* arg, u16 id);
@@ -21,27 +25,19 @@ extern void MOD05_021E2C58(struct ScriptContext *ctx, u16 typ, u16 id, u16 word1
extern struct ScrStrBufs *MOD06_02244210(struct SaveBlock2 *sav, u16 poke, u16 sex, u8 flag, u8 *unk);
extern void MOD05_021E2CBC(struct ScriptContext *ctx, struct ScrStrBufs *str, u8 param2, u32 param3);
extern void MOD05_021E2BB8(void *param0, struct ScriptContext *ctx);
-extern BOOL FUN_020546C8(u8 param0);
extern u32 FUN_02058488(u32 param0);
extern BOOL FUN_02030F40(void);
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(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 struct Window * MOD05_021E8140(u32 param0);
extern BOOL MOD05_021E8148(u32 param0);
-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);
+extern u32 Std_CreateYesNoMenu(struct BgConfig *param0, u8 **param1, u32 param2, u32 param3, u32 param4);
extern u32 FUN_020021AC(u32 param0, u32 param1);
-extern u32 FUN_0200D858(u32 *param0, u32 param1);
-extern void FUN_0200DBFC(u32 param0);
extern u32 MOD05_021E1BF8(struct UnkSavStruct80 *arg, u8 param1, u8 param2, u8 param3, u8 param4, u16 *param5, u32 param6, u32 *param7, struct MsgData *msgData);
extern void MOD05_021E1C4C(u32 param0, u32 param1, u32 param2);
extern void MOD05_021E1C54(u32 param0);
@@ -54,11 +50,11 @@ 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_0205AEA4(u32 param0, const void *ptr);
-extern void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2);
extern u32 FUN_02058B2C(u32 param0);
extern u32 FUN_02058B4C(u32 param0);
extern u32 FUN_020580B4(u32 param0, u32 param1);
extern u32 FUN_02058060(u32 param0, u32 param1);
+extern void FUN_0203B1A8(u32 param0, void *param1);
extern u8 *UNK_020F34E0;
@@ -79,6 +75,7 @@ static BOOL FUN_0203AD2C(struct ScriptContext *ctx);
static BOOL FUN_0203AD78(struct ScriptContext *ctx);
static u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1);
static BOOL FUN_0203B158(struct ScriptContext *ctx);
+static void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2);
extern u8 sScriptConditionTable[6][3];
@@ -771,8 +768,8 @@ THUMB_FUNC BOOL ScrCmd_Unk0033(struct ScriptContext *ctx)
{
struct UnkSavStruct80 *unk80 = ctx->unk80;
u8 *unk = (u8 *)FUN_02039438(unk80, 6);
- FUN_020545B8(unk80->unk08, FUN_02039438(unk80, 1), 3);
- FUN_02054608(FUN_02039438(unk80, 1), Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2));
+ FUN_020545B8(unk80->unk08, (struct Window *)FUN_02039438(unk80, 1), 3);
+ FUN_02054608((struct Window *)FUN_02039438(unk80, 1), Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2));
*unk = 1;
return FALSE;
}
@@ -782,7 +779,7 @@ THUMB_FUNC BOOL ScrCmd_CloseMessageBox(struct ScriptContext* ctx)
struct UnkSavStruct80 *unk80 = ctx->unk80;
struct Window *unk = FUN_02039438(unk80, 0x1);
u8 *unk2 = FUN_02039438(unk80, 0x6);
- FUN_0200D0E0(unk, 0); //clear window?
+ ClearFrameAndWindow2(unk, 0); //clear window?
RemoveWindow(unk);
*unk2 = 0;
return FALSE;
@@ -956,7 +953,7 @@ THUMB_FUNC BOOL ScrCmd_Unk003A(struct ScriptContext *ctx)
ReadMsgDataIntoString(ctx->msgData, msg, *unk2);
StringExpandPlaceholders(*unk4, *unk3, *unk2);
- *unk1 = FUN_02054658(MOD05_021E8140(unk80->unk60), *unk3, Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2), 1);
+ *unk1 = (u8)FUN_02054658(MOD05_021E8140(unk80->unk60), *unk3, Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2), 1);
ctx->data[0] = wk;
SetupNativeScript(ctx, FUN_0203A94C);
return TRUE;
@@ -1110,15 +1107,16 @@ THUMB_FUNC static BOOL FUN_0203AB00(struct ScriptContext *ctx)
THUMB_FUNC BOOL ScrCmd_ShowSaveClock(struct ScriptContext *ctx)
{
- u32 *unk = FUN_02039438(ctx->unk80, 1);
- u32 *unk2 = FUN_02039438(ctx->unk80, 18);
+ struct Window *unk = (struct Window *)FUN_02039438(ctx->unk80, 1);
+ struct UnkStruct_0200CABC_1 **unk2 = (struct UnkStruct_0200CABC_1 **)FUN_02039438(ctx->unk80, 18);
*unk2 = FUN_0200D858(unk, 994);
return FALSE;
}
+
THUMB_FUNC BOOL ScrCmd_HideSaveClock(struct ScriptContext *ctx)
{
- u32 *unk = FUN_02039438(ctx->unk80, 18);
+ struct UnkStruct_0200CABC_1 **unk = (struct UnkStruct_0200CABC_1 **)FUN_02039438(ctx->unk80, 18);
FUN_0200DBFC(*unk);
return FALSE;
}
@@ -1343,25 +1341,25 @@ THUMB_FUNC BOOL ScrCmd_Unk02A1(struct ScriptContext *ctx)
{
unk4[0] = 15;
pos++;
- unk4[1] = unk1 - unk5;
+ unk4[1] = (u16)(unk1 - unk5);
}
else if (unk5 > unk1)
{
unk4[0] = 14;
pos++;
- unk4[1] = unk5 - unk1;
+ unk4[1] = (u16)(unk5 - unk1);
}
if (unk6 < unk2)
{
unk4[pos * 2] = 12;
- unk4[pos * 2 + 1] = unk2 - unk6;
+ unk4[pos * 2 + 1] = (u16)(unk2 - unk6);
pos++;
}
else if (unk6 > unk2)
{
unk4[pos * 2] = 13;
- unk4[pos * 2 + 1] = unk6 - unk2;
+ unk4[pos * 2 + 1] = (u16)(unk6 - unk2);
pos++;
}
@@ -1405,3 +1403,17 @@ THUMB_FUNC static BOOL FUN_0203B158(struct ScriptContext *ctx)
u8 *unk = FUN_02039438(ctx->unk80, 4);
return *unk == 0 ? TRUE : FALSE;
}
+
+THUMB_FUNC static void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2)
+{
+ UnkStruct_0203B174 *unkStruct = (UnkStruct_0203B174 *)AllocFromHeap(4, sizeof(UnkStruct_0203B174));
+ if (unkStruct == NULL)
+ {
+ GF_AssertFail();
+ return;
+ }
+ unkStruct->Unk0C = arg;
+ unkStruct->Unk04 = param1;
+ unkStruct->Unk08 = param2;
+ unkStruct->Unk00 = FUN_0200CA44(FUN_0203B1A8, unkStruct, 0);
+}
diff --git a/arm9/src/scrcmd_amity_square.c b/arm9/src/scrcmd_amity_square.c
new file mode 100644
index 00000000..c957dec1
--- /dev/null
+++ b/arm9/src/scrcmd_amity_square.c
@@ -0,0 +1,200 @@
+#include "scrcmd.h"
+#include "constants/accessories.h"
+#include "constants/pokemon.h"
+#include "event_data.h"
+
+extern void FUN_0205F54C(struct ScriptState* state);
+extern u16 FUN_0205F55C(struct ScriptState* state);
+
+static const u16 sAmitySquarePossibleAccessoriesByPokemon[6][10] = {
+ { // Clefairy and Skitty
+ ACCESSORY_WHITE_FLUFF,
+ ACCESSORY_ORANGE_FLUFF,
+ ACCESSORY_WHITE_FEATHER,
+ ACCESSORY_MINI_PEBBLE,
+ ACCESSORY_SMALL_LEAF,
+ ACCESSORY_BLUE_SCALE,
+
+ ACCESSORY_WHITE_BEARD,
+ ACCESSORY_THIN_MUSHROOM,
+ ACCESSORY_BIG_SCALE,
+
+ ACCESSORY_STUMP
+ },
+
+ { // Torchic and Drifloon
+ ACCESSORY_PINK_FLUFF,
+ ACCESSORY_RED_FEATHER,
+ ACCESSORY_YELLOW_FEATHER,
+ ACCESSORY_BLACK_BEARD,
+ ACCESSORY_NARROW_SCALE,
+ ACCESSORY_WHITE_FLUFF,
+
+ ACCESSORY_WHITE_MOUSTACHE,
+ ACCESSORY_SHED_CLAW,
+ ACCESSORY_NARROW_LEAF,
+
+ ACCESSORY_PURPLE_SCALE
+ },
+
+ { // Psyduck and Pachirisu
+ ACCESSORY_SNAGGY_PEBBLE,
+ ACCESSORY_JAGGED_BOULDER,
+ ACCESSORY_BROWN_FLUFF,
+ ACCESSORY_MINI_PEBBLE,
+ ACCESSORY_BLACK_MOUSTACHE,
+ ACCESSORY_SHED_HORN,
+
+ ACCESSORY_NARROW_SCALE,
+ ACCESSORY_ROUND_PEBBLE,
+ ACCESSORY_GREEN_SCALE,
+
+ ACCESSORY_THICK_MUSHROOM
+ },
+
+ { // Jigglypuff and Shroomish
+ ACCESSORY_PINK_SCALE,
+ ACCESSORY_BLUE_FEATHER,
+ ACCESSORY_WHITE_FEATHER,
+ ACCESSORY_BLUE_SCALE,
+ ACCESSORY_THIN_MUSHROOM,
+ ACCESSORY_JAGGED_BOULDER,
+
+ ACCESSORY_WHITE_BEARD,
+ ACCESSORY_BLACK_BEARD,
+ ACCESSORY_BIG_LEAF,
+
+ ACCESSORY_ROUND_PEBBLE
+ },
+
+ { // Pikachu
+ ACCESSORY_ORANGE_FLUFF,
+ ACCESSORY_BROWN_FLUFF,
+ ACCESSORY_SMALL_LEAF,
+ ACCESSORY_RED_FEATHER,
+ ACCESSORY_YELLOW_FEATHER,
+ ACCESSORY_YELLOW_FLUFF,
+
+ ACCESSORY_GLITTER_BOULDER,
+ ACCESSORY_BIG_SCALE,
+ ACCESSORY_BLACK_MOUSTACHE,
+
+ ACCESSORY_PURPLE_SCALE
+ },
+
+ { // Buneary and Happiny
+ ACCESSORY_PINK_SCALE,
+ ACCESSORY_SHED_HORN,
+ ACCESSORY_PINK_FLUFF,
+ ACCESSORY_YELLOW_FEATHER,
+ ACCESSORY_SHED_CLAW,
+ ACCESSORY_BLACK_FLUFF,
+
+ ACCESSORY_SNAGGY_PEBBLE,
+ ACCESSORY_BIG_LEAF,
+ ACCESSORY_GREEN_SCALE,
+
+ ACCESSORY_BLACK_PEBBLE
+ },
+};
+
+THUMB_FUNC BOOL ScrCmd_ClearAmitySquareSteps(struct ScriptContext* ctx)
+{
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ FUN_0205F54C(state);
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckAmitySquareSteps(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2);
+
+ *ret_ptr = FUN_0205F55C(state);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GetAmitySquareAccessory(struct ScriptContext* ctx)
+{
+ u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 rand = (u16)(LCRandom() % 100);
+
+ u32 j;
+ if (rand < 15)
+ {
+ j = 0;
+ }
+ else if (rand < 30)
+ {
+ j = 1;
+ }
+ else if (rand < 45)
+ {
+ j = 2;
+ }
+ else if (rand < 60)
+ {
+ j = 3;
+ }
+ else if (rand < 70)
+ {
+ j = 4;
+ }
+ else if (rand < 80)
+ {
+ j = 5;
+ }
+ else if (rand < 88)
+ {
+ j = 6;
+ }
+ else if (rand < 93)
+ {
+ j = 7;
+ }
+ else if (rand < 98)
+ {
+ j = 8;
+ }
+ else
+ {
+ j = 9;
+ }
+
+ u32 i;
+ switch (species)
+ {
+ case SPECIES_CLEFAIRY:
+ case SPECIES_SKITTY:
+ i = 0;
+ break;
+ case SPECIES_TORCHIC:
+ case SPECIES_DRIFLOON:
+ i = 1;
+ break;
+ case SPECIES_PSYDUCK:
+ case SPECIES_PACHIRISU:
+ i = 2;
+ break;
+ case SPECIES_JIGGLYPUFF:
+ case SPECIES_SHROOMISH:
+ i = 3;
+ break;
+ case SPECIES_PIKACHU:
+ i = 4;
+ break;
+ case SPECIES_BUNEARY:
+ case SPECIES_HAPPINY:
+ i = 5;
+ break;
+ default:
+ i = 0;
+ break;
+ }
+
+ *ret_ptr = sAmitySquarePossibleAccessoriesByPokemon[i][j];
+ return FALSE;
+}
diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c
index ae20b5a4..b0993387 100644
--- a/arm9/src/scrcmd_sound.c
+++ b/arm9/src/scrcmd_sound.c
@@ -1,11 +1,7 @@
#include "scrcmd.h"
#include "unk_020040F4.h"
+#include "sound_chatot.h"
-extern void* Sav2_Chatot_get(struct SaveBlock2* sav2);
-extern u32 FUN_02005D20(void *);
-extern void FUN_02005E6C(void *);
-extern u32 FUN_02005E28(void);
-extern void FUN_02005E64(void);
extern BOOL FUN_02005CBC(void);
extern void PlaySound(u16);
extern void FUN_0204AB20(struct UnkSavStruct80 *ctx, u16);
@@ -41,7 +37,8 @@ THUMB_FUNC BOOL ScrCmd_PlayBgm(struct ScriptContext *ctx)
THUMB_FUNC BOOL ScrCmd_StopBgm(struct ScriptContext *ctx)
{
- u32 unk0 = FUN_02004124(ScriptReadHalfword(ctx));
+ ScriptReadHalfword(ctx);
+ u32 unk0 = FUN_02004124();
FUN_02005350(unk0, 0);
return FALSE;
}
@@ -199,7 +196,7 @@ 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)
+ if (Chatot_checkCry(unk) == 1)
{
*ret_ptr = 1;
return FALSE;
@@ -215,7 +212,7 @@ THUMB_FUNC BOOL ScrCmd_StartChatotRecord(struct ScriptContext* ctx)
{
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
- if (FUN_02005E28() == 0)
+ if (Chatot_startRecording() == 0)
{
*ret_ptr = 1;
return FALSE;
@@ -230,14 +227,14 @@ THUMB_FUNC BOOL ScrCmd_StartChatotRecord(struct ScriptContext* ctx)
THUMB_FUNC BOOL ScrCmd_StopChatotRecord(struct ScriptContext* ctx)
{
#pragma unused(ctx)
- FUN_02005E64();
+ Chatot_stopRecording();
return TRUE;
}
THUMB_FUNC BOOL ScrCmd_SaveChatotCry(struct ScriptContext* ctx)
{
void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2);
- FUN_02005E6C(unk);
+ Chatot_saveRecording(unk);
return TRUE;
}
diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c
index 1242d550..550dcab5 100644
--- a/arm9/src/script_buffers.c
+++ b/arm9/src/script_buffers.c
@@ -13,6 +13,8 @@
#include "script_buffers.h"
#include "unk_02024E64.h"
#include "text.h"
+#include "msgdata/msg.naix"
+#include "graphic/font.naix"
#pragma thumb on
@@ -34,9 +36,9 @@ const u16 UNK_020ECE6C[][2] = {
};
const u16 UNK_020ECE64[] = {
- 382,
- 384,
- 383,
+ NARC_msg_narc_0382_bin,
+ NARC_msg_narc_0384_bin,
+ NARC_msg_narc_0383_bin,
0
};
@@ -137,7 +139,7 @@ void BufferRivalsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2
void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2)
{
struct PlayerData * data = Sav2_PlayerData_GetProfileAddr(sav2);
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 497, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0497_bin, mgr->heap_id);
if (PlayerProfile_GetTrainerGender(data) == 0)
{
ReadMsgDataIntoString(msgData, 1, mgr->tmpbuf);
@@ -152,7 +154,7 @@ void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav
void BufferBoxMonSpeciesName(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 362, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, GetBoxMonData(mon, MON_DATA_SPECIES, NULL), mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
@@ -165,7 +167,7 @@ void BufferBoxMonSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, struct
void BufferSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 species)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 363, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0363_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, species, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
@@ -191,7 +193,7 @@ void BufferIntegerAsString(struct ScrStrBufs * mgr, u32 idx, int num, u32 ndigit
void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 588, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, move, mgr->tmpbuf);
@@ -202,7 +204,7 @@ void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move)
void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 484, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0484_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, ribbon, mgr->tmpbuf);
@@ -213,7 +215,7 @@ void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon)
void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 552, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0552_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, ability, mgr->tmpbuf);
@@ -224,7 +226,7 @@ void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability)
void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 190, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0190_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, nature, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
@@ -232,7 +234,7 @@ void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature)
void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 344, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0344_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -243,7 +245,7 @@ void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 346, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0346_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -254,7 +256,7 @@ void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 347, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0347_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -265,7 +267,7 @@ void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 349, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0349_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, pocket, mgr->tmpbuf);
@@ -276,7 +278,7 @@ void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket)
void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 565, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0565_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, type, mgr->tmpbuf);
@@ -287,7 +289,7 @@ void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type)
void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 495, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0495_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, stat, mgr->tmpbuf);
@@ -298,7 +300,7 @@ void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat)
void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 205, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0205_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, status, mgr->tmpbuf);
@@ -309,7 +311,7 @@ void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status)
void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 548, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0548_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, flavor, mgr->tmpbuf);
@@ -320,7 +322,7 @@ void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor)
void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 382, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, landmark, mgr->tmpbuf);
@@ -331,7 +333,7 @@ void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark)
void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 406, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0406_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, app, mgr->tmpbuf);
@@ -342,7 +344,7 @@ void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app)
void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 560, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf);
@@ -353,7 +355,7 @@ void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 561, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0561_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf);
@@ -364,7 +366,7 @@ void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trc
void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct TrainerDataLoaded * tr)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 560, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, tr->data.trainerClass, mgr->tmpbuf);
@@ -375,7 +377,7 @@ void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, stru
void BufferTrainerName(struct ScrStrBufs * mgr, u32 idx, u32 msgno)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 559, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0559_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msgno, mgr->tmpbuf);
@@ -392,7 +394,7 @@ void BufferTrainerNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct Tr
void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 569, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0569_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -403,7 +405,7 @@ void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 570, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0570_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -414,7 +416,7 @@ void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32
void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 571, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0571_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf);
@@ -425,7 +427,7 @@ void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap)
void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trap)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 572, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0572_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf);
@@ -436,7 +438,7 @@ void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32
void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 194, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0194_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, judge, mgr->tmpbuf);
@@ -447,7 +449,7 @@ void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge)
void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 191, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf);
@@ -458,7 +460,7 @@ void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg)
void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 191, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf);
@@ -469,7 +471,7 @@ void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg)
void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 574, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0574_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, question, mgr->tmpbuf);
@@ -480,7 +482,7 @@ void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question)
void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 573, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0573_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, answer, mgr->tmpbuf);
@@ -491,7 +493,7 @@ void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer)
void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 567, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0567_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf);
@@ -502,7 +504,7 @@ void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor)
void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 568, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0568_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf);
@@ -513,7 +515,7 @@ void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor
void BufferGenderSymbol(struct ScrStrBufs * mgr, u32 idx, u32 gender)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 199, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, mgr->heap_id);
switch (gender)
{
case 0:
@@ -538,7 +540,7 @@ void BufferBoxName(struct ScrStrBufs * mgr, u32 idx, struct PCStorage * pc, int
void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 331, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0331_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, gym, mgr->tmpbuf);
@@ -549,7 +551,7 @@ void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym)
void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 550, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0550_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, time, mgr->tmpbuf);
@@ -560,7 +562,7 @@ void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time)
void BufferCountryName(struct ScrStrBufs * mgr, u32 idx, u32 country)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 612, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0612_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, country, mgr->tmpbuf);
@@ -592,7 +594,7 @@ void FUN_0200B518(struct ScrStrBufs * mgr, u32 idx, u32 a2)
void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 10, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0010_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf);
@@ -603,7 +605,7 @@ void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal)
void BufferSealNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 seal)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 11, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0011_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf);
@@ -629,7 +631,7 @@ void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2)
// Location is invalid.
// Fallback: Mystery Zone
DestroyMsgData(msgData);
- msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 382, mgr->heap_id);
+ msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, 0, mgr->tmpbuf);
@@ -641,7 +643,7 @@ void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2)
void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 414, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0414_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, poffin, mgr->tmpbuf);
@@ -652,7 +654,7 @@ void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin)
void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 338, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0338_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf);
@@ -663,7 +665,7 @@ void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 339, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0339_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf);
@@ -674,7 +676,7 @@ void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
void BufferContestBackgroundName(struct ScrStrBufs * mgr, u32 idx, u32 bg)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 340, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0340_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, bg, mgr->tmpbuf);
@@ -696,7 +698,7 @@ void BufferEasyChatWord(struct ScrStrBufs * mgr, struct SaveBlock2 * sav2, u32 r
void BufferMonthNameAbbr(struct ScrStrBufs * mgr, u32 idx, u32 month)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 364, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0364_bin, mgr->heap_id);
if (msgData != NULL)
{
if (month < 1 || month > 12)
@@ -746,12 +748,12 @@ void ScrStrBufs_ResetBuffers(struct ScrStrBufs * mgr)
StringSetEmpty(mgr->array[i].msg);
}
-struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4)
+struct UnkStruct_0200B870 * MessagePrinter_new(u32 color1, u32 color2, u32 color3, u32 heap_id)
{
- struct UnkStruct_0200B870 * sp8 = AllocFromHeap(r4, sizeof(struct UnkStruct_0200B870));
+ struct UnkStruct_0200B870 * sp8 = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200B870));
if (sp8 != NULL)
{
- sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 4, 1, &sp8->unk_4, r4);
+ sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0004_NCGR_lz, 1, &sp8->unk_4, heap_id);
int i;
u8 * ptr = sp8->unk_4->unk_14;
for (i = 0; i < sp8->unk_4->unk_10; i++)
@@ -759,35 +761,35 @@ struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4)
switch (ptr[i])
{
case 0x00:
- ptr[i] = (u8)((sp4 << 4) | sp4);
+ ptr[i] = (u8)((color3 << 4) | color3);
break;
case 0x01:
- ptr[i] = (u8)((sp4 << 4) | r5);
+ ptr[i] = (u8)((color3 << 4) | color1);
break;
case 0x02:
- ptr[i] = (u8)((sp4 << 4) | r6);
+ ptr[i] = (u8)((color3 << 4) | color2);
break;
case 0x10:
- ptr[i] = (u8)((r5 << 4) | sp4);
+ ptr[i] = (u8)((color1 << 4) | color3);
break;
case 0x11:
- ptr[i] = (u8)((r5 << 4) | r5);
+ ptr[i] = (u8)((color1 << 4) | color1);
break;
case 0x12:
- ptr[i] = (u8)((r5 << 4) | r6);
+ ptr[i] = (u8)((color1 << 4) | color2);
break;
case 0x20:
- ptr[i] = (u8)((r6 << 4) | sp4);
+ ptr[i] = (u8)((color2 << 4) | color3);
break;
case 0x21:
- ptr[i] = (u8)((r6 << 4) | r5);
+ ptr[i] = (u8)((color2 << 4) | color1);
break;
case 0x22:
- ptr[i] = (u8)((r6 << 4) | r6);
+ ptr[i] = (u8)((color2 << 4) | color2);
break;
}
}
- sp8->unk_28 = sp4;
+ sp8->unk_28 = color3;
}
return sp8;
}
diff --git a/arm9/src/sound.c b/arm9/src/sound.c
index ec65dd06..210aec2e 100644
--- a/arm9/src/sound.c
+++ b/arm9/src/sound.c
@@ -3,6 +3,7 @@
#include "SPI_mic.h"
#include "SPI_pm.h"
#include "unk_020040F4.h"
+#include "sound_chatot.h"
#pragma thumb on
@@ -21,7 +22,6 @@ void FUN_020040DC(void);
extern void FUN_0200521C(int);
extern void FUN_0200538C(int, int, int);
extern BOOL FUN_02005404(void);
-extern void FUN_02005CFC(void);
void InitSoundData(struct SaveChatotSoundClip * chatot, struct Options * options)
{
diff --git a/arm9/src/sound_chatot.c b/arm9/src/sound_chatot.c
new file mode 100644
index 00000000..06b2fc64
--- /dev/null
+++ b/arm9/src/sound_chatot.c
@@ -0,0 +1,181 @@
+#include "global.h"
+#include "sound_chatot.h"
+#include "SPI_mic.h"
+#include "math_util.h"
+#include "proto.h"
+#include "sav_chatot.h"
+#include "sound.h"
+#include "unk_020040F4.h"
+#include "unk_020051F4.h"
+
+THUMB_FUNC BOOL FUN_02005CFC(void)
+{
+ if (*(u8 *)FUN_02003D38(29) == 1 && FUN_02004ABC(14) == 0)
+ {
+ FUN_02005DFC();
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC BOOL Chatot_checkCry(struct SaveChatotSoundClip *param0)
+{
+ u8 *r4 = FUN_02003D38(30);
+
+ if (!Chatot_exists(param0))
+ {
+ return FALSE;
+ }
+
+ if (*r4 != 1)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+THUMB_FUNC u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3)
+{
+#pragma unused(param1)
+
+ s8 *st0 = FUN_02004DB4();
+ u8 *st4 = FUN_02003D38(29);
+
+ if (!Chatot_checkCry(param0))
+ {
+ return 0;
+ }
+
+ FUN_02005614(0);
+ FUN_02005DFC();
+ FUN_02004984(14);
+ u16 r4 = (u16)(LCRandom() % 8192);
+
+ Chatot_Decode(st0, Chatot_GetData(param0));
+
+ struct UnkStruct_020040F4_1 st8;
+
+ st8.unk00 = FUN_02004930(14);
+ st8.unk04 = 0;
+ st8.unk08 = FUN_02004DB4();
+ st8.unk0c = 0;
+ st8.unk10 = 0;
+ st8.unk14 = 2000;
+ st8.unk18 = 2000;
+ st8.unk20 = (u32)(r4 + 0x8000);
+ st8.unk24 = param3 / 2 + 64;
+ st8.unk1c = param2;
+
+ u32 res = FUN_02004A6C(&st8, 14);
+ FUN_02004AF8(14, param2);
+ *st4 = 1;
+ FUN_02005E80(0);
+
+ return res;
+}
+
+THUMB_FUNC void FUN_02005DFC(void)
+{
+ u8 *r5 = FUN_02003D38(15);
+ u8 *r4 = FUN_02003D38(29);
+
+ if (*r5 == 1)
+ {
+ FUN_02004C3C(14);
+ FUN_02004A04(14);
+ }
+
+ *r4 = 0;
+}
+
+THUMB_FUNC u32 Chatot_startRecording(void)
+{
+ struct MIC_SamplingData st0;
+
+ st0.unk00 = 2;
+ st0.unk04 = FUN_02004DB4();
+ st0.unk08 = 2000;
+ if ((st0.unk08 & 0x1f) != 0)
+ {
+ st0.unk08 &= ~0x1f;
+ }
+ st0.unk0c = 0x4174;
+ st0.unk10 = 0;
+ st0.unk14 = 0;
+ st0.unk18 = 0;
+
+ return GF_MIC_StartAutoSampling(&st0);
+}
+
+THUMB_FUNC void Chatot_stopRecording(void)
+{
+ GF_MIC_StopAutoSampling();
+}
+
+THUMB_FUNC void Chatot_saveRecording(struct SaveChatotSoundClip *param0)
+{
+ Chatot_Encode(param0, FUN_02004DB4());
+}
+
+THUMB_FUNC void FUN_02005E80(u8 param0)
+{
+ *(u8 *)FUN_02003D38(30) = param0;
+}
+
+THUMB_FUNC void FUN_02005E90(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3)
+{
+ struct SaveChatotSoundClip **r0 = FUN_02003D38(35);
+ u32 ret;
+ if (param0 == 0)
+ {
+ ret = FUN_02005D48(*r0, param1, param2, param3);
+ }
+ else
+ {
+ ret = FUN_02005D48(param0, param1, param2, param3);
+ }
+
+ if (ret == 0)
+ {
+ FUN_02005E80(1);
+ FUN_020056AC(0, SPECIES_CHATOT, param3, param2, 11);
+ }
+}
+
+THUMB_FUNC u32 FUN_02005EE0(struct SaveChatotSoundClip *param0)
+{
+ if (!Chatot_exists(param0))
+ {
+ return 0;
+ }
+
+ s8 r0 = Chatot_GetData(param0)[15];
+ if (r0 < -30)
+ {
+ return 1;
+ }
+ else if (r0 >= 30 && r0 < 128)
+ {
+ return 2;
+ }
+
+ return 0;
+}
+
+THUMB_FUNC BOOL FUN_02005F14(s32 param0)
+{
+ switch (param0)
+ {
+ case 0:
+ case 1:
+ case 5:
+ case 11:
+ case 12:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
diff --git a/arm9/src/text.c b/arm9/src/text.c
index e8c76722..f178fa9d 100644
--- a/arm9/src/text.c
+++ b/arm9/src/text.c
@@ -6,10 +6,11 @@
#include "script_buffers.h"
#include "unk_0200CA44.h"
#include "font.h"
+#include "graphic/font.naix"
const struct FontInfo *gFonts = NULL;
-u16 UNK_021C5734[0x100];
+u16 sFontHalfRowLookupTable[0x100];
BOOL UNK_021C5714[8];
u16 UNK_021C570E;
u16 UNK_021C5710;
@@ -281,7 +282,7 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow
sp20[2] = shadowColor;
sp20[3] = bgColor;
- // FIXME: Need these to be accessed by a pointer to UNK_021C570C
+ // These are accessed by a pointer to UNK_021C570C due to -ipa file
UNK_021C5712 = bgColor;
UNK_021C570E = fgColor;
UNK_021C5710 = shadowColor;
@@ -294,7 +295,7 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow
{
for (l = 0; l < 4; l++)
{
- UNK_021C5734[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0));
+ sFontHalfRowLookupTable[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0));
}
}
}
@@ -303,22 +304,22 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow
THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst)
{
- dst[0] = UNK_021C5734[(u32)src[0] >> 8];
- dst[1] = UNK_021C5734[(u8)src[0]];
- dst[2] = UNK_021C5734[(u32)src[1] >> 8];
- dst[3] = UNK_021C5734[(u8)src[1]];
- dst[4] = UNK_021C5734[(u32)src[2] >> 8];
- dst[5] = UNK_021C5734[(u8)src[2]];
- dst[6] = UNK_021C5734[(u32)src[3] >> 8];
- dst[7] = UNK_021C5734[(u8)src[3]];
- dst[8] = UNK_021C5734[(u32)src[4] >> 8];
- dst[9] = UNK_021C5734[(u8)src[4]];
- dst[10] = UNK_021C5734[(u32)src[5] >> 8];
- dst[11] = UNK_021C5734[(u8)src[5]];
- dst[12] = UNK_021C5734[(u32)src[6] >> 8];
- dst[13] = UNK_021C5734[(u8)src[6]];
- dst[14] = UNK_021C5734[(u32)src[7] >> 8];
- dst[15] = UNK_021C5734[(u8)src[7]];
+ dst[0] = sFontHalfRowLookupTable[(u32)src[0] >> 8];
+ dst[1] = sFontHalfRowLookupTable[(u8)src[0]];
+ dst[2] = sFontHalfRowLookupTable[(u32)src[1] >> 8];
+ dst[3] = sFontHalfRowLookupTable[(u8)src[1]];
+ dst[4] = sFontHalfRowLookupTable[(u32)src[2] >> 8];
+ dst[5] = sFontHalfRowLookupTable[(u8)src[2]];
+ dst[6] = sFontHalfRowLookupTable[(u32)src[3] >> 8];
+ dst[7] = sFontHalfRowLookupTable[(u8)src[3]];
+ dst[8] = sFontHalfRowLookupTable[(u32)src[4] >> 8];
+ dst[9] = sFontHalfRowLookupTable[(u8)src[4]];
+ dst[10] = sFontHalfRowLookupTable[(u32)src[5] >> 8];
+ dst[11] = sFontHalfRowLookupTable[(u8)src[5]];
+ dst[12] = sFontHalfRowLookupTable[(u32)src[6] >> 8];
+ dst[13] = sFontHalfRowLookupTable[(u8)src[6]];
+ dst[14] = sFontHalfRowLookupTable[(u32)src[7] >> 8];
+ dst[15] = sFontHalfRowLookupTable[(u8)src[7]];
}
THUMB_FUNC void FUN_0201C1A8(struct TextPrinter *printer)
@@ -330,7 +331,7 @@ THUMB_FUNC u16 *FUN_0201C1B0(void)
{
void *res = AllocFromHeap(0, 32 * 24 * sizeof(u16));
struct UnkStruct_0200B870_sub * var;
- void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 5, 0, &var, 0);
+ void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0005_NCGR, 0, &var, 0);
MI_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16));
FreeToHeap(tmp);
return res;
diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c
index 3c3d0fed..03d01ae6 100644
--- a/arm9/src/text_02054590.c
+++ b/arm9/src/text_02054590.c
@@ -3,22 +3,10 @@
#include "bg_window.h"
#include "font.h"
#include "render_text.h"
+#include "render_window.h"
extern void FUN_0201BD5C(void);
-extern void FUN_0200CD68(
- struct BgConfig *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_0200D300(struct BgConfig *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)
{
if (param1 == 1)
@@ -45,7 +33,7 @@ THUMB_FUNC void FUN_02054608(struct Window *param0, struct Options *options)
{
FUN_0200CD68(param0->bgConfig, GetWindowBgId(param0), 994, 10, (u8)Options_GetFrame(options), 4);
FUN_0205464C(param0);
- FUN_0200D0BC(param0, 0, 994, 10);
+ DrawFrameAndWindow2(param0, 0, 994, 10);
}
THUMB_FUNC void FUN_0205464C(struct Window *param0)
@@ -99,9 +87,9 @@ THUMB_FUNC void FUN_020546E0(
}
}
-THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u32 param2)
+THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u16 param2)
{
FUN_0200D300(param0->bgConfig, GetWindowBgId(param0), 0x399, 9, (u8)param1, param2, 4);
FillWindowPixelBuffer(param0, 15);
- FUN_0200D6F8(param0, 0, 0x399, 9, (u8)param1);
+ DrawFrameAndWindow3(param0, 0, 0x399, 9, (u8)param1);
}
diff --git a/arm9/src/unk_020040F4.c b/arm9/src/unk_020040F4.c
index 5713ddf0..fa1d968f 100644
--- a/arm9/src/unk_020040F4.c
+++ b/arm9/src/unk_020040F4.c
@@ -3,6 +3,7 @@
#include "OS_cache.h"
#include "sound.h"
#include "unk_0202F150.h"
+#include "SPI_mic.h"
u32 UNK_021C3DD8[2];
@@ -22,9 +23,6 @@ extern void NNS_SndArcPlayerStartSeqEx(u32 *, u32, s32, s32, u32);
extern u16 NNS_SndPlayerCountPlayingSeqByPlayerNo(int);
extern u32 NNS_SndPlayerGetSeqNo(u32 *);
extern u32 NNS_SndArcGetBankInfo(u32);
-extern u32 MIC_StartAutoSampling(u32);
-extern u32 MIC_StopAutoSampling();
-extern u32 MIC_DoSamplingAsync(u32 param0, u32 param1, u32 param2, u32 param3);
extern u32 NNS_SndWaveOutAllocChannel(u32);
extern void NNS_SndWaveOutFreeChannel(u32);
extern u32 NNS_SndWaveOutStart(u32, u32, void *, u32, u32, u32, u32, s32, u32, s32);
@@ -59,7 +57,7 @@ THUMB_FUNC void FUN_020040F4(u8 param0)
*ptr = param0;
}
-THUMB_FUNC u8 FUN_02004104()
+THUMB_FUNC u8 FUN_02004104(void)
{
u8 *ptr = FUN_02003D38(5);
@@ -74,7 +72,7 @@ THUMB_FUNC void FUN_02004110(u16 param0)
FUN_02004130(0);
}
-THUMB_FUNC u16 FUN_02004124()
+THUMB_FUNC u16 FUN_02004124(void)
{
u16 *ptr = FUN_02003D38(9);
@@ -87,7 +85,7 @@ THUMB_FUNC void FUN_02004130(u16 param0)
*ptr = param0;
}
-THUMB_FUNC u16 FUN_02004140()
+THUMB_FUNC u16 FUN_02004140(void)
{
u16 *ptr = FUN_02003D38(10);
@@ -471,7 +469,7 @@ THUMB_FUNC void FUN_02004724(int param0)
FUN_0200521C(param0);
}
-THUMB_FUNC void FUN_02004738()
+THUMB_FUNC void FUN_02004738(void)
{
GF_Snd_RestoreState(FUN_02004748(4));
}
@@ -544,7 +542,7 @@ THUMB_FUNC void FUN_020047C8(u8 param0, u8 param1)
*ptr = param1;
}
-THUMB_FUNC void FUN_02004810()
+THUMB_FUNC void FUN_02004810(void)
{
u8 *ptr = FUN_02003D38(11);
u8 *ptr2 = FUN_02003D38(12);
@@ -650,14 +648,13 @@ THUMB_FUNC u16 FUN_02004900(u32 param0)
return *ptr;
}
-THUMB_FUNC u32 GF_MIC_StartAutoSampling(u32 param0)
+THUMB_FUNC u32 GF_MIC_StartAutoSampling(struct MIC_SamplingData *param0)
{
return MIC_StartAutoSampling(param0);
}
-THUMB_FUNC u32 GF_MIC_StopAutoSampling(u32 param0)
+THUMB_FUNC u32 GF_MIC_StopAutoSampling(void)
{
-#pragma unused(param0)
GetSoundDataPointer();
return MIC_StopAutoSampling();
}
@@ -914,7 +911,7 @@ THUMB_FUNC void FUN_02004C3C(u32 param0)
}
}
-THUMB_FUNC BOOL GF_SndCaptureIsActive()
+THUMB_FUNC BOOL GF_SndCaptureIsActive(void)
{
return NNS_SndCaptureIsActive();
}
@@ -936,7 +933,7 @@ THUMB_FUNC void GF_SndCaptureSetReverbVolume(u32 param0, u32 param1)
NNS_SndCaptureSetReverbVolume(param0, param1);
}
-THUMB_FUNC void FUN_02004CB4()
+THUMB_FUNC void FUN_02004CB4(void)
{
GetSoundDataPointer();
@@ -948,7 +945,7 @@ THUMB_FUNC void FUN_02004CB4()
NNS_SndCaptureStartEffect(r4, 0x1000, 0, 0x55F0, 2, FUN_02005068, st8);
}
-THUMB_FUNC void GF_SndCaptureStopEffect()
+THUMB_FUNC void GF_SndCaptureStopEffect(void)
{
NNS_SndCaptureStopEffect();
}
@@ -1000,7 +997,7 @@ THUMB_FUNC void FUN_02004D84(u32 param0)
*(u32 *)FUN_02003D38(7) = param0;
}
-THUMB_FUNC u16 FUN_02004D94()
+THUMB_FUNC u16 FUN_02004D94(void)
{
u16 *ptr = FUN_02003D38(7);
@@ -1013,7 +1010,7 @@ THUMB_FUNC u16 FUN_02004D94()
return --(*ptr);
}
-THUMB_FUNC u8 *FUN_02004DB4()
+THUMB_FUNC u8 *FUN_02004DB4(void)
{
return UNK_021C3DE0;
}
@@ -1345,7 +1342,7 @@ THUMB_FUNC void FUN_0200516C(u32 param0)
GF_SndCaptureIsActive();
}
-THUMB_FUNC void FUN_020051AC()
+THUMB_FUNC void FUN_020051AC(void)
{
if (FUN_02005404() == FALSE && GF_SndPlayerGetSeqNo(GetSoundPlayer(0)) != -1 &&
FUN_02004124() != 0x47e)
diff --git a/arm9/src/unk_020051F4.c b/arm9/src/unk_020051F4.c
index 6da250d5..53311039 100644
--- a/arm9/src/unk_020051F4.c
+++ b/arm9/src/unk_020051F4.c
@@ -6,6 +6,7 @@
#include "sound.h"
#include "unk_020040F4.h"
#include "unk_0200CA44.h"
+#include "sound_chatot.h"
extern u32 NNS_SndArcPlayerStartSeq(u32 *, u32);
extern u32 NNS_SndArcPlayerStartSeqEx(u32 *, s32, s32, s32, u32);
@@ -13,9 +14,6 @@ extern void NNS_SndPlayerStopSeqBySeqNo(u32, u32);
extern void NNS_SndPlayerStopSeqAll(u32);
extern void NNS_SndPlayerStopSeq(u32 *, u32);
extern void NNS_SndPlayerSetTrackPan(u32 *, u32, u32);
-extern u32 FUN_02005D48(u32, u32, u32, u32);
-extern void FUN_02005E80(u32);
-extern void FUN_02005DFC();
extern void *FUN_0201B6C8(u32 *);
THUMB_FUNC u32 FUN_020051F4(u16 param0)
@@ -281,7 +279,7 @@ THUMB_FUNC void FUN_0200554C(u32 param0)
THUMB_FUNC u32 FUN_02005578(u16 species)
{
u8 *r4 = FUN_02003D38(17);
- u32 *r0 = FUN_02003D38(35);
+ struct SaveChatotSoundClip **r0 = FUN_02003D38(35);
if (species != SPECIES_CHATOT)
{
diff --git a/arm9/src/unk_02008AA4.c b/arm9/src/unk_02008AA4.c
new file mode 100644
index 00000000..300967fc
--- /dev/null
+++ b/arm9/src/unk_02008AA4.c
@@ -0,0 +1,249 @@
+#include "global.h"
+#include "unk_02008AA4.h"
+#include "GX_vramcnt.h"
+#include "heap.h"
+#include "unk_0200BB14.h"
+#include "unk_02008DEC.h"
+#include "oam.h"
+
+extern void FUN_0202134C(void *, u32);
+extern u32 FUN_0201FCB0(u32 *);
+extern void FUN_02021390(u32, u32 *);
+extern void FUN_0201D194(u32, u32, u32);
+extern void FUN_0201E068(u32, u32);
+
+THUMB_FUNC void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0,
+ s32 param1,
+ s32 param2,
+ s32 param3,
+ s32 param4,
+ s32 param5,
+ s32 param6,
+ u32 param7,
+ u32 param8,
+ struct UnkStruct_02008DEC_1 *param9,
+ struct UnkStruct_02008DEC_1 *param10,
+ struct UnkStruct_02008DEC_1 *param11,
+ struct UnkStruct_02008DEC_1 *param12,
+ struct UnkStruct_02008DEC_1 *param13,
+ struct UnkStruct_02008DEC_1 *param14)
+{
+ struct UnkStruct_02008DEC_sub *r7;
+ struct UnkStruct_02008DEC_sub *st14;
+ struct UnkStruct_02008DEC_sub *st10;
+
+ struct UnkStruct_02008DEC_sub *stc = NULL;
+ struct UnkStruct_02008DEC_sub *r4 = NULL;
+ struct UnkStruct_02008DEC_sub *st8 = NULL;
+
+ GF_ASSERT(param9);
+ GF_ASSERT(param10);
+ GF_ASSERT(param12);
+ GF_ASSERT(param11);
+ GF_ASSERT(param0);
+
+ r7 = FUN_020094F0(param9, param1);
+ GF_ASSERT(r7);
+
+ st14 = FUN_020094F0(param10, param2);
+ GF_ASSERT(st14);
+
+ st10 = FUN_020094F0(param11, param3);
+ GF_ASSERT(st10);
+
+ if (param12 != 0 && param4 != -1)
+ {
+ stc = FUN_020094F0(param12, param4);
+ GF_ASSERT(stc);
+ }
+
+ if (param13 != 0)
+ {
+ if (param5 != -1)
+ {
+ r4 = FUN_020094F0(param13, param5);
+ }
+
+ if (param6 != -1)
+ {
+ st8 = FUN_020094F0(param14, param6);
+ }
+ }
+
+ u32 r6;
+ if (param7 != 0)
+ {
+ r6 = FUN_02009C80(r7, st10);
+ GF_ASSERT(r6);
+
+ param0->unk04 = FUN_02009544(r7);
+ }
+ else
+ {
+ r6 = FUN_02009C5C(r7);
+ GF_ASSERT(r6);
+
+ param0->unk04 = 0;
+ }
+
+ param0->unk08 = FUN_02009E54(st14, r6);
+ param0->unk00 = r6;
+ param0->unk0C = FUN_02009574(st10);
+
+ if (stc != 0)
+ {
+ param0->unk10 = FUN_0200958C(stc);
+ }
+ else
+ {
+ param0->unk10 = 0;
+ }
+
+ if (r4 != 0)
+ {
+ param0->unk14 = FUN_020095A4(r4);
+ param0->unk18 = FUN_020095BC(st8);
+ }
+ else
+ {
+ param0->unk14 = 0;
+ param0->unk18 = 0;
+ }
+
+ param0->unk1C = param7;
+ param0->unk20 = (u8)param8;
+}
+
+THUMB_FUNC struct UnkStruct_02008AA4_1 *FUN_02008BE0(struct UnkStruct_02008AA4_2 *param0,
+ u32 param1,
+ struct UnkStruct_02008DEC_1 *param2,
+ struct UnkStruct_02008DEC_1 *param3,
+ struct UnkStruct_02008DEC_1 *param4,
+ struct UnkStruct_02008DEC_1 *param5,
+ struct UnkStruct_02008DEC_1 *param6,
+ struct UnkStruct_02008DEC_1 *param7)
+{
+
+ s32 r4 = 0;
+ while (param0[r4].unk00 != -2)
+ {
+ r4++;
+ }
+
+ struct UnkStruct_02008AA4_1 *r6 = AllocFromHeap(param1, sizeof(struct UnkStruct_02008AA4_1));
+ r6->unk00 = AllocFromHeap(param1, r4 * sizeof(struct UnkStruct_0200BB14_sub));
+ r6->unk04 = r4;
+
+ for (int r7 = 0; r7 < r6->unk04; r7++)
+ {
+ FUN_02008AA4(&r6->unk00[r7],
+ param0[r7].unk00,
+ param0[r7].unk04,
+ param0[r7].unk08,
+ param0[r7].unk0C,
+ param0[r7].unk10,
+ param0[r7].unk14,
+ param0[r7].unk18,
+ param0[r7].unk1C,
+ param2,
+ param3,
+ param4,
+ param5,
+ param6,
+ param7);
+ }
+
+ return r6;
+}
+
+THUMB_FUNC void FUN_02008C80(struct UnkStruct_02008AA4_1 *param0)
+{
+ GF_ASSERT(param0);
+
+ if (param0->unk00 != NULL)
+ {
+ FreeToHeap(param0->unk00);
+ }
+ FreeToHeap(param0);
+}
+
+THUMB_FUNC u32 FUN_02008C9C(u32 param0, void *param1, u32 param2)
+{
+ FUN_0202134C(param1, 0xFFFFF000);
+
+ u32 st10[3];
+ u32 st0[4];
+
+ st0[0] = 0;
+ st0[1] = 0;
+ st0[2] = 0xFF000;
+ st0[3] = 0xC0000;
+ FUN_02009FD8(param1 + 0x98, st0, 1, param1);
+
+ st0[0] = 0;
+ st0[1] = 0xC0000;
+ st0[2] = 0xFF000;
+ st0[3] = 0xC0000;
+
+ FUN_02009FD8(param1 + 0xe0, st0, 2, param1);
+
+ st10[0] = param0;
+ st10[1] = (u32)param1;
+ st10[2] = param2;
+
+ return FUN_0201FCB0(st10);
+}
+
+THUMB_FUNC void FUN_02008D04(u32 param0, u32 param1, u32 param2)
+{
+ u32 st0[4];
+ st0[0] = param1;
+ st0[2] = 0xFF000;
+ st0[3] = 0xC0000;
+ st0[1] = param2;
+ FUN_02021390(param0 + 0x98, st0);
+}
+
+THUMB_FUNC void FUN_02008D24(u32 param0, u32 param1, u32 param2)
+{
+ u32 st0[4];
+ st0[0] = param1;
+ st0[2] = 0xFF000;
+ st0[3] = 0xC0000;
+ st0[1] = param2;
+ FUN_02021390(param0 + 0xe0, st0);
+}
+
+THUMB_FUNC void FUN_02008D44(u32 param0, u32 param1)
+{
+ switch (param1)
+ {
+ case 0x10:
+ if (GX_GetBankForOBJ() == 0x40 || GX_GetBankForOBJ() == 0x20)
+ {
+ FUN_0201D194(0x3E00, 0x200, param0);
+ return;
+ }
+
+ FUN_0201D194(0x7E00, 0x200, param0);
+ return;
+ case 0x00100010:
+ FUN_0201D194(0xfe00, 0x200, param0);
+ return;
+ case 0x00200010:
+ if (GX_GetBankForOBJ() == 0x30 || GX_GetBankForOBJ() == 0x50)
+ {
+ FUN_0201D194(0x13E00, 0x200, param0);
+ return;
+ }
+ FUN_0201D194(0x1FE00, 0x200, param0);
+ return;
+ }
+
+ GF_AssertFail();
+}
+
+THUMB_FUNC void FUN_02008DDC(u32 param0)
+{
+ FUN_0201E068(0xC000, param0);
+}
diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c
new file mode 100644
index 00000000..2238b920
--- /dev/null
+++ b/arm9/src/unk_02008DEC.c
@@ -0,0 +1,1118 @@
+#include "global.h"
+#include "unk_02008DEC.h"
+#include "NNS_g2d.h"
+#include "gf_gfx_loader.h"
+#include "heap.h"
+
+extern u32 FUN_02020C44(u32, u32);
+extern void FUN_02020C90(u32);
+extern u32 FUN_02020CB0(u32 param0, s32 param1);
+extern void FUN_02020E1C(u32 param0, u32 param1);
+extern void FUN_02020D68(u32 param0, u32 param1);
+extern s32 FUN_02020E38(u32);
+extern void *FUN_02020E0C(u32);
+extern BOOL NNS_G2dGetUnpackedMultiCellBank(void *, void *);
+extern BOOL NNS_G2dGetUnpackedMCAnimBank(void *, void *);
+extern u32 FUN_02020D10(u32, void *, s32, u32);
+extern u32 FUN_02020CD4(u32, void *, s32);
+extern u32 FUN_0201D1F8(u32 *param0);
+extern u32 FUN_0201D250(u32 *param0);
+extern void FUN_0201D2DC(s32, u32);
+extern void FUN_0201D324(s32 param0);
+extern u32 FUN_0201D3B0(s32);
+extern u32 FUN_0201D3D4(s32, u32);
+extern u32 FUN_0201D458(u32);
+extern void FUN_0201D4F0(u32);
+extern u32 FUN_0201E0E4(u32 *param0);
+extern u32 FUN_0201E128(u32 *param0);
+extern void FUN_0201E168(s32, u32);
+extern void FUN_0201E1C8(s32);
+extern u32 FUN_0201E258(s32, u32);
+extern u32 FUN_0201E230(s32);
+extern s32 NNS_G2dGetImagePaletteLocation(u32, u32);
+
+THUMB_FUNC struct UnkStruct_02008DEC_1 *FUN_02008DEC(u32 param0, s32 param1, u32 heap_id)
+{
+ struct UnkStruct_02008DEC_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_02008DEC_1));
+ ptr->unk00 = FUN_02020C44(param0, heap_id);
+ ptr->unk04 = AllocFromHeap(heap_id, param0 * sizeof(struct UnkStruct_02008DEC_sub));
+ memset(ptr->unk04, 0, param0 * sizeof(struct UnkStruct_02008DEC_sub));
+ ptr->unk08 = (s32)param0;
+ ptr->unk0C = 0;
+ ptr->unk10 = param1;
+
+ return ptr;
+}
+
+THUMB_FUNC void FUN_02008E2C(struct UnkStruct_02008DEC_1 *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk00);
+ GF_ASSERT(param0->unk04);
+
+ FUN_020094C4(param0);
+
+ FUN_02020C90(param0->unk00);
+ param0->unk00 = 0;
+
+ FreeToHeap(param0->unk04);
+ param0->unk04 = NULL;
+
+ FreeToHeap(param0);
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008E6C(
+ struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_2 *param1, s32 param2, u32 param3)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param1);
+ GF_ASSERT(param1->unk04 > param2);
+ GF_ASSERT(param0->unk10 == param1->unk08);
+
+ struct UnkStruct_02008DEC_sub *st1c = FUN_020097D0(param0);
+ GF_ASSERT(st1c);
+
+ if (param1->unk0C == 0)
+ {
+ struct UnkStruct_02008DEC_3 *r6 = &param1->unk00_3[param2];
+ GF_ASSERT(FUN_0200945C(param0, r6->unk00) == 1);
+
+ FUN_0200994C(
+ param0, st1c, r6->unk04, r6->unk00, r6->unk44, r6->unk48, param1->unk08, param3);
+ }
+ else
+ {
+ struct UnkStruct_02008DEC_4 *r6 = &param1->unk00_4[param2];
+ GF_ASSERT(FUN_0200945C(param0, r6->unk0C) == 1);
+
+ FUN_02009978(param0,
+ st1c,
+ r6->unk00,
+ r6->unk04,
+ r6->unk08,
+ r6->unk0C,
+ r6->unk10,
+ r6->unk14,
+ param1->unk08,
+ param3,
+ FALSE);
+ }
+
+ param0->unk0C++;
+
+ return st1c;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008F34(struct UnkStruct_02008DEC_1 *param0,
+ NarcId param1,
+ s32 param2,
+ BOOL param3,
+ s32 param4,
+ u32 param5,
+ u32 param6)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 0);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_02009978(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, FALSE);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008F90(struct UnkStruct_02008DEC_1 *param0,
+ NarcId param1,
+ s32 param2,
+ BOOL param3,
+ s32 param4,
+ u32 param5,
+ u32 param6,
+ BOOL param7)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 0);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_02009978(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008FEC(struct UnkStruct_02008DEC_1 *param0,
+ NarcId param1,
+ s32 param2,
+ BOOL param3,
+ s32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 1);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_02009978(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, FALSE);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_0200904C(struct UnkStruct_02008DEC_1 *param0,
+ NarcId param1,
+ s32 param2,
+ BOOL param3,
+ s32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7,
+ BOOL param8)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 1);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_02009978(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020090AC(struct UnkStruct_02008DEC_1 *param0,
+ NarcId param1,
+ s32 param2,
+ BOOL param3,
+ s32 param4,
+ u32 param5,
+ u32 param6)
+{
+ GF_ASSERT(param0);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_02009978(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, FALSE);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC void FUN_020090FC(struct UnkStruct_02008DEC_1 *param0,
+ struct UnkStruct_02008DEC_sub *param1,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
+ u32 param5)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 0);
+ GF_ASSERT(param1);
+ GF_ASSERT(param1->unk04 == 0);
+
+ s32 r6 = FUN_02009530(param1);
+ u32 r7 = FUN_020095E4(param1);
+ FUN_02009490(param0, param1);
+
+ FUN_02009978(param0, param1, param2, param3, param4, r6, r7, 0, 0, param5, FALSE);
+}
+
+THUMB_FUNC void FUN_02009168(struct UnkStruct_02008DEC_1 *param0,
+ struct UnkStruct_02008DEC_sub *param1,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
+ u32 param5)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 1);
+ GF_ASSERT(param1);
+ GF_ASSERT(param1->unk04 == 1);
+
+ s32 r6 = FUN_02009530(param1);
+ u32 r7 = FUN_020095E4(param1);
+ u32 st24 = FUN_02009610(param1);
+ FUN_02009490(param0, param1);
+
+ FUN_02009978(param0, param1, param2, param3, param4, r6, r7, st24, 1, param5, 0);
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020091E0(struct UnkStruct_02008DEC_1 *param0,
+ NARC *param1,
+ u32 param2,
+ u32 param3,
+ s32 param4,
+ u32 param5,
+ u32 param6)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 0);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, 0);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_0200923C(struct UnkStruct_02008DEC_1 *param0,
+ NARC *param1,
+ u32 param2,
+ u32 param3,
+ s32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 0);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02009298(struct UnkStruct_02008DEC_1 *param0,
+ NARC *param1,
+ u32 param2,
+ u32 param3,
+ s32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 1);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, 0);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020092F8(struct UnkStruct_02008DEC_1 *param0,
+ NARC *param1,
+ u32 param2,
+ u32 param3,
+ s32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7,
+ u32 param8)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk10 == 1);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02009358(struct UnkStruct_02008DEC_1 *param0,
+ NARC *param1,
+ u32 param2,
+ u32 param3,
+ s32 param4,
+ u32 param5,
+ u32 param6)
+{
+ GF_ASSERT(param0);
+
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0);
+ GF_ASSERT(r6);
+
+ FUN_020099B0(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, 0);
+ param0->unk0C++;
+
+ return r6;
+}
+
+THUMB_FUNC s32 FUN_020093A8(
+ struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_2 *param1, struct UnkStruct_02008DEC_5 *param2, u32 param3)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param1);
+
+ FUN_020093DC(param0, param1, 0, param1->unk04, param2, param3);
+
+ return param1->unk04;
+}
+
+THUMB_FUNC void FUN_020093DC(struct UnkStruct_02008DEC_1 *param0,
+ struct UnkStruct_02008DEC_2 *param1,
+ s32 param2,
+ s32 param3,
+ struct UnkStruct_02008DEC_5 *param4,
+ u32 param5)
+{
+ for (int r5 = param2; r5 < param2 + param3; r5++)
+ {
+ struct UnkStruct_02008DEC_sub *r0 = FUN_02008E6C(param0, param1, r5, param5);
+
+ if (param4 != NULL && param4->unk04 > param4->unk08)
+ {
+ param4->unk00[param4->unk08] = r0;
+ param4->unk08++;
+ }
+ }
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_5 *FUN_02009424(s32 param0, u32 param1)
+{
+ struct UnkStruct_02008DEC_5 *r4 = AllocFromHeap(param1, sizeof(struct UnkStruct_02008DEC_5));
+ r4->unk00 = AllocFromHeap(param1, param0 * sizeof(struct UnkStruct_02008DEC_sub *));
+ r4->unk04 = param0;
+ r4->unk08 = 0;
+
+ return r4;
+}
+
+THUMB_FUNC void FUN_02009448(struct UnkStruct_02008DEC_5 *param0)
+{
+ FreeToHeap(param0->unk00);
+ FreeToHeap(param0);
+}
+
+THUMB_FUNC u32 FUN_0200945C(struct UnkStruct_02008DEC_1 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+ return FUN_02020CB0(param0->unk00, param1);
+}
+
+THUMB_FUNC void FUN_02009474(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+
+ FUN_02009920(param0);
+ FUN_02020E1C(param0->unk00, 0);
+}
+
+THUMB_FUNC void FUN_02009490(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_sub *param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk04);
+
+ FUN_02009920(param1);
+ FUN_02020D68(param0->unk00, param1->unk00);
+ param1->unk00 = 0;
+ param0->unk0C--;
+}
+
+THUMB_FUNC void FUN_020094C4(struct UnkStruct_02008DEC_1 *param0)
+{
+ for (int i = 0; i < param0->unk08; i++)
+ {
+ if (param0->unk04[i].unk00 != 0)
+ {
+ FUN_02009490(param0, &param0->unk04[i]);
+ }
+ }
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020094F0(struct UnkStruct_02008DEC_1 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+
+ for (int i = 0; i < param0->unk08; i++)
+ {
+ if (param0->unk04[i].unk00 != 0)
+ {
+ s32 r0 = FUN_02020E38(param0->unk04[i].unk00);
+ if (r0 == param1)
+ {
+ return &param0->unk04[i];
+ }
+ }
+ }
+
+ return NULL;
+}
+
+THUMB_FUNC s32 FUN_02009530(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ return FUN_02020E38(param0->unk00);
+}
+
+THUMB_FUNC u32 FUN_02009544(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0->unk04 == 0);
+ return *FUN_02009934(param0);
+}
+
+THUMB_FUNC u32 FUN_0200955C(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0->unk04 == 1);
+ return *FUN_02009934(param0);
+}
+
+THUMB_FUNC u32 FUN_02009574(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0->unk04 == 2);
+ return *FUN_02009934(param0);
+}
+
+THUMB_FUNC u32 FUN_0200958C(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0->unk04 == 3);
+ return *FUN_02009934(param0);
+}
+
+THUMB_FUNC u32 FUN_020095A4(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0->unk04 == 4);
+ return *FUN_02009934(param0);
+}
+
+THUMB_FUNC u32 FUN_020095BC(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0->unk04 == 5);
+ return *FUN_02009934(param0);
+}
+
+THUMB_FUNC u32 FUN_020095D4(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+
+ return param0->unk04;
+}
+
+THUMB_FUNC u32 FUN_020095E4(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+
+ if (param0->unk04 == 0)
+ {
+ return FUN_02009934(param0)[1];
+ }
+ if (param0->unk04 == 1)
+ {
+ return FUN_02009934(param0)[1];
+ }
+
+ return 0;
+}
+
+THUMB_FUNC u32 FUN_02009610(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+
+ if (param0->unk04 == 1)
+ {
+ return FUN_02009934(param0)[2];
+ }
+
+ return 0;
+}
+
+THUMB_FUNC void FUN_02009630(struct UnkStruct_02008DEC_sub *param0, u32 param1)
+{
+ GF_ASSERT(param0);
+
+ if (param0->unk04 == 0)
+ {
+ FUN_02009934(param0)[1] = param1;
+ }
+ if (param0->unk04 == 1)
+ {
+ FUN_02009934(param0)[1] = param1;
+ }
+}
+
+THUMB_FUNC u32 FUN_0200965C(void)
+{
+ return 16;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_2 *FUN_02009660(struct UnkStruct_02008DEC_2 *param0, s32 param1)
+{
+ return &param0[param1];
+}
+
+THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct_02008DEC_2 *param1, u32 param2)
+{
+ GF_ASSERT(param1);
+
+ param1->unk08 = param0[0];
+ param1->unk0C = 1;
+
+ param1->unk04 = FUN_020099E8((struct UnkStruct_02008DEC_4 *)(param0 + 1));
+
+ if (param1->unk04 > 0)
+ {
+ param1->unk00_4 = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4));
+ }
+ else
+ {
+ param1->unk00_4 = NULL;
+ }
+
+ if (param1->unk00_4 != NULL)
+ {
+ memcpy(param1->unk00_4, param0 + 1, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4));
+ }
+}
+
+THUMB_FUNC void FUN_020096B4(struct UnkStruct_02008DEC_2 *param0)
+{
+ if (param0->unk00_4)
+ {
+ FreeToHeap(param0->unk00_4);
+ }
+ param0->unk00_4 = NULL;
+ param0->unk04 = 0;
+}
+
+THUMB_FUNC s32 FUN_020096CC(struct UnkStruct_02008DEC_2 *param0)
+{
+ GF_ASSERT(param0);
+
+ return param0->unk04;
+}
+
+THUMB_FUNC s32 FUN_020096DC(struct UnkStruct_02008DEC_2 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk04 > param1);
+
+ if (param0->unk0C == 0)
+ {
+ return param0->unk00_3[param1].unk00;
+ }
+
+ return param0->unk00_4[param1].unk0C;
+}
+
+THUMB_FUNC s32 FUN_02009710(struct UnkStruct_02008DEC_2 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk04 > param1);
+
+ s32 r6;
+ if (param0->unk0C == 1)
+ {
+ r6 = param0->unk00_4[param1].unk04;
+ }
+
+ // oops, UB here
+ return r6;
+}
+
+THUMB_FUNC BOOL FUN_0200973C(struct UnkStruct_02008DEC_2 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk04 > param1);
+
+ BOOL r6;
+ if (param0->unk0C == 1)
+ {
+ r6 = param0->unk00_4[param1].unk08;
+ }
+
+ // oops, UB here
+ return r6;
+}
+
+THUMB_FUNC u32 FUN_02009768(struct UnkStruct_02008DEC_2 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk04 > param1);
+
+ if (param0->unk0C == 0)
+ {
+ return param0->unk00_3[param1].unk44;
+ }
+
+ return param0->unk00_4[param1].unk10;
+}
+
+THUMB_FUNC u32 FUN_0200979C(struct UnkStruct_02008DEC_2 *param0, s32 param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk04 > param1);
+
+ if (param0->unk0C == 0)
+ {
+ return param0->unk00_3[param1].unk48;
+ }
+
+ return param0->unk00_4[param1].unk14;
+}
+
+THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020097D0(struct UnkStruct_02008DEC_1 *param0)
+{
+ for (int i = 0; i < param0->unk08; i++)
+ {
+ if (param0->unk04[i].unk00 == 0)
+ {
+ return &param0->unk04[i];
+ }
+ }
+
+ return NULL;
+}
+
+THUMB_FUNC void FUN_020097FC(
+ struct UnkStruct_02008DEC_sub *param0, u32 param1, u32 param2, u32 param3, u32 param4)
+{
+ void *r0 = FUN_02020E0C(param0->unk00);
+
+ switch (param1)
+ {
+ case 0:
+ param0->unk08 = FUN_0200986C(r0, param2, param4);
+ break;
+ case 1:
+ param0->unk08 = FUN_0200988C(r0, param2, param3, param4);
+ break;
+ case 2:
+ param0->unk08 = FUN_020098B0(r0, param4);
+ break;
+ case 3:
+ param0->unk08 = FUN_020098CC(r0, param4);
+ break;
+ case 4:
+ param0->unk08 = FUN_020098E8(r0, param4);
+ break;
+ case 5:
+ param0->unk08 = FUN_02009904(r0, param4);
+ break;
+ }
+}
+
+THUMB_FUNC struct CharacterData_02008DEC *FUN_0200986C(void *param0, u32 param1, u32 param2)
+{
+ struct CharacterData_02008DEC *ptr =
+ AllocFromHeap(param2, sizeof(struct CharacterData_02008DEC));
+
+ NNS_G2dGetUnpackedCharacterData(param0, &ptr->chData);
+ ptr->unk04 = param1;
+
+ return ptr;
+}
+
+THUMB_FUNC struct PaletteData_02008DEC *FUN_0200988C(
+ void *param0, u32 param1, u32 param2, u32 param3)
+{
+ struct PaletteData_02008DEC *ptr = AllocFromHeap(param3, sizeof(struct PaletteData_02008DEC));
+
+ NNS_G2dGetUnpackedPaletteData(param0, &ptr->plttData);
+ ptr->unk04 = param1;
+ ptr->unk08 = param2;
+
+ return ptr;
+}
+
+THUMB_FUNC struct CellDataBank_02008DEC *FUN_020098B0(void *param0, u32 param1)
+{
+ struct CellDataBank_02008DEC *ptr = AllocFromHeap(param1, sizeof(struct CellDataBank_02008DEC));
+
+ NNS_G2dGetUnpackedCellBank(param0, &ptr->cellBank);
+
+ return ptr;
+}
+
+THUMB_FUNC struct AnimBank_02008DEC *FUN_020098CC(void *param0, u32 param1)
+{
+ struct AnimBank_02008DEC *ptr = AllocFromHeap(param1, sizeof(struct AnimBank_02008DEC));
+
+ NNS_G2dGetUnpackedAnimBank(param0, &ptr->bankData);
+
+ return ptr;
+}
+
+THUMB_FUNC void *FUN_020098E8(void *param0, u32 param1)
+{
+ void *ptr = AllocFromHeap(param1, 4);
+
+ NNS_G2dGetUnpackedMultiCellBank(param0, ptr);
+
+ return ptr;
+}
+
+THUMB_FUNC void *FUN_02009904(void *param0, u32 param1)
+{
+ void *ptr = AllocFromHeap(param1, 4);
+
+ NNS_G2dGetUnpackedMCAnimBank(param0, ptr);
+
+ return ptr;
+}
+
+THUMB_FUNC void FUN_02009920(struct UnkStruct_02008DEC_sub *param0)
+{
+ if (param0->unk08 != NULL)
+ {
+ FreeToHeap(param0->unk08);
+ }
+
+ param0->unk08 = NULL;
+}
+
+THUMB_FUNC u32 *FUN_02009934(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param0->unk08);
+
+ return param0->unk08;
+}
+
+THUMB_FUNC void FUN_0200994C(struct UnkStruct_02008DEC_1 *param0,
+ struct UnkStruct_02008DEC_sub *param1,
+ void *param2,
+ s32 param3,
+ u32 param4,
+ u32 param5,
+ u32 param6,
+ u32 param7)
+{
+ param1->unk00 = FUN_02020D10(param0->unk00, param2, param3, param7);
+ param1->unk04 = param6;
+ FUN_020097FC(param1, param6, param4, param5, param7);
+}
+
+THUMB_FUNC void FUN_02009978(struct UnkStruct_02008DEC_1 *param0,
+ struct UnkStruct_02008DEC_sub *param1,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
+ s32 param5,
+ u32 param6,
+ u32 param7,
+ u32 param8,
+ u32 param9,
+ BOOL param10)
+{
+ void *r1 = GfGfxLoader_LoadFromNarc(param2, param3, param4, param9, param10);
+ param1->unk00 = FUN_02020CD4(param0->unk00, r1, param5);
+ param1->unk04 = param8;
+
+ FUN_020097FC(param1, param8, param6, param7, param9);
+}
+
+THUMB_FUNC void FUN_020099B0(struct UnkStruct_02008DEC_1 *param0,
+ struct UnkStruct_02008DEC_sub *param1,
+ NARC *param2,
+ u32 param3,
+ u32 param4,
+ s32 param5,
+ u32 param6,
+ u32 param7,
+ u32 param8,
+ u32 param9,
+ u32 param10)
+{
+ param1->unk00 =
+ FUN_02020CD4(param0->unk00, FUN_02009A04(param2, param3, param4, param9, param10), param5);
+ param1->unk04 = param8;
+
+ FUN_020097FC(param1, param8, param6, param7, param9);
+}
+
+THUMB_FUNC s32 FUN_020099E8(struct UnkStruct_02008DEC_4 *param0)
+{
+ s32 r3 = 0;
+ while (param0[r3].unk00 != -2)
+ {
+ r3++;
+ }
+
+ return r3;
+}
+
+THUMB_FUNC void *FUN_02009A04(NARC *param0, u32 param1, u32 param2, u32 param3, u32 param4)
+{
+ void *r4 = NARC_AllocAndReadWholeMember(param0, param1, param3);
+
+ if (r4 != NULL && param2 != 0)
+ {
+ void *ptr;
+ if (param4 == 0)
+ {
+ ptr = AllocFromHeap(param3, (*(u32 *)r4) >> 8);
+ }
+ else
+ {
+ ptr = AllocFromHeapAtEnd(param3, (*(u32 *)r4) >> 8);
+ }
+
+ if (ptr != NULL)
+ {
+ MI_UncompressLZ8(r4, ptr);
+ FreeToHeap(r4);
+ }
+
+ r4 = ptr;
+ }
+
+ return r4;
+}
+
+THUMB_FUNC u32 FUN_02009A50(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+
+ u32 st0[4];
+ st0[0] = FUN_02009544(param0);
+ st0[1] = FUN_020095E4(param0);
+ st0[2] = (u32)FUN_02009530(param0);
+ st0[3] = 0;
+
+ return FUN_0201D1F8(st0);
+}
+
+THUMB_FUNC void FUN_02009A90(struct UnkStruct_02008DEC_5 *param0)
+{
+ GF_ASSERT(param0);
+
+ for (int i = 0; i < param0->unk04; i++)
+ {
+ GF_ASSERT(param0->unk00[i] == NULL || FUN_02009A50(param0->unk00[i]) != 0);
+ }
+}
+
+THUMB_FUNC u32 FUN_02009AC4(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+
+ u32 st0[4];
+ st0[0] = FUN_02009544(param0);
+ st0[1] = FUN_020095E4(param0);
+ st0[2] = (u32)FUN_02009530(param0);
+ st0[3] = 0;
+
+ return FUN_0201D250(st0);
+}
+
+THUMB_FUNC u32 FUN_02009B04(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+
+ u32 st0[4];
+ st0[0] = FUN_02009544(param0);
+ st0[1] = FUN_020095E4(param0);
+ st0[2] = (u32)FUN_02009530(param0);
+ st0[3] = 1;
+
+ return FUN_0201D1F8(st0);
+}
+
+THUMB_FUNC void FUN_02009B44(struct UnkStruct_02008DEC_5 *param0)
+{
+ GF_ASSERT(param0);
+
+ for (int i = 0; i < param0->unk04; i++)
+ {
+ GF_ASSERT(param0->unk00[i] == NULL || FUN_02009B04(param0->unk00[i]) != 0);
+ }
+}
+
+THUMB_FUNC u32 FUN_02009B78(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+
+ u32 st0[4];
+ st0[0] = FUN_02009544(param0);
+ st0[1] = FUN_020095E4(param0);
+ st0[2] = (u32)FUN_02009530(param0);
+ st0[3] = 1;
+
+ return FUN_0201D250(st0);
+}
+
+THUMB_FUNC void FUN_02009BB8(struct UnkStruct_02008DEC_sub *param0, struct UnkStruct_02008DEC_sub *param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(param1);
+
+ FUN_0201D2DC(FUN_02009530(param0), FUN_02009544(param1));
+}
+
+THUMB_FUNC void FUN_02009BE8(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+
+ FUN_0201D2DC(FUN_02009530(param0), FUN_02009544(param0));
+}
+
+THUMB_FUNC void FUN_02009C0C(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+
+ FUN_0201D324(FUN_02009530(param0));
+}
+
+THUMB_FUNC void FUN_02009C30(struct UnkStruct_02008DEC_5 *param0)
+{
+ GF_ASSERT(param0);
+ for (int i = 0; i < param0->unk04; i++)
+ {
+ if (param0->unk00[i] != NULL)
+ {
+ FUN_02009C0C(param0->unk00[i]);
+ }
+ }
+}
+
+THUMB_FUNC u32 FUN_02009C5C(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+
+ return FUN_0201D3B0(FUN_02009530(param0));
+}
+
+THUMB_FUNC u32 FUN_02009C80(struct UnkStruct_02008DEC_sub *param0, struct UnkStruct_02008DEC_sub *param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 0);
+ GF_ASSERT(param1);
+ GF_ASSERT(FUN_020095D4(param1) == 2);
+
+ s32 r4 = FUN_02009530(param0);
+
+ u32 r0 = FUN_0201D3D4(r4, ((u32 **)FUN_02009574(param1))[3][0]);
+ if (r0 == 0)
+ {
+ return FUN_0201D458(FUN_0201D3B0(r4));
+ }
+
+ return r0;
+}
+
+THUMB_FUNC void FUN_02009CDC(u32 param0)
+{
+ GF_ASSERT(param0);
+
+ FUN_0201D4F0(param0);
+}
+
+THUMB_FUNC u32 FUN_02009CF0(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 1);
+
+ u32 st0[4];
+ st0[0] = FUN_0200955C(param0);
+ st0[1] = FUN_020095E4(param0);
+ st0[3] = (u32)FUN_02009530(param0);
+ st0[2] = FUN_02009610(param0);
+
+ return FUN_0201E0E4(st0);
+}
+
+THUMB_FUNC void FUN_02009D34(struct UnkStruct_02008DEC_5 *param0)
+{
+ GF_ASSERT(param0);
+ for (int i = 0; i < param0->unk04; i++)
+ {
+ if (param0->unk00[i] != NULL)
+ {
+ GF_ASSERT(FUN_02009CF0(param0->unk00[i]) != 0);
+ }
+ }
+}
+
+THUMB_FUNC u32 FUN_02009D68(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 1);
+
+ u32 st0[4];
+ st0[0] = FUN_0200955C(param0);
+ st0[1] = FUN_020095E4(param0);
+ st0[3] = (u32)FUN_02009530(param0);
+ st0[2] = FUN_02009610(param0);
+
+ return FUN_0201E128(st0);
+}
+
+THUMB_FUNC void FUN_02009DAC(struct UnkStruct_02008DEC_5 *param0)
+{
+ GF_ASSERT(param0);
+ for (int i = 0; i < param0->unk04; i++)
+ {
+ if (param0->unk00[i] != NULL)
+ {
+ GF_ASSERT(FUN_02009D68(param0->unk00[i]) != 0);
+ }
+ }
+}
+
+THUMB_FUNC void FUN_02009DE0(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+
+ FUN_0201E168(FUN_02009530(param0), FUN_0200955C(param0));
+}
+
+THUMB_FUNC void FUN_02009E04(struct UnkStruct_02008DEC_sub *param0)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 1);
+
+ FUN_0201E1C8(FUN_02009530(param0));
+}
+
+THUMB_FUNC void FUN_02009E28(struct UnkStruct_02008DEC_5 *param0)
+{
+ GF_ASSERT(param0);
+ for (int i = 0; i < param0->unk04; i++)
+ {
+ if (param0->unk00[i] != NULL)
+ {
+ FUN_02009E04(param0->unk00[i]);
+ }
+ }
+}
+
+THUMB_FUNC u32 FUN_02009E54(struct UnkStruct_02008DEC_sub *param0, u32 param1)
+{
+ GF_ASSERT(param0);
+ GF_ASSERT(FUN_020095D4(param0) == 1);
+
+ s32 r0 = FUN_02009530(param0);
+ if (param1 != 0)
+ {
+ return FUN_0201E258(r0, param1);
+ }
+
+ return FUN_0201E230(r0);
+}
+
+THUMB_FUNC s32 FUN_02009E88(struct UnkStruct_02008DEC_sub *param0, u32 param1)
+{
+ s32 ret = NNS_G2dGetImagePaletteLocation(FUN_02009E54(param0, 0), param1);
+ if (ret != -1)
+ {
+ return ret / 32;
+ }
+
+ return ret;
+}
diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c
index 4ed957d6..093d35c1 100644
--- a/arm9/src/unk_0200BB14.c
+++ b/arm9/src/unk_0200BB14.c
@@ -2,90 +2,28 @@
#include "unk_0200BB14.h"
#include "game_init.h"
#include "heap.h"
+#include "unk_02008AA4.h"
+#include "unk_02008DEC.h"
+#include "oam.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);
@@ -115,12 +53,6 @@ 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)
{
@@ -226,7 +158,7 @@ THUMB_FUNC void FUN_0200BC1C(u32 *param0)
THUMB_FUNC void FUN_0200BC30()
{
- FUN_02009F80();
+ ApplyAndResetOamManagerBuffer();
}
THUMB_FUNC void FUN_0200BC38()
@@ -273,7 +205,7 @@ THUMB_FUNC void FUN_0200BCB0(u32 *param0)
if (param0[2] == 1)
{
- FUN_02009FA0();
+ DeinitOamData();
}
}
@@ -317,12 +249,12 @@ THUMB_FUNC BOOL FUN_0200BD20(
}
param1->unk54 = st14;
- u32 r2 = FUN_0200965C(st14);
+ u32 r2 = FUN_0200965C();
param1->unk08 = AllocFromHeap(param0->unk000, r2 * st14);
for (s32 i = 0; i < st14; i++)
{
- u32 st18 = FUN_02009660(param1->unk08, i);
+ struct UnkStruct_02008DEC_2 *st18 = FUN_02009660(param1->unk08, i);
void *st1c = AllocAndReadFile(param0->unk000, st10[i]);
FUN_02009668(st1c, st18, param0->unk000);
@@ -337,14 +269,14 @@ THUMB_FUNC BOOL FUN_0200BD20(
for (s32 i = 0; i < st14; i++)
{
- u32 st20 = FUN_02009660(param1->unk08, i);
+ struct UnkStruct_02008DEC_2 *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 = AllocAndReadFile(param0->unk000, st10[6]);
+ struct UnkStruct_02008AA4_2 *r6 = AllocAndReadFile(param0->unk000, st10[6]);
param1->unk04 = FUN_02008BE0(r6,
param0->unk000,
param1->unk0c[0],
@@ -456,7 +388,7 @@ THUMB_FUNC u32 FUN_0200BE74(u32 *param0,
}
THUMB_FUNC BOOL FUN_0200BF60(
- struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, u32 *param2)
+ struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, s32 *param2)
{
struct UnkStruct_0200BB14_1 *st0 = param0;
s32 i;
@@ -486,9 +418,9 @@ THUMB_FUNC BOOL FUN_0200BF60(
param1->unk24[i] = FUN_02009424(param2[i], st0->unk000);
param1->unk3c[i] = 0;
- for (s32 j = 0; j < (s32)param1->unk24[i][1]; j++)
+ for (s32 j = 0; j < param1->unk24[i]->unk04; j++)
{
- ((u32 *)param1->unk24[i][0])[j] = 0;
+ param1->unk24[i]->unk00[j] = NULL;
}
}
}
@@ -498,9 +430,9 @@ THUMB_FUNC BOOL FUN_0200BF60(
THUMB_FUNC BOOL FUN_0200C00C(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
u32 param5,
s32 param6)
{
@@ -509,8 +441,8 @@ THUMB_FUNC BOOL FUN_0200C00C(u32 *param0,
return FALSE;
}
- u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
- if (r5 != 0)
+ struct UnkStruct_02008DEC_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != NULL)
{
FUN_02009B04(r5);
FUN_0200C474(param1->unk24[0], r5);
@@ -518,14 +450,14 @@ THUMB_FUNC BOOL FUN_0200C00C(u32 *param0,
}
GF_ASSERT(0);
- return r5 != 0 ? TRUE : FALSE;
+ return r5 != NULL ? TRUE : FALSE;
}
THUMB_FUNC s32 FUN_0200C06C(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
u32 param5,
u32 param6,
s32 param7)
@@ -535,16 +467,16 @@ THUMB_FUNC s32 FUN_0200C06C(u32 *param0,
return -1;
}
- u32 r5 =
+ struct UnkStruct_02008DEC_sub * r5 =
FUN_02008FEC(param1->unk0c[1], param2, param3, param4, param7, param6, param5, param0[0]);
- if (r5 != 0)
+ if (r5 != NULL)
{
GF_ASSERT(FUN_02009D68(r5) == 1);
FUN_0200C474(param1->unk24[1], r5);
return (s8)FUN_02009E88(r5, param6);
}
- GF_ASSERT(0);
+ GF_ASSERT(FALSE);
return -1;
}
@@ -552,9 +484,9 @@ THUMB_FUNC u8 FUN_0200C0DC(u32 param0,
u32 param1,
u32 *param2,
struct UnkStruct_0200BB14_2 *param3,
- u32 param4,
- u32 param5,
- u32 param6,
+ NarcId param4,
+ s32 param5,
+ BOOL param6,
u32 param7,
u32 param8,
s32 param9)
@@ -568,21 +500,21 @@ THUMB_FUNC u8 FUN_0200C0DC(u32 param0,
return (u8)r4;
}
-THUMB_FUNC u32 FUN_0200C124(u32 *param0,
+THUMB_FUNC BOOL FUN_0200C124(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
s32 param5)
{
return FUN_0200C404(param0, param1, param2, param3, param4, 2, param5);
}
-THUMB_FUNC u32 FUN_0200C13C(u32 *param0,
+THUMB_FUNC BOOL FUN_0200C13C(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
s32 param5)
{
return FUN_0200C404(param0, param1, param2, param3, param4, 3, param5);
@@ -722,32 +654,32 @@ THUMB_FUNC struct UnkStruct_0200BB14_5 *FUN_0200C154(
return ptr;
}
-THUMB_FUNC u32 FUN_0200C334(u32 *param0, u32 param1)
+THUMB_FUNC u32 FUN_0200C334(struct UnkStruct_02008DEC_1 **param0, s32 param1)
{
return FUN_02009E54(FUN_020094F0(param0[4], param1), 0);
}
-THUMB_FUNC u32 FUN_0200C344(u32 *param0, u32 param1, u32 param2)
+THUMB_FUNC s32 FUN_0200C344(struct UnkStruct_02008DEC_1 **param0, s32 param1, u32 param2)
{
return FUN_02009E88(FUN_020094F0(param0[4], param1), param2);
}
-THUMB_FUNC u32 FUN_0200C358(struct UnkStruct_0200BB14_2 *param0, u32 param1)
+THUMB_FUNC BOOL 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)
+THUMB_FUNC BOOL 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)
+THUMB_FUNC BOOL 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)
+THUMB_FUNC BOOL FUN_0200C388(struct UnkStruct_0200BB14_2 *param0, u32 param1)
{
return FUN_0200C4A8(param0->unk0c[3], param0->unk24[3], param1);
}
@@ -776,15 +708,15 @@ THUMB_FUNC void FUN_0200C3DC(u32 *param0)
}
FUN_0201FFC8(param0[0]);
- FUN_02008C80(param0[2]);
+ FUN_02008C80((struct UnkStruct_02008AA4_1 *)param0[2]);
FreeToHeap(param0);
}
THUMB_FUNC BOOL FUN_0200C404(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
u32 param5,
s32 param6)
{
@@ -793,25 +725,25 @@ THUMB_FUNC BOOL FUN_0200C404(u32 *param0,
return FALSE;
}
- u32 r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]);
- if (r5 != 0)
+ struct UnkStruct_02008DEC_sub *r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != NULL)
{
- u32 r4 = FUN_0200C474(param1->unk24[param5], r5);
- GF_ASSERT(r4 == 1);
+ BOOL r4 = FUN_0200C474(param1->unk24[param5], r5);
+ GF_ASSERT(r4 == TRUE);
return r4;
}
GF_ASSERT(0);
- return r5 != 0 ? TRUE : FALSE;
+ return r5 != NULL ? TRUE : FALSE;
}
-THUMB_FUNC BOOL FUN_0200C474(u32 *param0, u32 param1)
+THUMB_FUNC BOOL FUN_0200C474(struct UnkStruct_02008DEC_5 *param0, struct UnkStruct_02008DEC_sub *param1)
{
- for (s32 i = 0; i < (s32)param0[1]; i++)
+ for (s32 i = 0; i < param0->unk04; i++)
{
- if (((u32 *)param0[0])[i] == 0)
+ if (param0->unk00[i] == NULL)
{
- ((u32 *)param0[0])[i] = param1;
- param0[2]++;
+ param0->unk00[i] = param1;
+ param0->unk08++;
return TRUE;
}
}
@@ -819,19 +751,19 @@ THUMB_FUNC BOOL FUN_0200C474(u32 *param0, u32 param1)
return FALSE;
}
-THUMB_FUNC BOOL FUN_0200C4A8(u32 param0, u32 *param1, u32 param2)
+THUMB_FUNC BOOL FUN_0200C4A8(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_5 *param1, u32 param2)
{
- for (s32 i = 0; i < (s32)param1[1]; i++)
+ for (s32 i = 0; i < param1->unk04; i++)
{
- if (((u32 *)param1[0])[i] != 0)
+ if (param1->unk00[i] != 0)
{
- u32 r0 = FUN_02009530(((u32 *)param1[0])[i]);
+ s32 r0 = FUN_02009530(param1->unk00[i]);
if (r0 == param2)
{
- FUN_02009490(param0, ((u32 *)param1[0])[i]);
- ((u32 *)param1[0])[i] = 0;
- param1[2]--;
+ FUN_02009490(param0, param1->unk00[i]);
+ param1->unk00[i] = NULL;
+ param1->unk08--;
return TRUE;
}
@@ -841,20 +773,20 @@ THUMB_FUNC BOOL FUN_0200C4A8(u32 param0, u32 *param1, u32 param2)
return FALSE;
}
-THUMB_FUNC BOOL FUN_0200C4F4(u32 param0, u32 *param1, u32 param2)
+THUMB_FUNC BOOL FUN_0200C4F4(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_5 *param1, u32 param2)
{
- for (s32 i = 0; i < (s32)param1[1]; i++)
+ for (s32 i = 0; i < param1->unk04; i++)
{
- if (((u32 *)param1[0])[i] != 0)
+ if (param1->unk00[i] != NULL)
{
- u32 r0 = FUN_02009530(((u32 *)param1[0])[i]);
+ s32 r0 = FUN_02009530(param1->unk00[i]);
if (r0 == param2)
{
FUN_0201D324(param2);
- FUN_02009490(param0, ((u32 *)param1[0])[i]);
- ((u32 *)param1[0])[i] = 0;
- param1[2]--;
+ FUN_02009490(param0, param1->unk00[i]);
+ param1->unk00[i] = NULL;
+ param1->unk08--;
return TRUE;
}
@@ -864,20 +796,20 @@ THUMB_FUNC BOOL FUN_0200C4F4(u32 param0, u32 *param1, u32 param2)
return FALSE;
}
-THUMB_FUNC BOOL FUN_0200C548(u32 param0, u32 *param1, u32 param2)
+THUMB_FUNC BOOL FUN_0200C548(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_5 *param1, u32 param2)
{
- for (s32 i = 0; i < (s32)param1[1]; i++)
+ for (s32 i = 0; i < param1->unk04; i++)
{
- if (((u32 *)param1[0])[i] != 0)
+ if (param1->unk00[i] != 0)
{
- u32 r0 = FUN_02009530(((u32 *)param1[0])[i]);
+ s32 r0 = FUN_02009530(param1->unk00[i]);
if (r0 == param2)
{
FUN_0201E1C8(param2);
- FUN_02009490(param0, ((u32 *)param1[0])[i]);
- ((u32 *)param1[0])[i] = 0;
- param1[2]--;
+ FUN_02009490(param0, param1->unk00[i]);
+ param1->unk00[i] = NULL;
+ param1->unk08--;
return TRUE;
}
@@ -1085,18 +1017,18 @@ THUMB_FUNC void FUN_0200C75C(u32 param0, u16 *param1, u16 *param2)
{
s32 *r4 = FUN_0202011C(param0, param1, param2);
- param1[0] = r4[0] / 0x1000;
+ param1[0] = (u16)(r4[0] / 0x1000);
if (FUN_02020380(param0) == 2)
{
s32 r1 = r4[1] - 0xc0000;
- param2[0] = r1 / 0x1000;
+ param2[0] = (u16)(r1 / 0x1000);
return;
}
- param2[0] = r4[1] / 0x1000;
+ param2[0] = (u16)(r4[1] / 0x1000);
}
THUMB_FUNC void FUN_0200C7A0(u32 *param0, u16 *param1, u16 *param2)
@@ -1104,25 +1036,25 @@ 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)
+THUMB_FUNC void FUN_0200C7AC(u32 param0, u16 *param1, u16 *param2, s32 param3)
{
s32 *r4 = FUN_0202011C(param0, param1, param2);
- param1[0] = r4[0] / 0x1000;
+ param1[0] = (u16)(r4[0] / 0x1000);
if (FUN_02020380(param0) == 2)
{
s32 r1 = r4[1] - param3;
- param2[0] = r1 / 0x1000;
+ param2[0] = (u16)(r1 / 0x1000);
return;
}
- param2[0] = r4[1] / 0x1000;
+ param2[0] = (u16)(r4[1] / 0x1000);
}
-THUMB_FUNC void FUN_0200C7F0(u32 *param0, u16 *param1, u16 *param2, u32 param3)
+THUMB_FUNC void FUN_0200C7F0(u32 *param0, u16 *param1, u16 *param2, s32 param3)
{
FUN_0200C7AC(*param0, param1, param2, param3);
}
@@ -1229,9 +1161,9 @@ THUMB_FUNC void FUN_0200C90C(u32 *param0, u32 param1)
THUMB_FUNC BOOL FUN_0200C918(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
u32 param5,
s32 param6)
{
@@ -1240,8 +1172,8 @@ THUMB_FUNC BOOL FUN_0200C918(u32 *param0,
return FALSE;
}
- u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
- if (r5 != 0)
+ struct UnkStruct_02008DEC_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != NULL)
{
FUN_02009AC4(r5);
FUN_0200C474(param1->unk24[0], r5);
@@ -1249,15 +1181,15 @@ THUMB_FUNC BOOL FUN_0200C918(u32 *param0,
return TRUE;
}
- GF_ASSERT(0);
- return r5 != 0 ? TRUE : FALSE;
+ GF_ASSERT(FALSE);
+ return r5 != NULL ? TRUE : FALSE;
}
THUMB_FUNC BOOL FUN_0200C978(u32 *param0,
struct UnkStruct_0200BB14_2 *param1,
- u32 param2,
- u32 param3,
- u32 param4,
+ NarcId param2,
+ s32 param3,
+ BOOL param4,
u32 param5,
s32 param6)
{
@@ -1266,8 +1198,8 @@ THUMB_FUNC BOOL FUN_0200C978(u32 *param0,
return FALSE;
}
- u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
- if (r5 != 0)
+ struct UnkStruct_02008DEC_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]);
+ if (r5 != NULL)
{
FUN_02009B78(r5);
FUN_0200C474(param1->unk24[0], r5);
@@ -1275,23 +1207,23 @@ THUMB_FUNC BOOL FUN_0200C978(u32 *param0,
return TRUE;
}
- GF_ASSERT(0);
- return r5 != 0 ? TRUE : FALSE;
+ GF_ASSERT(FALSE);
+ return r5 != NULL ? TRUE : FALSE;
}
THUMB_FUNC void FUN_0200C9D8(
- u32 *param0, u32 *param1, u32 param2, u32 param3, u32 param4, u32 param5)
+ u32 *param0, struct UnkStruct_02008DEC_1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5)
{
- u32 r6 = FUN_020094F0(param1[3], param5);
+ struct UnkStruct_02008DEC_sub *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 *param0, struct UnkStruct_02008DEC_1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5)
{
- u32 r6 = FUN_020094F0(param1[4], param5);
+ struct UnkStruct_02008DEC_sub *r6 = FUN_020094F0(param1[4], param5);
FUN_02009168(param1[4], r6, param2, param3, param4, param0[0]);
FUN_02009DE0(r6);
diff --git a/arm9/src/unk_02021590.c b/arm9/src/unk_02021590.c
new file mode 100644
index 00000000..e6a3d690
--- /dev/null
+++ b/arm9/src/unk_02021590.c
@@ -0,0 +1,212 @@
+#include "global.h"
+#include "heap.h"
+#include "filesystem.h"
+#include "unk_02021590.h"
+#include "unk_0201B8B8.h"
+#include "string_util.h"
+
+static const u8 sGlyphShapes[][2] = {
+ { 0, 1 },
+ { 2, 3 },
+};
+
+static void (*const sAllocators[])(struct FontData *, u32) = {
+ InitFontResources_FromPreloaded,
+ InitFontResources_LazyFromNarc,
+};
+
+static void (*const sDestructors[])(struct FontData *) = {
+ FreeLoadedFontResources_FromPreloaded,
+ FreeLoadedFontResources_LazyFromNarc,
+};
+
+THUMB_FUNC struct FontData *FontData_new(NarcId narcId, s32 fileId, u32 unk2, BOOL unk3, u32 heap_id)
+{
+ struct FontData * ret = (struct FontData *)AllocFromHeap(heap_id, sizeof(struct FontData));
+ if (ret != NULL)
+ {
+ FontData_Init(ret, narcId, fileId, unk3, heap_id);
+ InitFontResources(ret, unk2, heap_id);
+ }
+ return ret;
+}
+
+THUMB_FUNC void FontData_delete(struct FontData * ptr)
+{
+ FreeLoadedFontResources(ptr);
+ FontData_FreeWidthsAndNarc(ptr);
+ FreeToHeap(ptr);
+}
+
+THUMB_FUNC void FontData_ModeSwitch(struct FontData * ptr, u32 a1, u32 heap_id)
+{
+ if (ptr->glyphAccessMode != a1)
+ {
+ FreeLoadedFontResources(ptr);
+ InitFontResources(ptr, a1, heap_id);
+ }
+}
+
+THUMB_FUNC void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id)
+{
+ ptr->narc = NARC_ctor(narcId, heap_id);
+ if (ptr->narc != NULL)
+ {
+ NARC_ReadFromMember(ptr->narc, (u32)fileId, 0, 16, &ptr->gfxHeader);
+ ptr->isFixedWidthFont = unk;
+ if (unk)
+ {
+ ptr->glyphWidths = NULL;
+ ptr->glyphWidthFunc = GetGlyphWidth_FixedWidth;
+ }
+ else
+ {
+ GF_ASSERT(ptr->gfxHeader.widthDataStart != 0);
+ ptr->glyphWidths = AllocFromHeap(heap_id, ptr->gfxHeader.numGlyphs);
+ ptr->glyphWidthFunc = GetGlyphWidth_VariableWidth;
+ NARC_ReadFromMember(ptr->narc, (u32)fileId, ptr->gfxHeader.widthDataStart, ptr->gfxHeader.numGlyphs, ptr->glyphWidths);
+ }
+ GF_ASSERT(ptr->gfxHeader.glyphWidth <= 2 && ptr->gfxHeader.glyphHeight <= 2);
+ ptr->glyphShape = sGlyphShapes[ptr->gfxHeader.glyphWidth - 1][ptr->gfxHeader.glyphHeight - 1];
+ ptr->glyphSize = (u32)(16 * ptr->gfxHeader.glyphWidth * ptr->gfxHeader.glyphHeight);
+ ptr->fileId = (u32)fileId;
+ }
+}
+
+THUMB_FUNC void FontData_FreeWidthsAndNarc(struct FontData * ptr)
+{
+ if (ptr->glyphWidths != NULL)
+ FreeToHeap(ptr->glyphWidths);
+ if (ptr->narc != NULL)
+ NARC_dtor(ptr->narc);
+}
+
+THUMB_FUNC void InitFontResources(struct FontData * ptr, u32 a1, u32 heap_id)
+{
+ ptr->glyphAccessMode = a1;
+ sAllocators[a1](ptr, heap_id);
+}
+
+THUMB_FUNC void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id)
+{
+ u32 r4 = ptr->glyphSize * ptr->gfxHeader.numGlyphs;
+ ptr->narcReadBuf = AllocFromHeap(heap_id, r4);
+ ptr->uncompGlyphFunc = DecompressGlyphTiles_FromPreloaded;
+ NARC_ReadFromMember(ptr->narc, ptr->fileId, ptr->gfxHeader.headerSize, r4, ptr->narcReadBuf);
+}
+
+THUMB_FUNC void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id)
+{
+#pragma unused(heap_id)
+ ptr->uncompGlyphFunc = DecompressGlyphTiles_LazyFromNarc;
+}
+
+THUMB_FUNC void FreeLoadedFontResources(struct FontData * ptr)
+{
+ sDestructors[ptr->glyphAccessMode](ptr);
+}
+
+THUMB_FUNC void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr)
+{
+ FreeToHeap(ptr->narcReadBuf);
+ ptr->narcReadBuf = NULL;
+}
+
+THUMB_FUNC void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr)
+{
+#pragma unused(ptr)
+}
+
+THUMB_FUNC void TryLoadGlyph(struct FontData * ptr, u32 param1, struct UnkStruct_02002C14_sub * ptr2)
+{
+ if (param1 <= ptr->gfxHeader.numGlyphs)
+ ptr->uncompGlyphFunc(ptr, (u16)(param1 - 1), ptr2);
+ else
+ {
+ ptr2->width = 0;
+ ptr2->height = 0;
+ }
+}
+
+THUMB_FUNC void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2)
+{
+ u8 *r4 = &((u8 *)ptr->narcReadBuf)[param1 * ptr->glyphSize];
+ switch (ptr->glyphShape)
+ {
+ case 0:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ break;
+ case 1:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x40));
+ break;
+ case 2:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x20));
+ break;
+ case 3:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x20));
+ DecompressGlyphTile((void *)(r4 + 0x20), (void *)(param2->buf + 0x40));
+ DecompressGlyphTile((void *)(r4 + 0x30), (void *)(param2->buf + 0x60));
+ break;
+ }
+ param2->width = (u8)ptr->glyphWidthFunc(ptr, param1);
+ param2->height = ptr->gfxHeader.fixedHeight;
+}
+
+THUMB_FUNC void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2)
+{
+ NARC_ReadFromMember(ptr->narc, ptr->fileId, ptr->gfxHeader.headerSize + param1 * ptr->glyphSize, ptr->glyphSize, ptr->glyphReadBuf);
+ switch (ptr->glyphShape)
+ {
+ case 0:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ break;
+ case 1:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x40));
+ break;
+ case 2:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x20));
+ break;
+ case 3:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x20));
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x20), (void *)(param2->buf + 0x40));
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x30), (void *)(param2->buf + 0x60));
+ break;
+ }
+ param2->width = (u8)ptr->glyphWidthFunc(ptr, param1);
+ param2->height = ptr->gfxHeader.fixedHeight;
+}
+
+THUMB_FUNC u32 GetStringWidth(struct FontData * ptr, const u16 * str, u32 letterSpacing)
+{
+ u32 width = 0;
+
+ while (*str != EOS)
+ {
+ if (*str == 0xFFFE)
+ {
+ str = MsgArray_SkipControlCode(str);
+ if (*str == EOS)
+ break;
+ }
+ width += ptr->glyphWidthFunc(ptr, (*str) - 1) + letterSpacing;
+ str++;
+ }
+ return width - letterSpacing;
+}
+
+THUMB_FUNC int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1)
+{
+ return ptr->glyphWidths[a1];
+}
+
+THUMB_FUNC int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1)
+{
+#pragma unused(a1)
+ return ptr->gfxHeader.fixedWidth;
+}
diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c
index b12e2d8f..07ddde87 100644
--- a/arm9/src/unk_02021934.c
+++ b/arm9/src/unk_02021934.c
@@ -3,6 +3,7 @@
#include "heap.h"
#include "string_util.h"
#include "unk_0201B8B8.h"
+#include "unk_02021590.h"
#pragma thumb on
@@ -10,7 +11,7 @@
void StrAddChar(struct String * str, u16 val);
-s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6)
+s32 StringGetWidth(struct FontData * r7, const u16 * arr, u32 r6)
{
s32 ret = 0;
u32 r4 = 0;
@@ -29,7 +30,7 @@ s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6)
}
else
{
- r4 += (r6 + r7->unk_70(r7, *arr - 1));
+ r4 += (r6 + r7->glyphWidthFunc(r7, *arr - 1));
arr++;
}
}
@@ -38,7 +39,7 @@ s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6)
return ret;
}
-s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C * r6, const u16 * arr)
+s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr)
{
s32 ret = 0;
while (*arr != 0xFFFF)
@@ -53,7 +54,7 @@ s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C
}
else
{
- ret += r6->unk_70(r6, *arr - 1);
+ ret += r6->glyphWidthFunc(r6, *arr - 1);
arr++;
}
}
diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c
index d9edd94c..e48262b0 100644
--- a/arm9/src/wfc_user_info_warning.c
+++ b/arm9/src/wfc_user_info_warning.c
@@ -10,11 +10,10 @@
#include "string16.h"
#include "text.h"
#include "wfc_user_info_warning.h"
+#include "brightness.h"
+#include "render_window.h"
extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id);
-extern void FUN_0200A274(fx32 brightness, fx32, u32);
-extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id);
-extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num);
extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen);
extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32);
@@ -83,7 +82,7 @@ THUMB_FUNC void ShowWFCUserInfoWarning(u32 heap_id, u32 a1)
SetKeyRepeatTimers(4, 8);
- gMain.unk65 = 0;
+ gMain.screensFlipped = 0;
GX_SwapDisplay();
reg_G2_BLDCNT = 0;
@@ -109,7 +108,7 @@ THUMB_FUNC void ShowWFCUserInfoWarning(u32 heap_id, u32 a1)
FUN_0201BD5C();
AddWindow(bg_config, &window, &sWFCWarningMsgWindowTemplate);
FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
- FUN_0200CCA4(&window, FALSE, 0x01F7, 2);
+ DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2);
ReadMsgDataIntoString(warning_messages_data, 15, warning_message);
AddTextPrinterParameterized(&window, 0, warning_message, 0, 0, 0, 0);
@@ -118,7 +117,7 @@ THUMB_FUNC void ShowWFCUserInfoWarning(u32 heap_id, u32 a1)
GX_BothDispOn();
FUN_0200E394(0);
FUN_0200E394(1);
- FUN_0200A274(0, 0x3F, 3);
+ SetBrightness(0, 0x3F, 3);
while (TRUE)
{