Previous 15994 Revisions Next

r7499 Friday 5th March, 2010 at 09:19:20 UTC by Fabio Priuli
[SNES] drawing routine rewrite, part 7 (and last, for the moment):
* a few cleanups
[src/mame/video]snes.c

src/mame/video/snes.c
r7498r7499
135135 * Routine for additive/subtractive blending
136136 * between the main and sub screens.
137137 *****************************************/
138INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 factor, UINT8 clip, UINT8 black_pen_clip )
138
139INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip )
139140{
140141   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]))
143144      *colour = 0; //clip to black before color math
144145
145146   if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF
r7498r7499
149150   if (!debug_options.transparency_disabled)
150151#endif /* SNES_LAYER_DEBUG */
151152   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]))
154155   {
155156      UINT16 r, g, b;
156157      int clip_max = 0;   // if add then clip to 0x1f, if sub then clip to 0
r7498r7499
224225   }
225226}
226227
227INLINE 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
232INLINE 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
237228/*****************************************
238229 * snes_draw_tile()
239230 *
240231 * Draw tiles with variable bit planes
241232 *****************************************/
242INLINE void snes_draw_tile(UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires )
233
234INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires )
243235{
244236   UINT8 mask, plane[8];
245237   UINT16 c;
r7498r7499
444436 *
445437 * Draw 2 tiles with variable bit planes
446438 *****************************************/
447INLINE 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
440INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires )
448441{
449442   if (flip)
450443   {
r7498r7499
465458 * The same as snes_draw_tile_4() except
466459 * that it takes a blend parameter.
467460 *****************************************/
461
468462INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend )
469463{
470464   UINT8 mask, plane[4];
r7498r7499
774768 *
775769 * Update an entire line of mode7 tiles.
776770 *********************************************/
771
777772#define MODE7_CLIP(x) (((x) & 0x2000) ? ((x) | ~0x03ff) : ((x) & 0x03ff))
778773
779774static void snes_update_line_mode7( UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline )
r7498r7499
948943 * Update an entire line of sprites.
949944 * FIXME: We need to support high priority bit
950945 *********************************************/
946
951947static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
952948{
953949   INT8 xs, ys;
r7498r7499
10861082 *
10871083 * Update Mode X line.
10881084 *********************************************/
1085
10891086static void snes_update_mode_0( UINT16 curline )
10901087{
10911088#ifdef SNES_LAYER_DEBUG
r7498r7499
12351232 * XOR:  ...###..###...     ###...##...###
12361233 * XNOR: ###...##...###     ...###..###...
12371234 *********************************************/
1238static void snes_update_windowmasks(void)
1235
1236static void snes_update_windowmasks( void )
12391237{
12401238   UINT16 ii, jj;
12411239   INT8 w1, w2;
r7498r7499
13061304 *
13071305 * Update the offsets with the latest changes.
13081306 *********************************************/
1309static void snes_update_offsets(void)
1307
1308static void snes_update_offsets( void )
13101309{
13111310   int ii;
13121311   for (ii = 0; ii < 4; ii++)
r7498r7499
13201319 *
13211320 * Redraw the current line.
13221321 *********************************************/
1322
13231323static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, UINT16 curline )
13241324{
13251325   UINT16 ii;
r7498r7499
13961396
13971397         /* perform color math if the layer wants it (except if it's an object > 192) */
13981398         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);
14001400
14011401         r = ((c & 0x1f) * fade) >> 4;
14021402         g = (((c & 0x3e0) >> 5) * fade) >> 4;
r7498r7499
14121412            scanlines[SNES_SUBSCREEN].buffer[x] = temp_col;
14131413
14141414            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);
14161416
14171417            r = ((c & 0x1f) * fade) >> 4;
14181418            g = (((c & 0x3e0) >> 5) * fade) >> 4;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team