1987 · Palace Software

Barbarian: The Ultimate Warrior

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/barbarian with me to Gold.

Five times a second the game paints both barbarians into a band of the background picture. The computer's fighter takes its choices from a list of 32, always in the same order, so it fights in a cycle that repeats every 6.4 seconds.

01 · The game

Two barbarians and a sword each

A fighting game for one player against the computer or two against each other, in which a well-timed blow takes the other fighter's head off.

Two barbarians face each other with swords in front of a volcano at sunset, the BARBARIAN logo above them and a snake coiled round a pillar at each side
Side 1 of the disk: the demo fight in front of the volcano.
A green goblin drags a headless body off to the left while the winner stands with his sword raised
After a head comes off, a goblin kicks it away and drags the body off.

Each fighter has twelve points of strength, shown as six half circles in the panel above the arena. A blow that lands takes one point. When a fighter has none left, he falls dead. One blow ends a fight at once at any strength: the flying neck chop, timed right, cuts off the other fighter's head.

The disk has two sides, and each loads on its own. Side 1 is practice: one player against the computer, or two players against each other with 90 seconds on the clock. Side 2 is the tournament: one player fights eight of the evil sorcerer Drax's warriors in turn, each better than the last, then faces Drax himself to free Princess Mariana. Both sides run the same program, and side 2's copy adds the code for the ending.

02 · The moves

Sixteen moves on one joystick

The joystick has nine positions and a fire button. Each position starts one move without fire and another with it. Press a square to hold the joystick there.

Joystick alone

Joystick with fire

The game's own code, running on the page: each pass reads the joystick (read_stick, $84C1), then moves the fighter one frame on and draws it as the game's main loop does (main_loop, $80BB), five passes a second. The screen is the game's own picture of the volcano, from the listing, with the other fighter left out. Forward is towards the other fighter, so the left-hand fighter's forward is right and the right-hand fighter's is left.

The game picks a move from a row of nine, one for each position of the joystick (move_rows, $CD3A). Which row it uses depends on the move under way and on the fire button (stick_row, $8508). A standing fighter uses row 0 without fire and row 8 with it, the two grids above. A crouching fighter uses another row, so he can stand up or swing low but not jump.

Standing and the two walks give way at once to whatever the joystick says next. Every other move holds on until its last frame, whatever the joystick does (stick_to_move, $853B). A swing of the sword is a commitment of four or five frames, nearly a second.

The list has 30 moves, more than the joystick starts. The others are started by the game: the recoil and the fall after a blow lands, the fall to death, the headless body, the victory, the taunt of a fighter left alone, and the turn when one fighter rolls past the other. One move, number $95, is never started at all (Discoveries).

03 · The title tune

Music: six minutes before it repeats

Richard Joseph's title tune plays when F3 is pressed. It runs for 6 minutes 16 seconds before it starts again, and two of its five parts are also the music for a fight.

The game's own sound driver, running on the page over the bytes in the listing and called as the game calls it, from two timers: the sequencer (sound_tick, $97F4) at the tune's tempo, the effects and the copy into the sound chip (effects_tick, $9D73) 98.5 times a second. Each routine runs to its end before the other starts. test_music.js holds each button to the game's code over the listing's whole memory, every write to the sound chip in order, for 60 seconds of each.

The driver plays three voices, and each reads its own sequence: notes, their lengths, and commands to wait, repeat, jump to another sequence or call one and come back, change the instrument, the tempo or the filter (do_command, $98EE). A tune is three sequence numbers, one for each voice. The title tune is $80, $81 and $82.

The tune has five parts, and each part's three sequences end by asking for the next three (command $F5). The fourth part, $89 to $8B, is the music the game plays as the two fighters walk on (walk_on, $8358). The fifth, $D4 to $D6, plays while the goblin drags a body off (goblin_drags, $9576). After the fifth comes $80 again.

The note table holds 192 quarter tones (note_freqs, $9D94), and its numbers fit an American NTSC machine's clock: each semitone is within 10 cents of true pitch at 1,022,727 Hz. A European PAL machine runs at 985,248 Hz, so it plays the whole tune 65 cents flat, about two thirds of a semitone. The player above plays it as a PAL machine does.

04 · The sound effects

Sound: every effect is a short tune

The sound effects are sequences for the same driver as the music. A blow, a clash or the goblin's kick asks for one sequence on each of up to three voices.

The game's own sound driver, as in the title tune's player above, with each effect asked for as the game asks for it in a fight. The four marked unused are sequences in the driver's list that nothing in the game asks for.

A swing of the sword asks for its sound when the move reaches a set frame (move_sound_moves, $C775): the web of death, the body chop, the neck chop, the overhead chop and the leg chop all use sequence $DD, the flying neck chop its own, $DE. A blow that lands asks for one of four hit sounds through its record (hit_sounds, $C738), and the knocked-down fighter's fall has its own. On side 2, Drax's star uses the swing's sequence on all three voices.

05 · One frame

The fighters are painted into the picture

The screen is one bitmap picture, and the fighters are drawn into a band of it. The C64's sprites, which float over the picture, carry only what the band cannot: the parts of a fighter that rise above it, the blood, the rolling head, the goblin and the right-hand fighter's coloured clothes.

One frame of side 1's demo, drawn by the page from the memory and the video chip's registers that VICE held for it, with the changes the game made during it. It matches VICE's own picture of the same frame in all 104,448 pixels.

Each fighter is drawn from blocks of 63 bytes, nine to a frame in three rows of three, stored the way sprite shapes are stored (compose_frame, $88E3). The game builds the frame in a buffer, flips it through a table for a fighter facing left (mirror_compose, $892C) and draws it into a copy of the band through a mask, so that the background shows round the fighter (draw_fighter, $8A10). The band is 32 characters wide and 8 tall, 2,560 bytes of the bitmap.

Each pass of the main loop starts from a clean copy of the band, kept since the backdrop was set up (clear_strip, $8B2E). It draws both fighters into it, then copies the whole band into the picture (show_strip, $8B64). The loop never waits for the screen, so this work sets its pace: a pass takes about ten frames of the screen's fifty a second, and the fighters move five times a second.

A frame of a fighter also names up to four sprites to lay over it (place_overlays, $8E83). Most are the parts of a fighter that rise above the band: the top of the head, a fist, the raised sword. The right-hand fighter also wears one sprite as a body piece in the skill level's colour, which is how the computer's warriors look different from each other.

06 · The blows

A blow lands on a pose at a distance

A blow is one frame of an attacking move. It lands when the other fighter shows one of the poses its list names and stands at a distance its record reaches.

Read from the tables in the listing: attack_poses ($C1B0), hit_lists ($C1BC) and the 39 records of hit_records ($C69C). The distance is in columns of 8 pixels between the two fighters. The rows marked in yellow name a pose a second time, and the game reads that second record from the wrong place (Discoveries).

Twelve poses are blows (attack_poses). Each pass the game looks up the attacker's pose there, then walks through that blow's list of pairs: a pose the victim may be in, and a record (hit_test, $8662). For the first pair that names the victim's pose, the record's first byte says at which distances the blow reaches, one bit for each distance from 0 to 7.

The other three bytes say what happens. The victim recoils, is knocked down, loses his head, or nothing happens at all. One of five sounds plays. Most records take a point of strength, add points to the attacker's score and draw blood. A record that takes nothing but plays the clash of swords is a parry: the victim's own pose blocked the blow.

Every record that hurts says one point, and the game takes one point whatever the record says (hit_effect, $86F3). So every blow is worth the same half circle of strength: a fighter dies on the twelfth blow that lands, and what the moves differ in is reach, speed and points.

07 · The computer's fighter

Thirty-two picks, in order

The computer's fighter has a joystick of its own. Five times a second it looks at your pose and the distance between you, and pushes the stick to one of eight replies.

The eight replies

The level's 32 picks, one a pass

A port of computer_moves ($8598), reading its tables from the listing. test_rules.js holds it to the game's routine, run on the page's 6502 over the listing, for every level, pose and distance at one count and every level and count at a spread of poses and distances, 43,456 cases. A move is named as it starts from standing; from another move the same push of the stick can start a different one.

The opponent's pose picks a row of eight numbers (ai_pose_rows, $C8CA), and the distance picks one of them through eight distance classes (distance_class, $C8A2): one for each distance up to 4 columns, then 5 to 6, 7 to 13, and 14 or more. That number is a list of eight joystick positions (ai_choices, $CA30).

Which of the eight it takes comes from the skill level's list of 32 picks (ai_level_picks, $C792), read at a counter that goes up by one on every pass. The counter is never reset or shuffled in a game, so the computer reads its 32 picks in order, over and over, every 6.4 seconds. The picks are sorted, so at every level the computer starts each cycle with its low-numbered replies and ends with its high-numbered ones. In the demo the counter is taken from two of CIA 1's timers instead, so the demo fighters pick at random.

A pick that comes while the fighter is in the middle of a move is lost, because the move holds the stick until its last frame. What the computer does is the pick that comes on the first pass after each move ends.

08 · Skill levels

Higher levels pick attacks more often

A level changes two things: the colour of the computer's clothes and its list of picks. Its speed, reach and strength are the same at every level.

From level_colours ($C78A) and ai_level_picks ($C792). The bars count how many of the level's 32 picks take each reply, 0 to 7.

Level 0 takes reply 6 or 7 on 22 of its 32 passes, and level 7 takes reply 0 or 1 on 22 of its. The lists put the attacks first and standing still or walking last. Close to a standing opponent, the list offers the overhead chop, the leg chop, the web of death, the neck chop and the body chop before standing still. Level 7 swings on all 32 passes, and level 0 stands still on 14.

The panel shows the level in place of the two-player clock, 00 to 07. A win in a one-player game moves up a level and over to the side's other arena, and side 1 stops at level 7 (walk_off, $83FA; Arenas). On side 2 the win at level 7 is the last fight before Drax.

09 · The ending

Drax throws stars

Side 2's eighth bout, at level 7, is fought in the hall of arches, with Drax and Mariana painted into its arches. Win it, and Drax steps out of the left-hand arch to throw stars while the barbarian crosses the arena to reach him.

The hall of arches: Drax stands in the left-hand arch, Mariana in the right-hand one, the barbarian alone at the left of the arena
The hall of arches. Drax and Mariana are part of the picture, painted into the arches.
Drax in purple robes at the right of the arena throws a star at the barbarian on the left; his arch is empty
Drax has stepped out: his arch is painted over and he is now sprites, throwing a star.
The barbarian lies dead at the left, the words YOUR END HAS COME across the arena, Drax standing at the right
A star that is not dodged kills at once.
The barbarian and Mariana stand together at the right of the arena, the words THANKS BIG BOY beside them
The end of the game, a few seconds before it goes back to the demo.

Screenshots from VICE, side 2, after a win at level 7.

Drax and Mariana are part of the picture until they move. When Drax steps out, the game swaps a 4 by 4 character block of the bitmap with a store of plain light blue (swap_cells_13, $8D5B on side 2), and swaps 13 sprite shapes in from under the system ROM, where they wait (swap_shape_bank, $8E01). Drax is then four sprites at the right of the arena.

Each time no star is in flight, Drax throws one, high or low, picked by the lowest bit of the video chip's raster line (drax_throws, $84BD). When the star reaches the barbarian, his move decides (star_strikes, $8522). A crouch, a leg chop or a roll lets a high star pass over him, and a jump clears a low one. Anything else, and he falls dead and the screen says YOUR END HAS COME. A crouch counts only once he is down: a star that arrives while he is still going down kills him.

Once the barbarian reaches column 28, Drax vanishes (reach_drax, $8572). There is no fight with Drax himself. The barbarian walks back to his mark to the walk-on tune, Mariana steps down from her arch, he walks over to her and raises his sword, and THANKS BIG BOY appears. Five seconds later the game goes back to the demo.

10 · The keys

What the keys do

The keyboard is read once a pass, a row of keys at a time, through CIA 1, the chip the joysticks share (read_keys, $9246).

KeyWhat it does
F1Stops the demo and sets up a game. On side 1, holding it switches between one and two players. On side 2 it always sets one.
F3Fades the sound out, switches between the title tune and the fight's sound effects, and fades back in. While the tune plays, the effects that would take its voices are dropped.
F5Pauses, and F5 again carries on. The second press has to be let go within a pass, about a fifth of a second: still held at the next pass, it pauses the game again.
F7Starts the game that F1 set up.
QQuits to the demo.
CTRL and VPrints a message in the arena for as long as V is held (Discoveries).

From read_keys, side 1. Side 2's copy is the same apart from F1.