From 2cb01b5b6a69635f7c8f554cf97442268aff28be Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 23 Mar 2023 09:36:09 +1100 Subject: [PATCH] z_room (1 non-matching) (#1143) * begin room docs and decomp * match Room_DrawImageSingle * match Room_DrawImageMulti * Room_AllocateAndLoad non-matching * big improvements on Room_DrawCullable * match Room_AllocateAndLoad * improvement? * cleanup * comments * cleanup * small pr suggestions * PR Suggestions * cleanup sceneCmds * some PR * PR Suggestions * more PR Suggestions * col to collision --- include/functions.h | 79 ++- include/regs.h | 5 + include/variables.h | 2 - include/z64.h | 2 - include/z64bgcheck.h | 5 +- include/z64scene.h | 240 +++---- spec | 1 - src/code/PreRender.c | 12 +- src/code/z_actor.c | 2 +- src/code/z_parameter.c | 7 +- src/code/z_play.c | 16 +- src/code/z_player_lib.c | 4 +- src/code/z_room.c | 589 ++++++++++++++++-- src/code/z_scene.c | 143 ++--- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 2 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 4 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 11 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 4 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 2 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 4 +- tools/disasm/functions.txt | 82 +-- tools/disasm/variables.txt | 4 +- tools/namefixer.py | 5 +- tools/sizes/code_functions.csv | 82 +-- 26 files changed, 907 insertions(+), 404 deletions(-) diff --git a/include/functions.h b/include/functions.h index 223d4badbe..d4ecd9579d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1888,19 +1888,14 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b); void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); void func_8012D40C(f32* param_1, f32* param_2, s16* param_3); -void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4); -void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags); -void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags); -void Room_DrawType2Mesh(PlayState* play, Room* room, u32 flags); -void func_8012DEE8(PlayState* play, Room* room, u32 flags); -u32 func_8012E254(s32 param_1, PlayState* play); -void func_8012E32C(PlayState* play, Room* room, u32 flags); -void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags); + +void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3); void Room_Init(PlayState* play, RoomContext* roomCtx); -u32 Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx); +size_t Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx); s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index); s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx); void Room_Draw(PlayState* play, Room* room, u32 flags); + void func_8012EBF8(PlayState* play, RoomContext* roomCtx); s32 Inventory_GetBtnBItem(PlayState* play); void Inventory_ChangeEquipment(s16 value); @@ -1919,40 +1914,40 @@ s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId); s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index); void Object_LoadAll(ObjectContext* objectCtx); void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id); -void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd); +void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd); +void Scene_CommandActorList(PlayState* play, SceneCmd* cmd); +void Scene_CommandActorCutsceneCamList(PlayState* play, SceneCmd* cmd); +void Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd); +void Scene_CommandRoomList(PlayState* play, SceneCmd* cmd); +void Scene_CommandEntranceList(PlayState* play, SceneCmd* cmd); +void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd); +void Scene_CommandRoomBehavior(PlayState* play, SceneCmd* cmd); +void Scene_CommandMesh(PlayState* play, SceneCmd* cmd); +void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd); +void Scene_CommandLightList(PlayState* play, SceneCmd* cmd); +void Scene_CommandPathList(PlayState* play, SceneCmd* cmd); +void Scene_CommandTransiActorList(PlayState* play, SceneCmd* cmd); void Door_InitContext(GameState* gameState, DoorContext* doorCtx); -void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd); +void Scene_CommandEnvLightSettings(PlayState* play, SceneCmd* cmd); void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex); -void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd); -void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd); +void Scene_CommandSkyboxSettings(PlayState* play, SceneCmd* cmd); +void Scene_CommandSkyboxDisables(PlayState* play, SceneCmd* cmd); +void Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd); +void Scene_CommandWindSettings(PlayState* play, SceneCmd* cmd); +void Scene_CommandExitList(PlayState* play, SceneCmd* cmd); +void Scene_Command09(PlayState* play, SceneCmd* cmd); +void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd); +void Scene_CommandEchoSetting(PlayState* play, SceneCmd* cmd); +void Scene_CommandAltHeaderList(PlayState* play, SceneCmd* cmd); +void Scene_CommandCutsceneList(PlayState* play, SceneCmd* cmd); +void Scene_CommandActorCutsceneList(PlayState* play, SceneCmd* cmd); +void Scene_CommandMiniMap(PlayState* play, SceneCmd* cmd); +void Scene_Command1D(PlayState* play, SceneCmd* cmd); +void Scene_CommandMiniMapCompassInfo(PlayState* play, SceneCmd* cmd); +void Scene_CommandSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd); +void Scene_CommandAnimatedMaterials(PlayState* play, SceneCmd* cmd); void Scene_SetExitFade(PlayState* play); -s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header); +s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd); u16 Entrance_Create(s32 scene, s32 spawn, s32 layer); u16 Entrance_CreateFromSpawn(s32 spawn); void Scene_Draw(PlayState* play); @@ -2319,7 +2314,7 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) void func_80169EFC(GameState* thisx); void func_80169F78(GameState* thisx); void func_80169FDC(GameState* thisx); -s32 func_80169FFC(GameState* thisx); +s32 Play_CamIsNotFixed(GameState* thisx); s32 FrameAdvance_IsEnabled(GameState* thisx); s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw); s32 Play_IsUnderwater(PlayState* this, Vec3f* pos); @@ -2367,7 +2362,7 @@ void PreRender_ApplyFiltersSlowlyInit(PreRender* this); void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this); void func_801720C4(PreRender* this); void func_801720FC(PreRenderParams* params, Gfx** gfxp); -void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags); +void Prerender_DrawBackground2D(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags); void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size); void THGA_Dt(TwoHeadGfxArena* thga); u32 THGA_IsCrash(TwoHeadGfxArena* thga); diff --git a/include/regs.h b/include/regs.h index 5dee53e977..8de13fb66e 100644 --- a/include/regs.h +++ b/include/regs.h @@ -63,6 +63,7 @@ extern RegEditor* gRegEditor; #define R_RUN_SPEED_LIMIT REG(45) #define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT +#define R_ROOM_IMAGE_NODRAW_FLAGS SREG(25) #define R_UPDATE_RATE SREG(30) #define R_FB_FILTER_TYPE SREG(80) #define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) @@ -139,6 +140,10 @@ extern RegEditor* gRegEditor; #define R_MINIMAP_DISABLED XREG(95) #define R_TRANS_FADE_FLASH_ALPHA_STEP iREG(50) // Set to a negative number to start the flash +#define R_ROOM_CULL_DEBUG_MODE iREG(86) +#define R_ROOM_CULL_NUM_ENTRIES iREG(87) +#define R_ROOM_CULL_USED_ENTRIES iREG(88) +#define R_ROOM_CULL_DEBUG_TARGET iREG(89) #define R_B_LABEL_DD WREG(0) #define R_OW_MINIMAP_X WREG(29) diff --git a/include/variables.h b/include/variables.h index b362c6a37a..9ce8d04d57 100644 --- a/include/variables.h +++ b/include/variables.h @@ -592,8 +592,6 @@ extern Gfx gCullFrontDList[]; extern Gfx sSetupDL[438]; extern Gfx sFillSetupDL[12]; extern Gfx gEmptyDL[1]; -extern Vec3f D_801C1D10; -extern room_draw_func roomDrawFuncs[4]; extern u32 gBitFlags[32]; extern u16 gEquipMasks[]; extern u16 gEquipNegMasks[]; diff --git a/include/z64.h b/include/z64.h index cd9dc71cf3..34be175f4f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -563,8 +563,6 @@ typedef void (*ColChkApplyFunc)(struct PlayState*, CollisionCheckContext*, Colli typedef void (*ColChkVsFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Collider*); typedef s32 (*ColChkLineFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); -typedef void(*room_draw_func)(struct PlayState* play, Room* room, u32 flags); - typedef struct { /* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc. /* 0x001 */ UNK_TYPE1 pad1[0x13]; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index fa0443e65b..ad56599b5b 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -96,7 +96,10 @@ typedef struct { /* 0x00 */ Vec3s pos; /* 0x06 */ Vec3s rot; /* 0x0C */ s16 fov; - /* 0x0E */ s16 unk_0E; + /* 0x0E */ union { + s16 roomImageOverrideBgCamIndex; + s16 unk_0E; + }; /* 0x10 */ s16 unk_10; } BgCamFuncData; // size = 0x12 diff --git a/include/z64scene.h b/include/z64scene.h index 66830d86d4..84b405b902 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -13,6 +13,9 @@ typedef struct { /* 0x4 */ uintptr_t vromEnd; } RomFile; // size = 0x8 +#define ROOM_DRAW_OPA (1 << 0) +#define ROOM_DRAW_XLU (1 << 1) + typedef struct { /* 0x0 */ u8 code; /* 0x1 */ u8 data1; @@ -213,58 +216,132 @@ typedef struct { /* 0x4 */ void* segment; } SCmdMinimapChests; // size = 0x8 -typedef struct { - /* 0x0 */ Gfx* opaqueDl; - /* 0x4 */ Gfx* translucentDl; -} RoomMeshType0Params; // size = 0x8 - -// Fields TODO -typedef struct { - /* 0x0 */ u8 type; - /* 0x1 */ u8 format; // 1 = single, 2 = multi -} RoomMeshType1; // size = 0x2 - -// Size TODO -typedef struct { - /* 0x0 */ UNK_TYPE1 pad0[0x10]; -} RoomMeshType1Params; // size = 0x10 - -typedef struct { - /* 0x0 */ UNK_TYPE1 pad0[0x10]; -} RoomMeshType2Params; // size = 0x10 +typedef enum { + /* 0 */ ROOM_SHAPE_TYPE_NORMAL, + /* 1 */ ROOM_SHAPE_TYPE_IMAGE, + /* 2 */ ROOM_SHAPE_TYPE_CULLABLE, + /* 3 */ ROOM_SHAPE_TYPE_NONE, + /* 4 */ ROOM_SHAPE_TYPE_MAX +} RoomShapeType; typedef struct { /* 0x0 */ u8 type; - /* 0x1 */ u8 count; - /* 0x2 */ UNK_TYPE1 pad2[0x2]; - /* 0x4 */ RoomMeshType0Params* paramsStart; - /* 0x8 */ RoomMeshType0Params* paramsEnd; -} RoomMeshType0; // size = 0xC +} RoomShapeBase; // size = 0x1 typedef struct { - /* 0x0 */ u8 type; - /* 0x1 */ u8 count; - /* 0x2 */ UNK_TYPE1 pad2[0x2]; - /* 0x4 */ RoomMeshType2Params* paramsStart; - /* 0x8 */ RoomMeshType2Params* paramsEnd; -} RoomMeshType2; // size = 0xC + /* 0x0 */ Gfx* opa; + /* 0x4 */ Gfx* xlu; +} RoomShapeDListsEntry; // size = 0x8 + +typedef struct { + /* 0x0 */ RoomShapeBase base; + /* 0x1 */ u8 numEntries; + /* 0x4 */ RoomShapeDListsEntry* entries; + /* 0x8 */ RoomShapeDListsEntry* entriesEnd; +} RoomShapeNormal; // size = 0xC + +typedef enum { + /* 1 */ ROOM_SHAPE_IMAGE_AMOUNT_SINGLE = 1, + /* 2 */ ROOM_SHAPE_IMAGE_AMOUNT_MULTI +} RoomShapeImageAmountType; + +typedef struct { + /* 0x0 */ RoomShapeBase base; + /* 0x1 */ u8 amountType; // uses `RoomShapeImageAmountType` + /* 0x4 */ RoomShapeDListsEntry* entry; +} RoomShapeImageBase; // size = 0x8 + +typedef struct { + /* 0x00 */ RoomShapeImageBase base; + /* 0x08 */ void* source; + /* 0x0C */ u32 unk_0C; + /* 0x10 */ void* tlut; + /* 0x14 */ u16 width; + /* 0x16 */ u16 height; + /* 0x18 */ u8 fmt; + /* 0x19 */ u8 siz; + /* 0x1A */ u16 tlutMode; + /* 0x1C */ u16 tlutCount; +} RoomShapeImageSingle; // size = 0x20 + +typedef struct { + /* 0x00 */ u16 unk_00; + /* 0x02 */ u8 bgCamIndex; // the bg cam index this entry is for + /* 0x04 */ void* source; + /* 0x08 */ u32 unk_0C; + /* 0x0C */ void* tlut; + /* 0x10 */ u16 width; + /* 0x12 */ u16 height; + /* 0x14 */ u8 fmt; + /* 0x15 */ u8 siz; + /* 0x16 */ u16 tlutMode; + /* 0x18 */ u16 tlutCount; +} RoomShapeImageMultiBgEntry; // size = 0x1C + +typedef struct { + /* 0x0 */ RoomShapeImageBase base; + /* 0x8 */ u8 numBackgrounds; + /* 0xC */ RoomShapeImageMultiBgEntry* backgrounds; +} RoomShapeImageMulti; // size = 0x10 + +typedef struct { + /* 0x0 */ Vec3s boundsSphereCenter; + /* 0x6 */ s16 boundsSphereRadius; + /* 0x8 */ Gfx* opa; + /* 0xC */ Gfx* xlu; +} RoomShapeCullableEntry; // size = 0x10 + +typedef struct { + /* 0x0 */ RoomShapeBase base; + /* 0x1 */ u8 numEntries; + /* 0x4 */ RoomShapeCullableEntry* entries; + /* 0x8 */ RoomShapeCullableEntry* entriesEnd; +} RoomShapeCullable; // size = 0xC typedef union { - RoomMeshType0 type0; - RoomMeshType1 type1; - RoomMeshType2 type2; -} RoomMesh; // size = 0xC + RoomShapeBase base; + RoomShapeNormal normal; + union { + RoomShapeImageBase base; + RoomShapeImageSingle single; + RoomShapeImageMulti multi; + } image; + RoomShapeCullable cullable; +} RoomShape; // "Ground Shape" + +// TODO: update ZAPD +#define SCENE_CMD_MESH SCENE_CMD_ROOM_SHAPE + +// TODO: Check which ones don't exist +typedef enum { + /* 0 */ ROOM_BEHAVIOR_TYPE1_0, + /* 1 */ ROOM_BEHAVIOR_TYPE1_1, + /* 2 */ ROOM_BEHAVIOR_TYPE1_2, + /* 3 */ ROOM_BEHAVIOR_TYPE1_3, // unused + /* 4 */ ROOM_BEHAVIOR_TYPE1_4, + /* 5 */ ROOM_BEHAVIOR_TYPE1_5 +} RoomBehaviorType1; + +typedef enum { + /* 0 */ ROOM_BEHAVIOR_TYPE2_0, + /* 1 */ ROOM_BEHAVIOR_TYPE2_1, + /* 2 */ ROOM_BEHAVIOR_TYPE2_2, + /* 3 */ ROOM_BEHAVIOR_TYPE2_HOT, + /* 4 */ ROOM_BEHAVIOR_TYPE2_4, + /* 5 */ ROOM_BEHAVIOR_TYPE2_5, + /* 6 */ ROOM_BEHAVIOR_TYPE2_6 +} RoomBehaviorType2; typedef struct { /* 0x00 */ s8 num; /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; // 3: Room is hot - /* 0x03 */ u8 unk3; + /* 0x02 */ u8 behaviorType2; + /* 0x03 */ u8 behaviorType1; /* 0x04 */ s8 echo; /* 0x05 */ u8 lensMode; /* 0x06 */ u8 enablePosLights; /* 0x07 */ UNK_TYPE1 pad7[0x1]; - /* 0x08 */ RoomMesh* mesh; + /* 0x08 */ RoomShape* roomShape; /* 0x0C */ void* segment; /* 0x10 */ UNK_TYPE1 pad10[0x4]; } Room; // size = 0x14 @@ -274,7 +351,7 @@ typedef struct { /* 0x14 */ Room prevRoom; /* 0x28 */ void* roomMemPages[2]; // In a scene with transitions, roomMemory is split between two pages that toggle each transition. This is one continuous range, as the second page allocates from the end /* 0x30 */ u8 activeMemPage; // 0 - First page in memory, 1 - Second page - /* 0x31 */ s8 unk31; + /* 0x31 */ s8 status; /* 0x32 */ UNK_TYPE1 pad32[0x2]; /* 0x34 */ void* activeRoomVram; /* 0x38 */ DmaRequest dmaRequest; @@ -286,15 +363,17 @@ typedef struct { /* 0x7A */ UNK_TYPE2 unk7A[3]; } RoomContext; // size = 0x80 -typedef struct { +typedef void(*RoomDrawHandler)(struct PlayState* play, Room* room, u32 flags); + +typedef struct TransitionActorEntry { struct { s8 room; // Room to switch to s8 bgCamIndex; // How the camera reacts during the transition. -2 for spiral staircase. -1 for generic door. 0+ will index scene CamData } /* 0x0 */ sides[2]; // 0 = front, 1 = back - /* 0x4 */ s16 id; + /* 0x4 */ s16 id; /* 0x6 */ Vec3s pos; - /* 0xC */ s16 rotY; - /* 0xE */ u16 params; + /* 0xC */ s16 rotY; + /* 0xE */ u16 params; } TransitionActorEntry; // size = 0x10 typedef struct { @@ -390,77 +469,6 @@ typedef struct { /* 0x00C */ ObjectStatus status[OBJECT_EXCHANGE_BANK_MAX]; } ObjectContext; // size = 0x958 -typedef struct { - /* 0x0 */ u8 headerType; -} MeshHeaderBase; // size = 0x1 - -typedef struct { - /* 0x0 */ MeshHeaderBase base; - /* 0x1 */ u8 numEntries; - /* 0x4 */ u32 dListStart; - /* 0x8 */ u32 dListEnd; -} MeshHeader0; // size = 0xC - -typedef struct { - /* 0x0 */ u32 opaqueDList; - /* 0x4 */ u32 translucentDList; -} MeshEntry0; // size = 0x8 - -typedef struct { - /* 0x0 */ MeshHeaderBase base; - /* 0x1 */ u8 format; - /* 0x4 */ u32 entryRecord; -} MeshHeader1Base; // size = 0x8 - -typedef struct { - /* 0x00 */ MeshHeader1Base base; - /* 0x08 */ u32 imagePtr; - /* 0x0C */ u32 unknown; - /* 0x10 */ u32 unknown2; - /* 0x14 */ u16 bgWidth; - /* 0x16 */ u16 bgHeight; - /* 0x18 */ u8 imageFormat; - /* 0x19 */ u8 imageSize; - /* 0x1A */ u16 imagePal; - /* 0x1C */ u16 imageFlip; -} MeshHeader1Single; // size = 0x20 - -typedef struct { - /* 0x0 */ MeshHeader1Base base; - /* 0x8 */ u8 bgCnt; - /* 0xC */ u32 bgRecordPtr; -} MeshHeader1Multi; // size = 0x10 - -typedef struct { - /* 0x00 */ u16 unknown; - /* 0x02 */ s8 bgID; - /* 0x04 */ u32 imagePtr; - /* 0x08 */ u32 unknown2; - /* 0x0C */ u32 unknown3; - /* 0x10 */ u16 bgWidth; - /* 0x12 */ u16 bgHeight; - /* 0x14 */ u8 imageFmt; - /* 0x15 */ u8 imageSize; - /* 0x16 */ u16 imagePal; - /* 0x18 */ u16 imageFlip; -} BackgroundRecord; // size = 0x1C - -typedef struct { - /* 0x0 */ s16 playerXMax; - /* 0x2 */ s16 playerZMax; - /* 0x4 */ s16 playerXMin; - /* 0x6 */ s16 playerZMin; - /* 0x8 */ u32 opaqueDList; - /* 0xC */ u32 translucentDList; -} MeshEntry2; // size = 0x10 - -typedef struct { - /* 0x0 */ MeshHeaderBase base; - /* 0x1 */ u8 numEntries; - /* 0x4 */ u32 dListStart; - /* 0x8 */ u32 dListEnd; -} MeshHeader2; // size = 0xC - typedef struct { /* 0x0 */ u8 count; // number of points in the path /* 0x1 */ u8 unk1; @@ -846,7 +854,7 @@ typedef enum { /* 0x07 */ SCENE_CMD_ID_SPECIAL_FILES, /* 0x08 */ SCENE_CMD_ID_ROOM_BEHAVIOR, /* 0x09 */ SCENE_CMD_ID_UNK_09, - /* 0x0A */ SCENE_CMD_ID_MESH, + /* 0x0A */ SCENE_CMD_ID_ROOM_SHAPE, /* 0x0B */ SCENE_CMD_ID_OBJECT_LIST, /* 0x0C */ SCENE_CMD_ID_LIGHT_LIST, /* 0x0D */ SCENE_CMD_ID_PATH_LIST, @@ -905,8 +913,8 @@ typedef enum { #define SCENE_CMD_UNK_09() \ { SCENE_CMD_ID_UNK_09, 0, CMD_W(0) } -#define SCENE_CMD_MESH(meshHeader) \ - { SCENE_CMD_ID_MESH, 0, CMD_PTR(meshHeader) } +#define SCENE_CMD_ROOM_SHAPE(roomShape) \ + { SCENE_CMD_ID_ROOM_SHAPE, 0, CMD_PTR(roomShape) } #define SCENE_CMD_OBJECT_LIST(numObjects, objectList) \ { SCENE_CMD_ID_OBJECT_LIST, numObjects, CMD_PTR(objectList) } diff --git a/spec b/spec index 404d100262..8c03e0389f 100644 --- a/spec +++ b/spec @@ -505,7 +505,6 @@ beginseg include "build/src/code/z_rcp.o" pad_text include "build/src/code/z_room.o" - include "build/data/code/z_room.data.o" include "build/src/code/code_8012EC80.o" pad_text include "build/data/code/code_801C2410.data.o" diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 16ae999c50..075f941d46 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -53,8 +53,8 @@ void func_8016FDB8(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 ar flags = 0x1C; } - func_80172758(&gfx, buf, NULL, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, 0.0f, - 1.0f, 1.0f, flags); + Prerender_DrawBackground2D(&gfx, buf, NULL, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, + 0.0f, 0.0f, 1.0f, 1.0f, flags); gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); @@ -89,8 +89,8 @@ void func_8016FF90(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, s32 en gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); - func_80172758(&gfx, buf, 0, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, 0.0f, 1.0f, - 1.0f, 0xB); + Prerender_DrawBackground2D(&gfx, buf, 0, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, + 0.0f, 1.0f, 1.0f, 0xB); gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); @@ -454,8 +454,8 @@ void func_801720C4(PreRender* this) { #pragma GLOBAL_ASM("asm/non_matchings/code/PreRender/func_801720FC.s") -void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, - f32 y, f32 xScale, f32 yScale, u32 flags) { +void Prerender_DrawBackground2D(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, + u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags) { PreRenderParams params; PreRenderParams* paramsp = ¶ms; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 72d330f590..d3eea4ebe5 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1344,7 +1344,7 @@ s32 func_800B715C(PlayState* play) { } void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { - if ((play->roomCtx.curRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { + if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && (player->actor.id == ACTOR_PLAYER)) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index f3bfb530f3..ca127a8b65 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1767,7 +1767,7 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { break; } - if ((play->roomCtx.curRoom.unk3 == 1) && (interfaceCtx->minimapAlpha >= 255)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) && (interfaceCtx->minimapAlpha >= 255)) { interfaceCtx->minimapAlpha = 255; } } @@ -5096,8 +5096,9 @@ void Interface_Draw(PlayState* play) { // Load in Grandma's Story gSPLoadUcodeL(OVERLAY_DISP++, gspS2DEX2_fifo); gfx = OVERLAY_DISP; - func_80172758(&gfx, sStoryTextures[interfaceCtx->storyType], sStoryTLUTs[interfaceCtx->storyType], - SCREEN_WIDTH, SCREEN_HEIGHT, 2, 1, 0x8000, 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0); + Prerender_DrawBackground2D(&gfx, sStoryTextures[interfaceCtx->storyType], + sStoryTLUTs[interfaceCtx->storyType], SCREEN_WIDTH, SCREEN_HEIGHT, 2, 1, 0x8000, + 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0); OVERLAY_DISP = gfx; gSPLoadUcode(OVERLAY_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); diff --git a/src/code/z_play.c b/src/code/z_play.c index f6a425367f..5f8c197f27 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -992,8 +992,8 @@ void Play_UpdateMain(PlayState* this) { Rumble_SetUpdateEnabled(false); } - Room_nop8012D510(this, &this->roomCtx.curRoom, &input[1], 0); - Room_nop8012D510(this, &this->roomCtx.prevRoom, &input[1], 1); + Room_Noop(this, &this->roomCtx.curRoom, &input[1], 0); + Room_Noop(this, &this->roomCtx.prevRoom, &input[1], 1); Skybox_Update(&this->skyboxCtx); if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { @@ -1127,7 +1127,7 @@ void Play_DrawMain(PlayState* this) { } if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (gTransitionTileState <= TRANS_TILE_SETUP)) { - if (this->skyboxCtx.skyboxShouldDraw || (this->roomCtx.curRoom.mesh->type0.type == 1)) { + if (this->skyboxCtx.skyboxShouldDraw || (this->roomCtx.curRoom.roomShape->base.type == ROOM_SHAPE_TYPE_IMAGE)) { func_8012CF0C(gfxCtx, false, true, 0, 0, 0); } else { func_8012CF0C(gfxCtx, true, true, this->lightCtx.fogColor.r, this->lightCtx.fogColor.g, @@ -1573,7 +1573,7 @@ void Play_InitScene(PlayState* this, s32 spawn) { Door_InitContext(&this->state, &this->doorCtx); Room_Init(this, &this->roomCtx); gSaveContext.worldMapArea = 0; - Scene_ProcessHeader(this, this->sceneSegment); + Scene_ExecuteCommands(this, this->sceneSegment); Play_InitEnvironment(this, this->skyboxId); } @@ -1940,11 +1940,10 @@ void func_80169FDC(GameState* thisx) { func_80169F78(thisx); } -// Used by Kankyo to determine how to change the lighting, e.g. for game over. -s32 func_80169FFC(GameState* thisx) { +s32 Play_CamIsNotFixed(GameState* thisx) { PlayState* this = (PlayState*)thisx; - return this->roomCtx.curRoom.mesh->type0.type != 1; + return this->roomCtx.curRoom.roomShape->base.type != ROOM_SHAPE_TYPE_IMAGE; } s32 FrameAdvance_IsEnabled(GameState* thisx) { @@ -2304,7 +2303,8 @@ void Play_Init(GameState* thisx) { while (!Room_HandleLoadCallbacks(this, &this->roomCtx)) {} - if ((CURRENT_DAY != 0) && ((this->roomCtx.curRoom.unk3 == 1) || (this->roomCtx.curRoom.unk3 == 5))) { + if ((CURRENT_DAY != 0) && ((this->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) || + (this->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_5))) { Actor_Spawn(&this->actorCtx, this, ACTOR_EN_TEST4, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0); } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 4bdd22e0ad..6e7d0222c5 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -441,7 +441,7 @@ void func_80123140(PlayState* play, Player* player) { IREG(69) = bootRegs[16]; MREG(95) = bootRegs[17]; - if (play->roomCtx.curRoom.unk3 == 2) { + if (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_2) { R_RUN_SPEED_LIMIT = 500; } @@ -1456,7 +1456,7 @@ s32 Player_GetEnvironmentalHazard(PlayState* play) { EnvHazardTextTriggerEntry* triggerEntry; s32 envHazard; - if (play->roomCtx.curRoom.unk2 == 3) { // Room is hot + if (play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_HOT) { envHazard = PLAYER_ENV_HAZARD_HOTROOM - 1; } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->underwaterTimer > 80)) { envHazard = PLAYER_ENV_HAZARD_UNDERWATER_FREE - 1; diff --git a/src/code/z_room.c b/src/code/z_room.c index eb615c4093..3358bb3003 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -1,62 +1,481 @@ #include "global.h" -void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) { +void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3) { } -void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags) { +void Room_DrawNone(PlayState* play, Room* room, u32 flags) { } -void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags) { - RoomMeshType0* mesh; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +void Room_DrawNormal(PlayState* play, Room* room, u32 flags) { + RoomShapeNormal* roomShape; + RoomShapeDListsEntry* entry; s32 i; - RoomMeshType0Params* meshParams; - GraphicsContext* gfxCtx; - UNK_TYPE4 pad; - gfxCtx = play->state.gfxCtx; - if (flags & 1) { - func_800BCBF4(&D_801C1D10, play); - gSPSegment(gfxCtx->polyOpa.p++, 0x03, room->segment); + OPEN_DISPS(play->state.gfxCtx); + + if (flags & ROOM_DRAW_OPA) { + func_800BCBF4(&sZeroVec, play); + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); func_8012C268(play); - gSPMatrix(gfxCtx->polyOpa.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } - if (flags & 2) { - func_800BCC68(&D_801C1D10, play); - gSPSegment(gfxCtx->polyXlu.p++, 0x03, room->segment); + if (flags & ROOM_DRAW_XLU) { + func_800BCC68(&sZeroVec, play); + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); func_8012C2DC(play->state.gfxCtx); - gSPMatrix(gfxCtx->polyXlu.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } - mesh = &room->mesh->type0; - meshParams = Lib_SegmentedToVirtual(mesh->paramsStart); - for (i = 0; i < mesh->count; i++) { - if ((flags & 1) && (meshParams->opaqueDl != NULL)) { - gSPDisplayList(gfxCtx->polyOpa.p++, meshParams->opaqueDl); + roomShape = &room->roomShape->normal; + entry = Lib_SegmentedToVirtual(roomShape->entries); + for (i = 0; i < roomShape->numEntries; i++) { + if ((flags & ROOM_DRAW_OPA) && (entry->opa != NULL)) { + gSPDisplayList(POLY_OPA_DISP++, entry->opa); } - if ((flags & 2) && (meshParams->translucentDl != NULL)) { - gSPDisplayList(gfxCtx->polyXlu.p++, meshParams->translucentDl); + if ((flags & ROOM_DRAW_XLU) && (entry->xlu != NULL)) { + gSPDisplayList(POLY_XLU_DISP++, entry->xlu); } - meshParams++; + entry++; } + + CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_DrawType2Mesh.s") +typedef enum { + /* 0 */ ROOM_CULL_DEBUG_MODE_OFF, + /* 1 */ ROOM_CULL_DEBUG_MODE_UP_TO_TARGET, + /* 2 */ ROOM_CULL_DEBUG_MODE_ONLY_TARGET +} RoomCullableDebugMode; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012DEE8.s") +typedef struct RoomShapeCullableEntryLinked { + /* 0x00 */ RoomShapeCullableEntry* entry; + /* 0x04 */ f32 boundsNearZ; + /* 0x08 */ struct RoomShapeCullableEntryLinked* prev; + /* 0x0C */ struct RoomShapeCullableEntryLinked* next; +} RoomShapeCullableEntryLinked; // size = 0x10 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E254.s") +// TODO: 127 is an arbitrarily chosen number to make the stack sorta work +#define ROOM_SHAPE_CULLABLE_MAX_ENTRIES 127 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E32C.s") +#ifdef NON_MATCHING +// Small regalloc, likely related to temp usage and scoping +void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { + RoomShapeCullable* roomShape; + RoomShapeCullableEntry* roomShapeCullableEntry; + RoomShapeCullableEntry* roomShapeCullableEntries; + RoomShapeCullableEntry* roomShapeCullableEntryIter; + Gfx* displayList; + f32 entryBoundsNearZ; + RoomShapeCullableEntryLinked linkedEntriesBuffer[ROOM_SHAPE_CULLABLE_MAX_ENTRIES]; + RoomShapeCullableEntryLinked* head = NULL; + RoomShapeCullableEntryLinked* tail = NULL; + s32 var_a1; + RoomShapeCullableEntryLinked* iter; + RoomShapeCullableEntryLinked* insert; + f32 var_fv1; + s32 i; + Vec3f pos; + Vec3f projectedPos; + s32 pad2; -void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) { - RoomMeshType1* mesh = &room->mesh->type1; - if (mesh->format == 1) { - func_8012DEE8(play, room, flags); - } else if (mesh->format == 2) { - func_8012E32C(play, room, flags); + OPEN_DISPS(play->state.gfxCtx); + + if (flags & ROOM_DRAW_OPA) { + func_800BCBF4(&sZeroVec, play); + + //! TODO: Fake + if (1) {} + if (1) {} + if (1) {} + + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + if (play->roomCtx.unk74 != NULL) { + gSPSegment(POLY_OPA_DISP++, 0x06, play->roomCtx.unk74); + } + func_8012C268(play); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + } + + if (flags & ROOM_DRAW_XLU) { + func_800BCC68(&sZeroVec, play); + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); + if (play->roomCtx.unk74 != NULL) { + gSPSegment(POLY_XLU_DISP++, 0x06, play->roomCtx.unk74); + } + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + } + + if ((room->enablePosLights != 0) || (MREG(93) != 0)) { + gSPSetGeometryMode(POLY_OPA_DISP++, G_LIGHTING_POSITIONAL); + gSPSetGeometryMode(POLY_XLU_DISP++, G_LIGHTING_POSITIONAL); + } + + roomShape = &room->roomShape->cullable; + roomShapeCullableEntry = Lib_SegmentedToVirtual(roomShape->entries); + insert = linkedEntriesBuffer; + + roomShapeCullableEntries = roomShapeCullableEntry; + + if (play->roomCtx.unk78 < 0) { + for (i = 0; i < roomShape->numEntries; i++, roomShapeCullableEntry++) { + if (R_ROOM_CULL_DEBUG_MODE != 0) { + if (((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_UP_TO_TARGET) && + (i <= R_ROOM_CULL_DEBUG_TARGET)) || + ((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_ONLY_TARGET) && (i == R_ROOM_CULL_DEBUG_TARGET))) { + if (flags & ROOM_DRAW_OPA) { + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + + if (flags & ROOM_DRAW_XLU) { + displayList = roomShapeCullableEntry->xlu; + if (displayList != NULL) { + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } + } + } else { + if (flags & ROOM_DRAW_OPA) { + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + + if (flags & ROOM_DRAW_XLU) { + displayList = roomShapeCullableEntry->xlu; + if (displayList != NULL) { + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } + } + } + } else { + f32 var_fa1 = 1.0f / play->projectionMtxFDiagonal.z; // sp54 + s32 pad5; + + // Pick and sort entries by depth + for (i = 0; i < roomShape->numEntries; i++, roomShapeCullableEntry++) { + + // Project the entry position, to get the depth it is at. + pos.x = roomShapeCullableEntry->boundsSphereCenter.x; + pos.y = roomShapeCullableEntry->boundsSphereCenter.y; + pos.z = roomShapeCullableEntry->boundsSphereCenter.z; + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &pos, &projectedPos); + + projectedPos.z *= var_fa1; + + var_fv1 = ABS_ALT(roomShapeCullableEntry->boundsSphereRadius); + + // If the entry bounding sphere isn't fully before the rendered depth range + if (-var_fv1 < projectedPos.z) { + + // Compute the depth of the nearest point in the entry's bounding sphere + entryBoundsNearZ = projectedPos.z - var_fv1; + + // If the entry bounding sphere isn't fully beyond the rendered depth range + if (entryBoundsNearZ < play->lightCtx.zFar) { + + // This entry will be rendered + insert->entry = roomShapeCullableEntry; + + if (roomShapeCullableEntry->boundsSphereRadius < 0) { + insert->boundsNearZ = FLT_MAX; + } else { + insert->boundsNearZ = entryBoundsNearZ; + } + + // Insert into the linked list, ordered by ascending depth of the nearest point in the bounding + // sphere + iter = head; + if (iter == NULL) { + head = tail = insert; + insert->prev = insert->next = NULL; + } else { + do { + if (insert->boundsNearZ < iter->boundsNearZ) { + break; + } + iter = iter->next; + } while (iter != NULL); + + if (iter == NULL) { + insert->prev = tail; + insert->next = NULL; + tail->next = insert; + tail = insert; + } else { + insert->prev = iter->prev; + if (insert->prev == NULL) { + head = insert; + } else { + insert->prev->next = insert; + } + iter->prev = insert; + insert->next = iter; + } + } + + insert++; + } + } + } + + //! FAKE: Similar trick used in OoT + R_ROOM_CULL_NUM_ENTRIES = roomShape->numEntries & 0xFFFF & 0xFFFF & 0xFFFF; + + // Draw entries, from nearest to furthest + i = 1; + + if (flags & ROOM_DRAW_OPA) { + for (; head != NULL; head = head->next, i++) { + s32 pad3; + RoomShapeCullableEntry* roomShapeCullableEntry; + + roomShapeCullableEntry = head->entry; + + if (R_ROOM_CULL_DEBUG_MODE != ROOM_CULL_DEBUG_MODE_OFF) { + // Debug mode drawing + + if (((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_UP_TO_TARGET) && + (i <= R_ROOM_CULL_DEBUG_TARGET)) || + ((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_ONLY_TARGET) && + (i == R_ROOM_CULL_DEBUG_TARGET))) { + + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + } else { + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + } + } + + if (flags & ROOM_DRAW_XLU) { + for (; head != NULL; head = head->prev) { + f32 temp_fv0; + f32 temp_fv1; + + roomShapeCullableEntry = head->entry; + displayList = roomShapeCullableEntry->xlu; + + if (displayList != NULL) { + if (roomShapeCullableEntry->boundsSphereRadius & 1) { + + temp_fv0 = head->boundsNearZ - (f32)(iREG(93) + 0xBB8); + temp_fv1 = iREG(94) + 0x7D0; + + if (temp_fv0 < temp_fv1) { + if (temp_fv0 < 0.0f) { + var_a1 = 255; + } else { + var_a1 = 255 - (s32)((temp_fv0 / temp_fv1) * 255.0f); + } + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, var_a1); + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } else { + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } + } + } + + R_ROOM_CULL_USED_ENTRIES = i - 1; + } + + CLOSE_DISPS(play->state.gfxCtx); +} +#else +void Room_DrawCullable(PlayState* play, Room* room, u32 flags); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_DrawCullable.s") +#endif + +#define ROOM_IMAGE_NODRAW_BACKGROUND (1 << 0) +#define ROOM_IMAGE_NODRAW_OPA (1 << 1) +#define ROOM_IMAGE_NODRAW_XLU (1 << 2) + +void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { + Camera* activeCam; + Gfx* gfx; + RoomShapeImageSingle* roomShape; + RoomShapeDListsEntry* entry; + u32 isFixedCamera; + u32 drawBackground; + u32 drawOpa; + u32 drawXlu; + + OPEN_DISPS(play->state.gfxCtx); + + activeCam = GET_ACTIVE_CAM(play); + isFixedCamera = false; // Condition is inferred from OoT + roomShape = &room->roomShape->image.single; + entry = Lib_SegmentedToVirtual(roomShape->base.entry); + drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (roomShape->source != NULL) && + !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND); + drawOpa = (flags & ROOM_DRAW_OPA) && (entry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA); + drawXlu = (flags & ROOM_DRAW_XLU) && (entry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU); + + if (drawOpa || drawBackground) { + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + + if (drawOpa) { + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, entry->opa); + } + + if (drawBackground) { + gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2_fifo); + + gfx = POLY_OPA_DISP; + + { + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, activeCam); + + Prerender_DrawBackground2D( + &gfx, roomShape->source, roomShape->tlut, roomShape->width, roomShape->height, roomShape->fmt, + roomShape->siz, roomShape->tlutMode, roomShape->tlutCount, + (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, + quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f, 1.0f, 1.0f, 0); + } + + POLY_OPA_DISP = gfx; + + gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + } + } + + if (drawXlu) { + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, entry->xlu); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +RoomShapeImageMultiBgEntry* Room_GetImageMultiBgEntry(RoomShapeImageMulti* roomShapeImageMulti, PlayState* play) { + Camera* activeCam = GET_ACTIVE_CAM(play); + s32 bgCamIndex = activeCam->bgCamDataId; + s16 overrideBgCamIndex; + Player* player; + RoomShapeImageMultiBgEntry* bgEntry; + s32 i; + + overrideBgCamIndex = ((BgCamFuncData*)BgCheck_GetBgCamFuncDataImpl(&play->colCtx, bgCamIndex, BGCHECK_SCENE)) + ->roomImageOverrideBgCamIndex; + if (overrideBgCamIndex >= 0) { + bgCamIndex = overrideBgCamIndex; + } + + player = GET_PLAYER(play); + player->actor.params = (player->actor.params & 0xFF00) | bgCamIndex; + + bgEntry = Lib_SegmentedToVirtual(roomShapeImageMulti->backgrounds); + for (i = 0; i < roomShapeImageMulti->numBackgrounds; i++) { + if (bgEntry->bgCamIndex == bgCamIndex) { + return bgEntry; + } + bgEntry++; + } + + __assert("../z_room.c", 849); + + return NULL; +} + +void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) { + Camera* activeCam; + Gfx* gfx; + RoomShapeImageMulti* roomShape; + RoomShapeImageMultiBgEntry* bgEntry; + RoomShapeDListsEntry* dListsEntry; + u32 isFixedCamera; + u32 drawBackground; + u32 drawOpa; + u32 drawXlu; + + OPEN_DISPS(play->state.gfxCtx); + + activeCam = GET_ACTIVE_CAM(play); + isFixedCamera = false; // Condition is inferred from OoT + roomShape = &room->roomShape->image.multi; + dListsEntry = Lib_SegmentedToVirtual(roomShape->base.entry); + + bgEntry = Room_GetImageMultiBgEntry(roomShape, play); + + drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (bgEntry->source != NULL) && + !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND); + drawOpa = + (flags & ROOM_DRAW_OPA) && (dListsEntry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA); + drawXlu = + (flags & ROOM_DRAW_XLU) && (dListsEntry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU); + + if (drawOpa || drawBackground) { + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + + if (drawOpa) { + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, dListsEntry->opa); + } + + if (drawBackground) { + gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2_fifo); + + gfx = POLY_OPA_DISP; + + { + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, activeCam); + Prerender_DrawBackground2D(&gfx, bgEntry->source, bgEntry->tlut, bgEntry->width, bgEntry->height, + bgEntry->fmt, bgEntry->siz, bgEntry->tlutMode, bgEntry->tlutCount, + (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, + quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f, 1.0f, 1.0f, + 0); + } + + POLY_OPA_DISP = gfx; + + gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + } + } + + if (drawXlu) { + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, dListsEntry->xlu); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Room_DrawImage(PlayState* play, Room* room, u32 flags) { + RoomShapeImageBase* roomShape = &room->roomShape->image.base; + + if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_SINGLE) { + Room_DrawImageSingle(play, room, flags); + } else if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_MULTI) { + Room_DrawImageMulti(play, room, flags); } else { __assert("../z_room.c", 965); } @@ -64,31 +483,96 @@ void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) { void Room_Init(PlayState* play, RoomContext* roomCtx) { s32 i; + roomCtx->curRoom.num = -1; roomCtx->curRoom.segment = NULL; roomCtx->unk78 = 1; roomCtx->unk79 = 0; - for (i = 0; i < 3; i++) { + for (i = 0; i < ARRAY_COUNT(roomCtx->unk7A); i++) { roomCtx->unk7A[i] = 0; } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s") +size_t Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx) { + size_t maxRoomSize = 0; + size_t roomSize; + s32 i; + s32 j; + s32 frontRoom; + s32 backRoom; + size_t frontRoomSize; + size_t backRoomSize; + size_t cumulRoomSize; + s32 pad[2]; + + { + RomFile* roomList = play->roomList; + + for (i = 0; i < play->numRooms; i++) { + roomSize = roomList[i].vromEnd - roomList[i].vromStart; + maxRoomSize = MAX(roomSize, maxRoomSize); + } + } + + if ((u32)play->doorCtx.numTransitionActors != 0) { + RomFile* roomList = play->roomList; + TransitionActorEntry* transitionActor = &play->doorCtx.transitionActorList[0]; + + for (j = 0; j < play->doorCtx.numTransitionActors; j++) { + frontRoom = transitionActor->sides[0].room; + backRoom = transitionActor->sides[1].room; + frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart; + backRoomSize = (backRoom < 0) ? 0 : roomList[backRoom].vromEnd - roomList[backRoom].vromStart; + cumulRoomSize = (frontRoom != backRoom) ? frontRoomSize + backRoomSize : frontRoomSize; + + maxRoomSize = MAX(cumulRoomSize, maxRoomSize); + transitionActor++; + } + } + + roomCtx->roomMemPages[0] = THA_AllocEndAlign16(&play->state.heap, maxRoomSize); + if (roomCtx->roomMemPages[0] == NULL) { + __assert("../z_room.c", 1078); + } + roomCtx->roomMemPages[1] = (void*)((uintptr_t)roomCtx->roomMemPages[0] + maxRoomSize); + roomCtx->activeMemPage = 0; + roomCtx->status = 0; + + if ((gSaveContext.respawnFlag != 0) && (gSaveContext.respawnFlag != -2) && (gSaveContext.respawnFlag != -7)) { + s32 respawnMode; + + if ((gSaveContext.respawnFlag == -8) || (gSaveContext.respawnFlag == -5) || (gSaveContext.respawnFlag == -4) || + ((gSaveContext.respawnFlag < 0) && (gSaveContext.respawnFlag != -1) && (gSaveContext.respawnFlag != -6))) { + respawnMode = RESPAWN_MODE_DOWN; + } else if (gSaveContext.respawnFlag < 0) { + respawnMode = RESPAWN_MODE_TOP; + } else { + respawnMode = gSaveContext.respawnFlag - 1; + } + frontRoom = gSaveContext.respawn[respawnMode].roomIndex; + } else { + frontRoom = play->setupEntranceList[play->curSpawn].room; + } + + Room_StartRoomTransition(play, roomCtx, frontRoom); + + return maxRoomSize; +} s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { - if (roomCtx->unk31 == 0) { - s32 size; + if (roomCtx->status == 0) { + size_t size; roomCtx->prevRoom = roomCtx->curRoom; roomCtx->curRoom.num = index; roomCtx->curRoom.segment = NULL; - roomCtx->unk31 = 1; + roomCtx->status = 1; size = play->roomList[index].vromEnd - play->roomList[index].vromStart; - roomCtx->activeRoomVram = (void*)(ALIGN16((u32)roomCtx->roomMemPages[roomCtx->activeMemPage] - + roomCtx->activeRoomVram = (void*)(ALIGN16((uintptr_t)roomCtx->roomMemPages[roomCtx->activeMemPage] - (size + 8) * roomCtx->activeMemPage - 7)); - osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, 1); + osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, ARRAY_COUNT(roomCtx->loadMsg)); DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, play->roomList[index].vromStart, size, 0, &roomCtx->loadQueue, NULL); roomCtx->activeMemPage ^= 1; @@ -100,14 +584,13 @@ s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { } s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { - if (roomCtx->unk31 == 1) { - if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { - roomCtx->unk31 = 0; + if (roomCtx->status == 1) { + if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { + roomCtx->status = 0; roomCtx->curRoom.segment = roomCtx->activeRoomVram; - // TODO: Segment number enum - gSegments[0x03] = VIRTUAL_TO_PHYSICAL(roomCtx->activeRoomVram); + gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->activeRoomVram); - Scene_ProcessHeader(play, (SceneCmd*)roomCtx->curRoom.segment); + Scene_ExecuteCommands(play, roomCtx->curRoom.segment); func_80123140(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); @@ -127,11 +610,17 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { return 1; } +RoomDrawHandler sRoomDrawHandlers[] = { + Room_DrawNormal, // ROOM_SHAPE_TYPE_NORMAL + Room_DrawImage, // ROOM_SHAPE_TYPE_IMAGE + Room_DrawCullable, // ROOM_SHAPE_TYPE_CULLABLE + Room_DrawNone, // ROOM_SHAPE_TYPE_NONE +}; + void Room_Draw(PlayState* play, Room* room, u32 flags) { if (room->segment != NULL) { - // TODO: Segment number enum - gSegments[0x03] = VIRTUAL_TO_PHYSICAL(room->segment); - roomDrawFuncs[room->mesh->type0.type](play, room, flags); + gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment); + sRoomDrawHandlers[room->roomShape->base.type](play, room, flags); } return; } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 1f431d0e4e..13d93c515d 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -141,7 +141,7 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { } // SceneTableEntry Header Command 0x00: Spawn List -void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) { s32 loadedCount; s16 playerObjectId; void* nextObject; @@ -168,19 +168,19 @@ void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x01: Actor List -void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandActorList(PlayState* play, SceneCmd* cmd) { play->numSetupActors = cmd->actorList.num; play->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); play->actorCtx.halfDaysBit = 0; } // SceneTableEntry Header Command 0x02: List of camera data for actor cutscenes -void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandActorCutsceneCamList(PlayState* play, SceneCmd* cmd) { play->actorCsCamList = Lib_SegmentedToVirtual(cmd->actorCsCamList.segment); } // SceneTableEntry Header Command 0x03: Collision Header -void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) { +void Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd) { CollisionHeader* colHeaderTemp; CollisionHeader* colHeader; @@ -205,18 +205,18 @@ void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x04: Room List -void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandRoomList(PlayState* play, SceneCmd* cmd) { play->numRooms = cmd->roomList.num; play->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); } // SceneTableEntry Header Command 0x06: Entrance List -void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandEntranceList(PlayState* play, SceneCmd* cmd) { play->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); } // SceneTableEntry Header Command 0x07: Special Files -void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) { // @note These quest hint files are identical to OoT's. // They are not relevant in this game and the system to process these scripts has been removed. static RomFile naviQuestHintFiles[2] = { @@ -236,9 +236,9 @@ void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x08: Room Behavior -void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) { - play->roomCtx.curRoom.unk3 = cmd->roomBehavior.gpFlag1; - play->roomCtx.curRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; +void Scene_CommandRoomBehavior(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.behaviorType1 = cmd->roomBehavior.gpFlag1; + play->roomCtx.curRoom.behaviorType2 = cmd->roomBehavior.gpFlag2 & 0xFF; play->roomCtx.curRoom.lensMode = (cmd->roomBehavior.gpFlag2 >> 8) & 1; play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; play->roomCtx.curRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xB) & 1; @@ -246,12 +246,12 @@ void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x0A: Mesh Header -void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd) { - play->roomCtx.curRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); +void Scene_CommandMesh(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.roomShape = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List -void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { s32 i; s32 j; s32 k; @@ -304,7 +304,7 @@ void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x0C: Light List -void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandLightList(PlayState* play, SceneCmd* cmd) { s32 i; LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment); @@ -315,12 +315,12 @@ void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x0D: Path List -void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandPathList(PlayState* play, SceneCmd* cmd) { play->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment); } // SceneTableEntry Header Command 0x0E: Transition Actor List -void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandTransiActorList(PlayState* play, SceneCmd* cmd) { play->doorCtx.numTransitionActors = cmd->transiActorList.num; play->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment); func_80105818(play, play->doorCtx.numTransitionActors, play->doorCtx.transitionActorList); @@ -332,7 +332,7 @@ void Door_InitContext(GameState* state, DoorContext* doorCtx) { } // SceneTableEntry Header Command 0x0F: Environment Light Settings List -void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandEnvLightSettings(PlayState* play, SceneCmd* cmd) { play->envCtx.numLightSettings = cmd->lightSettingList.num; play->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment); } @@ -363,7 +363,7 @@ void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) { } // SceneTableEntry Header Command 0x11: Skybox Settings -void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSkyboxSettings(PlayState* play, SceneCmd* cmd) { play->skyboxId = cmd->skyboxSettings.skyboxId & 3; play->envCtx.unk_17 = play->envCtx.unk_18 = cmd->skyboxSettings.unk5; play->envCtx.unk_1E = cmd->skyboxSettings.unk6; @@ -371,13 +371,13 @@ void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x12: Skybox Disables -void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSkyboxDisables(PlayState* play, SceneCmd* cmd) { play->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; play->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; } // SceneTableEntry Header Command 0x10: Time Settings -void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd) { if ((cmd->timeSettings.hour != 0xFF) && (cmd->timeSettings.min != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.save.time = CLOCK_TIME_ALT2_F(cmd->timeSettings.hour, cmd->timeSettings.min); @@ -418,7 +418,7 @@ void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x05: Wind Settings -void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandWindSettings(PlayState* play, SceneCmd* cmd) { s8 temp1 = cmd->windSettings.west; s8 temp2 = cmd->windSettings.vertical; s8 temp3 = cmd->windSettings.south; @@ -430,16 +430,16 @@ void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x13: Exit List -void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandExitList(PlayState* play, SceneCmd* cmd) { play->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); } // SceneTableEntry Header Command 0x09: Undefined -void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) { +void Scene_Command09(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x15: Sound Settings= -void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd) { play->sequenceCtx.seqId = cmd->soundSettings.seqId; play->sequenceCtx.ambienceId = cmd->soundSettings.ambienceId; @@ -450,12 +450,12 @@ void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x16: Echo Setting -void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd) { +void Scene_CommandEchoSetting(PlayState* play, SceneCmd* cmd) { play->roomCtx.curRoom.echo = cmd->echoSettings.echo; } // SceneTableEntry Header Command 0x18: Alternate Header List= -void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandAltHeaderList(PlayState* play, SceneCmd* cmd) { SceneCmd** altHeaderList; SceneCmd* altHeader; @@ -464,40 +464,40 @@ void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { altHeader = altHeaderList[gSaveContext.sceneLayer - 1]; if (altHeader != NULL) { - Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader)); + Scene_ExecuteCommands(play, Lib_SegmentedToVirtual(altHeader)); (cmd + 1)->base.code = 0x14; } } } // SceneTableEntry Header Command 0x17: Cutscene List -void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandCutsceneList(PlayState* play, SceneCmd* cmd) { play->csCtx.sceneCsCount = cmd->cutsceneList.sceneCsCount; play->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->cutsceneList.segment); } // SceneTableEntry Header Command 0x1B: Actor Cutscene List -void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandActorCutsceneList(PlayState* play, SceneCmd* cmd) { ActorCutscene_Init(play, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); } // SceneTableEntry Header Command 0x1C: Mini Maps -void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd) { +void Scene_CommandMiniMap(PlayState* play, SceneCmd* cmd) { func_80104CF4(play); func_8010549C(play, cmd->minimapSettings.segment); } // SceneTableEntry Header Command 0x1D: Undefined -void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd) { +void Scene_Command1D(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x1E: Minimap Compass Icon Info -void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) { +void Scene_CommandMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) { func_8010565C(play, cmd->minimapChests.num, cmd->minimapChests.segment); } // SceneTableEntry Header Command 0x19: Sets Region Visited Flag -void Scene_HeaderCmdSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { s16 j = 0; s16 i = 0; @@ -525,7 +525,7 @@ void Scene_HeaderCmdSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x1A: Material Animations -void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) { +void Scene_CommandAnimatedMaterials(PlayState* play, SceneCmd* cmd) { play->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment); } @@ -536,57 +536,58 @@ void Scene_SetExitFade(PlayState* play) { play->transitionType = Entrance_GetTransitionFlags(play->nextEntrance) & 0x7F; } +void (*sSceneCmdHandlers[])(PlayState*, SceneCmd*) = { + Scene_CommandSpawnList, + Scene_CommandActorList, + Scene_CommandActorCutsceneCamList, + Scene_CommandCollisionHeader, + Scene_CommandRoomList, + Scene_CommandWindSettings, + Scene_CommandEntranceList, + Scene_CommandSpecialFiles, + Scene_CommandRoomBehavior, + Scene_Command09, + Scene_CommandMesh, + Scene_CommandObjectList, + Scene_CommandLightList, + Scene_CommandPathList, + Scene_CommandTransiActorList, + Scene_CommandEnvLightSettings, + Scene_CommandTimeSettings, + Scene_CommandSkyboxSettings, + Scene_CommandSkyboxDisables, + Scene_CommandExitList, + NULL, + Scene_CommandSoundSettings, + Scene_CommandEchoSetting, + Scene_CommandCutsceneList, + Scene_CommandAltHeaderList, + Scene_CommandSetRegionVisitedFlag, + Scene_CommandAnimatedMaterials, + Scene_CommandActorCutsceneList, + Scene_CommandMiniMap, + Scene_Command1D, + Scene_CommandMiniMapCompassInfo, +}; + /** * Executes all of the commands in a scene or room header. */ -s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header) { - static void (*sceneCmdHandlers[])(PlayState*, SceneCmd*) = { - Scene_HeaderCmdSpawnList, - Scene_HeaderCmdActorList, - Scene_HeaderCmdActorCutsceneCamList, - Scene_HeaderCmdColHeader, - Scene_HeaderCmdRoomList, - Scene_HeaderCmdWindSettings, - Scene_HeaderCmdEntranceList, - Scene_HeaderCmdSpecialFiles, - Scene_HeaderCmdRoomBehavior, - Scene_HeaderCmd09, - Scene_HeaderCmdMesh, - Scene_HeaderCmdObjectList, - Scene_HeaderCmdLightList, - Scene_HeaderCmdPathList, - Scene_HeaderCmdTransiActorList, - Scene_HeaderCmdEnvLightSettings, - Scene_HeaderCmdTimeSettings, - Scene_HeaderCmdSkyboxSettings, - Scene_HeaderCmdSkyboxDisables, - Scene_HeaderCmdExitList, - NULL, - Scene_HeaderCmdSoundSettings, - Scene_HeaderCmdEchoSetting, - Scene_HeaderCmdCutsceneList, - Scene_HeaderCmdAltHeaderList, - Scene_HeaderCmdSetRegionVisitedFlag, - Scene_HeaderCmdAnimatedMaterials, - Scene_HeaderCmdActorCutsceneList, - Scene_HeaderCmdMiniMap, - Scene_HeaderCmd1D, - Scene_HeaderCmdMiniMapCompassInfo, - }; +s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd) { u32 cmdId; while (true) { - cmdId = header->base.code; + cmdId = sceneCmd->base.code; if (cmdId == SCENE_CMD_ID_END) { break; } if (cmdId < SCENE_CMD_MAX) { - sceneCmdHandlers[cmdId](play, header); + sSceneCmdHandlers[cmdId](play, sceneCmd); } - header++; + sceneCmd++; } return 0; diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 7a365e5472..8a9d26a4d5 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -498,7 +498,7 @@ void func_808A1618(DoorShutter* this, PlayState* play) { void func_808A1684(DoorShutter* this, PlayState* play) { f32 phi_f0; - if ((DECR(this->unk_166) == 0) && (play->roomCtx.unk31 == 0) && func_808A1340(this, play)) { + if ((DECR(this->unk_166) == 0) && (play->roomCtx.status == 0) && func_808A1340(this, play)) { if (this->doorType == 5) { phi_f0 = 20.0f; } else { diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 763e353113..4c0dd92d9d 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -328,7 +328,7 @@ s32 func_8094E054(EnGm* this, PlayState* play, s32 arg2) { s32 func_8094E0F8(EnGm* this, PlayState* play) { s32 ret = false; - if ((this->unk_260 != play->roomCtx.curRoom.num) && (play->roomCtx.unk31 == 0)) { + if ((this->unk_260 != play->roomCtx.curRoom.num) && (play->roomCtx.status == 0)) { this->unk_260 = play->roomCtx.curRoom.num; this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, play); this->actor.draw = NULL; diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index a0e359205c..e2d4792ca9 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -182,7 +182,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { u32 enHollId = EN_HOLL_GET_ID(&this->actor); if (sLoadingPlaneDistance < playerDistFromCentralPlane) { - if ((play->roomCtx.prevRoom.num >= 0) && (play->roomCtx.unk31 == 0)) { + if ((play->roomCtx.prevRoom.num >= 0) && (play->roomCtx.status == 0)) { this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[this->playerSide].room; if (play->roomCtx.prevRoom.num == this->actor.room) { EnHoll_ChangeRooms(play); @@ -298,7 +298,7 @@ void EnHoll_VerticalIdle(EnHoll* this, PlayState* play) { } void EnHoll_RoomTransitionIdle(EnHoll* this, PlayState* play) { - if (play->roomCtx.unk31 == 0) { + if (play->roomCtx.status == 0) { func_8012EBF8(play, &play->roomCtx); if (play->bgCoverAlpha == 0) { this->bgCoverAlphaActive = false; diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 7b3b28ea34..1f411bd39f 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -684,7 +684,8 @@ void EnKusa_Update(Actor* thisx, PlayState* play2) { } else { this->actor.shape.yOffset = 0.0f; } - if ((kusaGameplayFrames != play->gameplayFrames) && (play->roomCtx.curRoom.unk3 == 0)) { + if ((kusaGameplayFrames != play->gameplayFrames) && + (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0)) { EnKusa_Sway(); kusaGameplayFrames = play->gameplayFrames; } @@ -696,8 +697,9 @@ void EnKusa_DrawBush(Actor* thisx, PlayState* play2) { if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && - (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && + (this->actionFunc == EnKusa_WaitForInteract) && (this->actor.projectedPos.z > -150.0f) && + (this->actor.projectedPos.z < 400.0f)) { EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); } @@ -725,7 +727,8 @@ void EnKusa_DrawGrass(Actor* thisx, PlayState* play) { if (this->isCut) { Gfx_DrawDListOpa(play, gKusaStump); } else { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && + (this->actionFunc == EnKusa_WaitForInteract)) { if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); } diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 6d65b49100..49fa4a98ac 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -1293,7 +1293,7 @@ void func_80A5E604(Actor* thisx, PlayState* play) { } else { this->actor.draw = func_80A5E6F0; - if (play->roomCtx.curRoom.unk3 == 0) { + if (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) { func_80A5B508(); } func_80A5CAF4(&D_80A5F1C0); @@ -1356,7 +1356,7 @@ void EnKusa2_Draw(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if (this->actor.projectedPos.z <= 1200.0f) { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 5a6c4573f7..0e09b2e684 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -367,7 +367,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (play->numSetupActors <= 0) && - (play->roomCtx.unk31 == 0) && !Play_IsDebugCamEnabled()) { + (play->roomCtx.status == 0) && !Play_IsDebugCamEnabled()) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; s16 temp_a3; diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index bf0dc785b9..56b6c6f810 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -762,7 +762,7 @@ void func_80AF2938(EnTest7* this, PlayState* play) { player->stateFlags2 |= PLAYER_STATE2_20000000; this->unk_144 |= 2; this->unk_148.unk_04 = 30.0f; - if (play->roomCtx.curRoom.unk3 != 1) { + if (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_1) { func_80AF082C(this, func_80AF2AE8); } else { func_80AF082C(this, func_80AF2EC8); diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index ed67e92c2f..a5c66629aa 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -655,7 +655,7 @@ void ObjFlowerpot_Update(Actor* thisx, PlayState* play2) { func_80A1C554(this); - if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.curRoom.unk3 == 0)) { + if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0)) { func_80A1B3D0(); D_80A1D830 = play->gameplayFrames; } @@ -680,7 +680,7 @@ void ObjFlowerpot_Draw(Actor* thisx, PlayState* play) { } if (!(this->unk_1EA & 2)) { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && (this->actionFunc == func_80A1C838)) { if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A1B840(&D_80A1D838[this->unk_1EB]); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ae62d6f364..437840bc68 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2391,14 +2391,14 @@ 0x8012CF0C:("func_8012CF0C",), 0x8012D374:("func_8012D374",), 0x8012D40C:("func_8012D40C",), - 0x8012D510:("Room_nop8012D510",), - 0x8012D528:("Room_DrawType3Mesh",), - 0x8012D53C:("Room_DrawType0Mesh",), - 0x8012D750:("Room_DrawType2Mesh",), - 0x8012DEE8:("func_8012DEE8",), - 0x8012E254:("func_8012E254",), - 0x8012E32C:("func_8012E32C",), - 0x8012E6A8:("Room_DrawType1Mesh",), + 0x8012D510:("Room_Noop",), + 0x8012D528:("Room_DrawNone",), + 0x8012D53C:("Room_DrawNormal",), + 0x8012D750:("Room_DrawCullable",), + 0x8012DEE8:("Room_DrawImageSingle",), + 0x8012E254:("Room_GetImageMultiBgEntry",), + 0x8012E32C:("Room_DrawImageMulti",), + 0x8012E6A8:("Room_DrawImage",), 0x8012E710:("Room_Init",), 0x8012E750:("Room_AllocateAndLoad",), 0x8012E96C:("Room_StartRoomTransition",), @@ -2422,40 +2422,40 @@ 0x8012F668:("Object_IsLoaded",), 0x8012F698:("Object_LoadAll",), 0x8012F73C:("func_8012F73C",), - 0x8012F79C:("Scene_HeaderCmdSpawnList",), - 0x8012F90C:("Scene_HeaderCmdActorList",), - 0x8012F954:("Scene_HeaderCmdActorCutsceneCamList",), - 0x8012F984:("Scene_HeaderCmdColHeader",), - 0x8012FA24:("Scene_HeaderCmdRoomList",), - 0x8012FA68:("Scene_HeaderCmdEntranceList",), - 0x8012FA98:("Scene_HeaderCmdSpecialFiles",), - 0x8012FB60:("Scene_HeaderCmdRoomBehavior",), - 0x8012FBE8:("Scene_HeaderCmdMesh",), - 0x8012FC18:("Scene_HeaderCmdObjectList",), - 0x8012FDA4:("Scene_HeaderCmdLightList",), - 0x8012FE2C:("Scene_HeaderCmdPathList",), - 0x8012FE5C:("Scene_HeaderCmdTransiActorList",), + 0x8012F79C:("Scene_CommandSpawnList",), + 0x8012F90C:("Scene_CommandActorList",), + 0x8012F954:("Scene_CommandActorCutsceneCamList",), + 0x8012F984:("Scene_CommandCollisionHeader",), + 0x8012FA24:("Scene_CommandRoomList",), + 0x8012FA68:("Scene_CommandEntranceList",), + 0x8012FA98:("Scene_CommandSpecialFiles",), + 0x8012FB60:("Scene_CommandRoomBehavior",), + 0x8012FBE8:("Scene_CommandMesh",), + 0x8012FC18:("Scene_CommandObjectList",), + 0x8012FDA4:("Scene_CommandLightList",), + 0x8012FE2C:("Scene_CommandPathList",), + 0x8012FE5C:("Scene_CommandTransiActorList",), 0x8012FEBC:("Door_InitContext",), - 0x8012FECC:("Scene_HeaderCmdEnvLightSettings",), + 0x8012FECC:("Scene_CommandEnvLightSettings",), 0x8012FF10:("Scene_LoadAreaTextures",), - 0x8012FF8C:("Scene_HeaderCmdSkyboxSettings",), - 0x8012FFF0:("Scene_HeaderCmdSkyboxDisables",), - 0x80130018:("Scene_HeaderCmdTimeSettings",), - 0x8013033C:("Scene_HeaderCmdWindSettings",), - 0x801303A0:("Scene_HeaderCmdExitList",), - 0x801303D0:("Scene_HeaderCmd09",), - 0x801303E0:("Scene_HeaderCmdSoundSettings",), - 0x8013043C:("Scene_HeaderCmdEchoSetting",), - 0x80130454:("Scene_HeaderCmdAltHeaderList",), - 0x801304CC:("Scene_HeaderCmdCutsceneList",), - 0x80130500:("Scene_HeaderCmdActorCutsceneList",), - 0x80130540:("Scene_HeaderCmdMiniMap",), - 0x80130578:("Scene_HeaderCmd1D",), - 0x80130588:("Scene_HeaderCmdMiniMapCompassInfo",), - 0x801305B0:("Scene_HeaderCmdSetRegionVisitedFlag",), - 0x80130674:("Scene_HeaderCmdAnimatedMaterials",), + 0x8012FF8C:("Scene_CommandSkyboxSettings",), + 0x8012FFF0:("Scene_CommandSkyboxDisables",), + 0x80130018:("Scene_CommandTimeSettings",), + 0x8013033C:("Scene_CommandWindSettings",), + 0x801303A0:("Scene_CommandExitList",), + 0x801303D0:("Scene_Command09",), + 0x801303E0:("Scene_CommandSoundSettings",), + 0x8013043C:("Scene_CommandEchoSetting",), + 0x80130454:("Scene_CommandAltHeaderList",), + 0x801304CC:("Scene_CommandCutsceneList",), + 0x80130500:("Scene_CommandActorCutsceneList",), + 0x80130540:("Scene_CommandMiniMap",), + 0x80130578:("Scene_Command1D",), + 0x80130588:("Scene_CommandMiniMapCompassInfo",), + 0x801305B0:("Scene_CommandSetRegionVisitedFlag",), + 0x80130674:("Scene_CommandAnimatedMaterials",), 0x801306A4:("Scene_SetExitFade",), - 0x801306E8:("Scene_ProcessHeader",), + 0x801306E8:("Scene_ExecuteCommands",), 0x80130768:("Entrance_Create",), 0x80130784:("Entrance_CreateFromSpawn",), 0x801307C0:("Scene_Draw",), @@ -3032,7 +3032,7 @@ 0x80169EFC:("func_80169EFC",), 0x80169F78:("func_80169F78",), 0x80169FDC:("func_80169FDC",), - 0x80169FFC:("func_80169FFC",), + 0x80169FFC:("Play_CamIsNotFixed",), 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), 0x8016A0AC:("Play_IsUnderwater",), @@ -3079,7 +3079,7 @@ 0x80172078:("PreRender_ApplyFiltersSlowlyDestroy",), 0x801720C4:("func_801720C4",), 0x801720FC:("func_801720FC",), - 0x80172758:("func_80172758",), + 0x80172758:("Prerender_DrawBackground2D",), 0x801727F0:("THGA_Ct",), 0x80172810:("THGA_Dt",), 0x80172830:("THGA_IsCrash",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index de6991bd59..bf6d8e8bb9 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1339,8 +1339,8 @@ 0x801C0EF0:("sSetupDL","Gfx","[438]",0xdb0), 0x801C1CA0:("sFillSetupDL","Gfx","[12]",0x60), 0x801C1D00:("gEmptyDL","Gfx","[1]",0x8), - 0x801C1D10:("D_801C1D10","Vec3f","",0xc), - 0x801C1D1C:("roomDrawFuncs","room_draw_func","[4]",0x10), + 0x801C1D10:("sZeroVec","Vec3f","",0xc), + 0x801C1D1C:("sRoomDrawHandlers","RoomDrawHandler","[4]",0x10), 0x801C1D30:("gBitFlags","u32","[32]",0x80), 0x801C1DB0:("gEquipMasks","u16","[4]",0x8), 0x801C1DB8:("gEquipNegMasks","u16","[4]",0x8), diff --git a/tools/namefixer.py b/tools/namefixer.py index 828cf46bbc..cb902dcb62 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -492,7 +492,7 @@ wordReplace = { "func_800DFC90": "Camera_GetCamDir", "func_800DFD04": "Camera_AddQuake", "func_800DFFAC": "Camera_ChangeDoorCam", - + "func_80169FFC": "Play_CamIsNotFixed", "func_801694DC": "Play_CreateSubCamera", "Play_GetActiveCameraIndex": "Play_GetActiveCamId", "func_80169590": "Play_ChangeCameraStatus", @@ -814,6 +814,9 @@ wordReplace = { "play->nextEntranceIndex": "play->nextEntrance", "play->sceneNum": "play->sceneId", "play->pauseCtx.unk_1F0": "play->pauseCtx.bombersNotebookOpen", + "play->roomCtx.curRoom.unk3": "play->roomCtx.curRoom.behaviorType1", + "play->roomCtx.curRoom.unk2": "play->roomCtx.curRoom.behaviorType2", + "play->roomCtx.unk31": "play->roomCtx.status", "actorCtx.unkC": "actorCtx.halfDaysBit", "actorCtx.unk1F4": "actorCtx.unk_1F4.unk_00", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 3dd0ba7085..0f33e599de 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1905,14 +1905,14 @@ asm/non_matchings/code/z_rcp/Gfx_PrimColor.s,Gfx_PrimColor,0x8012CEA8,0x19 asm/non_matchings/code/z_rcp/func_8012CF0C.s,func_8012CF0C,0x8012CF0C,0x11A asm/non_matchings/code/z_rcp/func_8012D374.s,func_8012D374,0x8012D374,0x26 asm/non_matchings/code/z_rcp/func_8012D40C.s,func_8012D40C,0x8012D40C,0x3D -asm/non_matchings/code/z_room/Room_nop8012D510.s,Room_nop8012D510,0x8012D510,0x6 -asm/non_matchings/code/z_room/Room_DrawType3Mesh.s,Room_DrawType3Mesh,0x8012D528,0x5 -asm/non_matchings/code/z_room/Room_DrawType0Mesh.s,Room_DrawType0Mesh,0x8012D53C,0x85 -asm/non_matchings/code/z_room/Room_DrawType2Mesh.s,Room_DrawType2Mesh,0x8012D750,0x1E6 -asm/non_matchings/code/z_room/func_8012DEE8.s,func_8012DEE8,0x8012DEE8,0xDB -asm/non_matchings/code/z_room/func_8012E254.s,func_8012E254,0x8012E254,0x36 -asm/non_matchings/code/z_room/func_8012E32C.s,func_8012E32C,0x8012E32C,0xDF -asm/non_matchings/code/z_room/Room_DrawType1Mesh.s,Room_DrawType1Mesh,0x8012E6A8,0x1A +asm/non_matchings/code/z_room/Room_Noop.s,Room_Noop,0x8012D510,0x6 +asm/non_matchings/code/z_room/Room_DrawNone.s,Room_DrawNone,0x8012D528,0x5 +asm/non_matchings/code/z_room/Room_DrawNormal.s,Room_DrawNormal,0x8012D53C,0x85 +asm/non_matchings/code/z_room/Room_DrawCullable.s,Room_DrawCullable,0x8012D750,0x1E6 +asm/non_matchings/code/z_room/Room_DrawImageSingle.s,Room_DrawImageSingle,0x8012DEE8,0xDB +asm/non_matchings/code/z_room/Room_GetImageMultiBgEntry.s,Room_GetImageMultiBgEntry,0x8012E254,0x36 +asm/non_matchings/code/z_room/Room_DrawImageMulti.s,Room_DrawImageMulti,0x8012E32C,0xDF +asm/non_matchings/code/z_room/Room_DrawImage.s,Room_DrawImage,0x8012E6A8,0x1A asm/non_matchings/code/z_room/Room_Init.s,Room_Init,0x8012E710,0x10 asm/non_matchings/code/z_room/Room_AllocateAndLoad.s,Room_AllocateAndLoad,0x8012E750,0x87 asm/non_matchings/code/z_room/Room_StartRoomTransition.s,Room_StartRoomTransition,0x8012E96C,0x4F @@ -1936,40 +1936,40 @@ asm/non_matchings/code/z_scene/Object_GetIndex.s,Object_GetIndex,0x8012F608,0x18 asm/non_matchings/code/z_scene/Object_IsLoaded.s,Object_IsLoaded,0x8012F668,0xC asm/non_matchings/code/z_scene/Object_LoadAll.s,Object_LoadAll,0x8012F698,0x29 asm/non_matchings/code/z_scene/func_8012F73C.s,func_8012F73C,0x8012F73C,0x18 -asm/non_matchings/code/z_scene/Scene_HeaderCmdSpawnList.s,Scene_HeaderCmdSpawnList,0x8012F79C,0x5C -asm/non_matchings/code/z_scene/Scene_HeaderCmdActorList.s,Scene_HeaderCmdActorList,0x8012F90C,0x12 -asm/non_matchings/code/z_scene/Scene_HeaderCmdActorCutsceneCamList.s,Scene_HeaderCmdActorCutsceneCamList,0x8012F954,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdColHeader.s,Scene_HeaderCmdColHeader,0x8012F984,0x28 -asm/non_matchings/code/z_scene/Scene_HeaderCmdRoomList.s,Scene_HeaderCmdRoomList,0x8012FA24,0x11 -asm/non_matchings/code/z_scene/Scene_HeaderCmdEntranceList.s,Scene_HeaderCmdEntranceList,0x8012FA68,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdSpecialFiles.s,Scene_HeaderCmdSpecialFiles,0x8012FA98,0x32 -asm/non_matchings/code/z_scene/Scene_HeaderCmdRoomBehavior.s,Scene_HeaderCmdRoomBehavior,0x8012FB60,0x22 -asm/non_matchings/code/z_scene/Scene_HeaderCmdMesh.s,Scene_HeaderCmdMesh,0x8012FBE8,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdObjectList.s,Scene_HeaderCmdObjectList,0x8012FC18,0x63 -asm/non_matchings/code/z_scene/Scene_HeaderCmdLightList.s,Scene_HeaderCmdLightList,0x8012FDA4,0x22 -asm/non_matchings/code/z_scene/Scene_HeaderCmdPathList.s,Scene_HeaderCmdPathList,0x8012FE2C,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdTransiActorList.s,Scene_HeaderCmdTransiActorList,0x8012FE5C,0x18 +asm/non_matchings/code/z_scene/Scene_CommandSpawnList.s,Scene_CommandSpawnList,0x8012F79C,0x5C +asm/non_matchings/code/z_scene/Scene_CommandActorList.s,Scene_CommandActorList,0x8012F90C,0x12 +asm/non_matchings/code/z_scene/Scene_CommandActorCutsceneCamList.s,Scene_CommandActorCutsceneCamList,0x8012F954,0xC +asm/non_matchings/code/z_scene/Scene_CommandCollisionHeader.s,Scene_CommandCollisionHeader,0x8012F984,0x28 +asm/non_matchings/code/z_scene/Scene_CommandRoomList.s,Scene_CommandRoomList,0x8012FA24,0x11 +asm/non_matchings/code/z_scene/Scene_CommandEntranceList.s,Scene_CommandEntranceList,0x8012FA68,0xC +asm/non_matchings/code/z_scene/Scene_CommandSpecialFiles.s,Scene_CommandSpecialFiles,0x8012FA98,0x32 +asm/non_matchings/code/z_scene/Scene_CommandRoomBehavior.s,Scene_CommandRoomBehavior,0x8012FB60,0x22 +asm/non_matchings/code/z_scene/Scene_CommandMesh.s,Scene_CommandMesh,0x8012FBE8,0xC +asm/non_matchings/code/z_scene/Scene_CommandObjectList.s,Scene_CommandObjectList,0x8012FC18,0x63 +asm/non_matchings/code/z_scene/Scene_CommandLightList.s,Scene_CommandLightList,0x8012FDA4,0x22 +asm/non_matchings/code/z_scene/Scene_CommandPathList.s,Scene_CommandPathList,0x8012FE2C,0xC +asm/non_matchings/code/z_scene/Scene_CommandTransiActorList.s,Scene_CommandTransiActorList,0x8012FE5C,0x18 asm/non_matchings/code/z_scene/Door_InitContext.s,Door_InitContext,0x8012FEBC,0x4 -asm/non_matchings/code/z_scene/Scene_HeaderCmdEnvLightSettings.s,Scene_HeaderCmdEnvLightSettings,0x8012FECC,0x11 +asm/non_matchings/code/z_scene/Scene_CommandEnvLightSettings.s,Scene_CommandEnvLightSettings,0x8012FECC,0x11 asm/non_matchings/code/z_scene/Scene_LoadAreaTextures.s,Scene_LoadAreaTextures,0x8012FF10,0x1F -asm/non_matchings/code/z_scene/Scene_HeaderCmdSkyboxSettings.s,Scene_HeaderCmdSkyboxSettings,0x8012FF8C,0x19 -asm/non_matchings/code/z_scene/Scene_HeaderCmdSkyboxDisables.s,Scene_HeaderCmdSkyboxDisables,0x8012FFF0,0xA -asm/non_matchings/code/z_scene/Scene_HeaderCmdTimeSettings.s,Scene_HeaderCmdTimeSettings,0x80130018,0xC9 -asm/non_matchings/code/z_scene/Scene_HeaderCmdWindSettings.s,Scene_HeaderCmdWindSettings,0x8013033C,0x19 -asm/non_matchings/code/z_scene/Scene_HeaderCmdExitList.s,Scene_HeaderCmdExitList,0x801303A0,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmd09.s,Scene_HeaderCmd09,0x801303D0,0x4 -asm/non_matchings/code/z_scene/Scene_HeaderCmdSoundSettings.s,Scene_HeaderCmdSoundSettings,0x801303E0,0x17 -asm/non_matchings/code/z_scene/Scene_HeaderCmdEchoSetting.s,Scene_HeaderCmdEchoSetting,0x8013043C,0x6 -asm/non_matchings/code/z_scene/Scene_HeaderCmdAltHeaderList.s,Scene_HeaderCmdAltHeaderList,0x80130454,0x1E -asm/non_matchings/code/z_scene/Scene_HeaderCmdCutsceneList.s,Scene_HeaderCmdCutsceneList,0x801304CC,0xD -asm/non_matchings/code/z_scene/Scene_HeaderCmdActorCutsceneList.s,Scene_HeaderCmdActorCutsceneList,0x80130500,0x10 -asm/non_matchings/code/z_scene/Scene_HeaderCmdMiniMap.s,Scene_HeaderCmdMiniMap,0x80130540,0xE -asm/non_matchings/code/z_scene/Scene_HeaderCmd1D.s,Scene_HeaderCmd1D,0x80130578,0x4 -asm/non_matchings/code/z_scene/Scene_HeaderCmdMiniMapCompassInfo.s,Scene_HeaderCmdMiniMapCompassInfo,0x80130588,0xA -asm/non_matchings/code/z_scene/Scene_HeaderCmdSetRegionVisitedFlag.s,Scene_HeaderCmdSetRegionVisitedFlag,0x801305B0,0x31 -asm/non_matchings/code/z_scene/Scene_HeaderCmdAnimatedMaterials.s,Scene_HeaderCmdAnimatedMaterials,0x80130674,0xC +asm/non_matchings/code/z_scene/Scene_CommandSkyboxSettings.s,Scene_CommandSkyboxSettings,0x8012FF8C,0x19 +asm/non_matchings/code/z_scene/Scene_CommandSkyboxDisables.s,Scene_CommandSkyboxDisables,0x8012FFF0,0xA +asm/non_matchings/code/z_scene/Scene_CommandTimeSettings.s,Scene_CommandTimeSettings,0x80130018,0xC9 +asm/non_matchings/code/z_scene/Scene_CommandWindSettings.s,Scene_CommandWindSettings,0x8013033C,0x19 +asm/non_matchings/code/z_scene/Scene_CommandExitList.s,Scene_CommandExitList,0x801303A0,0xC +asm/non_matchings/code/z_scene/Scene_Command09.s,Scene_Command09,0x801303D0,0x4 +asm/non_matchings/code/z_scene/Scene_CommandSoundSettings.s,Scene_CommandSoundSettings,0x801303E0,0x17 +asm/non_matchings/code/z_scene/Scene_CommandEchoSetting.s,Scene_CommandEchoSetting,0x8013043C,0x6 +asm/non_matchings/code/z_scene/Scene_CommandAltHeaderList.s,Scene_CommandAltHeaderList,0x80130454,0x1E +asm/non_matchings/code/z_scene/Scene_CommandCutsceneList.s,Scene_CommandCutsceneList,0x801304CC,0xD +asm/non_matchings/code/z_scene/Scene_CommandActorCutsceneList.s,Scene_CommandActorCutsceneList,0x80130500,0x10 +asm/non_matchings/code/z_scene/Scene_CommandMiniMap.s,Scene_CommandMiniMap,0x80130540,0xE +asm/non_matchings/code/z_scene/Scene_Command1D.s,Scene_Command1D,0x80130578,0x4 +asm/non_matchings/code/z_scene/Scene_CommandMiniMapCompassInfo.s,Scene_CommandMiniMapCompassInfo,0x80130588,0xA +asm/non_matchings/code/z_scene/Scene_CommandSetRegionVisitedFlag.s,Scene_CommandSetRegionVisitedFlag,0x801305B0,0x31 +asm/non_matchings/code/z_scene/Scene_CommandAnimatedMaterials.s,Scene_CommandAnimatedMaterials,0x80130674,0xC asm/non_matchings/code/z_scene/Scene_SetExitFade.s,Scene_SetExitFade,0x801306A4,0x11 -asm/non_matchings/code/z_scene/Scene_ProcessHeader.s,Scene_ProcessHeader,0x801306E8,0x20 +asm/non_matchings/code/z_scene/Scene_ExecuteCommands.s,Scene_ExecuteCommands,0x801306E8,0x20 asm/non_matchings/code/z_scene/Entrance_Create.s,Entrance_Create,0x80130768,0x7 asm/non_matchings/code/z_scene/Entrance_CreateFromSpawn.s,Entrance_CreateFromSpawn,0x80130784,0xF asm/non_matchings/code/z_scene_proc/Scene_Draw.s,Scene_Draw,0x801307C0,0xD @@ -2546,7 +2546,7 @@ asm/non_matchings/code/z_play/func_80169ECC.s,func_80169ECC,0x80169ECC,0xC asm/non_matchings/code/z_play/func_80169EFC.s,func_80169EFC,0x80169EFC,0x1F asm/non_matchings/code/z_play/func_80169F78.s,func_80169F78,0x80169F78,0x19 asm/non_matchings/code/z_play/func_80169FDC.s,func_80169FDC,0x80169FDC,0x8 -asm/non_matchings/code/z_play/func_80169FFC.s,func_80169FFC,0x80169FFC,0x8 +asm/non_matchings/code/z_play/Play_CamIsNotFixed.s,Play_CamIsNotFixed,0x80169FFC,0x8 asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s,FrameAdvance_IsEnabled,0x8016A01C,0x4 asm/non_matchings/code/z_play/func_8016A02C.s,func_8016A02C,0x8016A02C,0x20 asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F @@ -2593,7 +2593,7 @@ asm/non_matchings/code/PreRender/PreRender_ApplyFiltersSlowlyInit.s,PreRender_Ap asm/non_matchings/code/PreRender/PreRender_ApplyFiltersSlowlyDestroy.s,PreRender_ApplyFiltersSlowlyDestroy,0x80172078,0x13 asm/non_matchings/code/PreRender/func_801720C4.s,func_801720C4,0x801720C4,0xE asm/non_matchings/code/PreRender/func_801720FC.s,func_801720FC,0x801720FC,0x197 -asm/non_matchings/code/PreRender/func_80172758.s,func_80172758,0x80172758,0x26 +asm/non_matchings/code/PreRender/Prerender_DrawBackground2D.s,Prerender_DrawBackground2D,0x80172758,0x26 asm/non_matchings/code/TwoHeadGfxArena/THGA_Ct.s,THGA_Ct,0x801727F0,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_Dt.s,THGA_Dt,0x80172810,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_IsCrash.s,THGA_IsCrash,0x80172830,0x8