Previous 199869 Revisions Next

r21541 Saturday 2nd March, 2013 at 19:38:40 UTC by David Haywood
make source x/y and dest x/y during the blitter copy more independent so we can treat compressed data as more of a stream
[src/mame/drivers]gunpey.c

trunk/src/mame/drivers/gunpey.c
r21540r21541
616616      //int color = space.machine().rand()&0x1f;
617617
618618
619/* the two parts of the banpresto logo have compressed data looking like this for the white fill area
620 the first part of this sprite covers the first 256 pixels of the screen, the second part covers the
621 right-most 64 pixels.  the second part reaches real data sooner because it has to compress less blank
622 bytes due to only covering a 64-pixel span.
623619
624 there is clearly a repeating pattern
625620
626 (srcwidth) byte just determines how the compressed data is organized in ROM and is unrelated to the
627 decompression.
628
629 left part
630data: srcwide(11)
631     a8 68 cd 9a 36 6d da b4 69
632     d3 a6 4d 9b 36 6d da b4 69
633     d3 a6 4d 9b 36 6d da b4 69
634     d3 a6 4d 9b 36 6d da b4 69
635     d3 a6 4d 9b 36 6d da b4 69
636     d3 a6 4d 9b 36 6d da b4 69
637     d3 a6 4d 9b 36 6d da b4 69
638     d3 a6 4d 9b 36 6d da b4 69
639     d3 a6 4d 9b 36 6d da b4 69
640     d3 a6 4d 9b 36 6d da b4 69
641     d3 a6 4d 9b 36 6d da b4 69
642     d3 a6 4d 9b 36 6d da b4 69
643     d3 a6 4d 9b 36 6d da b4 69
644     d3 a6 4d 9b 36 6d da b4 69
645     d3 a6 4d 9b 36 6d da b4 69
646     d3 a6 4d 9b 36 6d da b4 69
647     d3 a6 4d 9b 36 6d da b4 69
648     d3 a6 4d 9b 36 6d da b4 69
649     d3 a6 4d 9b 36 6d da b4 69
650     d3 a6 4d 9b 36 6d da b4 69
651     d3 a6 4d 9b 36 6d da b4 69
652     d3 a6 4d 9b 36 6d da b4 69
653     d3 a6 4d 9b 36 6d da b4 69
654     d3 a6 4d 9b 36 6d da b4 69
655     d3 a6 4d 9b 36 6d da b4 69
656     d3 a6 4d 9b 36 6d da b4 69
657     d3 a6 4d 9b 36 6d da b4 69
658     d3 a6 4d 9b 36 6d da b4 69
659     ...
660
66102 08 00 8c|06 06 16 05|3f 00 00 01|10 00 ef 00
662data: srcwide(05)
663     a8 68 cd 9a 36 6d da b4 69
664     d3 a6 4d 9b 36 6d da b4 69
665     d3 a6 4d 9b 36 6d da b4 69
666     d3 a6 4d 9b 36 6d da b4 69
667     d3 a6 4d 9b 36 6d da b4 69
668     d3 a6 4d 9b 36 6d da b4 69
669     d3 a6 4d 9b 36 6d da b4 69
670     d3 a6 4d 9b 36 6d da b4 69
671     d3 a6 4d 9b 36 6d da b4 69
672     d3 a6 4d 9b 36 6d da b4 e9
673     23 95 0a 19 a6 52 8d 0c 54
674     ce 6a b9 ac 2a 6e 53 0c 55
675     11 b0 55 a1 ca 2b 30 81 71
676     15 b7 1b 65 2a ae e1 02 c2
677     ca bb 7a 03 33 58 f9 d5 d6
678     0c 51 7e 09 08 2e bf 2c 28
679     bf 32 ac b8 69 d3 a6 95 85
680     29 bf 7a 13 c3 cb af e6 66
681     90 f2 ab ad b1 e5 57 4b f3
682     58 f9 ad cb 54 4d 5a 44 5c
683     c5 e0 80 cc 64 15 3f d0 b0
684     e5 98 5a 50 45 da cb aa 52
685     c8 25 e5 21 8b 55 4a 94 09
686     4d 9b 36 6d da b4 69 d3 a6
687     4d 9b 36 6d da b4 69 d3 a6
688     4d 9b 36 6d da b4 69 d3 a6
689     4d 9b 36 6d da b4 69 d3 a6
690     4d 9b 36 6d da b4 69 d3 a6
691     ....
692
693*/
694
695621      if(rle)
696622      {
697623         if(rle == 8)
r21540r21541
709635               ,blit_ram[0xc],blit_ram[0xd],blit_ram[0xe],blit_ram[0xf]);
710636            int count = 0;
711637            printf("data: ");
638            const int show_bytes = 1;
639            int bitspacer = 0;
640            int bitspace = 10;
712641#endif
713642
643           
644            int dstxbase = dstx;
645            int dstwcount = 0;
646            int dstycount = 0;
647            int srcxbase = srcx;
648            int srcwcount = 0;
649            int srcycount = 0;
650
714651            UINT8 sourcewide = blit_rom[(((srcy)&0x7ff)*0x800)+((srcx)&0x7ff)];
652            srcx++;srcwcount++; // we don't want to decode the width as part of the data stream..     
653            UINT8 lastdata = 0xff; // hack so we can bail when we appear to have run out of compressed data
654            bool out_of_data = false;
715655
716            for (int y=0;y<ysize;y++)
656            for (;;)
717657            {
718               for (int x=0;x<xsize;x++)
719               {
720                  UINT8 dat = blit_rom[(((srcy+y)&0x7ff)*0x800)+((srcx+x)&0x7ff)];
658               UINT8 data = blit_rom[(((srcy)&0x7ff)*0x800)+((srcx)&0x7ff)];
659               
660               // hack, really I imagine there is exactly enough compressed data to fill the dest bitmap area when decompressed, but to stop us
661               // overrunning into reading other data we terminate on a 0000, which doesn't seem likely to be compressed data.
662               if (data==0x00 && lastdata == 0x00)
663                  out_of_data = true;
721664
722                  // test.. (it's correct)
723                  if (x<=sourcewide)
724                  {
665               lastdata = data;
725666
726                     vram[(((dsty+y)&0x7ff)*0x800)+((dstx+x)&0x7ff)] = dat;
727
728                     #ifdef SHOW_COMPRESSED_DATA_DEBUG
729                     if (count<256)
667               if (!out_of_data)
668               {
669                  #ifdef SHOW_COMPRESSED_DATA_DEBUG
670                  if (count<256)
671                  {               
672                     if (show_bytes)
730673                     {
674                        printf("%02x ", data);
675                     }
676                     else
677                     {
678                        for (int z=0;z<8;z++)
679                        {
680                           printf("%d", (data>>(7-z))&1);
681                           bitspacer++;
682                           if (bitspacer == bitspace)
683                           {
684                              printf(" ");
685                              bitspacer = 0;
686                           }
687                        }
688                     }
689                     count++;
690                  }
691                  #endif
731692
732                        if (count==0) printf("srcwide(%02x) ", dat);
733                        else printf("%02x ", dat);
693                  vram[(((dsty)&0x7ff)*0x800)+((dstx)&0x7ff)] = data;
694               }
695               else
696                  vram[(((dsty)&0x7ff)*0x800)+((dstx)&0x7ff)] = 0x44;
734697
735                        count++;
736                     }
737                     #endif
738                  }
739                  else
698               // increase our source counter, taking note of the width of the compressed data in
699               // source (it differs from the destination width)
700               srcx++; srcwcount++;
701               if (srcwcount==sourcewide+1) // CHECK might not be +1
702               {
703                  srcwcount = 0;
704                  srcx = srcxbase;
705                  srcy++; srcycount++;
706               }
707
708               // increase destination counter and check if we've filled our destination rectangle
709               dstx++; dstwcount++;
710               if (dstwcount==xsize)
711               {
712                  dstwcount = 0;
713                  dstx = dstxbase;
714                  dsty++; dstycount++;
715                  if (dstycount==ysize)
740716                  {
741                     vram[(((dsty+y)&0x7ff)*0x800)+((dstx+x)&0x7ff)] = 0xff;
717                     break;
742718                  }
743
744719               }
745720            }
721
746722#ifdef SHOW_COMPRESSED_DATA_DEBUG
747            printf("\n\n");
723            printf("\n");
748724#endif
725
749726         }
750727         else
751728            printf("unknown RLE mode %02x\n",rle);
752729      }
753730      else
754731      {
755         for (int y=0;y<ysize;y++)
732         int dstxbase = dstx;
733         int dstwcount = 0;
734         int dstycount = 0;
735         int srcxbase = srcx;
736         int srcwcount = 0;
737         int srcycount = 0;
738
739         for (;;)
756740         {
757            for (int x=0;x<xsize;x++)
741            UINT8 data = blit_rom[(((srcy)&0x7ff)*0x800)+((srcx)&0x7ff)];
742            vram[(((dsty)&0x7ff)*0x800)+((dstx)&0x7ff)] = data;
743
744            srcx++; srcwcount++;
745            if (srcwcount==xsize)
758746            {
759               vram[(((dsty+y)&0x7ff)*0x800)+((dstx+x)&0x7ff)] = blit_rom[(((srcy+y)&0x7ff)*0x800)+((srcx+x)&0x7ff)];
747               srcwcount = 0;
748               srcx = srcxbase;
749               srcy++; srcycount++;
760750            }
751
752            // increase destination counter and check if we've filled our destination rectangle
753            dstx++; dstwcount++;
754            if (dstwcount==xsize)
755            {
756               dstwcount = 0;
757               dstx = dstxbase;
758               dsty++; dstycount++;
759               if (dstycount==ysize)
760               {
761                  break;
762               }
763            }
761764         }
762765      }
763766

Previous 199869 Revisions Next


© 1997-2024 The MAME Team