Jump to content
Sign in to follow this  
Larry

How do the Color Shadow Registers work?

Recommended Posts

In "Mapping the Atari," the color registers at locations 704-712 are indicated as the ram shadows for the rom locations $D0xx in the 400/800 OS and $FBxx in the XL/XE OS. I never really stopped to think how these actually work, but logically at boot-up or with a system reset, seems like these locations would be downloaded to the shadow registers so they can be altered by the user/program. And to make any permanent changes, one would need to change the rom locations and rom checksum (in the XL/XE) unless the checksum verification routines have been rendered inoperable.

 

Does that sound about right, or?

 

-Larry

Share this post


Link to post
Share on other sites

No, the ROM locations are the same for 400/800 OS and Xl/XE OS. It's $D0xx range. These are hardware registers. By writing into these registers you change what colors the GTIA chip will produce on screen. Because of these registers are write only (you can only write the color value to them, by reading you will not get that value back) you have to have color values store somewhere else to know what colors you have set. The OS VBI routine copies values from shadow registers to the HW registers each frame (not only for colors but for many of other registers too). This copying is done in VBI also beacause of if you would change them in random time you would change them in middle of the screen f.e. (whis is of course used by demos and games on purpose, but it's done in defined moment etc.). I hope you understand to me ;)

Edited by MaPa

Share this post


Link to post
Share on other sites

Just to clarify a bit...

 

The shadow registers are just a software function of the OS. It's a place in RAM to put values and the OS will copy them to the hardware registers for you.

 

Conversely, if the OS is running (and the CRITIC flag is off) values written directly to shadowed hardware registers will get clobbered when the OS copies the values from RAM.

 

Try writing directly to COLBK from BASIC and you'll notice you usually get a brief flash but the color is restored by the next frame.

Edited by Bryan

Share this post


Link to post
Share on other sites

Thanks.

OK, understood. But then what is the table at $FBxx -- the table of the default colors for the system? And presumably this is also the same for 800/XL/XE? (Peeking and Poking on my 130XE after startup shows that the foreground/background colors are the same as the shadows at $02Cx.)

-Larry

 

Just to clarify a bit...

 

The shadow registers are just a software function of the OS. It's a place in RAM to put values and the OS will copy them to the hardware registers for you.

 

Conversely, if the OS is running (and the CRITIC flag is off) values written directly to shadowed hardware registers will get clobbered when the OS copies the values from RAM.

 

Try writing directly to COLBK from BASIC and you'll notice you usually get a brief flash but the color is restored by the next frame.

Edited by Larry

Share this post


Link to post
Share on other sites

...and there's a reason for using these shadow regs:

 

Writing directly to the hardware registers, f.e. when changing the background colour, might result in a palette-change at the middle of the screen, i.e. the timing of the palette-change isn't deterministic, at least not when doing f.e. a POKE 53274,X instruction from basic.

 

In fact, that's why DLIs (Display List Interrupts) are so useful; changing palette at a fixed timing at middle of screen results in gfx enhancements. These interrupts (in Machine Language) will not write any values to the shadow regs, but immediately to the hw regs.

 

The OS has a function of copying the shadow regs to the hw regs at a fixed timing, once every TV-frame, at a fixed moment in time when the TV's drawing the empty offscreen parts.

  • Like 1

Share this post


Link to post
Share on other sites

Oops, seems I can't read. MaPa already answered the same as what I wrote 1 post ago.

 

 

OK, understood. But then what is the table at $FBxx -- the table of the default colors for the system?

 

Yes, it should be the palette of default colours. Memory $02Cx gets refreshed by the OS whenever a graphics mode is activated, or after cold/warm start.

Share this post


Link to post
Share on other sites

Just to clarify a bit...

 

The shadow registers are just a software function of the OS. It's a place in RAM to put values and the OS will copy them to the hardware registers for you.

 

Conversely, if the OS is running (and the CRITIC flag is off) values written directly to shadowed hardware registers will get clobbered when the OS copies the values from RAM.

...

The shadowed ones are the ones in RAM.

 

Try writing directly to COLBK from BASIC and you'll notice you usually get a brief flash but the color is restored by the next frame.

 

You can stop that from being restored if you do something like:

 

POKE 54286,0:POKE 53274,40

 

One that really needs to be shadowed is the Paddle value (location 624+) since that actually requires a frame's worth of time to be accurate in normal pot scan mode.

Share this post


Link to post
Share on other sites

One that really needs to be shadowed is the Paddle value (location 624+) since that actually requires a frame's worth of time to be accurate in normal pot scan mode.

 

Looks like shadow registers have some issues. I was trying to read HELP key in BASIC and it doesn't work (on my 800XL).

 

50 IF PEEK(764)=12 THEN ?"ENTER pressed.":GOTO 100

55 IF PEEK(764)=17 THEN ? "Help key pressed.":GOTO 70

60 GOTO 50

 

That print and branch to 70 never takes place.

Share this post


Link to post
Share on other sites

HELP key doesn't get stored there.

 

It goes to location $2DC (732). Once you read it and act on the keypress, you should store a 0 back there.

 

Also most shadow registers will not work if CRITIC flag (dec 66) is non-zero, or if IRQs are disabled.

 

Additionally, PF1 colour is stored if CRITIC is active on the XL and later machines.

Edited by Rybags

Share this post


Link to post
Share on other sites

Just to clarify a bit...

 

The shadow registers are just a software function of the OS. It's a place in RAM to put values and the OS will copy them to the hardware registers for you.

 

Conversely, if the OS is running (and the CRITIC flag is off) values written directly to shadowed hardware registers will get clobbered when the OS copies the values from RAM.

...

The shadowed ones are the ones in RAM.

No, the Shadow ones are the ones in RAM. Adding 'ed' makes Shadow a verb, therefore it must act on something. So, the Hardware ones are Shadowed, meaning they have a RAM counterpart.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks folks!

I've definitely learned quite a lot from these answers to my question.

-Larry

Share this post


Link to post
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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...