Mercurial > repos > blastem
comparison vdp.c @ 43:3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 09 Dec 2012 18:40:45 -0800 |
parents | 6653e67a6811 |
children | 3b79cbcf6846 |
comparison
equal
deleted
inserted
replaced
42:6653e67a6811 | 43:3fc57e1a2c56 |
---|---|
291 | 291 |
292 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) |
293 { | 293 { |
294 uint16_t address = ((col & 0x7FF) << 5); | 294 uint16_t address = ((col & 0x7FF) << 5); |
295 if (col & MAP_BIT_V_FLIP) { | 295 if (col & MAP_BIT_V_FLIP) { |
296 address += 24 - 4 * context->v_offset; | 296 address += 28 - 4 * context->v_offset; |
297 } else { | 297 } else { |
298 address += 4 * context->v_offset; | 298 address += 4 * context->v_offset; |
299 } | 299 } |
300 uint16_t pal_priority = (col >> 9) & 0x70; | 300 uint16_t pal_priority = (col >> 9) & 0x70; |
301 int32_t dir; | 301 int32_t dir; |
340 if (col) | 340 if (col) |
341 { | 341 { |
342 col-=2; | 342 col-=2; |
343 dst = context->framebuf + line * 320 + col * 8; | 343 dst = context->framebuf + line * 320 + col * 8; |
344 sprite_buf = context->linebuf + col * 8; | 344 sprite_buf = context->linebuf + col * 8; |
345 uint16_t a_src; | |
345 if (context->flags & FLAG_WINDOW) { | 346 if (context->flags & FLAG_WINDOW) { |
346 plane_a = context->tmp_buf_a + SCROLL_BUFFER_DRAW; | 347 plane_a = context->tmp_buf_a + SCROLL_BUFFER_DRAW; |
348 a_src = FBUF_SRC_W; | |
347 } else { | 349 } else { |
348 plane_a = context->tmp_buf_a + SCROLL_BUFFER_DRAW - (context->hscroll_a & 0xF); | 350 plane_a = context->tmp_buf_a + SCROLL_BUFFER_DRAW - (context->hscroll_a & 0xF); |
351 a_src = FBUF_SRC_A; | |
349 } | 352 } |
350 plane_b = context->tmp_buf_b + SCROLL_BUFFER_DRAW - (context->hscroll_b & 0xF); | 353 plane_b = context->tmp_buf_b + SCROLL_BUFFER_DRAW - (context->hscroll_b & 0xF); |
351 end = dst + 16; | 354 end = dst + 16; |
355 uint16_t src; | |
352 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7)); | 356 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7)); |
353 for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) { | 357 for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) { |
354 uint8_t pixel; | 358 uint8_t pixel; |
355 if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) { | 359 if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) { |
356 pixel = *sprite_buf; | 360 pixel = *sprite_buf; |
361 src = FBUF_SRC_S; | |
357 } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) { | 362 } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) { |
358 pixel = *plane_a; | 363 pixel = *plane_a; |
364 src = a_src; | |
359 } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) { | 365 } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) { |
360 pixel = *plane_b; | 366 pixel = *plane_b; |
367 src = FBUF_SRC_B; | |
361 } else if (*sprite_buf & 0xF) { | 368 } else if (*sprite_buf & 0xF) { |
362 pixel = *sprite_buf; | 369 pixel = *sprite_buf; |
370 src = FBUF_SRC_S; | |
363 } else if (*plane_a & 0xF) { | 371 } else if (*plane_a & 0xF) { |
364 pixel = *plane_a; | 372 pixel = *plane_a; |
373 src = a_src; | |
365 } else if (*plane_b & 0xF){ | 374 } else if (*plane_b & 0xF){ |
366 pixel = *plane_b; | 375 pixel = *plane_b; |
376 src = FBUF_SRC_B; | |
367 } else { | 377 } else { |
368 pixel = context->regs[REG_BG_COLOR] & 0x3F; | 378 pixel = context->regs[REG_BG_COLOR] & 0x3F; |
369 } | 379 src = FBUF_SRC_BG; |
370 *dst = context->cram[pixel & 0x3F] | ((pixel & BUF_BIT_PRIORITY) ? 0x1000 : 0); | 380 } |
381 *dst = context->cram[pixel & 0x3F] | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src; | |
371 } | 382 } |
372 } else { | 383 } else { |
373 //dst = context->framebuf + line * 320; | 384 //dst = context->framebuf + line * 320; |
374 //sprite_buf = context->linebuf + col * 8; | 385 //sprite_buf = context->linebuf + col * 8; |
375 //plane_a = context->tmp_buf_a + 16 - (context->hscroll_a & 0x7); | 386 //plane_a = context->tmp_buf_a + 16 - (context->hscroll_a & 0x7); |