src/mame/video/snes.c
| r7494 | r7495 | |
| 860 | 860 | { |
| 861 | 861 | if ((x + (count << 3) < SNES_SCR_WIDTH + 8)) |
| 862 | 862 | { |
| 863 | | if (widemode) |
| 864 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1); |
| 865 | | else |
| 866 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0); |
| 863 | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, widemode); |
| 867 | 864 | } |
| 868 | 865 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 869 | 866 | } |
| r7494 | r7495 | |
| 874 | 871 | { |
| 875 | 872 | if ((x + (xs << 3) < SNES_SCR_WIDTH + 8)) |
| 876 | 873 | { |
| 877 | | if (widemode) |
| 878 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1); |
| 879 | | else |
| 880 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0); |
| 874 | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, widemode); |
| 881 | 875 | } |
| 882 | 876 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 883 | 877 | } |
| r7494 | r7495 | |
| 913 | 907 | UINT8 *bg_enabled; |
| 914 | 908 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 915 | 909 | |
| 916 | | if (bg_enabled[4]) snes_update_objects(screen, 0, curline); |
| 917 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0); |
| 918 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0); |
| 919 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0); |
| 920 | 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); |
| 921 | 915 | } |
| 922 | 916 | |
| 923 | 917 | static void snes_update_mode_1( UINT8 screen, UINT16 curline ) |
| r7494 | r7495 | |
| 927 | 921 | |
| 928 | 922 | if (!snes_ppu.bg3_priority_bit) |
| 929 | 923 | { |
| 930 | | if (bg_enabled[4]) snes_update_objects(screen, 1, curline); |
| 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[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0); |
| 933 | 924 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0); |
| 925 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0); |
| 926 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0); |
| 927 | if (bg_enabled[4]) snes_update_objects(screen, 1, curline); |
| 934 | 928 | } |
| 935 | 929 | else |
| 936 | 930 | { |
| 937 | | if (bg_enabled[4]) snes_update_objects(screen, 9, curline); |
| 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[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0); |
| 940 | 931 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0); |
| 932 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0); |
| 933 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0); |
| 934 | if (bg_enabled[4]) snes_update_objects(screen, 9, curline); |
| 941 | 935 | } |
| 942 | 936 | } |
| 943 | 937 | |
| r7494 | r7495 | |
| 946 | 940 | UINT8 *bg_enabled; |
| 947 | 941 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 948 | 942 | |
| 949 | | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| 950 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0); |
| 951 | 943 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0); |
| 944 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0); |
| 945 | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| 952 | 946 | } |
| 953 | 947 | |
| 954 | 948 | static void snes_update_mode_3( UINT8 screen, UINT16 curline ) |
| r7494 | r7495 | |
| 956 | 950 | UINT8 *bg_enabled; |
| 957 | 951 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 958 | 952 | |
| 959 | | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| 960 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 961 | 953 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 954 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 955 | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| 962 | 956 | } |
| 963 | 957 | |
| 964 | 958 | static void snes_update_mode_4( UINT8 screen, UINT16 curline ) |
| r7494 | r7495 | |
| 966 | 960 | UINT8 *bg_enabled; |
| 967 | 961 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 968 | 962 | |
| 969 | | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| 970 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 971 | 963 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 964 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 965 | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| 972 | 966 | } |
| 973 | 967 | |
| 974 | 968 | static void snes_update_mode_5( UINT8 screen, UINT16 curline ) |
| r7494 | r7495 | |
| 976 | 970 | UINT8 *bg_enabled; |
| 977 | 971 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 978 | 972 | |
| 979 | | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| 980 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0); |
| 981 | 973 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0); |
| 974 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0); |
| 975 | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| 982 | 976 | } |
| 983 | 977 | |
| 984 | 978 | static void snes_update_mode_6( UINT8 screen, UINT16 curline ) |
| r7494 | r7495 | |
| 986 | 980 | UINT8 *bg_enabled; |
| 987 | 981 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 988 | 982 | |
| 989 | | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 990 | 983 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0); |
| 984 | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 991 | 985 | } |
| 992 | 986 | |
| 993 | 987 | static void snes_update_mode_7( UINT8 screen, UINT16 curline ) |
| r7494 | r7495 | |
| 997 | 991 | |
| 998 | 992 | if (!snes_ppu.mode7.extbg) |
| 999 | 993 | { |
| 1000 | | if (bg_enabled[4]) snes_update_objects(screen, 7, curline); |
| 1001 | 994 | if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline); |
| 995 | if (bg_enabled[4]) snes_update_objects(screen, 7, curline); |
| 1002 | 996 | } |
| 1003 | 997 | else |
| 1004 | 998 | { |
| 1005 | | if (bg_enabled[4]) snes_update_objects(screen, 8, curline); |
| 1006 | | if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline); |
| 1007 | 999 | if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, SNES_BG2, curline); |
| 1000 | if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline); |
| 1001 | if (bg_enabled[4]) snes_update_objects(screen, 8, curline); |
| 1008 | 1002 | } |
| 1009 | 1003 | } |
| 1010 | 1004 | |
| r7494 | r7495 | |
| 1196 | 1190 | |
| 1197 | 1191 | for (x = 0; x < SNES_SCR_WIDTH * 2; x += 2) |
| 1198 | 1192 | { |
| 1199 | | // if (snes_ppu.mode != 5 && snes_ppu.mode != 6) |
| 1193 | int r, g, b, hires; |
| 1194 | UINT16 temp_col; |
| 1195 | hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1; |
| 1196 | c = scanline->buffer[x]; |
| 1197 | temp_col = scanline->buffer[x]; |
| 1198 | |
| 1199 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1200 | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1201 | snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1202 | |
| 1203 | r = ((c & 0x1f) * fade) >> 4; |
| 1204 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1205 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1206 | |
| 1207 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1208 | if (!hires) |
| 1209 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1210 | else |
| 1200 | 1211 | { |
| 1201 | | int r, g, b; |
| 1202 | | c = scanline->buffer[x]; |
| 1212 | c = scanlines[SNES_SUBSCREEN].buffer[x]; |
| 1213 | scanlines[SNES_SUBSCREEN].buffer[x] = temp_col; |
| 1203 | 1214 | |
| 1204 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1205 | 1215 | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1206 | 1216 | snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1207 | 1217 | |
| r7494 | r7495 | |
| 1209 | 1219 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1210 | 1220 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1211 | 1221 | |
| 1212 | | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1213 | 1222 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1223 | } |
| 1214 | 1224 | |
| 1215 | | c = scanline->buffer[x + 1]; |
| 1225 | c = scanline->buffer[x + 1]; |
| 1226 | temp_col = scanline->buffer[x + 1]; |
| 1216 | 1227 | |
| 1217 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1218 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math) |
| 1219 | | snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1228 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1229 | if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math) |
| 1230 | snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1220 | 1231 | |
| 1221 | | r = ((c & 0x1f) * fade) >> 4; |
| 1222 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1223 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1232 | r = ((c & 0x1f) * fade) >> 4; |
| 1233 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1234 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1224 | 1235 | |
| 1225 | | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1236 | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1237 | if (!hires) |
| 1226 | 1238 | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1227 | | |
| 1228 | | } |
| 1229 | | #if 0 |
| 1230 | 1239 | else |
| 1231 | 1240 | { |
| 1232 | | int r, g, b; |
| 1233 | | UINT16 temp_col; |
| 1234 | | c = scanline->buffer[x]; |
| 1235 | | temp_col = scanline->buffer[x]; |
| 1241 | c = scanlines[SNES_SUBSCREEN].buffer[x + 1]; |
| 1242 | scanlines[SNES_SUBSCREEN].buffer[x + 1] = temp_col; |
| 1236 | 1243 | |
| 1237 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1238 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1239 | | snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1244 | if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math) |
| 1245 | snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1240 | 1246 | |
| 1241 | 1247 | r = ((c & 0x1f) * fade) >> 4; |
| 1242 | 1248 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1243 | 1249 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1244 | 1250 | |
| 1245 | | *BITMAP_ADDR32(bitmap, curline, x) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1246 | | |
| 1247 | | c = scanlines[SNES_SUBSCREEN].buffer[x]; |
| 1248 | | scanlines[SNES_SUBSCREEN].buffer[x] = temp_col; |
| 1249 | | |
| 1250 | | /* perform color math only if it's been done on the previous pixel */ |
| 1251 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1252 | | snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1253 | | |
| 1254 | | r = ((c & 0x1f) * fade) >> 4; |
| 1255 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1256 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1257 | | |
| 1258 | | *BITMAP_ADDR32(bitmap, curline, x + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1251 | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1259 | 1252 | } |
| 1260 | | #endif |
| 1261 | 1253 | } |
| 1262 | 1254 | } |
| 1263 | 1255 | |