1987 · Incentive Software

Driller

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

A solid 3D moon on a 48K Spectrum, drawn the way a painter works: every face of every shape in view is sorted by distance and filled in from the back, so the nearest faces simply cover the rest.

01 · The game

A probe, eighteen platforms and four hours

The title screen: DRILLER, introducing FreescapeThe probe in Amethyst at the start of a game, with the console below the view

Mitral, a moon mined and then abandoned, is filling with gas, and the gas will blow it apart in four hours. You drive a probe over the eighteen platforms built on its surface. In each one you find where the gas lies and teleport a drilling rig onto the spot; a rig close enough to the pocket makes the platform, or sector, safe. Make all eighteen safe before the clock runs out.

Everything is solid and you can look any way you like. The platforms hold buildings, doors, crystals and switches, and sensors that shoot at the probe and wear its shield down. Energy goes on drilling and on time, and some puzzles need a jet, kept in a hangar, that flies where the probe cannot.

Incentive called the engine Freescape. Each area is a list of boxes, pyramids and flat shapes, and each shape can carry a short script that runs when it is shot or walked into. The Maps tab draws every area.

02 · The view

The view is painted from the back, one face at a time

Pick an area and an entrance, then paint the view and watch the order the faces go in.

Heading

The probe at the entrance at the start of a game, drawn by the Play tab's port of draw_view on the memory the tape loads, with a copy of the view put on the screen after each call of fill_face. The port is held to the game's own code byte for byte in the lockstep test, and its drawing of the view at a moment saved from the emulator matches the game's screen in every pixel. The heading is in 72nds of a turn, as the game keeps it; the view keeps the entrance's place and pitch.

A picture takes several steps, all in draw_view at $6B12. First the area is cut down to the box that can be in view (bound_view_box). Each object then has its corners turned by the view matrix, made from the heading, the pitch and the roll and a table of sines at $8E78. A corner is turned without a multiply loop: before each picture, make_multipliers writes nine short routines of Z80 code into memory, one for each number in the matrix, each of which multiplies by that one number. The faces are clipped against the edges of the view and projected, and each visible face goes into a list.

sort_faces then puts the list in order, farthest first, and fill_face fills each face into a buffer with one of 15 patterns of four rows ($CF48): solid, empty, and the dithers and stripes that stand in for shades of colour on a machine with two colours to each square of 8 by 8 pixels. A face painted later covers what was painted before it. The finished buffer is copied to the screen in one go, so a player never sees the painting.

03 · Sound effects

Sound: every effect stops the game while it plays

Press an effect to hear it. The game has no music: 21 effects, all on the beeper.

Pick an effect.

Each effect is the Play tab's port of play_sound ($9574), run when the button is pressed: its writes to port $FE at the T-states the game's timing loops take, played by the site's model of the beeper. The line above is the beeper's level over the whole effect. What calls each effect is read from the code and from the areas' scripts.

The Spectrum's beeper is one bit, bit 4 of port $FE, and a note is that bit flipped at the right rate by a loop that counts. play_sound looks the effect up in a table of 21 addresses at $954A and calls it with the interrupts off, so nothing else happens while it plays: the clock stops, the sensors stop firing, and the keys are not read. Effect 11, which a script plays when the visitor appears over an area after eight minutes (Maps), holds the game for three seconds. Effects 16 and 18 make no sound at all.

04 · Drilling

How close the rig must be to the gas

Pick a sector and click its plan to place a rig. The shading is every place a rig would strike gas; the darker diamond is where it would make the sector safe.

Frame of the first strike, 0 to 15

The plan looks down on the sector's 128 by 128 cells, north up, its shapes in grey. Each cell's shade is drill's own sum for a rig centred there, worked out with the game's multiply and divide routines from the gas field in the area's record (bytes +10 to +12). The rig is the 12 by 12 square.

Every sector's record holds a gas field: a centre and a size. drill ($BEFA) puts the rig a few cells in front of the probe and measures from the rig's centre to the field's centre, across plus along rather than in a straight line. The strike is 100 less that distance times 100 over the field's size, so the region that strikes anything is a diamond, and the region that strikes 50 % or more, which makes the sector safe, is a diamond half its size.

The amount of gas in each sector is not in its record. It comes from a table of 18 amounts at $88EB, stored twice over, and the game starts reading it at a place set by the frame counter at the moment of the first strike of the game. The amounts are the same in every game, but which sector holds which moves round by up to 15 places. The score for a rig is the percentage times the amount times ten.

05 · Before the game

The security question and its 128 hidden words

Move the slider to pick a question. The bytes below are the record the game reads, and the letters are what security makes of them.

Frame counter, low 7 bits

The record at in the table at $ABC1: the word's length, the page plus $40, the line, the word plus $20, then one byte a letter.

Before play, the game asks for a word from the manual by page, line and word number. security ($CB7A) picks the question with the low seven bits of the frame counter, counting through the variable-length records one by one. The answer must be typed in capitals, ten letters at most, and three wrong answers clear the memory and restart the Spectrum.

The words are not stored as text. Each letter is shifted one bit to the left, and three bits that would be the same for every capital letter, the top two and the bottom one, are made to vary, so each letter is stored as one of four bytes. A search of memory for IMPROVE finds nothing. The check undoes it: it clears bit 6, sets bit 7 and shifts the byte back to the right. A right answer also mends the first instruction of draw_view, which the tape loads as a jump to itself (Discoveries).

06 · Sensors

Sensors shoot from inside the frame interrupt

A sensor is an object of type 2 with a range and a rate of fire. When the view is drawn, every sensor in range of the probe gets a six-byte record: its number, its range, and a state. The main loop then checks each one. A sensor on the screen fires only while pick_object finds it at its place in the picture; one off the screen fires only while move_to can walk a straight line from the probe to it, so a wall between them keeps the probe safe.

The shot itself is drawn by the interrupt, fifty times a second, whatever the main loop is doing. The interrupt counts each sensor's period down, draws its beam to the probe as a line flipped onto the screen and off again, plays effect 2 and takes the shield down. The time the interrupt spends on a beam is taken from the main loop, so a sensor that keeps firing slows the whole game down.

What uses the energyCosts
A minute of the clock1
Drilling, or taking a rig back5 each
Graphite's mines, the rectangles on its floor3 each

The probe starts with 48 of energy and 50 of shield, the jet with 29 and 34, each at most 63. A sensor's shot takes shield; running out of either, or the clock reaching 00:00:00, or a fall of more than a few cells, ends the game.

07 · The main loop

One key, one picture

The game does not run at a fixed rate. main_loop ($9807) waits for a command, carries it out, redraws the view if anything moved, checks the sensors, updates the console and runs the scripts, and only then reads the keys again. A pass that redraws takes several frames, more in a crowded area. With no key held, a pass still comes once a minute of the clock, so the scripts that count minutes keep running.

Five lamps on the console show each pass going by. They go dark as a pass starts, and light one at a time: when the command is taken, when the picture begins, when its objects are queued, when they are sorted and when the view reaches the screen.

KeysCommand
O K Q Wforward, back, turn left, turn right; with SPACE, the crosshair
P L · N M · R Flook up and down, tilt, rise and fall
0 · Bfire at the crosshair; show or hide the crosshair
D C · Idrill, collect the rig; the information screen