comparison vdp.c @ 1634:e397766c3028

Added VRAM debug window
author Michael Pavone <pavone@retrodev.com>
date Fri, 09 Nov 2018 20:16:09 -0800
parents cc699c4966b1
children 95880d947257
comparison
equal deleted inserted replaced
1633:9b7cba9ba541 1634:e397766c3028
1822 } 1822 }
1823 } 1823 }
1824 } 1824 }
1825 render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_PLANE], 1024); 1825 render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_PLANE], 1024);
1826 } 1826 }
1827
1828 if (context->enabled_debuggers & (1 << VDP_DEBUG_VRAM)) {
1829 uint32_t pitch;
1830 uint32_t *fb = render_get_framebuffer(context->debug_fb_indices[VDP_DEBUG_VRAM], &pitch);
1831
1832 uint8_t pal = (context->debug_modes[VDP_DEBUG_VRAM] % 4) << 4;
1833 for (int y = 0; y < 512; y++)
1834 {
1835 uint32_t *line = fb + y * pitch / sizeof(uint32_t);
1836 int row = y >> 4;
1837 int yoff = y >> 1 & 7;
1838 for (int col = 0; col < 64; col++)
1839 {
1840 uint16_t address = (row * 64 + col) * 32 + yoff * 4;
1841 for (int x = 0; x < 4; x++)
1842 {
1843 uint8_t byte = context->vdpmem[address++];
1844 uint8_t left = byte >> 4 | pal;
1845 uint8_t right = byte & 0xF | pal;
1846 *(line++) = context->colors[left];
1847 *(line++) = context->colors[left];
1848 *(line++) = context->colors[right];
1849 *(line++) = context->colors[right];
1850 }
1851 }
1852 }
1853
1854 render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_VRAM], 1024);
1855 }
1827 } 1856 }
1828 1857
1829 void vdp_force_update_framebuffer(vdp_context *context) 1858 void vdp_force_update_framebuffer(vdp_context *context)
1830 { 1859 {
1831 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL) 1860 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL)
3852 void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type) 3881 void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
3853 { 3882 {
3854 if (context->enabled_debuggers & 1 << debug_type) { 3883 if (context->enabled_debuggers & 1 << debug_type) {
3855 //TODO: implement me 3884 //TODO: implement me
3856 } else { 3885 } else {
3886 uint32_t width,height;
3857 char *caption; 3887 char *caption;
3858 switch(debug_type) 3888 switch(debug_type)
3859 { 3889 {
3860 case VDP_DEBUG_PLANE: 3890 case VDP_DEBUG_PLANE:
3861 caption = "BlastEm - VDP Plane Debugger"; 3891 caption = "BlastEm - VDP Plane Debugger";
3892 width = height = 1024;
3893 break;
3894 case VDP_DEBUG_VRAM:
3895 caption = "BlastEm - VDP VRAM Debugger";
3896 width = 1024;
3897 height = 512;
3862 break; 3898 break;
3863 default: 3899 default:
3864 return; 3900 return;
3865 } 3901 }
3866 context->debug_fb_indices[debug_type] = render_create_window(caption, 1024, 1024); 3902 context->debug_fb_indices[debug_type] = render_create_window(caption, width, height);
3867 if (context->debug_fb_indices[debug_type]) { 3903 if (context->debug_fb_indices[debug_type]) {
3868 context->enabled_debuggers |= 1 << debug_type; 3904 context->enabled_debuggers |= 1 << debug_type;
3869 } 3905 }
3870 } 3906 }
3871 } 3907 }