OpenTPW

Determinism and replay: evidence and DET-I contract#

Static evidence for the identified Feral Mac release, 2026-10-10. No original instruction was executed and no Windows/Patch 2 behaviour is claimed. Addresses are unpacked PEF section offsets (code section 0; data section 1, TOC data:0x8000), as in PPC-clock.md.

BinarySHA-256
SimThemePark.data04809cd4ccee5433c7fb0b7c93d32f6a7aa629c1849181c0b7906415e5e295f5
c_c++_shared.data5e04f9c00c922dc78a787d1b93067c75d37a3e65b0a0202e50c2f449f131b27f

Witness: tools/ppc-analysis/lanes/det/det_evidence.py (174 pinned instructions plus bounded scans). Reference arithmetic: tools/ppc-analysis/lanes/det/det_model.py. Labels used below:

This document serves the M2 requirement in COMPLETION-PLAN.md (§"Evidence and determinism contract", §M2): a fixed simulation tick, a stable update/event order, named RNGs with serialized state, and canonical replay fields.

1. What was already proved#

TopicFactSource
Clock domainsClock A (scheduler/RSE/animation default) is a rate-scaled, pause-aware ms accumulator that can be held; clock B (advisor LIP, advisor channels) is unscaled and pause-aware, with no hold.PPC-clock §"Two elapsed millisecond clocks"; PPC-formats §"Clock selection", §"Scene clock controls"
RateClock A's rate starts at 1.0 and steps ×1.25/÷1.25, clamped to [0.25, 2.0]. A direct setter (0x127c40) has no clamp. Rate scales accumulation from the last read, not a tick length.PPC-formats §"Scene clock controls" item 4; PPC-clock §"Rollover, saturation and interval drops"
Pause0x110518/0x110598/0x110604 freeze/resume/toggle both clocks together, gated on host +60 == 1.PPC-clock §"Pause and speed input records"; PPC-formats §"Scene clock controls"
Hold (fixed step)0x10ec60(obj, 32) stores 1000 divwu 32 = 31 ms per pass; this runs at main-loop entry (released at 0x1c15d0) and on every pass while the capture flag (TOC −0x5e24) is set.PPC-formats §"Scene clock controls"; PPC-clock §"Two elapsed millisecond clocks"
Scheduler31 ms substeps of clock A, park turn every 8th substep, signed backlog >2000 ms dropped, at most 3 park turns per callback, repeat while (signed) now > previous.PPC-clock §"Scheduler, park turns…", §"Rollover…"
World gateSubstep work runs only when application_flag8 || !gameplay_flag1; excluded substeps still advance time and the counter.PPC-clock §"Startup and turn gates"; review round 4 witness
Game typeMode 0/2 call turn 0x10536c directly, mode 1 via wrapper 0x10565c; other values run no turn.PPC-clock §"Startup and turn gates"
RSEInstruction budget per script per manager pass; ordinary scripts run when id & 7 == pass & 7; WAIT deadlines on clock A (ms).PPC-clock §"RSE scheduling…", §"WAIT boundaries and ID phases"
Animationframe = (now − start) × 30 / 1000 × speed on the selected clock; channel clocks cached once per update by 0xa6f70.PPC-clock §"Animation delta…"; PPC-formats §"Animation clock"
CalendarVirtual date = fixed 2000-01-01 epoch (mFunnyTimeStart, saved) + turn × 15000 / 4 s; mSessionStart is host time and does not feed the date.PPC-clock §"Calendar epoch reconciliation"
GuestsLive-list order is newest first; fixed need additions need turn % 16 == 0 ∧ id % 4 == 0; guest IDs are allocated sequentially from 1.PPC-review §6 "Nested needs guard", "Update order is newest first"; PPC-guests
Sound RNGcandidate = seed × 1664525 + 1013904223; the bundle's choosers never store the successor; the seed (mRandomSeed__17CAudioPlaceHolder, sound data 0xc2e4, slot 0x348 is a data pointer to it) is initialized from LbTime_GetClock.cited, unmerged: advisor tips 0899f19 (phase 9) and 526e2bf/836bb0b (phase 10)
World RNGContext generator 0x105328, setter 0x105360, time(NULL) seed, mRandomSeed save/load link, COAST and C-library generators separate.cited, unmerged: rides tips c6b0906, 40d395e, 76aaa62. Re-pinned here (§2.3), so these facts no longer depend on that merge.
Restore limitOnly the mRandomSeed field transfer is a qualified restore checkpoint; post-load draw order is not proved ("Keep graph-only random edges out of restore claims").cited, unmerged: rides 76aaa62

RNG instances#

InstanceOwner / stateAlgorithm and projectionSeed sourceSaved by originalStatus
World RNGworld +0x1da708 (uint32), next to mGameTick +0x1da70cMac: s = s·1664525 + 1013904223; returns wrapping signed abs of s. PC v2.0 (tp.exe 0x516330, state at world +0x1DA708): the same step, then the state is rotated right by 13 and the rotated value is stored and returned as its wrapping signed abs (DET-013)time(NULL) at world setup 0x10474c; reseeded to a thing ID at 7 sites, to an object field at 1 siteyes, label mRandomSeed (4 bytes)pinned
Coaster boardingapp global data 622280 (TOC 0xcc0)s = s·214013 + 2531011; s >> 16 logicalone C-library rand() at 0x54bf4no label foundpinned
Kart objectobject +0x38 (subsystem 0x20688)214013/2531011; s >> 16 arithmetic (srawi)not tracedno label foundpinned (lane: state field, multiplier; review: multiplier and increment)
Particle objectobject +0x10 (subsystem 0x9f748)214013/2531011; arithmetic >> 16not tracedno label foundpinned (lane: state field, multiplier only via the 214013 site count; review: multiplier and increment)
Weather objectobject +0x34, step function 0x904a8 (caller imports gei_Rain)1664525/1013904223; returns the full new statenot tracedno label foundpinned (lane: state field, multiplier; review: multiplier and increment)
C libraryc_c++_shared data 0x544c (static 1), shared by app and engine_shareds = s·1103515245 + 12345; (s >> 16) & 32767srand(low32(UTimer::GetAbsolute()/1000)) at 0x1c0cc0no label foundpinned (app/clib); engine use not traced
Sound seedsound data 0xc2e4candidate = seed·1664525 + 1013904223, not stored backLbTime_GetClocknocited (unmerged)

"No label found" rests on one scan: the application's string pool holds exactly one *Seed*/*Random* identifier string (mRandomSeed). Unlabelled persistence is not excluded.

2. Gaps closed in this lane#

2.1 Substep order (pinned)#

The catch-up loop in game-callback helper 0x1c1208 runs these steps, in this order, for each 31 ms substep (previous += 31; substep += 1 happen first, before the world gate):

CadenceSite → targetRole (bounded)
every0x1c230c → 0x9f748particle system (PTCL: strings), own 214013 LCGs
every0x1c2310 → 0x20688vehicle/kart subsystem (GoKart Race Over, CRUNCH, TOOT!), own 214013 LCG; its callees also draw from the world RNG
every0x1c2314 → 0xb2838RSE script-manager pass
substep & 1 == 00x1c2330 → 0x63dd0flying-car/ambient pass (FLY: strings); 6 direct world-RNG draws
substep & 1 == 00x1c2334 → 0xb7ac0reads the scheduler clock; role unqualified
substep & 7 == 0, cap < 30x1c23b8 → 0x10536c, or 0x1c23ec → 0x10565cpark turn (mode 0/2 direct, mode 1 wrapper)
substep & 7 == 00x1c2424 → 0xb5da4runs even when the cap is spent; role unqualified
substep & 31 == 00x1c246c → 0xbc1d4, 0x1c24b8 → 0xbc210, 0x1c24bc → 0x63d20audio controls from clamped counts (≤89, ≤100; zeroed in world state 4); role unqualified

Before the even block and the turn block, the loop stores previous into two globals (TOC −0x5e40 and −0x65e4). These are the phase origins of the interpolation alphas below. The park-work counter is reset once per callback, at 0x1c27a4, after rendering.

Park turn 0x10536c (pinned): mGameTick += 1 first; then, unless world state (+0x1da738) is 4, it walks the live thing list. That list is newest first (PPC-review §6), and the walk dispatches on thing type byte +2 via 0xfa9b0; guests are type handlers 0xeece4/0xef240. When turn % 30 == 0 and further guards hold, an extra block runs, ending at 0x1092bc. The fixed tail always runs in this order: 0x1078cc (deferred thing removal), 0xd67f0 (world/economy and calendar update), 0x10ce68 (action recorder/replayer).

2.2 Simulation rate versus render rate (pinned)#

2.3 One shared gameplay RNG, plus local streams (pinned + scan)#

3. OpenTPW divergences#

#OpenTPW todayOriginal (Mac, this build)Maps to
D1FixedStepClock: 60 Hz, 16-tick catch-up cap, drops the excess; ParkCalendar samples 248 ms turns from 60 Hz ticks31 ms substeps of clock A; turn every 8th substep; 2000 ms backlog drop; ≤3 turns per callback, later turn phases consumed without a turnECON-001 (this contract supplies the replacement)
D2Level.Update: SimulationTimeScale × Time.Delta into the clock; speeds ×2/×4Rate ×1.25 steps clamped to 0.25–2.0 on clock A; substep length fixedECON-004, UI-022
D3All systems tick every 60 Hz step in the order economy sync → guests → ride → objects → parkFixed order of §2.1: particles → vehicles → scripts → (even) ambient → (8th) park turn [tick++, things newest first, 30-turn block, removal, world/economy, recorder]unregistered (proposed DET-001); guest order in GUESTS.md "approximations"
D4RSE: one slice per 60 Hz tick for every script (RSE-VM.md "Not original behaviour yet")One manager pass per substep; ordinary scripts on id & 7 == pass & 7ported in a park (DETERMINISM.md "The substep scheduler", RideScriptWorld.RunPass); a standalone VM keeps the tick
D5Guests: own SplitMix64 GuestRandom seeded with Level.GuestSeed, id orderShared world LCG; reseed to the guest ID at creation; live list newest firstunregistered (GUESTS.md)
D6Economy: own SplitMix64 DeterministicRandom, saved as RandomStateSame shared world LCG (staff candidates 0xf5b64, staff RNG gates)ECON-009, ECON-010 (formula IDs; the generator itself is unregistered)
D7RideVM: new Random(seed) or new Random() per VM; child VMs seeded from itRSE RAND/FINDSCRIPTRAND/BUMP/TOUR draw from the one world RNGRIDES (unregistered); PPC-rides RAND section
D8Advisor: new AdvisorMouth(new Random())C-library rand in the per-frame update 0x7434ADVISOR-001
D9SoundEventSystem advances seed on every drawSound seed never advanced by the bundle's choosersAUDIO (unregistered; conflicts with unmerged phase 10)
D10Extensions.RandomVector3 uses Random.Sharedpresentation only; must never be reachable from simulationn/a (guard)
D11Rides/objects advance by float deltaTimeCoaster motion uses variable per-frame elapsed ms (frame-coupled); clip frames from the cached clockRIDES-001
D12Save stores economy RandomState onlyOriginal saves mGameTick and mRandomSeed (plus calendar fields)unregistered (save format)

4. DET-I implementation contract#

4.1 Clock and tick#

  1. Simulation time is an integer millisecond clock A. Keep it as a 32-bit word, with the native signed now > previous comparison isolated in one function (see APPROX DET-004). elapsed_A += trunc(rate × wall_ms), accumulated as in 0x127cd0. Pause freezes A and B.

  2. Fixed substep = 31 ms of clock A. Per frame: if (int)(now − previous) > 2000, set previous = now − 2000; then, while (int)now > (int)previous, run previous += 31; substep += 1; body. Reset the park-work counter after rendering. det_model.catch_up is the reference; port its vectors (1 ms gap → 1 substep, overshoot 30; 2000 ms → 65 substeps, turns at 8/16/24, capped at 32…64; 5000 ms → backlog drop to 2000).

  3. Body gate: if application_flag8 || !gameplay_flag1, run the body; otherwise time and the counter still advance.

  4. Rate: steps ×1.25/÷1.25, clamped to [0.25, 2.0], start 1.0. Do not map OpenTPW's ×2/×4 to anything except an explicit EXT label.

  5. Replay/headless mode = capture mode: feed exactly 31 ms of clock A per frame (the original's hold). One frame then equals one substep, and frame-coupled paths (coaster motion) see a constant delta. The canonical replay is indexed by substep_counter, never by wall time.

  6. Render once per frame after catch-up, with interpolation alphas (now − previous)/31, (now − even_origin)/62, (now − turn_origin)/248. Rendering must not mutate simulation state.

4.2 Update order#

Per substep, in this order. Labels in brackets are this build's addresses:

  1. particles [0x9f748] (presentation unless proven otherwise; keep its RNG separate),

  2. vehicles/karts [0x20688],

  3. RSE manager pass [0xb2838]: increment the pass counter, then run ordinary scripts with id & 7 == pass & 7 and flagged (+184) scripts every pass,

  4. if even: ambient/flying cars [0x63dd0], then [0xb7ac0],

  5. if substep & 7 == 0 and park_work < 3: park_work += 1, then a park turn for mode 0/1/2,

  6. if substep & 7 == 0: [0xb5da4],

  7. if substep & 31 == 0: audio-control updates (presentation).

Park turn: tick += 1; unless world state 4, walk the live thing list newest first and dispatch on type; every 30 turns the guarded extra block; deferred removals; world/economy/calendar update; input-log/recorder step.

Per frame after catch-up: sound service; advisor (clock B); per-frame script walk; interpolation; coaster motion with the frame's clock-A delta (31 ms in replay); render.

4.3 RNG classes#

ClassStateStepReturnSeeding in DET-I
WorldRnguints = rotr(s*1664525 + 1013904223, 13) (PC, see below)wrapping abs of the rotated state (int.MinValue bits kept)from the save/replay header. Reseed(ushort thingId) at entity creation/transition sites (§2.3)
CoasterRnguint (one per process/world)s*214013 + 2531011s >> 16 (logical)one ClibRng draw at world init
ObjectMsRnguint per kart/particle objects*214013 + 2531011(int)s >> 16 (arithmetic)unknown → DET-006
WeatherRnguint per weather objects*1664525 + 1013904223full sunknown → DET-006
ClibRnguint, static initial 1s*1103515245 + 12345(s >> 16) & 32767from the header (the original uses timer ms)
SoundSeeduintnone (candidate only)seed*1664525 + 1013904223from the header; never advanced by a draw

The PC world generator (tp.exe 0x516330, October 14, 2026) rotates its state: it computes s = s*1664525 + 1013904223, then ror s, 13, stores the rotated value as the new state and returns its absolute value (0x51633A–0x51635F; the inline copies at 0x51674B, 0x51680B, 0x516879 and 0x51A34B are the same, and the reseed 0x516370 stores its argument as the state). ParkLitter.Next already has the rotate. The first draft of this table (and the Mac generator 0x105328, which should be checked again for the same rotate) left it out. Port requirements for DET-013 to DET-015: one WorldRng per level holding the u32 at world+0x1DA708; reseed with the zero-extended u16 thing id at the eight sites 0x4D71CA, 0x4D94E2, 0x4F7B7E, 0x4FB19E (guest creation: eight draws, reseed, two draws), 0x4FCAFD, 0x4FE6A1, 0x4FE6FC (balloon) and 0x50205F, all taking the id through 0x50B350; the state is seeded from time() at world setup (0x515879) and saved as mRandomSeed (0x51710F save, 0x517DE8 load) next to mGameTick; every consumer shares the one stream (139 direct calls and four inline copies) in the original update order: substeps and the RSE pass schedule, things newest first, economy month-end.

Projections stay with each caller. RSE RAND is labs(labs(r >>> 1) % (int16(bound) + 1)), and bound −1 is unsupported. BUMP takes an unsigned remainder of r; TOUR uses labs then a signed remainder of

  1. The coaster takes the high half modulo the eligible-car count. Test vectors are in test_det_model.py (seed 0 → 1013904223; RAND seed 0 bound 10 → 6 then 8; coaster 12345 → 40352; C library 1 → 16838). System.Random, Random.Shared and SplitMix64 must not be reachable from simulation code.

4.4 State to persist#

Original import reads exactly these qualified fields: mGameTick (u32) and mRandomSeed (u32, raw world-RNG state), plus the calendar fields mFunnyTimeStart/mSessionStart/rate already proved in PPC-clock. OpenTPW's own save format (EXT) additionally persists everything needed for exact continuation: clock A value, previous, the substep counter, the manager pass counter, park-work count, rate, pause state, both interpolation phase origins, CoasterRng, ClibRng, SoundSeed, every ObjectMsRng/WeatherRng, the live-list order, the input-log cursor and pending script deadlines. Restoring an original save must not invent the non-saved streams silently: DET-I seeds them from the header and tags the load (DET-005).

4.5 Canonical replay fields#

Hash per park turn (and on demand per substep), in this order, little-endian: schema_version, scheduler_previous_ms, substep_counter, manager_pass_counter, park_turn, world_rng_state, coaster_rng_state, clib_rng_state, sound_seed, scale, paused, game_type_mode, world_state, calendar_funny_start, calendar_rate, thing_table_digest (live-list order, each thing's ID, type and serialized fields), script_table_digest (ID, PC, variables, deadlines), economy_digest, input_log_cursor. The replay input log records (substep_counter, action). Actions apply at the start of a substep, before step 1; the original's own recorder applies at park-turn granularity, which is a coarser subset of this. Compare floats by bit pattern; no tolerance applies to canonical state.

4.6 What stays APPROX or unknown#

Proposed new IDs. The register is not edited by this research lane.

IDStatementEvidence needed
DET-001Order inside subsystems we do not model yet (particles, karts, ambient, 0xb7ac0, 0xb5da4, the thirty-second block, 0x483ac, 0xb2aac)their roles; whether particles/karts/ambient feed gameplay state
DET-002Initial seeds: the original seeds the world from time(NULL) and the C library from timer ms, so no original seed is "correct"none possible; an EXT policy (explicit seed in the header)
DET-003Coaster motion is frame-coupled in the original; DET-I fixes it to 31 ms per substep-frame outside capture mode tooan original trace at different frame rates
DET-004Signed now > previous near 2³¹ does not terminate in the native loop; DET-I must pick a guarded policylong-session runtime qualification
DET-005Original saves restore only mRandomSeed/mGameTick; post-load draw order (rides 76aaa62) and the non-saved streams are reconstructedload-path tracing of World/ThingArray readers
DET-006Seed sources and lifetimes of ObjectMsRng (kart/particle) and WeatherRngtheir constructors
DET-007Reseed at 0xd5b14 uses object field +0x214 (helper 0xc3304), meaning unknowncaller semantics
DET-008The 30-turn block's guards (0x1091ac/0x1091b8/0xc3684) and its second thing passtheir predicates
DET-009Recorder 0x10ce68: record format, modes 0/1/2, and the countdown clamp to 2reader 0x10d144 dispatch table
DET-010Windows/Patch 2 equivalence of every item herePC binary or trace
DET-011engine_shared also imports rand and Toolbox Random; its draws share the C-library stateengine call sites
DET-012Sound-seed non-advancement rests on unmerged phase 10merge plus a re-pin on main

5. Reproduction#

python3 -I tools/ppc-analysis/lanes/det/det_evidence.py /path/to/mac-feral/bin
OPENTPW_PPC_BIN_ROOT=/path/to/mac-feral/bin python3 -I -m unittest discover -s tools/ppc-analysis/lanes/det -p 'test_*.py' -v
python3 -I tools/ppc-analysis/run_evidence_checks.py --mac-bin /path/to/mac-feral/bin

Tests: 33 in the lane. 11 need the PEFs; 8 of those are mutation tests that perturb one expectation each (slice length, park cap, eighth mask, turn interpolation divisor, world-RNG increment, a reseed site, substep call order, a scan count) and require the witness to fail. A probe confirmed that a no-op mutation is reported as a test failure, so these tests are not vacuous. LLVM/Capstone disassembly was used only for transient inspection outside the repository. No original bytes or listings are stored.

Source: docs/reverse/DET-plan.md in the project repository.