trunk/src/mame/video/snes.c
| r29190 | r29191 | |
| 81 | 81 | #define SNES_CLIP_ALWAYS 3 |
| 82 | 82 | |
| 83 | 83 | #if SNES_LAYER_DEBUG |
| 84 | | struct DEBUGOPTS |
| 85 | | { |
| 86 | | UINT8 bg_disabled[5]; |
| 87 | | UINT8 mode_disabled[8]; |
| 88 | | UINT8 draw_subscreen; |
| 89 | | UINT8 windows_disabled; |
| 90 | | UINT8 mosaic_disabled; |
| 91 | | UINT8 colormath_disabled; |
| 92 | | UINT8 sprite_reversed; |
| 93 | | UINT8 select_pri[5]; |
| 94 | | }; |
| 95 | | static struct DEBUGOPTS debug_options; |
| 96 | 84 | /* red green blue purple yellow cyan grey white */ |
| 97 | 85 | static const UINT16 dbg_mode_colours[8] = { 0x1f, 0x3e0, 0x7c00, 0x7c1f, 0x3ff, 0x7fe0, 0x4210, 0x7fff }; |
| 98 | 86 | #endif /* SNES_LAYER_DEBUG */ |
| r29190 | r29191 | |
| 197 | 185 | UINT8 clipmask = m_clipmasks[layer][ii]; |
| 198 | 186 | |
| 199 | 187 | #if SNES_LAYER_DEBUG |
| 200 | | if (debug_options.windows_disabled) |
| 188 | if (m_debug_options.windows_disabled) |
| 201 | 189 | clipmask = 0xff; |
| 202 | 190 | #endif /* SNES_LAYER_DEBUG */ |
| 203 | 191 | |
| r29190 | r29191 | |
| 232 | 220 | UINT8 clipmask = m_clipmasks[layer][ii >> 1]; |
| 233 | 221 | |
| 234 | 222 | #if SNES_LAYER_DEBUG |
| 235 | | if (debug_options.windows_disabled) |
| 223 | if (m_debug_options.windows_disabled) |
| 236 | 224 | clipmask = 0xff; |
| 237 | 225 | #endif /* SNES_LAYER_DEBUG */ |
| 238 | 226 | |
| r29190 | r29191 | |
| 266 | 254 | UINT8 clipmask = m_clipmasks[SNES_OAM][pos]; |
| 267 | 255 | |
| 268 | 256 | #if SNES_LAYER_DEBUG |
| 269 | | if (debug_options.windows_disabled) |
| 257 | if (m_debug_options.windows_disabled) |
| 270 | 258 | clipmask = 0xff; |
| 271 | 259 | #endif /* SNES_LAYER_DEBUG */ |
| 272 | 260 | |
| r29190 | r29191 | |
| 312 | 300 | UINT8 mosaic = m_layer[layer].mosaic_enabled; |
| 313 | 301 | |
| 314 | 302 | #if SNES_LAYER_DEBUG |
| 315 | | if (debug_options.mosaic_disabled) |
| 303 | if (m_debug_options.mosaic_disabled) |
| 316 | 304 | mosaic = 0; |
| 317 | 305 | #endif /* SNES_LAYER_DEBUG */ |
| 318 | 306 | |
| r29190 | r29191 | |
| 415 | 403 | UINT8 color_shift = 2 << color_depth; |
| 416 | 404 | |
| 417 | 405 | #if SNES_LAYER_DEBUG |
| 418 | | if (debug_options.bg_disabled[layer]) |
| 406 | if (m_debug_options.bg_disabled[layer]) |
| 419 | 407 | return; |
| 420 | 408 | #endif /* SNES_LAYER_DEBUG */ |
| 421 | 409 | |
| r29190 | r29191 | |
| 517 | 505 | |
| 518 | 506 | #if SNES_LAYER_DEBUG |
| 519 | 507 | /* if we want to draw only one of the priorities of this layer */ |
| 520 | | if (((debug_options.select_pri[layer] & 0x01) && (priority == priority_a)) || |
| 521 | | ((debug_options.select_pri[layer] & 0x02) && (priority == priority_b))) |
| 508 | if (((m_debug_options.select_pri[layer] & 0x01) && (priority == priority_a)) || |
| 509 | ((m_debug_options.select_pri[layer] & 0x02) && (priority == priority_b))) |
| 522 | 510 | { |
| 523 | 511 | if (!hires && tile_size) |
| 524 | 512 | ii += 16; |
| r29190 | r29191 | |
| 597 | 585 | int screen; |
| 598 | 586 | |
| 599 | 587 | #if SNES_LAYER_DEBUG |
| 600 | | if (debug_options.bg_disabled[layer]) |
| 588 | if (m_debug_options.bg_disabled[layer]) |
| 601 | 589 | return; |
| 602 | 590 | #endif /* SNES_LAYER_DEBUG */ |
| 603 | 591 | |
| r29190 | r29191 | |
| 659 | 647 | } |
| 660 | 648 | |
| 661 | 649 | #if SNES_LAYER_DEBUG |
| 662 | | if (debug_options.mosaic_disabled) |
| 650 | if (m_debug_options.mosaic_disabled) |
| 663 | 651 | { |
| 664 | 652 | mosaic_x = m_mosaic_table[0]; |
| 665 | 653 | mosaic_y = m_mosaic_table[0]; |
| r29190 | r29191 | |
| 712 | 700 | |
| 713 | 701 | #if SNES_LAYER_DEBUG |
| 714 | 702 | /* if we want to draw only one of the priorities of this layer */ |
| 715 | | if (((debug_options.select_pri[layer] & 0x01) && (priority == priority_a)) || |
| 716 | | ((debug_options.select_pri[layer] & 0x02) && (priority == priority_b))) |
| 703 | if (((m_debug_options.select_pri[layer] & 0x01) && (priority == priority_a)) || |
| 704 | ((m_debug_options.select_pri[layer] & 0x02) && (priority == priority_b))) |
| 717 | 705 | continue; |
| 718 | 706 | #endif /* SNES_LAYER_DEBUG */ |
| 719 | 707 | } |
| r29190 | r29191 | |
| 726 | 714 | UINT8 clipmask = m_clipmasks[layer][xpos]; |
| 727 | 715 | |
| 728 | 716 | #if SNES_LAYER_DEBUG |
| 729 | | if (debug_options.windows_disabled) |
| 717 | if (m_debug_options.windows_disabled) |
| 730 | 718 | clipmask = 0xff; |
| 731 | 719 | #endif /* SNES_LAYER_DEBUG */ |
| 732 | 720 | |
| r29190 | r29191 | |
| 784 | 772 | * test their priority with the one of the correct sprite - see update_objects. |
| 785 | 773 | *************************************************************************************************/ |
| 786 | 774 | |
| 787 | | struct OAM |
| 788 | | { |
| 789 | | UINT16 tile; |
| 790 | | INT16 x, y; |
| 791 | | UINT8 size, vflip, hflip, priority_bits, pal; |
| 792 | | int height, width; |
| 793 | | }; |
| 794 | 775 | |
| 795 | | static struct OAM oam_spritelist[SNES_SCR_WIDTH / 2]; |
| 796 | | |
| 797 | | static UINT8 oam_itemlist[32]; |
| 798 | | |
| 799 | | struct TILELIST { |
| 800 | | INT16 x; |
| 801 | | UINT16 priority, pal, tileaddr; |
| 802 | | int hflip; |
| 803 | | }; |
| 804 | | |
| 805 | | static struct TILELIST oam_tilelist[34]; |
| 806 | | |
| 807 | 776 | /********************************************* |
| 808 | 777 | * update_obsel() |
| 809 | 778 | * |
| r29190 | r29191 | |
| 843 | 812 | if (((ii + 1) % 4) == 0) |
| 844 | 813 | extra = oamram[oam_extra--]; |
| 845 | 814 | |
| 846 | | oam_spritelist[ii].vflip = (oamram[oam] & 0x80) >> 7; |
| 847 | | oam_spritelist[ii].hflip = (oamram[oam] & 0x40) >> 6; |
| 848 | | oam_spritelist[ii].priority_bits = (oamram[oam] & 0x30) >> 4; |
| 849 | | oam_spritelist[ii].pal = 128 + ((oamram[oam] & 0x0e) << 3); |
| 850 | | oam_spritelist[ii].tile = (oamram[oam--] & 0x1) << 8; |
| 851 | | oam_spritelist[ii].tile |= oamram[oam--]; |
| 852 | | oam_spritelist[ii].y = oamram[oam--] + 1; |
| 853 | | oam_spritelist[ii].x = oamram[oam--]; |
| 854 | | oam_spritelist[ii].size = (extra & 0x80) >> 7; |
| 815 | m_oam_spritelist[ii].vflip = (oamram[oam] & 0x80) >> 7; |
| 816 | m_oam_spritelist[ii].hflip = (oamram[oam] & 0x40) >> 6; |
| 817 | m_oam_spritelist[ii].priority_bits = (oamram[oam] & 0x30) >> 4; |
| 818 | m_oam_spritelist[ii].pal = 128 + ((oamram[oam] & 0x0e) << 3); |
| 819 | m_oam_spritelist[ii].tile = (oamram[oam--] & 0x1) << 8; |
| 820 | m_oam_spritelist[ii].tile |= oamram[oam--]; |
| 821 | m_oam_spritelist[ii].y = oamram[oam--] + 1; |
| 822 | m_oam_spritelist[ii].x = oamram[oam--]; |
| 823 | m_oam_spritelist[ii].size = (extra & 0x80) >> 7; |
| 855 | 824 | extra <<= 1; |
| 856 | | oam_spritelist[ii].x |= ((extra & 0x80) << 1); |
| 825 | m_oam_spritelist[ii].x |= ((extra & 0x80) << 1); |
| 857 | 826 | extra <<= 1; |
| 858 | 827 | |
| 859 | | oam_spritelist[ii].y *= m_obj_interlace; |
| 860 | | oam_spritelist[ii].y &= 0x1ff; |
| 828 | m_oam_spritelist[ii].y *= m_obj_interlace; |
| 829 | m_oam_spritelist[ii].y &= 0x1ff; |
| 861 | 830 | |
| 862 | | oam_spritelist[ii].x &= 0x1ff; |
| 831 | m_oam_spritelist[ii].x &= 0x1ff; |
| 863 | 832 | |
| 864 | 833 | /* Determine object size */ |
| 865 | 834 | switch (m_oam.size) |
| 866 | 835 | { |
| 867 | 836 | case 0: /* 8x8 or 16x16 */ |
| 868 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 2 : 1; |
| 869 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 2 : 1; |
| 837 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 2 : 1; |
| 838 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 2 : 1; |
| 870 | 839 | break; |
| 871 | 840 | case 1: /* 8x8 or 32x32 */ |
| 872 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 4 : 1; |
| 873 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 4 : 1; |
| 841 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 4 : 1; |
| 842 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 4 : 1; |
| 874 | 843 | break; |
| 875 | 844 | case 2: /* 8x8 or 64x64 */ |
| 876 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 8 : 1; |
| 877 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 8 : 1; |
| 845 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 8 : 1; |
| 846 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 8 : 1; |
| 878 | 847 | break; |
| 879 | 848 | case 3: /* 16x16 or 32x32 */ |
| 880 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 4 : 2; |
| 881 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 4 : 2; |
| 849 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 4 : 2; |
| 850 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 4 : 2; |
| 882 | 851 | break; |
| 883 | 852 | case 4: /* 16x16 or 64x64 */ |
| 884 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 8 : 2; |
| 885 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 8 : 2; |
| 853 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 8 : 2; |
| 854 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 8 : 2; |
| 886 | 855 | break; |
| 887 | 856 | case 5: /* 32x32 or 64x64 */ |
| 888 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 8 : 4; |
| 889 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 8 : 4; |
| 857 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 8 : 4; |
| 858 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 8 : 4; |
| 890 | 859 | break; |
| 891 | 860 | case 6: /* undocumented: 16x32 or 32x64 */ |
| 892 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 4 : 2; |
| 893 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 8 : 4; |
| 894 | | if (m_obj_interlace && !oam_spritelist[ii].size) |
| 895 | | oam_spritelist[ii].height = 2; |
| 861 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 4 : 2; |
| 862 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 8 : 4; |
| 863 | if (m_obj_interlace && !m_oam_spritelist[ii].size) |
| 864 | m_oam_spritelist[ii].height = 2; |
| 896 | 865 | break; |
| 897 | 866 | case 7: /* undocumented: 16x32 or 32x32 */ |
| 898 | | oam_spritelist[ii].width = oam_spritelist[ii].size ? 4 : 2; |
| 899 | | oam_spritelist[ii].height = oam_spritelist[ii].size ? 4 : 4; |
| 900 | | if (m_obj_interlace && !oam_spritelist[ii].size) |
| 901 | | oam_spritelist[ii].height = 2; |
| 867 | m_oam_spritelist[ii].width = m_oam_spritelist[ii].size ? 4 : 2; |
| 868 | m_oam_spritelist[ii].height = m_oam_spritelist[ii].size ? 4 : 4; |
| 869 | if (m_obj_interlace && !m_oam_spritelist[ii].size) |
| 870 | m_oam_spritelist[ii].height = 2; |
| 902 | 871 | break; |
| 903 | 872 | default: |
| 904 | 873 | /* we should never enter here... */ |
| r29190 | r29191 | |
| 919 | 888 | { |
| 920 | 889 | //if sprite is entirely offscreen and doesn't wrap around to the left side of the screen, |
| 921 | 890 | //then it is not counted. this *should* be 256, and not 255, even though dot 256 is offscreen. |
| 922 | | int spr_height = (oam_spritelist[sprite].height << 3); |
| 891 | int spr_height = (m_oam_spritelist[sprite].height << 3); |
| 923 | 892 | |
| 924 | | if (oam_spritelist[sprite].x > 256 && (oam_spritelist[sprite].x + (oam_spritelist[sprite].width << 3) - 1) < 512) |
| 893 | if (m_oam_spritelist[sprite].x > 256 && (m_oam_spritelist[sprite].x + (m_oam_spritelist[sprite].width << 3) - 1) < 512) |
| 925 | 894 | return 0; |
| 926 | 895 | |
| 927 | | if (curline >= oam_spritelist[sprite].y && curline < (oam_spritelist[sprite].y + spr_height)) |
| 896 | if (curline >= m_oam_spritelist[sprite].y && curline < (m_oam_spritelist[sprite].y + spr_height)) |
| 928 | 897 | return 1; |
| 929 | 898 | |
| 930 | | if ((oam_spritelist[sprite].y + spr_height) >= 256 && curline < ((oam_spritelist[sprite].y + spr_height) & 255)) |
| 899 | if ((m_oam_spritelist[sprite].y + spr_height) >= 256 && curline < ((m_oam_spritelist[sprite].y + spr_height) & 255)) |
| 931 | 900 | return 1; |
| 932 | 901 | |
| 933 | 902 | return 0; |
| r29190 | r29191 | |
| 962 | 931 | curline *= m_obj_interlace; |
| 963 | 932 | |
| 964 | 933 | /* reset the list of first 32 objects which intersect current scanline */ |
| 965 | | memset(oam_itemlist, 0xff, 32); |
| 934 | memset(m_oam_itemlist, 0xff, 32); |
| 966 | 935 | |
| 967 | 936 | /* populate the list of 32 objects */ |
| 968 | 937 | for (ii = 0; ii < 128; ii++) |
| r29190 | r29191 | |
| 975 | 944 | if (range_over++ >= 32) |
| 976 | 945 | break; |
| 977 | 946 | |
| 978 | | oam_itemlist[range_over - 1] = active_sprite; |
| 947 | m_oam_itemlist[range_over - 1] = active_sprite; |
| 979 | 948 | } |
| 980 | 949 | |
| 981 | 950 | /* reset the list of first 34 tiles to be drawn */ |
| 982 | 951 | for (ii = 0; ii < 34; ii++) |
| 983 | | oam_tilelist[ii].tileaddr = 0xffff; |
| 952 | m_oam_tilelist[ii].tileaddr = 0xffff; |
| 984 | 953 | |
| 985 | 954 | /* populate the list of 34 tiles */ |
| 986 | 955 | for (ii = 31; ii >= 0; ii--) |
| 987 | 956 | { |
| 988 | | if (oam_itemlist[ii] == 0xff) |
| 957 | if (m_oam_itemlist[ii] == 0xff) |
| 989 | 958 | continue; |
| 990 | 959 | |
| 991 | | active_sprite = oam_itemlist[ii]; |
| 960 | active_sprite = m_oam_itemlist[ii]; |
| 992 | 961 | |
| 993 | | tile = oam_spritelist[active_sprite].tile; |
| 994 | | x = oam_spritelist[active_sprite].x; |
| 995 | | y = oam_spritelist[active_sprite].y; |
| 996 | | height = oam_spritelist[active_sprite].height; |
| 997 | | width = oam_spritelist[active_sprite].width; |
| 998 | | vflip = oam_spritelist[active_sprite].vflip; |
| 999 | | hflip = oam_spritelist[active_sprite].hflip; |
| 1000 | | priority = oam_spritelist[active_sprite].priority_bits; |
| 1001 | | pal = oam_spritelist[active_sprite].pal; |
| 962 | tile = m_oam_spritelist[active_sprite].tile; |
| 963 | x = m_oam_spritelist[active_sprite].x; |
| 964 | y = m_oam_spritelist[active_sprite].y; |
| 965 | height = m_oam_spritelist[active_sprite].height; |
| 966 | width = m_oam_spritelist[active_sprite].width; |
| 967 | vflip = m_oam_spritelist[active_sprite].vflip; |
| 968 | hflip = m_oam_spritelist[active_sprite].hflip; |
| 969 | priority = m_oam_spritelist[active_sprite].priority_bits; |
| 970 | pal = m_oam_spritelist[active_sprite].pal; |
| 1002 | 971 | |
| 1003 | 972 | /* Adjust y, if past maximum position (for sprites which overlap between top & bottom) */ |
| 1004 | 973 | if (y >= (0x100 - 16) * m_interlace) |
| r29190 | r29191 | |
| 1030 | 999 | break; |
| 1031 | 1000 | |
| 1032 | 1001 | xs = (hflip) ? (width - 1 - jj) : jj; |
| 1033 | | oam_tilelist[time_over - 1].tileaddr = name_sel + tile + table_obj_offset[ys][xs] + line; |
| 1034 | | oam_tilelist[time_over - 1].hflip = hflip; |
| 1035 | | oam_tilelist[time_over - 1].x = xx; |
| 1036 | | oam_tilelist[time_over - 1].pal = pal; |
| 1037 | | oam_tilelist[time_over - 1].priority = priority; |
| 1002 | m_oam_tilelist[time_over - 1].tileaddr = name_sel + tile + table_obj_offset[ys][xs] + line; |
| 1003 | m_oam_tilelist[time_over - 1].hflip = hflip; |
| 1004 | m_oam_tilelist[time_over - 1].x = xx; |
| 1005 | m_oam_tilelist[time_over - 1].pal = pal; |
| 1006 | m_oam_tilelist[time_over - 1].priority = priority; |
| 1038 | 1007 | } |
| 1039 | 1008 | } |
| 1040 | 1009 | } |
| r29190 | r29191 | |
| 1061 | 1030 | int ii; |
| 1062 | 1031 | |
| 1063 | 1032 | #if SNES_LAYER_DEBUG |
| 1064 | | if (debug_options.bg_disabled[SNES_OAM]) |
| 1033 | if (m_debug_options.bg_disabled[SNES_OAM]) |
| 1065 | 1034 | return; |
| 1066 | 1035 | #endif /* SNES_LAYER_DEBUG */ |
| 1067 | 1036 | |
| r29190 | r29191 | |
| 1085 | 1054 | { |
| 1086 | 1055 | int tile = ii; |
| 1087 | 1056 | #if SNES_LAYER_DEBUG |
| 1088 | | if (debug_options.sprite_reversed) |
| 1057 | if (m_debug_options.sprite_reversed) |
| 1089 | 1058 | tile = 33 - ii; |
| 1090 | 1059 | #endif /* SNES_LAYER_DEBUG */ |
| 1091 | 1060 | |
| 1092 | | if (oam_tilelist[tile].tileaddr == 0xffff) |
| 1061 | if (m_oam_tilelist[tile].tileaddr == 0xffff) |
| 1093 | 1062 | continue; |
| 1094 | 1063 | |
| 1095 | | pri = priority[oam_tilelist[tile].priority]; |
| 1064 | pri = priority[m_oam_tilelist[tile].priority]; |
| 1096 | 1065 | |
| 1097 | 1066 | #if SNES_LAYER_DEBUG |
| 1098 | | if (debug_options.select_pri[SNES_OAM]) |
| 1067 | if (m_debug_options.select_pri[SNES_OAM]) |
| 1099 | 1068 | { |
| 1100 | | int oam_draw = debug_options.select_pri[SNES_OAM] - 1; |
| 1101 | | if (oam_draw != oam_tilelist[tile].priority) |
| 1069 | int oam_draw = m_debug_options.select_pri[SNES_OAM] - 1; |
| 1070 | if (oam_draw != m_oam_tilelist[tile].priority) |
| 1102 | 1071 | continue; |
| 1103 | 1072 | } |
| 1104 | 1073 | #endif /* SNES_LAYER_DEBUG */ |
| 1105 | 1074 | |
| 1106 | 1075 | /* OAM tiles have fixed planes (4), no direct color and no hires, but otherwise work the same as BG ones */ |
| 1107 | | draw_tile(4, SNES_OAM, charaddr + oam_tilelist[tile].tileaddr, oam_tilelist[tile].x, pri, oam_tilelist[tile].hflip, 0, oam_tilelist[tile].pal, 0); |
| 1076 | draw_tile(4, SNES_OAM, charaddr + m_oam_tilelist[tile].tileaddr, m_oam_tilelist[tile].x, pri, m_oam_tilelist[tile].hflip, 0, m_oam_tilelist[tile].pal, 0); |
| 1108 | 1077 | } |
| 1109 | 1078 | } |
| 1110 | 1079 | |
| r29190 | r29191 | |
| 1118 | 1087 | void snes_ppu_class::update_mode_0( UINT16 curline ) |
| 1119 | 1088 | { |
| 1120 | 1089 | #if SNES_LAYER_DEBUG |
| 1121 | | if (debug_options.mode_disabled[0]) |
| 1090 | if (m_debug_options.mode_disabled[0]) |
| 1122 | 1091 | return; |
| 1123 | 1092 | #endif /* SNES_LAYER_DEBUG */ |
| 1124 | 1093 | |
| r29190 | r29191 | |
| 1132 | 1101 | void snes_ppu_class::update_mode_1( UINT16 curline ) |
| 1133 | 1102 | { |
| 1134 | 1103 | #if SNES_LAYER_DEBUG |
| 1135 | | if (debug_options.mode_disabled[1]) |
| 1104 | if (m_debug_options.mode_disabled[1]) |
| 1136 | 1105 | return; |
| 1137 | 1106 | #endif /* SNES_LAYER_DEBUG */ |
| 1138 | 1107 | |
| r29190 | r29191 | |
| 1155 | 1124 | void snes_ppu_class::update_mode_2( UINT16 curline ) |
| 1156 | 1125 | { |
| 1157 | 1126 | #if SNES_LAYER_DEBUG |
| 1158 | | if (debug_options.mode_disabled[2]) |
| 1127 | if (m_debug_options.mode_disabled[2]) |
| 1159 | 1128 | return; |
| 1160 | 1129 | #endif /* SNES_LAYER_DEBUG */ |
| 1161 | 1130 | |
| r29190 | r29191 | |
| 1167 | 1136 | void snes_ppu_class::update_mode_3( UINT16 curline ) |
| 1168 | 1137 | { |
| 1169 | 1138 | #if SNES_LAYER_DEBUG |
| 1170 | | if (debug_options.mode_disabled[3]) |
| 1139 | if (m_debug_options.mode_disabled[3]) |
| 1171 | 1140 | return; |
| 1172 | 1141 | #endif /* SNES_LAYER_DEBUG */ |
| 1173 | 1142 | |
| r29190 | r29191 | |
| 1179 | 1148 | void snes_ppu_class::update_mode_4( UINT16 curline ) |
| 1180 | 1149 | { |
| 1181 | 1150 | #if SNES_LAYER_DEBUG |
| 1182 | | if (debug_options.mode_disabled[4]) |
| 1151 | if (m_debug_options.mode_disabled[4]) |
| 1183 | 1152 | return; |
| 1184 | 1153 | #endif /* SNES_LAYER_DEBUG */ |
| 1185 | 1154 | |
| r29190 | r29191 | |
| 1191 | 1160 | void snes_ppu_class::update_mode_5( UINT16 curline ) |
| 1192 | 1161 | { |
| 1193 | 1162 | #if SNES_LAYER_DEBUG |
| 1194 | | if (debug_options.mode_disabled[5]) |
| 1163 | if (m_debug_options.mode_disabled[5]) |
| 1195 | 1164 | return; |
| 1196 | 1165 | #endif /* SNES_LAYER_DEBUG */ |
| 1197 | 1166 | |
| r29190 | r29191 | |
| 1203 | 1172 | void snes_ppu_class::update_mode_6( UINT16 curline ) |
| 1204 | 1173 | { |
| 1205 | 1174 | #if SNES_LAYER_DEBUG |
| 1206 | | if (debug_options.mode_disabled[6]) |
| 1175 | if (m_debug_options.mode_disabled[6]) |
| 1207 | 1176 | return; |
| 1208 | 1177 | #endif /* SNES_LAYER_DEBUG */ |
| 1209 | 1178 | |
| r29190 | r29191 | |
| 1214 | 1183 | void snes_ppu_class::update_mode_7( UINT16 curline ) |
| 1215 | 1184 | { |
| 1216 | 1185 | #if SNES_LAYER_DEBUG |
| 1217 | | if (debug_options.mode_disabled[7]) |
| 1186 | if (m_debug_options.mode_disabled[7]) |
| 1218 | 1187 | return; |
| 1219 | 1188 | #endif /* SNES_LAYER_DEBUG */ |
| 1220 | 1189 | |
| r29190 | r29191 | |
| 1359 | 1328 | inline void snes_ppu_class::draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens ) |
| 1360 | 1329 | { |
| 1361 | 1330 | #if SNES_LAYER_DEBUG |
| 1362 | | if (debug_options.colormath_disabled) |
| 1331 | if (m_debug_options.colormath_disabled) |
| 1363 | 1332 | return; |
| 1364 | 1333 | #endif /* SNES_LAYER_DEBUG */ |
| 1365 | 1334 | |
| r29190 | r29191 | |
| 1386 | 1355 | |
| 1387 | 1356 | #if SNES_LAYER_DEBUG |
| 1388 | 1357 | /* Toggle drawing of SNES_SUBSCREEN or SNES_MAINSCREEN */ |
| 1389 | | if (debug_options.draw_subscreen) |
| 1358 | if (m_debug_options.draw_subscreen) |
| 1390 | 1359 | { |
| 1391 | 1360 | subscreen = switch_screens ? &m_scanlines[SNES_SUBSCREEN] : &m_scanlines[SNES_MAINSCREEN]; |
| 1392 | 1361 | } |
| r29190 | r29191 | |
| 1547 | 1516 | } |
| 1548 | 1517 | |
| 1549 | 1518 | /* Toggle drawing of SNES_SUBSCREEN or SNES_MAINSCREEN */ |
| 1550 | | if (debug_options.draw_subscreen) |
| 1519 | if (m_debug_options.draw_subscreen) |
| 1551 | 1520 | { |
| 1552 | 1521 | scanline1 = &m_scanlines[SNES_SUBSCREEN]; |
| 1553 | 1522 | scanline2 = &m_scanlines[SNES_MAINSCREEN]; |
| r29190 | r29191 | |
| 1649 | 1618 | running_machine &machine = screen.machine(); |
| 1650 | 1619 | |
| 1651 | 1620 | #if SNES_LAYER_DEBUG |
| 1652 | | memset(&debug_options, 0, sizeof(debug_options)); |
| 1621 | memset(&m_debug_options, 0, sizeof(m_debug_options)); |
| 1653 | 1622 | #endif |
| 1654 | 1623 | |
| 1655 | 1624 | m_vram = auto_alloc_array(machine, UINT8, SNES_VRAM_SIZE); |
| r29190 | r29191 | |
| 2670 | 2639 | { |
| 2671 | 2640 | int i; |
| 2672 | 2641 | UINT8 toggles = machine.root_device().ioport("DEBUG1")->read_safe(0); |
| 2673 | | debug_options.select_pri[SNES_BG1] = (toggles & 0x03); |
| 2674 | | debug_options.select_pri[SNES_BG2] = (toggles & 0x0c) >> 2; |
| 2675 | | debug_options.select_pri[SNES_BG3] = (toggles & 0x30) >> 4; |
| 2676 | | debug_options.select_pri[SNES_BG4] = (toggles & 0xc0) >> 6; |
| 2642 | m_debug_options.select_pri[SNES_BG1] = (toggles & 0x03); |
| 2643 | m_debug_options.select_pri[SNES_BG2] = (toggles & 0x0c) >> 2; |
| 2644 | m_debug_options.select_pri[SNES_BG3] = (toggles & 0x30) >> 4; |
| 2645 | m_debug_options.select_pri[SNES_BG4] = (toggles & 0xc0) >> 6; |
| 2677 | 2646 | |
| 2678 | 2647 | toggles = machine.root_device().ioport("DEBUG2")->read_safe(0); |
| 2679 | 2648 | for (i = 0; i < 4; i++) |
| 2680 | | DEBUG_TOGGLE(i, debug_options.bg_disabled[i], ("Debug: Disabled BG%d.\n", i + 1), ("Debug: Enabled BG%d.\n", i + 1)) |
| 2681 | | DEBUG_TOGGLE(4, debug_options.bg_disabled[SNES_OAM], ("Debug: Disabled OAM.\n"), ("Debug: Enabled OAM.\n")) |
| 2682 | | DEBUG_TOGGLE(5, debug_options.draw_subscreen, ("Debug: Switched screens.\n"), ("Debug: Switched screens.\n")) |
| 2683 | | DEBUG_TOGGLE(6, debug_options.colormath_disabled, ("Debug: Disabled Color Math.\n"), ("Debug: Enabled Color Math.\n")) |
| 2684 | | DEBUG_TOGGLE(7, debug_options.windows_disabled, ("Debug: Disabled Window Masks.\n"), ("Debug: Enabled Window Masks.\n")) |
| 2649 | DEBUG_TOGGLE(i, m_debug_options.bg_disabled[i], ("Debug: Disabled BG%d.\n", i + 1), ("Debug: Enabled BG%d.\n", i + 1)) |
| 2650 | DEBUG_TOGGLE(4, m_debug_options.bg_disabled[SNES_OAM], ("Debug: Disabled OAM.\n"), ("Debug: Enabled OAM.\n")) |
| 2651 | DEBUG_TOGGLE(5, m_debug_options.draw_subscreen, ("Debug: Switched screens.\n"), ("Debug: Switched screens.\n")) |
| 2652 | DEBUG_TOGGLE(6, m_debug_options.colormath_disabled, ("Debug: Disabled Color Math.\n"), ("Debug: Enabled Color Math.\n")) |
| 2653 | DEBUG_TOGGLE(7, m_debug_options.windows_disabled, ("Debug: Disabled Window Masks.\n"), ("Debug: Enabled Window Masks.\n")) |
| 2685 | 2654 | |
| 2686 | 2655 | toggles = machine.root_device().ioport("DEBUG4")->read_safe(0); |
| 2687 | 2656 | for (i = 0; i < 8; i++) |
| 2688 | | DEBUG_TOGGLE(i, debug_options.mode_disabled[i], ("Debug: Disabled Mode %d drawing.\n", i), ("Debug: Enabled Mode %d drawing.\n", i)) |
| 2657 | DEBUG_TOGGLE(i, m_debug_options.mode_disabled[i], ("Debug: Disabled Mode %d drawing.\n", i), ("Debug: Enabled Mode %d drawing.\n", i)) |
| 2689 | 2658 | |
| 2690 | 2659 | toggles = machine.root_device().ioport("DEBUG3")->read_safe(0); |
| 2691 | | DEBUG_TOGGLE(2, debug_options.mosaic_disabled, ("Debug: Disabled Mosaic.\n"), ("Debug: Enabled Mosaic.\n")) |
| 2692 | | debug_options.sprite_reversed = BIT(toggles, 7); |
| 2693 | | debug_options.select_pri[SNES_OAM] = (toggles & 0x70) >> 4; |
| 2660 | DEBUG_TOGGLE(2, m_debug_options.mosaic_disabled, ("Debug: Disabled Mosaic.\n"), ("Debug: Enabled Mosaic.\n")) |
| 2661 | m_debug_options.sprite_reversed = BIT(toggles, 7); |
| 2662 | m_debug_options.select_pri[SNES_OAM] = (toggles & 0x70) >> 4; |
| 2694 | 2663 | |
| 2695 | 2664 | #ifdef MAME_DEBUG |
| 2696 | 2665 | /* Once per frame, log video properties */ |
| r29190 | r29191 | |
| 2698 | 2667 | { |
| 2699 | 2668 | static const char WINLOGIC[4] = { '|', '&', '^', '!' }; |
| 2700 | 2669 | |
| 2701 | | logerror("%s", debug_options.windows_disabled?" ":"W"); |
| 2670 | logerror("%s", m_debug_options.windows_disabled?" ":"W"); |
| 2702 | 2671 | logerror("%s1 %s%s%s%s%s%c%s%s%d%s %d %4X %4X", |
| 2703 | | debug_options.bg_disabled[0]?" ":"*", |
| 2672 | m_debug_options.bg_disabled[0]?" ":"*", |
| 2704 | 2673 | (PPU_REG(TM) & 0x1)?"M":" ", |
| 2705 | 2674 | (PPU_REG(TS) & 0x1)?"S":" ", |
| 2706 | 2675 | (PPU_REG(CGADSUB) & 0x1)?"B":" ", |
| r29190 | r29191 | |
| 2715 | 2684 | (PPU_REG(BG1SC) & 0xfc) << 9, |
| 2716 | 2685 | m_layer[SNES_BG1].charmap << 13); |
| 2717 | 2686 | logerror("%s2 %s%s%s%s%s%c%s%s%d%s %d %4X %4X", |
| 2718 | | debug_options.bg_disabled[1]?" ":"*", |
| 2687 | m_debug_options.bg_disabled[1]?" ":"*", |
| 2719 | 2688 | (PPU_REG(TM) & 0x2)?"M":" ", |
| 2720 | 2689 | (PPU_REG(TS) & 0x2)?"S":" ", |
| 2721 | 2690 | (PPU_REG(CGADSUB) & 0x2)?"B":" ", |
| r29190 | r29191 | |
| 2730 | 2699 | (PPU_REG(BG2SC) & 0xfc) << 9, |
| 2731 | 2700 | m_layer[SNES_BG2].charmap << 13); |
| 2732 | 2701 | logerror("%s3 %s%s%s%s%s%c%s%s%d%s%s%d %4X %4X", |
| 2733 | | debug_options.bg_disabled[2]?" ":"*", |
| 2702 | m_debug_options.bg_disabled[2]?" ":"*", |
| 2734 | 2703 | (PPU_REG(TM) & 0x4)?"M":" ", |
| 2735 | 2704 | (PPU_REG(TS) & 0x4)?"S":" ", |
| 2736 | 2705 | (PPU_REG(CGADSUB) & 0x4)?"B":" ", |
| r29190 | r29191 | |
| 2746 | 2715 | (PPU_REG(BG3SC) & 0xfc) << 9, |
| 2747 | 2716 | m_layer[SNES_BG3].charmap << 13); |
| 2748 | 2717 | logerror("%s4 %s%s%s%s%s%c%s%s%d%s %d %4X %4X", |
| 2749 | | debug_options.bg_disabled[3]?" ":"*", |
| 2718 | m_debug_options.bg_disabled[3]?" ":"*", |
| 2750 | 2719 | (PPU_REG(TM) & 0x8)?"M":" ", |
| 2751 | 2720 | (PPU_REG(TS) & 0x8)?"S":" ", |
| 2752 | 2721 | (PPU_REG(CGADSUB) & 0x8)?"B":" ", |
| r29190 | r29191 | |
| 2761 | 2730 | (PPU_REG(BG4SC) & 0xfc) << 9, |
| 2762 | 2731 | m_layer[SNES_BG4].charmap << 13 ); |
| 2763 | 2732 | logerror("%sO %s%s%s%s%s%c%s%s %4X", |
| 2764 | | debug_options.bg_disabled[4]?" ":"*", |
| 2733 | m_debug_options.bg_disabled[4]?" ":"*", |
| 2765 | 2734 | (PPU_REG(TM) & 0x10)?"M":" ", |
| 2766 | 2735 | (PPU_REG(TS) & 0x10)?"S":" ", |
| 2767 | 2736 | (PPU_REG(CGADSUB) & 0x10)?"B":" ", |
| r29190 | r29191 | |
| 2772 | 2741 | (PPU_REG(WOBJSEL) & 0x8)?((PPU_REG(WOBJSEL) & 0x4)?"o":"i"):" ", |
| 2773 | 2742 | m_layer[SNES_OAM].charmap << 13 ); |
| 2774 | 2743 | logerror("%sB %s %c%s%s", |
| 2775 | | debug_options.colormath_disabled?" ":"*", |
| 2744 | m_debug_options.colormath_disabled?" ":"*", |
| 2776 | 2745 | (PPU_REG(CGADSUB) & 0x20)?"B":" ", |
| 2777 | 2746 | WINLOGIC[(PPU_REG(WOBJLOG) & 0xc)>>2], |
| 2778 | 2747 | (PPU_REG(WOBJSEL) & 0x20)?((PPU_REG(WOBJSEL) & 0x10)?"o":"i"):" ", |