Previous 15994 Revisions Next

r7582 Tuesday 16th March, 2010 at 08:23:38 UTC by Fabio Priuli
[SNES] improved sprite overlap (see Super Bomberman 5 leftmost sprite in the titlescreen), simplified oam address handling, fixed sprite blend exception
[src/mame/machine]snes.c
[src/mame/video]snes.c

src/mame/machine/snes.c
r7581r7582
461461            if (snes_ram[OAMDATA] == 0)
462462            {
463463               snes_ppu.oam.address++;
464               snes_ppu.oam.address_low = snes_ram[OAMADDL] = snes_ppu.oam.address & 0xff;
465               snes_ppu.oam.address_high = snes_ram[OAMADDH] = (snes_ppu.oam.address >> 8) & 0x1;
464               snes_ppu.oam.address &= 0x1ff;
466465               snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0;
467466            }
468467            return snes_ppu.ppu1_open_bus;
r7581r7582
687686
688687#ifndef MESS
689688      case 0x4100:      /* NSS Dip-Switches */
690#ifdef MAME_DEBUG
691         return input_port_read_safe(space->machine, "DEBUG1", 0);
692#else
693689         return input_port_read(space->machine, "DSW");
694#endif   /* MAME_DEBUG */
695690//      case 0x4101: //PC: a104 - a10e - a12a   //only nss_actr
696691//      case 0x420c: //PC: 9c7d - 8fab          //only nss_ssoc
697692
r7581r7582
705700
706701   /* Unsupported reads returns open bus */
707702//  printf("%02x %02x\n",offset,snes_open_bus_r(space,0));
708   return snes_open_bus_r(space,0);
703   return snes_open_bus_r(space, 0);
709704}
710705
711706/*
r7581r7582
818813            break;
819814         }
820815      case OAMADDL:   /* Address for accessing OAM (low) */
821         snes_ppu.oam.address_low = data;
822816         snes_ppu.oam.saved_address_low = data;
823         snes_ppu.oam.address = ((snes_ppu.oam.address_high & 0x1) << 8) + data;
817         snes_ppu.oam.address = (snes_ppu.oam.address & 0xff00) + data;
824818         snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0;
825819         snes_ram[OAMDATA] = 0;
826820         break;
827821      case OAMADDH:   /* Address for accessing OAM (high) */
828         snes_ppu.oam.address_high = data & 0x1;
829822         snes_ppu.oam.saved_address_high = data;
830         snes_ppu.oam.address = ((data & 0x1) << 8) + snes_ppu.oam.address_low;
823         snes_ppu.oam.address = (snes_ppu.oam.address & 0x00ff) | ((data & 0x01) << 8);
831824         snes_ppu.oam.priority_rotation = BIT(data, 7);
832825         snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0;
833826         snes_ram[OAMDATA] = 0;
r7581r7582
867860            {
868861               snes_ram[OAMDATA] = 0;
869862               snes_ppu.oam.address++;
870               snes_ppu.oam.address_low = snes_ram[OAMADDL] = snes_ppu.oam.address & 0xff;
871               snes_ppu.oam.address_high = snes_ram[OAMADDH] = (snes_ppu.oam.address >> 8) & 0x1;
863               snes_ppu.oam.address &= 0x1ff;
872864               snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0;
873865            }
874866            return;
src/mame/video/snes.c
r7581r7582
514514 * that it takes a blend parameter.
515515 *****************************************/
516516
517INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend )
517INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal )
518518{
519519   UINT8 mask, plane[4];
520520   UINT16 c;
521   int blend;
521522   INT16 ii, jj;
522523
523524   plane[0] = snes_vram[tileaddr];
r7581r7582
548549         mask >>= 1;
549550      }
550551
551      if (ii >= 0 && ii < SNES_SCR_WIDTH && scanlines[SNES_MAINSCREEN].enable)
552      INT16 pos = ii & 0x1ff;
553
554      if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[SNES_MAINSCREEN].enable)
552555      {
553         if (scanlines[SNES_MAINSCREEN].priority[ii] <= priority)
556         if (scanlines[SNES_MAINSCREEN].priority[pos] <= priority)
554557         {
555558            UINT8 clr = colour;
556559
r7581r7582
559562#endif /* SNES_LAYER_DEBUG */
560563            /* Clip to windows */
561564            if (scanlines[SNES_MAINSCREEN].clip)
562               clr &= snes_ppu.clipmasks[SNES_OAM][ii];
565               clr &= snes_ppu.clipmasks[SNES_OAM][pos];
563566
564567            /* Only draw if we have a colour (0 == transparent) */
565568            if (clr)
566569            {
567570               c = snes_cgram[(pal + clr) % FIXED_COLOUR];
571               blend = (pal + clr < 192) ? 1 : 0;
568572
569               scanlines[SNES_MAINSCREEN].buffer[ii] = c;
570               scanlines[SNES_MAINSCREEN].priority[ii] = priority;
571               scanlines[SNES_MAINSCREEN].layer[ii] = SNES_OAM;
572               scanlines[SNES_MAINSCREEN].blend_exception[ii] = blend;
573               scanlines[SNES_MAINSCREEN].buffer[pos] = c;
574               scanlines[SNES_MAINSCREEN].priority[pos] = priority;
575               scanlines[SNES_MAINSCREEN].layer[pos] = SNES_OAM;
576               scanlines[SNES_MAINSCREEN].blend_exception[pos] = blend;
573577            }
574578         }
575579      }
576580
577      if (ii >= 0 && ii < SNES_SCR_WIDTH && scanlines[SNES_SUBSCREEN].enable)
581      if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[SNES_SUBSCREEN].enable)
578582      {
579         if (scanlines[SNES_SUBSCREEN].priority[ii] <= priority)
583         if (scanlines[SNES_SUBSCREEN].priority[pos] <= priority)
580584         {
581585            UINT8 clr = colour;
582586
r7581r7582
585589#endif /* SNES_LAYER_DEBUG */
586590            /* Clip to windows */
587591            if (scanlines[SNES_SUBSCREEN].clip)
588               clr &= snes_ppu.clipmasks[SNES_OAM][ii];
592               clr &= snes_ppu.clipmasks[SNES_OAM][pos];
589593
590594            /* Only draw if we have a colour (0 == transparent) */
591595            if (clr)
592596            {
593597               c = snes_cgram[(pal + clr) % FIXED_COLOUR];
598               blend = (pal + clr < 192) ? 1 : 0;
594599
595               scanlines[SNES_SUBSCREEN].buffer[ii] = c;
596               scanlines[SNES_SUBSCREEN].priority[ii] = priority;
597               scanlines[SNES_SUBSCREEN].layer[ii] = SNES_OAM;
598               scanlines[SNES_SUBSCREEN].blend_exception[ii] = blend;
600               scanlines[SNES_SUBSCREEN].buffer[pos] = c;
601               scanlines[SNES_SUBSCREEN].priority[pos] = priority;
602               scanlines[SNES_SUBSCREEN].layer[pos] = SNES_OAM;
603               scanlines[SNES_SUBSCREEN].blend_exception[pos] = blend;
599604            }
600605         }
601606      }
r7581r7582
12261231
12271232static void snes_update_objects( UINT8 priority_tbl )
12281233{
1229   UINT8 blend, priority;
1234   UINT8 priority;
12301235   UINT32 charaddr;
12311236   int i;
12321237   static const UINT8 table_obj_priority[10][4] = {
r7581r7582
12631268      if (oam_tilelist[i].tileaddr == 0xffff)
12641269         continue;
12651270
1266      blend = (oam_tilelist[i].pal < 192) ? 1 : 0;
12671271      priority = table_obj_priority[priority_tbl][oam_tilelist[i].priority];
1268      snes_draw_tile_object(charaddr + oam_tilelist[i].tileaddr, oam_tilelist[i].x, priority, oam_tilelist[i].hflip, oam_tilelist[i].pal, blend);
1272      snes_draw_tile_object(charaddr + oam_tilelist[i].tileaddr, oam_tilelist[i].x, priority, oam_tilelist[i].hflip, oam_tilelist[i].pal);
12691273   }
12701274}
12711275
r7581r7582
13561360      return;
13571361#endif /* SNES_LAYER_DEBUG */
13581362
1363   snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0);
13591364   snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, 0);
1360   snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0);
13611365   snes_update_objects(5);
13621366}
13631367

Previous 15994 Revisions Next


© 1998-2018 The MESS Team