mirror of
https://github.com/holub/mame
synced 2025-04-16 05:24:54 +03:00
huc6272.cpp: don't return -1 when running out of nybbles in adpcm_update fn, fixes extremely overdriven PC-FX aliasing
huc6230.cpp: code review some dubious paths;
This commit is contained in:
parent
926e59db2b
commit
492b0e0df2
@ -23,6 +23,10 @@ void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_
|
||||
{
|
||||
for (int i = 0; i < outputs[0].samples(); i++)
|
||||
{
|
||||
// TODO: this implies to read from the PSG inputs
|
||||
// doesn't seem right at all, eventually causes extreme DC offset on BIOS main menu,
|
||||
// possibly because adpcm_timer runs from a different thread,
|
||||
// needs to be rechecked once we have better examples ...
|
||||
s32 samp0 = inputs[0].get(i) * 32768.0;
|
||||
s32 samp1 = inputs[1].get(i) * 32768.0;
|
||||
|
||||
@ -33,8 +37,9 @@ void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_
|
||||
if (!channel->m_playing)
|
||||
continue;
|
||||
|
||||
samp0 = std::clamp(samp0 + ((channel->m_output * channel->m_lvol) >> 3), -32768, 32767);
|
||||
samp1 = std::clamp(samp1 + ((channel->m_output * channel->m_rvol) >> 3), -32768, 32767);
|
||||
// TODO: wrong volume scales
|
||||
samp0 = std::clamp(samp0 + ((channel->m_output * channel->m_lvol) >> 4), -32768, 32767);
|
||||
samp1 = std::clamp(samp1 + ((channel->m_output * channel->m_rvol) >> 4), -32768, 32767);
|
||||
}
|
||||
|
||||
outputs[0].put_int(i, samp0, 32768);
|
||||
@ -124,6 +129,8 @@ TIMER_CALLBACK_MEMBER(huc6230_device::adpcm_timer)
|
||||
}
|
||||
|
||||
int32_t new_output;
|
||||
// TODO: BIOS doesn't use interpolation
|
||||
// which actually is linear interpolation off/on ...
|
||||
if (!channel->m_interpolate)
|
||||
new_output = channel->m_curr_sample;
|
||||
else
|
||||
|
@ -453,8 +453,9 @@ void huc6272_device::write(offs_t offset, uint32_t data)
|
||||
m_adpcm.playing[i] = BIT(data, i);
|
||||
if (!m_adpcm.playing[i])
|
||||
{
|
||||
m_adpcm.input[i] = -1;
|
||||
m_adpcm.input[i] = 0;
|
||||
m_adpcm.pos[i] = 0;
|
||||
m_adpcm.nibble[i] = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -504,6 +505,8 @@ void huc6272_device::write(offs_t offset, uint32_t data)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: clearly written in blind faith
|
||||
// (interrupt_update fns are untested by the BIOS main menu)
|
||||
uint8_t huc6272_device::adpcm_update(int chan)
|
||||
{
|
||||
if (!m_adpcm.playing[chan])
|
||||
@ -513,7 +516,11 @@ uint8_t huc6272_device::adpcm_update(int chan)
|
||||
m_adpcm.pos[chan]++;
|
||||
if (m_adpcm.pos[chan] >= rate)
|
||||
{
|
||||
if (m_adpcm.input[chan] == -1)
|
||||
m_adpcm.nibble[chan] += 4;
|
||||
if (m_adpcm.nibble[chan] >= 32)
|
||||
m_adpcm.nibble[chan] = 0;
|
||||
|
||||
if (m_adpcm.nibble[chan] == 0)
|
||||
{
|
||||
m_adpcm.input[chan] = read_dword(((m_page_setting & 0x1000) << 6) | m_adpcm.addr[chan]);
|
||||
m_adpcm.addr[chan] = (m_adpcm.addr[chan] & 0x20000) | ((m_adpcm.addr[chan] + 1) & 0x1ffff);
|
||||
@ -535,7 +542,7 @@ uint8_t huc6272_device::adpcm_update(int chan)
|
||||
interrupt_update();
|
||||
}
|
||||
|
||||
if (BIT(m_adpcm.control[chan],0)) // Ring Buffer
|
||||
if (BIT(m_adpcm.control[chan], 0)) // Ring Buffer
|
||||
{
|
||||
m_adpcm.addr[chan] = m_adpcm.start[chan];
|
||||
}
|
||||
@ -545,14 +552,9 @@ uint8_t huc6272_device::adpcm_update(int chan)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
m_adpcm.nibble[chan] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_adpcm.nibble[chan] += 4;
|
||||
if (m_adpcm.nibble[chan] >= 28)
|
||||
m_adpcm.input[chan] = -1;
|
||||
//m_adpcm.nibble[chan] = 0;
|
||||
}
|
||||
|
||||
m_adpcm.pos[chan] = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user