Previous 15994 Revisions Next

r7546 Wednesday 10th March, 2010 at 10:10:58 UTC by Fabio Priuli
[SNES] Reverted some more changes done in rev.7540, to fix Super Street Fighters 2 freeze (and possibly other regressions).
Changes will be applied again as soon as more OAM rewriting/refactoring is done (and then the duplicate code will be removed)
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mame/video]snes.c

src/mame/machine/snes.c
r7545r7546
769769   {
770770      case INIDISP:   /* Initial settings for screen */
771771         if ((snes_ppu.screen_disabled & 0x80) && (!(data & 0x80))) //a 1->0 force blank transition causes a reset OAM address
772         {
772         {   
773773            memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low);
774774            memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high);
775775         }
r7545r7546
780780         snes_ppu.oam.next_charmap = (data & 0x03) << 1;
781781         snes_ppu.oam.next_name_select = (((data & 0x18) >> 3) * 0x1000) << 1;
782782         snes_ppu.oam.next_size = (data & 0xe0) >> 5;
783         break;
783         switch ((data & 0xe0) >> 5)
784         {
785            case 0:         /* 8 & 16 */
786                     snes_ppu.oam.size[0] = 1;
787                     snes_ppu.oam.size[1] = 2;
788                     break;
789                  case 1:         /* 8 & 32 */
790                     snes_ppu.oam.size[0] = 1;
791                     snes_ppu.oam.size[1] = 4;
792                     break;
793                  case 2:         /* 8 & 64 */
794                     snes_ppu.oam.size[0] = 1;
795                     snes_ppu.oam.size[1] = 8;
796                     break;
797                  case 3:         /* 16 & 32 */
798                     snes_ppu.oam.size[0] = 2;
799                     snes_ppu.oam.size[1] = 4;
800                     break;
801                  case 4:         /* 16 & 64 */
802                     snes_ppu.oam.size[0] = 2;
803                     snes_ppu.oam.size[1] = 8;
804                     break;
805                  case 5:         /* 32 & 64 */
806                     snes_ppu.oam.size[0] = 4;
807                     snes_ppu.oam.size[1] = 8;
808                     break;
809                  default:
810                     /* Unknown size so default to 8 & 16 */
811                     logerror("Object size unsupported: %d\n", (data & 0xe0) >> 5);
812     
813                     snes_ppu.oam.size[0] = 1;
814                     snes_ppu.oam.size[1] = 2;
815            break;
816         }
784817      case OAMADDL:   /* Address for accessing OAM (low) */
785818         snes_ppu.oam.address_low = data;
786819         snes_ppu.oam.saved_address_low = data;
src/mame/includes/snes.h
r7545r7546
530530      UINT16 priority_rotation;
531531      UINT8 next_charmap;
532532      UINT8 next_size;
533      UINT8 size;
533      UINT8 size_;
534      UINT8 size[2];
534535      UINT32 next_name_select;
535536      UINT32 name_select;
536537      UINT8 first_sprite;
src/mame/video/snes.c
r7545r7546
999999
10001000static struct OAM oam_list[SNES_SCR_WIDTH / 2];
10011001
1002#if 0
1003
1004// FIXME: The following functions should be used to create sprite list with
1005// obsel data from the previous line. Unfortunately, some games are very picky
1006// about when you set up sprite attributes (e.g. Super Star Wars - The Empire
1007// Strikes Back and Super Street Fighter II) and they would freeze if we only build
1008// part of the sprite attributes at the right moment and part of them later, during
1009// scanline drawing. Hence, these functions are on hold until more OAM refactoring
1010// is done (soon-ish)
10021011static void snes_update_obsel( void )
10031012{
10041013   snes_ppu.layer[SNES_OAM].charmap = snes_ppu.oam.next_charmap;
10051014   snes_ppu.oam.name_select = snes_ppu.oam.next_name_select;
10061015
1007   if (snes_ppu.oam.size != snes_ppu.oam.next_size)
1016   if (snes_ppu.oam.size_ != snes_ppu.oam.next_size)
10081017   {
1009      snes_ppu.oam.size = snes_ppu.oam.next_size;
1018      snes_ppu.oam.size_ = snes_ppu.oam.next_size;
10101019      snes_ppu.update_oam_list = 1;
10111020   }
10121021}
r7545r7546
10471056         oam_list[i].x -= 512;
10481057
10491058      /* Determine object size */
1050      switch (snes_ppu.oam.size)
1059      switch (snes_ppu.oam.next_size)
10511060      {
10521061      case 0:         /* 8x8 or 16x16 */
10531062         oam_list[i].width  = oam_list[i].size ? 2 : 1;
r7545r7546
10871096         break;
10881097      default:
10891098         /* we should never enter here... */
1090         logerror("Object size unsupported: %d\n", snes_ppu.oam.size);
1099         logerror("Object size unsupported: %d\n", snes_ppu.oam.size_);
10911100         break;
10921101      }
10931102   }
10941103}
1104#endif
10951105
10961106static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
10971107{
r7545r7546
11141124                  {1, 3, 5, 6},   // mode 7 EXTBG
11151125                  {1, 2, 5, 8}   // mode 1 + BG3 priority bit
11161126   };
1127   UINT8 *oamram = (UINT8 *)snes_oam;
1128   INT16 oam = 0x1ff;
1129   UINT16 oam_extra = oam + 0x20;
1130   UINT16 extra = 0;
11171131
11181132#ifdef SNES_LAYER_DEBUG
11191133   if (debug_options.bg_disabled[SNES_OAM])
r7545r7546
11311145   curline /= snes_ppu.interlace;
11321146   curline *= snes_ppu.obj_interlace;
11331147
1134   charaddr = snes_ppu.layer[SNES_OAM].charmap << 13;
1148   charaddr = snes_ppu.oam.next_charmap << 13;
1149   
1150   for (i = 128; i > 0; i--)
1151   {
1152      if ((i % 4) == 0)
1153         extra = oamram[oam_extra--];
11351154
1136   snes_update_obsel();
1137   snes_oam_list_build();
1155      oam_list[i].vflip = (oamram[oam] & 0x80) >> 7;
1156      oam_list[i].hflip = (oamram[oam] & 0x40) >> 6;
1157      oam_list[i].priority_bits = (oamram[oam] & 0x30) >> 4;
1158      oam_list[i].pal = 128 + ((oamram[oam] & 0x0e) << 3);
1159      oam_list[i].tile = (oamram[oam--] & 0x1) << 8;
1160      oam_list[i].tile |= oamram[oam--];
1161      oam_list[i].y = oamram[oam--] + 1;   /* We seem to need to add one here.... */
1162      oam_list[i].x = oamram[oam--];
1163      oam_list[i].size = (extra & 0x80) >> 7;
1164      extra <<= 1;
1165      oam_list[i].x |= ((extra & 0x80) << 1);
1166      extra <<= 1;
1167      oam_list[i].y *= snes_ppu.obj_interlace;
11381168
1139   for (i = 128; i > 0; i--)
1140   {
1169      /* Adjust if past maximum position */
1170      if (oam_list[i].y >= snes_ppu.beam.last_visible_line * snes_ppu.interlace)
1171         oam_list[i].y -= 256 * snes_ppu.interlace;
1172      if (oam_list[i].x > 255)
1173         oam_list[i].x -= 512;
11411174      tile = oam_list[i].tile;
11421175      x = oam_list[i].x;
11431176      y = oam_list[i].y;
r7545r7546
11491182      pal = oam_list[i].pal;
11501183
11511184      /* Draw sprite if it intersects the current line */
1152      if (curline >= y && curline < (y + (height << 3)))
1185      if (curline >= y && curline < (y + (snes_ppu.oam.size[oam_list[i].size] << 3)))
11531186      {
11541187         /* Only objects using palettes 4-7 can be transparent */
11551188         blend = (pal < 192) ? 1 : 0;
11561189
11571190         /* Only objects using tiles over 255 use name select */
1158         name_sel = (tile < 256) ? 0 : snes_ppu.oam.name_select;
1191         name_sel = (tile < 256) ? 0 : snes_ppu.oam.next_name_select;
11591192
11601193         ys = (curline - y) >> 3;
11611194         line = (curline - y) % 8;
11621195         if (vflip)
11631196         {
1164            ys = height - ys - 1;
1197            ys = snes_ppu.oam.size[oam_list[i].size] - ys - 1;
11651198            line = (-1 * line) + 7;
11661199         }
11671200         line <<= 1;
r7545r7546
11691202         if (hflip)
11701203         {
11711204            UINT8 count = 0;
1172            for (xs = (width - 1); xs >= 0; xs--)
1205            for (xs = (snes_ppu.oam.size[oam_list[i].size] - 1); xs >= 0; xs--)
11731206            {
11741207               if ((x + (count << 3) < SNES_SCR_WIDTH))
11751208               {
r7545r7546
11801213         }
11811214         else
11821215         {
1183            for (xs = 0; xs < width; xs++)
1216            for (xs = 0; xs < snes_ppu.oam.size[oam_list[i].size]; xs++)
11841217            {
11851218               if ((x + (xs << 3) < SNES_SCR_WIDTH))
11861219               {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team