summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/vic10/exp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/vic10/exp.cpp')
-rw-r--r--src/devices/bus/vic10/exp.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/devices/bus/vic10/exp.cpp b/src/devices/bus/vic10/exp.cpp
index 8ad3d88d8ca..2e050b40cc3 100644
--- a/src/devices/bus/vic10/exp.cpp
+++ b/src/devices/bus/vic10/exp.cpp
@@ -11,6 +11,8 @@
#include "formats/cbm_crt.h"
+#include <tuple>
+
//**************************************************************************
// DEVICE DEFINITIONS
@@ -82,24 +84,35 @@ void vic10_expansion_slot_device::device_start()
std::pair<std::error_condition, std::string> vic10_expansion_slot_device::call_load()
{
+ std::error_condition err;
+
if (m_card)
{
if (!loaded_through_softlist())
{
+ util::core_file &file = image_core_file();
size_t const size = length();
if (is_filetype("80"))
{
- fread(m_card->m_lorom, 0x2000);
+ size_t actual;
+ std::tie(err, m_card->m_lorom, actual) = read(file, 0x2000);
+ if (!err && (actual != 0x2000))
+ err = std::errc::io_error;
- if (size == 0x4000)
+ if (!err && (size == 0x4000))
{
- fread(m_card->m_uprom, 0x2000);
+ std::tie(err, m_card->m_uprom, actual) = read(file, 0x2000);
+ if (!err && (actual != 0x2000))
+ err = std::errc::io_error;
}
}
else if (is_filetype("e0"))
{
- fread(m_card->m_uprom, size);
+ size_t actual;
+ std::tie(err, m_card->m_uprom, actual) = read(file, size);
+ if (!err && (actual != size))
+ err = std::errc::io_error;
}
else if (is_filetype("crt"))
{
@@ -108,7 +121,7 @@ std::pair<std::error_condition, std::string> vic10_expansion_slot_device::call_l
int exrom = 1;
int game = 1;
- if (cbm_crt_read_header(image_core_file(), &roml_size, &romh_size, &exrom, &game))
+ if (cbm_crt_read_header(file, &roml_size, &romh_size, &exrom, &game))
{
uint8_t *roml = nullptr;
uint8_t *romh = nullptr;
@@ -119,9 +132,13 @@ std::pair<std::error_condition, std::string> vic10_expansion_slot_device::call_l
if (roml_size) roml = m_card->m_lorom.get();
if (romh_size) romh = m_card->m_lorom.get();
- cbm_crt_read_data(image_core_file(), roml, romh);
+ cbm_crt_read_data(file, roml, romh);
}
}
+ else
+ {
+ err = image_error::INVALIDIMAGE;
+ }
}
else
{
@@ -131,7 +148,7 @@ std::pair<std::error_condition, std::string> vic10_expansion_slot_device::call_l
}
}
- return std::make_pair(std::error_condition(), std::string());
+ return std::make_pair(err, std::string());
}