changeset 2283:6f6f21d0c396

Fix missing address masks on some VRAM reads
author Michael Pavone <pavone@retrodev.com>
date Mon, 09 Jan 2023 00:15:26 -0800
parents a6a68c33cce7
children 5a53a8453241
files vdp.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Mon Jan 09 00:08:32 2023 -0800
+++ b/vdp.c	Mon Jan 09 00:15:26 2023 -0800
@@ -1152,13 +1152,14 @@
 		{
 		case VRAM_READ:
 			if (context->flags2 & FLAG2_READ_PENDING) {
-				context->prefetch |= context->vdpmem[context->address | 1];
+				//TODO: 128K VRAM support
+				context->prefetch |= context->vdpmem[(context->address & 0xFFFE) | 1];
 				context->flags |= FLAG_READ_FETCHED;
 				context->flags2 &= ~FLAG2_READ_PENDING;
 				//Should this happen after the prefetch or after the read?
 				increment_address(context);
 			} else {
-				//TODO: 128K VRAM Mode
+				//TODO: 128K VRAM support
 				context->prefetch = context->vdpmem[context->address & 0xFFFE] << 8;
 				context->flags2 |= FLAG2_READ_PENDING;
 			}
@@ -1168,7 +1169,8 @@
 			if (!(context->regs[REG_MODE_2] & BIT_MODE_5)) {
 				address = mode4_address_map[address & 0x3FFF];
 			}
-			context->prefetch = context->vdpmem[address];
+			//TODO: 128K VRAM support
+			context->prefetch = context->vdpmem[context->address & 0xFFFF];
 			context->prefetch |= context->fifo[context->fifo_write].value & 0xFF00;
 			context->flags |= FLAG_READ_FETCHED;
 			//Should this happen after the prefetch or after the read?