Hack Computer Simulator inside Browser! [OpenSource]

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Hack Computer Simulator inside Browser! [OpenSource]

magiwanders
Hello everyone,

as a weekend project while learning javascript I created a barebones Hack Computer Simulator that runs in a browser. You can find it here, there is also a brief tutorial. I hope you like it!

Here are some details:
 - Runs .hack files directly out of your assembler.
 - Comes with Pong preloaded! Just click START!
 - Control over how many cpu cycles per frame to execute, and how many frames per second.
 - Keyboard is routed to the KBD register at any moment.
 - RAM registers can be manually written before running a program.
 - Personalized screen colors.
 - Brief tutorial.
 - More coming!
 - This is *not* a VM simulator, this is a hard and pure hack computer simulator: it accepts only .hack files and files longer than the ROM will just not work! Also this is implemented in Javascript so it provides noticeably better performance than the java CPUEmulator, but not webassembly better!

SCREENSHOT



Last but not least, visit github if you want to see the code or even contribute! The code is a mess but improving... next weekend.

I hope you like it

Magi
Reply | Threaded
Open this post in threaded view
|

Re: Hack Computer Simulator inside Browser! [OpenSource]

WBahn
Administrator
Nice. A few other folks have done similar things, so you might look for their threads and see if they are doing something that might give you ideas on how to extend what you've got or maybe ways to improve what you've already got.
Reply | Threaded
Open this post in threaded view
|

Re: Hack Computer Simulator inside Browser! [OpenSource]

magiwanders
I have seen a tendency to run code in the VM emulator because it does not have a limit of  code lines. And the other simulators I have seen as well are VM simulators. On way to expand this project requires an optimized VM translator, which not many (and not me for now) have done! But yes, I will slowly start to explore the forum, I just signed up
Reply | Threaded
Open this post in threaded view
|

Re: Hack Computer Simulator inside Browser! [OpenSource]

WBahn
Administrator
It's very hard to make a VM emulator aware of code size limitations precisely because it IS emulating a machine that doesn't exist. Furthermore, any code size limitation would apply to the machine that is being emulated, which is NOT the Hack CPU.

But I agree that people tend to ignore the reality of the Hack's ROM space limits (and potentially the stack and heap space limits, as well, though I think the supplied emulator might be aware of those -- which arguably it shouldn't be as those are not part of the VM definition, but rather the mapping onto the Hack CPU, which is a separate issue).

A problem with trying to address this with an "optimized" VM translator is that the end result only applies to that particular optimized translator. Code that won't fit using that translate might using a different one and vice-versa. There's no such thing as a perfectly optimized translator.
Reply | Threaded
Open this post in threaded view
|

Re: Hack Computer Simulator inside Browser! [OpenSource]

Lozminda
In reply to this post by magiwanders
That is very cool and not just a tiny bit sneaky !

Awesome