Mercurial > repos > blastem
diff backend.c @ 1130:8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 28 Dec 2016 20:39:27 -0800 |
parents | 329ff62ea391 |
children | 5c8b1c33ca10 |
line wrap: on
line diff
--- a/backend.c Wed Dec 28 12:28:52 2016 -0800 +++ b/backend.c Wed Dec 28 20:39:27 2016 -0800 @@ -51,6 +51,23 @@ } } +memmap_chunk const *find_map_chunk(uint32_t address, cpu_options *opts, uint16_t flags, uint32_t *size_sum) +{ + if (size_sum) { + *size_sum = 0; + } + address &= opts->address_mask; + for (memmap_chunk const *cur = opts->memmap, *end = opts->memmap + opts->memmap_chunks; cur != end; cur++) + { + if (address >= cur->start && address < cur->end) { + return cur; + } else if (size_sum && (cur->flags & flags) == flags) { + *size_sum += chunk_size(opts, cur); + } + } + return NULL; +} + void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts) { memmap_chunk const * memmap = opts->memmap;