Mercurial > repos > blastem
comparison vdp.c @ 2579:bd8d1babbfb5
Implement background plane debug view for Mode 4
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 07 Feb 2025 23:32:15 -0800 |
parents | dddd16a6c69b |
children | 7e04620c9dc1 |
comparison
equal
deleted
inserted
replaced
2578:9b01541cbd60 | 2579:bd8d1babbfb5 |
---|---|
2259 } | 2259 } |
2260 } | 2260 } |
2261 } | 2261 } |
2262 } | 2262 } |
2263 | 2263 |
2264 static void plane_debug_mode5(uint32_t *fb, uint32_t pitch, vdp_context *context) | |
2265 { | |
2266 uint16_t hscroll_mask; | |
2267 uint16_t v_mul; | |
2268 uint16_t vscroll_mask = 0x1F | (context->regs[REG_SCROLL] & 0x30) << 1; | |
2269 switch(context->regs[REG_SCROLL] & 0x3) | |
2270 { | |
2271 case 0: | |
2272 hscroll_mask = 0x1F; | |
2273 v_mul = 64; | |
2274 break; | |
2275 case 0x1: | |
2276 hscroll_mask = 0x3F; | |
2277 v_mul = 128; | |
2278 break; | |
2279 case 0x2: | |
2280 //TODO: Verify this behavior | |
2281 hscroll_mask = 0x1F; | |
2282 v_mul = 0; | |
2283 break; | |
2284 case 0x3: | |
2285 hscroll_mask = 0x7F; | |
2286 v_mul = 256; | |
2287 break; | |
2288 } | |
2289 uint16_t table_address; | |
2290 switch(context->debug_modes[DEBUG_PLANE] & 3) | |
2291 { | |
2292 case 0: | |
2293 table_address = context->regs[REG_SCROLL_A] << 10 & 0xE000; | |
2294 break; | |
2295 case 1: | |
2296 table_address = context->regs[REG_SCROLL_B] << 13 & 0xE000; | |
2297 break; | |
2298 case 2: | |
2299 table_address = context->regs[REG_WINDOW] << 10; | |
2300 if (context->regs[REG_MODE_4] & BIT_H40) { | |
2301 table_address &= 0xF000; | |
2302 v_mul = 128; | |
2303 hscroll_mask = 0x3F; | |
2304 } else { | |
2305 table_address &= 0xF800; | |
2306 v_mul = 64; | |
2307 hscroll_mask = 0x1F; | |
2308 } | |
2309 vscroll_mask = 0x1F; | |
2310 break; | |
2311 } | |
2312 uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; | |
2313 uint16_t num_rows; | |
2314 int num_lines; | |
2315 if (context->double_res) { | |
2316 num_rows = 64; | |
2317 num_lines = 16; | |
2318 } else { | |
2319 num_rows = 128; | |
2320 num_lines = 8; | |
2321 } | |
2322 for (uint16_t row = 0; row < num_rows; row++) | |
2323 { | |
2324 uint16_t row_address = table_address + (row & vscroll_mask) * v_mul; | |
2325 for (uint16_t col = 0; col < 128; col++) | |
2326 { | |
2327 uint16_t address = row_address + (col & hscroll_mask) * 2; | |
2328 //pccv hnnn nnnn nnnn | |
2329 // | |
2330 uint16_t entry = context->vdpmem[address] << 8 | context->vdpmem[address + 1]; | |
2331 uint8_t pal = entry >> 9 & 0x30; | |
2332 | |
2333 uint32_t *dst = fb + (row * pitch * num_lines / sizeof(uint32_t)) + col * 8; | |
2334 if (context->double_res) { | |
2335 address = (entry & 0x3FF) * 64; | |
2336 } else { | |
2337 address = (entry & 0x7FF) * 32; | |
2338 } | |
2339 int y_diff = 4; | |
2340 if (entry & 0x1000) { | |
2341 y_diff = -4; | |
2342 address += (num_lines - 1) * 4; | |
2343 } | |
2344 int x_diff = 1; | |
2345 if (entry & 0x800) { | |
2346 x_diff = -1; | |
2347 address += 3; | |
2348 } | |
2349 for (int y = 0; y < num_lines; y++) | |
2350 { | |
2351 uint16_t trow_address = address; | |
2352 uint32_t *row_dst = dst; | |
2353 for (int x = 0; x < 4; x++) | |
2354 { | |
2355 uint8_t byte = context->vdpmem[trow_address]; | |
2356 trow_address += x_diff; | |
2357 uint8_t left, right; | |
2358 if (x_diff > 0) { | |
2359 left = byte >> 4; | |
2360 right = byte & 0xF; | |
2361 } else { | |
2362 left = byte & 0xF; | |
2363 right = byte >> 4; | |
2364 } | |
2365 *(row_dst++) = left ? context->colors[left|pal] : bg_color; | |
2366 *(row_dst++) = right ? context->colors[right|pal] : bg_color; | |
2367 } | |
2368 address += y_diff; | |
2369 dst += pitch / sizeof(uint32_t); | |
2370 } | |
2371 } | |
2372 } | |
2373 } | |
2374 | |
2375 static void sprite_debug_mode5(uint32_t *fb, uint32_t pitch, vdp_context *context) | |
2376 { | |
2377 uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; | |
2378 //clear a single alpha channel bit so we can distinguish between actual bg color and sprite | |
2379 //pixels that just happen to be the same color | |
2380 bg_color &= 0xFEFFFFFF; | |
2381 uint32_t *line = fb; | |
2382 uint32_t border_line = render_map_color(0, 0, 255); | |
2383 uint32_t sprite_outline = render_map_color(255, 0, 255); | |
2384 int right_border = 256 + ((context->h40_lines > context->output_lines / 2) ? 640 : 512); | |
2385 for (int y = 0; y < 1024; y++) | |
2386 { | |
2387 uint32_t *cur = line; | |
2388 if (y != 256 && y != 256+context->inactive_start*2) { | |
2389 for (int x = 0; x < 255; x++) | |
2390 { | |
2391 *(cur++) = bg_color; | |
2392 } | |
2393 *(cur++) = border_line; | |
2394 for (int x = 256; x < right_border; x++) | |
2395 { | |
2396 *(cur++) = bg_color; | |
2397 } | |
2398 *(cur++) = border_line; | |
2399 for (int x = right_border + 1; x < 1024; x++) | |
2400 { | |
2401 *(cur++) = bg_color; | |
2402 } | |
2403 } else { | |
2404 for (int x = 0; x < 1024; x++) | |
2405 { | |
2406 *(cur++) = border_line; | |
2407 } | |
2408 } | |
2409 line += pitch / sizeof(uint32_t); | |
2410 } | |
2411 for (int i = 0, index = 0; i < context->max_sprites_frame; i++) | |
2412 { | |
2413 uint32_t y = (context->sat_cache[index] & 3) << 8 | context->sat_cache[index + 1]; | |
2414 if (!context->double_res) { | |
2415 y &= 0x1FF; | |
2416 y <<= 1; | |
2417 } | |
2418 uint8_t tile_width = ((context->sat_cache[index+2] >> 2) & 0x3); | |
2419 uint32_t pixel_width = (tile_width + 1) * 16; | |
2420 uint8_t height = ((context->sat_cache[index+2] & 3) + 1) * 16; | |
2421 uint16_t col_offset = height * (context->double_res ? 4 : 2); | |
2422 uint16_t att_addr = mode5_sat_address(context) + index * 2 + 4; | |
2423 uint16_t tileinfo = (context->vdpmem[att_addr] << 8) | context->vdpmem[att_addr+1]; | |
2424 uint16_t tile_addr; | |
2425 if (context->double_res) { | |
2426 tile_addr = (tileinfo & 0x3FF) << 6; | |
2427 } else { | |
2428 tile_addr = (tileinfo & 0x7FF) << 5; | |
2429 } | |
2430 uint8_t pal = (tileinfo >> 9) & 0x30; | |
2431 uint16_t hflip = tileinfo & MAP_BIT_H_FLIP; | |
2432 uint16_t vflip = tileinfo & MAP_BIT_V_FLIP; | |
2433 uint32_t x = (((context->vdpmem[att_addr+ 2] & 0x3) << 8 | context->vdpmem[att_addr + 3]) & 0x1FF) * 2; | |
2434 uint32_t *line = fb + y * pitch / sizeof(uint32_t) + x; | |
2435 uint32_t *cur = line; | |
2436 for (uint32_t cx = x, x2 = x + pixel_width; cx < x2; cx++) | |
2437 { | |
2438 *(cur++) = sprite_outline; | |
2439 } | |
2440 uint8_t advance_source = 1; | |
2441 uint32_t y2 = y + height - 1; | |
2442 if (y2 > 1024) { | |
2443 y2 = 1024; | |
2444 } | |
2445 uint16_t line_offset = 4; | |
2446 if (vflip) { | |
2447 tile_addr += col_offset - 4; | |
2448 line_offset = -line_offset; | |
2449 } | |
2450 if (hflip) { | |
2451 tile_addr += col_offset * tile_width + 3; | |
2452 col_offset = -col_offset; | |
2453 } | |
2454 for (; y < y2; y++) | |
2455 { | |
2456 line += pitch / sizeof(uint32_t); | |
2457 cur = line; | |
2458 *(cur++) = sprite_outline; | |
2459 uint16_t line_addr = tile_addr; | |
2460 for (uint8_t tx = 0; tx <= tile_width; tx++) | |
2461 { | |
2462 uint16_t cur_addr = line_addr; | |
2463 for (uint8_t cx = 0; cx < 4; cx++) | |
2464 { | |
2465 uint8_t pair = context->vdpmem[cur_addr]; | |
2466 uint32_t left, right; | |
2467 if (hflip) { | |
2468 right = pair >> 4; | |
2469 left = pair & 0xF; | |
2470 cur_addr--; | |
2471 } else { | |
2472 left = pair >> 4; | |
2473 right = pair & 0xF; | |
2474 cur_addr++; | |
2475 } | |
2476 left = left ? context->colors[pal | left] : bg_color; | |
2477 right = right ? context->colors[pal | right] : bg_color; | |
2478 if (*cur == bg_color) { | |
2479 *(cur) = left; | |
2480 } | |
2481 cur++; | |
2482 if (cx | tx) { | |
2483 if (*cur == bg_color) { | |
2484 *(cur) = left; | |
2485 } | |
2486 cur++; | |
2487 } | |
2488 if (*cur == bg_color) { | |
2489 *(cur) = right; | |
2490 } | |
2491 cur++; | |
2492 if (cx != 3 || tx != tile_width) { | |
2493 if (*cur == bg_color) { | |
2494 *(cur) = right; | |
2495 } | |
2496 cur++; | |
2497 } | |
2498 } | |
2499 line_addr += col_offset; | |
2500 } | |
2501 | |
2502 *(cur++) = sprite_outline; | |
2503 if (advance_source || context->double_res) { | |
2504 tile_addr += line_offset; | |
2505 } | |
2506 advance_source = !advance_source; | |
2507 } | |
2508 if (y2 != 1024) { | |
2509 line += pitch / sizeof(uint32_t); | |
2510 cur = line; | |
2511 for (uint32_t cx = x, x2 = x + pixel_width; cx < x2; cx++) | |
2512 { | |
2513 *(cur++) = sprite_outline; | |
2514 } | |
2515 } | |
2516 index = context->sat_cache[index+3] * 4; | |
2517 if (!index) { | |
2518 break; | |
2519 } | |
2520 } | |
2521 } | |
2522 | |
2523 static void plane_debug_mode4(uint32_t *fb, uint32_t pitch, vdp_context *context) | |
2524 { | |
2525 uint32_t bg_color = context->colors[(context->regs[REG_BG_COLOR] & 0xF) + MODE4_OFFSET]; | |
2526 uint32_t address = (context->regs[REG_SCROLL_A] & 0xE) << 10; | |
2527 for (uint32_t row_address = address, end = address + 32*32*2; row_address < end; row_address += 2 * 32) | |
2528 { | |
2529 uint32_t *col = fb; | |
2530 for(uint32_t cur = row_address, row_end = row_address + 2 * 32; cur < row_end; cur += 2) | |
2531 { | |
2532 uint32_t mapped = mode4_address_map[cur]; | |
2533 uint16_t entry = context->vdpmem[mapped] << 8 | context->vdpmem[mapped + 1]; | |
2534 uint32_t tile_address = (entry & 0x1FF) << 5; | |
2535 uint8_t pal = entry >> 7 & 0x10; | |
2536 uint32_t i_init, i_inc, i_limit, tile_inc; | |
2537 if (entry & 0x200) { | |
2538 //hflip | |
2539 i_init = 0; | |
2540 i_inc = 4; | |
2541 i_limit = 32; | |
2542 } else { | |
2543 i_init = 28; | |
2544 i_inc = -4; | |
2545 i_limit = -4; | |
2546 } | |
2547 if (entry & 0x400) { | |
2548 //vflip | |
2549 tile_address += 7*4; | |
2550 tile_inc = -4; | |
2551 } else { | |
2552 tile_inc = 4; | |
2553 } | |
2554 uint32_t *line = col; | |
2555 for (int y = 0; y < 16; y++) | |
2556 { | |
2557 uint32_t first = mode4_address_map[tile_address]; | |
2558 uint32_t last = mode4_address_map[tile_address + 2]; | |
2559 uint32_t pixels = planar_to_chunky[context->vdpmem[first]] << 1; | |
2560 pixels |= planar_to_chunky[context->vdpmem[first+1]]; | |
2561 pixels |= planar_to_chunky[context->vdpmem[last]] << 3; | |
2562 pixels |= planar_to_chunky[context->vdpmem[last+1]] << 2; | |
2563 uint32_t *out = line; | |
2564 for (uint32_t i = i_init; i != i_limit; i += i_inc) | |
2565 { | |
2566 uint32_t pixel = context->colors[((pixels >> i & 0xF) | pal) + MODE4_OFFSET]; | |
2567 *(out++) = pixel; | |
2568 *(out++) = pixel; | |
2569 } | |
2570 | |
2571 | |
2572 if (y & 1) { | |
2573 tile_address += tile_inc; | |
2574 } | |
2575 line += pitch / sizeof(uint32_t); | |
2576 } | |
2577 | |
2578 | |
2579 | |
2580 col += 16; | |
2581 } | |
2582 fb += 16 * pitch / sizeof(uint32_t); | |
2583 } | |
2584 } | |
2585 | |
2586 static void sprite_debug_mode4(uint32_t *fb, uint32_t pitch, vdp_context *context) | |
2587 { | |
2588 } | |
2589 | |
2590 static void plane_debug_tms(uint32_t *fb, uint32_t pitch, vdp_context *context) | |
2591 { | |
2592 } | |
2593 | |
2594 static void sprite_debug_tms(uint32_t *fb, uint32_t pitch, vdp_context *context) | |
2595 { | |
2596 } | |
2264 | 2597 |
2265 static void vdp_update_per_frame_debug(vdp_context *context) | 2598 static void vdp_update_per_frame_debug(vdp_context *context) |
2266 { | 2599 { |
2267 if (context->enabled_debuggers & (1 << DEBUG_PLANE)) { | 2600 if (context->enabled_debuggers & (1 << DEBUG_PLANE)) { |
2601 | |
2268 uint32_t pitch; | 2602 uint32_t pitch; |
2269 uint32_t *fb = render_get_framebuffer(context->debug_fb_indices[DEBUG_PLANE], &pitch); | 2603 uint32_t *fb = render_get_framebuffer(context->debug_fb_indices[DEBUG_PLANE], &pitch); |
2270 uint16_t hscroll_mask; | 2604 if (context->type == VDP_GENESIS && (context->regs[REG_MODE_2] & BIT_MODE_5)) { |
2271 uint16_t v_mul; | 2605 if ((context->debug_modes[DEBUG_PLANE] & 3) == 3) { |
2272 uint16_t vscroll_mask = 0x1F | (context->regs[REG_SCROLL] & 0x30) << 1; | 2606 sprite_debug_mode5(fb, pitch, context); |
2273 switch(context->regs[REG_SCROLL] & 0x3) | |
2274 { | |
2275 case 0: | |
2276 hscroll_mask = 0x1F; | |
2277 v_mul = 64; | |
2278 break; | |
2279 case 0x1: | |
2280 hscroll_mask = 0x3F; | |
2281 v_mul = 128; | |
2282 break; | |
2283 case 0x2: | |
2284 //TODO: Verify this behavior | |
2285 hscroll_mask = 0x1F; | |
2286 v_mul = 0; | |
2287 break; | |
2288 case 0x3: | |
2289 hscroll_mask = 0x7F; | |
2290 v_mul = 256; | |
2291 break; | |
2292 } | |
2293 uint16_t table_address; | |
2294 switch(context->debug_modes[DEBUG_PLANE] & 3) | |
2295 { | |
2296 case 0: | |
2297 table_address = context->regs[REG_SCROLL_A] << 10 & 0xE000; | |
2298 break; | |
2299 case 1: | |
2300 table_address = context->regs[REG_SCROLL_B] << 13 & 0xE000; | |
2301 break; | |
2302 case 2: | |
2303 table_address = context->regs[REG_WINDOW] << 10; | |
2304 if (context->regs[REG_MODE_4] & BIT_H40) { | |
2305 table_address &= 0xF000; | |
2306 v_mul = 128; | |
2307 hscroll_mask = 0x3F; | |
2308 } else { | 2607 } else { |
2309 table_address &= 0xF800; | 2608 plane_debug_mode5(fb, pitch, context); |
2310 v_mul = 64; | 2609 } |
2311 hscroll_mask = 0x1F; | 2610 } else if (context->type != VDP_TMS9918A && (context->regs[REG_MODE_1] & BIT_MODE_4)) { |
2312 } | 2611 if (context->debug_modes[DEBUG_PLANE] & 1) { |
2313 vscroll_mask = 0x1F; | 2612 sprite_debug_mode4(fb, pitch, context); |
2314 break; | |
2315 } | |
2316 uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR & 0x3F]]; | |
2317 if ((context->debug_modes[DEBUG_PLANE] & 3) == 3) { | |
2318 //clear a single alpha channel bit so we can distinguish between actual bg color and sprite | |
2319 //pixels that just happen to be the same color | |
2320 bg_color &= 0xFEFFFFFF; | |
2321 uint32_t *line = fb; | |
2322 uint32_t border_line = render_map_color(0, 0, 255); | |
2323 uint32_t sprite_outline = render_map_color(255, 0, 255); | |
2324 int right_border = 256 + ((context->h40_lines > context->output_lines / 2) ? 640 : 512); | |
2325 for (int y = 0; y < 1024; y++) | |
2326 { | |
2327 uint32_t *cur = line; | |
2328 if (y != 256 && y != 256+context->inactive_start*2) { | |
2329 for (int x = 0; x < 255; x++) | |
2330 { | |
2331 *(cur++) = bg_color; | |
2332 } | |
2333 *(cur++) = border_line; | |
2334 for (int x = 256; x < right_border; x++) | |
2335 { | |
2336 *(cur++) = bg_color; | |
2337 } | |
2338 *(cur++) = border_line; | |
2339 for (int x = right_border + 1; x < 1024; x++) | |
2340 { | |
2341 *(cur++) = bg_color; | |
2342 } | |
2343 } else { | |
2344 for (int x = 0; x < 1024; x++) | |
2345 { | |
2346 *(cur++) = border_line; | |
2347 } | |
2348 } | |
2349 line += pitch / sizeof(uint32_t); | |
2350 } | |
2351 for (int i = 0, index = 0; i < context->max_sprites_frame; i++) | |
2352 { | |
2353 uint32_t y = (context->sat_cache[index] & 3) << 8 | context->sat_cache[index + 1]; | |
2354 if (!context->double_res) { | |
2355 y &= 0x1FF; | |
2356 y <<= 1; | |
2357 } | |
2358 uint8_t tile_width = ((context->sat_cache[index+2] >> 2) & 0x3); | |
2359 uint32_t pixel_width = (tile_width + 1) * 16; | |
2360 uint8_t height = ((context->sat_cache[index+2] & 3) + 1) * 16; | |
2361 uint16_t col_offset = height * (context->double_res ? 4 : 2); | |
2362 uint16_t att_addr = mode5_sat_address(context) + index * 2 + 4; | |
2363 uint16_t tileinfo = (context->vdpmem[att_addr] << 8) | context->vdpmem[att_addr+1]; | |
2364 uint16_t tile_addr; | |
2365 if (context->double_res) { | |
2366 tile_addr = (tileinfo & 0x3FF) << 6; | |
2367 } else { | |
2368 tile_addr = (tileinfo & 0x7FF) << 5; | |
2369 } | |
2370 uint8_t pal = (tileinfo >> 9) & 0x30; | |
2371 uint16_t hflip = tileinfo & MAP_BIT_H_FLIP; | |
2372 uint16_t vflip = tileinfo & MAP_BIT_V_FLIP; | |
2373 uint32_t x = (((context->vdpmem[att_addr+ 2] & 0x3) << 8 | context->vdpmem[att_addr + 3]) & 0x1FF) * 2; | |
2374 uint32_t *line = fb + y * pitch / sizeof(uint32_t) + x; | |
2375 uint32_t *cur = line; | |
2376 for (uint32_t cx = x, x2 = x + pixel_width; cx < x2; cx++) | |
2377 { | |
2378 *(cur++) = sprite_outline; | |
2379 } | |
2380 uint8_t advance_source = 1; | |
2381 uint32_t y2 = y + height - 1; | |
2382 if (y2 > 1024) { | |
2383 y2 = 1024; | |
2384 } | |
2385 uint16_t line_offset = 4; | |
2386 if (vflip) { | |
2387 tile_addr += col_offset - 4; | |
2388 line_offset = -line_offset; | |
2389 } | |
2390 if (hflip) { | |
2391 tile_addr += col_offset * tile_width + 3; | |
2392 col_offset = -col_offset; | |
2393 } | |
2394 for (; y < y2; y++) | |
2395 { | |
2396 line += pitch / sizeof(uint32_t); | |
2397 cur = line; | |
2398 *(cur++) = sprite_outline; | |
2399 uint16_t line_addr = tile_addr; | |
2400 for (uint8_t tx = 0; tx <= tile_width; tx++) | |
2401 { | |
2402 uint16_t cur_addr = line_addr; | |
2403 for (uint8_t cx = 0; cx < 4; cx++) | |
2404 { | |
2405 uint8_t pair = context->vdpmem[cur_addr]; | |
2406 uint32_t left, right; | |
2407 if (hflip) { | |
2408 right = pair >> 4; | |
2409 left = pair & 0xF; | |
2410 cur_addr--; | |
2411 } else { | |
2412 left = pair >> 4; | |
2413 right = pair & 0xF; | |
2414 cur_addr++; | |
2415 } | |
2416 left = left ? context->colors[pal | left] : bg_color; | |
2417 right = right ? context->colors[pal | right] : bg_color; | |
2418 if (*cur == bg_color) { | |
2419 *(cur) = left; | |
2420 } | |
2421 cur++; | |
2422 if (cx | tx) { | |
2423 if (*cur == bg_color) { | |
2424 *(cur) = left; | |
2425 } | |
2426 cur++; | |
2427 } | |
2428 if (*cur == bg_color) { | |
2429 *(cur) = right; | |
2430 } | |
2431 cur++; | |
2432 if (cx != 3 || tx != tile_width) { | |
2433 if (*cur == bg_color) { | |
2434 *(cur) = right; | |
2435 } | |
2436 cur++; | |
2437 } | |
2438 } | |
2439 line_addr += col_offset; | |
2440 } | |
2441 | |
2442 *(cur++) = sprite_outline; | |
2443 if (advance_source || context->double_res) { | |
2444 tile_addr += line_offset; | |
2445 } | |
2446 advance_source = !advance_source; | |
2447 } | |
2448 if (y2 != 1024) { | |
2449 line += pitch / sizeof(uint32_t); | |
2450 cur = line; | |
2451 for (uint32_t cx = x, x2 = x + pixel_width; cx < x2; cx++) | |
2452 { | |
2453 *(cur++) = sprite_outline; | |
2454 } | |
2455 } | |
2456 index = context->sat_cache[index+3] * 4; | |
2457 if (!index) { | |
2458 break; | |
2459 } | |
2460 } | |
2461 } else { | |
2462 | |
2463 uint16_t num_rows; | |
2464 int num_lines; | |
2465 if (context->double_res) { | |
2466 num_rows = 64; | |
2467 num_lines = 16; | |
2468 } else { | 2613 } else { |
2469 num_rows = 128; | 2614 plane_debug_mode4(fb, pitch, context); |
2470 num_lines = 8; | 2615 } |
2471 } | 2616 } else if (context->type != VDP_GENESIS) { |
2472 for (uint16_t row = 0; row < num_rows; row++) | 2617 if (context->debug_modes[DEBUG_PLANE] & 1) { |
2473 { | 2618 sprite_debug_tms(fb, pitch, context); |
2474 uint16_t row_address = table_address + (row & vscroll_mask) * v_mul; | 2619 } else { |
2475 for (uint16_t col = 0; col < 128; col++) | 2620 plane_debug_tms(fb, pitch, context); |
2476 { | |
2477 uint16_t address = row_address + (col & hscroll_mask) * 2; | |
2478 //pccv hnnn nnnn nnnn | |
2479 // | |
2480 uint16_t entry = context->vdpmem[address] << 8 | context->vdpmem[address + 1]; | |
2481 uint8_t pal = entry >> 9 & 0x30; | |
2482 | |
2483 uint32_t *dst = fb + (row * pitch * num_lines / sizeof(uint32_t)) + col * 8; | |
2484 if (context->double_res) { | |
2485 address = (entry & 0x3FF) * 64; | |
2486 } else { | |
2487 address = (entry & 0x7FF) * 32; | |
2488 } | |
2489 int y_diff = 4; | |
2490 if (entry & 0x1000) { | |
2491 y_diff = -4; | |
2492 address += (num_lines - 1) * 4; | |
2493 } | |
2494 int x_diff = 1; | |
2495 if (entry & 0x800) { | |
2496 x_diff = -1; | |
2497 address += 3; | |
2498 } | |
2499 for (int y = 0; y < num_lines; y++) | |
2500 { | |
2501 uint16_t trow_address = address; | |
2502 uint32_t *row_dst = dst; | |
2503 for (int x = 0; x < 4; x++) | |
2504 { | |
2505 uint8_t byte = context->vdpmem[trow_address]; | |
2506 trow_address += x_diff; | |
2507 uint8_t left, right; | |
2508 if (x_diff > 0) { | |
2509 left = byte >> 4; | |
2510 right = byte & 0xF; | |
2511 } else { | |
2512 left = byte & 0xF; | |
2513 right = byte >> 4; | |
2514 } | |
2515 *(row_dst++) = left ? context->colors[left|pal] : bg_color; | |
2516 *(row_dst++) = right ? context->colors[right|pal] : bg_color; | |
2517 } | |
2518 address += y_diff; | |
2519 dst += pitch / sizeof(uint32_t); | |
2520 } | |
2521 } | |
2522 } | 2621 } |
2523 } | 2622 } |
2524 render_framebuffer_updated(context->debug_fb_indices[DEBUG_PLANE], 1024); | 2623 render_framebuffer_updated(context->debug_fb_indices[DEBUG_PLANE], 1024); |
2525 } | 2624 } |
2526 | 2625 |
5802 char *caption; | 5901 char *caption; |
5803 switch(debug_type) | 5902 switch(debug_type) |
5804 { | 5903 { |
5805 case DEBUG_PLANE: | 5904 case DEBUG_PLANE: |
5806 caption = "BlastEm - VDP Plane Debugger"; | 5905 caption = "BlastEm - VDP Plane Debugger"; |
5807 width = height = 1024; | 5906 if (context->type == VDP_GENESIS) { |
5907 width = height = 1024; | |
5908 } else { | |
5909 width = height = 512; | |
5910 } | |
5808 break; | 5911 break; |
5809 case DEBUG_VRAM: | 5912 case DEBUG_VRAM: |
5810 caption = "BlastEm - VDP VRAM Debugger"; | 5913 caption = "BlastEm - VDP VRAM Debugger"; |
5811 width = 1024; | 5914 width = 1024; |
5812 height = 512; | 5915 height = 512; |