From dbed0835ed360c69803bf4f5698960f714509498 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 21 Sep 2024 16:24:11 +0200 Subject: [PATCH] dTgSw_c OK --- config/SOUE01/rels/d_t_timerNP/symbols.txt | 4 +- config/SOUE01/splits.txt | 4 + config/SOUE01/symbols.txt | 143 ++++++++-------- configure.py | 1 + include/d/tg/d_t_switch.h | 45 +++++ include/d/tg/d_t_timer.h | 9 +- include/toBeSorted/actor_event.h | 20 +++ include/toBeSorted/sceneflag_manager.h | 2 +- src/d/tg/d_t_switch.cpp | 187 +++++++++++++++++++++ src/toBeSorted/sceneflag_manager.cpp | 2 +- 10 files changed, 336 insertions(+), 81 deletions(-) create mode 100644 include/d/tg/d_t_switch.h create mode 100644 include/toBeSorted/actor_event.h create mode 100644 src/d/tg/d_t_switch.cpp diff --git a/config/SOUE01/rels/d_t_timerNP/symbols.txt b/config/SOUE01/rels/d_t_timerNP/symbols.txt index a6825912..3a6af027 100644 --- a/config/SOUE01/rels/d_t_timerNP/symbols.txt +++ b/config/SOUE01/rels/d_t_timerNP/symbols.txt @@ -2,7 +2,7 @@ _prolog = .text:0x00000000; // type:function size:0x2C scope:global _epilog = .text:0x00000030; // type:function size:0x2C scope:global _unresolved = .text:0x00000060; // type:function size:0x4 scope:global dTgTimer_c_classInit__Fv = .text:0x00000070; // type:function size:0x4C -__dt__14dTgTimerBase_cFv = .text:0x000000C0; // type:function size:0x58 +__dt__5dTg_cFv = .text:0x000000C0; // type:function size:0x58 increment__FPUs = .text:0x00000120; // type:function size:0x24 create__10dTgTimer_cFv = .text:0x00000150; // type:function size:0xD4 actorExecute__10dTgTimer_cFv = .text:0x00000230; // type:function size:0xB8 @@ -24,4 +24,4 @@ _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global g_profile_TIMER_TAG = .data:0x00000000; // type:object size:0x10 data:4byte __vt__10dTgTimer_c = .data:0x00000034; // type:object size:0x74 -__vt__14dTgTimerBase_c = .data:0x000000A8; // type:object size:0x74 +__vt__5dTg_c = .data:0x000000A8; // type:object size:0x74 diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 09a0e517..7493e4bb 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -292,6 +292,10 @@ d/tg/d_t_view_clip.cpp: d/tg/d_t_switch.cpp: .text start:0x802743E0 end:0x802756D8 .ctors start:0x804DB848 end:0x804DB84C + .data start:0x805361B0 end:0x80536478 + .sdata start:0x80573A70 end:0x80573A80 + .sdata2 start:0x8057C518 end:0x8057C520 + .bss start:0x805B56A8 end:0x805B57A8 d/tg/d_t_mass_object.cpp: .text start:0x802756E0 end:0x8027A0A4 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index f15084aa..9bb41d2f 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1,4 +1,4 @@ -__check_pad3 = .init:0x80004000; // type:function size:0x28 scope:local +__check_pad3_80004000 = .init:0x80004000; // type:function size:0x28 scope:local __set_debug_bba = .init:0x80004030; // type:function size:0xC scope:local __get_debug_bba = .init:0x80004040; // type:function size:0x8 scope:local __start = .init:0x80004050; // type:function size:0x168 scope:weak @@ -1424,7 +1424,7 @@ fn_80037ED0 = .text:0x80037ED0; // type:function size:0x14 fn_80037EF0 = .text:0x80037EF0; // type:function size:0xA4 fn_80037FA0 = .text:0x80037FA0; // type:function size:0x220 fn_800381C0 = .text:0x800381C0; // type:function size:0x2F0 -fn_800384B0 = .text:0x800384B0; // type:function size:0x1C +calcTimer__2cMFPUc_Uc = .text:0x800384B0; // type:function size:0x1C fn_800384D0 = .text:0x800384D0; // type:function size:0x64 fn_80038540 = .text:0x80038540; // type:function size:0x108 fn_80038650 = .text:0x80038650; // type:function size:0x144 @@ -3410,7 +3410,7 @@ fn_80097420 = .text:0x80097420; // type:function size:0x28 fn_80097450 = .text:0x80097450; // type:function size:0x6C fn_800974C0 = .text:0x800974C0; // type:function size:0x18 fn_800974E0 = .text:0x800974E0; // type:function size:0x28 -fn_80097510 = .text:0x80097510; // type:function size:0x58 +__dt__5dTg_c = .text:0x80097510; // type:function size:0x58 __dt__13DowsingTargetFv = .text:0x80097570; // type:function size:0x60 initialize__13DowsingTargetFQ213DowsingTarget11DowsingSlotUsPC7mVec3_cf = .text:0x800975D0; // type:function size:0x68 doRegister__13DowsingTargetFv = .text:0x80097640; // type:function size:0x4 @@ -3508,9 +3508,9 @@ fn_8009C7D0 = .text:0x8009C7D0; // type:function size:0x104 fn_8009C8E0 = .text:0x8009C8E0; // type:function size:0x10 fn_8009C8F0 = .text:0x8009C8F0; // type:function size:0x8 fn_8009C900 = .text:0x8009C900; // type:function size:0x4 -fn_8009C910 = .text:0x8009C910; // type:function size:0x70 +__ct__17ActorEventRelatedFR9dAcBase_cPv = .text:0x8009C910; // type:function size:0x70 fn_8009C980 = .text:0x8009C980; // type:function size:0x70 -fn_8009C9F0 = .text:0x8009C9F0; // type:function size:0x70 +__dt__17ActorEventRelatedFv = .text:0x8009C9F0; // type:function size:0x70 fn_8009CA60 = .text:0x8009CA60; // type:function size:0x4C fn_8009CAB0 = .text:0x8009CAB0; // type:function size:0x44 fn_8009CB00 = .text:0x8009CB00; // type:function size:0xBC @@ -3539,9 +3539,9 @@ fn_8009D700 = .text:0x8009D700; // type:function size:0x78 fn_8009D780 = .text:0x8009D780; // type:function size:0xA0 fn_8009D820 = .text:0x8009D820; // type:function size:0x50 fn_8009D870 = .text:0x8009D870; // type:function size:0x7C -fn_8009D8F0 = .text:0x8009D8F0; // type:function size:0x54 +scheduleEvent__17ActorEventRelatedFR5EventUl = .text:0x8009D8F0; // type:function size:0x54 fn_8009D950 = .text:0x8009D950; // type:function size:0x54 -fn_8009D9B0 = .text:0x8009D9B0; // type:function size:0x5C +isThisActorInEvent__17ActorEventRelatedFv = .text:0x8009D9B0; // type:function size:0x5C fn_8009DA10 = .text:0x8009DA10; // type:function size:0x30 fn_8009DA40 = .text:0x8009DA40; // type:function size:0x40 fn_8009DA80 = .text:0x8009DA80; // type:function size:0xC @@ -14515,52 +14515,52 @@ fn_80274330 = .text:0x80274330; // type:function size:0x14 fn_80274350 = .text:0x80274350; // type:function size:0x18 fn_80274370 = .text:0x80274370; // type:function size:0x10 fn_80274380 = .text:0x80274380; // type:function size:0x5C -fn_802743E0 = .text:0x802743E0; // type:function size:0xBC -fn_802744A0 = .text:0x802744A0; // type:function size:0x58 -fn_80274500 = .text:0x80274500; // type:function size:0x6C -fn_80274570 = .text:0x80274570; // type:function size:0xA0 -fn_80274610 = .text:0x80274610; // type:function size:0xA4 -fn_802746C0 = .text:0x802746C0; // type:function size:0x1B0 -fn_80274870 = .text:0x80274870; // type:function size:0x10 -fn_80274880 = .text:0x80274880; // type:function size:0x8 -fn_80274890 = .text:0x80274890; // type:function size:0x30 -fn_802748C0 = .text:0x802748C0; // type:function size:0x10 -fn_802748D0 = .text:0x802748D0; // type:function size:0x8 -fn_802748E0 = .text:0x802748E0; // type:function size:0x70 -fn_80274950 = .text:0x80274950; // type:function size:0x70 -fn_802749C0 = .text:0x802749C0; // type:function size:0x164 -fn_80274B30 = .text:0x80274B30; // type:function size:0x64 -fn_80274BA0 = .text:0x80274BA0; // type:function size:0x48 -fn_80274BF0 = .text:0x80274BF0; // type:function size:0x120 -fn_80274D10 = .text:0x80274D10; // type:function size:0x4 -fn_80274D20 = .text:0x80274D20; // type:function size:0xC -fn_80274D30 = .text:0x80274D30; // type:function size:0x54 -fn_80274D90 = .text:0x80274D90; // type:function size:0x4 -fn_80274DA0 = .text:0x80274DA0; // type:function size:0x94 -fn_80274E40 = .text:0x80274E40; // type:function size:0x74 -fn_80274EC0 = .text:0x80274EC0; // type:function size:0x4 -fn_80274ED0 = .text:0x80274ED0; // type:function size:0xC -fn_80274EE0 = .text:0x80274EE0; // type:function size:0x104 -fn_80274FF0 = .text:0x80274FF0; // type:function size:0x4 -fn_80275000 = .text:0x80275000; // type:function size:0xD4 -fn_802750E0 = .text:0x802750E0; // type:function size:0x10 -fn_802750F0 = .text:0x802750F0; // type:function size:0x60 -fn_80275150 = .text:0x80275150; // type:function size:0xC -fn_80275160 = .text:0x80275160; // type:function size:0x1C -fn_80275180 = .text:0x80275180; // type:function size:0x1C -fn_802751A0 = .text:0x802751A0; // type:function size:0x1C -fn_802751C0 = .text:0x802751C0; // type:function size:0x10 -fn_802751D0 = .text:0x802751D0; // type:function size:0x10 -fn_802751E0 = .text:0x802751E0; // type:function size:0x10 -fn_802751F0 = .text:0x802751F0; // type:function size:0x10 -fn_80275200 = .text:0x80275200; // type:function size:0x10 -fn_80275210 = .text:0x80275210; // type:function size:0x10 -fn_80275220 = .text:0x80275220; // type:function size:0x30 -fn_80275250 = .text:0x80275250; // type:function size:0x30 -fn_80275280 = .text:0x80275280; // type:function size:0x30 -fn_802752B0 = .text:0x802752B0; // type:function size:0x338 -fn_802755F0 = .text:0x802755F0; // type:function size:0x58 -fn_80275650 = .text:0x80275650; // type:function size:0x88 +dTgSw_c_classInit__Fv = .text:0x802743E0; // type:function size:0xBC +__dt__19sFState_c<7dTgSw_c>Fv = .text:0x802744A0; // type:function size:0x58 +__dt__22sFStateFct_c<7dTgSw_c>Fv = .text:0x80274500; // type:function size:0x6C +__dt__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80274570; // type:function size:0xA0 +__dt__45sFStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c>Fv = .text:0x80274610; // type:function size:0xA4 +create__7dTgSw_cFv = .text:0x802746C0; // type:function size:0x1B0 +changeState__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x80274870; // type:function size:0x10 +doDelete__7dTgSw_cFv = .text:0x80274880; // type:function size:0x8 +actorExecute__7dTgSw_cFv = .text:0x80274890; // type:function size:0x30 +executeState__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802748C0; // type:function size:0x10 +draw__7dTgSw_cFv = .text:0x802748D0; // type:function size:0x8 +resetAllSwitches__7dTgSw_cFv = .text:0x802748E0; // type:function size:0x70 +resetSwitchesAfterCurrent__7dTgSw_cFv = .text:0x80274950; // type:function size:0x70 +isPuzzleSolved__7dTgSw_cFv = .text:0x802749C0; // type:function size:0x164 +isLmfBossKeyPuzzle__7dTgSw_cFv = .text:0x80274B30; // type:function size:0x64 +initializeState_OnWait__7dTgSw_cFv = .text:0x80274BA0; // type:function size:0x48 +executeState_OnWait__7dTgSw_cFv = .text:0x80274BF0; // type:function size:0x120 +finalizeState_OnWait__7dTgSw_cFv = .text:0x80274D10; // type:function size:0x4 +initializeState_On__7dTgSw_cFv = .text:0x80274D20; // type:function size:0xC +executeState_On__7dTgSw_cFv = .text:0x80274D30; // type:function size:0x54 +finalizeState_On__7dTgSw_cFv = .text:0x80274D90; // type:function size:0x4 +initializeState_OffWait__7dTgSw_cFv = .text:0x80274DA0; // type:function size:0x94 +executeState_OffWait__7dTgSw_cFv = .text:0x80274E40; // type:function size:0x74 +finalizeState_OffWait__7dTgSw_cFv = .text:0x80274EC0; // type:function size:0x4 +initializeState_Off__7dTgSw_cFv = .text:0x80274ED0; // type:function size:0xC +executeState_Off__7dTgSw_cFv = .text:0x80274EE0; // type:function size:0x104 +finalizeState_Off__7dTgSw_cFv = .text:0x80274FF0; // type:function size:0x4 +__dt__7dTgSw_cFv = .text:0x80275000; // type:function size:0xD4 +getStateID__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x802750E0; // type:function size:0x10 +build__22sFStateFct_c<7dTgSw_c>FRC12sStateIDIf_c = .text:0x802750F0; // type:function size:0x60 +dispose__22sFStateFct_c<7dTgSw_c>FRP10sStateIf_c = .text:0x80275150; // type:function size:0xC +initialize__19sFState_c<7dTgSw_c>Fv = .text:0x80275160; // type:function size:0x1C +execute__19sFState_c<7dTgSw_c>Fv = .text:0x80275180; // type:function size:0x1C +finalize__19sFState_c<7dTgSw_c>Fv = .text:0x802751A0; // type:function size:0x1C +initializeState__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802751C0; // type:function size:0x10 +finalizeState__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802751D0; // type:function size:0x10 +refreshState__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802751E0; // type:function size:0x10 +getState__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x802751F0; // type:function size:0x10 +getNewStateID__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80275200; // type:function size:0x10 +getOldStateID__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80275210; // type:function size:0x10 +finalizeState__21sFStateID_c<7dTgSw_c>CFR7dTgSw_c = .text:0x80275220; // type:function size:0x30 +executeState__21sFStateID_c<7dTgSw_c>CFR7dTgSw_c = .text:0x80275250; // type:function size:0x30 +initializeState__21sFStateID_c<7dTgSw_c>CFR7dTgSw_c = .text:0x80275280; // type:function size:0x30 +__sinit_\d_t_switch_cpp = .text:0x802752B0; // type:function size:0x338 scope:local +__dt__21sFStateID_c<7dTgSw_c>Fv = .text:0x802755F0; // type:function size:0x58 +isSameName__21sFStateID_c<7dTgSw_c>CFPCc = .text:0x80275650; // type:function size:0x88 fn_802756E0 = .text:0x802756E0; // type:function size:0x4C fn_80275730 = .text:0x80275730; // type:function size:0x124 fn_80275860 = .text:0x80275860; // type:function size:0x8 @@ -33878,7 +33878,8 @@ lbl_8052C688 = .data:0x8052C688; // type:object size:0x2C lbl_8052C6B4 = .data:0x8052C6B4; // type:object size:0x2C lbl_8052C6E0 = .data:0x8052C6E0; // type:object size:0x2C lbl_8052C70C = .data:0x8052C70C; // type:object size:0x2C -lbl_8052C738 = .data:0x8052C738; // type:object size:0xA0 +lbl_8052C738 = .data:0x8052C738; // type:object size:0x2C +__vt__5dTg_c = .data:0x8052C764; // type:object size:0x74 lbl_8052C7D8 = .data:0x8052C7D8; // type:object size:0x4C lbl_8052C824 = .data:0x8052C824; // type:object size:0x34 lbl_8052C858 = .data:0x8052C858; // type:object size:0xC @@ -34497,14 +34498,15 @@ lbl_80536040 = .data:0x80536040; // type:object size:0x50 lbl_80536090 = .data:0x80536090; // type:object size:0x20 lbl_805360B0 = .data:0x805360B0; // type:object size:0x88 lbl_80536138 = .data:0x80536138; // type:object size:0x78 -lbl_805361B0 = .data:0x805361B0; // type:object size:0x10 -lbl_805361C0 = .data:0x805361C0; // type:object size:0x10 -lbl_805361D0 = .data:0x805361D0; // type:object size:0x78 -lbl_80536248 = .data:0x80536248; // type:object size:0x30 -lbl_80536278 = .data:0x80536278; // type:object size:0x30 -lbl_805362A8 = .data:0x805362A8; // type:object size:0x18 -lbl_805362C0 = .data:0x805362C0; // type:object size:0x180 -lbl_80536440 = .data:0x80536440; // type:object size:0x48 +g_profile_SW_TAG = .data:0x805361B0; // type:object size:0x10 +lbl_805361C0 = .data:0x805361C0; // type:object size:0xD data:string +__vt__7dTgSw_c = .data:0x805361D0; // type:object size:0x74 +__vt__45sFStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c> = .data:0x80536248; // type:object size:0x30 +__vt__75sStateMgr_c<7dTgSw_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x80536278; // type:object size:0x30 +__vt__22sFStateFct_c<7dTgSw_c> = .data:0x805362A8; // type:object size:0x14 +__vt__19sFState_c<7dTgSw_c> = .data:0x805362C0; // type:object size:0x18 +__vt__21sFStateID_c<7dTgSw_c> = .data:0x80536440; // type:object size:0x34 +lbl_80536478 = .data:0x80536478; // type:object size:0x10 lbl_80536488 = .data:0x80536488; // type:object size:0xC lbl_80536494 = .data:0x80536494; // type:object size:0xC lbl_805364A0 = .data:0x805364A0; // type:object size:0x10 @@ -38847,9 +38849,9 @@ lbl_80573A50 = .sdata:0x80573A50; // type:object size:0x4 lbl_80573A54 = .sdata:0x80573A54; // type:object size:0x4 lbl_80573A58 = .sdata:0x80573A58; // type:object size:0x8 lbl_80573A60 = .sdata:0x80573A60; // type:object size:0x5 data:string -lbl_80573A68 = .sdata:0x80573A68; // type:object size:0x7 -lbl_80573A70 = .sdata:0x80573A70; // type:object size:0x8 -lbl_80573A78 = .sdata:0x80573A78; // type:object size:0x8 +lbl_80573A68 = .sdata:0x80573A68; // type:object size:0x7 data:string +lbl_80573A70 = .sdata:0x80573A70; // type:object size:0x5 data:string +lbl_80573A78 = .sdata:0x80573A78; // type:object size:0x7 data:string lbl_80573A80 = .sdata:0x80573A80; // type:object size:0x8 lbl_80573A88 = .sdata:0x80573A88; // type:object size:0x8 lbl_80573A90 = .sdata:0x80573A90; // type:object size:0x8 @@ -45401,7 +45403,7 @@ lbl_8057C500 = .sdata2:0x8057C500; // type:object size:0x8 data:float lbl_8057C508 = .sdata2:0x8057C508; // type:object size:0x4 data:float lbl_8057C50C = .sdata2:0x8057C50C; // type:object size:0x4 data:float lbl_8057C510 = .sdata2:0x8057C510; // type:object size:0x8 data:float -lbl_8057C518 = .sdata2:0x8057C518; // type:object size:0x8 data:byte +lbl_8057C518 = .sdata2:0x8057C518; // type:object size:0x4 data:byte lbl_8057C520 = .sdata2:0x8057C520; // type:object size:0x4 data:float lbl_8057C524 = .sdata2:0x8057C524; // type:object size:0x4 data:float lbl_8057C528 = .sdata2:0x8057C528; // type:object size:0x4 data:float @@ -48915,10 +48917,11 @@ StateID_OffWait__8dAcOsw_c = .bss:0x805B55B8; // type:object size:0x30 data:4byt StateID_Off__8dAcOsw_c = .bss:0x805B55F8; // type:object size:0x30 data:4byte StateID_None__8dAcOsw_c = .bss:0x805B5638; // type:object size:0x30 data:4byte lbl_805B5668 = .bss:0x805B5668; // type:object size:0x40 -lbl_805B56A8 = .bss:0x805B56A8; // type:object size:0x10 -lbl_805B56B8 = .bss:0x805B56B8; // type:object size:0x80 data:4byte -lbl_805B5738 = .bss:0x805B5738; // type:object size:0x40 data:4byte -lbl_805B5778 = .bss:0x805B5778; // type:object size:0x30 data:4byte +lbl_805B56A8 = .bss:0x805B56A8; // type:object size:0xC +StateID_OnWait__7dTgSw_c = .bss:0x805B56B8; // type:object size:0x30 data:4byte +StateID_On__7dTgSw_c = .bss:0x805B56F8; // type:object size:0x30 data:4byte +StateID_OffWait__7dTgSw_c = .bss:0x805B5738; // type:object size:0x30 data:4byte +StateID_Off__7dTgSw_c = .bss:0x805B5778; // type:object size:0x30 data:4byte lbl_805B57A8 = .bss:0x805B57A8; // type:object size:0x18 data:4byte lbl_805B57C0 = .bss:0x805B57C0; // type:object size:0x10 lbl_805B57D0 = .bss:0x805B57D0; // type:object size:0x30 data:4byte diff --git a/configure.py b/configure.py index 76af0dde..4ee7c637 100644 --- a/configure.py +++ b/configure.py @@ -329,6 +329,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Object(NonMatching, "d/a/obj/d_a_obj_tbox.cpp"), Object(NonMatching, "d/a/obj/d_a_obj_time_area.cpp"), Object(Matching, "d/a/obj/d_a_obj_switch.cpp"), + Object(Matching, "d/tg/d_t_switch.cpp"), Object(Matching, "toBeSorted/arc_managers/current_stage_arc_manager.cpp"), Object(Matching, "toBeSorted/arc_managers/oarc_manager.cpp"), Object(Matching, "toBeSorted/arc_managers/layout_arc_manager.cpp"), diff --git a/include/d/tg/d_t_switch.h b/include/d/tg/d_t_switch.h new file mode 100644 index 00000000..0e241f25 --- /dev/null +++ b/include/d/tg/d_t_switch.h @@ -0,0 +1,45 @@ +#ifndef D_T_SWITCH_H +#define D_T_SWITCH_H + +#include +#include +#include +#include + +class dTgSw_c : public dTg_c { +public: + dTgSw_c() : mStateMgr(*this, sStateID::null), mActorEvent(*this, nullptr) {} + virtual ~dTgSw_c() {} + + virtual int create() override; + virtual int doDelete() override; + virtual int actorExecute() override; + virtual int draw() override; + + STATE_FUNC_DECLARE(dTgSw_c, OnWait); + STATE_FUNC_DECLARE(dTgSw_c, On); + STATE_FUNC_DECLARE(dTgSw_c, OffWait); + STATE_FUNC_DECLARE(dTgSw_c, Off); + +private: + bool isLmfBossKeyPuzzle(); + void resetAllSwitches(); + void resetSwitchesAfterCurrent(); + bool isPuzzleSolved(); + + /* 0x0FC */ STATE_MGR_DECLARE(dTgSw_c); + /* 0x138 */ ActorEventRelated mActorEvent; + /* 0x188 */ u8 mSetSceneFlagId; + /* 0x189 */ u8 mTrigSceneFlagIdBegin; + /* 0x18A */ u8 mFirst2; + /* 0x18B */ u8 mSecond2; + /* 0x18C */ u8 mThird2; + /* 0x18D */ u8 mNumSwitchesToWin; + /* 0x18E */ u8 mTrigSceneFlagIdEnd; + /* 0x18F */ u8 mTimer; + /* 0x190 */ u8 mCurrentFlagPosition; + /* 0x191 */ bool mIsFsBossKeyPuzzle; + /* 0x192 */ u8 field_0x192; +}; + +#endif diff --git a/include/d/tg/d_t_timer.h b/include/d/tg/d_t_timer.h index 8bf7b15c..e8caf0fc 100644 --- a/include/d/tg/d_t_timer.h +++ b/include/d/tg/d_t_timer.h @@ -2,14 +2,9 @@ #define D_T_TIMER_H #include +#include -class dTgTimerBase_c : public dAcBase_c { -public: - virtual ~dTgTimerBase_c() {} -}; - - -class dTgTimer_c : public dTgTimerBase_c { +class dTgTimer_c : public dTg_c { public: dTgTimer_c() {} virtual ~dTgTimer_c() {} diff --git a/include/toBeSorted/actor_event.h b/include/toBeSorted/actor_event.h new file mode 100644 index 00000000..d9cdcec1 --- /dev/null +++ b/include/toBeSorted/actor_event.h @@ -0,0 +1,20 @@ +#ifndef ACTOR_EVENT_H +#define ACTOR_EVENT_H + +#include +#include +#include + +class ActorEventRelated { +public: + ActorEventRelated(dAcBase_c &owner, void *); + ~ActorEventRelated(); + + bool isThisActorInEvent(); + void scheduleEvent(Event &, u32); + +private: + u8 field_0x00[0x50 - 0x00]; +}; + +#endif diff --git a/include/toBeSorted/sceneflag_manager.h b/include/toBeSorted/sceneflag_manager.h index a8fe5112..9eb1161d 100644 --- a/include/toBeSorted/sceneflag_manager.h +++ b/include/toBeSorted/sceneflag_manager.h @@ -48,7 +48,7 @@ class SceneflagManager { u16 checkFlag(u16 roomId, u16 flag); bool checkSceneflagGlobal(u16 sceneIdx, u16 flag); bool checkTempOrSceneflag(u16 flag); - bool checkUncommittedFlag(u16 roomId, u16 flag); + u16 checkUncommittedFlag(u16 roomId, u16 flag); void setZoneflag(u16 roomId, u16 flag); void setFlag(u16 roomId, u16 flag); void setSceneflagGlobal(u16 sceneIdx, u16 flag); diff --git a/src/d/tg/d_t_switch.cpp b/src/d/tg/d_t_switch.cpp new file mode 100644 index 00000000..d219443b --- /dev/null +++ b/src/d/tg/d_t_switch.cpp @@ -0,0 +1,187 @@ +#include +#include +#include +#include +#include + +SPECIAL_ACTOR_PROFILE(SW_TAG, dTgSw_c, fProfile::SW_TAG, 0x24, 0, 0); + +STATE_DEFINE(dTgSw_c, OnWait); +STATE_DEFINE(dTgSw_c, On); +STATE_DEFINE(dTgSw_c, OffWait); +STATE_DEFINE(dTgSw_c, Off); + +static const u8 D201_BossKeyPuzzleFlags[] = {0x25, 0x2E, 0x49, 0x4B}; + +int dTgSw_c::create() { + mFirst2 = params & 0b11; + if (mFirst2 >= 2) { + mFirst2 = 0; + } + mSecond2 = (params >> 2) & 0b11; + if (mSecond2 >= 3) { + mSecond2 = 0; + } + mThird2 = (params >> 4) & 0b11; + if (mThird2 >= 3) { + mThird2 = 0; + } + mSetSceneFlagId = (params >> 6) & 0xFF; + mTrigSceneFlagIdBegin = (params >> 14) & 0xFF; + mNumSwitchesToWin = (params >> 22) & 0x3F; + mTrigSceneFlagIdEnd = mNumSwitchesToWin; + if ((int)(params >> 0x1C) < 0xF) { + mTrigSceneFlagIdEnd += (params >> 0x1C); + } + + if (ScGame::isCurrentStage("D201")) { + if (roomid == 4) { + if (!SceneflagManager::sInstance->checkBoolFlag(roomid, 0x2F)) { + SceneflagManager::sInstance->unsetFlag(roomid, mSetSceneFlagId); + resetAllSwitches(); + const u8 *flag = D201_BossKeyPuzzleFlags; + for (u32 i = 0; i < 4; i++) { + SceneflagManager::sInstance->unsetFlag(roomid, *flag); + flag++; + } + } + mIsFsBossKeyPuzzle = true; + } + } + + bool b = SceneflagManager::sInstance->checkUncommittedFlag(roomid, mSetSceneFlagId); + mStateMgr.changeState(!b ? StateID_OnWait : StateID_OffWait); + return SUCCEEDED; +} + +int dTgSw_c::doDelete() { + return SUCCEEDED; +} + +int dTgSw_c::actorExecute() { + mStateMgr.executeState(); + return SUCCEEDED; +} + +int dTgSw_c::draw() { + return SUCCEEDED; +} + +void dTgSw_c::resetAllSwitches() { + for (int i = mTrigSceneFlagIdBegin; i < mTrigSceneFlagIdBegin + mTrigSceneFlagIdEnd; i++) { + SceneflagManager::sInstance->unsetFlag(roomid, i); + } + mCurrentFlagPosition = 0; +} + +void dTgSw_c::resetSwitchesAfterCurrent() { + for (int i = mTrigSceneFlagIdBegin + mCurrentFlagPosition; i < mTrigSceneFlagIdBegin + mTrigSceneFlagIdEnd; i++) { + SceneflagManager::sInstance->unsetFlag(roomid, i); + } +} + +bool dTgSw_c::isPuzzleSolved() { + for (int i = 0; i < mCurrentFlagPosition; i++) { + if (!SceneflagManager::sInstance->checkBoolFlag(roomid, mTrigSceneFlagIdBegin + i)) { + mCurrentFlagPosition = i; + field_0x192 = 1; + } + } + + if (field_0x192 == 0 && + SceneflagManager::sInstance->checkBoolFlag(roomid, mTrigSceneFlagIdBegin + mCurrentFlagPosition)) { + mCurrentFlagPosition++; + } + + s32 numCorrectFlags = mCurrentFlagPosition; + for (int i = mCurrentFlagPosition; i < mTrigSceneFlagIdEnd; i++) { + int t = i < mNumSwitchesToWin ? i : mNumSwitchesToWin; + if (SceneflagManager::sInstance->checkBoolFlag(roomid, mTrigSceneFlagIdBegin + t)) { + field_0x192 = 1; + numCorrectFlags++; + } + } + + return numCorrectFlags >= mNumSwitchesToWin; +} + +bool dTgSw_c::isLmfBossKeyPuzzle() { + return ScGame::isCurrentStage("D300_1") && roomid == 8 && mSetSceneFlagId == 0x1C; +} + +void dTgSw_c::initializeState_OnWait() { + SceneflagManager::sInstance->unsetFlag(roomid, mSetSceneFlagId); + field_0x192 = 0; +} +void dTgSw_c::executeState_OnWait() { + bool state = isPuzzleSolved(); + if (mSecond2 == 0) { + field_0x192 = 0; + if (state) { + mStateMgr.changeState(StateID_On); + } + } else if (mSecond2 == 1) { + if (field_0x192) { + mStateMgr.changeState(StateID_Off); + } else { + if (state) { + mStateMgr.changeState(mIsFsBossKeyPuzzle ? StateID_OffWait : StateID_On); + } + } + } else if (state) { + if (field_0x192) { + mStateMgr.changeState(StateID_Off); + } else { + mStateMgr.changeState(StateID_On); + } + } +} +void dTgSw_c::finalizeState_OnWait() {} + +void dTgSw_c::initializeState_On() { + mTimer = 4; +} +void dTgSw_c::executeState_On() { + if (cM::calcTimer(&mTimer) == 0) { + mStateMgr.changeState(StateID_OffWait); + } +} +void dTgSw_c::finalizeState_On() {} + +void dTgSw_c::initializeState_OffWait() { + if (!SceneflagManager::sInstance->checkBoolFlag(roomid, mSetSceneFlagId) && isLmfBossKeyPuzzle()) { + SceneflagManager::sInstance->setFlag(roomid, 0xC0); + } + SceneflagManager::sInstance->setFlag(roomid, mSetSceneFlagId); +} +void dTgSw_c::executeState_OffWait() { + if (mFirst2 == 1 && !isPuzzleSolved()) { + SceneflagManager::sInstance->unsetFlag(roomid, mSetSceneFlagId); + mStateMgr.changeState(StateID_Off); + } +} +void dTgSw_c::finalizeState_OffWait() {} + +void dTgSw_c::initializeState_Off() { + mTimer = 4; +} +void dTgSw_c::executeState_Off() { + if (mIsFsBossKeyPuzzle && !mActorEvent.isThisActorInEvent()) { + Event event = Event("FireCandleOn", 100, 0x100001, nullptr, nullptr); + mActorEvent.scheduleEvent(event, 0); + return; + } + if (cM::calcTimer(&mTimer) == 0) { + if (mThird2 == 1) { + resetAllSwitches(); + } else if (mThird2 != 2) { + resetSwitchesAfterCurrent(); + } + + if (isLmfBossKeyPuzzle()) { + SceneflagManager::sInstance->setFlag(roomid, 0xC1); + } + mStateMgr.changeState(StateID_OnWait); + } +} +void dTgSw_c::finalizeState_Off() {} diff --git a/src/toBeSorted/sceneflag_manager.cpp b/src/toBeSorted/sceneflag_manager.cpp index 36ab7087..a446027c 100644 --- a/src/toBeSorted/sceneflag_manager.cpp +++ b/src/toBeSorted/sceneflag_manager.cpp @@ -165,7 +165,7 @@ bool SceneflagManager::checkTempOrSceneflag(u16 flag) { return checkSceneflagGlobal(mSceneIdx, flag); } } -bool SceneflagManager::checkUncommittedFlag(u16 roomId, u16 flag) { +u16 SceneflagManager::checkUncommittedFlag(u16 roomId, u16 flag) { if (isZoneFlag(flag)) { return checkUncommittedZoneflag(roomId, flag); } else {