Hacker News new | ask | show | jobs
by plandis 1106 days ago
I’ve written a chip 8 emulator in both C and Rust and the Rust one is definitely more clear, and with destructured pattern matching you can really cleanly decode the opcodes in Rust: https://github.com/plan-x64/chip8/blob/master/chip8-core/src...

Normally I’d do something like a simple prefix lookup table with function pointers in C for this but chip8 opcodes require parsing the postfix to fully determine the operation (I.e. 8xy[0..e], where x and y are registers) which requires further parsing than a simple lookup table based on prefix.