1991 · Infogrames

North & South

This minisite was contributed by Nico-van-der-Zijden. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/north-and-south with me to Gold.

A board game of the American Civil War with four arcade games inside it, spread over four sides of tape. A captain is the strongest level in the arcade games and the weakest when chance decides them, and the computer general chooses each turn by one of five plans, two of which turn out to be the same.

01 · The game

A war on a map, fought out in arcade scenes

The Union and the Confederacy take turns on a map of the United States split into territories. Two people can play, or one against the computer, or the computer can play both sides.

The title scene
The title. Jeroen Tel's tune plays under the credits.
The menu
The menu: each side's flag, its character's head for the level, the year, three disasters, arcade or strategic.
The map in January 1861
The map in January 1861. Each army is a soldier on its territory.
A battle
A battle, on the field with the river.
The fort
Storming a fort.
The train
Stopping the enemy's train.

Each turn a side moves its armies, one territory each. An army that walks onto an enemy army starts a battle. One that walks into an enemy town has to take its fort. Cutting the railway between two enemy towns lets a side stop the enemy's supply train, which carries the gold that buys new armies. The war ends when one side has no army left.

The battle, the fort and the train are arcade games, each loaded from tape when it is needed. With the arcade turned off in the menu, chance decides them instead. Every picture on this page apart from these six is drawn from the game's own bytes, from the listings behind the Source code tab: every byte of the game, with a note on what each one does.

Numbers written like $9000 are places in the C64's 64 kilobytes of memory, counted in hexadecimal (base 16, with the digits 0 to 9 and A to F). Each one links to that place in the Source code tab. A name beside it, like year_setup, is the name the listing gives the routine or table there.

02 · Music

Music: Jeroen Tel's three tunes, played by the game's own player

The title has one tune, and the ending has two: one for the winner's screen and one for the loser's.

The buttons run the game's own music players on a simulator of the C64's processor, the 6502, and play what they write through the site's model of the C64's sound chip, the SID. They run once a frame, 50 times a second, as the game's screen interrupt (code the video chip sets off at a line of the screen) calls them: the title's player ($9000 starts, $9003 plays a frame, title part) and the ending's ($3000 and $3003, tune 0 for the victory and 1 for the defeat, ending part). test_music.js checks every write to the chip, frame by frame, against the same code run over each part's whole memory.

Each of the SID's three voices plays an order list, a list of patterns, and each pattern is a short run of notes. The ending's player is a later build of the title's. It keeps the same variables and adds three things. A glide slides from one note to the next (pattern byte $FD). An arpeggio, a fast run of notes that sounds like a chord, can take its base note from the order list. And a small detune from the instrument is added to every frequency ($3107). The two ending tunes share 22 of their patterns, and the defeat's is played a semitone higher (its transpose is 1).

03 · Sound

Sound: 31 effects from one player

The menu loads a sound player that stays in memory for the rest of the game. The map, the battle, the fort and the train all start their sounds through it by number.

The game's own sound player, run on the kit's 6502 from the map part's listing: $F128 sets it up, $F12B starts sound A, $F12E plays a frame. Each button is named for where the game asks for that number. Five numbers, 9, 10, 14, 21 and 25, are asked for nowhere, and a few sounds go on until something else stops them. Sound 17 is silence: for 14 frames it writes 0 to every voice's registers, which stops whatever was playing. test_music.js checks these against the player as well.

The battle, the fort and the train load over the map but stop short of $F128, so the player is still there when they run. The menu has its own copy of the player with a table of 16 sounds ($FC0E), and its sound numbers mean other sounds.

04 · The map

Each start year puts the armies where the war stood

The menu's calendar picks 1861, 1862, 1863 or 1864. Each year starts with its own owners for the 26 territories and its own armies.

Drawn by the map's own code, run on the kit's 6502 over the map part's listing: the places' backgrounds ($23DC, $23E7), the year's set-up (year_setup, $28D3) and the drawing of owners and armies ($3B97). The month band is drawn too, as the first turn has it ($39B3, $3B0D, $1E84). For 1861 the result differs from the emulator's picture of the game only in the 184 pixels the cursor covers (test_map.js).

The year's set-up copies four tables into the war's variables: who owns each territory ($0DAB), whose army stands on it ($0DE0) and how many infantry, cavalry and cannon it has ($0E2E, $0E14, $0E48). The 1861 table starts at $28EC, 1862 at $293F, 1863 at $29C0 and 1864 at $2A54. Every army on the map is drawn with one of two soldiers, one for each side (draw_army, $3BE7). The manual says the cannon balls at the soldier's feet show the army's size. The drawing reads only the army's side, so every army looks the same.

05 · A turn

Where an army moves decides what happens

A side's armies move one territory each, or stay. The one under the storm cloud, when the storm is on, cannot move (list_armies, $2E20). Clicking the band with the month and year ends the turn. What a move does depends only on what is in the territory it enters:

The territory holdsWhat happensCode
nobody, or the enemy and no armythe army takes it$2BA3
an enemy armya battlebattle_move, $2DA6
an enemy town and no armythe forttake_town, $2C75
an enemy town and an armya battle, then the fort$2C1A
one of the side's own armiesthe two join, while each total stays within 18 infantry, 9 cavalry and 3 cannonjoin_armies, $2CCF

After the moves, an enemy territory with no army and no town that the side's armies surround changes sides (surround, $32CF). Then the side's supply train runs along a railway between two of its towns, through its own territories, and brings one bag of gold for every five territories the side owns or occupies, and one more (count_gold, $3896). Five bags buy a new army of 6 infantry, 3 cavalry and a cannon, placed on the side's railway (new_army, $38D5).

06 · The computer

The computer general picks one of five plans each turn

Before it moves, the computer sets a plan number from four questions (ai_plan, $3C98). The plan changes how much each territory is worth to its armies.

The questions in the order ai_plan asks them; the first that answers yes decides. What each plan then changes is in ai_plan_scores ($3D09) and ai_occupied ($3DE4).

Every territory starts from a fixed score ($BF28). An empty territory that is not the computer's gains 5, and one with an enemy army loses twice that army's strength plus 2 (ai_occupied). Each army then values the territories by distance: whole at one step, three quarters at two, half at three, and nothing farther (ai_distance, $3E33). Below level 2 every score of 4 or more is moved up or down at random (ai_noise, $3ECA). The army steps toward the highest score (ai_step, $3F34).

Plan 2 is chosen when the European reinforcements are on and South Virginia, where their ship lands, is not the computer's. The code that applies a plan has steps for plans 0, 1 and 3 only, so under plan 2 the computer plays exactly as under plan 4 (Discoveries).

07 · The levels

The levels count one way in the arcade and the other way in strategic mode

Clicking a character's head on the menu steps that side's level: corporal, sergeant, captain ($1193, kept in $0380 and $0381). Each part of the game reads the level for itself, and they do not agree on which end is strong.

Where the table says "a random number from $7F", the game draws a number from 0 to 255 and the thing happens when it comes out at $7F (127) or more.

What the level changesCorporal (0)Sergeant (1)Captain (2)Code
a computer side's chance to act in a battle, each pass12 in 25625 in 256always$9D14
the defender's fort: the view starts at tile column200804$89B7
the defender's fort: guards81012$89B7
the defender's fort: the dog's chance to run, every 150 frames15 in 25620 in 25630 in 256$92EF
the defender's train: the view starts at column806040$8B50
the defender's train: guards81012$8B50
the computer's scores on the map get random noiseup to an eighthup to a halfnone$3EE4
strategic mode: the defender loses a fort or a train with a random number from$7F (50 %)$55 (67 %)$3F (75 %)$2DBB
strategic mode: in each round of a battle, the side this side fires at loses a unit of each kind with a random number from$3F (75 %)$55 (67 %)$7F (50 %)$32B0

In the battle, the fort, the train and the computer's thinking on the map, a captain is the strongest. A computer captain acts on every pass of a battle and moves on the map without noise, and a captain defending makes the attacker run the longest fort: the end is tile column 379 at every level, 375 columns from a captain's start and 179 from a corporal's. The strategic odds run the other way. A captain's fort falls three times in four, and a corporal's fire takes a unit three times in four. So with the arcade turned off, a side does best as a corporal. The manual calls the corporal the hardest level. The ending uses the level once more, as the player's rank in its message.

08 · The battle

Each battle is fought on one of three fields, picked at random

A random number from 0 to 255 picks the field (field_unpack, $90A5): the canyon with a wooden bridge or the river with a stone bridge, 85 chances in 256 each, or the open field, 86 in 256.

Each field unpacked from the battle file by the page's port of the game's unpacker (unpack, $8E1E): the bitmap from $826E's pointers, the screen from $8274's and the colours from $827A's, or green everywhere on the open field. test_fields.js checks the port against the game's own $90C5 on all three. The overlay marks, for each character row, the four columns where an object's position counts as in the river or the canyon (hazards, $A113; the river's table $8752, the canyon's $876C). The houses and trees the game adds at the edges are not drawn here.

Twenty objects fight: six soldiers, three riders and a cannon for each side. The field is a bitmap, a picture held in memory that the video chip shows, and the objects are cut into it as black shapes. The background under each is kept and put back before the next draw (save_under, $9247; restore_under, $92BF). Only the shots are sprites, the small pictures the video chip lays over the screen by itself. A cannonball that lands on a bridge row three times breaks the bridge, and its rows become river or canyon too (ball_crater, $A6A5; bridge_break, $A794).

On the canyon the table's bottom five rows hold $FF, the value the bridge rows have. Nothing falls in there, though the picture shows the canyon running to the bottom edge.

09 · The units

The three kinds of unit

A player picks which of the three units the stick moves (RUN/STOP for the Union, F5 for the Confederacy).

The ball flies (range + 2) × 2 frames at 2 pixel pairs a frame, so it lands (range + 2) × 8 pixels from where it starts: 16 pixels at range 0 and 264 at 31, across a field 320 pixels wide. Held for the full 124 frames, the gauge reaches 31.

10 · The fort and the train

The train is the fort's engine on a moving floor

To take a town, the attacker runs through its fort to the flag at the far end before the clock runs out: about 76 seconds, 3,780 frames (fort_clock, $8945). Guards come one at a time, a dog runs out now and then, and barrels roll in. Fire next to a guard swings the sabre; farther away it throws a knife, four in all (fighter_strike, $957F; fighter_throw, $95D3). A knife passes over a fighter who ducks (knife_hits, $9A63).

The train's file holds the same code, rebuilt at other addresses: the fighters, their poses, the knives and the guards. It takes away the walls, the dog and the barrels, and adds scenery in three bands that scroll at different speeds, wheels that turn and a driver in the cab. The attacker has 43 seconds (train_clock, $8ADE) to reach the locomotive. A fighter who climbs down to the ground is left behind as the train pulls away, and is beaten 30 columns later unless he climbs back on (left_behind, $8D4D).

Both are maps of tiles. A tile is 2 by 2 characters, and a character is a block of 8 by 8 pixels drawn from a set of shapes in memory: the fort nine rows of 400 tiles (fort_map, $2718), the train six rows of 240 (train_map, $2610). The Maps tab draws both whole.

11 · The ending

The ending names a rank and counts the months

When one side has no army left, the map loads the ending. It shows the winner's screen with the victory tune, the loser's with the defeat, or both when two people played (ending_main, $8000). A message scrolls along a text row above the picture. It names the player's rank, CORPORAL, SERGEANT or CAPTAIN, from the level picked on the menu (rank_words, $86C0), and puts the number of months the war lasted over its XX ($0399, $039A). There are four messages, one for each side winning and losing ($847B-$86BF).

12 · The tapes

Fourteen files on four sides of tape

A short program stays in memory from the boot to the end (script, $0806). It loads every file by number through one routine (load_file, $0803) with Cyberload, a fast loader that reads the tape with routines of its own in place of the C64's slow built-in ones, and asks for the right side first: "REWIND TAPE 1 SIDE 2, HIT FIRE THEN PLAY" (rewind_prompt, $092E).

Tape, sideFilesWhat they are
1, 1TP, OC, OM, T1-T4the title; the menu and the sound player; the four start years' texts
1, 2M2, M1, M3, CSthe map; the ending
2, 1BSthe battle
2, 2S1, S2the fort, the train

The menu's settings, the armies sent to a battle and its result all pass between the files through 30 bytes of memory that every load leaves alone ($037E-$039B). After a battle, a fort or a train the map loads its file M2 again, which the arcade game wrote over, and sets itself up from those bytes ($0CB1).