Emulating a BBC Microcomputer in Javascript
xania.org
xania.org
An exceptional game in 32kb. Would be interesting to see if they get as far as running Elite.
I do use dashboard (have my Selfoss RSS reader pinned to it) but only with my trackpad swipe-left :)
I found the hardest part of writing my own microcomputer emulator in javascript was keyboard mapping. Each browser does things in a somewhat different way, and then there is the inherent tradeoff between emulating the original keyboard layout faithfully vs using a logical layout (where pressing "=" on the PC keyboard results in a "=" event in the emulator).
As for the CPU emulation speed, indeed chrome doesn't optimize switch statements greater than 128 entries. I got around this by coding it as "if (opcode < 0x80) switch (opcode) { first 128 cases } else switch (opcode) { other 128 cases }
I had tried using a 256-way opcode dispatch table, which was great for chrome, but it hurt firefox performance (which is blazing with the 256-way switch). Having two 128-way switches was pretty good for both browsers.
From the awesome Fabrice Bellard (qemu etc...)
Edit: Formatting, additional details
Is this true? Anyone have some sense of why?
I recently saw this in Petka Antonov's "Optimization Killers"[1], though I've definitely seen it somewhere else as well, because I recall hearing that variables mixed with literals in a switch could trip up the optimizer.
[1] https://github.com/petkaantonov/bluebird/wiki/Optimization-k...
*CAT
at the prompt it will show an image listing. *Elite3
will run the game. Star is mapped to ' normally. It's quite sad that I typed the above commands correctly without thinking when I loaded the page :)