Jump to content
  • 0

Interfacing Directly With the Vera Video Memory



So in my other post here:


I wanted to make a programming language and a IDE to be used in the X16. So for creating the text box I have 2 options:

1. Using the GNU Readline library

pros: Allows me to program in c

cons: May not work on the X16, Lack of documentation, Might need to be ported to the X16

2. Directly editing the video memory

pros: Gives me full control over graphics, Wont require extra code to be ported,

cons: Even though I do have experience in assembly(x86 and 6502) it will be very hard to get right.

So I have chosen to interface with the video memory directly. I'm having a bit  of trouble understanding the Vera video card. I have read through parts of the unofficial documentation but I have a couple questions:

1. How do you switch to text mode?

2. How do you add characters or etc to specific parts of the screen?

As development continues more questions may arise if so they will be added on to the list of questions.

Thank you and have a nice day! 😀

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hoo boy, that unofficial documentation I wrote so long ago is somewhat out of date. I never updated it for VERA 0.9 (which is rapidly looking like it'll turn out to be VERA 1.0). I wouldn't use it anymore, and in fact I thought I'd made the document private... hrm...

Anyways, to most directly answer your questions:

Switching layer 0 to "text mode", where the text starts at VRAM address $00000 and glyph data starts at VRAM address $0F800:


lda #%01100000
sta $9F2D
lda #0
sta $9F2E
lda %01111100
sta $9F2F
stz $9F30
stz $9F31
stz $9F32
stz $9F33

You can set layer 1, instead, by moving the registers $9F2D-$9F33 to $9F34-$9F3A. In either case, you may need to copy glyph data into VRAM, but apparently the kernal can do this for you if you call the screen_set_charset function:


lda #2
jsr $FF62

Adding characters to specific parts of the screen:

Each cursor location in VRAM is stored as two bytes: Character index (a.k.a. screencode, a.k.a. tile index) in byte 0, color data in byte 1. So if you've configured a layer into text mode per the assembly above, then $00000 contains the character at <0, 0> (top-left corner of the screen), $00001 contains that character's color. $00002 contains the character at <0, 1>, $00003 contains its color.

If you inspect the configuration options carefully, you'll see that the text mode setup here is 128x64. This is the same as the default text console on system startup, you'll have to handle the 80-column limit yourself, just as the kernal does. Or not, use layer scrolling and have up to 128 characters per line.

Besides being a technical limitation of the VERA (it can't specifically do an 80-wide map, the map sizes are all powers of 2), 128 is convenient because it means a row of characters is 256 bytes wide (128 characters * 2 bytes per character = 256 bytes). So for any coordinates <X, Y>, the lowest byte of VRAM is always 2*X, and the next byte is always Y. $00708 is <4, 7>. $00F10 is <8, 15>. In general, any character's address in VRAM is 2*X + 256*Y, and its color is 1 + 2*X + 256*Y.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   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.


  • Create New...

Important Information

Please review our Terms of Use