Cool! I also wrote a Gameboy emulator in Go, but I never got to supporting audio or GBC. I wonder how much harder it is to do Gameboy Color once you've got decent Gameboy DMG emulation?
Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
21–30 of 34 posts
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#22At least the CPU is completely done.
I'll lurk his code :D
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#23As somebody not versed at all in the front end part of an emulator, what’s a good resource for learning how to put together something that will actually render frames? No preference on technologies here.
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#24Earlier quoted context omitted.
Start with Chip-8 or Space Invaders, both of which are substantially easier than the NES and Gameboy.
Took me a minute to realise you were talking about 8080 emulation - not Atari emulation: https://github.com/superzazu/invaders
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#25Everybody who's interested in multiple platform emulation with a nice UI should check OpenEmu: https://openemu.org/
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#26Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#27As someone who also wrote a GB emulator as a learning exercise, I found the sound code to be the worst part by far to write - getting sound timing right etc is very difficult (as the GB sound output changes instantly - it has no buffers etc)
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#28As somebody not versed at all in the front end part of an emulator, what’s a good resource for learning how to put together something that will actually render frames? No preference on technologies here.
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#29As somebody not versed at all in the front end part of an emulator, what’s a good resource for learning how to put together something that will actually render frames? No preference on technologies here.
Emulating the frame is also just part of the emulator. I.e. you got the display memory in some array (of pixel colors) in your code and the emulated instructions modify it. Then you just have to draw whatever is in that array on a "canvas" that your programming language supports.
Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go
#30Earlier quoted context omitted.
> I understand a lot of it is the process of translating machine code from, say, the GB processor to x86, but I’d love to learn more! You don't really need to translate to x86 per se. You can start off with an interpreter that takes in the 6502 or Z80 instructions (as represented by the binary data in the input ROM), then immediately perform operations based on those instructions. For example, if you're holding onto…
I have a question there. CPU instructions and what they do are highly documented and easy to replicate, but I'm guessing that timing is significantly less slo. How do you get that right?
The number of cycles per instructions can be either looked up from a table, hardwired into the emulation code, or if your emulated CPU is working on a "sub-instruction" granularity, the cycles per instructions "fall into place" automatically.
For instance if your host system's frame duration is 16.6ms (for a 60Hz framerate) and your emulated CPU needs to run at 1 MHz you compute the number of clock cycles as (1000000 / 60), that's about 16k cycles per second. Run the system emulation until the accumulated cycle count is >= that number each frame, and if you're emulation is fast enough you still have plenty of time left in the host system frame to render the emulator's video output, audio and an UI on top.