comparison vdp.c @ 1885:4178ce857e87

Calculate fine scroll once per line for a small speedup
author Michael Pavone <pavone@retrodev.com>
date Sat, 21 Sep 2019 11:01:07 -0700
parents b5549258b98b
children 183b86ba0212
comparison
equal deleted inserted replaced
1884:b5549258b98b 1885:4178ce857e87
1610 uint8_t a_src, src; 1610 uint8_t a_src, src;
1611 if (context->flags & FLAG_WINDOW) { 1611 if (context->flags & FLAG_WINDOW) {
1612 plane_a_off = context->buf_a_off; 1612 plane_a_off = context->buf_a_off;
1613 a_src = DBG_SRC_W; 1613 a_src = DBG_SRC_W;
1614 } else { 1614 } else {
1615 plane_a_off = context->buf_a_off - (context->hscroll_a & 0xF); 1615 plane_a_off = context->buf_a_off - context->hscroll_a_fine;
1616 a_src = DBG_SRC_A; 1616 a_src = DBG_SRC_A;
1617 } 1617 }
1618 plane_b_off = context->buf_b_off - (context->hscroll_b & 0xF); 1618 plane_b_off = context->buf_b_off - context->hscroll_b_fine;
1619 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7)); 1619 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7));
1620 1620
1621 if (context->regs[REG_MODE_4] & BIT_HILIGHT) { 1621 if (context->regs[REG_MODE_4] & BIT_HILIGHT) {
1622 if (output_disabled || test_layer) { 1622 if (output_disabled || test_layer) {
1623 render_testreg_highlight(context, col, dst, debug_dst, plane_a_off, plane_b_off, output_disabled, test_layer); 1623 render_testreg_highlight(context, col, dst, debug_dst, plane_a_off, plane_b_off, output_disabled, test_layer);
1650 case 2: { 1650 case 2: {
1651 //plane A 1651 //plane A
1652 //TODO: Deal with Window layer 1652 //TODO: Deal with Window layer
1653 int i; 1653 int i;
1654 i = 0; 1654 i = 0;
1655 uint8_t buf_off = context->buf_a_off - (context->hscroll_a & 0xF) + (16 - BORDER_LEFT); 1655 uint8_t buf_off = context->buf_a_off - context->hscroll_a_fine + (16 - BORDER_LEFT);
1656 //uint8_t *src = context->tmp_buf_a + ((context->buf_a_off + (i ? 0 : (16 - BORDER_LEFT) - (context->hscroll_a & 0xF))) & SCROLL_BUFFER_MASK); 1656 //uint8_t *src = context->tmp_buf_a + ((context->buf_a_off + (i ? 0 : (16 - BORDER_LEFT) - (context->hscroll_a & 0xF))) & SCROLL_BUFFER_MASK);
1657 for (; i < BORDER_LEFT; buf_off++, i++, dst++, debug_dst++) 1657 for (; i < BORDER_LEFT; buf_off++, i++, dst++, debug_dst++)
1658 { 1658 {
1659 *dst = context->tmp_buf_a[buf_off & SCROLL_BUFFER_MASK]; 1659 *dst = context->tmp_buf_a[buf_off & SCROLL_BUFFER_MASK];
1660 *debug_dst = DBG_SRC_A; 1660 *debug_dst = DBG_SRC_A;
1663 } 1663 }
1664 case 3: { 1664 case 3: {
1665 //plane B 1665 //plane B
1666 int i; 1666 int i;
1667 i = 0; 1667 i = 0;
1668 uint8_t buf_off = context->buf_b_off - (context->hscroll_b & 0xF) + (16 - BORDER_LEFT); 1668 uint8_t buf_off = context->buf_b_off - context->hscroll_b_fine + (16 - BORDER_LEFT);
1669 //uint8_t *src = context->tmp_buf_b + ((context->buf_b_off + (i ? 0 : (16 - BORDER_LEFT) - (context->hscroll_b & 0xF))) & SCROLL_BUFFER_MASK); 1669 //uint8_t *src = context->tmp_buf_b + ((context->buf_b_off + (i ? 0 : (16 - BORDER_LEFT) - (context->hscroll_b & 0xF))) & SCROLL_BUFFER_MASK);
1670 for (; i < BORDER_LEFT; buf_off++, i++, dst++, debug_dst++) 1670 for (; i < BORDER_LEFT; buf_off++, i++, dst++, debug_dst++)
1671 { 1671 {
1672 *dst = context->tmp_buf_b[buf_off & SCROLL_BUFFER_MASK]; 1672 *dst = context->tmp_buf_b[buf_off & SCROLL_BUFFER_MASK];
1673 *debug_dst = DBG_SRC_B; 1673 *debug_dst = DBG_SRC_B;
2528 mask |= 0x7; 2528 mask |= 0x7;
2529 } 2529 }
2530 render_border_garbage(context, address, context->tmp_buf_a, context->buf_a_off+8, context->col_2); 2530 render_border_garbage(context, address, context->tmp_buf_a, context->buf_a_off+8, context->col_2);
2531 address += (context->vcounter & mask) * 4; 2531 address += (context->vcounter & mask) * 4;
2532 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1]; 2532 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1];
2533 context->hscroll_a_fine = context->hscroll_a & 0xF;
2533 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3]; 2534 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3];
2535 context->hscroll_b_fine = context->hscroll_b & 0xF;
2534 //printf("%d: HScroll A: %d, HScroll B: %d\n", context->vcounter, context->hscroll_a, context->hscroll_b); 2536 //printf("%d: HScroll A: %d, HScroll B: %d\n", context->vcounter, context->hscroll_a, context->hscroll_b);
2535 //243-246 inclusive 2537 //243-246 inclusive
2536 for (int i = 0; i < 3; i++) 2538 for (int i = 0; i < 3; i++)
2537 { 2539 {
2538 render_sprite_cells(context); 2540 render_sprite_cells(context);
2747 mask |= 0x7; 2749 mask |= 0x7;
2748 } 2750 }
2749 render_border_garbage(context, address, context->tmp_buf_a, context->buf_a_off+8, context->col_2); 2751 render_border_garbage(context, address, context->tmp_buf_a, context->buf_a_off+8, context->col_2);
2750 address += (context->vcounter & mask) * 4; 2752 address += (context->vcounter & mask) * 4;
2751 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1]; 2753 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1];
2754 context->hscroll_a_fine = context->hscroll_a & 0xF;
2752 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3]; 2755 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3];
2756 context->hscroll_b_fine = context->hscroll_b & 0xF;
2753 //printf("%d: HScroll A: %d, HScroll B: %d\n", context->vcounter, context->hscroll_a, context->hscroll_b); 2757 //printf("%d: HScroll A: %d, HScroll B: %d\n", context->vcounter, context->hscroll_a, context->hscroll_b);
2754 if (context->flags & FLAG_DMA_RUN) { run_dma_src(context, -1); } 2758 if (context->flags & FLAG_DMA_RUN) { run_dma_src(context, -1); }
2755 context->hslot++; 2759 context->hslot++;
2756 context->cycles += h40_hsync_cycles[14]; 2760 context->cycles += h40_hsync_cycles[14];
2757 CHECK_ONLY //provides "garbage" for border when plane A selected 2761 CHECK_ONLY //provides "garbage" for border when plane A selected
2967 mask |= 0x7; 2971 mask |= 0x7;
2968 } 2972 }
2969 render_border_garbage(context, address, context->tmp_buf_a, context->buf_a_off+8, context->col_2); 2973 render_border_garbage(context, address, context->tmp_buf_a, context->buf_a_off+8, context->col_2);
2970 address += (context->vcounter & mask) * 4; 2974 address += (context->vcounter & mask) * 4;
2971 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1]; 2975 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1];
2976 context->hscroll_a_fine = context->hscroll_a & 0xF;
2972 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3]; 2977 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3];
2978 context->hscroll_b_fine = context->hscroll_a & 0xF;
2973 //printf("%d: HScroll A: %d, HScroll B: %d\n", context->vcounter, context->hscroll_a, context->hscroll_b); 2979 //printf("%d: HScroll A: %d, HScroll B: %d\n", context->vcounter, context->hscroll_a, context->hscroll_b);
2974 CHECK_LIMIT //provides "garbage" for border when plane A selected 2980 CHECK_LIMIT //provides "garbage" for border when plane A selected
2975 SPRITE_RENDER_H32(245) 2981 SPRITE_RENDER_H32(245)
2976 SPRITE_RENDER_H32(246) 2982 SPRITE_RENDER_H32(246)
2977 SPRITE_RENDER_H32(247) //provides "garbage" for border when plane B selected 2983 SPRITE_RENDER_H32(247) //provides "garbage" for border when plane B selected