5 ms·
I'm in the process of doing the same thing. Instead of using Rust I'm going to try to use Go. Would you mind sharing any resources that you found to help write
by bpowell 12y ago
I'm in the process of doing the same thing. Instead of using Rust I'm going to try to use Go. Would you mind sharing any resources that you found to help write the emulator?
- drbawb 12y agoSure! This walkthrough[1] writing a Gameboy emulator in Javascript was very helpful in seeing how an emulator should be structured. -- Though the full source is available: the actual tutorial is more of a guideline that introduces you to the hardware and structure of the emulator. It often shows code-snippets instead of working code. The Gameboy CPU Manual[2] and OP code chart[3] have been invaluable tools. In my experience: I spent most of my time flipping between the opcode chart and my CPU implementation. As a tip: lots of the CPU instructions do the same thing w/ different register pairs. There is huge potential for code reuse here. In Rust I achieved it with macros, though. Lastly: the "Pan Docs"[4] are more or less the same thing as the CPU Manual, but in a slightly more readable format. Also there[5] are some test ROMs[6] that you can use for debugging. I'm trying to find a good way to verify their results using Rust's unit testing. `opus5.gb`[6] is a nice way to test the graphics subsystem; it's also a good "first ROM" to run because it has no additional ROM or RAM in the cartridge. In other-words: you don't need to implement the memory bank controllers to get it working. --- And a little bit of friendly advice: _always_ keep debugging in the back of your mind. I usually resort to "printf debugging" but that really doesn't work inside a loop that's supposed to be ticking at 4.19MHz! :) I accidentally filled up my disk once already; I forgot I had redirected STDERR to a file and it was pretty-printing registers after every tick. Yikes! Good luck! It really is a fun little machine. [1]: http://imrannazar.com/GameBoy-Emulation-in-JavaScript http://imrannazar.com/GameBoy-Emulation-in-JavaScript [2]: http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf [3]: http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html [4]: http://problemkaputt.de/pandocs.htm http://problemkaputt.de/pandocs.htm [5]: http://gbdev.gg8.se/wiki/articles/Test_ROMs http://gbdev.gg8.se/wiki/articles/Test_ROMs [6]: https://www.google.com/#q=opus5.gb https://www.google.com/#q=opus5.gb
- bpowell 12y agoI have been reading through the emulator in Javascript walkthrough. It does a good job at explaining the basics. I'm not very far into development, still trying to understand the basics of the CPU. The manual and opcode chart you posted will help out a lot with that. Thanks for the tip about the CPU instructions. I did notice that, but when looking through the Javascript code there was a one to one relationship with opcodes to instructions. Wasn't sure why the person went that way, maybe because it was easier? Either way I will keep that in mind and try to do code reuse! Test ROMs are amazing! I have been playing around with a few ROMs I have and they all seem very complicated. This should make it easier to determine if I'm on the right track or not. With the little code I have written, 90% of it is Printf to the screen to see what is going on :). I do want to share with you this other tutorial that I found [1]. It is similar to the Javascript one, but it goes into way more detail on some parts. Thanks very much for all the help! I have a lot of reading to do this weekend! [1]: https://realboyemulator.wordpress.com/2013/01/01/the-nintendo-game-boy-1/ https://realboyemulator.wordpress.com/2013/01/01/the-nintend...
- drbawb 12y agoSeeing the Pokemon boot screen reminded me, I forgot the project which made me start down this road. I don't know if you've seen gomeboy-color[1]? It's an emulator written in Go. The picture of Pokemon Yellow on their homepage is what made me decide I wanted to emulate the Gameboy and not the NES. It also inspired me to build an interactive debugger that understands the Gameboy memory map. It's _pretty sweet_ when you can dump the 32x32 tile-map as a nice grid of tile offsets. [1]: http://djhworld.github.io/gomeboycolor/ http://djhworld.github.io/gomeboycolor/