all repos — mgba @ f5a3fd7c7f1ad32cd326775a910a8e4a39a0f301

mGBA Game Boy Advance Emulator

Rearrange _composite to optimize for common cases first
Jeffrey Pfau jeffrey@endrift.com
Sat, 26 Oct 2013 16:43:11 -0700
commit

f5a3fd7c7f1ad32cd326775a910a8e4a39a0f301

parent

6e40c7ec29b0b31343d427d51ea4c029cd71ce8c

1 files changed, 4 insertions(+), 4 deletions(-)

jump to
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -613,10 +613,10 @@ static void _composite(struct GBAVideoSoftwareRenderer* renderer, int offset, uint32_t color, uint32_t current) {

// We stash the priority on the top bits so we can do a one-operator comparison // The lower the number, the higher the priority, and sprites take precendence over backgrounds // We want to do special processing if the color pixel is target 1, however - if ((color & FLAG_ORDER_MASK) < (current & FLAG_ORDER_MASK)) { - if (current & FLAG_UNWRITTEN) { - renderer->row[offset] = color | (current & FLAG_OBJWIN); - } else if (!(color & FLAG_TARGET_1) || !(current & FLAG_TARGET_2)) { + if (current & FLAG_UNWRITTEN) { + renderer->row[offset] = color | (current & FLAG_OBJWIN); + } else if ((color & FLAG_ORDER_MASK) < (current & FLAG_ORDER_MASK)) { + if (!(color & FLAG_TARGET_1) || !(current & FLAG_TARGET_2)) { renderer->row[offset] = color | FLAG_FINALIZED; } else { renderer->row[offset] = _mix(renderer->bldb, current, renderer->blda, color) | FLAG_FINALIZED;