mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-04-28 13:17:58 +03:00
Fix messages crashing when no ntsc game is loaded (#5259)
* Fix messages crashing when no ntsc game is loaded * rename func
This commit is contained in:
parent
0dc5ff4984
commit
bcd8842bde
3 changed files with 37 additions and 23 deletions
|
@ -901,7 +901,7 @@ s32 Jpeg_Decode(void* data, void* zbuffer, void* workBuff, u32 workSize);
|
|||
void KaleidoSetup_Update(PlayState* play);
|
||||
void KaleidoSetup_Init(PlayState* play);
|
||||
void KaleidoSetup_Destroy(PlayState* play);
|
||||
void func_8006EE50(Font* font, u16 arg1, u16 arg2);
|
||||
void Font_LoadCharWide(Font* font, u16 arg1, u16 arg2);
|
||||
void Font_LoadChar(Font* font, u8 character, u16 codePointIndex);
|
||||
void Font_LoadMessageBoxIcon(Font* font, u16 icon);
|
||||
void Font_LoadOrderedFont(Font* font);
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include "textures/kanji/kanji.h"
|
||||
#include "textures/message_static/message_static.h"
|
||||
|
||||
// SOH [NTSC]
|
||||
extern MessageTableEntry* sJpnMessageEntryTablePtr;
|
||||
|
||||
// #region SOH [Port] Asset tables we can pull from instead of from ROM
|
||||
const char* fontTbl[140] =
|
||||
{
|
||||
|
@ -4141,9 +4144,20 @@ const char* msgStaticTbl[] =
|
|||
};
|
||||
// #endregion
|
||||
|
||||
void func_8006EE50(Font* font, u16 character, u16 codePointIndex) {
|
||||
// #region SOH [NTSC]
|
||||
/**
|
||||
* Loads a texture from kanji for the requested `character` into the character texture buffer
|
||||
* at `codePointIndex`. The value of `character` is the SHIFT-JIS encoding of the character.
|
||||
*/
|
||||
void Font_LoadCharWide(Font* font, u16 character, u16 codePointIndex) {
|
||||
// DmaMgr_RequestSync(&font->charTexBuf[codePointIndex], _kanjiSegmentStart + Kanji_OffsetFromShiftJIS(character), 0x80);
|
||||
|
||||
// #region SOH [NTSC]
|
||||
// This function is called even for non-nstc, but this function would be empty for non-ntsc.
|
||||
// To simulate that, we check if the jpn message table is loaded and if not immediately return.
|
||||
if (sJpnMessageEntryTablePtr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
s32 charIndex = Kanji_OffsetFromShiftJIS(character);
|
||||
charIndex /= FONT_CHAR_TEX_SIZE;
|
||||
if (charIndex < ARRAY_COUNT(kanjiFontTbl))
|
||||
|
@ -4213,8 +4227,6 @@ void Font_LoadOrderedFont(Font* font) {
|
|||
}
|
||||
|
||||
// #region SOH [NTSC]
|
||||
extern MessageTableEntry* sJpnMessageEntryTablePtr;
|
||||
|
||||
void Font_LoadOrderedFontNTSC(Font* font) {
|
||||
s32 len;
|
||||
s32 size;
|
||||
|
|
|
@ -1995,17 +1995,17 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
if (i == 1) {
|
||||
func_8006EE50(font, 0x95AA, charTexIdx);
|
||||
Font_LoadCharWide(font, 0x95AA, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = 0x95AA;
|
||||
decodedBufPos++;
|
||||
} else if (i == 3) {
|
||||
func_8006EE50(font, 0x9562, charTexIdx);
|
||||
Font_LoadCharWide(font, 0x9562, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = 0x9562;
|
||||
}
|
||||
|
@ -2032,7 +2032,7 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
loadChar = true;
|
||||
}
|
||||
if (loadChar) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
|
@ -2058,7 +2058,7 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
loadChar = true;
|
||||
}
|
||||
if (loadChar) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
|
@ -2076,7 +2076,7 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (i == 1 || digits[i] != 0) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
|
@ -2118,7 +2118,7 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
loadChar = true;
|
||||
}
|
||||
if (loadChar) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
|
@ -2148,17 +2148,17 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
if (i == 1) {
|
||||
func_8006EE50(font, 0x95AA, charTexIdx);
|
||||
Font_LoadCharWide(font, 0x95AA, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = 0x95AA;
|
||||
decodedBufPos++;
|
||||
} else if (i == 3) {
|
||||
func_8006EE50(font, 0x9562, charTexIdx);
|
||||
Font_LoadCharWide(font, 0x9562, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = 0x9562;
|
||||
}
|
||||
|
@ -2182,17 +2182,17 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
func_8006EE50(font, digits[i] + 0x824F, charTexIdx);
|
||||
Font_LoadCharWide(font, digits[i] + 0x824F, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = digits[i] + 0x824F;
|
||||
decodedBufPos++;
|
||||
if (i == 1) {
|
||||
func_8006EE50(font, 0x8E9E, charTexIdx);
|
||||
Font_LoadCharWide(font, 0x8E9E, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = 0x8E9E;
|
||||
decodedBufPos++;
|
||||
} else if (i == 3) {
|
||||
func_8006EE50(font, 0x95AA, charTexIdx);
|
||||
Font_LoadCharWide(font, 0x95AA, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
msgCtx->msgBufDecodedWide[decodedBufPos] = 0x95AA;
|
||||
}
|
||||
|
@ -2231,7 +2231,7 @@ void Message_DecodeJPN(PlayState* play) {
|
|||
msgCtx->choiceNum = 3;
|
||||
R_TEXT_INIT_XPOS += 32;
|
||||
} else if (curChar != MESSAGE_SPACE_JPN) {
|
||||
func_8006EE50(font, curChar, charTexIdx);
|
||||
Font_LoadCharWide(font, curChar, charTexIdx);
|
||||
charTexIdx += FONT_CHAR_TEX_SIZE;
|
||||
}
|
||||
}
|
||||
|
@ -3010,8 +3010,9 @@ void Message_StartOcarina(PlayState* play, u16 ocarinaActionId) {
|
|||
gSaveContext.unk_13EA = 0;
|
||||
Interface_ChangeAlpha(1);
|
||||
}
|
||||
for (k = 0, j = 0; j < 48; j++, k += 0x80) {
|
||||
func_8006EE50(&play->msgCtx.font, 0x8140, k);
|
||||
for (k = 0, j = 0; j < 48; j++) {
|
||||
Font_LoadCharWide(&play->msgCtx.font, 0x8140, k);
|
||||
k += FONT_CHAR_TEX_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3326,8 +3327,9 @@ void Message_DrawMain(PlayState* play, Gfx** p) {
|
|||
break;
|
||||
case MSGMODE_TEXT_CONTINUING:
|
||||
if (msgCtx->stateTimer == 1) {
|
||||
for (j = 0, i = 0; i < 48; i++, j += 0x80) {
|
||||
func_8006EE50(&play->msgCtx.font, 0x8140, j);
|
||||
for (j = 0, i = 0; i < 48; i++) {
|
||||
Font_LoadCharWide(&play->msgCtx.font, 0x8140, j);
|
||||
j += FONT_CHAR_TEX_SIZE;
|
||||
}
|
||||
if (gSaveContext.language == LANGUAGE_JPN && !sTextIsCredits && !sDisplayNextMessageAsEnglish) {
|
||||
Message_DrawTextJPN(play, &gfx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue