reverse logic of IMAGE_VERIFY (nw)

This commit is contained in:
Miodrag Milanovic 2016-07-31 20:01:30 +02:00
parent 6f5e223853
commit 22c7a00d57
8 changed files with 22 additions and 24 deletions

View File

@ -378,7 +378,7 @@ bool a78_cart_slot_device::call_load()
char head[128];
fread(head, 128);
if (verify_header((char *)head) == IMAGE_VERIFY_FAIL)
if (!verify_header((char *)head))
return IMAGE_INIT_FAIL;
len = (head[49] << 24) | (head[50] << 16) | (head[51] << 8) | head[52];
@ -506,11 +506,11 @@ bool a78_cart_slot_device::verify_header(char *header)
if (strncmp(magic, header + 1, 9))
{
logerror("Not a valid A7800 image\n");
return IMAGE_VERIFY_FAIL;
return false;
}
logerror("returning ID_OK\n");
return IMAGE_VERIFY_PASS;
return true;
}

View File

@ -215,13 +215,13 @@ static const char *sega8_get_slot(int type)
bool sega8_cart_slot_device::verify_cart( UINT8 *magic, int size )
{
int retval = IMAGE_VERIFY_FAIL;
int retval = false;
// Verify the file is a valid image - check $7ff0 for "TMR SEGA"
if (size >= 0x8000)
{
if (!strncmp((char*)&magic[0x7ff0], "TMR SEGA", 8))
retval = IMAGE_VERIFY_PASS;
retval = true;
}
return retval;
@ -368,7 +368,7 @@ bool sega8_cart_slot_device::call_load()
memcpy(ROM, get_software_region("rom"), get_software_region_length("rom"));
/* check the image */
if (verify_cart(ROM, len) == IMAGE_VERIFY_FAIL)
if (!verify_cart(ROM, len))
logerror("Warning loading image: verify_cart failed\n");
if (software_entry() != nullptr)

View File

@ -112,8 +112,6 @@ typedef void (*device_image_partialhash_func)(util::hash_collection &, const uns
#define IMAGE_INIT_PASS false
#define IMAGE_INIT_FAIL true
#define IMAGE_VERIFY_PASS false
#define IMAGE_VERIFY_FAIL true
#define DEVICE_IMAGE_LOAD_MEMBER_NAME(_name) device_image_load_##_name
#define DEVICE_IMAGE_LOAD_NAME(_class,_name) _class::DEVICE_IMAGE_LOAD_MEMBER_NAME(_name)

View File

@ -354,13 +354,13 @@ void coleco_state::machine_reset()
//static bool coleco_cart_verify(const UINT8 *cartdata, size_t size)
//{
// int retval = IMAGE_VERIFY_FAIL;
// int retval = false;
//
// /* Verify the file is in Colecovision format */
// if ((cartdata[0] == 0xAA) && (cartdata[1] == 0x55)) /* Production Cartridge */
// retval = IMAGE_VERIFY_PASS;
// retval = true;
// if ((cartdata[0] == 0x55) && (cartdata[1] == 0xAA)) /* "Test" Cartridge. Some games use this method to skip ColecoVision title screen and delay */
// retval = IMAGE_VERIFY_PASS;
// retval = true;
//
// return retval;
//}

View File

@ -162,7 +162,7 @@ QUICKLOAD_LOAD_MEMBER( lynx_state, lynx )
return IMAGE_INIT_FAIL;
/* Check the image */
if (lynx_verify_cart((char*)header, LYNX_QUICKLOAD) == IMAGE_VERIFY_FAIL)
if (!lynx_verify_cart((char*)header, LYNX_QUICKLOAD))
return IMAGE_INIT_FAIL;
start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu

View File

@ -288,17 +288,17 @@ bool lviv_state::lviv_verify_snapshot (UINT8 * data, UINT32 size)
if( strncmp( tag, (char*)data, strlen(tag) ) )
{
logerror("Not a Lviv snapshot\n");
return IMAGE_VERIFY_FAIL;
return false;
}
if (size != LVIV_SNAPSHOT_SIZE)
{
logerror ("Incomplete snapshot file\n");
return IMAGE_VERIFY_FAIL;
return false;
}
logerror("returning ID_OK\n");
return IMAGE_VERIFY_PASS;
return true;
}
SNAPSHOT_LOAD_MEMBER( lviv_state, lviv )
@ -307,7 +307,7 @@ SNAPSHOT_LOAD_MEMBER( lviv_state, lviv )
image.fread( &lviv_snapshot_data[0], LVIV_SNAPSHOT_SIZE);
if(lviv_verify_snapshot(&lviv_snapshot_data[0], snapshot_size) == IMAGE_VERIFY_FAIL)
if(!lviv_verify_snapshot(&lviv_snapshot_data[0], snapshot_size))
{
return IMAGE_INIT_FAIL;
}

View File

@ -2037,7 +2037,7 @@ bool lynx_state::lynx_verify_cart (char *header, int kind)
if (strncmp("BS93", &header[6], 4))
{
logerror("This is not a valid Lynx image\n");
return IMAGE_VERIFY_FAIL;
return false;
}
}
else
@ -2051,11 +2051,11 @@ bool lynx_state::lynx_verify_cart (char *header, int kind)
}
else
logerror("This is not a valid Lynx image\n");
return IMAGE_VERIFY_FAIL;
return false;
}
}
return IMAGE_VERIFY_PASS;
return true;
}
DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart )
@ -2082,7 +2082,7 @@ DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart )
image.fread(header, 0x40);
// Check the image
if (lynx_verify_cart((char*)header, LYNX_CART) == IMAGE_VERIFY_FAIL)
if (!lynx_verify_cart((char*)header, LYNX_CART))
return IMAGE_INIT_FAIL;
/* 2008-10 FP: According to Handy source these should be page_size_bank0. Are we using

View File

@ -527,18 +527,18 @@ bool microtan_state::microtan_verify_snapshot(UINT8 *data, int size)
if (size == 8263)
{
logerror("microtan_snapshot_id: magic size %d found\n", size);
return IMAGE_VERIFY_PASS;
return true;
}
else
{
if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size)
{
logerror("microtan_snapshot_id: header RAM size + structures matches filesize %d\n", size);
return IMAGE_VERIFY_PASS;
return true;
}
}
return IMAGE_VERIFY_FAIL;
return false;
}
int microtan_state::parse_intel_hex(UINT8 *snapshot_buff, char *src)
@ -827,7 +827,7 @@ SNAPSHOT_LOAD_MEMBER( microtan_state, microtan )
if (!snapshot_buff)
return IMAGE_INIT_FAIL;
if (microtan_verify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL)
if (!microtan_verify_snapshot(snapshot_buff, snapshot_size))
return IMAGE_INIT_FAIL;
microtan_snapshot_copy(snapshot_buff, snapshot_size);