Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Debug tools

The port can be built with a small command interpreter (port/debug/zbdebug.cpp) for getting into any state quickly: jump to a scene, set the levels, fill the party, edit the saved state, assert on the result. It is port code, not decompiled code, and the game's own cheats stay as they are (their codes are compared by hash, see Hidden scenes; the tools set the debugging flag directly instead).

How it is built in

decomp/game.cpp:gameFrame calls zbDebugFrame() at its start, inside #ifdef ZB_DEBUG. Neither the matching build (uv run match) nor the Windows 98 rebuild defines ZB_DEBUG, so the compiled code is unchanged; grep -rn ZB_DEBUG decomp/ finds every hook. CMake's ZB_DEBUG option (default on) adds port/debug/ to the game and defines it. uv run port build and run build it in; uv run port package leaves it out of the published site unless given --debug-tools.

Giving commands

Commands are separated by ; or newlines (# starts a comment) and queued to run when the game is at rest: active, no scene change pending, and no dialog open (while a dialog is open only the commands that look, wait or send input run: screenshot, get, assert, dump, wait, click X Y, key and quit, which is how a dialog is operated; the rest wait for it to close). "At rest" also means that none of a scene's own callbacks (open, close, frame, key) is running: they often run the main loop themselves while they wait for a sound or an animation, which calls the frame hook again from inside them, and a command run there would change the scene under them. zbdebug.cpp wraps each scene's callbacks to count them (before the game starts). A command that changes the scene holds up the ones after it until the scene it entered is open. The game starts in scene 0 (the intro), so a first command like scene 1 waits until the intro's frames run.

WhereHow
command linezoombinis --cmd "scene 9; party 8" (repeatable), --script commands.txt
uv run port run--cmd, --script, with headless_wasm or this machine's target, --screenshot, --seconds
browser?cmd=scene%209 in the URL (repeatable); zbDebug("scene 9") in the console (it queues the text and returns; the game picks it up on its next frame)
uv run port run headless_wasm --seconds 30 --screenshot build/port/shot.bmp \
    --cmd "debug on; level 1 3; party 8; scene 9; wait 2000; assert scene 9; dump"

assert makes quit (and so the process) exit with status 1 if any assertion or command failed; results print to the console prefixed [zbdebug].

Concepts

The commands name things from the game's own structure; this is what they are (the gameplay chapters have the detail).

  • Scene. The game is a set of numbered screens, and only one runs at a time (currentScene). The table below lists them. Changing scene is what scene N does.
  • Group. The twelve puzzle scenes (7-18) come in four groups of three, played in order: group 1 is scenes 7-9, group 2 is 10-12, group 3 is 13-15 and group 4 is 16-18. Clearing a group's last puzzle (9, 12, 15 or 18) sends the party to a camp or Zoombiniville. Groups 2 and 3 are alternatives: Shelter Rock offers either, and finishing either opens Shade Tree. See Modules and scenes.
  • Level. Each group has its own level, 1 to 4, and every puzzle in the group reads it to choose its rules (what it asks of the player, the number of choices, and so on), so level 1 is the first and level 4 the last, hardest tier. Each time the player clears a group's last puzzle that group's level goes up by one (to a maximum of 4), so a second journey through the same puzzles plays harder. (The port changes that, see Perfect clears per level.) level 2 3 makes scenes 10-12 play as level 3. The game stores levels as 0-3 in gameState, the commands use 1-4. clears G [N] shows or sets (0-3) the group's count of perfect clears towards its next level, and assert clearsG N checks it.
  • Practice mode. A mode the map offers (Ctrl-P, then a key 1-4): any puzzle is played at one chosen level whatever the groups' levels are, with a practice party, and nothing is saved to the journey. While it is on, leaving a puzzle goes back to the map. It overrides level. practice L turns it on (L 1-4) or off (0).
  • Party. The Zoombinis that set out on a journey, up to 16 (party() in gameState). Puzzle scenes make one view per party member when they open. Zoombini Isle and the two camps keep their own lists of waiting Zoombinis, which party does not touch, so use party before jumping to a puzzle scene (7-18), not to fill a camp.
  • Journey map. Between most scenes the game shows the party travelling over the map (scene 2). scene N skips it unless given map.
  • Camps and their "unlock bits". Shelter Rock (4), Shade Tree (5) and Zoombiniville (6) can be visited from the map only after the group before them has been cleared. The game remembers this as bits in gameState: for each group, one bit per level it has been left at. Shelter Rock opens on gameState[0x50] & 0xf (group 1), Shade Tree on 0x52 (the low nibble is group 2, the high nibble group 3) and Zoombiniville on 0x51 (group 4). The map reads such a nibble as a level number while the group is still at level 1, so only 0 (not cleared) and 1 (cleared) are valid there: a nibble of 15 makes the map index past its four levels' views and crash (openMap, in runViewScript). unlock therefore sets only the lowest bit of each group's nibble (0x50 and 0x51 to 1, 0x52 to 0x11), as the game's own debug key @ does, so every camp can be chosen on the map. It doesn't change the levels or the records.
  • Records. Zoombiniville's monuments (scene 6) each commemorate one journey the player completed: a date, a group and a level. gameState holds up to 16 of them, and the town draws one monument per record. The game adds one when the last puzzle of a group is cleared at a level it hasn't recorded yet. records N makes the first N slots (in order: group 1 at levels 1-4, then group 2, and so on) into completed journeys dated 1 January 1996, and clears the rest, so records 0 empties the town and records 16 fills it.
  • Waiting. Commands run in order, but only when the game is at rest (running, no dialog, no scene change under way). scene N also holds up the commands after it until the scene it entered has opened: scene N, or with map the journey scene (2) on the way, which stays up until its narration has played (about twenty seconds in the headless port); follow it with wait scene N to wait for N itself. wait scene N holds them until scene N is the current scene, which is for changes that something else makes: a --click, a key, a puzzle finishing. It continues at once if the game is already in N, and the rest of the queue stalls if N never comes. wait MS holds them for that many milliseconds. A wait after scene is what gives a scene time to start and draw before a --screenshot or assert.
  • Debug mode. debug on turns on the game's own debugging keys (below), the ones its hashed cheat enables.

Scenes

#SceneWhat it isNotes for scene N
0introthe logo movie, then onthe game starts here: do not jump to it while it is showing, which opens the intro a second time and corrupts the heap (set the saved scene during the logo and click instead)
1mapthe world map
2journeythe party travelling between placesentered with a route chosen by the game; not useful to jump to
3isleZoombini Isle: making the Zoombinis
4campShelter Rock, the first camp
5camp 2Shade Tree, the second camp
6townZoombiniville, with the monumentsdraws the records
7bridgeAllergic Cliffs (group 1)
8tunnelsStone Cold Caves (group 1)
9pizzaPizza Pass (group 1, the last)
10ferryCaptain Cajun's Ferryboat (group 2)
11lillyTitanic Tattooed Toads (group 2)
12slidesStone Rise (group 2, the last)
13fleensFleens! (group 3)
14hotelHotel Dimensia (group 3)
15netMudball Wall (group 3, the last)
16cavesThe Lion's Lair (group 4)
17smokeMirror Machine (group 4)
18mazeBubblewonder Abyss (group 4, the last)
19, 21catcha hidden throwing mini-gamesee Hidden scenes
20targetsa hidden target-shooting mini-game

The puzzles are described in Gameplay and the code, and the table's source, with the module and archive of each, is in Modules and scenes.

Commands

CommandDoes
debug on|offturns the game's debugging keys on or off (below)
transitions on|offthe options' "transitions" (Ctrl-T): the game starts with it on, and off is what shows the journey screen (scene 2) between scenes
scene N [map]leave the current scene (the way the game does, closing it) and open scene N (0-21), skipping the journey map unless map (which goes by the journey scene, 2, if the game shows one between the two); holds up the commands after it until the scene entered is open
level G Lgroup G (1-4) is at level L (1-4): its three puzzles now play at that level
practice Lpractice mode at level L (1-4); 0 leaves it
party Nthe party that sets out: N Zoombinis (up to 16), all on board, each a different kind, with names made the way the game makes them. It is made again on every later scene, as leaving a scene can empty it
unlockmarks every group as cleared (the lowest unlock bit of each), so the map's camp hotspots can be chosen
records Nthe first N of the town's 16 monument records are completed journeys; the rest are cleared
state get OFFSET [SIZE], state set OFFSET VALUE [SIZE]read or write 1, 2 or 4 bytes (default 1) of gameState at a byte offset, for what has no command (layout); numbers can be decimal or 0x hex. Nothing checks the values: one the game doesn't expect (such as a camp nibble above 1) can crash it
cheatcode HASH CODEset the game's cheat tracker (cheatHash, cheatCode) to those values, so that the next isCheat(HASH, CODE) test passes. This suits tests made when a hotspot is clicked (the map's hidden scenes, though scene 19 and 20 are simpler); a key typed afterwards shifts the tracker, so it can't trigger the key-driven ones
click X Y [press|move|release]click the mouse at a point of the screen now, or only press, move or release the button (a drag is click X Y press; wait 300; click X2 Y2 move; wait 300; click X2 Y2 release)
zoombinislist the party's Zoombini views in the order they were made (the party's order): where each one is, its features, name and state. The numbers below are these indexes, from 0
click zoombini Nclick the middle of Zoombini N's picture
drag zoombini N X Ydrag Zoombini N so that its feet end at (X, Y): the grab is at its middle and the game puts the feet where the pointer is, less that offset, so X, Y is where it should stand
drag zoombini N place Kthe same, to the K-th (from 1) of the scene's placed points (places): where a puzzle's drop spots are (a bridge's start, a seat, a room's door)
drag X1 Y1 X2 Y2a drag from one point to another (press, three moves with a pause each, release)
toadsin Toads (scene 11): list the pieces at the left (position, attribute and value) and the board's rows (entry point, left pad's attributes): a piece goes into a row where the pad's attribute (1-3) has its value
placeslist the scene's placed points (where a dragged Zoombini can be claimed: placedViewPoints, with which are taken) and its standing spots (viewPlaces)
key CODEgives the game the key CODE as if typed: ASCII for characters (key 0x4e is N), 1-26 for Ctrl-A to Ctrl-Z. The cheat tracker sees it too: key 1; key 109; key 105; key 100; key 105; key 32 types the real code Ctrl-A midi (the game's MIDI test)
roster save, roster loadwrite gameState to the current saved game, or read it back
wait MS, wait scene Nhold up the commands after, see Waiting
set NAME VALUE, seed Nwrite a game global by name (below); seed seeds the game's random numbers (randomSeed), which it otherwise takes from the time
wait until NAME OP VALUEhold up the commands after until the value passes the test (==, !=, <, >, <=, >=): wait until crossingUnderway == 1
screenshot NAMEwrite the screen now as NAME.bmp beside the --screenshot path (with uv run shots, a recipe's also pictures)
get NAME, assert NAME VALUEprint or check a value; the names are scene, pending (the scene about to open, -1 if none), practice, party (the count), zoombinis (the Zoombinis on the screen: a puzzle takes the party into its own list, so party reads 0 inside one), debug, dialog (non-zero while a dialog is up), transitions, due (the scene the current one is about to leave for), clock and viewclock (the game's clock in 60ths of a second, and the time since the last input), level1-level4 (1-4) and state:OFFSET[:SIZE]
paldiffprint which entries of the scene's own palette (loadedPalette) differ from the one the screen fades to (targetPalette): none when a scene's colours are right; for finding scenes that don't copy their palette
dump, help, quitprint the main state, list the commands, exit (status 1 if any assertion or command failed)

click and --click are the mouse: click X Y (on the 640×480 screen) clicks now, and press, move and release after it make a drag with waits between; --click MS:X,Y does the same at a time after the start.

Examples

# Allergic Cliffs at level 3, with a party of eight
level 1 3; party 8; scene 7

# The town with a full set of monuments
records 16; scene 6; wait 1000; dump

# Practice mode in Pizza Pass at level 2
practice 2; party 8; scene 9

# A test: it must end in the Mirror Machine
party 8; scene 17; wait 500; assert scene 17; quit

Debug keys

With debug on the game's own debugging keys work (mainloop.cpp:gameKey), and key CODE sends them: N (0x4e) draws the paths, P (0x50) shows the frame rate, S (0x53) toggles sound tests, ^ (0x5e) shows memory statistics, & (0x26) draws the palette chart, ] (0x5d) and [ (0x5b) turn step mode on and off, Tab (9) chooses every Zoombini on Zoombini Isle, Ctrl-R (18) shows the dragged Zoombini's position, Ctrl-Z (26) fills the views, @ (0x40) sets the lowest camp bits. In the map + and - change the practice party size.

Cautions

  • On the web, C: is persisted in IndexedDB: a command that changes the state, and any scene the game then enters, can end up saved over the player's roster. Use a private window for experiments.
  • scene N skips the game's own setup of that scene; give it a party (party) and levels (level) first, and note that # comments run to the end of a ;-separated command, not the line.
  • The commands were written without a runtime to hand: if one misbehaves, fix it here and in this table.

Game globals by name

get, set, assert and wait until also take the name of any integer global (char, short, int or long, signed or not, alone or as an array of one or two dimensions: name[3], name[1][2]) that decomp/'s headers declare and a source defines: get bridgeLevel, get queuedCount, wait until sentBackCount >= 1, set clickToDragOption 0. The table is generated from the headers by zbtools.debug_globals (uv run port build writes build/port/generated/debug_globals.inc), so a renamed global keeps working and a new one appears; structs, pointers and anything else aren't in it. Reading a puzzle's own variables is how a script waits for the game rather than for a time, and how to find out what a puzzle thinks is happening.

Playing a puzzle

A puzzle is played with drags, and a few things about the game's own input matter:

  • Turn "sticky mouse" off (set clickToDragOption 0; set dragClicks 0, the options' Ctrl-J): with it on (the default) the game treats a release as "pick up" and waits for a second click to drop, so a scripted drag would hang.
  • Aim by where the Zoombini stands. The game claims a drop spot when the Zoombini's feet are within placeSnapRadius of it, which is why drag zoombini N place K and drag zoombini N X Y work in feet, not pointer, coordinates.
  • Pause before the release (the built-in drags do): the game's drag loop has to see the pointer at the end before the button goes up.
  • Wait for the game, not the clock: wait until crossingUnderway == 1, wait until placeHeld == 0 and the like. While a drag or a click handler runs, the game runs its own loops, and the commands go on in them.

Oracles: solving a puzzle by its rule

A puzzle is won by working out a hidden rule, which a recorded list of moves can't do reliably (the rule depends on the random numbers, and the list breaks whenever they shift). An oracle is a debug command that reads the rule from the game's own state and plays the next correct (or deliberately wrong) move through real mouse input. They are in port/debug/oracles.cpp and are not part of the game. An oracle command is turned into plain commands (drag ..., wait until ...) at the moment it runs, so it sees the state as it is then; each one that plays a move says what it chose (cliffs: zoombini 3 to bridge 2 (right)), and an oracle may add values to get/assert/wait until (cliffsAcross, cliffsWaiting).

CommandDoes
cliffsAllergic Cliffs (scene 7): lists every Zoombini with its features, the bridge where the cliff lets it across and whether it is waiting
cliffs pick right|wrongdrags the first waiting Zoombini to its right bridge (or the other one); fails if six have been sent back (the cliff takes no more)
cliffs send right|wrong [N]N times (once): waits for the queue and the crossing to clear, then cliffs pick; waits a moment after each drop for the game to take it

| tunnels | Stone Cold Caves (scene 8): lists every Zoombini with the doors that let it in (the rule turnedBackAtDoor, and at level 0 the pair of doors that is shut) and whether it is waiting | | tunnels pick right\|wrong | drags the first waiting Zoombini to a door that lets it in (or turns it back); fails if there are no turn-backs left (the doors take no more drops) | | tunnels send right\|wrong [N] | N times (once): waits for the guards to be done with the last one, then tunnels pick |

| pizza | Pizza Pass (scene 9): what each troll wants (topping numbers from 0), their states, the pizzas left and whether a pizza can be served now | | pizza make right\|wrong\|partial | toggles the toppings with the buttons and serves the pizza, now: for the first troll not yet satisfied, exactly what it wants (right), that and one it doesn't want (wrong: it rejects the pizza) or one short (partial: it asks for more) | | pizza serve right\|wrong\|partial [N] | N times (once): waits until a pizza can be served (pizzaReady), then pizza make; a right one does nothing once the puzzle is solved |

| ferry | Captain Cajun's Ferryboat (scene 10): a seating of every Zoombini where each two touching places hold Zoombinis that share a feature, found by search, and how many nodes it took | | ferry links | which places each place touches (ferryLinks) | | ferry seat right\|wrong | drags the next Zoombini of that seating to its place (they are seated in place order, as the game checks a drop against the occupied places it touches); wrong drags a waiting Zoombini to a free place beside one it shares no feature with, so it is sent back | | ferry send right\|wrong [N] | N times (once): waits until nothing is walking back or sailing (ferryIdle), then ferry seat |

| toads match | Titanic Tattooed Toads (scene 11): the toads that could cross from a free row now, and the rows (a toad with attribute a and value v crosses from a row whose first square has v at a and whose squares with v join up, up/right/down/left, to the far column) | | toads place right\|dead\|wrong | drags the next toad to a row it crosses from (right), to one whose first square fits but from which it can't cross (dead: it stays on the board for good), or to one it doesn't fit (wrong: it goes back) | | toads send right [N] | N times: waits until a toad that can cross is free (the toads come back for the next trip), then toads place right |

| stone | Stone Rise (scene 12), levels 1 and 2 (the row levels): an arrangement of the Zoombinis on the listed cells where every feature stone (a cell whose snoid is 510 hair, 511 eyes, 512 nose, 513 feet) has the two Zoombinis either side of it sharing its feature, found by search | | stone dump | the board: the listed cells and every non-empty cell with its state, stone code and links | | stone seat right\|wrong | drags the next Zoombini of the arrangement onto its cell (in cell order); wrong drags a free Zoombini onto a free cell beside a seated one it shares no feature with (so the stone stays dark) | | stone send right [N] | N times (every cell): stone seat right |

| fleens | Fleens! (scene 13): which Zoombinis have one of the three picked fleens (the ones that stand apart) | | fleens pick right\|wrong | drops the next Zoombini whose fleen was picked (or wasn't) on the place in front of the fleens | | fleens send right\|wrong [N] | N times (three): waits until the scene is at rest (fleensIdle), then fleens pick |

| hotel | Hotel Dimensia (scene 14): what the rooms sort by, and for each waiting Zoombini the places it fits | | hotel intro | while the guide's introduction is on (talkerStarted), clicks to skip it | | hotel place right\|wrong | drops the first waiting Zoombini on the first place it fits (or doesn't). Levels 1 and 2 plan which column and row each feature value takes, so that no needed room is one of those boarded up; level 3 does the same for rows, layers and columns, over the rooms that can be dropped on | | hotel fill | until every Zoombini is in a room: waits for the scene to be at rest (hotelIdle), then hotel place right, trying again if the game didn't take a drop; gives up with an error after 120 tries | | hotel send right\|wrong [N] | N times, when the scene is at rest, hotel place | | hotel reach | the places a Zoombini can be dropped on |

| mud dump | Mudball Wall (scene 15): the groups' sizes and which tiles of the wall have Zoombinis behind them (placeGroups: the count, -1 once found or missed) | | mud shoot right\|wrong [TILE] | sets the shape and colour codes (a third, at levels 3 and 4, with the layer) that findCodeEntry maps to a tile that has Zoombinis behind it (or to one with none), spacing the clicks (one is ignored while the last code is being shown), and fires; TILE names the tile to try | | mud fill | until no tile has Zoombinis behind it: waits until the machine is ready (mudIdle), then mud shoot right | | mud send right\|wrong [N] | N times, when the machine is ready, a shot |

| lion | The Lion's Lair (scene 16): the stones each Zoombini not yet on one fits (a free stone that wants its values of the roster's features, as pickCave tests the one it was put on) | | lion place right\|wrong | drops the first Zoombini not on a stone on a stone that wants it (or one that doesn't: it walks to one that does) | | lion send right\|wrong [N] | N times (every Zoombini): waits until nothing is walking (lionIdle), then lion place |

Values: cliffsAcross (the Zoombinis that have crossed), cliffsWaiting (those standing among the waiting ones); tunnelsIn (let in), tunnelsWaiting, tunnelsQueued (entries the guards have yet to deal with); pizzaReady (a pizza can be served: the next Zoombini has come up with it and nothing is animating, or the puzzle is solved); ferrySeated (Zoombinis seated on the ferry), ferryIdle (nothing walking back, sailing or arriving); toadsAvailable (toads that could cross from a free row now), toadsOnBoard (toads set down and not yet back, hopping included); stoneLit (the Zoombinis on lit cells); fleensIdle (nothing walking up or being put down); hotelIdle (the hotel takes a drop: the introduction is over and nothing is arriving, being turned away or being reset); mudIdle (the machine takes a shot: nothing flying, crossing or being said, and shots are left); lionIdle (no Zoombini is walking to a stone and the drag is open).

level 1 2; party 16; scene 7; wait 6000
cliffs send right 16; wait until cliffsAcross == 16
assert sentBackCount 0; click 618 458; wait scene 8

An oracle that drags a Zoombini grabs it at a point where the game itself finds that Zoombini (viewAt), since in a crowd the middle of its picture can be under another Zoombini's (drag zoombini N ... grabs the middle, and put the wrong Zoombini down with a party of 16 in Fleens). It also lets the Zoombini go where the game takes the intended place: a drop takes the first free place, in order, within placeSnapRadius of the feet, and where places overlap (the hotel's 3D rooms) the place's own point may belong to a lower-numbered one, so some places can't be dropped on at all.

The other puzzles get theirs as their cases are written (see the coverage map).