diff options
author | Olivier Galibert <galibert@pobox.com> | 2021-01-11 23:32:54 +0100 |
---|---|---|
committer | Olivier Galibert <galibert@pobox.com> | 2021-01-11 23:33:03 +0100 |
commit | c5fe64666af97d5029af5e1707257b9258218faf (patch) | |
tree | 084bf4483aa98abd5544105fe7968e3437368ff5 | |
parent | 6611ce99a027e37ecc0cb01e9efebc44d898c07c (diff) |
mac/swim2: Add apple drivers and associated communications
-rw-r--r-- | src/devices/imagedev/floppy.cpp | 170 | ||||
-rw-r--r-- | src/devices/imagedev/floppy.h | 42 | ||||
-rwxr-xr-x | src/devices/machine/applefdintf.cpp | 3 | ||||
-rwxr-xr-x | src/devices/machine/applefdintf.h | 2 | ||||
-rw-r--r-- | src/devices/machine/swim2.cpp | 21 | ||||
-rw-r--r-- | src/mame/drivers/mac.cpp | 6 | ||||
-rw-r--r-- | src/mame/includes/mac.h | 8 | ||||
-rw-r--r-- | src/mame/machine/mac.cpp | 48 |
8 files changed, 284 insertions, 16 deletions
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index ae8764d8c7c..fb99ba5dacb 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -118,6 +118,10 @@ DEFINE_DEVICE_TYPE(ALPS_3255190X, alps_3255190x, "alps_3255190x", "ALPS 32551901 // IBM 8" drives DEFINE_DEVICE_TYPE(IBM_6360, ibm_6360, "ibm_6360", "IBM 6360 8\" single-sided single density floppy drive") +// Mac 3.5" drives +DEFINE_DEVICE_TYPE(MFD51W, mfd51w_device, "mfd51w", "Apple/Sony 3.5 DD variable-speed drive") +DEFINE_DEVICE_TYPE(MFD75W, mfd75w_device, "mfd75w", "Apple/Sony 3.5 HD variable-speed drive") + const floppy_format_type floppy_image_device::default_floppy_formats[] = { FLOPPY_D88_FORMAT, @@ -551,6 +555,12 @@ image_init_result floppy_image_device::call_create(int format_type, util::option return image_init_result::PASS; } +/* write protect, active high */ +bool floppy_image_device::wpt_r() +{ + return wpt; +} + /* motor on, active low */ void floppy_image_device::mon_w(int state) { @@ -2349,3 +2359,163 @@ void ibm_6360::setup_characteristics() variants.push_back(floppy_image::SSSD); } + + +//------------------------------------------------- +// Variable-speed Macintosh drives +//------------------------------------------------- + +mac_floppy_device::mac_floppy_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : floppy_image_device(mconfig, type, tag, owner, clock) +{ +} + +void mac_floppy_device::device_start() +{ + floppy_image_device::device_start(); + save_item(NAME(m_reg)); + save_item(NAME(m_strb)); +} + +void mac_floppy_device::device_reset() +{ + floppy_image_device::device_reset(); + m_reg = 0; + m_strb = 0; +} + +bool mac_floppy_device::wpt_r() +{ + static const char *const regnames[16] = { + "Dir", "Step", "Motor", "Eject", + "RdData0", "MFMDrive", "DoubleSide", "NoDrive", + "NoDiskInPl", "NoWrProtect", "NotTrack0", "NoTachPulse", + "RdData1", "MFMModeOn", "NoReady", "NotRevised" + }; + + logerror("fdc disk wpt_r reg %x %s\n", m_reg, regnames[m_reg]); + if(m_reg == 4) + machine().debug_break(); + + switch(m_reg) { + case 0x2: // Is the motor on? + return mon; + + case 0x4: // Used when reading data, result ignored + return false; + + case 0x5: // Is it a superdrive? + return true; + + case 0x6: // Is the drive double-sided? + return true; + + case 0x7: // Does drive exist? + return true; + + case 0x8: // Is there a disk in the drive? + return image != nullptr; + + case 0x9: // Is the disk write-protected? + return wpt; + + case 0xa: // Not on track 0? + return cyl == 0; + + case 0xf: // Does it implement the new interface? + return true; + + default: + return false; + } +} + +void mac_floppy_device::seek_phase_w(int phases) +{ + static const char *const regnames[16] = { + "DirNext", "StepOn", "MotorOn", "EjectOff", + "DirPrev", "StepOff", "MotorOff", "EjectOn", + "-", "MFMModeOn", "-", "-", + "-", "GCRModeOn", "-", "-" + }; + + bool prev_strb = m_strb; + + m_reg = (phases & 7) | (ss ? 8 : 0); + m_strb = (phases >> 3) & 1; + + if(m_strb && !prev_strb) { + switch(m_reg) { + case 0x0: // Step to cylinder + 1 + logerror("cmd step dir +1\n"); + dir_w(0); + break; + + case 0x1: // Step + logerror("cmd step\n"); + stp_w(0); + stp_w(1); + break; + + case 0x2: // Motor on + logerror("cmd motor on\n"); + mon_w(0); + break; + + case 0x3: // End eject + logerror("cmd end eject\n"); + break; + + case 0x4: // Step to cylinder - 1 + logerror("cmd step dir -1\n"); + dir_w(1); + break; + + case 0x6: // Motor off + logerror("cmd motor off\n"); + mon_w(1); + break; + + case 0x7: // Start eject + logerror("cmd start eject\n"); + call_unload(); + break; + + default: + logerror("cmd reg %x %s\n", m_reg, regnames[m_reg]); + break; + } + } +} + +mfd51w_device::mfd51w_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mac_floppy_device(mconfig, MFD51W, tag, owner, clock) +{ +} + +void mfd51w_device::setup_characteristics() +{ + form_factor = floppy_image::FF_35; + tracks = 80; + sides = 2; + set_rpm(300); + + variants.push_back(floppy_image::SSSD); + variants.push_back(floppy_image::SSDD); + variants.push_back(floppy_image::DSDD); +} + +mfd75w_device::mfd75w_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mac_floppy_device(mconfig, MFD75W, tag, owner, clock) +{ +} + +void mfd75w_device::setup_characteristics() +{ + form_factor = floppy_image::FF_35; + tracks = 80; + sides = 2; + set_rpm(300); + + variants.push_back(floppy_image::SSSD); + variants.push_back(floppy_image::SSDD); + variants.push_back(floppy_image::DSDD); + variants.push_back(floppy_image::DSHD); +} diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index dc9dd57ef3b..82cc39dcfdb 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -103,7 +103,7 @@ public: void set_ready(bool state); double get_pos(); - bool wpt_r() { return wpt; } + virtual bool wpt_r(); // Mac sony drives using this for various reporting int dskchg_r() { return dskchg; } bool trk00_r() { return (has_trk00_sensor ? (cyl != 0) : 1); } int idx_r() { return idx; } @@ -111,7 +111,7 @@ public: bool ss_r() { return ss; } bool twosid_r(); - void seek_phase_w(int phases); + virtual void seek_phase_w(int phases); void stp_w(int state); void dir_w(int state) { dir = state; } void ss_w(int state) { if (sides > 1) ss = state; } @@ -273,6 +273,44 @@ DECLARE_FLOPPY_IMAGE_DEVICE(IBM_6360, ibm_6360, "floppy_8" DECLARE_DEVICE_TYPE(FLOPPYSOUND, floppy_sound_device) +class mac_floppy_device : public floppy_image_device { +public: + virtual ~mac_floppy_device() = default; + + virtual bool wpt_r() override; + virtual void seek_phase_w(int phases) override; + virtual const char *image_interface() const noexcept override { return "floppy_3_5"; } + +protected: + u8 m_reg; + bool m_strb; + + mac_floppy_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + + virtual void device_start() override; + virtual void device_reset() override; +}; + +class mfd51w_device : public mac_floppy_device { +public: + mfd51w_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual ~mfd51w_device() = default; +protected: + virtual void setup_characteristics() override; +}; + +class mfd75w_device : public mac_floppy_device { +public: + mfd75w_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual ~mfd75w_device() = default; + +protected: + virtual void setup_characteristics() override; +}; + +DECLARE_DEVICE_TYPE(MFD51W, mfd51w_device) +DECLARE_DEVICE_TYPE(MFD75W, mfd75w_device) + /* Floppy drive sound diff --git a/src/devices/machine/applefdintf.cpp b/src/devices/machine/applefdintf.cpp index 3b1590720c1..8d859601c6b 100755 --- a/src/devices/machine/applefdintf.cpp +++ b/src/devices/machine/applefdintf.cpp @@ -31,7 +31,8 @@ void applefdintf_device::floppies_525(device_slot_interface &device) void applefdintf_device::floppies_35(device_slot_interface &device) { - device.option_add("35", FLOPPY_35_HD); + device.option_add("35dd", MFD51W); + device.option_add("35hd", MFD75W); } applefdintf_device::applefdintf_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : diff --git a/src/devices/machine/applefdintf.h b/src/devices/machine/applefdintf.h index 19095e875cc..ad8883765eb 100755 --- a/src/devices/machine/applefdintf.h +++ b/src/devices/machine/applefdintf.h @@ -76,7 +76,7 @@ public: // 3.5 static void floppies_35(device_slot_interface &device); template<typename T> static void add_35(machine_config &config, T &floppy) { - FLOPPY_CONNECTOR(config, floppy, floppies_35, "35", formats_35); + FLOPPY_CONNECTOR(config, floppy, floppies_35, "35dd", formats_35); } template<typename T> static void add_35_nc(machine_config &config, T &floppy) { FLOPPY_CONNECTOR(config, floppy, floppies_35, "", formats_35); diff --git a/src/devices/machine/swim2.cpp b/src/devices/machine/swim2.cpp index 992702bf782..9b9ff9fac60 100644 --- a/src/devices/machine/swim2.cpp +++ b/src/devices/machine/swim2.cpp @@ -68,12 +68,9 @@ void swim2_device::set_floppy(floppy_image_device *floppy) if(m_floppy == floppy) return; - if(m_floppy) - m_floppy->mon_w(true); m_floppy = floppy; - if(m_mode & 0x80) - m_floppy->mon_w(false); update_phases(); + m_hdsel_cb((m_mode >> 5) & 1); } floppy_image_device *swim2_device::get_floppy() const @@ -107,14 +104,13 @@ void swim2_device::flush_write(u64 when) void swim2_device::show_mode() const { - logerror("mode%s %s hdsel=%c %c%s %c%c%s\n", + logerror("mode%s hdsel=%c %c%s %c%c%s\n", m_mode & 0x80 ? " motoron" : "", - m_mode & 0x40 ? "ism" : "iwm", m_mode & 0x20 ? '1' : '0', m_mode & 0x10 ? 'w' : 'r', m_mode & 0x08 ? " action" : "", - m_mode & 0x04 ? 'a' : '-', - m_mode & 0x02 ? 'b' : '-', + m_mode & 0x04 ? 'b' : '-', + m_mode & 0x02 ? 'a' : '-', m_mode & 0x01 ? " clear" : ""); } @@ -246,7 +242,7 @@ void swim2_device::write(offs_t offset, u8 data) case 5: // setup m_setup = data; - m_sel35_cb(m_setup & 0x02); + m_sel35_cb((m_setup >> 1) & 1); logerror("setup write=%s %s test=%s %s %s 3.5=%s %s\n", m_setup & 0x40 ? "gcr" : "mfm", m_setup & 0x20 ? "ibm" : "apple", @@ -277,6 +273,11 @@ void swim2_device::write(offs_t offset, u8 data) if(m_mode & 0x01) fifo_clear(); + if((m_mode ^ prev_mode) & 0x06) + m_devsel_cb(m_mode & 0x80 ? (m_mode >> 1) & 3 : 0); + if((m_mode ^ prev_mode) & 0x20) + m_hdsel_cb((m_mode >> 5) & 1); + if((m_mode & 0x18) == 0x18 && ((prev_mode & 0x18) != 0x18)) { // Entering write mode m_current_bit = 0; @@ -353,7 +354,7 @@ void swim2_device::sync() // We count in half-cycles but only toggle write on full cycles u32 cycles = (next_sync - m_last_sync) << 1; - // logerror("ACTIVE %s %d-%d (%d)\n", m_mode & 0x10 ? "write" : "read", m_last_sync, next_sync, cycles); + logerror("ACTIVE %s %d-%d (%d)\n", m_mode & 0x10 ? "write" : "read", m_last_sync, next_sync, cycles); while(cycles) { // logerror("half cycles avail %d needed %d\n", cycles, m_half_cycles_before_change); diff --git a/src/mame/drivers/mac.cpp b/src/mame/drivers/mac.cpp index 9137200bce1..1810a154493 100644 --- a/src/mame/drivers/mac.cpp +++ b/src/mame/drivers/mac.cpp @@ -751,8 +751,10 @@ void mac_state::add_base_devices(machine_config &config, bool rtc, int woz_versi break; } - m_fdc->phases_cb().set([this](u8 data) { logerror("fdc phases = %x\n", data);}); - m_fdc->sel35_cb().set([this](int data) { logerror("fdc sel35 = %d\n", data);}); + m_fdc->phases_cb().set(FUNC(mac_state::phases_w)); + m_fdc->sel35_cb().set(FUNC(mac_state::sel35_w)); + m_fdc->devsel_cb().set(FUNC(mac_state::devsel_w)); + m_fdc->hdsel_cb().set(FUNC(mac_state::hdsel_w)); applefdintf_device::add_35(config, m_floppy[0]); applefdintf_device::add_35_nc(config, m_floppy[1]); diff --git a/src/mame/includes/mac.h b/src/mame/includes/mac.h index fcb4fa2af0c..c2f1a7ea55c 100644 --- a/src/mame/includes/mac.h +++ b/src/mame/includes/mac.h @@ -87,6 +87,7 @@ public: { m_rom_size = 0; m_rom_ptr = nullptr; + m_cur_floppy = nullptr; } void add_scsi(machine_config &config, bool cdrom = false); @@ -396,8 +397,15 @@ private: emu_timer *m_scanline_timer; + floppy_image_device *m_cur_floppy; + uint8_t m_pm_req, m_pm_state, m_pm_dptr, m_pm_cmd; + void phases_w(uint8_t phases); + void sel35_w(int sel35); + void devsel_w(uint8_t devsel); + void hdsel_w(int hdsel); + DECLARE_VIDEO_START(mac); DECLARE_VIDEO_START(macsonora); DECLARE_VIDEO_RESET(macrbv); diff --git a/src/mame/machine/mac.cpp b/src/mame/machine/mac.cpp index 1337bc1caa2..cd0f83cbf5a 100644 --- a/src/mame/machine/mac.cpp +++ b/src/mame/machine/mac.cpp @@ -2457,3 +2457,51 @@ void mac_state::mac_tracetrap(const char *cpu_name_local, int addr, int trap) logerror("mac_trace_trap: %s at 0x%08x: %s\n",cpu_name_local, addr, buf); } #endif + +#if !NEW_SWIM +void mac_state::phases_w(u8) +{ +} + +void mac_state::sel35_w(int) +{ +} + +void mac_state::devsel_w(u8) +{ +} + +void mac_state::hdsel_w(int) +{ +} +#else + +void mac_state::phases_w(uint8_t phases) +{ + if(m_cur_floppy) + m_cur_floppy->seek_phase_w(phases); +} + +void mac_state::sel35_w(int sel35) +{ + logerror("fdc mac sel35 %d\n", sel35); +} + +void mac_state::devsel_w(uint8_t devsel) +{ + if(devsel == 1) + m_cur_floppy = m_floppy[0]->get_device(); + else if(devsel == 2) + m_cur_floppy = m_floppy[1]->get_device(); + else + m_cur_floppy = nullptr; + m_fdc->set_floppy(m_cur_floppy); +} + +void mac_state::hdsel_w(int hdsel) +{ + if(m_cur_floppy) + m_cur_floppy->ss_w(hdsel); +} + +#endif |