diff options
-rw-r--r-- | arm9/asm/unk_02021590.s | 514 | ||||
-rw-r--r-- | arm9/global.inc | 10 | ||||
-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 | ||||
-rw-r--r-- | include/font.h | 15 | ||||
-rw-r--r-- | include/script_buffers.h | 2 | ||||
-rw-r--r-- | include/string16.h | 11 | ||||
-rw-r--r-- | include/unk_02021590.h | 52 |
13 files changed, 355 insertions, 590 deletions
diff --git a/arm9/asm/unk_02021590.s b/arm9/asm/unk_02021590.s deleted file mode 100644 index a648ab1d..00000000 --- a/arm9/asm/unk_02021590.s +++ /dev/null @@ -1,514 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .section .rodata - - .global UNK_020EE668 -UNK_020EE668: ; 0x020EE668 - .byte 0x00, 0x01, 0x02, 0x03 - - .global UNK_020EE66C -UNK_020EE66C: ; 0x020EE66C - .word FUN_020216EC, FUN_0202171C - - .global UNK_020EE674 -UNK_020EE674: ; 0x020EE674 - .word FUN_0202173C, FUN_0202174C - - .text - - thumb_func_start FUN_02021590 -FUN_02021590: ; 0x02021590 - push {r3-r7, lr} - sub sp, #0x8 - add r5, r0, #0x0 - add r6, r1, #0x0 - ldr r0, [sp, #0x20] - mov r1, #0x78 - add r7, r2, #0x0 - str r3, [sp, #0x4] - bl AllocFromHeap - add r4, r0, #0x0 - beq _020215C0 - ldr r1, [sp, #0x20] - ldr r3, [sp, #0x4] - str r1, [sp, #0x0] - add r1, r5, #0x0 - add r2, r6, #0x0 - bl FUN_02021600 - ldr r2, [sp, #0x20] - add r0, r4, #0x0 - add r1, r7, #0x0 - bl FUN_020216D4 -_020215C0: - add r0, r4, #0x0 - add sp, #0x8 - pop {r3-r7, pc} - .balign 4 - - thumb_func_start FUN_020215C8 -FUN_020215C8: ; 0x020215C8 - push {r4, lr} - add r4, r0, #0x0 - bl FUN_02021728 - add r0, r4, #0x0 - bl FUN_020216B8 - add r0, r4, #0x0 - bl FreeToHeap - pop {r4, pc} - .balign 4 - - thumb_func_start FUN_020215E0 -FUN_020215E0: ; 0x020215E0 - push {r4-r6, lr} - add r5, r0, #0x0 - add r4, r1, #0x0 - ldr r1, [r5, #0x0] - add r6, r2, #0x0 - cmp r1, r4 - beq _020215FC - bl FUN_02021728 - add r0, r5, #0x0 - add r1, r4, #0x0 - add r2, r6, #0x0 - bl FUN_020216D4 -_020215FC: - pop {r4-r6, pc} - .balign 4 - - thumb_func_start FUN_02021600 -FUN_02021600: ; 0x02021600 - push {r3-r6, lr} - sub sp, #0x4 - add r5, r0, #0x0 - add r0, r1, #0x0 - ldr r1, [sp, #0x18] - add r4, r2, #0x0 - add r6, r3, #0x0 - bl NARC_ctor - str r0, [r5, #0x54] - cmp r0, #0x0 - beq _020216A6 - add r1, r5, #0x0 - add r1, #0x5c - str r1, [sp, #0x0] - add r1, r4, #0x0 - mov r2, #0x0 - mov r3, #0x10 - bl NARC_ReadFromMember - str r6, [r5, #0x6c] - cmp r6, #0x0 - beq _02021638 - mov r0, #0x0 - str r0, [r5, #0x74] - ldr r0, _020216AC ; =FUN_0202192C - str r0, [r5, #0x70] - b _02021660 -_02021638: - ldr r0, [r5, #0x60] - cmp r0, #0x0 - bne _02021642 - bl GF_AssertFail -_02021642: - ldr r0, [sp, #0x18] - ldr r1, [r5, #0x64] - bl AllocFromHeap - str r0, [r5, #0x74] - ldr r0, _020216B0 ; =FUN_02021924 - add r1, r4, #0x0 - str r0, [r5, #0x70] - ldr r0, [r5, #0x74] - str r0, [sp, #0x0] - ldr r0, [r5, #0x54] - ldr r2, [r5, #0x60] - ldr r3, [r5, #0x64] - bl NARC_ReadFromMember -_02021660: - add r0, r5, #0x0 - add r0, #0x6a - ldrb r0, [r0, #0x0] - cmp r0, #0x2 - bhi _02021674 - add r0, r5, #0x0 - add r0, #0x6b - ldrb r0, [r0, #0x0] - cmp r0, #0x2 - bls _02021678 -_02021674: - bl GF_AssertFail -_02021678: - add r0, r5, #0x0 - add r0, #0x6a - ldrb r0, [r0, #0x0] - ldr r2, _020216B4 ; =UNK_020EE668 - sub r0, r0, #0x1 - lsl r3, r0, #0x1 - add r0, r5, #0x0 - add r0, #0x6b - ldrb r0, [r0, #0x0] - sub r1, r0, #0x1 - add r0, r2, r3 - ldrb r0, [r1, r0] - str r0, [r5, #0x8] - add r0, r5, #0x0 - add r0, #0x6b - ldrb r1, [r0, #0x0] - add r0, r5, #0x0 - add r0, #0x6a - ldrb r0, [r0, #0x0] - lsl r0, r0, #0x4 - mul r0, r1 - str r0, [r5, #0xc] - str r4, [r5, #0x58] -_020216A6: - add sp, #0x4 - pop {r3-r6, pc} - nop -_020216AC: .word FUN_0202192C -_020216B0: .word FUN_02021924 -_020216B4: .word UNK_020EE668 - - thumb_func_start FUN_020216B8 -FUN_020216B8: ; 0x020216B8 - push {r4, lr} - add r4, r0, #0x0 - ldr r0, [r4, #0x74] - cmp r0, #0x0 - beq _020216C6 - bl FreeToHeap -_020216C6: - ldr r0, [r4, #0x54] - cmp r0, #0x0 - beq _020216D0 - bl NARC_dtor -_020216D0: - pop {r4, pc} - .balign 4 - - thumb_func_start FUN_020216D4 -FUN_020216D4: ; 0x020216D4 - push {r3, lr} - add r3, r1, #0x0 - add r1, r2, #0x0 - str r3, [r0, #0x0] - ldr r2, _020216E8 ; =UNK_020EE66C - lsl r3, r3, #0x2 - ldr r2, [r2, r3] - blx r2 - pop {r3, pc} - nop -_020216E8: .word UNK_020EE66C - - thumb_func_start FUN_020216EC -FUN_020216EC: ; 0x020216EC - push {r3-r5, lr} - add r5, r0, #0x0 - ldr r2, [r5, #0xc] - ldr r0, [r5, #0x64] - add r4, r2, #0x0 - mul r4, r0 - add r0, r1, #0x0 - add r1, r4, #0x0 - bl AllocFromHeap - str r0, [r5, #0x10] - ldr r0, _02021718 ; =FUN_02021774 - add r3, r4, #0x0 - str r0, [r5, #0x4] - ldr r0, [r5, #0x10] - str r0, [sp, #0x0] - ldr r0, [r5, #0x54] - ldr r1, [r5, #0x58] - ldr r2, [r5, #0x5c] - bl NARC_ReadFromMember - pop {r3-r5, pc} - .balign 4 -_02021718: .word FUN_02021774 - - thumb_func_start FUN_0202171C -FUN_0202171C: ; 0x0202171C - ldr r1, _02021724 ; =FUN_0202181C - str r1, [r0, #0x4] - bx lr - nop -_02021724: .word FUN_0202181C - - thumb_func_start FUN_02021728 -FUN_02021728: ; 0x02021728 - push {r3, lr} - ldr r1, [r0, #0x0] - lsl r2, r1, #0x2 - ldr r1, _02021738 ; =UNK_020EE674 - ldr r1, [r1, r2] - blx r1 - pop {r3, pc} - nop -_02021738: .word UNK_020EE674 - - thumb_func_start FUN_0202173C -FUN_0202173C: ; 0x0202173C - push {r4, lr} - add r4, r0, #0x0 - ldr r0, [r4, #0x10] - bl FreeToHeap - mov r0, #0x0 - str r0, [r4, #0x10] - pop {r4, pc} - - thumb_func_start FUN_0202174C -FUN_0202174C: ; 0x0202174C - bx lr - .balign 4 - - thumb_func_start FUN_02021750 -FUN_02021750: ; 0x02021750 - push {r3, lr} - ldr r3, [r0, #0x64] - cmp r1, r3 - bhi _02021764 - sub r1, r1, #0x1 - lsl r1, r1, #0x10 - ldr r3, [r0, #0x4] - lsr r1, r1, #0x10 - blx r3 - pop {r3, pc} -_02021764: - add r0, r2, #0x0 - mov r1, #0x0 - add r0, #0x80 - strb r1, [r0, #0x0] - add r2, #0x81 - strb r1, [r2, #0x0] - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_02021774 -FUN_02021774: ; 0x02021774 - push {r3-r7, lr} - str r1, [sp, #0x0] - add r7, r0, #0x0 - ldr r0, [sp, #0x0] - ldr r1, [r7, #0xc] - add r5, r0, #0x0 - ldr r0, [r7, #0x8] - add r6, r2, #0x0 - mul r5, r1 - ldr r4, [r7, #0x10] - cmp r0, #0x3 - bhi _02021802 - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #0x6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_02021798: ; jump table (using 16-bit offset) - .short _020217A0 - _02021798 - 2; case 0 - .short _020217AA - _02021798 - 2; case 1 - .short _020217C0 - _02021798 - 2; case 2 - .short _020217D6 - _02021798 - 2; case 3 -_020217A0: - add r0, r4, r5 - add r1, r6, #0x0 - bl DecompressGlyphTile - b _02021802 -_020217AA: - add r0, r4, r5 - add r1, r6, #0x0 - bl DecompressGlyphTile - add r0, r4, r5 - add r1, r6, #0x0 - add r0, #0x10 - add r1, #0x40 - bl DecompressGlyphTile - b _02021802 -_020217C0: - add r0, r4, r5 - add r1, r6, #0x0 - bl DecompressGlyphTile - add r0, r4, r5 - add r1, r6, #0x0 - add r0, #0x10 - add r1, #0x20 - bl DecompressGlyphTile - b _02021802 -_020217D6: - add r0, r4, r5 - add r1, r6, #0x0 - bl DecompressGlyphTile - add r0, r4, r5 - add r1, r6, #0x0 - add r0, #0x10 - add r1, #0x20 - bl DecompressGlyphTile - add r0, r4, r5 - add r1, r6, #0x0 - add r0, #0x20 - add r1, #0x40 - bl DecompressGlyphTile - add r0, r4, r5 - add r1, r6, #0x0 - add r0, #0x30 - add r1, #0x60 - bl DecompressGlyphTile -_02021802: - ldr r1, [sp, #0x0] - ldr r2, [r7, #0x70] - add r0, r7, #0x0 - blx r2 - add r1, r6, #0x0 - add r1, #0x80 - add r7, #0x69 - strb r0, [r1, #0x0] - ldrb r0, [r7, #0x0] - add r6, #0x81 - strb r0, [r6, #0x0] - pop {r3-r7, pc} - .balign 4 - - thumb_func_start FUN_0202181C -FUN_0202181C: ; 0x0202181C - push {r3-r7, lr} - add r4, r0, #0x0 - ldr r6, [r4, #0xc] - add r0, #0x14 - str r0, [sp, #0x0] - add r7, r1, #0x0 - add r5, r2, #0x0 - add r2, r7, #0x0 - ldr r3, [r4, #0x5c] - mul r2, r6 - add r2, r3, r2 - ldr r0, [r4, #0x54] - ldr r1, [r4, #0x58] - add r3, r6, #0x0 - bl NARC_ReadFromMember - ldr r0, [r4, #0x8] - cmp r0, #0x3 - bhi _020218C0 - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #0x6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_0202184E: ; jump table (using 16-bit offset) - .short _02021856 - _0202184E - 2; case 0 - .short _02021862 - _0202184E - 2; case 1 - .short _0202187A - _0202184E - 2; case 2 - .short _02021892 - _0202184E - 2; case 3 -_02021856: - add r0, r4, #0x0 - add r0, #0x14 - add r1, r5, #0x0 - bl DecompressGlyphTile - b _020218C0 -_02021862: - add r0, r4, #0x0 - add r0, #0x14 - add r1, r5, #0x0 - bl DecompressGlyphTile - add r0, r4, #0x0 - add r1, r5, #0x0 - add r0, #0x24 - add r1, #0x40 - bl DecompressGlyphTile - b _020218C0 -_0202187A: - add r0, r4, #0x0 - add r0, #0x14 - add r1, r5, #0x0 - bl DecompressGlyphTile - add r0, r4, #0x0 - add r1, r5, #0x0 - add r0, #0x24 - add r1, #0x20 - bl DecompressGlyphTile - b _020218C0 -_02021892: - add r0, r4, #0x0 - add r0, #0x14 - add r1, r5, #0x0 - bl DecompressGlyphTile - add r0, r4, #0x0 - add r1, r5, #0x0 - add r0, #0x24 - add r1, #0x20 - bl DecompressGlyphTile - add r0, r4, #0x0 - add r1, r5, #0x0 - add r0, #0x34 - add r1, #0x40 - bl DecompressGlyphTile - add r0, r4, #0x0 - add r1, r5, #0x0 - add r0, #0x44 - add r1, #0x60 - bl DecompressGlyphTile -_020218C0: - ldr r2, [r4, #0x70] - add r0, r4, #0x0 - add r1, r7, #0x0 - blx r2 - add r1, r5, #0x0 - add r1, #0x80 - add r4, #0x69 - strb r0, [r1, #0x0] - ldrb r0, [r4, #0x0] - add r5, #0x81 - strb r0, [r5, #0x0] - pop {r3-r7, pc} - - thumb_func_start FUN_020218D8 -FUN_020218D8: ; 0x020218D8 - push {r3-r7, lr} - add r4, r1, #0x0 - ldrh r1, [r4, #0x0] - add r5, r0, #0x0 - ldr r0, _0202191C ; =0x0000FFFF - add r7, r2, #0x0 - mov r6, #0x0 - cmp r1, r0 - beq _02021916 -_020218EA: - ldr r0, _02021920 ; =0x0000FFFE - cmp r1, r0 - bne _02021900 - add r0, r4, #0x0 - bl MsgArray_SkipControlCode - add r4, r0, #0x0 - ldrh r1, [r4, #0x0] - ldr r0, _0202191C ; =0x0000FFFF - cmp r1, r0 - beq _02021916 -_02021900: - ldr r2, [r5, #0x70] - add r0, r5, #0x0 - sub r1, r1, #0x1 - blx r2 - add r4, r4, #0x2 - add r0, r7, r0 - add r6, r6, r0 - ldrh r1, [r4, #0x0] - ldr r0, _0202191C ; =0x0000FFFF - cmp r1, r0 - bne _020218EA -_02021916: - sub r0, r6, r7 - pop {r3-r7, pc} - nop -_0202191C: .word 0x0000FFFF -_02021920: .word 0x0000FFFE - - thumb_func_start FUN_02021924 -FUN_02021924: ; 0x02021924 - ldr r0, [r0, #0x74] - ldrb r0, [r0, r1] - bx lr - .balign 4 - - thumb_func_start FUN_0202192C -FUN_0202192C: ; 0x0202192C - add r0, #0x68 - ldrb r0, [r0, #0x0] - bx lr - .balign 4 diff --git a/arm9/global.inc b/arm9/global.inc index 8658cca9..2cf762ee 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -1381,11 +1381,11 @@ .extern FUN_0202135C .extern FUN_02021390 .extern FUN_020213A0 -.extern FUN_02021590 -.extern FUN_020215C8 -.extern FUN_020215E0 -.extern FUN_02021750 -.extern FUN_020218D8 +.extern FontData_new +.extern FontData_delete +.extern FontData_ModeSwitch +.extern TryLoadGlyph +.extern GetStringWidth .extern StringGetWidth .extern StringGetWidth_SingleLine_HandleClearToControlCode .extern String_ctor 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++; } } diff --git a/include/font.h b/include/font.h index 963e36bc..3c0f4267 100644 --- a/include/font.h +++ b/include/font.h @@ -4,28 +4,33 @@ #include "global.h" #include "text.h" -struct UnkStruct_02002C14 +struct UnkStruct_02002C14_sub { const char buf[0x80]; u8 width; u8 height; +}; + +struct UnkStruct_02002C14 +{ + struct UnkStruct_02002C14_sub unk00; void *unk84[4]; - struct UnkStruct_0202199C *unk94[4]; + struct FontData *unk94[4]; }; extern struct UnkStruct_02002C14 *UNK_02106FC8; void FUN_02002C14(); -void FUN_02002C50(u32 param0, u32 param1); +void FUN_02002C50(u32 font_id, u32 heap_id); void FUN_02002C84(s32 param0, u32 param1); void FUN_02002CC0(s32 param0); void FUN_02002CF8(int param0); -struct UnkStruct_02002C14 *FUN_02002D94(u32 param0, u32 param1); +struct UnkStruct_02002C14_sub *FUN_02002D94(u32 param0, u32 param1); u32 FontFunc(u32 fontId, struct TextPrinter *printer); u32 FUN_02002DE0(u32 param0, u16 *str, u32 param2); u32 FUN_02002E14(u32 param0, struct String *str, u32 param2); s32 GetFontAttribute(u8 fontId, s32 attr); -void FUN_02002ED0(u32 layer, u32 baseAddr, u32 heap_id); +void FUN_02002ED0(enum GFBgLayer layer, u32 baseAddr, u32 heap_id); void FUN_02002EEC(u32 layer, u32 baseAddr, u32 heap_id); s32 FUN_02002F08(u32 param0, struct String *str, u32 param2); u32 FUN_02002F40(u32 param0, struct String *str, u32 param2, u32 param3); diff --git a/include/script_buffers.h b/include/script_buffers.h index b9f0e268..e5c39291 100644 --- a/include/script_buffers.h +++ b/include/script_buffers.h @@ -104,7 +104,7 @@ void BufferMonthNameAbbr(struct ScrStrBufs * mgr, u32 idx, u32 month); void ScrStrBufs_UpperFirstChar(struct ScrStrBufs * mgr, u32 idx); void StringExpandPlaceholders(struct ScrStrBufs * mgr, struct String * dest, struct String * src); void ScrStrBufs_ResetBuffers(struct ScrStrBufs * mgr); -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); void MessagePrinter_delete(struct UnkStruct_0200B870 * a0); void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, struct Window * a2, int a3, int a4); void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y); diff --git a/include/string16.h b/include/string16.h index 69ea4e30..f42ff918 100644 --- a/include/string16.h +++ b/include/string16.h @@ -2,6 +2,7 @@ #define POKEDIAMOND_STRING16_H #include "string_util.h" +#include "unk_02021590.h" struct String { @@ -12,12 +13,6 @@ struct String u8 padding[2]; }; -struct UnkStruct_0202199C -{ - u8 filler_00[0x70]; - int (*unk_70)(struct UnkStruct_0202199C *, int); -}; - #define STR16_MAGIC 0xB6F8D2EC struct String * String_ctor(u32 count, u32 heap_id); @@ -25,8 +20,8 @@ BOOL StringCompare(struct String *, struct String *); void CopyU16ArrayToStringN(struct String *, u16 *, u32); // copy void StringSetEmpty(struct String *); // set empty struct String * StringDup(struct String *, u32 heap_id); -s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6); -s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C * r6, const u16 * arr); +s32 StringGetWidth(struct FontData * r7, const u16 * arr, u32 r6); +s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr); void String_dtor(struct String * str); void StringCopy(struct String * dest, struct String * src); void String16_FormatInteger(struct String * str, int num, u32 ndigits, int strConvMode, BOOL whichCharset); diff --git a/include/unk_02021590.h b/include/unk_02021590.h new file mode 100644 index 00000000..6ed73bb8 --- /dev/null +++ b/include/unk_02021590.h @@ -0,0 +1,52 @@ +#ifndef POKEDIAMOND_UNK_02021590_H
+#define POKEDIAMOND_UNK_02021590_H
+
+#include "filesystem.h"
+#include "font.h"
+
+struct FontGraphicHeader
+{
+ u32 headerSize;
+ u32 widthDataStart;
+ u32 numGlyphs;
+ u8 fixedWidth;
+ u8 fixedHeight;
+ u8 glyphWidth;
+ u8 glyphHeight;
+};
+
+struct FontData
+{
+ u32 glyphAccessMode;
+ void (*uncompGlyphFunc)(struct FontData *, u16, struct UnkStruct_02002C14_sub *);
+ u32 glyphShape;
+ u32 glyphSize;
+ void * narcReadBuf;
+ u8 glyphReadBuf[0x40];
+ NARC * narc;
+ u32 fileId;
+ struct FontGraphicHeader gfxHeader;
+ BOOL isFixedWidthFont;
+ int (*glyphWidthFunc)(struct FontData *, int);
+ u8 * glyphWidths;
+};
+
+struct FontData *FontData_new(NarcId narcId, s32 fileId, u32 unk2, BOOL unk3, u32 heap_id);
+void FontData_delete(struct FontData * ptr);
+void FontData_ModeSwitch(struct FontData * ptr, u32 a1, u32 heap_id);
+void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id);
+void FontData_FreeWidthsAndNarc(struct FontData * ptr);
+void InitFontResources(struct FontData * ptr, u32 a1, u32 heap_id);
+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 TryLoadGlyph(struct FontData * ptr, u32 param1, struct UnkStruct_02002C14_sub * ptr2);
+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);
+u32 GetStringWidth(struct FontData * ptr, const u16 * str, u32 letterSpacing);
+int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1);
+int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1);
+
+#endif //POKEDIAMOND_UNK_02021590_H
|