vis: somewhat better sound (nw)

This commit is contained in:
cracyc 2018-05-28 21:49:31 -05:00
parent 835d0366ca
commit f93a3c994f

View File

@ -30,12 +30,13 @@ private:
required_device<dac_word_interface> m_rdac;
required_device<dac_word_interface> m_ldac;
uint16_t m_count;
uint16_t m_curcount;
uint16_t m_sample[2];
uint8_t m_index[2]; // unknown indexed registers, volume?
uint8_t m_data[2][16];
uint8_t m_mode;
uint8_t m_stat;
uint8_t m_dmalen;
uint8_t m_ctrl;
unsigned int m_sample_byte;
unsigned int m_samples;
emu_timer *m_pcm;
@ -63,29 +64,26 @@ void vis_audio_device::device_start()
void vis_audio_device::device_reset()
{
m_count = 0xffff;
m_count = 0;
m_curcount = 0;
m_sample_byte = 0;
m_samples = 0;
m_mode = 0;
m_index[0] = m_index[1] = 0;
m_stat = 0;
}
void vis_audio_device::dack16_w(int line, uint16_t data)
{
m_sample[m_samples++] = data;
if(m_samples >= ((m_dmalen & 2) ? 1 : 2))
m_curcount++;
if(m_samples >= 2)
m_isa->drq7_w(CLEAR_LINE);
}
void vis_audio_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if(m_count == 0xffff)
{
m_isa->drq7_w(ASSERT_LINE);
m_samples = 0;
if(m_samples < 2)
return;
}
switch(m_mode & 0x88)
{
case 0x80: // 8bit mono
@ -113,20 +111,18 @@ void vis_audio_device::device_timer(emu_timer &timer, device_timer_id id, int pa
break;
}
if(m_sample_byte >= ((m_dmalen & 2) ? 2 : 4))
if(m_sample_byte >= 4)
{
m_sample_byte = 0;
m_samples = 0;
if(m_count)
m_isa->drq7_w(ASSERT_LINE);
else
m_isa->drq7_w(ASSERT_LINE);
if(m_curcount >= m_count)
{
m_ldac->write(0x8000);
m_rdac->write(0x8000);
m_stat = 4;
m_isa->irq7_w(ASSERT_LINE);
m_curcount = 0;
m_ctrl |= 4;
if(BIT(m_ctrl, 1))
m_isa->irq7_w(ASSERT_LINE);
}
m_count--;
}
}
@ -138,8 +134,8 @@ MACHINE_CONFIG_START(vis_audio_device::device_add_mconfig)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.00)
MCFG_SOUND_ROUTE(2, "lspeaker", 1.00)
MCFG_SOUND_ROUTE(3, "rspeaker", 1.00)
MCFG_DEVICE_ADD("ldac", DAC_16BIT_R2R, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) // unknown DAC
MCFG_DEVICE_ADD("rdac", DAC_16BIT_R2R, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) // unknown DAC
MCFG_DEVICE_ADD("ldac", DAC_16BIT_R2R, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) // sanyo lc7883k
MCFG_DEVICE_ADD("rdac", DAC_16BIT_R2R, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) // sanyo lc7883k
MCFG_DEVICE_ADD("vref", VOLTAGE_REGULATOR, 0) MCFG_VOLTAGE_REGULATOR_OUTPUT(5.0)
MCFG_SOUND_ROUTE(0, "ldac", 1.0, DAC_VREF_POS_INPUT) MCFG_SOUND_ROUTE(0, "ldac", -1.0, DAC_VREF_NEG_INPUT)
MCFG_SOUND_ROUTE(0, "rdac", 1.0, DAC_VREF_POS_INPUT) MCFG_SOUND_ROUTE(0, "rdac", -1.0, DAC_VREF_NEG_INPUT)
@ -150,14 +146,20 @@ READ8_MEMBER(vis_audio_device::pcm_r)
switch(offset)
{
case 0x00:
m_isa->irq7_w(CLEAR_LINE);
m_ctrl &= ~4;
return m_mode;
case 0x02:
return m_data[0][m_index[0]];
case 0x04:
return m_data[1][m_index[1]];
case 0x09:
{
u8 ret = m_ctrl;
m_isa->irq7_w(CLEAR_LINE);
return m_stat;
m_ctrl &= ~4;
return ret;
}
case 0x0c:
return m_count & 0xff;
case 0x0e:
@ -174,6 +176,7 @@ READ8_MEMBER(vis_audio_device::pcm_r)
WRITE8_MEMBER(vis_audio_device::pcm_w)
{
u8 oldmode = m_mode;
switch(offset)
{
case 0x00:
@ -192,7 +195,7 @@ WRITE8_MEMBER(vis_audio_device::pcm_w)
m_index[1] = data;
return;
case 0x09:
m_dmalen = data;
m_ctrl = data;
return;
case 0x0c:
m_count = (m_count & 0xff00) | data;
@ -207,12 +210,11 @@ WRITE8_MEMBER(vis_audio_device::pcm_w)
logerror("unknown pcm write %04x %02x\n", offset, data);
return;
}
if((m_mode & 0x10) && (m_count != 0xffff))
if((m_mode & 0x10) && (m_mode ^ oldmode))
{
const int rates[] = {44100, 22050, 11025, 5512};
m_samples = 0;
m_sample_byte = 0;
m_stat = 0;
m_isa->drq7_w(ASSERT_LINE);
attotime rate = attotime::from_hz(rates[(m_mode >> 5) & 3]);
m_pcm->adjust(rate, 0, rate);