From d7f3cd245475c0a3573a488114f3534cf23a34d3 Mon Sep 17 00:00:00 2001 From: geneb Date: Sat, 17 Jan 2026 10:00:16 -0800 Subject: [PATCH 01/13] WIP: Completed to the IF...THEN statement. --- X16 Reference - 04 - BASIC.md | 1034 ++++++++++++++++++++++++++------- 1 file changed, 817 insertions(+), 217 deletions(-) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index 89f810e..baa8ca3 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -1,3 +1,31 @@ + + + # Chapter 4: BASIC Programming @@ -11,154 +39,154 @@ for GitHub's Markdown flavor. Do not remove! ## Table of BASIC statements and functions | Keyword | Type | Summary | Origin | -|-|-|-|-| -| `ABS` | function | Returns absolute value of a number | C64 | -| `AND` | operator | Returns boolean "AND" or bitwise intersection | C64 | -| [`ASC`](#asc) | function | Returns numeric PETSCII value from string | C64 | -| `ATN` | function | Returns arctangent of a number | C64 | -| [`BANK`](#bank) | command | Sets the RAM and ROM banks to use for PEEK, POKE, and SYS | C128 | -| [`BASLOAD`](#bank) | command | Load and tokenize a BASLOAD (.basl) text file | X16 | -| [`BIN$`](#bin) | function | Converts numeric to a binary string | X16 | -| [`BINPUT#`](#binput) | command | Reads a fixed-length block of data from an open file | X16 | -| [`BLOAD`](#bload) | command | Loads a headerless binary file from disk to a memory address | X16 | -| [`BOOT`](#boot) | command | Loads and runs `AUTOBOOT.X16` | X16 | -| [`BSAVE`](#bsave) | command | Saves a headerless copy of a range of memory to a file | X16 | -| `BVERIFY` | command | Verifies that a file on disk matches RAM contents | X16 | -| [`BVLOAD`](#bvload) | command | Loads a headerless binary file from disk to VRAM | X16 | -| [`CHAR`](#char) | command | Draws a text string in graphics mode | X16 | -| `CHR$` | function | Returns PETSCII character from numeric value | C64 | -| [`CLOSE`](#close) | command | Closes a logical file number | C64 | -| `CLR` | command | Clears BASIC variable state | C64 | -| [`CLS`](#cls) | command | Clears the screen | X16 | -| `CMD` | command | Redirects output to non-screen device | C64 | -| `CONT` | command | Resumes execution of a BASIC program | C64 | -| [`COLOR`](#color) | command | Sets text fg and bg color | X16 | -| `COS` | function | Returns cosine of an angle in radians | C64 | -| `DA$` | variable | Returns the date in YYYYMMDD format from the system clock | X16 | -| `DATA` | command | Declares one or more constants | C64 | -| `DEF` | command | Defines a function for use later in BASIC | C64 | -| `DIM` | command | Allocates storage for an array | C64 | -| [`DOS`](#dos) | command | Disk and SD card directory operations | X16 | -| [`EDIT`](#edit) | command | Open the built-in text editor | X16 | -| `END` | command | Terminate program execution and return to `READY.` | C64 | -| [`EXEC`](#exec) | command | Play back a script from RAM into the BASIC editor | X16 | -| `EXP` | function | Returns the inverse natural log of a number | C64 | -| [`FMCHORD`](#fmchord) | command | Start or stop simultaneous notes on YM2151 | X16 | -| [`FMDRUM`](#fmdrum) | command | Plays a drum sound on YM2151 | X16 | -| [`FMFREQ`](#fmfreq) | command | Plays a frequency in Hz on YM2151 | X16 | -| [`FMINIT`](#fminit) | command | Stops sound and reinitializes YM2151 | X16 | -| [`FMINST`](#fminst) | command | Loads a patch preset into a YM2151 channel | X16 | -| [`FMNOTE`](#fmnote) | command | Plays a musical note on YM2151 | X16 | -| [`FMPAN`](#fmpan) | command | Sets stereo panning on YM2151 | X16 | -| [`FMPLAY`](#fmplay) | command | Plays a series of notes on YM2151 | X16 | -| [`FMPOKE`](#fmpoke) | command | Writes a value into a YM2151 register | X16 | -| [`FMVIB`](#fmvib) | command | Controls vibrato and tremolo on YM2151 | X16 | -| [`FMVOL`](#fmvol) | command | Sets channel volume on YM2151 | X16 | -| `FN` | function | Calls a previously defined function | C64 | -| `FOR` | command | Declares the start of a loop construct | C64 | -| [`FRAME`](#frame) | command | Draws an unfilled rectangle in graphics mode | X16 | -| `FRE` | function | Returns the number of unused BASIC bytes free | C64 | -| `GET` | command | Polls the keyboard cache for a single keystroke | C64 | -| `GET#` | command | Polls an open logical file for a single character | C64 | -| `GOSUB` | command | Jumps to a BASIC subroutine | C64 | -| `GOTO` | command | Branches immediately to a line number | C64 | -| [`HELP`](#help) | command | Displays a brief summary of online help resources | X16 | -| [`HEX$`](#hex) | function | Converts numeric to a hexadecimal string | X16 | -| [`I2CPEEK`](#i2cpeek) | function | Reads a byte from a device on the I²C bus | X16 | -| [`I2CPOKE`](#i2cpoke) | command | Writes a byte to a device on the I²C bus | X16 | -| `IF` | command | Tests a boolean condition and branches on result | C64 | -| `INPUT` | command | Reads a line or values from the keyboard | C64 | -| `INPUT#` | command | Reads lines or values from a logical file | C64 | -| `INT` | function | Discards the fractional part of a number | C64 | -| [`JOY`](#joy) | function | Reads gamepad button state | X16 | -| [`KEYMAP`](#keymap) | command | Changes the keyboard layout | X16 | -| `LEFT$` | function | Returns a substring starting from the beginning of a string | C64 | -| `LEN` | function | Returns the length of a string | C64 | -| `LET` | command | Explicitly declares a variable | C64 | -| [`LINE`](#line) | command | Draws a line in graphics mode | X16 | -| [`LINPUT`](#linput) | command | Reads a line from the keyboard | X16 | -| [`LINPUT#`](#linput-1) | command | Reads a line or other delimited data from an open file | X16 | -| [`LIST`](#list) | command | Outputs the program listing to the screen | C64 | -| `LOAD` | command | Loads a program from disk into memory | C64 | -| [`LOCATE`](#locate) | command | Moves the text cursor to new location | X16 | -| `LOG` | function | Returns the natural logarithm of a number | C64 | -| [`MENU`](#menu) | command | Invokes the Commander X16 utility menu | X16 | -| `MID$` | function | Returns a substring from the middle of a string | C64 | -| [`MOD`](#mod) | function | Returns the truncated remainder of a division | X16 | -| [`MON`](#mon) | command | Enters the machine language monitor | X16 | -| [`MOUSE`](#mouse) | command | Hides or shows mouse pointer | X16 | -| [`MOVSPR`](#movspr) | command | Set the X/Y position of a sprite | X16 | +| - | - | - | - | +| [`ABS`](#abs) | Function | Returns absolute value of a number | C64 | +| [`AND`](#and) | Operator | Returns boolean "AND" or bitwise intersection | C64 | +| [`ASC`](#asc) | Function | Returns numeric PETSCII value from string | C64 | +| [`ATN`](#atn) | Function | Returns arctangent of a number | C64 | +| [`BANK`](#bank) | Command | Sets the RAM and ROM banks to use for PEEK, POKE, and SYS | C128 | +| [`BASLOAD`](#bank) | Command | Load and tokenize a BASLOAD (.basl) text file | X16 | +| [`BIN$`](#bin) | Function | Converts numeric to a binary string | X16 | +| [`BINPUT#`](#binput) | Command | Reads a fixed-length block of data from an open file | X16 | +| [`BLOAD`](#bload) | Command | Loads a headerless binary file from disk to a memory address | X16 | +| [`BOOT`](#boot) | Command | Loads and runs `AUTOBOOT.X16` | X16 | +| [`BSAVE`](#bsave) | Command | Saves a headerless copy of a range of memory to a file | X16 | +| [`BVERIFY`](#bverify) | Command | Verifies that a file on disk matches RAM contents | X16 | +| [`BVLOAD`](#bvload) | Command | Loads a headerless binary file from disk to VRAM | X16 | +| [`CHAR`](#char) | Command | Draws a text string in graphics mode | X16 | +| [`CHR$`](#chr$) | Function | Returns PETSCII character from numeric value | C64 | +| [`CLOSE`](#close) | I/O Statement | Closes a logical file number | C64 | +| [`CLR`](#clr) | Command | Clears BASIC variable state | C64 | +| [`CLS`](#cls) | Command | Clears the screen | X16 | +| [`CMD`](#cmd) | I/O Statement | Redirects output to non-screen device | C64 | +| [`COLOR`](#color) | Command | Sets text fg and bg color | X16 | +| [`CONT`](#cont) | Command | Resumes execution of a BASIC program | C64 | +| [`COS`](#cos) | Function | Returns cosine of an angle in radians | C64 | +| [`DA$`](#da$) | String Function | Returns the date in YYYYMMDD format from the system clock | X16 | +| [`DATA`](#data) | Statement | Declares one or more constants | C64 | +| [`DEF FN`](#def-fn) | Statement | Defines a function for use later in BASIC | C64 | +| [`DIM`](#dim) | Statement | Allocates storage for an array | C64 | +| [`DOS`](#dos) | Command | Disk and SD card directory operations | X16 | +| [`EDIT`](#edit) | Command | Open the built-in text editor | X16 | +| [`END`](#end) | Statement | Terminate program execution and return to `READY.` | C64 | +| [`EXEC`](#exec) | Command | Play back a script from RAM into the BASIC editor | X16 | +| [`EXP`](#exp) | Function | Returns the inverse natural log of a number | C64 | +| [`FMCHORD`](#fmchord) | Command | Start or stop simultaneous notes on YM2151 | X16 | +| [`FMDRUM`](#fmdrum) | Command | Plays a drum sound on YM2151 | X16 | +| [`FMFREQ`](#fmfreq) | Command | Plays a frequency in Hz on YM2151 | X16 | +| [`FMINIT`](#fminit) | Command | Stops sound and reinitializes YM2151 | X16 | +| [`FMINST`](#fminst) | Command | Loads a patch preset into a YM2151 channel | X16 | +| [`FMNOTE`](#fmnote) | Command | Plays a musical note on YM2151 | X16 | +| [`FMPAN`](#fmpan) | Command | Sets stereo panning on YM2151 | X16 | +| [`FMPLAY`](#fmplay) | Command | Plays a series of notes on YM2151 | X16 | +| [`FMPOKE`](#fmpoke) | Command | Writes a value into a YM2151 register | X16 | +| [`FMVIB`](#fmvib) | Command | Controls vibrato and tremolo on YM2151 | X16 | +| [`FMVOL`](#fmvol) | Command | Sets channel volume on YM2151 | X16 | +| [`FN`](#fn) | Function | Calls a previously defined function | C64 | +| [`FOR-TO-STEP`](#for-to-step) | Statement | Declares the start of a loop construct | C64 | +| [`FRAME`](#frame) | Command | Draws an unfilled rectangle in graphics mode | X16 | +| [`FRE`](#fre) | Function | Returns the number of unused BASIC bytes free | C64 | +| [`GET`](#get) | Statement | Polls the keyboard cache for a single keystroke | C64 | +| [`GET#`](#get) | I/O Statement | Polls an open logical file for a single character | C64 | +| [`GOSUB`](#gosub) | Statement | Jumps to a BASIC subroutine | C64 | +| [`GOTO`](#goto) | Statement | Branches immediately to a line number | C64 | +| [`HELP`](#help) | Command | Displays a brief summary of online help resources | X16 | +| [`HEX$`](#hex) | Function | Converts numeric to a hexadecimal string | X16 | +| [`I2CPEEK`](#i2cpeek) | Function | Reads a byte from a device on the I²C bus | X16 | +| [`I2CPOKE`](#i2cpoke) | Command | Writes a byte to a device on the I²C bus | X16 | +| [`IF-THEN`](#if-then) | Statement | Tests a boolean condition and branches on result | C64 | +| `INPUT` | Command | Reads a line or values from the keyboard | C64 | +| `INPUT#` | Command | Reads lines or values from a logical file | C64 | +| `INT` | Function | Discards the fractional part of a number | C64 | +| [`JOY`](#joy) | Function | Reads gamepad button state | X16 | +| [`KEYMAP`](#keymap) | Command | Changes the keyboard layout | X16 | +| `LEFT$` | Function | Returns a substring starting from the beginning of a string | C64 | +| `LEN` | Function | Returns the length of a string | C64 | +| `LET` | Command | Explicitly declares a variable | C64 | +| [`LINE`](#line) | Command | Draws a line in graphics mode | X16 | +| [`LINPUT`](#linput) | Command | Reads a line from the keyboard | X16 | +| [`LINPUT#`](#linput-1) | Command | Reads a line or other delimited data from an open file | X16 | +| [`LIST`](#list) | Command | Outputs the program listing to the screen | C64 | +| `LOAD` | Command | Loads a program from disk into memory | C64 | +| [`LOCATE`](#locate) | Command | Moves the text cursor to new location | X16 | +| `LOG` | Function | Returns the natural logarithm of a number | C64 | +| [`MENU`](#menu) | Command | Invokes the Commander X16 utility menu | X16 | +| `MID$` | Function | Returns a substring from the middle of a string | C64 | +| [`MOD`](#mod) | Function | Returns the truncated remainder of a division | X16 | +| [`MON`](#mon) | Command | Enters the machine language monitor | X16 | +| [`MOUSE`](#mouse) | Command | Hides or shows mouse pointer | X16 | +| [`MOVSPR`](#movspr) | Command | Set the X/Y position of a sprite | X16 | | [`MX/MY/MB`](#mxmymb) | variable | Reads the mouse position and button state | X16 | | [`MWHEEL`](#mwheel) | variable | Reads the mouse wheel movement | X16 | -| `NEW` | command | Resets the state of BASIC and clears program memory | C64 | -| `NEXT` | command | Declares the end of a loop construct | C64 | -| `NOT` | operator | Bitwise or boolean inverse | C64 | -| [`OLD`](#old) | command | Undoes a NEW command or warm reset | X16 | -| `ON` | command | A GOTO/GOSUB table based on a variable value | C64 | -| `OPEN` | command | Opens a logical file to disk or other device | C64 | -| `OR` | operator | Bitwise or boolean "OR" | C64 | -| [`OVAL`](#oval) | command | Draws a filled oval in graphics mode | X16 | -| [`PEEK`](#peek) | function | Returns a value from a memory address | C64 | -| `π` | function | Returns the constant for the value of pi | C64 | -| [`POINTER`](#pointer) | function | Returns the address of a BASIC variable | C128 | -| [`POKE`](#poke) | command | Assigns a value to a memory address | C64 | -| `POS` | function | Returns the column position of the text cursor | C64 | -| [`POWEROFF`](#poweroff) | command | Immediately powers down the Commander X16 | X16 | -| `PRINT` | command | Prints data to the screen or other output | C64 | -| `PRINT#` | command | Prints data to an open logical file | C64 | -| [`PSET`](#pset) | command | Changes a pixel's color in graphics mode | X16 | -| [`PSGCHORD`](#psgchord) | command | Starts or stops simultaneous notes on VERA PSG | X16 | -| [`PSGFREQ`](#psgfreq) | command | Plays a frequency in Hz on VERA PSG | X16 | -| [`PSGINIT`](#psginit) | command | Stops sound and reinitializes VERA PSG | X16 | -| [`PSGNOTE`](#psgnote) | command | Plays a musical note on VERA PSG | X16 | -| [`PSGPAN`](#psgpan) | command | Sets stereo panning on VERA PSG | X16 | -| [`PSGPLAY`](#psgplay) | command | Plays a series of notes on VERA PSG | X16 | -| [`PSGVOL`](#psgvol) | command | Sets voice volume on VERA PSG | X16 | -| [`PSGWAV`](#psgwav) | command | Sets waveform on VERA PSG | X16 | -| `READ` | command | Assigns the next `DATA` constant to one or more variables | C64 | -| [`REBOOT`](#reboot) | command | Performs a warm reboot of the system | X16 | -| [`RECT`](#rect) | command | Draws a filled rectangle in graphics mode | X16 | -| `REM` | command | Declares a comment | C64 | -| [`REN`](#ren) | command | Renumbers a BASIC program | X16 | -| [`RESET`](#reset) | command | Performs a hard reset of the system | X16 | -| [`RESTORE`](#restore) | command | Resets the `READ` pointer to a `DATA` constant | C64 | -| `RETURN` | command | Returns from a subroutine to the statement following a GOSUB | C64 | -| `RIGHT$` | function | Returns a substring from the end of a string | C64 | -| [`RING`](#ring) | command | Draws an oval outline in graphics mode | X16 | -| `RND` | function | Returns a floating point number 0 <= n < 1 | C64 | -| [`RPT$`](#rpt) | function | Returns a string of repeated characters | X16 | -| `RUN` | command | Clears the variable state and starts a BASIC program | C64 | -| [`SAVE`](#save) | command | Saves a BASIC program from memory to disk | C64 | -| [`SCREEN`](#screen) | command | Selects a text or graphics mode | X16 | -| `SGN` | function | Returns the sign of a numeric value | C64 | -| `SIN` | function | Returns the sine of an angle in radians | C64 | -| [`SLEEP`](#sleep) | command | Introduces a delay in program execution | X16 | -| `SPC` | function | Returns a string with a set number of spaces | C64 | -| [`SPRITE`](#sprite) | command | Sets attributes for a sprite including visibility | X16 | -| [`SPRMEM`](#sprmem) | command | Set the VRAM address for a sprite's visual data | X16 | -| `SQR` | function | Returns the square root of a numeric value | C64 | +| `NEW` | Command | Resets the state of BASIC and clears program memory | C64 | +| `NEXT` | Command | Declares the end of a loop construct | C64 | +| `NOT` | Operator | Bitwise or boolean inverse | C64 | +| [`OLD`](#old) | Command | Undoes a NEW command or warm reset | X16 | +| `ON` | Command | A GOTO/GOSUB table based on a variable value | C64 | +| `OPEN` | Command | Opens a logical file to disk or other device | C64 | +| `OR` | Operator | Bitwise or boolean "OR" | C64 | +| [`OVAL`](#oval) | Command | Draws a filled oval in graphics mode | X16 | +| [`PEEK`](#peek) | Function | Returns a value from a memory address | C64 | +| `π` | Function | Returns the constant for the value of pi | C64 | +| [`POINTER`](#pointer) | Function | Returns the address of a BASIC variable | C128 | +| [`POKE`](#poke) | Command | Assigns a value to a memory address | C64 | +| `POS` | Function | Returns the column position of the text cursor | C64 | +| [`POWEROFF`](#poweroff) | Command | Immediately powers down the Commander X16 | X16 | +| `PRINT` | Command | Prints data to the screen or other output | C64 | +| `PRINT#` | Command | Prints data to an open logical file | C64 | +| [`PSET`](#pset) | Command | Changes a pixel's color in graphics mode | X16 | +| [`PSGCHORD`](#psgchord) | Command | Starts or stops simultaneous notes on VERA PSG | X16 | +| [`PSGFREQ`](#psgfreq) | Command | Plays a frequency in Hz on VERA PSG | X16 | +| [`PSGINIT`](#psginit) | Command | Stops sound and reinitializes VERA PSG | X16 | +| [`PSGNOTE`](#psgnote) | Command | Plays a musical note on VERA PSG | X16 | +| [`PSGPAN`](#psgpan) | Command | Sets stereo panning on VERA PSG | X16 | +| [`PSGPLAY`](#psgplay) | Command | Plays a series of notes on VERA PSG | X16 | +| [`PSGVOL`](#psgvol) | Command | Sets voice volume on VERA PSG | X16 | +| [`PSGWAV`](#psgwav) | Command | Sets waveform on VERA PSG | X16 | +| `READ` | Command | Assigns the next `DATA` constant to one or more variables | C64 | +| [`REBOOT`](#reboot) | Command | Performs a warm reboot of the system | X16 | +| [`RECT`](#rect) | Command | Draws a filled rectangle in graphics mode | X16 | +| `REM` | Command | Declares a comment | C64 | +| [`REN`](#ren) | Command | Renumbers a BASIC program | X16 | +| [`RESET`](#reset) | Command | Performs a hard reset of the system | X16 | +| [`RESTORE`](#restore) | Command | Resets the `READ` pointer to a `DATA` constant | C64 | +| `RETURN` | Command | Returns from a subroutine to the statement following a GOSUB | C64 | +| `RIGHT$` | Function | Returns a substring from the end of a string | C64 | +| [`RING`](#ring) | Command | Draws an oval outline in graphics mode | X16 | +| `RND` | Function | Returns a floating point number 0 <= n < 1 | C64 | +| [`RPT$`](#rpt) | Function | Returns a string of repeated characters | X16 | +| `RUN` | Command | Clears the variable state and starts a BASIC program | C64 | +| [`SAVE`](#save) | Command | Saves a BASIC program from memory to disk | C64 | +| [`SCREEN`](#screen) | Command | Selects a text or graphics mode | X16 | +| `SGN` | Function | Returns the sign of a numeric value | C64 | +| `SIN` | Function | Returns the sine of an angle in radians | C64 | +| [`SLEEP`](#sleep) | Command | Introduces a delay in program execution | X16 | +| `SPC` | Function | Returns a string with a set number of spaces | C64 | +| [`SPRITE`](#sprite) | Command | Sets attributes for a sprite including visibility | X16 | +| [`SPRMEM`](#sprmem) | Command | Set the VRAM address for a sprite's visual data | X16 | +| `SQR` | Function | Returns the square root of a numeric value | C64 | | `ST` | variable | Returns the status of certain DOS/peripheral operations | C64 | | `STEP` | keyword | Used in a `FOR` declaration to declare the iterator step | C64 | -| `STOP` | command | Breaks out of a BASIC program | C64 | -| `STR$` | function | Converts a numeric value to a string | C64 | -| [`STRPTR`](#strptr) | function | Returns the address of a BASIC string | X16 | -| [`SYS`](#sys) | command | Transfers control to machine language at a memory address | C64 | -| `TAB` | function | Returns a string with spaces used for column alignment | C64 | -| `TAN` | function | Return the tangent for an angle in radians | C64 | -| [`TATTR`](#tattr) | function | Returns a tile attribute from the tile/text layer | X16 | -| [`TDATA`](#tdata) | function | Returns a tile from the tile/text layer | X16 | +| `STOP` | Command | Breaks out of a BASIC program | C64 | +| `STR$` | Function | Converts a numeric value to a string | C64 | +| [`STRPTR`](#strptr) | Function | Returns the address of a BASIC string | X16 | +| [`SYS`](#sys) | Command | Transfers control to machine language at a memory address | C64 | +| `TAB` | Function | Returns a string with spaces used for column alignment | C64 | +| `TAN` | Function | Return the tangent for an angle in radians | C64 | +| [`TATTR`](#tattr) | Function | Returns a tile attribute from the tile/text layer | X16 | +| [`TDATA`](#tdata) | Function | Returns a tile from the tile/text layer | X16 | | `THEN` | keyword | Control structure as part of an `IF` statement | C64 | | `TI` | variable | Returns the jiffy timer value | C64 | | `TI$` | variable | Returns the time HHMMSS from the system clock | C64 | -| [`TILE`](#tile) | command | Changes a tile or character on the tile/text layer | X16 | +| [`TILE`](#tile) | Command | Changes a tile or character on the tile/text layer | X16 | | `TO` | keyword | Part of the `FOR` loop declaration syntax | C64 | -| `USR` | function | Call a user-defined function in machine language | C64 | -| `VAL` | function | Parse a string to return a numeric value | C64 | -| `VERIFY` | command | Verify that a BASIC program was written to disk correctly | C64 | -| [`VPEEK`](#vpeek) | function | Returns a value from VERA's VRAM | X16 | -| [`VPOKE`](#vpoke) | command | Sets a value in VERA's VRAM | X16 | -| [`VLOAD`](#vload) | command | Loads a file to VERA's VRAM | X16 | -| `WAIT` | command | Waits for a memory location to match a condition | C64 | +| `USR` | Function | Call a user-defined function in machine language | C64 | +| `VAL` | Function | Parse a string to return a numeric value | C64 | +| `VERIFY` | Command | Verify that a BASIC program was written to disk correctly | C64 | +| [`VPEEK`](#vpeek) | Function | Returns a value from VERA's VRAM | X16 | +| [`VPOKE`](#vpoke) | Command | Sets a value in VERA's VRAM | X16 | +| [`VLOAD`](#vload) | Command | Loads a file to VERA's VRAM | X16 | +| `WAIT` | Command | Waits for a memory location to match a condition | C64 | ## Commodore 64 Compatibility @@ -211,6 +239,83 @@ Refer to [Chapter 13](X16%20Reference%20-%2013%20-%20Working%20with%20CMDR-DOS.m There are several new statement and functions. Note that all BASIC keywords (such as `FOR`) get converted into tokens (such as `$81`), and the tokens for the new keywords have likely shifted from one ROM version to the next. Therefore, loading BASIC program saved from an old revision of BASIC may mix up keywords. As of ROM version R42, the keyword token positions should no longer shift and programs saved in R42 BASIC should be compatible with future versions. +### ABS + +**TYPE: Integer Function** +**FORMAT: ABS(<expression>)** + +**Action:** Returns the absolute value of the given expression, which is its value without a sign. + +**EXAMPLE of the ABS Function:** + +```BASIC +?ABS(-24) + 24 + +?ABS(50) + 50 +``` + +### AND + +**TYPE: Operator** +**FORMAT: <expression> AND <expression>** + +**Action:** AND is used in Boolean operations to test bits. It can also be used in operations +to check the truth of both operands. + +In Boolean algebra, the result of an AND operation is 1 only if both numbers being ANDed are 1. The result is +0 if either or both operands is 0 (false). + +**Simple 1 bit truth table for AND** + +| | | | | | +| :-- | --: | --: | --: | --: | +| Operand 1 | 0 | 1 | 0 | 1 | +| Operand 2 | 0 | 0 | 0 | 1 | +| Result | 0 | 0 | 0 | 1 | + +The Commander X16 BASIC can perform the AND operation on numbers in the range -32768 to +32767. Any fractional values are ignored, and numbers beyond the stated range will cause an ?ILLEGAL QUANTITY error. When converted to binary format, the range allowed yields 16 bits for each operand. Corresponding bits are ANDed together, forming a 16 bit result in the same range. + +**EXAMPLES of 16 bit AND Operation:** + +``` + 37 + AND 123 + 0000 0000 0010 0101 + 0000 0000 0111 1011 +Binary Result: 0000 0000 0010 0001 +Decimal Result: 33 + + 3 + AND 21432 + 0101 0011 1011 1000 + 0000 0000 0000 0011 +Binary Result: 0000 0000 0000 0000 +Decimal Result: 0 + +``` +When evaluating a number for true or false, the computer assumes the number is true as long as its value isn't 0. When evaluating a comparison, it assigns a value of -1 if the result is true, while false has a value of 0. In binary format, -1 is all 1's and 0 is all 0's. Therefore, when ANDing true/false evaluations, the result will be true if any bits in the result are true. + +**EXAMPLES of the AND Operator:** + +```BASIC +10 REM Test, set, and clear specific bits in a value +20 A = 321 +30 IF A AND 7 THEN PRINT "BIT 7 IS SET" +40 A = A OR 5 : REM Set bit 5 +50 IF A AND 5 THEN PRINT "BIT 5 IS SET" +60 A = A AND (255 - 7) : REM Clear bit 7 +70 IF NOT A AND 7 THEN PRINT "BIT 7 IS NOT SET" +``` + +```BASIC +10 REM True/False evaluations. +20 IF A=21 AND B=30 THEN GOTO 40: REM only true if both are true. +30 IF Z AND M=8 THEN GOTO 40: REM True if A is non-zero and M=8 is true. +40 PRINT "DONE." +``` + ### ASC **TYPE: Integer Function** @@ -218,7 +323,7 @@ There are several new statement and functions. Note that all BASIC keywords (suc **Action:** Returns an integer value representing the PETSCII code for the first character of `string`. If `string` is the empty string, `ASC()` returns 0. -**EXAMPLE of ASC Function:** +**EXAMPLE of the ASC Function:** ```BASIC ?ASC("A") @@ -228,18 +333,18 @@ There are several new statement and functions. Note that all BASIC keywords (suc 0 ``` -### BIN$ +### ATN -**TYPE: String Function** -**FORMAT: BIN$(n)** +**TYPE: Integer Function** +**FORMAT: ATN(<number>)** -**Action:** Return a string representing the binary value of n. If n <= 255, 8 characters are returned and if 255 < n <= 65535, 16 characters are returned. +**Action:** This mathematical function returns the arctangent of the number given. The result is the angle (in radians) whose tangent is the number given. The result is always in the range -π / 2 to +π / 2. -**EXAMPLE of BIN$ Function:** +**EXAMPLEs of ATN Function:** ```BASIC -PRINT BIN$(200) : REM PRINTS 11001000 AS BINARY REPRESENTATION OF 200 -PRINT BIN$(45231) : REM PRINTS 1011000010101111 TO REPRESENT 16 BITS +10 PRINT ATN(5) +20 A=ATN(Z) * 180 / PI; : REM Convert to degrees. ``` ### BANK @@ -249,7 +354,7 @@ PRINT BIN$(45231) : REM PRINTS 1011000010101111 TO REPRESENT 16 BITS **Action:** Set the active RAM (m) and ROM bank (n) for the purposes of `PEEK`, `POKE`, and `SYS`. Specifying the ROM bank is optional. If it is not specified, its previous value is retained. -**EXAMPLE of BANK Statement:** +**EXAMPLE of the BANK Statement:** ```BASIC BANK 1,10 : REM SETS THE RAM BANK TO 1 AND THE ROM BANK TO 10 @@ -259,7 +364,7 @@ SYS $C063 : REM CALLS ROUTINE AT $C09F IN ROM BANK 10 AUDIO (YM_INIT) Note: In the above example, the `SYS $C063` in ROM bank 10 is a call to [ym_init](X16%20Reference%20-%2011%20-%20Sound%20Programming.md#audio-api-routines), which does the first half of what the BASIC command `FMINIT` does, without setting any default instruments. It is generally not recommended to call routines in ROM directly this way, and most BASIC programmers will never have a need to call `SYS` directly, but advanced users may find a good reason to do so. -Note: BANK uses its own register to store the the command's desired bank numbers; this will not always be the same as the value stored in `$00` or `$01`. In fact, `$01` is always going to read `4` when PEEKing from BASIC. If you need to know the currently selected RAM and/or RAM banks, you should explicitly set them and use variables to track your selected bank number(s). +Note: BANK uses its own register to store the command's desired bank numbers; this will not always be the same as the value stored in `$00` or `$01`. In fact, `$01` is always going to read `4` when PEEKing from BASIC. If you need to know the currently selected RAM and/or RAM banks, you should explicitly set them and use variables to track your selected bank number(s). Note: Memory address `$00`, which is the hardware RAM bank register, will usually report the bank set by the `BANK` command. The one exception is after a `BLOAD` or `BVERIFY` inside of a running BASIC program. `BLOAD` and `BVERIFY` change the RAM bank (as if you called `BANK`) to the bank that `BLOAD` or `BVERIFY` stopped at. @@ -274,7 +379,7 @@ The device number is optional. If it's not specified, the current device is use For more information about BASLOAD, see [this external documentation](https://github.com/stefan-b-jakobsson/basload-rom) -**EXAMPLE of BASLOAD Command:** +**EXAMPLE of the BASLOAD Command:** ```BASIC BASLOAD "MYPROG.BASL" @@ -287,6 +392,20 @@ LIST READY. ``` +### BIN$ + +**TYPE: String Function** +**FORMAT: BIN$(n)** + +**Action:** Return a string representing the binary value of n. If n <= 255, 8 characters are returned and if 255 < n <= 65535, 16 characters are returned. + +**EXAMPLE of the BIN$ Function:** + +```BASIC +PRINT BIN$(200) : REM PRINTS 11001000 AS BINARY REPRESENTATION OF 200 +PRINT BIN$(45231) : REM PRINTS 1011000010101111 TO REPRESENT 16 BITS +``` + ### BINPUT# **TYPE: Command** @@ -294,7 +413,7 @@ READY. **Action:** `BINPUT#` Reads a block of data from an open file and stores the data into a string variable. If there are fewer than `` bytes available to be read from the file, fewer bytes will be stored. If the end of the file is reached, `ST AND 64` will be true. -**EXAMPLE of BINPUT# Statement:** +**EXAMPLE of the BINPUT# Statement:** ```BASIC 10 OPEN 8,8,8,"FILE.BIN,S,R" @@ -311,7 +430,7 @@ READY. **Action:** Load and run a PRG file named `AUTOBOOT.X16` from device 8. If the file is not found, nothing is done and no error is printed. -**EXAMPLE of BOOT Statement:** +**EXAMPLE of the BOOT Statement:** ```BASIC BOOT @@ -362,6 +481,22 @@ The above example appends a region of memory from \$A000 through and including \ **Warning:** Appending to file involves a risk of corrupting the file system of the SD card! See [Appending to file](X16%20Reference%20-%2013%20-%20Working%20with%20CMDR-DOS.md#appending-to-file). +### BVERIFY + +**TYPE: Command** +**FORMAT: BVERIFY <filename>, <device>, <bank>, <start address>, <end address>** + +**Action:** Verifies that a file on disk matches RAM contents. + +**EXAMPLE of the BSAVE:** + +```BASIC +BVERIFY "MYFILE.BIN",8,1,$A000,$C000 +``` + +The above example compares a region of memory from \$A000 in bank 1 through and including \$BFFF, stopping before \$C000, against the filename listed. + + ### BVLOAD **TYPE: Command** @@ -385,7 +520,7 @@ BVLOAD "MYFONT.BIN", 8, 1, $F000 :REM LOAD A FONT INTO THE DEFAULT FONT LOCATIO The string can contain printable ASCII characters (`CHR$($20)` to `CHR$($7E)`), as well most PETSCII control codes. -**EXAMPLE of CHAR Statement:** +**EXAMPLE of the CHAR Statement:** ```BASIC 10 SCREEN $80 @@ -398,20 +533,56 @@ The string can contain printable ASCII characters (`CHR$($20)` to `CHR$($7E)`), 70 CHAR 0,6+12*5,0,CHR$($12)+A$ :REM REVERSE ``` +### CHR$ + +**TYPE: String Function** +**FORMAT: CHR$(<number>)** + +**Action:** This function converts a Commodore ASCII code to its character equivalent. +See Appendix I for a list of available character sets and their codes. The number must +have a value between 0 and 255 (`$00-$FF`), or an ?ILLEGAL QUANTITY error message will result. + +The string can contain printable ASCII characters (`CHR$($20)` to `CHR$($7E)`), as well most PETSCII control codes. + +**EXAMPLE of the CHR$ Function:** + +```BASIC +10 PRINT CHR$($41) : REM Decimal 65, upper case A +20 Z$ = CHR$(13) : REM 13 = RETURN key +50 B = ASC(A$) : B$ = CHR$(B) : REM Converts to X16 ASCII code and back. +``` + ### CLOSE -**TYPE: Command** +**TYPE: I/O Statement** **FORMAT: CLOSE <file number>** **Action:** Closes any files used by `OPEN` statements. The `CLOSE` statement takes a single argument that is the file number to be closed. -**EXAMPLE of CLOSE Statement:** +**EXAMPLE of the CLOSE I/O Statement:** ```BASIC CLOSE 0 : REM CLOSE FILE OPENED AS 0 CLOSE 4 : REM CLOSE FILE OPENED AS 4 ``` +### CLR + +**TYPE: Command** +**FORMAT: CLR** + +**Action:** This statement clears RAM that had been used, but is no longer needed. +The BASIC program in memory is untouched, but all variables, arrays, GOSUB addresses, FOR..NEXT loops, +user-defined functions, and files are erased from memory, and their space is made available to new +variables, etc. + + +**EXAMPLE of the CLR Statement:** + +```BASIC +CLR +``` + ### CLS **TYPE: Command** @@ -419,12 +590,43 @@ CLOSE 4 : REM CLOSE FILE OPENED AS 4 **Action:** Clears the screen. Same effect as `?CHR$(147);`. -**EXAMPLE of CLS Statement:** +**EXAMPLE of the CLS Statement:** ```BASIC CLS ``` +### CMD + +**TYPE: I/O Statement** +**FORMAT: CMD <file number>[, string]** + +**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, tape, a printer, or an I/O device like the modem[^nomodem]. The file number must be specified in a prior `OPEN` statemewnt. The string, when specified, is sent to the file. This is handy +for titling printouts, etc. + +When this command is in effect, any `PRINT` statements and `LIST` commands will not display on the screen, but will send the text in the same format to the file. + +To re-direcet the output back to the screen, the `PRINT#` command should send a blank line to the `CMD` device before `CLOSE`ing, so it will stop expecting data. This is called "un-listening" the device. + +Any system error (like `?SYNTAX ERROR`) will cause output to return to the screen. Devices aren't un-listened by this, so you should send a blank line after an error condition. + +**EXAMPLE of the CMD I/O Statement:** + +```BASIC +OPEN 4,4: CMD 4, "LISTING" : LIST : REM Lists program on the printer +PRINT# 4: CLOSE 4: REM Un-listens and closes printer + +10 OPEN 2,8,2, "TEST.TXT,S,W" : REM Create a SEQ file. +20 CMD 2 : REM Direct output to the file not the screen. +30 FOR X = 1 TO 100 +40 PRINT X +50 NEXT X +60 PRINT# 2 : REM Un-listen +70 CLOSE 1 : REM Write remaining buffer contents, close file. +``` + +[^nomodem]: Device #2 (RS-232) support has been removed from the X16 KERNAL. + ### COLOR **TYPE: Command** @@ -439,6 +641,158 @@ COLOR 2 : REM SET FG COLOR TO RED, KEEP BG COLOR COLOR 2,0 : REM SET FG COLOR TO RED, BG COLOR TO BLACK ``` +### CONT + +**TYPE: Command** +**FORMAT: CONT** + +**Action:** This command re-starts the execution of a program which was halted by a `STOP` or `END` statement, or the **RUN/STOP** key being pressed. The program will re-start at the exact place from which it left off. + +While the program is stopped, the user can inspect or change any variables or look at the program. When debugging or examing a program, `STOP` statements can be placed at strategic locations to allow examination of variables and check the flow of the program. + +The error message `?CAN'T CONTINUE` will result from editing the program (even just hitting **RETURN** with the cursor on an unchanged line), or if the program halted due to an error, or if you caused an error before typing `CONT` to re-start the program. + + +**EXAMPLE of the CONT Command:** + +```BASIC +10 PI=0 : C=1 +20 PI=PI+4/C-4/(C+2) +30 PRINT PI +40 C=C+4 : GOTO 20 +``` + +This program calculats the value of PI. Run this program, and after a few seconds, hit the **RUN/STOP** key. You will see the display: + +``` + BREAK IN x +``` +Where `x` is the line number where program execution was interrupted. + +Type the command `PRINT C` to see how far the Commander X16 has gotten. Then use `CONT` to resume from where the Commander X16 left off. + + +### COS + +**TYPE: Function** +**FORMAT: COS(<number>)** + +**Action:** This mathematical function calculates the cosine of the number, where the number is an angle expressed in radians. + +**EXAMPLES of the COS Function:** + +```BASIC +10 PRINT COS(5) +15 A = 232 +20 PI = 3.14159265 +30 Y = COS(A * PI / 180) : REM Convert degrees to radians. +``` + +### DA$ + +**TYPE: String Function** +**FORMAT: DA$** + +**Action:** Returns or sets the date in the system clock. The format is YYYYMMDD. + +**EXAMPLE of the DA$ String Function** + +```BASIC +10 HD$ = DA$ +20 PRINT "HOLD DATE IS ";HD$;"." +30 DA$ = "20251121" +40 PRINT "NEW DATE IS NOW ";DA$;"." +50 DA$ = HD$ +``` + +### DATA + +**TYPE: Statement** +**FORMAT: DATA <list of constants>** + +**Action:** `DATA` statements store information within a program. The program uses the information by means of the `READ` statement, which pulls successive constants from the `DATA` statements. + +The `DATA` statements don't have to be executed by the program, they only have to be present. Therefore, they are usually placed at the end of the program. + +All data statements in a program are treated as a continuous list. Data is `READ` from left to right, from the lowest numbered line to the highest. If the `READ` statement encounters data that doesn't fit the type requested (if it needs a number and finds a string) an error message occurs. + +Any characters can be included as data, but if certain ones are used, the data item must be enclosed by quote marks (" "). These include punctuation like comma (,), colon (:), blank spaces, shifted letters, graphics, and cursor control characters. + + +**EXAMPLE of DATA Statements** + +```BASIC +10 FOR X = 1 TO 5 +20 READ Z +30 PRINT Z +40 NEXT X +50 DATA 2, 4, 6, 8, 10 +``` + +### DEF FN + +**TYPE: Statement** +**FORMAT: DEF FN <name> (<variable>) = <expression>** + +**Action:** This sets up a user-defined function that can be used later in the program. +The function can consist of any mathematical formula. + +User-defined functions save space in programs where a long formula is used in several places. The formula need only be specified once, in the definition statement, and then it is abbreviated as a function name. It must be executed once, but any subsequent executions are ignored. + +The function name is the letters `FN` followed by any variable name. +This can be 1 or 2 characters, the first being a letter and the second a letter or digit. + +**EXAMPLES of the DEF FN Statement:** + +```BASIC +10 DEF FN A(X) = X + 7 +20 DEF FN AA(X) = Y * Z +30 DEF FN A9(Q) = INT(RND(1)*Q+1) +``` +The function is called later in the program by using the function name with a variable in parenthesis. This function name is used like any other variable, and its value is automatically calculated. + +**EXAMPLES of FN Use:** + +```BASIC +40 PRINT FN A(9) +50 R = FNAA(9) +60 G = G + FN A9(10) +``` + +In line 50 above, the number 9 inside the parenthesis does not affect the outcome of the function because the function definition in line 20 doesn't use the variable in parenthesis. The result is Y times Z, regardless of the value of X. In the other two functions, the value in parenthesis does affect the result. + +### DIM + +**TYPE: Statement** +**FORMAT: DIM <variable>(<subscripts>) [,<variable>(<subscripts>)... ]** + +**Action:** This statement defines an array or matrix of variables. This allows you to use the variable name with a subscript. The subscript points to the element being used. The lowest element number in an array is zero, and the highest is the number given in the `DIM` statement, which has a maximum of 32767. + +The `DIM` statement must be executed once and only once for each array. A `?REDIM'D ARRAY` error occurs if this line is re-executed. Therefore, most programs perform all `DIM` operations at the very beginning. + +There may be any number of dimensions and 255 subscripts in an array, limited only by the amount of RAM memory which is available to hold the variables. The array may be made up of normal numeric variables, as shown above, or of strings or integer numbers. If the variables are other than normal numeric, use the `$` or `%` signs after the variable name to indicate string or integer variables. + +If an array referenced in a program was never `DIM`ensioned, it is automatically dimensioned to 11 elements in each dimension used in the first reference. + +**EXAMPLES of the DIM Statement:** + +```BASIC +10 DIM A(100) +20 DIM Z(5,7), Y(3,4,5) +30 DIM Y1%(Q) +40 DIM OH$(1000) +50 Z(5) = 9 : REM Automatically performs DIM Z(10) +``` + +**CALCULATING MEMORY USED BY DIM:** + + * 5 bytes for the array name. + * 2 bytes for each dimension. + * 2 bytes per element for integer variables. + * 5 bytes per element for floating point variables. + * 3 bytes per element for string variables. + * 1 byte for each character in each string element. + ### DOS **TYPE: Command** @@ -472,7 +826,7 @@ DOS : REM PRINTS DOS STATUS, E.G. "01,FILES SCRATCHED,01,00" The EDIT command loads the editor in the screen mode and character set that was active at the time the command was run. -**EXAMPLE of EDIT Statement:** +**EXAMPLE of the EDIT Statement:** ```BASIC EDIT "README.TXT" @@ -480,6 +834,25 @@ EDIT "README.TXT" A more elaborate X16-Edit manual can be found [here](https://github.com/X16Community/x16-rom/blob/master/x16-edit/docs/manual.pdf) +### END + +**TYPE: Statement** +**FORMAT: END** + +**Action:** This finishes a program's execution and displays the `READY` message, returning control to the person operating the computer. There may be any number of `END` statements within a program. While it is not necessary to include any `END` statements at all, it is recommended that a program does conclude with one, rather than just running out of lines. + +The `END` statement is similar to the `STOP` statement. The only difference is that `STOP` causes the computer to display the messsage `BREAK IN XX` and `END` just displays `READY`. both statements allow the computer to resume execution by typing the `CONT` command. + +**EXAMPLES of the END Statement: +```BASIC +10 PRINT "TYPE 'Y' TO END PROGRAM: "; +20 INPUT A$ +30 IF A$ = "Y" THEN END +50 PRINT "CONTINUING..." +50 REM The rest of the program... +999 END +``` + ### EXEC **TYPE: Command** @@ -491,7 +864,7 @@ A more elaborate X16-Edit manual can be found [here](https://github.com/X16Commu * The input can span multiple RAM banks. The input will stop once it reaches a null byte ($00) or if a BASIC error occurs. * The redirected input only applies to BASIC immediate mode. While programs are running, the EXEC handling is suspended. -**EXAMPLE of EXEC Statement:** +**EXAMPLE of the EXEC Statement:** ```BASIC BLOAD "MYPROGRAM.BAS",8,1,$A000 : REM "BANK PEEK(0)" NO LONGER NEEDED @@ -509,6 +882,20 @@ it for you: 40 NEW ``` +### EXP + +**TYPE: Numeric Function** +**FORMAT: EXP (<number>)** + +**Action:** This mathematical function calculates the constant e (2.71828183) raised to the power of the number given. A value greater than 88.0296919 causes an `?OVERFLOW` error to occur. + +**EXAMPLES of the EXP Function:** + +```BASIC +10 PRINT EXP(12) +20 C = D * EXP(A * B) +``` + ### FMCHORD **TYPE: Command** @@ -520,7 +907,7 @@ All macros are supported, even the ones that only affect the behavior of `PSGPLA The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of FMCHORD statement:** +**EXAMPLE of the FMCHORD statement:** ```BASIC 10 FMINIT @@ -556,7 +943,7 @@ This will play the first few lines of _Silent Night_ with a vibraphone lead and **Action:** Play a note by frequency on the YM2151. The accepted range is in Hz from 17 to 4434. FMFREQ also accepts a frequency of 0 to release the note. -**EXAMPLE of FMFREQ statement:** +**EXAMPLE of the FMFREQ statement:** ```BASIC 0 FMINST 0,160 : REM LOAD PURE SINE PATCH @@ -596,7 +983,7 @@ Load an instrument onto the YM2151 in the form of a [patch preset](X16%20Referen Notes can also be represented by negative numbers to skip retriggering, and will thus snap to another note without restarting the playback of the note. -**EXAMPLE of FMNOTE statement:** +**EXAMPLE of the FMNOTE statement:** ```BASIC 0 FMINST 1,64 : REM LOAD SOPRANO SAX @@ -631,7 +1018,7 @@ Notes can also be represented by negative numbers to skip retriggering, and will The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of FMPLAY statement:** +**EXAMPLE of the FMPLAY statement:** ```BASIC 10 FMINIT : REM INITIALIZE AND LOAD DEFAULT PATCHES, WILL USE E.PIANO @@ -646,9 +1033,9 @@ The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%2 **TYPE: Command** **FORMAT: FMPOKE <register>,<value>** -**Action:** This command uses the AUDIO API to write a value to one of the the YM2151's registers at a low level. +**Action:** This command uses the AUDIO API to write a value to one of the YM2151's registers at a low level. -**EXAMPLE of FMPOKE statement:** +**EXAMPLE of the FMPOKE statement:** ```BASIC 10 FMINIT @@ -668,7 +1055,7 @@ Only some patch presets (instruments) are sensitive to the LFO. Those are marked Good values for most instruments are speed somewhere between 190-220. A good light vibrato for most wind instruments would have a depth of 10-15, while tremolo instruments like the Vibraphone or Tremolo Strings are most realistic around 20-30. -**EXAMPLE of FMVIB statement:** +**EXAMPLE of the FMVIB statement:** ```BASIC 10 FMVIB 200,30 @@ -687,6 +1074,69 @@ The above BASIC program plays a C major scale with a vibraphone patch, first wit **Action:** This command sets the channel's volume. The volume remains at the requested level until another `FMVOL` command for that channel or `FMINIT` is called. Valid range is from 0 (completely silent) to 63 (full volume) +### FN + +**TYPE: Numeric Function** +**FORMAT: FN <name> (<number>)** + +**Action:** This function references the previously `DEF`ined formula specified by name. The number is substituted into its place (if any) and the formula is calculated. The result will be a numeric value. + +This function can be used in direct mode, as long as the statement `DEF`ining it has been executed. + +If an `FN` is executed before the `DEF` statement which defines it, an `?UNDEF'D FUNCTION` error occurs. + +**EXAMPLES the FN (User Defined) Function:** + +```BASIC +PRINT FN Z(Q) +135 A = FN A(3) + FN A(21) +210 IF FN X1(A+1) = 42 THEN END +``` + +### FOR-TO-STEP + +**TYPE: Statement** +**FORMAT: FOR <variable> = <start> TO <limit> [STEP <increment>]** + +**Action:** This is a special BASIC statement that lets you easily use a variable as a counter. You must specify certain parameters: the floating-point variable name, its starting value, the limit of the count, and how much to add during each cycle. + +Here is a simple BASIC program that counts from 1 to 10, `PRINT`ing each number and `END`ing when complete, and using no `FOR` statements: +```BASIC +10 A = 1 +20 PRINT A +30 A = A + 1 +40 IF A <= 10 THEN 20 +50 END +``` +Using the `FOR` statement, here is the same program: +```BASIC +10 FOR A = 1 TO 10 +20 PRINT A +30 NEXT A +40 END +``` + +As you can see, the program is shorter and easier to understand using the `FOR` statement. + +When the `FOR` statement is executed, several operations take place. The <start> value is placed in the <variable> being used in the counter. In the example above, a 1 is placed in `A`. + +When the `NEXT` statement is reached, the <increment> value is added to the <variable>. If a `STEP` was not included, the <increment> is set to +1. The first time the program hits line 30, 1 is added to `A`, so the new value of `A` is 2. + +Now the value in the <variable> is compared to the <limit>. if the <limit> has not been reached yet, the program `GO`es `TO` the line after the original `FOR` statement. In this case, the value of 2 in `A` is less than the limit of 10, so it `GO`es `TO` line 20. + +Eventually, the value of <limit> is exceeded by the <variable>. At that time, the loop is concluded and the program continues with the line following the `NEXT` statement. In our example, the value of `A` reaches 11, which exceeds the limit of 10, and the program goes on with line 40. + +When the value of <increment> is positive, the <variable> must exceed the <limit>, and when it is negative, it must become less than the <limit>. + +**NOTE: A loop always executes at least once.** + +**EXAMPLES of the FOR.. TO.. STEP.. Statement:** +```BASIC +10 FOR X = 100 TO 0 STEP -1 +10 FOR Z = PI TO 6 * 3.1459 STEP .01 +10 FOR ZY = 42 TO 42 +``` + ### FRAME **TYPE: Command** @@ -694,7 +1144,7 @@ The above BASIC program plays a C major scale with a vibraphone patch, first wit **Action:** This command draws a rectangle frame on the graphics screen in a given color. -**EXAMPLE of FRAME Statement:** +**EXAMPLE of the FRAME Statement:** ```BASIC 10 SCREEN$80 @@ -702,18 +1152,117 @@ The above BASIC program plays a C major scale with a vibraphone patch, first wit 30 GOTO20 ``` -### HEX$ +### FRE -**TYPE: String Function** -**FORMAT: HEX$(n)** +**TYPE: Function** +**FORMAT: FRE(<variable>)** -**Action:** Return a string representing the hexadecimal value of n. If n <= 255, 2 characters are returned and if 255 < n <= 65535, 4 characters are returned. +**Action:** This function tells you how much RAM is available for your programs and its variables. If a program tries to use more space than is available, the `?OUT OF MEMORY` error results. -**EXAMPLE of HEX$ Function:** +The number in parenthesis can have any value, and it is not used in the calculation. +**NOTE: If the result of `FRE` is negative, add 65536 to the `FRE` number to get the number of bytes available in memory.** + +**EXAMPLES of the FRE Function:** ```BASIC -PRINT HEX$(200) : REM PRINTS C8 AS HEXADECIMAL REPRESENTATION OF 200 -PRINT HEX$(45231) : REM PRINTS B0AF TO REPRESENT 16 BIT VALUE +PRINT FRE(0) +10 FM = (FRE(K) - 1000) / 7 +60000 IF FRE(0) < 100 THEN PRINT "NOT ENOUGH ROOM" +``` +**NOTE: The following always tells you the current available RAM:** +```BASIC +PRINT FRE(0) - (FRE(0) < 0) * 65536 +``` + +### GET + +**TYPE: Statement** +**FORMAT: GET <variable list>** + +**Action:** This statement reads each key typed by the user. As the user is typing, the characters are stored in the Commander X16's keyboard buffer. Up to 10 characters are stored here, and any keys struck after the 10th are discarded. Reading one of the characters with the `GET` statement makes room for another character. + +If the `GET` statement specifies numeric data, and the user types a key other than a number, the message `?SYNTAX ERROR` appears. To be safe, read the keys as strings and convert them to numbers later. + +The `GET` statement can be used to avoid some of the limitations of the `INPUT` statement. For more on this, see the section on Using the `GET` Statement in the Programming Techniques[^missing_pt] section. + +**EXAMPLES of the GET Statement:** + +```BASIC +10 GET OK$ : IF OK$ = "" THEN 10 : REM Loops until a key is pressed. +20 GET A1$, A2$, A3$, A4$, A5$ : REM Reads 5 keys +30 GET B, B$ : REM Reads a number key (0..9) and any key. +``` + +[^missing_pt]: There is no Programming Techniques section currently. + +### GET#** + +**TYPE: I/O Statement** +**FORMAT: GET# <file number>, <variable list>** + +**Action:** This statement reads characters one-at-a-time from the device or file specified. It works the same as the `GET` statement, except that the data comes from a different place than the keyboard. If no character is received, the variable list is set to an empty string (equal to "") or to 0 for numeric variables. Characters used to separate data in files, like the comma `(,)` or **RETURN** key code (ASCII code of 13), are received like any other character. + + **EXAMPLES of the GET# Statement:** + + ```BASIC + 10 GET# 1, A$ + 20 OPEN 1,3 : GET# 1, A3$ + 30 GET# 1, A(1), A(2), A$, B$ + ``` + +### GOSUB + +**TYPE: Statement** +**FORMAT: GOSUB <line number>** + +**Action** This is a specialized form of the `GOTO` statement, with one important difference: `GOSUB` remembers where it came from. When the `RETURN` statement (different from the **RETURN** key on the keyboard) is reached in the program, the program jumps back to the statement immediately following the original `GOSUB` statement. + +The major use of a subroutine (`GOSUB` means `GO` to a `SUB`-routine) is when a small section of program is used by different sections of the program. By using subroutines rather that repeating the same lines over and over at different places in the program, you can save lots of program space. In this way, `GOSUB` is similar to `DEF FN`. `DEF FN` lets you save space when using a formula, while `GOSUB` saves space when using a several-line routine. + +**An inefficient program that doesn't use `GOSUB`** +```BASIC +10 PRINT "THIS PROGRAM PRINTS" +20 FOR I = 1 TO 500 : NEXT I +30 PRINT "SLOWLY ON THE SCREEN" +40 FOR I = 1 TO 500 : NEXT I +50 PRINT "USING A SIMPLE LOOP" +60 FOR I = 1 TO 500 : NEXT I +70 PRINT "AS A TIME DELAY" +180 FOR I = 1 TO 500 : NEXT I +``` + +**The same program using `GOSUB`** +```BASIC +10 PRINT "THIS PROGRAM PRINTS" +20 GOSUB 200 +30 PRINT "SLOWLY ON THE SCREEN" +40 GOSUB 200 +50 PRINT "USING A SIMPLE LOOP" +60 GOSUB 200 +80 PRINT "AS A TIME DELAY" +90 GOSUB 200 +100 END +200 FOR I = 1 TO 500 : NEXT I +210 RETURN +``` +Each time the program executes a `GOSUB`, the line number and position in the program line are saved in a special area called the "stack", which takes up 256 bytes of memory. This limits the amount of data that can be stored in the stack. Therefore, the number of subroutine return addresses that can be stored is limited, and care should be taken to make sure every `GOSUB` hits the corresponding `RETURN`, otherwise you'll run out of memory even though the computer has plenty of bytes free. + +### GOTO + +**TYPE: Statement** +**FORMAT: GOTO <line number> or GO TO <line number>** + +**Action:** This statement allows the BASIC program to execute lines out of numerical order. The word `GOTO` followed by a number will make the program jump to the line with that number. `GOTO` NOT followed by a number equals `GOTO 0`. It must have the line number after the word `GOTO`. + +It is possible to create loops with `GOTO` that will never end. The simplest example of this is a line that `GO`es `TO` itself, like `10 GOTO 10`. + +These loops can be stopped by using the **RUN/STOP** key on the keyboard. + +**EXAMPLES of the GOTO Statement:** +```BASIC +GOTO 25 +10 GO TO 100 +20 GOTO 12000 ``` ### HELP @@ -723,6 +1272,20 @@ PRINT HEX$(45231) : REM PRINTS B0AF TO REPRESENT 16 BIT VALUE **Action:** The `HELP` command displays a brief summary of the ROM build, and points users to this guide at its home on GitHub, and to the community forums website. +### HEX$ + +**TYPE: String Function** +**FORMAT: HEX$(n)** + +**Action:** Return a string representing the hexadecimal value of n. If n <= 255, 2 characters are returned and if 255 < n <= 65535, 4 characters are returned. + +**EXAMPLE of the HEX$ Function:** + +```BASIC +PRINT HEX$(200) : REM PRINTS C8 AS HEXADECIMAL REPRESENTATION OF 200 +PRINT HEX$(45231) : REM PRINTS B0AF TO REPRESENT 16 BIT VALUE +``` + ### I2CPEEK **TYPE: Integer Function** @@ -730,7 +1293,7 @@ PRINT HEX$(45231) : REM PRINTS B0AF TO REPRESENT 16 BIT VALUE **Action:** Returns the value from a register on an I²C device. -**EXAMPLE of I2CPEEK Function:** +**EXAMPLE of the I2CPEEK Function:** ```BASIC PRINT HEX$(I2CPEEK($6F,0) AND $7F) @@ -745,7 +1308,7 @@ This command reports the seconds counter from the RTC by converting its internal **Action:** Sets the value to a register on an I²C device. -**EXAMPLE of I2CPOKE Function:** +**EXAMPLE of the I2CPOKE Function:** ```BASIC I2CPOKE $6F,$40,$80 @@ -753,6 +1316,43 @@ I2CPOKE $6F,$40,$80 This command sets a byte in NVRAM on the RTC to the value `$80` +### IF-THEN + +**TYPE: Statement** +**FORMAT:** +- **IF <expression> THEN <line number>** +- **IF <expression> GOTO <line number>** +- **IF <expression> <statements>** + +**Action:** This is the statement that gives BASIC most of its "intelligence", the ability to evaluate conditions and take different actions depending on the outcome. + +The word `IF` is followed by an expression, which can include variables, strings, numbers, comparisons, and logical operators. The word `THEN` appears on the same line and is followed by either a line number or one or more BASIC statments. When the expression is false, everything else after the word `THEN` on that line is ignored, and execution continues with the next line number in the program. A true result makes the progrm either branch to the line number after the word `THEN` or execute whatever other BASIC statements are found on that line. + +**EXAMPLE of the IF...GOTO... Statement:** +```BASIC +10 INPUT "ENTER A NUMBER";N +20 IF N <= 0 GOTO 50 +30 PRINT "SQUARE ROOT=";SQR(N) +40 GOTO 10 +50 PRINT "NUMBER MUST BE > 0" +60 GOTO 10 +``` +This program prints out the square root of any positive number. The `IF` statement here is used to validate the result of the `INPUT`. When the result of `N` is less than or equal to zero, the program skips to line 50, and when the result is false, the next line to be executed is 30. Note that `THEN GOTO` is not needed with `IF...THEN`, as in line 20 where `GOTO 50` actually means `THEN GOTO 50`. + +**EXAMPLE of the IF...THEN... Statement:** +```BASIC +10 FOR I = 1 TO 100 +20 IF RND(1) < .5 THEN X = X + 1 : GOTO 40 +30 Y = Y + 1 +40 NEXT I +50 PRINT "HEADS= ";X +60 PRINT "TAILS= ";Y +``` +The `IF` in line 20 tests a random number to see if it is less than .5. + +When the result is true, the whole series of statements following the word `THEN` are executed: first `X` is incremented by 1, then the program skips to line 40. When the result is false, the program drops to the next statement, line 30. + + ### JOY **TYPE: Integer Function** @@ -781,7 +1381,7 @@ If no controller is connected to the SNES port (or no keyboard is connected), th Note that this bitfield is different from the `joystick_get` KERNEL API one. Also note that the keyboard joystick will allow LEFT and RIGHT as well as UP and DOWN to be pressed at the same time, while controllers usually prevent this mechanically. -**EXAMPLE of JOY Function:** +**EXAMPLE of the JOY Function:** ```BASIC 10 REM DETECT CONTROLLER, FALL BACK TO KEYBOARD @@ -805,7 +1405,7 @@ Note that this bitfield is different from the `joystick_get` KERNEL API one. Als **Action:** This command sets the current keyboard layout. It can be put into an AUTOBOOT file to always set the keyboard layout on boot. -**EXAMPLE of KEYMAP Statement:** +**EXAMPLE of the KEYMAP Statement:** ```BASIC 10 KEYMAP"SV-SE" :REM SMALL BASIC PROGRAM TO SET LAYOUT TO SWEDISH/SWEDEN @@ -819,7 +1419,7 @@ SAVE"AUTOBOOT.X16" :REM SAVE AS AUTOBOOT FILE **Action:** This command draws a line on the graphics screen in a given color. -**EXAMPLE of LINE Statement:** +**EXAMPLE of the LINE Statement:** ```BASIC 10 SCREEN128 @@ -848,7 +1448,7 @@ The input is taken from the KERNAL editor, hence the user will have the freedom Due to how the editor works, an empty line will return `" "`– a string with a single space, and trailing spaces are not preserved. -**EXAMPLE of LINPUT Statement:** +**EXAMPLE of the LINPUT Statement:** ```BASIC 10 LINPUT A$ @@ -867,7 +1467,7 @@ Due to how the editor works, an empty line will return `" "`– a string wit `LINPUT#` can be used to read structured data from files. It can be particularly useful to extract quoted or null-terminated strings from files while reading. -**EXAMPLE of LINPUT# Statement:** +**EXAMPLE of the LINPUT# Statement:** ```BASIC 10 I=0 @@ -923,7 +1523,7 @@ approximately one screen full of text. **Action:** This command positions the text mode cursor at the given location. The values are 1-based. If no column is given, only the line is changed. -**EXAMPLE of LOCATE Statement:** +**EXAMPLE of the LOCATE Statement:** ```BASIC 100 REM DRAW CIRCLE ON TEXT SCREEN @@ -945,7 +1545,7 @@ The values are 1-based. If no column is given, only the line is changed. **Action:** This command currently invokes the Commander X16 Control Panel. In the future, the menu may instead present a menu of ROM-based applications and routines. -**EXAMPLE of MENU Statement:** +**EXAMPLE of the MENU Statement:** ```BASIC MENU @@ -960,7 +1560,7 @@ MENU The `MOD` function supports 16bit signed numbers (-32768 to 32767) -**EXAMPLE of MOD Function:** +**EXAMPLE of the MOD Function:** ```BASIC PRINT MOD(-17, 5) :REM RESULT WILL HAVE THE SAME SIGN AS DIVIDEND -2 @@ -982,7 +1582,7 @@ PRINT MOD(65000, 101) :REM DIVIDEND IS TOO LARGE FOR A SIGNED 16BIT VALUE **Action:** This command enters the machine language monitor. See the [Chapter 7: Machine Language Monitor](X16%20Reference%20-%2007%20-%20Machine%20Language%20Monitor.md#chapter-7-machine-language-monitor) for a description. -**EXAMPLE of MON Statement:** +**EXAMPLE of the MON Statement:** ```BASIC MON @@ -1025,7 +1625,7 @@ MOUSE 0 : REM DISABLE MOUSE `sprite idx` is a value between 0-127 inclusive. `x` and `y` have a range of -32768 to 32767 inclusive, but their meanings wrap every 1024 values. Values approaching 1023 will peek out from the left and top of the screen for x and y respectively as if they were negative and approaching 0. -1024, 1024, 0, and 2048 are all equivalent. Likewise, -10 and 1014 are equivalent. -**EXAMPLE of MOVSPR Statement:** +**EXAMPLE of the MOVSPR Statement:** ```BASIC 10 BVLOAD "MYSPRITE.BIN",8,1,$3000 @@ -1052,7 +1652,7 @@ MOUSE 0 : REM DISABLE MOUSE | 2 | right | | 4 | third | -**EXAMPLE of MX/MY/MB variables:** +**EXAMPLE of the MX/MY/MB variables:** ```BASIC REM SIMPLE DRAWING PROGRAM @@ -1082,7 +1682,7 @@ moved away from the user, and positive if it is moved towards the user. The rang **Action:** This command recovers the BASIC program in RAM that has been previously deleted using the `NEW` command or through a RESET. -**EXAMPLE of OLD Statement:** +**EXAMPLE of the OLD Statement:** ```BASIC OLD @@ -1097,7 +1697,7 @@ OLD The coordinate arguments define the rectangular bounding box of the oval. To draw a filled circle, make the width and height equal to each other. -**EXAMPLE of OVAL Statement:** +**EXAMPLE of the OVAL Statement:** ```BASIC 10 SCREEN $80 @@ -1115,7 +1715,7 @@ The coordinate arguments define the rectangular bounding box of the oval. To dra PEEKing values within the BRAM (`$A000`) and KERNAL/Cartridge (`$C000`) requires using `BANK` to set the banks accordingly. -**EXAMPLE of PEEK function:** +**EXAMPLE of the PEEK function:** ```BASIC 10 A=PEEK($C000) @@ -1129,7 +1729,7 @@ requires using `BANK` to set the banks accordingly. **Action:** Returns the memory address of the internal structure representing a BASIC variable. -**EXAMPLE of POINTER function:** +**EXAMPLE of the POINTER function:** ```BASIC 10 A$="MOO" @@ -1154,7 +1754,7 @@ older than R49. In R49, POKE works as expected assuming the area being written to is RAM and that [`BANK`](#bank) has been called with appropriate arguments. -**EXAMPLE of POKE function:** +**EXAMPLE of the POKE function:** ```BASIC 10 POKE $A000,47 @@ -1167,7 +1767,7 @@ called with appropriate arguments. **Action:** This command instructs the SMC to power down the system. This is equivalent to pressing the physical power switch. -**EXAMPLE of POWEROFF Statement:** +**EXAMPLE of the POWEROFF Statement:** ```BASIC POWEROFF @@ -1180,7 +1780,7 @@ POWEROFF **Action:** This command sets a pixel on the graphics screen to a given color. -**EXAMPLE of PSET Statement:** +**EXAMPLE of the PSET Statement:** ```BASIC 10 SCREEN$80 @@ -1199,7 +1799,7 @@ All macros are supported, even the ones that only affect `PSGPLAY` and `FMPLAY`. The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of PSGCHORD statement:** +**EXAMPLE of the PSGCHORD statement:** ```BASIC 10 PSGINIT @@ -1219,7 +1819,7 @@ The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%2 **Action:** Play a note by frequency on the VERA PSG. The accepted range is in Hz from 1 to 24319. PSGFREQ also accepts a frequency of 0 to release the note. -**EXAMPLE of PSGFREQ statement:** +**EXAMPLE of the PSGFREQ statement:** ```BASIC 10 PSGINIT : REM RESET ALL VOICES TO SQUARE WAVEFORM @@ -1249,7 +1849,7 @@ The above BASIC program plays a sound similar to a North American dial tone for |-|-|-|-|-|-|-|-|-|-|-|-|-|-| | Release | C | C♯/D♭ | D | D♯/E♭ | E | F | F♯/G♭ | G | G♯/A♭ | A | A♯/B♭ | B | no-op | -**EXAMPLE of PSGNOTE statement:** +**EXAMPLE of the PSGNOTE statement:** ```BASIC 10 PSGNOTE 1,$4A : REM PLAYS CONCERT A @@ -1281,7 +1881,7 @@ The above BASIC program plays a sound similar to a North American dial tone for The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of PSGPLAY statement:** +**EXAMPLE of the PSGPLAY statement:** ```BASIC 10 PSGWAV 0,31 : REM PULSE, 25% DUTY @@ -1310,7 +1910,7 @@ The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%2 * w = 128-191 -> Triangle (all values have identical effect) * w = 192-255 -> Noise (all values have identical effect) -**EXAMPLE of PSGWAV Statement:** +**EXAMPLE of the PSGWAV Statement:** ```BASIC 10 FOR O=$20 TO $50 STEP $10:REM OCTAVE LOOP @@ -1341,7 +1941,7 @@ This example plays a chromatic scale while applying pulse-width modulation on th The coordinate arguments define the rectangular bounding box of the oval. To draw a circle outline, make the width and height equal to each other. -**EXAMPLE of RING Statement:** +**EXAMPLE of the RING Statement:** ```BASIC 10 SCREEN $80 @@ -1356,7 +1956,7 @@ The coordinate arguments define the rectangular bounding box of the oval. To dra **Action:** This command draws a solid rectangle on the graphics screen in a given color. -**EXAMPLE of RECT Statement:** +**EXAMPLE of the RECT Statement:** ```BASIC 10 SCREEN$80 @@ -1371,7 +1971,7 @@ The coordinate arguments define the rectangular bounding box of the oval. To dra **Action:** Performs a software reset of the system by calling the ROM reset vector. -**EXAMPLE of REBOOT Statement:** +**EXAMPLE of the REBOOT Statement:** ```BASIC REBOOT @@ -1403,7 +2003,7 @@ In release R43, due to improper parsing of escape tokens, REN will improperly tr This behavior has been fixed in R44. -**EXAMPLE of REN Statement:** +**EXAMPLE of the REN Statement:** ```BASIC 10 PRINT "HELLO" @@ -1438,7 +2038,7 @@ READY. **Action:** This command instructs the SMC to assert the reset line on the system, which performs a hard reset. This is equivalent to pressing the physical reset switch. -**EXAMPLE of RESET Statement:** +**EXAMPLE of the RESET Statement:** ```BASIC RESET @@ -1451,7 +2051,7 @@ RESET **Action:** This command resets the pointer for the `READ` command. Without arguments, it will reset the pointer to the first `DATA` constant in the program. With a parameter `linenum`, the command will reset the pointer to the first `DATA` constant at or after that line number. -**EXAMPLE of RESTORE Statement:** +**EXAMPLE of the RESTORE Statement:** ```BASIC 10 DATA 1,2,3 @@ -1474,7 +2074,7 @@ This program will output the number 1 followed by the number 4. `RPT$(A,1)` is functionally equivalent to `CHR$(A)`. -**EXAMPLE of RPT$ function:** +**EXAMPLE of the RPT$ function:** ```BASIC 10 REM TEN EXCLAMATION MARKS @@ -1520,7 +2120,7 @@ The above example overwrites an existing file on drive 9, which would be a Commo For a list of supported modes, see [Chapter 3: Editor](X16%20Reference%20-%2003%20-%20Editor.md#chapter-3-editor). The value of -1 toggles between modes $00 and $03. -**EXAMPLE of SCREEN Statement:** +**EXAMPLE of the SCREEN Statement:** ```BASIC SCREEN 3 : REM SWITCH TO 40 CHARACTER MODE @@ -1537,7 +2137,7 @@ SCREEN -1 : REM SWITCH BETWEEN 40 and 80 CHARACTER MODE Allowed values for `jiffies` is from 0 to 65535, inclusive. -**EXAMPLE of SLEEP Statement:** +**EXAMPLE of the SLEEP Statement:** ```BASIC 10 FOR I=1 TO 10 @@ -1564,7 +2164,7 @@ The first two arguments are required, but the remainder are optional. Note: If VERA's sprite layer is disabled when the `SPRITE` command is called, the sprite layer will be enabled, regardless of the arguments to `SPRITE`. -**EXAMPLE of SPRITE Statement:** +**EXAMPLE of the SPRITE Statement:** ```BASIC 10 BVLOAD "MYSPRITE.BIN",8,1,$3000 @@ -1587,7 +2187,7 @@ The first three arguments are required, but the last one is optional. * `VRAM address` is a 16-bit value, \$0000-\$FFFF, is the address within the VRAM bank to point the sprite to. The lowest 5 bits are ignored. * `color depth` selects either 4 or 8-bit color depth for the sprite. 0 = 4-bit, 1 = 8-bit. This attribute can also be set by the `SPRITE` command. -**EXAMPLE of SPRITE Statement:** +**EXAMPLE of the SPRITE Statement:** ```BASIC 10 BVLOAD "MYSPRITE.BIN",8,1,$3000 @@ -1603,7 +2203,7 @@ The first three arguments are required, but the last one is optional. **Action:** Returns the memory address of the first character of a string contained within a string variable. If the string variable has zero length, this function will likely still return a non-zero value pointing either to the close quotation mark in the literal assignment, or to somewhere undefined in string memory. Programs should check the `LEN()` of string variables before using the pointer returned from `STRPTR`. -**EXAMPLE of STRPTR function:** +**EXAMPLE of the STRPTR function:** ```BASIC 10 A$="MOO" @@ -1641,7 +2241,7 @@ memory locations: When the routine is over, the CPU registers will be loaded back in to these locations. So you can read the results of a machine language routine by PEEKing these locations. -**EXAMPLE of SYS statement:** +**EXAMPLE of the SYS statement:** Push a <CR> into the keyboard buffer. @@ -1667,7 +2267,7 @@ In the default text mode, this can be used to quickly change a character on the However, it can also be used if VERA Layer 1's map base value is changed or the map size is changed. -**EXAMPLE of TILE command:** +**EXAMPLE of the TILE command:** ```BASIC 10 REM VERY SLOWLY CLEAR THE SCREEN IN STYLE @@ -1687,7 +2287,7 @@ However, it can also be used if VERA Layer 1's map base value is changed or the In the default text modes, this can be used to retrieve the color attribute (fg/bg) of a specific coordinate without needing to calculate the VRAM address for VPEEK. -**EXAMPLE of TATTR command:** +**EXAMPLE of the TATTR command:** ```BASIC 10 REM COPY BUTTERFLY LOGO WITH COLORS TO CENTER OF 80X60 SCREEN @@ -1709,7 +2309,7 @@ In the default text modes, this can be used to retrieve the color attribute (fg/ In the default text modes, this can be used to retrieve the character a specific coordinate without needing to calculate the VRAM address for VPEEK. -**EXAMPLE of TATTR command:** +**EXAMPLE of the TATTR command:** ```BASIC 10 REM COPY BUTTERFLY LOGO TO CENTER OF 80X60 SCREEN @@ -1733,7 +2333,7 @@ In addition, VPEEK can reach add-on VERA cards with higher bank numbers. BANK 2-3 is for IO3 (VERA at \$9F60-\$9F7F) BANK 4-5 is for IO4 (VERA at \$9F80-\$9F9F) -**EXAMPLE of VPEEK Function:** +**EXAMPLE of the VPEEK Function:** ```BASIC PRINT VPEEK(1,$B000) : REM SCREEN CODE OF CHARACTER AT 0/0 ON SCREEN @@ -1751,7 +2351,7 @@ In addition, VPOKE can reach add-on VERA cards with higher bank numbers. BANK 2-3 is for IO3 (VERA at \$9F60-\$9F7F) BANK 4-5 is for IO4 (VERA at \$9F80-\$9F9F) -**EXAMPLE of VPOKE Statement:** +**EXAMPLE of the VPOKE Statement:** ```BASIC VPOKE 1,$B000+1,1 * 16 + 2 : REM SETS THE COLORS OF THE CHARACTER From b9079439ee7b54772c0ecbe44c29d7debfa1a7c6 Mon Sep 17 00:00:00 2001 From: geneb Date: Sat, 17 Jan 2026 12:05:04 -0800 Subject: [PATCH 02/13] WIP: Completed to the NEXT statement. --- X16 Reference - 04 - BASIC.md | 239 +++++++++++++++++++++++++++++++--- 1 file changed, 218 insertions(+), 21 deletions(-) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index baa8ca3..69ede98 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -87,7 +87,7 @@ for GitHub's Markdown flavor. Do not remove! | [`FRAME`](#frame) | Command | Draws an unfilled rectangle in graphics mode | X16 | | [`FRE`](#fre) | Function | Returns the number of unused BASIC bytes free | C64 | | [`GET`](#get) | Statement | Polls the keyboard cache for a single keystroke | C64 | -| [`GET#`](#get) | I/O Statement | Polls an open logical file for a single character | C64 | +| [`GET#`](#get-1) | I/O Statement | Polls an open logical file for a single character | C64 | | [`GOSUB`](#gosub) | Statement | Jumps to a BASIC subroutine | C64 | | [`GOTO`](#goto) | Statement | Branches immediately to a line number | C64 | | [`HELP`](#help) | Command | Displays a brief summary of online help resources | X16 | @@ -95,31 +95,31 @@ for GitHub's Markdown flavor. Do not remove! | [`I2CPEEK`](#i2cpeek) | Function | Reads a byte from a device on the I²C bus | X16 | | [`I2CPOKE`](#i2cpoke) | Command | Writes a byte to a device on the I²C bus | X16 | | [`IF-THEN`](#if-then) | Statement | Tests a boolean condition and branches on result | C64 | -| `INPUT` | Command | Reads a line or values from the keyboard | C64 | -| `INPUT#` | Command | Reads lines or values from a logical file | C64 | -| `INT` | Function | Discards the fractional part of a number | C64 | -| [`JOY`](#joy) | Function | Reads gamepad button state | X16 | +| [`INPUT`](#input) | Statement | Reads a line or values from the keyboard | C64 | +| [`INPUT#`](#input-1) | I/O Statement | Reads lines or values from a logical file | C64 | +| [`INT`](#int) | Integer Function | Discards the fractional part of a number | C64 | +| [`JOY`](#joy) | Integer Function | Reads gamepad button state | X16 | | [`KEYMAP`](#keymap) | Command | Changes the keyboard layout | X16 | -| `LEFT$` | Function | Returns a substring starting from the beginning of a string | C64 | -| `LEN` | Function | Returns the length of a string | C64 | -| `LET` | Command | Explicitly declares a variable | C64 | +| [`LEFT$`](#left) | String Function | Returns a substring starting from the beginning of a string | C64 | +| [`LEN`](#len) | Integer Function | Returns the length of a string | C64 | +| [`LET`](#let) | Statement | Explicitly declares a variable | C64 | | [`LINE`](#line) | Command | Draws a line in graphics mode | X16 | | [`LINPUT`](#linput) | Command | Reads a line from the keyboard | X16 | | [`LINPUT#`](#linput-1) | Command | Reads a line or other delimited data from an open file | X16 | | [`LIST`](#list) | Command | Outputs the program listing to the screen | C64 | -| `LOAD` | Command | Loads a program from disk into memory | C64 | +| [`LOAD`](#load) | Command | Loads a program from disk into memory | C64 | | [`LOCATE`](#locate) | Command | Moves the text cursor to new location | X16 | -| `LOG` | Function | Returns the natural logarithm of a number | C64 | +| [`LOG`](#log) | Floating-Point Function | Returns the natural logarithm of a number | C64 | | [`MENU`](#menu) | Command | Invokes the Commander X16 utility menu | X16 | -| `MID$` | Function | Returns a substring from the middle of a string | C64 | +| [`MID$`](#mid) | String Function | Returns a substring from the middle of a string | C64 | | [`MOD`](#mod) | Function | Returns the truncated remainder of a division | X16 | | [`MON`](#mon) | Command | Enters the machine language monitor | X16 | | [`MOUSE`](#mouse) | Command | Hides or shows mouse pointer | X16 | | [`MOVSPR`](#movspr) | Command | Set the X/Y position of a sprite | X16 | | [`MX/MY/MB`](#mxmymb) | variable | Reads the mouse position and button state | X16 | | [`MWHEEL`](#mwheel) | variable | Reads the mouse wheel movement | X16 | -| `NEW` | Command | Resets the state of BASIC and clears program memory | C64 | -| `NEXT` | Command | Declares the end of a loop construct | C64 | +| [`NEW`](#new) | Command | Resets the state of BASIC and clears program memory | C64 | +| [`NEXT`](#next) | Statement | Declares the end of a loop construct | C64 | | `NOT` | Operator | Bitwise or boolean inverse | C64 | | [`OLD`](#old) | Command | Undoes a NEW command or warm reset | X16 | | `ON` | Command | A GOTO/GOSUB table based on a variable value | C64 | @@ -392,7 +392,7 @@ LIST READY. ``` -### BIN$ +### BIN$ **TYPE: String Function** **FORMAT: BIN$(n)** @@ -601,7 +601,7 @@ CLS **TYPE: I/O Statement** **FORMAT: CMD <file number>[, string]** -**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, tape, a printer, or an I/O device like the modem[^nomodem]. The file number must be specified in a prior `OPEN` statemewnt. The string, when specified, is sent to the file. This is handy +**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem[^nomodem]. The file number must be specified in a prior `OPEN` statemewnt. The string, when specified, is sent to the file. This is handy for titling printouts, etc. When this command is in effect, any `PRINT` statements and `LIST` commands will not display on the screen, but will send the text in the same format to the file. @@ -1195,7 +1195,7 @@ The `GET` statement can be used to avoid some of the limitations of the `INPUT` [^missing_pt]: There is no Programming Techniques section currently. -### GET#** +### GET# **TYPE: I/O Statement** **FORMAT: GET# <file number>, <variable list>** @@ -1352,6 +1352,63 @@ The `IF` in line 20 tests a random number to see if it is less than .5. When the result is true, the whole series of statements following the word `THEN` are executed: first `X` is incremented by 1, then the program skips to line 40. When the result is false, the program drops to the next statement, line 30. +### INPUT + +**TYPE: Statement** +**FORMAT: INPUT ["<prompt>"] <variable list>** + +**Action:** This is a statement that lets the person `RUN`ning the program "feed" information into the computer. When executed, this statement `PRINT`s a question mark `(?)` on the screen, and positions the cursor 1 space to the right of the question mark. Now the computer waits, cursor blinking, for the operator to type in the answer and press the **RETURN** key. + +The word `INPUT` may be followed by any text contained in quote marks `(" ")`. This text is `PRINT`ed on the screen, followed by the question mark. + +After the text comes a semicolon `(;)` and the name of one or more variables separated by commas. This variable is where the computer stores the information that the operator types. The variable can be any legal variable name, and you can have several different variable names, each for a different input. + +**EXAMPLES of the INPUT Statement:** +```BASIC +10 INPUT R +20 INPUT E, X, I$ +30 INPUT "ENTER ANSWER"; A$(42) +``` +When this program `RUN`s, the quesiton mark appears to prompt the operator that the Commander X16 is expecting an input for line 30. Any number typed goes into A for later use in the program. If the anwser typed was not a number, the `?REDO FROM START` message appears, which means that a string was entered when a number was expected. If the operator just hits **RETURN** without typing anything, the variable's value doesn't change. + +Now the question mark for line 20, appears. If we type only one number and hit **RETURN**, the Commander X16 will now display 2 question marks `(??)`, which means that more input is required. You can just type as many inputs as you need, separated by commas, which prevents the double question mark from appearing. If you type more data than the `INPUT` statement requested, the `?EXTRA IGNORED` message appears, which means that the extra items you typed were not put into any variables. + +Line 30 displays the words ENTER ANSWER before the question mark appears. The semicolon is required between the prompt and any list of variables. + +The `INPUT` statement can never be used outside a program. The Commander X16 needs space for a buffer for the `INPUT` variables, the same space that is used for commands. + +### INPUT# + +**TYPE: I/O Statement** +**FORMAT: INPUT# <file number>, <variable list>** + +**Action:** This is usually the fastest and easiest way to retrieve data stored in a file on disk. The data is in the form of whole variables of up to 80 characters in length, as opposed to the one-at-a-time method of `GET#`. First, the file must have been `OPEN`ed, then `INPUT#` can fill the variables. + +The `INPUT#` command assumes a variable is finished when it reads a `RETURN` code (`CHR$`(13)), a comma `(,)`, or colon `(:)`. Quote marks `(")` can be used to enclose these characters when writing if they are needed (see the `PRINT#` statement). + +If the variable type used is numeric, and non-numeric characters are received, a `BAD DATA` error results. `INPUT#` can read strings up to 80 characters long, beyond which a `?STRING TOO LONG` error results. + +When used with device #3 (the screen), this statement will read an entire logical line and move the cursor down to the next line. + +**EXAMPLES of the INPUT# Statement:** +```BASIC +10 INPUT# 1, FR +20 INPUT# 2, X$, Y$ +``` + +### INT + +**TYPE: Integer Function** +**FORMAT: INT(<numeric>)** + +**Action:** Returns the integer value of the expression. If the expression is positive, the fractional part is left off. If the expression is negative, any fraction causes the next lower integer to be returned. + +**EXAMPLES of the INT Function:** +```BASIC +10 PRINT INT(102.4242), INT(-16.702) +RUN + 102 -17 +``` ### JOY @@ -1412,6 +1469,52 @@ Note that this bitfield is different from the `joystick_get` KERNEL API one. Als SAVE"AUTOBOOT.X16" :REM SAVE AS AUTOBOOT FILE ``` +### LEFT$ + +**TYPE: String Function** +**FORMAT: LEFT$(<string>, <integer>)** + +**Action:** Returns a string comprised of the leftmost <integer> chracters of the <string>. The integer argument value must be in the range 0 to 255. If the integer is greater than the length of the string, the entire string will be returned. If an <integer> value of zero is used, then a null string (of zero length) is returned. + +**EXAMPLES of the LEFT$ Function:** +```BASIC +10 X$ = "COMMANDER X16 COMPUTER" +20 C$ = LEFT$(X$, 9): PRINT C$ +RUN + +COMMANDER +``` + +### LEN + +**TYPE: Integer Function** +**FORMAT: LEN(<string>)** + +**Action:** Returns the number of chracters in the string expression. Non-printed characters and blanks are counted. + +**EXAMPLE of the LEN Function:** +```BASIC +10 CX$ = "COMMANDER X16 COMPUTER" +20 PRINT LEN(CX$) +RUN + 22 +``` + +### LET + +**TYPE: Statement** +**FORMAT: [LET] <variable> = <expression>** + +**Action:** The `LET` statement can be used to assign a value to a variable. However, the word `LET` is optional and therefore most advanced programmers leave `LET` out because it's aways understood and wastes valuable memory. The equal sign `(=)` alone is sufficient when assigning the value of an expression to a variable name. + +**EXAMPLES of the LET Statement:** +```BASIC +10 LET A = 42 : REM This is the same as A=12 +20 LET A$ = "123" +30 B$ = "WIDGETS" +40 ANS$ = A$ + " " + B$ : REM ANS$ would equal "123 WIDGETS" +``` + ### LINE **TYPE: Command** @@ -1496,7 +1599,7 @@ The above example parses and prints out the filenames from a directory listing. The start and ending line numbers are both optional. The start and/or end may be specified. If both are specified, a hyphen must -be included. So LIST has 4 modes: +be included. So `LIST` has 4 modes: `LIST` by itself will display the entire program. @@ -1506,15 +1609,31 @@ be included. So LIST has 4 modes: `LIST 50-` will display line 50 to the end of the program. -Pressing the `CONTROL` key during a listing will slow the listing down once +Pressing the **CTRL** key during a listing will slow the listing down once printing reaches the bottom of the screen. Approximately one line per second will -be displayed. +be displayed. `LIST` is aborted by hitting the **RUN/STOP** key. -Pressing the `SPACE BAR` during the listing will cause the listing to pause. -Pressing the `SPACE BAR` a second time will unpause the listing. You may also +Pressing the **SPACE BAR** during the listing will cause the listing to pause. +Pressing the **SPACE BAR** a second time will unpause the listing. You may also use the down arrow key to scroll by one line or use the `PgDn` key to scroll approximately one screen full of text. +### LOAD + +**TYPE: Command** +**FORMAT: LOAD ["<filename>"][,<device>][,<address>]** + +**Action:** The `LOAD` statement reads the contents of a program file from disk into memory. That way you can use the information `LOAD`ed or change the information in some way. The device number is optional, but when it is left out, the Commander X16 will automatically default to 8, the first disk device. The `LOAD` command closes all open files and if it is used in direct mode, it performs a `CLR` (clear) before reading the program. If `LOAD` is executed from within a program, the program is `RUN`. this means that you can use `LOAD` to "chain" several programs together. None of the variables are cleared during a chain operation. + +If you are using file name pattern matching, the first file which matches the pattern is loaded. The asterisk in quotes by itself `("*")` causes the first file name in the disk directory to be loaded. If the file name used does not or if it is not a program, the BASIC error message `?FILE NOT FOUND` occurs. + +Programs will `LOAD` starting at memory location $0801 (hex) unless a secondary <address> of 1 is used. If you use the secondary address of 1 this will cause the program to `LOAD` to the memory loction from which it was saved. + +**EXAMPLES of the LOAD Command:** +- LOAD FN$ (uses the contents of FN$ to load from disk) +- LOAD "*",8 (loads the first program from device 8) +- LOAD "GAME",8,1 (loads "GAME" into the same memory address it was saved from) + ### LOCATE **TYPE: Command** @@ -1538,6 +1657,40 @@ The values are 1-based. If no column is given, only the line is changed. 190 NEXT ``` +### LOG + +**TYPE: Floating-Point Function** +**FORMAT: LOG(<numeric>)** + +**Action:** Returns the natural logarithm (log to the base of e) of the argument. If the value of the argument is zero or negative, the BASIC error message `?ILLEGAL QUANTITY` will occur. + +**EXAMPLES of the LOG Function:** +```BASIC +10 PRINT LOG(42/9) +RUN + 1.54044504 + +10 NUM = LOG(ARG) / LOG(10): REM Calculates the LOG of ARG to the base 10) +``` + +### MID$ + +**TYPE: String Function** +**FORMAT: MID$(<string>, <numeric-1>[,<numeric-2>])** + +**Action:** The `MID$` function returns a sub-string which is taken from within a larger <string> argument. The starting position of the sub-string is defined by the <numeric-1> argument and the length of the sub-string by the <numeric-2> argument. Both of the numeric arguments can have values ranging from 0 to 255. + +If the <numeric-1> value is greater than the length of the <string>, or if the <numeric-2> value is zero, then `MID$` gives a null string value. If the <numeric-2> is left out, then the computer will assume that a length of the rest of the string is to be used. And if the source string has fewer characters than <numeric-2>, from the starting position to the end of the string argument, then the whole rest of the string is used. + +**EXAMPLE of the MID$ Function:** +```BASIC +10 G$ = "GOOD" +20 A$ = "MORNING EVENING AFTERNOON" +30 PRINT G$ + MID$(A$, 8, 8) +RUN +GOOD EVENING +``` + ### MENU **TYPE: Command** @@ -1675,6 +1828,50 @@ REM SIMPLE DRAWING PROGRAM **Action:** Return the mouse scroll wheel movement since the value was last read. The value is negative if the scroll wheel is moved away from the user, and positive if it is moved towards the user. The range of the returned value is -128 to +127. +### NEW + +**TYPE: Command** +**FORMAT: NEW** + +**Action:** The `NEW` command is used to delete the program currently in memory and clear all variables. Before typing in a new program, `NEW` should be used in direct mode to clear memory. `NEW` can also be used in a program, but you should be aware of the fact that it will erase everything that has gone before and is still in the computer's memory. This can be particularly troublesome when you're trying to debug your program. + +> **BE CAREFUL**: Not clearing out an old program before typing a new one can result in a confusing mix of the two programs. + +**EXAMPLES of the NEW Command:** +```BASIC +NEW : REM Clears the program and all variables) +10 NEW : REM Performs a NEW operation and STOPs the program. +``` + +### NEXT + +**TYPE: Statement** +**FORMAT: NEXT [<counter>],[<counter>]...** + +**Action:** The `NEXT` statement is used with `FOR` to establish the end of a `FOR`...`NEXT` loop. The `NEXT` need not be physically the last statement in the loop, but it is always the last statement executed in a loop. The <counter> is the loop index's variable name used with `FOR` to start the loop. A single `NEXT` can stop several nested loops when it is followed by each `FOR`'s <counter> variable name(s). to do this each name must appear in the order of inner-most nested loop first, to outer-most nested loop last. When using a single `NEXT` to increment and stop several variable names, each variable name must be separated by commas. Loops can be nested to 9 levels. If the counter variable(s) are omitted, the counter associated with the `FOR` of the current level (of the nested loops) is incremented. + +When the `NEXT` is reached, the counter value is incremented by 1 or by an optional `STEP` value. It is then tested against an end-value to see if it's time to stop the loop. A loop will be stopped when a `NEXT` is found which has its counter value greater than the end-value. + +**EXAMPLES of the NEXT Statement:** +```BASIC +10 FOR A=1 TO 5: FOR B=10 TO 20: FOR C=5 TO -10 STEP -1 +20 NEXT C, B, A : REM Stopping nested loops + +10 FOR A = 1 TO 100 +20 FOR B = 1 TO 10 +30 NEXT B +500 NEXT A : REM Note how the loops do NOT cross each other. + +10 FOR Z = 1 TO 10 +20 FOR X = 1 TO 20 +30 NEXT +40 NEXT : REM Notice that no variable names are needed +``` + +### NOT + + + ### OLD **TYPE: Command** From 3ff78eef65cc12e7ef6cf611919f2868c48df560 Mon Sep 17 00:00:00 2001 From: geneb Date: Sun, 18 Jan 2026 10:45:55 -0800 Subject: [PATCH 03/13] WIP: Added images for the PRINT command. --- X16 Reference - 04 - BASIC.md | 196 +++++++++++++++++++++++++++++++--- images/rvs-Q.png | Bin 0 -> 611 bytes images/rvs-S.png | Bin 0 -> 646 bytes images/rvs-ball.png | Bin 0 -> 498 bytes images/rvs-bar.png | Bin 0 -> 430 bytes images/rvs-heart.png | Bin 0 -> 619 bytes images/rvs-r-bracket.png | Bin 0 -> 496 bytes 7 files changed, 183 insertions(+), 13 deletions(-) create mode 100644 images/rvs-Q.png create mode 100644 images/rvs-S.png create mode 100644 images/rvs-ball.png create mode 100644 images/rvs-bar.png create mode 100644 images/rvs-heart.png create mode 100644 images/rvs-r-bracket.png diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index 69ede98..e6ca979 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -120,17 +120,17 @@ for GitHub's Markdown flavor. Do not remove! | [`MWHEEL`](#mwheel) | variable | Reads the mouse wheel movement | X16 | | [`NEW`](#new) | Command | Resets the state of BASIC and clears program memory | C64 | | [`NEXT`](#next) | Statement | Declares the end of a loop construct | C64 | -| `NOT` | Operator | Bitwise or boolean inverse | C64 | +| [`NOT`](#not) | Logical Operator | Bitwise or boolean inverse | C64 | | [`OLD`](#old) | Command | Undoes a NEW command or warm reset | X16 | -| `ON` | Command | A GOTO/GOSUB table based on a variable value | C64 | -| `OPEN` | Command | Opens a logical file to disk or other device | C64 | -| `OR` | Operator | Bitwise or boolean "OR" | C64 | +| [`ON`](#on) | Statement | A GOTO/GOSUB table based on a variable value | C64 | +| [`OPEN`](#open) | I/O Statement | Opens a logical file to disk or other device | C64 | +| [`OR`](#or) | Logical Operator | Bitwise or boolean "OR" | C64 | | [`OVAL`](#oval) | Command | Draws a filled oval in graphics mode | X16 | | [`PEEK`](#peek) | Function | Returns a value from a memory address | C64 | | `π` | Function | Returns the constant for the value of pi | C64 | | [`POINTER`](#pointer) | Function | Returns the address of a BASIC variable | C128 | | [`POKE`](#poke) | Command | Assigns a value to a memory address | C64 | -| `POS` | Function | Returns the column position of the text cursor | C64 | +| [`POS`](#pos) | Integer Function | Returns the column position of the text cursor | C64 | | [`POWEROFF`](#poweroff) | Command | Immediately powers down the Commander X16 | X16 | | `PRINT` | Command | Prints data to the screen or other output | C64 | | `PRINT#` | Command | Prints data to an open logical file | C64 | @@ -601,7 +601,7 @@ CLS **TYPE: I/O Statement** **FORMAT: CMD <file number>[, string]** -**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem[^nomodem]. The file number must be specified in a prior `OPEN` statemewnt. The string, when specified, is sent to the file. This is handy +**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem1. The file number must be specified in a prior `OPEN` statemewnt. The string, when specified, is sent to the file. This is handy for titling printouts, etc. When this command is in effect, any `PRINT` statements and `LIST` commands will not display on the screen, but will send the text in the same format to the file. @@ -625,7 +625,7 @@ PRINT# 4: CLOSE 4: REM Un-listens and closes printer 70 CLOSE 1 : REM Write remaining buffer contents, close file. ``` -[^nomodem]: Device #2 (RS-232) support has been removed from the X16 KERNAL. +* 1 Device #2 (RS-232) support has been removed from the X16 KERNAL. ### COLOR @@ -1183,7 +1183,7 @@ PRINT FRE(0) - (FRE(0) < 0) * 65536 If the `GET` statement specifies numeric data, and the user types a key other than a number, the message `?SYNTAX ERROR` appears. To be safe, read the keys as strings and convert them to numbers later. -The `GET` statement can be used to avoid some of the limitations of the `INPUT` statement. For more on this, see the section on Using the `GET` Statement in the Programming Techniques[^missing_pt] section. +The `GET` statement can be used to avoid some of the limitations of the `INPUT` statement. For more on this, see the section on Using the `GET` Statement in the Programming Techniques2 section. **EXAMPLES of the GET Statement:** @@ -1193,7 +1193,7 @@ The `GET` statement can be used to avoid some of the limitations of the `INPUT` 30 GET B, B$ : REM Reads a number key (0..9) and any key. ``` -[^missing_pt]: There is no Programming Techniques section currently. +* 2: There is no Programming Techniques section currently. ### GET# @@ -1621,7 +1621,7 @@ approximately one screen full of text. ### LOAD **TYPE: Command** -**FORMAT: LOAD ["<filename>"][,<device>][,<address>]** +**FORMAT: LOAD ["<filename>"][,<device>][,<address>] LOAD ["<filename>"][,<device>][,<ram bank>, <start address>] ** **Action:** The `LOAD` statement reads the contents of a program file from disk into memory. That way you can use the information `LOAD`ed or change the information in some way. The device number is optional, but when it is left out, the Commander X16 will automatically default to 8, the first disk device. The `LOAD` command closes all open files and if it is used in direct mode, it performs a `CLR` (clear) before reading the program. If `LOAD` is executed from within a program, the program is `RUN`. this means that you can use `LOAD` to "chain" several programs together. None of the variables are cleared during a chain operation. @@ -1629,10 +1629,15 @@ If you are using file name pattern matching, the first file which matches the pa Programs will `LOAD` starting at memory location $0801 (hex) unless a secondary <address> of 1 is used. If you use the secondary address of 1 this will cause the program to `LOAD` to the memory loction from which it was saved. +If using the second form of the `LOAD` command, <ram bank> sets the back for the load, and <start address> is the location where your data will be `LOAD`ed into. + +The value of the <ram bank> argument only affects the `LOAD` when the <start address> is set in the range of `$A000-$BFFF`. + **EXAMPLES of the LOAD Command:** - LOAD FN$ (uses the contents of FN$ to load from disk) - LOAD "*",8 (loads the first program from device 8) - LOAD "GAME",8,1 (loads "GAME" into the same memory address it was saved from) +- LOAD "MUSIC.BIN",8,1,$A000 (loads a file into banked RAM, RAM bank 1, starting at $A000. The first two bytes of the file are skipped. To avoid skipping the first two bytes, use the `BLOAD` command instead.) ### LOCATE @@ -1870,7 +1875,44 @@ When the `NEXT` is reached, the counter value is incremented by 1 or by an optio ### NOT +**TYPE: Logical Operator** +**FORMAT: NOT <expression>** + +**Action:** The `NOT` logical operator "complements" the value of each bit in its single operand, producing an integer "two's complement" result. In other words, the `NOT` is really saying, "if it isn't...". When working with a floating-point number, the operands are converted to integers and any fractions are lost. The `NOT` operator can also be used in a comparison to reverse the true/false value which was the result of a relationship test and therefore it will reverse the meaning of the comparison. In the first example below, if the "two's complement" of "I" is equal to "D" and if "D" is `NOT` equal to "JA" then the expression is true. + +**EXAMPLES of the NOT Operator:** +```BASIC +10 IF NOT I = D AND NOT (D=JA) THEN... + +IA% = NOT 42 : PRINT IA% +-43 +``` + +> **NOTE:** To find the value of `NOT` use the expression X = (-(X+1)). (The two's complement of any integer is the bit complement plus one.) + +### ON + +**TYPE: Statement** +**FORMAT: ON <variable> GOTO / GOSUB <line number> [,<line number>]...** +**Action:** The `ON` statement is used to `GOTO` or `GOSUB` to one of several given line numbers, depending on the value of a variable. The value of the variables can range from zero through the number of lines given. If the value is a non-integer, the fractional portion is left off. for example, if the variable value is 3, `ON` will `GOTO` (or `GOSUB`) the third line number in the list. + +If the value of the variable is negative, the BASIC error message `?ILLEGAL QUANTITY` occurs. If the number is zero, or greater than the number of items in the list, the program just ignores the statement and continues with the statement following the `ON` statement. + +`ON` is really an underused variant of the `IF...THEN...` statement. Instead of using a qhole lot of `IF` statements each of which sends the program to one specific line, one `ON` statement can replace a list of `IF` statements. When you look at the first example you should notice that the one `ON` statement replaces four `IF...THEN...` statements. + +**EXAMPLES of the ON Statement:** +```BASIC +ON -(X=2) - 2 * (X=6) - 3 * (X < 3) - 4 * (X > 7) GOTO 400, 900, 1000, 100 + +ON A GOTO 100,130,180,220 + +ON Z+7 GOSUB 4800, 230, 4800 + +100 ON NUM GOTO 250, 350, 320, 490 + +500 ON SUM / 2 + 1 GOSUB 100, 900, 50 +``` ### OLD @@ -1885,6 +1927,63 @@ When the `NEXT` is reached, the counter value is incremented by 1 or by an optio OLD ``` +### OPEN + +**TYPE: I/O Statement** +**FORMAT: OPEN <file number>, <device> [, <address>] [, "<file name> [,<type>][, <mode>]"]** + +**Action** This statement `OPEN`s a channel for input and/or output to a peripheral device. however, you may NOt need all those ports for every `OPEN` statement. Some `OPEN` statements require only two codes: + +- LOGICAL FILE NUMBER +- DEVICE NUMBER + +The <file number> is the logical file number, which relates to the `OPEN`, `CLOSE`, `CMD`, `GET#`, `INPUT#`, and `PRINT#` statements to each other and associates them with the file name and the piece of equipment being used. The logical file number can range from 1 to 255 and you can assign it any number you want in that range. + +> **NOTE:** File numbers over 128 were really designed for other uses, so it's good practice to use only numbers below 127 for file numbers. + +Each peripheral device (printer, disk drive, etc) in the system has its own number which it answers to. The <device> number is used with `OPEN` to specify on which device the data file exists. Peripherals like disk drives or printers also answer to several secondary addresses. Think of these as codes which tell each device what operation to perform. The device logical file number is used with every `GET#`, `INPUT#`, and `PRINT#`. + +If the <device> number is left out the Commander X16 will automatically assume that you want to talk to device #1, which has traditionally been assigned to the tape device. Since the Commander X16 has no support for the tape device, I/O statements that reference it may operate with no error, but no actual work will be done. Because of this, it should be assumed that specifying the device address is NOT optional. + +For disk files, the secondary addresses 2 through 14 are available for data files, but other numbers have special meanings for DOS commands. You must use a secondary address when using your disk drive(s)3. + +The <file name> is a string of 1 to 16 characters and is optional for printer files. If the file <type> is left out, the type of file will automatically default to the Program (PRG) file type unless the <mode> is given. Sequential (SEQ) files are `OPEN`ed for reading (<mode>=R) unless you specify that files should be `OPEN`ed for writing (<mode>=W) A file <type> can be used to `OPEN` an existing Relative file. Use **REL** for <type> with Relative files. Relative and Sequential files are for disk only. + +> **NOTE:** Sequential files written outside of a disk image (.D64, .D81, etc) will appear as **PRG** files when viewing the file listing of the SD card. This is because the FAT32 file system used by the SD card does not differentiate between file types. + +If you try to access a file before it is `OPEN`ed the BASIC error message `?FILE NOT OPEN` will occur. If you try to `OPEN` a file for reading which does not exist the BASIC error message `?FILE NOT FOUND` will occur. If a file is `OPEN`ed to disk and the file name already exists, the DOS error message `FILE EXISTS` occurs. If a file is `OPEN`ed that is already `OPEN`, the BASIC error message `FILE OPEN` occurs. + +**EXAMPLES of the OPEN Statement:** +- OPEN 2, 8, 2, "TEXT FILE, SEQ, W" (opens a sequential file on disk) +- OPEN 50, 0 (keyboard input) +- OPEN 4, 3 (screen output) +- OPEN 75, 4 (printer output) +- OPEN 1, 8, 15, "COMMAND" (send a command to a disk device) + + +


+> 3: Reminder to add a discussion about manipulating disk files. + +### OR + +**TYPE: Logical Operator** +**FORMAT: <operand> OR <operand>** + +**Action:** Just as the relational operators can be used to make decisions regarding program flow, logical operators can connect two or more relations and return a true or false value which can then be used in a decision. When used in calculations, the logical `OR` gives you a bit result of 1 if the corresponding bit of either, or both, operands is 1. This will produce an integer as a result, depending on the values of the operands. + +When used in comparisons the logical `OR` operator is also used to link two expressions into a single compound expression. If either of the expressions are true, the combined expression value is true (-1). In the first example below, if AA is equal to BB `OR` if XX is 20, the expression is true. + +Logical operators work by converting their operands to 16 bit, signed, two's complement integers in the range of -32768 to +32767. If the operands are not in that range, an error message results. Each bit of thee result is determined by the corresponding bits in the two operands. + +**EXAMPLES of the OR Operator:** +```BASIC +10 IF (AA=BB) OR (XX=20) THEN... + +50 KK% = 64 OR 32: PRINT KK% +RUN + 96 (64 has a bit value of 1000000 and 100000 for 32. ORing the two together results in 1100000 or 96 decimal) +``` + ### OVAL **TYPE: Command** @@ -1904,12 +2003,12 @@ The coordinate arguments define the rectangular bounding box of the oval. To dra ### PEEK -**TYPE: Command** +**TYPE: Integer Function** **FORMAT: PEEK(<address>)** **Action:** Returns the value at given memory address -PEEKing values within the BRAM (`$A000`) and KERNAL/Cartridge (`$C000`) +`PEEK`ing values within the BRAM (`$A000`) and KERNAL/Cartridge (`$C000`) requires using `BANK` to set the banks accordingly. **EXAMPLE of the PEEK function:** @@ -1937,7 +2036,7 @@ RUN ### POKE -**TYPE: Function** +**TYPE: Statement** **FORMAT: POKE <address>, <value>** **Action:** Sets the contents of the memory address to given value. @@ -1957,6 +2056,18 @@ called with appropriate arguments. 10 POKE $A000,47 ``` +### POS + +**TYPE: Integer Function** +**FORMAT: POS(<dummy>)** + +**Action:** Tells you the current cursor position which, of course, is in the range of 0 (leftmost character) through position 79 on an 80 character logical screen line. If the Commander X16 is in 40 column mode, any position from 40 to 79 will refer to the second screen line. The <dummy> argument is ignored. + +**EXAMPLE of the POS Function:** +```BASIC +10 IF POS(0) > 38 THEN PRINT CHR$(13) +``` + ### POWEROFF **TYPE: Command** @@ -1970,6 +2081,65 @@ called with appropriate arguments. POWEROFF ``` +### PRINT + +**TYPE: Statement** +**FORMAT: PRINT [<variable>][<,/;><variable>]...** + +**Action:** The `PRINT` statement is normally used to write data items to the screen. However, the `CMD` statement may be used to redirect that output to any other device in the system. The <variable(s)> in the output-list are expressions of any type. If no output-list is present, a blank line is printed. The position of each printed item is determined by the punctuation used to separate items in the output-list. + +The punctuation characters that you can use are blanks, commas, or semicolons. the 80 character logical screen line is divided into 8 print zones of 10 spaces each. In the list of expressions, a comma causes the next value to be printed at the beginning of the next zone. A semicolon causes the next value to be printed immediately following the previous value. However, there are two exceptions to this rule: + +1. Numeric items are followed by an added space. +2. Positive numbers have a space preceding them. + +When you use blanks or no punctuation between string constants or variable names, it has the same effect as a semicolon. However, blanks between a string and a numeric item or between two numeric items will stop output without printing the second item. + +If a comma or a semicolon is at the end of the output-list, the next `PRINT` statement begins printing on the same line, and spaced accordingly. If no punctuation finishes the list, a carriage-return and a line-feed are printed at the end of the data. The next `PRINT` statement will begin on the next line. If your output is directed to the screen and the data printed is longer than 40 columns, the output is continued on the next screen line. + +There is no statement in BASIC with more variety than the `PRINT` statement. There are so many symbols, functions, and parameters associated with this statement that it might almost be considered as a language of its own within BASIC; a language specially designed for writing on the screen. + +**EXAMPLES of the PRINT Statement:** + +```BASIC +10 X = 10 +20 PRINT -5 * X, X - 5, X + 5, X / 5 +RUN +-50 5 15 2 +``` +```BASIC +10 X = 9 +20 PRINT X; "SQUARED IS";X * X;"AND"; +30 PRINT X "MULTIPLIED BY 19 IS" X * 19 +RUN + 9 SQUARED IS 81 AND 9 MULTIPLIED BY 19 IS 171 +``` +```BASIC +10 A$(1)="ALPHA":A$(2)="BRAVO":A$(3)="CHARLIE":A$(4)="DELTA":A$(5)="ECHO" +20 PRINT A$(1)A$(2);A$(3) A$(4),A$(5) +RUN +ALPHABRAVOCHARLIEDELTA ECHO +``` +**Quote Mode** + +Once the quote mark ( **SHIFT** **2** ) is typed, the cursor controls stop operating and start displaying reversed characters which actually stand for the cursor control you are hitting. This allows you to program these cursor controls, because once the text inside the quotes is `PRINT`ed, they perform their functions. The **INST/DEL** key is the only cursor control not affected by "quote mode". + +**1. Cursor Movement** + +The cursor controls which can be "programmed" in quote mode are: + +| **KEY** | **APPEARS AS** | +|---------:|:----------------:| +| **CLR/HOME** | [Reverse S](images/rvs-S.png) | +| **SHIFT** **CLR/HOME** | [Reverse Heart](images/rvs-heart.png) | +| **↑CRSR↓** | [Reverse S](images/rvs-Q.png) | +| **SHIFT** **↑CRSR↓** | [Reverse Ball](images/rvs-ball.png) | +| **←CRSR→** | [Reverse Left Bracket](images/rvs-r-bracket.png) | +| **SHIFT** **←CRSR→** | [Reverse Bar](images/rvs-bar.png) | + + + + ### PSET **TYPE: Command** diff --git a/images/rvs-Q.png b/images/rvs-Q.png new file mode 100644 index 0000000000000000000000000000000000000000..8cecf55747515fecbefe06ed1300107bbf7dd71e GIT binary patch literal 611 zcmeAS@N?(olHy`uVBq!ia0vp^vLMXC3?vhMr`rN4#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6-P0X`wF|NsAg{P^+w`STASKD>JM>MdKg0A&&q5)>2^7#SJm<>mM8-TUFg zhx_;M|Ni~Eq@+YdM1-50`^%RvU0q!-U%veF=TCos|APk)e*E|`W5$f_+qeJv_3Pii zf9dJz?Ck8Orl#KB-US5(7cN{VEG(3jl?@LMKXT-VpP%1?(8KqEHgOhsL>4nJ@ErzW z#^d=bQhX6s4hbT1CXrG`2!xR z{nr-&nSGuvjv*HQZzrA!lvI6<-0X`wF|Ns9#efsqL`STYqUi|y_@71eUA3l7zw6qi`&&|#K<;xcZ1%-r! z1Wry)EiJ9DU%$S1@#6md`_G;|v$3(^;ocG@7Lhz#yK$&cFgxVPIrzz_!lvI6;L0X`wF|NsBryLYdGf`W~W&6X`&fWn1^h4bgnPe@2$VPT1hiMep$!tB|z zxw*N&eEGt`!Leq|nwKwM`c75d3slNk;1OBOz`%DHgc*#k4~UoAr95xj6SNiQ5LU*3;F`Wt~$( F699@(f_MM` literal 0 HcmV?d00001 diff --git a/images/rvs-bar.png b/images/rvs-bar.png new file mode 100644 index 0000000000000000000000000000000000000000..5a128b8d2fa43403f03b0877d59ea0df6dfbcfca GIT binary patch literal 430 zcmeAS@N?(olHy`uVBq!ia0vp^vLMXD3?!HAt+D}9jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCil&0(?ST|NsBLckkXUTee)gcJ1ZMmkJ6BK$+6gQX3na*49?PgFdxDK4*bP zWHAE+-(e7DJf6QI1t=&{;u=vBoS#-wo>-L15RjOeSEA?V8lqsTXQ*eHlXuGwsAgMg zglC$krxpVTki*I##mLIQ2xNHyu{4woa<>K}GgzDn$TnnTVh{k*Q9zv8&H@(C0$Nv;eZ8x(p2r zK(apP4|u5dUta)Z8hg4phG?8mPHzopr0I2+2N&o-= literal 0 HcmV?d00001 diff --git a/images/rvs-heart.png b/images/rvs-heart.png new file mode 100644 index 0000000000000000000000000000000000000000..0052759834b173d7117367a374c781cde6eb2912 GIT binary patch literal 619 zcmeAS@N?(olHy`uVBq!ia0vp^vLMXC3?vhMr`rN4#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;~0X`wF|NsAQZEaOhP|(uS`ug?j%$YO&{QOEvN=i#hfl9c!xxak*($&>v zYHFI0kf5)xKY#xG#fumJ{{8#%<;$BlZ$5nZu(!9jfPjFVo!z%@-x?YkSXo&M3JR`W zyQZU~vt`Sc`uh6!@864yi=R4m>fphHoSd8&E?jU)_J0C2owL9rvY3H^?=T269?xHq z0u+=eag8Vm&QB{TPb^Ah2uRG#E79|F4N)-FGt{%p$-89-RI@EL!ZXd&Q;UHE$YEuW zVq|4t1hTwjH>LQ-Ev`U;>)M1XdYjX#r$Gbr~8MfMk8nAMjA^zrFy- zoayP}7-Hf7^x{dOLka?}7yYbT*g7qaC~|K5{J(w?YskW74rg!eeqA1>!Z2U^f~nN+ z!lvI6<`0X`wF|NsAAy?XWh`STASKK%IcV+92TpiDwS!j>&tLPA3B-@pIk$B$E| zPPw?aynp}R#Kfelt1Brf$gCZIV?V3k3Z7C;tMm!W|HNY>~40T0#w>kEL)5KkA! z5DWk0gaiB%GaVWvBRg1ijvP63;J|@XY)o%XY?4V(G~-iBwcL52L3+22$cLU&eEyMf zdvh{deK7s0xC2wui%mBe5+fB8V;op+>P9dyOf3@7`c@tj0J6)|)z4*}Q$iB} D+=75k literal 0 HcmV?d00001 From de2eb2cecb81285d8821a43a854158e01660e1aa Mon Sep 17 00:00:00 2001 From: geneb Date: Sun, 18 Jan 2026 12:15:13 -0800 Subject: [PATCH 04/13] WIP: Added more graphics and content for the PRINT statement section --- X16 Reference - 04 - BASIC.md | 93 ++++++++++++++++++++++++++++++---- images/norm-lower-bar.png | Bin 0 -> 472 bytes images/rvs-E.png | Bin 0 -> 701 bytes images/rvs-Q.png | Bin 611 -> 826 bytes images/rvs-S.png | Bin 646 -> 912 bytes images/rvs-ball.png | Bin 498 -> 610 bytes images/rvs-bar.png | Bin 430 -> 550 bytes images/rvs-circle.png | Bin 0 -> 657 bytes images/rvs-club.png | Bin 0 -> 797 bytes images/rvs-diamond.png | Bin 0 -> 835 bytes images/rvs-half-tile.png | Bin 0 -> 708 bytes images/rvs-heart.png | Bin 619 -> 816 bytes images/rvs-l-arr.png | Bin 0 -> 746 bytes images/rvs-l-ramp.png | Bin 0 -> 644 bytes images/rvs-pi.png | Bin 0 -> 746 bytes images/rvs-plus-symbol.png | Bin 0 -> 776 bytes images/rvs-pound.png | Bin 0 -> 941 bytes images/rvs-r-bracket.png | Bin 496 -> 683 bytes images/rvs-r-offset-bar.png | Bin 0 -> 529 bytes images/rvs-spade.png | Bin 0 -> 785 bytes images/rvs-ul-corner.png | Bin 0 -> 742 bytes images/rvs-up-arr.png | Bin 0 -> 794 bytes images/rvs-ur-corner.png | Bin 0 -> 502 bytes images/rvs-x-symbol.png | Bin 0 -> 821 bytes 24 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 images/norm-lower-bar.png create mode 100644 images/rvs-E.png create mode 100644 images/rvs-circle.png create mode 100644 images/rvs-club.png create mode 100644 images/rvs-diamond.png create mode 100644 images/rvs-half-tile.png create mode 100644 images/rvs-l-arr.png create mode 100644 images/rvs-l-ramp.png create mode 100644 images/rvs-pi.png create mode 100644 images/rvs-plus-symbol.png create mode 100644 images/rvs-pound.png create mode 100644 images/rvs-r-offset-bar.png create mode 100644 images/rvs-spade.png create mode 100644 images/rvs-ul-corner.png create mode 100644 images/rvs-up-arr.png create mode 100644 images/rvs-ur-corner.png create mode 100644 images/rvs-x-symbol.png diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index e6ca979..ec47541 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -25,6 +25,21 @@ mark { } } +marksq { + background-color: #f5f5f5; + color: #000000; + padding: 0 4px; +} + +/* Dark Mode */ +@media (prefers-color-scheme: dark) { + marksq { + background-color: #f5f5f5; + color: #000000; + padding: 0 4px; + } +} + # Chapter 4: BASIC Programming @@ -132,8 +147,8 @@ for GitHub's Markdown flavor. Do not remove! | [`POKE`](#poke) | Command | Assigns a value to a memory address | C64 | | [`POS`](#pos) | Integer Function | Returns the column position of the text cursor | C64 | | [`POWEROFF`](#poweroff) | Command | Immediately powers down the Commander X16 | X16 | -| `PRINT` | Command | Prints data to the screen or other output | C64 | -| `PRINT#` | Command | Prints data to an open logical file | C64 | +| [`PRINT`](#print) | Statement | Prints data to the screen or other output | C64 | +| [`PRINT#`](#print-1) | Statement | Prints data to an open logical file | C64 | | [`PSET`](#pset) | Command | Changes a pixel's color in graphics mode | X16 | | [`PSGCHORD`](#psgchord) | Command | Starts or stops simultaneous notes on VERA PSG | X16 | | [`PSGFREQ`](#psgfreq) | Command | Plays a frequency in Hz on VERA PSG | X16 | @@ -2128,16 +2143,74 @@ Once the quote mark ( **SHIFT** **2** ) is typed, the The cursor controls which can be "programmed" in quote mode are: -| **KEY** | **APPEARS AS** | -|---------:|:----------------:| -| **CLR/HOME** | [Reverse S](images/rvs-S.png) | -| **SHIFT** **CLR/HOME** | [Reverse Heart](images/rvs-heart.png) | -| **↑CRSR↓** | [Reverse S](images/rvs-Q.png) | -| **SHIFT** **↑CRSR↓** | [Reverse Ball](images/rvs-ball.png) | -| **←CRSR→** | [Reverse Left Bracket](images/rvs-r-bracket.png) | -| **SHIFT** **←CRSR→** | [Reverse Bar](images/rvs-bar.png) | +> | **KEY** | **APPEARS AS** | +> |---------:|:----------------:| +> | **CLR/HOME** | ![Reverse S](images/rvs-S.png) | +> | **SHIFT** **CLR/HOME** | ![Reverse Heart](images/rvs-heart.png) | +> | **↑CRSR↓** | ![Reverse Q](images/rvs-Q.png) | +> | **SHIFT** **↑CRSR↓** | ![Reverse Ball](images/rvs-ball.png) | +> | **←CRSR→** | ![Reverse Left Bracket](images/rvs-r-bracket.png) | +> | **SHIFT** **←CRSR→** | ![Reverse Bar](images/rvs-bar.png) | + +If you wanted the word HELLO to `PRINT` diagonally from the upper left corner of the screen, you would type: + +PRINT "**CLR/HOME** H **↑CRSR↓** E **↑CRSR↓** L **↑CRSR↓** L **↑CRSR↓** O" + +Which would appear as: + +PRINT "![](images/rvs-S.png) H ![](images/rvs-Q.png) E ![](images/rvs-Q.png) L ![](images/rvs-Q.png) L ![](images/rvs-Q.png) O" + +**2. Reverse Characters** + +Holding down the **CTRL** key and hitting **9** will cause **R** to appear inside the quotes. This will make all characters print starting in *reverse video* (like a negative of a picture). To end the reverse printing hit **CTRL** **0**, which prints a ![](images/norm-lower-bar.png) or else `PRINT` a **RETURN** (`CHR$`(13)). (Just ending the `PRINT` statement without a semicolon or a comma will take care of this.) + +**3. Color Controls** + +Holding down the **CTRL** or the Commander X16 Logo key with any of the 8 color keys will make a special reversed character which appears in quotes. When the character is `PRINT`ed, then the color change will occur. + +> | **KEY** | **COLOR** | **APPEARS AS** | +> |--------:|:---------:|:--------------:| +> | **CTRL** **1** | Black | ![Reverse UR Corner](images/rvs-ur-corner.png) | +> | **CTRL** **2** | White | ![Reverse E](images/rvs-E.png) | +> | **CTRL** **3** | Red | ![Reverse Pound](images/rvs-pound.png) | +> | **CTRL** **4** | Cyan | ![Reverse Left Ramp](images/rvs-l-ramp.png) | +> | **CTRL** **5** | Purple | ![Reverse Left Half Tile](images/rvs-half-tile.png) | +> | **CTRL** **6** | Green | ![Reverse Up Arrow](images/rvs-up-arr.png) | +> | **CTRL** **7** | Blue | ![Reverse Left Arrow](images/rvs-l-arr.png) | +> | **CTRL** **8** | Yellow | ![Reverse Pi](images/rvs-pi.png) | +> | **LOGO** **1** | Orange | ![Reverse Spade](images/rvs-spade.png) | +> | **LOGO** **2** | Brown | ![Reverse Upper Left Corner](images/rvs-ul-corner.png) | +> | **LOGO** **3** | Light Red | ![Reverse X Symbol](images/rvs-x-symbol.png) | +> | **LOGO** **4** | Grey 1 | ![Reverse Circle](images/rvs-circle.png) | +> | **LOGO** **5** | Grey 2 | ![Reverse Club](images/rvs-club.png) | +> | **LOGO** **6** | Light Green | ![Reverse Right Offset Bar](images/rvs-r-offset-bar.png) | +> | **LOGO** **7** | Light Blue | ![Reverse Diamond](images/rvs-diamond.png) | +> | **LOGO** **8** | Grey 3 | ![Reverse Plus Symbol](images/rvs-plus-symbol.png) | + +If you wanted to print the word HELLO in cyan and the word THERE in white, type: + +PRINT "**CTRL** **4**HELLO**CTRL** **2**THERE" + +Which would appear as: + +PRINT "![](images/rvs-l-ramp.png) HELLO ![](images/rvs-E.png) THERE" + +**4. Insert Mode** + +The spaces created by using the **INST/DEL** key have some of the same characteristics as quote mode. The cursor controls and color controls show up as reversed characters. The only difference is in the **INST** and **DEL** which performs +its normal function even in quote mode, now creates the **T**. And **INST**, which created a special character in quote mode, inserts spaces normally. + +Because of this, it is possible to create a `PRINT` statement containing **DEL**etes, which cannot be `PRINT`ed in quote mode. Here is an example of how this is done: + +10 PRINT "HELLO" **INST/DEL****SHIFT****INST/DEL****SHIFT****INST/DEL****INST/DEL****INST/DEL**P" + +which displays as: + +10 PRINT "HELLO**T****T**P" +When the above line is `RUN`, the word displayed will be HELP, because the last two letters are deleted and the P is put in their place. +> **WARNING:** The **DEL**etes will work when `LIST`ing as well as `PRINT`ing, so editing a line with these characters will be difficult. ### PSET diff --git a/images/norm-lower-bar.png b/images/norm-lower-bar.png new file mode 100644 index 0000000000000000000000000000000000000000..86197ef6220243d20af4013e4b4078eaf04976c0 GIT binary patch literal 472 zcmeAS@N?(olHy`uVBq!ia0vp^Vn8gy!2~4PAC&ooa@Ed~xChm}E!k(GfF$npYWX($`y8VyEfusFy)hKx)M0zf(n zh%?(+z~WgzHV7mDF-Sj*MzfTGnSo&fI|B<)g@KW=0pkLQsURJ!3m_&<0kT1W31|)z zSY?o<1&{^RWoTdklJz-%z(ckF`T`)c-P6S}#KQmW6-7Q4MIP1*KZS)1T8axK&K=I& zAtKg$xRHS|*3$E+-fY>eGu8j+YiV&QS=AMPdQg47>-6SFO@?k>E4Q*WOrOu8xMr)n z=26Szr*kcz3pZSwWqzCCPC@tNj;i-I_uO1oY;6-r>Iw3?x8L-+$+3#}8?Q+vpRxRT hf{npT^Uvwim5d4ZjFq;$s(k`-o~Nsy%Q~loCII*xb?N{B literal 0 HcmV?d00001 diff --git a/images/rvs-E.png b/images/rvs-E.png new file mode 100644 index 0000000000000000000000000000000000000000..80aa1334caf5b0460cfca5459c2e7a02449c1a90 GIT binary patch literal 701 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S_~VrE{6o}X)of~lUN zo@GwnEjyr^ZK)BSX`Y^13>-iXD}xjxD+42tb$b#xJG%x_k`kX)Dq1u0a0noM_PZ!4!3;(&3_pUnRAkca~j(u^H!iqovoxg8= z*56p}^O%`)U!#6ve(Huz#;y)Wmuw7-NYczwuI~2Ovqrk}`|3^V#YWX>9Kucy_HR(& zc=owcZL%a^`_drKy8p)>7Hr7f9krH^jk#i;_^R1w-Bc2`Mll-rPA>NAF=RNKW?aKz zDc8U5^|GLq;qD9!f;-o7E6hL7-0=Q4L)6-9WxIRr_Q&X{&OVZ1@@UTg6GjXV-s{>e zFjJ3dyd|^jZHd+0yzLh=GG?iTGi-box4ztJu2^?#?(NMt*W7=9TGU~UCbP!efHZf`OW9n&W!!{_n*6{ z|5J2YYT>!g4xYm&o)*0q?t5Ic^UCW|rKIn_|JK-Pn+vuJI9=Y7wDAY`e8Fexaz3p& Ppg8b!^>bP0l+XkKdC2P) literal 0 HcmV?d00001 diff --git a/images/rvs-Q.png b/images/rvs-Q.png index 8cecf55747515fecbefe06ed1300107bbf7dd71e..7b246b05254ddf728ceab2138bf3b8e7c58331ac 100644 GIT binary patch delta 608 zcmV-m0-yck1iA(xiBL{Q4GJ0x0000DNk~Le0000K0000K2m$~A00QfZT9F|j5(#if zS#tmY4#EHc4#EKyC`y2l*LDu_b^!qB0{{T>b^!qB1Cv_;T7N4c_a{6;2b2H+0qIFZ zK~y+T)swxd;!qTY_lZGn0*ZG2be1-Xg^eh-zJ-lg1nhhP5o@vXA+)uyNGfBeV53n{ z{0$;T3=xeno?FCwZphpjhUw<3_Re1GY?7>lUa!~Xa(O%+0Dv)O7{=rAAcWu-bX`|f z6=Q6*KA#V%s(;#SHbqfn80LDt=5o1wKL7FY;j{t_hr?Q}M$k|c=+0Jqx>0QGu3nM``UUY2E#$783{x!>;yA;U0I zsZ=~3k4B^Yet)ysRIAm|XoL^~MNv480{}q~@E4QG#DBh|)oPK^YPHH{vj8xiPAQ^z zKA)tfC@PUikd~%tQd@8FmXW9bz<+Q4F;#!&XEVllFc^^5Fbq;t6h)NZ|DfCL?)Upp zD3r-$0)arU*E0+QA!M3nBoYCD<#H*C;^A=E?RIYu35i9yT-J4+M8Xcw^F(HakgRJyB_DhnKPN$vm1OU@C z?JWSzX0zFBHXe`1-u7`c#qHLbFo;o u8~zeWl8|8-vMgIy*E#<^7~^m_{0WG+H}poi8x36m0000j~_pt zKY#w=!-rR|UcF_@7NClRgaicz1x7|jd3pK0d-s0$@ZtXb`@etxE-5Jy5fS0$=Kk{K zOIKId%ae*OCQ?_YX)Iy*bNsi~>Aw|7B7!G#MK z3JVKmWo5&|!;c&};^*hLAXNPDeV|pG1s;*b3=DjSL74G){)&`|!DW02Kp94mL%{UJ z>rwSS=MQ+O_FrEB6zKDGaSXBWe>?G{P?H0Xi*$*J-U`ll((nHLmya^Dau7WwWAiKT z<@6;%q7SSCeHIm6OS;1L!0O1<-02frZp6i>Fz^T)F&$G9&cA9g@maKx*vI?-?)jZf zI}me{DPq>zF8)=oq;5#uWU{_m`=EYyZdpaqnYSnPcNQPrSM{f&uz1DZCHd=2w>fRz hn>v5TZ{=5&3tZp;OXk;vd$@?2>>E?s*C^t diff --git a/images/rvs-S.png b/images/rvs-S.png index ac9aa96865f8e479a23e2110044507b81dc53b31..8a223493475b68f0cbd146f75123c48145734693 100644 GIT binary patch delta 695 zcmV;o0!aOa1&{|JiBL{Q4GJ0x0000DNk~Le0000K0000K2m=5B0J>N0Kan9He*q>? zOjJeu{QT_f?CI(0=;-M5^z{G#|Mm6t`}_On=jUy0ZB|Mn=56yu`%BM@L6i zR#s$WWaZ`M;o;#N92@`u0II60{r&y5wYA>f-s0loFE1~fo14bQ#+R3unVFfDm6hM$ z-=3bH1_lN$E-uc_&dkir)z#I>f62+3nwrJM#lgYB&CSgX4GpNMsMy%p>gwv&*49c& zN=!^lPEJlWH8n6WFb@w8w6wJA>+9|9?Ww7$qN1Yi?(XmJ??XdFW@ct(Wo2AkT-w^& zt*xyD1O&^=%h1r!n3$NHoSXpx0m{nC(b3VCmX^T4z<_{&fq{X2eSO>8N897$ zySuxSlatxm+1J+*|@^%3L=mP)%@^%3L=mV2#0a|}6A@?UdLI;!p009k2L_t(2 zQ&o;@Hv(Z4g-^paNK#{Cy2zknDudh#Ly}yJ+#=Wi|0k?>dflE+XFY4LeYQx*Fa`#p z88QqbWXkZ!Xm~90EyttbiCA2$Ns?2*w1@yRBxy?`$yC~cHJi!IIf$p{x!_1*ky!va z6;Vf?4CH?jfUJ_sZoy6IWD!77$v!1Vb*^};Sc|Tg%jJztEw{MM9hjj?rD9Zfe_7CXwLT0dq(OU(&@W-uwqQ@7xrDVYmqoClMd{Q!9Z;8G{AS`O@X z`}(GX+g2tRuR8AlF-;S=|MUIfvFmxB*X^k4k|QtH6Upb^OF-|HWW$!k+wUZeBky*- d^N;$+=NEgMGc5r1SeO6+002ovPDHLkV1k#pSiJxM delta 428 zcmbQh-o~of8Q|y6%O%Cdz`(%k>ERLtq-8;vgBeIB`cAi30&>r9u;`;yp|I?>W z&!0bk@#4k5fB#;+diCMMhf7OKfeN{~xxak*qM)FVkdVO1$*HBK_4Vu57cXAizkmPP zvu8FoHat8$-rnA(rlukyB1%e1)z#HMfBsyvW=&UDm!O~^2M5QNEnAKpIg*r=BqJlk z%*^cJ;UOj_791S>{rmS*>ZeYzv9YzZv`m~hv7w>i_{4|*fp&5hctjR6Fz_7)VaDV6 zD^e!6GM4cr0Hqj#7(!3xWQwZyIe)-Iwg378py(n`7sn6_|Fx5@^Bpqaan(0oqA5K+ zuQC%U@ppO7UGUdxqCM~ay>~y0azsy9v5mi4lgaZE-BGW TJLU60=Q4P@`njxgN@xNA_93o( diff --git a/images/rvs-ball.png b/images/rvs-ball.png index b1a44d5fe33f93549d50258516acb8d5c00c11b4..33b1f9b0c3f862759802f217f70b8e2b31c65d0d 100644 GIT binary patch delta 390 zcmV;10eSxN1L6cBiBL{Q4GJ0x0000DNk~Le0000K0000K2m=5B0J>N0Kan9Ie|u0& zR7Lyy`{Ci?+1c6J+S=II*!A`G?(XhlVqyRQ0BdV&8X6irJUl-?KR!M_KtMn)E-q?n zYSh%!-rnBb-QB3DsC;~U`T6<(|Nq9u#*dGW#Kgqb*4F&|{OaoJzrVk`ySu%;y|lEn z`1tr*T3UE`cw}T`^YinQlav1b8vbch^Qr&<010qNS#tmY4#EHc4#EKyC`y2lm39vD zb^!qB0{{T>b^!qB1Ctp6T7N4c_a{6;2b2H+0E$UOK~yMHwa`ZvgD?z5Q5gt`-b^QS zNcO+N97lGJ%{*^-NBRO_mTl%d!1eH+1FnyVK^VoNBo$~AW_eMH7}v0>8>;d-v{D zP*AY3vDva^3sAbSuyFqT`3VULEG#TBF)XOf|_x->1w=?da%_tO{S-?6bZnIwihV zpmW9Yj!Ki%CDz|xKabKXcJ4Y;_W9t}Ydo!S-c2>@o3Gufn09DkvtDmB7w5huaod1a OF?hQAxvX(KqM|~5W`IwK>+j#c-@SYH z{rmU-|NsB}`}gC=kDot({`c?S!-o%(l9IBsv*Y68_U+sE`t|FYnwpG^jFgm=$&)AF zym=F7(CXEzpFDY@q@;A~)~$8x);)dt)ZE;B?b@|wW@a~T+*q}0m4t-E*RNlH{P=O_ z&YdT-S4{@$;VkfoEM{QfJH)^NBp5|Cyc#CfmhpWmV`O*%bR2}9%*Ys3udVo9-NuQ1 z3Q$vmr;B5VM)2Dc$9WqZcvu7V=VyEp@`(!i@2b>eafz{5%2sJ{CBq*F^BxVq88a{Q zIK)jk6LVGZrdu{+$==izp2>Ruf3$w?J>C88;MZfm=7w9W1qG)wTli@!nJwe4 YxG7=Qr=H^lw2Q&h)z4*}QvzcX02Y;y2mk;8 delta 208 zcmZ3+vW{7?Gr-TCmrII^fq{Y7)59eQNXvpS3p0>hvbV}+qN0M0T!2rA>;M1%_wL=h zWy_Xp*RH*M`BFha0jQ$1wA9ANrnR-z@1RdDkk47*5n0T@z;_sg8IR|$NSSz|j4uHw z!wAF>da@5=RItza10JgV*B1aqjXhl)Lp07OCpa+ocsVE>IBx& t7xmsx?6b}baGKz;xK diff --git a/images/rvs-circle.png b/images/rvs-circle.png new file mode 100644 index 0000000000000000000000000000000000000000..b9e846eb6f9b12d32840aa664651f94b89064a72 GIT binary patch literal 657 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCilO0(?ST|NZ;-^aeY<`8 z_OfNmzJC4s>({T~;NXgiiq)%EM@2>L+_`hlo;|yF@2;<}|NZ;-f&~i_6B9pw{`~gs z+jsBYY4i2P0`2B3@Q5sCVBk9p!i>lBSEK+1B}!Z)N`mv#O3D+9QW*jgGxJLH{9Hp6 zO!W-)EOYX1*#XsTOO5bM^YqkW-~e)18Kf9l85n^qFCdnNvO!^_!N?32X9BVf8JQRa zfOHfPXSTC|#j}8H5J&)GkbW4AW+?+Olqaw=umDvU7#SNdE`XQ{(!sg_V$u{K8w8ku z<}iU(23cAFSx{Yu1_mHmpYsPiRQs%f9pVeL_B;7u}C~##wOp-u7*x_Lt^} U9Cg!WOauAA)78&qol`;+09)4OWdHyG literal 0 HcmV?d00001 diff --git a/images/rvs-club.png b/images/rvs-club.png new file mode 100644 index 0000000000000000000000000000000000000000..7e4f66c3d53d63e1c55c20a5e8c489d38a40ef41 GIT binary patch literal 797 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S_~VrE{6o}X)of~lUN zo@GwnEjyr^ZK)BSX`Y^13>-iXD}xjxD+42tb$b#xJG%x_k`kX)Dq1u0a0noNHo-U3d7XH1#)~7x>i0n;P(@Z^ThqmSZjnEPMs?0FubSlG%JU5P~Mf){fOHK$H2{BAi;Z#)doOJwg z;r{#g-*1ludOBj`&782cVVX;)rMd>1$nbssxkqHp)hu2%=3^4aDmLFN*?srEoa&9T z-BYzM7`SN@Z73TJfx9mtU4_j4+w)yL8p- zU5hVj@ErbFu_m7DKbKhB!cWbOKWo;VT9ObypONA8(@BPDdm02D&5_>5%y8rV_p}%M zE3UsTlv!-i*Q}7xllre}=7K4|_T7K|Rbc59fkk4U-4l9bkN;$x>n@_(;w>?{40_`TF(i88c=8)o4q~Wy_Xh$Bupe{Q1O*6T5cp3JD3((9rns;lt0LKhx6EmM>o(6&1B& z#fqFFsbD7bLp!ks&J{{H=Y@7}%3moLA1^~&1XIx8#d%9SfG zU%pIEPUhm`GB7ZB^5luXzrT)-j?(FF3Xm4+yHEY(UO`GE4;~kXKn^Q|6eBAGBar0<#L`eUD3UZ7nZe>rK(-+x6N3PdjsoJ$b{4RB7LW}B2|x_e z52Mj6WdKI=1a<}%pb7&cV*|zo5K}=qSQkJ{ngV2l029z0Ca}sNOA8{&803_>k z{(y&S|Mdkx=50?G#}JL+(EiNmMn{o0`8}^TK3S_0-QA)QxBJpEr725WPyPR|x^8AB z+xO+q?_9S`KgXcA-Tl$Fgi6;Bd5pLJ9B1Fp#i+32lHZB8y}P&j8|6H4d?Ii$!p6}^ z^Qqv;WDXm3w@)Ue)210!%{%$(*YVHY%lDm2jT0wd$~8>gLkg z#bw*Bm)(2Seyd#X>gzk^a$9QNl+0U_W4piP>s%G>z2RRzH(z*FG3oI3@}6UpU+(&& zVEkjrpHHhM|Jk%Z)Pu=bmzOc&-{;*Y<0Un8*Z7L(-4MH@<%Tdid~RpyZJwM~)sn`u+R&FJHd= z{P}b5-n~prOfzQ8$jr({T!%F68Q z?3$XIPoF-Om6atYCs$Qfef##UqN3vS=g%`|&MYY@>Fn%0d-m-0>(@`8KAn`5w0rk% zW@hGN$BzB@@nhb+dFAEh9UUFJcI}FaihBF@ZAwbYKW=;=H%V7 z1FG4U8sVAd>8ZuQ0pzeUNHMZ9FalX#Kr9VqgMw0nkr^z`1Y{dBGBF4M=_nx1Y-a(B zX93wDkO0IW{V*EMQU+!Qh6(HpEI<_oM#ct=3m~R~bg(Xfm^1~*1_36ZIZR-cL6#Ok z7F3s^fdNR?=llT=)&A=XfXr>4E{-7@!M*3A#hn~PSRVwxNLW!KY^btJb9$HF|Nre< zdrVeM|91Q5HM{KG2Ccd44k&w_SuzOKyqI bT5mH?Ob^!qB1Cv+*T7N4c_a{6;2b2H+0pCeP zK~y+Tt&_{@s!$ZhmnH>eBfC*eqFIA#(ku8LJwp!=G;Y*u1Q87zMZ=7mbpi9TL9`-4 zv_x&&8OYg@hXef&=Qr5sx4z|Cd�)*VQx)V@y$07=|3j<#IUy007VPG))VFpj<9z zv)M?rZClrMnt!IN)hei}8mSTE@%Z%{RaJ|{A^@ybDFB`CXO$mNk154^86+5QK!>MmStVnEz9zK|MhxB8xjP8Wmy2Q z+wI7hK7S@0Sph&0gyC>lC=|NgF2`}R*=)1f#8wFYY#RV*`rQsf2xHvu_oG+xJG0qr zyzK}ws!FA@TrTJHxh%_(@_ar&tg5P#?f(&yBvFQ8j7B5VG!uzLJpLELFifY@yt*xyJ z3JO|UT3^3@ojG%+pPyezNl9sGDNrdlH}{t>U%I-wOifJ_5)$ANKb477!4yv$Om5?OQ`b11l?QK|#T_Yu9vibhd2SQeR*H{{4G#aq&~9 zP8~dWkdu@1!i5Vi$^K6mL>L%23p^r=85sBugD~Uq{1qt^gUk35fEF_XF@&CYJ*wX4 z`~eTu{_6{Xf-^l`978PppI$sEbVxzK^`f733tOkf5k<~zpa0h{Vhvfi%;D^<-LK2T zR2b%KUoe&Wo!n%>TihAJ)Sxguq;9t0%LSr=U%SusM(X_CW|Sto#cUbhE>7oF_E*+k z+g+QVw$rGw>wsvPsy;8(M* phnw5wBoyue_ys`xVKa|?ZP|#%|KT&c)I$ztaD0e0swjGruF~; diff --git a/images/rvs-l-arr.png b/images/rvs-l-arr.png new file mode 100644 index 0000000000000000000000000000000000000000..4498948d7808f033dfbb05ac45e815a64fab69bf GIT binary patch literal 746 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCil?1^9%x{`>du!-o$qUc7ku^5xH;KfizfK6UC;UtizI$VgXL*SmM`e);mH zqM`z*{KkzNwY9av!onLiY&d-Qa9Ud0&6_uwn3(?m|KHi!X=!QM+S)p8+O&7?-u?dl zyREG)IXU_D>(_t&{Aq4(HZ(MJa&l^KZ~yk~o0XN7kB`rtJ9lQ!p8fv)`{&P}|M>A^ z&6+ieYgRf|{BdWo2az4Gn&N{>sYAzkmNedGh4ety{Nm-+u3~Mh)n6&H|6f zVg?4j!ywFfJby(BP*9@8HKHUqKdq!Zu_%=xATcwqM9AC z&ooa@Ed~xChm}E!k(GfF$npYWX($^M?i!5DU~wiO+mMloK>$cc0dZzK3s^i0$OeG~ zAO`7&(P)-30Ap?fI|B<)g@KW=0pkLQsURJ!3m_&<0kT1W31|)zSY?o<1&{^RWoTdk zlJz-%z(ckF`T`(xy{C&~h(>Vk`RhVW4m=JQOIfQoB!;-Sif|{rPkR6FKfmRM=3PAB zHH+2wITaP9o-Jk)RK6$?Z{s*g^Mm@tlv}b!H)HNO-#p615TNskW9g=#z}0qZu9}KS z$-Fu{t#O6c+rHWNN;kOsHg%|_e${1Xe{uR?q5xZ7-!Wmqz}e@X<#C_#i<0UPtL9}0 zMF%XOrLZ@0z7};j`1_#UO8Z My85}Sb4q9e0KXp>qW}N^ literal 0 HcmV?d00001 diff --git a/images/rvs-l-ramp.png b/images/rvs-l-ramp.png new file mode 100644 index 0000000000000000000000000000000000000000..a08c68bbde1d81fe2c02dcbf87b432b163cc4326 GIT binary patch literal 644 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijU1^9%x{{R2~)2B}_Uc7ko=FQ)~e}Db@wQ%7=pkzu)%Eyl%fBg6{Wy+M0 zkdXK9-~asibK10N#>U1|r%s(WZ{C$FR~Q)?6%`fVy?eJ}#foj)w%xmTZ_Ab~%a<>I z`}XahKYt7j4V|5xGcqz>zI@5V#PsOVBLf42IdkT0*s$T+wQIe-y?uRsW@cuuU%#F> zapJRQ&vxzFRb5@(+}zyQ*x23O{pHJ-Z{NQC`}gl}XQdm^L7W91k;M!Qe1}1p@p%4< z6ri9)iEBhjaDG}zd16s2LqK9?UWuNcYlwoWo}r#)PTnm$pqg!|5uRzDo>~kXKn^Q| z6eBAGBar0<#L`eUDC{&CnZe>rK(-+x6N3PdjsoJ$b{4RB7LW}B2|x_e52Mj6WdMf$ z1a<}%pb7&cV*|zo5K}=qSQkJ{ngV2l029z0Ca}sNOA8{&803_>k{(y&S|Mdkx zW~--*V~9p@?%CsFO$H*a7niRvS6ImTjpN(Bum9`MPJQZ@b)i*v8$U@l z>p7j3IO=g}&2xo@H}cDF{oh+_$T{`+3})B)f)0ifeG8_g&m(e(Y%Tsy?APuQ(p)JS*CJb(j4Xk1tE&-t%8)6|Bs<_&N{dI8RqU Jmvv4FO#q^F=pO(8 literal 0 HcmV?d00001 diff --git a/images/rvs-pi.png b/images/rvs-pi.png new file mode 100644 index 0000000000000000000000000000000000000000..735cb1eb84216af7cfab50586821c1153d8c10d5 GIT binary patch literal 746 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S_~VrE{6o}X)of~lUN zo@GwnEjyr^ZK)BSX`Y^13>-iXD}xjxD+42tb$b#xJG%x_k`kX)Dq1u0a0noOYo-U3d7XH1Hea~q+inN`#bnV#R@E_YyWG6_@hB(EAJWrAqVbuN$x0^ZuvzRn0y3-?txj z^y=*RARCpfwCZZsgUWfCb?vWru`sL+J6-b6-E6k2i_?+!?0uX~4%xoT<}f6m2@o($ z_3-r2Y(Jd1{<^Z#+ES~z+jO{V?&oj69q6Jq*>LhbiT>liCikC9l;C4)_FKMqO4W77 z2Old;q<9$~%+VL)J{Gb4_TLvg43keD(a7Hrqqq3P+p^!U?!5ng`f1V9pw6iZ9N&KL z6<8Fve!ACEkDfd}!A=gK>1MMT4CeZ^3OIG_@U*#-wYAIjc;TWack{kit-AfTY-h|N zgC5bfr5hu9oRUAvGBGGIG2Gs!dwSN{w2j}>x2440tJ>SA_vi3`(ai;yTG*mq*Q@Mb zub8Z}Dz)R|%^3gVg`a-z3F_*wcz*n`Aj7lIKY!NL+09=WlC}Bfp0bOd_hfC&n(~9~ zdg;VsJE>m3<(KdOSL0k7qBnhWuJqC=*I$QvWw!m{5)|cXmA}IHqE?xI=MzwbdAj!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S_~VrE{6o}X)of~lUN zo@GwnEjyr^ZK)BSX`Y^13>-iXD}xjxD+42tb$b#xJG%x_k`kX)Dq1u0a0noPXo-U3d7XE8PY|p(i5QtG{WLFhwXlYrnc%h@o zmOE@+S42YQFy^ zlopWJG?%{KwKnXu0T088&wnax?B@IDI=Eamx&7Ac&G%~8y~%d-muGf$bV#^Pd|v6w z?jXRzrg&uA+ok}msb8c7HJ8d89Y_E=b8$lG1=)X_LwFRAXl#gYS}3G-=|8)(*Gv`9 z#?&6gMS71d{!L&k+dX&6q&s=r&!#E2Twp)_dC%pSJnha?U8kkqe*3M)ZuYX3JV9Pw zFEdP(-dop*+Vj1+t+4+3>#Du`*!w!BdMyoGy;5Y!l<&X)*4i*0FgfeC*paXOaEg)T zT)(G9k(`bKXVQ$%f4-7%v~W*^PT1s|E>8hane9&20W4vJ1sS3j3^P6du{rmSXU%q_x>ebJmKmY&#|KrDxPoF+@b#(;<1VlzgMnpse z1_s`}d-weL^C2N2zP`Tq@85s-?pHFM_72@@u)S+hn@Pw&>PTTDz$5)u-xU%&qS`*&esVP0O|ix)2(9UYyWo!i>l zX3w7e@#DuYU%r%;l?4X}@7c3w<;s=1y1J#MrNza?W@cs%4i1wiPyYJ#Yj=0Iot>SJ zkB^_9pQWYc+O=yxeE6_s%a--)*MI)}dHeS59v&WXadF?jfB*LF+tjI3V`5^`)6;Wu za*B$IdV6~h9XfRJ;>Evz|E^xW+SAi>_wL;*R;+mY_HA-<^7ZT2^YincKYzYx(W1V- zzWVz5rlzLG#>Upx*5%8WA3S*Q(W6J#u3fuv~kXKn^Q|6eBAGBar0<#L`eUC~7qrnZe>rK(-+x6N3PdjsoJ$b{4RB7LW}B z2|x_e52Mj6WdJ6Q3G56kKotf?#s-WFAf|$Jur7d@GzG{80Vbe1OkkBkmKH!3RF|QF z0Z7*8`~eTu{_6{Xw()zqIEH8hhxTO#HzkO)#$OO#n%Qb@!mZu4{i?=ku~R+YuAbVY zq8+{E?f?G`&sY>MQ{xvZ~3&Dv_&^P*oBRY{Y0{QU%dXVv-~OMqihY%p_}@gDr+X$vz|MrA2fYwfKY5? zL+Hz@lG@^E)AwJh4Of0sP_wuJZe}_ewb(&XWfBjQ;I1d{ZC#+H#lGv&U~i!Q|=c K=d#Wzp$P!HbASi{ literal 0 HcmV?d00001 diff --git a/images/rvs-r-bracket.png b/images/rvs-r-bracket.png index e76e2f085ec3194b7760163eebdf6fda8be784b1..1f0eeb2b38bfd4e490f902eba9b43a349587fdbf 100644 GIT binary patch delta 463 zcmV;=0WkjX1FHogiBL{Q4GJ0x0000DNk~Le0000K0000K2m$~A00QfZT9F|j5(#if zS#tmY4#EHc4#EKyC`y2lo^}rMb^!qB0{{T>b^!qB1Ct^FT7N4c_a{6;2b2H+0a{5! zK~y+T?UTKZfVAZnrxe4o%Z6eo;zgOxJY)_;LWK)oSbYTIy^z za~wyOU(w3KIWMbaS;{VjO8H&>%Wv{`WlgK-{eCa&D}0p~CWIJ|$F^+?A@V%$^?LPs zy&O=elmTEg8o92^7%PUzEtFDa*Ei)b3=fCHt5>g{ zKY#w=!-pR~eypIN0928Xkg#RTmXMH;`}gnv`0?Y^sZ%a4F7MyJH!(5k>gq~LO7ipb zGc`3ma^#4!)0q`O4V(oYk;M!Qe1}1p@p%4Chk<*}T!lvI6;>1s;*b3=DjSL74G){)!Z!phSslL`iUdT1k0gQ7S_~VrE{6o}X)of~lUN zo@GwnEjyr^ZK)BSX`Y^13>-iXD}xjxD+42tb$b#xJG%x_k`kX)Dq1u0a0g!pX)5S5w!vAf*Aydu^XJd+-o1PO{{8RYzyJUL|NZ;-$&)9iq@-kLXJ=()rKYCd zyLWHjzI}0VaY;!@4<9}RYQ22<^0H;iZr;49rlz)H#fm+9_PlxX=FXiv{r&y7Zrx&H zVp330c=6)Jkt0W}tgK2(N_u*F-oAZ%?b@}Pni?r7sn@Sx|NQy$&!0c0rlwDxJc){m z`tjq(?%lih@84fvU%z3)hIQ-Kty!~X%a$#lK7CrdcI~QFt8U!5VPayEk&)5T(sJd> zm4bqT`1p7+F|o?ZN?TjooSd8o4<6jTd-u_!M+XlcG&3`^v9YnYx3{yiV`F3c`t@sL zQ%x$+-JAs;k;M!Qe1}1p@p%4<6ri9)iEBhjaDG}zd16s2LqK9?UWuNcYlwoWo}r#) zPTnm$pqg!|5uRzDo>~kXKn^Q|6eBAGBar0<#L`eUC;~JXnZe>rK(-+x6N3PdjsoJ$ zb{4RB7LW}B2|x_e52Mj6WdKIu1a<}%pb7&cV*|zo5K}=qSQkJ{ngV2l029z0Ca}sN zOA8{&803_>k{(y&S|Mdkx=2=e{#}JL++zZe7nhZqR9(JvbUihw)TlA=H;rq9L z(BGEHYtkr9SAaA^kYZxl%oYlIvzxw|Mdx^ed!XH=kF1sA*Tqn4lQZ~OGgy4C8qY46@6 z&4o6J&rgRY{Vl6c_)HAn`c0t^mO%eS?83{1OU{y BFU|k} literal 0 HcmV?d00001 diff --git a/images/rvs-ul-corner.png b/images/rvs-ul-corner.png new file mode 100644 index 0000000000000000000000000000000000000000..80633db3ac96ff965835850a94a99b2c7b1f03ac GIT binary patch literal 742 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCilC2Ka=ye*OCO=FOY8Zr!?n|NhUPKY_x&zP>MCzPx?=c4TBEBO{}`yE`{G z_r!@4H*VaxZr!>yYu4=Awd>25FHB5K|NsBj*4EC>&aSPkeemExOiawTZ{Pm@{VOXg zDZsrwu3k`3@b>N7 zWy_ZR`}eP{tt~V(bjgw>lP6CuEiH9+c7E~Vg`J(9kB`s7g$o@V90CFY9zA-Lo}QkS zl@%8kw|)EeckkY{wzj6FrKP5(c6D|A{{8#Yr%%V8%@+dtgtNdSvY3H^?=T269?xHq z0u+=eag8Vm&QB{TPb^Ah2uRG#E79|F4N)-FGt{%p$-89-RI@EL!ZXd&Q;UHE$YEuW zVq|4t1hTwjH>LQ-Ev`U;>)M1XdYjX#r$Gbr~8MfMk8nAMjA^zrFy- z+~Vot7@`rpc0xFRlY>ADf8x@J4QtZHUEXx;-M;zb|N2RctcPu_^{syzo%CxHP!yc5 z;HAR2XOdB11=}n6h2QqBj4+ye^3|?+r^S^bfKIUgrRu#Urqh{sf!4KGF`F*tNOojw z(_Nk1zG3y39GBhp5`D+~IMh2{cs&zgNDEwQsU+3?R4eRW`)l6|JIrf%Q~lo FCIDOw4c!0$ literal 0 HcmV?d00001 diff --git a/images/rvs-up-arr.png b/images/rvs-up-arr.png new file mode 100644 index 0000000000000000000000000000000000000000..b35f9525bbeb5dd72e3db79861fd37b3033a5144 GIT binary patch literal 794 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij+1o(uw{`vFg&6_tbU%veP`}gzb&vSEgLqkI&BO}AY!ctOFo<4p0@Zm!l z85yARd-v`=di2P^z+l&|UB{0fKX&ZczJ2?6d3o>Ozt6(LlAWFX_3PLF|NsB`^{c+V zo|Tm~At9lsr)SNYHQ&B{+q`*mT3XtwRjdB}`?qDw7Hey3Q&ZE!hYy>Xnc3Lb@bK{H z>FK?H|Nh61AA9%iWnyCb^5x6hw{Ks+e*N*|$4{R=9XN2n&(AMCJv}uwH8wVO^5n_$ z=FN+ajt&S2;O6H3@Zm#UU0q>eVRLh{uC8uDK|xbflf1nAty{Nl-@g6$@#DXL|K7ZL z^Uj?+-@kufHM2hi=o!uekH}&M2EM}}%y>M1MG8<*qQo_#Bsf2L5h);ff2~^0%B<>8x#{7jLcwhCLr68 zk%>V7NJjy2W;+X5JPXJMfdn81>4(v1mNEe2asoR83s8lDk+A{e0*I*~9jpr=CQSjd zL4XNp4ii{qkfjBX1=VF}U;vW!Ie)-Iwg378AoHxJi(`mJ@YcSYL5COwSj3f2nR0&Q zFjycVx`&f3U?+)Cuyxx4V7NJjy2W;+X5 zJPXJMfdn81>4(v1mNEdtYXUn13s8lDk+A{e0*I*~9jpr=CQSjdL4XNp4ii{qkfjBX z1=VF}U;vW!Ie)-Iwg378Ak)>;#W6%9I5}YfkAaclVg|7Z3fj`v>`Vnkh0QFL6+Z(Q z>^%Y;1VRHcD!4vzEaqzZdrn13tBv7Nj*x<*r)H+e0S*xshOcJ?OnduS|A7qmboFyt I=akR{08ONbY5)KL literal 0 HcmV?d00001 diff --git a/images/rvs-x-symbol.png b/images/rvs-x-symbol.png new file mode 100644 index 0000000000000000000000000000000000000000..32d25fc48e287e1eb62a03c6a14ea38d7a92a885 GIT binary patch literal 821 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCikn2Ka=y{{R2~{rmSfZrr$a>(=w<&;R}Vw`b2Dpk!}v@2_9KjvP56DJf}a zXsEBRuc4taZ{ED$zkh%H`0>Gm2V1vpUB7<)>({Tpef#$1%a^NHubw@7_V3@nU%!5R z`}S>ndwWVs%F&}o4;?ym`0(L_2M^xAf4{V}w6L)7>C>lAo;a!x2me@vSrKE)YM#DTvn}Gb@%SwSFc`u z`0!!VrcEbLp8WIY&zUo4>g(&PtE+2jYD!8jKs zu3fw0;^MNivl9~&*REar$Nv;eZ8x(p2rK(apP4|u5dUta)Z-uHBI4ABVo zy-*q5GS_!SE?ggasF-0x%Z3GIf$M`-x7{syF{k?G zrv-15)pxQl=)S?czMnaHg@%Efkl=cq&g&&xk4U%LY&g<%=mUTLN59-^#Jvo&QSp^XC3w;h29+qD@j(nUOofLEiRs^>bP0l+XkKX)IEH literal 0 HcmV?d00001 From 7bd63ec993327c61447e27cdd7ba1bb97b8459d8 Mon Sep 17 00:00:00 2001 From: geneb Date: Mon, 19 Jan 2026 10:30:37 -0800 Subject: [PATCH 05/13] WIP: Added more images for PRINT, completed to RIGHT$. --- X16 Reference - 04 - BASIC.md | 141 +++++++++++++++++++++++++++++++--- images/rvs-H.png | Bin 0 -> 677 bytes images/rvs-I.png | Bin 0 -> 678 bytes images/rvs-N.png | Bin 0 -> 693 bytes images/rvs-backslash.png | Bin 0 -> 692 bytes images/rvs-slash.png | Bin 0 -> 839 bytes 6 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 images/rvs-H.png create mode 100644 images/rvs-I.png create mode 100644 images/rvs-N.png create mode 100644 images/rvs-backslash.png create mode 100644 images/rvs-slash.png diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index ec47541..af28451 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -9,8 +9,8 @@ It also adds a border radius to the background to give the highlighted items a m - # Chapter 4: BASIC Programming ## Table of BASIC statements and functions From 72204b7da4e37d01a4ffe706587ec8a8a0dc7e22 Mon Sep 17 00:00:00 2001 From: geneb Date: Tue, 20 Jan 2026 15:11:58 -0800 Subject: [PATCH 11/13] WIP: Edited down to CONT. --- X16 Reference - 04 - BASIC.md | 171 +++++++++++++++++----------------- 1 file changed, 85 insertions(+), 86 deletions(-) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index d2b70d2..ab9bcb3 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -13,26 +13,26 @@ when viewed on github. PDF output appears correct. | Keyword | Type | Summary | Origin | | - | - | - | - | -| [`ABS`](#abs) | Function | Returns absolute value of a number | C64 | +| [`ABS`](#abs) | Numeric Function | Returns absolute value of a number | C64 | | [`AND`](#and) | Operator | Returns boolean "AND" or bitwise intersection | C64 | -| [`ASC`](#asc) | Function | Returns numeric PETSCII value from string | C64 | -| [`ATN`](#atn) | Function | Returns arctangent of a number | C64 | +| [`ASC`](#asc) | Numeric Function | Returns numeric PETSCII value from string | C64 | +| [`ATN`](#atn) | Numeric Function | Returns arctangent of a number | C64 | | [`BANK`](#bank) | Command | Sets the RAM and ROM banks to use for PEEK, POKE, and SYS | C128 | | [`BASLOAD`](#bank) | Command | Load and tokenize a BASLOAD (.basl) text file | X16 | -| [`BIN$`](#bin) | Function | Converts numeric to a binary string | X16 | -| [`BINPUT#`](#binput) | Command | Reads a fixed-length block of data from an open file | X16 | +| [`BIN$`](#bin) | String Function | Converts numeric to a binary string | X16 | +| [`BINPUT#`](#binput) | I/O Statement | Reads a fixed-length block of data from an open file | X16 | | [`BLOAD`](#bload) | Command | Loads a headerless binary file from disk to a memory address | X16 | | [`BOOT`](#boot) | Command | Loads and runs `AUTOBOOT.X16` | X16 | | [`BSAVE`](#bsave) | Command | Saves a headerless copy of a range of memory to a file | X16 | | [`BVERIFY`](#bverify) | Command | Verifies that a file on disk matches RAM contents | X16 | | [`BVLOAD`](#bvload) | Command | Loads a headerless binary file from disk to VRAM | X16 | | [`CHAR`](#char) | Command | Draws a text string in graphics mode | X16 | -| [`CHR$`](#chr$) | Function | Returns PETSCII character from numeric value | C64 | +| [`CHR$`](#chr$) | String Function | Returns PETSCII character from numeric value | C64 | | [`CLOSE`](#close) | I/O Statement | Closes a logical file number | C64 | -| [`CLR`](#clr) | Command | Clears BASIC variable state | C64 | -| [`CLS`](#cls) | Command | Clears the screen | X16 | +| [`CLR`](#clr) | Statement | Clears BASIC variable state | C64 | +| [`CLS`](#cls) | Statement | Clears the screen | X16 | | [`CMD`](#cmd) | I/O Statement | Redirects output to non-screen device | C64 | -| [`COLOR`](#color) | Command | Sets text fg and bg color | X16 | +| [`COLOR`](#color) | Statement | Sets text fg and bg color | X16 | | [`CONT`](#cont) | Command | Resumes execution of a BASIC program | C64 | | [`COS`](#cos) | Function | Returns cosine of an angle in radians | C64 | | [`DA$`](#da$) | String Function | Returns the date in YYYYMMDD format from the system clock | X16 | @@ -44,29 +44,29 @@ when viewed on github. PDF output appears correct. | [`END`](#end) | Statement | Terminate program execution and return to `READY.` | C64 | | [`EXEC`](#exec) | Command | Play back a script from RAM into the BASIC editor | X16 | | [`EXP`](#exp) | Function | Returns the inverse natural log of a number | C64 | -| [`FMCHORD`](#fmchord) | Command | Start or stop simultaneous notes on YM2151 | X16 | -| [`FMDRUM`](#fmdrum) | Command | Plays a drum sound on YM2151 | X16 | -| [`FMFREQ`](#fmfreq) | Command | Plays a frequency in Hz on YM2151 | X16 | -| [`FMINIT`](#fminit) | Command | Stops sound and reinitializes YM2151 | X16 | -| [`FMINST`](#fminst) | Command | Loads a patch preset into a YM2151 channel | X16 | -| [`FMNOTE`](#fmnote) | Command | Plays a musical note on YM2151 | X16 | -| [`FMPAN`](#fmpan) | Command | Sets stereo panning on YM2151 | X16 | -| [`FMPLAY`](#fmplay) | Command | Plays a series of notes on YM2151 | X16 | -| [`FMPOKE`](#fmpoke) | Command | Writes a value into a YM2151 register | X16 | -| [`FMVIB`](#fmvib) | Command | Controls vibrato and tremolo on YM2151 | X16 | -| [`FMVOL`](#fmvol) | Command | Sets channel volume on YM2151 | X16 | +| [`FMCHORD`](#fmchord) | Statement | Start or stop simultaneous notes on YM2151 | X16 | +| [`FMDRUM`](#fmdrum) | Statement | Plays a drum sound on YM2151 | X16 | +| [`FMFREQ`](#fmfreq) | Statement | Plays a frequency in Hz on YM2151 | X16 | +| [`FMINIT`](#fminit) | Statement | Stops sound and reinitializes YM2151 | X16 | +| [`FMINST`](#fminst) | Statement | Loads a patch preset into a YM2151 channel | X16 | +| [`FMNOTE`](#fmnote) | Statement | Plays a musical note on YM2151 | X16 | +| [`FMPAN`](#fmpan) | Statement | Sets stereo panning on YM2151 | X16 | +| [`FMPLAY`](#fmplay) | Statement | Plays a series of notes on YM2151 | X16 | +| [`FMPOKE`](#fmpoke) | Statement | Writes a value into a YM2151 register | X16 | +| [`FMVIB`](#fmvib) | Statement | Controls vibrato and tremolo on YM2151 | X16 | +| [`FMVOL`](#fmvol) | Statement | Sets channel volume on YM2151 | X16 | | [`FN`](#fn) | Function | Calls a previously defined function | C64 | | [`FOR-TO-STEP`](#for-to-step) | Statement | Declares the start of a loop construct | C64 | -| [`FRAME`](#frame) | Command | Draws an unfilled rectangle in graphics mode | X16 | +| [`FRAME`](#frame) | Statement | Draws an unfilled rectangle in graphics mode | X16 | | [`FRE`](#fre) | Function | Returns the number of unused BASIC bytes free | C64 | | [`GET`](#get) | Statement | Polls the keyboard cache for a single keystroke | C64 | | [`GET#`](#get-1) | I/O Statement | Polls an open logical file for a single character | C64 | | [`GOSUB`](#gosub) | Statement | Jumps to a BASIC subroutine | C64 | | [`GOTO`](#goto) | Statement | Branches immediately to a line number | C64 | | [`HELP`](#help) | Command | Displays a brief summary of online help resources | X16 | -| [`HEX$`](#hex) | Function | Converts numeric to a hexadecimal string | X16 | +| [`HEX$`](#hex) | String Function | Converts numeric to a hexadecimal string | X16 | | [`I2CPEEK`](#i2cpeek) | Function | Reads a byte from a device on the I²C bus | X16 | -| [`I2CPOKE`](#i2cpoke) | Command | Writes a byte to a device on the I²C bus | X16 | +| [`I2CPOKE`](#i2cpoke) | Statement | Writes a byte to a device on the I²C bus | X16 | | [`IF-THEN`](#if-then) | Statement | Tests a boolean condition and branches on result | C64 | | [`INPUT`](#input) | Statement | Reads a line or values from the keyboard | C64 | | [`INPUT#`](#input-1) | I/O Statement | Reads lines or values from a logical file | C64 | @@ -76,19 +76,19 @@ when viewed on github. PDF output appears correct. | [`LEFT$`](#left) | String Function | Returns a substring starting from the beginning of a string | C64 | | [`LEN`](#len) | Integer Function | Returns the length of a string | C64 | | [`LET`](#let) | Statement | Explicitly declares a variable | C64 | -| [`LINE`](#line) | Command | Draws a line in graphics mode | X16 | -| [`LINPUT`](#linput) | Command | Reads a line from the keyboard | X16 | -| [`LINPUT#`](#linput-1) | Command | Reads a line or other delimited data from an open file | X16 | +| [`LINE`](#line) | Statement | Draws a line in graphics mode | X16 | +| [`LINPUT`](#linput) | Statement | Reads a line from the keyboard | X16 | +| [`LINPUT#`](#linput-1) | I/O Statement | Reads a line or other delimited data from an open file | X16 | | [`LIST`](#list) | Command | Outputs the program listing to the screen | C64 | | [`LOAD`](#load) | Command | Loads a program from disk into memory | C64 | -| [`LOCATE`](#locate) | Command | Moves the text cursor to new location | X16 | +| [`LOCATE`](#locate) | Statement | Moves the text cursor to new location | X16 | | [`LOG`](#log) | Floating-Point Function | Returns the natural logarithm of a number | C64 | | [`MENU`](#menu) | Command | Invokes the Commander X16 utility menu | X16 | | [`MID$`](#mid) | String Function | Returns a substring from the middle of a string | C64 | | [`MOD`](#mod) | Function | Returns the truncated remainder of a division | X16 | | [`MON`](#mon) | Command | Enters the machine language monitor | X16 | -| [`MOUSE`](#mouse) | Command | Hides or shows mouse pointer | X16 | -| [`MOVSPR`](#movspr) | Command | Set the X/Y position of a sprite | X16 | +| [`MOUSE`](#mouse) | Statement | Hides or shows mouse pointer | X16 | +| [`MOVSPR`](#movspr) | Statement | Set the X/Y position of a sprite | X16 | | [`MX/MY/MB`](#mxmymb) | variable | Reads the mouse position and button state | X16 | | [`MWHEEL`](#mwheel) | variable | Reads the mouse wheel movement | X16 | | [`NEW`](#new) | Command | Resets the state of BASIC and clears program memory | C64 | @@ -98,45 +98,45 @@ when viewed on github. PDF output appears correct. | [`ON`](#on) | Statement | A GOTO/GOSUB table based on a variable value | C64 | | [`OPEN`](#open) | I/O Statement | Opens a logical file to disk or other device | C64 | | [`OR`](#or) | Logical Operator | Bitwise or boolean "OR" | C64 | -| [`OVAL`](#oval) | Command | Draws a filled oval in graphics mode | X16 | +| [`OVAL`](#oval) | Statement | Draws a filled oval in graphics mode | X16 | | [`PEEK`](#peek) | Function | Returns a value from a memory address | C64 | | `π` | Function | Returns the constant for the value of pi | C64 | | [`POINTER`](#pointer) | Function | Returns the address of a BASIC variable | C128 | -| [`POKE`](#poke) | Command | Assigns a value to a memory address | C64 | +| [`POKE`](#poke) | Statement | Assigns a value to a memory address | C64 | | [`POS`](#pos) | Integer Function | Returns the column position of the text cursor | C64 | | [`POWEROFF`](#poweroff) | Command | Immediately powers down the Commander X16 | X16 | | [`PRINT`](#print) | Statement | Prints data to the screen or other output | C64 | | [`PRINT#`](#print-1) | I/O Statement | Prints data to an open logical file | C64 | -| [`PSET`](#pset) | Command | Changes a pixel's color in graphics mode | X16 | -| [`PSGCHORD`](#psgchord) | Command | Starts or stops simultaneous notes on VERA PSG | X16 | -| [`PSGFREQ`](#psgfreq) | Command | Plays a frequency in Hz on VERA PSG | X16 | -| [`PSGINIT`](#psginit) | Command | Stops sound and reinitializes VERA PSG | X16 | -| [`PSGNOTE`](#psgnote) | Command | Plays a musical note on VERA PSG | X16 | -| [`PSGPAN`](#psgpan) | Command | Sets stereo panning on VERA PSG | X16 | -| [`PSGPLAY`](#psgplay) | Command | Plays a series of notes on VERA PSG | X16 | -| [`PSGVOL`](#psgvol) | Command | Sets voice volume on VERA PSG | X16 | -| [`PSGWAV`](#psgwav) | Command | Sets waveform on VERA PSG | X16 | +| [`PSET`](#pset) | Statement | Changes a pixel's color in graphics mode | X16 | +| [`PSGCHORD`](#psgchord) | Statement | Starts or stops simultaneous notes on VERA PSG | X16 | +| [`PSGFREQ`](#psgfreq) | Statement | Plays a frequency in Hz on VERA PSG | X16 | +| [`PSGINIT`](#psginit) | Statement | Stops sound and reinitializes VERA PSG | X16 | +| [`PSGNOTE`](#psgnote) | Statement | Plays a musical note on VERA PSG | X16 | +| [`PSGPAN`](#psgpan) | Statement | Sets stereo panning on VERA PSG | X16 | +| [`PSGPLAY`](#psgplay) | Statement | Plays a series of notes on VERA PSG | X16 | +| [`PSGVOL`](#psgvol) | Statement | Sets voice volume on VERA PSG | X16 | +| [`PSGWAV`](#psgwav) | Statement | Sets waveform on VERA PSG | X16 | | [`READ`](#read) | Statement | Assigns the next `DATA` constant to one or more variables | C64 | | [`REBOOT`](#reboot) | Command | Performs a warm reboot of the system | X16 | -| [`RECT`](#rect) | Command | Draws a filled rectangle in graphics mode | X16 | +| [`RECT`](#rect) | Statement | Draws a filled rectangle in graphics mode | X16 | | [`REM`](#rem) | Statement | Declares a comment | C64 | | [`REN`](#ren) | Command | Renumbers a BASIC program | X16 | | [`RESET`](#reset) | Command | Performs a hard reset of the system | X16 | -| [`RESTORE`](#restore) | Command | Resets the `READ` pointer to a `DATA` constant | C64 | +| [`RESTORE`](#restore) | Statement | Resets the `READ` pointer to a `DATA` constant | C64 | | [`RETURN`](#return) | Statement | Returns from a subroutine to the statement following a GOSUB | C64 | | [`RIGHT$`](#right) | String Function | Returns a substring from the end of a string | C64 | -| [`RING`](#ring) | Command | Draws an oval outline in graphics mode | X16 | +| [`RING`](#ring) | Statement | Draws an oval outline in graphics mode | X16 | | [`RND`](#rnd) | Floating-Point Function | Returns a floating point number 0 <= n < 1 | C64 | -| [`RPT$`](#rpt) | Function | Returns a string of repeated characters | X16 | +| [`RPT$`](#rpt) | String Function | Returns a string of repeated characters | X16 | | [`RUN`](#run) | Command | Clears the variable state and starts a BASIC program | C64 | | [`SAVE`](#save) | Command | Saves a BASIC program from memory to disk | C64 | -| [`SCREEN`](#screen) | Command | Selects a text or graphics mode | X16 | +| [`SCREEN`](#screen) | Statement | Selects a text or graphics mode | X16 | | [`SGN`](#sgn) | Integer Function | Returns the sign of a numeric value | C64 | | [`SIN`](#sin) | Floating-Point Function | Returns the sine of an angle in radians | C64 | -| [`SLEEP`](#sleep) | Command | Introduces a delay in program execution | X16 | +| [`SLEEP`](#sleep) | Statement | Introduces a delay in program execution | X16 | | [`SPC`](#spc) | Special Function | Returns a string with a set number of spaces | C64 | -| [`SPRITE`](#sprite) | Command | Sets attributes for a sprite including visibility | X16 | -| [`SPRMEM`](#sprmem) | Command | Set the VRAM address for a sprite's visual data | X16 | +| [`SPRITE`](#sprite) | Statement | Sets attributes for a sprite including visibility | X16 | +| [`SPRMEM`](#sprmem) | Statement | Set the VRAM address for a sprite's visual data | X16 | | [`SQR`](#sqr) | Floating-Point Function | Returns the square root of a numeric value | C64 | | [`ST`](#st) | Integer Function | Returns the status of certain DOS/peripheral operations | C64 | | [`STEP`](#step) | Statement | Used in a `FOR` declaration to declare the iterator step | C64 | @@ -153,10 +153,10 @@ when viewed on github. PDF output appears correct. | [`TIME$`](#time-1) | String Function | Returns the time HHMMSS from the system clock | C64 | | [`USR`](#usr) | Floating-Point Function | Call a user-defined function in machine language | C64 | | [`VAL`](#val) | Numeric Function | Parse a string to return a numeric value | C64 | -| [`VERIFY`] | Command | Verify that a BASIC program was written to disk correctly | C64 | +| [`VERIFY`](#verify) | Command | Verify that a BASIC program was written to disk correctly | C64 | | [`VPEEK`](#vpeek) | Function | Returns a value from VERA's VRAM | X16 | -| [`VPOKE`](#vpoke) | Command | Sets a value in VERA's VRAM | X16 | -| [`VLOAD`](#vload) | Command | Loads a file to VERA's VRAM | X16 | +| [`VPOKE`](#vpoke) | Statement | Sets a value in VERA's VRAM | X16 | +| [`VLOAD`](#vload) | Statement | Loads a file to VERA's VRAM | X16 | | [`WAIT`](#wait) | Statement | Waits for a memory location to match a condition | C64 | ## Commodore 64 Compatibility @@ -177,16 +177,16 @@ The Commander X16 BASIC interpreter is 100% backwards-compatible with the Commod Because of the differences in hardware, the following functions and statements are incompatible between C64 and X16 BASIC programs. -* `POKE`: write to a memory address -* `PEEK`: read from a memory address -* `WAIT`: wait for memory contents -* `SYS`: execute machine language code (when used with ROM code) +* [`POKE`](#poke): write to a memory address +* [`PEEK`](#peek): read from a memory address +* [`WAIT`](#wait): wait for memory contents +* [`SYS`](#sys): execute machine language code (when used with ROM code) The BASIC interpreter also currently shares all problems of the C64 version, like the slow garbage collector. ## Saving Files -By default, you cannot automatically overwrite a file with SAVE, BSAVE, or OPEN. To overwrite a file, you must prefix the filename with `@:`, like this: `SAVE "@:HELLO WORLD"`. (`"@0:filename"` is also acceptable.) +By default, you cannot automatically overwrite a file with [SAVE](#save), [BSAVE](#bsave), or [OPEN](#open). To overwrite a file, you must prefix the filename with `@:`, like this: `SAVE "@:HELLO WORLD"`. (`"@0:filename"` is also acceptable.) This follows the Commodore convention, which extended to all of their diskette drives and third party hard drives and flash drive readers. @@ -194,7 +194,7 @@ Always confirm you have successfully saved a file by checking the DOS status. Wh There are two ways to check the error channel from inside a program: -1. You can use the DOS command and make the user perform actions necessary to recover from an error (such as re-saving the file with an @: prefix). +1. You can use the [DOS](#dos) command and make the user perform actions necessary to recover from an error (such as re-saving the file with an @: prefix). 2. You can read the error yourself, using the following BASIC code: ```BASIC @@ -220,10 +220,10 @@ There are several new statement and functions. Note that all BASIC keywords (suc **EXAMPLE of the ABS Function:** ```BASIC -?ABS(-24) +PRINT ABS(-24) 24 -?ABS(50) +PRINT ABS(50) 50 ``` @@ -292,15 +292,15 @@ When evaluating a number for true or false, the computer assumes the number is t **TYPE: Integer Function** **FORMAT: ASC(<string>)** -**Action:** Returns an integer value representing the `PETSCII` code for the first character of <string>. If <string> is an empty ("") string, `ASC` returns 0. +**Action:** Returns an integer value representing the [PETSCII](X16%20Reference%20-%20Appendix%20I%20-%20Character%20Sets.md#pet-uppercase--graphics) code for the first character of <string>. If <string> is an empty ("") string, `ASC` returns 0. **EXAMPLE of the ASC Function:** ```BASIC -?ASC("A") +PRINT ASC("A") 65 -?ASC("") +PRINT ASC("") 0 ``` @@ -311,7 +311,7 @@ When evaluating a number for true or false, the computer assumes the number is t **Action:** This mathematical function returns the arctangent of the number given. The result is the angle (in radians) whose tangent is the number given. The result is always in the range -π / 2 to +π / 2. -**EXAMPLEs of ATN Function:** +**EXAMPLES of the ATN Function:** ```BASIC 10 PRINT ATN(5) @@ -337,7 +337,7 @@ Note: In the above example, the `SYS $C063` in ROM bank 10 is a call to [ym_init Note: BANK uses its own register to store the command's desired bank numbers; this will not always be the same as the value stored in `$00` or `$01`. In fact, `$01` is always going to read `4` when PEEKing from BASIC. If you need to know the currently selected RAM and/or RAM banks, you should explicitly set them and use variables to track your selected bank number(s). -Note: Memory address `$00`, which is the hardware RAM bank register, will usually report the bank set by the `BANK` command. The one exception is after a [BLOAD](#bload) or [BVERIFY](#bverify) inside of a running BASIC program. `BLOAD` and `BVERIFY` change the RAM bank (as if you called `BANK`) to the bank that `BLOAD` or `BVERIFY` stopped at. +Note: Memory address `$00`, which is the hardware RAM bank register, will usually report the bank set by the [BANK](#bank) command. The one exception is after a [BLOAD](#bload) or [BVERIFY](#bverify) inside of a running BASIC program. `BLOAD` and `BVERIFY` change the RAM bank (as if you called `BANK`) to the bank that `BLOAD` or `BVERIFY` stopped at. ### BASLOAD @@ -379,7 +379,7 @@ PRINT BIN$(45231) : REM PRINTS 1011000010101111 TO REPRESENT 16 BITS ### BINPUT# -**TYPE: Command** +**TYPE: I/O Statement** **FORMAT: BINPUT# <n>,<var$>,<len>** **Action:** `BINPUT#` Reads a block of data from an open file and stores the data into a string variable. If there are fewer than `` bytes available to be read from the file, fewer bytes will be stored. If the end of the file is reached, `ST AND 64` will be true. @@ -401,7 +401,7 @@ PRINT BIN$(45231) : REM PRINTS 1011000010101111 TO REPRESENT 16 BITS **Action:** Load and run a PRG file named `AUTOBOOT.X16` from device 8. If the file is not found, nothing is done and no error is printed. -**EXAMPLE of the BOOT Statement:** +**EXAMPLE of the BOOT Command:** ```BASIC BOOT @@ -418,7 +418,7 @@ Note: If the file is loaded to high RAM (starting in the range `$A000-$BFFF`), a After a successful load, `$030D` and `$030E` will contain the address of the final byte loaded + 1. If relevant, the value in memory location `$00` will point to the bank in which the next byte would have been loaded. -**EXAMPLES of BLOAD:** +**EXAMPLES of the BLOAD Command:** ```BASIC BLOAD "MYFILE.BIN",8,1,$A000:REM LOADS A FILE NAMED MYFILE.BIN FROM DEVICE 8 STARTING IN BANK 1 AT $A000. @@ -432,23 +432,23 @@ BLOAD "WHO.PCX",8,10,$B000:REM LOADS A FILE NAMED WHO.PCX INTO RAM STARTING IN B **Action:** Saves a region of memory to a binary file. -Note: The save will stop one byte before `end address`. +Note: The save will stop one byte before <end address>. -This command does not allow for automatic bank advancing, but you can achieve a similar result with successive BSAVE invocations to append additional memory locations to the same file. +This command does not allow for automatic bank advancing, but you can achieve a similar result with successive `BSAVE` invocations to append additional memory locations to the same file. -**EXAMPLES of BSAVE:** +**EXAMPLES of the BSAVE Command:** ```BASIC BSAVE "MYFILE.BIN",8,1,$A000,$C000 ``` -The above example saves a region of memory from \$A000 in bank 1 through and including \$BFFF, stopping before \$C000. +The above example saves a region of memory from `$A000` in bank 1 through and including `$BFFF`, stopping before `$C000`. ```BASIC BSAVE "MYFILE.BIN,S,A",8,2,$A000,$B000 ``` -The above example appends a region of memory from \$A000 through and including \$AFFF, stopping before \$B000. Running both of the above examples in succession will result in a file MYFILE.BIN 12KiB in size. +The above example appends a region of memory from `$A000` through and including `$AFFF`, stopping before `$B000`. Running both of the above examples in succession will result in a file MYFILE.BIN 12KiB in size. **Warning:** Appending to file involves a risk of corrupting the file system of the SD card! See [Appending to file](X16%20Reference%20-%2013%20-%20Working%20with%20CMDR-DOS.md#appending-to-file). @@ -459,13 +459,13 @@ The above example appends a region of memory from \$A000 through and including \ **Action:** Verifies that a file on disk matches RAM contents. -**EXAMPLE of the BSAVE:** +**EXAMPLE of the BVERIFY Command:** ```BASIC BVERIFY "MYFILE.BIN",8,1,$A000,$C000 ``` -The above example compares a region of memory from \$A000 in bank 1 through and including \$BFFF, stopping before \$C000, against the filename listed. +The above example compares a region of memory from `$A000` in bank 1 through and including `$BFFF`, stopping before `$C000`, against the filename listed. ### BVLOAD @@ -475,7 +475,7 @@ The above example compares a region of memory from \$A000 in bank 1 through and **Action:** Loads a binary file directly into VERA RAM. -**EXAMPLES of BVLOAD:** +**EXAMPLES of the BVLOAD Command:** ```BASIC BVLOAD "MYFILE.BIN", 8, 0, $4000 :REM LOADS MYFILE.BIN FROM DEVICE 8 TO VRAM $4000. @@ -484,7 +484,7 @@ BVLOAD "MYFONT.BIN", 8, 1, $F000 :REM LOAD A FONT INTO THE DEFAULT FONT LOCATIO ### CHAR -**TYPE: Command** +**TYPE: Statement** **FORMAT: CHAR <x>,<y>,<color>,<string>** **Action:** This command draws a text string on the graphics screen in a given color. @@ -528,7 +528,7 @@ The string can contain printable ASCII characters (`CHR$($20)` to `CHR$($7E)`), **TYPE: I/O Statement** **FORMAT: CLOSE <file number>** -**Action:** Closes any files used by `OPEN` statements. The `CLOSE` statement takes a single argument that is the file number to be closed. +**Action:** Closes any files used by [OPEN](#open) statements. The `CLOSE` statement takes a single argument that is the file number to be closed. **EXAMPLE of the CLOSE I/O Statement:** @@ -539,11 +539,11 @@ CLOSE 4 : REM CLOSE FILE OPENED AS 4 ### CLR -**TYPE: Command** +**TYPE: Statement** **FORMAT: CLR** **Action:** This statement clears RAM that had been used, but is no longer needed. -The BASIC program in memory is untouched, but all variables, arrays, GOSUB addresses, FOR..NEXT loops, +The BASIC program in memory is untouched, but all variables, arrays, [GOSUB](#gosub) addresses, [FOR..NEXT](#for-to-step) loops, user-defined functions, and files are erased from memory, and their space is made available to new variables, etc. @@ -572,12 +572,12 @@ CLS **TYPE: I/O Statement** **FORMAT: CMD <file number>[, string]** -**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem1. The file number must be specified in a prior `OPEN` statemewnt. The string, when specified, is sent to the file. This is handy +**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem1. The file number must be specified in a prior [OPEN](#open) statemewnt. The string, when specified, is sent to the file. This is handy for titling printouts, etc. -When this command is in effect, any `PRINT` statements and `LIST` commands will not display on the screen, but will send the text in the same format to the file. +When this command is in effect, any [PRINT](#print) statements and [LIST](#list) commands will not display on the screen, but will send the text in the same format to the file. -To re-direcet the output back to the screen, the `PRINT#` command should send a blank line to the `CMD` device before `CLOSE`ing, so it will stop expecting data. This is called "un-listening" the device. +To re-direcet the output back to the screen, the [PRINT#](#print-1) command should send a blank line to the [CMD](#cmd) device before [CLOSE](#close)ing, so it will stop expecting data. This is called "un-listening" the device. Any system error (like `?SYNTAX ERROR`) will cause output to return to the screen. Devices aren't un-listened by this, so you should send a blank line after an error condition. @@ -600,12 +600,12 @@ PRINT# 4: CLOSE 4: REM Un-listens and closes printer ### COLOR -**TYPE: Command** +**TYPE: Statement** **FORMAT: COLOR <fgcol>[,<bgcol>]** **Action:** This command works sets the text mode foreground color, and optionally the background color. -**EXAMPLES of COLOR Statement:** +**EXAMPLES of the COLOR Statement:** ```BASIC COLOR 2 : REM SET FG COLOR TO RED, KEEP BG COLOR @@ -617,7 +617,7 @@ COLOR 2,0 : REM SET FG COLOR TO RED, BG COLOR TO BLACK **TYPE: Command** **FORMAT: CONT** -**Action:** This command re-starts the execution of a program which was halted by a `STOP` or `END` statement, or the **RUN/STOP** key being pressed. The program will re-start at the exact place from which it left off. +**Action:** This command re-starts the execution of a program which was halted by a [STOP](#stop) or [END](#end) statement, or the **RUN/STOP** key being pressed. The program will re-start at the exact place from which it left off. While the program is stopped, the user can inspect or change any variables or look at the program. When debugging or examing a program, `STOP` statements can be placed at strategic locations to allow examination of variables and check the flow of the program. @@ -642,7 +642,6 @@ Where `x` is the line number where program execution was interrupted. Type the command `PRINT C` to see how far the Commander X16 has gotten. Then use `CONT` to resume from where the Commander X16 left off. - ### COS **TYPE: Function** From bb992d0b60b0350abc9bb2a3772a831ed2b9a141 Mon Sep 17 00:00:00 2001 From: geneb Date: Wed, 21 Jan 2026 09:50:28 -0800 Subject: [PATCH 12/13] WIP: All keyword documentation is complete. Added new graphics to replace two of the quote mode examples. --- X16 Reference - 04 - BASIC.md | 420 ++++++++++++++-------------- images/print-color-example.png | Bin 0 -> 5847 bytes images/print-screen-pos-example.png | Bin 0 -> 1724 bytes 3 files changed, 217 insertions(+), 203 deletions(-) create mode 100644 images/print-color-example.png create mode 100644 images/print-screen-pos-example.png diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index ab9bcb3..88dcf8b 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -27,12 +27,12 @@ when viewed on github. PDF output appears correct. | [`BVERIFY`](#bverify) | Command | Verifies that a file on disk matches RAM contents | X16 | | [`BVLOAD`](#bvload) | Command | Loads a headerless binary file from disk to VRAM | X16 | | [`CHAR`](#char) | Command | Draws a text string in graphics mode | X16 | -| [`CHR$`](#chr$) | String Function | Returns PETSCII character from numeric value | C64 | +| [`CHR$`](#chr) | String Function | Returns PETSCII character from numeric value | C64 | | [`CLOSE`](#close) | I/O Statement | Closes a logical file number | C64 | | [`CLR`](#clr) | Statement | Clears BASIC variable state | C64 | | [`CLS`](#cls) | Statement | Clears the screen | X16 | | [`CMD`](#cmd) | I/O Statement | Redirects output to non-screen device | C64 | -| [`COLOR`](#color) | Statement | Sets text fg and bg color | X16 | +| [`COLOR`](#color) | Statement | Sets text foreground and background color | X16 | | [`CONT`](#cont) | Command | Resumes execution of a BASIC program | C64 | | [`COS`](#cos) | Function | Returns cosine of an angle in radians | C64 | | [`DA$`](#da$) | String Function | Returns the date in YYYYMMDD format from the system clock | X16 | @@ -145,7 +145,7 @@ when viewed on github. PDF output appears correct. | [`STRPTR`](#strptr) | Function | Returns the address of a BASIC string | X16 | | [`SYS`](#sys) | Command | Transfers control to machine language at a memory address | C64 | | [`TAB`](#tab) | Special Function | Returns a string with spaces used for column alignment | C64 | -| [`TAN`] | Floating-Point Function | Return the tangent for an angle in radians | C64 | +| [`TAN`](#tan) | Floating-Point Function | Return the tangent for an angle in radians | C64 | | [`TATTR`](#tattr) | Function | Returns a tile attribute from the tile/text layer | X16 | | [`TDATA`](#tdata) | Function | Returns a tile from the tile/text layer | X16 | | [`TILE`](#tile) | Command | Changes a tile or character on the tile/text layer | X16 | @@ -173,7 +173,7 @@ The Commander X16 BASIC interpreter is 100% backwards-compatible with the Commod * `CHR$(14)`: switch to upper/lowercase font * `CHR$(142)`: switch to uppercase/graphics font * The BASIC vector table ($0300-$030B, $0311/$0312) -* [SYS](#sys) arguments in RAM +* [`SYS`](#sys) arguments in RAM Because of the differences in hardware, the following functions and statements are incompatible between C64 and X16 BASIC programs. @@ -186,7 +186,7 @@ The BASIC interpreter also currently shares all problems of the C64 version, lik ## Saving Files -By default, you cannot automatically overwrite a file with [SAVE](#save), [BSAVE](#bsave), or [OPEN](#open). To overwrite a file, you must prefix the filename with `@:`, like this: `SAVE "@:HELLO WORLD"`. (`"@0:filename"` is also acceptable.) +By default, you cannot automatically overwrite a file with [`SAVE`](#save), [`BSAVE`](#bsave), or [`OPEN`](#open). To overwrite a file, you must prefix the filename with `@:`, like this: `SAVE "@:HELLO WORLD"`. (`"@0:filename"` is also acceptable.) This follows the Commodore convention, which extended to all of their diskette drives and third party hard drives and flash drive readers. @@ -194,7 +194,7 @@ Always confirm you have successfully saved a file by checking the DOS status. Wh There are two ways to check the error channel from inside a program: -1. You can use the [DOS](#dos) command and make the user perform actions necessary to recover from an error (such as re-saving the file with an @: prefix). +1. You can use the [`DOS`](#dos) command and make the user perform actions necessary to recover from an error (such as re-saving the file with an @: prefix). 2. You can read the error yourself, using the following BASIC code: ```BASIC @@ -208,7 +208,7 @@ Refer to [Chapter 13](X16%20Reference%20-%2013%20-%20Working%20with%20CMDR-DOS.m ## New Statements and Functions -There are several new statement and functions. Note that all BASIC keywords (such as [FOR](#for)) get converted into tokens (such as `$81`), and the tokens for the new keywords have likely shifted from one ROM version to the next. Therefore, loading BASIC program saved from an old revision of BASIC may mix up keywords. As of ROM version R42, the keyword token positions should no longer shift and programs saved in R42 BASIC should be compatible with future versions. +There are several new statement and functions. Note that all BASIC keywords (such as [`FOR`](#for-to-step)) get converted into tokens (such as `$81`), and the tokens for the new keywords have likely shifted from one ROM version to the next. Therefore, loading BASIC program saved from an old revision of BASIC may mix up keywords. As of ROM version R42, the keyword token positions should no longer shift and programs saved in R42 BASIC should be compatible with future versions. ### ABS @@ -323,21 +323,21 @@ PRINT ASC("") **TYPE: Command** **FORMAT: BANK m[,n]** -**Action:** Set the active RAM (m) and ROM bank (n) for the purposes of [PEEK](#peek), [POKE](#poke), and [SYS](#sys). Specifying the ROM bank is optional. If it is not specified, its previous value is retained. +**Action:** Set the active RAM (m) and ROM bank (n) for the purposes of [`PEEK`](#peek), [`POKE`](#poke), and [`SYS`](#sys). Specifying the ROM bank is optional. If it is not specified, its previous value is retained. **EXAMPLE of the BANK Statement:** ```BASIC BANK 1,10 : REM SETS THE RAM BANK TO 1 AND THE ROM BANK TO 10 -?PEEK($A000) : REM PRINTS OUT THE VALUE STORED IN $A000 IN RAM BANK 1 +PRINT PEEK($A000) : REM PRINTS OUT THE VALUE STORED IN $A000 IN RAM BANK 1 SYS $C063 : REM CALLS ROUTINE AT $C09F IN ROM BANK 10 AUDIO (YM_INIT) ``` -Note: In the above example, the `SYS $C063` in ROM bank 10 is a call to [ym_init](X16%20Reference%20-%2011%20-%20Sound%20Programming.md#audio-api-routines), which does the first half of what the BASIC command [FMINIT](#fminit) does, without setting any default instruments. It is generally not recommended to call routines in ROM directly this way, and most BASIC programmers will never have a need to call [SYS](#sys) directly, but advanced users may find a good reason to do so. +Note: In the above example, the `SYS $C063` in ROM bank 10 is a call to [ym_init](X16%20Reference%20-%2011%20-%20Sound%20Programming.md#audio-api-routines), which does the first half of what the BASIC command [`FMINIT`](#fminit) does, without setting any default instruments. It is generally not recommended to call routines in ROM directly this way, and most BASIC programmers will never have a need to call [`SYS`](#sys) directly, but advanced users may find a good reason to do so. Note: BANK uses its own register to store the command's desired bank numbers; this will not always be the same as the value stored in `$00` or `$01`. In fact, `$01` is always going to read `4` when PEEKing from BASIC. If you need to know the currently selected RAM and/or RAM banks, you should explicitly set them and use variables to track your selected bank number(s). -Note: Memory address `$00`, which is the hardware RAM bank register, will usually report the bank set by the [BANK](#bank) command. The one exception is after a [BLOAD](#bload) or [BVERIFY](#bverify) inside of a running BASIC program. `BLOAD` and `BVERIFY` change the RAM bank (as if you called `BANK`) to the bank that `BLOAD` or `BVERIFY` stopped at. +Note: Memory address `$00`, which is the hardware RAM bank register, will usually report the bank set by the `BANK` statement. The one exception is after a [`BLOAD`](#bload) or [`BVERIFY`](#bverify) inside of a running BASIC program. `BLOAD` and `BVERIFY` change the RAM bank (as if you called `BANK`) to the bank that `BLOAD` or `BVERIFY` stopped at. ### BASLOAD @@ -346,7 +346,7 @@ Note: Memory address `$00`, which is the hardware RAM bank register, will usuall **Action:** Loads a plain text file with `BASLOAD` source and converts it into a runnable program. -The device number is optional. If it's not specified, the current device is used. The current device is set to 8 at system boot and may be changed with the [DOS](#dos) command. +The device number is optional. If it's not specified, the current device is used. The current device is set to 8 at system boot and may be changed with the [`DOS`](#dos) command. For more information about `BASLOAD`, see [this external documentation](https://github.com/stefan-b-jakobsson/basload-rom) @@ -382,7 +382,7 @@ PRINT BIN$(45231) : REM PRINTS 1011000010101111 TO REPRESENT 16 BITS **TYPE: I/O Statement** **FORMAT: BINPUT# <n>,<var$>,<len>** -**Action:** `BINPUT#` Reads a block of data from an open file and stores the data into a string variable. If there are fewer than `` bytes available to be read from the file, fewer bytes will be stored. If the end of the file is reached, `ST AND 64` will be true. +**Action:** `BINPUT#` Reads a block of data from an open file and stores the data into a string variable. If there are fewer than <len> bytes available to be read from the file, fewer bytes will be stored. If the end of the file is reached, [`ST`](#st)` AND 64` will be true. **EXAMPLE of the BINPUT# Statement:** @@ -528,7 +528,7 @@ The string can contain printable ASCII characters (`CHR$($20)` to `CHR$($7E)`), **TYPE: I/O Statement** **FORMAT: CLOSE <file number>** -**Action:** Closes any files used by [OPEN](#open) statements. The `CLOSE` statement takes a single argument that is the file number to be closed. +**Action:** Closes any files used by [`OPEN`](#open) statements. The `CLOSE` statement takes a single argument that is the file number to be closed. **EXAMPLE of the CLOSE I/O Statement:** @@ -543,9 +543,7 @@ CLOSE 4 : REM CLOSE FILE OPENED AS 4 **FORMAT: CLR** **Action:** This statement clears RAM that had been used, but is no longer needed. -The BASIC program in memory is untouched, but all variables, arrays, [GOSUB](#gosub) addresses, [FOR..NEXT](#for-to-step) loops, -user-defined functions, and files are erased from memory, and their space is made available to new -variables, etc. +The BASIC program in memory is untouched, but all variables, arrays, [`GOSUB`](#gosub) addresses, [`FOR..NEXT`](#for-to-step) loops, user-defined functions, and files are erased from memory, and their space is made available to new variables, etc. **EXAMPLE of the CLR Statement:** @@ -559,7 +557,7 @@ CLR **TYPE: Command** **FORMAT: CLS** -**Action:** Clears the screen. Same effect as `?CHR$(147);`. +**Action:** Clears the screen. Same effect as `PRINT CHR$(147);`. **EXAMPLE of the CLS Statement:** @@ -572,12 +570,12 @@ CLS **TYPE: I/O Statement** **FORMAT: CMD <file number>[, string]** -**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem1. The file number must be specified in a prior [OPEN](#open) statemewnt. The string, when specified, is sent to the file. This is handy +**Action:** This statement switches the primary output device from the video display to the file specified. This file could be on disk, a printer, or an I/O device like the modem1. The file number must be specified in a prior [OPEN](#open) statement. The string, when specified, is sent to the file. This is handy for titling printouts, etc. -When this command is in effect, any [PRINT](#print) statements and [LIST](#list) commands will not display on the screen, but will send the text in the same format to the file. +When this command is in effect, any [`PRINT`](#print) statements and [`LIST`](#list) commands will not display on the screen, but will send the text in the same format to the file. -To re-direcet the output back to the screen, the [PRINT#](#print-1) command should send a blank line to the [CMD](#cmd) device before [CLOSE](#close)ing, so it will stop expecting data. This is called "un-listening" the device. +To re-direct the output back to the screen, the [`PRINT#`](#print-1) command should send a blank line to the [`CMD`](#cmd) device before [`CLOSE`](#close)ing, so it will stop expecting data. This is called "un-listening" the device. Any system error (like `?SYNTAX ERROR`) will cause output to return to the screen. Devices aren't un-listened by this, so you should send a blank line after an error condition. @@ -617,7 +615,7 @@ COLOR 2,0 : REM SET FG COLOR TO RED, BG COLOR TO BLACK **TYPE: Command** **FORMAT: CONT** -**Action:** This command re-starts the execution of a program which was halted by a [STOP](#stop) or [END](#end) statement, or the **RUN/STOP** key being pressed. The program will re-start at the exact place from which it left off. +**Action:** This command re-starts the execution of a program which was halted by a [`STOP`](#stop) or [`END`](#end) statement, or the **RUN/STOP** key being pressed. The program will re-start at the exact place from which it left off. While the program is stopped, the user can inspect or change any variables or look at the program. When debugging or examing a program, `STOP` statements can be placed at strategic locations to allow examination of variables and check the flow of the program. @@ -633,7 +631,7 @@ The error message `?CAN'T CONTINUE` will result from editing the program (even j 40 C=C+4 : GOTO 20 ``` -This program calculats the value of PI. Run this program, and after a few seconds, hit the **RUN/STOP** key. You will see the display: +This program calculates the value of PI. Run this program, and after a few seconds, hit the **RUN/STOP** key. You will see the display: ``` BREAK IN x @@ -680,7 +678,7 @@ Type the command `PRINT C` to see how far the Commander X16 has gotten. Then us **TYPE: Statement** **FORMAT: DATA <list of constants>** -**Action:** `DATA` statements store information within a program. The program uses the information by means of the `READ` statement, which pulls successive constants from the `DATA` statements. +**Action:** `DATA` statements store information within a program. The program uses the information by means of the [`READ`](#read) statement, which pulls successive constants from the `DATA` statements. The `DATA` statements don't have to be executed by the program, they only have to be present. Therefore, they are usually placed at the end of the program. @@ -704,13 +702,11 @@ Any characters can be included as data, but if certain ones are used, the data i **TYPE: Statement** **FORMAT: DEF FN <name> (<variable>) = <expression>** -**Action:** This sets up a user-defined function that can be used later in the program. -The function can consist of any mathematical formula. +**Action:** This sets up a user-defined function that can be used later in the program. The function can consist of any mathematical formula. User-defined functions save space in programs where a long formula is used in several places. The formula need only be specified once, in the definition statement, and then it is abbreviated as a function name. It must be executed once, but any subsequent executions are ignored. -The function name is the letters `FN` followed by any variable name. -This can be 1 or 2 characters, the first being a letter and the second a letter or digit. +The function name is the letters `FN` followed by any variable name. This can be 1 or 2 characters, the first being a letter and the second a letter or digit. **EXAMPLES of the DEF FN Statement:** @@ -776,7 +772,7 @@ If an array referenced in a program was never `DIM`ensioned, it is automatically * With an argument starting with `"$"`, it shows the directory of the device. * Any other argument will be sent as a DOS command. -**EXAMPLES of DOS Statement:** +**EXAMPLES of the DOS Command:** ```BASIC DOS"$" : REM SHOWS DIRECTORY @@ -811,7 +807,7 @@ A more elaborate X16-Edit manual can be found [here](https://github.com/X16Commu **Action:** This finishes a program's execution and displays the `READY` message, returning control to the person operating the computer. There may be any number of `END` statements within a program. While it is not necessary to include any `END` statements at all, it is recommended that a program does conclude with one, rather than just running out of lines. -The `END` statement is similar to the `STOP` statement. The only difference is that `STOP` causes the computer to display the messsage `BREAK IN XX` and `END` just displays `READY`. both statements allow the computer to resume execution by typing the `CONT` command. +The `END` statement is similar to the [`STOP`](#stop) statement. The only difference is that `STOP` causes the computer to display the message `BREAK IN XX` and `END` just displays `READY`. both statements allow the computer to resume execution by typing the [`CONT`](#cont) command. **EXAMPLES of the END Statement: ```BASIC @@ -830,7 +826,7 @@ The `END` statement is similar to the `STOP` statement. The only difference is **Action:** Plays back a null-terminated script from MEMORY into the BASIC editor. Among other uses, this can be used to "type" in a program from a plain text file. -* If the `ram bank` argument is omitted and the address is in the range \$A000-\$BFFF, the RAM bank selected by the `BANK` command is used. +* If the `ram bank` argument is omitted and the address is in the range \$A000-\$BFFF, the RAM bank selected by the [`BANK`](#bank) command is used. * The input can span multiple RAM banks. The input will stop once it reaches a null byte ($00) or if a BASIC error occurs. * The redirected input only applies to BASIC immediate mode. While programs are running, the EXEC handling is suspended. @@ -857,7 +853,7 @@ it for you: **TYPE: Numeric Function** **FORMAT: EXP (<number>)** -**Action:** This mathematical function calculates the constant e (2.71828183) raised to the power of the number given. A value greater than 88.0296919 causes an `?OVERFLOW` error to occur. +**Action:** This mathematical function calculates the constant e (2.71828183) raised to the power of the number given. A value greater than 88.0296919 causes `?OVERFLOW ERROR` to occur. **EXAMPLES of the EXP Function:** @@ -868,16 +864,16 @@ it for you: ### FMCHORD -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMCHORD <first channel>,<string>** -**Action:** This command uses the same syntax as `FMPLAY`, but instead of playing a series of notes, it will start all of the notes in the string simultaneously on one or more channels. The first parameter to `FMCHORD` is the first channel to use, and will be used for the first note in the string, and subsequent notes in the string will be started on subsequent channels, with the channel after 7 being channel 0. +**Action:** This command uses the same syntax as [`FMPLAY`](#fmplay), but instead of playing a series of notes, it will start all of the notes in the string simultaneously on one or more channels. The first parameter to `FMCHORD` is the first channel to use, and will be used for the first note in the string, and subsequent notes in the string will be started on subsequent channels, with the channel after 7 being channel 0. -All macros are supported, even the ones that only affect the behavior of `PSGPLAY` and `FMPLAY`. +All macros are supported, even the ones that only affect the behavior of [`PSGPLAY`](#psgplay) and [`FMPLAY`](#fmplay). The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of the FMCHORD statement:** +**EXAMPLE of the FMCHORD Statement:** ```BASIC 10 FMINIT @@ -901,19 +897,19 @@ This will play the first few lines of _Silent Night_ with a vibraphone lead and ### FMDRUM -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMDRUM <channel>,<drum number>** **Action:** Loads a [drum preset](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#drum-presets "list of drum presets") onto the YM2151 and triggers it. Valid range is from 25 to 87, corresponding to the General MIDI percussion note values. FMDRUM will load a patch preset corresponding to the selected drum into the channel. If you then try to play notes on that same channel without loading an instrument patch, it will use the drum patch that was loaded for the drum sound instead, which may not sound particularly musical. ### FMFREQ -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMFREQ <channel>,<frequency>** -**Action:** Play a note by frequency on the YM2151. The accepted range is in Hz from 17 to 4434. FMFREQ also accepts a frequency of 0 to release the note. +**Action:** Play a note by frequency on the YM2151. The accepted range is in Hz from 17 to 4434. `FMFREQ` also accepts a frequency of 0 to release the note. -**EXAMPLE of the FMFREQ statement:** +**EXAMPLE of the FMFREQ Statement:** ```BASIC 0 FMINST 0,160 : REM LOAD PURE SINE PATCH @@ -928,21 +924,21 @@ The above BASIC program plays a sound similar to a North American dial tone for ### FMINIT -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMINIT** -**Action:** Initialize YM2151, silence all channels, and load a set of default patches into all 8 channels. +**Action:** Initialize the YM2151, silence all channels, and load a set of default patches into all 8 channels. ### FMINST -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMINST <channel>,<patch>** Load an instrument onto the YM2151 in the form of a [patch preset](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#fm-instrument-patch-presets) into a channel. Valid channels range from 0 to 7. Valid patches range from 0 to 162. ### FMNOTE -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMNOTE <channel>,<note>** **Action:** Play a note on the YM2151. The note value is constructed as follows. Using hexadecimal notation, the first nybble is the octave, 0-7, and the second nybble is the note within the octave as follows: @@ -953,7 +949,7 @@ Load an instrument onto the YM2151 in the form of a [patch preset](X16%20Referen Notes can also be represented by negative numbers to skip retriggering, and will thus snap to another note without restarting the playback of the note. -**EXAMPLE of the FMNOTE statement:** +**EXAMPLE of the FMNOTE Statement:** ```BASIC 0 FMINST 1,64 : REM LOAD SOPRANO SAX @@ -970,7 +966,7 @@ Notes can also be represented by negative numbers to skip retriggering, and will ### FMPAN -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMPAN <channel>,<panning>** **Action:** Sets the simple stereo panning on a YM2151 channel. Valid values are as follows: @@ -981,14 +977,14 @@ Notes can also be represented by negative numbers to skip retriggering, and will ### FMPLAY -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMPLAY <channel>,<string>** **Action:** This command is very similar to `PLAY` on other BASICs such as GWBASIC. It takes a string of notes, rests, tempo changes, note lengths, and other macros, and plays all of the notes synchronously. That is, the FMPLAY command will not return control until all of the notes and rests in the string have been fully played. The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of the FMPLAY statement:** +**EXAMPLE of the FMPLAY Statement:** ```BASIC 10 FMINIT : REM INITIALIZE AND LOAD DEFAULT PATCHES, WILL USE E.PIANO @@ -1000,12 +996,12 @@ The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%2 ### FMPOKE -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMPOKE <register>,<value>** **Action:** This command uses the AUDIO API to write a value to one of the YM2151's registers at a low level. -**EXAMPLE of the FMPOKE statement:** +**EXAMPLE of the FMPOKE Statement:** ```BASIC 10 FMINIT @@ -1025,7 +1021,7 @@ Only some patch presets (instruments) are sensitive to the LFO. Those are marked Good values for most instruments are speed somewhere between 190-220. A good light vibrato for most wind instruments would have a depth of 10-15, while tremolo instruments like the Vibraphone or Tremolo Strings are most realistic around 20-30. -**EXAMPLE of the FMVIB statement:** +**EXAMPLE of the FMVIB Statement:** ```BASIC 10 FMVIB 200,30 @@ -1039,17 +1035,17 @@ The above BASIC program plays a C major scale with a vibraphone patch, first wit ### FMVOL -**TYPE: Command** +**TYPE: Statement** **FORMAT: FMVOL <channel>,<volume>** -**Action:** This command sets the channel's volume. The volume remains at the requested level until another `FMVOL` command for that channel or `FMINIT` is called. Valid range is from 0 (completely silent) to 63 (full volume) +**Action:** This command sets the channel's volume. The volume remains at the requested level until another `FMVOL` command for that channel or [`FMINIT`](#fminit) is called. Valid range is from 0 (completely silent) to 63 (full volume) ### FN **TYPE: Numeric Function** **FORMAT: FN <name> (<number>)** -**Action:** This function references the previously `DEF`ined formula specified by name. The number is substituted into its place (if any) and the formula is calculated. The result will be a numeric value. +**Action:** This function references the previously [`DEF`](#def-fn)ined formula specified by name. The number is substituted into its place (if any) and the formula is calculated. The result will be a numeric value. This function can be used in direct mode, as long as the statement `DEF`ining it has been executed. @@ -1070,7 +1066,7 @@ PRINT FN Z(Q) **Action:** This is a special BASIC statement that lets you easily use a variable as a counter. You must specify certain parameters: the floating-point variable name, its starting value, the limit of the count, and how much to add during each cycle. -Here is a simple BASIC program that counts from 1 to 10, `PRINT`ing each number and `END`ing when complete, and using no `FOR` statements: +Here is a simple BASIC program that counts from 1 to 10, [`PRINT`](#print)ing each number and [`END`](#end)ing when complete, and using no `FOR` statements: ```BASIC 10 A = 1 20 PRINT A @@ -1090,7 +1086,7 @@ As you can see, the program is shorter and easier to understand using the `FOR` When the `FOR` statement is executed, several operations take place. The <start> value is placed in the <variable> being used in the counter. In the example above, a 1 is placed in `A`. -When the `NEXT` statement is reached, the <increment> value is added to the <variable>. If a `STEP` was not included, the <increment> is set to +1. The first time the program hits line 30, 1 is added to `A`, so the new value of `A` is 2. +When the [`NEXT`](#next) statement is reached, the <increment> value is added to the <variable>. If a `STEP` was not included, the <increment> is set to +1. The first time the program hits line 30, 1 is added to `A`, so the new value of `A` is 2. Now the value in the <variable> is compared to the <limit>. if the <limit> has not been reached yet, the program `GO`es `TO` the line after the original `FOR` statement. In this case, the value of 2 in `A` is less than the limit of 10, so it `GO`es `TO` line 20. @@ -1109,7 +1105,7 @@ When the value of <increment> is positive, the <variable> must excee ### FRAME -**TYPE: Command** +**TYPE: Statement** **FORMAT: FRAME <x1>,<y1>,<x2>,<y2>,<color>** **Action:** This command draws a rectangle frame on the graphics screen in a given color. @@ -1147,13 +1143,13 @@ PRINT FRE(0) - (FRE(0) < 0) * 65536 ### GET **TYPE: Statement** -**FORMAT: GET <variable list>** +**FORMAT: GET <variable list>** **Action:** This statement reads each key typed by the user. As the user is typing, the characters are stored in the Commander X16's keyboard buffer. Up to 10 characters are stored here, and any keys struck after the 10th are discarded. Reading one of the characters with the `GET` statement makes room for another character. If the `GET` statement specifies numeric data, and the user types a key other than a number, the message `?SYNTAX ERROR` appears. To be safe, read the keys as strings and convert them to numbers later. -The `GET` statement can be used to avoid some of the limitations of the `INPUT` statement. For more on this, see the section on Using the `GET` Statement in the Programming Techniques2 section. +The `GET` statement can be used to avoid some of the limitations of the [`INPUT`](#input) statement. For more on this, see the section on Using the `GET` Statement in the Programming Techniques2 section. **EXAMPLES of the GET Statement:** @@ -1170,7 +1166,7 @@ The `GET` statement can be used to avoid some of the limitations of the `INPUT` **TYPE: I/O Statement** **FORMAT: GET# <file number>, <variable list>** -**Action:** This statement reads characters one-at-a-time from the device or file specified. It works the same as the `GET` statement, except that the data comes from a different place than the keyboard. If no character is received, the variable list is set to an empty string (equal to "") or to 0 for numeric variables. Characters used to separate data in files, like the comma `(,)` or **RETURN** key code (ASCII code of 13), are received like any other character. +**Action:** This statement reads characters one-at-a-time from the device or file specified. It works the same as the [`GET`](#get) statement, except that the data comes from a different place than the keyboard. If no character is received, the variable list is set to an empty string (equal to "") or to 0 for numeric variables. Characters used to separate data in files, like the comma `(,)` or **RETURN** key code (ASCII code of 13), are received like any other character. **EXAMPLES of the GET# Statement:** @@ -1185,9 +1181,9 @@ The `GET` statement can be used to avoid some of the limitations of the `INPUT` **TYPE: Statement** **FORMAT: GOSUB <line number>** -**Action** This is a specialized form of the `GOTO` statement, with one important difference: `GOSUB` remembers where it came from. When the `RETURN` statement (different from the **RETURN** key on the keyboard) is reached in the program, the program jumps back to the statement immediately following the original `GOSUB` statement. +**Action** This is a specialized form of the [`GOTO`](#goto) statement, with one important difference: [`GOSUB`,](#gosub) remembers where it came from. When the [`RETURN`](#return) statement (different from the **RETURN** key on the keyboard) is reached in the program, the program jumps back to the statement immediately following the original `GOSUB` statement. -The major use of a subroutine (`GOSUB` means `GO` to a `SUB`-routine) is when a small section of program is used by different sections of the program. By using subroutines rather that repeating the same lines over and over at different places in the program, you can save lots of program space. In this way, `GOSUB` is similar to `DEF FN`. `DEF FN` lets you save space when using a formula, while `GOSUB` saves space when using a several-line routine. +The major use of a subroutine (`GOSUB` means `GO` to a `SUB`-routine) is when a small section of program is used by different sections of the program. By using subroutines rather that repeating the same lines over and over at different places in the program, you can save lots of program space. In this way, `GOSUB` is similar to [`DEF FN`](#def-fn). `DEF FN` lets you save space when using a formula, while `GOSUB` saves space when using a several-line routine. **An inefficient program that doesn't use `GOSUB`** ```BASIC @@ -1269,11 +1265,11 @@ PRINT HEX$(45231) : REM PRINTS B0AF TO REPRESENT 16 BIT VALUE PRINT HEX$(I2CPEEK($6F,0) AND $7F) ``` -This command reports the seconds counter from the RTC by converting its internal BCD representation to a string. +This command reports the seconds counter from the system clock by converting its internal BCD representation to a string. ### I2CPOKE -**TYPE: Command** +**TYPE: Statement** **FORMAT: I2CPOKE <device>,<register>,<value>** **Action:** Sets the value to a register on an I²C device. @@ -1296,7 +1292,7 @@ This command sets a byte in NVRAM on the RTC to the value `$80` **Action:** This is the statement that gives BASIC most of its "intelligence", the ability to evaluate conditions and take different actions depending on the outcome. -The word `IF` is followed by an expression, which can include variables, strings, numbers, comparisons, and logical operators. The word `THEN` appears on the same line and is followed by either a line number or one or more BASIC statments. When the expression is false, everything else after the word `THEN` on that line is ignored, and execution continues with the next line number in the program. A true result makes the progrm either branch to the line number after the word `THEN` or execute whatever other BASIC statements are found on that line. +The word `IF` is followed by an expression, which can include variables, strings, numbers, comparisons, and logical operators. The word `THEN` appears on the same line and is followed by either a line number or one or more BASIC statements. When the expression is false, everything else after the word `THEN` on that line is ignored, and execution continues with the next line number in the program. A true result makes the program either branch to the line number after the word `THEN` or execute whatever other BASIC statements are found on that line. **EXAMPLE of the IF...GOTO... Statement:** ```BASIC @@ -1327,7 +1323,7 @@ When the result is true, the whole series of statements following the word `THEN **TYPE: Statement** **FORMAT: INPUT ["<prompt>"] <variable list>** -**Action:** This is a statement that lets the person `RUN`ning the program "feed" information into the computer. When executed, this statement `PRINT`s a question mark `(?)` on the screen, and positions the cursor 1 space to the right of the question mark. Now the computer waits, cursor blinking, for the operator to type in the answer and press the **RETURN** key. +**Action:** This is a statement that lets the person [`RUN`](#run)ning the program "feed" information into the computer. When executed, this statement [`PRINT`](#print)s a question mark `(?)` on the screen, and positions the cursor 1 space to the right of the question mark. Now the computer waits, cursor blinking, for the operator to type in the answer and press the **RETURN** key. The word `INPUT` may be followed by any text contained in quote marks `(" ")`. This text is `PRINT`ed on the screen, followed by the question mark. @@ -1339,7 +1335,7 @@ After the text comes a semicolon `(;)` and the name of one or more variables sep 20 INPUT E, X, I$ 30 INPUT "ENTER ANSWER"; A$(42) ``` -When this program `RUN`s, the quesiton mark appears to prompt the operator that the Commander X16 is expecting an input for line 30. Any number typed goes into A for later use in the program. If the anwser typed was not a number, the `?REDO FROM START` message appears, which means that a string was entered when a number was expected. If the operator just hits **RETURN** without typing anything, the variable's value doesn't change. +When this program `RUN`s, the question mark appears to prompt the operator that the Commander X16 is expecting an input for line 30. Any number typed goes into A for later use in the program. If the answer typed was not a number, the `?REDO FROM START` message appears, which means that a string was entered when a number was expected. If the operator just hits **RETURN** without typing anything, the variable's value doesn't change. Now the question mark for line 20, appears. If we type only one number and hit **RETURN**, the Commander X16 will now display 2 question marks `(??)`, which means that more input is required. You can just type as many inputs as you need, separated by commas, which prevents the double question mark from appearing. If you type more data than the `INPUT` statement requested, the `?EXTRA IGNORED` message appears, which means that the extra items you typed were not put into any variables. @@ -1352,9 +1348,9 @@ The `INPUT` statement can never be used outside a program. The Commander X16 ne **TYPE: I/O Statement** **FORMAT: INPUT# <file number>, <variable list>** -**Action:** This is usually the fastest and easiest way to retrieve data stored in a file on disk. The data is in the form of whole variables of up to 80 characters in length, as opposed to the one-at-a-time method of `GET#`. First, the file must have been `OPEN`ed, then `INPUT#` can fill the variables. +**Action:** This is usually the fastest and easiest way to retrieve data stored in a file on disk. The data is in the form of whole variables of up to 80 characters in length, as opposed to the one-at-a-time method of [`GET#`](#get-1). First, the file must have been [`OPEN`](#open)ed, then `INPUT#` can fill the variables. -The `INPUT#` command assumes a variable is finished when it reads a `RETURN` code (`CHR$`(13)), a comma `(,)`, or colon `(:)`. Quote marks `(")` can be used to enclose these characters when writing if they are needed (see the `PRINT#` statement). +The `INPUT#` command assumes a variable is finished when it reads a [`RETURN`](#return) code ([`CHR$`](#chr)(13)), a comma `(,)`, or colon `(:)`. Quote marks `(")` can be used to enclose these characters when writing if they are needed (see the [`PRINT#`](#print-1) statement). If the variable type used is numeric, and non-numeric characters are received, a `BAD DATA` error results. `INPUT#` can read strings up to 80 characters long, beyond which a `?STRING TOO LONG` error results. @@ -1389,7 +1385,7 @@ RUN `JOY(1)` through `JOY(4)` return the state of SNES controllers connected to the system, and `JOY(0)` returns the state of the "keyboard joystick", a set of keyboard keys that map to the SNES controller layout. See [`joystick_get`](X16%20Reference%20-%2005%20-%20KERNAL.md#function-name-joystick_get) for details. -If no controller is connected to the SNES port (or no keyboard is connected), the function returns -1. Otherwise, the result is a bit field, with pressed buttons `OR`ed together: +If no controller is connected to the SNES port (or no keyboard is connected), the function returns -1. Otherwise, the result is a bit field, with pressed buttons [`OR`](#or)ed together: | Value | Button | |--------|--------| @@ -1406,7 +1402,7 @@ If no controller is connected to the SNES port (or no keyboard is connected), th | $002 | LEFT | | $001 | RIGHT | -Note that this bitfield is different from the `joystick_get` KERNEL API one. Also note that the keyboard joystick will allow LEFT and RIGHT as well as UP and DOWN to be pressed at the same time, while controllers usually prevent this mechanically. +Note that this bitfield is different from the `joystick_get` KERNAL API one. Also note that the keyboard joystick will allow LEFT and RIGHT as well as UP and DOWN to be pressed at the same time, while controllers usually prevent this mechanically. **EXAMPLE of the JOY Function:** @@ -1444,7 +1440,7 @@ SAVE"AUTOBOOT.X16" :REM SAVE AS AUTOBOOT FILE **TYPE: String Function** **FORMAT: LEFT$(<string>, <integer>)** -**Action:** Returns a string comprised of the leftmost <integer> chracters of the <string>. The integer argument value must be in the range 0 to 255. If the integer is greater than the length of the string, the entire string will be returned. If an <integer> value of zero is used, then a null string (of zero length) is returned. +**Action:** Returns a string comprised of the leftmost <integer> characters of the <string>. The integer argument value must be in the range 0 to 255. If the integer is greater than the length of the string, the entire string will be returned. If an <integer> value of zero is used, then a null string (of zero length) is returned. **EXAMPLES of the LEFT$ Function:** ```BASIC @@ -1460,7 +1456,7 @@ COMMANDER **TYPE: Integer Function** **FORMAT: LEN(<string>)** -**Action:** Returns the number of chracters in the string expression. Non-printed characters and blanks are counted. +**Action:** Returns the number of characters in the string expression. Non-printed characters and blanks are counted. **EXAMPLE of the LEN Function:** ```BASIC @@ -1475,7 +1471,7 @@ RUN **TYPE: Statement** **FORMAT: [LET] <variable> = <expression>** -**Action:** The `LET` statement can be used to assign a value to a variable. However, the word `LET` is optional and therefore most advanced programmers leave `LET` out because it's aways understood and wastes valuable memory. The equal sign `(=)` alone is sufficient when assigning the value of an expression to a variable name. +**Action:** The `LET` statement can be used to assign a value to a variable. However, the word `LET` is optional and therefore most advanced programmers leave `LET` out because it's always understood and wastes valuable memory. The equal sign `(=)` alone is sufficient when assigning the value of an expression to a variable name. **EXAMPLES of the LET Statement:** ```BASIC @@ -1487,10 +1483,10 @@ RUN ### LINE -**TYPE: Command** +**TYPE: Statement** **FORMAT: LINE <x1>,<y1>,<x2>,<y2>,<color>** -**Action:** This command draws a line on the graphics screen in a given color. +**Action:** This statement draws a line on the graphics screen in a given color. **EXAMPLE of the LINE Statement:** @@ -1501,7 +1497,7 @@ RUN 40 NEXT ``` -**If you're pasting this example into the Commander X16 emulator, use this code block instead so that the π symbol is properly received.** +> **If you're pasting this example into the Commander X16 emulator, use this code block instead so that the π symbol is properly received.** ```BASIC 10 SCREEN128 @@ -1515,7 +1511,7 @@ RUN **TYPE: Command** **FORMAT: LINPUT <var$>** -**Action:** `LINPUT` Reads a line of data from the keyboard and stores the data into a string variable. Unlike `INPUT`, no parsing or cooking of the input is done, and therefore quotes, commas, and colons are stored in the string as typed. No prompt is displayed, either. +**Action:** `LINPUT` Reads a line of data from the keyboard and stores the data into a string variable. Unlike [`INPUT`](#input), no parsing or cooking of the input is done, and therefore quotes, commas, and colons are stored in the string as typed. No prompt is displayed, either. The input is taken from the KERNAL editor, hence the user will have the freedom of all of the features of the editor such as cursor movement, mode switching, and color changing. @@ -1536,7 +1532,7 @@ Due to how the editor works, an empty line will return `" "`– a string wit **TYPE: Command** **FORMAT: LINPUT# <n>,<var$>\[,<delimiter>\]** -**Action:** `LINPUT#` Reads a line of data from an open file and stores the data into a string variable. The delimiter of a line by default is 13 (carriage return). The delimiter is not part of the stored value. If the end of the file is reached while reading, `ST AND 64` will be true. +**Action:** `LINPUT#` Reads a line of data from an open file and stores the data into a string variable. The delimiter of a line by default is 13 (carriage return). The delimiter is not part of the stored value. If the end of the file is reached while reading, [`ST`](#st)` AND 64` will be true. `LINPUT#` can be used to read structured data from files. It can be particularly useful to extract quoted or null-terminated strings from files while reading. @@ -1593,11 +1589,11 @@ approximately one screen full of text. **TYPE: Command** **FORMAT: LOAD ["<filename>"][,<device>][,<address>] LOAD ["<filename>"][,<device>][,<ram bank>, <start address>] ** -**Action:** The `LOAD` statement reads the contents of a program file from disk into memory. That way you can use the information `LOAD`ed or change the information in some way. The device number is optional, but when it is left out, the Commander X16 will automatically default to 8, the first disk device. The `LOAD` command closes all open files and if it is used in direct mode, it performs a `CLR` (clear) before reading the program. If `LOAD` is executed from within a program, the program is `RUN`. this means that you can use `LOAD` to "chain" several programs together. None of the variables are cleared during a chain operation. +**Action:** The `LOAD` statement reads the contents of a program file from disk into memory. That way you can use the information `LOAD`ed or change the information in some way. The device number is optional, but when it is left out, the Commander X16 will automatically default to 8, the first disk device. The `LOAD` command closes all open files and if it is used in direct mode, it performs a [`CLR`](#clr) (clear) before reading the program. If `LOAD` is executed from within a program, the program is `RUN`. this means that you can use `LOAD` to "chain" several programs together. None of the variables are cleared during a chain operation. If you are using file name pattern matching, the first file which matches the pattern is loaded. The asterisk in quotes by itself `("*")` causes the first file name in the disk directory to be loaded. If the file name used does not or if it is not a program, the BASIC error message `?FILE NOT FOUND` occurs. -Programs will `LOAD` starting at memory location $0801 (hex) unless a secondary <address> of 1 is used. If you use the secondary address of 1 this will cause the program to `LOAD` to the memory loction from which it was saved. +Programs will `LOAD` starting at memory location $0801 (hex) unless a secondary <address> of 1 is used. If you use the secondary address of 1 this will cause the program to `LOAD` to the memory location from which it was saved. If using the second form of the `LOAD` command, <ram bank> sets the back for the load, and <start address> is the location where your data will be `LOAD`ed into. @@ -1611,7 +1607,7 @@ The value of the <ram bank> argument only affects the `LOAD` when the < ### LOCATE -**TYPE: Command** +**TYPE: Statement** **FORMAT: LOCATE <line>[,<column>]** **Action:** This command positions the text mode cursor at the given location. @@ -1673,7 +1669,7 @@ GOOD EVENING **Action:** This command currently invokes the Commander X16 Control Panel. In the future, the menu may instead present a menu of ROM-based applications and routines. -**EXAMPLE of the MENU Statement:** +**EXAMPLE of the MENU Command:** ```BASIC MENU @@ -1710,7 +1706,7 @@ PRINT MOD(65000, 101) :REM DIVIDEND IS TOO LARGE FOR A SIGNED 16BIT VALUE **Action:** This command enters the machine language monitor. See the [Chapter 7: Machine Language Monitor](X16%20Reference%20-%2007%20-%20Machine%20Language%20Monitor.md#chapter-7-machine-language-monitor) for a description. -**EXAMPLE of the MON Statement:** +**EXAMPLE of the MON Command:** ```BASIC MON @@ -1745,12 +1741,12 @@ MOUSE 0 : REM DISABLE MOUSE ### MOVSPR -**TYPE: Command** +**TYPE: Statement** **FORMAT: MOVSPR <sprite idx>,<x>,<y>** **Action:** This command positions a sprite's upper left corner at a specific pixel location. It does not change its visibility. -`sprite idx` is a value between 0-127 inclusive. +<sprite idx> is a value between 0-127 inclusive. `x` and `y` have a range of -32768 to 32767 inclusive, but their meanings wrap every 1024 values. Values approaching 1023 will peek out from the left and top of the screen for x and y respectively as if they were negative and approaching 0. -1024, 1024, 0, and 2048 are all equivalent. Likewise, -10 and 1014 are equivalent. **EXAMPLE of the MOVSPR Statement:** @@ -1823,7 +1819,7 @@ NEW : REM Clears the program and all variables) **TYPE: Statement** **FORMAT: NEXT [<counter>],[<counter>]...** -**Action:** The `NEXT` statement is used with `FOR` to establish the end of a `FOR`...`NEXT` loop. The `NEXT` need not be physically the last statement in the loop, but it is always the last statement executed in a loop. The <counter> is the loop index's variable name used with `FOR` to start the loop. A single `NEXT` can stop several nested loops when it is followed by each `FOR`'s <counter> variable name(s). to do this each name must appear in the order of inner-most nested loop first, to outer-most nested loop last. When using a single `NEXT` to increment and stop several variable names, each variable name must be separated by commas. Loops can be nested to 9 levels. If the counter variable(s) are omitted, the counter associated with the `FOR` of the current level (of the nested loops) is incremented. +**Action:** The `NEXT` statement is used with [`FOR`](#for-to-step) to establish the end of a `FOR`...`NEXT` loop. The `NEXT` need not be physically the last statement in the loop, but it is always the last statement executed in a loop. The <counter> is the loop index's variable name used with `FOR` to start the loop. A single `NEXT` can stop several nested loops when it is followed by each `FOR`'s <counter> variable name(s). to do this each name must appear in the order of inner-most nested loop first, to outer-most nested loop last. When using a single `NEXT` to increment and stop several variable names, each variable name must be separated by commas. Loops can be nested to 9 levels. If the counter variable(s) are omitted, the counter associated with the `FOR` of the current level (of the nested loops) is incremented. When the `NEXT` is reached, the counter value is incremented by 1 or by an optional `STEP` value. It is then tested against an end-value to see if it's time to stop the loop. A loop will be stopped when a `NEXT` is found which has its counter value greater than the end-value. @@ -1865,11 +1861,11 @@ IA% = NOT 42 : PRINT IA% **TYPE: Statement** **FORMAT: ON <variable> GOTO / GOSUB <line number> [,<line number>]...** -**Action:** The `ON` statement is used to `GOTO` or `GOSUB` to one of several given line numbers, depending on the value of a variable. The value of the variables can range from zero through the number of lines given. If the value is a non-integer, the fractional portion is left off. for example, if the variable value is 3, `ON` will `GOTO` (or `GOSUB`) the third line number in the list. +**Action:** The `ON` statement is used to [`GOTO`](#goto) or [`GOSUB`](#gosub) to one of several given line numbers, depending on the value of a variable. The value of the variables can range from zero through the number of lines given. If the value is a non-integer, the fractional portion is left off. for example, if the variable value is 3, `ON` will `GOTO` (or `GOSUB`) the third line number in the list. If the value of the variable is negative, the BASIC error message `?ILLEGAL QUANTITY` occurs. If the number is zero, or greater than the number of items in the list, the program just ignores the statement and continues with the statement following the `ON` statement. -`ON` is really an underused variant of the `IF...THEN...` statement. Instead of using a qhole lot of `IF` statements each of which sends the program to one specific line, one `ON` statement can replace a list of `IF` statements. When you look at the first example you should notice that the one `ON` statement replaces four `IF...THEN...` statements. +`ON` is really an underused variant of the [`IF...THEN...`](#if-then) statement. Instead of using a whole lot of `IF` statements each of which sends the program to one specific line, one `ON` statement can replace a list of `IF` statements. When you look at the first example you should notice that the one `ON` statement replaces four `IF...THEN...` statements. **EXAMPLES of the ON Statement:** ```BASIC @@ -1889,7 +1885,7 @@ ON Z+7 GOSUB 4800, 230, 4800 **TYPE: Command** **FORMAT: OLD** -**Action:** This command recovers the BASIC program in RAM that has been previously deleted using the `NEW` command or through a RESET. +**Action:** This command recovers the BASIC program in RAM that has been previously deleted using the [`NEW`](#new) command or through a [`RESET`](#reset). **EXAMPLE of the OLD Statement:** @@ -1902,12 +1898,12 @@ OLD **TYPE: I/O Statement** **FORMAT: OPEN <file number>, <device> [, <address>] [, "<file name> [,<type>][, <mode>]"]** -**Action** This statement `OPEN`s a channel for input and/or output to a peripheral device. however, you may NOt need all those ports for every `OPEN` statement. Some `OPEN` statements require only two codes: +**Action** This statement `OPEN`s a channel for input and/or output to a peripheral device. however, you may NOT need all those ports for every `OPEN` statement. Some `OPEN` statements require only two codes: - LOGICAL FILE NUMBER - DEVICE NUMBER -The <file number> is the logical file number, which relates to the `OPEN`, `CLOSE`, `CMD`, `GET#`, `INPUT#`, and `PRINT#` statements to each other and associates them with the file name and the piece of equipment being used. The logical file number can range from 1 to 255 and you can assign it any number you want in that range. +The <file number> is the logical file number, which relates to the `OPEN`, [`CLOSE`](#close), [`CMD`](#cmd), [`GET#`](#get-1), [`INPUT#`](#input-1), and [`PRINT#`](#print-1) statements to each other and associates them with the file name and the piece of equipment being used. The logical file number can range from 1 to 255 and you can assign it any number you want in that range. > **NOTE:** File numbers over 128 were really designed for other uses, so it's good practice to use only numbers below 127 for file numbers. @@ -1915,7 +1911,7 @@ Each peripheral device (printer, disk drive, etc) in the system has its own numb If the <device> number is left out the Commander X16 will automatically assume that you want to talk to device #1, which has traditionally been assigned to the tape device. Since the Commander X16 has no support for the tape device, I/O statements that reference it may operate with no error, but no actual work will be done. Because of this, it should be assumed that specifying the device address is NOT optional. -For disk files, the secondary addresses 2 through 14 are available for data files, but other numbers have special meanings for DOS commands. You must use a secondary address when using your disk drive(s)3. +For disk files, the secondary addresses 2 through 14 are available for data files, but other numbers have special meanings for DOS commands. You must use a secondary address when using your disk drive(s). The <file name> is a string of 1 to 16 characters and is optional for printer files. If the file <type> is left out, the type of file will automatically default to the Program (PRG) file type unless the <mode> is given. Sequential (SEQ) files are `OPEN`ed for reading (<mode>=R) unless you specify that files should be `OPEN`ed for writing (<mode>=W) A file <type> can be used to `OPEN` an existing Relative file. Use **REL** for <type> with Relative files. Relative and Sequential files are for disk only. @@ -1931,8 +1927,7 @@ If you try to access a file before it is `OPEN`ed the BASIC error message `?FILE - OPEN 1, 8, 15, "COMMAND" (send a command to a disk device) -


-> 3: Reminder to add a discussion about manipulating disk files. +> **NOTE:** More information on working with disk files can be found in [Chapter 13](X16%20Reference%20-%2013%20-%20Working%20with%20CMDR-DOS.md#chapter-13-working-with-cmdr-dos). ### OR @@ -1956,7 +1951,7 @@ RUN ### OVAL -**TYPE: Command** +**TYPE: Statement** **FORMAT: OVAL <x1>,<y1>,<x2>,<y2>,<color>** **Action:** This command draws a filled oval on the graphics screen in a given color. @@ -1979,7 +1974,7 @@ The coordinate arguments define the rectangular bounding box of the oval. To dra **Action:** Returns the value at given memory address `PEEK`ing values within the BRAM (`$A000`) and KERNAL/Cartridge (`$C000`) -requires using `BANK` to set the banks accordingly. +requires using [`BANK`](#bank) to set the banks accordingly. **EXAMPLE of the PEEK function:** @@ -1995,7 +1990,7 @@ requires using `BANK` to set the banks accordingly. **Action:** Returns the memory address of the internal structure representing a BASIC variable. -**EXAMPLE of the POINTER function:** +**EXAMPLE of the POINTER Function:** ```BASIC 10 A$="MOO" @@ -2017,10 +2012,10 @@ called beforehand with the appropriate arguments. Writing to values within the KERNAL/Cartridge area (`$C000`) will not work as expected and may silently fail in KERNAL ROM versions older than R49. In R49, POKE works as expected assuming the -area being written to is RAM and that [`BANK`](#bank) has been +area being written to is RAM and that `BANK` has been called with appropriate arguments. -**EXAMPLE of the POKE function:** +**EXAMPLE of the POKE Statement:** ```BASIC 10 POKE $A000,47 @@ -2056,7 +2051,7 @@ POWEROFF **TYPE: Statement** **FORMAT: PRINT [<variable>][<,/;><variable>]...** -**Action:** The `PRINT` statement is normally used to write data items to the screen. However, the `CMD` statement may be used to redirect that output to any other device in the system. The <variable(s)> in the output-list are expressions of any type. If no output-list is present, a blank line is printed. The position of each printed item is determined by the punctuation used to separate items in the output-list. +**Action:** The `PRINT` statement is normally used to write data items to the screen. However, the [`CMD`](#cmd) statement may be used to redirect that output to any other device in the system. The <variable(s)> in the output-list are expressions of any type. If no output-list is present, a blank line is printed. The position of each printed item is determined by the punctuation used to separate items in the output-list. The punctuation characters that you can use are blanks, commas, or semicolons. the 80 character logical screen line is divided into 8 print zones of 10 spaces each. In the list of expressions, a comma causes the next value to be printed at the beginning of the next zone. A semicolon causes the next value to be printed immediately following the previous value. However, there are two exceptions to this rule: @@ -2113,11 +2108,11 @@ PRINT "**CLR/HOME** H **↑CRSR↓** E **& Which would appear as: -PRINT "![](images/rvs-S.png) H ![](images/rvs-Q.png) E ![](images/rvs-Q.png) L ![](images/rvs-Q.png) L ![](images/rvs-Q.png) O" +![Cursor Pos. Example](images/print-screen-pos-example.png) **2. Reverse Characters** -Holding down the **CTRL** key and hitting **9** will cause **R** to appear inside the quotes. This will make all characters print starting in *reverse video* (like a negative of a picture). To end the reverse printing hit **CTRL** **0**, which prints a ![](images/norm-lower-bar.png) or else `PRINT` a **RETURN** (`CHR$`(13)). (Just ending the `PRINT` statement without a semicolon or a comma will take care of this.) +Holding down the **CTRL** key and hitting **9** will cause **R** to appear inside the quotes. This will make all characters print starting in *reverse video* (like a negative of a picture). To end the reverse printing hit **CTRL** **0**, which prints a ![](images/norm-lower-bar.png) or else `PRINT` a **RETURN** ([`CHR$`](#chr)(13)). (Just ending the `PRINT` statement without a semicolon or a comma will take care of this.) **3. Color Controls** @@ -2148,7 +2143,7 @@ PRINT "**CTRL** **4**HELLO**CTRL** Which would appear as: -PRINT "![](images/rvs-l-ramp.png) HELLO ![](images/rvs-E.png) THERE" +![Print Color Example](images/print-color-example.png) **4. Insert Mode** @@ -2163,15 +2158,15 @@ which displays as: 10 PRINT "HELLO**T****T**P" -When the above line is `RUN`, the word displayed will be HELP, because the last two letters are deleted and the P is put in their place. +When the above line is [`RUN`](#run), the word displayed will be HELP, because the last two letters are deleted and the P is put in their place. -> **WARNING:** The **DEL**etes will work when `LIST`ing as well as `PRINT`ing, so editing a line with these characters will be difficult. +> **WARNING:** The **DEL**etes will work when [`LIST`](#list)ing as well as `PRINT`ing, so editing a line with these characters will be difficult. The "insert mode" condition is ended when the **RETURN** (or **SHIFT** **RETURN**) key is hit, or when as many characters have been typed as spaces were inserted. **5. Other Special Characters** -There are some other chracters that can be `PRINT`ed for special function, although they are not easily available from the keyboard. In order to get these in quotes, you must leave empty spaces for them in the line, hit **RETURN** or **SHIFT** **RETURN**, and go back to the spaces with the cursor controls. Now you must hit **CTRL** **RVS/ON**, to start typing reversed chracters, and type the keys shown below: +There are some other characters that can be `PRINT`ed for special function, although they are not easily available from the keyboard. In order to get these in quotes, you must leave empty spaces for them in the line, hit **RETURN** or **SHIFT** **RETURN**, and go back to the spaces with the cursor controls. Now you must hit **CTRL** **RVS/ON**, to start typing reversed characters, and type the keys shown below: | Function | Type | Appears As | |:--------:|:---------|:-----------| @@ -2188,11 +2183,11 @@ The **SHIFT** **RETURN** will work in the `LIST`ing as **TYPE: I/O Statement** **FORMAT: PRINT# <file number> [<variable>][<,/;><variable>]...** -**Action:** The `PRINT#` statement is used to write data items to a logical file. It must use the same number used to `OPEN` the file. Output goes to the device number used in the `OPEN` statement. The <variable> expressions in the output-list can be of any type. The punctuation characters between items are the same as with the `PRINT` statement and they can be used in the same ways. The effects of punctuation are different in one significant respects. +**Action:** The `PRINT#` statement is used to write data items to a logical file. It must use the same number used to `OPEN` the file. Output goes to the device number used in the [`OPEN`](#open) statement. The <variable> expressions in the output-list can be of any type. The punctuation characters between items are the same as with the `PRINT` statement and they can be used in the same ways. The effects of punctuation are different in one significant respects. -If no punctuation finishes the list, a carriage-return and a line-feed are written at the end of the data. If a comma or semicolon terminates the output-list, the carriage-return and line-feed are suppressed. Regardless of the punctuation, the next `PRINT#` statement beings output in the next available character position. The line-feed will act as a stop when using the `INPUT#` statement, leaving an empty variable when the next `INPUT#` is executed. The line-feed can be suppressed or compensated for as shown in the examples below. +If no punctuation finishes the list, a carriage-return and a line-feed are written at the end of the data. If a comma or semicolon terminates the output-list, the carriage-return and line-feed are suppressed. Regardless of the punctuation, the next `PRINT#` statement beings output in the next available character position. The line-feed will act as a stop when using the [`INPUT#`](#input-1) statement, leaving an empty variable when the next `INPUT#` is executed. The line-feed can be suppressed or compensated for as shown in the examples below. -The easiest way to write more than one variable to a file is to set a string variable to `CHR$`(13), and use that string in between all the other variables when writing the file. +The easiest way to write more than one variable to a file is to set a string variable to [`CHR$`](#chr)(13), and use that string in between all the other variables when writing the file. **EXAMPLES of the PRINT# Statement:** ```BASIC @@ -2216,7 +2211,7 @@ The easiest way to write more than one variable to a file is to set a string var ### PSET -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSET <x>,<y>,<color>** **Action:** This command sets a pixel on the graphics screen to a given color. @@ -2231,16 +2226,16 @@ The easiest way to write more than one variable to a file is to set a string var ### PSGCHORD -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGCHORD <first voice>,<string>** -**Action:** This command uses the same syntax as `PSGPLAY`, but instead of playing a series of notes, it will start all of the notes in the string simultaneously on one or more voices. The first parameter to `PSGCHORD` is the first voice to use, and will be used for the first note in the string, and subsequent notes in the string will be started on subsequent voices, with the voice after 15 being voice 0. +**Action:** This command uses the same syntax as [`PSGPLAY`](#psgplay), but instead of playing a series of notes, it will start all of the notes in the string simultaneously on one or more voices. The first parameter to `PSGCHORD` is the first voice to use, and will be used for the first note in the string, and subsequent notes in the string will be started on subsequent voices, with the voice after 15 being voice 0. -All macros are supported, even the ones that only affect `PSGPLAY` and `FMPLAY`. +All macros are supported, even the ones that only affect `PSGPLAY` and [`FMPLAY`](#fmplay). The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of the PSGCHORD statement:** +**EXAMPLE of the PSGCHORD Statement:** ```BASIC 10 PSGINIT @@ -2255,12 +2250,12 @@ The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%2 ### PSGFREQ -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGFREQ <voice>,<frequency>** **Action:** Play a note by frequency on the VERA PSG. The accepted range is in Hz from 1 to 24319. PSGFREQ also accepts a frequency of 0 to release the note. -**EXAMPLE of the PSGFREQ statement:** +**EXAMPLE of the PSGFREQ Statement:** ```BASIC 10 PSGINIT : REM RESET ALL VOICES TO SQUARE WAVEFORM @@ -2274,14 +2269,14 @@ The above BASIC program plays a sound similar to a North American dial tone for ### PSGINIT -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGINIT** **Action:** Initialize VERA PSG, silence all voices, set volume to 63 on all voices, and set the waveform to pulse and the duty cycle to 63 (50%) for all 16 voices. ### PSGNOTE -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGNOTE <voice>,<note>** **Action:** Play a note on the VERA PSG. The note value is constructed as follows. Using hexadecimal notation, the first nybble is the octave, 0-7, and the second nybble is the note within the octave as follows: @@ -2290,7 +2285,7 @@ The above BASIC program plays a sound similar to a North American dial tone for |-|-|-|-|-|-|-|-|-|-|-|-|-|-| | Release | C | C♯/D♭ | D | D♯/E♭ | E | F | F♯/G♭ | G | G♯/A♭ | A | A♯/B♭ | B | no-op | -**EXAMPLE of the PSGNOTE statement:** +**EXAMPLE of the PSGNOTE Statement:** ```BASIC 10 PSGNOTE 1,$4A : REM PLAYS CONCERT A @@ -2304,7 +2299,7 @@ The above BASIC program plays a sound similar to a North American dial tone for ### PSGPAN -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGPAN <voice>,<panning>** **Action:** Sets the simple stereo panning on a VERA PSG voice. Valid values are as follows: @@ -2315,17 +2310,17 @@ The above BASIC program plays a sound similar to a North American dial tone for ### PSGPLAY -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGPLAY <voice>,<string>** **Action:** This command is very similar to `PLAY` on other BASICs such as GWBASIC. It takes a string of notes, rests, tempo changes, note lengths, and other macros, and plays all of the notes synchronously. That is, the PSGPLAY command will not return control until all of the notes and rests in the string have been fully played. The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%20-%20Sound.md#basic-fmplay-and-psgplay-string-macros). -**EXAMPLE of the PSGPLAY statement:** +**EXAMPLE of the PSGPLAY Statement:** ```BASIC -10 PSGWAV 0,31 : REM PULSE, 25% DUTY +10 PSGWAV 0,31 : REM PULSE, 25% DUTY CYCLE 20 PSGPLAY 0,"T180 S0 O5 L32" : REM TEMPO 180 BPM, LEGATO, OCTAVE 5, 32ND NOTES 30 PSGPLAY 0,"CCEG>CCE-A-E-A->CE-A-" @@ -2334,19 +2329,19 @@ The full set of macros is documented [here](X16%20Reference%20-%20Appendix%20A%2 ### PSGVOL -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGVOL <voice>,<volume>** -**Action:** This command sets the voice's volume. The volume remains at the requested level until another `PSGVOL` command for that voice or `PSGINIT` is called. Valid range is from 0 (completely silent) to 63 (full volume). +**Action:** This statement sets the voice's volume. The volume remains at the requested level until another `PSGVOL` command for that voice or [`PSGINIT`](#psginit) is called. Valid range is from 0 (completely silent) to 63 (full volume). ### PSGWAV -**TYPE: Command** +**TYPE: Statement** **FORMAT: PSGWAV <voice>,<w>** **Action:** Sets the waveform and duty cycle for a PSG voice. -* w = 0-63 -> Pulse: Duty cycle is `(w+1)/128`. A value of 63 means 50% duty. +* w = 0-63 -> Pulse: Duty cycle is `(w+1)/128`. A value of 63 means 50% duty cycle. * w = 64-127 -> Sawtooth (all values have identical effect) * w = 128-191 -> Triangle (all values have identical effect) * w = 192-255 -> Noise (all values have identical effect) @@ -2378,11 +2373,11 @@ This example plays a chromatic scale while applying pulse-width modulation on th **TYPE: Statement** **FORMAT: READ <> [,<variable>]...*** -**Action:** The `READ` statement is used to fill variable names from constants in `DATA` statements. The data actually read must agree with the variable types specified or the BASIC error message `?SYNTAX ERROR` will result. Variables in the `DATA` input-list must be spearated by commas. +**Action:** The `READ` statement is used to fill variable names from constants in [`DATA`](#data) statements. The data actually read must agree with the variable types specified or the BASIC error message `?SYNTAX ERROR` will result. Variables in the `DATA` input-list must be separated by commas. A single `READ` statement can access on or more `DATA` statements, which will be accessed in order (see [DATA](#data)), or several `READ` statements can access the same `DATA` statement. If more `READ` statements are executed than the number of elements in `DATA` statement(s), in the program, the BASIC error message `?OUT OF DATA` is printed. If the number of variables specified is fewer than the number of elements in the `DATA` statement(s), subsequent `READ` statements will continue reading at the next data element. (See [RESTORE](#restore).) -> **NOTE:** The `?SYNTAX ERROR` will appear with the line number from the `DATA` statement, NOt the `READ` statement. +> **NOTE:** The `?SYNTAX ERROR` will appear with the line number from the `DATA` statement, NOT the `READ` statement. **EXAMPLES of the READ Statement:** ```BASIC @@ -2404,7 +2399,7 @@ A single `READ` statement can access on or more `DATA` statements, which will be **TYPE: Statement** **FORMAT: REM [<remark>]** -**Action:** The `REM` statement makes your programs more easily understood when `LIST`ed. It's a reminder to yourself to tell you what you had in mind when you were writing each section of the program. For instance, you might want to remember what a variable is used for, or some other useful information. The `REM`ark can be any text, word, or character including the colon `(:)` or BASIC keywords. The `REM` statement and anything following it on the same line number are ignored by BASIC, but `REM`arks are printed exactly as entered when the program is listed. A `REM` statement can be referred to by a `GOTO` or `GOSUB` statement, and the execution of the program will continue with the next highter program line having executable statements. +**Action:** The `REM` statement makes your programs more easily understood when [`LIST`](#list)ed. It's a reminder to yourself to tell you what you had in mind when you were writing each section of the program. For instance, you might want to remember what a variable is used for, or some other useful information. The `REM`ark can be any text, word, or character including the colon `(:)` or BASIC keywords. The `REM` statement and anything following it on the same line number are ignored by BASIC, but `REM`arks are printed exactly as entered when the program is listed. A `REM` statement can be referred to by a [`GOTO`](#goto) or [`GOSUB`](#gosub) statement, and the execution of the program will continue with the next higher program line having executable statements. **EXAMPLES of the REM Statement:** ```BASIC @@ -2416,10 +2411,10 @@ A single `READ` statement can access on or more `DATA` statements, which will be ### RING -**TYPE: Command** +**TYPE: Statement** **FORMAT: RING <x1>,<y1>,<x2>,<y2>,<color>** -**Action:** This command draws an oval outline on the graphics screen in a given color. +**Action:** This statement draws an oval outline on the graphics screen in a given color. The coordinate arguments define the rectangular bounding box of the oval. To draw a circle outline, make the width and height equal to each other. @@ -2433,10 +2428,10 @@ The coordinate arguments define the rectangular bounding box of the oval. To dra ### RECT -**TYPE: Command** +**TYPE: Statement** **FORMAT: RECT <x1>,<y1>,<x2>,<y2>,<color>** -**Action:** This command draws a solid rectangle on the graphics screen in a given color. +**Action:** This statement draws a solid rectangle on the graphics screen in a given color. **EXAMPLE of the RECT Statement:** @@ -2464,7 +2459,7 @@ REBOOT **TYPE: Command** **FORMAT: REN [<new line num>[, <increment>[, <first old line num>]]]** -**Action:** Renumbers a BASIC program while updating the line number arguments of GOSUB, GOTO, RESTORE, RUN, and THEN. +**Action:** Renumbers a BASIC program while updating the line number arguments of [`GOSUB`](#gosub), [`GOTO`](#goto), [`RESTORE`](#restore), [`RUN`](#run), and [`THEN`](#if-then). Optional arguments: @@ -2474,16 +2469,16 @@ Optional arguments: **Please ensure your have saved your program before using this command to renumber.** -**KNOWN BUG**: -In release R43, due to improper parsing of escape tokens, REN will improperly treat arguments to these statements as line numbers: - -* `FRAME` -* `RECT` -* `MOUSE` -* `COLOR` -* `PSGWAV` +> **KNOWN BUG:** In release R43, due to improper parsing of escape tokens, REN will improperly treat arguments to these statements as line numbers: +> +> * [`FRAME`](#frame) +> * [`RECT`](#rect) +> * [`MOUSE`](#mouse) +> * [`COLOR`](#color) +> * [`PSGWAV`](#psgwav) +> +> This behavior has been fixed in R44. -This behavior has been fixed in R44. **EXAMPLE of the REN Statement:** @@ -2528,10 +2523,10 @@ RESET ### RESTORE -**TYPE: Command** -**FORMAT: RESTORE \[<linenum>\]** +**TYPE: Statement** +**FORMAT: RESTORE [<linenum>]** -**Action:** This command resets the pointer for the `READ` command. Without arguments, it will reset the pointer to the first `DATA` constant in the program. With a parameter `linenum`, the command will reset the pointer to the first `DATA` constant at or after that line number. +**Action:** This statement resets the pointer for the [`READ`](#read) command. Without arguments, it will reset the pointer to the first [`DATA`](#data) constant in the program. With >linenum> parameter, the statement will reset the pointer to the first `DATA` constant at or after that line number. **EXAMPLE of the RESTORE Statement:** @@ -2552,7 +2547,7 @@ This program will output the number 1 followed by the number 4. **TYPE: Statement** **FORMAT: RETURN** -**Action:** The `RETURN` statement is used to exit from a subroutine called for by a `GOSUB` statement. `RETURN` restarts the rest of your program at the next executable statement following the `GOSUB`. If you are nesting subroutines, each `GOSUB` must be paired with at least one `RETURN` statement. A subroutine can contain any number of `RETURN` statements, but the first one encountered will exit the subroutine. +**Action:** The `RETURN` statement is used to exit from a subroutine called for by a [`GOSUB`](#gosub) statement. `RETURN` restarts the rest of your program at the next executable statement following the `GOSUB`. If you are nesting subroutines, each `GOSUB` must be paired with at least one `RETURN` statement. A subroutine can contain any number of `RETURN` statements, but the first one encountered will exit the subroutine. **EXAMPLE of the RETURN Statement:** ```BASIC @@ -2609,11 +2604,11 @@ If you choose a <numeric> argument of zero, then `RND` generates a number **TYPE: Function** **FORMAT: RPT$(<byte>,<count>)** -**Action:** Returns a string of <count> instances of the PETSCII character represented by the numeric value <byte>. This function is similar in behavior to `CHR$()` but takes a second argument as a repeat count. +**Action:** Returns a string of <count> instances of the PETSCII character represented by the numeric value <byte>. This function is similar in behavior to [`CHR$`](#chr) but takes a second argument as a repeat count. `RPT$(A,1)` is functionally equivalent to `CHR$(A)`. -**EXAMPLE of the RPT$ function:** +**EXAMPLE of the RPT$ Function:** ```BASIC 10 REM TEN EXCLAMATION MARKS @@ -2630,11 +2625,11 @@ READY. **TYPE: Command** **FORMAT: RUN [<line number>]** -**Action:** The system command `RUN` is used to start the program currently in memory. The `RUN` command acauses an implied `CLR` operation to be performed before starting the program. You can void the `CLR` operation by using `CONT` or `GOTO` to restart a program instead of `RUN`. If a <line number> is specified, your program will start on that line. Otherwise, the `RUN` command starts at the first line of the program. +**Action:** The system command `RUN` is used to start the program currently in memory. The `RUN` command causes an implied [`CLR`](#clr) operation to be performed before starting the program. You can void the `CLR` operation by using [`CONT`](#cont) or [`GOTO`](#goto) to restart a program instead of `RUN`. If a <line number> is specified, your program will start on that line. Otherwise, the `RUN` command starts at the first line of the program. The `RUN` command can also be used within a program. if the <line number> you specify doesn't exist, the BASIC error message `?UNDEF'D STATEMENT` occurs. -A `RUN`ning program stops and BASIC returns to direct mode when an `END` or `STOP` statement is reached, when the last line of the program is finished, or when a BASIC error occurs during execution. +A `RUN`ning program stops and BASIC returns to direct mode when an [`END`](#end) or [`STOP`](#stop) statement is reached, when the last line of the program is finished, or when a BASIC error occurs during execution. **EXAMPLES of the RUN Command:** - RUN - Starts at the first line of a program. @@ -2648,11 +2643,11 @@ A `RUN`ning program stops and BASIC returns to direct mode when an `END` or `STO **Action:** Saves a BASIC program to a file. -This saves the currently loaded BASIC program to a file. If the device number is not supplied, SAVE will use the default drive. This is usually the SD card. +This saves the currently loaded BASIC program to a file. If the device number is not supplied, `SAVE` will use the default drive. This is usually the SD card. -Note that SAVE will not overwrite an existing file by default. To do this, you must prefix the filename with @:, like this: `SAVE "@:filename"` +Note that `SAVE` will not overwrite an existing file by default. To do this, you must prefix the filename with @:, like this: `SAVE "@:filename"` -**EXAMPLES of SAVE:** +**EXAMPLES of the SAVE Command:** ```BASIC SAVE "HELLO.PRG" @@ -2668,12 +2663,31 @@ The above example overwrites an existing file on drive 9, which would be a Commo ### SCREEN -**TYPE: Command** +**TYPE: Statement** **FORMAT: SCREEN <mode>** -**Action:** This command switches screen modes. - -For a list of supported modes, see [Chapter 3: Editor](X16%20Reference%20-%2003%20-%20Editor.md#chapter-3-editor). The value of -1 toggles between modes $00 and $03. +**Action:** This statement switches screen modes. + +**Suported Modes** +| Mode | Description | +|------|-------------| +| $00 | 80x60 text | +| $01 | 80x30 text | +| $02 | 40x60 text | +| $03 | 40x30 text | +| $04 | 40x15 text | +| $05 | 20x30 text | +| $06 | 20x15 text | +| $07 | 22x23 text | +| $08 | 64x50 text | +| $09 | 64x25 text | +| $0A | 32x50 text | +| $0B | 32x25 text | +| $80 | 320x240@256c 40x30 text | + +Please refer to [Chapter 3: Editor](X16%20Reference%20-%2003%20-%20Editor.md#chapter-3-editor) for more information on text modes. + +The value of -1 toggles between modes $00 and $03. **EXAMPLE of the SCREEN Statement:** @@ -2702,7 +2716,7 @@ SCREEN -1 : REM SWITCH BETWEEN 40 and 80 CHARACTER MODE **TYPE: Floating-Point Function** **FORMAT: SIN(<numeric>)** -**Action:** `SIN` gives you the sine of the <numeric> argument, in radians. The value of `COS`(x) is equal to `SIN`(x + 3.1415925 / 2). +**Action:** `SIN` gives you the sine of the <numeric> argument, in radians. The value of [`COS`](#cos)(x) is equal to `SIN`(x + 3.1415925 / 2). **EXAMPLE of the SIN Function:** ```BASIC @@ -2712,7 +2726,7 @@ The result is .997494987. ### SLEEP -**TYPE: Command** +**TYPE: Statement** **FORMAT: SLEEP \[<jiffies>\]** **Action:** With the default interrupt source configured and enabled, this command waits for `jiffies`+1 VSYNC events and then resumes program execution. In other words, `SLEEP` with no arguments is equivalent to `SLEEP 0`, which waits until the beginning of the next frame. Another useful example, `SLEEP 60`, pauses for approximately 1 second. @@ -2745,19 +2759,19 @@ FIRST SECOND THIRD FOURTH ### SPRITE -**TYPE: Command** +**TYPE: Statement** **FORMAT: SPRITE <sprite idx>,<priority>\[,<palette offset>\[,<flip>\[,<x-width>\[,<y-width>\[,<color depth>\]\]\]\]\]** -**Action:** This command configures a sprite's geometry, palette, and visibility. +**Action:** This statement configures a sprite's geometry, palette, and visibility. The first two arguments are required, but the remainder are optional. -* `sprite idx` is a value between 0-127 inclusive. -* `priority`, also known as z-depth changes the visibility of the sprite and above which layer it is rendered. Range is 0-3 inclusive. 0 = off, 1 = below layer 0, 2 = in between layers 0 and 1, 3 = above layer 1 -* `palette offset` is the palette offset for the sprite. Range is 0-15 inclusive. This value is multiplied by 16 to determine the starting palette index. -* `flip` controls the X and Y flipping of the sprite. Range is 0-3 inclusive. 0 = unflipped, 1 = X is flipped, 2 = Y is flipped, 3 = both X and Y are flipped. -* `x-width` and `y-width` represent the dimensions of the sprite. Range is 0-3 inclusive. 0 = 8px, 1 = 16px, 2 = 32px, 3 = 64px. -* `color depth` selects either 4 or 8-bit color depth for the sprite. 0 = 4-bit, 1 = 8-bit. This attribute can also be set by the `SPRMEM` command. +* <sprite idx> is a value between 0-127 inclusive. +* <priority>, also known as z-depth changes the visibility of the sprite and above which layer it is rendered. Range is 0-3 inclusive. 0 = off, 1 = below layer 0, 2 = in between layers 0 and 1, 3 = above layer 1 +* <palette offset> is the palette offset for the sprite. Range is 0-15 inclusive. This value is multiplied by 16 to determine the starting palette index. +* <flip> controls the X and Y flipping of the sprite. Range is 0-3 inclusive. 0 = unflipped, 1 = X is flipped, 2 = Y is flipped, 3 = both X and Y are flipped. +* <x-width> and <y-width> represent the dimensions of the sprite. Range is 0-3 inclusive. 0 = 8px, 1 = 16px, 2 = 32px, 3 = 64px. +* <color depth> selects either 4 or 8-bit color depth for the sprite. 0 = 4-bit, 1 = 8-bit. This attribute can also be set by the [`SPRMEM`](#sprmem) command. Note: If VERA's sprite layer is disabled when the `SPRITE` command is called, the sprite layer will be enabled, regardless of the arguments to `SPRITE`. @@ -2772,17 +2786,17 @@ Note: If VERA's sprite layer is disabled when the `SPRITE` command is called, th ### SPRMEM -**TYPE: Command** +**TYPE: Statement** **FORMAT: SPRMEM <sprite idx>,<VRAM bank>,<VRAM address>\[,<color depth>\]** **Action:** This command configures the address of where the sprite's pixel data is to be found. It also can change or set the color depth of the sprite. The first three arguments are required, but the last one is optional. -* `sprite idx` is a value between 0-127 inclusive. -* `VRAM bank` is a value, `0` or `1`, which represents which of the two 64k regions of VRAM to select. -* `VRAM address` is a 16-bit value, \$0000-\$FFFF, is the address within the VRAM bank to point the sprite to. The lowest 5 bits are ignored. -* `color depth` selects either 4 or 8-bit color depth for the sprite. 0 = 4-bit, 1 = 8-bit. This attribute can also be set by the `SPRITE` command. +* <sprite idx> is a value between 0-127 inclusive. +* <VRAM bank> is a value, `0` or `1`, which represents which of the two 64k regions of VRAM to select. +* <VRAM address> is a 16-bit value, \$0000-\$FFFF, is the address within the VRAM bank to point the sprite to. The lowest 5 bits are ignored. +* <color depth> selects either 4 or 8-bit color depth for the sprite. 0 = 4-bit, 1 = 8-bit. This attribute can also be set by the `SPRITE` command. **EXAMPLE of the SPRITE Statement:** @@ -2822,11 +2836,11 @@ RUN | **ST Bit Position** | **ST Numeric Value** | **Serial Bus R/W** | **RS-232** | |:-------------------:|:--------------------:|:-------------------|:-----------| -| 0 | 1 | Indicates data directionif a timeout occured;
0 = reading, 1 = writing. | Parity Error | +| 0 | 1 | Indicates data direction if a timeout occurred;
0 = reading, 1 = writing. | Parity Error | | 1 | 2 | Timeout error | Framing error | | 2 | 4 | - | Receive buffer overrun | | 3 | 8 | - | Receive buffer empty | -| 4 | 16 | `VERIFY` error. | CTS signal missing | +| 4 | 16 | [`VERIFY`](#verify) error. | CTS signal missing | | 5 | 32 | - | - | | 6 | 64 | EOF | RTS signal missing | | 7 | -128 | Device Not Present | BREAK Detected | @@ -2851,7 +2865,7 @@ RUN **TYPE: Statement** **FORMAT: [STEP <expression>]** -**Action:** The optional `STEP` keyword follows the <end-value> expression in a `FOR` statement. It defines an increment value for the loop counter variable. Any value can be used as the `STEP` increment. Of course, a `STEP` value of zero will loop forever. If the `STEP` keyword is left out, the increment value will be + 1. When the `NEXT` statement in a `FOR` loop is reached, the `STEP` increment happens. Then the counter is tested against the end-value to see if the loop is finished. (See the [FOR](#for) statement for more information.) +**Action:** The optional `STEP` keyword follows the <end-value> expression in a [`FOR`](#for-to-step) statement. It defines an increment value for the loop counter variable. Any value can be used as the `STEP` increment. Of course, a `STEP` value of zero will loop forever. If the `STEP` keyword is left out, the increment value will be + 1. When the [`NEXT`](#next) statement in a `FOR` loop is reached, the `STEP` increment happens. Then the counter is tested against the end-value to see if the loop is finished. (See the [`FOR`](#for-to-step) statement for more information.) > **NOTE:** The `STEP` value cannot be changed once it's in the loop. @@ -2866,7 +2880,7 @@ RUN **TYPE: Statement:** **FORMAT: STOP** -**Action:** The `STOP` statement is used to halt execution of the current program and return to direct mode. Typing the **RUN/STOP** key on the keyboard has the same effect as a `STOP` statement. The BASIC error message `BREAK IN XX` is displayed on the screen, followed by `READY`. The "XX" is the line number where the `STOP` occurs. Any open files remain open and all variables are preserved and can be examined. The program can be restarted by using the `CONT` or `GOTO` statements. +**Action:** The `STOP` statement is used to halt execution of the current program and return to direct mode. Typing the **RUN/STOP** key on the keyboard has the same effect as a `STOP` statement. The BASIC error message `BREAK IN XX` is displayed on the screen, followed by `READY`. The "XX" is the line number where the `STOP` occurs. Any open files remain open and all variables are preserved and can be examined. The program can be restarted by using the [`CONT`](#cont) or [`GOTO`](#goto) statements. **EXAMPLES of the STOP Statement:** ```BASIC @@ -2896,7 +2910,7 @@ RUN **TYPE: Function** **FORMAT: STRPTR(<variable>)** -**Action:** Returns the memory address of the first character of a string contained within a string variable. If the string variable has zero length, this function will likely still return a non-zero value pointing either to the close quotation mark in the literal assignment, or to somewhere undefined in string memory. Programs should check the `LEN()` of string variables before using the pointer returned from `STRPTR`. +**Action:** Returns the memory address of the first character of a string contained within a string variable. If the string variable has zero length, this function will likely still return a non-zero value pointing either to the close quotation mark in the literal assignment, or to somewhere undefined in string memory. Programs should check the [`LEN`](#len)gth of string variables before using the pointer returned from `STRPTR`. **EXAMPLE of the STRPTR function:** @@ -2926,7 +2940,7 @@ In this case, the pointer returned on line 70 pointed to the first character aft **Action:** The SYS command executes a machine language subroutine located at <address>. Execution continues until an RTS is executed, and control returns to the BASIC program. -In order to communicate with the routine, you can pre-load the CPU registers by using POKE to write to the following +In order to communicate with the routine, you can pre-load the CPU registers by using [`POKE`](#poke) to write to the following memory locations: * `$030C`: Accumulator @@ -2934,7 +2948,7 @@ memory locations: * `$030E`: Y Register * `$030F`: Status Register/Flags -When the routine is over, the CPU registers will be loaded back in to these locations. So you can read the results of a machine language routine by PEEKing these locations. +When the routine is over, the CPU registers will be loaded back in to these locations. So you can read the results of a machine language routine by [`PEEK`](#peek)ing these locations. **EXAMPLE of the SYS statement:** @@ -2956,7 +2970,7 @@ SYS $FECC **TYPE: Special Function** **FORMAT: TAB(<numeric>)** -**Action:** The `TAB` function moves the cursor to a relative [SPC](#spc) move position on the screen given by the <numeric> argument, starting with the left-most position of the current line. The value of the argument can range from 0 to 255. The `TAB` function should only be used with the `PRINT` statement, since it has no effect if used with the `PRINT#` to a logical file. +**Action:** The `TAB` function moves the cursor to a relative [SPC](#spc) move position on the screen given by the <numeric> argument, starting with the left-most position of the current line. The value of the argument can range from 0 to 255. The `TAB` function should only be used with the `PRINT` statement, since it has no effect if used with the [`PRINT#`](#print-1) to a logical file. **EXAMPLE of the TAB Function:** ```BASIC @@ -2989,9 +3003,9 @@ RUN **Action:** The `TATTR`function retrieves the text/tile attribute at the given x/y coordinate. It works for tiles or text on Layer 1. -In the default text modes, this can be used to retrieve the color attribute (fg/bg) of a specific coordinate without needing to calculate the VRAM address for VPEEK. +In the default text modes, this can be used to retrieve the color attribute (foreground/background) of a specific coordinate without needing to calculate the VRAM address for [`VPEEK`](#vpeek). -**EXAMPLE of the TATTR command:** +**EXAMPLE of the TATTR Function:** ```BASIC 10 REM COPY BUTTERFLY LOGO WITH COLORS TO CENTER OF 80X60 SCREEN @@ -3009,11 +3023,11 @@ In the default text modes, this can be used to retrieve the color attribute (fg/ **TYPE: Function** **FORMAT: TDATA(<x coordinate>,<y coordinate>)** -**Action:** The `TDATA`function retrieves the text/tile at the given x/y coordinate. It works for tiles or text on Layer 1. +**Action:** The `TDATA` function retrieves the text/tile at the given x/y coordinate. It works for tiles or text on Layer 1. -In the default text modes, this can be used to retrieve the character a specific coordinate without needing to calculate the VRAM address for VPEEK. +In the default text modes, this can be used to retrieve the character a specific coordinate without needing to calculate the VRAM address for [`VPEEK`](#vpeek). -**EXAMPLE of the TATTR command:** +**EXAMPLE of the TATTR Function:** ```BASIC 10 REM COPY BUTTERFLY LOGO TO CENTER OF 80X60 SCREEN @@ -3027,16 +3041,16 @@ In the default text modes, this can be used to retrieve the character a specific ### TILE -**TYPE: Command** +**TYPE: Statement** **FORMAT: TILE <x>,<y>,<tile/screen code>\[,<attribute>\]** -**Action:** The `TILE` command sets the tile or text character at the given x/y tile/character coordinate to the given screen code or tile index, optionally resetting the attribute byte. It works for tiles or text on Layer 1. +**Action:** The `TILE` statement sets the tile or text character at the given x/y tile/character coordinate to the given screen code or tile index, optionally resetting the attribute byte. It works for tiles or text on Layer 1. -In the default text mode, this can be used to quickly change a character on the screen and optionally its fg/bg color without needing to calculate the VRAM address for VPOKE. +In the default text mode, this can be used to quickly change a character on the screen and optionally its foreground/background color without needing to calculate the VRAM address for [`VPOKE`](#vpoke). However, it can also be used if VERA Layer 1's map base value is changed or the map size is changed. -**EXAMPLE of the TILE command:** +**EXAMPLE of the TILE Statement:** ```BASIC 10 REM VERY SLOWLY CLEAR THE SCREEN IN STYLE @@ -3095,7 +3109,7 @@ The value of the <numeric> argument is stored in the floating-point accumu **TYPE: Numeric Function** **FORMAT: VAL(<string>)** -**Action:** Returns a numeric value representing the data in the <string> argument. If the first non-blank chracter of the string is not a plus sign `(+)`, minus sign `(-)`, or a digit, the value returned is zero. String conversion is finished when the end of a string or any non-digit character is found (except decimal point or exponential e). +**Action:** Returns a numeric value representing the data in the <string> argument. If the first non-blank character of the string is not a plus sign `(+)`, minus sign `(-)`, or a digit, the value returned is zero. String conversion is finished when the end of a string or any non-digit character is found (except decimal point or exponential e). **EXAMPLE of the VAL Function:** ```BASIC @@ -3108,7 +3122,7 @@ The value of the <numeric> argument is stored in the floating-point accumu **TYPE: Command** **FORMAT: VERIFY ["<file name>"][,<device>]** -**Action:** The `VERIFY` command ise used, in direct or program mode, to compare the contents of a BASIC program file on disk with the program currently in memory. `VERIFY` is normally used right after a [SAVE](#save), to make sure that the program was stored correctly on disk. +**Action:** The `VERIFY` command is used, in direct or program mode, to compare the contents of a BASIC program file on disk with the program currently in memory. `VERIFY` is normally used right after a [SAVE](#save), to make sure that the program was stored correctly on disk. If the <device> number is left out, the program is assumed to be on the first disk device, which is device #8. If any differences in program text are found, the BASIC error message `?VERIFY ERROR` is displayed. @@ -3129,7 +3143,7 @@ A program name can be given either in quotes `(" ")` or as a string variable. **Action:** Return a byte from the video address space. The video address space has 17 bit addresses, which is exposed as 2 banks of 65536 addresses each. -In addition, VPEEK can reach add-on VERA cards with higher bank numbers. +In addition, `VPEEK` can reach add-on VERA cards with higher bank numbers. BANK 2-3 is for IO3 (VERA at \$9F60-\$9F7F) BANK 4-5 is for IO4 (VERA at \$9F80-\$9F9F) @@ -3147,7 +3161,7 @@ PRINT VPEEK(1,$B000) : REM SCREEN CODE OF CHARACTER AT 0/0 ON SCREEN **Action:** Set a byte in the video address space. The video address space has 17 bit addresses, which is exposed as 2 banks of 65536 addresses each. -In addition, VPOKE can reach add-on VERA cards with higher bank numbers. +In addition, `VPOKE` can reach add-on VERA cards with higher bank numbers. BANK 2-3 is for IO3 (VERA at \$9F60-\$9F7F) BANK 4-5 is for IO4 (VERA at \$9F80-\$9F9F) @@ -3161,12 +3175,12 @@ VPOKE 1,$B000+1,1 * 16 + 2 : REM SETS THE COLORS OF THE CHARACTER ### VLOAD -**TYPE: Command** +**TYPE: Statement** **FORMAT: VLOAD <filename>, <device>, <VERA_high_address>, <VERA_low_address>** **Action:** Loads a file directly into VERA RAM, skipping the two-byte header that is presumed to be in the file. -**EXAMPLES of VLOAD:** +**EXAMPLES of the VLOAD Statement:** ```BASIC VLOAD "MYFILE.PRG", 8, 0, $4000 :REM LOADS MYFILE.PRG FROM DEVICE 8 TO VRAM $4000 @@ -3208,7 +3222,7 @@ The size of hex and binary values is only restricted by the range that can be re ### LOAD into VRAM -In BASIC, the contents of files can be directly loaded into VRAM with the `LOAD` statement. When a secondary address greater than one is used, the KERNAL will now load the file into the VERA's VRAM address space. The first two bytes of the file are used as lower 16 bits of the address. The upper 4 bits are `(SA-2) & 0x0ff` where `SA` is the secondary address. +In BASIC, the contents of files can be directly loaded into VRAM with the [`LOAD`](#load) statement. When a secondary address greater than one is used, the KERNAL will now load the file into the VERA's VRAM address space. The first two bytes of the file are used as lower 16 bits of the address. The upper 4 bits are `(SA-2) & 0x0ff` where `SA` is the secondary address. Examples: @@ -3223,22 +3237,22 @@ Examples: ### Default Device Numbers -In BASIC, the LOAD, SAVE and OPEN statements default to the last-used IEEE device (device numbers 8 and above), or 8. +In BASIC, the [LOAD], [`SAVE`](#save) and [`OPEN`](#open) statements default to the last-used IEEE device (device numbers 8 and above), or 8. ## Internal Representation Like on the C64, BASIC keywords are tokenized. -* The C64 BASIC V2 keywords occupy the range of \$80 (`END`) to \$CB (`GO`). +* The C64 BASIC V2 keywords occupy the range of \$80 ([`END`](#end)) to \$CB (`GO`). * BASIC V3.5 also used \$CE (`RGR`) to \$FD (`WHILE`). -* BASIC V7 introduced the \$CE escape code for function tokens \$CE-\$02 (`POT`) to \$CE-\$0A (`POINTER`), and the \$FE escape code for statement tokens \$FE-\$02 (`BANK`) to \$FE-\$38 (`SLOW`). +* BASIC V7 introduced the \$CE escape code for function tokens \$CE-\$02 (`POT`) to \$CE-\$0A (`POINTER`), and the \$FE escape code for statement tokens \$FE-\$02 ([`BANK`](#bank)) to \$FE-\$38 (`SLOW`). * The unreleased BASIC V10 extended the escaped tokens up to \$CE-\$0D (`RPALETTE`) and \$FE-\$45 (`EDIT`). The X16 BASIC aims to be as compatible as possible with this encoding. Keywords added to X16 BASIC that also exist in other versions of BASIC match the token, and new keywords are encoded in the ranges \$CE-\$80+ and \$FE-\$80+. ## Auto-Boot -When BASIC starts, it automatically executes the `BOOT` command, which tries to load a PRG file named `AUTOBOOT.X16` from device 8 and, if successful, runs it. Here are some use cases for this: +When BASIC starts, it automatically executes the [`BOOT`](#boot) command, which tries to load a PRG file named `AUTOBOOT.X16` from device 8 and, if successful, runs it. Here are some use cases for this: * An SD card with a game can auto-boot this way. * An SD card with a collection of applications can show a menu that allows selecting an application to load. diff --git a/images/print-color-example.png b/images/print-color-example.png new file mode 100644 index 0000000000000000000000000000000000000000..455c6ff881459c76a7123137a6d986034f40d189 GIT binary patch literal 5847 zcmZ8lby!tF(?6HIbcd8kHwXyQUP8JrjdZ7U!Jagu^v%7O<_MDx0W}`LKAfHKO$5KcJ^3al( z2CBztc99)4TZk$I0O}HP?#$7VeXO?%1|9%_-}{e11Fof3NFk-CoW7^FtBt3Rxw|!> zVQ%l@$)hF*rGLTmoJYjTWl0h_r`cLx(MC~`0{|mC=l~T69RMMb5|XI@7bC3!*g&ZN zk^i&jIS2(HL~=tU*+-%MNA7^c|C$++{;mH%{{LPIpd#JD1kjK(`1l3*K%f7s_1_Bg z&;Qkwip2jK3Q`Zse`aclyhNh^UG=!YbXjK3TKXh3B6yMt%FrlZmb}!_FWW08{M zGfzxVWtaaArCG{cdKS(+42%{p~1##W~3ia+OP*@_v#smTb{4i41Xn;*32Rj0O zYHv@7Jp|-mU=!O>@nOISVRoLFM1W_gE+;rtRDNtsm4#3a5+MB1{8f6l1qjkL6jQE7 zI>KO}OV*NeBCbG;LC7FX3Zm!cHlA%11V_kLjkD*C7aEny4Oj%&qK`xZg5kdrb(Bwc}Nv-J>W*Q$5SA9@cAul+30YWLR8R}_B z6)r6r6_+8n=F${O|9drTBZ=t^%(P#b0no2X9hOMOey#enWVnt&)Xj;13U0@ixl*HH zg{S;=zxuqQrWp$*fm{}61TGULUZEGzxWVtYJ=*A4(-dpL&}}*JrKa;ph-Px}u(b7M z#!i|3fQ5nQU8`$<4EdXc6xQs4c#k9+OQndNi3#tQzM6fc=%MsA#=AFv;5A;Mw}q}`(1BXO-Fi;qy#3whY<-WQEN)e$crV_3BLMS$yr_d zp5ZkZFx&W6?D~~RG}F?A?hQ0mS@Zqo_wSUxyG1t41GmR5TRSBroHK&uC+Zla_T2*%gHKS~_RUauk zyQo0p!xaq>YW1}Dkd3FpDgLFW6t-1UN%O*MPvZ@SDAElUwL9XjO8)GS!zH2y8@vUR zQrm@U65-YJHr*t80@`7^ml}h77|u@ssNO;%)n9g)!C#}v-O+%}4^zW+&Cq-S+v1CZ zEQp#pZp#|Nen(9Tz#}xSFMJF|w}ksB4d(c`tkwP$efB%a+LKrf(h3L%v-5A(m zx6RQs95iw2J<{A8ne-hm?&?TuK<=Y+^$vKH#QA7Q;@WUL&1b6 z^CD%Z>DN2=Gi~)%Sxvi(gP%U@K|0RPXM-Q|`p@3Atlb5Yku2*5_bY5k&@WWFmEu&qx^6dxm zSu2Y}Z&XMON*+NvuauGI)Z2$IHmVPUM3?0{c>4@mhx5}oQv2@xCAFa;${vnd?s>Jr%x_O2k(_Glk&k=(&wH7M5I9K!0;=K@Y;&L_ zfgX~TSS2>5DwEY#Cj%1A4AHc7#Ki$tmI{Tbh^D*yw3AT7;%KsY=&w@81))!phl~r~ z56LUi8kYTF(A&q^E}AHJkC_8+58ZUR3>th+b{(|yi{+zft&Ew)#=y4yev0h52X^pu zxegC}b6QJ}V=WkTu)cn?o!wXW*W0+^o2Age*dL@{dvoz>wlj`3ZOyJy@{uU^_JRJ0 zp`W#~+kzN0Qb&F}Ig#IKMuv@Dzb^K;xp}B4tzg7%umQS?doDtMP7#q?z#TQd1$XiK1d%xRH@#37{5%o{#~%o!Rb0W3gz{c!@?LU*J#v2LxRj<`6#9$cWz%v{ALLD(Ena z)6VNck-abf{OU}WzR+!Owxi=sVaYy?QA)vjO{dATQ`~yM$)(z+HMNz9FDvtEytnT) zPGN$DVNfXBaGZ!3Jx0Dd+7#eAY>mY_QSUjFrX)JhtvRMX5vauN-U8J^LLxwzzUa!FHoQOhe?|9Q9^lhBHdo9 zXct?pyG6aARB5Wx>~$M0R5Xy2yMQy?ey=mobzIp(rR7py4Gz$MJN{`Di)8d&R|M&g z1u!w%%JlU1S;Ut$*Z_&0<9=7>GwVo#iOlDW4MQeisnf zkfVT~?a1UOZT`jhvi6FPt-0w#D;~YfMtXX4b92%HH5e^?UKbhtdd=~uh2lO*-YXp* zo;xjjJDqOUG(s@m`K)*B9kt7s20#DNFp-c*-D1R9+S}=KJXRoosgpp#ebZRD**H~h zQrqY``NeNxH$;emG#Q!PPZ}mrUQb~?Ab&vhkEt~@8EJ>yJk`pz7=D_Q88L4+6*eaG zpO(}zaFUT1cRW6%l43SYNOkTHv8toI1*XS@vn3yVIR^SUu!#*dc-YJ;DoQwTgyZAa zawUXWzfVNNKuH4vFC-+4%RF|LXc7oEoVQE6fUASWG6Mth|0Y~XCSf%2-M%S$$juDf z)?Pd{a&tAEp{Gznx*)-wG(8qOuOi0t6^|eaZiMD#MKd(qdza&6)rSNJ+y8fnkj3Le zUiH_Tl=lH>U+*vGi5PiiOwkBSpx8IIlSvCE%a>iK@{QHM*V{Zs$Ak%>_r%OU1-`rd zQp3VCr;IruDS254)j<2p8ayX^5%eNpZP1B?<5@MZ7O4`q@D=+Sa5 zW364BO{s;bD#$**Q#cI}ANsY<`^0yx*3Ai%G-8R2tH(_+E3aRA1|tz@b1saS`XtBp zka{wszMmWN5L;j0p@fXUHIMhl$BKbAdupbdZYNtAoyepiT2MMQZjSUL*WbZbt{-wA zotHhBj`D;*JcYQMZRAGV!GQMu#(Hj!Y<^aSMk?2J!krhHs+5$xiEwyK?)rcB;<0-R zjg9S?`kJ>`+`Mp9cxft34?b;L;FnK)xaf;!_wq_{bSNIn35b7y^ZYn$>Ac^O@jc#JM|?05A5is?|yFbltHJ++;+!)0nf#X&v6`fQs~IsJfx zb9vwMC}_8cxAW0N&^RcWDNG)=A~fA&H*P`G5&IQg)U)(@h&7R%Vu5}4XH;U9@nZ4^ z^Q1ayCmCInhkMIJos10O^Mgg5H=aQqw{1K4&Wooh4}CS@iZtq%d}6%3CHW8(JJckn z=G4IPeLNmR&p7>)nh**1?Kr&gKi@ivA)kO=?elprrnE03F96CU&1LsL{JS^eNQx z(VJfJlrb?-*yre-*ZxXdo1(b+L~djRP9hn_!dQ;c<<-W3dTy#1r!<>O_m~Yv7g|?E zG8XK@_gt?W0;Zx8$Hc$$+?y3S9kEQ@sxtOl-AKH2vHM+42}&;lRl?sV(t6NJuKc)s zwD`7jD3|^RE{AFw;Cv-RVBNOLzMBG1S_v^w`0wUkzLjV%!;h;y1$G z)^|w^R?>2MJw+pC@d5w+w{9yqh)b8VAXrf&nGX>512UB<`<3KQKLAGl>V;;(ILO{R@tgX?tH$9o}q)Sd_TOdk-Cg#u0uz^2s(bS_XbZQr}>NHGI9YV1T(mAmbwi$RdaoJc`)p8DQ z$X!-N$$#`vIK%PMk0K&dDa2}Bdb4Tf=asUB{90Tu>$y+?Tp16Vjko%9dc>3%*474o zxzT=_k@;*^E!md3Ds|OPOOwx>_~mTzv6`WlXo_jPRbQXeaVa-&ISVxa!Tbx&kvg&V zh9s|QmcJ#G@oSZZNT7I_jWVhE=F2D@us3&{PqG%{OJOw*1#b? zs1bApLNTf7tgrV&R{R8#lO;Ddk@NGdZz|RFqQh`~O)R;*NLzVcecG{4)2&mRw6ehC zmeynw&^}Z8JT5WF*yft2p|d68KdVm1oM379ad>!IJW~{sYm4hqXwSjPIi>twQ4>YJ z|N1N-j&_-oGoDoJjnv3dy zzg($oQu%ESzw7WfK!+5wfg?6c@~V;Mop8GR(pLYAI6}}Vr3pK|y#7XA#SU##evVJ` zqVJgCa6ROsIa|ru$+BxZ$PN&9AZ>qZPN&LffRSFbx8D(RJ#zU$DSAROVDZJmW)g=0 zuK#hz)3tyJ8MG+e{JbDkyljfB_w%;R<0la>Hx|)p&YJW6 z^>r37|22x9z5U@%9wvwl@SA2jlOe$CqvXR#C`h1n^t=0`O|+%J`_)%2IM}Ar(6g4y z>sNTd(aKZOOa1!IQ}bS${G>QS4O0KJv14Huru99?C{t#bb(w%|Ac3T>xLR5YiA(K) z_v{jfU6jM8v2U%bisC~yjO(!)1o*w7r0AsRa7rk`0>Flq*b|3ZTX|LX4>5bOtZPx`4{n@npwJ-IMD>-&){&hNcv%@&AIuTA~OiB`Q`i8 zcS{n)1wMn6IOVbON+W0D*etn!m>`d3UuL5NyLgw(p6tf(XI+_1($fvv$hi0r!p@sE z8;7i<-vRnulk<^H%FJnULMhe#tqx$Ln)Y;VUhT@fU5T6)j&qg7imeICDk2<@vM|KtD*Rp z-L~^_W|ZYkb5eGbB}+uQ!n8&0-H1lMtU=CGc6?D%yL8ouMWeH&^AX{6Ipp>P8LQ?`2P}cWD+kbk``R0E2&Uf$JGjqI(k|Z!q{aE&3;-m*kO-Qg3*J@zD??+$vtbb;D@aop;7JT568{b0 zP#_CbVX^=QF$V}I|KiZy0bQ8%r@R!zjbTy%3Hd7!LcW#xln;gYzWGAfum9Ws<4_}Tu#TbUYutMs(Zw<6V;=sYQJ?Y z|BRQJ6AHdaC*00Mu8L~B=VXp82j-AN(D0RyV-=vjV5to2n?MR_wArmqFM4EBJmTJ; zNk34}!bu1Z7gqeyh7~ClYt{1zpQJ;_s+)0b{oiljG0yma)fipt)VA%M_hWH9d-a5y zm$J0KLC)xRMEs_n!(4MciLoqojfj4)zrYj6e)YusN~^)e*^YQNl}h*F6+j?f-W_k8o7%8bC? zJWV*o%hjSp-3~yE=_k^u3`X&0Q-Ra^^KhG6nPEzSq^I?q;ydNNJDPtS70Z`04{X0V z`CrOrsT#sN)T&Hoi|7{pPDPZEmcZ2bIz0&Wsuoq)XxTlsFWXqx@ zW@!0lWZ`kn!l+J-vdU*QVoG%3e84=X_|~FC7Dot1RRWTJD~9(fhL%8f+`Vmee)nb%fwc8|tvIKHmY^qRxMOwZBTg^9J3b zh&jAHU2-|N>oQ@(#}9sd4wYPw9ln^Ov7SB9ePna3XpnguR<>N(9`wSLCMSleNJYhX z=)@XnpCE_*epEI7(cqdK_5Lj-pCL|G{N0M^7{|ABUdlUj4^LTc3|-^)9!FlGqU~n< zt{TbA$B_uVgL9|&w%#O0oBLDEX*}KXyZM1~gJim^jt)AfJj(^;Z9AE*ADMymids7Q zQ%;4s0MWNZF$;1JXQsR&mrSB59x;7yQHu|jfuRs>Xu%95`?+UZ$A9V*zG2kOz3*8b z7nNdU+FEemAdoY~afBz{=K043BG%3uE`X=c{zC2p#bs#~b6Qs@-0mKyg(tWDbZvrY-Q z@#i4ek~j#ebIJ>M9#_n1N*)OQbw1v}Ws99MxZGB{bcR*YF3x^pedHecotK$>@`@H$ zUS2QGPoz55vle$+5NDBABWYP|zHpJ|a;DEhw&dkc1L{l4ny68aF4Geadfo~IecsvF z$xSVC;z4L!-1DvwwYT!A$;yet7%FWQabV84X Date: Wed, 21 Jan 2026 12:55:17 -0800 Subject: [PATCH 13/13] Fixed minor capitalization issue. --- X16 Reference - 04 - BASIC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/X16 Reference - 04 - BASIC.md b/X16 Reference - 04 - BASIC.md index 88dcf8b..1ed9a6f 100644 --- a/X16 Reference - 04 - BASIC.md +++ b/X16 Reference - 04 - BASIC.md @@ -9,7 +9,7 @@ New styling features were used in this document and may not render correctly when viewed on github. PDF output appears correct. --> -## Table of BASIC statements and functions +## Table of BASIC Statements and Functions | Keyword | Type | Summary | Origin | | - | - | - | - |