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; }