diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/communication_error.c | 1 | ||||
-rw-r--r-- | arm9/src/font.c | 38 | ||||
-rw-r--r-- | arm9/src/render_text.c | 2 | ||||
-rw-r--r-- | arm9/src/script_buffers.c | 27 | ||||
-rw-r--r-- | arm9/src/text.c | 39 | ||||
-rw-r--r-- | arm9/src/unk_02021590.c | 225 | ||||
-rw-r--r-- | arm9/src/unk_02021934.c | 9 |
7 files changed, 284 insertions, 57 deletions
diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 0ea26458..73345af1 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -7,7 +7,6 @@ #include "msgdata/msg.naix" #include "text.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); 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/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/script_buffers.c b/arm9/src/script_buffers.c index d7620db5..550dcab5 100644 --- a/arm9/src/script_buffers.c +++ b/arm9/src/script_buffers.c @@ -14,6 +14,7 @@ #include "unk_02024E64.h" #include "text.h" #include "msgdata/msg.naix" +#include "graphic/font.naix" #pragma thumb on @@ -747,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++) @@ -760,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/text.c b/arm9/src/text.c index e8c76722..64b3587e 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; @@ -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/unk_02021590.c b/arm9/src/unk_02021590.c new file mode 100644 index 00000000..3ab1a38e --- /dev/null +++ b/arm9/src/unk_02021590.c @@ -0,0 +1,225 @@ +#include "global.h"
+#include "heap.h"
+#include "filesystem.h"
+#include "unk_02021590.h"
+#include "unk_0201B8B8.h"
+#include "string_util.h"
+
+void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id);
+void InitFontResources(struct FontData *ptr, u32 a1, u32 heap_id);
+void FontData_FreeWidthsAndNarc(struct FontData * ptr);
+void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id);
+void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id);
+void FreeLoadedFontResources(struct FontData * ptr);
+void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr);
+void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr);
+void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2);
+void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2);
+int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1);
+int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1);
+
+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++; } } |