From 633e81ee5fc2c52a3a0c6239a4efe04e8cc999b9 Mon Sep 17 00:00:00 2001 From: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:06:49 +0100 Subject: [PATCH 1/3] Sync retail state ownership with the native 64-bit port Carry the shared ECL, Supervisor, HSCR, and GameManager fixes from main into the portable layout. Preserve the native pointer and wire-format branches, update the exact manifests and GDB consumers, and retire the corresponding legacy i386 aliases. Source commits: 12dde807, 831a5719, 3669a7fb. --- config/data-contracts.toml | 10 + config/globals.csv | 2 +- config/match-units.toml | 325 ++++++++++++++------------ config/reccmp-globals.csv | 8 +- scripts/check-match-config.py | 3 + scripts/gdb/laser-visual-observer.py | 3 +- scripts/gdb/portable-layout-checks.py | 4 +- src/AsciiManager.cpp | 4 +- src/EclDependencies.cpp | 8 +- src/EclExIns.cpp | 2 +- src/EclGlobals.cpp | 10 +- src/EclManager.hpp | 24 +- src/EclOperands.hpp | 9 - src/EclOperandsFloat.cpp | 24 +- src/EclOperandsInt.cpp | 24 +- src/EclRunHigh.inl | 7 +- src/EnemyManager.cpp | 44 ++-- src/EnemyManagerUpdate.cpp | 8 +- src/EnemyTimeline.cpp | 8 +- src/GameManager.cpp | 2 +- src/GameManager.hpp | 1 + src/GameManagerScoreProbe.cpp | 2 +- src/Gui.cpp | 22 +- src/ItemManager.cpp | 3 +- src/Player.cpp | 6 +- src/ReplayManager.cpp | 2 +- src/ResultScreen.cpp | 2 +- src/ScoreDat.hpp | 3 + src/Spellcard.cpp | 5 +- src/StageMenuProbe.cpp | 4 +- src/Supervisor.cpp | 8 +- src/Supervisor.hpp | 4 +- src/modern/linux/th08-layout.ld | 8 - 33 files changed, 304 insertions(+), 295 deletions(-) diff --git a/config/data-contracts.toml b/config/data-contracts.toml index 21660956..93edd9c7 100644 --- a/config/data-contracts.toml +++ b/config/data-contracts.toml @@ -21,6 +21,16 @@ size = 36 data_hex = "40420f0060e3160080841e00a0252600a0252600c0c62d0000093d00808d5b00a09f6500" evidence = "Observed nine-dword target table and native owner audit; docs/OWNER_AUDIT.md." +[[contracts]] +name = "gui-stage-music-contexts" +kind = "bytes" +object = "build/Gui.obj" +symbol = "?g_GuiStageMusicContexts@th08@@3PAUGuiStageMusicContextSet@1@A" +target_address = 0x004C7240 +size = 108 +data_hex = "0100000002000000000000000300000004000000000000000500000006000000000000000700000008000000000000000700000009000000000000000a0000000b000000000000000c0000000d0000000f0000000c0000000e0000000f000000100000001100000000000000" +evidence = "Nine three-dword retail rows consumed by gameplay setup and GUI music dispatch; docs/POSITION_INDEPENDENCE.md." + [[contracts]] name = "replay-difficulty-labels" kind = "pointer_array" diff --git a/config/globals.csv b/config/globals.csv index e3d9a34a..e66eaa28 100644 --- a/config/globals.csv +++ b/config/globals.csv @@ -9,6 +9,7 @@ _g_SoundBufferIdxVol, 0x004c8040 _g_SFXList, 0x004c81b0 _g_Background, 0x004e4030 _g_Spellcard, 0x004ea670 +_g_EclRuntime, 0x004eccb8 _g_EffectManager, 0x004ece60 _g_EffectManagerCalcChain, 0x00577ebc _g_EffectManagerDrawChain, 0x00577edc @@ -31,4 +32,3 @@ _g_Player, 0x017d5ef8 _g_ScreenEffect, 0x018b8a30 _g_SoundPlayer, 0x018b8a68 _g_AnmManager, 0x018bdc90 -_g_EclGameTimeScaleFlags, 0x017ce8fc diff --git a/config/match-units.toml b/config/match-units.toml index 022edf60..00211531 100644 --- a/config/match-units.toml +++ b/config/match-units.toml @@ -4204,7 +4204,7 @@ target = 0x0041F420 [[units.relocations]] offset = 0x4450 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -4442,7 +4442,7 @@ target = 0x0041F420 [[units.relocations]] offset = 0x4AA5 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -4839,13 +4839,15 @@ target = 0x00423130 offset = 0x5219 type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x01649508 +target = 0x0160F508 +addend = 0x3DE04 [[units.relocations]] offset = 0x5225 type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x01649508 +target = 0x0160F508 +addend = 0x3DE04 [[units.relocations]] offset = 0x5245 @@ -7143,36 +7145,37 @@ target = 0x004A3E70 [[units.relocations]] offset = 0x413 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x168 [[units.relocations]] offset = 0x41D type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x4 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x16C [[units.relocations]] offset = 0x427 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x8 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x170 [[units.relocations]] offset = 0x431 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0xC +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x174 [[units.relocations]] offset = 0x43C type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x10 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x178 [[units.relocations]] offset = 0x441 @@ -7183,9 +7186,9 @@ target = 0x004A3E70 [[units.relocations]] offset = 0x44C type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x14 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x17C [[units.relocations]] offset = 0x451 @@ -7196,9 +7199,9 @@ target = 0x004A3E70 [[units.relocations]] offset = 0x45C type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x18 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x180 [[units.relocations]] offset = 0x461 @@ -7209,9 +7212,9 @@ target = 0x004A3E70 [[units.relocations]] offset = 0x46C type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x1C +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x184 [[units.relocations]] offset = 0x471 @@ -8172,29 +8175,30 @@ addend = 0x3DE2C [[units.relocations]] offset = 0x200 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x168 [[units.relocations]] offset = 0x207 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x4 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x16C [[units.relocations]] offset = 0x20E type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x8 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x170 [[units.relocations]] offset = 0x215 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0xC +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x174 [[units.relocations]] offset = 0x224 @@ -8516,57 +8520,58 @@ addend = 0x3DBA9 [[units.relocations]] offset = 0x283 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x168 [[units.relocations]] offset = 0x28E type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x4 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x16C [[units.relocations]] offset = 0x299 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x8 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x170 [[units.relocations]] offset = 0x2A4 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0xC +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x174 [[units.relocations]] offset = 0x2AF type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x10 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x178 [[units.relocations]] offset = 0x2BA type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x14 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x17C [[units.relocations]] offset = 0x2C5 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x18 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x180 [[units.relocations]] offset = 0x2D0 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x1C +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x184 [[units.relocations]] offset = 0x44D @@ -9342,30 +9347,30 @@ addend = 0x2B4 [[units.relocations]] offset = 0x206 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x10 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x178 [[units.relocations]] offset = 0x210 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x14 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x17C [[units.relocations]] offset = 0x21A type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x18 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x180 [[units.relocations]] offset = 0x224 type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 -addend = 0x1C +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x184 [[units.relocations]] offset = 0x2B8 @@ -9782,7 +9787,7 @@ target = 0x0042C3B0 [[units.relocations]] offset = 0x176 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -9794,7 +9799,7 @@ target = 0x0042DFB0 [[units.relocations]] offset = 0x19F type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -9857,7 +9862,7 @@ target = 0x0042C420 [[units.relocations]] offset = 0x334 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -10782,7 +10787,7 @@ addend = 0x2E24 [[units.relocations]] offset = 0x1496 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -14372,7 +14377,8 @@ target = 0x004B7108 offset = 0x41E type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F504 +target = 0x0160F508 +addend = 0x3DDC4 [[units.relocations]] offset = 0x423 @@ -19968,7 +19974,8 @@ target = 0x0160F508 offset = 0x109 type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F504 +target = 0x0160F508 +addend = 0x3D818 [[units.relocations]] offset = 0x116 @@ -19986,7 +19993,8 @@ target = 0x0160F508 offset = 0x123 type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F504 +target = 0x0160F508 +addend = 0x3D818 [[units.relocations]] offset = 0x130 @@ -20143,7 +20151,8 @@ target = 0x0160F508 offset = 0x107 type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F504 +target = 0x0160F508 +addend = 0x3D828 [[units.relocations]] offset = 0x114 @@ -20161,7 +20170,8 @@ target = 0x0160F508 offset = 0x121 type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F504 +target = 0x0160F508 +addend = 0x3D828 [[units.relocations]] offset = 0x12E @@ -55054,14 +55064,16 @@ target = 0x0160F508 [[units.relocations]] offset = 0x1BC type = "DIR32" -symbol = "?g_MaxValuePointItemsCollected@th08@@3HA" -target = 0x0164CF9C +symbol = "?g_GameManager@th08@@3UGameManager@1@A" +target = 0x0160F508 +addend = 0x3DA94 [[units.relocations]] offset = 0x1C4 type = "DIR32" -symbol = "?g_MaxValuePointItemsCollected@th08@@3HA" -target = 0x0164CF9C +symbol = "?g_GameManager@th08@@3UGameManager@1@A" +target = 0x0160F508 +addend = 0x3DA94 [[units.relocations]] offset = 0x1C9 @@ -57152,8 +57164,9 @@ target = 0x004065F0 [[units.relocations]] offset = 0x71 type = "DIR32" -symbol = "?g_GuiFullPowerModeFrames@th08@@3HA" -target = 0x017CE8CC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 [[units]] name = "item-collect-power-small" @@ -58789,7 +58802,7 @@ target = 0x0040B900 [[units.relocations]] offset = 0x7B type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -60675,7 +60688,7 @@ target = 0x0040B900 [[units.relocations]] offset = 0x130 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -60699,7 +60712,7 @@ target = 0x004C73CC [[units.relocations]] offset = 0x154 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -60729,7 +60742,7 @@ target = 0x004C7418 [[units.relocations]] offset = 0x18A type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -60753,7 +60766,7 @@ target = 0x004C73F0 [[units.relocations]] offset = 0x1B0 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -60765,32 +60778,32 @@ target = 0x00418330 [[units.relocations]] offset = 0x1C9 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] offset = 0x1D2 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 addend = 0x4 [[units.relocations]] offset = 0x1E1 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] offset = 0x1EB type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] offset = 0x1F4 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 addend = 0x4 @@ -67463,8 +67476,9 @@ target = 0x0045D550 [[units.relocations]] offset = 0x191 type = "DIR32" -symbol = "?g_GuiFullPowerModeFrames@th08@@3HA" -target = 0x017CE8CC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 # Spellcard exact candidate 0x00416B10 [[units]] @@ -68235,8 +68249,9 @@ target = 0x0045D550 [[units.relocations]] offset = 0x220 type = "DIR32" -symbol = "?g_GuiFullPowerModeFrames@th08@@3HA" -target = 0x017CE8CC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 # Ledger name: th08::Enemy::ResetBulletRankInfluence [[units]] @@ -68299,8 +68314,9 @@ target = 0x004065F0 [[units.relocations]] offset = 0x72 type = "DIR32" -symbol = "?g_GuiFullPowerModeFrames@th08@@3HA" -target = 0x017CE8CC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 # Ledger name: th08::Spellcard::StartSpell # Evidence: VC7 COFF auxiliary extent is 0x9B3 and ends at the target ret 0x20. @@ -68598,8 +68614,9 @@ target = 0x004065F0 [[units.relocations]] offset = 0x72 type = "DIR32" -symbol = "?g_GuiFullPowerModeFrames@th08@@3HA" -target = 0x017CE8CC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 # Ledger name: th08::Enemy::DetachFromParentChain @@ -68688,7 +68705,7 @@ target = 0x0042B2F0 [[units.relocations]] offset = 0x21C type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -72939,8 +72956,9 @@ target = 4569264 [[units.relocations]] offset = 5154 type = "DIR32" -symbol = "?g_GuiMessageScreenEffectDuration@th08@@3HA" -target = 24963276 +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 [[units.relocations]] offset = 5166 @@ -73600,8 +73618,9 @@ target = 4426353 [[units.relocations]] offset = 880 type = "DIR32" -symbol = "th08::g_GuiFullPowerModeFrames" -target = 24963276 +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 [[units.relocations]] offset = 903 @@ -76094,14 +76113,16 @@ target = 23385384 [[units.relocations]] offset = 60 type = "DIR32" -symbol = "?g_GuiMessageScreenEffectDuration@th08@@3HA" -target = 24963276 +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 [[units.relocations]] offset = 69 type = "DIR32" -symbol = "?g_GuiMessageScreenEffectDuration@th08@@3HA" -target = 24963276 +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 [[units]] name = "gui-draw-dialogue" @@ -83013,26 +83034,30 @@ target = 0x00439883 [[units.relocations]] offset = 1077 type = "DIR32" -symbol = "?g_PlayerDeathbombCount@th08@@3HA" -target = 0x0164CFAC +symbol = "?g_GameManager@th08@@3UGameManager@1@A" +target = 0x0160F508 +addend = 0x3DAA4 [[units.relocations]] offset = 1086 type = "DIR32" -symbol = "?g_PlayerDeathbombCount@th08@@3HA" -target = 0x0164CFAC +symbol = "?g_GameManager@th08@@3UGameManager@1@A" +target = 0x0160F508 +addend = 0x3DAA4 [[units.relocations]] offset = 1094 type = "DIR32" -symbol = "?g_PlayerNormalBombCount@th08@@3HA" -target = 0x0164CFA8 +symbol = "?g_GameManager@th08@@3UGameManager@1@A" +target = 0x0160F508 +addend = 0x3DAA0 [[units.relocations]] offset = 1103 type = "DIR32" -symbol = "?g_PlayerNormalBombCount@th08@@3HA" -target = 0x0164CFA8 +symbol = "?g_GameManager@th08@@3UGameManager@1@A" +target = 0x0160F508 +addend = 0x3DAA0 [[units.relocations]] offset = 1110 @@ -91909,7 +91934,8 @@ target = 0x00454269 offset = 0x91F type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F54C +target = 0x0160F508 +addend = 0x3DA04 [[units.relocations]] offset = 0x925 @@ -102847,7 +102873,7 @@ size = 0x49C [[units.relocations]] offset = 0xC3 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -102901,7 +102927,7 @@ target = 0x00577F20 [[units.relocations]] offset = 0x242 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -103005,7 +103031,7 @@ target = 0x0040B8E0 [[units.relocations]] offset = 0x135 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -103084,7 +103110,7 @@ target = 0x00577F20 [[units.relocations]] offset = 0x255 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -105153,8 +105179,9 @@ target = 0x004069F0 [[units.relocations]] offset = 0x5B0 type = "DIR32" -symbol = "?g_GuiMessageScreenEffectDuration@th08@@3HA" -target = 0x017CE8CC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x174 # Ledger name: th08::Gui::InitStageClearScreen @@ -105384,7 +105411,7 @@ target = 0x018B8A28 [[units.relocations]] offset = 0xEA type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -105396,7 +105423,7 @@ target = 0x00418450 [[units.relocations]] offset = 0xF8 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -105429,7 +105456,7 @@ target = 0x018B8A28 [[units.relocations]] offset = 0xC9 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -105441,7 +105468,7 @@ target = 0x00418450 [[units.relocations]] offset = 0xEA type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -107316,7 +107343,7 @@ size = 0xD6 [[units.relocations]] offset = 0x73 type = "DIR32" -symbol = "?g_EclManager@th08@@3UEclManager@1@A" +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" target = 0x004ECCB8 [[units.relocations]] @@ -107328,8 +107355,9 @@ target = 0x00418450 [[units.relocations]] offset = 0x8E type = "DIR32" -symbol = "?g_EclCallParameters@EclRunLow@th08@@3UEclCallParameterCopy@12@A" -target = 0x004ECE20 +symbol = "?g_EclRuntime@th08@@3UEclRuntimeState@1@A" +target = 0x004ECCB8 +addend = 0x168 [[units]] name = "ecl-pop-context-00421cb0" @@ -111785,14 +111813,16 @@ target = 0x004B4338 [[units.relocations]] offset = 0xCC type = "DIR32" -symbol = "?g_EclGameTimeScaleFlags@th08@@3IA" -target = 0x017CE8FC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x1A4 [[units.relocations]] offset = 0xD5 type = "DIR32" -symbol = "?g_EclGameTimeScaleFlags@th08@@3IA" -target = 0x017CE8FC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x1A4 [[units.relocations]] offset = 0xDB @@ -120283,7 +120313,8 @@ target = 0x0160F508 offset = 0x1CE type = "DIR32" symbol = "?g_GameManager@th08@@3UGameManager@1@A" -target = 0x0160F509 +target = 0x0160F508 +addend = 0x3C7D9 [[units.relocations]] offset = 0x1D7 @@ -120469,8 +120500,9 @@ target = 0x017CE758 [[units.relocations]] offset = 0x86 type = "DIR32" -symbol = "?g_EclGameTimeScaleFlags@th08@@3IA" -target = 0x017CE8FC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x1A4 [[units.relocations]] offset = 0xD1 @@ -120619,8 +120651,9 @@ target = 0x017CE758 [[units.relocations]] offset = 0x7E type = "DIR32" -symbol = "?g_EclGameTimeScaleFlags@th08@@3IA" -target = 0x017CE8FC +symbol = "?g_Supervisor@th08@@3USupervisor@1@A" +target = 0x017CE758 +addend = 0x1A4 [[units.relocations]] offset = 0xA8 diff --git a/config/reccmp-globals.csv b/config/reccmp-globals.csv index fa7b50a0..65c33864 100644 --- a/config/reccmp-globals.csv +++ b/config/reccmp-globals.csv @@ -103,8 +103,7 @@ th08::g_Background,0x4e4030,global th08::g_BackgroundDrawChainLowPrio,0x4ea630,global th08::g_BackgroundCalcChain,0x4ea650,global th08::g_Spellcard,0x4ea670,global -th08::g_EclManager,0x4eccb8,global -th08::EclRunLow::g_EclCallParameters,0x4ece20,global +th08::g_EclRuntime,0x4eccb8,global th08::g_EffectManager,0x4ece60,global th08::g_EffectManagerCalcChain,0x577ebc,global th08::g_EffectManagerDrawChain,0x577edc,global @@ -142,7 +141,6 @@ th08::g_SupervisorScreenEffect,0x17ce750,global th08::g_Supervisor,0x17ce758,global th08::g_BulletManagerAnmReleaseRequired,0x17ce8c0,global th08::g_GuiAnmReleaseRequired,0x17ce8c4,global -th08::g_GuiFullPowerModeFrames,0x17ce8cc,global th08::g_SupervisorLoadingVms,0x17ceac0,global th08::g_MusicRoom,0x17cf4c8,global th08::g_Player,0x17d5ef8,global @@ -184,7 +182,6 @@ th08::g_GuiResultAnm1,0x4d50ac,global th08::g_GuiMessageAnm,0x17ce8f4,global th08::g_GuiMessageInputCurrent,0x164d52c,global th08::g_GuiMessageInputPrevious,0x164d534,global -th08::g_GuiMessageScreenEffectDuration,0x17ce8cc,global th08::g_GuiBossTimerColors,0x4c72ac,global th08::g_GuiTimePeriodLabels,0x4c72bc,global th08::g_ItemTimeOrbMode,0x18b8974,global @@ -195,8 +192,6 @@ th08::g_ItemScatterTimerStorage,0x18b89bc,global th08::g_EnemyDropSchedule,0x4c70d8,global th08::g_EnemyAttachedTimer30,0x18b89c8,global th08::g_EnemyAttachedTimer0,0x18b89e0,global -th08::g_PlayerNormalBombCount,0x164cfa8,global -th08::g_PlayerDeathbombCount,0x164cfac,global th08::g_BulletSpriteOffsetSmall,0x4c70f8,global th08::g_BulletSpriteOffsetMedium,0x4c7138,global th08::g_PlayerBombCallbacksByShotType,0x4c7ad0,global @@ -225,6 +220,5 @@ th08::g_GuiMessagePaths,0x4c74c0,global th08::g_EnemyManagerUpdateTrackedPosition,0x18b899c,global th08::g_EnemyTrackedEnemy,0x18b89b4,global th08::g_EnemyManagerUpdateTrackedPositionValid,0x18b89b8,global -th08::g_EclGameTimeScaleFlags,0x17ce8fc,global th08::g_TitleLastWordCommentFormats,0x4c82c8,global th08::g_TitleSpellDifficultyNames,0x4c8628,global diff --git a/scripts/check-match-config.py b/scripts/check-match-config.py index 76e7890d..5c480edd 100644 --- a/scripts/check-match-config.py +++ b/scripts/check-match-config.py @@ -96,6 +96,9 @@ def main() -> int: units = tomllib.load(stream)["units"] bindings = {(stable_symbol(row["symbol"]), row["target"]) for unit in units for row in unit.get("relocations", []) if row["type"] == "DIR32"} + for symbol, address in sorted(bindings): + if symbol in {"?g_GameManager@th08@@3UGameManager@1@A", "th08::g_GameManager"} and address != 0x0160F508: + fail(f"{symbol} must use target base 0x0160F508 and a member addend, found {address:#010x}") for contract in contracts: if (stable_symbol(contract["symbol"]), contract["target_address"]) not in bindings: fail(f"data contract {contract['name']} is not bound to a canonical DIR32 symbol/address") diff --git a/scripts/gdb/laser-visual-observer.py b/scripts/gdb/laser-visual-observer.py index b6364f65..8323b91a 100644 --- a/scripts/gdb/laser-visual-observer.py +++ b/scripts/gdb/laser-visual-observer.py @@ -147,7 +147,8 @@ def stop(self): item["ecl.floatVariables"] = list(struct.unpack("<8I", bytes(gdb.selected_inferior().read_memory(context["floatVariables"].address, 32)))) sub_id = item["ecl.subId"] if sub_id not in spawn_subroutines: - manager = value("th08::g_EclManager") + runtime = gdb.lookup_global_symbol("th08::g_EclRuntime") + manager = runtime.value()["manager"] if runtime else value("th08::g_EclManager") count = int(manager["eclFile"].dereference()["subCount"]) if not 0 <= sub_id < count <= 4096: raise RuntimeError("Spawn context has an invalid ECL subroutine index") diff --git a/scripts/gdb/portable-layout-checks.py b/scripts/gdb/portable-layout-checks.py index 94de2914..4d454383 100644 --- a/scripts/gdb/portable-layout-checks.py +++ b/scripts/gdb/portable-layout-checks.py @@ -156,6 +156,8 @@ def check(name, family, passed, **observed): set_value("$enemy = &th08::g_EnemyManager.enemies[0]") enemy = integer("$enemy") stream = integer("(void*)malloc(32)") +manager = ("th08::g_EclRuntime.manager" if gdb.lookup_global_symbol("th08::g_EclRuntime") + else "th08::g_EclManager") outputs = {} pairs = [(100.0, x) for x in (80.0, 96.0, 97.0, 288.0, 289.0, 320.0)] pairs += [(0.0, 96.0), (0.0, 97.0), (300.0, 288.0), (300.0, 289.0)] @@ -173,7 +175,7 @@ def check(name, family, passed, **observed): set_value("$enemy->mainEclContextStorage.currentInstr = " "(th08::EclRawInstruction*)%d" % stream) zero("th08::g_Rng") - call("th08::g_EclManager.RunEcl($enemy)") + call(manager + ".RunEcl($enemy)") angle = float(gdb.parse_and_eval("$enemy->mainEclContextStorage.floatVariables[0]")) outputs[player_x, x, raw] = angle left_branch = (player_x < x and 96 < x) or 288 < x diff --git a/src/AsciiManager.cpp b/src/AsciiManager.cpp index 4c4a19c8..46dd4a97 100644 --- a/src/AsciiManager.cpp +++ b/src/AsciiManager.cpp @@ -1202,7 +1202,7 @@ void PauseMenu::OnDraw() g_Supervisor.viewport.Width = g_GameManager.arcadeRegionSize.x; g_Supervisor.viewport.Height = g_GameManager.arcadeRegionSize.y; g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport); - if (((g_EclGameTimeScaleFlags >> 1) & 1) != 0 && this->curState != 0) + if (((reinterpret_cast(g_Supervisor.flags) >> 1) & 1) != 0 && this->curState != 0) { AnmVm menuBackground = this->menuBackground; menuBackground.zWriteDisabled = TRUE; @@ -1529,7 +1529,7 @@ void RetryMenu::OnDraw() g_Supervisor.viewport.Width = g_GameManager.arcadeRegionSize.x; g_Supervisor.viewport.Height = g_GameManager.arcadeRegionSize.y; g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport); - if (((g_EclGameTimeScaleFlags >> 1) & 1) != 0 && (this->curState != 0 || this->numFrames > 2)) + if (((reinterpret_cast(g_Supervisor.flags) >> 1) & 1) != 0 && (this->curState != 0 || this->numFrames > 2)) g_AnmManager->DrawNoRotation(&this->menuBackground); if (!g_GameManager.IsSpellPractice() && g_GameManager.difficulty < EXTRA) diff --git a/src/EclDependencies.cpp b/src/EclDependencies.cpp index 0d19d418..8b387ea4 100644 --- a/src/EclDependencies.cpp +++ b/src/EclDependencies.cpp @@ -473,7 +473,7 @@ void __fastcall SetPrimaryAnmScripts( } -C_ASSERT(sizeof(EclCallParameterCopy) == 0x20); +C_ASSERT(sizeof(EclCallParameters) == 0x20); // FUNCTION: th08 0x421bd0 void __fastcall CallSubOnEnemy( @@ -491,13 +491,13 @@ void __fastcall CallSubOnEnemy( *enemy->activeEclContext; } - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( enemy->activeEclContext, static_cast(rawSubId)); - *reinterpret_cast( + *reinterpret_cast( &enemy->activeEclContext->callParameterInts[0]) = - g_EclCallParameters; + g_EclRuntime.callParameters; if (((enemy->flags1 >> ENEMY_FLAG_DISABLE_ECL_CALL_STACK_SHIFT) & 1) == 0 && diff --git a/src/EclExIns.cpp b/src/EclExIns.cpp index 70e8430d..2c33c3c4 100644 --- a/src/EclExIns.cpp +++ b/src/EclExIns.cpp @@ -910,7 +910,7 @@ void __fastcall ExitScaledBulletTime(Enemy *enemy, EclExInstruction *instruction g_Supervisor.framerateMultiplier = 1.0f / static_cast(instruction->value); if (g_Supervisor.framerateMultiplier < 1.0f) - g_EclGameTimeScaleFlags |= 0x20U; + reinterpret_cast(g_Supervisor.flags) |= 0x20U; g_Supervisor.framerateMultiplier = 1.0f; g_Background.spellVms[0].SetInterrupt(1); g_Background.spellVms[1].SetInterrupt(1); diff --git a/src/EclGlobals.cpp b/src/EclGlobals.cpp index cdf4741d..a024669c 100644 --- a/src/EclGlobals.cpp +++ b/src/EclGlobals.cpp @@ -97,14 +97,6 @@ DIFFABLE_STATIC_ARRAY_ASSIGN(EclExInstructionCallback, 32, g_EclExInsn) = { &SpawnBombOrExtendItem, }; -#ifndef TH08_PORTABLE_NATIVE_LAYOUT -DIFFABLE_STATIC(u32, g_EclGameTimeScaleFlags); -#endif -DIFFABLE_STATIC(EclManager, g_EclManager); - -namespace EclRunLow -{ -DIFFABLE_STATIC(EclCallParameterCopy, g_EclCallParameters); -} // namespace EclRunLow +DIFFABLE_STATIC(EclRuntimeState, g_EclRuntime); } // namespace th08 diff --git a/src/EclManager.hpp b/src/EclManager.hpp index c9f1ee92..8fdf9d39 100644 --- a/src/EclManager.hpp +++ b/src/EclManager.hpp @@ -197,11 +197,6 @@ void __fastcall ShiftStageEffectOrigins(Float3 *delta); DIFFABLE_EXTERN(ChainElem, g_EffectManagerCalcChain); DIFFABLE_EXTERN(ChainElem, g_EffectManagerDrawChain); -#ifdef TH08_PORTABLE_NATIVE_LAYOUT -#define g_EclGameTimeScaleFlags reinterpret_cast(g_Supervisor.flags) -#else -DIFFABLE_EXTERN(u32, g_EclGameTimeScaleFlags); -#endif // TH08 1.00d ECL instruction protocol. Every value is explicit because the // serialized opcode number is part of the on-disk format; names describe the @@ -687,6 +682,23 @@ struct EclManager C_ASSERT(sizeof(EclManager) == 0x168); C_ASSERT(offsetof(EclManager, timelineState) == 0x8); -DIFFABLE_EXTERN(EclManager, g_EclManager); +struct EclCallParameters +{ + i32 ints[4]; + f32 floats[4]; +}; +C_ASSERT(sizeof(EclCallParameters) == 0x20); + +// Both parts are cleared together when the enemy chain is registered. +struct EclRuntimeState +{ + EclManager manager; + EclCallParameters callParameters; +}; +C_ASSERT(offsetof(EclRuntimeState, manager) == 0); +C_ASSERT(offsetof(EclRuntimeState, callParameters) == 0x168); +C_ASSERT(sizeof(EclRuntimeState) == 0x188); + +DIFFABLE_EXTERN(EclRuntimeState, g_EclRuntime); } // namespace th08 diff --git a/src/EclOperands.hpp b/src/EclOperands.hpp index 25b55fe3..24d7ec1f 100644 --- a/src/EclOperands.hpp +++ b/src/EclOperands.hpp @@ -15,13 +15,4 @@ f32 *__fastcall ResolveFloatLValue(Enemy *enemy, f32 *operand, u16 flags, i32 fl } // namespace EclOperands -namespace EclRunLow -{ -struct EclCallParameterCopy -{ - i32 ints[4]; - f32 floats[4]; -}; -extern EclCallParameterCopy g_EclCallParameters; -} // namespace EclRunLow } // namespace th08 diff --git a/src/EclOperandsFloat.cpp b/src/EclOperandsFloat.cpp index 83f65ff7..e15327bc 100644 --- a/src/EclOperandsFloat.cpp +++ b/src/EclOperandsFloat.cpp @@ -61,14 +61,14 @@ f32 Enemy::ResolveFloat(f32 operand) case ECL_OPERAND_SHOT_TYPE: return (f32)::th08::g_GameManager.shotType; case ECL_OPERAND_ITEM_DROP_TYPE: return (f32)this->itemDropType; case ECL_OPERAND_SCORE: return (f32)this->score; - case ECL_OPERAND_SHARED_CALL_INT_0: return (f32)EclRunLow::g_EclCallParameters.ints[0]; - case ECL_OPERAND_SHARED_CALL_INT_1: return (f32)EclRunLow::g_EclCallParameters.ints[1]; - case ECL_OPERAND_SHARED_CALL_INT_2: return (f32)EclRunLow::g_EclCallParameters.ints[2]; - case ECL_OPERAND_SHARED_CALL_INT_3: return (f32)EclRunLow::g_EclCallParameters.ints[3]; - case ECL_OPERAND_SHARED_CALL_FLOAT_0: return EclRunLow::g_EclCallParameters.floats[0]; - case ECL_OPERAND_SHARED_CALL_FLOAT_1: return EclRunLow::g_EclCallParameters.floats[1]; - case ECL_OPERAND_SHARED_CALL_FLOAT_2: return EclRunLow::g_EclCallParameters.floats[2]; - case ECL_OPERAND_SHARED_CALL_FLOAT_3: return EclRunLow::g_EclCallParameters.floats[3]; + case ECL_OPERAND_SHARED_CALL_INT_0: return (f32)g_EclRuntime.callParameters.ints[0]; + case ECL_OPERAND_SHARED_CALL_INT_1: return (f32)g_EclRuntime.callParameters.ints[1]; + case ECL_OPERAND_SHARED_CALL_INT_2: return (f32)g_EclRuntime.callParameters.ints[2]; + case ECL_OPERAND_SHARED_CALL_INT_3: return (f32)g_EclRuntime.callParameters.ints[3]; + case ECL_OPERAND_SHARED_CALL_FLOAT_0: return g_EclRuntime.callParameters.floats[0]; + case ECL_OPERAND_SHARED_CALL_FLOAT_1: return g_EclRuntime.callParameters.floats[1]; + case ECL_OPERAND_SHARED_CALL_FLOAT_2: return g_EclRuntime.callParameters.floats[2]; + case ECL_OPERAND_SHARED_CALL_FLOAT_3: return g_EclRuntime.callParameters.floats[3]; case ECL_OPERAND_LOCAL_FLOAT_0: return ECL_CONTEXT(this)->floatVariables[0]; case ECL_OPERAND_LOCAL_FLOAT_1: return ECL_CONTEXT(this)->floatVariables[1]; @@ -188,10 +188,10 @@ f32 *__fastcall ResolveFloatLValue(Enemy *enemy, f32 *operand, u16 flags, i32 fl case ECL_OPERAND_PLAYER_POSITION_Z: return &g_Player.position.z; case ECL_OPERAND_EXTRA_FLOAT_0: return &ECL_CONTEXT(enemy)->extraFloatVariables[0]; case ECL_OPERAND_EXTRA_FLOAT_1: return &ECL_CONTEXT(enemy)->extraFloatVariables[1]; - case ECL_OPERAND_SHARED_CALL_FLOAT_0: return &EclRunLow::g_EclCallParameters.floats[0]; - case ECL_OPERAND_SHARED_CALL_FLOAT_1: return &EclRunLow::g_EclCallParameters.floats[1]; - case ECL_OPERAND_SHARED_CALL_FLOAT_2: return &EclRunLow::g_EclCallParameters.floats[2]; - case ECL_OPERAND_SHARED_CALL_FLOAT_3: return &EclRunLow::g_EclCallParameters.floats[3]; + case ECL_OPERAND_SHARED_CALL_FLOAT_0: return &g_EclRuntime.callParameters.floats[0]; + case ECL_OPERAND_SHARED_CALL_FLOAT_1: return &g_EclRuntime.callParameters.floats[1]; + case ECL_OPERAND_SHARED_CALL_FLOAT_2: return &g_EclRuntime.callParameters.floats[2]; + case ECL_OPERAND_SHARED_CALL_FLOAT_3: return &g_EclRuntime.callParameters.floats[3]; case ECL_OPERAND_INTERPOLATION_ORIGIN_X: return &enemy->movementInterpolationOrigin.x; case ECL_OPERAND_INTERPOLATION_ORIGIN_Y: return &enemy->movementInterpolationOrigin.y; diff --git a/src/EclOperandsInt.cpp b/src/EclOperandsInt.cpp index 6d3061eb..f100de99 100644 --- a/src/EclOperandsInt.cpp +++ b/src/EclOperandsInt.cpp @@ -86,14 +86,14 @@ i32 __fastcall ResolveInt(Enemy *enemy, i32 operand) case ECL_OPERAND_CALL_FLOAT_1: return (i32)ECL_CONTEXT->callParameterFloats[1]; case ECL_OPERAND_CALL_FLOAT_2: return (i32)ECL_CONTEXT->callParameterFloats[2]; case ECL_OPERAND_CALL_FLOAT_3: return (i32)ECL_CONTEXT->callParameterFloats[3]; - case ECL_OPERAND_SHARED_CALL_INT_0: return EclRunLow::g_EclCallParameters.ints[0]; - case ECL_OPERAND_SHARED_CALL_INT_1: return EclRunLow::g_EclCallParameters.ints[1]; - case ECL_OPERAND_SHARED_CALL_INT_2: return EclRunLow::g_EclCallParameters.ints[2]; - case ECL_OPERAND_SHARED_CALL_INT_3: return EclRunLow::g_EclCallParameters.ints[3]; - case ECL_OPERAND_SHARED_CALL_FLOAT_0: return (i32)EclRunLow::g_EclCallParameters.floats[0]; - case ECL_OPERAND_SHARED_CALL_FLOAT_1: return (i32)EclRunLow::g_EclCallParameters.floats[1]; - case ECL_OPERAND_SHARED_CALL_FLOAT_2: return (i32)EclRunLow::g_EclCallParameters.floats[2]; - case ECL_OPERAND_SHARED_CALL_FLOAT_3: return (i32)EclRunLow::g_EclCallParameters.floats[3]; + case ECL_OPERAND_SHARED_CALL_INT_0: return g_EclRuntime.callParameters.ints[0]; + case ECL_OPERAND_SHARED_CALL_INT_1: return g_EclRuntime.callParameters.ints[1]; + case ECL_OPERAND_SHARED_CALL_INT_2: return g_EclRuntime.callParameters.ints[2]; + case ECL_OPERAND_SHARED_CALL_INT_3: return g_EclRuntime.callParameters.ints[3]; + case ECL_OPERAND_SHARED_CALL_FLOAT_0: return (i32)g_EclRuntime.callParameters.floats[0]; + case ECL_OPERAND_SHARED_CALL_FLOAT_1: return (i32)g_EclRuntime.callParameters.floats[1]; + case ECL_OPERAND_SHARED_CALL_FLOAT_2: return (i32)g_EclRuntime.callParameters.floats[2]; + case ECL_OPERAND_SHARED_CALL_FLOAT_3: return (i32)g_EclRuntime.callParameters.floats[3]; case ECL_OPERAND_ENEMY_POSITION_X: return (i32)enemy->worldPosition.x; case ECL_OPERAND_ENEMY_POSITION_Y: return (i32)enemy->worldPosition.y; case ECL_OPERAND_ENEMY_POSITION_Z: return (i32)enemy->worldPosition.z; @@ -192,10 +192,10 @@ i32 *__fastcall ResolveIntLValue(Enemy *enemy, i32 *operand, u16 flags, i32 flag case ECL_OPERAND_LIFE: return &enemy->life; case ECL_OPERAND_ITEM_DROP_TYPE: return &enemy->itemDropType; case ECL_OPERAND_SCORE: return &enemy->score; - case ECL_OPERAND_SHARED_CALL_INT_0: return &EclRunLow::g_EclCallParameters.ints[0]; - case ECL_OPERAND_SHARED_CALL_INT_1: return &EclRunLow::g_EclCallParameters.ints[1]; - case ECL_OPERAND_SHARED_CALL_INT_2: return &EclRunLow::g_EclCallParameters.ints[2]; - case ECL_OPERAND_SHARED_CALL_INT_3: return &EclRunLow::g_EclCallParameters.ints[3]; + case ECL_OPERAND_SHARED_CALL_INT_0: return &g_EclRuntime.callParameters.ints[0]; + case ECL_OPERAND_SHARED_CALL_INT_1: return &g_EclRuntime.callParameters.ints[1]; + case ECL_OPERAND_SHARED_CALL_INT_2: return &g_EclRuntime.callParameters.ints[2]; + case ECL_OPERAND_SHARED_CALL_INT_3: return &g_EclRuntime.callParameters.ints[3]; default: return operand; } } diff --git a/src/EclRunHigh.inl b/src/EclRunHigh.inl index e412d2a7..681d921a 100644 --- a/src/EclRunHigh.inl +++ b/src/EclRunHigh.inl @@ -571,7 +571,7 @@ enter_subroutine: sizeof(EnemyEclContext)); } - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( reinterpret_cast( &TH08_ECL_CONTEXT_ENEMY(ctx)->mainEclContextStorage), TH08_ECL_CONTEXT_ENEMY(ctx)->eclSubroutineIds[ @@ -663,7 +663,7 @@ enter_subroutine: 0, sizeof(EnemyChildEclBlock)); TH08_ECL_CONTEXT_ENEMY(ctx)->childEclBlocks[lhsInt]->subId = TH08_ECL_READ_I(ctx, 1); - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &(TH08_ECL_CONTEXT_ENEMY(ctx) ->childEclBlocks[lhsInt] ->eclContext), @@ -777,8 +777,7 @@ enter_subroutine: case ECL_OPCODE_SET_BACKGROUND_SCRIPT_LABEL: g_Background.pendingStageScriptLabel = TH08_ECL_READ_I(ctx, 0); break; case ECL_OPCODE_SET_BOSS_LIFE_MARKER_COUNT: g_Gui.SetBossLifeMarkerCount(TH08_ECL_READ_I(ctx, 0)); - g_GameManager.catkData[SPELLCARD_ST2_BOSS_3L] - .inGameHistory.maxBonus[SHOT_MARISA_ALICE] += 0x708; + g_GameManager.stagePlayTimeAll += 1800; break; case ECL_OPCODE_SPAWN_ENEMY_AT_POSITION: if (TH08_ECL_CONTEXT_ENEMY(ctx)->life > 0) diff --git a/src/EnemyManager.cpp b/src/EnemyManager.cpp index 400c5777..e016b715 100644 --- a/src/EnemyManager.cpp +++ b/src/EnemyManager.cpp @@ -455,7 +455,7 @@ i32 Enemy::HandleLifeCallback() { this->life = this->lifeCallbackThresholds[i]; this->phaseStartingLife = this->life; - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &this->mainEclContextStorage, *reinterpret_cast(&this->lifeCallbackSubIds[i])); this->lifeCallbackThresholds[i] = -1; @@ -490,7 +490,7 @@ i32 Enemy::HandleLifeCallback() enemyCursor->life = 0; if (enemyCursor->deathCallbackSubId >= 0) { - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &enemyCursor->mainEclContextStorage, enemyCursor->deathCallbackSubId); enemyCursor->deathCallbackSubId = -1; @@ -625,7 +625,7 @@ i32 Enemy::HandleTimerCallback() this->lifeCallbackThresholds[selectedOrK] = -1; } - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &this->mainEclContextStorage, *reinterpret_cast(&this->timerCallbackSubId)); this->timerCallbackThresholdFrames = -1; @@ -657,7 +657,7 @@ i32 Enemy::HandleTimerCallback() enemyCursor->life = 0; if (enemyCursor->deathCallbackSubId >= 0) { - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &enemyCursor->mainEclContextStorage, enemyCursor->deathCallbackSubId); enemyCursor->deathCallbackSubId = -1; @@ -1363,17 +1363,10 @@ ZunResult EnemyManager::AddedCallback(EnemyManager *enemyManager) if (!IsDisableResourceReload()) { -#ifdef TH08_MODERN_PORT - memset(&g_EclManager, 0, sizeof(g_EclManager)); - memset(&EclRunLow::g_EclCallParameters, 0, - sizeof(EclRunLow::g_EclCallParameters)); -#else - memset(&g_EclManager, 0, - sizeof(g_EclManager) + sizeof(EclRunLow::g_EclCallParameters)); -#endif + memset(&g_EclRuntime, 0, sizeof(g_EclRuntime)); if (!g_GameManager.flags.isSpellPractice) { - if (g_EclManager.Load(const_cast(g_StageEclFiles[g_GameManager.currentStage])) != + if (g_EclRuntime.manager.Load(const_cast(g_StageEclFiles[g_GameManager.currentStage])) != ZUN_SUCCESS) { return ZUN_ERROR; @@ -1381,7 +1374,7 @@ ZunResult EnemyManager::AddedCallback(EnemyManager *enemyManager) } else if (g_GameManager.currentSpellCardNumber >= 0xCD) { - if (g_EclManager.Load(const_cast(g_SpellEclFiles[ + if (g_EclRuntime.manager.Load(const_cast(g_SpellEclFiles[ g_GameManager.currentSpellCardNumber - 0xCD])) != ZUN_SUCCESS) { @@ -1390,7 +1383,7 @@ ZunResult EnemyManager::AddedCallback(EnemyManager *enemyManager) } else { - if (g_EclManager.Load(const_cast(g_StageSpellEclFiles[g_GameManager.currentStage])) != + if (g_EclRuntime.manager.Load(const_cast(g_StageSpellEclFiles[g_GameManager.currentStage])) != ZUN_SUCCESS) { return ZUN_ERROR; @@ -1399,18 +1392,11 @@ ZunResult EnemyManager::AddedCallback(EnemyManager *enemyManager) } else { - savedEclFile = g_EclManager.eclFile; - savedSubTable = g_EclManager.subTable; -#ifdef TH08_MODERN_PORT - memset(&g_EclManager, 0, sizeof(g_EclManager)); - memset(&EclRunLow::g_EclCallParameters, 0, - sizeof(EclRunLow::g_EclCallParameters)); -#else - memset(&g_EclManager, 0, - sizeof(g_EclManager) + sizeof(EclRunLow::g_EclCallParameters)); -#endif - g_EclManager.eclFile = savedEclFile; - g_EclManager.subTable = savedSubTable; + savedEclFile = g_EclRuntime.manager.eclFile; + savedSubTable = g_EclRuntime.manager.subTable; + memset(&g_EclRuntime, 0, sizeof(g_EclRuntime)); + g_EclRuntime.manager.eclFile = savedEclFile; + g_EclRuntime.manager.subTable = savedSubTable; } enemyManager->enemyDropCounter = g_Rng.GetRandomU16InRange(3); @@ -1445,7 +1431,7 @@ ZunResult EnemyManager::DeletedCallback(EnemyManager *enemyManager) } if (!IsDisableResourceReload()) { - g_EclManager.Unload(); + g_EclRuntime.manager.Unload(); } D3DXVECTOR3 markerPosition(-999.0f, -999.0f, -999.0f); @@ -1533,7 +1519,7 @@ i32 EnemyManager::KillAllNonBossEnemies(i32 maxScore, i32 initialScore) enemy->DetachFromParentChain(); if (enemy->deathCallbackSubId >= 0) { - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &enemy->mainEclContextStorage, enemy->deathCallbackSubId); enemy->deathCallbackSubId = -1; diff --git a/src/EnemyManagerUpdate.cpp b/src/EnemyManagerUpdate.cpp index 9d366d18..c2c309b3 100644 --- a/src/EnemyManagerUpdate.cpp +++ b/src/EnemyManagerUpdate.cpp @@ -108,11 +108,11 @@ i32 EnemyManager::OnUpdate() this->drawGroupHeads[1] = 0; this->drawGroupHeads[0] = 0; - for (enemyIndex = 0; enemyIndex < g_EclManager.GetTimelineCount(); ++enemyIndex) + for (enemyIndex = 0; enemyIndex < g_EclRuntime.manager.GetTimelineCount(); ++enemyIndex) { if (this->timelines[enemyIndex].instruction == 0) { - this->timelines[enemyIndex].instruction = g_EclManager.GetTimeline(enemyIndex); + this->timelines[enemyIndex].instruction = g_EclRuntime.manager.GetTimeline(enemyIndex); } this->timelines[enemyIndex].Run(); } @@ -154,7 +154,7 @@ i32 EnemyManager::OnUpdate() enemy->UpdateYoukaiAlignment(); run_enemy_ecl_after_pause: - if (g_EclManager.RunEcl(enemy) == -1) + if (g_EclRuntime.manager.RunEcl(enemy) == -1) { enemy->flags1 &= ~ENEMY_FLAG_ACTIVE; enemy->Despawn(); @@ -589,7 +589,7 @@ i32 EnemyManager::OnUpdate() &g_EnemyManager.spawnTemplate.bulletSpawnDescriptor, sizeof(BulletSpawnDescriptor)); enemy->shootIntervalFrames = 0; - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( reinterpret_cast( &enemy->mainEclContextStorage), enemy->deathCallbackSubId); diff --git a/src/EnemyTimeline.cpp b/src/EnemyTimeline.cpp index 97319989..47aa8392 100644 --- a/src/EnemyTimeline.cpp +++ b/src/EnemyTimeline.cpp @@ -37,9 +37,9 @@ Enemy *EnemyManager::SpawnEnemy1(i32 eclSubroutineId, const D3DXVECTOR3 *positio if (life >= 0) enemy->life = life; enemy->position = *FLOAT3_CONST_PTR(position); - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &enemy->mainEclContextStorage, (i16)eclSubroutineId); - if (g_EclManager.RunEcl(enemy) == ZUN_ERROR) + if (g_EclRuntime.manager.RunEcl(enemy) == ZUN_ERROR) { reinterpret_cast(&enemy->flags1)->active = 0; i = 480; @@ -88,12 +88,12 @@ Enemy *EnemyManager::SpawnEnemy2(i32 eclSubroutineId, const D3DXVECTOR3 *positio if (life >= 0) enemy->life = life; enemy->position = *FLOAT3_CONST_PTR(position); - g_EclManager.CallEclSub( + g_EclRuntime.manager.CallEclSub( &enemy->mainEclContextStorage, (i16)eclSubroutineId); *reinterpret_cast( enemy->mainEclContextStorage.intVariables) = *reinterpret_cast(contextInts); - if (g_EclManager.RunEcl(enemy) == ZUN_ERROR) + if (g_EclRuntime.manager.RunEcl(enemy) == ZUN_ERROR) { reinterpret_cast(&enemy->flags1)->active = 0; i = 480; diff --git a/src/GameManager.cpp b/src/GameManager.cpp index 93d5edbc..68dd4f7e 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -1204,7 +1204,7 @@ i32 InitializeScoreData() .highScores[g_GameManager.currentStage][g_GameManager.difficulty]; g_GameManager.pscrData[g_GameManager.shotType] .attempts[g_GameManager.currentStage][g_GameManager.difficulty]++; - g_GameManager.pscrData[g_GameManager.shotType].shotNumber = 1; + g_GameManager.pscrData[g_GameManager.shotType].shouldSerialize = 1; } ScoreDat::ReleaseScore(scoreDat); diff --git a/src/GameManager.hpp b/src/GameManager.hpp index aacd4b85..329edfe0 100644 --- a/src/GameManager.hpp +++ b/src/GameManager.hpp @@ -414,6 +414,7 @@ C_ASSERT(offsetof(GameManager, antiTamperHeapJitterAllocation) == 0x0); C_ASSERT(offsetof(GameManager, scriptedUpdateFreeze) == 0x2c); C_ASSERT(offsetof(GameManager, catkData) == 0x40); C_ASSERT(offsetof(GameManager, plst) == 0x3D804); +C_ASSERT(offsetof(GameManager, hscr) == 0x3DA2C); C_ASSERT(offsetof(GameManager, character) == 0x3DBA8); C_ASSERT(offsetof(GameManager, shotType) == 0x3DBA9); C_ASSERT(offsetof(GameManager, flags) == 0x3DBAC); diff --git a/src/GameManagerScoreProbe.cpp b/src/GameManagerScoreProbe.cpp index 96765053..a47b3c26 100644 --- a/src/GameManagerScoreProbe.cpp +++ b/src/GameManagerScoreProbe.cpp @@ -64,7 +64,7 @@ i32 InitializeScoreData() .highScores[g_GameManager.currentStage][g_GameManager.difficulty]; g_GameManager.pscrData[g_GameManager.shotType] .attempts[g_GameManager.currentStage][g_GameManager.difficulty]++; - g_GameManager.pscrData[g_GameManager.shotType].shotNumber = 1; + g_GameManager.pscrData[g_GameManager.shotType].shouldSerialize = 1; } ScoreDat::ReleaseScore(scoreDat); diff --git a/src/Gui.cpp b/src/Gui.cpp index f83c5bbb..b959e4ac 100644 --- a/src/Gui.cpp +++ b/src/Gui.cpp @@ -24,15 +24,9 @@ namespace th08 DIFFABLE_STATIC(Gui, g_Gui); DIFFABLE_STATIC(ChainElem, g_GuiCalcChain); DIFFABLE_STATIC(ChainElem, g_GuiDrawChain); -DIFFABLE_STATIC(i32, g_GuiFullPowerModeFrames); C_ASSERT(offsetof(Background, spellVmScriptBase) == 0xB34); DIFFABLE_STATIC(u16, g_GuiMessageInputCurrent); DIFFABLE_STATIC(u16, g_GuiMessageInputPrevious); -#ifdef TH08_PORTABLE_NATIVE_LAYOUT -#define g_GuiMessageScreenEffectDuration g_GuiFullPowerModeFrames -#else -DIFFABLE_STATIC(i32, g_GuiMessageScreenEffectDuration); -#endif // Target .data 0x004C7158: the per-stage clear-bonus production owner. DIFFABLE_STATIC_ARRAY_ASSIGN(i32, MAX_STAGES, g_GuiStageClearBonuses) = { 1000000, 1500000, 2000000, 2500000, 2500000, 3000000, 4000000, 6000000, 6660000, @@ -105,8 +99,8 @@ ChainCallbackResult Gui::OnUpdate(Gui *gui) gui->UpdateStageElements(); gui->impl->RunMsg(); - if ((g_CurFrameInput & TH_BUTTON_SKIP) && g_GuiMessageScreenEffectDuration < 8) - g_GuiMessageScreenEffectDuration = 8; + if ((g_CurFrameInput & TH_BUTTON_SKIP) && g_Supervisor.screenTransitionCountdown < 8) + g_Supervisor.screenTransitionCountdown = 8; gui->frameCounter++; return CHAIN_CALLBACK_RESULT_CONTINUE; } @@ -745,7 +739,7 @@ i32 GuiImpl::RunMsg() case GUI_MSG_FADE_SCREEN: ScreenEffect::RegisterChain( SCREEN_EFFECT_FULL_FADE_OUT, 442, 0xffffff, 0, 0, CHAIN_PRIO_DRAW_SCREENEFFECT); - g_GuiMessageScreenEffectDuration = 442; + g_Supervisor.screenTransitionCountdown = 442; break; case GUI_MSG_END_STAGE: if (g_GameManager.currentStage == STAGE6A || g_GameManager.currentStage == STAGE6B || @@ -1218,7 +1212,7 @@ void Gui::DrawGameScene() } vm = &this->impl->frontVms[13]; - if (g_Supervisor.IsHUDRedrawEnabled() || vm->currentInstruction != NULL || g_GuiFullPowerModeFrames != 0) + if (g_Supervisor.IsHUDRedrawEnabled() || vm->currentInstruction != NULL || g_Supervisor.screenTransitionCountdown != 0) { for (yPos = 0.0f; yPos < 464.0f; yPos += 32.0f) { @@ -1631,7 +1625,7 @@ void Gui::ShowBonusScore(i32 value) this->impl->bonusPopup.displayMode = 1; this->impl->bonusPopup.timer = 0; this->impl->bonusPopup.value = value; - g_GuiFullPowerModeFrames = 2; + g_Supervisor.screenTransitionCountdown = 2; } // FUNCTION: th08 0x437e5d @@ -1641,7 +1635,7 @@ void Gui::ShowPopupText(i32 value, i32 displayMode) this->impl->statusPopup.displayMode = displayMode; this->impl->statusPopup.timer = 0; this->impl->statusPopup.value = value; - g_GuiFullPowerModeFrames = 2; + g_Supervisor.screenTransitionCountdown = 2; } // FUNCTION: th08 0x437edc @@ -1651,7 +1645,7 @@ void Gui::ShowSpellcardBonus(i32 value) this->impl->spellcardBonusPopup.displayMode = 1; this->impl->spellcardBonusPopup.timer = 0; this->impl->spellcardBonusPopup.value = value; - g_GuiFullPowerModeFrames = 2; + g_Supervisor.screenTransitionCountdown = 2; } // FUNCTION: th08 0x437f5c @@ -2187,7 +2181,7 @@ ZunResult Gui::ActualAddedCallback() this->flags.timeDisplayUpdateFrames = 2; g_AsciiManager.asciiAnm->SetAndExecuteScriptIdx(&this->impl->stageRankVm, 3); - g_GuiMessageScreenEffectDuration = 16; + g_Supervisor.screenTransitionCountdown = 16; this->impl->stageClear.clockDisplayCurrent = 0; return ZUN_SUCCESS; diff --git a/src/ItemManager.cpp b/src/ItemManager.cpp index 9a999867..877fed74 100644 --- a/src/ItemManager.cpp +++ b/src/ItemManager.cpp @@ -13,7 +13,6 @@ namespace th08 { DIFFABLE_STATIC(ItemManager, g_ItemManager); -DIFFABLE_STATIC(i32, g_MaxValuePointItemsCollected); DIFFABLE_STATIC_ARRAY_ASSIGN(i32, 6, g_PowerUpThresholds) = {8, 24, 48, 80, 128, 999}; // FUNCTION: th08 0x441830 @@ -507,7 +506,7 @@ void Item::CollectPoint() } } - g_MaxValuePointItemsCollected++; + g_GameManager.hscr.numPointItemsCollected++; g_GameManager.UpdateAntiTamper(); } diff --git a/src/Player.cpp b/src/Player.cpp index 19f055ab..18b692fe 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -23,8 +23,6 @@ namespace th08 // far before the main Player implementation that begins at 0x00449CA0. Its // production definitions live in PlayerBomb.cpp. DIFFABLE_STATIC(Player, g_Player); -DIFFABLE_STATIC(i32, g_PlayerNormalBombCount); -DIFFABLE_STATIC(i32, g_PlayerDeathbombCount); DIFFABLE_STATIC_ARRAY_ASSIGN(const char *, 12, g_PlayerAnmFilenames) = { "player00.anm", "player01.anm", "player02.anm", "player03.anm", @@ -1259,11 +1257,11 @@ void Player::UpdateBombState() g_GameManager.AddToBombCount(-2); } } - ++g_PlayerDeathbombCount; + ++g_GameManager.hscr.numLastSpells; } else { - ++g_PlayerNormalBombCount; + ++g_GameManager.hscr.numBombsUsed; g_GameManager.AddToBombCount(-1); } g_GameManager.AddToBombsUsed(1); diff --git a/src/ReplayManager.cpp b/src/ReplayManager.cpp index e73205fa..947056c0 100644 --- a/src/ReplayManager.cpp +++ b/src/ReplayManager.cpp @@ -902,7 +902,7 @@ void ReplayManager::SaveReplay(const char *replayPath, const char *replayName) else { infoCursor = AppendFormat(infoCursor, TH_REPLAY_INFO_FINAL_STAGE, - g_GameManager.flags.gameCleared ? "Clear" : ResultScreen::GetStageName(g_GameManager.stageAtStart)); + g_GameManager.flags.gameCleared ? "Clear" : ResultScreen::GetStageName(g_GameManager.currentStage)); } infoCursor = AppendFormat(infoCursor, TH_REPLAY_INFO_DEATHS, g_GameManager.GetDeaths()); diff --git a/src/ResultScreen.cpp b/src/ResultScreen.cpp index 9801fe4b..43a2df57 100644 --- a/src/ResultScreen.cpp +++ b/src/ResultScreen.cpp @@ -539,7 +539,7 @@ void ResultScreen::LogScoreDataToFile(ResultScreen *resultScreen) g_GameManager.plst.playDataByDifficulty[HARD].continues, g_GameManager.plst.playDataByDifficulty[LUNATIC].continues, g_GameManager.plst.playDataByDifficulty[EXTRA].continues, - g_GameManager.plst.playDataByDifficulty[MAX_DIFFICULTIES].continues); + g_GameManager.plst.playDataTotals.continues); outputCursor = AppendLogFormat(outputCursor, TH_RESULT_PRACTICE_COUNT "\r\n", g_GameManager.plst.playDataByDifficulty[EASY].practices, g_GameManager.plst.playDataByDifficulty[NORMAL].practices, diff --git a/src/ScoreDat.hpp b/src/ScoreDat.hpp index d9e6ad93..2d9cbd47 100644 --- a/src/ScoreDat.hpp +++ b/src/ScoreDat.hpp @@ -266,7 +266,10 @@ struct Hscr C_ASSERT(sizeof(Hscr) == 0x168); C_ASSERT(offsetof(Hscr, reserved27) == 0x27); +C_ASSERT(offsetof(Hscr, numPointItemsCollected) == 0x68); C_ASSERT(offsetof(Hscr, unconsumedDword6C) == 0x6C); +C_ASSERT(offsetof(Hscr, numBombsUsed) == 0x74); +C_ASSERT(offsetof(Hscr, numLastSpells) == 0x78); C_ASSERT(offsetof(Hscr, defaultScoreMarker) == 0x166); C_ASSERT(offsetof(Hscr, reservedTail167) == 0x167); diff --git a/src/Spellcard.cpp b/src/Spellcard.cpp index 88fb573e..9971b3e7 100644 --- a/src/Spellcard.cpp +++ b/src/Spellcard.cpp @@ -392,7 +392,6 @@ Spellcard::Spellcard() } -DIFFABLE_EXTERN(i32, g_GuiFullPowerModeFrames); // FUNCTION: th08 0x4144d0 #pragma var_order(difficulty, i) @@ -938,7 +937,7 @@ void Spellcard::CutInPlayer(i32 playerFace, const char *name, i32 sprite) this->playerSpellNameWidth = strlen(name) * 0xf / 2.0f + 16; this->playerSpellNameFrameVm.SetInterrupt(1); g_SoundPlayer.PlaySoundByIdx(SOUND_CAT, 0); - g_GuiFullPowerModeFrames = 2; + g_Supervisor.screenTransitionCountdown = 2; } // FUNCTION: th08 0x415f00 @@ -976,7 +975,7 @@ void Spellcard::CutInEnemy(i32 enemyFace, const char *name, i32 sprite) this->spellBonusFrameVm.SetInterrupt(1); } g_SoundPlayer.PlaySoundByIdx(SOUND_CAT, 0); - g_GuiFullPowerModeFrames = 2; + g_Supervisor.screenTransitionCountdown = 2; } // FUNCTION: th08 0x416130 diff --git a/src/StageMenuProbe.cpp b/src/StageMenuProbe.cpp index af07e5cc..a96dd821 100644 --- a/src/StageMenuProbe.cpp +++ b/src/StageMenuProbe.cpp @@ -43,7 +43,7 @@ void PauseMenuProbe::OnDraw() g_Supervisor.viewport.Width = g_GameManager.arcadeRegionSize.x; g_Supervisor.viewport.Height = g_GameManager.arcadeRegionSize.y; g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport); - if (((g_EclGameTimeScaleFlags >> 1) & 1) != 0 && this->curState != 0) + if (((reinterpret_cast(g_Supervisor.flags) >> 1) & 1) != 0 && this->curState != 0) { AnmVm menuBackground = this->menuBackground; menuBackground.zWriteDisabled = TRUE; @@ -69,7 +69,7 @@ void RetryMenuProbe::OnDraw() g_Supervisor.viewport.Width = g_GameManager.arcadeRegionSize.x; g_Supervisor.viewport.Height = g_GameManager.arcadeRegionSize.y; g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport); - if (((g_EclGameTimeScaleFlags >> 1) & 1) != 0 && (this->curState != 0 || this->numFrames > 2)) + if (((reinterpret_cast(g_Supervisor.flags) >> 1) & 1) != 0 && (this->curState != 0 || this->numFrames > 2)) g_AnmManager->DrawNoRotation(&this->menuBackground); if (!g_GameManager.IsPracticeMode() && g_GameManager.difficulty < EXTRA) diff --git a/src/Supervisor.cpp b/src/Supervisor.cpp index f1752f9d..d182b5aa 100644 --- a/src/Supervisor.cpp +++ b/src/Supervisor.cpp @@ -1771,8 +1771,8 @@ void Supervisor::UpdatePlayTime() } if (g_GameManager.plst.totalSeconds >= 60) { - g_GameManager.plst.totalMinutes += (g_GameManager.plst.totalMilliseconds / 60); - g_GameManager.plst.totalSeconds = (g_GameManager.plst.totalMilliseconds % 60); + g_GameManager.plst.totalMinutes += (g_GameManager.plst.totalSeconds / 60); + g_GameManager.plst.totalSeconds = (g_GameManager.plst.totalSeconds % 60); } if (g_GameManager.plst.totalMinutes >= 60) { @@ -1813,8 +1813,8 @@ void Supervisor::UpdateGameTime() } if (g_GameManager.plst.gameSeconds >= 60) { - g_GameManager.plst.gameMinutes += (g_GameManager.plst.gameMilliseconds / 60); - g_GameManager.plst.gameSeconds = (g_GameManager.plst.gameMilliseconds % 60); + g_GameManager.plst.gameMinutes += (g_GameManager.plst.gameSeconds / 60); + g_GameManager.plst.gameSeconds = (g_GameManager.plst.gameSeconds % 60); } if (g_GameManager.plst.gameMinutes >= 60) { diff --git a/src/Supervisor.hpp b/src/Supervisor.hpp index b90ec894..24697eb0 100644 --- a/src/Supervisor.hpp +++ b/src/Supervisor.hpp @@ -296,8 +296,7 @@ struct Supervisor i32 releaseResourcesOnRestart; i32 keepStageResources; i32 unconsumedDword170; - i32 screenTransitionCountdown; // Commonly set for screen transitions and decremented once per frame, but never actually used for - // anything + i32 screenTransitionCountdown; i32 suppressFpsDisplay; BOOL disableVsync; ZunBool couldSetRefreshRate; @@ -344,6 +343,7 @@ C_ASSERT(sizeof(Supervisor) == 0x364); C_ASSERT(offsetof(Supervisor, isInitialStageLoad) == 0x164); C_ASSERT(offsetof(Supervisor, releaseResourcesOnRestart) == 0x168); C_ASSERT(offsetof(Supervisor, keepStageResources) == 0x16c); +C_ASSERT(offsetof(Supervisor, screenTransitionCountdown) == 0x174); C_ASSERT(offsetof(Supervisor, suppressFpsDisplay) == 0x178); C_ASSERT(offsetof(Supervisor, framerateMultiplier) == 0x188); C_ASSERT(offsetof(Supervisor, recordedFps) == 0x198); diff --git a/src/modern/linux/th08-layout.ld b/src/modern/linux/th08-layout.ld index 91f66e14..1dfd2879 100644 --- a/src/modern/linux/th08-layout.ld +++ b/src/modern/linux/th08-layout.ld @@ -30,8 +30,6 @@ SECTIONS _ZN4th0811g_SpellcardE = 0x004ea670; - _ZN4th0812g_EclManagerE = 0x004eccb8; - _ZN4th089EclRunLow19g_EclCallParametersE = 0x004ece20; _ZN4th0815g_EffectManagerE = 0x004ece60; /* @@ -54,9 +52,6 @@ SECTIONS _ZN4th0814g_GuiDrawChainE = 0x0160f4c4; _ZN4th0814g_GuiCalcChainE = 0x0160f4e4; _ZN4th0813g_GameManagerE = 0x0160f508; - _ZN4th0823g_PlayerNormalBombCountE = 0x0164cfa8; - _ZN4th0822g_PlayerDeathbombCountE = 0x0164cfac; - _ZN4th0829g_MaxValuePointItemsCollectedE = 0x0164cf9c; _ZN4th0822g_GameManagerCalcChainE = 0x0164d344; _ZN4th0822g_GameManagerDrawChainE = 0x0164d364; _ZN4th0814g_JoystickCapsE = 0x0164d388; @@ -80,11 +75,8 @@ SECTIONS _ZN4th0834g_DummyMidiTimerPerformanceCounterE = 0x017ce744; _ZN4th0824g_SupervisorScreenEffectE = 0x017ce750; _ZN4th0812g_SupervisorE = 0x017ce758; - _ZN4th0824g_GuiFullPowerModeFramesE = 0x017ce8cc; - _ZN4th0832g_GuiMessageScreenEffectDurationE = 0x017ce8cc; /* These target globals are overlapping views into aggregate owners. */ - _ZN4th0823g_EclGameTimeScaleFlagsE = 0x017ce8fc; _ZN4th088g_PlayerE = 0x017d5ef8; _ZN4th0822g_SupervisorLoadingVmsE = 0x017ceac0; From 8edf204dcb75875c559980a00e1de1b5e4657f90 Mon Sep 17 00:00:00 2001 From: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:14:15 +0100 Subject: [PATCH 2/3] docs: record native 64-bit PI validation --- docs/RE_HANDOFF.md | 5 +++++ docs/SEMANTIC_HISTORY.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/docs/RE_HANDOFF.md b/docs/RE_HANDOFF.md index 36d1035d..26c354aa 100644 --- a/docs/RE_HANDOFF.md +++ b/docs/RE_HANDOFF.md @@ -12,6 +12,11 @@ its source and useful findings are incorporated. Keep these branches and replay each branch's affected comparisons when moving source changes. This checkout follows the native-layout `port/portable-64bit` branch. +This branch includes the shared storage and GameManager field fixes from `main`. The +[64-bit validation record](SEMANTIC_HISTORY.md#shared-pi-ownership-in-the-64-bit-port--2026-11-20) +covers the reordered x86_64 link, Final B and Extra replays, and a +`score.dat` round trip. + The `.analysis/portable-perspective-rounding` worktree contains uncommitted billboard/transparent-quad tools and notes. Preserve that entire worktree and its inputs. Other experiment branches remain available through Git. diff --git a/docs/SEMANTIC_HISTORY.md b/docs/SEMANTIC_HISTORY.md index 8ebfe21c..dc799ebb 100644 --- a/docs/SEMANTIC_HISTORY.md +++ b/docs/SEMANTIC_HISTORY.md @@ -10,6 +10,38 @@ reproduce affected comparisons for new source changes. ## Completed batches +### Shared PI ownership in the 64-bit port — 2026-11-20 + +The port shares the retail storage owners established by `12dde807`, +`831a5719`, and `3669a7fb`. `EnemyManager::AddedCallback` at `0x0042EBF0` +clears the ECL manager and call parameters as one object, retaining native +ECL pointers during cached stage reloads. GUI transitions use the Supervisor +countdown, and point items, bombs, and deathbombs update the HSCR record +copied by the results screen. The GameManager changes bind opcode 148, +clock carry, replay labels, practice serialization, and total continues +to their retail fields. The port's i386 build still uses its existing +linker script for the remaining fixed-address owners. + +On `633e81ee`, a cold VC7 build matched all 1,106 accepted units. +The normal PE and its map pass the four initialized-data contracts and +confirm the nine corrected GameManager operands. The i386 Linux build +passes its layout check and reaches the Stage 5 demo. + +Both x86_64 links pass the 54 production layout checks in +`scripts/test-portable-layout.py`. Reversing the game objects moves +`g_EclRuntime` from `0x0081F200` to `0x00F3C2A0` and +`EnemyManager::AddedCallback` from `0x000665F4` to `0x000A2F62`, before +load bias. The reordered build passes focused checks for cached ECL reset, +GUI and HSCR writes, opcode 148, and both clock carries. The practice +attempt survives a `score.dat` round trip, the score report reads the total +continue count, and an unfinished replay labels the stage where it ended. + +With the recorder enabled, the reordered x86_64 executable matches retail +through the natural end of `easy-0-b` and `extra-1-extra`. The portable suite +and its `--verify-only` pass check all 25 fields over 107,296 and 44,106 +calculations respectively, including the recorded stage-end scores. The +Final B laser observer also resolves the new ECL owner during a live capture. + ### ANM player-bullet draw-mode protocol — 2026-09-19 Scope: `AnmManager::ExecuteScript @ 0x0045EA00`, From be0751e04ac296f127443bef391ade11a42510f7 Mon Sep 17 00:00:00 2001 From: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:37:45 +0100 Subject: [PATCH 3/3] docs: record additional x86_64 replay comparisons --- docs/SEMANTIC_HISTORY.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/SEMANTIC_HISTORY.md b/docs/SEMANTIC_HISTORY.md index dc799ebb..70ea8823 100644 --- a/docs/SEMANTIC_HISTORY.md +++ b/docs/SEMANTIC_HISTORY.md @@ -42,6 +42,13 @@ and its `--verify-only` pass check all 25 fields over 107,296 and 44,106 calculations respectively, including the recorded stage-end scores. The Final B laser observer also resolves the new ECL owner during a live capture. +The same reordered x86_64 binary also matched retail on three solver +replays and ten Silent Selene replays. The two groups covered 101,297 and +769,880 calculations respectively. All 25 recorded fields and the +stage-end scores agreed through natural replay completion. The four +Silent Selene game-over cases used the final input tail measured on two +independent retail runs of each replay. + ### ANM player-bullet draw-mode protocol — 2026-09-19 Scope: `AnmManager::ExecuteScript @ 0x0045EA00`,