1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-10 19:20:13 +00:00

Match retail z_message_PAL.c (#1736)

This commit is contained in:
cadmic 2024-02-09 10:08:28 -08:00 committed by GitHub
parent d2a1abf8df
commit 10ebdf9ff5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -291,17 +291,15 @@ void Message_GrowTextbox(MessageContext* msgCtx) {
void Message_FindMessage(PlayState* play, u16 textId) { void Message_FindMessage(PlayState* play, u16 textId) {
const char* foundSeg; const char* foundSeg;
const char* nextSeg; const char* nextSeg;
Font* font = &play->msgCtx.font;
MessageTableEntry* messageTableEntry = sNesMessageEntryTablePtr; MessageTableEntry* messageTableEntry = sNesMessageEntryTablePtr;
const char** languageSegmentTable; const char** languageSegmentTable;
Font* font;
const char* seg; const char* seg;
if (gSaveContext.language == LANGUAGE_ENG) { if (gSaveContext.language == LANGUAGE_ENG) {
seg = messageTableEntry->segment; seg = messageTableEntry->segment;
while (messageTableEntry->textId != 0xFFFF) { while (messageTableEntry->textId != 0xFFFF) {
font = &play->msgCtx.font;
if (messageTableEntry->textId == textId) { if (messageTableEntry->textId == textId) {
foundSeg = messageTableEntry->segment; foundSeg = messageTableEntry->segment;
font->charTexBuf[0] = messageTableEntry->typePos; font->charTexBuf[0] = messageTableEntry->typePos;
@ -323,8 +321,6 @@ void Message_FindMessage(PlayState* play, u16 textId) {
seg = messageTableEntry->segment; seg = messageTableEntry->segment;
while (messageTableEntry->textId != 0xFFFF) { while (messageTableEntry->textId != 0xFFFF) {
font = &play->msgCtx.font;
if (messageTableEntry->textId == textId) { if (messageTableEntry->textId == textId) {
foundSeg = *languageSegmentTable; foundSeg = *languageSegmentTable;
font->charTexBuf[0] = messageTableEntry->typePos; font->charTexBuf[0] = messageTableEntry->typePos;
@ -344,7 +340,6 @@ void Message_FindMessage(PlayState* play, u16 textId) {
} }
// "Message not found!!!" // "Message not found!!!"
PRINTF(" メッセージが,見つからなかった!!! = %x\n", textId); PRINTF(" メッセージが,見つからなかった!!! = %x\n", textId);
font = &play->msgCtx.font;
messageTableEntry = sNesMessageEntryTablePtr; messageTableEntry = sNesMessageEntryTablePtr;
if (gSaveContext.language == LANGUAGE_ENG) { if (gSaveContext.language == LANGUAGE_ENG) {
@ -368,13 +363,11 @@ void Message_FindCreditsMessage(PlayState* play, u16 textId) {
const char* foundSeg; const char* foundSeg;
const char* nextSeg; const char* nextSeg;
const char* seg; const char* seg;
Font* font = &play->msgCtx.font;
MessageTableEntry* messageTableEntry = sStaffMessageEntryTablePtr; MessageTableEntry* messageTableEntry = sStaffMessageEntryTablePtr;
Font* font;
seg = messageTableEntry->segment; seg = messageTableEntry->segment;
while (messageTableEntry->textId != 0xFFFF) { while (messageTableEntry->textId != 0xFFFF) {
font = &play->msgCtx.font;
if (messageTableEntry->textId == textId) { if (messageTableEntry->textId == textId) {
foundSeg = messageTableEntry->segment; foundSeg = messageTableEntry->segment;
font->charTexBuf[0] = messageTableEntry->typePos; font->charTexBuf[0] = messageTableEntry->typePos;
@ -981,7 +974,8 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) {
sMessageHasSetSfx = true; sMessageHasSetSfx = true;
// "Sound (SE)" // "Sound (SE)"
PRINTF("サウンド(SE)\n"); PRINTF("サウンド(SE)\n");
sfxHi = msgCtx->msgBufDecoded[i + 1] << 8; sfxHi = msgCtx->msgBufDecoded[i + 1];
sfxHi <<= 8;
Audio_PlaySfxGeneral(sfxHi | msgCtx->msgBufDecoded[i + 2], &gSfxDefaultPos, 4, Audio_PlaySfxGeneral(sfxHi | msgCtx->msgBufDecoded[i + 2], &gSfxDefaultPos, 4,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} }
@ -1369,8 +1363,8 @@ void Message_Decode(PlayState* play) {
} }
if (loadChar) { if (loadChar) {
Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx); Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx);
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
charTexIdx += FONT_CHAR_TEX_SIZE; charTexIdx += FONT_CHAR_TEX_SIZE;
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]); PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]);
decodedBufPos++; decodedBufPos++;
} }
@ -1390,8 +1384,8 @@ void Message_Decode(PlayState* play) {
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (i == 1 || digits[i] != 0) { if (i == 1 || digits[i] != 0) {
Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx); Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx);
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
charTexIdx += FONT_CHAR_TEX_SIZE; charTexIdx += FONT_CHAR_TEX_SIZE;
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]); PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]);
decodedBufPos++; decodedBufPos++;
} }
@ -1579,9 +1573,10 @@ void Message_OpenText(PlayState* play, u16 textId) {
Font* font = &msgCtx->font; Font* font = &msgCtx->font;
s16 textBoxType; s16 textBoxType;
if (msgCtx->msgMode == MSGMODE_NONE) { // clang-format off
gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode; if (msgCtx->msgMode == MSGMODE_NONE) { gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode; }
} // clang-format on
if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) { if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) {
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE); Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE);
} }
@ -1707,6 +1702,7 @@ void Message_StartTextbox(PlayState* play, u16 textId, Actor* actor) {
} }
void Message_ContinueTextbox(PlayState* play, u16 textId) { void Message_ContinueTextbox(PlayState* play, u16 textId) {
s32 pad;
MessageContext* msgCtx = &play->msgCtx; MessageContext* msgCtx = &play->msgCtx;
PRINTF(VT_FGCOL(GREEN)); PRINTF(VT_FGCOL(GREEN));
@ -2951,6 +2947,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) {
*p = gfx; *p = gfx;
} }
#if OOT_DEBUG
/** /**
* If the s16 variable pointed to by `var` changes in value, a black bar and white box * If the s16 variable pointed to by `var` changes in value, a black bar and white box
* are briefly drawn onto the screen. It can only watch one variable per build due to * are briefly drawn onto the screen. It can only watch one variable per build due to
@ -3002,14 +2999,19 @@ void Message_DrawDebugText(PlayState* play, Gfx** p) {
*p = GfxPrint_Close(&printer); *p = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer); GfxPrint_Destroy(&printer);
} }
#endif
void Message_Draw(PlayState* play) { void Message_Draw(PlayState* play) {
Gfx* plusOne; Gfx* plusOne;
Gfx* polyOpaP; Gfx* polyOpaP;
#if OOT_DEBUG
s16 watchVar; s16 watchVar;
#endif
OPEN_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3554); OPEN_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3554);
#if OOT_DEBUG
watchVar = gSaveContext.save.info.scarecrowLongSongSet; watchVar = gSaveContext.save.info.scarecrowLongSongSet;
Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx); Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx);
if (BREG(0) != 0 && play->msgCtx.textId != 0) { if (BREG(0) != 0 && play->msgCtx.textId != 0) {
@ -3021,6 +3023,8 @@ void Message_Draw(PlayState* play) {
POLY_OPA_DISP = plusOne; POLY_OPA_DISP = plusOne;
} }
if (1) {} if (1) {}
#endif
plusOne = Gfx_Open(polyOpaP = POLY_OPA_DISP); plusOne = Gfx_Open(polyOpaP = POLY_OPA_DISP);
gSPDisplayList(OVERLAY_DISP++, plusOne); gSPDisplayList(OVERLAY_DISP++, plusOne);
Message_DrawMain(play, &plusOne); Message_DrawMain(play, &plusOne);
@ -3063,6 +3067,7 @@ void Message_Update(PlayState* play) {
s16 playerFocusScreenPosY; s16 playerFocusScreenPosY;
s16 actorFocusScreenPosY; s16 actorFocusScreenPosY;
#if OOT_DEBUG
if (BREG(0) != 0) { if (BREG(0) != 0) {
if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN) && CHECK_BTN_ALL(input->cur.button, BTN_L)) { if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN) && CHECK_BTN_ALL(input->cur.button, BTN_L)) {
PRINTF("msgno=%d\n", D_80153D78); PRINTF("msgno=%d\n", D_80153D78);
@ -3088,10 +3093,9 @@ void Message_Update(PlayState* play) {
} }
} }
} }
#endif
if (msgCtx->msgLength == 0) { if (msgCtx->msgLength != 0) {
return;
}
switch (msgCtx->msgMode) { switch (msgCtx->msgMode) {
case MSGMODE_TEXT_START: case MSGMODE_TEXT_START:
@ -3119,8 +3123,8 @@ void Message_Update(PlayState* play) {
} else { } else {
averageY = ((actorFocusScreenPosY - playerFocusScreenPosY) / 2) + playerFocusScreenPosY; averageY = ((actorFocusScreenPosY - playerFocusScreenPosY) / 2) + playerFocusScreenPosY;
} }
PRINTF("dxpos=%d dypos=%d dypos1 dypos2=%d\n", focusScreenPosX, averageY, playerFocusScreenPosY, PRINTF("dxpos=%d dypos=%d dypos1 dypos2=%d\n", focusScreenPosX, averageY,
actorFocusScreenPosY); playerFocusScreenPosY, actorFocusScreenPosY);
} else { } else {
R_TEXTBOX_X = R_TEXTBOX_X_TARGET; R_TEXTBOX_X = R_TEXTBOX_X_TARGET;
R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET; R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET;
@ -3240,7 +3244,8 @@ void Message_Update(PlayState* play) {
} }
} else if (msgCtx->textboxEndType != TEXTBOX_ENDTYPE_PERSISTENT && } else if (msgCtx->textboxEndType != TEXTBOX_ENDTYPE_PERSISTENT &&
msgCtx->textboxEndType != TEXTBOX_ENDTYPE_EVENT && YREG(31) == 0) { msgCtx->textboxEndType != TEXTBOX_ENDTYPE_EVENT && YREG(31) == 0) {
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_2_CHOICE && play->msgCtx.ocarinaMode == OCARINA_MODE_01) { if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_2_CHOICE &&
play->msgCtx.ocarinaMode == OCARINA_MODE_01) {
if (Message_ShouldAdvance(play)) { if (Message_ShouldAdvance(play)) {
PRINTF("OCARINA_MODE=%d -> ", play->msgCtx.ocarinaMode); PRINTF("OCARINA_MODE=%d -> ", play->msgCtx.ocarinaMode);
play->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04; play->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04;
@ -3272,9 +3277,9 @@ void Message_Update(PlayState* play) {
(msgCtx->textId >= 0xFA && msgCtx->textId < 0xFE)) { (msgCtx->textId >= 0xFA && msgCtx->textId < 0xFE)) {
gSaveContext.healthAccumulator = 0x140; // Refill 20 hearts gSaveContext.healthAccumulator = 0x140; // Refill 20 hearts
} }
if (msgCtx->textId == 0x301F || msgCtx->textId == 0xA || msgCtx->textId == 0xC || msgCtx->textId == 0xCF || if (msgCtx->textId == 0x301F || msgCtx->textId == 0xA || msgCtx->textId == 0xC ||
msgCtx->textId == 0x21C || msgCtx->textId == 9 || msgCtx->textId == 0x4078 || msgCtx->textId == 0xCF || msgCtx->textId == 0x21C || msgCtx->textId == 9 ||
msgCtx->textId == 0x2015 || msgCtx->textId == 0x3040) { msgCtx->textId == 0x4078 || msgCtx->textId == 0x2015 || msgCtx->textId == 0x3040) {
gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL; gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL;
} }
if (play->csCtx.state == 0) { if (play->csCtx.state == 0) {
@ -3339,6 +3344,7 @@ void Message_Update(PlayState* play) {
msgCtx->lastOcarinaButtonIndex = OCARINA_BTN_INVALID; msgCtx->lastOcarinaButtonIndex = OCARINA_BTN_INVALID;
break; break;
} }
}
} }
void Message_SetTables(void) { void Message_SetTables(void) {