1987 · Domark

The Living Daylights: graphics

This minisite was contributed by unorig. 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-living-daylights with me to Gold.

Bond in three sprites, every sprite shape the game draws with, the hard hat drawn onto his head a shape at a time, the packing that fits ten screens into memory, and the loading picture.

01 · Bond

Bond is three sprites

A C64 sprite is 24 pixels wide and 21 high, too small for a running man. Bond is three: sprite 6 is his head and body, and sprites 4 and 5 are the two halves of his legs, side by side below it ($3EC7).

Each frame is drawn from the game's tables: the shape numbers from $349B (running), $341C (rolling), $33C2 and the heights from $33C8 (jumping), and $35A0 to $35A8 (the four ways he aims), at the places $3EC7 puts the three sprites. A table gives the first of the three shapes, and the game takes the next two for the legs ($348F). The colours are Gibraltar's: white for the top sprite and dark grey for the legs, with black and orange shared by every sprite.

Bond aims in four directions, and the game picks the pose from where the crosshair is ($3566). Running has ten frames, stepped every seventh frame of play while he walks and sooner while he runs, with a footstep at the second and seventh ($3455). The game writes the sprites twice in each frame, once for the top of the screen and once for the bottom, from two sets of copies in zero page ($35AC, $3625), so the same eight sprites can show different things above and below line $92.

02 · Every shape

160 sprite shapes, and more in each level

The game keeps 160 sprite shapes at $4800-$6FFF, numbers $20 to $BF. A shape's number is its address divided by 64, counted from the start of the video bank at $4000.

Each shape is drawn from its 63 bytes on the Source tab and labelled with its number. The two shared colours are black and orange, as the game sets them on Gibraltar; the third is the sprite's own colour. Every sprite in play is multicolour, except the crosshair and the cursor at Q branch.

ShapesWhat they are
$20-$3DBond running, ten frames of three sprites
$3E-$4FBond rolling, with $26 before and $9A and $20 after
$50-$58Bond jumping (with $3B)
$59-$64Bond aiming: four heads and bodies, then four of each half of his legs
$65-$7EThe companion on levels 2 to 4, two sprites a frame: running, then stumbling ($350C, $353B)
$7FThe crosshair
$80-$87Q branch's pictures of the crossbow, bazooka, sleep dart gun, grenade, ghetto blaster, missile pen, cigarette, and bomb ($2B6A)
$88Q branch's cursor, a frame drawn at double size
$89-$BFThe figures that rise from the scenery, in five kinds ($2293), the pipe worker, Bond lying down ($AA-$AC), a figure falling ($B8-$BD, $2333), and the doorways' figure ($BE)

03 · Shapes that come with a level

The helicopter is packed with the Mansion

Some things appear on one level only, and their shapes are packed with that level's scenery, at shape numbers $E8 and up, in the memory every level overwrites (Maps). The pictures of Q's last four gadgets are packed with Q branch's room in the same way.

Each row is drawn after the page has unpacked that screen with the game's own $30CB, as on the Maps tab. The helicopter is three sprites, 24 pixels apart ($1810).

04 · The hard hat

A hat drawn into 25 shapes, one a frame

Choosing the hard hat on The Pipeline puts it on Bond's head, in every pose he can take: the game draws the hat into 25 of his sprite shapes, one shape each frame, by flipping the hat's pixels in with an exclusive-or ($70EF). The 25 places, and how many rows of hat each gets, are tables at $713A to $7185, and the hat's pixels are at $719E. Flipping the same pixels again takes it off, which the game does at the start of the next level ($7124). Tick "Hard hat on" above to run the game's routine on the shapes and see which 25 change.

05 · Packing

Ten screens in 25 KB

Each level unpacks to about 9 KB: its own characters, a map of 3,680 characters, and their colours. Ten such screens, eight levels, Q branch's room, and the title, would not fit beside the game, so they are kept packed three times over and unpacked when needed ($30CB).

The outer layer is a Huffman code: the commonest bytes get the shortest codes of bits. The decoder walks a tree from its root for every byte, taking the left or the right branch for each bit read ($311E). The tree is one table for all ten screens, three pages at $9D00: a page of flags saying whether a branch ends in a byte, and a page each of left and right branches. Under the Huffman code is a run-length code, where the byte $27 is followed by a byte to repeat and how many times ($321E). Last, the colours are packed two to a byte, one in each half, and spread out again ($319D).

ScreenPacked atBytes
0 Gibraltar$ACD12,936
1 Concert Hall$B8493,058
2 The Pipeline$C43B3,517
3 The Mansion$02002,585
4 The Fairground$0C191,255
5 Tangiers$D1F82,916
6 Afghanistan$DD5C2,953
7 Whittaker's House$E8E51,552
8 Q branch and the title's graphics$EEF53,155
9 The title and the ending$FB481,022

The packed screens fill every corner the game can spare: below the program at $0200, where the system's own work area would normally be, and the top of memory from $ACD1 to $FF45, including the 4 KB of RAM hidden under the I/O chips at $D000. The game is loaded with those 4 KB at $8D00, and the first thing it does is copy them up under the chips ($3F2E). The Pipeline's stream runs straight across the I/O chips' addresses from $CC3B into $D000.

06 · The loading picture

A picture loaded over by the game

The loading picture: Bond in a white circle with his pistol, the Aston Martin, a man on horseback, a soldier with a rifle, and a woman, under JAMES BOND 007 and the Domark and The Living Daylights logos
The loading picture, as the emulator showed it while the disk loaded.

The picture is a multicolour bitmap kept in two files of its own on the disk: TLD7 holds the bitmap and its screen colours, and TLD6 the colours that go straight into the colour memory at $D800. The loader shows it while the rest of the game loads, and the game's own files then load over it, so none of it is in memory in play and none of it is on the Source tab.