Previous 15994 Revisions Next

r5454 Monday 17th August, 2009 at 14:34:30 UTC by Robbbert
[JAGUAR] Added scaled bitmap code, cases 0 and 1 (adds credits to Skiing game)
Added RGB24 bitmap support (fixes Iron Soldier 2nd screen)
A few coding efficiencies, most games run at (or close to) 100%
[src/mame/video]jagobj.c jaguar.c

src/mame/video/jagobj.c
r5453r5454
8080{
8181   if (firstpix & 7)
8282   {
83      UINT32 pixsrc = src[firstpix / 8];
83      UINT32 pixsrc = src[firstpix >> 3];
8484      while (firstpix & 7)
8585      {
86         int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f;
86         int pix = (pixsrc >> ((~firstpix & 7) << 2)) & 0x0f;
8787         if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
8888         {
8989            if (!(flags & 2))
r5453r5454
9696      }
9797   }
9898
99   firstpix /= 8;
100   iwidth /= 8;
99   firstpix >>= 3;
100   iwidth >>= 3;
101101   iwidth -= firstpix;
102102
103103   while (iwidth-- > 0)
r5453r5454
178178         xpos += dxpos;
179179      }
180180      else
181         xpos += 8 * dxpos;
181         xpos += dxpos << 3;
182182   }
183183}
184184
r5453r5454
246246{
247247   if (firstpix & 3)
248248   {
249      UINT32 pixsrc = src[firstpix / 4];
249      UINT32 pixsrc = src[firstpix >> 2];
250250      while (firstpix & 3)
251251      {
252         UINT8 pix = pixsrc >> (8 * (~firstpix & 3));
252         UINT8 pix = pixsrc >> ((~firstpix & 3) << 3);
253253         if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
254254         {
255255            if (!(flags & 2))
r5453r5454
262262      }
263263   }
264264
265   firstpix /= 4;
266   iwidth /= 4;
265   firstpix >>= 2;
266   iwidth >>= 2;
267267   iwidth -= firstpix;
268268
269269   while (iwidth-- > 0)
r5453r5454
308308         xpos += dxpos;
309309      }
310310      else
311         xpos += 4 * dxpos;
311         xpos += dxpos << 2;
312312   }
313313}
314314
r5453r5454
376376{
377377   if (firstpix & 1)
378378   {
379      UINT16 pix = src[firstpix / 2];
379      UINT16 pix = src[firstpix >> 1];
380380      if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
381381      {
382382         if (!(flags & 2))
r5453r5454
387387      xpos += dxpos;
388388   }
389389
390   firstpix /= 2;
391   iwidth /= 2;
390   firstpix >>= 1;
391   iwidth >>= 1;
392392   iwidth -= firstpix;
393393
394394   while (iwidth-- > 0)
r5453r5454
415415         xpos += dxpos;
416416      }
417417      else
418         xpos += 2 * dxpos;
418         xpos += dxpos << 1;
419419   }
420420}
421421
r5453r5454
473473
474474
475475
476
477
478/*************************************
479 *
480 *  32bpp bitmap renderers - needs to be verified
481 *
482 *************************************/
483
484INLINE void bitmap_32_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
485{
486   iwidth -= firstpix;
487
488   while (iwidth-- > 0)
489   {
490      UINT32 pix = src[firstpix++];
491
492      if (xpos < 760)
493      {
494         scanline[xpos++] = (pix&0xffff0000)>>16;
495         scanline[xpos++] = pix&0xffff;
496      }
497   }
498}
499
500static void bitmap_32_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
501{
502   bitmap_32_draw(firstpix, iwidth, src, xpos, 0, 1);
503}
504
505static void bitmap_32_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
506{
507   bitmap_32_draw(firstpix, iwidth, src, xpos, 1, -1);
508}
509
510static void bitmap_32_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
511{
512   bitmap_32_draw(firstpix, iwidth, src, xpos, 2, 1);
513}
514
515static void bitmap_32_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
516{
517   bitmap_32_draw(firstpix, iwidth, src, xpos, 3, -1);
518}
519
520static void bitmap_32_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
521{
522   bitmap_32_draw(firstpix, iwidth, src, xpos, 4, 1);
523}
524
525static void bitmap_32_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
526{
527   bitmap_32_draw(firstpix, iwidth, src, xpos, 5, -1);
528}
529
530static void bitmap_32_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
531{
532   bitmap_32_draw(firstpix, iwidth, src, xpos, 6, 1);
533}
534
535static void bitmap_32_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
536{
537   bitmap_32_draw(firstpix, iwidth, src, xpos, 7, -1);
538}
539
540static void (*const bitmap32[8])(INT32, INT32, UINT32 *, INT32) =
541{
542   bitmap_32_0,
543   bitmap_32_1,
544   bitmap_32_2,
545   bitmap_32_3,
546   bitmap_32_4,
547   bitmap_32_5,
548   bitmap_32_6,
549   bitmap_32_7
550};
551
552
553
476554INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
477555{
478556   int ppl         = 32 / depth;
479   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)];
557   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl<<1)) * (pitch<<1))];
480558   UINT8 pix      = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
481559   return pix;
482560}
r5453r5454
641719            (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos);
642720            break;
643721
722         /* 32bpp case */
723         case 5:
724            /* only handle pitch=1 for now */
725            if (pitch != 1)
726               logerror("Unhandled pitch = %d\n", pitch);
727
728            (*bitmap32[flags & 7])(firstpix, iwidth, src, xpos);
729            break;
730
644731         default:
645732            fprintf(stderr, "Unhandled bitmap source depth = %d\n", depthlog);
646733            break;
r5453r5454
724811      int dxpos = (flags & 1) ? -1 : 1;
725812      int xpix = firstpix, yinc;
726813
727      /* only handle pitch=0 for now */
814      /* only handle pitch=1 (sequential data) for now */
728815      if (pitch != 1)
729816         logerror("Unhandled pitch = %d\n", pitch);
730817      if (flags & 2)
r5453r5454
742829         /* switch off the depth */
743830         switch (depthlog)
744831         {
832            case 0:      /* needs to be verified */
833            {
834               UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
835               clut += _index & 0x01;
836
837               /* render in phrases */
838               while (xpix < iwidth)
839               {
840                  UINT16 pix = (src[xpix >> 5] >> (~xpix & 31)) & 0x01;
841
842                  while (xleft > 0)
843                  {
844                     if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
845                        scanline[xpos] = clut[BYTE_XOR_BE(pix)];
846                     xpos += dxpos;
847                     xleft -= 0x20;
848                  }
849                  while (xleft <= 0)
850                     xleft += hscale, xpix++;
851               }
852               break;
853            }
854
855            case 1:      /* needs to be verified */
856            {
857               UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
858               clut += _index & 0x0f;
859
860               /* render in phrases */
861               while (xpix < iwidth)
862               {
863                  UINT16 pix = (src[xpix >> 4] >> ((~xpix & 15) << 1)) & 0x03;
864
865                  while (xleft > 0)
866                  {
867                     if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
868                        scanline[xpos] = clut[BYTE_XOR_BE(pix)];
869                     xpos += dxpos;
870                     xleft -= 0x20;
871                  }
872                  while (xleft <= 0)
873                     xleft += hscale, xpix++;
874               }
875               break;
876            }
877
745878            case 2:
746879            {
747880               UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
r5453r5454
750883               /* render in phrases */
751884               while (xpix < iwidth)
752885               {
753                  UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f;
886                  UINT16 pix = (src[xpix >> 3] >> ((~xpix & 7) << 2)) & 0x0f;
754887
755888                  while (xleft > 0)
756889                  {
r5453r5454
772905               /* render in phrases */
773906               while (xpix < iwidth)
774907               {
775                  UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff;
908                  UINT16 pix = (src[xpix >> 2] >> ((~xpix & 3) << 3)) & 0xff;
776909
777910                  while (xleft > 0)
778911                  {
r5453r5454
790923            case 4:
791924               while (xpix < iwidth)
792925               {
793                  UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16);
926                  UINT16 pix = src[xpix >> 1] >> ((~xpix & 1) << 4);
794927
795928                  while (xleft > 0)
796929                  {
src/mame/video/jaguar.c
r5453r5454
424424   {
425425      /* YCC full */
426426      case 0x000:
427      /* RGB24 */
428      case 0x002:
427429         for (i = 0; i < 65536; i++)
428430         {
429431            UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8;
r5453r5454
465467      /* others */
466468      default:
467469         logerror("Can't handle mode %X\n", vmode);
470         fprintf(stderr, "Can't handle mode %X\n", vmode);
468471         break;
469472   }
470473}
r5453r5454
687690               int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2]));
688691               int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
689692               int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
690               int vbend = gpu_regs[VBE] & 0x7ff;
693               int vbend = MAX(gpu_regs[VBE],gpu_regs[VDB]) & 0x7ff;
691694               int vbstart = gpu_regs[VBB] & 0x7ff;
692695
693696               /* adjust for the half-lines */
r5453r5454
774777   /* only run if video is enabled and we are past the "display begin" */
775778   if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff))
776779   {
777      UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc / 2, 0);
780      UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc >> 1, 0);
778781      int maxx = visarea->max_x;
779      int hde = effective_hvalue(gpu_regs[HDE]) / 2;
782      int hde = effective_hvalue(gpu_regs[HDE]) >> 1;
780783      UINT16 x,scanline[760];
781784      UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1;
782785
r5453r5454
792795      process_object_list(machine, vc, scanline);
793796
794797      /* copy the data to the target, clipping */
795      for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
796         for (y = 0; y < pixel_width; y++)
797            dest[hdb++] = pen_table[scanline[x]];
798      if ((gpu_regs[VMODE] & 0x106) == 0x002)   /* RGB24 */
799      {
800         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x+=2)
801            for (y = 0; y < pixel_width; y++)
802            {
803               UINT8 r = pen_table[(scanline[x]&0xff)|256];
804               UINT8 g = pen_table[(scanline[x]>>8)|512];
805               UINT8 b = pen_table[scanline[x+1]&0xff];               
806               dest[hdb++] = MAKE_RGB(r, g, b);
807            }
808      }
809      else
810      {
811         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
812            for (y = 0; y < pixel_width; y++)
813               dest[hdb++] = pen_table[scanline[x]];
814      }
798815   }
799816
800817   /* adjust the timer in a loop, to handle missed cases */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team