summaryrefslogtreecommitdiff
path: root/src/code/z_kanfont.c
diff options
context:
space:
mode:
authorZelllll <56516451+Zelllll@users.noreply.github.com>2021-07-05 18:14:27 -0700
committerGitHub <noreply@github.com>2021-07-05 21:14:27 -0400
commit6db3fc7b323e8d81ba848a2baa372b3295a1d29e (patch)
treedc04ab357e99fc3df634d81005932dd8374e71a8 /src/code/z_kanfont.c
parent0e51bf35a169f3f73c7fb7e9f31f6ccafb4ebb25 (diff)
Document most of global context (#198)
* doesn't build for some reason..? * some formatting fixes * windows calculator is trash * fix! * fix2 * most of global context documented * interfacectx * hopefully fix interface * document restrictions * envCtx done * revert accidental change * fix * pause ctx done * fixxxxxxxxxxxxxxx * remove unintended zapd change * fix..? * format files * Update include/z64.h Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * ocarinstaff * Update include/z64.h Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update include/z64.h Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * suggestions * fix mistake in pausectx * typo * door context * renames * all nb removed * Update include/z64.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * fix kanfont, new docs * format files, merge master * fix typo in linker script * extract asm properly * door context rename * fixes in door context Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Diffstat (limited to 'src/code/z_kanfont.c')
-rw-r--r--src/code/z_kanfont.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c
index 25695727e..01ae5d043 100644
--- a/src/code/z_kanfont.c
+++ b/src/code/z_kanfont.c
@@ -1,34 +1,44 @@
#include <ultra64.h>
#include <global.h>
-void Kanfont_Nop800F4F40(GlobalContext* globalCtx, UNK_TYPE param_2, UNK_TYPE param_3) {
+// stubbed in NTSC-U
+void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset) {
}
-void Kanfont_LoadAsciiChar(GlobalContext* globalCtx, u8 character, s32 iParm3) {
- // UB to convert pointer to u32
- DmaMgr_SendRequest0((void*)((u32)&globalCtx->msgCtx.font.unk0[(globalCtx->msgCtx).unk11EF0] + iParm3),
- (u32)_nes_font_staticSegmentRomStart + character * 0x80 - 0x1000, 0x80);
+void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset) {
+ MessageContext* msgCtx = &globalCtx->msgCtx;
+ Font* font = &msgCtx->font;
+
+ DmaMgr_SendRequest0(&font->charBuf[font->unk_11D88][offset],
+ &_nes_font_staticSegmentRomStart[(codePointIndex - ' ') * FONT_CHAR_TEX_SIZE],
+ FONT_CHAR_TEX_SIZE);
}
-void Kanfont_LoadMessageBoxEnd(Font* font, u16 type) {
- // UB to convert pointer to u32
- DmaMgr_SendRequest0(&font->unk7800[0][0], type * 0x80 + (u32)_message_staticSegmentRomStart + 0x5000, 0x80);
+void Font_LoadMessageBoxEndIcon(Font* font, u16 icon) {
+ DmaMgr_SendRequest0(&font->iconBuf, &_message_staticSegmentRomStart[5 * 0x1000 + icon * FONT_CHAR_TEX_SIZE],
+ FONT_CHAR_TEX_SIZE);
}
-void Kanfont_LoadOrderedFont(Font* font) {
+static char sFontOrdering[] = "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19"
+ "!\"#$%&\'()*+,-./0123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "\x00\x0D\x0E\x1A"
+ "afjmosvwxyz{|}~"
+ "\x7F\x80\x81\x84\x86\x87\x88\x89\x8A\x8B\x8C";
+
+void Font_LoadOrderedFont(Font* font) {
u32 loadOffset;
s32 codePointIndex = 0;
- void* writeLocation;
+ u8* writeLocation;
while (1) {
- writeLocation = &font->unk7800[codePointIndex + 1];
- loadOffset = kanfontOrdering[codePointIndex] * 128;
- if (kanfontOrdering[codePointIndex] == 0) {
+ writeLocation = &font->fontBuf[codePointIndex * FONT_CHAR_TEX_SIZE];
+ loadOffset = sFontOrdering[codePointIndex] * FONT_CHAR_TEX_SIZE;
+ if (sFontOrdering[codePointIndex] == 0) {
loadOffset = 0;
}
// UB to convert pointer to u32
- DmaMgr_SendRequest0(writeLocation, (u32)_nes_font_staticSegmentRomStart + loadOffset, 0x80);
- if (kanfontOrdering[codePointIndex] == 140) {
+ DmaMgr_SendRequest0(writeLocation, (u32)_nes_font_staticSegmentRomStart + loadOffset, FONT_CHAR_TEX_SIZE);
+ if (sFontOrdering[codePointIndex] == 0x8C) {
break;
}
codePointIndex++;