summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/imagedev/bitbngr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/imagedev/bitbngr.cpp')
-rw-r--r--src/devices/imagedev/bitbngr.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/devices/imagedev/bitbngr.cpp b/src/devices/imagedev/bitbngr.cpp
index 2a18395ad75..86c92c88ceb 100644
--- a/src/devices/imagedev/bitbngr.cpp
+++ b/src/devices/imagedev/bitbngr.cpp
@@ -9,6 +9,10 @@
#include "emu.h"
#include "bitbngr.h"
+#include "softlist_dev.h"
+
+#include <cstring>
+
/***************************************************************************
@@ -24,6 +28,8 @@ DEFINE_DEVICE_TYPE(BITBANGER, bitbanger_device, "bitbanger", "Bitbanger")
bitbanger_device::bitbanger_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, BITBANGER, tag, owner, clock),
device_image_interface(mconfig, *this),
+ m_next(nullptr),
+ m_end(nullptr),
m_interface(nullptr),
m_is_readonly(false)
{
@@ -37,10 +43,8 @@ bitbanger_device::bitbanger_device(const machine_config &mconfig, const char *ta
void bitbanger_device::output(uint8_t data)
{
- if (exists())
- {
+ if (!loaded_through_softlist() && exists())
fwrite(&data, 1);
- }
}
@@ -50,11 +54,21 @@ void bitbanger_device::output(uint8_t data)
uint32_t bitbanger_device::input(void *buffer, uint32_t length)
{
- if (exists())
+ if (loaded_through_softlist())
+ {
+ size_t const result = std::min<size_t>(length, m_end - m_next);
+ memcpy(buffer, m_next, result);
+ m_next += result;
+ return uint32_t(result);
+ }
+ else if (exists())
{
return fread(buffer, length);
}
- return 0;
+ else
+ {
+ return 0;
+ }
}
@@ -63,8 +77,19 @@ uint32_t bitbanger_device::input(void *buffer, uint32_t length)
device_start
-------------------------------------------------*/
-void bitbanger_device::device_start(void)
+void bitbanger_device::device_start()
+{
+}
+
+
+
+/*-------------------------------------------------
+ get_software_list_loader
+-------------------------------------------------*/
+
+const software_list_loader &bitbanger_device::get_software_list_loader() const
{
+ return rom_software_list_loader::instance();
}
@@ -73,15 +98,24 @@ void bitbanger_device::device_start(void)
call_load
-------------------------------------------------*/
-image_init_result bitbanger_device::call_load(void)
+image_init_result bitbanger_device::call_load()
{
- /* we don't need to do anything special */
+ if (loaded_through_softlist())
+ {
+ auto const length = get_software_region_length("input");
+ m_next = get_software_region("input");
+ m_end = m_next + length;
+ }
+ else
+ {
+ m_next = m_end = nullptr;
+ }
return image_init_result::PASS;
}
image_init_result bitbanger_device::call_create(int format_type, util::option_resolution *format_options)
{
- /* we don't need to do anything special */
+ // we don't need to do anything special
return image_init_result::PASS;
}
@@ -89,6 +123,7 @@ image_init_result bitbanger_device::call_create(int format_type, util::option_re
call_unload
-------------------------------------------------*/
-void bitbanger_device::call_unload(void)
+void bitbanger_device::call_unload()
{
+ m_next = m_end = nullptr;
}