Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golden Sun sprite priority #38

Closed
paulb-nl opened this issue Jan 1, 2020 · 8 comments
Closed

Golden Sun sprite priority #38

paulb-nl opened this issue Jan 1, 2020 · 8 comments

Comments

@paulb-nl
Copy link
Contributor

paulb-nl commented Jan 1, 2020

Reported here with the Japanese version: http://www.atari-forum.com/viewtopic.php?p=389976#p389976

Save file

l3RYygl
JQVNHRU

This is some interesting behavior. The ice is BG1/2 with priority 2 and the player sprite is sprite 0 with priority 3.

However when the player should be on top of the ice then the game places normal sprites with transparent tiles with priority 2 on top of sprite 0 at sprite 2/3. This changes the priority of sprite 0 to priority 2.

I have (poorly) hacked bld_demo.gba with a hex editor to do the same thing and tested it on GBA hardware and got the same behavior.

Note that this also changes the Semi-Transparent pixels to normal pixels because the blending on the sprite in bld_demo.gba does not happen anymore when Special effects are disabled. mGBA almost has the correct behavior except for this part.

So in summary when a sprite overlaps a sprite with lower priority then the GBA overwrites the priority and Semi-Transparent bit but not the pixels if they are transparent.

@RobertPeip
Copy link
Member

That's really interesting behavior. To do that, we would need to seperate the color data from the priority/alpha data for the sprite drawing and save them seperatly until mixing.

@RobertPeip
Copy link
Member

I did a quick shot with my emulator: if i allow updating prio and alpha even when the pixel is transparent, it works with the ice. I could implement that in the FPGA, too. However i'm not sure if it will break anything....

@RobertPeip
Copy link
Member

RobertPeip commented Jan 1, 2020

Paul, are you going it fix it or should i take a look? Just in case we don't do double work.
Thanks again for the in depth analysis, great work!

@paulb-nl
Copy link
Contributor Author

paulb-nl commented Jan 1, 2020

I am not working on it currently so you can go ahead!

@RobertPeip
Copy link
Member

fixed

@paulb-nl
Copy link
Contributor Author

paulb-nl commented Jan 7, 2020

Nice work Robert! I have done some testing and everything seems to be working fine.

The Tonc prio_demo.gba is also affected by this and is now identical to GBA hardware when sprite sorting is disabled by pressing select. Some red sprites are pulled in front of the background.

20200107_221352-prio_demo2x

@endrift
Copy link

endrift commented Jan 9, 2020

Can I get that hacked up bld demo ROM that's broken in mGBA, or a savestate of Golden Sun?

@paulb-nl
Copy link
Contributor Author

paulb-nl commented Jan 9, 2020

Here is the bld_demo hack. I have added a screenshot with expected behavior: sprite behind the background, a small part on the left above the background and Semi-Transparency on mode 0 should not happen on that part.

mGBA is only incorrect on the Semi-Transparency part.

bld_demo(prio_hack).zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants