summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-12-24 02:33:22 +1100
committer Vas Crabb <vas@vastheman.com>2022-12-24 02:33:22 +1100
commit50fa0a6609235cbb6babf3b1a11e274542a1c00c (patch)
tree9a3ebccc0ccda1878ff40fc5d896ca57d8297208 /src
parent471438ac10f84c22558ff642ed1c1cac3e3e164e (diff)
imagedev: Allow command-line creation for tapes/memory cards/printouts.
Also made image devices not request read access when creating files for write-only devices.
Diffstat (limited to 'src')
-rw-r--r--src/devices/imagedev/cassette.h1
-rw-r--r--src/devices/imagedev/magtape.h1
-rw-r--r--src/devices/imagedev/memcard.h1
-rw-r--r--src/devices/imagedev/printer.h1
-rw-r--r--src/emu/diimage.cpp23
5 files changed, 18 insertions, 9 deletions
diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h
index ad71e062e70..6d05b5e94a5 100644
--- a/src/devices/imagedev/cassette.h
+++ b/src/devices/imagedev/cassette.h
@@ -67,6 +67,7 @@ public:
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
virtual bool is_reset_on_load() const noexcept override { return false; }
+ virtual bool support_command_line_image_creation() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return m_interface; }
virtual const char *file_extensions() const noexcept override { return m_extension_list; }
virtual const char *image_type_name() const noexcept override { return "cassette"; }
diff --git a/src/devices/imagedev/magtape.h b/src/devices/imagedev/magtape.h
index 5834573240c..8d302a93a58 100644
--- a/src/devices/imagedev/magtape.h
+++ b/src/devices/imagedev/magtape.h
@@ -28,6 +28,7 @@ public:
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
virtual bool is_reset_on_load() const noexcept override { return false; }
+ virtual bool support_command_line_image_creation() const noexcept override { return true; }
virtual const char *image_type_name() const noexcept override { return "magtape"; }
virtual const char *image_brief_type_name() const noexcept override { return "mtap"; }
diff --git a/src/devices/imagedev/memcard.h b/src/devices/imagedev/memcard.h
index 33ff6a4a62d..afac414a39a 100644
--- a/src/devices/imagedev/memcard.h
+++ b/src/devices/imagedev/memcard.h
@@ -27,6 +27,7 @@ public:
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
+ virtual bool support_command_line_image_creation() const noexcept override { return true; }
virtual const char *image_type_name() const noexcept override { return "memcard"; }
virtual const char *image_brief_type_name() const noexcept override { return "memc"; }
diff --git a/src/devices/imagedev/printer.h b/src/devices/imagedev/printer.h
index 509ecc43ef2..f509527a014 100644
--- a/src/devices/imagedev/printer.h
+++ b/src/devices/imagedev/printer.h
@@ -39,6 +39,7 @@ public:
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
virtual bool is_reset_on_load() const noexcept override { return false; }
+ virtual bool support_command_line_image_creation() const noexcept override { return true; }
virtual const char *file_extensions() const noexcept override { return "prn"; }
virtual const char *image_type_name() const noexcept override { return "printout"; }
virtual const char *image_brief_type_name() const noexcept override { return "prin"; }
diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp
index c741cab8b40..3073d8f2495 100644
--- a/src/emu/diimage.cpp
+++ b/src/emu/diimage.cpp
@@ -562,15 +562,20 @@ std::vector<u32> device_image_interface::determine_open_plan(bool is_create)
{
std::vector<u32> open_plan;
- // emit flags into a vector
- if (!is_create && is_readable() && is_writeable())
- open_plan.push_back(OPEN_FLAG_READ | OPEN_FLAG_WRITE);
- if (!is_create && !is_readable() && is_writeable())
- open_plan.push_back(OPEN_FLAG_WRITE);
- if (!is_create && is_readable())
- open_plan.push_back(OPEN_FLAG_READ);
- if (is_create && is_writeable() && is_creatable())
- open_plan.push_back(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
+ if (!is_create)
+ {
+ if (is_writeable())
+ open_plan.push_back(is_readable() ? (OPEN_FLAG_READ | OPEN_FLAG_WRITE) : OPEN_FLAG_WRITE);
+ else if (is_readable())
+ open_plan.push_back(OPEN_FLAG_READ);
+ }
+ else if (is_writeable() && is_creatable())
+ {
+ if (is_readable())
+ open_plan.push_back(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
+ else
+ open_plan.push_back(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
+ }
return open_plan;
}