libretro / gambatte-libretro

Hard fork of Gambatte to the libretro API.
http://sourceforge.net/projects/gambatte/
GNU General Public License v2.0
105 stars 79 forks source link

Prepare for using gbc mode with gb games, fix register inaccuracy #73

Closed meepingsnesroms closed 7 years ago

meepingsnesroms commented 7 years ago

(the force gbc was disabled since it has unresolved issues)

ghost commented 7 years ago

Looks good to me, nice work! Really hope this gets merged soon. And I like the idea of finally having the choice of choosing between GB, GBC and GBA and not just Auto, GB and GBA.

sergiobenrocha2 commented 7 years ago

I'm forcing GB, the GB bootloader appears, and then I still can use GB colorization auto or internal, which makes senses only with GBC or GBA [& no bootloader].

Forcing GBC & using bootloader, it conflicts with GB Colorization and Internal Palette, dunno if it's by purpose (since you can change the palette in the bootloader now). Shouldn't GB Colorization be disabled when using bootloader?

Forcing GBC and Use official bootloader = OFF, gives you a buggy palette (picture below), and you are unable to use any GB Colorization setting.

pokemon - red version usa europe sgb enhanced -170212-201248

sergiobenrocha2 commented 7 years ago

Shouldn't Emulated hardware have an default 'auto' option? If .gb rom, loads as GB, if .gbc rom loads as GBC

meepingsnesroms commented 7 years ago

Forcing gbc and loading a gb rom without bootloader is not supported and never will be, the way I implemented the bootloader it actually boots the system, since the gb and gbc are not the same the gbc bootloader puts the gbc in gb emulation mode which just booting wont do, thus the corrupt palette.

Set to gb mode for gb games or install the bootloader. You can also try the sameboy bootloader if you want an open source one.

sergiobenrocha2 commented 7 years ago

Wait, are you expecting people using real bios now? So by default we'll have a 'broken' core?

meepingsnesroms commented 7 years ago

No,just set the switch to gb if you are playing a gb game, and if your not using a bootloader turn the Use official bootloader to off.

I made sure the best that I could that everything still worked the same when not using a bootloader.

ghost commented 7 years ago

@meepingsnesroms I don't think it's right to require the user to select the right core option for every game. For example, say your system/bios folder is the default ("content dir") and you previously played a GBC game with "emulated hardware" set to GBC. If you now want to play a GB game, and your GB folder doesn't have the GBC bios in it, then you get corrupted graphics and no bios screen at all.

meepingsnesroms commented 7 years ago

I can put back the auto option too then.

meepingsnesroms commented 7 years ago

Put the auto option is back and fixed some bugs.

sergiobenrocha2 commented 7 years ago

Ok, it's working with Auto now, but if you chose 'Emulated hardware' GBC it still get the buggy palette (with no bios in the system).

When people force GBC, they are expecting a fully Game Boy Color in their hands, which plays nicely both gbc and gb roms.

Please test all user cases, otherwise we'll get a ton of bug report here, reddit, forum...

ghost commented 7 years ago

Loaded save states now have an incorrect palette:

http://imgur.com/a/IKCVc

This does not happen in the current master branch.

And one time I also got a buffer overflow on startup:

https://www.hastebin.com/ukegilabug.pas

But could not reproduce it a second time. I'm not sure if this is a new bug or not.

sergiobenrocha2 commented 7 years ago

GB Colorization = internal Internal Palette = GBC - Blue Emulated hardware = GB Use official bootloader = ON, but no bios in my directory

pokemon - gold version usa europe sgb enhanced -170213-015240

Does this exist in real world?


Found another case:

GB Colorization = custom (with palettes/default.pal in System/BIOS) Internal Palette = GBC - Blue Emulated hardware = GBC Use official bootloader = ON, but no bios in my directory

It'll load the gbc game fine, then change GB Colorization to 'internal' or OFF while running, you'll get this:

pokemon - gold version usa europe sgb enhanced -170213-020752

You'll get it if you change initially from OFF to 'custom' too.

ghost commented 7 years ago

No,just set the switch to gb if you are playing a gb game, and if your not using a bootloader turn the Use official bootloader to off.

How hard will it be to pragmatically detect if the bios files are present or not, and then to optionally use the bioses if the files are present? How is this pull req done?

meepingsnesroms commented 7 years ago

I thought it was finished at the time but with the issues it's not even close.

meepingsnesroms commented 7 years ago

All mentioned bugs other than force gbc without a bootloader and palette swap in game have been fixed.

meepingsnesroms commented 7 years ago

The gb mode with blue palette does exist,it is a gb game that can use extended features if available. Heres a video of it on gb. https://www.youtube.com/watch?v=pWEemiNnhb4

As for custom palettes I did not mess with the palettes from file, they might be remapping the gbc colors too.

sergiobenrocha2 commented 7 years ago

Game Boy is monochromatic dude

There's no sense Gold using Blue palette

pokemon - gold version usa europe sgb enhanced -170213-155856

sergiobenrocha2 commented 7 years ago

Another user case:

Emulated hardware = GBA Use official bootloader = ON (with bios in the directory)

Load a gb game, you'll get this:

pokemon - red version usa europe sgb enhanced -170213-160422

Edit: Oh, actually you fixed that in last commit

meepingsnesroms commented 7 years ago

You can turn the blue palette off, but this game supports monochrome mode and if you have palettes enabled and force gb this will happen, its normal.(This is not a bug, it is your theme setting, change it to "Grayscale")

I fixed the gb games in gba mode in my last commit.

sergiobenrocha2 commented 7 years ago

I think you are not looking the big picture here. When you force either GB or GBC, people should expect gambatte working as a real GB or GBC as whole, i.e. it'll boot the proper bootloader AND will have the proper palette support.

This is a fix for palettes when forcing GB:

--- libretro.cpp    2017-02-13 17:45:10.332828759 -0200
+++ libretro.cpp_new    2017-02-13 17:44:08.355847000 -0200
@@ -555,6 +555,13 @@ static void check_variables(void)
    if (gb.isCgb())
       return;

+   struct retro_variable var2 = {0};
+   var2.key = "gambatte_gb_hwmode";
+
+   // there's no colorization in real GB, this avoids having a GBC game with GB palettes too
+   if (!environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var2) || !var2.value || strcmp(var2.value, "GB") == 0)
+      return;
+
    // else it is a GB-mono game -> set a color palette
    //bool gb_colorization_old = gb_colorization_enable;

Edit: ugh, this is not the best way to do this, user can change 'Emulated hardware' from GB to GBC while running the game, it'll get the weird palettes

meepingsnesroms commented 7 years ago

I could make it check if the wanted systems bootloader is present and if not ignore the "Force System" option and always use auto.

Also then I would separate GBA mode into its own switch.(Use GBA GBC mode:no|yes)

Is that what you want?

As for running like a real gameboy, it is, that is how it would boot if you where able to remove the bootloader from the cpu.

sergiobenrocha2 commented 7 years ago

I could make it check if the wanted systems bootloader is present and if not ignore the "Force System" option and always use auto.

No.

Also then I would separate GBA mode into its own switch.(Use GBA GBC mode:no|yes)

Also no, it'll get more complicate than which already is.

That gb palette in gbc games when forcing GB was an issue way before you messing with the code actually, sorry for the complains.

sergiobenrocha2 commented 7 years ago

The only remain issues by your side is this I think:

GB Colorization = any option Internal Palette = any Emulated hardware = GBC Use official bootloader = ON (with bios in the directory)

After loading the game, change the 'GB Colorization' to any option, even with you turning it back you'll get this:

pokemon - red version usa europe sgb enhanced -170213-190844

Changing 'Emulated hardware' while running will get this too, even turning it back to GBC


GB Colorization = any option Internal Palette = any Emulated hardware = GBC Use official bootloader = ON, but no bios in my directory

pokemon - red version usa europe sgb enhanced -170212-201248

I didn't get yet what's the point in adding a GBC force setting, when it's broken for gb games.

This should be working exactly like GBA mode, before this PR

meepingsnesroms commented 7 years ago

Ok I fixed that, it was still treating the palettes as gbc even when the bootloader had switched to gb mode.

sergiobenrocha2 commented 7 years ago

Nice, you fixed the first issue in the last comment, not the second. You really want to push LLE on us eh?

meepingsnesroms commented 7 years ago

No I am not trying to force it, I fixed and submitted the patch before you edited the post so I did not even see it, I will fix it when I get home though.

sergiobenrocha2 commented 7 years ago

Somehow, now you need to restart the game to get the changed value in 'Color Correction' updated when forcing GBC or GBA. It's working properly with Auto or GB. It was working properly forcing GBA before your first PR

meepingsnesroms commented 7 years ago

Does it work with GBC games in auto?

I intend to fix it, but I see no reason to turn that off because than the whole screen is just lightly tinted black.

EDIT:This is wrong,tinted black only happens on android on mac it just changes the hue, this is a major bug, it also existed before my changes.

sergiobenrocha2 commented 7 years ago

Does it work with GBC games in auto?

Yes

meepingsnesroms commented 7 years ago

Theres a bug in retroarch or this core somewhere, on android turning off color correction turns the screen black.(This is using a version before I made any changes) On mac it just changes the hue.

sergiobenrocha2 commented 7 years ago

Yeah, I notice that too.

Color correction is working properly now, but gb games have that weird green palette while forcing gbc

meepingsnesroms commented 7 years ago

The palette issues should be fixed, are there any others?

sergiobenrocha2 commented 7 years ago

Yes, seems everything is working fine now