Difference between revisions of "NextBASIC"

From SpecNext official Wiki
Jump to: navigation, search
(Created page with "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 optiona...")
 
(Graphics)
Line 41: Line 41:
 
! Command !! Effect
 
! Command !! Effect
 
|-
 
|-
| DEF FN func(param[,param..])=expr || Creates a user defined function based on a parameterised expression
+
| CIRCLE x,y,r || Draw circle centered at x, y with radius r
 
|-
 
|-
| FOR var = start TO end [STEP step]? || Starts FOR loop between given numeric values (with given step)
+
| DRAW [modifier|x,y].. || Draw line from plot cursor to given coordinate
 
|-
 
|-
| IF c THEN statements.. || Run statements only if expression c is true
+
| INK c || Set ink (foreground) color for print and graphics commands
 
|-
 
|-
| GO TO x || Jump execution to line X
+
| LAYER DIM left, top, right, bottom || Sets visible area for current layer
 
|-
 
|-
| GO SUB x || Jump execution to line X, storing current location on gosub stack
+
| PAPER c || Set paper (background) color for print and graphics commands
 
|-
 
|-
| NEXT var || Marks end of FOR loop regarding VAR
+
| PLOT [modifier|x,y].. || Plot listed points as single pixels on current layer
 
|-
 
|-
| RETURN || Restore execution location from gosub stack
+
| POINT x, y, var || Stores the color at point x, y in variable var
 +
|-
 +
| POINT x, y || Returns the color at point x, y
 
|}
 
|}
 +
 +
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 ==
 
== Memory and Port Access ==

Revision as of 19:30, 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
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
CIRCLE x,y,r Draw circle centered at x, y with radius r
x,y].. Draw line from plot cursor to given coordinate
INK c Set ink (foreground) color for print and graphics commands
LAYER DIM left, top, right, bottom Sets visible area for current layer
PAPER c Set paper (background) color for print and graphics commands
x,y].. Plot listed points as single pixels on current layer
POINT x, y, var Stores the color at point x, y in variable var
POINT x, y Returns the color at point x, y

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?
BANK b ERASE a, b, c
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