20 INK 3: PAPER 6: PRINT
   "Hello World!"
30 SAVE "test.scr" SCREEN$

and then RUN it. You will immediately be greeted by purple letters on yellow background.

Now type:

CLS:LOAD "test.scr" SCREEN$

Immediately, the same message as previously will appear on your screen. Now change line 30 and replace SCREEN$ with LAYER so it reads:

30 SAVE "test.scr" LAYER

and RUN it again. Then give the following:

CLS: LOAD "test.scr" SCREEN$:PRINT AT
2,2; "Press Any Key": PAUSE 0: CLS: LOAD
"test.scr" LAYER

and press ENTER. What you will see is two consecutive LOADs of the same image with an intermediate prompt to press a key. Before we explain what just happened, type one more thing:

LAYER 2,1: LOAD "test.scr" SCREEN$: PAUSE
0: LAYER 2,0: LAYER 0

This will produce a blank screen waiting for a keypress which when it comes will give its place to the screen you previously saved. Finally modify the above line slightly to be:

LAYER 2,1: LOAD "test.scr" LAYER: PAUSE
0: LAYER 2,0: LAYER 0

which will produce a garbled image and an error report End of file which will disappear once you press a key. Don't forget to manually turn off Layer 2 after that command because due to the error, the command did not fully execute. What has happened is that the LAYER modifier attempted to load a screen in the format supported by the current layer as set by the LAYER command (and then run out of data as the Layer 0 screen we saved is markedly smaller), while SCREEN$ exclusively loads screens in the format recognizable by Layer 0; That means that for Layer 0, LOAD ... SCREEN$ is functionally equivalent to LOAD ... LAYER but that doesn't apply to the other layers. LOAD filespec SCREEN$ and LOAD filespec LAYER do not store the current palette in use. If you haven't changed the palette at all and are using NextBASIC's standard colours, then you'll get the display you're expecting, however if you have changed the palette you may be surprised by the unintended effects this can produce. In order to get the active palette and store it in a file you will need to use the ZX Spectrum Next's NextREG facilities covered in Chapter 22 – IN, OUT and the Next Registers, or the very handy Save Palette function of the NMI menu covered later in this chapter. Additionally you cannot load screens in the shadow areas of the graphic subsystem. For that you will need the following LOAD modifier; CODE with optional parameters address, length. This essentially loads machine code programs and raw data into memory either in the address they were saved from, or in the address and length –in bytes– we specify. Keeping with the example above, type the following:

LAYER 0: LOAD "test.scr" CODE

Once again, you'll be greeted by the cheerful Hello World! screen we generated previously. To expand a bit on this first type:

NEW

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.