Joystick in port 2: the arrow keys, and Space to fire.
If the keys stop working, click the screen.
PC$0800
A$000%00000000
X$000%00000000
Y$000%00000000
SP$FF
Flags:NV-BDIZC
Next:-
Cycles:0
PC next instruction
00 just changed
00 on the stack
GAME SOURCE
Five Games, Every Line of Code
Each game is one assembly file, written for this page in the style of an 80s
classic. Press Play, then read the source: the comments at the top of each file
explain how it works and what to change. Edit anything and press Run to play your
version.
Alien Armada
In the style of Space Invaders, 1978
Hold back a marching armada before it lands. Hide behind the shields, and pick off the mystery ship for a bonus.
Controls: Left and right move your base. Fire shoots.
How it works
The armada is made of characters, so it moves a whole character, 8 pixels, at a time.
A shot hits when the screen cell under its tip holds an alien character.
The score adds up in decimal, using the 6502's BCD mode (SED).
Try changing
More lives (up to 9): change START_LIVES.
Redraw the aliens: their pixels are under ALIEN CHARACTERS.
Rockfall
In the style of Boulder Dash, 1984
Dig through four caves, grab enough gems to open the exit and get out before time runs out. Boulders fall, fireflies roam.
Controls: Move to dig. Hold fire and push a direction to grab without stepping.
How it works
The screen is the map: the caves live in screen memory and nowhere else.
Every tile that moves has bit 7 set, so one BMI finds it and a jump table moves it.
The caves are drawn as plain text at the end of the file.
Try changing
Design your own cave in CAVES.
Speed the game up: lower TICK_FRAMES (down to 2).
Jumpin' Jo
In the style of Super Mario Bros. and The Great Giana Sisters, 1985-87
Run and jump across two smoothly scrolling levels. Stomp the bugs, bash blocks for gems and reach the flag.
Controls: Left and right run. Up or fire jumps; hold it to jump higher.
How it works
Smooth scrolling: $D016 slides the screen, and an unrolled loop shifts it every 8 pixels.
A raster split keeps the status line still above the scrolling level.
Speeds in 1/256ths of a pixel make the jumps rise and fall smoothly.
Try changing
Build your own level in LEVELS.
Lower gravity: make GRAVITY smaller.
Nova Strike
In the style of R-Type, 1987
Fly through an endless alien cave, blast waves of enemies and charge your beam for the guardian at the end of each stage.
Controls: Fly in any direction. Tap fire to shoot; hold it to charge the beam.
How it works
The cave is never stored: each column is invented as it scrolls in.
Enemy waves are rows in a table: when, what, how many, where.
The beam and the guardian are sprites stretched with $D01D and $D017.
Try changing
Design your own attack waves in WAVES.
A tighter cave: change MIN_GAP.
Dojo Duel
In the style of International Karate, 1986
A karate contest at sunset. Block, duck and strike to score three points first, then face an opponent with a higher belt.
Controls: Fire punches. Fire with towards kicks, with up high-kicks, with down sweeps. Up blocks, down ducks.
How it works
One raster interrupt runs 17 times a frame to paint the sunset a text row at a time.
The fighters facing left are made at the start by mirroring the sprites facing right.
Moves are rows in a table, and the opponent's skill comes from tables indexed by its belt.
Try changing
Face a black belt from the start: set START_BELT to 6.
Paint a different sky in BAND_COLORS.
Changing a game
Settings such as lives, speeds and colours are constants near the top of each file:
change a number and press Run.
Every run starts on a freshly reset C64, so nothing is left over from the last one.
Pause above the screen, then Step to follow the game one
instruction at a time. The memory viewer shows its variables change: try
Zero page.
Labels are not case-sensitive: SCORE and score are the same name. A branch reaches
127 bytes; to go further, branch over a JMP.
The File menu saves your version, as source or as a .prg that
runs in other C64 emulators: LOAD"GAME",8,1 then SYS 2064.