1989 · Taito America

Qix

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

The C64 Qix keeps its whole playfield three times over and tells the walls from the line you are drawing by colour alone. Its music player skips one frame in six on American machines, so the tunes play at the same speed everywhere.

01 · The game

Claim the screen, avoid the Qix

You steer a marker round the edge of an empty field. Holding fire takes it off the edge to draw a line; when the line reaches the edge again, the side without the Qix is filled in and becomes yours.

The title screen

The title picture, a multicolour bitmap loaded with the game.

Play: a claimed block in the corner, the Qix in the middle

Level 1 with 6 % claimed: the patterned block, the Qix (the blue lines), the Sparx on the edge, and the timer bar to the right.

The Qix is a bundle of lines that wanders the open field. If it touches the line you are drawing, you lose a life. Sparx run along the edges and kill on contact; a Fuse burns along your line if you stop half way. A level ends when you have claimed the share the level asks for: 65 % at first, 80 % by level 9.

A line drawn with fire held is a slow draw, and it scores twice as much as a fast one, drawn with fire released. Two Qix on one level can be split, by walling them into separate regions, for more points.

02 · One frame, rebuilt from memory

The colour of a pixel says what it is

The play screen is a multicolour bitmap: 160 pixels across, each one of four colours. The game uses the colour as the map.

One frame of level 1 drawn by the site's renderer from the memory and register writes recorded in the emulator. 94,822 of its 94,848 pixels match the emulator's own picture; the 26 that differ are on the Qix's newest line, which the game draws while the beam is passing.

The game keeps three copies of the field. The one on screen is at $2000; two more at $6000 and $E000 hold the same picture for the game to read. Every routine that asks "what is here?" looks up one pixel in the $E000 copy ($8D10) and compares it with the four masks at $150B: colour 3 is the edge the marker may walk, colour 1 the line being drawn, and colour 2 a line that kills.

A slow draw and a fast draw differ only in that check. The marker moves one pixel a step; with fire held, the step is skipped on every other pass ($991C). Moving onto colour 2 is a death. Reaching colour 3 closes the line, which $B243 then repaints as edge.

03 · The music

Music: eleven tunes, one frame in six skipped

The game stores eleven three-voice tunes. The title plays the longest; the others are shuffled and one plays at the end of each level.

The tunes played by the game's own music player: its bytes from $E000, run once a frame on the kit's 6502 simulator inside the page and heard through the site's model of the SID. Checked against the original code in a 6502 simulator: every register write of every frame of all eleven tunes, 14,159 frames, matches. The player reads three zero-page bytes before it writes them, so the first frame of a tune depends on what the game left there; the page starts from the title's values.

The player is a copy: the game loads it at $4000 and copies the 8,000 bytes to $E000 before the title and before each level's end tune ($884C). Play reuses $E000 as one of its three planes, so the music has to be put back each time.

The interrupt calls the player 60 times a second on an American NTSC machine and 50 times on a European PAL one. To keep the tempo the same, the start-up checks which machine it is on and patches two bytes of the player before the copy ($8030). On NTSC they make the player count six frames and skip one; on PAL the count never skips. Each voice reads a stream of notes and 21 commands (repeats, calls, jumps, transposition, waveform, filter, vibrato and sweeps), dispatched through a table per voice ($ED2B).

The Internet Archive's recording of this music credits Tim Follin. Nothing in the program names a composer.

04 · Scoring

Bug: splitting the Qix does not double the score

The manual says splitting two Qix multiplies the points for every fill after it. The code doubles only the low byte.

The arithmetic of $8E60, ported and checked against the game's own routine in a 6502 simulator over 3,150 cases (areas from 0 to 65,535, slow and fast, 0 to 4 splits): every result matches.

A fill is worth half its area in pixels, doubled for a slow line ($8E60). A line counts as fast when it ends with fire released. Each time a player splits the Qix, a counter goes up, and it stays up for the rest of the game. The score routine doubles the points once for each split, with a loop that adds the low byte to itself and carries into the high byte without doubling it. Below 256 points the doubling is right; above, most of the bonus is lost. A 4,000-pixel slow fill after one split scores 4,160 where it should score 8,000, and after two splits 4,224 where it should score 16,000.

When a level ends, the claim over the requirement earns 1,000 points a percent ($8E13). The claimed percentage is the high byte of the player's claimed pixel count, so one percent is 256 pixels of a field about 25,000 pixels inside.

05 · Progression

Each level is a row of one table

Fourteen settings per level, in tables at $1181: the claim needed, how many Qix, when each enemy appears, how hard the Qix leans towards you.

Read from the level tables at $1181-$121A by $9061. From level 12 on the game alternates the settings of levels 10 and 11.

The table explains how the difficulty climbs. Levels 3 and 4 bring a second Qix and Sparx that chase you up your line. Level 5 asks for 70 % and lets a pair of creatures loose in the open field. From level 7 the Qix pulls twice as hard towards the side of the screen you are on, and the timer bar may run out only once before every Sparx is out.

The game prepares the player for both changes. At the end of level 2 it shows "SPLITTING QIXS MULTIPLIES POINTS", and at the end of level 4 "CAPTURE SPRITZ FOR EXTRA POINTS" ($1786).

06 · The enemies

Sparx follow the edge towards the Qix

Every enemy is a sprite, and each kind moves by its own rule.

EnemySpritesHow it movesWhere
The Qixnone: lines in the bitmapTwo ends, each with a speed across and down. Every few steps each speed may reverse at random; at a wall it reverses with a pull towards the marker. The last eight lines stay on screen as a trail (sections 07-09).$946A
Sparx2-7, in three pairsWalk the edge pixel by pixel, one each way round; at a junction they take the branch nearer the Qix. They start halfway round the edge from the marker.$A1C0, $9F1D
Chasing Sparx4-5From level 3, once they reach the corner where your line left the edge, they follow the line itself.$B200
The Fuse1Appears when the marker stops while drawing, runs along the line from its start, and burns the line behind it into the killing colour.$8AC4, $AFD3
Spritz2-3, from level 7 also 6-7Start at the middle of a Qix's line and fly diagonally through the open field, turning by a table of 28 wall patterns. One that is walled in all round makes every later line score as slow, until you die.$9B3A, $9D47

The Sparx are released by the timer bar to the right of the field. It shortens from both ends, a pixel row at a time; each time the ends meet, the count of runs goes up and the bar is drawn full again ($85FD). Each pair of Sparx has a run count of its own in the level table.

07 · The Qix

The Qix is two bouncing points that turn back at random

The Qix has no path to follow and no target. Its line joins two points, each with a speed across and a speed down, and every few steps a random draw sends most of those speeds the other way.

Once a pass of the main loop, about 14 times a second, the game moves the Qix one step ($946A). The step erases the oldest of the eight lines on screen, moves the two ends, checks the new line against the claimed edges, and draws it. On the levels with two Qix the step serves them in turn, so each moves half as often. Both start each life on the same short line in the middle.

A speed is a signed byte: 3 or 4 pixels across, or 4 or 5 lines up or down. The game never changes a speed by a little. Every change draws a new size and flips the sign, because the routine that makes the new speed takes the old one's sign as its input ($A555). These are the only moments a speed changes:

WhenWhat the game doesWhere
The turn timer runs outDraws a new timer, then reverses each of the four speeds with a chance of three in four. No pull.$94C4
An end would leave the box two pixels inside the fieldReverses that speed and adds the pull towards the marker. The end stays put for this step.$92AD
The second end is 30 or more from the first, across or downMoves the second end 5 towards the first until it is closer. The Qix never spans more than 29 either way.$9313
An end's move crosses a claimed edgeTests the move across and the move down on their own, and reverses each one that crosses, as at a wall.$96CA
The new line itself still crosses a claimed edgePuts the Qix back on the oldest line of its trail and clears the timer (section 09).$9774
After every stepChooses the pull for the next bounce on each axis: towards the marker, from where the first end now is.$954F

A bounce also draws a new turn time, but stores it at $0273, which nothing reads. In 1,600 steps watched in the emulator, nothing did. A bounce leaves the turn timer running as it was.

Bug: Qix 2 has its own copy of the edge test, and one line of the copy reads Qix 1's height ($982F). When the game tests Qix 2's second end moving across on its own, it tests a line to that end's new position across but at Qix 1's height. So Qix 2 can bounce off an edge its move would not have crossed, or miss one it would. A replay of a two-Qix recording with the line read correctly drifts from the game after 288 steps; with the slip kept, all 400 steps match.

The turn timer is what changes most between levels. The game draws a random byte and keeps it when it falls between $20 and $3E, about one draw in eight; any other value is cut to 0-3. The level's mask ($6F) then caps the result. On level 1 the mask is 3, so the Qix turns every one to four steps and shivers about the middle of the field. From level 2 the one draw in eight lets the Qix run straight across the field.

LevelsSteps between turnsPull added at a bounce
11-4none
31-4; one turn in eight, 1-8none
2, 4, 5, 61-4; one turn in eight, 1-311
7 and later1-4; one turn in eight, 33-482

The pull is all the hunting the Qix does, and it works only at a bounce. The pull is added to the new speed on that axis, towards the marker. On level 7 a Qix that bounces off the far wall comes back towards you at up to 7 lines a step, and one that bounces off a wall on your side leaves at 2 or 3. In open field the Qix never steers.

    The viewer runs the game's own rules. It is a port of the Qix's step and the line routine it uses for every test and every pixel, down to the order of the random draws. Given the random numbers the game drew, it repeats 1,000 steps of one Qix and 400 of two, recorded in the emulator, exactly, in an open field and in fields with claimed corners. Levels 3, 4, 6, 8, 9 and 11 bring a second Qix, as in the game. Click the field to move the marker; the pull points at it. Your line lays a line being drawn up from the marker. The Qix colours are those of the frame in section 02.

    08 · The trail

    Secret: the Qix's whole trail can kill you, up to eight steps late

    The Qix on screen is eight lines, the newest and the seven before it, kept in tables of ten slots, of which the game uses eight ($021E). The game draws a new line and erases the oldest with one pixel routine ($AD64). That routine checks every pixel against the line you are drawing, whether it is drawing or erasing. So the newest line kills when it is drawn across your line, and the oldest kills when it is erased from under it.

    A line you draw across the middle of the trail is safe for a moment. The old Qix line it crossed is still on screen, and nothing checks it again until it becomes the oldest. Then the step that erases that line takes your life, up to seven steps, half a second, after you crossed it. In the emulator, a pixel of a line being drawn was placed under trail lines of different ages, six times. Five of the six kills came from the erase.

    The erase clears every pixel of the old line, including the pixels where newer lines cross it, so the trail on screen has small gaps. Drawing a line over a Qix pixel flips the pixel's colour bits instead of setting them, so crossings change colour.

    09 · The fallback

    Secret: a cornered Qix jumps back to where it was eight steps ago

    The edge tests check each end's move. They cannot see the line between the two new ends, which can cross a claimed corner when the open field is not a rectangle. The game tests that line last ($9774). When it crosses, the game gives up on the step and puts the Qix on the line in the trail slot it is about to overwrite: the oldest line, the one it erased at the start of this step. The timer is cleared, so the Qix turns on the next step.

    On screen the Qix jumps back to where it was eight steps before. In the emulator, a peninsula of claimed edge was added to the field; in 500 steps the Qix fell back five times, and each time it landed on its line from exactly eight steps earlier. Choose A peninsula or A claimed corner in the viewer above and watch the log for it.

    10 · Controls

    Either joystick port works

    The stick is read once a frame by the interrupt ($83DF), from both ports at once: the two port registers are combined with an exclusive OR, so a stick plugged into either port moves the marker. A diagonal is ignored in favour of the last straight direction, so the marker never cuts a corner. RUN/STOP pauses the game, and any stick movement resumes it ($81D9). RESTORE does nothing: the game points the NMI at a bare return.

    11 · Loading

    Secret: the game reloads itself after every game

    Play uses almost all of memory: the three copies of the field, the music's space at $E000 and the title's code. So when a game ends, the C64 loads the whole program again from disk ($1B97). The attract demonstration, which plays a game by itself after the title tune, loads the title picture back ($C2E0), and every level end loads a 134-byte file called TAITO that nothing then runs ($1A8D). Each load comes with three tries and a "DRIVE ERROR / CHECK THE DISK" screen.

    The attract demonstration naming the enemies

    The attract demonstration, driving the real game engine with scripted input and naming each enemy as it appears.

    Game over

    Game over: next comes a load of the whole game.