summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2020-10-12 22:42:17 +0100
committerGitHub <noreply@github.com>2020-10-12 17:42:17 -0400
commitfff616d2be4566e28a08fae7d2ab1b51ce455f9b (patch)
tree11b5b6176a7f5518e73eec5c2f660bebca7ccac5 /src
parented719f3da03afcfd5b4ebb47506d63564073a066 (diff)
Decompile z_kanfont (#443)
* Decompile z_kanfont.c * Cleanups * off -> offset * Kanfont -> Font , Keep so-far unused Font fields as padding, Remove MessageData sub-struct
Diffstat (limited to 'src')
-rw-r--r--src/code/z_construct.c2
-rw-r--r--src/code/z_kaleido_setup.c3
-rw-r--r--src/code/z_kanfont.c53
-rw-r--r--src/overlays/actors/ovl_En_Mag/z_en_mag.c16
-rw-r--r--src/overlays/actors/ovl_En_Mag/z_en_mag.h2
5 files changed, 62 insertions, 14 deletions
diff --git a/src/code/z_construct.c b/src/code/z_construct.c
index 15a8054e7..3d5a9337b 100644
--- a/src/code/z_construct.c
+++ b/src/code/z_construct.c
@@ -199,7 +199,7 @@ void func_80110F68(GlobalContext* globalCtx) {
__assert("message->fukidashiSegment != NULL", "../z_construct.c", 352);
}
- func_8006EF10(&globalCtx->msgCtx.unk_128);
+ Font_LoadOrderedFont(&globalCtx->msgCtx.font);
YREG(31) = 0;
}
diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c
index 10140553e..c2fc1b757 100644
--- a/src/code/z_kaleido_setup.c
+++ b/src/code/z_kaleido_setup.c
@@ -141,6 +141,3 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) {
void KaleidoSetup_Destroy(GlobalContext* globalCtx) {
}
-
-void func_8006EE50(UNK_PTR arg0, s16 arg1, s16 arg2) {
-}
diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c
index 272c235f3..104d6be42 100644
--- a/src/code/z_kanfont.c
+++ b/src/code/z_kanfont.c
@@ -1,7 +1,54 @@
#include "global.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kanfont/func_8006EE60.s")
+// To be moved to message_data_static header
+#define MESSAGE_NEWLINE '\x01'
+#define MESSAGE_END '\x02'
+// message_data_static symbols
+extern const char D_07000000[]; // start of file
+extern const char D_070380D4[]; // charset message (id 0xFFFC)
+extern const char D_0703811C[]; // end marker of last message
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kanfont/func_8006EEBC.s")
+void func_8006EE50(Font* font, s16 arg1, s16 arg2) {
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kanfont/func_8006EF10.s")
+void Font_LoadChar(u32 offset, u8 character, u16 codePointIndex) {
+ DmaMgr_SendRequest1(((u32)offset + codePointIndex) + 8,
+ &_nes_font_staticSegmentRomStart[character * FONT_CHAR_TEX_SIZE], FONT_CHAR_TEX_SIZE,
+ "../z_kanfont.c", 93);
+}
+
+void Font_LoadMessageBoxEndIcon(Font* font, u16 icon) {
+ DmaMgr_SendRequest1(font->iconBuf, &_message_staticSegmentRomStart[4 * 0x1000 + icon * FONT_CHAR_TEX_SIZE],
+ FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 100);
+}
+
+void Font_LoadOrderedFont(Font* font) {
+ s32 len;
+ s32 jj;
+ s32 fontStatic;
+ u32 fontBuf;
+ s32 codePointIndex;
+ s32 fontBufIndex;
+ s32 offset;
+
+ font->msgOffset = D_070380D4 - D_07000000;
+ len = font->msgLength = D_0703811C - D_070380D4;
+ DmaMgr_SendRequest1(font->msgBuf, &_nes_message_data_staticSegmentRomStart[font->msgOffset], len,
+ "../z_kanfont.c", 122);
+ osSyncPrintf("msg_data=%x, msg_data0=%x jj=%x\n", font->msgOffset, font->msgLength, jj = len);
+ len = jj;
+ for (fontBufIndex = 0, codePointIndex = 0; font->msgBuf[codePointIndex] != MESSAGE_END; codePointIndex++) {
+ if (codePointIndex > len) {
+ osSyncPrintf("ERROR!! エラー!!! error───!!!!\n");
+ return;
+ }
+ if (font->msgBuf[codePointIndex] != MESSAGE_NEWLINE) {
+ fontBuf = font->fontBuf + fontBufIndex * 8;
+ fontStatic = _nes_font_staticSegmentRomStart;
+ osSyncPrintf("nes_mes_buf[%d]=%d\n", codePointIndex, font->msgBuf[codePointIndex]);
+ offset = (font->msgBuf[codePointIndex] - '\x20') * FONT_CHAR_TEX_SIZE;
+ DmaMgr_SendRequest1(fontBuf, fontStatic + offset, FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134);
+ fontBufIndex += 0x10;
+ }
+ }
+}
diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c
index 0261c146c..2484df44a 100644
--- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c
+++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c
@@ -98,7 +98,7 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) {
gSaveContext.unk_1419 = 255;
}
- func_8006EF10(&this->unk_150);
+ Font_LoadOrderedFont(&this->font);
this->unk_E316 = 0;
this->unk_E318 = 0;
@@ -394,7 +394,7 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) {
0x06020000, 0x06020800, 0x06021000, 0x06021800, 0x06022000, 0x06022800, 0x06023000, 0x06023800, 0x06024000,
};
EnMag* this = THIS;
- u8* buf = this->unk_150;
+ Font* font = &this->font;
s32 pad;
Gfx* gfx = *gfxp;
u16 i, j, k;
@@ -496,7 +496,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) {
rectLeft = VREG(19) + 1;
for (i = 0; i < ARRAY_COUNT(noControllerFontIndexes); i++) {
- EnMag_DrawCharTexture(&gfx, buf + 0x3C88 + (noControllerFontIndexes[i] * 0x80), rectLeft, YREG(10) + 172);
+ EnMag_DrawCharTexture(&gfx, font->fontBuf + noControllerFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft,
+ YREG(10) + 172);
rectLeft += VREG(21);
if (i == 1) {
rectLeft += VREG(23);
@@ -509,7 +510,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) {
rectLeft = VREG(19);
for (i = 0; i < ARRAY_COUNT(noControllerFontIndexes); i++) {
- EnMag_DrawCharTexture(&gfx, buf + 0x3C88 + (noControllerFontIndexes[i] * 0x80), rectLeft, YREG(10) + 171);
+ EnMag_DrawCharTexture(&gfx, font->fontBuf + noControllerFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft,
+ YREG(10) + 171);
rectLeft += VREG(21);
if (i == 1) {
rectLeft += VREG(23);
@@ -530,7 +532,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) {
rectLeft = YREG(7) + 1;
for (i = 0; i < ARRAY_COUNT(pressStartFontIndexes); i++) {
- EnMag_DrawCharTexture(&gfx, buf + 0x3C88 + (pressStartFontIndexes[i] * 0x80), rectLeft, YREG(10) + 172);
+ EnMag_DrawCharTexture(&gfx, font->fontBuf + pressStartFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft,
+ YREG(10) + 172);
rectLeft += YREG(8);
if (i == 4) {
rectLeft += YREG(9);
@@ -543,7 +546,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) {
rectLeft = YREG(7);
for (i = 0; i < ARRAY_COUNT(pressStartFontIndexes); i++) {
- EnMag_DrawCharTexture(&gfx, buf + 0x3C88 + (pressStartFontIndexes[i] * 0x80), rectLeft, YREG(10) + 171);
+ EnMag_DrawCharTexture(&gfx, font->fontBuf + pressStartFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft,
+ YREG(10) + 171);
rectLeft += YREG(8);
if (i == 4) {
rectLeft += YREG(9);
diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.h b/src/overlays/actors/ovl_En_Mag/z_en_mag.h
index 9eba318aa..8962dd8f9 100644
--- a/src/overlays/actors/ovl_En_Mag/z_en_mag.h
+++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.h
@@ -9,7 +9,7 @@ struct EnMag;
typedef struct EnMag {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x0004];
- /* 0x0150 */ u8 unk_150[0xE188]; // kanfont struct/buffer
+ /* 0x0150 */ Font font;
/* 0xE2D8 */ s16 effectFadeInState;
/* 0xE2DA */ s16 effectFadeInTimer;
/* 0xE2DC */ s16 globalState;