aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-20 16:45:38 +0200
committerBad Diode <bd@badd10de.dev>2023-04-20 16:45:38 +0200
commita2f30f050fc5cd61d1b927e3c0eea102ec8603ae (patch)
treec59f7b62c804d45ddcc88531003c652d9ee8c11f
parent74eb2bf14f7e82c86419374bfd46b6cfd89f2df8 (diff)
downloaduxngba-a2f30f050fc5cd61d1b927e3c0eea102ec8603ae.tar.gz
uxngba-a2f30f050fc5cd61d1b927e3c0eea102ec8603ae.zip
Fix a bug with the 2bpp rendering
-rw-r--r--src/main.c4
-rw-r--r--src/ppu.c12
2 files changed, 8 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index b1562ca..cdfad6c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -45,8 +45,8 @@
45#define PROF_N_FRAMES 15 45#define PROF_N_FRAMES 15
46#endif 46#endif
47 47
48#if PROF_ENABLE == 1
49// Profile method 1: Average per N frames. 48// Profile method 1: Average per N frames.
49#if PROF_ENABLE == 1
50#define TEXT_ENABLE 1 50#define TEXT_ENABLE 1
51#define PROF(F,VAR) \ 51#define PROF(F,VAR) \
52 do { \ 52 do { \
@@ -55,8 +55,8 @@
55 (VAR) += profile_measure() - __tmp_prof;\ 55 (VAR) += profile_measure() - __tmp_prof;\
56 } while (0) 56 } while (0)
57 57
58#elif PROF_ENABLE == 2
59// Profile method 2: Maximum in N frames. 58// Profile method 2: Maximum in N frames.
59#elif PROF_ENABLE == 2
60#define TEXT_ENABLE 1 60#define TEXT_ENABLE 1
61#define PROF(F,VAR) \ 61#define PROF(F,VAR) \
62 do { \ 62 do { \
diff --git a/src/ppu.c b/src/ppu.c
index bc6f503..adf837c 100644
--- a/src/ppu.c
+++ b/src/ppu.c
@@ -673,12 +673,12 @@ ppu_2bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) {
673 col1mask &= ~col3mask; 673 col1mask &= ~col3mask;
674 col2mask &= ~col3mask; 674 col2mask &= ~col3mask;
675 col3mask = (color & col3mask) & 0x11111111; 675 col3mask = (color & col3mask) & 0x11111111;
676 u32 mask = ~(col1mask | col2mask | col3mask) & 0x11111111; 676 u32 mask = (col1mask | col2mask | col3mask) * 0xF;
677 color = (clr1 * col1mask) | 677 color = (clr1 * col1mask) |
678 (clr2 * col2mask) | 678 (clr2 * col2mask) |
679 (clr3 * col3mask); 679 (clr3 * col3mask);
680 dst[0] = (dst[0] & (mask << shift_left)) | (color << shift_left); 680 dst[0] = (dst[0] & ~(mask << shift_left)) | (color << shift_left);
681 dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); 681 dst[8] = (dst[8] & ~(mask >> shift_right)) | (color >> shift_right);
682 if ((start_row + v) == 7) dst += (32 - 1) * 8; 682 if ((start_row + v) == 7) dst += (32 - 1) * 8;
683 } 683 }
684 } else { 684 } else {
@@ -693,12 +693,12 @@ ppu_2bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y) {
693 col1mask &= ~col3mask; 693 col1mask &= ~col3mask;
694 col2mask &= ~col3mask; 694 col2mask &= ~col3mask;
695 col3mask = (color & col3mask) & 0x11111111; 695 col3mask = (color & col3mask) & 0x11111111;
696 u32 mask = ~(col1mask | col2mask | col3mask) & 0x11111111; 696 u32 mask = (col1mask | col2mask | col3mask) * 0xF;
697 color = (clr1 * col1mask) | 697 color = (clr1 * col1mask) |
698 (clr2 * col2mask) | 698 (clr2 * col2mask) |
699 (clr3 * col3mask); 699 (clr3 * col3mask);
700 dst[0] = (dst[0] & (mask << shift_left)) | (color << shift_left); 700 dst[0] = (dst[0] & ~(mask << shift_left)) | (color << shift_left);
701 dst[8] = (dst[8] & (mask >> shift_right)) | (color >> shift_right); 701 dst[8] = (dst[8] & ~(mask >> shift_right)) | (color >> shift_right);
702 if ((start_row + v) == 7) dst += (32 - 1) * 8; 702 if ((start_row + v) == 7) dst += (32 - 1) * 8;
703 } 703 }
704 } 704 }