src/mame/video/snes.c
| r7635 | r7636 | |
| 297 | 297 | if (scanlines[SNES_MAINSCREEN].priority[ii] <= priority) |
| 298 | 298 | { |
| 299 | 299 | UINT8 clr = colour; |
| 300 | | UINT8 mask = snes_ppu.clipmasks[layer][ii]; |
| 300 | UINT8 clipmask = snes_ppu.clipmasks[layer][ii]; |
| 301 | 301 | UINT8 mosaic = snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled; |
| 302 | 302 | |
| 303 | 303 | #ifdef SNES_LAYER_DEBUG |
| 304 | 304 | if (debug_options.windows_disabled) |
| 305 | | mask = 0xff; |
| 305 | clipmask = 0xff; |
| 306 | 306 | if (debug_options.mosaic_disabled) |
| 307 | 307 | mosaic = 0; |
| 308 | 308 | #endif /* SNES_LAYER_DEBUG */ |
| 309 | 309 | |
| 310 | 310 | /* Clip to windows */ |
| 311 | 311 | if (scanlines[SNES_MAINSCREEN].clip) |
| 312 | | clr &= mask; |
| 312 | clr &= clipmask; |
| 313 | 313 | |
| 314 | 314 | /* Only draw if we have a colour (0 == transparent) */ |
| 315 | 315 | if (clr) |
| r7635 | r7636 | |
| 333 | 333 | scanlines[SNES_MAINSCREEN].buffer[ii + x_mos] = c; |
| 334 | 334 | scanlines[SNES_MAINSCREEN].priority[ii + x_mos] = priority; |
| 335 | 335 | scanlines[SNES_MAINSCREEN].layer[ii + x_mos] = layer; |
| 336 | scanlines[SNES_MAINSCREEN].blend_exception[ii + x_mos] = 0; |
| 336 | 337 | } |
| 337 | 338 | |
| 338 | 339 | ii += x_mos - 1; |
| r7635 | r7636 | |
| 342 | 343 | scanlines[SNES_MAINSCREEN].buffer[ii] = c; |
| 343 | 344 | scanlines[SNES_MAINSCREEN].priority[ii] = priority; |
| 344 | 345 | scanlines[SNES_MAINSCREEN].layer[ii] = layer; |
| 346 | scanlines[SNES_MAINSCREEN].blend_exception[ii] = 0; |
| 345 | 347 | } |
| 346 | 348 | } |
| 347 | 349 | } |
| r7635 | r7636 | |
| 352 | 354 | if (scanlines[SNES_SUBSCREEN].priority[ii] <= priority) |
| 353 | 355 | { |
| 354 | 356 | UINT8 clr = colour; |
| 355 | | UINT8 mask = snes_ppu.clipmasks[layer][ii]; |
| 357 | UINT8 clipmask = snes_ppu.clipmasks[layer][ii]; |
| 356 | 358 | UINT8 mosaic = snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled; |
| 357 | 359 | |
| 358 | 360 | #ifdef SNES_LAYER_DEBUG |
| 359 | 361 | if (debug_options.windows_disabled) |
| 360 | | mask = 0xff; |
| 362 | clipmask = 0xff; |
| 361 | 363 | if (debug_options.mosaic_disabled) |
| 362 | 364 | mosaic = 0; |
| 363 | 365 | #endif /* SNES_LAYER_DEBUG */ |
| 364 | 366 | |
| 365 | 367 | /* Clip to windows */ |
| 366 | 368 | if (scanlines[SNES_SUBSCREEN].clip) |
| 367 | | clr &= mask; |
| 369 | clr &= clipmask; |
| 368 | 370 | |
| 369 | 371 | /* Only draw if we have a colour (0 == transparent) */ |
| 370 | 372 | if (clr) |
| r7635 | r7636 | |
| 388 | 390 | scanlines[SNES_SUBSCREEN].buffer[ii + x_mos] = c; |
| 389 | 391 | scanlines[SNES_SUBSCREEN].priority[ii + x_mos] = priority; |
| 390 | 392 | scanlines[SNES_SUBSCREEN].layer[ii + x_mos] = layer; |
| 393 | scanlines[SNES_SUBSCREEN].blend_exception[ii + x_mos] = 0; |
| 391 | 394 | } |
| 392 | 395 | |
| 393 | 396 | ii += x_mos - 1; |
| r7635 | r7636 | |
| 397 | 400 | scanlines[SNES_SUBSCREEN].buffer[ii] = c; |
| 398 | 401 | scanlines[SNES_SUBSCREEN].priority[ii] = priority; |
| 399 | 402 | scanlines[SNES_SUBSCREEN].layer[ii] = layer; |
| 403 | scanlines[SNES_SUBSCREEN].blend_exception[ii] = 0; |
| 400 | 404 | } |
| 401 | 405 | } |
| 402 | 406 | } |
| r7635 | r7636 | |
| 409 | 413 | if (scanlines[SNES_MAINSCREEN].priority[ii >> 1] <= priority) |
| 410 | 414 | { |
| 411 | 415 | UINT8 clr = colour; |
| 412 | | UINT8 mask = snes_ppu.clipmasks[layer][ii]; |
| 416 | UINT8 clipmask = snes_ppu.clipmasks[layer][ii]; |
| 413 | 417 | UINT8 mosaic = snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled; |
| 414 | 418 | |
| 415 | 419 | #ifdef SNES_LAYER_DEBUG |
| 416 | 420 | if (debug_options.windows_disabled) |
| 417 | | mask = 0xff; |
| 421 | clipmask = 0xff; |
| 418 | 422 | if (debug_options.mosaic_disabled) |
| 419 | 423 | mosaic = 0; |
| 420 | 424 | #endif /* SNES_LAYER_DEBUG */ |
| 421 | 425 | |
| 422 | 426 | /* Clip to windows */ |
| 423 | 427 | if (scanlines[SNES_MAINSCREEN].clip) |
| 424 | | clr &= mask; |
| 428 | clr &= clipmask; |
| 425 | 429 | |
| 426 | 430 | /* Only draw if we have a colour (0 == transparent) */ |
| 427 | 431 | if (clr) |
| r7635 | r7636 | |
| 445 | 449 | scanlines[SNES_MAINSCREEN].buffer[(ii + x_mos) >> 1] = c; |
| 446 | 450 | scanlines[SNES_MAINSCREEN].priority[(ii + x_mos) >> 1] = priority; |
| 447 | 451 | scanlines[SNES_MAINSCREEN].layer[(ii + x_mos) >> 1] = layer; |
| 452 | scanlines[SNES_MAINSCREEN].blend_exception[(ii + x_mos) >> 1] = 0; |
| 448 | 453 | } |
| 449 | 454 | ii += x_mos - 1; |
| 450 | 455 | } |
| r7635 | r7636 | |
| 453 | 458 | scanlines[SNES_MAINSCREEN].buffer[ii >> 1] = c; |
| 454 | 459 | scanlines[SNES_MAINSCREEN].priority[ii >> 1] = priority; |
| 455 | 460 | scanlines[SNES_MAINSCREEN].layer[ii >> 1] = layer; |
| 461 | scanlines[SNES_MAINSCREEN].blend_exception[ii >> 1] = 0; |
| 456 | 462 | } |
| 457 | 463 | } |
| 458 | 464 | } |
| r7635 | r7636 | |
| 463 | 469 | if (scanlines[SNES_SUBSCREEN].priority[ii >> 1] <= priority) |
| 464 | 470 | { |
| 465 | 471 | UINT8 clr = colour; |
| 466 | | UINT8 mask = snes_ppu.clipmasks[layer][ii]; |
| 472 | UINT8 clipmask = snes_ppu.clipmasks[layer][ii]; |
| 467 | 473 | UINT8 mosaic = snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled; |
| 468 | 474 | |
| 469 | 475 | #ifdef SNES_LAYER_DEBUG |
| 470 | 476 | if (debug_options.windows_disabled) |
| 471 | | mask = 0xff; |
| 477 | clipmask = 0xff; |
| 472 | 478 | if (debug_options.mosaic_disabled) |
| 473 | 479 | mosaic = 0; |
| 474 | 480 | #endif /* SNES_LAYER_DEBUG */ |
| 475 | 481 | |
| 476 | 482 | /* Clip to windows */ |
| 477 | 483 | if (scanlines[SNES_SUBSCREEN].clip) |
| 478 | | clr &= mask; |
| 484 | clr &= clipmask; |
| 479 | 485 | |
| 480 | 486 | /* Only draw if we have a colour (0 == transparent) */ |
| 481 | 487 | if (clr) |
| r7635 | r7636 | |
| 499 | 505 | scanlines[SNES_SUBSCREEN].buffer[(ii + x_mos) >> 1] = c; |
| 500 | 506 | scanlines[SNES_SUBSCREEN].priority[(ii + x_mos) >> 1] = priority; |
| 501 | 507 | scanlines[SNES_SUBSCREEN].layer[(ii + x_mos) >> 1] = layer; |
| 508 | scanlines[SNES_SUBSCREEN].blend_exception[(ii + x_mos) >> 1] = 0; |
| 502 | 509 | } |
| 503 | 510 | ii += x_mos - 1; |
| 504 | 511 | } |
| r7635 | r7636 | |
| 507 | 514 | scanlines[SNES_SUBSCREEN].buffer[ii >> 1] = c; |
| 508 | 515 | scanlines[SNES_SUBSCREEN].priority[ii >> 1] = priority; |
| 509 | 516 | scanlines[SNES_SUBSCREEN].layer[ii >> 1] = layer; |
| 517 | scanlines[SNES_SUBSCREEN].blend_exception[ii >> 1] = 0; |
| 510 | 518 | } |
| 511 | 519 | } |
| 512 | 520 | } |
| r7635 | r7636 | |
| 582 | 590 | |
| 583 | 591 | if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[SNES_MAINSCREEN].enable) |
| 584 | 592 | { |
| 585 | | if (scanlines[SNES_MAINSCREEN].priority[pos] <= priority) |
| 586 | 593 | { |
| 587 | 594 | UINT8 clr = colour; |
| 588 | | UINT8 mask = snes_ppu.clipmasks[SNES_OAM][pos]; |
| 595 | UINT8 clipmask = snes_ppu.clipmasks[SNES_OAM][pos]; |
| 589 | 596 | |
| 590 | 597 | #ifdef SNES_LAYER_DEBUG |
| 591 | 598 | if (debug_options.windows_disabled) |
| 592 | | mask = 0xff; |
| 599 | clipmask = 0xff; |
| 593 | 600 | #endif /* SNES_LAYER_DEBUG */ |
| 594 | 601 | |
| 595 | 602 | /* Clip to windows */ |
| 596 | 603 | if (scanlines[SNES_MAINSCREEN].clip) |
| 597 | | clr &= mask; |
| 604 | clr &= clipmask; |
| 598 | 605 | |
| 599 | 606 | /* Only draw if we have a colour (0 == transparent) */ |
| 600 | 607 | if (clr) |
| r7635 | r7636 | |
| 612 | 619 | |
| 613 | 620 | if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[SNES_SUBSCREEN].enable) |
| 614 | 621 | { |
| 615 | | if (scanlines[SNES_SUBSCREEN].priority[pos] <= priority) |
| 616 | 622 | { |
| 617 | 623 | UINT8 clr = colour; |
| 618 | | UINT8 mask = snes_ppu.clipmasks[SNES_OAM][pos]; |
| 624 | UINT8 clipmask = snes_ppu.clipmasks[SNES_OAM][pos]; |
| 619 | 625 | |
| 620 | 626 | #ifdef SNES_LAYER_DEBUG |
| 621 | 627 | if (debug_options.windows_disabled) |
| 622 | | mask = 0xff; |
| 628 | clipmask = 0xff; |
| 623 | 629 | #endif /* SNES_LAYER_DEBUG */ |
| 624 | 630 | |
| 625 | 631 | /* Clip to windows */ |
| 626 | 632 | if (scanlines[SNES_SUBSCREEN].clip) |
| 627 | | clr &= mask; |
| 633 | clr &= clipmask; |
| 628 | 634 | |
| 629 | 635 | /* Only draw if we have a colour (0 == transparent) */ |
| 630 | 636 | if (clr) |
| r7635 | r7636 | |
| 707 | 713 | if (snes_ppu.layer[layer].mosaic_enabled) |
| 708 | 714 | curline -= (curline % (snes_ppu.mosaic_size + 1)); |
| 709 | 715 | |
| 710 | | if ((snes_ppu.interlace == 2) && !hires) |
| 716 | if ((snes_ppu.interlace == 2) && !hires && !snes_ppu.pseudo_hires) |
| 711 | 717 | curline /= 2; |
| 712 | 718 | |
| 713 | 719 | /* Find the size of the tiles (8x8 or 16x16) */ |
| r7635 | r7636 | |
| 1002 | 1008 | if (scanlines[SNES_MAINSCREEN].enable) |
| 1003 | 1009 | { |
| 1004 | 1010 | UINT8 clr = colour; |
| 1005 | | UINT8 mask = snes_ppu.clipmasks[layer][xpos]; |
| 1011 | UINT8 clipmask = snes_ppu.clipmasks[layer][xpos]; |
| 1006 | 1012 | |
| 1007 | 1013 | #ifdef SNES_LAYER_DEBUG |
| 1008 | 1014 | if (debug_options.windows_disabled) |
| 1009 | | mask = 0xff; |
| 1015 | clipmask = 0xff; |
| 1010 | 1016 | #endif /* SNES_LAYER_DEBUG */ |
| 1011 | 1017 | |
| 1012 | 1018 | /* Clip to windows */ |
| 1013 | 1019 | if (scanlines[SNES_MAINSCREEN].clip) |
| 1014 | | clr &= mask; |
| 1020 | clr &= clipmask; |
| 1015 | 1021 | |
| 1016 | 1022 | /* Draw pixel if appropriate */ |
| 1017 | 1023 | if (scanlines[SNES_MAINSCREEN].priority[xpos] <= priority && clr > 0) |
| r7635 | r7636 | |
| 1034 | 1040 | if (scanlines[SNES_SUBSCREEN].enable) |
| 1035 | 1041 | { |
| 1036 | 1042 | UINT8 clr = colour; |
| 1037 | | UINT8 mask = snes_ppu.clipmasks[layer][xpos]; |
| 1043 | UINT8 clipmask = snes_ppu.clipmasks[layer][xpos]; |
| 1038 | 1044 | |
| 1039 | 1045 | #ifdef SNES_LAYER_DEBUG |
| 1040 | 1046 | if (debug_options.windows_disabled) |
| 1041 | | mask = 0xff; |
| 1047 | clipmask = 0xff; |
| 1042 | 1048 | #endif /* SNES_LAYER_DEBUG */ |
| 1043 | 1049 | |
| 1044 | 1050 | /* Clip to windows */ |
| 1045 | 1051 | if (scanlines[SNES_SUBSCREEN].clip) |
| 1046 | | clr &= mask; |
| 1052 | clr &= clipmask; |
| 1047 | 1053 | |
| 1048 | 1054 | /* Draw pixel if appropriate */ |
| 1049 | 1055 | if (scanlines[SNES_SUBSCREEN].priority[xpos] <= priority && clr > 0) |
| r7635 | r7636 | |
| 1375 | 1381 | return; |
| 1376 | 1382 | #endif /* SNES_LAYER_DEBUG */ |
| 1377 | 1383 | |
| 1384 | snes_update_objects(3, 6, 9, 12); |
| 1385 | snes_update_line(curline, SNES_BG1, 8, 11, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1386 | snes_update_line(curline, SNES_BG2, 7, 10, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1387 | snes_update_line(curline, SNES_BG3, 2, 5, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1378 | 1388 | snes_update_line(curline, SNES_BG4, 1, 4, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1379 | | snes_update_line(curline, SNES_BG3, 2, 5, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1380 | | snes_update_line(curline, SNES_BG2, 7, 10, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1381 | | snes_update_line(curline, SNES_BG1, 8, 11, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1382 | | snes_update_objects(3, 6, 9, 12); |
| 1383 | 1389 | } |
| 1384 | 1390 | |
| 1385 | 1391 | static void snes_update_mode_1( UINT16 curline ) |
| r7635 | r7636 | |
| 1391 | 1397 | |
| 1392 | 1398 | if (!snes_ppu.bg3_priority_bit) |
| 1393 | 1399 | { |
| 1400 | snes_update_objects(2, 4, 7, 10); |
| 1401 | snes_update_line(curline, SNES_BG1, 6, 9, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1402 | snes_update_line(curline, SNES_BG2, 5, 8, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1394 | 1403 | snes_update_line(curline, SNES_BG3, 1, 3, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1395 | | snes_update_line(curline, SNES_BG2, 5, 8, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1396 | | snes_update_line(curline, SNES_BG1, 6, 9, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1397 | | snes_update_objects(2, 4, 7, 10); |
| 1398 | 1404 | } |
| 1399 | 1405 | else |
| 1400 | 1406 | { |
| 1407 | snes_update_objects(2, 3, 6, 9); |
| 1408 | snes_update_line(curline, SNES_BG1, 5, 8, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1409 | snes_update_line(curline, SNES_BG2, 4, 7, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1401 | 1410 | snes_update_line(curline, SNES_BG3, 1, 10, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0); |
| 1402 | | snes_update_line(curline, SNES_BG2, 4, 7, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1403 | | snes_update_line(curline, SNES_BG1, 5, 8, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1404 | | snes_update_objects(2, 3, 6, 9); |
| 1405 | 1411 | } |
| 1406 | 1412 | } |
| 1407 | 1413 | |
| r7635 | r7636 | |
| 1412 | 1418 | return; |
| 1413 | 1419 | #endif /* SNES_LAYER_DEBUG */ |
| 1414 | 1420 | |
| 1421 | snes_update_objects(2, 4, 6, 8); |
| 1422 | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_MODE2, 0); |
| 1415 | 1423 | snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_MODE2, 0); |
| 1416 | | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_MODE2, 0); |
| 1417 | | snes_update_objects(2, 4, 6, 8); |
| 1418 | 1424 | } |
| 1419 | 1425 | |
| 1420 | 1426 | static void snes_update_mode_3( UINT16 curline ) |
| r7635 | r7636 | |
| 1424 | 1430 | return; |
| 1425 | 1431 | #endif /* SNES_LAYER_DEBUG */ |
| 1426 | 1432 | |
| 1433 | snes_update_objects(2, 4, 6, 8); |
| 1434 | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_8BPP, 0, SNES_OPT_NONE, snes_ppu.direct_color); |
| 1427 | 1435 | snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0); |
| 1428 | | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_8BPP, 0, SNES_OPT_NONE, snes_ppu.direct_color); |
| 1429 | | snes_update_objects(2, 4, 6, 8); |
| 1430 | 1436 | } |
| 1431 | 1437 | |
| 1432 | 1438 | static void snes_update_mode_4( UINT16 curline ) |
| r7635 | r7636 | |
| 1436 | 1442 | return; |
| 1437 | 1443 | #endif /* SNES_LAYER_DEBUG */ |
| 1438 | 1444 | |
| 1445 | snes_update_objects(2, 4, 6, 8); |
| 1446 | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_8BPP, 0, SNES_OPT_MODE4, snes_ppu.direct_color); |
| 1439 | 1447 | snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_MODE4, 0); |
| 1440 | | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_8BPP, 0, SNES_OPT_MODE4, snes_ppu.direct_color); |
| 1441 | | snes_update_objects(2, 4, 6, 8); |
| 1442 | 1448 | } |
| 1443 | 1449 | |
| 1444 | 1450 | static void snes_update_mode_5( UINT16 curline ) |
| r7635 | r7636 | |
| 1448 | 1454 | return; |
| 1449 | 1455 | #endif /* SNES_LAYER_DEBUG */ |
| 1450 | 1456 | |
| 1457 | snes_update_objects(2, 4, 6, 8); |
| 1458 | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_4BPP, 1, SNES_OPT_NONE, 0); |
| 1451 | 1459 | snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_2BPP, 1, SNES_OPT_NONE, 0); |
| 1452 | | snes_update_line(curline, SNES_BG1, 3, 7, SNES_COLOR_DEPTH_4BPP, 1, SNES_OPT_NONE, 0); |
| 1453 | | snes_update_objects(2, 4, 6, 8); |
| 1454 | 1460 | } |
| 1455 | 1461 | |
| 1456 | 1462 | static void snes_update_mode_6( UINT16 curline ) |
| r7635 | r7636 | |
| 1460 | 1466 | return; |
| 1461 | 1467 | #endif /* SNES_LAYER_DEBUG */ |
| 1462 | 1468 | |
| 1469 | snes_update_objects(1, 3, 4, 6); |
| 1463 | 1470 | snes_update_line(curline, SNES_BG1, 2, 5, SNES_COLOR_DEPTH_4BPP, 1, SNES_OPT_MODE6, 0); |
| 1464 | | snes_update_objects(1, 3, 4, 6); |
| 1465 | 1471 | } |
| 1466 | 1472 | |
| 1467 | 1473 | static void snes_update_mode_7( UINT16 curline ) |
| r7635 | r7636 | |
| 1473 | 1479 | |
| 1474 | 1480 | if (!snes_ppu.mode7.extbg) |
| 1475 | 1481 | { |
| 1482 | snes_update_objects(1, 3, 4, 5); |
| 1476 | 1483 | snes_update_line_mode7(curline, SNES_BG1, 2, 2); |
| 1477 | | snes_update_objects(1, 3, 4, 5); |
| 1478 | 1484 | } |
| 1479 | 1485 | else |
| 1480 | 1486 | { |
| 1487 | snes_update_objects(2, 4, 6, 7); |
| 1488 | snes_update_line_mode7(curline, SNES_BG1, 3, 3); |
| 1481 | 1489 | snes_update_line_mode7(curline, SNES_BG2, 1, 5); |
| 1482 | | snes_update_line_mode7(curline, SNES_BG1, 3, 3); |
| 1483 | | snes_update_objects(2, 4, 6, 7); |
| 1484 | 1490 | } |
| 1485 | 1491 | } |
| 1486 | 1492 | |
| r7635 | r7636 | |
| 1612 | 1618 | int fade; |
| 1613 | 1619 | struct SCANLINE *scanline1, *scanline2; |
| 1614 | 1620 | UINT16 c; |
| 1621 | UINT16 prev_colour = 0; |
| 1622 | int average = input_port_read_safe(machine, "OPTIONS", 0) & 0x01; |
| 1615 | 1623 | |
| 1616 | 1624 | profiler_mark_start(PROFILER_VIDEO); |
| 1617 | 1625 | |
| r7635 | r7636 | |
| 1642 | 1650 | /* Draw back colour */ |
| 1643 | 1651 | for (ii = 0; ii < SNES_SCR_WIDTH; ii++) |
| 1644 | 1652 | { |
| 1645 | | if (snes_ppu.mode == 5 || snes_ppu.mode == 6) |
| 1653 | if (snes_ppu.mode == 5 || snes_ppu.mode == 6 || snes_ppu.pseudo_hires) |
| 1646 | 1654 | scanlines[SNES_SUBSCREEN].buffer[ii] = snes_cgram[0]; |
| 1647 | 1655 | else |
| 1648 | 1656 | scanlines[SNES_SUBSCREEN].buffer[ii] = snes_cgram[FIXED_COLOUR]; |
| r7635 | r7636 | |
| 1685 | 1693 | for (x = 0; x < SNES_SCR_WIDTH; x++) |
| 1686 | 1694 | { |
| 1687 | 1695 | int r, g, b, hires; |
| 1688 | | hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1; |
| 1689 | | c = scanline1->buffer[x]; |
| 1696 | UINT16 tmp_col[2]; |
| 1697 | hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6 && !snes_ppu.pseudo_hires) ? 0 : 1; |
| 1690 | 1698 | |
| 1691 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1692 | | if (!scanline1->blend_exception[x] && snes_ppu.layer[scanline1->layer[x]].color_math) |
| 1693 | | snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 0); |
| 1699 | /* in hires, the first pixel (of 512) is subscreen pixel, then the first mainscreen pixel follows, and so on... */ |
| 1700 | if (!hires) |
| 1701 | { |
| 1702 | c = scanline1->buffer[x]; |
| 1694 | 1703 | |
| 1695 | | r = ((c & 0x1f) * fade) >> 4; |
| 1696 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1697 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1704 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1705 | if (!scanline1->blend_exception[x] && snes_ppu.layer[scanline1->layer[x]].color_math) |
| 1706 | snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 0); |
| 1698 | 1707 | |
| 1699 | | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1708 | r = ((c & 0x1f) * fade) >> 4; |
| 1709 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1710 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1700 | 1711 | |
| 1701 | | /* in hires, the first pixel (of 512) is subscreen pixel, then the first mainscreen pixel follows, and so on... */ |
| 1702 | | if (!hires) |
| 1703 | 1712 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1713 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1714 | } |
| 1704 | 1715 | else |
| 1705 | 1716 | { |
| 1717 | /* prepare the pixel from main screen */ |
| 1718 | c = scanline1->buffer[x]; |
| 1719 | |
| 1720 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1721 | if (!scanline1->blend_exception[x] && snes_ppu.layer[scanline1->layer[x]].color_math) |
| 1722 | snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 0); |
| 1723 | |
| 1724 | tmp_col[1] = c; |
| 1725 | |
| 1726 | /* prepare the pixel from sub screen */ |
| 1706 | 1727 | c = scanline2->buffer[x]; |
| 1707 | 1728 | |
| 1708 | 1729 | /* in hires, subscreen pixels are blended as well: for each subscreen pixel, color math is applied if |
| 1709 | 1730 | it had been applied to the previous mainscreen pixel. What happens at subscreen pixel 0 (which has no |
| 1710 | 1731 | previous mainscreen pixel) is undocumented. Until more info are discovered, we (arbitrarily) apply to it |
| 1711 | 1732 | the same color math as the *next* mainscreen pixel (i.e. mainscreen pixel 0) */ |
| 1712 | | |
| 1713 | 1733 | if (x == 0 && !scanline1->blend_exception[0] && snes_ppu.layer[scanline1->layer[0]].color_math) |
| 1714 | 1734 | snes_draw_blend(0, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1); |
| 1715 | 1735 | else if (x > 0 && !scanline1->blend_exception[x - 1] && snes_ppu.layer[scanline1->layer[x - 1]].color_math) |
| 1716 | 1736 | snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1); |
| 1717 | 1737 | |
| 1738 | tmp_col[0] = c; |
| 1718 | 1739 | |
| 1740 | /* average the first pixel if required, or draw it directly*/ |
| 1741 | if (average) |
| 1742 | c = (prev_colour + tmp_col[0] - ((prev_colour ^ tmp_col[0]) & 0x0421)) >> 1; |
| 1743 | else |
| 1744 | c = tmp_col[0]; |
| 1745 | |
| 1719 | 1746 | r = ((c & 0x1f) * fade) >> 4; |
| 1720 | 1747 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1721 | 1748 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1722 | 1749 | |
| 1723 | 1750 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1751 | prev_colour = tmp_col[0]; |
| 1752 | |
| 1753 | |
| 1754 | /* average the second pixel if required, or draw it directly*/ |
| 1755 | if (average) |
| 1756 | c = (prev_colour + tmp_col[1] - ((prev_colour ^ tmp_col[1]) & 0x0421)) >> 1; |
| 1757 | else |
| 1758 | c = tmp_col[1]; |
| 1759 | |
| 1760 | r = ((c & 0x1f) * fade) >> 4; |
| 1761 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1762 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1763 | |
| 1764 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1765 | prev_colour = tmp_col[1]; |
| 1724 | 1766 | } |
| 1725 | 1767 | } |
| 1726 | 1768 | } |