floppy: Filter out the writes when write protected, useful when when the apple2gs does a packet send (e.g a write) over DCD with write protect forced on (to avoid damaging a possibly present disk).

This commit is contained in:
Olivier Galibert 2021-02-12 09:35:55 +01:00
parent 1a44294de9
commit 9ba8e4a8c8
3 changed files with 21 additions and 4 deletions

View File

@ -954,10 +954,21 @@ attotime floppy_image_device::get_next_transition(const attotime &from_when)
} }
} }
bool floppy_image_device::writing_disabled() const
{
// Disable writing when write protect is on or when, in the diskii
// case, phase 1 is 1
return wpt || (phases & 2);
}
void floppy_image_device::write_flux(const attotime &start, const attotime &end, int transition_count, const attotime *transitions) void floppy_image_device::write_flux(const attotime &start, const attotime &end, int transition_count, const attotime *transitions)
{ {
if(!image || mon) if(!image || mon)
return; return;
if(writing_disabled())
return;
image_dirty = true; image_dirty = true;
cache_clear(); cache_clear();
@ -2418,6 +2429,11 @@ void mac_floppy_device::device_reset()
// 1110 - HD-20 drive // 1110 - HD-20 drive
// 1111 - No drive (pull-up on the sense line) // 1111 - No drive (pull-up on the sense line)
bool mac_floppy_device::writing_disabled() const
{
return wpt;
}
bool mac_floppy_device::wpt_r() bool mac_floppy_device::wpt_r()
{ {
static const char *const regnames[16] = { static const char *const regnames[16] = {

View File

@ -96,7 +96,8 @@ public:
void setup_led_cb(led_cb cb); void setup_led_cb(led_cb cb);
std::vector<uint32_t> &get_buffer() { return image->get_buffer(cyl, ss, subcyl); } std::vector<uint32_t> &get_buffer() { return image->get_buffer(cyl, ss, subcyl); }
int get_cyl() { return cyl; } int get_cyl() const { return cyl; }
bool on_track() const { return !subcyl; }
virtual void mon_w(int state); virtual void mon_w(int state);
bool ready_r(); bool ready_r();
@ -111,6 +112,8 @@ public:
bool ss_r() { return ss; } bool ss_r() { return ss; }
bool twosid_r(); bool twosid_r();
virtual bool writing_disabled() const;
virtual void seek_phase_w(int phases); virtual void seek_phase_w(int phases);
void stp_w(int state); void stp_w(int state);
void dir_w(int state) { dir = state; } void dir_w(int state) { dir = state; }
@ -285,6 +288,7 @@ public:
virtual void mon_w(int) override; virtual void mon_w(int) override;
virtual void seek_phase_w(int phases) override; virtual void seek_phase_w(int phases) override;
virtual const char *image_interface() const noexcept override { return "floppy_3_5"; } virtual const char *image_interface() const noexcept override { return "floppy_3_5"; }
virtual bool writing_disabled() const override;
protected: protected:
u8 m_reg; u8 m_reg;

View File

@ -100,9 +100,6 @@ void iwm_device::set_floppy(floppy_image_device *floppy)
sync(); sync();
if(floppy && std::string(floppy->tag()) == ":fdc:0:525")
machine().debug_break();
logerror("floppy %s\n", floppy ? floppy->tag() : "-"); logerror("floppy %s\n", floppy ? floppy->tag() : "-");
if(m_floppy && (m_control & 0x10)) if(m_floppy && (m_control & 0x10))