src/mame/video/snes.c
| r5281 | r5282 | |
| 162 | 162 | *****************************************/ |
| 163 | 163 | INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 clip ) |
| 164 | 164 | { |
| 165 | if( clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF |
| 166 | return; |
| 167 | |
| 165 | 168 | #ifdef SNES_DBG_video |
| 166 | 169 | if( !debug_options.transparency_disabled ) |
| 167 | 170 | #endif /* SNES_DBG_video */ |
| 168 | | if( (clip == SNES_CLIP_ALL || clip == SNES_CLIP_ALL2) || |
| 171 | if( (clip == SNES_CLIP_ALL) || |
| 169 | 172 | (clip == SNES_CLIP_IN && snes_ppu.clipmasks[5][offset]) || |
| 170 | 173 | (clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[5][offset]) ) |
| 171 | 174 | { |
| r5281 | r5282 | |
| 259 | 262 | |
| 260 | 263 | for( ii = x; ii < (x + 8); ii++ ) |
| 261 | 264 | { |
| 262 | | register UINT8 colour; |
| 265 | UINT8 colour; |
| 263 | 266 | if( flip ) |
| 264 | 267 | { |
| 265 | 268 | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0); |
| r5281 | r5282 | |
| 286 | 289 | c = snes_cgram[pal + colour]; |
| 287 | 290 | if( screen == MAINSCREEN ) /* Only blend main screens */ |
| 288 | 291 | snes_draw_blend(ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); |
| 289 | | scanlines[screen].buffer[ii] = c; |
| 290 | | scanlines[screen].zbuf[ii] = priority; |
| 292 | if( snes_ram[MOSAIC] & (1 << layer) ) // handle horizontal mosaic |
| 293 | { |
| 294 | int x_mos; |
| 295 | |
| 296 | //TODO: 512 modes has the h values doubled. |
| 297 | for(x_mos = 0;x_mos < (((snes_ram[MOSAIC] & 0xf0)>>4)+1) ; x_mos++) |
| 298 | { |
| 299 | scanlines[screen].buffer[ii + x_mos] = c; |
| 300 | scanlines[screen].zbuf[ii + x_mos] = priority; |
| 301 | } |
| 302 | ii += x_mos - 1; |
| 303 | } |
| 304 | else |
| 305 | { |
| 306 | scanlines[screen].buffer[ii] = c; |
| 307 | scanlines[screen].zbuf[ii] = priority; |
| 308 | } |
| 291 | 309 | } |
| 292 | 310 | } |
| 293 | 311 | } |
| r5281 | r5282 | |
| 335 | 353 | |
| 336 | 354 | for( ii = x; ii < (x + 8); ii++ ) |
| 337 | 355 | { |
| 338 | | register UINT8 colour; |
| 356 | UINT8 colour; |
| 339 | 357 | if( flip ) |
| 340 | 358 | { |
| 341 | 359 | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| r5281 | r5282 | |
| 364 | 382 | c = snes_cgram[pal + colour]; |
| 365 | 383 | if( screen == MAINSCREEN ) /* Only blend main screens */ |
| 366 | 384 | snes_draw_blend(ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); |
| 367 | | scanlines[screen].buffer[ii] = c; |
| 368 | | scanlines[screen].zbuf[ii] = priority; |
| 385 | if( snes_ram[MOSAIC] & (1 << layer) ) // handle horizontal mosaic |
| 386 | { |
| 387 | int x_mos; |
| 388 | |
| 389 | //TODO: 512 modes has the h values doubled. |
| 390 | for(x_mos = 0;x_mos < (((snes_ram[MOSAIC] & 0xf0)>>4)+1) ; x_mos++) |
| 391 | { |
| 392 | scanlines[screen].buffer[ii + x_mos] = c; |
| 393 | scanlines[screen].zbuf[ii + x_mos] = priority; |
| 394 | } |
| 395 | ii += x_mos - 1; |
| 396 | } |
| 397 | else |
| 398 | { |
| 399 | scanlines[screen].buffer[ii] = c; |
| 400 | scanlines[screen].zbuf[ii] = priority; |
| 401 | } |
| 369 | 402 | } |
| 370 | 403 | } |
| 371 | 404 | } |
| r5281 | r5282 | |
| 417 | 450 | |
| 418 | 451 | for( ii = x; ii < (x + 8); ii++ ) |
| 419 | 452 | { |
| 420 | | register UINT8 colour; |
| 453 | UINT8 colour; |
| 421 | 454 | if( flip ) |
| 422 | 455 | { |
| 423 | 456 | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| r5281 | r5282 | |
| 450 | 483 | c = snes_cgram[colour]; |
| 451 | 484 | if( screen == MAINSCREEN ) /* Only blend main screens */ |
| 452 | 485 | snes_draw_blend(ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); |
| 453 | | scanlines[screen].buffer[ii] = c; |
| 454 | | scanlines[screen].zbuf[ii] = priority; |
| 486 | if( snes_ram[MOSAIC] & (1 << layer) ) // handle horizontal mosaic |
| 487 | { |
| 488 | int x_mos; |
| 489 | |
| 490 | //TODO: 512 modes has the h values doubled. |
| 491 | for(x_mos = 0;x_mos < (((snes_ram[MOSAIC] & 0xf0)>>4)+1) ; x_mos++) |
| 492 | { |
| 493 | scanlines[screen].buffer[ii + x_mos] = c; |
| 494 | scanlines[screen].zbuf[ii + x_mos] = priority; |
| 495 | } |
| 496 | ii += x_mos - 1; |
| 497 | } |
| 498 | else |
| 499 | { |
| 500 | scanlines[screen].buffer[ii] = c; |
| 501 | scanlines[screen].zbuf[ii] = priority; |
| 502 | } |
| 455 | 503 | } |
| 456 | 504 | } |
| 457 | 505 | } |
| r5281 | r5282 | |
| 501 | 549 | |
| 502 | 550 | for( ii = x; ii < (x + 8); ii++ ) |
| 503 | 551 | { |
| 504 | | register UINT8 colour; |
| 552 | UINT8 colour; |
| 505 | 553 | if( flip ) |
| 506 | 554 | { |
| 507 | 555 | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| r5281 | r5282 | |
| 565 | 613 | x <<= 1; |
| 566 | 614 | for( ii = x; ii < (x + 16); ii += 2 ) |
| 567 | 615 | { |
| 568 | | register UINT8 colour; |
| 616 | UINT8 colour; |
| 569 | 617 | if( flip ) |
| 570 | 618 | { |
| 571 | 619 | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| r5281 | r5282 | |
| 657 | 705 | /* Jump to base map address */ |
| 658 | 706 | tmap = snes_ppu.layer[layer].map; |
| 659 | 707 | /* Offset vertically */ |
| 660 | | tmap += table_vscroll[snes_ppu.layer[layer].map_size][vtilescroll >> 5]; |
| 708 | tmap += table_vscroll[snes_ppu.layer[layer].map_size & 3][(vtilescroll >> 5) & 3]; |
| 661 | 709 | /* Scroll vertically */ |
| 662 | 710 | tmap += (vtilescroll & 0x1f) << 6; |
| 663 | 711 | /* Remember this position */ |
| r5281 | r5282 | |
| 682 | 730 | priority = table_bgd_pty[snes_ppu.mode > 1][layer][(snes_vram[tmap + ii + 1] & 0x20) >> 5]; |
| 683 | 731 | pal = (snes_vram[tmap + ii + 1] & 0x1c); /* 8 palettes of 4 colours */ |
| 684 | 732 | tile = (snes_vram[tmap + ii + 1] & 0x3) << 8; |
| 685 | | tile |= snes_vram[tmap + ii]; |
| 733 | tile |= (snes_vram[tmap + ii] & 0xff); |
| 686 | 734 | |
| 687 | 735 | /* Mode 0 palettes are layer specific */ |
| 688 | 736 | if( snes_ppu.mode == 0 ) |
| r5281 | r5282 | |
| 701 | 749 | } |
| 702 | 750 | else |
| 703 | 751 | { |
| 704 | | tile += 32; |
| 752 | tile += 16; |
| 705 | 753 | } |
| 706 | 754 | } |
| 707 | 755 | tile_line = -tile_line + 7; |
| r5281 | r5282 | |
| 710 | 758 | { |
| 711 | 759 | if( line > 7 ) |
| 712 | 760 | { |
| 713 | | tile += 32; |
| 761 | tile += 16; |
| 714 | 762 | tile_line -= 8; |
| 715 | 763 | } |
| 716 | 764 | } |
| r5281 | r5282 | |
| 829 | 877 | } |
| 830 | 878 | else |
| 831 | 879 | { |
| 832 | | tile += 32; |
| 880 | tile += 16; |
| 833 | 881 | } |
| 834 | 882 | } |
| 835 | 883 | tile_line = -tile_line + 7; |
| r5281 | r5282 | |
| 838 | 886 | { |
| 839 | 887 | if( line > 7 ) |
| 840 | 888 | { |
| 841 | | tile += 32; |
| 889 | tile += 16; |
| 842 | 890 | tile_line -= 8; |
| 843 | 891 | } |
| 844 | 892 | } |
| r5281 | r5282 | |
| 1228 | 1276 | INT16 ma, mb, mc, md; |
| 1229 | 1277 | INT16 xc, yc, tx, ty, sx, sy, hs, vs, xpos, xdir; |
| 1230 | 1278 | UINT8 priority = 0; |
| 1231 | | register UINT8 colour = 0; |
| 1279 | UINT8 colour = 0; |
| 1232 | 1280 | |
| 1233 | 1281 | #ifdef SNES_DBG_video |
| 1234 | 1282 | if( debug_options.bg_disabled[0] ) |