Mercurial > repos > blastem
diff z80_to_x86.c @ 819:ab017fb09e77
Added support for an IO memory map in Z80 core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 29 Jul 2015 00:03:36 -0700 |
parents | 724bbec47f86 |
children | 21a69dfb6ee7 |
line wrap: on
line diff
--- a/z80_to_x86.c Wed Jul 29 00:03:09 2015 -0700 +++ b/z80_to_x86.c Wed Jul 29 00:03:36 2015 -0700 @@ -339,7 +339,7 @@ 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 @@ } 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 @@ *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 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 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;