Previous 15994 Revisions Next

r5380 Sunday 9th August, 2009 at 06:11:01 UTC by Fabio Priuli
[SNES]
* merged OAM functions,
* fixed a small bit in Mode 7 math,
* added a few elements to PPU struct (this might be handy if we ever come to convert SNES PPU to a device)
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mame/video]snes.c

src/mame/machine/snes.c
r5379r5380
738738         snes_ppu.update_offsets = 1;
739739         break;
740740      case MOSAIC:   /* Size and screen designation for mosaic */
741         /* FIXME: We don't support horizontal mosaic yet */
741         /* FIXME: We support horizontal mosaic only partially */
742742         snes_ppu.mosaic_size = (data & 0xf0) >> 4;
743743         snes_ppu.layer[0].mosaic_enabled = data & 0x01;
744744         snes_ppu.layer[1].mosaic_enabled = data & 0x02;
r5379r5380
939939         break;
940940      case TM:      /* Main screen designation */
941941      case TS:      /* Subscreen designation */
942         break;
942943      case TMW:      /* Window mask for main screen designation */
944         snes_ppu.layer[0].main_window_enabled = data & 0x01;
945         snes_ppu.layer[1].main_window_enabled = data & 0x02;
946         snes_ppu.layer[2].main_window_enabled = data & 0x04;
947         snes_ppu.layer[3].main_window_enabled = data & 0x08;
948         snes_ppu.layer[4].main_window_enabled = data & 0x10;
949         break;
943950      case TSW:      /* Window mask for subscreen designation */
951         snes_ppu.layer[0].sub_window_enabled = data & 0x01;
952         snes_ppu.layer[1].sub_window_enabled = data & 0x02;
953         snes_ppu.layer[2].sub_window_enabled = data & 0x04;
954         snes_ppu.layer[3].sub_window_enabled = data & 0x08;
955         snes_ppu.layer[4].sub_window_enabled = data & 0x10;
944956         break;
945957      case CGWSEL:   /* Initial settings for Fixed colour addition or screen addition */
946958         /* FIXME: We don't support direct select for modes 3 & 4 or subscreen window stuff */
r5379r5380
10211033            // external latch
10221034            snes_latch_counters(space->machine);
10231035         }
1036         break;
10241037      case WRMPYA:   /* Multiplier A */
10251038         break;
10261039      case WRMPYB:   /* Multiplier B */
src/mame/includes/snes.h
r5379r5380
423423      UINT8 map_size;
424424      UINT8 tile_size;
425425      UINT8 mosaic_enabled;   // actually used only for layers 0->3!
426      UINT8 main_window_enabled;
427      UINT8 sub_window_enabled;
426428      struct
427429      {
428430         UINT16 horizontal;
src/mame/video/snes.c
r5379r5380
228228 *****************************************/
229229INLINE void snes_draw_tile(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal )
230230{
231   UINT8 mask, plane[8];
231   UINT8 mask, plane[8], window_enabled = 0;
232232   UINT16 c;
233233   INT16 ii, jj;
234234
r5379r5380
265265      if(!debug_options.windows_disabled)
266266#endif /* MAME_DEBUG */
267267      /* Clip to windows */
268      if ((screen == MAINSCREEN && (snes_ram[TMW] & (0x1 << layer))) || (screen == SUBSCREEN && (snes_ram[TSW] & (0x1 << layer))))
268      window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled;
269      if (window_enabled)
269270         colour &= snes_ppu.clipmasks[layer][ii];
270271
271272      /* Only draw if we have a colour (0 == transparent) */
r5379r5380
324325 * The same as snes_draw_tile_4() except
325326 * that it takes a blend parameter.
326327 *****************************************/
327INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend )
328INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend, UINT8 wide )
328329{
329   UINT8 mask, plane[4];
330   UINT8 mask, plane[4], window_enabled = 0;
330331   UINT16 c;
331332   INT16 ii;
333   UINT8 x_shift = wide ? 1 : 0;
334   UINT8 size = wide ? 16 : 8;
335   UINT8 step = wide ? 1 : 0;
332336
333337   plane[0] = snes_vram[tileaddr];
334338   plane[1] = snes_vram[tileaddr + 1];
335339   plane[2] = snes_vram[tileaddr + 16];
336340   plane[3] = snes_vram[tileaddr + 17];
337341
338   if( flip )
339      mask = 0x1;
342   if (flip)
343      mask = 0x01;
340344   else
341345      mask = 0x80;
342346
343   for( ii = x; ii < (x + 8); ii++ )
347   x <<= x_shift;
348   for (ii = x; ii < (x + size); ii += 1 + step)
344349   {
345350      UINT8 colour;
346      if( flip )
351      if (flip)
347352      {
348353         colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) |
349354                (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0);
r5379r5380
357362      }
358363
359364#ifdef MAME_DEBUG
360      if( !debug_options.windows_disabled )
365      if (!debug_options.windows_disabled)
361366#endif /* MAME_DEBUG */
362367      /* Clip to windows */
363      if( (screen == MAINSCREEN && (snes_ram[TMW] & 0x10)) || (screen == SUBSCREEN && (snes_ram[TSW] & 0x10)))
368      window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[4].sub_window_enabled;
369      if (window_enabled)
364370         colour &= snes_ppu.clipmasks[4][ii];
365371
366372      /* Only draw if we have a colour (0 == transparent) */
367      if( colour )
373      if (colour)
368374      {
369         if( ii >= 0 )
375         if (ii >= 0)
370376         {
371377            c = snes_cgram[pal + colour];
372            if( blend && screen == MAINSCREEN )   /* Only blend main screens */
378            if (blend && screen == MAINSCREEN)   /* Only blend main screens */
373379               snes_draw_blend(ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4);
374380
375381            scanlines[screen].buffer[ii] = c;
376382            scanlines[screen].zbuf[ii] = priority;
383            if (wide)
384            {
385               scanlines[screen].buffer[ii + 1] = c;
386               scanlines[screen].zbuf[ii + 1] = priority;
387            }
377388         }
378389      }
379390   }
380391}
381392
382/*****************************************
383 * snes_draw_tile_object_w()
384 *
385 * Draw tiles with 4 bit planes(16 colors)
386 * The same as snes_draw_tile_4() except
387 * that it takes a blend parameter.
388 * Wide version.
389 *****************************************/
390INLINE void snes_draw_tile_object_w(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend )
391{
392   UINT8 mask, plane[4];
393   UINT16 c;
394   INT16 ii;
395
396   plane[0] = snes_vram[tileaddr];
397   plane[1] = snes_vram[tileaddr + 1];
398   plane[2] = snes_vram[tileaddr + 16];
399   plane[3] = snes_vram[tileaddr + 17];
400
401   if( flip )
402      mask = 0x1;
403   else
404      mask = 0x80;
405
406   x <<= 1;
407   for( ii = x; ii < (x + 16); ii += 2 )
408   {
409      UINT8 colour;
410      if( flip )
411      {
412         colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) |
413                (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0);
414         mask <<= 1;
415      }
416      else
417      {
418         colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) |
419                (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0);
420         mask >>= 1;
421      }
422
423#ifdef MAME_DEBUG
424      if( !debug_options.windows_disabled )
425#endif /* MAME_DEBUG */
426      /* Clip to windows */
427      if( (screen == MAINSCREEN && (snes_ram[TMW] & 0x10)) || (screen == SUBSCREEN && (snes_ram[TSW] & 0x10)))
428         colour &= snes_ppu.clipmasks[4][ii];
429
430      /* Only draw if we have a colour (0 == transparent) */
431      if( colour )
432      {
433         if( ii >= 0 )
434         {
435            c = snes_cgram[pal + colour];
436            if( blend && screen == MAINSCREEN )   /* Only blend main screens */
437               snes_draw_blend(ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4);
438
439            scanlines[screen].buffer[ii] = c;
440            scanlines[screen].zbuf[ii] = priority;
441            scanlines[screen].buffer[ii + 1] = c;
442            scanlines[screen].zbuf[ii + 1] = priority;
443         }
444      }
445   }
446}
447
448393/*********************************************
449394 * snes_update_line()
450395 *
r5379r5380
741686         UINT16 clr;
742687         /* Direct select, but only outside EXTBG! */
743688         if (snes_ppu.direct_color && layer == 1)
744            clr = ((colour & 0x7) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
689            clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
745690         else
746691            clr = snes_cgram[colour];
747692         /* Only blend main screens */
r5379r5380
846791               if( (x + (count << 3) < SNES_SCR_WIDTH + 8) )
847792               {
848793                  if( widemode )
849                     snes_draw_tile_object_w(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend );
794                     snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1);
850795                  else
851                     snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend );
796                     snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0);
852797               }
853798               time_over++;   /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
854799            }
r5379r5380
860805               if( (x + (xs << 3) < SNES_SCR_WIDTH + 8) )
861806               {
862807                  if( widemode )
863                     snes_draw_tile_object_w(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend );
808                     snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1);
864809                  else
865                     snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend );
810                     snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0);
866811               }
867812               time_over++;   /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
868813            }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team