diff z80_to_x86.c @ 259:d9417261366f

Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
author Mike Pavone <pavone@retrodev.com>
date Tue, 30 Apr 2013 00:39:20 -0700
parents 4c7933444df4
children f0c53a4bbfa3
line wrap: on
line diff
--- a/z80_to_x86.c	Tue Apr 30 00:37:30 2013 -0700
+++ b/z80_to_x86.c	Tue Apr 30 00:39:20 2013 -0700
@@ -70,7 +70,7 @@
 	dst = cmp_rr(dst, ZCYCLES, ZLIMIT, SZ_D);
 	uint8_t * jmp_off = dst+1;
 	dst = jcc(dst, CC_NC, dst + 7);
-	dst = mov_ir(dst, address, SCRATCH2, SZ_W);
+	dst = mov_ir(dst, address, SCRATCH1, SZ_W);
 	dst = call(dst, (uint8_t *)z80_handle_cycle_limit_int);
 	*jmp_off = dst - (jmp_off+1);
 	return dst;
@@ -1166,6 +1166,9 @@
 		char disbuf[80];
 		z80_disasm(inst, disbuf);
 		fprintf(stderr, "unimplemented instruction: %s\n", disbuf);
+		FILE * f = fopen("zram.bin", "wb");
+		fwrite(context->mem_pointers[0], 1, 8 * 1024, f);
+		fclose(f);
 		exit(1);
 	}
 	}
@@ -1436,14 +1439,18 @@
 {
 	memset(context, 0, sizeof(*context));
 	context->static_code_map = malloc(sizeof(context->static_code_map));
+	context->static_code_map->base = NULL;
 	context->static_code_map->offsets = malloc(sizeof(int32_t) * 0x2000);
 	memset(context->static_code_map->offsets, 0xFF, sizeof(int32_t) * 0x2000);
 	context->banked_code_map = malloc(sizeof(native_map_slot) * (1 << 9));
+	memset(context->banked_code_map, 0, sizeof(native_map_slot) * (1 << 9));
 	context->options = options;
 }
 
 void z80_reset(z80_context * context)
 {
+	context->im = 0;
+	context->iff1 = context->iff2 = 0;
 	context->native_pc = z80_get_native_address_trans(context, 0);
 }