src/mame/video/snes.c
| r7496 | r7497 | |
| 111 | 111 | |
| 112 | 112 | struct SCANLINE |
| 113 | 113 | { |
| 114 | int enable, clip; |
| 115 | |
| 114 | 116 | UINT16 buffer[(SNES_SCR_WIDTH * 2)]; |
| 115 | 117 | UINT8 priority[(SNES_SCR_WIDTH * 2)]; |
| 116 | 118 | UINT8 layer[(SNES_SCR_WIDTH * 2)]; |
| r7496 | r7497 | |
| 237 | 239 | * |
| 238 | 240 | * Draw tiles with variable bit planes |
| 239 | 241 | *****************************************/ |
| 240 | | INLINE void snes_draw_tile(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 242 | INLINE void snes_draw_tile(UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 241 | 243 | { |
| 242 | | UINT8 mask, plane[8], window_enabled = 0; |
| 244 | UINT8 mask, plane[8]; |
| 243 | 245 | UINT16 c; |
| 244 | 246 | INT16 ii, jj; |
| 245 | 247 | |
| r7496 | r7497 | |
| 272 | 274 | mask >>= 1; |
| 273 | 275 | } |
| 274 | 276 | |
| 277 | |
| 278 | if (!hires) |
| 279 | { |
| 280 | if (scanlines[SNES_MAINSCREEN].enable) |
| 281 | { |
| 282 | |
| 275 | 283 | #ifdef SNES_LAYER_DEBUG |
| 276 | | if (!debug_options.windows_disabled) |
| 284 | if (!debug_options.windows_disabled) |
| 277 | 285 | #endif /* SNES_LAYER_DEBUG */ |
| 278 | | /* Clip to windows */ |
| 279 | | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 280 | | if (window_enabled) |
| 281 | | colour &= snes_ppu.clipmasks[layer][ii >> hires]; |
| 286 | /* Clip to windows */ |
| 287 | if (scanlines[SNES_MAINSCREEN].clip) |
| 288 | colour &= snes_ppu.clipmasks[layer][ii]; |
| 282 | 289 | |
| 283 | | /* Only draw if we have a colour (0 == transparent) */ |
| 284 | | if (colour) |
| 285 | | { |
| 286 | | if ((scanlines[screen].priority[ii >> hires] <= priority) && (ii >= 0)) |
| 290 | /* Only draw if we have a colour (0 == transparent) */ |
| 291 | if (colour) |
| 292 | { |
| 293 | if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 294 | { |
| 295 | if (direct_colors) |
| 296 | { |
| 297 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 298 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 299 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 300 | } |
| 301 | else |
| 302 | c = snes_cgram[pal + colour]; |
| 303 | |
| 304 | if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic |
| 305 | { |
| 306 | int x_mos; |
| 307 | |
| 308 | //TODO: 512 modes has the h values doubled. |
| 309 | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 310 | { |
| 311 | scanlines[SNES_MAINSCREEN].buffer[ii + x_mos] = c; |
| 312 | scanlines[SNES_MAINSCREEN].priority[ii + x_mos] = priority; |
| 313 | scanlines[SNES_MAINSCREEN].layer[ii + x_mos] = layer; |
| 314 | } |
| 315 | |
| 316 | ii += x_mos - 1; |
| 317 | } |
| 318 | else |
| 319 | { |
| 320 | scanlines[SNES_MAINSCREEN].buffer[ii] = c; |
| 321 | scanlines[SNES_MAINSCREEN].priority[ii] = priority; |
| 322 | scanlines[SNES_MAINSCREEN].layer[ii] = layer; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | if (scanlines[SNES_SUBSCREEN].enable) |
| 287 | 329 | { |
| 288 | | if (direct_colors) |
| 330 | #ifdef SNES_LAYER_DEBUG |
| 331 | if (!debug_options.windows_disabled) |
| 332 | #endif /* SNES_LAYER_DEBUG */ |
| 333 | /* Clip to windows */ |
| 334 | if (scanlines[SNES_SUBSCREEN].clip) |
| 335 | colour &= snes_ppu.clipmasks[layer][ii]; |
| 336 | |
| 337 | /* Only draw if we have a colour (0 == transparent) */ |
| 338 | if (colour) |
| 289 | 339 | { |
| 290 | | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 291 | | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 292 | | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 340 | if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 341 | { |
| 342 | if (direct_colors) |
| 343 | { |
| 344 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 345 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 346 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 347 | } |
| 348 | else |
| 349 | c = snes_cgram[pal + colour]; |
| 350 | |
| 351 | if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic |
| 352 | { |
| 353 | int x_mos; |
| 354 | |
| 355 | //TODO: 512 modes has the h values doubled. |
| 356 | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 357 | { |
| 358 | scanlines[SNES_SUBSCREEN].buffer[ii + x_mos] = c; |
| 359 | scanlines[SNES_SUBSCREEN].priority[ii + x_mos] = priority; |
| 360 | scanlines[SNES_SUBSCREEN].layer[ii + x_mos] = layer; |
| 361 | } |
| 362 | |
| 363 | ii += x_mos - 1; |
| 364 | } |
| 365 | else |
| 366 | { |
| 367 | scanlines[SNES_SUBSCREEN].buffer[ii] = c; |
| 368 | scanlines[SNES_SUBSCREEN].priority[ii] = priority; |
| 369 | scanlines[SNES_SUBSCREEN].layer[ii] = layer; |
| 370 | } |
| 371 | } |
| 293 | 372 | } |
| 294 | | else |
| 295 | | c = snes_cgram[pal + colour]; |
| 373 | } |
| 374 | } |
| 296 | 375 | |
| 297 | | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 376 | else /* hires */ |
| 377 | { |
| 378 | #ifdef SNES_LAYER_DEBUG |
| 379 | if (!debug_options.windows_disabled) |
| 380 | #endif /* SNES_LAYER_DEBUG */ |
| 381 | /* Clip to windows */ |
| 382 | if (scanlines[SNES_MAINSCREEN].clip) |
| 383 | colour &= snes_ppu.clipmasks[layer][ii >> hires]; |
| 384 | |
| 385 | /* Only draw if we have a colour (0 == transparent) */ |
| 386 | if (colour) |
| 387 | { |
| 388 | if ((scanlines[SNES_MAINSCREEN].priority[ii >> hires] <= priority) && (ii >= 0)) |
| 298 | 389 | { |
| 299 | | int x_mos; |
| 390 | if (direct_colors) |
| 391 | { |
| 392 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 393 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 394 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 395 | } |
| 396 | else |
| 397 | c = snes_cgram[pal + colour]; |
| 300 | 398 | |
| 301 | | //TODO: 512 modes has the h values doubled. |
| 302 | | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 399 | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 303 | 400 | { |
| 304 | | if (hires) |
| 401 | int x_mos; |
| 402 | |
| 403 | //TODO: 512 modes has the h values doubled. |
| 404 | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 305 | 405 | { |
| 306 | | if (ii & 1) |
| 406 | if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable) |
| 307 | 407 | { |
| 308 | 408 | scanlines[SNES_MAINSCREEN].buffer[(ii + x_mos) >> 1] = c; |
| 309 | 409 | scanlines[SNES_MAINSCREEN].priority[(ii + x_mos) >> 1] = priority; |
| 310 | 410 | scanlines[SNES_MAINSCREEN].layer[(ii + x_mos) >> 1] = layer; |
| 311 | 411 | } |
| 312 | | else |
| 412 | else if (scanlines[SNES_SUBSCREEN].enable) |
| 313 | 413 | { |
| 314 | 414 | scanlines[SNES_SUBSCREEN].buffer[(ii + x_mos) >> 1] = c; |
| 315 | 415 | scanlines[SNES_SUBSCREEN].priority[(ii + x_mos) >> 1] = priority; |
| 316 | 416 | scanlines[SNES_SUBSCREEN].layer[(ii + x_mos) >> 1] = layer; |
| 317 | 417 | } |
| 318 | 418 | } |
| 319 | | else |
| 320 | | { |
| 321 | | scanlines[screen].buffer[ii + x_mos] = c; |
| 322 | | scanlines[screen].priority[ii + x_mos] = priority; |
| 323 | | scanlines[screen].layer[ii + x_mos] = layer; |
| 324 | | } |
| 419 | ii += x_mos - 1; |
| 325 | 420 | } |
| 326 | | ii += x_mos - 1; |
| 327 | | } |
| 328 | | else |
| 329 | | { |
| 330 | | if (hires) |
| 421 | else |
| 331 | 422 | { |
| 332 | | if (ii & 1) |
| 423 | if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable) |
| 333 | 424 | { |
| 334 | 425 | scanlines[SNES_MAINSCREEN].buffer[ii >> 1] = c; |
| 335 | 426 | scanlines[SNES_MAINSCREEN].priority[ii >> 1] = priority; |
| 336 | 427 | scanlines[SNES_MAINSCREEN].layer[ii >> 1] = layer; |
| 337 | 428 | } |
| 338 | | else |
| 429 | else if (scanlines[SNES_SUBSCREEN].enable) |
| 339 | 430 | { |
| 340 | 431 | scanlines[SNES_SUBSCREEN].buffer[ii >> 1] = c; |
| 341 | 432 | scanlines[SNES_SUBSCREEN].priority[ii >> 1] = priority; |
| 342 | 433 | scanlines[SNES_SUBSCREEN].layer[ii >> 1] = layer; |
| 343 | 434 | } |
| 344 | 435 | } |
| 345 | | else |
| 346 | | { |
| 347 | | scanlines[screen].buffer[ii] = c; |
| 348 | | scanlines[screen].priority[ii] = priority; |
| 349 | | scanlines[screen].layer[ii] = layer; |
| 350 | | } |
| 351 | 436 | } |
| 352 | 437 | } |
| 353 | 438 | } |
| r7496 | r7497 | |
| 359 | 444 | * |
| 360 | 445 | * Draw 2 tiles with variable bit planes |
| 361 | 446 | *****************************************/ |
| 362 | | INLINE void snes_draw_tile_x2(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 447 | INLINE void snes_draw_tile_x2(UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 363 | 448 | { |
| 364 | 449 | if (flip) |
| 365 | 450 | { |
| 366 | | snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors, hires); |
| 367 | | snes_draw_tile(screen, planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors, hires); |
| 451 | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors, hires); |
| 452 | snes_draw_tile(planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors, hires); |
| 368 | 453 | } |
| 369 | 454 | else |
| 370 | 455 | { |
| 371 | | snes_draw_tile(screen, planes, layer, tileaddr, x, priority, flip, pal, direct_colors, hires); |
| 372 | | snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors, hires); |
| 456 | snes_draw_tile(planes, layer, tileaddr, x, priority, flip, pal, direct_colors, hires); |
| 457 | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors, hires); |
| 373 | 458 | } |
| 374 | 459 | } |
| 375 | 460 | |
| r7496 | r7497 | |
| 380 | 465 | * The same as snes_draw_tile_4() except |
| 381 | 466 | * that it takes a blend parameter. |
| 382 | 467 | *****************************************/ |
| 383 | | INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend, UINT8 wide ) |
| 468 | INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) |
| 384 | 469 | { |
| 385 | | UINT8 mask, plane[4], window_enabled = 0; |
| 470 | UINT8 mask, plane[4]; |
| 386 | 471 | UINT16 c; |
| 387 | 472 | INT16 ii; |
| 388 | | UINT8 x_shift = wide ? 1 : 0; |
| 389 | | UINT8 size = wide ? 16 : 8; |
| 390 | | UINT8 step = wide ? 1 : 0; |
| 391 | 473 | |
| 392 | 474 | plane[0] = snes_vram[tileaddr]; |
| 393 | 475 | plane[1] = snes_vram[tileaddr + 1]; |
| r7496 | r7497 | |
| 399 | 481 | else |
| 400 | 482 | mask = 0x80; |
| 401 | 483 | |
| 402 | | x <<= x_shift; |
| 403 | | for (ii = x; ii < (x + size); ii += 1 + step) |
| 484 | for (ii = x; ii < (x + 8); ii++) |
| 404 | 485 | { |
| 405 | 486 | UINT8 colour; |
| 406 | 487 | if (flip) |
| r7496 | r7497 | |
| 416 | 497 | mask >>= 1; |
| 417 | 498 | } |
| 418 | 499 | |
| 500 | if (scanlines[SNES_MAINSCREEN].enable) |
| 501 | { |
| 502 | |
| 419 | 503 | #ifdef SNES_LAYER_DEBUG |
| 420 | | if (!debug_options.windows_disabled) |
| 504 | if (!debug_options.windows_disabled) |
| 421 | 505 | #endif /* SNES_LAYER_DEBUG */ |
| 422 | | /* Clip to windows */ |
| 423 | | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[SNES_OAM].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 424 | | if (window_enabled) |
| 425 | | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 506 | /* Clip to windows */ |
| 507 | if (scanlines[SNES_MAINSCREEN].clip) |
| 508 | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 426 | 509 | |
| 427 | | /* Only draw if we have a colour (0 == transparent) */ |
| 428 | | if (colour) |
| 510 | /* Only draw if we have a colour (0 == transparent) */ |
| 511 | if (colour) |
| 512 | { |
| 513 | if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 514 | { |
| 515 | c = snes_cgram[pal + colour]; |
| 516 | |
| 517 | scanlines[SNES_MAINSCREEN].buffer[ii] = c; |
| 518 | scanlines[SNES_MAINSCREEN].priority[ii] = priority; |
| 519 | scanlines[SNES_MAINSCREEN].layer[ii] = SNES_OAM; |
| 520 | scanlines[SNES_MAINSCREEN].blend_exception[ii] = blend; |
| 521 | } |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | if (scanlines[SNES_SUBSCREEN].enable) |
| 429 | 526 | { |
| 430 | | if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0)) |
| 527 | |
| 528 | #ifdef SNES_LAYER_DEBUG |
| 529 | if (!debug_options.windows_disabled) |
| 530 | #endif /* SNES_LAYER_DEBUG */ |
| 531 | /* Clip to windows */ |
| 532 | if (scanlines[SNES_SUBSCREEN].clip) |
| 533 | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 534 | |
| 535 | /* Only draw if we have a colour (0 == transparent) */ |
| 536 | if (colour) |
| 431 | 537 | { |
| 432 | | c = snes_cgram[pal + colour]; |
| 538 | if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 539 | { |
| 540 | c = snes_cgram[pal + colour]; |
| 433 | 541 | |
| 434 | | scanlines[screen].buffer[ii] = c; |
| 435 | | scanlines[screen].priority[ii] = priority; |
| 436 | | scanlines[screen].layer[ii] = SNES_OAM; |
| 437 | | scanlines[screen].blend_exception[ii] = blend; |
| 438 | | if (wide) |
| 439 | | { |
| 440 | | scanlines[screen].buffer[ii + 1] = c; |
| 441 | | scanlines[screen].priority[ii + 1] = priority; |
| 442 | | scanlines[screen].layer[ii + 1] = SNES_OAM; |
| 443 | | scanlines[screen].blend_exception[ii + 1] = blend; |
| 542 | scanlines[SNES_SUBSCREEN].buffer[ii] = c; |
| 543 | scanlines[SNES_SUBSCREEN].priority[ii] = priority; |
| 544 | scanlines[SNES_SUBSCREEN].layer[ii] = SNES_OAM; |
| 545 | scanlines[SNES_SUBSCREEN].blend_exception[ii] = blend; |
| 444 | 546 | } |
| 445 | 547 | } |
| 446 | 548 | } |
| r7496 | r7497 | |
| 470 | 572 | return res; |
| 471 | 573 | } |
| 472 | 574 | |
| 473 | | INLINE void snes_update_line( UINT8 screen, UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors ) |
| 575 | INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors ) |
| 474 | 576 | { |
| 475 | 577 | UINT32 tmap, tile, xoff, yoff; |
| 476 | 578 | UINT16 ii = 0, vflip, hflip, pal; |
| r7496 | r7497 | |
| 492 | 594 | return; |
| 493 | 595 | #endif /* SNES_LAYER_DEBUG */ |
| 494 | 596 | |
| 597 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer]; |
| 598 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer]; |
| 599 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled; |
| 600 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled; |
| 601 | |
| 602 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 603 | return; |
| 604 | |
| 495 | 605 | /* Handle Mosaic effects */ |
| 496 | 606 | if (snes_ppu.layer[layer].mosaic_enabled) |
| 497 | 607 | curline -= (curline % (snes_ppu.mosaic_size + 1)); |
| r7496 | r7497 | |
| 599 | 709 | /* below, only color_planes depends on color_depth */ |
| 600 | 710 | if (hires) /* Hi-Res: 2bpp & 4bpp */ |
| 601 | 711 | { |
| 602 | | snes_draw_tile_x2(screen, color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii * 2, priority, hflip, pal, direct_colors, hires); |
| 712 | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii * 2, priority, hflip, pal, direct_colors, hires); |
| 603 | 713 | ii += 8; |
| 604 | 714 | } |
| 605 | 715 | else /* tile_size = 0 */ |
| 606 | 716 | { |
| 607 | 717 | if (tile_size) |
| 608 | 718 | { |
| 609 | | snes_draw_tile_x2(screen, color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 719 | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 610 | 720 | ii += 16; |
| 611 | 721 | } |
| 612 | 722 | else /* No Hi-Res: 2bpp, 4bpp & 8bpp */ |
| 613 | 723 | { |
| 614 | | snes_draw_tile(screen, color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 724 | snes_draw_tile(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 615 | 725 | ii += 8; |
| 616 | 726 | } |
| 617 | 727 | } |
| r7496 | r7497 | |
| 626 | 736 | *********************************************/ |
| 627 | 737 | #define MODE7_CLIP(x) (((x) & 0x2000) ? ((x) | ~0x03ff) : ((x) & 0x03ff)) |
| 628 | 738 | |
| 629 | | static void snes_update_line_mode7(UINT8 screen, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline ) |
| 739 | static void snes_update_line_mode7( UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline ) |
| 630 | 740 | { |
| 631 | 741 | UINT32 tiled; |
| 632 | 742 | INT16 ma, mb, mc, md; |
| 633 | 743 | INT32 xc, yc, tx, ty, sx, sy, hs, vs, xpos, xdir, x0, y0; |
| 634 | 744 | UINT8 priority = priority_a; |
| 635 | | UINT8 colour = 0, window_enabled = 0; |
| 745 | UINT8 colour = 0; |
| 636 | 746 | UINT16 *mosaic_x, *mosaic_y; |
| 637 | 747 | |
| 638 | 748 | #ifdef SNES_LAYER_DEBUG |
| r7496 | r7497 | |
| 640 | 750 | return; |
| 641 | 751 | #endif /* SNES_LAYER_DEBUG */ |
| 642 | 752 | |
| 753 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer]; |
| 754 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer]; |
| 755 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled; |
| 756 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled; |
| 757 | |
| 758 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 759 | return; |
| 760 | |
| 643 | 761 | ma = snes_ppu.mode7.matrix_a; |
| 644 | 762 | mb = snes_ppu.mode7.matrix_b; |
| 645 | 763 | mc = snes_ppu.mode7.matrix_c; |
| r7496 | r7497 | |
| 734 | 852 | colour &= 0x7f; |
| 735 | 853 | } |
| 736 | 854 | |
| 737 | | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 738 | | if (window_enabled) |
| 739 | | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 855 | if (scanlines[SNES_MAINSCREEN].enable) |
| 856 | { |
| 857 | if (scanlines[SNES_MAINSCREEN].clip) |
| 858 | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 740 | 859 | |
| 741 | | /* Draw pixel if appropriate */ |
| 742 | | if (scanlines[screen].priority[xpos] <= priority && colour > 0) |
| 860 | /* Draw pixel if appropriate */ |
| 861 | if (scanlines[SNES_MAINSCREEN].priority[xpos] <= priority && colour > 0) |
| 862 | { |
| 863 | UINT16 clr; |
| 864 | /* Direct select, but only outside EXTBG! */ |
| 865 | if (snes_ppu.direct_color && layer == 0) |
| 866 | { |
| 867 | /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */ |
| 868 | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 869 | } |
| 870 | else |
| 871 | clr = snes_cgram[colour]; |
| 872 | |
| 873 | scanlines[SNES_MAINSCREEN].buffer[xpos] = clr; |
| 874 | scanlines[SNES_MAINSCREEN].priority[xpos] = priority; |
| 875 | scanlines[SNES_MAINSCREEN].layer[xpos] = layer; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | if (scanlines[SNES_SUBSCREEN].enable) |
| 743 | 880 | { |
| 744 | | UINT16 clr; |
| 745 | | /* Direct select, but only outside EXTBG! */ |
| 746 | | if (snes_ppu.direct_color && layer == 0) |
| 881 | if (scanlines[SNES_SUBSCREEN].clip) |
| 882 | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 883 | |
| 884 | /* Draw pixel if appropriate */ |
| 885 | if (scanlines[SNES_SUBSCREEN].priority[xpos] <= priority && colour > 0) |
| 747 | 886 | { |
| 748 | | /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */ |
| 749 | | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 887 | UINT16 clr; |
| 888 | /* Direct select, but only outside EXTBG! */ |
| 889 | if (snes_ppu.direct_color && layer == 0) |
| 890 | { |
| 891 | /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */ |
| 892 | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 893 | } |
| 894 | else |
| 895 | clr = snes_cgram[colour]; |
| 896 | |
| 897 | scanlines[SNES_SUBSCREEN].buffer[xpos] = clr; |
| 898 | scanlines[SNES_SUBSCREEN].priority[xpos] = priority; |
| 899 | scanlines[SNES_SUBSCREEN].layer[xpos] = layer; |
| 750 | 900 | } |
| 751 | | else |
| 752 | | clr = snes_cgram[colour]; |
| 753 | | |
| 754 | | scanlines[screen].buffer[xpos] = clr; |
| 755 | | scanlines[screen].priority[xpos] = priority; |
| 756 | | scanlines[screen].layer[xpos] = layer; |
| 757 | 901 | } |
| 758 | 902 | } |
| 759 | 903 | } |
| r7496 | r7497 | |
| 764 | 908 | * Update an entire line of sprites. |
| 765 | 909 | * FIXME: We need to support high priority bit |
| 766 | 910 | *********************************************/ |
| 767 | | static void snes_update_objects( UINT8 screen, UINT8 priority_tbl, UINT16 curline ) |
| 911 | static void snes_update_objects( UINT8 priority_tbl, UINT16 curline ) |
| 768 | 912 | { |
| 769 | 913 | INT8 xs, ys; |
| 770 | | UINT8 line, widemode = 0; |
| 914 | UINT8 line; |
| 771 | 915 | UINT16 oam_extra, extra; |
| 772 | 916 | INT16 oam; |
| 773 | 917 | UINT8 range_over = 0, time_over = 0; |
| r7496 | r7497 | |
| 794 | 938 | return; |
| 795 | 939 | #endif /* SNES_LAYER_DEBUG */ |
| 796 | 940 | |
| 797 | | // if (snes_ppu.mode == 5 || snes_ppu.mode == 6) |
| 798 | | // widemode = 1; |
| 941 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[SNES_OAM]; |
| 942 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[SNES_OAM]; |
| 943 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[SNES_OAM].main_window_enabled; |
| 944 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 799 | 945 | |
| 946 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 947 | return; |
| 948 | |
| 800 | 949 | curline /= snes_ppu.interlace; |
| 801 | 950 | curline *= snes_ppu.obj_interlace; |
| 802 | 951 | |
| r7496 | r7497 | |
| 822 | 971 | extra <<= 1; |
| 823 | 972 | x |= ((extra & 0x80) << 1); |
| 824 | 973 | extra <<= 1; |
| 825 | | y*=snes_ppu.obj_interlace; |
| 974 | y *= snes_ppu.obj_interlace; |
| 826 | 975 | |
| 827 | 976 | /* Adjust if past maximum position */ |
| 828 | 977 | if (y >= snes_ppu.beam.last_visible_line*snes_ppu.interlace) |
| r7496 | r7497 | |
| 855 | 1004 | { |
| 856 | 1005 | if ((x + (count << 3) < SNES_SCR_WIDTH + 8)) |
| 857 | 1006 | { |
| 858 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, widemode); |
| 1007 | snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend); |
| 859 | 1008 | } |
| 860 | 1009 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 861 | 1010 | } |
| r7496 | r7497 | |
| 866 | 1015 | { |
| 867 | 1016 | if ((x + (xs << 3) < SNES_SCR_WIDTH + 8)) |
| 868 | 1017 | { |
| 869 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, widemode); |
| 1018 | snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend); |
| 870 | 1019 | } |
| 871 | 1020 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 872 | 1021 | } |
| r7496 | r7497 | |
| 897 | 1046 | * |
| 898 | 1047 | * Update Mode X line. |
| 899 | 1048 | *********************************************/ |
| 900 | | static void snes_update_mode_0( UINT8 screen, UINT16 curline ) |
| 1049 | static void snes_update_mode_0( UINT16 curline ) |
| 901 | 1050 | { |
| 902 | | UINT8 *bg_enabled; |
| 903 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 904 | | |
| 905 | 1051 | #ifdef SNES_LAYER_DEBUG |
| 906 | 1052 | if (debug_options.mode_disabled[0]) |
| 907 | 1053 | return; |
| 908 | 1054 | #endif /* SNES_LAYER_DEBUG */ |
| 909 | 1055 | |
| 910 | | if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0); |
| 911 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0); |
| 912 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0); |
| 913 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0); |
| 914 | | if (bg_enabled[4]) snes_update_objects(screen, 0, curline); |
| 1056 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0); |
| 1057 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0); |
| 1058 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0); |
| 1059 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0); |
| 1060 | snes_update_objects(0, curline); |
| 915 | 1061 | } |
| 916 | 1062 | |
| 917 | | static void snes_update_mode_1( UINT8 screen, UINT16 curline ) |
| 1063 | static void snes_update_mode_1( UINT16 curline ) |
| 918 | 1064 | { |
| 919 | | UINT8 *bg_enabled; |
| 920 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 921 | | |
| 922 | 1065 | #ifdef SNES_LAYER_DEBUG |
| 923 | 1066 | if (debug_options.mode_disabled[1]) |
| 924 | 1067 | return; |
| r7496 | r7497 | |
| 926 | 1069 | |
| 927 | 1070 | if (!snes_ppu.bg3_priority_bit) |
| 928 | 1071 | { |
| 929 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0); |
| 930 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0); |
| 931 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0); |
| 932 | | if (bg_enabled[4]) snes_update_objects(screen, 1, curline); |
| 1072 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0); |
| 1073 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0); |
| 1074 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0); |
| 1075 | snes_update_objects(1, curline); |
| 933 | 1076 | } |
| 934 | 1077 | else |
| 935 | 1078 | { |
| 936 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0); |
| 937 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0); |
| 938 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0); |
| 939 | | if (bg_enabled[4]) snes_update_objects(screen, 9, curline); |
| 1079 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0); |
| 1080 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0); |
| 1081 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0); |
| 1082 | snes_update_objects(9, curline); |
| 940 | 1083 | } |
| 941 | 1084 | } |
| 942 | 1085 | |
| 943 | | static void snes_update_mode_2( UINT8 screen, UINT16 curline ) |
| 1086 | static void snes_update_mode_2( UINT16 curline ) |
| 944 | 1087 | { |
| 945 | | UINT8 *bg_enabled; |
| 946 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 947 | | |
| 948 | 1088 | #ifdef SNES_LAYER_DEBUG |
| 949 | 1089 | if (debug_options.mode_disabled[2]) |
| 950 | 1090 | return; |
| 951 | 1091 | #endif /* SNES_LAYER_DEBUG */ |
| 952 | 1092 | |
| 953 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0); |
| 954 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0); |
| 955 | | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| 1093 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0); |
| 1094 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0); |
| 1095 | snes_update_objects(2, curline); |
| 956 | 1096 | } |
| 957 | 1097 | |
| 958 | | static void snes_update_mode_3( UINT8 screen, UINT16 curline ) |
| 1098 | static void snes_update_mode_3( UINT16 curline ) |
| 959 | 1099 | { |
| 960 | | UINT8 *bg_enabled; |
| 961 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 962 | | |
| 963 | 1100 | #ifdef SNES_LAYER_DEBUG |
| 964 | 1101 | if (debug_options.mode_disabled[3]) |
| 965 | 1102 | return; |
| 966 | 1103 | #endif /* SNES_LAYER_DEBUG */ |
| 967 | 1104 | |
| 968 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 969 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 970 | | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| 1105 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 1106 | snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 1107 | snes_update_objects(3, curline); |
| 971 | 1108 | } |
| 972 | 1109 | |
| 973 | | static void snes_update_mode_4( UINT8 screen, UINT16 curline ) |
| 1110 | static void snes_update_mode_4( UINT16 curline ) |
| 974 | 1111 | { |
| 975 | | UINT8 *bg_enabled; |
| 976 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 977 | | |
| 978 | 1112 | #ifdef SNES_LAYER_DEBUG |
| 979 | 1113 | if (debug_options.mode_disabled[4]) |
| 980 | 1114 | return; |
| 981 | 1115 | #endif /* SNES_LAYER_DEBUG */ |
| 982 | 1116 | |
| 983 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 984 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 985 | | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| 1117 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 1118 | snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 1119 | snes_update_objects(4, curline); |
| 986 | 1120 | } |
| 987 | 1121 | |
| 988 | | static void snes_update_mode_5( UINT8 screen, UINT16 curline ) |
| 1122 | static void snes_update_mode_5( UINT16 curline ) |
| 989 | 1123 | { |
| 990 | | UINT8 *bg_enabled; |
| 991 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 992 | | |
| 993 | 1124 | #ifdef SNES_LAYER_DEBUG |
| 994 | 1125 | if (debug_options.mode_disabled[5]) |
| 995 | 1126 | return; |
| 996 | 1127 | #endif /* SNES_LAYER_DEBUG */ |
| 997 | 1128 | |
| 998 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0); |
| 999 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0); |
| 1000 | | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| 1129 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0); |
| 1130 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0); |
| 1131 | snes_update_objects(5, curline); |
| 1001 | 1132 | } |
| 1002 | 1133 | |
| 1003 | | static void snes_update_mode_6( UINT8 screen, UINT16 curline ) |
| 1134 | static void snes_update_mode_6( UINT16 curline ) |
| 1004 | 1135 | { |
| 1005 | | UINT8 *bg_enabled; |
| 1006 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1007 | | |
| 1008 | 1136 | #ifdef SNES_LAYER_DEBUG |
| 1009 | 1137 | if (debug_options.mode_disabled[6]) |
| 1010 | 1138 | return; |
| 1011 | 1139 | #endif /* SNES_LAYER_DEBUG */ |
| 1012 | 1140 | |
| 1013 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0); |
| 1014 | | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 1141 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0); |
| 1142 | snes_update_objects(6, curline); |
| 1015 | 1143 | } |
| 1016 | 1144 | |
| 1017 | | static void snes_update_mode_7( UINT8 screen, UINT16 curline ) |
| 1145 | static void snes_update_mode_7( UINT16 curline ) |
| 1018 | 1146 | { |
| 1019 | | UINT8 *bg_enabled; |
| 1020 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1021 | | |
| 1022 | 1147 | #ifdef SNES_LAYER_DEBUG |
| 1023 | 1148 | if (debug_options.mode_disabled[7]) |
| 1024 | 1149 | return; |
| r7496 | r7497 | |
| 1026 | 1151 | |
| 1027 | 1152 | if (!snes_ppu.mode7.extbg) |
| 1028 | 1153 | { |
| 1029 | | if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline); |
| 1030 | | if (bg_enabled[4]) snes_update_objects(screen, 7, curline); |
| 1154 | snes_update_line_mode7(1, 1, SNES_BG1, curline); |
| 1155 | snes_update_objects(7, curline); |
| 1031 | 1156 | } |
| 1032 | 1157 | else |
| 1033 | 1158 | { |
| 1034 | | if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, SNES_BG2, curline); |
| 1035 | | if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline); |
| 1036 | | if (bg_enabled[4]) snes_update_objects(screen, 8, curline); |
| 1159 | snes_update_line_mode7(0, 4, SNES_BG2, curline); |
| 1160 | snes_update_line_mode7(2, 2, SNES_BG1, curline); |
| 1161 | snes_update_objects(8, curline); |
| 1037 | 1162 | } |
| 1038 | 1163 | } |
| 1039 | 1164 | |
| 1040 | 1165 | /********************************************* |
| 1041 | | * snes_draw_screen() |
| 1166 | * snes_draw_screens() |
| 1042 | 1167 | * |
| 1043 | 1168 | * Draw the whole screen (Mode 0 -> 7). |
| 1044 | 1169 | *********************************************/ |
| 1045 | 1170 | |
| 1046 | | static void snes_draw_screen( UINT8 screen, UINT16 curline ) |
| 1171 | static void snes_draw_screens( UINT16 curline ) |
| 1047 | 1172 | { |
| 1048 | 1173 | switch (snes_ppu.mode) |
| 1049 | 1174 | { |
| 1050 | | case 0: snes_update_mode_0(screen, curline); break; /* Mode 0 */ |
| 1051 | | case 1: snes_update_mode_1(screen, curline); break; /* Mode 1 */ |
| 1052 | | case 2: snes_update_mode_2(screen, curline); break; /* Mode 2 - Supports offset per tile */ |
| 1053 | | case 3: snes_update_mode_3(screen, curline); break; /* Mode 3 - Supports direct colour */ |
| 1054 | | case 4: snes_update_mode_4(screen, curline); break; /* Mode 4 - Supports offset per tile and direct colour */ |
| 1055 | | case 5: snes_update_mode_5(screen, curline); break; /* Mode 5 - Supports hires */ |
| 1056 | | case 6: snes_update_mode_6(screen, curline); break; /* Mode 6 - Supports offset per tile and hires */ |
| 1057 | | case 7: snes_update_mode_7(screen, curline); break; /* Mode 7 - Supports direct colour */ |
| 1175 | case 0: snes_update_mode_0(curline); break; /* Mode 0 */ |
| 1176 | case 1: snes_update_mode_1(curline); break; /* Mode 1 */ |
| 1177 | case 2: snes_update_mode_2(curline); break; /* Mode 2 - Supports offset per tile */ |
| 1178 | case 3: snes_update_mode_3(curline); break; /* Mode 3 - Supports direct colour */ |
| 1179 | case 4: snes_update_mode_4(curline); break; /* Mode 4 - Supports offset per tile and direct colour */ |
| 1180 | case 5: snes_update_mode_5(curline); break; /* Mode 5 - Supports hires */ |
| 1181 | case 6: snes_update_mode_6(curline); break; /* Mode 6 - Supports offset per tile and hires */ |
| 1182 | case 7: snes_update_mode_7(curline); break; /* Mode 7 - Supports direct colour */ |
| 1058 | 1183 | } |
| 1059 | 1184 | } |
| 1060 | 1185 | |
| r7496 | r7497 | |
| 1201 | 1326 | scanlines[SNES_MAINSCREEN].buffer[ii] = snes_cgram[0]; |
| 1202 | 1327 | } |
| 1203 | 1328 | |
| 1204 | | /* Draw SNES_SUBSCREEN */ |
| 1205 | | snes_draw_screen(SNES_SUBSCREEN, curline); |
| 1329 | /* Draw screens */ |
| 1330 | snes_draw_screens(curline); |
| 1206 | 1331 | |
| 1207 | | /* Draw SNES_MAINSCREEN */ |
| 1208 | | snes_draw_screen(SNES_MAINSCREEN, curline); |
| 1209 | | |
| 1210 | 1332 | #ifdef SNES_LAYER_DEBUG |
| 1211 | 1333 | if (snes_dbg_video(machine, bitmap, curline)) |
| 1212 | 1334 | { |
| r7496 | r7497 | |
| 1249 | 1371 | c = scanlines[SNES_SUBSCREEN].buffer[x]; |
| 1250 | 1372 | scanlines[SNES_SUBSCREEN].buffer[x] = temp_col; |
| 1251 | 1373 | |
| 1252 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1374 | if (!scanlines[SNES_SUBSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1253 | 1375 | snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1254 | 1376 | |
| 1255 | 1377 | r = ((c & 0x1f) * fade) >> 4; |