1985 · Ocean Software

Rambo: First Blood Part II

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/rambo-first-blood-part-ii with me to Gold.

One scrolling jungle of 119 rows, a helicopter flight that drains your energy as fuel, and a copy protection that loads its second stage over the top of memory until the last byte switches off the KERNAL under its own feet.

01 · The game

A jungle, a hut, a helicopter

You walk Rambo north through a jungle that scrolls in every direction, shooting the soldiers who come at you. Weapons lie in the jungle. One item calls in a helicopter; after the first flight you can cut ten prisoners free from a hut with the knife, and the second flight, with an enemy gunship behind you, ends the game if you land far enough north.

The first instructions pageRambo in the jungle at the start of play

The first instructions page and the start of play, from the emulator. The panel at the bottom is two sprites that hold the words ENERGY and SCORE, the energy bar and the score digits ($4400).

02 · The map

The whole jungle, drawn from the game's bytes

The map is 16 tiles wide and 119 tall, and each tile is a block of 8 by 8 characters, so the jungle is 128 characters across and 952 deep. Rambo starts at the south end, the bottom of this picture.

Drawn on this page from the clean map at $E770, the 67 tiles at $EF00 and the jungle's character set at $D000, in the colours game_init sets (background 11, multicolours 0 and 8, character colour 5). swaps each tile for the one tile_damage ($1241) puts in its place when an explosion lands on it.

The game draws only the screen's new edge as it scrolls: draw_map_row ($27B4) and the two column drawers read the map byte for the tile, then the character inside that tile. Before every game map_restore ($09CC) copies the clean map over the working copy at $E000, because explosions rewrite tiles in the working copy for the rest of the game.

03 · The sound

Martin Galway's music, played by the game's own driver

Every tune the game stores, and its sound effects, each started the way the game starts it.

The game's own driver ($8100-$AFB3, from the listing) runs on this page on the kit's 6502, once a frame, through a model of the SID with a 6581's filter. Each button sends the driver the command the game sends: silence (1), all three voices for music (26), then the tune's command. test_music.js beside this page runs the same commands on the whole listing and checks every write to the chip, frame by frame. Tune 28 has no caller in the game's code.

The effects, by the command each caller sends. The two loops repeat until stopped. The game starts and stops them in the helicopter stage, but they sound only while the music has no voices (command 26 with X = 0, which the S key sends), so these two buttons send that instead of 7.

The driver has one entry. The game puts a command number in A and calls sound_command ($8100), which looks up a routine in a split table ($836E and $838D). Several commands land part way into a run of BIT instructions: the second byte of each BIT is a hidden LDY #n, so one entry point per command picks a tune or an effect with no table of its own. Each voice reads a sequence of notes and lengths and of command bytes $C0 to $DC (call, return, repeat, jump, load an instrument, transpose, run machine code), with arpeggios, four-part slides and pulse-width sweeps (v1_tick, $870C, and its copies for voices 2 and 3).

04 · The enemies

A budget of soldiers

Soldiers walk in from seven entry zones, but only while a budget lasts, and your own noise raises it.

What adds to the spawn budget ($119B)How muchWhere
Each frame, by chance1, one time in 200enemies_update $0F42
An explosion (grenade, rocket, thrown weapon)5explosion_start $18EC
Firing weapon 45fire_check $19F7
An enemy firing a bullet1bullet_fire $2586

Each new soldier uses up one unit (enemy_spawn, $118B), so a quiet knife keeps the jungle emptier than a rocket launcher, which is how the instructions' advice not to engage the enemy turns into code. Once an item with bit 7 has been taken ($0AFF) the budget no longer limits them. Soldiers also come out of the ground at character $93 (hole_scan, $0D6F), and they fire more often the further north you are: bullet_fire picks a random soldier and fires with a chance of one in (255 − row/4)/4, aiming along a straight line at Rambo.

05 · Energy

Damage is paid off one unit a frame

HitUnits of damageWhere
A walking soldier touches Rambo4enemy_touch $0BE6
An enemy bullet7bullet_touch $0C33
The gunship's shot5gunship_shot_hit $319D
Flying, as fuel1 every few framesgunship_fire_timer $304E

The energy starts at 48 units ($0CC3). A hit adds to a damage counter ($0B), and energy_tick ($0C89) takes one unit a frame off the energy and clears one pixel of the bar, so the bar runs down smoothly after a hit. The helicopter has no fuel gauge of its own: its fuel is the same bar.

06 · The helicopter

A second engine for the flight

The flight runs its own main loop at $3009, with the jungle engine's routines reached through a jump table at $0337. The helicopter has 12 frames of heading, which it turns through toward the stick (steer_heading, $36CE), and scrolls two pixels a step. The gunship steers toward it with its own speed and a fraction for each axis (gunship_steer_y, $3373), takes five rocket hits to bring down, and only follows you on the second flight, after the hut has been opened (gunship_pursues, $3825).