diff --git a/src/mess/drivers/binbug.c b/src/mess/drivers/binbug.c index c5de8039690..290f1d590a1 100644 --- a/src/mess/drivers/binbug.c +++ b/src/mess/drivers/binbug.c @@ -222,70 +222,74 @@ QUICKLOAD_LOAD_MEMBER( binbug_state, binbug ) { address_space &space = m_maincpu->space(AS_PROGRAM); int i; - int quick_addr = 0x0440; + int quick_addr = 0x440; int exec_addr; int quick_length; UINT8 *quick_data; int read_; + int result = IMAGE_INIT_FAIL; quick_length = image.length(); - quick_data = (UINT8*)malloc(quick_length); - if (!quick_data) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); - image.message(" Cannot open file"); - return IMAGE_INIT_FAIL; - } - - read_ = image.fread( quick_data, quick_length); - if (read_ != quick_length) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); - image.message(" Cannot read the file"); - return IMAGE_INIT_FAIL; - } - - if (quick_data[0] != 0xc4) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); - image.message(" Invalid header"); - return IMAGE_INIT_FAIL; - } - - exec_addr = quick_data[1] * 256 + quick_data[2]; - - if (exec_addr >= quick_length) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); - image.message(" Exec address beyond end of file"); - return IMAGE_INIT_FAIL; - } - - if (quick_length < 0x444) + if (quick_length < 0x0444) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); image.message(" File too short"); - return IMAGE_INIT_FAIL; } - - if (quick_length > 0x8000) + else if (quick_length > 0x8000) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); image.message(" File too long"); - return IMAGE_INIT_FAIL; } - - for (i = quick_addr; i < quick_length; i++) + else { - space.write_byte(i, quick_data[i]); + quick_data = (UINT8*)malloc(quick_length); + if (!quick_data) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); + image.message(" Cannot open file"); + } + else + { + read_ = image.fread( quick_data, quick_length); + if (read_ != quick_length) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); + image.message(" Cannot read the file"); + } + else if (quick_data[0] != 0xc4) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); + image.message(" Invalid header"); + } + else + { + exec_addr = quick_data[1] * 256 + quick_data[2]; + + if (exec_addr >= quick_length) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); + image.message(" Exec address beyond end of file"); + } + else + { + for (i = quick_addr; i < read_; i++) + space.write_byte(i, quick_data[i]); + + /* display a message about the loaded quickload */ + image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); + + // Start the quickload + m_maincpu->set_pc(exec_addr); + + result = IMAGE_INIT_PASS; + } + } + } + + free( quick_data ); } - /* display a message about the loaded quickload */ - image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); - - // Start the quickload - m_maincpu->set_pc(exec_addr); - return IMAGE_INIT_PASS; + return result; } static MACHINE_CONFIG_START( binbug, binbug_state ) @@ -360,8 +364,7 @@ A is the code (0x08 = inhibit; 0x0B = unprotect; 0x0C = enable; 0x0E = protect). There are 256 pages so each page is 256 bytes. -To turn the clock on (if it was working), put a non-zero -into D80D. +The clock is controlled by the byte in D80D. Monitor Commands: C (compare)* diff --git a/src/mess/drivers/instruct.c b/src/mess/drivers/instruct.c index a4c66c19026..4d0fe73e568 100644 --- a/src/mess/drivers/instruct.c +++ b/src/mess/drivers/instruct.c @@ -231,70 +231,74 @@ QUICKLOAD_LOAD_MEMBER( instruct_state, instruct ) { address_space &space = m_maincpu->space(AS_PROGRAM); int i; - int quick_addr = 0x0100; + int quick_addr = 0x100; int exec_addr; int quick_length; UINT8 *quick_data; int read_; + int result = IMAGE_INIT_FAIL; quick_length = image.length(); - quick_data = (UINT8*)malloc(quick_length); - if (!quick_data) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); - image.message(" Cannot open file"); - return IMAGE_INIT_FAIL; - } - - read_ = image.fread( quick_data, quick_length); - if (read_ != quick_length) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); - image.message(" Cannot read the file"); - return IMAGE_INIT_FAIL; - } - - if (quick_data[0] != 0xc5) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); - image.message(" Invalid header"); - return IMAGE_INIT_FAIL; - } - - exec_addr = quick_data[1] * 256 + quick_data[2]; - - if (exec_addr >= quick_length) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); - image.message(" Exec address beyond end of file"); - return IMAGE_INIT_FAIL; - } - - if (quick_length < 0x104) + if (quick_length < 0x0104) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); image.message(" File too short"); - return IMAGE_INIT_FAIL; } - - if (quick_length > 0x17c0) + else if (quick_length > 0x17c0) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); image.message(" File too long"); - return IMAGE_INIT_FAIL; } - - for (i = quick_addr; i < quick_length; i++) + else { - space.write_byte(i, quick_data[i]); + quick_data = (UINT8*)malloc(quick_length); + if (!quick_data) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); + image.message(" Cannot open file"); + } + else + { + read_ = image.fread( quick_data, quick_length); + if (read_ != quick_length) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); + image.message(" Cannot read the file"); + } + else if (quick_data[0] != 0xc5) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); + image.message(" Invalid header"); + } + else + { + exec_addr = quick_data[1] * 256 + quick_data[2]; + + if (exec_addr >= quick_length) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); + image.message(" Exec address beyond end of file"); + } + else + { + for (i = quick_addr; i < read_; i++) + space.write_byte(i, quick_data[i]); + + /* display a message about the loaded quickload */ + image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); + + // Start the quickload + m_maincpu->set_pc(exec_addr); + + result = IMAGE_INIT_PASS; + } + } + } + + free( quick_data ); } - /* display a message about the loaded quickload */ - image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); - - // Start the quickload - m_maincpu->set_pc(exec_addr); - return IMAGE_INIT_PASS; + return result; } static MACHINE_CONFIG_START( instruct, instruct_state ) diff --git a/src/mess/drivers/pipbug.c b/src/mess/drivers/pipbug.c index 1f6c3483d32..3226763216b 100644 --- a/src/mess/drivers/pipbug.c +++ b/src/mess/drivers/pipbug.c @@ -97,70 +97,74 @@ QUICKLOAD_LOAD_MEMBER( pipbug_state, pipbug ) { address_space &space = m_maincpu->space(AS_PROGRAM); int i; - int quick_addr = 0x0440; + int quick_addr = 0x440; int exec_addr; int quick_length; UINT8 *quick_data; int read_; + int result = IMAGE_INIT_FAIL; quick_length = image.length(); - quick_data = (UINT8*)malloc(quick_length); - if (!quick_data) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); - image.message(" Cannot open file"); - return IMAGE_INIT_FAIL; - } - - read_ = image.fread( quick_data, quick_length); - if (read_ != quick_length) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); - image.message(" Cannot read the file"); - return IMAGE_INIT_FAIL; - } - - if (quick_data[0] != 0xc4) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); - image.message(" Invalid header"); - return IMAGE_INIT_FAIL; - } - - exec_addr = quick_data[1] * 256 + quick_data[2]; - - if (exec_addr >= quick_length) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); - image.message(" Exec address beyond end of file"); - return IMAGE_INIT_FAIL; - } - - if (quick_length < 0x444) + if (quick_length < 0x0444) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); image.message(" File too short"); - return IMAGE_INIT_FAIL; } - - if (quick_length > 0x8000) + else if (quick_length > 0x8000) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); image.message(" File too long"); - return IMAGE_INIT_FAIL; } - - for (i = quick_addr; i < quick_length; i++) + else { - space.write_byte(i, quick_data[i]); + quick_data = (UINT8*)malloc(quick_length); + if (!quick_data) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); + image.message(" Cannot open file"); + } + else + { + read_ = image.fread( quick_data, quick_length); + if (read_ != quick_length) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); + image.message(" Cannot read the file"); + } + else if (quick_data[0] != 0xc4) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); + image.message(" Invalid header"); + } + else + { + exec_addr = quick_data[1] * 256 + quick_data[2]; + + if (exec_addr >= quick_length) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); + image.message(" Exec address beyond end of file"); + } + else + { + for (i = quick_addr; i < read_; i++) + space.write_byte(i, quick_data[i]); + + /* display a message about the loaded quickload */ + image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); + + // Start the quickload + m_maincpu->set_pc(exec_addr); + + result = IMAGE_INIT_PASS; + } + } + } + + free( quick_data ); } - /* display a message about the loaded quickload */ - image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); - - // Start the quickload - m_maincpu->set_pc(exec_addr); - return IMAGE_INIT_PASS; + return result; } static MACHINE_CONFIG_START( pipbug, pipbug_state )