Mercurial > repos > blastem
comparison vdp.c @ 1272:be509813b2f2
Fill in the rest of the framebuffer holes created by horizontal border. Work remains for things to be seemless when display gets turned on and off mid frame
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 07 Mar 2017 20:17:12 -0800 |
parents | c865ee5478bc |
children | 6dedaa645843 |
comparison
equal
deleted
inserted
replaced
1271:c865ee5478bc | 1272:be509813b2f2 |
---|---|
1185 if (line == 0x1FF) { | 1185 if (line == 0x1FF) { |
1186 if (!col) { | 1186 if (!col) { |
1187 return; | 1187 return; |
1188 } | 1188 } |
1189 col -= 2; | 1189 col -= 2; |
1190 dst = context->output + BORDER_LEFT + col * 8; | 1190 if (col) { |
1191 dst = context->output + BORDER_LEFT + col * 8; | |
1192 } else { | |
1193 dst = context->output; | |
1194 uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; | |
1195 for (int i = 0; i < BORDER_LEFT; i++, dst++) | |
1196 { | |
1197 *dst = bg_color; | |
1198 } | |
1199 } | |
1191 uint32_t color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; | 1200 uint32_t color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; |
1192 for (int i = 0; i < 16; i++) | 1201 for (int i = 0; i < 16; i++) |
1193 { | 1202 { |
1194 *(dst++) = color; | 1203 *(dst++) = color; |
1195 } | 1204 } |
1486 context->vcounter = 0x1E5; | 1495 context->vcounter = 0x1E5; |
1487 } | 1496 } |
1488 } else if (context->vcounter == 0xDB) { | 1497 } else if (context->vcounter == 0xDB) { |
1489 context->vcounter = 0x1D5; | 1498 context->vcounter = 0x1D5; |
1490 } | 1499 } |
1491 if (headless) { | |
1492 if (context->vcounter == context->inactive_start) { | |
1493 context->frame++; | |
1494 } | |
1495 context->vcounter &= 0x1FF; | |
1496 } else { | |
1497 if (context->vcounter == context->inactive_start) { | |
1498 render_framebuffer_updated(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN: FRAMEBUFFER_ODD, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER)); | |
1499 if (context->double_res) { | |
1500 context->flags2 ^= FLAG2_EVEN_FIELD; | |
1501 } | |
1502 context->fb = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch); | |
1503 context->h40_lines = 0; | |
1504 context->frame++; | |
1505 } | |
1506 context->vcounter &= 0x1FF; | |
1507 uint32_t output_line; | |
1508 if (context->vcounter < context->inactive_start + context->border_bot) { | |
1509 output_line = context->border_top + context->vcounter; | |
1510 } else if (context->vcounter > 0x200 - context->border_top) { | |
1511 output_line = context->vcounter - (0x200 - context->border_top); | |
1512 } else { | |
1513 output_line = INVALID_LINE; | |
1514 } | |
1515 context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * output_line); | |
1516 #ifdef DEBUG_FB_FILL | |
1517 for (int i = 0; i < LINEBUF_SIZE; i++) | |
1518 { | |
1519 context->output[i] = 0xFFFF00FF; | |
1520 } | |
1521 #endif | |
1522 if (output_line != INVALID_LINE && (context->regs[REG_MODE_4] & BIT_H40)) { | |
1523 context->h40_lines++; | |
1524 } | |
1525 } | |
1526 | 1500 |
1527 if (context->vcounter > context->inactive_start) { | 1501 if (context->vcounter > context->inactive_start) { |
1528 context->hint_counter = context->regs[REG_HINT]; | 1502 context->hint_counter = context->regs[REG_HINT]; |
1529 } else if (context->hint_counter) { | 1503 } else if (context->hint_counter) { |
1530 context->hint_counter--; | 1504 context->hint_counter--; |
1531 } else { | 1505 } else { |
1532 context->flags2 |= FLAG2_HINT_PENDING; | 1506 context->flags2 |= FLAG2_HINT_PENDING; |
1533 context->pending_hint_start = context->cycles; | 1507 context->pending_hint_start = context->cycles; |
1534 context->hint_counter = context->regs[REG_HINT]; | 1508 context->hint_counter = context->regs[REG_HINT]; |
1509 } | |
1510 } | |
1511 | |
1512 static void advance_output_line(vdp_context *context) | |
1513 { | |
1514 if (headless) { | |
1515 if (context->vcounter == context->inactive_start) { | |
1516 context->frame++; | |
1517 } | |
1518 context->vcounter &= 0x1FF; | |
1519 } else { | |
1520 if (context->vcounter == context->inactive_start) { | |
1521 render_framebuffer_updated(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN: FRAMEBUFFER_ODD, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER)); | |
1522 if (context->double_res) { | |
1523 context->flags2 ^= FLAG2_EVEN_FIELD; | |
1524 } | |
1525 context->fb = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch); | |
1526 context->h40_lines = 0; | |
1527 context->frame++; | |
1528 } | |
1529 context->vcounter &= 0x1FF; | |
1530 uint32_t output_line; | |
1531 if (context->vcounter < context->inactive_start + context->border_bot) { | |
1532 output_line = context->border_top + context->vcounter; | |
1533 } else if (context->vcounter > 0x200 - context->border_top) { | |
1534 output_line = context->vcounter - (0x200 - context->border_top); | |
1535 } else { | |
1536 output_line = INVALID_LINE; | |
1537 } | |
1538 context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * output_line); | |
1539 #ifdef DEBUG_FB_FILL | |
1540 for (int i = 0; i < LINEBUF_SIZE; i++) | |
1541 { | |
1542 context->output[i] = 0xFFFF00FF; | |
1543 } | |
1544 #endif | |
1545 if (output_line != INVALID_LINE && (context->regs[REG_MODE_4] & BIT_H40)) { | |
1546 context->h40_lines++; | |
1547 } | |
1535 } | 1548 } |
1536 } | 1549 } |
1537 | 1550 |
1538 #define CHECK_ONLY if (context->cycles >= target_cycles) { return; } | 1551 #define CHECK_ONLY if (context->cycles >= target_cycles) { return; } |
1539 #define CHECK_LIMIT if (context->flags & FLAG_DMA_RUN) { run_dma_src(context, -1); } context->hslot++; context->cycles += slot_cycles; CHECK_ONLY | 1552 #define CHECK_LIMIT if (context->flags & FLAG_DMA_RUN) { run_dma_src(context, -1); } context->hslot++; context->cycles += slot_cycles; CHECK_ONLY |
1624 }\ | 1637 }\ |
1625 CHECK_ONLY | 1638 CHECK_ONLY |
1626 | 1639 |
1627 #define SPRITE_RENDER_H40(slot) \ | 1640 #define SPRITE_RENDER_H40(slot) \ |
1628 case slot:\ | 1641 case slot:\ |
1642 if ((slot) == BG_START_SLOT + LINEBUF_SIZE/2) {\ | |
1643 advance_output_line(context);\ | |
1644 }\ | |
1629 render_sprite_cells( context);\ | 1645 render_sprite_cells( context);\ |
1630 scan_sprite_table(context->vcounter, context);\ | 1646 scan_sprite_table(context->vcounter, context);\ |
1631 CHECK_LIMIT_HSYNC(slot) | 1647 CHECK_LIMIT_HSYNC(slot) |
1632 | 1648 |
1649 //Note that the line advancement check will fail if BG_START_SLOT is > 6 | |
1650 //as we're bumping up against the hcounter jump | |
1633 #define SPRITE_RENDER_H32(slot) \ | 1651 #define SPRITE_RENDER_H32(slot) \ |
1634 case slot:\ | 1652 case slot:\ |
1653 if ((slot) == BG_START_SLOT + (256+HORIZ_BORDER)/2) {\ | |
1654 advance_output_line(context);\ | |
1655 }\ | |
1635 render_sprite_cells( context);\ | 1656 render_sprite_cells( context);\ |
1636 scan_sprite_table(context->vcounter, context);\ | 1657 scan_sprite_table(context->vcounter, context);\ |
1637 if (context->flags & FLAG_DMA_RUN) { run_dma_src(context, -1); } \ | 1658 if (context->flags & FLAG_DMA_RUN) { run_dma_src(context, -1); } \ |
1638 if (slot == 147) {\ | 1659 if (slot == 147) {\ |
1639 context->hslot = 233;\ | 1660 context->hslot = 233;\ |
2275 context->vcounter < context->inactive_start + context->border_bot | 2296 context->vcounter < context->inactive_start + context->border_bot |
2276 || context->vcounter > 0x200 - context->border_top | 2297 || context->vcounter > 0x200 - context->border_top |
2277 )) { | 2298 )) { |
2278 dst = context->output + (context->hslot - BG_START_SLOT) * 2; | 2299 dst = context->output + (context->hslot - BG_START_SLOT) * 2; |
2279 } else if (context->hslot == bg_end_slot) { | 2300 } else if (context->hslot == bg_end_slot) { |
2301 advance_output_line(context); | |
2280 dst = NULL; | 2302 dst = NULL; |
2281 } | 2303 } |
2282 | 2304 |
2283 if (context->hslot == buf_clear_slot) { | 2305 if (context->hslot == buf_clear_slot) { |
2284 if (mode_5) { | 2306 if (mode_5) { |