Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Save.cutsceneIndex and adjacent data / code #2286

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
53cd39d
introduce `enum CutsceneIndex` as a first step
Feacur Nov 4, 2024
050c736
crudely rename `enum CutsceneIndex` entries
Feacur Nov 5, 2024
4049e33
run `check_format.py ...` separetely
Feacur Nov 5, 2024
2ae3bff
apply a draft PR suggestion
Feacur Nov 5, 2024
8cbdf80
rename `CS_INDEX_*` with PR suggestions
Feacur Nov 5, 2024
2ec57c9
improve `CS_INDEX_*` naming, rem `ENTRANCE` suffix
Feacur Nov 5, 2024
b8953fd
apply Jenkins fixes
Feacur Nov 5, 2024
32a2dd0
apply a PR suggestion
Feacur Nov 5, 2024
2bd2ca2
remove redundant comments, fix the header comment
Feacur Nov 5, 2024
6eaaa87
rename the flag for freeing `nextCutsceneIndex`
Feacur Nov 5, 2024
d9bbd67
rename the flag for automatic `sceneLayer` calc
Feacur Nov 5, 2024
eb75a6d
use explicit scene layer names instead of numbers
Feacur Nov 5, 2024
02a977f
ok, now the last two `CS_INDEX_*` are less unknown
Feacur Nov 5, 2024
bee188d
Merge branch 'main' into doc/cutscene_index
Feacur Nov 13, 2024
211bf74
apply Jenkins fixes
Feacur Nov 13, 2024
450e24e
Merge branch 'main' into doc/cutscene_index
Feacur Nov 17, 2024
3530507
Merge branch 'main' into doc/cutscene_index
Feacur Nov 19, 2024
4b3e0dc
run `fix_bss` locally
Feacur Nov 19, 2024
1d84bca
revert all local to the branch bss shifts
Feacur Nov 19, 2024
133a74f
ugh, use defines instead of an enum
Feacur Nov 19, 2024
0cbe8a4
still, add a BSS pragma for `z_demo.c`
Feacur Nov 20, 2024
279759f
Merge branch 'main' into doc/cutscene_index
Feacur Nov 20, 2024
5552e92
apply review changes
Feacur Nov 28, 2024
f728d55
factor out a cutscene layer formula
Feacur Nov 28, 2024
106cb10
give scene layers names throughout code
Feacur Nov 28, 2024
50acfc2
apply Jenkins fixes
Feacur Nov 28, 2024
6efea0a
tweak `CS_INDEX` descriptions
Feacur Nov 29, 2024
e9adab6
apply PR review suggestions
Feacur Nov 30, 2024
67f0eef
rename "auto" -> "default"
Feacur Nov 30, 2024
cbaad70
apply PR review suggestions
Feacur Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion include/z64cutscene.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,42 @@ typedef enum CutsceneDestination {
/* 0x77 */ CS_DEST_ZELDAS_COURTYARD_RECEIVE_LETTER
} CutsceneDestination;

// values `< 0xFFF0` indicate a "manual" cutscene; can be assigned to
// - `gSaveContext.save.cutsceneIndex`
// - `gSaveContext.nextCutsceneIndex`
// using them implies an intention to have `z_play.c` set `gSaveContext.sceneLayer` based on age and day time
// see enum values [`SCENE_LAYER_CHILD_DAY` .. `SCENE_LAYER_ADULT_NIGHT`]
#define CS_INDEX_DEFAULT 0x0000
#define CS_INDEX_UNK_8000 0x8000

// values `>= 0xFFF0` indicate a "scripted" cutscene; can be assigned to
// - `gSaveContext.save.cutsceneIndex`
// - `gSaveContext.nextCutsceneIndex`
// using them implies an intention to have `z_play.c` set `gSaveContext.sceneLayer` directly by index
// see `GET_CUTSCENE_LAYER(index)`
#define CS_INDEX_0 0xFFF0
#define CS_INDEX_1 0xFFF1
#define CS_INDEX_2 0xFFF2
#define CS_INDEX_3 0xFFF3
#define CS_INDEX_4 0xFFF4
#define CS_INDEX_5 0xFFF5
#define CS_INDEX_6 0xFFF6
#define CS_INDEX_7 0xFFF7
#define CS_INDEX_8 0xFFF8
#define CS_INDEX_9 0xFFF9
#define CS_INDEX_A 0xFFFA

// it's "out of range" even for the largest set of `entrance_table.h`
// but `z_demo.c` immediately sets `CS_STATE_STOP` state
#define CS_INDEX_UNK_FFFF 0xFFFF

// sentinel value used for `cutsceneIndex` to indicate that it should be reset to default
#define CS_INDEX_EMPTY 0xFFFD

// sentinel value used for `nextCutsceneIndex` to indicate that it is empty
// otherwise its value will be copied to `cutsceneIndex`
#define CS_INDEX_NEXT_EMPTY 0xFFEF

typedef union CsCmdCam {
struct {
/* 0x00 */ u16 unused0;
Expand All @@ -353,7 +389,6 @@ typedef union CsCmdCam {
s32 _words[2];
} CsCmdCam; // size = 0x8


typedef union CsCmdMisc {
struct {
/* 0x00 */ u16 type;
Expand Down
1 change: 1 addition & 0 deletions include/z64save.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ typedef enum SceneLayer {
} SceneLayer;

#define IS_CUTSCENE_LAYER (gSaveContext.sceneLayer >= SCENE_LAYER_CUTSCENE_FIRST)
#define GET_CUTSCENE_LAYER(index) (SCENE_LAYER_CUTSCENE_FIRST + (index & 0xF))

typedef enum LinkAge {
/* 0 */ LINK_AGE_ADULT,
Expand Down
2 changes: 1 addition & 1 deletion src/code/db_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,7 @@ s32 DebugCamera_UpdateDemoControl(DebugCam* debugCam, Camera* cam) {

if (CHECK_BTN_ALL(sPlay->state.input[1].press.button, BTN_CRIGHT)) {
gUseCutsceneCam = false;
gSaveContext.save.cutsceneIndex = 0xFFFD;
gSaveContext.save.cutsceneIndex = CS_INDEX_EMPTY;
gSaveContext.cutsceneTrigger = 1;
sDebugCamAnim.curFrame = 0.0f;
sDebugCamAnim.keyframe = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_common_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void SaveContext_Init(void) {
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = NATURE_ID_DISABLED;
gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX;
gSaveContext.nextCutsceneIndex = 0xFFEF;
gSaveContext.nextCutsceneIndex = CS_INDEX_NEXT_EMPTY;
gSaveContext.cutsceneTrigger = 0;
gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST;
gSaveContext.nextDayTime = NEXT_TIME_NONE;
Expand Down
178 changes: 90 additions & 88 deletions src/code/z_demo.c

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/code/z_horse.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ typedef struct struct_8011F9B8 {

void func_8006D684(PlayState* play, Player* player) {
static struct_8011F9B8 D_8011F9B8[] = {
{ SCENE_GERUDOS_FORTRESS, 0xFFF0, { 3600, 1413, 360 }, 0x8001, 8 },
{ SCENE_LON_LON_RANCH, 0xFFF0, { -250, 1, -1580 }, 0x4000, 6 },
{ SCENE_LON_LON_RANCH, 0xFFF1, { 0, 0, 0 }, 0x0000, 5 },
{ SCENE_LON_LON_RANCH, 0xFFF5, { 0, 0, 0 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, 0xFFF3, { -2961, 313, 7700 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, 0xFFF4, { -1900, 313, 7015 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, 0xFFF5, { -4043, 313, 6933 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, 0xFFF6, { -4043, 313, 6933 }, 0x0000, 7 },
{ SCENE_GERUDOS_FORTRESS, CS_INDEX_0, { 3600, 1413, 360 }, 0x8001, 8 },
{ SCENE_LON_LON_RANCH, CS_INDEX_0, { -250, 1, -1580 }, 0x4000, 6 },
{ SCENE_LON_LON_RANCH, CS_INDEX_1, { 0, 0, 0 }, 0x0000, 5 },
{ SCENE_LON_LON_RANCH, CS_INDEX_5, { 0, 0, 0 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, CS_INDEX_3, { -2961, 313, 7700 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, CS_INDEX_4, { -1900, 313, 7015 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, CS_INDEX_5, { -4043, 313, 6933 }, 0x0000, 7 },
{ SCENE_HYRULE_FIELD, CS_INDEX_6, { -4043, 313, 6933 }, 0x0000, 7 },
};
s32 pad;
s32 i;
Expand Down Expand Up @@ -192,7 +192,7 @@ void func_8006D684(PlayState* play, Player* player) {
(((void)0, gSaveContext.save.cutsceneIndex) == D_8011F9B8[i].cutsceneIndex)) {
if (D_8011F9B8[i].type == 7) {
if ((play->sceneId == SCENE_LON_LON_RANCH) &&
(((void)0, gSaveContext.save.cutsceneIndex) == 0xFFF1)) {
(((void)0, gSaveContext.save.cutsceneIndex) == CS_INDEX_1)) {
Feacur marked this conversation as resolved.
Show resolved Hide resolved
D_8011F9B8[i].pos.x = player->actor.world.pos.x;
D_8011F9B8[i].pos.y = player->actor.world.pos.y;
D_8011F9B8[i].pos.z = player->actor.world.pos.z;
Expand Down
6 changes: 3 additions & 3 deletions src/code/z_kaleido_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ void KaleidoSetup_Update(PlayState* play) {

if (!IS_PAUSED(pauseCtx) && play->gameOverCtx.state == GAMEOVER_INACTIVE &&
play->transitionTrigger == TRANS_TRIGGER_OFF && play->transitionMode == TRANS_MODE_OFF &&
gSaveContext.save.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_InCsMode(play) &&
play->shootingGalleryStatus <= 1 && gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY &&
gSaveContext.magicState != MAGIC_STATE_FILL &&
gSaveContext.save.cutsceneIndex < CS_INDEX_0 && gSaveContext.nextCutsceneIndex < CS_INDEX_0 &&
!Play_InCsMode(play) && play->shootingGalleryStatus <= 1 &&
gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY && gSaveContext.magicState != MAGIC_STATE_FILL &&
(play->sceneId != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) {

if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) {
Expand Down
7 changes: 4 additions & 3 deletions src/code/z_kankyo.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
if ((((void)0, gSaveContext.save.dayTime) > ((void)0, gSaveContext.skyboxTime)) ||
(((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(1, 0) || gTimeSpeed < 0))
#else
if (((((void)0, gSaveContext.sceneLayer) >= 5 || gTimeSpeed != 0) &&
if (((((void)0, gSaveContext.sceneLayer) >= GET_CUTSCENE_LAYER(CS_INDEX_1) || gTimeSpeed != 0) &&
((void)0, gSaveContext.save.dayTime) > ((void)0, gSaveContext.skyboxTime)) ||
(((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(1, 0) || gTimeSpeed < 0))
#endif
Expand Down Expand Up @@ -1421,7 +1421,8 @@ void Environment_DrawSunAndMoon(PlayState* play) {
play->envCtx.sunPos.z = +(Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f;
}

if (gSaveContext.save.entranceIndex != ENTR_HYRULE_FIELD_0 || ((void)0, gSaveContext.sceneLayer) != 5) {
if (gSaveContext.save.entranceIndex != ENTR_HYRULE_FIELD_0 ||
((void)0, gSaveContext.sceneLayer) != GET_CUTSCENE_LAYER(CS_INDEX_1)) {
Matrix_Translate(play->view.eye.x + play->envCtx.sunPos.x, play->view.eye.y + play->envCtx.sunPos.y,
play->view.eye.z + play->envCtx.sunPos.z, MTXMODE_NEW);

Expand Down Expand Up @@ -2618,7 +2619,7 @@ void Environment_StopStormNatureAmbience(PlayState* play) {

void Environment_WarpSongLeave(PlayState* play) {
gWeatherMode = WEATHER_MODE_CLEAR;
gSaveContext.save.cutsceneIndex = 0;
gSaveContext.save.cutsceneIndex = CS_INDEX_DEFAULT;
gSaveContext.respawnFlag = -3;
play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex;
play->transitionTrigger = TRANS_TRIGGER_START;
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -4294,7 +4294,7 @@ void Message_Update(PlayState* play) {

if (msgCtx->textId != 0x2061 && msgCtx->textId != 0x2025 && msgCtx->textId != 0x208C &&
((msgCtx->textId < 0x88D || msgCtx->textId >= 0x893) || msgCtx->choiceIndex != 0) &&
(msgCtx->textId != 0x3055 && gSaveContext.save.cutsceneIndex < 0xFFF0)) {
(msgCtx->textId != 0x3055 && gSaveContext.save.cutsceneIndex < CS_INDEX_0)) {
PRINTF("=== day_time=%x ", ((void)0, gSaveContext.save.cutsceneIndex));
if (play->activeCamId == CAM_ID_MAIN) {
if (gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NO_CHANGE ||
Expand Down
10 changes: 5 additions & 5 deletions src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ void func_80083108(PlayState* play) {
s16 i;
s16 sp28 = false;

if ((gSaveContext.save.cutsceneIndex < 0xFFF0) ||
((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.save.cutsceneIndex == 0xFFF0))) {
if ((gSaveContext.save.cutsceneIndex < CS_INDEX_0) ||
((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.save.cutsceneIndex == CS_INDEX_0))) {
gSaveContext.forceRisingButtonAlphas = false;

if ((player->stateFlags1 & PLAYER_STATE1_23) || (play->shootingGalleryStatus > 1) ||
Expand Down Expand Up @@ -3523,7 +3523,7 @@ void Interface_Draw(PlayState* play) {
(Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT)) {
// Trade quest timer reached 0
sSubTimerStateTimer = 40;
gSaveContext.save.cutsceneIndex = 0;
gSaveContext.save.cutsceneIndex = CS_INDEX_DEFAULT;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_FADE_WHITE;
gSaveContext.subTimerState = SUBTIMER_STATE_OFF;
Expand Down Expand Up @@ -3861,7 +3861,7 @@ void Interface_Draw(PlayState* play) {
(play->sceneId != SCENE_INSIDE_GANONS_CASTLE_COLLAPSE))) {
sSubTimerStateTimer = 40;
gSaveContext.subTimerState = SUBTIMER_STATE_RESPAWN;
gSaveContext.save.cutsceneIndex = 0;
gSaveContext.save.cutsceneIndex = CS_INDEX_DEFAULT;
Message_StartTextbox(play, 0x71B0, NULL);
Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8);
} else {
Expand Down Expand Up @@ -4031,7 +4031,7 @@ void Interface_Update(PlayState* play) {

if (!IS_PAUSED(&play->pauseCtx)) {
if ((gSaveContext.minigameState == 1) || !IS_CUTSCENE_LAYER ||
((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.sceneLayer == 4))) {
((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.sceneLayer == GET_CUTSCENE_LAYER(CS_INDEX_0)))) {
if ((msgCtx->msgMode == MSGMODE_NONE) ||
((msgCtx->msgMode != MSGMODE_NONE) && (play->sceneId == SCENE_BOMBCHU_BOWLING_ALLEY))) {
if (play->gameOverCtx.state == GAMEOVER_INACTIVE) {
Expand Down
25 changes: 12 additions & 13 deletions src/code/z_play.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "global.h"
#include "fault.h"
#include "quake.h"
Expand Down Expand Up @@ -55,7 +54,7 @@ void Play_SetViewpoint(PlayState* this, s16 viewpoint) {

this->viewpoint = viewpoint;

if ((R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) && (gSaveContext.save.cutsceneIndex < 0xFFF0)) {
if ((R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) && (gSaveContext.save.cutsceneIndex < CS_INDEX_0)) {
// Play a sfx when the player toggles the camera
Audio_PlaySfxGeneral((viewpoint == VIEWPOINT_LOCKED) ? NA_SE_SY_CAMERA_ZOOM_DOWN : NA_SE_SY_CAMERA_ZOOM_UP,
&gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
Expand Down Expand Up @@ -324,13 +323,13 @@ void Play_Init(GameState* thisx) {
AnimTaskQueue_Reset(&this->animTaskQueue);
Cutscene_InitContext(this, &this->csCtx);

if (gSaveContext.nextCutsceneIndex != 0xFFEF) {
if (gSaveContext.nextCutsceneIndex != CS_INDEX_NEXT_EMPTY) {
gSaveContext.save.cutsceneIndex = gSaveContext.nextCutsceneIndex;
gSaveContext.nextCutsceneIndex = 0xFFEF;
gSaveContext.nextCutsceneIndex = CS_INDEX_NEXT_EMPTY;
}

if (gSaveContext.save.cutsceneIndex == 0xFFFD) {
gSaveContext.save.cutsceneIndex = 0;
if (gSaveContext.save.cutsceneIndex == CS_INDEX_EMPTY) {
gSaveContext.save.cutsceneIndex = CS_INDEX_DEFAULT;
}

if (gSaveContext.nextDayTime != NEXT_TIME_NONE) {
Expand All @@ -346,10 +345,10 @@ void Play_Init(GameState* thisx) {

Cutscene_HandleConditionalTriggers(this);

if (gSaveContext.gameMode != GAMEMODE_NORMAL || gSaveContext.save.cutsceneIndex >= 0xFFF0) {
if (gSaveContext.gameMode != GAMEMODE_NORMAL || gSaveContext.save.cutsceneIndex >= CS_INDEX_0) {
gSaveContext.nayrusLoveTimer = 0;
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) {
gSaveContext.sceneLayer = SCENE_LAYER_CHILD_DAY;
} else if (!LINK_IS_ADULT && !IS_DAY) {
Expand All @@ -367,13 +366,13 @@ void Play_Init(GameState* thisx) {
!IS_CUTSCENE_LAYER) {
if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY) &&
CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE)) {
gSaveContext.sceneLayer = 1;
gSaveContext.sceneLayer = SCENE_LAYER_CHILD_NIGHT;
} else {
gSaveContext.sceneLayer = 0;
gSaveContext.sceneLayer = SCENE_LAYER_CHILD_DAY;
}
} else if ((gEntranceTable[((void)0, gSaveContext.save.entranceIndex)].sceneId == SCENE_KOKIRI_FOREST) &&
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(
Expand All @@ -386,7 +385,7 @@ void Play_Init(GameState* thisx) {
// 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.
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"));
((void (*)(void))0x81000000)();
PRINTF(T("出戻り?\n", "Return?\n"));
Expand Down Expand Up @@ -598,7 +597,7 @@ void Play_Update(PlayState* this) {

Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_NOTHING);

if (gSaveContext.save.cutsceneIndex >= 0xFFF0) {
if (gSaveContext.save.cutsceneIndex >= CS_INDEX_0) {
sceneLayer = SCENE_LAYER_CUTSCENE_FIRST + (gSaveContext.save.cutsceneIndex & 0xF);
}

Expand Down
16 changes: 8 additions & 8 deletions src/code/z_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void Object_InitContext(PlayState* play, ObjectContext* objectCtx) {
if (play2->sceneId == SCENE_HYRULE_FIELD) {
spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT;
} else if (play2->sceneId == SCENE_GANON_BOSS) {
if (gSaveContext.sceneLayer != 4) {
if (gSaveContext.sceneLayer != GET_CUTSCENE_LAYER(CS_INDEX_0)) {
spaceSize = 1150 * 1024 - OBJECT_SPACE_ADJUSTMENT;
} else {
spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT;
Expand Down Expand Up @@ -382,7 +382,7 @@ BAD_RETURN(s32) Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd) {
play->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
play->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f;

if (((play->envCtx.sceneTimeSpeed == 0) && (gSaveContext.save.cutsceneIndex < 0xFFF0)) ||
if (((play->envCtx.sceneTimeSpeed == 0) && (gSaveContext.save.cutsceneIndex < CS_INDEX_0)) ||
(gSaveContext.save.entranceIndex == ENTR_LAKE_HYLIA_8)) {
#if OOT_VERSION >= PAL_1_0
gSaveContext.skyboxTime = ((void)0, gSaveContext.save.dayTime);
Expand Down Expand Up @@ -445,7 +445,7 @@ BAD_RETURN(s32) Scene_CommandAlternateHeaderList(PlayState* play, SceneCmd* cmd)
PRINTF("\n[ZU]sceneset time =[%X]", ((void)0, gSaveContext.save.cutsceneIndex));
PRINTF("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneLayer));

if (gSaveContext.sceneLayer != 0) {
if (gSaveContext.sceneLayer != SCENE_LAYER_CHILD_DAY) {
SceneCmd* altHeader = ((SceneCmd**)SEGMENTED_TO_VIRTUAL(cmd->altHeaders.data))[gSaveContext.sceneLayer - 1];

if (altHeader != NULL) {
Expand Down Expand Up @@ -488,7 +488,7 @@ BAD_RETURN(s32) Scene_CommandMiscSettings(PlayState* play, SceneCmd* cmd) {

if (((play->sceneId >= SCENE_HYRULE_FIELD) && (play->sceneId <= SCENE_OUTSIDE_GANONS_CASTLE)) ||
((play->sceneId >= SCENE_MARKET_ENTRANCE_DAY) && (play->sceneId <= SCENE_TEMPLE_OF_TIME_EXTERIOR_RUINS))) {
if (gSaveContext.save.cutsceneIndex < 0xFFF0) {
if (gSaveContext.save.cutsceneIndex < CS_INDEX_0) {
gSaveContext.save.info.worldMapAreaData |= gBitFlags[((void)0, gSaveContext.worldMapArea)];
PRINTF("000 area_arrival=%x (%d)\n", gSaveContext.save.info.worldMapAreaData,
((void)0, gSaveContext.worldMapArea));
Expand All @@ -501,15 +501,15 @@ void Scene_SetTransitionForNextEntrance(PlayState* play) {

if (!IS_DAY) {
if (!LINK_IS_ADULT) {
entranceIndex = play->nextEntranceIndex + 1;
entranceIndex = play->nextEntranceIndex + SCENE_LAYER_CHILD_NIGHT;
} else {
entranceIndex = play->nextEntranceIndex + 3;
entranceIndex = play->nextEntranceIndex + SCENE_LAYER_ADULT_NIGHT;
}
} else {
if (!LINK_IS_ADULT) {
entranceIndex = play->nextEntranceIndex;
entranceIndex = play->nextEntranceIndex + SCENE_LAYER_CHILD_DAY;
} else {
entranceIndex = play->nextEntranceIndex + 2;
entranceIndex = play->nextEntranceIndex + SCENE_LAYER_ADULT_DAY;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/code/z_scene_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) {

CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5145);

if (gSaveContext.sceneLayer == 5) {
if (gSaveContext.sceneLayer == GET_CUTSCENE_LAYER(CS_INDEX_1)) {
Feacur marked this conversation as resolved.
Show resolved Hide resolved
gCustomLensFlareOn = true;
gCustomLensFlarePos.x = -20.0f;
gCustomLensFlarePos.y = 1220.0f;
Expand Down Expand Up @@ -1186,9 +1186,9 @@ void Scene_DrawConfigKokiriForest(PlayState* play) {
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);

if (gSaveContext.sceneLayer == 4) {
if (gSaveContext.sceneLayer == GET_CUTSCENE_LAYER(CS_INDEX_0)) {
spA3 = 255 - (u8)play->roomCtx.drawParams[0];
} else if (gSaveContext.sceneLayer == 6) {
} else if (gSaveContext.sceneLayer == GET_CUTSCENE_LAYER(CS_INDEX_2)) {
spA0 = play->roomCtx.drawParams[0] + 500;
} else if (
#if OOT_VERSION < PAL_1_0
Expand Down
4 changes: 2 additions & 2 deletions src/code/z_sram.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,11 @@ void Sram_InitSave(FileSelectState* fileSelect, SramContext* sramCtx) {
gSaveContext.save.entranceIndex = ENTR_LINKS_HOUSE_0;
gSaveContext.save.linkAge = LINK_AGE_CHILD;
gSaveContext.save.dayTime = CLOCK_TIME(10, 0);
gSaveContext.save.cutsceneIndex = 0xFFF1;
gSaveContext.save.cutsceneIndex = CS_INDEX_1;

#if DEBUG_FEATURES
if (fileSelect->buttonIndex == 0) {
gSaveContext.save.cutsceneIndex = 0;
gSaveContext.save.cutsceneIndex = CS_INDEX_DEFAULT;
}
#endif

Expand Down
Loading