Arduboy JavaScript Simulator

I have quickly knocked up a JavaScript version of the Arduboy API using the canvas. I plan to make this work with C code rather than porting it but it still allows quick development of games until the devel unit arrives. Currently no audio or support for the ‘delay’ function but will be coming soon.


I think this is really great. I tried a little something as well in C++ – I haven’t tackled the input yet, I’ll post a github link if I finish. Another dilemma seems to be trying to wrap SPI.h or come up with something to replace EEPROM. Maybe SQLite?

Ideally it would be nice to just drop the possible Arduboy source code in the environment and not need to change the source file or header much. The approach I’m using now needs references to SPI and EEPROM cutout and a draw method changed to be virtual so it can be wrapped by a new class. So close, but not quite there.

@ekem It would be great to see a C++ version - it would perform much quicker. Just writing to a file would be a simple replacement for EEPROM rather than loading SQLite. I tried porting the breakout example too: copy into the Javascript editor. Unfortunately, there are no synchronous function calls like ‘delay’ in JavaScript so I would need to re-code it. The next step for the JavaScript simulator is to parse the c .ino files and translate the calls. And to add sound too.

@mrboggieman, yeah a flat file setup would probably be easier : ) I will look into that.

Also, when it comes to a delay in javascript, try:

var delay=1000; //1 seconds

  //your code to be executed after 1 seconds
}, delay);

And yeah for the most part, it would require a bunch of rewrites. One possibility is to create a javascript object and map the function calls from Arduboy.h to canvas calls. There are already functions like drawLines() in the canvas api. Here’s a the documentation.

Wow you guys are awesome. Keep up the good work and we will for sure host this on the website and give you props. Maybe even free dev kits. No promises. But seriously awesome work!!!

this is really cool!

If you decide to put the code on github I might try helping to improve it

Maybe with Emscripten we could compile games directly to javascript.

@fazo96 I have created a github repo at I have looked into using a real compiler and 8 bit cpu emulator to properly emulate the Arduboy. Although it is complicated and will result in the simulator running a lot slower, it would likely be the next step. I have also thought about just something like sweet.js to translate the c syntax to javascript instead of doing a full emulator.