Mercurial > repos > blastem
comparison vdp.c @ 2381:d3479965e631
Fix VRAM viewer and plane viewer in double-resolution interlace mode
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 20 Nov 2023 20:20:14 -0800 |
parents | 3350b3c8faa8 |
children | ce9f5a42c481 |
comparison
equal
deleted
inserted
replaced
2380:1b21290358a8 | 2381:d3479965e631 |
---|---|
2073 } | 2073 } |
2074 | 2074 |
2075 static void vram_debug_mode5(uint32_t *fb, uint32_t pitch, vdp_context *context) | 2075 static void vram_debug_mode5(uint32_t *fb, uint32_t pitch, vdp_context *context) |
2076 { | 2076 { |
2077 uint8_t pal = (context->debug_modes[DEBUG_VRAM] % 4) << 4; | 2077 uint8_t pal = (context->debug_modes[DEBUG_VRAM] % 4) << 4; |
2078 int yshift, ymask, tilesize; | |
2079 if (context->double_res) { | |
2080 yshift = 5; | |
2081 ymask = 0xF; | |
2082 tilesize = 64; | |
2083 } else { | |
2084 yshift = 4; | |
2085 ymask = 0x7; | |
2086 tilesize = 32; | |
2087 } | |
2078 for (int y = 0; y < 512; y++) | 2088 for (int y = 0; y < 512; y++) |
2079 { | 2089 { |
2080 uint32_t *line = fb + y * pitch / sizeof(uint32_t); | 2090 uint32_t *line = fb + y * pitch / sizeof(uint32_t); |
2081 int row = y >> 4; | 2091 int row = y >> yshift; |
2082 int yoff = y >> 1 & 7; | 2092 int yoff = y >> 1 & ymask; |
2083 for (int col = 0; col < 64; col++) | 2093 for (int col = 0; col < 64; col++) |
2084 { | 2094 { |
2085 uint16_t address = (row * 64 + col) * 32 + yoff * 4; | 2095 uint16_t address = (row * 64 + col) * tilesize + yoff * 4; |
2086 for (int x = 0; x < 4; x++) | 2096 for (int x = 0; x < 4; x++) |
2087 { | 2097 { |
2088 uint8_t byte = context->vdpmem[address++]; | 2098 uint8_t byte = context->vdpmem[address++]; |
2089 uint8_t left = byte >> 4 | pal; | 2099 uint8_t left = byte >> 4 | pal; |
2090 uint8_t right = byte & 0xF | pal; | 2100 uint8_t right = byte & 0xF | pal; |
2199 } | 2209 } |
2200 vscroll_mask = 0x1F; | 2210 vscroll_mask = 0x1F; |
2201 break; | 2211 break; |
2202 } | 2212 } |
2203 uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR & 0x3F]]; | 2213 uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR & 0x3F]]; |
2204 for (uint16_t row = 0; row < 128; row++) | 2214 uint16_t num_rows; |
2215 int num_lines; | |
2216 if (context->double_res) { | |
2217 num_rows = 64; | |
2218 num_lines = 16; | |
2219 } else { | |
2220 num_rows = 128; | |
2221 num_lines = 8; | |
2222 } | |
2223 for (uint16_t row = 0; row < num_rows; row++) | |
2205 { | 2224 { |
2206 uint16_t row_address = table_address + (row & vscroll_mask) * v_mul; | 2225 uint16_t row_address = table_address + (row & vscroll_mask) * v_mul; |
2207 for (uint16_t col = 0; col < 128; col++) | 2226 for (uint16_t col = 0; col < 128; col++) |
2208 { | 2227 { |
2209 uint16_t address = row_address + (col & hscroll_mask) * 2; | 2228 uint16_t address = row_address + (col & hscroll_mask) * 2; |
2210 //pccv hnnn nnnn nnnn | 2229 //pccv hnnn nnnn nnnn |
2211 // | 2230 // |
2212 uint16_t entry = context->vdpmem[address] << 8 | context->vdpmem[address + 1]; | 2231 uint16_t entry = context->vdpmem[address] << 8 | context->vdpmem[address + 1]; |
2213 uint8_t pal = entry >> 9 & 0x30; | 2232 uint8_t pal = entry >> 9 & 0x30; |
2214 | 2233 |
2215 uint32_t *dst = fb + (row * pitch * 8 / sizeof(uint32_t)) + col * 8; | 2234 uint32_t *dst = fb + (row * pitch * num_lines / sizeof(uint32_t)) + col * 8; |
2216 address = (entry & 0x7FF) * 32; | 2235 if (context->double_res) { |
2236 address = (entry & 0x3FF) * 64; | |
2237 } else { | |
2238 address = (entry & 0x7FF) * 32; | |
2239 } | |
2217 int y_diff = 4; | 2240 int y_diff = 4; |
2218 if (entry & 0x1000) { | 2241 if (entry & 0x1000) { |
2219 y_diff = -4; | 2242 y_diff = -4; |
2220 address += 7 * 4; | 2243 address += (num_lines - 1) * 4; |
2221 } | 2244 } |
2222 int x_diff = 1; | 2245 int x_diff = 1; |
2223 if (entry & 0x800) { | 2246 if (entry & 0x800) { |
2224 x_diff = -1; | 2247 x_diff = -1; |
2225 address += 3; | 2248 address += 3; |
2226 } | 2249 } |
2227 for (int y = 0; y < 8; y++) | 2250 for (int y = 0; y < num_lines; y++) |
2228 { | 2251 { |
2229 uint16_t trow_address = address; | 2252 uint16_t trow_address = address; |
2230 uint32_t *row_dst = dst; | 2253 uint32_t *row_dst = dst; |
2231 for (int x = 0; x < 4; x++) | 2254 for (int x = 0; x < 4; x++) |
2232 { | 2255 { |