Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
818:a634ed0a92cf | 819:ab017fb09e77 |
---|---|
337 z80_options *opts = context->options; | 337 z80_options *opts = context->options; |
338 uint8_t * start = opts->gen.code.cur; | 338 uint8_t * start = opts->gen.code.cur; |
339 code_info *code = &opts->gen.code; | 339 code_info *code = &opts->gen.code; |
340 if (!interp) { | 340 if (!interp) { |
341 check_cycles_int(&opts->gen, address); | 341 check_cycles_int(&opts->gen, address); |
342 if (context->breakpoint_flags[address / sizeof(uint8_t)] & (1 << (address % sizeof(uint8_t)))) { | 342 if (context->breakpoint_flags[address / 8] & (1 << (address % 8))) { |
343 zbreakpoint_patch(context, address, start); | 343 zbreakpoint_patch(context, address, start); |
344 } | 344 } |
345 #ifdef Z80_LOG_ADDRESS | 345 #ifdef Z80_LOG_ADDRESS |
346 log_address(&opts->gen, address, "Z80: %X @ %d\n"); | 346 log_address(&opts->gen, address, "Z80: %X @ %d\n"); |
347 #endif | 347 #endif |
2242 dprintf("defferred address: %X\n", address); | 2242 dprintf("defferred address: %X\n", address); |
2243 } | 2243 } |
2244 } while (opts->gen.deferred); | 2244 } while (opts->gen.deferred); |
2245 } | 2245 } |
2246 | 2246 |
2247 void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, uint32_t clock_divider) | 2247 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) |
2248 { | 2248 { |
2249 memset(options, 0, sizeof(*options)); | 2249 memset(options, 0, sizeof(*options)); |
2250 | 2250 |
2251 options->gen.memmap = chunks; | 2251 options->gen.memmap = chunks; |
2252 options->gen.memmap_chunks = num_chunks; | 2252 options->gen.memmap_chunks = num_chunks; |
2449 restore_callee_save_regs(code); | 2449 restore_callee_save_regs(code); |
2450 //return to caller of z80_run | 2450 //return to caller of z80_run |
2451 *skip_sync = code->cur - (skip_sync+1); | 2451 *skip_sync = code->cur - (skip_sync+1); |
2452 retn(code); | 2452 retn(code); |
2453 | 2453 |
2454 options->read_io = code->cur; | 2454 //HACK |
2455 check_cycles(&options->gen); | 2455 options->gen.address_size = SZ_D; |
2456 cycles(&options->gen, 4); | 2456 options->gen.address_mask = 0xFF; |
2457 //Genesis has no IO hardware and always returns FF | 2457 options->read_io = gen_mem_fun(&options->gen, io_chunks, num_io_chunks, READ_8, NULL); |
2458 //eventually this should use a second memory map array | 2458 options->write_io = gen_mem_fun(&options->gen, io_chunks, num_io_chunks, WRITE_8, NULL); |
2459 mov_ir(code, 0xFF, options->gen.scratch1, SZ_B); | 2459 options->gen.address_size = SZ_W; |
2460 retn(code); | 2460 options->gen.address_mask = 0xFFFF; |
2461 | |
2462 options->write_io = code->cur; | |
2463 check_cycles(&options->gen); | |
2464 cycles(&options->gen, 4); | |
2465 retn(code); | |
2466 | 2461 |
2467 options->read_16 = code->cur; | 2462 options->read_16 = code->cur; |
2468 cycles(&options->gen, 3); | 2463 cycles(&options->gen, 3); |
2469 check_cycles(&options->gen); | 2464 check_cycles(&options->gen); |
2470 //TODO: figure out how to handle the extra wait state for word reads to bank area | 2465 //TODO: figure out how to handle the extra wait state for word reads to bank area |
2720 } | 2715 } |
2721 | 2716 |
2722 void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler) | 2717 void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler) |
2723 { | 2718 { |
2724 context->bp_handler = bp_handler; | 2719 context->bp_handler = bp_handler; |
2725 uint8_t bit = 1 << (address % sizeof(uint8_t)); | 2720 uint8_t bit = 1 << (address % 8); |
2726 if (!(bit & context->breakpoint_flags[address / sizeof(uint8_t)])) { | 2721 if (!(bit & context->breakpoint_flags[address / 8])) { |
2727 context->breakpoint_flags[address / sizeof(uint8_t)] |= bit; | 2722 context->breakpoint_flags[address / 8] |= bit; |
2728 if (!context->bp_stub) { | 2723 if (!context->bp_stub) { |
2729 zcreate_stub(context); | 2724 zcreate_stub(context); |
2730 } | 2725 } |
2731 uint8_t * native = z80_get_native_address(context, address); | 2726 uint8_t * native = z80_get_native_address(context, address); |
2732 if (native) { | 2727 if (native) { |
2735 } | 2730 } |
2736 } | 2731 } |
2737 | 2732 |
2738 void zremove_breakpoint(z80_context * context, uint16_t address) | 2733 void zremove_breakpoint(z80_context * context, uint16_t address) |
2739 { | 2734 { |
2740 context->breakpoint_flags[address / sizeof(uint8_t)] &= ~(1 << (address % sizeof(uint8_t))); | 2735 context->breakpoint_flags[address / 8] &= ~(1 << (address % 8)); |
2741 uint8_t * native = z80_get_native_address(context, address); | 2736 uint8_t * native = z80_get_native_address(context, address); |
2742 if (native) { | 2737 if (native) { |
2743 z80_options * opts = context->options; | 2738 z80_options * opts = context->options; |
2744 code_info tmp_code = opts->gen.code; | 2739 code_info tmp_code = opts->gen.code; |
2745 opts->gen.code.cur = native; | 2740 opts->gen.code.cur = native; |