d67f3d8086
* Add tests for Applesoft compiler in preparation for refactoring While refactoring the compiler, I found several small bugs: * Lower-case letters in strings and REM statements were converted to upper-case. * Lines are stored in the order received, not sorted by line number. * Does not prefer `ATN` to `AT`. * Does not prefer `TO` to `AT`. * `DATA` statements don't preserve spaces. * `DATA` statements don't preserve lowercase. These will be fixed in the upcoming refactoring. * Refactor the Applesoft Compiler Before, the compiler had a few bugs that were not trivial to solve because the implementation was in one heavily-nested function. In this refactoring of the compiler, things like tokenization have been split into separate methods which makes them a bit easier to understand. This refactoring also passes all of the tests. * Set `PRGEND` when compiling to memory Before, `PRGEND` was not adjusted which made round-tripping from the Applesoft compiler to the decompiler not work. This change now updates `PRGEND` with the end-of-program + 2 bytes which seems to be the most frequent value that I have observed. * Fix two compiler bugs In debugging the decompiler, I noticed two bugs in the compiler: * The first character after a line number was skipped. * `?` was not accepted as a shortcut for `PRINT`. This change fixes these two problems and adds tests. * Ignore spaces more aggressively It turns out that Applesoft happily accepts 'T H E N' for `THEN` but the parser did not. This change fixes that and adds tests for some odd cases. Interestingly, this means that there are some valid statements that Applesoft can never parse correctly because it is greedy and ignores (most) spaces. For example, `NOT RACE` will always parse as `NOTRACE` even though `NOT RACE` is a valid expression. * Move tokens into a separate file Because the token lists are just maps in opposite directions, put them in the same file. In the future, maybe we can build one automatically. * Fix `apple2.ts` I had neglected to actually update `apple2.ts` to use the new compiler and decompiler. They now do. Also, the decompiler can be created from `Memory`. It assumes, though, that the zero page pointers to the start and end of the program are correct. * Address comments * No more `as const` for tokens. * Extracted zero page constants to their own file. Co-authored-by: Will Scullin <scullin@scullin.com> |
||
---|---|---|
.github/workflows | ||
asm | ||
bin | ||
css | ||
img | ||
js | ||
json/disks | ||
test | ||
types | ||
workers | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc.json | ||
.gitignore | ||
apple2js.html | ||
apple2jse.html | ||
babel.config.js | ||
index.html | ||
jest.config.js | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
README.md | ||
tsconfig.json | ||
webpack.config.js |
apple2js
What is this?
Apple ][js and Apple //jse are Apple ][ and Apple //e emulators written entirely in JavaScript and HTML5.
Things are still a little rough around the edges right now, hopefully I will have more time to clean things up.
First
npm install
To run a development server
npm start
The open either http://localhost:8080/apple2js.html or http://localhost:8080/apple2jse.html
To build a static distribution into dist
npm run build
To add additional disk images, use
./bin/dsk2json -c Category -n Name path/to/image.dsk > json/disks/image.json
then
./bin/index
Updates
2019-03-02
-
Behind the scenes
A lot of not so visible changes behind the scenes. The website now runs directly off of github, and has a more modern toolchain (Goodbye make, Perl and closure compiler, hello Webpack!) to facilitate development.
-
Performance
In particular, the screen no longer redraws as quickly as possible.
-
Drag and Drop
Disk images can be dragged into the window to load them.
-
Contributions
Thanks to Ian Flanigan for additions to improve ChromeBook behavior.
2017-10-08
-
Better iOS support
Bluetooth keyboards now work better. Reset is Ctrl-Shift-Delete. iOS now allows loading disks from iCloud and services like Drop Box. Saving locally is still not supported by iOS. I now understand why sound doesn't work, and I'm working on a work-around.
-
Source Maps
Although the source code has always been available, by default I serve up minified Javascript for performance reasons. But now you can poke around more easily.
Updates (2017-08-31)
(It's been a long time since I updated, so this is a rough list)
-
Videx Videoterm Emulation (][js)
PR#3 now does something on the Apple ][!.
-
AppleColor RGB Card Emulation (//jse)
Now supports a bunch of the mostly non-standard video formats found on the AppleColor RGB card, including 16 color text, 16 color hires mode, and mixed black and white and color double hires
-
Machine selection
You can now select between original, autostart and plus Apple ][s, and unenhanced and enhanced //es.
Updates (2013-07-04)
-
RAMFactor Emulation (//jse)
I now simulate having a 1 Megabyte RAMFactor card in slot 2.
-
Thunderclock Emulation
There is cursory emulation of the Thunderclock card, enough to keep ProDOS applications from asking you to enter the date all the time. ProDOS attempts to guess the year from the month, the day and the day of the week, something that needs to be patched every 6 years. This means newer versions think it's 1996, older versions are stuck in the 80s.
-
Firefox Nightly Joystick Support
Joystick support has yet to officially land, but the latest nightlies support the gamepad API.
Updates (2013-03-20)
-
Animation Frames
I've switched from using setInterval() to requestAnimationFrame() where supported. This, in conjunction with the graphics re-write, seems to smooth performance and provide a more stable CPU speed.
-
Graphics Re-Write
This (third) re-write of the graphics system should improve performance with graphics intensive programs. Rather than rendering each graphics update as it happens, updates are rendered each animation frame.
Updates (2013-03-12)
-
Apple //e
After much flailing, and much staring at MMU emulation code in despair, I've finally published my Apple //e emulator. It's probably a little more rough than I'd hoped, but it has a lot of features that I really wanted to get into it, like basic double hires support, and it uses the enhanced Apple //e ROMs.
Updates (2013-02-25)
-
Joystick Support
Chrome only so far, the nascent gamepad API has finally allowed me to add basic joystick support. I can now re-live my glory days of Skyfox.
-
Re-written CPU emulator
I finally got around to applying some of the many lessons I learned along the way writing my first CPU emulator in Javascript. The last re-working gave me about a 100% performance gain.
-
Finally Fixed Oregon Trail
This seems to have been a major disappointment for many people. I was able to make it as a banker, but I'm embarassed to reveal my score.
-
Competition
Now in addition to Gil Megidish's Apple2JS, there's a couple of new kids on the block, including David Caldwell's Apple II+ emulator where he's put a lot more thought into the graphics rendering than I have, and appletoo, which I just stumbled across while looking for David's emulator and haven't had much time to look at.
Requirements
-
A Browser with HTML5 Support
The most recent versions of Google Chrome, Safari, Firefox, and Opera all seem to work reasonably well these days,although variations in HTML5 support pop up, and occasionally a major release will move things around out from under me. IE prior to 9 lacks canvas tag support and is unsupported. IE 9+ renders nicely on a modern machine.
-
Basic Knowledge of the Apple ][
If you don't know how to use an Apple ][, this won't be much fun for you.
Acknowledgements
-
I'm using the following libraries:
- jQuery and jQuery UI
- Base64 Utilities via KvZ
- LED graphics from Modern Life.
- CFFA2 Firmware by Chris Schumann, Rich Dreher and Dave Lyons
-
I heavily referenced:
- Beneath Apple DOS by Don Worth and Pieter Lechner
- Inside the Apple //e by Gary B. Little
- DOS 3.3 Anatomy
- Apple II Disk Drive Article by Neil Parker
- 6502.org
- The comp.sys.apple2.programmer FAQ
- Understanding the Apple ][ and Understanding the Apple //e by Jim Sather.
- Apple II Colors by Robert Munafo.
-
And special thanks to:
- ADTPro for allowing me to pull some of my circa 1980 programming efforts off some ancient floppies.
- KEGS, because at some point I got so tired of futzing with ADC/SBC code I just ported the KEGS C code for those opcodes to Javascript so I could stop worrying about it.
- Apple II History, for a lovely, informative site.
- Gil Megidish, for the kick in the pants to finally post my version, once I realized there was, in fact, another apple2js in the world.
- AppleWin, whose source code is a goldmine of useful references.
- Zellyn Hunter and a2audit, for allowing me to get really nitpicky in my memory emulation.
-
Contributors
- Snapperfish Various fixes