Skip to content

Implement HBlank OAM staging behaviour to match hardware#3756

Open
felixjones wants to merge 9 commits into
mgba-emu:masterfrom
felixjones:fix-1871-hblank-oam-delay
Open

Implement HBlank OAM staging behaviour to match hardware#3756
felixjones wants to merge 9 commits into
mgba-emu:masterfrom
felixjones:fix-1871-hblank-oam-delay

Conversation

@felixjones

Copy link
Copy Markdown
Contributor

Encountered the same issue in a game project I am working on where 1px thick lines rendered with OAM sprites are rendered on the wrong scanline

Fixes #1871 by staging OAM to the renderer 1 scanline earlier

This is similar to how NanoBoyAdvance solved it nba-emu/NanoBoyAdvance@eda1af7

A lot of this is a copy-paste of *WriteOAM and then modified for the staging concept, so the approach might be a bit unwieldy

And I couldn't for the life of me get the cinema locally set up, so that cinema test I added was a guess and uses a screenshot from this particular change

Comment thread src/gb/extra/proxy.c Outdated
@endrift

endrift commented Apr 5, 2026

Copy link
Copy Markdown
Member

This probably also fixes #2048. Please cross-check.

fwiw, I'm not sure how I feel about this approach. I also don't intend to merge this before 0.11 regardless, but it is something I was targeting for fixing in 0.12 regardless.

@endrift endrift added this to the mGBA 0.12.0 milestone Apr 5, 2026
@felixjones

Copy link
Copy Markdown
Contributor Author

This probably also fixes #2048. Please cross-check.

Yes can confirm #2048 is also fixed

cube_test-0

fwiw, I'm not sure how I feel about this approach. I also don't intend to merge this before 0.11 regardless, but it is something I was targeting for fixing in 0.12 regardless.

I struggled to think of a better approach, considering real OAM writes still need to happen. Double buffering them was all I could think of

@endrift

endrift commented Apr 6, 2026

Copy link
Copy Markdown
Member

The way I was planning on implementing this is by doing what actually happens on hardware: it renders the OAM to another buffer a frame early and then compositing into the final image, then rendering the current state of OAM to that buffer. This may require another buffer to do efficiently, but so be it.

@endrift

endrift commented Apr 6, 2026

Copy link
Copy Markdown
Member

That way I believe does not require modifying the API, which is something I want to avoid here since it would break mVLs

@felixjones

Copy link
Copy Markdown
Contributor Author

The way I was planning on implementing this is by doing what actually happens on hardware: it renders the OAM to another buffer a frame early and then compositing into the final image, then rendering the current state of OAM to that buffer. This may require another buffer to do efficiently, but so be it.

Looked into rendering the incoming line of OAM at HBlank start with the goal of not modifying the API, feels much cleaner as it's shuffling existing code around, but what do you think?

Comment thread src/gba/renderers/video-software.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sprites updated with HDMA differs from hardware

2 participants