Previous 199869 Revisions Next

r34533 Thursday 22nd January, 2015 at 10:27:42 UTC by David Haywood
fix decompression case for twcup98 title screen (nw)
[src/mame/machine]315-5881_crypt.c 315-5881_crypt.h

trunk/src/mame/machine/315-5881_crypt.c
r243044r243045
7070   if(!enc_ready)
7171      enc_start();
7272   if(dec_header & FLAG_COMPRESSED) {
73      if(line_buffer_pos == line_buffer_size)
73      if (line_buffer_pos == line_buffer_size) // if there's no data left to read..
74      {
75         if (done_compression == 1)
76            enc_start();
77           
78
79
7480         line_fill();
81      }
7582      base = line_buffer + line_buffer_pos;
7683      line_buffer_pos += 2;
7784   } else {
r243044r243045
94101{
95102   prot_cur_address = (prot_cur_address & 0x0000ffff) | (data << 16);
96103   enc_ready = false;
104
105   buffer_bit = 7;
106   buffer_bit2 = 15;
97107}
98108
99109void sega_315_5881_crypt_device::set_subkey(UINT16 data)
r243044r243045
645655
646656   prot_cur_address ++;
647657
658//   printf("get_decrypted_16 %04x\n", res);
659
648660   return res;
649661}
650662
651663
652664void sega_315_5881_crypt_device::enc_start()
653665{
654   dec_hist = 0; // seems to be needed by astrass at least otherwise any call after the first one will be influenced by the one before it.
655666   block_pos = 0;
667   done_compression = 0;
656668   buffer_pos = BUFFER_SIZE;
657   dec_header = get_decrypted_16() << 16;
669   
670   if (buffer_bit2 != 15) // if we have remaining bits in the decompression buffer we shouldn't read the next word yet but should instead use the bits we have?? (twcup98) (might just be because we should be pulling bytes not words?)
671   {
672//      printf("buffer_bit2 is %d\n", buffer_bit2);
673      dec_header = (buffer2a & 0x0003) << 16;
674   }
675   else
676   {
677      dec_hist = 0; // seems to be needed by astrass at least otherwise any call after the first one will be influenced by the one before it.
678      dec_header = get_decrypted_16() << 16;
679   }
680
658681   dec_header |= get_decrypted_16();
659682
660683   // the lower header bits are 2 values that multiply together to get the current stream length
r243044r243045
782805   if (buffer_bit2 == 15)
783806   {
784807      buffer_bit2 = 0;
785      UINT16 buffer2a = get_decrypted_16();
808      buffer2a = get_decrypted_16();
786809      buffer2[0] = buffer2a;
787810      buffer2[1] = buffer2a >> 8;
788811   //   block_pos+=2;
r243044r243045
857880      }
858881   }
859882
883   block_pos++;
860884   if (block_numlines == block_pos)
861885   {
862      enc_start();
886      done_compression = 1;
863887   }
864888   else
865889   {
866      block_pos++;
867890   }
868891}
trunk/src/mame/machine/315-5881_crypt.h
r243044r243045
5858
5959   int buffer_pos, line_buffer_pos, line_buffer_size, buffer_bit, buffer_bit2;
6060   UINT8 buffer2[2];
61   UINT16 buffer2a;
6162
6263   int block_size;
6364   int block_pos;
6465   int block_numlines;
66   int done_compression;
6567
6668   struct sbox {
6769      UINT8 table[64];


Previous 199869 Revisions Next


© 1997-2024 The MAME Team