1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-11 19:43:44 +00:00

factor out a cutscene layer formula

This commit is contained in:
feacur 2024-11-28 18:11:00 +01:00
parent 5552e92eef
commit f728d55c36
4 changed files with 9 additions and 11 deletions

View file

@ -346,7 +346,7 @@ typedef enum CutsceneDestination {
// the primary purpose of these values is to select `gSaveContext.sceneLayer` // the primary purpose of these values is to select `gSaveContext.sceneLayer`
// CS_INDEX_AUTO: [SCENE_LAYER_CHILD_DAY .. SCENE_LAYER_ADULT_NIGHT] // CS_INDEX_AUTO: [SCENE_LAYER_CHILD_DAY .. SCENE_LAYER_ADULT_NIGHT]
// CS_INDEX_[0 .. A]: SCENE_LAYER_CUTSCENE_FIRST + (cutscene index & 0xF) // CS_INDEX_[0 .. A]: GET_CUTSCENE_LAYER(index)
// `z_demo.c` is the main user // `z_demo.c` is the main user
#define CS_INDEX_AUTO 0x0000 #define CS_INDEX_AUTO 0x0000
#define CS_INDEX_0 0xFFF0 #define CS_INDEX_0 0xFFF0

View file

@ -392,6 +392,7 @@ typedef enum SceneLayer {
} SceneLayer; } SceneLayer;
#define IS_CUTSCENE_LAYER (gSaveContext.sceneLayer >= SCENE_LAYER_CUTSCENE_FIRST) #define IS_CUTSCENE_LAYER (gSaveContext.sceneLayer >= SCENE_LAYER_CUTSCENE_FIRST)
#define GET_CUTSCENE_LAYER(index) (SCENE_LAYER_CUTSCENE_FIRST + (index & 0xF))
typedef enum LinkAge { typedef enum LinkAge {
/* 0 */ LINK_AGE_ADULT, /* 0 */ LINK_AGE_ADULT,

View file

@ -349,7 +349,7 @@ void Play_Init(GameState* thisx) {
if (gSaveContext.gameMode != GAMEMODE_NORMAL || gSaveContext.save.cutsceneIndex >= CS_INDEX_0) { if (gSaveContext.gameMode != GAMEMODE_NORMAL || gSaveContext.save.cutsceneIndex >= CS_INDEX_0) {
gSaveContext.nayrusLoveTimer = 0; gSaveContext.nayrusLoveTimer = 0;
Magic_Reset(this); Magic_Reset(this);
gSaveContext.sceneLayer = SCENE_LAYER_CUTSCENE_FIRST + (gSaveContext.save.cutsceneIndex & 0xF); gSaveContext.sceneLayer = GET_CUTSCENE_LAYER(gSaveContext.save.cutsceneIndex);
} else if (!LINK_IS_ADULT && IS_DAY) { } else if (!LINK_IS_ADULT && IS_DAY) {
gSaveContext.sceneLayer = SCENE_LAYER_CHILD_DAY; gSaveContext.sceneLayer = SCENE_LAYER_CHILD_DAY;
} else if (!LINK_IS_ADULT && !IS_DAY) { } else if (!LINK_IS_ADULT && !IS_DAY) {
@ -367,13 +367,13 @@ void Play_Init(GameState* thisx) {
!IS_CUTSCENE_LAYER) { !IS_CUTSCENE_LAYER) {
if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY) && if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY) &&
CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE)) { CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE)) {
gSaveContext.sceneLayer = 1; gSaveContext.sceneLayer = SCENE_LAYER_CHILD_NIGHT;
} else { } else {
gSaveContext.sceneLayer = 0; gSaveContext.sceneLayer = SCENE_LAYER_CHILD_DAY;
} }
} else if ((gEntranceTable[((void)0, gSaveContext.save.entranceIndex)].sceneId == SCENE_KOKIRI_FOREST) && } else if ((gEntranceTable[((void)0, gSaveContext.save.entranceIndex)].sceneId == SCENE_KOKIRI_FOREST) &&
LINK_IS_ADULT && !IS_CUTSCENE_LAYER) { LINK_IS_ADULT && !IS_CUTSCENE_LAYER) {
gSaveContext.sceneLayer = GET_EVENTCHKINF(EVENTCHKINF_48) ? 3 : 2; gSaveContext.sceneLayer = GET_EVENTCHKINF(EVENTCHKINF_48) ? SCENE_LAYER_ADULT_NIGHT : SCENE_LAYER_ADULT_DAY;
} }
Play_SpawnScene( Play_SpawnScene(
@ -386,7 +386,7 @@ void Play_Init(GameState* thisx) {
// When entering Gerudo Valley in the credits, trigger the GC emulator to play the ending movie. // When entering Gerudo Valley in the credits, trigger the GC emulator to play the ending movie.
// The emulator constantly checks whether PC is 0x81000000, so this works even though it's not a valid address. // The emulator constantly checks whether PC is 0x81000000, so this works even though it's not a valid address.
if ((gEntranceTable[((void)0, gSaveContext.save.entranceIndex)].sceneId == SCENE_GERUDO_VALLEY) && if ((gEntranceTable[((void)0, gSaveContext.save.entranceIndex)].sceneId == SCENE_GERUDO_VALLEY) &&
gSaveContext.sceneLayer == 6) { gSaveContext.sceneLayer == GET_CUTSCENE_LAYER(CS_INDEX_2)) {
PRINTF(T("エンディングはじまるよー\n", "The ending starts\n")); PRINTF(T("エンディングはじまるよー\n", "The ending starts\n"));
((void (*)(void))0x81000000)(); ((void (*)(void))0x81000000)();
PRINTF(T("出戻り?\n", "Return?\n")); PRINTF(T("出戻り?\n", "Return?\n"));

View file

@ -12,11 +12,8 @@ void TitleSetup_SetupTitleScreen(TitleSetupState* this) {
gSaveContext.save.linkAge = LINK_AGE_ADULT; gSaveContext.save.linkAge = LINK_AGE_ADULT;
Sram_InitDebugSave(); Sram_InitDebugSave();
gSaveContext.save.cutsceneIndex = CS_INDEX_3; gSaveContext.save.cutsceneIndex = CS_INDEX_3;
gSaveContext.sceneLayer = 7; // assigning scene layer here is redundant, as Play_Init sets it right away
// assigning scene layer here is redundant, as Play_Init sets it to gSaveContext.sceneLayer = GET_CUTSCENE_LAYER(CS_INDEX_3);
// SCENE_LAYER_CUTSCENE_FIRST + (gSaveContext.save.cutsceneIndex & 0xF)
// or one of the other `enum SceneLayer` values; even so, `7` is exactly
// the value this formula equals to for CS_INDEX_3
SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState);
} }