Forgotten values
Did you know about CHIP-8 architecture?
No? Really?
Well, it’s a quite old and simple 8-bit virtual machine. Who created it, how it evolved, why does it have such a strange resolution and input - all these questions are irrelevant at this point. What really matters is 2 facts that happened for whatever reasons they happened:
- CHIP-8 became the most portable emulator in history. I don’t know whether it was ported to MRE or MiniJ but the fact that I was able to run the ROMs in Rockbox installed to SanDisk Sansa Clip MP3 player is alone enough.
- CHIP-8 architecture itself is in the public domain. I mean, no one can come over and say “Hey, that’s mine, you can’t clone it!”. No one may possess the architecture but everyone can implement it. That’s what I believe how things should be for all system software. But we already know that idealism fails…
And still, even here there are some dumb snobs with their “It’s incorrect to call CHIP-8 an emulator, it’s nothing more than an interpreter”. Lolwut? First, CHIP-8 specs describe memory parameters and instruction set. It’s a complete virtual machine, not your average BASIC or other interpreted language stuff. The instruction set doesn’t even remotely look like an interpreted language to start with. Second, most 8-bit platform emulators are subset of interpreters of some sort. So being an emulator doesn’t deny being an interpreter in general. So calling any CHIP-8 implementation an interpreter but not and emulator is blatantly wrong.
Anyway, what’s so great about this VM? First, its simplicity. Code and data share the same memory. Each instruction is exactly 2 bytes long. And there are not many different instructions either (in fact, just 35 of them). Second, its gaming orientation: non-blocking input, sprite graphics and ability to detect collisions on the draw instruction level: when a sprite overlaps an already “white” pixel, then VF
register is set to 1, otherwise it’s set to 0. Simply ingenious. Now I see the true beauty of monochrome. And yes, having just 64x32 pixels of video memory makes it blazingly fast to render on modern systems (even Nokia 8110 4G, yep).
Of course, such an architecture has its own weaknesses that make it unattractive. For me, it’s sound system. Single-freq beeper? Really? So, I created a non-standard extension (SYS 666h
) in my DALE-8 emulator to address this. It allows you to alter the frequency and waveform by putting the parameter into VA
register. Higher 2 bits control the waveform, lower 6 bits control the note. Plain and simple.
Also, different implementations in the point of time had set different views on how shift instructions should be handled. I prefer more traditional one where if we set SHL V1,V2, then V1 is set to V2 << 1. However, lots of modern games somehow assume that V1 should be set to V1 >> 1, and V2 is not involved at all. That’s quite stupid but this mode had to be implemented in my emulator as well. To run a game in this mode, rename it from .ch8
suffix to .s.ch8
. Here, s
means shift quirk
. Yep, the academic emulator example already has to contain two different quirks! Luckily, the other one, load-store quirk, quickly got irrelevant.
I also created my own assembler for CHIP-8, called Hackwrench. What good are Chip and Dale without Gadget Hackwrench anyway? There still are some things to work upon, like labels, but this project is also close to be pretty much complete.
Overall, writing CHIP-8 and for CHIP-8 is fun, challenging and - what matters most - uniting. It brings the art of lo-fi demoscene to the most exotic platforms ever thought of. And that’s why it’s still alive and probably will outlast all the corporate bullshit being fed to us nowadays.