changeset 659:759c38bf97f8

Minor Z80 core cleanup
author Michael Pavone <pavone@retrodev.com>
date Thu, 01 Jan 2015 20:26:22 -0800
parents 6aa29ac33f1a
children e7cae6d9aaa6
files blastem.c transz80.c z80_to_x86.c z80_to_x86.h ztestrun.c
diffstat 5 files changed, 9 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/blastem.c	Thu Jan 01 20:21:20 2015 -0800
+++ b/blastem.c	Thu Jan 01 20:26:22 2015 -0800
@@ -1352,7 +1352,7 @@
 	z80_context z_context;
 #ifndef NO_Z80
 	z80_options z_opts;
-	init_x86_z80_opts(&z_opts, z80_map, 5);
+	init_z80_opts(&z_opts, z80_map, 5);
 	init_z80_context(&z_context, &z_opts);
 #endif
 
--- a/transz80.c	Thu Jan 01 20:21:20 2015 -0800
+++ b/transz80.c	Thu Jan 01 20:26:22 2015 -0800
@@ -38,7 +38,7 @@
 {
 	long filesize;
 	uint8_t *filebuf;
-	x86_z80_options opts;
+	z80_options opts;
 	z80_context context;
 	if (argc < 2) {
 		fputs("usage: transz80 zrom [cartrom]\n", stderr);
@@ -70,7 +70,7 @@
 			*cur = (*cur >> 8) | (*cur << 8);
 		}
 	}
-	init_x86_z80_opts(&opts);
+	init_z80_opts(&opts);
 	init_z80_context(&context, &opts);
 	//Z80 RAM
 	context.mem_pointers[0] = z80_ram;
--- a/z80_to_x86.c	Thu Jan 01 20:21:20 2015 -0800
+++ b/z80_to_x86.c	Thu Jan 01 20:26:22 2015 -0800
@@ -14,12 +14,6 @@
 
 #define MODE_UNUSED (MODE_IMMED-1)
 
-#define ZCYCLES RBP
-#define ZLIMIT RDI
-#define SCRATCH1 R13
-#define SCRATCH2 R14
-#define CONTEXT RSI
-
 //#define DO_DEBUG_PRINT
 
 #ifdef DO_DEBUG_PRINT
@@ -138,7 +132,7 @@
 			}
 		} else {
 			ea->mode = MODE_REG_DISPLACE8;
-			ea->base = CONTEXT;
+			ea->base = opts->gen.context_reg;
 			ea->disp = offsetof(z80_context, regs) + inst->ea_reg;
 		}
 		break;
@@ -368,7 +362,7 @@
 			setcc_rdisp(code, CC_Z, opts->gen.context_reg, zf_off(ZF_Z));
 			setcc_rdisp(code, CC_S, opts->gen.context_reg, zf_off(ZF_S));
 			mov_irdisp(code, 0, opts->gen.context_reg, zf_off(ZF_N), SZ_B);;
-			mov_rdispr(code, opts->gen.context_reg, offsetof(z80_context, iff2), SCRATCH1, SZ_B);
+			mov_rdispr(code, opts->gen.context_reg, offsetof(z80_context, iff2), opts->gen.scratch1, SZ_B);
 			mov_rrdisp(code, opts->gen.scratch1, opts->gen.context_reg, zf_off(ZF_PV), SZ_B);
 		}
 		z80_save_reg(inst, opts);
@@ -1926,7 +1920,7 @@
 	} while (opts->gen.deferred);
 }
 
-void init_x86_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks)
+void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks)
 {
 	memset(options, 0, sizeof(*options));
 
@@ -2263,7 +2257,7 @@
 uint32_t zbreakpoint_patch(z80_context * context, uint16_t address, code_ptr dst)
 {
 	code_info code = {dst, dst+16};
-	mov_ir(&code, address, SCRATCH1, SZ_W);
+	mov_ir(&code, address, context->options->gen.scratch1, SZ_W);
 	call(&code, context->bp_stub);
 	return code.cur-dst;
 }
--- a/z80_to_x86.h	Thu Jan 01 20:21:20 2015 -0800
+++ b/z80_to_x86.h	Thu Jan 01 20:26:22 2015 -0800
@@ -84,7 +84,7 @@
 } z80_context;
 
 void translate_z80_stream(z80_context * context, uint32_t address);
-void init_x86_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks);
+void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks);
 void init_z80_context(z80_context * context, z80_options * options);
 code_ptr z80_get_native_address(z80_context * context, uint32_t address);
 code_ptr z80_get_native_address_trans(z80_context * context, uint32_t address);
--- a/ztestrun.c	Thu Jan 01 20:21:20 2015 -0800
+++ b/ztestrun.c	Thu Jan 01 20:26:22 2015 -0800
@@ -53,7 +53,7 @@
 	fseek(f, 0, SEEK_SET);
 	fread(z80_ram, 1, filesize < sizeof(z80_ram) ? filesize : sizeof(z80_ram), f);
 	fclose(f);
-	init_x86_z80_opts(&opts, z80_map, 2);
+	init_z80_opts(&opts, z80_map, 2);
 	init_z80_context(&context, &opts);
 	//Z80 RAM
 	context.mem_pointers[0] = z80_ram;