24 Character Display
Ack. Has it really been 2 months since I've posted?
I got a chance to do some coding the last couple days, and I've come up with something that I've always wanted to implement: a 24 character display for the Atari 2600. Behold, the wannabe Atari 2600 home computer!
Features:
- Displays 24 characters per line, and a max of around 18 lines per screen.
- Character set can contain 52 unique characters. More, if byte sharing is used.
- Only uses 26 bytes of RAM.
- Only uses 512 bytes of ROM for the character set.
- Works on a standard Atari, with a standard 4k cart.
Development Notes:
The idea for this display came from the classic 12 character text display. My display breaks each of the 12 sprite copies in to two nibbles, allowing for 24 characters total. The character set uses 5 bytes per character, and there are effectively 2 copies of every character, one defined in the left nibble, and one defined in the right nibble. This requires extra processing time, since the left and right nibbles have to be assembled into a single byte for each scanline. This is achieved with:
LDA (Buffer0),Y
ORA (Buffer1),Y
STA GRP0
This requires a whopping 13 cycles, which would make it impossible to squeeze 6 of these into a single 76 cycle scanline. To work around this, I only use this technique for the first 4 sprites. For the last 2, I preload the display data into a separate RAM buffer, so they can be displayed quicker. The total RAM requirements are 16 bytes for 8 2-byte addresses, which point to 8 nibble characters, which are displayed in 4 sprites, and then 10 bytes to hold the raw display data for the remaining 4 nibble characters, which are displayed in the remainting 2 sprites.
The original 12 character display code used a pseudo interlacing technique which is nice on the eyes, but unfortunately requires extra cycles. Instead, I ditched the interlacing model, and just horizontally shift the sprites on alternating frames. So, sprites 0, 2, 4, 6, 8, and 10 are displayed on even frames, and the other 6 are displayed on odd frames. This saves me the trouble of implementing HMOVES. It also saves RAM. The 12 character display code required 24 bytes of RAM, because all 12 characters are displayed each frame.
My only concern about this implementation is whether the flicker will make it too painful to look at. I've tested the binary in Stella 2.2 and Z26, and both displays look great, as long as the emulator is running at 60 Hz. I haven't tested it on real hardware with a TV. Anyone who can test this out, please let me know how it looks.
If you've ever used a Vic-20, you'll recognize the text in the screenshot.
I've only spent about 3 hours total on this code, so there's still plenty of optimization that could be done. One thing that would save ROM space is an end-of-line character. Currently, all 24 characters have to be defined for each line, which wastes a lot of ROM.
If the flicker is acceptable on a real Atari, this code will eventually become Stellar Adventure 2600, an interplanetary space trading game that will use a lot of text, and yes, it will be yet another Atari project for me to work on.
The binary is 8k only because I used my 8k source template when I started this project. It's really using less than 1k ROM.
Using the 6k RAM of the Supercharger, this display code could be enhanced to create something very similar to a Vic-20 programming environment.
8 Comments
Recommended Comments