1984 · Novagen Software

Encounter

This minisite was contributed by air. It’s currently claimed by air who is editing it to reach a Gold tier standard.

A first-person plain of obelisks and saucers, drawn with text where characters change every frame, and the ground is rendered by turning the sky upside down. Every saucer and the homing missile, drawn and recorded in play, are on Enemies; every level, to turn round in, is on Levels; what the game keeps from the player is on Discoveries.

01 · One frame, rebuilt from memory

The play screen, drawn from the snapshot

This is a game of spheres bouncing around in apparent real-time 3D. For fans of other Paul Woakes games, we might expect an efficient circle-drawing routine similar to the one rendering the planetfall in his game MERCENARY. It's quite astonishing then that all the circles in Encounter are drawn in text on a standard grid, using custom characters on rows 2-17. Here's a faithfully reconstructed frame rendered with characters, not a screenshot: try clicking cell grid to see how the circle is made.

The picture is character mode from top to bottom. Rows 0 and 1 are the status line in a double-width font. Rows 2 to 17 are the view, shown in multicolour text mode through a character set the game builds every frame. Rows 18 to 24 are the console, drawn once from the same font as the status line. Nothing in the sky or the ground is a pixel: those are background colours changed by a raster interrupt as the beam passes, which is the next section.

The eight sprites are the small things. Sprite 1 is the gun sight, fixed in the middle. Sprite 0 is the radar blip. Sprites 2 to 7 are the horizon hills and the clouds, which scroll against the heading so the horizon turns with the player. The yellow shape at the right edge is the shot from a yellow saucer - a near miss.

02 · The plain

Sixty-four obelisks on a grid

Every object has a 24-bit X and Z position. The obelisks sit on a 32-unit grid and a 16 × 16 map at $8A00 turns any position into the obelisk in that cell, which is how a collision test costs one table read.

The attract demo, the game playing itself from a recorded joystick script at $7400, replayed from its own object table: every position is the 24-bit value held at the top of a pass of the main loop ($A04C), read out of the running game. The plain is a 256 × 256 torus in high-byte units, so the view keeps the player in the middle and wraps. Grid lines are the 16-unit cells of the obelisk map at $8A00, drawn so that each obelisk sits in the middle of its cell. The pale wedge is what the visibility scan ($B77F) lets through: 45° either side of the heading and within $60 units on each axis. A ring marks a shot bouncing off an obelisk.

Shots and enemy shots ask the map every pass ($AC30): if the cell they moved into holds an obelisk and their range code to it is below $4F, their previous position is restored and their heading turned. A head-on hit comes straight back; an off-centre hit is turned four times as far as a mirror would turn it. The player never asks the map. Instead the visibility scan ($B77F) remembers the nearest object of any kind within four units, and the move routine refuses to advance while that object lies within 45° of the direction of travel. Homing missiles use neither test, which is why the manual warns that obelisks do not stop them.

03 · The horizon

The horizon costs no pixels

The sky, the horizon gradient and the ground cost no pixels. A chain of raster interrupts rewrites the background colour at seven lines of every frame, each stage pointing the interrupt vector at the next.

StageLineRowWrites
$B2FE16above the picturebackground $0B (dark grey) for the status rows
$B31D662sky colour from $BB; character set $4000 or $5000; multicolour on
$B34E1219, topfirst horizon colour from $BC
$B3741259, middlesecond horizon colour from $BD
$B39A1289, bottomthird horizon colour from $BE
$B3C013010ground colour from $AD; character set switched to the reflected copy at +$800
$B3EA19418black; font back to $7800; hi-res; then the per-frame timers, two sound sequencers and the colour flip

The last stage also does the game's per-frame housekeeping ($B415 to $B4BF): it counts frames, steps two sound loops and flips a bit that picks the low or high nibble of each colour pair. Where a pair has two different nibbles the band flickers between two colours at 25 Hz, which is how the game gets shades the palette does not have. The CIA timers are switched off at game start ($9F16), so this chain is the only interrupt while playing.

04 · The reflection

The ground is the sky upside down

After the objects are drawn into rows 2 to 9, $B1EC copies those rows into rows 17 to 10 with every character code inverted, and writes a top-to-bottom reversed copy of the character set into the next 2 KB. The interrupt at line 130 switches to that copy, so the lower half of the view is a mirror image for the cost of a copy loop.

Only the characters allocated that frame are reversed; the four fixed fill characters ($00, $20, $40, $60, textures 00, 55, AA and FF) invert into $FF, $DF, $BF and $9F, which the reversed copy leaves as the same textures. The view is double-buffered: odd frames draw into screen $6400 with characters at $5000 and $5800, even frames into $6000 with $4000 and $4800, and the line-66 interrupt shows whichever pair finished last.

05 · Objects

Obelisks, saucers and missiles are recipes for characters

Every object family has 32 pre-scaled scripts, one per distance step. A script says, row by row, which cells are solid fill and which are edges, and the renderer at $AD76 composes each edge cell into a freshly allocated character from a table of two-pixel masks.

Scripts live at $1E00 to $3EEB; the pointer tables at $9600 (low bytes) and $9700 (high bytes) are indexed by family × 32 + size step. Token colours: purple starts a new screen row, green is a run of fill cells, orange is one edge cell, red ends the variant.

FamilyDrawn asUsed by
0obeliskthe 64 obelisks, objects 32 to 95
1shotplayer shots, enemy shots, the warp spheres
2saucerthe enemy, object 2
3homing missilethe enemy when it is a missile
4, 5, 6explosion fragmentsobjects 24 to 31, cycling through the three kinds
7no scriptthe stargate and the arrival flash, drawn as a rectangle by $BA04

A script's first byte gives the screen row the object starts on, baked into each size step, and whether it carries two or four sub-cell variants for horizontal positions that fall between character cells. Fill cells are written straight into the screen as one of the four fixed characters. Edge cells are built: the renderer takes the cell's existing bitmap, applies an AND mask and an OR pattern from the tables at $BC85 and $BD05 for each of eight rows, and stores the result in the next free character code from $05, which walks $80, $A0, $C0, $E0, $01, $21 and so on, skipping the four fixed fills. Sixteen objects in view can use every dynamic character in the set.

Distance to size step goes through $8800, indexed by a logarithmic range code from $B766. The objects are drawn far to near ($B86C) after a selection sort of the view list ($B829), so nearer objects overwrite farther ones.

06 · Sound

Sound: the engine is noise at two pitches, swapped every frame

There is no sound driver. The raster interrupt steps two short pitch tables once a frame, one for the engine on voice 1 and one for a saucer's hum on voice 3, and the main loop writes the chip itself wherever something happens: a shot, a bump, an explosion, the stargate.

Each button runs the game's own code for the sound, its bytes from the listing, on a 6502 in the page: the interrupt every frame, and the pieces of the main loop on the frames the main loop reached them in play. A sound that lasts as long as something stays true (the engine while the stick is pushed, a saucer's hum, the warp at full speed) loops until Stop.

SoundVoiceWhat the code writesWhere
Engine1noise, its pitch byte $08 and $FF on alternate frames; gate on and no waveform with the stick centred$A231, $B415, $80C8
Your shot1noise at $1414, decay 8, cut after 12 frames$ACCF
Your shot hits an obelisk1noise at $1414, attack 3, decay 6, only while voice 1 is free$A09F
Driving into an obelisk1noise at $1414, decay 10; the engine waits 44 frames$B53F
A saucer's hum3triangle, its pitch byte stepped a frame at a time: 40 30 20 30 while it moves, 40 38 30 28 20 28 30 38 while it hovers$A616, $B444, $80A0
A saucer warms up to fire3square wave from $0800, up $80 a pass$A64D, $A676
A saucer's shot2noise at $1400, decay 8$A9BA
Its shot hits an obelisk2noise at $1414, attack 3, decay 6$A0E8
A saucer destroyed3noise, decay 11, its pitch byte $16, $14, $12, $10 and round again while the fragments fly$A8B2, $A14F
A homing missile2, 3two triangles pitched from its range, rising as it closes in$A3D5, $A811
You are hit1noise at $1414, decay 11; voices 2 and 3 off$AB9D
The stargate2, 3two triangles $100 apart, falling as the gate opens and rising as it closes$A2DD, $A04F, $A4CD
The warp2, 3noise on voice 3 rising with the speed; at full speed a sawtooth chord, $0800 and $1121$A722, $A19E
A burst-fire saucer3a pass-long triangle beep at $30, every 16 passes, 16 times$A563
A level key on the title screen1sawtooth at $0606 while the key is held$9CEA

The engine is the interrupt's table at $80C8 read from its second entry: $08, $FF, then the 0 that sends it back. Voice 1 plays noise with those two pitch bytes in turn, a frame each, so the sound repeats 25 times a second. It runs whenever the stick is pushed, turning included, and stops the moment the stick is centred: engine_sound_select ($A231) picks entry 1 of the table at $80C0 for any direction and entry 0 for none.

Voice 1 is shared with your shot, the bump and your death. Each of those sets a countdown at $1D, 12, 44 and 63 frames, and plays its own noise; the interrupt leaves the voice alone until the countdown runs out, then gives it back to the engine. A shot that hits an obelisk tests the same countdown, so its sound is lost when it lands while the shot's own sound still plays.

A saucer is heard on voice 3 from the moment it arrives, a triangle whose pitch the interrupt steps through one of two loops at $80A0: a quick four-step wobble while it moves, and a slower eight-step one while it hovers. Before it fires, the hum stops and a square wave climbs a step every pass ($A64D), until a counter at $91, falling four a pass from $FF, drops below the value at $92. One pass later the shot goes off, as noise on voice 2 ($A9BA). A burst-fire saucer turns the hum off and beeps instead: sixteen pass-long blips, one every 16 passes, and then its burst.

A homing missile is heard as a whine on voices 2 and 3 ($A811). Voice 3 plays at ((~range) | $80) × 16 and voice 2 lower by the range's complement, so as the range falls from $EE to $8A the pair rises from $0910 to $0F50 and drifts further apart. Two tones that close beat at the difference between them, which here grows from 1 Hz to 7 Hz as the missile comes in.

The stargate's two triangles are one pitch byte apart, 15 Hz, and beat 15 times a second. Their pitch comes from $75, which $A04F moves eight a pass: the tone falls as the gate opens, holds while it stays open, and climbs back as it closes. It climbs back too when the player flies in, and then the warp starts. Voice 3 plays noise at h × h + $100, where h is the square of the warp's progress $A5 divided by 256, so the hiss rises slowly at first and then fast. At full speed it gives way to a sawtooth chord on voices 2 and 3, held until the warp's time is up, and then the noise falls back the same way. The chord's top note is $1121 because $A1CA stores the control byte, $21, as its low byte where the other voice gets 0.

The volume is 15 throughout: the title's set-up ($9D8A) clears the chip and sets it, and each life's set-up ($A043) sets it again. No voice is ever routed through the filter.

07 · The loading sound

Sound: the cassette plays the game out loud as it loads

Novagen's 1984 cassette is never quiet. Its loader sends every byte it reads from the tape to the sound chip as a pitch, so the two minutes of loading are the game itself, heard as a sawtooth buzz that changes note about 275 times a second.

The cassette's screen, drawn as the video chip draws it, with the count as it stood at each moment of the load, and the load played through the site's model of the sound chip: the 32,768 bytes in the order the tape brings them, each sounding until the next arrives, for as long as its bits take on the tape. The slider starts the load at any block. The screen is built from the C64's own character set in ROM, and the page carries only the characters it shows and the ten digits, 400 bytes of Commodore's character ROM 901225-01, from its upper-case set at offsets $0008-$0507.

Before the first byte the loader sets up voice 1: a sawtooth, at full volume, with nothing in its envelope to soften it. Then each byte it takes from the tape goes to two places, to memory and to $D401, the high byte of the voice's pitch. The low byte stays at $F0, so a 0 is a 14-hertz rattle and $FF a 3,848-hertz whistle.

A byte sounds for as long as the next one takes to arrive. The tape gives each bit one pulse, a short one of 311 cycles for a 0 and a long one of 690 for a 1, so a byte of zeros takes two and a half thousandths of a second and a byte of eight 1s more than twice that. Code is a blur of notes. A run of one value holds a single note: at 93 and again at 89 blocks to go the tape brings 276 bytes of $FF in a row, and the load whistles for a second and a half each time.

After every 256 bytes the tape sends one more, their sum, and the loader checks it before it takes the block off the counter. A block that does not add up sends the C64 to its reset routine, and the load is over. After the last block the final note holds for nearly two seconds, until the game starts and turns the volume down.

08 · Controls

One routine reads the stick and plays back the demo

InputRead atDoes
stick up$DC00 bit 0forward, unless the object ahead is within $43 units, in which case a bump ($B53F)
stick down$DC00 bit 1reverse: the heading is flipped by 180°, the same move is made, the heading flipped back ($B56C)
stick left / right$DC00 bits 2, 3turn: 2 units on the first pass, then the skill's turn rate every pass, out of 2048 for a circle ($B4F0, $B4D8)
fire$DC00 bit 4a shot from one of three slots, lasting 24 passes (about a second), with an 8-pass lock ($ACB6)
F1$DC01 via column 0abandon the game and return to the title ($A118)
SPACE$DC01 via column 7pause ($A12A)
any stick direction$6Dends the pause ($A145); pressing SPACE again does nothing

The joystick is in control port 2 and is read once per pass of the main loop by $BC2C with the direction nibble kept in $6D and the fire bit in $6E. The same routine replays a recorded stick script from $7400 when the attract demo is running, one record per stick change with a count of passes, so the demo is a real game playing a recording.

On the title screen the keys go through the KERNAL's own scanner. F7 or the fire button starts. F5 cycles the skill through Novice, Advanced and Expert. The number keys 1 to 8 pick a level, and any level, whatever the manual says (Discoveries).

09 · Scoring and shields

The shield count is kept only on the screen

Saucer typePoints× level 1× level 8

The table at $8BB0, four bytes per type in BCD; a missile is worth the 500 at $8BAC. $A8B2 queues the award and $AAC8 pays it level times through the BCD adder at $B8B8.

The number of enemies in a level is drawn when the level starts: a random byte masked to 10 to 19 ($AA8F) into $8BA8, which is also what the E counter shows. The score is four BCD bytes at $8BA0 with a permanent trailing zero, which is why it always ends in 0.

The shield count has no variable. It is the digit on the status line at $6026: the game writes a 4 there at the start, subtracts one character code pair on each death ($ABDC), and adds one, up to 9, when the last enemy of a level dies ($A91D). The check for game over reads the same cell before subtracting, so the game ends on the death that finds the digit already at 0. Four shields are six deaths in the attract demo: four to start, one earned, and one more with S0 showing.

10 · The title screen

Data hidden in plain sight

The title screen is a complete 1000-byte screen stored at $6800. Five of its rows are painted in the background colour, and those rows hold the level-key table, a colour table, sprite colours, three variables, seven stub routines and the skill names.

Drawn from $6800 with the per-row colour table at $6918, which itself sits in row 7. With the reveal on, rows coloured like the background are shown in white.

RowHolds
5$68C8 the chance a saucer aligns to the player, $68C9 its default, $68CB the highest level reached
7$6918 25 row colours; $6931 the matrix codes of keys 8 to 1; $6939 seven sprite colours
13$6A08 seven copies of JMP $6A1D and the RTS they land on; the game calls six of them, on every pass in one case, and all do nothing
20, 21EXPERT, ADVANCED and NOVICE in the wide font, one of which F5 copies into row 22

11 · Where it lives

Where everything sits in memory

RangeBytesWhat
$1400 – $17BF960per-object working tables: view list, bearings, velocities, previous positions
$1E00 – $3EEB8428224 shape scripts, moved here from $3E00 by the init
$4000 – $5FFF8192two view character buffers with their reflected copies, rebuilt every frame
$6000 – $67FF2048the two play screens; four sprite frames in the rows of the second that are never drawn
$6800 – $6FFF2048title and game-over screens
$7000 – $7FFF4096sprite frames, then the character set
$8000 – $9BFF7168RESET vectors, scene records, sound loops, object arrays, maths tables, obelisk map, zero-page image, score, fire scripts, skill tables, shape profile rows and pointers
$9C00 – $BDFD8702the game: init and title, main loop and enemy states, renderer, interrupt chain, movement, input

Addresses are from the contributor's own program file, loaded and left at the title screen and then in level 1. The symbol map, the verified facts and the feature checklist sit beside this page.