comparison vdp.c @ 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 c7781cc950e9
children 57ebbc1ade30
comparison
equal deleted inserted replaced
2282:a6a68c33cce7 2283:6f6f21d0c396
1150 } else if (!(context->cd & 1) && !(context->flags & (FLAG_READ_FETCHED|FLAG_PENDING)) && context->read_latency <= context->cycles) { 1150 } else if (!(context->cd & 1) && !(context->flags & (FLAG_READ_FETCHED|FLAG_PENDING)) && context->read_latency <= context->cycles) {
1151 switch(context->cd & 0xF) 1151 switch(context->cd & 0xF)
1152 { 1152 {
1153 case VRAM_READ: 1153 case VRAM_READ:
1154 if (context->flags2 & FLAG2_READ_PENDING) { 1154 if (context->flags2 & FLAG2_READ_PENDING) {
1155 context->prefetch |= context->vdpmem[context->address | 1]; 1155 //TODO: 128K VRAM support
1156 context->prefetch |= context->vdpmem[(context->address & 0xFFFE) | 1];
1156 context->flags |= FLAG_READ_FETCHED; 1157 context->flags |= FLAG_READ_FETCHED;
1157 context->flags2 &= ~FLAG2_READ_PENDING; 1158 context->flags2 &= ~FLAG2_READ_PENDING;
1158 //Should this happen after the prefetch or after the read? 1159 //Should this happen after the prefetch or after the read?
1159 increment_address(context); 1160 increment_address(context);
1160 } else { 1161 } else {
1161 //TODO: 128K VRAM Mode 1162 //TODO: 128K VRAM support
1162 context->prefetch = context->vdpmem[context->address & 0xFFFE] << 8; 1163 context->prefetch = context->vdpmem[context->address & 0xFFFE] << 8;
1163 context->flags2 |= FLAG2_READ_PENDING; 1164 context->flags2 |= FLAG2_READ_PENDING;
1164 } 1165 }
1165 break; 1166 break;
1166 case VRAM_READ8: { 1167 case VRAM_READ8: {
1167 uint32_t address = context->address ^ 1; 1168 uint32_t address = context->address ^ 1;
1168 if (!(context->regs[REG_MODE_2] & BIT_MODE_5)) { 1169 if (!(context->regs[REG_MODE_2] & BIT_MODE_5)) {
1169 address = mode4_address_map[address & 0x3FFF]; 1170 address = mode4_address_map[address & 0x3FFF];
1170 } 1171 }
1171 context->prefetch = context->vdpmem[address]; 1172 //TODO: 128K VRAM support
1173 context->prefetch = context->vdpmem[context->address & 0xFFFF];
1172 context->prefetch |= context->fifo[context->fifo_write].value & 0xFF00; 1174 context->prefetch |= context->fifo[context->fifo_write].value & 0xFF00;
1173 context->flags |= FLAG_READ_FETCHED; 1175 context->flags |= FLAG_READ_FETCHED;
1174 //Should this happen after the prefetch or after the read? 1176 //Should this happen after the prefetch or after the read?
1175 increment_address(context); 1177 increment_address(context);
1176 break; 1178 break;