Difference between revisions of "NextBASIC"

From SpecNext official Wiki
Jump to: navigation, search
(Graphics)
(Basic Interaction Commands)
Line 6: Line 6:
 
{| class="wikitable"
 
{| class="wikitable"
 
! Command !! Effect
 
! Command !! Effect
 +
|-
 +
| BANK b LINE x,y || Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command.
 +
|-
 +
| BANK b LIST x? || Lists source code in bank b (from line x)
 
|-
 
|-
 
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)
 
| CLEAR x? || Resets variables, clears screen, resets plot cursor (and sets ramtop to X)

Revision as of 18:46, 11 October 2017

NextBASIC is an extended version of the classic Spectrum BASIC which adds extra commands supporting the new features of the NEXT.

? after parameters indicate they are optional. Square brackets [] indicate scope of optional or repeated areas (parenthesis are not used for this because they are part of the BASIC language). Bracketed sections in the effects only apply if the optional parameters are specified.

Basic Interaction Commands

Command Effect
BANK b LINE x,y Copies lines x,y into bank b. Once this is done, these lines cannot be edited except by overwriting them with another BANK..LINE command.
BANK b LIST x? Lists source code in bank b (from line x)
CLEAR x? Resets variables, clears screen, resets plot cursor (and sets ramtop to X)
LIST x? Lists source code (from line x)
LLIST x? Lists source code to printer (from line x)
NEW Clear stored program
RUN x? CLEAR then run program (from line x)

Control Flow

Command Effect
DEF FN func(param[,param..])=expr Creates a user defined function based on a parameterised expression
FOR var = start TO end [STEP step]? Starts FOR loop between given numeric values (with given step)
IF c THEN statements.. Run statements only if expression c is true
GO TO x Jump execution to line X
GO SUB x Jump execution to line X, storing current location on gosub stack
NEXT var Marks end of FOR loop regarding VAR
RETURN Restore execution location from gosub stack

Graphics

Command Effect
BRIGHT n Enable or disable bright colors. n must be 0 or 1. Not legal on non-ULA layers or if ULANext is enabled.
CIRCLE x,y,r Draw circle centered at x, y with radius r
DRAW [modifier or x,y].. Draw line from plot cursor to given coordinate
FLASH n Enable or disable ink/paper cycling. n must be 0 or 1. Not legal on non-ULA layers or if ULANext is enabled.
INK c Set ink (foreground) color for print and graphics commands. If ULANext is enabled, this can use any legal palette value. On layer 2, it can use any value 0-255.
LAYER x Selects active layer for graphics operations. LAYER 0 is an unenhanced ULA screen. LAYER 1 is the ULA screen but with enhancements and with the origin at the top left (not the bottom left). LAYER 2 is, well, Layer 2.
LAYER 1,x Sets mode for layer 1 based on x. 1 = Standard Spectrum, 2 = Times hires, 3 = Times hicolour, 0 = Lores Layer.
LAYER 2,x Selects Layer 2 and determines if it is displayed or not (x must be 0 or 1)
LAYER AT x, y Sets the scroll display offset for the current layer.
LAYER BANK f, b Only when Layer 2 is selected, selects the first bank for layer 2 (f) and shadow layer 2 (b). Note that a layer 2 screen occupies 3 banks.
LAYER CLEAR Resets all layer settings
LAYER DIM left, top, right, bottom Sets visible area for current layer
LAYER ERASE x, y, w, h [,f]? Fills a region at x,y, of size w,h, with palette index f (or the transparent value)
LAYER OVER Sets layer ordering
LAYER PALETTE x Choose which of the two palettes is used for the active layer (x must be 0 or 1)
LAYER PALETTE n, i, v Sets palette index i in palette in to color value v. V is always 9 bit, even if PALETTE DIM 8 is set.
LAYER PALETTE n BANK b, offset Loads current layer's palette n (0 or 1) from bytes starting at offset in bank b. If PALETTE DIM 8 is set, each byte is one color. If PALETTE DIM 9 is set, each color needs two bytes, but only one bit of the second is used.
PALETTE CLEAR Resets all palettes and palette settings
PALETTE DIM x Sets number of color bits in the active palette; x must be 8 or 9
PALETTE FORMAT x Enables ULANext colors with x inks. X must be a bitmask which masks off bits on the right of a value (1, 3, 7, 15, 31, 63, 127 or 255)
PALETTE OVER x Sets the global transparency color to x
PAPER c Set paper (background) color for print and graphics commands. Follows the same rules as INK.
PLOT [modifier or x,y].. Plot listed points as single pixels on current layer
POINT x, y, var Stores the color at point x, y on the ULA screen in variable var
POINT x, y Returns the color at point x, y on the ULA screen

Modifiers for graphics commands can be inline INK, PAPER, INVERSE, and OVER. INVERSE 1 causes drawing to be in the paper color. OVER 1 causes pixels in the line to be flipped.

Memory and Port Access

Command Effect
BANK 1346 FORMAT Re-enable RAMdisk having been disabled by previous BANK 1346 USR
BANK 1346 USR Disable RAMdisk, allowing banks 1, 3, 4, and 6 to be used
BANK b COPY TO c Copy entire bank b to bank c
BANK b COPY start, len TO c, start Copy len bytes from start in bank b, to start in bank c
BANK b ERASE x? Erase all data in bank by overwriting with zeros (or x)
BANK b ERASE off, len, value Overwrite len bytes of data at off in bank b with value
BANK b PEEK addr Returns value at given address in bank b (address is from start of bank)
BANK b POKE addr, value Sets address in bank b to value (address is from start of bank)
IN port Returns current value at port
PEEK addr Returns value at given address
POKE addr, value Sets address to value
OUT port, value Sends value to port