From 0acaed6d17afb9b47de50628d8afb8df009a2dc9 Mon Sep 17 00:00:00 2001 From: cadmic Date: Wed, 25 Sep 2024 14:41:08 -0700 Subject: [PATCH] [PAL N64] Match z_message.c (#2202) --- include/n64dd.h | 8 +++++++ src/code/z_message.c | 50 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/include/n64dd.h b/include/n64dd.h index 6931eac26c..6a353c3172 100644 --- a/include/n64dd.h +++ b/include/n64dd.h @@ -6,6 +6,7 @@ #include "z64pause.h" #include "z64scene.h" #include "z64map_mark.h" +#include "versions.h" struct Font; struct GameState; @@ -49,11 +50,18 @@ typedef struct n64ddStruct_80121220 { struct SceneTableEntry* (*unk_48)(s32 sceneId, struct SceneTableEntry* sceneTable); char unk_4C[0x08]; s32 (*unk_54)(struct PlayState*); +#if OOT_NTSC void (*unk_58)(struct MessageTableEntry**, struct MessageTableEntry**, struct MessageTableEntry**); +#else + void (*unk_58)(struct MessageTableEntry**, const char***, const char***, struct MessageTableEntry**); +#endif char unk_5C[0x4]; s32 (*unk_60)(struct Font*); s32 (*unk_64)(struct Font*); s32 (*unk_68)(struct Font*); +#if OOT_PAL + s32 (*unk_6C_PAL)(struct Font*); +#endif void (*unk_6C)(struct PlayState*, SceneDrawConfigFunc*); s32 (*unk_70)(struct DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk, OSMesgQueue* queue, OSMesg msg); void (*unk_74)(struct GameState*); diff --git a/src/code/z_message.c b/src/code/z_message.c index 86b1e20709..0f3502f367 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -3,13 +3,12 @@ #include "terminal.h" #include "versions.h" #include "assets/textures/parameter_static/parameter_static.h" -#include "versions.h" #if PLATFORM_N64 #include "n64dd.h" #endif #pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:112" + "ntsc-1.2:112 pal-1.0:128 pal-1.1:128" #if !PLATFORM_GC #define OCARINA_BUTTON_A_PRIM_1_R 80 @@ -108,7 +107,7 @@ u16 sNextTextId = 0; s16 sTextIsCredits = false; -#if OOT_PAL +#if PLATFORM_GC && OOT_PAL UNK_TYPE D_8014B30C = 0; #endif @@ -1724,7 +1723,7 @@ void Message_Decode(PlayState* play) { Font* font = &play->msgCtx.font; s32 charTexIdx = 0; s16 i; -#if OOT_NTSC +#if !(PLATFORM_GC && OOT_PAL) s16 j; #endif s16 decodedBufPos = 0; @@ -1735,7 +1734,7 @@ void Message_Decode(PlayState* play) { s16 loadChar; u16 value; u8 curChar; -#if OOT_NTSC +#if !(PLATFORM_GC && OOT_PAL) u16 curCharWide; u8* fontBuf; #endif @@ -2562,18 +2561,47 @@ void Message_OpenText(PlayState* play, u16 textId) { if (gSaveContext.language == LANGUAGE_ENG) { Message_FindMessagePAL(play, textId); msgCtx->msgLength = font->msgLength; +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_64 != NULL) && B_80121220->unk_64(&play->msgCtx.font)) { + + } else { + DmaMgr_RequestSync(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength); + } +#else DMA_REQUEST_SYNC(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, font->msgLength, "../z_message_PAL.c", 1966); +#endif } else if (gSaveContext.language == LANGUAGE_GER) { Message_FindMessagePAL(play, textId); msgCtx->msgLength = font->msgLength; +#if PLATFORM_N64 + //! @bug checks unk_64 != NULL instead of unk_68 != NULL + if ((B_80121220 != NULL) && (B_80121220->unk_64 != NULL) && B_80121220->unk_68(&play->msgCtx.font)) { + + } else { + DmaMgr_RequestSync(font->msgBuf, (uintptr_t)_ger_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength); + } +#else DMA_REQUEST_SYNC(font->msgBuf, (uintptr_t)_ger_message_data_staticSegmentRomStart + font->msgOffset, font->msgLength, "../z_message_PAL.c", 1978); +#endif } else { Message_FindMessagePAL(play, textId); msgCtx->msgLength = font->msgLength; +#if PLATFORM_N64 + //! @bug checks unk_64 != NULL instead of unk_6C_PAL != NULL + if ((B_80121220 != NULL) && (B_80121220->unk_64 != NULL) && B_80121220->unk_6C_PAL(&play->msgCtx.font)) { + + } else { + DmaMgr_RequestSync(font->msgBuf, (uintptr_t)_fra_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength); + } +#else DMA_REQUEST_SYNC(font->msgBuf, (uintptr_t)_fra_message_data_staticSegmentRomStart + font->msgOffset, font->msgLength, "../z_message_PAL.c", 1990); +#endif } #endif } @@ -4005,7 +4033,10 @@ void Message_Update(PlayState* play) { s16 playerFocusScreenPosY; s16 actorFocusScreenPosY; #if OOT_VERSION < GC_US - s32 pad[2]; + s32 pad1; +#endif +#if OOT_NTSC && OOT_VERSION < GC_US + s32 pad2; #endif #if OOT_DEBUG @@ -4323,9 +4354,14 @@ void Message_SetTables(void) { sStaffMessageEntryTablePtr = sStaffMessageEntryTable; -#if PLATFORM_N64 +#if PLATFORM_N64 && OOT_NTSC if ((B_80121220 != NULL) && (B_80121220->unk_58 != NULL)) { B_80121220->unk_58(&sJpnMessageEntryTablePtr, &sNesMessageEntryTablePtr, &sStaffMessageEntryTablePtr); } +#elif PLATFORM_N64 && OOT_PAL + if ((B_80121220 != NULL) && (B_80121220->unk_58 != NULL)) { + B_80121220->unk_58(&sNesMessageEntryTablePtr, &sGerMessageEntryTablePtr, &sFraMessageEntryTablePtr, + &sStaffMessageEntryTablePtr); + } #endif }