From 2e87212038a4abe3c66d20b98d6f1c2fff8f2380 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 24 Sep 2023 01:46:07 -0700 Subject: [PATCH] z_message_staff (1 NON-MATCHING) (#1376) * z_message_staff from z_message branch * Use highscores array * Clean up * format * PR cleanup * PR Review * Fix bss * Fix bss --- include/functions.h | 10 +- include/z64message.h | 234 +++++-- include/z64save.h | 47 +- src/code/code_8012EC80.c | 3 +- src/code/z_message.c | 153 ++-- src/code/z_message_nes.c | 16 +- src/code/z_message_staff.c | 654 +++++++++++++++++- src/code/z_parameter.c | 2 +- src/code/z_play.c | 6 +- src/code/z_player_lib.c | 4 +- src/code/z_sram_NES.c | 10 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 67 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 46 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 6 +- .../actors/ovl_En_Kujiya/z_en_kujiya.c | 16 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 12 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 10 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 2 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 7 +- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 2 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 2 +- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 2 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 2 +- .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 2 +- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c | 2 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 2 +- .../actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c | 2 +- .../actors/ovl_player_actor/z_player.c | 14 +- .../ovl_file_choose/z_file_nameset_NES.c | 1 - tools/disasm/files.txt | 1 + tools/disasm/functions.txt | 10 +- tools/namefixer.py | 36 +- 35 files changed, 1108 insertions(+), 281 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7ab743bd00..00e992e9e7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1010,13 +1010,13 @@ void func_80148B98(PlayState* play, u8 arg1); // void func_801491DC(void); // void func_80149454(void); // void func_801496C8(void); -// void func_8014995C(void); +void Message_DrawTextChar(PlayState* play, TexturePtr texture, Gfx** gfxP); void func_80149C18(PlayState* play); // void Message_FindMessage(void); void func_80149F74(PlayState* play, u32** ppuParm2); -// void func_8014AAD0(void); +void Message_HandleOcarina(PlayState* play); void func_8014ADBC(PlayState* play, UNK_PTR puParm2); -// void func_8014C70C(void); +void Message_LoadItemIcon(PlayState* play, u16 itemId, s16 arg2); void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos); // void func_8014CCB4(void); // void func_8014CDF0(void); @@ -1027,7 +1027,7 @@ void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_ void func_80150A84(PlayState* play); void func_80150D08(PlayState* play, u32 uParm2); void func_801514B0(PlayState* play, u16 arg1, u8 arg2); -void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor); +void Message_StartTextbox(PlayState* play, u16 textId, Actor* actor); void Message_ContinueTextbox(PlayState* play, u16 textId); void func_80151A68(PlayState* play, u16 textId); void Message_BombersNotebookQueueEvent(PlayState* play, u8 event); @@ -1061,7 +1061,7 @@ void func_8015966C(PlayState* play, UNK_PTR puParm2, UNK_TYPE arg3); // void func_8015A144(void); void func_8015B198(PlayState* play); void Message_FindCreditsMessage(PlayState* play, u16 textId); -void func_8015E7EC(PlayState* play, UNK_PTR puParm2); +void Message_DrawTextCredits(PlayState* play, Gfx** gfxP); // void func_8015F8A8(UNK_TYPE4 ctxt); uintptr_t KaleidoManager_FaultAddrConv(uintptr_t address, void* param); diff --git a/include/z64message.h b/include/z64message.h index 2a3810ff14..fc41055d41 100644 --- a/include/z64message.h +++ b/include/z64message.h @@ -10,6 +10,135 @@ struct MessageTableEntry; struct OcarinaStaff; struct PlayState; +typedef enum TextBoxType { + /* 0x00 */ TEXTBOX_TYPE_0, + /* 0x01 */ TEXTBOX_TYPE_1, + /* 0x02 */ TEXTBOX_TYPE_2, + /* 0x03 */ TEXTBOX_TYPE_3, + /* 0x04 */ TEXTBOX_TYPE_4, + /* 0x05 */ TEXTBOX_TYPE_5, + /* 0x06 */ TEXTBOX_TYPE_6, + /* 0x07 */ TEXTBOX_TYPE_7, + /* 0x08 */ TEXTBOX_TYPE_8, + /* 0x09 */ TEXTBOX_TYPE_9, + /* 0x0A */ TEXTBOX_TYPE_A, + /* 0x0B */ TEXTBOX_TYPE_B, + /* 0x0C */ TEXTBOX_TYPE_C, + /* 0x0D */ TEXTBOX_TYPE_D, + /* 0x0E */ TEXTBOX_TYPE_E, + /* 0x0F */ TEXTBOX_TYPE_F, + /* 0x10 */ TEXTBOX_TYPE_MAX +} TextBoxType; + +#define TEXTBOX_ENDTYPE_00 0x00 + +#define TEXTBOX_ENDTYPE_10 0x10 +#define TEXTBOX_ENDTYPE_11 0x11 +#define TEXTBOX_ENDTYPE_12 0x12 + +#define TEXTBOX_ENDTYPE_20 0x20 + +#define TEXTBOX_ENDTYPE_30 0x30 + +#define TEXTBOX_ENDTYPE_40 0x40 +#define TEXTBOX_ENDTYPE_41 0x41 +#define TEXTBOX_ENDTYPE_42 0x42 + +#define TEXTBOX_ENDTYPE_50 0x50 +#define TEXTBOX_ENDTYPE_52 0x52 +#define TEXTBOX_ENDTYPE_55 0x55 +#define TEXTBOX_ENDTYPE_56 0x56 +#define TEXTBOX_ENDTYPE_57 0x57 + +#define TEXTBOX_ENDTYPE_60 0x60 +#define TEXTBOX_ENDTYPE_61 0x61 +#define TEXTBOX_ENDTYPE_62 0x62 +#define TEXTBOX_ENDTYPE_63 0x63 +#define TEXTBOX_ENDTYPE_64 0x64 + +typedef enum MessageMode { + /* 0x00 */ MSGMODE_NONE, + /* 0x01 */ MSGMODE_TEXT_START, + /* 0x02 */ MSGMODE_TEXT_BOX_GROWING, + /* 0x03 */ MSGMODE_TEXT_STARTING, + /* 0x04 */ MSGMODE_TEXT_NEXT_MSG, + /* 0x05 */ MSGMODE_TEXT_CONTINUING, + /* 0x06 */ MSGMODE_TEXT_DISPLAYING, + /* 0x07 */ MSGMODE_TEXT_AWAIT_INPUT, + /* 0x08 */ MSGMODE_TEXT_DELAYED_BREAK, + /* 0x09 */ MSGMODE_9, + /* 0x0A */ MSGMODE_OCARINA_STARTING, + /* 0x0B */ MSGMODE_SONG_DEMONSTRATION_STARTING, + /* 0x0C */ MSGMODE_SONG_PROMPT_STARTING, + /* 0x0D */ MSGMODE_OCARINA_PLAYING, + /* 0x0E */ MSGMODE_E, + /* 0x0F */ MSGMODE_OCARINA_FAIL, + /* 0x10 */ MSGMODE_OCARINA_FAIL_NO_TEXT, + /* 0x11 */ MSGMODE_OCARINA_NOTES_DROP, + /* 0x12 */ MSGMODE_SONG_PLAYED, + /* 0x13 */ MSGMODE_SETUP_DISPLAY_SONG_PLAYED, + /* 0x14 */ MSGMODE_DISPLAY_SONG_PLAYED, + /* 0x15 */ MSGMODE_DISPLAY_SONG_PLAYED_TEXT_BEGIN, + /* 0x16 */ MSGMODE_16, + /* 0x17 */ MSGMODE_17, + /* 0x18 */ MSGMODE_18, + /* 0x19 */ MSGMODE_19, + /* 0x1A */ MSGMODE_SONG_DEMONSTRATION, + /* 0x1B */ MSGMODE_SONG_DEMONSTRATION_DONE, + /* 0x1C */ MSGMODE_SONG_PROMPT, + /* 0x1D */ MSGMODE_SONG_PROMPT_SUCCESS, + /* 0x1E */ MSGMODE_SONG_PROMPT_FAIL, + /* 0x1F */ MSGMODE_SONG_PROMPT_NOTES_DROP, + /* 0x20 */ MSGMODE_OCARINA_AWAIT_INPUT, + /* 0x21 */ MSGMODE_21, + /* 0x22 */ MSGMODE_22, + /* 0x23 */ MSGMODE_23, + /* 0x24 */ MSGMODE_24, + /* 0x25 */ MSGMODE_25, + /* 0x26 */ MSGMODE_26, + /* 0x27 */ MSGMODE_SCARECROW_LONG_RECORDING_START, + /* 0x28 */ MSGMODE_SCARECROW_LONG_RECORDING_ONGOING, + /* 0x29 */ MSGMODE_SCARECROW_LONG_DEMONSTRATION, + /* 0x2A */ MSGMODE_SCARECROW_SPAWN_RECORDING_START, + /* 0x2B */ MSGMODE_SCARECROW_SPAWN_RECORDING_ONGOING, + /* 0x2C */ MSGMODE_SCARECROW_SPAWN_RECORDING_FAILED, + /* 0x2D */ MSGMODE_SCARECROW_SPAWN_RECORDING_DONE, + /* 0x2E */ MSGMODE_SCARECROW_SPAWN_DEMONSTRATION, + /* 0x2F */ MSGMODE_2F, + /* 0x30 */ MSGMODE_30, + /* 0x31 */ MSGMODE_31, + /* 0x32 */ MSGMODE_32, + /* 0x33 */ MSGMODE_33, + /* 0x34 */ MSGMODE_34, + /* 0x35 */ MSGMODE_35, + /* 0x36 */ MSGMODE_36, + /* 0x37 */ MSGMODE_37, + /* 0x38 */ MSGMODE_38, + /* 0x39 */ MSGMODE_39, + /* 0x3A */ MSGMODE_3A, + /* 0x3B */ MSGMODE_3B, + /* 0x3C */ MSGMODE_3C, + /* 0x3D */ MSGMODE_3D, + /* 0x3E */ MSGMODE_3E, + /* 0x3F */ MSGMODE_3F, + /* 0x40 */ MSGMODE_40, + /* 0x41 */ MSGMODE_TEXT_AWAIT_NEXT, + /* 0x42 */ MSGMODE_TEXT_DONE, + /* 0x43 */ MSGMODE_TEXT_CLOSING, + /* 0x44 */ MSGMODE_PAUSED, // Causes the message system to do nothing until external code sets a new message mode or calls a public function + /* 0x45 */ MSGMODE_SCENE_TITLE_CARD_FADE_IN_BACKGROUND, // Scene Title Card + /* 0x46 */ MSGMODE_SCENE_TITLE_CARD_FADE_IN_TEXT, + /* 0x47 */ MSGMODE_SCENE_TITLE_CARD_DISPLAYING, + /* 0x48 */ MSGMODE_SCENE_TITLE_CARD_FADE_OUT_TEXT, + /* 0x49 */ MSGMODE_SCENE_TITLE_CARD_FADE_OUT_BACKGROUND, + /* 0x4A */ MSGMODE_NEW_CYCLE_0, // End of cycle? + /* 0x4B */ MSGMODE_NEW_CYCLE_1, + /* 0x4C */ MSGMODE_NEW_CYCLE_2, + /* 0x4D */ MSGMODE_OWL_SAVE_0, + /* 0x4E */ MSGMODE_OWL_SAVE_1, + /* 0x4F */ MSGMODE_OWL_SAVE_2 +} MessageMode; + extern u16 sBombersNotebookEventMessages[BOMBERS_NOTEBOOK_EVENT_MAX]; extern u16 gBombersNotebookWeekEventFlags[BOMBERS_NOTEBOOK_EVENT_MAX]; @@ -82,81 +211,78 @@ typedef struct { typedef struct MessageContext { /* 0x00000 */ View view; /* 0x00168 */ Font font; - /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EF8 */ u8* textboxSegment; /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; /* 0x11F00 */ struct OcarinaStaff* ocarinaStaff; /* 0x11F04 */ u16 currentTextId; - /* 0x11F06 */ UNK_TYPE1 unk11F06[0x2]; + /* 0x11F06 */ u16 choiceTextId; // s16? /* 0x11F08 */ u16 unk11F08; - /* 0x11F0A */ u8 unk11F0A; - /* 0x11F0B */ s8 unk11F0B; - /* 0x11F0C */ s8 unk11F0C; - /* 0x11F0B */ UNK_TYPE1 unk11F0D[0x3]; + /* 0x11F0A */ u8 textBoxType; + /* 0x11F0B */ u8 textBoxPos; + /* 0x11F0C */ u8 unk11F0C; /* 0x11F10 */ s32 msgLength; - /* 0x11F14 */ u16 unk11F14; - /* 0x11F16 */ u16 unk11F16; - /* 0x11F18 */ s8 unk11F18; - /* 0x11F19 */ UNK_TYPE1 unk11F19[0x1]; + /* 0x11F14 */ u16 nextTextId; + /* 0x11F16 */ u16 itemId; + /* 0x11F18 */ u8 unk11F18; /* 0x11F1A */ s16 unk11F1A[3]; /* 0x11F20 */ UNK_TYPE1 unk11F20[0x2]; - /* 0x11F22 */ u8 msgMode; // TODO: MessageMode enum + /* 0x11F22 */ u8 msgMode; /* 0x11F23 */ UNK_TYPE1 unk11F23; /* 0x11F24 */ union { char schar[200]; u16 wchar[100]; } decodedBuffer; /* 0x11FEC */ u16 msgBufPos; - /* 0x11FEE */ s16 unk11FEE; - /* 0x11FF0 */ s16 unk11FF0; - /* 0x11FF2 */ u16 unk11FF2; - /* 0x11FF4 */ s16 unk11FF4; - /* 0x11FF6 */ s16 unk11FF6; + /* 0x11FEE */ u16 textDrawPos; + /* 0x11FF0 */ u16 decodedTextLen; + /* 0x11FF2 */ u16 textUnskippable; + /* 0x11FF4 */ s16 textPosX; + /* 0x11FF6 */ s16 textPosY; /* 0x11FF8 */ s16 unk11FF8; /* 0x11FFA */ s16 unk11FFA; /* 0x11FFC */ s16 unk11FFC; /* 0x11FFE */ s16 unk11FFE[0x3]; - /* 0x12004 */ s16 unk12004; - /* 0x12006 */ s16 unk12006; + /* 0x12004 */ s16 textboxXTarget; + /* 0x12006 */ s16 textboxYTarget; /* 0x12008 */ s16 unk12008; - /* 0x1200A */ UNK_TYPE2 unk1200A; + /* 0x1200A */ s16 unk1200A; /* 0x1200C */ s16 unk1200C; /* 0x1200E */ s16 unk1200E; /* 0x12010 */ s16 unk12010; /* 0x12012 */ s16 unk12012; /* 0x12014 */ s16 unk12014; /* 0x12014 */ s16 unk12016; - /* 0x12018 */ s16 unk12018; // messageR - /* 0x1201A */ s16 unk1201A; // messageG - /* 0x1201C */ s16 unk1201C; // messageB - /* 0x1201E */ s16 unk1201E; // messageA - /* 0x12020 */ u8 unk12020; // probably textboxEndType + /* 0x12018 */ s16 textColorR; + /* 0x1201A */ s16 textColorG; + /* 0x1201C */ s16 textColorB; + /* 0x1201E */ s16 textColorAlpha; + /* 0x12020 */ u8 textboxEndType; /* 0x12021 */ u8 choiceIndex; - /* 0x12022 */ u8 unk12022; + /* 0x12022 */ u8 choiceNum; /* 0x12023 */ u8 stateTimer; - /* 0x12024 */ s16 unk12024; - /* 0x12026 */ u16 unk12026; + /* 0x12024 */ u16 textDelayTimer; + /* 0x12026 */ u16 textDelay; /* 0x12028 */ u16 songPlayed; /* 0x1202A */ u16 ocarinaMode; /* 0x1202C */ u16 ocarinaAction; /* 0x1202E */ u16 lastPlayedSong; /* 0x12030 */ s16 unk_12030; /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ s16 unk12034; - /* 0x12036 */ s16 unk12036; - /* 0x12038 */ s16 unk12038; - /* 0x1203A */ s16 unk1203A; - /* 0x1203C */ s16 unk1203C; + /* 0x12034 */ s16 textboxColorRed; + /* 0x12036 */ s16 textboxColorGreen; + /* 0x12038 */ s16 textboxColorBlue; + /* 0x1203A */ s16 textboxColorAlphaTarget; + /* 0x1203C */ s16 textboxColorAlphaCurrent; /* 0x1203E */ s16 unk1203E; - /* 0x12040 */ struct Actor* unkActor; + /* 0x12040 */ struct Actor* talkActor; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ s16 unk12046; - /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 unk12049[0x1]; - /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12046 */ s16 blockSunsSong; + /* 0x12048 */ u8 ocarinaButtonIndex; + /* 0x1204A */ s16 ocarinaButtonsPosY[5]; /* 0x12054 */ s16 unk12054[6]; // First, second and third digits in lottery code guess /* 0x1205A */ UNK_TYPE1 unk12060[0x8]; - /* 0x12068 */ s16 unk12068; - /* 0x1206A */ s16 unk1206A; + /* 0x12068 */ s16 textboxX; + /* 0x1206A */ s16 textboxY; /* 0x1206C */ s32 unk1206C; /* 0x12070 */ s32 unk12070; /* 0x12074 */ s32 unk12074; @@ -164,21 +290,24 @@ typedef struct MessageContext { /* 0x1207C */ s32 bankRupees; /* 0x12080 */ struct MessageTableEntry* messageEntryTable; /* 0x12084 */ struct MessageTableEntry* messageEntryTableNes; - /* 0x12088 */ UNK_TYPE4 unk12088; + /* 0x12088 */ UNK_TYPE1 unk12088[0x4]; /* 0x1208C */ struct MessageTableEntry* messageTableStaff; - /* 0x12090 */ s16 unk12090; - /* 0x12092 */ s16 unk12092; - /* 0x12094 */ s8 unk12094; - /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; - /* 0x12098 */ f32 unk12098; // Text_Scale? - /* 0x1209C */ s16 unk1209C; - /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; - /* 0x120A0 */ s32 unk120A0; - /* 0x120A4 */ s16 unk120A4[6]; - /* 0x120B0 */ u8 unk120B0; + /* 0x12090 */ s16 textIsCredits; + /* 0x12092 */ s16 messageHasSetSfx; + /* 0x12094 */ u8 textboxSkipped; + /* 0x12098 */ f32 textCharScale; + /* 0x1209C */ s16 textFade; + /* 0x120A0 */ s32 ocarinaAvailableSongs; + /* 0x120A4 */ s16 stickAdjX; + /* 0x120A6 */ s16 stickAdjY; + /* 0x120A8 */ s16 stickXRepeatState; + /* 0x120AA */ s16 stickYRepeatState; + /* 0x120AC */ s16 stickXRepeatTimer; + /* 0x120AE */ s16 stickYRepeatTimer; + /* 0x120B0 */ u8 ocarinaSongEffectActive; /* 0x120B1 */ u8 bombersNotebookEventQueueCount; /* 0x120B2 */ u8 bombersNotebookEventQueue[10]; - /* 0x120BC */ u16 unk_120BC; + /* 0x120BC */ u16 hudVisibility; /* 0x120BE */ s16 unk120BE; /* 0x120C0 */ s16 unk120C0; /* 0x120C2 */ s16 unk120C2; @@ -191,7 +320,8 @@ typedef struct MessageContext { /* 0x120D2 */ s16 unk120D2; /* 0x120D4 */ s16 unk120D4; /* 0x120D6 */ s16 unk120D6; - /* 0x120D8 */ UNK_TYPE1 unk120D8[0x8]; + /* 0x120D8 */ s16 unk120D8; + /* 0x120DA */ UNK_TYPE1 unk_120DA[0x6]; } MessageContext; // size = 0x120E0 #endif diff --git a/include/z64save.h b/include/z64save.h index cdc46f0230..c8075d9ecc 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -154,6 +154,17 @@ typedef enum { /* 52 */ HUD_VISIBILITY_NONE_INSTANT = 52 } HudVisibility; +typedef enum HighScore { + /* 0 */ HS_BANK_RUPEES, + /* 1 */ HS_UNK_1, + /* 2 */ HS_FISHING, // Fishing flags + /* 3 */ HS_BOAT_ARCHERY, + /* 4 */ HS_HOSRE_BACK_BALLOON, + /* 5 */ HS_LOTTERY_GUESS, // Lottery code chosen by player (only uses lower three hex digits) + /* 6 */ HS_SHOOTING_GALLERY, // High scores for both shooting galleries. Town uses lower 16 bits, Swamp uses higher 16 bits. + /* 7 */ HS_MAX +} HighScore; + #define PICTO_PHOTO_WIDTH 160 #define PICTO_PHOTO_HEIGHT 112 @@ -278,13 +289,7 @@ typedef struct SaveInfo { /* 0xEA8 */ u32 unk_EA8[2]; // Related to blue warps /* 0xEB0 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man /* 0xEB4 */ u32 unk_EB4; - /* 0xEB8 */ u32 bankRupees; - /* 0xEBC */ u32 unk_EBC; - /* 0xEC0 */ u32 unk_EC0; // Fishing flags - /* 0xEC4 */ u32 unk_EC4; - /* 0xEC8 */ u32 horseBackBalloonHighScore; - /* 0xECC */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) - /* 0xED0 */ u32 shootingGalleryHighScores; // High scores for both shooting galleries. Town uses lower 16 bits, Swamp uses higher 16 bits. + /* 0xEB8 */ u32 highScores[HS_MAX]; /* 0xED4 */ u8 weekEventReg[100]; // "week_event_reg" /* 0xF38 */ u32 regionsVisited; // "area_arrival" /* 0xF3C */ u32 worldMapCloudVisibility; // "cloud_clear" @@ -430,6 +435,10 @@ typedef enum { #define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) #define LINK_IS_ADULT (gSaveContext.save.linkAge == 0) +#define YEARS_CHILD 5 +#define YEARS_ADULT 17 +#define LINK_AGE_IN_YEARS (!LINK_IS_ADULT ? YEARS_CHILD : YEARS_ADULT) + #define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) // The day begins at CLOCK_TIME(6, 0) so it must be offset. @@ -510,10 +519,26 @@ typedef enum { #define SET_STOLEN_ITEM_2(itemId) \ (gSaveContext.save.saveInfo.stolenItems = (gSaveContext.save.saveInfo.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) -#define GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() ((s32)(gSaveContext.save.saveInfo.shootingGalleryHighScores & 0xFFFF)) -#define GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() ((s32)((gSaveContext.save.saveInfo.shootingGalleryHighScores & 0xFFFF0000) >> 0x10)) -#define SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.saveInfo.shootingGalleryHighScores = (gSaveContext.save.saveInfo.shootingGalleryHighScores & 0xFFFF0000) | ((u16)(score))) -#define SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.saveInfo.shootingGalleryHighScores = ((gSaveContext.save.saveInfo.shootingGalleryHighScores) & 0xFFFF) | ((u16)(score) << 0x10)) +#define HIGH_SCORE(type) (gSaveContext.save.saveInfo.highScores[(type)]) + +#define HS_GET_BANK_RUPEES() (HIGH_SCORE(HS_BANK_RUPEES) & 0xFFFF) +#define HS_SET_BANK_RUPEES(rupees) (HIGH_SCORE(HS_BANK_RUPEES) = ((HIGH_SCORE(HS_BANK_RUPEES) & 0xFFFF0000) | (rupees))) + +#define HS_GET_HIGH_SCORE_3_LOWER() (HIGH_SCORE(HS_BOAT_ARCHERY) & 0xFFFF) +#define HS_SET_HIGH_SCORE_3_LOWER(score) (HIGH_SCORE(HS_BOAT_ARCHERY) = ((HIGH_SCORE(HS_BOAT_ARCHERY) & 0xFFFF0000) | (score))) +#define HS_GET_BOAT_ARCHERY_HIGH_SCORE() ((HIGH_SCORE(HS_BOAT_ARCHERY) & 0xFFFF0000) >> 0x10) +#define HS_SET_BOAT_ARCHERY_HIGH_SCORE(score) (HIGH_SCORE(HS_BOAT_ARCHERY) = ((HIGH_SCORE(HS_BOAT_ARCHERY) & 0xFFFF) | ((u16)(score) << 0x10))) + +#define HS_GET_HORSE_BACK_BALLOON_TIME() ((s32)HIGH_SCORE(HS_HOSRE_BACK_BALLOON)) +#define HS_SET_HORSE_BACK_BALLOON_TIME(time) (HIGH_SCORE(HS_HOSRE_BACK_BALLOON) = (time)) + +#define HS_GET_LOTTERY_CODE_GUESS() (HIGH_SCORE(HS_LOTTERY_GUESS) & 0xFFFF) +#define HS_SET_LOTTERY_CODE_GUESS(guess) (HIGH_SCORE(HS_LOTTERY_GUESS) = ((HIGH_SCORE(HS_LOTTERY_GUESS) & 0xFFFF0000) | ((guess) & 0xFFFF))) + +#define HS_GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() ((s32)(HIGH_SCORE(HS_SHOOTING_GALLERY) & 0xFFFF)) +#define HS_SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(score) (HIGH_SCORE(HS_SHOOTING_GALLERY) = (HIGH_SCORE(HS_SHOOTING_GALLERY) & 0xFFFF0000) | ((u16)(score))) +#define HS_GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() ((s32)((HIGH_SCORE(HS_SHOOTING_GALLERY) & 0xFFFF0000) >> 0x10)) +#define HS_SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(score) (HIGH_SCORE(HS_SHOOTING_GALLERY) = (HIGH_SCORE(HS_SHOOTING_GALLERY) & 0xFFFF) | ((u16)(score) << 0x10)) /** * gSaveContext.save.saveInfo.weekEventReg diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index 9a2100d01e..768c0b8dc3 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -723,6 +723,5 @@ void Inventory_SaveLotteryCodeGuess(PlayState* play) { lotteryCodeGuess = ((play->msgCtx.unk12054[0] & 0xF) << 8); // First Digit lotteryCodeGuess |= ((play->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit lotteryCodeGuess |= (play->msgCtx.unk12054[2] & 0xF); // Third Digit - gSaveContext.save.saveInfo.lotteryCodeGuess = - (gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + HS_SET_LOTTERY_CODE_GUESS(lotteryCodeGuess); } diff --git a/src/code/z_message.c b/src/code/z_message.c index cf88c60df8..37e392aec7 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -67,11 +67,11 @@ void func_80147520(void) { void func_80147564(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - msgCtx->unk1204A[0] = 0xBD; - msgCtx->unk1204A[1] = 0xB8; - msgCtx->unk1204A[2] = 0xB3; - msgCtx->unk1204A[3] = 0xAE; - msgCtx->unk1204A[4] = 0xA9; + msgCtx->ocarinaButtonsPosY[OCARINA_BTN_A] = 189; + msgCtx->ocarinaButtonsPosY[OCARINA_BTN_C_DOWN] = 184; + msgCtx->ocarinaButtonsPosY[OCARINA_BTN_C_RIGHT] = 179; + msgCtx->ocarinaButtonsPosY[OCARINA_BTN_C_LEFT] = 174; + msgCtx->ocarinaButtonsPosY[OCARINA_BTN_C_UP] = 169; func_80147520(); D_801F6B0C = 0x50; D_801F6B10 = 0x96; @@ -91,7 +91,7 @@ s32 Message_ShouldAdvance(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; Input* controller = CONTROLLER1(&play->state); - if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { Audio_PlaySfx(NA_SE_SY_MESSAGE_PASS); } @@ -110,7 +110,7 @@ s32 Message_ShouldAdvanceSilent(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; Input* controller = CONTROLLER1(&play->state); - if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { return CHECK_BTN_ALL(controller->press.button, BTN_A); } else { return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || @@ -124,7 +124,7 @@ void Message_CloseTextbox(PlayState* play) { if (play->msgCtx.msgLength != 0) { msgCtx->stateTimer = 2; msgCtx->msgMode = 0x43; - msgCtx->unk12020 = 0; + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_00; Audio_PlaySfx(NA_SE_NONE); } } @@ -172,13 +172,13 @@ void func_80148B98(PlayState* play, u8 arg1) { void func_80148CBC(PlayState* play, UNK_PTR puParm2, u8 arg2) { MessageContext* msgCtx = &play->msgCtx; - msgCtx->unk11FF4 = 0x30; + msgCtx->textPosX = 0x30; if (arg2 == 1) { - msgCtx->unk11FF6 = msgCtx->unk11FFE[1 + msgCtx->choiceIndex]; + msgCtx->textPosY = msgCtx->unk11FFE[1 + msgCtx->choiceIndex]; } else { - msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex]; + msgCtx->textPosY = msgCtx->unk11FFE[msgCtx->choiceIndex]; } - func_80147818(play, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); + func_80147818(play, puParm2, msgCtx->textPosX, msgCtx->textPosY); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s") @@ -191,7 +191,7 @@ void func_80148CBC(PlayState* play, UNK_PTR puParm2, u8 arg2) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801496C8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014995C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_DrawTextChar.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s") @@ -225,11 +225,11 @@ void Message_FindMessage(PlayState* play, u16 textId) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149F74.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014AAD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_HandleOcarina.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014ADBC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_LoadItemIcon.s") void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { MessageContext* msgCtx = &play->msgCtx; @@ -239,7 +239,7 @@ void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg Font_LoadChar(play, codePointIndex, temp1); msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex; temp1 += FONT_CHAR_TEX_SIZE; - temp2 += (16.0f * msgCtx->unk12098); + temp2 += (16.0f * msgCtx->textCharScale); *offset = temp1; *arg3 = temp2; } @@ -264,7 +264,7 @@ void func_8014CCB4(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) k += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.wchar[t] = 0x815C; - f += 16.0f * msgCtx->unk12098 * 3.0f; + f += 16.0f * msgCtx->textCharScale * 3.0f; *decodedBufPos = t; *offset = k; *arg3 = f; @@ -302,7 +302,7 @@ void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { } temp_s1--; - sp3C += (stringLimit - 1) * (16.0f * msgCtx->unk12098); + sp3C += (stringLimit - 1) * (16.0f * msgCtx->textCharScale); *arg3 = temp_s1; *arg1 = temp_s2; @@ -317,15 +317,15 @@ void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor) { +void Message_StartTextbox(PlayState* play, u16 textId, Actor* actor) { MessageContext* msgCtx = &play->msgCtx; msgCtx->ocarinaAction = 0xFFFF; func_80150D08(play, textId); - msgCtx->unkActor = Actor; + msgCtx->talkActor = actor; msgCtx->msgMode = 1; msgCtx->stateTimer = 0; - msgCtx->unk12024 = 0; + msgCtx->textDelayTimer = 0; play->msgCtx.ocarinaMode = 0; } @@ -338,7 +338,7 @@ void Message_ContinueTextbox(PlayState* play, u16 textId) { func_80150A84(play); msgCtx->msgMode = 5; msgCtx->stateTimer = 8; - msgCtx->unk12024 = 0; + msgCtx->textDelayTimer = 0; if (interfaceCtx->unk_222 == 0) { if (textId != 0x1B93) { @@ -347,11 +347,11 @@ void Message_ContinueTextbox(PlayState* play, u16 textId) { func_8011552C(play, DO_ACTION_DECIDE); } } - msgCtx->unk1203C = msgCtx->unk1203A; + msgCtx->textboxColorAlphaCurrent = msgCtx->textboxColorAlphaTarget; if (play->pauseCtx.bombersNotebookOpen) { - msgCtx->unk12004 = 0x22; - msgCtx->unk12006 = 0x15E; + msgCtx->textboxXTarget = 0x22; + msgCtx->textboxYTarget = 0x15E; func_80149C18(play); msgCtx->stateTimer = 1; } @@ -365,8 +365,8 @@ void func_80151A68(PlayState* play, u16 textId) { func_80150A84(play); func_8015B198(play); msgCtx->msgMode = 0x45; - msgCtx->unk12024 = 0; - msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; + msgCtx->textDelayTimer = 0; + msgCtx->textboxColorAlphaCurrent = msgCtx->textboxColorAlphaTarget = msgCtx->textColorAlpha = 0; msgCtx->stateTimer = 30; // Day/Dawn/Night.. Messages @@ -432,12 +432,12 @@ u32 func_80151C9C(PlayState* play) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s") void func_80152434(PlayState* play, u16 arg2) { - play->msgCtx.unk12046 = 0; + play->msgCtx.blockSunsSong = false; func_80151DA4(play, arg2); } void func_80152464(PlayState* play, u16 arg1) { - play->msgCtx.unk12046 = 1; + play->msgCtx.blockSunsSong = true; func_80151DA4(play, arg1); } @@ -450,32 +450,33 @@ u8 Message_GetState(MessageContext* msgCtx) { } if (msgCtx->msgMode == 0x42) { - if (msgCtx->unk11F14 != 0xFFFF) { + if (msgCtx->nextTextId != 0xFFFF) { return TEXT_STATE_1; } - if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { return TEXT_STATE_CHOICE; } - if ((msgCtx->unk12020 == 0x40) || (msgCtx->unk12020 == 0x42) || (msgCtx->unk12020 == 0x30)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_40) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_42) || + (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_30)) { return TEXT_STATE_5; } - if (msgCtx->unk12020 == 0x41) { + if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_41) { return TEXT_STATE_16; } - if ((msgCtx->unk12020 >= 0x50) && (msgCtx->unk12020 < 0x58)) { + if ((msgCtx->textboxEndType >= TEXTBOX_ENDTYPE_50) && (msgCtx->textboxEndType <= TEXTBOX_ENDTYPE_57)) { return TEXT_STATE_3; } - if ((msgCtx->unk12020 == 0x60) || (msgCtx->unk12020 == 0x61)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_60) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_61)) { return TEXT_STATE_14; } - if (msgCtx->unk12020 == 0x62) { + if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_62) { return TEXT_STATE_15; } - if (msgCtx->unk12020 == 0x63) { + if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_63) { return TEXT_STATE_17; } - if (msgCtx->unk12020 == 0x12) { + if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_12) { return TEXT_STATE_18; } return TEXT_STATE_DONE; @@ -526,7 +527,7 @@ void func_80152EC0(PlayState* play) { if (1) {} if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) && ((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) { - msgCtx->unk120B0 = 1; + msgCtx->ocarinaSongEffectActive = true; if (msgCtx->songPlayed != 0x16) { Actor_Spawn(&play->actorCtx, play, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]); @@ -541,16 +542,14 @@ void func_80152EC0(PlayState* play) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") -void func_80153E7C(PlayState* play, void* arg1) { - if ((gSaveContext.options.language == 0) && (play->msgCtx.unk12090 == 0)) { - func_8014ADBC(play, arg1); - return; +void func_80153E7C(PlayState* play, Gfx** gfxP) { + if ((gSaveContext.options.language == 0) && !play->msgCtx.textIsCredits) { + func_8014ADBC(play, gfxP); + } else if (play->msgCtx.textIsCredits) { + Message_DrawTextCredits(play, gfxP); + } else { + func_8015966C(play, gfxP, 0); } - if (play->msgCtx.unk12090 != 0) { - func_8015E7EC(play, arg1); - return; - } - func_8015966C(play, arg1, 0); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s") @@ -586,39 +585,39 @@ void func_801586A4(PlayState* play) { void Message_Init(PlayState* play) { Font* font; - MessageContext* messageCtx = &play->msgCtx; + MessageContext* msgCtx = &play->msgCtx; func_801586A4(play); play->msgCtx.ocarinaMode = 0; - messageCtx->msgMode = 0; - messageCtx->msgLength = 0; - messageCtx->currentTextId = 0; - messageCtx->unk12020 = 0; - messageCtx->choiceIndex = 0; - messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0; - messageCtx->unk1201E = 0xFF; - View_Init(&messageCtx->view, play->state.gfxCtx); - messageCtx->unk11EF8 = THA_AllocTailAlign16(&play->state.heap, 0x13C00); + msgCtx->msgMode = 0; + msgCtx->msgLength = 0; + msgCtx->currentTextId = 0; + msgCtx->textboxEndType = 0; + msgCtx->choiceIndex = 0; + msgCtx->ocarinaAction = msgCtx->textUnskippable = 0; + msgCtx->textColorAlpha = 0xFF; + View_Init(&msgCtx->view, play->state.gfxCtx); + msgCtx->textboxSegment = THA_AllocTailAlign16(&play->state.heap, 0x13C00); font = &play->msgCtx.font; Font_LoadOrderedFont(&play->msgCtx.font); font->unk_11D88 = 0; - messageCtx->unk12090 = messageCtx->unk12092 = 0; - messageCtx->unk12094 = 0; - messageCtx->unk1209C = 0; - messageCtx->unk120A0 = 0; - messageCtx->unk12068 = 0x34; - messageCtx->unk1206A = 0x24; - messageCtx->unk120B0 = 0; - messageCtx->unk120BE = 0; - messageCtx->unk120C0 = 0; - messageCtx->unk120C2 = 0; - messageCtx->unk120C4 = 0; - messageCtx->unk120C8 = 0; - messageCtx->unk120CA = 0; - messageCtx->unk120CC = 0; - messageCtx->unk120CE = 0; - messageCtx->unk120D0 = 0; - messageCtx->unk120D2 = 0; - messageCtx->unk120D4 = 0; - messageCtx->unk120D6 = 0; + msgCtx->textIsCredits = msgCtx->messageHasSetSfx = false; + msgCtx->textboxSkipped = 0; + msgCtx->textFade = 0; + msgCtx->ocarinaAvailableSongs = 0; + msgCtx->textboxX = 0x34; + msgCtx->textboxY = 0x24; + msgCtx->ocarinaSongEffectActive = false; + msgCtx->unk120BE = 0; + msgCtx->unk120C0 = 0; + msgCtx->unk120C2 = 0; + msgCtx->unk120C4 = 0; + msgCtx->unk120C8 = 0; + msgCtx->unk120CA = 0; + msgCtx->unk120CC = 0; + msgCtx->unk120CE = 0; + msgCtx->unk120D0 = 0; + msgCtx->unk120D2 = 0; + msgCtx->unk120D4 = 0; + msgCtx->unk120D6 = 0; } diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 759c3d6119..1dcb16474b 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -91,7 +91,7 @@ void Message_LoadCharNES(PlayState* play, u8 codePointIndex, s32* offset, f32* a Font_LoadCharNES(play, codePointIndex, temp1); msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex; temp1 += FONT_CHAR_TEX_SIZE; - temp2 += (16.0f * msgCtx->unk12098); + temp2 += (16.0f * msgCtx->textCharScale); *offset = temp1; *arg3 = temp2; } @@ -128,7 +128,7 @@ void Message_LoadPluralRupeesNES(PlayState* play, s16* decodedBufPos, s32* offse o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 's'; - f += 16.0f * msgCtx->unk12098 * 6.0f; + f += 16.0f * msgCtx->textCharScale * 6.0f; *decodedBufPos = p; *offset = o; *arg3 = f; @@ -152,7 +152,7 @@ void Message_LoadLocalizedRupeesNES(PlayState* play, s16* decodedBufPos, s32* of } p--; - f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.options.language - 1] + 1); + f += 16.0f * msgCtx->textCharScale * (D_801D0710[gSaveContext.options.language - 1] + 1); *decodedBufPos = p; *offset = o; *arg3 = f; @@ -191,9 +191,9 @@ void Message_LoadRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32 Font_LoadCharNES(play, 's', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 's'; - f += 16.0f * msgCtx->unk12098 * 6.0f; + f += 16.0f * msgCtx->textCharScale * 6.0f; } else { - f += 16.0f * msgCtx->unk12098 * 5.0f; + f += 16.0f * msgCtx->textCharScale * 5.0f; } *decodedBufPos = p; @@ -246,7 +246,7 @@ void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* } } - f += 5.0f * (16.0f * msgCtx->unk12098); + f += 5.0f * (16.0f * msgCtx->textCharScale); *decodedBufPos = p - 1; *offset = o; *arg3 = f; @@ -278,11 +278,11 @@ void Message_LoadOwlWarpTextNES(PlayState* play, s32* offset, f32* arg2, s16* de } currentChar = msgCtx->decodedBuffer.schar[p]; p++; - f += (D_801D0470[currentChar - ' '] * msgCtx->unk12098); + f += (D_801D0470[currentChar - ' '] * msgCtx->textCharScale); } p--; - f += (stringLimit - 1) * (16.0f * msgCtx->unk12098); + f += (stringLimit - 1) * (16.0f * msgCtx->textCharScale); *decodedBufPos = p; *offset = o; *arg2 = f; diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index ab30a3d9c6..a093ef5c1c 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -17,12 +17,660 @@ void Message_FindCreditsMessage(PlayState* play, u16 textId) { nextSegment = msgEntry->segment; font->messageStart = foundSegment - segment; font->messageEnd = nextSegment - foundSegment; - return; + break; } msgEntry++; } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E7EC.s") +f32 sCreditsFontWidths[144] = { + 8.0f, 8.0f, 6.0f, 9.0f, 9.0f, 14.0f, 12.0f, 3.0f, 7.0f, 7.0f, 7.0f, 9.0f, 4.0f, 6.0f, 4.0f, 9.0f, + 10.0f, 5.0f, 9.0f, 9.0f, 10.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 6.0f, 6.0f, 9.0f, 11.0f, 9.0f, 11.0f, + 13.0f, 12.0f, 9.0f, 11.0f, 11.0f, 8.0f, 8.0f, 12.0f, 10.0f, 4.0f, 8.0f, 10.0f, 8.0f, 13.0f, 11.0f, 13.0f, + 9.0f, 13.0f, 10.0f, 10.0f, 9.0f, 10.0f, 11.0f, 15.0f, 11.0f, 10.0f, 10.0f, 7.0f, 10.0f, 7.0f, 10.0f, 9.0f, + 5.0f, 8.0f, 9.0f, 8.0f, 9.0f, 9.0f, 6.0f, 9.0f, 8.0f, 4.0f, 6.0f, 8.0f, 4.0f, 12.0f, 9.0f, 9.0f, + 9.0f, 9.0f, 7.0f, 8.0f, 7.0f, 8.0f, 9.0f, 12.0f, 8.0f, 9.0f, 8.0f, 7.0f, 5.0f, 7.0f, 10.0f, 10.0f, + 12.0f, 12.0f, 12.0f, 12.0f, 11.0f, 8.0f, 8.0f, 8.0f, 6.0f, 6.0f, 13.0f, 13.0f, 10.0f, 10.0f, 10.0f, 9.0f, + 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 9.0f, 9.0f, 9.0f, 9.0f, 6.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 14.0f, + 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015F8A8.s") +#ifdef NON_MATCHING +// https://decomp.me/scratch/yc8Or +// v0/v1 swap between `character` and `i` +void Message_DrawTextCredits(PlayState* play, Gfx** gfxP) { + MessageContext* msgCtx = &play->msgCtx; + u16 lookAheadCharacter; + u16 j; + u16 i; + u16 sfxHi; + char character; + u16 charTexIndex; + Font* font = &msgCtx->font; + Gfx* gfx = *gfxP; + + msgCtx->textPosX = msgCtx->unk11FF8; + + if (!msgCtx->textIsCredits) { + msgCtx->textPosY = msgCtx->unk11FFA; + } else { + msgCtx->textPosY = 48; + } + + if (msgCtx->textBoxType == TEXTBOX_TYPE_5) { + msgCtx->textColorR = msgCtx->textColorG = msgCtx->textColorB = 0; + } else { + msgCtx->textColorR = msgCtx->textColorG = msgCtx->textColorB = 255; + } + + charTexIndex = 0; + + for (i = 0; i < msgCtx->textDrawPos; i++) { + character = msgCtx->decodedBuffer.schar[i]; + + switch (character) { + case 0x1: // MESSAGE_NEWLINE + msgCtx->textPosX = msgCtx->unk11FF8; + if ((msgCtx->choiceNum == 1) || (msgCtx->choiceNum == 3)) { + msgCtx->textPosX += 32; + } + if ((msgCtx->choiceNum == 2) && (msgCtx->textPosY != msgCtx->unk11FFA)) { + msgCtx->textPosX += 32; + } + msgCtx->textPosY += msgCtx->unk11FFC; + break; + + case 0x5: // Remnant of MESSAGE_COLOR + break; + + case ' ': + msgCtx->textPosX += 6; + break; + + case 0x4: // MESSAGE_BOX_BREAK + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + if (!msgCtx->textboxSkipped) { + Audio_PlaySfx(NA_SE_NONE); + msgCtx->msgMode = MSGMODE_TEXT_AWAIT_NEXT; + Font_LoadMessageBoxEndIcon(font, 0); + } else { + msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG; + msgCtx->textUnskippable = false; + msgCtx->msgBufPos++; + } + } + *gfxP = gfx; + return; + + case 0x6: // MESSAGE_SHIFT + msgCtx->textPosX += msgCtx->decodedBuffer.schar[++i]; + break; + + case 0x7: // MESSAGE_TEXTID + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_20; + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Audio_PlaySfx(NA_SE_NONE); + msgCtx->msgMode = MSGMODE_TEXT_DONE; + Font_LoadMessageBoxEndIcon(font, 0); + } + *gfxP = gfx; + return; + + case 0x8: // MESSAGE_QUICKTEXT_ENABLE + if (((i + 1) == msgCtx->textDrawPos) && + ((msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) || + ((msgCtx->msgMode >= MSGMODE_OCARINA_STARTING) && (msgCtx->msgMode <= MSGMODE_26)))) { + j = i; + while (true) { + lookAheadCharacter = msgCtx->decodedBuffer.schar[j]; + if (lookAheadCharacter == 6) { + j += 2; + continue; + } + if ((lookAheadCharacter != 9) && (lookAheadCharacter != 0xA) && (lookAheadCharacter != 0xB) && + (lookAheadCharacter != 0xC) && (lookAheadCharacter != 0xD) && (lookAheadCharacter != 4) && + (lookAheadCharacter != 2)) { + j++; + continue; + } + break; + } + i = j - 1; + msgCtx->textDrawPos = i + 1; + } + // fallthrough + case 0x9: // MESSAGE_QUICKTEXT_DISABLE + break; + + case 0xD: // MESSAGE_AWAIT_BUTTON_PRESS + if ((i + 1) == msgCtx->textDrawPos) { + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_AWAIT_INPUT; + Font_LoadMessageBoxEndIcon(font, 0); + } + *gfxP = gfx; + return; + } + break; + + case 0xC: // MESSAGE_BOX_BREAK_DELAYED + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->stateTimer = msgCtx->decodedBuffer.schar[++i]; + msgCtx->msgMode = MSGMODE_TEXT_DELAYED_BREAK; + } + *gfxP = gfx; + return; + + case 0x11: // MESSAGE_FADE2 + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_50; + msgCtx->stateTimer = msgCtx->decodedBuffer.schar[++i] << 8; + msgCtx->stateTimer |= msgCtx->decodedBuffer.schar[++i]; + } + *gfxP = gfx; + return; + + case 0x12: // MESSAGE_SFX + if ((msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) && !msgCtx->messageHasSetSfx) { + msgCtx->messageHasSetSfx = true; + sfxHi = msgCtx->decodedBuffer.schar[i + 1]; + sfxHi = sfxHi << 8; + Audio_PlaySfx(sfxHi | msgCtx->decodedBuffer.schar[i + 2]); + } + i += 2; + break; + + case 0x13: // remnant of MESSAGE_ITEM_ICON + break; + + case 0x15: // MESSAGE_BACKGROUND + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Audio_PlaySfx(NA_SE_NONE); + } + gDPPipeSync(gfx++); + gDPSetCombineMode(gfx++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, msgCtx->textColorAlpha); + + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1000, G_IM_FMT_I, 96, 48, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(gfx++, (msgCtx->textPosX + 1) << 2, (msgCtx->unk12012 + 1) << 2, + (msgCtx->textPosX + 0x61) << 2, (msgCtx->unk12012 + 0x31) << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1900, G_IM_FMT_I, 96, 48, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(gfx++, (msgCtx->textPosX + 0x61) << 2, (msgCtx->unk12012 + 1) << 2, + (msgCtx->textPosX + 0xC2) << 2, (msgCtx->unk12012 + 0x31) << 2, 0, 0, 0, 1 << 10, + 1 << 10); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, 255, 60, 0, msgCtx->textColorAlpha); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1000, G_IM_FMT_I, 96, 48, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(gfx++, msgCtx->textPosX << 2, msgCtx->unk12012 << 2, (msgCtx->textPosX + 0x60) << 2, + (msgCtx->unk12012 + 0x30) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1900, G_IM_FMT_I, 96, 48, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(gfx++, (msgCtx->textPosX + 0x60) << 2, msgCtx->unk12012 << 2, + (msgCtx->textPosX + 0xC0) << 2, (msgCtx->unk12012 + 0x30) << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + gDPPipeSync(gfx++); + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + msgCtx->textPosX += 0x20; + break; + + case 0x14: // MESSAGE_TEXT_SPEED + msgCtx->textDelay = msgCtx->decodedBuffer.schar[++i]; + break; + + case 0x1A: // MESSAGE_UNSKIPPABLE + msgCtx->textUnskippable = true; + break; + + case 0x1B: // MESSAGE_TWO_CHOICE + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_10; + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->choiceTextId = msgCtx->currentTextId; + msgCtx->stateTimer = 4; + msgCtx->choiceIndex = 0; + Font_LoadMessageBoxEndIcon(font, 2); + } + break; + + case 0x1C: // MESSAGE_THREE_CHOICE + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_11; + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->choiceTextId = msgCtx->currentTextId; + msgCtx->stateTimer = 4; + msgCtx->choiceIndex = 0; + Font_LoadMessageBoxEndIcon(font, 2); + } + break; + + case 0x2: // MESSAGE_END + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_00) { + Audio_PlaySfx(NA_SE_SY_MESSAGE_END); + Font_LoadMessageBoxEndIcon(font, 1); + if (play->csCtx.state == CS_STATE_IDLE) { + func_8011552C(play, DO_ACTION_RETURN); + } + } + } + *gfxP = gfx; + return; + + case 0x10: // MESSAGE_OCARINA + if ((i + 1) == msgCtx->textDrawPos) { + Message_HandleOcarina(play); + *gfxP = gfx; + return; + } + break; + + case 0xE: // MESSAGE_FADE + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_50; + msgCtx->stateTimer = msgCtx->decodedBuffer.schar[++i]; + Font_LoadMessageBoxEndIcon(font, 1); + if (play->csCtx.state == CS_STATE_IDLE) { + func_8011552C(play, DO_ACTION_RETURN); + } + } + *gfxP = gfx; + return; + + case 0xA: // MESSAGE_PERSISTENT + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Audio_PlaySfx(NA_SE_NONE); + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_30; + } + *gfxP = gfx; + return; + + case 0xB: // MESSAGE_EVENT + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = TEXTBOX_ENDTYPE_40; + Font_LoadMessageBoxEndIcon(font, 0); + Audio_PlaySfx(NA_SE_SY_MESSAGE_END); + } + *gfxP = gfx; + return; + + default: + if ((msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) && ((i + 1) == msgCtx->textDrawPos) && + (msgCtx->textDelayTimer == msgCtx->textDelay)) { + Audio_PlaySfx(NA_SE_NONE); + } + Message_DrawTextChar(play, &font->charBuf[font->unk_11D88][charTexIndex], &gfx); + charTexIndex += FONT_CHAR_TEX_SIZE; + + msgCtx->textPosX += (s32)(sCreditsFontWidths[character - ' '] * msgCtx->textCharScale); + break; + } + } + + if (msgCtx->textDelayTimer == 0) { + msgCtx->textDrawPos = i + 1; + msgCtx->textDelayTimer = msgCtx->textDelay; + } else { + msgCtx->textDelayTimer--; + } + + *gfxP = gfx; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/Message_DrawTextCredits.s") +#endif + +void Message_DecodeCredits(PlayState* play) { + u16 curChar; + s16 loadChar; + s16 i; + s16 playerNameLen; + s16 decodedBufPos = 0; + s16 charOffset; + f32 timeInSeconds; + s16 numLines = 0; + s16 value; + s16 digits[4]; + s32 charTexIdx = 0; + MessageContext* msgCtx = &play->msgCtx; + Font* font = &play->msgCtx.font; + + msgCtx->nextTextId = 0xFFFF; + + while (true) { + curChar = font->msgBuf.schar[msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos]; + + if ((curChar == 4) || (curChar == 7) || (curChar == 0xC) || (curChar == 0xB) || (curChar == 2)) { + // Textbox decoding ends with any of the above text control characters + msgCtx->msgMode = MSGMODE_TEXT_DISPLAYING; + msgCtx->textDrawPos = 1; + msgCtx->unk11FFA = msgCtx->textboxY + 8; + + if (msgCtx->textBoxType != TEXTBOX_TYPE_4) { + if (numLines == 0) { + msgCtx->unk11FFA = msgCtx->textboxY + 26; + } else if (numLines == 1) { + msgCtx->unk11FFA = msgCtx->textboxY + 20; + } else if (numLines == 2) { + msgCtx->unk11FFA = msgCtx->textboxY + 16; + } + } + + if (curChar == 7) { + value = font->msgBuf.schar[msgCtx->msgBufPos + 1]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos + 1]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos + 2]; + value <<= 8; + msgCtx->nextTextId = msgCtx->decodedBuffer.schar[decodedBufPos] | value; + } + + if (curChar == 0xC) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos + 1]; + msgCtx->msgBufPos += 2; + } + + msgCtx->decodedTextLen = decodedBufPos; + + if (msgCtx->textboxSkipped) { + msgCtx->textDrawPos = msgCtx->decodedTextLen; + } + break; + } else if (curChar == 0xF) { + // Substitute the player name control character for the file's player name. + for (playerNameLen = ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); playerNameLen > 0; + playerNameLen--) { + if (gSaveContext.save.saveInfo.playerData.playerName[playerNameLen - 1] != 0x3E) { + break; + } + } + + for (i = 0; i < playerNameLen; i++) { + curChar = gSaveContext.save.saveInfo.playerData.playerName[i]; + if (curChar == 62) { + curChar = ' '; + } else if (curChar == 64) { + curChar = '.'; + } else if (curChar == 63) { + curChar = '-'; + } else if (curChar < 10) { + charOffset = curChar; + curChar = '0' + charOffset; + } else if (curChar < 36) { + charOffset = curChar; + curChar = 'A' - 10 + charOffset; + } else if (curChar < 62) { + charOffset = curChar; + curChar = 'a' - 36 + charOffset; + } + + if (curChar != ' ') { + Font_LoadCharNES(play, curChar - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + } + msgCtx->decodedBuffer.schar[decodedBufPos] = curChar; + decodedBufPos++; + } + decodedBufPos--; + } else if ((curChar == 0x16) || (curChar == 0x17)) { + digits[0] = digits[1] = digits[2] = 0; + if (curChar == 0x17) { + digits[3] = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; + } else { + digits[3] = gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED]; + } + + while (digits[3] >= 60) { + digits[1]++; + if (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + digits[3] -= 60; + } + + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(play, digits[i] + '0' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + if (i == 1) { + Font_LoadCharNES(play, '"' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = '"'; + decodedBufPos++; + } else if (i == 3) { + Font_LoadCharNES(play, '"' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = '"'; + } + } + + } else if (curChar == 0x18) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = gSaveContext.minigameScore; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0' - ' ', charTexIdx); + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + charTexIdx += FONT_CHAR_TEX_SIZE; + decodedBufPos++; + } + } + decodedBufPos--; + } else if (curChar != 0x19) { + if (curChar == 0x1D) { + digits[0] = 0; + digits[1] = gSaveContext.minigameScore; + + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + for (i = 0; i < 2; i++) { + if ((i == 1) || (digits[i] != 0)) { + Font_LoadCharNES(play, digits[i] + '0' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + } + } + decodedBufPos--; + } else if (curChar == 0x1E) { + value = HIGH_SCORE((u8)font->msgBuf.schar[++msgCtx->msgBufPos]); + if ((font->msgBuf.schar[msgCtx->msgBufPos] & 0xFF) == HS_FISHING) { + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + value &= 0x7F; + } else { + value = + (s16)((HIGH_SCORE((u8)font->msgBuf.schar[msgCtx->msgBufPos]) & 0xFF000000) >> 0x18) & 0x7F; + } + value = SQ((f32)value) * 0.0036f + 0.5f; + } + switch (font->msgBuf.schar[msgCtx->msgBufPos] & 0xFF) { + case 0: + case 1: + case 2: + digits[0] = digits[1] = digits[2] = 0; + digits[3] = value; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0' - ' ', charTexIdx); + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + charTexIdx += FONT_CHAR_TEX_SIZE; + decodedBufPos++; + } + } + decodedBufPos--; + break; + + case 3: + case 4: + case 6: + digits[0] = digits[1] = digits[2] = 0; + digits[3] = value; + + while (digits[3] >= 60) { + digits[1]++; + if (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + digits[3] -= 60; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(play, digits[i] + '0' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + if (i == 1) { + Font_LoadCharNES(play, '"' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = '"'; + decodedBufPos++; + } else if (i == 3) { + Font_LoadCharNES(play, '"' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = '"'; + } + } + break; + + default: + break; + } + } else if (curChar == 0x1F) { + digits[0] = 0; + timeInSeconds = TIME_TO_MINUTES_F(gSaveContext.save.time); + + digits[1] = timeInSeconds / 60.0f; + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + digits[2] = 0; + digits[3] = (s32)timeInSeconds % 60; + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(play, digits[i] + '0' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + if (i == 1) { + Font_LoadCharNES(play, ':' - ' ', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = ':'; + decodedBufPos++; + } + } + + decodedBufPos--; + } else if (curChar == 0x13) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos + 1]; + Message_LoadItemIcon(play, font->msgBuf.schar[msgCtx->msgBufPos + 1], msgCtx->textboxY + 10); + } else if (curChar == 0x15) { + DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1000, + (uintptr_t)SEGMENT_ROM_START(message_texture_static) + 0x900, 0x900); + DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1900, + (uintptr_t)SEGMENT_ROM_START(message_texture_static) + 0x900, 0x900); + msgCtx->msgBufPos += 3; + msgCtx->unk12012 = msgCtx->textboxY + 8; + numLines = 2; + } else if (curChar == 5) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + } else if (curChar == 1) { + numLines++; + } else if ((curChar != 8) && (curChar != 9) && (curChar != 0xD) && (curChar != 0x10) && (curChar != 0xA) && + (curChar != 0x1A)) { + if (curChar == 0xE) { + msgCtx->textFade = true; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + } else if (curChar == 0x11) { + msgCtx->textFade = true; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + } else if ((curChar == 6) || (curChar == 0x14)) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos] & 0xFF; + } else if (curChar == 0x12) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + } else if (curChar == 0x1B) { + msgCtx->choiceNum = 2; + } else if (curChar == 0x1C) { + msgCtx->choiceNum = 3; + } else if (curChar != ' ') { + Font_LoadCharNES(play, curChar, charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + } + } + } + + decodedBufPos++; + msgCtx->msgBufPos++; + } +} diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index a3dc07aafe..2c4106e057 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -6870,7 +6870,7 @@ void Interface_Update(PlayState* play) { interfaceCtx->aButtonRoll = -15700.0f; interfaceCtx->aButtonState = A_BTN_STATE_2; - if ((msgCtx->msgMode != 0) && (msgCtx->unk12006 == 0x26)) { + if ((msgCtx->msgMode != 0) && (msgCtx->textboxYTarget == 0x26)) { R_A_BTN_Y_OFFSET = -14; } else { R_A_BTN_Y_OFFSET = 0; diff --git a/src/code/z_play.c b/src/code/z_play.c index 9bb8d5817b..44efbfbfbf 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -961,9 +961,9 @@ void Play_UpdateMain(PlayState* this) { Play_UpdateTransition(this); if (gTransitionTileState != TRANS_TILE_READY) { if ((gSaveContext.gameMode == GAMEMODE_NORMAL) && - (((this->msgCtx.msgMode == 0)) || - ((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == 0x42) && - (this->msgCtx.unk12020 == 0x41)) || + (((this->msgCtx.msgMode == MSGMODE_NONE)) || + ((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == MSGMODE_TEXT_DONE) && + (this->msgCtx.textboxEndType == TEXTBOX_ENDTYPE_41)) || ((this->msgCtx.currentTextId >= 0x100) && (this->msgCtx.currentTextId <= 0x200))) && (this->gameOverCtx.state == GAMEOVER_INACTIVE)) { KaleidoSetup_Update(this); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index a890090ff6..2e36ea553f 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -620,7 +620,7 @@ PlayerItemAction func_80123810(PlayState* play) { if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B)) { play->interfaceCtx.unk_222 = 0; play->interfaceCtx.unk_224 = 0; - Interface_SetHudVisibility(play->msgCtx.unk_120BC); + Interface_SetHudVisibility(play->msgCtx.hudVisibility); return PLAYER_IA_MINUS1; } } else { @@ -634,7 +634,7 @@ PlayerItemAction func_80123810(PlayState* play) { play->interfaceCtx.unk_222 = 0; play->interfaceCtx.unk_224 = 0; - Interface_SetHudVisibility(play->msgCtx.unk_120BC); + Interface_SetHudVisibility(play->msgCtx.hudVisibility); if ((itemId >= ITEM_FD) || ((itemAction = play->unk_18794(play, player, itemId)) <= PLAYER_IA_MINUS1)) { Audio_PlaySfx(NA_SE_SY_ERROR); diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 7683144909..198dac4e97 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -396,11 +396,11 @@ void Sram_ActivateOwl(u8 owlId) { } void Sram_ClearHighscores(void) { - gSaveContext.save.saveInfo.unk_EC4 = (gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF) | 0x130000; - gSaveContext.save.saveInfo.unk_EC4 = (gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF0000) | 0xA; - gSaveContext.save.saveInfo.horseBackBalloonHighScore = SECONDS_TO_TIMER(60); - SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(39); - SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(10); + HS_SET_BOAT_ARCHERY_HIGH_SCORE(19); + HS_SET_HIGH_SCORE_3_LOWER(10); + HS_SET_HORSE_BACK_BALLOON_TIME(SECONDS_TO_TIMER(60)); + HS_SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(39); + HS_SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(10); gSaveContext.save.saveInfo.dekuPlaygroundHighScores[0] = SECONDS_TO_TIMER(75); gSaveContext.save.saveInfo.dekuPlaygroundHighScores[1] = SECONDS_TO_TIMER(75); diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 4ae5482bf5..39269c2ac3 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -835,8 +835,7 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { thisx->flags |= (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY); if (sLinkAge != 1) { - // HIGH_SCORE(HS_FISHING) from OoT - if (gSaveContext.save.saveInfo.unk_EC0 & 0x1000) { + if (HIGH_SCORE(HS_FISHING) & 0x1000) { D_8090CD08 = 0; } else { D_8090CD08 = 1; @@ -854,18 +853,18 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); if (sLinkAge == 1) { - if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F) { - D_809171CC = gSaveContext.save.saveInfo.unk_EC0 & 0x7F; + if (HIGH_SCORE(HS_FISHING) & 0x7F) { + D_809171CC = HIGH_SCORE(HS_FISHING) & 0x7F; } else { D_809171CC = 40.0f; } - } else if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) { - D_809171CC = (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) >> 0x18; + } else if (HIGH_SCORE(HS_FISHING) & 0x7F000000) { + D_809171CC = (HIGH_SCORE(HS_FISHING) & 0x7F000000) >> 0x18; } else { D_809171CC = 45.0f; } - D_809171D1 = (gSaveContext.save.saveInfo.unk_EC0 & 0xFF0000) >> 0x10; + D_809171D1 = (HIGH_SCORE(HS_FISHING) & 0xFF0000) >> 0x10; if ((D_809171D1 & 7) == 7) { play->roomCtx.unk7A[0] = 90; D_809171CA = 1; @@ -2799,8 +2798,8 @@ void func_80903C60(EnFishing* this, u8 arg1) { void EnFishing_HandleAquariumDialog(EnFishing* this, PlayState* play) { if (sLinkAge == 1) { - if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F) { - if (gSaveContext.save.saveInfo.unk_EC0 & 0x80) { + if (HIGH_SCORE(HS_FISHING) & 0x7F) { + if (HIGH_SCORE(HS_FISHING) & 0x80) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2808,8 +2807,8 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, PlayState* play) { } else { this->actor.textId = 0x40AE; } - } else if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) { - if (gSaveContext.save.saveInfo.unk_EC0 & 0x80000000) { + } else if (HIGH_SCORE(HS_FISHING) & 0x7F000000) { + if (HIGH_SCORE(HS_FISHING) & 0x80000000) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -3749,8 +3748,8 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { if ((D_80917272 == 0) && (D_80917274 == 0)) { // Assignment of OoT's D_80B7E086 here removed in MM - if (((sLinkAge == 1) && (gSaveContext.save.saveInfo.unk_EC0 & 0x400)) || - ((sLinkAge != 1) && (gSaveContext.save.saveInfo.unk_EC0 & 0x800))) { + if (((sLinkAge == 1) && (HIGH_SCORE(HS_FISHING) & 0x400)) || + ((sLinkAge != 1) && (HIGH_SCORE(HS_FISHING) & 0x800))) { // Assignment of OoT's D_80B7A67C here removed in MM, this is now an empty branch } } else { @@ -4694,7 +4693,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 0: if (D_809171FC == 0) { if (sLinkAge != 1) { - if ((gSaveContext.save.saveInfo.unk_EC0 & 0x100) && !(gSaveContext.save.saveInfo.unk_EC0 & 0x200)) { + if ((HIGH_SCORE(HS_FISHING) & 0x100) && !(HIGH_SCORE(HS_FISHING) & 0x200)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4712,9 +4711,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { if (D_809171FC == 0) { this->unk_154 = 1; if (sLinkAge != 1) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x200; + HIGH_SCORE(HS_FISHING) |= 0x200; } else { - gSaveContext.save.saveInfo.unk_EC0 |= 0x100; + HIGH_SCORE(HS_FISHING) |= 0x100; } } else { this->unk_154 = 10; @@ -4805,8 +4804,8 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { D_8090CD04 = 20; this->unk_154 = 0; - if ((gSaveContext.save.saveInfo.unk_EC0 & 0xFF0000) < 0xFF0000) { - gSaveContext.save.saveInfo.unk_EC0 += 0x10000; + if ((HIGH_SCORE(HS_FISHING) & 0xFF0000) < 0xFF0000) { + HIGH_SCORE(HS_FISHING) += 0x10000; } } break; @@ -4924,29 +4923,29 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { if (sLinkAge == 1) { f32 temp; - gSaveContext.save.saveInfo.unk_EC0 &= 0xFFFFFF00; - gSaveContext.save.saveInfo.unk_EC0 |= ((s16)D_809171CC & 0x7F); - temp = (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) >> 0x18; + HIGH_SCORE(HS_FISHING) &= 0xFFFFFF00; + HIGH_SCORE(HS_FISHING) |= ((s16)D_809171CC & 0x7F); + temp = (HIGH_SCORE(HS_FISHING) & 0x7F000000) >> 0x18; if (temp < D_809171CC) { - gSaveContext.save.saveInfo.unk_EC0 &= 0xFFFFFF; - gSaveContext.save.saveInfo.unk_EC0 |= ((s16)D_809171CC & 0x7F) << 0x18; + HIGH_SCORE(HS_FISHING) &= 0xFFFFFF; + HIGH_SCORE(HS_FISHING) |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x80000000; + HIGH_SCORE(HS_FISHING) |= 0x80000000; } } if (D_809171D2 == 2) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x80; + HIGH_SCORE(HS_FISHING) |= 0x80; this->unk_154 = 0; break; } } else { - gSaveContext.save.saveInfo.unk_EC0 &= 0xFFFFFF; - gSaveContext.save.saveInfo.unk_EC0 |= ((s16)D_809171CC & 0x7F) << 0x18; + HIGH_SCORE(HS_FISHING) &= 0xFFFFFF; + HIGH_SCORE(HS_FISHING) |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x80000000; + HIGH_SCORE(HS_FISHING) |= 0x80000000; this->unk_154 = 0; break; } @@ -4963,14 +4962,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { } if (sLinkAge == 1) { - if ((D_809171CC >= 50.0f) && !(gSaveContext.save.saveInfo.unk_EC0 & 0x400)) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x400; + if ((D_809171CC >= 50.0f) && !(HIGH_SCORE(HS_FISHING) & 0x400)) { + HIGH_SCORE(HS_FISHING) |= 0x400; getItemId = GI_HEART_PIECE; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } } else { - if ((D_809171CC >= 60.0f) && !(gSaveContext.save.saveInfo.unk_EC0 & 0x800)) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x800; + if ((D_809171CC >= 60.0f) && !(HIGH_SCORE(HS_FISHING) & 0x800)) { + HIGH_SCORE(HS_FISHING) |= 0x800; getItemId = GI_SKULL_TOKEN; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } @@ -5140,9 +5139,9 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { } if (D_8090CD08 == 0) { - gSaveContext.save.saveInfo.unk_EC0 |= 0x1000; + HIGH_SCORE(HS_FISHING) |= 0x1000; } else if (D_8090CD08 == 1) { - gSaveContext.save.saveInfo.unk_EC0 &= ~0x1000; + HIGH_SCORE(HS_FISHING) &= ~0x1000; } if (D_8090CCFC != 0) { diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index f106aa4069..917624a645 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -126,7 +126,7 @@ static Vec3f sShopItemPositions[3] = { s32 EnFsn_TestItemSelected(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A); } return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 387763de11..ea3f9fea2e 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -89,7 +89,7 @@ void EnGinkoMan_Idle(EnGinkoMan* this, PlayState* play) { EnGinkoMan_SwitchAnimation(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { + if (HS_GET_BANK_RUPEES() == 0) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); Message_StartTextbox(play, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account @@ -154,7 +154,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); } - play->msgCtx.bankRupees = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; + play->msgCtx.bankRupees = HS_GET_BANK_RUPEES(); Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; } @@ -167,22 +167,22 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { break; case 0x45A: - if (((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && + if ((HS_GET_BANK_RUPEES() >= 200) && (this->previousBankValue < 200) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_40)) { SET_WEEKEVENTREG(WEEKEVENTREG_59_40); Message_StartTextbox(play, 0x45B, &this->actor); this->curTextId = 0x45B; - } else if (((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 1000) && - ((this->previousBankValue) < 1000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_80)) { + } else if ((HS_GET_BANK_RUPEES() >= 1000) && ((this->previousBankValue) < 1000) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_80)) { SET_WEEKEVENTREG(WEEKEVENTREG_59_80); Message_StartTextbox(play, 0x45C, &this->actor); this->curTextId = 0x45C; - } else if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 5000) { + } else if (HS_GET_BANK_RUPEES() >= 5000) { if ((this->previousBankValue < 5000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_60_01)) { SET_WEEKEVENTREG(WEEKEVENTREG_60_01); Message_StartTextbox(play, 0x45D, &this->actor); this->curTextId = 0x45D; - } else if (this->previousBankValue < (s16)(gSaveContext.save.saveInfo.bankRupees & 0xFFFF)) { + } else if (this->previousBankValue < (s16)HS_GET_BANK_RUPEES()) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); Message_StartTextbox(play, 0x45E, &this->actor); this->curTextId = 0x45E; @@ -229,7 +229,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { case 0x465: Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); - play->msgCtx.bankRupees = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; + play->msgCtx.bankRupees = HS_GET_BANK_RUPEES(); Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; break; @@ -248,7 +248,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { case 0x46C: case 0x47E: if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { - if ((u32)(gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 5000) { + if (HS_GET_BANK_RUPEES() >= 5000) { Message_StartTextbox(play, 0x45F, &this->actor); this->curTextId = 0x45F; } else if (gSaveContext.save.saveInfo.playerData.rupees == 0) { @@ -301,11 +301,11 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { case 0x472: case 0x473: case 0x474: - if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { + if (HS_GET_BANK_RUPEES() == 0) { Message_StartTextbox(play, 0x478, &this->actor); this->curTextId = 0x478; } else { - play->msgCtx.bankRupees = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; + play->msgCtx.bankRupees = HS_GET_BANK_RUPEES(); Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; } @@ -335,7 +335,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { switch (this->curTextId) { case 0x44E: if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 5000) { + if (HS_GET_BANK_RUPEES() >= 5000) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more @@ -378,20 +378,18 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { this->curTextId = 0x453; } - if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { + if (HS_GET_BANK_RUPEES() == 0) { this->isNewAccount = true; } Rupees_ChangeBy(-play->msgCtx.bankRupeesSelected); - this->previousBankValue = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; - gSaveContext.save.saveInfo.bankRupees = - ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) + play->msgCtx.bankRupeesSelected) | - (gSaveContext.save.saveInfo.bankRupees & 0xFFFF0000); + this->previousBankValue = HS_GET_BANK_RUPEES(); + HS_SET_BANK_RUPEES(HS_GET_BANK_RUPEES() + play->msgCtx.bankRupeesSelected); } } else { // GINKOMAN_CHOICE_NO Audio_PlaySfx_MessageCancel(); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); - if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { + if (HS_GET_BANK_RUPEES() == 0) { Message_StartTextbox(play, 0x456, &this->actor); this->curTextId = 0x456; } else { @@ -422,8 +420,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { case 0x471: if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((s32)((gSaveContext.save.saveInfo.bankRupees & 0xFFFF)) < - ((s32)(play->msgCtx.bankRupeesSelected + this->serviceFee))) { + if ((s32)HS_GET_BANK_RUPEES() < (play->msgCtx.bankRupeesSelected + this->serviceFee)) { Audio_PlaySfx(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); Message_StartTextbox(play, 0x476, &this->actor); @@ -447,11 +444,8 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { this->curTextId = 0x472; } - this->previousBankValue = (s16)(gSaveContext.save.saveInfo.bankRupees & 0xFFFF); - gSaveContext.save.saveInfo.bankRupees = - (((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) - play->msgCtx.bankRupeesSelected) - - this->serviceFee) | - (gSaveContext.save.saveInfo.bankRupees & 0xFFFF0000); + this->previousBankValue = HS_GET_BANK_RUPEES(); + HS_SET_BANK_RUPEES(HS_GET_BANK_RUPEES() - play->msgCtx.bankRupeesSelected - this->serviceFee); Rupees_ChangeBy(play->msgCtx.bankRupeesSelected); } } else { @@ -615,7 +609,7 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, PlayState* play) { case 0x469: Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); - play->msgCtx.bankRupees = (gSaveContext.save.saveInfo.bankRupees & 0xFFFF); + play->msgCtx.bankRupees = HS_GET_BANK_RUPEES(); if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(play, 0x46C, &this->actor); this->curTextId = 0x46C; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 06409d5247..be787e8d91 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -274,8 +274,10 @@ void func_8096FAAC(EnKakasi* this, PlayState* play) { * goes off every frame of song teach, but... doing what? */ void func_8096FBB8(EnKakasi* this, PlayState* play) { - if ((play->msgCtx.unk12048 == 0) || (play->msgCtx.unk12048 == 1) || (play->msgCtx.unk12048 == 2) || - (play->msgCtx.unk12048 == 3) || (play->msgCtx.unk12048 == 4)) { + if ((play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_A) || (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_DOWN) || + (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_RIGHT) || + (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_LEFT) || + (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_UP)) { // why not 0 < x < 4? fewer branches this->unk190++; } diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index ca2dfac2b4..beb9943745 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -46,13 +46,13 @@ ActorInit En_Kujiya_InitVars = { (ActorFunc)EnKujiya_Draw, }; -#define CHECK_LOTTERY_NUMBERS \ - (((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][0]) == \ - ((((void)0, gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF) & 0xF00) >> 8)) && \ - ((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][1]) == \ - ((((void)0, gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF) & 0xF0) >> 4)) && \ - ((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][2]) == \ - (((void)0, gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF) & 0xF))) +#define CHECK_LOTTERY_NUMBERS() \ + (((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][0]) == \ + ((HS_GET_LOTTERY_CODE_GUESS() & 0xF00) >> 8)) && \ + ((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][1]) == \ + ((HS_GET_LOTTERY_CODE_GUESS() & 0xF0) >> 4)) && \ + ((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][2]) == \ + (HS_GET_LOTTERY_CODE_GUESS() & 0xF))) void EnKujiya_Init(Actor* thisx, PlayState* play) { EnKujiya* this = THIS; @@ -159,7 +159,7 @@ void EnKujiya_ChooseNextDialogue(EnKujiya* this, PlayState* play) { break; case 0x2B65: - if (CHECK_LOTTERY_NUMBERS) { + if (CHECK_LOTTERY_NUMBERS()) { Message_StartTextbox(play, 0x2B66, &this->actor); this->textId = 0x2B66; // Won 50 Rupees } else { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 241260524d..516112d3df 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -916,9 +916,9 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { this->textId = 0x336D; } else { time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; - if ((s32)time < (s32)gSaveContext.save.saveInfo.horseBackBalloonHighScore) { + if ((s32)time < HS_GET_HORSE_BACK_BALLOON_TIME()) { // [Score] New record! - gSaveContext.save.saveInfo.horseBackBalloonHighScore = time; + HS_SET_HORSE_BACK_BALLOON_TIME(time); EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(play, 0x3350, &this->actor); this->textId = 0x3350; @@ -960,8 +960,8 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { this->textId = 0x3356; } else { time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; - if ((s32)time < (s32)gSaveContext.save.saveInfo.horseBackBalloonHighScore) { - gSaveContext.save.saveInfo.horseBackBalloonHighScore = time; + if ((s32)time < HS_GET_HORSE_BACK_BALLOON_TIME()) { + HS_SET_HORSE_BACK_BALLOON_TIME(time); EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(play, 0x3350, &this->actor); this->textId = 0x3350; @@ -987,9 +987,9 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { this->textId = 0x3356; } else { time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; - if ((s32)time < (s32)gSaveContext.save.saveInfo.horseBackBalloonHighScore) { + if ((s32)time < HS_GET_HORSE_BACK_BALLOON_TIME()) { // New record - gSaveContext.save.saveInfo.horseBackBalloonHighScore = time; + HS_SET_HORSE_BACK_BALLOON_TIME(time); Message_StartTextbox(play, 0x335D, &this->actor); this->textId = 0x335D; } else { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 15648514e2..fe7333cf7f 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -198,7 +198,7 @@ void EnOssan_SetupAction(EnOssan* this, EnOssanActionFunc action) { s32 EnOssan_TestItemSelected(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A); } return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 9c197223c4..90a625c884 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -176,7 +176,7 @@ void EnSob1_SetupAction(EnSob1* this, EnSob1ActionFunc action) { s32 EnSob1_TestItemSelected(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A); } return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index d3b88bb2dd..52c6d42f93 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1140,8 +1140,8 @@ void EnSyatekiMan_Swamp_EndGame(EnSyatekiMan* this, PlayState* play) { this->guayFlags = 0; this->wolfosFlags = 0; if (this->talkWaitTimer <= 0) { - if (GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() < this->score) { - SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(this->score); + if (HS_GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() < this->score) { + HS_SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(this->score); } this->talkWaitTimer = 15; @@ -1409,8 +1409,8 @@ void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play) { if ((this->talkWaitTimer <= 0) && !play->interfaceCtx.perfectLettersOn) { Flags_SetAllTreasure(play, this->score); this->talkWaitTimer = 15; - if ((GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) || (this->score == 50)) { - if (GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) { + if ((HS_GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) || (this->score == 50)) { + if (HS_GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_TOWN_SHOOTING_GALLERY_QUIVER_UPGRADE)) { // You got a new record! Message_StartTextbox(play, 0x407, &this->actor); @@ -1430,7 +1430,7 @@ void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play) { this->prevTextId = 0x406; } - SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(this->score); + HS_SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(this->score); this->shootingGameState = SG_GAME_STATE_ENDED; } else { if (CURRENT_DAY != 3) { diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index bf5a0900a5..0eb54ed347 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -126,7 +126,7 @@ void EnTrt_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 a s32 EnTrt_TestItemSelected(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) || (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_11)) { return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A); } return CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 0297339d97..8ca8857db4 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -350,11 +350,8 @@ void func_80B76980(EnTruMt* this, PlayState* play) { this->actor.speed = 0.0f; this->actionFunc = func_80B76BB8; } else if (CHECK_EVENTINF(EVENTINF_40)) { - u32 score = gSaveContext.minigameScore; - - if (((gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF0000) >> 0x10) < score) { - gSaveContext.save.saveInfo.unk_EC4 = - ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF); + if (((void)0, gSaveContext.minigameScore) > HS_GET_BOAT_ARCHERY_HIGH_SCORE()) { + HS_SET_BOAT_ARCHERY_HIGH_SCORE((u32)((void)0, gSaveContext.minigameScore)); SET_EVENTINF(EVENTINF_37); } } diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 015f1d8ae5..406e4ba0fe 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -80,7 +80,7 @@ void OceffSpot_End(OceffSpot* this, PlayState* play) { this->unk16C -= 0.05f; } else { Actor_Kill(&this->actor); - if ((R_TIME_SPEED != 400) && (play->msgCtx.unk12046 == 0)) { + if ((R_TIME_SPEED != 400) && !play->msgCtx.blockSunsSong) { if ((play->msgCtx.ocarinaAction != 0x39) || (play->msgCtx.ocarinaMode != 0xA)) { gSaveContext.sunsSongState = SUNSSONG_START; } diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index c73e67a1d3..59cd120cf4 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -41,7 +41,7 @@ void OceffWipe_Destroy(Actor* thisx, PlayState* play) { OceffWipe* this = THIS; Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index 641d49f492..6dbea91288 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -43,7 +43,7 @@ void OceffWipe2_Destroy(Actor* thisx, PlayState* play) { OceffWipe2* this = THIS; Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe2_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index f7156878c6..f0ab978c84 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -44,7 +44,7 @@ void OceffWipe3_Destroy(Actor* thisx, PlayState* play) { OceffWipe3* this = THIS; Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe3_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index d82c117e99..0bda6d1b93 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -43,7 +43,7 @@ void OceffWipe4_Destroy(Actor* thisx, PlayState* play) { OceffWipe4* this = THIS; Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe4_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index 3dcb06d5de..272d0fb88d 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -41,7 +41,7 @@ void OceffWipe5_Destroy(Actor* thisx, PlayState* play) { OceffWipe5* this = THIS; Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe5_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index 244870f9db..28a5dfb04d 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -39,7 +39,7 @@ void OceffWipe6_Init(Actor* thisx, PlayState* play) { void OceffWipe6_Destroy(Actor* thisx, PlayState* play) { Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe6_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c index fb8011c603..49f9fc0ddb 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -43,7 +43,7 @@ void OceffWipe7_Destroy(Actor* thisx, PlayState* play) { OceffWipe7* this = THIS; Magic_Reset(play); - play->msgCtx.unk120B0 = 0; + play->msgCtx.ocarinaSongEffectActive = false; } void OceffWipe7_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 6462c36655..ad5591c547 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -16394,8 +16394,8 @@ void func_80851D30(PlayState* play, Player* this) { var_s0++; } } else if (play->msgCtx.ocarinaMode == 1) { - if (play->msgCtx.unk12048 != 0xFF) { - var_s0[play->msgCtx.unk12048] = 1.2f; + if (play->msgCtx.ocarinaButtonIndex != OCARINA_BTN_INVALID) { + var_s0[play->msgCtx.ocarinaButtonIndex] = 1.2f; func_8082DB90(play, this, D_8085D190[this->transformation]); } else { s32 i; @@ -16419,11 +16419,11 @@ struct_8085D714 D_8085D714[] = { }; void func_80851EC8(PlayState* play, Player* this) { - struct_8085D714* temp3 = &D_8085D714[play->msgCtx.unk12048]; - f32* temp2 = &this->unk_B10[play->msgCtx.unk12048]; + struct_8085D714* temp3 = &D_8085D714[play->msgCtx.ocarinaButtonIndex]; + f32* temp2 = &this->unk_B10[play->msgCtx.ocarinaButtonIndex]; s16* temp_a3 = &this->unk_B86[temp3->unk_0]; - temp_a3[0] = play->msgCtx.unk12048; + temp_a3[0] = play->msgCtx.ocarinaButtonIndex; temp2[0] = 3.0f; } @@ -16479,7 +16479,7 @@ void func_808521E0(PlayState* play, Player* this) { func_80124618(D_801C0490, this->skelAnime.curFrame, &this->unk_AF0[1]); } else if (play->msgCtx.ocarinaMode == 1) { - if (play->msgCtx.unk12048 != 0xFF) { + if (play->msgCtx.ocarinaButtonIndex != OCARINA_BTN_INVALID) { func_80851EC8(play, this); } @@ -16500,7 +16500,7 @@ void func_80852290(PlayState* play, Player* this) { s16 var_a1_3; s16 sp38; - if ((play->msgCtx.ocarinaMode == 1) && (play->msgCtx.unk12048 != 0xFF)) { + if ((play->msgCtx.ocarinaMode == 1) && (play->msgCtx.ocarinaButtonIndex != OCARINA_BTN_INVALID)) { if ((this->unk_A90 != NULL) && (this->unk_A94 < 0.0f)) { this->unk_A90->flags |= ACTOR_FLAG_20000000; this->unk_A94 = 0.0f; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c index 2011d10fd3..f8f228eaa7 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c @@ -4,7 +4,6 @@ * Description: Entering name on a new file, selecting options from the options menu */ -#include "prevent_bss_reordering.h" #include "z_file_select.h" #include "z64rumble.h" #include "misc/title_static/title_static.h" diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index e2d456ee69..56d6477ca8 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -566,6 +566,7 @@ 0x801C5FC0 : "z_sram_NES", 0x801C6A70 : "z_message", 0x801D0470 : "z_message_nes", + 0x801D0910 : "z_message_staff", 0x801D0B50 : "z_player_call", 0x801D0B70 : "z_kaleido_manager", 0x801D0BB0 : "", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 09f7da10de..4ddf144d5b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2835,13 +2835,13 @@ 0x801491DC:("func_801491DC",), 0x80149454:("func_80149454",), 0x801496C8:("func_801496C8",), - 0x8014995C:("func_8014995C",), + 0x8014995C:("Message_DrawTextChar",), 0x80149C18:("func_80149C18",), 0x80149EBC:("Message_FindMessage",), 0x80149F74:("func_80149F74",), - 0x8014AAD0:("func_8014AAD0",), + 0x8014AAD0:("Message_HandleOcarina",), 0x8014ADBC:("func_8014ADBC",), - 0x8014C70C:("func_8014C70C",), + 0x8014C70C:("Message_LoadItemIcon",), 0x8014CC14:("Message_LoadChar",), 0x8014CCB4:("func_8014CCB4",), 0x8014CDF0:("func_8014CDF0",), @@ -2885,8 +2885,8 @@ 0x8015966C:("func_8015966C",), 0x8015B198:("func_8015B198",), 0x8015E750:("Message_FindCreditsMessage",), - 0x8015E7EC:("func_8015E7EC",), - 0x8015F8A8:("func_8015F8A8",), + 0x8015E7EC:("Message_DrawTextCredits",), + 0x8015F8A8:("Message_DecodeCredits",), 0x80160A90:("PlayerCall_InitFuncPtrs",), 0x80160AF8:("PlayerCall_Init",), 0x80160B40:("PlayerCall_Destroy",), diff --git a/tools/namefixer.py b/tools/namefixer.py index fa4efc6d36..86db40f182 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -767,6 +767,11 @@ wordReplace = { "func_8015926C": "Message_LoadOwlWarpTextNES", "func_8015E750": "Message_FindCreditsMessage", "func_80151BB4": "Message_BombersNotebookQueueEvent", + "func_8014995C": "Message_DrawTextChar", + "func_8014AAD0": "Message_HandleOcarina", + "func_8014C70C": "Message_LoadItemIcon", + "func_8015E7EC": "Message_DrawTextCredits", + "func_80133038": "Schedule_RunScript", "EffectSsKiraKira_SpawnSmallYellow": "EffectSsKirakira_SpawnSmallYellow", @@ -1097,7 +1102,36 @@ wordReplace = { "play->msgCtx.unk12023": "play->msgCtx.stateTimer", "play->msgCtx.unk1202A": "play->msgCtx.ocarinaMode", "play->msgCtx.unk1202C": "play->msgCtx.ocarinaAction", - "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + "play->msgCtx.unk12048": "play->msgCtx.lastOcarinaButtonIndex", + "play->msgCtx.unk120B0": "play->msgCtx.ocarinaSongEffectActive", + "play->msgCtx.unk12046": "play->msgCtx.blockSunsSong", + "play->msgCtx.unk12090": "play->msgCtx.textIsCredits", + "play->msgCtx.unk_120BC": "play->msgCtx.hudVisibility", + + "msgCtx->unk11EF8": "msgCtx->textboxSegment", + "msgCtx->unk11F14": "msgCtx->nextTextId", + "msgCtx->unk11FF2": "msgCtx->textUnskippable", + "msgCtx->unk11FF4": "msgCtx->textPosX", + "msgCtx->unk11FF6": "msgCtx->textPosY", + "msgCtx->unk12004": "msgCtx->textboxXTarget", + "msgCtx->unk12006": "msgCtx->textboxYTarget", + "msgCtx->unk1201E": "msgCtx->textColorAlpha", + "msgCtx->unk12020": "msgCtx->textboxEndType", + "msgCtx->unk12024": "msgCtx->textDelayTimer", + "msgCtx->unk1203A": "msgCtx->textboxColorAlphaTarget", + "msgCtx->unk1203C": "msgCtx->textboxColorAlphaCurrent", + "msgCtx->unk1204A": "msgCtx->ocarinaButtonsPosY", + "msgCtx->unk12068": "msgCtx->textboxX", + "msgCtx->unk1206A": "msgCtx->textboxY", + "msgCtx->unk12090": "msgCtx->textIsCredits", + "msgCtx->unk12092": "msgCtx->messageHasSetSfx", + "msgCtx->unk12094": "msgCtx->textboxSkipped", + "msgCtx->unk12098": "msgCtx->textCharScale", + "msgCtx->unk1209C": "msgCtx->textFade", + "msgCtx->unk120A0": "msgCtx->ocarinaAvailableSongs", + "msgCtx->unk120B0": "msgCtx->ocarinaSongEffectActive", + "msgCtx->unkActor": "msgCtx->talkActor", + "play->actorCtx.unk3": "play->actorCtx.lensActive", "play->actorCtx.unk4": "play->actorCtx.lensMaskSize", "play->actorCtx.targetContext": "play->actorCtx.targetCtx",