Hello,
It looks as if many people who work through book or Coursera course put a lot of effort into their Chapter 9 projects. I know I did. I thought it'd be nice to be able to share Jack programs we've written directly on the web without requiring viewers to download the SDK. With that in mind, I've been working a Jack virtual machine that runs on the web.
Here are two demo of the Jack VM running the
pong game, and the
Space Invaders clone I created for my chapter 9 project.
Screenshot:
The VM has a couple of features so far:
- It runs .vm files from the SDK's Jack compiler (with or without OS files bundled).
- It supports all instructions, keyboard and screen I/O.
- On larger screens, it displays the screen at 2x resolution.
- The majority of it's implemented in WebAssembly, so it should have good support for desktop browsers.
Because this project targets the web, there are some neat possibilities with this:
- We could include Jack programs in any webpage with a 1-line include + some simple JavaScript for configuration.
- Instructors could make interactive slides by combing it this with something like reveal.js
- An interactive gallery of working Jack programs rather than static screenshots.
- Some day, maybe even a full-fleged Nand2Tetris "IDE" like the Web Assembly studio
https://webassembly.studio.
What's Next?
- Tweak the VM execution speed so that it runs reasonably consistently across computers.
- Package up the player so that it can be included on any webpage with one line of JavaScript.
- Add an integrated Jack compiler so the player can load Jack programs from an HTML textarea.
The source is available on
GitHub if you're curious. The source is a bit of a mess, but the test suite is pretty thorough. I'll be cleaning the code and organization up as I implement the next set of features.
Hope you like it!
Jim