Mercurial > repos > blastem
comparison backend.c @ 2134:9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 18 Mar 2022 20:49:07 -0700 |
parents | 0013362c320c |
children | 38c281ef57b0 |
comparison
equal
deleted
inserted
replaced
2133:8554751f17b5 | 2134:9caebcfeac72 |
---|---|
94 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX | 94 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX |
95 ? mem_pointers[memmap[chunk].ptr_index] | 95 ? mem_pointers[memmap[chunk].ptr_index] |
96 : memmap[chunk].buffer; | 96 : memmap[chunk].buffer; |
97 if (!base) { | 97 if (!base) { |
98 if (memmap[chunk].flags & MMAP_AUX_BUFF) { | 98 if (memmap[chunk].flags & MMAP_AUX_BUFF) { |
99 return ((uint8_t *)memmap[chunk].buffer) + (address & memmap[chunk].aux_mask); | 99 address &= memmap[chunk].aux_mask; |
100 if (memmap[chunk].shift > 0) { | |
101 address <<= memmap[chunk].shift; | |
102 } else if (memmap[chunk].shift < 0) { | |
103 address >>= -memmap[chunk].shift; | |
104 } | |
105 return ((uint8_t *)memmap[chunk].buffer) + address; | |
100 } | 106 } |
101 return NULL; | 107 return NULL; |
102 } | 108 } |
103 return base + (address & memmap[chunk].mask); | 109 address &= memmap[chunk].mask; |
110 if (memmap[chunk].shift > 0) { | |
111 address <<= memmap[chunk].shift; | |
112 } else if (memmap[chunk].shift < 0) { | |
113 address >>= -memmap[chunk].shift; | |
114 } | |
115 return base + address; | |
104 } | 116 } |
105 } | 117 } |
106 return NULL; | 118 return NULL; |
107 } | 119 } |
108 | 120 |
119 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX | 131 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX |
120 ? mem_pointers[memmap[chunk].ptr_index] | 132 ? mem_pointers[memmap[chunk].ptr_index] |
121 : memmap[chunk].buffer; | 133 : memmap[chunk].buffer; |
122 if (!base) { | 134 if (!base) { |
123 if (memmap[chunk].flags & MMAP_AUX_BUFF) { | 135 if (memmap[chunk].flags & MMAP_AUX_BUFF) { |
124 return ((uint8_t *)memmap[chunk].buffer) + (address & memmap[chunk].aux_mask); | 136 address &= memmap[chunk].aux_mask; |
137 if (memmap[chunk].shift > 0) { | |
138 address <<= memmap[chunk].shift; | |
139 } else if (memmap[chunk].shift < 0) { | |
140 address >>= -memmap[chunk].shift; | |
141 } | |
142 return ((uint8_t *)memmap[chunk].buffer) + address; | |
125 } | 143 } |
126 return NULL; | 144 return NULL; |
127 } | 145 } |
128 return base + (address & memmap[chunk].mask); | 146 address &= memmap[chunk].mask; |
147 if (memmap[chunk].shift > 0) { | |
148 address <<= memmap[chunk].shift; | |
149 } else if (memmap[chunk].shift < 0) { | |
150 address >>= -memmap[chunk].shift; | |
151 } | |
152 return base + address; | |
129 } | 153 } |
130 } | 154 } |
131 return NULL; | 155 return NULL; |
132 } | 156 } |
133 | 157 |
145 } else { | 169 } else { |
146 base = chunk->buffer; | 170 base = chunk->buffer; |
147 } | 171 } |
148 if (base) { | 172 if (base) { |
149 uint16_t val; | 173 uint16_t val; |
174 if (chunk->shift > 0) { | |
175 offset <<= chunk->shift; | |
176 } else if (chunk->shift < 0){ | |
177 offset >>= chunk->shift; | |
178 } | |
150 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | 179 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
151 offset /= 2; | 180 offset /= 2; |
152 val = base[offset]; | 181 val = base[offset]; |
153 if (chunk->flags & MMAP_ONLY_ODD) { | 182 if (chunk->flags & MMAP_ONLY_ODD) { |
154 val |= 0xFF00; | 183 val |= 0xFF00; |
180 base = mem_pointers[chunk->ptr_index]; | 209 base = mem_pointers[chunk->ptr_index]; |
181 } else { | 210 } else { |
182 base = chunk->buffer; | 211 base = chunk->buffer; |
183 } | 212 } |
184 if (base) { | 213 if (base) { |
214 if (chunk->shift > 0) { | |
215 offset <<= chunk->shift; | |
216 } else if (chunk->shift < 0){ | |
217 offset >>= chunk->shift; | |
218 } | |
185 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | 219 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
186 offset /= 2; | 220 offset /= 2; |
187 if (chunk->flags & MMAP_ONLY_EVEN) { | 221 if (chunk->flags & MMAP_ONLY_EVEN) { |
188 value >>= 16; | 222 value >>= 16; |
189 } | 223 } |
212 base = mem_pointers[chunk->ptr_index]; | 246 base = mem_pointers[chunk->ptr_index]; |
213 } else { | 247 } else { |
214 base = chunk->buffer; | 248 base = chunk->buffer; |
215 } | 249 } |
216 if (base) { | 250 if (base) { |
251 if (chunk->shift > 0) { | |
252 offset <<= chunk->shift; | |
253 } else if (chunk->shift < 0){ | |
254 offset >>= chunk->shift; | |
255 } | |
217 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | 256 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
218 if (address & 1) { | 257 if (address & 1) { |
219 if (chunk->flags & MMAP_ONLY_EVEN) { | 258 if (chunk->flags & MMAP_ONLY_EVEN) { |
220 return 0xFF; | 259 return 0xFF; |
221 } | 260 } |
248 base = mem_pointers[chunk->ptr_index]; | 287 base = mem_pointers[chunk->ptr_index]; |
249 } else { | 288 } else { |
250 base = chunk->buffer; | 289 base = chunk->buffer; |
251 } | 290 } |
252 if (base) { | 291 if (base) { |
292 if (chunk->shift > 0) { | |
293 offset <<= chunk->shift; | |
294 } else if (chunk->shift < 0){ | |
295 offset >>= chunk->shift; | |
296 } | |
253 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { | 297 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
254 if (address & 1) { | 298 if (address & 1) { |
255 if (chunk->flags & MMAP_ONLY_EVEN) { | 299 if (chunk->flags & MMAP_ONLY_EVEN) { |
256 return; | 300 return; |
257 } | 301 } |