gbdev / pandocs

The single, most comprehensive Game Boy technical reference.
https://gbdev.io/pandocs/
Creative Commons Zero v1.0 Universal
616 stars 93 forks source link

Weird black lines while loading Quartet's border #198

Open ISSOtm opened 3 years ago

ISSOtm commented 3 years ago

For some reason, during Quartet's initial load, the border briefly flashes with dark lines. Investigate and document why. (Note: if the bugs ends up fixed on that download page, it's still present in the cracktro.)

Tip: the bug reproduces on Mesen-S, which has both a GB and SNES debugger, so it should be easier to figure out.

paulb-nl commented 3 years ago

When a new border is loaded the SGB first copies the tilemap of the empty black border at address $028E90 which is filled with tile 1 (address $0020) to VRAM address $7800 (word address $3C00). Normally tile 1 is a non-transparent tile with black palette. After that the new tilemap is copied. So if the black border is selected then it copies it twice.

Quartet puts a transparent tile at tile address $0020 with a single row of non-transparent black pixels at the bottom. When the SGB copies the tilemap of the black border the Gameboy background color is white so the white color is visible through the transparent tile except for the black line at the bottom of the tile.

Then the SGB copies the new tilemap from Quartet which is filled with tile 0 and that tile is fully transparent so the lines disappear.

ISSOtm commented 3 years ago

Then why does it not occur with other games? The cracktro, for example, uses a different border, byt IIRC is not subject to this despite having a non-blank tile 1.

paulb-nl commented 3 years ago

The cracktro has a non-transparent tile 1 that's why it doesn't occur. Quartet has a transparent tile 1 (except for the bottom row of pixels) so the white background comes through.

Games can avoid this issue by using a non-transparent tile 1 or by making sure that the Gameboy background color is black while using MASK_EN

ISSOtm commented 3 years ago

This should be confirmed in the SGB BIOS (ideally updating sgb-bios so that it can be cited), and then added to the docs. Thanks!

(Another item on my long TODO list; if anyone's willing to do it instead, feel free to ping us for any help.)