summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
authorAkira Akashi <rubenru09@aol.com>2021-06-23 00:11:42 +0100
committerGitHub <noreply@github.com>2021-06-23 00:11:42 +0100
commit5e61b9f18d4592bd964e238e2d3f45265f863cea (patch)
tree4d57137cd2097018e31d2db19d72c22f51942834 /arm9/src
parentcec1d428f458997fe3e4c0ac4abf0dc6b36ba699 (diff)
parent66d408a02664eabd153377fe3f4842da0da2d627 (diff)
Merge branch 'master' into 0202A1E0
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/error_message_reset.c2
-rw-r--r--arm9/src/font.c173
-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, 185 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..98885671
--- /dev/null
+++ b/arm9/src/font.c
@@ -0,0 +1,173 @@
+#include "global.h"
+#include "font.h"
+#include "gf_gfx_loader.h"
+#include "render_text.h"
+#include "string16.h"
+#include "text.h"
+#include "graphic/font.naix"
+
+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 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][0], 1, UNK_020ECB54[param0][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);
+}
+
+THUMB_FUNC void FUN_02002CF8(int param0)
+{
+
+ GF_ASSERT(param0 < 4);
+
+ if (UNK_02106FC8->unk84[param0] != NULL)
+ {
+ u32 i;
+ for (i = 0; i < 4; i++)
+ {
+ if (i != param0 && UNK_020ECB54[i][0] == UNK_020ECB54[param0][0] &&
+ UNK_02106FC8->unk94[i] != NULL)
+ {
+ 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;
+ }
+}
+
+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(NARC_GRAPHIC_FONT, NARC_font_narc_0006_NCLR, layer, baseAddr, 0x20, heap_id);
+}
+
+THUMB_FUNC void FUN_02002EEC(u32 layer, u32 baseAddr, u32 heap_id)
+{
+ GfGfxLoader_GXLoadPal(NARC_GRAPHIC_FONT, NARC_font_narc_0007_NCLR, 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)
{