Hacker News new | ask | show | jobs
by masswerk 1863 days ago
On the VCS, you are supposed to set up a scanline, which will be then drawn by the graphics chip (TIA) automatically. Manipulating this setup on the fly as in "racing the beam" is really more exploit territory. The vertical aspect of the image is left to the program(mer), but the VCS gives you a helping hand in form of a critical feature: The graphics chip can halt the CPU until it has reached the start of a new scanline. So your program can sleep and will be woken up precisely at the beginning of the horizontal blank interval. (The 6502C "Sally" MPU used in later Atari 8-bit computers had a similar feature: an extra signal to pause the processor, when pulled low.)
1 comments

> The graphics chip can halt the CPU until it has reached the start of a new scanline.

This seems similar to the horizontal-blank interrupt that's available on later machines, where it's widely used to change color palette or scroll values part-way down the screen. Because it’s an interrupt, though, the CPU doesn’t have to wait for it and can do other things during the active display period. As toast0 says, on the NES this interrupt is usually provided by hardware on the cartridge, but other 8-bit consoles (including the Game Boy and Master System) support it natively.

> Manipulating this setup on the fly as in "racing the beam" is really more exploit territory.

Even on the NES, "racing the beam" is not unheard of. For example, Marble Madness uses mid-scanline changes to draw text boxes in the middle of the level graphics. For part of the display it uses timed code to switch from the level nametable to text and back again within each scanline.