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

Fix description of OAM_HBL bit #108

Open
exelotl opened this issue May 30, 2024 · 1 comment
Open

Fix description of OAM_HBL bit #108

exelotl opened this issue May 30, 2024 · 1 comment

Comments

@exelotl
Copy link
Member

exelotl commented May 30, 2024

According to Tonc, DISPCNT Bit 5:

Allows access to OAM in an HBlank. OAM is normally locked in VDraw. Will reduce the amount of sprite pixels rendered per line.

This matches what GBATEK says:

Setting H-Blank Interval Free (Bit 5) allows to access OAM during H-Blank time - using this feature reduces the number of sprites that can be displayed per line.

However, this description is wrong!

There is no reason you can't access OAM at any point during VDraw (including HBlank) - it just might be a bit slower if you tried to do so at a moment when the PPU is accessing that memory.

Details from origamiscienceguy on Discord:

Vram, Palette, and OAM can be accessed at any time. If the PPU happens to be accessing something from that bank, waitstates will be inserted until an opening is available. This is usually just a couple cycles at most, with the exception of Mode 2 with both background enabled, in which case the PPU accesses the bg vram bank every cycle, forcing the CPU to wait until hblank to access.

The NanoBoyAdvance hardware docs explain the effect of Bit 5:

Sprite rendering for the current scanline starts at cycle #40 of the previous scanline and continues either until the horizontal blanking period of that previous scanline (if DISPCNT.bit5 = 1) or until cycle #40 of the current scanline (if DISPCNT.bit5 = 0).

In summary, enabling DISPCNT Bit 5 stops the PPU from accessing Obj-VRAM and OAM during HBlank, ensuring faster access to those memory areas at that time, but at the cost of reducing the number of sprite pixels that can be rendered per scanline.

@exelotl
Copy link
Member Author

exelotl commented Aug 14, 2024

JoaoBapt reported another case of this misinfo:

The regobj chapter says:

Actually, this isn’t something to worry about because you can’t update OAM during VDraw; it’s locked then.

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

No branches or pull requests

1 participant