Mercurial > repos > blastem
comparison backend.c @ 1838:0c1491818f4b
WIP new 68K core using CPU DSL
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 18 Apr 2019 19:47:50 -0700 |
parents | 33ec5df77fac |
children | 374a5ae694e8 42c12d141f6e |
comparison
equal
deleted
inserted
replaced
1837:f6ee0df6bb48 | 1838:0c1491818f4b |
---|---|
152 return chunk->read_16(offset, context); | 152 return chunk->read_16(offset, context); |
153 } | 153 } |
154 return 0xFFFF; | 154 return 0xFFFF; |
155 } | 155 } |
156 | 156 |
157 void write_word(uint32_t address, uint16_t value, void **mem_pointers, cpu_options *opts, void *context) | |
158 { | |
159 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); | |
160 if (!chunk) { | |
161 return; | |
162 } | |
163 uint32_t offset = (address - chunk->start) & chunk->mask; | |
164 if (chunk->flags & MMAP_WRITE) { | |
165 uint8_t *base; | |
166 if (chunk->flags & MMAP_PTR_IDX) { | |
167 base = mem_pointers[chunk->ptr_index]; | |
168 } else { | |
169 base = chunk->buffer; | |
170 } | |
171 if (base) { | |
172 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | |
173 offset /= 2; | |
174 if (chunk->flags & MMAP_ONLY_EVEN) { | |
175 value >>= 16; | |
176 } | |
177 base[offset] = value; | |
178 } else { | |
179 *(uint16_t *)(base + offset) = value; | |
180 } | |
181 return; | |
182 } | |
183 } | |
184 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_16) { | |
185 chunk->write_16(offset, context, value); | |
186 } | |
187 } | |
188 | |
157 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) | 189 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) |
158 { | 190 { |
159 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); | 191 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
160 if (!chunk) { | 192 if (!chunk) { |
161 return 0xFF; | 193 return 0xFF; |