Mercurial > repos > blastem
comparison vdp.c @ 41:e591004487bc
More correct window support, maybe
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 09 Dec 2012 17:10:08 -0800 |
parents | 7368a7071908 |
children | 6653e67a6811 |
comparison
equal
deleted
inserted
replaced
40:7368a7071908 | 41:e591004487bc |
---|---|
185 left_col = 0; right_col = 42; | 185 left_col = 0; right_col = 42; |
186 uint16_t top_line, bottom_line; | 186 uint16_t top_line, bottom_line; |
187 top_line = 0; bottom_line = 241; | 187 top_line = 0; bottom_line = 241; |
188 #else | 188 #else |
189 if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) { | 189 if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) { |
190 left_col = (context->regs[REG_WINDOW_H] & 0x1F) * 2; | |
191 right_col = 42; | |
192 } else { | |
190 left_col = 0; | 193 left_col = 0; |
191 right_col = (context->regs[REG_WINDOW_H] & 0x1F) * 2; | 194 right_col = (context->regs[REG_WINDOW_H] & 0x1F) * 2; |
192 if (right_col) { | 195 if (right_col) { |
193 right_col += 2; | 196 right_col += 2; |
194 } | 197 } |
198 } | |
199 uint16_t top_line, bottom_line; | |
200 if (context->regs[REG_WINDOW_V] & WINDOW_DOWN) { | |
201 top_line = (context->regs[REG_WINDOW_V] & 0x1F) * 8; | |
202 bottom_line = 241; | |
195 } else { | 203 } else { |
196 left_col = (context->regs[REG_WINDOW_H] & 0x1F) * 2; | 204 top_line = 0; |
197 right_col = 42; | 205 bottom_line = (context->regs[REG_WINDOW_V] & 0x1F) * 8; |
198 } | 206 } |
199 if (column >= left_col && column < right_col) { | 207 if ((column >= left_col && column < right_col) || (line >= top_line && line < bottom_line)) { |
200 uint16_t top_line, bottom_line; | 208 #endif |
201 if (context->regs[REG_WINDOW_V] & WINDOW_DOWN) { | 209 uint16_t address = context->regs[REG_WINDOW] << 10; |
202 top_line = (context->regs[REG_WINDOW_V] & 0x1F) * 8; | 210 uint16_t line_offset, offset, mask; |
203 bottom_line = 241; | 211 if (context->latched_mode & BIT_H40) { |
212 address &= 0xF000; | |
213 line_offset = (((line/* - top_line */) / 8) * 64 * 2) & 0xFFF; | |
214 mask = 0x7F; | |
215 | |
204 } else { | 216 } else { |
205 top_line = 0; | 217 address &= 0xF800; |
206 bottom_line = (context->regs[REG_WINDOW_V] & 0x1F) * 8; | 218 line_offset = (((line/* - top_line*/) / 8) * 32 * 2) & 0xFFF; |
207 } | 219 mask = 0x3F; |
208 if (line >= top_line && line < bottom_line) { | 220 } |
209 #endif | 221 offset = address + line_offset + (((column - 2/* - left_col*/) * 2) & mask); |
210 uint16_t address = context->regs[REG_WINDOW] << 10; | 222 context->col_1 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; |
211 uint16_t line_offset, offset, mask; | 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]); |
212 if (context->latched_mode & BIT_H40) { | 224 offset = address + line_offset + (((column - 1/* - left_col*/) * 2) & mask); |
213 address &= 0xF000; | 225 context->col_2 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; |
214 line_offset = (((line/* - top_line */) / 8) * 64 * 2) & 0xFFF; | 226 context->v_offset = (line/* - top_line*/) & 0x7; |
215 mask = 0x7F; | 227 context->flags |= FLAG_WINDOW; |
216 | 228 return; |
217 } else { | |
218 address &= 0xF800; | |
219 line_offset = (((line/* - top_line*/) / 8) * 32 * 2) & 0xFFF; | |
220 mask = 0x3F; | |
221 } | |
222 offset = address + line_offset + (((column - 2/* - left_col*/) * 2) & mask); | |
223 context->col_1 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; | |
224 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]); | |
225 offset = address + line_offset + (((column - 1/* - left_col*/) * 2) & mask); | |
226 context->col_2 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1]; | |
227 context->v_offset = (line/* - top_line*/) & 0x7; | |
228 context->flags |= FLAG_WINDOW; | |
229 return; | |
230 #if !ALWAYS_WINDOW | 229 #if !ALWAYS_WINDOW |
231 } | |
232 } | 230 } |
233 context->flags &= ~FLAG_WINDOW; | 231 context->flags &= ~FLAG_WINDOW; |
234 #endif | 232 #endif |
235 | 233 |
236 } | 234 } |