paletted textures are always twiddled

This commit is contained in:
Anthony Pesch 2017-07-18 17:30:02 -04:00
parent 0b3d5317f1
commit f26631c8fc
2 changed files with 9 additions and 7 deletions

View File

@ -319,20 +319,20 @@ void ta_texture_info(struct ta *ta, union tsp tsp, union tcw tcw,
if (tcw.pixel_format == TA_PIXEL_4BPP || tcw.pixel_format == TA_PIXEL_8BPP) { if (tcw.pixel_format == TA_PIXEL_4BPP || tcw.pixel_format == TA_PIXEL_8BPP) {
uint32_t palette_addr = 0; uint32_t palette_addr = 0;
/* palette ram is 4096 bytes, with each palette tex being 4 bytes each, /* palette ram is 4096 bytes, with each palette entry being 4 bytes each,
resulting in 1 << 10 indexes */ resulting in 1 << 10 indexes */
if (tcw.pixel_format == TA_PIXEL_4BPP) { if (tcw.pixel_format == TA_PIXEL_4BPP) {
/* in 4bpp mode, the palette selector represents the upper 6 bits of the /* in 4bpp mode, the palette selector represents the upper 6 bits of the
palette index, with the remaining 4 bits being filled in by the palette index, with the remaining 4 bits being filled in by the
texture */ texture */
palette_addr = (tcw.p.palette_selector << 4) * 4; palette_addr = tcw.p.palette_selector << 6;
*palette_size = (1 << 4) * 4; *palette_size = 1 << 6;
} else if (tcw.pixel_format == TA_PIXEL_8BPP) { } else if (tcw.pixel_format == TA_PIXEL_8BPP) {
/* in 8bpp mode, the palette selector represents the upper 2 bits of the /* in 8bpp mode, the palette selector represents the upper 2 bits of the
palette index, with the remaining 8 bits being filled in by the palette index, with the remaining 8 bits being filled in by the
texture */ texture */
palette_addr = ((tcw.p.palette_selector & 0x30) << 4) * 4; palette_addr = (tcw.p.palette_selector >> 4) << 10;
*palette_size = (1 << 8) * 4; *palette_size = 1 << 10;
} }
*palette = &ta->pvr->palette_ram[palette_addr]; *palette = &ta->pvr->palette_ram[palette_addr];

View File

@ -48,7 +48,9 @@ static inline uint32_t ta_texture_addr(union tcw tcw) {
} }
static inline int ta_texture_twiddled(union tcw tcw) { static inline int ta_texture_twiddled(union tcw tcw) {
return !tcw.scan_order; return !tcw.scan_order ||
/* paletted textures are always twiddled */
tcw.pixel_format == TA_PIXEL_8BPP || tcw.pixel_format == TA_PIXEL_4BPP;
} }
static inline int ta_texture_compressed(union tcw tcw) { static inline int ta_texture_compressed(union tcw tcw) {
@ -56,7 +58,7 @@ static inline int ta_texture_compressed(union tcw tcw) {
} }
static inline int ta_texture_mipmaps(union tcw tcw) { static inline int ta_texture_mipmaps(union tcw tcw) {
return !tcw.scan_order && tcw.mip_mapped; return ta_texture_twiddled(tcw) && tcw.mip_mapped;
} }
static inline int ta_texture_width(union tsp tsp, union tcw tcw) { static inline int ta_texture_width(union tsp tsp, union tcw tcw) {