mirror of
https://github.com/holub/mame
synced 2025-06-07 13:23:50 +03:00
trs80: improved cmd quickloader
This commit is contained in:
parent
5114f02941
commit
0df3ef56fd
@ -418,43 +418,49 @@ QUICKLOAD_LOAD_MEMBER(trs80_state::quickload_cb)
|
|||||||
image.fread( &type, 1);
|
image.fread( &type, 1);
|
||||||
image.fread( &length, 1);
|
image.fread( &length, 1);
|
||||||
|
|
||||||
length -= 2;
|
|
||||||
int block_length = length ? length : 256;
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CMD_TYPE_OBJECT_CODE:
|
case CMD_TYPE_OBJECT_CODE: // 01 - block of data
|
||||||
{
|
{
|
||||||
|
length -= 2;
|
||||||
|
u16 block_length = length ? length : 256;
|
||||||
image.fread( &addr, 2);
|
image.fread( &addr, 2);
|
||||||
uint16_t address = (addr[1] << 8) | addr[0];
|
u16 address = (addr[1] << 8) | addr[0];
|
||||||
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
|
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
|
||||||
|
if (address < 0x4000)
|
||||||
|
{
|
||||||
|
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Attempting to write outside of RAM");
|
||||||
|
return image_init_result::FAIL;
|
||||||
|
}
|
||||||
ptr = program.get_write_ptr(address);
|
ptr = program.get_write_ptr(address);
|
||||||
image.fread( ptr, block_length);
|
image.fread( ptr, block_length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_TYPE_TRANSFER_ADDRESS:
|
case CMD_TYPE_TRANSFER_ADDRESS: // 02 - go address
|
||||||
{
|
{
|
||||||
image.fread( &addr, 2);
|
image.fread( &addr, 2);
|
||||||
uint16_t address = (addr[1] << 8) | addr[0];
|
u16 address = (addr[1] << 8) | addr[0];
|
||||||
if (LOG) logerror("/CMD transfer address %04x\n", address);
|
if (LOG) logerror("/CMD transfer address %04x\n", address);
|
||||||
m_maincpu->set_state_int(Z80_PC, address);
|
m_maincpu->set_state_int(Z80_PC, address);
|
||||||
}
|
}
|
||||||
break;
|
return image_init_result::PASS;
|
||||||
|
|
||||||
case CMD_TYPE_LOAD_MODULE_HEADER:
|
case CMD_TYPE_LOAD_MODULE_HEADER: // 05 - name
|
||||||
image.fread( &data, block_length);
|
image.fread( &data, length);
|
||||||
if (LOG) logerror("/CMD load module header '%s'\n", data);
|
if (LOG) logerror("/CMD load module header '%s'\n", data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_TYPE_COPYRIGHT_BLOCK:
|
case CMD_TYPE_COPYRIGHT_BLOCK: // 1F - copyright info
|
||||||
image.fread( &data, block_length);
|
image.fread( &data, length);
|
||||||
if (LOG) logerror("/CMD copyright block '%s'\n", data);
|
if (LOG) logerror("/CMD copyright block '%s'\n", data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
image.fread( &data, block_length);
|
image.fread( &data, length);
|
||||||
logerror("/CMD unsupported block type %u!\n", type);
|
logerror("/CMD unsupported block type %u!\n", type);
|
||||||
|
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported or invalid block type");
|
||||||
|
return image_init_result::FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,43 +656,50 @@ QUICKLOAD_LOAD_MEMBER(trs80m3_state::quickload_cb)
|
|||||||
image.fread( &type, 1);
|
image.fread( &type, 1);
|
||||||
image.fread( &length, 1);
|
image.fread( &length, 1);
|
||||||
|
|
||||||
length -= 2;
|
|
||||||
int block_length = length ? length : 256;
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CMD_TYPE_OBJECT_CODE:
|
case CMD_TYPE_OBJECT_CODE: // 01 - block of data
|
||||||
{
|
{
|
||||||
|
length -= 2;
|
||||||
|
u16 block_length = length ? length : 256;
|
||||||
image.fread( &addr, 2);
|
image.fread( &addr, 2);
|
||||||
uint16_t address = (addr[1] << 8) | addr[0];
|
u16 address = (addr[1] << 8) | addr[0];
|
||||||
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
|
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
|
||||||
|
// Todo: the below only applies for non-ram
|
||||||
|
//if (address < 0x4000)
|
||||||
|
//{
|
||||||
|
//image.seterror(IMAGE_ERROR_UNSPECIFIED, "Attempting to write outside of RAM");
|
||||||
|
//return image_init_result::FAIL;
|
||||||
|
//}
|
||||||
ptr = program.get_write_ptr(address);
|
ptr = program.get_write_ptr(address);
|
||||||
image.fread( ptr, block_length);
|
image.fread( ptr, block_length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_TYPE_TRANSFER_ADDRESS:
|
case CMD_TYPE_TRANSFER_ADDRESS: // 02 - go address
|
||||||
{
|
{
|
||||||
image.fread( &addr, 2);
|
image.fread( &addr, 2);
|
||||||
uint16_t address = (addr[1] << 8) | addr[0];
|
u16 address = (addr[1] << 8) | addr[0];
|
||||||
if (LOG) logerror("/CMD transfer address %04x\n", address);
|
if (LOG) logerror("/CMD transfer address %04x\n", address);
|
||||||
m_maincpu->set_state_int(Z80_PC, address);
|
m_maincpu->set_state_int(Z80_PC, address);
|
||||||
}
|
}
|
||||||
break;
|
return image_init_result::PASS;
|
||||||
|
|
||||||
case CMD_TYPE_LOAD_MODULE_HEADER:
|
case CMD_TYPE_LOAD_MODULE_HEADER: // 05 - name
|
||||||
image.fread( &data, block_length);
|
image.fread( &data, length);
|
||||||
if (LOG) logerror("/CMD load module header '%s'\n", data);
|
if (LOG) logerror("/CMD load module header '%s'\n", data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_TYPE_COPYRIGHT_BLOCK:
|
case CMD_TYPE_COPYRIGHT_BLOCK: // 1F - copyright info
|
||||||
image.fread( &data, block_length);
|
image.fread( &data, length);
|
||||||
if (LOG) logerror("/CMD copyright block '%s'\n", data);
|
if (LOG) logerror("/CMD copyright block '%s'\n", data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
image.fread( &data, block_length);
|
image.fread( &data, length);
|
||||||
logerror("/CMD unsupported block type %u!\n", type);
|
logerror("/CMD unsupported block type %u!\n", type);
|
||||||
|
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported or invalid block type");
|
||||||
|
return image_init_result::FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user