mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2024-11-16 01:07:42 +00:00
Applesoft BASIC in JavaScript
cm | ||
polyfill@49d9a9d210 | ||
samples | ||
tools | ||
vfs | ||
.gitignore | ||
.gitmodules | ||
basic.js | ||
bell.js | ||
bell.wav | ||
bs.html | ||
cbasic.js | ||
display.css | ||
dos.js | ||
favicon.ico | ||
font-40col.png | ||
font-80col.png | ||
font.png | ||
hires.js | ||
index.html | ||
index.js | ||
LICENSE.md | ||
lores.js | ||
lpt.jpg | ||
printer.js | ||
README.md | ||
reference.html | ||
script.js | ||
script.md | ||
styles.css | ||
tty.js |
jsbasic - Applesoft BASIC in JavaScript
This is hosted for playing with at http://inexorabletash.github.io/jsbasic/
Use git clone --recursive
to get polyfill for older browsers.
Notes & Known Issues
- The BASIC program is compiled to JavaScript before execution. Syntax errors are therefore detected at compile-time rather than at run-time as on a traditional interpreter. For example, the following program would run without errors on an Apple since the erroneous second statement is never reached.
10 END : CHR$(PRINT)
- Handling of BASIC code that does not match the canonical
LIST
output format may not behave as on an Apple:- Keyword parsing differs from Applesoft command line. For example
FOR I = S TO P
doesn't collapse intoFOR I = STOP
.
- Keyword parsing differs from Applesoft command line. For example
- Limitations:
- Floating point overflow is only detected on variable assignment.
- Only a subset of DOS 3.3 and ProDOS useful for basic file I/O are implemented.
- Only a small number of common
PEEK
,POKE
andCALL
locations are supported. - Commands that refer to assembly routines (
&
,USR()
etc.), shape tables, and tape I/O are not implemented.
- Commands that operate on the program itself (
LIST
,RUN
,DEL
, etc.) are not implemented. - A handful of extensions are made beyond Applesoft BASIC:
- To improve readability, lines may start with
:
and continue the previously numbered line. DEF FN
can define string functions==
can be used as=
CHR$()
values > 255 do interesting thingsHSCRN(x, y)
allows probing the hi-res screen- hexadecimal literals e.g.
$C010
can be used as numbers
- To improve readability, lines may start with
You can run your basic programs from the command line (with only basic text input and output, and no graphics or DOS commands):
- Clone the repository locally
- On Windows, run from a command prompt via:
cscript.exe cbasic.js your_program.txt
- On Mac/Linux, install Mozilla Rhino, run from the command prompt via:
java -jar PATH_TO/js.jar cbasic.js your_program.txt