src/mame/video/snes.c
| r7521 | r7522 | |
| 249 | 249 | * Draw tiles with variable bit planes |
| 250 | 250 | *****************************************/ |
| 251 | 251 | |
| 252 | | INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 252 | INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires ) |
| 253 | 253 | { |
| 254 | 254 | UINT8 mask, plane[8]; |
| 255 | 255 | UINT16 c; |
| r7521 | r7522 | |
| 310 | 310 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 311 | 311 | } |
| 312 | 312 | else |
| 313 | | c = snes_cgram[pal + clr]; |
| 313 | c = snes_cgram[(pal + clr) % FIXED_COLOUR]; |
| 314 | 314 | |
| 315 | 315 | if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic |
| 316 | 316 | { |
| r7521 | r7522 | |
| 359 | 359 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 360 | 360 | } |
| 361 | 361 | else |
| 362 | | c = snes_cgram[pal + clr]; |
| 362 | c = snes_cgram[(pal + clr) % FIXED_COLOUR]; |
| 363 | 363 | |
| 364 | 364 | if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic |
| 365 | 365 | { |
| r7521 | r7522 | |
| 410 | 410 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 411 | 411 | } |
| 412 | 412 | else |
| 413 | | c = snes_cgram[pal + clr]; |
| 413 | c = snes_cgram[(pal + clr) % FIXED_COLOUR]; |
| 414 | 414 | |
| 415 | 415 | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 416 | 416 | { |
| r7521 | r7522 | |
| 458 | 458 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 459 | 459 | } |
| 460 | 460 | else |
| 461 | | c = snes_cgram[pal + clr]; |
| 461 | c = snes_cgram[(pal + clr) % FIXED_COLOUR]; |
| 462 | 462 | |
| 463 | 463 | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 464 | 464 | { |
| r7521 | r7522 | |
| 492 | 492 | * Draw 2 tiles with variable bit planes |
| 493 | 493 | *****************************************/ |
| 494 | 494 | |
| 495 | | 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 ) |
| 495 | INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires ) |
| 496 | 496 | { |
| 497 | 497 | if (flip) |
| 498 | 498 | { |
| 499 | | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors, hires); |
| 500 | | snes_draw_tile(planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors, hires); |
| 499 | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x, priority, flip, direct_colors, pal, hires); |
| 500 | snes_draw_tile(planes, layer, tileaddr, x + 8, priority, flip, direct_colors, pal, hires); |
| 501 | 501 | } |
| 502 | 502 | else |
| 503 | 503 | { |
| 504 | | snes_draw_tile(planes, layer, tileaddr, x, priority, flip, pal, direct_colors, hires); |
| 505 | | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors, hires); |
| 504 | snes_draw_tile(planes, layer, tileaddr, x, priority, flip, direct_colors, pal, hires); |
| 505 | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, direct_colors, pal, hires); |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| r7521 | r7522 | |
| 564 | 564 | { |
| 565 | 565 | if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 566 | 566 | { |
| 567 | | c = snes_cgram[pal + clr]; |
| 567 | c = snes_cgram[(pal + clr) % FIXED_COLOUR]; |
| 568 | 568 | |
| 569 | 569 | scanlines[SNES_MAINSCREEN].buffer[ii] = c; |
| 570 | 570 | scanlines[SNES_MAINSCREEN].priority[ii] = priority; |
| r7521 | r7522 | |
| 590 | 590 | { |
| 591 | 591 | if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 592 | 592 | { |
| 593 | | c = snes_cgram[pal + clr]; |
| 593 | c = snes_cgram[(pal + clr) % FIXED_COLOUR]; |
| 594 | 594 | |
| 595 | 595 | scanlines[SNES_SUBSCREEN].buffer[ii] = c; |
| 596 | 596 | scanlines[SNES_SUBSCREEN].priority[ii] = priority; |
| r7521 | r7522 | |
| 635 | 635 | { |
| 636 | 636 | UINT32 tmap, tile, xoff, yoff; |
| 637 | 637 | UINT32 charaddr; |
| 638 | | UINT16 ii = 0, vflip, hflip, pal; |
| 638 | UINT16 ii = 0, vflip, hflip, pal, pal_direct; |
| 639 | 639 | INT8 tile_line; |
| 640 | 640 | UINT8 priority; |
| 641 | UINT32 addr; |
| 642 | UINT16 tilemap; |
| 641 | 643 | /* scrolling */ |
| 642 | 644 | UINT16 opt_bit = (layer == SNES_BG1) ? 13 : (layer == SNES_BG2) ? 14 : 0; |
| 643 | 645 | UINT8 vshift, hshift, tile_size; |
| 644 | 646 | /* variables depending on color_depth */ |
| 645 | | UINT8 color_shift = 0; |
| 646 | | UINT8 color_planes = 2; |
| 647 | | UINT8 tile_divider = 1; |
| 648 | | UINT32 addr; |
| 649 | | UINT16 tilemap; |
| 647 | UINT8 tile_divider = (color_depth == SNES_COLOR_DEPTH_8BPP) ? 4 : 2; |
| 648 | UINT8 color_planes = 2 << color_depth; |
| 649 | /* below we cheat to simplify the code: 8BPP should have 0 pal offset, not 0x100 (but we take care of this by later using pal % FIXED_COLOUR) */ |
| 650 | UINT8 color_shift = 2 << color_depth; |
| 650 | 651 | |
| 651 | 652 | #ifdef SNES_LAYER_DEBUG |
| 652 | 653 | if (debug_options.bg_disabled[layer]) |
| r7521 | r7522 | |
| 685 | 686 | tmap = snes_ppu.layer[layer].tilemap << 9; |
| 686 | 687 | charaddr = snes_ppu.layer[layer].charmap << 13; |
| 687 | 688 | |
| 688 | | /* set a couple of variables depending on color_dept */ |
| 689 | | switch (color_depth) |
| 690 | | { |
| 691 | | case SNES_COLOR_DEPTH_2BPP: |
| 692 | | color_shift = 0; |
| 693 | | color_planes = 2; |
| 694 | | tile_divider = 2; |
| 695 | | break; |
| 696 | | case SNES_COLOR_DEPTH_4BPP: |
| 697 | | color_shift = 2; |
| 698 | | color_planes = 4; |
| 699 | | tile_divider = 2; |
| 700 | | break; |
| 701 | | case SNES_COLOR_DEPTH_8BPP: |
| 702 | | color_shift = 0; //n/a, pal offset is always zero |
| 703 | | color_planes = 8; |
| 704 | | tile_divider = 4; |
| 705 | | break; |
| 706 | | } |
| 707 | | |
| 708 | 689 | while (ii < 256) |
| 709 | 690 | { |
| 710 | 691 | // determine the horizontal position (Bishojo Janshi Suchi Pai & Desert Figther have tile_size & hires == 1) |
| r7521 | r7522 | |
| 763 | 744 | vflip = BIT(tilemap, 15); |
| 764 | 745 | hflip = BIT(tilemap, 14); |
| 765 | 746 | priority = BIT(tilemap, 13) ? priority_b : priority_a; |
| 766 | | pal = (color_depth == SNES_COLOR_DEPTH_8BPP && direct_colors == 0) ? 0 : ((tilemap & 0x1c00) >> 8) << color_shift; /* 8 palettes of (4 * color_shift) colours */ |
| 747 | pal_direct = ((tilemap & 0x1c00) >> 8); |
| 767 | 748 | tile = tilemap & 0x03ff; |
| 768 | 749 | |
| 750 | pal = ((pal_direct >> 2) << color_shift); |
| 751 | |
| 769 | 752 | /* Mode 0 palettes are layer specific */ |
| 770 | 753 | if (snes_ppu.mode == 0) |
| 771 | 754 | { |
| r7521 | r7522 | |
| 801 | 784 | /* below, only color_planes depends on color_depth */ |
| 802 | 785 | if (hires) /* Hi-Res: 2bpp & 4bpp */ |
| 803 | 786 | { |
| 804 | | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii * 2, priority, hflip, pal, direct_colors, hires); |
| 787 | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii * 2, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires); |
| 805 | 788 | ii += 8; |
| 806 | 789 | } |
| 807 | 790 | else /* tile_size = 0 */ |
| 808 | 791 | { |
| 809 | 792 | if (tile_size) |
| 810 | 793 | { |
| 811 | | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 794 | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires); |
| 812 | 795 | ii += 16; |
| 813 | 796 | } |
| 814 | 797 | else /* No Hi-Res: 2bpp, 4bpp & 8bpp */ |
| 815 | 798 | { |
| 816 | | snes_draw_tile(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 799 | snes_draw_tile(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires); |
| 817 | 800 | ii += 8; |
| 818 | 801 | } |
| 819 | 802 | } |