Browse code

Rewritten screen_talk with switch

Andrew Alderwick authored on 19/09/2021 21:51:35
Showing 1 changed files
... ...
@@ -345,32 +345,40 @@ screen_talk(Device *d, Uint8 b0, Uint8 w)
345 345
 {
346 346
 	if(!w)
347 347
 		return 1;
348
-	if(b0 == 0x3)
349
-		set_size(peek16(d->dat, 0x2), ppu.height);
350
-	else if(b0 == 0x5)
351
-		set_size(ppu.width, peek16(d->dat, 0x4));
352
-	else if(b0 == 0xe) {
353
-		Uint16 x = peek16(d->dat, 0x8);
354
-		Uint16 y = peek16(d->dat, 0xa);
355
-		Uint8 layer = d->dat[0xe] & 0x40;
356
-		reqdraw |= ppu_pixel(&ppu, layer ? ppu.fg : ppu.bg, x, y, d->dat[0xe] & 0x3);
357
-		if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 1); /* auto x+1 */
358
-		if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 1); /* auto y+1 */
359
-	} else if(b0 == 0xf) {
360
-		Uint16 x = peek16(d->dat, 0x8);
361
-		Uint16 y = peek16(d->dat, 0xa);
362
-		Uint8 layer = d->dat[0xf] & 0x40;
363
-		Uint8 *addr = &d->mem[peek16(d->dat, 0xc)];
364
-		if(d->dat[0xf] & 0x80) {
365
-			reqdraw |= ppu_2bpp(&ppu, layer ? ppu.fg : ppu.bg, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20);
366
-			if(d->dat[0x6] & 0x04) poke16(d->dat, 0xc, peek16(d->dat, 0xc) + 16); /* auto addr+16 */
367
-		} else {
368
-			reqdraw |= ppu_1bpp(&ppu, layer ? ppu.fg : ppu.bg, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20);
369
-			if(d->dat[0x6] & 0x04) poke16(d->dat, 0xc, peek16(d->dat, 0xc) + 8); /* auto addr+8 */
348
+	else
349
+		switch(b0) {
350
+		case 0x3:
351
+			set_size(peek16(d->dat, 0x2), ppu.height);
352
+			break;
353
+		case 0x5:
354
+			set_size(ppu.width, peek16(d->dat, 0x4));
355
+			break;
356
+		case 0xe: {
357
+			Uint16 x = peek16(d->dat, 0x8);
358
+			Uint16 y = peek16(d->dat, 0xa);
359
+			Uint8 layer = d->dat[0xe] & 0x40;
360
+			reqdraw |= ppu_pixel(&ppu, layer ? ppu.fg : ppu.bg, x, y, d->dat[0xe] & 0x3);
361
+			if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 1); /* auto x+1 */
362
+			if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 1); /* auto y+1 */
363
+			break;
364
+		}
365
+		case 0xf: {
366
+			Uint16 x = peek16(d->dat, 0x8);
367
+			Uint16 y = peek16(d->dat, 0xa);
368
+			Uint8 layer = d->dat[0xf] & 0x40;
369
+			Uint8 *addr = &d->mem[peek16(d->dat, 0xc)];
370
+			if(d->dat[0xf] & 0x80) {
371
+				reqdraw |= ppu_2bpp(&ppu, layer ? ppu.fg : ppu.bg, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20);
372
+				if(d->dat[0x6] & 0x04) poke16(d->dat, 0xc, peek16(d->dat, 0xc) + 16); /* auto addr+16 */
373
+			} else {
374
+				reqdraw |= ppu_1bpp(&ppu, layer ? ppu.fg : ppu.bg, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20);
375
+				if(d->dat[0x6] & 0x04) poke16(d->dat, 0xc, peek16(d->dat, 0xc) + 8); /* auto addr+8 */
376
+			}
377
+			if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 8); /* auto x+8 */
378
+			if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 8); /* auto y+8 */
379
+			break;
380
+		}
370 381
 		}
371
-		if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 8); /* auto x+8 */
372
-		if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 8); /* auto y+8 */
373
-	}
374 382
 	return 1;
375 383
 }
376 384