diff backend_x86.c @ 620:9d6fed6501ba

Fix handling of code writes for Z80 core. This seems to get things close to being back to where they were before the big refactor that broke the Z80 core. Some problems remain. Notably the sound driver in Sonic 2 is still quite broken.
author Michael Pavone <pavone@retrodev.com>
date Mon, 29 Dec 2014 23:08:39 -0800
parents 39d7d463ed5b
children 6aa29ac33f1a
line wrap: on
line diff
--- a/backend_x86.c	Mon Dec 29 21:36:17 2014 -0800
+++ b/backend_x86.c	Mon Dec 29 23:08:39 2014 -0800
@@ -200,9 +200,8 @@
 				}
 			}
 			if (is_write && (memmap[chunk].flags & MMAP_CODE)) {
-				//TODO: Fixme for Z80
 				mov_rr(code, opts->scratch2, opts->scratch1, opts->address_size);
-				shr_ir(code, 11, opts->scratch1, opts->address_size);
+				shr_ir(code, opts->ram_flags_shift, opts->scratch1, opts->address_size);
 				bt_rrdisp(code, opts->scratch1, opts->context_reg, opts->ram_flags_off, opts->address_size);
 				code_ptr not_code = code->cur + 1;
 				jcc(code, CC_NC, code->cur + 2);
@@ -210,6 +209,10 @@
 #ifdef X86_32
 				push_r(code, opts->context_reg);
 				push_r(code, opts->scratch2);
+#else
+				if (opts->scratch2 != RDI) {
+					mov_rr(code, opts->scratch2, RDI, opts->address_size);
+				}
 #endif
 				call(code, opts->handle_code_write);
 #ifdef X86_32