all repos — mgba @ 662a6cdd588172118b64ed11c059e9bfce2b270b

mGBA Game Boy Advance Emulator

DS GX: Partially fix compressed textures
Vicki Pfau vi@endrift.com
Thu, 09 Mar 2017 15:23:46 -0500
commit

662a6cdd588172118b64ed11c059e9bfce2b270b

parent

eb15e02412dc545a9da81b90778d13e51679d392

1 files changed, 18 insertions(+), 15 deletions(-)

jump to
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -174,47 +174,50 @@ uint8_t r, g, b;

unsigned wr, wg, wb, wa; if (poly->texFormat == 5) { // TODO: Slot 2 uses upper half - uint16_t texel2 = renderer->d.tex[1][texelCoord >> 1]; + uint16_t half = DSGXTexParamsGetVRAMBase(poly->poly->texParams) & 0x8000; + uint32_t slot1Base = (DSGXTexParamsGetVRAMBase(poly->poly->texParams) << 1) + (texelCoord >> 2) + half; + uint16_t texel2 = renderer->d.tex[1][slot1Base]; + uint16_t texel2Base = (texel2 & 0x3FFF) << 1; int a = 0x8; int b = 0; switch (texel2 >> 14) { case 0: if (texel == 3) { - return 0; + ta = 0; } - texel = poly->palBase[texel + (texel2 & 0x3FFF) * 2]; + texel = poly->palBase[texel + texel2Base]; break; case 1: if (texel == 3) { - return 0; + ta = 0; } if (texel != 2) { - texel = poly->palBase[texel + (texel2 & 0x3FFF) * 2]; + texel = poly->palBase[texel + texel2Base]; } else { - texel = poly->palBase[(texel2 & 0x3FFF) * 2]; - texel2 = poly->palBase[(texel2 & 0x3FFF) * 2 + 1]; + texel = poly->palBase[texel2Base]; + texel2 = poly->palBase[texel2Base + 1]; a = 4; b = 4; } break; case 2: - texel = poly->palBase[texel + (texel2 & 0x3FFF) * 2]; + texel = poly->palBase[texel + texel2Base]; break; case 3: switch (texel) { case 0: case 1: - texel = poly->palBase[texel + (texel2 & 0x3FFF) * 2]; + texel = poly->palBase[texel + texel2Base]; break; case 2: - texel = poly->palBase[(texel2 & 0x3FFF) * 2]; - texel2 = poly->palBase[(texel2 & 0x3FFF) * 2 + 1]; + texel = poly->palBase[texel2Base]; + texel2 = poly->palBase[texel2Base + 1]; a = 5; b = 3; break; case 3: - texel = poly->palBase[(texel2 & 0x3FFF) * 2]; - texel2 = poly->palBase[(texel2 & 0x3FFF) * 2 + 1]; + texel = poly->palBase[texel2Base]; + texel2 = poly->palBase[texel2Base + 1]; a = 3; b = 5; break;

@@ -387,11 +390,11 @@ poly->palBase = NULL;

break; case 2: poly->texBase = &renderer->tex[DSGXTexParamsGetVRAMBase(poly->poly->texParams) >> VRAM_BLOCK_OFFSET][(DSGXTexParamsGetVRAMBase(poly->poly->texParams) << 2) & 0xFFFF]; - poly->palBase = &renderer->texPal[poly->poly->palBase >> 12][(poly->poly->palBase << 2) & 0x1FFF]; + poly->palBase = &renderer->texPal[poly->poly->palBase >> 11][(poly->poly->palBase << 2) & 0x1FFF]; break; default: poly->texBase = &renderer->tex[DSGXTexParamsGetVRAMBase(poly->poly->texParams) >> VRAM_BLOCK_OFFSET][(DSGXTexParamsGetVRAMBase(poly->poly->texParams) << 2) & 0xFFFF]; - poly->palBase = &renderer->texPal[poly->poly->palBase >> 11][(poly->poly->palBase << 3) & 0x1FFF]; + poly->palBase = &renderer->texPal[poly->poly->palBase >> 10][(poly->poly->palBase << 3) & 0x1FFF]; break; } edge->polyId = i;