Mercurial > repos > blastem
diff m68k_core.c @ 985:751280fb4494
Fix interrupt latency from STOP instruction status reg changes. Fix modified code patching when non-standard aliases are used. This fixes the demo MDEM's First
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 24 Apr 2016 21:23:28 -0700 |
parents | 902c53d9c16f |
children | f680fe746a7d |
line wrap: on
line diff
--- a/m68k_core.c Sun Apr 24 14:30:15 2016 -0700 +++ b/m68k_core.c Sun Apr 24 21:23:28 2016 -0700 @@ -547,6 +547,13 @@ if (address & 1) { return opts->odd_address; } + //TODO: Refactor part of this loop into some kind of get_ram_chunk function + for (int i = 0; i < opts->gen.memmap_chunks; i++) { + if (address >= opts->gen.memmap[i].start && address < opts->gen.memmap[i].end) { + //calculate the lowest alias for this address + address = opts->gen.memmap[i].start + ((address - opts->gen.memmap[i].start) & opts->gen.memmap[i].mask); + } + } address /= 2; uint32_t chunk = address / NATIVE_CHUNK_SIZE; if (!native_code_map[chunk].base) { @@ -564,10 +571,17 @@ return get_native_address(context->options, address); } -uint32_t get_instruction_start(native_map_slot * native_code_map, uint32_t address) +uint32_t get_instruction_start(m68k_options *opts, native_map_slot * native_code_map, uint32_t address) { - //FIXME: Use opts->gen.address_mask - address &= 0xFFFFFF; + address &= opts->gen.address_mask; + //TODO: Refactor part of this loop into some kind of get_ram_chunk function + for (int i = 0; i < opts->gen.memmap_chunks; i++) { + if (address >= opts->gen.memmap[i].start && address < opts->gen.memmap[i].end) { + //calculate the lowest alias for this address + address = opts->gen.memmap[i].start + ((address - opts->gen.memmap[i].start) & opts->gen.memmap[i].mask); + } + } + address /= 2; uint32_t chunk = address / NATIVE_CHUNK_SIZE; if (!native_code_map[chunk].base) { @@ -612,6 +626,8 @@ ram_flags_off = final_off >> (opts->gen.ram_flags_shift + 3); context->ram_code_flags[ram_flags_off] |= 1 << ((final_off >> opts->gen.ram_flags_shift) & 7); } + //calculate the lowest alias for this address + address = opts->gen.memmap[i].start + ((address - opts->gen.memmap[i].start) & opts->gen.memmap[i].mask); break; } else if ((opts->gen.memmap[i].flags & (MMAP_WRITE | MMAP_CODE)) == (MMAP_WRITE | MMAP_CODE)) { uint32_t size = chunk_size(&opts->gen, opts->gen.memmap + i);