Display Window
Created by: phil, Last modification: Tue 11 of Aug, 2009 (11:55 UTC)
The size and position of the display window is programmable, with 4 bits of precision for each of the left, right, top and bottom positions. The horizontal resolution is 16 pixels and the vertical resolution is 8 lines.
There are theoretically 512 horizontal pixel positions along a scan line. The x start values are n * 16 pixels in from the left hand side. The stop values are n * 16 pixels from theoretical pixel 256 (this is not the exact centre of the TV screen, due to sync periods etc)
Horizontal Positions:
X Start and X Stop:
Width of display in pixels = ((X_Stop's Register Value + 16) - X_Start's Register Value) * 16
| vreg_window value | X_start pixel position | X_stop pixel position |
|---|---|---|
| $0 | 00 (1) | 256 |
| $1 | 16 (1) | 272 |
| $2 | 32 (1) | 288 |
| $3 | 48 (1) | 304 |
| $4 | 64 (1) | 320 |
| $5 | 80 (1) | 336 |
| $6 | 96 | 352 |
| $7 | 112 | 368 |
| $8 | 128 | 384 |
| $9 | 144 | 400 |
| $a | 160 | 416 |
| $b | 176 | 432 |
| $c | 192 | 448 |
| $d | 208 | 464 |
| $e | 224 | 480 |
| $f | 240 | 496 (1) |
- = Outside of the normally visible TV frame - there's no point using these values.
Vertical Positions:
Y Start:
Lines in display = 160 + (Y_Stop's Reg Value * 8) - (Y_Start's Reg Value * 8)
The Y_start value reflects the position of the top line of the active display window, counting from 16 lines above the first visible scanline of the screen. (These "redundant" 16 lines allow sprites to be masked off at the top of the display).
| vreg_window value | Lines from 1st visible | (Sprite Y coord) |
|---|---|---|
| $0 | -16 (1) | $01 |
| $1 | -8 (1) | $09 |
| $2 | 0 | $11 |
| $3 | 8 | $19 |
| $4 | 16 | $21 |
| $5 | 24 | $29 |
| $6 | 32 | $31 |
| $7 | 40 | $39 |
| $8 | 48 | $41 |
| $9 | 56 | $49 |
| $a | 64 | $51 |
| $b | 72 | $59 |
| $c | 80 | $61 |
| $d | 88 | $69 |
| $e | 96 | $71 |
| $f | 104 | $79 |
- = This is above the top of the visible screen, these values should not normally be used. (A value of $2 written to the Y_start register gives the highest available start line on PAL/NTSC/VGA displays.)
Y_stop:
The Y_stop value reflects the position of the last line of the display, also counting from 16 lines above the first visible scanline of the screen.
| vreg_window value | Lines from 1st visible | (Sprite Y coord) |
|---|---|---|
| $0 | 160 | $b1 |
| $1 | 168 | $b9 |
| $2 | 176 | $c1 |
| $3 | 184 | $c9 |
| $4 | 192 | $d1 |
| $5 | 200 | $d9 |
| $6 | 208 | $e1 |
| $7 | 216 | $e9 |
| $8 | 224 | $f1 |
| $9 | 232 | $f9 |
| $a | 240 | $101 |
| $b | 248 | $109 |
| $c | 256 | $111 |
| $d | 264 (1) | $119 |
| $e | 272 (1) | $121 |
| $f | 280 (1) | $129 |
- This is below the bottom of a PAL display, should not normally be used.
VGA/NTSC/PAL Mode notes:
The first visible line in all modes is value $2, but the different TV / VGA modes allow various amounts of scanlines in each frame. PAL has around 256 lines, NTSC around 232, VGA: 240, therefore the window will not automatically be vertically centred across all modes. If this is required it can be achieved with an offset constant added to the start/stop settings plus all sprite y coordinates and scanline-based operations. The 60Hz mode flag in the Video Status Register can assist if the correction is to be done automatically, else a display adjust routine can be provided in user programs.
