src/mame/video/snes.c
| r7498 | r7499 | |
| 135 | 135 | * Routine for additive/subtractive blending |
| 136 | 136 | * between the main and sub screens. |
| 137 | 137 | *****************************************/ |
| 138 | | INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 factor, UINT8 clip, UINT8 black_pen_clip ) |
| 138 | |
| 139 | INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 139 | 140 | { |
| 140 | 141 | if ((black_pen_clip == SNES_CLIP_ALL2) || |
| 141 | | (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset / factor]) || |
| 142 | | (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset / factor])) |
| 142 | (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 143 | (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 143 | 144 | *colour = 0; //clip to black before color math |
| 144 | 145 | |
| 145 | 146 | if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF |
| r7498 | r7499 | |
| 149 | 150 | if (!debug_options.transparency_disabled) |
| 150 | 151 | #endif /* SNES_LAYER_DEBUG */ |
| 151 | 152 | if ((clip == SNES_CLIP_ALL) || |
| 152 | | (clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset / factor]) || |
| 153 | | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset / factor])) |
| 153 | (clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 154 | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 154 | 155 | { |
| 155 | 156 | UINT16 r, g, b; |
| 156 | 157 | int clip_max = 0; // if add then clip to 0x1f, if sub then clip to 0 |
| r7498 | r7499 | |
| 224 | 225 | } |
| 225 | 226 | } |
| 226 | 227 | |
| 227 | | INLINE void snes_draw_blend_lores(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 228 | | { |
| 229 | | snes_draw_blend(offset, colour, 1, clip, black_pen_clip); |
| 230 | | } |
| 231 | | |
| 232 | | INLINE void snes_draw_blend_hires(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 233 | | { |
| 234 | | snes_draw_blend(offset, colour, 1, clip, black_pen_clip); |
| 235 | | } |
| 236 | | |
| 237 | 228 | /***************************************** |
| 238 | 229 | * snes_draw_tile() |
| 239 | 230 | * |
| 240 | 231 | * Draw tiles with variable bit planes |
| 241 | 232 | *****************************************/ |
| 242 | | INLINE void snes_draw_tile(UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 233 | |
| 234 | INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 243 | 235 | { |
| 244 | 236 | UINT8 mask, plane[8]; |
| 245 | 237 | UINT16 c; |
| r7498 | r7499 | |
| 444 | 436 | * |
| 445 | 437 | * Draw 2 tiles with variable bit planes |
| 446 | 438 | *****************************************/ |
| 447 | | 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 ) |
| 439 | |
| 440 | 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 ) |
| 448 | 441 | { |
| 449 | 442 | if (flip) |
| 450 | 443 | { |
| r7498 | r7499 | |
| 465 | 458 | * The same as snes_draw_tile_4() except |
| 466 | 459 | * that it takes a blend parameter. |
| 467 | 460 | *****************************************/ |
| 461 | |
| 468 | 462 | INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) |
| 469 | 463 | { |
| 470 | 464 | UINT8 mask, plane[4]; |
| r7498 | r7499 | |
| 774 | 768 | * |
| 775 | 769 | * Update an entire line of mode7 tiles. |
| 776 | 770 | *********************************************/ |
| 771 | |
| 777 | 772 | #define MODE7_CLIP(x) (((x) & 0x2000) ? ((x) | ~0x03ff) : ((x) & 0x03ff)) |
| 778 | 773 | |
| 779 | 774 | static void snes_update_line_mode7( UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline ) |
| r7498 | r7499 | |
| 948 | 943 | * Update an entire line of sprites. |
| 949 | 944 | * FIXME: We need to support high priority bit |
| 950 | 945 | *********************************************/ |
| 946 | |
| 951 | 947 | static void snes_update_objects( UINT8 priority_tbl, UINT16 curline ) |
| 952 | 948 | { |
| 953 | 949 | INT8 xs, ys; |
| r7498 | r7499 | |
| 1086 | 1082 | * |
| 1087 | 1083 | * Update Mode X line. |
| 1088 | 1084 | *********************************************/ |
| 1085 | |
| 1089 | 1086 | static void snes_update_mode_0( UINT16 curline ) |
| 1090 | 1087 | { |
| 1091 | 1088 | #ifdef SNES_LAYER_DEBUG |
| r7498 | r7499 | |
| 1235 | 1232 | * XOR: ...###..###... ###...##...### |
| 1236 | 1233 | * XNOR: ###...##...### ...###..###... |
| 1237 | 1234 | *********************************************/ |
| 1238 | | static void snes_update_windowmasks(void) |
| 1235 | |
| 1236 | static void snes_update_windowmasks( void ) |
| 1239 | 1237 | { |
| 1240 | 1238 | UINT16 ii, jj; |
| 1241 | 1239 | INT8 w1, w2; |
| r7498 | r7499 | |
| 1306 | 1304 | * |
| 1307 | 1305 | * Update the offsets with the latest changes. |
| 1308 | 1306 | *********************************************/ |
| 1309 | | static void snes_update_offsets(void) |
| 1307 | |
| 1308 | static void snes_update_offsets( void ) |
| 1310 | 1309 | { |
| 1311 | 1310 | int ii; |
| 1312 | 1311 | for (ii = 0; ii < 4; ii++) |
| r7498 | r7499 | |
| 1320 | 1319 | * |
| 1321 | 1320 | * Redraw the current line. |
| 1322 | 1321 | *********************************************/ |
| 1322 | |
| 1323 | 1323 | static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, UINT16 curline ) |
| 1324 | 1324 | { |
| 1325 | 1325 | UINT16 ii; |
| r7498 | r7499 | |
| 1396 | 1396 | |
| 1397 | 1397 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1398 | 1398 | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1399 | | snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1399 | snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1400 | 1400 | |
| 1401 | 1401 | r = ((c & 0x1f) * fade) >> 4; |
| 1402 | 1402 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| r7498 | r7499 | |
| 1412 | 1412 | scanlines[SNES_SUBSCREEN].buffer[x] = temp_col; |
| 1413 | 1413 | |
| 1414 | 1414 | if (!scanlines[SNES_SUBSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1415 | | snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1415 | snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1416 | 1416 | |
| 1417 | 1417 | r = ((c & 0x1f) * fade) >> 4; |
| 1418 | 1418 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |