Beginner Patterns
Foundational patterns for those starting their retro dev journey
Commodore 64
6 patternsSID Note Trigger
Play a single note on the SID chip with gate control. The foundation of all SID audio.
SID Voice Setup
Configure a SID voice with frequency, waveform, and ADSR envelope. Foundation for all SID audio programming.
Game Loop (Basic)
Simple frame-synchronised game loop using the raster register. Foundation for all C64 games.
Joystick Reading
Read joystick input from CIA#1 for player control. Simple, reliable, and cycle-efficient.
Sprite Movement with Bounds
Move sprites with joystick input and screen boundary clamping. Handle the VIC-II's 9-bit X coordinate.
Hardware Sprites
Enable, position, and colour one of the C64's eight hardware sprites — moveable objects the VIC-II draws over the background for free.
Sinclair ZX Spectrum
12 patternsAY Tone
Play a tone on the 128K's AY-3-8912 sound chip — select a register through port $FFFD, write it through $BFFD, and the chip holds the note on its own while the CPU gets on with the game.
Sound Beep
Generate a simple beep or tone by toggling the speaker bit. Rising or falling pitch for feedback sounds.
Game Loop (HALT)
Frame-synchronised game loop using the HALT instruction. Locks to 50Hz for consistent timing across all Spectrums.
Screen Frame (BASIC)
Draw a 1-cell border around the play area with title and footer bars. The standard game screen layout.
Text Utilities (BASIC)
Centre text on any row and clear rows — two tiny subroutines used in every BASIC game.
Keyboard Reading
Read the ZX Spectrum keyboard matrix by polling I/O ports. Simple, efficient, and no ROM routines required.
Grid Movement with Bounds
Move an entity on a grid with boundary checking. Prevents moving outside the play area.
Attribute Writing
Write colours directly to attribute memory for fast, flicker-free graphics without touching pixel data.
Character Printing
Print ASCII characters to the screen using the ROM character set. Direct display file access for fast text rendering.
Numeric Display
Convert a number (0-99) to two ASCII digits and print them. Essential for scores and counters.
Progress Bar (BASIC)
Horizontal progress bar with colour thresholds — blue through yellow, red, to white. Useful for health, temperature, or timers.
Seven-Segment Digits (BASIC)
Draw large seven-segment display digits using PLOT/DRAW. Cell-aligned with 1px outline. 10 DATA strings define all digits 0-9.
Nintendo Entertainment System
6 patternsA Square Wave
Enable one of the NES APU's pulse channels, set its duty, volume and 11-bit timer, and it holds a tone on its own — the foundation of every NES sound.
NMI Game Loop
Frame-synchronised game loop using the NMI interrupt for VBlank timing and OAM DMA transfer.
Reset Sequence
Standard NES initialisation: disable interrupts, wait for PPU, clear RAM. Required boilerplate for every NES program.
Controller Reading
Read the NES controller by strobing and shifting 8 button bits into a variable. Simple, reliable, standard approach.
Sprite Movement with Bounds
Move sprites with D-pad input and screen boundary clamping. Essential for player-controlled objects.
Palette Loading
Load colour palettes into PPU memory at $3F00. Required setup for any NES graphics.
Commodore Amiga
8 patternsPlaying a Sample
Point one of Paula's four audio channels at an 8-bit sample in chip RAM, set its pitch and volume, and let DMA play it — the foundation of all Amiga sound.
System Takeover
Disable AmigaOS interrupts and DMA to take full control of the hardware. Required for bare-metal game programming.
VBlank Game Loop
Frame-synchronised game loop that waits for vertical blank using the VPOSR register. 50Hz timing on PAL systems.
Joystick Edge Detection
Detect newly-pressed joystick directions, ignoring held inputs. Essential for grid-based movement and menu navigation.
Joystick Reading
Read Amiga joystick using the JOY1DAT register with XOR decoding for up/down directions.
Sprite Movement with Bounds
Move sprites with joystick input and play area boundary clamping. Foundation for player control.
Copper List Basics
Build a copper list to set colours and sprite pointers. The foundation of all Amiga graphics programming.
Sprite Control Words
Calculate and update Amiga sprite control words from X/Y coordinates. Position sprites anywhere on screen.
Cross-Platform
9 patternsFour Ways to Make a Sound
The tune driver is the same on every machine — but what it talks to isn't. Paula streams a sample, the APU synthesises fixed voices, the SID shapes a rich one, and the Spectrum toggles a single bit. Four answers to 'how does a computer make a sound?', and each one shaped the music.
Game State Machine
Organise game flow with distinct states (title, playing, game over). Clean separation of game phases.
The Ending Dwell
Win or lose, the screen holds for a beat before any button is believed. The pause is the punctuation that lets the player read their own ending — and it stops a held button blowing through three screens in three frames.
Three Caps: Counter, Index, Digit
A level counter, a table index, and a HUD digit are three different numbers with three different caps. The counter never stops, the index clamps for safety, the digit caps for display — conflate them and the game lies about one of them.
Input Edge Detection
Detect newly-pressed buttons, ignoring held inputs. Essential for menus and single-action triggers.
AABB Collision Detection
Axis-Aligned Bounding Box collision — fast rectangle overlap test for sprites and objects.
The Grace Window
A second of invulnerability after every respawn, covering every damage source, made visible by blinking the player. Without it, dying once where a hazard sits can spend every life in as many frames.
Blink on a Clock
PRESS START winks on a 32-frame beat read straight off a frame counter — one AND instruction selects draw or clear. A blink is two renderers taking turns on a clock you already had.
Sprite Animation
Cycle through animation frames with configurable timing. Walk cycles, explosions, idle animations.