mirror of https://github.com/mgba-emu/mgba.git
DS GX: Ensure palBase is non-null
This commit is contained in:
parent
0bdf30f650
commit
c24f31d2a7
|
@ -94,6 +94,9 @@ static color_t _lookupColor(struct DSGXSoftwareRenderer* renderer, struct DSGXSo
|
||||||
if (!poly->texBase && poly->texFormat) {
|
if (!poly->texBase && poly->texFormat) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (!poly->palBase && poly->texFormat && poly->texFormat != 7) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// TODO: Optimize
|
// TODO: Optimize
|
||||||
uint16_t texel;
|
uint16_t texel;
|
||||||
|
|
||||||
|
@ -450,22 +453,23 @@ static void _preparePoly(struct DSGXRenderer* renderer, struct DSGXVertex* verts
|
||||||
poly->blendFormat = DSGXPolygonAttrsGetMode(poly->polyParams);
|
poly->blendFormat = DSGXPolygonAttrsGetMode(poly->polyParams);
|
||||||
poly->texW = 8 << DSGXTexParamsGetSSize(poly->texParams);
|
poly->texW = 8 << DSGXTexParamsGetSSize(poly->texParams);
|
||||||
poly->texH = 8 << DSGXTexParamsGetTSize(poly->texParams);
|
poly->texH = 8 << DSGXTexParamsGetTSize(poly->texParams);
|
||||||
if (!renderer->tex[DSGXTexParamsGetVRAMBase(poly->texParams) >> VRAM_BLOCK_OFFSET]) {
|
poly->texBase = NULL;
|
||||||
poly->texBase = NULL;
|
poly->palBase = NULL;
|
||||||
poly->palBase = NULL;
|
if (renderer->tex[DSGXTexParamsGetVRAMBase(poly->texParams) >> VRAM_BLOCK_OFFSET]) {
|
||||||
} else {
|
|
||||||
switch (poly->texFormat) {
|
switch (poly->texFormat) {
|
||||||
case 0:
|
case 0:
|
||||||
poly->texBase = NULL;
|
|
||||||
poly->palBase = NULL;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
poly->texBase = &renderer->tex[DSGXTexParamsGetVRAMBase(poly->poly->texParams) >> VRAM_BLOCK_OFFSET][(DSGXTexParamsGetVRAMBase(poly->poly->texParams) << 2) & 0xFFFF];
|
if (renderer->texPal[poly->poly->palBase >> 11]) {
|
||||||
poly->palBase = &renderer->texPal[poly->poly->palBase >> 11][(poly->poly->palBase << 2) & 0x1FFF];
|
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 << 2) & 0x1FFF];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
poly->texBase = &renderer->tex[DSGXTexParamsGetVRAMBase(poly->poly->texParams) >> VRAM_BLOCK_OFFSET][(DSGXTexParamsGetVRAMBase(poly->poly->texParams) << 2) & 0xFFFF];
|
if (renderer->texPal[poly->poly->palBase >> 10]) {
|
||||||
poly->palBase = &renderer->texPal[poly->poly->palBase >> 10][(poly->poly->palBase << 3) & 0x1FFF];
|
poly->texBase = &renderer->tex[DSGXTexParamsGetVRAMBase(poly->poly->texParams) >> VRAM_BLOCK_OFFSET][(DSGXTexParamsGetVRAMBase(poly->poly->texParams) << 2) & 0xFFFF];
|
||||||
|
poly->palBase = &renderer->texPal[poly->poly->palBase >> 10][(poly->poly->palBase << 3) & 0x1FFF];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue