mirror of
https://github.com/holub/mame
synced 2025-06-28 15:14:21 +03:00
acorn/z88_impexp.cpp, nascom/nascom1.cpp: Modernize file I/O
This commit is contained in:
parent
102aa77ccc
commit
be3919035b
@ -176,11 +176,16 @@ std::pair<std::error_condition, std::string> z88_impexp_device::call_load()
|
|||||||
// file data
|
// file data
|
||||||
m_queue.push(0x1b);
|
m_queue.push(0x1b);
|
||||||
m_queue.push('F');
|
m_queue.push('F');
|
||||||
while (!image_feof())
|
|
||||||
|
util::core_file &file = image_core_file();
|
||||||
|
std::error_condition err;
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
|
size_t actual;
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
if (fread(&b, 1) != 1)
|
err = file.read(&b, 1, actual);
|
||||||
return std::make_pair(image_error::UNSPECIFIED, std::string());
|
if (err || actual != 1)
|
||||||
|
break;
|
||||||
|
|
||||||
// Escape non printable characters
|
// Escape non printable characters
|
||||||
if ((b < 0x20 || b >= 0x7f) && b != 0x0a && b != 0x0d && b != 0x09)
|
if ((b < 0x20 || b >= 0x7f) && b != 0x0a && b != 0x0d && b != 0x09)
|
||||||
@ -205,7 +210,7 @@ std::pair<std::error_condition, std::string> z88_impexp_device::call_load()
|
|||||||
m_queue.push('E');
|
m_queue.push('E');
|
||||||
queue();
|
queue();
|
||||||
|
|
||||||
return std::make_pair(std::error_condition(), std::string());
|
return std::make_pair(err, std::string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,9 +319,12 @@ TIMER_DEVICE_CALLBACK_MEMBER( nascom2_state::nascom2_kansas_r )
|
|||||||
template<int Dest>
|
template<int Dest>
|
||||||
SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb)
|
SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb)
|
||||||
{
|
{
|
||||||
|
util::core_file &file = image.image_core_file();
|
||||||
uint8_t line[29];
|
uint8_t line[29];
|
||||||
|
|
||||||
while (image.fread(&line, sizeof(line)) == sizeof(line))
|
std::error_condition err;
|
||||||
|
size_t actual;
|
||||||
|
while (!(err = file.read(&line, sizeof(line), actual)) && actual == sizeof(line))
|
||||||
{
|
{
|
||||||
unsigned int addr, b[8], dummy;
|
unsigned int addr, b[8], dummy;
|
||||||
|
|
||||||
@ -346,13 +349,15 @@ SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb)
|
|||||||
return std::make_pair(image_error::INVALIDIMAGE, "Unsupported file format");
|
return std::make_pair(image_error::INVALIDIMAGE, "Unsupported file format");
|
||||||
}
|
}
|
||||||
dummy = 0x00;
|
dummy = 0x00;
|
||||||
while (!image.image_feof() && dummy != 0x0a && dummy != 0x1f)
|
while (dummy != 0x0a && dummy != 0x1f)
|
||||||
{
|
{
|
||||||
image.fread(&dummy, 1);
|
err = file.read(&dummy, 1, actual);
|
||||||
|
if (err || actual != 1)
|
||||||
|
return std::make_pair(err, std::string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_pair(std::error_condition(), std::string());
|
return std::make_pair(err, std::string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -372,7 +377,11 @@ std::pair<std::error_condition, std::string> nascom2_state::load_cart(
|
|||||||
return std::make_pair(image_error::INVALIDLENGTH, "Unsupported image file size (must be no more than 4K)");
|
return std::make_pair(image_error::INVALIDLENGTH, "Unsupported image file size (must be no more than 4K)");
|
||||||
|
|
||||||
slot->rom_alloc(slot->length(), GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE);
|
slot->rom_alloc(slot->length(), GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE);
|
||||||
slot->fread(slot->get_rom_base(), slot->length());
|
|
||||||
|
size_t actual;
|
||||||
|
std::error_condition const err = slot->image_core_file().read(slot->get_rom_base(), slot->length(), actual);
|
||||||
|
if (err || actual != slot->length())
|
||||||
|
return std::make_pair(err ? err : std::errc::io_error, std::string());
|
||||||
|
|
||||||
// we just assume that socket1 should be loaded to 0xc000 and socket2 to 0xd000
|
// we just assume that socket1 should be loaded to 0xc000 and socket2 to 0xd000
|
||||||
switch (slot_id)
|
switch (slot_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user