Live data from Hacker News

Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

github.com

11–20 of 34 posts

Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

#12
post #10
post #7

I’ve often thought of writing my own emulator for the NES or GB/GBC to learn a little about how emulation works on a more fundamental level. 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!

> 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?

Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

#13
post #10

Earlier 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?

Timings are usually documented as well, usually at the clock cycle level.

Beyond that, you have to worry about hardware peculiarities that happen to affect maybe a few games, and at that point, you might start reverse engineering the behavior of those games!

Take a look at this article talking about exactly those thinking issues: https://www.tested.com/tech/gaming/2712-why-perfect-hardware...

Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

#14
post #7

I’ve often thought of writing my own emulator for the NES or GB/GBC to learn a little about how emulation works on a more fundamental level. 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!

https://www.reddit.com/r/emudev/ is a helpful resource.

Most people suggest working on a "toy" system, such as Chip-8 first. It is a mythical processor, rather than based upon real hardware. That said there are only a handful of opcodes to implement, and it does support graphics.

https://en.wikipedia.org/wiki/CHIP-8

There are ROMs out there for pong / space-invaders / etc, so you can play real games pretty quickly.

Of course there is nothing stopping you jumping straight into NES/GB/whatever. NES is easy to get started with, the others less so because of bank-switching, etc. But if you're patient you can manage it :)

Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

#15
post #3

How would someone begin to work on something like this?

http://emulator101.com/ is a good resource, as is https://www.reddit.com/r/emudev/.

Or you can just cheat, design a "toy" instruction set, and write something to process it. A couple of years ago I did that, in C/Perl:

* https://github.com/skx/simple.vm

Later I rewrote the interpreter/emulator in go:

* https://github.com/skx/go.vm

The downside with my approach here is that I ignored graphcs, sound, & I/O.

These days I'd recommend you write an emulator for the Chip-8 system..

Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

#19
post #7

I’ve often thought of writing my own emulator for the NES or GB/GBC to learn a little about how emulation works on a more fundamental level. 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!

There are some fantastic resources out there which detail basically every part of the GameBoy from processor to graphics.

For me the GB was a great entry point in learning about emulators as is is fairly simple compared with some other consoles. Even if you're not going to make an emulator some of them are still great reads - I've put a few resources I used on the GoBoy page: https://github.com/Humpheh/goboy#resources

Re: Goboy: Multi-Platform Nintendo Game Boy Color Emulator Written in Go

#20
post #4

Earlier quoted context omitted.

My recommendation is to start with the CPU emulation. The CPU in the Gameboy has decent documentation and there are plenty of implementations to look at if you're stumped. (One I like particular is the core in Higan, a multisystem emulator written in C++.)

I remember seeing some people recommend starting with the NES rather than the Gameboy - any ideas on this?

Gameboy is actually a bit friendlier than the NES to get started with, because of the low number of mappers (programmable chips in the cartridges to do tricks with addressing, NES had much greater need for these than the GB due to the dearth of tile RAM). But Sega Master System is even friendlier, I hear.
Post reply on HN