summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-07-29 00:03:36 -0700
committerMichael Pavone <pavone@retrodev.com>2015-07-29 00:03:36 -0700
commit7f3358e31c30e519a45258917fc419e57b4ca422 (patch)
tree1aab73cdc491d9c1418aa6295ba6281c815fb8c3
parentbb8d28d9fbb19dc79247f82af1c2fc42ff13e691 (diff)
Added support for an IO memory map in Z80 core
-rw-r--r--blastem.c2
-rw-r--r--z80_to_x86.c31
-rw-r--r--z80_to_x86.h2
-rw-r--r--ztestrun.c2
4 files changed, 16 insertions, 21 deletions
diff --git a/blastem.c b/blastem.c
index e362cfc..3306c60 100644
--- a/blastem.c
+++ b/blastem.c
@@ -1037,7 +1037,7 @@ int main(int argc, char ** argv)
z80_context z_context;
#ifndef NO_Z80
z80_options z_opts;
- init_z80_opts(&z_opts, z80_map, 5, MCLKS_PER_Z80);
+ init_z80_opts(&z_opts, z80_map, 5, NULL, 0, MCLKS_PER_Z80);
init_z80_context(&z_context, &z_opts);
z80_assert_reset(&z_context, 0);
#endif
diff --git a/z80_to_x86.c b/z80_to_x86.c
index 7205d16..6556cb3 100644
--- a/z80_to_x86.c
+++ b/z80_to_x86.c
@@ -339,7 +339,7 @@ void translate_z80inst(z80inst * inst, z80_context * context, uint16_t address,
code_info *code = &opts->gen.code;
if (!interp) {
check_cycles_int(&opts->gen, address);
- if (context->breakpoint_flags[address / sizeof(uint8_t)] & (1 << (address % sizeof(uint8_t)))) {
+ if (context->breakpoint_flags[address / 8] & (1 << (address % 8))) {
zbreakpoint_patch(context, address, start);
}
#ifdef Z80_LOG_ADDRESS
@@ -2244,7 +2244,7 @@ void translate_z80_stream(z80_context * context, uint32_t address)
} while (opts->gen.deferred);
}
-void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, uint32_t clock_divider)
+void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, memmap_chunk const * io_chunks, uint32_t num_io_chunks, uint32_t clock_divider)
{
memset(options, 0, sizeof(*options));
@@ -2451,18 +2451,13 @@ void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t
*skip_sync = code->cur - (skip_sync+1);
retn(code);
- options->read_io = code->cur;
- check_cycles(&options->gen);
- cycles(&options->gen, 4);
- //Genesis has no IO hardware and always returns FF
- //eventually this should use a second memory map array
- mov_ir(code, 0xFF, options->gen.scratch1, SZ_B);
- retn(code);
-
- options->write_io = code->cur;
- check_cycles(&options->gen);
- cycles(&options->gen, 4);
- retn(code);
+ //HACK
+ options->gen.address_size = SZ_D;
+ options->gen.address_mask = 0xFF;
+ options->read_io = gen_mem_fun(&options->gen, io_chunks, num_io_chunks, READ_8, NULL);
+ options->write_io = gen_mem_fun(&options->gen, io_chunks, num_io_chunks, WRITE_8, NULL);
+ options->gen.address_size = SZ_W;
+ options->gen.address_mask = 0xFFFF;
options->read_16 = code->cur;
cycles(&options->gen, 3);
@@ -2722,9 +2717,9 @@ void zcreate_stub(z80_context * context)
void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler)
{
context->bp_handler = bp_handler;
- uint8_t bit = 1 << (address % sizeof(uint8_t));
- if (!(bit & context->breakpoint_flags[address / sizeof(uint8_t)])) {
- context->breakpoint_flags[address / sizeof(uint8_t)] |= bit;
+ uint8_t bit = 1 << (address % 8);
+ if (!(bit & context->breakpoint_flags[address / 8])) {
+ context->breakpoint_flags[address / 8] |= bit;
if (!context->bp_stub) {
zcreate_stub(context);
}
@@ -2737,7 +2732,7 @@ void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_ha
void zremove_breakpoint(z80_context * context, uint16_t address)
{
- context->breakpoint_flags[address / sizeof(uint8_t)] &= ~(1 << (address % sizeof(uint8_t)));
+ context->breakpoint_flags[address / 8] &= ~(1 << (address % 8));
uint8_t * native = z80_get_native_address(context, address);
if (native) {
z80_options * opts = context->options;
diff --git a/z80_to_x86.h b/z80_to_x86.h
index a940bb7..51da4b0 100644
--- a/z80_to_x86.h
+++ b/z80_to_x86.h
@@ -87,7 +87,7 @@ typedef struct {
} z80_context;
void translate_z80_stream(z80_context * context, uint32_t address);
-void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, uint32_t clock_divider);
+void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, memmap_chunk const * io_chunks, uint32_t num_io_chunks, uint32_t clock_divider);
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 0e262d3..f169fcb 100644
--- a/ztestrun.c
+++ b/ztestrun.c
@@ -75,7 +75,7 @@ int main(int argc, char ** argv)
exit(1);
}
fclose(f);
- init_z80_opts(&opts, z80_map, 2, 1);
+ init_z80_opts(&opts, z80_map, 2, NULL, 0, 1);
init_z80_context(&context, &opts);
//Z80 RAM
context.mem_pointers[0] = z80_ram;