Centered Display Setup

Explains how to setup a display window of any size to be centered horizontally on the screen.

Background


Amiga PAL wasn't centered to even word widths on PAL TVs. I.e. a 320x256 screen (DDF 38 to d0, standard) was offset by 12px or so to the right, and normally you couldn't adjust that on your TV. Some games used 336x256 (DDF 30 to d0) because of this, and that pretty much covered the TV width well.
Then, users got CRT monitors, which could be adjusted and so 336x256 looked weird, since they centered the Workbench screen. So those who wanted to cover the whole screen went for 352x268 or similar (DDF 30 to d8).
Later, Workbench got centering and overscan options to set non-standard DDF and DIW values for its screens.
Today, flatscreens will (generally) center a standard Workbench screen nicely, but sometimes with no standard margins left and right, so that overscan will only be visible on real monitors. (Monitors that obey the raster timing for flyback etc.)

Best practice

Best practice is to start with DDF 38,d0 and DIW 2c81,2cc1 and modify these symmetrically and always in whole 16px steps for compatibility. If you still need to move the display a few pixels for some reason, you should use the scroll register to do that. Then, you may have to add 1 word to DDFSTOP, if you don't want to lose the pixels that you shifted past the right edge.
You should always set the scroll register to 0 if you're not consciously using it for shifting. If you don't set it, it will get a random value from whatever screen was displayed before you opened yours. (This is an easy trap to fall into, making you wonder why it doesn't line up and start adjusting back and forth, etc.)
Copper commands for a standard display:
dc.w $8e,$2c81
dc.w $90,$2cc1
dc.w $92,$38
dc.w $94,$d0
dc.w $102,0

If you enable 64-bit Fetch Mode on AGA, you may see something like modulo glitches. This is because Denise receives one 64-bit fetch too many. DDFSTOP should be ended prematurely in order for this to not occur. Decrease DDFSTOP until the display looks correct. You can subtract up to $36 from DDFSTOP and still include the last 64-bit fetch.