summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Olivier Galibert <galibert@pobox.com>2020-05-08 21:35:40 +0200
committerGravatarGravatar Olivier Galibert <galibert@pobox.com>2020-05-08 21:35:40 +0200
commit63dac99c839e68eb58a8b330eafe04c73d906984 (patch)
treefc64dfae48fe2e00df82dd502a047da0b86f6bcf
parent2dfb819208fa4365fadc33bc271b811521e78aa2 (diff)
apple: Add support for next-gen iwm and swim [O. Galibert]macfdc
-rw-r--r--scripts/src/bus.lua4
-rw-r--r--scripts/src/machine.lua74
-rw-r--r--scripts/target/mame/arcade.lua6
-rw-r--r--scripts/target/mame/mess.lua10
-rw-r--r--src/devices/bus/a2bus/a2diskii.cpp130
-rw-r--r--src/devices/bus/a2bus/a2diskii.h52
-rw-r--r--src/devices/bus/a2bus/a2diskiing.cpp191
-rw-r--r--src/devices/bus/a2bus/a2diskiing.h105
-rw-r--r--src/devices/bus/a2bus/a2iwm.cpp92
-rw-r--r--src/devices/bus/a2bus/a2iwm.h54
-rw-r--r--src/devices/machine/appldriv.cpp336
-rw-r--r--src/devices/machine/appldriv.h71
-rw-r--r--src/devices/machine/applefdc.cpp601
-rw-r--r--src/devices/machine/applefdc.h182
-rw-r--r--src/devices/machine/diskii.cpp350
-rw-r--r--src/devices/machine/diskii.h83
-rw-r--r--src/devices/machine/iwm.cpp440
-rw-r--r--src/devices/machine/iwm.h89
-rw-r--r--src/devices/machine/sonydriv.cpp628
-rw-r--r--src/devices/machine/sonydriv.h66
-rw-r--r--src/devices/machine/swim1.cpp176
-rw-r--r--src/devices/machine/swim1.h50
-rw-r--r--src/devices/machine/swim2.cpp239
-rw-r--r--src/devices/machine/swim2.h61
-rw-r--r--src/devices/machine/swim3.cpp176
-rw-r--r--src/devices/machine/swim3.h50
-rw-r--r--src/devices/machine/wozfdc.cpp504
-rw-r--r--src/devices/machine/wozfdc.h113
-rw-r--r--src/lib/formats/mfi_dsk.cpp3
-rw-r--r--src/mame/drivers/apple2.cpp8
-rw-r--r--src/mame/drivers/apple2e.cpp229
-rw-r--r--src/mame/drivers/apple2gs.cpp202
-rw-r--r--src/mame/drivers/apple3.cpp20
-rw-r--r--src/mame/drivers/lisa.cpp55
-rw-r--r--src/mame/drivers/mac.cpp195
-rw-r--r--src/mame/drivers/mac128.cpp63
-rw-r--r--src/mame/includes/apple3.h16
-rw-r--r--src/mame/includes/lisa.h7
-rw-r--r--src/mame/includes/mac.h23
-rw-r--r--src/mame/machine/apple3.cpp6
-rw-r--r--src/mame/machine/lisa.cpp16
-rw-r--r--src/mame/machine/mac.cpp42
-rw-r--r--src/mame/machine/macpci.cpp2
-rw-r--r--src/mame/machine/swim.cpp223
-rw-r--r--src/mame/machine/swim.h55
45 files changed, 2383 insertions, 3715 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index 11b8e4ea7b8..b8e8dbf38a5 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -2244,6 +2244,8 @@ if (BUSES["A2BUS"]~=null) then
MAME_DIR .. "src/devices/bus/a2bus/a2bus.h",
MAME_DIR .. "src/devices/bus/a2bus/a2diskii.cpp",
MAME_DIR .. "src/devices/bus/a2bus/a2diskii.h",
+ MAME_DIR .. "src/devices/bus/a2bus/a2iwm.cpp",
+ MAME_DIR .. "src/devices/bus/a2bus/a2iwm.h",
MAME_DIR .. "src/devices/bus/a2bus/a2mockingboard.cpp",
MAME_DIR .. "src/devices/bus/a2bus/a2mockingboard.h",
MAME_DIR .. "src/devices/bus/a2bus/a2cffa.cpp",
@@ -2298,8 +2300,6 @@ if (BUSES["A2BUS"]~=null) then
MAME_DIR .. "src/devices/bus/a2bus/a2eramworks3.h",
MAME_DIR .. "src/devices/bus/a2bus/a2corvus.cpp",
MAME_DIR .. "src/devices/bus/a2bus/a2corvus.h",
- MAME_DIR .. "src/devices/bus/a2bus/a2diskiing.cpp",
- MAME_DIR .. "src/devices/bus/a2bus/a2diskiing.h",
MAME_DIR .. "src/devices/bus/a2bus/a2mcms.cpp",
MAME_DIR .. "src/devices/bus/a2bus/a2mcms.h",
MAME_DIR .. "src/devices/bus/a2bus/a2dx1.cpp",
diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua
index ff3315b13de..9bb9c3f7a34 100644
--- a/scripts/src/machine.lua
+++ b/scripts/src/machine.lua
@@ -3700,12 +3700,56 @@ end
---------------------------------------------------
--
---@src/devices/machine/wozfdc.h,MACHINES["WOZFDC"] = true
+--@src/devices/machine/diskii.h,MACHINES["DISKII"] = true
---------------------------------------------------
-if (MACHINES["WOZFDC"]~=null) then
+if (MACHINES["DISKII"]~=null) then
files {
- MAME_DIR .. "src/devices/machine/wozfdc.cpp",
- MAME_DIR .. "src/devices/machine/wozfdc.h",
+ MAME_DIR .. "src/devices/machine/diskii.cpp",
+ MAME_DIR .. "src/devices/machine/diskii.h",
+ }
+end
+
+---------------------------------------------------
+--
+--@src/devices/machine/iwm.h,MACHINES["IWM"] = true
+---------------------------------------------------
+if (MACHINES["IWM"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/machine/iwm.cpp",
+ MAME_DIR .. "src/devices/machine/iwm.h",
+ }
+end
+
+---------------------------------------------------
+--
+--@src/devices/machine/swim1.h,MACHINES["SWIM1"] = true
+---------------------------------------------------
+if (MACHINES["SWIM1"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/machine/swim1.cpp",
+ MAME_DIR .. "src/devices/machine/swim1.h",
+ }
+end
+
+---------------------------------------------------
+--
+--@src/devices/machine/swim2.h,MACHINES["SWIM2"] = true
+---------------------------------------------------
+if (MACHINES["SWIM2"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/machine/swim2.cpp",
+ MAME_DIR .. "src/devices/machine/swim2.h",
+ }
+end
+
+---------------------------------------------------
+--
+--@src/devices/machine/swim3.h,MACHINES["SWIM3"] = true
+---------------------------------------------------
+if (MACHINES["SWIM3"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/machine/swim3.cpp",
+ MAME_DIR .. "src/devices/machine/swim3.h",
}
end
@@ -3866,17 +3910,6 @@ end
---------------------------------------------------
--
---@src/devices/machine/appldriv.h,MACHINES["APPLE_DRIVE"] = true
----------------------------------------------------
-if (MACHINES["APPLE_DRIVE"]~=null) then
- files {
- MAME_DIR .. "src/devices/machine/appldriv.cpp",
- MAME_DIR .. "src/devices/machine/appldriv.h",
- }
-end
-
----------------------------------------------------
---
--@src/devices/machine/applefdc.h,MACHINES["APPLE_FDC"] = true
---------------------------------------------------
if (MACHINES["APPLE_FDC"]~=null) then
@@ -3888,17 +3921,6 @@ end
---------------------------------------------------
--
---@src/devices/machine/sonydriv.h,MACHINES["SONY_DRIVE"] = true
----------------------------------------------------
-if (MACHINES["SONY_DRIVE"]~=null) then
- files {
- MAME_DIR .. "src/devices/machine/sonydriv.cpp",
- MAME_DIR .. "src/devices/machine/sonydriv.h",
- }
-end
-
----------------------------------------------------
---
--@src/devices/machine/scnxx562.h,MACHINES["SCNXX562"] = true
---------------------------------------------------
if (MACHINES["SCNXX562"]~=null) then
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua
index 388c9984ba5..2ec6e7bc1e1 100644
--- a/scripts/target/mame/arcade.lua
+++ b/scripts/target/mame/arcade.lua
@@ -673,7 +673,11 @@ MACHINES["FDC37C665GT"] = true
--MACHINES["STRATA"] = true
MACHINES["STEPPERS"] = true
--MACHINES["CORVUSHD"] = true
---MACHINES["WOZFDC"] = true
+--MACHINES["DISKII"] = true
+--MACHINES["IWM"] = true
+--MACHINES["SWIM1"] = true
+--MACHINES["SWIM2"] = true
+--MACHINES["SWIM3"] = true
--MACHINES["DIABLO_HD"] = true
MACHINES["PCI9050"] = true
MACHINES["TMS1024"] = true
diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua
index b9e10d8c1ab..05df00bacda 100644
--- a/scripts/target/mame/mess.lua
+++ b/scripts/target/mame/mess.lua
@@ -715,7 +715,11 @@ MACHINES["TI99_HD"] = true
MACHINES["STRATA"] = true
MACHINES["STEPPERS"] = true
MACHINES["CORVUSHD"] = true
-MACHINES["WOZFDC"] = true
+MACHINES["DISKII"] = true
+MACHINES["IWM"] = true
+MACHINES["SWIM1"] = true
+MACHINES["SWIM2"] = true
+MACHINES["SWIM3"] = true
MACHINES["DIABLO_HD"] = true
MACHINES["TMS1024"] = true
MACHINES["NSC810"] = true
@@ -1721,8 +1725,8 @@ files {
MAME_DIR .. "src/mame/machine/macrtc.h",
MAME_DIR .. "src/mame/machine/mackbd.cpp",
MAME_DIR .. "src/mame/machine/mackbd.h",
- MAME_DIR .. "src/mame/machine/swim.cpp",
- MAME_DIR .. "src/mame/machine/swim.h",
+ MAME_DIR .. "src/mame/machine/applefdc.cpp",
+ MAME_DIR .. "src/mame/machine/applefdc.h",
MAME_DIR .. "src/mame/video/mac.cpp",
MAME_DIR .. "src/mame/drivers/macpci.cpp",
MAME_DIR .. "src/mame/includes/macpci.h",
diff --git a/src/devices/bus/a2bus/a2diskii.cpp b/src/devices/bus/a2bus/a2diskii.cpp
index c67eb306837..c989c596ad7 100644
--- a/src/devices/bus/a2bus/a2diskii.cpp
+++ b/src/devices/bus/a2bus/a2diskii.cpp
@@ -9,12 +9,8 @@
*********************************************************************/
#include "emu.h"
-#include "imagedev/flopdrv.h"
-#include "formats/ap2_dsk.h"
-#include "machine/appldriv.h"
#include "a2diskii.h"
-
/***************************************************************************
PARAMETERS
***************************************************************************/
@@ -23,111 +19,81 @@
// GLOBAL VARIABLES
//**************************************************************************
-DEFINE_DEVICE_TYPE(A2BUS_DISKII, a2bus_diskii_device, "a2diskii", "Apple Disk II controller")
-DEFINE_DEVICE_TYPE(A2BUS_IWM_FDC, a2bus_iwmflop_device, "a2iwm_flop", "Apple IWM floppy card")
-DEFINE_DEVICE_TYPE(A2BUS_AGAT7_FDC, a2bus_agat7flop_device, "agat7_flop", "Agat-7 140K floppy card")
-DEFINE_DEVICE_TYPE(A2BUS_AGAT9_FDC, a2bus_agat9flop_device, "agat9_flop", "Agat-9 140K floppy card")
+DEFINE_DEVICE_TYPE(A2BUS_DISKII, a2bus_diskii_device, "a2diskii", "Apple Disk II controller (16-sector)")
+DEFINE_DEVICE_TYPE(A2BUS_DISKII13, a2bus_diskii13_device, "diskii13", "Apple Disk II controller (13-sector)")
+#define WOZFDC_TAG "wozfdc"
#define DISKII_ROM_REGION "diskii_rom"
-#define FDC_TAG "diskii_fdc"
-
-const applefdc_interface fdc_interface =
-{
- apple525_set_lines, /* set_lines */
- apple525_set_enable_lines, /* set_enable_lines */
-
- apple525_read_data, /* read_data */
- apple525_write_data, /* write_data */
- apple525_read_status /* read_status */
-};
-
-static const floppy_interface floppy_interface =
-{
- FLOPPY_STANDARD_5_25_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple2),
- "floppy_5_25"
-};
ROM_START( diskii )
ROM_REGION(0x100, DISKII_ROM_REGION, 0)
- ROM_LOAD( "341-0027-a.p5", 0x000000, 0x000100, CRC(ce7144f6) SHA1(d4181c9f046aafc3fb326b381baac809d9e38d16) )
-ROM_END
-
-ROM_START( agat7 )
- ROM_REGION(0x100, DISKII_ROM_REGION, 0)
- ROM_LOAD( "shugart7.rom", 0x0000, 0x0100, CRC(c6e4850c) SHA1(71626d3d2d4bbeeac2b77585b45a5566d20b8d34) )
+ ROM_LOAD( "341-0027-a.p5", 0x0000, 0x0100, CRC(ce7144f6) SHA1(d4181c9f046aafc3fb326b381baac809d9e38d16) ) /* 341-0027-a: 16-sector disk drive (older version), PROM P5 */
ROM_END
-ROM_START( agat9 )
+ROM_START( diskii13 )
ROM_REGION(0x100, DISKII_ROM_REGION, 0)
- ROM_LOAD( "shugart9.rom", 0x0000, 0x0100, CRC(964a0ce2) SHA1(bf955189ebffe874c20ef649a3db8177dc16af61) )
+ ROM_LOAD( "341-0009.bin", 0x000000, 0x000100, CRC(d34eb2ff) SHA1(afd060e6f35faf3bb0146fa889fc787adf56330a) )
ROM_END
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
-void a2bus_floppy_device::device_add_mconfig(machine_config &config)
+void a2bus_diskii_base_device::device_add_mconfig(machine_config &config)
+{
+ DISKII(config, m_wozfdc, 1021800*2);
+ m_wozfdc->phases_cb().set(FUNC(a2bus_diskii_base_device::phases_w));
+ m_wozfdc->devsel_cb().set(FUNC(a2bus_diskii_base_device::devsel_w));
+}
+
+void a2bus_diskii_device::device_add_mconfig(machine_config &config)
{
- APPLEFDC(config, m_fdc, &fdc_interface);
- FLOPPY_APPLE(config, FLOPPY_0, &floppy_interface, 15, 16);
- FLOPPY_APPLE(config, FLOPPY_1, &floppy_interface, 15, 16);
+ a2bus_diskii_base_device::device_add_mconfig(config);
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
}
-void a2bus_iwmflop_device::device_add_mconfig(machine_config &config)
+void a2bus_diskii13_device::device_add_mconfig(machine_config &config)
{
- IWM(config, m_fdc, &fdc_interface);
- FLOPPY_APPLE(config, FLOPPY_0, &floppy_interface, 15, 16);
- FLOPPY_APPLE(config, FLOPPY_1, &floppy_interface, 15, 16);
+ a2bus_diskii_base_device::device_add_mconfig(config);
+ applefdc_device::add_525_13(config, m_floppy[0]);
+ applefdc_device::add_525_13(config, m_floppy[1]);
}
//-------------------------------------------------
// rom_region - device-specific ROM region
//-------------------------------------------------
-const tiny_rom_entry *a2bus_floppy_device::device_rom_region() const
+const tiny_rom_entry *a2bus_diskii_device::device_rom_region() const
{
return ROM_NAME( diskii );
}
-const tiny_rom_entry *a2bus_agat7flop_device::device_rom_region() const
-{
- return ROM_NAME( agat7 );
-}
-
-const tiny_rom_entry *a2bus_agat9flop_device::device_rom_region() const
+const tiny_rom_entry *a2bus_diskii13_device::device_rom_region() const
{
- return ROM_NAME( agat9 );
+ return ROM_NAME( diskii13 );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
-a2bus_floppy_device::a2bus_floppy_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+a2bus_diskii_base_device::a2bus_diskii_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
device_a2bus_card_interface(mconfig, *this),
- m_fdc(*this, FDC_TAG), m_rom(nullptr)
+ m_wozfdc(*this, WOZFDC_TAG),
+ m_floppy(*this, "%u", 0U),
+ m_rom(nullptr)
{
}
a2bus_diskii_device::a2bus_diskii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- a2bus_floppy_device(mconfig, A2BUS_DISKII, tag, owner, clock)
+ a2bus_diskii_base_device(mconfig, A2BUS_DISKII, tag, owner, clock)
{
}
-a2bus_iwmflop_device::a2bus_iwmflop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- a2bus_floppy_device(mconfig, A2BUS_IWM_FDC, tag, owner, clock)
-{
-}
-
-a2bus_agat7flop_device::a2bus_agat7flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- a2bus_floppy_device(mconfig, A2BUS_AGAT7_FDC, tag, owner, clock)
-{
-}
-
-a2bus_agat9flop_device::a2bus_agat9flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- a2bus_floppy_device(mconfig, A2BUS_AGAT9_FDC, tag, owner, clock)
+a2bus_diskii13_device::a2bus_diskii13_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ a2bus_diskii_base_device(mconfig, A2BUS_DISKII13, tag, owner, clock)
{
}
@@ -135,23 +101,22 @@ a2bus_agat9flop_device::a2bus_agat9flop_device(const machine_config &mconfig, co
// device_start - device-specific startup
//-------------------------------------------------
-void a2bus_floppy_device::device_start()
+void a2bus_diskii_base_device::device_start()
{
m_rom = device().machine().root_device().memregion(this->subtag(DISKII_ROM_REGION).c_str())->base();
}
-void a2bus_floppy_device::device_reset()
+void a2bus_diskii_base_device::device_reset()
{
}
-
/*-------------------------------------------------
read_c0nx - called for reads from this card's c0nx space
-------------------------------------------------*/
-uint8_t a2bus_floppy_device::read_c0nx(uint8_t offset)
+uint8_t a2bus_diskii_base_device::read_c0nx(uint8_t offset)
{
- return m_fdc->read(offset);
+ return m_wozfdc->read(offset);
}
@@ -159,16 +124,33 @@ uint8_t a2bus_floppy_device::read_c0nx(uint8_t offset)
write_c0nx - called for writes to this card's c0nx space
-------------------------------------------------*/
-void a2bus_floppy_device::write_c0nx(uint8_t offset, uint8_t data)
+void a2bus_diskii_base_device::write_c0nx(uint8_t offset, uint8_t data)
{
- m_fdc->write(offset, data);
+ m_wozfdc->write(offset, data);
}
/*-------------------------------------------------
- read_cnxx - called for reads from this card's c0nx space
+ read_cnxx - called for reads from this card's cnxx space
-------------------------------------------------*/
-uint8_t a2bus_floppy_device::read_cnxx(uint8_t offset)
+uint8_t a2bus_diskii_base_device::read_cnxx(uint8_t offset)
{
return m_rom[offset];
}
+
+void a2bus_diskii_base_device::devsel_w(u8 data)
+{
+ if(data & 1)
+ m_wozfdc->set_floppy(m_floppy[0]->get_device());
+ else if(data & 2)
+ m_wozfdc->set_floppy(m_floppy[1]->get_device());
+ else
+ m_wozfdc->set_floppy(nullptr);
+}
+
+void a2bus_diskii_base_device::phases_w(u8 data)
+{
+ auto flp = m_wozfdc->get_floppy();
+ if(flp)
+ flp->seek_phase_w(data);
+}
diff --git a/src/devices/bus/a2bus/a2diskii.h b/src/devices/bus/a2bus/a2diskii.h
index 879744e8950..eb02f3809c9 100644
--- a/src/devices/bus/a2bus/a2diskii.h
+++ b/src/devices/bus/a2bus/a2diskii.h
@@ -4,7 +4,7 @@
a2diskii.h
- Apple II Disk II Controller Card
+ Apple II Disk II Controller Card, new floppy
*********************************************************************/
@@ -14,71 +14,65 @@
#pragma once
#include "a2bus.h"
-#include "machine/applefdc.h"
+#include "imagedev/floppy.h"
+#include "formats/flopimg.h"
+#include "machine/diskii.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
-class a2bus_floppy_device:
+
+class a2bus_diskii_base_device:
public device_t,
public device_a2bus_card_interface
{
-protected:
+public:
// construction/destruction
- a2bus_floppy_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+ a2bus_diskii_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual const tiny_rom_entry *device_rom_region() const override;
// overrides of standard a2bus slot functions
virtual uint8_t read_c0nx(uint8_t offset) override;
virtual void write_c0nx(uint8_t offset, uint8_t data) override;
virtual uint8_t read_cnxx(uint8_t offset) override;
- required_device<applefdc_base_device> m_fdc;
+ required_device<diskii_device> m_wozfdc;
+ required_device_array<floppy_connector, 2> m_floppy;
-private:
- uint8_t *m_rom;
-};
+protected:
+ const uint8_t *m_rom;
-class a2bus_diskii_device: public a2bus_floppy_device
-{
-public:
- a2bus_diskii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ void devsel_w(u8 data);
+ void phases_w(u8 data);
};
-class a2bus_iwmflop_device: public a2bus_floppy_device
+class a2bus_diskii_device: public a2bus_diskii_base_device
{
public:
- a2bus_iwmflop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ a2bus_diskii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
virtual void device_add_mconfig(machine_config &config) override;
-};
-
-class a2bus_agat7flop_device: public a2bus_floppy_device
-{
-public:
- a2bus_agat7flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
virtual const tiny_rom_entry *device_rom_region() const override;
};
-class a2bus_agat9flop_device: public a2bus_floppy_device
+class a2bus_diskii13_device: public a2bus_diskii_base_device
{
public:
- a2bus_agat9flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ a2bus_diskii13_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+protected:
+ virtual void device_add_mconfig(machine_config &config) override;
virtual const tiny_rom_entry *device_rom_region() const override;
};
// device type definition
-DECLARE_DEVICE_TYPE(A2BUS_DISKII, a2bus_diskii_device)
-DECLARE_DEVICE_TYPE(A2BUS_IWM_FDC, a2bus_iwmflop_device)
-DECLARE_DEVICE_TYPE(A2BUS_AGAT7_FDC, a2bus_agat7flop_device)
-DECLARE_DEVICE_TYPE(A2BUS_AGAT9_FDC, a2bus_agat9flop_device)
+DECLARE_DEVICE_TYPE(A2BUS_DISKII, a2bus_diskii_device)
+DECLARE_DEVICE_TYPE(A2BUS_DISKII13, a2bus_diskii13_device)
#endif // MAME_BUS_A2BUS_A2DISKII_H
diff --git a/src/devices/bus/a2bus/a2diskiing.cpp b/src/devices/bus/a2bus/a2diskiing.cpp
deleted file mode 100644
index 9ce3a0df64c..00000000000
--- a/src/devices/bus/a2bus/a2diskiing.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- a2diskii.c
-
- Implementation of the Apple II Disk II controller card
-
-*********************************************************************/
-
-#include "emu.h"
-#include "imagedev/floppy.h"
-#include "formats/ap2_dsk.h"
-#include "a2diskiing.h"
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-DEFINE_DEVICE_TYPE(A2BUS_DISKIING, a2bus_diskiing_device, "a2diskiing", "Apple Disk II NG controller (16-sector)")
-DEFINE_DEVICE_TYPE(A2BUS_DISKIING13, a2bus_diskiing13_device, "diskii13", "Apple Disk II NG controller (13-sector)")
-DEFINE_DEVICE_TYPE(A2BUS_APPLESURANCE, a2bus_applesurance_device, "a2surance", "Applesurance Diagnostic Controller")
-
-#define WOZFDC_TAG "wozfdc"
-#define DISKII_ROM_REGION "diskii_rom"
-
-static void a2_floppies(device_slot_interface &device)
-{
- device.option_add("525", FLOPPY_525_SD);
-}
-
-ROM_START( diskiing )
- ROM_REGION(0x100, DISKII_ROM_REGION, 0)
- ROM_LOAD( "341-0027-a.p5", 0x0000, 0x0100, CRC(ce7144f6) SHA1(d4181c9f046aafc3fb326b381baac809d9e38d16) ) /* 341-0027-a: 16-sector disk drive (older version), PROM P5 */
-ROM_END
-
-ROM_START( diskiing13 )
- ROM_REGION(0x100, DISKII_ROM_REGION, 0)
- ROM_LOAD( "341-0009.bin", 0x000000, 0x000100, CRC(d34eb2ff) SHA1(afd060e6f35faf3bb0146fa889fc787adf56330a) )
-ROM_END
-
-ROM_START( applesurance )
- ROM_REGION(0x1000, DISKII_ROM_REGION, 0)
- ROM_LOAD( "applesurance 3.0 - 2732.bin", 0x000000, 0x001000, CRC(64eafec7) SHA1(723dc6cd32de5a0f27af7503764185ac58904c05) )
-ROM_END
-
-FLOPPY_FORMATS_MEMBER( diskiing_device::floppy_formats )
- FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT, FLOPPY_EDD_FORMAT, FLOPPY_WOZ_FORMAT
-FLOPPY_FORMATS_END
-
-FLOPPY_FORMATS_MEMBER( a2bus_diskiing13_device::floppy_formats )
- FLOPPY_EDD_FORMAT, FLOPPY_WOZ_FORMAT
-FLOPPY_FORMATS_END
-
-//-------------------------------------------------
-// device_add_mconfig - add device configuration
-//-------------------------------------------------
-
-void diskiing_device::device_add_mconfig(machine_config &config)
-{
- DISKII_FDC(config, m_wozfdc, 1021800*2);
- for (auto &floppy : m_floppy)
- FLOPPY_CONNECTOR(config, floppy, a2_floppies, "525", diskiing_device::floppy_formats);
-}
-
-void a2bus_diskiing13_device::device_add_mconfig(machine_config &config)
-{
- DISKII_FDC(config, m_wozfdc, 1021800*2);
- for (auto &floppy : m_floppy)
- FLOPPY_CONNECTOR(config, floppy, a2_floppies, "525", a2bus_diskiing13_device::floppy_formats);
-}
-
-//-------------------------------------------------
-// rom_region - device-specific ROM region
-//-------------------------------------------------
-
-const tiny_rom_entry *diskiing_device::device_rom_region() const
-{
- return ROM_NAME( diskiing );
-}
-
-const tiny_rom_entry *a2bus_diskiing13_device::device_rom_region() const
-{
- return ROM_NAME( diskiing13 );
-}
-
-const tiny_rom_entry *a2bus_applesurance_device::device_rom_region() const
-{
- return ROM_NAME( applesurance );
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-diskiing_device::diskiing_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, type, tag, owner, clock),
- device_a2bus_card_interface(mconfig, *this),
- m_wozfdc(*this, WOZFDC_TAG),
- m_floppy(*this, "%u", 0U),
- m_rom(nullptr)
-{
-}
-
-a2bus_diskiing_device::a2bus_diskiing_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- diskiing_device(mconfig, A2BUS_DISKIING, tag, owner, clock)
-{
-}
-
-a2bus_diskiing13_device::a2bus_diskiing13_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- diskiing_device(mconfig, A2BUS_DISKIING13, tag, owner, clock)
-{
-}
-
-a2bus_applesurance_device::a2bus_applesurance_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- diskiing_device(mconfig, A2BUS_APPLESURANCE, tag, owner, clock),
- m_c800_bank(1)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void diskiing_device::device_start()
-{
- m_rom = device().machine().root_device().memregion(this->subtag(DISKII_ROM_REGION).c_str())->base();
-}
-
-void diskiing_device::device_reset()
-{
- m_wozfdc->set_floppies(m_floppy[0], m_floppy[1]);
-}
-
-/*-------------------------------------------------
- read_c0nx - called for reads from this card's c0nx space
--------------------------------------------------*/
-
-uint8_t diskiing_device::read_c0nx(uint8_t offset)
-{
- return m_wozfdc->read(offset);
-}
-
-
-/*-------------------------------------------------
- write_c0nx - called for writes to this card's c0nx space
--------------------------------------------------*/
-
-void diskiing_device::write_c0nx(uint8_t offset, uint8_t data)
-{
- m_wozfdc->write(offset, data);
-}
-
-/*-------------------------------------------------
- read_cnxx - called for reads from this card's cnxx space
--------------------------------------------------*/
-
-uint8_t diskiing_device::read_cnxx(uint8_t offset)
-{
- return m_rom[offset];
-}
-
-uint8_t a2bus_applesurance_device::read_cnxx(uint8_t offset)
-{
- return m_rom[offset+0x800];
-}
-
-uint8_t a2bus_applesurance_device::read_c800(uint16_t offset)
-{
- if (offset == 0x7ff)
- {
- m_c800_bank = 1;
- }
-
- if (!m_c800_bank)
- {
- return m_rom[offset];
- }
-
- return m_rom[offset+0x800];
-}
-
-void a2bus_applesurance_device::device_reset()
-{
- m_c800_bank = 1;
- diskiing_device::device_reset();
-}
diff --git a/src/devices/bus/a2bus/a2diskiing.h b/src/devices/bus/a2bus/a2diskiing.h
deleted file mode 100644
index a282d75ea01..00000000000
--- a/src/devices/bus/a2bus/a2diskiing.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- a2diskiing.h
-
- Apple II Disk II Controller Card, new floppy
-
-*********************************************************************/
-
-#ifndef MAME_BUS_A2BUS_A2DISKIING_H
-#define MAME_BUS_A2BUS_A2DISKIING_H
-
-#pragma once
-
-#include "a2bus.h"
-#include "imagedev/floppy.h"
-#include "formats/flopimg.h"
-#include "machine/wozfdc.h"
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-class diskiing_device:
- public device_t,
- public device_a2bus_card_interface
-{
-public:
- // construction/destruction
- diskiing_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
- virtual void device_add_mconfig(machine_config &config) override;
- virtual const tiny_rom_entry *device_rom_region() const override;
-
- // overrides of standard a2bus slot functions
- virtual uint8_t read_c0nx(uint8_t offset) override;
- virtual void write_c0nx(uint8_t offset, uint8_t data) override;
- virtual uint8_t read_cnxx(uint8_t offset) override;
-
- required_device<diskii_fdc_device> m_wozfdc;
- required_device_array<floppy_connector, 2> m_floppy;
-
- const uint8_t *m_rom;
-
-private:
- DECLARE_FLOPPY_FORMATS( floppy_formats );
-};
-
-class a2bus_diskiing_device: public diskiing_device
-{
-public:
- a2bus_diskiing_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-};
-
-class a2bus_diskiing13_device: public diskiing_device
-{
-public:
- a2bus_diskiing13_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
-protected:
- virtual void device_add_mconfig(machine_config &config) override;
- virtual const tiny_rom_entry *device_rom_region() const override;
-
-private:
- DECLARE_FLOPPY_FORMATS( floppy_formats );
-};
-
-class a2bus_applesurance_device: public diskiing_device
-{
-public:
- a2bus_applesurance_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
-protected:
- virtual const tiny_rom_entry *device_rom_region() const override;
-
- virtual void device_reset() override;
-
- virtual uint8_t read_cnxx(uint8_t offset) override;
- virtual uint8_t read_c800(uint16_t offset) override;
-
- virtual void write_c800(uint16_t offset, uint8_t data) override
- {
- if (offset == 0x7ff)
- {
- m_c800_bank = data & 1;
- }
- }
-
- virtual bool take_c800() override { return true; }
-
-private:
- int m_c800_bank;
-};
-
-// device type definition
-DECLARE_DEVICE_TYPE(A2BUS_DISKIING, a2bus_diskiing_device)
-DECLARE_DEVICE_TYPE(A2BUS_DISKIING13, a2bus_diskiing13_device)
-DECLARE_DEVICE_TYPE(A2BUS_APPLESURANCE, a2bus_applesurance_device)
-
-#endif // MAME_BUS_A2BUS_A2DISKIING_H
diff --git a/src/devices/bus/a2bus/a2iwm.cpp b/src/devices/bus/a2bus/a2iwm.cpp
new file mode 100644
index 00000000000..c22f8d8d6bb
--- /dev/null
+++ b/src/devices/bus/a2bus/a2iwm.cpp
@@ -0,0 +1,92 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/*********************************************************************
+
+ a2iwm.c
+
+ Implementation of the Apple II IWM controller card
+
+*********************************************************************/
+
+#include "emu.h"
+#include "formats/ap2_dsk.h"
+#include "a2iwm.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(A2BUS_IWM, a2bus_iwm_device, "a2iwm", "Apple IWM controller card")
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void a2bus_iwm_device::device_add_mconfig(machine_config &config)
+{
+ IWM(config, m_iwm, clock(), 1021800*2);
+ m_iwm->phases_cb().set(FUNC(a2bus_iwm_device::phases_w));
+ m_iwm->devsel_cb().set(FUNC(a2bus_iwm_device::devsel_w));
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
+}
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+a2bus_iwm_device::a2bus_iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, A2BUS_IWM, tag, owner, clock),
+ device_a2bus_card_interface(mconfig, *this),
+ m_iwm(*this, "iwm"),
+ m_floppy(*this, "%u", 0U)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void a2bus_iwm_device::device_start()
+{
+}
+
+void a2bus_iwm_device::device_reset()
+{
+}
+
+/*-------------------------------------------------
+ read_c0nx - called for reads from this card's c0nx space
+-------------------------------------------------*/
+
+uint8_t a2bus_iwm_device::read_c0nx(uint8_t offset)
+{
+ return m_iwm->read(offset);
+}
+
+
+/*-------------------------------------------------
+ write_c0nx - called for writes to this card's c0nx space
+-------------------------------------------------*/
+
+void a2bus_iwm_device::write_c0nx(uint8_t offset, uint8_t data)
+{
+ m_iwm->write(offset, data);
+}
+
+void a2bus_iwm_device::devsel_w(u8 data)
+{
+ if(data & 1)
+ m_iwm->set_floppy(m_floppy[0]->get_device());
+ else if(data & 2)
+ m_iwm->set_floppy(m_floppy[1]->get_device());
+ else
+ m_iwm->set_floppy(nullptr);
+}
+
+void a2bus_iwm_device::phases_w(u8 data)
+{
+ auto flp = m_iwm->get_floppy();
+ if(flp)
+ flp->seek_phase_w(data);
+}
diff --git a/src/devices/bus/a2bus/a2iwm.h b/src/devices/bus/a2bus/a2iwm.h
new file mode 100644
index 00000000000..cd73b77af83
--- /dev/null
+++ b/src/devices/bus/a2bus/a2iwm.h
@@ -0,0 +1,54 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/*********************************************************************
+
+ a2iwm.h
+
+ Apple II IWM Controller Card, new floppy
+
+*********************************************************************/
+
+#ifndef MAME_BUS_A2BUS_A2IWM_H
+#define MAME_BUS_A2BUS_A2IWM_H
+
+#pragma once
+
+#include "a2bus.h"
+#include "imagedev/floppy.h"
+#include "formats/flopimg.h"
+#include "machine/iwm.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+
+class a2bus_iwm_device:
+ public device_t,
+ public device_a2bus_card_interface
+{
+public:
+ // construction/destruction
+ a2bus_iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ // overrides of standard a2bus slot functions
+ virtual uint8_t read_c0nx(uint8_t offset) override;
+ virtual void write_c0nx(uint8_t offset, uint8_t data) override;
+
+ required_device<iwm_device> m_iwm;
+ required_device_array<floppy_connector, 2> m_floppy;
+
+private:
+ void devsel_w(u8 data);
+ void phases_w(u8 data);
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(A2BUS_IWM, a2bus_iwm_device)
+
+#endif // MAME_BUS_A2BUS_A2IWM_H
diff --git a/src/devices/machine/appldriv.cpp b/src/devices/machine/appldriv.cpp
deleted file mode 100644
index 1d207a9ab0b..00000000000
--- a/src/devices/machine/appldriv.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- appldriv.c
-
- Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c)
-
-*********************************************************************/
-#include "emu.h"
-#include "appldriv.h"
-#include "imagedev/flopdrv.h"
-#include "formats/ap2_dsk.h"
-
-// our parent's device is the Disk II card (Apple II) or main driver (Mac, IIgs)
-// either way, get the drive from there.
-#define PARENT_FLOPPY_0 "^floppy0"
-#define PARENT_FLOPPY_1 "^floppy1"
-#define PARENT_FLOPPY_2 "^floppy2"
-#define PARENT_FLOPPY_3 "^floppy3"
-
-static inline apple525_floppy_image_device *get_device(device_t *device)
-{
- assert(device != nullptr);
- assert(device->type() == FLOPPY_APPLE);
-
- return downcast<apple525_floppy_image_device *>(device);
-}
-
-static int apple525_enable_mask = 1;
-
-legacy_floppy_image_device *apple525_get_subdevice(device_t *device, int drive)
-{
- switch(drive) {
- case 0 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_0);
- case 1 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_1);
- case 2 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_2);
- case 3 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_3);
- }
- return nullptr;
-}
-
-device_t *apple525_get_device_by_type(device_t *device, int ftype, int drive)
-{
- int i;
- int cnt = 0;
- for (i=0;i<4;i++) {
- legacy_floppy_image_device *disk = apple525_get_subdevice(device, i);
- if (disk->floppy_get_drive_type()==ftype) {
- if (cnt==drive) {
- return disk;
- }
- cnt++;
- }
- }
- return nullptr;
-}
-
-void apple525_set_enable_lines(device_t *device, int enable_mask)
-{
- apple525_enable_mask = enable_mask;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void apple525_load_current_track(device_t *image)
-{
- int len;
- apple525_floppy_image_device *disk;
-
- disk = get_device(image);
- len = sizeof(disk->track_data);
-
- disk->floppy_drive_read_track_data_info_buffer(0, disk->track_data, &len);
- disk->track_loaded = 1;
- disk->track_dirty = 0;
-}
-
-static void apple525_save_current_track(device_t *image, int unload)
-{
- int len;
- apple525_floppy_image_device *disk;
-
- disk = get_device(image);
-
- if (disk->track_dirty)
- {
- len = sizeof(disk->track_data);
- disk->floppy_drive_write_track_data_info_buffer(0, disk->track_data, &len);
- disk->track_dirty = 0;
- }
- if (unload)
- disk->track_loaded = 0;
-}
-
-static void apple525_seek_disk(apple525_floppy_image_device *img, signed int step)
-{
- int track;
- int pseudo_track;
- apple525_floppy_image_device *disk;
-
- disk = get_device(img);
-
- apple525_save_current_track(img, false);
-
- track = img->floppy_drive_get_current_track();
- pseudo_track = (track * 2) + disk->tween_tracks;
-
- pseudo_track += step;
- if (pseudo_track < 0)
- pseudo_track = 0;
- else if (pseudo_track/2 >= APPLE2_TRACK_COUNT)
- pseudo_track = APPLE2_TRACK_COUNT*2-1;
-
- if (pseudo_track/2 != track)
- {
- img->floppy_drive_seek(pseudo_track/2 - img->floppy_drive_get_current_track());
- disk->track_loaded = 0;
- }
-
- if (pseudo_track & 1)
- disk->tween_tracks = 1;
- else
- disk->tween_tracks = 0;
-}
-
-static void apple525_disk_set_lines(device_t *device,device_t *image, uint8_t new_state)
-{
- apple525_floppy_image_device *cur_disk;
- uint8_t old_state;
- unsigned int phase;
-
- cur_disk = get_device(image);
-
- old_state = cur_disk->state;
- cur_disk->state = new_state;
-
- if ((new_state & 0x0F) > (old_state & 0x0F))
- {
- phase = 0;
- switch((old_state ^ new_state) & 0x0F)
- {
- case 1: phase = 0; break;
- case 2: phase = 1; break;
- case 4: phase = 2; break;
- case 8: phase = 3; break;
- }
-
- phase -= cur_disk->floppy_drive_get_current_track() * 2;
- if (cur_disk->tween_tracks)
- phase--;
- phase %= 4;
-
- switch(phase)
- {
- case 1:
- apple525_seek_disk(cur_disk, +1);
- break;
- case 3:
- apple525_seek_disk(cur_disk, -1);
- break;
- }
- }
-}
-
-int apple525_get_count(device_t *device)
-{
- int cnt = 0;
- if ((device->subdevice("^" FLOPPY_0)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_0)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_0))!=nullptr)) cnt++;
- if ((device->subdevice("^" FLOPPY_1)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_1)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_1))!=nullptr)) cnt++;
- if ((device->subdevice("^" FLOPPY_2)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_2)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_2))!=nullptr)) cnt++;
- if ((device->subdevice("^" FLOPPY_3)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_3)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_3))!=nullptr)) cnt++;
-
- return cnt;
-}
-
-void apple525_set_lines(device_t *device, uint8_t lines)
-{
- int i, count;
- device_t *image;
-
- count = apple525_get_count(device);
- for (i = 0; i < count; i++)
- {
- if (apple525_enable_mask & (1 << i))
- {
- image = apple525_get_device_by_type(device, FLOPPY_TYPE_APPLE, i);
- if (image)
- apple525_disk_set_lines(device,image, lines);
- }
- }
-}
-
-/* reads/writes a byte; write_value is -1 for read only */
-static uint8_t apple525_process_byte(device_t *img, int write_value)
-{
- uint8_t read_value;
- apple525_floppy_image_device *disk;
- int spinfract_divisor;
- int spinfract_dividend;
- apple525_floppy_image_device *config = get_device(img);
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- disk = get_device(img);
- spinfract_dividend = config->get_dividend();
- spinfract_divisor = config->get_divisor();
-
- /* no image initialized for that drive ? */
- if (!image->exists())
- return 0xFF;
-
- /* check the spin count if reading*/
- if (write_value < 0)
- {
- disk->spin_count++;
- disk->spin_count %= spinfract_divisor;
- if (disk->spin_count >= spinfract_dividend)
- return 0x00;
- }
-
- /* load track if need be */
- if (disk->track_loaded == 0)
- apple525_load_current_track(img);
-
- /* perform the read */
- read_value = disk->track_data[disk->position];
-
- /* perform the write, if applicable */
- if (write_value >= 0)
- {
- disk->track_data[disk->position] = write_value;
- disk->track_dirty = 1;
- }
-
- disk->position++;
- disk->position %= ARRAY_LENGTH(disk->track_data);
-
- /* when writing; save the current track after every full sector write */
- if ((write_value >= 0) && ((disk->position % APPLE2_NIBBLE_SIZE) == 0))
- apple525_save_current_track(img, false);
-
- return read_value;
-}
-
-static device_t *apple525_selected_image(device_t *device)
-{
- int i,count;
-
- count = apple525_get_count(device);
-
- for (i = 0; i < count; i++)
- {
- if (apple525_enable_mask & (1 << i))
- return apple525_get_device_by_type(device, FLOPPY_TYPE_APPLE, i);
- }
- return nullptr;
-}
-
-uint8_t apple525_read_data(device_t *device)
-{
- device_t *image;
- image = apple525_selected_image(device);
- return image ? apple525_process_byte(image, -1) : 0xFF;
-}
-
-void apple525_write_data(device_t *device,uint8_t data)
-{
- device_t *image;
- image = apple525_selected_image(device);
- if (image)
- apple525_process_byte(image, data);
-}
-
-int apple525_read_status(device_t *device)
-{
- int i, count, result = 0;
- device_image_interface *image;
-
- count = apple525_get_count(device);
-
- for (i = 0; i < count; i++)
- {
- if (apple525_enable_mask & (1 << i))
- {
- image = dynamic_cast<device_image_interface *>(apple525_get_device_by_type(device, FLOPPY_TYPE_APPLE, i));
- if (image && image->is_readonly())
- result = 1;
- }
- }
- return result;
-}
-
-// device type definition
-DEFINE_DEVICE_TYPE(FLOPPY_APPLE, apple525_floppy_image_device, "floppy_apple", "Apple Disk II")
-
-//-------------------------------------------------
-// apple525_floppy_image_device - constructor
-//-------------------------------------------------
-
-apple525_floppy_image_device::apple525_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : legacy_floppy_image_device(mconfig, FLOPPY_APPLE, tag, owner, clock)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void apple525_floppy_image_device::device_start()
-{
- legacy_floppy_image_device::device_start();
- floppy_set_type(FLOPPY_TYPE_APPLE);
-
- state = 0;
- tween_tracks = 0;
- track_loaded = 0;
- track_dirty = 0;
- position = 0;
- spin_count = 0;
- memset(track_data, 0, sizeof(track_data));
-}
-
-image_init_result apple525_floppy_image_device::call_load()
-{
- image_init_result result = legacy_floppy_image_device::call_load();
- floppy_drive_seek(-999);
- floppy_drive_seek(+35/2);
- return result;
-}
-
-void apple525_floppy_image_device::call_unload()
-{
- apple525_save_current_track(this, true);
-
- legacy_floppy_image_device::call_unload();
-}
diff --git a/src/devices/machine/appldriv.h b/src/devices/machine/appldriv.h
deleted file mode 100644
index 86f7c1658bf..00000000000
--- a/src/devices/machine/appldriv.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- appldriv.h
-
- Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c)
-
-*********************************************************************/
-
-#ifndef MAME_MACHINE_APPLDRIV_H
-#define MAME_MACHINE_APPLDRIV_H
-
-#pragma once
-
-#include "imagedev/flopdrv.h"
-#include "formats/ap2_dsk.h"
-
-#define FLOPPY_0 "floppy0"
-#define FLOPPY_1 "floppy1"
-#define FLOPPY_2 "floppy2"
-#define FLOPPY_3 "floppy3"
-
-void apple525_set_lines(device_t *device, uint8_t lines);
-void apple525_set_enable_lines(device_t *device, int enable_mask);
-
-uint8_t apple525_read_data(device_t *device);
-void apple525_write_data(device_t *device, uint8_t data);
-int apple525_read_status(device_t *device);
-int apple525_get_count(running_machine &machine);
-
-class apple525_floppy_image_device : public legacy_floppy_image_device
-{
-public:
- // construction/destruction
- apple525_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const floppy_interface *config, int dividend, int divisor)
- : apple525_floppy_image_device(mconfig, tag, owner, (uint32_t)0)
- {
- set_floppy_config(config);
- set_params(dividend, divisor);
- }
- apple525_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
-
- virtual image_init_result call_load() override;
- virtual void call_unload() override;
- void set_params(int dividend, int divisor) { m_dividend = dividend; m_divisor = divisor; }
-
- int get_dividend() { return m_dividend; }
- int get_divisor() { return m_divisor; }
-
- // these elements should be private, but are not yet
- unsigned int state : 4; /* bits 0-3 are the phase */
- unsigned int tween_tracks : 1;
- unsigned int track_loaded : 1;
- unsigned int track_dirty : 1;
- int position;
- int spin_count; /* simulate drive spin to fool RWTS test at $BD34 */
- uint8_t track_data[APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT];
-
-protected:
- virtual void device_start() override;
-
-private:
- int m_dividend;
- int m_divisor;
-};
-
-// device type definition
-DECLARE_DEVICE_TYPE(FLOPPY_APPLE, apple525_floppy_image_device)
-
-#endif // MAME_MACHINE_APPLDRIV_H
diff --git a/src/devices/machine/applefdc.cpp b/src/devices/machine/applefdc.cpp
index b13cc62eb3a..720fc5ce468 100644
--- a/src/devices/machine/applefdc.cpp
+++ b/src/devices/machine/applefdc.cpp
@@ -1,586 +1,73 @@
// license:BSD-3-Clause
// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont
-/*********************************************************************
-
- applefdc.c
-
- Implementation of various Apple Floppy Disk Controllers, including
- the classic Apple controller and the IWM (Integrated Woz Machine)
- chip
-
- The IWM chip was used as the floppy disk controller for early Macs and the
- Apple IIgs, and was eventually superseded by the SWIM chp.
-
- Nate Woods
- Raphael Nabet
-
- Writing this code would not be possible if it weren't for the work of the
- XGS and KEGS emulators which also contain IWM emulations.
-
- TODO
- - Implement the unimplemented IWM modes
- - IWM_MODE_CLOCKSPEED
- - IWM_MODE_BITCELLTIME
- - IWM_MODE_HANDSHAKEPROTOCOL
- - IWM_MODE_LATCHMODE
- - Investigate the differences between the IWM and the classic Apple II
- controller more fully. It is currently unclear what are genuine
- differences and what are effectively hacks that "just seem" to work.
- - Figure out iwm_readenable2handshake() and iwm_enable2(); they are
- hackish at best
- - Support the SWIM chip
- - Proper timing
- - This code was originally IWM specific; we need to clean up IWMisms in
- the code
- - Make it faster?
- - Add sound?
-
-*********************************************************************/
#include "emu.h"
#include "applefdc.h"
+#include "formats/ap2_dsk.h"
+#include "formats/ap_dsk35.h"
+#include "formats/pc_dsk.h"
+FLOPPY_FORMATS_MEMBER(applefdc_device::formats_525_13)
+ FLOPPY_EDD_FORMAT,
+ FLOPPY_WOZ_FORMAT
+FLOPPY_FORMATS_END
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-// logging
-#define LOG_APPLEFDC 0
-#define LOG_APPLEFDC_EXTRA 0
-
-// mask for FDC lines
-#define IWM_MOTOR 0x10
-#define IWM_DRIVE 0x20
-#define IWM_Q6 0x40
-#define IWM_Q7 0x80
-
-const device_timer_id TIMER_MOTOR_ONOFF = 1;
-
-
-
-
-
-/***************************************************************************
- IWM MODE
-
- The IWM mode has the following values:
-
- Bit 7 Reserved
- Bit 6 Reserved
- Bit 5 Reserved
- Bit 4 ! Clock speed
- 0=7MHz; used by Apple IIgs
- 1=8MHz; used by Mac (I believe)
- Bit 3 ! Bit cell time
- 0=4usec/bit (used for 5.25" drives)
- 1=2usec/bit (used for 3.5" drives)
- Bit 2 Motor-off delay
- 0=leave on for 1 sec after system turns it off
- 1=turn off immediately
- Bit 1 ! Handshake protocol
- 0=synchronous (software supplies timing for writing data; used for 5.25" drives)
- 1=asynchronous (IWM supplies timing; used for 3.5" drives)
- Bit 0 ! Latch mode
- 0=read data stays valid for 7usec (used for 5.25" drives)
- 1=read data stays valid for full byte time (used for 3.5" drives)
-
- ***************************************************************************/
-
-enum
-{
- IWM_MODE_CLOCKSPEED = 0x10,
- IWM_MODE_BITCELLTIME = 0x08,
- IWM_MODE_MOTOROFFDELAY = 0x04,
- IWM_MODE_HANDSHAKEPROTOCOL = 0x02,
- IWM_MODE_LATCHMODE = 0x01
-};
-
-
-
-/***************************************************************************
- BASE DEVICE
-***************************************************************************/
-
-//-------------------------------------------------
-// ctor
-//-------------------------------------------------
-
-applefdc_base_device::applefdc_base_device(applefdc_base_device::applefdc_t fdc_type, const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, type, tag, owner, clock),
- m_type(fdc_type),
- m_interface(nullptr)
-{
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void applefdc_base_device::device_start()
-{
- // timer
- m_motor_timer = timer_alloc(TIMER_MOTOR_ONOFF);
-
- // state
- m_write_byte = 0x00;
- m_lines = 0x00;
- m_mode = 0x1F; // default value needed by Lisa 2 - no, I don't know if it is true
- m_handshake_hack = 0x00;
-
- // register save states
- save_item(NAME(m_write_byte));
- save_item(NAME(m_lines));
- save_item(NAME(m_mode));
- save_item(NAME(m_handshake_hack));
-}
-
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void applefdc_base_device::device_reset(void)
-{
- m_handshake_hack = 0x00;
- m_write_byte = 0x00;
- m_lines = 0x00;
- m_mode = 0x1F; /* default value needed by Lisa 2 - no, I don't know if it is true */
- m_motor_timer->reset();
-}
-
-
-
-//-------------------------------------------------
-// device_timer - device-specific timer callbacks
-//-------------------------------------------------
-
-void applefdc_base_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER_MOTOR_ONOFF:
- turn_motor_onoff(param != 0);
- break;
- }
-}
-
-
-
-//-------------------------------------------------
-// get_interface - gets the interface
-//-------------------------------------------------
-
-const applefdc_interface *applefdc_base_device::get_interface()
-{
- static const applefdc_interface dummy_interface = {nullptr, };
-
- return (m_interface != nullptr) ? m_interface : &dummy_interface;
-}
-
-
-
-//-------------------------------------------------
-// iwm_enable2 - hackish function
-//-------------------------------------------------
-
-int applefdc_base_device::iwm_enable2()
-{
- /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */
- /* it is not called from the Mac Plus driver */
- return (m_lines & APPLEFDC_PH1) && (m_lines & APPLEFDC_PH3);
-}
-
-
-
-//-------------------------------------------------
-// iwm_readenable2handshake - hackish function
-//-------------------------------------------------
-
-uint8_t applefdc_base_device::iwm_readenable2handshake()
-{
- /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */
- /* it is not called from the Mac Plus driver */
- m_handshake_hack++;
- m_handshake_hack %= 4;
- return (m_handshake_hack != 0) ? 0xc0 : 0x80;
-}
-
-
-
-//-------------------------------------------------
-// statusreg_r - reads the status register
-//-------------------------------------------------
-
-uint8_t applefdc_base_device::statusreg_r()
-{
- uint8_t result;
- int status;
- const applefdc_interface *intf = get_interface();
-
- /* IWM status:
- *
- * Bit 7 Sense input (write protect for 5.25" drive and general status line for 3.5")
- * Bit 6 Reserved
- * Bit 5 Drive enable (is 1 if drive is on)
- * Bits 4-0 Same as IWM mode bits 4-0
- */
-
- status = iwm_enable2() ? 1 : (intf->read_status ? intf->read_status(this) : 0);
-
- result = (status ? 0x80 : 0x00);
-
- if (m_type != APPLEFDC_APPLE2)
- result |= (((m_lines & IWM_MOTOR) ? 1 : 0) << 5) | m_mode;
- return result;
-}
-
-
-
-//-------------------------------------------------
-// iwm_modereg_w - changes the mode register
-//-------------------------------------------------
-
-void applefdc_base_device::iwm_modereg_w(uint8_t data)
-{
- m_mode = data & 0x1f; /* write mode register */
-
- if (LOG_APPLEFDC_EXTRA)
- logerror("iwm_modereg_w: iwm_mode=0x%02x\n", (unsigned) m_mode);
-}
-
-
-
-//-------------------------------------------------
-// read_reg - reads a register
-//-------------------------------------------------
-
-uint8_t applefdc_base_device::read_reg(int lines)
-{
- const applefdc_interface *intf = get_interface();
- uint8_t result = 0;
-
- switch(lines)
- {
- case 0:
- // read data register
- if ((m_type != APPLEFDC_APPLE2) && (iwm_enable2() || !(m_lines & IWM_MOTOR)))
- {
- result = 0xFF;
- }
- else
- {
- // Right now, this function assumes latch mode; which is always used for
- // 3.5 inch drives. Eventually we should check to see if latch mode is
- // off
- if (LOG_APPLEFDC)
- {
- if ((m_mode & IWM_MODE_LATCHMODE) == 0x00)
- logerror("applefdc_read_reg(): latch mode off not implemented\n");
- }
-
- result = (intf->read_data ? intf->read_data(this) : 0x00);
- }
- break;
-
- case IWM_Q6:
- // read status register
- result = statusreg_r();
- break;
-
- case IWM_Q7:
- // Classic Apple II: Read status register
- // IWM: Read handshake register
- if (m_type == APPLEFDC_APPLE2)
- result = statusreg_r();
- else
- result = iwm_enable2() ? iwm_readenable2handshake() : 0x80;
- break;
- }
- return result;
-}
-
-
+FLOPPY_FORMATS_MEMBER(applefdc_device::formats_525)
+ FLOPPY_A216S_FORMAT,
+ FLOPPY_RWTS18_FORMAT,
+ FLOPPY_EDD_FORMAT,
+ FLOPPY_WOZ_FORMAT
+FLOPPY_FORMATS_END
-//-------------------------------------------------
-// write_reg - writes a register
-//-------------------------------------------------
+FLOPPY_FORMATS_MEMBER(applefdc_device::formats_35)
+ FLOPPY_DC42_FORMAT,
+ FLOPPY_PC_FORMAT
+FLOPPY_FORMATS_END
-void applefdc_base_device::write_reg(uint8_t data)
+void applefdc_device::floppies_525(device_slot_interface &device)
{
- const applefdc_interface *intf = get_interface();
-
- switch(m_lines & (IWM_Q6 | IWM_Q7))
- {
- case IWM_Q6 | IWM_Q7:
- if (!(m_lines & IWM_MOTOR))
- {
- iwm_modereg_w(data);
- }
- else if (!iwm_enable2())
- {
- // Right now, this function assumes latch mode; which is always used for
- // 3.5 inch drives. Eventually we should check to see if latch mode is
- // off
- if (LOG_APPLEFDC)
- {
- if ((m_mode & IWM_MODE_LATCHMODE) == 0)
- logerror("applefdc_write_reg(): latch mode off not implemented\n");
- }
-
- if (intf->write_data != nullptr)
- intf->write_data(this, data);
- }
- break;
- }
+ device.option_add("525", FLOPPY_525_SD);
}
-
-
-//-------------------------------------------------
-// turn_motor_onoff - timer callback for turning
-// motor on or off
-//-------------------------------------------------
-
-void applefdc_base_device::turn_motor_onoff(bool status)
+void applefdc_device::floppies_35(device_slot_interface &device)
{
- const applefdc_interface *intf = get_interface();
- int enable_lines;
-
- if (status)
- {
- m_lines |= IWM_MOTOR;
- enable_lines = (m_lines & IWM_DRIVE) ? 2 : 1;
- }
- else
- {
- m_lines &= ~IWM_MOTOR;
-
- if (m_type == APPLEFDC_APPLE2)
- enable_lines = (m_lines & IWM_DRIVE) ? 2 : 1;
- else
- enable_lines = 0;
- }
-
- /* invoke callback, if present */
- if (intf->set_enable_lines != nullptr)
- intf->set_enable_lines(this, enable_lines);
-
- if (LOG_APPLEFDC_EXTRA)
- logerror("iwm_turnmotor_onoff(): Turning motor %s\n", status ? "on" : "off");
-}
-
-
-
-//-------------------------------------------------
-// iwm_access
-//-------------------------------------------------
-
-void applefdc_base_device::iwm_access(int offset)
-{
- static const char *const lines[] =
- {
- "PH0",
- "PH1",
- "PH2",
- "PH3",
- "MOTOR",
- "DRIVE",
- "Q6",
- "Q7"
- };
-
- const applefdc_interface *intf = get_interface();
-
- if (offset & 1)
- m_lines |= (1 << (offset >> 1));
- else
- m_lines &= ~(1 << (offset >> 1));
-
- if (LOG_APPLEFDC_EXTRA)
- {
- logerror("iwm_access(): %s line %s => %02x\n",
- (offset & 1) ? "setting" : "clearing", lines[offset >> 1], m_lines);
- }
-
- if ((offset < 0x08) && (intf->set_lines != nullptr))
- intf->set_lines(this, m_lines & 0x0f);
-
- switch(offset)
- {
- case 0x08:
- /* turn off motor */
- m_motor_timer->adjust(
- (m_mode & IWM_MODE_MOTOROFFDELAY) ? attotime::zero : attotime::from_seconds(1), 0);
- break;
-
- case 0x09:
- /* turn on motor */
- m_motor_timer->adjust(attotime::zero, 1);
- break;
-
- case 0x0A:
- /* turn off IWM_DRIVE */
- if ((m_lines & IWM_MOTOR) && (intf->set_enable_lines != nullptr))
- intf->set_enable_lines(this, 1);
- break;
-
- case 0x0B:
- /* turn on IWM_DRIVE */
- if ((m_lines & IWM_MOTOR) && (intf->set_enable_lines != nullptr))
- intf->set_enable_lines(this, 2);
- break;
- }
+ device.option_add("35", FLOPPY_35_HD);
}
-
-
-//-------------------------------------------------
-// read - reads a byte from the FDC
-//-------------------------------------------------
-
-uint8_t applefdc_base_device::read(offs_t offset)
+applefdc_device::applefdc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, type, tag, owner, clock),
+ m_phases_cb(*this),
+ m_devsel_cb(*this),
+ m_sel35_cb(*this),
+ m_hdsel_cb(*this)
{
- const applefdc_interface *intf = get_interface();
- uint8_t result = 0;
-
- // normalize offset
- offset &= 0xf;
-
- if (LOG_APPLEFDC_EXTRA)
- logerror("applefdc_r: offset=%i\n", offset);
-
- iwm_access(offset);
-
- switch(m_type)
- {
- case APPLEFDC_APPLE2:
- switch(offset)
- {
- case 0x0C:
- if (m_lines & IWM_Q7)
- {
- if (intf->write_data != nullptr)
- intf->write_data(this, m_write_byte);
- result = 0;
- }
- else
- result = read_reg(0);
- break;
-
- case 0x0D:
- result = read_reg(IWM_Q6);
- break;
-
- case 0x0E:
- result = read_reg(IWM_Q7);
- break;
-
- case 0x0F:
- result = read_reg(IWM_Q7 | IWM_Q6);
- break;
- }
- break;
-
- case APPLEFDC_IWM:
- if ((offset & 1) == 0)
- result = read_reg(m_lines & (IWM_Q6 | IWM_Q7));
- break;
-
- case APPLEFDC_SWIM:
- if ((offset & 1) == 0)
- result = read_reg(m_lines & (IWM_Q6 | IWM_Q7));
- break;
- }
-
- return result;
}
-
-
-//-------------------------------------------------
-// write - writes a byte to the FDC
-//-------------------------------------------------
-
-void applefdc_base_device::write(offs_t offset, uint8_t data)
+void applefdc_device::device_start()
{
- const applefdc_interface *intf = get_interface();
-
- /* normalize offset */
- offset &= 15;
-
- if (LOG_APPLEFDC_EXTRA)
- logerror("applefdc_w: offset=%i data=0x%02x\n", offset, data);
-
- iwm_access(offset);
-
- switch(m_type)
- {
- case APPLEFDC_APPLE2:
- switch(offset)
- {
- case 0x0C:
- if (m_lines & IWM_Q7)
- {
- if (intf->write_data != nullptr)
- intf->write_data(this, m_write_byte);
- }
- break;
-
- case 0x0D:
- m_write_byte = data;
- break;
- }
- break;
-
- case APPLEFDC_IWM:
- if (offset & 1)
- write_reg(data);
- break;
-
- case APPLEFDC_SWIM:
- if (offset & 1)
- write_reg(data);
- break;
- }
+ m_phases_cb.resolve_safe();
+ m_devsel_cb.resolve_safe();
+ m_sel35_cb.resolve_safe();
+ m_hdsel_cb.resolve_safe();
+ save_item(NAME(m_phases));
+ save_item(NAME(m_phases_input));
}
-
-
-//-------------------------------------------------
-// get_lines - accessor
-//-------------------------------------------------
-
-uint8_t applefdc_base_device::get_lines()
+void applefdc_device::device_reset()
{
- return m_lines & 0x0f;
+ m_phases = 0xf0;
+ m_phases_input = 0x00;
+ update_phases();
}
-
-
-/***************************************************************************
- APPLE FDC - Used on Apple II
-***************************************************************************/
-
-DEFINE_DEVICE_TYPE(APPLEFDC, applefdc_device, "apple_fdc", "Apple FDC")
-
-applefdc_device::applefdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : applefdc_base_device(APPLEFDC_APPLE2, mconfig, APPLEFDC, tag, owner, clock)
+void applefdc_device::phases_w(u8 phases)
{
+ m_phases_input = phases;
+ update_phases();
}
-
-
-/***************************************************************************
- IWM - Used on early Macs
-***************************************************************************/
-
-DEFINE_DEVICE_TYPE(IWM, iwm_device, "iwm", "Apple IWM (Integrated Woz Machine)")
-
-iwm_device::iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : applefdc_base_device(APPLEFDC_IWM, mconfig, IWM, tag, owner, clock)
+void applefdc_device::update_phases()
{
+ u8 mask = m_phases >> 4;
+ m_phases_cb((m_phases & mask) | (m_phases_input & (mask ^ 0xf)));
}
diff --git a/src/devices/machine/applefdc.h b/src/devices/machine/applefdc.h
index 817b2e705e0..0aa05c9e4e2 100644
--- a/src/devices/machine/applefdc.h
+++ b/src/devices/machine/applefdc.h
@@ -1,16 +1,12 @@
// license:BSD-3-Clause
-// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont
+// copyright-holders:O. Galibert
/*********************************************************************
applefdc.h
- Implementation of various Apple Floppy Disk Controllers, including
- the classic Apple controller and the IWM (Integrated Woz Machine)
- chip
+ Common interface of various Apple Floppy Disk Controllers, implemented
+ in the classic Apple controller, the IWM and the SWIM variants
- Nate Woods
- Raphael Nabet
- R. Belmont
*********************************************************************/
@@ -19,134 +15,94 @@
#pragma once
+#include "imagedev/floppy.h"
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define APPLEFDC_PH0 0x01
-#define APPLEFDC_PH1 0x02
-#define APPLEFDC_PH2 0x04
-#define APPLEFDC_PH3 0x08
-
-DECLARE_DEVICE_TYPE(APPLEFDC, applefdc_device)
-DECLARE_DEVICE_TYPE(IWM, iwm_device)
-
-
-
-/***************************************************************************
- INTERFACE
-***************************************************************************/
-
-struct applefdc_interface
+class applefdc_device : public device_t
{
- void (*set_lines)(device_t *device, uint8_t lines);
- void (*set_enable_lines)(device_t *device, int enable_mask);
-
- uint8_t (*read_data)(device_t *device);
- void (*write_data)(device_t *device, uint8_t data);
- int (*read_status)(device_t *device);
-};
-
+public:
+ // read/write handlers for cpu access
+ virtual uint8_t read(offs_t offset) = 0;
+ virtual void write(offs_t offset, u8 data) = 0;
+ // phases line management
+ // Input from the exterior for the devices where they are bidirectional
+ void phases_w(u8 phases);
+ // Push output for when driven by the chip
+ auto phases_cb() { return m_phases_cb.bind(); }
-/***************************************************************************
- BASE DEVICE
-***************************************************************************/
+ // sel35 line when present (active high)
+ auto sel35_cb() { return m_sel35_cb.bind(); }
-class applefdc_base_device : public device_t
-{
-public:
- // configuration helpers
- void set_config(const applefdc_interface *intrf) { m_interface = intrf; }
+ // drive select lines (two of them in the low bits, active high)
+ auto devsel_cb() { return m_devsel_cb.bind(); }
- // read/write handlers
- virtual uint8_t read(offs_t offset);
- virtual void write(offs_t offset, uint8_t data);
+ // hdsel line when present and in output mode (active high)
+ auto hdsel_cb() { return m_hdsel_cb.bind(); }
- // accessor
- uint8_t get_lines();
+ // floppy selection input, to be updated according to the previous callbacks,
+ // nullptr if none selected
+ virtual void set_floppy(floppy_image_device *floppy) = 0;
- virtual void device_reset() override;
+ // get the currently selected floppy
+ virtual floppy_image_device *get_floppy() const = 0;
-protected:
- enum applefdc_t
- {
- APPLEFDC_APPLE2, /* classic Apple II disk controller (pre-IWM) */
- APPLEFDC_IWM, /* Integrated Woz Machine */
- APPLEFDC_SWIM /* Sander/Woz Integrated Machine */
- };
+ // Floppy formats
+ // 13-sector 5.25
+ DECLARE_FLOPPY_FORMATS(formats_525_13);
- // constructor
- applefdc_base_device(applefdc_t fdc_type, const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
-
- // device-level overrides
- virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
-
- // other protecteds
- virtual void iwm_modereg_w(uint8_t data);
-
-private:
- // data that is constant for the lifetime of the emulation
- emu_timer * m_motor_timer;
- applefdc_t m_type;
- const applefdc_interface *m_interface;
-
- // data that changes at emulation time
- uint8_t m_write_byte;
- uint8_t m_lines; /* flags from IWM_MOTOR - IWM_Q7 */
- uint8_t m_mode; /* 0-31; see above */
- uint8_t m_handshake_hack; /* not sure what this is for */
-
- // functions
- const applefdc_interface *get_interface();
- int iwm_enable2();
- uint8_t iwm_readenable2handshake();
- uint8_t statusreg_r();
- uint8_t read_reg(int lines);
- void write_reg(uint8_t data);
- void turn_motor_onoff(bool status);
- void iwm_access(int offset);
-};
+ // 5.25
+ DECLARE_FLOPPY_FORMATS(formats_525);
+ // 3.5
+ DECLARE_FLOPPY_FORMATS(formats_35);
+ // Floppy drives slot-level
+ // 5.25
+ static void floppies_525(device_slot_interface &device);
+ template<typename T> static void add_525_13(machine_config &config, T &floppy) {
+ FLOPPY_CONNECTOR(config, floppy, floppies_525, "525", formats_525_13);
+ }
+ template<typename T> static void add_525_13_nc(machine_config &config, T &floppy) {
+ FLOPPY_CONNECTOR(config, floppy, floppies_525, "", formats_525_13);
+ }
-/***************************************************************************
- APPLE FDC - Used on Apple II
-***************************************************************************/
+ template<typename T> static void add_525(machine_config &config, T &floppy) {
+ FLOPPY_CONNECTOR(config, floppy, floppies_525, "525", formats_525);
+ }
+ template<typename T> static void add_525_nc(machine_config &config, T &floppy) {
+ FLOPPY_CONNECTOR(config, floppy, floppies_525, "", formats_525);
+ }
-class applefdc_device : public applefdc_base_device
-{
-public:
- applefdc_device(const machine_config &mconfig, const char *tag, device_t *owner, const applefdc_interface *intrf)
- : applefdc_device(mconfig, tag, owner, (uint32_t)0)
- {
- set_config(intrf);
+ // 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);
+ }
+ template<typename T> static void add_35_nc(machine_config &config, T &floppy) {
+ FLOPPY_CONNECTOR(config, floppy, floppies_35, "", formats_35);
}
- applefdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-};
+ // Sync the state when something external is going to change, like
+ // the floppy side or rpm.
+ virtual void sync() = 0;
+protected:
+ devcb_write8 m_phases_cb, m_devsel_cb;
+ devcb_write_line m_sel35_cb, m_hdsel_cb;
-/***************************************************************************
- IWM - Used on early Macs
-***************************************************************************/
+ // Current phase value in the bottom bits, input/output flags in the top bits
+ u8 m_phases;
-class iwm_device : public applefdc_base_device
-{
-public:
- iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, const applefdc_interface *intrf)
- : iwm_device(mconfig, tag, owner, (uint32_t)0)
- {
- set_config(intrf);
- }
+ // Current value of the driven external phases input
+ u8 m_phases_input;
+
+ applefdc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
- iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ virtual void device_start() override;
+ virtual void device_reset() override;
- static constexpr feature_type imperfect_features() { return feature::DISK; }
+ void update_phases();
};
#endif // MAME_MACHINE_APPLEFDC_H
diff --git a/src/devices/machine/diskii.cpp b/src/devices/machine/diskii.cpp
new file mode 100644
index 00000000000..6c9de800119
--- /dev/null
+++ b/src/devices/machine/diskii.cpp
@@ -0,0 +1,350 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Implementation of the Apple Disk II floppy disk controller
+
+*********************************************************************/
+
+#include "emu.h"
+#include "diskii.h"
+#include "formats/ap2_dsk.h"
+
+/***************************************************************************
+ PARAMETERS
+***************************************************************************/
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(DISKII, diskii_device, "diskii", "Apple Disk II floppy controller")
+
+#define DISKII_P6_REGION "diskii_rom_p6"
+
+ROM_START( diskii )
+ ROM_REGION(0x100, DISKII_P6_REGION, 0)
+ ROM_LOAD( "341-0028-a.rom", 0x0000, 0x0100, CRC(b72a2c70) SHA1(bc39fbd5b9a8d2287ac5d0a42e639fc4d3c2f9d4)) /* 341-0028: 16-sector disk drive (older version), PROM P6 */
+ROM_END
+
+//-------------------------------------------------
+// rom_region - device-specific ROM region
+//-------------------------------------------------
+
+const tiny_rom_entry *diskii_device::device_rom_region() const
+{
+ return ROM_NAME( diskii );
+}
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void diskii_device::device_add_mconfig(machine_config &config)
+{
+ F9334(config, m_phaselatch); // 9334 on circuit diagram but 74LS259 in parts list; actual chip may vary
+ m_phaselatch->parallel_out_cb().set(FUNC(diskii_device::set_phase));
+}
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+diskii_device::diskii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ applefdc_device(mconfig, DISKII, tag, owner, clock),
+ m_phaselatch(*this, "phaselatch")
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void diskii_device::device_start()
+{
+ applefdc_device::device_start();
+
+ m_rom_p6 = machine().root_device().memregion(this->subtag(DISKII_P6_REGION).c_str())->base();
+
+ m_timer = timer_alloc(0);
+ m_delay_timer = timer_alloc(1);
+
+ save_item(NAME(m_last_6502_write));
+ save_item(NAME(m_mode_write));
+ save_item(NAME(m_mode_load));
+ save_item(NAME(m_active));
+ save_item(NAME(m_external_io_select));
+ save_item(NAME(m_cycles));
+ save_item(NAME(m_data_reg));
+ save_item(NAME(m_address));
+ save_item(NAME(m_write_start_time));
+ save_item(NAME(m_write_position));
+ save_item(NAME(m_write_line_active));
+}
+
+void diskii_device::device_reset()
+{
+ applefdc_device::device_reset();
+
+ m_floppy = nullptr;
+ m_active = MODE_IDLE;
+ m_mode_write = false;
+ m_mode_load = false;
+ m_last_6502_write = 0x00;
+ m_cycles = time_to_cycles(machine().time());
+ m_data_reg = 0x00;
+ m_address = 0x00;
+ m_write_start_time = attotime::never;
+ m_write_position = 0;
+ m_write_line_active = false;
+
+ // Just a timer to be sure that the lss is updated from time to
+ // time, so that there's no hiccup when it's talked to again.
+ m_timer->adjust(attotime::from_msec(10), 0, attotime::from_msec(10));
+
+ m_devsel_cb(1);
+}
+
+void diskii_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ if(m_active)
+ sync();
+
+ if(id == 1 && m_active == MODE_DELAY) {
+ if(m_floppy)
+ m_floppy->mon_w(true);
+ m_active = MODE_IDLE;
+ }
+}
+
+void diskii_device::set_floppy(floppy_image_device *floppy)
+{
+ if(m_floppy == floppy)
+ return;
+
+ sync();
+
+ if(m_floppy)
+ m_floppy->mon_w(true);
+ m_floppy = floppy;
+ if(m_active)
+ m_floppy->mon_w(false);
+ update_phases();
+}
+
+floppy_image_device *diskii_device::get_floppy() const
+{
+ return m_floppy;
+}
+
+/*-------------------------------------------------
+ read - called to read the FDC's registers
+-------------------------------------------------*/
+
+uint8_t diskii_device::read(offs_t offset)
+{
+ sync();
+ control(offset);
+
+ if(!(offset & 1))
+ return m_data_reg;
+
+ return 0xff;
+}
+
+
+/*-------------------------------------------------
+ write - called to write the FDC's registers
+-------------------------------------------------*/
+
+void diskii_device::write(offs_t offset, uint8_t data)
+{
+ sync();
+ control(offset);
+ m_last_6502_write = data;
+}
+
+WRITE8_MEMBER(diskii_device::set_phase)
+{
+ m_phases = 0xf0 | data;
+ update_phases();
+}
+
+void diskii_device::control(int offset)
+{
+ if(offset < 8)
+ m_phaselatch->write_bit(offset >> 1, offset & 1);
+
+ else
+ switch(offset) {
+ case 0x8:
+ if(m_active == MODE_ACTIVE) {
+ m_delay_timer->adjust(attotime::from_seconds(1));
+ m_active = MODE_DELAY;
+ }
+ break;
+ case 0x9:
+ switch(m_active) {
+ case MODE_IDLE:
+ if(m_floppy)
+ m_floppy->mon_w(false);
+ m_active = MODE_ACTIVE;
+ if(m_floppy)
+ lss_start();
+ break;
+ case MODE_DELAY:
+ m_active = MODE_ACTIVE;
+ m_delay_timer->adjust(attotime::never);
+ break;
+ }
+ break;
+ case 0xa:
+ m_devsel_cb(1);
+ break;
+ case 0xb:
+ m_devsel_cb(2);
+ break;
+ case 0xc:
+ if(m_mode_load) {
+ if(m_active)
+ m_address &= ~0x04;
+ m_mode_load = false;
+ }
+ break;
+ case 0xd:
+ if(!m_mode_load) {
+ if(m_active)
+ m_address |= 0x04;
+ m_mode_load = true;
+ }
+ break;
+ case 0xe:
+ if(m_mode_write) {
+ if(m_active)
+ m_address &= ~0x08;
+ m_mode_write = false;
+ attotime now = machine().time();
+ if(m_floppy)
+ m_floppy->write_flux(m_write_start_time, now, m_write_position, m_write_buffer);
+ }
+ break;
+ case 0xf:
+ if(!m_mode_write) {
+ if(m_active) {
+ m_address |= 0x08;
+ m_write_start_time = machine().time();
+ m_write_position = 0;
+ if(m_floppy)
+ m_floppy->set_write_splice(m_write_start_time);
+ }
+ m_mode_write = true;
+ }
+ break;
+ }
+}
+
+uint64_t diskii_device::time_to_cycles(const attotime &tm)
+{
+ // Clock is falling edges of the ~2Mhz clock
+ // The 1021800 must be the controlling 6502's speed
+
+ uint64_t cycles = tm.as_ticks(clock()*2);
+ cycles = (cycles+1) >> 1;
+ return cycles;
+}
+
+attotime diskii_device::cycles_to_time(uint64_t cycles)
+{
+ return attotime::from_ticks(cycles*2+1, clock()*2);
+}
+
+void diskii_device::lss_start()
+{
+ m_cycles = time_to_cycles(machine().time());
+ m_data_reg = 0x00;
+ m_address &= ~0x0e;
+ m_write_position = 0;
+ m_write_start_time = m_mode_write ? machine().time() : attotime::never;
+ m_write_line_active = false;
+ if(m_mode_write && m_floppy)
+ m_floppy->set_write_splice(m_write_start_time);
+}
+
+void diskii_device::sync()
+{
+ if(!m_active)
+ return;
+
+ attotime next_flux = m_floppy ? m_floppy->get_next_transition(cycles_to_time(m_cycles-1)) : attotime::never;
+
+ uint64_t cycles_limit = time_to_cycles(machine().time());
+ uint64_t cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : uint64_t(-1);
+ uint64_t cycles_next_flux_down = cycles_next_flux != uint64_t(-1) ? cycles_next_flux+1 : uint64_t(-1);
+
+ if(m_cycles >= cycles_next_flux && m_cycles < cycles_next_flux_down)
+ m_address &= ~0x10;
+ else
+ m_address |= 0x10;
+
+ while(m_cycles < cycles_limit) {
+ uint64_t cycles_next_trans = cycles_limit;
+ if(cycles_next_trans > cycles_next_flux && m_cycles < cycles_next_flux)
+ cycles_next_trans = cycles_next_flux;
+ if(cycles_next_trans > cycles_next_flux_down && m_cycles < cycles_next_flux_down)
+ cycles_next_trans = cycles_next_flux_down;
+
+ while(m_cycles < cycles_next_trans) {
+ uint8_t opcode = m_rom_p6[m_address];
+
+ if(m_mode_write) {
+ if((m_write_line_active && !(m_address & 0x80)) ||
+ (!m_write_line_active && (m_address & 0x80))) {
+ m_write_line_active = !m_write_line_active;
+ assert(m_write_position != 32);
+ m_write_buffer[m_write_position++] = cycles_to_time(m_cycles);
+ } else if(m_write_position >= 30) {
+ attotime now = cycles_to_time(m_cycles);
+ if(m_floppy)
+ m_floppy->write_flux(m_write_start_time, now, m_write_position, m_write_buffer);
+ m_write_start_time = now;
+ m_write_position = 0;
+ }
+ }
+
+ m_address = (m_address & 0x1e) | (opcode & 0xc0) | ((opcode & 0x20) >> 5) | ((opcode & 0x10) << 1);
+ switch(opcode & 0x0f) {
+ case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
+ m_data_reg = 0x00;
+ break;
+ case 0x8: case 0xc:
+ break;
+ case 0x9:
+ m_data_reg <<= 1;
+ break;
+ case 0xa: case 0xe:
+ m_data_reg = (m_data_reg >> 1) | (m_floppy && m_floppy->wpt_r() ? 0x80 : 0x00);
+ break;
+ case 0xb: case 0xf:
+ m_data_reg = m_last_6502_write;
+ break;
+ case 0xd:
+ m_data_reg = (m_data_reg << 1) | 0x01;
+ break;
+ }
+ if(m_data_reg & 0x80)
+ m_address |= 0x02;
+ else
+ m_address &= ~0x02;
+ m_cycles++;
+ }
+
+ if(m_cycles == cycles_next_flux)
+ m_address &= ~0x10;
+ else if(m_cycles == cycles_next_flux_down) {
+ m_address |= 0x10;
+ next_flux = m_floppy ? m_floppy->get_next_transition(cycles_to_time(m_cycles)) : attotime::never;
+ cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : uint64_t(-1);
+ cycles_next_flux_down = cycles_next_flux != uint64_t(-1) ? cycles_next_flux+1 : uint64_t(-1);
+ }
+ }
+}
diff --git a/src/devices/machine/diskii.h b/src/devices/machine/diskii.h
new file mode 100644
index 00000000000..a323b4b9856
--- /dev/null
+++ b/src/devices/machine/diskii.h
@@ -0,0 +1,83 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Apple Disk II floppy disk controller
+
+*********************************************************************/
+
+#ifndef MAME_MACHINE_DISKII_H
+#define MAME_MACHINE_DISKII_H
+
+#pragma once
+
+#include "applefdc.h"
+#include "formats/flopimg.h"
+#include "machine/74259.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+
+class diskii_device: public applefdc_device
+{
+public:
+ // construction/destruction
+ diskii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ // optional information overrides
+ virtual const tiny_rom_entry *device_rom_region() const override;
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ virtual u8 read(offs_t offset) override;
+ virtual void write(offs_t offset, uint8_t data) override;
+
+ virtual void set_floppy(floppy_image_device *floppy) override;
+ virtual floppy_image_device *get_floppy() const override;
+
+ virtual void sync() override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+ void control(int offset);
+ DECLARE_WRITE8_MEMBER(set_phase);
+ uint64_t time_to_cycles(const attotime &tm);
+ attotime cycles_to_time(uint64_t cycles);
+
+ void lss_start();
+
+ enum {
+ MODE_IDLE, MODE_ACTIVE, MODE_DELAY
+ };
+
+ floppy_image_device *m_floppy;
+
+ required_device<addressable_latch_device> m_phaselatch;
+
+ uint64_t m_cycles;
+ uint8_t m_data_reg, m_address;
+ attotime m_write_start_time;
+ attotime m_write_buffer[32];
+ int m_write_position;
+ bool m_write_line_active;
+
+ const uint8_t *m_rom_p6;
+ uint8_t m_last_6502_write;
+ bool m_mode_write, m_mode_load;
+ int m_active;
+ emu_timer *m_timer, *m_delay_timer;
+ bool m_external_drive_select;
+ bool m_external_io_select;
+
+ int m_drvsel;
+ int m_enable1;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(DISKII, diskii_device)
+
+#endif // MAME_MACHINE_DISKII_H
diff --git a/src/devices/machine/iwm.cpp b/src/devices/machine/iwm.cpp
new file mode 100644
index 00000000000..f26b26c98f5
--- /dev/null
+++ b/src/devices/machine/iwm.cpp
@@ -0,0 +1,440 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ iwm.c
+
+ Implementation of the Apple IWM floppy disk controller
+
+*********************************************************************/
+
+#include "emu.h"
+#include "iwm.h"
+
+DEFINE_DEVICE_TYPE(IWM_FDC, iwm_device, "iwm", "Apple IWM floppy controller")
+
+iwm_device::iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t q3_clock) :
+ applefdc_device(mconfig, IWM_FDC, tag, owner, clock),
+ m_q3_clock(q3_clock)
+{
+ m_q3_fclk_ratio = double(clock)/double(q3_clock); // ~0.25
+ m_fclk_q3_ratio = double(q3_clock)/double(clock); // ~4
+}
+
+u64 iwm_device::q3_to_fclk(u64 cycles) const
+{
+ return u64(m_q3_fclk_ratio * double(cycles) + 0.5);
+}
+
+u64 iwm_device::fclk_to_q3(u64 cycles) const
+{
+ return u64(m_fclk_q3_ratio * double(cycles) + 0.5);
+}
+
+void iwm_device::device_start()
+{
+ applefdc_device::device_start();
+
+ m_timer = timer_alloc();
+ save_item(NAME(m_last_sync));
+ save_item(NAME(m_next_state_change));
+ save_item(NAME(m_sync_update));
+ save_item(NAME(m_async_update));
+ save_item(NAME(m_flux_write_start));
+ save_item(NAME(m_flux_write));
+ save_item(NAME(m_flux_write_count));
+ save_item(NAME(m_q3_clock));
+ save_item(NAME(m_active));
+ save_item(NAME(m_rw));
+ save_item(NAME(m_rw_state));
+ save_item(NAME(m_data));
+ save_item(NAME(m_whd));
+ save_item(NAME(m_mode));
+ save_item(NAME(m_status));
+ save_item(NAME(m_control));
+ save_item(NAME(m_rsh));
+ save_item(NAME(m_wsh));
+}
+
+void iwm_device::device_reset()
+{
+ applefdc_device::device_reset();
+
+ m_floppy = nullptr;
+ m_last_sync = machine().time().as_ticks(clock());
+ m_next_state_change = 0;
+ m_active = MODE_IDLE;
+ m_rw = MODE_IDLE;
+ m_rw_state = S_IDLE;
+ m_data = 0x00;
+ m_whd = 0xff;
+ m_mode = 0x00;
+ m_status = 0x00;
+ m_control = 0x00;
+ m_wsh = 0x00;
+ m_rsh = 0x00;
+ m_flux_write_start = 0;
+ m_flux_write_count = 0;
+ m_devsel_cb(1);
+}
+
+void iwm_device::device_timer(emu_timer &, device_timer_id, int, void *)
+{
+ if(m_active == MODE_DELAY) {
+ m_active = MODE_IDLE;
+ if(m_floppy)
+ m_floppy->mon_w(true);
+ m_status &= ~0x20;
+ }
+}
+
+void iwm_device::set_floppy(floppy_image_device *floppy)
+{
+ if(m_floppy == floppy)
+ return;
+
+ sync();
+ flush_write();
+
+ if(m_floppy)
+ m_floppy->mon_w(true);
+ m_floppy = floppy;
+ if(m_active)
+ m_floppy->mon_w(false);
+ update_phases();
+}
+
+floppy_image_device *iwm_device::get_floppy() const
+{
+ return m_floppy;
+}
+
+uint8_t iwm_device::read(offs_t offset)
+{
+ return control(offset, 0x00);
+}
+
+void iwm_device::write(offs_t offset, u8 data)
+{
+ control(offset, data);
+}
+
+void iwm_device::flush_write()
+{
+ if(m_floppy && m_last_sync > m_flux_write_start) {
+ if(m_flux_write_count && m_flux_write[m_flux_write_count-1] == m_last_sync)
+ m_flux_write_count--;
+ attotime start = cycles_to_time(m_flux_write_start);
+ attotime end = cycles_to_time(m_last_sync);
+ std::vector<attotime> fluxes(m_flux_write_count);
+ for(u32 i=0; i != m_flux_write_count; i++)
+ fluxes[i] = cycles_to_time(m_flux_write[i]);
+ m_floppy->write_flux(start, end, m_flux_write_count, m_flux_write_count ? &fluxes[0] : nullptr);
+ }
+ m_flux_write_count = 0;
+ m_flux_write_start = m_last_sync;
+}
+
+u8 iwm_device::control(int offset, u8 data)
+{
+ sync();
+ logerror("control trigger %x, %02x\n", offset, data);
+ u8 changed = m_control | (m_phases & 0xf);
+ if(offset < 8) {
+ if(offset & 1)
+ m_phases |= 1 << (offset >> 1);
+ else
+ m_phases &= ~(1 << (offset >> 1));
+ update_phases();
+ } else {
+ if(offset & 1)
+ m_control |= 1 << (offset >> 1);
+ else
+ m_control &= ~(1 << (offset >> 1));
+ }
+
+ changed ^= m_control | (m_phases & 0xf);
+
+ if(changed & 0x20)
+ m_devsel_cb(m_control & 0x20 ? 2 : 1);
+
+ if(changed & 0x10) {
+ if(m_control & 0x10) {
+ m_active = MODE_ACTIVE;
+ if(m_floppy)
+ m_floppy->mon_w(false);
+ m_status |= 0x20;
+ } else {
+ if(m_mode & 0x04) {
+ m_active = MODE_IDLE;
+ if(m_floppy) {
+ m_floppy->mon_w(true);
+ m_floppy->seek_phase_w(0);
+ }
+ m_status &= ~0x20;
+ } else {
+ m_active = MODE_DELAY;
+ m_timer->adjust(cycles_to_time(8388608));
+ }
+ }
+ }
+
+ if(changed & 0xd0) {
+ if((m_control & 0xc0) == 0x00 && m_active) {
+ if(m_rw == MODE_WRITE)
+ flush_write();
+ m_rw = MODE_READ;
+ m_rw_state = S_IDLE;
+ m_next_state_change = 0;
+ m_sync_update = 0;
+ m_async_update = 0;
+ m_data = 0x00;
+
+ } else if((m_control & 0xc0) == 0xc0 && (changed & 0xc0) == 0x40 && m_active && m_rw != MODE_WRITE) {
+ m_rw = MODE_WRITE;
+ m_rw_state = S_IDLE;
+ m_next_state_change = 0;
+ m_flux_write_start = m_last_sync;
+ m_flux_write_count = 0;
+ if(m_floppy)
+ m_floppy->set_write_splice(cycles_to_time(m_flux_write_start));
+
+ } else if(m_rw == MODE_WRITE) {
+ if(!(m_control & 0x80)) {
+ flush_write();
+ m_rw = MODE_IDLE;
+ }
+ } else
+ m_rw = MODE_IDLE;
+ }
+
+ if(changed || 1) {
+ u8 s = m_control & 0xc0;
+ const char *slot = "?";
+ if(s == 0x00 && !m_active)
+ slot = "idle / ff";
+ if(s == 0x00 && m_active)
+ slot = "read / read data";
+ if(s == 0x40)
+ slot = "wp sense / read status";
+ if(s == 0x80)
+ slot = "write / read whd";
+ if(s == 0xc0 && !m_active)
+ slot = "mode set / write mode";
+ if(s == 0xc0 && m_active)
+ slot = "write load / write data";
+
+ logerror("control %c%c %c%c %c%c%c%c (%s) [%s, %s]\n",
+ m_control & 0x80 ? '1' : '0',
+ m_control & 0x40 ? '1' : '0',
+ m_control & 0x20 ? 'b' : 'a',
+ m_control & 0x10 ? '#' : '.',
+ m_phases & 0x08 ? '#' : '.',
+ m_phases & 0x04 ? '#' : '.',
+ m_phases & 0x02 ? '#' : '.',
+ m_phases & 0x01 ? '#' : '.',
+ slot,
+ m_active == MODE_IDLE ? "idle" : m_active == MODE_DELAY ? "delay" : "active",
+ m_rw == MODE_IDLE ? "idle" : m_rw == MODE_READ ? "read" : "write");
+ }
+
+ if(m_active && !(m_control & 0xc0) && !is_sync() && (m_data & 0x80))
+ m_async_update = m_last_sync + 14;
+
+ switch(m_control & 0xc0) {
+ case 0x00: return m_active ? m_data : 0xff;
+ case 0x40: return m_status;
+ case 0x80: return m_whd;
+ case 0xc0: if(offset & 1) { if(m_active) data_w(data); else mode_w(data); } return 0xff;
+ }
+
+ abort();
+}
+
+void iwm_device::mode_w(u8 data)
+{
+ m_mode = data;
+ m_status = (m_status & 0xe0) | (data & 0x1f);
+ logerror("mode %02x%s%s%s%s%s%s%s\n", m_mode,
+ m_mode & 0x80 ? " b7" : "",
+ m_mode & 0x40 ? " mz-reset" : "",
+ m_mode & 0x20 ? " test" : " normal",
+ m_mode & 0x10 ? " 8MHz" : " 7MHz",
+ m_mode & 0x08 ? " fast" : " slow",
+ m_mode & 0x04 ? "" : " timer",
+ m_mode & 0x02 ? " async" : " sync",
+ m_mode & 0x01 ? " latched" : "");
+}
+
+void iwm_device::data_w(u8 data)
+{
+ m_data = data;
+ if(is_sync() && m_rw == MODE_WRITE)
+ m_wsh = data;
+}
+
+u64 iwm_device::time_to_cycles(const attotime &tm) const
+{
+ return tm.as_ticks(clock());
+}
+
+attotime iwm_device::cycles_to_time(u64 cycles) const
+{
+ return attotime::from_ticks(cycles, clock());
+}
+
+bool iwm_device::is_sync() const
+{
+ return m_mode & 0x02 ? false : true;
+}
+
+u64 iwm_device::half_window_size() const
+{
+ switch(m_mode & 0x18) {
+ case 0x00: return 14;
+ case 0x08: return 7;
+ case 0x10: return 16;
+ case 0x18: return 8;
+ }
+ abort();
+}
+
+u64 iwm_device::window_size() const
+{
+ switch(m_mode & 0x18) {
+ case 0x00: return 28;
+ case 0x08: return 14;
+ case 0x10: return 36;
+ case 0x18: return 16;
+ }
+ abort();
+}
+
+u64 iwm_device::read_register_update_delay() const
+{
+ return m_mode & 0x08 ? 4 : 8;
+}
+
+u64 iwm_device::write_sync_half_window_size() const
+{
+ return m_mode & 0x08 ? 2 : 4;
+}
+
+void iwm_device::sync()
+{
+ if(!m_active)
+ return;
+
+ u64 next_sync = machine().time().as_ticks(clock());
+ switch(m_rw) {
+ case MODE_IDLE:
+ m_last_sync = next_sync;
+ break;
+
+ case MODE_READ: {
+ u64 next_flux_change = 0;
+ while(next_sync > m_last_sync) {
+ if(next_flux_change <= m_last_sync) {
+ attotime flux = m_floppy ? m_floppy->get_next_transition(cycles_to_time(m_last_sync+1)) : attotime::never;
+ next_flux_change = flux.is_never() ? u64(-1) : time_to_cycles(flux);
+ if(next_flux_change <= m_last_sync)
+ next_flux_change = m_last_sync+1;
+ }
+ if(next_sync < m_next_state_change) {
+ m_last_sync = next_sync;
+ break;
+ }
+ if(m_last_sync < m_next_state_change)
+ m_last_sync = m_next_state_change;
+ switch(m_rw_state) {
+ case S_IDLE:
+ m_rsh = 0x00;
+ m_rw_state = SR_WINDOW_EDGE_0;
+ m_next_state_change = m_last_sync + window_size();
+ m_sync_update = 0;
+ m_async_update = 0;
+ break;
+
+ case SR_WINDOW_EDGE_0:
+ case SR_WINDOW_EDGE_1: {
+ u64 endw = m_next_state_change + (m_rw_state == SR_WINDOW_EDGE_0 ? window_size() : half_window_size());
+ if(m_rw_state == SR_WINDOW_EDGE_0 && endw >= next_flux_change && next_sync >= next_flux_change) {
+ m_last_sync = m_next_state_change = next_flux_change;
+ m_rw_state = SR_WINDOW_EDGE_1;
+ break;
+ }
+ if(next_sync < endw) {
+ m_last_sync = next_sync;
+ break;
+ }
+ m_rsh = (m_rsh << 1) | (m_rw_state == SR_WINDOW_EDGE_1 ? 1 : 0);
+ m_next_state_change = m_last_sync = endw;
+ m_rw_state = SR_WINDOW_EDGE_0;
+ if(is_sync()) {
+ if(m_rsh >= 0x80) {
+ m_data = m_rsh;
+ m_rsh = 0;
+ } else if(m_rsh >= 0x04) {
+ m_data = m_rsh;
+ m_sync_update = 0;
+ } else if(m_rsh >= 0x02)
+ m_sync_update = m_last_sync + read_register_update_delay();
+
+ } else if(m_rsh >= 0x80) {
+ m_data = m_rsh;
+ m_rsh = 0;
+ }
+ break;
+ }
+ }
+ }
+ if(m_sync_update && m_sync_update <= m_last_sync) {
+ if(is_sync())
+ m_data = m_rsh;
+ m_sync_update = 0;
+ }
+ if(m_async_update && m_async_update <= m_last_sync) {
+ if(!is_sync()) {
+ m_data = 0;
+ }
+ m_async_update = 0;
+ }
+ break;
+ }
+
+ case MODE_WRITE: {
+ while(next_sync > m_last_sync) {
+ if(next_sync < m_next_state_change) {
+ m_last_sync = next_sync;
+ break;
+ }
+ if(m_last_sync < m_next_state_change)
+ m_last_sync = m_next_state_change;
+ switch(m_rw_state) {
+ case S_IDLE:
+ m_wsh = m_data;
+ m_rw_state = SW_WINDOW_MIDDLE;
+ m_next_state_change = q3_to_fclk(fclk_to_q3(m_last_sync) + write_sync_half_window_size());
+ m_flux_write_count = 0;
+ break;
+
+ case SW_WINDOW_MIDDLE:
+ if(m_wsh & 0x80)
+ m_flux_write[m_flux_write_count++] = m_last_sync;
+ m_wsh <<= 1;
+ m_next_state_change = q3_to_fclk(fclk_to_q3(m_last_sync) + write_sync_half_window_size());
+
+ m_rw_state = SW_WINDOW_END;
+ break;
+ case SW_WINDOW_END:
+ if(m_flux_write_count == m_flux_write.size())
+ flush_write();
+ m_next_state_change = q3_to_fclk(fclk_to_q3(m_last_sync) + write_sync_half_window_size());
+ m_rw_state = SW_WINDOW_MIDDLE;
+ break;
+ }
+ }
+ break;
+ }
+}
+}
diff --git a/src/devices/machine/iwm.h b/src/devices/machine/iwm.h
new file mode 100644
index 00000000000..4f63d2df806
--- /dev/null
+++ b/src/devices/machine/iwm.h
@@ -0,0 +1,89 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Apple IWM floppy disk controller
+
+*********************************************************************/
+
+#pragma once
+
+#ifndef MAME_MACHINE_IWM_H
+#define MAME_MACHINE_IWM_H
+
+#include "applefdc.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+
+class iwm_device: public applefdc_device
+{
+public:
+ // construction/destruction
+ iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t q3_clock = 0);
+ iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, XTAL q3_clock) :
+ iwm_device(mconfig, tag, owner, clock, q3_clock.value()) {}
+
+ virtual u8 read(offs_t offset) override;
+ virtual void write(offs_t offset, u8 data) override;
+
+ virtual void set_floppy(floppy_image_device *floppy) override;
+ virtual floppy_image_device *get_floppy() const override;
+
+ virtual void sync() override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+private:
+ enum {
+ MODE_IDLE,
+ MODE_ACTIVE, MODE_DELAY, // m_active modes
+ MODE_READ, MODE_WRITE // m_rw modes
+ };
+
+ // state machine states
+ enum {
+ S_IDLE,
+ SR_WINDOW_EDGE_0,
+ SR_WINDOW_EDGE_1,
+ SW_WINDOW_MIDDLE,
+ SW_WINDOW_END
+ };
+
+ floppy_image_device *m_floppy;
+ emu_timer *m_timer;
+ double m_q3_fclk_ratio, m_fclk_q3_ratio;
+ u64 m_last_sync, m_next_state_change, m_sync_update, m_async_update;
+ u64 m_flux_write_start;
+ std::array<u64, 16> m_flux_write;
+ u32 m_flux_write_count;
+ u32 m_q3_clock;
+ int m_active, m_rw, m_rw_state;
+ u8 m_data, m_whd, m_mode, m_status, m_control;
+ u8 m_rsh, m_wsh;
+
+ u8 control(int offset, u8 data);
+ u64 time_to_cycles(const attotime &tm) const;
+ attotime cycles_to_time(u64 cycles) const;
+ u64 fclk_to_q3(u64 cycles) const;
+ u64 q3_to_fclk(u64 cycles) const;
+
+ void mode_w(u8 data);
+ void data_w(u8 data);
+
+ u64 window_size() const;
+ u64 half_window_size() const;
+ u64 read_register_update_delay() const;
+ u64 write_sync_half_window_size() const;
+ inline bool is_sync() const;
+ void flush_write();
+};
+
+DECLARE_DEVICE_TYPE(IWM, iwm_device)
+
+#endif /* MAME_MACHINE_IWM_H */
diff --git a/src/devices/machine/sonydriv.cpp b/src/devices/machine/sonydriv.cpp
deleted file mode 100644
index 8f23a832c36..00000000000
--- a/src/devices/machine/sonydriv.cpp
+++ /dev/null
@@ -1,628 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont
-/*********************************************************************
-
- sonydriv.c
-
- Apple/Sony 3.5" floppy drive emulation (to be interfaced with iwm.c)
-
- Nate Woods, Raphael Nabet, R. Belmont
-
- This floppy drive was present in all variants of Lisa 2 (including Mac XL),
- all Apple IIgs and IIc Plus machines, and in all Macintoshes in production
- before 1988, when SWIM and SuperDrive were introduced.
-
- There were three major variants :
- - A single-sided 400k unit which was used on Lisa 2/Mac XL, and Macintosh
- 128k/512k. This unit needs the computer to send the proper pulses to
- control the drive motor rotation. It can be connected to all early
- Macintosh (but not Mac Classic?) as an external unit.
- - A double-sided 800k unit which was used on Macintosh Plus, 512ke, and
- early SE and II*. This unit generates its own drive motor rotation
- control signals. It can be connected to earlier (and later) Macintosh as
- an external or internal unit. Some Lisa2/10 and Mac XL were upgraded to
- use it, too, but a fdc ROM upgrade was required.
- - A double-sided 1440k unit. This is fully back compatible with the 800k
- drive, and adds 1440k MFM capability. This drive, called FDHD or
- SuperDrive by Apple, came in automatic and manual-inject versions.
-
- TODO :
- * support for other image formats?
- * should we support more than 2 floppy disk units? (Mac SE supported 3 drives)
-
-*********************************************************************/
-
-#include "emu.h"
-#include "sonydriv.h"
-
-#include "machine/applefdc.h"
-#include "formats/ap_dsk35.h"
-#include "imagedev/flopdrv.h"
-
-
-#ifdef MAME_DEBUG
-#define LOG_SONY 1
-#define LOG_SONY_EXTRA 0
-#else
-#define LOG_SONY 0
-#define LOG_SONY_EXTRA 0
-#endif
-
-/*
- These lines are normally connected to the PHI0-PHI3 lines of the IWM
-*/
-enum
-{
- SONY_CA0 = 0x01,
- SONY_CA1 = 0x02,
- SONY_CA2 = 0x04,
- SONY_LSTRB = 0x08
-};
-
-/*
- Structure that describes the state of a floppy drive, and the associated
- disk image
-*/
-struct floppy_t
-{
- device_t *img;
- emu_file *fd;
-
- unsigned int disk_switched : 1; /* disk-in-place status bit */
- unsigned int head : 1; /* active head (-> floppy side) */
- unsigned int step : 1;
- int motor_on;
-
- unsigned int loadedtrack_valid : 1; /* is data in track buffer valid ? */
- unsigned int loadedtrack_dirty : 1; /* has data in track buffer been modified? */
- size_t loadedtrack_size; /* size of loaded track */
- size_t loadedtrack_pos; /* position within loaded track */
- uint8_t *loadedtrack_data; /* pointer to track buffer */
-
- int is_fdhd; /* is drive an FDHD? */
- int is_400k; /* drive is single-sided, which means 400K */
-};
-
-struct sonydriv_t
-{
- int lines; /* four lines SONY_CA0 - SONY_LSTRB */
-
- int floppy_enable; /* whether a drive is enabled or not (-> enable line) */
- int floppy_select; /* which drive is enabled */
-
- int sel_line; /* one single line Is 0 or 1 */
-
- unsigned int rotation_speed; /* drive rotation speed - ignored if ext_speed_control == 0 */
- floppy_t floppy[2]; /* data for two floppy disk units */
-};
-static sonydriv_t sony;
-
-/* bit of code used in several places - I am unsure why it is here */
-static int sony_enable2(void)
-{
- return (sony.lines & SONY_CA1) && (sony.lines & SONY_LSTRB);
-}
-
-static legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive)
-{
- switch(drive) {
- case 0 : return machine.device<legacy_floppy_image_device>(FLOPPY_0);
- case 1 : return machine.device<legacy_floppy_image_device>(FLOPPY_1);
- case 2 : return machine.device<legacy_floppy_image_device>(FLOPPY_2);
- case 3 : return machine.device<legacy_floppy_image_device>(FLOPPY_3);
- }
- return nullptr;
-}
-
-static legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive)
-{
- int i;
- int cnt = 0;
- for (i=0;i<4;i++) {
- legacy_floppy_image_device *disk = floppy_get_device(machine,i);
- if (disk && disk->floppy_get_drive_type()==ftype) {
- if (cnt==drive) {
- return disk;
- }
- cnt++;
- }
- }
- return nullptr;
-}
-
-static int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype)
-{
- int i,drive =0;
- for (i=0;i<4;i++) {
- legacy_floppy_image_device *disk = floppy_get_device(image->machine(),i);
- if (disk && disk->floppy_get_drive_type()==ftype) {
- if (image==disk) {
- return drive;
- }
- drive++;
- }
- }
- return -1;
-}
-
-static void load_track_data(device_t *device,int floppy_select)
-{
- int track_size;
- legacy_floppy_image_device *cur_image;
- uint8_t *new_data;
- floppy_t *f;
-
- f = &sony.floppy[floppy_select];
- cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select);
-
- floppy_image_legacy *fimg = cur_image->flopimg_get_image();
-
- if (!fimg)
- {
- return;
- }
-
- track_size = floppy_get_track_size(fimg, f->head, cur_image->floppy_drive_get_current_track());
- if (f->loadedtrack_data) auto_free(device->machine(),f->loadedtrack_data);
- new_data = auto_alloc_array(device->machine(),uint8_t,track_size);
- if (!new_data)
- {
- return;
- }
-
- cur_image->floppy_drive_read_track_data_info_buffer(f->head, new_data, &track_size);
- f->loadedtrack_valid = 1;
- f->loadedtrack_dirty = 0;
- f->loadedtrack_size = track_size;
- f->loadedtrack_data = new_data;
- f->loadedtrack_pos = 0;
-}
-
-
-
-static void save_track_data(device_t *device, int floppy_select)
-{
- legacy_floppy_image_device *cur_image;
- floppy_t *f;
- int len;
-
- f = &sony.floppy[floppy_select];
- cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select);
-
- if (f->loadedtrack_dirty)
- {
- len = f->loadedtrack_size;
- cur_image->floppy_drive_write_track_data_info_buffer(f->head, f->loadedtrack_data, &len);
- f->loadedtrack_dirty = 0;
- }
-}
-
-
-
-uint8_t sony_read_data(device_t *device)
-{
- uint8_t result = 0;
- legacy_floppy_image_device *cur_image;
- floppy_t *f;
-
- if (sony_enable2() || (! sony.floppy_enable))
- return 0xFF; /* right ??? */
-
- f = &sony.floppy[sony.floppy_select];
- cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select);
- if (!cur_image->exists())
- return 0xFF;
-
- if (!f->loadedtrack_valid)
- load_track_data(device, sony.floppy_select);
-
- if (!f->loadedtrack_data)
- {
- return 0xFF;
- }
-
- result = sony_fetchtrack(f->loadedtrack_data, f->loadedtrack_size, &f->loadedtrack_pos);
- return result;
-}
-
-
-
-void sony_write_data(device_t *device,uint8_t data)
-{
- device_image_interface *cur_image;
- floppy_t *f;
-
- f = &sony.floppy[sony.floppy_select];
- cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select));
- if (!cur_image->exists())
- return;
-
- if (!f->loadedtrack_valid)
- load_track_data(device,sony.floppy_select);
-
- if (!f->loadedtrack_data)
- {
- return;
- }
-
- sony_filltrack(f->loadedtrack_data, f->loadedtrack_size, &f->loadedtrack_pos, data);
- f->loadedtrack_dirty = 1;
-}
-
-
-
-static int sony_rpm(floppy_t *f, legacy_floppy_image_device *cur_image)
-{
- int result = 0;
- /*
- * The Mac floppy controller was interesting in that its speed was adjusted
- * while the thing was running. On the tracks closer to the rim, it was
- * sped up so that more data could be placed on it. Hence, this function
- * has different results depending on the track number
- *
- * The Mac Plus (and probably the other Macs that use the IWM) verify that
- * the speed of the floppy drive is within a certain range depending on
- * what track the floppy is at. These RPM values are just guesses and are
- * probably not fully accurate, but they are within the range that the Mac
- * Plus expects and thus are probably in the right ballpark.
- *
- * Note - the timing values are the values returned by the Mac Plus routine
- * that calculates the speed; I'm not sure what units they are in
- */
-
- if ((f->is_400k) && (sony.rotation_speed))
- {
- /* 400k unit : rotation speed should be controlled by computer */
- result = sony.rotation_speed;
- }
- else
- { /* 800k unit : rotation speed controlled by drive */
-#if 1 /* Mac Plus */
- static const int speeds[] =
- {
- 500, /* 00-15: timing value 117B (acceptable range {1135-11E9} */
- 550, /* 16-31: timing value ???? (acceptable range {12C6-138A} */
- 600, /* 32-47: timing value ???? (acceptable range {14A7-157F} */
- 675, /* 48-63: timing value ???? (acceptable range {16F2-17E2} */
- 750 /* 64-79: timing value ???? (acceptable range {19D0-1ADE} */
- };
-#else /* Lisa 2 */
- /* 237 + 1.3*(256-reg) */
- static const int speeds[] =
- {
- 293, /* 00-15: timing value ???? (acceptable range {0330-0336} */
- 322, /* 16-31: timing value ???? (acceptable range {02ED-02F3} */
- 351, /* 32-47: timing value ???? (acceptable range {02A7-02AD} */
- 394, /* 48-63: timing value ???? (acceptable range {0262-0266} */
- 439 /* 64-79: timing value ???? (acceptable range {021E-0222} */
- };
-#endif
- if (cur_image && cur_image->exists())
- result = speeds[cur_image->floppy_drive_get_current_track() / 16];
- }
- return result;
-}
-
-int sony_read_status(device_t *device)
-{
- int result = 1;
- int action;
- floppy_t *f;
- legacy_floppy_image_device *cur_image;
-
- action = ((sony.lines & (SONY_CA1 | SONY_CA0)) << 2) | (sony.sel_line << 1) | ((sony.lines & SONY_CA2) >> 2);
-
- if (LOG_SONY_EXTRA)
- {
- device->logerror("%s sony.status(): action=%x%s\n",
- device->machine().describe_context(),
- action, sony.floppy_enable ? "" : " (no drive enabled)");
- }
-
- if ((! sony_enable2()) && sony.floppy_enable)
- {
- f = &sony.floppy[sony.floppy_select];
- cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select);
- if (!cur_image->exists())
- cur_image = nullptr;
-
- switch(action) {
- case 0x00: /* Step direction */
- result = f->step;
- break;
- case 0x01: /* Lower head activate */
- if (f->head != 0)
- {
- save_track_data(device,sony.floppy_select);
- f->head = 0;
- f->loadedtrack_valid = 0;
- }
- result = 0;
- break;
- case 0x02: /* Disk in place */
- result = cur_image ? 0 : 1; /* 0=disk 1=nodisk */
- break;
- case 0x03: /* Upper head activate (not on 400k) */
- if ((f->head != 1) && !(f->is_400k))
- {
- save_track_data(device,sony.floppy_select);
- f->head = 1;
- f->loadedtrack_valid = 0;
- }
- result = 0;
- break;
- case 0x04: /* Disk is stepping 0=stepping 1=not stepping*/
- result = 1;
- break;
- case 0x05: /* Drive is SuperDrive: 0 = 400/800k, 1 = SuperDrive */
- result = f->is_fdhd ? 1: 0;
- break;
- case 0x06: /* Disk is locked 0=locked 1=unlocked */
- if (cur_image)
- result = cur_image->floppy_wpt_r();
- else
- result = 0;
- break;
- case 0x08: /* Motor on 0=on 1=off */
- result = f->motor_on;
- break;
- case 0x09: /* Number of sides: 0=single sided, 1=double sided */
- if (cur_image)
- {
- floppy_image_legacy *fimg = cur_image->flopimg_get_image();
- if (fimg)
- {
- result = floppy_get_heads_per_disk(fimg) - 1;
- f->is_400k = result ? 0 : 1;
- }
- }
- break;
- case 0x0a: /* At track 0: 0=track zero 1=not track zero */
- device->logerror("%s sony.status(): reading Track 0\n", device->machine().describe_context());
- if (cur_image)
- result = cur_image->floppy_tk00_r();
- else
- result = 0;
- break;
- case 0x0b: /* Disk ready: 0=ready, 1=not ready */
- result = 0;
- break;
- case 0x0c: /* Disk switched */
- {
- if (cur_image)
- {
- if (!cur_image->floppy_dskchg_r())
- {
- f->disk_switched = 1;
- }
- }
- result = f->disk_switched;
- }
- break;
- case 0x0d: /* Unknown */
- /* I'm not sure what this one does, but the Mac Plus executes the
- * following code that uses this status:
- *
- * 417E52: moveq #$d, D0 ; Status 0x0d
- * 417E54: bsr 4185fe ; Query IWM status
- * 417E58: bmi 417e82 ; If result=1, then skip
- *
- * This code is called in the Sony driver's open method, and
- * _AddDrive does not get called if this status 0x0d returns 1.
- * Hence, we are returning 0
- */
- result = 0;
- break;
- case 0x0e: /* Tachometer */
- /* (time in seconds) / (60 sec/minute) * (rounds/minute) * (60 pulses) * (2 pulse phases) */
- if (cur_image)
- {
- result = ((int) (device->machine().time().as_double() / 60.0 * sony_rpm(f, cur_image) * 60.0 * 2.0)) & 1;
- }
- break;
- case 0x0f: /* 400k/800k: Drive installed: 0=drive connected, 1=drive not connected */
- /* FDHD: Inserted disk density: 0=HD, 1=DD */
- if (f->is_fdhd)
- {
- result = 1;
- }
- else
- {
- result = 0;
- }
- break;
- default:
- if (LOG_SONY)
- device->logerror("sony_status(): unknown action\n");
- break;
- }
- }
-
- return result;
-}
-
-static void sony_doaction(device_t *device)
-{
- int action;
- floppy_t *f;
- legacy_floppy_image_device *cur_image;
-
- action = ((sony.lines & (SONY_CA1 | SONY_CA0)) << 2) | ((sony.lines & SONY_CA2) >> 2) | (sony.sel_line << 1);
-
- if (LOG_SONY)
- {
- device->logerror("%s sony_doaction(): action=%d %s\n",
- device->machine().describe_context(), action, (sony.floppy_enable) ? "" : " (MOTOR OFF)");
- }
-
- if (sony.floppy_enable)
- {
- f = &sony.floppy[sony.floppy_select];
- cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select);
- if (!cur_image->exists())
- cur_image = nullptr;
-
- switch(action)
- {
- case 0x00: /* Set step inward (higher tracks) */
- f->step = 0;
- break;
- case 0x01: /* Set step outward (lower tracks) */
- f->step = 1;
- break;
- case 0x03: /* Reset diskswitched */
- f->disk_switched = 0;
- // flopdrv.cpp won't reset its disk switch flag without
- // doing a seek. So we do a seek of 0 tracks, which works.
- if (cur_image)
- {
- cur_image->floppy_drive_seek(0);
- }
- break;
- case 0x04: /* Step disk */
- if (cur_image)
- {
- save_track_data(device,sony.floppy_select);
- if (f->step)
- cur_image->floppy_drive_seek(-1);
- else
- cur_image->floppy_drive_seek(+1);
- f->loadedtrack_valid = 0;
- }
- break;
- case 0x08: /* Turn motor on */
- f->motor_on = CLEAR_LINE;
- if (cur_image)
- cur_image->floppy_mon_w(f->motor_on);
- break;
- case 0x09: /* Turn motor off */
- f->motor_on = ASSERT_LINE;
- if (cur_image)
- cur_image->floppy_mon_w(f->motor_on);
- break;
- case 0x0d: /* Eject disk */
- if (cur_image)
- cur_image->unload();
- break;
- default:
- if (LOG_SONY)
- device->logerror("sony_doaction(): unknown action %d\n", action);
- break;
- }
- }
-}
-
-void sony_set_lines(device_t *device,uint8_t lines)
-{
- int old_sony_lines = sony.lines;
-
- sony.lines = lines & 0x0F;
-
- {
- //int action = ((sony.lines & (SONY_CA1 | SONY_CA0)) << 2) | (sony.sel_line << 1) | ((sony.lines & SONY_CA2) >> 2);
- //logerror("sony.set_lines: %02x, action now %d\n", lines&0xf, action);
- }
-
- /* have we just set LSTRB ? */
- if ((sony.lines & ~old_sony_lines) & SONY_LSTRB)
- {
- /* if so, write drive reg */
- sony_doaction(device);
- }
-
- if (LOG_SONY_EXTRA)
- device->logerror("sony.set_lines(): %d\n", lines);
-}
-
-void sony_set_enable_lines(device_t *device,int enable_mask)
-{
- switch (enable_mask)
- {
- case 0:
- default: /* well, we have to do something, right ? */
- sony.floppy_enable = 0;
- break;
- case 1:
- sony.floppy_enable = 1;
- sony.floppy_select = 0;
- break;
- case 2:
- sony.floppy_enable = 1;
- sony.floppy_select = 1;
- break;
- }
-
- if (LOG_SONY_EXTRA)
- device->logerror("sony.set_enable_lines(): %d\n", enable_mask);
-}
-
-void sony_set_sel_line(device_t *device,int sel)
-{
- sony.sel_line = sel ? 1 : 0;
-
- {
- //int action = ((sony.lines & (SONY_CA1 | SONY_CA0)) << 2) | (sony.sel_line << 1) | ((sony.lines & SONY_CA2) >> 2);
- //logerror("sony.set_sel_line: %d, action now %d\n", sony.sel_line, action);
- }
-
- if (LOG_SONY_EXTRA)
- device->logerror("sony.set_sel_line(): %s line IWM_SEL\n", sony.sel_line ? "setting" : "clearing");
-}
-
-void sony_set_speed(int speed)
-{
- sony.rotation_speed = speed;
-}
-
-// device type definition
-DEFINE_DEVICE_TYPE(FLOPPY_SONY, sonydriv_floppy_image_device, "floppy_sonny", "Floppy Disk [Sony]")
-
-//-------------------------------------------------
-// sonydriv_floppy_image_device - constructor
-//-------------------------------------------------
-
-sonydriv_floppy_image_device::sonydriv_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : legacy_floppy_image_device(mconfig, FLOPPY_SONY, tag, owner, clock)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void sonydriv_floppy_image_device::device_start()
-{
- legacy_floppy_image_device::device_start();
- floppy_set_type(FLOPPY_TYPE_SONY);
-
- sony.floppy[0].is_fdhd = 0;
- sony.floppy[1].is_fdhd = 0;
- sony.floppy[0].is_400k = 0;
- sony.floppy[1].is_400k = 0;
- sony.floppy[0].loadedtrack_data = nullptr;
- sony.floppy[1].loadedtrack_data = nullptr;
- sony.floppy[0].head = 0;
- sony.floppy[1].head = 0;
- sony.rotation_speed = 0;
-}
-
-void sonydriv_floppy_image_device::call_unload()
-{
- int id;
- device_t *fdc;
-
- /* locate the FDC */
- fdc = machine().device("fdc");
-
- id = floppy_get_drive_by_type(this,FLOPPY_TYPE_SONY);
- save_track_data(fdc, id);
- memset(&sony.floppy[id], 0, sizeof(sony.floppy[id]));
-
- legacy_floppy_image_device::call_unload();
-}
-
-void sonydriv_floppy_image_device::legacy_2_drives_add(machine_config &mconfig, const floppy_interface *config)
-{
- FLOPPY_SONY(mconfig, FLOPPY_0).set_floppy_config(config);
- FLOPPY_SONY(mconfig, FLOPPY_1).set_floppy_config(config);
-}
diff --git a/src/devices/machine/sonydriv.h b/src/devices/machine/sonydriv.h
deleted file mode 100644
index 8e0e5a54e5d..00000000000
--- a/src/devices/machine/sonydriv.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont
-/*********************************************************************
-
- sonydriv.h
-
- Apple/Sony 3.5" floppy drive emulation (to be interfaced with applefdc.c)
-
-*********************************************************************/
-
-#ifndef MAME_MACHINE_SONYDRIV_H
-#define MAME_MACHINE_SONYDRIV_H
-
-#pragma once
-
-#include "imagedev/flopdrv.h"
-
-#define FLOPPY_0 "floppy0"
-#define FLOPPY_1 "floppy1"
-#define FLOPPY_2 "floppy2"
-#define FLOPPY_3 "floppy3"
-
-#if 0
-enum
-{
- SONY_FLOPPY_ALLOW400K = 0x0001,
- SONY_FLOPPY_ALLOW800K = 0x0002,
-
- SONY_FLOPPY_SUPPORT2IMG = 0x4000,
- SONY_FLOPPY_EXT_SPEED_CONTROL = 0x8000 // means the speed is controlled by computer
-};
-#endif
-
-void sony_set_lines(device_t *device, uint8_t lines);
-void sony_set_enable_lines(device_t *device, int enable_mask);
-void sony_set_sel_line(device_t *device, int sel);
-
-void sony_set_speed(int speed);
-
-uint8_t sony_read_data(device_t *device);
-void sony_write_data(device_t *device, uint8_t data);
-int sony_read_status(device_t *device);
-
-class sonydriv_floppy_image_device : public legacy_floppy_image_device
-{
-public:
- // construction/destruction
- sonydriv_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const floppy_interface *config)
- : sonydriv_floppy_image_device(mconfig, tag, owner, (uint32_t)0)
- {
- set_floppy_config(config);
- }
- sonydriv_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
-
- static void legacy_2_drives_add(machine_config &mconfig, const floppy_interface *config);
-
- virtual void call_unload() override;
-
-protected:
- virtual void device_start() override;
-};
-
-// device type definition
-DECLARE_DEVICE_TYPE(FLOPPY_SONY, sonydriv_floppy_image_device)
-
-#endif // MAME_MACHINE_SONYDRIV_H
diff --git a/src/devices/machine/swim1.cpp b/src/devices/machine/swim1.cpp
new file mode 100644
index 00000000000..4521c7d8f49
--- /dev/null
+++ b/src/devices/machine/swim1.cpp
@@ -0,0 +1,176 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Implementation of the Apple SWIM1 floppy disk controller
+
+*********************************************************************/
+
+#include "emu.h"
+#include "swim1.h"
+
+DEFINE_DEVICE_TYPE(SWIM1, swim1_device, "swim1", "Apple SWIM1 (Sander/Wozniak Integrated Machine) version 1 floppy controller")
+
+swim1_device::swim1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ applefdc_device(mconfig, SWIM1, tag, owner, clock)
+{
+}
+
+void swim1_device::device_start()
+{
+ applefdc_device::device_start();
+ save_item(NAME(m_mode));
+ save_item(NAME(m_setup));
+ save_item(NAME(m_param_idx));
+ save_item(NAME(m_param));
+}
+
+void swim1_device::device_reset()
+{
+ applefdc_device::device_reset();
+ m_mode = 0x40;
+ m_setup = 0x00;
+ m_param_idx = 0;
+ memset(m_param, 0, sizeof(m_param));
+ m_floppy = nullptr;
+
+ m_devsel_cb(0);
+ m_sel35_cb(true);
+ m_hdsel_cb(false);
+}
+
+void swim1_device::device_timer(emu_timer &, device_timer_id, int, void *)
+{
+}
+
+void swim1_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();
+}
+
+floppy_image_device *swim1_device::get_floppy() const
+{
+ return m_floppy;
+}
+
+void swim1_device::show_mode() const
+{
+ logerror("mode%s %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 & 0x01 ? " clear" : "");
+
+}
+
+u8 swim1_device::read(offs_t offset)
+{
+ static const char *const names[] = {
+ "?0", "?1", "?2", "?3", "?4", "?5", "?6", "?7",
+ "data", "mark", "crc", "param", "phases", "setup", "status", "handshake"
+ };
+ switch(offset) {
+ case 0x3: case 0xb: {
+ u8 r = m_param[m_param_idx];
+ m_param_idx = (m_param_idx + 1) & 15;
+ return r;
+ }
+ case 0x4: case 0xc:
+ return m_phases;
+ case 0x5: case 0xd:
+ return m_setup;
+ case 0xe:
+ return m_mode;
+ default:
+ logerror("read %s\n", names[offset & 15]);
+ break;
+ }
+ return 0xff;
+}
+
+void swim1_device::write(offs_t offset, u8 data)
+{
+ machine().debug_break();
+ static const char *const names[] = {
+ "data", "mark", "crc", "param", "phases", "setup", "mode0", "mode1",
+ "?8", "?9", "?a", "?b", "?c", "?d", "?e", "?f"
+ };
+ switch(offset) {
+ case 0x3: case 0xb: {
+#if 0
+ static const char *const pname[16] = {
+ "minct", "mult", "ssl", "sss", "sll", "sls", "rpt", "csls",
+ "lsl", "lss", "lll", "lls", "late", "time0", "early", "time1"
+ };
+#endif
+ static const char *const pname[4] = {
+ "late", "time0", "early", "time1"
+ };
+ logerror("param[%s] = %02x\n", pname[m_param_idx], data);
+ m_param[m_param_idx] = data;
+ m_param_idx = (m_param_idx + 1) & 3;
+ break;
+ }
+ case 0x4: {
+ m_phases = data;
+ update_phases();
+ break;
+ }
+
+ case 0x5: case 0xd:
+ m_setup = data;
+#if 0
+ logerror("setup timer=%s tsm=%s %s ecm=%s %s %s 3.5=%s %s\n",
+ m_setup & 0x80 ? "on" : "off",
+ m_setup & 0x40 ? "off" : "on",
+ m_setup & 0x20 ? "ibm" : "apple",
+ m_setup & 0x10 ? "on" : "off",
+ m_setup & 0x08 ? "fclk/2" : "fclk",
+ m_setup & 0x04 ? "gcr" : "mfm",
+ m_setup & 0x02 ? "off" : "on",
+ m_setup & 0x01 ? "hdsel" : "q3");
+#endif
+ logerror("setup timer=%s tsm=%s %s ecm=%s %s %s 3.5=%s %s\n",
+ m_setup & 0x80 ? "on" : "off",
+ m_setup & 0x40 ? "off" : "on",
+ m_setup & 0x20 ? "ibm" : "apple",
+ m_setup & 0x10 ? "on" : "off",
+ m_setup & 0x08 ? "fclk/2" : "fclk",
+ m_setup & 0x04 ? "gcr" : "mfm",
+ m_setup & 0x02 ? "off" : "on",
+ m_setup & 0x01 ? "hdsel" : "q3");
+ break;
+
+ case 0x6:
+ m_mode &= ~data;
+ m_mode |= 0x40;
+ m_param_idx = 0;
+ show_mode();
+ break;
+
+ case 0x7:
+ m_mode |= data;
+ show_mode();
+ break;
+
+ default:
+ logerror("write %s, %02x\n", names[offset], data);
+ break;
+ }
+}
+
+void swim1_device::sync()
+{
+}
diff --git a/src/devices/machine/swim1.h b/src/devices/machine/swim1.h
new file mode 100644
index 00000000000..7b96ef6e2e6
--- /dev/null
+++ b/src/devices/machine/swim1.h
@@ -0,0 +1,50 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Apple SWIM1 floppy disk controller
+
+*********************************************************************/
+
+#pragma once
+
+#ifndef MAME_MACHINE_SWIM1_H
+#define MAME_MACHINE_SWIM1_H
+
+#include "applefdc.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+
+class swim1_device : public applefdc_device
+{
+public:
+ // construction/destruction
+ swim1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual u8 read(offs_t offset) override;
+ virtual void write(offs_t offset, u8 data) override;
+
+ virtual void set_floppy(floppy_image_device *floppy) override;
+ virtual floppy_image_device *get_floppy() const override;
+
+ virtual void sync() override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+private:
+ floppy_image_device *m_floppy;
+ u8 m_param[4];
+ u8 m_mode, m_setup, m_param_idx;
+
+ void show_mode() const;
+};
+
+DECLARE_DEVICE_TYPE(SWIM1, swim1_device)
+
+#endif /* MAME_MACHINE_SWIM1_H */
diff --git a/src/devices/machine/swim2.cpp b/src/devices/machine/swim2.cpp
new file mode 100644
index 00000000000..19bd9176ee7
--- /dev/null
+++ b/src/devices/machine/swim2.cpp
@@ -0,0 +1,239 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Implementation of the Apple SWIM2 floppy disk controller
+
+*********************************************************************/
+
+#include "emu.h"
+#include "swim2.h"
+
+DEFINE_DEVICE_TYPE(SWIM2, swim2_device, "swim2", "Apple SWIM2 (Sander/Wozniak Integrated Machine) version 2 floppy controller")
+
+swim2_device::swim2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ applefdc_device(mconfig, SWIM2, tag, owner, clock)
+{
+}
+
+void swim2_device::device_start()
+{
+ applefdc_device::device_start();
+
+ save_item(NAME(m_mode));
+ save_item(NAME(m_setup));
+ save_item(NAME(m_param_idx));
+ save_item(NAME(m_param));
+ save_item(NAME(m_last_sync));
+}
+
+void swim2_device::device_reset()
+{
+ applefdc_device::device_reset();
+
+ m_mode = 0x40;
+ m_setup = 0x00;
+ m_param_idx = 0;
+ memset(m_param, 0, sizeof(m_param));
+ m_floppy = nullptr;
+
+ m_devsel_cb(0);
+ m_sel35_cb(true);
+ m_hdsel_cb(false);
+}
+
+void swim2_device::device_timer(emu_timer &, device_timer_id, int, void *)
+{
+}
+
+void swim2_device::set_floppy(floppy_image_device *floppy)
+{
+ if(m_floppy == floppy)
+ return;
+
+ sync();
+ flush_write();
+
+ if(m_floppy)
+ m_floppy->mon_w(true);
+ m_floppy = floppy;
+ if(m_mode & 0x80)
+ m_floppy->mon_w(false);
+ update_phases();
+}
+
+floppy_image_device *swim2_device::get_floppy() const
+{
+ return m_floppy;
+}
+
+void swim2_device::flush_write()
+{
+ if(m_floppy && m_last_sync > m_flux_write_start) {
+ if(m_flux_write_count && m_flux_write[m_flux_write_count-1] == m_last_sync)
+ m_flux_write_count--;
+ attotime start = cycles_to_time(m_flux_write_start);
+ attotime end = cycles_to_time(m_last_sync);
+ std::vector<attotime> fluxes(m_flux_write_count);
+ for(u32 i=0; i != m_flux_write_count; i++)
+ fluxes[i] = cycles_to_time(m_flux_write[i]);
+ m_floppy->write_flux(start, end, m_flux_write_count, m_flux_write_count ? &fluxes[0] : nullptr);
+ }
+ m_flux_write_count = 0;
+ m_flux_write_start = m_last_sync;
+}
+
+void swim2_device::show_mode() const
+{
+ logerror("mode%s %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 & 0x01 ? " clear" : "");
+
+}
+
+u8 swim2_device::read(offs_t offset)
+{
+ sync();
+
+ static const char *const names[] = {
+ "?0", "?1", "?2", "?3", "?4", "?5", "?6", "?7",
+ "data", "mark", "crc", "param", "phases", "setup", "status", "handshake"
+ };
+ switch(offset) {
+ case 0x3: case 0xb: {
+ u8 r = m_param[m_param_idx];
+ m_param_idx = (m_param_idx + 1) & 15;
+ return r;
+ }
+ case 0x4: case 0xc:
+ return m_phases;
+ case 0x5: case 0xd:
+ return m_setup;
+ case 0xe:
+ return m_mode;
+ default:
+ logerror("read %s\n", names[offset & 15]);
+ break;
+ }
+ return 0xff;
+}
+
+void swim2_device::write(offs_t offset, u8 data)
+{
+ sync();
+
+ static const char *const names[] = {
+ "data", "mark", "crc", "param", "phases", "setup", "mode0", "mode1",
+ "?8", "?9", "?a", "?b", "?c", "?d", "?e", "?f"
+ };
+
+ switch(offset) {
+ case 0x3: case 0xb: {
+#if 0
+ static const char *const pname[16] = {
+ "minct", "mult", "ssl", "sss", "sll", "sls", "rpt", "csls",
+ "lsl", "lss", "lll", "lls", "late", "time0", "early", "time1"
+ };
+#endif
+ static const char *const pname[4] = {
+ "late", "time0", "early", "time1"
+ };
+ logerror("param[%s] = %02x\n", pname[m_param_idx], data);
+ m_param[m_param_idx] = data;
+ m_param_idx = (m_param_idx + 1) & 3;
+ break;
+ }
+ case 0x4: {
+ m_phases = data;
+ update_phases();
+ break;
+ }
+
+ case 0x5: case 0xd:
+ m_setup = data;
+ m_sel35_cb(m_setup & 0x02);
+#if 0
+ logerror("setup timer=%s tsm=%s %s ecm=%s %s %s 3.5=%s %s\n",
+ m_setup & 0x80 ? "on" : "off",
+ m_setup & 0x40 ? "off" : "on",
+ m_setup & 0x20 ? "ibm" : "apple",
+ m_setup & 0x10 ? "on" : "off",
+ m_setup & 0x08 ? "fclk/2" : "fclk",
+ m_setup & 0x04 ? "gcr" : "mfm",
+ m_setup & 0x02 ? "off" : "on",
+ m_setup & 0x01 ? "hdsel" : "q3");
+#endif
+ logerror("setup write=%s %s test=%s %s %s 3.5=%s %s\n",
+ m_setup & 0x40 ? "gcr" : "mfm",
+ m_setup & 0x20 ? "ibm" : "apple",
+ m_setup & 0x10 ? "on" : "off",
+ m_setup & 0x08 ? "fclk/2" : "fclk",
+ m_setup & 0x04 ? "gcr" : "mfm",
+ m_setup & 0x02 ? "off" : "on",
+ m_setup & 0x01 ? "wrinvert" : "wrdirect");
+ break;
+
+ case 0x6:
+ m_mode &= ~data;
+ m_mode |= 0x40;
+ m_param_idx = 0;
+ show_mode();
+ break;
+
+ case 0x7:
+ // if(!(m_mode & 0x01) && (data & 0x01))
+ // fifo_clear();
+ m_mode |= data;
+ show_mode();
+ break;
+
+ default:
+ logerror("write %s, %02x\n", names[offset], data);
+ break;
+ }
+
+
+ if((m_mode & 0x18) == 0x18) {
+ // In write mode
+ if(!m_flux_write_start) {
+ m_flux_write_count = 0;
+ m_flux_write_start = m_last_sync;
+ logerror("write start\n");
+ }
+ } else {
+ // Not in write mode
+ if(m_flux_write_start) {
+ flush_write();
+ m_flux_write_start = 0;
+ logerror("write end\n");
+ }
+ }
+}
+
+u64 swim2_device::time_to_cycles(const attotime &tm) const
+{
+ return tm.as_ticks(clock());
+}
+
+attotime swim2_device::cycles_to_time(u64 cycles) const
+{
+ return attotime::from_ticks(cycles, clock());
+}
+
+void swim2_device::sync()
+{
+ u64 next_sync = machine().time().as_ticks(clock());
+ if(!(m_mode & 0x08)) {
+ m_last_sync = next_sync;
+ return;
+ }
+
+ logerror("ACTIVE %s %d-%d (%d)\n", m_mode & 0x10 ? "write" : "read", m_last_sync, next_sync, next_sync - m_last_sync);
+ m_last_sync = next_sync;
+}
diff --git a/src/devices/machine/swim2.h b/src/devices/machine/swim2.h
new file mode 100644
index 00000000000..b95238d040e
--- /dev/null
+++ b/src/devices/machine/swim2.h
@@ -0,0 +1,61 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Apple SWIM2 floppy disk controller
+
+*********************************************************************/
+
+#pragma once
+
+#ifndef MAME_MACHINE_SWIM2_H
+#define MAME_MACHINE_SWIM2_H
+
+#include "applefdc.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+
+class swim2_device : public applefdc_device
+{
+public:
+ // construction/destruction
+ swim2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual u8 read(offs_t offset) override;
+ virtual void write(offs_t offset, u8 data) override;
+
+ virtual void set_floppy(floppy_image_device *floppy) override;
+ virtual floppy_image_device *get_floppy() const override;
+
+ virtual void sync() override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+private:
+ floppy_image_device *m_floppy;
+ u8 m_param[4];
+ u8 m_mode, m_setup, m_param_idx, m_fifo;
+ bool m_fifo_full;
+
+ u64 m_last_sync;
+ u64 m_flux_write_start;
+ std::array<u64, 16> m_flux_write;
+ u32 m_flux_write_count;
+
+ u64 time_to_cycles(const attotime &tm) const;
+ attotime cycles_to_time(u64 cycles) const;
+
+ void fifo_clear();
+ void flush_write();
+ void show_mode() const;
+};
+
+DECLARE_DEVICE_TYPE(SWIM2, swim2_device)
+
+#endif /* MAME_MACHINE_SWIM2_H */
diff --git a/src/devices/machine/swim3.cpp b/src/devices/machine/swim3.cpp
new file mode 100644
index 00000000000..88234a7105a
--- /dev/null
+++ b/src/devices/machine/swim3.cpp
@@ -0,0 +1,176 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Implementation of the Apple SWIM3 floppy disk controller
+
+*********************************************************************/
+
+#include "emu.h"
+#include "swim3.h"
+
+DEFINE_DEVICE_TYPE(SWIM3, swim3_device, "swim3", "Apple SWIM3 (Sander/Wozniak Integrated Machine) version 3 floppy controller")
+
+swim3_device::swim3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ applefdc_device(mconfig, SWIM3, tag, owner, clock)
+{
+}
+
+void swim3_device::device_start()
+{
+ applefdc_device::device_start();
+ save_item(NAME(m_mode));
+ save_item(NAME(m_setup));
+ save_item(NAME(m_param_idx));
+ save_item(NAME(m_param));
+}
+
+void swim3_device::device_reset()
+{
+ applefdc_device::device_reset();
+ m_mode = 0x40;
+ m_setup = 0x00;
+ m_param_idx = 0;
+ memset(m_param, 0, sizeof(m_param));
+ m_floppy = nullptr;
+
+ m_devsel_cb(0);
+ m_sel35_cb(true);
+ m_hdsel_cb(false);
+}
+
+void swim3_device::device_timer(emu_timer &, device_timer_id, int, void *)
+{
+}
+
+void swim3_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();
+}
+
+floppy_image_device *swim3_device::get_floppy() const
+{
+ return m_floppy;
+}
+
+void swim3_device::show_mode() const
+{
+ logerror("mode%s %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 & 0x01 ? " clear" : "");
+
+}
+
+u8 swim3_device::read(offs_t offset)
+{
+ static const char *const names[] = {
+ "?0", "?1", "?2", "?3", "?4", "?5", "?6", "?7",
+ "data", "mark", "crc", "param", "phases", "setup", "status", "handshake"
+ };
+ switch(offset) {
+ case 0x3: case 0xb: {
+ u8 r = m_param[m_param_idx];
+ m_param_idx = (m_param_idx + 1) & 15;
+ return r;
+ }
+ case 0x4: case 0xc:
+ return m_phases;
+ case 0x5: case 0xd:
+ return m_setup;
+ case 0xe:
+ return m_mode;
+ default:
+ logerror("read %s\n", names[offset & 15]);
+ break;
+ }
+ return 0xff;
+}
+
+void swim3_device::write(offs_t offset, u8 data)
+{
+ machine().debug_break();
+ static const char *const names[] = {
+ "data", "mark", "crc", "param", "phases", "setup", "mode0", "mode1",
+ "?8", "?9", "?a", "?b", "?c", "?d", "?e", "?f"
+ };
+ switch(offset) {
+ case 0x3: case 0xb: {
+#if 0
+ static const char *const pname[16] = {
+ "minct", "mult", "ssl", "sss", "sll", "sls", "rpt", "csls",
+ "lsl", "lss", "lll", "lls", "late", "time0", "early", "time1"
+ };
+#endif
+ static const char *const pname[4] = {
+ "late", "time0", "early", "time1"
+ };
+ logerror("param[%s] = %02x\n", pname[m_param_idx], data);
+ m_param[m_param_idx] = data;
+ m_param_idx = (m_param_idx + 1) & 3;
+ break;
+ }
+ case 0x4: {
+ m_phases = data;
+ update_phases();
+ break;
+ }
+
+ case 0x5: case 0xd:
+ m_setup = data;
+#if 0
+ logerror("setup timer=%s tsm=%s %s ecm=%s %s %s 3.5=%s %s\n",
+ m_setup & 0x80 ? "on" : "off",
+ m_setup & 0x40 ? "off" : "on",
+ m_setup & 0x20 ? "ibm" : "apple",
+ m_setup & 0x10 ? "on" : "off",
+ m_setup & 0x08 ? "fclk/2" : "fclk",
+ m_setup & 0x04 ? "gcr" : "mfm",
+ m_setup & 0x02 ? "off" : "on",
+ m_setup & 0x01 ? "hdsel" : "q3");
+#endif
+ logerror("setup timer=%s tsm=%s %s ecm=%s %s %s 3.5=%s %s\n",
+ m_setup & 0x80 ? "on" : "off",
+ m_setup & 0x40 ? "off" : "on",
+ m_setup & 0x20 ? "ibm" : "apple",
+ m_setup & 0x10 ? "on" : "off",
+ m_setup & 0x08 ? "fclk/2" : "fclk",
+ m_setup & 0x04 ? "gcr" : "mfm",
+ m_setup & 0x02 ? "off" : "on",
+ m_setup & 0x01 ? "hdsel" : "q3");
+ break;
+
+ case 0x6:
+ m_mode &= ~data;
+ m_mode |= 0x40;
+ m_param_idx = 0;
+ show_mode();
+ break;
+
+ case 0x7:
+ m_mode |= data;
+ show_mode();
+ break;
+
+ default:
+ logerror("write %s, %02x\n", names[offset], data);
+ break;
+ }
+}
+
+void swim3_device::sync()
+{
+}
diff --git a/src/devices/machine/swim3.h b/src/devices/machine/swim3.h
new file mode 100644
index 00000000000..20415edfc09
--- /dev/null
+++ b/src/devices/machine/swim3.h
@@ -0,0 +1,50 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/*********************************************************************
+
+ Apple SWIM3 floppy disk controller
+
+*********************************************************************/
+
+#pragma once
+
+#ifndef MAME_MACHINE_SWIM3_H
+#define MAME_MACHINE_SWIM3_H
+
+#include "applefdc.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+
+class swim3_device : public applefdc_device
+{
+public:
+ // construction/destruction
+ swim3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual u8 read(offs_t offset) override;
+ virtual void write(offs_t offset, u8 data) override;
+
+ virtual void set_floppy(floppy_image_device *floppy) override;
+ virtual floppy_image_device *get_floppy() const override;
+
+ virtual void sync() override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+private:
+ floppy_image_device *m_floppy;
+ u8 m_param[4];
+ u8 m_mode, m_setup, m_param_idx;
+
+ void show_mode() const;
+};
+
+DECLARE_DEVICE_TYPE(SWIM3, swim3_device)
+
+#endif /* MAME_MACHINE_SWIM3_H */
diff --git a/src/devices/machine/wozfdc.cpp b/src/devices/machine/wozfdc.cpp
deleted file mode 100644
index 0c316a4c108..00000000000
--- a/src/devices/machine/wozfdc.cpp
+++ /dev/null
@@ -1,504 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/*********************************************************************
-
- wozfdc.c
-
- Implementation of the Apple Disk II floppy disk controller
-
-*********************************************************************/
-
-#include "emu.h"
-#include "wozfdc.h"
-
-#include "imagedev/floppy.h"
-#include "formats/ap2_dsk.h"
-
-/***************************************************************************
- PARAMETERS
-***************************************************************************/
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-DEFINE_DEVICE_TYPE(DISKII_FDC, diskii_fdc_device, "d2fdc", "Apple Disk II floppy controller")
-DEFINE_DEVICE_TYPE(APPLEIII_FDC, appleiii_fdc_device, "a3fdc", "Apple III floppy controller")
-
-#define DISKII_P6_REGION "diskii_rom_p6"
-
-ROM_START( diskiing )
- ROM_REGION(0x100, DISKII_P6_REGION, 0)
- ROM_LOAD( "341-0028-a.rom", 0x0000, 0x0100, CRC(b72a2c70) SHA1(bc39fbd5b9a8d2287ac5d0a42e639fc4d3c2f9d4)) /* 341-0028: 16-sector disk drive (older version), PROM P6 */
-ROM_END
-
-//-------------------------------------------------
-// rom_region - device-specific ROM region
-//-------------------------------------------------
-
-const tiny_rom_entry *wozfdc_device::device_rom_region() const
-{
- return ROM_NAME( diskiing );
-}
-
-//-------------------------------------------------
-// device_add_mconfig - add device configuration
-//-------------------------------------------------
-
-void wozfdc_device::device_add_mconfig(machine_config &config)
-{
- F9334(config, m_phaselatch); // 9334 on circuit diagram but 74LS259 in parts list; actual chip may vary
- m_phaselatch->parallel_out_cb().set(FUNC(wozfdc_device::set_phase));
-}
-
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-wozfdc_device::wozfdc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, type, tag, owner, clock),
- m_phaselatch(*this, "phaselatch")
-{
-}
-
-diskii_fdc_device::diskii_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- wozfdc_device(mconfig, DISKII_FDC, tag, owner, clock)
-{
-}
-
-appleiii_fdc_device::appleiii_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- wozfdc_device(mconfig, APPLEIII_FDC, tag, owner, clock)
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void wozfdc_device::device_start()
-{
- m_rom_p6 = machine().root_device().memregion(this->subtag(DISKII_P6_REGION).c_str())->base();
-
- timer = timer_alloc(0);
- delay_timer = timer_alloc(1);
-
- save_item(NAME(last_6502_write));
- save_item(NAME(mode_write));
- save_item(NAME(mode_load));
- save_item(NAME(active));
- save_item(NAME(external_io_select));
- save_item(NAME(cycles));
- save_item(NAME(data_reg));
- save_item(NAME(address));
- save_item(NAME(write_start_time));
- save_item(NAME(write_position));
- save_item(NAME(write_line_active));
- save_item(NAME(drvsel));
- save_item(NAME(enable1));
-}
-
-void wozfdc_device::device_reset()
-{
- floppy = nullptr;
- active = MODE_IDLE;
- mode_write = false;
- mode_load = false;
- last_6502_write = 0x00;
- cycles = time_to_cycles(machine().time());
- data_reg = 0x00;
- address = 0x00;
- write_start_time = attotime::never;
- write_position = 0;
- write_line_active = false;
- external_io_select = false;
-
- // Just a timer to be sure that the lss is updated from time to
- // time, so that there's no hiccup when it's talked to again.
- timer->adjust(attotime::from_msec(10), 0, attotime::from_msec(10));
-}
-
-void wozfdc_device::a3_update_drive_sel()
-{
- floppy_image_device *newflop = nullptr;
-
- if (!external_io_select)
- {
- newflop = floppy0->get_device();
- }
- else
- {
- switch (drvsel & 3)
- {
- case 0:
- newflop = floppy0->get_device();
- break;
-
- case 1:
- newflop = floppy1->get_device();
- break;
-
- case 2:
- newflop = floppy2->get_device();
- break;
-
- case 3:
- newflop = floppy3->get_device();
- break;
- }
- }
-
- if (floppy != newflop)
- {
- if(active) {
- lss_sync();
- floppy->mon_w(true);
- }
- floppy = newflop;
- if(active)
- floppy->mon_w(false);
- }
-}
-
-void diskii_fdc_device::device_reset()
-{
- wozfdc_device::device_reset();
- external_drive_select = false;
-
- if (floppy0 != nullptr)
- {
- floppy = floppy0->get_device();
- }
-}
-
-void appleiii_fdc_device::device_reset()
-{
- wozfdc_device::device_reset();
- external_drive_select = true;
- drvsel = 0;
- enable1 = 1;
-}
-
-void wozfdc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- if(active)
- lss_sync();
-
- if(id == 1 && active == MODE_DELAY) {
- if(floppy)
- floppy->mon_w(true);
- active = MODE_IDLE;
- }
-}
-
-/*-------------------------------------------------
- read - called to read the FDC's registers
--------------------------------------------------*/
-
-uint8_t wozfdc_device::read(offs_t offset)
-{
- lss_sync();
- control(offset);
-
- if(!(offset & 1)) {
- return data_reg;
- }
- return 0xff;
-}
-
-
-/*-------------------------------------------------
- write - called to write the FDC's registers
--------------------------------------------------*/
-
-void wozfdc_device::write(offs_t offset, uint8_t data)
-{
- lss_sync();
- control(offset);
- last_6502_write = data;
-}
-
-void wozfdc_device::set_phase(uint8_t data)
-{
- if (floppy && active)
- floppy->seek_phase_w(data);
-}
-
-void wozfdc_device::control(int offset)
-{
- if(offset < 8)
- m_phaselatch->write_bit(offset >> 1, offset & 1);
-
- else
- switch(offset) {
- case 0x8:
- if(active == MODE_ACTIVE) {
- delay_timer->adjust(attotime::from_seconds(1));
- active = MODE_DELAY;
- }
- break;
- case 0x9:
- switch(active) {
- case MODE_IDLE:
- if(floppy)
- floppy->mon_w(false);
- active = MODE_ACTIVE;
- if(floppy)
- lss_start();
- break;
- case MODE_DELAY:
- active = MODE_ACTIVE;
- delay_timer->adjust(attotime::never);
- break;
- }
- break;
- case 0xa:
- external_io_select = false;
- if(floppy != floppy0->get_device()) {
- if(active)
- floppy->mon_w(true);
- floppy = floppy0->get_device();
- if(active)
- floppy->mon_w(false);
- }
- break;
- case 0xb:
- external_io_select = true;
- if (!external_drive_select)
- {
- if (floppy != floppy1->get_device())
- {
- if(active)
- floppy->mon_w(true);
- floppy = floppy1->get_device();
- if(active)
- floppy->mon_w(false);
- }
- }
- else
- {
- a3_update_drive_sel();
- }
- break;
- case 0xc:
- if(mode_load) {
- if(active)
- address &= ~0x04;
- mode_load = false;
- }
- break;
- case 0xd:
- if(!mode_load) {
- if(active)
- address |= 0x04;
- mode_load = true;
- }
- break;
- case 0xe:
- if(mode_write) {
- if(active)
- address &= ~0x08;
- mode_write = false;
- attotime now = machine().time();
- if(floppy)
- floppy->write_flux(write_start_time, now, write_position, write_buffer);
- }
- break;
- case 0xf:
- if(!mode_write) {
- if(active) {
- address |= 0x08;
- write_start_time = machine().time();
- write_position = 0;
- if(floppy)
- floppy->set_write_splice(write_start_time);
- }
- mode_write = true;
- }
- break;
- }
-}
-
-uint64_t wozfdc_device::time_to_cycles(const attotime &tm)
-{
- // Clock is falling edges of the ~2Mhz clock
- // The 1021800 must be the controlling 6502's speed
-
- uint64_t cycles = tm.as_ticks(clock()*2);
- cycles = (cycles+1) >> 1;
- return cycles;
-}
-
-attotime wozfdc_device::cycles_to_time(uint64_t cycles)
-{
- return attotime::from_ticks(cycles*2+1, clock()*2);
-}
-
-void wozfdc_device::lss_start()
-{
- cycles = time_to_cycles(machine().time());
- data_reg = 0x00;
- address &= ~0x0e;
- write_position = 0;
- write_start_time = mode_write ? machine().time() : attotime::never;
- write_line_active = false;
- if(mode_write && floppy)
- floppy->set_write_splice(write_start_time);
-}
-
-void wozfdc_device::lss_sync()
-{
- if(!active)
- return;
-
- attotime next_flux = floppy ? floppy->get_next_transition(cycles_to_time(cycles-1)) : attotime::never;
-
- uint64_t cycles_limit = time_to_cycles(machine().time());
- uint64_t cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : uint64_t(-1);
- uint64_t cycles_next_flux_down = cycles_next_flux != uint64_t(-1) ? cycles_next_flux+1 : uint64_t(-1);
-
- if(cycles >= cycles_next_flux && cycles < cycles_next_flux_down)
- address &= ~0x10;
- else
- address |= 0x10;
-
- while(cycles < cycles_limit) {
- uint64_t cycles_next_trans = cycles_limit;
- if(cycles_next_trans > cycles_next_flux && cycles < cycles_next_flux)
- cycles_next_trans = cycles_next_flux;
- if(cycles_next_trans > cycles_next_flux_down && cycles < cycles_next_flux_down)
- cycles_next_trans = cycles_next_flux_down;
-
- while(cycles < cycles_next_trans) {
- uint8_t opcode = m_rom_p6[address];
-
- if(mode_write) {
- if((write_line_active && !(address & 0x80)) ||
- (!write_line_active && (address & 0x80))) {
- write_line_active = !write_line_active;
- assert(write_position != 32);
- write_buffer[write_position++] = cycles_to_time(cycles);
- } else if(write_position >= 30) {
- attotime now = cycles_to_time(cycles);
- if(floppy)
- floppy->write_flux(write_start_time, now, write_position, write_buffer);
- write_start_time = now;
- write_position = 0;
- }
- }
-
- address = (address & 0x1e) | (opcode & 0xc0) | ((opcode & 0x20) >> 5) | ((opcode & 0x10) << 1);
- switch(opcode & 0x0f) {
- case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
- data_reg = 0x00;
- break;
- case 0x8: case 0xc:
- break;
- case 0x9:
- data_reg <<= 1;
- break;
- case 0xa: case 0xe:
- data_reg = (data_reg >> 1) | (floppy && floppy->wpt_r() ? 0x80 : 0x00);
- break;
- case 0xb: case 0xf:
- data_reg = last_6502_write;
- break;
- case 0xd:
- data_reg = (data_reg << 1) | 0x01;
- break;
- }
- if(data_reg & 0x80)
- address |= 0x02;
- else
- address &= ~0x02;
- cycles++;
- }
-
- if(cycles == cycles_next_flux)
- address &= ~0x10;
- else if(cycles == cycles_next_flux_down) {
- address |= 0x10;
- next_flux = floppy ? floppy->get_next_transition(cycles_to_time(cycles)) : attotime::never;
- cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : uint64_t(-1);
- cycles_next_flux_down = cycles_next_flux != uint64_t(-1) ? cycles_next_flux+1 : uint64_t(-1);
- }
- }
-}
-
-// set the two images for the Disk II
-void diskii_fdc_device::set_floppies(floppy_connector *f0, floppy_connector *f1)
-{
- floppy0 = f0;
- floppy1 = f1;
-
- if (floppy0)
- {
- floppy = floppy0->get_device();
- }
-}
-
-void appleiii_fdc_device::set_floppies_4(floppy_connector *f0, floppy_connector *f1, floppy_connector *f2, floppy_connector *f3)
-{
- floppy0 = f0;
- floppy1 = f1;
- floppy2 = f2;
- floppy3 = f3;
-
- if (floppy0)
- {
- floppy = floppy0->get_device();
- }
-}
-
-uint8_t appleiii_fdc_device::read_c0dx(uint8_t offset)
-{
- control_dx(offset);
-
- return 0xff;
-}
-
-void appleiii_fdc_device::write_c0dx(uint8_t offset, uint8_t data)
-{
- control_dx(offset);
-}
-
-void appleiii_fdc_device::control_dx(int offset)
-{
- switch (offset)
- {
- case 0: // clear drive select bit 0
- drvsel &= ~1;
- break;
-
- case 1: // set drive select bit 0
- drvsel |= 1;
- break;
-
- case 2: // clear drive select bit 1
- drvsel &= ~2;
- break;
-
- case 3: // set drive select bit 1
- drvsel |= 2;
- break;
-
- case 4: // clear enable 1
- enable1 = 0;
- break;
-
- case 5: // set enable 1
- enable1 = 1;
- break;
-
- case 6: // clear side 2
- case 7: // set side 2
- break;
-
- default: // cod8-c0df are not FDC related
- break;
- }
-
- if (offset < 8)
- {
- a3_update_drive_sel();
- }
-}
diff --git a/src/devices/machine/wozfdc.h b/src/devices/machine/wozfdc.h
deleted file mode 100644
index 6c7a438be17..00000000000
--- a/src/devices/machine/wozfdc.h
+++ /dev/null
@@ -1,113 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert
-/*********************************************************************
-
- wozfdc.h
-
- Apple Disk II floppy disk controller
-
-*********************************************************************/
-
-#ifndef MAME_MACHINE_WOZFDC_H
-#define MAME_MACHINE_WOZFDC_H
-
-#pragma once
-
-#include "imagedev/floppy.h"
-#include "formats/flopimg.h"
-#include "machine/74259.h"
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-
-class wozfdc_device:
- public device_t
-{
-public:
- // optional information overrides
- virtual const tiny_rom_entry *device_rom_region() const override;
- virtual void device_add_mconfig(machine_config &config) override;
-
- uint8_t read(offs_t offset);
- void write(offs_t offset, uint8_t data);
-
-protected:
- // construction/destruction
- wozfdc_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;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
-
- void control(int offset);
- void set_phase(uint8_t data);
- uint64_t time_to_cycles(const attotime &tm);
- attotime cycles_to_time(uint64_t cycles);
- void a3_update_drive_sel();
-
- void lss_start();
- void lss_sync();
-
- enum {
- MODE_IDLE, MODE_ACTIVE, MODE_DELAY
- };
-
- floppy_connector *floppy0, *floppy1, *floppy2, *floppy3;
- floppy_image_device *floppy;
-
- required_device<addressable_latch_device> m_phaselatch;
-
- uint64_t cycles;
- uint8_t data_reg, address;
- attotime write_start_time;
- attotime write_buffer[32];
- int write_position;
- bool write_line_active;
-
- const uint8_t *m_rom_p6;
- uint8_t last_6502_write;
- bool mode_write, mode_load;
- int active;
- emu_timer *timer, *delay_timer;
- bool external_drive_select;
- bool external_io_select;
-
- int drvsel;
- int enable1;
-};
-
-class diskii_fdc_device : public wozfdc_device
-{
-public:
- diskii_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- void set_floppies(floppy_connector *f0, floppy_connector *f1);
-
-protected:
- virtual void device_reset() override;
-};
-
-class appleiii_fdc_device : public wozfdc_device
-{
-public:
- appleiii_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- void set_floppies_4(floppy_connector *f0, floppy_connector *f1, floppy_connector *f2, floppy_connector *f3);
-
- uint8_t read_c0dx(uint8_t offset);
- void write_c0dx(uint8_t offset, uint8_t data);
-
-protected:
- virtual void device_reset() override;
-
-private:
- void control_dx(int offset);
-};
-
-// device type definition
-DECLARE_DEVICE_TYPE(DISKII_FDC, diskii_fdc_device)
-DECLARE_DEVICE_TYPE(APPLEIII_FDC, appleiii_fdc_device)
-
-#endif // MAME_MACHINE_WOZFDC_H
diff --git a/src/lib/formats/mfi_dsk.cpp b/src/lib/formats/mfi_dsk.cpp
index 0f118ce620f..96376b198a0 100644
--- a/src/lib/formats/mfi_dsk.cpp
+++ b/src/lib/formats/mfi_dsk.cpp
@@ -122,6 +122,9 @@ bool mfi_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
std::vector<uint8_t> compressed;
entry *ent = entries;
+ if(!h.cyl_count)
+ return true;
+
for(unsigned int cyl=0; cyl <= (h.cyl_count - 1) << 2; cyl += 4 >> resolution)
for(unsigned int head=0; head != h.head_count; head++) {
image->set_write_splice_position(cyl >> 2, head, ent->write_splice, cyl & 3);
diff --git a/src/mame/drivers/apple2.cpp b/src/mame/drivers/apple2.cpp
index 82c48032390..3640665ce30 100644
--- a/src/mame/drivers/apple2.cpp
+++ b/src/mame/drivers/apple2.cpp
@@ -60,7 +60,6 @@ II Plus: RAM options reduced to 16/32/48 KB.
#include "bus/a2bus/a2cffa.h"
#include "bus/a2bus/a2corvus.h"
#include "bus/a2bus/a2diskii.h"
-#include "bus/a2bus/a2diskiing.h"
#include "bus/a2bus/a2dx1.h"
#include "bus/a2bus/a2echoii.h"
#include "bus/a2bus/a2mcms.h"
@@ -1270,9 +1269,8 @@ static void apple2_slot0_cards(device_slot_interface &device)
static void apple2_cards(device_slot_interface &device)
{
- device.option_add("diskii", A2BUS_DISKII); /* Disk II Controller Card */
- device.option_add("diskiing", A2BUS_DISKIING); /* Disk II Controller Card, cycle-accurate version */
- device.option_add("diskiing13", A2BUS_DISKIING13); /* Disk II Controller Card, cycle-accurate version */
+ device.option_add("diskii", A2BUS_DISKII); /* Disk II Controller Card, cycle-accurate version */
+ device.option_add("diskii13", A2BUS_DISKII13); /* Disk II Controller Card, cycle-accurate version */
device.option_add("mockingboard", A2BUS_MOCKINGBOARD); /* Sweet Micro Systems Mockingboard */
device.option_add("phasor", A2BUS_PHASOR); /* Applied Engineering Phasor */
device.option_add("cffa2", A2BUS_CFFA2); /* CFFA2000 Compact Flash for Apple II (www.dreher.net), 65C02/65816 firmware */
@@ -1393,7 +1391,7 @@ void apple2_state::apple2_common(machine_config &config)
A2BUS_SLOT(config, "sl3", m_a2bus, apple2_cards, nullptr);
A2BUS_SLOT(config, "sl4", m_a2bus, apple2_cards, "mockingboard");
A2BUS_SLOT(config, "sl5", m_a2bus, apple2_cards, nullptr);
- A2BUS_SLOT(config, "sl6", m_a2bus, apple2_cards, "diskiing");
+ A2BUS_SLOT(config, "sl6", m_a2bus, apple2_cards, "diskii");
A2BUS_SLOT(config, "sl7", m_a2bus, apple2_cards, nullptr);
/* Set up the softlists: clean cracks priority, originals second, others last */
diff --git a/src/mame/drivers/apple2e.cpp b/src/mame/drivers/apple2e.cpp
index c003c713e70..692daf4ddc1 100644
--- a/src/mame/drivers/apple2e.cpp
+++ b/src/mame/drivers/apple2e.cpp
@@ -106,19 +106,17 @@ Address bus A0-A11 is Y0-Y11
#include "cpu/z80/z80.h"
#include "imagedev/cassette.h"
#include "imagedev/flopdrv.h"
-#include "machine/appldriv.h"
#include "machine/bankdev.h"
#include "machine/kb3600.h"
#include "machine/mos6551.h"
#include "machine/ram.h"
-#include "machine/sonydriv.h"
#include "machine/timer.h"
#include "machine/ds1315.h"
#include "machine/apple2common.h"
#include "bus/a2bus/a2bus.h"
#include "bus/a2bus/a2diskii.h"
-#include "bus/a2bus/a2diskiing.h"
+#include "bus/a2bus/a2iwm.h"
#include "bus/a2bus/a2mockingboard.h"
#include "bus/a2bus/a2cffa.h"
#include "bus/a2bus/a2memexp.h"
@@ -167,9 +165,6 @@ Address bus A0-A11 is Y0-Y11
#include "softlist.h"
#include "speaker.h"
-#include "formats/ap2_dsk.h"
-#include "formats/ap_dsk35.h"
-
#define A2_CPU_TAG "maincpu"
#define A2_KBDC_TAG "ay3600"
@@ -179,8 +174,6 @@ Address bus A0-A11 is Y0-Y11
#define A2_UPPERBANK_TAG "inhbank"
#define IIC_ACIA1_TAG "acia1"
#define IIC_ACIA2_TAG "acia2"
-#define IICP_IWM_TAG "fdc"
-#define LASER128_UDC_TAG "l128udc"
#define PRINTER_PORT_TAG "printer"
#define MODEM_PORT_TAG "modem"
#define A2_AUXSLOT_TAG "auxbus"
@@ -248,9 +241,9 @@ public:
m_lcbank(*this, A2_LCBANK_TAG),
m_acia1(*this, IIC_ACIA1_TAG),
m_acia2(*this, IIC_ACIA2_TAG),
- m_laserudc(*this, LASER128_UDC_TAG),
- m_iicpiwm(*this, IICP_IWM_TAG),
- m_ds1315(*this, "nsc")
+ m_fdc(*this, "fdc"),
+ m_ds1315(*this, "nsc"),
+ m_floppy(*this, "fdc:%d", 0U)
{ }
required_device<cpu_device> m_maincpu;
@@ -284,9 +277,9 @@ public:
required_device<address_map_bank_device> m_c800bank;
required_device<address_map_bank_device> m_lcbank;
optional_device<mos6551_device> m_acia1, m_acia2;
- optional_device<applefdc_base_device> m_laserudc;
- optional_device<iwm_device> m_iicpiwm;
+ optional_device<applefdc_device> m_fdc;
required_device<ds1315_device> m_ds1315;
+ optional_device_array<floppy_connector, 4> m_floppy;
TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt);
TIMER_DEVICE_CALLBACK_MEMBER(ay3600_repeat);
@@ -403,6 +396,7 @@ public:
void spectred_keyb_map(address_map &map);
bool m_35sel, m_hdsel, m_intdrive;
+ u8 m_devsel;
private:
int m_speaker_state;
@@ -490,8 +484,47 @@ private:
void mig_w(uint16_t offset, uint8_t data);
offs_t dasm_trampoline(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer &params);
+
+ void update_devsel();
+ void phases_w(u8 data);
+ void devsel_w(u8 data);
};
+void apple2e_state::update_devsel()
+{
+ if(m_floppy[2]) {
+ if(m_35sel && (m_devsel & 1))
+ m_fdc->set_floppy(m_floppy[2]->get_device());
+ else if(m_35sel && m_devsel & 2)
+ m_fdc->set_floppy(m_floppy[3]->get_device());
+ else if(m_devsel & 1)
+ m_fdc->set_floppy(m_floppy[0]->get_device());
+ else if(m_devsel & 2)
+ m_fdc->set_floppy(m_floppy[1]->get_device());
+ else
+ m_fdc->set_floppy(nullptr);
+ } else {
+ if(m_devsel & 1)
+ m_fdc->set_floppy(m_floppy[0]->get_device());
+ else if(m_devsel & 2)
+ m_fdc->set_floppy(m_floppy[1]->get_device());
+ else
+ m_fdc->set_floppy(nullptr);
+ }
+}
+
+void apple2e_state::devsel_w(u8 data)
+{
+ m_devsel = data;
+ update_devsel();
+}
+
+void apple2e_state::phases_w(u8 data)
+{
+ auto flp = m_fdc->get_floppy();
+ if(flp)
+ flp->seek_phase_w(data);
+}
offs_t apple2e_state::dasm_trampoline(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer &params)
{
@@ -519,13 +552,11 @@ uint8_t apple2e_state::mig_r(uint16_t offset)
if ((offset >= 0x240) && (offset < 0x260))
{
m_hdsel = false;
- sony_set_sel_line(m_iicpiwm, 0);
}
if ((offset >= 0x260) && (offset < 0x280))
{
m_hdsel = true;
- sony_set_sel_line(m_iicpiwm, 0x80);
}
// reset MIG RAM window
@@ -543,7 +574,7 @@ void apple2e_state::mig_w(uint16_t offset, uint8_t data)
if (offset == 0x40)
{
- m_iicpiwm->device_reset();
+ m_fdc->reset();
return;
}
@@ -580,12 +611,14 @@ void apple2e_state::mig_w(uint16_t offset, uint8_t data)
if ((offset >= 0x240) && (offset < 0x260))
{
m_35sel = false;
+ update_devsel();
return;
}
if ((offset >= 0x260) && (offset < 0x280))
{
m_35sel = true;
+ update_devsel();
return;
}
@@ -962,6 +995,8 @@ void apple2e_state::machine_start()
void apple2e_state::machine_reset()
{
+ m_devsel = 0;
+ m_35sel = false;
m_page2 = false;
m_video->m_page2 = false;
m_video->m_monohgr = false;
@@ -2252,7 +2287,7 @@ READ8_MEMBER(apple2e_state::c080_r)
{
if ((m_isiicplus) && (slot == 6))
{
- return m_iicpiwm->read(offset % 0x10);
+ return m_fdc->read(offset % 0x10);
}
if (m_slotdevice[slot] != nullptr)
@@ -2287,7 +2322,7 @@ WRITE8_MEMBER(apple2e_state::c080_w)
{
if ((m_isiicplus) && (slot == 6))
{
- m_iicpiwm->write(offset % 0x10, data);
+ m_fdc->write(offset % 0x10, data);
return;
}
@@ -2917,7 +2952,7 @@ void apple2e_state::laser128_map(address_map &map)
// map(0xc098, 0xc09b).rw(m_acia1, FUNC(mos6551_device::read), FUNC(mos6551_device::write));
// map(0xc0a8, 0xc0ab).rw(m_acia2, FUNC(mos6551_device::read), FUNC(mos6551_device::write));
map(0xc0d0, 0xc0d3).rw(FUNC(apple2e_state::memexp_r), FUNC(apple2e_state::memexp_w));
- map(0xc0e0, 0xc0ef).rw(m_laserudc, FUNC(applefdc_base_device::read), FUNC(applefdc_base_device::write));
+ map(0xc0e0, 0xc0ef).rw(m_fdc, FUNC(applefdc_device::read), FUNC(applefdc_device::write));
map(0xc100, 0xc2ff).m(m_c100bank, FUNC(address_map_bank_device::amap8));
map(0xc300, 0xc3ff).m(m_c300bank, FUNC(address_map_bank_device::amap8));
map(0xc400, 0xc7ff).m(m_c400bank, FUNC(address_map_bank_device::amap8));
@@ -4162,9 +4197,8 @@ INPUT_PORTS_END
static void apple2_cards(device_slot_interface &device)
{
- device.option_add("diskii", A2BUS_DISKII); /* Disk II Controller Card */
- device.option_add("diskiing", A2BUS_DISKIING); /* Disk II Controller Card, cycle-accurate version */
- device.option_add("diskiing13", A2BUS_DISKIING13); /* Disk II Controller Card, cycle-accurate version */
+ device.option_add("diskii", A2BUS_DISKII); /* Disk II Controller Card, cycle-accurate version */
+ device.option_add("diskii13", A2BUS_DISKII13); /* Disk II Controller Card, cycle-accurate version */
device.option_add("mockingboard", A2BUS_MOCKINGBOARD); /* Sweet Micro Systems Mockingboard */
device.option_add("phasor", A2BUS_PHASOR); /* Applied Engineering Phasor */
device.option_add("cffa2", A2BUS_CFFA2); /* CFFA2000 Compact Flash for Apple II (www.dreher.net), 65C02/65816 firmware */
@@ -4321,7 +4355,7 @@ void apple2e_state::apple2e(machine_config &config)
A2BUS_SLOT(config, "sl3", m_a2bus, apple2_cards, nullptr);
A2BUS_SLOT(config, "sl4", m_a2bus, apple2_cards, "mockingboard");
A2BUS_SLOT(config, "sl5", m_a2bus, apple2_cards, nullptr);
- A2BUS_SLOT(config, "sl6", m_a2bus, apple2_cards, "diskiing");
+ A2BUS_SLOT(config, "sl6", m_a2bus, apple2_cards, "diskii");
A2BUS_SLOT(config, "sl7", m_a2bus, apple2_cards, nullptr);
A2EAUXSLOT(config, m_a2eauxslot, 0);
@@ -4427,7 +4461,7 @@ void apple2e_state::apple2c(machine_config &config)
// TODO: populate the IIc's other virtual slots with ONBOARD_ADD
A2BUS_MOCKINGBOARD(config, "sl4", A2BUS_7M_CLOCK).set_onboard(m_a2bus); // Mockingboard 4C
- A2BUS_DISKIING(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
+ A2BUS_DISKII(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
config.device_remove("aux");
config.device_remove(A2_AUXSLOT_TAG);
@@ -4435,108 +4469,6 @@ void apple2e_state::apple2c(machine_config &config)
m_ram->set_default_size("128K").set_extra_options("128K");
}
-static void apple2cp_set_lines(device_t *device, uint8_t lines)
-{
- apple2e_state *state = device->machine().driver_data<apple2e_state>();
-
- if (state->m_35sel)
- {
- sony_set_lines(device, lines);
- }
- else
- {
- apple525_set_lines(device, lines);
- }
-}
-
-static void apple2cp_set_enable_lines(device_t *device,int enable_mask)
-{
- apple2e_state *state = device->machine().driver_data<apple2e_state>();
-
-// printf("set_enable_lines: 35sel %d int %d enable_mask %d\n", state->m_35sel, state->m_intdrive, enable_mask);
-
- if ((state->m_35sel) && (state->m_intdrive) && (enable_mask == 2))
- {
- sony_set_enable_lines(device, 1);
- }
- else if (!state->m_35sel)
- {
- apple525_set_enable_lines(device, enable_mask);
- }
- else
- {
- sony_set_enable_lines(device, 0);
- }
-}
-
-static uint8_t apple2cp_read_data(device_t *device)
-{
- apple2e_state *state = device->machine().driver_data<apple2e_state>();
-
- if (state->m_35sel)
- {
- return sony_read_data(device);
- }
- else
- {
- return apple525_read_data(device);
- }
-
- return 0;
-}
-
-static void apple2cp_write_data(device_t *device, uint8_t data)
-{
- apple2e_state *state = device->machine().driver_data<apple2e_state>();
-
- if (state->m_35sel)
- {
- sony_write_data(device, data);
- }
- else
- {
- apple525_write_data(device, data);
- }
-}
-
-static int apple2cp_read_status(device_t *device)
-{
- apple2e_state *state = device->machine().driver_data<apple2e_state>();
-
- if (state->m_35sel)
- {
- return sony_read_status(device);
- }
- else
- {
- return apple525_read_status(device);
- }
-}
-
-const applefdc_interface a2cp_interface =
-{
- apple2cp_set_lines, /* set_lines */
- apple2cp_set_enable_lines, /* set_enable_lines */
-
- apple2cp_read_data, /* read_data */
- apple2cp_write_data, /* write_data */
- apple2cp_read_status /* read_status */
-};
-
-static const floppy_interface apple2cp_floppy35_floppy_interface =
-{
- FLOPPY_STANDARD_5_25_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple35_iigs),
- "floppy_3_5"
-};
-
-static const floppy_interface floppy_interface =
-{
- FLOPPY_STANDARD_5_25_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple2),
- "floppy_5_25"
-};
-
void apple2e_state::apple2cp(machine_config &config)
{
apple2c(config);
@@ -4546,11 +4478,14 @@ void apple2e_state::apple2cp(machine_config &config)
config.device_remove("sl4");
config.device_remove("sl6");
- IWM(config, m_iicpiwm, &a2cp_interface);
- FLOPPY_APPLE(config, FLOPPY_0, &floppy_interface, 15, 16);
- FLOPPY_APPLE(config, FLOPPY_1, &floppy_interface, 15, 16);
- FLOPPY_SONY(config, FLOPPY_2, &apple2cp_floppy35_floppy_interface);
- FLOPPY_SONY(config, FLOPPY_3, &apple2cp_floppy35_floppy_interface);
+ IWM(config, m_fdc, A2BUS_7M_CLOCK, 1021800*2);
+ m_fdc->devsel_cb().set(FUNC(apple2e_state::devsel_w));
+ m_fdc->phases_cb().set(FUNC(apple2e_state::phases_w));
+
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
+ applefdc_device::add_35(config, m_floppy[2]);
+ applefdc_device::add_35(config, m_floppy[3]);
m_ram->set_default_size("128K").set_extra_options("128K, 384K, 640K, 896K, 1152K");
}
@@ -4560,7 +4495,7 @@ void apple2e_state::apple2c_iwm(machine_config &config)
apple2c(config);
config.device_remove("sl6");
- A2BUS_IWM_FDC(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
+ A2BUS_IWM(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
}
void apple2e_state::apple2c_mem(machine_config &config)
@@ -4571,30 +4506,22 @@ void apple2e_state::apple2c_mem(machine_config &config)
m_maincpu->set_dasm_override(FUNC(apple2e_state::dasm_trampoline));
config.device_remove("sl6");
- A2BUS_IWM_FDC(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
+ A2BUS_IWM(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
m_ram->set_default_size("128K").set_extra_options("128K, 384K, 640K, 896K, 1152K");
}
-const applefdc_interface fdc_interface =
-{
- apple525_set_lines, /* set_lines */
- apple525_set_enable_lines, /* set_enable_lines */
-
- apple525_read_data, /* read_data */
- apple525_write_data, /* write_data */
- apple525_read_status /* read_status */
-};
-
void apple2e_state::laser128(machine_config &config)
{
apple2c(config);
M65C02(config.replace(), m_maincpu, 1021800);
m_maincpu->set_addrmap(AS_PROGRAM, &apple2e_state::laser128_map);
- APPLEFDC(config, m_laserudc, &fdc_interface);
- FLOPPY_APPLE(config, FLOPPY_0, &floppy_interface, 15, 16);
- FLOPPY_APPLE(config, FLOPPY_1, &floppy_interface, 15, 16);
+ DISKII(config, m_fdc, 1021800*2);
+ m_fdc->devsel_cb().set(FUNC(apple2e_state::devsel_w));
+ m_fdc->phases_cb().set(FUNC(apple2e_state::phases_w));
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
config.device_remove("sl4");
config.device_remove("sl6");
@@ -4616,9 +4543,11 @@ void apple2e_state::laser128ex2(machine_config &config)
M65C02(config.replace(), m_maincpu, 1021800);
m_maincpu->set_addrmap(AS_PROGRAM, &apple2e_state::laser128_map);
- APPLEFDC(config, m_laserudc, &fdc_interface);
- FLOPPY_APPLE(config, FLOPPY_0, &floppy_interface, 15, 16);
- FLOPPY_APPLE(config, FLOPPY_1, &floppy_interface, 15, 16);
+ DISKII(config, m_fdc, 1021800*2);
+ m_fdc->devsel_cb().set(FUNC(apple2e_state::devsel_w));
+ m_fdc->phases_cb().set(FUNC(apple2e_state::phases_w));
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
config.device_remove("sl4");
config.device_remove("sl6");
@@ -4641,7 +4570,7 @@ void apple2e_state::cec(machine_config &config)
config.device_remove("sl3");
config.device_remove("sl6");
- A2BUS_DISKIING(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
+ A2BUS_DISKII(config, "sl6", A2BUS_7M_CLOCK).set_onboard(m_a2bus);
SOFTWARE_LIST(config, "flop525_cec").set_original("cecflop");
diff --git a/src/mame/drivers/apple2gs.cpp b/src/mame/drivers/apple2gs.cpp
index 96f3550b3ef..d27f88e01c9 100644
--- a/src/mame/drivers/apple2gs.cpp
+++ b/src/mame/drivers/apple2gs.cpp
@@ -57,12 +57,7 @@
#include "machine/kb3600.h"
#include "machine/nvram.h"
-#include "machine/applefdc.h"
-#include "machine/sonydriv.h"
-#include "machine/appldriv.h"
-#include "imagedev/flopdrv.h"
-#include "formats/ap2_dsk.h"
-#include "formats/ap_dsk35.h"
+#include "machine/iwm.h"
#include "bus/rs232/rs232.h"
@@ -73,7 +68,7 @@
#include "bus/a2bus/a2bus.h"
#include "bus/a2bus/ramcard16k.h"
-#include "bus/a2bus/a2diskiing.h"
+#include "bus/a2bus/a2diskii.h"
#include "bus/a2bus/a2mockingboard.h"
#include "bus/a2bus/a2cffa.h"
#include "bus/a2bus/a2memexp.h"
@@ -125,7 +120,7 @@
#define A2GS_AUXUPPER_TAG "inhaux"
#define A2GS_00UPPER_TAG "inh00"
#define A2GS_01UPPER_TAG "inh01"
-#define A2GS_IWM_TAG "fdc" // must be "fdc" or sonydriv pukes
+#define A2GS_IWM_TAG "fdc"
#define A2GS_DOC_TAG "doc"
#define A2GS_VIDEO_TAG "a2video"
#define SCC_TAG "scc"
@@ -220,7 +215,8 @@ public:
m_ay3600(*this, "ay3600"),
m_kbdrom(*this, "keyboard"),
m_adb_mousex(*this, "adb_mouse_x"),
- m_adb_mousey(*this, "adb_mouse_y")
+ m_adb_mousey(*this, "adb_mouse_y"),
+ m_floppy(*this, "fdc:%d", 0U)
{ }
required_device<g65816_device> m_maincpu;
@@ -243,12 +239,13 @@ public:
required_device<address_map_bank_device> m_lcbank, m_lcaux, m_lc00, m_lc01, m_bank0_atc, m_bank1_atc;
required_device<z80scc_device> m_scc;
required_device<es5503_device> m_doc;
- required_device<applefdc_base_device> m_iwm;
+ required_device<iwm_device> m_iwm;
optional_ioport m_ky0, m_ky1, m_ky2, m_ky3, m_ky4, m_ky5, m_ky6, m_ky7, m_ky8, m_ky9;
required_ioport m_kbspecial;
optional_device<ay3600_device> m_ay3600;
required_memory_region m_kbdrom;
required_ioport m_adb_mousex, m_adb_mousey;
+ required_device_array<floppy_connector, 4> m_floppy;
enum glu_reg_names
{
@@ -409,11 +406,6 @@ public:
void rb4000bank_map(address_map &map);
void a2gs_es5503_map(address_map &map);
- // temp old IWM hookup
- int apple2_fdc_has_35();
- int apple2_fdc_has_525();
- void apple2_iwm_setdiskreg(uint8_t data);
-
uint8_t m_diskreg; // move into private when we can
void rom1_init() { m_is_rom3 = false; }
@@ -2547,7 +2539,7 @@ WRITE8_MEMBER(apple2gs_state::c000_w)
case 0x31: // DISKREG
m_diskreg = data;
- apple2_iwm_setdiskreg(m_diskreg);
+ // apple2_iwm_setdiskreg(m_diskreg);
break;
case 0x32: // VGCINTCLEAR
@@ -4099,165 +4091,6 @@ READ8_MEMBER(apple2gs_state::doc_adc_read)
return 0x80;
}
-// temporary hookup of old IWM
-
-int apple2gs_state::apple2_fdc_has_35()
-{
- return device_type_iterator<sonydriv_floppy_image_device>(*this).count(); // - apple525_get_count(machine)) > 0;
-}
-
-int apple2gs_state::apple2_fdc_has_525()
-{
- return 1; //apple525_get_count(machine) > 0;
-}
-
-static void apple2_fdc_set_lines(device_t *device, uint8_t lines)
-{
- apple2gs_state *state = device->machine().driver_data<apple2gs_state>();
- if (state->m_diskreg & 0x40)
- {
- if (state->apple2_fdc_has_35())
- {
- /* slot 5: 3.5" disks */
- sony_set_lines(device,lines);
- }
- }
- else
- {
- if (state->apple2_fdc_has_525())
- {
- /* slot 6: 5.25" disks */
- apple525_set_lines(device,lines);
- }
- }
-}
-
-static void apple2_fdc_set_enable_lines(device_t *device,int enable_mask)
-{
- apple2gs_state *state = device->machine().driver_data<apple2gs_state>();
- int slot5_enable_mask = 0;
- int slot6_enable_mask = 0;
-
- if (state->m_diskreg & 0x40)
- slot5_enable_mask = enable_mask;
- else
- slot6_enable_mask = enable_mask;
-
- if (state->apple2_fdc_has_35())
- {
- /* set the 3.5" enable lines */
- sony_set_enable_lines(device,slot5_enable_mask);
- }
-
- if (state->apple2_fdc_has_525())
- {
- /* set the 5.25" enable lines */
- apple525_set_enable_lines(device,slot6_enable_mask);
- }
-}
-
-static uint8_t apple2_fdc_read_data(device_t *device)
-{
- apple2gs_state *state = device->machine().driver_data<apple2gs_state>();
- uint8_t result = 0x00;
-
- if (state->m_diskreg & 0x40)
- {
- if (state->apple2_fdc_has_35())
- {
- /* slot 5: 3.5" disks */
- result = sony_read_data(device);
- }
- }
- else
- {
- if (state->apple2_fdc_has_525())
- {
- /* slot 6: 5.25" disks */
- result = apple525_read_data(device);
- }
- }
- return result;
-}
-
-static void apple2_fdc_write_data(device_t *device, uint8_t data)
-{
- apple2gs_state *state = device->machine().driver_data<apple2gs_state>();
- if (state->m_diskreg & 0x40)
- {
- if (state->apple2_fdc_has_35())
- {
- /* slot 5: 3.5" disks */
- sony_write_data(device,data);
- }
- }
- else
- {
- if (state->apple2_fdc_has_525())
- {
- /* slot 6: 5.25" disks */
- apple525_write_data(device,data);
- }
- }
-}
-
-static int apple2_fdc_read_status(device_t *device)
-{
- apple2gs_state *state = device->machine().driver_data<apple2gs_state>();
- int result = 0;
-
- if (state->m_diskreg & 0x40)
- {
- if (state->apple2_fdc_has_35())
- {
- /* slot 5: 3.5" disks */
- result = sony_read_status(device);
- }
- }
- else
- {
- if (state->apple2_fdc_has_525())
- {
- /* slot 6: 5.25" disks */
- result = apple525_read_status(device);
- }
- }
- return result;
-}
-
-void apple2gs_state::apple2_iwm_setdiskreg(uint8_t data)
-{
- if (apple2_fdc_has_35())
- {
- sony_set_sel_line(m_iwm, m_diskreg & 0x80);
- }
-}
-
-const applefdc_interface apple2_fdc_interface =
-{
- apple2_fdc_set_lines, /* set_lines */
- apple2_fdc_set_enable_lines, /* set_enable_lines */
-
- apple2_fdc_read_data, /* read_data */
- apple2_fdc_write_data, /* write_data */
- apple2_fdc_read_status /* read_status */
-};
-
-static const floppy_interface apple2gs_floppy35_floppy_interface =
-{
- FLOPPY_STANDARD_5_25_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple35_iigs),
- "floppy_3_5"
-};
-
-static const floppy_interface apple2gs_floppy525_floppy_interface =
-{
- FLOPPY_STANDARD_5_25_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple2),
- "floppy_5_25"
-};
-
-
/***************************************************************************
INPUT PORTS
***************************************************************************/
@@ -4517,7 +4350,7 @@ INPUT_PORTS_END
static void apple2_cards(device_slot_interface &device)
{
- device.option_add("diskiing", A2BUS_DISKIING); /* Disk II Controller Card, cycle-accurate version */
+ device.option_add("diskii", A2BUS_DISKII); /* Disk II Controller Card, cycle-accurate version */
device.option_add("mockingboard", A2BUS_MOCKINGBOARD); /* Sweet Micro Systems Mockingboard */
device.option_add("phasor", A2BUS_PHASOR); /* Applied Engineering Phasor */
device.option_add("cffa2", A2BUS_CFFA2); /* CFFA2000 Compact Flash for Apple II (www.dreher.net), 65C02/65816 firmware */
@@ -4739,19 +4572,16 @@ void apple2gs_state::apple2gs(machine_config &config)
A2BUS_SLOT(config, "sl6", m_a2bus, apple2_cards, nullptr);
A2BUS_SLOT(config, "sl7", m_a2bus, apple2_cards, nullptr);
- IWM(config, m_iwm, &apple2_fdc_interface);
-
- FLOPPY_APPLE(config, FLOPPY_0, &apple2gs_floppy525_floppy_interface, 15, 16);
- FLOPPY_APPLE(config, FLOPPY_1, &apple2gs_floppy525_floppy_interface, 15, 16);
-
- FLOPPY_SONY(config, FLOPPY_2, &apple2gs_floppy35_floppy_interface);
- FLOPPY_SONY(config, FLOPPY_3, &apple2gs_floppy35_floppy_interface);
+ IWM(config, m_iwm, A2GS_7M, A2GS_MASTER_CLOCK/14);
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
+ applefdc_device::add_35(config, m_floppy[2]);
+ applefdc_device::add_35(config, m_floppy[3]);
SOFTWARE_LIST(config, "flop35_list").set_original("apple2gs");
SOFTWARE_LIST(config, "flop525_clean").set_compatible("apple2_flop_clcracked"); // No filter on clean cracks yet.
- // As WOZ images won't load in the 2GS driver yet, comment out the softlist entry.
- //SOFTWARE_LIST(config, "flop525_orig").set_compatible("apple2_flop_orig").set_filter("A2GS"); // Filter list to compatible disks for this machine.
- SOFTWARE_LIST(config, "flop525_misc").set_compatible("apple2_flop_misc");
+ SOFTWARE_LIST(config, "flop525_orig").set_compatible("apple2_flop_orig").set_filter("A2GS"); // Filter list to compatible disks for this machine.
+ SOFTWARE_LIST(config, "flop525_misc").set_compatible("apple2_misc");
}
void apple2gs_state::apple2gsr1(machine_config &config)
diff --git a/src/mame/drivers/apple3.cpp b/src/mame/drivers/apple3.cpp
index f55b434478c..7d496bf1ae4 100644
--- a/src/mame/drivers/apple3.cpp
+++ b/src/mame/drivers/apple3.cpp
@@ -19,7 +19,6 @@
#include "emu.h"
#include "includes/apple3.h"
#include "sound/volt_reg.h"
-#include "formats/ap2_dsk.h"
#include "bus/a2bus/a2cffa.h"
#include "bus/a2bus/a2applicard.h"
@@ -48,15 +47,6 @@ static void apple3_cards(device_slot_interface &device)
device.option_add("focusdrive", A2BUS_FOCUSDRIVE); // Focus Drive IDE card
}
-static void a3_floppies(device_slot_interface &device)
-{
- device.option_add("525", FLOPPY_525_SD);
-}
-
-FLOPPY_FORMATS_MEMBER( apple3_state::floppy_formats )
- FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT, FLOPPY_EDD_FORMAT, FLOPPY_WOZ_FORMAT
-FLOPPY_FORMATS_END
-
void apple3_state::apple3(machine_config &config)
{
/* basic machine hardware */
@@ -109,11 +99,11 @@ void apple3_state::apple3(machine_config &config)
A2BUS_SLOT(config, "sl4", m_a2bus, apple3_cards, nullptr);
/* fdc */
- APPLEIII_FDC(config, m_fdc, 1021800*2);
- FLOPPY_CONNECTOR(config, "0", a3_floppies, "525", apple3_state::floppy_formats);
- FLOPPY_CONNECTOR(config, "1", a3_floppies, "525", apple3_state::floppy_formats);
- FLOPPY_CONNECTOR(config, "2", a3_floppies, "525", apple3_state::floppy_formats);
- FLOPPY_CONNECTOR(config, "3", a3_floppies, "525", apple3_state::floppy_formats);
+ DISKII(config, m_fdc, 1021800*2);
+ applefdc_device::add_525(config, m_floppy[0]);
+ applefdc_device::add_525(config, m_floppy[1]);
+ applefdc_device::add_525(config, m_floppy[2]);
+ applefdc_device::add_525(config, m_floppy[3]);
/* softlist for fdc */
SOFTWARE_LIST(config, "flop525_list").set_original("apple3");
diff --git a/src/mame/drivers/lisa.cpp b/src/mame/drivers/lisa.cpp
index f2158394ae1..0b092b115ca 100644
--- a/src/mame/drivers/lisa.cpp
+++ b/src/mame/drivers/lisa.cpp
@@ -13,7 +13,6 @@
#include "emu.h"
#include "includes/lisa.h"
#include "cpu/cop400/cop400.h"
-#include "formats/ap_dsk35.h"
#include "screen.h"
#include "softlist.h"
#include "speaker.h"
@@ -46,52 +45,6 @@ void lisa_state::lisa210_fdc_map(address_map &map)
map(0x1000, 0x1fff).rom().region("fdccpu", 0x1000).share("fdc_rom"); /* ROM */
}
-
-
-/***************************************************************************
- DEVICE CONFIG
-***************************************************************************/
-
-static void lisa2_set_iwm_enable_lines(device_t *device,int enable_mask)
-{
- /* E1 & E2 is connected to the Sony SEL line (?) */
- /*logerror("new sel line state %d\n", (enable_mask) ? 0 : 1);*/
- sony_set_sel_line(device,(enable_mask) ? 0 : 1);
-}
-
-static void lisa210_set_iwm_enable_lines(device_t *device,int enable_mask)
-{
- /* E2 is connected to the Sony enable line (?) */
- sony_set_enable_lines(device,enable_mask >> 1);
-}
-
-static const applefdc_interface lisa2_fdc_interface =
-{
- sony_set_lines,
- lisa2_set_iwm_enable_lines,
-
- sony_read_data,
- sony_write_data,
- sony_read_status
-};
-
-static const applefdc_interface lisa210_fdc_interface =
-{
- sony_set_lines,
- lisa210_set_iwm_enable_lines,
-
- sony_read_data,
- sony_write_data,
- sony_read_status
-};
-
-static const floppy_interface lisa_floppy_interface =
-{
- FLOPPY_STANDARD_5_25_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple35_mac),
- "floppy_5_25"
-};
-
/***************************************************************************
MACHINE DRIVER
***************************************************************************/
@@ -147,8 +100,9 @@ void lisa_state::lisa(machine_config &config)
m_nvram->set_custom_handler(FUNC(lisa_state::nvram_init));
/* devices */
- IWM(config, m_fdc, &lisa2_fdc_interface);
- sonydriv_floppy_image_device::legacy_2_drives_add(config, &lisa_floppy_interface);
+ IWM(config, m_fdc, 8000000, 1021800*2);
+ applefdc_device::add_35(config, m_floppy[0]);
+ applefdc_device::add_35(config, m_floppy[1]);
/* software lists */
SOFTWARE_LIST(config, "disk_list").set_original("lisa");
@@ -171,9 +125,6 @@ void lisa_state::lisa210(machine_config &config)
lisa(config);
m_fdc_cpu->set_addrmap(AS_PROGRAM, &lisa_state::lisa210_fdc_map);
- /* Lisa 2/10 and MacXL had a slightly different FDC interface */
- m_fdc->set_config(&lisa210_fdc_interface);
-
/* via */
m_via0->set_clock(1250000);
m_via1->set_clock(1250000);
diff --git a/src/mame/drivers/mac.cpp b/src/mame/drivers/mac.cpp
index a3944ba5d82..ef3aa01bae7 100644
--- a/src/mame/drivers/mac.cpp
+++ b/src/mame/drivers/mac.cpp
@@ -50,10 +50,10 @@
#include "cpu/m68000/m68000.h"
#include "cpu/powerpc/ppc.h"
#include "cpu/m6805/m6805.h"
-#include "machine/applefdc.h"
-#include "machine/swim.h"
-#include "machine/sonydriv.h"
-#include "formats/ap_dsk35.h"
+#include "machine/iwm.h"
+#include "machine/swim1.h"
+#include "machine/swim2.h"
+#include "machine/swim3.h"
#include "bus/scsi/scsi.h"
#include "bus/scsi/scsihd.h"
#include "bus/scsi/scsicd.h"
@@ -578,7 +578,7 @@ void mac_state::mac512ke_map(address_map &map)
{
map(0x800000, 0x9fffff).r(FUNC(mac_state::mac_scc_r));
map(0xa00000, 0xbfffff).w(FUNC(mac_state::mac_scc_w));
- map(0xc00000, 0xdfffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0xc00000, 0xdfffff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0xe80000, 0xefffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w));
map(0xfffff0, 0xffffff).rw(FUNC(mac_state::mac_autovector_r), FUNC(mac_state::mac_autovector_w));
}
@@ -588,7 +588,7 @@ void mac_state::macplus_map(address_map &map)
map(0x580000, 0x5fffff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macplus_scsi_w));
map(0x800000, 0x9fffff).r(FUNC(mac_state::mac_scc_r));
map(0xa00000, 0xbfffff).w(FUNC(mac_state::mac_scc_w));
- map(0xc00000, 0xdfffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0xc00000, 0xdfffff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0xe80000, 0xefffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w));
map(0xfffff0, 0xffffff).rw(FUNC(mac_state::mac_autovector_r), FUNC(mac_state::mac_autovector_w));
}
@@ -598,7 +598,7 @@ void mac_state::macse_map(address_map &map)
map(0x580000, 0x5fffff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macplus_scsi_w));
map(0x900000, 0x9fffff).r(FUNC(mac_state::mac_scc_r));
map(0xb00000, 0xbfffff).w(FUNC(mac_state::mac_scc_w));
- map(0xd00000, 0xdfffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0xd00000, 0xdfffff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0xe80000, 0xefffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w));
map(0xfffff0, 0xffffff).rw(FUNC(mac_state::mac_autovector_r), FUNC(mac_state::mac_autovector_w));
}
@@ -606,7 +606,7 @@ void mac_state::macse_map(address_map &map)
void mac_state::macprtb_map(address_map &map)
{
map(0x900000, 0x93ffff).rom().region("bootrom", 0).mirror(0x0c0000);
- map(0xf60000, 0xf6ffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0xf60000, 0xf6ffff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0xf70000, 0xf7ffff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w));
map(0xf90000, 0xf9ffff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macplus_scsi_w));
map(0xfa8000, 0xfaffff).ram().share("vram16"); // VRAM
@@ -628,7 +628,7 @@ void mac_state::maclc_map(address_map &map)
map(0xf10000, 0xf11fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w));
map(0xf12000, 0xf13fff).rw(FUNC(mac_state::macii_scsi_drq_r), FUNC(mac_state::macii_scsi_drq_w));
map(0xf14000, 0xf15fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write));
- map(0xf16000, 0xf17fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0xf16000, 0xf17fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0xf24000, 0xf24003).rw(FUNC(mac_state::rbv_ramdac_r), FUNC(mac_state::ariel_ramdac_w));
map(0xf26000, 0xf27fff).rw(FUNC(mac_state::mac_rbv_r), FUNC(mac_state::mac_rbv_w)); // VIA2 (V8)
map(0xf40000, 0xfbffff).ram().share("vram");
@@ -644,7 +644,7 @@ void mac_state::maclc3_map(address_map &map)
map(0x50010000, 0x50011fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w)).mirror(0x00f00000);
map(0x50012000, 0x50013fff).rw(FUNC(mac_state::macii_scsi_drq_r), FUNC(mac_state::macii_scsi_drq_w)).mirror(0x00f00000);
map(0x50014000, 0x50015fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)).mirror(0x00f00000);
- map(0x50016000, 0x50017fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x00f00000);
+ map(0x50016000, 0x50017fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00f00000);
map(0x50024000, 0x50025fff).w(FUNC(mac_state::ariel_ramdac_w)).mirror(0x00f00000);
map(0x50026000, 0x50027fff).rw(FUNC(mac_state::mac_rbv_r), FUNC(mac_state::mac_rbv_w)).mirror(0x00f00000);
map(0x50028000, 0x50028003).rw(FUNC(mac_state::mac_sonora_vctl_r), FUNC(mac_state::mac_sonora_vctl_w)).mirror(0x00f00000);
@@ -667,7 +667,7 @@ void mac_state::macii_map(address_map &map)
map(0x50010000, 0x50011fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w)).mirror(0x00f00000);
map(0x50012060, 0x50012063).r(FUNC(mac_state::macii_scsi_drq_r)).mirror(0x00f00000);
map(0x50014000, 0x50015fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)).mirror(0x00f00000);
- map(0x50016000, 0x50017fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x00f00000);
+ map(0x50016000, 0x50017fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00f00000);
map(0x50040000, 0x50041fff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w)).mirror(0x00f00000);
}
@@ -681,7 +681,7 @@ void mac_state::maciici_map(address_map &map)
map(0x50010000, 0x50011fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w)).mirror(0x00f00000);
map(0x50012060, 0x50012063).r(FUNC(mac_state::macii_scsi_drq_r)).mirror(0x00f00000);
map(0x50014000, 0x50015fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)).mirror(0x00f00000);
- map(0x50016000, 0x50017fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x00f00000);
+ map(0x50016000, 0x50017fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00f00000);
map(0x50024000, 0x50024007).w(FUNC(mac_state::rbv_ramdac_w)).mirror(0x00f00000);
map(0x50026000, 0x50027fff).rw(FUNC(mac_state::mac_rbv_r), FUNC(mac_state::mac_rbv_w)).mirror(0x00f00000);
map(0x50040000, 0x50041fff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w)).mirror(0x00f00000);
@@ -698,7 +698,7 @@ void mac_state::macse30_map(address_map &map)
map(0x50010000, 0x50011fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w)).mirror(0x00f00000);
map(0x50012060, 0x50012063).r(FUNC(mac_state::macii_scsi_drq_r)).mirror(0x00f00000);
map(0x50014000, 0x50015fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)).mirror(0x00f00000);
- map(0x50016000, 0x50017fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x00f00000);
+ map(0x50016000, 0x50017fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00f00000);
map(0x50040000, 0x50041fff).rw(FUNC(mac_state::mac_via_r), FUNC(mac_state::mac_via_w)).mirror(0x00f00000); // mirror
map(0xfe000000, 0xfe00ffff).ram().share("vram");
@@ -736,7 +736,7 @@ void mac_state::macpb140_map(address_map &map)
map(0x50010000, 0x50011fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w)).mirror(0x01f00000);
map(0x50012060, 0x50012063).r(FUNC(mac_state::macii_scsi_drq_r)).mirror(0x01f00000);
map(0x50014000, 0x50015fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)).mirror(0x01f00000);
- map(0x50016000, 0x50017fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x01f00000);
+ map(0x50016000, 0x50017fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00f00000);
map(0x50024000, 0x50027fff).r(FUNC(mac_state::buserror_r)).mirror(0x01f00000); // bus error here to make sure we aren't mistaken for another decoder
map(0xfee08000, 0xfeffffff).ram().share("vram");
@@ -753,7 +753,7 @@ void mac_state::macpb160_map(address_map &map)
map(0x50f10000, 0x50f11fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w));
map(0x50f12060, 0x50f12063).r(FUNC(mac_state::macii_scsi_drq_r));
map(0x50f14000, 0x50f15fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write));
- map(0x50f16000, 0x50f17fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0x50f16000, 0x50f17fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0x50f20000, 0x50f21fff).rw(FUNC(mac_state::mac_gsc_r), FUNC(mac_state::mac_gsc_w));
map(0x50f24000, 0x50f27fff).r(FUNC(mac_state::buserror_r)); // bus error here to make sure we aren't mistaken for another decoder
@@ -771,7 +771,7 @@ void mac_state::macpb165c_map(address_map &map)
map(0x50f10000, 0x50f11fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w));
map(0x50f12060, 0x50f12063).r(FUNC(mac_state::macii_scsi_drq_r));
map(0x50f14000, 0x50f15fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write));
- map(0x50f16000, 0x50f17fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0x50f16000, 0x50f17fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0x50f20000, 0x50f21fff).r(FUNC(mac_state::buserror_r)); // bus error here to detect we're not the grayscale 160/165/180
map(0x50f24000, 0x50f27fff).r(FUNC(mac_state::buserror_r)); // bus error here to make sure we aren't mistaken for another decoder
@@ -794,7 +794,7 @@ void mac_state::macpd210_map(address_map &map)
map(0x50f10000, 0x50f11fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w));
map(0x50f12060, 0x50f12063).r(FUNC(mac_state::macii_scsi_drq_r));
map(0x50f14000, 0x50f15fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write));
- map(0x50f16000, 0x50f17fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w));
+ map(0x50f16000, 0x50f17fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w));
map(0x50f20000, 0x50f21fff).rw(FUNC(mac_state::mac_gsc_r), FUNC(mac_state::mac_gsc_w));
map(0x50f24000, 0x50f27fff).r(FUNC(mac_state::buserror_r)); // bus error here to make sure we aren't mistaken for another decoder
@@ -815,7 +815,7 @@ void mac_state::quadra700_map(address_map &map)
map(0x5000f000, 0x5000f3ff).rw(FUNC(mac_state::mac_5396_r), FUNC(mac_state::mac_5396_w)).mirror(0x00fc0000);
map(0x5000c000, 0x5000dfff).rw(FUNC(mac_state::mac_scc_r), FUNC(mac_state::mac_scc_2_w)).mirror(0x00fc0000);
map(0x50014000, 0x50015fff).rw(m_asc, FUNC(asc_device::read), FUNC(asc_device::write)).mirror(0x00fc0000);
- map(0x5001e000, 0x5001ffff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x00fc0000);
+ map(0x5001e000, 0x5001ffff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00fc0000);
// f9800000 = VDAC / DAFB
map(0xf9000000, 0xf91fffff).ram().share("vram");
@@ -836,7 +836,7 @@ void mac_state::pwrmac_map(address_map &map)
map(0x50010000, 0x50011fff).rw(FUNC(mac_state::macplus_scsi_r), FUNC(mac_state::macii_scsi_w)).mirror(0x00f00000);
// 50014000 = sound registers (AWACS)
map(0x50014000, 0x50015fff).rw(m_awacs, FUNC(awacs_device::read), FUNC(awacs_device::write)).mirror(0x01f00000);
- map(0x50016000, 0x50017fff).rw(FUNC(mac_state::mac_iwm_r), FUNC(mac_state::mac_iwm_w)).mirror(0x00f00000);
+ map(0x50016000, 0x50017fff).rw(FUNC(mac_state::fdc_r), FUNC(mac_state::fdc_w)).mirror(0x00f00000);
map(0x50024000, 0x50025fff).w(FUNC(mac_state::ariel_ramdac_w)).mirror(0x00f00000);
map(0x50026000, 0x50027fff).rw(FUNC(mac_state::mac_via2_r), FUNC(mac_state::mac_via2_w)).mirror(0x00f00000);
map(0x50028000, 0x50028007).rw(FUNC(mac_state::mac_sonora_vctl_r), FUNC(mac_state::mac_sonora_vctl_w)).mirror(0x00f00000);
@@ -854,16 +854,6 @@ void mac_state::pwrmac_map(address_map &map)
DEVICE CONFIG
***************************************************************************/
-static const applefdc_interface mac_iwm_interface =
-{
- sony_set_lines,
- mac_fdc_set_enable_lines,
-
- sony_read_data,
- sony_write_data,
- sony_read_status
-};
-
static void mac_nubus_cards(device_slot_interface &device)
{
device.option_add("m2video", NUBUS_M2VIDEO); /* Apple Macintosh II Video Card */
@@ -907,23 +897,34 @@ static void mac_lcpds_cards(device_slot_interface &device)
MACHINE DRIVERS
***************************************************************************/
-static const floppy_interface mac_floppy_interface =
-{
- FLOPPY_STANDARD_3_5_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple35_mac),
- "floppy_3_5"
-};
-
-void mac_state::add_base_devices(machine_config &config, bool rtc, bool super_woz)
+void mac_state::add_base_devices(machine_config &config, bool rtc, int woz_version)
{
if (rtc)
- RTC3430042(config, m_rtc, XTAL(32'768));
+ RTC3430042(config, m_rtc, XTAL(32768));
- if (super_woz)
- SWIM(config, m_fdc, &mac_iwm_interface);
- else
- IWM(config, m_fdc, &mac_iwm_interface);
- sonydriv_floppy_image_device::legacy_2_drives_add(config, &mac_floppy_interface);
+ switch (woz_version) {
+ case 0:
+ IWM(config, m_fdc, C7M, 1021800*2);
+ break;
+
+ case 1:
+ SWIM1(config, m_fdc, C15M);
+ break;
+
+ case 2:
+ SWIM2(config, m_fdc, C15M);
+ break;
+
+ case 3:
+ SWIM3(config, m_fdc, C15M);
+ 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);});
+
+ applefdc_device::add_35(config, m_floppy[0]);
+ applefdc_device::add_35_nc(config, m_floppy[1]);
SCC8530(config, m_scc, C7M);
m_scc->intrq_callback().set(FUNC(mac_state::set_scc_interrupt));
@@ -1037,7 +1038,7 @@ void mac_state::add_pb1xx_vias(machine_config &config)
m_via2->irq_handler().set(FUNC(mac_state::mac_via2_irq));
}
-void mac_state::mac512ke_base(machine_config &config)
+void mac_state::mac512ke_base(machine_config &config, int woz_version)
{
M68000(config, m_maincpu, C7M); /* 7.8336 MHz */
m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::mac512ke_map);
@@ -1060,7 +1061,7 @@ void mac_state::mac512ke_base(machine_config &config)
vreg.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT);
vreg.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT);
- add_base_devices(config, true, false);
+ add_base_devices(config, true, woz_version);
VIA6522(config, m_via1, 1000000);
m_via1->readpa_handler().set(FUNC(mac_state::mac_via_in_a));
@@ -1074,9 +1075,9 @@ void mac_state::mac512ke_base(machine_config &config)
m_ram->set_default_size("512K");
}
-void mac_state::mac512ke(machine_config &config)
+void mac_state::mac512ke(machine_config &config, int woz_version)
{
- mac512ke_base(config);
+ mac512ke_base(config, woz_version);
add_mackbd(config);
}
@@ -1157,7 +1158,7 @@ void mac_state::macse(machine_config &config)
void mac_state::macclasc(machine_config &config)
{
- mac512ke_base(config);
+ mac512ke_base(config, 1);
add_macplus_additions(config);
m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::macse_map);
@@ -1186,7 +1187,7 @@ void mac_state::macprtb(machine_config &config)
MCFG_VIDEO_START_OVERRIDE(mac_state,macprtb)
/* devices */
- add_base_devices(config);
+ add_base_devices(config, true, 1);
add_scsi(config);
add_asc(config, asc_device::asc_type::ASC);
@@ -1203,7 +1204,7 @@ void mac_state::macprtb(machine_config &config)
m_ram->set_extra_options("1M,3M,5M,7M,9M");
}
-void mac_state::macii(machine_config &config, bool cpu, asc_device::asc_type asc_type, bool nubus, bool nubus_bank1, bool nubus_bank2)
+void mac_state::macii(machine_config &config, bool cpu, asc_device::asc_type asc_type, bool nubus, bool nubus_bank1, bool nubus_bank2, int woz_version)
{
if (cpu)
{
@@ -1215,7 +1216,7 @@ void mac_state::macii(machine_config &config, bool cpu, asc_device::asc_type asc
PALETTE(config, m_palette).set_entries(256);
add_asc(config, asc_type);
- add_base_devices(config);
+ add_base_devices(config, true, woz_version);
add_scsi(config, true);
if (nubus)
add_nubus(config, nubus_bank1, nubus_bank2);
@@ -1247,7 +1248,7 @@ void mac_state::maciifx(machine_config &config)
m_maincpu->set_dasm_override(FUNC(mac_state::mac_dasm_override));
add_asc(config, asc_device::asc_type::ASC);
- add_base_devices(config);
+ add_base_devices(config, true, 1);
add_scsi(config);
VIA6522(config, m_via1, C7M/10);
@@ -1267,9 +1268,9 @@ void mac_state::maciifx(machine_config &config)
add_nubus(config);
}
-void mac_state::maclc(machine_config &config, bool cpu, bool egret, asc_device::asc_type asc_type)
+void mac_state::maclc(machine_config &config, bool cpu, bool egret, asc_device::asc_type asc_type, int woz_version)
{
- macii(config, false, asc_type, false);
+ macii(config, false, asc_type, false, true, true, woz_version);
if (cpu)
{
@@ -1300,9 +1301,9 @@ void mac_state::maclc(machine_config &config, bool cpu, bool egret, asc_device::
add_egret(config, EGRET_341S0850);
}
-void mac_state::maclc2(machine_config &config, bool egret)
+void mac_state::maclc2(machine_config &config, bool egret, int woz_version)
{
- maclc(config, false, egret);
+ maclc(config, false, egret, asc_device::asc_type::V8, woz_version);
M68030(config, m_maincpu, C15M);
m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::maclc_map);
@@ -1314,14 +1315,14 @@ void mac_state::maclc2(machine_config &config, bool egret)
void mac_state::maccclas(machine_config &config)
{
- maclc2(config, false);
+ maclc2(config, false, 2);
add_cuda(config, CUDA_341S0788); // should be 0417, but that version won't sync up properly with the '030 right now
m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b_cdadb));
}
void mac_state::maclc3(machine_config &config, bool egret)
{
- maclc(config, false, false, asc_device::asc_type::SONORA);
+ maclc(config, false, false, asc_device::asc_type::SONORA, 2);
M68030(config, m_maincpu, 25000000);
m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::maclc3_map);
@@ -1410,7 +1411,7 @@ void mac_state::macse30(machine_config &config)
MCFG_VIDEO_START_OVERRIDE(mac_state,mac)
- add_base_devices(config, true, true);
+ add_base_devices(config, true, 1);
add_asc(config, asc_device::asc_type::ASC);
add_scsi(config);
@@ -1441,7 +1442,7 @@ void mac_state::macpb140(machine_config &config)
add_asc(config, asc_device::asc_type::ASC);
add_scsi(config);
- add_base_devices(config, false, true);
+ add_base_devices(config, false, 1);
add_pb1xx_vias(config);
RAM(config, m_ram);
@@ -1486,7 +1487,7 @@ void mac_state::macpb160(machine_config &config)
add_asc(config, asc_device::asc_type::ASC);
add_scsi(config);
- add_base_devices(config, false, true);
+ add_base_devices(config, false, 1);
add_pb1xx_vias(config);
RAM(config, m_ram);
@@ -1547,7 +1548,7 @@ void mac_state::macclas2(machine_config &config)
void mac_state::maciici(machine_config &config)
{
- macii(config, false, asc_device::asc_type::ASC, true, false, true);
+ macii(config, false, asc_device::asc_type::ASC, true, false, true, 1);
M68030(config, m_maincpu, 25000000);
m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::maciici_map);
@@ -1571,7 +1572,7 @@ void mac_state::maciici(machine_config &config)
void mac_state::maciisi(machine_config &config)
{
- macii(config, false, asc_device::asc_type::ASC, false);
+ macii(config, false, asc_device::asc_type::ASC, false, false, false, 1);
M68030(config, m_maincpu, 20000000);
m_maincpu->set_addrmap(AS_PROGRAM, &mac_state::maciici_map);
@@ -1621,7 +1622,7 @@ void mac_state::pwrmac(machine_config &config)
m_awacs->add_route(1, "rspeaker", 1.0);
add_scsi(config);
- add_base_devices(config, false, false);
+ add_base_devices(config, false, 3);
add_via1_adb(config, false);
m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b_cdadb));
@@ -1655,7 +1656,7 @@ void mac_state::macqd700(machine_config &config)
PALETTE(config, m_palette).set_entries(256);
add_asc(config, asc_device::asc_type::EASC);
- add_base_devices(config, true, false);
+ add_base_devices(config, true, 1);
add_nubus(config, false, false);
NUBUS_SLOT(config, "nbd", "nubus", mac_nubus_cards, nullptr);
@@ -2035,35 +2036,35 @@ ROM_END
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */
//COMP( 1983, mactw, 0, 0, mac128k, macplus, mac_state, init_mac128k512k, "Apple Computer", "Macintosh (4.3T Prototype)", MACHINE_NOT_WORKING )
-COMP( 1987, macse, 0, 0, macse, macadb, mac_state, init_macse, "Apple Computer", "Macintosh SE", MACHINE_NOT_WORKING )
-COMP( 1987, macsefd, 0, 0, macse, macadb, mac_state, init_macse, "Apple Computer", "Macintosh SE (FDHD)", MACHINE_NOT_WORKING )
-COMP( 1987, macii, 0, 0, macii, macadb, mac_state, init_macii, "Apple Computer", "Macintosh II", MACHINE_NOT_WORKING )
-COMP( 1987, maciihmu, macii, 0, maciihmu, macadb, mac_state, init_macii, "Apple Computer", "Macintosh II (w/o 68851 MMU)", MACHINE_NOT_WORKING )
-COMP( 1988, mac2fdhd, 0, 0, macii, macadb, mac_state, init_maciifdhd, "Apple Computer", "Macintosh II (FDHD)", MACHINE_NOT_WORKING )
-COMP( 1988, maciix, mac2fdhd, 0, maciix, macadb, mac_state, init_maciix, "Apple Computer", "Macintosh IIx", MACHINE_NOT_WORKING )
-COMP( 1989, macprtb, 0, 0, macprtb, macadb, mac_state, init_macprtb, "Apple Computer", "Macintosh Portable", MACHINE_NOT_WORKING )
-COMP( 1989, macse30, mac2fdhd, 0, macse30, macadb, mac_state, init_macse30, "Apple Computer", "Macintosh SE/30", MACHINE_NOT_WORKING )
-COMP( 1989, maciicx, mac2fdhd, 0, maciicx, macadb, mac_state, init_maciicx, "Apple Computer", "Macintosh IIcx", MACHINE_NOT_WORKING )
-COMP( 1989, maciici, 0, 0, maciici, maciici, mac_state, init_maciici, "Apple Computer", "Macintosh IIci", MACHINE_NOT_WORKING )
-COMP( 1990, maciifx, 0, 0, maciifx, macadb, mac_state, init_maciifx, "Apple Computer", "Macintosh IIfx", MACHINE_NOT_WORKING )
-COMP( 1990, macclasc, 0, 0, macclasc, macadb, mac_state, init_macclassic, "Apple Computer", "Macintosh Classic", MACHINE_NOT_WORKING )
-COMP( 1990, maclc, 0, 0, maclc, maciici, mac_state, init_maclc, "Apple Computer", "Macintosh LC", MACHINE_IMPERFECT_SOUND )
-COMP( 1990, maciisi, 0, 0, maciisi, maciici, mac_state, init_maciisi, "Apple Computer", "Macintosh IIsi", MACHINE_NOT_WORKING )
-COMP( 1991, macpb100, 0, 0, macprtb, macadb, mac_state, init_macprtb, "Apple Computer", "Macintosh PowerBook 100", MACHINE_NOT_WORKING )
-COMP( 1991, macpb140, 0, 0, macpb140, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 140", MACHINE_NOT_WORKING )
-COMP( 1991, macpb170, macpb140, 0, macpb170, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 170", MACHINE_NOT_WORKING )
-COMP( 1991, macqd700, macpb140, 0, macqd700, macadb, mac_state, init_macquadra700, "Apple Computer", "Macintosh Quadra 700", MACHINE_NOT_WORKING )
-COMP( 1991, macclas2, 0, 0, macclas2, macadb, mac_state, init_macclassic2, "Apple Computer", "Macintosh Classic II", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND )
-COMP( 1991, maclc2, 0, 0, maclc2, maciici, mac_state, init_maclc2, "Apple Computer", "Macintosh LC II", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND )
-COMP( 1992, macpb145, macpb140, 0, macpb145, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 145", MACHINE_NOT_WORKING )
-COMP( 1992, macpb160, 0, 0, macpb160, macadb, mac_state, init_macpb160, "Apple Computer", "Macintosh PowerBook 160", MACHINE_NOT_WORKING )
-COMP( 1992, macpb180, macpb160, 0, macpb180, macadb, mac_state, init_macpb160, "Apple Computer", "Macintosh PowerBook 180", MACHINE_NOT_WORKING )
-COMP( 1992, macpb180c, macpb160, 0, macpb180c,macadb, mac_state, init_macpb160, "Apple Computer", "Macintosh PowerBook 180c", MACHINE_NOT_WORKING )
-COMP( 1992, macpd210, 0, 0, macpd210, macadb, mac_state, init_macpd210, "Apple Computer", "Macintosh PowerBook Duo 210", MACHINE_NOT_WORKING )
-COMP( 1993, maccclas, 0, 0, maccclas, macadb, mac_state, init_maclrcclassic, "Apple Computer", "Macintosh Color Classic", MACHINE_NOT_WORKING )
-COMP( 1992, macpb145b, macpb140, 0, macpb170, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 145B", MACHINE_NOT_WORKING )
-COMP( 1993, maclc3, 0, 0, maclc3, maciici, mac_state, init_maclc3, "Apple Computer", "Macintosh LC III", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND )
-COMP( 1993, maciivx, 0, 0, maciivx, maciici, mac_state, init_maciivx, "Apple Computer", "Macintosh IIvx", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND )
-COMP( 1993, maciivi, maciivx, 0, maciivi, maciici, mac_state, init_maciivx, "Apple Computer", "Macintosh IIvi", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND )
-COMP( 1993, maclc520, 0, 0, maclc520, maciici, mac_state, init_maclc520, "Apple Computer", "Macintosh LC 520", MACHINE_NOT_WORKING )
-COMP( 1994, pmac6100, 0, 0, pwrmac, macadb, mac_state, init_macpm6100, "Apple Computer", "Power Macintosh 6100/60", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND )
+COMP( 1987, macse, 0, 0, macse, macadb, mac_state, init_macse, "Apple Computer", "Macintosh SE", MACHINE_NOT_WORKING ) // iwm/swim
+COMP( 1987, macsefd, 0, 0, macse, macadb, mac_state, init_macse, "Apple Computer", "Macintosh SE (FDHD)", MACHINE_NOT_WORKING ) // iwm/swim
+COMP( 1987, macii, 0, 0, macii, macadb, mac_state, init_macii, "Apple Computer", "Macintosh II", MACHINE_NOT_WORKING ) // iwm/swim
+COMP( 1987, maciihmu, macii, 0, maciihmu, macadb, mac_state, init_macii, "Apple Computer", "Macintosh II (w/o 68851 MMU)", MACHINE_NOT_WORKING ) // iwm/swim
+COMP( 1988, mac2fdhd, 0, 0, macii, macadb, mac_state, init_maciifdhd, "Apple Computer", "Macintosh II (FDHD)", MACHINE_NOT_WORKING ) // iwm/swim
+COMP( 1988, maciix, mac2fdhd, 0, maciix, macadb, mac_state, init_maciix, "Apple Computer", "Macintosh IIx", MACHINE_NOT_WORKING ) // swim
+COMP( 1989, macprtb, 0, 0, macprtb, macadb, mac_state, init_macprtb, "Apple Computer", "Macintosh Portable", MACHINE_NOT_WORKING ) // swim
+COMP( 1989, macse30, mac2fdhd, 0, macse30, macadb, mac_state, init_macse30, "Apple Computer", "Macintosh SE/30", MACHINE_NOT_WORKING ) // swim
+COMP( 1989, maciicx, mac2fdhd, 0, maciicx, macadb, mac_state, init_maciicx, "Apple Computer", "Macintosh IIcx", MACHINE_NOT_WORKING ) // swim
+COMP( 1989, maciici, 0, 0, maciici, maciici, mac_state, init_maciici, "Apple Computer", "Macintosh IIci", MACHINE_NOT_WORKING ) // swim
+COMP( 1990, maciifx, 0, 0, maciifx, macadb, mac_state, init_maciifx, "Apple Computer", "Macintosh IIfx", MACHINE_NOT_WORKING ) // swim + iop
+COMP( 1990, macclasc, 0, 0, macclasc, macadb, mac_state, init_macclassic, "Apple Computer", "Macintosh Classic", MACHINE_NOT_WORKING ) // swim
+COMP( 1990, maclc, 0, 0, maclc, maciici, mac_state, init_maclc, "Apple Computer", "Macintosh LC", MACHINE_IMPERFECT_SOUND ) // swim
+COMP( 1990, maciisi, 0, 0, maciisi, maciici, mac_state, init_maciisi, "Apple Computer", "Macintosh IIsi", MACHINE_NOT_WORKING ) // swim
+COMP( 1991, macpb100, 0, 0, macprtb, macadb, mac_state, init_macprtb, "Apple Computer", "Macintosh PowerBook 100", MACHINE_NOT_WORKING ) // swim
+COMP( 1991, macpb140, 0, 0, macpb140, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 140", MACHINE_NOT_WORKING ) // swim
+COMP( 1991, macpb170, macpb140, 0, macpb170, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 170", MACHINE_NOT_WORKING ) // swim
+COMP( 1991, macqd700, macpb140, 0, macqd700, macadb, mac_state, init_macquadra700, "Apple Computer", "Macintosh Quadra 700", MACHINE_NOT_WORKING ) // swim
+COMP( 1991, macclas2, 0, 0, macclas2, macadb, mac_state, init_macclassic2, "Apple Computer", "Macintosh Classic II", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND ) // swim
+COMP( 1991, maclc2, 0, 0, maclc2, maciici, mac_state, init_maclc2, "Apple Computer", "Macintosh LC II", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND ) // swim
+COMP( 1992, macpb145, macpb140, 0, macpb145, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 145", MACHINE_NOT_WORKING ) // swim
+COMP( 1992, macpb160, 0, 0, macpb160, macadb, mac_state, init_macpb160, "Apple Computer", "Macintosh PowerBook 160", MACHINE_NOT_WORKING ) // swim
+COMP( 1992, macpb180, macpb160, 0, macpb180, macadb, mac_state, init_macpb160, "Apple Computer", "Macintosh PowerBook 180", MACHINE_NOT_WORKING ) // swim
+COMP( 1992, macpb180c, macpb160, 0, macpb180c,macadb, mac_state, init_macpb160, "Apple Computer", "Macintosh PowerBook 180c", MACHINE_NOT_WORKING ) // swim
+COMP( 1992, macpd210, 0, 0, macpd210, macadb, mac_state, init_macpd210, "Apple Computer", "Macintosh PowerBook Duo 210", MACHINE_NOT_WORKING ) // swim
+COMP( 1993, maccclas, 0, 0, maccclas, macadb, mac_state, init_maclrcclassic, "Apple Computer", "Macintosh Color Classic", MACHINE_NOT_WORKING ) // swim2
+COMP( 1992, macpb145b, macpb140, 0, macpb170, macadb, mac_state, init_macpb140, "Apple Computer", "Macintosh PowerBook 145B", MACHINE_NOT_WORKING ) // swim
+COMP( 1993, maclc3, 0, 0, maclc3, maciici, mac_state, init_maclc3, "Apple Computer", "Macintosh LC III", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND ) // swim2
+COMP( 1993, maciivx, 0, 0, maciivx, maciici, mac_state, init_maciivx, "Apple Computer", "Macintosh IIvx", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND ) // swim
+COMP( 1993, maciivi, maciivx, 0, maciivi, maciici, mac_state, init_maciivx, "Apple Computer", "Macintosh IIvi", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_SOUND ) // swim
+COMP( 1993, maclc520, 0, 0, maclc520, maciici, mac_state, init_maclc520, "Apple Computer", "Macintosh LC 520", MACHINE_NOT_WORKING ) // swim2
+COMP( 1994, pmac6100, 0, 0, pwrmac, macadb, mac_state, init_macpm6100, "Apple Computer", "Power Macintosh 6100/60", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND ) // swim3
diff --git a/src/mame/drivers/mac128.cpp b/src/mame/drivers/mac128.cpp
index c6799f2f564..188c63e2d95 100644
--- a/src/mame/drivers/mac128.cpp
+++ b/src/mame/drivers/mac128.cpp
@@ -84,16 +84,13 @@ c0 8 data bits, Rx disabled
#include "machine/6522via.h"
#include "machine/z80scc.h"
#include "machine/ncr5380.h"
-#include "machine/applefdc.h"
-#include "machine/swim.h"
-#include "machine/sonydriv.h"
+#include "machine/iwm.h"
#include "machine/mackbd.h"
#include "machine/macrtc.h"
#include "machine/ram.h"
#include "machine/timer.h"
#include "sound/dac.h"
#include "sound/volt_reg.h"
-#include "formats/ap_dsk35.h"
#include "bus/scsi/scsi.h"
#include "bus/scsi/scsihd.h"
#include "bus/scsi/scsicd.h"
@@ -148,6 +145,7 @@ public:
m_ram(*this, RAM_TAG),
m_ncr5380(*this, "ncr5380"),
m_iwm(*this, "fdc"),
+ m_floppy(*this, "fdc:%d", 0U),
m_mackbd(*this, MACKBD_TAG),
m_rtc(*this,"rtc"),
m_mouse0(*this, "MOUSE0"),
@@ -173,7 +171,8 @@ private:
required_device<via6522_device> m_via;
required_device<ram_device> m_ram;
optional_device<ncr5380_device> m_ncr5380;
- required_device<applefdc_base_device> m_iwm;
+ required_device<iwm_device> m_iwm;
+ required_device_array<floppy_connector, 2> m_floppy;
optional_device<mackbd_device> m_mackbd;
optional_device<rtc3430042_device> m_rtc;
@@ -210,6 +209,9 @@ private:
void vblank_irq();
void mouse_callback();
+ void fdc_w(offs_t offset, u8 data);
+ u8 fdc_r(offs_t offset);
+
DECLARE_READ16_MEMBER ( ram_r );
DECLARE_WRITE16_MEMBER ( ram_w );
DECLARE_READ16_MEMBER ( ram_600000_r );
@@ -218,8 +220,6 @@ private:
DECLARE_WRITE16_MEMBER ( mac_via_w );
DECLARE_READ16_MEMBER ( mac_autovector_r );
DECLARE_WRITE16_MEMBER ( mac_autovector_w );
- DECLARE_READ16_MEMBER ( mac_iwm_r );
- DECLARE_WRITE16_MEMBER ( mac_iwm_w );
DECLARE_READ16_MEMBER ( macplus_scsi_r );
DECLARE_WRITE16_MEMBER ( macplus_scsi_w );
DECLARE_WRITE_LINE_MEMBER(mac_scsi_irq);
@@ -603,7 +603,7 @@ void mac128_state::scc_mouse_irq(int x, int y)
}
}
-READ16_MEMBER ( mac128_state::mac_iwm_r )
+u8 mac128_state::fdc_r(offs_t offset)
{
/* The first time this is called is in a floppy test, which goes from
* $400104 to $400126. After that, all access to the floppy goes through
@@ -615,23 +615,20 @@ READ16_MEMBER ( mac128_state::mac_iwm_r )
uint16_t result = 0;
- result = m_iwm->read(offset >> 8);
+ result = m_iwm->read(offset >> 9);
if (LOG_MAC_IWM)
- printf("mac_iwm_r: offset=0x%08x mem_mask %04x = %02x (PC %x)\n", offset, mem_mask, result, m_maincpu->pc());
+ printf("fdc_r: offset=0x%08x = %02x (PC %x)\n", offset, result, m_maincpu->pc());
- return (result << 8) | result;
+ return result;
}
-WRITE16_MEMBER ( mac128_state::mac_iwm_w )
+void mac128_state::fdc_w(offs_t offset, u8 data)
{
if (LOG_MAC_IWM)
- printf("mac_iwm_w: offset=0x%08x data=0x%04x mask %04x (PC=%x)\n", offset, data, mem_mask, m_maincpu->pc());
+ printf("fdc_w: offset=0x%08x data=0x%02x (PC=%x)\n", offset, data, m_maincpu->pc());
- if (ACCESSING_BITS_0_7)
- m_iwm->write((offset >> 8), data & 0xff);
- else
- m_iwm->write((offset >> 8), data>>8);
+ m_iwm->write((offset >> 9), data);
}
WRITE_LINE_MEMBER(mac128_state::mac_via_irq)
@@ -719,7 +716,7 @@ WRITE8_MEMBER(mac128_state::mac_via_out_a)
//set_scc_waitrequest((data & 0x80) >> 7);
m_screen_buffer = (data & 0x40) >> 6;
- sony_set_sel_line(m_iwm, (data & 0x20) >> 5);
+ // sony_set_sel_line(m_iwm, (data & 0x20) >> 5);
m_main_buffer = ((data & 0x08) == 0x08) ? true : false;
m_snd_vol = data & 0x07;
@@ -924,7 +921,7 @@ void mac128_state::mac512ke_map(address_map &map)
map(0x600000, 0x6fffff).rw(FUNC(mac128_state::ram_600000_r), FUNC(mac128_state::ram_600000_w));
map(0x800000, 0x9fffff).r(m_scc, FUNC(z80scc_device::dc_ab_r)).umask16(0xff00);
map(0xa00000, 0xbfffff).w(m_scc, FUNC(z80scc_device::dc_ab_w)).umask16(0x00ff);
- map(0xc00000, 0xdfffff).rw(FUNC(mac128_state::mac_iwm_r), FUNC(mac128_state::mac_iwm_w));
+ map(0xc00000, 0xdfffff).rw(FUNC(mac128_state::fdc_r), FUNC(mac128_state::fdc_w));
map(0xe80000, 0xefffff).rw(FUNC(mac128_state::mac_via_r), FUNC(mac128_state::mac_via_w));
map(0xfffff0, 0xffffff).rw(FUNC(mac128_state::mac_autovector_r), FUNC(mac128_state::mac_autovector_w));
}
@@ -936,36 +933,15 @@ void mac128_state::macplus_map(address_map &map)
map(0x580000, 0x5fffff).rw(FUNC(mac128_state::macplus_scsi_r), FUNC(mac128_state::macplus_scsi_w));
map(0x800000, 0x9fffff).r(m_scc, FUNC(z80scc_device::dc_ab_r)).umask16(0xff00);
map(0xa00000, 0xbfffff).w(m_scc, FUNC(z80scc_device::dc_ab_w)).umask16(0x00ff);
- map(0xc00000, 0xdfffff).rw(FUNC(mac128_state::mac_iwm_r), FUNC(mac128_state::mac_iwm_w));
+ map(0xc00000, 0xdfffff).rw(FUNC(mac128_state::fdc_r), FUNC(mac128_state::fdc_w));
map(0xe80000, 0xefffff).rw(FUNC(mac128_state::mac_via_r), FUNC(mac128_state::mac_via_w));
map(0xfffff0, 0xffffff).rw(FUNC(mac128_state::mac_autovector_r), FUNC(mac128_state::mac_autovector_w));
}
/***************************************************************************
- DEVICE CONFIG
-***************************************************************************/
-
-static const applefdc_interface mac_iwm_interface =
-{
- sony_set_lines,
- sony_set_enable_lines,
-
- sony_read_data,
- sony_write_data,
- sony_read_status
-};
-
-/***************************************************************************
MACHINE DRIVERS
***************************************************************************/
-static const floppy_interface mac_floppy_interface =
-{
- FLOPPY_STANDARD_3_5_DSHD,
- LEGACY_FLOPPY_OPTIONS_NAME(apple35_mac),
- "floppy_3_5"
-};
-
static void mac_pds_cards(device_slot_interface &device)
{
device.option_add("hyperdrive", PDS_HYPERDRIVE); // GCC HyperDrive ST-506 interface
@@ -997,8 +973,9 @@ void mac128_state::mac512ke(machine_config &config)
/* devices */
RTC3430042(config, m_rtc, 32.768_kHz_XTAL);
- IWM(config, m_iwm, 0).set_config(&mac_iwm_interface);
- sonydriv_floppy_image_device::legacy_2_drives_add(config, &mac_floppy_interface);
+ IWM(config, m_iwm, C7M, 1021800*2);
+ applefdc_device::add_35(config, m_floppy[0]);
+ applefdc_device::add_35(config, m_floppy[1]);
SCC85C30(config, m_scc, C7M);
m_scc->configure_channels(C3_7M, 0, C3_7M, 0);
diff --git a/src/mame/includes/apple3.h b/src/mame/includes/apple3.h
index 58b86f1ee3b..56964fb9fd2 100644
--- a/src/mame/includes/apple3.h
+++ b/src/mame/includes/apple3.h
@@ -22,7 +22,7 @@
#include "machine/kb3600.h"
#include "machine/mm58167.h"
#include "sound/dac.h"
-#include "machine/wozfdc.h"
+#include "machine/diskii.h"
#include "imagedev/floppy.h"
#include "formats/flopimg.h"
#include "emupal.h"
@@ -47,6 +47,7 @@ public:
m_via(*this, "via6522_%u", 0),
m_acia(*this, "acia"),
m_fdc(*this, "fdc"),
+ m_floppy(*this, "fdc:%u", 0U),
m_ay3600(*this, "ay3600"),
m_a2bus(*this, "a2bus"),
m_rtc(*this, "rtc"),
@@ -60,11 +61,7 @@ public:
m_joy2x(*this, "joy_2_x"),
m_joy2y(*this, "joy_2_y"),
m_joybuttons(*this, "joy_buttons"),
- m_pdltimer(*this, "pdltimer"),
- floppy0(*this, "0"),
- floppy1(*this, "1"),
- floppy2(*this, "2"),
- floppy3(*this, "3")
+ m_pdltimer(*this, "pdltimer")
{
}
@@ -72,7 +69,8 @@ public:
required_device<ram_device> m_ram;
required_device_array<via6522_device, 2> m_via;
required_device<mos6551_device> m_acia;
- required_device<appleiii_fdc_device> m_fdc;
+ required_device<diskii_device> m_fdc;
+ required_device_array<floppy_connector, 4> m_floppy;
required_device<ay3600_device> m_ay3600;
required_device<a2bus_device> m_a2bus;
required_device<mm58167_device> m_rtc;
@@ -83,10 +81,6 @@ public:
required_device<screen_device> m_screen;
required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons;
required_device<timer_device> m_pdltimer;
- required_device<floppy_connector> floppy0;
- required_device<floppy_connector> floppy1;
- required_device<floppy_connector> floppy2;
- required_device<floppy_connector> floppy3;
uint8_t apple3_memory_r(offs_t offset);
void apple3_memory_w(offs_t offset, uint8_t data);
diff --git a/src/mame/includes/lisa.h b/src/mame/includes/lisa.h
index c48acf1ee6e..dc829a3f23b 100644
--- a/src/mame/includes/lisa.h
+++ b/src/mame/includes/lisa.h
@@ -17,9 +17,8 @@
#include "machine/6522via.h"
#include "machine/6522via.h"
#include "machine/8530scc.h"
-#include "machine/applefdc.h"
+#include "machine/iwm.h"
#include "machine/nvram.h"
-#include "machine/sonydriv.h"
#include "sound/spkrdev.h"
#include "emupal.h"
#include "screen.h"
@@ -107,6 +106,7 @@ public:
m_via0(*this, "via6522_0"),
m_via1(*this, "via6522_1"),
m_fdc(*this, "fdc"),
+ m_floppy(*this, "fdc:%u", 0U),
m_scc(*this, "scc"),
m_speaker(*this, "speaker"),
m_nvram(*this, "nvram"),
@@ -140,7 +140,8 @@ private:
required_device<m68000_base_device> m_maincpu;
required_device<via6522_device> m_via0;
required_device<via6522_device> m_via1;
- optional_device<applefdc_base_device> m_fdc;
+ optional_device<iwm_device> m_fdc;
+ optional_device_array<floppy_connector, 2> m_floppy;
required_device<scc8530_legacy_device> m_scc;
required_device<speaker_sound_device> m_speaker;
required_device<nvram_device> m_nvram;
diff --git a/src/mame/includes/mac.h b/src/mame/includes/mac.h
index c47f84d3f8c..45c75f25095 100644
--- a/src/mame/includes/mac.h
+++ b/src/mame/includes/mac.h
@@ -29,6 +29,7 @@
#include "sound/awacs.h"
#include "sound/dac.h"
#include "cpu/m68000/m68000.h"
+#include "imagedev/floppy.h"
#include "emupal.h"
#include "screen.h"
@@ -81,6 +82,7 @@ public:
m_539x_2(*this, MAC_539X_2_TAG),
m_ncr5380(*this, "ncr5380"),
m_fdc(*this, "fdc"),
+ m_floppy(*this, "fdc:%d", 0U),
m_mackbd(*this, MACKBD_TAG),
m_rtc(*this, "rtc"),
m_mouse0(*this, "MOUSE0"),
@@ -102,7 +104,7 @@ public:
void add_mackbd(machine_config &config);
void add_scsi(machine_config &config, bool cdrom = false);
- void add_base_devices(machine_config &config, bool rtc = true, bool super_woz = false);
+ void add_base_devices(machine_config &config, bool rtc, int woz_version);
void add_asc(machine_config &config, asc_device::asc_type type = asc_device::asc_type::ASC);
void add_macplus_additions(machine_config &config);
void add_nubus(machine_config &config, bool bank1 = true, bool bank2 = true);
@@ -114,14 +116,14 @@ public:
void add_egret(machine_config &config, int type);
void add_cuda(machine_config &config, int type);
- void mac512ke_base(machine_config &config);
- void mac512ke(machine_config &config);
+ void mac512ke_base(machine_config &config, int woz_version = 0);
+ void mac512ke(machine_config &config, int woz_version = 0);
void macplus(machine_config &config);
- void maclc(machine_config &config, bool cpu = true, bool egret = true, asc_device::asc_type asc_type = asc_device::asc_type::V8);
+ void maclc(machine_config &config, bool cpu = true, bool egret = true, asc_device::asc_type asc_type = asc_device::asc_type::V8, int woz_version = 1);
void macpb170(machine_config &config);
void macclasc(machine_config &config);
void maciisi(machine_config &config);
- void maclc2(machine_config &config, bool egret = true);
+ void maclc2(machine_config &config, bool egret = true, int woz_version = 1);
void macse(machine_config &config);
void maclc3(machine_config &config, bool egret = true);
void macpd210(machine_config &config);
@@ -144,7 +146,7 @@ public:
void macpb140(machine_config &config);
void macclas2(machine_config &config);
void macii(machine_config &config, bool cpu = true, asc_device::asc_type asc_type = asc_device::asc_type::ASC,
- bool nubus = true, bool nubus_bank1 = true, bool nubus_bank2 = true);
+ bool nubus = true, bool nubus_bank1 = true, bool nubus_bank2 = true, int woz_version = 1);
void maciihmu(machine_config &config);
void init_maclc2();
@@ -263,7 +265,8 @@ private:
optional_device<ncr539x_device> m_539x_1;
optional_device<ncr539x_device> m_539x_2;
optional_device<ncr5380_device> m_ncr5380;
- required_device<applefdc_base_device> m_fdc;
+ required_device<applefdc_device> m_fdc;
+ required_device_array<floppy_connector, 2> m_floppy;
optional_device<mackbd_device> m_mackbd;
optional_device<rtc3430042_device> m_rtc;
@@ -398,14 +401,15 @@ private:
void set_adb_line(int linestate);
void update_volume();
+ void fdc_w(offs_t offset, u8 data);
+ u8 fdc_r(offs_t offset);
+
DECLARE_READ16_MEMBER ( mac_via_r );
DECLARE_WRITE16_MEMBER ( mac_via_w );
DECLARE_READ16_MEMBER ( mac_via2_r );
DECLARE_WRITE16_MEMBER ( mac_via2_w );
DECLARE_READ16_MEMBER ( mac_autovector_r );
DECLARE_WRITE16_MEMBER ( mac_autovector_w );
- DECLARE_READ16_MEMBER ( mac_iwm_r );
- DECLARE_WRITE16_MEMBER ( mac_iwm_w );
DECLARE_READ16_MEMBER ( mac_scc_r );
DECLARE_WRITE16_MEMBER ( mac_scc_w );
DECLARE_WRITE16_MEMBER ( mac_scc_2_w );
@@ -473,6 +477,7 @@ private:
DECLARE_WRITE_LINE_MEMBER(mac_scsi_irq);
DECLARE_WRITE_LINE_MEMBER(mac_asc_irq);
+ DECLARE_FLOPPY_FORMATS(floppy_formats);
void mac512ke_map(address_map &map);
void macii_map(address_map &map);
diff --git a/src/mame/machine/apple3.cpp b/src/mame/machine/apple3.cpp
index 49ebc9a5ba1..f49e8f017c0 100644
--- a/src/mame/machine/apple3.cpp
+++ b/src/mame/machine/apple3.cpp
@@ -248,7 +248,7 @@ uint8_t apple3_state::apple3_c0xx_r(offs_t offset)
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
/* external drive stuff */
- m_fdc->read_c0dx(offset&0xf);
+ // m_fdc->read_c0dx(offset&0xf);
result = 0x00;
break;
@@ -429,7 +429,7 @@ void apple3_state::apple3_c0xx_w(offs_t offset, uint8_t data)
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
/* external drive stuff */
- m_fdc->write_c0dx(offset&0xf, data);
+ // m_fdc->write_c0dx(offset&0xf, data);
break;
case 0xd8: case 0xd9:
@@ -646,8 +646,6 @@ void apple3_state::machine_reset()
m_ramp_active = false;
m_charwrt = false;
- m_fdc->set_floppies_4(floppy0, floppy1, floppy2, floppy3);
-
m_scanstart->adjust(m_screen->time_until_pos(0, 0));
m_scanend->adjust(attotime::never);
}
diff --git a/src/mame/machine/lisa.cpp b/src/mame/machine/lisa.cpp
index e4b1290c8a1..eb78e634195 100644
--- a/src/mame/machine/lisa.cpp
+++ b/src/mame/machine/lisa.cpp
@@ -995,7 +995,7 @@ void lisa_state::machine_reset()
{
if (m_features.floppy_hardware == sony_lisa2)
{
- sony_set_enable_lines(m_fdc, 1); /* on lisa2, drive unit 1 is always selected (?) */
+ // sony_set_enable_lines(m_fdc, 1); /* on lisa2, drive unit 1 is always selected (?) */
}
}
}
@@ -1125,9 +1125,9 @@ void lisa_state::lisa_fdc_ttl_glue_access(offs_t offset)
if (m_MT1 && ! oldMT1)
{
m_PWM_floppy_motor_speed = (m_PWM_floppy_motor_speed << 1) & 0xff;
- if (m_fdc->get_lines() & APPLEFDC_PH0)
- m_PWM_floppy_motor_speed |= 1;
- sony_set_speed(((256-m_PWM_floppy_motor_speed) * 1.3) + 237);
+ // if (m_fdc->get_lines() & APPLEFDC_PH0)
+ // m_PWM_floppy_motor_speed |= 1;
+ // sony_set_speed(((256-m_PWM_floppy_motor_speed) * 1.3) + 237);
}
}
/*else
@@ -1143,8 +1143,8 @@ void lisa_state::lisa_fdc_ttl_glue_access(offs_t offset)
twiggy_set_head_line(offset & 1);
else
#endif
- if (m_features.floppy_hardware == sony_lisa210)
- sony_set_sel_line(m_fdc, offset & 1);
+ // if (m_features.floppy_hardware == sony_lisa210)
+ // sony_set_sel_line(m_fdc, offset & 1);
break;
case 6:
m_DISK_DIAG = offset & 1;
@@ -1204,8 +1204,8 @@ WRITE8_MEMBER(lisa_state::lisa_fdc_io_w)
twiggy_set_speed((256-data) * 1.3 /* ??? */ + 237 /* ??? */);
else
#endif
- if (m_features.floppy_hardware == sony_lisa210)
- sony_set_speed(((256-data) * 1.3) + 237);
+ // if (m_features.floppy_hardware == sony_lisa210)
+ // sony_set_speed(((256-data) * 1.3) + 237);
break;
case 3: /* not used */
diff --git a/src/mame/machine/mac.cpp b/src/mame/machine/mac.cpp
index ab59e67cccf..2793780d383 100644
--- a/src/mame/machine/mac.cpp
+++ b/src/mame/machine/mac.cpp
@@ -92,7 +92,6 @@
#include "emu.h"
#include "includes/mac.h"
-#include "machine/sonydriv.h"
#define AUDIO_IS_CLASSIC (m_model <= MODEL_MAC_CLASSIC)
#define MAC_HAS_VIA2 ((m_model >= MODEL_MAC_II) && (m_model != MODEL_MAC_IIFX))
@@ -131,17 +130,17 @@ void mac_fdc_set_enable_lines(device_t *device, int enable_mask)
if (mac->m_model != mac_state::MODEL_MAC_SE)
{
- sony_set_enable_lines(device, enable_mask);
+ // sony_set_enable_lines(device, enable_mask);
}
else
{
if (enable_mask)
{
- sony_set_enable_lines(device, mac->m_drive_select ? 1 : 2);
+ // sony_set_enable_lines(device, mac->m_drive_select ? 1 : 2);
}
else
{
- sony_set_enable_lines(device, enable_mask);
+ // sony_set_enable_lines(device, enable_mask);
}
}
}
@@ -1185,37 +1184,14 @@ WRITE16_MEMBER ( mac_state::mac_scc_2_w )
m_scc->reg_w(offset, data >> 8);
}
-/* ********************************** *
- * IWM Code specific to the Mac Plus *
- * ********************************** */
-
-READ16_MEMBER ( mac_state::mac_iwm_r )
+void mac_state::fdc_w(offs_t offset, u8 data)
{
- /* The first time this is called is in a floppy test, which goes from
- * $400104 to $400126. After that, all access to the floppy goes through
- * the disk driver in the MacOS
- *
- * I just thought this would be on interest to someone trying to further
- * this driver along
- */
-
- uint16_t result = m_fdc->read(offset >> 8);
-
- if (LOG_MAC_IWM)
- printf("%s mac_iwm_r: offset=0x%08x mem_mask %04x = %02x\n", machine().describe_context().c_str(), offset, mem_mask, result);
-
- return (result << 8) | result;
+ m_fdc->write((offset >> 9) & 0xf, data);
}
-WRITE16_MEMBER ( mac_state::mac_iwm_w )
+u8 mac_state::fdc_r(offs_t offset)
{
- if (LOG_MAC_IWM)
- printf("mac_iwm_w: offset=0x%08x data=0x%04x mask %04x (PC=%x)\n", offset, data, mem_mask, m_maincpu->pc());
-
- if (ACCESSING_BITS_0_7)
- m_fdc->write((offset >> 8), data & 0xff);
- else
- m_fdc->write((offset >> 8), data>>8);
+ return m_fdc->read((offset >> 9) & 0xf);
}
WRITE_LINE_MEMBER(mac_state::mac_adb_via_out_cb2)
@@ -1448,7 +1424,7 @@ WRITE8_MEMBER(mac_state::mac_via_out_a)
set_scc_waitrequest((data & 0x80) >> 7);
m_screen_buffer = (data & 0x40) >> 6;
- sony_set_sel_line(m_fdc.target(), (data & 0x20) >> 5);
+ // sony_set_sel_line(m_fdc.target(), (data & 0x20) >> 5);
if (m_model == MODEL_MAC_SE) // on SE this selects which floppy drive (0 = upper, 1 = lower)
{
m_drive_select = ((data & 0x10) >> 4);
@@ -1586,7 +1562,7 @@ WRITE8_MEMBER(mac_state::mac_via_out_b_pmu)
{
// printf("%s VIA1 OUT B: %02x\n", machine().describe_context().c_str(), data);
- sony_set_sel_line(m_fdc.target(), (data & 0x20) >> 5);
+// sony_set_sel_line(m_fdc.target(), (data & 0x20) >> 5);
m_drive_select = ((data & 0x10) >> 4);
if ((data & 1) && !(m_pm_req & 1))
diff --git a/src/mame/machine/macpci.cpp b/src/mame/machine/macpci.cpp
index cbc31a32dd2..f5e298ee1cc 100644
--- a/src/mame/machine/macpci.cpp
+++ b/src/mame/machine/macpci.cpp
@@ -13,8 +13,6 @@
#include "emu.h"
#include "machine/8530scc.h"
#include "cpu/m68000/m68000.h"
-#include "machine/applefdc.h"
-#include "machine/sonydriv.h"
#include "includes/macpci.h"
#include "machine/ram.h"
#include "debugger.h"
diff --git a/src/mame/machine/swim.cpp b/src/mame/machine/swim.cpp
deleted file mode 100644
index bc3a4277799..00000000000
--- a/src/mame/machine/swim.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- swim.c
-
- Implementation of the Apple SWIM FDC controller; used on (less)
- early Macs
-
-*********************************************************************/
-
-#include "emu.h"
-#include "machine/swim.h"
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define LOG_SWIM 0
-
-enum
-{
- SWIM_MODE_IWM,
- SWIM_MODE_SWIM,
- SWIM_MODE_SWIM2,
- SWIM_MODE_SWIM3
-};
-
-
-/***************************************************************************
- DEVICE
-***************************************************************************/
-
-DEFINE_DEVICE_TYPE(SWIM, swim_device, "swim", "Apple SWIM (Steve Woz Integrated Machine)")
-
-//-------------------------------------------------
-// ctor
-//-------------------------------------------------
-
-swim_device::swim_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : applefdc_base_device(APPLEFDC_SWIM, mconfig, SWIM, tag, owner, clock)
-{
-}
-
-
-
-//-------------------------------------------------
-// device_start - device-specific start
-//-------------------------------------------------
-
-void swim_device::device_start()
-{
- // call inherited version
- applefdc_base_device::device_start();
-
- m_swim_mode = SWIM_MODE_IWM;
- m_swim_magic_state = 0x00;
- m_parm_offset = 0x00;
- memset(m_ism_regs, 0, sizeof(m_ism_regs));
- memset(m_parms, 0, sizeof(m_parms));
-}
-
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void swim_device::device_reset()
-{
- // call inherited version
- applefdc_base_device::device_reset();
-
- static uint8_t swim_default_parms[16] =
- {
- 0x38, 0x18, 0x41, 0x2e, 0x2e, 0x18, 0x18, 0x1b,
- 0x1b, 0x2f, 0x2f, 0x19, 0x19, 0x97, 0x1b, 0x57
- };
-
- for (int i = 0; i < 16; i++)
- {
- m_parms[i] = swim_default_parms[i];
- }
-
- m_swim_magic_state = 0;
- m_swim_mode = SWIM_MODE_IWM;
- m_parm_offset = 0;
-}
-
-
-
-//-------------------------------------------------
-// read - reads a byte from the FDC
-//-------------------------------------------------
-
-uint8_t swim_device::read(offs_t offset)
-{
- uint8_t result = 0;
-
- if (m_swim_mode == SWIM_MODE_IWM)
- {
- // IWM mode
- result = applefdc_base_device::read(offset);
- }
- else if (m_swim_mode >= SWIM_MODE_SWIM)
- {
- // reading parameter RAM?
- if ((offset & 7) == 3)
- {
- result = m_parms[m_parm_offset++];
- m_parm_offset &= 0xf;
- }
- else
- {
- result = m_ism_regs[offset&7];
- }
-
- if (LOG_SWIM)
- logerror("SWIM: read %02x from offset %x\n", result, offset & 7);
- }
- return result;
-}
-
-
-
-//-------------------------------------------------
-// write - write a byte to the FDC
-//-------------------------------------------------
-
-void swim_device::write(offs_t offset, uint8_t data)
-{
- if (m_swim_mode == SWIM_MODE_IWM)
- {
- // IWM mode
- applefdc_base_device::write(offset, data);
- }
- else if (m_swim_mode >= SWIM_MODE_SWIM)
- {
- if (LOG_SWIM)
- logerror("SWIM: write %02x to offset %x\n", data, offset & 7);
-
- switch (offset & 7)
- {
- case 2: // write CRC
- break;
-
- case 3: // write parameter
- m_parms[m_parm_offset++] = data;
- m_parm_offset &= 0xf;
- break;
-
- case 6: // write zeros to status (also zeroes parameter RAM pointer)
- m_ism_regs[6] &= ~data;
- m_parm_offset = 0;
-
- if (data == 0xf8) // magic "revert to IWM" value
- {
- if (LOG_SWIM)
- logerror("SWIM: reverting to IWM\n");
- m_swim_mode = SWIM_MODE_IWM;
- }
- break;
-
- case 7: // write ones to status
- m_ism_regs[6] |= data;
- break;
-
- default:
- m_ism_regs[offset & 7] = data;
- break;
-
- }
- }
-}
-
-
-
-//-------------------------------------------------
-// iwm_modereg_w - changes the mode register
-//-------------------------------------------------
-
-void swim_device::iwm_modereg_w(uint8_t data)
-{
- // SWIM mode is unlocked by writing 1/0/1/1 in a row to bit 6 (which is unused on IWM)
- // when SWIM mode engages, the IWM is disconnected from both the 68k and the drives,
- // and the ISM is substituted.
-
- switch (m_swim_magic_state)
- {
- case 0:
- case 2:
- case 3:
- if (data & 0x40)
- {
- m_swim_magic_state++;
- }
- else
- {
- m_swim_magic_state = 0;
- }
- break;
- case 1:
- if (!(data & 0x40))
- {
- m_swim_magic_state++;
- }
- else
- {
- m_swim_magic_state = 0;
- }
- break;
- }
-
- if (m_swim_magic_state == 4)
- {
- m_swim_magic_state = 0;
- m_swim_mode = SWIM_MODE_SWIM;
- }
-
- // call inherited version
- applefdc_base_device::iwm_modereg_w(data);
-}
diff --git a/src/mame/machine/swim.h b/src/mame/machine/swim.h
deleted file mode 100644
index f7d86130ad1..00000000000
--- a/src/mame/machine/swim.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:R. Belmont
-/*********************************************************************
-
- swim.h
-
- Implementation of the Apple SWIM FDC controller; used on (less)
- early Macs
-
-*********************************************************************/
-
-#ifndef MAME_MACHINE_SWIM_H
-#define MAME_MACHINE_SWIM_H
-
-#include "machine/applefdc.h"
-
-
-/***************************************************************************
- DEVICE
-***************************************************************************/
-
-DECLARE_DEVICE_TYPE(SWIM, swim_device)
-
-class swim_device : public applefdc_base_device
-{
-public:
- swim_device(const machine_config &mconfig, const char *tag, device_t *owner, const applefdc_interface *intrf)
- : swim_device(mconfig, tag, owner, (uint32_t)0)
- {
- set_config(intrf);
- }
-
- swim_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- // read/write
- virtual uint8_t read(offs_t offset) override;
- virtual void write(offs_t offset, uint8_t data) override;
-
-protected:
- // device-level overrides
- virtual void device_start() override;
- virtual void device_reset() override;
-
- // other overrides
- virtual void iwm_modereg_w(uint8_t data) override;
-
-private:
- uint8_t m_swim_mode;
- uint8_t m_swim_magic_state;
- uint8_t m_parm_offset;
- uint8_t m_ism_regs[8];
- uint8_t m_parms[16];
-};
-
-#endif // MAME_MACHINE_SWIM_H