samcoupe: Add support for the S D IDE Adapter

This commit is contained in:
Dirk Best 2020-07-20 11:39:56 +02:00
parent d55e7a32a8
commit f5ded52474
4 changed files with 169 additions and 0 deletions

View File

@ -4320,6 +4320,8 @@ if (BUSES["SAMCOUPE_EXPANSION"]~=null) then
MAME_DIR .. "src/devices/bus/samcoupe/expansion/onemeg.h",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/sambus.cpp",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/sambus.h",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/sdide.cpp",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/sdide.h",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/sid.cpp",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/sid.h",
MAME_DIR .. "src/devices/bus/samcoupe/expansion/spi.cpp",

View File

@ -13,6 +13,7 @@
#include "dallas.h"
#include "onemeg.h"
#include "sambus.h"
#include "sdide.h"
#include "sid.h"
#include "spi.h"
#include "voicebox.h"
@ -23,6 +24,7 @@ void samcoupe_expansion_modules(device_slot_interface &device)
device.option_add("dallas", SAM_DALLAS_CLOCK);
device.option_add("onemeg", SAM_ONEMEG);
device.option_add("sambus", SAM_SAMBUS);
device.option_add("sdide", SAM_SDIDE);
device.option_add("sid6581", SAM_SID6581);
device.option_add("sid8580", SAM_SID8580);
device.option_add("spi", SAM_SPI);

View File

@ -0,0 +1,116 @@
// license: GPL-2.0+
// copyright-holders: Dirk Best
/***************************************************************************
S D IDE Adapter for SAM Coupe
***************************************************************************/
#include "emu.h"
#include "sdide.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(SAM_SDIDE, sam_sdide_device, "sam_sdide", "S D IDE Adapter")
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void sam_sdide_device::device_add_mconfig(machine_config &config)
{
ATA_INTERFACE(config, m_ata).options(ata_devices, "hdd", nullptr, false);
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// sam_sdide_device - constructor
//-------------------------------------------------
sam_sdide_device::sam_sdide_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, SAM_SDIDE, tag, owner, clock),
device_samcoupe_expansion_interface(mconfig, *this),
m_ata(*this, "ata"),
m_address_latch(0),
m_data_latch(0),
m_data_pending(false)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sam_sdide_device::device_start()
{
// register for savestates
save_item(NAME(m_address_latch));
save_item(NAME(m_data_latch));
save_item(NAME(m_data_pending));
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
uint8_t sam_sdide_device::iorq_r(offs_t offset)
{
uint8_t data = 0xff;
switch (offset & 0xff)
{
case 0xbd: // data
if (m_data_pending)
data = m_data_latch;
else
{
uint16_t result = 0;
if (BIT(m_address_latch, 3) == 0)
result = m_ata->cs0_r(m_address_latch & 0x07);
if (BIT(m_address_latch, 4) == 0)
result = m_ata->cs1_r(m_address_latch & 0x07);
m_data_latch = result >> 8;
data = result;
}
m_data_pending = !m_data_pending;
break;
}
return data;
}
void sam_sdide_device::iorq_w(offs_t offset, uint8_t data)
{
switch (offset & 0xff)
{
case 0xbd: // data
if (!m_data_pending)
m_data_latch = data;
else
{
if (BIT(m_address_latch, 3) == 0)
m_ata->cs0_w(m_address_latch & 0x07, (data << 8) | m_data_latch);
if (BIT(m_address_latch, 4) == 0)
m_ata->cs1_w(m_address_latch & 0x07, (data << 8) | m_data_latch);
}
m_data_pending = !m_data_pending;
break;
case 0xbf: // register select
m_address_latch = data;
m_data_pending = false;
break;
}
}

View File

@ -0,0 +1,49 @@
// license: GPL-2.0+
// copyright-holders: Dirk Best
/***************************************************************************
S D IDE Adapter for SAM Coupe
***************************************************************************/
#ifndef MAME_BUS_SAMCOUPE_EXPANSION_SDIDE_H
#define MAME_BUS_SAMCOUPE_EXPANSION_SDIDE_H
#pragma once
#include "expansion.h"
#include "bus/ata/ataintf.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> sam_sdide_device
class sam_sdide_device : public device_t, public device_samcoupe_expansion_interface
{
public:
// construction/destruction
sam_sdide_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// from host
virtual uint8_t iorq_r(offs_t offset) override;
virtual void iorq_w(offs_t offset, uint8_t data) override;
protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
private:
required_device<ata_interface_device> m_ata;
uint8_t m_address_latch;
uint8_t m_data_latch;
bool m_data_pending;
};
// device type definition
DECLARE_DEVICE_TYPE(SAM_SDIDE, sam_sdide_device)
#endif // MAME_BUS_SAMCOUPE_EXPANSION_SDIDE_H