From 9a593dd7f03bbe619ee1fabb1e70af9683dd8901 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 18 Sep 2024 12:30:18 +0200 Subject: misc: Added proper error messages to COM quickload (MT 08915) [Robbbert] --- src/mame/altos/altos5.cpp | 35 ++++++++++++++++++----------------- src/mame/ausnz/aussiebyte.cpp | 40 +++++++++++++++++++++------------------- src/mame/kaypro/kaypro_m.cpp | 24 ++++++++++++++---------- src/mame/ncr/dmv.cpp | 23 ++++++++++++----------- src/mame/sony/smc777.cpp | 33 +++++++++++++++++---------------- src/mame/trs/coco3.cpp | 2 +- src/mame/xerox/xerox820.cpp | 32 +++++++++++++++++--------------- 7 files changed, 100 insertions(+), 89 deletions(-) diff --git a/src/mame/altos/altos5.cpp b/src/mame/altos/altos5.cpp index ce80a963dc1..12cf53d0300 100644 --- a/src/mame/altos/altos5.cpp +++ b/src/mame/altos/altos5.cpp @@ -302,37 +302,38 @@ void altos5_state::port09_w(uint8_t data) QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb) { - address_space& prog_space = m_maincpu->space(AS_PROGRAM); - - if (image.length() >= 0xfd00) - return std::make_pair(image_error::INVALIDLENGTH, std::string()); - setup_banks(2); - /* Avoid loading a program if CP/M-80 is not in memory */ + address_space& prog_space = m_maincpu->space(AS_PROGRAM); + + // Avoid loading a program if CP/M-80 is not in memory if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return std::make_pair(image_error::UNSUPPORTED, std::string()); + return std::make_pair(image_error::UNSUPPORTED, "CP/M must already be running"); } - /* Load image to the TPA (Transient Program Area) */ + const int mem_avail = 256 * prog_space.read_byte(7) + prog_space.read_byte(6) - 512; + if (mem_avail < image.length()) + return std::make_pair(image_error::UNSPECIFIED, "Insufficient memory available"); + + // Load image to the TPA (Transient Program Area) uint16_t quickload_size = image.length(); for (uint16_t i = 0; i < quickload_size; i++) { uint8_t data; - - if (image.fread( &data, 1) != 1) - return std::make_pair(image_error::UNSPECIFIED, std::string()); - prog_space.write_byte(i+0x100, data); + if (image.fread(&data, 1) != 1) + return std::make_pair(image_error::BADSOFTWARE, "Problem reading the image at offset " + std::to_string(i)); + prog_space.write_byte(i + 0x100, data); } - /* clear out command tail */ - prog_space.write_byte(0x80, 0); prog_space.write_byte(0x81, 0); + // clear out command tail + prog_space.write_byte(0x80, 0); + prog_space.write_byte(0x81, 0); - /* Roughly set SP basing on the BDOS position */ - m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); - m_maincpu->set_pc(0x100); // start program + // Roughly set SP basing on the BDOS position + m_maincpu->set_state_int(Z80_SP, mem_avail + 384); + m_maincpu->set_pc(0x100); // start program return std::make_pair(std::error_condition(), std::string()); } diff --git a/src/mame/ausnz/aussiebyte.cpp b/src/mame/ausnz/aussiebyte.cpp index 1a350bca67d..0745691357e 100644 --- a/src/mame/ausnz/aussiebyte.cpp +++ b/src/mame/ausnz/aussiebyte.cpp @@ -398,40 +398,42 @@ static void aussiebyte_floppies(device_slot_interface &device) QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb) { - address_space& prog_space = m_maincpu->space(AS_PROGRAM); - - if (image.length() >= 0xfd00) - return std::make_pair(image_error::INVALIDLENGTH, std::string()); - - /* RAM must be banked in */ - m_port15 = true; // disable boot rom + // RAM must be banked in + m_port15 = true; // disable boot rom m_port1a = 4; - m_bankr0->set_entry(m_port1a); /* enable correct program bank */ + m_bankr0->set_entry(m_port1a); // enable correct program bank m_bankw0->set_entry(m_port1a); - /* Avoid loading a program if CP/M-80 is not in memory */ + address_space& prog_space = m_maincpu->space(AS_PROGRAM); + + // Avoid loading a program if CP/M-80 is not in memory if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return std::make_pair(image_error::UNSUPPORTED, std::string()); + return std::make_pair(image_error::UNSUPPORTED, "CP/M must already be running"); } - /* Load image to the TPA (Transient Program Area) */ + const int mem_avail = 256 * prog_space.read_byte(7) + prog_space.read_byte(6) - 512; + if (mem_avail < image.length()) + return std::make_pair(image_error::UNSPECIFIED, "Insufficient memory available"); + + // Load image to the TPA (Transient Program Area) u16 quickload_size = image.length(); for (u16 i = 0; i < quickload_size; i++) { u8 data; - if (image.fread( &data, 1) != 1) - return std::make_pair(image_error::UNSPECIFIED, std::string()); - prog_space.write_byte(i+0x100, data); + if (image.fread(&data, 1) != 1) + return std::make_pair(image_error::BADSOFTWARE, "Problem reading the image at offset " + std::to_string(i)); + prog_space.write_byte(i + 0x100, data); } - /* clear out command tail */ - prog_space.write_byte(0x80, 0); prog_space.write_byte(0x81, 0); + // clear out command tail + prog_space.write_byte(0x80, 0); + prog_space.write_byte(0x81, 0); - /* Roughly set SP basing on the BDOS position */ - m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 0x400); - m_maincpu->set_pc(0x100); // start program + // Roughly set SP basing on the BDOS position + m_maincpu->set_state_int(Z80_SP, mem_avail + 384); + m_maincpu->set_pc(0x100); // start program return std::make_pair(std::error_condition(), std::string()); } diff --git a/src/mame/kaypro/kaypro_m.cpp b/src/mame/kaypro/kaypro_m.cpp index 2bda040f82f..8bb754cc115 100644 --- a/src/mame/kaypro/kaypro_m.cpp +++ b/src/mame/kaypro/kaypro_m.cpp @@ -300,27 +300,31 @@ QUICKLOAD_LOAD_MEMBER(kaypro_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); - /* Avoid loading a program if CP/M-80 is not in memory */ + // Avoid loading a program if CP/M-80 is not in memory if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) - return std::make_pair(image_error::UNSUPPORTED, std::string()); + return std::make_pair(image_error::UNSUPPORTED, "CP/M must already be running"); - if (image.length() >= 0xfd00) - return std::make_pair(image_error::INVALIDLENGTH, std::string()); + // Check for sufficient RAM based on position of CPM + const int mem_avail = 256 * prog_space.read_byte(7) + prog_space.read_byte(6) - 512; + if (mem_avail < image.length()) + return std::make_pair(image_error::UNSPECIFIED, "Insufficient memory available"); - /* Load image to the TPA (Transient Program Area) */ + // Load image to the TPA (Transient Program Area) u16 quickload_size = image.length(); for (u16 i = 0; i < quickload_size; i++) { u8 data; if (image.fread(&data, 1) != 1) - return std::make_pair(image_error::UNSPECIFIED, std::string()); - prog_space.write_byte(i+0x100, data); + return std::make_pair(image_error::BADSOFTWARE, "Problem reading the image at offset " + std::to_string(i)); + prog_space.write_byte(i + 0x100, data); } - prog_space.write_byte(0x80, 0); prog_space.write_byte(0x81, 0); // clear out command tail + // clear out command tail + prog_space.write_byte(0x80, 0); + prog_space.write_byte(0x81, 0); - m_maincpu->set_pc(0x100); // start program - m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); // put the stack a bit before BDOS + m_maincpu->set_state_int(Z80_SP, mem_avail + 384); // put the stack a bit before BDOS + m_maincpu->set_pc(0x100); // start program return std::make_pair(std::error_condition(), std::string()); } diff --git a/src/mame/ncr/dmv.cpp b/src/mame/ncr/dmv.cpp index 69237aa5400..1e8cda6b882 100644 --- a/src/mame/ncr/dmv.cpp +++ b/src/mame/ncr/dmv.cpp @@ -402,27 +402,28 @@ UPD7220_DRAW_TEXT_LINE_MEMBER( dmv_state::hgdc_draw_text ) QUICKLOAD_LOAD_MEMBER(dmv_state::quickload_cb) { - /* Avoid loading a program if CP/M-80 is not in memory */ + // Avoid loading a program if CP/M-80 is not in memory if ((m_ram->base()[0] != 0xc3) || (m_ram->base()[5] != 0xc3)) - return std::make_pair(image_error::UNSUPPORTED, std::string()); + return std::make_pair(image_error::UNSUPPORTED, "CP/M must already be running"); - if (image.length() >= 0xfd00) - return std::make_pair(image_error::INVALIDLENGTH, std::string()); + const int mem_avail = 256 * m_ram->base()[7] + m_ram->base()[6] - 512; + if (mem_avail < image.length()) + return std::make_pair(image_error::UNSPECIFIED, "Insufficient memory available"); - /* Load image to the TPA (Transient Program Area) */ + // Load image to the TPA (Transient Program Area) uint16_t quickload_size = image.length(); for (uint16_t i = 0; i < quickload_size; i++) { uint8_t data; - if (image.fread( &data, 1) != 1) - return std::make_pair(image_error::UNSPECIFIED, std::string()); - m_ram->base()[i+0x100] = data; + if (image.fread(&data, 1) != 1) + return std::make_pair(image_error::BADSOFTWARE, "Problem reading the image at offset " + std::to_string(i)); + m_ram->base()[i + 0x100] = data; } - m_ram->base()[0x80] = m_ram->base()[0x81] = 0; // clear out command tail + m_ram->base()[0x80] = m_ram->base()[0x81] = 0; // clear out command tail - m_maincpu->set_pc(0x100); // start program - m_maincpu->set_state_int(Z80_SP, 256 * m_ram->base()[7] - 300); // put the stack a bit before BDOS + m_maincpu->set_state_int(Z80_SP, mem_avail + 384); // put the stack a bit before BDOS + m_maincpu->set_pc(0x100); // start program return std::make_pair(std::error_condition(), std::string()); } diff --git a/src/mame/sony/smc777.cpp b/src/mame/sony/smc777.cpp index 8d338056b5f..b1a6c6c2cc6 100644 --- a/src/mame/sony/smc777.cpp +++ b/src/mame/sony/smc777.cpp @@ -419,34 +419,35 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb) { address_space& prog_space = m_maincpu->space(AS_PROGRAM); - if (image.length() >= 0xfd00) - return std::make_pair(image_error::INVALIDLENGTH, std::string()); - - /* The right RAM bank must be active */ - - /* Avoid loading a program if CP/M-80 is not in memory */ + // Avoid loading a program if CP/M-80 is not in memory if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return std::make_pair(image_error::UNSUPPORTED, std::string()); + return std::make_pair(image_error::UNSUPPORTED, "CP/M must already be running"); } - /* Load image to the TPA (Transient Program Area) */ + // Check for sufficient RAM based on position of CPM + const int mem_avail = 256 * prog_space.read_byte(7) + prog_space.read_byte(6) - 512; + if (mem_avail < image.length()) + return std::make_pair(image_error::UNSPECIFIED, "Insufficient memory available"); + + // Load image to the TPA (Transient Program Area) uint16_t quickload_size = image.length(); for (uint16_t i = 0; i < quickload_size; i++) { uint8_t data; - if (image.fread( &data, 1) != 1) - return std::make_pair(image_error::UNSPECIFIED, std::string()); - prog_space.write_byte(i+0x100, data); + if (image.fread(&data, 1) != 1) + return std::make_pair(image_error::BADSOFTWARE, "Problem reading the image at offset " + std::to_string(i)); + prog_space.write_byte(i + 0x100, data); } - /* clear out command tail */ - prog_space.write_byte(0x80, 0); prog_space.write_byte(0x81, 0); + // clear out command tail */ + prog_space.write_byte(0x80, 0); + prog_space.write_byte(0x81, 0); - /* Roughly set SP basing on the BDOS position */ - m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); - m_maincpu->set_pc(0x100); // start program + // Roughly set SP basing on the BDOS position + m_maincpu->set_state_int(Z80_SP, mem_avail + 384); + m_maincpu->set_pc(0x100); // start program return std::make_pair(std::error_condition(), std::string()); } diff --git a/src/mame/trs/coco3.cpp b/src/mame/trs/coco3.cpp index c5f3db9674e..6d5af8e936c 100644 --- a/src/mame/trs/coco3.cpp +++ b/src/mame/trs/coco3.cpp @@ -311,7 +311,7 @@ void coco3_state::coco3(machine_config &config) // monitor SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_screen->set_raw(28.636363_MHz_XTAL/2, 912, 0, 640, 262, 1, 241-1); + m_screen->set_raw(28.636363_MHz_XTAL/2, 912, 0, 640, 262, 1, 240); m_screen->set_screen_update(FUNC(coco3_state::screen_update)); // internal ram diff --git a/src/mame/xerox/xerox820.cpp b/src/mame/xerox/xerox820.cpp index b984140ce8a..00373b7916d 100644 --- a/src/mame/xerox/xerox820.cpp +++ b/src/mame/xerox/xerox820.cpp @@ -380,36 +380,38 @@ static const z80_daisy_config xerox820_daisy_chain[] = QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb) { - if (image.length() >= 0xfd00) - return std::make_pair(image_error::INVALIDLENGTH, std::string()); + m_view.select(0); address_space &prog_space = m_maincpu->space(AS_PROGRAM); - m_view.select(0); - - /* Avoid loading a program if CP/M-80 is not in memory */ + // Avoid loading a program if CP/M-80 is not in memory if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return std::make_pair(image_error::UNSUPPORTED, std::string()); + return std::make_pair(image_error::UNSUPPORTED, "CP/M must already be running"); } - /* Load image to the TPA (Transient Program Area) */ + const int mem_avail = 256 * prog_space.read_byte(7) + prog_space.read_byte(6) - 512; + if (mem_avail < image.length()) + return std::make_pair(image_error::UNSPECIFIED, "Insufficient memory available"); + + // Load image to the TPA (Transient Program Area) uint16_t quickload_size = image.length(); for (uint16_t i = 0; i < quickload_size; i++) { uint8_t data; - if (image.fread( &data, 1) != 1) - return std::make_pair(image_error::UNSPECIFIED, std::string()); - prog_space.write_byte(i+0x100, data); + if (image.fread(&data, 1) != 1) + return std::make_pair(image_error::BADSOFTWARE, "Problem reading the image at offset " + std::to_string(i)); + prog_space.write_byte(i + 0x100, data); } - /* clear out command tail */ - prog_space.write_byte(0x80, 0); prog_space.write_byte(0x81, 0); + // clear out command tail */ + prog_space.write_byte(0x80, 0); + prog_space.write_byte(0x81, 0); - /* Roughly set SP basing on the BDOS position */ - m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); - m_maincpu->set_pc(0x100); // start program + // Roughly set SP basing on the BDOS position + m_maincpu->set_state_int(Z80_SP, mem_avail + 384); + m_maincpu->set_pc(0x100); // start program return std::make_pair(std::error_condition(), std::string()); } -- cgit v1.2.3