diff --git a/.clangd b/.clangd new file mode 100644 index 00000000..ca38e50f --- /dev/null +++ b/.clangd @@ -0,0 +1,5 @@ +# https://clangd.llvm.org/config +CompileFlags: + Add: [ + "-Wno-c++11-compat-deprecated-writable-strings" + ] diff --git a/.vscode/settings.json b/.vscode/settings.json index f2f3f170..6eeacd5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,7 @@ "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "files.associations": { - "*.inc": "c", + "*.inc": "cpp", ".clangd": "yaml" }, // Disable C/C++ IntelliSense, use clangd instead diff --git a/config/SOUE01/rels/d_a_obj_island_nusiNP/splits.txt b/config/SOUE01/rels/d_a_obj_island_nusiNP/splits.txt index 3199dc96..34ec1ee1 100644 --- a/config/SOUE01/rels/d_a_obj_island_nusiNP/splits.txt +++ b/config/SOUE01/rels/d_a_obj_island_nusiNP/splits.txt @@ -17,3 +17,6 @@ REL/global_destructor_chain.c: REL/d/a/obj/d_a_obj_island_nusi.cpp: .text start:0x000000F0 end:0x00000FC8 .ctors start:0x00000000 end:0x00000004 + .rodata start:0x00000000 end:0x0000002C + .data start:0x00000000 end:0x00000248 + .bss start:0x00000008 end:0x00000088 diff --git a/config/SOUE01/rels/d_a_obj_island_nusiNP/symbols.txt b/config/SOUE01/rels/d_a_obj_island_nusiNP/symbols.txt index 44ac6803..902714ea 100644 --- a/config/SOUE01/rels/d_a_obj_island_nusiNP/symbols.txt +++ b/config/SOUE01/rels/d_a_obj_island_nusiNP/symbols.txt @@ -8,20 +8,20 @@ __dt__29sFState_c<16dAcOislandNusi_c>Fv = .text:0x000001D0; // type:function siz __dt__32sFStateFct_c<16dAcOislandNusi_c>Fv = .text:0x00000230; // type:function size:0x6C __dt__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002A0; // type:function size:0xA0 __dt__55sFStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000340; // type:function size:0xA4 -AcOislandNusi__initModels = .text:0x000003F0; // type:function size:0x15C -AcOislandNusi__init = .text:0x00000550; // type:function size:0x13C +createHeap__16dAcOislandNusi_cFv = .text:0x000003F0; // type:function size:0x15C +create__16dAcOislandNusi_cFv = .text:0x00000550; // type:function size:0x13C changeState__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000690; // type:function size:0x10 -AcOislandNusi__destroy = .text:0x000006A0; // type:function size:0x38 -AcOislandNusi__update = .text:0x000006E0; // type:function size:0x30 +doDelete__16dAcOislandNusi_cFv = .text:0x000006A0; // type:function size:0x38 +actorExecute__16dAcOislandNusi_cFv = .text:0x000006E0; // type:function size:0x30 executeState__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000710; // type:function size:0x10 -AcOislandNusi__draw = .text:0x00000720; // type:function size:0x60 +draw__16dAcOislandNusi_cFv = .text:0x00000720; // type:function size:0x60 initializeState_Wait__16dAcOislandNusi_cFv = .text:0x00000780; // type:function size:0xD0 executeState_Wait__16dAcOislandNusi_cFv = .text:0x00000850; // type:function size:0x50 finalizeState_Wait__16dAcOislandNusi_cFv = .text:0x000008A0; // type:function size:0x4 initializeState_NusiFight__16dAcOislandNusi_cFv = .text:0x000008B0; // type:function size:0xD0 executeState_NusiFight__16dAcOislandNusi_cFv = .text:0x00000980; // type:function size:0x50 finalizeState_NusiFight__16dAcOislandNusi_cFv = .text:0x000009D0; // type:function size:0x4 -isInLeviasFight = .text:0x000009E0; // type:function size:0x7C +isInLeviasFight__16dAcOislandNusi_cCFv = .text:0x000009E0; // type:function size:0x7C __dt__16dAcOislandNusi_cFv = .text:0x00000A60; // type:function size:0xE4 getStateID__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000B50; // type:function size:0x10 build__32sFStateFct_c<16dAcOislandNusi_c>FRC12sStateIDIf_c = .text:0x00000B60; // type:function size:0x60 @@ -44,20 +44,20 @@ isSameName__31sFStateID_c<16dAcOislandNusi_c>CFPCc = .text:0x00000F40; // type:f _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global __destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global -lbl_413_rodata_0 = .rodata:0x00000000; // type:object size:0x8 data:float -lbl_413_rodata_8 = .rodata:0x00000008; // type:object size:0x24 data:4byte -lbl_413_data_0 = .data:0x00000000; // type:object size:0x8 data:4byte -lbl_413_data_8 = .data:0x00000008; // type:object size:0x10 -g_profile_OBJ_ISLAND_NUSI = .data:0x00000018; // type:object size:0x38 -lbl_413_data_50 = .data:0x00000050; // type:object size:0x20 -lbl_413_data_70 = .data:0x00000070; // type:object size:0x8 -lbl_413_data_78 = .data:0x00000078; // type:object size:0x80 -lbl_413_data_F8 = .data:0x000000F8; // type:object size:0x30 -lbl_413_data_128 = .data:0x00000128; // type:object size:0x30 -lbl_413_data_158 = .data:0x00000158; // type:object size:0x18 -lbl_413_data_170 = .data:0x00000170; // type:object size:0xA4 -lbl_413_data_214 = .data:0x00000214; // type:object size:0x34 +lbl_413_rodata_0 = .rodata:0x00000000; // type:object size:0x8 scope:local data:float +lbl_413_rodata_8 = .rodata:0x00000008; // type:object size:0x24 scope:local data:4byte +lbl_413_data_0 = .data:0x00000000; // type:object size:0x8 scope:local data:4byte +lbl_413_data_8 = .data:0x00000008; // type:object size:0x10 scope:local +g_profile_OBJ_ISLAND_NUSI = .data:0x00000018; // type:object size:0x10 +lbl_413_data_50 = .data:0x00000050; // type:object size:0x20 scope:local +lbl_413_data_70 = .data:0x00000070; // type:object size:0x8 scope:local +__vt__16dAcOislandNusi_c = .data:0x00000078; // type:object size:0x80 +__vt__55sFStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c> = .data:0x000000F8; // type:object size:0x30 +__vt__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000128; // type:object size:0x30 +__vt__32sFStateFct_c<16dAcOislandNusi_c> = .data:0x00000158; // type:object size:0x14 +__vt__29sFState_c<16dAcOislandNusi_c> = .data:0x00000170; // type:object size:0x18 +__vt__31sFStateID_c<16dAcOislandNusi_c> = .data:0x00000214; // type:object size:0x34 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global -lbl_413_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte -lbl_413_bss_18 = .bss:0x00000018; // type:object size:0x40 data:4byte -lbl_413_bss_58 = .bss:0x00000058; // type:object size:0x30 data:4byte +lbl_413_bss_8 = .bss:0x00000008; // type:object size:0xC scope:local data:4byte +StateID_Wait__16dAcOislandNusi_c = .bss:0x00000018; // type:object size:0x30 data:4byte +StateID_NusiFight__16dAcOislandNusi_c = .bss:0x00000058; // type:object size:0x30 data:4byte diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f984a698..05f36d5c 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -199,35 +199,11 @@ d/d_text_writer.cpp: toBeSorted/time_area_mgr.cpp: .text start:0x800B9280 end:0x800BB2A0 -toBeSorted/sceneflag_manager.cpp: - .text start:0x800BD8C0 end:0x800BE7A8 - .sbss start:0x805753E0 end:0x805753F0 - .bss start:0x805A78D0 end:0x805A7AD8 - -toBeSorted/misc_flag_managers.cpp: - .text start:0x800BE7B0 end:0x800BEE00 - .data start:0x80510CDC end:0x80510D04 - .sbss start:0x805753F0 end:0x805753FC - .bss start:0x805A7AD8 end:0x805A9AD8 - -toBeSorted/flag_space.cpp: - .text start:0x800BEE00 end:0x800BEF90 - .data start:0x80510D04 end:0x80510D10 - -toBeSorted/unk_flag_stuff.cpp: - .text start:0x800BEF90 end:0x800BF200 - -toBeSorted/bitwise_flag_helper.cpp: - .text start:0x800BF200 end:0x800BF264 - -toBeSorted/dungeonflag_manager.cpp: - .text start:0x800BF8D0 end:0x800BFB9C - .bss start:0x805A9C58 end:0x805A9C68 - -toBeSorted/skipflag_manager.cpp: - .text start:0x800BFBA0 end:0x800BFE00 - .sbss start:0x80575408 end:0x8057540C - .bss start:0x805A9C68 end:0x805A9C88 +d/flag/flag_managers.cpp: + .text start:0x800BD8C0 end:0x800C0650 + .data start:0x80510B88 end:0x80510D10 + .sbss start:0x805753E0 end:0x80575410 + .bss start:0x805A78D0 end:0x805A9C88 toBeSorted/special_item_drop_mgr.cpp: .text start:0x800C7B60 end:0x800C82B0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index fd12079c..17968599 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3560,7 +3560,7 @@ fn_8009EAE0 = .text:0x8009EAE0; // type:function size:0x4 fn_8009EAF0 = .text:0x8009EAF0; // type:function size:0xC fn_8009EB00 = .text:0x8009EB00; // type:function size:0xC fn_8009EB10 = .text:0x8009EB10; // type:function size:0xC -fn_8009EB20 = .text:0x8009EB20; // type:function size:0x8 +setFlag__15ItemflagManagerFUs = .text:0x8009EB20; // type:function size:0x8 copyQueuedEventToCurrentAndHandleSkipEvent = .text:0x8009EB30; // type:function size:0x36C fn_8009EEA0 = .text:0x8009EEA0; // type:function size:0x53C alsoSetAsCurrentEvent__12EventManagerFP9dAcBase_cP5EventPv = .text:0x8009F3E0; // type:function size:0x470 @@ -4069,7 +4069,7 @@ fn_800BD7A0 = .text:0x800BD7A0; // type:function size:0x74 fn_800BD820 = .text:0x800BD820; // type:function size:0x8 fn_800BD830 = .text:0x800BD830; // type:function size:0x78 fn_800BD8B0 = .text:0x800BD8B0; // type:function size:0x10 -doNothing__16SceneflagManagerFv = .text:0x800BD8C0; // type:function size:0x4 +init__16SceneflagManagerFv = .text:0x800BD8C0; // type:function size:0x4 setShouldCommit__16SceneflagManagerFUs = .text:0x800BD8D0; // type:function size:0xC __ct__16SceneflagManagerFv = .text:0x800BD8E0; // type:function size:0x64 isNotTempOrZoneFlag__16SceneflagManagerFUs = .text:0x800BD950; // type:function size:0xC @@ -4101,120 +4101,120 @@ unsetZoneflag__16SceneflagManagerFUsUs = .text:0x800BE3E0; // type:function size unsetFlag__16SceneflagManagerFUsUs = .text:0x800BE490; // type:function size:0x70 unsetSceneflagGlobal__16SceneflagManagerFUsUs = .text:0x800BE500; // type:function size:0xE0 unsetTempOrSceneflag__16SceneflagManagerFUs = .text:0x800BE5E0; // type:function size:0x100 -doCommit__16SceneflagManagerFv = .text:0x800BE6E0; // type:function size:0xC8 -commitIfNecessary__22CommittableFlagManagerFv = .text:0x800BE7B0; // type:function size:0x58 -doCommit__15TBoxFlagManagerFv = .text:0x800BE810; // type:function size:0x58 -checkUncommittedFlag__15TBoxFlagManagerFUs = .text:0x800BE870; // type:function size:0x68 -__ct__15TBoxFlagManagerFv = .text:0x800BE8E0; // type:function size:0x40 -init__15TBoxFlagManagerFv = .text:0x800BE920; // type:function size:0x4 -copyFromSave__15TBoxFlagManagerFs = .text:0x800BE930; // type:function size:0x5C -checkFlag__15TBoxFlagManagerFUsUs = .text:0x800BE990; // type:function size:0x94 -getFlagCount__15TBoxFlagManagerCFv = .text:0x800BEA30; // type:function size:0x8 -setFlag__15TBoxFlagManagerFUs = .text:0x800BEA40; // type:function size:0x80 -clearSavedFlags__18EnemyDefeatManagerFv = .text:0x800BEAC0; // type:function size:0x40 -checkUncommittedFlag__18EnemyDefeatManagerFUs = .text:0x800BEB00; // type:function size:0x7C -__ct__18EnemyDefeatManagerFv = .text:0x800BEB80; // type:function size:0x38 -init__18EnemyDefeatManagerFv = .text:0x800BEBC0; // type:function size:0xC -copyFromSave__18EnemyDefeatManagerFUs = .text:0x800BEBD0; // type:function size:0x54 -updateFlagIndex__18EnemyDefeatManagerFUs = .text:0x800BEC30; // type:function size:0x18 -clearAll__18EnemyDefeatManagerFv = .text:0x800BEC50; // type:function size:0x34 -checkIsValidFlag__18EnemyDefeatManagerFUs = .text:0x800BEC90; // type:function size:0x18 -checkFlag__18EnemyDefeatManagerFUs = .text:0x800BECB0; // type:function size:0xA0 -getFlagCount__18EnemyDefeatManagerCFv = .text:0x800BED50; // type:function size:0x8 -setFlag__18EnemyDefeatManagerFUs = .text:0x800BED60; // type:function size:0x94 -getFlagPtrChecked__9FlagSpaceFv = .text:0x800BEE00; // type:function size:0x3C -getFlagPtrUnchecked__9FlagSpaceFv = .text:0x800BEE40; // type:function size:0x8 +commit__16SceneflagManagerFv = .text:0x800BE6E0; // type:function size:0xC8 +commit__22CommittableFlagManagerFv = .text:0x800BE7B0; // type:function size:0x58 +doCommit__15TBoxflagManagerFv = .text:0x800BE810; // type:function size:0x58 +checkUncommittedFlag__15TBoxflagManagerFUs = .text:0x800BE870; // type:function size:0x68 +__ct__15TBoxflagManagerFv = .text:0x800BE8E0; // type:function size:0x40 +init__15TBoxflagManagerFv = .text:0x800BE920; // type:function size:0x4 +copyFromSave__15TBoxflagManagerFUl = .text:0x800BE930; // type:function size:0x5C +checkFlag__15TBoxflagManagerFUsUs = .text:0x800BE990; // type:function size:0x94 +getFlagCount__15TBoxflagManagerCFv = .text:0x800BEA30; // type:function size:0x8 +setFlag__15TBoxflagManagerFUs = .text:0x800BEA40; // type:function size:0x80 +clearSavedFlags__16EnemyflagManagerFv = .text:0x800BEAC0; // type:function size:0x40 +checkUncommittedFlag__16EnemyflagManagerFUs = .text:0x800BEB00; // type:function size:0x7C +__ct__16EnemyflagManagerFv = .text:0x800BEB80; // type:function size:0x38 +init__16EnemyflagManagerFv = .text:0x800BEBC0; // type:function size:0xC +copyFromSave__16EnemyflagManagerFUs = .text:0x800BEBD0; // type:function size:0x54 +updateFlagIndex__16EnemyflagManagerFUs = .text:0x800BEC30; // type:function size:0x18 +clearAll__16EnemyflagManagerFv = .text:0x800BEC50; // type:function size:0x34 +checkIsValidFlag__16EnemyflagManagerFUs = .text:0x800BEC90; // type:function size:0x18 +checkFlag__16EnemyflagManagerFUs = .text:0x800BECB0; // type:function size:0xA0 +getFlagCount__16EnemyflagManagerCFv = .text:0x800BED50; // type:function size:0x8 +setFlag__16EnemyflagManagerFUs = .text:0x800BED60; // type:function size:0x94 +getFlagPtrChecked__9FlagSpaceCFv = .text:0x800BEE00; // type:function size:0x3C +getFlagPtrUnchecked__9FlagSpaceCFv = .text:0x800BEE40; // type:function size:0x8 unsetAll__9FlagSpaceFv = .text:0x800BEE50; // type:function size:0xC setAllToZero__9FlagSpaceFUsUs = .text:0x800BEE60; // type:function size:0x68 -copyFromSaveFile2__9FlagSpaceFPUsUsUs = .text:0x800BEED0; // type:function size:0x7C -copyFromSaveFile__9FlagSpaceFPUsUsUs = .text:0x800BEF50; // type:function size:0x20 -filemanagerCheck__9FlagSpaceFv = .text:0x800BEF70; // type:function size:0x20 -calculateMask__12UnkFlagStuffFi = .text:0x800BEF90; // type:function size:0x18 -doNothing__12UnkFlagStuffFUl = .text:0x800BEFB0; // type:function size:0x4 -__ct__12UnkFlagStuffFUsP17UnkFlagDefinition = .text:0x800BEFC0; // type:function size:0xC -prepareIndexShiftMask__12UnkFlagStuffFUsUlPUsPUcPUs = .text:0x800BEFD0; // type:function size:0x80 -maskForIdx__12UnkFlagStuffFUs = .text:0x800BF050; // type:function size:0x50 -getCounterOrFlag__12UnkFlagStuffFUsPUsUl = .text:0x800BF0A0; // type:function size:0x68 -setCounterOrFlag__12UnkFlagStuffFUsPUsUlUl = .text:0x800BF110; // type:function size:0x9C -checkFlagValid__12UnkFlagStuffFUsUl = .text:0x800BF1B0; // type:function size:0x50 +copyFromSaveFile2__9FlagSpaceFPCUsUsUs = .text:0x800BEED0; // type:function size:0x7C +copyFromSaveFile__9FlagSpaceFPCUsUsUs = .text:0x800BEF50; // type:function size:0x20 +filemanagerCheck__9FlagSpaceCFv = .text:0x800BEF70; // type:function size:0x20 +calculateMask__9FlagIndexFl = .text:0x800BEF90; // type:function size:0x18 +doNothing__9FlagIndexFUl = .text:0x800BEFB0; // type:function size:0x4 +__ct__9FlagIndexFUsP14FlagDefinition = .text:0x800BEFC0; // type:function size:0xC +prepareIndexShiftMask__9FlagIndexFUsUlPUsPUcPUs = .text:0x800BEFD0; // type:function size:0x80 +maskForIdx__9FlagIndexFUsUs = .text:0x800BF050; // type:function size:0x50 +getCounterOrFlag__9FlagIndexFUsPCUsUl = .text:0x800BF0A0; // type:function size:0x68 +setCounterOrFlag__9FlagIndexFUsPUsUlUl = .text:0x800BF110; // type:function size:0x9C +checkFlagValid__9FlagIndexFUsUl = .text:0x800BF1B0; // type:function size:0x50 checkFlag__17BitwiseFlagHelperFUsUsPCUsUs = .text:0x800BF200; // type:function size:0x14 setFlag__17BitwiseFlagHelperFUsUsPUsUs = .text:0x800BF220; // type:function size:0x20 unsetFlag__17BitwiseFlagHelperFUsUsPUsUs = .text:0x800BF240; // type:function size:0x24 -ItemStoryManagerBase__ctor = .text:0x800BF270; // type:function size:0x28 -fn_800BF2A0 = .text:0x800BF2A0; // type:function size:0x70 -fn_800BF310 = .text:0x800BF310; // type:function size:0xC -setupUnkFlagStuff = .text:0x800BF320; // type:function size:0x60 -StoryflagManager__copyFromSave = .text:0x800BF380; // type:function size:0x58 -ItemStoryManagerBase__init = .text:0x800BF3E0; // type:function size:0x88 -fn_800BF470 = .text:0x800BF470; // type:function size:0x4 -StoryflagManager__getCounterOrFlag = .text:0x800BF480; // type:function size:0x58 -fn_800BF4E0 = .text:0x800BF4E0; // type:function size:0x50 -fn_800BF530 = .text:0x800BF530; // type:function size:0x78 -StoryflagManager__setFlagTo1 = .text:0x800BF5B0; // type:function size:0x8 -StoryflagManager__setFlagTo0 = .text:0x800BF5C0; // type:function size:0x8 -StoryflagManager__setStoryflag = .text:0x800BF5D0; // type:function size:0x4 -getFlag__20ItemStoryManagerBaseCFUs = .text:0x800BF5E0; // type:function size:0x4 -ItemflagManager__getUncommittedFlags = .text:0x800BF5F0; // type:function size:0x4 -fn_800BF600 = .text:0x800BF600; // type:function size:0x4 -fn_800BF610 = .text:0x800BF610; // type:function size:0x18 -fn_800BF630 = .text:0x800BF630; // type:function size:0x4 -fn_800BF640 = .text:0x800BF640; // type:function size:0x10 -fn_800BF650 = .text:0x800BF650; // type:function size:0x40 -fn_800BF690 = .text:0x800BF690; // type:function size:0x4 -StoryflagManager__ctor = .text:0x800BF6A0; // type:function size:0x5C -fn_800BF700 = .text:0x800BF700; // type:function size:0x3C -StoryflagManager__setupUnkFlagstuff = .text:0x800BF740; // type:function size:0x10 -fn_800BF750 = .text:0x800BF750; // type:function size:0x4 -fn_800BF760 = .text:0x800BF760; // type:function size:0x4C -StoryflagManager__setFlagTo02 = .text:0x800BF7B0; // type:function size:0x4 -ItemflagManager__ctor = .text:0x800BF7C0; // type:function size:0x5C -fn_800BF820 = .text:0x800BF820; // type:function size:0x3C -ItemflagManager__setupUnkFlagStuff = .text:0x800BF860; // type:function size:0x10 -fn_800BF870 = .text:0x800BF870; // type:function size:0x4 -fn_800BF880 = .text:0x800BF880; // type:function size:0x4C -copyFromSave__18DungeonflagManagerFUs = .text:0x800BF8D0; // type:function size:0x54 +__ct__20ItemStoryManagerBaseFv = .text:0x800BF270; // type:function size:0x28 +__dt__20ItemStoryManagerBaseFv = .text:0x800BF2A0; // type:function size:0x70 +setFlagSizes__20ItemStoryManagerBaseFUsUs = .text:0x800BF310; // type:function size:0xC +createFlagIndex__20ItemStoryManagerBaseFP14FlagDefinitionUs = .text:0x800BF320; // type:function size:0x60 +copyFromSave__20ItemStoryManagerBaseFv = .text:0x800BF380; // type:function size:0x58 +init__20ItemStoryManagerBaseFv = .text:0x800BF3E0; // type:function size:0x88 +initFlagSpace__20ItemStoryManagerBaseFv = .text:0x800BF470; // type:function size:0x4 +getFlag__20ItemStoryManagerBaseCFUs = .text:0x800BF480; // type:function size:0x58 +getUncommittedValue_Priv__20ItemStoryManagerBaseFUs = .text:0x800BF4E0; // type:function size:0x50 +setOrClearFlag__20ItemStoryManagerBaseFUsUs = .text:0x800BF530; // type:function size:0x78 +setFlag__20ItemStoryManagerBaseFUs = .text:0x800BF5B0; // type:function size:0x8 +unsetFlag__20ItemStoryManagerBaseFUs = .text:0x800BF5C0; // type:function size:0x8 +setFlagOrCounterToValue__20ItemStoryManagerBaseFUsUs = .text:0x800BF5D0; // type:function size:0x4 +getCounterOrFlag__20ItemStoryManagerBaseCFUs = .text:0x800BF5E0; // type:function size:0x4 +getUncommittedValue__20ItemStoryManagerBaseFUs = .text:0x800BF5F0; // type:function size:0x4 +unk3__20ItemStoryManagerBaseFUs = .text:0x800BF600; // type:function size:0x4 +onFlagChange__20ItemStoryManagerBaseFUs = .text:0x800BF610; // type:function size:0x18 +onDirty__20ItemStoryManagerBaseFv = .text:0x800BF630; // type:function size:0x4 +getMaskForFlag__20ItemStoryManagerBaseFUs = .text:0x800BF640; // type:function size:0x10 +doCommit_Priv__20ItemStoryManagerBaseFv = .text:0x800BF650; // type:function size:0x40 +postCommit__20ItemStoryManagerBaseFv = .text:0x800BF690; // type:function size:0x4 +__ct__16StoryflagManagerFv = .text:0x800BF6A0; // type:function size:0x5C +copyFlagsFromSaveFirstTime__16StoryflagManagerFv = .text:0x800BF700; // type:function size:0x3C +setupFlagIndex__16StoryflagManagerFv = .text:0x800BF740; // type:function size:0x10 +onDirty__16StoryflagManagerFv = .text:0x800BF750; // type:function size:0x4 +commit__16StoryflagManagerFv = .text:0x800BF760; // type:function size:0x4C +unsetFlag__16StoryflagManagerFUs = .text:0x800BF7B0; // type:function size:0x4 +__ct__15ItemflagManagerFv = .text:0x800BF7C0; // type:function size:0x5C +copyFlagsFromSaveFirstTime__15ItemflagManagerFv = .text:0x800BF820; // type:function size:0x3C +setupFlagIndex__15ItemflagManagerFv = .text:0x800BF860; // type:function size:0x10 +onDirty__15ItemflagManagerFv = .text:0x800BF870; // type:function size:0x4 +commit__15ItemflagManagerFv = .text:0x800BF880; // type:function size:0x4C +copyFromSave_Internal__18DungeonflagManagerFUs = .text:0x800BF8D0; // type:function size:0x54 setCommitFlag__18DungeonflagManagerFUs = .text:0x800BF930; // type:function size:0xC __ct__18DungeonflagManagerFv = .text:0x800BF940; // type:function size:0x3C -setupFlagStuff__18DungeonflagManagerFv = .text:0x800BF980; // type:function size:0x54 -copyFromSave__18DungeonflagManagerFs = .text:0x800BF9E0; // type:function size:0xC +init__18DungeonflagManagerFv = .text:0x800BF980; // type:function size:0x54 +copyFromSave__18DungeonflagManagerFUl = .text:0x800BF9E0; // type:function size:0xC setToValue__18DungeonflagManagerFUsUl = .text:0x800BF9F0; // type:function size:0x6C setFlag__18DungeonflagManagerFUs = .text:0x800BFA60; // type:function size:0x60 getDungeonFlag__18DungeonflagManagerFUs = .text:0x800BFAC0; // type:function size:0x50 -doCommit__18DungeonflagManagerFv = .text:0x800BFB10; // type:function size:0x8C -copyFromSave__15SkipflagManagerFv = .text:0x800BFBA0; // type:function size:0x44 +commit__18DungeonflagManagerFv = .text:0x800BFB10; // type:function size:0x8C +doCopyFromSave__15SkipflagManagerFv = .text:0x800BFBA0; // type:function size:0x44 setCommitFlag__15SkipflagManagerFUs = .text:0x800BFBF0; // type:function size:0xC __ct__15SkipflagManagerFv = .text:0x800BFC00; // type:function size:0x2C -unsetCommitFlag__15SkipflagManagerFv = .text:0x800BFC30; // type:function size:0xC -thunk_copyFromSave__15SkipflagManagerFv = .text:0x800BFC40; // type:function size:0x4 +init__15SkipflagManagerFv = .text:0x800BFC30; // type:function size:0xC +copyFromSave__15SkipflagManagerFv = .text:0x800BFC40; // type:function size:0x4 setFlag__15SkipflagManagerFUs = .text:0x800BFC50; // type:function size:0xD0 checkFlag__15SkipflagManagerFUs = .text:0x800BFD20; // type:function size:0x68 -commitFlags__15SkipflagManagerFv = .text:0x800BFD90; // type:function size:0x70 -setupFlagManagers = .text:0x800BFE00; // type:function size:0x294 -__dt__15TBoxFlagManagerFv = .text:0x800C00A0; // type:function size:0x40 -__dt__18EnemyDefeatManagerFv = .text:0x800C00E0; // type:function size:0x40 -StoryflagManager__dtor = .text:0x800C0120; // type:function size:0x58 -fn_800C0180 = .text:0x800C0180; // type:function size:0x58 -fn_800C01E0 = .text:0x800C01E0; // type:function size:0x8 -copyAllFlagmanagersFromSave = .text:0x800C01F0; // type:function size:0x78 -updateFlagForFlagindex = .text:0x800C0270; // type:function size:0x58 -commitAllFlagManagers = .text:0x800C02D0; // type:function size:0x54 -checkedMemcpy = .text:0x800C0330; // type:function size:0x54 -getItemFlags = .text:0x800C0390; // type:function size:0x8 -fn_800C03A0 = .text:0x800C03A0; // type:function size:0x8 -fn_800C03B0 = .text:0x800C03B0; // type:function size:0x8 -StoryflagManager__getStoryflag = .text:0x800C03C0; // type:function size:0x8 -ItemflagManager__setToValue = .text:0x800C03D0; // type:function size:0x8 -fn_800C03E0 = .text:0x800C03E0; // type:function size:0x8 -fn_800C03F0 = .text:0x800C03F0; // type:function size:0x44 -ItemStoryManagerBase__setFlagSpacePtr = .text:0x800C0440; // type:function size:0xC -getStoryFlagsSpacePtr = .text:0x800C0450; // type:function size:0x8 -StoryflagManager__doCommit = .text:0x800C0460; // type:function size:0x44 -StoryflagManager__setFlagsPtr = .text:0x800C04B0; // type:function size:0xC -EnemyDefeatFlagManager__doCommit = .text:0x800C04C0; // type:function size:0x44 -fn_800C0510 = .text:0x800C0510; // type:function size:0x5C -fn_800C0570 = .text:0x800C0570; // type:function size:0x5C -fn_800C05D0 = .text:0x800C05D0; // type:function size:0x40 -fn_800C0610 = .text:0x800C0610; // type:function size:0x40 +commit__15SkipflagManagerFv = .text:0x800BFD90; // type:function size:0x70 +setupFlagManagers__FPQ23EGG4Heap = .text:0x800BFE00; // type:function size:0x294 +__dt__15TBoxflagManagerFv = .text:0x800C00A0; // type:function size:0x40 +__dt__16EnemyflagManagerFv = .text:0x800C00E0; // type:function size:0x40 +__dt__16StoryflagManagerFv = .text:0x800C0120; // type:function size:0x58 +__dt__15ItemflagManagerFv = .text:0x800C0180; // type:function size:0x58 +postSetup__Fv = .text:0x800C01E0; // type:function size:0x8 +copyAllFlagManagersFromSave__Fv = .text:0x800C01F0; // type:function size:0x78 +updateFlagForFlagIndex__FUs = .text:0x800C0270; // type:function size:0x58 +commitAllFlagManagers__Fv = .text:0x800C02D0; // type:function size:0x54 +checkedMemcpy__FPvUlPCvUl = .text:0x800C0330; // type:function size:0x54 +getSaveFlagSpace__15ItemflagManagerCFv = .text:0x800C0390; // type:function size:0x8 +unk3__15ItemflagManagerFUs = .text:0x800C03A0; // type:function size:0x8 +getUncommittedValue__15ItemflagManagerFUs = .text:0x800C03B0; // type:function size:0x8 +getCounterOrFlag__15ItemflagManagerCFUs = .text:0x800C03C0; // type:function size:0x8 +setFlagOrCounterToValue__15ItemflagManagerFUsUs = .text:0x800C03D0; // type:function size:0x8 +unsetFlag__15ItemflagManagerFUs = .text:0x800C03E0; // type:function size:0x8 +doCommit__15ItemflagManagerFv = .text:0x800C03F0; // type:function size:0x44 +initFlagSpace__15ItemflagManagerFv = .text:0x800C0440; // type:function size:0xC +getSaveFlagSpace__16StoryflagManagerCFv = .text:0x800C0450; // type:function size:0x8 +doCommit__16StoryflagManagerFv = .text:0x800C0460; // type:function size:0x44 +initFlagSpace__16StoryflagManagerFv = .text:0x800C04B0; // type:function size:0xC +doCommit__16EnemyflagManagerFv = .text:0x800C04C0; // type:function size:0x44 +__dt__32MyFlagManager<15ItemflagManager>Fv = .text:0x800C0510; // type:function size:0x5C +__dt__33MyFlagManager<16StoryflagManager>Fv = .text:0x800C0570; // type:function size:0x5C +__dt__33MyFlagManager<16EnemyflagManager>Fv = .text:0x800C05D0; // type:function size:0x40 +__dt__32MyFlagManager<15TBoxflagManager>Fv = .text:0x800C0610; // type:function size:0x40 fn_800C0650 = .text:0x800C0650; // type:function size:0x3C fn_800C0690 = .text:0x800C0690; // type:function size:0x70 fn_800C0700 = .text:0x800C0700; // type:function size:0x7C @@ -9210,11 +9210,11 @@ executeState__86sStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c,12sFState getStateID__86sStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801685C0; // type:function size:0x10 addToDrawList__17dLytCommonArrow_cFv = .text:0x801685D0; // type:function size:0x34 setState__17dLytCommonArrow_cFl = .text:0x80168610; // type:function size:0x24 -fn_80168640__17dLytCommonArrow_cFPf = .text:0x80168640; // type:function size:0x34 -fn_80168680__17dLytCommonArrow_cFv = .text:0x80168680; // type:function size:0x70 -fn_801686F0__17dLytCommonArrow_cFv = .text:0x801686F0; // type:function size:0x70 +setTranslate__17dLytCommonArrow_cFPC3Vec = .text:0x80168640; // type:function size:0x34 +requestIn__17dLytCommonArrow_cFv = .text:0x80168680; // type:function size:0x70 +requestOut__17dLytCommonArrow_cFv = .text:0x801686F0; // type:function size:0x70 fn_80168760__17dLytCommonArrow_cFv = .text:0x80168760; // type:function size:0x2C -fn_80168790__17dLytCommonArrow_cFlf = .text:0x80168790; // type:function size:0x68 +displayElement__17dLytCommonArrow_cFlf = .text:0x80168790; // type:function size:0x68 fn_80168800__17dLytCommonArrow_cFl = .text:0x80168800; // type:function size:0x10 fn_80168810__17dLytCommonArrow_cFPQ23d2d10AnmGroup_c = .text:0x80168810; // type:function size:0x64 fn_80168880__17dLytCommonArrow_cFv = .text:0x80168880; // type:function size:0xC4 @@ -31008,15 +31008,15 @@ lbl_80510B48 = .data:0x80510B48; // type:object size:0xC lbl_80510B54 = .data:0x80510B54; // type:object size:0xC lbl_80510B60 = .data:0x80510B60; // type:object size:0x10 lbl_80510B70 = .data:0x80510B70; // type:object size:0x18 -ItemflagManager__vtable = .data:0x80510B88; // type:object size:0x3C -StoryflagManager__vtable = .data:0x80510BC4; // type:object size:0x3C -lbl_80510C00 = .data:0x80510C00; // type:object size:0x14 -lbl_80510C14 = .data:0x80510C14; // type:object size:0x14 -ItemflagManager__vtableBase = .data:0x80510C28; // type:object size:0x3C -StoryflagManager__vtableBase = .data:0x80510C64; // type:object size:0x3C -ItemStoryManagerBase__vtable = .data:0x80510CA0; // type:object size:0x3C -__vt__18EnemyDefeatManager = .data:0x80510CDC; // type:object size:0x14 -__vt__15TBoxFlagManager = .data:0x80510CF0; // type:object size:0x14 +__vt__32MyFlagManager<15ItemflagManager> = .data:0x80510B88; // type:object size:0x3C +__vt__33MyFlagManager<16StoryflagManager> = .data:0x80510BC4; // type:object size:0x3C +__vt__33MyFlagManager<16EnemyflagManager> = .data:0x80510C00; // type:object size:0x14 +__vt__32MyFlagManager<15TBoxflagManager> = .data:0x80510C14; // type:object size:0x14 +__vt__15ItemflagManager = .data:0x80510C28; // type:object size:0x3C +__vt__16StoryflagManager = .data:0x80510C64; // type:object size:0x3C +__vt__20ItemStoryManagerBase = .data:0x80510CA0; // type:object size:0x3C +__vt__16EnemyflagManager = .data:0x80510CDC; // type:object size:0x14 +__vt__15TBoxflagManager = .data:0x80510CF0; // type:object size:0x14 __vt__9FlagSpace = .data:0x80510D04; // type:object size:0xC lbl_80510D10 = .data:0x80510D10; // type:object size:0x38 data:4byte lbl_80510D48 = .data:0x80510D48; // type:object size:0x18 @@ -33250,18 +33250,18 @@ lbl_80527260 = .data:0x80527260; // type:object size:0x14 lbl_80527274 = .data:0x80527274; // type:object size:0x14 lbl_80527288 = .data:0x80527288; // type:object size:0x10 lbl_80527298 = .data:0x80527298; // type:object size:0x18 data:string -lbl_805272B0 = .data:0x805272B0; // type:object size:0xC -lbl_805272BC = .data:0x805272BC; // type:object size:0x1C -lbl_805272D8 = .data:0x805272D8; // type:object size:0xC -lbl_805272E4 = .data:0x805272E4; // type:object size:0x1C -lbl_80527300 = .data:0x80527300; // type:object size:0xC -lbl_8052730C = .data:0x8052730C; // type:object size:0x1C +lbl_805272B0 = .data:0x805272B0; // type:object size:0xB data:string +lbl_805272BC = .data:0x805272BC; // type:object size:0x1A data:string +lbl_805272D8 = .data:0x805272D8; // type:object size:0xA data:string +lbl_805272E4 = .data:0x805272E4; // type:object size:0x1A data:string +lbl_80527300 = .data:0x80527300; // type:object size:0xA data:string +lbl_8052730C = .data:0x8052730C; // type:object size:0x1B data:string lbl_80527328 = .data:0x80527328; // type:object size:0xC data:string lbl_80527334 = .data:0x80527334; // type:object size:0xC data:string lbl_80527340 = .data:0x80527340; // type:object size:0x1C data:string -lbl_8052735C = .data:0x8052735C; // type:object size:0x1C -lbl_80527378 = .data:0x80527378; // type:object size:0xC -lbl_80527384 = .data:0x80527384; // type:object size:0x58 +lbl_8052735C = .data:0x8052735C; // type:object size:0x1B data:string +lbl_80527378 = .data:0x80527378; // type:object size:0xB data:string +lbl_80527384 = .data:0x80527384; // type:object size:0x19 data:string __vt__17dLytCommonArrow_c = .data:0x805273DC; // type:object size:0xC __vt__56sFStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c> = .data:0x805273E8; // type:object size:0x30 __vt__86sStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x80527418; // type:object size:0x30 @@ -38204,7 +38204,7 @@ lbl_805729C0 = .sdata:0x805729C0; // type:object size:0x4 data:4byte lbl_805729C4 = .sdata:0x805729C4; // type:object size:0x4 lbl_805729C8 = .sdata:0x805729C8; // type:object size:0x4 data:4byte lbl_805729CC = .sdata:0x805729CC; // type:object size:0x4 -lbl_805729D0 = .sdata:0x805729D0; // type:object size:0x8 +lbl_805729D0 = .sdata:0x805729D0; // type:object size:0x1 lbl_805729D8 = .sdata:0x805729D8; // type:object size:0x4 lbl_805729DC = .sdata:0x805729DC; // type:object size:0x4 lbl_805729E0 = .sdata:0x805729E0; // type:object size:0x8 data:string @@ -39942,12 +39942,12 @@ NAND_REQUEST_THREAD = .sbss:0x805753D0; // type:object size:0x8 data:4byte lbl_805753D8 = .sbss:0x805753D8; // type:object size:0x8 data:4byte sInstance__16SceneflagManager = .sbss:0x805753E0; // type:object size:0x4 data:4byte sTempFlags__16SceneflagManager = .sbss:0x805753E8; // type:object size:0x8 -sInstance__15TBoxFlagManager = .sbss:0x805753F0; // type:object size:0x4 data:4byte -sTBoxFlags__15TBoxFlagManager = .sbss:0x805753F4; // type:object size:0x4 -sInstance__18EnemyDefeatManager = .sbss:0x805753F8; // type:object size:0x4 data:4byte +sInstance__15TBoxflagManager = .sbss:0x805753F0; // type:object size:0x4 data:4byte +sTBoxFlags__15TBoxflagManager = .sbss:0x805753F4; // type:object size:0x4 +sInstance__16EnemyflagManager = .sbss:0x805753F8; // type:object size:0x4 data:4byte sInstance__16StoryflagManager = .sbss:0x805753FC; // type:object size:0x4 data:4byte sInstance__15ItemflagManager = .sbss:0x80575400; // type:object size:0x4 data:4byte -DUNGEONFLAG_MANAGER = .sbss:0x80575404; // type:object size:0x4 data:4byte +sInstance__18DungeonflagManager = .sbss:0x80575404; // type:object size:0x4 data:4byte sInstance__15SkipflagManager = .sbss:0x80575408; // type:object size:0x4 data:4byte lbl_80575410 = .sbss:0x80575410; // type:object size:0x8 data:4byte lbl_80575418 = .sbss:0x80575418; // type:object size:0x8 @@ -48330,11 +48330,11 @@ FontColors1 = .bss:0x805A7730; // type:object size:0xC4 data:byte FontColors2 = .bss:0x805A77F4; // type:object size:0xC4 data:byte lbl_805A78B8 = .bss:0x805A78B8; // type:object size:0xC TIMESHIFT_STONE_REFS = .bss:0x805A78C4; // type:object size:0xC data:4byte -STATIC_SCENEFLAGS = .bss:0x805A78D0; // type:object size:0x10 -STATIC_ZONE_FLAGS = .bss:0x805A78E0; // type:object size:0x1F8 -sEnemyDefeatFlags__18EnemyDefeatManager = .bss:0x805A7AD8; // type:object size:0x2000 -STATIC_STORYFLAGS = .bss:0x805A9AD8; // type:object size:0x100 -STATIC_ITEM_FLAGS = .bss:0x805A9BD8; // type:object size:0x80 +sSceneFlags__16SceneflagManager = .bss:0x805A78D0; // type:object size:0x10 +sZoneFlags__16SceneflagManager = .bss:0x805A78E0; // type:object size:0x1F8 +sEnemyDefeatFlags__16EnemyflagManager = .bss:0x805A7AD8; // type:object size:0x2000 +sFlags__16StoryflagManager = .bss:0x805A9AD8; // type:object size:0x100 +sFlags__15ItemflagManager = .bss:0x805A9BD8; // type:object size:0x80 sDungeonFlags__18DungeonflagManager = .bss:0x805A9C58; // type:object size:0x10 sSkipFlags__15SkipflagManager = .bss:0x805A9C68; // type:object size:0x20 lbl_805A9C88 = .bss:0x805A9C88; // type:object size:0x10 data:4byte @@ -48761,7 +48761,7 @@ LytSaveMsgWindow__STATE_INIT = .bss:0x805B1BC0; // type:object size:0x40 data:4b LytSaveMsgWindow__STATE_IN = .bss:0x805B1C00; // type:object size:0x40 data:4byte LytSaveMsgWindow__STATE_WAIT = .bss:0x805B1C40; // type:object size:0x40 data:4byte LytSaveMsgWindow__STATE_OUT = .bss:0x805B1C80; // type:object size:0x30 data:4byte -lbl_805B1CB0 = .bss:0x805B1CB0; // type:object size:0x10 +lbl_805B1CB0 = .bss:0x805B1CB0; // type:object size:0xC StateID_None__17dLytCommonArrow_c = .bss:0x805B1CC0; // type:object size:0x30 data:4byte StateID_In__17dLytCommonArrow_c = .bss:0x805B1D00; // type:object size:0x30 data:4byte StateID_Wait__17dLytCommonArrow_c = .bss:0x805B1D40; // type:object size:0x30 data:4byte diff --git a/configure.py b/configure.py index d9a6566f..eb6b5dde 100644 --- a/configure.py +++ b/configure.py @@ -321,13 +321,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): "progress_category": "game", "host": False, "objects": [ - Object(Matching, "toBeSorted/unk_flag_stuff.cpp"), - Object(Matching, "toBeSorted/bitwise_flag_helper.cpp"), - Object(Matching, "toBeSorted/sceneflag_manager.cpp"), - Object(NonMatching, "toBeSorted/flag_space.cpp"), - Object(NonMatching, "toBeSorted/misc_flag_managers.cpp"), - Object(Matching, "toBeSorted/dungeonflag_manager.cpp"), - Object(Matching, "toBeSorted/skipflag_manager.cpp"), + Object(Matching, "d/flag/flag_managers.cpp"), Object(NonMatching, "toBeSorted/special_item_drop_mgr.cpp"), Object(Matching, "d/d_base.cpp"), Object(Matching, "d/d_dvd.cpp"), @@ -421,7 +415,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Object(Matching, "d/lyt/d_screen_fader.cpp"), Object(NonMatching, "d/d_cs_base.cpp"), Object(NonMatching, "d/d_cs_game.cpp"), - Object(NonMatching, "d/lyt/d_lyt_common_arrow.cpp"), + Object(Matching, "d/lyt/d_lyt_common_arrow.cpp"), Object(NonMatching, "toBeSorted/file_manager.cpp"), Object(NonMatching, "toBeSorted/save_manager.cpp"), Object(Matching, "DynamicLink.cpp"), @@ -1434,7 +1428,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Rel(NonMatching, "d_a_obj_into_hole", "REL/d/a/obj/d_a_obj_into_hole.cpp"), Rel(NonMatching, "d_a_obj_iron_stage", "REL/d/a/obj/d_a_obj_iron_stage.cpp"), Rel(NonMatching, "d_a_obj_island_LOD", "REL/d/a/obj/d_a_obj_island_LOD.cpp"), - Rel(NonMatching, "d_a_obj_island_nusi", "REL/d/a/obj/d_a_obj_island_nusi.cpp"), + Rel(Matching, "d_a_obj_island_nusi", "REL/d/a/obj/d_a_obj_island_nusi.cpp"), Rel( NonMatching, "d_a_obj_item_heart_container", diff --git a/include/d/a/obj/d_a_obj_island_nusi.h b/include/d/a/obj/d_a_obj_island_nusi.h index 4ef59671..29b139f7 100644 --- a/include/d/a/obj/d_a_obj_island_nusi.h +++ b/include/d/a/obj/d_a_obj_island_nusi.h @@ -2,6 +2,9 @@ #define D_A_OBJ_ISLAND_NUSI_H #include "d/a/obj/d_a_obj_base.h" +#include "d/col/bg/d_bg_w.h" +#include "m/m3d/m_smdl.h" +#include "nw4r/g3d/g3d_resfile.h" #include "s/s_State.hpp" #include "s/s_StateMgr.hpp" @@ -10,11 +13,24 @@ class dAcOislandNusi_c : public dAcObjBase_c { dAcOislandNusi_c() : mStateMgr(*this, sStateID::null) {} virtual ~dAcOislandNusi_c() {} + virtual bool createHeap() override; + virtual int create() override; + virtual int doDelete() override; + virtual int actorExecute() override; + virtual int draw() override; + STATE_FUNC_DECLARE(dAcOislandNusi_c, Wait); STATE_FUNC_DECLARE(dAcOislandNusi_c, NusiFight); private: - /* 0x??? */ STATE_MGR_DECLARE(dAcOislandNusi_c); + static const f32 someFloat; + + bool isInLeviasFight() const; + + /* 0x330 */ m3d::smdl_c mMdls[2]; + /* 0x360 */ nw4r::g3d::ResFile mRes; + /* 0x36C */ dBgW mBgW; + /* 0x57C */ STATE_MGR_DECLARE(dAcOislandNusi_c); }; #endif diff --git a/include/d/d_cs_base.h b/include/d/d_cs_base.h index c3aa6346..2d75ce27 100644 --- a/include/d/d_cs_base.h +++ b/include/d/d_cs_base.h @@ -1,6 +1,7 @@ #ifndef D_C_BASE_H #define D_C_BASE_H +#include "common.h" #include "d/d_cs.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_cursor_stick.h" @@ -25,6 +26,10 @@ class dCsBase_c : public dCs_c { field_0x703 = val; } + d2d::dLytStructD *getUnk() { + return mStructC.field_0x14; + } + private: static int sfield0x700Init; void setCurrentLyt(int lyt); diff --git a/include/d/flag/baseflag_manager.h b/include/d/flag/baseflag_manager.h new file mode 100644 index 00000000..c30236f4 --- /dev/null +++ b/include/d/flag/baseflag_manager.h @@ -0,0 +1,49 @@ +#ifndef D_FLAG_BASEFLAG_MANAGER_H +#define D_FLAG_BASEFLAG_MANAGER_H + +#include "d/flag/flag_index.h" +#include "d/flag/flag_space.h" + +class ItemStoryManagerBase { +public: + ItemStoryManagerBase(); + + /** 0x08 */ virtual ~ItemStoryManagerBase(); + /** 0x0C */ virtual void initFlagSpace(); + /** 0x10 */ virtual void onDirty(); + /** 0x14 */ virtual void copyFlagsFromSaveFirstTime() = 0; + /** 0x18 */ virtual void setupFlagIndex() = 0; + /** 0x1C */ virtual void doCommit() = 0; + /** 0x20 */ virtual void setFlag(u16 flag); + /** 0x24 */ virtual void unsetFlag(u16 flag); + /** 0x28 */ virtual void setFlagOrCounterToValue(u16 flag, u16 value); + /** 0x2C */ virtual u16 getCounterOrFlag(u16 flag) const; + /** 0x30 */ virtual u16 getUncommittedValue(u16 flag); + /** 0x34 */ virtual u16 unk3(u16 arg); + /** 0x38 */ virtual const u16 *getSaveFlagSpace() const = 0; + + + void init(); + void copyFromSave(); + void createFlagIndex(FlagDefinition *def, u16 count); + void doCommit_Priv(); + void setOrClearFlag(u16 flag, u16 value); + u16 getFlag(u16 flag) const; + void onFlagChange(u16 flag); + u16 getMaskForFlag(u16 flag); + void postCommit(); + + u16 getUncommittedValue_Priv(u16 flag); + +protected: + + void setFlagSizes(u16 flagCount, u16 flagSizeBytes); + + /** 0x04 */ u16 mFlagCount; + /** 0x06 */ u16 mFlagSizeBytes; + /** 0x08 */ FlagSpace *mpFlagSpace; + /** 0x0C */ FlagIndex *mpFlagIndex; + /** 0x10 */ bool mDirty; +}; + +#endif diff --git a/include/toBeSorted/bitwise_flag_helper.h b/include/d/flag/bitwise_flag_helper.h similarity index 100% rename from include/toBeSorted/bitwise_flag_helper.h rename to include/d/flag/bitwise_flag_helper.h diff --git a/include/d/flag/committable_flag_manager.h b/include/d/flag/committable_flag_manager.h new file mode 100644 index 00000000..e709d518 --- /dev/null +++ b/include/d/flag/committable_flag_manager.h @@ -0,0 +1,23 @@ +#ifndef D_FLAG_COMMITTABLE_FLAG_MANAGER_H +#define D_FLAG_COMMITTABLE_FLAG_MANAGER_H + +class CommittableFlagManager { +public: + bool mNeedsCommit; + + virtual void doCommit() = 0; + virtual ~CommittableFlagManager() {} + bool commit(); + void setNeedsCommit(bool commit) { + mNeedsCommit = commit; + } + CommittableFlagManager() { + mNeedsCommit = false; + } + CommittableFlagManager(bool commit) { + mNeedsCommit = commit; + } +}; + + +#endif diff --git a/include/d/flag/dungeonflag_manager.h b/include/d/flag/dungeonflag_manager.h new file mode 100644 index 00000000..55dfa150 --- /dev/null +++ b/include/d/flag/dungeonflag_manager.h @@ -0,0 +1,36 @@ +#ifndef D_FLAG_DUNGEONFLAG_MANAGER_H +#define D_FLAG_DUNGEONFLAG_MANAGER_H + +#include "d/flag/flag_index.h" +#include "d/flag/flag_space.h" +#include "toBeSorted/file_manager.h" + +class DungeonflagManager { +public: + bool mShouldCommit; + u16 mStageIndex; + FlagIndex *mpFlagIndex; + FlagSpace mFlagSpace; + + static u16 sDungeonFlags[8]; + + void copyFromSave(u32 flag); + void copyFromSave_Internal(u16 flagIndex); + void setCommitFlag(u16 flag); + DungeonflagManager(); + void init(); + void setToValue(u16 flag, u32 value); + void setFlag(u16 flag); + u16 getDungeonFlag(u16 flag); + bool commit(); + + /** inline shenanigans to get copyFromSave to match */ + static inline u16 *saveFilePtr(u16 flagIndex) { + u32 offset = (flagIndex & 0x1fff) * 8; + return FileManager::sInstance->getDungeonFlagsConst() + offset; + } + + static DungeonflagManager *sInstance; +}; + +#endif diff --git a/include/d/flag/enemyflag_manager.h b/include/d/flag/enemyflag_manager.h new file mode 100644 index 00000000..1bfe3a62 --- /dev/null +++ b/include/d/flag/enemyflag_manager.h @@ -0,0 +1,41 @@ +#ifndef D_FLAG_ENEMYFLAG_MANAGER_H +#define D_FLAG_ENEMYFLAG_MANAGER_H + +#include "d/flag/bitwise_flag_helper.h" +#include "d/flag/committable_flag_manager.h" +#include "d/flag/flag_space.h" +#include "toBeSorted/file_manager.h" + +class EnemyflagManager : public CommittableFlagManager { +public: + FlagSpace mFlagSpace; + BitwiseFlagHelper mFlagHelper; + u16 mSceneIndex; + + static u16 sEnemyDefeatFlags[4096]; + + static EnemyflagManager *sInstance; + + void clearSavedFlags(); + bool checkUncommittedFlag(u16 flag); + u16 checkUncommittedFlag2(u16 flag) { + return checkUncommittedFlag(flag); + } + EnemyflagManager(); + void init(); + void copyFromSave(u16 sceneIndex); + void updateFlagIndex(u16 sceneIndex); + void clearAll(); + bool checkIsValidFlag(u16 flag); + bool checkFlag(u16 flag); + virtual ~EnemyflagManager() {} + virtual u16 getFlagCount() const; + void setFlag(u16 flag); + + virtual void doCommit() override { + FileManager *mgr = FileManager::sInstance; + mgr->setEnemyDefeatFlags(mFlagSpace.getFlagPtrUnchecked(), 0, 0x1000); + }; +}; + +#endif diff --git a/include/d/flag/flag_index.h b/include/d/flag/flag_index.h new file mode 100644 index 00000000..f4f98d34 --- /dev/null +++ b/include/d/flag/flag_index.h @@ -0,0 +1,37 @@ +#ifndef D_FLAG_FLAG_INDEX_H +#define D_FLAG_FLAG_INDEX_H + +#include "common.h" + +/** + * @brief Defines a single story or item flag. + */ +struct FlagDefinition { + u8 mIndex; + u8 mShiftMask; +}; + +/** + * @brief Helper class for packing and unpacking flag data. + * + * Some flag managers store their data in a packed format, where + * flags have a variable number of bits and can appear in varied + * locations within a halfword. + */ +class FlagIndex { + u16 mDefinitionsCount; + FlagDefinition *mpDefinitions; + +public: + u16 calculateMask(s32 shift); + void doNothing(u32 unused); + FlagIndex(u16 count, FlagDefinition *definitions); + void prepareIndexShiftMask(u16 counterIdx, u32 flagCount, u16 *pIndex, u8 *pShift, u16 *pMask); + u16 maskForIdx(u16 index, u16 flagCount); + u16 getCounterOrFlag(u16 counterIdx, const u16 *pData, u32 flagCount); + void setCounterOrFlag(u16 counterIdx, u16 *pData, u32 flagCount, u32 value); + + u32 checkFlagValid(u16 counterIdx, u32 flagCount); +}; + +#endif diff --git a/include/d/flag/flag_managers.h b/include/d/flag/flag_managers.h new file mode 100644 index 00000000..e834dfbf --- /dev/null +++ b/include/d/flag/flag_managers.h @@ -0,0 +1,13 @@ +#ifndef D_FLAG_FLAG_MANAGERS_H +#define D_FLAG_FLAG_MANAGERS_H + +#include "egg/core/eggHeap.h" + +void setupFlagManagers(EGG::Heap *heap); +void copyAllFlagManagersFromSave(); +void updateFlagForFlagIndex(u16 stage); +void commitAllFlagManagers(); + +bool checkedMemcpy(void *dest, u32 destLen, const void *src, u32 count); + +#endif diff --git a/include/toBeSorted/flag_space.h b/include/d/flag/flag_space.h similarity index 65% rename from include/toBeSorted/flag_space.h rename to include/d/flag/flag_space.h index a59ae3f3..bcc47c19 100644 --- a/include/toBeSorted/flag_space.h +++ b/include/d/flag/flag_space.h @@ -16,13 +16,13 @@ class FlagSpace : public BaseFlagSpace { mCount = count; } FlagSpace(u16 *pFlags, u16 count) : BaseFlagSpace(pFlags, count) {} - u16 *getFlagPtrChecked(); - u16 *getFlagPtrUnchecked(); + u16 *getFlagPtrChecked() const; + u16 *getFlagPtrUnchecked() const; void unsetAll(); void setAllToZero(u16 offset, u16 flagCount); - void copyFromSaveFile2(u16 *pSaved, u16 offset, u16 flagCount); - void copyFromSaveFile(u16 *pSaved, u16 offset, u16 flagCount); - virtual void filemanagerCheck(); + void copyFromSaveFile2(const u16 *pSaved, u16 offset, u16 flagCount); + void copyFromSaveFile(const u16 *pSaved, u16 offset, u16 flagCount); + virtual void filemanagerCheck() const; }; #endif diff --git a/include/d/flag/itemflag_manager.h b/include/d/flag/itemflag_manager.h new file mode 100644 index 00000000..e6561302 --- /dev/null +++ b/include/d/flag/itemflag_manager.h @@ -0,0 +1,60 @@ + +#ifndef D_FLAG_ITEMFLAG_MANAGER_H +#define D_FLAG_ITEMFLAG_MANAGER_H + +#include "d/flag/baseflag_manager.h" +#include "toBeSorted/file_manager.h" + + +class ItemflagManager : public ItemStoryManagerBase { +public: + FlagSpace mItemFlags; + + ItemflagManager(); + virtual ~ItemflagManager() {} + + bool commit(); + + /** 0x0C */ virtual void initFlagSpace() override { + mpFlagSpace = &mItemFlags; + } + /** 0x10 */ virtual void onDirty() override; + /** 0x14 */ virtual void copyFlagsFromSaveFirstTime(); + /** 0x18 */ virtual void setupFlagIndex(); + /** 0x1C */ virtual void doCommit() { + u16 sz = mFlagCount; + u16 *flags = mpFlagSpace->getFlagPtrUnchecked(); + FileManager::sInstance->setItemFlags(flags, 0, sz); + } + /** 0x20 */ virtual void setFlag(u16 flag) { + ItemStoryManagerBase::setFlag(flag & ~0x4000); + } + /** 0x24 */ virtual void unsetFlag(u16 flag) { + ItemStoryManagerBase::unsetFlag(flag & ~0x4000); + } + /** 0x28 */ virtual void setFlagOrCounterToValue(u16 flag, u16 value) { + ItemStoryManagerBase::setFlagOrCounterToValue(flag & ~0x4000, value); + } + /** 0x2C */ virtual u16 getCounterOrFlag(u16 flag) const { + return ItemStoryManagerBase::getCounterOrFlag(flag & ~0x4000); + } + /** 0x30 */ virtual u16 getUncommittedValue(u16 flag) { + return ItemStoryManagerBase::getUncommittedValue(flag & ~0x4000); + } + /** 0x34 */ virtual u16 unk3(u16 arg) { + return ItemStoryManagerBase::unk3(arg & ~0x4000); + } + /** 0x38 */ virtual const u16 *getSaveFlagSpace() const { + return FileManager::sInstance->getItemFlagsConst(); + }; + + u16 getFlagDirect(u16 flag) { + return ItemStoryManagerBase::getCounterOrFlag(flag); + } + +public: + static ItemflagManager *sInstance; + static u16 sFlags[0x40]; +}; + +#endif diff --git a/include/toBeSorted/sceneflag_manager.h b/include/d/flag/sceneflag_manager.h similarity index 94% rename from include/toBeSorted/sceneflag_manager.h rename to include/d/flag/sceneflag_manager.h index 047581eb..d1c8d98f 100644 --- a/include/toBeSorted/sceneflag_manager.h +++ b/include/d/flag/sceneflag_manager.h @@ -2,8 +2,8 @@ #define SCENEFLAG_MANAGER_H #include "common.h" -#include "toBeSorted/bitwise_flag_helper.h" -#include "toBeSorted/flag_space.h" +#include "d/flag/bitwise_flag_helper.h" +#include "d/flag/flag_space.h" class SceneflagManager { @@ -20,7 +20,7 @@ class SceneflagManager { static u16 sZoneFlags[0xFC]; static SceneflagManager *sInstance; - void doNothing(); + void init(); void setShouldCommit(u16 flag); SceneflagManager(); s32 isNotTempOrZoneFlag(u16 flag); @@ -58,7 +58,7 @@ class SceneflagManager { void unsetFlag(u16 roomId, u16 flag); void unsetSceneflagGlobal(u16 sceneIdx, u16 flag); void unsetTempOrSceneflag(u16 flag); - s32 doCommit(); + s32 commit(); bool checkBoolFlag(u16 roomid, u16 flag) { return checkFlag(roomid, flag); diff --git a/include/d/flag/skipflag_manager.h b/include/d/flag/skipflag_manager.h new file mode 100644 index 00000000..c0cbc926 --- /dev/null +++ b/include/d/flag/skipflag_manager.h @@ -0,0 +1,30 @@ +#ifndef D_FLAG_SKIPFLAG_MANAGER_H +#define D_FLAG_SKIPFLAG_MANAGER_H + + +#include "d/flag/bitwise_flag_helper.h" +#include "d/flag/flag_space.h" + +class SkipflagManager { +public: + SkipflagManager(); + void init(); + + void setCommitFlag(u16 flag); + void copyFromSave(); + void setFlag(u16 flag); + bool checkFlag(u16 flag); + bool commit(); + static SkipflagManager *sInstance; + +private: + void doCopyFromSave(); + + static u16 sSkipFlags[16]; + + bool mShouldCommit; + BitwiseFlagHelper mFlagHelper; + FlagSpace mFlagSpace; +}; + +#endif diff --git a/include/d/flag/storyflag_manager.h b/include/d/flag/storyflag_manager.h new file mode 100644 index 00000000..66639005 --- /dev/null +++ b/include/d/flag/storyflag_manager.h @@ -0,0 +1,38 @@ +#ifndef D_FLAG_STORYFLAG_MANAGER_H +#define D_FLAG_STORYFLAG_MANAGER_H + +#include "d/flag/baseflag_manager.h" +#include "toBeSorted/file_manager.h" + +class StoryflagManager : public ItemStoryManagerBase { +public: + StoryflagManager(); + + virtual ~StoryflagManager() {} + + FlagSpace mStoryFlags; + + bool commit(); + + /** 0x0C */ virtual void initFlagSpace() override { + mpFlagSpace = &mStoryFlags; + } + /** 0x10 */ virtual void onDirty() override; + /** 0x14 */ virtual void copyFlagsFromSaveFirstTime() override; + /** 0x18 */ virtual void setupFlagIndex() override; + /** 0x1C */ virtual void doCommit() override { + u16 sz = mFlagCount; + u16 *flags = mpFlagSpace->getFlagPtrUnchecked(); + FileManager::sInstance->setStoryFlags(flags, 0, sz); + } + /** 0x24 */ virtual void unsetFlag(u16 flag) override; + /** 0x38 */ virtual const u16 *getSaveFlagSpace() const override { + return FileManager::sInstance->getStoryFlagsConst(); + }; + +public: + static StoryflagManager *sInstance; + static u16 sFlags[0x80]; +}; + +#endif diff --git a/include/d/flag/tboxflag_manager.h b/include/d/flag/tboxflag_manager.h new file mode 100644 index 00000000..a675b789 --- /dev/null +++ b/include/d/flag/tboxflag_manager.h @@ -0,0 +1,33 @@ +#ifndef D_FLAG_TBOXFLAG_MANAGER_H +#define D_FLAG_TBOXFLAG_MANAGER_H + +#include "d/flag/bitwise_flag_helper.h" +#include "d/flag/committable_flag_manager.h" +#include "d/flag/flag_space.h" + +class TBoxflagManager : public CommittableFlagManager { +public: + FlagSpace mFlagSpace; + u16 mSceneIndex; + BitwiseFlagHelper mFlagHelper; + + static u16 sTBoxFlags[2]; + + static TBoxflagManager *sInstance; + + virtual void doCommit() override; + bool checkUncommittedFlag(u16 flag); + TBoxflagManager(); + virtual ~TBoxflagManager() {} + void init(); + void copyFromSave(u32 sceneIndex); + bool checkFlag(u16 sceneIndex, u16 flag); + virtual u16 getFlagCount() const; + void setFlag(u16 flag); + bool checkUncommittedFlag(u16 sceneIndex, u16 flag); + u16 checkUncommittedFlag2(u16 flag) { + return checkUncommittedFlag(flag); + } +}; + +#endif diff --git a/include/d/lyt/d_lyt_common_arrow.h b/include/d/lyt/d_lyt_common_arrow.h index 06ff8c07..16415e5a 100644 --- a/include/d/lyt/d_lyt_common_arrow.h +++ b/include/d/lyt/d_lyt_common_arrow.h @@ -3,6 +3,7 @@ #include "d/lyt/d2d.h" #include "d/lyt/d_structd.h" +#include "nw4r/lyt/lyt_bounding.h" #include "s/s_State.hpp" #include "s/s_StateMgr.hpp" @@ -23,11 +24,11 @@ class dLytCommonArrow_c { bool fn_80168490(); bool fn_80168500(); - void fn_80168640(f32 *); - bool fn_80168680(); - bool fn_801686F0(); + void setTranslate(const Vec *); + bool requestIn(); + bool requestOut(); bool fn_80168760(); - void fn_80168790(s32, f32); + void displayElement(s32, f32); void fn_80168800(s32); void fn_80168810(d2d::AnmGroup_c *); void fn_80168880(); @@ -36,18 +37,18 @@ class dLytCommonArrow_c { UI_STATE_MGR_DECLARE(dLytCommonArrow_c); /* 0x40 */ d2d::LytBase_c mLytBase; d2d::ResAccIf_c mResAcc; - d2d::AnmGroup_c field_0x440[0x9]; - d2d::dLytStructD field_0x680; - void *field_0x6A8; - void *field_0x6AC; - s32 field_0x6B0; + d2d::AnmGroup_c mAnmGroups[0x9]; + d2d::dLytStructD mStructD; + nw4r::lyt::Bounding *mBoundingL; + nw4r::lyt::Bounding *mBoundingR; + s32 mType; s32 field_0x6B4; s32 field_0x6B8; s32 field_0x6BC; s32 field_0x6C0; - s32 field_0x6C4; - u8 field_0x6C8; - u8 field_0x6C9; + s32 mTimer; + u8 mInRequested; + u8 mOutRequested; u8 field_0x6CA; u8 field_0x6CB; u8 field_0x6CC; diff --git a/include/d/lyt/d_structd.h b/include/d/lyt/d_structd.h index 51359aa6..346dda60 100644 --- a/include/d/lyt/d_structd.h +++ b/include/d/lyt/d_structd.h @@ -1,21 +1,23 @@ #ifndef D_LYT_STRUCTD_H #define D_LYT_STRUCTD_H +#include "common.h" #include "egg/core/eggHeap.h" -#include "nw4r/ut/ut_LinkList.h" #include "toBeSorted/tlist.h" namespace d2d { +class dLytStructD; + class dLytStructC { public: - dLytStructC() : field_0x10(0), field_0x14(0) {} + dLytStructC() : field_0x10(0), field_0x14(nullptr) {} virtual ~dLytStructC() {} virtual void *dLytStructC0x0C(); TListNode mLink; u16 field_0x10; - s32 field_0x14; + dLytStructD *field_0x14; }; class dLytStructCSub : public dLytStructC { @@ -30,7 +32,8 @@ class dLytStructCSub : public dLytStructC { struct dLytStructD_Base { dLytStructD_Base() : field_0x0C(0), field_0x10(0), field_0x14(0), field_0x015(0), field_0x016(0) {} - virtual ~dLytStructD_Base() {} + virtual u32 getType() = 0; + virtual void doSomething() = 0; TListNode mLink; u32 field_0x0C; u32 field_0x10; @@ -56,8 +59,10 @@ struct dLytStructDInArray { }; struct dLytStructD : dLytStructD_Base { - dLytStructD() : field_0x18(0), field_0x1C(nullptr), field_0x20(0), field_0x22(0), field_0x23(0), field_0x24(0) {} + dLytStructD() : field_0x18(0), field_0x1C(nullptr), field_0x20(0), field_0x22(0), field_0x23(0), field_0x24(nullptr) {} + virtual u32 getType() override; + virtual void doSomething() override; virtual ~dLytStructD(); void init(nw4r::lyt::Pane *, u16, u8, u8); @@ -69,7 +74,7 @@ struct dLytStructD : dLytStructD_Base { u16 field_0x20; u8 field_0x22; u8 field_0x23; - u32 field_0x24; + void *field_0x24; }; class dLytStructDList { diff --git a/include/libc.h b/include/libc.h index e5eb89f8..3ae187a0 100644 --- a/include/libc.h +++ b/include/libc.h @@ -7,7 +7,6 @@ extern "C" { // void *memset(void *dest, s32 value, u32 count); // void *memcpy(void *dest, const void *src, u32 count); -void *checkedMemcpy(void *dest, u16 destLen, const void *src, u16 count); } #endif diff --git a/include/nw4r/g3d/g3d_scnmdl.h b/include/nw4r/g3d/g3d_scnmdl.h index c2ab9ff0..f81dde0d 100644 --- a/include/nw4r/g3d/g3d_scnmdl.h +++ b/include/nw4r/g3d/g3d_scnmdl.h @@ -21,6 +21,15 @@ class ScnMdl : public ScnMdlSimple { char UNK_0x0[0x34]; }; + class CopiedVisAccess { + public: + CopiedVisAccess(ScnMdl *, u32); + void SetVisibility(bool); + private: + // TODO + char UNK_0x0[0x10]; + }; + public: virtual bool SetAnmObj(AnmObj *p, AnmObjType type) override; diff --git a/include/toBeSorted/file_manager.h b/include/toBeSorted/file_manager.h index 185f2f23..89a769aa 100644 --- a/include/toBeSorted/file_manager.h +++ b/include/toBeSorted/file_manager.h @@ -1,3 +1,6 @@ +#ifndef FILE_MANAGER_H +#define FILE_MANAGER_H + #include "common.h" #include "egg/core/eggHeap.h" #include "m/m_angle.h" @@ -76,7 +79,7 @@ class FileManager { /* 8000A330 */ u16 *getStoryFlagsMut(); /* 8000A360 */ const u16 *getStoryFlagsConst() const; /* 8000A3B0 */ u16 *getItemFlagsMut(); - /* 8000A3E0 */ u16 *getItemFlagsConst(); + /* 8000A3E0 */ const u16 *getItemFlagsConst(); /* 8000A430 */ u16 *getDungeonFlagsMut(); /* 8000A460 */ u16 *getDungeonFlagsConst(); /* 8000A4B0 */ u16 *getSceneFlagsMut(); @@ -210,7 +213,7 @@ class FileManager { /* 8000CAD0 */ bool isNew_FileA(); /* 8000CB00 */ void setSceneFlagIndex(u16 idx); - /* 8000CB30 */ u16 getSceneFlagIndex(); + /* 8000CB30 */ u32 getSceneFlagIndex(); /* 8000CB80 */ s32 getFileAreaIndex(); /* 8000CBD0 */ void fn_8000CBD0(u8); @@ -285,3 +288,5 @@ class FileManager { } static FileManager *sInstance; }; + +#endif diff --git a/include/toBeSorted/item_story_flag_manager.h b/include/toBeSorted/item_story_flag_manager.h deleted file mode 100644 index 669b9b4a..00000000 --- a/include/toBeSorted/item_story_flag_manager.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef ITEM_STORY_FLAG_MANAGER_H -#define ITEM_STORY_FLAG_MANAGER_H - -#include "toBeSorted/flag_space.h" -#include "toBeSorted/unk_flag_stuff.h" - -// TODO These classes have an interesting relation and there are like 5 vtables, so -// the stuff in this header should not be relied upon for actually implementing these, -// but we need the interface - -class ItemStoryManagerBase { -public: - ItemStoryManagerBase(); - - /** 0x08 */ virtual ~ItemStoryManagerBase(); - /** 0x0C */ virtual void setFlagszptr(); - /** 0x10 */ virtual void onDirty(); - /** 0x14 */ virtual void copyFlagsFromSave() = 0; - /** 0x18 */ virtual void setupUnkFlagsStuff() = 0; - /** 0x1C */ virtual bool doCommit() = 0; - /** 0x20 */ virtual void setFlag(u16 flag); - /** 0x24 */ virtual void unsetFlag(u16 flag); - /** 0x28 */ virtual void setFlagOrCounterToValue(u16 flag, u16 value); - /** 0x2C */ virtual u16 getCounterOrFlag(u16 flag) const; - /** 0x30 */ virtual u16 getUncommittedValue(u16 flag); - /** 0x34 */ virtual void unk3(); - /** 0x38 */ virtual u16 *getSaveFlagSpace() = 0; - - u16 getFlag(u16 flag) const; -}; - -class StoryflagManager : public ItemStoryManagerBase { - FlagSpace storyFlags; - -public: - static StoryflagManager *sInstance; -}; - -class ItemflagManager : public ItemStoryManagerBase { - FlagSpace itemFlags; - -public: - static ItemflagManager *sInstance; -}; - -#endif diff --git a/include/toBeSorted/misc_flag_managers.h b/include/toBeSorted/misc_flag_managers.h deleted file mode 100644 index 6a871cfa..00000000 --- a/include/toBeSorted/misc_flag_managers.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef MISC_FLAG_MANAGERS_H -#define MISC_FLAG_MANAGERS_H - -#include "common.h" -#include "toBeSorted/bitwise_flag_helper.h" -#include "toBeSorted/flag_space.h" - -class CommittableFlagManager { -public: - bool mNeedsCommit; - - virtual void doCommit() = 0; - bool commitIfNecessary(); - void setNeedsCommit(bool commit) { - mNeedsCommit = commit; - } - CommittableFlagManager() { - mNeedsCommit = false; - } - CommittableFlagManager(bool commit) { - mNeedsCommit = commit; - } -}; - -class TBoxFlagManager : public CommittableFlagManager { -public: - FlagSpace mFlagSpace; - u16 mSceneIndex; - BitwiseFlagHelper mFlagHelper; - - static u16 sTBoxFlags[2]; - - static TBoxFlagManager *sInstance; - - virtual void doCommit() override; - bool checkUncommittedFlag(u16 flag); - TBoxFlagManager(); - virtual ~TBoxFlagManager() {} - void init(); - void copyFromSave(s16 sceneIndex); - bool checkFlag(u16 sceneIndex, u16 flag); - virtual u16 getFlagCount() const; - void setFlag(u16 flag); - bool checkUncommittedFlag(u16 sceneIndex, u16 flag); - u16 checkUncommittedFlag2(u16 flag) { - return checkUncommittedFlag(flag); - } -}; - -// NOTE: Not actually Enemy Defeat. -// This is a little more than that, it keeps track of live objects based on their id as a whole -class EnemyDefeatManager : public CommittableFlagManager { -public: - FlagSpace mFlagSpace; - BitwiseFlagHelper mFlagHelper; - u16 mSceneIndex; - - static u16 sEnemyDefeatFlags[4096]; - - static EnemyDefeatManager *sInstance; - - void clearSavedFlags(); - bool checkUncommittedFlag(u16 flag); - u16 checkUncommittedFlag2(u16 flag) { - return checkUncommittedFlag(flag); - } - EnemyDefeatManager(); - void init(); - void copyFromSave(u16 sceneIndex); - void updateFlagIndex(u16 sceneIndex); - void clearAll(); - bool checkIsValidFlag(u16 flag); - bool checkFlag(u16 flag); - virtual ~EnemyDefeatManager() {} - virtual u16 getFlagCount() const; - void setFlag(u16 flag); -}; - -#endif diff --git a/include/toBeSorted/unk_flag_stuff.h b/include/toBeSorted/unk_flag_stuff.h deleted file mode 100644 index 04d9a024..00000000 --- a/include/toBeSorted/unk_flag_stuff.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef UNK_FLAG_STUFF_H -#define UNK_FLAG_STUFF_H - -#include "common.h" - -struct UnkFlagDefinition { - u8 mIndex; - u8 mShiftMask; -}; - -class UnkFlagStuff { - u16 mDefinitionsCount; - UnkFlagDefinition *mpDefinitions; - -public: - u16 calculateMask(s32 shift); - void doNothing(u32 unused); - UnkFlagStuff(u16 count, UnkFlagDefinition *definitions); - void prepareIndexShiftMask(u16 counterIdx, u32 flagCount, u16 *pIndex, u8 *pShift, u16 *pMask); - u16 maskForIdx(u16 index); - u32 getCounterOrFlag(u16 counterIdx, u16 *pData, u32 flagCount); - void setCounterOrFlag(u16 counterIdx, u16 *pData, u32 flagCount, u32 value); - u32 checkFlagValid(u16 counterIdx, u32 flagCount); -}; - -#endif diff --git a/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp b/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp index 35aeb06e..1a89d00e 100644 --- a/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp +++ b/src/REL/d/a/obj/d_a_obj_bamboo_island.cpp @@ -1,7 +1,7 @@ #include "d/a/obj/d_a_obj_bamboo_island.h" #include "d/col/bg/d_bg_s.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/storyflag_manager.h" #include "toBeSorted/room_manager.h" const f32 dAcObambooIsland_c::unusedFloat1 = 100000.0f; diff --git a/src/REL/d/a/obj/d_a_obj_island_nusi.cpp b/src/REL/d/a/obj/d_a_obj_island_nusi.cpp index bef28fa4..dc50ca9d 100644 --- a/src/REL/d/a/obj/d_a_obj_island_nusi.cpp +++ b/src/REL/d/a/obj/d_a_obj_island_nusi.cpp @@ -1,13 +1,117 @@ #include "d/a/obj/d_a_obj_island_nusi.h" +#include "d/a/obj/d_a_obj_base.h" +#include "d/col/bg/d_bg_s.h" +#include "f/f_base.h" +#include "m/m_vec.h" +#include "nw4r/g3d/g3d_resmdl.h" +#include "nw4r/g3d/g3d_resnode.h" +#include "nw4r/g3d/g3d_scnmdl.h" +#include "nw4r/g3d/g3d_scnobj.h" +#include "d/flag/storyflag_manager.h" +#include "toBeSorted/room_manager.h" + +const f32 dAcOislandNusi_c::someFloat = 100000.0f; + +static const char *const sMdlNames[] = { + "IslNusi", + "IslNusi_s", +}; + SPECIAL_ACTOR_PROFILE(OBJ_ISLAND_NUSI, dAcOislandNusi_c, fProfile::OBJ_ISLAND_NUSI, 0x204, 0, 3); STATE_DEFINE(dAcOislandNusi_c, Wait); STATE_DEFINE(dAcOislandNusi_c, NusiFight); -void dAcOislandNusi_c::initializeState_Wait() {} -void dAcOislandNusi_c::executeState_Wait() {} +bool dAcOislandNusi_c::createHeap() { + mRes = getOarcResFile("IslNusi"); + RoomManager::bindStageResToFile(&mRes); + RoomManager::bindSkyCmnToResFile(&mRes); + for (int i = 0; i < 2; i++) { + nw4r::g3d::ResMdl mdl = mRes.GetResMdl(sMdlNames[i]); + TRY_CREATE(mMdls[i].create(mdl, &heap_allocator, 0x160)); + } + + mMdls[0].setOption(0x30001, 0); + + void *dzb = getOarcFile("IslNusi", "dzb/IslNusi.dzb"); + void *plc = getOarcFile("IslNusi", "dat/IslNusi.plc"); + updateMatrix(); + for (int i = 0; i < 2; i++) { + mMdls[i].setLocalMtx(mWorldMtx); + } + TRY_CREATE(!mBgW.Set((cBgD_t *)dzb, (PLC *)plc, cBgW::MOVE_BG_e, &mWorldMtx, &mScale)); + mBgW.Lock(); + // TODO InitMapStuff bool vs BOOL + return (BOOL)mBgW.InitMapStuff(&heap_allocator); +} + +int dAcOislandNusi_c::create() { + CREATE_ALLOCATOR(dAcOislandNusi_c); + dBgS::GetInstance()->Regist(&mBgW, this); + dBgS::GetInstance()->RegistBg(&mBgW, this); + if (isInLeviasFight()) { + mStateMgr.changeState(StateID_NusiFight); + } else { + mStateMgr.changeState(StateID_Wait); + } + + mMdls[0].setPriorityDraw(0x1C, 9); + mMdls[1].setPriorityDraw(0x22, 9); + boundingBox.Set(mVec3_c(-4000.0f, -1200.0f, -2700.0f), mVec3_c(4800.0f, 3400.0f, 1700.0f)); + + mCullingDistance = 500000.0f; + + return SUCCEEDED; +} + +int dAcOislandNusi_c::doDelete() { + dBgS::GetInstance()->UnRegist(&mBgW); + return SUCCEEDED; +} + +int dAcOislandNusi_c::actorExecute() { + mStateMgr.executeState(); + return SUCCEEDED; +} + +int dAcOislandNusi_c::draw() { + for (int i = 0; i < 2; i++) { + drawModelType1(&mMdls[i]); + } + return SUCCEEDED; +} + +void dAcOislandNusi_c::initializeState_Wait() { + nw4r::g3d::ScnMdl *m = nw4r::g3d::ScnObj::DynamicCast(mMdls[0].getG3dObject()); + nw4r::g3d::ResMdl resM = mMdls[0].getResMdl(); + nw4r::g3d::ResNode resNd = resM.GetResNode("pPipe1"); + u32 id = resNd.GetID(); + nw4r::g3d::ScnMdl::CopiedVisAccess visAccess(m, id); + visAccess.SetVisibility(true); +} +void dAcOislandNusi_c::executeState_Wait() { + if (isInLeviasFight()) { + mStateMgr.changeState(StateID_NusiFight); + } +} void dAcOislandNusi_c::finalizeState_Wait() {} -void dAcOislandNusi_c::initializeState_NusiFight() {} -void dAcOislandNusi_c::executeState_NusiFight() {} + +void dAcOislandNusi_c::initializeState_NusiFight() { + nw4r::g3d::ScnMdl *m = nw4r::g3d::ScnObj::DynamicCast(mMdls[0].getG3dObject()); + nw4r::g3d::ResMdl resM = mMdls[0].getResMdl(); + nw4r::g3d::ResNode resNd = resM.GetResNode("pPipe1"); + u32 id = resNd.GetID(); + nw4r::g3d::ScnMdl::CopiedVisAccess visAccess(m, id); + visAccess.SetVisibility(false); +} +void dAcOislandNusi_c::executeState_NusiFight() { + if (!isInLeviasFight()) { + mStateMgr.changeState(StateID_Wait); + } +} void dAcOislandNusi_c::finalizeState_NusiFight() {} + +bool dAcOislandNusi_c::isInLeviasFight() const { + return StoryflagManager::sInstance->getCounterOrFlag(368) && !StoryflagManager::sInstance->getCounterOrFlag(200); +} diff --git a/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp b/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp index aff5ff3c..d363eb78 100644 --- a/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp +++ b/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp @@ -1,6 +1,6 @@ #include "d/a/obj/d_a_obj_junk_repairing.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/storyflag_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_JUNK_REPAIR, dAcOJunkRep_c, fProfile::OBJ_JUNK_REPAIR, 0x027B, 0, 3); diff --git a/src/REL/d/a/obj/d_a_obj_pool_cock.cpp b/src/REL/d/a/obj/d_a_obj_pool_cock.cpp index 61e2ca47..78a11035 100644 --- a/src/REL/d/a/obj/d_a_obj_pool_cock.cpp +++ b/src/REL/d/a/obj/d_a_obj_pool_cock.cpp @@ -3,7 +3,7 @@ #include "d/a/obj/d_a_obj_vortex.h" #include "s/s_Math.h" #include "toBeSorted/room_manager.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_POOL_COCK, dAcOPoolCock_c, fProfile::OBJ_POOL_COCK, 0x024D, 0, 7); 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 54d61a36..33f6c2b1 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 @@ -4,7 +4,7 @@ #include "toBeSorted/attention.h" #include "toBeSorted/event.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/storyflag_manager.h" #include "toBeSorted/scgame.h" SPECIAL_ACTOR_PROFILE(OBJ_TOD3_STONE, dAcOtoD3StoneFigure_c, fProfile::OBJ_TOD3_STONE, 0x1B3, 0, 0); diff --git a/src/REL/d/a/obj/d_a_obj_utajima.cpp b/src/REL/d/a/obj/d_a_obj_utajima.cpp index 29fb96b2..d3248393 100644 --- a/src/REL/d/a/obj/d_a_obj_utajima.cpp +++ b/src/REL/d/a/obj/d_a_obj_utajima.cpp @@ -4,7 +4,7 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/col/bg/d_bg_s.h" #include "d/col/c/c_m3d_g_aab.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/storyflag_manager.h" #include "toBeSorted/room_manager.h" static const char *const mMdlNames[] = { diff --git a/src/REL/d/t/d_t_dowsing.cpp b/src/REL/d/t/d_t_dowsing.cpp index dee083da..642d1de9 100644 --- a/src/REL/d/t/d_t_dowsing.cpp +++ b/src/REL/d/t/d_t_dowsing.cpp @@ -1,8 +1,8 @@ #include "d/t/d_t_dowsing.h" -#include "toBeSorted/item_story_flag_manager.h" -#include "toBeSorted/room_manager.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/itemflag_manager.h" +#include "d/flag/storyflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(T_DOWSING, dTgDowsing_c, fProfile::T_DOWSING, 0x0293, 0, 0); @@ -56,13 +56,13 @@ bool dTgDowsing_c::checkDowsing() const { switch (mDowsingOption) { case TRIAL_0: - return ItemflagManager::sInstance->getFlag(187) && !StoryflagManager::sInstance->getCounterOrFlag(93); + return ItemflagManager::sInstance->getFlagDirect(187) && !StoryflagManager::sInstance->getCounterOrFlag(93); case TRIAL_1: - return ItemflagManager::sInstance->getFlag(188) && !StoryflagManager::sInstance->getCounterOrFlag(97); + return ItemflagManager::sInstance->getFlagDirect(188) && !StoryflagManager::sInstance->getCounterOrFlag(97); case TRIAL_2: - return ItemflagManager::sInstance->getFlag(189) && !StoryflagManager::sInstance->getCounterOrFlag(98); + return ItemflagManager::sInstance->getFlagDirect(189) && !StoryflagManager::sInstance->getCounterOrFlag(98); case TRIAL_3: - return ItemflagManager::sInstance->getFlag(193) && !StoryflagManager::sInstance->getCounterOrFlag(99); + return ItemflagManager::sInstance->getFlagDirect(193) && !StoryflagManager::sInstance->getCounterOrFlag(99); 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_genki_dws_tgt.cpp b/src/REL/d/t/d_t_genki_dws_tgt.cpp index a354795b..bdee8025 100644 --- a/src/REL/d/t/d_t_genki_dws_tgt.cpp +++ b/src/REL/d/t/d_t_genki_dws_tgt.cpp @@ -1,8 +1,8 @@ #include "d/t/d_t_genki_dws_tgt.h" -#include "toBeSorted/item_story_flag_manager.h" #include "toBeSorted/room_manager.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" +#include "d/flag/storyflag_manager.h" #include "toBeSorted/scgame.h" diff --git a/src/REL/d/t/d_t_reaction.cpp b/src/REL/d/t/d_t_reaction.cpp index fc0c2e42..614d0d30 100644 --- a/src/REL/d/t/d_t_reaction.cpp +++ b/src/REL/d/t/d_t_reaction.cpp @@ -5,7 +5,7 @@ #include "d/a/d_a_player.h" #include "d/a/obj/d_a_obj_item.h" #include "d/col/cc/d_cc_mgr.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(TAG_REACTION, dTgReaction_c, fProfile::TAG_REACTION, 0x0151, 0, 0); diff --git a/src/REL/d/t/d_t_ship_window.cpp b/src/REL/d/t/d_t_ship_window.cpp index 9ae4a0f9..7b650421 100644 --- a/src/REL/d/t/d_t_ship_window.cpp +++ b/src/REL/d/t/d_t_ship_window.cpp @@ -1,7 +1,7 @@ #include "d/t/d_t_ship_window.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(TAG_SHIP_WINDOW, dTgShipWindow_c, fProfile::TAG_SHIP_WINDOW, 0x0228, 0, 0); diff --git a/src/REL/d/t/d_t_sw_area.cpp b/src/REL/d/t/d_t_sw_area.cpp index ab8b67fb..90d96210 100644 --- a/src/REL/d/t/d_t_sw_area.cpp +++ b/src/REL/d/t/d_t_sw_area.cpp @@ -1,8 +1,8 @@ #include "d/t/d_t_sw_area.h" #include "d/a/d_a_player.h" #include "toBeSorted/area_math.h" -#include "toBeSorted/sceneflag_manager.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/sceneflag_manager.h" +#include "d/flag/storyflag_manager.h" SPECIAL_ACTOR_PROFILE(SW_AREA_TAG, dTgSwArea_c, fProfile::SW_AREA_TAG, 0x292, 0, 0); diff --git a/src/REL/d/t/d_t_time_area_check.cpp b/src/REL/d/t/d_t_time_area_check.cpp index d35b3932..8f9ca218 100644 --- a/src/REL/d/t/d_t_time_area_check.cpp +++ b/src/REL/d/t/d_t_time_area_check.cpp @@ -1,6 +1,6 @@ #include "d/t/d_t_time_area_check.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" #include "toBeSorted/time_area_mgr.h" diff --git a/src/REL/d/t/d_t_timer.cpp b/src/REL/d/t/d_t_timer.cpp index c5237049..08e61bcf 100644 --- a/src/REL/d/t/d_t_timer.cpp +++ b/src/REL/d/t/d_t_timer.cpp @@ -1,6 +1,6 @@ #include "d/t/d_t_timer.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(TAG_TIMER, dTgTimer_c, fProfile::TAG_TIMER, 0x029F, 0, 0); diff --git a/src/REL/d/t/d_t_touch.cpp b/src/REL/d/t/d_t_touch.cpp index 06bcecff..352f2f54 100644 --- a/src/REL/d/t/d_t_touch.cpp +++ b/src/REL/d/t/d_t_touch.cpp @@ -2,7 +2,7 @@ #include "c/c_math.h" #include "toBeSorted/area_math.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(TOUCH_TAG, dTgTouchTag, fProfile::TOUCH_TAG, 0x028E, 0, 0); diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index e8a75968..30581cee 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -8,7 +8,7 @@ #include "toBeSorted/event.h" #include "toBeSorted/event_manager.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/misc_flag_managers.h" +#include "d/flag/enemyflag_manager.h" #include "toBeSorted/room_manager.h" #include "toBeSorted/scgame.h" #include "toBeSorted/special_item_drop_mgr.h" @@ -476,7 +476,7 @@ void dAcBase_c::setActorRef(dAcBase_c *ref) { // May not be only purpose void dAcBase_c::setEnemyDefeatFlag() { - EnemyDefeatManager::sInstance->setFlag(obj_id); + EnemyflagManager::sInstance->setFlag(obj_id); } // 8002d940 diff --git a/src/d/a/obj/d_a_obj_switch.cpp b/src/d/a/obj/d_a_obj_switch.cpp index 65b678d4..2131d02b 100644 --- a/src/d/a/obj/d_a_obj_switch.cpp +++ b/src/d/a/obj/d_a_obj_switch.cpp @@ -6,7 +6,7 @@ #include "d/col/bg/d_bg_w.h" #include "nw4r/g3d/g3d_resfile.h" #include "s/s_Math.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_SW, dAcOsw_c, fProfile::OBJ_SW, 0x12B, 0, 0x1002); diff --git a/src/d/col/bg/d_bg_s_acch.cpp b/src/d/col/bg/d_bg_s_acch.cpp index 17407a43..06f2496d 100644 --- a/src/d/col/bg/d_bg_s_acch.cpp +++ b/src/d/col/bg/d_bg_s_acch.cpp @@ -210,8 +210,7 @@ void dBgS_Acch::GroundCheck(dBgS &bgs, bool param2) { } } - // UUUUUGH - if ((mFlags & ACCH_FLAG_0x4000000) && !(mFlags & GROUND_HIT)) { + if (Chk_0x4000000() && !i_ChkGroundHit()) { SetGroundAway(); } diff --git a/src/d/flag/baseflag_manager.inc b/src/d/flag/baseflag_manager.inc new file mode 100644 index 00000000..f9de576d --- /dev/null +++ b/src/d/flag/baseflag_manager.inc @@ -0,0 +1,117 @@ +#include "d/flag/baseflag_manager.h" + +ItemStoryManagerBase::ItemStoryManagerBase(): mFlagCount(0), mFlagSizeBytes(0), mpFlagSpace(nullptr), mpFlagIndex(nullptr), mDirty(false) {} +ItemStoryManagerBase::~ItemStoryManagerBase() { + if (mpFlagIndex != nullptr) { + delete mpFlagIndex; + } +} + +void ItemStoryManagerBase::setFlagSizes(u16 flagCount, u16 flagSizeBytes) { + mFlagCount = flagCount; + mFlagSizeBytes = flagSizeBytes; +} + +/** 800bf320 */ +void ItemStoryManagerBase::createFlagIndex(FlagDefinition *def, u16 count) { + mpFlagIndex = new FlagIndex(count, def); +} + +/** 800bf380 */ +void ItemStoryManagerBase::copyFromSave() { + FlagSpace *current = mpFlagSpace; + const u16 *saved = getSaveFlagSpace(); + current->copyFromSaveFile(saved, 0, mFlagCount); +} + +/** 800bf3e0 */ +void ItemStoryManagerBase::init() { + const u16 *space = getSaveFlagSpace(); + if (space == nullptr || mpFlagIndex == nullptr) { + initFlagSpace(); + copyFlagsFromSaveFirstTime(); + setupFlagIndex(); + } +} + +/** 800bf470 */ +void ItemStoryManagerBase::initFlagSpace() { + +} + +/** 800bf480 */ +u16 ItemStoryManagerBase::getFlag(u16 flag) const { + const u16 *data = getSaveFlagSpace(); + return mpFlagIndex->getCounterOrFlag(flag, data, mFlagCount); +} + +/** 800bf4e0 */ +u16 ItemStoryManagerBase::getUncommittedValue_Priv(u16 flag) { + u16 *data = mpFlagSpace->getFlagPtrUnchecked(); + return mpFlagIndex->getCounterOrFlag(flag, data, mFlagCount); +} + +/** 800bf530 */ +void ItemStoryManagerBase::setOrClearFlag(u16 flag, u16 value) { + FlagSpace *storyFlagsPtr = mpFlagSpace; + u16 *pData = storyFlagsPtr->getFlagPtrChecked(); + mpFlagIndex->setCounterOrFlag(flag, pData, storyFlagsPtr->mCount, value); + onFlagChange(flag); +} + +/** 800bf5b0 */ +void ItemStoryManagerBase::setFlag(u16 flag) { + setOrClearFlag(flag, true); +} + +/** 800bf5c0 */ +void ItemStoryManagerBase::unsetFlag(u16 flag) { + setOrClearFlag(flag, false); +} + +/** 800bf5d0 */ +void ItemStoryManagerBase::setFlagOrCounterToValue(u16 flag, u16 value) { + setOrClearFlag(flag, value); +} + +/** 800bf5e0 */ +u16 ItemStoryManagerBase::getCounterOrFlag(u16 flag) const { + return ItemStoryManagerBase::getFlag(flag); +} + +/** 800bf5f0 */ +u16 ItemStoryManagerBase::getUncommittedValue(u16 flag) { + return getUncommittedValue_Priv(flag); +} + +/** 800bf600 */ +u16 ItemStoryManagerBase::unk3(u16 flag) { + return getMaskForFlag(flag); +} + +/** 800bf610 */ +void ItemStoryManagerBase::onFlagChange(u16 flag) { + mDirty = true; + onDirty(); +} + +/** 800bf630 */ +void ItemStoryManagerBase::onDirty() { + +} + +/** 800bf640 */ +u16 ItemStoryManagerBase::getMaskForFlag(u16 flag) { + return mpFlagIndex->maskForIdx(flag, mFlagCount); +} + +/** 800bf650 */ +void ItemStoryManagerBase::doCommit_Priv() { + doCommit(); + mDirty = false; +} + +/* 800bf690 */ +void ItemStoryManagerBase::postCommit() { + +} diff --git a/src/toBeSorted/bitwise_flag_helper.cpp b/src/d/flag/bitwise_flag_helper.inc similarity index 89% rename from src/toBeSorted/bitwise_flag_helper.cpp rename to src/d/flag/bitwise_flag_helper.inc index bc3ac870..a79095f5 100644 --- a/src/toBeSorted/bitwise_flag_helper.cpp +++ b/src/d/flag/bitwise_flag_helper.inc @@ -1,4 +1,4 @@ -#include "toBeSorted/bitwise_flag_helper.h" +#include "d/flag/bitwise_flag_helper.h" #include "common.h" diff --git a/src/d/flag/committable_flag_manager.inc b/src/d/flag/committable_flag_manager.inc new file mode 100644 index 00000000..8bf86ba7 --- /dev/null +++ b/src/d/flag/committable_flag_manager.inc @@ -0,0 +1,12 @@ +#include "d/flag/committable_flag_manager.h" + +/* 0x800BE7B0 */ +bool CommittableFlagManager::commit() { + if (mNeedsCommit) { + doCommit(); + mNeedsCommit = false; + return true; + } else { + return false; + } +} diff --git a/src/d/flag/dungeonflag_manager.inc b/src/d/flag/dungeonflag_manager.inc new file mode 100644 index 00000000..08c5036a --- /dev/null +++ b/src/d/flag/dungeonflag_manager.inc @@ -0,0 +1,75 @@ +#include "d/flag/dungeonflag_manager.h" +#include "d/flag/flag_index.h" + + +// TODO move +extern "C" FlagDefinition DungeonflagManager__FLAG_DEFINITIONS[]; + +/** 80575404 */ +DungeonflagManager *DungeonflagManager::sInstance = nullptr; + +/** 805a9c58 */ +u16 DungeonflagManager::sDungeonFlags[8] = {}; + +/** 800bf8d0 */ +void DungeonflagManager::copyFromSave_Internal(u16 flagIndex) { + mFlagSpace.copyFromSaveFile(saveFilePtr(flagIndex), 0, 0x8); +} + +/** 800bf930 */ +void DungeonflagManager::setCommitFlag(u16 flag) { + mShouldCommit = true; +} + +/** 0x800bf940 */ +DungeonflagManager::DungeonflagManager() + : mShouldCommit(false), mStageIndex(-1), mpFlagIndex(nullptr), + mFlagSpace(sDungeonFlags, ARRAY_LENGTH(sDungeonFlags)) {} + +/** 800bf980 */ +void DungeonflagManager::init() { + mpFlagIndex = new FlagIndex(0x11, DungeonflagManager__FLAG_DEFINITIONS); + mShouldCommit = false; +} + +/** 800bf9e0 */ +void DungeonflagManager::copyFromSave(u32 flag) { + mStageIndex = flag; + copyFromSave_Internal(flag); +} + +/** 800bf9f0 */ +void DungeonflagManager::setToValue(u16 flag, u32 value) { + u16 *data = mFlagSpace.getFlagPtrChecked(); + mpFlagIndex->setCounterOrFlag(flag, data, 8, value); + setCommitFlag(flag); +} + +/** 800bfa60 */ +void DungeonflagManager::setFlag(u16 flag) { + u16 *data = mFlagSpace.getFlagPtrChecked(); + mpFlagIndex->setCounterOrFlag(flag, data, 8, 1); + setCommitFlag(flag); +} + +/** 800fbac0 */ +u16 DungeonflagManager::getDungeonFlag(u16 flag) { + u16 *data = mFlagSpace.getFlagPtrUnchecked(); + return mpFlagIndex->getCounterOrFlag(flag, data, 8); +} + +/** 800fbb10 */ +bool DungeonflagManager::commit() { + FileManager *instance; + u16 idx = mStageIndex; + if (idx == 0xFFFF) { + return false; + } else if (mShouldCommit) { + instance = FileManager::sInstance; + u16 *ptr = mFlagSpace.getFlagPtrUnchecked(); + instance->setDungeonFlags(ptr, (idx & 0x1fff) * 8, 0x08); + mShouldCommit = false; + return true; + } + return false; +} diff --git a/src/d/flag/enemyflag_manager.inc b/src/d/flag/enemyflag_manager.inc new file mode 100644 index 00000000..6c274fa4 --- /dev/null +++ b/src/d/flag/enemyflag_manager.inc @@ -0,0 +1,81 @@ +#include "d/flag/enemyflag_manager.h" + +EnemyflagManager *EnemyflagManager::sInstance = nullptr; +u16 EnemyflagManager::sEnemyDefeatFlags[4096] = {}; + +/* 0x800BEAC0 */ +void EnemyflagManager::clearSavedFlags() { + u16 empty[0x1000]; + memset(empty, 0, 0x2000); + FileManager::getInstance()->setEnemyDefeatFlags(empty, 0, 0x1000); +} + +/* 0x800BEB00 */ +bool EnemyflagManager::checkUncommittedFlag(u16 flag) { + if (checkIsValidFlag(flag)) { + return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount); + } else { + return false; + } +} + +/* 0x800BEB80 */ +EnemyflagManager::EnemyflagManager() + : CommittableFlagManager(false), mFlagSpace(sEnemyDefeatFlags, ARRAY_LENGTH(sEnemyDefeatFlags)) {} + +/* 0x800BEBC0 */ +void EnemyflagManager::init() { + mSceneIndex = 0; + clearAll(); +} + +/* 0x800BEBD0 */ +void EnemyflagManager::copyFromSave(u16 sceneIndex) { + mSceneIndex = sceneIndex; + u16 count = mFlagSpace.mCount; + u16 *flags = FileManager::getInstance()->getEnemyDefeatFlagsConst(); + mFlagSpace.copyFromSaveFile(flags, 0, count); +} + +/* 0x800BEC30 */ +void EnemyflagManager::updateFlagIndex(u16 sceneIndex) { + if (mSceneIndex == sceneIndex) { + return; + } + mSceneIndex = sceneIndex; + clearAll(); +} + +/* 0x800BEC50 */ +void EnemyflagManager::clearAll() { + clearSavedFlags(); + mFlagSpace.unsetAll(); +} + +/* 0x800BEC90 */ +bool EnemyflagManager::checkIsValidFlag(u16 flag) { + return flag < 0xFFFF; +} + +/* 0x800BECB0 */ +bool EnemyflagManager::checkFlag(u16 flag) { + if (!checkIsValidFlag(flag)) { + return false; + } else { + u16 *pData = FileManager::getInstance()->getEnemyDefeatFlagsConst(); + return mFlagHelper.checkFlag(flag / 16, flag % 16, pData, getFlagCount()); + } +} + +/* 0x800BED50 */ +u16 EnemyflagManager::getFlagCount() const { + return 0x1000; +} + +/* 0x800BED60 */ +void EnemyflagManager::setFlag(u16 flag) { + if (checkUncommittedFlag2(flag) != 1 && checkIsValidFlag(flag)) { + mFlagHelper.setFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrChecked(), mFlagSpace.mCount); + setNeedsCommit(true); + } +} diff --git a/src/toBeSorted/unk_flag_stuff.cpp b/src/d/flag/flag_index.inc similarity index 55% rename from src/toBeSorted/unk_flag_stuff.cpp rename to src/d/flag/flag_index.inc index 17cbaa87..e72efd5f 100644 --- a/src/toBeSorted/unk_flag_stuff.cpp +++ b/src/d/flag/flag_index.inc @@ -1,30 +1,30 @@ -#include "toBeSorted/unk_flag_stuff.h" +#include "d/flag/flag_index.h" -u16 UnkFlagStuff::calculateMask(s32 shift) { +u16 FlagIndex::calculateMask(s32 shift) { return (2 << (shift & 0xF)) - 1; } -void UnkFlagStuff::doNothing(u32 unused) {} +void FlagIndex::doNothing(u32 unused) {} -UnkFlagStuff::UnkFlagStuff(u16 count, UnkFlagDefinition *definitions) { +FlagIndex::FlagIndex(u16 count, FlagDefinition *definitions) { this->mDefinitionsCount = count; this->mpDefinitions = definitions; } -void UnkFlagStuff::prepareIndexShiftMask(u16 counterIdx, u32 unused, u16 *indexPtr, u8 *shiftPtr, u16 *maskPtr) { +void FlagIndex::prepareIndexShiftMask(u16 counterIdx, u32 unused, u16 *indexPtr, u8 *shiftPtr, u16 *maskPtr) { doNothing(counterIdx); *indexPtr = mpDefinitions[counterIdx].mIndex; *shiftPtr = mpDefinitions[counterIdx].mShiftMask >> 4; *maskPtr = calculateMask(mpDefinitions[counterIdx].mShiftMask); } -u16 UnkFlagStuff::maskForIdx(u16 index) { +u16 FlagIndex::maskForIdx(u16 index, u16 flagCount) { doNothing(index); return calculateMask(mpDefinitions[index].mShiftMask); } -u32 UnkFlagStuff::getCounterOrFlag(u16 counterIdx, u16 *dataPtr, u32 param4) { +u16 FlagIndex::getCounterOrFlag(u16 counterIdx, const u16 *dataPtr, u32 param4) { u16 index = 0; u8 shift = 0; u16 mask = 0; @@ -32,7 +32,7 @@ u32 UnkFlagStuff::getCounterOrFlag(u16 counterIdx, u16 *dataPtr, u32 param4) { return mask & (dataPtr[index] >> shift); } -void UnkFlagStuff::setCounterOrFlag(u16 counterIdx, u16 *dataPtr, u32 flagCount, u32 value) { +void FlagIndex::setCounterOrFlag(u16 counterIdx, u16 *dataPtr, u32 flagCount, u32 value) { u16 index = 0; u8 shift = 0; u16 mask = 0; @@ -41,21 +41,13 @@ void UnkFlagStuff::setCounterOrFlag(u16 counterIdx, u16 *dataPtr, u32 flagCount, dataPtr[index] = (u16)(value << shift) | dataPtr[index]; } -inline bool isLessThan(int a, int b) { - return a <= b; -} - -u32 UnkFlagStuff::checkFlagValid(u16 counterIdx, u32 flagCount) { +u32 FlagIndex::checkFlagValid(u16 counterIdx, u32 flagCount) { if (mpDefinitions == nullptr) { return 0; } if (mDefinitionsCount <= counterIdx || mpDefinitions[counterIdx].mIndex == 0xFF) { return 0; } else { - if (isLessThan(flagCount, mpDefinitions[counterIdx].mIndex)) { - return 0; - } else { - return 1; - } + return (int)mpDefinitions[counterIdx].mIndex < (int)flagCount; } } diff --git a/src/d/flag/flag_managers.cpp b/src/d/flag/flag_managers.cpp new file mode 100644 index 00000000..259ea153 --- /dev/null +++ b/src/d/flag/flag_managers.cpp @@ -0,0 +1,125 @@ + +#include "d/flag/flag_managers.h" + +// clang-format off +#include "common.h" +#include "egg/core/eggHeap.h" +#include "m/m_heap.h" +// vtable order +#include "d/flag/flag_space.h" +#include "d/flag/tboxflag_manager.h" +#include "d/flag/enemyflag_manager.h" +#include "d/flag/storyflag_manager.h" +#include "d/flag/itemflag_manager.h" + +// actual managers +#include "d/flag/sceneflag_manager.inc" +#include "d/flag/committable_flag_manager.inc" +#include "d/flag/tboxflag_manager.inc" +#include "d/flag/enemyflag_manager.inc" +#include "d/flag/flag_space.inc" +#include "d/flag/flag_index.inc" +#include "d/flag/bitwise_flag_helper.inc" +#include "d/flag/baseflag_manager.inc" +#include "d/flag/storyflag_manager.inc" +#include "d/flag/itemflag_manager.inc" +#include "d/flag/dungeonflag_manager.inc" +#include "d/flag/skipflag_manager.inc" +// clang-format on + + +static void postSetup(); + +template +class MyFlagManager : public T { +public: + MyFlagManager() {} + ~MyFlagManager() {} +}; + +void setupFlagManagers(EGG::Heap *heap) { + if (SceneflagManager::sInstance == nullptr) { + SceneflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + SceneflagManager::sInstance->init(); + } + + if (TBoxflagManager::sInstance == nullptr) { + TBoxflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + TBoxflagManager::sInstance->init(); + } + + if (EnemyflagManager::sInstance == nullptr) { + EnemyflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + EnemyflagManager::sInstance->init(); + } + + if (StoryflagManager::sInstance == nullptr) { + StoryflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + StoryflagManager::sInstance->init(); + } + + if (ItemflagManager::sInstance == nullptr) { + ItemflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + ItemflagManager::sInstance->init(); + } + + if (DungeonflagManager::sInstance == nullptr) { + DungeonflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + DungeonflagManager::sInstance->init(); + } + + if (SkipflagManager::sInstance == nullptr) { + SkipflagManager::sInstance = new (heap) MyFlagManager(); + mHeap m(heap); + SkipflagManager::sInstance->init(); + } + + postSetup(); +} + +static void postSetup() { + updateFlagForFlagIndex(0); +} + +void copyAllFlagManagersFromSave() { + u16 flag = FileManager::sInstance->getSceneFlagIndex(); + SceneflagManager::sInstance->copyFromSave(flag); + TBoxflagManager::sInstance->copyFromSave(flag); + StoryflagManager::sInstance->copyFromSave(); + ItemflagManager::sInstance->copyFromSave(); + DungeonflagManager::sInstance->copyFromSave(flag); + SkipflagManager::sInstance->copyFromSave(); + EnemyflagManager::sInstance->copyFromSave(flag); +} + +void updateFlagForFlagIndex(u16 stage) { + SceneflagManager::sInstance->updateFlagindex(stage); + TBoxflagManager::sInstance->copyFromSave(stage); + EnemyflagManager::sInstance->updateFlagIndex(stage); + DungeonflagManager::sInstance->copyFromSave(stage); +} + +void commitAllFlagManagers() { + StoryflagManager::sInstance->commit(); + ItemflagManager::sInstance->commit(); + DungeonflagManager::sInstance->commit(); + SkipflagManager::sInstance->commit(); + SceneflagManager::sInstance->commit(); + TBoxflagManager::sInstance->commit(); + EnemyflagManager::sInstance->commit(); +} + +bool checkedMemcpy(void *dest, u32 destLen, const void *src, u32 count) { + if (dest == nullptr || src == nullptr || destLen < count || destLen > 0xFFFF) { + return true; + } else { + memcpy(dest, src, count); + return false; + } +} diff --git a/src/d/flag/flag_space.inc b/src/d/flag/flag_space.inc new file mode 100644 index 00000000..18e7c0ab --- /dev/null +++ b/src/d/flag/flag_space.inc @@ -0,0 +1,33 @@ +#include "common.h" +#include "d/flag/flag_managers.h" +#include "d/flag/flag_space.h" +#include "toBeSorted/file_manager.h" + +u16 *FlagSpace::getFlagPtrChecked() const { + filemanagerCheck(); + return mpFlags; +} +u16 *FlagSpace::getFlagPtrUnchecked() const { + return mpFlags; +} +void FlagSpace::unsetAll() { + setAllToZero(0, mCount); +} +void FlagSpace::setAllToZero(u16 offset, u16 flagCount) { + filemanagerCheck(); + memset(mpFlags + offset, 0, (u16)(flagCount * 2)); +} +void FlagSpace::copyFromSaveFile2(const u16 *pSaved, u16 offset, u16 flagCount) { + filemanagerCheck(); + checkedMemcpy(mpFlags + offset, (u16)(mCount * 2), pSaved, (u16)(flagCount * 2)); +} + +void FlagSpace::copyFromSaveFile(const u16 *pSaved, u16 offset, u16 flagCount) { + checkedMemcpy(mpFlags + offset, (u16)(mCount * 2), pSaved, (u16)(flagCount * 2)); +} +void FlagSpace::filemanagerCheck() const { + if (FileManager::sInstance->mIsFileUnk1[0]) { + return; + } + while (true) {} +} diff --git a/src/d/flag/itemflag_manager.inc b/src/d/flag/itemflag_manager.inc new file mode 100644 index 00000000..1e603342 --- /dev/null +++ b/src/d/flag/itemflag_manager.inc @@ -0,0 +1,29 @@ +#include "d/flag/itemflag_manager.h" + +u16 ItemflagManager::sFlags[0x40]; + +ItemflagManager *ItemflagManager::sInstance = nullptr; + +ItemflagManager::ItemflagManager() : mItemFlags(sFlags, 0x40) {} + +void ItemflagManager::copyFlagsFromSaveFirstTime() { + setFlagSizes(0x40, 0x80); + ItemStoryManagerBase::copyFromSave(); +} + +extern "C" FlagDefinition ItemflagManager__ITEMFLAG_DEFINITIONS[]; + +void ItemflagManager::setupFlagIndex() { + createFlagIndex(ItemflagManager__ITEMFLAG_DEFINITIONS, 0x1FE); +} + +void ItemflagManager::onDirty() {} + +bool ItemflagManager::commit() { + if (mDirty) { + doCommit_Priv(); + postCommit(); + return true; + } + return false; +} diff --git a/src/toBeSorted/sceneflag_manager.cpp b/src/d/flag/sceneflag_manager.inc similarity index 95% rename from src/toBeSorted/sceneflag_manager.cpp rename to src/d/flag/sceneflag_manager.inc index 0f7b7b89..5101567e 100644 --- a/src/toBeSorted/sceneflag_manager.cpp +++ b/src/d/flag/sceneflag_manager.inc @@ -1,16 +1,13 @@ -#include "toBeSorted/sceneflag_manager.h" - #include "common.h" -#include "libc.h" +#include "d/flag/sceneflag_manager.h" #include "toBeSorted/file_manager.h" - SceneflagManager *SceneflagManager::sInstance = nullptr; u16 SceneflagManager::sTempFlags[] = {}; u16 SceneflagManager::sSceneFlags[8] = {}; u16 SceneflagManager::sZoneFlags[0xFC] = {}; -void SceneflagManager::doNothing() {} +void SceneflagManager::init() {} void SceneflagManager::setShouldCommit(u16 flag) { mShouldCommit = 1; } @@ -20,14 +17,7 @@ SceneflagManager::SceneflagManager() mSceneIdx = 0xFFFF; mShouldCommit = 0; } -// SceneflagManager::SceneflagManager() -// { -// mSceneflags.init(sSceneFlags, ARRAY_LENGTH(sSceneFlags)); -// mTempflags.init(sTempFlags, ARRAY_LENGTH(sTempFlags)); -// mZoneflags.init(sZoneFlags, ARRAY_LENGTH(sZoneFlags)); -// mSceneIdx = 0xFFFF; -// mShouldCommit = 0; -// } + s32 SceneflagManager::isNotTempOrZoneFlag(u16 flag) { // return ((s32)flag - 0x80) < 0; return flag < 0x80; @@ -259,7 +249,7 @@ void SceneflagManager::unsetTempOrSceneflag(u16 flag) { setShouldCommit(flag); } } -s32 SceneflagManager::doCommit() { +s32 SceneflagManager::commit() { if (mSceneIdx == 0xFFFF) { return 0; } else if (mShouldCommit) { diff --git a/src/toBeSorted/skipflag_manager.cpp b/src/d/flag/skipflag_manager.inc similarity index 69% rename from src/toBeSorted/skipflag_manager.cpp rename to src/d/flag/skipflag_manager.inc index f0ffad77..96287018 100644 --- a/src/toBeSorted/skipflag_manager.cpp +++ b/src/d/flag/skipflag_manager.inc @@ -1,26 +1,9 @@ -#include "libc.h" -#include "toBeSorted/bitwise_flag_helper.h" +#include "common.h" +#include "d/flag/bitwise_flag_helper.h" +#include "d/flag/flag_managers.h" +#include "d/flag/flag_space.h" +#include "d/flag/skipflag_manager.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/flag_space.h" - -class SkipflagManager { -public: - bool mShouldCommit; - BitwiseFlagHelper mFlagHelper; - FlagSpace mFlagSpace; - - static u16 sSkipFlags[16]; - static SkipflagManager *sInstance; - - void copyFromSave(); - void setCommitFlag(u16 flag); - SkipflagManager(); - void unsetCommitFlag(); - void thunk_copyFromSave(); - void setFlag(u16 flag); - bool checkFlag(u16 flag); - bool commitFlags(); -}; // 0x80575408 SkipflagManager *SkipflagManager::sInstance = nullptr; @@ -28,7 +11,7 @@ SkipflagManager *SkipflagManager::sInstance = nullptr; u16 SkipflagManager::sSkipFlags[16] = {}; // 800bfba0 -void SkipflagManager::copyFromSave() { +void SkipflagManager::doCopyFromSave() { u16 *savedSkipflags = FileManager::sInstance->getSkipFlags(); mFlagSpace.copyFromSaveFile(savedSkipflags, 0, 0x10); } @@ -42,13 +25,13 @@ void SkipflagManager::setCommitFlag(u16 flag) { SkipflagManager::SkipflagManager() : mFlagSpace(sSkipFlags, ARRAY_LENGTH(sSkipFlags)), mShouldCommit(false) {} // 800bfc30 -void SkipflagManager::unsetCommitFlag() { +void SkipflagManager::init() { mShouldCommit = false; } // 800bfc40 -void SkipflagManager::thunk_copyFromSave() { - SkipflagManager::copyFromSave(); +void SkipflagManager::copyFromSave() { + doCopyFromSave(); } // 800bfc50 @@ -70,7 +53,7 @@ bool SkipflagManager::checkFlag(u16 flag) { } // 800bfd90 -bool SkipflagManager::commitFlags() { +bool SkipflagManager::commit() { if (mShouldCommit) { FileManager *instance = FileManager::sInstance; instance->setSkipFlagsChecked(mFlagSpace.getFlagPtrUnchecked(), 0, 0x10); diff --git a/src/d/flag/storyflag_manager.inc b/src/d/flag/storyflag_manager.inc new file mode 100644 index 00000000..e4cd30f4 --- /dev/null +++ b/src/d/flag/storyflag_manager.inc @@ -0,0 +1,32 @@ +#include "d/flag/storyflag_manager.h" + +u16 StoryflagManager::sFlags[0x80]; +StoryflagManager *StoryflagManager::sInstance = nullptr; + +StoryflagManager::StoryflagManager() : mStoryFlags(sFlags, 0x80) {} + +void StoryflagManager::copyFlagsFromSaveFirstTime() { + setFlagSizes(0x80, 0x100); + ItemStoryManagerBase::copyFromSave(); +} + +extern "C" FlagDefinition StoryflagManager__STORYFLAG_DEFINITIONS[]; + +void StoryflagManager::setupFlagIndex() { + createFlagIndex(StoryflagManager__STORYFLAG_DEFINITIONS, 0x4B1); +} + +void StoryflagManager::onDirty() {} + +bool StoryflagManager::commit() { + if (mDirty) { + doCommit_Priv(); + postCommit(); + return true; + } + return false; +} + +void StoryflagManager::unsetFlag(u16 flag) { + ItemStoryManagerBase::unsetFlag(flag); +} diff --git a/src/d/flag/tboxflag_manager.inc b/src/d/flag/tboxflag_manager.inc new file mode 100644 index 00000000..a00ac045 --- /dev/null +++ b/src/d/flag/tboxflag_manager.inc @@ -0,0 +1,54 @@ +#include "d/flag/tboxflag_manager.h" +#include "toBeSorted/file_manager.h" + +TBoxflagManager *TBoxflagManager::sInstance = nullptr; +u16 TBoxflagManager::sTBoxFlags[2] = {}; + +/* 0x800BE810 */ +void TBoxflagManager::doCommit() { + if (mSceneIndex != 0xFFFF) { + FileManager::getInstance()->setTBoxFlags(mFlagSpace.getFlagPtrUnchecked(), mSceneIndex * 2, 2); + } +} + +/* 0x800BE870 */ +bool TBoxflagManager::checkUncommittedFlag(u16 flag) { + return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount); +} + +/* 0x800BE8E0 */ +TBoxflagManager::TBoxflagManager() : CommittableFlagManager(false), mFlagSpace(sTBoxFlags, ARRAY_LENGTH(sTBoxFlags)) { + mSceneIndex = 0xFFFF; +} + +/* 0x800BE920 */ +void TBoxflagManager::init() {} + +/* 0x800BE930 */ +void TBoxflagManager::copyFromSave(u32 sceneIndex) { + u16 idx = sceneIndex; + mSceneIndex = idx; + u16 *flags = FileManager::getInstance()->getTBoxFlagsConst(); + mFlagSpace.copyFromSaveFile2(flags + (idx * 2), 0, 2); +} + +/* 0x800BE990 */ +bool TBoxflagManager::checkFlag(u16 sceneIndex, u16 flag) { + s32 actualFlag = (flag + sceneIndex * 0x20); + return mFlagHelper.checkFlag( + actualFlag / 16, flag % 16, FileManager::getInstance()->getTBoxFlagsConst(), getFlagCount() + ); +} + +/* 0x800BEA30 */ +u16 TBoxflagManager::getFlagCount() const { + return 0x200; +} + +/* 0x800BEA40 */ +void TBoxflagManager::setFlag(u16 flag) { + if (checkUncommittedFlag2(flag) != 1) { + mFlagHelper.setFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrChecked(), mFlagSpace.mCount); + setNeedsCommit(true); + } +} diff --git a/src/d/lyt/d_lyt_common_arrow.cpp b/src/d/lyt/d_lyt_common_arrow.cpp index 438bbb94..ad0b028f 100644 --- a/src/d/lyt/d_lyt_common_arrow.cpp +++ b/src/d/lyt/d_lyt_common_arrow.cpp @@ -1,15 +1,15 @@ #include "d/lyt/d_lyt_common_arrow.h" +#include "d/d_cs_base.h" +#include "d/lyt/d_structd.h" +#include "rvl/MTX/mtx.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" - STATE_DEFINE(dLytCommonArrow_c, None); STATE_DEFINE(dLytCommonArrow_c, In); STATE_DEFINE(dLytCommonArrow_c, Wait); STATE_DEFINE(dLytCommonArrow_c, Out); -f32 arrow_fs[0x20]; - static const d2d::LytBrlanMapping brlanMap[] = { { "commonArrow_00_in.brlan", "G_inOut_00"}, { "commonArrow_00_loop.brlan", "G_loop_00"}, @@ -22,6 +22,19 @@ static const d2d::LytBrlanMapping brlanMap[] = { { "commonArrow_00_out.brlan", "G_inOut_00"}, }; +#define ANIM_IN 0 +#define ANIM_LOOP 1 +#define ANIM_TYPE 2 +#define ANIM_ONOFF_L 3 +#define ANIM_ONOFF_R 4 + +#define ANIM_DECIDE_OFFSET 5 + +#define ANIM_DECIDE_L 5 +#define ANIM_DECIDE_R 6 +#define ANIM_INPUT 7 +#define ANIM_OUT 8 + dLytCommonArrow_c::dLytCommonArrow_c() : mStateMgr(*this, sStateID::null) {} bool dLytCommonArrow_c::init() { @@ -31,22 +44,22 @@ bool dLytCommonArrow_c::init() { mLytBase.mPriority = 0x86; for (int i = 0; i < 9; i++) { - field_0x440[i].init(brlanMap[i].mFile, &mResAcc, mLytBase.getLayout(), brlanMap[i].mName); + mAnmGroups[i].init(brlanMap[i].mFile, &mResAcc, mLytBase.getLayout(), brlanMap[i].mName); } - field_0x680.fn_80065E70(mLytBase.getLayout()->GetRootPane(), 1, 0, 0); - d2d::dLytStructDList::sInstance->appendToList2(&field_0x680); - field_0x6A8 = mLytBase.findBounding("B_arrowL_00"); - field_0x6AC = mLytBase.findBounding("B_arrowR_00"); + mStructD.fn_80065E70(mLytBase.getLayout()->GetRootPane(), 1, 0, 0); + d2d::dLytStructDList::sInstance->appendToList2(&mStructD); + mBoundingL = mLytBase.findBounding("B_arrowL_00"); + mBoundingR = mLytBase.findBounding("B_arrowR_00"); mStateMgr.changeState(StateID_None); setState(0); return true; } bool dLytCommonArrow_c::fn_80168490() { - d2d::dLytStructDList::sInstance->removeFromList2(&field_0x680); + d2d::dLytStructDList::sInstance->removeFromList2(&mStructD); mLytBase.unbindAnims(); for (int i = 0; i < 9; i++) { - field_0x440[i].afterUnbind(); + mAnmGroups[i].afterUnbind(); } return true; } @@ -54,11 +67,11 @@ bool dLytCommonArrow_c::fn_80168490() { bool dLytCommonArrow_c::fn_80168500() { mStateMgr.executeState(); if (!mStateMgr.getStateID()->isEqual(StateID_None)) { - field_0x440[1].play(); + mAnmGroups[ANIM_LOOP].play(); } mLytBase.calc(); - field_0x680.field_0x22 = 0; - field_0x680.fn_80065F70(); + mStructD.field_0x22 = 0; + mStructD.fn_80065F70(); field_0x6BC = field_0x6B8; return true; } @@ -71,7 +84,7 @@ bool dLytCommonArrow_c::addToDrawList() { } void dLytCommonArrow_c::setState(s32 state) { - field_0x6B0 = state; + mType = state; if (state == 0) { mLytBase.mPriority = 0x86; } else { @@ -79,24 +92,25 @@ void dLytCommonArrow_c::setState(s32 state) { } } -void dLytCommonArrow_c::fn_80168640(f32 *arg) { - // TODO - mLytBase.getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC3(arg[0], arg[1], 0.0f)); +void dLytCommonArrow_c::setTranslate(const Vec *arg) { + nw4r::math::VEC3 v(*arg); + v.z = 0.0f; + mLytBase.getLayout()->GetRootPane()->SetTranslate(v); } -bool dLytCommonArrow_c::fn_80168680() { +bool dLytCommonArrow_c::requestIn() { if (!mStateMgr.getStateID()->isEqual(StateID_None)) { return false; } - field_0x6C8 = 1; + mInRequested = 1; return true; } -bool dLytCommonArrow_c::fn_801686F0() { +bool dLytCommonArrow_c::requestOut() { if (!mStateMgr.getStateID()->isEqual(StateID_Wait)) { return false; } - field_0x6C9 = 1; + mOutRequested = 1; return true; } @@ -108,13 +122,13 @@ bool dLytCommonArrow_c::fn_80168760() { return false; } -void dLytCommonArrow_c::fn_80168790(s32 idx, f32 frame) { - d2d::AnmGroup_c *s = &field_0x440[idx]; +void dLytCommonArrow_c::displayElement(s32 idx, f32 frame) { + d2d::AnmGroup_c *s = &mAnmGroups[idx]; s->setFrameAndControlThings(frame); } void dLytCommonArrow_c::fn_80168800(s32 idx) { - field_0x440[idx].unbind(); + mAnmGroups[idx].unbind(); } void dLytCommonArrow_c::fn_80168810(d2d::AnmGroup_c *ctrl) { @@ -127,50 +141,73 @@ void dLytCommonArrow_c::fn_80168810(d2d::AnmGroup_c *ctrl) { } } -void dLytCommonArrow_c::fn_80168880() {} +extern "C" u8 lbl_80572D10; + +void dLytCommonArrow_c::fn_80168880() { + int i = -1; + if (lbl_80572D10 == 0) { + field_0x6B4 = 2; + return; + } + + d2d::dLytStructD *thing = dCsBase_c::sInstance->getUnk(); + if (thing != nullptr && thing->getType() == 'lyt ') { + if (thing->field_0x24 == mBoundingL) { + i = 0; + } else if (thing->field_0x24 == mBoundingR) { + i = 1; + } + } + + if (i >= 0) { + field_0x6B4 = i; + } else { + field_0x6B4 = 2; + } +} void dLytCommonArrow_c::initializeState_None() { mLytBase.unbindAnims(); - field_0x6C8 = 0; - field_0x6C9 = 0; + mInRequested = 0; + mOutRequested = 0; field_0x6CA = 0; field_0x6CB = 0; field_0x6B4 = 2; field_0x6B8 = 2; field_0x6BC = 2; field_0x6C0 = 2; - field_0x6C4 = 0; - fn_80168790(0, 0.0f); + mTimer = 0; + displayElement(ANIM_IN, 0.0f); field_0x6CC = 1; } void dLytCommonArrow_c::executeState_None() { - if (field_0x6C8 == 1) { + if (mInRequested == 1) { mStateMgr.changeState(StateID_In); } } void dLytCommonArrow_c::finalizeState_None() { - field_0x6C8 = 0; - fn_80168790(1, 0.0f); + mInRequested = 0; + displayElement(ANIM_LOOP, 0.0f); } void dLytCommonArrow_c::initializeState_In() { - field_0x6C4 = 0; + mTimer = 0; field_0x6CB = 1; - f32 tmp = 0.0f; - if (field_0x6B0 == 1) { - tmp = 1.0f; + f32 anmType = 0.0f; + if (mType == 1) { + anmType = 1.0f; } - fn_80168790(2, tmp); - fn_80168790(3, 0.0f); - fn_80168790(4, 0.0f); - fn_80168790(7, 0.0f); + displayElement(ANIM_TYPE, anmType); + displayElement(ANIM_ONOFF_L, 0.0f); + displayElement(ANIM_ONOFF_R, 0.0f); + displayElement(ANIM_INPUT, 0.0f); } void dLytCommonArrow_c::executeState_In() { - switch (field_0x6C4) { + switch (mTimer) { case 0: { - d2d::AnmGroup_c *s = &field_0x440[0]; + d2d::AnmGroup_c *s = &mAnmGroups[ANIM_IN]; if (s->isEndReached() == 1) { - field_0x6C4 += 1; + mTimer += 1; field_0x6CA = 1; } else { s->play(); @@ -183,43 +220,92 @@ void dLytCommonArrow_c::executeState_In() { } } void dLytCommonArrow_c::finalizeState_In() { - fn_80168800(0); + fn_80168800(ANIM_IN); } void dLytCommonArrow_c::initializeState_Wait() { - field_0x6C4 = 0; + mTimer = 0; } + +extern "C" void SmallSoundManager__playSound(void *, u32); +extern "C" void *SOUND_EFFECT_SOUND_MGR; + void dLytCommonArrow_c::executeState_Wait() { - if (field_0x6C9 == 1) { + if (mOutRequested == 1) { mStateMgr.changeState(StateID_Out); return; } fn_80168880(); if (field_0x6B8 == 0) { - field_0x440[3].play(); - fn_80168810(&field_0x440[4]); + d2d::AnmGroup_c &g = mAnmGroups[ANIM_ONOFF_L]; + g.play(); + fn_80168810(&mAnmGroups[ANIM_ONOFF_R]); } else if (field_0x6B8 == 1) { - field_0x440[4].play(); - fn_80168810(&field_0x440[3]); + d2d::AnmGroup_c &g = mAnmGroups[ANIM_ONOFF_R]; + g.play(); + fn_80168810(&mAnmGroups[ANIM_ONOFF_L]); + } else { + fn_80168810(&mAnmGroups[ANIM_ONOFF_L]); + fn_80168810(&mAnmGroups[ANIM_ONOFF_R]); + } + + d2d::AnmGroup_c &g2 = mAnmGroups[ANIM_INPUT]; + if (field_0x6CC != 0) { + fn_80168810(&g2); } else { - fn_80168810(&field_0x440[3]); - fn_80168810(&field_0x440[4]); + g2.play(); + } + + switch (mTimer) { + case 0: + if (field_0x6C0 != 2) { + displayElement(field_0x6C0 + ANIM_DECIDE_OFFSET, 0.0f); + if (field_0x6C0 == 0) { + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x142D); + } else { + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x142E); + } + mTimer++; + } + break; + case 1: { + d2d::AnmGroup_c &g = mAnmGroups[field_0x6C0 + ANIM_DECIDE_OFFSET]; + if (g.isEndReached() == true) { + mTimer++; + field_0x6CA = 1; + } + g.play(); + } break; + case 2: + fn_80168800(field_0x6C0 + ANIM_DECIDE_OFFSET); + mTimer = 0; + field_0x6CA = 0; + field_0x6C0 = 2; + break; + } + + if (field_0x6BC != field_0x6B8 && field_0x6B8 != 2) { + if (field_0x6B8 == 0) { + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x142B); + } else { + SmallSoundManager__playSound(SOUND_EFFECT_SOUND_MGR, 0x142C); + } } } void dLytCommonArrow_c::finalizeState_Wait() {} void dLytCommonArrow_c::initializeState_Out() { - field_0x6C4 = 0; - fn_80168790(8, 0.0f); - field_0x6C9 = 0; + mTimer = 0; + displayElement(ANIM_OUT, 0.0f); + mOutRequested = 0; } void dLytCommonArrow_c::executeState_Out() { - switch (field_0x6C4) { + switch (mTimer) { case 0: { - d2d::AnmGroup_c *s = &field_0x440[8]; + d2d::AnmGroup_c *s = &mAnmGroups[ANIM_OUT]; if (s->isEndReached() == 1) { - field_0x6C4 = 1; + mTimer = 1; field_0x6CA = 1; } s->play(); diff --git a/src/d/tg/d_t_switch.cpp b/src/d/tg/d_t_switch.cpp index c576d9d6..f7c1141b 100644 --- a/src/d/tg/d_t_switch.cpp +++ b/src/d/tg/d_t_switch.cpp @@ -2,7 +2,7 @@ #include "c/c_math.h" #include "toBeSorted/event.h" -#include "toBeSorted/sceneflag_manager.h" +#include "d/flag/sceneflag_manager.h" #include "toBeSorted/scgame.h" diff --git a/src/toBeSorted/counters/counter.cpp b/src/toBeSorted/counters/counter.cpp index 7bda499c..89b5b60e 100644 --- a/src/toBeSorted/counters/counter.cpp +++ b/src/toBeSorted/counters/counter.cpp @@ -1,6 +1,6 @@ #include "toBeSorted/counters/counter.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/itemflag_manager.h" /* 8016cc40 */ s32 Counter::checkedAdd(s32 num) { s32 uncommitted = getUncommittedValue(); diff --git a/src/toBeSorted/counters/rupee_counter.cpp b/src/toBeSorted/counters/rupee_counter.cpp index 0ccfa6eb..1a96ae83 100644 --- a/src/toBeSorted/counters/rupee_counter.cpp +++ b/src/toBeSorted/counters/rupee_counter.cpp @@ -1,5 +1,5 @@ #include "toBeSorted/counters/counter.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/itemflag_manager.h" static u16 getBaseCapacity(); static u16 getExtraWalletCapacity(); @@ -28,7 +28,7 @@ struct WalletStruct { }; const WalletStruct *wallet = &wallet_definitions[3]; for (; i < 4; i++, wallet--) { - if (ItemflagManager::sInstance->getFlag(wallet->flag)) { + if (ItemflagManager::sInstance->getFlagDirect(wallet->flag)) { return wallet->capacity; } } diff --git a/src/toBeSorted/dowsing_target.cpp b/src/toBeSorted/dowsing_target.cpp index 48ae7952..41acf5bf 100644 --- a/src/toBeSorted/dowsing_target.cpp +++ b/src/toBeSorted/dowsing_target.cpp @@ -2,8 +2,8 @@ #include "c/c_math.h" #include "m/m_mtx.h" -#include "nw4r/ut/ut_LinkList.h" -#include "toBeSorted/item_story_flag_manager.h" +#include "d/flag/itemflag_manager.h" +#include "d/flag/storyflag_manager.h" #include "toBeSorted/tlist.h" diff --git a/src/toBeSorted/dungeonflag_manager.cpp b/src/toBeSorted/dungeonflag_manager.cpp deleted file mode 100644 index 7fcab742..00000000 --- a/src/toBeSorted/dungeonflag_manager.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "libc.h" -#include "toBeSorted/bitwise_flag_helper.h" -#include "toBeSorted/file_manager.h" -#include "toBeSorted/flag_space.h" -#include "toBeSorted/unk_flag_stuff.h" - - -// TODO move -extern "C" UnkFlagDefinition DungeonflagManager__FLAG_DEFINITIONS[]; - -class DungeonflagManager { -public: - bool mShouldCommit; - u16 mStageIndex; - UnkFlagStuff *mFlagStuff; - FlagSpace mFlagSpace; - - static u16 sDungeonFlags[8]; - // static DungeonflagManager *sInstance; - - void copyFromSave(s16 flag); - void copyFromSave(u16 flagIndex); - void setCommitFlag(u16 flag); - DungeonflagManager(); - void setupFlagStuff(); - void setToValue(u16 flag, u32 value); - void setFlag(u16 flag); - u32 getDungeonFlag(u16 flag); - bool doCommit(); - - /** inline shenanigans to get copyFromSave to match */ - static inline u16 *saveFilePtr(u16 flagIndex) { - u32 offset = (flagIndex & 0x1fff) * 8; - return FileManager::sInstance->getDungeonFlagsConst() + offset; - } -}; - -/** 80575404 */ -// DungeonflagManager *DungeonflagManager::sInstance = nullptr; - -/** 805a9c58 */ -u16 DungeonflagManager::sDungeonFlags[8] = {}; - -/** 800bf8d0 */ -void DungeonflagManager::copyFromSave(u16 flagIndex) { - mFlagSpace.copyFromSaveFile(saveFilePtr(flagIndex), 0, 0x8); -} - -/** 800bf930 */ -void DungeonflagManager::setCommitFlag(u16 flag) { - mShouldCommit = true; -} - -/** 0x800bf940 */ -DungeonflagManager::DungeonflagManager() - : mShouldCommit(false), mStageIndex(-1), mFlagStuff(nullptr), - mFlagSpace(sDungeonFlags, ARRAY_LENGTH(sDungeonFlags)) {} - -/** 800bf980 */ -void DungeonflagManager::setupFlagStuff() { - mFlagStuff = new UnkFlagStuff(0x11, DungeonflagManager__FLAG_DEFINITIONS); - mShouldCommit = false; -} - -/** 800bf9e0 */ -void DungeonflagManager::copyFromSave(s16 flag) { - mStageIndex = flag; - copyFromSave((u16)flag); -} - -/** 800bf9f0 */ -void DungeonflagManager::setToValue(u16 flag, u32 value) { - u16 *data = mFlagSpace.getFlagPtrChecked(); - mFlagStuff->setCounterOrFlag(flag, data, 8, value); - setCommitFlag(flag); -} - -/** 800bfa60 */ -void DungeonflagManager::setFlag(u16 flag) { - u16 *data = mFlagSpace.getFlagPtrChecked(); - mFlagStuff->setCounterOrFlag(flag, data, 8, 1); - setCommitFlag(flag); -} - -/** 800fbac0 */ -u32 DungeonflagManager::getDungeonFlag(u16 flag) { - u16 *data = mFlagSpace.getFlagPtrUnchecked(); - return mFlagStuff->getCounterOrFlag(flag, data, 8); -} - -/** 800fbb10 */ -bool DungeonflagManager::doCommit() { - FileManager *instance; - u16 idx = mStageIndex; - if (idx == 0xFFFF) { - return false; - } else if (mShouldCommit) { - instance = FileManager::sInstance; - u16 *ptr = mFlagSpace.getFlagPtrUnchecked(); - instance->setDungeonFlags(ptr, (idx & 0x1fff) * 8, 0x08); - mShouldCommit = false; - return true; - } - return false; -} diff --git a/src/toBeSorted/file_manager.cpp b/src/toBeSorted/file_manager.cpp index 394975d5..cc5376dd 100644 --- a/src/toBeSorted/file_manager.cpp +++ b/src/toBeSorted/file_manager.cpp @@ -80,7 +80,7 @@ u16 *FileManager::getStoryFlagsMut() { return getCurrentFile()->getStoryFlags1(); } /* 8000A3B0 */ u16 *FileManager::getItemFlagsMut() {} -/* 8000A3E0 */ u16 *FileManager::getItemFlagsConst() {} +/* 8000A3E0 */ const u16 *FileManager::getItemFlagsConst() {} /* 8000A430 */ u16 *FileManager::getDungeonFlagsMut() {} /* 8000A460 */ u16 *FileManager::getDungeonFlagsConst() {} /* 8000A4B0 */ u16 *FileManager::getSceneFlagsMut() {} @@ -234,7 +234,7 @@ u16 *FileManager::getStoryFlagsMut() { /* 8000CAD0 */ bool FileManager::isNew_FileA() {} /* 8000CB00 */ void FileManager::setSceneFlagIndex(u16 idx) {} -/* 8000CB30 */ u16 FileManager::getSceneFlagIndex() {} +/* 8000CB30 */ u32 FileManager::getSceneFlagIndex() {} /* 8000CB80 */ s32 FileManager::getFileAreaIndex() {} /* 8000CBD0 */ void FileManager::fn_8000CBD0(u8) {} diff --git a/src/toBeSorted/flag_space.cpp b/src/toBeSorted/flag_space.cpp deleted file mode 100644 index f915eaa7..00000000 --- a/src/toBeSorted/flag_space.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "toBeSorted/flag_space.h" - -#include "common.h" -#include "libc.h" -#include "toBeSorted/file_manager.h" - -u16 *FlagSpace::getFlagPtrChecked() { - filemanagerCheck(); - return mpFlags; -} -u16 *FlagSpace::getFlagPtrUnchecked() { - return mpFlags; -} -void FlagSpace::unsetAll() { - setAllToZero(0, mCount); -} -void FlagSpace::setAllToZero(u16 offset, u16 flagCount) { - filemanagerCheck(); - memset(mpFlags + offset, 0, (u16)(flagCount * 2)); -} -void FlagSpace::copyFromSaveFile2(u16 *pSaved, u16 offset, u16 flagCount) { - filemanagerCheck(); - checkedMemcpy(mpFlags + offset, mCount * 2, pSaved, flagCount * 2); -} - -void FlagSpace::copyFromSaveFile(u16 *pSaved, u16 offset, u16 flagCount) { - checkedMemcpy(mpFlags + offset, mCount * 2, pSaved, flagCount * 2); -} -void FlagSpace::filemanagerCheck() { - if (FileManager::sInstance->mIsFileUnk1[0]) { - return; - } - while (true) {} -} diff --git a/src/toBeSorted/misc_flag_managers.cpp b/src/toBeSorted/misc_flag_managers.cpp deleted file mode 100644 index d23b36ec..00000000 --- a/src/toBeSorted/misc_flag_managers.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "toBeSorted/misc_flag_managers.h" - -#include "common.h" -#include "libc.h" -#include "toBeSorted/bitwise_flag_helper.h" -#include "toBeSorted/file_manager.h" -#include "toBeSorted/flag_space.h" - - -/* 0x800BE7B0 */ -bool CommittableFlagManager::commitIfNecessary() { - if (mNeedsCommit) { - doCommit(); - mNeedsCommit = false; - return true; - } else { - return false; - } -} - -TBoxFlagManager *TBoxFlagManager::sInstance = nullptr; -u16 TBoxFlagManager::sTBoxFlags[2] = {}; - -/* 0x800BE810 */ -void TBoxFlagManager::doCommit() { - if (mSceneIndex != 0xFFFF) { - FileManager::getInstance()->setTBoxFlags(mFlagSpace.getFlagPtrUnchecked(), mSceneIndex * 2, 2); - } -} - -/* 0x800BE870 */ -bool TBoxFlagManager::checkUncommittedFlag(u16 flag) { - return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount); -} - -/* 0x800BE8E0 */ -TBoxFlagManager::TBoxFlagManager() : CommittableFlagManager(false), mFlagSpace(sTBoxFlags, ARRAY_LENGTH(sTBoxFlags)) { - mSceneIndex = 0xFFFF; -} - -/* 0x800BE920 */ -void TBoxFlagManager::init() {} - -/* 0x800BE930 */ -void TBoxFlagManager::copyFromSave(s16 sceneIndex) { - u16 idx = sceneIndex; - mSceneIndex = idx; - u16 *flags = FileManager::getInstance()->getTBoxFlagsConst(); - mFlagSpace.copyFromSaveFile2(flags + (idx * 2), 0, 2); -} - -/* 0x800BE990 */ -bool TBoxFlagManager::checkFlag(u16 sceneIndex, u16 flag) { - s32 actualFlag = (flag + sceneIndex * 0x20); - return mFlagHelper.checkFlag( - actualFlag / 16, flag % 16, FileManager::getInstance()->getTBoxFlagsConst(), getFlagCount() - ); -} - -/* 0x800BEA30 */ -u16 TBoxFlagManager::getFlagCount() const { - return 0x200; -} - -/* 0x800BEA40 */ -void TBoxFlagManager::setFlag(u16 flag) { - if (checkUncommittedFlag2(flag) != 1) { - mFlagHelper.setFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrChecked(), mFlagSpace.mCount); - setNeedsCommit(true); - } -} - -EnemyDefeatManager *EnemyDefeatManager::sInstance = nullptr; -u16 EnemyDefeatManager::sEnemyDefeatFlags[4096] = {}; - -/* 0x800BEAC0 */ -void EnemyDefeatManager::clearSavedFlags() { - u16 empty[0x1000]; - memset(empty, 0, 0x2000); - FileManager::getInstance()->setEnemyDefeatFlags(empty, 0, 0x1000); -} - -/* 0x800BEB00 */ -bool EnemyDefeatManager::checkUncommittedFlag(u16 flag) { - if (checkIsValidFlag(flag)) { - return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount); - } else { - return false; - } -} - -/* 0x800BEB80 */ -EnemyDefeatManager::EnemyDefeatManager() - : CommittableFlagManager(false), mFlagSpace(sEnemyDefeatFlags, ARRAY_LENGTH(sEnemyDefeatFlags)) {} - -/* 0x800BEBC0 */ -void EnemyDefeatManager::init() { - mSceneIndex = 0; - clearAll(); -} - -/* 0x800BEBD0 */ -void EnemyDefeatManager::copyFromSave(u16 sceneIndex) { - mSceneIndex = sceneIndex; - u16 count = mFlagSpace.mCount; - u16 *flags = FileManager::getInstance()->getEnemyDefeatFlagsConst(); - mFlagSpace.copyFromSaveFile(flags, 0, count); -} - -/* 0x800BEC30 */ -void EnemyDefeatManager::updateFlagIndex(u16 sceneIndex) { - if (mSceneIndex == sceneIndex) { - return; - } - mSceneIndex = sceneIndex; - clearAll(); -} - -/* 0x800BEC50 */ -void EnemyDefeatManager::clearAll() { - clearSavedFlags(); - mFlagSpace.unsetAll(); -} - -/* 0x800BEC90 */ -bool EnemyDefeatManager::checkIsValidFlag(u16 flag) { - return flag < 0xFFFF; -} - -/* 0x800BECB0 */ -bool EnemyDefeatManager::checkFlag(u16 flag) { - if (!checkIsValidFlag(flag)) { - return false; - } else { - u16 *pData = FileManager::getInstance()->getEnemyDefeatFlagsConst(); - return mFlagHelper.checkFlag(flag / 16, flag % 16, pData, getFlagCount()); - } -} - -/* 0x800BED50 */ -u16 EnemyDefeatManager::getFlagCount() const { - return 0x1000; -} - -/* 0x800BED60 */ -void EnemyDefeatManager::setFlag(u16 flag) { - if (checkUncommittedFlag2(flag) != 1 && checkIsValidFlag(flag)) { - mFlagHelper.setFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrChecked(), mFlagSpace.mCount); - setNeedsCommit(true); - } -}