diff --git a/src/mess/drivers/d6800.c b/src/mess/drivers/d6800.c index b559addce0d..88fecc83208 100644 --- a/src/mess/drivers/d6800.c +++ b/src/mess/drivers/d6800.c @@ -338,11 +338,12 @@ QUICKLOAD_LOAD_MEMBER( d6800_state, d6800 ) { address_space &space = m_maincpu->space(AS_PROGRAM); int i; - int quick_addr = 0x0200; + int quick_addr = 0x200; int exec_addr = 0xc000; int quick_length; UINT8 *quick_data; int read_; + int result = IMAGE_INIT_FAIL; quick_length = image.length(); quick_data = (UINT8*)malloc(quick_length); @@ -350,27 +351,34 @@ QUICKLOAD_LOAD_MEMBER( d6800_state, d6800 ) { 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) + else { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); - image.message(" Cannot read the 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"); + } + else + { + for (i = 0; i < quick_length; i++) + if ((quick_addr + i) < 0x800) + space.write_byte(i + quick_addr, quick_data[i]); + + /* display a message about the loaded quickload */ + image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length,quick_addr,quick_addr+quick_length,exec_addr); + + // Start the quickload + m_maincpu->set_pc(exec_addr); + + result = IMAGE_INIT_PASS; + } + + free( quick_data ); } - for (i = 0; i < quick_length; i++) - if ((quick_addr + i) < 0x800) - space.write_byte(i + quick_addr, quick_data[i]); - - /* display a message about the loaded quickload */ - image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length,quick_addr,quick_addr+quick_length,exec_addr); - - // Start the quickload - m_maincpu->set_pc(exec_addr); - return IMAGE_INIT_PASS; + return result; } static MACHINE_CONFIG_START( d6800, d6800_state ) diff --git a/src/mess/drivers/homelab.c b/src/mess/drivers/homelab.c index fe1066587c0..e263b31a919 100644 --- a/src/mess/drivers/homelab.c +++ b/src/mess/drivers/homelab.c @@ -10,6 +10,7 @@ ToDO: - HTP files should be a cassette format, not a quickload. + - Quickloads cause the emulated machine to hang or reboot. - homelab2 - cassette to fix. Note that rom code 0x40-48 is meaningless garbage, had to patch to stop it crashing. Need a new dump. @@ -661,6 +662,7 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); image.message(" Cannot open file"); + free(quick_data); return IMAGE_INIT_FAIL; } @@ -669,6 +671,7 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); image.message(" Cannot read the file"); + free(quick_data); return IMAGE_INIT_FAIL; } @@ -678,6 +681,7 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); image.message(" Invalid header"); + free(quick_data); return IMAGE_INIT_FAIL; } @@ -687,6 +691,7 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long"); image.message(" File name too long"); + free(quick_data); return IMAGE_INIT_FAIL; } @@ -700,6 +705,7 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size"); image.message(" Unexpected EOF while getting file size"); + free(quick_data); return IMAGE_INIT_FAIL; } @@ -711,6 +717,7 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) { image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too large"); image.message(" File too large"); + free(quick_data); return IMAGE_INIT_FAIL; } @@ -726,11 +733,13 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) snprintf(message, ARRAY_LENGTH(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); image.seterror(IMAGE_ERROR_INVALIDIMAGE, message); image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); + free(quick_data); return IMAGE_INIT_FAIL; } space.write_byte(j, ch); } + free(quick_data); return IMAGE_INIT_PASS; } diff --git a/src/mess/drivers/vc4000.c b/src/mess/drivers/vc4000.c index 8f226c100f9..0ba6bb3466e 100644 --- a/src/mess/drivers/vc4000.c +++ b/src/mess/drivers/vc4000.c @@ -533,6 +533,7 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) int quick_length; UINT8 *quick_data; int read_; + int result = IMAGE_INIT_FAIL; quick_length = image.length(); quick_data = (UINT8*)malloc(quick_length); @@ -540,90 +541,93 @@ QUICKLOAD_LOAD_MEMBER( vc4000_state,vc4000) { 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 (mame_stricmp(image.filetype(), "tvc")==0) - { - if (quick_data[0] != 2) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); - image.message(" Invalid header"); - return IMAGE_INIT_FAIL; - } - - quick_addr = quick_data[1] * 256 + quick_data[2]; - exec_addr = quick_data[3] * 256 + quick_data[4]; - - space.write_byte(0x08be, quick_data[3]); - space.write_byte(0x08bf, quick_data[4]); - - for (i = 0; i < quick_length - 5; i++) - if ((quick_addr + i) < 0x1600) - space.write_byte(i + quick_addr, quick_data[i+5]); - - /* display a message about the loaded quickload */ - image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); - - // Start the quickload - m_maincpu->set_pc(exec_addr); - return IMAGE_INIT_PASS; } else - if (mame_stricmp(image.filetype(), "pgm")==0) { - if (quick_data[0] != 0) + read_ = image.fread( quick_data, quick_length); + if (read_ != quick_length) { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); - image.message(" Invalid header"); - return IMAGE_INIT_FAIL; + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); + image.message(" Cannot read the file"); } - - exec_addr = quick_data[1] * 256 + quick_data[2]; - - if (exec_addr >= quick_length) + else { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); - image.message(" Exec address beyond end of file"); - return IMAGE_INIT_FAIL; + if (mame_stricmp(image.filetype(), "tvc")==0) + { + if (quick_data[0] != 2) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); + image.message(" Invalid header"); + } + else + { + quick_addr = quick_data[1] * 256 + quick_data[2]; + exec_addr = quick_data[3] * 256 + quick_data[4]; + + space.write_byte(0x08be, quick_data[3]); + space.write_byte(0x08bf, quick_data[4]); + + for (i = 0; i < quick_length - 5; i++) + if ((quick_addr + i) < 0x1600) + space.write_byte(i + quick_addr, quick_data[i+5]); + + /* display a message about the loaded quickload */ + image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); + + // Start the quickload + m_maincpu->set_pc(exec_addr); + result = IMAGE_INIT_PASS; + } + } + else + if (mame_stricmp(image.filetype(), "pgm")==0) + { + if (quick_data[0] != 0) + { + 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 + if (quick_length < 0x904) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); + image.message(" File too short"); + } + else + // some programs store data in PVI memory and other random places. This is not supported. + if (quick_length > 0x1600) + { + image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); + image.message(" File too long"); + } + else + { + for (i = quick_addr; i < quick_length; i++) + if (i < 0x1600) + 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; + } + } + } } - - if (quick_length < 0x904) - { - image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); - image.message(" File too short"); - return IMAGE_INIT_FAIL; - } - - // some programs store data in PVI memory and other random places. This is not supported. - if (quick_length > 0x1600) - { - 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++) - if (i < 0x1600) - 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); - return IMAGE_INIT_PASS; + free (quick_data); } - else - return IMAGE_INIT_FAIL; + return result; }