Raster Bars
You'll write a cycle-timed effect in assembly for a real 8-bit or 16-bit machine, where your code has to race the electron beam.
About
On a C64, an Amiga, a Spectrum or a NES there is no frame buffer you can write to at leisure. The classic effects (raster bars, an opened border, sprite multiplexing, copper gradients) come from changing a hardware register on an exact scanline, and if your code is one cycle late the whole screen jitters. Retro Computing's Peek and Poke ends with twenty bytes of machine code called from BASIC, and this badge starts there; fixing the machine itself stays in Retro Computing. What counts is your own assembly, stable in an accurate emulator like VICE, FS-UAE, Mesen or Fuse; real hardware is a bonus, not a requirement. A BASIC program or a library that hides the timing does not count. The thing nobody tells beginners is that a raster interrupt fires late by a variable number of cycles, so a stable raster needs a trick like the double interrupt or a timer. If you do borrow real hardware, leave the case closed, because an old CRT holds a lethal charge long after it is unplugged.
At a glance
- Per requirement
- 35 XP
- Completion bonus
- 300 XP
- Requirements
- 6
- Takes
- Three weeks
- Skill level
- Advanced (years of practice)
- Cost
- Free
- Supplies
- Nothing special
- Where
- At home
- Other people
- On your own
Requirements
-
1
Pick a platform, set up an assembler and emulator, and change the border colour. Good pairs are the C64 with 64tass or KickAssembler and VICE, the Amiga with vasm and FS-UAE, the NES with ca65 and Mesen, and the Spectrum with sjasmplus and Fuse. Assemble a program that writes one value to the border colour register and nothing else. Take a screenshot of the changed border and your source. Photo
-
2
Change a colour on one exact scanline. Set up a raster interrupt, a copper WAIT or a timed loop so that a colour changes partway down the screen and you get a hard horizontal edge. On the Spectrum there is no raster interrupt at all, so you count T-states from the frame interrupt, which is harder and is the point. Take a screenshot of the edge. Photo
-
3
Make the edge rock steady. On the C64 use the double-interrupt trick or a CIA timer to swallow the jitter; on the NES use the sprite zero hit; on the Amiga the copper is exact by design, so instead rebuild a moving copper list every frame from a table. Film ten seconds close up, with no flicker or wobble on the edge. Video
-
4
Animate a set of bars moving with a sine table at full frame rate. Precompute a sine table of positions, draw at least four bars with a gradient each, and move them every frame. A PAL C64 frame is about 19,656 cycles, so count what each bar costs. Film the bars bouncing. Video
-
5
Share the frame with a second element and keep the timing. Add a scroller, sprites or a logo on screen with the bars, which means your bar code can no longer use the whole frame. Keep the bars steady while the other thing moves. Film both running together. Video
-
6
Release the file with source and film it on a real screen if you can. Post a .prg, .adf, .nes or .tap with the source and a capture. If you can borrow the real machine at a retro meet or from a friend, film it on the CRT; the emulator counts if you can't. Write one line on the trick that finally made it stable. Video