Implement blending on sprites
Jeffrey Pfau jeffrey@endrift.com
Wed, 24 Apr 2013 23:49:16 -0700
1 files changed,
10 insertions(+),
5 deletions(-)
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -298,6 +298,13 @@ }
static void _compositeBackground(struct GBAVideoSoftwareRenderer* renderer, int offset, int entry, struct PixelFlags flags) { if (renderer->flags[offset].isSprite && flags.priority >= renderer->flags[offset].priority) { + if (renderer->flags[offset].target1) { + if (flags.target2) { + renderer->row[offset] = _mix(renderer->bldb, renderer->d.palette[entry], renderer->blda, renderer->row[offset]); + } + } + renderer->flags[offset].finalized = 1; + renderer->flags[offset].written = 1; return; } if (renderer->blendEffect == BLEND_NONE || (!flags.target1 && !flags.target2)) {@@ -310,10 +317,8 @@ } else if (renderer->blendEffect == BLEND_ALPHA) {
if (renderer->flags[offset].written) { if (renderer->flags[offset].target1 && flags.target2) { renderer->row[offset] = _mix(renderer->bldb, renderer->d.palette[entry], renderer->blda, renderer->row[offset]); - renderer->flags[offset].finalized = 1; - } else { - renderer->flags[offset].finalized = 1; } + renderer->flags[offset].finalized = 1; } else { renderer->row[offset] = renderer->d.palette[entry]; renderer->flags[offset].target1 = flags.target1;@@ -394,8 +399,8 @@ (void)(renderer);
struct PixelFlags flags = { .priority = sprite->priority, .isSprite = 1, - .target1 = renderer->target1Obj, - .target2 = renderer->target1Obj || sprite->mode == OBJ_MODE_SEMITRANSPARENT + .target1 = renderer->target1Obj || sprite->mode == OBJ_MODE_SEMITRANSPARENT, + .target2 = renderer->target2Obj }; int inX = sprite->x; int inY = y - sprite->y;