1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 21:40:03 +00:00
oot/src/code/z_kanfont.c
Tharo a497f33bda
z_message_PAL, message_data_static and surrounding doc (#996)
* Initial progress on z_message_PAL, very messy

* Fix merge

* Some more progress

* Fix merge

* More z_message_PAL

* Small progress

* More small progress

* message_data_static files OK

* Prepare z_message_tables

* Matched another function, small updates

* Attempt to use asm-processor static-symbols branch

* Refactor text id declarations

* Begin large text codes parser function

* Fix merge

* Refactor done

* Build OK, add color and highscore names

* Remove encoded text headers and automatically encode during build

* Fix kanfont

* Various cleanups

* DISP macros

* Another match aside data

* Further progress

* Small improvements

* Deduplicate magic values for text control codes, small improvements

* Tiny progress

* Minor cleanups

* Clean up z_message_PAL comment

* Progress on large functions

* Further progress on large functions

* Changes to mkldscript to link .data in the .rodata section

* data OK

* Few improvements

* Use gDPLoadTextureBlock macros where appropriate

* rm z_message_tables, progress on large functions

* 2 more matches

* Improvements

* Small progress

* More progress on big function

* progress

* match func_80107980

* match Message_Update

* match func_8010BED8

* done

* Progress on remaining large functions

* Small progress on largest function

* Another match, extract text and move to assets, improve text build system

* Small nonmatchings improvements

* docs wip

* Largest function maybe equivalent

* Fix merge

* Document do_action values, largest function is almost instruction-matching

* Rename NAVI do_action to NONE, as that appears to be how that value is used in practice

* Fix merge

* one match

* Last function is instruction-matching

* Fix

* Improvements thanks to engineer124

* Stack matched thanks to petrie911, now just a/v/low t regalloc issues, some cleanup

* More variables labeled, use text state enum everywhere

* More labels and names

* Fix

* Actor_IsTalking -> Actor_TalkRequested

* Match func_8010C39C and remove unused asm

* More docs

* Mostly ocarina related docs

* All msgModes named

* Fix assetclean

* Cleanup

* Extraction fixes and headers

* Suggestions

* Review suggestions

* Change text extraction again, only extract if the headers do not already exist

* Fix

* Use ast for charmap, fix assetclean for real this time

* Review suggestions

* BGM ids and ran formatter

* Review comments

* rename include_readonly to include_data_with_rodata

* Remove leading 0s in number directives

* Review suggestions for message_data_static

* textbox pos enum comments, rename several enum names from Message to TextBox

Co-authored-by: Thar0 <maximilianc64@gmail.com>
Co-authored-by: Zelllll <56516451+Zelllll@users.noreply.github.com>
Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
Co-authored-by: Roman971 <romanlasnier@hotmail.com>
2021-11-22 20:20:30 -05:00

66 lines
2.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "global.h"
#include "message_data_static.h"
void func_8006EE50(Font* font, u16 arg1, u16 arg2) {
}
/**
* Loads a texture from nes_font_static for the requested `character` into the character texture buffer
* at `codePointIndex`. The value of `character` is the ASCII codepoint subtract ' '/0x20.
*/
void Font_LoadChar(Font* font, u8 character, u16 codePointIndex) {
DmaMgr_SendRequest1(&font->charTexBuf[codePointIndex],
&_nes_font_staticSegmentRomStart[character * FONT_CHAR_TEX_SIZE], FONT_CHAR_TEX_SIZE,
"../z_kanfont.c", 93);
}
/**
* Loads a message box icon from message_static, such as the ending triangle/square or choice arrow into the
* icon buffer.
* The different icons are given in the MessageBoxIcon enum.
*/
void Font_LoadMessageBoxIcon(Font* font, u16 icon) {
DmaMgr_SendRequest1(font->iconBuf,
&_message_staticSegmentRomStart[4 * MESSAGE_STATIC_TEX_SIZE + icon * FONT_CHAR_TEX_SIZE],
FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 100);
}
/**
* Loads a full set of character textures based on their ordering in the message with text id 0xFFFC into
* the font buffer.
*/
void Font_LoadOrderedFont(Font* font) {
s32 len;
s32 jj;
s32 fontStatic;
u32 fontBuf;
s32 codePointIndex;
s32 fontBufIndex;
s32 offset;
font->msgOffset = _message_0xFFFC_nes - (const char*)_nes_message_data_staticSegmentStart;
len = font->msgLength = _message_0xFFFD_nes - _message_0xFFFC_nes;
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───\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 += FONT_CHAR_TEX_SIZE / 8;
}
}
}