From 641f3d7b300ba50e8e7738091be7d5053d2f56e0 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 7 Mar 2025 23:18:17 +0100 Subject: [PATCH 01/11] d_room mostly matching --- config/SOUE01/splits.txt | 9 + config/SOUE01/symbols.txt | 223 +++--- configure.py | 1 + include/d/a/d_a_base.h | 8 + include/d/col/bg/d_bg_s.h | 4 +- include/d/col/bg/d_bg_w_base.h | 3 + include/d/d_room.h | 220 ++++++ include/d/d_sc_game.h | 3 +- include/d/t/d_t_mass_obj.h | 21 + include/m/m3d/m_bmdl.h | 2 +- include/m/m3d/m_scnleaf.h | 4 + include/nw4r/g3d/res/g3d_resmdl.h | 4 + include/nw4r/g3d/res/g3d_resnode.h | 14 +- include/nw4r/math/math_geometry.h | 1 + .../arc_managers/current_stage_arc_manager.h | 2 +- include/toBeSorted/room_manager.h | 71 +- include/toBeSorted/stage_manager.h | 15 + include/toBeSorted/time_area_mgr.h | 17 +- include/toBeSorted/unk_with_water.h | 37 + src/REL/d/a/obj/d_a_obj_time_stage_bg.cpp | 2 +- src/REL/d/t/d_t_genki_dws_tgt.cpp | 5 +- src/d/a/d_a_base.cpp | 6 +- src/d/a/obj/d_a_obj_tbox.cpp | 5 +- src/d/col/bg/d_bg_s.cpp | 4 +- src/d/d_room.cpp | 652 ++++++++++++++++++ src/m/m3d/m_bmdl.cpp | 2 +- .../current_stage_arc_manager.cpp | 2 +- 27 files changed, 1144 insertions(+), 193 deletions(-) create mode 100644 include/d/t/d_t_mass_obj.h create mode 100644 include/toBeSorted/unk_with_water.h create mode 100644 src/d/d_room.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 5fe4e35b..0af7c857 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -206,6 +206,10 @@ toBeSorted/dowsing_target.cpp: .sdata2 start:0x80579640 end:0x80579670 .bss start:0x805A2FB0 end:0x805A3010 +toBeSorted/minigame_mgr.cpp: + .text start:0x800A5060 end:0x800A5608 + .ctors start:0x804DB6C4 end:0x804DB6C8 + d/lyt/d2d.cpp: .text start:0x800A9D30 end:0x800ACAB8 .data start:0x8050FFC8 end:0x80510088 @@ -651,6 +655,11 @@ d/d_room_mgr.cpp: d/d_room.cpp: .text start:0x801B5C80 end:0x801B84D8 .ctors start:0x804DB810 end:0x804DB814 + .rodata start:0x804EAB60 end:0x804EAB88 + .data start:0x8052E0D8 end:0x8052E358 + .sdata start:0x805732F8 end:0x80573348 + .sdata2 start:0x8057B528 end:0x8057B540 + .bss start:0x805B36E0 end:0x805B3760 d/d_sc_title.cpp: .text start:0x801B9230 end:0x801BA3A0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index cfac4d4c..3f9005bf 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -596,7 +596,7 @@ fn_80018EA0 = .text:0x80018EA0; // type:function size:0x58 fn_80018F00 = .text:0x80018F00; // type:function size:0x60 fn_80018F60 = .text:0x80018F60; // type:function size:0x7C fn_80018FE0 = .text:0x80018FE0; // type:function size:0xD0 -fn_800190B0 = .text:0x800190B0; // type:function size:0xB8 +remove__12UnkWithWaterFv = .text:0x800190B0; // type:function size:0xB8 fn_80019170 = .text:0x80019170; // type:function size:0x74 fn_800191F0 = .text:0x800191F0; // type:function size:0x9C fn_80019290 = .text:0x80019290; // type:function size:0x5C @@ -632,7 +632,7 @@ fn_80019E30 = .text:0x80019E30; // type:function size:0x44 fn_80019E80 = .text:0x80019E80; // type:function size:0x3A8 attach__14dScnCallback_cFRQ23m3d9scnLeaf_c = .text:0x8001A230; // type:function size:0x50 setPCAMpos2 = .text:0x8001A280; // type:function size:0x144 -fn_8001A3D0 = .text:0x8001A3D0; // type:function size:0x140 +linkMdl__12UnkWithWaterFRQ34nw4r3g3d6ResMdlP12UnkWithWater = .text:0x8001A3D0; // type:function size:0x140 fn_8001A510 = .text:0x8001A510; // type:function size:0x4 fn_8001A520 = .text:0x8001A520; // type:function size:0x4 fn_8001A530 = .text:0x8001A530; // type:function size:0x4 @@ -1636,7 +1636,7 @@ initializeState__22sFStateID_c<8dAcNpc_c>CFR8dAcNpc_c = .text:0x8003EFF0; // typ fn_8003F020 = .text:0x8003F020; // type:function size:0x40 fn_8003F060 = .text:0x8003F060; // type:function size:0x40 fn_8003F0A0 = .text:0x8003F0A0; // type:function size:0x40 -__sinit_\d_a_npc_cpp = .text:0x8003F0E0; // type:function size:0x330 +__sinit_\d_a_npc_cpp = .text:0x8003F0E0; // type:function size:0x330 scope:local __dt__22sFStateID_c<8dAcNpc_c>Fv = .text:0x8003F410; // type:function size:0x58 __dt__29sFStateVirtualID_c<8dAcNpc_c>Fv = .text:0x8003F470; // type:function size:0x5C number__29sFStateVirtualID_c<8dAcNpc_c>CFv = .text:0x8003F4D0; // type:function size:0xDC @@ -1985,7 +1985,7 @@ fn_8004CC60 = .text:0x8004CC60; // type:function size:0x4 fn_8004CC70 = .text:0x8004CC70; // type:function size:0x8 fn_8004CC80 = .text:0x8004CC80; // type:function size:0x8 fn_8004CC90 = .text:0x8004CC90; // type:function size:0x40 -__sinit_\d_a_ordinary_npc_cpp = .text:0x8004CCD0; // type:function size:0x784 +__sinit_\d_a_ordinary_npc_cpp = .text:0x8004CCD0; // type:function size:0x784 scope:local __dt__31sFStateID_c<16dAcOrdinaryNpc_c>Fv = .text:0x8004D460; // type:function size:0x58 __dt__38sFStateVirtualID_c<16dAcOrdinaryNpc_c>Fv = .text:0x8004D4C0; // type:function size:0x5C baseID_Wait<8dAcNpc_c>__Fv_RC10sStateID_c = .text:0x8004D520; // type:function size:0xC @@ -2997,7 +2997,7 @@ unloadRoomArc__22CurrentStageArcManagerFi = .text:0x80069590; // type:function s decrement__22CurrentStageArcManagerFPCc = .text:0x800695D0; // type:function size:0x28 loadFromRoomArc__22CurrentStageArcManagerFiPCc = .text:0x80069600; // type:function size:0x48 getDataFromRoomArc__22CurrentStageArcManagerFiPCc = .text:0x80069650; // type:function size:0x48 -getHeap__Fv = .text:0x800696A0; // type:function size:0x8 +getHeap__22CurrentStageArcManagerFl = .text:0x800696A0; // type:function size:0x8 getCurrentStageDirectory__22CurrentStageArcManagerFv = .text:0x800696B0; // type:function size:0x12C getRoomArcDirectory__22CurrentStageArcManagerCFi = .text:0x800697E0; // type:function size:0xB0 create__22CurrentStageArcManagerFPQ23EGG4Heap = .text:0x80069890; // type:function size:0x64 @@ -4415,7 +4415,7 @@ fn_800C7A10 = .text:0x800C7A10; // type:function size:0x8 Timekeeper__doCount = .text:0x800C7A20; // type:function size:0x130 fn_800C7B50 = .text:0x800C7B50; // type:function size:0x8 __ct__18SpecialItemDropMgrFv = .text:0x800C7B60; // type:function size:0x14 -SpecialItemDropMgr__ctor = .text:0x800C7B80; // type:function size:0x30 +create__18SpecialItemDropMgrFv = .text:0x800C7B80; // type:function size:0x30 fn_800C7BB0__18SpecialItemDropMgrFi = .text:0x800C7BB0; // type:function size:0x150 shouldTryExtraHearts__18SpecialItemDropMgrFi = .text:0x800C7D00; // type:function size:0x1C shouldTryExtraRupees__18SpecialItemDropMgrFi = .text:0x800C7D20; // type:function size:0x1C @@ -10556,8 +10556,8 @@ StageManager__addObjnId = .text:0x80199130; // type:function size:0x8 StageManager__addStageArcn = .text:0x80199140; // type:function size:0x8 StageManager__addActorId = .text:0x80199150; // type:function size:0x8 StageManager__addLayerArcn = .text:0x80199160; // type:function size:0x8 -initUnkWithWater = .text:0x80199170; // type:function size:0x18 -fn_80199190 = .text:0x80199190; // type:function size:0x18 +initUnkWithWater__11dStageMgr_cFUlP12UnkWithWater = .text:0x80199170; // type:function size:0x18 +destroyUnkWithWater__11dStageMgr_cFUlP12UnkWithWater = .text:0x80199190; // type:function size:0x18 fn_801991B0 = .text:0x801991B0; // type:function size:0xA0 fn_80199250 = .text:0x80199250; // type:function size:0x3C fn_80199290 = .text:0x80199290; // type:function size:0x164 @@ -10575,14 +10575,14 @@ StageManager__isAreaTypeBoss = .text:0x801998E0; // type:function size:0x2C StageManager__isAreaTypeSkyloft = .text:0x80199910; // type:function size:0x2C StageManager__isAreaTypeHouse = .text:0x80199940; // type:function size:0x2C isAreaTypeSky__11dStageMgr_cCFv = .text:0x80199970; // type:function size:0x2C -StageManager__isAreaTypeOverworldOrSkyloft = .text:0x801999A0; // type:function size:0x3C -StageManager__isAreaTypeDungeonOrBoss = .text:0x801999E0; // type:function size:0x3C +isAreaTypeOverworldOrSkyloft__11dStageMgr_cCFv = .text:0x801999A0; // type:function size:0x3C +isAreaTypeDungeonOrBoss__11dStageMgr_cCFv = .text:0x801999E0; // type:function size:0x3C StageManager__getSTIFmapNameId = .text:0x80199A20; // type:function size:0x20 StageManager__getSTIFbyte4 = .text:0x80199A40; // type:function size:0x20 fn_80199A60 = .text:0x80199A60; // type:function size:0x3C isSTIFbyte4_5or6 = .text:0x80199AA0; // type:function size:0x3C fn_80199AE0 = .text:0x80199AE0; // type:function size:0x3C -StageManager__getSTIFunk1 = .text:0x80199B20; // type:function size:0x20 +getSTIFunk1__11dStageMgr_cCFv = .text:0x80199B20; // type:function size:0x20 StageManager__getSTIFunk3 = .text:0x80199B40; // type:function size:0x1C fn_80199B60 = .text:0x80199B60; // type:function size:0xC fn_80199B70 = .text:0x80199B70; // type:function size:0x1C @@ -10963,7 +10963,7 @@ RoomManager__draw = .text:0x801B36F0; // type:function size:0x24 fn_801B3720 = .text:0x801B3720; // type:function size:0x4 RoomManager__createRoomsAfterRespawnMaybe = .text:0x801B3730; // type:function size:0x200 fn_801B3930 = .text:0x801B3930; // type:function size:0x30 -RoomManager__setRoom = .text:0x801B3960; // type:function size:0x10 +setRoom__11RoomManagerFiP7dRoom_c = .text:0x801B3960; // type:function size:0x10 GetRoomByIndex__11RoomManagerFi = .text:0x801B3970; // type:function size:0x10 RoomManager__handleRoomChangeMaybe = .text:0x801B3980; // type:function size:0x114 RoomManager__updateRoomFlags = .text:0x801B3AA0; // type:function size:0x134 @@ -10979,7 +10979,7 @@ fn_801B3F30 = .text:0x801B3F30; // type:function size:0x8 RoomManager__someCollisionThing = .text:0x801B3F40; // type:function size:0x90 RoomManager__getRMPLForRoom = .text:0x801B3FD0; // type:function size:0x34 RoomManager__getDungeonflagAndShiftForRoomVisit = .text:0x801B4010; // type:function size:0x34 -RoomManager__hasVisitedRoomId = .text:0x801B4050; // type:function size:0x8C +hasVisitedRoomId__11RoomManagerCFl = .text:0x801B4050; // type:function size:0x8C RoomManager__setRoomVisited = .text:0x801B40E0; // type:function size:0x12C RoomManager__createRoom = .text:0x801B4210; // type:function size:0x28 RoomManager__createLytSeekerStone = .text:0x801B4240; // type:function size:0x68 @@ -10987,7 +10987,7 @@ getRoom__11RoomManagerFi = .text:0x801B42B0; // type:function size:0x20 bindStageResToFile__11RoomManagerFPQ34nw4r3g3d7ResFile = .text:0x801B42D0; // type:function size:0x50 bindSkyCmnToResFile__11RoomManagerFPQ34nw4r3g3d7ResFile = .text:0x801B4320; // type:function size:0x54 RoomManager__getMA0AnmTexSrt = .text:0x801B4380; // type:function size:0xA0 -RoomManager__getMA0IndirectSrt = .text:0x801B4420; // type:function size:0x9C +getMA0IndirectSrt__11RoomManagerFPQ34nw4r3g3d12ResAnmTexSrtRCQ34nw4r3g3d6ResMdl = .text:0x801B4420; // type:function size:0x9C changeLoadedEntities__11RoomManagerFP11RoomManagerUlb = .text:0x801B44C0; // type:function size:0x50 RoomManager__checkRoomFlag = .text:0x801B4510; // type:function size:0x3C RoomManager__checkEnemyDefeatFlag = .text:0x801B4550; // type:function size:0x6C @@ -11023,82 +11023,82 @@ fn_801B5B90 = .text:0x801B5B90; // type:function size:0x10 fn_801B5BA0 = .text:0x801B5BA0; // type:function size:0x28 AcStageSelect__ctor = .text:0x801B5BD0; // type:function size:0x4C AcStageSelect__dtor = .text:0x801B5C20; // type:function size:0x5C -dRoom__ctor = .text:0x801B5C80; // type:function size:0x17C -RoomModel_ctor = .text:0x801B5E00; // type:function size:0x5C -fn_801B5E60 = .text:0x801B5E60; // type:function size:0x7C -fn_801B5EE0 = .text:0x801B5EE0; // type:function size:0x15C -fn_801B6040 = .text:0x801B6040; // type:function size:0x58 -fn_801B60A0 = .text:0x801B60A0; // type:function size:0x6C -fn_801B6110 = .text:0x801B6110; // type:function size:0xA0 -fn_801B61B0 = .text:0x801B61B0; // type:function size:0xA4 -fn_801B6260 = .text:0x801B6260; // type:function size:0x40 -dRoom__init = .text:0x801B62A0; // type:function size:0x33C -fn_801B65E0 = .text:0x801B65E0; // type:function size:0x10 -dRoom__destory = .text:0x801B65F0; // type:function size:0x74 -dRoom__baseUpdate = .text:0x801B6670; // type:function size:0x140 -fn_801B67B0 = .text:0x801B67B0; // type:function size:0x10 -dRoom__draw = .text:0x801B67C0; // type:function size:0x84 +dRoom_c_classInit__Fv = .text:0x801B5C80; // type:function size:0x17C +__ct__Q27dRoom_c7model_cFv = .text:0x801B5E00; // type:function size:0x5C +__dt__Q27dRoom_c5mdl_cFv = .text:0x801B5E60; // type:function size:0x7C +__dt__Q27dRoom_c7model_cFv = .text:0x801B5EE0; // type:function size:0x15C +__dt__19sFState_c<7dRoom_c>Fv = .text:0x801B6040; // type:function size:0x58 +__dt__22sFStateFct_c<7dRoom_c>Fv = .text:0x801B60A0; // type:function size:0x6C +__dt__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B6110; // type:function size:0xA0 +__dt__45sFStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c>Fv = .text:0x801B61B0; // type:function size:0xA4 +__dt__Q27dRoom_c12UnkRoomClassFv = .text:0x801B6260; // type:function size:0x40 +create__7dRoom_cFv = .text:0x801B62A0; // type:function size:0x33C +changeState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x801B65E0; // type:function size:0x10 +doDelete__7dRoom_cFv = .text:0x801B65F0; // type:function size:0x74 +execute__7dRoom_cFv = .text:0x801B6670; // type:function size:0x140 +executeState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B67B0; // type:function size:0x10 +draw__7dRoom_cFv = .text:0x801B67C0; // type:function size:0x84 dRoom__getEntranceById = .text:0x801B6850; // type:function size:0x34 fn_801B6890 = .text:0x801B6890; // type:function size:0x10 RoomManager__getEVNTForIndex = .text:0x801B68A0; // type:function size:0x10 -fn_801B68B0 = .text:0x801B68B0; // type:function size:0x20 -fn_801B68D0 = .text:0x801B68D0; // type:function size:0x54 -fn_801B6930 = .text:0x801B6930; // type:function size:0x20 -fn_801B6950 = .text:0x801B6950; // type:function size:0x58 -fn_801B69B0 = .text:0x801B69B0; // type:function size:0xBC -registerRoomCollisions = .text:0x801B6A70; // type:function size:0x110 -fn_801B6B80 = .text:0x801B6B80; // type:function size:0x70 -fn_801B6BF0 = .text:0x801B6BF0; // type:function size:0x6C -fn_801B6C60 = .text:0x801B6C60; // type:function size:0xFC -getFullRoomModelBounds = .text:0x801B6D60; // type:function size:0xC8 -fn_801B6E30 = .text:0x801B6E30; // type:function size:0x14 -fn_801B6E50 = .text:0x801B6E50; // type:function size:0xD0 -fn_801B6F20 = .text:0x801B6F20; // type:function size:0x78 -fn_801B6FA0 = .text:0x801B6FA0; // type:function size:0x4C -fn_801B6FF0 = .text:0x801B6FF0; // type:function size:0x80 -fn_801B7070 = .text:0x801B7070; // type:function size:0x8 -Room__stateActiveEnter = .text:0x801B7080; // type:function size:0x88 -Room__stateActiveUpdate = .text:0x801B7110; // type:function size:0x44 -Room__stateActiveLeave = .text:0x801B7160; // type:function size:0x4 -fn_801B7170 = .text:0x801B7170; // type:function size:0x10 -Room__stateInactiveEnter = .text:0x801B7180; // type:function size:0x50 -Room__stateInactiveUpdate = .text:0x801B71D0; // type:function size:0x28 -Room__stateInactiveLeave = .text:0x801B7200; // type:function size:0x10 -fn_801B7210 = .text:0x801B7210; // type:function size:0x54 -fn_801B7270 = .text:0x801B7270; // type:function size:0x170 -fn_801B73E0 = .text:0x801B73E0; // type:function size:0x4 -fn_801B73F0 = .text:0x801B73F0; // type:function size:0xE4 -fn_801B74E0 = .text:0x801B74E0; // type:function size:0xB0 -fn_801B7590 = .text:0x801B7590; // type:function size:0x98 -createRoomModel = .text:0x801B7630; // type:function size:0x490 -fn_801B7AC0 = .text:0x801B7AC0; // type:function size:0x168 -fn_801B7C30 = .text:0x801B7C30; // type:function size:0x68 -fn_801B7CA0 = .text:0x801B7CA0; // type:function size:0x38 -fn_801B7CE0 = .text:0x801B7CE0; // type:function size:0x18 -m3d__bmdl_c__getBounds = .text:0x801B7D00; // type:function size:0x4 -fn_801B7D10 = .text:0x801B7D10; // type:function size:0x3C -fn_801B7D50 = .text:0x801B7D50; // type:function size:0xBC -fn_801B7E10 = .text:0x801B7E10; // type:function size:0xF8 -fn_801B7F10 = .text:0x801B7F10; // type:function size:0x2C -fn_801B7F40 = .text:0x801B7F40; // type:function size:0x10 -fn_801B7F50 = .text:0x801B7F50; // type:function size:0x60 -fn_801B7FB0 = .text:0x801B7FB0; // type:function size:0xC -fn_801B7FC0 = .text:0x801B7FC0; // type:function size:0x1C -fn_801B7FE0 = .text:0x801B7FE0; // type:function size:0x1C -fn_801B8000 = .text:0x801B8000; // type:function size:0x1C -fn_801B8020 = .text:0x801B8020; // type:function size:0x10 -fn_801B8030 = .text:0x801B8030; // type:function size:0x10 -fn_801B8040 = .text:0x801B8040; // type:function size:0x10 -fn_801B8050 = .text:0x801B8050; // type:function size:0x10 -fn_801B8060 = .text:0x801B8060; // type:function size:0x10 -fn_801B8070 = .text:0x801B8070; // type:function size:0x10 -fn_801B8080 = .text:0x801B8080; // type:function size:0x30 -fn_801B80B0 = .text:0x801B80B0; // type:function size:0x30 -fn_801B80E0 = .text:0x801B80E0; // type:function size:0x30 -dRoom__dtor = .text:0x801B8110; // type:function size:0x11C -Room__initStates = .text:0x801B8230; // type:function size:0x1C0 -Room__ActorStatedtor = .text:0x801B83F0; // type:function size:0x58 -fn_801B8450 = .text:0x801B8450; // type:function size:0x88 +deactivateUpdatesCb__FP9dAcBase_c = .text:0x801B68B0; // type:function size:0x20 +deactivateUpdates__7dRoom_cFv = .text:0x801B68D0; // type:function size:0x54 +activateUpdatesCb__FP9dAcBase_c = .text:0x801B6930; // type:function size:0x20 +activateUpdates__7dRoom_cFv = .text:0x801B6950; // type:function size:0x58 +foreachObject__7dRoom_cFPFP9dAcBase_c_v = .text:0x801B69B0; // type:function size:0xBC +setupBg__7dRoom_cFv = .text:0x801B6A70; // type:function size:0x110 +executeBg__7dRoom_cFv = .text:0x801B6B80; // type:function size:0x70 +releaseBg__7dRoom_cFv = .text:0x801B6BF0; // type:function size:0x6C +drawOnMapIfVisible__7dRoom_cFP6mMtx_ci = .text:0x801B6C60; // type:function size:0xFC +getBounds__7dRoom_cCFP7mVec3_cP7mVec3_c = .text:0x801B6D60; // type:function size:0xC8 +formatObj__7dRoom_cFiR14SizedString<8> = .text:0x801B6E30; // type:function size:0x14 +sprintf__14SizedString<8>FPCce = .text:0x801B6E50; // type:function size:0xD0 +updateObjNodeInEachRoom__7dRoom_cFib = .text:0x801B6F20; // type:function size:0x78 +destroyModels__7dRoom_cFv = .text:0x801B6FA0; // type:function size:0x4C +someLastBossThing__7dRoom_cFb = .text:0x801B6FF0; // type:function size:0x80 +getFrame__7dRoom_cCFv = .text:0x801B7070; // type:function size:0x8 +initializeState_Active__7dRoom_cFv = .text:0x801B7080; // type:function size:0x88 +executeState_Active__7dRoom_cFv = .text:0x801B7110; // type:function size:0x44 +finalizeState_Active__7dRoom_cFv = .text:0x801B7160; // type:function size:0x4 +deleteActor__FP9dAcBase_c = .text:0x801B7170; // type:function size:0x10 +initializeState_NonActive__7dRoom_cFv = .text:0x801B7180; // type:function size:0x50 +executeState_NonActive__7dRoom_cFv = .text:0x801B71D0; // type:function size:0x28 +finalizeState_NonActive__7dRoom_cFv = .text:0x801B7200; // type:function size:0x10 +remove__Q27dRoom_c5mdl_cFv = .text:0x801B7210; // type:function size:0x54 +create__Q27dRoom_c5mdl_cFQ34nw4r3g3d6ResMdlR12mAllocator_c = .text:0x801B7270; // type:function size:0x170 +__ct__Q34nw4r4math4AABBFv = .text:0x801B73E0; // type:function size:0x4 +configureSomething__Q27dRoom_c5mdl_cFv = .text:0x801B73F0; // type:function size:0xE4 +somethingVisibility__Q27dRoom_c5mdl_cFUlb = .text:0x801B74E0; // type:function size:0xB0 +doSomethingWithVis__Q27dRoom_c5mdl_cFb = .text:0x801B7590; // type:function size:0x98 +create__Q27dRoom_c7model_cFQ34nw4r3g3d7ResFileR12mAllocator_clP12UnkWithWater = .text:0x801B7630; // type:function size:0x490 +execute__Q27dRoom_c7model_cFlbf = .text:0x801B7AC0; // type:function size:0x168 +draw__Q27dRoom_c7model_cFi = .text:0x801B7C30; // type:function size:0x68 +configureSomething__Q27dRoom_c7model_cFiPQ27dRoom_c5mdl_c = .text:0x801B7CA0; // type:function size:0x38 +getDrawPriority__Q27dRoom_c7model_cFl = .text:0x801B7CE0; // type:function size:0x18 +getBounds__Q27dRoom_c7model_cCFP7mVec3_cP7mVec3_c = .text:0x801B7D00; // type:function size:0x4 +getResNode__Q27dRoom_c7model_cFPCc = .text:0x801B7D10; // type:function size:0x3C +updateObjNode__Q27dRoom_c7model_cFPCcb = .text:0x801B7D50; // type:function size:0xBC +destroy__Q27dRoom_c7model_cFv = .text:0x801B7E10; // type:function size:0xF8 +getFrame__Q27dRoom_c7model_cCFv = .text:0x801B7F10; // type:function size:0x2C +getStateID__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801B7F40; // type:function size:0x10 +build__22sFStateFct_c<7dRoom_c>FRC12sStateIDIf_c = .text:0x801B7F50; // type:function size:0x60 +dispose__22sFStateFct_c<7dRoom_c>FRP10sStateIf_c = .text:0x801B7FB0; // type:function size:0xC +initialize__19sFState_c<7dRoom_c>Fv = .text:0x801B7FC0; // type:function size:0x1C +execute__19sFState_c<7dRoom_c>Fv = .text:0x801B7FE0; // type:function size:0x1C +finalize__19sFState_c<7dRoom_c>Fv = .text:0x801B8000; // type:function size:0x1C +initializeState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B8020; // type:function size:0x10 +finalizeState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B8030; // type:function size:0x10 +refreshState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B8040; // type:function size:0x10 +getState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801B8050; // type:function size:0x10 +getNewStateID__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801B8060; // type:function size:0x10 +getOldStateID__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801B8070; // type:function size:0x10 +finalizeState__21sFStateID_c<7dRoom_c>CFR7dRoom_c = .text:0x801B8080; // type:function size:0x30 +executeState__21sFStateID_c<7dRoom_c>CFR7dRoom_c = .text:0x801B80B0; // type:function size:0x30 +initializeState__21sFStateID_c<7dRoom_c>CFR7dRoom_c = .text:0x801B80E0; // type:function size:0x30 +__dt__7dRoom_cFv = .text:0x801B8110; // type:function size:0x11C +__sinit_\d_room_cpp = .text:0x801B8230; // type:function size:0x1C0 scope:local +__dt__21sFStateID_c<7dRoom_c>Fv = .text:0x801B83F0; // type:function size:0x58 +isSameName__21sFStateID_c<7dRoom_c>CFPCc = .text:0x801B8450; // type:function size:0x88 TagVrbox__ctor = .text:0x801B84E0; // type:function size:0x5C TagVrbox__setStageSpecificSkyCameraStuffMaybeMaybe = .text:0x801B8540; // type:function size:0x25C fn_801B87A0 = .text:0x801B87A0; // type:function size:0x15C @@ -11188,7 +11188,7 @@ fn_801BB2E0 = .text:0x801BB2E0; // type:function size:0xC setSpawnData__12SpawnInfoExtFPCcUcUcUcRC7mVec3_c4mAng = .text:0x801BB2F0; // type:function size:0x88 set__14LinkReloadInfoFUcRC7mVec3_c4mAngUl = .text:0x801BB380; // type:function size:0x34 isCurrentStage__9dScGame_cFPCc = .text:0x801BB3C0; // type:function size:0x10 -isStageSkyloftLayer20 = .text:0x801BB3D0; // type:function size:0x54 +isStageSkyloftLayer20__9dScGame_cFv = .text:0x801BB3D0; // type:function size:0x54 isInCredits = .text:0x801BB430; // type:function size:0x54 isStateLayerWithSeekerStoneHintMenu = .text:0x801BB490; // type:function size:0x78 copySpawnNextToCurrent__9dScGame_cFv = .text:0x801BB510; // type:function size:0xBC @@ -11229,7 +11229,7 @@ hasReachedEnd__19sFPhase<9dScGame_c>CFv = .text:0x801BC070; // type:function siz finalizeState__23sFStateID_c<9dScGame_c>CFR9dScGame_c = .text:0x801BC0A0; // type:function size:0x30 executeState__23sFStateID_c<9dScGame_c>CFR9dScGame_c = .text:0x801BC0D0; // type:function size:0x30 initializeState__23sFStateID_c<9dScGame_c>CFR9dScGame_c = .text:0x801BC100; // type:function size:0x30 -__sinit_\d_sc_game_cpp = .text:0x801BC130; // type:function size:0x27C +__sinit_\d_sc_game_cpp = .text:0x801BC130; // type:function size:0x27C scope:local __dt__23sFStateID_c<9dScGame_c>Fv = .text:0x801BC3B0; // type:function size:0x58 __dt__30sFStateVirtualID_c<9dScGame_c>Fv = .text:0x801BC410; // type:function size:0x5C number__30sFStateVirtualID_c<9dScGame_c>CFv = .text:0x801BC470; // type:function size:0xDC @@ -14571,7 +14571,7 @@ TgMassObj__destroy = .text:0x802760F0; // type:function size:0xB4 fn_802761B0 = .text:0x802761B0; // type:function size:0x7C TgMassObj__update = .text:0x80276230; // type:function size:0xEC TgMassObj__draw = .text:0x80276320; // type:function size:0x74 -fn_802763A0 = .text:0x802763A0; // type:function size:0x60 +unloadRoom__12dTgMassObj_cFUs = .text:0x802763A0; // type:function size:0x60 fn_80276400 = .text:0x80276400; // type:function size:0x250 fn_80276650 = .text:0x80276650; // type:function size:0x260 fn_802768B0 = .text:0x802768B0; // type:function size:0xB4 @@ -17593,7 +17593,7 @@ setCullMode__Q23m3d6bmdl_cFUl11_GXCullModeb = .text:0x802E9FA0; // type:function setCullModeAll__Q23m3d6bmdl_cF11_GXCullModeb = .text:0x802EA090; // type:function size:0x120 setMatVisible__Q23m3d6bmdl_cFUlb = .text:0x802EA1B0; // type:function size:0xE4 setMatTexture__Q23m3d6bmdl_cFPcP9_GXTexObjbPvii = .text:0x802EA2A0; // type:function size:0x2F0 -getBounds__Q23m3d6bmdl_cFP7mVec3_cP7mVec3_c = .text:0x802EA590; // type:function size:0x150 +getBounds__Q23m3d6bmdl_cCFP7mVec3_cP7mVec3_c = .text:0x802EA590; // type:function size:0x150 remove__Q23m3d6bmdl_cFv = .text:0x802EA6E0; // type:function size:0xC __ct__Q23m3d11calcRatio_cFv = .text:0x802EA6F0; // type:function size:0x38 __dt__Q23m3d11calcRatio_cFv = .text:0x802EA730; // type:function size:0x40 @@ -19157,9 +19157,9 @@ dBgS_MoveBGProc_Typical__FP4dBgWPvRC13cBgS_PolyInfobP7mVec3_cP7mAng3_cP7mAng3_c dBgS_MoveBGProc_RotY__FP4dBgWPvRC13cBgS_PolyInfobP7mVec3_cP7mAng3_cP7mAng3_c = .text:0x8033CDD0; // type:function size:0x34 dBgS_MoveBGProc_TypicalRotY__FP4dBgWPvRC13cBgS_PolyInfobP7mVec3_cP7mAng3_cP7mAng3_c = .text:0x8033CE10; // type:function size:0x6C RideCallBack__4dBgSFRC13cBgS_PolyInfoP12dAcObjBase_c = .text:0x8033CE80; // type:function size:0x80 -ArrowStickCallBack__4dBgSFRC13cBgS_PolyInfoP9dAcBase_cR7mVec3_c = .text:0x8033CF00; // type:function size:0x78 -UnkCallback__4dBgSFRC13cBgS_PolyInfoP9dAcBase_c = .text:0x8033CF80; // type:function size:0x88 -PushPullCallBack__4dBgSFRC13cBgS_PolyInfoP9dAcBase_cQ29dBgW_Base13PushPullLabel = .text:0x8033D010; // type:function size:0x98 +ArrowStickCallBack__4dBgSFRC13cBgS_PolyInfoP12dAcObjBase_cR7mVec3_c = .text:0x8033CF00; // type:function size:0x78 +UnkCallback__4dBgSFRC13cBgS_PolyInfoP12dAcObjBase_c = .text:0x8033CF80; // type:function size:0x88 +PushPullCallBack__4dBgSFRC13cBgS_PolyInfoP12dAcObjBase_cQ29dBgW_Base13PushPullLabel = .text:0x8033D010; // type:function size:0x98 dBgS_CheckBWallPoly__FRC13cBgS_PolyInfo = .text:0x8033D0B0; // type:function size:0x70 dBgS_CheckBGroundPoly__FRC13cBgS_PolyInfo = .text:0x8033D120; // type:function size:0x5C dBgS_CheckBRoofPoly__FRC13cBgS_PolyInfo = .text:0x8033D180; // type:function size:0x5C @@ -19169,10 +19169,10 @@ UpdateScrollTex__4dBgSFv = .text:0x8033D280; // type:function size:0x90 SetupMapGX__4dBgSFP6mMtx_c = .text:0x8033D310; // type:function size:0x4E0 SetupMapMaterial__4dBgSFibl = .text:0x8033D7F0; // type:function size:0x224 GetMapAccessor__4dBgSFv = .text:0x8033DA20; // type:function size:0x8 -DrawMap__4dBgSFUcP6mMtx_cbi = .text:0x8033DA30; // type:function size:0x1A8 +DrawMap__4dBgSFiP6mMtx_cbi = .text:0x8033DA30; // type:function size:0x1A8 SetupScrollGX__4dBgSFv = .text:0x8033DBE0; // type:function size:0x2A0 SetupScrollMaterial__4dBgSFilb = .text:0x8033DE80; // type:function size:0x408 -DrawMapScroll__4dBgSFUcP6mMtx_cbi = .text:0x8033E290; // type:function size:0x200 +DrawMapScroll__4dBgSFiP6mMtx_cbi = .text:0x8033E290; // type:function size:0x200 DrawSkyKeepMap__4dBgSFP6mMtx_ci = .text:0x8033E490; // type:function size:0x2E4 ConfigureMapTexture__4dBgSFPQ23EGG4Heap = .text:0x8033E780; // type:function size:0x1A0 __ct__14MapLineSegmentFv = .text:0x8033E920; // type:function size:0x20 @@ -28406,8 +28406,8 @@ lbl_804EA934 = .rodata:0x804EA934; // type:object size:0x1C lbl_804EA950 = .rodata:0x804EA950; // type:object size:0x78 data:4byte lbl_804EA9C8 = .rodata:0x804EA9C8; // type:object size:0x58 data:4byte lbl_804EAA20 = .rodata:0x804EAA20; // type:object size:0x140 -RoomCollisionData = .rodata:0x804EAB60; // type:object size:0x10 data:4byte -lbl_804EAB70 = .rodata:0x804EAB70; // type:object size:0x18 +sRoomBg = .rodata:0x804EAB60; // type:object size:0x10 scope:local data:4byte +cfg = .rodata:0x804EAB70; // type:object size:0x18 scope:local TRANSITION_TYPES = .rodata:0x804EAB88; // type:object size:0x10 GODDESS_WALL_FLAGS = .rodata:0x804EAB98; // type:object size:0x78 data:4byte BIPPING_STORY_FLAGS = .rodata:0x804EAC10; // type:object size:0x28 data:4byte @@ -29875,7 +29875,8 @@ lbl_80500948 = .data:0x80500948; // type:object size:0x14 lbl_8050095C = .data:0x8050095C; // type:object size:0xC lbl_80500968 = .data:0x80500968; // type:object size:0x2C lbl_80500994 = .data:0x80500994; // type:object size:0x2C -lbl_805009C0 = .data:0x805009C0; // type:object size:0x60 +__vt__12UnkWithWater = .data:0x805009C0; // type:object size:0x10 +lbl_805009D0 = .data:0x805009D0; // type:object size:0x50 AnimModelWrapper__vtable = .data:0x80500A20; // type:object size:0x50 lbl_80500A70 = .data:0x80500A70; // type:object size:0x2C lbl_80500A9C = .data:0x80500A9C; // type:object size:0xC @@ -34193,7 +34194,7 @@ RoomManager__RoomTable__vtable = .data:0x8052E04C; // type:object size:0xC lbl_8052E058 = .data:0x8052E058; // type:object size:0x24 g_profile_STAGE_SELECT = .data:0x8052E080; // type:object size:0xC AcStageSelect__vtable = .data:0x8052E08C; // type:object size:0x4C -g_profile_ROOM = .data:0x8052E0D8; // type:object size:0x44 +g_profile_ROOM = .data:0x8052E0D8; // type:object size:0xC lbl_8052E11C = .data:0x8052E11C; // type:object size:0x10 lbl_8052E12C = .data:0x8052E12C; // type:object size:0x10 lbl_8052E13C = .data:0x8052E13C; // type:object size:0x10 @@ -34201,14 +34202,14 @@ lbl_8052E14C = .data:0x8052E14C; // type:object size:0x10 lbl_8052E15C = .data:0x8052E15C; // type:object size:0xC lbl_8052E168 = .data:0x8052E168; // type:object size:0xC lbl_8052E174 = .data:0x8052E174; // type:object size:0x14 -dRoom__vtable = .data:0x8052E188; // type:object size:0x4C -lbl_8052E1D4 = .data:0x8052E1D4; // type:object size:0xC -lbl_8052E1E0 = .data:0x8052E1E0; // type:object size:0x30 -lbl_8052E210 = .data:0x8052E210; // type:object size:0x30 -lbl_8052E240 = .data:0x8052E240; // type:object size:0x18 -lbl_8052E258 = .data:0x8052E258; // type:object size:0x18 -lbl_8052E270 = .data:0x8052E270; // type:object size:0xB4 -lbl_8052E324 = .data:0x8052E324; // type:object size:0x34 +__vt__7dRoom_c = .data:0x8052E188; // type:object size:0x4C +__vt__Q27dRoom_c12UnkRoomClass = .data:0x8052E1D4; // type:object size:0xC +__vt__45sFStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c> = .data:0x8052E1E0; // type:object size:0x30 +__vt__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x8052E210; // type:object size:0x30 +__vt__22sFStateFct_c<7dRoom_c> = .data:0x8052E240; // type:object size:0x14 +__vt__19sFState_c<7dRoom_c> = .data:0x8052E258; // type:object size:0x18 +__vt__Q27dRoom_c5mdl_c = .data:0x8052E270; // type:object size:0x2C +__vt__21sFStateID_c<7dRoom_c> = .data:0x8052E324; // type:object size:0x34 g_profile_VRBOX_TAG = .data:0x8052E358; // type:object size:0x10 lbl_8052E368 = .data:0x8052E368; // type:object size:0x18 lbl_8052E380 = .data:0x8052E380; // type:object size:0x20 @@ -40380,7 +40381,7 @@ sCurrentObtainingItemOarcName = .sbss:0x80575918; // type:object size:0x4 data:4 @GUARD@draw__9dAcTbox_cFv@shadowDirs = .sbss:0x80575926; // type:object size:0x1 data:byte @GUARD@checkIsClear__9dAcTbox_cCFv@offsets = .sbss:0x80575927; // type:object size:0x1 data:byte lbl_80575928 = .sbss:0x80575928; // type:object size:0x8 data:byte -TgMassObj__MASS_OBJ_TAG_PTR = .sbss:0x80575930; // type:object size:0x4 data:4byte +sInstance__12dTgMassObj_c = .sbss:0x80575930; // type:object size:0x4 data:4byte lbl_80575934 = .sbss:0x80575934; // type:object size:0x4 data:4byte lbl_80575938 = .sbss:0x80575938; // type:object size:0x4 data:float lbl_8057593C = .sbss:0x8057593C; // type:object size:0x4 data:float @@ -49132,8 +49133,8 @@ lbl_805B31E0 = .bss:0x805B31E0; // type:object size:0x400 MSBT_NAME_IN_ARC = .bss:0x805B35E0; // type:object size:0x80 data:byte lbl_805B3660 = .bss:0x805B3660; // type:object size:0x80 data:byte lbl_805B36E0 = .bss:0x805B36E0; // type:object size:0x10 -Room__STATE_ACTIVE = .bss:0x805B36F0; // type:object size:0x40 data:4byte -Room__STATE_NON_ACTIVE = .bss:0x805B3730; // type:object size:0x30 data:4byte +StateID_Active__7dRoom_c = .bss:0x805B36F0; // type:object size:0x30 data:4byte +StateID_NonActive__7dRoom_c = .bss:0x805B3730; // type:object size:0x30 data:4byte lbl_805B3760 = .bss:0x805B3760; // type:object size:0xC StateID_Stanby__10dScTitle_c = .bss:0x805B376C; // type:object size:0x34 StateID_Action__10dScTitle_c = .bss:0x805B37AC; // type:object size:0x34 diff --git a/configure.py b/configure.py index 7e451643..5b1adfc9 100644 --- a/configure.py +++ b/configure.py @@ -429,6 +429,7 @@ config.libs = [ Object(Matching, "d/lyt/d_lyt_fader.cpp"), Object(Matching, "d/lyt/d_screen_fader.cpp"), Object(NonMatching, "d/a/d_a_insect.cpp"), + Object(NonMatching, "d/d_room.cpp"), Object(NonMatching, "d/d_cs_base.cpp"), Object(NonMatching, "d/d_cs_game.cpp"), Object(Matching, "d/d_sc_title.cpp"), diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index 90afd1dc..ab4ca53a 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -173,6 +173,14 @@ public: return actor_properties & property; } + void callunkVirtFunc_0x60() { + unkVirtFunc_0x60(); + } + + void callrestorePosRotFromCopy() { + restorePosRotFromCopy(); + } + public: // funcs found in TU /* 8002c650 */ static void setTempCreateParams( diff --git a/include/d/col/bg/d_bg_s.h b/include/d/col/bg/d_bg_s.h index abb6dc59..d39058b6 100644 --- a/include/d/col/bg/d_bg_s.h +++ b/include/d/col/bg/d_bg_s.h @@ -228,10 +228,10 @@ public: void SetupMapGX(mMtx_c *); void SetupMapMaterial(int matIdx, bool, s32 roomId); UNKTYPE *GetMapAccessor(); - void DrawMap(u8 roomId, mMtx_c *, bool bColor, int); + void DrawMap(int roomId, mMtx_c *, bool bColor, int); void SetupScrollGX(); void SetupScrollMaterial(int matIdx, s32, bool); - void DrawMapScroll(u8 roomId, mMtx_c *, bool bColor, int); + void DrawMapScroll(int roomId, mMtx_c *, bool bColor, int); void DrawSkyKeepMap(mMtx_c *, int); bool ConfigureMapTexture(EGG::Heap *); diff --git a/include/d/col/bg/d_bg_w_base.h b/include/d/col/bg/d_bg_w_base.h index a8d634b5..af0eba52 100644 --- a/include/d/col/bg/d_bg_w_base.h +++ b/include/d/col/bg/d_bg_w_base.h @@ -176,6 +176,9 @@ public: void SetPriority(PRIORITY priority) { mPriority = priority; } + void SetUnkBase() { + mField_0x18.field_0x00 = 1; + } void OnStickWall() { field_0x24 |= 1; } diff --git a/include/d/d_room.h b/include/d/d_room.h index e69de29b..7af97952 100644 --- a/include/d/d_room.h +++ b/include/d/d_room.h @@ -0,0 +1,220 @@ +#ifndef D_ROOM_H +#define D_ROOM_H + +#include "common.h" +#include "d/a/d_a_base.h" +#include "d/col/bg/d_bg_w_kcol.h" +#include "d/d_base.h" +#include "m/m3d/m_anmmatclr.h" +#include "m/m3d/m_anmtexpat.h" +#include "m/m3d/m_anmtexsrt.h" +#include "m/m3d/m_anmvis.h" +#include "m/m3d/m_smdl.h" +#include "m/m_allocator.h" +#include "nw4r/g3d/res/g3d_resfile.h" +#include "nw4r/g3d/res/g3d_resmdl.h" +#include "nw4r/g3d/res/g3d_resnode.h" +#include "nw4r/math/math_geometry.h" +#include "s/s_State.hpp" +#include "sized_string.h" +#include "toBeSorted/unk_with_water.h" + +struct DrawPriorityConfig { + u8 pDrawOpa1; + u8 pDrawXlu; + u8 pDrawOpa2; +}; + +// This could be std::unique_ptr, but we don't have it yet +template +class RaiiPtr { +public: + T *mPtr; + + RaiiPtr() : mPtr(nullptr) {} + ~RaiiPtr() { + if (mPtr != nullptr) { + delete mPtr; + mPtr = nullptr; + } + } + + void operator=(T *ptr) { + mPtr = ptr; + } + + operator bool() const { + return mPtr != nullptr; + } + + const T *operator->() const { + return mPtr; + } + + T *operator->() { + return mPtr; + } + + const T &operator*() const { + return *this->operator->(); + } + + T &operator*() { + return *this->operator->(); + } +}; + +class dRoom_c : public dBase_c { + class mdl_c : public m3d::smdl_c { + public: + mdl_c() : mpAabb(nullptr) {} + virtual ~mdl_c() { + remove(); + } + virtual void remove() override; + + bool hasModel() const { + return getG3dObject() != nullptr; + } + + bool create(nw4r::g3d::ResMdl resMdl, mAllocator_c &alloc); + void configureSomething(); + void somethingVisibility(u32 id, bool visible); + + private: + void doSomethingWithVis(bool arg); + nw4r::math::AABB *mpAabb; + }; + class model_c { + friend class dRoom_c; + + public: + model_c() {} + + bool create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s32 idx, UnkWithWater *waterThing); + bool getBounds(mVec3_c *min, mVec3_c *max) const; + nw4r::g3d::ResNode getResNode(const char *nodeName); + void updateObjNode(const char *node, bool visible); + void destroy(); + void execute(s32 idx, bool roomfield_0x573, f32 pastState); + void draw(int roomid); + f32 getFrame() const; + void configureSomething(int roomid, mdl_c *mdl); + + const DrawPriorityConfig *getDrawPriority(s32 idx); + + private: + mdl_c mMdl; + RaiiPtr mpAnmClr; + RaiiPtr mpAnmPat; + RaiiPtr mpAnmSrt; + RaiiPtr mpAnmVis; + }; + +public: + dRoom_c() + : mStateMgr(*this, sStateID::null), + field_0x15C(nullptr), + SCEN(nullptr), + PLY(nullptr), + CAM(nullptr), + EVNT(nullptr), + PATH(nullptr), + PNT(nullptr), + BPNT(nullptr), + AREA(nullptr), + unkCount(0), + scenCount(0), + plyCount(0), + camCount(0), + evntCount(0), + pathCount(0), + pntCount(0), + bpntCount(0), + areaCount(0), + mFlags(0) {} + virtual ~dRoom_c() {} + + virtual int create() override; + virtual int doDelete() override; + virtual int execute() override; + virtual int draw() override; + + STATE_FUNC_DECLARE(dRoom_c, Active); + STATE_FUNC_DECLARE(dRoom_c, NonActive); + + bool checkFlag(u32 flag) { + return mFlags & flag; + } + + void drawOnMapIfVisible(mMtx_c *mtx, int param); + void getBounds(mVec3_c *min, mVec3_c *max) const; + + void someLastBossThing(bool arg); + f32 getFrame() const; + + typedef void (*foreachObjCallback)(dAcBase_c *obj); + s32 foreachObject(foreachObjCallback cb); + +private: + bool setupBg(); + void executeBg(); + void releaseBg(); + + static void formatObj(int obj, SizedString<8> &str); + void updateObjNodeInEachRoom(int obj, bool visible); + void destroyModels(); + void activateUpdates(); + void deactivateUpdates(); + + /* 0x068 */ mHeapAllocator_c mAllocator; + /* 0x084 */ nw4r::g3d::ResFile mRoomRes; + /* 0x088 */ UnkWithWater mWaterThing; + /* 0x0A0 */ model_c mModels[8]; + /* 0x220 */ dBgWKCol mBg[2]; + /* 0x4E0 */ STATE_MGR_DECLARE(dRoom_c); + + /* 0x51C */ void *field_0x15C; + /* 0x520 */ void *SCEN; + /* 0x524 */ void *PLY; + /* 0x528 */ void *CAM; + /* 0x52C */ void *EVNT; + /* 0x530 */ void *PATH; + /* 0x534 */ void *PNT; + /* 0x538 */ void *BPNT; + /* 0x53C */ void *SPTH; + /* 0x540 */ void *field_0x540; + /* 0x544 */ void *field_0x544; + /* 0x548 */ void *AREA; + /* 0x54C */ u16 unkCount; + /* 0x54E */ u16 scenCount; + /* 0x550 */ u16 plyCount; + /* 0x552 */ u16 camCount; + /* 0x554 */ u16 evntCount; + /* 0x556 */ u16 pathCount; + /* 0x558 */ u16 pntCount; + /* 0x55A */ u16 bpntCount; + /* 0x55C */ u16 spthCount; + /* 0x55E */ u16 unk2Count; + /* 0x560 */ u16 unk3Count; + /* 0x562 */ u16 areaCount; + + // peak vtable placement + class UnkRoomClass { + public: + virtual ~UnkRoomClass() {} + }; + + /* 0x564 */ UnkRoomClass mUnk; + /* 0x568 */ u8 mFlags; + void *BZS; + /* 0x570 */ s8 roomid; + /* 0x571 */ bool field_0x571; + /* 0x572 */ bool field_0x572; + /* 0x573 */ bool field_0x573; + /* 0x574 */ bool mHasAnmTexPat; + /* 0x575 */ bool mDidAlreadyInit; + /* 0x576 */ bool field_0x576; +}; + +#endif diff --git a/include/d/d_sc_game.h b/include/d/d_sc_game.h index 1bae3b7f..0b002f89 100644 --- a/include/d/d_sc_game.h +++ b/include/d/d_sc_game.h @@ -57,7 +57,7 @@ struct SpawnInfo { /* 0x00 */ SizedString<32> stageName; /* 0x20 */ u16 transitionFadeFrames; - /* 0x22 */ s8 room; + /* 0x22 */ u8 room; /* 0x23 */ u8 layer; /* 0x24 */ s8 entrance; /* 0x25 */ u8 night; @@ -136,6 +136,7 @@ public: STATE_VIRTUAL_FUNC_DECLARE(dScGame_c, Action); static bool isCurrentStage(const char *stageName); + static bool isStageSkyloftLayer20(); static SpawnInfo currentSpawnInfo; static SpawnInfo nextSpawnInfo; diff --git a/include/d/t/d_t_mass_obj.h b/include/d/t/d_t_mass_obj.h new file mode 100644 index 00000000..bfb7166a --- /dev/null +++ b/include/d/t/d_t_mass_obj.h @@ -0,0 +1,21 @@ +#ifndef D_T_MASS_OBJ_H +#define D_T_MASS_OBJ_H + +#include "d/t/d_tg.h" + +class dTgMassObj_c : public dTg_c { +public: + dTgMassObj_c() {} + virtual ~dTgMassObj_c() {} + + static dTgMassObj_c *GetInstance() { + return sInstance; + } + + void unloadRoom(u16 roomid); + +private: + static dTgMassObj_c *sInstance; +}; + +#endif diff --git a/include/m/m3d/m_bmdl.h b/include/m/m3d/m_bmdl.h index eda8bfe7..e42d3f57 100644 --- a/include/m/m3d/m_bmdl.h +++ b/include/m/m3d/m_bmdl.h @@ -37,7 +37,7 @@ public: void setCullModeAll(GXCullMode cullMode, bool bMarkDirty); void setMatVisible(u32 matId, bool bVisble); int setMatTexture(char *name, GXTexObj *texObj, bool copy, void *unk, int, int); - bool getBounds(mVec3_c *min, mVec3_c *max); + bool getBounds(mVec3_c *min, mVec3_c *max) const; private: banm_c *mpCurrentAnm; diff --git a/include/m/m3d/m_scnleaf.h b/include/m/m3d/m_scnleaf.h index 44090e7b..5e7b7d49 100644 --- a/include/m/m3d/m_scnleaf.h +++ b/include/m/m3d/m_scnleaf.h @@ -53,6 +53,10 @@ public: return mpScnLeaf; } + inline const nw4r::g3d::ScnLeaf *getG3dObject() const { + return mpScnLeaf; + } + protected: /* 0x14 */ nw4r::g3d::ScnLeaf *mpScnLeaf; }; diff --git a/include/nw4r/g3d/res/g3d_resmdl.h b/include/nw4r/g3d/res/g3d_resmdl.h index 428bdff6..11f9ce97 100644 --- a/include/nw4r/g3d/res/g3d_resmdl.h +++ b/include/nw4r/g3d/res/g3d_resmdl.h @@ -148,6 +148,10 @@ public: return GetRevision() == REVISION; } + const char *GetName() const { + return ofs_to_ptr(ref().name); + } + const u8 *GetResByteCode(const char *pName) const; ResNode GetResNode(const char *pName) const; diff --git a/include/nw4r/g3d/res/g3d_resnode.h b/include/nw4r/g3d/res/g3d_resnode.h index 1fa0244c..e31a3617 100644 --- a/include/nw4r/g3d/res/g3d_resnode.h +++ b/include/nw4r/g3d/res/g3d_resnode.h @@ -67,8 +67,8 @@ struct ResNodeData : ResNodeDataTypedef { math::_VEC3 scale; // at 0x20 math::_VEC3 rot; // at 0x2C math::_VEC3 translate; // at 0x38 - math::VEC3 volume_min; // at 0x44 - math::VEC3 volume_max; // at 0x50 + math::_VEC3 volume_min; // at 0x44 + math::_VEC3 volume_max; // at 0x50 s32 toParentNode; // at 0x5C s32 toChildNode; // at 0x60 s32 toNextSibling; // at 0x64 @@ -143,6 +143,16 @@ public: return ref().translate; } + // not in the dwarf + const math::VEC3 &GetBoundsMin() const { + return *(const math::VEC3*)&ref().volume_min; + } + + // not in the dwarf + const math::VEC3 &GetBoundsMax() const { + return *(const math::VEC3*)&ref().volume_max; + } + ResNode GetParentNode() { return ofs_to_obj(ref().toParentNode); } diff --git a/include/nw4r/math/math_geometry.h b/include/nw4r/math/math_geometry.h index a869e98f..922942e8 100644 --- a/include/nw4r/math/math_geometry.h +++ b/include/nw4r/math/math_geometry.h @@ -35,6 +35,7 @@ struct PLANE { struct AABB { AABB() {} + AABB(const VEC3 &min, const VEC3 &max) : min(min), max(max) {} void Set(const VEC3 *points, unsigned int num); void Set(const AABB *box, const MTX34 *mtx); diff --git a/include/toBeSorted/arc_managers/current_stage_arc_manager.h b/include/toBeSorted/arc_managers/current_stage_arc_manager.h index 84e4cbe5..ee25ec14 100644 --- a/include/toBeSorted/arc_managers/current_stage_arc_manager.h +++ b/include/toBeSorted/arc_managers/current_stage_arc_manager.h @@ -30,7 +30,7 @@ public: const char *getCurrentStageDirectory(); const char *getRoomArcDirectory(int room) const; - static EGG::ExpHeap *getHeap(); + EGG::ExpHeap *getHeap(s32 roomid); private: SizedString<32> mStageName; diff --git a/include/toBeSorted/room_manager.h b/include/toBeSorted/room_manager.h index fcc5688a..3353e826 100644 --- a/include/toBeSorted/room_manager.h +++ b/include/toBeSorted/room_manager.h @@ -3,73 +3,17 @@ #include "common.h" #include "d/d_base.h" +#include "d/d_room.h" #include "m/m_allocator.h" #include "m/types_m.h" - +#include "nw4r/g3d/res/g3d_resmdl.h" #define MAX_ROOM_NUMBER 64 -class dRoomModel { - char mainModel[28]; // Actually smdl_c - nw4r::math::AABB *roomBounds; - m3d::anmMatClr_c *anmMatClr; - m3d::anmTexPat_c *anmTexPat; - m3d::anmTexSrt_c *anmTexSrt; - m3d::anmVis_c *anmVis; -}; - -class dRoomCollision { - char todo[352]; -}; - -class dRoom : public dBase_c { -public: - mAllocator_c allocator; - nw4r::g3d::ResFile *roomRes; - char unkWithWater[24]; - dRoomModel roomModels[8]; - dRoomCollision roomCollisions[2]; - char stateMgr[60]; - char _0[4]; - void *SCEN; - void *PLY; - void *CAM; - void *EVNT; - void *PATH; - void *PNT; - void *BPNT; - void *SPTH; - void *_1; - void *_2; - void *AREA; - char _3[4]; - short plyCount; - short camCount; - short evntCount; - short pathCount; - short pntCount; - short bpntCount; - short spthCount; - short _4; - short _5; - short areaCount; - char _6[4]; - u8 flags; - void *BZS; - s8 roomid; - char _7[3]; - bool hasAnmTexPat; - bool didAlreadyInit; - - bool checkFlag(u32 flag) { - return flags & flag; - } -}; - class dRoomTable { /* 801b4670 */ dRoomTable(dRoomTable *roomTable); virtual ~dRoomTable(); - dRoom *rooms[MAX_ROOM_NUMBER - 1]; + dRoom_c *rooms[MAX_ROOM_NUMBER - 1]; }; class MapRelated { @@ -99,16 +43,19 @@ public: /* 80575760 */ static RoomManager *m_Instance; public: - /* 801b3970 */ dRoom *GetRoomByIndex(int roomid); - /* 801b42b0 */ static dRoom *getRoom(int roomid); + /* 801b3970 */ dRoom_c *GetRoomByIndex(int roomid); + /* 801b42b0 */ static dRoom_c *getRoom(int roomid); /* 801b42d0 */ static void bindStageResToFile(nw4r::g3d::ResFile *); /* 801b4320 */ static void bindSkyCmnToResFile(nw4r::g3d::ResFile *); /* 801b4380 */ static bool getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *, char *); - /* 801b4420 */ static bool getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *, char *); + /* 801b4420 */ static bool getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *, const nw4r::g3d::ResMdl &mdl); /* 801b44c0 */ static void changeLoadedEntities(RoomManager *mgr, u32 index_shift, bool set); /* 801b4510 */ static u32 checkRoomFlag(RoomManager *mgr, u32 flag); /* 801b4550 */ static bool checkEnemyDefeatFlag(RoomManager *mgr, u32 flag); /* 801b45c0 */ static bool fn_801B45C0(RoomManager *mgr /* plus others */); + /* 801b6c60 */ bool hasVisitedRoomId(s32 roomid) const; + + void setRoom(int roomid, dRoom_c *room); }; #endif diff --git a/include/toBeSorted/stage_manager.h b/include/toBeSorted/stage_manager.h index 0e406d57..c5cf9984 100644 --- a/include/toBeSorted/stage_manager.h +++ b/include/toBeSorted/stage_manager.h @@ -2,19 +2,34 @@ #define STAGE_MANAGER_H #include "d/d_base.h" +#include "toBeSorted/unk_with_water.h" class dStageMgr_c : dBase_c { public: bool isAreaTypeDungeon() const; bool isAreaTypeSky() const; + bool isAreaTypeDungeonOrBoss() const; + bool isAreaTypeOverworldOrSkyloft() const; + s32 getSTIFunk1() const; + s32 getAreaType() const; static dStageMgr_c *GetInstance() { return sInstance; } + bool checkFlag0x88A0(u32 flag) const { + return (field_0x88A0 & flag) != 0; + } + + void initUnkWithWater(u32 val, UnkWithWater *waterThing); + void destroyUnkWithWater(u32 val, UnkWithWater *waterThing); + private: static dStageMgr_c *sInstance; + + /* 0x0068 */ u8 _0x0068[0x88A0 - 0x0068]; + /* 0x88A0 */ u32 field_0x88A0; }; #endif diff --git a/include/toBeSorted/time_area_mgr.h b/include/toBeSorted/time_area_mgr.h index d28abfb3..c4cde66d 100644 --- a/include/toBeSorted/time_area_mgr.h +++ b/include/toBeSorted/time_area_mgr.h @@ -61,6 +61,18 @@ public: static dTimeAreaMgr_c *sInstance; + bool isInLanayruMiningFacility() const { + return mIsInLanayruMiningFacility; + } + + bool isField0x78() const { + return field_0x78; + } + + void setField0x7A(bool val) { + field_0x7A = val; + } + private: /* 0x04 */ u8 field_0x04[0x0C - 0x04]; /* 0x0C */ mHeapAllocator_c mAllocator; @@ -68,7 +80,10 @@ private: /* 0x40 */ dTimeAreaMgrProcB_c mProcB; /* 0x5C */ u8 field_0x5C[0x64 - 0x5C]; /* 0x64 */ s32 field_0x64; - /* 0x68 */ u8 field_0x68[0x7B - 0x68]; + /* 0x68 */ u8 field_0x68[0x78 - 0x68]; + /* 0x78 */ bool field_0x78; + /* 0x79 */ u8 field_0x79[0x7A - 0x79]; + /* 0x7A */ bool field_0x7A; /* 0x7B */ bool mIsInLanayruMiningFacility; }; diff --git a/include/toBeSorted/unk_with_water.h b/include/toBeSorted/unk_with_water.h new file mode 100644 index 00000000..9fa2f40c --- /dev/null +++ b/include/toBeSorted/unk_with_water.h @@ -0,0 +1,37 @@ +#ifndef UNK_WITH_WATER_H +#define UNK_WITH_WATER_H + +#include "common.h" +#include "nw4r/g3d/res/g3d_resmdl.h" +#include "toBeSorted/tlist.h" + +struct UnkWithWaterNode { +public: + /* 0x00 */ TListNode mNode; + /* 0x08 */ UNKWORD field_0x08; + /* 0x0C */ UNKWORD field_0x0C; +}; + +class UnkWithWater { +public: + typedef TList NodeList; + + UnkWithWater() : field_0x04(0), field_0x08(0) {} + virtual ~UnkWithWater() { + remove(); + } + + static bool linkMdl(nw4r::g3d::ResMdl &mdl, UnkWithWater *thing); + bool hasLinks() const { + return mList.mCount != 0; + } + +private: + void remove(); + + /* 0x04 */ UNKWORD field_0x04; + /* 0x08 */ UNKWORD field_0x08; + /* 0x0C */ NodeList mList; +}; + +#endif diff --git a/src/REL/d/a/obj/d_a_obj_time_stage_bg.cpp b/src/REL/d/a/obj/d_a_obj_time_stage_bg.cpp index 3176ceba..ba496cd0 100644 --- a/src/REL/d/a/obj/d_a_obj_time_stage_bg.cpp +++ b/src/REL/d/a/obj/d_a_obj_time_stage_bg.cpp @@ -32,7 +32,7 @@ bool dAcOTimeStageBg_c::createHeap() { TRY_CREATE(mMdl1.create(mdl, &heap_allocator, 0x128)); nw4r::g3d::ResNode nd = mdl.GetResNode(sMdlNames[mSubType]); - field_0x3EC.copyFrom((nd.ref().volume_min + nd.ref().volume_max) * 0.5f); + field_0x3EC.copyFrom((nd.GetBoundsMin() + nd.GetBoundsMax()) * 0.5f); if (mSubType == 4) { nw4r::g3d::ResAnmClr a = mRes.GetResAnmClr("Teniobj_0"); TRY_CREATE(mAnm.create(mdl, a, &heap_allocator, nullptr, 1)); diff --git a/src/REL/d/t/d_t_genki_dws_tgt.cpp b/src/REL/d/t/d_t_genki_dws_tgt.cpp index ef184152..778b38f4 100644 --- a/src/REL/d/t/d_t_genki_dws_tgt.cpp +++ b/src/REL/d/t/d_t_genki_dws_tgt.cpp @@ -1,5 +1,6 @@ #include "d/t/d_t_genki_dws_tgt.h" +#include "d/d_room.h" #include "d/d_sc_game.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" @@ -51,9 +52,9 @@ int dTgGenkiDwsTgt_c::actorExecute() { } else { RoomManager *mgr = RoomManager::m_Instance; if (mgr != nullptr) { - dRoom *room = RoomManager::m_Instance->GetRoomByIndex(roomid); + dRoom_c *room = RoomManager::m_Instance->GetRoomByIndex(roomid); if (room != nullptr) { - if (room->flags & 8) { + if (room->checkFlag(8)) { mDowsingTarget.doRegister(); } else { mDowsingTarget.doUnregister(); diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index b4bed28c..68dc8364 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -3,6 +3,7 @@ #include "d/a/d_a_player.h" #include "d/a/obj/d_a_obj_base.h" #include "d/d_heap.h" +#include "d/d_room.h" #include "d/d_sc_game.h" #include "d/flag/enemyflag_manager.h" #include "f/f_list_nd.h" @@ -35,7 +36,6 @@ extern "C" s16 targetAngleY(mVec3_c *, mVec3_c *); extern "C" s16 targetAngleX(mVec3_c *, mVec3_c *); extern "C" bool checkCollision(mVec3_c *pos); extern "C" s8 collisionCheckGetRoom(); -extern "C" dRoom *getRoomByIndex(RoomManager *mgr, s8 roomid); bool dAcBase_c::createHeap() { return true; @@ -434,8 +434,8 @@ void dAcBase_c::updateRoomId(f32 yOffset) { // 8002d540 bool dAcBase_c::isRoomFlags_0x6_Set() { - dRoom *room = RoomManager::m_Instance->GetRoomByIndex(roomid); - return (room->flags & 6); + dRoom_c *room = RoomManager::m_Instance->GetRoomByIndex(roomid); + return (room->checkFlag(0x4 | 0x2)); } // Start of SoundSource stuff diff --git a/src/d/a/obj/d_a_obj_tbox.cpp b/src/d/a/obj/d_a_obj_tbox.cpp index d62b1169..1689a31f 100644 --- a/src/d/a/obj/d_a_obj_tbox.cpp +++ b/src/d/a/obj/d_a_obj_tbox.cpp @@ -11,6 +11,7 @@ #include "d/col/c/c_bg_s_poly_info.h" #include "d/col/cc/d_cc_d.h" #include "d/col/cc/d_cc_s.h" +#include "d/d_room.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" #include "d/flag/tboxflag_manager.h" @@ -1191,7 +1192,7 @@ int dAcTbox_c::actorExecute() { (this->*mRegisterDowsingTarget)(); } - dRoom *r = RoomManager::m_Instance->GetRoomByIndex(roomid); + dRoom_c *r = RoomManager::m_Instance->GetRoomByIndex(roomid); bool hasFlags = r->checkFlag(0x1E); if (hasFlags) { setObjectProperty(0x200); @@ -1327,7 +1328,7 @@ int dAcTbox_c::actorExecuteInEvent() { (this->*mRegisterDowsingTarget)(); } - dRoom *r = RoomManager::m_Instance->GetRoomByIndex(roomid); + dRoom_c *r = RoomManager::m_Instance->GetRoomByIndex(roomid); bool hasFlags = r->checkFlag(0x1E); if (hasFlags) { setObjectProperty(0x200); diff --git a/src/d/col/bg/d_bg_s.cpp b/src/d/col/bg/d_bg_s.cpp index b23d869e..229ad3d5 100644 --- a/src/d/col/bg/d_bg_s.cpp +++ b/src/d/col/bg/d_bg_s.cpp @@ -1028,7 +1028,7 @@ UNKTYPE *dBgS::GetMapAccessor() { return lbl_805754B0; } -void dBgS::DrawMap(u8 roomId, mMtx_c *, bool bColor, int) { +void dBgS::DrawMap(int roomId, mMtx_c *, bool bColor, int) { // TODO } @@ -1068,7 +1068,7 @@ void dBgS::SetupScrollMaterial(int matIdx, s32, bool) { // TODO } -void dBgS::DrawMapScroll(u8 roomId, mMtx_c *, bool bColor, int) { +void dBgS::DrawMapScroll(int roomId, mMtx_c *, bool bColor, int) { // TODO } diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp new file mode 100644 index 00000000..48ef2c34 --- /dev/null +++ b/src/d/d_room.cpp @@ -0,0 +1,652 @@ +#include "d/d_room.h" + +#include "common.h" +#include "d/a/d_a_base.h" +#include "d/a/d_a_item.h" +#include "d/a/obj/d_a_obj_base.h" +#include "d/col/bg/d_bg_s.h" +#include "d/col/bg/d_bg_w_base.h" +#include "d/col/bg/d_bg_w_kcol.h" +#include "d/d_sc_game.h" +#include "d/flag/sceneflag_manager.h" +#include "d/flag/storyflag_manager.h" +#include "d/t/d_t_mass_obj.h" +#include "egg/math/eggMath.h" +#include "f/f_base.h" +#include "m/m3d/m_anmmatclr.h" +#include "m/m3d/m_anmtexpat.h" +#include "m/m3d/m_anmtexsrt.h" +#include "m/m3d/m_anmvis.h" +#include "m/m3d/m_fanm.h" +#include "m/m3d/m_smdl.h" +#include "m/m_mtx.h" +#include "m/m_vec.h" +#include "nw4r/g3d/g3d_scnmdl.h" +#include "nw4r/g3d/g3d_scnobj.h" +#include "nw4r/g3d/res/g3d_resanmclr.h" +#include "nw4r/g3d/res/g3d_resanmtexpat.h" +#include "nw4r/g3d/res/g3d_resanmtexsrt.h" +#include "nw4r/g3d/res/g3d_resanmvis.h" +#include "nw4r/g3d/res/g3d_resfile.h" +#include "nw4r/g3d/res/g3d_resmat.h" +#include "nw4r/g3d/res/g3d_resmdl.h" +#include "nw4r/g3d/res/g3d_resnode.h" +#include "nw4r/math/math_geometry.h" +#include "nw4r/math/math_types.h" +#include "sized_string.h" +#include "toBeSorted/arc_managers/current_stage_arc_manager.h" +#include "toBeSorted/room_manager.h" +#include "toBeSorted/stage_manager.h" +#include "toBeSorted/time_area_mgr.h" +#include "toBeSorted/unk_with_water.h" + +SPECIAL_BASE_PROFILE(ROOM, dRoom_c, fProfile::ROOM, 0x9, 96); + +STATE_DEFINE(dRoom_c, Active); +STATE_DEFINE(dRoom_c, NonActive); + +extern "C" void parseRoomBzs(int roomid, void *bzs); + +int dRoom_c::create() { + roomid = params & 0x3F; + field_0x573 = dStageMgr_c::GetInstance()->getSTIFunk1() == 0 && + !(dScGame_c::isCurrentStage("D301") && roomid == 12) && + !(dScGame_c::isCurrentStage("D303") && roomid == 12) && + !(dScGame_c::isCurrentStage("D300") && (roomid == 0 || roomid == 1 || roomid == 4)) && + !(dScGame_c::isCurrentStage("D300_1") && (roomid == 7 || roomid == 9)); + if (!mAllocator.createNewTempFrmHeap( + -1, CurrentStageArcManager::sInstance->getHeap(roomid), "dRoom_c::m_allocator", 0x20, 0 + )) { + return FAILED; + } + + bool anyError = false; + + mRoomRes = nw4r::g3d::ResFile(CurrentStageArcManager::sInstance->loadFromRoomArc(roomid, "g3d/room.brres")); + RoomManager::bindStageResToFile(&mRoomRes); + RoomManager::bindSkyCmnToResFile(&mRoomRes); + + for (s32 i = 0; i < 8; i++) { + model_c *mdl = &mModels[i]; + if (i != 2 || roomid != 1 || dScGame_c::currentSpawnInfo.layer != 14 || !dScGame_c::isCurrentStage("F406")) { + if (!mdl->create(mRoomRes, mAllocator, i, &mWaterThing)) { + anyError = true; + break; + } + if (mdl->mpAnmPat) { + mHasAnmTexPat = true; + } + } + } + + if (!anyError) { + if (mWaterThing.hasLinks()) { + u32 val = 0; + dStageMgr_c *stageMr = dStageMgr_c::GetInstance(); + if (stageMr->checkFlag0x88A0(2)) { + val = 3; + } + stageMr->initUnkWithWater(val, &mWaterThing); + } + anyError = setupBg(); + } + mAllocator.adjustFrmHeapRestoreCurrent(); + + if (anyError) { + return FAILED; + } + + RoomManager::m_Instance->setRoom(roomid, this); + BZS = CurrentStageArcManager::sInstance->loadFromRoomArc(roomid, "dat/room.bzs"); + parseRoomBzs(roomid, BZS); + mDidAlreadyInit = (params >> 6) & 1; + mStateMgr.changeState(StateID_Active); + if (roomid != dScGame_c::currentSpawnInfo.room) { + mFlags |= 2; + deactivateUpdates(); + } + + return SUCCEEDED; +} + +int dRoom_c::doDelete() { + destroyModels(); + if (mWaterThing.hasLinks()) { + u32 val = 0; + dStageMgr_c *stageMr = dStageMgr_c::GetInstance(); + if (stageMr->checkFlag0x88A0(2)) { + val = 3; + } + stageMr->destroyUnkWithWater(val, &mWaterThing); + } + + RoomManager::m_Instance->setRoom(roomid, nullptr); + return SUCCEEDED; +} + +int dRoom_c::execute() { + mStateMgr.executeState(); + f32 val = 0.0f; + if (field_0x573) { + val = dTimeAreaMgr_c::sInstance->checkPositionIsInPastState(roomid, mVec3_c::Zero, nullptr, 1000000.0f); + field_0x576 = !mHasAnmTexPat && (!dTimeAreaMgr_c::sInstance->isInLanayruMiningFacility() || val > 0.0f) && + dTimeAreaMgr_c::sInstance->isField0x78(); + } else { + field_0x576 = false; + } + + if ((mFlags & 2) != 0 || field_0x576) { + releaseBg(); + return SUCCEEDED; + } + + executeBg(); + for (s32 i = 0; i < 8; i++) { + mModels[i].execute(i, field_0x573, val); + } + + return SUCCEEDED; +} + +int dRoom_c::draw() { + if ((mFlags & 2) != 0 || field_0x576) { + return SUCCEEDED; + } + for (s32 i = 0; i < 8; i++) { + mModels[i].draw(roomid); + } + return SUCCEEDED; +} + +void deactivateUpdatesCb(dAcBase_c *ac) { + if (!ac->checkActorProperty(0x400)) { + return; + } + ac->callunkVirtFunc_0x60(); +} + +void dRoom_c::deactivateUpdates() { + if (!field_0x572) { + foreachObject(deactivateUpdatesCb); + setProcControlFlag(ROOT_DISABLE_EXECUTE | ROOT_DISABLE_DRAW); + field_0x572 = true; + } +} + +void activateUpdatesCb(dAcBase_c *ac) { + if (!ac->checkActorProperty(0x400)) { + return; + } + ac->callrestorePosRotFromCopy(); +} + +void dRoom_c::activateUpdates() { + if (field_0x572) { + foreachObject(activateUpdatesCb); + clearProcControlFlag(ROOT_DISABLE_EXECUTE); + clearProcControlFlag(ROOT_DISABLE_DRAW); + field_0x572 = false; + } +} + +s32 dRoom_c::foreachObject(foreachObjCallback cb) { + s32 count = 0; + + fBase_c *start = getConnectBrNext(); + if (start == nullptr) { + start = getConnectParent(); + } + + for (fBase_c *base = getConnectChild(); base != nullptr && base != start; base = getConnectTreeNext(base)) { + if (base->group_type == ACTOR || base->group_type == STAGE) { + cb(static_cast(base)); + count++; + } + } + return count; +} + +struct BgData { + const char *kcl; + const char *plc; +}; + +static const BgData sRoomBg[] = { + { "kcl/room.kcl", "dat/room.plc"}, + {"kcl/room_n.kcl", "dat/room_n.plc"}, +}; + +bool dRoom_c::setupBg() { + for (int i = 0; i < 2; i++) { + dBgWKCol *bg = &mBg[i]; + void *kcl = CurrentStageArcManager::sInstance->getDataFromRoomArc(roomid, sRoomBg[i].kcl); + if (kcl != nullptr) { + void *plc = CurrentStageArcManager::sInstance->loadFromRoomArc(roomid, sRoomBg[i].plc); + bg->Set(kcl, plc); + bg->SetRoomId(roomid); + bg->SetPriority(dBgW_Base::PRIORITY_0); + bool ok = (BOOL)bg->InitMapStuff(&mAllocator); + if (!ok) { + return true; + } + + if (field_0x573 && !mHasAnmTexPat) { + bg->SetUnkBase(); + } + // ??? + dBgS::GetInstance()->Regist(bg, (dAcObjBase_c *)nullptr); + dBgS::GetInstance()->RegistBg(bg, nullptr); + } + } + return false; +} + +void dRoom_c::executeBg() { + for (int i = 0; i < 2; i++) { + if (!mBg[i].ChkNotReady()) { + dBgS::GetInstance()->Regist(&mBg[i], (dAcObjBase_c *)nullptr); + } + } +} + +void dRoom_c::releaseBg() { + for (int i = 0; i < 2; i++) { + if (!mBg[i].ChkNotReady()) { + dBgS::GetInstance()->Release(&mBg[i]); + } + } +} + +void dRoom_c::drawOnMapIfVisible(mMtx_c *mtx, int param) { + bool drawFully = true; + if (dStageMgr_c::GetInstance()->isAreaTypeDungeonOrBoss()) { + drawFully = RoomManager::m_Instance->hasVisitedRoomId(roomid); + if (!drawFully && !dAcItem_c::checkFlag(/* DUNGEON_MAP_FI */ 0x32)) { + return; + } + } else { + // "new map part in lake floria" + if (dStageMgr_c::GetInstance()->isAreaTypeOverworldOrSkyloft() && dScGame_c::isCurrentStage("F102") && + !StoryflagManager::sInstance->getCounterOrFlag(115) && roomid >= 3 && roomid < 5) { + return; + } + } + + dBgS::GetInstance()->DrawMap(roomid, mtx, drawFully, param); +} + +void dRoom_c::getBounds(mVec3_c *min, mVec3_c *max) const { + for (int i = 0; i < 8; i++) { + mVec3_c tMin, tMax; + mModels[i].getBounds(&tMin, &tMax); + if (i == 0) { + *min = tMin; + *max = tMax; + } else { + nw4r::math::VEC3Minimize(min, min, tMin); + nw4r::math::VEC3Maximize(max, max, tMax); + } + } +} + +void dRoom_c::formatObj(int obj, SizedString<8> &str) { + str.sprintf("obj%d", obj); +} + +void dRoom_c::updateObjNodeInEachRoom(int obj, bool visible) { + SizedString<8> objName; + formatObj(obj, objName); + for (int i = 0; i < 8; i++) { + mModels[i].updateObjNode(objName, visible); + } +} + +void dRoom_c::destroyModels() { + for (int i = 0; i < 8; i++) { + mModels[i].destroy(); + } +} + +// Called from d_a_lastboss +void dRoom_c::someLastBossThing(bool arg) { + const char *name = "model0"; + if (!arg) { + name = "model_obj0"; + } + nw4r::g3d::ResAnmTexSrt anmSrt = mRoomRes.GetResAnmTexSrt(name); + if (anmSrt.IsValid()) { + mModels[0].mpAnmSrt->setAnm(mModels[0].mMdl, anmSrt, 0, m3d::PLAY_MODE_4); + mModels[0].mMdl.setAnm(*mModels[0].mpAnmSrt); + } +} + +f32 dRoom_c::getFrame() const { + return mModels[0].getFrame(); +} + +extern "C" void fn_800641D0(int roomid, void *roomBzs); +extern "C" void fn_80064160(int roomid, void *roomBzs); + +void dRoom_c::initializeState_Active() { + SceneflagManager::sInstance->unsetZoneflagsForRoom(roomid); + executeBg(); + fn_800641D0(roomid, BZS); + if (mDidAlreadyInit) { + fn_80064160(roomid, BZS); + } else { + mFlags |= 8 | 2; + mDidAlreadyInit = true; + } +} + +void dRoom_c::executeState_Active() { + u8 flags = mFlags; + field_0x571 = (flags & (4 | 2)) != 0; + if (field_0x571) { + if ((flags & 8) != 0) { + mStateMgr.changeState(StateID_NonActive); + } else { + deactivateUpdates(); + } + return; + } + + activateUpdates(); +} + +void dRoom_c::finalizeState_Active() {} + +void deleteActor(dAcBase_c *ac) { + ac->setActorProperty(0x800); + ac->deleteRequest(); +} + +void dRoom_c::initializeState_NonActive() { + foreachObject(deleteActor); + if (dTgMassObj_c::GetInstance() != nullptr) { + dTgMassObj_c::GetInstance()->unloadRoom(roomid); + } +} + +void dRoom_c::executeState_NonActive() { + if ((mFlags & 8) != 0) { + return; + } + mStateMgr.changeState(StateID_Active); +} + +void dRoom_c::finalizeState_NonActive() { + mFlags = mFlags & ~8; + destroyModels(); +} + +void dRoom_c::mdl_c::remove() { + if (mpAabb != nullptr) { + delete[] mpAabb; + mpAabb = nullptr; + doSomethingWithVis(true); + } +} + +bool dRoom_c::mdl_c::create(nw4r::g3d::ResMdl resMdl, mAllocator_c &alloc) { + if (!m3d::smdl_c::create(resMdl, &alloc, 0x40)) { + return false; + } + calc(false); + u32 numEntries = resMdl.GetResNodeNumEntries(); + mpAabb = new nw4r::math::AABB[numEntries]; + ; + if (mpAabb == nullptr) { + return false; + } + + nw4r::math::AABB *buf = mpAabb; + u32 id = 0; + if (numEntries != 0) { + for (; id < numEntries; id++) { + mMtx_c mtx; + getNodeWorldMtx(id, mtx); + nw4r::g3d::ResNode resNd = resMdl.GetResNode(id); + // TODO Vec problems + nw4r::math::VEC3 min, max; + min = resNd.GetBoundsMin(); + max = resNd.GetBoundsMax(); + nw4r::math::AABB bb(min, max); + buf->Set(&bb, mtx); + buf++; + } + } + + doSomethingWithVis(false); + return true; +} + +extern "C" bool fn_801BB750(nw4r::math::AABB *aabb, f32 f); + +void dRoom_c::mdl_c::configureSomething() { + nw4r::g3d::ResMdl mdl = getResMdl(); + u32 numNodes = mdl.GetResNodeNumEntries(); + + nw4r::math::AABB *aabbs = mpAabb; + for (u32 i = 0; i < numNodes; i++) { + nw4r::g3d::ResNode nd = mdl.GetResNode(i); + if (nd.IsVisible() && (nd.ref().flags & nw4r::g3d::ResNodeData::FLAG_GEOMETRY) && + nd.GetBillboardMode() == nw4r::g3d::ResNodeDataTypedef::BILLBOARD_OFF) { + somethingVisibility(i, !fn_801BB750(&aabbs[i], EGG::Math::maxNumber())); + } + } +} + +void dRoom_c::mdl_c::somethingVisibility(u32 id, bool visible) { + nw4r::g3d::ScnMdl *mdl = nw4r::g3d::ScnObj::DynamicCast(getG3dObject()); + nw4r::g3d::ScnMdl::CopiedVisAccess v(mdl, id); + v.SetVisibility(visible); +} + +void dRoom_c::mdl_c::doSomethingWithVis(bool arg) { + nw4r::g3d::ResMdl mdl = getResMdl(); + const char *mdlName = mdl.GetName(); + if (strequals(mdlName, "model0_s") && dScGame_c::isStageSkyloftLayer20()) { + nw4r::g3d::ResMat mat = mdl.GetResMat("MA03_C_Door_Kasan"); + setMatVisible(mat.GetID(), arg); + } +} + +bool dRoom_c::model_c::create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s32 idx, UnkWithWater *waterThing) { + SizedString<16> mdlName; + mdlName.sprintf("model%d", idx >> 1); + if ((idx & 1) != 0) { + mdlName += "_s"; + } + + nw4r::g3d::ResMdl mdl = resFile.GetResMdl(mdlName); + if (!mdl.IsValid()) { + return true; + } + + bool linkResult = UnkWithWater::linkMdl(mdl, waterThing); + if (!mMdl.create(mdl, alloc)) { + return false; + } + + const DrawPriorityConfig *cfg = getDrawPriority(idx); + u8 xlu = linkResult != 0 ? dStageMgr_c::GetInstance()->checkFlag0x88A0(0x2) ? cfg->pDrawXlu : 0x84 : cfg->pDrawXlu; + mMdl.setPriorityDraw(cfg->pDrawOpa1, xlu); + bool anyAnims = false; + nw4r::g3d::ResAnmClr anmClr = resFile.GetResAnmClr(mdlName); + if (anmClr.IsValid()) { + mpAnmClr = new m3d::anmMatClr_c(); + if (!mpAnmClr) { + return false; + } + if (!mpAnmClr->create(mdl, anmClr, &alloc, nullptr, 1)) { + return false; + } + mMdl.setAnm(*mpAnmClr); + anyAnims = true; + } + + nw4r::g3d::ResAnmTexPat anmPat = resFile.GetResAnmTexPat(mdlName); + if (anmPat.IsValid()) { + mpAnmPat = new m3d::anmTexPat_c(); + if (!mpAnmPat) { + return false; + } + if (!mpAnmPat->create(mdl, anmPat, &alloc, nullptr, 1)) { + return false; + } + mMdl.setAnm(*mpAnmPat); + anyAnims = true; + } + + nw4r::g3d::ResAnmTexSrt anmSrt = resFile.GetResAnmTexSrt(mdlName); + if (!anmSrt.IsValid()) { + RoomManager::getMA0IndirectSrt(&anmSrt, mdl); + } + if (anmSrt.IsValid()) { + mpAnmSrt = new m3d::anmTexSrt_c(); + if (!mpAnmSrt) { + return false; + } + if (!mpAnmSrt->create(mdl, anmSrt, &alloc, nullptr, 1)) { + return false; + } + mMdl.setAnm(*mpAnmSrt); + anyAnims = true; + } + + nw4r::g3d::ResAnmVis anmVis = resFile.GetResAnmVis(mdlName); + if (anmVis.IsValid()) { + mpAnmVis = new m3d::anmVis_c(); + if (!mpAnmVis) { + return false; + } + if (!mpAnmVis->create(mdl, anmVis, &alloc, nullptr)) { + return false; + } + mMdl.setAnm(*mpAnmVis); + anyAnims = true; + } + + if (anyAnims) { + mMdl.setOption(nw4r::g3d::ScnObj::OPTION_DISABLE_CALC_WORLD, false); + } + + return true; +} + +void dRoom_c::model_c::execute(s32 idx, bool roomfield_0x573, f32 pastState) { + if (!mMdl.hasModel()) { + return; + } + + if (mpAnmClr) { + mpAnmClr->play(); + } + + if (mpAnmSrt) { + mpAnmSrt->play(); + } + + if (mpAnmVis) { + mpAnmVis->play(); + } + + if (roomfield_0x573 && !(idx >= 6)) { + if (mpAnmPat) { + int frame = (pastState > 0.0f); + mpAnmPat->setFrame(frame, 0); + } else { + const DrawPriorityConfig *cfg = getDrawPriority(idx); + if (pastState > 0.0f) { + mMdl.setPriorityDraw(cfg->pDrawOpa2, cfg->pDrawXlu); + } else { + mMdl.setPriorityDraw(cfg->pDrawOpa1, cfg->pDrawXlu); + } + } + } else { + if (mpAnmPat) { + mpAnmPat->play(); + } + } +} + +void dRoom_c::model_c::draw(int roomid) { + if (!mMdl.hasModel()) { + return; + } + mMdl.configureSomething(); + configureSomething(roomid, &mMdl); + mMdl.entry(); +} + +extern "C" void fn_80017B10(nw4r::g3d::ResMdl &mdl, bool, bool); + +void dRoom_c::model_c::configureSomething(int roomid, mdl_c *mdl) { + nw4r::g3d::ResMdl resMdl = mdl->getResMdl(); + fn_80017B10(resMdl, true, false); +} + +const DrawPriorityConfig cfg[] = { + {0x18, 0x5, 0x7}, + {0x1E, 0x5, 0x9}, + {0x19, 0x6, 0x7}, + {0x1F, 0x6, 0x9}, + {0x1A, 0x7, 0x7}, + {0x20, 0x7, 0x9}, + {0x1B, 0x8, 0x7}, + {0x21, 0x8, 0x9}, +}; + +const DrawPriorityConfig *dRoom_c::model_c::getDrawPriority(s32 idx) { + return &cfg[idx]; +} + +bool dRoom_c::model_c::getBounds(mVec3_c *min, mVec3_c *max) const { + return mMdl.getBounds(min, max); +} + +nw4r::g3d::ResNode dRoom_c::model_c::getResNode(const char *nodeName) { + return mMdl.getResMdl().GetResNode(nodeName); +} + +void dRoom_c::model_c::updateObjNode(const char *node, bool visible) { + if (!mMdl.hasModel()) { + return; + } + + nw4r::g3d::ResNode nd = getResNode(node); + if (!nd.IsValid()) { + return; + } + + nd.SetVisibility(visible); + mMdl.somethingVisibility(nd.GetID(), visible); + if (visible) { + dTimeAreaMgr_c::sInstance->setField0x7A(true); + } else { + dTimeAreaMgr_c::sInstance->setField0x7A(false); + } +} + +void dRoom_c::model_c::destroy() { + if (!mMdl.hasModel()) { + return; + } + + nw4r::g3d::ScnMdl *mdl = nw4r::g3d::ScnObj::DynamicCast(mMdl.getG3dObject()); + nw4r::g3d::ResMdl resMdl = mMdl.getResMdl(); + for (u32 i = 0; i < resMdl.GetResNodeNumEntries(); i++) { + nw4r::g3d::ResNode nd = resMdl.GetResNode(i); + nd.SetVisibility(true); + nw4r::g3d::ScnMdl::CopiedVisAccess v(mdl, i); + v.SetVisibility(true); + } +} + +f32 dRoom_c::model_c::getFrame() const { + if (!mMdl.hasModel() || !mpAnmSrt) { + return 0.0f; + } + return mpAnmSrt->getFrame(0); +} diff --git a/src/m/m3d/m_bmdl.cpp b/src/m/m3d/m_bmdl.cpp index 1eec02e8..39bc384b 100644 --- a/src/m/m3d/m_bmdl.cpp +++ b/src/m/m3d/m_bmdl.cpp @@ -219,7 +219,7 @@ int bmdl_c::setMatTexture(char *name, GXTexObj *texObj, bool copy, void *unk, in // TODO } -bool bmdl_c::getBounds(mVec3_c *min, mVec3_c *max) { +bool bmdl_c::getBounds(mVec3_c *min, mVec3_c *max) const { // TODO } diff --git a/src/toBeSorted/arc_managers/current_stage_arc_manager.cpp b/src/toBeSorted/arc_managers/current_stage_arc_manager.cpp index be757b81..33ed8bac 100644 --- a/src/toBeSorted/arc_managers/current_stage_arc_manager.cpp +++ b/src/toBeSorted/arc_managers/current_stage_arc_manager.cpp @@ -95,7 +95,7 @@ void *CurrentStageArcManager::getDataFromRoomArc(int roomId, const char *fileNam return mArcTable.getSubEntryData(getRoomArcDirectory(roomId), fileName); } -EGG::ExpHeap *getHeap() { +EGG::ExpHeap *CurrentStageArcManager::getHeap(s32 roomid) { return dHeap::workExHeap.heap; } From 535c42b5fcfd0b9211d5b21a30cd57094098bcaf Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 8 Mar 2025 10:05:29 +0100 Subject: [PATCH 02/11] Fix vec problems --- src/d/d_room.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index 48ef2c34..6447299f 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -395,7 +395,7 @@ bool dRoom_c::mdl_c::create(nw4r::g3d::ResMdl resMdl, mAllocator_c &alloc) { calc(false); u32 numEntries = resMdl.GetResNodeNumEntries(); mpAabb = new nw4r::math::AABB[numEntries]; - ; + if (mpAabb == nullptr) { return false; } @@ -407,10 +407,9 @@ bool dRoom_c::mdl_c::create(nw4r::g3d::ResMdl resMdl, mAllocator_c &alloc) { mMtx_c mtx; getNodeWorldMtx(id, mtx); nw4r::g3d::ResNode resNd = resMdl.GetResNode(id); - // TODO Vec problems - nw4r::math::VEC3 min, max; - min = resNd.GetBoundsMin(); - max = resNd.GetBoundsMax(); + mVec3_c min, max; + min.copyFrom(resNd.GetBoundsMin()); + max.copyFrom(resNd.GetBoundsMax()); nw4r::math::AABB bb(min, max); buf->Set(&bb, mtx); buf++; From 03c99fc37c5a833d4334f43c14b6206d65108663 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 8 Mar 2025 10:15:47 +0100 Subject: [PATCH 03/11] Comments --- src/d/d_room.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index 6447299f..f2334854 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -50,9 +50,12 @@ extern "C" void parseRoomBzs(int roomid, void *bzs); int dRoom_c::create() { roomid = params & 0x3F; field_0x573 = dStageMgr_c::GetInstance()->getSTIFunk1() == 0 && + // SSH machine room (less sure about D303...) !(dScGame_c::isCurrentStage("D301") && roomid == 12) && !(dScGame_c::isCurrentStage("D303") && roomid == 12) && + // LMF first two rooms, Gust Bellows room !(dScGame_c::isCurrentStage("D300") && (roomid == 0 || roomid == 1 || roomid == 4)) && + // LMF crawlspace, spike maze !(dScGame_c::isCurrentStage("D300_1") && (roomid == 7 || roomid == 9)); if (!mAllocator.createNewTempFrmHeap( -1, CurrentStageArcManager::sInstance->getHeap(roomid), "dRoom_c::m_allocator", 0x20, 0 @@ -258,6 +261,8 @@ void dRoom_c::releaseBg() { } void dRoom_c::drawOnMapIfVisible(mMtx_c *mtx, int param) { + // Dungeon map shows rooms but doesn't fill them out + // Visited rooms are shown filled out bool drawFully = true; if (dStageMgr_c::GetInstance()->isAreaTypeDungeonOrBoss()) { drawFully = RoomManager::m_Instance->hasVisitedRoomId(roomid); @@ -265,7 +270,7 @@ void dRoom_c::drawOnMapIfVisible(mMtx_c *mtx, int param) { return; } } else { - // "new map part in lake floria" + // Lake Floria interior if (dStageMgr_c::GetInstance()->isAreaTypeOverworldOrSkyloft() && dScGame_c::isCurrentStage("F102") && !StoryflagManager::sInstance->getCounterOrFlag(115) && roomid >= 3 && roomid < 5) { return; From c558c88f2534c699661671d41fcbd84633be74b3 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 8 Mar 2025 18:54:53 +0100 Subject: [PATCH 04/11] d_stage progress --- config/SOUE01/splits.txt | 7 +- config/SOUE01/symbols.txt | 92 ++--- configure.py | 3 +- include/d/d_bzs_types.h | 163 ++++++++ include/d/d_fader.h | 4 + include/d/d_room.h | 33 +- include/d/d_sc_game.h | 4 + include/d/d_stage.h | 174 +++++++++ include/d/flag/sceneflag_manager.h | 2 +- include/m/m_fader.h | 8 +- include/nw4r/g3d/res/g3d_resmat.h | 4 + include/toBeSorted/area_utils.h | 10 +- include/toBeSorted/event_manager.h | 2 + include/toBeSorted/music_mgrs.h | 3 + include/toBeSorted/room_manager.h | 61 --- include/toBeSorted/time_area_mgr.h | 4 + src/REL/d/a/obj/d_a_obj_appear_bridge.cpp | 4 +- src/REL/d/a/obj/d_a_obj_bamboo_island.cpp | 6 +- src/REL/d/a/obj/d_a_obj_island_nusi.cpp | 6 +- src/REL/d/a/obj/d_a_obj_lava_F200.cpp | 4 +- src/REL/d/a/obj/d_a_obj_megami_island.cpp | 6 +- src/REL/d/a/obj/d_a_obj_pool_cock.cpp | 4 +- src/REL/d/a/obj/d_a_obj_sun_light.cpp | 6 +- src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp | 4 +- src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp | 4 +- src/REL/d/a/obj/d_a_obj_uta_demo_pedest.cpp | 6 +- src/REL/d/a/obj/d_a_obj_utajima.cpp | 6 +- src/REL/d/a/obj/d_a_obj_utajima_island.cpp | 6 +- src/REL/d/a/obj/d_a_obj_utajima_lv2.cpp | 6 +- src/REL/d/t/d_t_genki_dws_tgt.cpp | 7 +- src/d/a/d_a_base.cpp | 18 +- src/d/a/obj/d_a_obj_tbox.cpp | 6 +- src/d/d_room.cpp | 14 +- src/d/d_sc_game.cpp | 1 - src/d/d_stage.cpp | 392 ++++++++++++++++++++ src/d/flag/sceneflag_manager.inc | 2 +- src/toBeSorted/room_manager.cpp | 3 - 37 files changed, 885 insertions(+), 200 deletions(-) create mode 100644 include/d/d_bzs_types.h create mode 100644 include/d/d_stage.h delete mode 100644 include/toBeSorted/room_manager.h create mode 100644 src/d/d_stage.cpp delete mode 100644 src/toBeSorted/room_manager.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 0af7c857..27ad9e06 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -154,7 +154,7 @@ d/d_scene.cpp: .sbss start:0x80575220 end:0x80575228 .bss start:0x805A06F0 end:0x805A0720 -d/d_stage.cpp: +d/d_stage_parse.cpp: .text start:0x80062E40 end:0x80064250 d/d_sys.cpp: @@ -648,9 +648,12 @@ d/tg/d_t_weather.cpp: .text start:0x801A65D0 end:0x801AF7D8 .ctors start:0x804DB804 end:0x804DB808 -d/d_room_mgr.cpp: +d/d_stage.cpp: .text start:0x801B32A0 end:0x801B5BC8 .ctors start:0x804DB80C end:0x804DB810 + .data start:0x8052DF40 end:0x8052E080 + .sdata start:0x80573290 end:0x805732F8 + .sdata2 start:0x8057B4E8 end:0x8057B528 d/d_room.cpp: .text start:0x801B5C80 end:0x801B84D8 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 3f9005bf..e2b45c5b 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -10951,52 +10951,52 @@ fn_801B31B0 = .text:0x801B31B0; // type:function size:0x24 fn_801B31E0 = .text:0x801B31E0; // type:function size:0x34 fn_801B3220 = .text:0x801B3220; // type:function size:0x64 initCurrentLangString = .text:0x801B3290; // type:function size:0xC -RoomManager__ctor = .text:0x801B32A0; // type:function size:0x30 -RoomManager__ctorCont = .text:0x801B32D0; // type:function size:0xF0 -fn_801B33C0 = .text:0x801B33C0; // type:function size:0x58 -fn_801B3420 = .text:0x801B3420; // type:function size:0x40 +dStage_c_classInit__Fv = .text:0x801B32A0; // type:function size:0x30 +__ct__8dStage_cFv = .text:0x801B32D0; // type:function size:0xF0 +__dt__18sFPhase<8dStage_c>Fv = .text:0x801B33C0; // type:function size:0x58 +__dt__12dRoomTable_cFv = .text:0x801B3420; // type:function size:0x40 fn_801B3460 = .text:0x801B3460; // type:function size:0x40 -RoomManager__init = .text:0x801B34A0; // type:function size:0x1D8 -fn_801B3680 = .text:0x801B3680; // type:function size:0x30 -RoomManager__baseUpdate = .text:0x801B36B0; // type:function size:0x3C -RoomManager__draw = .text:0x801B36F0; // type:function size:0x24 -fn_801B3720 = .text:0x801B3720; // type:function size:0x4 -RoomManager__createRoomsAfterRespawnMaybe = .text:0x801B3730; // type:function size:0x200 -fn_801B3930 = .text:0x801B3930; // type:function size:0x30 -setRoom__11RoomManagerFiP7dRoom_c = .text:0x801B3960; // type:function size:0x10 -GetRoomByIndex__11RoomManagerFi = .text:0x801B3970; // type:function size:0x10 +create__8dStage_cFv = .text:0x801B34A0; // type:function size:0x1D8 +doDelete__8dStage_cFv = .text:0x801B3680; // type:function size:0x30 +execute__8dStage_cFv = .text:0x801B36B0; // type:function size:0x3C +draw__8dStage_cFv = .text:0x801B36F0; // type:function size:0x24 +deleteReady__8dStage_cFv = .text:0x801B3720; // type:function size:0x4 +createRooms__8dStage_cFv = .text:0x801B3730; // type:function size:0x200 +waitForRooms__8dStage_cFv = .text:0x801B3930; // type:function size:0x30 +setRoom__8dStage_cFiP7dRoom_c = .text:0x801B3960; // type:function size:0x10 +getRoom__8dStage_cFl = .text:0x801B3970; // type:function size:0x10 RoomManager__handleRoomChangeMaybe = .text:0x801B3980; // type:function size:0x114 RoomManager__updateRoomFlags = .text:0x801B3AA0; // type:function size:0x134 RoomManager__checkOtherRoomLoaded = .text:0x801B3BE0; // type:function size:0x78 fn_801B3C60 = .text:0x801B3C60; // type:function size:0x9C -RoomManager__fadeIn = .text:0x801B3D00; // type:function size:0xA8 -RoomManager__fadeOut = .text:0x801B3DB0; // type:function size:0xA8 -RoomManager__somethingFadeOutRelated = .text:0x801B3E60; // type:function size:0x40 -RoomManager__somethingFadeInRelated = .text:0x801B3EA0; // type:function size:0x40 +fadeIn__8dStage_cFlUs = .text:0x801B3D00; // type:function size:0xA8 +fadeOut__8dStage_cFlUs = .text:0x801B3DB0; // type:function size:0xA8 +forceFadeOut__8dStage_cFv = .text:0x801B3E60; // type:function size:0x40 +forceFadeIn__8dStage_cFv = .text:0x801B3EA0; // type:function size:0x40 fn_801B3EE0 = .text:0x801B3EE0; // type:function size:0x3C fn_801B3F20 = .text:0x801B3F20; // type:function size:0x8 fn_801B3F30 = .text:0x801B3F30; // type:function size:0x8 -RoomManager__someCollisionThing = .text:0x801B3F40; // type:function size:0x90 +drawMap__8dStage_cFP6mMtx_ci = .text:0x801B3F40; // type:function size:0x90 RoomManager__getRMPLForRoom = .text:0x801B3FD0; // type:function size:0x34 -RoomManager__getDungeonflagAndShiftForRoomVisit = .text:0x801B4010; // type:function size:0x34 -hasVisitedRoomId__11RoomManagerCFl = .text:0x801B4050; // type:function size:0x8C -RoomManager__setRoomVisited = .text:0x801B40E0; // type:function size:0x12C -RoomManager__createRoom = .text:0x801B4210; // type:function size:0x28 -RoomManager__createLytSeekerStone = .text:0x801B4240; // type:function size:0x68 -getRoom__11RoomManagerFi = .text:0x801B42B0; // type:function size:0x20 -bindStageResToFile__11RoomManagerFPQ34nw4r3g3d7ResFile = .text:0x801B42D0; // type:function size:0x50 -bindSkyCmnToResFile__11RoomManagerFPQ34nw4r3g3d7ResFile = .text:0x801B4320; // type:function size:0x54 -RoomManager__getMA0AnmTexSrt = .text:0x801B4380; // type:function size:0xA0 -getMA0IndirectSrt__11RoomManagerFPQ34nw4r3g3d12ResAnmTexSrtRCQ34nw4r3g3d6ResMdl = .text:0x801B4420; // type:function size:0x9C -changeLoadedEntities__11RoomManagerFP11RoomManagerUlb = .text:0x801B44C0; // type:function size:0x50 +getFlagPositionForRoomVisit__FiPUsPUs = .text:0x801B4010; // type:function size:0x34 +hasVisitedRoom__8dStage_cCFi = .text:0x801B4050; // type:function size:0x8C +setRoomVisited__8dStage_cFi = .text:0x801B40E0; // type:function size:0x12C +createRoom__8dStage_cFib = .text:0x801B4210; // type:function size:0x28 +createLytSeekerStone__8dStage_cFv = .text:0x801B4240; // type:function size:0x68 +getParentForRoom__8dStage_cFl = .text:0x801B42B0; // type:function size:0x20 +bindStageResToFile__8dStage_cFPQ34nw4r3g3d7ResFile = .text:0x801B42D0; // type:function size:0x50 +bindSkyCmnToResFile__8dStage_cFPQ34nw4r3g3d7ResFile = .text:0x801B4320; // type:function size:0x54 +getMA0AnmTexSrt__8dStage_cFPQ34nw4r3g3d12ResAnmTexSrtPCc = .text:0x801B4380; // type:function size:0xA0 +getMA0IndirectSrt__8dStage_cFPQ34nw4r3g3d12ResAnmTexSrtRCQ34nw4r3g3d6ResMdl = .text:0x801B4420; // type:function size:0x9C +changeLoadedEntities__8dStage_cFUlb = .text:0x801B44C0; // type:function size:0x50 RoomManager__checkRoomFlag = .text:0x801B4510; // type:function size:0x3C RoomManager__checkEnemyDefeatFlag = .text:0x801B4550; // type:function size:0x6C fn_801B45C0 = .text:0x801B45C0; // type:function size:0xAC -RoomManager__RoomTable__ctor = .text:0x801B4670; // type:function size:0x110 -RoomManager__MapRelated__init = .text:0x801B4780; // type:function size:0x180 -fn_801B4900 = .text:0x801B4900; // type:function size:0x44 -fn_801B4950 = .text:0x801B4950; // type:function size:0x40 -fn_801B4990 = .text:0x801B4990; // type:function size:0x84 +__ct__12dRoomTable_cFv = .text:0x801B4670; // type:function size:0x110 +__ct__10MapRelatedFv = .text:0x801B4780; // type:function size:0x180 +__ct__Q210MapRelated5ChildFv = .text:0x801B4900; // type:function size:0x44 +__dt__Q210MapRelated5ChildFv = .text:0x801B4950; // type:function size:0x40 +__dt__10MapRelatedFv = .text:0x801B4990; // type:function size:0x84 fn_801B4A20 = .text:0x801B4A20; // type:function size:0xBC fn_801B4AE0 = .text:0x801B4AE0; // type:function size:0x44 fn_801B4B30 = .text:0x801B4B30; // type:function size:0x24 @@ -11014,13 +11014,13 @@ fn_801B5180 = .text:0x801B5180; // type:function size:0x7F0 fn_801B5970 = .text:0x801B5970; // type:function size:0x38 fn_801B59B0 = .text:0x801B59B0; // type:function size:0x58 fn_801B5A10 = .text:0x801B5A10; // type:function size:0x58 -RoomManager__dtor = .text:0x801B5A70; // type:function size:0x94 -fn_801B5B10 = .text:0x801B5B10; // type:function size:0x30 -fn_801B5B40 = .text:0x801B5B40; // type:function size:0xC -fn_801B5B50 = .text:0x801B5B50; // type:function size:0x10 -fn_801B5B60 = .text:0x801B5B60; // type:function size:0x2C +__dt__8dStage_cFv = .text:0x801B5A70; // type:function size:0x94 +callPhase__18sFPhase<8dStage_c>Fv = .text:0x801B5B10; // type:function size:0x30 +onReset__18sFPhase<8dStage_c>Fv = .text:0x801B5B40; // type:function size:0xC +nextPhase__18sFPhase<8dStage_c>Fv = .text:0x801B5B50; // type:function size:0x10 +hasReachedEnd__18sFPhase<8dStage_c>CFv = .text:0x801B5B60; // type:function size:0x2C fn_801B5B90 = .text:0x801B5B90; // type:function size:0x10 -fn_801B5BA0 = .text:0x801B5BA0; // type:function size:0x28 +__sinit_\d_stage_cpp = .text:0x801B5BA0; // type:function size:0x28 AcStageSelect__ctor = .text:0x801B5BD0; // type:function size:0x4C AcStageSelect__dtor = .text:0x801B5C20; // type:function size:0x5C dRoom_c_classInit__Fv = .text:0x801B5C80; // type:function size:0x17C @@ -34180,18 +34180,18 @@ lbl_8052DE68 = .data:0x8052DE68; // type:object size:0x10 GlobalMessageRelatedContext__vtable = .data:0x8052DE78; // type:object size:0x4C ActorEventFlowManager__vtable = .data:0x8052DEC4; // type:object size:0x78 g_profile_STAGE = .data:0x8052DF40; // type:object size:0xC -actorInit.defaultFlags = .data:0x8052DF4C; // type:object size:0x24 +sCallbacks__8dStage_c = .data:0x8052DF4C; // type:object size:0x24 lbl_8052DF70 = .data:0x8052DF70; // type:object size:0x10 lbl_8052DF80 = .data:0x8052DF80; // type:object size:0x10 lbl_8052DF90 = .data:0x8052DF90; // type:object size:0x10 data:string lbl_8052DFA0 = .data:0x8052DFA0; // type:object size:0x10 data:string -lbl_8052DFB0 = .data:0x8052DFB0; // type:object size:0xC data:4byte +sMatsToTry = .data:0x8052DFB0; // type:object size:0xC data:4byte lbl_8052DFBC = .data:0x8052DFBC; // type:object size:0x1C lbl_8052DFD8 = .data:0x8052DFD8; // type:object size:0x1C -RoomManager__vtable = .data:0x8052DFF4; // type:object size:0x4C +__vt__8dStage_c = .data:0x8052DFF4; // type:object size:0x4C lbl_8052E040 = .data:0x8052E040; // type:object size:0xC -RoomManager__RoomTable__vtable = .data:0x8052E04C; // type:object size:0xC -lbl_8052E058 = .data:0x8052E058; // type:object size:0x24 +__vt__12dRoomTable_c = .data:0x8052E04C; // type:object size:0xC +__vt__18sFPhase<8dStage_c> = .data:0x8052E058; // type:object size:0x24 g_profile_STAGE_SELECT = .data:0x8052E080; // type:object size:0xC AcStageSelect__vtable = .data:0x8052E08C; // type:object size:0x4C g_profile_ROOM = .data:0x8052E0D8; // type:object size:0xC @@ -40234,7 +40234,7 @@ lbl_80575749 = .sbss:0x80575749; // type:object size:0x7 data:byte CURRENT_LANGUAGE_STRING = .sbss:0x80575750; // type:object size:0x8 data:byte lbl_80575758 = .sbss:0x80575758; // type:object size:0x4 data:4byte lbl_8057575C = .sbss:0x8057575C; // type:object size:0x4 data:4byte -m_Instance__11RoomManager = .sbss:0x80575760; // type:object size:0x4 data:4byte +sInstance__8dStage_c = .sbss:0x80575760; // type:object size:0x4 data:4byte lbl_80575764 = .sbss:0x80575764; // type:object size:0x1 data:byte lbl_80575768 = .sbss:0x80575768; // type:object size:0x8 data:byte lbl_80575770 = .sbss:0x80575770; // type:object size:0x4 data:float diff --git a/configure.py b/configure.py index 5b1adfc9..be60b1f5 100644 --- a/configure.py +++ b/configure.py @@ -340,7 +340,7 @@ config.libs = [ Object(Matching, "d/d_heap.cpp"), Object(Matching, "d/d_rawarchive.cpp"), Object(Matching, "d/d_scene.cpp"), - Object(NonMatching, "d/d_stage.cpp"), + Object(NonMatching, "d/d_stage_parse.cpp"), Object(NonMatching, "d/d_sys.cpp"), Object(NonMatching, "toBeSorted/sound_info.cpp"), Object(Matching, "toBeSorted/arc_callback_handler.cpp"), @@ -429,6 +429,7 @@ config.libs = [ Object(Matching, "d/lyt/d_lyt_fader.cpp"), Object(Matching, "d/lyt/d_screen_fader.cpp"), Object(NonMatching, "d/a/d_a_insect.cpp"), + Object(NonMatching, "d/d_stage.cpp"), Object(NonMatching, "d/d_room.cpp"), Object(NonMatching, "d/d_cs_base.cpp"), Object(NonMatching, "d/d_cs_game.cpp"), diff --git a/include/d/d_bzs_types.h b/include/d/d_bzs_types.h new file mode 100644 index 00000000..afba4360 --- /dev/null +++ b/include/d/d_bzs_types.h @@ -0,0 +1,163 @@ +#ifndef D_STAGE_TYPES_H +#define D_STAGE_TYPES_H + +#include "common.h" +#include "m/m_angle.h" +#include "m/m_vec.h" + + +// Size 0x20 +struct AREA { + /* 0x00 */ mVec3_c mPos; + /* 0x0C */ mVec3_c mScale; + /* 0x18 */ mAng mAngleY; + /* 0x1A */ mAng mAngleLink; + /* 0x1C */ u8 field_0x1C; +}; + +// TODO: double check, copied from ss-tools +// Size 0x28 +struct BPNT { + /* 0x00 */ mVec3_c position1; + /* 0x0C */ mVec3_c position2; + /* 0x18 */ mVec3_c position3; + /* 0x24 */ u8 _0x24[4]; +}; + +// TODO: double check, copied from ss-tools +// Size 0x2C +struct CAM { + /* 0x00 */ u8 _0x00[4]; + /* 0x04 */ mVec3_c position; + /* 0x10 */ f32 angle; + /* 0x14 */ u8 _0x14[8]; + /* 0x1C */ char name[16]; +}; + +// Size 0x38 +struct EVNT { + /* 0x00 */ u8 _0x00[2]; + /* 0x02 */ u16 storyFlag1; + /* 0x04 */ u16 storyFlag2; + /* 0x06 */ u8 _0x06[3]; + /* 0x09 */ u8 exitId; + /* 0x0A */ u8 _0x0A[3]; + /* 0x0D */ u8 skipEvent; + /* 0x0E */ u8 _0x0E[1]; + /* 0x0F */ u8 sceneFlag1; + /* 0x10 */ u8 sceneFlag2; + /* 0x11 */ u8 skipFlag; + /* 0x12 */ u8 _0x12[2]; + /* 0x14 */ u16 item; + /* 0x16 */ u16 _0x16[2]; + /* 0x18 */ char name[32]; +}; + +// Size 0x04 +struct LYLT { + /* 0x0 */ u8 layer; + /* 0x1 */ u8 demoHigh; + /* 0x2 */ u8 demoLow; + /* 0x3 */ u8 dummy; +}; + +// Size 0x04 +struct LYSE { + /* 0x0 */ u16 storyFlag; + /* 0x2 */ u8 night; + /* 0x3 */ u8 layer; +}; + +// Size 0x24 +struct OBJ { + /* 0x00 */ u32 params1; + /* 0x04 */ u32 params2; + /* 0x08 */ mVec3_c position; + /* 0x14 */ mAng3_c angle; + /* 0x1A */ u16 id; + /* 0x1C */ char name[8]; +}; + +// Size 0xC +struct PATH { + /* 0x00 */ u8 field_0x00; + /* 0x01 */ u8 field_0x01; + /* 0x02 */ u16 pointStartIndex; + /* 0x04 */ u16 pointCount; + /* 0x06 */ u8 _0x06[4]; + /* 0x0A */ u8 firstBitIsWrapAround; + /* 0x0B */ u8 _0x0B[1]; +}; + +// Size 0x24 +struct PCAM { + /* 0x00 */ mVec3_c position1; + /* 0x0C */ mVec3_c position2; + /* 0x18 */ f32 field_0x18; + /* 0x1C */ f32 field_0x1C; + /* 0x20 */ u8 id; + /* 0x21 */ u8 _0x21[3]; +}; + +// Size 0x18 +struct PLY { + /* 0x00 */ u16 storyFlag; + /* 0x02 */ u8 playCutscene; + /* 0x03 */ u8 _0x03[1]; + /* 0x04 */ mVec3_c position; + /* 0x10 */ mAng3_c angle; + /* 0x16 */ u16 entranceId; +}; + +// Size 0x10 +struct PNT { + /* 0x00 */ mVec3_c position; + /* 0x0C */ u8 _0x0C[4]; +}; + +// Size 0x4 +struct RMPL { + /* 0x0 */ u8 roomId; + /* 0x1 */ u8 count; + /* 0x2 */ u16 offset; +}; + +// Size 0x28 +struct SCEN { + /* 0x00 */ char name[32]; + /* 0x20 */ u8 room; + /* 0x21 */ u8 layer; + /* 0x22 */ u8 entrance; + /* 0x23 */ u8 night; + /* 0x24 */ u8 transitionType; + /* 0x25 */ u8 transitionFadeFrames; + /* 0x26 */ u8 zero; + /* 0x27 */ u8 savePrompt; +}; + +// Size 0x30 +struct SOBJ { + /* 0x00 */ u32 params1; + /* 0x04 */ u32 params2; + /* 0x08 */ mVec3_c position; + /* 0x14 */ mVec3_c scale; + /* 0x20 */ mAng3_c angle; + /* 0x26 */ u16 id; + /* 0x28 */ char name[8]; +}; + +// Size 0x14 +struct STIF { + /* 0x00 */ f32 field_0x00; + /* 0x04 */ f32 field_0x04; + /* 0x08 */ f32 defaultCullingDistance; + /* 0x0C */ u16 flagIndex; + /* 0x0E */ u8 areaType; + /* 0x0F */ u8 field_0x0F; + /* 0x10 */ u8 field_0x10; + /* 0x11 */ u8 field_0x11; + /* 0x12 */ u8 mapNameId; + /* 0x13 */ u8 field_0x13; +}; + +#endif diff --git a/include/d/d_fader.h b/include/d/d_fader.h index 24e2cd39..43912630 100644 --- a/include/d/d_fader.h +++ b/include/d/d_fader.h @@ -59,6 +59,10 @@ public: mFadeInFrame = frame; } + void setFadeOutFrame(u16 frame) { + mFadeOutFrame = frame; + } + private: /* 0x08 */ mColorFader_c *mpColorFader; /* 0x0C */ dLytFader_c *mpLytFader; diff --git a/include/d/d_room.h b/include/d/d_room.h index 7af97952..2519dc01 100644 --- a/include/d/d_room.h +++ b/include/d/d_room.h @@ -5,6 +5,7 @@ #include "d/a/d_a_base.h" #include "d/col/bg/d_bg_w_kcol.h" #include "d/d_base.h" +#include "d/d_bzs_types.h" #include "m/m3d/m_anmmatclr.h" #include "m/m3d/m_anmtexpat.h" #include "m/m3d/m_anmtexsrt.h" @@ -115,13 +116,13 @@ public: dRoom_c() : mStateMgr(*this, sStateID::null), field_0x15C(nullptr), - SCEN(nullptr), - PLY(nullptr), - CAM(nullptr), - EVNT(nullptr), - PATH(nullptr), - PNT(nullptr), - BPNT(nullptr), + scen(nullptr), + ply(nullptr), + cam(nullptr), + evnt(nullptr), + path(nullptr), + pnt(nullptr), + bpnt(nullptr), AREA(nullptr), unkCount(0), scenCount(0), @@ -175,17 +176,17 @@ private: /* 0x4E0 */ STATE_MGR_DECLARE(dRoom_c); /* 0x51C */ void *field_0x15C; - /* 0x520 */ void *SCEN; - /* 0x524 */ void *PLY; - /* 0x528 */ void *CAM; - /* 0x52C */ void *EVNT; - /* 0x530 */ void *PATH; - /* 0x534 */ void *PNT; - /* 0x538 */ void *BPNT; - /* 0x53C */ void *SPTH; + /* 0x520 */ SCEN *scen; + /* 0x524 */ PLY *ply; + /* 0x528 */ CAM *cam; + /* 0x52C */ EVNT *evnt; + /* 0x530 */ PATH *path; + /* 0x534 */ PNT *pnt; + /* 0x538 */ BPNT *bpnt; + /* 0x53C */ PATH *spth; /* 0x540 */ void *field_0x540; /* 0x544 */ void *field_0x544; - /* 0x548 */ void *AREA; + /* 0x548 */ AREA *AREA; /* 0x54C */ u16 unkCount; /* 0x54E */ u16 scenCount; /* 0x550 */ u16 plyCount; diff --git a/include/d/d_sc_game.h b/include/d/d_sc_game.h index 0b002f89..1a948eb9 100644 --- a/include/d/d_sc_game.h +++ b/include/d/d_sc_game.h @@ -152,6 +152,10 @@ public: void clearSpawnInfo(); const SpawnInfoExt &getSpawnInfo() const; + static void resetUpdateFrameCount() { + sUpdateFrameCount = 0; + } + protected: static u32 sUpdateFrameCount; static u8 sCurrentLayer; diff --git a/include/d/d_stage.h b/include/d/d_stage.h new file mode 100644 index 00000000..da4bf0ee --- /dev/null +++ b/include/d/d_stage.h @@ -0,0 +1,174 @@ +#ifndef D_STAGE_H +#define D_STAGE_H + +#include "common.h" +#include "d/d_base.h" +#include "d/d_fader.h" +#include "d/d_room.h" +#include "m/m_allocator.h" +#include "m/m_mtx.h" +#include "m/m_vec.h" +#include "s/s_FPhase.h" + +#define MAX_ROOM_NUMBER 64 + +class dRoomTable_c { +public: + /* 801b4670 */ dRoomTable_c(); + virtual ~dRoomTable_c() {} + + void setRoom(int roomid, dRoom_c *room) { + mRooms[roomid] = room; + } + + dRoom_c *getRoom(s32 idx) { + return mRooms[idx]; + } + +private: + dRoom_c *mRooms[MAX_ROOM_NUMBER - 1]; +}; + +class EggScreenEffectBlur { +public: + EggScreenEffectBlur(); + ~EggScreenEffectBlur(); + +private: + u8 _0x00[0x38 - 0x00]; +}; + +class EggPostEffectBlur { +public: + EggPostEffectBlur(); + ~EggPostEffectBlur() {} + + void setField0x30(f32 val) { + field_0x30 = val; + } + +private: + u8 _0x00[0x30 - 0x00]; + f32 field_0x30; + u8 _0x03[0x78 - 0x34]; +}; + +class MapRelated { +friend class dStage_c; + struct Child { + Child() : a(mVec3_c::Zero), b(mVec3_c::Zero), c(false) {} + ~Child() {} + mVec3_c a; + mVec3_c b; + bool c; + }; + +public: + MapRelated(); + ~MapRelated(); + /* 0x000 */ mHeapAllocator_c mAllocator; + /* 0x01C */ Child mChildren[8]; + /* 0x0FC */ mVec3_c field_0x0FC; + /* 0x108 */ f32 field_0x108; + /* 0x10C */ f32 field_0x10C; + /* 0x110 */ f32 field_0x110; + /* 0x114 */ f32 field_0x114; + /* 0x118 */ f32 field_0x118; + /* 0x11C */ f32 field_0x11C; + /* 0x120 */ f32 field_0x120; + /* 0x124 */ f32 field_0x124; + /* 0x128 */ f32 field_0x128; + /* 0x12C */ f32 field_0x12C; + /* 0x130 */ EggScreenEffectBlur mScreenEffect; + /* 0x168 */ EggPostEffectBlur mPostEffect; + /* 0x1E0 */ u32 field_0x1E0; + /* 0x1E4 */ u16 field_0x1E4; + /* 0x1E6 */ u16 field_0x1E6; + /* 0x1E8 */ u8 field_0x1E8; + /* 0x1E9 */ u8 field_0x1E9; + /* 0x1EA */ s8 field_0x1EA; + /* 0x1EB */ u8 field_0x1EB; + /* 0x1EC */ u8 field_0x1EC; + /* 0x1ED */ u8 field_0x1ED; + /* 0x1EE */ u8 field_0x1EE; + /* 0x1EF */ u8 field_0x1EF; + /* 0x1F0 */ u8 field_0x1F0; + +public: + /* 801b4780 */ void init(MapRelated *); + /* 801b4900 */ void fn_801b4900(); + void fn_801B4B80(u32 mapParams, const mVec3_c ¢er, const mVec3_c &size); + void fn_801B4C70(const mVec3_c &); + void fn_801B50C0(s32); +}; + +// OBJ NAME: STAGE +// Ghidra: RoomManager +// size: 0x239c +// vtable: 8052dff4 +class dStage_c : public dBase_c { +public: + dStage_c(); + virtual ~dStage_c() { + sInstance = nullptr; + } + + int create() override; + int doDelete() override; + int execute() override; + int draw() override; + void deleteReady() override; + + void drawMap(mMtx_c *mtx, int); + dRoom_c *getRoom(s32 idx); + void setRoom(int roomid, dRoom_c *room); + + bool fadeIn(s32 fadeType, u16 frames); + bool fadeOut(s32 fadeType, u16 frames); + + void forceFadeIn(); + void forceFadeOut(); + + bool hasVisitedRoom(int roomid) const; + void setRoomVisited(int roomid); + + + static void bindStageResToFile(nw4r::g3d::ResFile *file); + static void bindSkyCmnToResFile(nw4r::g3d::ResFile *file); + static bool getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *, const char *matName); + static bool getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *, const nw4r::g3d::ResMdl &mdl); + + /** Returns stage if idx == -1, otherwise room */ + static dBase_c *getParentForRoom(s32 idx); + + void changeLoadedEntities(u32 index_shift, bool set); + + static dStage_c *GetInstance() { + return sInstance; + } + + u8 getCurrRoomId() const { + return curr_room_id; + } + +private: + dRoom_c *createRoom(int roomid, bool flag0x40); + void createLytSeekerStone(); + + sFPhaseBase::sFPhaseState createRooms(); + sFPhaseBase::sFPhaseState waitForRooms(); + + static sFPhase::phaseCallback sCallbacks[]; + + /* 0x0068 */ sFPhase mPhase; + /* 0x007C */ dRoomTable_c rooms; + /* 0x017C */ dFader_c mFader; + /* 0x01A0 */ MapRelated mapRelated; + /* 0x0394 */ u8 _0x394[0x39C - 0x394]; + /* 0x039C */ u32 loaded_entities[2047]; + /* 0x2398 */ u8 curr_room_id; + + /* 80575760 */ static dStage_c *sInstance; +}; + +#endif diff --git a/include/d/flag/sceneflag_manager.h b/include/d/flag/sceneflag_manager.h index d1c8d98f..2d6e6000 100644 --- a/include/d/flag/sceneflag_manager.h +++ b/include/d/flag/sceneflag_manager.h @@ -48,7 +48,7 @@ public: } u16 checkFlag(u16 roomId, u16 flag); bool checkSceneflagGlobal(u16 sceneIdx, u16 flag); - bool checkTempOrSceneflag(u16 flag); + u16 checkTempOrSceneflag(u16 flag); u16 checkUncommittedFlag(u16 roomId, u16 flag); void setZoneflag(u16 roomId, u16 flag); void setFlag(u16 roomId, u16 flag); diff --git a/include/m/m_fader.h b/include/m/m_fader.h index 68509fef..1d61c0ef 100644 --- a/include/m/m_fader.h +++ b/include/m/m_fader.h @@ -8,14 +8,18 @@ public: void draw(); bool setFader(mFaderBase_c *fader); - bool isStatus(mFaderBase_c::EStatus status) { + bool isStatus(mFaderBase_c::EStatus status) const { return mpFader->getStatus() == status; } - bool isNotStatus(mFaderBase_c::EStatus status) { + bool isNotStatus(mFaderBase_c::EStatus status) const { return isStatus(status) != true; } + mFaderBase_c::EStatus getStatus() const { + return mpFader->getStatus(); + } + void setStatus(mFaderBase_c::EStatus status) { mpFader->setStatus(status); } diff --git a/include/nw4r/g3d/res/g3d_resmat.h b/include/nw4r/g3d/res/g3d_resmat.h index dba3bf4e..883ab107 100644 --- a/include/nw4r/g3d/res/g3d_resmat.h +++ b/include/nw4r/g3d/res/g3d_resmat.h @@ -565,6 +565,10 @@ public: return ResTexPlttInfo(&pData[id]); } + const char *GetName() const { + return ofs_to_ptr(ref().name); + } + ResMatDLData *GetResMatDLData() { return ofs_to_ptr(ref().toResMatDLData); } diff --git a/include/toBeSorted/area_utils.h b/include/toBeSorted/area_utils.h index d73cb218..5a38ba07 100644 --- a/include/toBeSorted/area_utils.h +++ b/include/toBeSorted/area_utils.h @@ -1,16 +1,8 @@ #ifndef AREA_UTILS_H #define AREA_UTILS_H -#include "m/m_angle.h" #include "m/m_vec.h" - -struct AREA { - /* 0x00 */ mVec3_c mPos; - /* 0x0C */ mVec3_c mScale; - /* 0x18 */ mAng mAngleY; - /* 0x1A */ mAng mAngleLink; - /* 0x1C */ u8 field_0x1C; -}; +#include "d/d_bzs_types.h" /* 800a9b00 */ bool checkPosInArea(AREA **area, const mVec3_c &pos); /* 800a9bd0 */ AREA *getAreaForIndexInRoom(s32 areaIndex, s32 roomId); diff --git a/include/toBeSorted/event_manager.h b/include/toBeSorted/event_manager.h index bd98a1c9..00f38cf3 100644 --- a/include/toBeSorted/event_manager.h +++ b/include/toBeSorted/event_manager.h @@ -6,6 +6,8 @@ #include "sized_string.h" #include "toBeSorted/event.h" +#include + class dAcBase_c; class EventManager { diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 3c1c9c87..620d125a 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -10,4 +10,7 @@ extern "C" void fn_8035E310(void *); extern "C" void *ENEMY_SOUND_MGR; extern "C" void fn_80362150(void *, u16); +extern "C" void *ENEMY_BGM_RELATED_MGR; +extern "C" void fn_80384570(void *, bool); + #endif diff --git a/include/toBeSorted/room_manager.h b/include/toBeSorted/room_manager.h deleted file mode 100644 index 3353e826..00000000 --- a/include/toBeSorted/room_manager.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef ROOM_MANAGER_H -#define ROOM_MANAGER_H - -#include "common.h" -#include "d/d_base.h" -#include "d/d_room.h" -#include "m/m_allocator.h" -#include "m/types_m.h" -#include "nw4r/g3d/res/g3d_resmdl.h" - -#define MAX_ROOM_NUMBER 64 - -class dRoomTable { - /* 801b4670 */ dRoomTable(dRoomTable *roomTable); - virtual ~dRoomTable(); - dRoom_c *rooms[MAX_ROOM_NUMBER - 1]; -}; - -class MapRelated { -public: - mAllocator_c allocator; - char unk[472]; - -public: - /* 801b4780 */ void init(MapRelated *); - /* 801b4900 */ void fn_801b4900(); -}; - -// OBJ NAME: STAGE -// Ghidra: RoomManager -// size: 0x239c -// vtable: 8052dff4 -class RoomManager : public dBase_c { -public: - /* 0068 */ char field_0x68[0x7C - 0x68]; - /* 007C */ dRoomTable rooms; - /* 017c */ char fader[0x1a0 - 0x174]; // size unk - /* 01a0 */ MapRelated mapRelated; - /* 039c */ u32 loaded_entities[2047]; - /* 2398 */ u8 curr_room_id; - -public: - /* 80575760 */ static RoomManager *m_Instance; - -public: - /* 801b3970 */ dRoom_c *GetRoomByIndex(int roomid); - /* 801b42b0 */ static dRoom_c *getRoom(int roomid); - /* 801b42d0 */ static void bindStageResToFile(nw4r::g3d::ResFile *); - /* 801b4320 */ static void bindSkyCmnToResFile(nw4r::g3d::ResFile *); - /* 801b4380 */ static bool getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *, char *); - /* 801b4420 */ static bool getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *, const nw4r::g3d::ResMdl &mdl); - /* 801b44c0 */ static void changeLoadedEntities(RoomManager *mgr, u32 index_shift, bool set); - /* 801b4510 */ static u32 checkRoomFlag(RoomManager *mgr, u32 flag); - /* 801b4550 */ static bool checkEnemyDefeatFlag(RoomManager *mgr, u32 flag); - /* 801b45c0 */ static bool fn_801B45C0(RoomManager *mgr /* plus others */); - /* 801b6c60 */ bool hasVisitedRoomId(s32 roomid) const; - - void setRoom(int roomid, dRoom_c *room); -}; - -#endif diff --git a/include/toBeSorted/time_area_mgr.h b/include/toBeSorted/time_area_mgr.h index c4cde66d..507abd11 100644 --- a/include/toBeSorted/time_area_mgr.h +++ b/include/toBeSorted/time_area_mgr.h @@ -69,6 +69,10 @@ public: return field_0x78; } + void setField0x78(bool val) { + field_0x78 = val; + } + void setField0x7A(bool val) { field_0x7A = val; } diff --git a/src/REL/d/a/obj/d_a_obj_appear_bridge.cpp b/src/REL/d/a/obj/d_a_obj_appear_bridge.cpp index dc0e8296..1111db14 100644 --- a/src/REL/d/a/obj/d_a_obj_appear_bridge.cpp +++ b/src/REL/d/a/obj/d_a_obj_appear_bridge.cpp @@ -2,9 +2,9 @@ #include "d/a/d_a_player.h" #include "d/col/bg/d_bg_s.h" +#include "d/d_stage.h" #include "nw4r/types_nw4r.h" #include "toBeSorted/area_utils.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_APPEAR_BRIDGE, dAcOappearBridge_c, fProfile::OBJ_APPEAR_BRIDGE, 0x01FC, 0, 6); @@ -18,7 +18,7 @@ STATE_DEFINE(dAcOappearBridge_c, Disappear); bool dAcOappearBridge_c::createHeap() { mResFile = nw4r::g3d::ResFile(getOarcResFile("TongueStage")); - RoomManager::bindStageResToFile(&mResFile); + dStage_c::bindStageResToFile(&mResFile); nw4r::g3d::ResMdl mdl = mResFile.GetResMdl("TongueStage"); TRY_CREATE(mModel.create(mdl, &heap_allocator, 0x128)); nw4r::g3d::ResAnmTexSrt srt = mResFile.GetResAnmTexSrt("TongueStage"); diff --git a/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp b/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp index 1b727ce1..da0f38e9 100644 --- a/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp +++ b/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp @@ -1,9 +1,9 @@ #include "d/a/obj/d_a_obj_bamboo_island.h" #include "d/col/bg/d_bg_s.h" +#include "d/d_stage.h" #include "d/flag/storyflag_manager.h" #include "nw4r/g3d/res/g3d_resfile.h" -#include "toBeSorted/room_manager.h" const f32 dAcObambooIsland_c::unusedFloat1 = 100000.0f; const f32 dAcObambooIsland_c::unusedFloat2 = 0.0f; @@ -23,8 +23,8 @@ void dAcObambooIsland_c::rideCallback(dBgW *unknown, dAcObjBase_c *actor, dAcObj bool dAcObambooIsland_c::createHeap() { mBrres = nw4r::g3d::ResFile(getOarcResFile("IslBamb")); - RoomManager::bindStageResToFile(&mBrres); - RoomManager::bindSkyCmnToResFile(&mBrres); + dStage_c::bindStageResToFile(&mBrres); + dStage_c::bindSkyCmnToResFile(&mBrres); for (int i = 0; i < 2; i++) { nw4r::g3d::ResMdl mdl = mBrres.GetResMdl(sBambooIslandNames[i]); TRY_CREATE(mModels[i].create(mdl, &heap_allocator, 0x120)); diff --git a/src/REL/d/a/obj/d_a_obj_island_nusi.cpp b/src/REL/d/a/obj/d_a_obj_island_nusi.cpp index c4ee7b25..0177af16 100644 --- a/src/REL/d/a/obj/d_a_obj_island_nusi.cpp +++ b/src/REL/d/a/obj/d_a_obj_island_nusi.cpp @@ -2,6 +2,7 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/col/bg/d_bg_s.h" +#include "d/d_stage.h" #include "d/flag/storyflag_manager.h" #include "f/f_base.h" #include "m/m_vec.h" @@ -10,7 +11,6 @@ #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" #include "nw4r/g3d/res/g3d_resnode.h" -#include "toBeSorted/room_manager.h" const f32 dAcOislandNusi_c::someFloat = 100000.0f; @@ -26,8 +26,8 @@ STATE_DEFINE(dAcOislandNusi_c, NusiFight); bool dAcOislandNusi_c::createHeap() { mRes = nw4r::g3d::ResFile(getOarcResFile("IslNusi")); - RoomManager::bindStageResToFile(&mRes); - RoomManager::bindSkyCmnToResFile(&mRes); + dStage_c::bindStageResToFile(&mRes); + dStage_c::bindSkyCmnToResFile(&mRes); for (int i = 0; i < 2; i++) { nw4r::g3d::ResMdl mdl = mRes.GetResMdl(sMdlNames[i]); TRY_CREATE(mMdls[i].create(mdl, &heap_allocator, 0x160)); diff --git a/src/REL/d/a/obj/d_a_obj_lava_F200.cpp b/src/REL/d/a/obj/d_a_obj_lava_F200.cpp index 068fd747..1a9311bc 100644 --- a/src/REL/d/a/obj/d_a_obj_lava_F200.cpp +++ b/src/REL/d/a/obj/d_a_obj_lava_F200.cpp @@ -1,13 +1,13 @@ #include "d/a/obj/d_a_obj_lava_F200.h" +#include "d/d_stage.h" #include "nw4r/g3d/res/g3d_resfile.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_LAVA_F200, dAcOlavaF200_c, fProfile::OBJ_LAVA_F200, 0x0214, 0, 0); bool dAcOlavaF200_c::createHeap() { mBrres = nw4r::g3d::ResFile(getOarcResFile("LavaF200")); - RoomManager::bindStageResToFile(&mBrres); + dStage_c::bindStageResToFile(&mBrres); nw4r::g3d::ResMdl mdl0 = mBrres.GetResMdl("LavaF200"); TRY_CREATE(mModels[0].create(mdl0, &heap_allocator, 0x32C)); diff --git a/src/REL/d/a/obj/d_a_obj_megami_island.cpp b/src/REL/d/a/obj/d_a_obj_megami_island.cpp index e8df429f..529e1f8a 100644 --- a/src/REL/d/a/obj/d_a_obj_megami_island.cpp +++ b/src/REL/d/a/obj/d_a_obj_megami_island.cpp @@ -3,12 +3,12 @@ #include "common.h" #include "d/a/obj/d_a_obj_base.h" #include "d/col/bg/d_bg_s.h" +#include "d/d_stage.h" #include "d/flag/storyflag_manager.h" #include "f/f_base.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resanmtexsrt.h" #include "nw4r/g3d/res/g3d_resmdl.h" -#include "toBeSorted/room_manager.h" static const char *const sResFiles[] = { "F000Megami", @@ -46,8 +46,8 @@ bool dAcOmegamiIsland_c::createHeap() { mVariant = getVariant(); mRes = nw4r::g3d::ResFile(getOarcResFile(sResFiles[mVariant])); - RoomManager::bindStageResToFile(&mRes); - RoomManager::bindSkyCmnToResFile(&mRes); + dStage_c::bindStageResToFile(&mRes); + dStage_c::bindSkyCmnToResFile(&mRes); nw4r::g3d::ResMdl mdl1 = mRes.GetResMdl(sMdl1[mVariant]); TRY_CREATE(mMdls[0].create(mdl1, &heap_allocator, 0x120)); diff --git a/src/REL/d/a/obj/d_a_obj_pool_cock.cpp b/src/REL/d/a/obj/d_a_obj_pool_cock.cpp index 3c786404..f52cd41e 100644 --- a/src/REL/d/a/obj/d_a_obj_pool_cock.cpp +++ b/src/REL/d/a/obj/d_a_obj_pool_cock.cpp @@ -1,9 +1,9 @@ #include "d/a/obj/d_a_obj_pool_cock.h" #include "d/a/obj/d_a_obj_vortex.h" +#include "d/d_stage.h" #include "d/flag/sceneflag_manager.h" #include "s/s_Math.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_POOL_COCK, dAcOPoolCock_c, fProfile::OBJ_POOL_COCK, 0x024D, 0, 7); @@ -11,7 +11,7 @@ STATE_DEFINE(dAcOPoolCock_c, Wait); bool dAcOPoolCock_c::createHeap() { mBrres = nw4r::g3d::ResFile(getOarcResFile("WaterD101")); - RoomManager::bindStageResToFile(&mBrres); + dStage_c::bindStageResToFile(&mBrres); nw4r::g3d::ResMdl mdl = mBrres.GetResMdl("PoolCockD101"); for (int i = 0; i < 2; i++) { TRY_CREATE(mModels[i].create(mdl, &heap_allocator, 0x120)); diff --git a/src/REL/d/a/obj/d_a_obj_sun_light.cpp b/src/REL/d/a/obj/d_a_obj_sun_light.cpp index 6f141c95..7441e083 100644 --- a/src/REL/d/a/obj/d_a_obj_sun_light.cpp +++ b/src/REL/d/a/obj/d_a_obj_sun_light.cpp @@ -1,9 +1,9 @@ #include "d/a/obj/d_a_obj_sun_light.h" #include "d/d_sc_game.h" +#include "d/d_stage.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "toBeSorted/arc_managers/current_stage_arc_manager.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_SUN_LIGHT, dAcOsunLight_c, fProfile::OBJ_SUN_LIGHT, 0x0219, 0, 3); @@ -11,8 +11,8 @@ STATE_DEFINE(dAcOsunLight_c, Wait); bool dAcOsunLight_c::createHeap() { mBrres = nw4r::g3d::ResFile(CurrentStageArcManager::sInstance->getData("g3d/stage.brres")); - RoomManager::bindStageResToFile(&mBrres); - RoomManager::bindSkyCmnToResFile(&mBrres); + dStage_c::bindStageResToFile(&mBrres); + dStage_c::bindSkyCmnToResFile(&mBrres); nw4r::g3d::ResMdl mdl = mBrres.GetResMdl("StageF000Light"); TRY_CREATE(mModel.create(mdl, &heap_allocator, 0x120)); nw4r::g3d::ResAnmTexSrt srt = mBrres.GetResAnmTexSrt("StageF000Light"); diff --git a/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp b/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp index 06411982..c5e741e2 100644 --- a/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp +++ b/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp @@ -4,12 +4,12 @@ #include "d/a/d_a_base.h" #include "d/a/obj/d_a_obj_tower_D101.h" #include "d/col/bg/d_bg_s_wtr_chk.h" +#include "d/d_stage.h" #include "f/f_base.h" #include "f/f_manager.h" #include "f/f_profile_name.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resmdl.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_TOWER_GEAR_D101, dAcOTowerGearD101_c, fProfile::OBJ_TOWER_GEAR_D101, 0x17E, 0, 7); @@ -20,7 +20,7 @@ extern "C" void fn_80067340(mVec3_c &, nw4r::g3d::ResMdl *, const char *); bool dAcOTowerGearD101_c::createHeap() { const char *name = "TowerGearD101"; mRes = nw4r::g3d::ResFile(getOarcResFile(name)); - RoomManager::bindStageResToFile(&mRes); + dStage_c::bindStageResToFile(&mRes); nw4r::g3d::ResMdl mdl = mRes.GetResMdl(name); if (!mMdl.create(mdl, &heap_allocator, 0x120, 1, nullptr)) { return false; diff --git a/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp b/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp index ddd7498a..5a1a4190 100644 --- a/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp +++ b/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp @@ -5,6 +5,7 @@ #include "d/a/d_a_player.h" #include "d/col/bg/d_bg_s.h" #include "d/col/bg/d_bg_w.h" +#include "d/d_stage.h" #include "d/flag/sceneflag_manager.h" #include "f/f_base.h" #include "m/m3d/m_fanm.h" @@ -17,7 +18,6 @@ #include "s/s_Math.h" #include "toBeSorted/actor_event.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_TOWER_HAND_D101, dAcOTowerHandD101_c, fProfile::OBJ_TOWER_HAND_D101, 0x180, 0, 6); @@ -108,7 +108,7 @@ bool dAcOTowerHandD101_c::createHeap() { if (!res.IsValid()) { return false; } - RoomManager::bindStageResToFile(&res); + dStage_c::bindStageResToFile(&res); if (direction == 1) { mMdl.getModel().setCullModeAll(GX_CULL_FRONT, false); } diff --git a/src/REL/d/a/obj/d_a_obj_uta_demo_pedest.cpp b/src/REL/d/a/obj/d_a_obj_uta_demo_pedest.cpp index 3545cb7f..3be5c7b3 100644 --- a/src/REL/d/a/obj/d_a_obj_uta_demo_pedest.cpp +++ b/src/REL/d/a/obj/d_a_obj_uta_demo_pedest.cpp @@ -1,12 +1,12 @@ #include "d/a/obj/d_a_obj_uta_demo_pedest.h" #include "d/a/obj/d_a_obj_base.h" +#include "d/d_stage.h" #include "f/f_base.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" #include "toBeSorted/arc_managers/current_stage_arc_manager.h" -#include "toBeSorted/room_manager.h" static const char *const sMdlNames[] = { "StageF010rPedest", @@ -25,8 +25,8 @@ bool dAcOutaDemoPedest_c::createHeap() { } mRes = nw4r::g3d::ResFile(CurrentStageArcManager::sInstance->getData("g3d/stage.brres")); - RoomManager::bindStageResToFile(&mRes); - RoomManager::bindSkyCmnToResFile(&mRes); + dStage_c::bindStageResToFile(&mRes); + dStage_c::bindSkyCmnToResFile(&mRes); nw4r::g3d::ResMdl mdl = mRes.GetResMdl(sMdlNames[mModelType]); TRY_CREATE(mMdl.create(mdl, &heap_allocator, 0x120)); diff --git a/src/REL/d/a/obj/d_a_obj_utajima.cpp b/src/REL/d/a/obj/d_a_obj_utajima.cpp index 09df9cfa..f7bd2ccf 100644 --- a/src/REL/d/a/obj/d_a_obj_utajima.cpp +++ b/src/REL/d/a/obj/d_a_obj_utajima.cpp @@ -4,8 +4,8 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/col/bg/d_bg_s.h" #include "d/col/c/c_m3d_g_aab.h" +#include "d/d_stage.h" #include "d/flag/storyflag_manager.h" -#include "toBeSorted/room_manager.h" static const char *const mMdlNames[] = { "IslSon", @@ -24,8 +24,8 @@ void dAcOutajima_c::rideCallback(dBgW *bg, dAcObjBase_c *o1, dAcObjBase_c *o2) { bool dAcOutajima_c::createHeap() { mRes = nw4r::g3d::ResFile(getOarcResFile("IslSon")); - RoomManager::bindStageResToFile(&mRes); - RoomManager::bindSkyCmnToResFile(&mRes); + dStage_c::bindStageResToFile(&mRes); + dStage_c::bindSkyCmnToResFile(&mRes); nw4r::g3d::ResMdl m(nullptr); diff --git a/src/REL/d/a/obj/d_a_obj_utajima_island.cpp b/src/REL/d/a/obj/d_a_obj_utajima_island.cpp index a85dfd6f..6ca9731a 100644 --- a/src/REL/d/a/obj/d_a_obj_utajima_island.cpp +++ b/src/REL/d/a/obj/d_a_obj_utajima_island.cpp @@ -4,13 +4,13 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/a/obj/d_a_obj_utajima_main_mecha.h" #include "d/col/bg/d_bg_s.h" +#include "d/d_stage.h" #include "f/f_base.h" #include "f/f_manager.h" #include "f/f_profile_name.h" #include "m/m_angle.h" #include "nw4r/g3d/res/g3d_resmdl.h" #include "s/s_Math.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_UTAJIMA_ISLAND, dAcOutajimaIsland_c, fProfile::OBJ_UTAJIMA_ISLAND, 0x1D2, 0, 6); @@ -25,8 +25,8 @@ const f32 dAcOutajimaIsland_c::floats[] = { bool dAcOutajimaIsland_c::createHeap() { mRes = nw4r::g3d::ResFile(getOarcResFile("IslPuzIslet00")); - RoomManager::bindStageResToFile(&mRes); - RoomManager::bindSkyCmnToResFile(&mRes); + dStage_c::bindStageResToFile(&mRes); + dStage_c::bindSkyCmnToResFile(&mRes); nw4r::g3d::ResMdl m = mRes.GetResMdl("IslPuzIslet00"); TRY_CREATE(mMdl.create(m, &heap_allocator, 0x120)); diff --git a/src/REL/d/a/obj/d_a_obj_utajima_lv2.cpp b/src/REL/d/a/obj/d_a_obj_utajima_lv2.cpp index 2c68945a..b8624e2e 100644 --- a/src/REL/d/a/obj/d_a_obj_utajima_lv2.cpp +++ b/src/REL/d/a/obj/d_a_obj_utajima_lv2.cpp @@ -2,8 +2,8 @@ #include "common.h" #include "d/col/bg/d_bg_s.h" +#include "d/d_stage.h" #include "m/m_vec.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_UTAJIMA_LV2, dAcOutajimaLv2_c, fProfile::OBJ_UTAJIMA_LV2, 0x1D5, 0, 3); @@ -11,8 +11,8 @@ const f32 dAcOutajimaLv2_c::someFloat = 100000.0f; bool dAcOutajimaLv2_c::createHeap() { mRes = nw4r::g3d::ResFile(getOarcResFile("IslCave")); - RoomManager::bindStageResToFile(&mRes); - RoomManager::bindSkyCmnToResFile(&mRes); + dStage_c::bindStageResToFile(&mRes); + dStage_c::bindSkyCmnToResFile(&mRes); nw4r::g3d::ResMdl mdl = mRes.GetResMdl("IslCave"); TRY_CREATE(mMdl.create(mdl, &heap_allocator, 0x120)); diff --git a/src/REL/d/t/d_t_genki_dws_tgt.cpp b/src/REL/d/t/d_t_genki_dws_tgt.cpp index 778b38f4..1d3479be 100644 --- a/src/REL/d/t/d_t_genki_dws_tgt.cpp +++ b/src/REL/d/t/d_t_genki_dws_tgt.cpp @@ -2,9 +2,9 @@ #include "d/d_room.h" #include "d/d_sc_game.h" +#include "d/d_stage.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(TAG_GENKI_DOWSING_TARGET, dTgGenkiDwsTgt_c, fProfile::TAG_GENKI_DOWSING_TARGET, 0x02A5, 0, 0); @@ -50,9 +50,8 @@ int dTgGenkiDwsTgt_c::actorExecute() { if (flag) { deleteRequest(); } else { - RoomManager *mgr = RoomManager::m_Instance; - if (mgr != nullptr) { - dRoom_c *room = RoomManager::m_Instance->GetRoomByIndex(roomid); + if (dStage_c::GetInstance() != nullptr) { + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); if (room != nullptr) { if (room->checkFlag(8)) { mDowsingTarget.doRegister(); diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index 68dc8364..c56e80e9 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -5,13 +5,13 @@ #include "d/d_heap.h" #include "d/d_room.h" #include "d/d_sc_game.h" +#include "d/d_stage.h" #include "d/flag/enemyflag_manager.h" #include "f/f_list_nd.h" #include "m/m_vec.h" #include "toBeSorted/event.h" #include "toBeSorted/event_manager.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/room_manager.h" #include "toBeSorted/special_item_drop_mgr.h" // .sdata @@ -126,13 +126,13 @@ int dAcBase_c::initAllocator(int size, char *name, EGG::Heap *heap, int align) { } bool dAcBase_c::addActorToRoom(s32 roomId) { - dBase_c *room = RoomManager::getRoom(roomId); + dBase_c *room = dStage_c::getParentForRoom(roomId); if (room == nullptr) { return false; } if (setConnectChild(room)) { if (roomId == -1) { - this->roomid = RoomManager::m_Instance->curr_room_id; + this->roomid = dStage_c::GetInstance()->getCurrRoomId(); } else { this->roomid = roomId; } @@ -427,14 +427,14 @@ void dAcBase_c::updateRoomId(f32 yOffset) { if (checkCollision(&actorPos)) { roomid = collisionCheckGetRoom(); } else { - roomid = RoomManager::m_Instance->curr_room_id; + roomid = dStage_c::GetInstance()->getCurrRoomId(); } } } // 8002d540 bool dAcBase_c::isRoomFlags_0x6_Set() { - dRoom_c *room = RoomManager::m_Instance->GetRoomByIndex(roomid); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); return (room->checkFlag(0x4 | 0x2)); } @@ -478,12 +478,12 @@ void dAcBase_c::setEnemyDefeatFlag() { // 8002d940 void dAcBase_c::changeLoadedEntitiesWithSet() { - RoomManager::m_Instance->changeLoadedEntities(RoomManager::m_Instance, obj_id, true); + dStage_c::GetInstance()->changeLoadedEntities(obj_id, true); } // 8002d960 void dAcBase_c::changeLoadedEntitiesNoSet() { - RoomManager::m_Instance->changeLoadedEntities(RoomManager::m_Instance, obj_id, false); + dStage_c::GetInstance()->changeLoadedEntities(obj_id, false); } // spawns GroupType2 (ACTOR) @@ -513,7 +513,7 @@ dAcBase_c *dAcBase_c::createActor( setTempCreateParams( actorPosition, actorRotation, actorScale, actorRoomid, newParams2, (dAcBase_c *)actorRef, 0, -1, 0xFF, nullptr ); - dBase_c *room = RoomManager::getRoom(roomid); + dBase_c *room = dStage_c::getParentForRoom(roomid); return (dAcBase_c *)dBase_c::createBase(actorId, room, actorParams1, ACTOR); } @@ -544,7 +544,7 @@ dAcBase_c *dAcBase_c::createActorStage( setTempCreateParams( actorPosition, actorRotation, actorScale, actorRoomid, newParams2, (dAcBase_c *)actorRef, 0, -1, 0xFF, nullptr ); - dBase_c *room = RoomManager::getRoom(roomid); + dBase_c *room = dStage_c::getParentForRoom(roomid); return (dAcBase_c *)dBase_c::createBase(actorId, room, actorParams1, STAGE); } diff --git a/src/d/a/obj/d_a_obj_tbox.cpp b/src/d/a/obj/d_a_obj_tbox.cpp index 1689a31f..d391c4af 100644 --- a/src/d/a/obj/d_a_obj_tbox.cpp +++ b/src/d/a/obj/d_a_obj_tbox.cpp @@ -12,6 +12,7 @@ #include "d/col/cc/d_cc_d.h" #include "d/col/cc/d_cc_s.h" #include "d/d_room.h" +#include "d/d_stage.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" #include "d/flag/tboxflag_manager.h" @@ -32,7 +33,6 @@ #include "toBeSorted/counters/goddess_chest_counter.h" #include "toBeSorted/dowsing_target.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/room_manager.h" SPECIAL_ACTOR_PROFILE(TBOX, dAcTbox_c, fProfile::TBOX, 0x018D, 0, 6); @@ -1192,7 +1192,7 @@ int dAcTbox_c::actorExecute() { (this->*mRegisterDowsingTarget)(); } - dRoom_c *r = RoomManager::m_Instance->GetRoomByIndex(roomid); + dRoom_c *r = dStage_c::GetInstance()->getRoom(roomid); bool hasFlags = r->checkFlag(0x1E); if (hasFlags) { setObjectProperty(0x200); @@ -1328,7 +1328,7 @@ int dAcTbox_c::actorExecuteInEvent() { (this->*mRegisterDowsingTarget)(); } - dRoom_c *r = RoomManager::m_Instance->GetRoomByIndex(roomid); + dRoom_c *r = dStage_c::GetInstance()->getRoom(roomid); bool hasFlags = r->checkFlag(0x1E); if (hasFlags) { setObjectProperty(0x200); diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index f2334854..8d486c1a 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -8,6 +8,7 @@ #include "d/col/bg/d_bg_w_base.h" #include "d/col/bg/d_bg_w_kcol.h" #include "d/d_sc_game.h" +#include "d/d_stage.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" #include "d/t/d_t_mass_obj.h" @@ -35,7 +36,6 @@ #include "nw4r/math/math_types.h" #include "sized_string.h" #include "toBeSorted/arc_managers/current_stage_arc_manager.h" -#include "toBeSorted/room_manager.h" #include "toBeSorted/stage_manager.h" #include "toBeSorted/time_area_mgr.h" #include "toBeSorted/unk_with_water.h" @@ -66,8 +66,8 @@ int dRoom_c::create() { bool anyError = false; mRoomRes = nw4r::g3d::ResFile(CurrentStageArcManager::sInstance->loadFromRoomArc(roomid, "g3d/room.brres")); - RoomManager::bindStageResToFile(&mRoomRes); - RoomManager::bindSkyCmnToResFile(&mRoomRes); + dStage_c::bindStageResToFile(&mRoomRes); + dStage_c::bindSkyCmnToResFile(&mRoomRes); for (s32 i = 0; i < 8; i++) { model_c *mdl = &mModels[i]; @@ -99,7 +99,7 @@ int dRoom_c::create() { return FAILED; } - RoomManager::m_Instance->setRoom(roomid, this); + dStage_c::GetInstance()->setRoom(roomid, this); BZS = CurrentStageArcManager::sInstance->loadFromRoomArc(roomid, "dat/room.bzs"); parseRoomBzs(roomid, BZS); mDidAlreadyInit = (params >> 6) & 1; @@ -123,7 +123,7 @@ int dRoom_c::doDelete() { stageMr->destroyUnkWithWater(val, &mWaterThing); } - RoomManager::m_Instance->setRoom(roomid, nullptr); + dStage_c::GetInstance()->setRoom(roomid, nullptr); return SUCCEEDED; } @@ -265,7 +265,7 @@ void dRoom_c::drawOnMapIfVisible(mMtx_c *mtx, int param) { // Visited rooms are shown filled out bool drawFully = true; if (dStageMgr_c::GetInstance()->isAreaTypeDungeonOrBoss()) { - drawFully = RoomManager::m_Instance->hasVisitedRoomId(roomid); + drawFully = dStage_c::GetInstance()->hasVisitedRoom(roomid); if (!drawFully && !dAcItem_c::checkFlag(/* DUNGEON_MAP_FI */ 0x32)) { return; } @@ -505,7 +505,7 @@ bool dRoom_c::model_c::create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s nw4r::g3d::ResAnmTexSrt anmSrt = resFile.GetResAnmTexSrt(mdlName); if (!anmSrt.IsValid()) { - RoomManager::getMA0IndirectSrt(&anmSrt, mdl); + dStage_c::getMA0IndirectSrt(&anmSrt, mdl); } if (anmSrt.IsValid()) { mpAnmSrt = new m3d::anmTexSrt_c(); diff --git a/src/d/d_sc_game.cpp b/src/d/d_sc_game.cpp index d85b57a6..ce809c76 100644 --- a/src/d/d_sc_game.cpp +++ b/src/d/d_sc_game.cpp @@ -14,7 +14,6 @@ #include "toBeSorted/file_manager.h" #include "toBeSorted/minigame_mgr.h" #include "toBeSorted/music_mgrs.h" -#include "toBeSorted/room_manager.h" #include "toBeSorted/some_gxf_thing.h" #include "toBeSorted/stage_manager.h" diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp new file mode 100644 index 00000000..91759aba --- /dev/null +++ b/src/d/d_stage.cpp @@ -0,0 +1,392 @@ +#include "d/d_stage.h" + +#include "common.h" +#include "d/col/bg/d_bg_s.h" +#include "d/d_base.h" +#include "d/d_room.h" +#include "d/d_sc_game.h" +#include "d/d_sc_title.h" +#include "d/flag/dungeonflag_manager.h" +#include "d/flag/sceneflag_manager.h" +#include "d/flag/storyflag_manager.h" +#include "f/f_base.h" +#include "f/f_profile.h" +#include "f/f_profile_name.h" +#include "m/m_fader_base.h" +#include "m/m_vec.h" +#include "nw4r/g3d/res/g3d_resfile.h" +#include "nw4r/g3d/res/g3d_resmat.h" +#include "nw4r/g3d/res/g3d_resmdl.h" +#include "nw4r/math/math_types.h" +#include "s/s_FPhase.h" +#include "toBeSorted/arc_managers/current_stage_arc_manager.h" +#include "toBeSorted/arc_managers/layout_arc_manager.h" +#include "toBeSorted/arc_managers/oarc_manager.h" +#include "toBeSorted/event_manager.h" +#include "toBeSorted/music_mgrs.h" +#include "toBeSorted/time_area_mgr.h" + +#include + +SPECIAL_BASE_PROFILE(STAGE, dStage_c, fProfile::STAGE, 6, 0x4E0); + +sFPhase::phaseCallback dStage_c::sCallbacks[] = { + &dStage_c::createRooms, + &dStage_c::waitForRooms, + nullptr, +}; + +extern "C" void fn_8001BE60(f32, f32); +extern "C" void *SCRAPPER_PTR; + +dStage_c::dStage_c() : mPhase(this, sCallbacks) { + memset(loaded_entities, 0, sizeof(loaded_entities)); + sInstance = this; + dScGame_c::resetUpdateFrameCount(); + SCRAPPER_PTR = nullptr; + fn_8001BE60(2000.0f, 1700.0f); +} + +extern "C" void *SCRAPPER_PICKUP_TARGET; +extern "C" void ScrapperPickupMgr__update(void *); +extern "C" void ScrapperPickupMgr__dtor(); +extern "C" void fn_80028A80(); +extern "C" void fn_80028EC0(); +extern "C" void fn_80066D30(s32); + +int dStage_c::create() { + if (mPhase.step() != sFPhaseBase::PHASE_ALL_DONE) { + return NOT_READY; + } + + // dStageMgr_c *stageMgr = dStageMgr_c::GetInstance(); + // for (int i = 0; i < dSta) + + if (mapRelated.field_0x1EB == 0) { + mVec3_c min, max; + for (s32 i = 0; i < MAX_ROOM_NUMBER - 1; i++) { + dRoom_c *room = getRoom(i); + if (room != nullptr) { + mVec3_c tmin, tmax; + room->getBounds(&tmin, &tmax); + if (i == 0) { + min = tmin; + max = tmax; + } else { + nw4r::math::VEC3Minimize(min, min, tmin); + nw4r::math::VEC3Maximize(max, max, tmax); + } + } + } + max.y += 6000.0f; + mVec3_c size = max - min; + mVec3_c center = mVec3_c(min.x + size.x * 0.5f, min.y, min.z + size.z * 0.5f); + mapRelated.fn_801B4B80(0, center, size); + mVec3_c v = mVec3_c(10000.0f, 10000.0f, 100000.0f); + mapRelated.fn_801B4C70(v); + } + mapRelated.fn_801B50C0(0); + fn_80028A80(); + + return SUCCEEDED; +} + +int dStage_c::doDelete() { + fn_80028EC0(); + fn_80066D30(-1); + ScrapperPickupMgr__dtor(); + return SUCCEEDED; +} + +int dStage_c::execute() { + mFader.calc(); + ScrapperPickupMgr__update(SCRAPPER_PICKUP_TARGET); + return SUCCEEDED; +} + +extern "C" void resetViewClipVals(); + +int dStage_c::draw() { + resetViewClipVals(); + return SUCCEEDED; +} + +void dStage_c::deleteReady() {} + +sFPhaseBase::sFPhaseState dStage_c::createRooms() { + // TODO + // if (dScGame_c::sCo) + mFader.create(); + mFader.setTypes(1, 1); + mFader.setFadeInFrame(1); + mFader.fadeIn(); + mFader.calc(); + mFader.setFrames(15, 15); + mFader.initForLyt(); + // TODO + + if (dScTitle_c::sInstance != nullptr) { + dBase_c::createBase(fProfile::TITLE, this, 0, OTHER); + } + + dTimeAreaMgr_c::sInstance->setField0x78(false); + + return sFPhaseBase::PHASE_NEXT; +} + +sFPhaseBase::sFPhaseState dStage_c::waitForRooms() { + if (checkChildProcessCreateState()) { + return sFPhaseBase::PHASE_RETRY; + } + return sFPhaseBase::PHASE_NEXT; +} + +void dStage_c::setRoom(int roomid, dRoom_c *room) { + rooms.setRoom(roomid, room); +} + +dRoom_c *dStage_c::getRoom(s32 idx) { + return rooms.getRoom(idx); +} + +bool dStage_c::fadeIn(s32 fadeType, u16 frames) { + if (mFader.getStatus() != mFaderBase_c::FADED_OUT) { + return false; + } + mFader.setFadeInType(fadeType); + mFader.setFadeInFrame(frames); + mFader.fadeIn(); + fn_80384570(ENEMY_BGM_RELATED_MGR, false); + return true; +} + +bool dStage_c::fadeOut(s32 fadeType, u16 frames) { + if (mFader.getStatus() != mFaderBase_c::FADED_IN) { + return false; + } + mFader.setFadeOutType(fadeType); + mFader.setFadeOutFrame(frames); + mFader.fadeOut(); + fn_80384570(ENEMY_BGM_RELATED_MGR, true); + return true; +} + +void dStage_c::forceFadeOut() { + mFader.setStatus(mFaderBase_c::FADED_OUT); + fn_80384570(ENEMY_BGM_RELATED_MGR, true); +} + +void dStage_c::forceFadeIn() { + mFader.setStatus(mFaderBase_c::FADED_IN); + fn_80384570(ENEMY_BGM_RELATED_MGR, false); +} + +void dStage_c::drawMap(mMtx_c *mtx, int param) { + dBgS::GetInstance()->UpdateScrollTex(); + for (s32 i = 0; i < MAX_ROOM_NUMBER - 1; i++) { + dRoom_c *room = getRoom(i); + if (room != nullptr) { + room->drawOnMapIfVisible(mtx, param); + } + } + dBgS::GetInstance()->DrawSkyKeepMap(mtx, param); +} + +static void getFlagPositionForRoomVisit(int roomid, u16 *o_flag, u16 *o_shift) { + *o_flag = (roomid / 16) + 8; + *o_shift = 1 << (roomid % 16); +} + +bool dStage_c::hasVisitedRoom(int roomid) const { + u16 flag, shift; + getFlagPositionForRoomVisit(roomid, &flag, &shift); + DungeonflagManager *mg = DungeonflagManager::sInstance; + return (mg->getCounterOrFlag(flag, 8) & shift) != 0; +} + +void dStage_c::setRoomVisited(int roomid) { + // TODO this is probably an inline but inline bools cause extra instructions + if (EventManager::getCurrentEventName() != nullptr && + std::strncmp(EventManager::getCurrentEventName(), "Save", 0x20) == 0) { + return; + } + + if (dScGame_c::sInstance == nullptr || dScGame_c::sInstance->profile_name == fProfile::GAME) { + u16 flag, shift; + getFlagPositionForRoomVisit(roomid, &flag, &shift); + DungeonflagManager *mg = DungeonflagManager::sInstance; + u16 newVal = shift | mg->getCounterOrFlag(flag, 8); + mg->setToValue(flag, newVal); + } +} + +dRoom_c *dStage_c::createRoom(int roomid, bool flag0x40) { + return static_cast( + dBase_c::createBase(fProfile::ROOM, this, (roomid & 0x3F) | (flag0x40 ? 0x40 : 0), OTHER) + ); +} + +void dStage_c::createLytSeekerStone() { + dBase_c::createBase(fProfile::LYT_CONTROL_GAME, this, 0, OTHER); + if (LayoutArcManager::sInstance->hasEntry("SeekerStone")) { + dBase_c::createBase(fProfile::LYT_SEEKER_STONE, this, 0, OTHER); + } +} + +dBase_c *dStage_c::getParentForRoom(s32 idx) { + if (idx == -1) { + return dStage_c::GetInstance(); + } + return dStage_c::GetInstance()->getRoom(idx); +} + +void dStage_c::bindStageResToFile(nw4r::g3d::ResFile *file) { + nw4r::g3d::ResFile f = nw4r::g3d::ResFile(CurrentStageArcManager::sInstance->getData("g3d/stage.brres")); + if (f.IsValid()) { + file->Bind(f); + } +} + +void dStage_c::bindSkyCmnToResFile(nw4r::g3d::ResFile *file) { + nw4r::g3d::ResFile f = nw4r::g3d::ResFile(OarcManager::sInstance->getSubEntryData("SkyCmn", "g3d/model.brres")); + if (f.IsValid()) { + file->Bind(f); + } +} + +static const char *sMatsToTry[] = { + "MA01", + "MA02", + "MA04", +}; + +bool dStage_c::getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *o_srt, const char *matName) { + const char **candidate = sMatsToTry; + for (int i = 0; i < ARRAY_LENGTH(sMatsToTry); i++, candidate++) { + if (!std::strncmp(matName, *candidate, std::strlen(*candidate))) { + nw4r::g3d::ResFile mdl = nw4r::g3d::ResFile(OarcManager::sInstance->getMdlFromArc2("Common")); + *o_srt = mdl.GetResAnmTexSrt(*candidate); + return true; + } + } + return false; +} + +bool dStage_c::getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *o_srt, const nw4r::g3d::ResMdl &mdl) { + for (u32 i = 0; i < mdl.GetResMatNumEntries(); i++) { + nw4r::g3d::ResMat mat = mdl.GetResMat(i); + const char *name = mat.GetName(); + if (getMA0AnmTexSrt(o_srt, name)) { + return true; + } + } + return false; +} + +dRoomTable_c::dRoomTable_c() { + // Okay + mRooms[0] = nullptr; + mRooms[1] = nullptr; + mRooms[2] = nullptr; + mRooms[3] = nullptr; + mRooms[4] = nullptr; + mRooms[5] = nullptr; + mRooms[6] = nullptr; + mRooms[7] = nullptr; + mRooms[8] = nullptr; + mRooms[9] = nullptr; + mRooms[10] = nullptr; + mRooms[11] = nullptr; + mRooms[12] = nullptr; + mRooms[13] = nullptr; + mRooms[14] = nullptr; + mRooms[15] = nullptr; + mRooms[16] = nullptr; + mRooms[17] = nullptr; + mRooms[18] = nullptr; + mRooms[19] = nullptr; + mRooms[20] = nullptr; + mRooms[21] = nullptr; + mRooms[22] = nullptr; + mRooms[23] = nullptr; + mRooms[24] = nullptr; + mRooms[25] = nullptr; + mRooms[26] = nullptr; + mRooms[27] = nullptr; + mRooms[28] = nullptr; + mRooms[29] = nullptr; + mRooms[30] = nullptr; + mRooms[31] = nullptr; + mRooms[32] = nullptr; + mRooms[33] = nullptr; + mRooms[34] = nullptr; + mRooms[35] = nullptr; + mRooms[36] = nullptr; + mRooms[37] = nullptr; + mRooms[38] = nullptr; + mRooms[39] = nullptr; + mRooms[40] = nullptr; + mRooms[41] = nullptr; + mRooms[42] = nullptr; + mRooms[43] = nullptr; + mRooms[44] = nullptr; + mRooms[45] = nullptr; + mRooms[46] = nullptr; + mRooms[47] = nullptr; + mRooms[48] = nullptr; + mRooms[49] = nullptr; + mRooms[50] = nullptr; + mRooms[51] = nullptr; + mRooms[52] = nullptr; + mRooms[53] = nullptr; + mRooms[54] = nullptr; + mRooms[55] = nullptr; + mRooms[56] = nullptr; + mRooms[57] = nullptr; + mRooms[58] = nullptr; + mRooms[59] = nullptr; + mRooms[60] = nullptr; + mRooms[61] = nullptr; + mRooms[62] = nullptr; +} + +MapRelated::MapRelated() + : field_0x0FC(0.0f, 0.0f, 0.0f), + field_0x108(0.0f), + field_0x10C(0.0f), + field_0x110(0.0f), + field_0x114(0.0f), + field_0x118(0.0f), + field_0x11C(0.0f), + field_0x120(0.0f), + field_0x124(0.0f), + field_0x128(0.0f), + field_0x12C(0.0f), + field_0x1E0(0), + field_0x1E6(0), + field_0x1E8(0), + field_0x1E9(4), + field_0x1EA(-3), + field_0x1EB(0), + field_0x1EC(0), + field_0x1ED(0), + field_0x1EE(0), + field_0x1F0(0) { + mPostEffect.setField0x30(0.15f); + bool showPastVariant = true; + bool showDesertPast = dScGame_c::isCurrentStage("S300") || + ((dScGame_c::isCurrentStage("F300") || dScGame_c::isCurrentStage("F300_4")) && + SceneflagManager::sInstance->checkTempOrSceneflag(3)); + if (!showDesertPast) { + bool hideSeaPast = !(dScGame_c::isCurrentStage("F301_1") && StoryflagManager::sInstance->getCounterOrFlag(519)); + if (hideSeaPast) { + showPastVariant = false; + } + } + field_0x1EF = showPastVariant; +} + +extern "C" void fn_801B4AE0(); +MapRelated::~MapRelated() { + fn_801B4AE0(); +} diff --git a/src/d/flag/sceneflag_manager.inc b/src/d/flag/sceneflag_manager.inc index 5101567e..2fb9d2b7 100644 --- a/src/d/flag/sceneflag_manager.inc +++ b/src/d/flag/sceneflag_manager.inc @@ -146,7 +146,7 @@ bool SceneflagManager::checkSceneflagGlobal(u16 sceneIdx, u16 flag) { u16 *pData = FileManager::sInstance->getSceneFlagsConst(); return mFlagHelper.checkFlag(getSceneflagSlotGlobal(sceneIdx, flag), flag % 16, pData, 0x800); } -bool SceneflagManager::checkTempOrSceneflag(u16 flag) { +u16 SceneflagManager::checkTempOrSceneflag(u16 flag) { if (flag >= 0x80) { u16 tempflag = flag - 0x80; const u16 *pData = FileManager::sInstance->getTempFlagsConst(); diff --git a/src/toBeSorted/room_manager.cpp b/src/toBeSorted/room_manager.cpp deleted file mode 100644 index fe904bf2..00000000 --- a/src/toBeSorted/room_manager.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "toBeSorted/room_manager.h" - -RoomManager* RoomManager::m_Instance; \ No newline at end of file From 32b7ce138d86d862290909f7e9a23c703e0675e1 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 8 Mar 2025 22:40:04 +0100 Subject: [PATCH 05/11] dStageMgr_c start, more splits --- config/SOUE01/splits.txt | 28 ++ config/SOUE01/symbols.txt | 134 ++++---- configure.py | 2 + include/d/col/cc/d_cc_mass_s.h | 4 + include/d/col/cc/d_cc_s.h | 5 + include/d/d_last.h | 17 + include/d/d_sc_game.h | 14 +- include/d/d_stage_mgr.h | 114 +++++++ include/d/d_stage_parse.h | 12 + include/m/m_fader.h | 4 + include/sized_string.h | 4 + .../arc_managers/current_stage_arc_manager.h | 4 + .../toBeSorted/arc_managers/oarc_manager.h | 13 + include/toBeSorted/music_mgrs.h | 5 + include/toBeSorted/stage_manager.h | 35 -- src/d/col/cc/d_cc_s.cpp | 3 +- src/d/d_room.cpp | 2 +- src/d/d_sc_game.cpp | 2 +- src/d/d_stage_mgr.cpp | 298 ++++++++++++++++++ src/d/lyt/meter/d_lyt_meter.cpp | 2 +- 20 files changed, 593 insertions(+), 109 deletions(-) create mode 100644 include/d/d_last.h create mode 100644 include/d/d_stage_mgr.h create mode 100644 include/d/d_stage_parse.h delete mode 100644 include/toBeSorted/stage_manager.h create mode 100644 src/d/d_stage_mgr.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 27ad9e06..3b37935b 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -623,6 +623,16 @@ d/lyt/d_screen_fader.cpp: .data start:0x80528D68 end:0x80528D90 .sdata2 start:0x8057ABE0 end:0x8057AC08 +d/a/d_a_bird_base.cpp: + .text start:0x80175FD0 end:0x80179128 + +d/a/d_a_door_base.cpp: + .text start:0x80179130 end:0x801792C4 + .ctors start:0x804DB7DC end:0x804DB7E0 + +d/lyt/d_lyt_map_popup.cpp: + .text start:0x801792D0 end:0x80189F9C + d/a/d_a_fish_mgr_base.cpp: .text start:0x8018B880 end:0x8018BFC8 .ctors start:0x804DB7E4 end:0x804DB7E8 @@ -631,6 +641,9 @@ d/a/d_a_fish_base.cpp: .text start:0x8018BFD0 end:0x8018E378 .ctors start:0x804DB7E8 end:0x804DB7EC +toBeSorted/sword_proj_effect_list.cpp: + .text start:0x8018E380 end:0x8018F188 + d/a/d_a_insect.cpp: .text start:0x8018F190 end:0x80190710 .data start:0x8052ABD8 end:0x8052ACC0 @@ -644,6 +657,21 @@ d/a/d_a_salbage_npc.cpp: .text start:0x80192B00 end:0x80194080 .ctors start:0x804DB7F0 end:0x804DB7F4 +d/d_stage_mgr.cpp: + .text start:0x801975C0 end:0x8019CFD8 + .ctors start:0x804DB7FC end:0x804DB800 + .data start:0x8052B708 end:0x8052C128 + +d/d_last.cpp: + .text start:0x8019CFE0 end:0x8019D15C + +d/d_camera.cpp: + .text start:0x8019D160 end:0x8019ED0C + .ctors start:0x804DB800 end:0x804DB804 + +d/d_light_obj.cpp: + .text start:0x8019ED10 end:0x801A65C8 + d/tg/d_t_weather.cpp: .text start:0x801A65D0 end:0x801AF7D8 .ctors start:0x804DB804 end:0x804DB808 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index e2b45c5b..cf2428cb 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -10516,21 +10516,21 @@ fn_801973C0 = .text:0x801973C0; // type:function size:0x58 fn_80197420 = .text:0x80197420; // type:function size:0x140 fn_80197560 = .text:0x80197560; // type:function size:0x28 fn_80197590 = .text:0x80197590; // type:function size:0x28 -StageManager__ctor = .text:0x801975C0; // type:function size:0x34 +dStageMgr_c_classInit__Fv = .text:0x801975C0; // type:function size:0x34 fn_80197600 = .text:0x80197600; // type:function size:0xA0 fn_801976A0 = .text:0x801976A0; // type:function size:0x90 -StageManager__ctorCont = .text:0x80197730; // type:function size:0x39C +__ct__11dStageMgr_cFv = .text:0x80197730; // type:function size:0x39C fn_80197AD0 = .text:0x80197AD0; // type:function size:0x4C fn_80197B20 = .text:0x80197B20; // type:function size:0x54 -fn_80197B80 = .text:0x80197B80; // type:function size:0x40 +__dt__Q23EGG6ScreenFv = .text:0x80197B80; // type:function size:0x40 fn_80197BC0 = .text:0x80197BC0; // type:function size:0x40 fn_80197C00 = .text:0x80197C00; // type:function size:0x64 fn_80197C70 = .text:0x80197C70; // type:function size:0x5C -fn_80197CD0 = .text:0x80197CD0; // type:function size:0x58 -fn_80197D30 = .text:0x80197D30; // type:function size:0x58 -fn_80197D90 = .text:0x80197D90; // type:function size:0x6C -fn_80197E00 = .text:0x80197E00; // type:function size:0xA0 -fn_80197EA0 = .text:0x80197EA0; // type:function size:0xA4 +__dt__22sFPhase<11dStageMgr_c>Fv = .text:0x80197CD0; // type:function size:0x58 +__dt__24sFState_c<11dStageMgr_c>Fv = .text:0x80197D30; // type:function size:0x58 +__dt__27sFStateFct_c<11dStageMgr_c>Fv = .text:0x80197D90; // type:function size:0x6C +__dt__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80197E00; // type:function size:0xA0 +__dt__50sFStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c>Fv = .text:0x80197EA0; // type:function size:0xA4 fn_80197F50 = .text:0x80197F50; // type:function size:0x5C fn_80197FB0 = .text:0x80197FB0; // type:function size:0x5C fn_80198010 = .text:0x80198010; // type:function size:0x60 @@ -10539,16 +10539,16 @@ EGG__DrawPathShadowVolume____dt = .text:0x801980E0; // type:function size:0x60 fn_80198140 = .text:0x80198140; // type:function size:0x58 fn_801981A0 = .text:0x801981A0; // type:function size:0x58 fn_80198200 = .text:0x80198200; // type:function size:0x58 -fn_80198260 = .text:0x80198260; // type:function size:0x308 +__dt__11dStageMgr_cFv = .text:0x80198260; // type:function size:0x308 StageManager__init = .text:0x80198570; // type:function size:0xDC fn_80198650 = .text:0x80198650; // type:function size:0x1CC StageManager__baseUpdate = .text:0x80198820; // type:function size:0x3D8 -fn_80198C00 = .text:0x80198C00; // type:function size:0x10 -fn_80198C10 = .text:0x80198C10; // type:function size:0x10 +getStateID__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80198C00; // type:function size:0x10 +executeState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80198C10; // type:function size:0x10 StageManager__draw = .text:0x80198C20; // type:function size:0x14C fn_80198D70 = .text:0x80198D70; // type:function size:0x14 StageManager__init2 = .text:0x80198D90; // type:function size:0x25C -fn_80198FF0 = .text:0x80198FF0; // type:function size:0x10 +changeState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x80198FF0; // type:function size:0x10 fn_80199000 = .text:0x80199000; // type:function size:0x110 fn_80199110 = .text:0x80199110; // type:function size:0x8 fn_80199120 = .text:0x80199120; // type:function size:0x10 @@ -10601,41 +10601,41 @@ fn_8019A390 = .text:0x8019A390; // type:function size:0x44 fn_8019A3E0 = .text:0x8019A3E0; // type:function size:0x2C8 fn_8019A6B0 = .text:0x8019A6B0; // type:function size:0xF0 fn_8019A7A0 = .text:0x8019A7A0; // type:function size:0x3C -StageMgr__stateReadStageResEnter = .text:0x8019A7E0; // type:function size:0x10 -StageMgr__stateReadStageResUpdate = .text:0x8019A7F0; // type:function size:0x58 -StageMgr__stateReadStageResLeave = .text:0x8019A850; // type:function size:0x60 -StageManager__loadRoomsAndAdditionalLayouts = .text:0x8019A8B0; // type:function size:0x218 -StageMgr__stateReadRoomResUpdate = .text:0x8019AAD0; // type:function size:0x6C -StageMgr__stateReadRoomResLeave = .text:0x8019AB40; // type:function size:0xB8 -StageMgr__stateReadObjectResEnter = .text:0x8019AC00; // type:function size:0x8 -StageMgr__stateReadObjectResUpdate = .text:0x8019AC10; // type:function size:0x54 -StageMgr__stateReadObjectResLeave = .text:0x8019AC70; // type:function size:0x4 -StageMgr__stateReadStageLayerResEnter = .text:0x8019AC80; // type:function size:0x14 -StageMgr__stateReadStageLayerResUpdate = .text:0x8019ACA0; // type:function size:0x58 -StageMgr__stateReadObjectResLeave2 = .text:0x8019AD00; // type:function size:0x4 -StageMgr__stateReadLayerObjectResEnter = .text:0x8019AD10; // type:function size:0x19C -StageMgr__stateReadLayerObjectResUpdate = .text:0x8019AEB0; // type:function size:0x68 -StageMgr__stateReadLayerObjectResLeave = .text:0x8019AF20; // type:function size:0x98 +initializeState_ReadStageRes__11dStageMgr_cFv = .text:0x8019A7E0; // type:function size:0x10 +executeState_ReadStageRes__11dStageMgr_cFv = .text:0x8019A7F0; // type:function size:0x58 +finalizeState_ReadStageRes__11dStageMgr_cFv = .text:0x8019A850; // type:function size:0x60 +initializeState_ReadRoomRes__11dStageMgr_cFv = .text:0x8019A8B0; // type:function size:0x218 +executeState_ReadRoomRes__11dStageMgr_cFv = .text:0x8019AAD0; // type:function size:0x6C +finalizeState_ReadRoomRes__11dStageMgr_cFv = .text:0x8019AB40; // type:function size:0xB8 +initializeState_ReadObjectRes__11dStageMgr_cFv = .text:0x8019AC00; // type:function size:0x8 +executeState_ReadObjectRes__11dStageMgr_cFv = .text:0x8019AC10; // type:function size:0x54 +finalizeState_ReadObjectRes__11dStageMgr_cFv = .text:0x8019AC70; // type:function size:0x4 +initializeState_ReadStageLayerRes__11dStageMgr_cFv = .text:0x8019AC80; // type:function size:0x14 +executeState_ReadStageLayerRes__11dStageMgr_cFv = .text:0x8019ACA0; // type:function size:0x58 +finalizeState_ReadStageLayerRes__11dStageMgr_cFv = .text:0x8019AD00; // type:function size:0x4 +initializeState_ReadLayerObjectRes__11dStageMgr_cFv = .text:0x8019AD10; // type:function size:0x19C +executeState_ReadLayerObjectRes__11dStageMgr_cFv = .text:0x8019AEB0; // type:function size:0x68 +finalizeState_ReadLayerObjectRes__11dStageMgr_cFv = .text:0x8019AF20; // type:function size:0x98 fn_8019AFC0 = .text:0x8019AFC0; // type:function size:0x28 -StageMgr__stateSoundLoadSceneDataEnter = .text:0x8019AFF0; // type:function size:0x44 -StageMgr__stateSoundLoadSceneDataUpdate = .text:0x8019B040; // type:function size:0x34 -StageMgr__stateSoundLoadSceneDataLeave = .text:0x8019B080; // type:function size:0x38 -StageMgr__stateCreateObjectEnter = .text:0x8019B0C0; // type:function size:0x684 -StageMgr__stateCreateObjectUpdate = .text:0x8019B750; // type:function size:0x50 -StageMgr__stateCreateObjectLeave = .text:0x8019B7A0; // type:function size:0x4 +initializeState_SoundLoadSceneData__11dStageMgr_cFv = .text:0x8019AFF0; // type:function size:0x44 +executeState_SoundLoadSceneData__11dStageMgr_cFv = .text:0x8019B040; // type:function size:0x34 +finalizeState_SoundLoadSceneData__11dStageMgr_cFv = .text:0x8019B080; // type:function size:0x38 +initializeState_CreateObject__11dStageMgr_cFv = .text:0x8019B0C0; // type:function size:0x684 +executeState_CreateObject__11dStageMgr_cFv = .text:0x8019B750; // type:function size:0x50 +finalizeState_CreateObject__11dStageMgr_cFv = .text:0x8019B7A0; // type:function size:0x4 fn_8019B7B0 = .text:0x8019B7B0; // type:function size:0x28 -StageMgr__stateReadObjectSoundEnter = .text:0x8019B7E0; // type:function size:0x3C -StageMgr__stateReadObjectSoundUpdate = .text:0x8019B820; // type:function size:0x7C -StageMgr__stateReadObjectSoundLeave = .text:0x8019B8A0; // type:function size:0x4C -StageMgr__stateSceneChangeSaveEnter = .text:0x8019B8F0; // type:function size:0x54 -StageMgr__stateSceneChangeSaveUpdate = .text:0x8019B950; // type:function size:0x4C -StageMgr__stateSceneChangeSaveLeave = .text:0x8019B9A0; // type:function size:0x1C -StageMgr__stateRestartSceneWaitEnter = .text:0x8019B9C0; // type:function size:0x8 -StageMgr__stateRestartSceneWaitUpdate = .text:0x8019B9D0; // type:function size:0x118 -StageMgr__stateRestartSceneWaitLeave = .text:0x8019BAF0; // type:function size:0x4 -StageMgr__stateRestartSceneEnter = .text:0x8019BB00; // type:function size:0x5C -StageMgr__stateRestartSceneUpdate = .text:0x8019BB60; // type:function size:0x130 -StageMgr__stateRestartSceneLeave = .text:0x8019BC90; // type:function size:0x28 +initializeState_ReadObjectSound__11dStageMgr_cFv = .text:0x8019B7E0; // type:function size:0x3C +executeState_ReadObjectSound__11dStageMgr_cFv = .text:0x8019B820; // type:function size:0x7C +finalizeState_ReadObjectSound__11dStageMgr_cFv = .text:0x8019B8A0; // type:function size:0x4C +initializeState_SceneChangeSave__11dStageMgr_cFv = .text:0x8019B8F0; // type:function size:0x54 +executeState_SceneChangeSave__11dStageMgr_cFv = .text:0x8019B950; // type:function size:0x4C +finalizeState_SceneChangeSave__11dStageMgr_cFv = .text:0x8019B9A0; // type:function size:0x1C +initializeState_RestartSceneWait__11dStageMgr_cFv = .text:0x8019B9C0; // type:function size:0x8 +executeState_RestartSceneWait__11dStageMgr_cFv = .text:0x8019B9D0; // type:function size:0x118 +finalizeState_RestartSceneWait__11dStageMgr_cFv = .text:0x8019BAF0; // type:function size:0x4 +initializeState_RestartScene__11dStageMgr_cFv = .text:0x8019BB00; // type:function size:0x5C +executeState_RestartScene__11dStageMgr_cFv = .text:0x8019BB60; // type:function size:0x130 +finalizeState_RestartScene__11dStageMgr_cFv = .text:0x8019BC90; // type:function size:0x28 fn_8019BCC0 = .text:0x8019BCC0; // type:function size:0x16C fn_8019BE30 = .text:0x8019BE30; // type:function size:0x8 fn_8019BE40 = .text:0x8019BE40; // type:function size:0x74 @@ -10656,21 +10656,21 @@ fn_8019C270 = .text:0x8019C270; // type:function size:0x4 fn_8019C280 = .text:0x8019C280; // type:function size:0x4 fn_8019C290 = .text:0x8019C290; // type:function size:0x8 fn_8019C2A0 = .text:0x8019C2A0; // type:function size:0x8 -fn_8019C2B0 = .text:0x8019C2B0; // type:function size:0x60 -fn_8019C310 = .text:0x8019C310; // type:function size:0xC -fn_8019C320 = .text:0x8019C320; // type:function size:0x1C -fn_8019C340 = .text:0x8019C340; // type:function size:0x1C -fn_8019C360 = .text:0x8019C360; // type:function size:0x1C -fn_8019C380 = .text:0x8019C380; // type:function size:0x10 -fn_8019C390 = .text:0x8019C390; // type:function size:0x10 -fn_8019C3A0 = .text:0x8019C3A0; // type:function size:0x10 -fn_8019C3B0 = .text:0x8019C3B0; // type:function size:0x10 -fn_8019C3C0 = .text:0x8019C3C0; // type:function size:0x10 -fn_8019C3D0 = .text:0x8019C3D0; // type:function size:0x10 -fn_8019C3E0 = .text:0x8019C3E0; // type:function size:0x30 -fn_8019C410 = .text:0x8019C410; // type:function size:0xC -fn_8019C420 = .text:0x8019C420; // type:function size:0x10 -fn_8019C430 = .text:0x8019C430; // type:function size:0x2C +build__27sFStateFct_c<11dStageMgr_c>FRC12sStateIDIf_c = .text:0x8019C2B0; // type:function size:0x60 +dispose__27sFStateFct_c<11dStageMgr_c>FRP10sStateIf_c = .text:0x8019C310; // type:function size:0xC +initialize__24sFState_c<11dStageMgr_c>Fv = .text:0x8019C320; // type:function size:0x1C +execute__24sFState_c<11dStageMgr_c>Fv = .text:0x8019C340; // type:function size:0x1C +finalize__24sFState_c<11dStageMgr_c>Fv = .text:0x8019C360; // type:function size:0x1C +initializeState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8019C380; // type:function size:0x10 +finalizeState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8019C390; // type:function size:0x10 +refreshState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8019C3A0; // type:function size:0x10 +getState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x8019C3B0; // type:function size:0x10 +getNewStateID__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x8019C3C0; // type:function size:0x10 +getOldStateID__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x8019C3D0; // type:function size:0x10 +callPhase__22sFPhase<11dStageMgr_c>Fv = .text:0x8019C3E0; // type:function size:0x30 +onReset__22sFPhase<11dStageMgr_c>Fv = .text:0x8019C410; // type:function size:0xC +nextPhase__22sFPhase<11dStageMgr_c>Fv = .text:0x8019C420; // type:function size:0x10 +hasReachedEnd__22sFPhase<11dStageMgr_c>CFv = .text:0x8019C430; // type:function size:0x2C fn_8019C460 = .text:0x8019C460; // type:function size:0x10 fn_8019C470 = .text:0x8019C470; // type:function size:0x10 fn_8019C480 = .text:0x8019C480; // type:function size:0x10 @@ -10678,12 +10678,12 @@ fn_8019C490 = .text:0x8019C490; // type:function size:0x8 fn_8019C4A0 = .text:0x8019C4A0; // type:function size:0x10 fn_8019C4B0 = .text:0x8019C4B0; // type:function size:0x8 fn_8019C4C0 = .text:0x8019C4C0; // type:function size:0x10 -fn_8019C4D0 = .text:0x8019C4D0; // type:function size:0x30 -fn_8019C500 = .text:0x8019C500; // type:function size:0x30 -fn_8019C530 = .text:0x8019C530; // type:function size:0x30 -StageMgr__initStates = .text:0x8019C560; // type:function size:0x87C -StageMgr__state_dtor = .text:0x8019CDE0; // type:function size:0x58 -fn_8019CE40 = .text:0x8019CE40; // type:function size:0x88 +finalizeState__26sFStateID_c<11dStageMgr_c>CFR11dStageMgr_c = .text:0x8019C4D0; // type:function size:0x30 +executeState__26sFStateID_c<11dStageMgr_c>CFR11dStageMgr_c = .text:0x8019C500; // type:function size:0x30 +initializeState__26sFStateID_c<11dStageMgr_c>CFR11dStageMgr_c = .text:0x8019C530; // type:function size:0x30 +__sinit_\d_stage_mgr_cpp = .text:0x8019C560; // type:function size:0x87C scope:local +__dt__26sFStateID_c<11dStageMgr_c>Fv = .text:0x8019CDE0; // type:function size:0x58 +isSameName__26sFStateID_c<11dStageMgr_c>CFPCc = .text:0x8019CE40; // type:function size:0x88 fn_8019CED0 = .text:0x8019CED0; // type:function size:0x8 fn_8019CEE0 = .text:0x8019CEE0; // type:function size:0x8 fn_8019CEF0 = .text:0x8019CEF0; // type:function size:0x8 @@ -11020,7 +11020,7 @@ onReset__18sFPhase<8dStage_c>Fv = .text:0x801B5B40; // type:function size:0xC nextPhase__18sFPhase<8dStage_c>Fv = .text:0x801B5B50; // type:function size:0x10 hasReachedEnd__18sFPhase<8dStage_c>CFv = .text:0x801B5B60; // type:function size:0x2C fn_801B5B90 = .text:0x801B5B90; // type:function size:0x10 -__sinit_\d_stage_cpp = .text:0x801B5BA0; // type:function size:0x28 +__sinit_\d_stage_cpp = .text:0x801B5BA0; // type:function size:0x28 scope:local AcStageSelect__ctor = .text:0x801B5BD0; // type:function size:0x4C AcStageSelect__dtor = .text:0x801B5C20; // type:function size:0x5C dRoom_c_classInit__Fv = .text:0x801B5C80; // type:function size:0x17C diff --git a/configure.py b/configure.py index be60b1f5..fe71ad1b 100644 --- a/configure.py +++ b/configure.py @@ -429,6 +429,8 @@ config.libs = [ Object(Matching, "d/lyt/d_lyt_fader.cpp"), Object(Matching, "d/lyt/d_screen_fader.cpp"), Object(NonMatching, "d/a/d_a_insect.cpp"), + Object(NonMatching, "d/d_stage_mgr.cpp"), + Object(NonMatching, "d/d_last.cpp"), Object(NonMatching, "d/d_stage.cpp"), Object(NonMatching, "d/d_room.cpp"), Object(NonMatching, "d/d_cs_base.cpp"), diff --git a/include/d/col/cc/d_cc_mass_s.h b/include/d/col/cc/d_cc_mass_s.h index d6c7db55..056ec3cf 100644 --- a/include/d/col/cc/d_cc_mass_s.h +++ b/include/d/col/cc/d_cc_mass_s.h @@ -1,3 +1,5 @@ +#ifndef D_CC_MASS_OBJ_H +#define D_CC_MASS_OBJ_H #include "common.h" #include "d/a/obj/d_a_obj_base.h" @@ -102,3 +104,5 @@ public: // u8 GetResultCam() const; // void GetCamTopPos(Vec *p_out); }; + +#endif diff --git a/include/d/col/cc/d_cc_s.h b/include/d/col/cc/d_cc_s.h index 7b9096a7..06b24d0b 100644 --- a/include/d/col/cc/d_cc_s.h +++ b/include/d/col/cc/d_cc_s.h @@ -1,3 +1,6 @@ +#ifndef D_CC_S_H +#define D_CC_S_H + #include "common.h" #include "d/col/c/c_cc_d.h" #include "d/col/cc/d_cc_mass_s.h" @@ -76,3 +79,5 @@ public: static dCcS *GetInstance(); static dCcS *sInstance; }; + +#endif diff --git a/include/d/d_last.h b/include/d/d_last.h new file mode 100644 index 00000000..a4cf0fb4 --- /dev/null +++ b/include/d/d_last.h @@ -0,0 +1,17 @@ +#ifndef D_LAST_H +#define D_LAST_H + +#include "d/d_base.h" + +class dLast_c : public dBase_c { +public: + typedef void (*executeCallback)(void); + + static void setExecuteCallback(executeCallback cb) { + sExecuteCallback = cb; + } +private: + static executeCallback sExecuteCallback; +}; + +#endif diff --git a/include/d/d_sc_game.h b/include/d/d_sc_game.h index 1a948eb9..67099a2d 100644 --- a/include/d/d_sc_game.h +++ b/include/d/d_sc_game.h @@ -62,7 +62,7 @@ struct SpawnInfo { /* 0x24 */ s8 entrance; /* 0x25 */ u8 night; /* 0x26 */ u8 trial; - /* 0x27 */ s8 transitionType; + /* 0x27 */ u8 transitionType; /* 0x28 */ s8 unk; enum DayNight { @@ -137,6 +137,8 @@ public: static bool isCurrentStage(const char *stageName); static bool isStageSkyloftLayer20(); + static bool isInCredits(); + static bool isStateLayerWithSeekerStoneHintMenu(); static SpawnInfo currentSpawnInfo; static SpawnInfo nextSpawnInfo; @@ -156,6 +158,14 @@ public: sUpdateFrameCount = 0; } + bool savePromptFlag() const { + return mSavePromptFlag; + } + + void setSavePromptFlag(bool val) { + mSavePromptFlag = val; + } + protected: static u32 sUpdateFrameCount; static u8 sCurrentLayer; @@ -225,7 +235,7 @@ protected: /* 0x29C */ s32 mLastAreaType; /* 0x2A0 */ u8 mType0PosFlag; /* 0x2A1 */ u8 field_0x2A1; - /* 0x2A2 */ u8 mSavePromptFlag; + /* 0x2A2 */ bool mSavePromptFlag; /* 0x2A3 */ bool mPreventSaveRespawnInfo; }; diff --git a/include/d/d_stage_mgr.h b/include/d/d_stage_mgr.h new file mode 100644 index 00000000..7ae15250 --- /dev/null +++ b/include/d/d_stage_mgr.h @@ -0,0 +1,114 @@ +#ifndef D_STAGE_MGR_H +#define D_STAGE_MGR_H + +#include "d/col/bg/d_bg_s.h" +#include "d/col/cc/d_cc_s.h" +#include "d/d_base.h" +#include "d/d_dylink.h" +#include "d/d_fader.h" +#include "d/d_bzs_types.h" +#include "egg/gfx/eggScreen.h" +#include "m/m_allocator.h" +#include "m/m_dvd.h" +#include "s/s_FPhase.h" +#include "s/s_State.hpp" +#include "sized_string.h" +#include "toBeSorted/arc_managers/layout_arc_manager.h" +#include "toBeSorted/arc_managers/oarc_manager.h" +#include "toBeSorted/attention.h" +#include "toBeSorted/time_area_mgr.h" +#include "toBeSorted/unk_with_water.h" + +class RelObjCtrl { +public: + dDynamicModuleControl mRelCtrl; + ObjectArcControl mOarcCtrl; + + void doLoad(); + bool isLoaded() const; +}; + +class dStageMgr_c : public dBase_c { +public: + dStageMgr_c(); + virtual ~dStageMgr_c(); + + STATE_FUNC_DECLARE(dStageMgr_c, ReadStageRes); + STATE_FUNC_DECLARE(dStageMgr_c, ReadRoomRes); + STATE_FUNC_DECLARE(dStageMgr_c, ReadObjectRes); + STATE_FUNC_DECLARE(dStageMgr_c, ReadStageLayerRes); + STATE_FUNC_DECLARE(dStageMgr_c, ReadLayerObjectRes); + STATE_FUNC_DECLARE(dStageMgr_c, SoundLoadSceneData); + STATE_FUNC_DECLARE(dStageMgr_c, CreateObject); + STATE_FUNC_DECLARE(dStageMgr_c, ReadObjectSound); + STATE_FUNC_DECLARE(dStageMgr_c, SceneChangeSave); + STATE_FUNC_DECLARE(dStageMgr_c, RestartSceneWait); + STATE_FUNC_DECLARE(dStageMgr_c, RestartScene); + +public: + bool isAreaTypeDungeon() const; + bool isAreaTypeSky() const; + bool isAreaTypeDungeonOrBoss() const; + bool isAreaTypeOverworldOrSkyloft() const; + s32 getSTIFunk1() const; + + s32 getAreaType() const; + + static dStageMgr_c *GetInstance() { + return sInstance; + } + + bool checkFlag0x88A0(u32 flag) const { + return (field_0x88A0 & flag) != 0; + } + + void initUnkWithWater(u32 val, UnkWithWater *waterThing); + void destroyUnkWithWater(u32 val, UnkWithWater *waterThing); + + void addActorId(u16 actorId); + +private: + static void lastExecuteCallback(); + void triggerFade(s32 fadeType, u8 fadeFrames); + + static dStageMgr_c *sInstance; + static sFPhase::phaseCallback sCallbacks[]; + + /* 0x0068 */ mHeapAllocator_c mAlloc; + /* 0x0084 */ sFPhase mPhase; + /* 0x0098 */ STATE_MGR_DECLARE(dStageMgr_c); + /* 0x00D4 */ RelObjCtrl mStageObjCtrl; + /* 0x0324 */ RelObjCtrl mLayerObjCtrl; + /* 0x0574 */ LayoutArcControl mLayoutArcCtrl1; + /* 0x0580 */ LayoutArcControl mLayoutArcCtrl2; + /* 0x058C */ dBgS mBg; + // ... + /* 0x3E40 */ dCcS mCc; + // ... + /* 0x7930 */ dFader_c mFader; + + /* 0x7954 */ u16 mPcamCount; + /* 0x7956 */ u16 mLyseCount; + /* 0x7958 */ u16 mRmplCount; + + /* 0x795C */ PCAM *pcam; + /* 0x7960 */ PCAM *lyse; + /* 0x7964 */ STIF *stif; + /* 0x7968 */ RMPL *rmpl; + + /* 0x799C */ mDvd_callback_c *mpDvdCallback; + /* 0x79A0 */ mDvd_callback_c *mpDvdCallback2; + + /* 0x79A4 */ EGG::Screen mScreens[2]; + + /* 0x7AB4 */ AttentionManager mAttention; + /* 0x8694 */ dTimeAreaMgr_c mTimeAreaMgr; + + // ... + u8 ___[2450]; + + /* 0x88A0 */ u32 field_0x88A0; + /* 0x88A4 */ SizedString<16> mDemoName; + /* 0x88BC */ bool field_0x88BC; +}; +#endif diff --git a/include/d/d_stage_parse.h b/include/d/d_stage_parse.h new file mode 100644 index 00000000..00143224 --- /dev/null +++ b/include/d/d_stage_parse.h @@ -0,0 +1,12 @@ +#ifndef D_STAGE_PARSE_H +#define D_STAGE_PARSE_H + +#include "common.h" + +typedef s32 parseCallbackArg; + +void parseStageBzs(parseCallbackArg arg, void *bzs); +void parseRoomStageBzs(parseCallbackArg arg, void *bzs); +void parseBzsStageRoom(parseCallbackArg arg, void *bzs); + +#endif diff --git a/include/m/m_fader.h b/include/m/m_fader.h index 1d61c0ef..2d8c1189 100644 --- a/include/m/m_fader.h +++ b/include/m/m_fader.h @@ -16,6 +16,10 @@ public: return isStatus(status) != true; } + bool isSettled() const { + return isStatus(mFaderBase_c::FADED_IN) || isStatus(mFaderBase_c::FADED_OUT); + } + mFaderBase_c::EStatus getStatus() const { return mpFader->getStatus(); } diff --git a/include/sized_string.h b/include/sized_string.h index c1aac98b..64b01a5a 100644 --- a/include/sized_string.h +++ b/include/sized_string.h @@ -76,6 +76,10 @@ struct SizedString { va_end(list); return printed; } + + size_t len() const { + return strlen(mChars); + } }; // TODO this might be a shared template with SizedString but I'm diff --git a/include/toBeSorted/arc_managers/current_stage_arc_manager.h b/include/toBeSorted/arc_managers/current_stage_arc_manager.h index ee25ec14..11c8951c 100644 --- a/include/toBeSorted/arc_managers/current_stage_arc_manager.h +++ b/include/toBeSorted/arc_managers/current_stage_arc_manager.h @@ -32,6 +32,10 @@ public: EGG::ExpHeap *getHeap(s32 roomid); + inline int ensureAllEntriesLoaded() { + return mArcTable.ensureAllEntriesLoaded(); + } + private: SizedString<32> mStageName; SizedString<32> mCurrentLoadingStageArcName; diff --git a/include/toBeSorted/arc_managers/oarc_manager.h b/include/toBeSorted/arc_managers/oarc_manager.h index 319f44e9..5634b080 100644 --- a/include/toBeSorted/arc_managers/oarc_manager.h +++ b/include/toBeSorted/arc_managers/oarc_manager.h @@ -38,4 +38,17 @@ private: dRawArcTable_c mArcTable; }; +class ObjectArcControl { +public: + ObjectArcControl() : mObjectArcs(nullptr), mNumArcs(0) {} + virtual ~ObjectArcControl(); + void set(const char *const *objectArcs, s32 numArcs); + void load(EGG::Heap *heap); + void release(); + +private: + const char **mObjectArcs; + s32 mNumArcs; +}; + #endif diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 620d125a..0702156c 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -9,6 +9,11 @@ extern "C" void fn_8035E310(void *); extern "C" void *ENEMY_SOUND_MGR; extern "C" void fn_80362150(void *, u16); +extern "C" void fn_803625F0(void *, u16); +extern "C" void fn_803618F0(void *); +extern "C" void fn_80362730(void *); +extern "C" void fn_80365D20(void *); +extern "C" void fn_803624F0(void *); extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); diff --git a/include/toBeSorted/stage_manager.h b/include/toBeSorted/stage_manager.h deleted file mode 100644 index c5cf9984..00000000 --- a/include/toBeSorted/stage_manager.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef STAGE_MANAGER_H -#define STAGE_MANAGER_H - -#include "d/d_base.h" -#include "toBeSorted/unk_with_water.h" - -class dStageMgr_c : dBase_c { -public: - bool isAreaTypeDungeon() const; - bool isAreaTypeSky() const; - bool isAreaTypeDungeonOrBoss() const; - bool isAreaTypeOverworldOrSkyloft() const; - s32 getSTIFunk1() const; - - s32 getAreaType() const; - - static dStageMgr_c *GetInstance() { - return sInstance; - } - - bool checkFlag0x88A0(u32 flag) const { - return (field_0x88A0 & flag) != 0; - } - - void initUnkWithWater(u32 val, UnkWithWater *waterThing); - void destroyUnkWithWater(u32 val, UnkWithWater *waterThing); - -private: - static dStageMgr_c *sInstance; - - /* 0x0068 */ u8 _0x0068[0x88A0 - 0x0068]; - /* 0x88A0 */ u32 field_0x88A0; -}; - -#endif diff --git a/src/d/col/cc/d_cc_s.cpp b/src/d/col/cc/d_cc_s.cpp index 01f1d9e2..120ee9f0 100644 --- a/src/d/col/cc/d_cc_s.cpp +++ b/src/d/col/cc/d_cc_s.cpp @@ -4,9 +4,9 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/col/c/c_cc_d.h" #include "d/col/c/c_m3d_g_aab.h" +#include "d/d_stage_mgr.h" #include "f/f_base.h" #include "rvl/MTX/mtx.h" -#include "toBeSorted/stage_manager.h" dCcS *dCcS::sInstance; @@ -168,7 +168,6 @@ void dCcS::ClearArea() { mAreaCount = 0; } - extern "C" bool fn_8019A7A0(void *stg, f32 *, f32 *); void dCcS::AdjustHitPos() { f32 x, z; diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index 8d486c1a..7b466eab 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -9,6 +9,7 @@ #include "d/col/bg/d_bg_w_kcol.h" #include "d/d_sc_game.h" #include "d/d_stage.h" +#include "d/d_stage_mgr.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" #include "d/t/d_t_mass_obj.h" @@ -36,7 +37,6 @@ #include "nw4r/math/math_types.h" #include "sized_string.h" #include "toBeSorted/arc_managers/current_stage_arc_manager.h" -#include "toBeSorted/stage_manager.h" #include "toBeSorted/time_area_mgr.h" #include "toBeSorted/unk_with_water.h" diff --git a/src/d/d_sc_game.cpp b/src/d/d_sc_game.cpp index ce809c76..c0948c6e 100644 --- a/src/d/d_sc_game.cpp +++ b/src/d/d_sc_game.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/d_base.h" +#include "d/d_stage_mgr.h" #include "d/flag/storyflag_manager.h" #include "f/f_base.h" #include "f/f_profile_name.h" @@ -15,7 +16,6 @@ #include "toBeSorted/minigame_mgr.h" #include "toBeSorted/music_mgrs.h" #include "toBeSorted/some_gxf_thing.h" -#include "toBeSorted/stage_manager.h" #include diff --git a/src/d/d_stage_mgr.cpp b/src/d/d_stage_mgr.cpp new file mode 100644 index 00000000..26dd73d9 --- /dev/null +++ b/src/d/d_stage_mgr.cpp @@ -0,0 +1,298 @@ +#include "d/d_stage_mgr.h" + +#include "common.h" +#include "d/d_base.h" +#include "d/d_bzs_types.h" +#include "d/d_heap.h" +#include "d/d_last.h" +#include "d/d_sc_game.h" +#include "d/d_stage_parse.h" +#include "d/d_sys.h" +#include "d/flag/flag_managers.h" +#include "egg/core/eggHeap.h" +#include "f/f_base.h" +#include "f/f_profile_name.h" +#include "m/m_dvd.h" +#include "toBeSorted/arc_managers/current_stage_arc_manager.h" +#include "toBeSorted/arc_managers/layout_arc_manager.h" +#include "toBeSorted/arc_managers/oarc_manager.h" +#include "toBeSorted/music_mgrs.h" +#include + +SPECIAL_BASE_PROFILE(STAGE_MANAGER, dStageMgr_c, fProfile::STAGE_MANAGER, 0X5, 1536); + +STATE_DEFINE(dStageMgr_c, ReadStageRes); +STATE_DEFINE(dStageMgr_c, ReadRoomRes); +STATE_DEFINE(dStageMgr_c, ReadObjectRes); +STATE_DEFINE(dStageMgr_c, ReadStageLayerRes); +STATE_DEFINE(dStageMgr_c, ReadLayerObjectRes); +STATE_DEFINE(dStageMgr_c, SoundLoadSceneData); +STATE_DEFINE(dStageMgr_c, CreateObject); +STATE_DEFINE(dStageMgr_c, ReadObjectSound); +STATE_DEFINE(dStageMgr_c, SceneChangeSave); +STATE_DEFINE(dStageMgr_c, RestartSceneWait); +STATE_DEFINE(dStageMgr_c, RestartScene); + +dStageMgr_c::dStageMgr_c() : mStateMgr(*this, sStateID::null), mPhase(this, sCallbacks) { + sInstance = this; +} + +dStageMgr_c::~dStageMgr_c() { + sInstance = nullptr; +} + +void dStageMgr_c::initializeState_ReadStageRes() { + CurrentStageArcManager::sInstance->setStage(dScGame_c::currentSpawnInfo.stageName); +} + +void dStageMgr_c::executeState_ReadStageRes() { + if (CurrentStageArcManager::sInstance->ensureAllEntriesLoaded() == 0) { + mStateMgr.changeState(StateID_ReadRoomRes); + } +} + +void dStageMgr_c::finalizeState_ReadStageRes() { + void *stageBzs = CurrentStageArcManager::sInstance->getData("dat/stage.bzs"); + if (stageBzs != nullptr) { + parseStageBzs(-1, stageBzs); + parseRoomStageBzs(-1, stageBzs); + } + fn_803618F0(ENEMY_SOUND_MGR); +} + +void dStageMgr_c::initializeState_ReadRoomRes() {} + +void dStageMgr_c::executeState_ReadRoomRes() { + if (CurrentStageArcManager::sInstance->ensureAllEntriesLoaded() == 0 && + LayoutArcManager::sInstance->ensureAllEntriesLoaded() == 0) { + mStateMgr.changeState(StateID_ReadObjectRes); + } +} + +void dStageMgr_c::finalizeState_ReadRoomRes() { + if (rmpl != nullptr) { + RMPL *itRmpl = rmpl; + for (int i = 0; i < mRmplCount; itRmpl++, i++) { + void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(itRmpl->roomId, "dat/room.bzs"); + parseRoomStageBzs(itRmpl->roomId, bzs); + } + } else { + u32 roomId = dScGame_c::currentSpawnInfo.room; + void *bzs = + CurrentStageArcManager::sInstance->loadFromRoomArc(dScGame_c::currentSpawnInfo.room, "dat/room.bzs"); + parseRoomStageBzs(roomId, bzs); + } +} + +void dStageMgr_c::initializeState_ReadObjectRes() { + mStageObjCtrl.doLoad(); +} + +void dStageMgr_c::executeState_ReadObjectRes() { + if (mStageObjCtrl.isLoaded()) { + mStateMgr.changeState(StateID_ReadStageLayerRes); + } +} + +void dStageMgr_c::finalizeState_ReadObjectRes() {} + +void dStageMgr_c::initializeState_ReadStageLayerRes() { + CurrentStageArcManager::sInstance->loadFileFromExtraLayerArc(dScGame_c::currentSpawnInfo.layer); +} + +void dStageMgr_c::executeState_ReadStageLayerRes() { + if (CurrentStageArcManager::sInstance->ensureAllEntriesLoaded() == 0) { + mStateMgr.changeState(StateID_ReadLayerObjectRes); + } +} + +void dStageMgr_c::finalizeState_ReadStageLayerRes() {} + +const char demoName[] = ""; +static const char *sSeekerStoneLayoutArcs[] = { + "SeekerStone", +}; + +void dStageMgr_c::initializeState_ReadLayerObjectRes() { + mDemoName = demoName; + + void *bzs = CurrentStageArcManager::sInstance->getData("dat/stage.bzs"); + if (bzs != nullptr) { + parseBzsStageRoom(-1, bzs); + } + + if (rmpl != nullptr) { + RMPL *itRmpl = rmpl; + for (int i = 0; i < mRmplCount; itRmpl++, i++) { + void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(itRmpl->roomId, "dat/room.bzs"); + parseBzsStageRoom(itRmpl->roomId, bzs); + } + } else { + u32 roomId = dScGame_c::currentSpawnInfo.room; + void *bzs = + CurrentStageArcManager::sInstance->loadFromRoomArc(dScGame_c::currentSpawnInfo.room, "dat/room.bzs"); + parseBzsStageRoom(roomId, bzs); + } + + if (dScGame_c::isStateLayerWithSeekerStoneHintMenu()) { + mLayoutArcCtrl2.set(sSeekerStoneLayoutArcs, ARRAY_LENGTH(sSeekerStoneLayoutArcs)); + mLayoutArcCtrl2.load(dHeap::work2Heap.heap); + addActorId(fProfile::LYT_SEEKER_STONE); + } + mLayerObjCtrl.doLoad(); +} + +void dStageMgr_c::executeState_ReadLayerObjectRes() { + if (mLayerObjCtrl.isLoaded() && LayoutArcManager::sInstance->ensureAllEntriesLoaded() == 0) { + mStateMgr.changeState(StateID_SoundLoadSceneData); + } +} + +extern "C" void fn_800C85D0(void *, EGG::Heap *heap, bool, void *jpc, void *jpn); +extern "C" void *FOR_LOADED_PARTICLES; + +void dStageMgr_c::finalizeState_ReadLayerObjectRes() { + if (mDemoName.len() != 0) { + const char *name = mDemoName; + void *jpc = OarcManager::sInstance->getSubEntryData(name, "dat/jparticle.jpc"); + if (jpc != nullptr) { + void *jpn = OarcManager::sInstance->getSubEntryData(name, "dat/jparticle.jpn"); + fn_800C85D0(FOR_LOADED_PARTICLES, dHeap::work2Heap.heap, true, jpc, jpn); + } + } +} + +static void *soundCallback(void *arg) { + fn_80362730(ENEMY_SOUND_MGR); + return reinterpret_cast(true); +} + +void dStageMgr_c::initializeState_SoundLoadSceneData() { + fn_803624F0(ENEMY_SOUND_MGR); + mpDvdCallback = mDvd_callback_c::createOrDie(soundCallback, nullptr); +} + +void dStageMgr_c::executeState_SoundLoadSceneData() { + if (mpDvdCallback != nullptr && mpDvdCallback->mStatus != 0) { + mStateMgr.changeState(StateID_CreateObject); + } +} + +void dStageMgr_c::finalizeState_SoundLoadSceneData() { + mpDvdCallback->do_delete(); + mpDvdCallback = nullptr; +} + +void dStageMgr_c::initializeState_CreateObject() { + // too much egg +} + +void dStageMgr_c::executeState_CreateObject() { + if (!checkChildProcessCreateState()) { + mStateMgr.changeState(StateID_ReadObjectSound); + } +} + +void dStageMgr_c::finalizeState_CreateObject() {} + +static void *soundCallback2(void *arg) { + fn_80365D20(ENEMY_SOUND_MGR); + return reinterpret_cast(true); +} + +void dStageMgr_c::initializeState_ReadObjectSound() { + mpDvdCallback2 = mDvd_callback_c::createOrDie(soundCallback2, nullptr); +} + +void dStageMgr_c::executeState_ReadObjectSound() { + if (mpDvdCallback2 == nullptr) { + return; + } + + if (mpDvdCallback2->mStatus == 0) { + return; + } + + if (dScGame_c::sInstance != nullptr) { + if (dScGame_c::sInstance->savePromptFlag() == true) { + mStateMgr.changeState(StateID_SceneChangeSave); + } else { + mStateMgr.changeState(StateID_RestartSceneWait); + } + return; + } + + mStateMgr.changeState(StateID_RestartSceneWait); +} + +void dStageMgr_c::finalizeState_ReadObjectSound() { + mpDvdCallback2->do_delete(); + // mpDvdCallback2 = nullptr; + clearProcControlFlag(ROOT_DISABLE_EXECUTE); + clearProcControlFlag(ROOT_DISABLE_DRAW); + dLast_c::setExecuteCallback(lastExecuteCallback); +} + +extern "C" void *LYT_SAVE_MGR; +extern "C" void fn_80285600(void*, int, int); +void dStageMgr_c::initializeState_SceneChangeSave() { + dScGame_c::sInstance->setSavePromptFlag(false); + if (LYT_SAVE_MGR != nullptr) { + fn_80285600(LYT_SAVE_MGR, 3, 0); + } + dBase_c::s_NextExecuteControlFlags |= 1; + dSys::setFrameRate(2); +} + +void dStageMgr_c::executeState_SceneChangeSave() { + if (LYT_SAVE_MGR != nullptr) { + // "isNotSaving???" + if (((u8*)LYT_SAVE_MGR)[0x119C] == true) { + mStateMgr.changeState(StateID_RestartSceneWait); + } + } else { + mStateMgr.changeState(StateID_RestartSceneWait); + } +} + +void dStageMgr_c::finalizeState_SceneChangeSave() { + dBase_c::s_NextExecuteControlFlags &= ~1; + dBase_c::s_DrawControlFlags &= ~1; +} + +void dStageMgr_c::initializeState_RestartSceneWait() { + dSys::setFrameRate(2); +} + +void dStageMgr_c::executeState_RestartSceneWait() { + if (mFader.isSettled()) { + if (mFader.isStatus(mFaderBase_c::FADED_IN)) { + if (field_0x88BC) { + mStateMgr.changeState(StateID_RestartScene); + } + } else { + mFader.fadeIn(); + } + // TODO + mFader.calc(); + } +} + +void dStageMgr_c::finalizeState_RestartSceneWait() {} + +void dStageMgr_c::initializeState_RestartScene() { + triggerFade(dScGame_c::nextSpawnInfo.transitionType, dScGame_c::nextSpawnInfo.transitionFadeFrames); + mFader.setFadeInType(dScGame_c::nextSpawnInfo.transitionType); + fn_803625F0(ENEMY_SOUND_MGR, mFader.getFadeOutFrame()); +} + +void dStageMgr_c::executeState_RestartScene() { + if (mFader.isStatus(mFaderBase_c::FADED_OUT)) { + + } +} + +void dStageMgr_c::finalizeState_RestartScene() { + commitAllFlagManagers(); + dSys::setFrameRate(1); +} diff --git a/src/d/lyt/meter/d_lyt_meter.cpp b/src/d/lyt/meter/d_lyt_meter.cpp index 302892bd..2f6bcfbc 100644 --- a/src/d/lyt/meter/d_lyt_meter.cpp +++ b/src/d/lyt/meter/d_lyt_meter.cpp @@ -2,11 +2,11 @@ #include "common.h" #include "d/d_sc_game.h" #include "d/d_sc_title.h" +#include "d/d_stage_mgr.h" #include "d/lyt/d_lyt_area_caption.h" #include "d/lyt/d_lyt_meter_configuration.h" #include "d/lyt/d_window.h" #include "d/lyt/meter/d_lyt_meter.h" -#include "toBeSorted/stage_manager.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" // clang-format on From 7225fbe4ff16f947701be7a0fd19837732df6369 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 16:39:21 +0100 Subject: [PATCH 06/11] d_stage_parse ok --- config/SOUE01/splits.txt | 5 +- config/SOUE01/symbols.txt | 122 +++---- configure.py | 2 +- include/d/a/obj/d_a_obj_base.h | 8 +- include/d/d_bzs_types.h | 43 ++- include/d/d_room.h | 145 ++++++--- include/d/d_sc_game.h | 30 +- include/d/d_stage.h | 3 + include/d/d_stage_mgr.h | 59 +++- include/d/d_stage_parse.h | 13 +- include/toBeSorted/file_manager.h | 4 +- src/d/d_sc_game.cpp | 4 +- src/d/d_stage.cpp | 11 +- src/d/d_stage_mgr.cpp | 29 +- src/d/d_stage_parse.cpp | 523 ++++++++++++++++++++++++++++++ src/toBeSorted/file_manager.cpp | 4 +- 16 files changed, 852 insertions(+), 153 deletions(-) create mode 100644 src/d/d_stage_parse.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 3b37935b..30f421e5 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -155,7 +155,10 @@ d/d_scene.cpp: .bss start:0x805A06F0 end:0x805A0720 d/d_stage_parse.cpp: - .text start:0x80062E40 end:0x80064250 + .text start:0x80062ED0 end:0x8006424C + .rodata start:0x804E0B38 end:0x804E0C98 + .data start:0x8050DE48 end:0x8050DE58 + .sdata2 start:0x80577920 end:0x80577928 d/d_sys.cpp: .text start:0x80064250 end:0x80064920 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index cf2428cb..a6e63f0d 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -379,7 +379,7 @@ getNightT1__11FileManagerFv = .text:0x8000CA00; // type:function size:0x44 setNightT3__11FileManagerFb = .text:0x8000CA50; // type:function size:0x30 getNightT3__11FileManagerFv = .text:0x8000CA80; // type:function size:0x44 isNew_FileA__11FileManagerFv = .text:0x8000CAD0; // type:function size:0x24 -setSceneFlagIndex__11FileManagerFUs = .text:0x8000CB00; // type:function size:0x30 +setSceneFlagIndex__11FileManagerFs = .text:0x8000CB00; // type:function size:0x30 getSceneFlagIndex__11FileManagerFv = .text:0x8000CB30; // type:function size:0x44 getFileAreaIndex__11FileManagerFv = .text:0x8000CB80; // type:function size:0x44 fn_8000CBD0__11FileManagerFUc = .text:0x8000CBD0; // type:function size:0x30 @@ -1118,8 +1118,8 @@ postExecute__12dAcObjBase_cFQ27fBase_c12MAIN_STATE_e = .text:0x8002E2A0; // type preDraw__12dAcObjBase_cFv = .text:0x8002E330; // type:function size:0x27C getObjectListEntry__12dAcObjBase_cFv = .text:0x8002E5B0; // type:function size:0x8 restorePosRotFromCopy__12dAcObjBase_cFv = .text:0x8002E5C0; // type:function size:0x70 -create__12dAcObjBase_cFQ28fProfile14PROFILE_NAME_eUlUlP7mVec3_cP7mAng3_cP7mVec3_cUl = .text:0x8002E630; // type:function size:0x98 -create__12dAcObjBase_cFPcUlUlP7mVec3_cP7mAng3_cP7mVec3_cUlUsSc = .text:0x8002E6D0; // type:function size:0xA0 +create__12dAcObjBase_cFQ28fProfile14PROFILE_NAME_eUlUlPC7mVec3_cPC7mAng3_cPC7mVec3_cUl = .text:0x8002E630; // type:function size:0x98 +create__12dAcObjBase_cFPCcUlUlPC7mVec3_cPC7mAng3_cPC7mVec3_cUlUsSc = .text:0x8002E6D0; // type:function size:0xA0 ActorObjectBase__findObject = .text:0x8002E770; // type:function size:0x7C getNextObject__12dAcObjBase_cFP9fLiMgBa_cP12dAcObjBase_c = .text:0x8002E7F0; // type:function size:0x58 isPlayer__12dAcObjBase_cFv = .text:0x8002E850; // type:function size:0x14 @@ -1144,7 +1144,7 @@ fn_8002EFA0 = .text:0x8002EFA0; // type:function size:0x50 fn_8002EFF0 = .text:0x8002EFF0; // type:function size:0x194 fn_8002F190 = .text:0x8002F190; // type:function size:0x24 createActorUnkGroup3__12dAcObjBase_cFQ28fProfile14PROFILE_NAME_eUlUlP7mVec3_cP7mAng3_cP7mVec3_cUl = .text:0x8002F1C0; // type:function size:0x98 -fn_8002F260 = .text:0x8002F260; // type:function size:0xA0 +createActorUnkGroup3__12dAcObjBase_cFPCcUlUlPC7mVec3_cPC7mAng3_cPC7mVec3_cUlUsSc = .text:0x8002F260; // type:function size:0xA0 __ct__11dAcEnBase_cFv = .text:0x8002F300; // type:function size:0x74 ActorEnemyBase__dtor = .text:0x8002F380; // type:function size:0x74 ActorEnemyBase__shouldUpdateMaybe = .text:0x8002F400; // type:function size:0xB4 @@ -2784,44 +2784,44 @@ fn_80062E40 = .text:0x80062E40; // type:function size:0x4 fn_80062E50 = .text:0x80062E50; // type:function size:0x60 fn_80062EB0 = .text:0x80062EB0; // type:function size:0x4 fn_80062EC0 = .text:0x80062EC0; // type:function size:0x4 -parseBzsPcam = .text:0x80062ED0; // type:function size:0x1C -parseBzsLyse = .text:0x80062EF0; // type:function size:0x20 -parseBzsStif = .text:0x80062F10; // type:function size:0x54 -parseBzsRmpl = .text:0x80062F70; // type:function size:0x1C -fn_80062F90 = .text:0x80062F90; // type:function size:0x54 -parseBzsLylt = .text:0x80062FF0; // type:function size:0xD8 +handleBzsPcam__FiPC14BzsSectionHead = .text:0x80062ED0; // type:function size:0x1C +handleBzsLyse__FiPC14BzsSectionHead = .text:0x80062EF0; // type:function size:0x20 +handleBzsStif__FiPC14BzsSectionHead = .text:0x80062F10; // type:function size:0x54 +handleBzsRmpl__FiPC14BzsSectionHead = .text:0x80062F70; // type:function size:0x1C +handleBzsFile__FiPC14BzsSectionHead = .text:0x80062F90; // type:function size:0x54 +handleBzsLylt__FiPC14BzsSectionHead = .text:0x80062FF0; // type:function size:0xD8 sprintf__15SizedString<16>FPCce = .text:0x800630D0; // type:function size:0xD0 -parseBzsScen = .text:0x800631A0; // type:function size:0x54 -parseBzsCam = .text:0x80063200; // type:function size:0x54 -parseBzsEvnt = .text:0x80063260; // type:function size:0x54 -parseBzsPath = .text:0x800632C0; // type:function size:0x54 -parseBzsPnt = .text:0x80063320; // type:function size:0x54 -parseBzsBpnt = .text:0x80063380; // type:function size:0x54 -parseBzsSpth = .text:0x800633E0; // type:function size:0x54 -fn_80063440 = .text:0x80063440; // type:function size:0x54 -fn_800634A0 = .text:0x800634A0; // type:function size:0x54 -parseBzsArea = .text:0x80063500; // type:function size:0x54 -parseBzsPlyAndAlsoSpawnLink = .text:0x80063560; // type:function size:0x330 -parseBzsObjn = .text:0x80063890; // type:function size:0x78 -parseBzsArcn = .text:0x80063910; // type:function size:0x78 -parseBzsObjn2 = .text:0x80063990; // type:function size:0x84 -parseBzsArcn2 = .text:0x80063A20; // type:function size:0x78 -getEnemyDefeatFlagFromId = .text:0x80063AA0; // type:function size:0x3C -getViewClipIndexFromId = .text:0x80063AE0; // type:function size:0x1C -parseBzsObj = .text:0x80063B00; // type:function size:0xB8 -parseBzsSobj = .text:0x80063BC0; // type:function size:0xB8 -parseBzsStas = .text:0x80063C80; // type:function size:0xB8 -fn_80063D40 = .text:0x80063D40; // type:function size:0x78 -parseBzsLay = .text:0x80063DC0; // type:function size:0x80 -fn_80063E40 = .text:0x80063E40; // type:function size:0x80 -fn_80063EC0 = .text:0x80063EC0; // type:function size:0x80 -findAndRunStageTagParseFunc = .text:0x80063F40; // type:function size:0x48 -parseRoomStageBzs = .text:0x80063F90; // type:function size:0x70 -parseBzsStageRoom = .text:0x80064000; // type:function size:0x70 -parseStageBzs = .text:0x80064070; // type:function size:0x7C -parseRoomBzs = .text:0x800640F0; // type:function size:0x70 -fn_80064160 = .text:0x80064160; // type:function size:0x70 -fn_800641D0 = .text:0x800641D0; // type:function size:0x7C +handleBzsScen__FiPC14BzsSectionHead = .text:0x800631A0; // type:function size:0x54 +handleBzsCam__FiPC14BzsSectionHead = .text:0x80063200; // type:function size:0x54 +handleBzsEvnt__FiPC14BzsSectionHead = .text:0x80063260; // type:function size:0x54 +handleBzsPath__FiPC14BzsSectionHead = .text:0x800632C0; // type:function size:0x54 +handleBzsPnt__FiPC14BzsSectionHead = .text:0x80063320; // type:function size:0x54 +handleBzsBpnt__FiPC14BzsSectionHead = .text:0x80063380; // type:function size:0x54 +handleBzsSpth__FiPC14BzsSectionHead = .text:0x800633E0; // type:function size:0x54 +handleBzsSpnt__FiPC14BzsSectionHead = .text:0x80063440; // type:function size:0x54 +handleBzsSbpt__FiPC14BzsSectionHead = .text:0x800634A0; // type:function size:0x54 +handleBzsArea__FiPC14BzsSectionHead = .text:0x80063500; // type:function size:0x54 +handleBzsPly__FiPC14BzsSectionHead = .text:0x80063560; // type:function size:0x330 +handleBzsObjn__FiPC14BzsSectionHead = .text:0x80063890; // type:function size:0x78 +handleBzsArcn__FiPC14BzsSectionHead = .text:0x80063910; // type:function size:0x78 +handleBzsLayerObjn__FiPC14BzsSectionHead = .text:0x80063990; // type:function size:0x84 +handleBzsLayerArcn__FiPC14BzsSectionHead = .text:0x80063A20; // type:function size:0x78 +getEnemyDefeatFlagFromId__FlUs = .text:0x80063AA0; // type:function size:0x3C +getViewClipIndexFromId__FUs = .text:0x80063AE0; // type:function size:0x1C +handleBzsObj__FiPC14BzsSectionHead = .text:0x80063B00; // type:function size:0xB8 +handleBzsSobj__FiPC14BzsSectionHead = .text:0x80063BC0; // type:function size:0xB8 +handleBzsStas__FiPC14BzsSectionHead = .text:0x80063C80; // type:function size:0xB8 +parseLayerBzs__FiUlPC3LAYPC17BzsTagToParseFuncl = .text:0x80063D40; // type:function size:0x78 +handleBzsLay__FiPC14BzsSectionHead = .text:0x80063DC0; // type:function size:0x80 +handleBzsLay2__FiPC14BzsSectionHead = .text:0x80063E40; // type:function size:0x80 +handleBzsLay3__FiPC14BzsSectionHead = .text:0x80063EC0; // type:function size:0x80 +findAndRunStageTagParseFunc__FiPC14BzsSectionHeadPC17BzsTagToParseFuncl = .text:0x80063F40; // type:function size:0x48 +parseRoomStageBzs__FiPCv = .text:0x80063F90; // type:function size:0x70 +parseBzsStageRoom__FiPCv = .text:0x80064000; // type:function size:0x70 +parseStageBzs__FiPCv = .text:0x80064070; // type:function size:0x7C +parseRoomBzs__FiPCv = .text:0x800640F0; // type:function size:0x70 +parseRoomReactivateBzs__FiPCv = .text:0x80064160; // type:function size:0x70 +parseRoomActivateBzs__FiPCv = .text:0x800641D0; // type:function size:0x7C dSys_c__initAudioMgr = .text:0x80064250; // type:function size:0xB0 dSys_c__beginRender = .text:0x80064300; // type:function size:0x38 dSys_c__endRender = .text:0x80064340; // type:function size:0x18 @@ -10552,10 +10552,10 @@ changeState__80sStateMgr_c<11dStageMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,1 fn_80199000 = .text:0x80199000; // type:function size:0x110 fn_80199110 = .text:0x80199110; // type:function size:0x8 fn_80199120 = .text:0x80199120; // type:function size:0x10 -StageManager__addObjnId = .text:0x80199130; // type:function size:0x8 -StageManager__addStageArcn = .text:0x80199140; // type:function size:0x8 -StageManager__addActorId = .text:0x80199150; // type:function size:0x8 -StageManager__addLayerArcn = .text:0x80199160; // type:function size:0x8 +addObjId__11dStageMgr_cFUs = .text:0x80199130; // type:function size:0x8 +addStageArcn__11dStageMgr_cFPCc = .text:0x80199140; // type:function size:0x8 +addActorId__11dStageMgr_cFUs = .text:0x80199150; // type:function size:0x8 +addLayerArcn__11dStageMgr_cFPCc = .text:0x80199160; // type:function size:0x8 initUnkWithWater__11dStageMgr_cFUlP12UnkWithWater = .text:0x80199170; // type:function size:0x18 destroyUnkWithWater__11dStageMgr_cFUlP12UnkWithWater = .text:0x80199190; // type:function size:0x18 fn_801991B0 = .text:0x801991B0; // type:function size:0xA0 @@ -10565,9 +10565,9 @@ fn_80199400 = .text:0x80199400; // type:function size:0xE8 fn_801994F0 = .text:0x801994F0; // type:function size:0x4 triggerEntranceRestart = .text:0x80199500; // type:function size:0x40 getPCAMfromId = .text:0x80199540; // type:function size:0x34 -StageManager__overrideLayer0WithLyse = .text:0x80199580; // type:function size:0xF8 -StageManager__setSTIF = .text:0x80199680; // type:function size:0x1AC -StageManager__getFlagindex = .text:0x80199830; // type:function size:0x2C +overrideLayer0WithLyse__11dStageMgr_cFv = .text:0x80199580; // type:function size:0xF8 +setStif__11dStageMgr_cFPC4STIF = .text:0x80199680; // type:function size:0x1AC +getFlagIndex__11dStageMgr_cCFv = .text:0x80199830; // type:function size:0x2C getAreaType__11dStageMgr_cCFv = .text:0x80199860; // type:function size:0x1C StageManager__isAreaTypeNormal = .text:0x80199880; // type:function size:0x28 isAreaTypeDungeon__11dStageMgr_cCFv = .text:0x801998B0; // type:function size:0x2C @@ -10965,7 +10965,7 @@ createRooms__8dStage_cFv = .text:0x801B3730; // type:function size:0x200 waitForRooms__8dStage_cFv = .text:0x801B3930; // type:function size:0x30 setRoom__8dStage_cFiP7dRoom_c = .text:0x801B3960; // type:function size:0x10 getRoom__8dStage_cFl = .text:0x801B3970; // type:function size:0x10 -RoomManager__handleRoomChangeMaybe = .text:0x801B3980; // type:function size:0x114 +handleRoomChange__8dStage_cFi = .text:0x801B3980; // type:function size:0x114 RoomManager__updateRoomFlags = .text:0x801B3AA0; // type:function size:0x134 RoomManager__checkOtherRoomLoaded = .text:0x801B3BE0; // type:function size:0x78 fn_801B3C60 = .text:0x801B3C60; // type:function size:0x9C @@ -10990,7 +10990,7 @@ getMA0AnmTexSrt__8dStage_cFPQ34nw4r3g3d12ResAnmTexSrtPCc = .text:0x801B4380; // getMA0IndirectSrt__8dStage_cFPQ34nw4r3g3d12ResAnmTexSrtRCQ34nw4r3g3d6ResMdl = .text:0x801B4420; // type:function size:0x9C changeLoadedEntities__8dStage_cFUlb = .text:0x801B44C0; // type:function size:0x50 RoomManager__checkRoomFlag = .text:0x801B4510; // type:function size:0x3C -RoomManager__checkEnemyDefeatFlag = .text:0x801B4550; // type:function size:0x6C +checkEnemyDefeatFlag__8dStage_cFUs = .text:0x801B4550; // type:function size:0x6C fn_801B45C0 = .text:0x801B45C0; // type:function size:0xAC __ct__12dRoomTable_cFv = .text:0x801B4670; // type:function size:0x110 __ct__10MapRelatedFv = .text:0x801B4780; // type:function size:0x180 @@ -11038,7 +11038,7 @@ doDelete__7dRoom_cFv = .text:0x801B65F0; // type:function size:0x74 execute__7dRoom_cFv = .text:0x801B6670; // type:function size:0x140 executeState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B67B0; // type:function size:0x10 draw__7dRoom_cFv = .text:0x801B67C0; // type:function size:0x84 -dRoom__getEntranceById = .text:0x801B6850; // type:function size:0x34 +getEntranceById__7dRoom_cCFUc = .text:0x801B6850; // type:function size:0x34 fn_801B6890 = .text:0x801B6890; // type:function size:0x10 RoomManager__getEVNTForIndex = .text:0x801B68A0; // type:function size:0x10 deactivateUpdatesCb__FP9dAcBase_c = .text:0x801B68B0; // type:function size:0x20 @@ -28179,14 +28179,14 @@ lbl_804E0AE4 = .rodata:0x804E0AE4; // type:object size:0x14 lbl_804E0AF8 = .rodata:0x804E0AF8; // type:object size:0x14 lbl_804E0B0C = .rodata:0x804E0B0C; // type:object size:0x14 data:float lbl_804E0B20 = .rodata:0x804E0B20; // type:object size:0x18 data:float -lbl_804E0B38 = .rodata:0x804E0B38; // type:object size:0x10 -lbl_804E0B48 = .rodata:0x804E0B48; // type:object size:0x18 -lbl_804E0B60 = .rodata:0x804E0B60; // type:object size:0x30 -lbl_804E0B90 = .rodata:0x804E0B90; // type:object size:0x70 -lbl_804E0C00 = .rodata:0x804E0C00; // type:object size:0x10 -lbl_804E0C10 = .rodata:0x804E0C10; // type:object size:0x10 -lbl_804E0C20 = .rodata:0x804E0C20; // type:object size:0x60 -lbl_804E0C80 = .rodata:0x804E0C80; // type:object size:0x18 +layerHandlers = .rodata:0x804E0B38; // type:object size:0x10 +layerHandlers2 = .rodata:0x804E0B48; // type:object size:0x18 +layerHandlers3 = .rodata:0x804E0B60; // type:object size:0x30 +defaultHandlers = .rodata:0x804E0B90; // type:object size:0x70 +roomStageHandlers = .rodata:0x804E0C00; // type:object size:0x10 +stageRoomHandlers = .rodata:0x804E0C10; // type:object size:0x10 +roomHandlers = .rodata:0x804E0C20; // type:object size:0x60 +roomReactivateHandlers = .rodata:0x804E0C80; // type:object size:0x18 lbl_804E0C98 = .rodata:0x804E0C98; // type:object size:0x3C lbl_804E0CD4 = .rodata:0x804E0CD4; // type:object size:0x3C lbl_804E0D10 = .rodata:0x804E0D10; // type:object size:0x3C @@ -30778,7 +30778,7 @@ lbl_8050DDB8 = .data:0x8050DDB8; // type:object size:0x20 @4669 = .data:0x8050DDD8; // type:object size:0xE scope:local data:string @4670 = .data:0x8050DDE8; // type:object size:0xB scope:local data:string __vt__8dScene_c = .data:0x8050DDF8; // type:object size:0x4C -lbl_8050DE48 = .data:0x8050DE48; // type:object size:0x10 +lbl_8050DE48 = .data:0x8050DE48; // type:object size:0xE data:string lbl_8050DE58 = .data:0x8050DE58; // type:object size:0x5C lbl_8050DEB4 = .data:0x8050DEB4; // type:object size:0x10 lbl_8050DEC4 = .data:0x8050DEC4; // type:object size:0x10 @@ -41981,7 +41981,7 @@ lbl_8057790E = .sdata2:0x8057790E; // type:object size:0x2 data:2byte lbl_80577910 = .sdata2:0x80577910; // type:object size:0x4 data:float lbl_80577914 = .sdata2:0x80577914; // type:object size:0x4 data:float lbl_80577918 = .sdata2:0x80577918; // type:object size:0x8 data:float -lbl_80577920 = .sdata2:0x80577920; // type:object size:0x8 +roomActivateHandlers = .sdata2:0x80577920; // type:object size:0x8 lbl_80577928 = .sdata2:0x80577928; // type:object size:0x4 data:float lbl_8057792C = .sdata2:0x8057792C; // type:object size:0x4 data:float lbl_80577930 = .sdata2:0x80577930; // type:object size:0x8 data:double diff --git a/configure.py b/configure.py index fe71ad1b..16e3edfc 100644 --- a/configure.py +++ b/configure.py @@ -340,7 +340,7 @@ config.libs = [ Object(Matching, "d/d_heap.cpp"), Object(Matching, "d/d_rawarchive.cpp"), Object(Matching, "d/d_scene.cpp"), - Object(NonMatching, "d/d_stage_parse.cpp"), + Object(Matching, "d/d_stage_parse.cpp"), Object(NonMatching, "d/d_sys.cpp"), Object(NonMatching, "toBeSorted/sound_info.cpp"), Object(Matching, "toBeSorted/arc_callback_handler.cpp"), diff --git a/include/d/a/obj/d_a_obj_base.h b/include/d/a/obj/d_a_obj_base.h index 78d72533..4ce988b2 100644 --- a/include/d/a/obj/d_a_obj_base.h +++ b/include/d/a/obj/d_a_obj_base.h @@ -160,11 +160,11 @@ public: public: /* 8002e630 */ static dAcObjBase_c *create( - fProfile::PROFILE_NAME_e actorId, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, + fProfile::PROFILE_NAME_e actorId, u32 roomId, u32 params1, const mVec3_c *pos, const mAng3_c *rot, const mVec3_c *scale, u32 params2 ); /* 8002e6d0 */ static dAcObjBase_c *create( - char *name, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2, u16 id, + const char *name, u32 roomId, u32 params1, const mVec3_c *pos, const mAng3_c *rot, const mVec3_c *scale, u32 params2, u16 id, s8 viewclipId ); /* 8002e770 */ static dAcObjBase_c * @@ -208,8 +208,8 @@ public: u32 params2 ); /* 8002f260 */ static dAcBase_c *createActorUnkGroup3( - char *name, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2, u16 id, - u8 viewclipId + const char *name, u32 roomId, u32 params1, const mVec3_c *pos, const mAng3_c *rot, const mVec3_c *scale, + u32 params2, u16 id, s8 viewclipId ); }; diff --git a/include/d/d_bzs_types.h b/include/d/d_bzs_types.h index afba4360..0ff841ba 100644 --- a/include/d/d_bzs_types.h +++ b/include/d/d_bzs_types.h @@ -5,6 +5,12 @@ #include "m/m_angle.h" #include "m/m_vec.h" +// https://github.com/lepelog/skywardsword-tools/blob/master/bzs.py + +// Size 0x2 +struct ARCN { + /* 0x00 */ u16 offset; +}; // Size 0x20 struct AREA { @@ -53,11 +59,21 @@ struct EVNT { /* 0x18 */ char name[32]; }; +// Size 0x??? +struct bzsFILE { + // ??? +}; + +struct LAY { + /* 0x00 */ u16 mCount; + /* 0x04 */ u32 mOffset; +}; + // Size 0x04 struct LYLT { /* 0x0 */ u8 layer; - /* 0x1 */ u8 demoHigh; - /* 0x2 */ u8 demoLow; + /* 0x1 */ s8 demoHigh; + /* 0x2 */ s8 demoLow; /* 0x3 */ u8 dummy; }; @@ -78,6 +94,11 @@ struct OBJ { /* 0x1C */ char name[8]; }; +// Size 0x2 +struct OBJN { + /* 0x00 */ u16 offset; +}; + // Size 0xC struct PATH { /* 0x00 */ u8 field_0x00; @@ -101,9 +122,12 @@ struct PCAM { // Size 0x18 struct PLY { - /* 0x00 */ u16 storyFlag; - /* 0x02 */ u8 playCutscene; - /* 0x03 */ u8 _0x03[1]; + // The Ghidra struct seems to overambitiously encode + // the params themselves, this is just an u32 link actor params + // /* 0x00 */ u16 storyFlag; + // /* 0x02 */ u8 playCutscene; + // /* 0x03 */ u8 _0x03[1]; + /* 0x00 */ u32 linkParams; /* 0x04 */ mVec3_c position; /* 0x10 */ mAng3_c angle; /* 0x16 */ u16 entranceId; @@ -146,6 +170,15 @@ struct SOBJ { /* 0x28 */ char name[8]; }; +// Size 0x??? +struct SBPT { + // ??? +}; + +// Parsed the same way in ss-tools +typedef PNT SPNT; +typedef PATH SPTH; + // Size 0x14 struct STIF { /* 0x00 */ f32 field_0x00; diff --git a/include/d/d_room.h b/include/d/d_room.h index 2519dc01..37e2fc64 100644 --- a/include/d/d_room.h +++ b/include/d/d_room.h @@ -115,24 +115,24 @@ class dRoom_c : public dBase_c { public: dRoom_c() : mStateMgr(*this, sStateID::null), - field_0x15C(nullptr), - scen(nullptr), - ply(nullptr), - cam(nullptr), - evnt(nullptr), - path(nullptr), - pnt(nullptr), - bpnt(nullptr), - AREA(nullptr), - unkCount(0), - scenCount(0), - plyCount(0), - camCount(0), - evntCount(0), - pathCount(0), - pntCount(0), - bpntCount(0), - areaCount(0), + mpFile(nullptr), + mpScen(nullptr), + mpPly(nullptr), + mpCam(nullptr), + mpEvnt(nullptr), + mpPath(nullptr), + mpPnt(nullptr), + mpBpnt(nullptr), + mpArea(nullptr), + mFileCount(0), + mScenCount(0), + mPlyCount(0), + mCamCount(0), + mEvntCount(0), + mPathCount(0), + mPntCount(0), + mBpntCount(0), + mAreaCount(0), mFlags(0) {} virtual ~dRoom_c() {} @@ -150,6 +150,7 @@ public: void drawOnMapIfVisible(mMtx_c *mtx, int param); void getBounds(mVec3_c *min, mVec3_c *max) const; + const PLY *getEntranceById(u8 id) const; void someLastBossThing(bool arg); f32 getFrame() const; @@ -157,6 +158,66 @@ public: typedef void (*foreachObjCallback)(dAcBase_c *obj); s32 foreachObject(foreachObjCallback cb); + void setFile(const bzsFILE *file, u16 count) { + mFileCount = count; + mpFile = file; + } + + void setScen(const SCEN *scen, u16 count) { + mScenCount = count; + mpScen = scen; + } + + void setCam(const CAM *file, u16 count) { + mCamCount = count; + mpCam = file; + } + + void setEvnt(const EVNT *evnt, u16 count) { + mEvntCount = count; + mpEvnt = evnt; + } + + void setPath(const PATH *path, u16 count) { + mPathCount = count; + mpPath = path; + } + + void setPnt(const PNT *pnt, u16 count) { + mPntCount = count; + mpPnt = pnt; + } + + void setBpnt(const BPNT *bpnt, u16 count) { + mBpntCount = count; + mpBpnt = bpnt; + } + + void setSpth(const SPTH *spth, u16 count) { + mSpthCount = count; + mpSpth = spth; + } + + void setSpnt(const SPNT *spnt, u16 count) { + mSpntCount = count; + mpSpnt = spnt; + } + + void setSbpt(const SBPT *sbpt, u16 count) { + mSbptCount = count; + mpSbpt = sbpt; + } + + void setArea(const AREA *path, u16 count) { + mAreaCount = count; + mpArea = path; + } + + void setPly(const PLY *ply, u16 count) { + mPlyCount = count; + mpPly = ply; + } + private: bool setupBg(); void executeBg(); @@ -175,30 +236,30 @@ private: /* 0x220 */ dBgWKCol mBg[2]; /* 0x4E0 */ STATE_MGR_DECLARE(dRoom_c); - /* 0x51C */ void *field_0x15C; - /* 0x520 */ SCEN *scen; - /* 0x524 */ PLY *ply; - /* 0x528 */ CAM *cam; - /* 0x52C */ EVNT *evnt; - /* 0x530 */ PATH *path; - /* 0x534 */ PNT *pnt; - /* 0x538 */ BPNT *bpnt; - /* 0x53C */ PATH *spth; - /* 0x540 */ void *field_0x540; - /* 0x544 */ void *field_0x544; - /* 0x548 */ AREA *AREA; - /* 0x54C */ u16 unkCount; - /* 0x54E */ u16 scenCount; - /* 0x550 */ u16 plyCount; - /* 0x552 */ u16 camCount; - /* 0x554 */ u16 evntCount; - /* 0x556 */ u16 pathCount; - /* 0x558 */ u16 pntCount; - /* 0x55A */ u16 bpntCount; - /* 0x55C */ u16 spthCount; - /* 0x55E */ u16 unk2Count; - /* 0x560 */ u16 unk3Count; - /* 0x562 */ u16 areaCount; + /* 0x51C */ const bzsFILE *mpFile; + /* 0x520 */ const SCEN *mpScen; + /* 0x524 */ const PLY *mpPly; + /* 0x528 */ const CAM *mpCam; + /* 0x52C */ const EVNT *mpEvnt; + /* 0x530 */ const PATH *mpPath; + /* 0x534 */ const PNT *mpPnt; + /* 0x538 */ const BPNT *mpBpnt; + /* 0x53C */ const SPTH *mpSpth; + /* 0x540 */ const SPNT *mpSpnt; + /* 0x544 */ const SBPT *mpSbpt; + /* 0x548 */ const AREA *mpArea; + /* 0x54C */ u16 mFileCount; + /* 0x54E */ u16 mScenCount; + /* 0x550 */ u16 mPlyCount; + /* 0x552 */ u16 mCamCount; + /* 0x554 */ u16 mEvntCount; + /* 0x556 */ u16 mPathCount; + /* 0x558 */ u16 mPntCount; + /* 0x55A */ u16 mBpntCount; + /* 0x55C */ u16 mSpthCount; + /* 0x55E */ u16 mSpntCount; + /* 0x560 */ u16 mSbptCount; + /* 0x562 */ u16 mAreaCount; // peak vtable placement class UnkRoomClass { diff --git a/include/d/d_sc_game.h b/include/d/d_sc_game.h index 67099a2d..49f4cca3 100644 --- a/include/d/d_sc_game.h +++ b/include/d/d_sc_game.h @@ -59,7 +59,7 @@ struct SpawnInfo { /* 0x20 */ u16 transitionFadeFrames; /* 0x22 */ u8 room; /* 0x23 */ u8 layer; - /* 0x24 */ s8 entrance; + /* 0x24 */ u8 entrance; /* 0x25 */ u8 night; /* 0x26 */ u8 trial; /* 0x27 */ u8 transitionType; @@ -104,13 +104,13 @@ struct SpawnInfoExt : public SpawnInfo { struct LinkReloadInfo { LinkReloadInfo() : mType0CsFlag(0) {} - void set(u8 roomid, const mVec3_c &pos, mAng rot, u32 flags); + void set(u8 roomid, const mVec3_c &pos, mAng rot, u32 linkParams); /* 0x00 */ mVec3_c mPosition; /* 0x0C */ mAng mRotY; /* 0x0E */ u8 mRoomId; /* 0x0F */ u8 mType0CsFlag; - /* 0x10 */ u32 mUnkFlags; + /* 0x10 */ u32 mLinkParams; }; class dScGame_c : public dScene_c { @@ -166,6 +166,30 @@ public: mSavePromptFlag = val; } + u8 getType0CsFlag() const { + return mReloadInfo.mType0CsFlag; + } + + void setType0CsFlag(u8 flag) { + mReloadInfo.mType0CsFlag = flag; + } + + u8 getType0PosFlag() const { + return mType0PosFlag; + } + + void setType0PosFlag(u8 flag) { + mType0PosFlag = flag; + } + + static u8 getReloaderType() { + return sReloaderType; + } + + static void setReloaderType(u8 type) { + sReloaderType = type; + } + protected: static u32 sUpdateFrameCount; static u8 sCurrentLayer; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index da4bf0ee..03c27d93 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -122,6 +122,9 @@ public: void drawMap(mMtx_c *mtx, int); dRoom_c *getRoom(s32 idx); void setRoom(int roomid, dRoom_c *room); + void handleRoomChange(int roomid); + + bool checkEnemyDefeatFlag(u16 flag); bool fadeIn(s32 fadeType, u16 frames); bool fadeOut(s32 fadeType, u16 frames); diff --git a/include/d/d_stage_mgr.h b/include/d/d_stage_mgr.h index 7ae15250..bff1d7bf 100644 --- a/include/d/d_stage_mgr.h +++ b/include/d/d_stage_mgr.h @@ -65,10 +65,58 @@ public: void initUnkWithWater(u32 val, UnkWithWater *waterThing); void destroyUnkWithWater(u32 val, UnkWithWater *waterThing); + const RMPL *getRmpl() const { + return mpRmpl; + } + + u16 getRmplCount() const { + return mRmplCount; + } + + void setRmpl(const RMPL *pcam, u16 count) { + mRmplCount = count; + mpRmpl = pcam; + } + + const PCAM *getPcam() const { + return mpPcam; + } + + u16 getPcamCount() const { + return mPcamCount; + } + + void setPcam(const PCAM *pcam, u16 count) { + mPcamCount = count; + mpPcam = pcam; + } + + void setLyse(const LYSE *lyse, u16 count) { + mLyseCount = count; + mpLyse = lyse; + } + + void overrideLayer0WithLyse(); + + void setStif(const STIF *stif); + s16 getFlagIndex() const; + + void setDemoName(const SizedString<16>& name) { + mDemoName = name; + } + + const char *getDemoName() const { + return mDemoName; + } + + void addLayerArcn(const char *path); + void addStageArcn(const char *path); + void addObjId(u16 id); void addActorId(u16 actorId); private: static void lastExecuteCallback(); + void triggerFade(s32 fadeType, u8 fadeFrames); static dStageMgr_c *sInstance; @@ -83,6 +131,7 @@ private: /* 0x0580 */ LayoutArcControl mLayoutArcCtrl2; /* 0x058C */ dBgS mBg; // ... + u8 _0x00001[0x7D0]; /* 0x3E40 */ dCcS mCc; // ... /* 0x7930 */ dFader_c mFader; @@ -91,10 +140,10 @@ private: /* 0x7956 */ u16 mLyseCount; /* 0x7958 */ u16 mRmplCount; - /* 0x795C */ PCAM *pcam; - /* 0x7960 */ PCAM *lyse; - /* 0x7964 */ STIF *stif; - /* 0x7968 */ RMPL *rmpl; + /* 0x795C */ const PCAM *mpPcam; + /* 0x7960 */ const LYSE *mpLyse; + /* 0x7964 */ const STIF *mpStif; + /* 0x7968 */ const RMPL *mpRmpl; /* 0x799C */ mDvd_callback_c *mpDvdCallback; /* 0x79A0 */ mDvd_callback_c *mpDvdCallback2; @@ -105,7 +154,7 @@ private: /* 0x8694 */ dTimeAreaMgr_c mTimeAreaMgr; // ... - u8 ___[2450]; + u8 ___[446]; /* 0x88A0 */ u32 field_0x88A0; /* 0x88A4 */ SizedString<16> mDemoName; diff --git a/include/d/d_stage_parse.h b/include/d/d_stage_parse.h index 00143224..429f0ea7 100644 --- a/include/d/d_stage_parse.h +++ b/include/d/d_stage_parse.h @@ -1,12 +1,11 @@ #ifndef D_STAGE_PARSE_H #define D_STAGE_PARSE_H -#include "common.h" - -typedef s32 parseCallbackArg; - -void parseStageBzs(parseCallbackArg arg, void *bzs); -void parseRoomStageBzs(parseCallbackArg arg, void *bzs); -void parseBzsStageRoom(parseCallbackArg arg, void *bzs); +void parseRoomStageBzs(int roomid, const void *bzs); +void parseBzsStageRoom(int roomid, const void *bzs); +void parseStageBzs(int roomid, const void *bzs); +void parseRoomBzs(int roomid, const void *bzs); +void parseRoomReactivateBzs(int roomid, const void *bzs); +void parseRoomActivateBzs(int roomid, const void *bzs); #endif diff --git a/include/toBeSorted/file_manager.h b/include/toBeSorted/file_manager.h index 882910c7..100ce14d 100644 --- a/include/toBeSorted/file_manager.h +++ b/include/toBeSorted/file_manager.h @@ -210,12 +210,12 @@ public: /* 8000CAD0 */ bool isNew_FileA(); - /* 8000CB00 */ void setSceneFlagIndex(u16 idx); + /* 8000CB00 */ void setSceneFlagIndex(s16 idx); /* 8000CB30 */ u32 getSceneFlagIndex(); /* 8000CB80 */ s32 getFileAreaIndex(); /* 8000CBD0 */ void fn_8000CBD0(u8); - /* 8000CC00 */ void fn_8000CC00(); + /* 8000CC00 */ u8 fn_8000CC00(); /* 8000CC50 */ void setFileTimes(); /* 8000CCB0 */ void setPlayTime(s64 time); diff --git a/src/d/d_sc_game.cpp b/src/d/d_sc_game.cpp index c0948c6e..0ec9c5c7 100644 --- a/src/d/d_sc_game.cpp +++ b/src/d/d_sc_game.cpp @@ -248,11 +248,11 @@ void SpawnInfoExt::setSpawnData( mType0RotY = rot; } -void LinkReloadInfo::set(u8 roomid, const mVec3_c &pos, mAng rot, u32 flags) { +void LinkReloadInfo::set(u8 roomid, const mVec3_c &pos, mAng rot, u32 linkParams) { mRoomId = roomid; mPosition = pos; mRotY = rot; - mUnkFlags = flags; + mLinkParams = linkParams; mType0CsFlag = 1; } diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 91759aba..56fa4b6f 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -3,9 +3,11 @@ #include "common.h" #include "d/col/bg/d_bg_s.h" #include "d/d_base.h" +#include "d/d_bzs_types.h" #include "d/d_room.h" #include "d/d_sc_game.h" #include "d/d_sc_title.h" +#include "d/d_stage_mgr.h" #include "d/flag/dungeonflag_manager.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" @@ -53,14 +55,19 @@ extern "C" void ScrapperPickupMgr__dtor(); extern "C" void fn_80028A80(); extern "C" void fn_80028EC0(); extern "C" void fn_80066D30(s32); +extern "C" void setPCAMpos2(const PCAM *); int dStage_c::create() { if (mPhase.step() != sFPhaseBase::PHASE_ALL_DONE) { return NOT_READY; } - // dStageMgr_c *stageMgr = dStageMgr_c::GetInstance(); - // for (int i = 0; i < dSta) + dStageMgr_c *stageMgr = dStageMgr_c::GetInstance(); + const PCAM *pcam = stageMgr->getPcam(); + for (int i = 0; i < stageMgr->getPcamCount(); i++) { + setPCAMpos2(pcam); + pcam++; + } if (mapRelated.field_0x1EB == 0) { mVec3_c min, max; diff --git a/src/d/d_stage_mgr.cpp b/src/d/d_stage_mgr.cpp index 26dd73d9..b5056a69 100644 --- a/src/d/d_stage_mgr.cpp +++ b/src/d/d_stage_mgr.cpp @@ -17,7 +17,6 @@ #include "toBeSorted/arc_managers/layout_arc_manager.h" #include "toBeSorted/arc_managers/oarc_manager.h" #include "toBeSorted/music_mgrs.h" -#include SPECIAL_BASE_PROFILE(STAGE_MANAGER, dStageMgr_c, fProfile::STAGE_MANAGER, 0X5, 1536); @@ -52,7 +51,7 @@ void dStageMgr_c::executeState_ReadStageRes() { } void dStageMgr_c::finalizeState_ReadStageRes() { - void *stageBzs = CurrentStageArcManager::sInstance->getData("dat/stage.bzs"); + const void *stageBzs = CurrentStageArcManager::sInstance->getData("dat/stage.bzs"); if (stageBzs != nullptr) { parseStageBzs(-1, stageBzs); parseRoomStageBzs(-1, stageBzs); @@ -70,15 +69,15 @@ void dStageMgr_c::executeState_ReadRoomRes() { } void dStageMgr_c::finalizeState_ReadRoomRes() { - if (rmpl != nullptr) { - RMPL *itRmpl = rmpl; + if (mpRmpl != nullptr) { + const RMPL *itRmpl = mpRmpl; for (int i = 0; i < mRmplCount; itRmpl++, i++) { - void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(itRmpl->roomId, "dat/room.bzs"); + const void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(itRmpl->roomId, "dat/room.bzs"); parseRoomStageBzs(itRmpl->roomId, bzs); } } else { u32 roomId = dScGame_c::currentSpawnInfo.room; - void *bzs = + const void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(dScGame_c::currentSpawnInfo.room, "dat/room.bzs"); parseRoomStageBzs(roomId, bzs); } @@ -116,20 +115,20 @@ static const char *sSeekerStoneLayoutArcs[] = { void dStageMgr_c::initializeState_ReadLayerObjectRes() { mDemoName = demoName; - void *bzs = CurrentStageArcManager::sInstance->getData("dat/stage.bzs"); + const void *bzs = CurrentStageArcManager::sInstance->getData("dat/stage.bzs"); if (bzs != nullptr) { parseBzsStageRoom(-1, bzs); } - if (rmpl != nullptr) { - RMPL *itRmpl = rmpl; + if (mpRmpl != nullptr) { + const RMPL *itRmpl = mpRmpl; for (int i = 0; i < mRmplCount; itRmpl++, i++) { - void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(itRmpl->roomId, "dat/room.bzs"); + const void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(itRmpl->roomId, "dat/room.bzs"); parseBzsStageRoom(itRmpl->roomId, bzs); } } else { u32 roomId = dScGame_c::currentSpawnInfo.room; - void *bzs = + const void *bzs = CurrentStageArcManager::sInstance->loadFromRoomArc(dScGame_c::currentSpawnInfo.room, "dat/room.bzs"); parseBzsStageRoom(roomId, bzs); } @@ -234,7 +233,7 @@ void dStageMgr_c::finalizeState_ReadObjectSound() { } extern "C" void *LYT_SAVE_MGR; -extern "C" void fn_80285600(void*, int, int); +extern "C" void fn_80285600(void *, int, int); void dStageMgr_c::initializeState_SceneChangeSave() { dScGame_c::sInstance->setSavePromptFlag(false); if (LYT_SAVE_MGR != nullptr) { @@ -247,7 +246,7 @@ void dStageMgr_c::initializeState_SceneChangeSave() { void dStageMgr_c::executeState_SceneChangeSave() { if (LYT_SAVE_MGR != nullptr) { // "isNotSaving???" - if (((u8*)LYT_SAVE_MGR)[0x119C] == true) { + if (((u8 *)LYT_SAVE_MGR)[0x119C] == true) { mStateMgr.changeState(StateID_RestartSceneWait); } } else { @@ -287,9 +286,7 @@ void dStageMgr_c::initializeState_RestartScene() { } void dStageMgr_c::executeState_RestartScene() { - if (mFader.isStatus(mFaderBase_c::FADED_OUT)) { - - } + if (mFader.isStatus(mFaderBase_c::FADED_OUT)) {} } void dStageMgr_c::finalizeState_RestartScene() { diff --git a/src/d/d_stage_parse.cpp b/src/d/d_stage_parse.cpp new file mode 100644 index 00000000..63d0c66a --- /dev/null +++ b/src/d/d_stage_parse.cpp @@ -0,0 +1,523 @@ +#include "d/d_stage_parse.h" + +#include "common.h" +#include "d/a/obj/d_a_obj_base.h" +#include "d/d_base.h" +#include "d/d_bzs_types.h" +#include "d/d_room.h" +#include "d/d_sc_game.h" +#include "d/d_stage.h" +#include "d/d_stage_mgr.h" +#include "d/flag/flag_managers.h" +#include "d/flag/storyflag_manager.h" +#include "f/f_base.h" +#include "f/f_profile_name.h" +#include "m/m_angle.h" +#include "m/m_vec.h" +#include "sized_string.h" +#include "toBeSorted/file_manager.h" + +struct BzsHeader { + /* 0x00 */ u32 mName; + /* 0x04 */ u16 mSectionCount; + /* 0x08 */ u32 mOffset; +}; + +struct BzsSectionHead { + /* 0x00 */ u32 mTag; + /* 0x04 */ u16 mCount; + /* 0x08 */ u32 mOffset; +}; + +typedef void (*BzsParseFunc)(int roomid, const BzsSectionHead *section); + +struct BzsTagToParseFunc { + /* 0x00 */ u32 mTag; + /* 0x04 */ BzsParseFunc mParseFunc; +}; + +#define OFS_TO_PTR(ty, section) \ + (reinterpret_cast(reinterpret_cast(section) + section->mOffset)) + +static void findAndRunStageTagParseFunc( + int roomid, const BzsSectionHead *head, const BzsTagToParseFunc *handlerTable, s32 tableSize +); + +static void handleBzsPcam(int roomid, const BzsSectionHead *section) { + dStageMgr_c::GetInstance()->setPcam(OFS_TO_PTR(PCAM, section), section->mCount); +} + +static void handleBzsLyse(int roomid, const BzsSectionHead *section) { + dStageMgr_c::GetInstance()->setLyse(OFS_TO_PTR(LYSE, section), section->mCount); + dStageMgr_c::GetInstance()->overrideLayer0WithLyse(); +} + +static void handleBzsStif(int roomid, const BzsSectionHead *section) { + // section->mCount == 1 + dStageMgr_c::GetInstance()->setStif(OFS_TO_PTR(STIF, section)); + s16 flagIndex = dStageMgr_c::GetInstance()->getFlagIndex(); + FileManager::sInstance->setSceneFlagIndex(flagIndex); + updateFlagForFlagIndex(flagIndex); +} + +static void handleBzsRmpl(int roomid, const BzsSectionHead *section) { + dStageMgr_c::GetInstance()->setRmpl(OFS_TO_PTR(RMPL, section), section->mCount); +} + +static void handleBzsFile(int roomid, const BzsSectionHead *section) { + const bzsFILE *file = OFS_TO_PTR(bzsFILE, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setFile(file, section->mCount); +} + +static void handleBzsLylt(int roomid, const BzsSectionHead *section) { + const LYLT *lylt = OFS_TO_PTR(LYLT, section); + for (s32 i = 0; i < section->mCount; i++) { + if (lylt->layer == dScGame_c::currentSpawnInfo.layer && lylt->demoHigh >= 0) { + SizedString<16> demoName; + demoName.sprintf("Demo%02d_%02d", lylt->demoHigh, lylt->demoLow); + dStageMgr_c::GetInstance()->setDemoName(demoName); + dStageMgr_c::GetInstance()->addLayerArcn(dStageMgr_c::GetInstance()->getDemoName()); + } + lylt++; + } +} + +static void handleBzsScen(int roomid, const BzsSectionHead *section) { + const SCEN *scen = OFS_TO_PTR(SCEN, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setScen(scen, section->mCount); +} + +static void handleBzsCam(int roomid, const BzsSectionHead *section) { + const CAM *cam = OFS_TO_PTR(CAM, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setCam(cam, section->mCount); +} + +static void handleBzsEvnt(int roomid, const BzsSectionHead *section) { + const EVNT *evnt = OFS_TO_PTR(EVNT, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setEvnt(evnt, section->mCount); +} + +static void handleBzsPath(int roomid, const BzsSectionHead *section) { + const PATH *path = OFS_TO_PTR(PATH, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setPath(path, section->mCount); +} + +static void handleBzsPnt(int roomid, const BzsSectionHead *section) { + const PNT *pnt = OFS_TO_PTR(PNT, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setPnt(pnt, section->mCount); +} + +static void handleBzsBpnt(int roomid, const BzsSectionHead *section) { + const BPNT *bpnt = OFS_TO_PTR(BPNT, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setBpnt(bpnt, section->mCount); +} + +static void handleBzsSpth(int roomid, const BzsSectionHead *section) { + const SPTH *spth = OFS_TO_PTR(SPTH, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setSpth(spth, section->mCount); +} + +static void handleBzsSpnt(int roomid, const BzsSectionHead *section) { + const SPNT *spnt = OFS_TO_PTR(SPNT, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setSpnt(spnt, section->mCount); +} + +static void handleBzsSbpt(int roomid, const BzsSectionHead *section) { + const SBPT *sbpt = OFS_TO_PTR(SBPT, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setSbpt(sbpt, section->mCount); +} + +static void handleBzsArea(int roomid, const BzsSectionHead *section) { + const AREA *area = OFS_TO_PTR(AREA, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setArea(area, section->mCount); +} + +extern "C" bool fn_8005C5D0(u32); +extern "C" void spawnLightObject(); +extern "C" void spawnWeatherTag(); + +static void handleBzsPly(int roomid, const BzsSectionHead *section) { + const PLY *ply = OFS_TO_PTR(PLY, section); + dRoom_c *room = dStage_c::GetInstance()->getRoom(roomid); + room->setPly(ply, section->mCount); + + if (roomid == dScGame_c::currentSpawnInfo.room) { + dScGame_c *sc = dScGame_c::GetInstance(); + const mVec3_c *linkPos; + const mAng3_c *linkAngle; + mAng3_c ang(0, 0, 0); + mVec3_c pos; + u32 linkActorParams = 0x7FFFFFF; + bool param = 0; + bool preventSetRespawnInfo = false; + u8 reloaderType = dScGame_c::getReloaderType(); + if (reloaderType != 0) { + FileManager *fileMgr = FileManager::sInstance; + if (reloaderType == 2) { + pos = *FileManager::sInstance->getPosT2(); + ang.y = fileMgr->getAngleT2(); + linkPos = &pos; + linkAngle = ∠ + linkActorParams = 0x7FFFF1B; + } else if (reloaderType == 3) { + pos = *FileManager::sInstance->getPosT3(); + ang.y = fileMgr->getAngleT3(); + linkPos = &pos; + linkAngle = ∠ + if (!StoryflagManager::sInstance->getCounterOrFlag(752) && + !StoryflagManager::sInstance->getCounterOrFlag(119)) { + const PLY *entrance = room->getEntranceById(dScGame_c::currentSpawnInfo.entrance); + if (fn_8005C5D0(entrance->linkParams) == true) { + linkActorParams = entrance->linkParams; + } + } + } else { + if (FileManager::sInstance->getEntranceLoadFlagT1() == 0 && dScGame_c::getReloaderType() != 4) { + pos = *fileMgr->getPosT1(); + ang.y = fileMgr->getAngleT1(); + if (fileMgr->fn_8000CC00() == 2) { + const PLY *entrance = room->getEntranceById(dScGame_c::currentSpawnInfo.entrance); + linkActorParams = entrance->linkParams; + } + linkPos = &pos; + linkAngle = ∠ + } else { + const PLY *entrance = room->getEntranceById(dScGame_c::currentSpawnInfo.entrance); + linkActorParams = entrance->linkParams; + linkPos = &entrance->position; + linkAngle = &entrance->angle; + } + } + dScGame_c::setReloaderType(0); + if (sc->getType0CsFlag() != 0) { + sc->setType0CsFlag(0); + } + } else { + if (dScGame_c::GetInstance()->getType0CsFlag() != 0) { + preventSetRespawnInfo = true; + const LinkReloadInfo &info = dScGame_c::GetInstance()->getLinkReloadInfo(); + ang.y = info.mRotY; + linkPos = &info.mPosition; + linkAngle = ∠ + linkActorParams = info.mLinkParams; + sc->setType0CsFlag(0); + } else if (dScGame_c::GetInstance()->getType0PosFlag() != 0) { + const SpawnInfoExt &info = dScGame_c::GetInstance()->getSpawnInfo(); + pos = info.mType0Pos; + linkPos = &pos; + ang.y = info.mType0RotY; + linkAngle = ∠ + sc->setType0PosFlag(0); + } else { + const PLY *entrance = room->getEntranceById(dScGame_c::currentSpawnInfo.entrance); + linkActorParams = entrance->linkParams; + linkPos = &entrance->position; + linkAngle = &entrance->angle; + param = true; + } + } + + // TODO constify args + dAcObjBase_c::create( + fProfile::PLAYER, -1, linkActorParams, (mVec3_c *)linkPos, (mAng3_c *)linkAngle, nullptr, -1 + ); + if (!preventSetRespawnInfo) { + dScGame_c::GetInstance()->setRespawnInfo(*linkPos, *linkAngle, param); + } + dStage_c::GetInstance()->handleRoomChange(roomid); + dBase_c::createBase(fProfile::CAMERA, dStage_c::GetInstance(), 0, fBase_c::OTHER); + spawnLightObject(); + spawnWeatherTag(); + } +} + +extern "C" u16 getActorIdForObjName2(const char *objname); + +// The above function suffered from tons of regswaps that ended up being fixed very quickly +// (swapping *pos and *ang). The below four functions have a single regswap that I don't +// understand and that I spent more time trying to fix than in the above function. + +static void handleBzsObjn(int roomid, const BzsSectionHead *section) { + const OBJN *objn = OFS_TO_PTR(OBJN, section); + const char *buf = reinterpret_cast(objn); + for (s32 i = 0; i < section->mCount; i++) { + dStageMgr_c::GetInstance()->addObjId(getActorIdForObjName2(buf + objn->offset)); + objn++; + } +} + +static void handleBzsArcn(int roomid, const BzsSectionHead *section) { + const ARCN *arcn = OFS_TO_PTR(ARCN, section); + const char *buf = reinterpret_cast(arcn); + for (s32 i = 0; i < section->mCount; i++) { + dStageMgr_c::GetInstance()->addStageArcn(buf + arcn->offset); + arcn++; + } +} + +static void handleBzsLayerObjn(int roomid, const BzsSectionHead *section) { + const OBJN *objn = OFS_TO_PTR(OBJN, section); + const char *buf = reinterpret_cast(objn); + for (s32 i = 0; i < section->mCount; i++) { + u16 id = getActorIdForObjName2(buf + objn->offset); + dStageMgr_c::GetInstance()->addActorId(id); + objn++; + } +} + +static void handleBzsLayerArcn(int roomid, const BzsSectionHead *section) { + const ARCN *arcn = OFS_TO_PTR(ARCN, section); + const char *buf = reinterpret_cast(arcn); + for (s32 i = 0; i < section->mCount; i++) { + dStageMgr_c::GetInstance()->addLayerArcn(buf + arcn->offset); + arcn++; + } +} + +static u16 getEnemyDefeatFlagFromId(s32 roomid, u16 id) { + u16 val = id & 0x3FF; + if (val >= 0x400) { + // Interesting condition + return -1; + } + if (roomid == -1) { + return val + (0x3F << 10); + } + return val + (roomid << 10); +} + +static s8 getViewClipIndexFromId(u16 id) { + s8 val = (id >> 10) & 0x3F; + if (val == 0x3F) { + return -1; + } + return val; +} + +static void handleBzsObj(int roomid, const BzsSectionHead *section) { + dStage_c *stage = dStage_c::GetInstance(); + const OBJ *obj = OFS_TO_PTR(OBJ, section); + for (s32 i = 0; i < section->mCount; i++) { + u16 flag = getEnemyDefeatFlagFromId(roomid, obj->id); + s8 viewClipIdx = getViewClipIndexFromId(obj->id); + if (stage->checkEnemyDefeatFlag(flag)) { + dAcObjBase_c::create( + obj->name, roomid, obj->params1, &obj->position, &obj->angle, nullptr, obj->params2, flag, viewClipIdx + ); + } + obj++; + } +} + +static void handleBzsSobj(int roomid, const BzsSectionHead *section) { + dStage_c *stage = dStage_c::GetInstance(); + const SOBJ *obj = OFS_TO_PTR(SOBJ, section); + for (s32 i = 0; i < section->mCount; i++) { + u16 flag = getEnemyDefeatFlagFromId(roomid, obj->id); + s8 viewClipIdx = getViewClipIndexFromId(obj->id); + if (stage->checkEnemyDefeatFlag(flag)) { + dAcObjBase_c::create( + obj->name, roomid, obj->params1, &obj->position, &obj->angle, (mVec3_c *)&obj->scale, obj->params2, + flag, viewClipIdx + ); + } + obj++; + } +} + +static void handleBzsStas(int roomid, const BzsSectionHead *section) { + dStage_c *stage = dStage_c::GetInstance(); + const SOBJ *obj = OFS_TO_PTR(SOBJ, section); + for (s32 i = 0; i < section->mCount; i++) { + u16 flag = getEnemyDefeatFlagFromId(roomid, obj->id); + s8 viewClipIdx = getViewClipIndexFromId(obj->id); + if (stage->checkEnemyDefeatFlag(flag)) { + dAcObjBase_c::createActorUnkGroup3( + obj->name, roomid, obj->params1, &obj->position, &obj->angle, &obj->scale, obj->params2, flag, + viewClipIdx + ); + } + obj++; + } +} + +void parseLayerBzs(int roomid, u32 layer, const LAY *head, const BzsTagToParseFunc *handlerTable, s32 tableSize) { + const LAY *lay = head + layer; + const BzsSectionHead *newHead = OFS_TO_PTR(BzsSectionHead, lay); + for (s32 i = 0; i < lay->mCount; i++) { + findAndRunStageTagParseFunc(roomid, newHead++, handlerTable, tableSize); + } +} + +static const BzsTagToParseFunc layerHandlers[] = { + {'OBJN', handleBzsLayerObjn}, + {'ARCN', handleBzsLayerArcn}, +}; + +void handleBzsLay(int roomid, const BzsSectionHead *section) { + const LAY *lay = OFS_TO_PTR(LAY, section); + parseLayerBzs(roomid, 0, lay, layerHandlers, ARRAY_LENGTH(layerHandlers)); + if (dScGame_c::currentSpawnInfo.layer != 0) { + parseLayerBzs(roomid, dScGame_c::currentSpawnInfo.layer, lay, layerHandlers, ARRAY_LENGTH(layerHandlers)); + } +} + +static const BzsTagToParseFunc layerHandlers2[] = { + {'OBJ ', handleBzsObj}, + {'SOBJ', handleBzsSobj}, + {'STAG', handleBzsStas}, +}; + +void handleBzsLay2(int roomid, const BzsSectionHead *section) { + const LAY *lay = OFS_TO_PTR(LAY, section); + parseLayerBzs(roomid, 0, lay, layerHandlers2, ARRAY_LENGTH(layerHandlers2)); + if (dScGame_c::currentSpawnInfo.layer != 0) { + parseLayerBzs(roomid, dScGame_c::currentSpawnInfo.layer, lay, layerHandlers2, ARRAY_LENGTH(layerHandlers2)); + } +} + +static const BzsTagToParseFunc layerHandlers3[] = { + {'OBJS', handleBzsObj}, + {'SOBS', handleBzsSobj}, + {'STAS', handleBzsStas}, + {'SNDT', handleBzsStas}, + {'TBOX', handleBzsObj}, + {'DOOR', handleBzsObj}, +}; + +void handleBzsLay3(int roomid, const BzsSectionHead *section) { + const LAY *lay = OFS_TO_PTR(LAY, section); + parseLayerBzs(roomid, 0, lay, layerHandlers3, ARRAY_LENGTH(layerHandlers3)); + if (dScGame_c::currentSpawnInfo.layer != 0) { + parseLayerBzs(roomid, dScGame_c::currentSpawnInfo.layer, lay, layerHandlers3, ARRAY_LENGTH(layerHandlers3)); + } +} + +static const BzsTagToParseFunc defaultHandlers[] = { + {'PCAM', handleBzsPcam}, + {'LYSE', handleBzsLyse}, + {'STIF', handleBzsStif}, + {'RMPL', handleBzsRmpl}, + {'SCEN', handleBzsScen}, + {'CAM ', handleBzsCam}, + {'EVNT', handleBzsEvnt}, + {'PATH', handleBzsPath}, + {'PNT ', handleBzsPnt}, + {'BPNT', handleBzsBpnt}, + {'SPTH', handleBzsSpth}, + {'SPNT', handleBzsSpnt}, + {'SBPT', handleBzsSbpt}, + {'AREA', handleBzsArea}, +}; + +static void findAndRunStageTagParseFunc( + int roomid, const BzsSectionHead *head, const BzsTagToParseFunc *handlerTable, s32 tableSize +) { + if (handlerTable == nullptr) { + tableSize = ARRAY_LENGTH(defaultHandlers); + handlerTable = defaultHandlers; + } + while (tableSize > 0) { + if (head->mTag == handlerTable->mTag) { + handlerTable->mParseFunc(roomid, head); + return; + } + handlerTable++; + tableSize--; + } +} + +static const BzsTagToParseFunc roomStageHandlers[] = { + {'OBJN', handleBzsObjn}, + {'ARCN', handleBzsArcn}, +}; + +void parseRoomStageBzs(int roomid, const void *bzs) { + const BzsHeader *header = static_cast(bzs); + const BzsSectionHead *head = OFS_TO_PTR(BzsSectionHead, header); + for (s32 i = 0; i < header->mSectionCount; i++) { + findAndRunStageTagParseFunc(roomid, head++, roomStageHandlers, ARRAY_LENGTH(roomStageHandlers)); + } +} + +static const BzsTagToParseFunc stageRoomHandlers[] = { + {'LYLT', handleBzsLylt}, + {'LAY ', handleBzsLay}, +}; + +void parseBzsStageRoom(int roomid, const void *bzs) { + const BzsHeader *header = static_cast(bzs); + const BzsSectionHead *head = OFS_TO_PTR(BzsSectionHead, header); + for (s32 i = 0; i < header->mSectionCount; i++) { + findAndRunStageTagParseFunc(roomid, head++, stageRoomHandlers, ARRAY_LENGTH(stageRoomHandlers)); + } +} + +void parseStageBzs(int roomid, const void *bzs) { + const BzsHeader *header = static_cast(bzs); + const BzsSectionHead *head = OFS_TO_PTR(BzsSectionHead, header); + for (s32 i = 0; i < header->mSectionCount; i++) { + // Run "default handlers" + findAndRunStageTagParseFunc(roomid, head++, nullptr, 0); + } +} + +static const BzsTagToParseFunc roomHandlers[] = { + {'FILE', handleBzsFile}, + {'SCEN', handleBzsScen}, + {'CAM ', handleBzsCam}, + {'EVNT', handleBzsEvnt}, + {'PATH', handleBzsPath}, + {'PNT ', handleBzsPnt}, + {'BPNT', handleBzsBpnt}, + {'SPTH', handleBzsSpth}, + {'SPNT', handleBzsSpnt}, + {'SBPT', handleBzsSbpt}, + {'AREA', handleBzsArea}, + {'PLY ', handleBzsPly}, +}; + +void parseRoomBzs(int roomid, const void *bzs) { + const BzsHeader *header = static_cast(bzs); + const BzsSectionHead *head = OFS_TO_PTR(BzsSectionHead, header); + for (s32 i = 0; i < header->mSectionCount; i++) { + findAndRunStageTagParseFunc(roomid, head++, roomHandlers, ARRAY_LENGTH(roomHandlers)); + } +} + +static const BzsTagToParseFunc roomReactivateHandlers[] = { + {'SOBJ', handleBzsSobj}, + {'STAG', handleBzsStas}, + {'LAY ', handleBzsLay2}, +}; + +void parseRoomReactivateBzs(int roomid, const void *bzs) { + const BzsHeader *header = static_cast(bzs); + const BzsSectionHead *head = OFS_TO_PTR(BzsSectionHead, header); + for (s32 i = 0; i < header->mSectionCount; i++) { + findAndRunStageTagParseFunc(roomid, head++, roomReactivateHandlers, ARRAY_LENGTH(roomReactivateHandlers)); + } +} + +static const BzsTagToParseFunc roomActivateHandlers[] = { + {'LAY ', handleBzsLay3}, +}; + +void parseRoomActivateBzs(int roomid, const void *bzs) { + const BzsHeader *header = static_cast(bzs); + const BzsSectionHead *head = OFS_TO_PTR(BzsSectionHead, header); + for (s32 i = 0; i < header->mSectionCount; i++) { + findAndRunStageTagParseFunc(roomid, head++, roomActivateHandlers, ARRAY_LENGTH(roomActivateHandlers)); + } +} diff --git a/src/toBeSorted/file_manager.cpp b/src/toBeSorted/file_manager.cpp index 8554415a..752d9f89 100644 --- a/src/toBeSorted/file_manager.cpp +++ b/src/toBeSorted/file_manager.cpp @@ -235,12 +235,12 @@ u16 *FileManager::getStoryFlagsMut() { /* 8000CAD0 */ bool FileManager::isNew_FileA() {} -/* 8000CB00 */ void FileManager::setSceneFlagIndex(u16 idx) {} +/* 8000CB00 */ void FileManager::setSceneFlagIndex(s16 idx) {} /* 8000CB30 */ u32 FileManager::getSceneFlagIndex() {} /* 8000CB80 */ s32 FileManager::getFileAreaIndex() {} /* 8000CBD0 */ void FileManager::fn_8000CBD0(u8) {} -/* 8000CC00 */ void FileManager::fn_8000CC00() {} +/* 8000CC00 */ u8 FileManager::fn_8000CC00() {} /* 8000CC50 */ void FileManager::setFileTimes() {} /* 8000CCB0 */ void FileManager::setPlayTime(s64 time) {} From 5246f61acad41e1445070794547afdacbf96f49f Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 17:54:32 +0100 Subject: [PATCH 07/11] Field names --- include/d/d_room.h | 8 ++++---- src/d/d_room.cpp | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/d/d_room.h b/include/d/d_room.h index 37e2fc64..ab1284f9 100644 --- a/include/d/d_room.h +++ b/include/d/d_room.h @@ -269,14 +269,14 @@ private: /* 0x564 */ UnkRoomClass mUnk; /* 0x568 */ u8 mFlags; - void *BZS; + /* 0x56C */ void *BZS; /* 0x570 */ s8 roomid; /* 0x571 */ bool field_0x571; - /* 0x572 */ bool field_0x572; - /* 0x573 */ bool field_0x573; + /* 0x572 */ bool mUpdatesDeactivated; + /* 0x573 */ bool mCanHavePastState; /* 0x574 */ bool mHasAnmTexPat; /* 0x575 */ bool mDidAlreadyInit; - /* 0x576 */ bool field_0x576; + /* 0x576 */ bool mSkipDrawing; }; #endif diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index 7b466eab..143b59c3 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -49,7 +49,7 @@ extern "C" void parseRoomBzs(int roomid, void *bzs); int dRoom_c::create() { roomid = params & 0x3F; - field_0x573 = dStageMgr_c::GetInstance()->getSTIFunk1() == 0 && + mCanHavePastState = dStageMgr_c::GetInstance()->getSTIFunk1() == 0 && // SSH machine room (less sure about D303...) !(dScGame_c::isCurrentStage("D301") && roomid == 12) && !(dScGame_c::isCurrentStage("D303") && roomid == 12) && @@ -130,29 +130,29 @@ int dRoom_c::doDelete() { int dRoom_c::execute() { mStateMgr.executeState(); f32 val = 0.0f; - if (field_0x573) { + if (mCanHavePastState) { val = dTimeAreaMgr_c::sInstance->checkPositionIsInPastState(roomid, mVec3_c::Zero, nullptr, 1000000.0f); - field_0x576 = !mHasAnmTexPat && (!dTimeAreaMgr_c::sInstance->isInLanayruMiningFacility() || val > 0.0f) && + mSkipDrawing = !mHasAnmTexPat && (!dTimeAreaMgr_c::sInstance->isInLanayruMiningFacility() || val > 0.0f) && dTimeAreaMgr_c::sInstance->isField0x78(); } else { - field_0x576 = false; + mSkipDrawing = false; } - if ((mFlags & 2) != 0 || field_0x576) { + if ((mFlags & 2) != 0 || mSkipDrawing) { releaseBg(); return SUCCEEDED; } executeBg(); for (s32 i = 0; i < 8; i++) { - mModels[i].execute(i, field_0x573, val); + mModels[i].execute(i, mCanHavePastState, val); } return SUCCEEDED; } int dRoom_c::draw() { - if ((mFlags & 2) != 0 || field_0x576) { + if ((mFlags & 2) != 0 || mSkipDrawing) { return SUCCEEDED; } for (s32 i = 0; i < 8; i++) { @@ -169,10 +169,10 @@ void deactivateUpdatesCb(dAcBase_c *ac) { } void dRoom_c::deactivateUpdates() { - if (!field_0x572) { + if (!mUpdatesDeactivated) { foreachObject(deactivateUpdatesCb); setProcControlFlag(ROOT_DISABLE_EXECUTE | ROOT_DISABLE_DRAW); - field_0x572 = true; + mUpdatesDeactivated = true; } } @@ -184,11 +184,11 @@ void activateUpdatesCb(dAcBase_c *ac) { } void dRoom_c::activateUpdates() { - if (field_0x572) { + if (mUpdatesDeactivated) { foreachObject(activateUpdatesCb); clearProcControlFlag(ROOT_DISABLE_EXECUTE); clearProcControlFlag(ROOT_DISABLE_DRAW); - field_0x572 = false; + mUpdatesDeactivated = false; } } @@ -233,7 +233,7 @@ bool dRoom_c::setupBg() { return true; } - if (field_0x573 && !mHasAnmTexPat) { + if (mCanHavePastState && !mHasAnmTexPat) { bg->SetUnkBase(); } // ??? @@ -539,7 +539,7 @@ bool dRoom_c::model_c::create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s return true; } -void dRoom_c::model_c::execute(s32 idx, bool roomfield_0x573, f32 pastState) { +void dRoom_c::model_c::execute(s32 idx, bool canHavePastState, f32 pastState) { if (!mMdl.hasModel()) { return; } @@ -556,7 +556,7 @@ void dRoom_c::model_c::execute(s32 idx, bool roomfield_0x573, f32 pastState) { mpAnmVis->play(); } - if (roomfield_0x573 && !(idx >= 6)) { + if (canHavePastState && !(idx >= 6)) { if (mpAnmPat) { int frame = (pastState > 0.0f); mpAnmPat->setFrame(frame, 0); From e4b31cbd6b735dab6d88978722c51e50eb160070 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 17:56:43 +0100 Subject: [PATCH 08/11] Remove fixed regswap comment --- src/d/d_stage_parse.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d/d_stage_parse.cpp b/src/d/d_stage_parse.cpp index 63d0c66a..b04852c4 100644 --- a/src/d/d_stage_parse.cpp +++ b/src/d/d_stage_parse.cpp @@ -244,10 +244,6 @@ static void handleBzsPly(int roomid, const BzsSectionHead *section) { extern "C" u16 getActorIdForObjName2(const char *objname); -// The above function suffered from tons of regswaps that ended up being fixed very quickly -// (swapping *pos and *ang). The below four functions have a single regswap that I don't -// understand and that I spent more time trying to fix than in the above function. - static void handleBzsObjn(int roomid, const BzsSectionHead *section) { const OBJN *objn = OFS_TO_PTR(OBJN, section); const char *buf = reinterpret_cast(objn); From 08d659a21c5ad52ec8a5db169028823bed2aa4c5 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 17:58:12 +0100 Subject: [PATCH 09/11] static --- src/d/d_stage_parse.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d/d_stage_parse.cpp b/src/d/d_stage_parse.cpp index b04852c4..30e2f20e 100644 --- a/src/d/d_stage_parse.cpp +++ b/src/d/d_stage_parse.cpp @@ -348,7 +348,7 @@ static void handleBzsStas(int roomid, const BzsSectionHead *section) { } } -void parseLayerBzs(int roomid, u32 layer, const LAY *head, const BzsTagToParseFunc *handlerTable, s32 tableSize) { +static void parseLayerBzs(int roomid, u32 layer, const LAY *head, const BzsTagToParseFunc *handlerTable, s32 tableSize) { const LAY *lay = head + layer; const BzsSectionHead *newHead = OFS_TO_PTR(BzsSectionHead, lay); for (s32 i = 0; i < lay->mCount; i++) { @@ -361,7 +361,7 @@ static const BzsTagToParseFunc layerHandlers[] = { {'ARCN', handleBzsLayerArcn}, }; -void handleBzsLay(int roomid, const BzsSectionHead *section) { +static void handleBzsLay(int roomid, const BzsSectionHead *section) { const LAY *lay = OFS_TO_PTR(LAY, section); parseLayerBzs(roomid, 0, lay, layerHandlers, ARRAY_LENGTH(layerHandlers)); if (dScGame_c::currentSpawnInfo.layer != 0) { @@ -375,7 +375,7 @@ static const BzsTagToParseFunc layerHandlers2[] = { {'STAG', handleBzsStas}, }; -void handleBzsLay2(int roomid, const BzsSectionHead *section) { +static void handleBzsLay2(int roomid, const BzsSectionHead *section) { const LAY *lay = OFS_TO_PTR(LAY, section); parseLayerBzs(roomid, 0, lay, layerHandlers2, ARRAY_LENGTH(layerHandlers2)); if (dScGame_c::currentSpawnInfo.layer != 0) { @@ -392,7 +392,7 @@ static const BzsTagToParseFunc layerHandlers3[] = { {'DOOR', handleBzsObj}, }; -void handleBzsLay3(int roomid, const BzsSectionHead *section) { +static void handleBzsLay3(int roomid, const BzsSectionHead *section) { const LAY *lay = OFS_TO_PTR(LAY, section); parseLayerBzs(roomid, 0, lay, layerHandlers3, ARRAY_LENGTH(layerHandlers3)); if (dScGame_c::currentSpawnInfo.layer != 0) { From 1be580fb78a28f3b7dc0047cf40d0d76b7998e83 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 18:56:32 +0100 Subject: [PATCH 10/11] Review comments --- include/d/a/d_a_base.h | 10 +------- include/d/d_room.h | 40 +----------------------------- include/toBeSorted/attention.h | 17 ++----------- include/toBeSorted/raii_ptr.h | 45 ++++++++++++++++++++++++++++++++++ src/d/d_room.cpp | 36 +++++++++++++-------------- 5 files changed, 67 insertions(+), 81 deletions(-) create mode 100644 include/toBeSorted/raii_ptr.h diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index ab4ca53a..835a4cde 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -94,7 +94,7 @@ public: /* 0xF4 */ char someStr[4]; /* 0xF8 */ char field_0xf8[0xfc - 0xf8]; -protected: +public: /* 80501544 */ // vtable /* 0x08 | 8002c880 */ virtual int create(); /* 0x10 | 8002c8f0 */ virtual void postCreate(MAIN_STATE_e state); @@ -173,14 +173,6 @@ public: return actor_properties & property; } - void callunkVirtFunc_0x60() { - unkVirtFunc_0x60(); - } - - void callrestorePosRotFromCopy() { - restorePosRotFromCopy(); - } - public: // funcs found in TU /* 8002c650 */ static void setTempCreateParams( diff --git a/include/d/d_room.h b/include/d/d_room.h index ab1284f9..233b8439 100644 --- a/include/d/d_room.h +++ b/include/d/d_room.h @@ -18,6 +18,7 @@ #include "nw4r/math/math_geometry.h" #include "s/s_State.hpp" #include "sized_string.h" +#include "toBeSorted/raii_ptr.h" #include "toBeSorted/unk_with_water.h" struct DrawPriorityConfig { @@ -26,45 +27,6 @@ struct DrawPriorityConfig { u8 pDrawOpa2; }; -// This could be std::unique_ptr, but we don't have it yet -template -class RaiiPtr { -public: - T *mPtr; - - RaiiPtr() : mPtr(nullptr) {} - ~RaiiPtr() { - if (mPtr != nullptr) { - delete mPtr; - mPtr = nullptr; - } - } - - void operator=(T *ptr) { - mPtr = ptr; - } - - operator bool() const { - return mPtr != nullptr; - } - - const T *operator->() const { - return mPtr; - } - - T *operator->() { - return mPtr; - } - - const T &operator*() const { - return *this->operator->(); - } - - T &operator*() { - return *this->operator->(); - } -}; - class dRoom_c : public dBase_c { class mdl_c : public m3d::smdl_c { public: diff --git a/include/toBeSorted/attention.h b/include/toBeSorted/attention.h index 6add6305..b6b4f207 100644 --- a/include/toBeSorted/attention.h +++ b/include/toBeSorted/attention.h @@ -9,7 +9,7 @@ #include "m/m3d/m_smdl.h" #include "m/m_allocator.h" #include "toBeSorted/effects_struct.h" - +#include "toBeSorted/raii_ptr.h" static const u32 OFF = 'off '; static const u32 NONE = 'none'; @@ -18,25 +18,12 @@ static const u32 NEXT = 'next'; static const u32 ON = 'on '; static const u32 AWAY = 'away'; -class UniquePtrLike { -public: - m3d::anmChr_c *mPtr; - - UniquePtrLike() : mPtr(nullptr) {} - ~UniquePtrLike() { - if (mPtr != nullptr) { - delete mPtr; - mPtr = nullptr; - } - } -}; - class InteractionMdl { public: m3d::smdl_c mMdl; m3d::anmMatClr_c mAnmClr; m3d::anmTexPat_c mAnmTex; - UniquePtrLike mAnmChr; + RaiiPtr mAnmChr; u8 field_0x78; u8 field_0x79; diff --git a/include/toBeSorted/raii_ptr.h b/include/toBeSorted/raii_ptr.h new file mode 100644 index 00000000..9160af80 --- /dev/null +++ b/include/toBeSorted/raii_ptr.h @@ -0,0 +1,45 @@ +#ifndef RAII_PTR_H +#define RAII_PTR_H + +#include "common.h" + +// This could be std::unique_ptr, but we don't have it yet +template +class RaiiPtr { +public: + T *mPtr; + + RaiiPtr() : mPtr(nullptr) {} + ~RaiiPtr() { + if (mPtr != nullptr) { + delete mPtr; + mPtr = nullptr; + } + } + + void operator=(T *ptr) { + mPtr = ptr; + } + + operator bool() const { + return mPtr != nullptr; + } + + const T *operator->() const { + return mPtr; + } + + T *operator->() { + return mPtr; + } + + const T &operator*() const { + return *this->operator->(); + } + + T &operator*() { + return *this->operator->(); + } +}; + +#endif diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index 143b59c3..3bfd760f 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -50,13 +50,13 @@ extern "C" void parseRoomBzs(int roomid, void *bzs); int dRoom_c::create() { roomid = params & 0x3F; mCanHavePastState = dStageMgr_c::GetInstance()->getSTIFunk1() == 0 && - // SSH machine room (less sure about D303...) - !(dScGame_c::isCurrentStage("D301") && roomid == 12) && - !(dScGame_c::isCurrentStage("D303") && roomid == 12) && - // LMF first two rooms, Gust Bellows room - !(dScGame_c::isCurrentStage("D300") && (roomid == 0 || roomid == 1 || roomid == 4)) && - // LMF crawlspace, spike maze - !(dScGame_c::isCurrentStage("D300_1") && (roomid == 7 || roomid == 9)); + // SSH machine room (less sure about D303...) + !(dScGame_c::isCurrentStage("D301") && roomid == 12) && + !(dScGame_c::isCurrentStage("D303") && roomid == 12) && + // LMF first two rooms, Gust Bellows room + !(dScGame_c::isCurrentStage("D300") && (roomid == 0 || roomid == 1 || roomid == 4)) && + // LMF crawlspace, spike maze + !(dScGame_c::isCurrentStage("D300_1") && (roomid == 7 || roomid == 9)); if (!mAllocator.createNewTempFrmHeap( -1, CurrentStageArcManager::sInstance->getHeap(roomid), "dRoom_c::m_allocator", 0x20, 0 )) { @@ -69,7 +69,7 @@ int dRoom_c::create() { dStage_c::bindStageResToFile(&mRoomRes); dStage_c::bindSkyCmnToResFile(&mRoomRes); - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < ARRAY_LENGTH(mModels); i++) { model_c *mdl = &mModels[i]; if (i != 2 || roomid != 1 || dScGame_c::currentSpawnInfo.layer != 14 || !dScGame_c::isCurrentStage("F406")) { if (!mdl->create(mRoomRes, mAllocator, i, &mWaterThing)) { @@ -133,7 +133,7 @@ int dRoom_c::execute() { if (mCanHavePastState) { val = dTimeAreaMgr_c::sInstance->checkPositionIsInPastState(roomid, mVec3_c::Zero, nullptr, 1000000.0f); mSkipDrawing = !mHasAnmTexPat && (!dTimeAreaMgr_c::sInstance->isInLanayruMiningFacility() || val > 0.0f) && - dTimeAreaMgr_c::sInstance->isField0x78(); + dTimeAreaMgr_c::sInstance->isField0x78(); } else { mSkipDrawing = false; } @@ -144,7 +144,7 @@ int dRoom_c::execute() { } executeBg(); - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < ARRAY_LENGTH(mModels); i++) { mModels[i].execute(i, mCanHavePastState, val); } @@ -155,7 +155,7 @@ int dRoom_c::draw() { if ((mFlags & 2) != 0 || mSkipDrawing) { return SUCCEEDED; } - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < ARRAY_LENGTH(mModels); i++) { mModels[i].draw(roomid); } return SUCCEEDED; @@ -165,7 +165,7 @@ void deactivateUpdatesCb(dAcBase_c *ac) { if (!ac->checkActorProperty(0x400)) { return; } - ac->callunkVirtFunc_0x60(); + ac->unkVirtFunc_0x60(); } void dRoom_c::deactivateUpdates() { @@ -180,7 +180,7 @@ void activateUpdatesCb(dAcBase_c *ac) { if (!ac->checkActorProperty(0x400)) { return; } - ac->callrestorePosRotFromCopy(); + ac->restorePosRotFromCopy(); } void dRoom_c::activateUpdates() { @@ -220,7 +220,7 @@ static const BgData sRoomBg[] = { }; bool dRoom_c::setupBg() { - for (int i = 0; i < 2; i++) { + for (int i = 0; i < ARRAY_LENGTH(mBg); i++) { dBgWKCol *bg = &mBg[i]; void *kcl = CurrentStageArcManager::sInstance->getDataFromRoomArc(roomid, sRoomBg[i].kcl); if (kcl != nullptr) { @@ -245,7 +245,7 @@ bool dRoom_c::setupBg() { } void dRoom_c::executeBg() { - for (int i = 0; i < 2; i++) { + for (int i = 0; i < ARRAY_LENGTH(mBg); i++) { if (!mBg[i].ChkNotReady()) { dBgS::GetInstance()->Regist(&mBg[i], (dAcObjBase_c *)nullptr); } @@ -281,7 +281,7 @@ void dRoom_c::drawOnMapIfVisible(mMtx_c *mtx, int param) { } void dRoom_c::getBounds(mVec3_c *min, mVec3_c *max) const { - for (int i = 0; i < 8; i++) { + for (int i = 0; i < ARRAY_LENGTH(mModels); i++) { mVec3_c tMin, tMax; mModels[i].getBounds(&tMin, &tMax); if (i == 0) { @@ -301,13 +301,13 @@ void dRoom_c::formatObj(int obj, SizedString<8> &str) { void dRoom_c::updateObjNodeInEachRoom(int obj, bool visible) { SizedString<8> objName; formatObj(obj, objName); - for (int i = 0; i < 8; i++) { + for (int i = 0; i < ARRAY_LENGTH(mModels); i++) { mModels[i].updateObjNode(objName, visible); } } void dRoom_c::destroyModels() { - for (int i = 0; i < 8; i++) { + for (int i = 0; i < ARRAY_LENGTH(mModels); i++) { mModels[i].destroy(); } } From 07723ba95912fce6580d189ad937057f2eb3e87f Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 19:01:24 +0100 Subject: [PATCH 11/11] Egg header --- include/d/d_stage.h | 30 ++++----------------------- include/egg/gfx/eggPostEffectBlur.h | 20 +++++++++++++++++- include/egg/gfx/eggScreenEffectBlur.h | 14 ++++++++++++- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 03c27d93..23b01ee1 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -5,6 +5,8 @@ #include "d/d_base.h" #include "d/d_fader.h" #include "d/d_room.h" +#include "egg/gfx/eggPostEffectBlur.h" +#include "egg/gfx/eggScreenEffectBlur.h" #include "m/m_allocator.h" #include "m/m_mtx.h" #include "m/m_vec.h" @@ -29,30 +31,6 @@ private: dRoom_c *mRooms[MAX_ROOM_NUMBER - 1]; }; -class EggScreenEffectBlur { -public: - EggScreenEffectBlur(); - ~EggScreenEffectBlur(); - -private: - u8 _0x00[0x38 - 0x00]; -}; - -class EggPostEffectBlur { -public: - EggPostEffectBlur(); - ~EggPostEffectBlur() {} - - void setField0x30(f32 val) { - field_0x30 = val; - } - -private: - u8 _0x00[0x30 - 0x00]; - f32 field_0x30; - u8 _0x03[0x78 - 0x34]; -}; - class MapRelated { friend class dStage_c; struct Child { @@ -79,8 +57,8 @@ public: /* 0x124 */ f32 field_0x124; /* 0x128 */ f32 field_0x128; /* 0x12C */ f32 field_0x12C; - /* 0x130 */ EggScreenEffectBlur mScreenEffect; - /* 0x168 */ EggPostEffectBlur mPostEffect; + /* 0x130 */ EGG::ScreenEffectBlur mScreenEffect; + /* 0x168 */ EGG::PostEffectBlur mPostEffect; /* 0x1E0 */ u32 field_0x1E0; /* 0x1E4 */ u16 field_0x1E4; /* 0x1E6 */ u16 field_0x1E6; diff --git a/include/egg/gfx/eggPostEffectBlur.h b/include/egg/gfx/eggPostEffectBlur.h index 61133991..4c116d62 100644 --- a/include/egg/gfx/eggPostEffectBlur.h +++ b/include/egg/gfx/eggPostEffectBlur.h @@ -1,6 +1,24 @@ #ifndef EGG_POST_EFFECT_BLUR_H #define EGG_POST_EFFECT_BLUR_H -namespace EGG {} // namespace EGG +#include "common.h" +namespace EGG { + +class PostEffectBlur { +public: + PostEffectBlur(); + ~PostEffectBlur() {} + + void setField0x30(f32 val) { + field_0x30 = val; + } + +private: + u8 _0x00[0x30 - 0x00]; + f32 field_0x30; + u8 _0x03[0x78 - 0x34]; +}; + +} // namespace EGG #endif diff --git a/include/egg/gfx/eggScreenEffectBlur.h b/include/egg/gfx/eggScreenEffectBlur.h index 18f33154..0553161f 100644 --- a/include/egg/gfx/eggScreenEffectBlur.h +++ b/include/egg/gfx/eggScreenEffectBlur.h @@ -1,6 +1,18 @@ #ifndef EGG_SCREEN_EFFECT_BLUR_H #define EGG_SCREEN_EFFECT_BLUR_H -namespace EGG {} // namespace EGG +#include "common.h" +namespace EGG { + +class ScreenEffectBlur { +public: + ScreenEffectBlur(); + ~ScreenEffectBlur(); + +private: + u8 _0x00[0x38 - 0x00]; +}; + +} // namespace EGG #endif