Jump to content

TROGBlog

  • entries
    47
  • comments
    219
  • views
    125,211

24 Character Display


TROGDOR

1,879 views

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!

 

sa02go3.png

 

tesoro_bas.zip

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. :roll:

 

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

If you look through my blog, you'll find an HMOVE trick that may be helpful. It would allow you to move the text left and right 8 pixels on alternate scan lines at a cost of only 9 cycles every two scan lines. Works on real hardware, but not on any release version of any emulator I know of.

Link to comment

picked up on the VIC scheme right away - and it has 2 more characters across than the VIC did :)

 

Tried it and it rolls on my Atari.

Link to comment

Supercat, thanks for the suggestion, but I'm going to try to make this work without the HMOVEs. If I were to HMOVE the display, it would require pointers for all 24 characters on every frame, which would eat 52 bytes of RAM. That doesn't leave enough to support the game that I'm intending to use this with. Plus, I'd like to be able to play this in an emulator. Have you mentioned this issue to any of the emu developers?

 

SpiceWare, thanks for testing it. I'm at a loss for why this would roll. Running in Z26 with -n, it consistently says 262 scanlines. I'll double check the source. I threw this together pretty quickly, and I may have done something brain-damaged in the Vblankwait.

 

Is there a way in Stella or Z26 to flag potential rolling problems?

Link to comment

Found it - forgot to turn off video output. The vertical retrace doesn't work correctly if there's a video signal.

 

OverScan
lda #2	
sta VBLANK		;turn off video output
LDA #35		;Prepare timer to exit OverScan.
STA TIM64T	;Turn it on.

 

The flicker is really bad with the white background. I changed the color inits to this and it looks fine:

Reset
LDA #$00
STA COLUBK

LDA #$82
STA COLUP0
STA COLUP1

Link to comment

POKE 36866,24

Say what? Are you saying that POKE 36866,24 will get rid of the left and right borders and give you 2 more characters on each line of the VIC-20's display? I don't remember that-- but it's been so long. I had (still have) "Mapping the VIC," so if it was in there, then I probably knew about it but forgot. :)

 

Michael

Link to comment

I like it! It's similar to the approach I used for "E.T. Book Cart," but also different. One thing, though; you might want to change the design of your "G," because it's kind of hard to make out. I suggest the following:

.XX.
X...
X.X.
X.X.
.XX.

Michael

Link to comment

POKE 36866,24

Say what? Are you saying that POKE 36866,24 will get rid of the left and right borders and give you 2 more characters on each line of the VIC-20's display? I don't remember that-- but it's been so long. I had (still have) "Mapping the VIC," so if it was in there, then I probably knew about it but forgot. :)

 

Michael

The VIC let you control the # of characters across and the # of rows of characters. The built in display routines would scroll weird if the screen wasn't 22x23, but your program could work around it by going directly to memory instead of PRINT/CHROUT.

 

You could also set the characters to be 8x16 instead of 8x8. There was no hi-res graphics mode on the VIC - instead you used the 8x16 character size and filled the screen up with a unique character in each location(at the 8x8 size there were not enough characters to fill the screen to do this). I used this with a 3 pixel wide font to write a 40 column terminal program for the VIC.

 

More info here:

http://home.freeuk.com/fpgaarcade/resources/6561.txt

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...