1986 · Argus Press Software

The Detective

This minisite was contributed by Nico-van-der-Zijden, air. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/the-detective with me to Gold.

The McFungus house is thirty rooms drawn from seventeen packed pictures, each stretched, recoloured and given its own characters as Snide walks in.

01 · Every room

The house, room by room

Pick a room to draw it from the game's own bytes. Wide rooms scroll in the game; here they are drawn whole.

Drawn in the built site.

Each room is a picture record from the list at $C100, chosen by the room's type in $1BC0. build_room ($388D) clears a map 256 columns wide and 15 rows deep at $0C00, unpacks the record into it ($3BD7), and copies a 40-column window of the map to the screen as the player walks ($35E8). The same record serves several rooms: the corridors upstairs are one picture, and the bedrooms another, told apart by their colours ($1B80, $1BA0) and by which of three sets of characters the room asks for ($1EE0).

Doors are not part of the pictures. Once the picture is in, build_room lays a row of floor along the front ($38F3), then looks through the door table at $1F00 for every door with the room on either side and draws each one open or closed ($3993). Last, it blanks everything right of the picture. The picture above is drawn the same way, as the doors stand when a game starts.

Two things in the pictures move, and neither is a sprite: the game rewrites the characters they are drawn with, so every copy on the screen changes at once. A small flame in the passages, the kitchen and the cellar is character 97. Every fourth frame the interrupt copies one of three 8-byte frames from $E800 over it, in the order 0, 1, 2, 1, so the flame leans left and right ($2C83). The same routine counts the clock's minutes. The fire in the drawing room's grate is characters 52 to 54. Every eighth frame they get the next 24 bytes of a 40-byte ring at $E818, 8 bytes further on each time, so each character takes over the picture its neighbour had, and the fire repeats every 40 frames ($2CC2). The picture above runs both at the game's rates.

02 · Doors

Thirty-two doors in one table

Each door is an eight-byte record at $1F00: the room on one side and the door's column there, the room on the other side and its column there, a flags byte (bit 0 open, bit 1 locked), a type for each side, and the object that unlocks it. Twenty-nine records are used; the last three name no room ($FF).

The type says where the door is drawn and what it is. An even type with bit 1 clear sits in the back wall, and one with bit 1 set is a gap in the front row of floor. The upper bits give the kind, and the game names the kinds itself when the player investigates a door ($892A): types 0 to 3 are "A DOOR", types 8 to 11 are "A SECRET PASSAGE!", and types 4 to 7 get no answer at all. Those are openings: one of type 4 draws nothing whether open or closed, and one of type 6 is always drawn as a gap.

A secret passage hides itself in the drawing. Closed, one in the back wall (type 8) puts back the picture behind it ($3B8B), and one in the floor (type 10) is drawn as six characters of plain floor ($3B97). Investigating it says "A SECRET PASSAGE!", marks it open and redraws it. The house has six, in the kitchen, the cellar, the drawing room and the Reverend's and the Major's rooms, and between the passages and the two areas outside that they lead to.

When a game starts ($8680), every door is closed except the four that are an opening on at least one side and a secret passage on neither, and three doors are locked ($86E2): the study's and Bentley's, whose key is object 15 ("A BUNCH OF KEYS"), and the Professor's, whose key is object 16 ("A BIG IRON KEY"). The cast lock and unlock doors as they go, through their scripts.

The coloured bars under the picture mark each door's columns, as the drawing routines place them, and each piece of furniture's: the first and last column of the rectangle the player cannot walk through ($1B00, $1B20), named from the list at $8401. The small objects are not drawn anywhere: they are kept in the furniture, and the game lists them only when the player opens it.

The floor plan under the bars shows the room from above. Besides a column, Snide has a depth ($1D7D), which grows as he walks away from the viewer: up on the stick adds one. He can stand from one less than the room's front value ($1C00) to one less than its back value ($1BE0), the grey band. Each piece of furniture is a rectangle in columns and depth ($1B00-$1B60), and a task of the main loop ($2EB4) finds the nearest edge on each side of him, which is as far as he can walk. Most furniture stands against the back wall and reaches past it. In the emulator, in the hall, Snide stopped at depth 58 against the back value of 59 and at 7 against the front value of 8, and under the stairs, whose front edge is 26, the back limit the game keeps ($1DEF) became 26. The plan ignores the picture's perspective: doors and passages in the back wall (types 0 and 8) are drawn a quarter of the room's depth to the right of their column, and the plan marks them where they are drawn.

03 · The pictures

Seventeen records, packed a bit at a time

A record is the address of the next record, the picture's width in columns, and then the picture as a stream of bits, read lowest bit first ($3D56). The stream is a series of runs. Each run is a count byte and one bit: with the bit clear, each character of the run is a whole byte; with it set, a 4-bit high nibble follows and each character of the run takes only 4 bits of its own ($3C3D). A count of zero ends the picture. Rooms are mostly walls and floors drawn from a few neighbouring character codes, so most runs cost half a byte a character.

RecordAddressWidthPacked bytesRooms

Records 10 and 11 are not any room's own picture: they are laid over the landing and the hall, from the left edge, once two of the cast are dead ($3D0A). Record 16, the last, is used by no room.