libretro / gpsp

gpSP for libretro.
GNU General Public License v2.0
51 stars 51 forks source link

[Android] Golden Sun Carpet Glitch (background elements appearing in foreground issue) #227

Open Burlz10 opened 9 months ago

Burlz10 commented 9 months ago

On the ship to to Tolbi. Carpet appears in the foreground instead of background. See below pictures. Thank you. IMG_3193 IMG_3192

andymcca commented 9 months ago

Is this with latest build?

Similar issue in mgba from a few years ago - https://github.com/mgba-emu/mgba/issues/1444

The referenced commit was reverted a couple of weeks later, so it's a similar sprite rendering issue that exists in gpsp.

Please attach save file and instruction to reproduce.

Burlz10 commented 9 months ago

Correct. This was the latest build v0.91. I will create a save file for testing soon. IMG_3194

Darkstalix commented 9 months ago

This is also happening in GS 1 Mercury lighthouse area which i cant remember cause i replayed them this xmas and also this happens on GS 2 In mars Lighthouse ice shards/blocks. Mostly if i recall any object with transparency on it it would mostly come to foreground layer If saves and states needed i can provide since Mars lighthouse is endgame

qwewqewqe

andymcca commented 9 months ago

@Burlz10 @Darkstalix saves and states for both issues please!

Darkstalix commented 9 months ago

@Burlz10 @Darkstalix saves and states for both issues please!

There you go .state and .sav This is for Mars lighthouse issue thanks i appreciate

GOLDEN_SUN_B_AGFE00.zip

andymcca commented 9 months ago

These games do weird things with the OAM/BG ordering, and rely on the hardware to interpret in a certain way. So these are similar emulation bugs to the intro and dungeon ones recently fixed.

What's happening here is that a higher priority normal OBJ (but lower in the OAM priority order) consisting of a fully transparent colour should be blocking out the carpet entirely on the OBJ layers, allowing the 'lower priority' character sprite to be visible.

But gpsp sorts the OBJ/BG layers by relative priority first and then applies this order per scanline, so the above trick wont work. We could possibly get round this by forcing sprites higher in the OAM priority order to match the most recent OBJ priority, but this might break other games. So this one might need a bit of thought to fix.

Darkstalix commented 9 months ago

I understand and tbh if you feel like when fixing one thing that might break something else then it would be ok to leave it as it is, really. The huge issues i had last year were the sound channel missing which was fixed finally and made me really happy. Thanks for explaining us the issues

andymcca commented 9 months ago

Here's the mgba Frame Inspector for GS - here the frame is being rendered as it should be -

GS1

andymcca commented 9 months ago

If I disable Sprite 11 (Normal 64x64 OBJ with Colour 0), then we get the behaviour we see in gpsp

GS2

andymcca commented 9 months ago

The Carpet is part of BG1, which appears to be a lower priority than BG2 in this frame (maybe BG1 set as priority 2?)

GS3

andymcca commented 9 months ago

Sprite order - Sprite 11 is Priority 1, but all others (0 - 10) are set as Priority 3, despite being lower in the OAM order and thus should be higher priority

GS4

So Sprite 11 appears to 'Mask' the lower priority BGs from the OBJ layers (despite consisting wholly of a transparent colour), allowing the lower priority OBJs to become visible, regardless of their BG-relative priority setting

I think (David may correct me) that this is difficult to emulate in gpsp due to how we currently handle the rendering. By the time we come to render Sprite 11, we've already covered the character sprites with the carpet background. Would have to detect this specific scenario and then either a) retrieve the underlying OBJs to re-render them or b) re-order the affected pixels accordingly. Maybe there's a c)? I don't know!

andymcca commented 9 months ago

Nanoboy Advance also had this issue previously - https://github.com/nba-emu/NanoBoyAdvance/issues/99

Darkstalix commented 9 months ago

Thanks alot for even attempting on this! Takes a lot of time to work on these I rather keep the stability gpsp has now cause for me its the best, i dont know but for some reason gpsp is faster than mgba for me especially on these games. If you see both games side by side on these cores the gpsp has a tad faster render or how to call it which always made me loving it. Cast on both games at the same time Odyssey for example or even some spell giving attack on all 4 members On mgba its more like accurate but slower like the the og hardware On gpsp its faster and for fluent? i cant really explain but its waaaaay better

If you have to restart remaking the code for these small issues but break something else i would vote to keep it as it is Has David released the fix for the summon issues? the core says that its updated , or even pretend to update every time i try from retroarch with Online updater but the issue is still there.

Personally thanks everyone trying to fix these, appreciated

andymcca commented 9 months ago

@davidgfnet I found this explanation from fleroviux on the gbadev Discord -

The BG-priority of a given OBJ layer pixel is essentially the max of all OBJs that intersect with this pixel, regardless whether the intersecting pixel is transparent or opaque.

So a higher priority OBJ can elevate the priority of a lower priority OBJ without actually occluding it.

Golden Sun does that. It uses a completely transparent OBJ to elevate the priority of NPCs and the PC over a BG inside one specific rectangle (carpet)

Burlz10 commented 9 months ago

Thanks for looking into this. If it’s too complicated a fix then it’s fine as it is. But if there is something that can be done then of course it’s much appreciated. With regard to the summon issue, like darkstalix I attempted to update the core and see if the summon animation fixed. I experienced the same issue.

davidgfnet commented 9 months ago

Checking how other emus do this. They either render all pixels from the different pipelines and pick the top 2 ones (or one if no color effects are present) or they play with some funny front to back rendering (instead of back to front which is what gpsp does). It is indeed funny business, since the game uses the PPU in an unintended way, but GS is known for hackery :) Might take a while to get it fixed, since it's very low priority and requires some minor rewrites. Also unsure about the performance impact (should be ~0% if properly done though). Thanks for reporting this! Seems like all emus stumble on that one :)

andymcca commented 9 months ago

If you have to restart remaking the code for these small issues but break something else i would vote to keep it as it is Has David released the fix for the summon issues? the core says that its updated , or even pretend to update every time i try from retroarch with Online updater but the issue is still there.

@Darkstalix just FYI, the summon issue just got fixed today, should be in tomorrow's nightly!

Burlz10 commented 9 months ago

Hey I updated the core and it seems to have restarted all of my games and therefore replaced all of my autosave states when started. Am I able to load the original .sav files instead and then re-enable autosave state? If so could someone explain how to do do this? Sorry for the trouble and thanks for your work on this fix.

Edit: Looking at my save file location. New saves are being saved as .srm files instead of .sav like it was before, not sure if that helps identify the issue.

Burlz10 commented 9 months ago

@Darkstalix did you experience this same issue as well?

Darkstalix commented 9 months ago

Yes i just checked, it looks like the gpsp creates srm now. Was there an isue with sav files?

DerinQyu commented 9 months ago

Hey I updated the core and it seems to have restarted all of my games and therefore replaced all of my autosave states when started. Am I able to load the original .sav files instead and then re-enable autosave state? If so could someone explain how to do do this? Sorry for the trouble and thanks for your work on this fix.

Edit: Looking at my save file location. New saves are being saved as .srm files instead of .sav like it was before, not sure if that helps identify the issue.

Just rename your .sav to .srm it should work.

Darkstalix commented 9 months ago

Thats ok tbh if we have to go with srm from now on its ok, it doesnt matter. Im just wondering if it was on purpose or something happened by mistake on this hotfix of the core

Burlz10 commented 9 months ago

Also @davidgfnet or @andymcca while I can confirm that the summon animations for Golden Sun are fixed (thanks for this) with this new update. I’ve encountered a new issue. ALL RTC based games/events do not seem to work anymore. I tried running Pokemon unbound after converting my .SAV to .SRM and it produced an RTC error. In addition, I tried starting a new Pokemon Emerald save and after saving and restarting it produced the same RTC error. Is there an easy fix for this I’m missing or is this a bigger issue that I should file a ticket for?

@DerinQyu or @Darkstalix. Could one of you guys attempt to run a old or new Pokémon save and confirm I have this correct?

DerinQyu commented 9 months ago

Also @davidgfnet or @andymcca while I can confirm that the summon animations for Golden Sun are fixed (thanks for this) with this new update. I’ve encountered a new issue. ALL RTC based games/events do not seem to work anymore. I tried running Pokemon unbound after converting my .SAV to .SRM and it produced an RTC error. In addition, I tried starting a new Pokemon Emerald save and after saving and restarting it produced the same RTC error. Is there an easy fix for this I’m missing or is this a bigger issue that I should file a ticket for?

@DerinQyu or @Darkstalix. Could one of you guys attempt to run a old or new Pokémon save and confirm I have this correct?

Please open a new issue and post a log file. On my ps vita pokemon gaia save files are working fine no rtc error.

Darkstalix commented 9 months ago

I just tried Metroid zero mission and Fusion, pokemon fire red, all 3 castlevanias, FFV, and so far all worked. I tried a new Pokemon emerald save game. Saved, closed and restarted emulation and i didnt get any rtc error and loaded up ok. Pokemon Unbound is a hack but i didnt have an old save to try to load to get the error. Tho i tried it on the latest 2.1.1.1 with a new savegame and i didnt get the error. Make sure in the core options while IN game set the RTC to ON cause if you read the description of the setting it says that you might have to set it to on for hacks and non commercial files

Burlz10 commented 9 months ago

Apologies must be an issue with me then. I’ll try setting RTC from auto to on and play around with the Pokémon unbound and Pokémon emerald saves and see what happens.

Edit: Turning the RTC from auto to on wasn’t working. But I tried deleting the auto save and launching from the .SRM instead of resetting from the quick menu and there was no error anymore. Resetting from the auto save doesn’t prompt the error anymore. Not sure why it worked but hey it’s all good now. No ticket required. Thank you though.

andymcca commented 9 months ago

@Burlz10 good to hear the issue is resolved. To clarify, there used to be a a core option to choose between gpsp save method (sav) or libretro save (srm) method. Both files are the same but with different extensions (although RetroArch does allow you to compress save files too). The gpsp option was removed when implementing save overrides (for games that employ copy protection such as the Dragonball Z games) for the sake of simplicity.

With all the recent changes to the core, Save States have had to be changed also, meaning States from earlier versions of the core won't work now. So yes, please rely on actual game save files instead when upgrading to the latest version.

Darkstalix commented 9 months ago

Since i got a bit confused from the post and English is not my first language. Does that mean that we will use srm from now on gpsp core?

andymcca commented 9 months ago

Yes srm only from now on (no more sav files)

mitchchn commented 1 month ago

The issue is not Android-specific, reproed in gpSP 1.15 on Mac, Miyoo Mini Plus, and RG35XX-H. It also shows up in more places in Golden Sun, for example with these two NPCs in Xian:

Screenshot 2024-05-19 at 1 34 19 PM Screenshot 2024-05-19 at 1 35 05 PM

Here's a save state in Xian. Walk up to the waterfall and wait for the girl to pass in front of it to see the second example.

Golden Sun (USA, Europe).state.zip