Copyright
About the Author
About the Team
Introduction
- Six games
- Who this book is for
- How the book is organised
- How each chapter works
- What you need
- How the games were made
- Conventions
Part I. The Machine and the Language
Chapter 1. Why Write Spectrum Games Now
- Learning Objectives
- What a home computer was
- A machine you can hold in your head
- What a game does every update
- Budgets
- The constraint is the game
- Six games, six lessons
- How the games were made
- Setting up your workbench
- Reading this book
- What you can now do
- Summary
- Exercises
Chapter 2. The Machine on Your Desk
- Learning Objectives
- Memory as numbered boxes
- Bits and bytes
- Hexadecimal
- By hand: a row of the Weed
- Addresses
- A map of 64 KB
- The screen as memory
- The screen’s strange layout
- Attributes: colour by the cell
- Clock ticks: the T-state
- Frames and T-states
- Contended memory
- Ports: talking to the ULA
- The interrupt in brief
- Banks and port
$7FFD - The AY-3-8912
- What you can now do
- Summary
- Exercises
Chapter 3. Z80 Assembly for Modern Programmers
- Learning Objectives
- What a processor does
- Machine code
- Python has bytecode too
- A different kind of program
- Registers: the processor’s hands
- Reading a line of assembly
- Moving data with ld
- The flags
- One instruction at a time
- Deciding with cp and jumps
- A whole function: absdiff
- The stack, call and ret
- Negative numbers and two’s complement
- Sixteen bits at a time
- Multiplying by shifting
- Bits
- Records and indexes with IX
- A jump table built from ret
- The second register set
- Talking to hardware with in and out
- What instructions cost
- What you can now do
- Summary
- Exercises
Chapter 4. From Text to Tape
- Learning Objectives
- What an assembler does
- Assembling two lines by hand
- Names and the symbol table
- Running sjasmplus
- The symbol file and the listing
- Directives
- Saving memory and banks
- The cost of ALIGN
- One source, two machines
- build.yaml and build_game.py
- Checking the memory map
- Running verify
- The tape format
- The BASIC loader
- The packed loader
- Loading it in an emulator
- Your own game from the template
- What you can now do
- Summary
- Exercises
Part II. The Engine Room
Chapter 5. The Frame Loop and the Interrupt
- Learning Objectives
- A doorbell while you cook
- A steady beat
- Six frames on paper
- Pointing the interrupt at your code
- What the interrupt does every frame
- Why every register is saved
- What the interrupt costs
- Living below
$C000 - Latching keys
- Joysticks in the interrupt
- The main loop and its catch-up debt
- The contract, and where the game misses it
- What you can now do
- Summary
- Exercises
Chapter 6. Movement, Fixed Point and Collision
- Learning Objectives
- Moving by part of a square
- Fixed point: fractions in disguise
- Angles as bytes
- Rates that are not whole numbers
- A quarter of a cosine
- Speeding up and slowing down
- The pixel walk
- Row assist
- Boxes and the no-harm rule
- Mowing, the Battery and the random Lawn
- What you can now do
- Summary
- Exercises
Chapter 7. Drawing Without Flicker
- Learning Objectives
- What a sprite is
- Drawing the Mower on squared paper
- From paper to
defb - Putting the rows on the screen
- A second frame
- Masks
- Shifting to any pixel
- The unrolled chain
- Copying rectangles fast
- Why drawing on the screen flickers
- Three copies of the picture
- Compose: drawing only what changed
- When the lawn changes
- Present first, top to bottom
- Tinting the actors
- Whole screens and cards
- How verify measures flicker
- What you can now do
- Summary
- Exercises
Chapter 8. Music and Sound on the AY
- Learning Objectives
- What a sound is
- A chip that keeps playing
- A note as a number
- Music as a list of notes
- Patterns and the order list
- One frame of registers
- Playing from the interrupt
- Effects on channel C
- Giving channel C back
- The hum that masked the music
- The music toggle
- Effects off and the chord on channel C
- Proving the songs
- The beeper on the 48K
- What you can now do
- Summary
- Exercises
Part III. Six Games, Six Lessons
Chapter 9. Wordris: A Dictionary in a Few Kilobytes
- Learning Objectives
- The well on squared paper
- The well as a byte grid
- Finding a word in the well
- Why not a list of words
- A trie on paper
- From paper to packed bits
- The trie in bank 4
- Walking the trie in code
- What it costs
- Paging without tears
- Falling, locking and the soft-drop surge
- Spreading a burst over frames
- Scoring the winner
- Drawing letters as tiles
- What you can now do
- Summary
- Exercises
Chapter 10. Antigravity: Physics with Whole Numbers
- Learning Objectives
- Speed, and speed changing
- Ten updates with a pencil
- Sixteenths of a pixel
- Gravity that points up
- A clamp made from a subtraction
- Inertia and the brake
- Integration, and the frame behind
- Predicting a flight
- Boxes after the move
- One compare for a range
- Leaving early through the stack
- Ten sectors in 23 bytes each
- Air, score and grade
- What you can now do
- Summary
- Exercises
Chapter 11. Tiger Gorilla: Scrolling a Jungle
- Learning Objectives
- A window on a long picture
- By hand: a strip under a card
- Why redrawing is slow
- Tiles in planar pages
- Two screens, one of them awkward
- A budget of four frames
- The half-cell camera
- By hand: eight steps of walking
- The camera’s step rule
- Building a half cell
- Colour at the half step
- The black ground that flashed
- Correcting the colour
- Paying for the fix
- Vines and swinging
- The crocodile below row 128
- Choosing where the clash goes
- What you can now do
- Summary
- Exercises
Chapter 12. Gold Master: Rooms, People and Words
- Learning Objectives
- A game made of tables
- On paper first
- An office in a table
- Rooms and exits
- A route table instead of a search
- Walls as bits
- Wants as bits
- The tea economy
- Percy’s routine
- Touch, the rule that took longest
- Words on the screen
- Where it all lives
- What you can now do
- Summary
- Exercises
Chapter 13. WOLF: Timing, Waggling and Scripted Characters
- Learning Objectives
- Rhythm in frames
- Counting your own rhythm
- A gym on a 4-frame update
- Why the update cannot count the pump
- What fair means
- Reading the pump in the interrupt
- Accepting a press
- Smoothing the gap
- The form meter
- The comfy rhythm that failed
- Beats on a stamp ring
- Characters that follow a script
- Coaches as bytecode
- The buzzer’s restart bit
- One coach slot, three coaches
- Speech bubbles made of map tiles
- Calling code in another bank
- What you can now do
- Summary
- Exercises
Part IV. Making It Good
Chapter 14. Testing a Machine-Code Game
- Learning Objectives
- Why a game needs automatic tests
- What makes a test repeatable
- A recipe by hand
- The harness contract
- Deterministic by design
- The interrupt that changed the letters
- Recipes: tests as data
- A bot that plays
- Keeping bot tests honest
- Custom checks
- What verify checks
- Reading a real report
- Testing from the middle of an interval
- What verify cannot see
- What you can now do
- Summary
- Exercises
Chapter 15. Playtesting, Triage and Keeping a Decisions Log
- Learning Objectives
- What players find
- A finding and its grade
- Grading three findings by hand
- Playing at reduced speed
- The charter
- The report
- Tone rules
- From a vague report to numbers
- Triage: fix, defer or by design
- The decisions log
- The gate
- The outside view
- What you can now do
- Summary
- Exercises
Chapter 16. Shipping: Tapes, Loading Screens and the Box
- Learning Objectives
- Bytes as sound
- The arithmetic of one byte
- Estimating a real tape by hand
- The tape writer’s sum
- Where the minutes go
- The packed headerless loader
- The block table
- Unpacking as it lands
- What the game may not assume
- Loading screens
- The Dalex house style
- The box: inlay, advert and review
- The load video and the web demo
- What you can now do
- Summary
- Exercises
Chapter 17. Your First Game
- Learning Objectives
- A tiny idea
- What a one-page spec holds
- Writing a spec by hand
- Milestone 1 as a whole tiny game
- The 128K or the 48K
- A budget in T-states
- Choosing the update rate
- Starting from the template
- Keeping the harness contract
- Recipes for every boundary
- Verify, playtest, gate
- Mistakes the six games made
- What six games prove
- What you can now do
- Summary
- Exercises
Conclusion
- What you can do now
- What the checks did not cover
- What to do next
- The machine that rewards curiosity
Appendix A. Z80 Instruction Reference
- Moving data
- Arithmetic
- Logic, bits and shifts
- Jumps, calls and loops
- Input, output and the processor
- The flags
Glossary
Bibliography
- Manuals and data sheets
- Reference pages
- Tools
- Books from the period
- The games