Implement row/half-row skip

This helps a lot with backgrounds that are mostly transparent.
This commit is contained in:
David Guillen Fandos 2023-08-06 14:19:27 +02:00
parent 01471a4295
commit 7bcd7939fb
1 changed files with 69 additions and 58 deletions

View File

@ -226,6 +226,7 @@ static inline void render_tile_Nbpp(
if (is8bpp) {
for (u32 j = 0; j < 2; j++) {
u32 tilepix = eswap32(((u32*)tile_ptr)[hflip ? 1-j : j]);
if (tilepix) {
for (u32 i = 0; i < 4; i++, dest_ptr++) {
u8 pval = hflip ? (tilepix >> (24 - i*8)) : (tilepix >> (i*8));
if (pval) {
@ -237,18 +238,21 @@ static inline void render_tile_Nbpp(
*dest_ptr = pval | px_comb | ((isbase ? bg_comb : *dest_ptr) << 16);
}
else if (isbase) {
if (rdtype == FULLCOLOR)
*dest_ptr = bgcolor;
else
*dest_ptr = 0 | bg_comb; // Add combine flags
}
*dest_ptr = (rdtype == FULLCOLOR) ? bgcolor : 0 | bg_comb;
}
}
} else {
for (u32 i = 0; i < 4; i++, dest_ptr++)
if (isbase)
*dest_ptr = (rdtype == FULLCOLOR) ? bgcolor : 0 | bg_comb;
}
}
} else {
u32 tilepix = eswap32(*(u32*)tile_ptr);
if (tilepix) { // We can skip it all if the row is transparent
u16 tilepal = (tile >> 12) << 4;
u16 pxflg = px_comb | tilepal;
const u16 *subpal = &paltbl[tilepal];
u32 tilepix = eswap32(*(u32*)tile_ptr);
for (u32 i = 0; i < 8; i++, dest_ptr++) {
u8 pval = (hflip ? (tilepix >> ((7-i)*4)) : (tilepix >> (i*4))) & 0xF;
if (pval) {
@ -260,12 +264,14 @@ static inline void render_tile_Nbpp(
*dest_ptr = pxflg | pval | ((isbase ? bg_comb : *dest_ptr) << 16); // Stack pixels
}
else if (isbase) {
if (rdtype == FULLCOLOR)
*dest_ptr = bgcolor;
else
*dest_ptr = 0 | bg_comb;
*dest_ptr = (rdtype == FULLCOLOR) ? bgcolor : 0 | bg_comb;
}
}
} else if (isbase) {
// In this case we simply fill the pixels with background pixels
for (u32 i = 0; i < 8; i++, dest_ptr++)
*dest_ptr = (rdtype == FULLCOLOR) ? bgcolor : 0 | bg_comb;
}
}
}
@ -854,6 +860,7 @@ static inline void render_obj_tile_Nbpp(u32 px_comb,
if (is8bpp) {
for (u32 j = 0; j < 2; j++) {
u32 tilepix = eswap32(((u32*)tile_ptr)[hflip ? 1-j : j]);
if (tilepix) {
for (u32 i = 0; i < 4; i++, dest_ptr++) {
u8 pval = hflip ? (tilepix >> (24 - i*8)) : (tilepix >> (i*8));
if (pval) {
@ -871,9 +878,12 @@ static inline void render_obj_tile_Nbpp(u32 px_comb,
*dest_ptr = dest_ptr[240];
}
}
} else
dest_ptr += 4;
}
} else {
u32 tilepix = eswap32(*(u32*)tile_ptr);
if (tilepix) { // Can skip all pixels if the row is just transparent
for (u32 i = 0; i < 8; i++, dest_ptr++) {
u8 pval = (hflip ? (tilepix >> ((7-i)*4)) : (tilepix >> (i*4))) & 0xF;
const u16 *subpal = &pal[palette];
@ -893,6 +903,7 @@ static inline void render_obj_tile_Nbpp(u32 px_comb,
}
}
}
}
}
// Renders a regular sprite (non-affine) row to screen.