300 DATA 227, 182, 219, 72, 182, 0,
    0, 0, 68, 182, 227, 182, 72, 219,
    182, 227
310 DATA 227, 182, 219, 72, 182, 68,
    68, 0, 68, 68, 68, 182, 72, 219,
    182, 227
320 DATA 227, 240, 68, 72, 182, 68,
    68, 0, 68, 68, 68, 182, 72, 68,
    240, 227
330 DATA 227, 227, 227, 72, 182, 68,
    255, 182, 182, 255, 68, 182, 72,
    227, 227, 227
340 DATA 227, 227, 227, 227, 68, 68,
    255, 68, 68, 255, 68, 68, 227,
    227, 227, 227
350 DATA 227, 227, 227, 227, 227, 68,
    255, 182, 182, 255, 68, 227, 227,
    227, 227, 227
360 DATA 227, 227, 227, 227, 227,
    227, 236, 224, 236, 224, 227,
    227, 227, 227, 227, 227
370 DATA 227, 227, 227, 227, 227,
    227, 227, 252, 252, 227, 227,
    227, 227, 227, 227, 227

If you use the 64 or 85 column modes (Via the Edit/Options menu) you'll be able to discern the pattern in a similar manner as you did for the UDGs in Chapter 13. Value 227 is obviously the transparency as we discussed above.

Line 40 is a new command for us (which we will examine in length in Chapter 23) but what it does, is to reserve the first free memory bank and assign its identification number to variable a. This way we don't need to remember –or hard code– an arbitrary number as that number could be in use if this is loaded on another machine.

Next, line 60 reads each value in succession and then writes (with BANK POKE) each value in a progressively increasing offset in bank a. Once the READ process is done, we SAVE the stored values in a file for later use. This particular version of SAVE (SAVE … BANK) will be explained in length in chapters 19 and 23.

Putting Sprites on Screen

The sprite (or rather a pattern that can be assigned to a sprite) is now safely stored in bank a. So how do we display it?

For that we need a few commands. SPRITE CLEAR, SPRITE BANK, SPRITE PRINT, SPRITE BORDER and finally SPRITE.

Let's follow them one by one:

SPRITE CLEAR

clears all sprite assignments and starts fresh. It's a good idea to start any program dealing with sprites with that command so let's insert it into our program immediately with:

20 SPRITE CLEAR

We now have let NextBASIC know that we have no sprites assigned with the previous command, but now we need to assign new ones. This is done with:


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.