83
edits
m (→ZX Spectrum Video Mode: tag the display file bit with copyedit) |
(→Display file layout: Copyedited for clarity) |
||
Line 10: | Line 10: | ||
=== Display file layout === | === Display file layout === | ||
The pixel data appear starting at address 4000h (16384); the screen is divided vertically into thirds, then lines modulo 8, then rows (blocks of 8 lines). This might become clearer if you look at how the address lines are 'jumbled': if we write L4-L0 for the bits of the Line number (0-23), P2-P0 for the bits of the Pixel row within the line (0-7), and C4-C0 for the bits of the Column number (0-31), we get the following... | The pixel data appear starting at address 4000h (16384); the screen is divided vertically into thirds, then lines modulo 8, then rows (blocks of 8 lines). This might become clearer if you look at how the address lines are 'jumbled': if we write L4-L0 for the bits of the Line number (0-23), P2-P0 for the bits of the Pixel row within the line (0-7), and C4-C0 for the bits of the Column number (0-31), we get the following... | ||
{| border="1" cellpadding="3" | |||
Alternatively, in C, dataByteHigh=0x40|(line&0x18)|(pixelrow%8), dataByteLow=((line&0x7)<<5)|column. | |(msb)|||| '''0''' || '''1''' || '''0''' ||L4||L3||P2||P1||P0|| ||L2||L1||L0||C4||C3||C2||C1||C0||||(lsb) | ||
|} | |||
Alternatively, in C, | |||
dataByteHigh=0x40|(line&0x18)|(pixelrow%8), dataByteLow=((line&0x7)<<5)|column. | |||
Then, the byte at this address contains 8 bits, which are the pixel data for the relevant row of 8 pixels. | Then, the byte at this address contains 8 bits, which are the pixel data for the relevant row of 8 pixels. | ||
The attribute bytes are arranged slightly more sanely, as they don't have the pixel row in there... | The attribute bytes are arranged slightly more sanely, as they don't have the pixel row in there... | ||
{| border="1" cellpadding="3" | |||
In C again, attrByteHigh=0x58|(line>>3), attrByteLow=dataByteLow. | |(msb)|||| '''0''' || '''1''' || '''0''' || '''1''' || '''1''' || '''0''' ||L4||L3||||L2||L1||L0||C4||C3||C2||C1||C0||||(lsb) | ||
|} | |||
In C again, | |||
attrByteHigh=0x58|(line>>3), attrByteLow=dataByteLow. | |||
One way to make this clearer (or not...) is to run a program which sequentially fills in the screen RAM, like the following: | |||
10 FOR a=16384 TO 23295 | |||
20 POKE a,255 | |||
30 NEXT a | |||
Watching the order in which the screen is filled should make it clear how the screen RAM works. | |||
=== Attribute Byte === | === Attribute Byte === |
edits