diff options
author | Akira Akashi <rubenru09@aol.com> | 2021-08-16 08:34:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 08:34:55 +0100 |
commit | 168950d7e03129c23ddce331593823d1d48411cf (patch) | |
tree | eb0753d70cca0a010b552b45ab384b1ccb98a180 /arm9/src | |
parent | a6b9c13d97e130e43c774f81c383ad452811ef75 (diff) | |
parent | e1a3782f3cac045ea8f8a21869f17608479c5bdb (diff) |
Merge pull request #447 from PikalaxALT/pikalax_work
unk_02021590
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 | 122 | ||||
-rw-r--r-- | arm9/src/text.c | 39 | ||||
-rw-r--r-- | arm9/src/unk_02021590.c | 212 | ||||
-rw-r--r-- | arm9/src/unk_02021934.c | 9 |
7 files changed, 319 insertions, 104 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 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/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..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++; } } |