mirror of
https://github.com/holub/mame
synced 2025-04-22 08:22:15 +03:00
Simplify snapshot/quickload callback parameters; remove some uses of auto_alloc_array
This commit is contained in:
parent
17f0286d73
commit
b75fade787
@ -48,7 +48,7 @@ snapshot_image_device::~snapshot_image_device()
|
||||
TIMER_CALLBACK_MEMBER(snapshot_image_device::process_snapshot_or_quickload)
|
||||
{
|
||||
/* invoke the load */
|
||||
m_load(*this, filetype().c_str(), length());
|
||||
m_load(*this);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -20,7 +20,7 @@ class snapshot_image_device : public device_t,
|
||||
public device_image_interface
|
||||
{
|
||||
public:
|
||||
typedef device_delegate<image_init_result (device_image_interface &, const char *, int)> load_delegate;
|
||||
typedef device_delegate<image_init_result (device_image_interface &)> load_delegate;
|
||||
|
||||
// construction/destruction
|
||||
snapshot_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const char* extensions, attotime delay = attotime::zero)
|
||||
@ -94,10 +94,10 @@ DECLARE_DEVICE_TYPE(QUICKLOAD, quickload_image_device)
|
||||
/***************************************************************************
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
#define SNAPSHOT_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image, const char *file_type, int snapshot_size)
|
||||
#define SNAPSHOT_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image)
|
||||
#define DECLARE_SNAPSHOT_LOAD_MEMBER(_name) SNAPSHOT_LOAD_MEMBER(_name)
|
||||
|
||||
#define QUICKLOAD_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image, const char *file_type, int quickload_size)
|
||||
#define QUICKLOAD_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image)
|
||||
#define DECLARE_QUICKLOAD_LOAD_MEMBER(_name) QUICKLOAD_LOAD_MEMBER(_name)
|
||||
|
||||
#endif // MAME_DEVICES_IMAGEDEV_SNAPQUIK_H
|
||||
|
@ -462,8 +462,8 @@ QUICKLOAD_LOAD_MEMBER(abc80_state::quickload_cb)
|
||||
offs_t address = space.read_byte(BOFA + 1) << 8 | space.read_byte(BOFA);
|
||||
if (LOG) logerror("BOFA %04x\n",address);
|
||||
|
||||
std::vector<u8> data;
|
||||
data.resize(quickload_size);
|
||||
int quickload_size = image.length();
|
||||
std::vector<u8> data(quickload_size);
|
||||
image.fread(&data[0], quickload_size);
|
||||
for (int i = 1; i < quickload_size; i++)
|
||||
space.write_byte(address++, data[i]);
|
||||
|
@ -971,8 +971,8 @@ QUICKLOAD_LOAD_MEMBER(abc800_state::quickload_cb)
|
||||
{
|
||||
address_space &space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
std::vector<uint8_t> data;
|
||||
data.resize(quickload_size);
|
||||
size_t quickload_size = image.length();
|
||||
std::vector<uint8_t> data(quickload_size);
|
||||
image.fread(&data[0], quickload_size);
|
||||
|
||||
uint8_t prstat = data[2];
|
||||
|
@ -301,7 +301,7 @@ QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb)
|
||||
{
|
||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
setup_banks(2);
|
||||
@ -314,6 +314,7 @@ QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb)
|
||||
}
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
uint16_t quickload_size = image.length();
|
||||
for (uint16_t i = 0; i < quickload_size; i++)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -406,7 +406,7 @@ QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb)
|
||||
{
|
||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* RAM must be banked in */
|
||||
@ -423,6 +423,7 @@ QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb)
|
||||
}
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
u16 quickload_size = image.length();
|
||||
for (u16 i = 0; i < quickload_size; i++)
|
||||
{
|
||||
u8 data;
|
||||
|
@ -275,7 +275,7 @@ enum
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(c128_state::quickload_c128)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -423,7 +423,7 @@ enum
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(c64_state::quickload_c64)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -342,12 +342,12 @@ static void cbmb_quick_sethiaddress(address_space &space, uint16_t hiaddress)
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(cbm2_state::quickload_cbmb)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0x10000, cbmb_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0x10000, cbmb_quick_sethiaddress);
|
||||
}
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(p500_state::quickload_p500)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbmb_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0, cbmb_quick_sethiaddress);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
|
@ -400,10 +400,11 @@ QUICKLOAD_LOAD_MEMBER(dmv_state::quickload_cb)
|
||||
if ((m_ram->base()[0] != 0xc3) || (m_ram->base()[5] != 0xc3))
|
||||
return image_init_result::FAIL;
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
uint16_t quickload_size = image.length();
|
||||
for (uint16_t i = 0; i < quickload_size; i++)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -829,7 +829,7 @@ QUICKLOAD_LOAD_MEMBER(einstein_state::quickload_cb)
|
||||
{
|
||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* disable rom */
|
||||
@ -837,6 +837,7 @@ QUICKLOAD_LOAD_MEMBER(einstein_state::quickload_cb)
|
||||
m_bank1->set_entry(m_rom_enabled);
|
||||
|
||||
/* load image */
|
||||
uint16_t quickload_size = image.length();
|
||||
for (uint16_t i = 0; i < quickload_size; i++)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -214,9 +214,9 @@ private:
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(iris3000_state::load_romboard)
|
||||
{
|
||||
m_file_data.resize(quickload_size);
|
||||
m_file_data.resize(image.length());
|
||||
|
||||
if (!quickload_size || image.fread(&m_file_data[0], quickload_size) != quickload_size)
|
||||
if (image.length() == 0 || image.fread(&m_file_data[0], image.length()) != image.length())
|
||||
{
|
||||
m_file_data.clear();
|
||||
return image_init_result::FAIL;
|
||||
|
@ -1908,12 +1908,12 @@ void jaguarcd_state::init_jaguarcd()
|
||||
save_item(NAME(m_joystick_data));
|
||||
}
|
||||
|
||||
image_init_result jaguar_state::quickload_cb(device_image_interface &image, const char *file_type, int quickload_size)
|
||||
image_init_result jaguar_state::quickload_cb(device_image_interface &image)
|
||||
{
|
||||
offs_t quickload_begin = 0x4000, start = quickload_begin, skip = 0;
|
||||
|
||||
memset(m_shared_ram, 0, 0x200000);
|
||||
quickload_size = std::min(quickload_size, int(0x200000 - quickload_begin));
|
||||
offs_t quickload_size = std::min(offs_t(image.length()), 0x200000 - quickload_begin);
|
||||
|
||||
image.fread( &memregion("maincpu")->base()[quickload_begin], quickload_size);
|
||||
|
||||
|
@ -469,7 +469,7 @@ static void cbm_pet_quick_sethiaddress( address_space &space, uint16_t hiaddress
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(pet_state::quickload_pet)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_pet_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0, cbm_pet_quick_sethiaddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,7 +191,7 @@ private:
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(plus4_state::quickload_c16)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
|
@ -477,9 +477,9 @@ void psx1_state::parallel_w(offs_t offset, uint16_t data)
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(psx1_state::quickload_exe)
|
||||
{
|
||||
m_exe_buffer.resize(quickload_size);
|
||||
m_exe_buffer.resize(image.length());
|
||||
|
||||
if (image.fread(reinterpret_cast<void *>(&m_exe_buffer[0]), quickload_size) != quickload_size)
|
||||
if (image.fread(reinterpret_cast<void *>(&m_exe_buffer[0]), image.length()) != image.length())
|
||||
{
|
||||
m_exe_buffer.resize(0);
|
||||
return image_init_result::FAIL;
|
||||
|
@ -329,7 +329,7 @@ QUICKLOAD_LOAD_MEMBER(qx10_state::quickload_cb)
|
||||
{
|
||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* The right RAM bank must be active */
|
||||
@ -344,6 +344,7 @@ QUICKLOAD_LOAD_MEMBER(qx10_state::quickload_cb)
|
||||
}
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
uint16_t quickload_size = image.length();
|
||||
for (uint16_t i = 0; i < quickload_size; i++)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -408,7 +408,7 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb)
|
||||
{
|
||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* The right RAM bank must be active */
|
||||
@ -421,6 +421,7 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb)
|
||||
}
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
uint16_t quickload_size = image.length();
|
||||
for (uint16_t i = 0; i < quickload_size; i++)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -2712,10 +2712,10 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file)
|
||||
{
|
||||
m_vgmplay->stop();
|
||||
|
||||
m_file_data.resize(quickload_size);
|
||||
m_file_data.resize(image.length());
|
||||
|
||||
if (!quickload_size ||
|
||||
image.fread(&m_file_data[0], quickload_size) != quickload_size)
|
||||
if (image.length() == 0 ||
|
||||
image.fread(&m_file_data[0], image.length()) != image.length())
|
||||
{
|
||||
m_file_data.clear();
|
||||
return image_init_result::FAIL;
|
||||
|
@ -164,7 +164,7 @@ private:
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(vic20_state::quickload_vc20)
|
||||
{
|
||||
return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
return general_cbm_loadsnap(image, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
|
@ -171,7 +171,7 @@ SNAPSHOT_LOAD_MEMBER(vtech1_base_state::snapshot_cb)
|
||||
|
||||
// get start and end addresses
|
||||
uint16_t start = pick_integer_le(header, 22, 2);
|
||||
uint16_t end = start + snapshot_size - sizeof(header);
|
||||
uint16_t end = start + image.length() - sizeof(header);
|
||||
uint16_t size = end - start;
|
||||
|
||||
// write it to ram
|
||||
|
@ -410,7 +410,7 @@ QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb)
|
||||
{
|
||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
bankswitch(0);
|
||||
@ -423,6 +423,7 @@ QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb)
|
||||
}
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
uint16_t quickload_size = image.length();
|
||||
for (uint16_t i = 0; i < quickload_size; i++)
|
||||
{
|
||||
uint8_t data;
|
||||
|
@ -331,10 +331,10 @@ SNAPSHOT_LOAD_MEMBER(z1013_state::snapshot_cb)
|
||||
0020 up - Program to load
|
||||
*/
|
||||
|
||||
uint8_t* data= auto_alloc_array(machine(), uint8_t, snapshot_size);
|
||||
std::vector<uint8_t> data(image.length());
|
||||
uint16_t startaddr,endaddr,runaddr;
|
||||
|
||||
image.fread( data, snapshot_size);
|
||||
image.fread(&data[0], image.length());
|
||||
|
||||
startaddr = data[0] + data[1]*256;
|
||||
endaddr = data[2] + data[3]*256;
|
||||
@ -350,7 +350,7 @@ SNAPSHOT_LOAD_MEMBER(z1013_state::snapshot_cb)
|
||||
}
|
||||
|
||||
memcpy (m_maincpu->space(AS_PROGRAM).get_read_ptr(startaddr),
|
||||
data+0x20, endaddr - startaddr + 1);
|
||||
&data[0x20], endaddr - startaddr + 1);
|
||||
|
||||
if (runaddr)
|
||||
m_maincpu->set_state_int(Z80_PC, runaddr);
|
||||
|
@ -266,7 +266,7 @@ private:
|
||||
DECLARE_WRITE_LINE_MEMBER( dsp_cpu_int );
|
||||
DECLARE_WRITE_LINE_MEMBER( external_int );
|
||||
|
||||
image_init_result quickload_cb(device_image_interface &image, const char *file_type, int quickload_size);
|
||||
image_init_result quickload_cb(device_image_interface &image);
|
||||
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( cart_load );
|
||||
void cpu_space_map(address_map &map);
|
||||
void dsp_map(address_map &map);
|
||||
|
@ -3257,16 +3257,14 @@ MACHINE_RESET_MEMBER(amstrad_state,aleste)
|
||||
/* load snapshot */
|
||||
SNAPSHOT_LOAD_MEMBER(amstrad_state::snapshot_cb)
|
||||
{
|
||||
std::vector<uint8_t> snapshot;
|
||||
|
||||
/* get file size */
|
||||
if (snapshot_size < 8)
|
||||
if (image.length() < 8)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
snapshot.resize(snapshot_size);
|
||||
std::vector<uint8_t> snapshot(image.length());
|
||||
|
||||
/* read whole file */
|
||||
image.fread(&snapshot[0], snapshot_size);
|
||||
image.fread(&snapshot[0], image.length());
|
||||
|
||||
if (memcmp(&snapshot[0], "MV - SNA", 8))
|
||||
{
|
||||
|
@ -24,8 +24,8 @@
|
||||
* 0x001c data */
|
||||
|
||||
|
||||
image_init_result general_cbm_loadsnap( device_image_interface &image, const char *file_type, int snapshot_size,
|
||||
address_space &space, offs_t offset, void (*cbm_sethiaddress)(address_space &space, uint16_t hiaddress) )
|
||||
image_init_result general_cbm_loadsnap( device_image_interface &image, address_space &space, offs_t offset,
|
||||
void (*cbm_sethiaddress)(address_space &space, uint16_t hiaddress) )
|
||||
{
|
||||
char buffer[7];
|
||||
std::vector<uint8_t> data;
|
||||
@ -33,14 +33,13 @@ image_init_result general_cbm_loadsnap( device_image_interface &image, const cha
|
||||
uint16_t address = 0;
|
||||
int i;
|
||||
|
||||
if (!file_type)
|
||||
goto error;
|
||||
int snapshot_size = image.length();
|
||||
|
||||
if (!core_stricmp(file_type, "prg"))
|
||||
if (image.is_filetype("prg"))
|
||||
{
|
||||
/* prg files */
|
||||
}
|
||||
else if (!core_stricmp(file_type, "p00"))
|
||||
else if (image.is_filetype("p00"))
|
||||
{
|
||||
/* p00 files */
|
||||
if (image.fread( buffer, sizeof(buffer)) != sizeof(buffer))
|
||||
@ -50,7 +49,7 @@ image_init_result general_cbm_loadsnap( device_image_interface &image, const cha
|
||||
image.fseek(26, SEEK_SET);
|
||||
snapshot_size -= 26;
|
||||
}
|
||||
else if (!core_stricmp(file_type, "t64"))
|
||||
else if (image.is_filetype("t64"))
|
||||
{
|
||||
/* t64 files - for GB64 Single T64s loading to x0801 - header is always the same size */
|
||||
if (image.fread( buffer, sizeof(buffer)) != sizeof(buffer))
|
||||
@ -67,7 +66,7 @@ image_init_result general_cbm_loadsnap( device_image_interface &image, const cha
|
||||
|
||||
image.fread( &address, 2);
|
||||
address = little_endianize_int16(address);
|
||||
if (!core_stricmp(file_type, "t64"))
|
||||
if (image.is_filetype("t64"))
|
||||
address = 2049;
|
||||
snapshot_size -= 2;
|
||||
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
image_init_result general_cbm_loadsnap(
|
||||
device_image_interface &image,
|
||||
const char *file_type,
|
||||
int snapshot_size,
|
||||
address_space &space,
|
||||
offs_t offset,
|
||||
void (*cbm_sethiaddress)(address_space &space, uint16_t hiaddress));
|
||||
|
@ -117,21 +117,20 @@ void galaxy_state::setup_snapshot(const uint8_t * data, uint32_t size)
|
||||
|
||||
SNAPSHOT_LOAD_MEMBER(galaxy_state::snapshot_cb)
|
||||
{
|
||||
uint8_t* snapshot_data;
|
||||
|
||||
uint32_t snapshot_size = image.length();
|
||||
switch (snapshot_size)
|
||||
{
|
||||
case GALAXY_SNAPSHOT_V1_SIZE:
|
||||
case GALAXY_SNAPSHOT_V2_SIZE:
|
||||
snapshot_data = auto_alloc_array(machine(), uint8_t, snapshot_size);
|
||||
break;
|
||||
default:
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
image.fread( snapshot_data, snapshot_size);
|
||||
std::vector<uint8_t> snapshot_data(snapshot_size);
|
||||
image.fread(&snapshot_data[0], snapshot_size);
|
||||
|
||||
setup_snapshot(snapshot_data, snapshot_size);
|
||||
setup_snapshot(&snapshot_data[0], snapshot_size);
|
||||
|
||||
return image_init_result::PASS;
|
||||
}
|
||||
|
@ -273,10 +273,11 @@ QUICKLOAD_LOAD_MEMBER(kaypro_state::quickload_cb)
|
||||
if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3))
|
||||
return image_init_result::FAIL;
|
||||
|
||||
if (quickload_size >= 0xfd00)
|
||||
if (image.length() >= 0xfd00)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* Load image to the TPA (Transient Program Area) */
|
||||
u16 quickload_size = image.length();
|
||||
for (u16 i = 0; i < quickload_size; i++)
|
||||
{
|
||||
u8 data;
|
||||
|
@ -297,7 +297,7 @@ SNAPSHOT_LOAD_MEMBER(lviv_state::snapshot_cb)
|
||||
|
||||
image.fread(&snapshot_data[0], LVIV_SNAPSHOT_SIZE);
|
||||
|
||||
if (verify_snapshot(&snapshot_data[0], snapshot_size) != image_verify_result::PASS)
|
||||
if (verify_snapshot(&snapshot_data[0], image.length()) != image_verify_result::PASS)
|
||||
{
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
@ -583,6 +583,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_bee)
|
||||
uint16_t i, j;
|
||||
uint8_t data, sw = m_io_config->read() & 1; /* reading the config switch: 1 = autorun */
|
||||
|
||||
size_t quickload_size = image.length();
|
||||
if (image.is_filetype("mwb"))
|
||||
{
|
||||
/* mwb files - standard basic files */
|
||||
@ -677,7 +678,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_bin)
|
||||
address_space &space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
/* load the binary into memory */
|
||||
if (z80bin_load_file(&image, space, file_type, &execute_address, &start_addr, &end_addr) != image_init_result::PASS)
|
||||
if (z80bin_load_file(image, space, execute_address, start_addr, end_addr) != image_init_result::PASS)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* is this file executable? */
|
||||
|
@ -671,10 +671,10 @@ SNAPSHOT_LOAD_MEMBER(microtan_state::snapshot_cb)
|
||||
if (!snapshot_buff)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
if (verify_snapshot(snapshot_buff, snapshot_size) != image_verify_result::PASS)
|
||||
if (verify_snapshot(snapshot_buff, image.length()) != image_verify_result::PASS)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
snapshot_copy(snapshot_buff, snapshot_size);
|
||||
snapshot_copy(snapshot_buff, image.length());
|
||||
return image_init_result::PASS;
|
||||
}
|
||||
|
||||
@ -682,12 +682,12 @@ QUICKLOAD_LOAD_MEMBER(microtan_state::quickload_cb)
|
||||
{
|
||||
int snapshot_size = 8263; /* magic size */
|
||||
std::vector<uint8_t> snapshot_buff(snapshot_size, 0);
|
||||
std::vector<char> buff(quickload_size + 1);
|
||||
std::vector<char> buff(image.length() + 1);
|
||||
image_init_result rc;
|
||||
|
||||
image.fread(&buff[0], quickload_size);
|
||||
image.fread(&buff[0], image.length());
|
||||
|
||||
buff[quickload_size] = '\0';
|
||||
buff[image.length()] = '\0';
|
||||
|
||||
if (buff[0] == ':')
|
||||
rc = parse_intel_hex(&snapshot_buff[0], &buff[0]);
|
||||
|
@ -468,7 +468,7 @@ SNAPSHOT_LOAD_MEMBER(mtx_state::snapshot_cb)
|
||||
}
|
||||
|
||||
// write actual image data
|
||||
uint16_t data_size = snapshot_size - 18 - system_variables_size;
|
||||
uint16_t data_size = image.length() - 18 - system_variables_size;
|
||||
for (int i = 0; i < data_size; i++)
|
||||
program.write_byte(0x4000 + i, data[18 + system_variables_size + i]);
|
||||
|
||||
@ -486,7 +486,7 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb)
|
||||
address_space &program = m_maincpu->space(AS_PROGRAM);
|
||||
uint8_t *data = (uint8_t*)image.ptr();
|
||||
|
||||
if (quickload_size < 4)
|
||||
if (image.length() < 4)
|
||||
{
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
|
||||
return image_init_result::FAIL;
|
||||
@ -495,7 +495,7 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb)
|
||||
uint16_t code_base = pick_integer_le(data, 0, 2);
|
||||
uint16_t code_length = pick_integer_le(data, 2, 2);
|
||||
|
||||
if (quickload_size < code_length)
|
||||
if (image.length() < code_length)
|
||||
{
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
|
||||
return image_init_result::FAIL;
|
||||
|
@ -240,7 +240,7 @@ void poly88_state::intr_w(uint8_t data)
|
||||
SNAPSHOT_LOAD_MEMBER(poly88_state::snapshot_cb)
|
||||
{
|
||||
address_space &space = m_maincpu->space(AS_PROGRAM);
|
||||
uint8_t* data= auto_alloc_array(machine(), uint8_t, snapshot_size);
|
||||
int snapshot_size = image.length();
|
||||
uint16_t recordNum;
|
||||
uint16_t recordLen;
|
||||
uint16_t address;
|
||||
@ -251,7 +251,8 @@ SNAPSHOT_LOAD_MEMBER(poly88_state::snapshot_cb)
|
||||
int i = 0;
|
||||
int theend = 0;
|
||||
|
||||
image.fread( data, snapshot_size);
|
||||
std::vector<uint8_t> data(snapshot_size);
|
||||
image.fread(&data[0], snapshot_size);
|
||||
|
||||
while (pos<snapshot_size) {
|
||||
for(i=0;i<9;i++) {
|
||||
@ -260,7 +261,7 @@ SNAPSHOT_LOAD_MEMBER(poly88_state::snapshot_cb)
|
||||
pos+=8;
|
||||
name[8] = 0;
|
||||
|
||||
|
||||
// FIXME: this risks buffer overruns
|
||||
recordNum = data[pos]+ data[pos+1]*256; pos+=2;
|
||||
recordLen = data[pos]; pos++;
|
||||
if (recordLen==0) recordLen=0x100;
|
||||
|
@ -283,9 +283,9 @@ void primo_state::setup_pss (uint8_t* snapshot_data, uint32_t snapshot_size)
|
||||
|
||||
SNAPSHOT_LOAD_MEMBER(primo_state::snapshot_cb)
|
||||
{
|
||||
std::vector<uint8_t> snapshot_data(snapshot_size);
|
||||
std::vector<uint8_t> snapshot_data(image.length());
|
||||
|
||||
if (image.fread(&snapshot_data[0], snapshot_size) != snapshot_size)
|
||||
if (image.fread(&snapshot_data[0], image.length()) != image.length())
|
||||
{
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
@ -295,7 +295,7 @@ SNAPSHOT_LOAD_MEMBER(primo_state::snapshot_cb)
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
setup_pss(&snapshot_data[0], snapshot_size);
|
||||
setup_pss(&snapshot_data[0], image.length());
|
||||
|
||||
return image_init_result::PASS;
|
||||
}
|
||||
@ -322,6 +322,7 @@ void primo_state::setup_pp(uint8_t* quickload_data, uint32_t quickload_size)
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(primo_state::quickload_cb)
|
||||
{
|
||||
size_t quickload_size = image.length();
|
||||
std::vector<uint8_t> quickload_data(quickload_size);
|
||||
|
||||
if (image.fread(&quickload_data[0], quickload_size) != quickload_size)
|
||||
|
@ -539,7 +539,7 @@ SNAPSHOT_LOAD_MEMBER(sorcerer_state::snapshot_cb)
|
||||
unsigned char s_byte;
|
||||
|
||||
/* check size */
|
||||
if (snapshot_size != 0x1001c)
|
||||
if (image.length() != 0x1001c)
|
||||
{
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Snapshot must be 65564 bytes");
|
||||
image.message("Snapshot must be 65564 bytes");
|
||||
@ -591,7 +591,7 @@ QUICKLOAD_LOAD_MEMBER(sorcerer_state::quickload_cb)
|
||||
address_space &space = m_maincpu->space(AS_PROGRAM);
|
||||
|
||||
/* load the binary into memory */
|
||||
if (z80bin_load_file(&image, space, file_type, &execute_address, &start_address, &end_address) != image_init_result::PASS)
|
||||
if (z80bin_load_file(image, space, execute_address, start_address, end_address) != image_init_result::PASS)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
/* is this file executable? */
|
||||
|
@ -110,11 +110,12 @@ void spectrum_state::page_basicrom()
|
||||
|
||||
SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
{
|
||||
size_t snapshot_size = image.length();
|
||||
std::vector<uint8_t> snapshot_data(snapshot_size);
|
||||
|
||||
image.fread(&snapshot_data[0], snapshot_size);
|
||||
|
||||
if (!core_stricmp(file_type, "sna"))
|
||||
if (image.is_filetype("sna"))
|
||||
{
|
||||
if ((snapshot_size != SNA48_SIZE) && (snapshot_size != SNA128_SIZE_1) && (snapshot_size != SNA128_SIZE_2))
|
||||
{
|
||||
@ -123,7 +124,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_sna(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "sp"))
|
||||
else if (image.is_filetype("sp"))
|
||||
{
|
||||
if ((snapshot_data[0] != 'S' && snapshot_data[1] != 'P') && (snapshot_size != SP_NEW_SIZE_16K && snapshot_size != SP_NEW_SIZE_48K))
|
||||
{
|
||||
@ -135,7 +136,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_sp(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "ach"))
|
||||
else if (image.is_filetype("ach"))
|
||||
{
|
||||
if (snapshot_size != ACH_SIZE)
|
||||
{
|
||||
@ -144,7 +145,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_ach(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "prg"))
|
||||
else if (image.is_filetype("prg"))
|
||||
{
|
||||
if (snapshot_size != PRG_SIZE)
|
||||
{
|
||||
@ -153,7 +154,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_prg(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "plusd"))
|
||||
else if (image.is_filetype("plusd"))
|
||||
{
|
||||
if ((snapshot_size != PLUSD48_SIZE) && (snapshot_size != PLUSD128_SIZE))
|
||||
{
|
||||
@ -162,7 +163,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_plusd(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "sem"))
|
||||
else if (image.is_filetype("sem"))
|
||||
{
|
||||
if (snapshot_data[0] != 0x05 && snapshot_data[1] != 'S' && \
|
||||
snapshot_data[2] != 'P' && snapshot_data[3] != 'E' && \
|
||||
@ -176,7 +177,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_sem(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "sit"))
|
||||
else if (image.is_filetype("sit"))
|
||||
{
|
||||
if (snapshot_size != SIT_SIZE)
|
||||
{
|
||||
@ -185,7 +186,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_sit(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "zx"))
|
||||
else if (image.is_filetype("zx"))
|
||||
{
|
||||
if (snapshot_size != ZX_SIZE)
|
||||
{
|
||||
@ -194,7 +195,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_zx(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "snp"))
|
||||
else if (image.is_filetype("snp"))
|
||||
{
|
||||
if (snapshot_size != SNP_SIZE)
|
||||
{
|
||||
@ -203,7 +204,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_snp(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "snx"))
|
||||
else if (image.is_filetype("snx"))
|
||||
{
|
||||
if (snapshot_data[0] != 'X' && snapshot_data[1] != 'S' && \
|
||||
snapshot_data[2] != 'N' && snapshot_data[3] != 'A')
|
||||
@ -213,7 +214,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb)
|
||||
}
|
||||
setup_snx(&snapshot_data[0], snapshot_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "frz"))
|
||||
else if (image.is_filetype("frz"))
|
||||
{
|
||||
if (snapshot_size != FRZ_SIZE)
|
||||
{
|
||||
@ -2417,11 +2418,12 @@ void spectrum_state::setup_z80(uint8_t *snapdata, uint32_t snapsize)
|
||||
|
||||
QUICKLOAD_LOAD_MEMBER(spectrum_state::quickload_cb)
|
||||
{
|
||||
size_t quickload_size = image.length();
|
||||
std::vector<uint8_t> quickload_data(quickload_size);
|
||||
|
||||
image.fread(&quickload_data[0], quickload_size);
|
||||
|
||||
if (!core_stricmp(file_type, "scr"))
|
||||
if (image.is_filetype("scr"))
|
||||
{
|
||||
if ((quickload_size != SCR_SIZE) && (quickload_size != SCR_BITMAP))
|
||||
{
|
||||
@ -2430,7 +2432,7 @@ QUICKLOAD_LOAD_MEMBER(spectrum_state::quickload_cb)
|
||||
}
|
||||
setup_scr(&quickload_data[0], quickload_size);
|
||||
}
|
||||
else if (!core_stricmp(file_type, "raw"))
|
||||
else if (image.is_filetype("raw"))
|
||||
{
|
||||
if (quickload_size != RAW_SIZE)
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ QUICKLOAD_LOAD_MEMBER(super80_state::quickload_cb)
|
||||
uint16_t exec_addr, start_addr, end_addr;
|
||||
|
||||
// load the binary into memory
|
||||
if (z80bin_load_file(&image, m_maincpu->space(AS_PROGRAM), file_type, &exec_addr, &start_addr, &end_addr) != image_init_result::PASS)
|
||||
if (z80bin_load_file(image, m_maincpu->space(AS_PROGRAM), exec_addr, start_addr, end_addr) != image_init_result::PASS)
|
||||
return image_init_result::FAIL;
|
||||
|
||||
// is this file executable?
|
||||
|
@ -1219,7 +1219,6 @@ void ti85_state::ti86_setup_snapshot (uint8_t * data)
|
||||
SNAPSHOT_LOAD_MEMBER(ti85_state::snapshot_cb)
|
||||
{
|
||||
int expected_snapshot_size = 0;
|
||||
std::vector<uint8_t> ti8x_snapshot_data;
|
||||
|
||||
if (!strncmp(machine().system().name, "ti85", 4))
|
||||
expected_snapshot_size = TI85_SNAPSHOT_SIZE;
|
||||
@ -1228,15 +1227,14 @@ SNAPSHOT_LOAD_MEMBER(ti85_state::snapshot_cb)
|
||||
|
||||
logerror("Snapshot loading\n");
|
||||
|
||||
if (snapshot_size != expected_snapshot_size)
|
||||
if (image.length() != expected_snapshot_size)
|
||||
{
|
||||
logerror ("Incomplete snapshot file\n");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
ti8x_snapshot_data.resize(snapshot_size);
|
||||
|
||||
image.fread( &ti8x_snapshot_data[0], snapshot_size);
|
||||
std::vector<uint8_t> ti8x_snapshot_data(image.length());
|
||||
image.fread( &ti8x_snapshot_data[0], image.length());
|
||||
|
||||
if (!strncmp(machine().system().name, "ti85", 4))
|
||||
ti85_setup_snapshot(&ti8x_snapshot_data[0]);
|
||||
|
@ -8,7 +8,7 @@
|
||||
memory
|
||||
-------------------------------------------------*/
|
||||
|
||||
image_init_result z80bin_load_file(device_image_interface *image, address_space &space, const char *file_type, uint16_t *exec_addr, uint16_t *start_addr, uint16_t *end_addr)
|
||||
image_init_result z80bin_load_file(device_image_interface &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr)
|
||||
{
|
||||
int ch;
|
||||
uint16_t args[3];
|
||||
@ -17,14 +17,14 @@ image_init_result z80bin_load_file(device_image_interface *image, address_space
|
||||
char pgmname[256];
|
||||
char message[512];
|
||||
|
||||
image->fseek(7, SEEK_SET);
|
||||
image.fseek(7, SEEK_SET);
|
||||
|
||||
while((ch = image->fgetc()) != 0x1A)
|
||||
while((ch = image.fgetc()) != 0x1A)
|
||||
{
|
||||
if (ch == EOF)
|
||||
{
|
||||
image->seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file name");
|
||||
image->message(" Unexpected EOF while getting file name");
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file name");
|
||||
image.message(" Unexpected EOF while getting file name");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
@ -32,8 +32,8 @@ image_init_result z80bin_load_file(device_image_interface *image, address_space
|
||||
{
|
||||
if (i >= (ARRAY_LENGTH(pgmname) - 1))
|
||||
{
|
||||
image->seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long");
|
||||
image->message(" File name too long");
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long");
|
||||
image.message(" File name too long");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
@ -44,30 +44,30 @@ image_init_result z80bin_load_file(device_image_interface *image, address_space
|
||||
|
||||
pgmname[i] = '\0'; /* terminate string with a null */
|
||||
|
||||
if (image->fread(args, sizeof(args)) != sizeof(args))
|
||||
if (image.fread(args, sizeof(args)) != sizeof(args))
|
||||
{
|
||||
image->seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size");
|
||||
image->message(" Unexpected EOF while getting file size");
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size");
|
||||
image.message(" Unexpected EOF while getting file size");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
exec_addr[0] = little_endianize_int16(args[0]);
|
||||
start_addr[0] = little_endianize_int16(args[1]);
|
||||
end_addr[0] = little_endianize_int16(args[2]);
|
||||
exec_addr = little_endianize_int16(args[0]);
|
||||
start_addr = little_endianize_int16(args[1]);
|
||||
end_addr = little_endianize_int16(args[2]);
|
||||
|
||||
size = (end_addr[0] - start_addr[0] + 1) & 0xffff;
|
||||
size = (end_addr - start_addr + 1) & 0xffff;
|
||||
|
||||
/* display a message about the loaded quickload */
|
||||
image->message(" %s\nsize=%04X : start=%04X : end=%04X : exec=%04X",pgmname,size,start_addr[0],end_addr[0],exec_addr[0]);
|
||||
image.message(" %s\nsize=%04X : start=%04X : end=%04X : exec=%04X",pgmname,size,start_addr,end_addr,exec_addr);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
j = (start_addr[0] + i) & 0xffff;
|
||||
if (image->fread(&data, 1) != 1)
|
||||
j = (start_addr + i) & 0xffff;
|
||||
if (image.fread(&data, 1) != 1)
|
||||
{
|
||||
snprintf(message, ARRAY_LENGTH(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
|
||||
image->seterror(IMAGE_ERROR_INVALIDIMAGE, message);
|
||||
image->message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
|
||||
image.seterror(IMAGE_ERROR_INVALIDIMAGE, message);
|
||||
image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
space.write_byte(j, data);
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
image_init_result z80bin_load_file(device_image_interface *image, address_space &space, const char *file_type, uint16_t *exec_addr, uint16_t *start_addr, uint16_t *end_addr);
|
||||
image_init_result z80bin_load_file(device_image_interface &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr);
|
||||
|
||||
#endif // MAME_MACHINE_Z80BIN_H
|
||||
|
Loading…
Reference in New Issue
Block a user