What's new

Game Boy

Helius

Capsule Corp.
Very nice djh, keep us informed!

I didn't even try the bootrom myself. Not many people making Game Boy emulators these days.

I'm trying to port my emulator to Raspberry Pi so I will be monitoring the thread if I can be of any help. Feel free to ask.
 

hackiosa

New member
Hey guys!
I'm writing a GameBoy Emulator in .net, that will be open source. But I got the following problem.
I've already written the code for memory managment (including code for the most MBCs), for register managment, for mapping file ecettera.
But now I'm on adding all the about 400(?) opcodes, but I don't exactly know what the following opcodes do.

  • RL
    RLA
    RLC
    RLCA
    RLD
    RR
    RRA
    RRC
    RRCA
    RRD
Note: These are for the Z80 Cpu. I know , they got something to do with bit shifting.

Greetz hackiosa
 

Helius

Capsule Corp.
Those are rotations, you know, rotate left (RL), rotate right (RR)...

These two documents will help with the opcodes.

Good luck with your emu and keep us updated :)
 

Attachments

  • GBCribSheet000129.pdf
    728.5 KB · Views: 1,380
  • GB.pdf
    292 KB · Views: 422

Mepsi

New member
Hey, newbie to these forums here.

I am rather interested in making a GB emulator for myself, as far as my coding experience goes, I can program just not to a massively advanced level.
I had a go at doing a Chip8 emulator in C# using XNA last night and managed to complete it in about 12 hours and I must say it was the most fun I've had programming in a long time.

Anyway I'm trying to get my head around this GB emulation and I just cant get my head around it quite yet, one of the big things for me is how do I go about implementing the interrupts and timings properly, any help will be much appreciated, or any recomendations on easier emulators past the Chip8 I can work on first.
 

Helius

Capsule Corp.
Going from chip-8 to Game Boy is a massive step forward. Be prepared for 50x the complexity and size of chip-8.

Space Invaders is easier than Game Boy but not very rewarding as you will end up playing only one game :p

I recommend you not bothering with interrupts for now. Start by implementing all the opcodes and basic background rendering, this way you'll see your results pretty quickly and improve from there.

For the timing just execute the opcodes and save their cycle counts to a variable. Use that to update the graphics state accordingly.
 

Rüdiger

New member
After writing a chip8 emulator years ago, last weekend I decided to write one for the gb.
It took me several hours to find some really stupid mistakes (no, JP (HL) does not jump to the address stored at (HL), treated one unconditional jump as conditional...)
but after that blargg's test ROMs actually started testing something and on sunday most instructions passed.
DAA, DI, EI, HALT and STOP are still unimplemented,
ADD SP,r8 and LD HL,SP+r8 still fail the test, I suspect the flag calculations are wrong.

Now I will try to implement enough interrupts and hardware registers to get some graphics on the screen.
 

Rüdiger

New member
I added input, interrupts and crude graphic output. Nothing is really playable yet but some simple games already start up and run.
 

Attachments

  • 2013-06-26-234935_256x256_scrot.png
    2013-06-26-234935_256x256_scrot.png
    4.3 KB · Views: 158
  • 2013-06-26-223651_256x256_scrot.png
    2013-06-26-223651_256x256_scrot.png
    6.3 KB · Views: 124
  • 2013-06-27-001743_256x256_scrot.png
    2013-06-27-001743_256x256_scrot.png
    6.1 KB · Views: 126

Rüdiger

New member
It's written in C++ with some Python to generate the tables for instruction decoding.
I have exams approaching and my progress has therefore slowed down quite a bit.
I cleaned up the code and will try proper rendering as soon as I have more time...
 

djh

New member
Hi everyone,

I recently launched the alpha release of my GB emulator

One of the last items in my list is to get Sound working, but I'm currently struggling to understand where to even get started on this. I'm fine with graphics and everything else, but sound is like a completely alien topic.

Does anyone have any resources that might help?
 

djh

New member
btw I have a website/project page for my emulator but the forums won't let me post images or URLs as I'm a new member, but if you're interested my emulator can be found at djhworld [dot] github [dot] io [slash] gomeboycolor
 

Rüdiger

New member
I finally have some time to work on my emulator. Some demos are running near perfect but most commercial games show a garbled title screen at best...
 

Attachments

  • 2013-07-12-224547_160x144_scrot.png
    2013-07-12-224547_160x144_scrot.png
    4 KB · Views: 101
  • 2013-07-18-124904_160x144_scrot.png
    2013-07-18-124904_160x144_scrot.png
    3.6 KB · Views: 95

Helius

Capsule Corp.
Very nice!
What are the results of the cpu_instrs and instr_timing test roms?
You may find some clues in them.

Btw, I've just added boot rom support to my emulator :)
 

Rüdiger

New member
And I'm still alive, just very busy with other stuff.
I added a simple GUI and draw the tiles and BG map as seperate images for easier debugging.
I fixed some small bugs and most of the cpu code seems to run fine with only some incorrect flags in DAA and 1-2 other.
Next up would be a rework of the gpu which was more or less written to run one game and still misses lots of features.
 

Attachments

  • 2013-09-17-194306_619x268_scrot.png
    2013-09-17-194306_619x268_scrot.png
    85.2 KB · Views: 102
  • 2013-09-17-195341_204x262_scrot.png
    2013-09-17-195341_204x262_scrot.png
    6.1 KB · Views: 104
  • 2013-09-17-194904_204x262_scrot.png
    2013-09-17-194904_204x262_scrot.png
    7.6 KB · Views: 87

MrGame64

New member
The GPU (or more correctly PPU in this case) seems to be a tough nut to crack, when it comes to the GameBoy. As for the DAA I can PM you some code if you want :)

Hi everyone,

I recently launched the alpha release of my GB emulator

One of the last items in my list is to get Sound working, but I'm currently struggling to understand where to even get started on this. I'm fine with graphics and everything else, but sound is like a completely alien topic.

Does anyone have any resources that might help?

You might look at Blargg's Audio Libraries.
It may take some time to understand the code, but it's the best Gameboy audio emulator so far.
 
Last edited:

Sergio89

New member
Hello, Game Boy gurus.

I think this is the right place for the following post:

I'm currently working on a Game Boy/Game Boy Color emulator. More information can be found here: realboyemulator.wordpress.com

It is fairly stable (well, not so much for the Game Boy Color part), and it even passes the tests cpu_instrs, instr_timing and mem_timing. It also implements channels 1, 2 and 4, but I think I'm really missing something and I want to understand what it is. If you could test the emulator, you would notice that sound indeed is not very good.

I'll try now to describe where my doubts arises:

I use the SDL libraries, but this doesn't really matter. SDL creates a thread that calls a 'callback' function every time audio need updating. So, because sample sizes are 1470 (quite arbitrary) bytes, the function gets called 30 times per second when sampling at 44100hz. Right now, the 'callback' function just calls another function that fills the sound buffer according to the values in the sound registers.
Now, I have seen some implementations (VisualBoy's, for instance), and all of them seem to do some kind of synchronization that I can't figure out. For example, when writing to a sound register, a mutex is locked so the 'callback' function does not update sound state. Then, before actually writing the new value to the sound register, the update function is called (the same one that the 'callback' function calls to update sound state). But this time, the whole buffer (the 1470 bytes, for example) are not filled (maybe less samples are needed at that particular point); instead, a small portion is filled depending on the time that has passed since last update. Also, a variable of the likes of 'buffer_position' is used, so for the next update (either through the 'callback' function or the last-mentioned mechanism), the buffer starts filling at 'buffer_position' offset.

This synchronization mechanism is what I fail to understand. What could go wrong with my current implementation, which currently only updates the sound buffer when the 'callback' function is called, and not when a sound register is being updated?

Thanks a lot in advance.
 

Top