# HG changeset patch # User Michael Pavone # Date 1418886199 28800 # Node ID 4ff7bbb3943b403de5b94cfc34663f3ac7f16caa # Parent 966b46c68942707dd4e2a52057d5f292a66a33ef Get rest of emulator compiling again with Z80 core enabled diff -r 966b46c68942 -r 4ff7bbb3943b backend.h --- a/backend.h Wed Dec 17 09:53:51 2014 -0800 +++ b/backend.h Wed Dec 17 23:03:19 2014 -0800 @@ -79,6 +79,7 @@ #define MMAP_ONLY_ODD 0x10 #define MMAP_ONLY_EVEN 0x20 #define MMAP_FUNC_NULL 0x40 +#define MMAP_CUSTOM 0x80 typedef uint16_t (*read_16_fun)(uint32_t address, void * context); typedef uint8_t (*read_8_fun)(uint32_t address, void * context); diff -r 966b46c68942 -r 4ff7bbb3943b blastem.c --- a/blastem.c Wed Dec 17 09:53:51 2014 -0800 +++ b/blastem.c Wed Dec 17 23:03:19 2014 -0800 @@ -383,8 +383,9 @@ return vdp_port_write(vdp_port, context, vdp_port < 0x10 ? value | value << 8 : ((vdp_port & 1) ? value : 0)); } -z80_context * z80_vdp_port_write(uint16_t vdp_port, z80_context * context, uint8_t value) +void * z80_vdp_port_write(uint32_t vdp_port, void * vcontext, uint8_t value) { + z80_context * context = vcontext; genesis_context * gen = context->system; if (vdp_port & 0xE0) { printf("machine freeze due to write to Z80 address %X\n", 0x7F00 | vdp_port); @@ -453,6 +454,34 @@ } } +uint8_t z80_vdp_port_read(uint32_t vdp_port, void * vcontext) +{ + z80_context * context = vcontext; + if (vdp_port & 0xE0) { + printf("machine freeze due to read from Z80 address %X\n", 0x7F00 | vdp_port); + exit(1); + } + genesis_context * gen = context->system; + vdp_port &= 0x1F; + uint16_t ret; + if (vdp_port < 0x10) { + //These probably won't currently interact well with the 68K accessing the VDP + vdp_run_context(gen->vdp, context->current_cycle * MCLKS_PER_Z80); + if (vdp_port < 4) { + ret = vdp_data_port_read(gen->vdp); + } else if (vdp_port < 8) { + ret = vdp_control_port_read(gen->vdp); + } else { + printf("Illegal write to HV Counter port %X\n", vdp_port); + exit(1); + } + } else { + //TODO: Figure out the correct value today + ret = 0xFFFF; + } + return vdp_port & 1 ? ret : ret >> 8; +} + uint32_t zram_counter = 0; #define Z80_ACK_DELAY 3 #define Z80_BUSY_DELAY 1//TODO: Find the actual value for this @@ -674,8 +703,9 @@ return value; } -z80_context * z80_write_ym(uint16_t location, z80_context * context, uint8_t value) +void * z80_write_ym(uint32_t location, void * vcontext, uint8_t value) { + z80_context * context = vcontext; genesis_context * gen = context->system; sync_sound(gen, context->current_cycle * MCLKS_PER_Z80); if (location & 1) { @@ -688,13 +718,28 @@ return context; } -uint8_t z80_read_ym(uint16_t location, z80_context * context) +uint8_t z80_read_ym(uint32_t location, void * vcontext) { + z80_context * context = vcontext; genesis_context * gen = context->system; sync_sound(gen, context->current_cycle * MCLKS_PER_Z80); return ym_read_status(gen->ym); } +uint8_t z80_read_bank(uint32_t location, void * vcontext) +{ + z80_context * context = vcontext; + //TODO: Implement me + return 0; +} + +void *z80_write_bank(uint32_t location, void * vcontext, uint8_t value) +{ + z80_context * context = vcontext; + //TODO: Implement me + return context; +} + uint16_t read_sram_w(uint32_t address, m68k_context * context) { genesis_context * gen = context->system; diff -r 966b46c68942 -r 4ff7bbb3943b z80_to_x86.c --- a/z80_to_x86.c Wed Dec 17 09:53:51 2014 -0800 +++ b/z80_to_x86.c Wed Dec 17 23:03:19 2014 -0800 @@ -1897,7 +1897,7 @@ } } -void init_x86_z80_opts(z80_options * options, memmap_chunk * chunks, uint32_t num_chunks) +void init_x86_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks) { memset(options, 0, sizeof(*options)); @@ -2069,6 +2069,13 @@ jmp_r(code, options->gen.scratch1); } +void * z80_gen_bank_write(uint32_t start_address, void * voptions) +{ + z80_options * options = voptions; + //TODO: Handle writes to bank register + return options; +} + void init_z80_context(z80_context * context, z80_options * options) { memset(context, 0, sizeof(*context)); diff -r 966b46c68942 -r 4ff7bbb3943b z80_to_x86.h --- a/z80_to_x86.h Wed Dec 17 09:53:51 2014 -0800 +++ b/z80_to_x86.h Wed Dec 17 23:03:19 2014 -0800 @@ -67,7 +67,7 @@ } z80_context; void translate_z80_stream(z80_context * context, uint32_t address); -void init_x86_z80_opts(z80_options * options, memmap_chunk * chunks, uint32_t num_chunks); +void init_x86_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); @@ -76,6 +76,7 @@ void z80_reset(z80_context * context); void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler); void zremove_breakpoint(z80_context * context, uint16_t address); +void * z80_gen_bank_write(uint32_t start_address, void * voptions); #endif //Z80_TO_X86_H_