src/mame/video/snes.c
| r7495 | r7496 | |
| 278 | 278 | /* Clip to windows */ |
| 279 | 279 | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 280 | 280 | if (window_enabled) |
| 281 | | colour &= snes_ppu.clipmasks[layer][ii]; |
| 281 | colour &= snes_ppu.clipmasks[layer][ii >> hires]; |
| 282 | 282 | |
| 283 | 283 | /* Only draw if we have a colour (0 == transparent) */ |
| 284 | 284 | if (colour) |
| 285 | 285 | { |
| 286 | | if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0)) |
| 286 | if ((scanlines[screen].priority[ii >> hires] <= priority) && (ii >= 0)) |
| 287 | 287 | { |
| 288 | 288 | if (direct_colors) |
| 289 | 289 | { |
| r7495 | r7496 | |
| 490 | 490 | #ifdef SNES_LAYER_DEBUG |
| 491 | 491 | if (debug_options.bg_disabled[layer]) |
| 492 | 492 | return; |
| 493 | | |
| 494 | | if (debug_options.mode_disabled[snes_ppu.mode]) |
| 495 | | return; |
| 496 | 493 | #endif /* SNES_LAYER_DEBUG */ |
| 497 | 494 | |
| 498 | 495 | /* Handle Mosaic effects */ |
| r7495 | r7496 | |
| 558 | 555 | ppp = Tile palette. The number of entries in the palette depends on the Mode and the BG. |
| 559 | 556 | cccccccccc = Tile number. |
| 560 | 557 | */ |
| 561 | | UINT32 addr = snes_get_tmap(layer, tile_size, tmap, ii + xoff, yoff); |
| 558 | |
| 559 | UINT32 addr = snes_get_tmap(layer, tile_size, tmap, (ii << (tile_size * hires)) + xoff, yoff); |
| 562 | 560 | UINT16 tilemap = snes_vram[addr] | (snes_vram[addr + 1] << 8); |
| 563 | 561 | vflip = BIT(tilemap, 15); |
| 564 | 562 | hflip = BIT(tilemap, 14); |
| r7495 | r7496 | |
| 640 | 638 | #ifdef SNES_LAYER_DEBUG |
| 641 | 639 | if (debug_options.bg_disabled[layer]) |
| 642 | 640 | return; |
| 643 | | |
| 644 | | if (debug_options.mode_disabled[snes_ppu.mode]) |
| 645 | | return; |
| 646 | 641 | #endif /* SNES_LAYER_DEBUG */ |
| 647 | 642 | |
| 648 | 643 | ma = snes_ppu.mode7.matrix_a; |
| r7495 | r7496 | |
| 795 | 790 | }; |
| 796 | 791 | |
| 797 | 792 | #ifdef SNES_LAYER_DEBUG |
| 798 | | if (debug_options.bg_disabled[4]) |
| 793 | if (debug_options.bg_disabled[SNES_OAM]) |
| 799 | 794 | return; |
| 800 | 795 | #endif /* SNES_LAYER_DEBUG */ |
| 801 | 796 | |
| r7495 | r7496 | |
| 907 | 902 | UINT8 *bg_enabled; |
| 908 | 903 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 909 | 904 | |
| 905 | #ifdef SNES_LAYER_DEBUG |
| 906 | if (debug_options.mode_disabled[0]) |
| 907 | return; |
| 908 | #endif /* SNES_LAYER_DEBUG */ |
| 909 | |
| 910 | 910 | if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0); |
| 911 | 911 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0); |
| 912 | 912 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0); |
| r7495 | r7496 | |
| 919 | 919 | UINT8 *bg_enabled; |
| 920 | 920 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 921 | 921 | |
| 922 | #ifdef SNES_LAYER_DEBUG |
| 923 | if (debug_options.mode_disabled[1]) |
| 924 | return; |
| 925 | #endif /* SNES_LAYER_DEBUG */ |
| 926 | |
| 922 | 927 | if (!snes_ppu.bg3_priority_bit) |
| 923 | 928 | { |
| 924 | 929 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0); |
| r7495 | r7496 | |
| 940 | 945 | UINT8 *bg_enabled; |
| 941 | 946 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 942 | 947 | |
| 948 | #ifdef SNES_LAYER_DEBUG |
| 949 | if (debug_options.mode_disabled[2]) |
| 950 | return; |
| 951 | #endif /* SNES_LAYER_DEBUG */ |
| 952 | |
| 943 | 953 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0); |
| 944 | 954 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0); |
| 945 | 955 | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| r7495 | r7496 | |
| 950 | 960 | UINT8 *bg_enabled; |
| 951 | 961 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 952 | 962 | |
| 963 | #ifdef SNES_LAYER_DEBUG |
| 964 | if (debug_options.mode_disabled[3]) |
| 965 | return; |
| 966 | #endif /* SNES_LAYER_DEBUG */ |
| 967 | |
| 953 | 968 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 954 | 969 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 955 | 970 | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| r7495 | r7496 | |
| 960 | 975 | UINT8 *bg_enabled; |
| 961 | 976 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 962 | 977 | |
| 978 | #ifdef SNES_LAYER_DEBUG |
| 979 | if (debug_options.mode_disabled[4]) |
| 980 | return; |
| 981 | #endif /* SNES_LAYER_DEBUG */ |
| 982 | |
| 963 | 983 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 964 | 984 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 965 | 985 | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| r7495 | r7496 | |
| 970 | 990 | UINT8 *bg_enabled; |
| 971 | 991 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 972 | 992 | |
| 993 | #ifdef SNES_LAYER_DEBUG |
| 994 | if (debug_options.mode_disabled[5]) |
| 995 | return; |
| 996 | #endif /* SNES_LAYER_DEBUG */ |
| 997 | |
| 973 | 998 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0); |
| 974 | 999 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0); |
| 975 | 1000 | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| r7495 | r7496 | |
| 980 | 1005 | UINT8 *bg_enabled; |
| 981 | 1006 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 982 | 1007 | |
| 1008 | #ifdef SNES_LAYER_DEBUG |
| 1009 | if (debug_options.mode_disabled[6]) |
| 1010 | return; |
| 1011 | #endif /* SNES_LAYER_DEBUG */ |
| 1012 | |
| 983 | 1013 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0); |
| 984 | 1014 | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 985 | 1015 | } |
| r7495 | r7496 | |
| 989 | 1019 | UINT8 *bg_enabled; |
| 990 | 1020 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 991 | 1021 | |
| 1022 | #ifdef SNES_LAYER_DEBUG |
| 1023 | if (debug_options.mode_disabled[7]) |
| 1024 | return; |
| 1025 | #endif /* SNES_LAYER_DEBUG */ |
| 1026 | |
| 992 | 1027 | if (!snes_ppu.mode7.extbg) |
| 993 | 1028 | { |
| 994 | 1029 | if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline); |
| r7495 | r7496 | |
| 1007 | 1042 | * |
| 1008 | 1043 | * Draw the whole screen (Mode 0 -> 7). |
| 1009 | 1044 | *********************************************/ |
| 1045 | |
| 1010 | 1046 | static void snes_draw_screen( UINT8 screen, UINT16 curline ) |
| 1011 | 1047 | { |
| 1012 | 1048 | switch (snes_ppu.mode) |
| r7495 | r7496 | |
| 1188 | 1224 | /* Phew! Draw the line to screen */ |
| 1189 | 1225 | fade = snes_ppu.screen_brightness; |
| 1190 | 1226 | |
| 1191 | | for (x = 0; x < SNES_SCR_WIDTH * 2; x += 2) |
| 1227 | for (x = 0; x < SNES_SCR_WIDTH * 2; x++) |
| 1192 | 1228 | { |
| 1193 | 1229 | int r, g, b, hires; |
| 1194 | 1230 | UINT16 temp_col; |
| r7495 | r7496 | |
| 1205 | 1241 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1206 | 1242 | |
| 1207 | 1243 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1244 | |
| 1208 | 1245 | if (!hires) |
| 1209 | 1246 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1210 | 1247 | else |
| r7495 | r7496 | |
| 1221 | 1258 | |
| 1222 | 1259 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1223 | 1260 | } |
| 1224 | | |
| 1225 | | c = scanline->buffer[x + 1]; |
| 1226 | | temp_col = scanline->buffer[x + 1]; |
| 1227 | | |
| 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); |
| 1231 | | |
| 1232 | | r = ((c & 0x1f) * fade) >> 4; |
| 1233 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1234 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1235 | | |
| 1236 | | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1237 | | if (!hires) |
| 1238 | | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1239 | | else |
| 1240 | | { |
| 1241 | | c = scanlines[SNES_SUBSCREEN].buffer[x + 1]; |
| 1242 | | scanlines[SNES_SUBSCREEN].buffer[x + 1] = temp_col; |
| 1243 | | |
| 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); |
| 1246 | | |
| 1247 | | r = ((c & 0x1f) * fade) >> 4; |
| 1248 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1249 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1250 | | |
| 1251 | | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1252 | | } |
| 1253 | 1261 | } |
| 1254 | 1262 | } |
| 1255 | 1263 | |