Applesoft BASIC Interpreter in Javascript

By Joshua Bell | Applesoft BASIC Quick Reference | Notes | Known Issues | To Do | Links | History

Related projects: Logo in Javascript | Streaming video to an Apple II - vnIIc

Enter code below      



Notes

Known Issues

To Do

Links

History

2009-06-10:
Added Boy's Surface sample by Lukas Innig
2009-05-08:
Fixed running with cscript
Slight performance tweaks for IE c/o explicit sizing
2009-05-08:
Tracked down source of IE perf issues when drawing with paddles; when the thumb/stick moves, IE does a relayout/repaint of any content above the paddle in the HTML flow. If I delete the page header it's silky-smooth. Unfortunately, any text above the screen seems to make it fall off the deep end - so no fix yet without gutting the page.
Undid "Line breaks from PRINT now clear to the right edge" - doesn't repro on Apple. What was I thinking?
2009-05-06:
A bunch of performance tweaks based on IE8's JavaScript profiler. While they look good on paper, they mean diddly-squat to perceived performance. Don't precalc default variable values, avoid DOM changes that are no-ops, and (sigh) don't scan the whole screen looking for FLASH-styled cells - maintain a list instead so perf isn't impacted if there are none.
2009-05-01:
Expressions are now just-in-time compiled to JavaScript. Screen updates are the real bottleneck, though, so this isn't a big performance boost. Performance comparison (on my 1.73GHz machine) of the lores Mandelbrot set demo: So not a huge win except on faster execution engines. But this is just the first step...
Fixed POKE 216,x shim to disable ONERR handler
2009-04-30:
Rejiggered internal value storage/passing system to use fundamental JavaScript types instead of {number: value} or {string: value}. I didn't trust JavaScript's type system when I first wrote this code.
2009-04-26:
Performance - made GOTO/GOSUB not do a linear scan to find the line (d'oh). Significant perf boost for IE.
Added Unit Tests sample. Coverage is not complete but it's getting there.
RND() with negative now consistently reseeds (added custom pseudoranom number generator)
FOR I = 10 TO 1 : PRINT I : NEXT now correctly prints 10 then finishes (was previously incorrectly inferring STEP -1)
2009-04-25:
Line breaks from PRINT now clear to the right edge of the text window
Automatically show input devices if PDL() called
Added Zhodani Relay Station Placement example (run after generating a sector with Traveller Sector Generator)
2009-04-24:
Fixed a bug where changing text mode (e.g. PR#3) after calling HGR would break split-screen mode.
2009-04-14:
Updated to an IE8-compatible version of excanvas. Updated my excanvas patch to support scaling.
2009-04-05:
Allow DEF FN to be invalid (errors occur in FN, per Applesoft)
Fixed PR#0 in Safari
Added RENAME old,newto DOS
Fixed LIST for assignment statements with no LET
Fixed operator spacing for LIST
Fixed parsing of empty REM statements
Program would execute after a tokenization error was encountered - fixed.
Added Traveller Sector Generator sample
2009-03-07:
Fixed cursor blinking
Added Connections, Puzzler, and Squiggle by Gregg Buntin
2009-03-06:
Addressed IE performance issues: sped up Text and LoRes screen initialization, don't use classes for characters (sigh).
Fixed PRINT SPC()
2009-03-05:
PRINT CHR$(7) now rings a BELL (if your browser has an audio/wav WAV handler configured)
Reimplemented the text display (TTY) using bitmap font, to mimic the look of 40/80 column text (no more copy/paste, alas)
Added MouseText support. INVERSE:PRINT CHR$(27);"XY";CHR$(24):NORMAL
The ASCII Pac-Man sample was really Unicode Pac-Man, which the bitmap font doesn't support, so it broke. So I cheated.
2009-03-01:
Added Scribble sample, by William Simms
2009-02-12:
Added February Surprise sample by Antti Pirskanen
2008-11-08:
Ignore whitespace-only lines, as a convenience
Added ASCII PAC-MAN(ish) sample by Michael Kemp
2008-10-19:
Added TEXT ADVENTURE sample by Floyd McWilliams.
Allow string literals to be terminated by end-of-line (suggested by Mike Kienenberger for compatibility)
2008-09-18:
Fixed a case where syntax errors were ignored
2008-09-17:
Fixed input focus to work in Google Chrome
Fixed READ to support multiple variables, e.g. READ I,J,S$
2008-08-23:
Added Save/Load buttons that let you save your work to a cookie
Added DRAWING PROGRAM sample by Brian Broker
Fixed power operator (^) which wasn't being parsed correctly
Fixed subtle bug with string comparisons (result was double-typed as number and string)
2008-05-01:
Fixed NEXT I,J,... to terminate multiple loops - thanks to Scott Alfter for pointing this out
Bowing to popular demand, it now supports ? as an alias for PRINT
2008-03-15:
Implemented ONERR GOTO line and RESUME, including POKE 216,0
Added demo for ONERR, added ONERR support to sequential file access demo
Fix hires graphics on Safari - not sure when it broke
2008-03-14:
Code cleanup c/o jslint.com
Bug fix: INPUT A,B,C no longer worked. Probably mis-re-factored at some point.
2007-12-08:
Implement file writing (to client-side VFS only), including APPEND operations
Added DOS DELETE command
GR does implicit HTAB 1 : VTAB 24
PEEK(49168) has the same effect as POKE 49168,N
As a convenience, PEEK and POKE at 49200/-16336 (speaker toggle) now accepted, but a no-op
As a convenience, spaces now accepted before = forCOLOR= and HCOLOR=
2007-11-22:
Added button to submit your sample (via email) for inclusion
Added SIMPLE.PONG sample c/o USENET post by mad.scientist.jr
Improved comment handling (doesn't tokenize)
2007-10-22:
Make GET support keyboard flag, so IF PEEK(-16384) > 127 THEN GET A$ works
2007-10-20:
Bug fix: User could type after hitting Stop. Now TTY state is reset.
Added missing statement: ON expr GOSUB ...
RND(0) returns last, negative reseeds
2007-10-14:
Fixed location of paddle button 3 (C060)
2007-09-22:
Implemented scaling in ExplorerCanvas (source); hires now scaled somewhat correctly in IE
Bug fixes: HOME would force full-screen text; HPLOT can now plot a single pixel
2007-09-20:
Added hires support via canvas tag
Display switches (POKE 49232...49239, not counting page 2) supported.
Added text window support: POKE 32,left : POKE 33,width : POKE 34,top : POKE 35,bottom
2007-09-16:
Added full screen lores support via POKE 29234,0
Fixed keyboard input on Safari - hacky, but logical
2007-09-15:
Added Mandelbrot set demo to DEMOS
Added PEEK and POKE shims
Added paddle buttons: Home = 0 = Open Apple, End = 1 = Solid Apple, Page Up = 2, Page Down = 3
Added Caps Lock (defaults to on; real Caps Lock key toggles it; this means it usually ends up in an inverted state)
Round numerical results to 8 decimal places (hacky)
2007-09-10:
Added demo file links, cleaned up UI a bit.
Added hacky PR#0/PR#3 support (to set 40 columns)
2007-09-09:
Execute multiple steps before yielding. Increases perceived performance by about 10x.
Adjust lores colors per Linards Ticmanis on comp.sys.apple2.
Added Joystick, reorganized web pages
2007-09-04:
Added MON/NOMON support.
Fixed bugs with: READ into arrays, two argument MID$, e-format number parsing, DOS null command
2007-09-03:
Bugfixes: SPC() and TAB() followed by ; in PRINT statements. DOS parameter lists can include spaces.
2007-09-02:
Oops - FRE is a function not a statement. Fixed!
2007-09-01:
Implemented DATA/READ/RESTORE
2007-08-31:
Implemented DEF FN
2007-08-30:
Implemented DIM. File reads complete.
2007-08-27:
Added preliminary DOS implementation. Sequential access read only; there's a file called "JABBERWOCKY" to try.
2007-08-24:
Fixed bugs with string variables, key presses in IE, and HTML tweaks for better layout and lo-res sizing
2007-06-05:
Added paddle support (PDL)
2007-06-03:
Added lores graphics support (GR, PLOT, HLIN, VLIN, COLOR=, SCRN)
2007-05-01:
Extracted step mechanism from interpreter, so web page can introduce delays; no longer case-sensitive to keywords
2007-04-29:
Fixed command-line mode again
2007-04-27:
Added screen emulation (e.g. HOME, HTAB, VTAB) and input (e.g. GET)
2007-04-24:
Integrated into browser (display and event model)
2007-04-21:
Project started; interpreter functional via WSH on Windows