mirror of
https://github.com/holub/mame
synced 2025-05-16 19:00:43 +03:00
Clean-ups and version bump
This commit is contained in:
parent
2f8094ea33
commit
cf4b58b6f6
@ -1457,9 +1457,9 @@ void media_identifier::identify(const char *filename)
|
||||
// crude, need real UTF16->UTF8 conversion ideally
|
||||
for (int j=0;j<namelen;j++)
|
||||
{
|
||||
temp3[j] = (UINT8)temp[j];
|
||||
temp3[j] = (UINT8)temp[j];
|
||||
}
|
||||
|
||||
|
||||
if (!(f->IsDir) && (f->Size != 0))
|
||||
{
|
||||
UINT8 *data = global_alloc_array(UINT8, f->Size);
|
||||
|
@ -10485,8 +10485,8 @@ M68KMAKE_OP(cinv, 32, ., .)
|
||||
{
|
||||
UINT16 ir = mc68kcpu->ir;
|
||||
UINT8 cache = (ir >> 6) & 3;
|
||||
// UINT8 scope = (ir >> 3) & 3;
|
||||
// logerror("68040 %s: pc=%08x ir=%04x cache=%d scope=%d register=%d\n", ir & 0x0020 ? "cpush" : "cinv", REG_PPC(mc68kcpu), ir, cache, scope, ir & 7);
|
||||
// UINT8 scope = (ir >> 3) & 3;
|
||||
// logerror("68040 %s: pc=%08x ir=%04x cache=%d scope=%d register=%d\n", ir & 0x0020 ? "cpush" : "cinv", REG_PPC(mc68kcpu), ir, cache, scope, ir & 7);
|
||||
switch (cache)
|
||||
{
|
||||
case 2:
|
||||
|
@ -610,11 +610,11 @@ INLINE UINT32 get_dt3_table_entry(m68ki_cpu_core *m68k, UINT32 tptr, UINT8 fc, U
|
||||
static UINT32 psrp = 0, purp=0;
|
||||
if(psrp != m68k->mmu_srp_aptr) {
|
||||
psrp = m68k->mmu_srp_aptr;
|
||||
// fprintf(stderr, "srp = %08x\n", psrp);
|
||||
// fprintf(stderr, "srp = %08x\n", psrp);
|
||||
}
|
||||
if(purp != m68k->mmu_urp_aptr) {
|
||||
purp = m68k->mmu_urp_aptr;
|
||||
// fprintf(stderr, "urp = %08x\n", purp);
|
||||
// fprintf(stderr, "urp = %08x\n", purp);
|
||||
}
|
||||
|
||||
// is UDT marked valid?
|
||||
@ -791,7 +791,7 @@ void m68881_mmu_ops(m68ki_cpu_core *m68k)
|
||||
}
|
||||
else if ((m68k->ir & 0xffe0) == 0xf500)
|
||||
{
|
||||
// logerror("68040 pflush: pc=%08x ir=%04x opmode=%d register=%d\n", REG_PPC(m68k), m68k->ir, (m68k->ir >> 3) & 3, m68k->ir & 7);
|
||||
// logerror("68040 pflush: pc=%08x ir=%04x opmode=%d register=%d\n", REG_PPC(m68k), m68k->ir, (m68k->ir >> 3) & 3, m68k->ir & 7);
|
||||
pmmu_atc_flush(m68k);
|
||||
}
|
||||
else // the rest are 1111000xxxXXXXXX where xxx is the instruction family
|
||||
|
@ -375,7 +375,7 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], astring &error_stri
|
||||
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
update_slot_options();
|
||||
while (add_slot_options(false));
|
||||
add_device_options(true);
|
||||
add_device_options(true);
|
||||
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
return result;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ bool hash_collection::add_from_string(char type, const char *buffer, int length)
|
||||
// handle CRCs
|
||||
if (type == HASH_CRC)
|
||||
return m_has_crc32 = m_crc32.from_string(buffer, length);
|
||||
|
||||
|
||||
// handle SHA1s
|
||||
else if (type == HASH_SHA1)
|
||||
return m_has_sha1 = m_sha1.from_string(buffer, length);
|
||||
@ -195,14 +195,14 @@ bool hash_collection::add_from_string(char type, const char *buffer, int length)
|
||||
bool hash_collection::remove(char type)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
||||
// handle CRCs
|
||||
if (type == HASH_CRC)
|
||||
{
|
||||
result = m_has_crc32;
|
||||
m_has_crc32 = false;
|
||||
}
|
||||
|
||||
|
||||
// handle SHA1s
|
||||
else if (type == HASH_SHA1)
|
||||
{
|
||||
@ -222,12 +222,12 @@ bool hash_collection::remove(char type)
|
||||
const char *hash_collection::internal_string(astring &buffer) const
|
||||
{
|
||||
buffer.reset();
|
||||
|
||||
|
||||
// handle CRCs
|
||||
astring temp;
|
||||
if (m_has_crc32)
|
||||
buffer.cat(HASH_CRC).cat(m_crc32.as_string(temp));
|
||||
|
||||
|
||||
// handle SHA1s
|
||||
if (m_has_sha1)
|
||||
buffer.cat(HASH_SHA1).cat(m_sha1.as_string(temp));
|
||||
@ -250,7 +250,7 @@ const char *hash_collection::macro_string(astring &buffer) const
|
||||
astring temp;
|
||||
if (m_has_crc32)
|
||||
buffer.cat("CRC(").cat(m_crc32.as_string(temp)).cat(") ");
|
||||
|
||||
|
||||
// handle SHA1s
|
||||
if (m_has_sha1)
|
||||
buffer.cat("SHA1(").cat(m_sha1.as_string(temp)).cat(") ");
|
||||
@ -277,7 +277,7 @@ const char *hash_collection::attribute_string(astring &buffer) const
|
||||
astring temp;
|
||||
if (m_has_crc32)
|
||||
buffer.cat("crc=\"").cat(m_crc32.as_string(temp)).cat("\" ");
|
||||
|
||||
|
||||
// handle SHA1s
|
||||
if (m_has_sha1)
|
||||
buffer.cat("sha1=\"").cat(m_sha1.as_string(temp)).cat("\" ");
|
||||
@ -352,7 +352,7 @@ void hash_collection::begin(const char *types)
|
||||
// by default use all types
|
||||
if (types == NULL)
|
||||
m_creator->m_doing_crc32 = m_creator->m_doing_sha1 = true;
|
||||
|
||||
|
||||
// otherwise, just allocate the ones that are specified
|
||||
else
|
||||
{
|
||||
@ -369,7 +369,7 @@ void hash_collection::begin(const char *types)
|
||||
void hash_collection::buffer(const UINT8 *data, UINT32 length)
|
||||
{
|
||||
assert(m_creator != NULL);
|
||||
|
||||
|
||||
// append to each active hash
|
||||
if (m_creator->m_doing_crc32)
|
||||
m_creator->m_crc32_creator.append(data, length);
|
||||
@ -385,24 +385,24 @@ void hash_collection::buffer(const UINT8 *data, UINT32 length)
|
||||
void hash_collection::end()
|
||||
{
|
||||
assert(m_creator != NULL);
|
||||
|
||||
|
||||
// default to getting nothing
|
||||
m_has_crc32 = m_has_sha1 = false;
|
||||
|
||||
|
||||
// finish up the CRC32
|
||||
if (m_creator->m_doing_crc32)
|
||||
{
|
||||
m_has_crc32 = true;
|
||||
m_crc32 = m_creator->m_crc32_creator.finish();
|
||||
}
|
||||
|
||||
|
||||
// finish up the SHA1
|
||||
if (m_creator->m_doing_sha1)
|
||||
{
|
||||
m_has_sha1 = true;
|
||||
m_sha1 = m_creator->m_sha1_creator.finish();
|
||||
}
|
||||
|
||||
|
||||
// nuke the creator
|
||||
delete m_creator;
|
||||
m_creator = NULL;
|
||||
@ -418,13 +418,13 @@ void hash_collection::copyfrom(const hash_collection &src)
|
||||
{
|
||||
// copy flags directly
|
||||
m_flags = src.m_flags;
|
||||
|
||||
|
||||
// copy hashes
|
||||
m_has_crc32 = src.m_has_crc32;
|
||||
m_crc32 = src.m_crc32;
|
||||
m_has_sha1 = src.m_has_sha1;
|
||||
m_sha1 = src.m_sha1;
|
||||
|
||||
// don't copy creators
|
||||
// don't copy creators
|
||||
m_creator = NULL;
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ static void write_sector_done(ide_state *ide)
|
||||
/* now do the write */
|
||||
if (ide->drive[ide->cur_drive].slot) {
|
||||
count = ide->drive[ide->cur_drive].slot->write_sector(lba, ide->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* by default, mark the buffer ready and the seek complete */
|
||||
ide->status |= IDE_STATUS_BUFFER_READY;
|
||||
@ -1174,7 +1174,7 @@ static void handle_command(ide_state *ide, UINT8 command)
|
||||
ide->status &= ~IDE_STATUS_ERROR;
|
||||
ide->error = IDE_ERROR_NONE;
|
||||
ide->drive[ide->cur_drive].slot->set_geometry(ide->sector_count,ide->drive[ide->cur_drive].cur_head + 1);
|
||||
|
||||
|
||||
/* signal an interrupt */
|
||||
signal_delayed_interrupt(ide, MINIMUM_COMMAND_TIME, 0);
|
||||
break;
|
||||
@ -1921,7 +1921,7 @@ static DEVICE_START( ide_controller )
|
||||
static DEVICE_RESET( ide_controller )
|
||||
{
|
||||
ide_state *ide = get_safe_token(device);
|
||||
LOG(("IDE controller reset performed\n"));
|
||||
LOG(("IDE controller reset performed\n"));
|
||||
/* reset the drive state */
|
||||
ide->cur_drive = 0;
|
||||
ide->status = IDE_STATUS_DRIVE_READY | IDE_STATUS_SEEK_COMPLETE;
|
||||
@ -1938,7 +1938,7 @@ SLOT_INTERFACE_START(ide_image_devices)
|
||||
SLOT_INTERFACE_END
|
||||
|
||||
SLOT_INTERFACE_START(ide_devices)
|
||||
SLOT_INTERFACE("hdd", IDE_HARDDISK)
|
||||
SLOT_INTERFACE("hdd", IDE_HARDDISK)
|
||||
SLOT_INTERFACE_END
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -2060,7 +2060,7 @@ void ide_hdd_device::device_reset()
|
||||
{
|
||||
m_handle = get_disk_handle(machine(), owner()->tag());
|
||||
m_disk = hard_disk_open(m_handle);
|
||||
|
||||
|
||||
if (m_disk != NULL)
|
||||
{
|
||||
const hard_disk_info *hdinfo = hard_disk_get_info(m_disk);
|
||||
@ -2072,11 +2072,11 @@ void ide_hdd_device::device_reset()
|
||||
if (PRINTF_IDE_COMMANDS) mame_printf_debug("CHS: %d %d %d\n", m_num_cylinders, m_num_heads, m_num_sectors);
|
||||
mame_printf_debug("CHS: %d %d %d\n", m_num_cylinders, m_num_heads, m_num_sectors);
|
||||
}
|
||||
// build the features page
|
||||
// build the features page
|
||||
UINT32 metalength;
|
||||
if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE)
|
||||
ide_build_features();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -2137,7 +2137,7 @@ void ide_hdd_image_device::device_reset()
|
||||
m_num_heads = hdinfo->heads;
|
||||
if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", m_num_cylinders, m_num_heads, m_num_sectors);
|
||||
}
|
||||
// build the features page
|
||||
// build the features page
|
||||
UINT32 metalength;
|
||||
if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE)
|
||||
ide_build_features();
|
||||
@ -2152,7 +2152,7 @@ void ide_hdd_image_device::device_reset()
|
||||
//-------------------------------------------------
|
||||
static MACHINE_CONFIG_FRAGMENT( hdd_image )
|
||||
MCFG_HARDDISK_ADD( "harddisk" )
|
||||
MACHINE_CONFIG_END
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
machine_config_constructor ide_hdd_image_device::device_mconfig_additions() const
|
||||
{
|
||||
|
@ -33,8 +33,8 @@ public:
|
||||
public:
|
||||
virtual int read_sector(UINT32 lba, void *buffer) = 0;
|
||||
virtual int write_sector(UINT32 lba, const void *buffer) = 0;
|
||||
|
||||
UINT8 *get_features() { return m_features;}
|
||||
|
||||
UINT8 *get_features() { return m_features;}
|
||||
|
||||
UINT16 get_cylinders() { return m_num_cylinders; }
|
||||
UINT16 get_sectors() { return m_num_sectors; }
|
||||
@ -59,12 +59,12 @@ public:
|
||||
ide_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
int read_sector(UINT32 lba, void *buffer) { return (m_dev) ? m_dev->read_sector(lba,buffer) : 0; }
|
||||
int write_sector(UINT32 lba, const void *buffer) { return (m_dev) ? m_dev->write_sector(lba,buffer) : 0; }
|
||||
UINT8 *get_features() { return (m_dev) ? m_dev->get_features() : NULL;}
|
||||
int write_sector(UINT32 lba, const void *buffer) { return (m_dev) ? m_dev->write_sector(lba,buffer) : 0; }
|
||||
UINT8 *get_features() { return (m_dev) ? m_dev->get_features() : NULL;}
|
||||
|
||||
UINT16 get_cylinders() { return (m_dev) ? m_dev->get_cylinders() : 0; }
|
||||
UINT16 get_sectors() { return (m_dev) ? m_dev->get_sectors() : 0; }
|
||||
UINT16 get_heads() { return (m_dev) ? m_dev->get_heads() : 0; }
|
||||
UINT16 get_heads() { return (m_dev) ? m_dev->get_heads() : 0; }
|
||||
void set_geometry(UINT8 sectors, UINT8 heads) { if (m_dev) m_dev->set_geometry(sectors,heads); }
|
||||
bool is_ready() { return (m_dev) ? m_dev->is_ready() : false; }
|
||||
void read_key(UINT8 key[]) { if (m_dev) m_dev->read_key(key); }
|
||||
@ -96,7 +96,7 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
|
||||
void ide_build_features();
|
||||
virtual bool is_ready() { return (m_disk != NULL); }
|
||||
protected:
|
||||
|
@ -68,7 +68,7 @@ void nscsi_bus_device::regen_ctrl(int refid)
|
||||
}
|
||||
logerror("\n");
|
||||
}
|
||||
|
||||
|
||||
octrl = octrl ^ ctrl;
|
||||
if(octrl)
|
||||
for(int i=0; i<devcnt; i++)
|
||||
@ -357,7 +357,7 @@ void nscsi_full_device::step(bool timeout)
|
||||
} else
|
||||
target_recv_byte();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
logerror("%s: step() unexpected state %d.%d\n",
|
||||
tag(),
|
||||
@ -442,7 +442,7 @@ nscsi_full_device::control *nscsi_full_device::buf_control_pop()
|
||||
buf_control_rpos++;
|
||||
if(buf_control_rpos == buf_control_wpos)
|
||||
buf_control_rpos = buf_control_wpos = 0;
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
void nscsi_full_device::scsi_status_complete(UINT8 st)
|
||||
|
@ -7,7 +7,7 @@
|
||||
MCFG_DEVICE_ADD(_tag, NSCSI_BUS, 0)
|
||||
|
||||
#define MCFG_NSCSI_DEVICE_ADD(_tag, _subtag, _type, _clock) \
|
||||
MCFG_DEVICE_ADD(_tag, NSCSI_CONNECTOR, 0) \
|
||||
MCFG_DEVICE_ADD(_tag, NSCSI_CONNECTOR, 0) \
|
||||
downcast<nscsi_connector *>(device)->set_fixed_device(_subtag); \
|
||||
MCFG_DEVICE_ADD(_tag ":" _subtag, _type, _clock)
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
MCFG_NSCSI_DEVICE_ADD(_tag, _subtag, _type, _clock)
|
||||
|
||||
#define MCFG_NSCSI_ADD(_tag, _slot_intf, _def_slot, _def_inp) \
|
||||
MCFG_DEVICE_ADD(_tag, NSCSI_CONNECTOR, 0) \
|
||||
MCFG_DEVICE_ADD(_tag, NSCSI_CONNECTOR, 0) \
|
||||
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
|
||||
|
||||
class nscsi_device;
|
||||
@ -336,7 +336,7 @@ private:
|
||||
|
||||
control *buf_control_push();
|
||||
control *buf_control_pop();
|
||||
|
||||
|
||||
void step(bool timeout);
|
||||
void target_recv_byte();
|
||||
void target_send_byte(UINT8 val);
|
||||
|
@ -83,7 +83,7 @@ void nscsi_harddisk_device::scsi_command()
|
||||
bad_lun();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int page = scsi_cmdbuf[2];
|
||||
int size = scsi_cmdbuf[4];
|
||||
switch(page) {
|
||||
|
@ -456,13 +456,13 @@ static void dump_wrong_and_correct_checksums(rom_load_data *romdata, const hash_
|
||||
romdata->errorstring.catprintf(" EXPECTED: %s\n", hashes.macro_string(tempstr));
|
||||
romdata->errorstring.catprintf(" FOUND: %s\n", acthashes.macro_string(tempstr));
|
||||
/*
|
||||
// warn about any ill-formed hashes
|
||||
for (hash_base *hash = hashes.first(); hash != NULL; hash = hash->next())
|
||||
if (hash->parse_error())
|
||||
{
|
||||
romdata->errorstring.catprintf("\tInvalid %s checksum treated as 0 (check leading zeros)\n", hash->name());
|
||||
romdata->warnings++;
|
||||
}
|
||||
// warn about any ill-formed hashes
|
||||
for (hash_base *hash = hashes.first(); hash != NULL; hash = hash->next())
|
||||
if (hash->parse_error())
|
||||
{
|
||||
romdata->errorstring.catprintf("\tInvalid %s checksum treated as 0 (check leading zeros)\n", hash->name());
|
||||
romdata->warnings++;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@ -1157,11 +1157,11 @@ static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd
|
||||
{
|
||||
astring fullpath(diff_file.fullpath());
|
||||
diff_file.close();
|
||||
|
||||
|
||||
LOG(("Opening differencing image file: %s\n", fullpath.cstr()));
|
||||
return diff_chd.open(fullpath, true, &source);
|
||||
}
|
||||
|
||||
|
||||
/* didn't work; try creating it instead */
|
||||
LOG(("Creating differencing image: %s\n", fname.cstr()));
|
||||
diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
@ -1177,7 +1177,7 @@ static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd
|
||||
chd_error err = diff_chd.create(fullpath, source.logical_bytes(), source.hunk_bytes(), compression, source);
|
||||
if (err != CHDERR_NONE)
|
||||
return err;
|
||||
|
||||
|
||||
return diff_chd.clone_all_metadata(source);
|
||||
}
|
||||
|
||||
@ -1199,7 +1199,7 @@ static void process_disk_entries(rom_load_data *romdata, const char *regiontag,
|
||||
if (ROMENTRY_ISFILE(romp))
|
||||
{
|
||||
open_chd *chd = global_alloc(open_chd(regiontag));
|
||||
|
||||
|
||||
hash_collection hashes(ROM_GETHASHDATA(romp));
|
||||
chd_error err;
|
||||
|
||||
|
@ -6,17 +6,17 @@
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Playback of pre-recorded samples. Used for high-level simulation of
|
||||
discrete sound circuits where proper low-level simulation isn't
|
||||
available. Also used for tape loops and similar.
|
||||
Playback of pre-recorded samples. Used for high-level simulation of
|
||||
discrete sound circuits where proper low-level simulation isn't
|
||||
available. Also used for tape loops and similar.
|
||||
|
||||
Current limitations
|
||||
- Only supports single channel samples!
|
||||
Current limitations
|
||||
- Only supports single channel samples!
|
||||
|
||||
Considerations
|
||||
- Maybe this should be part of the presentation layer
|
||||
(artwork etc.) with samples specified in .lay files instead of
|
||||
in drivers?
|
||||
Considerations
|
||||
- Maybe this should be part of the presentation layer
|
||||
(artwork etc.) with samples specified in .lay files instead of
|
||||
in drivers?
|
||||
|
||||
****************************************************************************
|
||||
|
||||
@ -135,7 +135,7 @@ void samples_device::start(UINT8 channel, UINT32 samplenum, bool loop)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// start_raw - start playing an externally
|
||||
// start_raw - start playing an externally
|
||||
// provided sample
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -249,7 +249,7 @@ UINT32 samples_device::base_frequency(UINT8 channel) const
|
||||
|
||||
//-------------------------------------------------
|
||||
// playing - return true if a sample is still
|
||||
// playing on the given channel
|
||||
// playing on the given channel
|
||||
//-------------------------------------------------
|
||||
|
||||
bool samples_device::playing(UINT8 channel) const
|
||||
@ -318,7 +318,7 @@ void samples_device::device_reset()
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_post_load - handle updating after a
|
||||
// restore
|
||||
// restore
|
||||
//-------------------------------------------------
|
||||
|
||||
void samples_device::device_post_load()
|
||||
@ -422,7 +422,7 @@ void samples_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// read_sample - read a WAV or FLAC file as a
|
||||
// read_sample - read a WAV or FLAC file as a
|
||||
// sample
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -436,7 +436,7 @@ bool samples_device::read_sample(emu_file &file, loaded_sample &sample)
|
||||
mame_printf_warning("Unable to read %s, 0-byte file?\n", file.filename());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// look for the appropriate RIFF tag
|
||||
if (memcmp(&buf[0], "RIFF", 4) == 0)
|
||||
return read_wav_sample(file, sample);
|
||||
@ -458,7 +458,7 @@ bool samples_device::read_wav_sample(emu_file &file, loaded_sample &sample)
|
||||
printf("Reading %s as WAV\n", file.filename());
|
||||
// we already read the opening 'WAVE' header
|
||||
UINT32 offset = 4;
|
||||
|
||||
|
||||
// get the total size
|
||||
UINT32 filesize;
|
||||
offset += file.read(&filesize, 4);
|
||||
@ -593,12 +593,12 @@ printf("Reading %s as FLAC\n", file.filename());
|
||||
return false;
|
||||
if (decoder.bits_per_sample() != 16)
|
||||
return false;
|
||||
|
||||
|
||||
// resize the array and read
|
||||
sample.data.resize(sample.length);
|
||||
if (!decoder.decode_interleaved(sample.data, sample.length))
|
||||
return false;
|
||||
|
||||
|
||||
// finish up and clean up
|
||||
decoder.finish();
|
||||
return true;
|
||||
@ -615,7 +615,7 @@ void samples_device::load_samples()
|
||||
// if the user doesn't want to use samples, bail
|
||||
if (!machine().options().samples())
|
||||
return;
|
||||
|
||||
|
||||
// iterate over ourself
|
||||
const char *basename = machine().basename();
|
||||
samples_iterator iter(*this);
|
||||
@ -634,7 +634,7 @@ printf("Sample %d = %s\n", index, samplename);
|
||||
file_error filerr = file.open(basename, PATH_SEPARATOR, samplename, ".flac");
|
||||
if (filerr != FILERR_NONE && altbasename != NULL)
|
||||
filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".flac");
|
||||
|
||||
|
||||
// if not, try as WAV
|
||||
if (filerr != FILERR_NONE)
|
||||
filerr = file.open(basename, PATH_SEPARATOR, samplename, ".wav");
|
||||
|
@ -79,7 +79,7 @@ struct samples_interface
|
||||
|
||||
// ======================> samples_device
|
||||
|
||||
class samples_device : public device_t,
|
||||
class samples_device : public device_t,
|
||||
public device_sound_interface,
|
||||
public samples_interface
|
||||
{
|
||||
@ -100,11 +100,11 @@ public:
|
||||
void pause(UINT8 channel, bool pause = true);
|
||||
void stop(UINT8 channel);
|
||||
void stop_all();
|
||||
|
||||
|
||||
// dynamic control
|
||||
void set_frequency(UINT8 channel, UINT32 frequency);
|
||||
void set_volume(UINT8 channel, float volume);
|
||||
|
||||
|
||||
protected:
|
||||
// subclasses can do it this way
|
||||
samples_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
|
||||
@ -123,7 +123,7 @@ private:
|
||||
{
|
||||
// shouldn't need a copy, but in case it happens, catch it here
|
||||
loaded_sample &operator=(const loaded_sample &rhs) { assert(false); return *this; }
|
||||
|
||||
|
||||
UINT32 length; // length in samples
|
||||
UINT32 frequency; // frequency of the sample
|
||||
dynamic_array<INT16> data; // 16-bit signed data
|
||||
@ -142,7 +142,7 @@ private:
|
||||
bool loop;
|
||||
bool paused;
|
||||
};
|
||||
|
||||
|
||||
// internal helpers
|
||||
bool read_sample(emu_file &file, loaded_sample &sample);
|
||||
bool read_wav_sample(emu_file &file, loaded_sample &sample);
|
||||
@ -172,7 +172,7 @@ public:
|
||||
samples_iterator(samples_interface &intf)
|
||||
: m_intf(intf),
|
||||
m_current(-1) { }
|
||||
|
||||
|
||||
// getters
|
||||
const char *altbasename() const { return (m_intf.m_names != NULL && m_intf.m_names[0] != NULL && m_intf.m_names[0][0] == '*') ? &m_intf.m_names[0][1] : NULL; }
|
||||
|
||||
@ -181,7 +181,7 @@ public:
|
||||
{
|
||||
if (m_intf.m_names == NULL || m_intf.m_names[0] == NULL)
|
||||
return NULL;
|
||||
m_current = 0;
|
||||
m_current = 0;
|
||||
if (m_intf.m_names[0][0] == '*')
|
||||
m_current++;
|
||||
return m_intf.m_names[m_current++];
|
||||
@ -193,7 +193,7 @@ public:
|
||||
return NULL;
|
||||
return m_intf.m_names[m_current++];
|
||||
}
|
||||
|
||||
|
||||
// counting
|
||||
int count()
|
||||
{
|
||||
|
@ -52,14 +52,14 @@ const device_type VOTRAX = &device_creator<votrax_device>;
|
||||
|
||||
const char *const votrax_device::s_phoneme_table[64] =
|
||||
{
|
||||
"EH3", "EH2", "EH1", " "/*PA0*/"DT", "A1", "A2", "ZH",
|
||||
"AH2", "I3", "I2", "I1", "M", "N", "B", "V",
|
||||
"CH", "SH", "Z", "AW1", "NG", "AH1", "OO1", "OO",
|
||||
"L", "K", "J", "H", "G", "F", "D", "S",
|
||||
"A", "AY", "Y1", "UH3", "AH", "P", "O", "I",
|
||||
"U", "Y", "T", "R", "E", "W", "AE", "AE1",
|
||||
"AW2", "UH2", "UH1", "UH", "O2", "O1", "IU", "U1",
|
||||
"THV", "TH", "ER", "EH", "E1", "AW", " "/*PA1*/, "."/*STOP*/
|
||||
"EH3", "EH2", "EH1", " "/*PA0*/"DT", "A1", "A2", "ZH",
|
||||
"AH2", "I3", "I2", "I1", "M", "N", "B", "V",
|
||||
"CH", "SH", "Z", "AW1", "NG", "AH1", "OO1", "OO",
|
||||
"L", "K", "J", "H", "G", "F", "D", "S",
|
||||
"A", "AY", "Y1", "UH3", "AH", "P", "O", "I",
|
||||
"U", "Y", "T", "R", "E", "W", "AE", "AE1",
|
||||
"AW2", "UH2", "UH1", "UH", "O2", "O1", "IU", "U1",
|
||||
"THV", "TH", "ER", "EH", "E1", "AW", " "/*PA1*/, "."/*STOP*/
|
||||
};
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ WRITE8_MEMBER( votrax_device::write )
|
||||
{
|
||||
// append to the current string
|
||||
m_current.cat(s_phoneme_table[data & 0x3f]);
|
||||
|
||||
|
||||
// look for a match in our sample table
|
||||
for (int index = 0; m_votrax_map[index].phoneme != NULL; index++)
|
||||
if (m_current.find(m_votrax_map[index].phoneme) != -1)
|
||||
@ -117,7 +117,7 @@ WRITE8_MEMBER( votrax_device::write )
|
||||
m_current.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if we got a stop and didn't find a match, print it
|
||||
if ((data & 0x3f) == 0x3f)
|
||||
{
|
||||
@ -157,7 +157,7 @@ void votrax_device::device_start()
|
||||
m_channels = 1;
|
||||
m_names = m_sample_list;
|
||||
m_start = NULL;
|
||||
|
||||
|
||||
// let the samples device do the rest
|
||||
samples_device::device_start();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ struct votrax_interface
|
||||
|
||||
// ======================> votrax_device
|
||||
|
||||
class votrax_device : public samples_device,
|
||||
class votrax_device : public samples_device,
|
||||
public votrax_interface
|
||||
{
|
||||
public:
|
||||
@ -89,7 +89,7 @@ public:
|
||||
// writers
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
DECLARE_READ_LINE_MEMBER( status );
|
||||
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
|
@ -1072,8 +1072,8 @@ static void recompute_params(running_machine &machine)
|
||||
static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data)
|
||||
{
|
||||
/* Doom does this */
|
||||
// if(vga.crtc.protect_enable && index <= 0x07)
|
||||
// printf("write to protected address %02x\n",index);
|
||||
// if(vga.crtc.protect_enable && index <= 0x07)
|
||||
// printf("write to protected address %02x\n",index);
|
||||
|
||||
switch(index)
|
||||
{
|
||||
@ -1260,7 +1260,7 @@ static UINT8 vga_vblank(running_machine &machine)
|
||||
res = 1;
|
||||
}
|
||||
|
||||
// popmessage("%d %d %d",vblank_start,vblank_end,vga.crtc.vert_total);
|
||||
// popmessage("%d %d %d",vblank_start,vblank_end,vga.crtc.vert_total);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -2234,7 +2234,7 @@ WRITE8_HANDLER(tseng_et4k_03d0_w)
|
||||
vga.crtc.data[vga.crtc.index] = data;
|
||||
tseng_crtc_reg_write(space->machine(),vga.crtc.index,data);
|
||||
//if((vga.crtc.index & 0xfe) != 0x0e)
|
||||
// printf("%02x %02x %d\n",vga.crtc.index,data,space->machine().primary_screen->vpos());
|
||||
// printf("%02x %02x %d\n",vga.crtc.index,data,space->machine().primary_screen->vpos());
|
||||
break;
|
||||
case 8:
|
||||
et4k.reg_3d8 = data;
|
||||
|
@ -184,9 +184,9 @@ chd_file *ldplayer_state::get_disc()
|
||||
{
|
||||
astring fullpath(image_file->fullpath();
|
||||
image_file.close();
|
||||
|
||||
|
||||
// try to open the CHD
|
||||
|
||||
|
||||
if (set_disk_handle(machine(), "laserdisc", fullpath) == CHDERR_NONE)
|
||||
{
|
||||
m_filename.cpy(dir->name);
|
||||
|
@ -300,7 +300,7 @@ bool pc_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||
const format &f = formats[type];
|
||||
if(!f.desc)
|
||||
return false;
|
||||
|
||||
|
||||
UINT8 sectdata[36*512];
|
||||
desc_s sectors[36];
|
||||
for(int i=0; i<f.sector_count; i++) {
|
||||
|
@ -136,17 +136,17 @@ void SzAr_Free(CSzAr *p, ISzAlloc *alloc);
|
||||
*outBufferSize
|
||||
You can consider "*outBuffer" as cache of solid block. If your archive is solid,
|
||||
it will increase decompression speed.
|
||||
|
||||
|
||||
If you use external function, you can declare these 3 cache variables
|
||||
(blockIndex, outBuffer, outBufferSize) as static in that external function.
|
||||
|
||||
|
||||
Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CSzAr db;
|
||||
|
||||
|
||||
UInt64 startPosAfterHeader;
|
||||
UInt64 dataPos;
|
||||
|
||||
|
@ -52,11 +52,11 @@ void MY_FAST_CALL CrcGenerateTable()
|
||||
UInt32 r = g_CrcTable[i - 256];
|
||||
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MY_CPU_LE
|
||||
|
||||
g_CrcUpdate = CrcUpdateT4;
|
||||
|
||||
|
||||
#if CRC_NUM_TABLES == 8
|
||||
if (!CPU_Is_InOrder())
|
||||
g_CrcUpdate = CrcUpdateT8;
|
||||
|
@ -537,12 +537,12 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc)
|
||||
{
|
||||
UInt32 numCoders, numBindPairs, numPackStreams, i;
|
||||
UInt32 numInStreams = 0, numOutStreams = 0;
|
||||
|
||||
|
||||
RINOK(SzReadNumber32(sd, &numCoders));
|
||||
if (numCoders > NUM_FOLDER_CODERS_MAX)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
folder->NumCoders = numCoders;
|
||||
|
||||
|
||||
MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc);
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
@ -810,7 +810,7 @@ static SRes SzReadSubStreamsInfo(
|
||||
numDigests += numSubstreams;
|
||||
}
|
||||
|
||||
|
||||
|
||||
si = 0;
|
||||
for (;;)
|
||||
{
|
||||
@ -963,8 +963,8 @@ static SRes SzReadHeader2(
|
||||
RINOK(SzReadArchiveProperties(sd));
|
||||
RINOK(SzReadID(sd, &type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (type == k7zIdMainStreamsInfo)
|
||||
{
|
||||
RINOK(SzReadStreamsInfo(sd,
|
||||
@ -982,7 +982,7 @@ static SRes SzReadHeader2(
|
||||
return SZ_OK;
|
||||
if (type != k7zIdFilesInfo)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
|
||||
|
||||
RINOK(SzReadNumber32(sd, &numFiles));
|
||||
p->db.NumFiles = numFiles;
|
||||
|
||||
@ -1165,19 +1165,19 @@ static SRes SzReadAndDecodePackedStreams2(
|
||||
RINOK(SzReadStreamsInfo(sd, &dataStartPos, p,
|
||||
&numUnpackStreams, unpackSizes, digestsDefined, digests,
|
||||
allocTemp, allocTemp));
|
||||
|
||||
|
||||
dataStartPos += baseOffset;
|
||||
if (p->NumFolders != 1)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
|
||||
folder = p->Folders;
|
||||
unpackSize = SzFolder_GetUnpackSize(folder);
|
||||
|
||||
|
||||
RINOK(LookInStream_SeekTo(inStream, dataStartPos));
|
||||
|
||||
if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp))
|
||||
return SZ_ERROR_MEM;
|
||||
|
||||
|
||||
res = SzFolder_Decode(folder, p->PackSizes,
|
||||
inStream, dataStartPos,
|
||||
outBuffer->data, (size_t)unpackSize, allocTemp);
|
||||
@ -1240,7 +1240,7 @@ static SRes SzArEx_Open2(
|
||||
nextHeaderCRC = GetUi32(header + 28);
|
||||
|
||||
p->startPosAfterHeader = startArcPos + k7zStartHeaderSize;
|
||||
|
||||
|
||||
if (CrcCalc(header + 12, 20) != GetUi32(header + 8))
|
||||
return SZ_ERROR_CRC;
|
||||
|
||||
@ -1356,9 +1356,9 @@ SRes SzArEx_Extract(
|
||||
*blockIndex = folderIndex;
|
||||
IAlloc_Free(allocMain, *outBuffer);
|
||||
*outBuffer = 0;
|
||||
|
||||
|
||||
RINOK(LookInStream_SeekTo(inStream, startOffset));
|
||||
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
*outBufferSize = unpackSize;
|
||||
|
@ -228,9 +228,9 @@ void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks)
|
||||
p[1] ^= GetUi32(data + 4);
|
||||
p[2] ^= GetUi32(data + 8);
|
||||
p[3] ^= GetUi32(data + 12);
|
||||
|
||||
|
||||
Aes_Encode(p + 4, p, p);
|
||||
|
||||
|
||||
SetUi32(data, p[0]);
|
||||
SetUi32(data + 4, p[1]);
|
||||
SetUi32(data + 8, p[2]);
|
||||
@ -254,7 +254,7 @@ void MY_FAST_CALL AesCbc_Decode(UInt32 *p, Byte *data, size_t numBlocks)
|
||||
SetUi32(data + 4, p[1] ^ out[1]);
|
||||
SetUi32(data + 8, p[2] ^ out[2]);
|
||||
SetUi32(data + 12, p[3] ^ out[3]);
|
||||
|
||||
|
||||
p[0] = in[0];
|
||||
p[1] = in[1];
|
||||
p[2] = in[2];
|
||||
|
@ -99,7 +99,7 @@ void *BigAlloc(size_t size)
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
|
||||
{
|
||||
@ -118,7 +118,7 @@ void BigFree(void *address)
|
||||
if (address != 0)
|
||||
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
|
||||
#endif
|
||||
|
||||
|
||||
if (address == 0)
|
||||
return;
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
|
@ -48,14 +48,14 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||
((UInt32)data[i + 0] << 11) |
|
||||
(((UInt32)data[i + 3] & 0x7) << 8) |
|
||||
(data[i + 2]);
|
||||
|
||||
|
||||
src <<= 1;
|
||||
if (encoding)
|
||||
dest = ip + (UInt32)i + src;
|
||||
else
|
||||
dest = src - (ip + (UInt32)i);
|
||||
dest >>= 1;
|
||||
|
||||
|
||||
data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));
|
||||
data[i + 0] = (Byte)(dest >> 11);
|
||||
data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7));
|
||||
@ -80,7 +80,7 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||
((UInt32)data[i + 1] << 16) |
|
||||
((UInt32)data[i + 2] << 8) |
|
||||
((UInt32)data[i + 3] & (~3));
|
||||
|
||||
|
||||
UInt32 dest;
|
||||
if (encoding)
|
||||
dest = ip + (UInt32)i + src;
|
||||
@ -113,14 +113,14 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||
((UInt32)data[i + 2] << 8) |
|
||||
((UInt32)data[i + 3]);
|
||||
UInt32 dest;
|
||||
|
||||
|
||||
src <<= 2;
|
||||
if (encoding)
|
||||
dest = ip + i + src;
|
||||
else
|
||||
dest = src - (ip + i);
|
||||
dest >>= 2;
|
||||
|
||||
|
||||
dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
|
||||
|
||||
data[i + 0] = (Byte)(dest >> 24);
|
||||
|
@ -13,23 +13,23 @@ extern "C" {
|
||||
/*
|
||||
These functions convert relative addresses to absolute addresses
|
||||
in CALL instructions to increase the compression ratio.
|
||||
|
||||
|
||||
In:
|
||||
data - data buffer
|
||||
size - size of data
|
||||
ip - current virtual Instruction Pinter (IP) value
|
||||
state - state variable for x86 converter
|
||||
encoding - 0 (for decoding), 1 (for encoding)
|
||||
|
||||
|
||||
Out:
|
||||
state - state variable for x86 converter
|
||||
|
||||
Returns:
|
||||
The number of processed bytes. If you call these functions with multiple calls,
|
||||
you must start next call with first byte after block of processed bytes.
|
||||
|
||||
|
||||
Type Endian Alignment LookAhead
|
||||
|
||||
|
||||
x86 little 1 4
|
||||
ARMT little 2 2
|
||||
ARM little 4 0
|
||||
|
@ -42,20 +42,20 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
|
||||
UInt32 dest;
|
||||
src |= ((UInt32)(instNorm >> 36) & 1) << 20;
|
||||
|
||||
|
||||
src <<= 4;
|
||||
|
||||
|
||||
if (encoding)
|
||||
dest = ip + (UInt32)i + src;
|
||||
else
|
||||
dest = src - (ip + (UInt32)i);
|
||||
|
||||
|
||||
dest >>= 4;
|
||||
|
||||
|
||||
instNorm &= ~((UInt64)(0x8FFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
|
||||
|
||||
|
||||
instruction &= (1 << bitRes) - 1;
|
||||
instruction |= (instNorm << bitRes);
|
||||
for (j = 0; j < 6; j++)
|
||||
|
@ -96,7 +96,7 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
|
||||
gPrev = Groups[sp];
|
||||
temp[0] = (gPrev << NumRefBits);
|
||||
}
|
||||
|
||||
|
||||
for (j = 1; j < groupSize; j++)
|
||||
{
|
||||
UInt32 sp = ind2[j] + NumSortedBytes;
|
||||
@ -114,11 +114,11 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HeapSort(temp, groupSize);
|
||||
mask = ((1 << NumRefBits) - 1);
|
||||
thereAreGroups = 0;
|
||||
|
||||
|
||||
group = groupOffset;
|
||||
cg = (temp[0] >> NumRefBits);
|
||||
temp[0] = ind2[temp[0] & mask];
|
||||
@ -129,12 +129,12 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
|
||||
#else
|
||||
UInt32 prevGroupStart = 0;
|
||||
#endif
|
||||
|
||||
|
||||
for (j = 1; j < groupSize; j++)
|
||||
{
|
||||
UInt32 val = temp[j];
|
||||
UInt32 cgCur = (val >> NumRefBits);
|
||||
|
||||
|
||||
if (cgCur != cg)
|
||||
{
|
||||
cg = cgCur;
|
||||
@ -398,7 +398,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
|
||||
for (i = 0; i < blockSize - 1; i++)
|
||||
Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i;
|
||||
Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i;
|
||||
|
||||
|
||||
#ifndef BLOCK_SORT_EXTERNAL_FLAGS
|
||||
{
|
||||
UInt32 prev = 0;
|
||||
@ -441,7 +441,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
|
||||
for (groupSize = 1;
|
||||
(Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
|
||||
groupSize++);
|
||||
|
||||
|
||||
groupSize++;
|
||||
|
||||
#else
|
||||
@ -473,7 +473,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
if (NumSortedBytes >= blockSize)
|
||||
{
|
||||
UInt32 j;
|
||||
|
@ -81,7 +81,7 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
|
||||
: "0" (function)) ;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
int CPUInfo[4];
|
||||
|
@ -18,9 +18,9 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
/* if (maxLen > 10) maxLen = 10; */
|
||||
{
|
||||
UInt32 i;
|
||||
|
||||
|
||||
#ifdef HUFFMAN_SPEED_OPT
|
||||
|
||||
|
||||
UInt32 counters[NUM_COUNTERS];
|
||||
for (i = 0; i < NUM_COUNTERS; i++)
|
||||
counters[i] = 0;
|
||||
@ -29,7 +29,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
UInt32 freq = freqs[i];
|
||||
counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++;
|
||||
}
|
||||
|
||||
|
||||
for (i = 1; i < NUM_COUNTERS; i++)
|
||||
{
|
||||
UInt32 temp = counters[i];
|
||||
@ -47,7 +47,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
}
|
||||
counters[0] = 0;
|
||||
HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]);
|
||||
|
||||
|
||||
#else
|
||||
|
||||
for (i = 0; i < numSymbols; i++)
|
||||
@ -78,10 +78,10 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
lens[minCode] = lens[maxCode] = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
UInt32 b, e, i;
|
||||
|
||||
|
||||
i = b = e = 0;
|
||||
do
|
||||
{
|
||||
@ -96,12 +96,12 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
e++;
|
||||
}
|
||||
while (num - e > 1);
|
||||
|
||||
|
||||
{
|
||||
UInt32 lenCounters[kMaxLen + 1];
|
||||
for (i = 0; i <= kMaxLen; i++)
|
||||
lenCounters[i] = 0;
|
||||
|
||||
|
||||
p[--e] &= MASK;
|
||||
lenCounters[1] = 2;
|
||||
while (e > 0)
|
||||
@ -113,7 +113,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
lenCounters[len]--;
|
||||
lenCounters[len + 1] += 2;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
UInt32 len;
|
||||
i = 0;
|
||||
@ -124,7 +124,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
|
||||
lens[p[i++] & MASK] = (Byte)len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
UInt32 nextCodes[kMaxLen + 1];
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ Conditions:
|
||||
maxLen <= 16 = kMaxLen
|
||||
Num_Items(p) >= HUFFMAN_TEMP_SIZE(num)
|
||||
*/
|
||||
|
||||
|
||||
void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -512,7 +512,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||
|
||||
delta2 = p->pos - p->hash[hash2Value];
|
||||
curMatch = p->hash[kFix3HashSize + hashValue];
|
||||
|
||||
|
||||
p->hash[hash2Value] =
|
||||
p->hash[kFix3HashSize + hashValue] = p->pos;
|
||||
|
||||
@ -546,7 +546,7 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||
delta2 = p->pos - p->hash[ hash2Value];
|
||||
delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
|
||||
curMatch = p->hash[kFix4HashSize + hashValue];
|
||||
|
||||
|
||||
p->hash[ hash2Value] =
|
||||
p->hash[kFix3HashSize + hash3Value] =
|
||||
p->hash[kFix4HashSize + hashValue] = p->pos;
|
||||
|
@ -58,7 +58,7 @@ void MtSync_StopWriting(CMtSync *p)
|
||||
p->csWasEntered = False;
|
||||
}
|
||||
Semaphore_Release1(&p->freeSemaphore);
|
||||
|
||||
|
||||
Event_Wait(&p->wasStopped);
|
||||
|
||||
while (myNumBlocks++ != p->numProcessedBlocks)
|
||||
@ -108,12 +108,12 @@ static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void
|
||||
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart));
|
||||
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted));
|
||||
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped));
|
||||
|
||||
|
||||
RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks));
|
||||
RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks));
|
||||
|
||||
p->needStart = True;
|
||||
|
||||
|
||||
RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj));
|
||||
p->wasCreated = True;
|
||||
return SZ_OK;
|
||||
@ -385,7 +385,7 @@ void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex)
|
||||
CriticalSection_Enter(&sync->cs);
|
||||
sync->csWasEntered = True;
|
||||
}
|
||||
|
||||
|
||||
BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize);
|
||||
|
||||
if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize)
|
||||
@ -561,7 +561,7 @@ UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
|
||||
const Byte *cur = p->pointerToCurPos;
|
||||
UInt32 lzPos = p->lzPos;
|
||||
MT_HASH2_CALC
|
||||
|
||||
|
||||
curMatch2 = hash[hash2Value];
|
||||
hash[hash2Value] = lzPos;
|
||||
|
||||
@ -584,7 +584,7 @@ UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
|
||||
|
||||
curMatch2 = hash[ hash2Value];
|
||||
curMatch3 = hash[kFix3HashSize + hash3Value];
|
||||
|
||||
|
||||
hash[ hash2Value] =
|
||||
hash[kFix3HashSize + hash3Value] =
|
||||
lzPos;
|
||||
@ -616,11 +616,11 @@ UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
|
||||
const Byte *cur = p->pointerToCurPos;
|
||||
UInt32 lzPos = p->lzPos;
|
||||
MT_HASH4_CALC
|
||||
|
||||
|
||||
curMatch2 = hash[ hash2Value];
|
||||
curMatch3 = hash[kFix3HashSize + hash3Value];
|
||||
curMatch4 = hash[kFix4HashSize + hash4Value];
|
||||
|
||||
|
||||
hash[ hash2Value] =
|
||||
hash[kFix3HashSize + hash3Value] =
|
||||
hash[kFix4HashSize + hash4Value] =
|
||||
|
@ -62,7 +62,7 @@ typedef struct _CMatchFinderMt
|
||||
const UInt32 *crc;
|
||||
|
||||
Mf_Mix_Matches MixMatchesFunc;
|
||||
|
||||
|
||||
/* LZ + BT */
|
||||
CMtSync btSync;
|
||||
Byte btDummy[kMtCacheLineDummy];
|
||||
@ -85,7 +85,7 @@ typedef struct _CMatchFinderMt
|
||||
/* BT + Hash */
|
||||
CMtSync hashSync;
|
||||
/* Byte hashDummy[kMtCacheLineDummy]; */
|
||||
|
||||
|
||||
/* Hash */
|
||||
Mf_GetHeads GetHeadsFunc;
|
||||
CMatchFinder *MatchFinder;
|
||||
|
@ -114,17 +114,17 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
||||
else
|
||||
p->unpackSize = (UInt32)(p->control & 0x1F) << 16;
|
||||
return LZMA2_STATE_UNPACK0;
|
||||
|
||||
|
||||
case LZMA2_STATE_UNPACK0:
|
||||
p->unpackSize |= (UInt32)b << 8;
|
||||
return LZMA2_STATE_UNPACK1;
|
||||
|
||||
|
||||
case LZMA2_STATE_UNPACK1:
|
||||
p->unpackSize |= (UInt32)b;
|
||||
p->unpackSize++;
|
||||
PRF(printf(" %8d", p->unpackSize));
|
||||
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
|
||||
|
||||
|
||||
case LZMA2_STATE_PACK0:
|
||||
p->packSize = (UInt32)b << 8;
|
||||
return LZMA2_STATE_PACK1;
|
||||
@ -199,7 +199,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
||||
SizeT destSizeCur = dicLimit - dicPos;
|
||||
SizeT srcSizeCur = inSize - *srcLen;
|
||||
ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY;
|
||||
|
||||
|
||||
if (p->unpackSize <= destSizeCur)
|
||||
{
|
||||
destSizeCur = (SizeT)p->unpackSize;
|
||||
@ -250,7 +250,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
||||
Bool initState = (mode > 0);
|
||||
if ((!initDic && p->needInitDic) || (!initState && p->needInitState))
|
||||
return SZ_ERROR_DATA;
|
||||
|
||||
|
||||
LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
|
||||
p->needInitDic = False;
|
||||
p->needInitState = False;
|
||||
@ -258,9 +258,9 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
||||
}
|
||||
if (srcSizeCur > p->packSize)
|
||||
srcSizeCur = (SizeT)p->packSize;
|
||||
|
||||
|
||||
res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status);
|
||||
|
||||
|
||||
src += srcSizeCur;
|
||||
*srcLen += srcSizeCur;
|
||||
p->packSize -= (UInt32)srcSizeCur;
|
||||
|
@ -83,11 +83,11 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
||||
if (packSize < lzHeaderSize)
|
||||
return SZ_ERROR_OUTPUT_EOF;
|
||||
packSize -= lzHeaderSize;
|
||||
|
||||
|
||||
LzmaEnc_SaveState(p->enc);
|
||||
res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState,
|
||||
outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize);
|
||||
|
||||
|
||||
PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize));
|
||||
|
||||
if (unpackSize == 0)
|
||||
@ -146,10 +146,10 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
||||
outBuf[destPos++] = (Byte)u;
|
||||
outBuf[destPos++] = (Byte)(pm >> 8);
|
||||
outBuf[destPos++] = (Byte)pm;
|
||||
|
||||
|
||||
if (p->needInitProp)
|
||||
outBuf[destPos++] = p->props;
|
||||
|
||||
|
||||
p->needInitProp = False;
|
||||
p->needInitState = False;
|
||||
destPos += packSize;
|
||||
@ -244,7 +244,7 @@ typedef struct
|
||||
{
|
||||
Byte propEncoded;
|
||||
CLzma2EncProps props;
|
||||
|
||||
|
||||
Byte *outBuf;
|
||||
|
||||
ISzAlloc *alloc;
|
||||
@ -322,10 +322,10 @@ static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *des
|
||||
if (srcSize != 0)
|
||||
{
|
||||
RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
|
||||
|
||||
|
||||
RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE,
|
||||
mainEncoder->alloc, mainEncoder->allocBig));
|
||||
|
||||
|
||||
while (p->srcPos < srcSize)
|
||||
{
|
||||
size_t packSize = destLim - *destSize;
|
||||
@ -460,7 +460,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
||||
|
||||
mtCallback.funcTable.Code = MtCallbackImp_Code;
|
||||
mtCallback.lzma2Enc = p;
|
||||
|
||||
|
||||
p->mtCoder.progress = progress;
|
||||
p->mtCoder.inStream = inStream;
|
||||
p->mtCoder.outStream = outStream;
|
||||
@ -470,7 +470,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
||||
p->mtCoder.blockSize = p->props.blockSize;
|
||||
p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;
|
||||
p->mtCoder.numThreads = p->props.numBlockThreads;
|
||||
|
||||
|
||||
return MtCoder_Code(&p->mtCoder);
|
||||
}
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
||||
LzmaEncProps_Init(&props);
|
||||
props.level = level;
|
||||
props.dictSize = dictSize;
|
||||
|
||||
|
||||
*destLen = 0;
|
||||
if (outSize2 < LZMA86_HEADER_SIZE)
|
||||
return SZ_ERROR_OUTPUT_EOF;
|
||||
@ -78,12 +78,12 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
||||
break;
|
||||
if (useFilter && i == 0)
|
||||
curModeIsFiltered = True;
|
||||
|
||||
|
||||
curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed,
|
||||
curModeIsFiltered ? filteredStream : src, srcLen,
|
||||
&props, dest + 1, &outPropsSize, 0,
|
||||
NULL, &g_Alloc, &g_Alloc);
|
||||
|
||||
|
||||
if (curRes != SZ_ERROR_OUTPUT_EOF)
|
||||
{
|
||||
if (curRes != SZ_OK)
|
||||
|
@ -141,7 +141,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
Byte *dic = p->dic;
|
||||
SizeT dicBufSize = p->dicBufSize;
|
||||
SizeT dicPos = p->dicPos;
|
||||
|
||||
|
||||
UInt32 processedPos = p->processedPos;
|
||||
UInt32 checkDicSize = p->checkDicSize;
|
||||
unsigned len = 0;
|
||||
@ -324,7 +324,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
{
|
||||
NORMALIZE
|
||||
range >>= 1;
|
||||
|
||||
|
||||
{
|
||||
UInt32 t;
|
||||
code -= range;
|
||||
@ -723,7 +723,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
||||
SizeT inSize = *srcLen;
|
||||
(*srcLen) = 0;
|
||||
LzmaDec_WriteRem(p, dicLimit);
|
||||
|
||||
|
||||
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||
|
||||
while (p->remainLen != kMatchSpecLenStart)
|
||||
@ -769,7 +769,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
||||
|
||||
if (p->needInitState)
|
||||
LzmaDec_InitStateReal(p);
|
||||
|
||||
|
||||
if (p->tempBufSize == 0)
|
||||
{
|
||||
SizeT processed;
|
||||
@ -900,12 +900,12 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
|
||||
{
|
||||
UInt32 dicSize;
|
||||
Byte d;
|
||||
|
||||
|
||||
if (size < LZMA_PROPS_SIZE)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
else
|
||||
dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
|
||||
|
||||
|
||||
if (dicSize < LZMA_DIC_MIN)
|
||||
dicSize = LZMA_DIC_MIN;
|
||||
p->dicSize = dicSize;
|
||||
|
@ -130,7 +130,7 @@ LzmaDec_Allocate* can return:
|
||||
SZ_ERROR_MEM - Memory allocation error
|
||||
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||
*/
|
||||
|
||||
|
||||
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
|
||||
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
|
||||
|
||||
@ -159,7 +159,7 @@ void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
|
||||
*/
|
||||
|
||||
/* LzmaDec_DecodeToDic
|
||||
|
||||
|
||||
The decoding to internal dictionary buffer (CLzmaDec::dic).
|
||||
You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
|
||||
|
||||
|
@ -119,7 +119,7 @@ void LzmaEnc_FastPosInit(Byte *g_FastPos)
|
||||
int c = 2, slotFast;
|
||||
g_FastPos[0] = 0;
|
||||
g_FastPos[1] = 1;
|
||||
|
||||
|
||||
for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
|
||||
{
|
||||
UInt32 k = (1 << ((slotFast >> 1) - 1));
|
||||
@ -256,7 +256,7 @@ typedef struct
|
||||
CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
|
||||
CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
|
||||
CLzmaProb posAlignEncoder[1 << kNumAlignBits];
|
||||
|
||||
|
||||
CLenPriceEnc lenEnc;
|
||||
CLenPriceEnc repLenEnc;
|
||||
|
||||
@ -279,7 +279,7 @@ typedef struct
|
||||
#ifndef _7ZIP_ST
|
||||
Byte pad[128];
|
||||
#endif
|
||||
|
||||
|
||||
UInt32 optimumEndIndex;
|
||||
UInt32 optimumCurrentIndex;
|
||||
|
||||
@ -287,7 +287,7 @@ typedef struct
|
||||
UInt32 numPairs;
|
||||
UInt32 numAvail;
|
||||
COptimal opt[kNumOpts];
|
||||
|
||||
|
||||
#ifndef LZMA_LOG_BSR
|
||||
Byte g_FastPos[1 << kNumLogBits];
|
||||
#endif
|
||||
@ -321,14 +321,14 @@ typedef struct
|
||||
CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
|
||||
CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
|
||||
CLzmaProb posAlignEncoder[1 << kNumAlignBits];
|
||||
|
||||
|
||||
CLenPriceEnc lenEnc;
|
||||
CLenPriceEnc repLenEnc;
|
||||
|
||||
unsigned lclp;
|
||||
|
||||
Bool fastMode;
|
||||
|
||||
|
||||
CRangeEnc rc;
|
||||
|
||||
Bool writeEndMark;
|
||||
@ -917,10 +917,10 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
|
||||
{
|
||||
UInt32 posPrev = posMem;
|
||||
UInt32 backCur = backMem;
|
||||
|
||||
|
||||
backMem = p->opt[posPrev].backPrev;
|
||||
posMem = p->opt[posPrev].posPrev;
|
||||
|
||||
|
||||
p->opt[posPrev].backPrev = backCur;
|
||||
p->opt[posPrev].posPrev = cur;
|
||||
cur = posPrev;
|
||||
@ -951,7 +951,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
return lenRes;
|
||||
}
|
||||
p->optimumCurrentIndex = p->optimumEndIndex = 0;
|
||||
|
||||
|
||||
if (p->additionalOffset == 0)
|
||||
mainLen = ReadMatchDistances(p, &numPairs);
|
||||
else
|
||||
@ -1249,7 +1249,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
|
||||
matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
|
||||
repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
|
||||
|
||||
|
||||
if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
|
||||
{
|
||||
UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
|
||||
@ -1311,7 +1311,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
startLen = 2; /* speed optimization */
|
||||
{
|
||||
UInt32 repIndex;
|
||||
@ -1342,10 +1342,10 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
}
|
||||
while (--lenTest >= 2);
|
||||
lenTest = lenTestTemp;
|
||||
|
||||
|
||||
if (repIndex == 0)
|
||||
startLen = lenTest + 1;
|
||||
|
||||
|
||||
/* if (_maxMode) */
|
||||
{
|
||||
UInt32 lenTest2 = lenTest + 1;
|
||||
@ -1369,7 +1369,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
nextRepMatchPrice = curAndLenCharPrice +
|
||||
GET_PRICE_1(p->isMatch[state2][posStateNext]) +
|
||||
GET_PRICE_1(p->isRep[state2]);
|
||||
|
||||
|
||||
/* for (; lenTest2 >= 2; lenTest2--) */
|
||||
{
|
||||
UInt32 curAndLenPrice;
|
||||
@ -1424,7 +1424,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
|
||||
else
|
||||
curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];
|
||||
|
||||
|
||||
opt = &p->opt[cur + lenTest];
|
||||
if (curAndLenPrice < opt->price)
|
||||
{
|
||||
@ -1458,7 +1458,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
||||
nextRepMatchPrice = curAndLenCharPrice +
|
||||
GET_PRICE_1(p->isMatch[state2][posStateNext]) +
|
||||
GET_PRICE_1(p->isRep[state2]);
|
||||
|
||||
|
||||
/* for (; lenTest2 >= 2; lenTest2--) */
|
||||
{
|
||||
UInt32 offset = cur + lenTest + 1 + lenTest2;
|
||||
@ -1570,7 +1570,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
|
||||
MovePos(p, repLen - 1);
|
||||
return repLen;
|
||||
}
|
||||
|
||||
|
||||
if (mainLen < 2 || numAvail <= 2)
|
||||
return 1;
|
||||
|
||||
@ -1584,7 +1584,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
|
||||
(p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist)))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
|
||||
for (i = 0; i < LZMA_NUM_REPS; i++)
|
||||
{
|
||||
@ -1845,7 +1845,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
|
||||
pos -= LZMA_NUM_REPS;
|
||||
GetPosSlot(pos, posSlot);
|
||||
RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);
|
||||
|
||||
|
||||
if (posSlot >= kStartPosModelIndex)
|
||||
{
|
||||
UInt32 footerBits = ((posSlot >> 1) - 1);
|
||||
@ -2150,7 +2150,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||
p->rc.outStream = &outStream.funcTable;
|
||||
|
||||
res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
|
||||
|
||||
|
||||
*unpackSize = (UInt32)(p->nowPos64 - nowPos64);
|
||||
*destLen -= outStream.rem;
|
||||
if (outStream.overflow)
|
||||
|
@ -38,7 +38,7 @@ outPropsSize -
|
||||
LZMA Encoder will use defult values for any parameter, if it is
|
||||
-1 for any from: level, loc, lp, pb, fb, numThreads
|
||||
0 for dictSize
|
||||
|
||||
|
||||
level - compression level: 0 <= level <= 9;
|
||||
|
||||
level dictSize algo fb
|
||||
@ -50,7 +50,7 @@ level - compression level: 0 <= level <= 9;
|
||||
5: 16 MB 1 32
|
||||
6: 32 MB 1 32
|
||||
7+: 64 MB 1 64
|
||||
|
||||
|
||||
The default value for "level" is 5.
|
||||
|
||||
algo = 0 means fast method
|
||||
|
@ -190,9 +190,9 @@ static SRes MtThread_Process(CMtThread *p, Bool *stop)
|
||||
*stop = True;
|
||||
if (Event_Wait(&p->canRead) != 0)
|
||||
return SZ_ERROR_THREAD;
|
||||
|
||||
|
||||
next = GET_NEXT_THREAD(p);
|
||||
|
||||
|
||||
if (p->stopReading)
|
||||
{
|
||||
next->stopReading = True;
|
||||
|
@ -14,7 +14,7 @@ typedef struct
|
||||
CAutoResetEvent startEvent;
|
||||
CAutoResetEvent finishedEvent;
|
||||
int stop;
|
||||
|
||||
|
||||
THREAD_FUNC_TYPE func;
|
||||
LPVOID param;
|
||||
THREAD_FUNC_RET_TYPE res;
|
||||
@ -75,7 +75,7 @@ typedef struct _CMtCoder
|
||||
size_t blockSize;
|
||||
size_t destBlockSize;
|
||||
unsigned numThreads;
|
||||
|
||||
|
||||
ISeqInStream *inStream;
|
||||
ISeqOutStream *outStream;
|
||||
ICompressProgress *progress;
|
||||
|
@ -82,5 +82,5 @@ typedef
|
||||
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -148,7 +148,7 @@ static void GlueFreeBlocks(CPpmd7 *p)
|
||||
#else
|
||||
CPpmd7_Node_Ref head = p->AlignOffset + p->Size;
|
||||
#endif
|
||||
|
||||
|
||||
CPpmd7_Node_Ref n = head;
|
||||
unsigned i;
|
||||
|
||||
@ -175,7 +175,7 @@ static void GlueFreeBlocks(CPpmd7 *p)
|
||||
NODE(n)->Prev = head;
|
||||
if (p->LoUnit != p->HiUnit)
|
||||
((CPpmd7_Node *)p->LoUnit)->Stamp = 1;
|
||||
|
||||
|
||||
/* Glue free blocks */
|
||||
while (n != head)
|
||||
{
|
||||
@ -193,7 +193,7 @@ static void GlueFreeBlocks(CPpmd7 *p)
|
||||
}
|
||||
n = node->Next;
|
||||
}
|
||||
|
||||
|
||||
/* Fill lists of free blocks */
|
||||
for (n = NODE(head)->Next; n != head;)
|
||||
{
|
||||
@ -319,7 +319,7 @@ static void RestartModel(CPpmd7 *p)
|
||||
for (m = 0; m < 64; m += 8)
|
||||
dest[m] = val;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 25; i++)
|
||||
for (k = 0; k < 16; k++)
|
||||
{
|
||||
@ -345,10 +345,10 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)
|
||||
CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState);
|
||||
CPpmd_State *ps[PPMD7_MAX_ORDER];
|
||||
unsigned numPs = 0;
|
||||
|
||||
|
||||
if (!skip)
|
||||
ps[numPs++] = p->FoundState;
|
||||
|
||||
|
||||
while (c->Suffix)
|
||||
{
|
||||
CPpmd_Void_Ref successor;
|
||||
@ -370,10 +370,10 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)
|
||||
}
|
||||
ps[numPs++] = s;
|
||||
}
|
||||
|
||||
|
||||
upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch);
|
||||
SetSuccessor(&upState, upBranch + 1);
|
||||
|
||||
|
||||
if (c->NumStats == 1)
|
||||
upState.Freq = ONE_STATE(c)->Freq;
|
||||
else
|
||||
@ -407,7 +407,7 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)
|
||||
c = c1;
|
||||
}
|
||||
while (numPs != 0);
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -423,11 +423,11 @@ static void UpdateModel(CPpmd7 *p)
|
||||
CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState);
|
||||
CTX_PTR c;
|
||||
unsigned s0, ns;
|
||||
|
||||
|
||||
if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0)
|
||||
{
|
||||
c = SUFFIX(p->MinContext);
|
||||
|
||||
|
||||
if (c->NumStats == 1)
|
||||
{
|
||||
CPpmd_State *s = ONE_STATE(c);
|
||||
@ -465,7 +465,7 @@ static void UpdateModel(CPpmd7 *p)
|
||||
SetSuccessor(p->FoundState, REF(p->MinContext));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*p->Text++ = p->FoundState->Symbol;
|
||||
successor = REF(p->Text);
|
||||
if (p->Text >= p->UnitsStart)
|
||||
@ -473,7 +473,7 @@ static void UpdateModel(CPpmd7 *p)
|
||||
RestartModel(p);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (fSuccessor)
|
||||
{
|
||||
if (fSuccessor <= successor)
|
||||
@ -497,9 +497,9 @@ static void UpdateModel(CPpmd7 *p)
|
||||
SetSuccessor(p->FoundState, successor);
|
||||
fSuccessor = REF(p->MinContext);
|
||||
}
|
||||
|
||||
|
||||
s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1);
|
||||
|
||||
|
||||
for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c))
|
||||
{
|
||||
unsigned ns1;
|
||||
@ -566,7 +566,7 @@ static void UpdateModel(CPpmd7 *p)
|
||||
}
|
||||
p->MaxContext = p->MinContext = CTX(fSuccessor);
|
||||
}
|
||||
|
||||
|
||||
static void Rescale(CPpmd7 *p)
|
||||
{
|
||||
unsigned i, adder, sumFreq, escFreq;
|
||||
@ -583,7 +583,7 @@ static void Rescale(CPpmd7 *p)
|
||||
adder = (p->OrderFall != 0);
|
||||
s->Freq = (Byte)((s->Freq + adder) >> 1);
|
||||
sumFreq = s->Freq;
|
||||
|
||||
|
||||
i = p->MinContext->NumStats - 1;
|
||||
do
|
||||
{
|
||||
@ -601,7 +601,7 @@ static void Rescale(CPpmd7 *p)
|
||||
}
|
||||
}
|
||||
while (--i);
|
||||
|
||||
|
||||
if (s->Freq == 0)
|
||||
{
|
||||
unsigned numStats = p->MinContext->NumStats;
|
||||
|
@ -136,5 +136,5 @@ void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p);
|
||||
void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -160,11 +160,11 @@ int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc)
|
||||
i -= k;
|
||||
}
|
||||
while (i != num);
|
||||
|
||||
|
||||
see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum);
|
||||
freqSum += hiCnt;
|
||||
count = rc->GetThreshold(rc, freqSum);
|
||||
|
||||
|
||||
if (count < hiCnt)
|
||||
{
|
||||
Byte symbol;
|
||||
|
@ -104,7 +104,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol)
|
||||
sum += s->Freq;
|
||||
}
|
||||
while (--i);
|
||||
|
||||
|
||||
p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];
|
||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
||||
MASK(s->Symbol) = 0;
|
||||
@ -149,7 +149,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol)
|
||||
p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);
|
||||
}
|
||||
while (p->MinContext->NumStats == numMasked);
|
||||
|
||||
|
||||
see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq);
|
||||
s = Ppmd7_GetStats(p, p->MinContext);
|
||||
sum = 0;
|
||||
@ -178,7 +178,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol)
|
||||
s++;
|
||||
}
|
||||
while (--i);
|
||||
|
||||
|
||||
RangeEnc_Encode(rc, sum, escFreq, sum + escFreq);
|
||||
see->Summ = (UInt16)(see->Summ + sum + escFreq);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ static void GlueFreeBlocks(CPpmd8 *p)
|
||||
|
||||
p->GlueCount = 1 << 13;
|
||||
memset(p->Stamps, 0, sizeof(p->Stamps));
|
||||
|
||||
|
||||
/* Order-0 context is always at top UNIT, so we don't need guard NODE at the end.
|
||||
All blocks up to p->LoUnit can be free, so we need guard NODE at LoUnit. */
|
||||
if (p->LoUnit != p->HiUnit)
|
||||
@ -175,7 +175,7 @@ static void GlueFreeBlocks(CPpmd8 *p)
|
||||
}
|
||||
}
|
||||
*prev = 0;
|
||||
|
||||
|
||||
/* Fill lists of free blocks */
|
||||
while (head != 0)
|
||||
{
|
||||
@ -298,7 +298,7 @@ static void ExpandTextArea(CPpmd8 *p)
|
||||
memset(count, 0, sizeof(count));
|
||||
if (p->LoUnit != p->HiUnit)
|
||||
((CPpmd8_Node *)p->LoUnit)->Stamp = 0;
|
||||
|
||||
|
||||
{
|
||||
CPpmd8_Node *node = (CPpmd8_Node *)p->UnitsStart;
|
||||
for (; node->Stamp == EMPTY_NODE; node += node->NU)
|
||||
@ -308,7 +308,7 @@ static void ExpandTextArea(CPpmd8 *p)
|
||||
}
|
||||
p->UnitsStart = (Byte *)node;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < PPMD_NUM_INDEXES; i++)
|
||||
{
|
||||
CPpmd8_Node_Ref *next = (CPpmd8_Node_Ref *)&p->FreeList[i];
|
||||
@ -440,7 +440,7 @@ static CPpmd_Void_Ref CutOff(CPpmd8 *p, CTX_PTR ctx, unsigned order)
|
||||
int i;
|
||||
unsigned tmp;
|
||||
CPpmd_State *s;
|
||||
|
||||
|
||||
if (!ctx->NumStats)
|
||||
{
|
||||
s = ONE_STATE(ctx);
|
||||
@ -470,7 +470,7 @@ static CPpmd_Void_Ref CutOff(CPpmd8 *p, CTX_PTR ctx, unsigned order)
|
||||
SetSuccessor(s, CutOff(p, CTX(SUCCESSOR(s)), order + 1));
|
||||
else
|
||||
SetSuccessor(s, 0);
|
||||
|
||||
|
||||
if (i != ctx->NumStats && order)
|
||||
{
|
||||
ctx->NumStats = (Byte)i;
|
||||
@ -521,7 +521,7 @@ static CPpmd_Void_Ref RemoveBinContexts(CPpmd8 *p, CTX_PTR ctx, unsigned order)
|
||||
SetSuccessor(s, RemoveBinContexts(p, CTX(SUCCESSOR(s)), order + 1));
|
||||
else
|
||||
SetSuccessor(s, 0);
|
||||
|
||||
|
||||
return REF(ctx);
|
||||
}
|
||||
#endif
|
||||
@ -561,7 +561,7 @@ static void RestoreModel(CPpmd8 *p, CTX_PTR c1
|
||||
}
|
||||
else
|
||||
Refresh(p, c, (c->NumStats+3) >> 1, 0);
|
||||
|
||||
|
||||
for (; c != p->MinContext; c = SUFFIX(c))
|
||||
if (!c->NumStats)
|
||||
ONE_STATE(c)->Freq -= ONE_STATE(c)->Freq >> 1;
|
||||
@ -610,10 +610,10 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c
|
||||
/* fixed over Shkarin's code. Maybe it could work without + 1 too. */
|
||||
CPpmd_State *ps[PPMD8_MAX_ORDER + 1];
|
||||
unsigned numPs = 0;
|
||||
|
||||
|
||||
if (!skip)
|
||||
ps[numPs++] = p->FoundState;
|
||||
|
||||
|
||||
while (c->Suffix)
|
||||
{
|
||||
CPpmd_Void_Ref successor;
|
||||
@ -648,7 +648,7 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c
|
||||
}
|
||||
ps[numPs++] = s;
|
||||
}
|
||||
|
||||
|
||||
upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch);
|
||||
SetSuccessor(&upState, upBranch + 1);
|
||||
flags = 0x10 * (p->FoundState->Symbol >= 0x40) + 0x08 * (upState.Symbol >= 0x40);
|
||||
@ -687,7 +687,7 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c
|
||||
c = c1;
|
||||
}
|
||||
while (numPs != 0);
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -696,7 +696,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
|
||||
CPpmd_State *s = NULL;
|
||||
CTX_PTR c1 = c;
|
||||
CPpmd_Void_Ref upBranch = REF(p->Text);
|
||||
|
||||
|
||||
#ifdef PPMD8_FREEZE_SUPPORT
|
||||
/* The BUG in Shkarin's code was fixed: ps could overflow in CUT_OFF mode. */
|
||||
CPpmd_State *ps[PPMD8_MAX_ORDER + 1];
|
||||
@ -754,7 +754,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
|
||||
SetSuccessor(s, upBranch);
|
||||
p->OrderFall++;
|
||||
}
|
||||
|
||||
|
||||
#ifdef PPMD8_FREEZE_SUPPORT
|
||||
if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE)
|
||||
{
|
||||
@ -779,7 +779,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
|
||||
SetSuccessor(s, REF(successor));
|
||||
p->FoundState = s1;
|
||||
}
|
||||
|
||||
|
||||
if (p->OrderFall == 1 && c1 == p->MaxContext)
|
||||
{
|
||||
SetSuccessor(p->FoundState, SUCCESSOR(s));
|
||||
@ -797,11 +797,11 @@ static void UpdateModel(CPpmd8 *p)
|
||||
unsigned s0, ns, fFreq = p->FoundState->Freq;
|
||||
Byte flag, fSymbol = p->FoundState->Symbol;
|
||||
CPpmd_State *s = NULL;
|
||||
|
||||
|
||||
if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0)
|
||||
{
|
||||
c = SUFFIX(p->MinContext);
|
||||
|
||||
|
||||
if (c->NumStats == 0)
|
||||
{
|
||||
s = ONE_STATE(c);
|
||||
@ -827,7 +827,7 @@ static void UpdateModel(CPpmd8 *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c = p->MaxContext;
|
||||
if (p->OrderFall == 0 && fSuccessor)
|
||||
{
|
||||
@ -844,7 +844,7 @@ static void UpdateModel(CPpmd8 *p)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*p->Text++ = p->FoundState->Symbol;
|
||||
successor = REF(p->Text);
|
||||
if (p->Text >= p->UnitsStart)
|
||||
@ -852,7 +852,7 @@ static void UpdateModel(CPpmd8 *p)
|
||||
RESTORE_MODEL(c, CTX(fSuccessor)); /* check it */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!fSuccessor)
|
||||
{
|
||||
CTX_PTR cs = ReduceOrder(p, s, p->MinContext);
|
||||
@ -873,7 +873,7 @@ static void UpdateModel(CPpmd8 *p)
|
||||
}
|
||||
fSuccessor = REF(cs);
|
||||
}
|
||||
|
||||
|
||||
if (--p->OrderFall == 0)
|
||||
{
|
||||
successor = fSuccessor;
|
||||
@ -887,10 +887,10 @@ static void UpdateModel(CPpmd8 *p)
|
||||
p->OrderFall = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq;
|
||||
flag = 0x08 * (fSymbol >= 0x40);
|
||||
|
||||
|
||||
for (; c != p->MinContext; c = SUFFIX(c))
|
||||
{
|
||||
unsigned ns1;
|
||||
@ -958,7 +958,7 @@ static void UpdateModel(CPpmd8 *p)
|
||||
}
|
||||
p->MaxContext = p->MinContext = CTX(fSuccessor);
|
||||
}
|
||||
|
||||
|
||||
static void Rescale(CPpmd8 *p)
|
||||
{
|
||||
unsigned i, adder, sumFreq, escFreq;
|
||||
@ -979,7 +979,7 @@ static void Rescale(CPpmd8 *p)
|
||||
);
|
||||
s->Freq = (Byte)((s->Freq + adder) >> 1);
|
||||
sumFreq = s->Freq;
|
||||
|
||||
|
||||
i = p->MinContext->NumStats;
|
||||
do
|
||||
{
|
||||
@ -997,7 +997,7 @@ static void Rescale(CPpmd8 *p)
|
||||
}
|
||||
}
|
||||
while (--i);
|
||||
|
||||
|
||||
if (s->Freq == 0)
|
||||
{
|
||||
unsigned numStats = p->MinContext->NumStats;
|
||||
|
@ -133,5 +133,5 @@ void Ppmd8_RangeEnc_FlushData(CPpmd8 *p);
|
||||
void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -128,11 +128,11 @@ int Ppmd8_DecodeSymbol(CPpmd8 *p)
|
||||
i -= k;
|
||||
}
|
||||
while (i != num);
|
||||
|
||||
|
||||
see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum);
|
||||
freqSum += hiCnt;
|
||||
count = RangeDec_GetThreshold(p, freqSum);
|
||||
|
||||
|
||||
if (count < hiCnt)
|
||||
{
|
||||
Byte symbol;
|
||||
|
@ -81,7 +81,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
|
||||
sum += s->Freq;
|
||||
}
|
||||
while (--i);
|
||||
|
||||
|
||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
||||
MASK(s->Symbol) = 0;
|
||||
i = p->MinContext->NumStats;
|
||||
@ -125,7 +125,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
|
||||
p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix);
|
||||
}
|
||||
while (p->MinContext->NumStats == numMasked);
|
||||
|
||||
|
||||
see = Ppmd8_MakeEscFreq(p, numMasked, &escFreq);
|
||||
s = Ppmd8_GetStats(p, p->MinContext);
|
||||
sum = 0;
|
||||
@ -154,7 +154,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
|
||||
s++;
|
||||
}
|
||||
while (--i);
|
||||
|
||||
|
||||
RangeEnc_Encode(p, sum, escFreq, sum + escFreq);
|
||||
see->Summ = (UInt16)(see->Summ + sum + escFreq);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ static void Sha256_Transform(UInt32 *state, const UInt32 *data)
|
||||
for (j = 0; j < 8; j++)
|
||||
state[j] += T[j];
|
||||
#endif
|
||||
|
||||
|
||||
/* Wipe variables */
|
||||
/* memset(W, 0, sizeof(W)); */
|
||||
/* memset(T, 0, sizeof(T)); */
|
||||
|
@ -199,7 +199,7 @@ typedef struct
|
||||
unsigned indexPreSize;
|
||||
|
||||
CXzStreamFlags streamFlags;
|
||||
|
||||
|
||||
UInt32 blockHeaderSize;
|
||||
UInt64 packSize;
|
||||
UInt64 unpackSize;
|
||||
|
@ -421,7 +421,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
||||
const Byte *srcCur;
|
||||
int srcFinishedCur;
|
||||
int encodingWasFinished;
|
||||
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
srcCur = src;
|
||||
@ -434,7 +434,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
||||
srcLenCur = p->size[i - 1] - p->pos[i - 1];
|
||||
srcFinishedCur = p->finished[i - 1];
|
||||
}
|
||||
|
||||
|
||||
if (i == p->numCoders - 1)
|
||||
{
|
||||
destCur = dest;
|
||||
@ -447,7 +447,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
||||
destCur = p->buf + (CODER_BUF_SIZE * i);
|
||||
destLenCur = CODER_BUF_SIZE;
|
||||
}
|
||||
|
||||
|
||||
res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, &encodingWasFinished);
|
||||
|
||||
if (!encodingWasFinished)
|
||||
@ -474,7 +474,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
||||
p->pos[i] = 0;
|
||||
p->finished[i] = encodingWasFinished;
|
||||
}
|
||||
|
||||
|
||||
if (res != SZ_OK)
|
||||
return res;
|
||||
|
||||
@ -637,20 +637,20 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
||||
*status = CODER_STATUS_NOT_FINISHED;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
|
||||
res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status);
|
||||
XzCheck_Update(&p->check, dest, destLen2);
|
||||
|
||||
|
||||
(*srcLen) += srcLen2;
|
||||
src += srcLen2;
|
||||
p->packSize += srcLen2;
|
||||
|
||||
|
||||
(*destLen) += destLen2;
|
||||
dest += destLen2;
|
||||
p->unpackSize += destLen2;
|
||||
|
||||
|
||||
RINOK(res);
|
||||
|
||||
|
||||
if (*status == CODER_STATUS_FINISHED_WITH_MARK)
|
||||
{
|
||||
Byte temp[32];
|
||||
@ -659,14 +659,14 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
||||
Sha256_Update(&p->sha, temp, num);
|
||||
p->indexSize += num;
|
||||
p->numBlocks++;
|
||||
|
||||
|
||||
p->state = XZ_STATE_BLOCK_FOOTER;
|
||||
p->pos = 0;
|
||||
p->alignPos = 0;
|
||||
}
|
||||
else if (srcLen2 == 0 && destLen2 == 0)
|
||||
return SZ_OK;
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -872,7 +872,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case XZ_STATE_BLOCK: break; /* to disable GCC warning */
|
||||
}
|
||||
}
|
||||
|
@ -409,10 +409,10 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
|
||||
int filterIndex = 0;
|
||||
CXzFilter *filter = NULL;
|
||||
const CXzFilterProps *fp = props->filterProps;
|
||||
|
||||
|
||||
XzBlock_ClearFlags(&block);
|
||||
XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0));
|
||||
|
||||
|
||||
if (fp)
|
||||
{
|
||||
filter = &block.filters[filterIndex++];
|
||||
@ -440,13 +440,13 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
|
||||
seqSizeOutStream.p.Write = MyWrite;
|
||||
seqSizeOutStream.realStream = outStream;
|
||||
seqSizeOutStream.processed = 0;
|
||||
|
||||
|
||||
RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.p));
|
||||
|
||||
|
||||
checkInStream.p.Read = SeqCheckInStream_Read;
|
||||
checkInStream.realStream = inStream;
|
||||
SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags));
|
||||
|
||||
|
||||
if (fp)
|
||||
{
|
||||
#ifdef USE_SUBBLOCK
|
||||
|
@ -88,7 +88,7 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *
|
||||
if (numBlocks != numBlocks64 || numBlocks * 2 > size)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
}
|
||||
|
||||
|
||||
crcStartPos = pos;
|
||||
Xz_Free(p, alloc);
|
||||
if (numBlocks != 0)
|
||||
@ -149,7 +149,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff
|
||||
RINOK(SeekFromCur(stream, startOffset));
|
||||
|
||||
RINOK(LookInStream_Read2(stream, buf, XZ_STREAM_FOOTER_SIZE, SZ_ERROR_NO_ARCHIVE));
|
||||
|
||||
|
||||
if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
|
||||
{
|
||||
UInt32 total = 0;
|
||||
@ -185,7 +185,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff
|
||||
if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
|
||||
return SZ_ERROR_NO_ARCHIVE;
|
||||
}
|
||||
|
||||
|
||||
p->flags = (CXzStreamFlags)GetBe16(buf + 8);
|
||||
|
||||
if (!XzFlags_IsSupported(p->flags))
|
||||
|
@ -120,12 +120,12 @@ WRes File_Read(CSzFile *p, void *data, size_t *size)
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
*size = fread(data, 1, originalSize, p->file);
|
||||
if (*size == originalSize)
|
||||
return 0;
|
||||
return ferror(p->file);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
|
||||
size_t originalSize = *size;
|
||||
if (originalSize == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_FILE
|
||||
|
||||
*size = 0;
|
||||
@ -160,7 +160,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
|
||||
if (*size == originalSize)
|
||||
return 0;
|
||||
return ferror(p->file);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int moveMethod;
|
||||
int res;
|
||||
switch (origin)
|
||||
@ -203,14 +203,14 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
|
||||
res = fseek(p->file, (long)*pos, moveMethod);
|
||||
*pos = ftell(p->file);
|
||||
return res;
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
WRes File_GetLength(CSzFile *p, UInt64 *length)
|
||||
{
|
||||
#ifdef USE_WINDOWS_FILE
|
||||
|
||||
|
||||
DWORD sizeHigh;
|
||||
DWORD sizeLow = GetFileSize(p->handle, &sizeHigh);
|
||||
if (sizeLow == 0xFFFFFFFF)
|
||||
@ -221,15 +221,15 @@ WRes File_GetLength(CSzFile *p, UInt64 *length)
|
||||
}
|
||||
*length = (((UInt64)sizeHigh) << 32) + sizeLow;
|
||||
return 0;
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
long pos = ftell(p->file);
|
||||
int res = fseek(p->file, 0, SEEK_END);
|
||||
*length = ftell(p->file);
|
||||
fseek(p->file, pos, SEEK_SET);
|
||||
return res;
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@
|
||||
+02 = samples (2 bytes) - number of samples per audio stream
|
||||
+04 = width (2 bytes) - width of video data
|
||||
+06 = height (2 bytes) - height of video data
|
||||
+08 = audio huffman size (2 bytes) - size of audio huffman tables
|
||||
(0x0000 => uncompressed deltas are used)
|
||||
+08 = audio huffman size (2 bytes) - size of audio huffman tables
|
||||
(0x0000 => uncompressed deltas are used)
|
||||
+0A = str0size (2 bytes) - compressed size of stream 0
|
||||
+0C = str1size (2 bytes) - compressed size of stream 1
|
||||
...
|
||||
@ -214,7 +214,7 @@ m_flac_encoder.set_strip_metadata(true);
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// encode_data - encode a block of data into a
|
||||
// encode_data - encode a block of data into a
|
||||
// compressed data stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -343,12 +343,12 @@ avhuff_error avhuff_encoder::assemble_data(UINT8 *dest, UINT32 dlength, bitmap_y
|
||||
*dest++ = bitmap.width() & 0xff;
|
||||
*dest++ = bitmap.height() >> 8;
|
||||
*dest++ = bitmap.height() & 0xff;
|
||||
|
||||
|
||||
// copy the metadata
|
||||
if (metadatasize > 0)
|
||||
memcpy(dest, metadata, metadatasize);
|
||||
dest += metadatasize;
|
||||
|
||||
|
||||
// copy the audio streams
|
||||
for (UINT8 curchan = 0; curchan < channels; curchan++)
|
||||
for (UINT32 cursamp = 0; cursamp < numsamples; cursamp++)
|
||||
@ -356,7 +356,7 @@ avhuff_error avhuff_encoder::assemble_data(UINT8 *dest, UINT32 dlength, bitmap_y
|
||||
*dest++ = samples[curchan][cursamp] >> 8;
|
||||
*dest++ = samples[curchan][cursamp] & 0xff;
|
||||
}
|
||||
|
||||
|
||||
// copy the video data
|
||||
for (INT32 y = 0; y < bitmap.height(); y++)
|
||||
{
|
||||
@ -372,7 +372,7 @@ avhuff_error avhuff_encoder::assemble_data(UINT8 *dest, UINT32 dlength, bitmap_y
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// encode_audio - encode raw audio data to the
|
||||
// encode_audio - encode raw audio data to the
|
||||
// destination
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -384,20 +384,20 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
|
||||
UINT16 be_test = 0;
|
||||
*(UINT8 *)&be_test = 1;
|
||||
bool swap_endian = (be_test == 1);
|
||||
|
||||
|
||||
// set huffman tree size to 0xffff to indicate FLAC
|
||||
sizes[0] = 0xff;
|
||||
sizes[1] = 0xff;
|
||||
|
||||
|
||||
// set the block size for this round and iterate over channels
|
||||
m_flac_encoder.set_block_size(samples);
|
||||
for (int chnum = 0; chnum < channels; chnum++)
|
||||
for (int chnum = 0; chnum < channels; chnum++)
|
||||
{
|
||||
// encode the data
|
||||
m_flac_encoder.reset(dest, samples * 2);
|
||||
if (!m_flac_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(source) + chnum * samples, samples, swap_endian))
|
||||
return AVHERR_COMPRESSION_ERROR;
|
||||
|
||||
|
||||
// set the size for this channel
|
||||
UINT32 cursize = m_flac_encoder.finish();
|
||||
sizes[chnum * 2 + 2] = cursize >> 8;
|
||||
@ -495,7 +495,7 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// encode_video - encode raw video data to the
|
||||
// encode_video - encode raw video data to the
|
||||
// destination
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -516,7 +516,7 @@ avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int widt
|
||||
// set up the output; first byte is 0x80 to indicate lossless encoding
|
||||
bitstream_out bitbuf(dest, width * height * 2);
|
||||
bitbuf.write(0x80, 8);
|
||||
|
||||
|
||||
// compute the histograms for the data
|
||||
UINT16 *yrle = m_ycontext.rle_and_histo_bitmap(source + 0, width, 2, height);
|
||||
UINT16 *cbrle = m_cbcontext.rle_and_histo_bitmap(source + 1, width / 2, 4, height);
|
||||
@ -563,7 +563,7 @@ avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int widt
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// rle_and_histo_bitmap - RLE compress and
|
||||
// rle_and_histo_bitmap - RLE compress and
|
||||
// histogram a bitmap's worth of data
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -584,12 +584,12 @@ UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *sour
|
||||
// fetch current data
|
||||
UINT8 curdelta = *source - prevdata;
|
||||
prevdata = *source;
|
||||
|
||||
|
||||
// 0 deltas scan forward for a count
|
||||
if (curdelta == 0)
|
||||
{
|
||||
int zerocount = 1;
|
||||
|
||||
|
||||
// count the number of consecutive values
|
||||
const UINT8 *scandata;
|
||||
for (scandata = source + item_advance; scandata < end; scandata += item_advance)
|
||||
@ -597,7 +597,7 @@ UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *sour
|
||||
zerocount++;
|
||||
else
|
||||
break;
|
||||
|
||||
|
||||
// if we hit the end of a row, maximize the count
|
||||
if (scandata >= end && zerocount >= 8)
|
||||
zerocount = 100000;
|
||||
@ -609,16 +609,16 @@ UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *sour
|
||||
// advance past the run
|
||||
source += (code_to_rlecount(rlecode) - 1) * item_advance;
|
||||
}
|
||||
|
||||
|
||||
// otherwise, encode the actual data
|
||||
else
|
||||
m_encoder.histo_one(*dest++ = curdelta);
|
||||
}
|
||||
|
||||
|
||||
// advance to the next row
|
||||
source = end;
|
||||
}
|
||||
|
||||
|
||||
// compute the tree for our histogram
|
||||
m_encoder.compute_tree_from_histo();
|
||||
return m_rlebuffer;
|
||||
@ -787,7 +787,7 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength,
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decode_audio - decode audio from a compressed
|
||||
// decode_audio - decode audio from a compressed
|
||||
// data stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -827,7 +827,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
|
||||
// finish up
|
||||
m_flac_decoder.finish();
|
||||
}
|
||||
|
||||
|
||||
// advance to the next channel's data
|
||||
source += size;
|
||||
}
|
||||
@ -881,7 +881,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
|
||||
curdest += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// otherwise, Huffman-decode the data
|
||||
else
|
||||
{
|
||||
@ -902,7 +902,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
|
||||
return AVHERR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// advance to the next channel's data
|
||||
source += size;
|
||||
}
|
||||
@ -911,7 +911,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decode_video - decode video from a compressed
|
||||
// decode_video - decode video from a compressed
|
||||
// data stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -969,7 +969,7 @@ avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const
|
||||
m_cbcontext.flush_rle();
|
||||
m_crcontext.flush_rle();
|
||||
}
|
||||
|
||||
|
||||
// check for errors if we overflowed or decoded too little data
|
||||
if (bitbuf.overflow() || bitbuf.flush() != complength)
|
||||
return AVHERR_INVALID_DATA;
|
||||
|
@ -129,7 +129,7 @@ private:
|
||||
// construction/destruction
|
||||
deltarle_encoder()
|
||||
: m_rlecount(0) { }
|
||||
|
||||
|
||||
// histogramming
|
||||
UINT16 *rle_and_histo_bitmap(const UINT8 *source, UINT32 items_per_row, UINT32 item_advance, UINT32 row_count);
|
||||
|
||||
@ -150,10 +150,10 @@ private:
|
||||
avhuff_error encode_video(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength);
|
||||
avhuff_error encode_video_lossless(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength);
|
||||
|
||||
// video encoding contexts
|
||||
deltarle_encoder m_ycontext;
|
||||
deltarle_encoder m_cbcontext;
|
||||
deltarle_encoder m_crcontext;
|
||||
// video encoding contexts
|
||||
deltarle_encoder m_ycontext;
|
||||
deltarle_encoder m_cbcontext;
|
||||
deltarle_encoder m_crcontext;
|
||||
|
||||
// audio encoding contexts
|
||||
dynamic_buffer m_audiobuffer;
|
||||
@ -189,7 +189,7 @@ private:
|
||||
// construction/destruction
|
||||
deltarle_decoder()
|
||||
: m_rlecount(0), m_prevdata(0) { }
|
||||
|
||||
|
||||
// general
|
||||
void reset() { m_rlecount = m_prevdata = 0; }
|
||||
|
||||
@ -212,12 +212,12 @@ private:
|
||||
avhuff_error decode_video_lossless(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor);
|
||||
|
||||
// internal state
|
||||
avhuff_decompress_config m_config;
|
||||
avhuff_decompress_config m_config;
|
||||
|
||||
// video decoding contexts
|
||||
deltarle_decoder m_ycontext;
|
||||
deltarle_decoder m_cbcontext;
|
||||
deltarle_decoder m_crcontext;
|
||||
deltarle_decoder m_ycontext;
|
||||
deltarle_decoder m_cbcontext;
|
||||
deltarle_decoder m_crcontext;
|
||||
|
||||
// audio decoding contexts
|
||||
huffman_8bit_decoder m_audiohi_decoder;
|
||||
|
@ -55,11 +55,11 @@ class bitstream_in
|
||||
public:
|
||||
// construction/destruction
|
||||
bitstream_in(const void *src, UINT32 srclength);
|
||||
|
||||
|
||||
// getters
|
||||
bool overflow() const { return ((m_doffset - m_bits / 8) > m_dlength); }
|
||||
UINT32 read_offset() const;
|
||||
|
||||
|
||||
// operations
|
||||
UINT32 read(int numbits);
|
||||
UINT32 peek(int numbits);
|
||||
@ -82,10 +82,10 @@ class bitstream_out
|
||||
public:
|
||||
// construction/destruction
|
||||
bitstream_out(void *dest, UINT32 destlength);
|
||||
|
||||
|
||||
// getters
|
||||
bool overflow() const { return (m_doffset > m_dlength); }
|
||||
|
||||
|
||||
// operations
|
||||
void write(UINT32 newbits, int numbits);
|
||||
UINT32 flush();
|
||||
|
@ -380,7 +380,7 @@ UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer)
|
||||
UINT32 chdsector = physical_to_chd_lba(file, lbasector, tracknum);
|
||||
if (file->cdtoc.tracks[tracknum].subsize == 0)
|
||||
return 1;
|
||||
|
||||
|
||||
// read the data
|
||||
chd_error err = read_partial_sector(file, buffer, chdsector, tracknum, file->cdtoc.tracks[tracknum].datasize, file->cdtoc.tracks[tracknum].subsize);
|
||||
return (err == CHDERR_NONE);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@
|
||||
|
||||
Compressed Hunks of Data header format. All numbers are stored in
|
||||
Motorola (big-endian) byte ordering.
|
||||
|
||||
|
||||
=========================================================================
|
||||
|
||||
V1 header:
|
||||
@ -78,15 +78,15 @@
|
||||
0x00000001 - set if this drive has a parent
|
||||
0x00000002 - set if this drive allows writes
|
||||
|
||||
Compression types:
|
||||
CHDCOMPRESSION_NONE = 0
|
||||
CHDCOMPRESSION_ZLIB = 1
|
||||
|
||||
Compression types:
|
||||
CHDCOMPRESSION_NONE = 0
|
||||
CHDCOMPRESSION_ZLIB = 1
|
||||
|
||||
V1 map format:
|
||||
|
||||
[ 0] UINT64 offset : 44; // starting offset within the file
|
||||
[ 0] UINT64 length : 20; // length of data; if == hunksize, data is uncompressed
|
||||
|
||||
|
||||
[ 0] UINT64 offset : 44; // starting offset within the file
|
||||
[ 0] UINT64 length : 20; // length of data; if == hunksize, data is uncompressed
|
||||
|
||||
=========================================================================
|
||||
|
||||
V2 header:
|
||||
@ -105,9 +105,9 @@
|
||||
[ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 76] UINT32 seclen; // number of bytes per sector
|
||||
[ 80] (V2 header length)
|
||||
|
||||
|
||||
Flags and map format are same as V1
|
||||
|
||||
|
||||
=========================================================================
|
||||
|
||||
V3 header:
|
||||
@ -126,21 +126,21 @@
|
||||
[ 80] UINT8 sha1[20]; // SHA1 checksum of raw data
|
||||
[100] UINT8 parentsha1[20];// SHA1 checksum of parent file
|
||||
[120] (V3 header length)
|
||||
|
||||
|
||||
Flags are the same as V1
|
||||
|
||||
Compression types:
|
||||
CHDCOMPRESSION_NONE = 0
|
||||
CHDCOMPRESSION_ZLIB = 1
|
||||
CHDCOMPRESSION_ZLIB_PLUS = 2
|
||||
|
||||
Compression types:
|
||||
CHDCOMPRESSION_NONE = 0
|
||||
CHDCOMPRESSION_ZLIB = 1
|
||||
CHDCOMPRESSION_ZLIB_PLUS = 2
|
||||
|
||||
V3 map format:
|
||||
|
||||
[ 0] UINT64 offset; // starting offset within the file
|
||||
[ 8] UINT32 crc32; // 32-bit CRC of the uncompressed data
|
||||
[ 12] UINT16 length_lo; // lower 16 bits of length
|
||||
[ 14] UINT8 length_hi; // upper 8 bits of length
|
||||
[ 15] UINT8 flags; // flags, indicating compression info
|
||||
[ 8] UINT32 crc32; // 32-bit CRC of the uncompressed data
|
||||
[ 12] UINT16 length_lo; // lower 16 bits of length
|
||||
[ 14] UINT8 length_hi; // upper 8 bits of length
|
||||
[ 15] UINT8 flags; // flags, indicating compression info
|
||||
|
||||
=========================================================================
|
||||
|
||||
@ -159,21 +159,21 @@
|
||||
[ 68] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
|
||||
[ 88] UINT8 rawsha1[20]; // raw data SHA1
|
||||
[108] (V4 header length)
|
||||
|
||||
|
||||
Flags are the same as V1
|
||||
|
||||
Compression types:
|
||||
CHDCOMPRESSION_NONE = 0
|
||||
CHDCOMPRESSION_ZLIB = 1
|
||||
CHDCOMPRESSION_ZLIB_PLUS = 2
|
||||
CHDCOMPRESSION_AV = 3
|
||||
|
||||
|
||||
Compression types:
|
||||
CHDCOMPRESSION_NONE = 0
|
||||
CHDCOMPRESSION_ZLIB = 1
|
||||
CHDCOMPRESSION_ZLIB_PLUS = 2
|
||||
CHDCOMPRESSION_AV = 3
|
||||
|
||||
Map format is the same as V3
|
||||
|
||||
|
||||
=========================================================================
|
||||
|
||||
V5 header:
|
||||
|
||||
|
||||
[ 0] char tag[8]; // 'MComprHD'
|
||||
[ 8] UINT32 length; // length of header (including tag and length fields)
|
||||
[ 12] UINT32 version; // drive format version
|
||||
@ -188,30 +188,30 @@
|
||||
[104] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
|
||||
[124] (V5 header length)
|
||||
|
||||
If parentsha1 != 0, we have a parent (no need for flags)
|
||||
If compressors[0] == 0, we are uncompressed (including maps)
|
||||
|
||||
If parentsha1 != 0, we have a parent (no need for flags)
|
||||
If compressors[0] == 0, we are uncompressed (including maps)
|
||||
|
||||
V5 uncompressed map format:
|
||||
|
||||
[ 0] UINT32 offset; // starting offset / hunk size
|
||||
|
||||
|
||||
[ 0] UINT32 offset; // starting offset / hunk size
|
||||
|
||||
V5 compressed map format header:
|
||||
|
||||
[ 0] UINT32 length; // length of compressed map
|
||||
[ 4] UINT48 datastart; // offset of first block
|
||||
[ 10] UINT16 crc; // crc-16 of the map
|
||||
[ 12] UINT8 lengthbits; // bits used to encode complength
|
||||
[ 13] UINT8 hunkbits; // bits used to encode self-refs
|
||||
[ 14] UINT8 parentunitbits; // bits used to encode parent unit refs
|
||||
[ 15] UINT8 reserved; // future use
|
||||
|
||||
[ 0] UINT32 length; // length of compressed map
|
||||
[ 4] UINT48 datastart; // offset of first block
|
||||
[ 10] UINT16 crc; // crc-16 of the map
|
||||
[ 12] UINT8 lengthbits; // bits used to encode complength
|
||||
[ 13] UINT8 hunkbits; // bits used to encode self-refs
|
||||
[ 14] UINT8 parentunitbits; // bits used to encode parent unit refs
|
||||
[ 15] UINT8 reserved; // future use
|
||||
[ 16] (compressed header length)
|
||||
|
||||
|
||||
Each compressed map entry, once expanded, looks like:
|
||||
|
||||
[ 0] UINT8 compression; // compression type
|
||||
[ 1] UINT24 complength; // compressed length
|
||||
[ 4] UINT48 offset; // offset
|
||||
[ 10] UINT16 crc; // crc-16 of the data
|
||||
|
||||
[ 0] UINT8 compression; // compression type
|
||||
[ 1] UINT24 complength; // compressed length
|
||||
[ 4] UINT48 offset; // offset
|
||||
[ 10] UINT16 crc; // crc-16 of the data
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -222,7 +222,7 @@
|
||||
|
||||
// pseudo-codecs returned by hunk_info
|
||||
const chd_codec_type CHD_CODEC_SELF = 1; // copy of another hunk
|
||||
const chd_codec_type CHD_CODEC_PARENT = 2; // copy of a parent's hunk
|
||||
const chd_codec_type CHD_CODEC_PARENT = 2; // copy of a parent's hunk
|
||||
const chd_codec_type CHD_CODEC_MINI = 3; // legacy "mini" 8-byte repeat
|
||||
|
||||
// core types
|
||||
@ -322,7 +322,7 @@ class chd_file
|
||||
static const UINT32 V4_HEADER_SIZE = 108;
|
||||
static const UINT32 V5_HEADER_SIZE = 124;
|
||||
static const UINT32 MAX_HEADER_SIZE = V5_HEADER_SIZE;
|
||||
|
||||
|
||||
public:
|
||||
// construction/destruction
|
||||
chd_file();
|
||||
@ -360,7 +360,7 @@ public:
|
||||
// file open
|
||||
chd_error open(const char *filename, bool writeable = false, chd_file *parent = NULL);
|
||||
chd_error open(core_file &file, bool writeable = false, chd_file *parent = NULL);
|
||||
|
||||
|
||||
// file close
|
||||
void close();
|
||||
|
||||
@ -382,20 +382,20 @@ public:
|
||||
chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const dynamic_buffer &input, UINT8 flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, input, input.count(), flags = CHD_MDFLAGS_CHECKSUM); }
|
||||
chd_error delete_metadata(chd_metadata_tag metatag, UINT32 metaindex);
|
||||
chd_error clone_all_metadata(chd_file &source);
|
||||
|
||||
|
||||
// hashing helper
|
||||
sha1_t compute_overall_sha1(sha1_t rawsha1);
|
||||
|
||||
// codec interfaces
|
||||
chd_error codec_configure(chd_codec_type codec, int param, void *config);
|
||||
|
||||
|
||||
// static helpers
|
||||
static const char *error_string(chd_error err);
|
||||
|
||||
private:
|
||||
struct metadata_entry;
|
||||
struct metadata_hash;
|
||||
|
||||
|
||||
// inline helpers
|
||||
UINT64 be_read(const UINT8 *base, int numbytes);
|
||||
void be_write(UINT8 *base, UINT64 value, int numbytes);
|
||||
@ -430,7 +430,7 @@ private:
|
||||
bool m_owns_file; // flag indicating if this file should be closed on chd_close()
|
||||
bool m_allow_reads; // permit reads from this CHD?
|
||||
bool m_allow_writes; // permit writes to this CHD?
|
||||
|
||||
|
||||
// core parameters from the header
|
||||
UINT32 m_version; // version of the header
|
||||
UINT64 m_logicalbytes; // logical size of the raw CHD data in bytes
|
||||
@ -443,14 +443,14 @@ private:
|
||||
chd_codec_type m_compression[4]; // array of compression types used
|
||||
chd_file * m_parent; // pointer to parent file, or NULL if none
|
||||
bool m_parent_missing; // are we missing our parent?
|
||||
|
||||
|
||||
// key offsets within the header
|
||||
UINT64 m_mapoffset_offset; // offset of map offset field
|
||||
UINT64 m_metaoffset_offset;// offset of metaoffset field
|
||||
UINT64 m_sha1_offset; // offset of SHA1 field
|
||||
UINT64 m_rawsha1_offset; // offset of raw SHA1 field
|
||||
UINT64 m_parentsha1_offset;// offset of paren SHA1 field
|
||||
|
||||
|
||||
// map information
|
||||
UINT32 m_mapentrybytes; // length of each entry in a map
|
||||
dynamic_buffer m_rawmap; // raw map data
|
||||
@ -458,7 +458,7 @@ private:
|
||||
// compression management
|
||||
chd_decompressor * m_decompressor[4]; // array of decompression codecs
|
||||
dynamic_buffer m_compressed; // temporary buffer for compressed data
|
||||
|
||||
|
||||
// caching
|
||||
dynamic_buffer m_cache; // single-hunk cache for partial reads/writes
|
||||
UINT32 m_cachehunk; // which hunk is in the cache?
|
||||
@ -474,7 +474,7 @@ public:
|
||||
// construction/destruction
|
||||
chd_file_compressor();
|
||||
virtual ~chd_file_compressor();
|
||||
|
||||
|
||||
// compression management
|
||||
void compress_begin();
|
||||
chd_error compress_continue(double &progress, double &ratio);
|
||||
@ -482,7 +482,7 @@ public:
|
||||
protected:
|
||||
// required override: read more data
|
||||
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length) = 0;
|
||||
|
||||
|
||||
private:
|
||||
// hash map for looking up values
|
||||
class hashmap
|
||||
@ -491,12 +491,12 @@ private:
|
||||
// construction/destruction
|
||||
hashmap();
|
||||
~hashmap();
|
||||
|
||||
|
||||
// operations
|
||||
void reset();
|
||||
UINT64 find(crc16_t crc16, sha1_t sha1);
|
||||
void add(UINT64 itemnum, crc16_t crc16, sha1_t sha1);
|
||||
|
||||
|
||||
// constants
|
||||
static const UINT64 NOT_FOUND = ~UINT64(0);
|
||||
private:
|
||||
@ -507,13 +507,13 @@ private:
|
||||
UINT64 m_itemnum; // item number
|
||||
sha1_t m_sha1; // SHA-1 of the block
|
||||
};
|
||||
|
||||
|
||||
// block of entries
|
||||
struct entry_block
|
||||
{
|
||||
entry_block(entry_block *prev)
|
||||
: m_next(prev), m_nextalloc(0) { }
|
||||
|
||||
|
||||
entry_block * m_next; // next block in list
|
||||
UINT32 m_nextalloc; // next to be allocated
|
||||
entry_t m_array[16384]; // array of entries
|
||||
@ -532,7 +532,7 @@ private:
|
||||
WS_QUEUED,
|
||||
WS_COMPLETE
|
||||
};
|
||||
|
||||
|
||||
// a CRC-16/SHA-1 pair
|
||||
struct hash_pair
|
||||
{
|
||||
@ -540,7 +540,7 @@ private:
|
||||
sha1_t m_sha1; // calculated SHA-1
|
||||
};
|
||||
|
||||
// a single work item
|
||||
// a single work item
|
||||
struct work_item
|
||||
{
|
||||
osd_work_item * m_osd; // OSD work item running on this block
|
||||
@ -554,7 +554,7 @@ private:
|
||||
chd_compressor_group *m_codecs; // codec instance
|
||||
dynamic_array<hash_pair> m_hash; // array of hashes
|
||||
};
|
||||
|
||||
|
||||
// internal helpers
|
||||
static void *async_walk_parent_static(void *param, int threadid);
|
||||
void async_walk_parent(work_item &item);
|
||||
@ -563,15 +563,15 @@ private:
|
||||
static void *async_read_static(void *param, int threadid);
|
||||
void async_read();
|
||||
|
||||
// current compression status
|
||||
bool m_walking_parent; // are we building the parent map?
|
||||
// current compression status
|
||||
bool m_walking_parent; // are we building the parent map?
|
||||
UINT64 m_total_in; // total bytes in
|
||||
UINT64 m_total_out; // total bytes out
|
||||
sha1_creator m_compsha1; // running SHA-1 on raw data
|
||||
|
||||
// hash lookup maps
|
||||
hashmap m_parent_map; // hash map for parent
|
||||
hashmap m_current_map; // hash map for current
|
||||
hashmap m_parent_map; // hash map for parent
|
||||
hashmap m_current_map; // hash map for current
|
||||
|
||||
// read I/O thread
|
||||
osd_work_queue * m_read_queue; // work queue for reading
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
// construction/destruction
|
||||
chd_zlib_allocator();
|
||||
~chd_zlib_allocator();
|
||||
|
||||
|
||||
// installation
|
||||
void install(z_stream &stream);
|
||||
|
||||
@ -150,7 +150,7 @@ public:
|
||||
|
||||
// core functionality
|
||||
virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest);
|
||||
|
||||
|
||||
// helpers
|
||||
static void configure_properties(CLzmaEncProps &props, chd_file &chd);
|
||||
|
||||
@ -346,7 +346,7 @@ class chd_avhuff_compressor : public chd_compressor
|
||||
public:
|
||||
// construction/destruction
|
||||
chd_avhuff_compressor(chd_file &chd, bool lossy);
|
||||
|
||||
|
||||
// core functionality
|
||||
virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest);
|
||||
|
||||
@ -368,7 +368,7 @@ class chd_avhuff_decompressor : public chd_decompressor
|
||||
public:
|
||||
// construction/destruction
|
||||
chd_avhuff_decompressor(chd_file &chd, bool lossy);
|
||||
|
||||
|
||||
// core functionality
|
||||
virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen);
|
||||
virtual void configure(int param, void *config);
|
||||
@ -420,7 +420,7 @@ chd_codec::chd_codec(chd_file &file, bool lossy)
|
||||
chd_codec::~chd_codec()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// configure - configuration
|
||||
@ -597,7 +597,7 @@ INT8 chd_compressor_group::find_best_compressor(const UINT8 *src, UINT8 *compres
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
if (memcmp(src, m_decompressed, m_hunkbytes) != 0)
|
||||
{
|
||||
compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, m_compress_test);
|
||||
@ -621,13 +621,13 @@ printf(" codec%d=%d bytes \n", codecnum, compbytes);
|
||||
}
|
||||
catch (...) { }
|
||||
}
|
||||
|
||||
|
||||
// if the best is none, copy it over
|
||||
if (compression == -1)
|
||||
memcpy(compressed, src, m_hunkbytes);
|
||||
return compression;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -832,7 +832,7 @@ chd_zlib_decompressor::~chd_zlib_decompressor()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decompress - decompress data using the ZLIB
|
||||
// decompress - decompress data using the ZLIB
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -869,7 +869,7 @@ chd_lzma_allocator::chd_lzma_allocator()
|
||||
{
|
||||
// reset pointer list
|
||||
memset(m_allocptr, 0, sizeof(m_allocptr));
|
||||
|
||||
|
||||
// set our pointers
|
||||
Alloc = &chd_lzma_allocator::fast_alloc;
|
||||
Free = &chd_lzma_allocator::fast_free;
|
||||
@ -936,7 +936,7 @@ void chd_lzma_allocator::fast_free(void *p, void *address)
|
||||
{
|
||||
if (address == NULL)
|
||||
return;
|
||||
|
||||
|
||||
chd_lzma_allocator *codec = reinterpret_cast<chd_lzma_allocator *>(p);
|
||||
|
||||
// find the hunk
|
||||
@ -994,7 +994,7 @@ UINT32 chd_lzma_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des
|
||||
SRes res = LzmaEnc_SetProps(encoder, &m_props);
|
||||
if (res != SZ_OK)
|
||||
throw CHDERR_COMPRESSION_ERROR;
|
||||
|
||||
|
||||
// run it
|
||||
SizeT complen = srclen;
|
||||
res = LzmaEnc_MemEncode(encoder, dest, &complen, src, srclen, 0, NULL, &m_allocator, &m_allocator);
|
||||
@ -1046,14 +1046,14 @@ chd_lzma_decompressor::chd_lzma_decompressor(chd_file &chd, bool lossy)
|
||||
// configure the properties like the compressor did
|
||||
CLzmaEncProps encoder_props;
|
||||
chd_lzma_compressor::configure_properties(encoder_props, chd);
|
||||
|
||||
|
||||
// convert to decoder properties
|
||||
CLzmaProps decoder_props;
|
||||
decoder_props.lc = encoder_props.lc;
|
||||
decoder_props.lp = encoder_props.lp;
|
||||
decoder_props.pb = encoder_props.pb;
|
||||
decoder_props.dicSize = encoder_props.dictSize;
|
||||
|
||||
|
||||
// do memory allocations
|
||||
SRes res = LzmaDec_Allocate_MAME(&m_decoder, &decoder_props, &m_allocator);
|
||||
if (res != SZ_OK)
|
||||
@ -1073,7 +1073,7 @@ chd_lzma_decompressor::~chd_lzma_decompressor()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decompress - decompress data using the LZMA
|
||||
// decompress - decompress data using the LZMA
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1081,7 +1081,7 @@ void chd_lzma_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *
|
||||
{
|
||||
// initialize
|
||||
LzmaDec_Init(&m_decoder);
|
||||
|
||||
|
||||
// decode
|
||||
SizeT consumedlen = complen;
|
||||
SizeT decodedlen = destlen;
|
||||
@ -1108,7 +1108,7 @@ chd_huffman_compressor::chd_huffman_compressor(chd_file &chd, bool lossy)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// compress - compress data using the Huffman
|
||||
// compress - compress data using the Huffman
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1137,7 +1137,7 @@ chd_huffman_decompressor::chd_huffman_decompressor(chd_file &chd, bool lossy)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decompress - decompress data using the Huffman
|
||||
// decompress - decompress data using the Huffman
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1167,7 +1167,7 @@ chd_flac_compressor::chd_flac_compressor(chd_file &chd, bool lossy, bool bigendi
|
||||
m_swap_endian = bigendian;
|
||||
else
|
||||
m_swap_endian = !bigendian;
|
||||
|
||||
|
||||
// configure the encoder
|
||||
m_encoder.set_sample_rate(44100);
|
||||
m_encoder.set_num_channels(2);
|
||||
@ -1218,7 +1218,7 @@ chd_flac_decompressor::chd_flac_decompressor(chd_file &chd, bool lossy, bool big
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decompress - decompress data using the FLAC
|
||||
// decompress - decompress data using the FLAC
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1256,7 +1256,7 @@ chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, bool lossy)
|
||||
UINT16 native_endian = 0;
|
||||
*reinterpret_cast<UINT8 *>(&native_endian) = 1;
|
||||
m_swap_endian = (native_endian == 1);
|
||||
|
||||
|
||||
// configure the encoder
|
||||
m_encoder.set_sample_rate(44100);
|
||||
m_encoder.set_num_channels(2);
|
||||
@ -1310,7 +1310,7 @@ UINT32 chd_cd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *
|
||||
|
||||
// finish up
|
||||
UINT32 complen = m_encoder.finish();
|
||||
|
||||
|
||||
// deflate the subcode data
|
||||
m_deflater.next_in = const_cast<Bytef *>(&m_buffer[frames * CD_MAX_SECTOR_DATA]);
|
||||
m_deflater.avail_in = frames * CD_MAX_SUBCODE_DATA;
|
||||
@ -1380,7 +1380,7 @@ chd_cd_flac_decompressor::~chd_cd_flac_decompressor()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decompress - decompress data using the FLAC
|
||||
// decompress - decompress data using the FLAC
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1410,7 +1410,7 @@ void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT
|
||||
zerr = inflate(&m_inflater, Z_FINISH);
|
||||
if (m_inflater.total_out != frames * CD_MAX_SUBCODE_DATA)
|
||||
throw CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
|
||||
// reassemble the data
|
||||
for (UINT32 framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
@ -1474,8 +1474,8 @@ UINT32 chd_avhuff_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *d
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// postinit - actual initialization of avhuff
|
||||
// happens here, on the first attempt to compress
|
||||
// postinit - actual initialization of avhuff
|
||||
// happens here, on the first attempt to compress
|
||||
// or decompress data
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1520,7 +1520,7 @@ chd_avhuff_decompressor::chd_avhuff_decompressor(chd_file &chd, bool lossy)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decompress - decompress data using the A/V
|
||||
// decompress - decompress data using the A/V
|
||||
// codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1542,7 +1542,7 @@ void chd_avhuff_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// config - codec-specific configuration for the
|
||||
// config - codec-specific configuration for the
|
||||
// A/V codec
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1551,7 +1551,7 @@ void chd_avhuff_decompressor::configure(int param, void *config)
|
||||
// if we're getting the decompression configuration, apply it now
|
||||
if (param == AVHUFF_CODEC_DECOMPRESS_CONFIG)
|
||||
m_decoder.configure(*reinterpret_cast<avhuff_decompress_config *>(config));
|
||||
|
||||
|
||||
// anything else is invalid
|
||||
else
|
||||
throw CHDERR_INVALID_PARAMETER;
|
||||
|
@ -75,7 +75,7 @@ class chd_codec
|
||||
protected:
|
||||
// can't create these directly
|
||||
chd_codec(chd_file &file, bool lossy);
|
||||
|
||||
|
||||
public:
|
||||
// allow public deletion
|
||||
virtual ~chd_codec();
|
||||
@ -133,7 +133,7 @@ public:
|
||||
// create compressors or decompressors
|
||||
static chd_compressor *new_compressor(chd_codec_type type, chd_file &file);
|
||||
static chd_decompressor *new_decompressor(chd_codec_type type, chd_file &file);
|
||||
|
||||
|
||||
// utilities
|
||||
static bool codec_exists(chd_codec_type type) { return (find_in_list(type) != NULL); }
|
||||
static const char *codec_name(chd_codec_type type);
|
||||
@ -151,7 +151,7 @@ private:
|
||||
|
||||
// internal helper functions
|
||||
static const codec_entry *find_in_list(chd_codec_type type);
|
||||
|
||||
|
||||
template<class _CompressorClass>
|
||||
static chd_compressor *construct_compressor(chd_file &chd, bool lossy) { return new _CompressorClass(chd, lossy); }
|
||||
|
||||
@ -172,10 +172,10 @@ public:
|
||||
// construction/destruction
|
||||
chd_compressor_group(chd_file &file, chd_codec_type compressor_list[4]);
|
||||
~chd_compressor_group();
|
||||
|
||||
|
||||
// find the best compressor
|
||||
INT8 find_best_compressor(const UINT8 *src, UINT8 *compressed, UINT32 &complen);
|
||||
|
||||
|
||||
private:
|
||||
// internal state
|
||||
UINT32 m_hunkbytes; // number of bytes in a hunk
|
||||
@ -197,10 +197,10 @@ private:
|
||||
const chd_codec_type CHD_CODEC_NONE = 0;
|
||||
const chd_codec_type CHD_CODEC_ZLIB = CHD_MAKE_TAG('z','l','i','b');
|
||||
const chd_codec_type CHD_CODEC_LZMA = CHD_MAKE_TAG('l','z','m','a');
|
||||
const chd_codec_type CHD_CODEC_HUFFMAN = CHD_MAKE_TAG('h','u','f','f');
|
||||
const chd_codec_type CHD_CODEC_FLAC_BE = CHD_MAKE_TAG('f','l','c','b');
|
||||
const chd_codec_type CHD_CODEC_FLAC_LE = CHD_MAKE_TAG('f','l','c','l');
|
||||
const chd_codec_type CHD_CODEC_CD_FLAC = CHD_MAKE_TAG('c','d','f','l');
|
||||
const chd_codec_type CHD_CODEC_HUFFMAN = CHD_MAKE_TAG('h','u','f','f');
|
||||
const chd_codec_type CHD_CODEC_FLAC_BE = CHD_MAKE_TAG('f','l','c','b');
|
||||
const chd_codec_type CHD_CODEC_FLAC_LE = CHD_MAKE_TAG('f','l','c','l');
|
||||
const chd_codec_type CHD_CODEC_CD_FLAC = CHD_MAKE_TAG('c','d','f','l');
|
||||
const chd_codec_type CHD_CODEC_AVHUFF = CHD_MAKE_TAG('a','v','h','u');
|
||||
|
||||
// A/V codec configuration parameters
|
||||
|
@ -59,7 +59,7 @@ private:
|
||||
|
||||
public:
|
||||
// construction/destruction
|
||||
dynamic_array(int initial = 0)
|
||||
dynamic_array(int initial = 0)
|
||||
: m_array(NULL),
|
||||
m_count(0),
|
||||
m_allocated(0) { if (initial != 0) expand_internal(initial); m_count = initial; }
|
||||
@ -73,7 +73,7 @@ public:
|
||||
|
||||
// simple getters
|
||||
int count() const { return m_count; }
|
||||
|
||||
|
||||
// helpers
|
||||
void append(const _ElementType &element) { if (m_count == m_allocated) expand_internal((m_allocated == 0) ? 16 : (m_allocated << 1), true); m_array[m_count++] = element; }
|
||||
void reset() { delete[] m_array; m_array = NULL; m_count = m_allocated = 0; }
|
||||
|
@ -82,7 +82,7 @@ flac_encoder::~flac_encoder()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// reset - reset state with the original
|
||||
// reset - reset state with the original
|
||||
// parameters
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -96,7 +96,7 @@ bool flac_encoder::reset()
|
||||
// configure the encoder in a standard way
|
||||
// note we do this on each reset; if we don't, results are NOT consistent!
|
||||
FLAC__stream_encoder_set_verify(m_encoder, false);
|
||||
// FLAC__stream_encoder_set_do_md5(m_encoder, false);
|
||||
// FLAC__stream_encoder_set_do_md5(m_encoder, false);
|
||||
FLAC__stream_encoder_set_compression_level(m_encoder, 8);
|
||||
FLAC__stream_encoder_set_channels(m_encoder, m_channels);
|
||||
FLAC__stream_encoder_set_bits_per_sample(m_encoder, 16);
|
||||
@ -161,7 +161,7 @@ bool flac_encoder::encode_interleaved(const INT16 *samples, UINT32 samples_per_c
|
||||
for (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++)
|
||||
for (int channel = 0; channel < num_channels; channel++, srcindex++)
|
||||
*dest++ = INT16((UINT16(samples[srcindex]) << shift) | (UINT16(samples[srcindex]) >> shift));
|
||||
|
||||
|
||||
// process this batch
|
||||
if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples))
|
||||
return false;
|
||||
@ -194,7 +194,7 @@ bool flac_encoder::encode(INT16 *const *samples, UINT32 samples_per_channel, boo
|
||||
for (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++, srcindex++)
|
||||
for (int channel = 0; channel < num_channels; channel++)
|
||||
*dest++ = INT16((UINT16(samples[channel][srcindex]) << shift) | (UINT16(samples[channel][srcindex]) >> shift));
|
||||
|
||||
|
||||
// process this batch
|
||||
if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples))
|
||||
return false;
|
||||
@ -205,7 +205,7 @@ bool flac_encoder::encode(INT16 *const *samples, UINT32 samples_per_channel, boo
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// finish - complete encoding and flush the
|
||||
// finish - complete encoding and flush the
|
||||
// stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -227,7 +227,7 @@ void flac_encoder::init_common()
|
||||
m_encoder = FLAC__stream_encoder_new();
|
||||
if (m_encoder == NULL)
|
||||
throw std::bad_alloc();
|
||||
|
||||
|
||||
// initialize default state
|
||||
m_file = NULL;
|
||||
m_compressed_offset = 0;
|
||||
@ -243,7 +243,7 @@ void flac_encoder::init_common()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// write_callback - handle writes to the
|
||||
// write_callback - handle writes to the
|
||||
// output stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -265,7 +265,7 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf
|
||||
offset += ignore;
|
||||
m_ignore_bytes -= ignore;
|
||||
}
|
||||
|
||||
|
||||
// if we haven't hit the end of metadata, process a new piece
|
||||
else if (!m_found_audio)
|
||||
{
|
||||
@ -275,7 +275,7 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
// otherwise process as audio data and copy to the output
|
||||
// otherwise process as audio data and copy to the output
|
||||
else
|
||||
{
|
||||
int count = bytes - offset;
|
||||
@ -360,21 +360,21 @@ flac_decoder::~flac_decoder()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// reset - reset state with the original
|
||||
// reset - reset state with the original
|
||||
// parameters
|
||||
//-------------------------------------------------
|
||||
|
||||
bool flac_decoder::reset()
|
||||
{
|
||||
m_compressed_offset = 0;
|
||||
if (FLAC__stream_decoder_init_stream(m_decoder,
|
||||
&flac_decoder::read_callback_static,
|
||||
NULL,
|
||||
&flac_decoder::tell_callback_static,
|
||||
NULL,
|
||||
NULL,
|
||||
&flac_decoder::write_callback_static,
|
||||
&flac_decoder::metadata_callback_static,
|
||||
if (FLAC__stream_decoder_init_stream(m_decoder,
|
||||
&flac_decoder::read_callback_static,
|
||||
NULL,
|
||||
&flac_decoder::tell_callback_static,
|
||||
NULL,
|
||||
NULL,
|
||||
&flac_decoder::write_callback_static,
|
||||
&flac_decoder::metadata_callback_static,
|
||||
&flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||
return false;
|
||||
return FLAC__stream_decoder_process_until_end_of_metadata(m_decoder);
|
||||
@ -407,15 +407,15 @@ bool flac_decoder::reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_si
|
||||
static const UINT8 s_header_template[0x2a] =
|
||||
{
|
||||
0x66, 0x4C, 0x61, 0x43, // +00: 'fLaC' stream header
|
||||
0x80, // +04: metadata block type 0 (STREAMINFO),
|
||||
0x80, // +04: metadata block type 0 (STREAMINFO),
|
||||
// flagged as last block
|
||||
0x00, 0x00, 0x22, // +05: metadata block length = 0x22
|
||||
0x00, 0x00, 0x22, // +05: metadata block length = 0x22
|
||||
0x00, 0x00, // +08: minimum block size
|
||||
0x00, 0x00, // +0A: maximum block size
|
||||
0x00, 0x00, 0x00, // +0C: minimum frame size (0 == unknown)
|
||||
0x00, 0x00, 0x00, // +0F: maximum frame size (0 == unknown)
|
||||
0x0A, 0xC4, 0x42, 0xF0, 0x00, 0x00, 0x00, 0x00, // +12: sample rate (0x0ac44 == 44100),
|
||||
// numchannels (2), sample bits (16),
|
||||
0x00, 0x00, 0x00, // +0C: minimum frame size (0 == unknown)
|
||||
0x00, 0x00, 0x00, // +0F: maximum frame size (0 == unknown)
|
||||
0x0A, 0xC4, 0x42, 0xF0, 0x00, 0x00, 0x00, 0x00, // +12: sample rate (0x0ac44 == 44100),
|
||||
// numchannels (2), sample bits (16),
|
||||
// samples in stream (0 == unknown)
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // +1A: MD5 signature (0 == none)
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 //
|
||||
@ -466,7 +466,7 @@ bool flac_decoder::decode_interleaved(INT16 *samples, UINT32 num_samples, bool s
|
||||
m_uncompressed_offset = 0;
|
||||
m_uncompressed_length = num_samples;
|
||||
m_uncompressed_swap = swap_endian;
|
||||
|
||||
|
||||
// loop until we get everything we want
|
||||
while (m_uncompressed_offset < m_uncompressed_length)
|
||||
if (!FLAC__stream_decoder_process_single(m_decoder))
|
||||
@ -494,7 +494,7 @@ bool flac_decoder::decode(INT16 **samples, UINT32 num_samples, bool swap_endian)
|
||||
m_uncompressed_offset = 0;
|
||||
m_uncompressed_length = num_samples;
|
||||
m_uncompressed_swap = swap_endian;
|
||||
|
||||
|
||||
// loop until we get everything we want
|
||||
while (m_uncompressed_offset < m_uncompressed_length)
|
||||
if (!FLAC__stream_decoder_process_single(m_decoder))
|
||||
@ -513,7 +513,7 @@ UINT32 flac_decoder::finish()
|
||||
FLAC__uint64 position = 0;
|
||||
FLAC__stream_decoder_get_decode_position(m_decoder, &position);
|
||||
FLAC__stream_decoder_finish(m_decoder);
|
||||
|
||||
|
||||
// adjust position if we provided the header
|
||||
if (position == 0)
|
||||
return 0;
|
||||
@ -536,11 +536,11 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback_static(const FLAC__Str
|
||||
FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], size_t *bytes)
|
||||
{
|
||||
UINT32 expected = *bytes;
|
||||
|
||||
|
||||
// if a file, just read
|
||||
if (m_file != NULL)
|
||||
*bytes = core_fread(m_file, buffer, expected);
|
||||
|
||||
|
||||
// otherwise, copy from memory
|
||||
else
|
||||
{
|
||||
@ -553,7 +553,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s
|
||||
outputpos += bytes_to_copy;
|
||||
m_compressed_offset += bytes_to_copy;
|
||||
}
|
||||
|
||||
|
||||
// once we're out of that, copy from the secondary buffer
|
||||
if (outputpos < *bytes && m_compressed_offset < m_compressed_length + m_compressed2_length)
|
||||
{
|
||||
@ -579,7 +579,7 @@ void flac_decoder::metadata_callback_static(const FLAC__StreamDecoder *decoder,
|
||||
// ignore all but STREAMINFO metadata
|
||||
if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO)
|
||||
return;
|
||||
|
||||
|
||||
// parse out the data we care about
|
||||
flac_decoder *fldecoder = reinterpret_cast<flac_decoder *>(client_data);
|
||||
fldecoder->m_sample_rate = metadata->data.stream_info.sample_rate;
|
||||
@ -613,7 +613,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback_static(const FLAC__S
|
||||
FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
|
||||
{
|
||||
assert(frame->header.channels == channels());
|
||||
|
||||
|
||||
// interleaved case
|
||||
int shift = m_uncompressed_swap ? 8 : 0;
|
||||
int blocksize = frame->header.blocksize;
|
||||
@ -624,7 +624,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame
|
||||
for (int chan = 0; chan < frame->header.channels; chan++)
|
||||
*dest++ = INT16((UINT16(buffer[chan][sampnum]) << shift) | (UINT16(buffer[chan][sampnum]) >> shift));
|
||||
}
|
||||
|
||||
|
||||
// non-interleaved case
|
||||
else
|
||||
{
|
||||
|
@ -67,16 +67,16 @@ public:
|
||||
void set_num_channels(UINT8 num_channels) { m_channels = num_channels; }
|
||||
void set_block_size(UINT32 block_size) { m_block_size = block_size; }
|
||||
void set_strip_metadata(bool strip) { m_strip_metadata = strip; }
|
||||
|
||||
|
||||
// getters (valid after reset)
|
||||
FLAC__StreamEncoderState state() const { return FLAC__stream_encoder_get_state(m_encoder); }
|
||||
const char *state_string() const { return FLAC__stream_encoder_get_resolved_state_string(m_encoder); }
|
||||
|
||||
|
||||
// reset
|
||||
bool reset();
|
||||
bool reset(void *buffer, UINT32 buflength);
|
||||
bool reset(core_file &file);
|
||||
|
||||
|
||||
// encode a buffer
|
||||
bool encode_interleaved(const INT16 *samples, UINT32 samples_per_channel, bool swap_endian = false);
|
||||
bool encode(INT16 *const *samples, UINT32 samples_per_channel, bool swap_endian = false);
|
||||
@ -96,14 +96,14 @@ private:
|
||||
UINT32 m_compressed_offset; // current offset with the compressed stream
|
||||
FLAC__byte * m_compressed_start; // start of compressed data
|
||||
UINT32 m_compressed_length; // length of the compressed stream
|
||||
|
||||
|
||||
// parameters
|
||||
UINT32 m_sample_rate; // sample rate
|
||||
UINT8 m_channels; // number of channels
|
||||
UINT32 m_block_size; // block size
|
||||
|
||||
// header stripping
|
||||
bool m_strip_metadata; // strip the the metadata?
|
||||
bool m_strip_metadata; // strip the the metadata?
|
||||
UINT32 m_ignore_bytes; // how many bytes to ignore when writing
|
||||
bool m_found_audio; // have we hit the audio yet?
|
||||
};
|
||||
@ -119,7 +119,7 @@ public:
|
||||
flac_decoder(const void *buffer, UINT32 length, const void *buffer2 = NULL, UINT32 length2 = 0);
|
||||
flac_decoder(core_file &file);
|
||||
~flac_decoder();
|
||||
|
||||
|
||||
// getters (valid after reset)
|
||||
UINT32 sample_rate() const { return m_sample_rate; }
|
||||
UINT8 channels() const { return m_channels; }
|
||||
@ -127,13 +127,13 @@ public:
|
||||
UINT32 total_samples() const { return FLAC__stream_decoder_get_total_samples(m_decoder); }
|
||||
FLAC__StreamDecoderState state() const { return FLAC__stream_decoder_get_state(m_decoder); }
|
||||
const char *state_string() const { return FLAC__stream_decoder_get_resolved_state_string(m_decoder); }
|
||||
|
||||
|
||||
// reset
|
||||
bool reset();
|
||||
bool reset(const void *buffer, UINT32 length, const void *buffer2 = NULL, UINT32 length2 = 0);
|
||||
bool reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_size, const void *buffer, UINT32 length);
|
||||
bool reset(core_file &file);
|
||||
|
||||
|
||||
// decode to a buffer; num_samples must be a multiple of the block size
|
||||
bool decode_interleaved(INT16 *samples, UINT32 num_samples, bool swap_endian = false);
|
||||
bool decode(INT16 **samples, UINT32 num_samples, bool swap_endian = false);
|
||||
|
@ -1,39 +1,39 @@
|
||||
/***************************************************************************
|
||||
|
||||
hashing.c
|
||||
hashing.c
|
||||
|
||||
Hashing helper classes.
|
||||
Hashing helper classes.
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -57,7 +57,7 @@ const sha1_t sha1_t::null = { { 0 } };
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// char_to_hex - return the hex value of a
|
||||
// char_to_hex - return the hex value of a
|
||||
// character
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -89,7 +89,7 @@ bool sha1_t::from_string(const char *string, int length)
|
||||
length = strlen(string);
|
||||
if (length < 2 * sizeof(m_raw))
|
||||
return false;
|
||||
|
||||
|
||||
// iterate through our raw buffer
|
||||
for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++)
|
||||
{
|
||||
@ -111,7 +111,7 @@ const char *sha1_t::as_string(astring &buffer) const
|
||||
{
|
||||
buffer.reset();
|
||||
for (int i = 0; i < ARRAY_LENGTH(m_raw); i++)
|
||||
buffer.catformat("%02x", m_raw[i]);
|
||||
buffer.catformat("%02x", m_raw[i]);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ bool md5_t::from_string(const char *string, int length)
|
||||
length = strlen(string);
|
||||
if (length < 2 * sizeof(m_raw))
|
||||
return false;
|
||||
|
||||
|
||||
// iterate through our raw buffer
|
||||
for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++)
|
||||
{
|
||||
@ -153,7 +153,7 @@ const char *md5_t::as_string(astring &buffer) const
|
||||
{
|
||||
buffer.reset();
|
||||
for (int i = 0; i < ARRAY_LENGTH(m_raw); i++)
|
||||
buffer.catformat("%02x", m_raw[i]);
|
||||
buffer.catformat("%02x", m_raw[i]);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ bool crc32_t::from_string(const char *string, int length)
|
||||
length = strlen(string);
|
||||
if (length < 2 * sizeof(m_raw))
|
||||
return false;
|
||||
|
||||
|
||||
// iterate through our raw buffer
|
||||
m_raw = 0;
|
||||
for (int bytenum = 0; bytenum < sizeof(m_raw) * 2; bytenum++)
|
||||
@ -199,7 +199,7 @@ const char *crc32_t::as_string(astring &buffer) const
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// append - hash a block of data, appending to
|
||||
// append - hash a block of data, appending to
|
||||
// the currently-accumulated value
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -225,7 +225,7 @@ bool crc16_t::from_string(const char *string, int length)
|
||||
length = strlen(string);
|
||||
if (length < 2 * sizeof(m_raw))
|
||||
return false;
|
||||
|
||||
|
||||
// iterate through our raw buffer
|
||||
m_raw = 0;
|
||||
for (int bytenum = 0; bytenum < sizeof(m_raw) * 2; bytenum++)
|
||||
@ -250,13 +250,13 @@ const char *crc16_t::as_string(astring &buffer) const
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// append - hash a block of data, appending to
|
||||
// append - hash a block of data, appending to
|
||||
// the currently-accumulated value
|
||||
//-------------------------------------------------
|
||||
|
||||
void crc16_creator::append(const void *data, UINT32 length)
|
||||
{
|
||||
static const UINT16 s_table[256] =
|
||||
static const UINT16 s_table[256] =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
@ -293,7 +293,7 @@ void crc16_creator::append(const void *data, UINT32 length)
|
||||
};
|
||||
|
||||
const UINT8 *src = reinterpret_cast<const UINT8 *>(data);
|
||||
|
||||
|
||||
// fetch the current value into a local and rip through the source data
|
||||
UINT16 crc = m_accum.m_raw;
|
||||
while (length-- != 0)
|
||||
|
@ -1,39 +1,39 @@
|
||||
/***************************************************************************
|
||||
|
||||
hashing.h
|
||||
hashing.h
|
||||
|
||||
Hashing helper classes.
|
||||
Hashing helper classes.
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -73,13 +73,13 @@ class sha1_creator
|
||||
public:
|
||||
// construction/destruction
|
||||
sha1_creator() { reset(); }
|
||||
|
||||
|
||||
// reset
|
||||
void reset() { sha1_init(&m_context); }
|
||||
|
||||
|
||||
// append data
|
||||
void append(const void *data, UINT32 length) { sha1_update(&m_context, length, reinterpret_cast<const UINT8 *>(data)); }
|
||||
|
||||
|
||||
// finalize and compute the final digest
|
||||
sha1_t finish()
|
||||
{
|
||||
@ -92,8 +92,8 @@ public:
|
||||
// static wrapper to just get the digest from a block
|
||||
static sha1_t simple(const void *data, UINT32 length)
|
||||
{
|
||||
sha1_creator creator;
|
||||
creator.append(data, length);
|
||||
sha1_creator creator;
|
||||
creator.append(data, length);
|
||||
return creator.finish();
|
||||
}
|
||||
|
||||
@ -124,13 +124,13 @@ class md5_creator
|
||||
public:
|
||||
// construction/destruction
|
||||
md5_creator() { reset(); }
|
||||
|
||||
|
||||
// reset
|
||||
void reset() { MD5Init(&m_context); }
|
||||
|
||||
|
||||
// append data
|
||||
void append(const void *data, UINT32 length) { MD5Update(&m_context, reinterpret_cast<const unsigned char *>(data), length); }
|
||||
|
||||
|
||||
// finalize and compute the final digest
|
||||
md5_t finish()
|
||||
{
|
||||
@ -142,14 +142,14 @@ public:
|
||||
// static wrapper to just get the digest from a block
|
||||
static md5_t simple(const void *data, UINT32 length)
|
||||
{
|
||||
md5_creator creator;
|
||||
creator.append(data, length);
|
||||
md5_creator creator;
|
||||
creator.append(data, length);
|
||||
return creator.finish();
|
||||
}
|
||||
|
||||
protected:
|
||||
// internal state
|
||||
struct MD5Context m_context; // internal context
|
||||
struct MD5Context m_context; // internal context
|
||||
};
|
||||
|
||||
|
||||
@ -175,21 +175,21 @@ class crc32_creator
|
||||
public:
|
||||
// construction/destruction
|
||||
crc32_creator() { reset(); }
|
||||
|
||||
|
||||
// reset
|
||||
void reset() { m_accum.m_raw = 0; }
|
||||
|
||||
|
||||
// append data
|
||||
void append(const void *data, UINT32 length);
|
||||
|
||||
|
||||
// finalize and compute the final digest
|
||||
crc32_t finish() { return m_accum; }
|
||||
|
||||
// static wrapper to just get the digest from a block
|
||||
static crc32_t simple(const void *data, UINT32 length)
|
||||
{
|
||||
crc32_creator creator;
|
||||
creator.append(data, length);
|
||||
crc32_creator creator;
|
||||
creator.append(data, length);
|
||||
return creator.finish();
|
||||
}
|
||||
|
||||
@ -221,21 +221,21 @@ class crc16_creator
|
||||
public:
|
||||
// construction/destruction
|
||||
crc16_creator() { reset(); }
|
||||
|
||||
|
||||
// reset
|
||||
void reset() { m_accum.m_raw = 0xffff; }
|
||||
|
||||
|
||||
// append data
|
||||
void append(const void *data, UINT32 length);
|
||||
|
||||
|
||||
// finalize and compute the final digest
|
||||
crc16_t finish() { return m_accum; }
|
||||
|
||||
// static wrapper to just get the digest from a block
|
||||
static crc16_t simple(const void *data, UINT32 length)
|
||||
{
|
||||
crc16_creator creator;
|
||||
creator.append(data, length);
|
||||
crc16_creator creator;
|
||||
creator.append(data, length);
|
||||
return creator.finish();
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ huffman_context_base::huffman_context_base(int numcodes, int maxbits, lookup_val
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// import_tree_rle - import an RLE-encoded
|
||||
// import_tree_rle - import an RLE-encoded
|
||||
// huffman tree from a source data stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -215,7 +215,7 @@ huffman_error huffman_context_base::import_tree_rle(bitstream_in &bitbuf)
|
||||
huffman_error error = assign_canonical_codes();
|
||||
if (error != HUFFERR_NONE)
|
||||
return error;
|
||||
|
||||
|
||||
// build the lookup table
|
||||
build_lookup_table();
|
||||
|
||||
@ -267,7 +267,7 @@ huffman_error huffman_context_base::export_tree_rle(bitstream_out &bitbuf)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// import_tree_huffman - import a huffman-encoded
|
||||
// import_tree_huffman - import a huffman-encoded
|
||||
// huffman tree from a source data stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -288,13 +288,13 @@ huffman_error huffman_context_base::import_tree_huffman(bitstream_in &bitbuf)
|
||||
smallhuff.m_huffnode[index].m_numbits = (count == 7) ? 0 : count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// then regenerate the tree
|
||||
huffman_error error = smallhuff.assign_canonical_codes();
|
||||
if (error != HUFFERR_NONE)
|
||||
return error;
|
||||
smallhuff.build_lookup_table();
|
||||
|
||||
|
||||
// determine the maximum length of an RLE count
|
||||
UINT32 temp = m_numcodes - 9;
|
||||
UINT8 rlefullbits = 0;
|
||||
@ -337,7 +337,7 @@ huffman_error huffman_context_base::import_tree_huffman(bitstream_in &bitbuf)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// export_tree_huffman - export a huffman tree to
|
||||
// export_tree_huffman - export a huffman tree to
|
||||
// a huffman target data stream
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -350,7 +350,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
|
||||
UINT16 *lengths = rle_lengths;
|
||||
int last = ~0;
|
||||
int repcount = 0;
|
||||
|
||||
|
||||
// use a small huffman context to create a tree (ignoring RLE lengths)
|
||||
huffman_encoder<24, 6> smallhuff;
|
||||
|
||||
@ -363,14 +363,14 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
|
||||
{
|
||||
if (repcount == 1)
|
||||
smallhuff.histo_one(*dest++ = last + 1);
|
||||
else
|
||||
else
|
||||
smallhuff.histo_one(*dest++ = 0), *lengths++ = repcount - 2;
|
||||
}
|
||||
|
||||
|
||||
// if same as last, just track repeats
|
||||
if (newval == last)
|
||||
repcount++;
|
||||
|
||||
|
||||
// otherwise, write it and start a new run
|
||||
else
|
||||
{
|
||||
@ -385,7 +385,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
|
||||
{
|
||||
if (repcount == 1)
|
||||
smallhuff.histo_one(*dest++ = last + 1);
|
||||
else
|
||||
else
|
||||
smallhuff.histo_one(*dest++ = 0), *lengths++ = repcount - 2;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
|
||||
for (int index = first_non_zero; index <= last_non_zero; index++)
|
||||
bitbuf.write(smallhuff.m_huffnode[index].m_numbits, 3);
|
||||
bitbuf.write(7, 3);
|
||||
|
||||
|
||||
// determine the maximum length of an RLE count
|
||||
UINT32 temp = m_numcodes - 9;
|
||||
UINT8 rlefullbits = 0;
|
||||
@ -427,7 +427,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
|
||||
// encode the data
|
||||
UINT8 data = *src;
|
||||
smallhuff.encode_one(bitbuf, data);
|
||||
|
||||
|
||||
// if this is an RLE token, encode the length following
|
||||
if (data == 0)
|
||||
{
|
||||
@ -438,7 +438,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
|
||||
bitbuf.write(7, 3), bitbuf.write(count - 7, rlefullbits);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// flush the final buffer
|
||||
return bitbuf.overflow() ? HUFFERR_OUTPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
|
||||
}
|
||||
@ -540,7 +540,7 @@ int CLIB_DECL huffman_context_base::tree_node_compare(const void *item1, const v
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// build_tree - build a huffman tree based on the
|
||||
// build_tree - build a huffman tree based on the
|
||||
// data distribution
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -616,8 +616,8 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// assign_canonical_codes - assign canonical codes
|
||||
// to all the nodes based on the number of bits
|
||||
// assign_canonical_codes - assign canonical codes
|
||||
// to all the nodes based on the number of bits
|
||||
// in each
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -696,7 +696,7 @@ void huffman_context_base::build_lookup_table()
|
||||
huffman_8bit_encoder::huffman_8bit_encoder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// encode - encode a full buffer
|
||||
@ -713,13 +713,13 @@ huffman_error huffman_8bit_encoder::encode(const UINT8 *source, UINT32 slength,
|
||||
huffman_error err = compute_tree_from_histo();
|
||||
if (err != HUFFERR_NONE)
|
||||
return err;
|
||||
|
||||
|
||||
// export the tree
|
||||
bitstream_out bitbuf(dest, dlength);
|
||||
err = export_tree_huffman(bitbuf);
|
||||
if (err != HUFFERR_NONE)
|
||||
return err;
|
||||
|
||||
|
||||
// then encode the data
|
||||
for (UINT32 cur = 0; cur < slength; cur++)
|
||||
encode_one(bitbuf, source[cur]);
|
||||
@ -727,7 +727,7 @@ huffman_error huffman_8bit_encoder::encode(const UINT8 *source, UINT32 slength,
|
||||
return bitbuf.overflow() ? HUFFERR_OUTPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// 8-BIT DECODER
|
||||
@ -740,7 +740,7 @@ huffman_error huffman_8bit_encoder::encode(const UINT8 *source, UINT32 slength,
|
||||
huffman_8bit_decoder::huffman_8bit_decoder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// decode - decode a full buffer
|
||||
@ -753,7 +753,7 @@ huffman_error huffman_8bit_decoder::decode(const UINT8 *source, UINT32 slength,
|
||||
huffman_error err = import_tree_huffman(bitbuf);
|
||||
if (err != HUFFERR_NONE)
|
||||
return err;
|
||||
|
||||
|
||||
// then decode the data
|
||||
for (UINT32 cur = 0; cur < dlength; cur++)
|
||||
dest[cur] = decode_one(bitbuf);
|
||||
|
@ -84,7 +84,7 @@ protected:
|
||||
UINT32 m_bits; // bits used to encode the node
|
||||
UINT8 m_numbits; // number of bits needed for this node
|
||||
};
|
||||
|
||||
|
||||
// construction/destruction
|
||||
huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, UINT32 *histo, node_t *nodes);
|
||||
|
||||
@ -133,12 +133,12 @@ public:
|
||||
void histo_reset() { memset(m_datahisto_array, 0, sizeof(m_datahisto_array)); }
|
||||
void histo_one(UINT32 data);
|
||||
void encode_one(bitstream_out &bitbuf, UINT32 data);
|
||||
|
||||
|
||||
// expose tree computation and export
|
||||
using huffman_context_base::compute_tree_from_histo;
|
||||
using huffman_context_base::export_tree_rle;
|
||||
using huffman_context_base::export_tree_huffman;
|
||||
|
||||
|
||||
private:
|
||||
// array versions of the info we need
|
||||
UINT32 m_datahisto_array[_NumCodes];
|
||||
@ -159,11 +159,11 @@ public:
|
||||
|
||||
// single item operations
|
||||
UINT32 decode_one(bitstream_in &bitbuf);
|
||||
|
||||
|
||||
// expose tree import
|
||||
using huffman_context_base::import_tree_rle;
|
||||
using huffman_context_base::import_tree_huffman;
|
||||
|
||||
|
||||
private:
|
||||
// array versions of the info we need
|
||||
node_t m_huffnode_array[_NumCodes];
|
||||
@ -179,12 +179,12 @@ class huffman_8bit_encoder : public huffman_encoder<>
|
||||
public:
|
||||
// construction/destruction
|
||||
huffman_8bit_encoder();
|
||||
|
||||
|
||||
// operations
|
||||
huffman_error encode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength, UINT32 &complength);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================> huffman_8bit_decoder
|
||||
|
||||
// generic 8-bit encoder/decoder
|
||||
@ -193,7 +193,7 @@ class huffman_8bit_decoder : public huffman_decoder<>
|
||||
public:
|
||||
// construction/destruction
|
||||
huffman_8bit_decoder();
|
||||
|
||||
|
||||
// operations
|
||||
huffman_error decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength);
|
||||
};
|
||||
|
@ -91,7 +91,7 @@ WRes File_Close(CSzFile *p)
|
||||
|
||||
WRes File_Read(CSzFile *p, void *data, size_t *size)
|
||||
{
|
||||
// file_error err;
|
||||
// file_error err;
|
||||
UINT32 read_length;
|
||||
|
||||
if (!p->_7z_osdfile)
|
||||
@ -104,7 +104,7 @@ WRes File_Read(CSzFile *p, void *data, size_t *size)
|
||||
if (originalSize == 0)
|
||||
return 0;
|
||||
|
||||
// err =
|
||||
// err =
|
||||
osd_read( p->_7z_osdfile, data, p->_7z_currfpos, originalSize, &read_length );
|
||||
*size = read_length;
|
||||
p->_7z_currfpos += read_length;
|
||||
@ -127,7 +127,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
|
||||
if (origin==2) p->_7z_currfpos = p->_7z_length - *pos;
|
||||
|
||||
*pos = p->_7z_currfpos;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -263,11 +263,11 @@ int _7z_search_crc_match(_7z_file *new_7z, UINT32 search_crc, const char* search
|
||||
if ((zn>=0x41) && (zn<=0x5a)) zn+=0x20;
|
||||
|
||||
if (sn != zn) break;
|
||||
}
|
||||
}
|
||||
if (j==search_filename_length) namematch = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Check for a CRC match */
|
||||
if (crc==search_crc) crcmatch = true;
|
||||
|
||||
@ -289,9 +289,9 @@ int _7z_search_crc_match(_7z_file *new_7z, UINT32 search_crc, const char* search
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found)
|
||||
if (found)
|
||||
{
|
||||
// printf("found %S %d %08x %08x %08x %s %d\n", temp, len, crc, search_crc, size, search_filename, search_filename_length);
|
||||
// printf("found %S %d %08x %08x %08x %s %d\n", temp, len, crc, search_crc, size, search_filename, search_filename_length);
|
||||
new_7z->curr_file_idx = i;
|
||||
new_7z->uncompressed_length = size;
|
||||
new_7z->crc = crc;
|
||||
@ -364,7 +364,7 @@ _7z_error _7z_file_open(const char *filename, _7z_file **_7z)
|
||||
|
||||
FileInStream_CreateVTable(&new_7z->archiveStream);
|
||||
LookToRead_CreateVTable(&new_7z->lookStream, False);
|
||||
|
||||
|
||||
new_7z->lookStream.realStream = &new_7z->archiveStream.s;
|
||||
LookToRead_Init(&new_7z->lookStream);
|
||||
|
||||
@ -478,7 +478,7 @@ _7z_error _7z_file_decompress(_7z_file *new_7z, void *buffer, UINT32 length)
|
||||
&new_7z->blockIndex, &new_7z->outBuffer, &new_7z->outBufferSize,
|
||||
&offset, &outSizeProcessed,
|
||||
&new_7z->allocImp, &new_7z->allocTempImp);
|
||||
|
||||
|
||||
if (res != SZ_OK)
|
||||
return _7ZERR_FILE_ERROR;
|
||||
|
||||
@ -510,7 +510,7 @@ static void free__7z_file(_7z_file *_7z)
|
||||
|
||||
if (_7z->outBuffer) IAlloc_Free(&_7z->allocImp, _7z->outBuffer);
|
||||
if (_7z->inited) SzArEx_Free(&_7z->db, &_7z->allocImp);
|
||||
|
||||
|
||||
|
||||
free(_7z);
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ class ide_baseboard_device : public ide_hdd_device
|
||||
public:
|
||||
// construction/destruction
|
||||
ide_baseboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
|
||||
virtual int read_sector(UINT32 lba, void *buffer);
|
||||
virtual int write_sector(UINT32 lba, const void *buffer);
|
||||
virtual bool is_ready() { return true; }
|
||||
|
@ -430,7 +430,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
case 0x04:
|
||||
{
|
||||
state->m_blitterMode = (data & 0x00ff0000) >> 16;
|
||||
|
||||
|
||||
if (state->m_blitterMode == 0xf4)
|
||||
{
|
||||
// Some sort of addressing state.
|
||||
@ -456,7 +456,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// The data register
|
||||
case 0x05:
|
||||
{
|
||||
@ -470,9 +470,9 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
// DEBUG: Uncomment to see the ASCII strings as they are being blitted
|
||||
//if (state->m_blitterSerialCount >= state->m_textBytesToWrite)
|
||||
//{
|
||||
// for (int i = 0; i < state->m_textBytesToWrite+1; i++)
|
||||
// printf("%c", space->read_byte(0x03f40000 + state->m_textOffset + i));
|
||||
// printf("\n");
|
||||
// for (int i = 0; i < state->m_textBytesToWrite+1; i++)
|
||||
// printf("%c", space->read_byte(0x03f40000 + state->m_textOffset + i));
|
||||
// printf("\n");
|
||||
//}
|
||||
}
|
||||
else if (state->m_blitterMode == 0x30 || state->m_blitterMode == 0x90)
|
||||
@ -511,8 +511,8 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
}
|
||||
else if (state->m_blitterSerialCount == 11)
|
||||
{
|
||||
const UINT32 memOffset = data;
|
||||
|
||||
const UINT32 memOffset = data;
|
||||
|
||||
// Splat some sprites
|
||||
for (int h = 0; h < state->m_hCellCount; h++)
|
||||
{
|
||||
@ -520,11 +520,11 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
{
|
||||
const int pixelOffsetX = state->m_hPosition + (h*16);
|
||||
const int pixelOffsetY = state->m_vPosition + (v*16);
|
||||
|
||||
|
||||
// It's unknown if it's row-major or column-major
|
||||
// TODO: Study the CRT test and "Cool Riders" logo for clues.
|
||||
UINT8 spriteNumber = space->read_byte(memOffset + h + (v*h));
|
||||
|
||||
|
||||
// DEBUG: For demo purposes, skip spaces and NULL characters
|
||||
if (spriteNumber == 0x20 || spriteNumber == 0x00)
|
||||
continue;
|
||||
@ -541,7 +541,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
color = 0xff00ff00;
|
||||
else if (state->m_colorNumber == 0x5e)
|
||||
color = 0xff0000ff;
|
||||
else
|
||||
else
|
||||
color = 0xff00ffff;
|
||||
state->m_temp_bitmap_sprites.pix32(pixelOffsetY+y, pixelOffsetX+x) = color;
|
||||
}
|
||||
@ -549,7 +549,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
state->m_blitterSerialCount++;
|
||||
}
|
||||
break;
|
||||
|
@ -150,7 +150,7 @@ static WRITE8_DEVICE_HANDLER( kungfur_latch3_w )
|
||||
static WRITE8_DEVICE_HANDLER( kungfur_control_w )
|
||||
{
|
||||
kungfur_state *state = device->machine().driver_data<kungfur_state>();
|
||||
|
||||
|
||||
// d0-d3: N/C
|
||||
// d4: irq ack
|
||||
if (~data & 0x10)
|
||||
@ -193,7 +193,7 @@ static void kfr_adpcm1_int(device_t *device)
|
||||
kungfur_state *state = device->machine().driver_data<kungfur_state>();
|
||||
UINT8 *ROM = device->machine().region("adpcm1")->base();
|
||||
UINT8 data = ROM[state->m_adpcm_pos[0] & 0x1ffff];
|
||||
|
||||
|
||||
msm5205_data_w(device, state->m_adpcm_sel[0] ? data & 0xf : data >> 4 & 0xf);
|
||||
state->m_adpcm_pos[0] += state->m_adpcm_sel[0];
|
||||
state->m_adpcm_sel[0] ^= 1;
|
||||
@ -204,7 +204,7 @@ static void kfr_adpcm2_int(device_t *device)
|
||||
kungfur_state *state = device->machine().driver_data<kungfur_state>();
|
||||
UINT8 *ROM = device->machine().region("adpcm2")->base();
|
||||
UINT8 data = ROM[state->m_adpcm_pos[1] & 0x3ffff];
|
||||
|
||||
|
||||
msm5205_data_w(device, state->m_adpcm_sel[1] ? data & 0xf : data >> 4 & 0xf);
|
||||
state->m_adpcm_pos[1] += state->m_adpcm_sel[1];
|
||||
state->m_adpcm_sel[1] ^= 1;
|
||||
@ -244,10 +244,10 @@ static INPUT_PORTS_START( kungfur )
|
||||
PORT_DIPSETTING( 0x06, DEF_STR( 2C_1C ) )
|
||||
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )
|
||||
PORT_DIPSETTING( 0x03, DEF_STR( 1C_2C ) )
|
||||
// PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) // dupe
|
||||
// PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) // dupe
|
||||
PORT_DIPSETTING( 0x02, DEF_STR( 1C_3C ) )
|
||||
// PORT_DIPSETTING( 0x00, DEF_STR( 1C_3C ) ) // dupe
|
||||
// PORT_DIPSETTING( 0x04, DEF_STR( 0C_0C ) ) // invalid
|
||||
// PORT_DIPSETTING( 0x00, DEF_STR( 1C_3C ) ) // dupe
|
||||
// PORT_DIPSETTING( 0x04, DEF_STR( 0C_0C ) ) // invalid
|
||||
PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
|
||||
PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
|
||||
INPUT_PORTS_END
|
||||
|
@ -2152,7 +2152,7 @@ ROM_START( winrun )
|
||||
ROM_LOAD("wrvoi-0.11b", 0x040000, 0x40000, CRC(8040b645) SHA1(7ccafb3073fa79910e26cf9b8b6e8e9ae22e55fc) )
|
||||
ROM_LOAD("wrvoi-1.11c", 0x0c0000, 0x40000, CRC(d347e904) SHA1(620cd07e6230322c306283e45a43fa1e217028d4) )
|
||||
ROM_LOAD("wrvoi-2.11d", 0x140000, 0x40000, CRC(b34747af) SHA1(7e0b55631bffa0583bf4f7f5368db9f09e411ba1) )
|
||||
ROM_LOAD("wrvoi-3.11e", 0x1c0000, 0x40000, CRC(43085303) SHA1(9f743055c20df3548879118194244e37a0b91f7e) )
|
||||
ROM_LOAD("wrvoi-3.11e", 0x1c0000, 0x40000, CRC(43085303) SHA1(9f743055c20df3548879118194244e37a0b91f7e) )
|
||||
|
||||
ROM_REGION( 0x1000, "pals", 0 )
|
||||
/* Main PCB (2252960101) */
|
||||
@ -2541,4 +2541,4 @@ GAME( 1991, starblad, 0, poly_c140_typeA, s21default, starblad, ROT0,
|
||||
GAME( 1992, aircomb, 0, poly_c140_typeB, aircombt, aircombt, ROT0, "Namco", "Air Combat (US)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
|
||||
GAME( 1992, aircombj, aircomb, poly_c140_typeB, aircombt, aircombt, ROT0, "Namco", "Air Combat (Japan)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
|
||||
GAME( 1993, cybsled, 0, poly_c140_typeA, cybsled, cybsled, ROT0, "Namco", "Cyber Sled (US)", GAME_IMPERFECT_GRAPHICS )
|
||||
GAME( 1993, cybsledj, cybsled, poly_c140_typeA, cybsled, cybsled, ROT0, "Namco", "Cyber Sled (Japan)", GAME_IMPERFECT_GRAPHICS )
|
||||
GAME( 1993, cybsledj, cybsled, poly_c140_typeA, cybsled, cybsled, ROT0, "Namco", "Cyber Sled (Japan)", GAME_IMPERFECT_GRAPHICS )
|
||||
|
@ -967,8 +967,8 @@ Notes:
|
||||
J104 - 6 pin connector joined with a cable to J6 on the V198 EMI PCB. This cable is the I/O connection to/from the main board.
|
||||
J105 - 110VAC power input
|
||||
J106 - DC variable power output to feed-back motor
|
||||
|
||||
|
||||
|
||||
|
||||
Namco Gorgon-based games
|
||||
------------------------
|
||||
|
||||
|
@ -6861,7 +6861,7 @@ ROM_START( initdv3e )
|
||||
|
||||
ROM_REGION( 0x4300, "pic", ROMREGION_ERASEFF)
|
||||
//PIC16C622A (317-0384-COM)
|
||||
ROM_LOAD( "317-0384-com.pic", 0x000000, 0x004300, CRC(081ccd51) SHA1(598b3bd9e8b16f5954d15738c1ca55703609b690) )
|
||||
ROM_LOAD( "317-0384-com.pic", 0x000000, 0x004300, CRC(081ccd51) SHA1(598b3bd9e8b16f5954d15738c1ca55703609b690) )
|
||||
ROM_END
|
||||
|
||||
/*
|
||||
@ -7062,29 +7062,29 @@ ROM_START( soulsurf )
|
||||
|
||||
ROM_REGION( 0xb000000, "rom_board", ROMREGION_ERASEFF)
|
||||
// Cart has a Sega factory EPROM sticker stating "EPR-23838C" and a Sega factory sticker stating "Rev. A". Seriously.
|
||||
ROM_LOAD( "epr-23838c.ic22", 0x000000, 0x400000, CRC(5e5fb00f) SHA1(c5e81ebead9072cc08f09d1715d609cb0f7631ba) )
|
||||
ROM_LOAD( "epr-23838c.ic22", 0x000000, 0x400000, CRC(5e5fb00f) SHA1(c5e81ebead9072cc08f09d1715d609cb0f7631ba) )
|
||||
ROM_RELOAD( 0x400000, 0x400000)
|
||||
ROM_LOAD( "ssf01.ic1s", 0x0800000, 0x800000, CRC(4f12f789) SHA1(7b79b687fc61e2e981b9e5e8e0939c4ad24a98f0) )
|
||||
ROM_LOAD( "ssf02.ic2s", 0x1000000, 0x800000, CRC(a255d41a) SHA1(3e932527eb68edf3e8538c1ad264a1c599f6a9d5) )
|
||||
ROM_LOAD( "ssf03.ic3s", 0x1800000, 0x800000, CRC(0f8d6577) SHA1(afaf440e667bacc941c0a5418a0e3b0f2bb725b7) )
|
||||
ROM_LOAD( "ssf04.ic4s", 0x2000000, 0x800000, CRC(bdf25bd0) SHA1(f79b1fdba9c48969c49617c43c1919637adb13ba) )
|
||||
ROM_LOAD( "ssf05.ic5s", 0x2800000, 0x800000, CRC(a74b3bb4) SHA1(0ce7cef849061a9af7a61d69dc633f6971a3a63d) )
|
||||
ROM_LOAD( "ssf06.ic6s", 0x3000000, 0x800000, CRC(3cd1f5d5) SHA1(77573c3a60af64e6e6a0eb85d5b8176ed98b0723) )
|
||||
ROM_LOAD( "ssf07.ic7s", 0x3800000, 0x800000, CRC(00d240f5) SHA1(43010fc596f2cdffdff35a6122f2ab02a5251bc0) )
|
||||
ROM_LOAD( "ssf08.ic8s", 0x4000000, 0x800000, CRC(d4907fa1) SHA1(79b1c771819f6e4baa048010bfb940a45370eba2) )
|
||||
ROM_LOAD( "ssf09.ic9s", 0x4800000, 0x800000, CRC(6327d49e) SHA1(a10e3c27f70dbf18e63cf51962b6a79a52eba26c) )
|
||||
ROM_LOAD( "ssf10.ic10s", 0x5000000, 0x800000, CRC(7975dc80) SHA1(81bda50968f0153a0c4432d8d81e817c1e82e5b2) )
|
||||
ROM_LOAD( "ssf11.ic11s", 0x5800000, 0x800000, CRC(a242f682) SHA1(435ea5bb1b3667f9ef3d7de081b15f4e8e6a0d01) )
|
||||
ROM_LOAD( "ssf12.ic12s", 0x6000000, 0x800000, CRC(45fa259e) SHA1(8d7e708e7a2cbc2d60b68715dd79bac28d894d4c) )
|
||||
ROM_LOAD( "ssf13.ic13s", 0x6800000, 0x800000, CRC(e9578063) SHA1(618f66d01f6bdacbf2a3242774a316b130594e02) )
|
||||
ROM_LOAD( "ssf14.ic14s", 0x7000000, 0x800000, CRC(2edc1311) SHA1(bceb54dd29012580e2e6f15f16c6b31195010153) )
|
||||
ROM_LOAD( "ssf15.ic15s", 0x7800000, 0x800000, CRC(416db320) SHA1(34536716a35260d9457703704bb9174fb1616d60) )
|
||||
ROM_LOAD( "ssf16.ic16s", 0x8000000, 0x800000, CRC(2530cc04) SHA1(6425c031e5a129a3c9451bc694b5da8553f154c2) )
|
||||
ROM_LOAD( "ssf17.ic17s", 0x8800000, 0x800000, CRC(9e6afcc2) SHA1(4fb69d834ea12c82e897af47a22dcc47f3c83768) )
|
||||
ROM_LOAD( "ssf18.ic18s", 0x9000000, 0x800000, CRC(854ed5e5) SHA1(e445599f6a9e9d05c279259307edc08bce5d6d1f) )
|
||||
ROM_LOAD( "ssf19.ic19s", 0x9800000, 0x800000, CRC(4f8ec86a) SHA1(406ab9eeccd99fa5515d4a2c229c8db1a5cb8f83) )
|
||||
ROM_LOAD( "ssf20.ic20s", 0xa000000, 0x800000, CRC(c90b960d) SHA1(66e9f09d1f7f6a991371574a2e095c0e22fb7031) )
|
||||
ROM_LOAD( "ssf21.ic21s", 0xa800000, 0x800000, CRC(1477c064) SHA1(87fb8d8a91d6bed70b246a8df88fa77fbf3db443) )
|
||||
ROM_LOAD( "ssf01.ic1s", 0x0800000, 0x800000, CRC(4f12f789) SHA1(7b79b687fc61e2e981b9e5e8e0939c4ad24a98f0) )
|
||||
ROM_LOAD( "ssf02.ic2s", 0x1000000, 0x800000, CRC(a255d41a) SHA1(3e932527eb68edf3e8538c1ad264a1c599f6a9d5) )
|
||||
ROM_LOAD( "ssf03.ic3s", 0x1800000, 0x800000, CRC(0f8d6577) SHA1(afaf440e667bacc941c0a5418a0e3b0f2bb725b7) )
|
||||
ROM_LOAD( "ssf04.ic4s", 0x2000000, 0x800000, CRC(bdf25bd0) SHA1(f79b1fdba9c48969c49617c43c1919637adb13ba) )
|
||||
ROM_LOAD( "ssf05.ic5s", 0x2800000, 0x800000, CRC(a74b3bb4) SHA1(0ce7cef849061a9af7a61d69dc633f6971a3a63d) )
|
||||
ROM_LOAD( "ssf06.ic6s", 0x3000000, 0x800000, CRC(3cd1f5d5) SHA1(77573c3a60af64e6e6a0eb85d5b8176ed98b0723) )
|
||||
ROM_LOAD( "ssf07.ic7s", 0x3800000, 0x800000, CRC(00d240f5) SHA1(43010fc596f2cdffdff35a6122f2ab02a5251bc0) )
|
||||
ROM_LOAD( "ssf08.ic8s", 0x4000000, 0x800000, CRC(d4907fa1) SHA1(79b1c771819f6e4baa048010bfb940a45370eba2) )
|
||||
ROM_LOAD( "ssf09.ic9s", 0x4800000, 0x800000, CRC(6327d49e) SHA1(a10e3c27f70dbf18e63cf51962b6a79a52eba26c) )
|
||||
ROM_LOAD( "ssf10.ic10s", 0x5000000, 0x800000, CRC(7975dc80) SHA1(81bda50968f0153a0c4432d8d81e817c1e82e5b2) )
|
||||
ROM_LOAD( "ssf11.ic11s", 0x5800000, 0x800000, CRC(a242f682) SHA1(435ea5bb1b3667f9ef3d7de081b15f4e8e6a0d01) )
|
||||
ROM_LOAD( "ssf12.ic12s", 0x6000000, 0x800000, CRC(45fa259e) SHA1(8d7e708e7a2cbc2d60b68715dd79bac28d894d4c) )
|
||||
ROM_LOAD( "ssf13.ic13s", 0x6800000, 0x800000, CRC(e9578063) SHA1(618f66d01f6bdacbf2a3242774a316b130594e02) )
|
||||
ROM_LOAD( "ssf14.ic14s", 0x7000000, 0x800000, CRC(2edc1311) SHA1(bceb54dd29012580e2e6f15f16c6b31195010153) )
|
||||
ROM_LOAD( "ssf15.ic15s", 0x7800000, 0x800000, CRC(416db320) SHA1(34536716a35260d9457703704bb9174fb1616d60) )
|
||||
ROM_LOAD( "ssf16.ic16s", 0x8000000, 0x800000, CRC(2530cc04) SHA1(6425c031e5a129a3c9451bc694b5da8553f154c2) )
|
||||
ROM_LOAD( "ssf17.ic17s", 0x8800000, 0x800000, CRC(9e6afcc2) SHA1(4fb69d834ea12c82e897af47a22dcc47f3c83768) )
|
||||
ROM_LOAD( "ssf18.ic18s", 0x9000000, 0x800000, CRC(854ed5e5) SHA1(e445599f6a9e9d05c279259307edc08bce5d6d1f) )
|
||||
ROM_LOAD( "ssf19.ic19s", 0x9800000, 0x800000, CRC(4f8ec86a) SHA1(406ab9eeccd99fa5515d4a2c229c8db1a5cb8f83) )
|
||||
ROM_LOAD( "ssf20.ic20s", 0xa000000, 0x800000, CRC(c90b960d) SHA1(66e9f09d1f7f6a991371574a2e095c0e22fb7031) )
|
||||
ROM_LOAD( "ssf21.ic21s", 0xa800000, 0x800000, CRC(1477c064) SHA1(87fb8d8a91d6bed70b246a8df88fa77fbf3db443) )
|
||||
ROM_END
|
||||
|
||||
/*
|
||||
@ -7855,7 +7855,7 @@ ROM_END
|
||||
/* 0062 */ GAME( 2002, clubkrte, naomi2, naomi2, naomi, naomi2, ROT0, "Sega", "Club Kart: European Session (Rev D)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
|
||||
/* 0080 */ GAME( 2002, vf4cart, naomi2, naomi2m2, naomi, naomi2, ROT0, "Sega", "Virtua Fighter 4 (Cartridge)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
|
||||
/* 0087 */ GAME( 2002, kingrt66, naomi2, naomi2, naomi, naomi2, ROT0, "Sega", "King of Route 66 (Rev A)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
|
||||
/* 0095 */ GAME( 2002, soulsurf, naomi2, naomi2, naomi, naomi2, ROT0, "Sega", "Soul Surfer (Rev A)", GAME_FLAGS )
|
||||
/* 0095 */ GAME( 2002, soulsurf, naomi2, naomi2, naomi, naomi2, ROT0, "Sega", "Soul Surfer (Rev A)", GAME_FLAGS )
|
||||
/* 0106 */ GAME( 2002, vf4evoct, naomi2, naomi2m1, naomi, vf4evoct, ROT0, "Sega", "Virtua Fighter 4 Evolution (Cartridge)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
|
||||
// 0129 Club Kart Prize
|
||||
|
||||
@ -7948,7 +7948,7 @@ ROM_END
|
||||
// 0032A Initial D Arcade Stage Ver. 3 (Japan) (Rev A)
|
||||
/* 0032B */ GAME( 2004, initdv3jb, initdv3j, naomigd, naomi, naomi2, ROT0, "Sega", "Initial D Arcade Stage Ver. 3 (Japan) (Rev. B) (GDS-0032B)", GAME_FLAGS )
|
||||
/* 0032C */ GAME( 2004, initdv3j, naomi2, naomi2gd,naomi, naomi2, ROT0, "Sega", "Initial D Arcade Stage Ver. 3 (Japan) (Rev. C) (GDS-0032C)", GAME_FLAGS )
|
||||
/* 0033 */ GAME( 2004, initdv3e, naomi2, naomi2gd,naomi, naomi2, ROT0, "Sega", "Initial D Arcade Stage Ver. 3 (Export) (GDS-0033)", GAME_FLAGS )
|
||||
/* 0033 */ GAME( 2004, initdv3e, naomi2, naomi2gd,naomi, naomi2, ROT0, "Sega", "Initial D Arcade Stage Ver. 3 (Export) (GDS-0033)", GAME_FLAGS )
|
||||
// 0034
|
||||
// 0035
|
||||
// 0036 Virtua Fighter 4 Final Tuned
|
||||
|
@ -8889,7 +8889,7 @@ ROM_START( sbp ) /* Unlicensed, no official game ID # */
|
||||
|
||||
ROM_REGION( 0x800000, "ymsnd", 0 )
|
||||
ROM_LOAD( "12a.bin", 0x000000, 0x400000, CRC(c96723b9) SHA1(52eec88550781d45f84efbf9b905d7e7912e96fa) )
|
||||
ROM_LOAD( "13a.bin", 0x400000, 0x400000, CRC(08c339a5) SHA1(badc9510ae243ef2a7877977eb36efa81b1489fe) )
|
||||
ROM_LOAD( "13a.bin", 0x400000, 0x400000, CRC(08c339a5) SHA1(badc9510ae243ef2a7877977eb36efa81b1489fe) )
|
||||
|
||||
NO_DELTAT_REGION
|
||||
|
||||
|
@ -451,7 +451,7 @@ static WRITE32_HANDLER(rf5c296_mem_w)
|
||||
taitogn_state *state = space->machine().driver_data<taitogn_state>();
|
||||
|
||||
if(offset >= 0x140 && offset <= 0x144) {
|
||||
dynamic_buffer key;
|
||||
dynamic_buffer key;
|
||||
|
||||
int pos = (offset - 0x140)*2;
|
||||
UINT8 v, k;
|
||||
|
@ -1654,8 +1654,8 @@ ROM_END
|
||||
|
||||
ROM_START( wyvernwga )
|
||||
ROM_REGION32_BE( 0x100000, "user1", ROMREGION_ERASE00 ) /* Hyperstone CPU Code */
|
||||
ROM_LOAD( "rom1_alt.rom", 0x000000, 0x080000, CRC(586881fd) SHA1(d335bbd91def8fa4935eb2375c9b00471a1f40eb) )
|
||||
ROM_LOAD( "rom2_alt.rom", 0x080000, 0x080000, CRC(938049ec) SHA1(cc10944c99ceb388dd4aafc93377c40540861d14) )
|
||||
ROM_LOAD( "rom1_alt.rom", 0x000000, 0x080000, CRC(586881fd) SHA1(d335bbd91def8fa4935eb2375c9b00471a1f40eb) )
|
||||
ROM_LOAD( "rom2_alt.rom", 0x080000, 0x080000, CRC(938049ec) SHA1(cc10944c99ceb388dd4aafc93377c40540861d14) )
|
||||
|
||||
ROM_REGION( 0x020000, "audiocpu", 0 ) /* QDSP ('51) Code */
|
||||
ROM_LOAD( "u7", 0x0000, 0x20000, CRC(00a3f705) SHA1(f0a6bafd16bea53d4c05c8cc108983cbd41e5757) )
|
||||
|
@ -1927,13 +1927,13 @@ void n64_periphs::handle_pif()
|
||||
{
|
||||
//printf("Before:\n");
|
||||
/*for(int i = 0; i < 0x40; i++)
|
||||
{
|
||||
printf("%02x ", pif_cmd[i]);
|
||||
if((i & 0xf) == 0xf)
|
||||
{
|
||||
printf("\n");
|
||||
}
|
||||
}*/
|
||||
{
|
||||
printf("%02x ", pif_cmd[i]);
|
||||
if((i & 0xf) == 0xf)
|
||||
{
|
||||
printf("\n");
|
||||
}
|
||||
}*/
|
||||
if(pif_cmd[0x3f] == 0x1) // only handle the command if the last byte is 1
|
||||
{
|
||||
int channel = 0;
|
||||
@ -2005,14 +2005,14 @@ void n64_periphs::handle_pif()
|
||||
}
|
||||
|
||||
/*printf("After:\n");
|
||||
for(int i = 0; i < 0x40; i++)
|
||||
{
|
||||
printf("%02x ", pif_ram[i]);
|
||||
if((i & 0xf) == 0xf)
|
||||
{
|
||||
printf("\n");
|
||||
}
|
||||
}*/
|
||||
for(int i = 0; i < 0x40; i++)
|
||||
{
|
||||
printf("%02x ", pif_ram[i]);
|
||||
if((i & 0xf) == 0xf)
|
||||
{
|
||||
printf("\n");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void n64_periphs::pif_dma(int direction)
|
||||
|
@ -68,7 +68,7 @@ void n64_rdp::GetAlphaCvg(UINT8 *comb_alpha, rdp_span_aux *userdata, const rdp_p
|
||||
{
|
||||
temp3 = (temp * temp2) + 4;
|
||||
userdata->CurrentPixCvg = (temp3 >> 8) & 0xf;
|
||||
}
|
||||
}
|
||||
if (object.OtherModes.alpha_cvg_select)
|
||||
{
|
||||
temp = (OtherModes.cvg_times_alpha) ? (temp3 >> 3) : (temp2 << 5);
|
||||
@ -157,11 +157,11 @@ void n64_rdp::VideoUpdate16(n64_periphs *n64, bitmap_rgb32 &bitmap)
|
||||
|
||||
//if(divot)
|
||||
//{
|
||||
// if(i > 0 && i < (hres - 1))
|
||||
// {
|
||||
// prev_cvg = ((frame_buffer[(pixels - 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels - 1)^BYTE_ADDR_XOR] & 3);
|
||||
// next_cvg = ((frame_buffer[(pixels + 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels + 1)^BYTE_ADDR_XOR] & 3);
|
||||
// }
|
||||
// if(i > 0 && i < (hres - 1))
|
||||
// {
|
||||
// prev_cvg = ((frame_buffer[(pixels - 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels - 1)^BYTE_ADDR_XOR] & 3);
|
||||
// next_cvg = ((frame_buffer[(pixels + 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels + 1)^BYTE_ADDR_XOR] & 3);
|
||||
// }
|
||||
//}
|
||||
c.i.r = ((pix >> 8) & 0xf8) | (pix >> 13);
|
||||
c.i.g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07);
|
||||
|
@ -370,7 +370,7 @@ struct rdp_span_aux
|
||||
INT32 m_precomp_t;
|
||||
UINT8 BlendEnable;
|
||||
bool PreWrap;
|
||||
INT32 m_dzpix_enc;
|
||||
INT32 m_dzpix_enc;
|
||||
UINT8 *m_tmem; /* pointer to texture cache for this polygon */
|
||||
bool m_start_span;
|
||||
};
|
||||
@ -594,14 +594,14 @@ class n64_rdp : public poly_manager<UINT32, rdp_poly_state, 8, 32000>
|
||||
|
||||
UINT8 ReplicatedRGBA[32];
|
||||
|
||||
Rectangle Scissor;
|
||||
Rectangle Scissor;
|
||||
SpanBaseT SpanBase;
|
||||
|
||||
rectangle visarea;
|
||||
rectangle visarea;
|
||||
|
||||
void DrawTriangle(bool shade, bool texture, bool zbuffer, bool rect);
|
||||
void compute_cvg_noflip(extent_t *Spans, INT32* majorx, INT32* minorx, INT32* majorxint, INT32* minorxint, INT32 scanline, INT32 yh, INT32 yl, INT32 base);
|
||||
void compute_cvg_flip(extent_t *Spans, INT32* majorx, INT32* minorx, INT32* majorxint, INT32* minorxint, INT32 scanline, INT32 yh, INT32 yl, INT32 base);
|
||||
void compute_cvg_noflip(extent_t *Spans, INT32* majorx, INT32* minorx, INT32* majorxint, INT32* minorxint, INT32 scanline, INT32 yh, INT32 yl, INT32 base);
|
||||
void compute_cvg_flip(extent_t *Spans, INT32* majorx, INT32* minorx, INT32* majorxint, INT32* minorxint, INT32 scanline, INT32 yh, INT32 yl, INT32 base);
|
||||
|
||||
void* AuxBuf;
|
||||
UINT32 AuxBufPtr;
|
||||
@ -611,7 +611,7 @@ class n64_rdp : public poly_manager<UINT32, rdp_poly_state, 8, 32000>
|
||||
UINT32 ExtentBufPtr[2];
|
||||
UINT32 ExtentBufIndex;
|
||||
|
||||
bool rdp_range_check(UINT32 addr);
|
||||
bool rdp_range_check(UINT32 addr);
|
||||
|
||||
N64Tile m_tiles[8];
|
||||
|
||||
|
@ -638,10 +638,10 @@ SCREEN_UPDATE_IND16( hachamf )
|
||||
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
|
||||
};
|
||||
nmk16_draw_sprites2(screen.machine(), bitmap,cliprect, hachamf_swaptbl);
|
||||
/* nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
|
||||
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
|
||||
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
|
||||
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);*/
|
||||
/* nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
|
||||
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
|
||||
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
|
||||
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);*/
|
||||
|
||||
state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
return 0;
|
||||
|
@ -58,7 +58,7 @@ USE_DISPATCH_GL = 1
|
||||
# uncomment the next line to use couriersud's multi-keyboard patch for sdl2.0
|
||||
# SDL2_MULTIAPI = 1
|
||||
|
||||
# uncomment the next line to specify where you have installed
|
||||
# uncomment the next line to specify where you have installed
|
||||
# SDL. Equivalent to the ./configure --prefix=<path>
|
||||
# SDL_INSTALL_ROOT = /usr/local/sdl13
|
||||
|
||||
@ -382,7 +382,7 @@ ifdef SDL_INSTALL_ROOT
|
||||
# FIXME: remove the directfb ref. later. This is just there for now to work around an issue with SDL1.3 and SDL2.0
|
||||
INCPATH += -I$(SDL_INSTALL_ROOT)/include/directfb
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
INCPATH += `pkg-config --cflags fontconfig`
|
||||
LIBS += `pkg-config --libs fontconfig`
|
||||
|
@ -324,7 +324,7 @@ osd_work_queue *osd_work_queue_alloc(int flags)
|
||||
// on an n-CPU system, create n threads for multi queues, and 1 thread for everything else
|
||||
else
|
||||
queue->threads = (flags & WORK_QUEUE_FLAG_MULTI) ? numprocs : 1;
|
||||
|
||||
|
||||
// multi-queues with high frequency items should top out at 4 for now
|
||||
// since we have scaling problems above that
|
||||
if ((flags & WORK_QUEUE_FLAG_HIGH_FREQ) && queue->threads > 1)
|
||||
|
@ -215,7 +215,7 @@ public:
|
||||
: m_file(file),
|
||||
m_offset(offset),
|
||||
m_maxoffset(MIN(maxoffset, (file != NULL) ? core_fsize(file) : 0)) { }
|
||||
|
||||
|
||||
// read interface
|
||||
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length)
|
||||
{
|
||||
@ -247,7 +247,7 @@ public:
|
||||
m_offset(offset),
|
||||
m_maxoffset(MIN(maxoffset, file.logical_bytes())) { }
|
||||
|
||||
// read interface
|
||||
// read interface
|
||||
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length)
|
||||
{
|
||||
offset += m_offset;
|
||||
@ -279,24 +279,24 @@ public:
|
||||
: m_file(NULL),
|
||||
m_toc(toc),
|
||||
m_info(info) { }
|
||||
|
||||
|
||||
~chd_cd_compressor()
|
||||
{
|
||||
if (m_file != NULL)
|
||||
core_fclose(m_file);
|
||||
}
|
||||
|
||||
// read interface
|
||||
// read interface
|
||||
virtual UINT32 read_data(void *_dest, UINT64 offset, UINT32 length)
|
||||
{
|
||||
// verify assumptions made below
|
||||
assert(offset % CD_FRAME_SIZE == 0);
|
||||
assert(length % CD_FRAME_SIZE == 0);
|
||||
|
||||
|
||||
// initialize destination to 0 so that unused areas are filled
|
||||
UINT8 *dest = reinterpret_cast<UINT8 *>(_dest);
|
||||
memset(dest, 0, length);
|
||||
|
||||
|
||||
// find out which track we're starting in
|
||||
UINT64 startoffs = 0;
|
||||
UINT32 length_remaining = length;
|
||||
@ -316,7 +316,7 @@ public:
|
||||
if (filerr != FILERR_NONE)
|
||||
report_error(1, "Error opening input file (%s)'", m_lastfile.cstr());
|
||||
}
|
||||
|
||||
|
||||
// iterate over frames
|
||||
UINT32 bytesperframe = trackinfo.datasize + trackinfo.subsize;
|
||||
UINT64 src_track_start = m_info.track[tracknum].offset;
|
||||
@ -332,7 +332,7 @@ public:
|
||||
UINT32 count = core_fread(m_file, dest, bytesperframe);
|
||||
if (count != bytesperframe)
|
||||
report_error(1, "Error reading input file (%s)'", m_lastfile.cstr());
|
||||
|
||||
|
||||
// swap if appropriate
|
||||
if (m_info.track[tracknum].swap)
|
||||
for (UINT32 swapindex = 0; swapindex < 2352; swapindex += 2)
|
||||
@ -342,7 +342,7 @@ public:
|
||||
dest[swapindex + 1] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// advance
|
||||
offset += CD_FRAME_SIZE;
|
||||
dest += CD_FRAME_SIZE;
|
||||
@ -351,7 +351,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// next track starts after the previous one
|
||||
startoffs = endoffs;
|
||||
}
|
||||
@ -381,11 +381,11 @@ public:
|
||||
m_frame_count(num_frames),
|
||||
m_ldframedata(num_frames * VBI_PACKED_BYTES),
|
||||
m_rawdata(info.bytes_per_frame) { }
|
||||
|
||||
|
||||
// getters
|
||||
const dynamic_buffer &ldframedata() const { return m_ldframedata; }
|
||||
|
||||
// read interface
|
||||
|
||||
// read interface
|
||||
virtual UINT32 read_data(void *_dest, UINT64 offset, UINT32 length)
|
||||
{
|
||||
UINT8 *dest = reinterpret_cast<UINT8 *>(_dest);
|
||||
@ -402,7 +402,7 @@ public:
|
||||
INT32 effframe = m_start_frame + framenum;
|
||||
UINT32 first_sample = (UINT64(m_info.rate) * UINT64(effframe) * UINT64(1000000) + m_info.fps_times_1million - 1) / UINT64(m_info.fps_times_1million);
|
||||
UINT32 samples = (UINT64(m_info.rate) * UINT64(effframe + 1) * UINT64(1000000) + m_info.fps_times_1million - 1) / UINT64(m_info.fps_times_1million) - first_sample;
|
||||
|
||||
|
||||
// loop over channels and read the samples
|
||||
int channels = MIN(m_info.channels, ARRAY_LENGTH(m_audio));
|
||||
INT16 *samplesptr[ARRAY_LENGTH(m_audio)];
|
||||
@ -437,13 +437,13 @@ public:
|
||||
UINT32 rawsize = avhuff_encoder::raw_data_size(m_rawdata);
|
||||
if (rawsize < m_rawdata.count())
|
||||
memset(&m_rawdata[rawsize], 0, m_rawdata.count() - rawsize);
|
||||
|
||||
|
||||
// copy to the destination
|
||||
UINT64 start_offset = UINT64(framenum) * UINT64(m_info.bytes_per_frame);
|
||||
UINT64 end_offset = start_offset + m_info.bytes_per_frame;
|
||||
UINT32 bytes_to_copy = MIN(length_remaining, end_offset - offset);
|
||||
memcpy(dest, &m_rawdata[offset - start_offset], bytes_to_copy);
|
||||
|
||||
|
||||
// advance
|
||||
offset += bytes_to_copy;
|
||||
dest += bytes_to_copy;
|
||||
@ -519,29 +519,29 @@ static const option_description s_options[] =
|
||||
// descriptions for each command
|
||||
static const command_description s_commands[] =
|
||||
{
|
||||
{ COMMAND_INFO, do_info, ": displays information about a CHD",
|
||||
{ COMMAND_INFO, do_info, ": displays information about a CHD",
|
||||
{
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_VERBOSE
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_VERIFY, do_verify, ": verifies a CHD's integrity",
|
||||
|
||||
{ COMMAND_VERIFY, do_verify, ": verifies a CHD's integrity",
|
||||
{
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_CREATE_RAW, do_create_raw, ": create a raw CHD from the input file",
|
||||
|
||||
{ COMMAND_CREATE_RAW, do_create_raw, ": create a raw CHD from the input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_PARENT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS,
|
||||
REQUIRED OPTION_HUNK_SIZE,
|
||||
REQUIRED OPTION_UNIT_SIZE,
|
||||
@ -551,16 +551,16 @@ static const command_description s_commands[] =
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_CREATE_HD, do_create_hd, ": create a hard disk CHD from the input file",
|
||||
|
||||
{ COMMAND_CREATE_HD, do_create_hd, ": create a hard disk CHD from the input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_PARENT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
OPTION_INPUT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS,
|
||||
OPTION_HUNK_SIZE,
|
||||
OPTION_COMPRESSION,
|
||||
@ -572,13 +572,13 @@ static const command_description s_commands[] =
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_CREATE_CD, do_create_cd, ": create a CD CHD from the input file",
|
||||
|
||||
{ COMMAND_CREATE_CD, do_create_cd, ": create a CD CHD from the input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_PARENT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_HUNK_SIZE,
|
||||
OPTION_COMPRESSION,
|
||||
#if NUM_PROCESSORS_SUPPORTED
|
||||
@ -586,13 +586,13 @@ static const command_description s_commands[] =
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_CREATE_LD, do_create_ld, ": create a laserdisc CHD from the input file",
|
||||
|
||||
{ COMMAND_CREATE_LD, do_create_ld, ": create a laserdisc CHD from the input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_PARENT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_START_FRAME,
|
||||
OPTION_INPUT_LENGTH_FRAMES,
|
||||
OPTION_HUNK_SIZE,
|
||||
@ -602,63 +602,63 @@ static const command_description s_commands[] =
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_EXTRACT_RAW, do_extract_raw, ": extract raw file from a CHD input file",
|
||||
|
||||
{ COMMAND_EXTRACT_RAW, do_extract_raw, ": extract raw file from a CHD input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_EXTRACT_HD, do_extract_raw, ": extract raw hard disk file from a CHD input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_EXTRACT_CD, do_extract_cd, ": extract CD file from a CHD input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_BIN,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_EXTRACT_LD, do_extract_ld, ": extract laserdisc AVI from a CHD input file",
|
||||
|
||||
{ COMMAND_EXTRACT_HD, do_extract_raw, ": extract raw hard disk file from a CHD input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_FRAME,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_EXTRACT_CD, do_extract_cd, ": extract CD file from a CHD input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_BIN,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_EXTRACT_LD, do_extract_ld, ": extract laserdisc AVI from a CHD input file",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_FRAME,
|
||||
OPTION_INPUT_LENGTH_FRAMES
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_COPY, do_copy, ": copy data from one CHD to another of the same type",
|
||||
|
||||
{ COMMAND_COPY, do_copy, ": copy data from one CHD to another of the same type",
|
||||
{
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
REQUIRED OPTION_OUTPUT,
|
||||
OPTION_OUTPUT_PARENT,
|
||||
OPTION_OUTPUT_FORCE,
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_INPUT,
|
||||
OPTION_INPUT_PARENT,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_START_BYTE,
|
||||
OPTION_INPUT_START_HUNK,
|
||||
OPTION_INPUT_LENGTH_BYTES,
|
||||
OPTION_INPUT_LENGTH_HUNKS,
|
||||
OPTION_HUNK_SIZE,
|
||||
@ -668,10 +668,10 @@ static const command_description s_commands[] =
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_ADD_METADATA, do_add_metadata, ": add metadata to the CHD",
|
||||
|
||||
{ COMMAND_ADD_METADATA, do_add_metadata, ": add metadata to the CHD",
|
||||
{
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_TAG,
|
||||
OPTION_INDEX,
|
||||
OPTION_VALUE_TEXT,
|
||||
@ -679,10 +679,10 @@ static const command_description s_commands[] =
|
||||
OPTION_NO_CHECKSUM
|
||||
}
|
||||
},
|
||||
|
||||
{ COMMAND_DEL_METADATA, do_del_metadata, ": remove metadata from the CHD",
|
||||
|
||||
{ COMMAND_DEL_METADATA, do_del_metadata, ": remove metadata from the CHD",
|
||||
{
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_INPUT,
|
||||
REQUIRED OPTION_TAG,
|
||||
OPTION_INDEX
|
||||
}
|
||||
@ -708,7 +708,7 @@ static void report_error(int error, const char *format, ...)
|
||||
fflush(stderr);
|
||||
va_end(arg);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
|
||||
// reset time for progress and return the error
|
||||
lastprogress = 0;
|
||||
throw fatal_error(error);
|
||||
@ -782,7 +782,7 @@ static int print_help(const char *argv0, const command_description &desc, const
|
||||
bool required = (option[0] == REQUIRED[0]);
|
||||
if (required)
|
||||
option++;
|
||||
|
||||
|
||||
// find the option
|
||||
for (int optnum = 0; optnum < ARRAY_LENGTH(s_options); optnum++)
|
||||
if (strcmp(option, s_options[optnum].name) == 0)
|
||||
@ -807,7 +807,7 @@ const char *big_int_string(astring &string, UINT64 intvalue)
|
||||
// 0 is a special case
|
||||
if (intvalue == 0)
|
||||
return string.cpy("0");
|
||||
|
||||
|
||||
// loop until all chunks are done
|
||||
string.reset();
|
||||
bool first = true;
|
||||
@ -815,7 +815,7 @@ const char *big_int_string(astring &string, UINT64 intvalue)
|
||||
{
|
||||
int chunk = intvalue % 1000;
|
||||
intvalue /= 1000;
|
||||
|
||||
|
||||
astring insert;
|
||||
insert.format((intvalue != 0) ? "%03d" : "%d", chunk);
|
||||
|
||||
@ -850,7 +850,7 @@ UINT64 parse_number(const char *string)
|
||||
int length = strlen(string);
|
||||
if (length == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
// scan forward over digits
|
||||
UINT64 result = 0;
|
||||
while (isdigit(*string))
|
||||
@ -858,7 +858,7 @@ UINT64 parse_number(const char *string)
|
||||
result = (result * 10) + (*string - '0');
|
||||
string++;
|
||||
}
|
||||
|
||||
|
||||
// handle multipliers
|
||||
if (*string == 'k' || *string == 'K')
|
||||
result *= 1024;
|
||||
@ -866,7 +866,7 @@ UINT64 parse_number(const char *string)
|
||||
result *= 1024 * 1024;
|
||||
if (*string == 'g' || *string == 'G')
|
||||
result *= 1024 * 1024 * 1024;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -881,7 +881,7 @@ static void guess_chs(astring *filename, UINT64 filesize, int sectorsize, UINT32
|
||||
// if this is a direct physical drive read, handle it specially
|
||||
if (filename != NULL && osd_get_physical_drive_geometry(*filename, &cylinders, &heads, §ors, &bps))
|
||||
return;
|
||||
|
||||
|
||||
// if we have no length to work with, we can't guess
|
||||
if (filesize == 0)
|
||||
report_error(1, "Can't guess CHS values because there is no input file");
|
||||
@ -913,7 +913,7 @@ static void guess_chs(astring *filename, UINT64 filesize, int sectorsize, UINT32
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// parse_input_chd_parameters - parse the
|
||||
// parse_input_chd_parameters - parse the
|
||||
// standard set of input CHD parameters
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -962,7 +962,7 @@ static void parse_input_start_end(const parameters_t ¶ms, UINT64 logical_siz
|
||||
input_start = parse_number(*input_start_frame_str) * framebytes;
|
||||
if (input_start >= input_end)
|
||||
report_error(1, "Input start offset greater than input file size");
|
||||
|
||||
|
||||
// process input length
|
||||
astring *input_length_bytes_str = params.find(OPTION_INPUT_LENGTH_BYTES);
|
||||
astring *input_length_hunks_str = params.find(OPTION_INPUT_LENGTH_HUNKS);
|
||||
@ -1001,7 +1001,7 @@ static void check_existing_output_file(const parameters_t ¶ms, const char *f
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// parse_output_chd_parameters - parse the
|
||||
// parse_output_chd_parameters - parse the
|
||||
// standard set of output CHD parameters
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1025,7 +1025,7 @@ static astring *parse_output_chd_parameters(const parameters_t ¶ms, chd_file
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// parse_hunk_size - parse the hunk_size
|
||||
// parse_hunk_size - parse the hunk_size
|
||||
// parameter in a standard way
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1044,7 +1044,7 @@ static void parse_hunk_size(const parameters_t ¶ms, UINT32 required_granular
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// parse_compression - parse a standard
|
||||
// parse_compression - parse a standard
|
||||
// compression parameter string
|
||||
//-------------------------------------------------
|
||||
|
||||
@ -1061,7 +1061,7 @@ static void parse_compression(const parameters_t ¶ms, chd_codec_type compres
|
||||
compression[0] = compression[1] = compression[2] = compression[3] = CHD_CODEC_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// iterate through compressors
|
||||
int index = 0;
|
||||
for (int start = 0, end = compression_str->chr(0, ','); index < 4; start = end + 1, end = compression_str->chr(end + 1, ','))
|
||||
@ -1112,7 +1112,7 @@ static const char *compression_string(astring &string, chd_codec_type compressio
|
||||
string.reset();
|
||||
if (compression[0] == CHD_CODEC_NONE)
|
||||
return string.cpy("none");
|
||||
|
||||
|
||||
// iterate over types
|
||||
for (int index = 0; index < 4; index++)
|
||||
{
|
||||
@ -1126,7 +1126,7 @@ static const char *compression_string(astring &string, chd_codec_type compressio
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// compress_common - standard compression loop
|
||||
@ -1137,7 +1137,7 @@ static void compress_common(chd_file_compressor &chd)
|
||||
// begin compressing
|
||||
chd.compress_begin();
|
||||
|
||||
// loop until done
|
||||
// loop until done
|
||||
double complete, ratio;
|
||||
chd_error err;
|
||||
while ((err = chd.compress_continue(complete, ratio)) == CHDERR_WALKING_PARENT || err == CHDERR_COMPRESSING)
|
||||
@ -1190,7 +1190,7 @@ void output_track_metadata(bool cuemode, core_file *file, int tracknum, const cd
|
||||
tempstr.cpy("AUDIO");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// output TRACK entry
|
||||
core_fprintf(file, " TRACK %02d %s\n", tracknum + 1, tempstr.cstr());
|
||||
|
||||
@ -1205,7 +1205,7 @@ void output_track_metadata(bool cuemode, core_file *file, int tracknum, const cd
|
||||
if (info.postgap > 0)
|
||||
core_fprintf(file, " POSTGAP %s\n", msf_string_from_frames(tempstr, info.postgap));
|
||||
}
|
||||
|
||||
|
||||
// non-CUE mode
|
||||
else
|
||||
{
|
||||
@ -1304,7 +1304,7 @@ static void do_info(parameters_t ¶ms)
|
||||
chd_error err = input_chd.read_metadata(CHDMETATAG_WILDCARD, index, buffer, metatag, metaflags);
|
||||
if (err != CHDERR_NONE)
|
||||
break;
|
||||
|
||||
|
||||
// determine our index
|
||||
UINT32 metaindex = ~0;
|
||||
for (int cur = 0; cur < info.count(); cur++)
|
||||
@ -1313,7 +1313,7 @@ static void do_info(parameters_t ¶ms)
|
||||
metaindex = ++info[cur].index;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// if not found, add to our tracking
|
||||
if (metaindex == ~0)
|
||||
{
|
||||
@ -1335,7 +1335,7 @@ static void do_info(parameters_t ¶ms)
|
||||
printf("%c", isprint(UINT8(buffer[chnum])) ? buffer[chnum] : '.');
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
// print compression stats if verbose
|
||||
if (params.find(OPTION_VERBOSE) != NULL)
|
||||
{
|
||||
@ -1348,7 +1348,7 @@ static void do_info(parameters_t ¶ms)
|
||||
chd_error err = input_chd.hunk_info(hunknum, codec, compbytes);
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error getting info on hunk %d: %s", hunknum, chd_file::error_string(err));
|
||||
|
||||
|
||||
// decode into our data
|
||||
if (codec > CHD_CODEC_MINI)
|
||||
for (int comptype = 0; comptype < 4; comptype++)
|
||||
@ -1359,11 +1359,11 @@ static void do_info(parameters_t ¶ms)
|
||||
}
|
||||
if (codec > ARRAY_LENGTH(compression_types))
|
||||
codec = ARRAY_LENGTH(compression_types) - 1;
|
||||
|
||||
|
||||
// count stats
|
||||
compression_types[codec]++;
|
||||
}
|
||||
|
||||
|
||||
// output the stats
|
||||
printf("\n");
|
||||
printf(" Hunks Percent Name\n");
|
||||
@ -1385,10 +1385,10 @@ static void do_info(parameters_t ¶ms)
|
||||
name = chd_codec_list::codec_name(input_chd.compression(index));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// output the stats
|
||||
astring tempstr;
|
||||
printf("%10s %5.1f%% %-40s\n",
|
||||
printf("%10s %5.1f%% %-40s\n",
|
||||
big_int_string(tempstr, compression_types[comptype]),
|
||||
100.0 * double(compression_types[comptype]) / double(input_chd.hunk_count()),
|
||||
name);
|
||||
@ -1417,7 +1417,7 @@ static void do_verify(parameters_t ¶ms)
|
||||
|
||||
// create an array to read into
|
||||
dynamic_buffer buffer((TEMP_BUFFER_SIZE / input_chd.hunk_bytes()) * input_chd.hunk_bytes());
|
||||
|
||||
|
||||
// read all the data and build up an SHA-1
|
||||
sha1_creator rawsha1;
|
||||
for (UINT64 offset = 0; offset < input_chd.logical_bytes(); )
|
||||
@ -1429,13 +1429,13 @@ static void do_verify(parameters_t ¶ms)
|
||||
chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read);
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err));
|
||||
|
||||
|
||||
// add to the checksum
|
||||
rawsha1.append(buffer, bytes_to_read);
|
||||
offset += bytes_to_read;
|
||||
}
|
||||
sha1_t computed_sha1 = rawsha1.finish();
|
||||
|
||||
|
||||
// finish up
|
||||
if (raw_sha1 != computed_sha1)
|
||||
{
|
||||
@ -1453,7 +1453,7 @@ static void do_verify(parameters_t ¶ms)
|
||||
else
|
||||
{
|
||||
printf("Raw SHA1 verification successful!\n");
|
||||
|
||||
|
||||
// now include the metadata for >= v4
|
||||
if (input_chd.version() >= 4)
|
||||
{
|
||||
@ -1498,7 +1498,7 @@ static void do_create_raw(parameters_t ¶ms)
|
||||
// process output CHD
|
||||
chd_file output_parent;
|
||||
astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
|
||||
|
||||
|
||||
// process hunk size
|
||||
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : 0;
|
||||
parse_hunk_size(params, 1, hunk_size);
|
||||
@ -1517,12 +1517,12 @@ static void do_create_raw(parameters_t ¶ms)
|
||||
UINT64 input_start;
|
||||
UINT64 input_end;
|
||||
parse_input_start_end(params, core_fsize(input_file), hunk_size, hunk_size, input_start, input_end);
|
||||
|
||||
|
||||
// process compression
|
||||
chd_codec_type compression[4];
|
||||
memcpy(compression, s_default_raw_compression, sizeof(compression));
|
||||
parse_compression(params, compression);
|
||||
|
||||
|
||||
// process numprocessors
|
||||
parse_numprocessors(params);
|
||||
|
||||
@ -1553,7 +1553,7 @@ static void do_create_raw(parameters_t ¶ms)
|
||||
err = chd.create(*output_chd_str, input_end - input_start, hunk_size, unit_size, compression);
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err));
|
||||
|
||||
|
||||
// if we have a parent, copy forward all the metadata
|
||||
if (output_parent.opened())
|
||||
chd.clone_all_metadata(output_parent);
|
||||
@ -1588,11 +1588,11 @@ static void do_create_hd(parameters_t ¶ms)
|
||||
if (filerr != FILERR_NONE)
|
||||
report_error(1, "Unable to open file (%s)", input_file_str->cstr());
|
||||
}
|
||||
|
||||
|
||||
// process output CHD
|
||||
chd_file output_parent;
|
||||
astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
|
||||
|
||||
|
||||
// process sectorsize
|
||||
UINT32 sector_size = output_parent.opened() ? output_parent.unit_bytes() : IDE_SECTOR_SIZE;
|
||||
astring *sectorsize_str = params.find(OPTION_SECTOR_SIZE);
|
||||
@ -1602,16 +1602,16 @@ static void do_create_hd(parameters_t ¶ms)
|
||||
report_error(1, "Sector size does not apply when creating a diff from the parent");
|
||||
sector_size = parse_number(*sectorsize_str);
|
||||
}
|
||||
|
||||
|
||||
// process hunk size (needs to know sector_size)
|
||||
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : MAX((4096 / sector_size) * sector_size, sector_size);
|
||||
parse_hunk_size(params, sector_size, hunk_size);
|
||||
|
||||
|
||||
// process input start/end (needs to know hunk_size)
|
||||
UINT64 input_start;
|
||||
UINT64 input_end;
|
||||
parse_input_start_end(params, core_fsize(input_file), hunk_size, hunk_size, input_start, input_end);
|
||||
|
||||
|
||||
// process compression
|
||||
chd_codec_type compression[4];
|
||||
memcpy(compression, s_default_hd_compression, sizeof(compression));
|
||||
@ -1656,7 +1656,7 @@ static void do_create_hd(parameters_t ¶ms)
|
||||
heads = (identdata[7] << 8) | identdata[6];
|
||||
sectors = (identdata[13] << 8) | identdata[12];
|
||||
}
|
||||
|
||||
|
||||
// extract geometry from the parent if we have one
|
||||
if (output_parent.opened() && cylinders == 0)
|
||||
{
|
||||
@ -1666,7 +1666,7 @@ static void do_create_hd(parameters_t ¶ms)
|
||||
if (sscanf(metadata, HARD_DISK_METADATA_FORMAT, &cylinders, &heads, §ors, §or_size) != 4)
|
||||
report_error(1, "Error parsing hard disk metadata in parent CHD");
|
||||
}
|
||||
|
||||
|
||||
// if no CHS values, try to guess them
|
||||
if (cylinders == 0)
|
||||
{
|
||||
@ -1675,7 +1675,7 @@ static void do_create_hd(parameters_t ¶ms)
|
||||
guess_chs(input_file_str, input_end - input_start, sector_size, cylinders, heads, sectors, sector_size);
|
||||
}
|
||||
UINT32 totalsectors = cylinders * heads * sectors;
|
||||
|
||||
|
||||
// print some info
|
||||
astring tempstr;
|
||||
printf("Output CHD: %s\n", output_chd_str->cstr());
|
||||
@ -1758,7 +1758,7 @@ static void do_create_cd(parameters_t ¶ms)
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error parsing input file (%s: %s\n", input_file_str->cstr(), chd_file::error_string(err));
|
||||
}
|
||||
|
||||
|
||||
// process output CHD
|
||||
chd_file output_parent;
|
||||
astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
|
||||
@ -1766,7 +1766,7 @@ static void do_create_cd(parameters_t ¶ms)
|
||||
// process hunk size
|
||||
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : CD_FRAMES_PER_HUNK * CD_FRAME_SIZE;
|
||||
parse_hunk_size(params, CD_FRAME_SIZE, hunk_size);
|
||||
|
||||
|
||||
// process compression
|
||||
chd_codec_type compression[4];
|
||||
memcpy(compression, s_default_cd_compression, sizeof(compression));
|
||||
@ -1847,16 +1847,16 @@ static void do_create_ld(parameters_t ¶ms)
|
||||
report_error(1, "Error opening AVI file (%s): %s\n", input_file_str->cstr(), avi_error_string(avierr));
|
||||
}
|
||||
const avi_movie_info *aviinfo = avi_get_movie_info(input_file);
|
||||
|
||||
|
||||
// process output CHD
|
||||
chd_file output_parent;
|
||||
astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
|
||||
|
||||
|
||||
// process input start/end
|
||||
UINT64 input_start;
|
||||
UINT64 input_end;
|
||||
parse_input_start_end(params, aviinfo->video_numsamples, 0, 1, input_start, input_end);
|
||||
|
||||
|
||||
// determine parameters of the incoming video stream
|
||||
avi_info info;
|
||||
info.fps_times_1million = UINT64(aviinfo->video_timescale) * 1000000 / aviinfo->video_sampletime;
|
||||
@ -1878,11 +1878,11 @@ static void do_create_ld(parameters_t ¶ms)
|
||||
// determine the number of bytes per frame
|
||||
info.max_samples_per_frame = (UINT64(info.rate) * 1000000 + info.fps_times_1million - 1) / info.fps_times_1million;
|
||||
info.bytes_per_frame = avhuff_encoder::raw_data_size(info.width, info.height, info.channels, info.max_samples_per_frame);
|
||||
|
||||
|
||||
// process hunk size
|
||||
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : info.bytes_per_frame;
|
||||
parse_hunk_size(params, info.bytes_per_frame, hunk_size);
|
||||
|
||||
|
||||
// process compression
|
||||
chd_codec_type compression[4];
|
||||
memcpy(compression, s_default_ld_compression, sizeof(compression));
|
||||
@ -1932,7 +1932,7 @@ static void do_create_ld(parameters_t ¶ms)
|
||||
|
||||
// create the compressor and then run it generically
|
||||
compress_common(chd);
|
||||
|
||||
|
||||
// write the final LD metadata
|
||||
if (info.height == 524/2 || info.height == 624/2)
|
||||
{
|
||||
@ -1972,13 +1972,13 @@ static void do_copy(parameters_t ¶ms)
|
||||
// process output CHD
|
||||
chd_file output_parent;
|
||||
astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
|
||||
|
||||
|
||||
// process hunk size
|
||||
UINT32 hunk_size = input_chd.hunk_bytes();
|
||||
parse_hunk_size(params, 1, hunk_size);
|
||||
if (hunk_size % input_chd.hunk_bytes() != 0 && input_chd.hunk_bytes() % hunk_size != 0)
|
||||
report_error(1, "Hunk size is not an even multiple or divisor of input hunk size");
|
||||
|
||||
|
||||
// process compression; we default to our current preferences using metadata to pick the type
|
||||
chd_codec_type compression[4];
|
||||
{
|
||||
@ -2041,13 +2041,13 @@ static void do_copy(parameters_t ¶ms)
|
||||
redo_cd = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// otherwise, clone it
|
||||
err = chd.write_metadata(metatag, CHDMETAINDEX_APPEND, metadata);
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error writing cloned metadata: %s", chd_file::error_string(err));
|
||||
}
|
||||
|
||||
|
||||
// if we need to re-do the CD metadata, do it now
|
||||
if (redo_cd)
|
||||
{
|
||||
@ -2059,7 +2059,7 @@ static void do_copy(parameters_t ¶ms)
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error writing upgraded CD metadata: %s", chd_file::error_string(err));
|
||||
}
|
||||
|
||||
|
||||
// compress it generically
|
||||
compress_common(chd);
|
||||
}
|
||||
@ -2090,12 +2090,12 @@ static void do_extract_raw(parameters_t ¶ms)
|
||||
UINT64 input_start;
|
||||
UINT64 input_end;
|
||||
parse_input_start_end(params, input_chd.logical_bytes(), input_chd.hunk_bytes(), input_chd.hunk_bytes(), input_start, input_end);
|
||||
|
||||
|
||||
// verify output file doesn't exist
|
||||
astring *output_file_str = params.find(OPTION_OUTPUT);
|
||||
if (output_file_str != NULL)
|
||||
check_existing_output_file(params, *output_file_str);
|
||||
|
||||
|
||||
// print some info
|
||||
astring tempstr;
|
||||
printf("Output File: %s\n", output_file_str->cstr());
|
||||
@ -2126,7 +2126,7 @@ static void do_extract_raw(parameters_t ¶ms)
|
||||
chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read);
|
||||
if (err != CHDERR_NONE)
|
||||
report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err));
|
||||
|
||||
|
||||
// write to the output
|
||||
UINT32 count = core_fwrite(output_file, buffer, bytes_to_read);
|
||||
if (count != bytes_to_read)
|
||||
@ -2135,7 +2135,7 @@ static void do_extract_raw(parameters_t ¶ms)
|
||||
// advance
|
||||
offset += bytes_to_read;
|
||||
}
|
||||
|
||||
|
||||
// finish up
|
||||
core_fclose(output_file);
|
||||
printf("Extraction complete \n");
|
||||
@ -2170,7 +2170,7 @@ static void do_extract_cd(parameters_t ¶ms)
|
||||
if (cdrom == NULL)
|
||||
report_error(1, "Unable to recognize CHD file as a CD");
|
||||
const cdrom_toc *toc = cdrom_get_toc(cdrom);
|
||||
|
||||
|
||||
// verify output file doesn't exist
|
||||
astring *output_file_str = params.find(OPTION_OUTPUT);
|
||||
if (output_file_str != NULL)
|
||||
@ -2186,7 +2186,7 @@ static void do_extract_cd(parameters_t ¶ms)
|
||||
if (output_bin_file_str == NULL)
|
||||
output_bin_file_str = &default_name;
|
||||
check_existing_output_file(params, *output_bin_file_str);
|
||||
|
||||
|
||||
// print some info
|
||||
astring tempstr;
|
||||
printf("Output TOC: %s\n", output_file_str->cstr());
|
||||
@ -2213,7 +2213,7 @@ static void do_extract_cd(parameters_t ¶ms)
|
||||
UINT64 total_bytes = 0;
|
||||
for (int tracknum = 0; tracknum < toc->numtrks; tracknum++)
|
||||
total_bytes += toc->tracks[tracknum].frames * (toc->tracks[tracknum].datasize + toc->tracks[tracknum].subsize);
|
||||
|
||||
|
||||
// iterate over tracks and copy all data
|
||||
UINT64 outputoffs = 0;
|
||||
UINT32 discoffs = 0;
|
||||
@ -2227,7 +2227,7 @@ static void do_extract_cd(parameters_t ¶ms)
|
||||
// resize the buffer for the track
|
||||
UINT32 output_frame_size = trackinfo.datasize + ((trackinfo.subtype != CD_SUB_NONE) ? trackinfo.subsize : 0);
|
||||
buffer.resize((TEMP_BUFFER_SIZE / output_frame_size) * output_frame_size);
|
||||
|
||||
|
||||
// now read and output the actual data
|
||||
UINT32 bufferoffs = 0;
|
||||
for (int frame = 0; frame < trackinfo.frames; frame++)
|
||||
@ -2267,7 +2267,7 @@ static void do_extract_cd(parameters_t ¶ms)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// finish up
|
||||
core_fclose(output_bin_file);
|
||||
core_fclose(output_toc_file);
|
||||
@ -2328,7 +2328,7 @@ static void do_extract_ld(parameters_t ¶ms)
|
||||
frame_bytes = avhuff_encoder::raw_data_size(width, height, channels, max_samples_per_frame);
|
||||
if (frame_bytes != input_chd.hunk_bytes())
|
||||
report_error(1, "Frame size does not match hunk size for this CHD");
|
||||
|
||||
|
||||
// parse out input start/end
|
||||
UINT64 input_start;
|
||||
UINT64 input_end;
|
||||
@ -2386,7 +2386,7 @@ static void do_extract_ld(parameters_t ¶ms)
|
||||
audio_data[chnum].resize(max_samples_per_frame);
|
||||
avconfig.audio[chnum] = audio_data[chnum];
|
||||
}
|
||||
|
||||
|
||||
// iterate over frames
|
||||
bitmap_yuy16 fullbitmap(width, height * interlace_factor);
|
||||
for (int framenum = input_start; framenum < input_end; framenum++)
|
||||
@ -2396,7 +2396,7 @@ static void do_extract_ld(parameters_t ¶ms)
|
||||
// set up the fake bitmap for this frame
|
||||
avconfig.video.wrap(&fullbitmap.pix(framenum % interlace_factor), fullbitmap.width(), fullbitmap.height() / interlace_factor, fullbitmap.rowpixels() * interlace_factor);
|
||||
input_chd.codec_configure(CHD_CODEC_AVHUFF, AVHUFF_CODEC_DECOMPRESS_CONFIG, &avconfig);
|
||||
|
||||
|
||||
// read the hunk into the buffers
|
||||
chd_error err = input_chd.read_hunk(framenum, NULL);
|
||||
if (err != CHDERR_NONE)
|
||||
@ -2454,13 +2454,13 @@ static void do_add_metadata(parameters_t ¶ms)
|
||||
tag_str->cat(" ");
|
||||
tag = CHD_MAKE_TAG((*tag_str)[0], (*tag_str)[1], (*tag_str)[2], (*tag_str)[3]);
|
||||
}
|
||||
|
||||
|
||||
// process index
|
||||
UINT32 index = 0;
|
||||
astring *index_str = params.find(OPTION_INDEX);
|
||||
if (index_str != NULL)
|
||||
index = atoi(*index_str);
|
||||
|
||||
|
||||
// process text input
|
||||
astring *text_str = params.find(OPTION_VALUE_TEXT);
|
||||
astring text;
|
||||
@ -2470,7 +2470,7 @@ static void do_add_metadata(parameters_t ¶ms)
|
||||
if (text[0] == '"' && text[text.len() - 1] == '"')
|
||||
text.substr(1, text.len() - 2);
|
||||
}
|
||||
|
||||
|
||||
// process file input
|
||||
astring *file_str = params.find(OPTION_VALUE_FILE);
|
||||
dynamic_buffer file;
|
||||
@ -2480,18 +2480,18 @@ static void do_add_metadata(parameters_t ¶ms)
|
||||
if (filerr != FILERR_NONE)
|
||||
report_error(1, "Error reading metadata file (%s)", file_str->cstr());
|
||||
}
|
||||
|
||||
|
||||
// make sure we have one or the other
|
||||
if (text_str == NULL && file_str == NULL)
|
||||
report_error(1, "Error: missing either --valuetext/-vt or --valuefile/-vf parameters");
|
||||
if (text_str != NULL && file_str != NULL)
|
||||
report_error(1, "Error: both --valuetext/-vt or --valuefile/-vf parameters specified; only one permitted");
|
||||
|
||||
|
||||
// process no checksum
|
||||
UINT8 flags = CHD_MDFLAGS_CHECKSUM;
|
||||
if (params.find(OPTION_NO_CHECKSUM) != NULL)
|
||||
flags &= ~CHD_MDFLAGS_CHECKSUM;
|
||||
|
||||
|
||||
// print some info
|
||||
astring tempstr;
|
||||
printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr());
|
||||
@ -2516,7 +2516,7 @@ static void do_add_metadata(parameters_t ¶ms)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// do_del_metadata - remove metadata from a CHD
|
||||
// do_del_metadata - remove metadata from a CHD
|
||||
//-------------------------------------------------
|
||||
|
||||
static void do_del_metadata(parameters_t ¶ms)
|
||||
@ -2534,13 +2534,13 @@ static void do_del_metadata(parameters_t ¶ms)
|
||||
tag_str->cat(" ");
|
||||
tag = CHD_MAKE_TAG((*tag_str)[0], (*tag_str)[1], (*tag_str)[2], (*tag_str)[3]);
|
||||
}
|
||||
|
||||
|
||||
// process index
|
||||
UINT32 index = 0;
|
||||
astring *index_str = params.find(OPTION_INDEX);
|
||||
if (index_str != NULL)
|
||||
index = atoi(*index_str);
|
||||
|
||||
|
||||
// print some info
|
||||
astring tempstr;
|
||||
printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr());
|
||||
@ -2578,13 +2578,13 @@ int CLIB_DECL main(int argc, char *argv[])
|
||||
return print_help(argv[0]);
|
||||
command = argv[argnum++];
|
||||
}
|
||||
|
||||
|
||||
// iterate over commands to find our match
|
||||
for (int cmdnum = 0; cmdnum < ARRAY_LENGTH(s_commands); cmdnum++)
|
||||
if (strcmp(command, s_commands[cmdnum].name) == 0)
|
||||
{
|
||||
const command_description &desc = s_commands[cmdnum];
|
||||
|
||||
|
||||
// print help if that was requested
|
||||
if (help)
|
||||
return print_help(argv[0], desc);
|
||||
@ -2629,7 +2629,7 @@ int CLIB_DECL main(int argc, char *argv[])
|
||||
return print_help(argv[0], desc, "Option is missing parameter");
|
||||
param = argv[argnum++];
|
||||
}
|
||||
|
||||
|
||||
// add to the map
|
||||
if (parameters.add(odesc.name, new astring(param)) == TMERR_DUPLICATE)
|
||||
return print_help(argv[0], desc, "Multiple parameters of the same type specified");
|
||||
@ -2641,7 +2641,7 @@ int CLIB_DECL main(int argc, char *argv[])
|
||||
if (valid == ARRAY_LENGTH(desc.valid_options))
|
||||
return print_help(argv[0], desc, "Option not valid for this command");
|
||||
}
|
||||
|
||||
|
||||
// make sure we got all our required parameters
|
||||
for (int valid = 0; valid < ARRAY_LENGTH(desc.valid_options); valid++)
|
||||
{
|
||||
@ -2651,7 +2651,7 @@ int CLIB_DECL main(int argc, char *argv[])
|
||||
if (*validname == REQUIRED[0] && parameters.find(++validname) == NULL)
|
||||
return print_help(argv[0], desc, "Required parameters missing");
|
||||
}
|
||||
|
||||
|
||||
// all clear, run the command
|
||||
try
|
||||
{
|
||||
@ -2673,7 +2673,7 @@ int CLIB_DECL main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// print generic help if nothing found
|
||||
return print_help(argv[0]);
|
||||
}
|
||||
|
@ -38,4 +38,4 @@
|
||||
***************************************************************************/
|
||||
|
||||
extern const char build_version[];
|
||||
const char build_version[] = "0.145 ("__DATE__")";
|
||||
const char build_version[] = "0.145u1 ("__DATE__")";
|
||||
|
Loading…
Reference in New Issue
Block a user