diff options
author | Bad Diode <bd@badd10de.dev> | 2023-04-19 18:56:00 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-04-19 18:56:00 +0200 |
commit | da30ead571b5243b777244b6407fe911fab8359f (patch) | |
tree | 1ae311ee519f75d7a9c21dcb5cc023412f91204d | |
parent | d68d16405b013967e0faa12f9dfc608e3bb3d0d4 (diff) | |
download | uxngba-da30ead571b5243b777244b6407fe911fab8359f.tar.gz uxngba-da30ead571b5243b777244b6407fe911fab8359f.zip |
Fix some more ppu bugs
-rw-r--r-- | src/ppu.c | 52 |
1 files changed, 14 insertions, 38 deletions
@@ -457,14 +457,10 @@ ppu_1bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) { | |||
457 | if ((y + v) >= SCREEN_HEIGHT) break; | 457 | if ((y + v) >= SCREEN_HEIGHT) break; |
458 | u8 ch1 = sprite[v]; | 458 | u8 ch1 = sprite[v]; |
459 | u32 color= lut[ch1]; | 459 | u32 color= lut[ch1]; |
460 | u32 mask = ~color; | 460 | u32 mask = color * 0xF; |
461 | color *= clr & 3; | 461 | color *= clr & 3; |
462 | if (start_col == 0) { | 462 | dst[0] = (dst[0] & ~(mask << shift_left)) | (color << shift_left); |
463 | dst[0] = (dst[0] & ~mask) | color; | 463 | dst[8] = (dst[8] & ~(mask >> shift_right)) | (color >> shift_right); |
464 | } else { | ||
465 | dst[0] = (dst[0] & ~(mask << shift_left)) | (color << shift_left); | ||
466 | dst[8] = (dst[8] & ~(mask >> shift_right)) | (color >> shift_right); | ||
467 | } | ||
468 | if ((start_row + v) == 7) dst += (32 - 1) * 8; | 464 | if ((start_row + v) == 7) dst += (32 - 1) * 8; |
469 | } | 465 | } |
470 | } else { | 466 | } else { |
@@ -472,14 +468,10 @@ ppu_1bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) { | |||
472 | if ((y + v) >= SCREEN_HEIGHT) break; | 468 | if ((y + v) >= SCREEN_HEIGHT) break; |
473 | u8 ch1 = sprite[(7 - v)]; | 469 | u8 ch1 = sprite[(7 - v)]; |
474 | u32 color= lut[ch1]; | 470 | u32 color= lut[ch1]; |
475 | u32 mask = ~color; | 471 | u32 mask = color * 0xF; |
476 | color *= clr & 3; | 472 | color *= clr & 3; |
477 | if (start_col == 0) { | 473 | dst[0] = (dst[0] & ~(mask << shift_left)) | (color << shift_left); |
478 | dst[0] = (dst[0] & ~mask) | color; | 474 | dst[8] = (dst[8] & ~(mask >> shift_right)) | (color >> shift_right); |
479 | } else { | ||
480 | dst[0] = (dst[0] & ~(mask << shift_left)) | (color << shift_left); | ||
481 | dst[8] = (dst[8] & ~(mask >> shift_right)) | (color >> shift_right); | ||
482 | } | ||
483 | if ((start_row + v) == 7) dst += (32 - 1) * 8; | 475 | if ((start_row + v) == 7) dst += (32 - 1) * 8; |
484 | } | 476 | } |
485 | } | 477 | } |
@@ -631,12 +623,8 @@ ppu_2bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) { | |||
631 | u8 ch1 = sprite[v]; | 623 | u8 ch1 = sprite[v]; |
632 | u8 ch2 = sprite[v | 8]; | 624 | u8 ch2 = sprite[v | 8]; |
633 | u32 color = lut[ch1] | (lut[ch2] << 1); | 625 | u32 color = lut[ch1] | (lut[ch2] << 1); |
634 | if (start_col == 0) { | 626 | dst[0] = (dst[0] & (mask << shift_left)) | color; |
635 | dst[0] = (dst[0] & mask) | color; | 627 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); |
636 | } else { | ||
637 | dst[0] = (dst[0] & (mask << shift_left)) | color; | ||
638 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); | ||
639 | } | ||
640 | if ((start_row + v) == 7) dst += (32 - 1) * 8; | 628 | if ((start_row + v) == 7) dst += (32 - 1) * 8; |
641 | } | 629 | } |
642 | } else { | 630 | } else { |
@@ -645,12 +633,8 @@ ppu_2bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) { | |||
645 | u8 ch1 = sprite[(7 - v)]; | 633 | u8 ch1 = sprite[(7 - v)]; |
646 | u8 ch2 = sprite[(7 - v) | 8]; | 634 | u8 ch2 = sprite[(7 - v) | 8]; |
647 | u32 color = lut[ch1] | (lut[ch2] << 1); | 635 | u32 color = lut[ch1] | (lut[ch2] << 1); |
648 | if (start_col == 0) { | 636 | dst[0] = (dst[0] & (mask << shift_left)) | color; |
649 | dst[0] = (dst[0] & mask) | color; | 637 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); |
650 | } else { | ||
651 | dst[0] = (dst[0] & (mask << shift_left)) | color; | ||
652 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); | ||
653 | } | ||
654 | if ((start_row + v) == 7) dst += (32 - 1) * 8; | 638 | if ((start_row + v) == 7) dst += (32 - 1) * 8; |
655 | } | 639 | } |
656 | } | 640 | } |
@@ -723,12 +707,8 @@ ppu_2bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) { | |||
723 | color = (clr1 * col1mask) | | 707 | color = (clr1 * col1mask) | |
724 | (clr2 * col2mask) | | 708 | (clr2 * col2mask) | |
725 | (clr3 * col3mask); | 709 | (clr3 * col3mask); |
726 | if (start_col == 0) { | 710 | dst[0] = (dst[0] & (mask << shift_left)) | color; |
727 | dst[0] = (dst[0] & mask) | color; | 711 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); |
728 | } else { | ||
729 | dst[0] = (dst[0] & (mask << shift_left)) | color; | ||
730 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); | ||
731 | } | ||
732 | if ((start_row + v) == 7) dst += (32 - 1) * 8; | 712 | if ((start_row + v) == 7) dst += (32 - 1) * 8; |
733 | } | 713 | } |
734 | } else { | 714 | } else { |
@@ -747,12 +727,8 @@ ppu_2bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) { | |||
747 | color = (clr1 * col1mask) | | 727 | color = (clr1 * col1mask) | |
748 | (clr2 * col2mask) | | 728 | (clr2 * col2mask) | |
749 | (clr3 * col3mask); | 729 | (clr3 * col3mask); |
750 | if (start_col == 0) { | 730 | dst[0] = (dst[0] & (mask << shift_left)) | color; |
751 | dst[0] = (dst[0] & mask) | color; | 731 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); |
752 | } else { | ||
753 | dst[0] = (dst[0] & (mask << shift_left)) | color; | ||
754 | dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); | ||
755 | } | ||
756 | if ((start_row + v) == 7) dst += (32 - 1) * 8; | 732 | if ((start_row + v) == 7) dst += (32 - 1) * 8; |
757 | } | 733 | } |
758 | } | 734 | } |