pccard_sram: Add support for the Mitsubishi Melcard SRAM card with 1 MB RAM as an example for a card without attribute memory.

Change input ports from DIP to configuration switches.
This commit is contained in:
Dirk Best 2023-03-10 17:19:26 +01:00
parent 3a11560726
commit 4ca6a1b3e9
3 changed files with 112 additions and 11 deletions

View File

@ -21,6 +21,10 @@
// DEVICE DEFINITIONS
//**************************************************************************
// devices without attribute memory
DEFINE_DEVICE_TYPE(PCCARD_SRAM_MITSUBISHI_1M, pccard_mitsubishi_mf31m1_lycat01_device, "mitsubishi_mf31m1_lycat01", "Mitsubishi Melcard 1 MB SRAM")
// devices with attribute memory
DEFINE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_1M, pccard_centennial_sl01m_15_11194_device, "centennial_sl01m_15_11194", "Centennial 1 MB SRAM")
DEFINE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_2M, pccard_centennial_sl02m_15_11194_device, "centennial_sl02m_15_11194", "Centennial 2 MB SRAM")
DEFINE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_4M, pccard_centennial_sl04m_15_11194_device, "centennial_sl04m_15_11194", "Centennial 4 MB SRAM")
@ -31,15 +35,15 @@ DEFINE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_4M, pccard_centennial_sl04m_15_11194_d
static INPUT_PORTS_START( card )
PORT_START("switches")
PORT_DIPNAME(0x01, 0x00, "Battery Failed") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pccard_sram_device, battery_voltage_1_w)
PORT_DIPSETTING( 0x01, DEF_STR(Yes))
PORT_DIPSETTING( 0x00, DEF_STR(No))
PORT_DIPNAME(0x02, 0x00, "Battery Low") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pccard_sram_device, battery_voltage_2_w)
PORT_DIPSETTING( 0x02, DEF_STR(Yes))
PORT_DIPSETTING( 0x00, DEF_STR(No))
PORT_DIPNAME(0x04, 0x04, "Write Protect") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pccard_sram_device, write_protect_w)
PORT_DIPSETTING( 0x04, DEF_STR(No))
PORT_DIPSETTING( 0x00, DEF_STR(Yes))
PORT_CONFNAME(0x01, 0x00, "Battery Failed") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pccard_sram_device, battery_voltage_1_w)
PORT_CONFSETTING( 0x01, DEF_STR(Yes))
PORT_CONFSETTING( 0x00, DEF_STR(No))
PORT_CONFNAME(0x02, 0x00, "Battery Low") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pccard_sram_device, battery_voltage_2_w)
PORT_CONFSETTING( 0x02, DEF_STR(Yes))
PORT_CONFSETTING( 0x00, DEF_STR(No))
PORT_CONFNAME(0x04, 0x04, "Write Protect") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pccard_sram_device, write_protect_w)
PORT_CONFSETTING( 0x04, DEF_STR(No))
PORT_CONFSETTING( 0x00, DEF_STR(Yes))
INPUT_PORTS_END
ioport_constructor pccard_sram_device::device_input_ports() const
@ -132,7 +136,7 @@ uint16_t pccard_sram_device::read_reg(offs_t offset, uint16_t mem_mask)
{
uint16_t data = 0xffff;
if (m_card_detect)
if (has_configured_map(1) && m_card_detect)
data = space(1).read_word(offset * 2, mem_mask);
LOGMASKED(LOG_ATTRIBUTE, "attribute memory r: %06x = %04x & %04x\n", offset, data, mem_mask);
@ -144,7 +148,7 @@ void pccard_sram_device::write_reg(offs_t offset, uint16_t data, uint16_t mem_ma
{
LOGMASKED(LOG_ATTRIBUTE, "attribute memory w: %06x = %04x & %04x\n", offset, data, mem_mask);
if (m_card_detect && BIT(m_switches->read(), 2))
if (has_configured_map(1) && m_card_detect && BIT(m_switches->read(), 2))
space(1).write_word(offset * 2, data & 0x00ff, mem_mask);
}
@ -155,6 +159,76 @@ void pccard_sram_device::card_inserted(bool state)
}
/***************************************************************************
Mitsubishi Melcard
MF31M1-LYCAT01: 8/16-bit Data Bus Static RAM Card
***************************************************************************/
pccard_mitsubishi_sram_device::pccard_mitsubishi_sram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
pccard_sram_device(mconfig, type, tag, owner, clock),
m_sram(*this, "sram")
{
}
image_init_result pccard_mitsubishi_sram_device::call_load()
{
card_inserted(false);
if (length() != m_sram.bytes())
return image_init_result::FAIL;
if (fread(&m_sram[0], m_sram.bytes()) != m_sram.bytes())
return image_init_result::FAIL;
card_inserted(true);
return image_init_result::PASS;
}
image_init_result pccard_mitsubishi_sram_device::call_create(int format_type, util::option_resolution *format_options)
{
card_inserted(false);
// clear ram
std::fill_n(&m_sram[0], m_sram.length(), 0);
if (fwrite(&m_sram[0], m_sram.bytes()) != m_sram.bytes())
return image_init_result::FAIL;
card_inserted(true);
return image_init_result::PASS;
}
void pccard_mitsubishi_sram_device::call_unload()
{
if (m_card_detect && !is_readonly())
{
fseek(0, SEEK_SET);
fwrite(&m_sram[0], m_sram.bytes());
}
std::fill_n(&m_sram[0], m_sram.length(), 0);
card_inserted(false);
}
pccard_mitsubishi_mf31m1_lycat01_device::pccard_mitsubishi_mf31m1_lycat01_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
pccard_mitsubishi_sram_device(mconfig, PCCARD_SRAM_MITSUBISHI_1M, tag, owner, clock)
{
m_memory_space_config = address_space_config("memory", ENDIANNESS_LITTLE, 16, 20, 0, address_map_constructor(FUNC(pccard_mitsubishi_mf31m1_lycat01_device::memory_map), this));
m_attribute_space_config = address_space_config("attribute", ENDIANNESS_LITTLE, 16, 14, 0);
}
void pccard_mitsubishi_mf31m1_lycat01_device::memory_map(address_map &map)
{
map(0x000000, 0x0fffff).ram().share("sram");
}
/***************************************************************************
Centennial SRAM

View File

@ -70,6 +70,31 @@ private:
required_ioport m_switches;
};
class pccard_mitsubishi_sram_device : public pccard_sram_device
{
protected:
pccard_mitsubishi_sram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
protected:
// device_image_interface overrides
virtual image_init_result call_load() override;
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
virtual void call_unload() override;
private:
required_shared_ptr<uint16_t> m_sram;
};
class pccard_mitsubishi_mf31m1_lycat01_device : public pccard_mitsubishi_sram_device
{
public:
// construction/destruction
pccard_mitsubishi_mf31m1_lycat01_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
private:
void memory_map(address_map &map);
};
class pccard_centennial_sram_device : public pccard_sram_device
{
protected:
@ -133,6 +158,7 @@ private:
};
// device type definition
DECLARE_DEVICE_TYPE(PCCARD_SRAM_MITSUBISHI_1M, pccard_mitsubishi_mf31m1_lycat01_device)
DECLARE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_1M, pccard_centennial_sl01m_15_11194_device)
DECLARE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_2M, pccard_centennial_sl02m_15_11194_device)
DECLARE_DEVICE_TYPE(PCCARD_SRAM_CENTENNIAL_4M, pccard_centennial_sl04m_15_11194_device)

View File

@ -1624,6 +1624,7 @@ static void amiga_floppies(device_slot_interface &device)
static void pcmcia_devices(device_slot_interface &device)
{
device.option_add("melcard_1m", PCCARD_SRAM_MITSUBISHI_1M);
device.option_add("sram_1m", PCCARD_SRAM_CENTENNIAL_1M);
device.option_add("sram_2m", PCCARD_SRAM_CENTENNIAL_2M);
device.option_add("sram_4m", PCCARD_SRAM_CENTENNIAL_4M);