Mercurial > repos > blastem
comparison backend.c @ 1703:49a52c737bf0
Fix zero flag calculation in CPU DSL
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 28 Jan 2019 19:24:04 -0800 |
parents | d377d6037dd9 |
children | 33ec5df77fac |
comparison
equal
deleted
inserted
replaced
1702:73ac2e59fa3f | 1703:49a52c737bf0 |
---|---|
127 return chunk->read_16(offset, context); | 127 return chunk->read_16(offset, context); |
128 } | 128 } |
129 return 0xFFFF; | 129 return 0xFFFF; |
130 } | 130 } |
131 | 131 |
132 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) | |
133 { | |
134 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); | |
135 if (!chunk) { | |
136 return 0xFF; | |
137 } | |
138 uint32_t offset = address & chunk->mask; | |
139 if (chunk->flags & MMAP_READ) { | |
140 uint8_t *base; | |
141 if (chunk->flags & MMAP_PTR_IDX) { | |
142 base = mem_pointers[chunk->ptr_index]; | |
143 } else { | |
144 base = chunk->buffer; | |
145 } | |
146 if (base) { | |
147 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | |
148 if (address & 1) { | |
149 if (chunk->flags & MMAP_ONLY_EVEN) { | |
150 return 0xFF; | |
151 } | |
152 } else if (chunk->flags & MMAP_ONLY_ODD) { | |
153 return 0xFF; | |
154 } | |
155 offset /= 2; | |
156 } | |
157 return base[offset]; | |
158 } | |
159 } | |
160 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_8) { | |
161 return chunk->read_8(offset, context); | |
162 } | |
163 return 0xFF; | |
164 } | |
165 | |
166 void write_byte(uint32_t address, uint8_t value, void **mem_pointers, cpu_options *opts, void *context) | |
167 { | |
168 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); | |
169 if (!chunk) { | |
170 return; | |
171 } | |
172 uint32_t offset = address & chunk->mask; | |
173 if (chunk->flags & MMAP_WRITE) { | |
174 uint8_t *base; | |
175 if (chunk->flags & MMAP_PTR_IDX) { | |
176 base = mem_pointers[chunk->ptr_index]; | |
177 } else { | |
178 base = chunk->buffer; | |
179 } | |
180 if (base) { | |
181 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | |
182 if (address & 1) { | |
183 if (chunk->flags & MMAP_ONLY_EVEN) { | |
184 return; | |
185 } | |
186 } else if (chunk->flags & MMAP_ONLY_ODD) { | |
187 return; | |
188 } | |
189 offset /= 2; | |
190 } | |
191 base[offset] = value; | |
192 } | |
193 } | |
194 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_8) { | |
195 chunk->write_8(offset, context, value); | |
196 } | |
197 } | |
198 | |
132 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) | 199 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) |
133 { | 200 { |
134 if (chunk->mask == opts->address_mask) { | 201 if (chunk->mask == opts->address_mask) { |
135 return chunk->end - chunk->start; | 202 return chunk->end - chunk->start; |
136 } else { | 203 } else { |