|
|
|
|
|
by fspear
2001 days ago
|
|
I would add an emulator to the list.I've always struggled to figure out how these are built from scratch. A long time ago I wanted to code a neogeo emulator but gave up before I even started, I didn't have a clue where to begin. I am amazed at anyone that can code an emulator from scratch. |
|
it mostly boils down to keeping a bunch of registers and a giant switch statement. Each case simply implements the opcode. You have an array of bytes for the memory, and some emulated devices (e.g. trigger a screen update when the framebuffer memory gets changed, or set the instruction pointer to a handler when a key gets pressed.)
It gets hard when instructions need lots of decoding, or you have 3d graphics hardware to emulate, or if you have something like a BIOS, or if you want to JIT.
I'm actually eyeing implementing a console on an FPGA as my holiday project, with something like Chisel.