PRINT INK 9; ...

ATTR

The ATTR function has the form:

ATTR (line, column)

Its two arguments are the line and column numbers that you would use in an AT item, and its result is a number that shows the colours and so on at the corresponding character position on the screen. You can use this as freely in expressions as you can any other function.

The number that is the result is the sum of four other numbers as follows:

128 if the character position is flashing, 0 if it is steady
64 if the character position is bright, 0 if it is normal
8 times the code for the paper colour –and finally–
the code for the ink colour

For instance, if the character position is flashing and normal with yellow paper and blue ink then the four numbers that we have to add together are 128,0,8*6=48 and 1, making 177 altogether. Test this with:

PRINT AT 0,0; FLASH 1; PAPER 6; INK 1;
" "; ATTR (0,0)

ATTR works only on Layer 0 and that is because it works by reading each COLOUR_FILE location. On different modes where the memory organisation and usage differs it will return a number that corresponds to the original COLOUR_FILE memory location, which could be for all purposes nonsense. That being said, you can get information on the extended colour attribute display if the EnhancedULA functions are enabled presuming the screen area hasn't moved. That number will correspond to the indices in use and it changes according to which PALETTE FORMAT command is in effect as we'll see below. For other modes it's safer to use the POINT TO command which we will examine in Chapter 16.

PALETTE

In previous sections of this chapter we got introduced to the subject of palettes and how they affect colour display and manipulation in each of the colour modes. We also got briefly introduced to the PALETTE keyword and a few of its uses. We can now expand a bit more on the subject, as PALETTE not only affects printing of the characters on screen but also all aspects of graphics including the ZX Spectrum Next's Sprite Engine.

The PALETTE keyword can be used as a primary statement or as a modifier to the LAYER and SPRITE statements to perform a variety of functions that pertain to colour manipulation.

As we saw, colour on the ZX Spectrum Next when using extended colour attribute display or any mode that doesn't use attributes, can be defined using 9 bits or 8 bits per colour. The default is 9; when 8 bits are chosen, as we have already seen previously, non attribute modes can emulate a straight-up bitmapped linear display (with the side-effect that only 4 levels of blue are available). In the latter case you can basically ignore all PALETTE statements as non-applicable for Layer 2 –and this whole section for that matter– however you need to use them if you want to manipulate LoRes or any of the Layer 1 and Layer 0 modes and/or change the default colours anywhere in your system, or even to recolour an old game. In order to do that and to have access to the broadest gamut of colour you will need to change the bit-depth of your palette(s). You can do so with the PALETTE DIM statement in the form:

PALETTE DIM bits


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.