summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/isa/mcd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/isa/mcd.cpp')
-rw-r--r--src/devices/bus/isa/mcd.cpp93
1 files changed, 52 insertions, 41 deletions
diff --git a/src/devices/bus/isa/mcd.cpp b/src/devices/bus/isa/mcd.cpp
index a06e269302c..085ab3676b9 100644
--- a/src/devices/bus/isa/mcd.cpp
+++ b/src/devices/bus/isa/mcd.cpp
@@ -3,7 +3,10 @@
#include "emu.h"
#include "mcd.h"
+#include "speaker.h"
+
#include "coreutil.h"
+#include "multibyte.h"
void mcd_isa_device::map(address_map &map)
{
@@ -11,36 +14,36 @@ void mcd_isa_device::map(address_map &map)
map(0x1, 0x1).rw(FUNC(mcd_isa_device::flag_r), FUNC(mcd_isa_device::reset_w));
}
-static INPUT_PORTS_START( ide )
-INPUT_PORTS_END
-
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
DEFINE_DEVICE_TYPE(ISA16_MCD, mcd_isa_device, "mcd_isa", "Mitsumi ISA CD-ROM Adapter")
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
-ioport_constructor mcd_isa_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME( ide );
-}
-
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
+void mcd_isa_device::device_add_mconfig(machine_config &config)
+{
+ SPEAKER(config, "lheadphone").front_left();
+ SPEAKER(config, "rheadphone").front_right();
+ CDDA(config, m_cdda);
+ m_cdda->add_route(0, "lheadphone", 1.0);
+ m_cdda->add_route(1, "rheadphone", 1.0);
+ m_cdda->set_cdrom_tag(*this);
+}
+
//-------------------------------------------------
// mcd_isa_device - constructor
//-------------------------------------------------
mcd_isa_device::mcd_isa_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
cdrom_image_device(mconfig, ISA16_MCD, tag, owner, clock),
- device_isa16_card_interface( mconfig, *this )
+ device_isa16_card_interface( mconfig, *this ),
+ m_cdda(*this, "cdda")
{
+ set_interface("cdrom");
}
//-------------------------------------------------
@@ -65,7 +68,7 @@ void mcd_isa_device::device_reset()
m_cmdrd_count = 0;
m_cmdbuf_count = 0;
m_buf_count = 0;
- m_curtoctrk = 1;
+ m_curtoctrk = 0;
m_dma = 0;
m_irq = 0;
m_conf = 0;
@@ -78,6 +81,18 @@ void mcd_isa_device::device_reset()
bool mcd_isa_device::read_sector(bool first)
{
+ uint32_t lba = cdrom_file::msf_to_lba(m_readmsf);
+ if(m_drvmode == DRV_MODE_CDDA)
+ {
+ if(m_cdrom_handle->get_track_type(m_cdrom_handle->get_track(lba)) == cdrom_file::CD_TRACK_AUDIO)
+ {
+ m_cdda->stop_audio();
+ m_cdda->start_audio(lba, m_readcount);
+ return true;
+ }
+ else
+ m_drvmode = DRV_MODE_READ;
+ }
if((m_irq & IRQ_DATACOMP) && !first)
m_isa->irq5_w(ASSERT_LINE);
if(!m_readcount)
@@ -86,15 +101,15 @@ bool mcd_isa_device::read_sector(bool first)
m_data = false;
return false;
}
- uint32_t lba = msf_to_lba(m_readmsf);
- cdrom_read_data(m_cdrom_handle, lba - 150, m_buf, m_mode & 0x40 ? CD_TRACK_MODE1_RAW : CD_TRACK_MODE1);
+ m_cdda->stop_audio();
+ m_cdrom_handle->read_data(lba - 150, m_buf, m_mode & 0x40 ? cdrom_file::CD_TRACK_MODE1_RAW : cdrom_file::CD_TRACK_MODE1);
if(m_mode & 0x40)
{
//correct the header
m_buf[12] = dec_2_bcd((m_readmsf >> 16) & 0xff);
m_buf[13] = dec_2_bcd((m_readmsf >> 8) & 0xff);
}
- m_readmsf = lba_to_msf_alt(lba + 1);
+ m_readmsf = cdrom_file::lba_to_msf_alt(lba + 1);
m_buf_count = m_dmalen + 1;
m_buf_idx = 0;
m_data = true;
@@ -152,8 +167,8 @@ uint16_t mcd_isa_device::dack16_r(int line)
uint16_t ret = 0;
if(m_buf_idx < 2351)
{
- ret = m_buf[m_buf_idx++];
- ret |= (m_buf[m_buf_idx++] << 8);
+ ret = get_u16le(&m_buf[m_buf_idx]);
+ m_buf_idx += 2;
}
m_buf_count -= 2;
if(!m_buf_count)
@@ -259,15 +274,11 @@ void mcd_isa_device::cmd_w(uint8_t data)
case CMD_GET_INFO:
if(m_cdrom_handle)
{
- uint32_t first = lba_to_msf(150), last = lba_to_msf(cdrom_get_track_start(m_cdrom_handle, 0xaa));
+ uint32_t first = cdrom_file::lba_to_msf(150), last = cdrom_file::lba_to_msf(m_cdrom_handle->get_track_start(0xaa));
m_cmdbuf[1] = 1;
- m_cmdbuf[2] = dec_2_bcd(cdrom_get_last_track(m_cdrom_handle));
- m_cmdbuf[3] = dec_2_bcd((last >> 16) & 0xff);
- m_cmdbuf[4] = dec_2_bcd((last >> 8) & 0xff);
- m_cmdbuf[5] = dec_2_bcd(last & 0xff);
- m_cmdbuf[6] = dec_2_bcd((first >> 16) & 0xff);
- m_cmdbuf[7] = dec_2_bcd((first >> 8) & 0xff);
- m_cmdbuf[8] = dec_2_bcd(first & 0xff);
+ m_cmdbuf[2] = dec_2_bcd(m_cdrom_handle->get_last_track());
+ put_u24be(&m_cmdbuf[3], last);
+ put_u24be(&m_cmdbuf[6], first);
m_cmdbuf[9] = 0;
m_cmdbuf_count = 10;
m_readcount = 0;
@@ -281,21 +292,20 @@ void mcd_isa_device::cmd_w(uint8_t data)
case CMD_GET_Q:
if(m_cdrom_handle)
{
- int tracks = cdrom_get_last_track(m_cdrom_handle);
- uint32_t start = lba_to_msf(cdrom_get_track_start(m_cdrom_handle, m_curtoctrk));
- uint32_t end = lba_to_msf(cdrom_get_track_start(m_cdrom_handle, m_curtoctrk < tracks ? m_curtoctrk + 1 : 0xaa));
- m_cmdbuf[1] = (cdrom_get_adr_control(m_cdrom_handle, m_curtoctrk) << 4) & 0xf0;
+ int tracks = m_cdrom_handle->get_last_track();
+ uint32_t start = m_cdrom_handle->get_track_start(m_curtoctrk);
+ uint32_t len = cdrom_file::lba_to_msf(m_cdrom_handle->get_track_start(m_curtoctrk < (tracks - 1) ? m_curtoctrk + 1 : 0xaa) - start);
+ start = cdrom_file::lba_to_msf(start);
+ m_cmdbuf[1] = (m_cdrom_handle->get_adr_control(m_curtoctrk) << 4) & 0xf0;
m_cmdbuf[2] = 0; // track num except when reading toc
- m_cmdbuf[3] = dec_2_bcd(m_curtoctrk); // index
- m_cmdbuf[4] = dec_2_bcd((start >> 16) & 0xff);
- m_cmdbuf[5] = dec_2_bcd((start >> 8) & 0xff);
- m_cmdbuf[6] = dec_2_bcd(start & 0xff);
+ m_cmdbuf[3] = dec_2_bcd(m_curtoctrk + 1); // index
+ put_u24be(&m_cmdbuf[4], len);
m_cmdbuf[7] = 0;
- m_cmdbuf[8] = dec_2_bcd((end >> 16) & 0xff);
- m_cmdbuf[9] = dec_2_bcd((end >> 8) & 0xff);
- m_cmdbuf[10] = dec_2_bcd(end & 0xff);
+ put_u24be(&m_cmdbuf[8], start);
if(m_curtoctrk >= tracks)
- m_curtoctrk = 1;
+ m_curtoctrk = 0;
+ else if(m_mode & MODE_GET_TOC)
+ m_curtoctrk++;
m_cmdbuf_count = 11;
m_readcount = 0;
}
@@ -313,8 +323,9 @@ void mcd_isa_device::cmd_w(uint8_t data)
break;
case CMD_STOPCDDA:
case CMD_STOP:
+ m_cdda->stop_audio();
m_drvmode = DRV_MODE_STOP;
- m_curtoctrk = 1;
+ m_curtoctrk = 0;
break;
case CMD_CONFIG:
m_cmdrd_count = 2;
@@ -324,7 +335,7 @@ void mcd_isa_device::cmd_w(uint8_t data)
if(m_cdrom_handle)
{
m_readcount = 0;
- m_drvmode = DRV_MODE_READ;
+ m_drvmode = data == CMD_READ1X ? DRV_MODE_CDDA : DRV_MODE_READ;
m_cmdrd_count = 6;
}
else