Previous 15994 Revisions Next

r5541 Sunday 30th August, 2009 at 09:53:59 UTC by Robbbert
[JAGUAR] reapply updates
[src/mame/video]jagobj.c jaguar.c

src/mame/video/jagobj.c
r5540r5541
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))
r5540r5541
9696      }
9797   }
9898
99   firstpix /= 8;
100   iwidth /= 8;
99   firstpix >>= 3;
100   iwidth >>= 3;
101101   iwidth -= firstpix;
102102
103103   while (iwidth-- > 0)
r5540r5541
178178         xpos += dxpos;
179179      }
180180      else
181         xpos += 8 * dxpos;
181         xpos += dxpos << 3;
182182   }
183183}
184184
r5540r5541
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))
r5540r5541
262262      }
263263   }
264264
265   firstpix /= 4;
266   iwidth /= 4;
265   firstpix >>= 2;
266   iwidth >>= 2;
267267   iwidth -= firstpix;
268268
269269   while (iwidth-- > 0)
r5540r5541
308308         xpos += dxpos;
309309      }
310310      else
311         xpos += 4 * dxpos;
311         xpos += dxpos << 2;
312312   }
313313}
314314
r5540r5541
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))
r5540r5541
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)
r5540r5541
415415         xpos += dxpos;
416416      }
417417      else
418         xpos += 2 * dxpos;
418         xpos += dxpos << 1;
419419   }
420420}
421421
r5540r5541
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{
478   int ppl         = 32 / depth;
479   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)];
480   UINT8 pix      = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
556   int ppl      = 32 / depth;
557   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl<<1)) * (pitch<<1))];
558   UINT8 pix   = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
481559   return pix;
482560}
483561
r5540r5541
534612      UINT32 dwidth = (lower2 >> 18) & 0x3ff;
535613      UINT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
536614      UINT8 _index = (upper2 >> 5) & 0xfe;
537      UINT8 flags = (upper2 >> 13) & 0x0f;
538      UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
615      UINT8 flags = (upper2 >> 13) & 0x07;
616      UINT8 firstpix = ((upper2 >> 17) & 0x3f) >> depthlog;
539617      int i, dxpos = (flags & 1) ? -1 : 1;
540618
541619      /* preadjust for firstpix */
r5540r5541
547625         /* 1bpp case */
548626         case 0:
549627         {
550            UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
551            clut += _index & 0xfe;
628            UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
552629
553630            /* non-blending */
554631            if (!(flags & 2))
r5540r5541
581658         /* 2bpp case */
582659         case 1:
583660         {
584            UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
585            clut += _index & 0xfc;
661            UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
586662
587663            /* non-blending */
588664            if (!(flags & 2))
r5540r5541
618694            if (pitch != 1)
619695               logerror("Unhandled pitch = %d\n", pitch);
620696
621            clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf0);
622            (*bitmap4[flags & 7])(firstpix, iwidth, src, xpos);
697            clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
698            (*bitmap4[flags])(firstpix, iwidth, src, xpos);
623699            break;
624700
625701         /* 8bpp case */
r5540r5541
629705               logerror("Unhandled pitch = %d\n", pitch);
630706
631707            clutbase = (UINT16 *)jaguar_gpu_clut;
632            (*bitmap8[flags & 7])(firstpix, iwidth, src, xpos);
708            (*bitmap8[flags])(firstpix, iwidth, src, xpos);
633709            break;
634710
635711         /* 16bpp case */
r5540r5541
638714            if (pitch != 1)
639715               logerror("Unhandled pitch = %d\n", pitch);
640716
641            (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos);
717            (*bitmap16[flags])(firstpix, iwidth, src, xpos);
642718            break;
643719
720         /* 32bpp case */
721         case 5:
722            /* only handle pitch=1 for now */
723            if (pitch != 1)
724               logerror("Unhandled pitch = %d\n", pitch);
725
726            (*bitmap32[flags])(firstpix, iwidth, src, xpos);
727            break;
728
644729         default:
645730            fprintf(stderr, "Unhandled bitmap source depth = %d\n", depthlog);
646731            break;
r5540r5541
715800      UINT32 dwidth = (lower2 >> 18) & 0x3ff;
716801      INT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
717802      UINT8 _index = (upper2 >> 5) & 0xfe;
718      UINT8 flags = (upper2 >> 13) & 0x0f;
719      UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
803      UINT8 flags = (upper2 >> 13) & 0x07;
804      UINT8 firstpix = ((upper2 >> 17) & 0x3f) >> depthlog;
720805
721806      INT32 hscale = lower3 & 0xff;
722807      INT32 vscale = (lower3 >> 8) & 0xff;
r5540r5541
724809      int dxpos = (flags & 1) ? -1 : 1;
725810      int xpix = firstpix, yinc;
726811
727      /* only handle pitch=0 for now */
812      /* only handle pitch=1 (sequential data) for now */
728813      if (pitch != 1)
729814         logerror("Unhandled pitch = %d\n", pitch);
730815      if (flags & 2)
r5540r5541
742827         /* switch off the depth */
743828         switch (depthlog)
744829         {
830            case 0:
831            {
832               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
833
834               /* render in phrases */
835               while (xpix < iwidth)
836               {
837                  UINT16 pix = (src[xpix >> 5] >> (~xpix & 31)) & 0x01;
838
839                  while (xleft > 0)
840                  {
841                     if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
842                        scanline[xpos] = clut[BYTE_XOR_BE(pix)];
843                     xpos += dxpos;
844                     xleft -= 0x20;
845                  }
846                  while (xleft <= 0)
847                     xleft += hscale, xpix++;
848               }
849               break;
850            }
851
852            case 1:
853            {
854               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
855
856               /* render in phrases */
857               while (xpix < iwidth)
858               {
859                  UINT16 pix = (src[xpix >> 4] >> ((~xpix & 15) << 1)) & 0x03;
860
861                  while (xleft > 0)
862                  {
863                     if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
864                        scanline[xpos] = clut[BYTE_XOR_BE(pix)];
865                     xpos += dxpos;
866                     xleft -= 0x20;
867                  }
868                  while (xleft <= 0)
869                     xleft += hscale, xpix++;
870               }
871               break;
872            }
873
745874            case 2:
746875            {
747               UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
748               clut += _index & 0xf0;
876               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
749877
750878               /* render in phrases */
751879               while (xpix < iwidth)
752880               {
753                  UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f;
881                  UINT16 pix = (src[xpix >> 3] >> ((~xpix & 7) << 2)) & 0x0f;
754882
755883                  while (xleft > 0)
756884                  {
r5540r5541
772900               /* render in phrases */
773901               while (xpix < iwidth)
774902               {
775                  UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff;
903                  UINT16 pix = (src[xpix >> 2] >> ((~xpix & 3) << 3)) & 0xff;
776904
777905                  while (xleft > 0)
778906                  {
r5540r5541
790918            case 4:
791919               while (xpix < iwidth)
792920               {
793                  UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16);
921                  UINT16 pix = src[xpix >> 1] >> ((~xpix & 1) << 4);
794922
795923                  while (xleft > 0)
796924                  {
r5540r5541
831959
832960/*************************************
833961 *
834 *  Brach object processor
962 *  Branch object processor
835963 *
836964 *************************************/
837965
r5540r5541
9371065
9381066         /* GPU interrupt */
9391067         case 2:
940            gpu_regs[OB_HH]=objdata[1];
941            gpu_regs[OB_HL]=objdata[2];
942            gpu_regs[OB_LH]=objdata[3];
943            gpu_regs[OB_LL]=objdata[4];
1068            gpu_regs[OB_HH]=(objdata[1]&0xffff0000)>>16;
1069            gpu_regs[OB_HL]=objdata[1]&0xffff;
1070            gpu_regs[OB_LH]=(objdata[0]&0xffff0000)>>16;
1071            gpu_regs[OB_LL]=objdata[0]&0xffff;
9441072            cpu_irq_state |= 2;
9451073            update_cpu_irq(machine);
9461074            done=1;
src/mame/video/jaguar.c
r5540r5541
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;
r5540r5541
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}
r5540r5541
595598   switch (offset)
596599   {
597600      case B_CMD:   /* B_CMD */
598         return 0x00000001;
601         return 1;
599602
600603      default:
601604         logerror("%08X:Blitter read register @ F022%02X\n", cpu_get_previouspc(space->cpu), offset * 4);
r5540r5541
643646   return gpu_regs[offset];
644647}
645648
649#if 0
650static TIMER_CALLBACK( jaguar_pit )
651{
652   attotime sample_period;
653   cpu_irq_state |= 4;
654   update_cpu_irq(machine);
646655
656   if (gpu_regs[PIT0])
657   {
658      sample_period = ATTOTIME_IN_NSEC(cpu_get_clock(cputag_get_cpu(machine,"gpu")) / (1+gpu_regs[PIT0]) / (1+gpu_regs[PIT1]));
659//      timer_set(machine, sample_period, NULL, 0, jaguar_pit);
660   }
661}
662#endif
663   
647664WRITE16_HANDLER( jaguar_tom_regs_w )
648665{
649666   UINT32 reg_store = gpu_regs[offset];
650
667   attotime sample_period;
651668   if (offset < GPU_REGS)
652669   {
653670      COMBINE_DATA(&gpu_regs[offset]);
654671
655672      switch (offset)
656673      {
674
675#if 0         case PIT1:
676            if (gpu_regs[PIT0])
677            {
678               sample_period = ATTOTIME_IN_NSEC(cpu_get_clock(cputag_get_cpu(space->machine,"gpu")) / (1+gpu_regs[PIT0]) / (1+gpu_regs[PIT1]));
679               timer_set(space->machine, sample_period, NULL, 0, jaguar_pit);
680            }
681            break;
682#endif
657683         case INT1:
658684            cpu_irq_state &= ~(gpu_regs[INT1] >> 8);
659685            update_cpu_irq(space->machine);
r5540r5541
687713               int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2]));
688714               int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
689715               int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
690               int vbend = gpu_regs[VBE] & 0x7ff;
716               int vbend = MAX(gpu_regs[VBE],gpu_regs[VDB]) & 0x7ff;
691717               int vbstart = gpu_regs[VBB] & 0x7ff;
692718
693719               /* adjust for the half-lines */
r5540r5541
774800   /* only run if video is enabled and we are past the "display begin" */
775801   if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff))
776802   {
777      UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc / 2, 0);
803      UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc >> 1, 0);
778804      int maxx = visarea->max_x;
779      int hde = effective_hvalue(gpu_regs[HDE]) / 2;
805      int hde = effective_hvalue(gpu_regs[HDE]) >> 1;
780806      UINT16 x,scanline[760];
781807      UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1;
782808
r5540r5541
792818      process_object_list(machine, vc, scanline);
793819
794820      /* 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]];
821      if ((gpu_regs[VMODE] & 0x106) == 0x002)   /* RGB24 */
822      {
823         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x+=2)
824            for (y = 0; y < pixel_width; y++)
825            {
826               UINT8 r = pen_table[(scanline[x]&0xff)|256];
827               UINT8 g = pen_table[(scanline[x]>>8)|512];
828               UINT8 b = pen_table[scanline[x+1]&0xff];               
829               dest[hdb++] = MAKE_RGB(r, g, b);
830            }
831      }
832      else
833      {
834         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
835            for (y = 0; y < pixel_width; y++)
836               dest[hdb++] = pen_table[scanline[x]];
837      }
798838   }
799839
800840   /* adjust the timer in a loop, to handle missed cases */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team