From 1bf557eb7214364219b8e3ca32d373e35cd17757 Mon Sep 17 00:00:00 2001 From: mamehaze Date: Wed, 21 Jan 2015 17:53:27 +0000 Subject: misc 315-5881 (nw) --- src/mame/machine/315-5881_crypt.c | 25 +++++++++++++++---------- src/mame/machine/315-5881_crypt.h | 5 +++-- src/mame/machine/315-5881_helper.c | 4 ++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/mame/machine/315-5881_crypt.c b/src/mame/machine/315-5881_crypt.c index 6a21bb261b6..aa2558c1242 100644 --- a/src/mame/machine/315-5881_crypt.c +++ b/src/mame/machine/315-5881_crypt.c @@ -661,12 +661,15 @@ void sega_315_5881_crypt_device::enc_start() // in astrass the first block is 0xffff (for a 0x10000 block) followed by 0x3f3f (for a 0x1000 block) // etc. after each block a new header must be read, it looks like compressed and uncompressed blocks // can be mixed like this, I don't know if the length is src length of decompressed length. - int blockx = ((dec_header & 0x00ff) >> 0) + 1; - int blocky = ((dec_header & 0xff00) >> 8) + 1; + // deathcox and others confirm format as 0x20000 bit as compressed bit, 0x1ff00 bits as block size 1, 0x000ff bits as block size 2 + // for compressed streams the 'line size' is block size 1. + + int blockx = ((dec_header & 0x000000ff) >> 0) + 1; + int blocky = ((dec_header & 0x0001ff00) >> 8) + 1; block_size = blockx * blocky; if(dec_header & FLAG_COMPRESSED) { - line_buffer_size = dec_header & FLAG_LINE_SIZE_512 ? 512 : 256; + line_buffer_size = blocky; line_buffer_pos = line_buffer_size; buffer_bit = 7; } @@ -683,12 +686,16 @@ void sega_315_5881_crypt_device::enc_fill() buffer[i] = val; buffer[i+1] = val >> 8; block_pos+=2; - if (block_pos == block_size) + + if (!(dec_header & FLAG_COMPRESSED)) { - // if we reach the size specified we need to read a new header - // todo: how should this work with compressed blocks?? + if (block_pos == block_size) + { + // if we reach the size specified we need to read a new header + // todo: for compressed blocks this depends on OUTPUT size, not input size, so things get messy - enc_start(); + enc_start(); + } } } buffer_pos = 0; @@ -788,8 +795,6 @@ void sega_315_5881_crypt_device::line_fill() line_buffer_prev = lp; line_buffer_pos = 0; - UINT32 line_buffer_mask = line_buffer_size-1; - for(int i=0; i != line_buffer_size;) { // vlc 0: start of line // vlc 1: interior of line @@ -812,7 +817,7 @@ void sega_315_5881_crypt_device::line_fill() static int offsets[4] = {0, 1, 0, -1}; int offset = offsets[(tmp & 0x18) >> 3]; for(int j=0; j != count; j++) { - lc[i^1] = lp[((i+offset) & line_buffer_mask)^1]; + lc[i^1] = lp[((i+offset) % line_buffer_size)^1]; i++; } diff --git a/src/mame/machine/315-5881_crypt.h b/src/mame/machine/315-5881_crypt.h index 3a7d98997c9..2c55ff30c4d 100644 --- a/src/mame/machine/315-5881_crypt.h +++ b/src/mame/machine/315-5881_crypt.h @@ -42,8 +42,9 @@ protected: private: enum { - BUFFER_SIZE = 32768, LINE_SIZE = 512, - FLAG_COMPRESSED = 0x10000, FLAG_LINE_SIZE_512 = 0x20000 +// BUFFER_SIZE = 32768, LINE_SIZE = 512, + BUFFER_SIZE = 2, LINE_SIZE = 512, // this should be a stream, without any 'BUFFER_SIZE' ? I guess the SH4 DMA implementation isn't on a timer tho? + FLAG_COMPRESSED = 0x20000 }; UINT32 key; diff --git a/src/mame/machine/315-5881_helper.c b/src/mame/machine/315-5881_helper.c index f19574d2c26..cbb049656f6 100644 --- a/src/mame/machine/315-5881_helper.c +++ b/src/mame/machine/315-5881_helper.c @@ -32,8 +32,8 @@ struct game_keys static const struct game_keys keys_table[] = { // name key gameid # year chip label platform -// { "twcup98", 0x05200913 }, // 25209801 1998 317-5039-COM ST-V (this is correct key, but not yet working with our code) - { "twcup98", -1 }, // 25209801 1998 317-5039-COM ST-V + { "twcup98", 0x05200913 }, // 25209801 1998 317-5039-COM ST-V (this is correct key, but not yet working with our code) +// { "twcup98", -1 }, // 25209801 1998 317-5039-COM ST-V { "astrass", 0x052e2901 }, // 25349801 1998 317-5040-COM ST-V (yes, the 317-5040-COM chip was reused for 3 different games and on both Naomi and ST-V!) { "wldkicks", 0x052e2901 }, // 25209801 2000 317-5040-COM Naomi { "toukon4", 0x052e2901 }, // 25349801 2000 317-5040-COM Naomi -- cgit v1.2.3