changeset 672:18ef3b61e70b

Restore emulation of Z80 being locked out of the 68K bus during DMA and the like
author Michael Pavone <pavone@retrodev.com>
date Sat, 03 Jan 2015 20:20:15 -0800
parents 8ad39a2b0bce
children 7f1b5570b2a1
files blastem.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/blastem.c	Sat Jan 03 20:13:51 2015 -0800
+++ b/blastem.c	Sat Jan 03 20:20:15 2015 -0800
@@ -666,12 +666,15 @@
 uint8_t z80_read_bank(uint32_t location, void * vcontext)
 {
 	z80_context * context = vcontext;
+	genesis_context *gen = context->system;
+	if (gen->bus_busy) {
+		context->current_cycle = context->sync_cycle;
+	}
 	//typical delay from bus arbitration
 	context->current_cycle += 3 * MCLKS_PER_Z80;
+	//TODO: add cycle for an access right after a previous one
 
 	location &= 0x7FFF;
-	//TODO: add cycle for an access right after a previous one
-	//TODO: block Z80 if VDP has the bus or the 68K is blocked on a VDP access
 	if (context->mem_pointers[1]) {
 		return context->mem_pointers[1][location ^ 1];
 	}
@@ -687,11 +690,15 @@
 void *z80_write_bank(uint32_t location, void * vcontext, uint8_t value)
 {
 	z80_context * context = vcontext;
+	genesis_context *gen = context->system;
+	if (gen->bus_busy) {
+		context->current_cycle = context->sync_cycle;
+	}
 	//typical delay from bus arbitration
 	context->current_cycle += 3 * MCLKS_PER_Z80;
+	//TODO: add cycle for an access right after a previous one
+
 	location &= 0x7FFF;
-	//TODO: add cycle for an access right after a previous one
-	//TODO: block Z80 if VDP has the bus or the 68K is blocked on a VDP access
 	uint32_t address = context->bank_reg << 15 | location;
 	if (address >= 0xE00000) {
 		address &= 0xFFFF;