Two of the most important ports in this list are collectively called Next Register or NextREG for short. Most of the machine's features can be controlled through NextREG.
We use a NextREG by first selecting it with the control port and then writing to – or reading from – the NextREG data port.
In NextBASIC this is achieved with two consecutive OUT commands in the case of writing or with a combination of consecutive OUT and IN in the case of reading from a NextREG.
The first command is directed to the Select port 9275 (243Bh), selecting a specific register and the second to the Data port 9531 (253Bh) to modify or read the value stored there.
If given from NextBASIC, these commands must be given consecutively in one line as NextBASIC may do something different with NextREG in-between commands. If you give the first and then wait to give the second, NextBASIC may have changed the Select register in the meantime; so by giving them together you give it no time to do something else.
The Z80N CPU which powers the ZX Spectrum Next, also provides a special NEXTREG instruction and this is referenced in Appendix A.
Finally, as mentioned in the introduction, in order to read NextREG, NextBASIC also has a specialised command and function called REG, which is much easier to use than the combination of OUT and IN keywords.
We'll showcase both methods here, in order for you to be able to use either as there are cases where the ZX Spectrum Next's facilities are still available but without NextBASIC to provide access to them. The command as a statement has the form:
REG n,v
which is essentially the same as doing:
OUT 9275, n:OUT 9531, v
Obviously n is the register number and v is the value we modify the register with. As a function, REG has the following form:
% REG n or REG n
as it works with both the integer as well as the standard expression evaluators. This essentially is the same as executing
OUT 9275, n: %x = % IN 9531 (or the equivalent x = IN 9531).
Let's give one simple example in both forms and let's mix-and-match a bit as well, to show the equivalency:
Assuming we want to change speeds to 28MHz, we could give:
RUN AT 3
or
OUT 9275, 7:OUT 9531, 3
and we can verify that it is set by either bringing up any NextBASIC menu (menus list the currently set speed on top) with the EDIT key or by doing:
OUT 9275,7: PRINT % IN 9531 & @11
Which is the same as
PRINT % REG 7&@11
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.