mirror of https://github.com/mgba-emu/mgba.git
Support 256-color sprites
This commit is contained in:
parent
61c6b7186e
commit
e3fddc5739
|
@ -631,26 +631,51 @@ static void _drawSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj
|
|||
inY = height - inY - 1;
|
||||
}
|
||||
unsigned charBase = BASE_TILE + sprite->tile * 0x20;
|
||||
unsigned yBase = (inY & ~0x7) * (renderer->dispcnt.objCharacterMapping ? width >> 1 : 0x80) + (inY & 0x7) * 4;
|
||||
for (int outX = x >= start ? x : start; outX < x + width && outX < end; ++outX) {
|
||||
int inX = outX - x;
|
||||
if (sprite->hflip) {
|
||||
inX = width - inX - 1;
|
||||
}
|
||||
if (renderer->flags[outX].isSprite) {
|
||||
continue;
|
||||
}
|
||||
unsigned xBase = (inX & ~0x7) * 4 + ((inX >> 1) & 2);
|
||||
uint16_t tileData = renderer->d.vram[(yBase + charBase + xBase) >> 1];
|
||||
tileData = (tileData >> ((inX & 3) << 2)) & 0xF;
|
||||
if (tileData) {
|
||||
if (renderer->blendEffect == BLEND_NONE || renderer->blendEffect == BLEND_ALPHA || !renderer->target1Obj) {
|
||||
renderer->spriteLayer[outX] = renderer->normalPalette[0x100 | tileData | (sprite->palette << 4)];
|
||||
} else {
|
||||
renderer->spriteLayer[outX] = renderer->variantPalette[0x100 | tileData | (sprite->palette << 4)];
|
||||
if (!sprite->multipalette) {
|
||||
unsigned yBase = (inY & ~0x7) * (renderer->dispcnt.objCharacterMapping ? width >> 1 : 0x80) + (inY & 0x7) * 4;
|
||||
for (int outX = x >= start ? x : start; outX < x + width && outX < end; ++outX) {
|
||||
int inX = outX - x;
|
||||
if (sprite->hflip) {
|
||||
inX = width - inX - 1;
|
||||
}
|
||||
if (renderer->flags[outX].isSprite) {
|
||||
continue;
|
||||
}
|
||||
unsigned xBase = (inX & ~0x7) * 4 + ((inX >> 1) & 2);
|
||||
uint16_t tileData = renderer->d.vram[(yBase + charBase + xBase) >> 1];
|
||||
tileData = (tileData >> ((inX & 3) << 2)) & 0xF;
|
||||
if (tileData) {
|
||||
if (renderer->blendEffect == BLEND_NONE || renderer->blendEffect == BLEND_ALPHA || !renderer->target1Obj) {
|
||||
renderer->spriteLayer[outX] = renderer->normalPalette[0x100 | tileData | (sprite->palette << 4)];
|
||||
} else {
|
||||
renderer->spriteLayer[outX] = renderer->variantPalette[0x100 | tileData | (sprite->palette << 4)];
|
||||
}
|
||||
renderer->flags[outX] = flags;
|
||||
}
|
||||
renderer->flags[outX] = flags;
|
||||
}
|
||||
} else {
|
||||
unsigned yBase = (inY & ~0x7) * (renderer->dispcnt.objCharacterMapping ? width : 0x100) + (inY & 0x7) * 8;
|
||||
for (int outX = x >= start ? x : start; outX < x + width && outX < end; ++outX) {
|
||||
int inX = outX - x;
|
||||
if (sprite->hflip) {
|
||||
inX = width - inX - 1;
|
||||
}
|
||||
if (renderer->flags[outX].isSprite) {
|
||||
continue;
|
||||
}
|
||||
unsigned xBase = (inX & ~0x7) * 8 + (inX & 6);
|
||||
uint16_t tileData = renderer->d.vram[(yBase + charBase + xBase) >> 1];
|
||||
tileData = (tileData >> ((inX & 1) << 3)) & 0xFF;
|
||||
if (tileData) {
|
||||
if (renderer->blendEffect == BLEND_NONE || renderer->blendEffect == BLEND_ALPHA || !renderer->target1Obj) {
|
||||
renderer->spriteLayer[outX] = renderer->normalPalette[0x100 | tileData];
|
||||
} else {
|
||||
renderer->spriteLayer[outX] = renderer->variantPalette[0x100 | tileData];
|
||||
}
|
||||
renderer->flags[outX] = flags;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue