summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/ym2151.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-03-04 10:07:56 -0500
committer AJR <ajrhacker@users.noreply.github.com>2020-03-04 10:07:56 -0500
commit81cccebb1fa12ecd338d014d5f5c6308b5ad2b7f (patch)
treef0e2e12d68066e1f5c7380d43378034ea9aa0155 /src/devices/sound/ym2151.cpp
parent245b2106b7d343630a5a64836826908de47b577e (diff)
ym2151: Add YM2164 variant and emulate some known differences
Diffstat (limited to 'src/devices/sound/ym2151.cpp')
-rw-r--r--src/devices/sound/ym2151.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/devices/sound/ym2151.cpp b/src/devices/sound/ym2151.cpp
index f6284aa0360..64b02822644 100644
--- a/src/devices/sound/ym2151.cpp
+++ b/src/devices/sound/ym2151.cpp
@@ -5,6 +5,7 @@
#include "ym2151.h"
DEFINE_DEVICE_TYPE(YM2151, ym2151_device, "ym2151", "Yamaha YM2151 OPM")
+DEFINE_DEVICE_TYPE(YM2164, ym2164_device, "ym2164", "Yamaha YM2164 OPP")
#define FREQ_SH 16 /* 16.16 fixed point (frequency calculations) */
@@ -407,6 +408,21 @@ void ym2151_device::calculate_timers()
}
}
+void ym2164_device::calculate_timers()
+{
+ /* calculate timers' deltas */
+ for (int i=0; i<1024; i++)
+ {
+ /* ASG 980324: changed to compute both tim_A_tab and timer_A_time */
+ timer_A_time[i] = clocks_to_attotime(64 * (1024 - i));
+ }
+ for (int i=0; i<256; i++)
+ {
+ /* ASG 980324: changed to compute both tim_B_tab and timer_B_time */
+ timer_B_time[i] = clocks_to_attotime(2048 * (256 - i));
+ }
+}
+
void ym2151_device::YM2151Operator::key_on(uint32_t key_set, uint32_t eg_cnt)
{
if (!key)
@@ -910,6 +926,16 @@ void ym2151_device::write_reg(int r, int v)
}
}
+void ym2164_device::write_reg(int r, int v)
+{
+ if (r < 0x08)
+ logerror("%s: Writing %02X to undocumented register %d\n", machine().describe_context(), v, r);
+ else if (r == 0x09)
+ ym2151_device::write_reg(0x01, v);
+ else
+ ym2151_device::write_reg(r, v);
+}
+
void ym2151_device::device_post_load()
{
for (int j=0; j<8; j++)
@@ -1662,8 +1688,8 @@ void ym2151_device::advance()
// ym2151_device - constructor
//-------------------------------------------------
-ym2151_device::ym2151_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, YM2151, tag, owner, clock),
+ym2151_device::ym2151_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, type, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_stream(nullptr),
m_lastreg(0),
@@ -1673,6 +1699,21 @@ ym2151_device::ym2151_device(const machine_config &mconfig, const char *tag, dev
{
}
+ym2151_device::ym2151_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : ym2151_device(mconfig, YM2151, tag, owner, clock)
+{
+}
+
+
+//-------------------------------------------------
+// ym2164_device - constructor
+//-------------------------------------------------
+
+ym2164_device::ym2164_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : ym2151_device(mconfig, YM2164, tag, owner, clock)
+{
+}
+
//-------------------------------------------------
// read - read from the device