Applesoft BASIC in JavaScript
Go to file
Joshua Bell cea98d6b01 Spacing
2015-09-17 13:54:29 -07:00
cm
polyfill@66a492fda0 Bump polyfill 2015-08-15 14:06:06 -07:00
samples Make line numbers relevant; resolves issue #5 2014-12-28 20:55:23 -07:00
tools
vfs
.gitignore
.gitmodules Pull CodeMirror from CDN, use submodule for polyfill 2013-12-08 15:48:03 -08:00
basic.js Make line numbers relevant; resolves issue #5 2014-12-28 20:55:23 -07:00
bell.js Remove copyright/license from individual JS files 2013-08-21 23:07:46 -07:00
bell.wav
bs.html Add script example 2013-12-08 15:56:19 -08:00
cbasic.js New samples, updated docs 2013-08-18 21:26:39 -07:00
display.css
dos.js Remove copyright/license from individual JS files 2013-08-21 23:07:46 -07:00
favicon.ico Updated favicon 2015-03-12 21:25:07 -07:00
font-40col.png Add more invisible arrows to font bitmap 2013-08-21 23:20:32 -07:00
font-80col.png Add more invisible arrows to font bitmap 2013-08-21 23:20:32 -07:00
font.png Add more invisible arrows to font bitmap 2013-08-21 23:20:32 -07:00
hires.js Remove copyright/license from individual JS files 2013-08-21 23:07:46 -07:00
index.html Update extensions. Update GA snippet. Drop script/style @type 2015-09-17 13:51:35 -07:00
index.js Re-enable input on iOS, Resolves #9 2015-01-02 10:32:03 -07:00
LICENSE.md Tweak license 2013-08-21 23:08:42 -07:00
lores.js Remove copyright/license from individual JS files 2013-08-21 23:07:46 -07:00
lpt.jpg
printer.js Remove copyright/license from individual JS files 2013-08-21 23:07:46 -07:00
README.md Make line numbers relevant; resolves issue #5 2014-12-28 20:55:23 -07:00
reference.html Spacing 2015-09-17 13:54:29 -07:00
script.js Fix script for Firefox 2014-01-25 22:25:01 -08:00
script.md Add github pages URLs 2014-01-27 08:55:20 -08:00
styles.css Whitespace 2013-12-08 15:35:19 -08:00
tty.js Expose more TTY CALL shims 2014-11-08 16:36:31 -08:00

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 into FOR I = STOP.
  • 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 and CALL 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 things
    • HSCRN(x, y) allows probing the hi-res screen
    • hexadecimal literals e.g. $C010 can be used as numbers

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