Clean-ups and version bump

This commit is contained in:
Angelo Salese 2012-02-19 15:23:23 +00:00
parent 2f8094ea33
commit cf4b58b6f6
90 changed files with 1050 additions and 1050 deletions

View File

@ -1457,9 +1457,9 @@ void media_identifier::identify(const char *filename)
// crude, need real UTF16->UTF8 conversion ideally // crude, need real UTF16->UTF8 conversion ideally
for (int j=0;j<namelen;j++) for (int j=0;j<namelen;j++)
{ {
temp3[j] = (UINT8)temp[j]; temp3[j] = (UINT8)temp[j];
} }
if (!(f->IsDir) && (f->Size != 0)) if (!(f->IsDir) && (f->Size != 0))
{ {
UINT8 *data = global_alloc_array(UINT8, f->Size); UINT8 *data = global_alloc_array(UINT8, f->Size);

View File

@ -10485,8 +10485,8 @@ M68KMAKE_OP(cinv, 32, ., .)
{ {
UINT16 ir = mc68kcpu->ir; UINT16 ir = mc68kcpu->ir;
UINT8 cache = (ir >> 6) & 3; UINT8 cache = (ir >> 6) & 3;
// UINT8 scope = (ir >> 3) & 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); // 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) switch (cache)
{ {
case 2: case 2:

View File

@ -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; static UINT32 psrp = 0, purp=0;
if(psrp != m68k->mmu_srp_aptr) { if(psrp != m68k->mmu_srp_aptr) {
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) { if(purp != m68k->mmu_urp_aptr) {
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? // is UDT marked valid?
@ -791,7 +791,7 @@ void m68881_mmu_ops(m68ki_cpu_core *m68k)
} }
else if ((m68k->ir & 0xffe0) == 0xf500) 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); pmmu_atc_flush(m68k);
} }
else // the rest are 1111000xxxXXXXXX where xxx is the instruction family else // the rest are 1111000xxxXXXXXX where xxx is the instruction family

View File

@ -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); result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
update_slot_options(); update_slot_options();
while (add_slot_options(false)); 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); result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
return result; return result;
} }

View File

@ -179,7 +179,7 @@ bool hash_collection::add_from_string(char type, const char *buffer, int length)
// handle CRCs // handle CRCs
if (type == HASH_CRC) if (type == HASH_CRC)
return m_has_crc32 = m_crc32.from_string(buffer, length); return m_has_crc32 = m_crc32.from_string(buffer, length);
// handle SHA1s // handle SHA1s
else if (type == HASH_SHA1) else if (type == HASH_SHA1)
return m_has_sha1 = m_sha1.from_string(buffer, length); 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 hash_collection::remove(char type)
{ {
bool result = false; bool result = false;
// handle CRCs // handle CRCs
if (type == HASH_CRC) if (type == HASH_CRC)
{ {
result = m_has_crc32; result = m_has_crc32;
m_has_crc32 = false; m_has_crc32 = false;
} }
// handle SHA1s // handle SHA1s
else if (type == HASH_SHA1) else if (type == HASH_SHA1)
{ {
@ -222,12 +222,12 @@ bool hash_collection::remove(char type)
const char *hash_collection::internal_string(astring &buffer) const const char *hash_collection::internal_string(astring &buffer) const
{ {
buffer.reset(); buffer.reset();
// handle CRCs // handle CRCs
astring temp; astring temp;
if (m_has_crc32) if (m_has_crc32)
buffer.cat(HASH_CRC).cat(m_crc32.as_string(temp)); buffer.cat(HASH_CRC).cat(m_crc32.as_string(temp));
// handle SHA1s // handle SHA1s
if (m_has_sha1) if (m_has_sha1)
buffer.cat(HASH_SHA1).cat(m_sha1.as_string(temp)); 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; astring temp;
if (m_has_crc32) if (m_has_crc32)
buffer.cat("CRC(").cat(m_crc32.as_string(temp)).cat(") "); buffer.cat("CRC(").cat(m_crc32.as_string(temp)).cat(") ");
// handle SHA1s // handle SHA1s
if (m_has_sha1) if (m_has_sha1)
buffer.cat("SHA1(").cat(m_sha1.as_string(temp)).cat(") "); 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; astring temp;
if (m_has_crc32) if (m_has_crc32)
buffer.cat("crc=\"").cat(m_crc32.as_string(temp)).cat("\" "); buffer.cat("crc=\"").cat(m_crc32.as_string(temp)).cat("\" ");
// handle SHA1s // handle SHA1s
if (m_has_sha1) if (m_has_sha1)
buffer.cat("sha1=\"").cat(m_sha1.as_string(temp)).cat("\" "); 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 // by default use all types
if (types == NULL) if (types == NULL)
m_creator->m_doing_crc32 = m_creator->m_doing_sha1 = true; m_creator->m_doing_crc32 = m_creator->m_doing_sha1 = true;
// otherwise, just allocate the ones that are specified // otherwise, just allocate the ones that are specified
else else
{ {
@ -369,7 +369,7 @@ void hash_collection::begin(const char *types)
void hash_collection::buffer(const UINT8 *data, UINT32 length) void hash_collection::buffer(const UINT8 *data, UINT32 length)
{ {
assert(m_creator != NULL); assert(m_creator != NULL);
// append to each active hash // append to each active hash
if (m_creator->m_doing_crc32) if (m_creator->m_doing_crc32)
m_creator->m_crc32_creator.append(data, length); 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() void hash_collection::end()
{ {
assert(m_creator != NULL); assert(m_creator != NULL);
// default to getting nothing // default to getting nothing
m_has_crc32 = m_has_sha1 = false; m_has_crc32 = m_has_sha1 = false;
// finish up the CRC32 // finish up the CRC32
if (m_creator->m_doing_crc32) if (m_creator->m_doing_crc32)
{ {
m_has_crc32 = true; m_has_crc32 = true;
m_crc32 = m_creator->m_crc32_creator.finish(); m_crc32 = m_creator->m_crc32_creator.finish();
} }
// finish up the SHA1 // finish up the SHA1
if (m_creator->m_doing_sha1) if (m_creator->m_doing_sha1)
{ {
m_has_sha1 = true; m_has_sha1 = true;
m_sha1 = m_creator->m_sha1_creator.finish(); m_sha1 = m_creator->m_sha1_creator.finish();
} }
// nuke the creator // nuke the creator
delete m_creator; delete m_creator;
m_creator = NULL; m_creator = NULL;
@ -418,13 +418,13 @@ void hash_collection::copyfrom(const hash_collection &src)
{ {
// copy flags directly // copy flags directly
m_flags = src.m_flags; m_flags = src.m_flags;
// copy hashes // copy hashes
m_has_crc32 = src.m_has_crc32; m_has_crc32 = src.m_has_crc32;
m_crc32 = src.m_crc32; m_crc32 = src.m_crc32;
m_has_sha1 = src.m_has_sha1; m_has_sha1 = src.m_has_sha1;
m_sha1 = src.m_sha1; m_sha1 = src.m_sha1;
// don't copy creators // don't copy creators
m_creator = NULL; m_creator = NULL;
} }

View File

@ -921,7 +921,7 @@ static void write_sector_done(ide_state *ide)
/* now do the write */ /* now do the write */
if (ide->drive[ide->cur_drive].slot) { if (ide->drive[ide->cur_drive].slot) {
count = ide->drive[ide->cur_drive].slot->write_sector(lba, ide->buffer); count = ide->drive[ide->cur_drive].slot->write_sector(lba, ide->buffer);
} }
/* by default, mark the buffer ready and the seek complete */ /* by default, mark the buffer ready and the seek complete */
ide->status |= IDE_STATUS_BUFFER_READY; 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->status &= ~IDE_STATUS_ERROR;
ide->error = IDE_ERROR_NONE; ide->error = IDE_ERROR_NONE;
ide->drive[ide->cur_drive].slot->set_geometry(ide->sector_count,ide->drive[ide->cur_drive].cur_head + 1); ide->drive[ide->cur_drive].slot->set_geometry(ide->sector_count,ide->drive[ide->cur_drive].cur_head + 1);
/* signal an interrupt */ /* signal an interrupt */
signal_delayed_interrupt(ide, MINIMUM_COMMAND_TIME, 0); signal_delayed_interrupt(ide, MINIMUM_COMMAND_TIME, 0);
break; break;
@ -1921,7 +1921,7 @@ static DEVICE_START( ide_controller )
static DEVICE_RESET( ide_controller ) static DEVICE_RESET( ide_controller )
{ {
ide_state *ide = get_safe_token(device); ide_state *ide = get_safe_token(device);
LOG(("IDE controller reset performed\n")); LOG(("IDE controller reset performed\n"));
/* reset the drive state */ /* reset the drive state */
ide->cur_drive = 0; ide->cur_drive = 0;
ide->status = IDE_STATUS_DRIVE_READY | IDE_STATUS_SEEK_COMPLETE; 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_END
SLOT_INTERFACE_START(ide_devices) SLOT_INTERFACE_START(ide_devices)
SLOT_INTERFACE("hdd", IDE_HARDDISK) SLOT_INTERFACE("hdd", IDE_HARDDISK)
SLOT_INTERFACE_END SLOT_INTERFACE_END
/*------------------------------------------------- /*-------------------------------------------------
@ -2060,7 +2060,7 @@ void ide_hdd_device::device_reset()
{ {
m_handle = get_disk_handle(machine(), owner()->tag()); m_handle = get_disk_handle(machine(), owner()->tag());
m_disk = hard_disk_open(m_handle); m_disk = hard_disk_open(m_handle);
if (m_disk != NULL) if (m_disk != NULL)
{ {
const hard_disk_info *hdinfo = hard_disk_get_info(m_disk); 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); 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); 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; UINT32 metalength;
if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE) if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE)
ide_build_features(); ide_build_features();
} }
} }
//------------------------------------------------- //-------------------------------------------------
@ -2137,7 +2137,7 @@ void ide_hdd_image_device::device_reset()
m_num_heads = hdinfo->heads; m_num_heads = hdinfo->heads;
if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", m_num_cylinders, m_num_heads, m_num_sectors); 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; UINT32 metalength;
if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE) if (m_handle->read_metadata (HARD_DISK_IDENT_METADATA_TAG, 0, m_features, IDE_DISK_SECTOR_SIZE, metalength) != CHDERR_NONE)
ide_build_features(); ide_build_features();
@ -2152,7 +2152,7 @@ void ide_hdd_image_device::device_reset()
//------------------------------------------------- //-------------------------------------------------
static MACHINE_CONFIG_FRAGMENT( hdd_image ) static MACHINE_CONFIG_FRAGMENT( hdd_image )
MCFG_HARDDISK_ADD( "harddisk" ) MCFG_HARDDISK_ADD( "harddisk" )
MACHINE_CONFIG_END MACHINE_CONFIG_END
machine_config_constructor ide_hdd_image_device::device_mconfig_additions() const machine_config_constructor ide_hdd_image_device::device_mconfig_additions() const
{ {

View File

@ -33,8 +33,8 @@ public:
public: public:
virtual int read_sector(UINT32 lba, void *buffer) = 0; virtual int read_sector(UINT32 lba, void *buffer) = 0;
virtual int write_sector(UINT32 lba, const 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_cylinders() { return m_num_cylinders; }
UINT16 get_sectors() { return m_num_sectors; } 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); 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 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; } 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;} UINT8 *get_features() { return (m_dev) ? m_dev->get_features() : NULL;}
UINT16 get_cylinders() { return (m_dev) ? m_dev->get_cylinders() : 0; } UINT16 get_cylinders() { return (m_dev) ? m_dev->get_cylinders() : 0; }
UINT16 get_sectors() { return (m_dev) ? m_dev->get_sectors() : 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); } 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; } bool is_ready() { return (m_dev) ? m_dev->is_ready() : false; }
void read_key(UINT8 key[]) { if (m_dev) m_dev->read_key(key); } void read_key(UINT8 key[]) { if (m_dev) m_dev->read_key(key); }
@ -96,7 +96,7 @@ protected:
// device-level overrides // device-level overrides
virtual void device_start(); virtual void device_start();
virtual void device_reset(); virtual void device_reset();
void ide_build_features(); void ide_build_features();
virtual bool is_ready() { return (m_disk != NULL); } virtual bool is_ready() { return (m_disk != NULL); }
protected: protected:

View File

@ -68,7 +68,7 @@ void nscsi_bus_device::regen_ctrl(int refid)
} }
logerror("\n"); logerror("\n");
} }
octrl = octrl ^ ctrl; octrl = octrl ^ ctrl;
if(octrl) if(octrl)
for(int i=0; i<devcnt; i++) for(int i=0; i<devcnt; i++)
@ -357,7 +357,7 @@ void nscsi_full_device::step(bool timeout)
} else } else
target_recv_byte(); target_recv_byte();
break; break;
default: default:
logerror("%s: step() unexpected state %d.%d\n", logerror("%s: step() unexpected state %d.%d\n",
tag(), tag(),
@ -442,7 +442,7 @@ nscsi_full_device::control *nscsi_full_device::buf_control_pop()
buf_control_rpos++; buf_control_rpos++;
if(buf_control_rpos == buf_control_wpos) if(buf_control_rpos == buf_control_wpos)
buf_control_rpos = buf_control_wpos = 0; buf_control_rpos = buf_control_wpos = 0;
return c; return c;
} }
void nscsi_full_device::scsi_status_complete(UINT8 st) void nscsi_full_device::scsi_status_complete(UINT8 st)

View File

@ -7,7 +7,7 @@
MCFG_DEVICE_ADD(_tag, NSCSI_BUS, 0) MCFG_DEVICE_ADD(_tag, NSCSI_BUS, 0)
#define MCFG_NSCSI_DEVICE_ADD(_tag, _subtag, _type, _clock) \ #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); \ downcast<nscsi_connector *>(device)->set_fixed_device(_subtag); \
MCFG_DEVICE_ADD(_tag ":" _subtag, _type, _clock) MCFG_DEVICE_ADD(_tag ":" _subtag, _type, _clock)
@ -15,7 +15,7 @@
MCFG_NSCSI_DEVICE_ADD(_tag, _subtag, _type, _clock) MCFG_NSCSI_DEVICE_ADD(_tag, _subtag, _type, _clock)
#define MCFG_NSCSI_ADD(_tag, _slot_intf, _def_slot, _def_inp) \ #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) MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
class nscsi_device; class nscsi_device;
@ -336,7 +336,7 @@ private:
control *buf_control_push(); control *buf_control_push();
control *buf_control_pop(); control *buf_control_pop();
void step(bool timeout); void step(bool timeout);
void target_recv_byte(); void target_recv_byte();
void target_send_byte(UINT8 val); void target_send_byte(UINT8 val);

View File

@ -83,7 +83,7 @@ void nscsi_harddisk_device::scsi_command()
bad_lun(); bad_lun();
return; return;
} }
int page = scsi_cmdbuf[2]; int page = scsi_cmdbuf[2];
int size = scsi_cmdbuf[4]; int size = scsi_cmdbuf[4];
switch(page) { switch(page) {

View File

@ -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(" EXPECTED: %s\n", hashes.macro_string(tempstr));
romdata->errorstring.catprintf(" FOUND: %s\n", acthashes.macro_string(tempstr)); romdata->errorstring.catprintf(" FOUND: %s\n", acthashes.macro_string(tempstr));
/* /*
// warn about any ill-formed hashes // warn about any ill-formed hashes
for (hash_base *hash = hashes.first(); hash != NULL; hash = hash->next()) for (hash_base *hash = hashes.first(); hash != NULL; hash = hash->next())
if (hash->parse_error()) if (hash->parse_error())
{ {
romdata->errorstring.catprintf("\tInvalid %s checksum treated as 0 (check leading zeros)\n", hash->name()); romdata->errorstring.catprintf("\tInvalid %s checksum treated as 0 (check leading zeros)\n", hash->name());
romdata->warnings++; 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()); astring fullpath(diff_file.fullpath());
diff_file.close(); diff_file.close();
LOG(("Opening differencing image file: %s\n", fullpath.cstr())); LOG(("Opening differencing image file: %s\n", fullpath.cstr()));
return diff_chd.open(fullpath, true, &source); return diff_chd.open(fullpath, true, &source);
} }
/* didn't work; try creating it instead */ /* didn't work; try creating it instead */
LOG(("Creating differencing image: %s\n", fname.cstr())); 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); 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); chd_error err = diff_chd.create(fullpath, source.logical_bytes(), source.hunk_bytes(), compression, source);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
return err; return err;
return diff_chd.clone_all_metadata(source); 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)) if (ROMENTRY_ISFILE(romp))
{ {
open_chd *chd = global_alloc(open_chd(regiontag)); open_chd *chd = global_alloc(open_chd(regiontag));
hash_collection hashes(ROM_GETHASHDATA(romp)); hash_collection hashes(ROM_GETHASHDATA(romp));
chd_error err; chd_error err;

View File

@ -6,17 +6,17 @@
**************************************************************************** ****************************************************************************
Playback of pre-recorded samples. Used for high-level simulation of Playback of pre-recorded samples. Used for high-level simulation of
discrete sound circuits where proper low-level simulation isn't discrete sound circuits where proper low-level simulation isn't
available. Also used for tape loops and similar. available. Also used for tape loops and similar.
Current limitations Current limitations
- Only supports single channel samples! - Only supports single channel samples!
Considerations Considerations
- Maybe this should be part of the presentation layer - Maybe this should be part of the presentation layer
(artwork etc.) with samples specified in .lay files instead of (artwork etc.) with samples specified in .lay files instead of
in drivers? 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 // provided sample
//------------------------------------------------- //-------------------------------------------------
@ -249,7 +249,7 @@ UINT32 samples_device::base_frequency(UINT8 channel) const
//------------------------------------------------- //-------------------------------------------------
// playing - return true if a sample is still // 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 bool samples_device::playing(UINT8 channel) const
@ -318,7 +318,7 @@ void samples_device::device_reset()
//------------------------------------------------- //-------------------------------------------------
// device_post_load - handle updating after a // device_post_load - handle updating after a
// restore // restore
//------------------------------------------------- //-------------------------------------------------
void samples_device::device_post_load() 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 // 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()); mame_printf_warning("Unable to read %s, 0-byte file?\n", file.filename());
return false; return false;
} }
// look for the appropriate RIFF tag // look for the appropriate RIFF tag
if (memcmp(&buf[0], "RIFF", 4) == 0) if (memcmp(&buf[0], "RIFF", 4) == 0)
return read_wav_sample(file, sample); 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()); printf("Reading %s as WAV\n", file.filename());
// we already read the opening 'WAVE' header // we already read the opening 'WAVE' header
UINT32 offset = 4; UINT32 offset = 4;
// get the total size // get the total size
UINT32 filesize; UINT32 filesize;
offset += file.read(&filesize, 4); offset += file.read(&filesize, 4);
@ -593,12 +593,12 @@ printf("Reading %s as FLAC\n", file.filename());
return false; return false;
if (decoder.bits_per_sample() != 16) if (decoder.bits_per_sample() != 16)
return false; return false;
// resize the array and read // resize the array and read
sample.data.resize(sample.length); sample.data.resize(sample.length);
if (!decoder.decode_interleaved(sample.data, sample.length)) if (!decoder.decode_interleaved(sample.data, sample.length))
return false; return false;
// finish up and clean up // finish up and clean up
decoder.finish(); decoder.finish();
return true; return true;
@ -615,7 +615,7 @@ void samples_device::load_samples()
// if the user doesn't want to use samples, bail // if the user doesn't want to use samples, bail
if (!machine().options().samples()) if (!machine().options().samples())
return; return;
// iterate over ourself // iterate over ourself
const char *basename = machine().basename(); const char *basename = machine().basename();
samples_iterator iter(*this); 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"); file_error filerr = file.open(basename, PATH_SEPARATOR, samplename, ".flac");
if (filerr != FILERR_NONE && altbasename != NULL) if (filerr != FILERR_NONE && altbasename != NULL)
filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".flac"); filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".flac");
// if not, try as WAV // if not, try as WAV
if (filerr != FILERR_NONE) if (filerr != FILERR_NONE)
filerr = file.open(basename, PATH_SEPARATOR, samplename, ".wav"); filerr = file.open(basename, PATH_SEPARATOR, samplename, ".wav");

View File

@ -79,7 +79,7 @@ struct samples_interface
// ======================> samples_device // ======================> samples_device
class samples_device : public device_t, class samples_device : public device_t,
public device_sound_interface, public device_sound_interface,
public samples_interface public samples_interface
{ {
@ -100,11 +100,11 @@ public:
void pause(UINT8 channel, bool pause = true); void pause(UINT8 channel, bool pause = true);
void stop(UINT8 channel); void stop(UINT8 channel);
void stop_all(); void stop_all();
// dynamic control // dynamic control
void set_frequency(UINT8 channel, UINT32 frequency); void set_frequency(UINT8 channel, UINT32 frequency);
void set_volume(UINT8 channel, float volume); void set_volume(UINT8 channel, float volume);
protected: protected:
// subclasses can do it this way // 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); 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 // shouldn't need a copy, but in case it happens, catch it here
loaded_sample &operator=(const loaded_sample &rhs) { assert(false); return *this; } loaded_sample &operator=(const loaded_sample &rhs) { assert(false); return *this; }
UINT32 length; // length in samples UINT32 length; // length in samples
UINT32 frequency; // frequency of the sample UINT32 frequency; // frequency of the sample
dynamic_array<INT16> data; // 16-bit signed data dynamic_array<INT16> data; // 16-bit signed data
@ -142,7 +142,7 @@ private:
bool loop; bool loop;
bool paused; bool paused;
}; };
// internal helpers // internal helpers
bool read_sample(emu_file &file, loaded_sample &sample); bool read_sample(emu_file &file, loaded_sample &sample);
bool read_wav_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) samples_iterator(samples_interface &intf)
: m_intf(intf), : m_intf(intf),
m_current(-1) { } m_current(-1) { }
// getters // 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; } 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) if (m_intf.m_names == NULL || m_intf.m_names[0] == NULL)
return NULL; return NULL;
m_current = 0; m_current = 0;
if (m_intf.m_names[0][0] == '*') if (m_intf.m_names[0][0] == '*')
m_current++; m_current++;
return m_intf.m_names[m_current++]; return m_intf.m_names[m_current++];
@ -193,7 +193,7 @@ public:
return NULL; return NULL;
return m_intf.m_names[m_current++]; return m_intf.m_names[m_current++];
} }
// counting // counting
int count() int count()
{ {

View File

@ -52,14 +52,14 @@ const device_type VOTRAX = &device_creator<votrax_device>;
const char *const votrax_device::s_phoneme_table[64] = const char *const votrax_device::s_phoneme_table[64] =
{ {
"EH3", "EH2", "EH1", " "/*PA0*/"DT", "A1", "A2", "ZH", "EH3", "EH2", "EH1", " "/*PA0*/"DT", "A1", "A2", "ZH",
"AH2", "I3", "I2", "I1", "M", "N", "B", "V", "AH2", "I3", "I2", "I1", "M", "N", "B", "V",
"CH", "SH", "Z", "AW1", "NG", "AH1", "OO1", "OO", "CH", "SH", "Z", "AW1", "NG", "AH1", "OO1", "OO",
"L", "K", "J", "H", "G", "F", "D", "S", "L", "K", "J", "H", "G", "F", "D", "S",
"A", "AY", "Y1", "UH3", "AH", "P", "O", "I", "A", "AY", "Y1", "UH3", "AH", "P", "O", "I",
"U", "Y", "T", "R", "E", "W", "AE", "AE1", "U", "Y", "T", "R", "E", "W", "AE", "AE1",
"AW2", "UH2", "UH1", "UH", "O2", "O1", "IU", "U1", "AW2", "UH2", "UH1", "UH", "O2", "O1", "IU", "U1",
"THV", "TH", "ER", "EH", "E1", "AW", " "/*PA1*/, "."/*STOP*/ "THV", "TH", "ER", "EH", "E1", "AW", " "/*PA1*/, "."/*STOP*/
}; };
@ -103,7 +103,7 @@ WRITE8_MEMBER( votrax_device::write )
{ {
// append to the current string // append to the current string
m_current.cat(s_phoneme_table[data & 0x3f]); m_current.cat(s_phoneme_table[data & 0x3f]);
// look for a match in our sample table // look for a match in our sample table
for (int index = 0; m_votrax_map[index].phoneme != NULL; index++) for (int index = 0; m_votrax_map[index].phoneme != NULL; index++)
if (m_current.find(m_votrax_map[index].phoneme) != -1) if (m_current.find(m_votrax_map[index].phoneme) != -1)
@ -117,7 +117,7 @@ WRITE8_MEMBER( votrax_device::write )
m_current.reset(); m_current.reset();
return; return;
} }
// if we got a stop and didn't find a match, print it // if we got a stop and didn't find a match, print it
if ((data & 0x3f) == 0x3f) if ((data & 0x3f) == 0x3f)
{ {
@ -157,7 +157,7 @@ void votrax_device::device_start()
m_channels = 1; m_channels = 1;
m_names = m_sample_list; m_names = m_sample_list;
m_start = NULL; m_start = NULL;
// let the samples device do the rest // let the samples device do the rest
samples_device::device_start(); samples_device::device_start();
} }

View File

@ -76,7 +76,7 @@ struct votrax_interface
// ======================> votrax_device // ======================> votrax_device
class votrax_device : public samples_device, class votrax_device : public samples_device,
public votrax_interface public votrax_interface
{ {
public: public:
@ -89,7 +89,7 @@ public:
// writers // writers
DECLARE_WRITE8_MEMBER( write ); DECLARE_WRITE8_MEMBER( write );
DECLARE_READ_LINE_MEMBER( status ); DECLARE_READ_LINE_MEMBER( status );
protected: protected:
// device-level overrides // device-level overrides
virtual void device_start(); virtual void device_start();

View File

@ -1072,8 +1072,8 @@ static void recompute_params(running_machine &machine)
static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data) static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data)
{ {
/* Doom does this */ /* Doom does this */
// if(vga.crtc.protect_enable && index <= 0x07) // if(vga.crtc.protect_enable && index <= 0x07)
// printf("write to protected address %02x\n",index); // printf("write to protected address %02x\n",index);
switch(index) switch(index)
{ {
@ -1260,7 +1260,7 @@ static UINT8 vga_vblank(running_machine &machine)
res = 1; 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; return res;
} }
@ -2234,7 +2234,7 @@ WRITE8_HANDLER(tseng_et4k_03d0_w)
vga.crtc.data[vga.crtc.index] = data; vga.crtc.data[vga.crtc.index] = data;
tseng_crtc_reg_write(space->machine(),vga.crtc.index,data); tseng_crtc_reg_write(space->machine(),vga.crtc.index,data);
//if((vga.crtc.index & 0xfe) != 0x0e) //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; break;
case 8: case 8:
et4k.reg_3d8 = data; et4k.reg_3d8 = data;

View File

@ -184,9 +184,9 @@ chd_file *ldplayer_state::get_disc()
{ {
astring fullpath(image_file->fullpath(); astring fullpath(image_file->fullpath();
image_file.close(); image_file.close();
// try to open the CHD // try to open the CHD
if (set_disk_handle(machine(), "laserdisc", fullpath) == CHDERR_NONE) if (set_disk_handle(machine(), "laserdisc", fullpath) == CHDERR_NONE)
{ {
m_filename.cpy(dir->name); m_filename.cpy(dir->name);

View File

@ -300,7 +300,7 @@ bool pc_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
const format &f = formats[type]; const format &f = formats[type];
if(!f.desc) if(!f.desc)
return false; return false;
UINT8 sectdata[36*512]; UINT8 sectdata[36*512];
desc_s sectors[36]; desc_s sectors[36];
for(int i=0; i<f.sector_count; i++) { for(int i=0; i<f.sector_count; i++) {

View File

@ -136,17 +136,17 @@ void SzAr_Free(CSzAr *p, ISzAlloc *alloc);
*outBufferSize *outBufferSize
You can consider "*outBuffer" as cache of solid block. If your archive is solid, You can consider "*outBuffer" as cache of solid block. If your archive is solid,
it will increase decompression speed. it will increase decompression speed.
If you use external function, you can declare these 3 cache variables If you use external function, you can declare these 3 cache variables
(blockIndex, outBuffer, outBufferSize) as static in that external function. (blockIndex, outBuffer, outBufferSize) as static in that external function.
Free *outBuffer and set *outBuffer to 0, if you want to flush cache. Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
*/ */
typedef struct typedef struct
{ {
CSzAr db; CSzAr db;
UInt64 startPosAfterHeader; UInt64 startPosAfterHeader;
UInt64 dataPos; UInt64 dataPos;

View File

@ -52,11 +52,11 @@ void MY_FAST_CALL CrcGenerateTable()
UInt32 r = g_CrcTable[i - 256]; UInt32 r = g_CrcTable[i - 256];
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
} }
#ifdef MY_CPU_LE #ifdef MY_CPU_LE
g_CrcUpdate = CrcUpdateT4; g_CrcUpdate = CrcUpdateT4;
#if CRC_NUM_TABLES == 8 #if CRC_NUM_TABLES == 8
if (!CPU_Is_InOrder()) if (!CPU_Is_InOrder())
g_CrcUpdate = CrcUpdateT8; g_CrcUpdate = CrcUpdateT8;

View File

@ -537,12 +537,12 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc)
{ {
UInt32 numCoders, numBindPairs, numPackStreams, i; UInt32 numCoders, numBindPairs, numPackStreams, i;
UInt32 numInStreams = 0, numOutStreams = 0; UInt32 numInStreams = 0, numOutStreams = 0;
RINOK(SzReadNumber32(sd, &numCoders)); RINOK(SzReadNumber32(sd, &numCoders));
if (numCoders > NUM_FOLDER_CODERS_MAX) if (numCoders > NUM_FOLDER_CODERS_MAX)
return SZ_ERROR_UNSUPPORTED; return SZ_ERROR_UNSUPPORTED;
folder->NumCoders = numCoders; folder->NumCoders = numCoders;
MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc);
for (i = 0; i < numCoders; i++) for (i = 0; i < numCoders; i++)
@ -810,7 +810,7 @@ static SRes SzReadSubStreamsInfo(
numDigests += numSubstreams; numDigests += numSubstreams;
} }
si = 0; si = 0;
for (;;) for (;;)
{ {
@ -963,8 +963,8 @@ static SRes SzReadHeader2(
RINOK(SzReadArchiveProperties(sd)); RINOK(SzReadArchiveProperties(sd));
RINOK(SzReadID(sd, &type)); RINOK(SzReadID(sd, &type));
} }
if (type == k7zIdMainStreamsInfo) if (type == k7zIdMainStreamsInfo)
{ {
RINOK(SzReadStreamsInfo(sd, RINOK(SzReadStreamsInfo(sd,
@ -982,7 +982,7 @@ static SRes SzReadHeader2(
return SZ_OK; return SZ_OK;
if (type != k7zIdFilesInfo) if (type != k7zIdFilesInfo)
return SZ_ERROR_ARCHIVE; return SZ_ERROR_ARCHIVE;
RINOK(SzReadNumber32(sd, &numFiles)); RINOK(SzReadNumber32(sd, &numFiles));
p->db.NumFiles = numFiles; p->db.NumFiles = numFiles;
@ -1165,19 +1165,19 @@ static SRes SzReadAndDecodePackedStreams2(
RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, RINOK(SzReadStreamsInfo(sd, &dataStartPos, p,
&numUnpackStreams, unpackSizes, digestsDefined, digests, &numUnpackStreams, unpackSizes, digestsDefined, digests,
allocTemp, allocTemp)); allocTemp, allocTemp));
dataStartPos += baseOffset; dataStartPos += baseOffset;
if (p->NumFolders != 1) if (p->NumFolders != 1)
return SZ_ERROR_ARCHIVE; return SZ_ERROR_ARCHIVE;
folder = p->Folders; folder = p->Folders;
unpackSize = SzFolder_GetUnpackSize(folder); unpackSize = SzFolder_GetUnpackSize(folder);
RINOK(LookInStream_SeekTo(inStream, dataStartPos)); RINOK(LookInStream_SeekTo(inStream, dataStartPos));
if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp))
return SZ_ERROR_MEM; return SZ_ERROR_MEM;
res = SzFolder_Decode(folder, p->PackSizes, res = SzFolder_Decode(folder, p->PackSizes,
inStream, dataStartPos, inStream, dataStartPos,
outBuffer->data, (size_t)unpackSize, allocTemp); outBuffer->data, (size_t)unpackSize, allocTemp);
@ -1240,7 +1240,7 @@ static SRes SzArEx_Open2(
nextHeaderCRC = GetUi32(header + 28); nextHeaderCRC = GetUi32(header + 28);
p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; p->startPosAfterHeader = startArcPos + k7zStartHeaderSize;
if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) if (CrcCalc(header + 12, 20) != GetUi32(header + 8))
return SZ_ERROR_CRC; return SZ_ERROR_CRC;
@ -1356,9 +1356,9 @@ SRes SzArEx_Extract(
*blockIndex = folderIndex; *blockIndex = folderIndex;
IAlloc_Free(allocMain, *outBuffer); IAlloc_Free(allocMain, *outBuffer);
*outBuffer = 0; *outBuffer = 0;
RINOK(LookInStream_SeekTo(inStream, startOffset)); RINOK(LookInStream_SeekTo(inStream, startOffset));
if (res == SZ_OK) if (res == SZ_OK)
{ {
*outBufferSize = unpackSize; *outBufferSize = unpackSize;

View File

@ -228,9 +228,9 @@ void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks)
p[1] ^= GetUi32(data + 4); p[1] ^= GetUi32(data + 4);
p[2] ^= GetUi32(data + 8); p[2] ^= GetUi32(data + 8);
p[3] ^= GetUi32(data + 12); p[3] ^= GetUi32(data + 12);
Aes_Encode(p + 4, p, p); Aes_Encode(p + 4, p, p);
SetUi32(data, p[0]); SetUi32(data, p[0]);
SetUi32(data + 4, p[1]); SetUi32(data + 4, p[1]);
SetUi32(data + 8, p[2]); 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 + 4, p[1] ^ out[1]);
SetUi32(data + 8, p[2] ^ out[2]); SetUi32(data + 8, p[2] ^ out[2]);
SetUi32(data + 12, p[3] ^ out[3]); SetUi32(data + 12, p[3] ^ out[3]);
p[0] = in[0]; p[0] = in[0];
p[1] = in[1]; p[1] = in[1];
p[2] = in[2]; p[2] = in[2];

View File

@ -99,7 +99,7 @@ void *BigAlloc(size_t size)
#ifdef _SZ_ALLOC_DEBUG #ifdef _SZ_ALLOC_DEBUG
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++); fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
#endif #endif
#ifdef _7ZIP_LARGE_PAGES #ifdef _7ZIP_LARGE_PAGES
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18)) if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
{ {
@ -118,7 +118,7 @@ void BigFree(void *address)
if (address != 0) if (address != 0)
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig); fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
#endif #endif
if (address == 0) if (address == 0)
return; return;
VirtualFree(address, 0, MEM_RELEASE); VirtualFree(address, 0, MEM_RELEASE);

View File

@ -48,14 +48,14 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
((UInt32)data[i + 0] << 11) | ((UInt32)data[i + 0] << 11) |
(((UInt32)data[i + 3] & 0x7) << 8) | (((UInt32)data[i + 3] & 0x7) << 8) |
(data[i + 2]); (data[i + 2]);
src <<= 1; src <<= 1;
if (encoding) if (encoding)
dest = ip + (UInt32)i + src; dest = ip + (UInt32)i + src;
else else
dest = src - (ip + (UInt32)i); dest = src - (ip + (UInt32)i);
dest >>= 1; dest >>= 1;
data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7)); data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));
data[i + 0] = (Byte)(dest >> 11); data[i + 0] = (Byte)(dest >> 11);
data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7)); 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 + 1] << 16) |
((UInt32)data[i + 2] << 8) | ((UInt32)data[i + 2] << 8) |
((UInt32)data[i + 3] & (~3)); ((UInt32)data[i + 3] & (~3));
UInt32 dest; UInt32 dest;
if (encoding) if (encoding)
dest = ip + (UInt32)i + src; 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 + 2] << 8) |
((UInt32)data[i + 3]); ((UInt32)data[i + 3]);
UInt32 dest; UInt32 dest;
src <<= 2; src <<= 2;
if (encoding) if (encoding)
dest = ip + i + src; dest = ip + i + src;
else else
dest = src - (ip + i); dest = src - (ip + i);
dest >>= 2; dest >>= 2;
dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
data[i + 0] = (Byte)(dest >> 24); data[i + 0] = (Byte)(dest >> 24);

View File

@ -13,23 +13,23 @@ extern "C" {
/* /*
These functions convert relative addresses to absolute addresses These functions convert relative addresses to absolute addresses
in CALL instructions to increase the compression ratio. in CALL instructions to increase the compression ratio.
In: In:
data - data buffer data - data buffer
size - size of data size - size of data
ip - current virtual Instruction Pinter (IP) value ip - current virtual Instruction Pinter (IP) value
state - state variable for x86 converter state - state variable for x86 converter
encoding - 0 (for decoding), 1 (for encoding) encoding - 0 (for decoding), 1 (for encoding)
Out: Out:
state - state variable for x86 converter state - state variable for x86 converter
Returns: Returns:
The number of processed bytes. If you call these functions with multiple calls, 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. you must start next call with first byte after block of processed bytes.
Type Endian Alignment LookAhead Type Endian Alignment LookAhead
x86 little 1 4 x86 little 1 4
ARMT little 2 2 ARMT little 2 2
ARM little 4 0 ARM little 4 0

View File

@ -42,20 +42,20 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF); UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
UInt32 dest; UInt32 dest;
src |= ((UInt32)(instNorm >> 36) & 1) << 20; src |= ((UInt32)(instNorm >> 36) & 1) << 20;
src <<= 4; src <<= 4;
if (encoding) if (encoding)
dest = ip + (UInt32)i + src; dest = ip + (UInt32)i + src;
else else
dest = src - (ip + (UInt32)i); dest = src - (ip + (UInt32)i);
dest >>= 4; dest >>= 4;
instNorm &= ~((UInt64)(0x8FFFFF) << 13); instNorm &= ~((UInt64)(0x8FFFFF) << 13);
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13); instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20)); instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
instruction &= (1 << bitRes) - 1; instruction &= (1 << bitRes) - 1;
instruction |= (instNorm << bitRes); instruction |= (instNorm << bitRes);
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)

View File

@ -96,7 +96,7 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
gPrev = Groups[sp]; gPrev = Groups[sp];
temp[0] = (gPrev << NumRefBits); temp[0] = (gPrev << NumRefBits);
} }
for (j = 1; j < groupSize; j++) for (j = 1; j < groupSize; j++)
{ {
UInt32 sp = ind2[j] + NumSortedBytes; UInt32 sp = ind2[j] + NumSortedBytes;
@ -114,11 +114,11 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
return 1; return 1;
} }
} }
HeapSort(temp, groupSize); HeapSort(temp, groupSize);
mask = ((1 << NumRefBits) - 1); mask = ((1 << NumRefBits) - 1);
thereAreGroups = 0; thereAreGroups = 0;
group = groupOffset; group = groupOffset;
cg = (temp[0] >> NumRefBits); cg = (temp[0] >> NumRefBits);
temp[0] = ind2[temp[0] & mask]; temp[0] = ind2[temp[0] & mask];
@ -129,12 +129,12 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
#else #else
UInt32 prevGroupStart = 0; UInt32 prevGroupStart = 0;
#endif #endif
for (j = 1; j < groupSize; j++) for (j = 1; j < groupSize; j++)
{ {
UInt32 val = temp[j]; UInt32 val = temp[j];
UInt32 cgCur = (val >> NumRefBits); UInt32 cgCur = (val >> NumRefBits);
if (cgCur != cg) if (cgCur != cg)
{ {
cg = cgCur; cg = cgCur;
@ -398,7 +398,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
for (i = 0; i < blockSize - 1; i++) for (i = 0; i < blockSize - 1; i++)
Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i; Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i;
Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i; Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i;
#ifndef BLOCK_SORT_EXTERNAL_FLAGS #ifndef BLOCK_SORT_EXTERNAL_FLAGS
{ {
UInt32 prev = 0; UInt32 prev = 0;
@ -441,7 +441,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
for (groupSize = 1; for (groupSize = 1;
(Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0; (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
groupSize++); groupSize++);
groupSize++; groupSize++;
#else #else
@ -473,7 +473,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
} }
#endif #endif
if (NumSortedBytes >= blockSize) if (NumSortedBytes >= blockSize)
{ {
UInt32 j; UInt32 j;

View File

@ -81,7 +81,7 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
: "0" (function)) ; : "0" (function)) ;
#endif #endif
#else #else
int CPUInfo[4]; int CPUInfo[4];

View File

@ -18,9 +18,9 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
/* if (maxLen > 10) maxLen = 10; */ /* if (maxLen > 10) maxLen = 10; */
{ {
UInt32 i; UInt32 i;
#ifdef HUFFMAN_SPEED_OPT #ifdef HUFFMAN_SPEED_OPT
UInt32 counters[NUM_COUNTERS]; UInt32 counters[NUM_COUNTERS];
for (i = 0; i < NUM_COUNTERS; i++) for (i = 0; i < NUM_COUNTERS; i++)
counters[i] = 0; counters[i] = 0;
@ -29,7 +29,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
UInt32 freq = freqs[i]; UInt32 freq = freqs[i];
counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++; counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++;
} }
for (i = 1; i < NUM_COUNTERS; i++) for (i = 1; i < NUM_COUNTERS; i++)
{ {
UInt32 temp = 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; counters[0] = 0;
HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]); HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]);
#else #else
for (i = 0; i < numSymbols; i++) 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; lens[minCode] = lens[maxCode] = 1;
return; return;
} }
{ {
UInt32 b, e, i; UInt32 b, e, i;
i = b = e = 0; i = b = e = 0;
do do
{ {
@ -96,12 +96,12 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
e++; e++;
} }
while (num - e > 1); while (num - e > 1);
{ {
UInt32 lenCounters[kMaxLen + 1]; UInt32 lenCounters[kMaxLen + 1];
for (i = 0; i <= kMaxLen; i++) for (i = 0; i <= kMaxLen; i++)
lenCounters[i] = 0; lenCounters[i] = 0;
p[--e] &= MASK; p[--e] &= MASK;
lenCounters[1] = 2; lenCounters[1] = 2;
while (e > 0) while (e > 0)
@ -113,7 +113,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
lenCounters[len]--; lenCounters[len]--;
lenCounters[len + 1] += 2; lenCounters[len + 1] += 2;
} }
{ {
UInt32 len; UInt32 len;
i = 0; i = 0;
@ -124,7 +124,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
lens[p[i++] & MASK] = (Byte)len; lens[p[i++] & MASK] = (Byte)len;
} }
} }
{ {
UInt32 nextCodes[kMaxLen + 1]; UInt32 nextCodes[kMaxLen + 1];
{ {

View File

@ -17,7 +17,7 @@ Conditions:
maxLen <= 16 = kMaxLen maxLen <= 16 = kMaxLen
Num_Items(p) >= HUFFMAN_TEMP_SIZE(num) Num_Items(p) >= HUFFMAN_TEMP_SIZE(num)
*/ */
void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen); void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -512,7 +512,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
delta2 = p->pos - p->hash[hash2Value]; delta2 = p->pos - p->hash[hash2Value];
curMatch = p->hash[kFix3HashSize + hashValue]; curMatch = p->hash[kFix3HashSize + hashValue];
p->hash[hash2Value] = p->hash[hash2Value] =
p->hash[kFix3HashSize + hashValue] = p->pos; 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]; delta2 = p->pos - p->hash[ hash2Value];
delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
curMatch = p->hash[kFix4HashSize + hashValue]; curMatch = p->hash[kFix4HashSize + hashValue];
p->hash[ hash2Value] = p->hash[ hash2Value] =
p->hash[kFix3HashSize + hash3Value] = p->hash[kFix3HashSize + hash3Value] =
p->hash[kFix4HashSize + hashValue] = p->pos; p->hash[kFix4HashSize + hashValue] = p->pos;

View File

@ -58,7 +58,7 @@ void MtSync_StopWriting(CMtSync *p)
p->csWasEntered = False; p->csWasEntered = False;
} }
Semaphore_Release1(&p->freeSemaphore); Semaphore_Release1(&p->freeSemaphore);
Event_Wait(&p->wasStopped); Event_Wait(&p->wasStopped);
while (myNumBlocks++ != p->numProcessedBlocks) 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->canStart));
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted)); RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted));
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped)); RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped));
RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks)); RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks));
RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks)); RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks));
p->needStart = True; p->needStart = True;
RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj)); RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj));
p->wasCreated = True; p->wasCreated = True;
return SZ_OK; return SZ_OK;
@ -385,7 +385,7 @@ void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex)
CriticalSection_Enter(&sync->cs); CriticalSection_Enter(&sync->cs);
sync->csWasEntered = True; sync->csWasEntered = True;
} }
BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize); BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize);
if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize) if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize)
@ -561,7 +561,7 @@ UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
const Byte *cur = p->pointerToCurPos; const Byte *cur = p->pointerToCurPos;
UInt32 lzPos = p->lzPos; UInt32 lzPos = p->lzPos;
MT_HASH2_CALC MT_HASH2_CALC
curMatch2 = hash[hash2Value]; curMatch2 = hash[hash2Value];
hash[hash2Value] = lzPos; hash[hash2Value] = lzPos;
@ -584,7 +584,7 @@ UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
curMatch2 = hash[ hash2Value]; curMatch2 = hash[ hash2Value];
curMatch3 = hash[kFix3HashSize + hash3Value]; curMatch3 = hash[kFix3HashSize + hash3Value];
hash[ hash2Value] = hash[ hash2Value] =
hash[kFix3HashSize + hash3Value] = hash[kFix3HashSize + hash3Value] =
lzPos; lzPos;
@ -616,11 +616,11 @@ UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
const Byte *cur = p->pointerToCurPos; const Byte *cur = p->pointerToCurPos;
UInt32 lzPos = p->lzPos; UInt32 lzPos = p->lzPos;
MT_HASH4_CALC MT_HASH4_CALC
curMatch2 = hash[ hash2Value]; curMatch2 = hash[ hash2Value];
curMatch3 = hash[kFix3HashSize + hash3Value]; curMatch3 = hash[kFix3HashSize + hash3Value];
curMatch4 = hash[kFix4HashSize + hash4Value]; curMatch4 = hash[kFix4HashSize + hash4Value];
hash[ hash2Value] = hash[ hash2Value] =
hash[kFix3HashSize + hash3Value] = hash[kFix3HashSize + hash3Value] =
hash[kFix4HashSize + hash4Value] = hash[kFix4HashSize + hash4Value] =

View File

@ -62,7 +62,7 @@ typedef struct _CMatchFinderMt
const UInt32 *crc; const UInt32 *crc;
Mf_Mix_Matches MixMatchesFunc; Mf_Mix_Matches MixMatchesFunc;
/* LZ + BT */ /* LZ + BT */
CMtSync btSync; CMtSync btSync;
Byte btDummy[kMtCacheLineDummy]; Byte btDummy[kMtCacheLineDummy];
@ -85,7 +85,7 @@ typedef struct _CMatchFinderMt
/* BT + Hash */ /* BT + Hash */
CMtSync hashSync; CMtSync hashSync;
/* Byte hashDummy[kMtCacheLineDummy]; */ /* Byte hashDummy[kMtCacheLineDummy]; */
/* Hash */ /* Hash */
Mf_GetHeads GetHeadsFunc; Mf_GetHeads GetHeadsFunc;
CMatchFinder *MatchFinder; CMatchFinder *MatchFinder;

View File

@ -114,17 +114,17 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
else else
p->unpackSize = (UInt32)(p->control & 0x1F) << 16; p->unpackSize = (UInt32)(p->control & 0x1F) << 16;
return LZMA2_STATE_UNPACK0; return LZMA2_STATE_UNPACK0;
case LZMA2_STATE_UNPACK0: case LZMA2_STATE_UNPACK0:
p->unpackSize |= (UInt32)b << 8; p->unpackSize |= (UInt32)b << 8;
return LZMA2_STATE_UNPACK1; return LZMA2_STATE_UNPACK1;
case LZMA2_STATE_UNPACK1: case LZMA2_STATE_UNPACK1:
p->unpackSize |= (UInt32)b; p->unpackSize |= (UInt32)b;
p->unpackSize++; p->unpackSize++;
PRF(printf(" %8d", p->unpackSize)); PRF(printf(" %8d", p->unpackSize));
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
case LZMA2_STATE_PACK0: case LZMA2_STATE_PACK0:
p->packSize = (UInt32)b << 8; p->packSize = (UInt32)b << 8;
return LZMA2_STATE_PACK1; return LZMA2_STATE_PACK1;
@ -199,7 +199,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
SizeT destSizeCur = dicLimit - dicPos; SizeT destSizeCur = dicLimit - dicPos;
SizeT srcSizeCur = inSize - *srcLen; SizeT srcSizeCur = inSize - *srcLen;
ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY;
if (p->unpackSize <= destSizeCur) if (p->unpackSize <= destSizeCur)
{ {
destSizeCur = (SizeT)p->unpackSize; destSizeCur = (SizeT)p->unpackSize;
@ -250,7 +250,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
Bool initState = (mode > 0); Bool initState = (mode > 0);
if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) if ((!initDic && p->needInitDic) || (!initState && p->needInitState))
return SZ_ERROR_DATA; return SZ_ERROR_DATA;
LzmaDec_InitDicAndState(&p->decoder, initDic, initState); LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
p->needInitDic = False; p->needInitDic = False;
p->needInitState = False; p->needInitState = False;
@ -258,9 +258,9 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
} }
if (srcSizeCur > p->packSize) if (srcSizeCur > p->packSize)
srcSizeCur = (SizeT)p->packSize; srcSizeCur = (SizeT)p->packSize;
res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status);
src += srcSizeCur; src += srcSizeCur;
*srcLen += srcSizeCur; *srcLen += srcSizeCur;
p->packSize -= (UInt32)srcSizeCur; p->packSize -= (UInt32)srcSizeCur;

View File

@ -83,11 +83,11 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
if (packSize < lzHeaderSize) if (packSize < lzHeaderSize)
return SZ_ERROR_OUTPUT_EOF; return SZ_ERROR_OUTPUT_EOF;
packSize -= lzHeaderSize; packSize -= lzHeaderSize;
LzmaEnc_SaveState(p->enc); LzmaEnc_SaveState(p->enc);
res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState, res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState,
outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize); outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize);
PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize)); PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize));
if (unpackSize == 0) if (unpackSize == 0)
@ -146,10 +146,10 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
outBuf[destPos++] = (Byte)u; outBuf[destPos++] = (Byte)u;
outBuf[destPos++] = (Byte)(pm >> 8); outBuf[destPos++] = (Byte)(pm >> 8);
outBuf[destPos++] = (Byte)pm; outBuf[destPos++] = (Byte)pm;
if (p->needInitProp) if (p->needInitProp)
outBuf[destPos++] = p->props; outBuf[destPos++] = p->props;
p->needInitProp = False; p->needInitProp = False;
p->needInitState = False; p->needInitState = False;
destPos += packSize; destPos += packSize;
@ -244,7 +244,7 @@ typedef struct
{ {
Byte propEncoded; Byte propEncoded;
CLzma2EncProps props; CLzma2EncProps props;
Byte *outBuf; Byte *outBuf;
ISzAlloc *alloc; ISzAlloc *alloc;
@ -322,10 +322,10 @@ static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *des
if (srcSize != 0) if (srcSize != 0)
{ {
RINOK(Lzma2EncInt_Init(p, &mainEncoder->props)); RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE, RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE,
mainEncoder->alloc, mainEncoder->allocBig)); mainEncoder->alloc, mainEncoder->allocBig));
while (p->srcPos < srcSize) while (p->srcPos < srcSize)
{ {
size_t packSize = destLim - *destSize; size_t packSize = destLim - *destSize;
@ -460,7 +460,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
mtCallback.funcTable.Code = MtCallbackImp_Code; mtCallback.funcTable.Code = MtCallbackImp_Code;
mtCallback.lzma2Enc = p; mtCallback.lzma2Enc = p;
p->mtCoder.progress = progress; p->mtCoder.progress = progress;
p->mtCoder.inStream = inStream; p->mtCoder.inStream = inStream;
p->mtCoder.outStream = outStream; p->mtCoder.outStream = outStream;
@ -470,7 +470,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
p->mtCoder.blockSize = p->props.blockSize; p->mtCoder.blockSize = p->props.blockSize;
p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16; p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;
p->mtCoder.numThreads = p->props.numBlockThreads; p->mtCoder.numThreads = p->props.numBlockThreads;
return MtCoder_Code(&p->mtCoder); return MtCoder_Code(&p->mtCoder);
} }
#endif #endif

View File

@ -26,7 +26,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
LzmaEncProps_Init(&props); LzmaEncProps_Init(&props);
props.level = level; props.level = level;
props.dictSize = dictSize; props.dictSize = dictSize;
*destLen = 0; *destLen = 0;
if (outSize2 < LZMA86_HEADER_SIZE) if (outSize2 < LZMA86_HEADER_SIZE)
return SZ_ERROR_OUTPUT_EOF; return SZ_ERROR_OUTPUT_EOF;
@ -78,12 +78,12 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
break; break;
if (useFilter && i == 0) if (useFilter && i == 0)
curModeIsFiltered = True; curModeIsFiltered = True;
curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed, curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed,
curModeIsFiltered ? filteredStream : src, srcLen, curModeIsFiltered ? filteredStream : src, srcLen,
&props, dest + 1, &outPropsSize, 0, &props, dest + 1, &outPropsSize, 0,
NULL, &g_Alloc, &g_Alloc); NULL, &g_Alloc, &g_Alloc);
if (curRes != SZ_ERROR_OUTPUT_EOF) if (curRes != SZ_ERROR_OUTPUT_EOF)
{ {
if (curRes != SZ_OK) if (curRes != SZ_OK)

View File

@ -141,7 +141,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
Byte *dic = p->dic; Byte *dic = p->dic;
SizeT dicBufSize = p->dicBufSize; SizeT dicBufSize = p->dicBufSize;
SizeT dicPos = p->dicPos; SizeT dicPos = p->dicPos;
UInt32 processedPos = p->processedPos; UInt32 processedPos = p->processedPos;
UInt32 checkDicSize = p->checkDicSize; UInt32 checkDicSize = p->checkDicSize;
unsigned len = 0; unsigned len = 0;
@ -324,7 +324,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
{ {
NORMALIZE NORMALIZE
range >>= 1; range >>= 1;
{ {
UInt32 t; UInt32 t;
code -= range; code -= range;
@ -723,7 +723,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
SizeT inSize = *srcLen; SizeT inSize = *srcLen;
(*srcLen) = 0; (*srcLen) = 0;
LzmaDec_WriteRem(p, dicLimit); LzmaDec_WriteRem(p, dicLimit);
*status = LZMA_STATUS_NOT_SPECIFIED; *status = LZMA_STATUS_NOT_SPECIFIED;
while (p->remainLen != kMatchSpecLenStart) while (p->remainLen != kMatchSpecLenStart)
@ -769,7 +769,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
if (p->needInitState) if (p->needInitState)
LzmaDec_InitStateReal(p); LzmaDec_InitStateReal(p);
if (p->tempBufSize == 0) if (p->tempBufSize == 0)
{ {
SizeT processed; SizeT processed;
@ -900,12 +900,12 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
{ {
UInt32 dicSize; UInt32 dicSize;
Byte d; Byte d;
if (size < LZMA_PROPS_SIZE) if (size < LZMA_PROPS_SIZE)
return SZ_ERROR_UNSUPPORTED; return SZ_ERROR_UNSUPPORTED;
else else
dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
if (dicSize < LZMA_DIC_MIN) if (dicSize < LZMA_DIC_MIN)
dicSize = LZMA_DIC_MIN; dicSize = LZMA_DIC_MIN;
p->dicSize = dicSize; p->dicSize = dicSize;

View File

@ -130,7 +130,7 @@ LzmaDec_Allocate* can return:
SZ_ERROR_MEM - Memory allocation error SZ_ERROR_MEM - Memory allocation error
SZ_ERROR_UNSUPPORTED - Unsupported properties SZ_ERROR_UNSUPPORTED - Unsupported properties
*/ */
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
@ -159,7 +159,7 @@ void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
*/ */
/* LzmaDec_DecodeToDic /* LzmaDec_DecodeToDic
The decoding to internal dictionary buffer (CLzmaDec::dic). The decoding to internal dictionary buffer (CLzmaDec::dic).
You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!

View File

@ -119,7 +119,7 @@ void LzmaEnc_FastPosInit(Byte *g_FastPos)
int c = 2, slotFast; int c = 2, slotFast;
g_FastPos[0] = 0; g_FastPos[0] = 0;
g_FastPos[1] = 1; g_FastPos[1] = 1;
for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++) for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
{ {
UInt32 k = (1 << ((slotFast >> 1) - 1)); UInt32 k = (1 << ((slotFast >> 1) - 1));
@ -256,7 +256,7 @@ typedef struct
CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
CLzmaProb posAlignEncoder[1 << kNumAlignBits]; CLzmaProb posAlignEncoder[1 << kNumAlignBits];
CLenPriceEnc lenEnc; CLenPriceEnc lenEnc;
CLenPriceEnc repLenEnc; CLenPriceEnc repLenEnc;
@ -279,7 +279,7 @@ typedef struct
#ifndef _7ZIP_ST #ifndef _7ZIP_ST
Byte pad[128]; Byte pad[128];
#endif #endif
UInt32 optimumEndIndex; UInt32 optimumEndIndex;
UInt32 optimumCurrentIndex; UInt32 optimumCurrentIndex;
@ -287,7 +287,7 @@ typedef struct
UInt32 numPairs; UInt32 numPairs;
UInt32 numAvail; UInt32 numAvail;
COptimal opt[kNumOpts]; COptimal opt[kNumOpts];
#ifndef LZMA_LOG_BSR #ifndef LZMA_LOG_BSR
Byte g_FastPos[1 << kNumLogBits]; Byte g_FastPos[1 << kNumLogBits];
#endif #endif
@ -321,14 +321,14 @@ typedef struct
CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
CLzmaProb posAlignEncoder[1 << kNumAlignBits]; CLzmaProb posAlignEncoder[1 << kNumAlignBits];
CLenPriceEnc lenEnc; CLenPriceEnc lenEnc;
CLenPriceEnc repLenEnc; CLenPriceEnc repLenEnc;
unsigned lclp; unsigned lclp;
Bool fastMode; Bool fastMode;
CRangeEnc rc; CRangeEnc rc;
Bool writeEndMark; Bool writeEndMark;
@ -917,10 +917,10 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
{ {
UInt32 posPrev = posMem; UInt32 posPrev = posMem;
UInt32 backCur = backMem; UInt32 backCur = backMem;
backMem = p->opt[posPrev].backPrev; backMem = p->opt[posPrev].backPrev;
posMem = p->opt[posPrev].posPrev; posMem = p->opt[posPrev].posPrev;
p->opt[posPrev].backPrev = backCur; p->opt[posPrev].backPrev = backCur;
p->opt[posPrev].posPrev = cur; p->opt[posPrev].posPrev = cur;
cur = posPrev; cur = posPrev;
@ -951,7 +951,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
return lenRes; return lenRes;
} }
p->optimumCurrentIndex = p->optimumEndIndex = 0; p->optimumCurrentIndex = p->optimumEndIndex = 0;
if (p->additionalOffset == 0) if (p->additionalOffset == 0)
mainLen = ReadMatchDistances(p, &numPairs); mainLen = ReadMatchDistances(p, &numPairs);
else else
@ -1249,7 +1249,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
{ {
UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
@ -1311,7 +1311,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
} }
} }
} }
startLen = 2; /* speed optimization */ startLen = 2; /* speed optimization */
{ {
UInt32 repIndex; UInt32 repIndex;
@ -1342,10 +1342,10 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
} }
while (--lenTest >= 2); while (--lenTest >= 2);
lenTest = lenTestTemp; lenTest = lenTestTemp;
if (repIndex == 0) if (repIndex == 0)
startLen = lenTest + 1; startLen = lenTest + 1;
/* if (_maxMode) */ /* if (_maxMode) */
{ {
UInt32 lenTest2 = lenTest + 1; UInt32 lenTest2 = lenTest + 1;
@ -1369,7 +1369,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
nextRepMatchPrice = curAndLenCharPrice + nextRepMatchPrice = curAndLenCharPrice +
GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isMatch[state2][posStateNext]) +
GET_PRICE_1(p->isRep[state2]); GET_PRICE_1(p->isRep[state2]);
/* for (; lenTest2 >= 2; lenTest2--) */ /* for (; lenTest2 >= 2; lenTest2--) */
{ {
UInt32 curAndLenPrice; UInt32 curAndLenPrice;
@ -1424,7 +1424,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
else else
curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];
opt = &p->opt[cur + lenTest]; opt = &p->opt[cur + lenTest];
if (curAndLenPrice < opt->price) if (curAndLenPrice < opt->price)
{ {
@ -1458,7 +1458,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
nextRepMatchPrice = curAndLenCharPrice + nextRepMatchPrice = curAndLenCharPrice +
GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isMatch[state2][posStateNext]) +
GET_PRICE_1(p->isRep[state2]); GET_PRICE_1(p->isRep[state2]);
/* for (; lenTest2 >= 2; lenTest2--) */ /* for (; lenTest2 >= 2; lenTest2--) */
{ {
UInt32 offset = cur + lenTest + 1 + lenTest2; UInt32 offset = cur + lenTest + 1 + lenTest2;
@ -1570,7 +1570,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
MovePos(p, repLen - 1); MovePos(p, repLen - 1);
return repLen; return repLen;
} }
if (mainLen < 2 || numAvail <= 2) if (mainLen < 2 || numAvail <= 2)
return 1; return 1;
@ -1584,7 +1584,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
(p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist)))
return 1; return 1;
} }
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
for (i = 0; i < LZMA_NUM_REPS; i++) 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; pos -= LZMA_NUM_REPS;
GetPosSlot(pos, posSlot); GetPosSlot(pos, posSlot);
RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);
if (posSlot >= kStartPosModelIndex) if (posSlot >= kStartPosModelIndex)
{ {
UInt32 footerBits = ((posSlot >> 1) - 1); UInt32 footerBits = ((posSlot >> 1) - 1);
@ -2150,7 +2150,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
p->rc.outStream = &outStream.funcTable; p->rc.outStream = &outStream.funcTable;
res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
*unpackSize = (UInt32)(p->nowPos64 - nowPos64); *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
*destLen -= outStream.rem; *destLen -= outStream.rem;
if (outStream.overflow) if (outStream.overflow)

View File

@ -38,7 +38,7 @@ outPropsSize -
LZMA Encoder will use defult values for any parameter, if it is LZMA Encoder will use defult values for any parameter, if it is
-1 for any from: level, loc, lp, pb, fb, numThreads -1 for any from: level, loc, lp, pb, fb, numThreads
0 for dictSize 0 for dictSize
level - compression level: 0 <= level <= 9; level - compression level: 0 <= level <= 9;
level dictSize algo fb level dictSize algo fb
@ -50,7 +50,7 @@ level - compression level: 0 <= level <= 9;
5: 16 MB 1 32 5: 16 MB 1 32
6: 32 MB 1 32 6: 32 MB 1 32
7+: 64 MB 1 64 7+: 64 MB 1 64
The default value for "level" is 5. The default value for "level" is 5.
algo = 0 means fast method algo = 0 means fast method

View File

@ -190,9 +190,9 @@ static SRes MtThread_Process(CMtThread *p, Bool *stop)
*stop = True; *stop = True;
if (Event_Wait(&p->canRead) != 0) if (Event_Wait(&p->canRead) != 0)
return SZ_ERROR_THREAD; return SZ_ERROR_THREAD;
next = GET_NEXT_THREAD(p); next = GET_NEXT_THREAD(p);
if (p->stopReading) if (p->stopReading)
{ {
next->stopReading = True; next->stopReading = True;

View File

@ -14,7 +14,7 @@ typedef struct
CAutoResetEvent startEvent; CAutoResetEvent startEvent;
CAutoResetEvent finishedEvent; CAutoResetEvent finishedEvent;
int stop; int stop;
THREAD_FUNC_TYPE func; THREAD_FUNC_TYPE func;
LPVOID param; LPVOID param;
THREAD_FUNC_RET_TYPE res; THREAD_FUNC_RET_TYPE res;
@ -75,7 +75,7 @@ typedef struct _CMtCoder
size_t blockSize; size_t blockSize;
size_t destBlockSize; size_t destBlockSize;
unsigned numThreads; unsigned numThreads;
ISeqInStream *inStream; ISeqInStream *inStream;
ISeqOutStream *outStream; ISeqOutStream *outStream;
ICompressProgress *progress; ICompressProgress *progress;

View File

@ -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; }} 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 EXTERN_C_END
#endif #endif

View File

@ -148,7 +148,7 @@ static void GlueFreeBlocks(CPpmd7 *p)
#else #else
CPpmd7_Node_Ref head = p->AlignOffset + p->Size; CPpmd7_Node_Ref head = p->AlignOffset + p->Size;
#endif #endif
CPpmd7_Node_Ref n = head; CPpmd7_Node_Ref n = head;
unsigned i; unsigned i;
@ -175,7 +175,7 @@ static void GlueFreeBlocks(CPpmd7 *p)
NODE(n)->Prev = head; NODE(n)->Prev = head;
if (p->LoUnit != p->HiUnit) if (p->LoUnit != p->HiUnit)
((CPpmd7_Node *)p->LoUnit)->Stamp = 1; ((CPpmd7_Node *)p->LoUnit)->Stamp = 1;
/* Glue free blocks */ /* Glue free blocks */
while (n != head) while (n != head)
{ {
@ -193,7 +193,7 @@ static void GlueFreeBlocks(CPpmd7 *p)
} }
n = node->Next; n = node->Next;
} }
/* Fill lists of free blocks */ /* Fill lists of free blocks */
for (n = NODE(head)->Next; n != head;) for (n = NODE(head)->Next; n != head;)
{ {
@ -319,7 +319,7 @@ static void RestartModel(CPpmd7 *p)
for (m = 0; m < 64; m += 8) for (m = 0; m < 64; m += 8)
dest[m] = val; dest[m] = val;
} }
for (i = 0; i < 25; i++) for (i = 0; i < 25; i++)
for (k = 0; k < 16; k++) 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_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState);
CPpmd_State *ps[PPMD7_MAX_ORDER]; CPpmd_State *ps[PPMD7_MAX_ORDER];
unsigned numPs = 0; unsigned numPs = 0;
if (!skip) if (!skip)
ps[numPs++] = p->FoundState; ps[numPs++] = p->FoundState;
while (c->Suffix) while (c->Suffix)
{ {
CPpmd_Void_Ref successor; CPpmd_Void_Ref successor;
@ -370,10 +370,10 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)
} }
ps[numPs++] = s; ps[numPs++] = s;
} }
upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch); upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch);
SetSuccessor(&upState, upBranch + 1); SetSuccessor(&upState, upBranch + 1);
if (c->NumStats == 1) if (c->NumStats == 1)
upState.Freq = ONE_STATE(c)->Freq; upState.Freq = ONE_STATE(c)->Freq;
else else
@ -407,7 +407,7 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)
c = c1; c = c1;
} }
while (numPs != 0); while (numPs != 0);
return c; return c;
} }
@ -423,11 +423,11 @@ static void UpdateModel(CPpmd7 *p)
CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState); CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState);
CTX_PTR c; CTX_PTR c;
unsigned s0, ns; unsigned s0, ns;
if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0)
{ {
c = SUFFIX(p->MinContext); c = SUFFIX(p->MinContext);
if (c->NumStats == 1) if (c->NumStats == 1)
{ {
CPpmd_State *s = ONE_STATE(c); CPpmd_State *s = ONE_STATE(c);
@ -465,7 +465,7 @@ static void UpdateModel(CPpmd7 *p)
SetSuccessor(p->FoundState, REF(p->MinContext)); SetSuccessor(p->FoundState, REF(p->MinContext));
return; return;
} }
*p->Text++ = p->FoundState->Symbol; *p->Text++ = p->FoundState->Symbol;
successor = REF(p->Text); successor = REF(p->Text);
if (p->Text >= p->UnitsStart) if (p->Text >= p->UnitsStart)
@ -473,7 +473,7 @@ static void UpdateModel(CPpmd7 *p)
RestartModel(p); RestartModel(p);
return; return;
} }
if (fSuccessor) if (fSuccessor)
{ {
if (fSuccessor <= successor) if (fSuccessor <= successor)
@ -497,9 +497,9 @@ static void UpdateModel(CPpmd7 *p)
SetSuccessor(p->FoundState, successor); SetSuccessor(p->FoundState, successor);
fSuccessor = REF(p->MinContext); fSuccessor = REF(p->MinContext);
} }
s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1); s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1);
for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c)) for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c))
{ {
unsigned ns1; unsigned ns1;
@ -566,7 +566,7 @@ static void UpdateModel(CPpmd7 *p)
} }
p->MaxContext = p->MinContext = CTX(fSuccessor); p->MaxContext = p->MinContext = CTX(fSuccessor);
} }
static void Rescale(CPpmd7 *p) static void Rescale(CPpmd7 *p)
{ {
unsigned i, adder, sumFreq, escFreq; unsigned i, adder, sumFreq, escFreq;
@ -583,7 +583,7 @@ static void Rescale(CPpmd7 *p)
adder = (p->OrderFall != 0); adder = (p->OrderFall != 0);
s->Freq = (Byte)((s->Freq + adder) >> 1); s->Freq = (Byte)((s->Freq + adder) >> 1);
sumFreq = s->Freq; sumFreq = s->Freq;
i = p->MinContext->NumStats - 1; i = p->MinContext->NumStats - 1;
do do
{ {
@ -601,7 +601,7 @@ static void Rescale(CPpmd7 *p)
} }
} }
while (--i); while (--i);
if (s->Freq == 0) if (s->Freq == 0)
{ {
unsigned numStats = p->MinContext->NumStats; unsigned numStats = p->MinContext->NumStats;

View File

@ -136,5 +136,5 @@ void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p);
void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);
EXTERN_C_END EXTERN_C_END
#endif #endif

View File

@ -160,11 +160,11 @@ int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc)
i -= k; i -= k;
} }
while (i != num); while (i != num);
see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum); see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum);
freqSum += hiCnt; freqSum += hiCnt;
count = rc->GetThreshold(rc, freqSum); count = rc->GetThreshold(rc, freqSum);
if (count < hiCnt) if (count < hiCnt)
{ {
Byte symbol; Byte symbol;

View File

@ -104,7 +104,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol)
sum += s->Freq; sum += s->Freq;
} }
while (--i); while (--i);
p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]; p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];
PPMD_SetAllBitsIn256Bytes(charMask); PPMD_SetAllBitsIn256Bytes(charMask);
MASK(s->Symbol) = 0; 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); p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);
} }
while (p->MinContext->NumStats == numMasked); while (p->MinContext->NumStats == numMasked);
see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq); see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq);
s = Ppmd7_GetStats(p, p->MinContext); s = Ppmd7_GetStats(p, p->MinContext);
sum = 0; sum = 0;
@ -178,7 +178,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol)
s++; s++;
} }
while (--i); while (--i);
RangeEnc_Encode(rc, sum, escFreq, sum + escFreq); RangeEnc_Encode(rc, sum, escFreq, sum + escFreq);
see->Summ = (UInt16)(see->Summ + sum + escFreq); see->Summ = (UInt16)(see->Summ + sum + escFreq);
} }

View File

@ -146,7 +146,7 @@ static void GlueFreeBlocks(CPpmd8 *p)
p->GlueCount = 1 << 13; p->GlueCount = 1 << 13;
memset(p->Stamps, 0, sizeof(p->Stamps)); 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. /* 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. */ All blocks up to p->LoUnit can be free, so we need guard NODE at LoUnit. */
if (p->LoUnit != p->HiUnit) if (p->LoUnit != p->HiUnit)
@ -175,7 +175,7 @@ static void GlueFreeBlocks(CPpmd8 *p)
} }
} }
*prev = 0; *prev = 0;
/* Fill lists of free blocks */ /* Fill lists of free blocks */
while (head != 0) while (head != 0)
{ {
@ -298,7 +298,7 @@ static void ExpandTextArea(CPpmd8 *p)
memset(count, 0, sizeof(count)); memset(count, 0, sizeof(count));
if (p->LoUnit != p->HiUnit) if (p->LoUnit != p->HiUnit)
((CPpmd8_Node *)p->LoUnit)->Stamp = 0; ((CPpmd8_Node *)p->LoUnit)->Stamp = 0;
{ {
CPpmd8_Node *node = (CPpmd8_Node *)p->UnitsStart; CPpmd8_Node *node = (CPpmd8_Node *)p->UnitsStart;
for (; node->Stamp == EMPTY_NODE; node += node->NU) for (; node->Stamp == EMPTY_NODE; node += node->NU)
@ -308,7 +308,7 @@ static void ExpandTextArea(CPpmd8 *p)
} }
p->UnitsStart = (Byte *)node; p->UnitsStart = (Byte *)node;
} }
for (i = 0; i < PPMD_NUM_INDEXES; i++) for (i = 0; i < PPMD_NUM_INDEXES; i++)
{ {
CPpmd8_Node_Ref *next = (CPpmd8_Node_Ref *)&p->FreeList[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; int i;
unsigned tmp; unsigned tmp;
CPpmd_State *s; CPpmd_State *s;
if (!ctx->NumStats) if (!ctx->NumStats)
{ {
s = ONE_STATE(ctx); 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)); SetSuccessor(s, CutOff(p, CTX(SUCCESSOR(s)), order + 1));
else else
SetSuccessor(s, 0); SetSuccessor(s, 0);
if (i != ctx->NumStats && order) if (i != ctx->NumStats && order)
{ {
ctx->NumStats = (Byte)i; 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)); SetSuccessor(s, RemoveBinContexts(p, CTX(SUCCESSOR(s)), order + 1));
else else
SetSuccessor(s, 0); SetSuccessor(s, 0);
return REF(ctx); return REF(ctx);
} }
#endif #endif
@ -561,7 +561,7 @@ static void RestoreModel(CPpmd8 *p, CTX_PTR c1
} }
else else
Refresh(p, c, (c->NumStats+3) >> 1, 0); Refresh(p, c, (c->NumStats+3) >> 1, 0);
for (; c != p->MinContext; c = SUFFIX(c)) for (; c != p->MinContext; c = SUFFIX(c))
if (!c->NumStats) if (!c->NumStats)
ONE_STATE(c)->Freq -= ONE_STATE(c)->Freq >> 1; 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. */ /* fixed over Shkarin's code. Maybe it could work without + 1 too. */
CPpmd_State *ps[PPMD8_MAX_ORDER + 1]; CPpmd_State *ps[PPMD8_MAX_ORDER + 1];
unsigned numPs = 0; unsigned numPs = 0;
if (!skip) if (!skip)
ps[numPs++] = p->FoundState; ps[numPs++] = p->FoundState;
while (c->Suffix) while (c->Suffix)
{ {
CPpmd_Void_Ref successor; 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; ps[numPs++] = s;
} }
upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch); upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch);
SetSuccessor(&upState, upBranch + 1); SetSuccessor(&upState, upBranch + 1);
flags = 0x10 * (p->FoundState->Symbol >= 0x40) + 0x08 * (upState.Symbol >= 0x40); 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; c = c1;
} }
while (numPs != 0); while (numPs != 0);
return c; return c;
} }
@ -696,7 +696,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
CPpmd_State *s = NULL; CPpmd_State *s = NULL;
CTX_PTR c1 = c; CTX_PTR c1 = c;
CPpmd_Void_Ref upBranch = REF(p->Text); CPpmd_Void_Ref upBranch = REF(p->Text);
#ifdef PPMD8_FREEZE_SUPPORT #ifdef PPMD8_FREEZE_SUPPORT
/* The BUG in Shkarin's code was fixed: ps could overflow in CUT_OFF mode. */ /* The BUG in Shkarin's code was fixed: ps could overflow in CUT_OFF mode. */
CPpmd_State *ps[PPMD8_MAX_ORDER + 1]; 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); SetSuccessor(s, upBranch);
p->OrderFall++; p->OrderFall++;
} }
#ifdef PPMD8_FREEZE_SUPPORT #ifdef PPMD8_FREEZE_SUPPORT
if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE) 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)); SetSuccessor(s, REF(successor));
p->FoundState = s1; p->FoundState = s1;
} }
if (p->OrderFall == 1 && c1 == p->MaxContext) if (p->OrderFall == 1 && c1 == p->MaxContext)
{ {
SetSuccessor(p->FoundState, SUCCESSOR(s)); SetSuccessor(p->FoundState, SUCCESSOR(s));
@ -797,11 +797,11 @@ static void UpdateModel(CPpmd8 *p)
unsigned s0, ns, fFreq = p->FoundState->Freq; unsigned s0, ns, fFreq = p->FoundState->Freq;
Byte flag, fSymbol = p->FoundState->Symbol; Byte flag, fSymbol = p->FoundState->Symbol;
CPpmd_State *s = NULL; CPpmd_State *s = NULL;
if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0)
{ {
c = SUFFIX(p->MinContext); c = SUFFIX(p->MinContext);
if (c->NumStats == 0) if (c->NumStats == 0)
{ {
s = ONE_STATE(c); s = ONE_STATE(c);
@ -827,7 +827,7 @@ static void UpdateModel(CPpmd8 *p)
} }
} }
} }
c = p->MaxContext; c = p->MaxContext;
if (p->OrderFall == 0 && fSuccessor) if (p->OrderFall == 0 && fSuccessor)
{ {
@ -844,7 +844,7 @@ static void UpdateModel(CPpmd8 *p)
} }
return; return;
} }
*p->Text++ = p->FoundState->Symbol; *p->Text++ = p->FoundState->Symbol;
successor = REF(p->Text); successor = REF(p->Text);
if (p->Text >= p->UnitsStart) if (p->Text >= p->UnitsStart)
@ -852,7 +852,7 @@ static void UpdateModel(CPpmd8 *p)
RESTORE_MODEL(c, CTX(fSuccessor)); /* check it */ RESTORE_MODEL(c, CTX(fSuccessor)); /* check it */
return; return;
} }
if (!fSuccessor) if (!fSuccessor)
{ {
CTX_PTR cs = ReduceOrder(p, s, p->MinContext); CTX_PTR cs = ReduceOrder(p, s, p->MinContext);
@ -873,7 +873,7 @@ static void UpdateModel(CPpmd8 *p)
} }
fSuccessor = REF(cs); fSuccessor = REF(cs);
} }
if (--p->OrderFall == 0) if (--p->OrderFall == 0)
{ {
successor = fSuccessor; successor = fSuccessor;
@ -887,10 +887,10 @@ static void UpdateModel(CPpmd8 *p)
p->OrderFall = 0; p->OrderFall = 0;
} }
#endif #endif
s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq; s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq;
flag = 0x08 * (fSymbol >= 0x40); flag = 0x08 * (fSymbol >= 0x40);
for (; c != p->MinContext; c = SUFFIX(c)) for (; c != p->MinContext; c = SUFFIX(c))
{ {
unsigned ns1; unsigned ns1;
@ -958,7 +958,7 @@ static void UpdateModel(CPpmd8 *p)
} }
p->MaxContext = p->MinContext = CTX(fSuccessor); p->MaxContext = p->MinContext = CTX(fSuccessor);
} }
static void Rescale(CPpmd8 *p) static void Rescale(CPpmd8 *p)
{ {
unsigned i, adder, sumFreq, escFreq; unsigned i, adder, sumFreq, escFreq;
@ -979,7 +979,7 @@ static void Rescale(CPpmd8 *p)
); );
s->Freq = (Byte)((s->Freq + adder) >> 1); s->Freq = (Byte)((s->Freq + adder) >> 1);
sumFreq = s->Freq; sumFreq = s->Freq;
i = p->MinContext->NumStats; i = p->MinContext->NumStats;
do do
{ {
@ -997,7 +997,7 @@ static void Rescale(CPpmd8 *p)
} }
} }
while (--i); while (--i);
if (s->Freq == 0) if (s->Freq == 0)
{ {
unsigned numStats = p->MinContext->NumStats; unsigned numStats = p->MinContext->NumStats;

View File

@ -133,5 +133,5 @@ void Ppmd8_RangeEnc_FlushData(CPpmd8 *p);
void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */
EXTERN_C_END EXTERN_C_END
#endif #endif

View File

@ -128,11 +128,11 @@ int Ppmd8_DecodeSymbol(CPpmd8 *p)
i -= k; i -= k;
} }
while (i != num); while (i != num);
see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum); see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum);
freqSum += hiCnt; freqSum += hiCnt;
count = RangeDec_GetThreshold(p, freqSum); count = RangeDec_GetThreshold(p, freqSum);
if (count < hiCnt) if (count < hiCnt)
{ {
Byte symbol; Byte symbol;

View File

@ -81,7 +81,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
sum += s->Freq; sum += s->Freq;
} }
while (--i); while (--i);
PPMD_SetAllBitsIn256Bytes(charMask); PPMD_SetAllBitsIn256Bytes(charMask);
MASK(s->Symbol) = 0; MASK(s->Symbol) = 0;
i = p->MinContext->NumStats; i = p->MinContext->NumStats;
@ -125,7 +125,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix); p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix);
} }
while (p->MinContext->NumStats == numMasked); while (p->MinContext->NumStats == numMasked);
see = Ppmd8_MakeEscFreq(p, numMasked, &escFreq); see = Ppmd8_MakeEscFreq(p, numMasked, &escFreq);
s = Ppmd8_GetStats(p, p->MinContext); s = Ppmd8_GetStats(p, p->MinContext);
sum = 0; sum = 0;
@ -154,7 +154,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
s++; s++;
} }
while (--i); while (--i);
RangeEnc_Encode(p, sum, escFreq, sum + escFreq); RangeEnc_Encode(p, sum, escFreq, sum + escFreq);
see->Summ = (UInt16)(see->Summ + sum + escFreq); see->Summ = (UInt16)(see->Summ + sum + escFreq);
} }

View File

@ -133,7 +133,7 @@ static void Sha256_Transform(UInt32 *state, const UInt32 *data)
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
state[j] += T[j]; state[j] += T[j];
#endif #endif
/* Wipe variables */ /* Wipe variables */
/* memset(W, 0, sizeof(W)); */ /* memset(W, 0, sizeof(W)); */
/* memset(T, 0, sizeof(T)); */ /* memset(T, 0, sizeof(T)); */

View File

@ -199,7 +199,7 @@ typedef struct
unsigned indexPreSize; unsigned indexPreSize;
CXzStreamFlags streamFlags; CXzStreamFlags streamFlags;
UInt32 blockHeaderSize; UInt32 blockHeaderSize;
UInt64 packSize; UInt64 packSize;
UInt64 unpackSize; UInt64 unpackSize;

View File

@ -421,7 +421,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
const Byte *srcCur; const Byte *srcCur;
int srcFinishedCur; int srcFinishedCur;
int encodingWasFinished; int encodingWasFinished;
if (i == 0) if (i == 0)
{ {
srcCur = src; srcCur = src;
@ -434,7 +434,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
srcLenCur = p->size[i - 1] - p->pos[i - 1]; srcLenCur = p->size[i - 1] - p->pos[i - 1];
srcFinishedCur = p->finished[i - 1]; srcFinishedCur = p->finished[i - 1];
} }
if (i == p->numCoders - 1) if (i == p->numCoders - 1)
{ {
destCur = dest; destCur = dest;
@ -447,7 +447,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
destCur = p->buf + (CODER_BUF_SIZE * i); destCur = p->buf + (CODER_BUF_SIZE * i);
destLenCur = CODER_BUF_SIZE; destLenCur = CODER_BUF_SIZE;
} }
res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, &encodingWasFinished); res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, &encodingWasFinished);
if (!encodingWasFinished) if (!encodingWasFinished)
@ -474,7 +474,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
p->pos[i] = 0; p->pos[i] = 0;
p->finished[i] = encodingWasFinished; p->finished[i] = encodingWasFinished;
} }
if (res != SZ_OK) if (res != SZ_OK)
return res; return res;
@ -637,20 +637,20 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
*status = CODER_STATUS_NOT_FINISHED; *status = CODER_STATUS_NOT_FINISHED;
return SZ_OK; return SZ_OK;
} }
res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status); res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status);
XzCheck_Update(&p->check, dest, destLen2); XzCheck_Update(&p->check, dest, destLen2);
(*srcLen) += srcLen2; (*srcLen) += srcLen2;
src += srcLen2; src += srcLen2;
p->packSize += srcLen2; p->packSize += srcLen2;
(*destLen) += destLen2; (*destLen) += destLen2;
dest += destLen2; dest += destLen2;
p->unpackSize += destLen2; p->unpackSize += destLen2;
RINOK(res); RINOK(res);
if (*status == CODER_STATUS_FINISHED_WITH_MARK) if (*status == CODER_STATUS_FINISHED_WITH_MARK)
{ {
Byte temp[32]; Byte temp[32];
@ -659,14 +659,14 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
Sha256_Update(&p->sha, temp, num); Sha256_Update(&p->sha, temp, num);
p->indexSize += num; p->indexSize += num;
p->numBlocks++; p->numBlocks++;
p->state = XZ_STATE_BLOCK_FOOTER; p->state = XZ_STATE_BLOCK_FOOTER;
p->pos = 0; p->pos = 0;
p->alignPos = 0; p->alignPos = 0;
} }
else if (srcLen2 == 0 && destLen2 == 0) else if (srcLen2 == 0 && destLen2 == 0)
return SZ_OK; return SZ_OK;
continue; continue;
} }
@ -872,7 +872,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
} }
break; break;
} }
case XZ_STATE_BLOCK: break; /* to disable GCC warning */ case XZ_STATE_BLOCK: break; /* to disable GCC warning */
} }
} }

View File

@ -409,10 +409,10 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
int filterIndex = 0; int filterIndex = 0;
CXzFilter *filter = NULL; CXzFilter *filter = NULL;
const CXzFilterProps *fp = props->filterProps; const CXzFilterProps *fp = props->filterProps;
XzBlock_ClearFlags(&block); XzBlock_ClearFlags(&block);
XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0)); XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0));
if (fp) if (fp)
{ {
filter = &block.filters[filterIndex++]; filter = &block.filters[filterIndex++];
@ -440,13 +440,13 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
seqSizeOutStream.p.Write = MyWrite; seqSizeOutStream.p.Write = MyWrite;
seqSizeOutStream.realStream = outStream; seqSizeOutStream.realStream = outStream;
seqSizeOutStream.processed = 0; seqSizeOutStream.processed = 0;
RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.p)); RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.p));
checkInStream.p.Read = SeqCheckInStream_Read; checkInStream.p.Read = SeqCheckInStream_Read;
checkInStream.realStream = inStream; checkInStream.realStream = inStream;
SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags)); SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags));
if (fp) if (fp)
{ {
#ifdef USE_SUBBLOCK #ifdef USE_SUBBLOCK

View File

@ -88,7 +88,7 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *
if (numBlocks != numBlocks64 || numBlocks * 2 > size) if (numBlocks != numBlocks64 || numBlocks * 2 > size)
return SZ_ERROR_ARCHIVE; return SZ_ERROR_ARCHIVE;
} }
crcStartPos = pos; crcStartPos = pos;
Xz_Free(p, alloc); Xz_Free(p, alloc);
if (numBlocks != 0) if (numBlocks != 0)
@ -149,7 +149,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff
RINOK(SeekFromCur(stream, startOffset)); RINOK(SeekFromCur(stream, startOffset));
RINOK(LookInStream_Read2(stream, buf, XZ_STREAM_FOOTER_SIZE, SZ_ERROR_NO_ARCHIVE)); 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) if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
{ {
UInt32 total = 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) if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
return SZ_ERROR_NO_ARCHIVE; return SZ_ERROR_NO_ARCHIVE;
} }
p->flags = (CXzStreamFlags)GetBe16(buf + 8); p->flags = (CXzStreamFlags)GetBe16(buf + 8);
if (!XzFlags_IsSupported(p->flags)) if (!XzFlags_IsSupported(p->flags))

View File

@ -120,12 +120,12 @@ WRes File_Read(CSzFile *p, void *data, size_t *size)
return 0; return 0;
#else #else
*size = fread(data, 1, originalSize, p->file); *size = fread(data, 1, originalSize, p->file);
if (*size == originalSize) if (*size == originalSize)
return 0; return 0;
return ferror(p->file); return ferror(p->file);
#endif #endif
} }
@ -134,7 +134,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
size_t originalSize = *size; size_t originalSize = *size;
if (originalSize == 0) if (originalSize == 0)
return 0; return 0;
#ifdef USE_WINDOWS_FILE #ifdef USE_WINDOWS_FILE
*size = 0; *size = 0;
@ -160,7 +160,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
if (*size == originalSize) if (*size == originalSize)
return 0; return 0;
return ferror(p->file); return ferror(p->file);
#endif #endif
} }
@ -190,7 +190,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
return 0; return 0;
#else #else
int moveMethod; int moveMethod;
int res; int res;
switch (origin) switch (origin)
@ -203,14 +203,14 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
res = fseek(p->file, (long)*pos, moveMethod); res = fseek(p->file, (long)*pos, moveMethod);
*pos = ftell(p->file); *pos = ftell(p->file);
return res; return res;
#endif #endif
} }
WRes File_GetLength(CSzFile *p, UInt64 *length) WRes File_GetLength(CSzFile *p, UInt64 *length)
{ {
#ifdef USE_WINDOWS_FILE #ifdef USE_WINDOWS_FILE
DWORD sizeHigh; DWORD sizeHigh;
DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); DWORD sizeLow = GetFileSize(p->handle, &sizeHigh);
if (sizeLow == 0xFFFFFFFF) if (sizeLow == 0xFFFFFFFF)
@ -221,15 +221,15 @@ WRes File_GetLength(CSzFile *p, UInt64 *length)
} }
*length = (((UInt64)sizeHigh) << 32) + sizeLow; *length = (((UInt64)sizeHigh) << 32) + sizeLow;
return 0; return 0;
#else #else
long pos = ftell(p->file); long pos = ftell(p->file);
int res = fseek(p->file, 0, SEEK_END); int res = fseek(p->file, 0, SEEK_END);
*length = ftell(p->file); *length = ftell(p->file);
fseek(p->file, pos, SEEK_SET); fseek(p->file, pos, SEEK_SET);
return res; return res;
#endif #endif
} }

View File

@ -60,8 +60,8 @@
+02 = samples (2 bytes) - number of samples per audio stream +02 = samples (2 bytes) - number of samples per audio stream
+04 = width (2 bytes) - width of video data +04 = width (2 bytes) - width of video data
+06 = height (2 bytes) - height of video data +06 = height (2 bytes) - height of video data
+08 = audio huffman size (2 bytes) - size of audio huffman tables +08 = audio huffman size (2 bytes) - size of audio huffman tables
(0x0000 => uncompressed deltas are used) (0x0000 => uncompressed deltas are used)
+0A = str0size (2 bytes) - compressed size of stream 0 +0A = str0size (2 bytes) - compressed size of stream 0
+0C = str1size (2 bytes) - compressed size of stream 1 +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 // 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.width() & 0xff;
*dest++ = bitmap.height() >> 8; *dest++ = bitmap.height() >> 8;
*dest++ = bitmap.height() & 0xff; *dest++ = bitmap.height() & 0xff;
// copy the metadata // copy the metadata
if (metadatasize > 0) if (metadatasize > 0)
memcpy(dest, metadata, metadatasize); memcpy(dest, metadata, metadatasize);
dest += metadatasize; dest += metadatasize;
// copy the audio streams // copy the audio streams
for (UINT8 curchan = 0; curchan < channels; curchan++) for (UINT8 curchan = 0; curchan < channels; curchan++)
for (UINT32 cursamp = 0; cursamp < numsamples; cursamp++) 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] >> 8;
*dest++ = samples[curchan][cursamp] & 0xff; *dest++ = samples[curchan][cursamp] & 0xff;
} }
// copy the video data // copy the video data
for (INT32 y = 0; y < bitmap.height(); y++) 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 // destination
//------------------------------------------------- //-------------------------------------------------
@ -384,20 +384,20 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
UINT16 be_test = 0; UINT16 be_test = 0;
*(UINT8 *)&be_test = 1; *(UINT8 *)&be_test = 1;
bool swap_endian = (be_test == 1); bool swap_endian = (be_test == 1);
// set huffman tree size to 0xffff to indicate FLAC // set huffman tree size to 0xffff to indicate FLAC
sizes[0] = 0xff; sizes[0] = 0xff;
sizes[1] = 0xff; sizes[1] = 0xff;
// set the block size for this round and iterate over channels // set the block size for this round and iterate over channels
m_flac_encoder.set_block_size(samples); m_flac_encoder.set_block_size(samples);
for (int chnum = 0; chnum < channels; chnum++) for (int chnum = 0; chnum < channels; chnum++)
{ {
// encode the data // encode the data
m_flac_encoder.reset(dest, samples * 2); m_flac_encoder.reset(dest, samples * 2);
if (!m_flac_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(source) + chnum * samples, samples, swap_endian)) if (!m_flac_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(source) + chnum * samples, samples, swap_endian))
return AVHERR_COMPRESSION_ERROR; return AVHERR_COMPRESSION_ERROR;
// set the size for this channel // set the size for this channel
UINT32 cursize = m_flac_encoder.finish(); UINT32 cursize = m_flac_encoder.finish();
sizes[chnum * 2 + 2] = cursize >> 8; 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 // 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 // set up the output; first byte is 0x80 to indicate lossless encoding
bitstream_out bitbuf(dest, width * height * 2); bitstream_out bitbuf(dest, width * height * 2);
bitbuf.write(0x80, 8); bitbuf.write(0x80, 8);
// compute the histograms for the data // compute the histograms for the data
UINT16 *yrle = m_ycontext.rle_and_histo_bitmap(source + 0, width, 2, height); 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); 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 // 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 // fetch current data
UINT8 curdelta = *source - prevdata; UINT8 curdelta = *source - prevdata;
prevdata = *source; prevdata = *source;
// 0 deltas scan forward for a count // 0 deltas scan forward for a count
if (curdelta == 0) if (curdelta == 0)
{ {
int zerocount = 1; int zerocount = 1;
// count the number of consecutive values // count the number of consecutive values
const UINT8 *scandata; const UINT8 *scandata;
for (scandata = source + item_advance; scandata < end; scandata += item_advance) 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++; zerocount++;
else else
break; break;
// if we hit the end of a row, maximize the count // if we hit the end of a row, maximize the count
if (scandata >= end && zerocount >= 8) if (scandata >= end && zerocount >= 8)
zerocount = 100000; zerocount = 100000;
@ -609,16 +609,16 @@ UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *sour
// advance past the run // advance past the run
source += (code_to_rlecount(rlecode) - 1) * item_advance; source += (code_to_rlecount(rlecode) - 1) * item_advance;
} }
// otherwise, encode the actual data // otherwise, encode the actual data
else else
m_encoder.histo_one(*dest++ = curdelta); m_encoder.histo_one(*dest++ = curdelta);
} }
// advance to the next row // advance to the next row
source = end; source = end;
} }
// compute the tree for our histogram // compute the tree for our histogram
m_encoder.compute_tree_from_histo(); m_encoder.compute_tree_from_histo();
return m_rlebuffer; 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 // data stream
//------------------------------------------------- //-------------------------------------------------
@ -827,7 +827,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
// finish up // finish up
m_flac_decoder.finish(); m_flac_decoder.finish();
} }
// advance to the next channel's data // advance to the next channel's data
source += size; source += size;
} }
@ -881,7 +881,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
curdest += 2; curdest += 2;
} }
} }
// otherwise, Huffman-decode the data // otherwise, Huffman-decode the data
else else
{ {
@ -902,7 +902,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
return AVHERR_INVALID_DATA; return AVHERR_INVALID_DATA;
} }
} }
// advance to the next channel's data // advance to the next channel's data
source += size; 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 // data stream
//------------------------------------------------- //-------------------------------------------------
@ -969,7 +969,7 @@ avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const
m_cbcontext.flush_rle(); m_cbcontext.flush_rle();
m_crcontext.flush_rle(); m_crcontext.flush_rle();
} }
// check for errors if we overflowed or decoded too little data // check for errors if we overflowed or decoded too little data
if (bitbuf.overflow() || bitbuf.flush() != complength) if (bitbuf.overflow() || bitbuf.flush() != complength)
return AVHERR_INVALID_DATA; return AVHERR_INVALID_DATA;

View File

@ -129,7 +129,7 @@ private:
// construction/destruction // construction/destruction
deltarle_encoder() deltarle_encoder()
: m_rlecount(0) { } : m_rlecount(0) { }
// histogramming // histogramming
UINT16 *rle_and_histo_bitmap(const UINT8 *source, UINT32 items_per_row, UINT32 item_advance, UINT32 row_count); 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(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); avhuff_error encode_video_lossless(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength);
// video encoding contexts // video encoding contexts
deltarle_encoder m_ycontext; deltarle_encoder m_ycontext;
deltarle_encoder m_cbcontext; deltarle_encoder m_cbcontext;
deltarle_encoder m_crcontext; deltarle_encoder m_crcontext;
// audio encoding contexts // audio encoding contexts
dynamic_buffer m_audiobuffer; dynamic_buffer m_audiobuffer;
@ -189,7 +189,7 @@ private:
// construction/destruction // construction/destruction
deltarle_decoder() deltarle_decoder()
: m_rlecount(0), m_prevdata(0) { } : m_rlecount(0), m_prevdata(0) { }
// general // general
void reset() { m_rlecount = m_prevdata = 0; } 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); avhuff_error decode_video_lossless(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor);
// internal state // internal state
avhuff_decompress_config m_config; avhuff_decompress_config m_config;
// video decoding contexts // video decoding contexts
deltarle_decoder m_ycontext; deltarle_decoder m_ycontext;
deltarle_decoder m_cbcontext; deltarle_decoder m_cbcontext;
deltarle_decoder m_crcontext; deltarle_decoder m_crcontext;
// audio decoding contexts // audio decoding contexts
huffman_8bit_decoder m_audiohi_decoder; huffman_8bit_decoder m_audiohi_decoder;

View File

@ -55,11 +55,11 @@ class bitstream_in
public: public:
// construction/destruction // construction/destruction
bitstream_in(const void *src, UINT32 srclength); bitstream_in(const void *src, UINT32 srclength);
// getters // getters
bool overflow() const { return ((m_doffset - m_bits / 8) > m_dlength); } bool overflow() const { return ((m_doffset - m_bits / 8) > m_dlength); }
UINT32 read_offset() const; UINT32 read_offset() const;
// operations // operations
UINT32 read(int numbits); UINT32 read(int numbits);
UINT32 peek(int numbits); UINT32 peek(int numbits);
@ -82,10 +82,10 @@ class bitstream_out
public: public:
// construction/destruction // construction/destruction
bitstream_out(void *dest, UINT32 destlength); bitstream_out(void *dest, UINT32 destlength);
// getters // getters
bool overflow() const { return (m_doffset > m_dlength); } bool overflow() const { return (m_doffset > m_dlength); }
// operations // operations
void write(UINT32 newbits, int numbits); void write(UINT32 newbits, int numbits);
UINT32 flush(); UINT32 flush();

View File

@ -380,7 +380,7 @@ UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer)
UINT32 chdsector = physical_to_chd_lba(file, lbasector, tracknum); UINT32 chdsector = physical_to_chd_lba(file, lbasector, tracknum);
if (file->cdtoc.tracks[tracknum].subsize == 0) if (file->cdtoc.tracks[tracknum].subsize == 0)
return 1; return 1;
// read the data // read the data
chd_error err = read_partial_sector(file, buffer, chdsector, tracknum, file->cdtoc.tracks[tracknum].datasize, file->cdtoc.tracks[tracknum].subsize); chd_error err = read_partial_sector(file, buffer, chdsector, tracknum, file->cdtoc.tracks[tracknum].datasize, file->cdtoc.tracks[tracknum].subsize);
return (err == CHDERR_NONE); return (err == CHDERR_NONE);

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@
Compressed Hunks of Data header format. All numbers are stored in Compressed Hunks of Data header format. All numbers are stored in
Motorola (big-endian) byte ordering. Motorola (big-endian) byte ordering.
========================================================================= =========================================================================
V1 header: V1 header:
@ -78,15 +78,15 @@
0x00000001 - set if this drive has a parent 0x00000001 - set if this drive has a parent
0x00000002 - set if this drive allows writes 0x00000002 - set if this drive allows writes
Compression types: Compression types:
CHDCOMPRESSION_NONE = 0 CHDCOMPRESSION_NONE = 0
CHDCOMPRESSION_ZLIB = 1 CHDCOMPRESSION_ZLIB = 1
V1 map format: V1 map format:
[ 0] UINT64 offset : 44; // starting offset within the file [ 0] UINT64 offset : 44; // starting offset within the file
[ 0] UINT64 length : 20; // length of data; if == hunksize, data is uncompressed [ 0] UINT64 length : 20; // length of data; if == hunksize, data is uncompressed
========================================================================= =========================================================================
V2 header: V2 header:
@ -105,9 +105,9 @@
[ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file [ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
[ 76] UINT32 seclen; // number of bytes per sector [ 76] UINT32 seclen; // number of bytes per sector
[ 80] (V2 header length) [ 80] (V2 header length)
Flags and map format are same as V1 Flags and map format are same as V1
========================================================================= =========================================================================
V3 header: V3 header:
@ -126,21 +126,21 @@
[ 80] UINT8 sha1[20]; // SHA1 checksum of raw data [ 80] UINT8 sha1[20]; // SHA1 checksum of raw data
[100] UINT8 parentsha1[20];// SHA1 checksum of parent file [100] UINT8 parentsha1[20];// SHA1 checksum of parent file
[120] (V3 header length) [120] (V3 header length)
Flags are the same as V1 Flags are the same as V1
Compression types: Compression types:
CHDCOMPRESSION_NONE = 0 CHDCOMPRESSION_NONE = 0
CHDCOMPRESSION_ZLIB = 1 CHDCOMPRESSION_ZLIB = 1
CHDCOMPRESSION_ZLIB_PLUS = 2 CHDCOMPRESSION_ZLIB_PLUS = 2
V3 map format: V3 map format:
[ 0] UINT64 offset; // starting offset within the file [ 0] UINT64 offset; // starting offset within the file
[ 8] UINT32 crc32; // 32-bit CRC of the uncompressed data [ 8] UINT32 crc32; // 32-bit CRC of the uncompressed data
[ 12] UINT16 length_lo; // lower 16 bits of length [ 12] UINT16 length_lo; // lower 16 bits of length
[ 14] UINT8 length_hi; // upper 8 bits of length [ 14] UINT8 length_hi; // upper 8 bits of length
[ 15] UINT8 flags; // flags, indicating compression info [ 15] UINT8 flags; // flags, indicating compression info
========================================================================= =========================================================================
@ -159,21 +159,21 @@
[ 68] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent [ 68] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
[ 88] UINT8 rawsha1[20]; // raw data SHA1 [ 88] UINT8 rawsha1[20]; // raw data SHA1
[108] (V4 header length) [108] (V4 header length)
Flags are the same as V1 Flags are the same as V1
Compression types: Compression types:
CHDCOMPRESSION_NONE = 0 CHDCOMPRESSION_NONE = 0
CHDCOMPRESSION_ZLIB = 1 CHDCOMPRESSION_ZLIB = 1
CHDCOMPRESSION_ZLIB_PLUS = 2 CHDCOMPRESSION_ZLIB_PLUS = 2
CHDCOMPRESSION_AV = 3 CHDCOMPRESSION_AV = 3
Map format is the same as V3 Map format is the same as V3
========================================================================= =========================================================================
V5 header: V5 header:
[ 0] char tag[8]; // 'MComprHD' [ 0] char tag[8]; // 'MComprHD'
[ 8] UINT32 length; // length of header (including tag and length fields) [ 8] UINT32 length; // length of header (including tag and length fields)
[ 12] UINT32 version; // drive format version [ 12] UINT32 version; // drive format version
@ -188,30 +188,30 @@
[104] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent [104] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
[124] (V5 header length) [124] (V5 header length)
If parentsha1 != 0, we have a parent (no need for flags) If parentsha1 != 0, we have a parent (no need for flags)
If compressors[0] == 0, we are uncompressed (including maps) If compressors[0] == 0, we are uncompressed (including maps)
V5 uncompressed map format: V5 uncompressed map format:
[ 0] UINT32 offset; // starting offset / hunk size [ 0] UINT32 offset; // starting offset / hunk size
V5 compressed map format header: V5 compressed map format header:
[ 0] UINT32 length; // length of compressed map [ 0] UINT32 length; // length of compressed map
[ 4] UINT48 datastart; // offset of first block [ 4] UINT48 datastart; // offset of first block
[ 10] UINT16 crc; // crc-16 of the map [ 10] UINT16 crc; // crc-16 of the map
[ 12] UINT8 lengthbits; // bits used to encode complength [ 12] UINT8 lengthbits; // bits used to encode complength
[ 13] UINT8 hunkbits; // bits used to encode self-refs [ 13] UINT8 hunkbits; // bits used to encode self-refs
[ 14] UINT8 parentunitbits; // bits used to encode parent unit refs [ 14] UINT8 parentunitbits; // bits used to encode parent unit refs
[ 15] UINT8 reserved; // future use [ 15] UINT8 reserved; // future use
[ 16] (compressed header length) [ 16] (compressed header length)
Each compressed map entry, once expanded, looks like: Each compressed map entry, once expanded, looks like:
[ 0] UINT8 compression; // compression type [ 0] UINT8 compression; // compression type
[ 1] UINT24 complength; // compressed length [ 1] UINT24 complength; // compressed length
[ 4] UINT48 offset; // offset [ 4] UINT48 offset; // offset
[ 10] UINT16 crc; // crc-16 of the data [ 10] UINT16 crc; // crc-16 of the data
***************************************************************************/ ***************************************************************************/
@ -222,7 +222,7 @@
// pseudo-codecs returned by hunk_info // pseudo-codecs returned by hunk_info
const chd_codec_type CHD_CODEC_SELF = 1; // copy of another hunk 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 const chd_codec_type CHD_CODEC_MINI = 3; // legacy "mini" 8-byte repeat
// core types // core types
@ -322,7 +322,7 @@ class chd_file
static const UINT32 V4_HEADER_SIZE = 108; static const UINT32 V4_HEADER_SIZE = 108;
static const UINT32 V5_HEADER_SIZE = 124; static const UINT32 V5_HEADER_SIZE = 124;
static const UINT32 MAX_HEADER_SIZE = V5_HEADER_SIZE; static const UINT32 MAX_HEADER_SIZE = V5_HEADER_SIZE;
public: public:
// construction/destruction // construction/destruction
chd_file(); chd_file();
@ -360,7 +360,7 @@ public:
// file open // file open
chd_error open(const char *filename, bool writeable = false, chd_file *parent = NULL); 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); chd_error open(core_file &file, bool writeable = false, chd_file *parent = NULL);
// file close // file close
void 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 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 delete_metadata(chd_metadata_tag metatag, UINT32 metaindex);
chd_error clone_all_metadata(chd_file &source); chd_error clone_all_metadata(chd_file &source);
// hashing helper // hashing helper
sha1_t compute_overall_sha1(sha1_t rawsha1); sha1_t compute_overall_sha1(sha1_t rawsha1);
// codec interfaces // codec interfaces
chd_error codec_configure(chd_codec_type codec, int param, void *config); chd_error codec_configure(chd_codec_type codec, int param, void *config);
// static helpers // static helpers
static const char *error_string(chd_error err); static const char *error_string(chd_error err);
private: private:
struct metadata_entry; struct metadata_entry;
struct metadata_hash; struct metadata_hash;
// inline helpers // inline helpers
UINT64 be_read(const UINT8 *base, int numbytes); UINT64 be_read(const UINT8 *base, int numbytes);
void be_write(UINT8 *base, UINT64 value, 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_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_reads; // permit reads from this CHD?
bool m_allow_writes; // permit writes to this CHD? bool m_allow_writes; // permit writes to this CHD?
// core parameters from the header // core parameters from the header
UINT32 m_version; // version of the header UINT32 m_version; // version of the header
UINT64 m_logicalbytes; // logical size of the raw CHD data in bytes 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_codec_type m_compression[4]; // array of compression types used
chd_file * m_parent; // pointer to parent file, or NULL if none chd_file * m_parent; // pointer to parent file, or NULL if none
bool m_parent_missing; // are we missing our parent? bool m_parent_missing; // are we missing our parent?
// key offsets within the header // key offsets within the header
UINT64 m_mapoffset_offset; // offset of map offset field UINT64 m_mapoffset_offset; // offset of map offset field
UINT64 m_metaoffset_offset;// offset of metaoffset field UINT64 m_metaoffset_offset;// offset of metaoffset field
UINT64 m_sha1_offset; // offset of SHA1 field UINT64 m_sha1_offset; // offset of SHA1 field
UINT64 m_rawsha1_offset; // offset of raw SHA1 field UINT64 m_rawsha1_offset; // offset of raw SHA1 field
UINT64 m_parentsha1_offset;// offset of paren SHA1 field UINT64 m_parentsha1_offset;// offset of paren SHA1 field
// map information // map information
UINT32 m_mapentrybytes; // length of each entry in a map UINT32 m_mapentrybytes; // length of each entry in a map
dynamic_buffer m_rawmap; // raw map data dynamic_buffer m_rawmap; // raw map data
@ -458,7 +458,7 @@ private:
// compression management // compression management
chd_decompressor * m_decompressor[4]; // array of decompression codecs chd_decompressor * m_decompressor[4]; // array of decompression codecs
dynamic_buffer m_compressed; // temporary buffer for compressed data dynamic_buffer m_compressed; // temporary buffer for compressed data
// caching // caching
dynamic_buffer m_cache; // single-hunk cache for partial reads/writes dynamic_buffer m_cache; // single-hunk cache for partial reads/writes
UINT32 m_cachehunk; // which hunk is in the cache? UINT32 m_cachehunk; // which hunk is in the cache?
@ -474,7 +474,7 @@ public:
// construction/destruction // construction/destruction
chd_file_compressor(); chd_file_compressor();
virtual ~chd_file_compressor(); virtual ~chd_file_compressor();
// compression management // compression management
void compress_begin(); void compress_begin();
chd_error compress_continue(double &progress, double &ratio); chd_error compress_continue(double &progress, double &ratio);
@ -482,7 +482,7 @@ public:
protected: protected:
// required override: read more data // required override: read more data
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length) = 0; virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length) = 0;
private: private:
// hash map for looking up values // hash map for looking up values
class hashmap class hashmap
@ -491,12 +491,12 @@ private:
// construction/destruction // construction/destruction
hashmap(); hashmap();
~hashmap(); ~hashmap();
// operations // operations
void reset(); void reset();
UINT64 find(crc16_t crc16, sha1_t sha1); UINT64 find(crc16_t crc16, sha1_t sha1);
void add(UINT64 itemnum, crc16_t crc16, sha1_t sha1); void add(UINT64 itemnum, crc16_t crc16, sha1_t sha1);
// constants // constants
static const UINT64 NOT_FOUND = ~UINT64(0); static const UINT64 NOT_FOUND = ~UINT64(0);
private: private:
@ -507,13 +507,13 @@ private:
UINT64 m_itemnum; // item number UINT64 m_itemnum; // item number
sha1_t m_sha1; // SHA-1 of the block sha1_t m_sha1; // SHA-1 of the block
}; };
// block of entries // block of entries
struct entry_block struct entry_block
{ {
entry_block(entry_block *prev) entry_block(entry_block *prev)
: m_next(prev), m_nextalloc(0) { } : m_next(prev), m_nextalloc(0) { }
entry_block * m_next; // next block in list entry_block * m_next; // next block in list
UINT32 m_nextalloc; // next to be allocated UINT32 m_nextalloc; // next to be allocated
entry_t m_array[16384]; // array of entries entry_t m_array[16384]; // array of entries
@ -532,7 +532,7 @@ private:
WS_QUEUED, WS_QUEUED,
WS_COMPLETE WS_COMPLETE
}; };
// a CRC-16/SHA-1 pair // a CRC-16/SHA-1 pair
struct hash_pair struct hash_pair
{ {
@ -540,7 +540,7 @@ private:
sha1_t m_sha1; // calculated SHA-1 sha1_t m_sha1; // calculated SHA-1
}; };
// a single work item // a single work item
struct work_item struct work_item
{ {
osd_work_item * m_osd; // OSD work item running on this block osd_work_item * m_osd; // OSD work item running on this block
@ -554,7 +554,7 @@ private:
chd_compressor_group *m_codecs; // codec instance chd_compressor_group *m_codecs; // codec instance
dynamic_array<hash_pair> m_hash; // array of hashes dynamic_array<hash_pair> m_hash; // array of hashes
}; };
// internal helpers // internal helpers
static void *async_walk_parent_static(void *param, int threadid); static void *async_walk_parent_static(void *param, int threadid);
void async_walk_parent(work_item &item); void async_walk_parent(work_item &item);
@ -563,15 +563,15 @@ private:
static void *async_read_static(void *param, int threadid); static void *async_read_static(void *param, int threadid);
void async_read(); void async_read();
// current compression status // current compression status
bool m_walking_parent; // are we building the parent map? bool m_walking_parent; // are we building the parent map?
UINT64 m_total_in; // total bytes in UINT64 m_total_in; // total bytes in
UINT64 m_total_out; // total bytes out UINT64 m_total_out; // total bytes out
sha1_creator m_compsha1; // running SHA-1 on raw data sha1_creator m_compsha1; // running SHA-1 on raw data
// hash lookup maps // hash lookup maps
hashmap m_parent_map; // hash map for parent hashmap m_parent_map; // hash map for parent
hashmap m_current_map; // hash map for current hashmap m_current_map; // hash map for current
// read I/O thread // read I/O thread
osd_work_queue * m_read_queue; // work queue for reading osd_work_queue * m_read_queue; // work queue for reading

View File

@ -64,7 +64,7 @@ public:
// construction/destruction // construction/destruction
chd_zlib_allocator(); chd_zlib_allocator();
~chd_zlib_allocator(); ~chd_zlib_allocator();
// installation // installation
void install(z_stream &stream); void install(z_stream &stream);
@ -150,7 +150,7 @@ public:
// core functionality // core functionality
virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest);
// helpers // helpers
static void configure_properties(CLzmaEncProps &props, chd_file &chd); static void configure_properties(CLzmaEncProps &props, chd_file &chd);
@ -346,7 +346,7 @@ class chd_avhuff_compressor : public chd_compressor
public: public:
// construction/destruction // construction/destruction
chd_avhuff_compressor(chd_file &chd, bool lossy); chd_avhuff_compressor(chd_file &chd, bool lossy);
// core functionality // core functionality
virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest);
@ -368,7 +368,7 @@ class chd_avhuff_decompressor : public chd_decompressor
public: public:
// construction/destruction // construction/destruction
chd_avhuff_decompressor(chd_file &chd, bool lossy); chd_avhuff_decompressor(chd_file &chd, bool lossy);
// core functionality // core functionality
virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen);
virtual void configure(int param, void *config); virtual void configure(int param, void *config);
@ -420,7 +420,7 @@ chd_codec::chd_codec(chd_file &file, bool lossy)
chd_codec::~chd_codec() chd_codec::~chd_codec()
{ {
} }
//------------------------------------------------- //-------------------------------------------------
// configure - configuration // configure - configuration
@ -597,7 +597,7 @@ INT8 chd_compressor_group::find_best_compressor(const UINT8 *src, UINT8 *compres
catch (...) catch (...)
{ {
} }
if (memcmp(src, m_decompressed, m_hunkbytes) != 0) if (memcmp(src, m_decompressed, m_hunkbytes) != 0)
{ {
compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, m_compress_test); compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, m_compress_test);
@ -621,13 +621,13 @@ printf(" codec%d=%d bytes \n", codecnum, compbytes);
} }
catch (...) { } catch (...) { }
} }
// if the best is none, copy it over // if the best is none, copy it over
if (compression == -1) if (compression == -1)
memcpy(compressed, src, m_hunkbytes); memcpy(compressed, src, m_hunkbytes);
return compression; 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 // codec
//------------------------------------------------- //-------------------------------------------------
@ -869,7 +869,7 @@ chd_lzma_allocator::chd_lzma_allocator()
{ {
// reset pointer list // reset pointer list
memset(m_allocptr, 0, sizeof(m_allocptr)); memset(m_allocptr, 0, sizeof(m_allocptr));
// set our pointers // set our pointers
Alloc = &chd_lzma_allocator::fast_alloc; Alloc = &chd_lzma_allocator::fast_alloc;
Free = &chd_lzma_allocator::fast_free; Free = &chd_lzma_allocator::fast_free;
@ -936,7 +936,7 @@ void chd_lzma_allocator::fast_free(void *p, void *address)
{ {
if (address == NULL) if (address == NULL)
return; return;
chd_lzma_allocator *codec = reinterpret_cast<chd_lzma_allocator *>(p); chd_lzma_allocator *codec = reinterpret_cast<chd_lzma_allocator *>(p);
// find the hunk // 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); SRes res = LzmaEnc_SetProps(encoder, &m_props);
if (res != SZ_OK) if (res != SZ_OK)
throw CHDERR_COMPRESSION_ERROR; throw CHDERR_COMPRESSION_ERROR;
// run it // run it
SizeT complen = srclen; SizeT complen = srclen;
res = LzmaEnc_MemEncode(encoder, dest, &complen, src, srclen, 0, NULL, &m_allocator, &m_allocator); 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 // configure the properties like the compressor did
CLzmaEncProps encoder_props; CLzmaEncProps encoder_props;
chd_lzma_compressor::configure_properties(encoder_props, chd); chd_lzma_compressor::configure_properties(encoder_props, chd);
// convert to decoder properties // convert to decoder properties
CLzmaProps decoder_props; CLzmaProps decoder_props;
decoder_props.lc = encoder_props.lc; decoder_props.lc = encoder_props.lc;
decoder_props.lp = encoder_props.lp; decoder_props.lp = encoder_props.lp;
decoder_props.pb = encoder_props.pb; decoder_props.pb = encoder_props.pb;
decoder_props.dicSize = encoder_props.dictSize; decoder_props.dicSize = encoder_props.dictSize;
// do memory allocations // do memory allocations
SRes res = LzmaDec_Allocate_MAME(&m_decoder, &decoder_props, &m_allocator); SRes res = LzmaDec_Allocate_MAME(&m_decoder, &decoder_props, &m_allocator);
if (res != SZ_OK) 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 // codec
//------------------------------------------------- //-------------------------------------------------
@ -1081,7 +1081,7 @@ void chd_lzma_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *
{ {
// initialize // initialize
LzmaDec_Init(&m_decoder); LzmaDec_Init(&m_decoder);
// decode // decode
SizeT consumedlen = complen; SizeT consumedlen = complen;
SizeT decodedlen = destlen; 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 // 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 // codec
//------------------------------------------------- //-------------------------------------------------
@ -1167,7 +1167,7 @@ chd_flac_compressor::chd_flac_compressor(chd_file &chd, bool lossy, bool bigendi
m_swap_endian = bigendian; m_swap_endian = bigendian;
else else
m_swap_endian = !bigendian; m_swap_endian = !bigendian;
// configure the encoder // configure the encoder
m_encoder.set_sample_rate(44100); m_encoder.set_sample_rate(44100);
m_encoder.set_num_channels(2); 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 // codec
//------------------------------------------------- //-------------------------------------------------
@ -1256,7 +1256,7 @@ chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, bool lossy)
UINT16 native_endian = 0; UINT16 native_endian = 0;
*reinterpret_cast<UINT8 *>(&native_endian) = 1; *reinterpret_cast<UINT8 *>(&native_endian) = 1;
m_swap_endian = (native_endian == 1); m_swap_endian = (native_endian == 1);
// configure the encoder // configure the encoder
m_encoder.set_sample_rate(44100); m_encoder.set_sample_rate(44100);
m_encoder.set_num_channels(2); m_encoder.set_num_channels(2);
@ -1310,7 +1310,7 @@ UINT32 chd_cd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *
// finish up // finish up
UINT32 complen = m_encoder.finish(); UINT32 complen = m_encoder.finish();
// deflate the subcode data // deflate the subcode data
m_deflater.next_in = const_cast<Bytef *>(&m_buffer[frames * CD_MAX_SECTOR_DATA]); m_deflater.next_in = const_cast<Bytef *>(&m_buffer[frames * CD_MAX_SECTOR_DATA]);
m_deflater.avail_in = frames * CD_MAX_SUBCODE_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 // codec
//------------------------------------------------- //-------------------------------------------------
@ -1410,7 +1410,7 @@ void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT
zerr = inflate(&m_inflater, Z_FINISH); zerr = inflate(&m_inflater, Z_FINISH);
if (m_inflater.total_out != frames * CD_MAX_SUBCODE_DATA) if (m_inflater.total_out != frames * CD_MAX_SUBCODE_DATA)
throw CHDERR_DECOMPRESSION_ERROR; throw CHDERR_DECOMPRESSION_ERROR;
// reassemble the data // reassemble the data
for (UINT32 framenum = 0; framenum < frames; framenum++) 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 // postinit - actual initialization of avhuff
// happens here, on the first attempt to compress // happens here, on the first attempt to compress
// or decompress data // 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 // 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 // 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 we're getting the decompression configuration, apply it now
if (param == AVHUFF_CODEC_DECOMPRESS_CONFIG) if (param == AVHUFF_CODEC_DECOMPRESS_CONFIG)
m_decoder.configure(*reinterpret_cast<avhuff_decompress_config *>(config)); m_decoder.configure(*reinterpret_cast<avhuff_decompress_config *>(config));
// anything else is invalid // anything else is invalid
else else
throw CHDERR_INVALID_PARAMETER; throw CHDERR_INVALID_PARAMETER;

View File

@ -75,7 +75,7 @@ class chd_codec
protected: protected:
// can't create these directly // can't create these directly
chd_codec(chd_file &file, bool lossy); chd_codec(chd_file &file, bool lossy);
public: public:
// allow public deletion // allow public deletion
virtual ~chd_codec(); virtual ~chd_codec();
@ -133,7 +133,7 @@ public:
// create compressors or decompressors // create compressors or decompressors
static chd_compressor *new_compressor(chd_codec_type type, chd_file &file); static chd_compressor *new_compressor(chd_codec_type type, chd_file &file);
static chd_decompressor *new_decompressor(chd_codec_type type, chd_file &file); static chd_decompressor *new_decompressor(chd_codec_type type, chd_file &file);
// utilities // utilities
static bool codec_exists(chd_codec_type type) { return (find_in_list(type) != NULL); } static bool codec_exists(chd_codec_type type) { return (find_in_list(type) != NULL); }
static const char *codec_name(chd_codec_type type); static const char *codec_name(chd_codec_type type);
@ -151,7 +151,7 @@ private:
// internal helper functions // internal helper functions
static const codec_entry *find_in_list(chd_codec_type type); static const codec_entry *find_in_list(chd_codec_type type);
template<class _CompressorClass> template<class _CompressorClass>
static chd_compressor *construct_compressor(chd_file &chd, bool lossy) { return new _CompressorClass(chd, lossy); } static chd_compressor *construct_compressor(chd_file &chd, bool lossy) { return new _CompressorClass(chd, lossy); }
@ -172,10 +172,10 @@ public:
// construction/destruction // construction/destruction
chd_compressor_group(chd_file &file, chd_codec_type compressor_list[4]); chd_compressor_group(chd_file &file, chd_codec_type compressor_list[4]);
~chd_compressor_group(); ~chd_compressor_group();
// find the best compressor // find the best compressor
INT8 find_best_compressor(const UINT8 *src, UINT8 *compressed, UINT32 &complen); INT8 find_best_compressor(const UINT8 *src, UINT8 *compressed, UINT32 &complen);
private: private:
// internal state // internal state
UINT32 m_hunkbytes; // number of bytes in a hunk 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_NONE = 0;
const chd_codec_type CHD_CODEC_ZLIB = CHD_MAKE_TAG('z','l','i','b'); 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_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_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_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_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_CD_FLAC = CHD_MAKE_TAG('c','d','f','l');
const chd_codec_type CHD_CODEC_AVHUFF = CHD_MAKE_TAG('a','v','h','u'); const chd_codec_type CHD_CODEC_AVHUFF = CHD_MAKE_TAG('a','v','h','u');
// A/V codec configuration parameters // A/V codec configuration parameters

View File

@ -59,7 +59,7 @@ private:
public: public:
// construction/destruction // construction/destruction
dynamic_array(int initial = 0) dynamic_array(int initial = 0)
: m_array(NULL), : m_array(NULL),
m_count(0), m_count(0),
m_allocated(0) { if (initial != 0) expand_internal(initial); m_count = initial; } m_allocated(0) { if (initial != 0) expand_internal(initial); m_count = initial; }
@ -73,7 +73,7 @@ public:
// simple getters // simple getters
int count() const { return m_count; } int count() const { return m_count; }
// helpers // 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 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; } void reset() { delete[] m_array; m_array = NULL; m_count = m_allocated = 0; }

View File

@ -82,7 +82,7 @@ flac_encoder::~flac_encoder()
//------------------------------------------------- //-------------------------------------------------
// reset - reset state with the original // reset - reset state with the original
// parameters // parameters
//------------------------------------------------- //-------------------------------------------------
@ -96,7 +96,7 @@ bool flac_encoder::reset()
// configure the encoder in a standard way // configure the encoder in a standard way
// note we do this on each reset; if we don't, results are NOT consistent! // 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_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_compression_level(m_encoder, 8);
FLAC__stream_encoder_set_channels(m_encoder, m_channels); FLAC__stream_encoder_set_channels(m_encoder, m_channels);
FLAC__stream_encoder_set_bits_per_sample(m_encoder, 16); 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 (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++)
for (int channel = 0; channel < num_channels; channel++, srcindex++) for (int channel = 0; channel < num_channels; channel++, srcindex++)
*dest++ = INT16((UINT16(samples[srcindex]) << shift) | (UINT16(samples[srcindex]) >> shift)); *dest++ = INT16((UINT16(samples[srcindex]) << shift) | (UINT16(samples[srcindex]) >> shift));
// process this batch // process this batch
if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples)) if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples))
return false; 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 (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++, srcindex++)
for (int channel = 0; channel < num_channels; channel++) for (int channel = 0; channel < num_channels; channel++)
*dest++ = INT16((UINT16(samples[channel][srcindex]) << shift) | (UINT16(samples[channel][srcindex]) >> shift)); *dest++ = INT16((UINT16(samples[channel][srcindex]) << shift) | (UINT16(samples[channel][srcindex]) >> shift));
// process this batch // process this batch
if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples)) if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples))
return false; 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 // stream
//------------------------------------------------- //-------------------------------------------------
@ -227,7 +227,7 @@ void flac_encoder::init_common()
m_encoder = FLAC__stream_encoder_new(); m_encoder = FLAC__stream_encoder_new();
if (m_encoder == NULL) if (m_encoder == NULL)
throw std::bad_alloc(); throw std::bad_alloc();
// initialize default state // initialize default state
m_file = NULL; m_file = NULL;
m_compressed_offset = 0; 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 // output stream
//------------------------------------------------- //-------------------------------------------------
@ -265,7 +265,7 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf
offset += ignore; offset += ignore;
m_ignore_bytes -= ignore; m_ignore_bytes -= ignore;
} }
// if we haven't hit the end of metadata, process a new piece // if we haven't hit the end of metadata, process a new piece
else if (!m_found_audio) else if (!m_found_audio)
{ {
@ -275,7 +275,7 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf
offset += 4; offset += 4;
} }
// otherwise process as audio data and copy to the output // otherwise process as audio data and copy to the output
else else
{ {
int count = bytes - offset; 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 // parameters
//------------------------------------------------- //-------------------------------------------------
bool flac_decoder::reset() bool flac_decoder::reset()
{ {
m_compressed_offset = 0; m_compressed_offset = 0;
if (FLAC__stream_decoder_init_stream(m_decoder, if (FLAC__stream_decoder_init_stream(m_decoder,
&flac_decoder::read_callback_static, &flac_decoder::read_callback_static,
NULL, NULL,
&flac_decoder::tell_callback_static, &flac_decoder::tell_callback_static,
NULL, NULL,
NULL, NULL,
&flac_decoder::write_callback_static, &flac_decoder::write_callback_static,
&flac_decoder::metadata_callback_static, &flac_decoder::metadata_callback_static,
&flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK) &flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
return false; return false;
return FLAC__stream_decoder_process_until_end_of_metadata(m_decoder); 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] = static const UINT8 s_header_template[0x2a] =
{ {
0x66, 0x4C, 0x61, 0x43, // +00: 'fLaC' stream header 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 // 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, // +08: minimum block size
0x00, 0x00, // +0A: maximum block size 0x00, 0x00, // +0A: maximum block size
0x00, 0x00, 0x00, // +0C: minimum frame size (0 == unknown) 0x00, 0x00, 0x00, // +0C: minimum frame size (0 == unknown)
0x00, 0x00, 0x00, // +0F: maximum 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), 0x0A, 0xC4, 0x42, 0xF0, 0x00, 0x00, 0x00, 0x00, // +12: sample rate (0x0ac44 == 44100),
// numchannels (2), sample bits (16), // numchannels (2), sample bits (16),
// samples in stream (0 == unknown) // 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, // +1A: MD5 signature (0 == none)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // 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_offset = 0;
m_uncompressed_length = num_samples; m_uncompressed_length = num_samples;
m_uncompressed_swap = swap_endian; m_uncompressed_swap = swap_endian;
// loop until we get everything we want // loop until we get everything we want
while (m_uncompressed_offset < m_uncompressed_length) while (m_uncompressed_offset < m_uncompressed_length)
if (!FLAC__stream_decoder_process_single(m_decoder)) 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_offset = 0;
m_uncompressed_length = num_samples; m_uncompressed_length = num_samples;
m_uncompressed_swap = swap_endian; m_uncompressed_swap = swap_endian;
// loop until we get everything we want // loop until we get everything we want
while (m_uncompressed_offset < m_uncompressed_length) while (m_uncompressed_offset < m_uncompressed_length)
if (!FLAC__stream_decoder_process_single(m_decoder)) if (!FLAC__stream_decoder_process_single(m_decoder))
@ -513,7 +513,7 @@ UINT32 flac_decoder::finish()
FLAC__uint64 position = 0; FLAC__uint64 position = 0;
FLAC__stream_decoder_get_decode_position(m_decoder, &position); FLAC__stream_decoder_get_decode_position(m_decoder, &position);
FLAC__stream_decoder_finish(m_decoder); FLAC__stream_decoder_finish(m_decoder);
// adjust position if we provided the header // adjust position if we provided the header
if (position == 0) if (position == 0)
return 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) FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], size_t *bytes)
{ {
UINT32 expected = *bytes; UINT32 expected = *bytes;
// if a file, just read // if a file, just read
if (m_file != NULL) if (m_file != NULL)
*bytes = core_fread(m_file, buffer, expected); *bytes = core_fread(m_file, buffer, expected);
// otherwise, copy from memory // otherwise, copy from memory
else else
{ {
@ -553,7 +553,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s
outputpos += bytes_to_copy; outputpos += bytes_to_copy;
m_compressed_offset += bytes_to_copy; m_compressed_offset += bytes_to_copy;
} }
// once we're out of that, copy from the secondary buffer // once we're out of that, copy from the secondary buffer
if (outputpos < *bytes && m_compressed_offset < m_compressed_length + m_compressed2_length) 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 // ignore all but STREAMINFO metadata
if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO) if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO)
return; return;
// parse out the data we care about // parse out the data we care about
flac_decoder *fldecoder = reinterpret_cast<flac_decoder *>(client_data); flac_decoder *fldecoder = reinterpret_cast<flac_decoder *>(client_data);
fldecoder->m_sample_rate = metadata->data.stream_info.sample_rate; 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[]) FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
{ {
assert(frame->header.channels == channels()); assert(frame->header.channels == channels());
// interleaved case // interleaved case
int shift = m_uncompressed_swap ? 8 : 0; int shift = m_uncompressed_swap ? 8 : 0;
int blocksize = frame->header.blocksize; 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++) for (int chan = 0; chan < frame->header.channels; chan++)
*dest++ = INT16((UINT16(buffer[chan][sampnum]) << shift) | (UINT16(buffer[chan][sampnum]) >> shift)); *dest++ = INT16((UINT16(buffer[chan][sampnum]) << shift) | (UINT16(buffer[chan][sampnum]) >> shift));
} }
// non-interleaved case // non-interleaved case
else else
{ {

View File

@ -67,16 +67,16 @@ public:
void set_num_channels(UINT8 num_channels) { m_channels = num_channels; } 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_block_size(UINT32 block_size) { m_block_size = block_size; }
void set_strip_metadata(bool strip) { m_strip_metadata = strip; } void set_strip_metadata(bool strip) { m_strip_metadata = strip; }
// getters (valid after reset) // getters (valid after reset)
FLAC__StreamEncoderState state() const { return FLAC__stream_encoder_get_state(m_encoder); } 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); } const char *state_string() const { return FLAC__stream_encoder_get_resolved_state_string(m_encoder); }
// reset // reset
bool reset(); bool reset();
bool reset(void *buffer, UINT32 buflength); bool reset(void *buffer, UINT32 buflength);
bool reset(core_file &file); bool reset(core_file &file);
// encode a buffer // encode a buffer
bool encode_interleaved(const INT16 *samples, UINT32 samples_per_channel, bool swap_endian = false); 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); 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 UINT32 m_compressed_offset; // current offset with the compressed stream
FLAC__byte * m_compressed_start; // start of compressed data FLAC__byte * m_compressed_start; // start of compressed data
UINT32 m_compressed_length; // length of the compressed stream UINT32 m_compressed_length; // length of the compressed stream
// parameters // parameters
UINT32 m_sample_rate; // sample rate UINT32 m_sample_rate; // sample rate
UINT8 m_channels; // number of channels UINT8 m_channels; // number of channels
UINT32 m_block_size; // block size UINT32 m_block_size; // block size
// header stripping // 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 UINT32 m_ignore_bytes; // how many bytes to ignore when writing
bool m_found_audio; // have we hit the audio yet? 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(const void *buffer, UINT32 length, const void *buffer2 = NULL, UINT32 length2 = 0);
flac_decoder(core_file &file); flac_decoder(core_file &file);
~flac_decoder(); ~flac_decoder();
// getters (valid after reset) // getters (valid after reset)
UINT32 sample_rate() const { return m_sample_rate; } UINT32 sample_rate() const { return m_sample_rate; }
UINT8 channels() const { return m_channels; } UINT8 channels() const { return m_channels; }
@ -127,13 +127,13 @@ public:
UINT32 total_samples() const { return FLAC__stream_decoder_get_total_samples(m_decoder); } 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); } 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); } const char *state_string() const { return FLAC__stream_decoder_get_resolved_state_string(m_decoder); }
// reset // reset
bool reset(); bool reset();
bool reset(const void *buffer, UINT32 length, const void *buffer2 = NULL, UINT32 length2 = 0); 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(UINT32 sample_rate, UINT8 num_channels, UINT32 block_size, const void *buffer, UINT32 length);
bool reset(core_file &file); bool reset(core_file &file);
// decode to a buffer; num_samples must be a multiple of the block size // 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_interleaved(INT16 *samples, UINT32 num_samples, bool swap_endian = false);
bool decode(INT16 **samples, UINT32 num_samples, bool swap_endian = false); bool decode(INT16 **samples, UINT32 num_samples, bool swap_endian = false);

View File

@ -1,39 +1,39 @@
/*************************************************************************** /***************************************************************************
hashing.c hashing.c
Hashing helper classes. Hashing helper classes.
**************************************************************************** ****************************************************************************
Copyright Aaron Giles Copyright Aaron Giles
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
met: met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the the documentation and/or other materials provided with the
distribution. distribution.
* Neither the name 'MAME' nor the names of its contributors may be * Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software used to endorse or promote products derived from this software
without specific prior written permission. without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. 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 // character
//------------------------------------------------- //-------------------------------------------------
@ -89,7 +89,7 @@ bool sha1_t::from_string(const char *string, int length)
length = strlen(string); length = strlen(string);
if (length < 2 * sizeof(m_raw)) if (length < 2 * sizeof(m_raw))
return false; return false;
// iterate through our raw buffer // iterate through our raw buffer
for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++) for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++)
{ {
@ -111,7 +111,7 @@ const char *sha1_t::as_string(astring &buffer) const
{ {
buffer.reset(); buffer.reset();
for (int i = 0; i < ARRAY_LENGTH(m_raw); i++) for (int i = 0; i < ARRAY_LENGTH(m_raw); i++)
buffer.catformat("%02x", m_raw[i]); buffer.catformat("%02x", m_raw[i]);
return buffer; return buffer;
} }
@ -131,7 +131,7 @@ bool md5_t::from_string(const char *string, int length)
length = strlen(string); length = strlen(string);
if (length < 2 * sizeof(m_raw)) if (length < 2 * sizeof(m_raw))
return false; return false;
// iterate through our raw buffer // iterate through our raw buffer
for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++) for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++)
{ {
@ -153,7 +153,7 @@ const char *md5_t::as_string(astring &buffer) const
{ {
buffer.reset(); buffer.reset();
for (int i = 0; i < ARRAY_LENGTH(m_raw); i++) for (int i = 0; i < ARRAY_LENGTH(m_raw); i++)
buffer.catformat("%02x", m_raw[i]); buffer.catformat("%02x", m_raw[i]);
return buffer; return buffer;
} }
@ -174,7 +174,7 @@ bool crc32_t::from_string(const char *string, int length)
length = strlen(string); length = strlen(string);
if (length < 2 * sizeof(m_raw)) if (length < 2 * sizeof(m_raw))
return false; return false;
// iterate through our raw buffer // iterate through our raw buffer
m_raw = 0; m_raw = 0;
for (int bytenum = 0; bytenum < sizeof(m_raw) * 2; bytenum++) 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 // the currently-accumulated value
//------------------------------------------------- //-------------------------------------------------
@ -225,7 +225,7 @@ bool crc16_t::from_string(const char *string, int length)
length = strlen(string); length = strlen(string);
if (length < 2 * sizeof(m_raw)) if (length < 2 * sizeof(m_raw))
return false; return false;
// iterate through our raw buffer // iterate through our raw buffer
m_raw = 0; m_raw = 0;
for (int bytenum = 0; bytenum < sizeof(m_raw) * 2; bytenum++) 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 // the currently-accumulated value
//------------------------------------------------- //-------------------------------------------------
void crc16_creator::append(const void *data, UINT32 length) 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, 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 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); const UINT8 *src = reinterpret_cast<const UINT8 *>(data);
// fetch the current value into a local and rip through the source data // fetch the current value into a local and rip through the source data
UINT16 crc = m_accum.m_raw; UINT16 crc = m_accum.m_raw;
while (length-- != 0) while (length-- != 0)

View File

@ -1,39 +1,39 @@
/*************************************************************************** /***************************************************************************
hashing.h hashing.h
Hashing helper classes. Hashing helper classes.
**************************************************************************** ****************************************************************************
Copyright Aaron Giles Copyright Aaron Giles
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
met: met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the the documentation and/or other materials provided with the
distribution. distribution.
* Neither the name 'MAME' nor the names of its contributors may be * Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software used to endorse or promote products derived from this software
without specific prior written permission. without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/ ***************************************************************************/
@ -73,13 +73,13 @@ class sha1_creator
public: public:
// construction/destruction // construction/destruction
sha1_creator() { reset(); } sha1_creator() { reset(); }
// reset // reset
void reset() { sha1_init(&m_context); } void reset() { sha1_init(&m_context); }
// append data // append data
void append(const void *data, UINT32 length) { sha1_update(&m_context, length, reinterpret_cast<const UINT8 *>(data)); } void append(const void *data, UINT32 length) { sha1_update(&m_context, length, reinterpret_cast<const UINT8 *>(data)); }
// finalize and compute the final digest // finalize and compute the final digest
sha1_t finish() sha1_t finish()
{ {
@ -92,8 +92,8 @@ public:
// static wrapper to just get the digest from a block // static wrapper to just get the digest from a block
static sha1_t simple(const void *data, UINT32 length) static sha1_t simple(const void *data, UINT32 length)
{ {
sha1_creator creator; sha1_creator creator;
creator.append(data, length); creator.append(data, length);
return creator.finish(); return creator.finish();
} }
@ -124,13 +124,13 @@ class md5_creator
public: public:
// construction/destruction // construction/destruction
md5_creator() { reset(); } md5_creator() { reset(); }
// reset // reset
void reset() { MD5Init(&m_context); } void reset() { MD5Init(&m_context); }
// append data // append data
void append(const void *data, UINT32 length) { MD5Update(&m_context, reinterpret_cast<const unsigned char *>(data), length); } void append(const void *data, UINT32 length) { MD5Update(&m_context, reinterpret_cast<const unsigned char *>(data), length); }
// finalize and compute the final digest // finalize and compute the final digest
md5_t finish() md5_t finish()
{ {
@ -142,14 +142,14 @@ public:
// static wrapper to just get the digest from a block // static wrapper to just get the digest from a block
static md5_t simple(const void *data, UINT32 length) static md5_t simple(const void *data, UINT32 length)
{ {
md5_creator creator; md5_creator creator;
creator.append(data, length); creator.append(data, length);
return creator.finish(); return creator.finish();
} }
protected: protected:
// internal state // internal state
struct MD5Context m_context; // internal context struct MD5Context m_context; // internal context
}; };
@ -175,21 +175,21 @@ class crc32_creator
public: public:
// construction/destruction // construction/destruction
crc32_creator() { reset(); } crc32_creator() { reset(); }
// reset // reset
void reset() { m_accum.m_raw = 0; } void reset() { m_accum.m_raw = 0; }
// append data // append data
void append(const void *data, UINT32 length); void append(const void *data, UINT32 length);
// finalize and compute the final digest // finalize and compute the final digest
crc32_t finish() { return m_accum; } crc32_t finish() { return m_accum; }
// static wrapper to just get the digest from a block // static wrapper to just get the digest from a block
static crc32_t simple(const void *data, UINT32 length) static crc32_t simple(const void *data, UINT32 length)
{ {
crc32_creator creator; crc32_creator creator;
creator.append(data, length); creator.append(data, length);
return creator.finish(); return creator.finish();
} }
@ -221,21 +221,21 @@ class crc16_creator
public: public:
// construction/destruction // construction/destruction
crc16_creator() { reset(); } crc16_creator() { reset(); }
// reset // reset
void reset() { m_accum.m_raw = 0xffff; } void reset() { m_accum.m_raw = 0xffff; }
// append data // append data
void append(const void *data, UINT32 length); void append(const void *data, UINT32 length);
// finalize and compute the final digest // finalize and compute the final digest
crc16_t finish() { return m_accum; } crc16_t finish() { return m_accum; }
// static wrapper to just get the digest from a block // static wrapper to just get the digest from a block
static crc16_t simple(const void *data, UINT32 length) static crc16_t simple(const void *data, UINT32 length)
{ {
crc16_creator creator; crc16_creator creator;
creator.append(data, length); creator.append(data, length);
return creator.finish(); return creator.finish();
} }

View File

@ -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 // 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(); huffman_error error = assign_canonical_codes();
if (error != HUFFERR_NONE) if (error != HUFFERR_NONE)
return error; return error;
// build the lookup table // build the lookup table
build_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 // 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; smallhuff.m_huffnode[index].m_numbits = (count == 7) ? 0 : count;
} }
} }
// then regenerate the tree // then regenerate the tree
huffman_error error = smallhuff.assign_canonical_codes(); huffman_error error = smallhuff.assign_canonical_codes();
if (error != HUFFERR_NONE) if (error != HUFFERR_NONE)
return error; return error;
smallhuff.build_lookup_table(); smallhuff.build_lookup_table();
// determine the maximum length of an RLE count // determine the maximum length of an RLE count
UINT32 temp = m_numcodes - 9; UINT32 temp = m_numcodes - 9;
UINT8 rlefullbits = 0; 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 // a huffman target data stream
//------------------------------------------------- //-------------------------------------------------
@ -350,7 +350,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
UINT16 *lengths = rle_lengths; UINT16 *lengths = rle_lengths;
int last = ~0; int last = ~0;
int repcount = 0; int repcount = 0;
// use a small huffman context to create a tree (ignoring RLE lengths) // use a small huffman context to create a tree (ignoring RLE lengths)
huffman_encoder<24, 6> smallhuff; huffman_encoder<24, 6> smallhuff;
@ -363,14 +363,14 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
{ {
if (repcount == 1) if (repcount == 1)
smallhuff.histo_one(*dest++ = last + 1); smallhuff.histo_one(*dest++ = last + 1);
else else
smallhuff.histo_one(*dest++ = 0), *lengths++ = repcount - 2; smallhuff.histo_one(*dest++ = 0), *lengths++ = repcount - 2;
} }
// if same as last, just track repeats // if same as last, just track repeats
if (newval == last) if (newval == last)
repcount++; repcount++;
// otherwise, write it and start a new run // otherwise, write it and start a new run
else else
{ {
@ -385,7 +385,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
{ {
if (repcount == 1) if (repcount == 1)
smallhuff.histo_one(*dest++ = last + 1); smallhuff.histo_one(*dest++ = last + 1);
else else
smallhuff.histo_one(*dest++ = 0), *lengths++ = repcount - 2; 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++) for (int index = first_non_zero; index <= last_non_zero; index++)
bitbuf.write(smallhuff.m_huffnode[index].m_numbits, 3); bitbuf.write(smallhuff.m_huffnode[index].m_numbits, 3);
bitbuf.write(7, 3); bitbuf.write(7, 3);
// determine the maximum length of an RLE count // determine the maximum length of an RLE count
UINT32 temp = m_numcodes - 9; UINT32 temp = m_numcodes - 9;
UINT8 rlefullbits = 0; UINT8 rlefullbits = 0;
@ -427,7 +427,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
// encode the data // encode the data
UINT8 data = *src; UINT8 data = *src;
smallhuff.encode_one(bitbuf, data); smallhuff.encode_one(bitbuf, data);
// if this is an RLE token, encode the length following // if this is an RLE token, encode the length following
if (data == 0) 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); bitbuf.write(7, 3), bitbuf.write(count - 7, rlefullbits);
} }
} }
// flush the final buffer // flush the final buffer
return bitbuf.overflow() ? HUFFERR_OUTPUT_BUFFER_TOO_SMALL : HUFFERR_NONE; 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 // data distribution
//------------------------------------------------- //-------------------------------------------------
@ -616,8 +616,8 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight)
//------------------------------------------------- //-------------------------------------------------
// assign_canonical_codes - assign canonical codes // assign_canonical_codes - assign canonical codes
// to all the nodes based on the number of bits // to all the nodes based on the number of bits
// in each // in each
//------------------------------------------------- //-------------------------------------------------
@ -696,7 +696,7 @@ void huffman_context_base::build_lookup_table()
huffman_8bit_encoder::huffman_8bit_encoder() huffman_8bit_encoder::huffman_8bit_encoder()
{ {
} }
//------------------------------------------------- //-------------------------------------------------
// encode - encode a full buffer // 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(); huffman_error err = compute_tree_from_histo();
if (err != HUFFERR_NONE) if (err != HUFFERR_NONE)
return err; return err;
// export the tree // export the tree
bitstream_out bitbuf(dest, dlength); bitstream_out bitbuf(dest, dlength);
err = export_tree_huffman(bitbuf); err = export_tree_huffman(bitbuf);
if (err != HUFFERR_NONE) if (err != HUFFERR_NONE)
return err; return err;
// then encode the data // then encode the data
for (UINT32 cur = 0; cur < slength; cur++) for (UINT32 cur = 0; cur < slength; cur++)
encode_one(bitbuf, source[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; return bitbuf.overflow() ? HUFFERR_OUTPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
} }
//************************************************************************** //**************************************************************************
// 8-BIT DECODER // 8-BIT DECODER
@ -740,7 +740,7 @@ huffman_error huffman_8bit_encoder::encode(const UINT8 *source, UINT32 slength,
huffman_8bit_decoder::huffman_8bit_decoder() huffman_8bit_decoder::huffman_8bit_decoder()
{ {
} }
//------------------------------------------------- //-------------------------------------------------
// decode - decode a full buffer // 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); huffman_error err = import_tree_huffman(bitbuf);
if (err != HUFFERR_NONE) if (err != HUFFERR_NONE)
return err; return err;
// then decode the data // then decode the data
for (UINT32 cur = 0; cur < dlength; cur++) for (UINT32 cur = 0; cur < dlength; cur++)
dest[cur] = decode_one(bitbuf); dest[cur] = decode_one(bitbuf);

View File

@ -84,7 +84,7 @@ protected:
UINT32 m_bits; // bits used to encode the node UINT32 m_bits; // bits used to encode the node
UINT8 m_numbits; // number of bits needed for this node UINT8 m_numbits; // number of bits needed for this node
}; };
// construction/destruction // construction/destruction
huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, UINT32 *histo, node_t *nodes); 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_reset() { memset(m_datahisto_array, 0, sizeof(m_datahisto_array)); }
void histo_one(UINT32 data); void histo_one(UINT32 data);
void encode_one(bitstream_out &bitbuf, UINT32 data); void encode_one(bitstream_out &bitbuf, UINT32 data);
// expose tree computation and export // expose tree computation and export
using huffman_context_base::compute_tree_from_histo; using huffman_context_base::compute_tree_from_histo;
using huffman_context_base::export_tree_rle; using huffman_context_base::export_tree_rle;
using huffman_context_base::export_tree_huffman; using huffman_context_base::export_tree_huffman;
private: private:
// array versions of the info we need // array versions of the info we need
UINT32 m_datahisto_array[_NumCodes]; UINT32 m_datahisto_array[_NumCodes];
@ -159,11 +159,11 @@ public:
// single item operations // single item operations
UINT32 decode_one(bitstream_in &bitbuf); UINT32 decode_one(bitstream_in &bitbuf);
// expose tree import // expose tree import
using huffman_context_base::import_tree_rle; using huffman_context_base::import_tree_rle;
using huffman_context_base::import_tree_huffman; using huffman_context_base::import_tree_huffman;
private: private:
// array versions of the info we need // array versions of the info we need
node_t m_huffnode_array[_NumCodes]; node_t m_huffnode_array[_NumCodes];
@ -179,12 +179,12 @@ class huffman_8bit_encoder : public huffman_encoder<>
public: public:
// construction/destruction // construction/destruction
huffman_8bit_encoder(); huffman_8bit_encoder();
// operations // operations
huffman_error encode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength, UINT32 &complength); huffman_error encode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength, UINT32 &complength);
}; };
// ======================> huffman_8bit_decoder // ======================> huffman_8bit_decoder
// generic 8-bit encoder/decoder // generic 8-bit encoder/decoder
@ -193,7 +193,7 @@ class huffman_8bit_decoder : public huffman_decoder<>
public: public:
// construction/destruction // construction/destruction
huffman_8bit_decoder(); huffman_8bit_decoder();
// operations // operations
huffman_error decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength); huffman_error decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength);
}; };

View File

@ -91,7 +91,7 @@ WRes File_Close(CSzFile *p)
WRes File_Read(CSzFile *p, void *data, size_t *size) WRes File_Read(CSzFile *p, void *data, size_t *size)
{ {
// file_error err; // file_error err;
UINT32 read_length; UINT32 read_length;
if (!p->_7z_osdfile) if (!p->_7z_osdfile)
@ -104,7 +104,7 @@ WRes File_Read(CSzFile *p, void *data, size_t *size)
if (originalSize == 0) if (originalSize == 0)
return 0; return 0;
// err = // err =
osd_read( p->_7z_osdfile, data, p->_7z_currfpos, originalSize, &read_length ); osd_read( p->_7z_osdfile, data, p->_7z_currfpos, originalSize, &read_length );
*size = read_length; *size = read_length;
p->_7z_currfpos += 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; if (origin==2) p->_7z_currfpos = p->_7z_length - *pos;
*pos = p->_7z_currfpos; *pos = p->_7z_currfpos;
return 0; 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 ((zn>=0x41) && (zn<=0x5a)) zn+=0x20;
if (sn != zn) break; if (sn != zn) break;
} }
if (j==search_filename_length) namematch = true; if (j==search_filename_length) namematch = true;
} }
/* Check for a CRC match */ /* Check for a CRC match */
if (crc==search_crc) crcmatch = true; 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; 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->curr_file_idx = i;
new_7z->uncompressed_length = size; new_7z->uncompressed_length = size;
new_7z->crc = crc; new_7z->crc = crc;
@ -364,7 +364,7 @@ _7z_error _7z_file_open(const char *filename, _7z_file **_7z)
FileInStream_CreateVTable(&new_7z->archiveStream); FileInStream_CreateVTable(&new_7z->archiveStream);
LookToRead_CreateVTable(&new_7z->lookStream, False); LookToRead_CreateVTable(&new_7z->lookStream, False);
new_7z->lookStream.realStream = &new_7z->archiveStream.s; new_7z->lookStream.realStream = &new_7z->archiveStream.s;
LookToRead_Init(&new_7z->lookStream); 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, &new_7z->blockIndex, &new_7z->outBuffer, &new_7z->outBufferSize,
&offset, &outSizeProcessed, &offset, &outSizeProcessed,
&new_7z->allocImp, &new_7z->allocTempImp); &new_7z->allocImp, &new_7z->allocTempImp);
if (res != SZ_OK) if (res != SZ_OK)
return _7ZERR_FILE_ERROR; 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->outBuffer) IAlloc_Free(&_7z->allocImp, _7z->outBuffer);
if (_7z->inited) SzArEx_Free(&_7z->db, &_7z->allocImp); if (_7z->inited) SzArEx_Free(&_7z->db, &_7z->allocImp);
free(_7z); free(_7z);
} }

View File

@ -829,7 +829,7 @@ class ide_baseboard_device : public ide_hdd_device
public: public:
// construction/destruction // construction/destruction
ide_baseboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); 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 read_sector(UINT32 lba, void *buffer);
virtual int write_sector(UINT32 lba, const void *buffer); virtual int write_sector(UINT32 lba, const void *buffer);
virtual bool is_ready() { return true; } virtual bool is_ready() { return true; }

View File

@ -430,7 +430,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
case 0x04: case 0x04:
{ {
state->m_blitterMode = (data & 0x00ff0000) >> 16; state->m_blitterMode = (data & 0x00ff0000) >> 16;
if (state->m_blitterMode == 0xf4) if (state->m_blitterMode == 0xf4)
{ {
// Some sort of addressing state. // Some sort of addressing state.
@ -456,7 +456,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
} }
break; break;
} }
// The data register // The data register
case 0x05: 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 // DEBUG: Uncomment to see the ASCII strings as they are being blitted
//if (state->m_blitterSerialCount >= state->m_textBytesToWrite) //if (state->m_blitterSerialCount >= state->m_textBytesToWrite)
//{ //{
// for (int i = 0; i < state->m_textBytesToWrite+1; i++) // for (int i = 0; i < state->m_textBytesToWrite+1; i++)
// printf("%c", space->read_byte(0x03f40000 + state->m_textOffset + i)); // printf("%c", space->read_byte(0x03f40000 + state->m_textOffset + i));
// printf("\n"); // printf("\n");
//} //}
} }
else if (state->m_blitterMode == 0x30 || state->m_blitterMode == 0x90) 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) else if (state->m_blitterSerialCount == 11)
{ {
const UINT32 memOffset = data; const UINT32 memOffset = data;
// Splat some sprites // Splat some sprites
for (int h = 0; h < state->m_hCellCount; h++) 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 pixelOffsetX = state->m_hPosition + (h*16);
const int pixelOffsetY = state->m_vPosition + (v*16); const int pixelOffsetY = state->m_vPosition + (v*16);
// It's unknown if it's row-major or column-major // It's unknown if it's row-major or column-major
// TODO: Study the CRT test and "Cool Riders" logo for clues. // TODO: Study the CRT test and "Cool Riders" logo for clues.
UINT8 spriteNumber = space->read_byte(memOffset + h + (v*h)); UINT8 spriteNumber = space->read_byte(memOffset + h + (v*h));
// DEBUG: For demo purposes, skip spaces and NULL characters // DEBUG: For demo purposes, skip spaces and NULL characters
if (spriteNumber == 0x20 || spriteNumber == 0x00) if (spriteNumber == 0x20 || spriteNumber == 0x00)
continue; continue;
@ -541,7 +541,7 @@ static WRITE32_HANDLER( sysh1_txt_blit_w )
color = 0xff00ff00; color = 0xff00ff00;
else if (state->m_colorNumber == 0x5e) else if (state->m_colorNumber == 0x5e)
color = 0xff0000ff; color = 0xff0000ff;
else else
color = 0xff00ffff; color = 0xff00ffff;
state->m_temp_bitmap_sprites.pix32(pixelOffsetY+y, pixelOffsetX+x) = color; 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++; state->m_blitterSerialCount++;
} }
break; break;

View File

@ -150,7 +150,7 @@ static WRITE8_DEVICE_HANDLER( kungfur_latch3_w )
static WRITE8_DEVICE_HANDLER( kungfur_control_w ) static WRITE8_DEVICE_HANDLER( kungfur_control_w )
{ {
kungfur_state *state = device->machine().driver_data<kungfur_state>(); kungfur_state *state = device->machine().driver_data<kungfur_state>();
// d0-d3: N/C // d0-d3: N/C
// d4: irq ack // d4: irq ack
if (~data & 0x10) if (~data & 0x10)
@ -193,7 +193,7 @@ static void kfr_adpcm1_int(device_t *device)
kungfur_state *state = device->machine().driver_data<kungfur_state>(); kungfur_state *state = device->machine().driver_data<kungfur_state>();
UINT8 *ROM = device->machine().region("adpcm1")->base(); UINT8 *ROM = device->machine().region("adpcm1")->base();
UINT8 data = ROM[state->m_adpcm_pos[0] & 0x1ffff]; UINT8 data = ROM[state->m_adpcm_pos[0] & 0x1ffff];
msm5205_data_w(device, state->m_adpcm_sel[0] ? data & 0xf : data >> 4 & 0xf); 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_pos[0] += state->m_adpcm_sel[0];
state->m_adpcm_sel[0] ^= 1; 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>(); kungfur_state *state = device->machine().driver_data<kungfur_state>();
UINT8 *ROM = device->machine().region("adpcm2")->base(); UINT8 *ROM = device->machine().region("adpcm2")->base();
UINT8 data = ROM[state->m_adpcm_pos[1] & 0x3ffff]; UINT8 data = ROM[state->m_adpcm_pos[1] & 0x3ffff];
msm5205_data_w(device, state->m_adpcm_sel[1] ? data & 0xf : data >> 4 & 0xf); 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_pos[1] += state->m_adpcm_sel[1];
state->m_adpcm_sel[1] ^= 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( 0x06, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_2C ) ) 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( 0x02, DEF_STR( 1C_3C ) )
// PORT_DIPSETTING( 0x00, DEF_STR( 1C_3C ) ) // dupe // PORT_DIPSETTING( 0x00, DEF_STR( 1C_3C ) ) // dupe
// PORT_DIPSETTING( 0x04, DEF_STR( 0C_0C ) ) // invalid // PORT_DIPSETTING( 0x04, DEF_STR( 0C_0C ) ) // invalid
PORT_SERVICE( 0x08, IP_ACTIVE_LOW ) PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END INPUT_PORTS_END

View File

@ -2152,7 +2152,7 @@ ROM_START( winrun )
ROM_LOAD("wrvoi-0.11b", 0x040000, 0x40000, CRC(8040b645) SHA1(7ccafb3073fa79910e26cf9b8b6e8e9ae22e55fc) ) 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-1.11c", 0x0c0000, 0x40000, CRC(d347e904) SHA1(620cd07e6230322c306283e45a43fa1e217028d4) )
ROM_LOAD("wrvoi-2.11d", 0x140000, 0x40000, CRC(b34747af) SHA1(7e0b55631bffa0583bf4f7f5368db9f09e411ba1) ) 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 ) ROM_REGION( 0x1000, "pals", 0 )
/* Main PCB (2252960101) */ /* 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, 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( 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, 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 )

View File

@ -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. 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 J105 - 110VAC power input
J106 - DC variable power output to feed-back motor J106 - DC variable power output to feed-back motor
Namco Gorgon-based games Namco Gorgon-based games
------------------------ ------------------------

View File

@ -6861,7 +6861,7 @@ ROM_START( initdv3e )
ROM_REGION( 0x4300, "pic", ROMREGION_ERASEFF) ROM_REGION( 0x4300, "pic", ROMREGION_ERASEFF)
//PIC16C622A (317-0384-COM) //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 ROM_END
/* /*
@ -7062,29 +7062,29 @@ ROM_START( soulsurf )
ROM_REGION( 0xb000000, "rom_board", ROMREGION_ERASEFF) 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. // 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_RELOAD( 0x400000, 0x400000)
ROM_LOAD( "ssf01.ic1s", 0x0800000, 0x800000, CRC(4f12f789) SHA1(7b79b687fc61e2e981b9e5e8e0939c4ad24a98f0) ) ROM_LOAD( "ssf01.ic1s", 0x0800000, 0x800000, CRC(4f12f789) SHA1(7b79b687fc61e2e981b9e5e8e0939c4ad24a98f0) )
ROM_LOAD( "ssf02.ic2s", 0x1000000, 0x800000, CRC(a255d41a) SHA1(3e932527eb68edf3e8538c1ad264a1c599f6a9d5) ) ROM_LOAD( "ssf02.ic2s", 0x1000000, 0x800000, CRC(a255d41a) SHA1(3e932527eb68edf3e8538c1ad264a1c599f6a9d5) )
ROM_LOAD( "ssf03.ic3s", 0x1800000, 0x800000, CRC(0f8d6577) SHA1(afaf440e667bacc941c0a5418a0e3b0f2bb725b7) ) ROM_LOAD( "ssf03.ic3s", 0x1800000, 0x800000, CRC(0f8d6577) SHA1(afaf440e667bacc941c0a5418a0e3b0f2bb725b7) )
ROM_LOAD( "ssf04.ic4s", 0x2000000, 0x800000, CRC(bdf25bd0) SHA1(f79b1fdba9c48969c49617c43c1919637adb13ba) ) ROM_LOAD( "ssf04.ic4s", 0x2000000, 0x800000, CRC(bdf25bd0) SHA1(f79b1fdba9c48969c49617c43c1919637adb13ba) )
ROM_LOAD( "ssf05.ic5s", 0x2800000, 0x800000, CRC(a74b3bb4) SHA1(0ce7cef849061a9af7a61d69dc633f6971a3a63d) ) ROM_LOAD( "ssf05.ic5s", 0x2800000, 0x800000, CRC(a74b3bb4) SHA1(0ce7cef849061a9af7a61d69dc633f6971a3a63d) )
ROM_LOAD( "ssf06.ic6s", 0x3000000, 0x800000, CRC(3cd1f5d5) SHA1(77573c3a60af64e6e6a0eb85d5b8176ed98b0723) ) ROM_LOAD( "ssf06.ic6s", 0x3000000, 0x800000, CRC(3cd1f5d5) SHA1(77573c3a60af64e6e6a0eb85d5b8176ed98b0723) )
ROM_LOAD( "ssf07.ic7s", 0x3800000, 0x800000, CRC(00d240f5) SHA1(43010fc596f2cdffdff35a6122f2ab02a5251bc0) ) ROM_LOAD( "ssf07.ic7s", 0x3800000, 0x800000, CRC(00d240f5) SHA1(43010fc596f2cdffdff35a6122f2ab02a5251bc0) )
ROM_LOAD( "ssf08.ic8s", 0x4000000, 0x800000, CRC(d4907fa1) SHA1(79b1c771819f6e4baa048010bfb940a45370eba2) ) ROM_LOAD( "ssf08.ic8s", 0x4000000, 0x800000, CRC(d4907fa1) SHA1(79b1c771819f6e4baa048010bfb940a45370eba2) )
ROM_LOAD( "ssf09.ic9s", 0x4800000, 0x800000, CRC(6327d49e) SHA1(a10e3c27f70dbf18e63cf51962b6a79a52eba26c) ) ROM_LOAD( "ssf09.ic9s", 0x4800000, 0x800000, CRC(6327d49e) SHA1(a10e3c27f70dbf18e63cf51962b6a79a52eba26c) )
ROM_LOAD( "ssf10.ic10s", 0x5000000, 0x800000, CRC(7975dc80) SHA1(81bda50968f0153a0c4432d8d81e817c1e82e5b2) ) ROM_LOAD( "ssf10.ic10s", 0x5000000, 0x800000, CRC(7975dc80) SHA1(81bda50968f0153a0c4432d8d81e817c1e82e5b2) )
ROM_LOAD( "ssf11.ic11s", 0x5800000, 0x800000, CRC(a242f682) SHA1(435ea5bb1b3667f9ef3d7de081b15f4e8e6a0d01) ) ROM_LOAD( "ssf11.ic11s", 0x5800000, 0x800000, CRC(a242f682) SHA1(435ea5bb1b3667f9ef3d7de081b15f4e8e6a0d01) )
ROM_LOAD( "ssf12.ic12s", 0x6000000, 0x800000, CRC(45fa259e) SHA1(8d7e708e7a2cbc2d60b68715dd79bac28d894d4c) ) ROM_LOAD( "ssf12.ic12s", 0x6000000, 0x800000, CRC(45fa259e) SHA1(8d7e708e7a2cbc2d60b68715dd79bac28d894d4c) )
ROM_LOAD( "ssf13.ic13s", 0x6800000, 0x800000, CRC(e9578063) SHA1(618f66d01f6bdacbf2a3242774a316b130594e02) ) ROM_LOAD( "ssf13.ic13s", 0x6800000, 0x800000, CRC(e9578063) SHA1(618f66d01f6bdacbf2a3242774a316b130594e02) )
ROM_LOAD( "ssf14.ic14s", 0x7000000, 0x800000, CRC(2edc1311) SHA1(bceb54dd29012580e2e6f15f16c6b31195010153) ) ROM_LOAD( "ssf14.ic14s", 0x7000000, 0x800000, CRC(2edc1311) SHA1(bceb54dd29012580e2e6f15f16c6b31195010153) )
ROM_LOAD( "ssf15.ic15s", 0x7800000, 0x800000, CRC(416db320) SHA1(34536716a35260d9457703704bb9174fb1616d60) ) ROM_LOAD( "ssf15.ic15s", 0x7800000, 0x800000, CRC(416db320) SHA1(34536716a35260d9457703704bb9174fb1616d60) )
ROM_LOAD( "ssf16.ic16s", 0x8000000, 0x800000, CRC(2530cc04) SHA1(6425c031e5a129a3c9451bc694b5da8553f154c2) ) ROM_LOAD( "ssf16.ic16s", 0x8000000, 0x800000, CRC(2530cc04) SHA1(6425c031e5a129a3c9451bc694b5da8553f154c2) )
ROM_LOAD( "ssf17.ic17s", 0x8800000, 0x800000, CRC(9e6afcc2) SHA1(4fb69d834ea12c82e897af47a22dcc47f3c83768) ) ROM_LOAD( "ssf17.ic17s", 0x8800000, 0x800000, CRC(9e6afcc2) SHA1(4fb69d834ea12c82e897af47a22dcc47f3c83768) )
ROM_LOAD( "ssf18.ic18s", 0x9000000, 0x800000, CRC(854ed5e5) SHA1(e445599f6a9e9d05c279259307edc08bce5d6d1f) ) ROM_LOAD( "ssf18.ic18s", 0x9000000, 0x800000, CRC(854ed5e5) SHA1(e445599f6a9e9d05c279259307edc08bce5d6d1f) )
ROM_LOAD( "ssf19.ic19s", 0x9800000, 0x800000, CRC(4f8ec86a) SHA1(406ab9eeccd99fa5515d4a2c229c8db1a5cb8f83) ) ROM_LOAD( "ssf19.ic19s", 0x9800000, 0x800000, CRC(4f8ec86a) SHA1(406ab9eeccd99fa5515d4a2c229c8db1a5cb8f83) )
ROM_LOAD( "ssf20.ic20s", 0xa000000, 0x800000, CRC(c90b960d) SHA1(66e9f09d1f7f6a991371574a2e095c0e22fb7031) ) ROM_LOAD( "ssf20.ic20s", 0xa000000, 0x800000, CRC(c90b960d) SHA1(66e9f09d1f7f6a991371574a2e095c0e22fb7031) )
ROM_LOAD( "ssf21.ic21s", 0xa800000, 0x800000, CRC(1477c064) SHA1(87fb8d8a91d6bed70b246a8df88fa77fbf3db443) ) ROM_LOAD( "ssf21.ic21s", 0xa800000, 0x800000, CRC(1477c064) SHA1(87fb8d8a91d6bed70b246a8df88fa77fbf3db443) )
ROM_END 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 ) /* 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 ) /* 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 ) /* 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 ) /* 0106 */ GAME( 2002, vf4evoct, naomi2, naomi2m1, naomi, vf4evoct, ROT0, "Sega", "Virtua Fighter 4 Evolution (Cartridge)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
// 0129 Club Kart Prize // 0129 Club Kart Prize
@ -7948,7 +7948,7 @@ ROM_END
// 0032A Initial D Arcade Stage Ver. 3 (Japan) (Rev A) // 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 ) /* 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 ) /* 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 // 0034
// 0035 // 0035
// 0036 Virtua Fighter 4 Final Tuned // 0036 Virtua Fighter 4 Final Tuned

View File

@ -8889,7 +8889,7 @@ ROM_START( sbp ) /* Unlicensed, no official game ID # */
ROM_REGION( 0x800000, "ymsnd", 0 ) ROM_REGION( 0x800000, "ymsnd", 0 )
ROM_LOAD( "12a.bin", 0x000000, 0x400000, CRC(c96723b9) SHA1(52eec88550781d45f84efbf9b905d7e7912e96fa) ) 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 NO_DELTAT_REGION

View File

@ -451,7 +451,7 @@ static WRITE32_HANDLER(rf5c296_mem_w)
taitogn_state *state = space->machine().driver_data<taitogn_state>(); taitogn_state *state = space->machine().driver_data<taitogn_state>();
if(offset >= 0x140 && offset <= 0x144) { if(offset >= 0x140 && offset <= 0x144) {
dynamic_buffer key; dynamic_buffer key;
int pos = (offset - 0x140)*2; int pos = (offset - 0x140)*2;
UINT8 v, k; UINT8 v, k;

View File

@ -1654,8 +1654,8 @@ ROM_END
ROM_START( wyvernwga ) ROM_START( wyvernwga )
ROM_REGION32_BE( 0x100000, "user1", ROMREGION_ERASE00 ) /* Hyperstone CPU Code */ ROM_REGION32_BE( 0x100000, "user1", ROMREGION_ERASE00 ) /* Hyperstone CPU Code */
ROM_LOAD( "rom1_alt.rom", 0x000000, 0x080000, CRC(586881fd) SHA1(d335bbd91def8fa4935eb2375c9b00471a1f40eb) ) ROM_LOAD( "rom1_alt.rom", 0x000000, 0x080000, CRC(586881fd) SHA1(d335bbd91def8fa4935eb2375c9b00471a1f40eb) )
ROM_LOAD( "rom2_alt.rom", 0x080000, 0x080000, CRC(938049ec) SHA1(cc10944c99ceb388dd4aafc93377c40540861d14) ) ROM_LOAD( "rom2_alt.rom", 0x080000, 0x080000, CRC(938049ec) SHA1(cc10944c99ceb388dd4aafc93377c40540861d14) )
ROM_REGION( 0x020000, "audiocpu", 0 ) /* QDSP ('51) Code */ ROM_REGION( 0x020000, "audiocpu", 0 ) /* QDSP ('51) Code */
ROM_LOAD( "u7", 0x0000, 0x20000, CRC(00a3f705) SHA1(f0a6bafd16bea53d4c05c8cc108983cbd41e5757) ) ROM_LOAD( "u7", 0x0000, 0x20000, CRC(00a3f705) SHA1(f0a6bafd16bea53d4c05c8cc108983cbd41e5757) )

View File

@ -1927,13 +1927,13 @@ void n64_periphs::handle_pif()
{ {
//printf("Before:\n"); //printf("Before:\n");
/*for(int i = 0; i < 0x40; i++) /*for(int i = 0; i < 0x40; i++)
{ {
printf("%02x ", pif_cmd[i]); printf("%02x ", pif_cmd[i]);
if((i & 0xf) == 0xf) if((i & 0xf) == 0xf)
{ {
printf("\n"); printf("\n");
} }
}*/ }*/
if(pif_cmd[0x3f] == 0x1) // only handle the command if the last byte is 1 if(pif_cmd[0x3f] == 0x1) // only handle the command if the last byte is 1
{ {
int channel = 0; int channel = 0;
@ -2005,14 +2005,14 @@ void n64_periphs::handle_pif()
} }
/*printf("After:\n"); /*printf("After:\n");
for(int i = 0; i < 0x40; i++) for(int i = 0; i < 0x40; i++)
{ {
printf("%02x ", pif_ram[i]); printf("%02x ", pif_ram[i]);
if((i & 0xf) == 0xf) if((i & 0xf) == 0xf)
{ {
printf("\n"); printf("\n");
} }
}*/ }*/
} }
void n64_periphs::pif_dma(int direction) void n64_periphs::pif_dma(int direction)

View File

@ -68,7 +68,7 @@ void n64_rdp::GetAlphaCvg(UINT8 *comb_alpha, rdp_span_aux *userdata, const rdp_p
{ {
temp3 = (temp * temp2) + 4; temp3 = (temp * temp2) + 4;
userdata->CurrentPixCvg = (temp3 >> 8) & 0xf; userdata->CurrentPixCvg = (temp3 >> 8) & 0xf;
} }
if (object.OtherModes.alpha_cvg_select) if (object.OtherModes.alpha_cvg_select)
{ {
temp = (OtherModes.cvg_times_alpha) ? (temp3 >> 3) : (temp2 << 5); 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(divot)
//{ //{
// if(i > 0 && i < (hres - 1)) // 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); // 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); // 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.r = ((pix >> 8) & 0xf8) | (pix >> 13);
c.i.g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07); c.i.g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07);

View File

@ -370,7 +370,7 @@ struct rdp_span_aux
INT32 m_precomp_t; INT32 m_precomp_t;
UINT8 BlendEnable; UINT8 BlendEnable;
bool PreWrap; bool PreWrap;
INT32 m_dzpix_enc; INT32 m_dzpix_enc;
UINT8 *m_tmem; /* pointer to texture cache for this polygon */ UINT8 *m_tmem; /* pointer to texture cache for this polygon */
bool m_start_span; bool m_start_span;
}; };
@ -594,14 +594,14 @@ class n64_rdp : public poly_manager<UINT32, rdp_poly_state, 8, 32000>
UINT8 ReplicatedRGBA[32]; UINT8 ReplicatedRGBA[32];
Rectangle Scissor; Rectangle Scissor;
SpanBaseT SpanBase; SpanBaseT SpanBase;
rectangle visarea; rectangle visarea;
void DrawTriangle(bool shade, bool texture, bool zbuffer, bool rect); 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_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_flip(extent_t *Spans, INT32* majorx, INT32* minorx, INT32* majorxint, INT32* minorxint, INT32 scanline, INT32 yh, INT32 yl, INT32 base);
void* AuxBuf; void* AuxBuf;
UINT32 AuxBufPtr; UINT32 AuxBufPtr;
@ -611,7 +611,7 @@ class n64_rdp : public poly_manager<UINT32, rdp_poly_state, 8, 32000>
UINT32 ExtentBufPtr[2]; UINT32 ExtentBufPtr[2];
UINT32 ExtentBufIndex; UINT32 ExtentBufIndex;
bool rdp_range_check(UINT32 addr); bool rdp_range_check(UINT32 addr);
N64Tile m_tiles[8]; N64Tile m_tiles[8];

View File

@ -638,10 +638,10 @@ SCREEN_UPDATE_IND16( hachamf )
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
}; };
nmk16_draw_sprites2(screen.machine(), bitmap,cliprect, hachamf_swaptbl); nmk16_draw_sprites2(screen.machine(), bitmap,cliprect, hachamf_swaptbl);
/* nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3); /* nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2); nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1); nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);*/ nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);*/
state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
return 0; return 0;

View File

@ -58,7 +58,7 @@ USE_DISPATCH_GL = 1
# uncomment the next line to use couriersud's multi-keyboard patch for sdl2.0 # uncomment the next line to use couriersud's multi-keyboard patch for sdl2.0
# SDL2_MULTIAPI = 1 # 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. Equivalent to the ./configure --prefix=<path>
# SDL_INSTALL_ROOT = /usr/local/sdl13 # 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 # 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 INCPATH += -I$(SDL_INSTALL_ROOT)/include/directfb
endif endif
endif endif
INCPATH += `pkg-config --cflags fontconfig` INCPATH += `pkg-config --cflags fontconfig`
LIBS += `pkg-config --libs fontconfig` LIBS += `pkg-config --libs fontconfig`

View File

@ -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 // on an n-CPU system, create n threads for multi queues, and 1 thread for everything else
else else
queue->threads = (flags & WORK_QUEUE_FLAG_MULTI) ? numprocs : 1; queue->threads = (flags & WORK_QUEUE_FLAG_MULTI) ? numprocs : 1;
// multi-queues with high frequency items should top out at 4 for now // multi-queues with high frequency items should top out at 4 for now
// since we have scaling problems above that // since we have scaling problems above that
if ((flags & WORK_QUEUE_FLAG_HIGH_FREQ) && queue->threads > 1) if ((flags & WORK_QUEUE_FLAG_HIGH_FREQ) && queue->threads > 1)

View File

@ -215,7 +215,7 @@ public:
: m_file(file), : m_file(file),
m_offset(offset), m_offset(offset),
m_maxoffset(MIN(maxoffset, (file != NULL) ? core_fsize(file) : 0)) { } m_maxoffset(MIN(maxoffset, (file != NULL) ? core_fsize(file) : 0)) { }
// read interface // read interface
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length) virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length)
{ {
@ -247,7 +247,7 @@ public:
m_offset(offset), m_offset(offset),
m_maxoffset(MIN(maxoffset, file.logical_bytes())) { } m_maxoffset(MIN(maxoffset, file.logical_bytes())) { }
// read interface // read interface
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length) virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length)
{ {
offset += m_offset; offset += m_offset;
@ -279,24 +279,24 @@ public:
: m_file(NULL), : m_file(NULL),
m_toc(toc), m_toc(toc),
m_info(info) { } m_info(info) { }
~chd_cd_compressor() ~chd_cd_compressor()
{ {
if (m_file != NULL) if (m_file != NULL)
core_fclose(m_file); core_fclose(m_file);
} }
// read interface // read interface
virtual UINT32 read_data(void *_dest, UINT64 offset, UINT32 length) virtual UINT32 read_data(void *_dest, UINT64 offset, UINT32 length)
{ {
// verify assumptions made below // verify assumptions made below
assert(offset % CD_FRAME_SIZE == 0); assert(offset % CD_FRAME_SIZE == 0);
assert(length % CD_FRAME_SIZE == 0); assert(length % CD_FRAME_SIZE == 0);
// initialize destination to 0 so that unused areas are filled // initialize destination to 0 so that unused areas are filled
UINT8 *dest = reinterpret_cast<UINT8 *>(_dest); UINT8 *dest = reinterpret_cast<UINT8 *>(_dest);
memset(dest, 0, length); memset(dest, 0, length);
// find out which track we're starting in // find out which track we're starting in
UINT64 startoffs = 0; UINT64 startoffs = 0;
UINT32 length_remaining = length; UINT32 length_remaining = length;
@ -316,7 +316,7 @@ public:
if (filerr != FILERR_NONE) if (filerr != FILERR_NONE)
report_error(1, "Error opening input file (%s)'", m_lastfile.cstr()); report_error(1, "Error opening input file (%s)'", m_lastfile.cstr());
} }
// iterate over frames // iterate over frames
UINT32 bytesperframe = trackinfo.datasize + trackinfo.subsize; UINT32 bytesperframe = trackinfo.datasize + trackinfo.subsize;
UINT64 src_track_start = m_info.track[tracknum].offset; UINT64 src_track_start = m_info.track[tracknum].offset;
@ -332,7 +332,7 @@ public:
UINT32 count = core_fread(m_file, dest, bytesperframe); UINT32 count = core_fread(m_file, dest, bytesperframe);
if (count != bytesperframe) if (count != bytesperframe)
report_error(1, "Error reading input file (%s)'", m_lastfile.cstr()); report_error(1, "Error reading input file (%s)'", m_lastfile.cstr());
// swap if appropriate // swap if appropriate
if (m_info.track[tracknum].swap) if (m_info.track[tracknum].swap)
for (UINT32 swapindex = 0; swapindex < 2352; swapindex += 2) for (UINT32 swapindex = 0; swapindex < 2352; swapindex += 2)
@ -342,7 +342,7 @@ public:
dest[swapindex + 1] = temp; dest[swapindex + 1] = temp;
} }
} }
// advance // advance
offset += CD_FRAME_SIZE; offset += CD_FRAME_SIZE;
dest += CD_FRAME_SIZE; dest += CD_FRAME_SIZE;
@ -351,7 +351,7 @@ public:
break; break;
} }
} }
// next track starts after the previous one // next track starts after the previous one
startoffs = endoffs; startoffs = endoffs;
} }
@ -381,11 +381,11 @@ public:
m_frame_count(num_frames), m_frame_count(num_frames),
m_ldframedata(num_frames * VBI_PACKED_BYTES), m_ldframedata(num_frames * VBI_PACKED_BYTES),
m_rawdata(info.bytes_per_frame) { } m_rawdata(info.bytes_per_frame) { }
// getters // getters
const dynamic_buffer &ldframedata() const { return m_ldframedata; } const dynamic_buffer &ldframedata() const { return m_ldframedata; }
// read interface // read interface
virtual UINT32 read_data(void *_dest, UINT64 offset, UINT32 length) virtual UINT32 read_data(void *_dest, UINT64 offset, UINT32 length)
{ {
UINT8 *dest = reinterpret_cast<UINT8 *>(_dest); UINT8 *dest = reinterpret_cast<UINT8 *>(_dest);
@ -402,7 +402,7 @@ public:
INT32 effframe = m_start_frame + framenum; 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 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; 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 // loop over channels and read the samples
int channels = MIN(m_info.channels, ARRAY_LENGTH(m_audio)); int channels = MIN(m_info.channels, ARRAY_LENGTH(m_audio));
INT16 *samplesptr[ARRAY_LENGTH(m_audio)]; INT16 *samplesptr[ARRAY_LENGTH(m_audio)];
@ -437,13 +437,13 @@ public:
UINT32 rawsize = avhuff_encoder::raw_data_size(m_rawdata); UINT32 rawsize = avhuff_encoder::raw_data_size(m_rawdata);
if (rawsize < m_rawdata.count()) if (rawsize < m_rawdata.count())
memset(&m_rawdata[rawsize], 0, m_rawdata.count() - rawsize); memset(&m_rawdata[rawsize], 0, m_rawdata.count() - rawsize);
// copy to the destination // copy to the destination
UINT64 start_offset = UINT64(framenum) * UINT64(m_info.bytes_per_frame); UINT64 start_offset = UINT64(framenum) * UINT64(m_info.bytes_per_frame);
UINT64 end_offset = start_offset + 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); UINT32 bytes_to_copy = MIN(length_remaining, end_offset - offset);
memcpy(dest, &m_rawdata[offset - start_offset], bytes_to_copy); memcpy(dest, &m_rawdata[offset - start_offset], bytes_to_copy);
// advance // advance
offset += bytes_to_copy; offset += bytes_to_copy;
dest += bytes_to_copy; dest += bytes_to_copy;
@ -519,29 +519,29 @@ static const option_description s_options[] =
// descriptions for each command // descriptions for each command
static const command_description s_commands[] = 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, REQUIRED OPTION_INPUT,
OPTION_VERBOSE OPTION_VERBOSE
} }
}, },
{ COMMAND_VERIFY, do_verify, ": verifies a CHD's integrity", { COMMAND_VERIFY, do_verify, ": verifies a CHD's integrity",
{ {
REQUIRED OPTION_INPUT, REQUIRED OPTION_INPUT,
OPTION_INPUT_PARENT 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_PARENT,
OPTION_OUTPUT_FORCE, OPTION_OUTPUT_FORCE,
REQUIRED OPTION_INPUT, REQUIRED OPTION_INPUT,
OPTION_INPUT_START_BYTE, OPTION_INPUT_START_BYTE,
OPTION_INPUT_START_HUNK, OPTION_INPUT_START_HUNK,
OPTION_INPUT_LENGTH_BYTES, OPTION_INPUT_LENGTH_BYTES,
OPTION_INPUT_LENGTH_HUNKS, OPTION_INPUT_LENGTH_HUNKS,
REQUIRED OPTION_HUNK_SIZE, REQUIRED OPTION_HUNK_SIZE,
REQUIRED OPTION_UNIT_SIZE, REQUIRED OPTION_UNIT_SIZE,
@ -551,16 +551,16 @@ static const command_description s_commands[] =
#endif #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_PARENT,
OPTION_OUTPUT_FORCE, OPTION_OUTPUT_FORCE,
OPTION_INPUT, OPTION_INPUT,
OPTION_INPUT_START_BYTE, OPTION_INPUT_START_BYTE,
OPTION_INPUT_START_HUNK, OPTION_INPUT_START_HUNK,
OPTION_INPUT_LENGTH_BYTES, OPTION_INPUT_LENGTH_BYTES,
OPTION_INPUT_LENGTH_HUNKS, OPTION_INPUT_LENGTH_HUNKS,
OPTION_HUNK_SIZE, OPTION_HUNK_SIZE,
OPTION_COMPRESSION, OPTION_COMPRESSION,
@ -572,13 +572,13 @@ static const command_description s_commands[] =
#endif #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_PARENT,
OPTION_OUTPUT_FORCE, OPTION_OUTPUT_FORCE,
REQUIRED OPTION_INPUT, REQUIRED OPTION_INPUT,
OPTION_HUNK_SIZE, OPTION_HUNK_SIZE,
OPTION_COMPRESSION, OPTION_COMPRESSION,
#if NUM_PROCESSORS_SUPPORTED #if NUM_PROCESSORS_SUPPORTED
@ -586,13 +586,13 @@ static const command_description s_commands[] =
#endif #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_PARENT,
OPTION_OUTPUT_FORCE, OPTION_OUTPUT_FORCE,
REQUIRED OPTION_INPUT, REQUIRED OPTION_INPUT,
OPTION_INPUT_START_FRAME, OPTION_INPUT_START_FRAME,
OPTION_INPUT_LENGTH_FRAMES, OPTION_INPUT_LENGTH_FRAMES,
OPTION_HUNK_SIZE, OPTION_HUNK_SIZE,
@ -602,63 +602,63 @@ static const command_description s_commands[] =
#endif #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, 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,
OPTION_OUTPUT_FORCE, OPTION_OUTPUT_FORCE,
REQUIRED OPTION_INPUT, 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, OPTION_OUTPUT_FORCE,
REQUIRED OPTION_INPUT, REQUIRED OPTION_INPUT,
OPTION_INPUT_PARENT, OPTION_INPUT_PARENT,
OPTION_INPUT_START_FRAME, 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 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_PARENT,
OPTION_OUTPUT_FORCE, OPTION_OUTPUT_FORCE,
REQUIRED OPTION_INPUT, REQUIRED OPTION_INPUT,
OPTION_INPUT_PARENT, OPTION_INPUT_PARENT,
OPTION_INPUT_START_BYTE, OPTION_INPUT_START_BYTE,
OPTION_INPUT_START_HUNK, OPTION_INPUT_START_HUNK,
OPTION_INPUT_LENGTH_BYTES, OPTION_INPUT_LENGTH_BYTES,
OPTION_INPUT_LENGTH_HUNKS, OPTION_INPUT_LENGTH_HUNKS,
OPTION_HUNK_SIZE, OPTION_HUNK_SIZE,
@ -668,10 +668,10 @@ static const command_description s_commands[] =
#endif #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, REQUIRED OPTION_TAG,
OPTION_INDEX, OPTION_INDEX,
OPTION_VALUE_TEXT, OPTION_VALUE_TEXT,
@ -679,10 +679,10 @@ static const command_description s_commands[] =
OPTION_NO_CHECKSUM 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, REQUIRED OPTION_TAG,
OPTION_INDEX OPTION_INDEX
} }
@ -708,7 +708,7 @@ static void report_error(int error, const char *format, ...)
fflush(stderr); fflush(stderr);
va_end(arg); va_end(arg);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
// reset time for progress and return the error // reset time for progress and return the error
lastprogress = 0; lastprogress = 0;
throw fatal_error(error); 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]); bool required = (option[0] == REQUIRED[0]);
if (required) if (required)
option++; option++;
// find the option // find the option
for (int optnum = 0; optnum < ARRAY_LENGTH(s_options); optnum++) for (int optnum = 0; optnum < ARRAY_LENGTH(s_options); optnum++)
if (strcmp(option, s_options[optnum].name) == 0) 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 // 0 is a special case
if (intvalue == 0) if (intvalue == 0)
return string.cpy("0"); return string.cpy("0");
// loop until all chunks are done // loop until all chunks are done
string.reset(); string.reset();
bool first = true; bool first = true;
@ -815,7 +815,7 @@ const char *big_int_string(astring &string, UINT64 intvalue)
{ {
int chunk = intvalue % 1000; int chunk = intvalue % 1000;
intvalue /= 1000; intvalue /= 1000;
astring insert; astring insert;
insert.format((intvalue != 0) ? "%03d" : "%d", chunk); insert.format((intvalue != 0) ? "%03d" : "%d", chunk);
@ -850,7 +850,7 @@ UINT64 parse_number(const char *string)
int length = strlen(string); int length = strlen(string);
if (length == 0) if (length == 0)
return 0; return 0;
// scan forward over digits // scan forward over digits
UINT64 result = 0; UINT64 result = 0;
while (isdigit(*string)) while (isdigit(*string))
@ -858,7 +858,7 @@ UINT64 parse_number(const char *string)
result = (result * 10) + (*string - '0'); result = (result * 10) + (*string - '0');
string++; string++;
} }
// handle multipliers // handle multipliers
if (*string == 'k' || *string == 'K') if (*string == 'k' || *string == 'K')
result *= 1024; result *= 1024;
@ -866,7 +866,7 @@ UINT64 parse_number(const char *string)
result *= 1024 * 1024; result *= 1024 * 1024;
if (*string == 'g' || *string == 'G') if (*string == 'g' || *string == 'G')
result *= 1024 * 1024 * 1024; result *= 1024 * 1024 * 1024;
return result; 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 this is a direct physical drive read, handle it specially
if (filename != NULL && osd_get_physical_drive_geometry(*filename, &cylinders, &heads, &sectors, &bps)) if (filename != NULL && osd_get_physical_drive_geometry(*filename, &cylinders, &heads, &sectors, &bps))
return; return;
// if we have no length to work with, we can't guess // if we have no length to work with, we can't guess
if (filesize == 0) if (filesize == 0)
report_error(1, "Can't guess CHS values because there is no input file"); 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 // standard set of input CHD parameters
//------------------------------------------------- //-------------------------------------------------
@ -962,7 +962,7 @@ static void parse_input_start_end(const parameters_t &params, UINT64 logical_siz
input_start = parse_number(*input_start_frame_str) * framebytes; input_start = parse_number(*input_start_frame_str) * framebytes;
if (input_start >= input_end) if (input_start >= input_end)
report_error(1, "Input start offset greater than input file size"); report_error(1, "Input start offset greater than input file size");
// process input length // process input length
astring *input_length_bytes_str = params.find(OPTION_INPUT_LENGTH_BYTES); astring *input_length_bytes_str = params.find(OPTION_INPUT_LENGTH_BYTES);
astring *input_length_hunks_str = params.find(OPTION_INPUT_LENGTH_HUNKS); astring *input_length_hunks_str = params.find(OPTION_INPUT_LENGTH_HUNKS);
@ -1001,7 +1001,7 @@ static void check_existing_output_file(const parameters_t &params, const char *f
//------------------------------------------------- //-------------------------------------------------
// parse_output_chd_parameters - parse the // parse_output_chd_parameters - parse the
// standard set of output CHD parameters // standard set of output CHD parameters
//------------------------------------------------- //-------------------------------------------------
@ -1025,7 +1025,7 @@ static astring *parse_output_chd_parameters(const parameters_t &params, chd_file
//------------------------------------------------- //-------------------------------------------------
// parse_hunk_size - parse the hunk_size // parse_hunk_size - parse the hunk_size
// parameter in a standard way // parameter in a standard way
//------------------------------------------------- //-------------------------------------------------
@ -1044,7 +1044,7 @@ static void parse_hunk_size(const parameters_t &params, UINT32 required_granular
//------------------------------------------------- //-------------------------------------------------
// parse_compression - parse a standard // parse_compression - parse a standard
// compression parameter string // compression parameter string
//------------------------------------------------- //-------------------------------------------------
@ -1061,7 +1061,7 @@ static void parse_compression(const parameters_t &params, chd_codec_type compres
compression[0] = compression[1] = compression[2] = compression[3] = CHD_CODEC_NONE; compression[0] = compression[1] = compression[2] = compression[3] = CHD_CODEC_NONE;
return; return;
} }
// iterate through compressors // iterate through compressors
int index = 0; int index = 0;
for (int start = 0, end = compression_str->chr(0, ','); index < 4; start = end + 1, end = compression_str->chr(end + 1, ',')) 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(); string.reset();
if (compression[0] == CHD_CODEC_NONE) if (compression[0] == CHD_CODEC_NONE)
return string.cpy("none"); return string.cpy("none");
// iterate over types // iterate over types
for (int index = 0; index < 4; index++) for (int index = 0; index < 4; index++)
{ {
@ -1126,7 +1126,7 @@ static const char *compression_string(astring &string, chd_codec_type compressio
} }
return string; return string;
} }
//------------------------------------------------- //-------------------------------------------------
// compress_common - standard compression loop // compress_common - standard compression loop
@ -1137,7 +1137,7 @@ static void compress_common(chd_file_compressor &chd)
// begin compressing // begin compressing
chd.compress_begin(); chd.compress_begin();
// loop until done // loop until done
double complete, ratio; double complete, ratio;
chd_error err; chd_error err;
while ((err = chd.compress_continue(complete, ratio)) == CHDERR_WALKING_PARENT || err == CHDERR_COMPRESSING) 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"); tempstr.cpy("AUDIO");
break; break;
} }
// output TRACK entry // output TRACK entry
core_fprintf(file, " TRACK %02d %s\n", tracknum + 1, tempstr.cstr()); 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) if (info.postgap > 0)
core_fprintf(file, " POSTGAP %s\n", msf_string_from_frames(tempstr, info.postgap)); core_fprintf(file, " POSTGAP %s\n", msf_string_from_frames(tempstr, info.postgap));
} }
// non-CUE mode // non-CUE mode
else else
{ {
@ -1304,7 +1304,7 @@ static void do_info(parameters_t &params)
chd_error err = input_chd.read_metadata(CHDMETATAG_WILDCARD, index, buffer, metatag, metaflags); chd_error err = input_chd.read_metadata(CHDMETATAG_WILDCARD, index, buffer, metatag, metaflags);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
break; break;
// determine our index // determine our index
UINT32 metaindex = ~0; UINT32 metaindex = ~0;
for (int cur = 0; cur < info.count(); cur++) for (int cur = 0; cur < info.count(); cur++)
@ -1313,7 +1313,7 @@ static void do_info(parameters_t &params)
metaindex = ++info[cur].index; metaindex = ++info[cur].index;
break; break;
} }
// if not found, add to our tracking // if not found, add to our tracking
if (metaindex == ~0) if (metaindex == ~0)
{ {
@ -1335,7 +1335,7 @@ static void do_info(parameters_t &params)
printf("%c", isprint(UINT8(buffer[chnum])) ? buffer[chnum] : '.'); printf("%c", isprint(UINT8(buffer[chnum])) ? buffer[chnum] : '.');
printf("\n"); printf("\n");
} }
// print compression stats if verbose // print compression stats if verbose
if (params.find(OPTION_VERBOSE) != NULL) if (params.find(OPTION_VERBOSE) != NULL)
{ {
@ -1348,7 +1348,7 @@ static void do_info(parameters_t &params)
chd_error err = input_chd.hunk_info(hunknum, codec, compbytes); chd_error err = input_chd.hunk_info(hunknum, codec, compbytes);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error getting info on hunk %d: %s", hunknum, chd_file::error_string(err)); report_error(1, "Error getting info on hunk %d: %s", hunknum, chd_file::error_string(err));
// decode into our data // decode into our data
if (codec > CHD_CODEC_MINI) if (codec > CHD_CODEC_MINI)
for (int comptype = 0; comptype < 4; comptype++) for (int comptype = 0; comptype < 4; comptype++)
@ -1359,11 +1359,11 @@ static void do_info(parameters_t &params)
} }
if (codec > ARRAY_LENGTH(compression_types)) if (codec > ARRAY_LENGTH(compression_types))
codec = ARRAY_LENGTH(compression_types) - 1; codec = ARRAY_LENGTH(compression_types) - 1;
// count stats // count stats
compression_types[codec]++; compression_types[codec]++;
} }
// output the stats // output the stats
printf("\n"); printf("\n");
printf(" Hunks Percent Name\n"); printf(" Hunks Percent Name\n");
@ -1385,10 +1385,10 @@ static void do_info(parameters_t &params)
name = chd_codec_list::codec_name(input_chd.compression(index)); name = chd_codec_list::codec_name(input_chd.compression(index));
break; break;
} }
// output the stats // output the stats
astring tempstr; astring tempstr;
printf("%10s %5.1f%% %-40s\n", printf("%10s %5.1f%% %-40s\n",
big_int_string(tempstr, compression_types[comptype]), big_int_string(tempstr, compression_types[comptype]),
100.0 * double(compression_types[comptype]) / double(input_chd.hunk_count()), 100.0 * double(compression_types[comptype]) / double(input_chd.hunk_count()),
name); name);
@ -1417,7 +1417,7 @@ static void do_verify(parameters_t &params)
// create an array to read into // create an array to read into
dynamic_buffer buffer((TEMP_BUFFER_SIZE / input_chd.hunk_bytes()) * input_chd.hunk_bytes()); dynamic_buffer buffer((TEMP_BUFFER_SIZE / input_chd.hunk_bytes()) * input_chd.hunk_bytes());
// read all the data and build up an SHA-1 // read all the data and build up an SHA-1
sha1_creator rawsha1; sha1_creator rawsha1;
for (UINT64 offset = 0; offset < input_chd.logical_bytes(); ) for (UINT64 offset = 0; offset < input_chd.logical_bytes(); )
@ -1429,13 +1429,13 @@ static void do_verify(parameters_t &params)
chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read); chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err)); report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err));
// add to the checksum // add to the checksum
rawsha1.append(buffer, bytes_to_read); rawsha1.append(buffer, bytes_to_read);
offset += bytes_to_read; offset += bytes_to_read;
} }
sha1_t computed_sha1 = rawsha1.finish(); sha1_t computed_sha1 = rawsha1.finish();
// finish up // finish up
if (raw_sha1 != computed_sha1) if (raw_sha1 != computed_sha1)
{ {
@ -1453,7 +1453,7 @@ static void do_verify(parameters_t &params)
else else
{ {
printf("Raw SHA1 verification successful!\n"); printf("Raw SHA1 verification successful!\n");
// now include the metadata for >= v4 // now include the metadata for >= v4
if (input_chd.version() >= 4) if (input_chd.version() >= 4)
{ {
@ -1498,7 +1498,7 @@ static void do_create_raw(parameters_t &params)
// process output CHD // process output CHD
chd_file output_parent; chd_file output_parent;
astring *output_chd_str = parse_output_chd_parameters(params, output_parent); astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
// process hunk size // process hunk size
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : 0; UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : 0;
parse_hunk_size(params, 1, hunk_size); parse_hunk_size(params, 1, hunk_size);
@ -1517,12 +1517,12 @@ static void do_create_raw(parameters_t &params)
UINT64 input_start; UINT64 input_start;
UINT64 input_end; UINT64 input_end;
parse_input_start_end(params, core_fsize(input_file), hunk_size, hunk_size, input_start, input_end); parse_input_start_end(params, core_fsize(input_file), hunk_size, hunk_size, input_start, input_end);
// process compression // process compression
chd_codec_type compression[4]; chd_codec_type compression[4];
memcpy(compression, s_default_raw_compression, sizeof(compression)); memcpy(compression, s_default_raw_compression, sizeof(compression));
parse_compression(params, compression); parse_compression(params, compression);
// process numprocessors // process numprocessors
parse_numprocessors(params); parse_numprocessors(params);
@ -1553,7 +1553,7 @@ static void do_create_raw(parameters_t &params)
err = chd.create(*output_chd_str, input_end - input_start, hunk_size, unit_size, compression); err = chd.create(*output_chd_str, input_end - input_start, hunk_size, unit_size, compression);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); 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 we have a parent, copy forward all the metadata
if (output_parent.opened()) if (output_parent.opened())
chd.clone_all_metadata(output_parent); chd.clone_all_metadata(output_parent);
@ -1588,11 +1588,11 @@ static void do_create_hd(parameters_t &params)
if (filerr != FILERR_NONE) if (filerr != FILERR_NONE)
report_error(1, "Unable to open file (%s)", input_file_str->cstr()); report_error(1, "Unable to open file (%s)", input_file_str->cstr());
} }
// process output CHD // process output CHD
chd_file output_parent; chd_file output_parent;
astring *output_chd_str = parse_output_chd_parameters(params, output_parent); astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
// process sectorsize // process sectorsize
UINT32 sector_size = output_parent.opened() ? output_parent.unit_bytes() : IDE_SECTOR_SIZE; UINT32 sector_size = output_parent.opened() ? output_parent.unit_bytes() : IDE_SECTOR_SIZE;
astring *sectorsize_str = params.find(OPTION_SECTOR_SIZE); astring *sectorsize_str = params.find(OPTION_SECTOR_SIZE);
@ -1602,16 +1602,16 @@ static void do_create_hd(parameters_t &params)
report_error(1, "Sector size does not apply when creating a diff from the parent"); report_error(1, "Sector size does not apply when creating a diff from the parent");
sector_size = parse_number(*sectorsize_str); sector_size = parse_number(*sectorsize_str);
} }
// process hunk size (needs to know sector_size) // 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); 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); parse_hunk_size(params, sector_size, hunk_size);
// process input start/end (needs to know hunk_size) // process input start/end (needs to know hunk_size)
UINT64 input_start; UINT64 input_start;
UINT64 input_end; UINT64 input_end;
parse_input_start_end(params, core_fsize(input_file), hunk_size, hunk_size, input_start, input_end); parse_input_start_end(params, core_fsize(input_file), hunk_size, hunk_size, input_start, input_end);
// process compression // process compression
chd_codec_type compression[4]; chd_codec_type compression[4];
memcpy(compression, s_default_hd_compression, sizeof(compression)); memcpy(compression, s_default_hd_compression, sizeof(compression));
@ -1656,7 +1656,7 @@ static void do_create_hd(parameters_t &params)
heads = (identdata[7] << 8) | identdata[6]; heads = (identdata[7] << 8) | identdata[6];
sectors = (identdata[13] << 8) | identdata[12]; sectors = (identdata[13] << 8) | identdata[12];
} }
// extract geometry from the parent if we have one // extract geometry from the parent if we have one
if (output_parent.opened() && cylinders == 0) if (output_parent.opened() && cylinders == 0)
{ {
@ -1666,7 +1666,7 @@ static void do_create_hd(parameters_t &params)
if (sscanf(metadata, HARD_DISK_METADATA_FORMAT, &cylinders, &heads, &sectors, &sector_size) != 4) if (sscanf(metadata, HARD_DISK_METADATA_FORMAT, &cylinders, &heads, &sectors, &sector_size) != 4)
report_error(1, "Error parsing hard disk metadata in parent CHD"); report_error(1, "Error parsing hard disk metadata in parent CHD");
} }
// if no CHS values, try to guess them // if no CHS values, try to guess them
if (cylinders == 0) if (cylinders == 0)
{ {
@ -1675,7 +1675,7 @@ static void do_create_hd(parameters_t &params)
guess_chs(input_file_str, input_end - input_start, sector_size, cylinders, heads, sectors, sector_size); guess_chs(input_file_str, input_end - input_start, sector_size, cylinders, heads, sectors, sector_size);
} }
UINT32 totalsectors = cylinders * heads * sectors; UINT32 totalsectors = cylinders * heads * sectors;
// print some info // print some info
astring tempstr; astring tempstr;
printf("Output CHD: %s\n", output_chd_str->cstr()); printf("Output CHD: %s\n", output_chd_str->cstr());
@ -1758,7 +1758,7 @@ static void do_create_cd(parameters_t &params)
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error parsing input file (%s: %s\n", input_file_str->cstr(), chd_file::error_string(err)); report_error(1, "Error parsing input file (%s: %s\n", input_file_str->cstr(), chd_file::error_string(err));
} }
// process output CHD // process output CHD
chd_file output_parent; chd_file output_parent;
astring *output_chd_str = parse_output_chd_parameters(params, output_parent); astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
@ -1766,7 +1766,7 @@ static void do_create_cd(parameters_t &params)
// process hunk size // process hunk size
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : CD_FRAMES_PER_HUNK * CD_FRAME_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); parse_hunk_size(params, CD_FRAME_SIZE, hunk_size);
// process compression // process compression
chd_codec_type compression[4]; chd_codec_type compression[4];
memcpy(compression, s_default_cd_compression, sizeof(compression)); memcpy(compression, s_default_cd_compression, sizeof(compression));
@ -1847,16 +1847,16 @@ static void do_create_ld(parameters_t &params)
report_error(1, "Error opening AVI file (%s): %s\n", input_file_str->cstr(), avi_error_string(avierr)); 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); const avi_movie_info *aviinfo = avi_get_movie_info(input_file);
// process output CHD // process output CHD
chd_file output_parent; chd_file output_parent;
astring *output_chd_str = parse_output_chd_parameters(params, output_parent); astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
// process input start/end // process input start/end
UINT64 input_start; UINT64 input_start;
UINT64 input_end; UINT64 input_end;
parse_input_start_end(params, aviinfo->video_numsamples, 0, 1, input_start, input_end); parse_input_start_end(params, aviinfo->video_numsamples, 0, 1, input_start, input_end);
// determine parameters of the incoming video stream // determine parameters of the incoming video stream
avi_info info; avi_info info;
info.fps_times_1million = UINT64(aviinfo->video_timescale) * 1000000 / aviinfo->video_sampletime; info.fps_times_1million = UINT64(aviinfo->video_timescale) * 1000000 / aviinfo->video_sampletime;
@ -1878,11 +1878,11 @@ static void do_create_ld(parameters_t &params)
// determine the number of bytes per frame // 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.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); info.bytes_per_frame = avhuff_encoder::raw_data_size(info.width, info.height, info.channels, info.max_samples_per_frame);
// process hunk size // process hunk size
UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : info.bytes_per_frame; UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : info.bytes_per_frame;
parse_hunk_size(params, info.bytes_per_frame, hunk_size); parse_hunk_size(params, info.bytes_per_frame, hunk_size);
// process compression // process compression
chd_codec_type compression[4]; chd_codec_type compression[4];
memcpy(compression, s_default_ld_compression, sizeof(compression)); memcpy(compression, s_default_ld_compression, sizeof(compression));
@ -1932,7 +1932,7 @@ static void do_create_ld(parameters_t &params)
// create the compressor and then run it generically // create the compressor and then run it generically
compress_common(chd); compress_common(chd);
// write the final LD metadata // write the final LD metadata
if (info.height == 524/2 || info.height == 624/2) if (info.height == 524/2 || info.height == 624/2)
{ {
@ -1972,13 +1972,13 @@ static void do_copy(parameters_t &params)
// process output CHD // process output CHD
chd_file output_parent; chd_file output_parent;
astring *output_chd_str = parse_output_chd_parameters(params, output_parent); astring *output_chd_str = parse_output_chd_parameters(params, output_parent);
// process hunk size // process hunk size
UINT32 hunk_size = input_chd.hunk_bytes(); UINT32 hunk_size = input_chd.hunk_bytes();
parse_hunk_size(params, 1, hunk_size); parse_hunk_size(params, 1, hunk_size);
if (hunk_size % input_chd.hunk_bytes() != 0 && input_chd.hunk_bytes() % hunk_size != 0) 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"); 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 // process compression; we default to our current preferences using metadata to pick the type
chd_codec_type compression[4]; chd_codec_type compression[4];
{ {
@ -2041,13 +2041,13 @@ static void do_copy(parameters_t &params)
redo_cd = true; redo_cd = true;
continue; continue;
} }
// otherwise, clone it // otherwise, clone it
err = chd.write_metadata(metatag, CHDMETAINDEX_APPEND, metadata); err = chd.write_metadata(metatag, CHDMETAINDEX_APPEND, metadata);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error writing cloned metadata: %s", chd_file::error_string(err)); 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 we need to re-do the CD metadata, do it now
if (redo_cd) if (redo_cd)
{ {
@ -2059,7 +2059,7 @@ static void do_copy(parameters_t &params)
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error writing upgraded CD metadata: %s", chd_file::error_string(err)); report_error(1, "Error writing upgraded CD metadata: %s", chd_file::error_string(err));
} }
// compress it generically // compress it generically
compress_common(chd); compress_common(chd);
} }
@ -2090,12 +2090,12 @@ static void do_extract_raw(parameters_t &params)
UINT64 input_start; UINT64 input_start;
UINT64 input_end; UINT64 input_end;
parse_input_start_end(params, input_chd.logical_bytes(), input_chd.hunk_bytes(), input_chd.hunk_bytes(), input_start, 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 // verify output file doesn't exist
astring *output_file_str = params.find(OPTION_OUTPUT); astring *output_file_str = params.find(OPTION_OUTPUT);
if (output_file_str != NULL) if (output_file_str != NULL)
check_existing_output_file(params, *output_file_str); check_existing_output_file(params, *output_file_str);
// print some info // print some info
astring tempstr; astring tempstr;
printf("Output File: %s\n", output_file_str->cstr()); printf("Output File: %s\n", output_file_str->cstr());
@ -2126,7 +2126,7 @@ static void do_extract_raw(parameters_t &params)
chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read); chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err)); report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err));
// write to the output // write to the output
UINT32 count = core_fwrite(output_file, buffer, bytes_to_read); UINT32 count = core_fwrite(output_file, buffer, bytes_to_read);
if (count != bytes_to_read) if (count != bytes_to_read)
@ -2135,7 +2135,7 @@ static void do_extract_raw(parameters_t &params)
// advance // advance
offset += bytes_to_read; offset += bytes_to_read;
} }
// finish up // finish up
core_fclose(output_file); core_fclose(output_file);
printf("Extraction complete \n"); printf("Extraction complete \n");
@ -2170,7 +2170,7 @@ static void do_extract_cd(parameters_t &params)
if (cdrom == NULL) if (cdrom == NULL)
report_error(1, "Unable to recognize CHD file as a CD"); report_error(1, "Unable to recognize CHD file as a CD");
const cdrom_toc *toc = cdrom_get_toc(cdrom); const cdrom_toc *toc = cdrom_get_toc(cdrom);
// verify output file doesn't exist // verify output file doesn't exist
astring *output_file_str = params.find(OPTION_OUTPUT); astring *output_file_str = params.find(OPTION_OUTPUT);
if (output_file_str != NULL) if (output_file_str != NULL)
@ -2186,7 +2186,7 @@ static void do_extract_cd(parameters_t &params)
if (output_bin_file_str == NULL) if (output_bin_file_str == NULL)
output_bin_file_str = &default_name; output_bin_file_str = &default_name;
check_existing_output_file(params, *output_bin_file_str); check_existing_output_file(params, *output_bin_file_str);
// print some info // print some info
astring tempstr; astring tempstr;
printf("Output TOC: %s\n", output_file_str->cstr()); printf("Output TOC: %s\n", output_file_str->cstr());
@ -2213,7 +2213,7 @@ static void do_extract_cd(parameters_t &params)
UINT64 total_bytes = 0; UINT64 total_bytes = 0;
for (int tracknum = 0; tracknum < toc->numtrks; tracknum++) for (int tracknum = 0; tracknum < toc->numtrks; tracknum++)
total_bytes += toc->tracks[tracknum].frames * (toc->tracks[tracknum].datasize + toc->tracks[tracknum].subsize); total_bytes += toc->tracks[tracknum].frames * (toc->tracks[tracknum].datasize + toc->tracks[tracknum].subsize);
// iterate over tracks and copy all data // iterate over tracks and copy all data
UINT64 outputoffs = 0; UINT64 outputoffs = 0;
UINT32 discoffs = 0; UINT32 discoffs = 0;
@ -2227,7 +2227,7 @@ static void do_extract_cd(parameters_t &params)
// resize the buffer for the track // resize the buffer for the track
UINT32 output_frame_size = trackinfo.datasize + ((trackinfo.subtype != CD_SUB_NONE) ? trackinfo.subsize : 0); 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); buffer.resize((TEMP_BUFFER_SIZE / output_frame_size) * output_frame_size);
// now read and output the actual data // now read and output the actual data
UINT32 bufferoffs = 0; UINT32 bufferoffs = 0;
for (int frame = 0; frame < trackinfo.frames; frame++) for (int frame = 0; frame < trackinfo.frames; frame++)
@ -2267,7 +2267,7 @@ static void do_extract_cd(parameters_t &params)
} }
} }
} }
// finish up // finish up
core_fclose(output_bin_file); core_fclose(output_bin_file);
core_fclose(output_toc_file); core_fclose(output_toc_file);
@ -2328,7 +2328,7 @@ static void do_extract_ld(parameters_t &params)
frame_bytes = avhuff_encoder::raw_data_size(width, height, channels, max_samples_per_frame); frame_bytes = avhuff_encoder::raw_data_size(width, height, channels, max_samples_per_frame);
if (frame_bytes != input_chd.hunk_bytes()) if (frame_bytes != input_chd.hunk_bytes())
report_error(1, "Frame size does not match hunk size for this CHD"); report_error(1, "Frame size does not match hunk size for this CHD");
// parse out input start/end // parse out input start/end
UINT64 input_start; UINT64 input_start;
UINT64 input_end; UINT64 input_end;
@ -2386,7 +2386,7 @@ static void do_extract_ld(parameters_t &params)
audio_data[chnum].resize(max_samples_per_frame); audio_data[chnum].resize(max_samples_per_frame);
avconfig.audio[chnum] = audio_data[chnum]; avconfig.audio[chnum] = audio_data[chnum];
} }
// iterate over frames // iterate over frames
bitmap_yuy16 fullbitmap(width, height * interlace_factor); bitmap_yuy16 fullbitmap(width, height * interlace_factor);
for (int framenum = input_start; framenum < input_end; framenum++) for (int framenum = input_start; framenum < input_end; framenum++)
@ -2396,7 +2396,7 @@ static void do_extract_ld(parameters_t &params)
// set up the fake bitmap for this frame // 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); 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); input_chd.codec_configure(CHD_CODEC_AVHUFF, AVHUFF_CODEC_DECOMPRESS_CONFIG, &avconfig);
// read the hunk into the buffers // read the hunk into the buffers
chd_error err = input_chd.read_hunk(framenum, NULL); chd_error err = input_chd.read_hunk(framenum, NULL);
if (err != CHDERR_NONE) if (err != CHDERR_NONE)
@ -2454,13 +2454,13 @@ static void do_add_metadata(parameters_t &params)
tag_str->cat(" "); tag_str->cat(" ");
tag = CHD_MAKE_TAG((*tag_str)[0], (*tag_str)[1], (*tag_str)[2], (*tag_str)[3]); tag = CHD_MAKE_TAG((*tag_str)[0], (*tag_str)[1], (*tag_str)[2], (*tag_str)[3]);
} }
// process index // process index
UINT32 index = 0; UINT32 index = 0;
astring *index_str = params.find(OPTION_INDEX); astring *index_str = params.find(OPTION_INDEX);
if (index_str != NULL) if (index_str != NULL)
index = atoi(*index_str); index = atoi(*index_str);
// process text input // process text input
astring *text_str = params.find(OPTION_VALUE_TEXT); astring *text_str = params.find(OPTION_VALUE_TEXT);
astring text; astring text;
@ -2470,7 +2470,7 @@ static void do_add_metadata(parameters_t &params)
if (text[0] == '"' && text[text.len() - 1] == '"') if (text[0] == '"' && text[text.len() - 1] == '"')
text.substr(1, text.len() - 2); text.substr(1, text.len() - 2);
} }
// process file input // process file input
astring *file_str = params.find(OPTION_VALUE_FILE); astring *file_str = params.find(OPTION_VALUE_FILE);
dynamic_buffer file; dynamic_buffer file;
@ -2480,18 +2480,18 @@ static void do_add_metadata(parameters_t &params)
if (filerr != FILERR_NONE) if (filerr != FILERR_NONE)
report_error(1, "Error reading metadata file (%s)", file_str->cstr()); report_error(1, "Error reading metadata file (%s)", file_str->cstr());
} }
// make sure we have one or the other // make sure we have one or the other
if (text_str == NULL && file_str == NULL) if (text_str == NULL && file_str == NULL)
report_error(1, "Error: missing either --valuetext/-vt or --valuefile/-vf parameters"); report_error(1, "Error: missing either --valuetext/-vt or --valuefile/-vf parameters");
if (text_str != NULL && file_str != NULL) if (text_str != NULL && file_str != NULL)
report_error(1, "Error: both --valuetext/-vt or --valuefile/-vf parameters specified; only one permitted"); report_error(1, "Error: both --valuetext/-vt or --valuefile/-vf parameters specified; only one permitted");
// process no checksum // process no checksum
UINT8 flags = CHD_MDFLAGS_CHECKSUM; UINT8 flags = CHD_MDFLAGS_CHECKSUM;
if (params.find(OPTION_NO_CHECKSUM) != NULL) if (params.find(OPTION_NO_CHECKSUM) != NULL)
flags &= ~CHD_MDFLAGS_CHECKSUM; flags &= ~CHD_MDFLAGS_CHECKSUM;
// print some info // print some info
astring tempstr; astring tempstr;
printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr()); printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr());
@ -2516,7 +2516,7 @@ static void do_add_metadata(parameters_t &params)
//------------------------------------------------- //-------------------------------------------------
// do_del_metadata - remove metadata from a CHD // do_del_metadata - remove metadata from a CHD
//------------------------------------------------- //-------------------------------------------------
static void do_del_metadata(parameters_t &params) static void do_del_metadata(parameters_t &params)
@ -2534,13 +2534,13 @@ static void do_del_metadata(parameters_t &params)
tag_str->cat(" "); tag_str->cat(" ");
tag = CHD_MAKE_TAG((*tag_str)[0], (*tag_str)[1], (*tag_str)[2], (*tag_str)[3]); tag = CHD_MAKE_TAG((*tag_str)[0], (*tag_str)[1], (*tag_str)[2], (*tag_str)[3]);
} }
// process index // process index
UINT32 index = 0; UINT32 index = 0;
astring *index_str = params.find(OPTION_INDEX); astring *index_str = params.find(OPTION_INDEX);
if (index_str != NULL) if (index_str != NULL)
index = atoi(*index_str); index = atoi(*index_str);
// print some info // print some info
astring tempstr; astring tempstr;
printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr()); 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]); return print_help(argv[0]);
command = argv[argnum++]; command = argv[argnum++];
} }
// iterate over commands to find our match // iterate over commands to find our match
for (int cmdnum = 0; cmdnum < ARRAY_LENGTH(s_commands); cmdnum++) for (int cmdnum = 0; cmdnum < ARRAY_LENGTH(s_commands); cmdnum++)
if (strcmp(command, s_commands[cmdnum].name) == 0) if (strcmp(command, s_commands[cmdnum].name) == 0)
{ {
const command_description &desc = s_commands[cmdnum]; const command_description &desc = s_commands[cmdnum];
// print help if that was requested // print help if that was requested
if (help) if (help)
return print_help(argv[0], desc); 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"); return print_help(argv[0], desc, "Option is missing parameter");
param = argv[argnum++]; param = argv[argnum++];
} }
// add to the map // add to the map
if (parameters.add(odesc.name, new astring(param)) == TMERR_DUPLICATE) if (parameters.add(odesc.name, new astring(param)) == TMERR_DUPLICATE)
return print_help(argv[0], desc, "Multiple parameters of the same type specified"); 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)) if (valid == ARRAY_LENGTH(desc.valid_options))
return print_help(argv[0], desc, "Option not valid for this command"); return print_help(argv[0], desc, "Option not valid for this command");
} }
// make sure we got all our required parameters // make sure we got all our required parameters
for (int valid = 0; valid < ARRAY_LENGTH(desc.valid_options); valid++) 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) if (*validname == REQUIRED[0] && parameters.find(++validname) == NULL)
return print_help(argv[0], desc, "Required parameters missing"); return print_help(argv[0], desc, "Required parameters missing");
} }
// all clear, run the command // all clear, run the command
try try
{ {
@ -2673,7 +2673,7 @@ int CLIB_DECL main(int argc, char *argv[])
return 1; return 1;
} }
} }
// print generic help if nothing found // print generic help if nothing found
return print_help(argv[0]); return print_help(argv[0]);
} }

View File

@ -38,4 +38,4 @@
***************************************************************************/ ***************************************************************************/
extern const char build_version[]; extern const char build_version[];
const char build_version[] = "0.145 ("__DATE__")"; const char build_version[] = "0.145u1 ("__DATE__")";