diff --git a/soh/include/z64save.h b/soh/include/z64save.h index 56db4b414..982da9d5c 100644 --- a/soh/include/z64save.h +++ b/soh/include/z64save.h @@ -173,7 +173,6 @@ typedef struct { /* 0x1420 */ s16 worldMapArea; /* 0x1422 */ s16 sunsSongState; // controls the effects of suns song /* 0x1424 */ s16 healthAccumulator; - /* 0x1426 */ s8 randomizerFlag; } SaveContext; // size = 0x1428 typedef enum { diff --git a/soh/soh/Enhancements/randomizer.cpp b/soh/soh/Enhancements/randomizer.cpp index d5f14fded..4721ffc79 100644 --- a/soh/soh/Enhancements/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer.cpp @@ -736,7 +736,7 @@ GetItemID Randomizer::GetItemFromGet(RandomizerGet randoGet, GetItemID ogItemId) } RandomizerCheck Randomizer::GetCheckFromActor(s16 actorId, GetItemID ogItemId) { - if (!gSaveContext.randomizerFlag) { + if (!gSaveContext.n64ddFlag) { return UNKNOWN_CHECK; } @@ -754,7 +754,7 @@ RandomizerCheck Randomizer::GetCheckFromActor(s16 actorId, GetItemID ogItemId) { } RandomizerCheck Randomizer::GetCheckFromSceneAndParams(s16 sceneNum, s16 actorParams) { - if (!gSaveContext.randomizerFlag) { + if (!gSaveContext.n64ddFlag) { return UNKNOWN_CHECK; } diff --git a/soh/src/code/title_setup.c b/soh/src/code/title_setup.c index 1e709dc12..131c97627 100644 --- a/soh/src/code/title_setup.c +++ b/soh/src/code/title_setup.c @@ -4,7 +4,7 @@ void TitleSetup_InitImpl(GameState* gameState) { osSyncPrintf("ゼルダ共通データ初期化\n"); // "Zelda common data initalization" SaveContext_Init(); gameState->running = false; - SET_NEXT_GAMESTATE(gameState, Title_Init, TitleContext); + SET_NEXT_GAMESTATE(gameState, FileChoose_Init, TitleContext); } void TitleSetup_Destroy(GameState* gameState) { diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 570eedd1f..2f7e9da2b 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -198,15 +198,24 @@ void FileChoose_UpdateMainMenu(GameState* thisx) { this->nameEntryBoxPosX = 120; this->nameEntryBoxAlpha = 0; memcpy(&this->fileNames[this->buttonIndex][0], &emptyName, 8); - } else if (this->n64ddFlags[this->buttonIndex] == this->n64ddFlag) { + } else if (this->n64ddFlags[this->buttonIndex] == 0 && CVar_GetS32("gRandomizer", 0) == 0) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); this->actionTimer = 8; this->selectMode = SM_FADE_MAIN_TO_SELECT; this->selectedFileIndex = this->buttonIndex; this->menuMode = FS_MENU_MODE_SELECT; this->nextTitleLabel = FS_TITLE_OPEN_FILE; - } else if (!this->n64ddFlags[this->buttonIndex]) { + } else if (this->n64ddFlags[this->buttonIndex] == 0 && CVar_GetS32("gRandomizer", 0) != 0) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (this->n64ddFlags[this->buttonIndex] != 0 && CVar_GetS32("gRandomizer", 0) == 0) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else if (this->n64ddFlags[this->buttonIndex] != 0 && CVar_GetS32("gRandomizer", 0) != 0) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + this->actionTimer = 8; + this->selectMode = SM_FADE_MAIN_TO_SELECT; + this->selectedFileIndex = this->buttonIndex; + this->menuMode = FS_MENU_MODE_SELECT; + this->nextTitleLabel = FS_TITLE_OPEN_FILE; } } else { if (this->warningLabel == FS_WARNING_NONE) { @@ -990,7 +999,11 @@ void FileChoose_DrawWindowContents(GameState* thisx) { // draw file button gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[temp], 20, 0); - isActive = ((this->n64ddFlag == this->n64ddFlags[i]) || (this->nameBoxAlpha[i] == 0)) ? 0 : 1; + isActive = + (((this->n64ddFlags[i] == 0 && CVar_GetS32("gRandomizer", 0) == 0) || + (this->n64ddFlags[i] != 0 && CVar_GetS32("gRandomizer", 0) != 0) || (this->nameBoxAlpha[i] == 0) + ? 0 + : 1)); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1], sWindowContentColors[isActive][2], this->fileButtonAlpha[i]); @@ -1032,7 +1045,12 @@ void FileChoose_DrawWindowContents(GameState* thisx) { // draw file info for (fileIndex = 0; fileIndex < 3; fileIndex++) { - isActive = ((this->n64ddFlag == this->n64ddFlags[fileIndex]) || (this->nameBoxAlpha[fileIndex] == 0)) ? 0 : 1; + isActive = + (((this->n64ddFlags[fileIndex] == 0 && CVar_GetS32("gRandomizer", 0) == 0) || + (this->n64ddFlags[fileIndex] != 0 && CVar_GetS32("gRandomizer", 0) != 0) || + (this->nameBoxAlpha[fileIndex] == 0) + ? 0 + : 1)); FileChoose_DrawFileInfo(&this->state, fileIndex, isActive); } @@ -1598,8 +1616,6 @@ void FileChoose_Main(GameState* thisx) { OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2898); - this->n64ddFlag = 0; - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); gSPSegment(POLY_OPA_DISP++, 0x02, this->parameterSegment); @@ -1852,8 +1868,10 @@ void FileChoose_InitContext(GameState* thisx) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + /* this->n64ddFlags[0] = this->n64ddFlags[1] = this->n64ddFlags[2] = this->defense[0] = this->defense[1] = this->defense[2] = 0; + */ SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c index 2a4873233..c1e8ee6f4 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c @@ -436,8 +436,11 @@ void FileChoose_DrawNameEntry(GameState* thisx) { if (validName) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSaveContext.fileNum = this->buttonIndex; - gSaveContext.randomizerFlag = (CVar_GetS32("gRandomizer", 0) == 1); + + this->n64ddFlags[this->buttonIndex] = CVar_GetS32("gRandomizer", 0) != 0; + gSaveContext.n64ddFlag = CVar_GetS32("gRandomizer", 0) != 0; dayTime = ((void)0, gSaveContext.dayTime); Sram_InitSave(this, &this->sramCtx);