WP-090: Phantom’s Knights of the Snack Table: the serving game (Gen 1)

Status: ✅ Done (2026-11-27). Fork PR barefootbetters/scummvm#15 merged on 2026-11-27 (merge commit d18cb66884). Phase: 5 (a defect found in the Phantom closeout’s live play) Depends on: WP-055 ✅ (Pie Noon, the sibling class), WP-057 ✅ (a room’s own Room::Actor sprites), WP-073 ✅ (the room’s claim and entry) Companion EC: none (inline checklist under Exit criteria) Pre-flight: pre-flight-WP-090-2026-11-27. Required: the packet modifies engines/terraglyph/**. Targets generation(s): Gen 1, Phantom of the Knight only. Showdown has no such room. Estimated effort: Half a day


The room played by WP-116 (2026-11-29) through the engine’s own event path: the serving game matched this port. One gap was in the engine: through the opening, the cursor was hidden in the top rows, where the room’s tick shows it.

Goal

Make ROOM_P31_KST (Knights of the Snack Table) playable. Port the original’s serving game from the decompile of class 0x419700 and the sprite classes it builds, and replace the placeholder that WP-073 left.

Background

Jeff’s live play of Phantom on 2026-11-27 found the room unplayable. Shaggy stood at his post, no knights appeared, nothing answered the mouse, and the counter read 13 at Spooky. The fork’s KstRoom (engines/terraglyph/kst_rooms.cpp at 1c02ca7ecd) read neither the mouse nor clicks. Its tick spawned knights on a timer, and each knight slid to a seat and served itself. WP-073 said so under Deviations: the serving loop was “modelled from the trace, not simulated”, and the three sub-controllers were “not reproduced”. Its self-test covered the setup only, so it passed.

WP-073 had also read the room’s purpose from marker names, and that reading was wrong. The decompile shows the room is a bartender game. +0xE8 holds the mugs the player has left (five less the difficulty), not knights still to serve. The counter shows the snacks the player has. The room exits to the dining room when the mugs run out, not when a quota is met. The three “sub-controllers” are the lists of full mugs, empty mugs and mugs left. The packet’s brief carried WP-073’s model, and the Result below says where the code differs from it.

Scope

In scope:

  1. Fork, engines/terraglyph/kst_rooms.{h,cpp}: Shaggy (0x4192F0, update 0x419370), the knights (0x418CA0, 0x418EE0), the full and empty mugs (0x418710/0x418860, 0x4189B0/0x418B10), the three lists, the room’s tick (0x419E40), a round (0x41A5C0), the entry’s counter, mugs and overlay depths (0x419A80), and the cursor rule.
  2. Fork, room.{h,cpp}: Room::Actor::actorPlays(), so a class can hold a sprite’s player while the room pauses, as the original holds the knights’ and the mugs’ players (vtable +0x08).
  3. Fork, kst_check.cpp: play the game through the engine’s tick with the mouse set directly and rand() pinned to 1, against an independent reference written from the trace.
  4. Docs: scooby-exe gains the serving game, with a correction note on WP-073’s section; this packet; the index row; a pointer in WP-073.

Out of scope:

Exit criteria

  1. Live (session). A run through test_script (move, down, up and screenshots) shows the following: knights arrive; the player serves them with the mouse; the mugs behave as the code says; the counter shows the snacks and the mugs on the counter count down; running out of mugs returns to ROOM_P12_Dining_Room. The brief asked for “the counter shows the right quota and counts down, and meeting the quota returns to the dining room”. The code has no quota, so this criterion is restated from the decompile (see Background).
  2. Self-test. The KST lines match the reference line for line. The rest of the self-test matches the 1c02ca7ecd baseline except the per-run random keys. The build of engines/terraglyph/ has no new warnings.
  3. Process. The fork PR against scooby-engine is open (merged later the same day), and this packet records each claim with its evidence label.

Result (2026-11-27)

Every claim is Gen 1, Phantom. Evidence labels: source (the decompile), self-test, log (the engine’s debug log of a live run), live — session (a scripted run this session drove, with screenshots). Nothing here is live — Jeff. The screenshots, logs and the reference stay local, in this session’s scratchpad.

Decompiler (source). Ghidra isn’t on PATH and GHIDRA_HOME isn’t set. decompdecomp’s toolchain has Ghidra 12.1.4, at %LOCALAPPDATA%\decompnet\toolchains\ghidra, and that copy runs headless on Java 27.0.1. The session imported Scooby.exe (SHA-256 619EA687…AF807ED) into a scratch project outside the repo and decompiled the room’s functions, vtables and constants with a small post-script.

What the original does (source). This is written up in full in scooby-exe. In brief:

The port (source). The fork branch is wp-090-kst-serving, commit a5829afe4e, PR #15, merged into scooby-engine on 2026-11-27 as d18cb66884. Every state, constant and sound name above is in kst_rooms.cpp, with the address it came from. The lists keep the original’s order (newest first), and rand() draws are taken in the original’s order.

Self-test (self-test). kst_check.cpp drives the engine’s own tick with _mousePos and _mouseDown set directly and the room’s rand() pinned to 1. The reference is wp090_ref.py, kept local. It was written from the decompile notes, not from the C++. It reads the placements and the sequences’ step counts from TGIFILE.ART and the clip names from the sound indexes. It models the original’s tree walk: children by descending depth, a new child after every child of at least its depth, and the next sibling read before a child is walked. The 10 KST lines match it exactly, and checked:

The rest of the self-test matched the 1c02ca7ecd baseline built from C:\dev\scummvm: 1815 check lines each. The only differences are the per-run random keys (the drawbridge’s flags, Ewan’s CurrentQuestion). The runtime warnings were identical in both runs; see Found on the way.

Build (log). Terraglyph-only, out of tree in the fork worktree: 0 errors and 0 warnings.

Live (live — session, with log). All runs used start_room=ROOM_P31_KST, a new game (1 snack, level 0), and the engine’s --debugflags=script,input log.

Deviations:

Found on the way:

Deliverables

Notes