Mercurial > repos > blastem
comparison vdp.c @ 42:6653e67a6811
Fix bug in tile address masking. Remove some debug code from window plane.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 09 Dec 2012 17:26:36 -0800 |
parents | e591004487bc |
children | 3fc57e1a2c56 |
comparison
equal
deleted
inserted
replaced
41:e591004487bc | 42:6653e67a6811 |
---|---|
173 //TODO: Implement me | 173 //TODO: Implement me |
174 } | 174 } |
175 | 175 |
176 #define WINDOW_RIGHT 0x80 | 176 #define WINDOW_RIGHT 0x80 |
177 #define WINDOW_DOWN 0x80 | 177 #define WINDOW_DOWN 0x80 |
178 #define ALWAYS_WINDOW 0 | |
179 | 178 |
180 void read_map_scroll(uint16_t column, uint16_t vsram_off, uint32_t line, uint16_t address, uint16_t hscroll_val, vdp_context * context) | 179 void read_map_scroll(uint16_t column, uint16_t vsram_off, uint32_t line, uint16_t address, uint16_t hscroll_val, vdp_context * context) |
181 { | 180 { |
182 if (!vsram_off) { | 181 if (!vsram_off) { |
183 uint16_t left_col, right_col; | 182 uint16_t left_col, right_col; |
184 #if ALWAYS_WINDOW | |
185 left_col = 0; right_col = 42; | |
186 uint16_t top_line, bottom_line; | |
187 top_line = 0; bottom_line = 241; | |
188 #else | |
189 if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) { | 183 if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) { |
190 left_col = (context->regs[REG_WINDOW_H] & 0x1F) * 2; | 184 left_col = (context->regs[REG_WINDOW_H] & 0x1F) * 2; |
191 right_col = 42; | 185 right_col = 42; |
192 } else { | 186 } else { |
193 left_col = 0; | 187 left_col = 0; |
203 } else { | 197 } else { |
204 top_line = 0; | 198 top_line = 0; |
205 bottom_line = (context->regs[REG_WINDOW_V] & 0x1F) * 8; | 199 bottom_line = (context->regs[REG_WINDOW_V] & 0x1F) * 8; |
206 } | 200 } |
207 if ((column >= left_col && column < right_col) || (line >= top_line && line < bottom_line)) { | 201 if ((column >= left_col && column < right_col) || (line >= top_line && line < bottom_line)) { |
208 #endif | |
209 uint16_t address = context->regs[REG_WINDOW] << 10; | 202 uint16_t address = context->regs[REG_WINDOW] << 10; |
210 uint16_t line_offset, offset, mask; | 203 uint16_t line_offset, offset, mask; |
211 if (context->latched_mode & BIT_H40) { | 204 if (context->latched_mode & BIT_H40) { |
212 address &= 0xF000; | 205 address &= 0xF000; |
213 line_offset = (((line/* - top_line */) / 8) * 64 * 2) & 0xFFF; | 206 line_offset = (((line) / 8) * 64 * 2) & 0xFFF; |
214 mask = 0x7F; | 207 mask = 0x7F; |
215 | 208 |
216 } else { | 209 } else { |
217 address &= 0xF800; | 210 address &= 0xF800; |
218 line_offset = (((line/* - top_line*/) / 8) * 32 * 2) & 0xFFF; | 211 line_offset = (((line) / 8) * 32 * 2) & 0xFFF; |
219 mask = 0x3F; | 212 mask = 0x3F; |
220 } | 213 } |
221 offset = address + line_offset + (((column - 2/* - left_col*/) * 2) & mask); | 214 offset = address + line_offset + (((column - 2) * 2) & mask); |
222 context->col_1 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; | 215 context->col_1 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; |
223 printf("Window | top: %d, bot: %d, left: %d, right: %d, base: %X, line: %X offset: %X, tile: %X, reg: %X\n", top_line, bottom_line, left_col, right_col, address, line_offset, offset, ((context->col_1 & 0x3FF) << 5), context->regs[REG_WINDOW]); | 216 printf("Window | top: %d, bot: %d, left: %d, right: %d, base: %X, line: %X offset: %X, tile: %X, reg: %X\n", top_line, bottom_line, left_col, right_col, address, line_offset, offset, ((context->col_1 & 0x3FF) << 5), context->regs[REG_WINDOW]); |
224 offset = address + line_offset + (((column - 1/* - left_col*/) * 2) & mask); | 217 offset = address + line_offset + (((column - 1) * 2) & mask); |
225 context->col_2 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; | 218 context->col_2 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; |
226 context->v_offset = (line/* - top_line*/) & 0x7; | 219 context->v_offset = (line) & 0x7; |
227 context->flags |= FLAG_WINDOW; | 220 context->flags |= FLAG_WINDOW; |
228 return; | 221 return; |
229 #if !ALWAYS_WINDOW | |
230 } | 222 } |
231 context->flags &= ~FLAG_WINDOW; | 223 context->flags &= ~FLAG_WINDOW; |
232 #endif | |
233 | |
234 } | 224 } |
235 uint16_t vscroll; | 225 uint16_t vscroll; |
236 switch(context->regs[REG_SCROLL] & 0x30) | 226 switch(context->regs[REG_SCROLL] & 0x30) |
237 { | 227 { |
238 case 0: | 228 case 0: |
299 read_map_scroll(column, 1, line, (context->regs[REG_SCROLL_B] & 0x7) << 13, context->hscroll_b, context); | 289 read_map_scroll(column, 1, line, (context->regs[REG_SCROLL_B] & 0x7) << 13, context->hscroll_b, context); |
300 } | 290 } |
301 | 291 |
302 void render_map(uint16_t col, uint8_t * tmp_buf, vdp_context * context) | 292 void render_map(uint16_t col, uint8_t * tmp_buf, vdp_context * context) |
303 { | 293 { |
304 uint16_t address = ((col & 0x3FF) << 5); | 294 uint16_t address = ((col & 0x7FF) << 5); |
305 if (col & MAP_BIT_V_FLIP) { | 295 if (col & MAP_BIT_V_FLIP) { |
306 address += 24 - 4 * context->v_offset; | 296 address += 24 - 4 * context->v_offset; |
307 } else { | 297 } else { |
308 address += 4 * context->v_offset; | 298 address += 4 * context->v_offset; |
309 } | 299 } |