{"id":16833253,"url":"https://github.com/rejunity/zx-racing-the-beam","last_synced_at":"2026-02-25T15:03:01.601Z","repository":{"id":202897086,"uuid":"498299583","full_name":"rejunity/zx-racing-the-beam","owner":"rejunity","description":"ZX Spectrum 48/128 \"Racing the Beam\"","archived":false,"fork":false,"pushed_at":"2023-10-25T21:10:12.000Z","size":4554,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-14T17:40:21.672Z","etag":null,"topics":["cycle-accurate","demoscene","z80asm","zx-spectrum"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rejunity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-31T11:05:20.000Z","updated_at":"2024-12-16T17:30:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"5cd0d56a-3ee1-4735-be68-6b5534f808ec","html_url":"https://github.com/rejunity/zx-racing-the-beam","commit_stats":null,"previous_names":["rejunity/zx-racing-the-beam"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rejunity/zx-racing-the-beam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejunity%2Fzx-racing-the-beam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejunity%2Fzx-racing-the-beam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejunity%2Fzx-racing-the-beam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejunity%2Fzx-racing-the-beam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rejunity","download_url":"https://codeload.github.com/rejunity/zx-racing-the-beam/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rejunity%2Fzx-racing-the-beam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281441022,"owners_count":26501758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cycle-accurate","demoscene","z80asm","zx-spectrum"],"created_at":"2024-10-13T11:52:52.156Z","updated_at":"2025-10-28T12:46:07.491Z","avatar_url":"https://github.com/rejunity.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"ZX Spectrum 48/128 \"Racing the Beam\" Experiments\n=====\n\nThis repo contains set of experiments for **racing the beam** and **opening the border** on ZX Spectrum 48K.\n - *racing the beam* - is the besis of multicolour effects that defy 8x8 color attributes,\n - *opening the border* - allows to draw outside of the normal video memory area.\n\nBoth techniques require precise cycle timing which is complicated on ZX Spectrum 48/128K due to [memory contention](https://sinclair.wiki.zxnet.co.uk/wiki/Contended_memory).\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n    \u003cimg src=\"./screenshots/checkers_hscroll.gif\"\u003e\n\u003c/p\u003e\n\n## Prerequistes and tools\n\nTools for Mac OSX are included directly in the repository and should not require any additional installation. (**HELP NEEDED**: *Setup for Windows and Unix!*)\n\n- Emulator: [Fuse](https://fuse-emulator.sourceforge.net), [Fuse for Mac OSX](https://fuse-for-macosx.sourceforge.io)\n- Assembler: [zmac](http://48k.ca/zmac.html)\n\n# What next?\n\nFirst run `screen_timing` example that demonstrates exact frame timing and how to draw on the border at a particular position.\n\nExecuting `make screen_timing` will compile `screen_timing.asm` file, build `screen_timing.tap` tape file and execute the emulator:\n\n```make screen_timing```\n\n![screen_timing.tap](./screenshots/screen_timing.png)\n\nLook at [screen_timing.asm](./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.\n\nNext look at [interrupt_mode2.asm](./interrupt_mode2.asm). It provides predictable frame timing and explains at which cycle exactly frame starts.\nNothing particularly interesting happens visually just border is changing every N frames. Look at the code instead.\n\n```make interrupt_mode2```\n\n![interrup_mode2.tap](./screenshots/interrupt_mode2.gif)\n\nNext run `checkers` example that draws static image on the border:\n\n```make checkers```\n\n![checkers.tap](./screenshots/checkers.png)\n\nFinally look at `checkers_hscroll.asm` which willl draw animated checkerboard across the whole screen including the border.\n\n```make checkers_hscroll```\n\n![checkers_hscroll.tap](./screenshots/checkers_hscroll.gif)\n\nThis code races the beam and deals with [memory contention](https://sinclair.wiki.zxnet.co.uk/wiki/Contended_memory).\n(**HELP NEEDED**: *Update code to run with 128K timing*)\n\nSee, if you could re-implement it with the less code or make it more readable?\n\n### Setting up Build \u0026 Run in Sublime Text \n\n1) Open your **Sublime Text** editor and chose Tools ▶ Build System ▶ New Build System…\n2) Copy contents of the [ZXasm.sublime-build](ZXasm.sublime-build) into newly create sublime-build script, save with `ZXasm.sublime-build` name.\n3) Pick any `.asm` file in the project, chose Tools ▶ Build System and specify `ZXasm`.\nNow you can use Command+B (or Ctrl+B) to build \u0026 launch emulator!\n\nFor more information see [Sublime build system docs](https://www.sublimetext.com/docs/build_systems.html)\n\n### Adding new .asm file \n\n1) Create new `my_new_experiment.asm`\n2) Add to [Makefile](Makefile): `TAPES+=my_new_experiment.tap`\n3) Now you can use:\n\n```make my_new_experiment```\n\n\n## TODO\n- Setup for Windows and Unix!\n- Move generated and temporary files into /output folder\n- 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 :(\n- Measure and update T cycles timings in `interrupt_mode2.asm` by running on 128K/+2/+2A/+3 emulated machines.\n- Implement 64x48 multicolour by flipping between screen pages on 128K.\n- AY at 200Mhz\n- Investigate if custom code generator (say with Python) instead of zmac would simplify cycle exact code genereation\n\n\n## Useful information\n### Hardware\n- ZX Spectrum 48K Hardware overview: [https://worldofspectrum.org/faq/reference/48kreference.htm](https://worldofspectrum.org/faq/reference/48kreference.htm#Hardware)\n- Different Spectrum Models: https://spectrumforeveryone.com/technical/zx-spectrum-models/\n- ULA types: https://spectrumforeveryone.com/technical/zx-spectrum-ula-types/\n- ZX Spectrum schematics and PCB layouts: https://spectrumforeveryone.com/technical/zx-spectrum-pcb-schematics-layout/\n### Timing\n- ZX Spectrum 48K frame timing: https://worldofspectrum.org/faq/reference/48kreference.htm#ZXSpectrum\n- It is very important to understand Memory Contention, 48K model: https://worldofspectrum.org/faq/reference/48kreference.htm#Contention\n- ZX Spectrum 128K memory banks, frame and contention timing: https://worldofspectrum.org/faq/reference/128kreference.htm\n- Z80 Instruction cycles, sizes and opcodes: https://spectrumforeveryone.com/technical/z80-processor-instructions/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frejunity%2Fzx-racing-the-beam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frejunity%2Fzx-racing-the-beam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frejunity%2Fzx-racing-the-beam/lists"}