Skip to content

rejunity/zx-racing-the-beam

Repository files navigation

ZX Spectrum 48/128 "Racing the Beam" Experiments

This repo contains set of experiments for racing the beam and opening the border on ZX Spectrum 48K.

  • racing the beam - is the besis of multicolour effects that defy 8x8 color attributes,
  • opening the border - allows to draw outside of the normal video memory area.

Both techniques require precise cycle timing which is complicated on ZX Spectrum 48/128K due to memory contention.

Prerequistes and tools

Tools for Mac OSX are included directly in the repository and should not require any additional installation. (HELP NEEDED: Setup for Windows and Unix!)

What next?

First run screen_timing example that demonstrates exact frame timing and how to draw on the border at a particular position.

Executing make screen_timing will compile screen_timing.asm file, build screen_timing.tap tape file and execute the emulator:

make screen_timing

screen_timing.tap

Look at screen_timing.asm source code. It will explain frame timing for ZX Spectrum 48K and demonstrate how to catch TV beam at a desired position.

Next look at interrupt_mode2.asm. It provides predictable frame timing and explains at which cycle exactly frame starts. Nothing particularly interesting happens visually just border is changing every N frames. Look at the code instead.

make interrupt_mode2

interrup_mode2.tap

Next run checkers example that draws static image on the border:

make checkers

checkers.tap

Finally look at checkers_hscroll.asm which willl draw animated checkerboard across the whole screen including the border.

make checkers_hscroll

checkers_hscroll.tap

This code races the beam and deals with memory contention. (HELP NEEDED: Update code to run with 128K timing)

See, if you could re-implement it with the less code or make it more readable?

Setting up Build & Run in Sublime Text

  1. Open your Sublime Text editor and chose Tools ▶ Build System ▶ New Build System…
  2. Copy contents of the ZXasm.sublime-build into newly create sublime-build script, save with ZXasm.sublime-build name.
  3. Pick any .asm file in the project, chose Tools ▶ Build System and specify ZXasm. Now you can use Command+B (or Ctrl+B) to build & launch emulator!

For more information see Sublime build system docs

Adding new .asm file

  1. Create new my_new_experiment.asm
  2. Add to Makefile: TAPES+=my_new_experiment.tap
  3. Now you can use:

make my_new_experiment

TODO

  • Setup for Windows and Unix!
  • Move generated and temporary files into /output folder
  • Port checkers.asm and checkers_hscroll.asm to work on 128K/+2/+2A/+3, currently only 48K is supported. Each model of Spectrum unfortunately has slightly different timing :(
  • Measure and update T cycles timings in interrupt_mode2.asm by running on 128K/+2/+2A/+3 emulated machines.
  • Implement 64x48 multicolour by flipping between screen pages on 128K.
  • AY at 200Mhz
  • Investigate if custom code generator (say with Python) instead of zmac would simplify cycle exact code genereation

Useful information

Hardware

Timing