Previous 199869 Revisions Next

r34525 Wednesday 21st January, 2015 at 19:21:00 UTC by David Haywood
(nw)
[src/mame/machine]315-5881_crypt.c 315-5881_crypt.h

trunk/src/mame/machine/315-5881_crypt.c
r243036r243037
664664   // deathcox and others confirm format as 0x20000 bit as compressed bit, 0x1ff00 bits as block size 1, 0x000ff bits as block size 2
665665   // for compressed streams the 'line size' is block size 1. 
666666
667   int blockx = ((dec_header & 0x000000ff) >> 0) + 1;
667   block_numlines = ((dec_header & 0x000000ff) >> 0) + 1;
668668   int blocky = ((dec_header & 0x0001ff00) >> 8) + 1;
669   block_size = blockx * blocky;
669   block_size = block_numlines * blocky;
670670
671671   if(dec_header & FLAG_COMPRESSED) {
672672      line_buffer_size = blocky;
673673      line_buffer_pos = line_buffer_size;
674674      buffer_bit = 7;
675      buffer_bit2 = 15;
675676   }
676677
677//   printf("header %08x\n", dec_header);
678   printf("header %08x\n", dec_header);
678679   enc_ready = true;
679680}
680681
r243036r243037
775776
776777int sega_315_5881_crypt_device::get_compressed_bit()
777778{
778   if(buffer_pos == BUFFER_SIZE)
779      enc_fill();
780   int res = (buffer[buffer_pos^1] >> buffer_bit) & 1;
779//   if(buffer_pos == BUFFER_SIZE)
780//      enc_fill();
781
782   if (buffer_bit2 == 15)
783   {
784      buffer_bit2 = 0;
785      UINT16 buffer2a = get_decrypted_16();
786      buffer2[0] = buffer2a;
787      buffer2[1] = buffer2a >> 8;
788   //   block_pos+=2;
789      buffer_pos = 0;
790
791   }
792   else
793   {
794      buffer_bit2++;
795   }
796
797//   if (buffer_bit ==7) printf("using byte %02x\n", buffer2[(buffer_pos&1) ^ 1]);
798
799   int res = (buffer2[(buffer_pos&1)^1] >> buffer_bit) & 1;
781800   buffer_bit--;
782801   if(buffer_bit == -1) {
783802      buffer_bit = 7;
r243036r243037
785804   }
786805   return res;
787806}
788
789807void sega_315_5881_crypt_device::line_fill()
790808{
791809   assert(line_buffer_pos == line_buffer_size);
r243036r243037
838856         }
839857      }
840858   }
859
860   if (block_numlines == block_pos)
861   {
862      enc_start();
863   }
864   else
865   {
866      block_pos++;
867   }
841868}
trunk/src/mame/machine/315-5881_crypt.h
r243036r243037
5656
5757   bool enc_ready;
5858
59   int buffer_pos, line_buffer_pos, line_buffer_size, buffer_bit;
59   int buffer_pos, line_buffer_pos, line_buffer_size, buffer_bit, buffer_bit2;
60   UINT8 buffer2[2];
61
6062   int block_size;
6163   int block_pos;
64   int block_numlines;
6265
6366   struct sbox {
6467      UINT8 table[64];


Previous 199869 Revisions Next


© 1997-2024 The MAME Team