diff --git a/include/functions.h b/include/functions.h index 4fa85953ee..dbc09bee48 100644 --- a/include/functions.h +++ b/include/functions.h @@ -825,7 +825,7 @@ void func_800B90F4(void); // func_800B90F4 void func_800B9120(ActorContext* actCtxt); // func_800B9120 void Actor_Init(GlobalContext* ctxt, ActorContext* actCtxt, UNK_TYPE4 uParm3); // func_800B9170 void func_800B9334(GlobalContext* ctxt, ActorContext* actCtxt); // func_800B9334 -void func_800B948C(void); // func_800B948C +Actor* func_800B948C(GlobalContext* ctxt); // func_800B948C void func_800B9780(GlobalContext* ctxt, ActorContext* actCtxt); // func_800B9780 void Actor_DrawActor(GlobalContext* ctxt, Actor* actor); // func_800B9A04 void func_800B9D1C(Actor* actor); // func_800B9D1C @@ -1711,9 +1711,9 @@ void func_800F4A10(GlobalContext* ctxt); // func_800F4A10 void func_800F4C0C(GlobalContext* ctxt); // func_800F4C0C void func_800F4E20(GlobalContext* ctxt); // func_800F4E20 void func_800F4F28(GlobalContext* ctxt); // func_800F4F28 -void Kanfont_Nop800F4F40(void); // func_800F4F40 -void Kanfont_LoadAsciiChar(GlobalContext* ctxt, s8 character, s32 iParm3); // func_800F4F54 -void Kanfont_LoadMessageBoxEnd(Font* font, u32 type); // func_800F4FC0 +void Kanfont_Nop800F4F40(GlobalContext* ctxt, UNK_TYPE4 param_2, UNK_TYPE4 param_3); // func_800F4F40 +void Kanfont_LoadAsciiChar(GlobalContext* ctxt, u8 character, s32 iParm3); // func_800F4F54 +void Kanfont_LoadMessageBoxEnd(Font* font, u16 type); // func_800F4FC0 void Kanfont_LoadOrderedFont(Font* font); // func_800F5004 void func_800F5090(void); // func_800F5090 void func_800F50D4(void); // func_800F50D4 diff --git a/include/structs.h b/include/structs.h index 7883383624..e68d9a2c54 100644 --- a/include/structs.h +++ b/include/structs.h @@ -304,8 +304,8 @@ typedef struct { // Font textures are loaded into here typedef struct { -/* 0x0000 */ u8 unk0[128][120][2]; -/* 0x7800 */ u8 unk7800[128][93]; +/* 0x0000 */ u8 unk0[2][120][128]; +/* 0x7800 */ u8 unk7800[93][128]; } Font; typedef struct { @@ -1168,7 +1168,9 @@ typedef struct { typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; -/* 0x0A7E8 */ UNK_TYPE1 padA7E8[30492]; +/* 0x0A7E8 */ UNK_TYPE1 padA7E8[30472]; +/* 0x11EF0 */ u8 unk11EF0; +/* 0x11EF1 */ UNK_TYPE1 pad11EF1[19]; /* 0x11F04 */ u16 unk11F04; /* 0x11F06 */ UNK_TYPE1 pad11F06[28]; /* 0x11F22 */ u8 unk11F22; @@ -1942,7 +1944,7 @@ struct GlobalContext { /* 0x187FC */ z_Matrix unk187FC; /* 0x1883C */ UNK_TYPE1 pad1883C[8]; /* 0x18844 */ u8 unk18844; -/* 0x18845 */ UNK_TYPE1 pad18845[1]; +/* 0x18845 */ u8 unk18845; /* 0x18846 */ u16 sceneNumActorsToLoad; /* 0x18848 */ u8 numRooms; /* 0x18849 */ UNK_TYPE1 pad18849[3]; diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index c543ce287d..99f5933e7b 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -239,7 +239,7 @@ SECTIONS build/asm/z_horse.o(.text) build/asm/z_jpeg.o(.text) build/asm/code_0x800F4A10.o(.text) - build/asm/z_kanfont.o(.text) + build/src/code/z_kanfont.o(.text) build/asm/z_kankyo.o(.text) build/src/code/z_lib.o(.text) build/asm/z_lifemeter.o(.text) diff --git a/src/code/code_0x800F4F40.c.ignore b/src/code/code_0x800F4F40.c.ignore deleted file mode 100644 index c28a46b289..0000000000 --- a/src/code/code_0x800F4F40.c.ignore +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -void func_800F4F40(UNK_TYPE a0, UNK_TYPE a1, UNK_TYPE a2) { - -} - -void func_800F4F54(s800F4F54* a0, u8 a1, UNK_TYPE a2) { - u32 arg0 = (u32)a0 + a0->unk167F8 * (15 * 1024) + a2 + 19056; - u32 arg1 = ((a1 * 128) - 4096) + (u32)&D_00ACC000; - func_80080C90(arg0, arg1, 128); -} - -void func_800F4FC0(UNK_TYPE a0, u16 a1) { - func_80080C90(a0 + 30720, (a1 * 128 + 20480) + (u32)&D_00AC4000, 128); -} - -void func_800F5004(UNK_TYPE a0) { - u8* s0 = D_801BDB30; - u32 s1 = a0 + 30848; - u32 v1; - - while (1) { - v1 = (*s0)*128; - if (*s0 == 0) { - v1 = 0; - } - func_80080C90(s1, v1 + (u32)&D_00AC4000, 128); - s1 += 128; - if (*s0 == 140) break; - s0++; - } -} diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c new file mode 100644 index 0000000000..93a31c097f --- /dev/null +++ b/src/code/z_kanfont.c @@ -0,0 +1,31 @@ +#include +#include + +void Kanfont_Nop800F4F40(GlobalContext* ctxt, UNK_TYPE param_2, UNK_TYPE param_3) {} + +void Kanfont_LoadAsciiChar(GlobalContext* ctxt, u8 character, s32 iParm3) { + Dmamgr_SendRequestAndWait((u32)ctxt->msgContext.font.unk0[(ctxt->msgContext).unk11EF0] + iParm3, + (u32)&nes_font_static_vrom_start + character * 0x80 - 0x1000, + 0x80); +} + +void Kanfont_LoadMessageBoxEnd(Font* font, u16 type) { + Dmamgr_SendRequestAndWait((u32)font->unk7800, type * 0x80 + (u32)&message_static_vrom_start + 0x5000, 0x80); +} + +void Kanfont_LoadOrderedFont(Font* font) { + u32 loadOffset; + s32 codePointIndex = 0; + u32 writeLocation; + + while (1) { + writeLocation = (u32)&font->unk7800[codePointIndex + 1]; + loadOffset = kanfontOrdering[codePointIndex] * 128; + if (kanfontOrdering[codePointIndex] == 0) { + loadOffset = 0; + } + Dmamgr_SendRequestAndWait(writeLocation, (u32)&nes_font_static_vrom_start + loadOffset, 0x80); + if (kanfontOrdering[codePointIndex] == 140) break; + codePointIndex++; + } +} diff --git a/tables/functions.py b/tables/functions.py index ed428041da..8e5342df1e 100644 --- a/tables/functions.py +++ b/tables/functions.py @@ -814,7 +814,7 @@ 0x800B9120:("func_800B9120","void","ActorContext* actCtxt"), 0x800B9170:("Actor_Init","void","GlobalContext* ctxt, ActorContext* actCtxt, UNK_TYPE4 uParm3"), 0x800B9334:("func_800B9334","void","GlobalContext* ctxt, ActorContext* actCtxt"), - 0x800B948C:("func_800B948C","void","void"), + 0x800B948C:("func_800B948C","Actor*","GlobalContext* ctxt"), 0x800B9780:("func_800B9780","void","GlobalContext* ctxt, ActorContext* actCtxt"), 0x800B9A04:("Actor_DrawActor","void","GlobalContext* ctxt, Actor* actor"), 0x800B9D1C:("func_800B9D1C","void","Actor* actor"), @@ -1700,9 +1700,9 @@ 0x800F4C0C:("func_800F4C0C","void","GlobalContext* ctxt"), 0x800F4E20:("func_800F4E20","void","GlobalContext* ctxt"), 0x800F4F28:("func_800F4F28","void","GlobalContext* ctxt"), - 0x800F4F40:("Kanfont_Nop800F4F40","void","void"), - 0x800F4F54:("Kanfont_LoadAsciiChar","void","GlobalContext* ctxt, s8 character, s32 iParm3"), - 0x800F4FC0:("Kanfont_LoadMessageBoxEnd","void","Font* font, u32 type"), + 0x800F4F40:("Kanfont_Nop800F4F40","void","GlobalContext* ctxt, UNK_TYPE4 param_2, UNK_TYPE4 param_3"), + 0x800F4F54:("Kanfont_LoadAsciiChar","void","GlobalContext* ctxt, u8 character, s32 iParm3"), + 0x800F4FC0:("Kanfont_LoadMessageBoxEnd","void","Font* font, u16 type"), 0x800F5004:("Kanfont_LoadOrderedFont","void","Font* font"), 0x800F5090:("func_800F5090","void","void"), 0x800F50D4:("func_800F50D4","void","void"),