summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/ti99/peb/horizon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/ti99/peb/horizon.cpp')
-rw-r--r--src/devices/bus/ti99/peb/horizon.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/devices/bus/ti99/peb/horizon.cpp b/src/devices/bus/ti99/peb/horizon.cpp
index 1be6264189c..d594f445e5b 100644
--- a/src/devices/bus/ti99/peb/horizon.cpp
+++ b/src/devices/bus/ti99/peb/horizon.cpp
@@ -126,16 +126,16 @@
#include "emu.h"
#include "horizon.h"
-#define LOG_WARN (1U<<1) // Warnings
-#define LOG_CONFIG (1U<<2) // Configuration
-#define LOG_32K (1U<<3) // 32K optional RAM r/w
-#define LOG_DSR (1U<<4) // DSR
-#define LOG_RAM (1U<<5) // RAM chips
-#define LOG_ORAM (1U<<6) // outside of RAM chips
-#define LOG_CRU (1U<<7) // CRU
-#define LOG_PAGE (1U<<8) // Page access
+#define LOG_WARN (1U << 1) // Warnings
+#define LOG_CONFIG (1U << 2) // Configuration
+#define LOG_32K (1U << 3) // 32K optional RAM r/w
+#define LOG_DSR (1U << 4) // DSR
+#define LOG_RAM (1U << 5) // RAM chips
+#define LOG_ORAM (1U << 6) // outside of RAM chips
+#define LOG_CRU (1U << 7) // CRU
+#define LOG_PAGE (1U << 8) // Page access
-#define VERBOSE ( LOG_GENERAL | LOG_CONFIG | LOG_WARN )
+#define VERBOSE (LOG_GENERAL | LOG_CONFIG | LOG_WARN)
#include "logmacro.h"
@@ -324,7 +324,6 @@ void horizon_ramdisk_device::read_write(offs_t offset, uint8_t *value, bool writ
*/
void horizon_ramdisk_device::crureadz(offs_t offset, uint8_t *value)
{
- return;
}
/*
@@ -450,14 +449,11 @@ void horizon_ramdisk_device::nvram_default()
}
-void horizon_ramdisk_device::nvram_read(emu_file &file)
+bool horizon_ramdisk_device::nvram_read(util::read_stream &file)
{
int ramsize, dsrsize;
get_mem_size(ramsize, dsrsize);
- if (file.size() != ramsize + dsrsize)
- LOGMASKED(LOG_WARN, "NVRAM file size (%d) does not match the current configuration. Check settings.\n", file.size());
-
// NVRAM plus ROS, according to the current configuration
auto buffer = make_unique_clear<uint8_t []>(ramsize + dsrsize);
@@ -466,8 +462,10 @@ void horizon_ramdisk_device::nvram_read(emu_file &file)
// Read complete file, at most ramsize+dsrsize
// Mind that the configuration may have changed
- int filesize = file.read(&buffer[0], ramsize + dsrsize);
- int nvramsize = filesize - dsrsize;
+ auto const [err, filesize] = util::read(file, &buffer[0], ramsize + dsrsize);
+ if (err)
+ return false;
+ int nvramsize = int(filesize) - dsrsize;
// At least the DSR must be complete
if (nvramsize >= 0)
@@ -475,10 +473,14 @@ void horizon_ramdisk_device::nvram_read(emu_file &file)
// Copy from buffer to NVRAM and ROS
if (nvramsize > 0) memcpy(m_ram->pointer(), &buffer[0], nvramsize);
memcpy(m_dsrram->pointer(), &buffer[nvramsize], dsrsize);
+
+ return true;
}
+
+ return false;
}
-void horizon_ramdisk_device::nvram_write(emu_file &file)
+bool horizon_ramdisk_device::nvram_write(util::write_stream &file)
{
int ramsize, dsrsize;
get_mem_size(ramsize, dsrsize);
@@ -490,10 +492,11 @@ void horizon_ramdisk_device::nvram_write(emu_file &file)
memcpy(&buffer[ramsize], m_dsrram->pointer(), dsrsize);
// Store both parts in one file
- file.write(buffer.get(), ramsize + dsrsize);
+ auto const [err, filesize] = util::write(file, buffer.get(), ramsize + dsrsize);
+ return !err;
}
-bool horizon_ramdisk_device::nvram_can_write()
+bool horizon_ramdisk_device::nvram_can_write() const
{
// Do not save if nothing was written. This is helpful to avoid loss of the
// contents when the settings were found to be different, and the emulation