Skip to content

Commit

Permalink
Added proper messages to COM quickload (MT 08915)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbbert committed Sep 18, 2024
1 parent 15b605b commit d0ebbc0
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 68 deletions.
29 changes: 15 additions & 14 deletions src/mame/altos/altos5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,36 +302,37 @@ 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) */
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());
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);
// 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());
Expand Down
30 changes: 16 additions & 14 deletions src/mame/ausnz/aussiebyte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,39 +398,41 @@ 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 */
// 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_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) */
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());
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);
// 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());
Expand Down
20 changes: 12 additions & 8 deletions src/mame/kaypro/kaypro_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
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());
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_state_int(Z80_SP, mem_avail + 384); // put the stack a bit before BDOS
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

return std::make_pair(std::error_condition(), std::string());
}
15 changes: 8 additions & 7 deletions src/mame/ncr/dmv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
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());
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_maincpu->set_state_int(Z80_SP, mem_avail + 384); // put the stack a bit before BDOS
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

return std::make_pair(std::error_condition(), std::string());
}
Expand Down
27 changes: 14 additions & 13 deletions src/mame/sony/smc777.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,33 +419,34 @@ 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
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());
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);
// 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());
Expand Down
26 changes: 14 additions & 12 deletions src/mame/xerox/xerox820.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,35 +380,37 @@ 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) */
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());
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);
// 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());
Expand Down

0 comments on commit d0ebbc0

Please sign in to comment.