1, 2, 3, 4, 5 ... 23  Next
Accurate Game Boy emulation 
Author Message

Joined: 2016-01-06 01:01
Posts: 67
 Accurate Game Boy emulation
Hello!
I came here to discuss a topic very dear to me: accurate Game Boy emulation. I'm not the first one to passionately pursue this topic, but I think I'm one of the few people who are still active.
Many things about Game Boy hardware are already known, and my research is preceded by a lot of hard work by other people. However, there's still a lot of room for additional research, and even the most accurate Game Boy emulators are far from perfect.
If you think you've seen a perfect Game Boy emulator, please see all the red X marks in my test ROM result table: https://github.com/Gekkio/mooneye-gb#mo ... ance-tests
Or alternatively show me an otherwise accurate emulator that can play Pinball Deluxe without hacks or workarounds.

To elaborate further, I'm here for two reasons:

1. I'm going to help byuu improve the Game Boy emulation accuracy in higan. We've already talked about this a bit, and I've explained some low-hanging fruits that will be fixed at some point.
However, I don't want to steal too much "byuu time" from other areas of higan and related projects ;)

2. I'd like to brainstorm some tough Game Boy hardware behaviour. I'm certain there's people on this forum with a huge amount of valuable knowledge about Nintendo systems, emulation, and hardware circuits.
As an example, my two current "worst case scenarios" are a model- and potentially unit-dependent bus conflict inside the CPU, and the effect of sprites and their locations on PPU mode 3 duration. No emulator I've tried so far passes my test ROMs.
The internal CPU bus conflict is probably worthless from an emulation point of view, but the PPU mode 3 duration can affect the timing of interrupts and VRAM/OAM inaccessibility and can therefore have a significant impact on emulator accuracy in practice.

My main focus has been and will be hardware research, my own emulator, and writing test ROMs. But I want to offer my knowledge and test results to others, and I like the accuracy focus of higan.
Big thanks to byuu for his interest in my research! The feeling of doing work that might be useful to someone else than myself is a very important motivator in difficult and tedious (but interesting!) projects such as this.


2016-01-07 16:31

Joined: 2014-09-27 09:44
Posts: 965
 Re: Accurate Game Boy emulation
Welcome.
Glad to see accuracy peeps coming here. I'm not much into portable gaming, but there are portable games I wanna play with emulation, so I'll still support your work.

_________________
"Even if b became the most amazing programming language the world has ever seen, I would not rewrite higan/icarus in it. I can 100% guarantee you of that." — byuu


2016-01-07 17:51
User avatar

Joined: 2014-09-27 09:27
Posts: 1212
 Re: Accurate Game Boy emulation
From what I've heard, improving the GB should be a lot easier than GBA, it's just a matter of doing it and finding the motivation. Good news if someone is willing to tackle this by writing a bunch of test roms a la endrift. There are a lot of games that could benefit as seen in my partial buglist.

_________________
GB/GBA Buglist for Higan 103r26


2016-01-07 18:50
User avatar

Joined: 2014-09-25 13:52
Posts: 8242
 Re: Accurate Game Boy emulation
Yay, this is totally awesome! Thanks for joining, and thanks for sharing your time :D

Now we have endrift for GBA, gekkio for GB, and Cydrak for NDS. All we need now is to get an NES grandmaster here :D

OS X port's pretty much fully functional again, just a few minor issues. I should be ready to go on GB improvements starting tomorrow.

_________________
What the hell's going on? Can someone tell me please?
Why I'm switching faster than the channels on TV.
I'm black, then I'm white. No, something isn't right.
My enemy's invisible, I don't know how to fight.


2016-01-07 21:58

Joined: 2014-09-27 09:44
Posts: 965
 Re: Accurate Game Boy emulation
If not Kevtris, I am in the mood of finally tackling some Famicom goodness, but I need to finish my exams first. :'(

_________________
"Even if b became the most amazing programming language the world has ever seen, I would not rewrite higan/icarus in it. I can 100% guarantee you of that." — byuu


2016-01-07 21:59

Joined: 2014-12-12 10:59
Posts: 176
 Re: Accurate Game Boy emulation
I've been idly thinking about adding GB support to mGBA, mostly as an exercise to add extensibility to mGBA's infrastructure, and actually ordered a GB flashcart yesterday for...well, similar reasons. I might be willing to help look into this, although if I do add GB support to mGBA, it won't be for a while. I need to release 0.4 first, of course.


2016-01-08 09:23
User avatar

Joined: 2014-09-25 13:52
Posts: 8242
 Re: Accurate Game Boy emulation
> I've been idly thinking about adding GB support to mGBA

That would be a lot of fun, and I know the GB<>GBA isn't as strong as SNES<>GB, but I'll warn you ... my second emulator started me down a wondrous journey that took many years. I started wanting to emulate more and more systems (very fun!!, but spreads your time thin), wanting to abstract all my emulator cores to a shared interface model, and wanting to rewrite my GUI to use said interface model to dynamically add/remove emulation cores at compile-time.

It's rewarding work, but it really restructures a huge amount of your project and adds an extra layer of abstraction that can at times be stifling.

The alternative, of course, is to have an entirely separate project. But you'll end up hating all the code duplication, and having to patch the same functions in two codebases all the time. For me, it'd suck all the fun out of it completely.

That said ... one important thing about Game Boys is that there are so many hardware revisions.

sinamas was (is?) primarily focused on the CGB family.
gekkio seems to be running the gauntlet, but I believe his primary interest is the classic DMG.
I'm trying to do CGB as well, but I am primarily interested in the SGB family.
It would be pretty cool, if you were willing, to have your primary focus be on the AGB/AGS modes of running DMG/CGB games.
That would pretty much only leave the MGB for want of a dedicated author.

Now obviously, we could all try and emulate every mode in each of our emulators and all of that.

Anyway, just an idea. We could all work together on all GB targets as well.

If you do start on GB, be sure to hit me up on IRC or whatever. I'd be happy to answer whatever questions I can to try and help you out. And fair warning, stay away from beware. When I was developing my emulator, he gave me extremely misleading and sometimes outright false information on all the questions I asked, which made development for me significantly harder until I caught on and stopped listening to him. Hanlon's Razor and all, I guess, but all the same, beware :P

_________________
What the hell's going on? Can someone tell me please?
Why I'm switching faster than the channels on TV.
I'm black, then I'm white. No, something isn't right.
My enemy's invisible, I don't know how to fight.


2016-01-08 18:19
User avatar

Joined: 2014-09-27 09:22
Posts: 609
Location: Salem, Oregon
 Re: Accurate Game Boy emulation
Always great to see more work and collaboration


2016-01-08 18:45

Joined: 2016-01-06 01:01
Posts: 67
 Re: Accurate Game Boy emulation
I appreciate all information and help, especially if it concerns devices or behaviour I haven't yet tested properly. Personally I think even overlapping effort is a good thing, because we can have independent confirmation about things.

Quote:
gekkio seems to be running the gauntlet, but I believe his primary interest is the classic DMG.


Yeah, I'm focusing on DMG, but mostly because it is the logical point where to start. My personal favourite and the device from childhood is actually an MGB I bought from Japan in 1997 :)
I do intend to emulate other devices as well, although I'm never going to focus on the SNES-side of SGB/SGB2 or the GBA-side of AGB/AGS.
Also, I'm at the moment choosing to ignore analog and non-deterministic effects, which can still be considered to be necessary for accurate emulation by some people.
I'm not currently interested in differences between mainboard versions (such as DMG-CPU-02 vs DMG-CPU-03), but only on CPU chip versions (such as DMG CPU A vs DMG CPU B).

If we look at the different Game Boy devices, my current knowledge indicates that we can divide them into two major groups. If you have any contradictory proof, I'd love to see it and be proven wrong :)

DMG: the original. CPU revisions A B C
MGB: same as DMG, but VRAM is integrated in the CPU, and boot ROM is different by one byte. Only one CPU revision
MGL: MGB with backlight. Same CPU as in MGB
SGB: DMG CPU with different boot ROM + SNES stuff (ICD2, SNES ROM, etc.). Only one CPU revision
SGB2: same as SGB, except has MGB CPU with different boot ROM, clock crystal, link port, different SNES ROM. Only one CPU revision

CGB: different behaviour between DMG mode and CGB mode, and DMG mode is different to DMG/MGB/SGB/SGB2. CPU revisions A B C D E
AGB: includes a CGB core with the same behaviour. CPU revisions A B
AGS: same as AGB (also, AGS-001 and AGS-101 are the same). I've seen revisions "CPU AGB B" (same as AGB) and "CPU AGB B E"

Now, if we dismiss all the differences intended by Nintendo (registers and FFxx hardware IO after boot), so far in my tests these devices group into just these two categories.
The only exception is the internal CPU conflict, but that might be unit-dependent, and overall might not we worth emulating.
It's entirely possible we'll still see many differences, but so far I haven't seen convincing evidence to the contrary.
I'm especially interested in finding a difference between CGB/AGB/AGS that is not related to sound, which is already different between CGB revisions.

Here's some sources for my information:
List of devices I personally own: https://github.com/Gekkio/mooneye-gb#accuracy
Nintendo devices in Console5 wiki: http://console5.com/wiki/Category:Nintendo
Thread at chipmusic.com: http://chipmusic.org/forums/topic/13583 ... revisions/


2016-01-08 20:09

Joined: 2014-12-12 10:59
Posts: 176
 Re: Accurate Game Boy emulation
byuu wrote:
> I've been idly thinking about adding GB support to mGBA

That would be a lot of fun, and I know the GB<>GBA isn't as strong as SNES<>GB, but I'll warn you ... my second emulator started me down a wondrous journey that took many years. I started wanting to emulate more and more systems (very fun!!, but spreads your time thin), wanting to abstract all my emulator cores to a shared interface model, and wanting to rewrite my GUI to use said interface model to dynamically add/remove emulation cores at compile-time.

It's rewarding work, but it really restructures a huge amount of your project and adds an extra layer of abstraction that can at times be stifling.


You say that as though I haven't been talking to Cydrak and Normmatt about maybe adding DS support at some point, too. Fwiw, a good chunk of it was already written to be modular, but it will be a LOT of work to get everything modular enough to stick it all together.

byuu wrote:
The alternative, of course, is to have an entirely separate project. But you'll end up hating all the code duplication, and having to patch the same functions in two codebases all the time. For me, it'd suck all the fun out of it completely.


Ick.

byuu wrote:
That said ... one important thing about Game Boys is that there are so many hardware revisions.

sinamas was (is?) primarily focused on the CGB family.
gekkio seems to be running the gauntlet, but I believe his primary interest is the classic DMG.
I'm trying to do CGB as well, but I am primarily interested in the SGB family.
It would be pretty cool, if you were willing, to have your primary focus be on the AGB/AGS modes of running DMG/CGB games.
That would pretty much only leave the MGB for want of a dedicated author.

Now obviously, we could all try and emulate every mode in each of our emulators and all of that.


Am I going to have to buy a DMG? I only have a CGB and AGB/AGS :(


2016-01-08 20:16
1, 2, 3, 4, 5 ... 23  Next