src/mame/machine/snes.c
| r7540 | r7541 | |
| 1133 | 1133 | } |
| 1134 | 1134 | break; |
| 1135 | 1135 | case TM: /* Main screen designation */ |
| 1136 | | snes_ppu.main_bg_enabled[0] = BIT(data, 0); |
| 1137 | | snes_ppu.main_bg_enabled[1] = BIT(data, 1); |
| 1138 | | snes_ppu.main_bg_enabled[2] = BIT(data, 2); |
| 1139 | | snes_ppu.main_bg_enabled[3] = BIT(data, 3); |
| 1140 | | snes_ppu.main_bg_enabled[4] = BIT(data, 4); |
| 1136 | snes_ppu.layer[SNES_BG1].main_bg_enabled = BIT(data, 0); |
| 1137 | snes_ppu.layer[SNES_BG2].main_bg_enabled = BIT(data, 1); |
| 1138 | snes_ppu.layer[SNES_BG3].main_bg_enabled = BIT(data, 2); |
| 1139 | snes_ppu.layer[SNES_BG4].main_bg_enabled = BIT(data, 3); |
| 1140 | snes_ppu.layer[SNES_OAM].main_bg_enabled = BIT(data, 4); |
| 1141 | 1141 | break; |
| 1142 | 1142 | case TS: /* Subscreen designation */ |
| 1143 | | snes_ppu.sub_bg_enabled[0] = BIT(data, 0); |
| 1144 | | snes_ppu.sub_bg_enabled[1] = BIT(data, 1); |
| 1145 | | snes_ppu.sub_bg_enabled[2] = BIT(data, 2); |
| 1146 | | snes_ppu.sub_bg_enabled[3] = BIT(data, 3); |
| 1147 | | snes_ppu.sub_bg_enabled[4] = BIT(data, 4); |
| 1143 | snes_ppu.layer[SNES_BG1].sub_bg_enabled = BIT(data, 0); |
| 1144 | snes_ppu.layer[SNES_BG2].sub_bg_enabled = BIT(data, 1); |
| 1145 | snes_ppu.layer[SNES_BG3].sub_bg_enabled = BIT(data, 2); |
| 1146 | snes_ppu.layer[SNES_BG4].sub_bg_enabled = BIT(data, 3); |
| 1147 | snes_ppu.layer[SNES_OAM].sub_bg_enabled = BIT(data, 4); |
| 1148 | 1148 | break; |
| 1149 | 1149 | case TMW: /* Window mask for main screen designation */ |
| 1150 | 1150 | snes_ppu.layer[SNES_BG1].main_window_enabled = BIT(data, 0); |
| r7540 | r7541 | |
| 1162 | 1162 | break; |
| 1163 | 1163 | case CGWSEL: /* Initial settings for Fixed colour addition or screen addition */ |
| 1164 | 1164 | /* FIXME: We don't support direct select for modes 3 & 4 or subscreen window stuff */ |
| 1165 | | snes_ppu.main_color_mask = (data >> 6) & 0x03; |
| 1166 | | snes_ppu.sub_color_mask = (data >> 4) & 0x03; |
| 1165 | snes_ppu.clip_to_black = (data >> 6) & 0x03; |
| 1166 | snes_ppu.prevent_color_math = (data >> 4) & 0x03; |
| 1167 | 1167 | snes_ppu.sub_add_mode = BIT(data, 1); |
| 1168 | 1168 | snes_ppu.direct_color = BIT(data, 0); |
| 1169 | 1169 | #ifdef SNES_DBG_REG_W |
src/mame/video/snes.c
| r7540 | r7541 | |
| 76 | 76 | |
| 77 | 77 | #define SNES_MAINSCREEN 0 |
| 78 | 78 | #define SNES_SUBSCREEN 1 |
| 79 | | #define SNES_CLIP_ALL 0 |
| 79 | #define SNES_CLIP_NEVER 0 |
| 80 | 80 | #define SNES_CLIP_IN 1 |
| 81 | 81 | #define SNES_CLIP_OUT 2 |
| 82 | | #define SNES_CLIP_ALL2 3 |
| 82 | #define SNES_CLIP_ALWAYS 3 |
| 83 | 83 | |
| 84 | 84 | #ifdef SNES_LAYER_DEBUG |
| 85 | 85 | struct DEBUGOPTS |
| r7540 | r7541 | |
| 136 | 136 | * between the main and sub screens. |
| 137 | 137 | *****************************************/ |
| 138 | 138 | |
| 139 | | INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip, int switch_screens ) |
| 139 | INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens ) |
| 140 | 140 | { |
| 141 | 141 | /* when color math is applied to subscreen pixels, the blending depends on the blending used by the previous mainscreen |
| 142 | 142 | pixel, except for subscreen pixel 0 which has no previous mainscreen pixel, see comments in snes_refresh_scanline */ |
| 143 | 143 | if (switch_screens && offset > 0) |
| 144 | 144 | offset -= 1; |
| 145 | 145 | |
| 146 | | if ((black_pen_clip == SNES_CLIP_ALL2) || |
| 146 | if ((black_pen_clip == SNES_CLIP_ALWAYS) || |
| 147 | 147 | (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 148 | 148 | (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 149 | 149 | *colour = 0; //clip to black before color math |
| 150 | 150 | |
| 151 | | if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF |
| 151 | if (prevent_color_math == SNES_CLIP_ALWAYS) // blending mode 3 == always OFF |
| 152 | 152 | return; |
| 153 | 153 | |
| 154 | 154 | #ifdef SNES_LAYER_DEBUG |
| 155 | 155 | if (!debug_options.transparency_disabled) |
| 156 | 156 | #endif /* SNES_LAYER_DEBUG */ |
| 157 | | if ((clip == SNES_CLIP_ALL) || |
| 158 | | (clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 159 | | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 157 | if ((prevent_color_math == SNES_CLIP_NEVER) || |
| 158 | (prevent_color_math == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 159 | (prevent_color_math == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 160 | 160 | { |
| 161 | 161 | UINT16 r, g, b; |
| 162 | 162 | struct SCANLINE *subscreen; |
| r7540 | r7541 | |
| 655 | 655 | return; |
| 656 | 656 | #endif /* SNES_LAYER_DEBUG */ |
| 657 | 657 | |
| 658 | | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer]; |
| 659 | | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer]; |
| 658 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.layer[layer].main_bg_enabled; |
| 659 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.layer[layer].sub_bg_enabled; |
| 660 | 660 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled; |
| 661 | 661 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled; |
| 662 | 662 | |
| r7540 | r7541 | |
| 828 | 828 | return; |
| 829 | 829 | #endif /* SNES_LAYER_DEBUG */ |
| 830 | 830 | |
| 831 | | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer]; |
| 832 | | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer]; |
| 831 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.layer[layer].main_bg_enabled; |
| 832 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.layer[layer].sub_bg_enabled; |
| 833 | 833 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled; |
| 834 | 834 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled; |
| 835 | 835 | |
| r7540 | r7541 | |
| 1120 | 1120 | return; |
| 1121 | 1121 | #endif /* SNES_LAYER_DEBUG */ |
| 1122 | 1122 | |
| 1123 | | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[SNES_OAM]; |
| 1124 | | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[SNES_OAM]; |
| 1123 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.layer[SNES_OAM].main_bg_enabled; |
| 1124 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.layer[SNES_OAM].sub_bg_enabled; |
| 1125 | 1125 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[SNES_OAM].main_window_enabled; |
| 1126 | 1126 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 1127 | 1127 | |
| r7540 | r7541 | |
| 1531 | 1531 | |
| 1532 | 1532 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1533 | 1533 | if (!scanline1->blend_exception[x] && snes_ppu.layer[scanline1->layer[x]].color_math) |
| 1534 | | snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask, 0); |
| 1534 | snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 0); |
| 1535 | 1535 | |
| 1536 | 1536 | r = ((c & 0x1f) * fade) >> 4; |
| 1537 | 1537 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| r7540 | r7541 | |
| 1552 | 1552 | the same color math as the *next* mainscreen pixel (i.e. mainscreen pixel 0) */ |
| 1553 | 1553 | |
| 1554 | 1554 | if (x == 0 && !scanline1->blend_exception[0] && snes_ppu.layer[scanline1->layer[0]].color_math) |
| 1555 | | snes_draw_blend(0, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask, 1); |
| 1555 | snes_draw_blend(0, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1); |
| 1556 | 1556 | else if (x > 0 && !scanline1->blend_exception[x - 1] && snes_ppu.layer[scanline1->layer[x - 1]].color_math) |
| 1557 | | snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask, 1); |
| 1557 | snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1); |
| 1558 | 1558 | |
| 1559 | 1559 | |
| 1560 | 1560 | r = ((c & 0x1f) * fade) >> 4; |