From 0c3d23d09f17b610ae24f5e6743cba08f038105b Mon Sep 17 00:00:00 2001 From: gamer147 Date: Mon, 3 Aug 2026 09:54:45 -0400 Subject: [PATCH] Extract VM runtime settings handler --- docs/PROJECT-STRUCTURE.md | 2 ++ docs/remake-architecture-and-roadmap.md | 14 ++++++-- .../Vm/VirtualMachine.RuntimeSettings.cs | 36 +++++++++++++++++++ engine/Age.Engine/Vm/VirtualMachine.cs | 11 +----- 4 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 engine/Age.Engine/Vm/VirtualMachine.RuntimeSettings.cs diff --git a/docs/PROJECT-STRUCTURE.md b/docs/PROJECT-STRUCTURE.md index a979c57..b988f7e 100644 --- a/docs/PROJECT-STRUCTURE.md +++ b/docs/PROJECT-STRUCTURE.md @@ -216,6 +216,8 @@ string comparison/concatenation/conversion/move, native byte-length and CP932 op fullwidth string editor; shared operand storage, addressing, and native-string encoding remain in the coordinator. `engine/Age.Engine/Vm/VirtualMachine.Diagnostics.cs` owns diagnostic value/newline accumulation and synchronous show-and-clear opcode dispatch; shared diagnostic state and native-context formatting remain in the coordinator. +`engine/Age.Engine/Vm/VirtualMachine.RuntimeSettings.cs` owns message-window alpha and system-menu enable/show +delay opcode dispatch; reset/default initialization, public menu-state accessors, and host state remain centralized. The disposable `build/page-map-.jsonl` files are produced by editor/development Godot runs and map runtime ADV page ordinals to their authoritative script offsets for `tools/locate_page.py`. Packaged exports diff --git a/docs/remake-architecture-and-roadmap.md b/docs/remake-architecture-and-roadmap.md index e5e008e..2ed65fb 100644 --- a/docs/remake-architecture-and-roadmap.md +++ b/docs/remake-architecture-and-roadmap.md @@ -734,6 +734,13 @@ do not mix mechanical moves with semantic changes. instruction through guarded `StepDiagnostic`; shared accumulator state and native-context formatting remain in the coordinator. Runtime validation remains green. + The eighteenth bounded `VirtualMachine.Step` extraction moved message-window alpha get/set, system-menu + enable state, and system-menu show-delay get/set into + `engine/Age.Engine/Vm/VirtualMachine.RuntimeSettings.cs`. The top-level dispatcher retains all labels and + aliases at their existing positions and routes them through guarded `StepRuntimeSetting`; reset/default + initialization, public menu-state accessors, and host state remain centralized. Runtime validation remains + green. + **Gate:** no externally visible behavior or command changes; generated artifacts are byte-identical where deterministic, and the corresponding engine, Python, Godot, and corpus validations remain green after each domain move. @@ -1107,8 +1114,9 @@ Continue step 2 of the **codebase consolidation** maintenance slice: behavior-ne by the tracked launcher and layered validation driver. With the planned `Main`, `GodotAdvHost`, and `GfxState` domains isolated and the audio, movie, surface/texture, retained-object, animation, presentation, ADV-text, text-history, ADV-service, input, timing, persistence, and memory/collection `VirtualMachine.Step` families routed -through domain handlers, with control-flow/coroutine, process/root-exit/cross-script lifecycle, value, and -diagnostic dispatch now isolated as well, extract message-window and system-menu runtime settings -next without replacing the proven dispatcher or changing public types, commands, and generated output. +through domain handlers, with control-flow/coroutine, process/root-exit/cross-script lifecycle, value, +diagnostic, and runtime-setting dispatch now isolated as well, route the four remaining recognized opcode bodies +for script entry/root state and surface reload policy into their existing domain handlers, leaving `Step` as the +proven dispatcher and unknown-op fallback without changing public types, commands, and generated output. Concrete playthrough blockers may still preempt this bounded maintenance work; the consolidation effort does not replace Phase B gameplay validation or the open cross-platform gates. diff --git a/engine/Age.Engine/Vm/VirtualMachine.RuntimeSettings.cs b/engine/Age.Engine/Vm/VirtualMachine.RuntimeSettings.cs new file mode 100644 index 0000000..fb933e0 --- /dev/null +++ b/engine/Age.Engine/Vm/VirtualMachine.RuntimeSettings.cs @@ -0,0 +1,36 @@ +using Age.Engine.Model; + +namespace Age.Engine.Vm; + +public sealed partial class VirtualMachine +{ + private int StepRuntimeSetting(string label, IReadOnlyList a, int pc) + { + switch (label) + { + case "get-message-window-alpha": // 0x131: process-owned message:MesWinAlpha setting + case "u00415F70": + Write(a[0], _messageWindowAlphaSetting); + return pc + 1; + case "set-message-window-alpha": // 0x141: paired message:MesWinAlpha configuration setter + case "u0041FAA0": + _messageWindowAlphaSetting = (int)Read(a[0]); + _host.SetMessageWindowAlphaSetting(_messageWindowAlphaSetting); + return pc + 1; + case "set-system-menu-enabled": // 0x142: native AGERC menu reentrancy guard + case "u0041FB10": // pre-reference compatibility + _systemMenuActionsEnabled = unchecked((int)Read(a[0])); + return pc + 1; + case "get-system-menu-show-delay": // 0x148: paired TIMER_SHOWMENU getter + case "u004160A0": // pre-reference compatibility + Write(a[0], unchecked((int)_systemMenuShowDelayMilliseconds)); + return pc + 1; + case "set-system-menu-show-delay": // 0x149: top-edge dwell threshold in milliseconds + case "u0041FCE0": // pre-reference compatibility + _systemMenuShowDelayMilliseconds = unchecked((uint)Read(a[0])); + return pc + 1; + default: + throw new InvalidOperationException($"Non-runtime-setting opcode routed to runtime-setting handler: {label}"); + } + } +} diff --git a/engine/Age.Engine/Vm/VirtualMachine.cs b/engine/Age.Engine/Vm/VirtualMachine.cs index ee0f7b9..f54e5bd 100644 --- a/engine/Age.Engine/Vm/VirtualMachine.cs +++ b/engine/Age.Engine/Vm/VirtualMachine.cs @@ -1444,24 +1444,15 @@ public sealed partial class VirtualMachine return StepAdvText(label, ins, pc); case "get-message-window-alpha": // 0x131: process-owned message:MesWinAlpha setting case "u00415F70": - Write(a[0], _messageWindowAlphaSetting); return pc + 1; case "set-message-window-alpha": // 0x141: paired message:MesWinAlpha configuration setter case "u0041FAA0": - _messageWindowAlphaSetting = (int)Read(a[0]); - _host.SetMessageWindowAlphaSetting(_messageWindowAlphaSetting); - return pc + 1; case "set-system-menu-enabled": // 0x142: native AGERC menu reentrancy guard case "u0041FB10": // pre-reference compatibility - _systemMenuActionsEnabled = unchecked((int)Read(a[0])); - return pc + 1; case "get-system-menu-show-delay": // 0x148: paired TIMER_SHOWMENU getter case "u004160A0": // pre-reference compatibility - Write(a[0], unchecked((int)_systemMenuShowDelayMilliseconds)); - return pc + 1; case "set-system-menu-show-delay": // 0x149: top-edge dwell threshold in milliseconds case "u0041FCE0": // pre-reference compatibility - _systemMenuShowDelayMilliseconds = unchecked((uint)Read(a[0])); - return pc + 1; + return StepRuntimeSetting(label, a, pc); case "get-message-glyph-delay": // 0x7f case "u00414C60": case "set-message-glyph-delay": // 0x1b5