mirror of https://github.com/mgba-emu/mgba.git
GB Video: Fix SGB border transparency
This commit is contained in:
parent
4a10ea2f69
commit
9630583646
|
@ -81,18 +81,12 @@ static void _regenerateSGBBorder(struct GBVideoSoftwareRenderer* renderer) {
|
||||||
if (SGBBgAttributesIsXFlip(mapData)) {
|
if (SGBBgAttributesIsXFlip(mapData)) {
|
||||||
for (i = 0; i < 8; ++i) {
|
for (i = 0; i < 8; ++i) {
|
||||||
colorSelector = (tileData[0] >> i & 0x1) << 0 | (tileData[1] >> i & 0x1) << 1 | (tileData[2] >> i & 0x1) << 2 | (tileData[3] >> i & 0x1) << 3;
|
colorSelector = (tileData[0] >> i & 0x1) << 0 | (tileData[1] >> i & 0x1) << 1 | (tileData[2] >> i & 0x1) << 2 | (tileData[3] >> i & 0x1) << 3;
|
||||||
// The first color of every palette is transparent
|
renderer->outputBuffer[base + i] = renderer->palette[paletteBase | colorSelector];
|
||||||
if (colorSelector) {
|
|
||||||
renderer->outputBuffer[base + i] = renderer->palette[paletteBase | colorSelector];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 7; i >= 0; --i) {
|
for (i = 7; i >= 0; --i) {
|
||||||
colorSelector = (tileData[0] >> i & 0x1) << 0 | (tileData[1] >> i & 0x1) << 1 | (tileData[2] >> i & 0x1) << 2 | (tileData[3] >> i & 0x1) << 3;
|
colorSelector = (tileData[0] >> i & 0x1) << 0 | (tileData[1] >> i & 0x1) << 1 | (tileData[2] >> i & 0x1) << 2 | (tileData[3] >> i & 0x1) << 3;
|
||||||
|
renderer->outputBuffer[base + 7 - i] = renderer->palette[paletteBase | colorSelector];
|
||||||
if (colorSelector) {
|
|
||||||
renderer->outputBuffer[base + 7 - i] = renderer->palette[paletteBase | colorSelector];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,13 +353,28 @@ static void GBVideoSoftwareRendererWriteSGBPacket(struct GBVideoRenderer* render
|
||||||
static void GBVideoSoftwareRendererWritePalette(struct GBVideoRenderer* renderer, int index, uint16_t value) {
|
static void GBVideoSoftwareRendererWritePalette(struct GBVideoRenderer* renderer, int index, uint16_t value) {
|
||||||
struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
|
struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
|
||||||
color_t color = mColorFrom555(value);
|
color_t color = mColorFrom555(value);
|
||||||
if (softwareRenderer->model == GB_MODEL_SGB && index < 0x10 && index && !(index & 3)) {
|
if (softwareRenderer->model == GB_MODEL_SGB) {
|
||||||
color = softwareRenderer->palette[0];
|
if (index < 0x10 && index && !(index & 3)) {
|
||||||
|
color = softwareRenderer->palette[0];
|
||||||
|
} else if (index >= 0x40 && !(index & 0xF)) {
|
||||||
|
color = softwareRenderer->palette[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
softwareRenderer->palette[index] = color;
|
softwareRenderer->palette[index] = color;
|
||||||
if (renderer->cache) {
|
if (renderer->cache) {
|
||||||
mCacheSetWritePalette(renderer->cache, index, color);
|
mCacheSetWritePalette(renderer->cache, index, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (softwareRenderer->model == GB_MODEL_SGB && !index && GBRegisterLCDCIsEnable(softwareRenderer->lcdc)) {
|
||||||
|
renderer->writePalette(renderer, 0x04, value);
|
||||||
|
renderer->writePalette(renderer, 0x08, value);
|
||||||
|
renderer->writePalette(renderer, 0x0C, value);
|
||||||
|
renderer->writePalette(renderer, 0x40, value);
|
||||||
|
renderer->writePalette(renderer, 0x50, value);
|
||||||
|
renderer->writePalette(renderer, 0x60, value);
|
||||||
|
renderer->writePalette(renderer, 0x70, value);
|
||||||
|
_regenerateSGBBorder(softwareRenderer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBVideoSoftwareRendererWriteVRAM(struct GBVideoRenderer* renderer, uint16_t address) {
|
static void GBVideoSoftwareRendererWriteVRAM(struct GBVideoRenderer* renderer, uint16_t address) {
|
||||||
|
|
Loading…
Reference in New Issue