summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/error_message_reset.c2
-rw-r--r--arm9/src/font.c271
-rw-r--r--arm9/src/list_menu.c1
-rw-r--r--arm9/src/main.c3
-rw-r--r--arm9/src/render_text.c12
-rw-r--r--arm9/src/text.c2
-rw-r--r--arm9/src/text_02054590.c3
-rw-r--r--arm9/src/unk_02064E4C.c3
8 files changed, 283 insertions, 14 deletions
diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c
index e0d01bde..d49e8e51 100644
--- a/arm9/src/error_message_reset.c
+++ b/arm9/src/error_message_reset.c
@@ -5,6 +5,7 @@
#include "unk_0202F150.h"
#include "bg_window.h"
#include "PAD_pad.h"
+#include "font.h"
const struct WindowTemplate UNK_020FF49C = {
@@ -43,7 +44,6 @@ 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_02002ED0(u32 param0, u32 param1, u32 param2);
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);
diff --git a/arm9/src/font.c b/arm9/src/font.c
new file mode 100644
index 00000000..acf52448
--- /dev/null
+++ b/arm9/src/font.c
@@ -0,0 +1,271 @@
+#include "global.h"
+#include "font.h"
+#include "gf_gfx_loader.h"
+#include "render_text.h"
+#include "string16.h"
+#include "text.h"
+
+struct UnkStruct_02002C14 *UNK_02106FC8;
+
+struct UnkStruct_02002C14 UNK_02106FCC;
+
+const u16 UNK_020ECB54[] = { 0, 0, 1, 0, 2, 0, 3, 0 };
+
+const struct FontInfo gFontInfos[5] = {
+ { 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
+ { 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
+ { 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
+ { 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+};
+
+extern u32 FUN_02021590(u32, u16, u32, u16, u32);
+extern void FUN_020215E0(u32, u32, u32);
+extern void FUN_020215C8(u32 param0);
+extern void FUN_02021750(void *, u32);
+extern u32 FUN_020218D8(void *, u16 *str, u32);
+
+THUMB_FUNC void FUN_02002C14()
+{
+ UNK_02106FC8 = &UNK_02106FCC;
+
+ for (u32 i = 0; i < 4; i++)
+ {
+ UNK_02106FC8->unk84[i] = NULL;
+ UNK_02106FC8->unk94[i] = NULL;
+ }
+
+ SetFontsPointer(&gFontInfos[0]);
+}
+
+THUMB_FUNC void FUN_02002C50(u32 param0, u32 param1)
+{
+ UNK_02106FC8->unk94[param0] =
+ FUN_02021590(14, UNK_020ECB54[param0 * 2], 1, UNK_020ECB54[param0 * 2 + 1], param1);
+}
+
+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);
+}
+
+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);
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC void FUN_02002CF8(s32 param0)
+{
+ /*
+ param0 is used as a index to a u32[]. The original assembly computes param0<<2 several times
+ in the function where the present attempt compute it once and keep it r6.
+ */
+
+ GF_ASSERT(param0 < 4);
+
+ if (UNK_02106FC8->unk84[param0] != NULL)
+ {
+ u32 i;
+ for (i = 0; i < 4; i++)
+ {
+ if (i == param0)
+ {
+ continue;
+ }
+
+ if (UNK_020ECB54[i * 2] != UNK_020ECB54[param0 * 2])
+ {
+ continue;
+ }
+
+ if (UNK_02106FC8->unk84[i] == NULL)
+ {
+ continue;
+ }
+
+ UNK_02106FC8->unk84[i] = UNK_02106FC8->unk84[param0];
+ break;
+ }
+
+ if (i == 4)
+ {
+ FreeToHeap(UNK_02106FC8->unk84[param0]);
+ UNK_02106FC8->unk84[param0] = NULL;
+ }
+ }
+
+ if (UNK_02106FC8->unk94[param0] != NULL)
+ {
+ FUN_020215C8(UNK_02106FC8->unk94[param0]);
+ UNK_02106FC8->unk94[param0] = NULL;
+ }
+}
+#else
+asm void FUN_02002CF8(s32 param0)
+{
+ // clang-format off
+ push {r3-r7, lr}
+ add r4, r0, #0x0
+ cmp r4, #0x4
+ blt _02002D04
+ bl GF_AssertFail
+_02002D04:
+ ldr r0, =UNK_02106FC8
+ lsl r6, r4, #0x2
+ ldr r7, [r0, #0x0]
+ add r0, r7, r6
+ add r0, #0x84
+ ldr r0, [r0, #0x0]
+ mov r12, r0
+ cmp r0, #0x0
+ beq _02002D68
+ ldr r2, =UNK_020ECB54
+ mov r1, #0x0
+ ldrh r0, [r2, r6]
+ add r3, r7, #0x0
+_02002D1E:
+ cmp r1, r4
+ beq _02002D3E
+ ldrh r5, [r2, #0x0]
+ cmp r5, r0
+ bne _02002D3E
+ add r5, r3, #0x0
+ add r5, #0x94
+ ldr r5, [r5, #0x0]
+ cmp r5, #0x0
+ beq _02002D3E
+ lsl r0, r1, #0x2
+ add r2, r7, r0
+ add r2, #0x84
+ mov r0, r12
+ str r0, [r2, #0x0]
+ b _02002D48
+_02002D3E:
+ add r1, r1, #0x1
+ add r2, r2, #0x4
+ add r3, r3, #0x4
+ cmp r1, #0x4
+ blo _02002D1E
+_02002D48:
+ cmp r1, #0x4
+ bne _02002D68
+ ldr r0, =UNK_02106FC8
+ lsl r5, r4, #0x2
+ ldr r0, [r0, #0x0]
+ add r0, r0, r5
+ add r0, #0x84
+ ldr r0, [r0, #0x0]
+ bl FreeToHeap
+ ldr r0, =UNK_02106FC8
+ mov r1, #0x0
+ ldr r0, [r0, #0x0]
+ add r0, r0, r5
+ add r0, #0x84
+ str r1, [r0, #0x0]
+_02002D68:
+ ldr r0, =UNK_02106FC8
+ ldr r0, [r0, #0x0]
+ add r0, r0, r6
+ add r0, #0x94
+ ldr r0, [r0, #0x0]
+ cmp r0, #0x0
+ beq _02002D88
+ bl FUN_020215C8
+ ldr r0, =UNK_02106FC8
+ mov r2, #0x0
+ ldr r1, [r0, #0x0]
+ lsl r0, r4, #0x2
+ add r0, r1, r0
+ add r0, #0x94
+ str r2, [r0, #0x0]
+_02002D88:
+ pop {r3-r7, pc}
+ // clang-format on
+}
+#endif
+
+THUMB_FUNC struct UnkStruct_02002C14 *FUN_02002D94(u32 param0, u32 param1)
+{
+ FUN_02021750(UNK_02106FC8->unk94[param0], param1);
+
+ return UNK_02106FC8;
+}
+
+THUMB_FUNC u32 FontFunc(u32 fontId, struct TextPrinter *printer)
+{
+ struct TextPrinterSubStruct *subStruct =
+ (struct TextPrinterSubStruct *)(&printer->subStructFields);
+
+ if (subStruct->hasGlyphIdBeenSet == 0)
+ {
+ subStruct->glyphId = fontId;
+ subStruct->hasGlyphIdBeenSet = 1;
+ }
+
+ return RenderText(printer);
+}
+
+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);
+}
+
+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);
+}
+
+THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr)
+{
+ u8 ret = 0;
+ switch (attr)
+ {
+ case 0:
+ ret = gFontInfos[fontId].maxLetterWidth;
+ break;
+ case 1:
+ ret = gFontInfos[fontId].maxLetterHeight;
+ break;
+ case 2:
+ ret = gFontInfos[fontId].letterSpacing;
+ break;
+ case 3:
+ ret = gFontInfos[fontId].lineSpacing;
+ break;
+ case 4:
+ ret = gFontInfos[fontId].unk;
+ break;
+ case 5:
+ ret = gFontInfos[fontId].fgColor;
+ break;
+ case 6:
+ ret = gFontInfos[fontId].bgColor;
+ break;
+ case 7:
+ ret = gFontInfos[fontId].shadowColor;
+ break;
+ }
+
+ return ret;
+}
+
+THUMB_FUNC void FUN_02002ED0(u32 layer, u32 baseAddr, u32 heap_id)
+{
+ GfGfxLoader_GXLoadPal(14, 6, layer, baseAddr, 0x20, heap_id);
+}
+
+THUMB_FUNC void FUN_02002EEC(u32 layer, u32 baseAddr, u32 heap_id)
+{
+ GfGfxLoader_GXLoadPal(14, 7, layer, baseAddr, 0x20, heap_id);
+}
diff --git a/arm9/src/list_menu.c b/arm9/src/list_menu.c
index 033d06f9..b21818d3 100644
--- a/arm9/src/list_menu.c
+++ b/arm9/src/list_menu.c
@@ -3,6 +3,7 @@
#include "main.h"
#include "list_menu.h"
#include "text.h"
+#include "font.h"
void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count);
void ListMenuDrawCursor(struct ListMenu * list);
diff --git a/arm9/src/main.c b/arm9/src/main.c
index 979fb7ca..46f8add7 100644
--- a/arm9/src/main.c
+++ b/arm9/src/main.c
@@ -15,6 +15,7 @@
#include "unk_02031734.h"
#include "unk_0202F150.h"
#include "module_52.h"
+#include "font.h"
FS_EXTERN_OVERLAY(MODULE_52);
FS_EXTERN_OVERLAY(MODULE_63);
@@ -27,8 +28,6 @@ struct UnkStruct_02016FA8 UNK_02016FA8;
extern void FUN_02022294(void);
extern void GF_InitRTCWork(void);
-extern void FUN_02002C14(void);
-extern void FUN_02002C50(int, int);
extern int FUN_020337E8(int);
extern void FUN_02034188(int, int);
extern void FUN_02089D90(int);
diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c
index af0218c8..34777739 100644
--- a/arm9/src/render_text.c
+++ b/arm9/src/render_text.c
@@ -4,6 +4,7 @@
#include "string_util.h"
#include "text.h"
#include "unk_0201B8B8.h"
+#include "font.h"
u16 unk00;
@@ -11,7 +12,6 @@ TextFlags gTextFlags;
const u8 UNK_020ECB50[] = { 0, 1, 2, 1 };
-extern const char *FUN_02002D94(u8, u16);
extern void PlaySE(u16);
THUMB_FUNC u32 RenderText(struct TextPrinter *printer)
@@ -207,16 +207,16 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer)
return 3;
}
- const char *r5 = FUN_02002D94(subStruct->glyphId, currentChar);
+ struct UnkStruct_02002C14 *r5 = FUN_02002D94(subStruct->glyphId, currentChar);
CopyGlyphToWindow(printer->printerTemplate.window,
- r5,
- r5[0x80],
- r5[0x81],
+ r5->buf,
+ r5->width,
+ r5->height,
printer->printerTemplate.currentX,
printer->printerTemplate.currentY,
printer->printerTemplate.unk2);
- printer->printerTemplate.currentX += r5[0x80] + printer->printerTemplate.letterSpacing;
+ printer->printerTemplate.currentX += r5->width + printer->printerTemplate.letterSpacing;
return 0;
case 1:
diff --git a/arm9/src/text.c b/arm9/src/text.c
index 36349b8b..8ca16d55 100644
--- a/arm9/src/text.c
+++ b/arm9/src/text.c
@@ -5,6 +5,7 @@
#include "filesystem.h"
#include "script_buffers.h"
#include "unk_0200CA44.h"
+#include "font.h"
const struct FontInfo *gFonts = NULL;
@@ -19,7 +20,6 @@ extern struct TextPrinter *FUN_0201B6C8(void);
extern void FUN_0201C1A8(struct TextPrinter *printer);
-extern u32 FontFunc(u8 fontId, struct TextPrinter *printer);
extern void * GfGfxLoader_GetCharData(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32);
diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c
index f5527257..3c3d0fed 100644
--- a/arm9/src/text_02054590.c
+++ b/arm9/src/text_02054590.c
@@ -1,11 +1,10 @@
#include "text_02054590.h"
#include "text.h"
#include "bg_window.h"
+#include "font.h"
#include "render_text.h"
extern void FUN_0201BD5C(void);
-extern void FUN_02002ED0(u32 param0, u32 param1, u32 param2);
-extern void FUN_02002EEC(u32 param0, u32 param1, u32 param2);
extern void FUN_0200CD68(
struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5);
diff --git a/arm9/src/unk_02064E4C.c b/arm9/src/unk_02064E4C.c
index 90ff8340..6bcb5d33 100644
--- a/arm9/src/unk_02064E4C.c
+++ b/arm9/src/unk_02064E4C.c
@@ -1,11 +1,10 @@
#include "global.h"
#include "map_header.h"
#include "unk_02064E4C.h"
+#include "font.h"
#pragma thumb on
-// TODO: types of a0 and a2 aren't known yet
-extern void FUN_02002E14(void * a0, struct String * str, void * a2);
void FUN_02064E4C(struct MsgData * msgData, u16 map_sec, struct String * dest)
{