mirror of
https://github.com/holub/mame
synced 2025-06-04 11:56:28 +03:00
spectrum.cpp: add Didaktik D40/D80 disk interface
This commit is contained in:
parent
036927b005
commit
5c3f020bf8
@ -3738,6 +3738,8 @@ if (BUSES["SPECTRUM"]~=null) then
|
||||
MAME_DIR .. "src/devices/bus/spectrum/beta.h",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/beta128.cpp",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/beta128.h",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/d40.cpp",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/d40.h",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/intf1.cpp",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/intf1.h",
|
||||
MAME_DIR .. "src/devices/bus/spectrum/intf2.cpp",
|
||||
|
@ -617,6 +617,18 @@ if (FORMATS["D71_DSK"]~=null or _OPTIONS["with-tools"]) then
|
||||
}
|
||||
end
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
--@src/lib/formats/d40_dsk.h,FORMATS["D40_DSK"] = true
|
||||
--------------------------------------------------
|
||||
|
||||
if (FORMATS["D40_DSK"]~=null or _OPTIONS["with-tools"]) then
|
||||
files {
|
||||
MAME_DIR.. "src/lib/formats/d40_dsk.cpp",
|
||||
MAME_DIR.. "src/lib/formats/d40_dsk.h",
|
||||
}
|
||||
end
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
--@src/lib/formats/d80_dsk.h,FORMATS["D80_DSK"] = true
|
||||
|
@ -1,5 +1,5 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Nigel Barnes, David Haywood
|
||||
// copyright-holders:Nigel Barnes, David Haywood, MetalliC
|
||||
/*********************************************************************
|
||||
|
||||
Technology Research Beta Disk interface & clones
|
||||
|
279
src/devices/bus/spectrum/d40.cpp
Normal file
279
src/devices/bus/spectrum/d40.cpp
Normal file
@ -0,0 +1,279 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:MetalliC
|
||||
/**********************************************************************
|
||||
|
||||
Didaktik D40/D80 disk interface
|
||||
(C) 1991 Didaktik Scalica
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#include "emu.h"
|
||||
#include "d40.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(SPECTRUM_D40, spectrum_d40_device, "spectrum_d40", "Didaktik D40 disk interface")
|
||||
DEFINE_DEVICE_TYPE(SPECTRUM_D80, spectrum_d80_device, "spectrum_d80", "Didaktik D80 disk interface")
|
||||
|
||||
//-------------------------------------------------
|
||||
// INPUT_PORTS
|
||||
//-------------------------------------------------
|
||||
|
||||
INPUT_PORTS_START(d40)
|
||||
PORT_START("BUTTON")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Snapshot Button") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHANGED_MEMBER(DEVICE_SELF, spectrum_d40_device, snapshot_button, 0)
|
||||
INPUT_PORTS_END
|
||||
|
||||
//-------------------------------------------------
|
||||
// input_ports - device-specific input ports
|
||||
//-------------------------------------------------
|
||||
|
||||
ioport_constructor spectrum_d40_device::device_input_ports() const
|
||||
{
|
||||
return INPUT_PORTS_NAME(d40);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// SLOT_INTERFACE( floppies )
|
||||
//-------------------------------------------------
|
||||
|
||||
static void didaktik_floppies(device_slot_interface &device)
|
||||
{
|
||||
device.option_add("35dd", FLOPPY_35_DD);
|
||||
device.option_add("525dd", FLOPPY_525_DD);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// floppy_format_type floppy_formats
|
||||
//-------------------------------------------------
|
||||
|
||||
FLOPPY_FORMATS_MEMBER(spectrum_d40_device::floppy_formats)
|
||||
FLOPPY_D40D80_FORMAT
|
||||
FLOPPY_FORMATS_END
|
||||
|
||||
//-------------------------------------------------
|
||||
// ROM
|
||||
//-------------------------------------------------
|
||||
|
||||
ROM_START(d40)
|
||||
ROM_REGION(0x4000, "rom", 0)
|
||||
ROM_DEFAULT_BIOS("mdos11")
|
||||
ROM_SYSTEM_BIOS(0, "mdos11", "MDOS 1.0 (1991)")
|
||||
ROMX_LOAD("mdos10.bin", 0x0000, 0x4000, CRC(e6b70939) SHA1(308c4b5daf6bb1f05c68a447129d723da423326e), ROM_BIOS(0))
|
||||
ROM_SYSTEM_BIOS(1, "mdos12", "MDOS 1.0+ (1992)")
|
||||
ROMX_LOAD("mdos10p.bin", 0x0000, 0x4000, CRC(92c45741) SHA1(b8473235feecff4eccbace56a90cf1d8c79506eb), ROM_BIOS(1))
|
||||
ROM_SYSTEM_BIOS(2, "mdos2", "MDOS 2.0 (1993)") // doesn't work, from different board type with GM82C765B FDC
|
||||
ROMX_LOAD("mdos20.bin", 0x0000, 0x4000, CRC(9e79d022) SHA1(e8d3355051fb287dd0dda34ba8824442130c8254), ROM_BIOS(2))
|
||||
ROM_END
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_add_mconfig - add device configuration
|
||||
//-------------------------------------------------
|
||||
|
||||
void spectrum_d40_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
WD2797(config, m_fdc, 4_MHz_XTAL / 4);
|
||||
m_fdc->intrq_wr_callback().set(FUNC(spectrum_d40_device::fdc_intrq_w));
|
||||
m_fdc->drq_wr_callback().set(FUNC(spectrum_d40_device::fdc_drq_w));
|
||||
FLOPPY_CONNECTOR(config, "fdc:0", didaktik_floppies, "525dd", spectrum_d40_device::floppy_formats).enable_sound(true);
|
||||
FLOPPY_CONNECTOR(config, "fdc:1", didaktik_floppies, "525dd", spectrum_d40_device::floppy_formats).enable_sound(true);
|
||||
|
||||
/* software list */
|
||||
//SOFTWARE_LIST(config, "flop_list").set_original("spectrum_d40_flop");
|
||||
}
|
||||
|
||||
void spectrum_d80_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
WD2797(config, m_fdc, 4_MHz_XTAL / 4);
|
||||
m_fdc->intrq_wr_callback().set(FUNC(spectrum_d80_device::fdc_intrq_w));
|
||||
m_fdc->drq_wr_callback().set(FUNC(spectrum_d80_device::fdc_drq_w));
|
||||
FLOPPY_CONNECTOR(config, "fdc:0", didaktik_floppies, "35dd", spectrum_d80_device::floppy_formats).enable_sound(true);
|
||||
FLOPPY_CONNECTOR(config, "fdc:1", didaktik_floppies, "35dd", spectrum_d80_device::floppy_formats).enable_sound(true);
|
||||
|
||||
/* software list */
|
||||
//SOFTWARE_LIST(config, "flop_list").set_original("spectrum_d40_flop");
|
||||
}
|
||||
|
||||
const tiny_rom_entry *spectrum_d40_device::device_rom_region() const
|
||||
{
|
||||
return ROM_NAME(d40);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// spectrum_d40_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
spectrum_d40_device::spectrum_d40_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_spectrum_expansion_interface(mconfig, *this)
|
||||
, m_rom(*this, "rom")
|
||||
, m_fdc(*this, "fdc")
|
||||
, m_floppy(*this, "fdc:%u", 0)
|
||||
{
|
||||
}
|
||||
|
||||
spectrum_d40_device::spectrum_d40_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: spectrum_d40_device(mconfig, SPECTRUM_D40, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
spectrum_d80_device::spectrum_d80_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: spectrum_d40_device(mconfig, SPECTRUM_D80, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void spectrum_d40_device::device_start()
|
||||
{
|
||||
std::fill(std::begin(m_ram), std::end(m_ram), 0);
|
||||
save_item(NAME(m_romcs));
|
||||
save_item(NAME(m_ram));
|
||||
save_item(NAME(m_control));
|
||||
save_item(NAME(m_snap_flag));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void spectrum_d40_device::device_reset()
|
||||
{
|
||||
m_romcs = 0;
|
||||
m_control = 0;
|
||||
m_snap_flag = 0;
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// IMPLEMENTATION spectrum_d40_device
|
||||
//**************************************************************************
|
||||
|
||||
READ_LINE_MEMBER(spectrum_d40_device::romcs)
|
||||
{
|
||||
return m_romcs;
|
||||
}
|
||||
|
||||
void spectrum_d40_device::pre_opcode_fetch(offs_t offset)
|
||||
{
|
||||
if (!machine().side_effects_disabled())
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0x0000:
|
||||
case 0x0008:
|
||||
m_romcs = 1;
|
||||
break;
|
||||
case 0x0066:
|
||||
if (!m_romcs)
|
||||
{
|
||||
m_romcs = 1;
|
||||
m_snap_flag = 1;
|
||||
}
|
||||
break;
|
||||
case 0x1700:
|
||||
m_romcs = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t spectrum_d40_device::iorq_r(offs_t offset)
|
||||
{
|
||||
uint8_t data = 0xff;
|
||||
|
||||
switch (offset & 0xf9)
|
||||
{
|
||||
case 0x81: // FDC
|
||||
data = m_fdc->read((offset >> 1) & 0x03);
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void spectrum_d40_device::iorq_w(offs_t offset, uint8_t data)
|
||||
{
|
||||
switch (offset & 0xf9)
|
||||
{
|
||||
case 0x81: // FDC
|
||||
m_fdc->write((offset >> 1) & 0x03, data);
|
||||
break;
|
||||
case 0x89: // control port
|
||||
{
|
||||
m_control = data;
|
||||
|
||||
floppy_image_device* floppy = nullptr;
|
||||
if (BIT(data, 0))
|
||||
floppy = m_floppy[0]->get_device();
|
||||
else if (BIT(data, 1))
|
||||
floppy = m_floppy[1]->get_device();
|
||||
m_fdc->set_floppy(floppy);
|
||||
|
||||
m_floppy[0]->get_device()->mon_w(BIT(data, 2) ? 0 : 1);
|
||||
m_floppy[1]->get_device()->mon_w(BIT(data, 3) ? 0 : 1);
|
||||
}
|
||||
break;
|
||||
case 0x91: // PPI reset
|
||||
// TODO PPI
|
||||
break;
|
||||
case 0x99: // PPI enable
|
||||
// TODO PPI
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t spectrum_d40_device::mreq_r(offs_t offset)
|
||||
{
|
||||
if (m_snap_flag && offset == 0x66)
|
||||
{
|
||||
m_snap_flag = 0;
|
||||
return 0xc7;
|
||||
}
|
||||
|
||||
uint8_t data = 0xff;
|
||||
|
||||
if (m_romcs)
|
||||
{
|
||||
if (offset < 0x3800)
|
||||
data = m_rom->base()[offset];
|
||||
else
|
||||
data = m_ram[offset & 0x7ff];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void spectrum_d40_device::mreq_w(offs_t offset, uint8_t data)
|
||||
{
|
||||
if (m_romcs)
|
||||
{
|
||||
if ((offset & 0xf800) == 0x3800)
|
||||
m_ram[offset & 0x7ff] = data;
|
||||
}
|
||||
}
|
||||
|
||||
INPUT_CHANGED_MEMBER(spectrum_d40_device::snapshot_button)
|
||||
{
|
||||
m_slot->nmi_w((!newval && oldval && !m_romcs) ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
void spectrum_d40_device::fdc_intrq_w(int state)
|
||||
{
|
||||
m_slot->nmi_w((state && BIT(m_control, 7)) ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
void spectrum_d40_device::fdc_drq_w(int state)
|
||||
{
|
||||
m_slot->nmi_w((state && BIT(m_control, 6)) ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
79
src/devices/bus/spectrum/d40.h
Normal file
79
src/devices/bus/spectrum/d40.h
Normal file
@ -0,0 +1,79 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:MetalliC
|
||||
/**********************************************************************
|
||||
|
||||
Didaktik D40/D80 interface
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef MAME_BUS_SPECTRUM_D40_H
|
||||
#define MAME_BUS_SPECTRUM_D40_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "exp.h"
|
||||
//#include "softlist.h"
|
||||
#include "imagedev/floppy.h"
|
||||
#include "machine/wd_fdc.h"
|
||||
#include "formats/d40_dsk.h"
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
class spectrum_d40_device: public device_t, public device_spectrum_expansion_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
spectrum_d40_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
DECLARE_FLOPPY_FORMATS(floppy_formats);
|
||||
DECLARE_INPUT_CHANGED_MEMBER(snapshot_button);
|
||||
|
||||
protected:
|
||||
spectrum_d40_device(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_reset() override;
|
||||
|
||||
// optional information overrides
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
virtual ioport_constructor device_input_ports() const override;
|
||||
virtual const tiny_rom_entry *device_rom_region() const override;
|
||||
|
||||
virtual void pre_opcode_fetch(offs_t offset) override;
|
||||
virtual uint8_t mreq_r(offs_t offset) override;
|
||||
virtual void mreq_w(offs_t offset, uint8_t data) override;
|
||||
virtual uint8_t iorq_r(offs_t offset) override;
|
||||
virtual void iorq_w(offs_t offset, uint8_t data) override;
|
||||
virtual DECLARE_READ_LINE_MEMBER(romcs) override;
|
||||
|
||||
void fdc_intrq_w(int state);
|
||||
void fdc_drq_w(int state);
|
||||
|
||||
required_memory_region m_rom;
|
||||
required_device<wd_fdc_device_base> m_fdc;
|
||||
required_device_array<floppy_connector, 2> m_floppy;
|
||||
|
||||
int m_romcs;
|
||||
uint8_t m_ram[2 * 1024];
|
||||
uint8_t m_control;
|
||||
int m_snap_flag;
|
||||
};
|
||||
|
||||
class spectrum_d80_device :
|
||||
public spectrum_d40_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
spectrum_d80_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
protected:
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(SPECTRUM_D40, spectrum_d40_device)
|
||||
DECLARE_DEVICE_TYPE(SPECTRUM_D80, spectrum_d80_device)
|
||||
|
||||
#endif // MAME_BUS_SPECTRUM_D40_H
|
@ -156,6 +156,7 @@ void spectrum_expansion_slot_device::mreq_w(offs_t offset, uint8_t data)
|
||||
// slot devices
|
||||
#include "beta.h"
|
||||
#include "beta128.h"
|
||||
#include "d40.h"
|
||||
#include "intf1.h"
|
||||
#include "intf2.h"
|
||||
#include "fuller.h"
|
||||
@ -194,6 +195,8 @@ void spectrum_expansion_devices(device_slot_interface &device)
|
||||
device.option_add("mprint", SPECTRUM_MPRINT);
|
||||
device.option_add("opus", SPECTRUM_OPUS);
|
||||
device.option_add("plusd", SPECTRUM_PLUSD);
|
||||
device.option_add("d40", SPECTRUM_D40);
|
||||
device.option_add("d80", SPECTRUM_D80);
|
||||
device.option_add("protek", SPECTRUM_PROTEK);
|
||||
device.option_add("specdrum", SPECTRUM_SPECDRUM);
|
||||
device.option_add("uslot", SPECTRUM_USLOT);
|
||||
@ -213,6 +216,8 @@ void spec128_expansion_devices(device_slot_interface &device)
|
||||
device.option_add("mikroplus", SPECTRUM_MIKROPLUS);
|
||||
device.option_add("mprint", SPECTRUM_MPRINT);
|
||||
device.option_add("opus", SPECTRUM_OPUS);
|
||||
//device.option_add("d40", SPECTRUM_D40);
|
||||
//device.option_add("d80", SPECTRUM_D80);
|
||||
//device.option_add("plusd", SPECTRUM_PLUSD);
|
||||
device.option_add("plus2test", SPECTRUM_PLUS2TEST);
|
||||
device.option_add("protek", SPECTRUM_PROTEK);
|
||||
|
46
src/lib/formats/d40_dsk.cpp
Normal file
46
src/lib/formats/d40_dsk.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:MetalliC
|
||||
/*********************************************************************
|
||||
|
||||
formats/d40_dsk.c
|
||||
|
||||
Didaktik D40/D80 disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "formats/d40_dsk.h"
|
||||
|
||||
d40_format::d40_format() : wd177x_format(formats)
|
||||
{
|
||||
}
|
||||
|
||||
const char *d40_format::name() const
|
||||
{
|
||||
return "d40";
|
||||
}
|
||||
|
||||
const char *d40_format::description() const
|
||||
{
|
||||
return "Didaktik D40/D80 floppy disk image";
|
||||
}
|
||||
|
||||
const char *d40_format::extensions() const
|
||||
{
|
||||
return "d40,d80";
|
||||
}
|
||||
|
||||
const d40_format::format d40_format::formats[] = {
|
||||
{ // 400K 5"25 double density, gaps unverified
|
||||
floppy_image::FF_525, floppy_image::DSDD, floppy_image::MFM,
|
||||
2000, 10, 40, 2, 512, {}, 1, {}, 50, 22, 36
|
||||
},
|
||||
{ // 720K 3'5 double density, gaps unverified
|
||||
floppy_image::FF_35, floppy_image::DSDD, floppy_image::MFM,
|
||||
2000, 9, 80, 2, 512, {}, 1, {}, 50, 22, 80
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
const floppy_format_type FLOPPY_D40D80_FORMAT = &floppy_image_format_creator<d40_format>;
|
31
src/lib/formats/d40_dsk.h
Normal file
31
src/lib/formats/d40_dsk.h
Normal file
@ -0,0 +1,31 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:MetalliC
|
||||
/*********************************************************************
|
||||
|
||||
formats/d40_dsk.h
|
||||
|
||||
Didaktik D40/D80 disk images
|
||||
|
||||
*********************************************************************/
|
||||
#ifndef MAME_FORMATS_D40_DSK_H
|
||||
#define MAME_FORMATS_D40_DSK_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wd177x_dsk.h"
|
||||
|
||||
class d40_format : public wd177x_format {
|
||||
public:
|
||||
d40_format();
|
||||
|
||||
virtual const char *name() const override;
|
||||
virtual const char *description() const override;
|
||||
virtual const char *extensions() const override;
|
||||
|
||||
private:
|
||||
static const format formats[];
|
||||
};
|
||||
|
||||
extern const floppy_format_type FLOPPY_D40D80_FORMAT;
|
||||
|
||||
#endif // MAME_FORMATS_D40_DSK_H
|
Loading…
Reference in New Issue
Block a user