all repos — mgba @ bcf446737c90d95f4914b96e9085befd063721df

mGBA Game Boy Advance Emulator

Start implementing transparency
Jeffrey Pfau jeffrey@endrift.com
Mon, 22 Apr 2013 02:07:35 -0700
commit

bcf446737c90d95f4914b96e9085befd063721df

parent

e1d5f3f457972dd5eff1c1d139edb5c0c9bc8066

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

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

@@ -158,7 +158,7 @@ }

} for (int x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) { for (int i = 0; i < 4; ++i) { - if (softwareRenderer->sortedBg[i]->enabled) { + if (softwareRenderer->sortedBg[i]->enabled && softwareRenderer->sortedBg[i]->internalBuffer[x] != 0x8000) { row[x] = softwareRenderer->sortedBg[i]->internalBuffer[x]; break; }

@@ -223,7 +223,11 @@ mapData.packed = renderer->d.vram[screenBase];

charBase = ((background->charBase + mapData.tile << 5) >> 1) + ((inY & 0x7) << 1) + (((outX + inX) >> 2) & 1); uint16_t tileData = renderer->d.vram[charBase]; tileData >>= ((outX + inX) & 0x3) << 2; - background->internalBuffer[outX] = renderer->d.palette[(tileData & 0xF) | (mapData.palette << 4)]; + if (tileData & 0xF) { + background->internalBuffer[outX] = renderer->d.palette[(tileData & 0xF) | (mapData.palette << 4)]; + } else { + background->internalBuffer[outX] = 0x8000; + } } }

@@ -235,8 +239,8 @@ static int _backgroundComparator(const void* a, const void* b) {

const struct GBAVideoSoftwareBackground* bgA = *(const struct GBAVideoSoftwareBackground**) a; const struct GBAVideoSoftwareBackground* bgB = *(const struct GBAVideoSoftwareBackground**) b; if (bgA->priority != bgB->priority) { - return bgB->priority - bgA->priority; + return bgA->priority - bgB->priority; } else { - return bgB->index - bgA->index; + return bgA->index - bgB->index; } }