Implement blending on sprites

This commit is contained in:
Jeffrey Pfau 2013-04-24 23:49:16 -07:00
parent 07b96cddef
commit 4446e0dbde
1 changed files with 10 additions and 5 deletions

View File

@ -298,6 +298,13 @@ static void GBAVideoSoftwareRendererWriteBLDCNT(struct GBAVideoSoftwareRenderer*
static void _compositeBackground(struct GBAVideoSoftwareRenderer* renderer, int offset, int entry, struct PixelFlags flags) { 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].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; return;
} }
if (renderer->blendEffect == BLEND_NONE || (!flags.target1 && !flags.target2)) { if (renderer->blendEffect == BLEND_NONE || (!flags.target1 && !flags.target2)) {
@ -310,10 +317,8 @@ static void _compositeBackground(struct GBAVideoSoftwareRenderer* renderer, int
if (renderer->flags[offset].written) { if (renderer->flags[offset].written) {
if (renderer->flags[offset].target1 && flags.target2) { if (renderer->flags[offset].target1 && flags.target2) {
renderer->row[offset] = _mix(renderer->bldb, renderer->d.palette[entry], renderer->blda, renderer->row[offset]); 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 { } else {
renderer->row[offset] = renderer->d.palette[entry]; renderer->row[offset] = renderer->d.palette[entry];
renderer->flags[offset].target1 = flags.target1; renderer->flags[offset].target1 = flags.target1;
@ -394,8 +399,8 @@ static void _drawSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj
struct PixelFlags flags = { struct PixelFlags flags = {
.priority = sprite->priority, .priority = sprite->priority,
.isSprite = 1, .isSprite = 1,
.target1 = renderer->target1Obj, .target1 = renderer->target1Obj || sprite->mode == OBJ_MODE_SEMITRANSPARENT,
.target2 = renderer->target1Obj || sprite->mode == OBJ_MODE_SEMITRANSPARENT .target2 = renderer->target2Obj
}; };
int inX = sprite->x; int inX = sprite->x;
int inY = y - sprite->y; int inY = y - sprite->y;