# HG changeset patch # User Michael Pavone # Date 1419923319 28800 # Node ID 9d6fed6501baf2592e6cf65752a21568d9caf6bf # Parent 3072fb746601565ea5714abcb7d49b806ad6c188 Fix handling of code writes for Z80 core. This seems to get things close to being back to where they were before the big refactor that broke the Z80 core. Some problems remain. Notably the sound driver in Sonic 2 is still quite broken. diff -r 3072fb746601 -r 9d6fed6501ba backend.h --- a/backend.h Mon Dec 29 21:36:17 2014 -0800 +++ b/backend.h Mon Dec 29 23:08:39 2014 -0800 @@ -62,6 +62,7 @@ uint32_t bus_cycles; int32_t mem_ptr_off; int32_t ram_flags_off; + uint8_t ram_flags_shift; uint8_t address_size; uint8_t byte_swap; uint8_t context_reg; diff -r 3072fb746601 -r 9d6fed6501ba backend_x86.c --- a/backend_x86.c Mon Dec 29 21:36:17 2014 -0800 +++ b/backend_x86.c Mon Dec 29 23:08:39 2014 -0800 @@ -200,9 +200,8 @@ } } if (is_write && (memmap[chunk].flags & MMAP_CODE)) { - //TODO: Fixme for Z80 mov_rr(code, opts->scratch2, opts->scratch1, opts->address_size); - shr_ir(code, 11, opts->scratch1, opts->address_size); + shr_ir(code, opts->ram_flags_shift, opts->scratch1, opts->address_size); bt_rrdisp(code, opts->scratch1, opts->context_reg, opts->ram_flags_off, opts->address_size); code_ptr not_code = code->cur + 1; jcc(code, CC_NC, code->cur + 2); @@ -210,6 +209,10 @@ #ifdef X86_32 push_r(code, opts->context_reg); push_r(code, opts->scratch2); +#else + if (opts->scratch2 != RDI) { + mov_rr(code, opts->scratch2, RDI, opts->address_size); + } #endif call(code, opts->handle_code_write); #ifdef X86_32 diff -r 3072fb746601 -r 9d6fed6501ba m68k_core_x86.c --- a/m68k_core_x86.c Mon Dec 29 21:36:17 2014 -0800 +++ b/m68k_core_x86.c Mon Dec 29 23:08:39 2014 -0800 @@ -2237,6 +2237,7 @@ opts->gen.bus_cycles = BUS; opts->gen.mem_ptr_off = offsetof(m68k_context, mem_pointers); opts->gen.ram_flags_off = offsetof(m68k_context, ram_code_flags); + opts->gen.ram_flags_shift = 11; for (int i = 0; i < 8; i++) { opts->dregs[i] = opts->aregs[i] = -1; diff -r 3072fb746601 -r 9d6fed6501ba z80_to_x86.c --- a/z80_to_x86.c Mon Dec 29 21:36:17 2014 -0800 +++ b/z80_to_x86.c Mon Dec 29 23:08:39 2014 -0800 @@ -1907,6 +1907,7 @@ options->gen.bus_cycles = 3; options->gen.mem_ptr_off = offsetof(z80_context, mem_pointers); options->gen.ram_flags_off = offsetof(z80_context, ram_code_flags); + options->gen.ram_flags_shift = 7; options->flags = 0; options->regs[Z80_B] = BH;