1986 · Imagine Software (Ocean)

Green Beret

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/c64/green-beret with me to Gold.

Four stages, a title page, an opening scene and an ending fit in one load, because the game swaps blocks of graphics in and out of memory between stages. The drums under play are a tune that never ends.

01 · The game

A commando with a knife

Konami's 1985 arcade game, converted for the Commodore 64 by Imagine in 1986.

The title page: GREEN BERET in large letters, and the credits The Missile Base: the hero on the left, soldiers running at him under a red iron bridge

The title page and the first stage, the Missile Base, in the emulator.

You play a commando sent to free four prisoners from an enemy camp. You walk right through four stages, the Missile Base, the Harbour, the Bridge and the Prison Camp, with a knife. The screen scrolls one way: once you pass the middle, it moves on as you walk, and it never goes back.

Soldiers run at you from both sides and along the floors above. Some shoot, some jump, some throw grenades, and some of the white ones carry a flame thrower, a bazooka or hand grenades, which they drop when you knife them. Space fires the weapon you are carrying. A touch, a bullet or a mine costs a life.

At the end of each stage an alarm sounds and a fight begins: a lorry of soldiers, a pack of dogs, three helicopters, and waves from both sides. After the Prison Camp the prisoners go free and the game starts again from the Missile Base, with the soldiers shooting twice as often.

02 · Music

Music: the drums under play never stop

The game plays thirteen pieces by Martin Galway. The two that start play hand the drums to a loop that runs for as long as you play.

The game's own music driver ($E000) running on the page, over the bytes in the listing, called as the game calls it once a frame: the three note readers from the main loop, then the three effects routines from the raster interrupt. test_music.js holds every button to the game's code, every write to the sound chip in order, for 3,000 frames each. The title, the two that start play, the two fights' tunes and the hi-score table's go round until you stop them.

The driver plays three voices. Each reads its own pattern, a list of notes and commands: call another pattern and come back, jump, repeat, transpose, load an instrument, slide the pitch, sweep the pulse width. A tune is six bytes in tune_table, where each voice's pattern starts.

In "Play starts" and "Play resumes", voices 1 and 2 play one note each and stop. Voice 3 runs a pattern that loops for ever ($F282), and most of its beats are command $DC, which only voice 3 has. That command, v3_crash, strikes all three voices at once: noise on voice 1 and two triangle waves on the others. It is the drum beat under every stage. While a sound effect is using any voice, the strike is skipped, so the drums drop out under a gunshot.

Voice 3 also sets the tempo for all three voices. Command $D0 copies bytes into a voice's settings, and voice 3's copy runs past the end of its own settings into durations, the table every voice reads its note lengths from.

In April 2026 Martin Galway published the source of the game's sound (MartinGalway/C64_music, greenberet.asm, dated 5 April 1986). Its list has fourteen tunes. Thirteen are the game's, in the same order, except that the helicopters' rotor, last in the source's list, sits in the game's list where the fourteenth was: "HIGH-SCORE TABLE MUSIC". The game has no hi-score table, only the hi score on the status line, and none of that tune's notes are in it, though the four blocks of settings it loads still are. Hi-score table (unused) in the player above plays it: the source's three voices assembled for the game's layout, on the game's own driver. Eleven of the game's seventeen sound effects are in the source too, byte for byte; the bazooka's and the weapon's are not.

03 · Sound effects

Sound: effects borrow the music's voices

Seventeen effects of 31 bytes each, played on the same three voices as the music.

Each button runs the game's own routine that starts the effect (sfx_hit, sfx_gun and the rest), then the driver once a frame until the sound has died away, checked by test_music.js like the tunes.

An effect is a voice's whole setting in one block: waveform, envelope, frequency, pulse width, and a frequency slide or arpeggio with a pulse sweep. sfx_start copies it to the voice and marks the voice as taken, and the music's notes on that voice go silent until the effect's sound time runs out. A bigger sound, an explosion, a bazooka shell or a weapon being taken, takes all three voices at once.

04 · One frame, rebuilt from memory

Twenty-one figures on eight sprites

The C64 has eight sprites. Green Beret moves up to 21 figures, and re-uses each sprite lower down the screen once its first figure has been drawn.

One frame of the Harbour, drawn by the page from memory and from every write the game made to the video chip during the frame, recorded in the emulator. All 104,448 pixels match the emulator's own picture of the frame. With the sprites marked, each box is one use of a hardware sprite, numbered 0-7, with the raster line its position was written on.

The game keeps 21 virtual sprites in its own tables: the hero's top and legs, a top and legs for each of six enemies, three projectiles of his and three of theirs, and the weapon a soldier drops. Each frame the main loop sorts them by height (sprites_sort) and hands a copy to the raster interrupt (sprites_to_irq), so that it can move them while the interrupt draws.

The interrupt runs in three phases. At line 246, below the playfield, it reads the joystick, moves the hero and switches the video chip to the status band at the top of the next frame. At line 70 it switches back to the playfield and its fine scroll. Then the multiplexer ($C474) runs down the screen 14 lines at a time. Each time, every figure whose top is above the next threshold gets the next hardware sprite, counting 7 down to 0 and round again, with its colour, shape, X and Y. A hardware sprite can be given a new figure once the beam has passed its last one.

05 · The map

A stage is a strip of tiles

Each new column at the right edge of the screen is read from two tiles, one above the other.

Drawn by the page from the map, the tiles and the character set in the listing, with the stage's own graphics swapped in as the game swaps them. test_map.js runs the game's own drawing routine, column_draw, for every column of every stage and checks that it writes what the page draws. Every stage, whole: Maps.

The map at $C000 is one long strip that holds all four stages. It has two bytes for every eight columns: the tile for the top half of the playfield and the tile for the bottom half. A tile is 8 by 8 characters, 64 bytes at $A000, with a colour for each character 4 KB higher at $B000. A new column takes one column of each of its two tiles, 16 characters from row 8 to row 23 (column_draw).

The rest of the screen is fixed. Rows 3 to 7 are sky, the same character all along, and row 24 is a floor everyone stands on. The top four rows of tiles are always drawn in one colour, because the routine that shifts the screen left moves the colours of rows 12 to 23 only. The mines are placed separately: when a new column matches an entry in the stage's mine table, the routine puts a mine character on row 23.

The hero walks freely until his X reaches $88, a little past the middle. After that the screen scrolls instead, by his walking speed, 1.5 pixels a frame on average. The fine scroll register shifts the picture a pixel at a time; every eight pixels the game moves rows 8 to 23 one character left (coarse_scroll) and draws the next column at the right edge.

06 · The hero

A jump is 42 frames

The hero is moved from the raster interrupt, once a frame, and every jump in the game follows one table of heights.

The heights in jump_arc, read the way player_jump reads them: from entry 20 down to 0 while he rises, then back up to 20. Measured in the emulator, the hero's legs went from line 226 to 196 and back in 42 frames.

Up starts a jump, and a second jump needs up pressed again. Pushed diagonally, he keeps moving left or right through the jump. Each frame his height is the jump's base plus an entry of jump_arc. The entries are 30 lines apart from one end to the other, and the first two are both 0, so he hangs at the top for four frames. The same table throws the dogs, the enemies' jumps and the hand grenades, each starting from a different entry.

Fire stabs with the knife, standing or, with the stick pulled down, crouching. The stab holds for five frames. Its point is 13 or 7 units ahead of him (a unit is two pixels), and it hits an enemy within 6 units across and 16 lines of height. A crouching stab reaches lower, and a dog leaps only at a hero who is standing. Space fires the extra weapon; it fires nothing on a ladder.

The game reads one more key. While 1 is held, the interrupt skips the hero's movement, so he freezes where he is, even in mid-air (Discoveries).

07 · The enemies

The soldiers and what each one does

Every enemy is two sprites, a top and legs, and a type number from 0 to 9 that picks its colour, its speed, its points and its behaviour.

Shapes, colours, speeds and points drawn from the listing: the walking frames in enemy_anim_tops and enemy_anim_bottoms, the colours in type_top_colours, the speeds in type_speeds and the points in enemy_points, shown with the 0 the score adds. The behaviour of each type is a routine in behaviour_table.

Most enemies walk at you along their floor and follow you up and down ladders: when you are on a lower floor, an enemy standing on the top of a ladder climbs down, and one beside a ladder climbs up when you are higher. Brown soldiers and kickers never climb. A floor holds at most three enemies, and the game counts an enemy on every floor its fall or climb may pass.

The ones that shoot fire when their own frame counter reaches $50: once in every 256 frames, about every five seconds, and only on your floor. They stop, turn to face you, kneel or raise the weapon, and fire on the fifth step. A soldier who touches you kills you; so does a bullet, a shell, a grenade or a bomb.

08 · Who comes when

The difficulty creeps up while you play

Most enemies come from five lanes, each a timer. A difficulty number rises as you play and changes which enemy each lane sends and how soon.

Difficulty0

Read from lane_types and lane_reload at the lane plus the difficulty, and lane_sides. Seconds at 50 frames a second.

Each lane counts its timer down once a frame. When it reaches 0 the lane is ready, with an enemy type and a new time, both read from a table at the lane's number plus the difficulty. A ready lane sends its enemy when fewer than five are out and a slot is free, onto your floor if it has room, otherwise onto the floor below (random_spawn). All the lanes but lane 2 send theirs from the right.

Every 256 frames irq_status adds the stage's rate (difficulty_rates) to a fraction, and each carry raises the difficulty by one, up to the stage's cap (difficulty_caps).

The difficulty goes back to 0 at the start of each stage and after every death, so a player who dies often meets easier soldiers. The map adds 60 enemies of its own at fixed columns (scripted_spawn): the white soldiers who carry weapons, the grenade throwers, the crawlers, the bazooka men lying in wait and the paratroopers. They are marked on the Maps.

After the Prison Camp the game starts again with one change. fire_frame_b, the second frame count at which an enemy fires, becomes $82 instead of $50, so every enemy that shoots fires twice in its 256 frames.

09 · The end of each stage

Each stage ends in a fight of its own

When the scroll reaches the stage's last column, an alarm sounds, the hero may walk on across the screen, and the stage's own routine takes over the main loop.

The lorry built from nine sprites as lorry_update places them, a helicopter from six as helis_place does (with the rotor frames of rotor_shapes), and the eighteen dogs in the order dog_release sends them, each in its colour from dog_colours, facing the way it runs.

The Missile Base. A lorry drives across the bottom floor, slowing from 6 pixels a frame to 2 as it goes, and leaves the screen. Then eighteen soldiers and kickers come from the right, never more than three on the floor at once.

The Harbour. A handler in green stands at one edge and sends eighteen dogs, in threes from alternate sides, the first three from the left. A dog running right leaps at a hero who is up to 19 units ahead of it and standing. Crouching, he is never leapt at. The dogs' shapes are swapped into the sprite memory for the fight and out again after it.

The Bridge. Three helicopters come, at most two at once, each built from three enemy slots. A helicopter comes down to hover low and chase the hero, or, when the other one is already low, to hover high and patrol from side to side. Both throw grenades from their middle, the way the officers do. A hit on any of a helicopter's parts destroys all of it, and the one left comes down low to chase him.

The Prison Camp. Eighteen enemies come along the bottom floor, from the right and from the left in turn: blue soldiers, bazooka men lying down, kickers and officers. When the last has gone the prisoners are free.

10 · Memory

Four stages in one load

The game loads once. Each stage's characters, tiles and tile colours wait elsewhere in memory, and nine block swaps put them where the video chip and the map routine read them.

Top: the 256 characters at $7800, which the playfield shows, as each stage has them. Bottom: the 64 tiles at $A000, with their colours, as each stage has them. Drawn from the listing with the stage's swaps made as block_swap makes them.

block_swap exchanges two blocks of memory byte for byte, so the graphics it moves out are kept where the new ones were, and a second swap puts everything back. The blocks under the I/O area, $D000-$DFFF, hold three character sets that the processor can only see with the chips switched out, and the routine switches them out for those swaps. The Bridge's swaps leave the Harbour's in place, and the Prison Camp's are made on top of the Bridge's, so each stage's memory is the sum of the swaps before it. A new game undoes them all (swaps_undo).

The same trick serves the title page and the scenes between stages: swap 8 brings the title's character set to $7800 and takes it back. The texts, such as WELL DONE and the credits, are kept in spare characters of a character set, and move with it.