comparison vdp.c @ 1878:881083d76212

Small optimization to render_normal and a minor bugfix in left border debug register handling
author Michael Pavone <pavone@retrodev.com>
date Tue, 20 Aug 2019 20:18:27 -0700
parents 9486236f28ac
children 55198fc9cc1f
comparison
equal deleted inserted replaced
1877:9486236f28ac 1878:881083d76212
1312 return (sh_pixel){.index = pixel, .intensity = intensity}; 1312 return (sh_pixel){.index = pixel, .intensity = intensity};
1313 } 1313 }
1314 1314
1315 static void render_normal(vdp_context *context, int32_t col, uint8_t *dst, uint8_t *debug_dst, int plane_a_off, int plane_b_off) 1315 static void render_normal(vdp_context *context, int32_t col, uint8_t *dst, uint8_t *debug_dst, int plane_a_off, int plane_b_off)
1316 { 1316 {
1317 int start = 0; 1317 uint8_t *sprite_buf = context->linebuf + col * 8;
1318 if (!col && (context->regs[REG_MODE_1] & BIT_COL0_MASK)) { 1318 if (!col && (context->regs[REG_MODE_1] & BIT_COL0_MASK)) {
1319 memset(dst, 0, 8); 1319 memset(dst, 0, 8);
1320 memset(debug_dst, DBG_SRC_BG, 8); 1320 memset(debug_dst, DBG_SRC_BG, 8);
1321 dst += 8; 1321 dst += 8;
1322 debug_dst += 8; 1322 debug_dst += 8;
1323 start = 8; 1323 sprite_buf += 8;
1324 } 1324 plane_a_off += 8;
1325 uint8_t *sprite_buf = context->linebuf + col * 8 + start; 1325 plane_b_off += 8;
1326 for (int i = start; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) 1326 for (int i = 0; i < 8; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i)
1327 { 1327 {
1328 uint8_t sprite, plane_a, plane_b; 1328 uint8_t sprite, plane_a, plane_b;
1329 plane_a = context->tmp_buf_a[plane_a_off & SCROLL_BUFFER_MASK]; 1329 plane_a = context->tmp_buf_a[plane_a_off & SCROLL_BUFFER_MASK];
1330 plane_b = context->tmp_buf_b[plane_b_off & SCROLL_BUFFER_MASK]; 1330 plane_b = context->tmp_buf_b[plane_b_off & SCROLL_BUFFER_MASK];
1331 sprite = *sprite_buf; 1331 *(dst++) = composite_normal(context, debug_dst, *sprite_buf, plane_a, plane_b, context->regs[REG_BG_COLOR]) & 0x3F;
1332 *(dst++) = composite_normal(context, debug_dst, sprite, plane_a, plane_b, context->regs[REG_BG_COLOR]) & 0x3F; 1332 debug_dst++;
1333 debug_dst++; 1333 }
1334 } else {
1335 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i)
1336 {
1337 uint8_t sprite, plane_a, plane_b;
1338 plane_a = context->tmp_buf_a[plane_a_off & SCROLL_BUFFER_MASK];
1339 plane_b = context->tmp_buf_b[plane_b_off & SCROLL_BUFFER_MASK];
1340 *(dst++) = composite_normal(context, debug_dst, *sprite_buf, plane_a, plane_b, context->regs[REG_BG_COLOR]) & 0x3F;
1341 debug_dst++;
1342 }
1334 } 1343 }
1335 } 1344 }
1336 1345
1337 static void render_highlight(vdp_context *context, int32_t col, uint8_t *dst, uint8_t *debug_dst, int plane_a_off, int plane_b_off) 1346 static void render_highlight(vdp_context *context, int32_t col, uint8_t *dst, uint8_t *debug_dst, int plane_a_off, int plane_b_off)
1338 { 1347 {
1626 switch(test_layer) 1635 switch(test_layer)
1627 { 1636 {
1628 case 1: 1637 case 1:
1629 memset(dst, 0, BORDER_LEFT); 1638 memset(dst, 0, BORDER_LEFT);
1630 memset(debug_dst, DBG_SRC_BG, BORDER_LEFT); 1639 memset(debug_dst, DBG_SRC_BG, BORDER_LEFT);
1640 dst += BORDER_LEFT;
1631 break; 1641 break;
1632 case 2: { 1642 case 2: {
1633 //plane A 1643 //plane A
1634 //TODO: Deal with Window layer 1644 //TODO: Deal with Window layer
1635 int i; 1645 int i;
1658 } 1668 }
1659 } 1669 }
1660 } else { 1670 } else {
1661 memset(dst, pixel, BORDER_LEFT); 1671 memset(dst, pixel, BORDER_LEFT);
1662 memset(debug_dst, DBG_SRC_BG, BORDER_LEFT); 1672 memset(debug_dst, DBG_SRC_BG, BORDER_LEFT);
1663 } 1673 dst += BORDER_LEFT;
1664 dst += BORDER_LEFT; 1674 }
1665 } 1675 }
1666 context->done_composite = dst; 1676 context->done_composite = dst;
1667 context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK; 1677 context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK;
1668 context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK; 1678 context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK;
1669 } 1679 }