diff options
Diffstat (limited to 'z80_util.c')
-rw-r--r-- | z80_util.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -3,13 +3,23 @@ void z80_read_8(z80_context *context) { context->cycles += 3 * context->opts->gen.clock_divider; - context->scratch1 = read_byte(context->scratch1, NULL, &context->opts->gen, context); + uint8_t *fast = context->fastmem[context->scratch1 >> 10]; + if (fast) { + context->scratch1 = fast[context->scratch1 & 0x3FF]; + } else { + context->scratch1 = read_byte(context->scratch1, NULL, &context->opts->gen, context); + } } void z80_write_8(z80_context *context) { context->cycles += 3 * context->opts->gen.clock_divider; - write_byte(context->scratch2, context->scratch1, NULL, &context->opts->gen, context); + uint8_t *fast = context->fastmem[context->scratch2 >> 10]; + if (fast) { + fast[context->scratch2 & 0x3FF] = context->scratch1; + } else { + write_byte(context->scratch2, context->scratch1, NULL, &context->opts->gen, context); + } } void z80_io_read8(z80_context *context) @@ -69,6 +79,16 @@ z80_context * init_z80_context(z80_options *options) context->io_map = (memmap_chunk *)tmp_io_chunks; context->io_chunks = tmp_num_io_chunks; context->io_mask = tmp_io_mask; + for(uint32_t address = 0; address < 0x10000; address+=1024) + { + uint8_t *start = get_native_pointer(address, NULL, &options->gen); + if (start) { + uint8_t *end = get_native_pointer(address + 1023, NULL, &options->gen); + if (end && end - start == 1023) { + context->fastmem[address >> 10] = start; + } + } + } return context; } |