Applesoft BASIC in JavaScript
Go to file
2013-05-06 20:12:39 -07:00
samples Added new sample 2013-05-06 00:12:26 -04:00
vfs Snapshot 2012-02-08 22:13:44 -05:00
.gitignore Add ignore list. Update tty.js to use new-style key location data. 2012-06-05 12:04:24 -04:00
basic.js Added keyword table to support language localization 2012-06-20 11:54:32 -04:00
bell.js dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
bell.mp3 Snapshot 2012-02-08 22:13:44 -05:00
bell.ogg Snapshot 2012-02-08 22:13:44 -05:00
bell.wav Snapshot 2012-02-08 22:13:44 -05:00
dos.js dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
feed.js dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
feed.xml Snapshot 2012-02-08 22:13:44 -05:00
font-40col.png Snapshot 2012-02-08 22:13:44 -05:00
font-80col.png Snapshot 2012-02-08 22:13:44 -05:00
font.png Snapshot 2012-02-08 22:13:44 -05:00
hires.js Fix clearing to color 2012-08-09 17:48:41 -04:00
index.htm Added new sample 2013-05-06 00:12:26 -04:00
index.js Support source queryparam. Fix space. 2013-05-02 22:53:08 -04:00
lores.js dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
paddles.js dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
printer.js dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
README.md Update README.md 2013-05-06 20:12:39 -07:00
reference.htm dos2unix; factor out index.js; use addEvent/getClassList shims; change screen style using CSS classes 2012-02-08 22:37:04 -05:00
styles.css Make CodeMirror usage optional. update email address 2012-06-20 12:13:06 -04:00
tty.js Support source queryparam. Fix space. 2013-05-02 22:53:08 -04:00

jsbasic - Applesoft BASIC in JavaScript

This is hosted for playing with at http://calormen.com/applesoft/

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.
  • The interpreter doesn't actually care about line numbers for statement ordering (just for GOTO/GOSUB targets and IF statements). So 20 PRINT "A", 10 PRINT "B" will just print A, then B
  • To improve readability, lines may start with : and continue the previously numbered line.
  • Floating point overflow is only detected on variable assignment.
  • The DOS operating system implements only a subset of DOS 3.3 and ProDOS useful for basic file I/O.
  • Except for a small number of compatibility shims for common operations (e.g. keyboard strobe), commands that refer to assembly routines (PEEK, POKE, CALL, USR etc.), shape tables, or tape I/O are not implemented.
  • Commands that operate on the program itself (LIST, RUN, DEL, etc.) are not implemented.

You can run your basic programs from the command line (with only basic text input and output, and no graphics or DOS commands):

  • On Windows, download basic.js and run from a command prompt via: cscript.exe basic.js your_basic_program.txt
  • On Mac/Linux, install Mozilla Rhino, download basic.js and run from the command prompt via: java -jar PATH_TO/js.jar basic.js your_program.txt

To Do

  • Upload the CodeMirror styles
  • Snapshot and/or link sensibly to the polyfills
  • Implement DOS functionality for consoles

Links


6502asm.com - a 6502 assembler/emulator in JavaScript Quite BASIC - a similar project aimed at teaching programming NG-BASIC for Javascript Navaho Gunleg's interpreter BASIC Programming Resources Apple II emulator in JavaScript