summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-09-01 19:17:31 -0400
committer AJR <ajrhacker@users.noreply.github.com>2020-09-01 19:17:31 -0400
commitb72f11ef07046f3bc5d9c4bec4ff8836a34b34ec (patch)
treee8e506d69edd3892e372a276905032db157a5e65
parent82b7fb4eceae20982e9c2695691957d8475c364d (diff)
st2205u: Add DMA register stubs
-rw-r--r--src/devices/cpu/m6502/st2204.cpp26
-rw-r--r--src/devices/cpu/m6502/st2204.h8
-rw-r--r--src/devices/cpu/m6502/st2205u.cpp119
-rw-r--r--src/devices/cpu/m6502/st2205u.h34
-rw-r--r--src/devices/cpu/m6502/st2xxx.cpp29
-rw-r--r--src/devices/cpu/m6502/st2xxx.h5
6 files changed, 185 insertions, 36 deletions
diff --git a/src/devices/cpu/m6502/st2204.cpp b/src/devices/cpu/m6502/st2204.cpp
index 0d7162ac207..d482e6b798a 100644
--- a/src/devices/cpu/m6502/st2204.cpp
+++ b/src/devices/cpu/m6502/st2204.cpp
@@ -105,6 +105,7 @@ void st2204_device::device_start()
save_item(NAME(m_dms));
save_item(NAME(m_dmd));
save_item(NAME(m_dcnth));
+ save_item(NAME(intf->dmr));
mintf = std::move(intf);
save_common_registers();
@@ -178,6 +179,9 @@ void st2204_device::device_reset()
m_dac = 0;
m_psg_timer->enable(false);
m_dac_callback(0);
+
+ downcast<mi_st2204 &>(*mintf).dmr = 0;
+ // other DMA registers are undefined
}
const char *st2204_device::st2xxx_irq_name(int i) const
@@ -585,6 +589,28 @@ void st2204_device::dcnth_w(u8 data)
m_dcnth = data & 0x1f;
}
+u8 st2204_device::dmrl_r()
+{
+ return downcast<mi_st2204 &>(*mintf).dmr & 0xff;
+}
+
+void st2204_device::dmrl_w(u8 data)
+{
+ u16 &dmr = downcast<mi_st2204 &>(*mintf).dmr;
+ dmr = (data & m_drr_mask) | (dmr & 0xff00);
+}
+
+u8 st2204_device::dmrh_r()
+{
+ return downcast<mi_st2204 &>(*mintf).dmr >> 8;
+}
+
+void st2204_device::dmrh_w(u8 data)
+{
+ u16 &dmr = downcast<mi_st2204 &>(*mintf).dmr;
+ dmr = ((u16(data) << 8) & m_drr_mask) | (dmr & 0x00ff);
+}
+
u8 st2204_device::pmem_r(offs_t offset)
{
return downcast<mi_st2204 &>(*mintf).pread(offset);
diff --git a/src/devices/cpu/m6502/st2204.h b/src/devices/cpu/m6502/st2204.h
index 42af8ad9612..4d8839833d0 100644
--- a/src/devices/cpu/m6502/st2204.h
+++ b/src/devices/cpu/m6502/st2204.h
@@ -77,6 +77,8 @@ private:
u8 dread(u16 adr);
u8 dreadc(u16 adr);
void dwrite(u16 adr, u8 val);
+
+ u16 dmr;
};
TIMER_CALLBACK_MEMBER(t0_interrupt);
@@ -91,6 +93,7 @@ private:
void t1m_w(u8 data);
u8 t1c_r();
void t1c_w(u8 data);
+
TIMER_CALLBACK_MEMBER(psg_interrupt);
void psg_timer_reload();
u8 psg_r(offs_t offset);
@@ -101,6 +104,7 @@ private:
void vol_w(u8 data);
u8 dac_r();
void dac_w(u8 data);
+
u8 dmsl_r();
void dmsl_w(u8 data);
u8 dmsh_r();
@@ -111,6 +115,10 @@ private:
void dmdh_w(u8 data);
void dcntl_w(u8 data);
void dcnth_w(u8 data);
+ u8 dmrl_r();
+ void dmrl_w(u8 data);
+ u8 dmrh_r();
+ void dmrh_w(u8 data);
u8 pmem_r(offs_t offset);
void pmem_w(offs_t offset, u8 data);
diff --git a/src/devices/cpu/m6502/st2205u.cpp b/src/devices/cpu/m6502/st2205u.cpp
index 4d5e11dad3a..88ea691ce40 100644
--- a/src/devices/cpu/m6502/st2205u.cpp
+++ b/src/devices/cpu/m6502/st2205u.cpp
@@ -44,7 +44,7 @@ st2205u_device::st2205u_device(const machine_config &mconfig, const char *tag, d
, m_tc_12bit{0}
, m_t4c(0)
, m_tien(0)
- , m_dac_fifo{{0}}
+ , m_dac_fifo{{0}}
, m_fifo_filled{0}
, m_psgc(0)
, m_psgm(0)
@@ -55,6 +55,11 @@ st2205u_device::st2205u_device(const machine_config &mconfig, const char *tag, d
, m_gray_levels{0}
, m_usbcon(0)
, m_usbien(0)
+ , m_dptr{0}
+ , m_dbkr{0}
+ , m_dcnt{0}
+ , m_dctr(0)
+ , m_dmod{0}
, m_rctr(0)
, m_lvctr(0)
{
@@ -91,6 +96,11 @@ void st2205u_device::device_start()
save_item(NAME(m_gray_levels));
save_item(NAME(m_usbcon));
save_item(NAME(m_usbien));
+ save_item(NAME(m_dptr));
+ save_item(NAME(m_dbkr));
+ save_item(NAME(m_dcnt));
+ save_item(NAME(m_dctr));
+ save_item(NAME(m_dmod));
save_item(NAME(m_rctr));
save_item(NAME(m_lvctr));
save_item(NAME(intf->brr));
@@ -153,6 +163,16 @@ void st2205u_device::device_start()
state_add(ST_BDIV, "BDIV", m_bdiv);
state_add(ST_USBCON, "USBCON", m_usbcon).mask(0xfc);
state_add(ST_USBIEN, "USBIEN", m_usbien).mask(0xbf);
+ for (int i = 0; i < 2; i++)
+ {
+ state_add(ST_DMS0 + i, string_format("DMS%d", i).c_str(), m_dptr[i * 2]).mask(0x7fff);
+ state_add(ST_DMD0 + i, string_format("DMD%d", i).c_str(), m_dptr[i * 2 + 1]).mask(0x7fff);
+ state_add(ST_DBKS0 + i, string_format("DBKS%d", i).c_str(), m_dbkr[i * 2]).mask(0x87ff);
+ state_add(ST_DBKD0 + i, string_format("DBKD%d", i).c_str(), m_dbkr[i * 2 + 1]).mask(0x87ff);
+ state_add(ST_DCNT0 + i, string_format("DCNT%d", i).c_str(), m_dcnt[i]).mask(0x7fff);
+ state_add(ST_DMOD0 + i, string_format("DMOD%d", i).c_str(), m_dmod[i]).mask(0x3f);
+ }
+ state_add(ST_DCTR, "DCTR", m_dctr).mask(0x03);
state_add(ST_RCTR, "RCTR", m_rctr).mask(0xef);
state_add(ST_LVCTR, "LVCTR", m_lvctr).mask(0x0f);
}
@@ -182,6 +202,12 @@ void st2205u_device::device_reset()
m_usbcon = 0;
m_usbien = 0x20;
+ std::fill(std::begin(m_dptr), std::end(m_dptr), 0);
+ std::fill(std::begin(m_dbkr), std::end(m_dbkr), 0);
+ std::fill(std::begin(m_dcnt), std::end(m_dcnt), 0);
+ m_dctr = 0;
+ std::fill(std::begin(m_dmod), std::end(m_dmod), 0);
+
m_rctr = 0;
m_lvctr = 0;
@@ -513,6 +539,87 @@ void st2205u_device::usbien_w(u8 data)
m_usbien = data & 0xbf;
}
+u8 st2205u_device::dptrl_r()
+{
+ return m_dptr[m_dctr] & 0x00ff;
+}
+
+void st2205u_device::dptrl_w(u8 data)
+{
+ m_dptr[m_dctr] = (m_dptr[m_dctr] & 0x7f00) | data;
+}
+
+u8 st2205u_device::dptrh_r()
+{
+ return (m_dptr[m_dctr] >> 8) | 0x80;
+}
+
+void st2205u_device::dptrh_w(u8 data)
+{
+ m_dptr[m_dctr] = u16(data & 0x7f) << 8 | (m_dptr[m_dctr] & 0x00ff);
+}
+
+u8 st2205u_device::dbkrl_r()
+{
+ return m_dbkr[m_dctr] & 0x00ff;
+}
+
+void st2205u_device::dbkrl_w(u8 data)
+{
+ m_dbkr[m_dctr] = (m_dbkr[m_dctr] & 0x8700) | data;
+}
+
+u8 st2205u_device::dbkrh_r()
+{
+ return (m_dbkr[m_dctr] >> 8) | 0x78;
+}
+
+void st2205u_device::dbkrh_w(u8 data)
+{
+ m_dbkr[m_dctr] = u16(data & 0x87) << 8 | (m_dbkr[m_dctr] & 0x00ff);
+}
+
+u8 st2205u_device::dcntl_r()
+{
+ return m_dcnt[m_dctr >> 1] & 0x00ff;
+}
+
+void st2205u_device::dcntl_w(u8 data)
+{
+ m_dcnt[m_dctr >> 1] = (m_dcnt[m_dctr >> 1] & 0x7f00) | data;
+}
+
+u8 st2205u_device::dcnth_r()
+{
+ return (m_dcnt[m_dctr >> 1] >> 8) | 0x80;
+}
+
+void st2205u_device::dcnth_w(u8 data)
+{
+ m_dcnt[m_dctr >> 1] = (m_dcnt[m_dctr >> 1] & 0x7f00) | data;
+ // TODO: start DMA here
+}
+
+u8 st2205u_device::dctr_r()
+{
+ return m_dctr | 0xfc;
+}
+
+void st2205u_device::dctr_w(u8 data)
+{
+ m_dctr = data & 0x03;
+}
+
+u8 st2205u_device::dmod_r()
+{
+ return m_dmod[m_dctr >> 1] | 0xc0;
+}
+
+void st2205u_device::dmod_w(u8 data)
+{
+ m_dmod[m_dctr >> 1] = data & 0x3f;
+}
+
u8 st2205u_device::rctr_r()
{
return (m_rctr & 0xe0) | 0x10;
@@ -625,8 +732,14 @@ void st2205u_device::int_map(address_map &map)
map(0x004e, 0x004e).rw(FUNC(st2205u_device::pl_r), FUNC(st2205u_device::pl_w));
map(0x004f, 0x004f).rw(FUNC(st2205u_device::pcl_r), FUNC(st2205u_device::pcl_w));
map(0x0057, 0x0057).rw(FUNC(st2205u_device::lvctr_r), FUNC(st2205u_device::lvctr_w));
- map(0x005a, 0x005a).rw(FUNC(st2205u_device::dmrl_r), FUNC(st2205u_device::dmrl_w));
- map(0x005b, 0x005b).rw(FUNC(st2205u_device::dmrh_r), FUNC(st2205u_device::dmrh_w));
+ map(0x0058, 0x0058).rw(FUNC(st2205u_device::dptrl_r), FUNC(st2205u_device::dptrl_w));
+ map(0x0059, 0x0059).rw(FUNC(st2205u_device::dptrh_r), FUNC(st2205u_device::dptrh_w));
+ map(0x005a, 0x005a).rw(FUNC(st2205u_device::dbkrl_r), FUNC(st2205u_device::dbkrl_w));
+ map(0x005b, 0x005b).rw(FUNC(st2205u_device::dbkrh_r), FUNC(st2205u_device::dbkrh_w));
+ map(0x005c, 0x005c).rw(FUNC(st2205u_device::dcntl_r), FUNC(st2205u_device::dcntl_w));
+ map(0x005d, 0x005d).rw(FUNC(st2205u_device::dcnth_r), FUNC(st2205u_device::dcnth_w));
+ map(0x005e, 0x005e).rw(FUNC(st2205u_device::dctr_r), FUNC(st2205u_device::dctr_w));
+ map(0x005f, 0x005f).rw(FUNC(st2205u_device::dmod_r), FUNC(st2205u_device::dmod_w));
map(0x0060, 0x0060).rw(FUNC(st2205u_device::uctr_r), FUNC(st2205u_device::uctr_w));
map(0x0061, 0x0061).rw(FUNC(st2205u_device::usr_r), FUNC(st2205u_device::usr_clr_w));
map(0x0062, 0x0062).rw(FUNC(st2205u_device::irctr_r), FUNC(st2205u_device::irctr_w));
diff --git a/src/devices/cpu/m6502/st2205u.h b/src/devices/cpu/m6502/st2205u.h
index 767d6a4f2be..381a045e79a 100644
--- a/src/devices/cpu/m6502/st2205u.h
+++ b/src/devices/cpu/m6502/st2205u.h
@@ -38,6 +38,19 @@ public:
ST_VOLM1,
ST_LBUF,
ST_BRR,
+ ST_DMS0,
+ ST_DMS1,
+ ST_DMD0,
+ ST_DMD1,
+ ST_DBKS0,
+ ST_DBKS1,
+ ST_DBKD0,
+ ST_DBKD1,
+ ST_DCNT0,
+ ST_DCNT1,
+ ST_DCTR,
+ ST_DMOD0,
+ ST_DMOD1,
ST_USBCON,
ST_USBIEN,
ST_RCTR,
@@ -124,6 +137,22 @@ private:
void usbcon_w(u8 data);
u8 usbien_r();
void usbien_w(u8 data);
+ u8 dptrl_r();
+ void dptrl_w(u8 data);
+ u8 dptrh_r();
+ void dptrh_w(u8 data);
+ u8 dbkrl_r();
+ void dbkrl_w(u8 data);
+ u8 dbkrh_r();
+ void dbkrh_w(u8 data);
+ u8 dcntl_r();
+ void dcntl_w(u8 data);
+ u8 dcnth_r();
+ void dcnth_w(u8 data);
+ u8 dctr_r();
+ void dctr_w(u8 data);
+ u8 dmod_r();
+ void dmod_w(u8 data);
u8 rctr_r();
void rctr_w(u8 data);
u8 lvctr_r();
@@ -155,6 +184,11 @@ private:
u8 m_gray_levels[16];
u8 m_usbcon;
u8 m_usbien;
+ u16 m_dptr[4];
+ u16 m_dbkr[4];
+ u16 m_dcnt[2];
+ u8 m_dctr;
+ u8 m_dmod[2];
u8 m_rctr;
u8 m_lvctr;
};
diff --git a/src/devices/cpu/m6502/st2xxx.cpp b/src/devices/cpu/m6502/st2xxx.cpp
index 89de90f3b20..41327c00267 100644
--- a/src/devices/cpu/m6502/st2xxx.cpp
+++ b/src/devices/cpu/m6502/st2xxx.cpp
@@ -161,11 +161,7 @@ void st2xxx_device::save_common_registers()
save_item(NAME(intf->prr));
}
if (m_drr_mask != 0)
- {
save_item(NAME(intf->drr));
- if (st2xxx_has_dma())
- save_item(NAME(intf->dmr));
- }
if (m_bt_mask != 0)
{
save_item(NAME(m_bten));
@@ -220,7 +216,6 @@ void st2xxx_device::device_reset()
m.irr = 0;
m.prr = 0;
m.drr = 0;
- m.dmr = 0;
// reset interrupt registers
m_ireq = 0;
@@ -253,7 +248,7 @@ void st2xxx_device::device_reset()
// reset UART and BRG
m_uctr = 0;
- m_usr = 0x01;
+ m_usr = BIT(st2xxx_uctr_mask(), 4) ? 0x01 : 0;
m_irctr = 0;
m_bctr = 0;
}
@@ -572,28 +567,6 @@ void st2xxx_device::drrh_w(u8 data)
drr = ((u16(data) << 8) & m_drr_mask) | (drr & 0x00ff);
}
-u8 st2xxx_device::dmrl_r()
-{
- return downcast<mi_st2xxx &>(*mintf).dmr & 0xff;
-}
-
-void st2xxx_device::dmrl_w(u8 data)
-{
- u16 &dmr = downcast<mi_st2xxx &>(*mintf).dmr;
- dmr = (data & m_drr_mask) | (dmr & 0xff00);
-}
-
-u8 st2xxx_device::dmrh_r()
-{
- return downcast<mi_st2xxx &>(*mintf).dmr >> 8;
-}
-
-void st2xxx_device::dmrh_w(u8 data)
-{
- u16 &dmr = downcast<mi_st2xxx &>(*mintf).dmr;
- dmr = ((u16(data) << 8) & m_drr_mask) | (dmr & 0x00ff);
-}
-
u8 st2xxx_device::ireql_r()
{
return m_ireq & 0x00ff;
diff --git a/src/devices/cpu/m6502/st2xxx.h b/src/devices/cpu/m6502/st2xxx.h
index 9980c1aafbb..f83d005cbab 100644
--- a/src/devices/cpu/m6502/st2xxx.h
+++ b/src/devices/cpu/m6502/st2xxx.h
@@ -121,7 +121,6 @@ protected:
u16 irr;
u16 prr;
u16 drr;
- u16 dmr;
};
void init_base_timer(u16 ireq);
@@ -173,10 +172,6 @@ protected:
void drrl_w(u8 data);
u8 drrh_r();
void drrh_w(u8 data);
- u8 dmrl_r();
- void dmrl_w(u8 data);
- u8 dmrh_r();
- void dmrh_w(u8 data);
u8 bten_r();
void bten_w(u8 data);