From 88413be8669808573bcdb4c50d5d038ed7fd17d1 Mon Sep 17 00:00:00 2001 From: cracyc Date: Mon, 1 Feb 2016 17:24:21 -0600 Subject: [PATCH] pc9801_cd: 9801 cdrom drivers require DRDY and SERV always set (nw) pc9801_kbd: make a serial keyboard someday (nw) --- Load NECCDM.SYS to make the cdrom work. --- scripts/target/mame/mess.lua | 2 ++ src/mame/drivers/pc9801.cpp | 7 ++++++- src/mame/machine/pc9801_cd.cpp | 34 +++++++++++++++++++++++++++++++++ src/mame/machine/pc9801_cd.h | 23 ++++++++++++++++++++++ src/mame/machine/pc9801_kbd.cpp | 8 +++++++- src/mame/machine/pc9801_kbd.h | 1 + 6 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/mame/machine/pc9801_cd.cpp create mode 100644 src/mame/machine/pc9801_cd.h diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index cfbf4e0667a..d6f3b786332 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -2090,6 +2090,8 @@ files { MAME_DIR .. "src/mame/machine/pc9801_cbus.h", MAME_DIR .. "src/mame/machine/pc9801_kbd.cpp", MAME_DIR .. "src/mame/machine/pc9801_kbd.h", + MAME_DIR .. "src/mame/machine/pc9801_cd.cpp", + MAME_DIR .. "src/mame/machine/pc9801_cd.h", MAME_DIR .. "src/mame/drivers/tk80bs.cpp", MAME_DIR .. "src/mame/drivers/hh_ucom4.cpp", MAME_DIR .. "src/mame/includes/hh_ucom4.h", diff --git a/src/mame/drivers/pc9801.cpp b/src/mame/drivers/pc9801.cpp index 433e8346858..48b89439694 100644 --- a/src/mame/drivers/pc9801.cpp +++ b/src/mame/drivers/pc9801.cpp @@ -425,6 +425,7 @@ Keyboard TX commands: #include "machine/pc9801_118.h" #include "machine/pc9801_cbus.h" #include "machine/pc9801_kbd.h" +#include "machine/pc9801_cd.h" #include "machine/idectrl.h" #include "machine/idehd.h" @@ -3218,6 +3219,10 @@ TIMER_DEVICE_CALLBACK_MEMBER( pc9801_state::mouse_irq_cb ) } } +SLOT_INTERFACE_START(pc9801_atapi_devices) + SLOT_INTERFACE("pc9801_cd", PC9801_CD) +SLOT_INTERFACE_END + static MACHINE_CONFIG_FRAGMENT( pc9801_keyboard ) MCFG_DEVICE_ADD("keyb", PC9801_KBD, 53) MCFG_PC9801_KBD_IRQ_CALLBACK(DEVWRITELINE("pic8259_master", pic8259_device, ir1_w)) @@ -3266,7 +3271,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_FRAGMENT( pc9801_ide ) MCFG_ATA_INTERFACE_ADD("ide1", ata_devices, "hdd", nullptr, false) MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(pc9801_state, ide1_irq_w)) - MCFG_ATA_INTERFACE_ADD("ide2", ata_devices, "cdrom", nullptr, false) + MCFG_ATA_INTERFACE_ADD("ide2", pc9801_atapi_devices, "pc9801_cd", nullptr, false) MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(pc9801_state, ide2_irq_w)) MACHINE_CONFIG_END diff --git a/src/mame/machine/pc9801_cd.cpp b/src/mame/machine/pc9801_cd.cpp new file mode 100644 index 00000000000..2a4dffdc98e --- /dev/null +++ b/src/mame/machine/pc9801_cd.cpp @@ -0,0 +1,34 @@ +// license:BSD-3-Clause +// copyright-holders:smf +#include "pc9801_cd.h" + +// device type definition +const device_type PC9801_CD = &device_creator; + +pc9801_cd_device::pc9801_cd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + atapi_cdrom_device(mconfig, PC9801_CD, "PC9801 CD-ROM Drive", tag, owner, clock, "pc9801_cd", __FILE__) +{ +} + +void pc9801_cd_device::fill_buffer() +{ + atapi_hle_device::fill_buffer(); + m_status |= IDE_STATUS_DRDY | IDE_STATUS_SERV; +} + +void pc9801_cd_device::process_buffer() +{ + atapi_hle_device::process_buffer(); + m_status |= IDE_STATUS_DRDY | IDE_STATUS_SERV; +} + +void pc9801_cd_device::process_command() +{ + atapi_hle_device::process_command(); + switch(m_command) + { + case IDE_COMMAND_CHECK_POWER_MODE: + m_status = IDE_STATUS_DRDY | IDE_STATUS_SERV; + break; + } +} diff --git a/src/mame/machine/pc9801_cd.h b/src/mame/machine/pc9801_cd.h new file mode 100644 index 00000000000..35a2d223bd8 --- /dev/null +++ b/src/mame/machine/pc9801_cd.h @@ -0,0 +1,23 @@ +// license:BSD-3-Clause +// copyright-holders:smf + +#ifndef __PC9801_CD_H__ +#define __PC9801_CD_H__ + +#include "machine/atapicdr.h" + +class pc9801_cd_device : public atapi_cdrom_device +{ +public: + pc9801_cd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + +protected: + virtual void fill_buffer() override; + virtual void process_command() override; + virtual void process_buffer() override; +}; + +// device type definition +extern const device_type PC9801_CD; + +#endif diff --git a/src/mame/machine/pc9801_kbd.cpp b/src/mame/machine/pc9801_kbd.cpp index 260bd9f6b3d..3e4cd4373f8 100644 --- a/src/mame/machine/pc9801_kbd.cpp +++ b/src/mame/machine/pc9801_kbd.cpp @@ -257,6 +257,7 @@ void pc9801_kbd_device::device_reset() m_keyb_tx = 0xff; m_keyb_rx = 0; + m_key_avail = false; } //------------------------------------------------- @@ -276,6 +277,7 @@ void pc9801_kbd_device::device_timer(emu_timer &timer, device_timer_id id, int p { m_keyb_tx = i | 0x80; m_write_irq(ASSERT_LINE); + m_key_avail = true; m_rx_buf[i] = 0; return; } @@ -288,6 +290,7 @@ void pc9801_kbd_device::device_timer(emu_timer &timer, device_timer_id id, int p { m_keyb_tx = i; m_write_irq(ASSERT_LINE); + m_key_avail = true; m_rx_buf[i] = 0; return; } @@ -303,8 +306,11 @@ READ8_MEMBER( pc9801_kbd_device::rx_r ) { m_write_irq(CLEAR_LINE); if(!offset) + { + m_key_avail = false; return m_keyb_tx; - return 1 | 4 | 2; + } + return 1 | 4 | (m_key_avail ? 2 : 0); } WRITE8_MEMBER( pc9801_kbd_device::tx_w ) diff --git a/src/mame/machine/pc9801_kbd.h b/src/mame/machine/pc9801_kbd.h index c33d554ab3e..e776e2b238e 100644 --- a/src/mame/machine/pc9801_kbd.h +++ b/src/mame/machine/pc9801_kbd.h @@ -55,6 +55,7 @@ protected: UINT8 m_rx_buf[0x80]; UINT8 m_keyb_tx; UINT8 m_keyb_rx; + bool m_key_avail; };