diff options
Diffstat (limited to 'backend.c')
-rw-r--r-- | backend.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -93,6 +93,42 @@ void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * return NULL; } +uint16_t read_word(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) +{ + memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); + if (!chunk) { + return 0xFFFF; + } + uint32_t offset = (address - chunk->start) & chunk->mask; + if (chunk->flags & MMAP_READ) { + uint8_t *base; + if (chunk->flags & MMAP_PTR_IDX) { + base = mem_pointers[chunk->ptr_index]; + } else { + base = chunk->buffer; + } + if (base) { + uint16_t val; + if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { + offset /= 2; + uint16_t val = base[offset]; + if (chunk->flags & MMAP_ONLY_ODD) { + val |= 0xFF00; + } else { + val = val << 8 | 0xFF; + } + } else { + val = *(uint16_t *)(base + offset); + } + return val; + } + } + if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_16) { + return chunk->read_16(offset, context); + } + return 0xFFFF; +} + uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) { if (chunk->mask == opts->address_mask) { |