jgilchrist/gbemu

How to understand the code and where to start?

shikhindahikar opened this issue · 4 comments

Hi @jgilchrist , I also want to make a Gameboy emulator on C/C++ and I have no idea how to approach the problem. I know I must read Gameboy manual and understand how it works but what do I do after that? I see that you have solved this problem, so will you please explain me how to get started with coding something for this project? Thanks in advance!

PS: I am going to code in Visual Studio 2017, on Windows 10.

Hi :-)
i was able to build the emulator following the instructions of the readme file. Just a question, the audio is available at the moment or it has to be add?
I ask you that because at the moment i have no audio output and I don't know if I am missing some dependencies or I need to put some specific option on the cli when I run the emulator. I tested it with super mario land
Thanks,

I am sorry but I have no idea how this works, I am kind of a beginner at open source. If you have successfully run the code can you please tell me with an example how do I use this command on Ubuntu terminal

gbemu [--debug] [--trace] [--silent] [--exit-on-infinite-jr] [--print-serial-output] <rom_file>

I have compiled using make command but I don't know how to use the above command to run the emulator.

Hi @shikhindahikar, thanks for checking out the project!

There are a lot of different ways you can start coding an emulator as there are a bunch of different subsystems that need to work together to get the game running. Personally I got started with the CPU - which in practice meant looking at the Gameboy's CPU architecture - pandocs has some information on this but there are some other great resources (like this site and this site, both of which have information about all of the opcodes that the CPU can execute). Then I moved onto other subsystems like video and memory management.

If you're new to emulators, I'd also recommend looking into the CHIP-8. It's a fantasy console which is significantly less complicated than the Gameboy and is a very popular choice as a first emulator project - it's easier to implement so it's a great way to get started and get an idea of what is involved. There are also some good tutorials on CHIP-8 emulators which might help you get started (this looks like a good one).

Regarding running gbemu once it's built, you'll need a ROM file for the game you want to play. Once you have the ROM file somewhere on your disk (let's say it's called the_rom.bin) you can run gbemu by executing ./build/gbemu the_rom.bin. All those other switches in the usage information allow you to customise the behaviour of the emulator - like --print-serial-output which writes out any bytes written to the Gameboy's serial port out to the console - but they aren't necessary to just run a game.

Hope this helps!

Thanks @jgilchrist I can now run the games! I will try making CHIP-8 for a start.