From 0d9419527ac3016b4b0ad016a223d5412c13d882 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Sat, 3 May 2025 05:33:18 -0400 Subject: [PATCH] Scene table restructure --- include/tables/scene_table.h | 21 ++++++++++++++++++++- include/z64scene.h | 26 ++++++++------------------ src/code/z_actor.c | 2 +- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/include/tables/scene_table.h b/include/tables/scene_table.h index f18faab35c..3765445914 100644 --- a/include/tables/scene_table.h +++ b/include/tables/scene_table.h @@ -8,6 +8,10 @@ * - Argument 4: Scene draw config index * - Argument 5: ? (Unknown) * - Argument 6: ? (Unknown) + * + * DEFINE_SCENE_TABLE_END auto-generates the SCENE_TABLE_MAX value + * DEFINE_SCENE_ENUM should only be defined when creating the `SceneId` enum. + * It creates an enum value for scenes that are referenced but no longer exist */ /* 0x00 */ DEFINE_SCENE(ydan_scene, g_pn_06, SCENE_DEKU_TREE, SDC_DEKU_TREE, 1, 2) /* 0x01 */ DEFINE_SCENE(ddan_scene, g_pn_08, SCENE_DODONGOS_CAVERN, SDC_DODONGOS_CAVERN, 1, 3) @@ -110,7 +114,12 @@ /* 0x62 */ DEFINE_SCENE(spot18_scene, g_pn_41, SCENE_GORON_CITY, SDC_GORON_CITY, 0, 0) /* 0x63 */ DEFINE_SCENE(spot20_scene, g_pn_42, SCENE_LON_LON_RANCH, SDC_LON_LON_RANCH, 0, 0) /* 0x64 */ DEFINE_SCENE(ganon_tou_scene, g_pn_43, SCENE_OUTSIDE_GANONS_CASTLE, SDC_OUTSIDE_GANONS_CASTLE, 0, 0) -#if DEBUG_ASSETS + +#if !DEBUG_ASSETS && defined(DEFINE_SCENE_ENUM) + DEFINE_SCENE_TABLE_END() +#endif + +#if DEBUG_ASSETS || defined(DEFINE_SCENE_ENUM) /* 0x65 */ DEFINE_SCENE(test01_scene, none, SCENE_TEST01, SDC_CALM_WATER, 0, 0) /* 0x66 */ DEFINE_SCENE(besitu_scene, none, SCENE_BESITU, SDC_BESITU, 0, 0) /* 0x67 */ DEFINE_SCENE(depth_test_scene, none, SCENE_DEPTH_TEST, SDC_DEFAULT, 0, 0) @@ -121,3 +130,13 @@ /* 0x6C */ DEFINE_SCENE(sasatest_scene, none, SCENE_SASATEST, SDC_DEFAULT, 0, 0) /* 0x6D */ DEFINE_SCENE(testroom_scene, none, SCENE_TESTROOM, SDC_DEFAULT, 0, 0) #endif + +#if DEBUG_ASSETS && defined(DEFINE_SCENE_ENUM) + DEFINE_SCENE_TABLE_END() +#endif + +#if defined(DEFINE_SCENE_ENUM) +/* 0x6E */ DEFINE_SCENE_ENUM(SCENE_UNUSED_6E) +/* 0x6F */ DEFINE_SCENE_ENUM(SCENE_UNUSED_6F) +/* 0x70 */ DEFINE_SCENE_ENUM(SCENE_UNUSED_70) +#endif diff --git a/include/z64scene.h b/include/z64scene.h index 09b342c047..9a9d3fe704 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -257,29 +257,19 @@ typedef union SceneCmd { typedef BAD_RETURN(s32) (*SceneCmdHandlerFunc)(struct PlayState*, SceneCmd*); #define DEFINE_SCENE(_0, _1, enum, _3, _4, _5) enum, +#define DEFINE_SCENE_ENUM(enum) enum, +#define DEFINE_SCENE_TABLE_END() \ + SCENE_TABLE_MAX, \ + SCENE_TABLE__ = SCENE_TABLE_MAX - 1, typedef enum SceneID { #include "tables/scene_table.h" - /* 0x6E */ SCENE_ID_MAX + SCENE_ID_MAX } SceneID; #undef DEFINE_SCENE - -// Fake enum values for scenes that are still referenced in the entrance table -#if !DEBUG_ASSETS -// Debug-only scenes -#define SCENE_TEST01 0x65 -#define SCENE_BESITU 0x66 -#define SCENE_DEPTH_TEST 0x67 -#define SCENE_SYOTES 0x68 -#define SCENE_SYOTES2 0x69 -#define SCENE_SUTARU 0x6A -#define SCENE_HAIRAL_NIWA2 0x6B -#define SCENE_SASATEST 0x6C -#define SCENE_TESTROOM 0x6D -#endif -// Deleted scene -#define SCENE_UNUSED_6E 0x6E +#undef DEFINE_SCENE_ENUM +#undef DEFINE_SCENE_TABLE_END // Macros for `EntranceInfo.field` #define ENTRANCE_INFO_CONTINUE_BGM_FLAG (1 << 15) @@ -514,6 +504,6 @@ void Scene_SetTransitionForNextEntrance(struct PlayState* play); void Scene_Draw(struct PlayState* play); extern EntranceInfo gEntranceTable[ENTR_MAX]; -extern SceneTableEntry gSceneTable[SCENE_ID_MAX]; +extern SceneTableEntry gSceneTable[SCENE_TABLE_MAX]; #endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 721087332e..5a6dd1ac1f 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3900,7 +3900,7 @@ void Actor_SetTextWithPrefix(PlayState* play, Actor* actor, s16 baseTextId) { case SCENE_KOKIRI_FOREST: case SCENE_SACRED_FOREST_MEADOW: case SCENE_LOST_WOODS: - case 112: + case SCENE_UNUSED_70: prefix = 0x1000; break; case SCENE_STABLE: