Previous 15994 Revisions Next

r5616 Monday 7th September, 2009 at 04:26:07 UTC by MooglyGuy
Added support for rotating/zooming sprites in the GBA driver
[src/mess/includes]gba.h
[src/mess/video]gba.c

src/mess/video/gba.c
r5615r5616
148148      cx = cy = sizes[size] / 2;
149149
150150//      psx = ((PA * (X - cx)) & ~63) + ((PB * (Y - cy)) & ~63) + ((PB * ypos) & ~63) + (cx << 8); //pixel start x
151//      psy = ((PC * (X - cx)) & ~63) + ((PD * (Y - cy)) & ~63) + ((PD * ypos) & ~63) + (cy << 8); //pixel start y     
151//      psy = ((PC * (X - cx)) & ~63) + ((PD * (Y - cy)) & ~63) + ((PD * ypos) & ~63) + (cy << 8); //pixel start y
152152      psx = ((PA * (X - cx))) + ((PB * (Y - cy))) + ((PB * ypos)) + (cx << 8); //pixel start x
153      psy = ((PC * (X - cx))) + ((PD * (Y - cy))) + ((PD * ypos)) + (cy << 8); //pixel start y     
153      psy = ((PC * (X - cx))) + ((PD * (Y - cy))) + ((PD * ypos)) + (cy << 8); //pixel start y
154154
155155
156156      /*
r5615r5616
186186         {
187187            scanline[x] = pgba_pram[pixel]&0x7fff;
188188         }
189      }     
189      }
190190   }
191191#endif
192192}
r5615r5616
406406      for( gba_oamindex = 127; gba_oamindex >= 0; gba_oamindex-- )
407407      {
408408         UINT16 attr0, attr1, attr2;
409         INT32 cury, lg;
410         UINT8 *src;
411         UINT16 j;
409412
410413         attr0 = pgba_oam[(4*gba_oamindex)+0];
411414         attr1 = pgba_oam[(4*gba_oamindex)+1];
412415         attr2 = pgba_oam[(4*gba_oamindex)+2];
413416
414         if (((attr0 & OBJ_MODE) != OBJ_MODE_WINDOW) && (((attr2 >> 10) & 3) == priority))
417         if (((attr0 & OBJ_MODE) != OBJ_MODE_WINDOW) && (((attr2 >> 10) & 3) >= priority))
415418         {
416419            width = 0;
417420            height = 0;
r5615r5616
490493            tiledrawindex = tileindex = (attr2 & OBJ_TILENUM);
491494            tilebytebase = 0x10000;   // the index doesn't change in the higher modes, we just ignore sprites that are out of range
492495
493             if (attr0 & OBJ_USEROZ)
496             if (attr0 & OBJ_ROZMODE_ROZ)
494497            {
495                // don't draw ROZ sprites for now
496//               printf("OAM: ROZ\n");
498               INT16 sx, sy;
499               INT32 fx, fy, ax, ay, rx, ry, offs;
500               UINT8 blockparam;
501               INT16 dx, dy, dmx, dmy;
502               UINT8 color;
503
504               width *= 8;
505               height *= 8;
506
507               if ((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DISABLE)
508               {
509                  continue;
510               }
511
512               sx = (attr1 & OBJ_X_COORD);
513               sy = (attr0 & OBJ_Y_COORD);
514
515               lg = width;
516
517               if(sx & 0x100)
518               {
519                  sx |= 0xffffff00;
520               }
521
522               if(sy >= 160)
523               {
524                  sy |= 0xffffff00;
525               }
526
527               fx = width;
528               fy = height;
529
530               if((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DBLROZ)
531               {
532                  fx *= 2;
533                  fy *= 2;
534                  lg *= 2;
535               }
536
537               if((y < sy) || (y >= sy + fy) || (sx >= 240) || (sx + fx <= 0))
538               {
539                  continue;
540               }
541
542               cury = y - sy;
543
544               blockparam = ((attr1 & OBJ_SCALE_PARAM) >> OBJ_SCALE_PARAM_SHIFT) << 4;
545
546               dx  = (INT16)pgba_oam[blockparam+3];
547               dmx = (INT16)pgba_oam[blockparam+7];
548               dy  = (INT16)pgba_oam[blockparam+11];
549               dmy = (INT16)pgba_oam[blockparam+15];
550
551               rx = (width << 7) - (fx >> 1)*dx - (fy >> 1)*dmx + cury * dmx;
552               ry = (height << 7) - (fx >> 1)*dy - (fy >> 1)*dmy + cury * dmy;
553
554               if (sx < 0)
555               {
556                  if(sx + fx <= 0)
557                  {
558                     continue;
559                  }
560
561                  lg += sx;
562                  rx -= sx*dx;
563                  ry -= sx*dy;
564                  sx = 0;
565               }
566               else
567               {
568                  if(sx + fx > 256)
569                  {
570                     lg = 256 - sx;
571                  }
572               }
573
574               //printf( "Drawing a sprite scanline, y = %d, sx = %d, sy = %d\n", y, sx, sy );
575               if(attr0 & OBJ_PALMODE_256)
576               {
577                  UINT16 *pgba_pram = (UINT16*)gba_state->gba_pram;
578
579                  src = (UINT8*)&gba_state->gba_vram[tilebytebase >> 2];
580                  if(!src)
581                  {
582                     continue;
583                  }
584
585                  src += tiledrawindex * 32;
586
587                  for(j = 0; j < lg; ++j, ++sx)
588                  {
589                     ax = (rx >> 8);
590                     ay = (ry >> 8);
591
592                     if(ax >= 0 && ay >= 0 && ax < width && ay < height)
593                     {
594                        if((gba_state->DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_2D)
595                        {
596                           offs = (ax & 0x7) + ((ax & 0xfff8) << 3) + ((ay >> 3) << 10) + ((ay & 0x7) << 3);
597                        }
598                        else
599                        {
600                           offs = (ax & 0x7) + ((ax & 0xfff8) << 3) + (((ay >> 3) * width) << 3) + ((ay & 0x7) << 3);
601                        }
602
603                        color = src[offs];
604
605                        if(color)
606                        {
607                           scanline[sx] = pgba_pram[256+color] & 0x7fff;
608                        }
609                     }
610
611                     rx += dx;
612                     ry += dy;
613                  }
614               }
615               else
616               {
617                  UINT16 *pgba_pram = (UINT16*)gba_state->gba_pram;
618
619                  src = (UINT8*)&gba_state->gba_vram[tilebytebase >> 2];
620                  if(!src)
621                  {
622                     continue;
623                  }
624
625                  src += tiledrawindex * 32;
626
627                  for(j = 0; j < lg; ++j, ++sx)
628                  {
629                     ax = (rx >> 8);
630                     ay = (ry >> 8);
631
632                     if(ax >= 0 && ay >= 0 && ax < width && ay < height)
633                     {
634                        if((gba_state->DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_2D)
635                        {
636                           offs = ((ax >> 1) & 0x3) + (((ax >> 1) & 0xfffc) << 3) + ((ay >> 3) << 10) + ((ay & 0x7) << 2);
637                        }
638                        else
639                        {
640                           offs = ((ax >> 1) & 0x3) + (((ax >> 1) & 0xfffc) << 3) + (((ay >> 3) * width) << 2) + ((ay & 0x7) << 2);
641                        }
642
643                        color = src[offs];
644
645                        if(ax & 1)
646                        {
647                           color >>= 4;
648                        }
649                        else
650                        {
651                           color &= 0x0f;
652                        }
653
654                        if(color)
655                        {
656                           scanline[sx] = pgba_pram[256 + ((attr2 & 0xf000) >> 8) + color] & 0x7fff;
657                        }
658                     }
659
660                     rx += dx;
661                     ry += dy;
662                  }
663               }
497664            }
498665            else
499666            {
500667               INT16 sx, sy;
501668               int vflip, hflip;
502669
503               if (attr0 & OBJ_DISABLE)
670               if ((attr0 & OBJ_ROZMODE) == OBJ_ROZMODE_DISABLE)
504671               {
505672                  continue;
506673               }
r5615r5616
694861   int level, x;
695862
696863   /* generate a table to make mosaic fast */
697   for (level = 0; level < 16; level++)
864   for (level = 0; level < 16; level++)
698865   {
699866      for (x = 0; x < 4096; x++)
700867      {
src/mess/includes/gba.h
r5615r5616
4343#define DISPCNT_OBJWIN_EN      0x8000
4444
4545#define OBJ_Y_COORD         0x00ff
46#define OBJ_USEROZ         0x0100
47#define OBJ_DOUBLE         0x0200
48#define OBJ_DISABLE         0x0200
46#define OBJ_ROZMODE         0x0300
47#define OBJ_ROZMODE_NONE   0x0000
48#define OBJ_ROZMODE_ROZ      0x0100
49#define OBJ_ROZMODE_DISABLE   0x0200
50#define OBJ_ROZMODE_DBLROZ   0x0300
4951
5052#define OBJ_MODE         0x0c00
5153#define OBJ_MODE_NORMAL         0x0000
5254#define OBJ_MODE_ALPHA         0x0400
5355#define OBJ_MODE_WINDOW         0x0800
56#define OBJ_MODE_BITMAP         0x0c00
5457
5558#define OBJ_MOSAIC         0x1000
5659

Previous 15994 Revisions Next


© 1998-2018 The MESS Team