diff z80_to_x86.c @ 335:14a937097c2b

Some Z80 interrupt fixes
author Mike Pavone <pavone@retrodev.com>
date Tue, 14 May 2013 21:59:56 -0700
parents 684e71e9f0d0
children c42fae88d346
line wrap: on
line diff
--- a/z80_to_x86.c	Tue May 14 00:46:34 2013 -0700
+++ b/z80_to_x86.c	Tue May 14 21:59:56 2013 -0700
@@ -893,8 +893,11 @@
 	case Z80_EI:
 		//TODO: Implement interrupt enable latency of 1 instruction afer EI
 		dst = zcycles(dst, 4);
+		dst = mov_rrdisp8(dst, ZCYCLES, CONTEXT, offsetof(z80_context, int_enable_cycle), SZ_D);
 		dst = mov_irdisp8(dst, 1, CONTEXT, offsetof(z80_context, iff1), SZ_B);
 		dst = mov_irdisp8(dst, 1, CONTEXT, offsetof(z80_context, iff2), SZ_B);
+		//interrupt enable has a one-instruction latency, minimum instruction duration is 4 cycles
+		dst = add_irdisp8(dst, 4, CONTEXT, offsetof(z80_context, int_enable_cycle), SZ_D);
 		dst = call(dst, (uint8_t *)z80_do_sync);
 		break;
 	case Z80_IM: