1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-21 14:31:17 +00:00

z_message_PAL, message_data_static and surrounding doc (#996)

* Initial progress on z_message_PAL, very messy

* Fix merge

* Some more progress

* Fix merge

* More z_message_PAL

* Small progress

* More small progress

* message_data_static files OK

* Prepare z_message_tables

* Matched another function, small updates

* Attempt to use asm-processor static-symbols branch

* Refactor text id declarations

* Begin large text codes parser function

* Fix merge

* Refactor done

* Build OK, add color and highscore names

* Remove encoded text headers and automatically encode during build

* Fix kanfont

* Various cleanups

* DISP macros

* Another match aside data

* Further progress

* Small improvements

* Deduplicate magic values for text control codes, small improvements

* Tiny progress

* Minor cleanups

* Clean up z_message_PAL comment

* Progress on large functions

* Further progress on large functions

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

* data OK

* Few improvements

* Use gDPLoadTextureBlock macros where appropriate

* rm z_message_tables, progress on large functions

* 2 more matches

* Improvements

* Small progress

* More progress on big function

* progress

* match func_80107980

* match Message_Update

* match func_8010BED8

* done

* Progress on remaining large functions

* Small progress on largest function

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

* Small nonmatchings improvements

* docs wip

* Largest function maybe equivalent

* Fix merge

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

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

* Fix merge

* one match

* Last function is instruction-matching

* Fix

* Improvements thanks to engineer124

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

* More variables labeled, use text state enum everywhere

* More labels and names

* Fix

* Actor_IsTalking -> Actor_TalkRequested

* Match func_8010C39C and remove unused asm

* More docs

* Mostly ocarina related docs

* All msgModes named

* Fix assetclean

* Cleanup

* Extraction fixes and headers

* Suggestions

* Review suggestions

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

* Fix

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

* Review suggestions

* BGM ids and ran formatter

* Review comments

* rename include_readonly to include_data_with_rodata

* Remove leading 0s in number directives

* Review suggestions for message_data_static

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

Co-authored-by: Thar0 <maximilianc64@gmail.com>
Co-authored-by: Zelllll <56516451+Zelllll@users.noreply.github.com>
Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
Co-authored-by: Roman971 <romanlasnier@hotmail.com>
This commit is contained in:
Tharo 2021-11-23 01:20:30 +00:00 committed by GitHub
parent 03636166b3
commit a497f33bda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
216 changed files with 7052 additions and 16801 deletions

View file

@ -196,10 +196,8 @@ static u8 sJumpOrder[] = {
FROG_BLUE, FROG_YELLOW, FROG_RED, FROG_PURPLE, FROG_WHITE, FROG_BLUE, FROG_YELLOW, FROG_RED,
};
// probably can be replaced with a message context enum at a later time
// A, CDOWN, CRIGHT, CLEFT, CUP
static u8 sOcarinaNotes[] = {
0, 1, 2, 3, 4,
OCARINA_NOTE_A, OCARINA_NOTE_C_DOWN, OCARINA_NOTE_C_RIGHT, OCARINA_NOTE_C_LEFT, OCARINA_NOTE_C_UP,
};
void EnFr_OrientUnderwater(EnFr* this) {
@ -602,12 +600,12 @@ void EnFr_Idle(EnFr* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
if (player->stateFlags2 & 0x2000000) {
if (globalCtx->msgCtx.unk_E3EE == 4) {
globalCtx->msgCtx.unk_E3EE = 0;
if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_04) {
globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00;
}
OnePointCutscene_Init(globalCtx, 4110, ~0x62, &this->actor, MAIN_CAM);
globalCtx->msgCtx.msgMode = 0x37;
globalCtx->msgCtx.msgMode = MSGMODE_PAUSED;
player->actor.world.pos.x = this->actor.world.pos.x; // x = 990.0f
player->actor.world.pos.y = this->actor.world.pos.y; // y = 205.0f
player->actor.world.pos.z = this->actor.world.pos.z; // z = -1220.0f
@ -620,11 +618,11 @@ void EnFr_Idle(EnFr* this, GlobalContext* globalCtx) {
}
void EnFr_Activate(EnFr* this, GlobalContext* globalCtx) {
if (globalCtx->msgCtx.msgMode == 0xC) {
globalCtx->msgCtx.msgMode = 0x37;
if (globalCtx->msgCtx.msgMode == MSGMODE_OCARINA_PLAYING) {
globalCtx->msgCtx.msgMode = MSGMODE_PAUSED;
sEnFrPointers.flags = 1;
this->actionFunc = EnFr_ActivateCheckFrogSong;
} else if (globalCtx->msgCtx.msgMode == 0x37) { // Goes to Frogs 2 Song
} else if (globalCtx->msgCtx.msgMode == MSGMODE_PAUSED) { // Goes to Frogs 2 Song
sEnFrPointers.flags = 1;
this->actionFunc = EnFr_ActivateCheckFrogSong;
}
@ -641,7 +639,7 @@ void EnFr_ActivateCheckFrogSong(EnFr* this, GlobalContext* globalCtx) {
&& (gSaveContext.eventChkInf[13] & 0x40)) { // SoS
this->actionFunc = EnFr_TalkBeforeFrogSong;
this->songIndex = FROG_CHOIR_SONG;
func_8010B680(globalCtx, 0x40AB, &this->actor);
Message_StartTextbox(globalCtx, 0x40AB, &this->actor);
} else {
this->songIndex = FROG_ZL;
this->actionFunc = func_80A1BE98;
@ -662,49 +660,49 @@ void func_80A1BE98(EnFr* this, GlobalContext* globalCtx) {
}
}
func_8010BD58(globalCtx, 0x30);
func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_NOWARP);
this->actionFunc = EnFr_ListeningToOcarinaNotes;
}
void EnFr_ListeningToOcarinaNotes(EnFr* this, GlobalContext* globalCtx) {
this->songIndex = FROG_NO_SONG;
switch (globalCtx->msgCtx.unk_E3EE) { // Ocarina Song played
case 7:
switch (globalCtx->msgCtx.ocarinaMode) { // Ocarina Song played
case OCARINA_MODE_07:
this->songIndex = FROG_ZL;
break;
case 6:
case OCARINA_MODE_06:
this->songIndex = FROG_EPONA;
break;
case 5:
case OCARINA_MODE_05:
this->songIndex = FROG_SARIA;
break;
case 8:
case OCARINA_MODE_08:
this->songIndex = FROG_SUNS;
break;
case 9:
case OCARINA_MODE_09:
this->songIndex = FROG_SOT;
break;
case 10:
case OCARINA_MODE_0A:
this->songIndex = FROG_STORMS;
break;
case 4:
case OCARINA_MODE_04:
EnFr_OcarinaMistake(this, globalCtx);
break;
case 1: // Ocarina note played, but no song played
switch (globalCtx->msgCtx.unk_E410) { // Jumping frogs in open ocarina based on ocarina note played
case 0:
case OCARINA_MODE_01: // Ocarina note played, but no song played
switch (globalCtx->msgCtx.lastOcaNoteIdx) { // Jumping frogs in open ocarina based on ocarina note played
case OCARINA_NOTE_A:
EnFr_SetupJumpingUp(this, FROG_BLUE);
break;
case 1:
case OCARINA_NOTE_C_DOWN:
EnFr_SetupJumpingUp(this, FROG_YELLOW);
break;
case 2:
case OCARINA_NOTE_C_RIGHT:
EnFr_SetupJumpingUp(this, FROG_RED);
break;
case 3:
case OCARINA_NOTE_C_LEFT:
EnFr_SetupJumpingUp(this, FROG_PURPLE);
break;
case 4:
case OCARINA_NOTE_C_UP:
EnFr_SetupJumpingUp(this, FROG_WHITE);
break;
}
@ -755,8 +753,8 @@ void EnFr_ChildSongFirstTime(EnFr* this, GlobalContext* globalCtx) {
}
void EnFr_TalkBeforeFrogSong(EnFr* this, GlobalContext* globalCtx) {
if ((func_8010BDBC(&globalCtx->msgCtx) == 5) && (func_80106BC8(globalCtx))) {
func_80106CCC(globalCtx);
if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) {
Message_CloseTextbox(globalCtx);
this->frogSongTimer = 2;
this->actionFunc = EnFr_SetupFrogSong;
}
@ -814,7 +812,7 @@ void EnFr_SetupFrogSong(EnFr* this, GlobalContext* globalCtx) {
} else {
this->frogSongTimer = 40;
this->ocarinaNoteIndex = 0;
func_8010BD58(globalCtx, 0x2F);
func_8010BD58(globalCtx, OCARINA_ACTION_FROGS);
this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex);
EnFr_CheckOcarinaInputFrogSong(this->ocarinaNote);
this->actionFunc = EnFr_ContinueFrogSong;
@ -827,7 +825,7 @@ s32 EnFr_IsFrogSongComplete(EnFr* this, GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
u8 ocarinaNoteIndex;
if (this->ocarinaNote == (*msgCtx).unk_E410) { // required to match, possibly an array?
if (this->ocarinaNote == (*msgCtx).lastOcaNoteIdx) { // required to match, possibly an array?
this->ocarinaNoteIndex++;
ocarinaNoteIndex = this->ocarinaNoteIndex;
if (1) {}
@ -846,10 +844,10 @@ s32 EnFr_IsFrogSongComplete(EnFr* this, GlobalContext* globalCtx) {
}
void EnFr_OcarinaMistake(EnFr* this, GlobalContext* globalCtx) {
func_80106CCC(globalCtx);
Message_CloseTextbox(globalCtx);
this->reward = GI_NONE;
func_80078884(NA_SE_SY_OCARINA_ERROR);
func_800ED858(0);
Audio_OcaSetInstrument(0);
sEnFrPointers.flags = 12;
EnFr_DeactivateButterfly();
this->actionFunc = EnFr_Deactivate;
@ -864,7 +862,7 @@ void EnFr_ContinueFrogSong(EnFr* this, GlobalContext* globalCtx) {
EnFr_OcarinaMistake(this, globalCtx);
} else {
this->frogSongTimer--;
if (globalCtx->msgCtx.msgMode == 0x32) {
if (globalCtx->msgCtx.msgMode == MSGMODE_FROGS_PLAYING) {
counter = 0;
for (i = 0; i < ARRAY_COUNT(sEnFrPointers.frogs); i++) {
frog = sEnFrPointers.frogs[i];
@ -880,22 +878,22 @@ void EnFr_ContinueFrogSong(EnFr* this, GlobalContext* globalCtx) {
}
}
if (globalCtx->msgCtx.msgMode == 0x33) {
globalCtx->msgCtx.msgMode = 0x31;
switch (globalCtx->msgCtx.unk_E410) {
case 0:
if (globalCtx->msgCtx.msgMode == MSGMODE_FROGS_WAITING) {
globalCtx->msgCtx.msgMode = MSGMODE_FROGS_START;
switch (globalCtx->msgCtx.lastOcaNoteIdx) {
case OCARINA_NOTE_A:
EnFr_SetupJumpingUp(this, FROG_BLUE);
break;
case 1:
case OCARINA_NOTE_C_DOWN:
EnFr_SetupJumpingUp(this, FROG_YELLOW);
break;
case 2:
case OCARINA_NOTE_C_RIGHT:
EnFr_SetupJumpingUp(this, FROG_RED);
break;
case 3:
case OCARINA_NOTE_C_LEFT:
EnFr_SetupJumpingUp(this, FROG_PURPLE);
break;
case 4:
case OCARINA_NOTE_C_UP:
EnFr_SetupJumpingUp(this, FROG_WHITE);
}
if (EnFr_IsFrogSongComplete(this, globalCtx)) {
@ -914,20 +912,20 @@ void EnFr_SetupReward(EnFr* this, GlobalContext* globalCtx, u8 unkCondition) {
func_80078884(NA_SE_SY_CORRECT_CHIME);
}
func_800ED858(0);
globalCtx->msgCtx.msgMode = 0x37;
Audio_OcaSetInstrument(0);
globalCtx->msgCtx.msgMode = MSGMODE_PAUSED;
this->actionFunc = EnFr_PrintTextBox;
}
void EnFr_PrintTextBox(EnFr* this, GlobalContext* globalCtx) {
func_8010B680(globalCtx, this->actor.textId, &this->actor);
Message_StartTextbox(globalCtx, this->actor.textId, &this->actor);
this->actionFunc = EnFr_TalkBeforeReward;
}
void EnFr_TalkBeforeReward(EnFr* this, GlobalContext* globalCtx) {
if ((func_8010BDBC(&globalCtx->msgCtx) == 5) && func_80106BC8(globalCtx)) {
if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) {
this->frogSongTimer = 100;
func_80106CCC(globalCtx);
Message_CloseTextbox(globalCtx);
this->actionFunc = EnFr_SetReward;
}
}
@ -1000,7 +998,7 @@ void EnFr_Deactivate(EnFr* this, GlobalContext* globalCtx) {
frogLoop2->isDeactivating = false;
}
globalCtx->msgCtx.unk_E3EE = 4;
globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04;
Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0);
if (this->reward == GI_NONE) {
this->actionFunc = EnFr_Idle;
@ -1020,7 +1018,7 @@ void EnFr_GiveReward(EnFr* this, GlobalContext* globalCtx) {
}
void EnFr_SetIdle(EnFr* this, GlobalContext* globalCtx) {
if ((func_8010BDBC(&globalCtx->msgCtx) == 6) && (func_80106BC8(globalCtx))) {
if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) {
this->actionFunc = EnFr_Idle;
}
}

View file

@ -52,7 +52,7 @@ typedef struct EnFr {
/* 0x037E */ u8 growingScaleIndex; // Target Scale Level 0-3 while growing (3 highest smooth)
/* 0x037F */ u8 isGrowing; // While growing, the frog will switch between its larger size and its original size every frame
/* 0x0380 */ u8 ocarinaNoteIndex; // Related to unk_381
/* 0x0381 */ u8 ocarinaNote; // Ocarina Note to Play for Frogs 2. Related to globalCtx->msgCtx.unk_E410
/* 0x0381 */ u8 ocarinaNote; // Ocarina Note to Play for Frogs 2
/* 0x0382 */ u8 songIndex; // Song index 1-7 (6 songs + custom HP Song): 5 = sos, 6 = all songs
/* 0x0383 */ u8 isJumpingToFrogSong; // Conditional:
/* 0x0384 */ char unk_384[0x02];