Is it known how Space Invaders displayed all the aliens on the Atari 2600?
Is it known how Space Invaders displayed all the aliens on the Atari 2600?
The Atari 2600 has two 8-bit wide player sprites, and it appears to be these sprites which are used to draw these aliens.
There are a few different ways to produce many copies of one sprite; controlled by nusiz0
and nusiz1
. If you don't want the sprite stretched, then there's a choice between:
nusiz0
nusiz1
I suppose it's possible they used player 1 and player 2, both together, three copies of each, to get the six aliens on a row. But what about when an alien gets shot down? Some kind of routine needs to work out how to configure each sprite, with number of copies and distance between changing every time. Has that ever been disassembled? I'd be interested to figure it out.
1 Answer
1
It's rather simple. Neither the multiple sprite mode, nor any secret trick is used.
The TIA doesn't have any directly-accessible register for storing a sprite position ahead of time. Sprites are drawn when they are enabled on the actual line (Y coordinate) and whenever RESPx
is triggered (X coordinate). To display the 6 aliens, RESPx
gets triggered 6 successive times. To not draw an alien the corresponding player is just cleared for that activation — or, during an explosion, replaced by the appropriate sprite.
RESPx
RESPx
You really want to read the by now classic book Racing the Beam. A must-read for anyone interested in TIA workings — and way less work than crawling through disassemblies and guessing what happened :))
@Wilson It goes into the specific details of several classics, like Pit-Fall, Pac-Man, Asteroids, Space Invaiders and so on. It's about the machine and how it was done in a whole sense, targeted at a broader audience, not just coders - but don't underestimate the detail, it's still a challenging read.
– Raffzahn
Sep 7 '18 at 13:56
How did they do the timing so the register is set/cleared at the right times? Did they have to time the instruction stream from start-of-line?
– Maury Markowitz
Sep 7 '18 at 14:26
@MauryMarkowitz Jup, exactly. A CPU clock is 3 pixel clocks. So everything is caclulated from the start of teh line. The mechanic is rather simple. When the work of a line is done, one TIA register is accessed, which outs the CPU into hold until the start of the next line, resulting in cycle exact synchronisation. Easy to count from there on. Well, there are a lot of fine print to think about, byut basicy that's it.
– Raffzahn
Sep 7 '18 at 14:30
Damb. And I thought .Net was annoying.
– Maury Markowitz
Sep 7 '18 at 14:30
@Wilson NieDzejkob's solution may work, except that a
NOP
is two clocks. Better to prepare 6 memory locations with the sprite data (Alien, Explosion or nothing) and then move them into the register during the line drawn. A good place to store such serial accessed data is the stack, so the drawing can be done by repeating PLA; STA GRP0; STA RESP0
six times. That adds up to 10 cycles or 30 pixels each. With double with sprites (NUSIZ0=5
), it will exactly look like above picture, with aliens (16px) spaced almost an aliens width (14px) apart, doesn't it? TIA programing is fun.– Raffzahn
Sep 8 '18 at 1:16
NOP
PLA; STA GRP0; STA RESP0
NUSIZ0=5
Thanks for contributing an answer to Retrocomputing Stack Exchange!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Galaxian does one better for the record: seven on a line rather than six.
– Tommy
Sep 11 '18 at 16:22