Jump to content
IGNORED

How to set up video mode?


Sdw

Recommended Posts

Coming from primarily from Commodore systems (c64 for example) the Atari 8 bit way of dealing with graphics modes has me scratching my head a bit.

On the C64 you simply use some registers to set up what mode you want (textmode/gfx and hires/multicolor) and then some others to point where in memory your bitmap data (or character screen/font definition) is, and that's pretty much it.

 

I've found the following memory map of the Atari CTIA/GTIA

http://en.wikipedia.org/wiki/CTIA_and_GTIA

 

However, there are no registers dealing with video modes at all as far as I can see.

I have read enough to understand that I instead need to use display lists to set up my video mode, however I can't find any good, clear examples.

Can anyone provide a simple example on how to set up the different video modes (pure to-the-metal-assembly preferred, don't want to use any system/Basic routines)

Link to comment
Share on other sites

The memory location you want to use is 560 ... that is a two byte pointer to the start of your display list.

 

The display list is a set of instructions that tell your Atari how to lay out the screen and what display modes to use. This is stored at the memory location pointed to by DLIST (560+256*561)

 

This is a useful reference for display list programming:

 

http://www.atariarch...ere/chapt02.php

 

Also this: http://www.atariarch...g/appendix8.php

 

You have these commands which set different modes:

 

2 - Graphics mode 0, text, 40 columns, 8x8 char, 2 colors.

3 - Special version of the above, 8x8, 2 colors, but with true descenders, each char uses 10 scanlines

4 - Graphics mode 12, text, 40 columns, 4x8 characters, 5 colors (4 per char cell).

5 - Graphics mode 13 text, same as above, but lower resolution (double scanline)

6 - Graphics mode 1 text, 20 columns, 8x8 char, 5 colors, you can display monochrome text in 4 colors

7 - Graphics mode 2 text, as above, but at double scanline lower resolution

8 - Graphics mode 3 bitmap, 4 colors, 40 block pixels across, 40x24 resolution

9 - Graphics mode 4 bitmap, 2 colors, 80 x 48 resolution

A - Graphics mode 5 bitmap, 4 colors, 80x48

B - Graphics mode 6 bitmap, 2 colors, 160x96 resolition

C - Graphics mode 14 bitmap, 2 colors, 160x192

D - Graphics mode 7 butmap, 4 colors, 160x96 resolution

E - Graphics mode 15 bitmap, 4 colors, 160x192

F - Graphics mode 8 bitmap, 2 colors, 320x192 (highest resolution)

 

These commands are used every display line. You can also add modifiers to these as follows ...

set bit 4 (add 16) - enables horizontal fine scroll

set bit 5 (add 32) - enables vertical fine scroll

set bit 6 (add 64) - load memory scan, for changing the memory of your screen. Next two bytes are the address where the screen data is.

set bit 7 (add 128) - display list interrupt (for changing color or other settings mid-screen)

 

There are also commands which are even multiples of 16 that cause Antic to insert blank scanlines, and two commands which are basically like JMP instructions, telling ANTIC to jump to a memory location and continue processing the display list. 1 is a regular jump, 65 is a jump after vertical blank, used at the end of the DL, to point Antic back to either the top of the DL, or start of the next DL.

 

Hope this helps.

Edited by Synthpopalooza
Link to comment
Share on other sites

So as an example, the default setting, Graphics 0, as referenced by display list instructions:

 

112

112

112 (3 sets of 8 blank scan lines)

66 (Graphics 0 + load memory scan, this is required to tell ANTIC where the screen mem is) + lo-hi screen memory bytes

23 lines of instruction 2 (Graphics 0)

65 (jump and wait for VBI) followed by 2 byte address of display list start, this tells ANTIC to redraw the screen as above after the VBI.

 

Some other helpful locations:

 

756 - CHBAS, Character font pointer. This is set to a page boundary.

88-89 - Pointer to screen memory

559 - This serves a number of functions, including setting up 32, 40, or 48 byte displays (screen width)

623 - Covers player missle (sprite) priorities, and also allows setting GTIA (16 color) modes. This is usually done using hires mode, gives you displays with 80 pixels across but with 9 to 16 colors depending on which mode you use.

Edited by Synthpopalooza
Link to comment
Share on other sites

Here is a minimal setup in xasm for ANTIC mode E, 160x200, 4 color mode, with linear screen memory.

 

 opt l+h+f-
icl 'hardware.asm'

main equ $2000
scr equ $3010

org main
sei
lda #0
sta IRQEN
sta NMIEN
sta DMACTL
cmp:rne VCOUNT
mwa #dlist DLISTL
mva #$22 DMACTL
jmp *

dlist
:2 dta $70
dta $4E,a(scr)
:101 dta $E
dta $4E,a(scr+4096-16)
:97 dta $E
dta $41,a(dlist)

org scr
:8016 dta #&$FF
run main

 

Code and executable:

 

antice.zip

 

See also Trevin Beatties' Atari Technical Information and phaeron's Altirra Hardware Reference Manual.

Link to comment
Share on other sites

I'll add a few things.

  • You want to create a display list (screen layout) with no more than 240 scanlines. The general rule is use 24 blank lines at the top.
  • When setting up a screen, remember than ANTIC cannot read more than 4Kb at a time. What this means is that when using any of the hi-res screen modes towards the middle, you will need a 2nd LMS instruction.
  • The machine reads 40 bytes per line (48 if in wide or smooth H-Scroll is enabled). This means you have somewhere between 40 and 320 pixels across. 320 pixels is monochrome, 160 pixels is 4 colour, 80 pixels is 16 colour.
  • Every line can be a different resolution, and can read from a different section of memory. Smooth horizontal and vertical scrolling is also able to be controlled on a line by line basis.

There is a wealth of information over at http://www.atariarch...s.org/ Mapping the Atari is a must, and De Re Atari has some good information as well.

 

Have fun coding the little Atari 8-bits. I have owned one continually since 1982 and there is still new software coming out that amazes me.

Link to comment
Share on other sites

I should also add:

 

The locations I mentioned for character set and GTIA, are actually the shadow registers that you would use from BASIC, or a VBI. Using assembly, you would need to use the actual hardware registers, which can be found through Mapping the Atari (I don't remember them offhand).

Edited by Synthpopalooza
Link to comment
Share on other sites

hscroll enabling means 48 bytes... ;)

 

some additional information from my side...

 

you can mix and setup your screen layout like you wish. so it is more AMIGA like ("Copper list") than c64 where you have a fixed screenlayout based on your VIC settings (ok...without hammering VIC-registers for "special fx").

 

maybe in modern words the Display List is more like a small script (or program) which ANTIC runs through every VBL and builds up the screen. It has again nothing to do like on 2600 where you are going to race the beam.

 

but beware... once you are getting used to... and going back to c64 you gonna miss something ;) (and praise god for the color ram :D)

Link to comment
Share on other sites

so actually bit 6,7 of the PRIOR register of GTIA is used for some kind of mode selection (mode9,10,11) which are based on highres mode F where 4 bits of each VRAM byte is interpretated differently (16 lum of one color, 9 individual colors = color register selection, 16 colors with 1 lum).

 

VSCROL, HSCROL regions can be set up free (not like on c64) and with hardware you can scroll 16 color clocks (most of the time = pixel). Difference here to c64... VIC works while scrolling in 320x resolution while here ANTIC works in color clocks. f.e. in 160x 4 color mode you can scroll without moving any byte around 4 chars in x-direction while in y-directions 2 chars.

 

what else to add... you can have "no borders" without any $d011 trickery simply by doing a LDA #35 STA $D400 f.e. ;) so you have fullscreen "by hardware" if you want... and if you need more CPU time... you can reduce your display list and the visible screen layout to gain DMA time back...

 

you will love the linear VRAM (compared to VIC) and you will hate the 128 char limit per font ;) and there is no comparable color ram...

 

another difference... writing to ROM areas are not going to go "through" and stored in the RAM below ROM. on A8 you need to turn off ROM to get access to the RAM below... and the hardware I/O area is not usable for RAM. so on A8 approx. 56k RAM compared to the 66K of the c64.

Link to comment
Share on other sites

another difference... writing to ROM areas are not going to go "through" and stored in the RAM below ROM. on A8 you need to turn off ROM to get access to the RAM below... and the hardware I/O area is not usable for RAM. so on A8 approx. 56k RAM compared to the 66K of the c64.

 

Atari has 62Kb of usable RAM (if you switch of the Os that is). Only $d000-$d7ff are not usable.

 

The extra 2Kb you gave the C64 - were you referring to the Color-RAM or is it just a typo?

 

 

EDIT:

@all: Don't know if it isn't a bit confusing to shove almost all knowledge of the A8 display into his head where all he wanted is to setup a Gr.15 screen which was shown in post 4 :o

Edited by Creature XL
Link to comment
Share on other sites

C64 = 64K - 2 bytes (0 and 1 not normally accessable except with "tricks")

4K under I/O area is accessable by banking via the on-chip 6510 port.

1k x 4 bit screen attribute Ram isn't normally counted as system Ram. I guess if you're desperate there are 24 4 bit spare nybbles that the screen doesn't use.

 

 

Re Display Lists - best bet is to start with simple ones, jumping in with full blown hires + multi LMS and scrolling regions is a bit heavy.

Link to comment
Share on other sites

oops... maybe you are right but maybe he should see what else to explore before he gets confused while Gr. 15 is linear and not 8x8 layouted ;)

I C.

What about a (structured) list about difference between A8 and C64? I am pretty sure the C64 people on AA will help.

It could be a post in this thread to which AA users can point the next "convert" ;)

Of course along with a link to the "Altirra HW-Manual" to explore the details.

Link to comment
Share on other sites

I think trying to force one to act like the other just drives you mad in the end - they're different and the best you can do is keep your game logic out of your machine specifics and suck up the extra work.

 

That said as a compromise there ought to be an example bit of code that for a minimal machine setup that is as close to a commodore 64 (or plus4) as you can reasonably get that will get people up and running.

 

Although in my mind all I can think of right now is something that loads at $0810 and sets up a 40x25 multicolour character screen at $0400

Edited by sack-c0s
Link to comment
Share on other sites

Thank you all, great info!

 

Xuel's little example was just enough to get me going (once I figured out what the strange assembler-specific macros were doing! :D)

I also managed to get some different text modes up and running, without problem. Now I have a nice little dither-plasma going! ;)

 

Regarding Xuel's example though - what is the reason to put the screen at $3010, and not an even address (like $3000 or so)?

 

Also, the list Synthpopalooza contained many graphics modes, however, I'm sure I've heard of additional modes like 80x192 with 16 lumas of the same color for example, any info on how to set those up?

Link to comment
Share on other sites

They're GTIA modes which are enabled by changing GPRIOR / PRIOR

 

High 2 bits control the mode 00=normal 01=16 luma @ colour of COLBAK, 10=9 paletted colours, 11=16 colour @ luma of COLBAK.

 

Usual practice is to use GTIA mode in conjunction with a hires (320) pixel Antic bitmap or character mode, but some other modes are useful with them too.

 

Mixing GTIA modes or GTIA + normal modes will usually mean DLI programming needed to do the register changes on the fly.

Link to comment
Share on other sites

Regarding Xuel's example though - what is the reason to put the screen at $3010, and not an even address (like $3000 or so)?

 

ANTIC's bitmap counter only has 12 bits, so it loops every 4096 bytes. The bitmap address's top 4 bits are fixed to whatever the last LMS instruction set them to. So, the reason for the 16 byte offset from $3000 is so that ANTIC doesn't loop in the middle of a line. Instead, the last byte of the last line of the first LMS butts up against the very end of the 4096 byte boundary. Then the next LMS can start back up at the very start of the next 4096 byte boundary. See also section 4.5 of the Altirra Hardware Reference Manual.

 

Also, I made a mistake in the scr section. It should read ":8000", not ":8016" since the padding is taken care of in the src equate. There are exactly 8000 bytes for a 160x200 screen bitmap.

Link to comment
Share on other sites

They're GTIA modes which are enabled by changing GPRIOR / PRIOR

 

High 2 bits control the mode 00=normal 01=16 luma @ colour of COLBAK, 10=9 paletted colours, 11=16 colour @ luma of COLBAK.

 

Usual practice is to use GTIA mode in conjunction with a hires (320) pixel Antic bitmap or character mode, but some other modes are useful with them too.

 

Mixing GTIA modes or GTIA + normal modes will usually mean DLI programming needed to do the register changes on the fly.

 

What is the benefit of using GTIA modes in conjunction with a hires mode? Examples?

Link to comment
Share on other sites

The default is that GTIA modes do use hires, ie Graphics 9,10,11 are simply Graphics 8 with the GTIA mode turned on.

 

It's a bit complex but to do with the way data passes from Antic to GTIA over the AN0-2 lines. Hires modes allow all possibilities of bit pairs which GTIA combines to give 16 colour combinations but other modes usually don't allow all combinations so aren't as useful.

Link to comment
Share on other sites

[Hmm, Andreas on XL - does that mean I have to code for ST next time to win? :-) ]

 

> what is the reason to put the screen at $3010, and not an even address

The screen ram pointer of ANTIC has 12 bits only, so it cannot cross a 4k boundary without a 2nd LMS instruction in the DL.

And because 4096/40 BPL = 102 leaves 16 bytes you start 16 bytes later.

Otherwise the roll-over of the screen pointer will appear in the middle of scanline and will break your linar memory layout.

Just type "GRAPHICS 15" in BASIC and dump the DL to see what the OS does by default.

 

[Read before post]

Edited by JAC!
  • Like 1
Link to comment
Share on other sites

The default is that GTIA modes do use hires, ie Graphics 9,10,11 are simply Graphics 8 with the GTIA mode turned on.

 

It's a bit complex but to do with the way data passes from Antic to GTIA over the AN0-2 lines. Hires modes allow all possibilities of bit pairs which GTIA combines to give 16 colour combinations but other modes usually don't allow all combinations so aren't as useful.

 

Specifically, using ANTIC 4/5 with the GTIA bit set has interesting effects.

 

In modes 9 (monochrome) and 11 (15 colors + background) the layout differs between normal and inverse characters. Here's a table:

 

Nybble: Normal color: Inverse color:

 

0000 and 0001 0 0

0010 1 1

0011 2 3*

0100 and 0101 0 0

0110 1 1

0111 2 3*

1000 and 1001 4 4

1010 5 5

1011 6 7*

1100 and 1101 8 12*

1110 9 13*

1111 10 15*

 

* indicates colors that change when inversed. Colors 11 and 14 unavailable.

 

In mode 10 the rules are different. We are only concerned with 7 color patterns.

 

Nybble Normal Inverse

0101 PM0 (BG) PM0 (BG)

0110 PM1 PM1

0111 PM2 PM3*

1000 BAK BAK

1001 PF0 PF0

1010 PF1 PF1

1011 PF2 PF3*

 

All 9 graphics 10 colors are available, except that PM3 and PF3 replace PM2 and PF2 when inversed (analogous to Antic 4 where PF3 replaces PF2 in inverse).

 

The offshoot of this is, this is one possible way to use Graphics 10 in low-resolution, by setting up ANTIC 5 with GTIA set to 10, and having 4 character sets changed with DLI's. You just can't mix inverse and normal colors in the same char cell ... 7 colors per char cell only.

Edited by Synthpopalooza
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

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