deltabeard / Peanut-GB

A Game Boy (DMG) emulator single header library written in C99. Performance is prioritised over accuracy.
https://projects.deltabeard.com/peanutgb/
276 stars 35 forks source link

Avoid rendering both the background and window on the same line #108

Open ccawley2011 opened 1 month ago

ccawley2011 commented 1 month ago

From what I understand, if the window is active on a given line it'll completely cover the background, so there's no need to draw both of them. In addition, this PR will only clear the buffer if neither the window nor the background are active, which improves performance a bit.

deltabeard commented 1 month ago

These changes causes failures in the DMG-Acid2 test as shown below.

DMG-ACID2_0000000000

Previously, the output was:

DMG-ACID2_0000000000

The left eye and the left chin are drawn by the background which is why they do not look correct after your changes (see https://github.com/mattcurrie/dmg-acid2?tab=readme-ov-file#eyes). The coordinates of the window can be changed to start at any x and y pixel. See https://gbdev.io/pandocs/Scrolling.html#ff4aff4b--wy-wx-window-y-position-x-position-plus-7 .

The increase in speed was impressive though. 🙂