ITotalJustice / notorious_beeg

gba emulator written in c++23
https://notorious-beeg.netlify.app/
GNU General Public License v3.0
41 stars 4 forks source link

LOZ minish cap - link vanishes when walking up / down stairs #108

Open ITotalJustice opened 1 year ago

ITotalJustice commented 1 year ago

this seems to be a priority issue. normally bg2 is prio 2 and link is either prio 2 or higher.

Screenshot_20230115_215416

when walking down stairs, bg2 remains the same however it seems the the priority of the object is changed, causing link the vanish.

image

by disabling bg2, we can see that link is still there.

image

ITotalJustice commented 1 year ago

i fixed the issue, not sure if this is correct however because i figured it out by trial and error. i cannot find any documentation for this either...

the issue

object priority is set whenever a opaque pixel is drawn to the screen. this prevents further objects to be drawn to that pixel if their priority is >=.

the fix

it seems that the priority is always set for non-window objects, regardless of the pixel being opaque or not. furthermore, an opaque object will always overwrite a transparent object, regardless of priority.

this means that the check

if (line.priority[x] <= obj.priority) { continue }

becomes

if (line.priority[x] >= obj.priority && line.is_opaque[x] ) { continue }

and as for setting the priority

if (obj.opaque) { line.priority[x] = obj.priority; }

becomes

if (obj.priority < line.priority[x]) { line.priority[x] = obj.priority; }  

NOTE: i don't think the priority is set if the object is a window, although i may be wrong.

ITotalJustice commented 11 months ago

the above fix seems to break emerald intro

https://github.com/ITotalJustice/notorious_beeg/assets/47043333/57ec5544-e2a1-47e3-b427-90f69471b199

ITotalJustice commented 11 months ago

fixed it, i didn't properly impl "an opaque object will always overwrite a transparent object, regardless of priority." part