Previous 199869 Revisions Next

r21261 Thursday 21st February, 2013 at 15:18:50 UTC by David Haywood
expand the gfx data at startup from packed 10bpp words to 16bpp words(10 bits used) for easier / faster use
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21260r21261
452452   UINT8 sound_data, sound_fifo_full;
453453
454454   UINT8* m_compressedgfx;
455   UINT16* m_expanded_10bit_gfx;
456
455457   UINT32 get_20bit_data(UINT32 romoffset, int _20bitwordnum);
456458   UINT16 get_10bit_data(UINT32 romoffset, int _10bitwordnum);
457459
r21260r21261
620622
621623
622624
623#define READ_COMPRESSED_ROM(chip) \
624   m_compressedgfx[(chip)*0x400000 + romoffset] << 8 | m_compressedgfx[(chip)*0x0400000 + romoffset +1]; \
625625
626// this helps you feth the 20bit words from an address in the compressed data
627UINT32 coolridr_state::get_20bit_data(UINT32 romoffset, int _20bitwordnum)
628{
629   UINT16 testvalue, testvalue2;
630
631   int temp = _20bitwordnum & 3;
632   int inc = 0;
633   if (_20bitwordnum&4) inc = 5;
634
635   romoffset += (_20bitwordnum>>3)*2;
636
637
638
639   if (temp==0)
640   {
641      testvalue  = READ_COMPRESSED_ROM(0+inc);
642      testvalue2 = READ_COMPRESSED_ROM(1+inc);
643      return (testvalue << 4) | (testvalue2 & 0xf000) >> 12;
644   }
645   else if (temp==1)
646   {
647      testvalue  = READ_COMPRESSED_ROM(1+inc);
648      testvalue2 = READ_COMPRESSED_ROM(2+inc);
649      return ((testvalue & 0x0fff) << 8) | (testvalue2 & 0xff00) >> 8;
650   }
651   else if (temp==2)
652   {
653      testvalue  = READ_COMPRESSED_ROM(2+inc);
654      testvalue2 = READ_COMPRESSED_ROM(3+inc);
655      return ((testvalue & 0x00ff) << 12) | (testvalue2 & 0xfff0) >> 4;
656   }
657   else // temp == 3
658   {
659      testvalue  = READ_COMPRESSED_ROM(3+inc);
660      testvalue2 = READ_COMPRESSED_ROM(4+inc);
661      return ((testvalue & 0x000f) << 16) | (testvalue2);
662   }
663
664}
665
666UINT16 coolridr_state::get_10bit_data(UINT32 romoffset, int _10bitwordnum)
667{
668   UINT32 data = get_20bit_data(romoffset, _10bitwordnum>>1);
669   if (_10bitwordnum&1) return data & 0x3ff;
670   else return (data>>10) & 0x3ff;
671}
672
673626/* This is a RLE-based sprite blitter (US Patent #6,141,122), very unusual from Sega... */
674627WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
675628{
r21260r21261
11701123
11711124#if 0
11721125                  // logging only
1173                  if (!m_indirect_tile_enable)
1126                  //if (!m_indirect_tile_enable)
11741127                  {
11751128                     //if (m_hCellCount==0x10)
11761129                     {
r21260r21261
11791132                           for (int h = 0; h < m_hCellCount; h++)
11801133                           {
11811134                                 int lookupnum = h + (v*m_hCellCount);
1135                                 if (m_indirect_tile_enable)
1136                                 {
1137                                    const UINT32 memOffset = data;
1138                                    lookupnum = space.read_byte(memOffset + h + (v*m_hCellCount));
1139                                 }
11821140                                 UINT32 spriteNumber = get_20bit_data( m_b3romoffset, lookupnum);
11831141
11841142#if 0
r21260r21261
11951153                                 int compdataoffset = (m_b3romoffset + (spriteNumber>>3));
11961154                                 // do some logging for the sprite mentioned above 'investigate this sprite' looking at compressed data used in the first column
11971155                                 //if ((compdataoffset==0x3e9030) && (h==0))
1198                                 if ((compdataoffset >= 0x016590) && (compdataoffset<=0x0165e6) && (h==0))
1156                                 if (v==0)
11991157                                 {
12001158                                    printf("%05x (%08x,%d) | ",spriteNumber, compdataoffset, spriteNumber&7 );
12011159
r21260r21261
12771235
12781236
12791237                        // these should be 'cell numbers' (tile numbers) which look up RLE data?
1280                        UINT32 spriteNumber = get_20bit_data( m_b3romoffset, lookupnum );
1238                        UINT32 spriteNumber = (m_expanded_10bit_gfx[ (m_b3romoffset << 3) + (lookupnum<<1) +0 ] << 10) | (m_expanded_10bit_gfx[ (m_b3romoffset << 3) + (lookupnum<<1) + 1 ]);
12811239
12821240                        int i = 1;// skip first 10 bits for now
12831241                        int data_written = 0;
r21260r21261
12851243                        while (data_written<256)
12861244                        {
12871245
1288                           UINT16 compdata = get_10bit_data( m_b3romoffset, spriteNumber + i);
1246                           UINT16 compdata = m_expanded_10bit_gfx[ (m_b3romoffset << 3) + spriteNumber + i];
12891247
12901248                           if (((compdata & 0x300) == 0x000) || ((compdata & 0x300) == 0x100))
12911249                           {
r21260r21261
12931251                              int encodelength = (compdata & 0x03e)>>1;
12941252                              int data = (compdata & 0x3c0) >> 6;
12951253
1254                              // guess, blank tiles have the following form
1255                              // 00120 (00000024,0) | 010 03f
1256                              if (compdata&1) encodelength = 255;
1257
12961258                              while (data_written<256 && encodelength >=0)
12971259                              {
12981260                                 m_tempshape[data_written] = data;
r21260r21261
21302092}
21312093
21322094
2095
2096
2097#define READ_COMPRESSED_ROM(chip) \
2098   m_compressedgfx[(chip)*0x400000 + romoffset] << 8 | m_compressedgfx[(chip)*0x0400000 + romoffset +1]; \
2099
2100// this helps you feth the 20bit words from an address in the compressed data
2101UINT32 coolridr_state::get_20bit_data(UINT32 romoffset, int _20bitwordnum)
2102{
2103   UINT16 testvalue, testvalue2;
2104
2105   int temp = _20bitwordnum & 3;
2106   int inc = 0;
2107   if (_20bitwordnum&4) inc = 5;
2108
2109   romoffset += (_20bitwordnum>>3)*2;
2110
2111
2112
2113   if (temp==0)
2114   {
2115      testvalue  = READ_COMPRESSED_ROM(0+inc);
2116      testvalue2 = READ_COMPRESSED_ROM(1+inc);
2117      return (testvalue << 4) | (testvalue2 & 0xf000) >> 12;
2118   }
2119   else if (temp==1)
2120   {
2121      testvalue  = READ_COMPRESSED_ROM(1+inc);
2122      testvalue2 = READ_COMPRESSED_ROM(2+inc);
2123      return ((testvalue & 0x0fff) << 8) | (testvalue2 & 0xff00) >> 8;
2124   }
2125   else if (temp==2)
2126   {
2127      testvalue  = READ_COMPRESSED_ROM(2+inc);
2128      testvalue2 = READ_COMPRESSED_ROM(3+inc);
2129      return ((testvalue & 0x00ff) << 12) | (testvalue2 & 0xfff0) >> 4;
2130   }
2131   else // temp == 3
2132   {
2133      testvalue  = READ_COMPRESSED_ROM(3+inc);
2134      testvalue2 = READ_COMPRESSED_ROM(4+inc);
2135      return ((testvalue & 0x000f) << 16) | (testvalue2);
2136   }
2137
2138}
2139
2140UINT16 coolridr_state::get_10bit_data(UINT32 romoffset, int _10bitwordnum)
2141{
2142   UINT32 data = get_20bit_data(romoffset, _10bitwordnum>>1);
2143   if (_10bitwordnum&1) return data & 0x3ff;
2144   else return (data>>10) & 0x3ff;
2145}
2146
21332147void coolridr_state::machine_start()
21342148{
21352149//  machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
r21260r21261
21382152//   memcpy(memregion("soundcpu")->base(), memregion("maincpu")->base()+0x100000, 0x80000);
21392153//   m_soundcpu->reset();
21402154   m_compressedgfx = memregion( "gfx5" )->base();
2155   size_t  size    = memregion( "gfx5" )->bytes();
21412156
2157   // we're expanding 10bit packed data to 16bits(10 used)
2158   m_expanded_10bit_gfx = auto_alloc_array(machine(), UINT16, ((size/10)*16)/2);
2159
2160   for (int i=0;i<(0x800000*8)/2;i++)
2161   {
2162      m_expanded_10bit_gfx[i] = get_10bit_data( 0, i);
2163   }
2164
2165   if (0)
2166   {
2167      FILE *fp;
2168      char filename[256];
2169      sprintf(filename,"expanded_%s_gfx", machine().system().name);
2170      fp=fopen(filename, "w+b");
2171      if (fp)
2172      {   
2173         for (int i=0;i<(0x800000*8);i++)
2174         {
2175            fwrite((UINT8*)m_expanded_10bit_gfx+(i^1), 1, 1, fp);
2176         }
2177         fclose(fp);
2178         
2179      }
2180   }
2181
21422182}
21432183
21442184void coolridr_state::machine_reset()
r21260r21261
22942334   ROM_LOAD16_WORD_SWAP( "mpr-17645.ic6", 0x2400000, 0x0400000, CRC(56968d07) SHA1(e88c3d66ea05affb4681a25d155f097bd1b5a84b) ) // 0049
22952335
22962336
2297
22982337   ROM_REGION( 0x80000, "scsp1", 0 )   /* first SCSP's RAM */
22992338   ROM_FILL( 0x000000, 0x80000, 0 )
23002339

Previous 199869 Revisions Next


© 1997-2024 The MAME Team