Previous 15994 Revisions Next

r7513 Friday 5th March, 2010 at 17:12:14 UTC by Fabio Priuli
[SNES] minor fixes and cleanups
[src/mame/includes]snes.h
[src/mame/video]snes.c

src/mame/includes/snes.h
r7512r7513
536536   UINT8 window1_left, window1_right, window2_left, window2_right;
537537
538538   UINT16 mosaic_table[16][4096];
539   UINT8 clipmasks[6][SNES_SCR_WIDTH + 8];
539   UINT8 clipmasks[6][SNES_SCR_WIDTH];
540540   UINT8 update_windows;
541541   UINT8 update_offsets;
542542   UINT8 mode;
src/mame/video/snes.c
r7512r7513
113113{
114114   int enable, clip;
115115
116   UINT16 buffer[(SNES_SCR_WIDTH * 2)];
117   UINT8  priority[(SNES_SCR_WIDTH * 2)];
118   UINT8  layer[(SNES_SCR_WIDTH * 2)];
119   UINT8  blend_exception[(SNES_SCR_WIDTH * 2)];
116   UINT16 buffer[SNES_SCR_WIDTH];
117   UINT8  priority[SNES_SCR_WIDTH];
118   UINT8  layer[SNES_SCR_WIDTH];
119   UINT8  blend_exception[SNES_SCR_WIDTH];
120120};
121121
122122static struct SCANLINE scanlines[2];
r7512r7513
158158
159159      if (snes_ppu.sub_add_mode) /* SNES_SUBSCREEN*/
160160      {
161         if ((snes_ppu.color_modes & 0x80) == 0x00)
161         if (!BIT(snes_ppu.color_modes, 7)
162162         {
163            /* add */
163            /* 0x00 add */
164164            r = (*colour & 0x1f) + (scanlines[SNES_SUBSCREEN].buffer[offset] & 0x1f);
165165            g = ((*colour & 0x3e0) >> 5) + ((scanlines[SNES_SUBSCREEN].buffer[offset] & 0x3e0) >> 5);
166166            b = ((*colour & 0x7c00) >> 10) + ((scanlines[SNES_SUBSCREEN].buffer[offset] & 0x7c00) >> 10);
r7512r7513
177177            if (b > 0x1f) b = 0;
178178         }
179179         /* only halve if the color is not the back colour */
180         if ((snes_ppu.color_modes & 0x40) && (scanlines[SNES_SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]))
180         if (BIT(snes_ppu.color_modes, 6) && (scanlines[SNES_SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]))
181181         {
182182            r >>= 1;
183183            g >>= 1;
r7512r7513
186186      }
187187      else /* Fixed colour */
188188      {
189         if ((snes_ppu.color_modes & 0x80) == 0x00)
189         if (!BIT(snes_ppu.color_modes, 7)
190190         {
191            /* add */
191            /* 0x00 add */
192192            r = (*colour & 0x1f) + (snes_cgram[FIXED_COLOUR] & 0x1f);
193193            g = ((*colour & 0x3e0) >> 5) + ((snes_cgram[FIXED_COLOUR] & 0x3e0) >> 5);
194194            b = ((*colour & 0x7c00) >> 10) + ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10);
r7512r7513
205205            if (b > 0x1f) b = 0;
206206         }
207207         /* halve if necessary */
208         if (snes_ppu.color_modes & 0x40)
208         if (BIT(snes_ppu.color_modes, 6))
209209         {
210210            r >>= 1;
211211            g >>= 1;
r7512r7513
271271      {
272272         if (scanlines[SNES_MAINSCREEN].enable)
273273         {
274            UINT8 clr = colour;
274275
275276#ifdef SNES_LAYER_DEBUG
276277            if (!debug_options.windows_disabled)
277278#endif /* SNES_LAYER_DEBUG */
278279            /* Clip to windows */
279280            if (scanlines[SNES_MAINSCREEN].clip)
280               colour &= snes_ppu.clipmasks[layer][ii];
281               clr &= snes_ppu.clipmasks[layer][ii];
281282
282283            /* Only draw if we have a colour (0 == transparent) */
283            if (colour)
284            if (clr)
284285            {
285286               if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0))
286287               {
287288                  if (direct_colors)
288289                  {
289290                     /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
290                     c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
291                     c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
291292                     c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
292293                  }
293294                  else
294                     c = snes_cgram[pal + colour];
295                     c = snes_cgram[pal + clr];
295296
296297                  if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic
297298                  {
r7512r7513
319320
320321         if (scanlines[SNES_SUBSCREEN].enable)
321322         {
323            UINT8 clr = colour;
324
322325#ifdef SNES_LAYER_DEBUG
323326            if (!debug_options.windows_disabled)
324327#endif /* SNES_LAYER_DEBUG */
325328            /* Clip to windows */
326329            if (scanlines[SNES_SUBSCREEN].clip)
327               colour &= snes_ppu.clipmasks[layer][ii];
330               clr &= snes_ppu.clipmasks[layer][ii];
328331
329332            /* Only draw if we have a colour (0 == transparent) */
330            if (colour)
333            if (clr)
331334            {
332335               if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0))
333336               {
334337                  if (direct_colors)
335338                  {
336339                     /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
337                     c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
340                     c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
338341                     c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
339342                  }
340343                  else
341                     c = snes_cgram[pal + colour];
344                     c = snes_cgram[pal + clr];
342345
343346                  if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic
344347                  {
r7512r7513
364367            }
365368         }
366369      }
367
368370      else /* hires */
369371      {
372         if (ii >= 0 && (ii & 1) && scanlines[SNES_MAINSCREEN].enable)
373         {
374            if ((scanlines[SNES_MAINSCREEN].priority[ii >> 1] <= priority))
375            {
376               UINT8 clr = colour;
377
370378#ifdef SNES_LAYER_DEBUG
371         if (!debug_options.windows_disabled)
379               if (!debug_options.windows_disabled)
372380#endif /* SNES_LAYER_DEBUG */
373         /* Clip to windows */
374         if (scanlines[SNES_MAINSCREEN].clip)
375            colour &= snes_ppu.clipmasks[layer][ii >> hires];
381               /* Clip to windows */
382               if (scanlines[SNES_MAINSCREEN].clip)
383                  clr &= snes_ppu.clipmasks[layer][ii >> 1];
376384
377         /* Only draw if we have a colour (0 == transparent) */
378         if (colour)
379         {
380            if ((scanlines[SNES_MAINSCREEN].priority[ii >> hires] <= priority) && (ii >= 0))
381            {
382               if (direct_colors)
385               /* Only draw if we have a colour (0 == transparent) */
386               if (clr)
383387               {
384                  /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
385                  c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
386                  c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
387               }
388               else
389                  c = snes_cgram[pal + colour];
388                  if (direct_colors)
389                  {
390                     /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
391                     c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
392                     c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
393                  }
394                  else
395                     c = snes_cgram[pal + clr];
390396
391               if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
392               {
393                  int x_mos;
397                  if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
398                  {
399                     int x_mos;
394400
395                  //TODO: 512 modes has the h values doubled.
396                  for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
397                  {
398                     if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable)
401                     //TODO: 512 modes has the h values doubled.
402                     for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
399403                     {
400404                        scanlines[SNES_MAINSCREEN].buffer[(ii + x_mos) >> 1] = c;
401405                        scanlines[SNES_MAINSCREEN].priority[(ii + x_mos) >> 1] = priority;
402406                        scanlines[SNES_MAINSCREEN].layer[(ii + x_mos) >> 1] = layer;
403407                     }
404                     else if (scanlines[SNES_SUBSCREEN].enable)
408                     ii += x_mos - 1;
409                  }
410                  else
411                  {
412                     scanlines[SNES_MAINSCREEN].buffer[ii >> 1] = c;
413                     scanlines[SNES_MAINSCREEN].priority[ii >> 1] = priority;
414                     scanlines[SNES_MAINSCREEN].layer[ii >> 1] = layer;
415                  }
416               }
417            }
418         }
419
420         if (ii >= 0 && !(ii & 1) && scanlines[SNES_SUBSCREEN].enable)
421         {
422            if ((scanlines[SNES_SUBSCREEN].priority[ii >> 1] <= priority))
423            {
424               UINT8 clr = colour;
425
426#ifdef SNES_LAYER_DEBUG
427               if (!debug_options.windows_disabled)
428#endif /* SNES_LAYER_DEBUG */
429               /* Clip to windows */
430               if (scanlines[SNES_SUBSCREEN].clip)
431                  clr &= snes_ppu.clipmasks[layer][ii >> 1];
432
433               /* Only draw if we have a colour (0 == transparent) */
434               if (clr)
435               {
436                  if (direct_colors)
437                  {
438                     /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
439                     c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
440                     c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
441                  }
442                  else
443                     c = snes_cgram[pal + clr];
444
445                  if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
446                  {
447                     int x_mos;
448
449                     //TODO: 512 modes has the h values doubled.
450                     for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
405451                     {
406452                        scanlines[SNES_SUBSCREEN].buffer[(ii + x_mos) >> 1] = c;
407453                        scanlines[SNES_SUBSCREEN].priority[(ii + x_mos) >> 1] = priority;
408454                        scanlines[SNES_SUBSCREEN].layer[(ii + x_mos) >> 1] = layer;
409455                     }
456                     ii += x_mos - 1;
410457                  }
411                  ii += x_mos - 1;
412               }
413               else
414               {
415                  if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable)
458                  else
416459                  {
417                     scanlines[SNES_MAINSCREEN].buffer[ii >> 1] = c;
418                     scanlines[SNES_MAINSCREEN].priority[ii >> 1] = priority;
419                     scanlines[SNES_MAINSCREEN].layer[ii >> 1] = layer;
420                  }
421                  else if (scanlines[SNES_SUBSCREEN].enable)
422                  {
423460                     scanlines[SNES_SUBSCREEN].buffer[ii >> 1] = c;
424461                     scanlines[SNES_SUBSCREEN].priority[ii >> 1] = priority;
425462                     scanlines[SNES_SUBSCREEN].layer[ii >> 1] = layer;
r7512r7513
463500{
464501   UINT8 mask, plane[4];
465502   UINT16 c;
466   INT16 ii;
503   INT16 ii, jj;
467504
468505   plane[0] = snes_vram[tileaddr];
469506   plane[1] = snes_vram[tileaddr + 1];
r7512r7513
477514
478515   for (ii = x; ii < (x + 8); ii++)
479516   {
480      UINT8 colour;
517      UINT8 colour = 0;
481518      if (flip)
482519      {
483         colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) |
484                (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0);
520         for (jj = 0; jj < 4; jj++)
521            colour |= plane[jj] & mask ? (1 << jj) : 0;
522
485523         mask <<= 1;
486524      }
487525      else
488526      {
489         colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) |
490                (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0);
527         for (jj = 0; jj < 4; jj++)
528            colour |= plane[jj] & mask ? (1 << jj) : 0;
529
491530         mask >>= 1;
492531      }
493532
494533      if (scanlines[SNES_MAINSCREEN].enable)
495534      {
535         UINT8 clr = colour;
496536
497537#ifdef SNES_LAYER_DEBUG
498538         if (!debug_options.windows_disabled)
499539#endif /* SNES_LAYER_DEBUG */
500540         /* Clip to windows */
501541         if (scanlines[SNES_MAINSCREEN].clip)
502            colour &= snes_ppu.clipmasks[SNES_OAM][ii];
542            clr &= snes_ppu.clipmasks[SNES_OAM][ii];
503543
504544         /* Only draw if we have a colour (0 == transparent) */
505         if (colour)
545         if (clr)
506546         {
507547            if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0))
508548            {
509               c = snes_cgram[pal + colour];
549               c = snes_cgram[pal + clr];
510550
511551               scanlines[SNES_MAINSCREEN].buffer[ii] = c;
512552               scanlines[SNES_MAINSCREEN].priority[ii] = priority;
r7512r7513
518558
519559      if (scanlines[SNES_SUBSCREEN].enable)
520560      {
561         UINT8 clr = colour;
521562
522563#ifdef SNES_LAYER_DEBUG
523564         if (!debug_options.windows_disabled)
524565#endif /* SNES_LAYER_DEBUG */
525566         /* Clip to windows */
526567         if (scanlines[SNES_SUBSCREEN].clip)
527            colour &= snes_ppu.clipmasks[SNES_OAM][ii];
568            clr &= snes_ppu.clipmasks[SNES_OAM][ii];
528569
529570         /* Only draw if we have a colour (0 == transparent) */
530         if (colour)
571         if (clr)
531572         {
532573            if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0))
533574            {
534               c = snes_cgram[pal + colour];
575               c = snes_cgram[pal + clr];
535576
536577               scanlines[SNES_SUBSCREEN].buffer[ii] = c;
537578               scanlines[SNES_SUBSCREEN].priority[ii] = priority;
r7512r7513
544585}
545586
546587/*********************************************
547 * snes_update_line()
588 * snes_get_tmap_addr()
548589 *
549 * Update an entire line of tiles.
590 * Find the address in VRAM of the tile (x,y)
550591 *********************************************/
551592
552INLINE UINT32 snes_get_tmap( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y )
593INLINE UINT32 snes_get_tmap_addr( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y )
553594{
554595   UINT32 res = base;
555596   x  >>= (3 + tile_size);
r7512r7513
566607   return res;
567608}
568609
610/*********************************************
611 * snes_update_line()
612 *
613 * Update an entire line of tiles.
614 *********************************************/
615
569616INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors )
570617{
571618   UINT32 tmap, tile, xoff, yoff;
619   UINT32 charaddr;
572620   UINT16 ii = 0, vflip, hflip, pal;
573621   INT8 tile_line;
574622   UINT8 priority;
575623   /* scrolling */
576   UINT32 charaddr;
577   UINT16 vscroll, hscroll;
578624   UINT16 opt_bit = (layer == SNES_BG1) ? 13 : (layer == SNES_BG2) ? 14 : 0;
579625   UINT8 vshift, hshift, tile_size;
580626   /* variables depending on color_depth */
581627   UINT8 color_shift = 0;
582628   UINT8 color_planes = 2;
583629   UINT8 tile_divider = 1;
630   UINT32 addr;
631   UINT16 tilemap;
584632
585633#ifdef SNES_LAYER_DEBUG
586634   if (debug_options.bg_disabled[layer])
r7512r7513
606654   tile_size = snes_ppu.layer[layer].tile_size;
607655
608656   /* Find scroll info */
609   hscroll = (snes_ppu.layer[layer].hoffs & 0x3ff) >> (3 + tile_size);
610   hshift = snes_ppu.layer[layer].hoffs & ((8 << tile_size) - 1);
611   vscroll = ((snes_ppu.layer[layer].voffs & 0x3ff) + curline) >> (3 + tile_size);
612   vshift = ((snes_ppu.layer[layer].voffs & 0x3ff) + curline) & ((8 << tile_size) - 1);
613
614657   xoff = snes_ppu.layer[layer].hoffs;
615658   yoff = snes_ppu.layer[layer].voffs;
659   hshift = xoff & ((8 << tile_size) - 1);
660   vshift = (yoff + curline) & ((8 << tile_size) - 1);
616661
617662   /* figure out which line to draw */
618663   if (vshift > ((8 << tile_size) - 1))   /* scrolled into the next tile */
619   {
620      vscroll++;   /* pretend we scrolled by 1 tile line */
621664      vshift -= (8 << tile_size);
622   }
623   if (vscroll >= 128)
624      vscroll -= 128;
625665
626666   /* Jump to base map address */
627667   tmap = snes_ppu.layer[layer].tilemap << 9;
r7512r7513
649689
650690   while (ii < 256)
651691   {
652      /*
653        Tilemap format
654          vhopppcc cccccccc
655
656          v/h  = Vertical/Horizontal flip this tile.
657          o    = Tile priority.
658          ppp  = Tile palette. The number of entries in the palette depends on the Mode and the BG.
659          cccccccccc = Tile number.
660        */
661
662692      // determine the horizontal position (Bishojo Janshi Suchi Pai & Desert Figther have tile_size & hires == 1)
663693      UINT32 xpos = xoff + (ii << (tile_size * hires));
664694      UINT32 ypos = yoff + curline;
r7512r7513
675705            {
676706            case SNES_OPT_MODE2:
677707            case SNES_OPT_MODE6:
678               haddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff));
679               vaddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff) + 8);
708               haddr = snes_get_tmap_addr(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff));
709               vaddr = snes_get_tmap_addr(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff) + 8);
680710               hval = snes_vram[haddr] | (snes_vram[haddr + 1] << 8);
681711               vval = snes_vram[vaddr] | (snes_vram[vaddr + 1] << 8);
682712               if (BIT(hval, opt_bit))
r7512r7513
685715                  ypos = curline + vval;
686716               break;
687717            case SNES_OPT_MODE4:
688               haddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff));
718               haddr = snes_get_tmap_addr(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff));
689719               hval = snes_vram[haddr] | (snes_vram[haddr + 1] << 8);
690720               if (BIT(hval, opt_bit))
691721               {
r7512r7513
700730         }
701731      }
702732
703      UINT32 addr = snes_get_tmap(layer, tile_size, tmap, xpos, ypos);
704      UINT16 tilemap = snes_vram[addr] | (snes_vram[addr + 1] << 8);
733      addr = snes_get_tmap_addr(layer, tile_size, tmap, xpos, ypos);
734
735      /*
736        Tilemap format
737          vhopppcc cccccccc
738
739          v/h  = Vertical/Horizontal flip this tile.
740          o    = Tile priority.
741          ppp  = Tile palette. The number of entries in the palette depends on the Mode and the BG.
742          cccccccccc = Tile number.
743        */
744      tilemap = snes_vram[addr] | (snes_vram[addr + 1] << 8);
705745      vflip = BIT(tilemap, 15);
706746      hflip = BIT(tilemap, 14);
707747      priority = BIT(tilemap, 13) ? priority_b : priority_a;
r7512r7513
779819   UINT8 priority = priority_a;
780820   UINT8 colour = 0;
781821   UINT16 *mosaic_x, *mosaic_y;
822   UINT16 c;
782823
783824#ifdef SNES_LAYER_DEBUG
784825   if (debug_options.bg_disabled[layer])
r7512r7513
889930
890931      if (scanlines[SNES_MAINSCREEN].enable)
891932      {
933         UINT8 clr = colour;
934
892935         if (scanlines[SNES_MAINSCREEN].clip)
893            colour &= snes_ppu.clipmasks[layer][xpos];
936            clr &= snes_ppu.clipmasks[layer][xpos];
894937
895938         /* Draw pixel if appropriate */
896         if (scanlines[SNES_MAINSCREEN].priority[xpos] <= priority && colour > 0)
939         if (scanlines[SNES_MAINSCREEN].priority[xpos] <= priority && clr > 0)
897940         {
898            UINT16 clr;
899941            /* Direct select, but only outside EXTBG! */
900942            if (snes_ppu.direct_color && layer == 0)
901943            {
902944               /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */
903               clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
945               c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
904946            }
905947            else
906               clr = snes_cgram[colour];
948               c = snes_cgram[clr];
907949
908            scanlines[SNES_MAINSCREEN].buffer[xpos] = clr;
950            scanlines[SNES_MAINSCREEN].buffer[xpos] = c;
909951            scanlines[SNES_MAINSCREEN].priority[xpos] = priority;
910952            scanlines[SNES_MAINSCREEN].layer[xpos] = layer;
911953         }
r7512r7513
913955
914956      if (scanlines[SNES_SUBSCREEN].enable)
915957      {
958         UINT8 clr = colour;
959
916960         if (scanlines[SNES_SUBSCREEN].clip)
917            colour &= snes_ppu.clipmasks[layer][xpos];
961            clr &= snes_ppu.clipmasks[layer][xpos];
918962
919963         /* Draw pixel if appropriate */
920         if (scanlines[SNES_SUBSCREEN].priority[xpos] <= priority && colour > 0)
964         if (scanlines[SNES_SUBSCREEN].priority[xpos] <= priority && clr > 0)
921965         {
922            UINT16 clr;
923966            /* Direct select, but only outside EXTBG! */
924967            if (snes_ppu.direct_color && layer == 0)
925968            {
926969               /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */
927               clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
970               c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
928971            }
929972            else
930               clr = snes_cgram[colour];
973               c = snes_cgram[clr];
931974
932            scanlines[SNES_SUBSCREEN].buffer[xpos] = clr;
975            scanlines[SNES_SUBSCREEN].buffer[xpos] = c;
933976            scanlines[SNES_SUBSCREEN].priority[xpos] = priority;
934977            scanlines[SNES_SUBSCREEN].layer[xpos] = layer;
935978         }
r7512r7513
12401283
12411284   snes_ppu.update_windows = 0;      /* reset the flag */
12421285
1243   for (ii = 0; ii < SNES_SCR_WIDTH + 8; ii++)
1286   for (ii = 0; ii < SNES_SCR_WIDTH; ii++)
12441287   {
12451288      /* update bg 1, 2, 3, 4, obj & color windows */
12461289      /* jj = layer */
r7512r7513
13431386         snes_update_offsets();
13441387
13451388      /* Clear priority */
1346      memset(scanlines[SNES_MAINSCREEN].priority, 0, SNES_SCR_WIDTH * 2);
1347      memset(scanlines[SNES_SUBSCREEN].priority, 0, SNES_SCR_WIDTH * 2);
1389      memset(scanlines[SNES_MAINSCREEN].priority, 0, SNES_SCR_WIDTH);
1390      memset(scanlines[SNES_SUBSCREEN].priority, 0, SNES_SCR_WIDTH);
13481391
13491392      /* Clear layers */
1350      memset(scanlines[SNES_MAINSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH * 2);
1351      memset(scanlines[SNES_SUBSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH * 2);
1393      memset(scanlines[SNES_MAINSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH);
1394      memset(scanlines[SNES_SUBSCREEN].layer, SNES_COLOR, SNES_SCR_WIDTH);
13521395
13531396      /* Clear blend_exception (only used for OAM) */
1354      memset(scanlines[SNES_MAINSCREEN].blend_exception, 0, SNES_SCR_WIDTH * 2);
1355      memset(scanlines[SNES_SUBSCREEN].blend_exception, 0, SNES_SCR_WIDTH * 2);
1397      memset(scanlines[SNES_MAINSCREEN].blend_exception, 0, SNES_SCR_WIDTH);
1398      memset(scanlines[SNES_SUBSCREEN].blend_exception, 0, SNES_SCR_WIDTH);
13561399
13571400      /* Draw back colour */
1358      for (ii = 0; ii < SNES_SCR_WIDTH * 2; ii++)
1401      for (ii = 0; ii < SNES_SCR_WIDTH; ii++)
13591402      {
13601403         if (snes_ppu.mode == 5 || snes_ppu.mode == 6)
13611404            scanlines[SNES_SUBSCREEN].buffer[ii] = snes_cgram[0];
13621405         else
13631406            scanlines[SNES_SUBSCREEN].buffer[ii] = snes_cgram[FIXED_COLOUR];
13641407
1365         /* Draw back colour */
13661408         scanlines[SNES_MAINSCREEN].buffer[ii] = snes_cgram[0];
13671409      }
13681410
r7512r7513
13861428      /* Phew! Draw the line to screen */
13871429      fade = snes_ppu.screen_brightness;
13881430
1389      for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
1431      for (x = 0; x < SNES_SCR_WIDTH; x++)
13901432      {
13911433         int r, g, b, hires;
13921434         UINT16 temp_col;
r7512r7513
14111453            c = scanlines[SNES_SUBSCREEN].buffer[x];
14121454            scanlines[SNES_SUBSCREEN].buffer[x] = temp_col;
14131455
1414            if (!scanlines[SNES_SUBSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1456            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
14151457               snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
14161458
14171459            r = ((c & 0x1f) * fade) >> 4;
r7512r7513
14601502      if (!debug_options.input_count--)
14611503      {
14621504         UINT8 toggles = input_port_read_safe(machine, "DEBUG2", 0);
1463         if (toggles & 0x01)
1505         if (BIT(toggles, 0))
14641506            debug_options.bg_disabled[0] = !debug_options.bg_disabled[0];
1465         if (toggles & 0x02)
1507         if (BIT(toggles, 1))
14661508            debug_options.bg_disabled[1] = !debug_options.bg_disabled[1];
1467         if (toggles & 0x04)
1509         if (BIT(toggles, 2))
14681510            debug_options.bg_disabled[2] = !debug_options.bg_disabled[2];
1469         if (toggles & 0x08)
1511         if (BIT(toggles, 3))
14701512            debug_options.bg_disabled[3] = !debug_options.bg_disabled[3];
1471         if (toggles & 0x10)
1513         if (BIT(toggles, 4))
14721514            debug_options.bg_disabled[4] = !debug_options.bg_disabled[4];
1473         if (toggles & 0x20)
1515         if (BIT(toggles, 5))
14741516            debug_options.draw_subscreen = !debug_options.draw_subscreen;
1475         if (toggles & 0x40)
1517         if (BIT(toggles, 6))
14761518            debug_options.bg_disabled[5] = !debug_options.bg_disabled[5];
1477         if (toggles & 0x80)
1519         if (BIT(toggles, 7))
14781520            debug_options.windows_disabled = !debug_options.windows_disabled;
14791521         toggles = input_port_read_safe(machine, "DEBUG4", 0);
1480         if (toggles & 0x01)
1522         if (BIT(toggles, 0))
14811523            debug_options.mode_disabled[0] = !debug_options.mode_disabled[0];
1482         if (toggles & 0x02)
1524         if (BIT(toggles, 1))
14831525            debug_options.mode_disabled[1] = !debug_options.mode_disabled[1];
1484         if (toggles & 0x04)
1526         if (BIT(toggles, 2))
14851527            debug_options.mode_disabled[2] = !debug_options.mode_disabled[2];
1486         if (toggles & 0x08)
1528         if (BIT(toggles, 3))
14871529            debug_options.mode_disabled[3] = !debug_options.mode_disabled[3];
1488         if (toggles & 0x10)
1530         if (BIT(toggles, 4))
14891531            debug_options.mode_disabled[4] = !debug_options.mode_disabled[4];
1490         if (toggles & 0x20)
1532         if (BIT(toggles, 5))
14911533            debug_options.mode_disabled[5] = !debug_options.mode_disabled[5];
1492         if (toggles & 0x40)
1534         if (BIT(toggles, 6))
14931535            debug_options.mode_disabled[6] = !debug_options.mode_disabled[6];
1494         if (toggles & 0x80)
1536         if (BIT(toggles, 7))
14951537            debug_options.mode_disabled[7] = !debug_options.mode_disabled[7];
14961538         toggles = input_port_read_safe(machine, "DEBUG3", 0);
14971539         if (toggles & 0x4)
14981540            debug_options.transparency_disabled = !debug_options.transparency_disabled;
14991541         debug_options.input_count = 5;
15001542      }
1501      /* Display some debug info on the screen */
1543
15021544      logerror("%s%s", debug_options.windows_disabled?" ":"W", debug_options.transparency_disabled?" ":"T" );
1503      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15041545      logerror("%s1 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
15051546            debug_options.bg_disabled[0]?" ":"*",
15061547            (snes_ram[TM] & 0x1)?"M":" ",
r7512r7513
15161557            snes_ram[BG1SC] & 0x3,
15171558            (snes_ram[BG1SC] & 0xfc) << 9,
15181559            snes_ppu.layer[SNES_BG1].charmap << 13);
1519      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15201560      logerror("%s2 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
15211561            debug_options.bg_disabled[1]?" ":"*",
15221562            (snes_ram[TM] & 0x2)?"M":" ",
r7512r7513
15321572            snes_ram[BG2SC] & 0x3,
15331573            (snes_ram[BG2SC] & 0xfc) << 9,
15341574            snes_ppu.layer[SNES_BG2].charmap << 13);
1535      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15361575      logerror("%s3 %s%s%s%s%s%c%s%s%d%s%s%d %4X %4X",
15371576            debug_options.bg_disabled[2]?" ":"*",
15381577            (snes_ram[TM] & 0x4)?"M":" ",
r7512r7513
15491588            snes_ram[BG3SC] & 0x3,
15501589            (snes_ram[BG3SC] & 0xfc) << 9,
15511590            snes_ppu.layer[SNES_BG3].charmap << 13);
1552      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15531591      logerror("%s4 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
15541592            debug_options.bg_disabled[3]?" ":"*",
15551593            (snes_ram[TM] & 0x8)?"M":" ",
r7512r7513
15651603            snes_ram[BG4SC] & 0x3,
15661604            (snes_ram[BG4SC] & 0xfc) << 9,
15671605            snes_ppu.layer[SNES_BG4].charmap << 13 );
1568      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15691606      logerror("%sO %s%s%s%s%s%c%s%s%d%d       %4X",
15701607            debug_options.bg_disabled[4]?" ":"*",
15711608            (snes_ram[TM] & 0x10)?"M":" ",
r7512r7513
15781615            (snes_ram[WOBJSEL] & 0x8)?((snes_ram[WOBJSEL] & 0x4)?"o":"i"):" ",
15791616            snes_ppu.oam.size[0], snes_ppu.oam.size[1],
15801617            snes_ppu.layer[SNES_OAM].charmap << 13 );
1581      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15821618      logerror("%sB   %s  %c%s%s",
15831619            debug_options.bg_disabled[5]?" ":"*",
15841620            (snes_ram[CGADSUB] & 0x20)?"B":" ",
15851621            WINLOGIC[(snes_ram[WOBJLOG] & 0xc)>>2],
15861622            (snes_ram[WOBJSEL] & 0x20)?((snes_ram[WOBJSEL] & 0x10)?"o":"i"):" ",
15871623            (snes_ram[WOBJSEL] & 0x80)?((snes_ram[WOBJSEL] & 0x40)?"o":"i"):" " );
1588      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15891624      logerror("1) %3d %3d   2) %3d %3d", (snes_ppu.bgd_offset.horizontal[0] & 0x3ff) >> 3, (snes_ppu.bgd_offset.vertical[0] & 0x3ff) >> 3, (snes_ppu.bgd_offset.horizontal[1] & 0x3ff) >> 3, (snes_ppu.bgd_offset.vertical[1] & 0x3ff) >> 3 );
1590      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15911625      logerror("3) %3d %3d   4) %3d %3d", (snes_ppu.bgd_offset.horizontal[2] & 0x3ff) >> 3, (snes_ppu.bgd_offset.vertical[2] & 0x3ff) >> 3, (snes_ppu.bgd_offset.horizontal[3] & 0x3ff) >> 3, (snes_ppu.bgd_offset.vertical[3] & 0x3ff) >> 3 );
1592      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15931626      logerror("Flags: %s%s%s %s %2d", (snes_ram[CGWSEL] & 0x2)?"S":"F", (snes_ram[CGADSUB] & 0x80)?"-":"+", (snes_ram[CGADSUB] & 0x40)?" 50%":"100%",(snes_ram[CGWSEL] & 0x1)?"D":"P", (snes_ram[MOSAIC] & 0xf0) >> 4 );
1594      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15951627      logerror("SetINI: %s %s %s %s %s %s", (snes_ram[SETINI] & 0x1)?" I":"NI", (snes_ram[SETINI] & 0x2)?"P":"R", (snes_ram[SETINI] & 0x4)?"240":"225",(snes_ram[SETINI] & 0x8)?"512":"256",(snes_ram[SETINI] & 0x40)?"E":"N",(snes_ram[SETINI] & 0x80)?"ES":"NS" );
1596      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15971628      logerror("Mode7: A %5d B %5d", snes_ppu.mode7.matrix_a, snes_ppu.mode7.matrix_b );
1598      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
15991629      logerror(" %s%s%s   C %5d D %5d", (snes_ram[M7SEL] & 0xc0)?((snes_ram[M7SEL] & 0x40)?"0":"C"):"R", (snes_ram[M7SEL] & 0x1)?"H":" ", (snes_ram[M7SEL] & 0x2)?"V":" ", snes_ppu.mode7.matrix_c, snes_ppu.mode7.matrix_d );
1600      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
16011630      logerror("       X %5d Y %5d", snes_ppu.mode7.origin_x, snes_ppu.mode7.origin_y );
1602      //ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
16031631   }
16041632
16051633   return 0;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team