Browse code

screen_talk should not peek at addr when drawing a single pixel

neauoire authored on 30/07/2021 23:31:10
Showing 1 changed files
... ...
@@ -294,15 +294,17 @@ screen_talk(Device *d, Uint8 b0, Uint8 w)
294 294
 	if(w && b0 == 0xe) {
295 295
 		Uint16 x = mempeek16(d->dat, 0x8);
296 296
 		Uint16 y = mempeek16(d->dat, 0xa);
297
-		Uint8 *addr = &d->mem[mempeek16(d->dat, 0xc)];
298 297
 		Layer *layer = d->dat[0xe] >> 4 & 0x1 ? &ppu.fg : &ppu.bg;
299 298
 		Uint8 mode = d->dat[0xe] >> 5;
300 299
 		if(!mode)
301 300
 			putpixel(&ppu, layer, x, y, d->dat[0xe] & 0x3);
302
-		else if(mode-- & 0x1)
303
-			puticn(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
304
-		else
305
-			putchr(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
301
+		else {
302
+			Uint8 *addr = &d->mem[mempeek16(d->dat, 0xc)];
303
+			if(mode-- & 0x1)
304
+				puticn(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
305
+			else
306
+				putchr(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
307
+		}
306 308
 		reqdraw = 1;
307 309
 	}
308 310
 }