Browse code

ppu arch64: clear "changed" on fg/bg and handle leftovers, if any

Sigrid Solveig Haflínudóttir authored on 26/12/2021 13:19:02
Showing 1 changed files
... ...
@@ -9,7 +9,9 @@ ppu_redraw(Ppu *p, Uint32 *screen)
9 9
 	Uint8 *bg = p->bg.pixels;
10 10
 	int i;
11 11
 
12
-	for(i = 0; i < p->width * p->height; i += 16, fg += 16, bg += 16, screen += 16) {
12
+	p->fg.changed = p->bg.changed = 0;
13
+
14
+	for(i = 0; i < (p->width * p->height & ~15); i += 16, fg += 16, bg += 16, screen += 16) {
13 15
 		uint8x16_t fg8 = vld1q_u8(fg);
14 16
 		uint8x16_t bg8 = vld1q_u8(bg);
15 17
 		uint8x16_t px8 = vbslq_u8(vceqzq_u8(fg8), bg8, fg8);
... ...
@@ -21,4 +23,7 @@ ppu_redraw(Ppu *p, Uint32 *screen)
21 23
 		};
22 24
 		vst4q_u8((uint8_t*)screen, px);
23 25
 	}
26
+
27
+	for(; i < p->width * p->height; i++)
28
+		screen[i] = p->palette[*fg ? *fg : *bg];
24 29
 }