<!-- PDF page 83 -->

use two commas in a row.

There are two more kinds of *PRINT items*, which are used to tell the computer not what, but where to print. For example **PRINT AT 11,16;"\*"** prints a star in the middle of the screen in *Layer 0*.

The modifier

```
AT vertical_position, horizontal_position
```

moves the **PRINT** position (the place where the next item is to be printed) to the vertical and horizontal position specified. Horizontal positions are measured in *columns* and vertical positions in *rows* however for layers other than *Layer 0*, the number of columns and rows varies according to the size of characters used (and for *HiRes* mode the horizontal resolution as well). Character sizes are set according to the previous *section*, however for **AT** usage purposes, we need to note that *double-width and double-height* character sizes do not modify the maximum *columns* and *rows* **AT** will accept as parameters, so if for example you use **PRINT CHR$ 29; CHR$ 1** for characters that are **16** pixels high, you will still get a maximum of **24** rows for **AT** purposes.

You may have noticed at the beginning of this chapter that we discussed *Layer 0* as being organised for character printing purposes, in a matrix of 24 rows by 32 columns. As you will see however when in *Layer 0*, *NextBASIC* will not give you access to the last two rows since, as we discussed in *Chapter 1*, the bottom two rows of the screen are reserved. This is also true for bitmap graphics commands as you will see in *Chapters 17* and *18*. We will expand further on the possible combinations for **AT** but for now give the command:

```
PRINT AT 22,31;"*"
```

and you will immediately receive error **5 Out of screen, 0:1**. It's not difficult to understand why that happened. As we can see in *Fig. 8* below, for the purposes of printing via *NextBASIC*[^p83-1], your computer has a vertical resolution of 192 pixels. Since, as we learned in *Chapter 13*, each character is 8 pixels high, we can make a quick division and see that 192 ÷ 8 = 24. Knowing that the two last lines are reserved and not accessible to us, we can reduce our available rows by a further 16 pixels (or 2 rows) so we get a total 22 rows. As your computer starts counting from *zero*, 22 rows would go up to 21 as a value, which in turn explains why you received the error.

Rows on which we can place output using **AT**, are numbered therefore from **0** (at the top) to **21**, and columns from **0** (on the left) to **31**.

This situation changes when we change *layers* and go to the other two groups (remember that *Layer 3* and the higher resolution *Layer 2* sublayers are excluded). As discussed previously, columns and rows on these are calculated according to the width of characters that we have selected with the *control codes*. Before we illustrate graphically how the screen is organised, the following table will give you the possible combinations in columns per character width. Remember that you can also figure this out on your own by dividing the maximum resolution of the *layer* you're using by the selected character width.

<table>
<thead>
<tr><td></td><th colspan="3">Number of columns per Layer</th></tr>
<tr><th>Character<br>width<br>(in px)</th><th>LoRes<br>Layer 1,0<br>(128 x 96)</th><th>HiRes<br>Layer 1,2<br>(512 x 192)</th><th>Standard Res<br>Layers: 1,1–1,3 – 2<br>(256 x 192)</th></tr>
</thead>
<tbody>
<tr><td>3</td><td>42</td><td>170</td><td>85</td></tr>
<tr><td>4</td><td>32</td><td>128</td><td>64</td></tr>
<tr><td>5</td><td>25</td><td>102</td><td>51</td></tr>
<tr><td>6</td><td>21</td><td>85</td><td>42</td></tr>
<tr><td>7</td><td>18</td><td>73</td><td>36</td></tr>
<tr><td>8</td><td>16</td><td>64</td><td>32</td></tr>
</tbody>
</table>

*Table 6 – Column positions for PRINT according to character size*

[^p83-1]: The maximum screen resolution of the ZX Spectrum Next is 320 x 256 pixels (or 640 x 256 half-width pixels), however these resolutions are only available to *Layers 2,3* and Sprite Layers as we will see in the following chapters.

