Pages 309–311 · Markdown
Chapter 1 – Basic Programming Concepts .......... 5
Introduction ....................................... 5
PRINT, LET, programs and line numbers ............. 5
Variables and Arrays ............................... 6
Assignments ........................................ 6
Labels .............................................. 8
Using LIST, RUN and cursors to edit and run programs 8
REM, NEW, INPUT and GO TO .......................... 9
Using STOP, BREAK and CONTINUE .................... 10
Error trapping ..................................... 13
ERROR [n] .......................................... 14
Chapter 2 – Decisions ............................. 16
Making decisions ................................... 16
Using IF to make decisions ......................... 16
ELSE ............................................... 17
Case selection with ON ............................. 19
Decisions with the ? operator ...................... 19
Chapter 3 – Looping ............................... 21
Using FOR, TO and NEXT ............................. 21
STEP ............................................... 22
EXIT ............................................... 23
REPEAT...REPEAT UNTIL loops ........................ 24
WHILE ............................................... 25
Error trapping within REPEAT...REPEAT UNTIL loops .. 26
Chapter 4 – Procedures and Subroutines ............ 27
Branching .......................................... 27
GO SUB and RETURN .................................. 27
LOCAL keyword ...................................... 28
PRIVATE and PRIVATE CLEAR .......................... 29
Procedures (DEFPROC / ENDPROC / PROC) .............. 29
Passing parameters by reference with REF ........... 32
Reading parameters with DATA and READ .............. 33
Trapping errors locally ............................. 33
Chapter 5 – READ, DATA, RESTORE ................... 35
READ, DATA and RESTORE ............................. 35
DATA (function) .................................... 36
Chapter 6 – Expressions ........................... 37
Mathematical operations +, - , * , /, MOD .......... 37
Order of mathematical calculations ................. 37
Bitwise, relational and logical operators .......... 37
Unary/Bitwise NOT (!) .............................. 38
Bitwise operators <<, >>, &, |, ↑, ↑| .............. 38
Expressions ......................................... 39
Variable names and limitations ..................... 39
Scientific notation ................................. 40
Decimal, Binary and Hexadecimal numbers ............ 41
More about Integer Expressions and Variables ....... 41
Signed vs Unsigned Integer Expressions ............. 45
Chapter 7 – Strings ............................... 49
Introduction ........................................ 49
String slicing, using TO ........................... 49
String multiplication using the * operator ......... 50
Transforming a string with trailing modifers ....... 51
Tokenisation of strings ............................. 51
Chapter 8 – Functions ............................. 52
Order of calculations using functions .............. 52
String functions .................................... 53
LEN ................................................. 53
STR$ ................................................ 53
IN .................................................. 54
VAL and VAL$ ........................................ 55
Numeric functions ................................... 55
SGN ................................................. 55
ABS ................................................. 56
INT ................................................. 56
SQR ................................................. 56
User defined functions using DEF and FN ............ 56
NextBASIC functions within integer expressions ..... 58
Chapter 9 – Mathematical Functions ................ 60
↑ and EXP ........................................... 60
LN .................................................. 61
PI .................................................. 61
Trigonometry with SIN, COS, TAN, ASN, ACS and ATN .. 62
Chapter 10 – Random Numbers ....................... 64
RANDOMIZE, RND and % RND ........................... 64
Chapter 11 – Arrays ................................ 67
DIM ................................................. 67
DIM function ........................................ 70
Chapter 12 – Conditions ............................ 71
AND, OR and NOT ..................................... 71
Chapter 13 – The Character Set ..................... 74
CHR$ and CODE ....................................... 74
The graphics symbols ................................ 74
Tokens .............................................. 75
BIN and USR ......................................... 75
POKE and PEEK ....................................... 76
Alternative Character Sets .......................... 79
Character Graphics Mode ............................ 80
Chapter 14 – More about PRINT and INPUT ........... 81
Coordinate Systems .................................. 81
Screen Modes and Pixel Coordinates .................. 81
Changing the size of characters ..................... 82
Using AT to print to a certain location ............. 82
Using POINT to print to a certain location .......... 85
SCREEN$ ............................................. 88
TAB ................................................. 88
CLS ................................................. 89
Scrolling ........................................... 89
Expanding on INPUT .................................. 90
LINE input .......................................... 91
Using Expressions for INPUT ......................... 91
Using control codes with PRINT ...................... 92
INKEY$ .............................................. 93
Using INPUT for game controllers .................... 93
Chapter 15 – Colours ............................... 95
An introduction to colour on the ZX Spectrum Next ... 95
Basics of computer colour ........................... 95
Colour organisation and representation .............. 95
Spatial vs Colour Resolution ........................ 95
Colour attribute display ............................ 98
Extended colour attribute display ................... 100
Palette-based hybrid linear bitmapped colour display 101
Layer 3 colour storage .............................. 102
Layer 2 priority colours ............................ 102
More on the LAYER command ........................... 103
BORDER, PAPER, INK, BRIGHT and FLASH ................ 105
BORDER .............................................. 107
INVERSE and OVER .................................... 107
Using colour control codes .......................... 107
ATTR ................................................ 108
PALETTE ............................................. 108
Chapter 16 – Graphics .............................. 113
PLOT ................................................ 113
DRAW and CIRCLE ..................................... 114
POINT, POINT TO ..................................... 116
Using OVER and INVERSE with graphics commands ...... 117
Using stippling patterns to generate additional colours 118
Quick erase and fill using LAYER ERASE .............. 118
Clipping windows .................................... 118
Tiling ............................................... 119
Accessing non-supported graphics modes .............. 120
Chapter 17 – Time and Motion ........................ 121
PAUSE ............................................... 121
Using POKE and PEEK at the System Variables ......... 122
TIME (command/function) ............................. 122
Retrieving information from the RTC ................. 122
TIME$ ............................................... 123
INKEY$ .............................................. 125
Animation: a quick primer ........................... 125
Mass Storage Frame Playback ......................... 125
Memory Based Frame Playback ......................... 127
Animation with the Sprite System .................... 128
Creating Sprites ..................................... 128
Putting Sprites on Screen ............................ 130
Animating Sprites .................................... 132
Moving Sprites on Screen ............................. 134
Relative sprites ..................................... 136
Composite vs Unified sprites ....................... 136
Batching ............................................ 137
Automatic sprite movement ........................... 137
Sprite functions .................................... 139
Scrolling ........................................... 140
The Copper .......................................... 140
Chapter 18 – Sound and Music ....................... 144
Basic sounds with the BEEP command .................. 144
Enhanced Sound and Music with PLAY .................. 147
Using the PLAY command .............................. 147
Constructing strings ................................ 148
PLAY command summary ................................ 148
Setting the pitch ................................... 148
Note duration ....................................... 149
The N Command ....................................... 151
Note volume ......................................... 151
Volume effects ....................................... 151
Tempo ............................................... 152
Repeated phrases ..................................... 152
The H command ....................................... 153
Comments ............................................ 153
Channel selection ................................... 153
Stereo control ....................................... 153
Digital Audio ....................................... 153
WAV ................................................. 154
MOD ................................................. 154
PT3 ................................................. 154
Using the Pi accelerator for audio ................... 154
External Audio Output ................................ 155
Chapter 19 – NextZXOS and alternatives ............. 157
Guide to NextZXOS ................................... 157
NextZXOS main features .............................. 157
Files, Drives, Partitions and Disks .................. 158
Working with files .................................. 158
Filenames ........................................... 159
LOAD ................................................ 160
SAVE ................................................ 164
VERIFY .............................................. 168
MERGE ............................................... 169
Using NextZXOS ...................................... 170
Wildcards ........................................... 170
Filesystems ......................................... 171
Partitions .......................................... 171
Storage devices and disks ............................ 171
Mounting ............................................ 172
Drive cataloguing ................................... 173
Drive, Folder and User Area navigation and management 177
MKDIR ............................................... 178
RMDIR ............................................... 178
CD .................................................. 179
PWD ................................................. 180
Managing files and their attributes .................. 181
COPY ................................................ 181
ERASE ............................................... 182
MOVE ................................................ 183
File attributes ...................................... 184
The RAMdisk ......................................... 186
Drive and Partition Management ...................... 186
CAT TAB and CAT ASN .................................. 186
MOVE ... IN, MOVE ... OUT and REMOUNT ............... 187
Virtual filesystem management – .mkdata and .mkswap .. 188
Printing ............................................ 189
The SPECTRUM command ................................ 189
Speed Control ....................................... 191
NextBASIC Editor and Program support commands ....... 192
The Browser ......................................... 193
The Browser Window .................................. 193
Using the Browser ................................... 194
Configuring the Browser .............................. 196
The Command Line ..................................... 196
ROM Cartridge Loaders ................................ 197
48K BASIC ........................................... 197
128K BASIC .......................................... 197
ZX80 and ZX81 BASIC .................................. 197
NMI Menu ............................................ 197
The NextZXOS folder structure ........................ 199
NextZXOS dot commands ................................ 199
Modifying the startup – Autoexec.bas ................. 200
CP/M ................................................ 201
Preparing your ZX Spectrum Next for esxDOS ........... 204
Chapter 20 – Channels, Streams,
Drivers and Windows ................................. 206
Channels ............................................ 206
Streams ............................................. 208
Using Streams ....................................... 208
Stream control commands .............................. 208
The Variable and Memory Channels ..................... 211
Installable device drivers and Driver Channels ....... 213
Driver Channel support ............................... 213
Windows ............................................. 214
System Windows vs User Windows ....................... 214
User character sets .................................. 216
Window input ......................................... 217
Window definitions ................................... 217
Chapter 21 – Optional Features ...................... 220
Overview ............................................ 220
Installation (for Issue 2 mainboards) ................ 220
Raspberry Pi Zero installation on the Issue 4 mainboard 222
Testing the add-ons' installation .................... 222
A. Testing the memory ................................ 223
Using the Real Time Clock hardware ................... 227
Using the RTC together with the WiFi module .......... 228
Using the rest of the add-ons ........................ 228
Chapter 22 – IN, OUT and the
Next Registers ...................................... 229
IN and OUT .......................................... 229
Hardware address decoding ............................ 229
Accessing the ZX Spectrum Next features with NextREG . 232
The Next Registers .................................. 234
The Expansion Bus ................................... 246
Chapter 23 – The Memory ............................ 247
Overview ............................................ 247
ROM and RAM ......................................... 247
The Memory Map ...................................... 247
Memory Management ................................... 248
Reading and Writing to Memory ........................ 249
NextZXOS and NextBASIC memory allocation ............. 251
Memory Areas and their use ........................... 252
NextBASIC Data Structures ............................ 253
PEEK, POKE and their variants ........................ 256
CLEAR ............................................... 259
Memory Bank management with BANK .................... 259
Using BANK with graphics ............................. 262
Using BANK with files ................................ 264
Extending NextBASIC Programs with BANK ............... 265
NextZXOS Paging Mechanism Overview ................... 265
MMU-Based Memory Management .......................... 269
Layer 2 Bank Switching ............................... 269
Paging method interactions ........................... 269
Paging out the ROM ................................... 269
Chapter 24 – The System Variables ................... 271
Overview ............................................ 271
System Variables ..................................... 271
Chapter 25 – Using Machine Code ..................... 275
Using Machine Code ................................... 275
Using CLEAR to Make Space ............................ 275
Using USR to run machine code ........................ 276
Calling NextZXOS from NextBASIC ...................... 278
Opcodes Prefixes ..................................... 281
Appendix A – Character Set, Z80N
Mnemonics and Control Codes ......................... 282
Appendix B – Reference .............................. 288
Reports and Error Codes .............................. 288
General Errors ....................................... 288
Storage Device Related Errors ........................ 290
NextBASIC Keywords and Functions ..................... 291
The Decimal System ................................... 295
The Binary System .................................... 295
The Hexadecimal System ............................... 295
Bits, Bytes and Words ................................ 296
Using Binary and Hex in NextBASIC .................... 296
Appendix C – Machine Personalities .................. 297
Overview ............................................ 297
The Cores and their update procedures ................ 297
Regular Core update .................................. 298
AB Core update ....................................... 298
Multicore (Extra Cores) update ........................ 299
Updating the firmware ................................ 299
Updating the System/Next™ distribution ............... 300
Selecting and configuring a personality .............. 300
Troubleshooting ....................................... 302
Other things to look for .............................. 302
Appendix D– The Calculator ........................... 303
Selecting the calculator .............................. 303
Entering numbers ...................................... 303
Running total .......................................... 303
Using built-in mathematical functions ................. 304
Editing the screen ..................................... 304
Assigning variables .................................... 304
User defined functions ................................. 304
Exiting from the calculator ............................ 305
Acknowledgements ...................................... 307
Table Of Contents ..................................... 309
Index ................................................. 312
Technical Specifications .............................. 317
Issue 2 ............................................... 317
Issue 4 ............................................... 318
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.