Mercurial > repos > blastem
comparison vdp.c @ 719:019d27995e32
Upgrade to SDL 2.0 and drop support for the non-OpenGL render path
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 20 May 2015 19:05:11 -0700 |
parents | eaba6789f316 |
children | 15d9359fd771 |
comparison
equal
deleted
inserted
replaced
718:eaba6789f316 | 719:019d27995e32 |
---|---|
60 if (headless) { | 60 if (headless) { |
61 context->oddbuf = context->framebuf = malloc(FRAMEBUF_ENTRIES * (32 / 8)); | 61 context->oddbuf = context->framebuf = malloc(FRAMEBUF_ENTRIES * (32 / 8)); |
62 memset(context->framebuf, 0, FRAMEBUF_ENTRIES * (32 / 8)); | 62 memset(context->framebuf, 0, FRAMEBUF_ENTRIES * (32 / 8)); |
63 context->evenbuf = malloc(FRAMEBUF_ENTRIES * (32 / 8)); | 63 context->evenbuf = malloc(FRAMEBUF_ENTRIES * (32 / 8)); |
64 memset(context->evenbuf, 0, FRAMEBUF_ENTRIES * (32 / 8)); | 64 memset(context->evenbuf, 0, FRAMEBUF_ENTRIES * (32 / 8)); |
65 context->b32 = 1; | |
66 } else { | 65 } else { |
67 render_alloc_surfaces(context); | 66 render_alloc_surfaces(context); |
68 context->b32 = render_depth() == 32; | |
69 } | 67 } |
70 context->framebuf = context->oddbuf; | 68 context->framebuf = context->oddbuf; |
71 context->linebuf = malloc(LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); | 69 context->linebuf = malloc(LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); |
72 memset(context->linebuf, 0, LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); | 70 memset(context->linebuf, 0, LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); |
73 context->tmp_buf_a = context->linebuf + LINEBUF_SIZE; | 71 context->tmp_buf_a = context->linebuf + LINEBUF_SIZE; |
786 { | 784 { |
787 if (line >= 240) { | 785 if (line >= 240) { |
788 return; | 786 return; |
789 } | 787 } |
790 render_map(context->col_2, context->tmp_buf_b, context->buf_b_off+8, context); | 788 render_map(context->col_2, context->tmp_buf_b, context->buf_b_off+8, context); |
791 uint16_t *dst; | 789 uint32_t *dst; |
792 uint32_t *dst32; | |
793 uint8_t *sprite_buf, *plane_a, *plane_b; | 790 uint8_t *sprite_buf, *plane_a, *plane_b; |
794 int plane_a_off, plane_b_off; | 791 int plane_a_off, plane_b_off; |
795 if (col) | 792 if (col) |
796 { | 793 { |
797 col-=2; | 794 col-=2; |
798 if (context->b32) { | 795 dst = context->framebuf; |
799 dst32 = context->framebuf; | 796 dst += line * 320 + col * 8; |
800 dst32 += line * 320 + col * 8; | |
801 } else { | |
802 dst = context->framebuf; | |
803 dst += line * 320 + col * 8; | |
804 } | |
805 sprite_buf = context->linebuf + col * 8; | 797 sprite_buf = context->linebuf + col * 8; |
806 uint8_t a_src, src; | 798 uint8_t a_src, src; |
807 if (context->flags & FLAG_WINDOW) { | 799 if (context->flags & FLAG_WINDOW) { |
808 plane_a_off = context->buf_a_off; | 800 plane_a_off = context->buf_a_off; |
809 a_src = DBG_SRC_W; | 801 a_src = DBG_SRC_W; |
857 if (context->debug) { | 849 if (context->debug) { |
858 outpixel = context->debugcolors[src]; | 850 outpixel = context->debugcolors[src]; |
859 } else { | 851 } else { |
860 outpixel = colors[pixel]; | 852 outpixel = colors[pixel]; |
861 } | 853 } |
862 if (context->b32) { | 854 *(dst++) = outpixel; |
863 *(dst32++) = outpixel; | |
864 } else { | |
865 *(dst++) = outpixel; | |
866 } | |
867 //*dst = (context->cram[pixel & 0x3F] & 0xEEE) | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src; | 855 //*dst = (context->cram[pixel & 0x3F] & 0xEEE) | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src; |
868 } | 856 } |
869 } else { | 857 } else { |
870 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) { | 858 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) { |
871 plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK); | 859 plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK); |
888 if (context->debug) { | 876 if (context->debug) { |
889 outpixel = context->debugcolors[src]; | 877 outpixel = context->debugcolors[src]; |
890 } else { | 878 } else { |
891 outpixel = context->colors[pixel & 0x3F]; | 879 outpixel = context->colors[pixel & 0x3F]; |
892 } | 880 } |
893 if (context->b32) { | 881 *(dst++) = outpixel; |
894 *(dst32++) = outpixel; | |
895 } else { | |
896 *(dst++) = outpixel; | |
897 } | |
898 } | 882 } |
899 } | 883 } |
900 } | 884 } |
901 context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK; | 885 context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK; |
902 context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK; | 886 context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK; |
1443 uint32_t x = (slot-11)*2; | 1427 uint32_t x = (slot-11)*2; |
1444 starti = line * 320 + x; | 1428 starti = line * 320 + x; |
1445 } | 1429 } |
1446 } | 1430 } |
1447 if (starti >= 0) { | 1431 if (starti >= 0) { |
1448 if (context->b32) { | 1432 uint32_t color = context->colors[context->regs[REG_BG_COLOR]]; |
1449 uint32_t color = context->colors[context->regs[REG_BG_COLOR]]; | 1433 uint32_t * start = context->framebuf; |
1450 uint32_t * start = context->framebuf; | 1434 start += starti; |
1451 start += starti; | 1435 for (int i = 0; i < 2; i++) { |
1452 for (int i = 0; i < 2; i++) { | 1436 *(start++) = color; |
1453 *(start++) = color; | |
1454 } | |
1455 } else { | |
1456 uint16_t color = context->colors[context->regs[REG_BG_COLOR]]; | |
1457 uint16_t * start = context->framebuf; | |
1458 start += starti; | |
1459 for (int i = 0; i < 2; i++) { | |
1460 *(start++) = color; | |
1461 } | |
1462 } | 1437 } |
1463 } | 1438 } |
1464 } | 1439 } |
1465 | 1440 |
1466 uint32_t const h40_hsync_cycles[] = {19, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 19}; | 1441 uint32_t const h40_hsync_cycles[] = {19, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 19}; |