mu80: make the wave rom test pass

This commit is contained in:
Olivier Galibert 2023-10-06 22:48:46 +02:00
parent 7f9a051492
commit a90cc6becd
3 changed files with 66 additions and 15 deletions

View File

@ -17,10 +17,18 @@ swp20_device::swp20_device(const machine_config &mconfig, const char *tag, devic
void swp20_device::device_start()
{
m_stream = stream_alloc(0, 2, 44100);
save_item(NAME(m_sample_address));
}
void swp20_device::device_reset()
{
std::fill(m_sample_address.begin(), m_sample_address.end(), 0);
m_waverom_access = 0;
m_waverom_val = 0;
m_p3c_port = 0x00;
m_p3c_address = true;
m_voice = 0x00;
@ -32,6 +40,16 @@ void swp20_device::map(address_map &map)
{
map(0x00, 0x3f).rw(FUNC(swp20_device::snd_r), FUNC(swp20_device::snd_w));
map(0x01, 0x01).w(FUNC(swp20_device::voice_w));
map(0x2d, 0x2d).rw(FUNC(swp20_device::sample_address_r<2>), FUNC(swp20_device::sample_address_w<2>));
map(0x2e, 0x2e).rw(FUNC(swp20_device::sample_address_r<1>), FUNC(swp20_device::sample_address_w<1>));
map(0x2f, 0x2f).rw(FUNC(swp20_device::sample_address_r<0>), FUNC(swp20_device::sample_address_w<0>));
map(0x37, 0x37).w(FUNC(swp20_device::waverom_access_w));
map(0x3a, 0x3a).r(FUNC(swp20_device::waverom_val_r<1>));
map(0x3b, 0x3b).r(FUNC(swp20_device::waverom_val_r<0>));
map(0x3c, 0x3c).w(FUNC(swp20_device::p3c_w));
}
@ -47,6 +65,35 @@ void swp20_device::map(address_map &map)
// write 40-5f.data
// etc
void swp20_device::voice_w(u8 data)
{
m_voice = data & 0x1f;
}
void swp20_device::waverom_access_w(u8 data)
{
m_waverom_access = data;
}
template<int sel> u8 swp20_device::waverom_val_r()
{
return read_word(m_sample_address[0x1f]*2) >> (8*sel);
}
template<int sel> void swp20_device::sample_address_w(offs_t offset, u8 data)
{
m_stream->update();
m_sample_address[m_voice] = (m_sample_address[m_voice] & ~(0xff << (8*sel))) | (data << (8*sel));
if(!sel)
logerror("sample_address[%02x] = %04x\n", m_voice, m_sample_address[m_voice]);
}
template<int sel> u8 swp20_device::sample_address_r(offs_t offset)
{
return m_sample_address[m_voice] >> (8*sel);
}
void swp20_device::p3c_w(u8 data)
{
if(m_p3c_address)
@ -67,10 +114,6 @@ void swp20_device::snd_w(offs_t offset, u8 data)
{
// Registers 0-f are global, 10-3f per-voice
switch(offset) {
case 0x01:
m_voice = data & 0x1f;
break;
case 0x04: case 0x05: case 0x06: case 0x07: {
int off = 8*(offset & 3);
u32 mask = 0xff << off;
@ -86,12 +129,6 @@ void swp20_device::snd_w(offs_t offset, u8 data)
break;
}
case 0x10: // freq high
break;
case 0x11: // freq low
break;
default:
logerror("w %02x.%02x, %02x %s\n", m_voice, offset, data, machine().describe_context());
}

View File

@ -23,12 +23,26 @@ protected:
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream *m_stream;
std::array<u32, 0x20> m_sample_address;
u16 m_waverom_val;
u8 m_waverom_access;
u8 m_p3c_port;
bool m_p3c_address;
u8 m_voice;
u32 m_keyon;
u32 m_keyoff;
void voice_w(u8 data);
template<int sel> void sample_address_w(offs_t offset, u8 data);
template<int sel> u8 sample_address_r(offs_t offset);
void waverom_access_w(u8 data);
template<int sel> u8 waverom_val_r();
// Generic upload port
void p3c_w(u8 data);

View File

@ -366,11 +366,11 @@ ROM_START( mu80 )
ROM_REGION( 0x80000, "mu80cpu", 0 )
ROM_LOAD16_WORD_SWAP( "yamaha_mu80.bin", 0x000000, 0x080000, CRC(c31074c0) SHA1(a11bd4523cd8ff1e1744078c3b4c18112b73c61e) )
ROM_REGION16_LE( 0x2000000, "swp20", ROMREGION_ERASE00 )
ROM_LOAD( "xq012b0-822.bin", 0x1c00000, 0x200000, CRC(cb454418) SHA1(43dab164de5497df9203a1ac9e7ece478276e46d))
ROM_LOAD( "xq013b0-823.bin", 0x1a00000, 0x200000, CRC(f14117b4) SHA1(fc603b7b7a3f3500521d4d9638a9562f90cc0354))
ROM_LOAD( "xq089b0-824.bin", 0x1600000, 0x200000, CRC(0adbf203) SHA1(ecc4c1cfb123d12bc3dad092c31bddc707bb4d07))
ROM_LOAD( "xq090b0-825.bin", 0x0e00000, 0x200000, CRC(34c422b3) SHA1(14073c41fbdf4faa9da9c83dafe4dc2d6b01b53b))
ROM_REGION16_LE( 0x800000, "swp20", 0 )
ROM_LOAD( "xq012b0-822.bin", 0x000000, 0x200000, CRC(cb454418) SHA1(43dab164de5497df9203a1ac9e7ece478276e46d))
ROM_LOAD( "xq013b0-823.bin", 0x200000, 0x200000, CRC(f14117b4) SHA1(fc603b7b7a3f3500521d4d9638a9562f90cc0354))
ROM_LOAD( "xq089b0-824.bin", 0x400000, 0x200000, CRC(0adbf203) SHA1(ecc4c1cfb123d12bc3dad092c31bddc707bb4d07))
ROM_LOAD( "xq090b0-825.bin", 0x600000, 0x200000, CRC(34c422b3) SHA1(14073c41fbdf4faa9da9c83dafe4dc2d6b01b53b))
ROM_END
} // anonymous namespace