From 58813216fc7397a0b7356c2236269c783cf83fce Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 8 May 2021 17:16:21 -0400 Subject: [PATCH] Add scene macros (#792) * add scene macros * SCENECMD -> SCENE_CMD * light renaming * SCENE_CMD_ROOM_BEHAVIOR * update params names * Remove extra spaces * More review changes by fig * remove MM cmd ids * more review changes * last minute edit * I keep confusing both lights commands * Review changes * Yet another cutscene change * Unused02 is unused --- include/command_macros_base.h | 2 + include/z64scene.h | 114 +++++++++++++++++++++++++++++++++- src/code/z_scene.c | 4 +- 3 files changed, 116 insertions(+), 4 deletions(-) diff --git a/include/command_macros_base.h b/include/command_macros_base.h index 8d0a3917ae..c0d2ac4e89 100644 --- a/include/command_macros_base.h +++ b/include/command_macros_base.h @@ -16,4 +16,6 @@ #define CMD_W(a) (a) +#define CMD_PTR(a) (u32)(a) + #endif diff --git a/include/z64scene.h b/include/z64scene.h index cdfa1f4870..3e5f38d43a 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -1,6 +1,8 @@ #ifndef _Z64SCENE_H_ #define _Z64SCENE_H_ +#include "command_macros_base.h" + typedef struct { /* 0x00 */ u32 vromStart; /* 0x04 */ u32 vromEnd; @@ -37,7 +39,7 @@ typedef struct { /* 0x00 */ u8 code; /* 0x01 */ u8 data1; /* 0x04 */ u32 segment; -} SCmdCsCameraList; +} SCmdUnused02; typedef struct { /* 0x00 */ u8 code; @@ -277,7 +279,7 @@ typedef union { SCmdBase base; SCmdSpawnList spawnList; SCmdActorList actorList; - SCmdCsCameraList csCameraList; + SCmdUnused02 unused02; SCmdRoomList roomList; SCmdEntranceList entranceList; SCmdObjectList objectList; @@ -417,4 +419,112 @@ typedef enum { /* 0x6E */ SCENE_ID_MAX } SceneID; +// Scene commands + +typedef enum { + /* 0x00 */ SCENE_CMD_ID_SPAWN_LIST, + /* 0x01 */ SCENE_CMD_ID_ACTOR_LIST, + /* 0x02 */ SCENE_CMD_ID_UNUSED_02, + /* 0x03 */ SCENE_CMD_ID_COL_HEADER, + /* 0x04 */ SCENE_CMD_ID_ROOM_LIST, + /* 0x05 */ SCENE_CMD_ID_WIND_SETTINGS, + /* 0x06 */ SCENE_CMD_ID_ENTRANCE_LIST, + /* 0x07 */ SCENE_CMD_ID_SPECIAL_FILES, + /* 0x08 */ SCENE_CMD_ID_ROOM_BEHAVIOR, + /* 0x09 */ SCENE_CMD_ID_UNUSED_09, + /* 0x0A */ SCENE_CMD_ID_MESH, + /* 0x0B */ SCENE_CMD_ID_OBJECT_LIST, + /* 0x0C */ SCENE_CMD_ID_LIGHT_LIST, + /* 0x0D */ SCENE_CMD_ID_PATH_LIST, + /* 0x0E */ SCENE_CMD_ID_TRANSI_ACTOR_LIST, + /* 0x0F */ SCENE_CMD_ID_ENV_LIGHT_SETTINGS, + /* 0x10 */ SCENE_CMD_ID_TIME_SETTINGS, + /* 0x11 */ SCENE_CMD_ID_SKYBOX_SETTINGS, + /* 0x12 */ SCENE_CMD_ID_SKYBOX_DISABLES, + /* 0x13 */ SCENE_CMD_ID_EXIT_LIST, + /* 0x14 */ SCENE_CMD_ID_END, + /* 0x15 */ SCENE_CMD_ID_SOUND_SETTINGS, + /* 0x16 */ SCENE_CMD_ID_ECHO_SETTINGS, + /* 0x17 */ SCENE_CMD_ID_CUTSCENE_DATA, + /* 0x18 */ SCENE_CMD_ID_ALTERNATE_HEADER_LIST, + /* 0x19 */ SCENE_CMD_ID_MISC_SETTINGS +} SceneCommandTypeID; + +#define SCENE_CMD_SPAWN_LIST(numSpawns, spawnList) \ + { SCENE_CMD_ID_SPAWN_LIST, numSpawns, CMD_PTR(spawnList) } + +#define SCENE_CMD_ACTOR_LIST(numActors, actorList) \ + { SCENE_CMD_ID_ACTOR_LIST, numActors, CMD_PTR(actorList) } + +#define SCENE_CMD_UNUSED_02(unk, data) \ + { SCENE_CMD_ID_UNUSED_02, unk, CMD_PTR(data) } + +#define SCENE_CMD_COL_HEADER(colHeader) \ + { SCENE_CMD_ID_COL_HEADER, 0, CMD_PTR(colHeader) } + +#define SCENE_CMD_ROOM_LIST(numRooms, roomList) \ + { SCENE_CMD_ID_ROOM_LIST, numRooms, CMD_PTR(roomList) } + +#define SCENE_CMD_WIND_SETTINGS(xDir, yDir, zDir, strength) \ + { SCENE_CMD_ID_WIND_SETTINGS, 0, CMD_BBBB(xDir, yDir, zDir, strength) } + +#define SCENE_CMD_ENTRANCE_LIST(entranceList) \ + { SCENE_CMD_ID_ENTRANCE_LIST, 0, CMD_PTR(entranceList) } + +#define SCENE_CMD_SPECIAL_FILES(elfMessageFile, keepObjectId) \ + { SCENE_CMD_ID_SPECIAL_FILES, elfMessageFile, CMD_W(keepObjectId) } + +#define SCENE_CMD_ROOM_BEHAVIOR(curRoomUnk3, curRoomUnk2, showInvisActors, disableWarpSongs) \ + { SCENE_CMD_ID_ROOM_BEHAVIOR, curRoomUnk3, \ + curRoomUnk2 | _SHIFTL(showInvisActors, 8, 1) | _SHIFTL(disableWarpSongs, 10, 1) } + +#define SCENE_CMD_MESH(meshHeader) \ + { SCENE_CMD_ID_MESH, 0, CMD_PTR(meshHeader) } + +#define SCENE_CMD_OBJECT_LIST(numObjects, objectList) \ + { SCENE_CMD_ID_OBJECT_LIST, numObjects, CMD_PTR(objectList) } + +#define SCENE_CMD_LIGHT_LIST(numLights, lightList) \ + { SCENE_CMD_ID_POS_LIGHT_LIST, numLights, CMD_PTR(lightList) } + +#define SCENE_CMD_PATH_LIST(pathList) \ + { SCENE_CMD_ID_PATH_LIST, 0, CMD_PTR(pathList) } + +#define SCENE_CMD_TRANSITION_ACTOR_LIST(numTransitionActors, transitionActorList) \ + { SCENE_CMD_ID_TRANSI_ACTOR_LIST, numTransitionActors, CMD_PTR(transitionActorList) } + +#define SCENE_CMD_ENV_LIGHT_SETTINGS(numLightSettings, lightSettingsList) \ + { SCENE_CMD_ID_ENV_LIGHT_SETTINGS, numLightSettings, CMD_PTR(lightSettingsList) } + +#define SCENE_CMD_TIME_SETTINGS(hour, min, speed) \ + { SCENE_CMD_ID_TIME_SETTINGS, 0, CMD_BBBB(hour, min, speed, 0) } + +#define SCENE_CMD_SKYBOX_SETTINGS(skyboxId, weather, isIndoors) \ + { SCENE_CMD_ID_SKYBOX_SETTINGS, 0, CMD_BBBB(skyboxId, weather, isIndoors, 0) } + +#define SCENE_CMD_SKYBOX_DISABLES(disableSky, disableSunMoon) \ + { SCENE_CMD_ID_SKYBOX_DISABLES, 0, CMD_BBBB(disableSky, disableSunMoon, 0, 0) } + +#define SCENE_CMD_EXIT_LIST(exitList) \ + { SCENE_CMD_ID_EXIT_LIST, 0, CMD_PTR(exitList) } + +#define SCENE_CMD_END() \ + { SCENE_CMD_ID_END, 0, CMD_W(0) } + +#define SCENE_CMD_SOUND_SETTINGS(audioSessionId, nighttimeSfx, bgmId) \ + { SCENE_CMD_ID_SOUND_SETTINGS, audioSessionId, CMD_BBBB(0, 0, nighttimeSfx, bgmId) } + +#define SCENE_CMD_ECHO_SETTINGS(echo) \ + { SCENE_CMD_ID_ECHO_SETTINGS, 0, CMD_BBBB(0, 0, 0, echo) } + +#define SCENE_CMD_CUTSCENE_DATA(cutsceneData) \ + { SCENE_CMD_ID_CUTSCENE_DATA, 0, CMD_PTR(cutsceneData) } + +#define SCENE_CMD_ALTERNATE_HEADER_LIST(alternateHeaderList) \ + { SCENE_CMD_ID_ALTERNATE_HEADER_LIST, 0, CMD_PTR(alternateHeaderList) } + +#define SCENE_CMD_MISC_SETTINGS(camMode, worldMapLocation) \ + { SCENE_CMD_ID_MISC_SETTINGS, camMode, CMD_W(worldMapLocation) } + + #endif diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 894b2fee81..8e3ab67a26 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -202,9 +202,9 @@ void func_800985DC(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->setupActorList = SEGMENTED_TO_VIRTUAL(cmd->actorList.segment); } -// Scene Command 0x02: Cutscene Camera List +// Scene Command 0x02: Unused 02 void func_80098630(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->csCameraList.segment); + globalCtx->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); } // Scene Command 0x03: Collision Header