diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 82369de1..0a66776a 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -590,9 +590,14 @@ d/a/d_a_player.cpp: .text start:0x801C5C30 end:0x802471F8 .ctors start:0x804DB824 end:0x804DB828 -d/a/obj/d_a_obj_item.cpp: +d/a/d_a_item.cpp: .text start:0x80247200 end:0x80258E58 .ctors start:0x804DB828 end:0x804DB82C + .rodata start:0x804EBBB0 end:0x804ED33C + .data start:0x80533268 end:0x80534490 + .sbss start:0x805758B8 end:0x805758E0 + .sdata2 start:0x8057BD88 end:0x8057BF7C + .bss start:0x805B4490 end:0x805B48A8 d/a/obj/d_a_obj_bomb.cpp: .text start:0x80258E60 end:0x8025D5D8 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c9058917..e761d496 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -13342,7 +13342,7 @@ increment = .text:0x80247EC0; // type:function size:0x28 fn_80247EF0 = .text:0x80247EF0; // type:function size:0xA4 fn_80247FA0 = .text:0x80247FA0; // type:function size:0x8 fn_80247FB0 = .text:0x80247FB0; // type:function size:0x8 -AcItem__ctor = .text:0x80247FC0; // type:function size:0x30 +dAcItem_c_classInit__Fv = .text:0x80247FC0; // type:function size:0x30 AcItem__dontForceDemo = .text:0x80247FF0; // type:function size:0x8 AcItem__shouldForceDemo = .text:0x80248000; // type:function size:0x8 fn_80248010 = .text:0x80248010; // type:function size:0x8 @@ -13351,13 +13351,13 @@ fn_80248030 = .text:0x80248030; // type:function size:0x8 fn_80248040 = .text:0x80248040; // type:function size:0x8 fn_80248050 = .text:0x80248050; // type:function size:0x8 fn_80248060 = .text:0x80248060; // type:function size:0x8 -AcItem__ctorCont = .text:0x80248070; // type:function size:0x1FC +__ct__9dAcItem_cFv = .text:0x80248070; // type:function size:0x1FC fn_80248270 = .text:0x80248270; // type:function size:0x58 -fn_802482D0 = .text:0x802482D0; // type:function size:0x58 -fn_80248330 = .text:0x80248330; // type:function size:0x6C -fn_802483A0 = .text:0x802483A0; // type:function size:0xA0 -fn_80248440 = .text:0x80248440; // type:function size:0xA4 -fn_802484F0 = .text:0x802484F0; // type:function size:0x248 +__dt__21sFState_c<9dAcItem_c>Fv = .text:0x802482D0; // type:function size:0x58 +__dt__24sFStateFct_c<9dAcItem_c>Fv = .text:0x80248330; // type:function size:0x6C +__dt__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802483A0; // type:function size:0xA0 +__dt__47sFStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c>Fv = .text:0x80248440; // type:function size:0xA4 +__dt__9dAcItem_cFv = .text:0x802484F0; // type:function size:0x248 fn_80248740 = .text:0x80248740; // type:function size:0x40 fn_80248780 = .text:0x80248780; // type:function size:0x40 AcItem__spawnItem = .text:0x802487C0; // type:function size:0x170 @@ -13402,11 +13402,11 @@ AcItem__getItemListElement = .text:0x8024A450; // type:function size:0x8 AcItem__getFinalDeterminedItemId = .text:0x8024A460; // type:function size:0x8 AcItem__initModels = .text:0x8024A470; // type:function size:0x75C AcItem__init = .text:0x8024ABD0; // type:function size:0x2888 -changeStateFromEventMaybeMaybe = .text:0x8024D460; // type:function size:0x10 -fn_8024D470 = .text:0x8024D470; // type:function size:0x10 +changeState__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x8024D460; // type:function size:0x10 +getStateID__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x8024D470; // type:function size:0x10 AcItem__destroy = .text:0x8024D480; // type:function size:0xEC AcItem__update = .text:0x8024D570; // type:function size:0x66C -fn_8024DBE0 = .text:0x8024DBE0; // type:function size:0x10 +executeState__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8024DBE0; // type:function size:0x10 AcItem__draw = .text:0x8024DBF0; // type:function size:0x304 setNumberOfItems = .text:0x8024DF00; // type:function size:0x8 AcItem__setFreestandingYOffset = .text:0x8024DF10; // type:function size:0x8 @@ -13416,42 +13416,42 @@ isItemDropFromEnemy = .text:0x8024DF40; // type:function size:0x24 resetNumberOfItems = .text:0x8024DF70; // type:function size:0xC AcItem__resetFramesInAir = .text:0x8024DF80; // type:function size:0x8 AcItem__incrementFramesInAir = .text:0x8024DF90; // type:function size:0x44 -AcItem__stateWaitEnter = .text:0x8024DFE0; // type:function size:0xA8 -AcItem__stateWaitUpdate = .text:0x8024E090; // type:function size:0x10AC -AcItem__stateWaitLeave = .text:0x8024F140; // type:function size:0x7C -AcItem__stateCarryEnter = .text:0x8024F1C0; // type:function size:0x94 -AcItem__stateCarryUpdate = .text:0x8024F260; // type:function size:0x2D0 -AcItem__stateCarryLeave = .text:0x8024F530; // type:function size:0x4 -AcItem__stateGetBeetleEnter = .text:0x8024F540; // type:function size:0x120 -AcItem__stateGetBeetleUpdate = .text:0x8024F660; // type:function size:0x194 -AcItem__stateGetBeetleLeave = .text:0x8024F800; // type:function size:0x4 -AcItem__stateWaitGetEnter = .text:0x8024F810; // type:function size:0x48 -AcItem__stateWaitGetUpdate = .text:0x8024F860; // type:function size:0x90 -AcItem__stateWaitGetLeave = .text:0x8024F8F0; // type:function size:0x10 -AcItem__stateGetEnter = .text:0x8024F900; // type:function size:0xAC -AcItem__stateGetUpdate = .text:0x8024F9B0; // type:function size:0x70 -AcItem__stateGetLeave = .text:0x8024FA20; // type:function size:0x4 -AcItem__stateWaitGetDemoEnter = .text:0x8024FA30; // type:function size:0x7C -AcItem__stateWaitGetDemoUpdate = .text:0x8024FAB0; // type:function size:0x14C -AcItem__stateWaitGetDemoLeave = .text:0x8024FC00; // type:function size:0x4 -AcItem__stateWaitForcedGetEnter = .text:0x8024FC10; // type:function size:0x74 -AcItem__stateWaitForcedGetUpdate = .text:0x8024FC90; // type:function size:0x68 -AcItem__stateWaitForcedGetLeave = .text:0x8024FD00; // type:function size:0x4 -AcItem__stateGetDemoEnter = .text:0x8024FD10; // type:function size:0x2EC -AcItem__stateGetDemoUpdate = .text:0x80250000; // type:function size:0x274 -AcItem__stateGetDemoLeave = .text:0x80250280; // type:function size:0x84 -AcItem__stateWaitTboxGetDemoEnter = .text:0x80250310; // type:function size:0x74 -AcItem__stateWaitTboxGetDemoUpdate = .text:0x80250390; // type:function size:0x88 -AcItem__stateWaitTboxGetDemoLeave = .text:0x80250420; // type:function size:0x4 -AcItem__stateResurgeWaitEnter = .text:0x80250430; // type:function size:0xA4 -AcItem__stateResurgeWaitUpdate = .text:0x802504E0; // type:function size:0xA4 -AcItem__stateResurgeWaitLeave = .text:0x80250590; // type:function size:0x4 -AcItem__stateWaitTurnOffEnter = .text:0x802505A0; // type:function size:0x64 -AcItem__stateWaitTurnOffUpdate = .text:0x80250610; // type:function size:0x20 -AcItem__stateWaitTurnOffLeave = .text:0x80250630; // type:function size:0x4 -AcItem__stateWaitSacredDewGetEffectEnter = .text:0x80250640; // type:function size:0x64 -AcItem__stateWaitSacredDewGetEffectUpdate = .text:0x802506B0; // type:function size:0x80 -AcItem__stateWaitSacredDewGetEffectLeave = .text:0x80250730; // type:function size:0x4 +initializeState_Wait__9dAcItem_cFv = .text:0x8024DFE0; // type:function size:0xA8 +executeState_Wait__9dAcItem_cFv = .text:0x8024E090; // type:function size:0x10AC +finalizeState_Wait__9dAcItem_cFv = .text:0x8024F140; // type:function size:0x7C +initializeState_Carry__9dAcItem_cFv = .text:0x8024F1C0; // type:function size:0x94 +executeState_Carry__9dAcItem_cFv = .text:0x8024F260; // type:function size:0x2D0 +finalizeState_Carry__9dAcItem_cFv = .text:0x8024F530; // type:function size:0x4 +initializeState_GetBeetle__9dAcItem_cFv = .text:0x8024F540; // type:function size:0x120 +executeState_GetBeetle__9dAcItem_cFv = .text:0x8024F660; // type:function size:0x194 +finalizeState_GetBeetle__9dAcItem_cFv = .text:0x8024F800; // type:function size:0x4 +initializeState_WaitGet__9dAcItem_cFv = .text:0x8024F810; // type:function size:0x48 +executeState_WaitGet__9dAcItem_cFv = .text:0x8024F860; // type:function size:0x90 +finalizeState_WaitGet__9dAcItem_cFv = .text:0x8024F8F0; // type:function size:0x10 +initializeState_Get__9dAcItem_cFv = .text:0x8024F900; // type:function size:0xAC +executeState_Get__9dAcItem_cFv = .text:0x8024F9B0; // type:function size:0x70 +finalizeState_Get__9dAcItem_cFv = .text:0x8024FA20; // type:function size:0x4 +initializeState_WaitGetDemo__9dAcItem_cFv = .text:0x8024FA30; // type:function size:0x7C +executeState_WaitGetDemo__9dAcItem_cFv = .text:0x8024FAB0; // type:function size:0x14C +finalizeState_WaitGetDemo__9dAcItem_cFv = .text:0x8024FC00; // type:function size:0x4 +initializeState_WaitForcedGetDemo__9dAcItem_cFv = .text:0x8024FC10; // type:function size:0x74 +executeState_WaitForcedGetDemo__9dAcItem_cFv = .text:0x8024FC90; // type:function size:0x68 +finalizeState_WaitForcedGetDemo__9dAcItem_cFv = .text:0x8024FD00; // type:function size:0x4 +initializeState_GetDemo__9dAcItem_cFv = .text:0x8024FD10; // type:function size:0x2EC +executeState_GetDemo__9dAcItem_cFv = .text:0x80250000; // type:function size:0x274 +finalizeState_GetDemo__9dAcItem_cFv = .text:0x80250280; // type:function size:0x84 +initializeState_WaitTBoxGetDemo__9dAcItem_cFv = .text:0x80250310; // type:function size:0x74 +executeState_WaitTBoxGetDemo__9dAcItem_cFv = .text:0x80250390; // type:function size:0x88 +finalizeState_WaitTBoxGetDemo__9dAcItem_cFv = .text:0x80250420; // type:function size:0x4 +initializeState_ResurgeWait__9dAcItem_cFv = .text:0x80250430; // type:function size:0xA4 +executeState_ResurgeWait__9dAcItem_cFv = .text:0x802504E0; // type:function size:0xA4 +finalizeState_ResurgeWait__9dAcItem_cFv = .text:0x80250590; // type:function size:0x4 +initializeState_WaitTurnOff__9dAcItem_cFv = .text:0x802505A0; // type:function size:0x64 +executeState_WaitTurnOff__9dAcItem_cFv = .text:0x80250610; // type:function size:0x20 +finalizeState_WaitTurnOff__9dAcItem_cFv = .text:0x80250630; // type:function size:0x4 +initializeState_WaitSacredDewGetEffect__9dAcItem_cFv = .text:0x80250640; // type:function size:0x64 +executeState_WaitSacredDewGetEffect__9dAcItem_cFv = .text:0x802506B0; // type:function size:0x80 +finalizeState_WaitSacredDewGetEffect__9dAcItem_cFv = .text:0x80250730; // type:function size:0x4 getItemFromBWheelItem__9dAcItem_cFv = .text:0x80250740; // type:function size:0xEC setItemPosition__9dAcItem_cFRC7mVec3_c = .text:0x80250830; // type:function size:0x40 fn_80250870 = .text:0x80250870; // type:function size:0x38 @@ -13953,27 +13953,27 @@ fn_80257C20 = .text:0x80257C20; // type:function size:0x40 fn_80257C60 = .text:0x80257C60; // type:function size:0x40 fn_80257CA0 = .text:0x80257CA0; // type:function size:0x40 fn_80257CE0 = .text:0x80257CE0; // type:function size:0x40 -fn_80257D20 = .text:0x80257D20; // type:function size:0x60 -fn_80257D80 = .text:0x80257D80; // type:function size:0xC -fn_80257D90 = .text:0x80257D90; // type:function size:0x1C -fn_80257DB0 = .text:0x80257DB0; // type:function size:0x1C -fn_80257DD0 = .text:0x80257DD0; // type:function size:0x1C -fn_80257DF0 = .text:0x80257DF0; // type:function size:0x10 -fn_80257E00 = .text:0x80257E00; // type:function size:0x10 -fn_80257E10 = .text:0x80257E10; // type:function size:0x10 -fn_80257E20 = .text:0x80257E20; // type:function size:0x10 -fn_80257E30 = .text:0x80257E30; // type:function size:0x10 -fn_80257E40 = .text:0x80257E40; // type:function size:0x10 -fn_80257E50 = .text:0x80257E50; // type:function size:0x30 -fn_80257E80 = .text:0x80257E80; // type:function size:0x30 -fn_80257EB0 = .text:0x80257EB0; // type:function size:0x30 -AcItem__sinit = .text:0x80257EE0; // type:function size:0xDD0 +build__24sFStateFct_c<9dAcItem_c>FRC12sStateIDIf_c = .text:0x80257D20; // type:function size:0x60 +dispose__24sFStateFct_c<9dAcItem_c>FRP10sStateIf_c = .text:0x80257D80; // type:function size:0xC +initialize__21sFState_c<9dAcItem_c>Fv = .text:0x80257D90; // type:function size:0x1C +execute__21sFState_c<9dAcItem_c>Fv = .text:0x80257DB0; // type:function size:0x1C +finalize__21sFState_c<9dAcItem_c>Fv = .text:0x80257DD0; // type:function size:0x1C +initializeState__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80257DF0; // type:function size:0x10 +finalizeState__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80257E00; // type:function size:0x10 +refreshState__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80257E10; // type:function size:0x10 +getState__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80257E20; // type:function size:0x10 +getNewStateID__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80257E30; // type:function size:0x10 +getOldStateID__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80257E40; // type:function size:0x10 +finalizeState__23sFStateID_c<9dAcItem_c>CFR9dAcItem_c = .text:0x80257E50; // type:function size:0x30 +executeState__23sFStateID_c<9dAcItem_c>CFR9dAcItem_c = .text:0x80257E80; // type:function size:0x30 +initializeState__23sFStateID_c<9dAcItem_c>CFR9dAcItem_c = .text:0x80257EB0; // type:function size:0x30 +__sinit_\d_a_item_cpp = .text:0x80257EE0; // type:function size:0xDD0 scope:local fn_80258CB0 = .text:0x80258CB0; // type:function size:0x1C fn_80258CD0 = .text:0x80258CD0; // type:function size:0x40 fn_80258D10 = .text:0x80258D10; // type:function size:0x1C fn_80258D30 = .text:0x80258D30; // type:function size:0x40 -AcItem__state_dtor = .text:0x80258D70; // type:function size:0x58 -fn_80258DD0 = .text:0x80258DD0; // type:function size:0x88 +__dt__23sFStateID_c<9dAcItem_c>Fv = .text:0x80258D70; // type:function size:0x58 +isSameName__23sFStateID_c<9dAcItem_c>CFPCc = .text:0x80258DD0; // type:function size:0x88 dAcBomb_c_classInit__Fv = .text:0x80258E60; // type:function size:0x134 __dt__21sFState_c<9dAcBomb_c>Fv = .text:0x80258FA0; // type:function size:0x58 fn_80259000 = .text:0x80259000; // type:function size:0x6C @@ -25413,7 +25413,7 @@ GetBasicPlayer__Q44nw4r3snd6detail8SeqSoundFv = .text:0x80473120; // type:functi GetBasicPlayer__Q44nw4r3snd6detail8SeqSoundCFv = .text:0x80473130; // type:function size:0x8 IsPrepared__Q44nw4r3snd6detail8SeqSoundCFv = .text:0x80473140; // type:function size:0x8 GetRuntimeTypeInfo__Q44nw4r3snd6detail8SeqSoundCFv = .text:0x80473150; // type:function size:0x8 scope:weak -__sinit_snd_SeqSound_cpp = .text:0x80473160; // type:function size:0xC +__sinit_snd_SeqSound_cpp = .text:0x80473160; // type:function size:0xC scope:local __ct__Q34nw4r3snd14SeqSoundHandleFPQ34nw4r3snd11SoundHandle = .text:0x80473170; // type:function size:0xF4 DetachSound__Q34nw4r3snd14SeqSoundHandleFv = .text:0x80473270; // type:function size:0x38 SetPlayerTrackNo__Q44nw4r3snd6detail8SeqTrackFi = .text:0x804732B0; // type:function size:0x8 @@ -25472,7 +25472,7 @@ detail_AllocAmbientArg__Q34nw4r3snd14Sound3DManagerFUl = .text:0x80475E70; // ty detail_FreeAmbientArg__Q34nw4r3snd14Sound3DManagerFPvPCQ44nw4r3snd6detail10BasicSound = .text:0x80475EE0; // type:function size:0x14 SetBiquadFilterType__Q34nw4r3snd14Sound3DManagerFi = .text:0x80475F00; // type:function size:0x8 __ct__Q34nw4r3snd12Sound3DParamFv = .text:0x80475F10; // type:function size:0x28 -__sinit_snd_Sound3DManager_cpp = .text:0x80475F40; // type:function size:0xC +__sinit_snd_Sound3DManager_cpp = .text:0x80475F40; // type:function size:0xC scope:local @4@detail_FreeAmbientArg__Q34nw4r3snd14Sound3DManagerFPvPCQ44nw4r3snd6detail10BasicSound = .text:0x80475F50; // type:function size:0x8 @4@detail_AllocAmbientArg__Q34nw4r3snd14Sound3DManagerFUl = .text:0x80475F60; // type:function size:0x8 @4@__dt__Q34nw4r3snd14Sound3DManagerFv = .text:0x80475F70; // type:function size:0x8 @@ -25628,7 +25628,7 @@ GetRequiredMemSize__Q34nw4r3snd11SoundSystemFRCQ44nw4r3snd11SoundSystem16SoundSy InitSoundSystem__Q34nw4r3snd11SoundSystemFRCQ44nw4r3snd11SoundSystem16SoundSystemParamPvUl = .text:0x8047C480; // type:function size:0x1AC IsInitializedSoundSystem__Q34nw4r3snd11SoundSystemFv = .text:0x8047C630; // type:function size:0x8 WaitForResetReady__Q34nw4r3snd11SoundSystemFv = .text:0x8047C640; // type:function size:0x74 -__sinit_snd_SoundSystem_cpp = .text:0x8047C6C0; // type:function size:0x48 +__sinit_snd_SoundSystem_cpp = .text:0x8047C6C0; // type:function size:0x48 scope:local GetInstance__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C710; // type:function size:0xB8 __dt__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C7D0; // type:function size:0x70 Create__Q44nw4r3snd6detail11SoundThreadFlPvUl = .text:0x8047C840; // type:function size:0x12C @@ -25713,7 +25713,7 @@ GetBasicPlayer__Q44nw4r3snd6detail9StrmSoundFv = .text:0x80480D40; // type:funct GetBasicPlayer__Q44nw4r3snd6detail9StrmSoundCFv = .text:0x80480D50; // type:function size:0x8 IsPrepared__Q44nw4r3snd6detail9StrmSoundCFv = .text:0x80480D60; // type:function size:0x8 GetRuntimeTypeInfo__Q44nw4r3snd6detail9StrmSoundCFv = .text:0x80480D70; // type:function size:0x8 scope:weak -__sinit_snd_StrmSound_cpp = .text:0x80480D80; // type:function size:0xC +__sinit_snd_StrmSound_cpp = .text:0x80480D80; // type:function size:0xC scope:local __ct__Q34nw4r3snd15StrmSoundHandleFPQ34nw4r3snd11SoundHandle = .text:0x80480D90; // type:function size:0xF4 DetachSound__Q34nw4r3snd15StrmSoundHandleFv = .text:0x80480E90; // type:function size:0x38 __dt__Q44nw4r3snd6detail4TaskFv = .text:0x80480ED0; // type:function size:0x40 @@ -25816,7 +25816,7 @@ GetBasicPlayer__Q44nw4r3snd6detail9WaveSoundFv = .text:0x804852D0; // type:funct GetBasicPlayer__Q44nw4r3snd6detail9WaveSoundCFv = .text:0x804852E0; // type:function size:0x8 IsPrepared__Q44nw4r3snd6detail9WaveSoundCFv = .text:0x804852F0; // type:function size:0x8 GetRuntimeTypeInfo__Q44nw4r3snd6detail9WaveSoundCFv = .text:0x80485300; // type:function size:0x8 scope:weak -__sinit_snd_WaveSound_cpp = .text:0x80485310; // type:function size:0xC +__sinit_snd_WaveSound_cpp = .text:0x80485310; // type:function size:0xC scope:local detail_AttachSoundAsTempHandle__Q34nw4r3snd15WaveSoundHandleFPQ44nw4r3snd6detail9WaveSound = .text:0x80485320; // type:function size:0xF4 DetachSound__Q34nw4r3snd15WaveSoundHandleFv = .text:0x80485420; // type:function size:0x38 __ct__Q44nw4r3snd6detail13WsdFileReaderFPCv = .text:0x80485460; // type:function size:0x90 @@ -28524,8 +28524,8 @@ lbl_804EBB94 = .rodata:0x804EBB94; // type:object size:0xC data:float lbl_804EBBA0 = .rodata:0x804EBBA0; // type:object size:0x10 ITEM_INIT_STRUCTS = .rodata:0x804EBBB0; // type:object size:0x87C DEFAULT_ITEM_INIT_STRUCT = .rodata:0x804EC42C; // type:object size:0x14 -ITEM_FLAG_STRUCTS = .rodata:0x804EC440; // type:object size:0x538 -lbl_804EC978 = .rodata:0x804EC978; // type:object size:0x7F8 +l_item_flag_structs = .rodata:0x804EC440; // type:object size:0x538 scope:local +l_item_types = .rodata:0x804EC978; // type:object size:0x7F8 scope:local TRIAL_INDEX_STRUCTS = .rodata:0x804ED170; // type:object size:0x20 GLITTERING_SPORES_CHANCES = .rodata:0x804ED190; // type:object size:0x20 data:4byte lbl_804ED1B0 = .rodata:0x804ED1B0; // type:object size:0x18 @@ -28539,7 +28539,7 @@ RANDOM_ITEM_DEFINITIONS = .rodata:0x804ED268; // type:object size:0x38 data:4byt lbl_804ED2A0 = .rodata:0x804ED2A0; // type:object size:0x30 AcItem__SHOULD_DEMO_FUNCS = .rodata:0x804ED2D0; // type:object size:0x30 lbl_804ED300 = .rodata:0x804ED300; // type:object size:0x18 -lbl_804ED318 = .rodata:0x804ED318; // type:object size:0x28 +lbl_804ED318 = .rodata:0x804ED318; // type:object size:0x24 lbl_804ED340 = .rodata:0x804ED340; // type:object size:0x10 data:float lbl_804ED350 = .rodata:0x804ED350; // type:object size:0x30 lbl_804ED380 = .rodata:0x804ED380; // type:object size:0x30 @@ -34399,11 +34399,11 @@ lbl_80533D70 = .data:0x80533D70; // type:object size:0xC data:4byte jumptable_80533D7C = .data:0x80533D7C; // type:object size:0x90 scope:local lbl_80533E0C = .data:0x80533E0C; // type:object size:0x10 jumptable_80533E1C = .data:0x80533E1C; // type:object size:0x90 scope:local -AcItem__vtable = .data:0x80533EE0; // type:object size:0x98 -lbl_80533F78 = .data:0x80533F78; // type:object size:0x30 -lbl_80533FA8 = .data:0x80533FA8; // type:object size:0x30 -lbl_80533FD8 = .data:0x80533FD8; // type:object size:0x18 -lbl_80533FF0 = .data:0x80533FF0; // type:object size:0x18 +__vt__9dAcItem_c = .data:0x80533EE0; // type:object size:0x98 +__vt__47sFStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c> = .data:0x80533F78; // type:object size:0x30 +__vt__77sStateMgr_c<9dAcItem_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x80533FA8; // type:object size:0x30 +__vt__24sFStateFct_c<9dAcItem_c> = .data:0x80533FD8; // type:object size:0x18 +__vt__21sFState_c<9dAcItem_c> = .data:0x80533FF0; // type:object size:0x18 lbl_80534008 = .data:0x80534008; // type:object size:0x1C lbl_80534024 = .data:0x80534024; // type:object size:0x38 lbl_8053405C = .data:0x8053405C; // type:object size:0x14 @@ -45126,7 +45126,7 @@ lbl_8057BF68 = .sdata2:0x8057BF68; // type:object size:0x4 data:float lbl_8057BF6C = .sdata2:0x8057BF6C; // type:object size:0x4 data:float lbl_8057BF70 = .sdata2:0x8057BF70; // type:object size:0x4 data:float lbl_8057BF74 = .sdata2:0x8057BF74; // type:object size:0x4 data:float -lbl_8057BF78 = .sdata2:0x8057BF78; // type:object size:0x8 data:float +lbl_8057BF78 = .sdata2:0x8057BF78; // type:object size:0x4 data:float lbl_8057BF80 = .sdata2:0x8057BF80; // type:object size:0x4 data:float lbl_8057BF84 = .sdata2:0x8057BF84; // type:object size:0x4 data:float lbl_8057BF88 = .sdata2:0x8057BF88; // type:object size:0x4 data:float diff --git a/configure.py b/configure.py index bb2bc29b..dfda1e14 100644 --- a/configure.py +++ b/configure.py @@ -336,8 +336,8 @@ config.libs = [ Object(NonMatching, "toBeSorted/sound_info.cpp"), Object(Matching, "toBeSorted/arc_callback_handler.cpp"), Object(NonMatching, "d/a/d_a_base.cpp"), + Object(NonMatching, "d/a/d_a_item.cpp"), Object(NonMatching, "d/a/obj/d_a_obj_base.cpp"), - Object(NonMatching, "d/a/obj/d_a_obj_item.cpp"), Object(NonMatching, "d/a/obj/d_a_obj_bomb.cpp"), Object(NonMatching, "d/a/obj/d_a_obj_arrow.cpp"), Object(NonMatching, "d/a/obj/d_a_obj_boomerang.cpp"), diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index f78c0937..da64e4e8 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -6,7 +6,6 @@ #include "m/m_allocator.h" #include "m/m_angle.h" #include "m/m_vec.h" -#include "stddef.h" #include "toBeSorted/tlist.h" class dAcBase_c; diff --git a/include/d/a/d_a_item.h b/include/d/a/d_a_item.h new file mode 100644 index 00000000..fd2fa95c --- /dev/null +++ b/include/d/a/d_a_item.h @@ -0,0 +1,176 @@ +#ifndef D_A_ITEM_H +#define D_A_ITEM_H + +#include "common.h" +#include "d/a/d_a_base.h" +#include "d/a/d_a_itembase.h" +#include "d/a/obj/d_a_obj_scattersand.h" +#include "d/col/bg/d_bg_s_acch.h" +#include "d/col/c/c_cc_d.h" +#include "d/col/cc/d_cc_d.h" +#include "d/d_shadow.h" +#include "f/f_list_mg.h" +#include "f/f_list_nd.h" +#include "m/m_angle.h" +#include "m/m_vec.h" +#include "nw4r/ut/ut_Color.h" +#include "s/s_State.hpp" +#include "toBeSorted/actor_event.h" +#include "toBeSorted/dowsing_target.h" +#include "toBeSorted/effects_struct.h" + +class dAcItem_0xB34 { +public: + virtual ~dAcItem_0xB34(); +}; + +class dAcItem_c : public dAcItemBase_c { +public: + dAcItem_c(); + virtual ~dAcItem_c(); + + STATE_FUNC_DECLARE(dAcItem_c, Wait); + STATE_FUNC_DECLARE(dAcItem_c, Carry); + STATE_FUNC_DECLARE(dAcItem_c, GetBeetle); + STATE_FUNC_DECLARE(dAcItem_c, WaitGet); + STATE_FUNC_DECLARE(dAcItem_c, Get); + STATE_FUNC_DECLARE(dAcItem_c, WaitGetDemo); + STATE_FUNC_DECLARE(dAcItem_c, WaitForcedGetDemo); + STATE_FUNC_DECLARE(dAcItem_c, GetDemo); + STATE_FUNC_DECLARE(dAcItem_c, WaitTBoxGetDemo); + STATE_FUNC_DECLARE(dAcItem_c, ResurgeWait); + STATE_FUNC_DECLARE(dAcItem_c, WaitTurnOff); + STATE_FUNC_DECLARE(dAcItem_c, WaitSacredDewGetEffect); + + static u32 createItemParams(u16 itemId, u32 subType, u32 unk, u8 unk2, u8, u8); + + static void spawnItem(u16 item, u32 room, const mVec3_c &pos, const mAng3_c &rot, u32 params, u32 arg); + static void spawnDrop(u16 item, u32 room, const mVec3_c &pos, const mAng3_c &rot); + static u32 checkFlag(u32 flag); + void setItemPosition(const mVec3_c &); + void getItemFromBWheelItem(); + bool isStateWait(); + +private: + /* 0x334 */ UNKTYPE *mpMdl; // Model has its own handling system + /* 0x338 */ dShadowCircle_c mShdw; + /* 0x340 */ mVec3_c mField_0x340; + /* 0x34C */ nw4r::ut::Color mColorFilter; + /* 0x350 */ f32 mLightLevelMaybe; + /* 0x354 */ u8 _354[0x35C - 0x354]; + /* 0x35C */ dBgS_AcchCir mAcchCir; + /* 0x3B8 */ dBgS_ObjAcch mObjAcch; + /* 0x768 */ dCcD_Cyl mCyl; + /* 0x8B8 */ STATE_MGR_DECLARE(dAcItem_c); + /* 0x8F4 */ EffectsStruct mEff_0x8F4; + /* 0x928 */ EffectsStruct mEff_0x928; + /* 0x95C */ EffectsStruct mEff_0x95C; + /* 0x990 */ EffectsStruct mEff_0x990; + /* 0x9C4 */ EffectsStruct mEff_0x9C4; + /* 0x9F8 */ EffectsStruct mEff_0x9F8; + /* 0xA2C */ EffectsStruct mEff_0xA2C; + /* 0xA60 */ EffectsStruct mEff_0xA60; + /* 0xA94 */ dAcRef_c mCoveredSand; + /* 0xAA0 */ dAcRef_c mUnkRef; + /* 0xAAC */ mVec3_c posCopy; + /* 0xAB8 */ fLiNdBa_c mNode; + /* 0xAC4 */ ActorEventRelated mEventRelated; + /* 0xB14 */ DowsingTarget mDowsingTarget; + /* 0xB34 */ dAcItem_0xB34 *mField_0xB34[2]; + /* 0xB34 */ dAcItem_0xB34 *mField_0xB3C; + /* 0xB40 */ UNKTYPE (dAcItem_c::*mFunc_0xB40)(UNKTYPE); + /* 0xB4C */ UNKTYPE (dAcItem_c::*mFunc_0xB4C)(UNKTYPE); + /* 0xB58 */ UNKTYPE (dAcItem_c::*mFunc_0xB58)(UNKTYPE); + /* 0xB64 */ UNKTYPE (dAcItem_c::*mFunc_0xB64)(UNKTYPE); + /* 0xB70 */ UNKTYPE (dAcItem_c::*mFunc_0xB70)(UNKTYPE); + /* 0xB7C */ UNKTYPE (dAcItem_c::*mFunc_0xB7C)(UNKTYPE); + /* 0xB88 */ UNKTYPE (dAcItem_c::*mFunc_0xB88)(UNKTYPE); + /* 0xB94 */ UNKTYPE (dAcItem_c::*mFunc_0xB94)(UNKTYPE); + /* 0xBA0 */ UNKTYPE (dAcItem_c::*mFunc_0xBA0)(UNKTYPE); + /* 0xBAC */ UNKTYPE (dAcItem_c::*mFunc_0xBAC)(UNKTYPE); + /* 0xBB8 */ UNKTYPE (dAcItem_c::*mFunc_0xBB8)(UNKTYPE); + /* 0xBC4 */ UNKTYPE (dAcItem_c::*mFunc_0xBC4)(UNKTYPE); + /* 0xBD0 */ UNKTYPE (dAcItem_c::*mFunc_0xBD0)(UNKTYPE); + /* 0xBDC */ UNKTYPE (dAcItem_c::*mFunc_0xBDC)(UNKTYPE); + /* 0xBE8 */ UNKTYPE (dAcItem_c::*mFunc_0xBE8)(UNKTYPE); + /* 0xBF4 */ UNKTYPE (dAcItem_c::*mFunc_0xBF4)(UNKTYPE); + /* 0xC00 */ UNKTYPE (dAcItem_c::*mFunc_0xC00)(UNKTYPE); + /* 0xC0C */ UNKTYPE (dAcItem_c::*mFunc_0xC0C)(UNKTYPE); + /* 0xC18 */ UNKTYPE (dAcItem_c::*mFunc_0xC18)(UNKTYPE); + /* 0xC24 */ UNKTYPE (dAcItem_c::*mFunc_0xC24)(UNKTYPE); + /* 0xC30 */ UNKTYPE (dAcItem_c::*mFunc_0xC30)(UNKTYPE); + /* 0xC3C */ UNKTYPE (dAcItem_c::*mFunc_0xC3C)(UNKTYPE); + /* 0xC48 */ UNKTYPE (dAcItem_c::*mFunc_0xC48)(UNKTYPE); + /* 0xC54 */ UNKTYPE (dAcItem_c::*mFunc_0xC54)(UNKTYPE); + /* 0xC60 */ UNKTYPE (dAcItem_c::*mFunc_0xC60)(UNKTYPE); + /* 0xC6C */ UNKTYPE (dAcItem_c::*mFunc_0xC6C)(UNKTYPE); + /* 0xC78 */ UNKTYPE (dAcItem_c::*mFunc_0xC78)(UNKTYPE); + /* 0xC84 */ UNKTYPE (dAcItem_c::*mFunc_0xC84)(UNKTYPE); + /* 0xC90 */ UNKTYPE (dAcItem_c::*mFunc_0xC90)(UNKTYPE); + /* 0xC9C */ UNKTYPE (dAcItem_c::*mFunc_0xC9C)(UNKTYPE); + /* 0xCA8 */ UNKTYPE (dAcItem_c::*mFunc_0xCA8)(UNKTYPE); + /* 0xCB4 */ UNKTYPE (dAcItem_c::*mFunc_0xCB4)(UNKTYPE); + /* 0xCC0 */ dAcRef_c mItemQueuePrev; + /* 0xCCC */ dAcRef_c mItemQueueNext; + /* 0xCD8 */ f32 mField_0xCD8; + /* 0xCDC */ f32 mBaseScale; + /* 0xCE0 */ f32 mCurrentScale; + /* 0xCE4 */ f32 mField_0xCE4; + /* 0xCE8 */ f32 mField_0xCE8; + /* 0xCEC */ f32 mField_0xCEC; + /* 0xCF0 */ u8 _CF0[0xD00 - 0xCF0]; + /* 0xD00 */ f32 mField_0xD00; + /* 0xD04 */ f32 mField_0xD04; + /* 0xD08 */ u8 _D08[0xD14 - 0xD08]; + /* 0xD14 */ f32 mFreestandingOffsetH; + /* 0xD18 */ f32 mField_0xD18; + /* 0xD1C */ int mGetItemPouchSlot; + /* 0xD20 */ int mField_0xD20; + /* 0xD24 */ u8 _D24[0xD2C - 0xD24]; + /* 0xD2C */ u32 mFramesInAir; + /* 0xD30 */ int mItemQuantity; + /* 0xD34 */ u32 mItemFlags; + /* 0xD38 */ mAng3_c mField_0xD38; + /* 0xD3E */ u16 mField_0xD3E; + /* 0xD40 */ mAng mMdlRotY; + /* 0xD42 */ s16 mField_0xD42; + /* 0xD44 */ u16 mRealItemId; + /* 0xD46 */ s16 mDespawnTimer; + /* 0xD48 */ u8 mField_0xD48; + /* 0xD49 */ u8 mField_0xD49; + /* 0xD4A */ u8 mField_0xD4A; + /* 0xD4B */ u8 mField_0xD4B; + /* 0xD4C */ u8 mField_0xD4C; + /* 0xD4D */ u8 mField_0xD4D; + /* 0xD4E */ u8 mMdlScaleType; + /* 0xD4F */ u8 mbNoDespawn; + /* 0xD50 */ u8 mbNoGravity; + /* 0xD51 */ u8 mField_0xD51; + /* 0xD52 */ u8 mField_0xD52; + /* 0xD53 */ u8 mField_0xD53; + /* 0xD54 */ u8 mbIsWaiting; + /* 0xD55 */ u8 mField_0xD55; + /* 0xD56 */ u8 mField_0xD56; + /* 0xD57 */ u8 mField_0xD57; + /* 0xD58 */ u8 mField_0xD58; + /* 0xD59 */ u8 mField_0xD59; + /* 0xD5A */ u8 mField_0xD5A; + /* 0xD5B */ u8 mField_0xD5B; + /* 0xD5C */ u8 mField_0xD5C; + /* 0xD5D */ bool mbShowItemLighting; + /* 0xD5E */ u8 mField_0xD5E; + /* 0xD5F */ u8 mField_0xD5F; + /* 0xD60 */ u8 mField_0xD60; + /* 0xD61 */ u8 mField_0xD61; + /* 0xD62 */ u8 mField_0xD62; + /* 0xD63 */ u8 mField_0xD63; + /* 0xD64 */ u8 mField_0xD64; + /* 0xD65 */ u8 mField_0xD65; + /* 0xD66 */ u8 mField_0xD66; + /* 0xD67 */ u8 mField_0xD67; + +public: + static fLiMgBa_c sItemList; +}; + +#endif diff --git a/include/d/a/d_a_itembase.h b/include/d/a/d_a_itembase.h new file mode 100644 index 00000000..79bee679 --- /dev/null +++ b/include/d/a/d_a_itembase.h @@ -0,0 +1,246 @@ +#ifndef D_A_ITEMBASE_H +#define D_A_ITEMBASE_H + +#include "d/a/obj/d_a_obj_base.h" + +enum ITEM_ID { + /* 0x000 */ ITEM_NONE = 0, + /* 0x001 */ ITEM_SMALL_KEY = 1, + /* 0x002 */ ITEM_GREEN_RUPEE = 2, + /* 0x003 */ ITEM_BLUE_RUPEE = 3, + /* 0x004 */ ITEM_RED_RUPEE = 4, + /* 0x005 */ ITEM_COMPLETE_TRIFORCE = 5, + /* 0x006 */ ITEM_HEART = 6, + /* 0x007 */ ITEM_SINGLE_ARROW = 7, + /* 0x008 */ ITEM_BUNDLE_ARROWS = 8, + /* 0x009 */ ITEM_GODDESS_WHITESWORD = 9, + /* 0x00A */ ITEM_PRACTICE_SWORD = 10, + /* 0x00B */ ITEM_GODDESS_SWORD = 11, + /* 0x00C */ ITEM_GODDESS_LONGSWORD = 12, + /* 0x00D */ ITEM_MASTER_SWORD = 13, + /* 0x00E */ ITEM_TRUE_MASTER_SWORD = 14, + /* 0x00F */ ITEM_SAILCLOTH = 15, + /* 0x010 */ ITEM_GODDESS_HARP = 16, + /* 0x011 */ ITEM_SPIRIT_VESSEL = 17, + /* 0x012 */ ITEM_UNK_18 = 18, + /* 0x013 */ ITEM_BOW = 19, + /* 0x014 */ ITEM_CLAWSHOTS = 20, + /* 0x015 */ ITEM_BIRD_STATUETTE = 21, + /* 0x016 */ ITEM_COMMON_BUG = 22, + /* 0x017 */ ITEM_UNCOMMON_BUG = 23, + /* 0x018 */ ITEM_RARE_BUG = 24, + /* 0x019 */ ITEM_AC_BK = 25, + /* 0x01A */ ITEM_FS_BK = 26, + /* 0x01B */ ITEM_SSH_BK = 27, + /* 0x01C */ ITEM_KEY_PIECE = 28, + /* 0x01D */ ITEM_SV_BK = 29, + /* 0x01E */ ITEM_ET_BK = 30, + /* 0x01F */ ITEM_LMF_BK = 31, + /* 0x020 */ ITEM_SILVER_RUPEE = 32, + /* 0x021 */ ITEM_GOLD_RUPEE = 33, + /* 0x022 */ ITEM_RUPOOR = 34, + /* 0x023 */ ITEM_5_CRYSTALS = 35, + /* 0x024 */ ITEM_GLITTERING_SPORES = 36, + /* 0x025 */ ITEM_UNK_37 = 37, + /* 0x026 */ ITEM_UNK_38 = 38, + /* 0x027 */ ITEM_UNK_39 = 39, + /* 0x028 */ ITEM_5_BOMBS = 40, + /* 0x029 */ ITEM_10_BOMBS = 41, + /* 0x02A */ ITEM_STAMINA_FRUIT = 42, + /* 0x02B */ ITEM_FARORE_TEAR = 43, + /* 0x02C */ ITEM_DIN_TEAR = 44, + /* 0x02D */ ITEM_NAYRU_TEAR = 45, + /* 0x02E */ ITEM_SACRED_TEAR = 46, + /* 0x02F */ ITEM_LIGHT_FRUIT = 47, + /* 0x030 */ ITEM_1_CRYSTAL = 48, + /* 0x031 */ ITEM_GUST_BELLOWS = 49, + /* 0x032 */ ITEM_DUNGEON_MAP_FI = 50, + /* 0x033 */ ITEM_DUNGEON_MAP = 51, + /* 0x034 */ ITEM_SLINGSHOT = 52, + /* 0x035 */ ITEM_BEETLE = 53, + /* 0x036 */ ITEM_WATER = 54, + /* 0x037 */ ITEM_MUSHROOM_SPORES = 55, + /* 0x038 */ ITEM_DIGGING_MITTS = 56, + /* 0x039 */ ITEM_5_DEKU_SEEDS = 57, + /* 0x03A */ ITEM_UNK_58 = 58, + /* 0x03B */ ITEM_UNK_59 = 59, + /* 0x03C */ ITEM_10_DEKU_SEEDS = 60, + /* 0x03D */ ITEM_COMMON_TREASURE = 61, + /* 0x03E */ ITEM_COMMON_TREASURE2 = 62, + /* 0x03F */ ITEM_UNCOMMON_TREASURE = 63, + /* 0x040 */ ITEM_RARE_TREASURE = 64, + /* 0x041 */ ITEM_GUARDIAN_POTION = 65, + /* 0x042 */ ITEM_GUARDIAN_POTION_PLUS = 66, + /* 0x043 */ ITEM_UNK_67 = 67, + /* 0x044 */ ITEM_WATER_SCALE = 68, + /* 0x045 */ ITEM_UNK_69 = 69, + /* 0x046 */ ITEM_BUG_MEDAL = 70, + /* 0x047 */ ITEM_BUG_NET = 71, + /* 0x048 */ ITEM_FAIRY = 72, + /* 0x049 */ ITEM_UNK_73 = 73, + /* 0x04A */ ITEM_SACRED_WATER = 74, + /* 0x04B */ ITEM_HOOK_BEETLE = 75, + /* 0x04C */ ITEM_QUICK_BEETLE = 76, + /* 0x04D */ ITEM_TOUGH_BEETLE = 77, + /* 0x04E */ ITEM_HEART_POTION = 78, + /* 0x04F */ ITEM_HEART_POTION_PLUS = 79, + /* 0x050 */ ITEM_HEART_POTION_ALSO = 80, + /* 0x051 */ ITEM_HEART_POTION_PLUS_PLUS = 81, + /* 0x052 */ ITEM_UNK_82 = 82, + /* 0x053 */ ITEM_GUARDIAN_POTION_NO_TBOX = 83, + /* 0x054 */ ITEM_STAMINA_POTION = 84, + /* 0x055 */ ITEM_STAMINA_POTION_PLUS = 85, + /* 0x056 */ ITEM_AIR_POTION = 86, + /* 0x057 */ ITEM_AIR_POTION_PLUS = 87, + /* 0x058 */ ITEM_BOTTLED_FAIRY = 88, + /* 0x059 */ ITEM_UNK_89 = 89, + /* 0x05A */ ITEM_IRON_BOW = 90, + /* 0x05B */ ITEM_SACRED_BOW = 91, + /* 0x05C */ ITEM_BOMB_BAG = 92, + /* 0x05D */ ITEM_HEART_CONTAINER = 93, + /* 0x05E */ ITEM_HEART_PIECE = 94, + /* 0x05F */ ITEM_TRI_COURAGE = 95, + /* 0x060 */ ITEM_TRI_POWER = 96, + /* 0x061 */ ITEM_TRI_WISDOM = 97, + /* 0x062 */ ITEM_SEA_CHART = 98, + /* 0x063 */ ITEM_MOGMA_MITTS = 99, + /* 0x064 */ ITEM_HEART_MEDAL = 100, + /* 0x065 */ ITEM_RUPEE_MEDAL = 101, + /* 0x066 */ ITEM_TREASURE_MEDAL = 102, + /* 0x067 */ ITEM_POTION_MEDAL = 103, + /* 0x068 */ ITEM_CURSED_MEDAL = 104, + /* 0x069 */ ITEM_SCATTERSHOT = 105, + /* 0x06A */ ITEM_UNK_106 = 106, + /* 0x06B */ ITEM_UNK_107 = 107, + /* 0x06C */ ITEM_MEDIUM_WALLET = 108, + /* 0x06D */ ITEM_BIG_WALLET = 109, + /* 0x06E */ ITEM_GIANT_WALLET = 110, + /* 0x06F */ ITEM_TYCOON_WALLET = 111, + /* 0x070 */ ITEM_ADVENTURE_POUCH = 112, + /* 0x071 */ ITEM_POUCH_EXPANSION = 113, + /* 0x072 */ ITEM_LIFE_MEDAL = 114, + /* 0x073 */ ITEM_UNK_115 = 115, + /* 0x074 */ ITEM_WOODEN_SHIELD = 116, + /* 0x075 */ ITEM_BANDED_SHIELD = 117, + /* 0x076 */ ITEM_BRACED_SHIELD = 118, + /* 0x077 */ ITEM_IRON_SHIELD = 119, + /* 0x078 */ ITEM_REINFORCED_SHIELD = 120, + /* 0x079 */ ITEM_FORTIFIED_SHIELD = 121, + /* 0x07A */ ITEM_SACRED_SHIELD = 122, + /* 0x07B */ ITEM_DIVINE_SHIELD = 123, + /* 0x07C */ ITEM_GODDESS_SHIELD = 124, + /* 0x07D */ ITEM_HYLIAN_SHIELD = 125, + /* 0x07E */ ITEM_REVITALIZING_POTION = 126, + /* 0x07F */ ITEM_REVITALIZING_POTION_PLUS = 127, + /* 0x080 */ ITEM_SMALL_SEED_SATCHEL = 128, + /* 0x081 */ ITEM_MEDIUM_SEED_SATCHEL = 129, + /* 0x082 */ ITEM_LARGE_SEED_SATCHEL = 130, + /* 0x083 */ ITEM_SMALL_QUIVER = 131, + /* 0x084 */ ITEM_MEDIUM_QUIVER = 132, + /* 0x085 */ ITEM_LARGE_QUIVER = 133, + /* 0x086 */ ITEM_SMALL_BOMB_BAG = 134, + /* 0x087 */ ITEM_MEDIUM_BOMB_BAG = 135, + /* 0x088 */ ITEM_LARGE_BOMB_BAG = 136, + /* 0x089 */ ITEM_WHIP = 137, + /* 0x08A */ ITEM_FIRESHIELD_EARRINGS = 138, + /* 0x08B */ ITEM_UNK_139 = 139, + /* 0x08C */ ITEM_BIG_BUG_NET = 140, + /* 0x08D */ ITEM_FARON_GRASSHOPPER = 141, + /* 0x08E */ ITEM_WOODLAND_RHINO_BEETLE = 142, + /* 0x08F */ ITEM_DEKU_HORNET_ = 143, + /* 0x090 */ ITEM_SKYLOFT_MANTIS = 144, + /* 0x091 */ ITEM_VOLCANIC_LADYBUG = 145, + /* 0x092 */ ITEM_BLESSED_BUTTERFLY = 146, + /* 0x093 */ ITEM_LANAYRU_ANT = 147, + /* 0x094 */ ITEM_SAND_CICADA = 148, + /* 0x095 */ ITEM_GERUDO_DRAGONFLY = 149, + /* 0x096 */ ITEM_ELDIN_ROLLER = 150, + /* 0x097 */ ITEM_SKY_STAG_BEETLE = 151, + /* 0x098 */ ITEM_STARRY_FIREFLY = 152, + /* 0x099 */ ITEM_BOTTLE = 153, + /* 0x09A */ ITEM_RUPEE_MEDAL_ALSO = 154, + /* 0x09B */ ITEM_HEART_MEDAL_ALSO = 155, + /* 0x09C */ ITEM_UNK_156 = 156, + /* 0x09D */ ITEM_UNK_157 = 157, + /* 0x09E */ ITEM_CAWLIN_LETTER = 158, + /* 0x09F */ ITEM_BEEDLE_INSECT_CAGE = 159, + /* 0x0A0 */ ITEM_RATTLE = 160, + /* 0x0A1 */ ITEM_HORNET_LARVAE = 161, + /* 0x0A2 */ ITEM_BIRD_FEATHER = 162, + /* 0x0A3 */ ITEM_TUMBLE_WEED = 163, + /* 0x0A4 */ ITEM_LIZARD_TAIL = 164, + /* 0x0A5 */ ITEM_ELDIN_ORE = 165, + /* 0x0A6 */ ITEM_ANCIENT_FLOWER = 166, + /* 0x0A7 */ ITEM_AMBER_RELIC = 167, + /* 0x0A8 */ ITEM_DUSK_RELIC = 168, + /* 0x0A9 */ ITEM_JELLY_BLOB = 169, + /* 0x0AA */ ITEM_MONSTER_CLAW = 170, + /* 0x0AB */ ITEM_MONSTER_HORN = 171, + /* 0x0AC */ ITEM_ORNAMENTAL_SKULL = 172, + /* 0x0AD */ ITEM_EVIL_CRYSTAL = 173, + /* 0x0AE */ ITEM_BLUE_BIRD_FEATHER = 174, + /* 0x0AF */ ITEM_GOLDEN_SKULL = 175, + /* 0x0B0 */ ITEM_GODDESS_PLUME = 176, + /* 0x0B1 */ ITEM_EMERALD_TABLET = 177, + /* 0x0B2 */ ITEM_RUBY_TABLET = 178, + /* 0x0B3 */ ITEM_AMBER_TABLET = 179, + /* 0x0B4 */ ITEM_STONE_OF_TRIALS = 180, + /* 0x0B5 */ ITEM_UNK_181 = 181, + /* 0x0B6 */ ITEM_UNK_182 = 182, + /* 0x0B7 */ ITEM_UNK_183 = 183, + /* 0x0B8 */ ITEM_UNK_184 = 184, + /* 0x0B9 */ ITEM_UNK_185 = 185, + /* 0x0BA */ ITEM_BALLAD_OF_THE_GODDESS = 186, + /* 0x0BB */ ITEM_FARORES_COURAGE = 187, + /* 0x0BC */ ITEM_NAYRUS_WISDOM = 188, + /* 0x0BD */ ITEM_DINS_POWER = 189, + /* 0x0BE */ ITEM_FARON_SOTH = 190, + /* 0x0BF */ ITEM_ELDIN_SOTH = 191, + /* 0x0C0 */ ITEM_LANAYRU_SOTH = 192, + /* 0x0C1 */ ITEM_SOTH = 193, + /* 0x0C2 */ ITEM_REVITALIZING_POTION_PLUS_PLUS = 194, + /* 0x0C3 */ ITEM_HOT_SOUP = 195, + /* 0x0C4 */ ITEM_COLD_SOUP = 196, + /* 0x0C5 */ ITEM_LIFE_TREE_SEED = 197, + /* 0x0C6 */ ITEM_LIFE_TREE_FRUIT = 198, + /* 0x0C7 */ ITEM_EXTRA_WALLET = 199, + /* 0x0C8 */ ITEM_UNK_200 = 200, + /* 0x18D */ ITEM_LIFE_MEDAL_AGAIN = 397, // ?? Prob doesnt exist + /* 0x18E */ ITEM_POUCH_EXPANSION_GODDESS_CHEST = 398, // ?? Prob doesnt exist + /* 0x1FF */ MAX_ITEM_ID = 511 +}; + +struct ItemFlagStruct { + u8 mField_0x00; + u8 mField_0x01; + u8 mField_0x02; + u8 mField_0x03; + u16 mFlag; + u8 mFlagKind; + u8 mField_0x07; +}; +class dAcItemBase_c : public dAcObjBase_c { +public: + dAcItemBase_c() {} + virtual ~dAcItemBase_c() {} + virtual u16 getItemId(); + + static bool isValidItemTypeIdx(int itemId); + static bool getItemTypeFromId(u16 itemID, u32 *pOutType); + static bool getItemAnimType(u16 itemId, u32 *pOutType); + static int getHeartContainerHeartIncrease(); + static int getCompletedHeartPieceHeartIncrease(); + static u8 getTearIdx(int tearNum); + static bool getFlagIdxForTear(int tearNum, u32 *pOutFlag); + static u16 getTearBit(int tearNum); + static bool setDungeonFlagForTear(int tearNum); + +private: + u16 mId; + + static const ItemFlagStruct sDefaultFlagStruct; + static const ItemFlagStruct sItemFlagStructs[167]; + static const u32 sItemTypeFlags[MAX_ITEM_ID - 1]; +}; + +#endif diff --git a/include/d/a/obj/d_a_obj_item.h b/include/d/a/obj/d_a_obj_item.h deleted file mode 100644 index 7c9efbc4..00000000 --- a/include/d/a/obj/d_a_obj_item.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef D_A_ITEM_BASE_H -#define D_A_ITEM_BASE_H - -#include "d/a/obj/d_a_obj_base.h" -#include "m/m_vec.h" - -// Ghidra: AcItem -// Size: 0xd68 -// official name -class dAcItem_c : public dAcObjBase_c { -public: - static u32 createItemParams(u16 itemId, u32 subType, u32 unk, u8 unk2, u8, u8); - - static void spawnItem(u16 item, u32 room, const mVec3_c &pos, const mAng3_c &rot, u32 params, u32 arg); - static void spawnDrop(u16 item, u32 room, const mVec3_c &pos, const mAng3_c &rot); - - static u32 checkFlag(u32 flag); - void setItemPosition(const mVec3_c &); - void getItemFromBWheelItem(); - bool isStateWait(); - - static fLiMgBa_c sItemList; -}; - -#endif diff --git a/include/d/a/obj/d_a_obj_tower_hand_D101.h b/include/d/a/obj/d_a_obj_tower_hand_D101.h index 9e9bb068..3dcca5fc 100644 --- a/include/d/a/obj/d_a_obj_tower_hand_D101.h +++ b/include/d/a/obj/d_a_obj_tower_hand_D101.h @@ -3,8 +3,8 @@ #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/a/obj/d_a_obj_item.h" #include "d/col/bg/d_bg_w.h" #include "m/m3d/m_anmmdl.h" #include "m/m_angle.h" @@ -15,6 +15,7 @@ #include "toBeSorted/actor_event.h" #include "toBeSorted/effects_struct.h" + class dAcOTowerHandD101_c : public dAcObjBase_c { public: dAcOTowerHandD101_c() : mStateMgr(*this, sStateID::null), mEffects(this), mEvent(*this, nullptr), mFlags(0) {} diff --git a/include/d/d_shadow.h b/include/d/d_shadow.h index e30b8f2c..902f2e6a 100644 --- a/include/d/d_shadow.h +++ b/include/d/d_shadow.h @@ -1,3 +1,6 @@ +#ifndef D_SHADOW_H +#define D_SHADOW_H + #include "m/m3d/m_shadow.h" // This is unofficial, idk if this is close, but this is a common shadow extension. @@ -7,3 +10,5 @@ public: dShadowCircle_c() {} virtual ~dShadowCircle_c() {} }; + +#endif diff --git a/include/toBeSorted/file_manager.h b/include/toBeSorted/file_manager.h index b4f44e6f..1bfdb845 100644 --- a/include/toBeSorted/file_manager.h +++ b/include/toBeSorted/file_manager.h @@ -2,14 +2,12 @@ #define FILE_MANAGER_H #include "common.h" +#include "d/a/d_a_itembase.h" #include "egg/core/eggHeap.h" #include "m/m_angle.h" #include "m/m_vec.h" #include "toBeSorted/save_file.h" - -enum ITEM_ID { -}; enum SAVE_ITEM_ID { }; diff --git a/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp b/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp index 67e875e3..4de37268 100644 --- a/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp +++ b/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp @@ -1,7 +1,7 @@ #include "d/a/obj/d_a_obj_toD3_stone_figure.h" +#include "d/a/d_a_item.h" #include "d/col/cc/d_cc_s.h" -#include "d/a/obj/d_a_obj_item.h" #include "d/flag/storyflag_manager.h" #include "toBeSorted/attention.h" #include "toBeSorted/event.h" @@ -165,5 +165,5 @@ void dAcOtoD3StoneFigure_c::doInteraction(s32 arg) { } bool dAcOtoD3StoneFigure_c::hasStoneOfTrials() const { - return dAcItem_c::checkFlag(0xB4); + return dAcItem_c::checkFlag(ITEM_STONE_OF_TRIALS); } diff --git a/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp b/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp index 29b56942..cb827499 100644 --- a/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp +++ b/src/REL/d/a/obj/d_a_obj_tower_hand_D101.cpp @@ -1,8 +1,8 @@ #include "d/a/obj/d_a_obj_tower_hand_D101.h" #include "common.h" +#include "d/a/d_a_item.h" #include "d/a/d_a_player.h" -#include "d/a/obj/d_a_obj_item.h" #include "d/col/bg/d_bg_s.h" #include "d/col/bg/d_bg_w.h" #include "d/flag/sceneflag_manager.h" diff --git a/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp b/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp index a72d947c..9e88c7ad 100644 --- a/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp +++ b/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp @@ -2,23 +2,20 @@ #include "c/c_math.h" #include "common.h" +#include "d/a/d_a_itembase.h" #include "d/a/d_a_player.h" #include "d/a/obj/d_a_obj_base.h" #include "d/col/bg/d_bg_s.h" -#include "d/col/bg/d_bg_s_gnd_chk.h" #include "d/col/c/c_cc_d.h" #include "d/col/c/c_m3d_g_pla.h" #include "d/col/cc/d_cc_d.h" #include "d/col/cc/d_cc_s.h" #include "egg/math/eggMath.h" #include "egg/math/eggQuat.h" -#include "f/f_base.h" #include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_quat.h" #include "m/m_vec.h" -#include "nw4r/math/math_triangular.h" -#include "rvl/MTX/mtx.h" #include "rvl/MTX/vec.h" #include "s/s_Math.h" #include "toBeSorted/dowsing_target.h" @@ -118,7 +115,7 @@ int dAcOTumbleWeed_c::actorExecute() { mObjAcch.CrrPos(*dBgS::GetInstance()); mField_0x974 += position.y - mOldPosition.y; if (checkCollect()) { - dAcPy_c::LINK->bugNetCollectTreasure(0xA3 /* TODO(Item Id) ITEM_TUMBLEWEED */); + dAcPy_c::LINK->bugNetCollectTreasure(ITEM_TUMBLE_WEED); FUN_8002dcd0(); return SUCCEEDED; } diff --git a/src/REL/d/t/d_t_dowsing.cpp b/src/REL/d/t/d_t_dowsing.cpp index 642d1de9..fa099174 100644 --- a/src/REL/d/t/d_t_dowsing.cpp +++ b/src/REL/d/t/d_t_dowsing.cpp @@ -1,9 +1,9 @@ #include "d/t/d_t_dowsing.h" +#include "d/a/d_a_item.h" #include "d/flag/itemflag_manager.h" -#include "d/flag/storyflag_manager.h" #include "d/flag/sceneflag_manager.h" - +#include "d/flag/storyflag_manager.h" SPECIAL_ACTOR_PROFILE(T_DOWSING, dTgDowsing_c, fProfile::T_DOWSING, 0x0293, 0, 0); @@ -56,13 +56,17 @@ bool dTgDowsing_c::checkDowsing() const { switch (mDowsingOption) { case TRIAL_0: - return ItemflagManager::sInstance->getFlagDirect(187) && !StoryflagManager::sInstance->getCounterOrFlag(93); + return ItemflagManager::sInstance->getFlagDirect(ITEM_FARORES_COURAGE) && + !StoryflagManager::sInstance->getCounterOrFlag(93); // TOOD (Counter ID) case TRIAL_1: - return ItemflagManager::sInstance->getFlagDirect(188) && !StoryflagManager::sInstance->getCounterOrFlag(97); + return ItemflagManager::sInstance->getFlagDirect(ITEM_NAYRUS_WISDOM) && + !StoryflagManager::sInstance->getCounterOrFlag(97); // TOOD (Counter ID) case TRIAL_2: - return ItemflagManager::sInstance->getFlagDirect(189) && !StoryflagManager::sInstance->getCounterOrFlag(98); + return ItemflagManager::sInstance->getFlagDirect(ITEM_DINS_POWER) && + !StoryflagManager::sInstance->getCounterOrFlag(98); // TOOD (Counter ID) case TRIAL_3: - return ItemflagManager::sInstance->getFlagDirect(193) && !StoryflagManager::sInstance->getCounterOrFlag(99); + return ItemflagManager::sInstance->getFlagDirect(ITEM_SOTH) && + !StoryflagManager::sInstance->getCounterOrFlag(99); // TOOD (Counter ID) case PROPELLER: return DowsingTarget::hasPropellerDowsing(); case WATER_BASIN: return DowsingTarget::hasWaterBasinDowsing(); case CRYSTAL_BALL: return DowsingTarget::hasCrystalBallDowsing(); diff --git a/src/REL/d/t/d_t_reaction.cpp b/src/REL/d/t/d_t_reaction.cpp index 5e0db3ac..8ed37eec 100644 --- a/src/REL/d/t/d_t_reaction.cpp +++ b/src/REL/d/t/d_t_reaction.cpp @@ -2,11 +2,13 @@ #include "c/c_lib.h" #include "c/c_math.h" +#include "d/a/d_a_item.h" #include "d/a/d_a_player.h" -#include "d/a/obj/d_a_obj_item.h" +#include "d/col/c/c_cc_d.h" #include "d/col/cc/d_cc_s.h" #include "d/flag/sceneflag_manager.h" + SPECIAL_ACTOR_PROFILE(TAG_REACTION, dTgReaction_c, fProfile::TAG_REACTION, 0x0151, 0, 0); STATE_DEFINE(dTgReaction_c, Wait); @@ -64,7 +66,7 @@ int dTgReaction_c::create() { } if (field_0x4DE) { - u32 heartMedalCount = adventurePouchCountItem(/* HEART_MEDAL*/ 100); + u32 heartMedalCount = adventurePouchCountItem(ITEM_HEART_MEDAL); if (heartMedalCount == 0) { return FAILED; } else if (heartMedalCount == 1 && cM::rnd() < 0.5f) { @@ -176,11 +178,11 @@ void dTgReaction_c::checkForBonkItem() { c.rotY(rotation.y); c2 += c; c2.y += field_0x4E4; - u32 newItemParms = dAcItem_c::createItemParams(/* HEART_PIECE */ 0x5E, 1, 0, getSceneFlag(), 1, 0xFF); + u32 newItemParms = dAcItem_c::createItemParams(ITEM_HEART_PIECE, 1, 0, getSceneFlag(), 1, 0xFF); if (dAcObjBase_c::create(fProfile::ITEM, roomid, newItemParms, &c2, nullptr, nullptr, 0xFFFFFFFF)) { field_0x4DD = 1; onDelete(); - SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x13AD); + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x13AD); // TODO (Sound ID) } } } else { @@ -202,7 +204,7 @@ void dTgReaction_c::checkForBonkItem() { pos.y += field_0x4E4; if (fn_578_DB0(pos, uVar3)) { - SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x13AE); + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x13AE); // TODO (Sound ID) } SceneflagManager::sInstance->setFlag(roomid, getSceneFlag()); onDelete(); @@ -211,7 +213,7 @@ void dTgReaction_c::checkForBonkItem() { } void dTgReaction_c::checkForBubble() { - if (mCollision.ChkTgHit() && mCollision.ChkTgAtHitType(0x100000)) { + if (mCollision.ChkTgHit() && mCollision.ChkTgAtHitType(AT_TYPE_0x100000)) { if (dAcPy_c::LINK != nullptr && dAcPy_c::LINK->checkFlags0x350(0x40)) { mVec3_c spawnPos = position; dAcObjBase_c::create(fProfile::OBJ_BUBBLE, roomid, 0x4, &spawnPos, nullptr, nullptr, 0xFFFFFFFF); @@ -236,7 +238,7 @@ void dTgReaction_c::checkForSlingBellowsItem() { mVec3_c spawnPos = position; spawnPos.y += field_0x4E4; if (fn_578_DB0(spawnPos, uVar3)) { - SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x13AE); + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x13AE); // TODO (Sound ID) } SceneflagManager::sInstance->setFlag(roomid, getSceneFlag()); onDelete(); @@ -282,11 +284,11 @@ bool dTgReaction_c::spawnHearts(s32 params, const mVec3_c &pos, s32 arg, mAng an mAng offset = cM::rndRange(-tmp2, tmp2); ang.y = mAng(step) + offset; if (arg == 5) { - dAcItem_c::spawnItem(/* HEART */ 0x6, roomid, pos, ang, 0xFFFFFFFF, 1); + dAcItem_c::spawnItem(ITEM_HEART, roomid, pos, ang, 0xFFFFFFFF, 1); } else if (arg == 6) { - dAcItem_c::spawnItem(/* HEART */ 0x6, roomid, pos, ang, 0xFFFFFFFF, 0); + dAcItem_c::spawnItem(ITEM_HEART, roomid, pos, ang, 0xFFFFFFFF, 0); } else { - dAcItem_c::spawnDrop(/* HEART */ 0x6, roomid, pos, ang); + dAcItem_c::spawnDrop(ITEM_HEART, roomid, pos, ang); } step = mAng(step) - stepSize; } diff --git a/src/REL/d/t/d_t_tumble_weed.cpp b/src/REL/d/t/d_t_tumble_weed.cpp index 9c5cc926..f11c2e1c 100644 --- a/src/REL/d/t/d_t_tumble_weed.cpp +++ b/src/REL/d/t/d_t_tumble_weed.cpp @@ -3,7 +3,6 @@ #include "m/m_vec.h" #include "s/s_Math.h" - SPECIAL_ACTOR_PROFILE(TUMBLE_WEED_TAG, dTgTumbleWeed_c, fProfile::TUMBLE_WEED_TAG, 0x0244, 0, 0); STATE_DEFINE(dTgTumbleWeed_c, AreaOut); diff --git a/src/d/a/d_a_item.cpp b/src/d/a/d_a_item.cpp new file mode 100644 index 00000000..d49b3ecf --- /dev/null +++ b/src/d/a/d_a_item.cpp @@ -0,0 +1,409 @@ +#include "d/a/d_a_item.h" + +#include "common.h" +#include "d/a/d_a_itembase.h" +#include "d/flag/dungeonflag_manager.h" +#include "d/flag/flag_index.h" +#include "f/f_list_mg.h" +#include "toBeSorted/dowsing_target.h" +#include "toBeSorted/file_manager.h" + +const ItemFlagStruct dAcItemBase_c::sDefaultFlagStruct = {0x28, 0x3C, 0x1E, 0xFF, 0x0000, 0x02, 0x01}; +const ItemFlagStruct dAcItemBase_c::sItemFlagStructs[167] = { + {0x28, 0x3c, 0x1e, 0xff, 0x0001, 0x00, 0x01}, + {0x32, 0x46, 0x1e, 0xff, 0x0002, 0x02, 0x01}, + {0x32, 0x46, 0x1e, 0xff, 0x0003, 0x02, 0x01}, + {0x32, 0x46, 0x1e, 0xff, 0x0004, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0005, 0x02, 0x00}, + {0x32, 0x46, 0x1e, 0xff, 0x0006, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0007, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0008, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0009, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000a, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000b, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000d, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000e, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000f, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0010, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0011, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0013, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0014, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0015, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x001c, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x000c, 0x00, 0x01}, + {0x32, 0x46, 0x1e, 0xff, 0x0020, 0x00, 0x01}, + {0x32, 0x46, 0x1e, 0xff, 0x0021, 0x00, 0x01}, + {0x32, 0x46, 0x1e, 0xff, 0x0022, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0023, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0024, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0028, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0029, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x002a, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x002b, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x002c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x002d, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x002e, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0046, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0030, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0031, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0002, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0033, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0034, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0035, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0036, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0037, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0038, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0039, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x003c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0041, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0042, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0044, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0046, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0047, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0048, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x004a, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x004b, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x004c, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x004d, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x004e, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x004f, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0051, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0054, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0055, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0056, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0057, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0058, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x005a, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x005b, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x005c, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x005d, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x005e, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x005f, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0060, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0061, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0062, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0063, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0064, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0065, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0066, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0067, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0068, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0069, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x006b, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x006c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x006d, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x006e, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x006f, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0070, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0071, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0072, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0074, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0075, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0076, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0077, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0078, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0079, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x007a, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x007b, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x007c, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x007d, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x007e, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x007f, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0080, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0081, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0082, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0083, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0084, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0085, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0086, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0087, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0088, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x0089, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x008a, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x008c, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0x00, 0x008d, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x01, 0x008e, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x02, 0x007a, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x03, 0x0090, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x04, 0x0091, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x05, 0x0092, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x06, 0x0093, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x07, 0x0094, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x08, 0x0095, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x09, 0x0096, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x0a, 0x0097, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x0b, 0x0098, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x0099, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x009e, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x009f, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00a0, 0x00, 0x00}, + {0x28, 0x3c, 0x1e, 0x0c, 0x02f1, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x0d, 0x02f2, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x0e, 0x02f3, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x0f, 0x02f4, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x10, 0x02f5, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x11, 0x02f6, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x12, 0x02f7, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x13, 0x02f8, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x14, 0x02f9, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x15, 0x02fa, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x16, 0x02fb, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x17, 0x02fc, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x18, 0x02fd, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x19, 0x02fe, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x1a, 0x02ff, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0x1b, 0x0300, 0x00, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x00b1, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00b2, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00b3, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00b4, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00ba, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00bb, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00bc, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00bd, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00be, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00bf, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c0, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c1, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c2, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c3, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c4, 0x02, 0x00}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c5, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c6, 0x02, 0x01}, + {0x28, 0x3c, 0x1e, 0xff, 0x00c7, 0x00, 0x00}, +}; + +const u32 dAcItemBase_c::sItemTypeFlags[MAX_ITEM_ID - 1] = { + 0x2000, 0x0, 0x3000, 0x3000, 0x0, 0x1000, 0x3000, 0x3000, 0x0, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, + 0x1000, 0x1000, 0x1000, 0x0, 0x0, 0x1000, 0x1000, 0x1000, 0x3000, 0x3000, 0x3000, 0x1000, 0x1000, 0x1000, + 0x0, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x0, 0x2, 0x1000, 0x1000, 0x1000, 0x3000, 0x0, + 0x3000, 0x0, 0x0, 0x0, 0x0, 0x3000, 0x0, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x3002, 0x3002, + 0x1000, 0x3000, 0x0, 0x0, 0x0, 0x3000, 0x3000, 0x3000, 0x0, 0x220, 0x220, 0x1000, 0x1000, 0x0, + 0x10, 0x1000, 0x0, 0x0, 0x2, 0x1000, 0x1000, 0x1000, 0x10, 0x20, 0x0, 0x20, 0x0, 0x0, + 0x111, 0x111, 0x11, 0x11, 0x120, 0x0, 0x1000, 0x1000, 0x1000, 0x1000, 0x0, 0x1000, 0x1000, 0x1000, + 0x0, 0x1000, 0x121, 0x2, 0x2, 0x222, 0x4, 0x1000, 0x1000, 0x0, 0x0, 0x0, 0x0, 0x1000, + 0x1000, 0x0, 0x0, 0x3, 0x120, 0x120, 0x120, 0x120, 0x120, 0x120, 0x120, 0x120, 0x120, 0x1120, + 0x110, 0x110, 0x101, 0x202, 0x203, 0x300, 0x400, 0x500, 0x201, 0x302, 0x303, 0x1000, 0x1000, 0x1000, + 0x1000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x21, + 0x3, 0x3, 0x3, 0x3, 0x0, 0x0, 0x0, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, + 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0, 0x0, 0x0, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, + 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x110, 0x110, + 0x110, 0x0, 0x1000, 0x4, 0x0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0, + 0xFFFF, 0xFFFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0xFFFF, 0xFFFF, 0xFFFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFFFF, + 0xFFFF, 0x0, 0x0, 0x0, 0x0, 0x0, +}; + +bool dAcItemBase_c::isValidItemTypeIdx(int itemId) { + return itemId < ARRAY_LENGTH(sItemTypeFlags); +} + +bool dAcItemBase_c::getItemTypeFromId(u16 itemID, u32 *pOutType) { + bool valid = isValidItemTypeIdx(itemID); + if (valid) { + *pOutType = sItemTypeFlags[itemID]; + } + return valid; +} + +bool dAcItemBase_c::getItemAnimType(u16 itemId, u32 *pOutType) { + u32 type; + bool valid = getItemTypeFromId(itemId, &type); + if (valid) { + *pOutType = type >> 12 & 0xF; + } + return valid; +} + +int dAcItemBase_c::getHeartContainerHeartIncrease() { + return 1; +} + +int dAcItemBase_c::getCompletedHeartPieceHeartIncrease() { + return 1; +} + +u8 dAcItemBase_c::getTearIdx(int tearNum) { + return tearNum / 15; +} +bool dAcItemBase_c::getFlagIdxForTear(int tearNum, u32 *pOutFlag) { + u8 idx = getTearIdx(tearNum); + if (idx == 0) { + *pOutFlag = 0xd; + return true; + } else if (idx == 1) { + *pOutFlag = 0xe; + return true; + } else { + return false; + } +} +u16 dAcItemBase_c::getTearBit(int tearNum) { + return 1 << tearNum % 15; +} + +bool dAcItemBase_c::setDungeonFlagForTear(int tearNum) { + u32 flag_idx; + if (!getFlagIdxForTear(tearNum, &flag_idx)) { + return false; + } + // idk + int idx = DungeonflagManager::sInstance->mStageIndex; + const u16 *pData = FileManager::sInstance->getDungeonFlagsConst() + ((idx & 0x1FFF) * 4); + u32 counterMask = DungeonflagManager::sInstance->mpFlagIndex->getCounterOrFlag(flag_idx, pData, 8); + u32 tearMask = getTearBit(tearNum); + DungeonflagManager::sInstance->setToValue(flag_idx, tearMask | counterMask); + return true; +} + +u16 dAcItemBase_c::getItemId() { + return mId; +} + +// TODO: Incorrect location +bool isItemThatHasStruct(u16 itemId) { + return itemId; +} + +// TODO: Incorrect location +u16 getIndex(u16 itemId) { + return itemId; +} + +// TODO: Incorrect location +// const ItemFlagStruct *getItemFlagStruct(u16 itemId) { +// if (isItemThatHasStruct(itemId)) { +// return &sItemFlagStructs[getIndex(itemId)]; +// } else { +// return &sDefaultFlagStruct; +// } +// } + +fLiMgBa_c dAcItem_c::sItemList; + +SPECIAL_ACTOR_PROFILE(ITEM, dAcItem_c, fProfile::ITEM, 0x2B, 0, 2); + +STATE_DEFINE(dAcItem_c, Wait); +STATE_DEFINE(dAcItem_c, Carry); +STATE_DEFINE(dAcItem_c, GetBeetle); +STATE_DEFINE(dAcItem_c, WaitGet); +STATE_DEFINE(dAcItem_c, Get); +STATE_DEFINE(dAcItem_c, WaitGetDemo); +STATE_DEFINE(dAcItem_c, WaitForcedGetDemo); +STATE_DEFINE(dAcItem_c, GetDemo); +STATE_DEFINE(dAcItem_c, WaitTBoxGetDemo); +STATE_DEFINE(dAcItem_c, ResurgeWait); +STATE_DEFINE(dAcItem_c, WaitTurnOff); +STATE_DEFINE(dAcItem_c, WaitSacredDewGetEffect); + +dAcItem_c::dAcItem_c() + : mStateMgr(*this, sStateID::null), mEff_0x8F4(this), mEff_0x928(this), mEff_0x95C(this), mEff_0x990(this), + mEff_0x9C4(this), mEff_0x9F8(this), mEff_0xA2C(this), mEff_0xA60(this), mNode(this), + mEventRelated(*this, nullptr), mDowsingTarget(this, DowsingTarget::SLOT_NONE), mItemQueuePrev(nullptr), + mItemQueueNext(nullptr) { + mField_0xCD8 = 1.0f; + mBaseScale = 1.0f; + mCurrentScale = 1.0f; + mField_0xCE4 = 1.0f; + mField_0xCE8 = 1.0f; + mField_0xCEC = 1.0f; + + mItemFlags = 0; + mField_0xD4C = 0; + + mbNoDespawn = false; + mbNoGravity = false; + + mField_0xD51 = 0; + mField_0xD56 = 0; + + mbShowItemLighting = false; + + mField_0xD62 = 0; + mField_0xD63 = 0; + mField_0xD65 = 0; + mField_0xD66 = 0; + + sItemList.append(&mNode); + unkByteTargetFiRelated = 3; +} +dAcItem_c::~dAcItem_c() { + delete mField_0xB3C; + for (int i = 0; i < 2; i++) { + delete mField_0xB34[i]; + } + mDowsingTarget.doUnregister(); +} + +void dAcItem_c::initializeState_Wait() {} +void dAcItem_c::executeState_Wait() {} +void dAcItem_c::finalizeState_Wait() {} + +void dAcItem_c::initializeState_Carry() {} +void dAcItem_c::executeState_Carry() {} +void dAcItem_c::finalizeState_Carry() {} + +void dAcItem_c::initializeState_GetBeetle() {} +void dAcItem_c::executeState_GetBeetle() {} +void dAcItem_c::finalizeState_GetBeetle() {} + +void dAcItem_c::initializeState_WaitGet() {} +void dAcItem_c::executeState_WaitGet() {} +void dAcItem_c::finalizeState_WaitGet() {} + +void dAcItem_c::initializeState_Get() {} +void dAcItem_c::executeState_Get() {} +void dAcItem_c::finalizeState_Get() {} + +void dAcItem_c::initializeState_WaitGetDemo() {} +void dAcItem_c::executeState_WaitGetDemo() {} +void dAcItem_c::finalizeState_WaitGetDemo() {} + +void dAcItem_c::initializeState_WaitForcedGetDemo() {} +void dAcItem_c::executeState_WaitForcedGetDemo() {} +void dAcItem_c::finalizeState_WaitForcedGetDemo() {} + +void dAcItem_c::initializeState_GetDemo() {} +void dAcItem_c::executeState_GetDemo() {} +void dAcItem_c::finalizeState_GetDemo() {} + +void dAcItem_c::initializeState_WaitTBoxGetDemo() {} +void dAcItem_c::executeState_WaitTBoxGetDemo() {} +void dAcItem_c::finalizeState_WaitTBoxGetDemo() {} + +void dAcItem_c::initializeState_ResurgeWait() {} +void dAcItem_c::executeState_ResurgeWait() {} +void dAcItem_c::finalizeState_ResurgeWait() {} + +void dAcItem_c::initializeState_WaitTurnOff() {} +void dAcItem_c::executeState_WaitTurnOff() {} +void dAcItem_c::finalizeState_WaitTurnOff() {} + +void dAcItem_c::initializeState_WaitSacredDewGetEffect() {} +void dAcItem_c::executeState_WaitSacredDewGetEffect() {} +void dAcItem_c::finalizeState_WaitSacredDewGetEffect() {} diff --git a/src/toBeSorted/counters/rupee_counter.cpp b/src/toBeSorted/counters/rupee_counter.cpp index 1a96ae83..99e4e3a7 100644 --- a/src/toBeSorted/counters/rupee_counter.cpp +++ b/src/toBeSorted/counters/rupee_counter.cpp @@ -1,5 +1,6 @@ -#include "toBeSorted/counters/counter.h" +#include "d/a/d_a_item.h" #include "d/flag/itemflag_manager.h" +#include "toBeSorted/counters/counter.h" static u16 getBaseCapacity(); static u16 getExtraWalletCapacity(); @@ -21,10 +22,10 @@ struct WalletStruct { /* 8016DE10 */ static u16 getBaseCapacity() { int i = 0; /* 804E91B0 */ WalletStruct wallet_definitions[4] = { - {0x6c, 500}, - {0x6d, 1000}, - {0x6e, 5000}, - {0x6f, 9000}, + {ITEM_MEDIUM_WALLET, 500}, + { ITEM_BIG_WALLET, 1000}, + { ITEM_GIANT_WALLET, 5000}, + {ITEM_TYCOON_WALLET, 9000}, }; const WalletStruct *wallet = &wallet_definitions[3]; for (; i < 4; i++, wallet--) { @@ -39,7 +40,7 @@ struct WalletStruct { extern "C" u16 getCounterByIndex(u16); /* 8016DEC0 */ static u16 getExtraWalletCapacity() { - return 300 * getCounterByIndex(0x27); + return 300 * getCounterByIndex(0x27); // Maybe 0x27 corresponds to item 27 -> small wallet? } /* 80575610 */ RupeeCounter RUPEE_COUNTER; diff --git a/src/toBeSorted/dowsing_target.cpp b/src/toBeSorted/dowsing_target.cpp index 0dbf031e..6b2d40ad 100644 --- a/src/toBeSorted/dowsing_target.cpp +++ b/src/toBeSorted/dowsing_target.cpp @@ -1,19 +1,18 @@ #include "toBeSorted/dowsing_target.h" #include "c/c_math.h" -#include "m/m_mtx.h" #include "d/flag/itemflag_manager.h" #include "d/flag/storyflag_manager.h" +#include "m/m_mtx.h" #include "toBeSorted/tlist.h" - typedef TList DowsingList; DowsingList DOWSING_LISTS[8]; static const int DOWSING_TARGET_STORY_FLAGS[8] = { 100, 105, 100, 104, 108, 110, 109, 102, -}; +}; // TODO (Story Flag ID) DowsingTarget::~DowsingTarget() { doUnregister(); @@ -56,6 +55,8 @@ void DowsingTarget::getPosition(mVec3_c &position) { PSMTXMultVec(mtx.m, mOffset, position); } +// TODO (Story Flag IDs) + bool DowsingTarget::hasZeldaDowsing() { return StoryflagManager::sInstance->getCounterOrFlag(100); } @@ -73,14 +74,15 @@ bool DowsingTarget::hasDesertNodeDowsing() { } inline bool checkTrial(u16 itemflag, u16 storyflag) { - return (ItemflagManager::sInstance->getFlagDirect(itemflag) && !StoryflagManager::sInstance->getCounterOrFlag(storyflag)) ? true : false; + return (ItemflagManager::sInstance->getFlagDirect(itemflag) && + !StoryflagManager::sInstance->getCounterOrFlag(storyflag)) ? + true : + false; } +// TODO (Story Flag IDs) (you get the point lmao) bool DowsingTarget::hasAnyTrialDowsing() { - return checkTrial(187, 93) || - checkTrial(188, 97) || - checkTrial(189, 98) || - checkTrial(193, 99); + return checkTrial(187, 93) || checkTrial(188, 97) || checkTrial(189, 98) || checkTrial(193, 99); } bool DowsingTarget::hasSacredWaterDowsing() { diff --git a/src/toBeSorted/file_manager.cpp b/src/toBeSorted/file_manager.cpp index b78b9fa6..30853c27 100644 --- a/src/toBeSorted/file_manager.cpp +++ b/src/toBeSorted/file_manager.cpp @@ -6,6 +6,7 @@ // clang-format off #include "sized_string.h" +#include "toBeSorted/dowsing_target.h" // clang-format on // This class here makes no sense and the name might @@ -111,14 +112,15 @@ u16 *FileManager::getStoryFlagsMut() { if (fileNum != 0) { file = &mFileB; } + file->new_file = 0; - file->health_capacity = 0x18; - file->unused_heart_related = 0x18; - file->current_health = 0x18; + file->health_capacity = 24; // 6 hearts * 4 quarters + file->unused_heart_related = 24; + file->current_health = 24; file->shield_pouch_slot = 8; - file->equipped_b_item = 0xb; - file->selectedDowsingSlot = 0x8; - file->lastUsedPouchItemSlot = 0x8; + file->equipped_b_item = 0xb; // TODO (B Wheel Id) + file->selectedDowsingSlot = DowsingTarget::SLOT_NONE; + file->lastUsedPouchItemSlot = 8; SizedString<32> buf; buf = "F405"; diff --git a/src/toBeSorted/special_item_drop_mgr.cpp b/src/toBeSorted/special_item_drop_mgr.cpp index 7d4c8613..6940a5ac 100644 --- a/src/toBeSorted/special_item_drop_mgr.cpp +++ b/src/toBeSorted/special_item_drop_mgr.cpp @@ -3,8 +3,9 @@ #include "c/c_lib.h" #include "c/c_math.h" #include "common.h" +#include "d/a/d_a_item.h" +#include "d/a/d_a_itembase.h" #include "d/a/d_a_player.h" -#include "d/a/obj/d_a_obj_item.h" #include "m/m_angle.h" #include "m/m_vec.h" @@ -366,34 +367,11 @@ const LowHealthReplacement LOW_HEALTH_REPLACEMENTS[] = { }, }; -// TODO: Convert to enum once work on items has started -static const u16 SPECIAL_ITEM_ARRAY[] = { - 0, // None - 6, // Heart - 6, // Heart - 2, // Green Rupee - 3, // Blue Rupee - 4, // Red Rupee - 0x2b, // Farore Tear - 0x28, // 5 Bombs - 0x29, // 10 Bombs - 7, // Single Arrow - 8, // Bundle Arrows - 0x39, // 5 Deku Seeds - 0, // None - 0, // None - 0x1c, // ET Key Piece - 0xa5, // Eldin Ore - 58, // ??? - 59, // ??? - 183, // ??? - 184, // ??? - 185, // ??? - 72, // Fairy - 72, // Fairy - 1, // Small Key - 34, // Rupoor -}; +int SPECIAL_ITEM_ARRAY[] = {ITEM_NONE, ITEM_HEART, ITEM_HEART, ITEM_GREEN_RUPEE, ITEM_BLUE_RUPEE, + ITEM_RED_RUPEE, ITEM_FARORE_TEAR, ITEM_5_BOMBS, ITEM_10_BOMBS, ITEM_SINGLE_ARROW, + ITEM_BUNDLE_ARROWS, ITEM_5_DEKU_SEEDS, ITEM_NONE, ITEM_NONE, ITEM_KEY_PIECE, + ITEM_ELDIN_ORE, ITEM_UNK_58, ITEM_UNK_59, ITEM_UNK_183, ITEM_UNK_184, + ITEM_UNK_185, ITEM_FAIRY, ITEM_FAIRY, ITEM_SMALL_KEY, ITEM_RUPOOR}; static const u32 sNumDropEntries = 0x36; static const struct { @@ -403,8 +381,7 @@ static const struct { 0x36, sList, }; - -static const u16 RAND_RUPEE_ARRAY[] = {2, 3, 4}; +static const int RAND_RUPEE_ARRAY[3] = {ITEM_GREEN_RUPEE, ITEM_BLUE_RUPEE, ITEM_RED_RUPEE}; extern "C" int getCurrentBowType(); extern "C" int getCurrentSlingshotType(); @@ -435,7 +412,7 @@ int SpecialItemDropMgr::fn_800C7BB0(int specialItemId) { } else if (specialItemId != 0x27 && (entryIdx == 1 || entryIdx == 2) && isHeroMode()) { // Hearts generally don't drop on Hero Mode unless it's a special kind of heart (which?) weight = 0; - } else if ((entryIdx == 7 || entryIdx == 8) && !dAcItem_c::checkFlag(/* Bomb Bag */ 92)) { + } else if ((entryIdx == 7 || entryIdx == 8) && !dAcItem_c::checkFlag(ITEM_BOMB_BAG)) { // Bombs won't drop until you get the Bomb Bag weight = 0; } @@ -487,15 +464,14 @@ int SpecialItemDropMgr::giveSpecialDropItem( bool ret = spawnSpecialDropItem(specialItemId, roomid, pos, subtype, rot); if (shouldTryExtraHearts(specialItemId)) { - for (u32 i = 0; i < adventurePouchCountItem(/* HEART_MEDAL */ 100); i++) { + for (u32 i = 0; i < adventurePouchCountItem(ITEM_HEART_MEDAL); i++) { bool ok = spawnSpecialDropItem(0x27, roomid, pos, subtype, rot); ret |= ok; } } if (shouldTryExtraRupees(specialItemId)) { - for (u32 i = 0; - i < adventurePouchCountItem(/* RUPEE_MEDAL */ 101) + adventurePouchCountItem(/* CURSED_MEDAL */ 104); + for (u32 i = 0; i < adventurePouchCountItem(ITEM_RUPEE_MEDAL) + adventurePouchCountItem(ITEM_CURSED_MEDAL); i++) { bool ok = spawnSpecialDropItem(0x28, roomid, pos, subtype, rot); ret |= ok; diff --git a/tools/custom/file_setup.py b/tools/custom/file_setup.py new file mode 100644 index 00000000..9cd6acfe --- /dev/null +++ b/tools/custom/file_setup.py @@ -0,0 +1,655 @@ +""" +File Setup sets up a header and cpp file template for the specified .s and symbol file. +Note: The file splits must already be made for this to work properly (including .data) + +Call with: + python ./tools/custom/file_setup.py PATH_TO_S_FILE PATH_TO_SYMBOLS_FILE + +From Rel Setup: +We have about 600 actor RELs, and quite a lot of them use a heavily +templated state system with 5 vtables, 24 function instances, and another +3 actual actor functions per state. This is not difficult to set up, +but it *is* quite tedious. But even if setting up a REL takes 5 minutes, +we're looking at 50+ hours, so if I can write this script in less than 50 +hours, it was worth it. + +For this file: +This has been modifed so that actors from the main DOL can be setup as well, +given a pre-split asm file. This has not yet been tested extensively, so please +make backup before running. + +""" + +from dataclasses import dataclass +import glob +import os +import pathlib +import re +import string +import sys +from typing import List + +CLASS_DIR_TREE = { + "d": { + "a": { + "b": {}, + "e": {}, + "npc": {}, + "obj": {}, + }, + "t": {}, + } +} + + +def get_file_path(file_name: str, tree=CLASS_DIR_TREE): + name_components = file_name.split("_", 1) + if len(name_components) == 1: + return "" + subtree = tree.get(name_components[0], None) + if subtree is None: + return "" + else: + return name_components[0] + "/" + get_file_path(name_components[1], subtree) + + +def L(items): + """Join items and add a length prefix""" + s = None + if isinstance(items, list): + s = "".join(items) + else: + s = items + + return str(len(s)) + s + + +def m_size(size: int): + return lambda f: f.size == size + + +def m_instructions(instrs: list): + return lambda f: all(instr in f.instructions for instr in instrs) + + +def simple_state_function(fn_name: str, load_02: str): + instrs = m_instructions([f"lwzu r12, 0x18(r3)", f"lwz r12, {load_02}(r12)"]) + return ( + [m_size(0x10), instrs], + lambda x: fn_name + + L( + [ + "sStateMgr_c<", + L(x), + ",20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>", + ] + ) + + "Fv", + ) + + +def state_proxy_function(fn_name: str, load_01: str): + instrs = m_instructions( + [ + "mr r4, r3", + "lwz r3, 0x8(r3)", + "lwz r4, 0x4(r4)", + "lwz r12, 0x0(r3)", + f"lwz r12, {load_01}(r12)", + ] + ) + return ( + [m_size(0x1C), instrs], + lambda x: fn_name + L(["sFState_c<", L(x), ">"]) + "Fv", + ) + + +def state_get_function(fn_name: str, load_01: str): + instrs = m_instructions(["lwzu r12, 0x18(r3)", f"lwz r12, {load_01}(r12)"]) + return ( + [m_size(0x10), instrs], + lambda x: fn_name + + L( + [ + "sStateMgr_c<", + L(x), + ",20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>", + ] + ) + + "CFv", + ) + + +def state_invoker_function(fn_name: str, ptmf_offset: str): + instrs = m_instructions([f"addi r12, r5, {ptmf_offset}", "bl __ptmf_scall"]) + return ( + [m_size(0x30), instrs], + lambda x: fn_name + L(["sFStateID_c<", L(x), ">"]) + "CFR" + L(x), + ) + + +FUNCTION_MATCHERS = [ + ( + [m_size(0x58), m_instructions(["bl __dt__10sStateIf_cFv"])], + lambda x: "__dt__" + L(["sFState_c<", L(x), ">"]) + "Fv", + ), + ( + [m_size(0x6C), m_instructions(["bl __dt__13sStateFctIf_cFv"])], + lambda x: "__dt__" + L(["sFStateFct_c<", L(x), ">"]) + "Fv", + ), + ( + [m_size(0xA0), m_instructions(["bl __dt__13sStateMgrIf_cFv"])], + lambda x: "__dt__" + + L( + [ + "sStateMgr_c<", + L(x), + ",20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>", + ] + ) + + "Fv", + ), + ( + [m_size(0xA4), m_instructions(["bl __dt__13sStateMgrIf_cFv"])], + lambda x: "__dt__" + + L(["sFStateMgr_c<", L(x), ",20sStateMethodUsr_FI_c>"]) + + "Fv", + ), + ( + [m_size(0x10), m_instructions([f"lwzu r12, 0x18(r3)", f"lwz r12, 0x18(r12)"])], + lambda x: "changeState__" + + L( + [ + "sStateMgr_c<", + L(x), + ",20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>", + ] + ) + + "FRC12sStateIDIf_c", + ), + simple_state_function("executeState__", "0x10"), + state_get_function("getStateID__", "0x28"), + ( + [m_size(0x60), m_instructions(["lwz r12, 0xc(r12)"])], + lambda x: "build__" + L(["sFStateFct_c<", L(x), ">"]) + "FRC12sStateIDIf_c", + ), + ( + [m_size(0xC), m_instructions(["stw r0, 0x0(r4)"])], + lambda x: "dispose__" + L(["sFStateFct_c<", L(x), ">"]) + "FRP10sStateIf_c", + ), + state_proxy_function("initialize__", "0x28"), + state_proxy_function("execute__", "0x2c"), + state_proxy_function("finalize__", "0x30"), + simple_state_function("initializeState__", "0xc"), + simple_state_function("finalizeState__", "0x14"), + simple_state_function("refreshState__", "0x1c"), + state_get_function("getState__", "0x20"), + state_get_function("getNewStateID__", "0x24"), + state_get_function("getOldStateID__", "0x2c"), + state_invoker_function("finalizeState__", "0x24"), + state_invoker_function("executeState__", "0x18"), + state_invoker_function("initializeState__", "0xc"), + ( + [m_size(0x58), m_instructions(["bl __dt__10sStateID_cFv"])], + lambda x: "__dt__" + L(["sFStateID_c<", L(x), ">"]) + "Fv", + ), + ( + [m_size(0x88), m_instructions(["bl strrchr", "bl strcmp"])], + lambda x: "isSameName__" + L(["sFStateID_c<", L(x), ">"]) + "CFPCc", + ), +] + +# ctor call, base class, include file +BASE_CLASSES = [ + ("bl __ct__7dBase_cFv", "dBase_c", "d/d_base.h"), + ("bl __ct__9dAcBase_cFv", "dAcBase_c", "d/a/d_a_base.h"), + ("bl __ct__12dAcObjBase_cFv", "dAcObjBase_c", "d/a/obj/d_a_obj_base.h"), + ("bl __ct__11dAcEnBase_cFv", "dAcEnBase_c", "d/a/e/d_a_en_base.h"), + ("bl __ct__8dAcNpc_cFv", "dAcNpc_c", "d/a/npc/d_a_npc.h"), + ("bl ActorNpcBase__ctor2", "dAcNpc_c", "d/a/npc/d_a_npc.h"), + ("bl __ct__16dAcObjDoor_cFv", "dAcObjDoor_c", "d/a/obj/d_a_obj_door_base.h"), + # bit of a lie but not worth automating + ("bl ActorLytBase__ctor", "dBase_c", "d/d_base.h"), + ("bl fn_800629D0", "dBase_c", "d/d_base.h"), +] + + +@dataclass +class Function: + name: str + size: int + instructions: list + + +@dataclass +class DataObj: + name: str + size: int + values: list + + +def get_strings(block: DataObj): + strings = [] + curr_str = "" + for val in block.values: + if not val.startswith(".4byte 0x"): + if curr_str: + strings.append(curr_str) + curr_str = "" + + if val.startswith(".string"): + strings.append(val[9:-1]) + continue + num_val = val[9:] + for i in range(0, 4): + byte_val = int(num_val[(2 * i) : (2 * (i + 1))], 16) + if ( + byte_val >= ord("0") + and byte_val <= ord("9") + or byte_val >= ord("a") + and byte_val <= ord("z") + or byte_val >= ord("A") + and byte_val <= ord("Z") + or byte_val == ord(":") + or byte_val == ord("_") + ): + curr_str += chr(byte_val) + else: + if curr_str: + strings.append(curr_str) + curr_str = "" + continue + return strings + + +def load_profiles_list(): + text = pathlib.Path("./include/f/f_profile_name.h").read_text() + result = [] + for line in text.splitlines(): + spl = line.split(" */ ") + if len(spl) > 1: + result.append(spl[1][:-1]) + + return result + + +PROFILES_LIST = load_profiles_list() + + +def get_profile_name(id: int): + return PROFILES_LIST[id] + + +def match_class_profile(block: DataObj, class_name: str, static_ctor: str): + """ + Returns new_ctor_function_name, new_data_name, decl_header + """ + if not len(block.values) or not static_ctor in block.values[0]: + return None + + if not all(v.startswith(".4byte") for v in block.values): + return None + + if block.values[0].startswith(".4byte 0x"): + return None + + if not all(v.startswith(".4byte 0x") for v in block.values[1:4]): + return None + + prof_id = int(block.values[1][9:13], 16) + draw_order = int(block.values[1][13:17], 16) + properties = int(block.values[2][9:], 16) + base_properties = int(block.values[3][9:], 16) if block.size >= 0x10 else None + + prof_name = get_profile_name(prof_id) + + new_fn_name = class_name + "_classInit__Fv" + new_block_name = "g_profile_" + prof_name + if base_properties is not None: + decl = f"SPECIAL_ACTOR_PROFILE({prof_name}, {class_name}, fProfile::{prof_name}, {hex(draw_order).upper()}, {str(properties)}, {str(base_properties)});" + else: + decl = f"SPECIAL_BASE_PROFILE({prof_name}, {class_name}, fProfile::{prof_name}, {hex(draw_order).upper()}, {str(properties)});" + + return new_fn_name, new_block_name, decl + + +data_re = re.compile( + "# \\.data:0x([0-9A-F]+) \\| 0x([0-9A-F]+) \\| size: 0x([0-9A-F]+)" +) + + +def parse_data(file): + blocks = [] + lines = file.splitlines() + i = 0 + while i < len(lines): + if m := data_re.match(lines[i]): + block_lines = [] + size = int(m.group(3), 16) + i += 1 + obj_name = lines[i].split(",")[0][5:] + i += 1 + while not lines[i].startswith(".endobj"): + block_lines.append(lines[i].strip()) + i += 1 + + blocks.append(DataObj(obj_name, size, block_lines)) + i += 1 + + return blocks + + +text_re = re.compile( + "# \\.text:0x([0-9A-F]+) \\| 0x([0-9A-F]+) \\| size: 0x([0-9A-F]+)" +) + + +def parse_function(file): + blocks = [] + lines = file.splitlines() + i = 0 + while i < len(lines): + if m := text_re.match(lines[i]): + block_lines = [] + size = int(m.group(3), 16) + i += 1 + obj_name = lines[i].split(",")[0][4:] + i += 1 + while not lines[i].startswith(".endfn"): + if lines[i].startswith("/*"): + block_lines.append(lines[i].split("\t")[1].strip()) + i += 1 + + blocks.append(Function(obj_name, size, block_lines)) + i += 1 + + return blocks + + +DEFAULT_NAME_FALLBACKS = [ + ("d_a_b_", "dAcB"), + ("d_a_e_", "dAcEn"), + ("d_a_obj_", "dAcO"), + ("d_a_npc_", "dAcNpc"), + ("d_t_", "dTg"), + ("d_a_", "dAc"), + ("d_", "d"), +] + + +def build_class_name(strings, file_name): + for s in strings: + if "::StateID_" in s: + return s.split("::")[0] + + for s in strings: + if "::m_allocator" in s: + return s.split("::")[0] + + for base, cl in DEFAULT_NAME_FALLBACKS: + if file_name.startswith(base): + l = len(base) + return cl + string.capwords(file_name[l:], "_").replace("_", "") + "_c" + + return None + + +def find_static_ctor(fns: List[Function]): + for fn in fns: + for instr in fn.instructions: + if instr == "bl __nw__7fBase_cFUl": + has_inline_ctor = fn.size > 0x34 + return fn.name, has_inline_ctor + + +def find_dtors(fns: List[Function]): + dtors = [] + for fn in fns: + for instr in fn.instructions: + if instr == "bl __dl__7fBase_cFPv": + dtors.append(fn.name) + return dtors + + +def find_state_candidates(data_blocks: List[DataObj], num_states): + for block in data_blocks: + fns = [] + i = 0 + while i + 2 < len(block.values): + if ( + block.values[i] == ".4byte 0x00000000" + and block.values[i + 1] == ".4byte 0xFFFFFFFF" + ): + fn_candidate = block.values[i + 2] + if fn_candidate.startswith(".4byte") and not fn_candidate[ + 7: + ].startswith("0x"): + fns.append(fn_candidate[7:]) + + i += 1 + + if len(fns) == num_states * 3: + return fns + + return None + + +def find_vtable_block_idx(data_blocks: list[DataObj], dtor_listing): + dtor = ".4byte " + dtor_listing + + for i, block in enumerate(data_blocks): + if dtor in block.values: + return i + + return None + + +def find_state_names(strings): + states = [] + for s in strings: + spl = s.split("::StateID_") + if len(spl) == 2: + states.append(spl[1]) + + return states + + +FILES_WITH_MULTIPLE_STATE_MGRS = ["d_lyt_file_select", "d_a_b_girahimu3_first"] + + +def process_file(file_name, data_blocks: List[DataObj], fns: List[Function], sym_file): + has_multiple_templates = file_name in FILES_WITH_MULTIPLE_STATE_MGRS + strings = [s for b in data_blocks for s in get_strings(b)] + name = build_class_name(strings, file_name) + + renames = [] + new_ctor_name = "__ct__" + L(name) + "Fv" + new_dtor_name = "__dt__" + L(name) + "Fv" + + old_static_ctor_name, has_inline_ctor = find_static_ctor(fns) + + if not old_static_ctor_name: + print(file_name, "no ctor!") + return + + old_dtor_names = find_dtors(fns) + if len(old_dtor_names) == 0: + print(file_name, "no dtor") + return + + if len(old_dtor_names) > 1: + print(file_name, "multiple dtors") + print(old_dtor_names) + # chosen_dtor = 1 # HACK for dAcItem + return + else: + chosen_dtor = 0 + + old_dtor_name = old_dtor_names[chosen_dtor] + + renames.append((old_dtor_name, new_dtor_name)) + + for b in data_blocks: + if res := match_class_profile(b, name, old_static_ctor_name): + new_static_ctor_name, new_data_name, decl_header = res + renames.append((old_static_ctor_name, new_static_ctor_name)) + renames.append((b.name, new_data_name)) + break + + for f in fns: + for ctor, base_class_, include_ in BASE_CLASSES: + if any(instr == ctor for instr in f.instructions): + renames.append((f.name, new_ctor_name)) + base_class = base_class_ + include = include_ + + for f in fns: + if not has_multiple_templates: + for matchers, name_fn in FUNCTION_MATCHERS: + if all(match(f) for match in matchers): + renames.append((f.name, name_fn(name))) + + if "bl __ct__10sStateID_cFPCc" in f.instructions: + renames.append((f.name, f"__sinit_\\{file_name}_cpp")) + + uses_state_system = not has_multiple_templates and any( + "bl __ct__10sStateID_cFPCc" in fn.instructions for fn in fns + ) + auto_functions = [] + state_decls = [] + state_defs = [] + includes = [include] + if uses_state_system: + includes.append("s/s_State.hpp") + includes.append("s/s_StateMgr.hpp") + state_names = find_state_names(strings) + # Since find_state_candidates uses ptmfs for state funcs, a hint may need to be applied. + # This is done by finding the vtable, since most of the time (?) the funcs appear after the vtable. + # dAcItem has *many* ptmfs, which can cause issues + # Easy way to find vtable? Find the dtor in the obj :) + vtable_idx = find_vtable_block_idx(data_blocks, old_dtor_name) + blocks_after_vtable = data_blocks + if vtable_idx: + blocks_after_vtable = data_blocks[vtable_idx:] + + state_candidates = find_state_candidates(blocks_after_vtable, len(state_names)) + if state_candidates: + for idx, orig in enumerate(state_candidates): + if idx % 3 == 0: + method = "finalize" + elif idx % 3 == 1: + method = "execute" + elif idx % 3 == 2: + method = "initialize" + + state_name = state_names[idx // 3] + + readable_function = f"void {name}::{method}State_{state_name}()" + " {}" + mangled_function = f"{method}State_{state_name}__" + L(name) + "Fv" + + renames.append((orig, mangled_function)) + auto_functions.append(readable_function) + + # fix order + if idx % 3 == 2: + auto_functions[-1], auto_functions[-3] = ( + auto_functions[-3], + auto_functions[-1], + ) + + for state_name in state_names: + state_decls.append(f"STATE_FUNC_DECLARE({name}, {state_name});") + state_defs.append(f"STATE_DEFINE({name}, {state_name});") + else: + print(file_name, "no matching state functions (maybe virtual?)") + + header_guard = file_name.upper() + "_H" + file_path = get_file_path(file_name) + file_name + with open(os.path.join("./include", file_path + ".h"), "w") as f: + f.write(f"#ifndef {header_guard}\n") + f.write(f"#define {header_guard}\n\n") + + for i in includes: + f.write(f'#include "{i}"\n') + f.write("\n") + + f.write(f"class {name} : public {base_class} {{ \n") + f.write(f"public:\n") + + if has_inline_ctor: + f.write(f"\t{name}()") + if uses_state_system: + f.write(" : mStateMgr(*this, sStateID::null)") + f.write(" {}\n") + f.write(f"\tvirtual ~{name}() {{}}\n\n") + else: + f.write(f"\t{name}();\n") + f.write(f"\tvirtual ~{name}();\n\n") + + if state_decls: + for s in state_decls: + f.write(f"\t{s}\n") + f.write("\n") + + f.write("private:\n") + + if uses_state_system: + f.write(f"\t/* 0x??? */ STATE_MGR_DECLARE({name});\n") + + f.write("};\n") + f.write("#endif\n") + + with open(os.path.join("./src/", file_path + ".cpp"), "w+") as f: + f.write(f'#include "{file_path}.h"\n\n') + + f.write(f"{decl_header}\n\n") + + if state_defs: + for s in state_defs: + f.write(f"{s}\n") + f.write("\n") + + if not has_inline_ctor: + f.write(f"{name}::{name}()") + if uses_state_system: + f.write(" : mStateMgr(*this, sStateID::null)") + f.write(" {}\n") + f.write(f"{name}::~{name}() {{}}\n\n") + + for fn in auto_functions: + f.write(fn + "\n") + + symbols_path = pathlib.Path(sym_file) + symbols_txt = symbols_path.read_text() + # print(renames) + for orig, new_name in renames: + symbols_txt = symbols_txt.replace(f"{orig} = .", f"{new_name} = .") + + symbol_lines = symbols_txt.splitlines() + for idx, l in enumerate(symbol_lines): + if l.startswith("__sinit") and l.find("scope:local") == -1: + symbol_lines[idx] += " scope:local" + + symbols_txt = "\n".join(symbol_lines) + + symbols_path.write_text(symbols_txt) + + +def main(): + s_file = sys.argv[1] + sym_file = sys.argv[2] + + s_text = pathlib.Path(s_file).read_text() + fns = parse_function(s_text) + datas = parse_data(s_text) + + if len(datas) == 0: + print("No data found. Exiting") + + file_name = pathlib.Path(s_file).stem.removesuffix("NP") + + process_file(file_name, datas, fns, sym_file) + + +if __name__ == "__main__": + main()