mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.61k stars 769 forks source link

Clarification about Game Boy Palette #3246

Closed fekir closed 2 months ago

fekir commented 2 months ago

Some games boy games are forward compatible with the game boy color.

One of those is https://makrill.itch.io/death-planet (ROM can be downloaded without additional costs)

From the images (and video) on the page, the game uses some colors, but when starting the game with mgba, the game is only black-white.

I found out that I can get the same colors on the website (or at least very similar) if I set the preset to "GBC Dark Green -> A".

The main question is why this change is necessary? From what I've read, other games that are forward compatible/support colors or the super-game boy do not need any change in the configuration.

With other emulators that support GBC no change is necessary, and the colors are shown automatically.

Is there any chance that mgba could recognize that this game is forward compatible and execute it in GBC mode with colors?

CasualPokePlayer commented 2 months ago

This isn't "forward compatible" per se. The GBC palette you're seeing is just a default palette given to "Game Boy Only" games. It is not something directly controlled by the game per se (as the game cannot set the GBC palettes directly on account of it running in the backwards compatibility GB mode which locks out GBC specific functionality to the game), rather it is something set by the GBC bootrom normally (which default palette is used depends on the cartridge header, as some GB only games were given special default palettes, in this case it's just using the default palette most GB only games were given), and is something the user normally is able to override with button inputs when the bootrom is ran (one of which is actually the classic grayscale palette).

GB emulators for autodetection typically just emulate the game with actual GB emulation, which means just some standard grayscale or shades of green. If you force them to use GBC emulation (and use the GBC bootrom), or set a custom palette within emulator settings to match what the bootrom would set, then you could get colors.

fekir commented 2 months ago

Thank for the explanation.

With "forward compatible" I meant a GB game, able to take advantage of GBC features.

Like the games listed at https://github.com/mgba-emu/mgba/issues/2161

As far as I've understood, those are GB games, but when run on a GBC they are rendered with (their predefined) colors.

When forcing GBC emulation with the game "death star", the game is still rendered black and white. But I do not have the GBC bootrom, so that might be an issue (AFAIK no BIOS was necessary for mgba, I noticed only now the relevant settings in mgba)

endrift commented 2 months ago

The "predefined" colors are defined by the GBC boot ROM, not the GB game, and it's effectively a loose list of existing games. If it's not one of those games, the boot ROM picks a palette based on...factors I don't quite know. The former is what that setting emulates. The latter is not emulated but the list of palettes included is what that list you've selected from is.

fekir commented 2 months ago

Thank you for the clarification.

Would it make sense to expand this loose list (if mgba has one) to include single games like death-planet?

fekir commented 2 months ago

I found this table

https://tcrf.net/Notes:Game_Boy_Color_Bootstrap_ROM

with following note

Notice that entry 0x1C, flags 0x03, hash 0x00 is actually a dummy entry, used for all games that are not found in the hash table or don't have a Nintendo Licensee code.

And the entry 0x1C, flags 0x03, hash 0x00 looks a lot like the color palette "GBC Dark Green -> A"

endrift commented 2 months ago

Thank you for the clarification.

Would it make sense to expand this loose list (if mgba has one) to include single games like death-planet?

Not really. The point is compatibility with the existing GBC list. If all GB games that aren't in that list show up with the default GBC palette, that would cause some significant confusion among users wondering why it's not using their selected palette.

Also, adding homebrew games is definitely not a thing I'm interested in, since that's a dynamic list that could change on a whim.

fekir commented 2 months ago

Shouldn't according to the list I've found the game appear with the colored palette by default on a real game boy color?

endrift commented 2 months ago

That would apply to all GB games if you have that setting on, which is not desirable, considering there's a separate palette setting for this.

fekir commented 2 months ago

Hello @endrift

why do you say it is not desirable if it is the behavior of the emulated platform? Because mgba also emulates the GB (non-color)?

It's because

If all GB games that aren't in that list show up with the default GBC palette, that would cause some significant confusion among users wondering why it's not using their selected palette.

But in that case, it would make sense that if someone chooses an alternate palette, this overrides the one selected from the list.

Also, adding homebrew games is definitely not a thing I'm interested in, since that's a dynamic list that could change on a whim.

Yes, scrap that idea, it was before I found out that the game should work automatically with colors on a real GBC.

That would apply to all GB games if you have that setting on, which is not desirable, considering there's a separate palette setting for this.

But also the other settings apply to all games, and does a worse job. If I set "GBC Dark Green -> A", it would also apply to games that look terrible with that palette. Implementing the list at https://tcrf.net/Notes:Game_Boy_Color_Bootstrap_ROM, or having the option "use default gbc palette algorithm" would provide a better default behavior if one wants to enable colors by default.

endrift commented 2 months ago

Hello @endrift

why do you say it is not desirable if it is the behavior of the emulated platform? Because mgba also emulates the GB (non-color)?

Yes, and

It's because

If all GB games that aren't in that list show up with the default GBC palette, that would cause some significant confusion among users wondering why it's not using their selected palette.

But in that case, it would make sense that if someone chooses an alternate palette, this overrides the one selected from the list.

What? Why would this override that custom palette? That would make custom palettes do nothing, because they would always be overridden. When the setting is on, the set of all games that would use the selected palette and the set of all games that would use the Dark Green palette is the exact same set, definitionally. If you want to use the Dark Green palette, set the Dark Green palette as what you're using. It's that simple.

Also, adding homebrew games is definitely not a thing I'm interested in, since that's a dynamic list that could change on a whim.

Yes, scrap that idea, it was before I found out that the game should work automatically with colors on a real GBC.

That would apply to all GB games if you have that setting on, which is not desirable, considering there's a separate palette setting for this.

But also the other settings apply to all games, and does a worse job. If I set "GBC Dark Green -> A", it would also apply to games that look terrible with that palette. Implementing the list at https://tcrf.net/Notes:Game_Boy_Color_Bootstrap_ROM, or having the option "use default gbc palette algorithm" would provide a better default behavior if one wants to enable colors by default.

The list on that page is the exact same "loose list" that I described earlier. That's exactly what that setting does; it just uses that algorithm, and I called it a loose list because it can hit things that aren't in the list, but usually doesn't.

I'm really not sure what you think is going on here, since what you've just described is either mutually exclusive with what's being done on all cases where applicable or exactly the same as what's being done in other circumstances.

There's nothing to be done.

fekir commented 2 months ago

Ok, I might not doing a good job at expressing my intent

What I want to achieve is the following.

Use the gbc emulator for gb games, and apply following list for the colors: https://tcrf.net/Notes:Game_Boy_Color_Bootstrap_ROM, including "entry 0x1C, flags 0x03, hash 0x00".

Thus under settings, I set Models to CGB for GB and CGB games, and in Game Palette, how should I configure mgba?

I do not want to apply the "GBC Dark Green -> A", for example to Pokemon Red ("entry 0x10, flags 0x01, flags 0x14"), but it is what happens when clicking on "ok" or "apply".