From 9f83bcaad374943b43d37414796bea94e9e8e6e8 Mon Sep 17 00:00:00 2001
From: Joshua Bell
-Extensions beyond Applesoft BASIC are called out with footnotes. +Extensions beyond Applesoft BASIC are called out with footnotes.
See also:
@@ -40,7 +41,7 @@ This is intended as a quick reference for the Applesoft BASI -POKE 32,n
- Text window left edge
- POKE 33,n
- Text window width
- POKE 34,n
- Text window top edge
- POKE 35,n
- Text window bottom
- POKE 36,n
- Text cursor x
- POKE 37,n
- Text cursor y
- POKE 216,n
- ONERR flag (n < 128 disables ONERR handler)
- POKE 230,n
- Hi-Res plotting page (32 = page 1, 64 = page 2)
- POKE 49168,0
- clear keyboard strobe
- POKE 49200,0
- toggle speaker (no-op)
- POKE 49232,0
- graphics mode
- POKE 49233,0
- text mode
- POKE 49234,0
- full graphics
- POKE 49235,0
- split screen
- POKE 49238,0
- lores
- POKE 49239,0
- hires
- POKE 32,n
- Text window left edge
+ POKE 33,n
- Text window width
+ POKE 34,n
- Text window top edge
+ POKE 35,n
- Text window bottom
+ POKE 36,n
- Text cursor x
+ POKE 37,n
- Text cursor y
+ POKE 216,n
- ONERR flag (n < 128 disables ONERR handler)
+ POKE 230,n
- Hi-Res plotting page (32 = page 1, 64 = page 2)
+ POKE 49168,0
- clear keyboard strobe
+ POKE 49200,0
- toggle speaker (no-op)
+ POKE 49232,0
- graphics mode
+ POKE 49233,0
- text mode
+ POKE 49234,0
- full graphics
+ POKE 49235,0
- split screen
+ POKE 49238,0
- lores
+ POKE 49239,0
- hires
+ CALL -3100
- reveal hi-res page 1
- CALL -3086
- clear current hi-res page to black
- CALL -3082
- clear current hi-res page to current color
- CALL 54951
- clear stack (cancel pending FOR
-NEXT
loops and GOSUB
s)
- CALL -3100
- reveal hi-res page 1
+ CALL -3086
- clear current hi-res page to black
+ CALL -3082
- clear current hi-res page to current color
+ CALL 54951
- clear stack (cancel pending FOR
-NEXT
loops and GOSUB
s)
+ PR#0
- set 40 column mode
- PR#3
- set 80 column mode
- PR#0
- set 40 column mode
+ PR#3
- set 80 column mode
+ PEEK(32)
- Text window left edge
- PEEK(33)
- Text window width
- PEEK(34)
- Text window top edge
- PEEK(35)
- Text window bottom
- PEEK(36)
- Text cursor x
- PEEK(37)
- Text cursor y
- PEEK(78)
& PEEK(79)
- Random-Number Field
- PEEK(222)
- Last error code
- PEEK(230)
- Hi-Res plotting page (32 = page 1, 64 = page 2)
- PEEK(49152)
- Read Keyboard
- PEEK(49168)
- Clear Keyboard strobe
- PEEK(49200)
- Click Speaker (no-op)
- PEEK(49248)
- Read Paddle Button #3 - Use the PageDown key
- PEEK(49249)
- Read Paddle Button #0 - Use the Home key
- PEEK(49250)
- Read Paddle Button #1 - Use the End key
- PEEK(49251)
- Read Paddle Button #2 - Use the PageUp or Shift key
- PEEK(32)
- Text window left edge
+ PEEK(33)
- Text window width
+ PEEK(34)
- Text window top edge
+ PEEK(35)
- Text window bottom
+ PEEK(36)
- Text cursor x
+ PEEK(37)
- Text cursor y
+ PEEK(78)
& PEEK(79)
- Random-Number Field
+ PEEK(222)
- Last error code
+ PEEK(230)
- Hi-Res plotting page (32 = page 1, 64 = page 2)
+ PEEK(49152)
- Read Keyboard
+ PEEK(49168)
- Clear Keyboard strobe
+ PEEK(49200)
- Click Speaker (no-op)
+ PEEK(49248)
- Read Paddle Button #3 - Use the PageDown key
+ PEEK(49249)
- Read Paddle Button #0 - Use the Home key
+ PEEK(49250)
- Read Paddle Button #1 - Use the End key
+ PEEK(49251)
- Read Paddle Button #2 - Use the PageUp or Shift key
+ PEEK(222)
in an ONERR handler.
See also
Other DOS commands are NOT IMPLEMENTED.
Some sample files are present in a server-side store loaded on-demand into a client-side virtual file system (VFS). Creating or writing to a file will write to the VFS. Subsequent reads will read from the VFS. Files may be deleted from the VFS. These changes will not persist if the browser is refreshed or closed.
@@ -388,20 +388,20 @@ This is intended as a quick reference for the Applesoft BASIPEEK(222)
in an ONERR handler.
The Open Apple and Closed Apple keys on later Apple II models correspond to the Button #0 and Button #1 inputs and are emulated on modern keyboards -with the Home and End keys respectively. (Unfortunately, browsers -are currently unable to distinguish the left and right Alt or Command keys.) +with the Left Alt and Right Alt keys respectively if possible, +otherwise the Home and End keys respectively.
@@ -432,14 +432,14 @@ using GET
(blocking) or PEEK(49152)
(non-blocking):
CHR$(8) | Left arrow - |
CHR$(10) | Down arrow - |
CHR$(11) | Up arrow - |
CHR$(13) | Enter or Return - |
CHR$(21) | Right arrow - |
CHR$(24) | Clear - |
CHR$(27) | Escape - |
CHR$(127) | Delete or Backspace + |
CHR$(8) | Left arrow + |
CHR$(10) | Down arrow + |
CHR$(11) | Up arrow + |
CHR$(13) | Enter or Return + |
CHR$(21) | Right arrow + |
CHR$(24) | Clear + |
CHR$(27) | Escape + |
CHR$(127) | Delete or Backspace |
CHR$(4) | DOS command escape prefix - |
CHR$(7) | Make a "beep" (if your browser supports it) - |
CHR$(8) | Backspace (move cursor left, wrap up) - |
CHR$(10) | Line feed (move cursor down) - |
CHR$(13) | Carriage return (move cursor down and to left edge) - |
CHR$(127) | Displays a cursor glyph + |
CHR$(4) | DOS command escape prefix + |
CHR$(7) | Make a "beep" (if your browser supports it) + |
CHR$(8) | Backspace (move cursor left, wrap up) + |
CHR$(10) | Line feed (move cursor down) + |
CHR$(13) | Carriage return (move cursor down and to left edge) + |
CHR$(127) | Displays a cursor glyph |
If 80-column firmware is active, the following additional codes are available:
CHR$(11) | Clears from the cursor position to the end of the window - |
CHR$(12) | Move cursor to upper left and clear window - |
CHR$(14) | Set normal text output - |
CHR$(15) | Set inverse text output - |
CHR$(17) | Set display to 40 columns - |
CHR$(18) | Set display to 80 columns - |
CHR$(21) | Deactivate the 80-column firmware - |
CHR$(22) | Scroll display down, preserving cursor position - |
CHR$(23) | Scroll display up, preserving cursor position - |
CHR$(24) | Disable mousetext - |
CHR$(25) | Move cursor to upper left (but don't clear window) - |
CHR$(26) | Clear the current line - |
CHR$(27) | Enable mousetext - |
CHR$(28) | Forward space (move cursor right, wrap down) - |
CHR$(29) | Clear from cursor position to end of line + |
CHR$(11) | Clears from the cursor position to the end of the window + |
CHR$(12) | Move cursor to upper left and clear window + |
CHR$(14) | Set normal text output + |
CHR$(15) | Set inverse text output + |
CHR$(17) | Set display to 40 columns + |
CHR$(18) | Set display to 80 columns + |
CHR$(21) | Deactivate the 80-column firmware + |
CHR$(22) | Scroll display down, preserving cursor position + |
CHR$(23) | Scroll display up, preserving cursor position + |
CHR$(24) | Disable mousetext + |
CHR$(25) | Move cursor to upper left (but do not clear window) + |
CHR$(26) | Clear the current line + |
CHR$(27) | Enable mousetext + |
CHR$(28) | Forward space (move cursor right, wrap down) + |
CHR$(29) | Clear from cursor position to end of line |
@@ -503,15 +503,15 @@ consumed by a recursive descent parser which outputs a JavaScript object representing the program.
The token types (treated as terminals) are
- reserved
,
- identifier
,
- string-literal
,
- number-literal
,
- operator
,
- line-number
,
- separator
,
- remark
,
- data-declaration
+ reserved
,
+ identifier
,
+ string-literal
,
+ number-literal
,
+ operator
,
+ line-number
,
+ separator
,
+ remark
,
+ data-declaration
- take a peek at the code if you want the gruesome details. Source lines may
only start with line numbers or (as an extension) separators. Special statement
parsing is done while lexing: REM
consumes anything to the next
@@ -529,10 +529,10 @@ object representing the program.
Overall program parsing is done with a recursive descent parser.
- Program = Line { Line } - Line = line-number Statement { separator Statement } - Statement = data-declaration | remark | Command | EmptyStatement - Command = identifier /*...*/ | reserved /*...*/ +Program = Line { Line } +Line = line-number Statement { separator Statement } +Statement = data-declaration | remark | Command | EmptyStatement +Command = identifier /*...*/ | reserved /*...*/
Statements ("commands" in the above grammar) are parsed with distinct cases for each statement type. @@ -541,88 +541,77 @@ with a standard recursive descent parser. The parser generates JavaScript expres which are used as arguments for the library calls.
- Expression = OrExpression - OrExpression = AndExpression { 'OR' AndExpression } - AndExpression = RelationalExpression { 'AND' RelationalExpression } - RelationalExpression = AdditiveExpression { RelOp AdditiveExpression } - RelOp = '=' | '<' | '>' | '<=' | '=<' | '>=' | '=>' | '<>' | '><' - AdditiveExpression = MultiplicativeExpression { ( '+' | '-' ) MultiplicativeExpression } - MultiplicativeExpression = PowerExpression { ( '*' | '/' ) PowerExpression } - PowerExpression = UnaryExpression [ '^' UnaryExpression ] - UnaryExpression = ( '+' | '-' | 'NOT' ) UnaryExpression - | FinalExpression - FinalExpression = number-literal - | string-literal - | 'FN' user_function_name '(' Expression ')' - | reserved '(' Expression { ',' Expression } ')' - | identifier [ '(' Expression { ',' Expression } ')' ] - | '(' Expression ')' +Expression = OrExpression +OrExpression = AndExpression { 'OR' AndExpression } +AndExpression = RelationalExpression { 'AND' RelationalExpression } +RelationalExpression = AdditiveExpression { RelOp AdditiveExpression } +RelOp = '=' | '<' | '>' | '<=' | '=<' | '>=' | '=>' | '<>' | '><' +AdditiveExpression = MultiplicativeExpression { ( '+' | '-' ) MultiplicativeExpression } +MultiplicativeExpression = PowerExpression { ( '*' | '/' ) PowerExpression } +PowerExpression = UnaryExpression [ '^' UnaryExpression ] +UnaryExpression = ( '+' | '-' | 'NOT' ) UnaryExpression + | FinalExpression +FinalExpression = number-literal + | string-literal + | 'FN' user_function_name '(' Expression ')' + | reserved '(' Expression { ',' Expression } ')' + | identifier [ '(' Expression { ',' Expression } ')' ] + | '(' Expression ')'-
Since Applesoft supports re-entrant error handling and synchronous input, the output of the compiler is an array of statement-functions plus a driver function which implements the logic for walking over the array.
DEF FN
supports string and integer functions
- e.g. DEF FN IN$(X$) = " " + X$
- (but return type must still match argument type)
- ==
is supported for equality comparisons, in addition to =
- CHR$()
values greater than 255 generate glyphs that might be useful for certain maze games.
- HSCRN(x,y)
is added to allow reading the
- hires screen. On a real Apple this required a machine-language routine (or a shape table and XDRAW
).
-
+ DEF FN
supports string and integer functions
+ e.g. DEF FN IN$(X$) = " " + X$
+ (but return type must still match argument type)
+ ==
is supported for equality comparisons, in addition to =
+ CHR$()
values greater than 255 generate glyphs that might be useful for certain maze games.
+ HSCRN(x,y)
is added to allow reading the
+ hires screen. On a real Apple this required a machine-language routine (or a shape table and XDRAW
).