I have some free time this weekend...I might take this repo and port it over to clojure to get the hang of things.
I have some free time this weekend...I might take this repo and port it over to clojure to get the hang of things.
Yeah everyone will comment after me that x86 gets way more complex over time but if you just want to get a quick intro and you aren't a perfectionist x86 is kind of compelling.
And recently I wanted to try emulating MSP341 at someone's recommendation because it has a very simple architecture. But just getting a C compiler for it isn't easy! When I've tried to cross-compile C to other archs like RISC-V it also wasn't straightforward and I just got stuck in this toolchain spot.
If it were easier to cross-compile simple languages like C then writing emulators for other environments would be easier.
If you're on a new Mac, my whole argument applies for aarch64 instead of x86.
But I'm not arguing everyone must do it. Just trying to share why one unintuitive approach (the "complex" x86 architecture) might actually be easier and cooler than you think.
https://notes.eatonphil.com/emulating-amd64-starting-with-el...
I don't think 808x is such an unpopular machine for approaching emulation.
Some people use Space invaders (or contemporary titles), which is based on an 8080, as stepping stone between CHIP-8 and more modern (complex) platforms.
https://multigesture.net/articles/how-to-write-an-emulator-c...
My only qarning is that there are a lot of edge cases in the specification--and the proper specs are wrong.
I ended up spending most of the time searching through undocumented/missing CPU specifications. It became rather tedious.
For a learning project, this made it poorly suited. There are so many good emulators out there, the only reason to write one is for the learning experience. I just felt that I stopped oearning after a while and was just debugging obscure combinations of cpu states.
Still, the reason I want to do it online is specifically because I want an excuse to really understand low-level hardware. I (and probably a majority of people on HN who do software) really only have "real" experience with "Java or Higher" with maybe hitting C if I have the rare occasion of having to worry about saving a few milliseconds. An emulator would force me understand low level hardware, or at least I think it would.
Also, read the book Code by Charles Petzold.
I wrote a Gameboy Color emulator[1] earlier this year, but stopped as soon as I realized that I wasn't learning anything new. As a result, my emulator has a few issues and does not support sound, but it is able to run quite a few games. I also got it running in a browser via WASM, which was fun.
https://wiki.xxiivv.com/site/uxn.html
There is also the LC3 virtual virtual machine, with a fairly great guide on creating it. https://justinmeiners.github.io/lc3-vm/If you look at the examples, you'll find that writing a Chip8 emulator with JimTCL it's a breeze.
Anyhow, I found the CPU part a lot of fun, and there's public domain test roms with expected registers after each instruction that you can use to test and confirm. Interaction with other hardware and emulation of that hardware gets a lot more challenging. The gameboy is certainly different than the NES, but I suspect there's a lot of similarity at the high level. It's certainly reasonable to stop (or pause, perhaps), when it stops being so fun, too.
I'm also not sure porting an emulator is going to give you the same understanding as writing one, but maybe.
Getting the graphics and sound in sync with the CPU is a lot more challenging if you're looking to support many games, but if you just want to play some of the super simple early NES games, like Donkey Kong, then you can get away with a lot of inaccuracies.
I wrote my first emulator a while ago, for the Gigatron. People recommend CHIP-8 a lot but I just thought it looked too trivial and uninteresting. The Gigatron is still incredibly simple, but it's also a really elegant little beast worth studying for its own sake.