1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-06 14:20:11 +00:00

Decompile z_sram.c (#431)

* Decompile z_sram.c

* rename Sram_CalcChecksum to Sram_WriteSaveSlot

* progress

* done i think

* add original name comments

* temp substructs

* minor fixes

* review

* review 2

* fix

Co-authored-by: fig <fig02srl@gmail.com>
This commit is contained in:
Random 2020-10-11 19:45:08 +02:00 committed by GitHub
parent 9d35542207
commit b010db7c19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 1514 additions and 1672 deletions

View file

@ -104,7 +104,7 @@ s32 func_80994750(DoorGerudo* this, GlobalContext* globalCtx) {
void func_8099485C(DoorGerudo* this, GlobalContext* globalCtx) {
if (this->unk_164 != 0) {
this->actionFunc = func_8099496C;
gSaveContext.dungeonKeys[gSaveContext.mapIndex] -= 1;
gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] -= 1;
Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F);
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK);
} else {
@ -113,7 +113,7 @@ void func_8099485C(DoorGerudo* this, GlobalContext* globalCtx) {
if (direction != 0) {
Player* player = PLAYER;
if (gSaveContext.dungeonKeys[gSaveContext.mapIndex] <= 0) {
if (gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] <= 0) {
player->naviMessageId = -0x203;
} else if (!Flags_GetCollectible(globalCtx, (this->dyna.actor.params >> 8) & 0x1F)) {
player->naviMessageId = -0x225;

View file

@ -426,7 +426,7 @@ s32 func_80A3AEBC(GlobalContext* globalCtx, EnGirlA* this) {
}
s32 func_80A3AF30(GlobalContext* globalCtx, EnGirlA* this) {
if ((gBitFlags[2] & gSaveContext.equipment) && !(gBitFlags[3] & gSaveContext.equipment)) {
if ((gBitFlags[2] & gSaveContext.inventory.equipment) && !(gBitFlags[3] & gSaveContext.inventory.equipment)) {
return 2;
}
if (gSaveContext.rupees < this->unk_1C8) {
@ -439,7 +439,7 @@ s32 func_80A3AF30(GlobalContext* globalCtx, EnGirlA* this) {
}
s32 func_80A3AFC4(GlobalContext* globalCtx, EnGirlA* this) {
if (gBitFlags[5] & gSaveContext.equipment) {
if (gBitFlags[5] & gSaveContext.inventory.equipment) {
return 2;
}
if (gSaveContext.rupees < this->unk_1C8) {
@ -452,7 +452,7 @@ s32 func_80A3AFC4(GlobalContext* globalCtx, EnGirlA* this) {
}
s32 func_80A3B040(GlobalContext* globalCtx, EnGirlA* this) {
if (gBitFlags[4] & gSaveContext.equipment) {
if (gBitFlags[4] & gSaveContext.inventory.equipment) {
return 2;
}
if (gSaveContext.rupees < this->unk_1C8) {
@ -468,7 +468,7 @@ s32 func_80A3B0BC(GlobalContext* globalCtx, EnGirlA* this) {
if (LINK_AGE_IN_YEARS == YEARS_CHILD) {
return 2;
}
if (gBitFlags[9] & gSaveContext.equipment) {
if (gBitFlags[9] & gSaveContext.inventory.equipment) {
return 2;
}
if (gSaveContext.rupees < this->unk_1C8) {
@ -484,7 +484,7 @@ s32 func_80A3B160(GlobalContext* globalCtx, EnGirlA* this) {
if (LINK_AGE_IN_YEARS == YEARS_CHILD) {
return 2;
}
if (gBitFlags[10] & gSaveContext.equipment) {
if (gBitFlags[10] & gSaveContext.inventory.equipment) {
return 2;
}
if (gSaveContext.rupees < this->unk_1C8) {

View file

@ -234,7 +234,7 @@ void EnIshi_DropCollectible(EnIshi* this, GlobalContext* globalCtx) {
if (dropParams >= 0xD) {
dropParams = 0;
}
Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.posRot.pos, dropParams << 4);
}
}

View file

@ -169,13 +169,13 @@ void func_80A8F660(EnKakasi* this, GlobalContext* globalCtx) {
this->unk_196 = 6;
if (LINK_IS_CHILD) {
this->unk_194 = false;
if (gSaveContext.unk_F3C[4] != 0) {
if (gSaveContext.scarecrowCustomSongSet) {
this->actor.textId = 0x407A;
this->unk_196 = 5;
}
} else {
this->unk_194 = true;
if (gSaveContext.unk_F3C[4] != 0) {
if (gSaveContext.scarecrowCustomSongSet) {
this->actor.textId = 0x4079;
this->unk_196 = 5;
}
@ -335,7 +335,7 @@ void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx) {
if (BREG(3) != 0) {
osSyncPrintf("\n\n");
// flag!
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.unk_F3C[4]);
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.scarecrowCustomSongSet);
}
func_80093D18(globalCtx->state.gfxCtx);
SkelAnime_DrawSV(globalCtx, this->skelanime.skeleton, this->skelanime.limbDrawTbl, this->skelanime.dListCount, NULL,

View file

@ -205,7 +205,8 @@ void EnKakasi2_Update(Actor* thisx, GlobalContext* globalCtx) {
}
if (BREG(0) != 0) {
if (BREG(5) != 0) {
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ this->actor.player_distance ☆☆☆☆☆ %f\n" VT_RST, this->actor.xzDistFromLink);
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ this->actor.player_distance ☆☆☆☆☆ %f\n" VT_RST,
this->actor.xzDistFromLink);
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ this->hosei.x ☆☆☆☆☆ %f\n" VT_RST, this->maxSpawnDistance.x);
osSyncPrintf("\n\n");
}

View file

@ -179,14 +179,14 @@ void func_80A91284(EnKakasi3* this, GlobalContext* globalCtx) {
if (LINK_IS_CHILD) {
this->unk_194 = false;
if (gSaveContext.unk_12C5 != 0) {
if (gSaveContext.scarecrowSpawnSongSet) {
this->actor.textId = 0x40A0;
this->dialogState = 5;
this->unk_1A8 = 1;
}
} else {
this->unk_194 = true;
if (gSaveContext.unk_12C5 != 0) {
if (gSaveContext.scarecrowSpawnSongSet) {
if (this->unk_195) {
this->actor.textId = 0x40A2;
} else {
@ -238,7 +238,7 @@ void func_80A91348(EnKakasi3* this, GlobalContext* globalCtx) {
if (this->actor.xzDistFromLink < 80.0f) {
player->stateFlags2 |= 0x800000;
}
} else if (gSaveContext.unk_12C5 != 0 && !this->unk_195) {
} else if (gSaveContext.scarecrowSpawnSongSet && !this->unk_195) {
if (player->stateFlags2 & 0x1000000) {
this->camId = func_800800F8(globalCtx, 0x8D4, -0x63, &this->actor, 0);
@ -341,7 +341,7 @@ void func_80A918E4(EnKakasi3* this, GlobalContext* globalCtx) {
}
if ((globalCtx->msgCtx.unk_E3EE == 4 || (globalCtx->msgCtx.unk_E3EE >= 5 && globalCtx->msgCtx.unk_E3EE < 11)) &&
globalCtx->msgCtx.msgMode == 0) {
func_8010B680(globalCtx, 0x40A6, NULL);
this->dialogState = 5;
func_800803F0(globalCtx, this->camId);
@ -405,7 +405,7 @@ void EnKakasi3_Update(Actor* thisx, GlobalContext* globalCtx) {
if (BREG(2) != 0) {
osSyncPrintf("\n\n");
// flag!
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.unk_12C5);
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ フラグ! ☆☆☆☆☆ %d\n" VT_RST, gSaveContext.scarecrowSpawnSongSet);
}
this->unk_198++;

View file

@ -83,13 +83,13 @@ u16 func_80AA2AA0(GlobalContext* globalCtx, Actor* thisx) {
if (gSaveContext.timer1Value >= 0xD3) {
return 0x208E;
}
if ((gSaveContext.unk_EC4 == 0) || (gSaveContext.unk_EC4 >= 0xB4)) {
gSaveContext.unk_EC4 = 0xB4;
if ((gSaveContext.horseRaceRecord == 0) || (gSaveContext.horseRaceRecord >= 0xB4)) {
gSaveContext.horseRaceRecord = 0xB4;
gSaveContext.timer1Value = *timer1ValuePtr;
}
if (!(gSaveContext.eventChkInf[1] & 0x4000) && (gSaveContext.timer1Value < 0x32)) {
return 0x208F;
} else if (gSaveContext.timer1Value < gSaveContext.unk_EC4) {
} else if (gSaveContext.timer1Value < gSaveContext.horseRaceRecord) {
return 0x2012;
} else {
return 0x2004;
@ -126,7 +126,7 @@ s16 func_80AA2BD4(GlobalContext* globalCtx, Actor* thisx) {
if (globalCtx->msgCtx.choiceIndex == 0) {
if (gSaveContext.eventChkInf[1] & 0x4000) {
func_8010B720(globalCtx, 0x2091);
} else if (gSaveContext.unk_EC4 == 0) {
} else if (gSaveContext.horseRaceRecord == 0) {
func_8010B720(globalCtx, 0x2092);
} else {
func_8010B720(globalCtx, 0x2090);
@ -144,8 +144,8 @@ s16 func_80AA2BD4(GlobalContext* globalCtx, Actor* thisx) {
gSaveContext.eventChkInf[1] |= 0x4000;
case 0x2004:
case 0x2012:
if (gSaveContext.unk_EC4 > gSaveContext.timer1Value) {
gSaveContext.unk_EC4 = gSaveContext.timer1Value;
if (gSaveContext.horseRaceRecord > gSaveContext.timer1Value) {
gSaveContext.horseRaceRecord = gSaveContext.timer1Value;
}
case 0x208E:
gSaveContext.eventInf[0] &= ~0x400;

View file

@ -117,7 +117,7 @@ void func_80ABEF2C(EnOkarinaTag* this, GlobalContext* globalCtx) {
if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) {
this->actor.flags &= ~1;
} else {
if ((this->unk_152 != 6) || (gSaveContext.unk_12C5 != 0)) {
if ((this->unk_152 != 6) || (gSaveContext.scarecrowSpawnSongSet)) {
if (player->stateFlags2 & 0x1000000) {
// "North! ! ! ! !"
osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 北!!!!! ☆☆☆☆☆ %f\n" VT_RST, this->actor.xzDistFromLink);
@ -189,7 +189,7 @@ void func_80ABF28C(EnOkarinaTag* this, GlobalContext* globalCtx) {
Player* player = PLAYER;
this->unk_15A++;
if ((this->unk_152 != 6) || (gSaveContext.unk_12C5 != 0)) {
if ((this->unk_152 != 6) || (gSaveContext.scarecrowSpawnSongSet)) {
if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) {
this->actor.flags &= ~1;
} else if (((this->unk_150 != 4) || !(gSaveContext.eventChkInf[4] & 0x800)) &&

View file

@ -229,12 +229,11 @@ void func_80AE5270(EnReeba* this, GlobalContext* globalCtx) {
this->actionfunc = func_80AE5688;
return;
}
if (this->unk_274 == 0) {
Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_MOVE);
this->unk_274 = 10;
}
}
void func_80AE538C(EnReeba* this, GlobalContext* globalCtx) {

View file

@ -396,4 +396,4 @@ const ActorInit En_Rl_InitVars = {
(ActorFunc)EnRl_Destroy,
(ActorFunc)EnRl_Update,
(ActorFunc)EnRl_Draw,
};
};

View file

@ -57,7 +57,7 @@ void EnTakaraMan_Init(Actor* thisx, GlobalContext* globalCtx) {
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ ばぅん! ☆☆☆☆☆ %x\n" VT_RST,
globalCtx->actorCtx.flags.chest); // "Bun! %x" (needs a better translation)
globalCtx->actorCtx.flags.chest = 0;
gSaveContext.dungeonKeys[gSaveContext.mapIndex] = -1;
gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] = -1;
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06004FE0, &D_06000498, this->limbDrawTbl, this->transitionDrawTbl,
10);
thisx->posRot2.pos = thisx->posRot.pos;

View file

@ -268,10 +268,8 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) {
gDPSetEnvColor(oGfxCtx->polyXlu.p++, 255, 0, 0, 0);
Matrix_Translate(0.0f, 52.0f, 0.0f, MTXMODE_APPLY);
Matrix_RotateY(
(s16)(func_8005A9F4(ACTIVE_CAM) - this->actor.shape.rot.y + 0x8000) *
(M_PI / 0x8000),
MTXMODE_APPLY);
Matrix_RotateY((s16)(func_8005A9F4(ACTIVE_CAM) - this->actor.shape.rot.y + 0x8000) * (M_PI / 0x8000),
MTXMODE_APPLY);
Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY);
gSPMatrix(oGfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_syokudai.c", 745),

View file

@ -3056,7 +3056,7 @@ void func_80836BEC(Player* this, GlobalContext* globalCtx) {
actorToTarget = &PLAYER->actor;
}
holdTarget = (gSaveContext.zTargetingSetting != 0) || (this->actor.type != ACTORTYPE_PLAYER);
holdTarget = (gSaveContext.zTargetSetting != 0) || (this->actor.type != ACTORTYPE_PLAYER);
this->stateFlags1 |= 0x8000;
if ((actorToTarget != NULL) && !(actorToTarget->flags & 0x8000000)) {
@ -4042,9 +4042,9 @@ s32 func_80839034(GlobalContext* globalCtx, Player* this, CollisionPoly* arg2, u
}
if (linearVel > R_RUN_SPEED_LIMIT / 100.0f) {
gSaveContext.unk_13BC = R_RUN_SPEED_LIMIT / 100.0f;
gSaveContext.entranceSpeed = R_RUN_SPEED_LIMIT / 100.0f;
} else {
gSaveContext.unk_13BC = linearVel;
gSaveContext.entranceSpeed = linearVel;
}
if (D_808535F4 != 0) {
@ -4273,8 +4273,8 @@ s32 func_80839800(Player* this, GlobalContext* globalCtx) {
func_8003C890(&globalCtx->colCtx, &sp58, &sp4C);
if (func_80839034(globalCtx, this, sp58, 50)) {
gSaveContext.unk_13BC = 2.0f;
gSaveContext.unk_13C0 = NA_SE_OC_DOOR_OPEN;
gSaveContext.entranceSpeed = 2.0f;
gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN;
}
} else {
func_8005AD40(Gameplay_GetCamera(globalCtx, 0), doorActor,
@ -5356,18 +5356,18 @@ void func_8083CA20(GlobalContext* globalCtx, Player* this) {
void func_8083CA54(GlobalContext* globalCtx, Player* this) {
this->linearVelocity = 2.0f;
gSaveContext.unk_13BC = 2.0f;
gSaveContext.entranceSpeed = 2.0f;
if (func_8083C910(globalCtx, this, 120.0f)) {
this->unk_850 = -15;
}
}
void func_8083CA9C(GlobalContext* globalCtx, Player* this) {
if (gSaveContext.unk_13BC < 0.1f) {
gSaveContext.unk_13BC = 0.1f;
if (gSaveContext.entranceSpeed < 0.1f) {
gSaveContext.entranceSpeed = 0.1f;
}
this->linearVelocity = gSaveContext.unk_13BC;
this->linearVelocity = gSaveContext.entranceSpeed;
if (func_8083C910(globalCtx, this, 800.0f)) {
this->unk_850 = -80 / this->linearVelocity;
@ -8676,7 +8676,7 @@ void func_80845CA4(Player* this, GlobalContext* globalCtx) {
sp30 = 20;
if (this->stateFlags1 & 1) {
sp34 = gSaveContext.unk_13BC;
sp34 = gSaveContext.entranceSpeed;
if (D_808535F4 != 0) {
this->unk_450.x = (Math_Sins(D_808535FC) * 400.0f) + this->actor.posRot.pos.x;
@ -8685,7 +8685,7 @@ void func_80845CA4(Player* this, GlobalContext* globalCtx) {
} else if (this->unk_850 < 0) {
this->unk_850++;
sp34 = gSaveContext.unk_13BC;
sp34 = gSaveContext.entranceSpeed;
sp30 = -1;
}
@ -9071,7 +9071,7 @@ void Player_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 sp4C;
s32 initMode;
s16 params;
u16 unk_13C0;
u16 entranceSound;
globalCtx->unk_11E5C = globalCtx->bombchuBowlingAmmo = 0;
@ -9125,7 +9125,7 @@ void Player_Init(Actor* thisx, GlobalContext* globalCtx) {
}
if ((sp50 == 0) || (sp50 < -1)) {
if ((scene->titleFile.vromStart != scene->titleFile.vromEnd) && (gSaveContext.unk_13C7 != 0) &&
if ((scene->titleFile.vromStart != scene->titleFile.vromEnd) && (gSaveContext.showTitleCard) &&
(gSaveContext.sceneSetupIndex < 4) &&
(gEntranceTable[gSaveContext.entranceIndex + gSaveContext.sceneSetupIndex].field & 0x4000) &&
((globalCtx->sceneNum != SCENE_DDAN) || (gSaveContext.eventChkInf[11] & 1)) &&
@ -9133,7 +9133,7 @@ void Player_Init(Actor* thisx, GlobalContext* globalCtx) {
TitleCard_InitPlaceName(globalCtx, &globalCtx->actorCtx.titleCtx, this->giObjectSegment, 0xA0, 0x78, 0x90,
0x18, 0x14);
}
gSaveContext.unk_13C7 = 1;
gSaveContext.showTitleCard = true;
}
if (sp50 == 2) {
@ -9177,10 +9177,10 @@ void Player_Init(Actor* thisx, GlobalContext* globalCtx) {
this->stateFlags3 &= ~0x40;
}
if (gSaveContext.unk_13C0 != 0) {
unk_13C0 = gSaveContext.unk_13C0;
Audio_PlayActorSound2(&this->actor, unk_13C0);
gSaveContext.unk_13C0 = 0;
if (gSaveContext.entranceSound != 0) {
entranceSound = gSaveContext.entranceSound;
Audio_PlayActorSound2(&this->actor, entranceSound);
gSaveContext.entranceSound = 0;
}
Map_SavePlayerInitialInfo(globalCtx);
@ -11818,7 +11818,8 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) {
Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else {
if ((this->getItemId == GI_HEART_CONTAINER_2) || (this->getItemId == GI_HEART_CONTAINER) ||
((this->getItemId == GI_HEART_PIECE) && ((gSaveContext.questItems & 0xF0000000) == 0x40000000))) {
((this->getItemId == GI_HEART_PIECE) &&
((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) {
temp1 = 0x924;
} else {
temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? 0x39 : 0x922;