gpsp icon indicating copy to clipboard operation
gpsp copied to clipboard

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

Open Burlz10 opened this issue 2 years ago • 38 comments

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

Burlz10 avatar Sep 24 '23 06:09 Burlz10

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.

andymcca avatar Sep 24 '23 07:09 andymcca

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

Burlz10 avatar Sep 24 '23 07:09 Burlz10

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

Darkstalix avatar Sep 24 '23 08:09 Darkstalix

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

andymcca avatar Sep 24 '23 10:09 andymcca

@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

Darkstalix avatar Sep 24 '23 11:09 Darkstalix

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.

andymcca avatar Sep 24 '23 14:09 andymcca

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

Darkstalix avatar Sep 24 '23 16:09 Darkstalix

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

GS1

andymcca avatar Sep 25 '23 16:09 andymcca

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

GS2

andymcca avatar Sep 25 '23 16:09 andymcca

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 avatar Sep 25 '23 16:09 andymcca

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 avatar Sep 25 '23 16:09 andymcca

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

andymcca avatar Sep 25 '23 16:09 andymcca

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

Darkstalix avatar Sep 25 '23 17:09 Darkstalix

@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)

andymcca avatar Sep 25 '23 18:09 andymcca

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.

Burlz10 avatar Sep 26 '23 03:09 Burlz10

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 :)

davidgfnet avatar Oct 02 '23 17:10 davidgfnet

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!

andymcca avatar Oct 02 '23 20:10 andymcca

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 avatar Oct 02 '23 23:10 Burlz10

@Darkstalix did you experience this same issue as well?

Burlz10 avatar Oct 02 '23 23:10 Burlz10

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

Darkstalix avatar Oct 03 '23 16:10 Darkstalix

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.

DerinQyu avatar Oct 03 '23 19:10 DerinQyu

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

Darkstalix avatar Oct 03 '23 21:10 Darkstalix

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?

Burlz10 avatar Oct 04 '23 01:10 Burlz10

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.

DerinQyu avatar Oct 04 '23 01:10 DerinQyu

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

Darkstalix avatar Oct 04 '23 05:10 Darkstalix

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.

Burlz10 avatar Oct 04 '23 05:10 Burlz10

@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.

andymcca avatar Oct 04 '23 06:10 andymcca

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?

Darkstalix avatar Oct 04 '23 09:10 Darkstalix

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

andymcca avatar Oct 04 '23 11:10 andymcca

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

mitchchn avatar May 19 '24 18:05 mitchchn