Mercurial > repos > blastem
comparison backend.c @ 744:fc68992cf18d
Merge windows branch with latest changes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 May 2015 21:19:55 -0700 |
parents | fc04781f4d28 |
children | 329ff62ea391 |
comparison
equal
deleted
inserted
replaced
743:cf78cb045fa4 | 744:fc68992cf18d |
---|---|
49 cur = cur->next; | 49 cur = cur->next; |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts) | |
55 { | |
56 memmap_chunk const * memmap = opts->memmap; | |
57 address &= opts->address_mask; | |
58 for (uint32_t chunk = 0; chunk < opts->memmap_chunks; chunk++) | |
59 { | |
60 if (address >= memmap[chunk].start && address < memmap[chunk].end) { | |
61 if (!(memmap[chunk].flags & MMAP_READ)) { | |
62 return NULL; | |
63 } | |
64 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX | |
65 ? mem_pointers[memmap[chunk].ptr_index] | |
66 : memmap[chunk].buffer; | |
67 if (!base) { | |
68 return NULL; | |
69 } | |
70 return base + (address & memmap[chunk].mask); | |
71 } | |
72 } | |
73 return NULL; | |
74 } | |
75 | |
76 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) | |
77 { | |
78 if (chunk->mask == opts->address_mask) { | |
79 return chunk->end - chunk->start; | |
80 } else { | |
81 return chunk->mask + 1; | |
82 } | |
83 } | |
84 | |
85 uint32_t ram_size(cpu_options *opts) | |
86 { | |
87 uint32_t size = 0; | |
88 for (int i = 0; i < opts->memmap_chunks; i++) | |
89 { | |
90 if ((opts->memmap[i].flags & (MMAP_WRITE | MMAP_CODE)) == (MMAP_WRITE | MMAP_CODE)) { | |
91 if (opts->memmap[i].mask == opts->address_mask) { | |
92 size += opts->memmap[i].end - opts->memmap[i].start; | |
93 } else { | |
94 size += opts->memmap[i].mask + 1; | |
95 } | |
96 } | |
97 } | |
98 return size; | |
99 } |