mirror of
https://github.com/holub/mame
synced 2025-04-27 18:53:05 +03:00
mtx.c: Improve snapshot loading
This commit is contained in:
parent
a4f86de597
commit
ed9bab35b6
@ -372,7 +372,7 @@ static MACHINE_CONFIG_START( mtx512, mtx_state )
|
|||||||
MCFG_Z80CTC_ADD(Z80CTC_TAG, XTAL_4MHz, ctc_intf )
|
MCFG_Z80CTC_ADD(Z80CTC_TAG, XTAL_4MHz, ctc_intf )
|
||||||
MCFG_TIMER_DRIVER_ADD_PERIODIC("z80ctc_timer", mtx_state, ctc_tick, attotime::from_hz(XTAL_4MHz/13))
|
MCFG_TIMER_DRIVER_ADD_PERIODIC("z80ctc_timer", mtx_state, ctc_tick, attotime::from_hz(XTAL_4MHz/13))
|
||||||
MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, standard_centronics)
|
MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, standard_centronics)
|
||||||
MCFG_SNAPSHOT_ADD("snapshot", mtx_state, mtx, "mtb", 0.5)
|
MCFG_SNAPSHOT_ADD("snapshot", mtx_state, mtx, "mtx", 1)
|
||||||
MCFG_CASSETTE_ADD("cassette", mtx_cassette_interface)
|
MCFG_CASSETTE_ADD("cassette", mtx_cassette_interface)
|
||||||
MCFG_TIMER_DRIVER_ADD_PERIODIC("cassette_timer", mtx_state, cassette_tick, attotime::from_hz(44100))
|
MCFG_TIMER_DRIVER_ADD_PERIODIC("cassette_timer", mtx_state, cassette_tick, attotime::from_hz(44100))
|
||||||
|
|
||||||
|
@ -323,36 +323,58 @@ WRITE8_MEMBER(mtx_state::hrx_attr_w)
|
|||||||
SNAPSHOT
|
SNAPSHOT
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
// this only works for some of the files, nothing which tries to load
|
||||||
|
// more data from tape. todo: tapes which autorun after loading
|
||||||
SNAPSHOT_LOAD_MEMBER( mtx_state, mtx )
|
SNAPSHOT_LOAD_MEMBER( mtx_state, mtx )
|
||||||
{
|
{
|
||||||
address_space &program = m_maincpu->space(AS_PROGRAM);
|
address_space &program = m_maincpu->space(AS_PROGRAM);
|
||||||
|
void *ptr;
|
||||||
UINT8 header[18];
|
UINT8 header[18];
|
||||||
UINT16 addr;
|
|
||||||
|
|
||||||
/* get the header */
|
// read header
|
||||||
image.fread( &header, sizeof(header));
|
image.fread(&header, sizeof(header));
|
||||||
|
|
||||||
if (header[0] == 0xff)
|
// verify first byte
|
||||||
|
if (header[0] != 0xff)
|
||||||
{
|
{
|
||||||
/* long header */
|
image.seterror(IMAGE_ERROR_INVALIDIMAGE, NULL);
|
||||||
addr = pick_integer_le(header, 16, 2);
|
return IMAGE_INIT_FAIL;
|
||||||
void *ptr = program.get_write_ptr(addr);
|
|
||||||
image.fread( ptr, 599);
|
|
||||||
ptr = program.get_write_ptr(0xc000);
|
|
||||||
image.fread( ptr, snapshot_size - 599 - 18);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// get tape name
|
||||||
|
char tape_name[16];
|
||||||
|
memcpy(&tape_name, &header[1], 15);
|
||||||
|
tape_name[15] = '\0';
|
||||||
|
image.message("Loading '%s'", tape_name);
|
||||||
|
|
||||||
|
// start of system variables area
|
||||||
|
UINT16 system_variables_base = pick_integer_le(header, 16, 2);
|
||||||
|
|
||||||
|
// write system variables
|
||||||
|
UINT16 system_variables_size = 0;
|
||||||
|
|
||||||
|
if (system_variables_base != 0)
|
||||||
{
|
{
|
||||||
/* short header */
|
ptr = program.get_write_ptr(system_variables_base);
|
||||||
addr = pick_integer_le(header, 0, 2);
|
system_variables_size = 0xfb4b - system_variables_base;
|
||||||
image.fseek(4, SEEK_SET);
|
image.fread(ptr, system_variables_size);
|
||||||
void *ptr = program.get_write_ptr(addr);
|
|
||||||
image.fread( ptr, 599);
|
|
||||||
ptr = program.get_write_ptr(0xc000);
|
|
||||||
image.fread( ptr, snapshot_size - 599 - 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write actual image data
|
||||||
|
UINT16 data_size = snapshot_size - 18 - system_variables_size;
|
||||||
|
|
||||||
|
ptr = program.get_write_ptr(0x4000);
|
||||||
|
image.fread(ptr, 0x4000);
|
||||||
|
|
||||||
|
// if we cross the page boundary, get a new write pointer and write the rest
|
||||||
|
if (data_size > 0x4000)
|
||||||
|
{
|
||||||
|
ptr = program.get_write_ptr(0x8000);
|
||||||
|
image.fread(ptr, 0x4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
logerror("snapshot name = '%s', system_size = 0x%04x, data_size = 0x%04x\n", tape_name, system_variables_size, data_size);
|
||||||
|
|
||||||
return IMAGE_INIT_PASS;
|
return IMAGE_INIT_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user