summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-01-01 20:26:22 -0800
committerMichael Pavone <pavone@retrodev.com>2015-01-01 20:26:22 -0800
commitd41ae43228509a1a67446492b844013cf1e68c36 (patch)
treed944a6076ee2030915a57c28fbd2f3cce060e0d5
parent983a2089cf49d0f6995fb30ca2327d239f21ebb4 (diff)
Minor Z80 core cleanup
-rw-r--r--blastem.c2
-rw-r--r--transz80.c4
-rw-r--r--z80_to_x86.c14
-rw-r--r--z80_to_x86.h2
-rw-r--r--ztestrun.c2
5 files changed, 9 insertions, 15 deletions
diff --git a/blastem.c b/blastem.c
index ddbf8ae..1e396d7 100644
--- a/blastem.c
+++ b/blastem.c
@@ -1352,7 +1352,7 @@ int main(int argc, char ** argv)
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
diff --git a/transz80.c b/transz80.c
index a006a92..eec1736 100644
--- a/transz80.c
+++ b/transz80.c
@@ -38,7 +38,7 @@ int main(int argc, char ** argv)
{
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 @@ int main(int argc, char ** argv)
*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;
diff --git a/z80_to_x86.c b/z80_to_x86.c
index 1912b89..a30adde 100644
--- a/z80_to_x86.c
+++ b/z80_to_x86.c
@@ -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 @@ void translate_z80_ea(z80inst * inst, host_ea * ea, z80_options * opts, uint8_t
}
} 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 @@ void translate_z80inst(z80inst * inst, z80_context * context, uint16_t address,
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 @@ void translate_z80_stream(z80_context * context, uint32_t address)
} 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 @@ void z80_reset(z80_context * context)
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;
}
diff --git a/z80_to_x86.h b/z80_to_x86.h
index 71d6f10..0c035c6 100644
--- a/z80_to_x86.h
+++ b/z80_to_x86.h
@@ -84,7 +84,7 @@ typedef struct {
} 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);
diff --git a/ztestrun.c b/ztestrun.c
index 1c7c6d8..ef042b5 100644
--- a/ztestrun.c
+++ b/ztestrun.c
@@ -53,7 +53,7 @@ int main(int argc, char ** argv)
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;