Previous 15994 Revisions Next

r7526 Sunday 7th March, 2010 at 01:55:02 UTC by Fabio Priuli
[SNES] Fixed scrolling problems
[src/mame/video]snes.c

src/mame/video/snes.c
r7525r7526
287287
288288      if (!hires)
289289      {
290         if (scanlines[SNES_MAINSCREEN].enable)
290         if (ii >= 0 && ii < (SNES_SCR_WIDTH << hires) && scanlines[SNES_MAINSCREEN].enable)
291291         {
292            UINT8 clr = colour;
292            if (scanlines[SNES_MAINSCREEN].priority[ii] <= priority)
293            {
294               UINT8 clr = colour;
293295
294296#ifdef SNES_LAYER_DEBUG
295            if (!debug_options.windows_disabled)
297               if (!debug_options.windows_disabled)
296298#endif /* SNES_LAYER_DEBUG */
297            /* Clip to windows */
298            if (scanlines[SNES_MAINSCREEN].clip)
299               clr &= snes_ppu.clipmasks[layer][ii];
299               /* Clip to windows */
300               if (scanlines[SNES_MAINSCREEN].clip)
301                  clr &= snes_ppu.clipmasks[layer][ii];
300302
301303            /* Only draw if we have a colour (0 == transparent) */
302            if (clr)
303            {
304               if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0))
304               if (clr)
305305               {
306306                  if (direct_colors)
307307                  {
r7525r7526
336336            }
337337         }
338338
339         if (scanlines[SNES_SUBSCREEN].enable)
339         if (ii >= 0 && ii < (SNES_SCR_WIDTH << hires) && scanlines[SNES_SUBSCREEN].enable)
340340         {
341            UINT8 clr = colour;
341            if (scanlines[SNES_SUBSCREEN].priority[ii] <= priority)
342            {
343               UINT8 clr = colour;
342344
343345#ifdef SNES_LAYER_DEBUG
344            if (!debug_options.windows_disabled)
346               if (!debug_options.windows_disabled)
345347#endif /* SNES_LAYER_DEBUG */
346            /* Clip to windows */
347            if (scanlines[SNES_SUBSCREEN].clip)
348               clr &= snes_ppu.clipmasks[layer][ii];
348               /* Clip to windows */
349               if (scanlines[SNES_SUBSCREEN].clip)
350                  clr &= snes_ppu.clipmasks[layer][ii];
349351
350            /* Only draw if we have a colour (0 == transparent) */
351            if (clr)
352            {
353               if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0))
352               /* Only draw if we have a colour (0 == transparent) */
353               if (clr)
354354               {
355355                  if (direct_colors)
356356                  {
r7525r7526
387387      }
388388      else /* hires */
389389      {
390         if (ii >= 0 && (ii & 1) && scanlines[SNES_MAINSCREEN].enable)
390         if (ii >= 0 && ii < (SNES_SCR_WIDTH << hires) && (ii & 1) && scanlines[SNES_MAINSCREEN].enable)
391391         {
392            if ((scanlines[SNES_MAINSCREEN].priority[ii >> 1] <= priority))
392            if (scanlines[SNES_MAINSCREEN].priority[ii >> 1] <= priority)
393393            {
394394               UINT8 clr = colour;
395395
r7525r7526
435435            }
436436         }
437437
438         if (ii >= 0 && !(ii & 1) && scanlines[SNES_SUBSCREEN].enable)
438         if (ii >= 0 && ii < (SNES_SCR_WIDTH << hires) && !(ii & 1) && scanlines[SNES_SUBSCREEN].enable)
439439         {
440            if ((scanlines[SNES_SUBSCREEN].priority[ii >> 1] <= priority))
440            if (scanlines[SNES_SUBSCREEN].priority[ii >> 1] <= priority)
441441            {
442442               UINT8 clr = colour;
443443
r7525r7526
480480                     scanlines[SNES_SUBSCREEN].layer[ii >> 1] = layer;
481481                  }
482482               }
483            }
483            }   
484484         }
485485      }
486486   }
r7525r7526
636636   UINT32 tmap, tile, xoff, yoff;
637637   UINT32 charaddr;
638638   UINT16 ii = 0, vflip, hflip, pal, pal_direct;
639   INT8 tile_line;
639   INT8 yscroll;
640   UINT8 xscroll;
640641   UINT8 priority;
641642   UINT32 addr;
642643   UINT16 tilemap;
r7525r7526
676677   xoff = snes_ppu.layer[layer].hoffs;
677678   yoff = snes_ppu.layer[layer].voffs;
678679
680   xscroll = xoff & ((1 << (3 + tile_size)) - 1);
681
679682   /* Jump to base map address */
680683   tmap = snes_ppu.layer[layer].tilemap << 9;
681684   charaddr = snes_ppu.layer[layer].charmap << 13;
682685
683   while (ii < 256)
686   while (ii < 256 + (8 << tile_size))
684687   {
685688      // determine the horizontal position (Bishojo Janshi Suchi Pai & Desert Figther have tile_size & hires == 1)
686689      UINT32 xpos = xoff + (ii << (tile_size * hires));
r7525r7526
749752      }
750753
751754      /* figure out which line to draw */
752      tile_line = ypos & ((8 << tile_size) - 1);
755      yscroll = ypos & ((8 << tile_size) - 1);
753756
754      if (tile_line > ((8 << tile_size) - 1))   /* scrolled into the next tile */
755         tile_line -= (8 << tile_size);
757      if (yscroll > ((8 << tile_size) - 1))   /* scrolled into the next tile */
758         yscroll -= (8 << tile_size);
756759
757760      if (vflip)
758761      {
759762         if (tile_size)
760763         {
761            if (tile_line > 7)
764            if (yscroll > 7)
762765            {
763               tile_line -= 8;
766               yscroll -= 8;
764767            }
765768            else
766769            {
767770               tile += 32 / tile_divider;
768771            }
769772         }
770         tile_line = -tile_line + 7;
773         yscroll = -yscroll + 7;
771774      }
772775      else
773776      {
774         if (tile_line > 7)
777         if (yscroll > 7)
775778         {
776779            tile += 32 / tile_divider;
777            tile_line -= 8;
780            yscroll -= 8;
778781         }
779782      }
780      tile_line <<= 1;
783      yscroll <<= 1;
781784
782785      /* below, only color_planes depends on color_depth */
783786      if (hires)   /* Hi-Res: 2bpp & 4bpp */
784787      {
785         snes_draw_tile_x2(color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ii * 2, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires);
788         snes_draw_tile_x2(color_planes, layer, charaddr + (tile  * 8 * color_planes) + yscroll, (ii - xscroll) * 2, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires);
786789         ii += 8;
787790      }
788791      else   /* tile_size = 0 */
789792      {
790793         if (tile_size)
791794         {
792            snes_draw_tile_x2(color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ii, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires);
795            snes_draw_tile_x2(color_planes, layer, charaddr + (tile  * 8 * color_planes) + yscroll, ii - xscroll, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires);
793796            ii += 16;
794797         }
795798         else   /* No Hi-Res: 2bpp, 4bpp & 8bpp */
796799         {
797            snes_draw_tile(color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ii, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires);
800            snes_draw_tile(color_planes, layer, charaddr + (tile  * 8 * color_planes) + yscroll, ii - xscroll, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires);
798801            ii += 8;
799802         }
800803      }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team