Previous 199869 Revisions Next

r21247 Thursday 21st February, 2013 at 01:13:09 UTC by David Haywood
improve code to parse compressed data
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21246r21247
450450   UINT8 sound_data;
451451
452452   UINT8* m_compressedgfx;
453   UINT32 get_20bit_data(UINT32 romoffset, int _20bitwordnum);
453454
454455   DECLARE_READ32_MEMBER(sysh1_sound_dma_r);
455456   DECLARE_WRITE32_MEMBER(sysh1_sound_dma_w);
r21246r21247
613614#endif
614615
615616
617
618
619#define READ_COMPRESSED_ROM(chip) \
620   m_compressedgfx[(chip)*0x400000 + romoffset] << 8 | m_compressedgfx[(chip)*0x0400000 + romoffset +1]; \
621
622// this helps you feth the 20bit words from an address in the compressed data
623UINT32 coolridr_state::get_20bit_data(UINT32 romoffset, int _20bitwordnum)
624{
625   UINT16 testvalue, testvalue2;
626
627   int temp = _20bitwordnum & 3;
628   int inc = 0;
629   if (_20bitwordnum&4) inc = 5;
630
631   romoffset += (_20bitwordnum>>3)*2;
632
633
634
635   if (temp==0)
636   {
637      testvalue  = READ_COMPRESSED_ROM(0+inc);
638      testvalue2 = READ_COMPRESSED_ROM(1+inc);
639      return (testvalue << 4) | (testvalue2 & 0xf000) >> 12;
640   }
641   else if (temp==1)
642   {
643      testvalue  = READ_COMPRESSED_ROM(1+inc);
644      testvalue2 = READ_COMPRESSED_ROM(2+inc);
645      return ((testvalue & 0x0fff) << 8) | (testvalue2 & 0xff00) >> 8;
646   }
647   else if (temp==2)
648   {
649      testvalue  = READ_COMPRESSED_ROM(2+inc);
650      testvalue2 = READ_COMPRESSED_ROM(3+inc);
651      return ((testvalue & 0x00ff) << 12) | (testvalue2 & 0xfff0) >> 4;
652   }
653   else // temp == 3
654   {
655      testvalue  = READ_COMPRESSED_ROM(3+inc);
656      testvalue2 = READ_COMPRESSED_ROM(4+inc);
657      return ((testvalue & 0x000f) << 16) | (testvalue2);
658   }
659
660}
661
616662/* This is a RLE-based sprite blitter (US Patent #6,141,122), very unusual from Sega... */
617663WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
618664{
r21246r21247
798844#if 0
799845                     // if we look in rom IC6 (+0x2400000) then the word before our offset is very often 0x0000 probably indicating that's the last word used
800846                     printf("rom offset %08x, previous values : ", m_b3romoffset);
801                     for (int i=0;i<10;i++)
847                     for (int i=0;i<8;i++)
802848                     {
803                        UINT16 testvalue = m_compressedgfx[i*0x400000 + m_b3romoffset - 2] << 8 | m_compressedgfx[i*0x0400000 + m_b3romoffset - 1];
804                        if ((i==0) || (i==5)) printf("%04x", testvalue);
805                        if ((i==1) || (i==6)) printf("%01x %03x", (testvalue & 0xf000) >> 12, testvalue & 0x0fff);
806                        if ((i==2) || (i==7)) printf("%02x %02x", (testvalue & 0xff00) >> 8, testvalue & 0x00ff);
807                        if ((i==3) || (i==8)) printf("%03x %01x", (testvalue & 0xfff0) >> 4, testvalue & 0x000f);
808                        if ((i==4) || (i==9)) printf("%04x ", testvalue);
849                        UINT32 dat20 = get_20bit_data( m_b3romoffset, i);
850                        printf("%05x ",dat20);
809851                     }
810852                     printf("\n");
811853#endif
r21246r21247
815857                     // 0008, 0000, 8000, 0800, 0080, 0008, 0000, 8000, 0800, 0080,
816858                     //   1     2     3     4     5     6     7     8     9    10
817859                     // so you can see 1/6  2/7,  3/8,  4/9,  5/10 are often similar or the same
818                     printf("rom offset %08x, values : ", m_b3romoffset);
819                     for (int i=0;i<10;i++)
860                     if (m_b3romoffset == 0x0000848e)
820861                     {
821                        UINT16 testvalue = m_compressedgfx[i*0x400000 + m_b3romoffset] << 8 | m_compressedgfx[i*0x0400000 + m_b3romoffset +1];
822                        if ((i==0) || (i==5)) printf("%04x", testvalue);
823                        if ((i==1) || (i==6)) printf("%01x %03x", (testvalue & 0xf000) >> 12, testvalue & 0x0fff);
824                        if ((i==2) || (i==7)) printf("%02x %02x", (testvalue & 0xff00) >> 8, testvalue & 0x00ff);
825                        if ((i==3) || (i==8)) printf("%03x %01x", (testvalue & 0xfff0) >> 4, testvalue & 0x000f);
826                        if ((i==4) || (i==9)) printf("%04x ", testvalue);
827
862                        printf("rom offset %08x, values : \n", m_b3romoffset);
863                     
864                        for (int b=0;b<8;b++)
865                        {
866                           for (int i=0;i<8;i++)
867                           {
868                              UINT32 dat20 = get_20bit_data( m_b3romoffset, i+b*8);
869                              printf("%05x ",dat20);
870                           }
871                           printf("\n");
872                        }
873                        printf("\n");
828874                     }
829                     printf("\n");
875                     /*
876                     rom offset 0000848e, values :
877                     00a00 00a00 00a00 00a00 00a00 00a02 00a3d 00a98
878                     00afa 00b3f 00b95 00be9 00c4d 00c89 00a00 00cd3
879                     00d17 00d4b 00d94 00dee 00e50 00eb0 00f16 00f62
880                     00fce 00a00 00a00 00a00 00a00 00a00 00a00 00a00
881                     00a00 00a00 00a00 00a00 00ff2 0101d 01060 0109d
882                     010d2 01112 01148 01194 011be 00a00 011f1 0121c
883                     0123f 01272 012af 012f0 0132c 01377 013af 01400
884                     00a00 00a00 00a00 00a00 00a00 00a00 00000 00000
885                     */
830886
831887
888
889     
890
832891                     // these are used for slider bars in test mode
833892                     //   rom offset 00140000, values : 0008, 0000, 8000, 0800, 0080, 0008, 0000, 8000, 0800, 0080,
834893                     //   rom offset 00140008, values : 0004, 9000, 4900, 0490, 0049, 0004, 9000, 4900, 0490, 0049,
r21246r21247
10391098
10401099                        // It's unknown if it's row-major or column-major
10411100                        // TODO: Study the CRT test and "Cool Riders" logo for clues.
1042                        UINT8 spriteNumber = 0;
1101                        UINT32 spriteNumber = 0;
10431102
10441103                        // with this bit enabled the tile numbers gets looked up using 'data' (which would be m_blit11) (eg 03f40000 for startup text)
10451104                        // this allows text strings to be written as 8-bit ascii in one area (using command 0x10), and drawn using multi-width sprites
r21246r21247
10561115                           continue;
10571116   #endif
10581117                        }
1118                        else
1119                        {
1120                           int lookupnum = h + (v*h);
1121                           
1122                           // these should be 'cell numbers' (tile numbers) which look up RLE data?
1123                           spriteNumber = get_20bit_data( m_b3romoffset, lookupnum);
1124                           /*
10591125
1126                           printf("%05x ",spriteNumber);
1127                           //if ((h == m_hCellCount-1) && (v == m_vCellCount-1))
1128                           //   printf("\n");
10601129
1130                           if ((h == m_hCellCount-1))
1131                              printf("\n");
1132
1133                           */
1134
1135                           //if (spriteNumber == 0x00)
1136                           //   continue;
1137                           
1138                        }
1139
10611140                        int blockwide = ((16*m_hZoom)/0x40)-1;
10621141                        int blockhigh = ((16*m_vZoom)/0x40)-1;
10631142                        // hack
r21246r21247
11111190                        }
11121191                     }
11131192                  }
1193
1194                  //printf("\n");
1195
11141196               }
11151197            }
11161198            else

Previous 199869 Revisions Next


© 1997-2024 The MAME Team