The attribute data comes first, stored as h consecutive rows of attributes, w bytes wide. Following this is the screen data, stored as h × 8 consecutive rows of pixel data, w bytes wide. The total memory used is therefore w × h × 9 bytes.
In this mode, each character position is 16 pixels wide, comprising a left and right "half". The screen data is stored as h × 8 consecutive pixel rows of data. For each row, the first w bytes comprise the left halves of all characters. The next w bytes in the row comprise the right halves of all the characters. The total memory used is therefore w × h × 16 bytes.
The screen data is stored as h × 8 consecutive pixel rows of data. For each row, the first w bytes comprise the pixel data. The next w bytes in the row comprise the attribute data. The total memory used is therefore w × h × 16 bytes.
The data is stored as h × 8 consecutive pixel rows of data. For each row, there are w × 8 bytes, with each byte representing a single pixel. The total memory used is therefore w × h × 64 bytes.
In the previous section, we dealt with bank management. The following command could very well belong there, but since it deals with memory management of the graphics subsystem and specifically with Layer 2, we will cover it here. LAYER BANK redefines which banks will store Layer 2 display data (the front buffer) and which will act as the back buffer (for rendering). The syntax is as follows:
LAYER BANK n,m
where n is the front buffer base bank number for Layer 2 (this also sets n+1 and n+2) and m is the back buffer base bank number (and also sets m+1 and m+2). These values can be the same and both default to 9. Unlike other LAYER commands, it can be executed in any mode. For example to move Layer 2 to banks 13 to 15 (front buffer) and 16 to 18 (back buffer):
LAYER BANK 13,16
If we now give:
BANK 9 CLEAR
We can see that bank 9 (the original base bank for Layer 2) can now be released. The effects of LAYER BANK can be undone either by reversing the command, with NEW or with LAYER CLEAR.
Memory banks are also ideal to store palette information as palettes are basically a series of 256 bytes or words (depending on your PALETTE DIM setting). There are two commands for that: LAYER PALETTE BANK and SPRITE PALETTE BANK. Their syntax is virtually identical and is as follows:
LAYER|SPRITE PALETTE n BANK b,offset
where n is the palette number (0 or 1), b is the bank number and offset is the start location in the bank where the palette values are located. As mentioned above, if PALETTE DIM was set to 8, LAYER and SPRITE PALETTE BANK will load 256 bytes from bank b, offset, while if PALETTE DIM was set to 9, 512 bytes will be loaded.
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.