trs80: removed magic number in quickload, better crash protection.

This commit is contained in:
Robbbert 2021-05-06 21:47:46 +10:00
parent fb08f0bb4e
commit 9b09093f1b
3 changed files with 6 additions and 7 deletions

View File

@ -421,12 +421,12 @@ QUICKLOAD_LOAD_MEMBER(meritum_state::quickload_cb)
image.fread( &addr, 2);
u16 address = (addr[1] << 8) | addr[0];
logerror("/CMD object code block: address %04x length %u\n", address, block_length);
if (address < 0x3c00)
ptr = program.get_write_ptr(address);
if (!ptr)
{
image.message("Attempting to write outside of RAM");
return image_init_result::FAIL;
}
ptr = program.get_write_ptr(address);
image.fread( ptr, block_length);
}
break;

View File

@ -396,12 +396,12 @@ QUICKLOAD_LOAD_MEMBER(trs80_state::quickload_cb)
image.fread( &addr, 2);
u16 address = (addr[1] << 8) | addr[0];
if (LOG) logerror("/CMD object code block: address %04x length %u\n", address, block_length);
if (address < 0x3c00)
ptr = program.get_write_ptr(address);
if (!ptr)
{
image.message("Attempting to write outside of RAM");
return image_init_result::FAIL;
}
ptr = program.get_write_ptr(address);
image.fread( ptr, block_length);
}
break;

View File

@ -675,13 +675,12 @@ QUICKLOAD_LOAD_MEMBER(trs80m3_state::quickload_cb)
image.fread( &addr, 2);
u16 address = (addr[1] << 8) | addr[0];
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 < 0x3c00)
ptr = program.get_write_ptr(address);
if (!ptr)
{
image.message("Attempting to write outside of RAM");
return image_init_result::FAIL;
}
ptr = program.get_write_ptr(address);
image.fread( ptr, block_length);
}
break;