summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/gb.cpp
diff options
context:
space:
mode:
author Wilbert Pol <wilbertpol@users.noreply.github.com>2016-10-07 20:36:50 +0200
committer Wilbert Pol <wilbertpol@users.noreply.github.com>2016-10-07 20:36:50 +0200
commitd1681b5f3844389e26d7bbc12b65939dc1c29374 (patch)
tree504e688c3a8bbf1f8e483846905772409d8ee13d /src/devices/sound/gb.cpp
parentbe9320048b03d4cc2d656e01d48a2a16a455f0ce (diff)
gameboy: fixed some audio regressions (nw)
Diffstat (limited to 'src/devices/sound/gb.cpp')
-rw-r--r--src/devices/sound/gb.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/devices/sound/gb.cpp b/src/devices/sound/gb.cpp
index 5ed8ec05939..33d71f09446 100644
--- a/src/devices/sound/gb.cpp
+++ b/src/devices/sound/gb.cpp
@@ -335,7 +335,7 @@ void gameboy_sound_device::update_square_channel(struct SOUND &snd, UINT64 cycle
{
if (snd.on)
{
- // compensate for left over cycles
+ // compensate for leftover cycles
if (snd.cycles_left > 0)
{
// Emit sample(s)
@@ -381,7 +381,7 @@ void dmg_apu_device::update_wave_channel(struct SOUND &snd, UINT64 cycles)
{
if (snd.on)
{
- // compensate for left over cycles
+ // compensate for leftover cycles
if (snd.cycles_left > 0)
{
if (cycles <= snd.cycles_left)
@@ -813,6 +813,12 @@ void gameboy_sound_device::sound_w_internal( int offset, UINT8 data )
break;
case NR13: /* Frequency lo (R/W) */
m_snd_1.reg[3] = data;
+ // Only enabling the frequency line breaks blarggs's sound test #5
+ // This condition may not be correct
+ if (!m_snd_1.sweep_enabled)
+ {
+ m_snd_1.frequency = ((m_snd_1.reg[4] & 0x7) << 8) | m_snd_1.reg[3];
+ }
break;
case NR14: /* Frequency hi / Initialize (R/W) */
m_snd_1.reg[4] = data;
@@ -859,6 +865,14 @@ void gameboy_sound_device::sound_w_internal( int offset, UINT8 data )
tick_length(m_snd_1);
}
}
+ else
+ {
+ // This condition may not be correct
+ if (!m_snd_1.sweep_enabled)
+ {
+ m_snd_1.frequency = ((m_snd_1.reg[4] & 0x7) << 8) | m_snd_1.reg[3];
+ }
+ }
}
break;
@@ -924,6 +938,10 @@ void gameboy_sound_device::sound_w_internal( int offset, UINT8 data )
tick_length(m_snd_2);
}
}
+ else
+ {
+ m_snd_2.frequency = ((m_snd_2.reg[4] & 0x7) << 8) | m_snd_2.reg[3];
+ }
}
break;
@@ -946,7 +964,7 @@ void gameboy_sound_device::sound_w_internal( int offset, UINT8 data )
break;
case NR33: /* Frequency lo (W) */
m_snd_3.reg[3] = data;
- m_snd_3.frequency = ((m_snd_3.reg[4] & 0x7) << 8) + m_snd_3.reg[3];
+ m_snd_3.frequency = ((m_snd_3.reg[4] & 0x7) << 8) | m_snd_3.reg[3];
break;
case NR34: /* Frequency hi / Initialize (W) */
m_snd_3.reg[4] = data;
@@ -974,7 +992,7 @@ void gameboy_sound_device::sound_w_internal( int offset, UINT8 data )
m_snd_3.duty = 1;
m_snd_3.duty_count = 0;
m_snd_3.length_counting = true;
- m_snd_3.frequency = ((m_snd_3.reg[4] & 0x7) << 8) + m_snd_3.reg[3];
+ m_snd_3.frequency = ((m_snd_3.reg[4] & 0x7) << 8) | m_snd_3.reg[3];
m_snd_3.frequency_counter = m_snd_3.frequency;
// There is a tiny bit of delay in starting up the wave channel(?)
//
@@ -994,6 +1012,10 @@ void gameboy_sound_device::sound_w_internal( int offset, UINT8 data )
tick_length(m_snd_3);
}
}
+ else
+ {
+ m_snd_3.frequency = ((m_snd_3.reg[4] & 0x7) << 8) | m_snd_3.reg[3];
+ }
}
break;