Files
Neutron/docs/analysis/objective-timing.md

108 lines
5.1 KiB
Markdown

# Objective pad timeout, slide and O key
Read-only Neutron.exe recovery plus managed regression checks. Original text VAs
below correspond to file offsets VA-0x400000. This fixes the earlier stationary
HUD approximation; original-game/runtime visual comparison remains separate.
## Timer and phases
Objective selector4F8194 is distinct from animation timer4F8188.406F50 ignores
nonpositive selectors; for a positive selector it clears44 flags, stores selector,
resets timer0 at406F76 and enables the selected flag. Initial UI4018A8 and Jimmy
PostLoad423EC6 set timer20, so merely loading a saved positive selector does not
prove that its popup should initially appear.
4043D9 checks current controlled entity5099E4 againstNULL. Only a non-null entity
advances the timer by elapsed seconds at4043E5..4043F1 and invokes407070 through
virtual4D0. No controlled entity takes40447A..4044BD, hiding objective art and
leaving the timer unchanged. The test is for any controlled entity, not necessarily
Jimmy; cutscene control policy must be supplied separately by the caller.
407070 uses these phases (source floats retain their original widths):
| Timer t | Pad | Objective art/digit | Pad vertical offset from stationary layout |
| --- | --- | --- | --- |
| t<0.7 | Visible | Hidden | (1-t*1.4285714626312256f)*100 |
| 0.7<=t<7 | Visible | Visible |0|
|7<=t<8.7 | Visible | Hidden |(t-7)*1.4285714626312256f*100|
|t>=8.7 | Hidden | Hidden |No draw|
Entry threshold0.7 is48D974; reciprocal scale is48D970; distance100 is48D96C.
Stationary end is signed integer7 at4EC498. Exit draw window ends at7+1.7f,
with1.7 at48D940. The longer exit draw window means the pad can already leave
the viewport before the branch finally stops drawing it.
Pad top-left is x384,y=380+self[4EC]+slideOffset. Stationary art is
x384,y=448+self[4EC] (plus15 per visible row), digit x393,y=450+self[4EC].
Entry4070FD..407138 draws only the pad. Stationary4071BA..407247 shows selected
flags, digit and pad. Exit407266..40727E hides the44 objective art elements,
then407280..4072C4 draws the departing pad. At equality8.7 the40725F test exits.
Entry sets self[4E8] and emits effect216 once at4070BA..4070CA. Stationary
4071BA clears that latch. Resetting the timer while still entering therefore
does not necessarily replay the sound; ObjectivePanel retains this distinction.
## O opens/closes the pad, separate from gadget layout
407071 reads509887, which is virtual key'O' (4F) plus the recovered keyboard
array509838. Controller flag509AC9 joins that condition.4F7C30 is its edge latch:
no input clears the latch at40708F; a newly held input sets it at40715B.
On that edge40714F..407198:
- If timer is nonnegative and less than7, set it to7 and begin slide-out.
- Otherwise reset it to0 and begin slide-in.
- Holding the input does not repeat the toggle. Release then press creates a new edge.
The previous port used O to toggle layout offset-69/0. Original helpers406590
and406650 do change that offset and recreate/hide other gadget UI resources,
but407070's O branch does not call those helpers. O must control the timer instead.
The current objective consumer retains layoutOffset=-69; other gadget layout
transitions remain a separate system.
## Practice/pause policy
While a practice modal is active (excluding source type12),4044D7..404504 sets
the timer to7+1.7 and hides pad and art. No404D97 resets the timer to0, so dismissing
practice can explicitly reopen the current objective. This is distinct from
pausing the timer because no controlled actor exists. Focus/inspection/global
UI-pause scheduling is a caller policy until the complete original UI loop is
recovered; the component accepts explicit elapsed seconds and gating arguments.
## Component and integration API
`Game/ObjectivePanel.cs` owns only this presentation state:
```
var panel = new ObjectivePanel(currentSelector, layoutOffset: -69);
interactions.ObjectiveChanged += panel.Select;
// Each active UI tick; pass the actual held O state only when UI input is allowed.
panel.Key(oHeld);
panel.Step(seconds, hasControlledActor, modalActive);
// Pad and content need independent draw visibility.
panel.PadVisible; panel.ContentVisible; panel.YOffset;
// On practice No, matching404D97:
panel.Show();
```
`Select(positive)` resets timing even when selector is unchanged. Nonpositive
assignments are the recovered no-op. The current renderer has one selected lab
objective instead of all44 independent flags; selector0 deliberately shows no
invented art/digit. `SoundEffect` emits216 at the source entry latch. Constructor
layout bounds and selectors above43 reject malformed caller input.
## Verification
`source scripts/env.sh`, then:
```
dotnet run --project tests/GamePort.ObjectiveTests -- ../Original
```
Six groups pass: exact original constants/instructions; entry/hold/exit positions
and boundary equality; O edge/hold/reopen/layout separation; repeated selector
assignments and0 no-art; controlled-entity/modal/pause lifecycle; source sound
latch plus malformed inputs. The tests compare original Neutron.exe bytes at
seven decisive timer/input/visibility sites. No original file is modified or
executed. Renderer composition/native runtime tests belong to primary integration.