40 BANK 9 COPY TO 111: REM
    first we copy it
 50 PAUSE 0: REM wait for a
    key
 60 BANK 9 ERASE 128:; Erase it with
    value 128 which is by default a
    red colour for Layer 2
 70 PAUSE 0:; wait for a key
 90 BANK 111 COPY TO 9:; restore it
100 PAUSE 0:; wait for a key
110 LAYER 2,0: LAYER 0

You can see easily how fast this happens (and how it can be used for a myriad of applications)

Using BANK with graphics

Over the course of chapters dealing with graphics, we've used a lot of graphics-related commands that involved the use of BANK. These are BANK LAYER, LAYER BANK, LAYER PALETTE BANK, SPRITE PALETTE BANK, SPRITE BANK, TILE BANK and TILE DIM all benefiting all providing significant speed enhancements both in development and in usage.

We saw above the use of BANK COPY to copy data from one bank to another. This includes Layer data as they too are kept in banks and managed by NextZXOS. There is however a specially crafted command that does this and more as it adds more options specifically tuned to the requirements of display. Unlike BANK COPY, this is designed to update small areas of the screen to facilitate effects and especially animation. The command is BANK LAYER and it is used to quickly copy data from a memory bank to the screen in the current mode, or vice versa. The syntax is as follows:

BANK n LAYER x,y,w,h|offset TO [raster_op] offset|x,y,w,h

where n is the source OR destination bank number, x and y is the top left character position expressed in character column and row coordinates, w, h are the width and height again in characters of the area to be copied from or copied to, offset is the starting offset in the bank we'll be copying to or from while raster_op, is an optional symbol modifier to TO that affects the data being copied at their destination (does not affect the source data).

TO raster_op can be one of the following values:

TO Straightforward copy
TO & ANDs the copied data onto the destination
TO | ORs the copied data onto the destination
TO ^ XORs the copied data into the destination
TO ~ Copies data into the destination unless it is equal to the global transparency colour (default E3h); if so, leaves the destination unchanged

The area of screen copied by BANK...LAYER is defined as with Windows in characters. That means that character positions range from 0 to 31 for x and 0 to 23 for y, for all modes except LoRes, where they range from 0 to 15 for x and 0 to 11 for y.

Data copied from the screen is laid out as follows, depending upon the currently selected layer (see Chapter 16):


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.