OpenTPW

Tour rides#

The four original tour rides (Jurassic Tours jungle/rides/tourride, Flightmare Tours hallow/rides/tourride, Star Tours space/rides/scitour, Tweety Tours fantasy/rides/twetours) take and release riders through the TOUR opcode. Rules are traced from the Windows tp.exe (TPW-EXE, through the shared REA session over the decrypted executable); every approximation carries a TOUR- ID in the register.

Code: source/OpenTPW/World/Tours/ (TourController, TourCar, TourWorld, TourSave), the TOUR routing in OriginalObjectRuntime.Tours.cs, the launch pad in OriginalObject.ComputeTourStation, Level.Tours.cs.

What a tour ride is (Q1)#

There is no track and no build tool. The ride is placed like any ride; its .sam has Bumper.WhichTrackType 0 and Info.RunsContinuously 1. The controller is the flying-car module (FLY_): the dispatcher at [BIN:TPW-EXE:0x005542FE] reaches a 99-slot table of 0x122C-byte controllers (0x008791F8), each holding 20 cars of 0xE4 bytes. A car is a free-flying vehicle (the ride's supplemental mesh 0: a bird, balloon, craft or kite carrying the riders on its head nodes 1..9) that lifts off from the ride's launch pad (model node of class 0x800, number 99), flies a random walk over the park's lattice for the ride's duration at a height that clears the ground, comes back, circles the station until the landing slot is free and lands. Everything is integer maths on 3000 units per cell (300 per model unit) and 4096 angle units per turn, with a 4096-entry sine table (0.5 + 1024 sin, truncated) and fixed flight bounds x 70000..190000, z 30000..140000.

TOUR commands (Q2)#

Jump table 0x005569D0, command โˆ’ 1 indexes it; the first argument of every handler is the controller id kept in the script's +0x9C.

CmdHandlerMeaning
10x0055A620create the controller and its first car (the script operand is the "small" flag, always 0)
20x0055D3D0destroy
30x0055D830board a guest id into the car standing at the station (state 1, count not negative)
40x0055D610hand out the next rider of the station car that is unloading, newest seat first; 0 when none (output variable and flags)
50x0055DCF0number of cars requested (applies at once while open)
80x0055D950flight duration: operand x 1000 / 64 ticks; running flights are cut to it
90x0055DA70condition 1 fine, 2 worn, 3 broken (first car breaks, flight ends), 4 as 3 and flying riders thrown off
100x0055DD20ready test: a car stands at the station (flags)
110x0055DD80depart: needs a ready car and an open ride, riders or several cars; clears ready
120x0055DDD0approach mode (the scripts set 1: take off and land along the station heading)
140x0055D9F0open / close (close: one car wanted, flights end, a station car with riders starts unloading)
150x0055DD40the first car is broken and standing at the station
160x0055DE30running: anybody aboard, no car ready, or more than one car (output variable and flags)
17 / 180x0055DDF0 / 0x0055DE10car-avoidance scale and bank scale (1024 = 1.0; Flightmare sets 2048)
6, 7, 13refused with a log line; no script issues them

Cars, boarding, end of a run (Q3)#

The per-tick state machine is [BIN:TPW-EXE:0x0055ABF0], called from 0x0054F5EF on every second world step: the world loop (0x0054E360) advances its clock by 31 ms and counts the steps ([0x00877D34], raised at 0x0054F4D3), and the tour tick sits behind test al, 1 on that counter (0x0054F5D7), so it runs once per 62 ms; OpenTPW runs it in the park's substep scheduler on the even passes (SimulationSubstep, DETERMINISM.md "The substep scheduler"), after the script pass and not from the objects' own tick. The draw divides the time since that tick by the same 62 ms (0x00700F90 is 1/62), and TOUR 8's operand x 1000 / 64 ticks are about operand seconds at that rate. TourController.TickSeconds is 0.062. Car states: 1 docked (loading, or unloading when its rider count is negative), 2 take-off, 3 tour, 4 return, 5 staging (fixed approach), 6 approach, 7 landing, 8 patrol, 9 leaving. A new car appears outside the flight area and circles the station (state 8) until the landing slot (+0x2C) is free. The first car of a ride is created docked and sets the ready flag.

A run: the script waits for TOUR 10, unloads with TOUR 4 (WALKOFF/WALKGET on Star and Tweety), loads with TOUR 3 until the car is full or ten seconds passed since the last boarding, then TOUR 11 and TOUR 8. The car takes off (the first target 20000 units along the heading at least 14000 up), flies lattice targets (0x0055C350: continue the direction, turn aside when the ground ahead is above the car, targets height max(12000, ground + 5000)) until its timer ends, returns, patrols the four corners 25000 units out (0x0055C270), claims the landing slot, flies the approach line and descends; on landing the rider count turns negative and the script unloads. Cars avoid each other (slower car loses a sixteenth of its speed, the lower one climbs) and clear stations by 30000. The ground they clear is the original's cell lookup 0x00452AE0: the height map of the object that owns the cell (the .hmp byte x 100/255 plus the object's base height, see below), otherwise the terrain.

Closing the ride (TOUR 14 0) touches only the wanted count, the flight timers, a station car's rider count (it turns negative) and the open word (0x0055D9F0); the ready flag is left as it was. A departure the script had ordered (TOUR 11 clears ready) that the closing stops before the lift-off therefore leaves the sole car docked with its riders aboard and ready clear (0x0055ABF0 state 1 lifts a car only with ready clear, no breakdown and, for the first car of a one-car ride, an open ride): TOUR 10 reads 0 and the script waits. When the ride reopens the car flies once more with its negative count, lands (ready set, only positive counts are negated) and the script unloads it. OpenTPW does the same; the riders are not stranded for good: reopening releases them, and deleting the ride releases everybody through the visitor bridge (RideVisitorBridge.ReleaseAll).

Stale slot words (TOUR-009). Car creation (0x0055A720) does not write a slot's heading, patrol corner, seat ids or approach heading (only the ride's first car takes the station's heading), so a new car in a reused slot starts from the last car's values. OpenTPW keeps them: they are saved (every seat word of a live car, and a FreeSlots list for free slots that hold a non-zero word) and hashed, so a saved and an uninterrupted run agree. A handed-out or thrown-off seat keeps its id too (0x0055D610 and 0x0055D720 read the slot without clearing it).

Saves (Q4)#

The original saves the module as the FLYR block (FLY_, the active word, the 400-byte controller pointer table, the four bounds, six padding words, the controller size 0x122C and every controller raw: 452 bytes when empty). OpenTPW's park-resume envelope gets an optional Tours part (TourWorldSaveData: every live controller, its cars and riders by attraction id), validated on load and restored onto the rides; the canonical digest includes the module only while a controller exists, so every park without a tour ride keeps its pins. An older save without the part restores each live tour ride with a fresh controller ([EXT:legacy-tour-save], was TOUR-006: the original's save always carries FLYR, so this is OpenTPW's save-compatibility decision). Bridge walkers carry an optional ready time (WalkingOffReady, absent for other rides). The tick clock of a saved controller may hold up to one tick (TourController.MaximumSavedRemainder, 62 ms); a save from the 31 ms clock holds less than 31 ms and restores unchanged (the value is elapsed seconds, so the first advance runs it off). The FreeSlots and the full seat lists are trailing optional parts: a save without them restores with zero stale words. No schema version moved: the canonical digest still includes the tour module only while a controller exists.

Launch pad (TOUR-003 retired)#

TOUR 1 (0x005542FE) reads the pad node live (0x0044B220, class 0x800 number 99, then 0x004386D0) and the instance angle +0x10 (0x00554385). +0x10 is the build angle the constructor stores in degrees (0x004DB0CD, handed over by the placement 0x00529E10) and, for a saved ride, the save's mAngle, which the attraction reader (0x004DB7D0) loads straight into +0x10: the placement rotation is the angle either way. All four tour scripts run TOUR 1 before any clip is triggered (WAITANIM 0 0 on an idle channel, then TOUR 1), so the live node is the model's rest pose; TourAssetTests.TheLaunchPadIsReadBeforeAnyClipPlays pins that. TOUR-003 retired.

The walk table and the walk-off time (TOUR-007 and TOUR-011 retired)#

The script's walk table (header walk size entries of 0x20 bytes) is the original's, in RideVisitorBridge. WALKON (0x00556F40) takes the first free entry and stores its seven operands (the visitor, nodes u1 and u2 for the walk on, nodes u3 and u4 for the walk off, the walk action and a last word), state 1, the start now and the end now + ftol(distance(u1, u2)) x 100 ms (100 ms for 0; u1 is the first dummy of class 0x800 whose number matches, u2 one of class 0x80 for the head action 4, else 0x800, 0x0044B220, both read live through 0x00556B90); a full table logs and stores nothing. The walk update of the main loop pass (0x00557AB0, called at 0x0054FA08 of 0x0054E360, once per rendered frame after the park's substeps, then 0x00557D80) moves state 1 to state 2 once the end has passed: the head action 4 hangs the rider's head on head id u2 (0x0044B410) and action 2 creates effect 0x13 at u2. WALKOFF (0x005571A0) finds the entry by visitor (none: it logs and does nothing) and, whatever its state, sets state 3, the start now and the end now + ftol(distance(u3, u4)) x 100 ms (u3 of class 0x80 for the head action 4, else 0x800, u4 of class 0x800); action 2 creates effect 0x13 at u3 and a head action 4 head that is up (state 2) comes down (0x0044B4C0). The update moves state 3 to state 4 at the end, and WALKGET (0x00557110) hands out the first entry of the table in state 4 and frees it. The ride runtime measures the model's dummies for every object that walks riders (OriginalObjectRuntime.WalkNodeDistance; every literal node pair of the 47 shipped WALKON instructions exists in its model, WalkNodeCorpusTests), so a ride's riders now leave after the measured walk (a few hundred milliseconds to two seconds) and not at once; the Star and Tweety Tours' slots lie 10 model units apart, so both still ride 1000 ms (TourAssetTests.TheTourWalkOffsSpanTheModelsSlotNodes, WalkOffTimingTests, WalkTableTests). The slot order, a WALKOFF restart in any state, the table size and the unknown rider are tested in WalkTableTests. The bridge saves the table entry by entry (WalkTable, optional; a save from before restores its on-board riders and walkers into the table). Round 11 (package W) moved the table to the original's cadence: BOUNCE takes the first free entry for any guest (0x555736), the walk update runs once per rendered frame after the park's substeps with the share clamp of 0x557E56 and 0x558010 and WALKGET hands out state 4 only (an entry that ends inside a substep is handed out at the next pass), the bodies step through the sprite player (the frame steppers 0x00476940 and 0x00476020 are the VM's own) and the orientation takes the node flag 0x10 (negated). Round 11 left nothing under TOUR-011 (retired): the height of a body without the height bit is the ride model's sampler (0x004511A0 after the mode 0x450EA0 picks from the model, +0xA0 added in every mode; Level.WalkerGroundOf; a point no face covers is the face sampler's -100 plus +0xA0, 0x4512A7), a node missing from the model leaves the original's stack words undefined ([EXT:original-undefined-reads]) and the walk update runs after every fixed tick ([EXT:fixed-60hz-clock]). The bodies themselves are the next section.

The walking body (TOUR-011)#

The walk update draws every entry it passes (0x00557D80, each through the body routine 0x005580A0), so the riders of every ride that runs WALKON are seen (47 WALKON instructions in 38 shipped rides, not only the tours). WalkerBodies and FlatRideBounceRiders.CollectWalkers pose them for the guest renderers (the same path as the bounce riders):

WalkerBodyTests pins the rules and a placed Mayan Spinner's table entries in every state; the native Jungle capture with a Mayan Spinner shows the body walking on and cheering on board.

Pose sines (TOUR-008 narrowed)#

The rotation builder behind the car pose (0x0046F6F0) reads sine and cosine from a 4096-entry table filled at start (0x004708D0: float(fsin(i / 4096 x 2 pi)), index round(angle x 4096 / 2 pi) & 4095, a cosine the sine of the angle plus a quarter turn). OriginalSineTable is that table and TourPose.Rotation turns the matrix with it; the quantisation is up to 7.7e-4 on a sine. Only the shadow question stays under TOUR-008.

Not done#

The hoarding posts' and station tiles' ground (TOUR-005); see the register. There is no shadow under the cars in the original either (TOUR-008 retired: the car draw, the MESHSHADOW flag, the vertex writer and the batcher 0x00581DB0 show none).

Drawing#

TourRenderer draws every live car as the ride's supplemental mesh 0 (Bird.md2, balloon, craft, kite) and the riders hang from the mesh's head dummies through the ride-head renderer, like the go-karts' riders. The pose is the original's draw pass [BIN:TPW-EXE:0x0055CE60] (TourPose):

Sounds, effects and animations (TOUR-004 and TOUR-008 retired)#

The controller raises TourEffects (TourController.Effect, presentation only: no world draw) and OriginalObjectRuntime plays them:

Object ground (TOUR-005)#

The original's .hmp is the height map of every object (loaded beside its mesh by 0x00451640, whose header words +0xC, +0x10 and +0x14 become pointers; +8 is the width in cells). The lookup 0x00452AE0 for a map cell takes the mesh instance of its second layer (0x0053BF30: a track piece or a park fence post), else the object that owns the cell (the owner word of a type-4, 9 or 10 cell and the class-3 thing in the owner's anchor cell, 0x527E80, 0x527D60) and, when that instance has a map, returns the byte of the per-cell maxima table x 100/255 (0x006FE408) plus the object's height (+0x44 of its instance matrix). The table index is width x row + column, with row and column the truncated tenths of the cell corner's offset from the instance position, turned by the instance rotation (0, 90, 180, 270 swap and reflect the two offsets, the +10 terms being a cell's width). ObjectHeightMaps reads <mesh>.hmp of the catalogue entry and does the same from OpenTPW's placement: the instance position is the model-to-engine translation, the rotation the placement's. All 274 catalogue objects ship their map and every footprint cell of every one of them lies inside it at all four rotations (TourAssetTests, TourRegisterRoundTests.TheMapIndexFollowsThePlacementsRotation), which fixes the orientation. The object route is matched (the footprint cells are the typed cells of one owner word). The second layer is read first, as the original does: a kart or water track tile's piece map (TrackRenderer.PieceGround). The tile's instance sits at the origin cell plus two cells of the engine rotation's offset (360 - rotation: 90 y + 1, 180 x + 1 and y + 1, 270 x + 1; added once by the instancer 0x00522B90 / 0x00522D50 and once by 0x00466F90), its map is 2 x 2 cells indexed from that corner with the engine rotation, and its height is the tile height 0x00466D70 (the midrange of the 3 x 3 vertices); every shipped piece map holds the tile's four cells at all four rotations (TrackAssetTests.EveryShippedPieceMapHoldsItsTilesFourCellsAtEveryRotation). A tile with the add-on bit has no piece instance and falls through to the object (the add-on). The mesh loader 0x004629D0 rebuilds a map only when the file is missing, malformed or of another size than the object's shape (0x00451640), and every shipped object map has its shape's size (TourAssetTests.EveryShippedHeightMapHasTheSizeOfItsObjectsShape), so the rebuild never runs for the catalogue. The lookup asks the second layer's handle for any kind of record: 0x0053BF30 returns the record's instance word +4, an extension record (0xC or 0x11) answering through its parent word (a parent word of 0 logs a message and answers none). The park fence's posts are the family 5 records (kind 25: the selector 0x0053A540, tail 0x0053A844โ€“0x0053A995; the refresh 0x0053AFA0 calls 0x00522F20, which reads table 0x00763608: ho_fos1, ho_end1 and ho_fob1; the previously cited 0x005229E0 / 0x00763388 belongs to the primary-cell family-2 queue meshes quedead, questra, quebnd, queend), so the post's cell and the three cells beside it answer with the hoarding instance's own map. Every hoarding mesh of every theme ships its 2 x 2 .hmp (ho_fos1 to ho_fos4, ho_fob1 to ho_fob4, ho_end1), so the rebuild 0x00451880 never runs for them either. OpenTPW draws no park fence mesh and so keeps no instance to sample: such a cell answers the object or the terrain. The constructor 0x00522F20 computes 360 - rotation, replacing exactly 360 by zero; the post's piece, its transform and height still need the fence meshes themselves. The map loader 0x00451640 compares the loaded map's size with the width and height its caller gives and rebuilds on a difference; for track pieces the caller's expected size is not read.

Station types 13 and 18 take the selector's default table 0x00763138, whose entries are family 1. The refresh 0x0053AFA0 builds instances only for families 3, 4 and 5 (its callers of the instancers 0x00522B90, 0x00522D50, 0x00522F20 are the only stores of a record's instance), so a station cell has no instance of its own and the lookup falls to the object that owns the cell, as OpenTPW does. TOUR-005 remains open for the park fence's instances and the track pieces' expected map size. The object's base height is RIDES-014's vertex midpoint.

Register changes (October 15 round)#

Verification#

The native jungle smoke places Jurassic Tours through the build path, sends two real guests to it, and when a car flies with riders freezes the world and reads back the GPU pixels with the cars shown and hidden (they differ); the run goes on until the car landed and both riders were handed back through TOUR 4, then removes the ride. The park-resume smoke with OPENTPW_SMOKE_TOUR=1 (both phases) buys the ride with a golden ticket, saves with a car in flight, restores through the menu load and matches the 600 continuation ticks of canonical hashes. The saved car is empty in that run; riders in flight are covered by the unit round trip and the asset test. The asset test closes each real tour script's ride after ten minutes and accepts both original outcomes (everything unloaded, or the TOUR-010 car docked with its riders), then deletes the ride and requires every boarded guest released.

Source: docs/TOURS.md in the project repository.