Part I of refactoring, nw

This commit is contained in:
angelosa 2015-04-05 20:04:42 +02:00
parent d0e5da8a1b
commit efb5123b0c
2 changed files with 23 additions and 122 deletions

View File

@ -1,6 +1,6 @@
/***************************************************************************
L7A1045 L6028 DSP-A
L7A1045 L6028 DSP-A
(QFP120 package)
this is the audio chip used on the following
@ -44,7 +44,7 @@
7 ---------------- ---------------- llllllllrrrrrrrr left/right volume
8 ---------------- ---------------- ---------------- (read only?)
8 ---------------- ---------------- ---------------- (read only?)
9 ---------------- ---------------- ---------------- (read only?)
@ -149,7 +149,7 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, stream_samp
if ((start + pos) >= end)
{
m_key &= ~(1 << i);
}
sample = (INT8)m_rom[(start + pos) & (m_rom_size-1)];
@ -168,16 +168,12 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, stream_samp
WRITE16_MEMBER( l7a1045_sound_device::l7a1045_sound_w )
{
m_stream->update();
switch (offset)
{
case 0x00:l7a1045_sound_select_w(space, offset, data, mem_mask); break;
case 0x01:l7a1045_sound_data_02_w(space, offset, data, mem_mask); break;
case 0x02:l7a1045_sound_data_04_w(space, offset, data, mem_mask); break;
case 0x03:l7a1045_sound_data_06_w(space, offset, data, mem_mask); break;
}
m_stream->update(); // TODO
if(offset == 0)
sound_select_w(space, offset, data, mem_mask);
else
sound_data_w(space,offset - 1,data,mem_mask);
}
@ -199,7 +195,7 @@ READ16_MEMBER( l7a1045_sound_device::l7a1045_sound_r )
}
WRITE16_MEMBER(l7a1045_sound_device::l7a1045_sound_select_w)
WRITE16_MEMBER(l7a1045_sound_device::sound_select_w)
{
// I'm guessing these addresses are the sound chip / DSP?
@ -222,130 +218,37 @@ WRITE16_MEMBER(l7a1045_sound_device::l7a1045_sound_select_w)
}
WRITE16_MEMBER(l7a1045_sound_device::l7a1045_sound_data_02_w) // upper? word of various registers?
WRITE16_MEMBER(l7a1045_sound_device::sound_data_w)
{
m_audiodat[m_audioregister][m_audiochannel].dat[2] = data;
// if(m_audioregister == 0)
// printf("%04x %04x (%04x|%04x %04x)\n",offset,data,offset ^ 2,m_audioregister,m_audiochannel);
// write with registers 00, 01, 04, 06, 05, 03, 07, 02 on startup
// groups writes of register 0a per channel
m_audiodat[m_audioregister][m_audiochannel].dat[offset] = data;
if(offset == 0)
{
// register 08 / 09 not written?
switch (m_audioregister)
{
default:
case 0x08:
case 0x09:
printf("%08x: unexpected write port 0x0002 register %02x chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audioregister, m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
// case 0x00:
case 0x01:
case 0x04:
case 0x06:
case 0x05:
case 0x03:
case 0x02:
case 0x07:
case 0x0a:
// printf("%08x: write port 0x0002 register %02x chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audioregister, m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
case 0x00:
// hack
l7a1045_voice *vptr = &m_voice[m_audiochannel];
l7a1045_voice *vptr = &m_voice[m_audiochannel];
m_key |= 1 << m_audiochannel;
vptr->frac = 0;
vptr->pos = 0;
vptr->start = (m_audiodat[0][m_audiochannel].dat[0] & 0x000f) << (16 + 4);
vptr->start |= (m_audiodat[0][m_audiochannel].dat[1] & 0xffff) << (4);
vptr->start |= (m_audiodat[0][m_audiochannel].dat[2] & 0xf000) >> (12);
vptr->start = (m_audiodat[0][m_audiochannel].dat[2] & 0x000f) << (16 + 4);
vptr->start |= (m_audiodat[0][m_audiochannel].dat[1] & 0xffff) << (4);
vptr->start |= (m_audiodat[0][m_audiochannel].dat[0] & 0xf000) >> (12);
vptr->start &= m_rom_size - 1;
//printf("%08x: REGISTER 00 write port 0x0002 chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
}
}
WRITE16_MEMBER(l7a1045_sound_device::l7a1045_sound_data_04_w) // lower? word of various registers?
{
m_audiodat[m_audioregister][m_audiochannel].dat[1] = data;
// write with registers 00, 04, 06, 05, 03, 07, 02, 01 on startup
// groups writes of register 0a per channel
// register 08 / 09 not written?
switch (m_audioregister)
{
default:
case 0x08:
case 0x09:
printf("%08x: unexpected write port 0x0004 register %02x chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audioregister, m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
// case 0x00:
case 0x04:
case 0x06:
case 0x05:
case 0x03:
case 0x07:
case 0x01:
case 0x02:
case 0x0a:
//printf("%08x: write port 0x0004 register %02x chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audioregister, m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
case 0x00:
//printf("%08x: REGISTER 00 write port 0x0004 chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
}
}
WRITE16_MEMBER(l7a1045_sound_device::l7a1045_sound_data_06_w) // other part? of various registers.. less used than 02/04, maybe flags?
{
// 00 / 01 written at startup
// nothing else used?
m_audiodat[m_audioregister][m_audiochannel].dat[0] = data;
switch (m_audioregister)
{
default:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x08:
case 0x09:
case 0x0a:
printf("%08x: unexpected write port 0x0006 register %02x chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audioregister, m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
// case 0x00:
case 0x01:
//printf("%08x: unexpected write port 0x0006 register %02x chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audioregister, m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
case 0x00:
// it writes 2 values here for each sample
// the 2nd one seems to contain the upper 4 bits of the sample address
// so why does it write different data first?
//printf("%08x: REGISTER 00 write port 0x0006 chansel %02x data %04x (%04x%04x%04x)\n", space.device().safe_pc(), m_audiochannel, data, m_audiodat[m_audioregister][m_audiochannel].dat[0], m_audiodat[m_audioregister][m_audiochannel].dat[1], m_audiodat[m_audioregister][m_audiochannel].dat[2]);
break;
}
}

View File

@ -15,7 +15,7 @@ struct l7a1045_voice
UINT32 start;
UINT32 pos;
UINT32 frac;
};
// ======================> l7a1045_sound_device
@ -55,10 +55,8 @@ private:
l7a1045_48bit_data m_audiodat[0x10][0x20];
DECLARE_WRITE16_MEMBER(l7a1045_sound_select_w);
DECLARE_WRITE16_MEMBER(l7a1045_sound_data_02_w);
DECLARE_WRITE16_MEMBER(l7a1045_sound_data_04_w);
DECLARE_WRITE16_MEMBER(l7a1045_sound_data_06_w);
DECLARE_WRITE16_MEMBER(sound_select_w);
DECLARE_WRITE16_MEMBER(sound_data_w);
DECLARE_READ16_MEMBER(l7a1045_sound_port_0004_r);
DECLARE_READ16_MEMBER(l7a1045_sound_port_0006_r);