summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2018-09-30 10:41:34 +0900
committer hap <happppp@users.noreply.github.com>2018-09-30 03:41:34 +0200
commit51f02ffaf21b55b1d9d4a9b7af0166e6191f5812 (patch)
treed657a93d39e0a926792fd4f0451a96ff5cf9d4ae
parentb757576f35552b16ef2d11bc2179e5170b37d3eb (diff)
iremga20.cpp : Fix frequency update algorithm (#4040)
* iremga20.cpp : Fix frequency update algorithm * iremga20.cpp : Fix naming * iremga20.cpp : Fix method iremga20.h : Fix value name
-rw-r--r--src/devices/sound/iremga20.cpp17
-rw-r--r--src/devices/sound/iremga20.h2
2 files changed, 11 insertions, 8 deletions
diff --git a/src/devices/sound/iremga20.cpp b/src/devices/sound/iremga20.cpp
index d8280c9b68a..e3c18cbf700 100644
--- a/src/devices/sound/iremga20.cpp
+++ b/src/devices/sound/iremga20.cpp
@@ -80,7 +80,7 @@ void iremga20_device::device_start()
{
save_item(NAME(m_channel[i].rate), i);
save_item(NAME(m_channel[i].pos), i);
- save_item(NAME(m_channel[i].frac), i);
+ save_item(NAME(m_channel[i].counter), i);
save_item(NAME(m_channel[i].end), i);
save_item(NAME(m_channel[i].volume), i);
save_item(NAME(m_channel[i].play), i);
@@ -99,7 +99,7 @@ void iremga20_device::device_reset()
{
m_channel[i].rate = 0;
m_channel[i].pos = 0;
- m_channel[i].frac = 0;
+ m_channel[i].counter = 0;
m_channel[i].end = 0;
m_channel[i].volume = 0;
m_channel[i].play = 0;
@@ -150,9 +150,12 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
else
{
sampleout += (sample - 0x80) * (int32_t)ch.volume;
- ch.frac += ch.rate;
- ch.pos += (ch.frac >> 24);
- ch.frac &= ((1 << 24) - 1);
+ ch.counter--;
+ if (ch.counter <= ch.rate)
+ {
+ ch.pos++;
+ ch.counter = 0x100;
+ }
}
}
}
@@ -182,7 +185,7 @@ WRITE8_MEMBER( iremga20_device::irem_ga20_w )
switch (offset & 0x7)
{
case 4:
- m_channel[ch].rate = (1 << 24) / (256 - data);
+ m_channel[ch].rate = data;
break;
case 5:
@@ -196,7 +199,7 @@ WRITE8_MEMBER( iremga20_device::irem_ga20_w )
m_channel[ch].play = 1;
m_channel[ch].pos = (m_regs[ch << 3 | 0] | m_regs[ch << 3 | 1] << 8) << 4;
m_channel[ch].end = (m_regs[ch << 3 | 2] | m_regs[ch << 3 | 3] << 8) << 4;
- m_channel[ch].frac = 0;
+ m_channel[ch].counter = 0x100;
}
else
m_channel[ch].play = 0;
diff --git a/src/devices/sound/iremga20.h b/src/devices/sound/iremga20.h
index cd85b295f5a..e5b250a8f0a 100644
--- a/src/devices/sound/iremga20.h
+++ b/src/devices/sound/iremga20.h
@@ -45,7 +45,7 @@ private:
{
uint32_t rate;
uint32_t pos;
- uint32_t frac;
+ uint32_t counter;
uint32_t end;
uint32_t volume;
uint32_t play;