Skip to content

Latest commit

 

History

History
280 lines (277 loc) · 21.9 KB

README.md

File metadata and controls

280 lines (277 loc) · 21.9 KB

plusBASIC Quick Reference Guide

Literals

  • Numeric literals evaluate to floating point or integer numbers.
    • {+|-}{digit...|{digit}{.}{digit...}}{E{+|-}digit...} - A floating point decimal number.
    • {+|-}{digit...} - An integer decimal number.
    • $hexdigit... - An integer hexadecimal number.
    • 'character' - An integer number equal to the ASCII code of character.
  • String literals evaluate to floating point of integer values.
    • "{character...}" - A string containing the specified characters.
    • $"{hexdigit...}" - A string containing the characters specified by each two-digit hexadecimal number.
    • \"{{\}character}..." - A string containing C style escape codes.

Operators

  • Arithmetic operations evaluate performed using floating point math.
    • - expression - Negate expression
    • expression + expression - Add second expression to first expression.
    • expression - expression - Subtract second expression from first expression.
    • expression * expression - Multiply first expression by second expression.
    • expression / expression - Divide first expression by second expression.
    • expression ^ expression - Raise first expression to power second expression.
    • expression MOD expression - Calculate the remainder of the first expression divided by the second expression.
  • Relational operations return -1 if true, 0 if false.
    • expression > expression - True if first expression is greater than second expression.
    • expression = expression - True if first expression is equal second expression.
    • expression < expression - True if first expression is less than second expression.
    • expression >= expression - True if first expression is greater than or equal to second expression.
    • expression <= expression - True if first expression is less than or equal to second expression.
  • Logical operators perform the corresponding boolean operation on the bits of the each integer expression.
    • NOT integer - Sets resulting bit to 1 if the operand bit is 0.
    • integer AND integer - Sets resulting bit to 1 if both operand bits are 1.
    • integer OR integer - Sets the resulting bit to 1 if either operand bit is 1.
    • integer XOR integer - Sets resulting bit to 1 if one operand bits is 1, and the other is 0.
  • String operators create new temporary string.
    • string + string - Concatenates second string to the end of first string.
    • string %% (expression{,...}) - Perform string substitution.

Special characters

  • _label - Line label. Valid at the beginining of a line, or as the operand of a GOTO or GOSUB.
  • 'comment - Shortcut for REM. Valid at the beginning of a line, or after a statement terminating colon.

Statement and functions

  • ABS(expression) - Return absolute value of expression.
  • ARGS - Return number of RUN arguments
  • ARGS$(index) - Return RUN argument number index.
  • ASC(string) - Return ASCII value of the first character of string.
  • ASC$(hexstring) - Convert hex_string to an ASCII string.
  • ATN(float) - Return arctangent of argument.
  • CALL address {ARGS hl,de,bc,a} - Executes machine language routine at address, optionally passing arguments into the associated registers.
  • CALL MODULE - Proposed enhancement.
  • CD {dirname} - Display current path or change directory.
  • CD$ - Return current path.
  • CHR$(byte) - Convert ASCII value to string.
  • CIRCLE (x,y),radius{,{color}{,{start},{end}{,aspect}}} - Not implemented.
  • CLEAR {integer{,address}} - Clear all variables, optionally allocating string text space and top of BASIC RAM.
  • CLEAR BITMAP {fgcolor,bgcolor} - Clear bitmap screen
  • CLOAD {{?}filename}|*array - Load or verify program or load array data from cassette.
  • CLOSE - Not implemented.
  • CLS {fgcolor,bgcolor} - Clear the text screen.
  • COLOR fgcolor{,bgcolor} - Set or get bitmap default color(s).
  • COMPARE (array,array) - Compare the binary contents of two numeric arrays.
  • COMPARE ({@page,}address,{@page,}address,length) - Compare two blocks of memory.
  • COMPARE (filespec,filespec) - Not implemented.
  • CONT - Resume program execution after STOP, Ctrl-C/Escape, or error.
  • COPY - Copy text screen to serial printer.
  • COPY *array TO *array - Not implemented.
  • COPY {@page,}address,length TO {@page,}address {FAST} - Copy bytes from one section of memory to another.
  • COPY FILE filespec TO filespec - Copy file.
  • COS(float) - Return cosine of argument.
  • CSAVE filename|*array - Save program or array data to cassette.
  • DATA literal{,...} - Define data for READ statement.
  • DATE$ - Return the current date.
  • DATETIME$ - Return the current date and time.
  • DEC(hexstring) - Convert hexadecimal string to integer.
  • DEEK({@page,}address) - Read integer from memory.
  • DEF ATTRLIST strvar=attr,... - Create a string list of sprite and/or tile attributes.
  • DEF BYTELIST strvar=byte,... - Create a string list of bytes.
  • DEF FN var(var) = expression - Define user-defined function.
  • DEF INTLIST strvar=integer,... - Create a string list of integers.
  • DEF PALETTELIST strvar=palette,... - Create a string list of palette numbers.
  • DEF RGBLIST strvar=r,g,b;... - Create a string list of RGB values.
  • DEF TILELIST strvar=tileno,... - Create a string list of palatte indexes.
  • DEF USR=address - Not implemented.
  • DIM array(dim{,...}){,...} - Create and allocates one or more arrays.
  • DIR {dirspec} - Display disk directory.
  • DOKE {@page,}address,integer - Write integer to memory.
  • DRAW command_string - Not implemented.
  • DRAW TEXT (col,row)),string - Not implemented.
  • EDIT {lineref} - Not implemented.
  • END - Terminate program execution.
  • ERASE *array{,*array...} - Delete arrays.
  • EVAL(string) - Evaluate expression in string.
  • EXP(float) - Return argument to the power of mathematical constant e.
  • FILEDIR$(filespec) - Extract path from filespec.
  • FILEEXT$(filespec) - Extract extension from filespec.
  • FILL {@page},address,oount,byte - Fill block of memory with byte.
  • FILL {@page},address,oount,WORD integer - Fill block of memory with integer.
  • FILL BITMAP {BYTE byte} {COLOR fgcolor, bgcolor} - Fill bitmap and/or colormap with byte and/or color(s).
  • FILL SCREEN {(x,y_)-(x,y)} {CHR character} {COLOR fgcolor, bgcolor} - Fill screen with character and/or colors.
  • FILL TILEMAP {(x,y_)-(x,y)} TILE tileno{ ATTR attrs}{ PALETTE palette} - Fill tilemap with specified tile, attributes and palette.
  • FOR var=expression TO expression {STEP expression] - Initiate a FOR loop.
  • FRE(float|string) - Return amount of unused variable and array or string space (after forcing garage collection).
  • GET ARGS var{,...} - Read arguments from argument list after GOSUB.
  • GET SCREEN (x,y_)-(x,y) {CHR|ATTR} *array|^strvar - Copy text screen clip to array or string variable.
  • GET TILEMAP (x,y_)-(x,y) *array|^strvar - Copy tilemap clip to array or string variable.
  • GETCHRSET - Return character set currently in use.
  • GETCOLOR - Return screen printing colors.
  • GETKEY - Wait for key an return ASCII code.
  • GETKEY$ - Wait for key and return as string.
  • GETPALETTE$(palette) - Return palette contents.
  • GETSPRITE$(spritedef) - Return attributes of each spritle in the spritedef.
  • GETTILE$(tileno) - Return tile pixels.
  • GOSUB lineref{:ARGS expression{,...} {RETURN var{,...}} - Branch to subroutine with optional call and return arguments.
  • GOTO lineref - Branch to line specified by line number or label.
  • HEX$(number) - Convert byte or integer into hexadecimal string.
  • HEX$(string) - Convert ASCII string into hexadecimal string.
  • IF expression GOTO linefref|THEN lineno|statement - Branch to line or execute statements if expression evaluates to true.
  • IN(port) - Read a Z80 I/O port.
  • INDEX(*array,string) - Search for string in element of array
  • INMEM({@page,}address,string) - Search for string in memory.
  • INT(expression) - Return expression rounded down to nearest integer.
  • INKEY - Return ASCII code of most recently pressed key.
  • INKEY$ - Return most recently pressed key as string.
  • INPUT {stringliteral;}var{,...} - Prompt for keyboard input and assigns entries to variables.
  • INSTR({offset,}haystack,_needle) - Search for string needle in string haystack.
  • JOY(_stick) - Read one or both game controllers.
  • KEY({keycode|string}) - Check if key is currently pressed.
  • LEFT$(string,len) - Return the first up to len characters of string.
  • LEN(string) - Return length of string.
  • {LET} var=expression - Define and assigns value to variable.
  • LINE {(x1,y1)}-(x2,y2){,{color}{,B{F}}}} - Not implemented.
  • LINEH x,y1,y2 - Not implemented.
  • LINEV x1,x2,y - Not implemented.
  • LIST {lineref} - Display program lines starting at beginning of program or specified line.
  • LLIST {lineref} - Outputs program lines to printer starting at beginning of program or specified line.
  • LOAD filespec - Load BASIC program into memory.
  • LOAD filespec,{@page,}address - Load binary file into memory.
  • LOAD filespec,*array - Load binary file data into numeric or string array.
  • LOAD filespec,*array,ASC - Load multi-line ASCII file into string array.
  • LOAD filespec,^string - Load up to 255 characters of file into string variable.
  • LOAD BITMAP filespec - Load bitmap screen file into Video RAM.
  • LOAD CHRSET filespec - Load character set into alternate character buffer.
  • LOAD DIR filespec,*array - Load disk directory into string array.
  • LOAD FNKEYS filespec - Load function key definitions from file.
  • LOAD MODULE - Proposed enhancement.
  • LOAD PALETTE p,filespec - Load file data ino palette.
  • LOAD PT3 filespec - Load PT3 track into PT player buffer.
  • LOAD SCREEN filespec - Load text screen from file.
  • LOAD TILEMAP - Not implemented.
  • LOCATE x,y - Move text cursor to specified position.
  • LOG(float) - Return natural logarithm of argument.
  • LOOP PT3 {filespec} - Play specified or previously loaded PT3 track repeatedly.
  • LPOS(expression_) - Return current column position of printer.
  • LPRINT TAB(integer)|SPC(integer)|expression|;|,{...} - Output data to printer.
  • MENU - Not implemented.
  • MID$(string,start{,len}) - Return first up to len or all remaining characters starting at character start of string.
  • MID$(strvar,start_{,len})=string - Not implemented.
  • MKDIR dirname - Create directory.
  • MOUSEB - Return mouse button state
  • MOUSEW - Return mouse wheel delta
  • MOUSEX - Return mouse x-position
  • MOUSEY - Return mouse y-position
  • NEXT {var,...} - Terminate one or more FOR loops.
  • NEW - Delete program and clears all variables.
  • ON integer GOSUB lineref,... - GOSUB one of several line numbers based on expression.
  • ON integer GOTO lineref,... - GOTO one of several line numbers based on expression.
  • ON ERROR GOTO lineref - Enable or disable error trapping.
  • OPEN - Not implemented.
  • OUT port,byte - Write to a Z80 port.
  • PAD$(string,length{,char}) - Pad string on left or right.
  • PAUSE - Halt program execution until key is pressed.
  • PAUSE jiffies - Not implemented.
  • PAUSE PT3 - Pause currently playing PT3 track.
  • PEEK({@page,}address) - Read byte from memory.
  • PEEK$({@page,}address,length) - Read string from memory.
  • PEEKCOLOR(address) - Read byte from color RAM.
  • PEEKCOLOR$(address,length) - Read string from color RAM.
  • PEEKSCREEN(address) - Read byte from screen RAM.
  • PEEKSCREEN$(address,length) - Read string from screen RAM.
  • PLAY PT3 {filespec} - Play specified or previously loaded PT3 track.
  • PLAY SAMPLE @page,address - Play digital sample from previously loaded file.
  • POINT(x,y) - Return status of bloxel or pixel.
  • POKE {@page,}address,byte - Write byte to memory.
  • POKE {@page,}address,string - Write string to memory.
  • POKE COLOR address,byte - Write byte to color RAM.
  • POKE COLOR address,string - Write string to color RAM.
  • POKE SCREEN address,byte - Write byte to screen RAM.
  • POKE SCREEN address,string - Write string to screen RAM.
  • POS(expression_) - Return current cursor column.
  • POSX - Return 1bpp bitmap last x-position.
  • POSY - Return 1bpp bitmap last y-position.
  • PRESET (x,y) - Erase bloxel or pixel.
  • PRINT TAB(integer)|SPC(integer)|expression|;|,{...} - Display data on screen.
  • PSG register,byte{,...} - Write bytes to PSG register
  • PSG register,byte{;...} - Not implemented
  • PSET (x,y) - Draw bloxel or pixel.
  • PT3LOOP - Return -1 if PT3 is set to loop, else 0.
  • PT3STATUS - Return -1 if PT3 is playing, else 0.
  • PUT SCREEN (x,y_) {CHR|ATTR} *array|^strvar - Copy clip from array or string variable to text screen.
  • PUT TILEMAP (x,y_) *array|^strvar - Copy clip from array or string variable to tilemap.
  • READ var{,...} - Read values from data statements into variables.
  • REM text - Denotes comment.
  • RENAME filespec TO filespec - Rename file or directory
  • RESUME lineref - Clear error condition and continues program execution at specified line
  • RESUME PT3 - Resume playing paused PT3 track.
  • RESET *array - Set all array elements to 0 or empty string and collect garbage if string array.
  • RESET PALETTE palette - Reset palette to default RGB values.
  • RESET SCREEN - Reset current text screen to default settings.
  • RESTORE {lineref} - Reset READ/DATA pointer to beginning of program or specified line.
  • RESTORE BITMAP|TILEMAP - Not implemented.
  • RESTORE SCREEN - Copy respective screen buffer to current text screen..
  • RETURN {expression{,...}} - Resume program execution after GOSUB, optionally returning results.
  • RGB(r,g,b) - Not implemented.
  • RGB$(r,g,b) - Return string representing a single palette entry.
  • RIGHT$(string,len) - Return the last up to byte characters of string.
  • RND(integer) - Return new or previous psuedo-random number or seeds the random number generator.
  • RUN {lineref} - Start program execution at first or specified line.
  • RUN filespec - Load and runs specified program, cartridge image, or FPGA core.
  • SAVE filespec{,ASC|CAQ|TOK} - Save BASIC program to CAQ or ASCII or raw tokenized file.
  • SAVE filespec,{@page,}address,length - Save memory to binary file.
  • SAVE filespec,*array - Save numeric or string array data to file.
  • SAVE BITMAP filespec - Save bitmap screen data from Video RAM to file.
  • SAVE FNKEYS filespec - Save function key definitions to file.
  • SAVE PALETTE p,filespec - Save palette contents to file.
  • SAVE SCREEN filespec - Save text screen to file.
  • SAVE TILEMAP - Not implemented.
  • SCREEN {text},{graphics},{sprites},{priority},{remap} - Set screen mode.
  • SET COLOR fgcolor,bgcolor - Enable color printing mode.
  • SET COLOR OFF - Disable color printing mode.
  • SET FAST ON|OFF - Enable or disables turbo mode.
  • SET FNKEY key TO string - Set auto-typed text when function key is pressed.
  • SET KEY mode - Set alternate keyboard port mode.
  • SET PALETTE palette{,index} TO rgblist - Set palette entries.
  • SET PT3 LOOP {ON|OFF} - Set loop status of active or paused PT3 track.
  • SET SAVE ASC ON|OFF - Enable or disable forced saving of BASIC programs in ASCII format.
  • SET SPRITE spritedef {ON|OFF} {POS x,y} {TILE tilelist} {PALETTE palettelist} {ATTR attrlist} - Set sprite properties.
  • SET SPRITE spritedef TILECLIP *array|^strvar - Set sprite to tile indexes and properties in tilemap clip.
  • SET SPRITE spritedef TO proplist - Set sprite properties from combined properties list.
  • SET SPRITE * OFF|CLEAR - Disable or clears all sprites.
  • SET TILE tileno TO tiledata - Write tile definition Video RAM.
  • SET TILE tileno TO CHR ascii_code, fg_color, bg_color - Convert character definition to tile data and write to Video RAM.
  • SET TILEMAP (x,y) TO TILE tileno {ATTR attrs} {PALETTE palette} - Set tilemap cell to tile index, attributes, and palette.
  • SET TILEMAP (x,y) TO integer - Set tilemap cell to integer represeting combined tile index, attributes, and palette.
  • SET TILEMAP OFFSET x,y - Scroll tilemap to specified position.
  • SGN(expression) - Return signum of expression.
  • SIN(float) - Return sine of argument.
  • SOUND (duration,frequency) - Generate a tone through the television speaker.
  • SPLIT string INTO *array$ DEL delimiter - Split delimited string into string array elements
  • SQR(_float) - Return square root of argument.
  • STASH BITMAP|TILEMAP - Not implemented.
  • STASH SCREEN - Copy current text screen to respective screen buffer.
  • STOP - Interrupt program execution.
  • STOP PT3 - Stop currently playing PT3 track.
  • STR$(float) - Convert floating point number to ASCII string.
  • STRING$(length{,byte|string}) - Create string of repeated character.
  • STRPTR(strvar) - Return address of text for string variable.
  • SWAP BITMAP|TILEMAP - Not implemented.
  • SWAP SCREEN - Swap current text screen with respective screen buffer.
  • SWAP VARS var,var - Not implemented.
  • TAN(float) - Return tangent of argument.
  • TILEMAP(x,y) - Return tile index and properties in tile cell.
  • TILEMAPX - Return X-offset of tilemap.
  • TILEMAPY - Return X-offset of tilemap.
  • TIME$ - Return the current time.
  • TIMER - Return timer count.
  • TIMER = expression - Set and start jiffy timer.
  • TRIM$(string{,string}) - Remove characters from both ends of string.
  • TRIMDIR$(filespec) - Remove path from filespec.
  • TRIMEXT$(filespec) - Remove extension from filespec.
  • TRIML$(string{,string}) - Remove characters from left end of string.
  • TRIMR$(string{,string}) - Remove characters from right end of string.
  • TRON - Enable line tracing.
  • TROFF - Disable line tracing.
  • USE CHRSET 0|1|filespec - Copy specified character set to character RAM.
  • USE SCREEN {@page,}text,graphics - Not implemented.
  • USR(expression) - Call user-defined machine language routine passing argument and returning result.
  • VAL(float) - Convert ASCII string to floating point number.
  • VARPTR(var{$}|*array{$}) - Return address of variable, array element, or array
  • VER(expression) - Return System or plusBASIC version as integer.
  • VER$(expression) - Return System or plusBASIC version as printable string.
  • WRITE - Not implemented.