From 451f2b6a97831c0d40ee1b44edd41b79328a0ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Banaan=20Ananas?= Date: Fri, 21 Feb 2014 20:03:05 +0000 Subject: [PATCH] implemented volume, taitognet sounds pretty good now, still need to find out why taitofx1b sound sucks compared to it, especially raystorm --- src/emu/sound/zsg2.c | 27 ++++++++++++++------------- src/emu/sound/zsg2.h | 1 + src/mame/audio/taito_zm.c | 16 +++++++++++----- src/mame/audio/taito_zm.h | 1 + 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/emu/sound/zsg2.c b/src/emu/sound/zsg2.c index 0112c82c98b..cc143f31cc5 100644 --- a/src/emu/sound/zsg2.c +++ b/src/emu/sound/zsg2.c @@ -44,13 +44,11 @@ --------------------------------------------------------- -Emulation is still preliminary. - TODO: -- channel volume, 16bits?? need to make a lookup table? -- some samples are in stereo format? +- volume/panning is linear? +- what is reg 0xa/0xc? seems related to volume +- identify sample flags - memory reads out of range sometimes -- a lot of unknowns */ @@ -110,6 +108,7 @@ void zsg2_device::device_start() save_item(NAME(m_chan[ch].loop_pos), ch); save_item(NAME(m_chan[ch].page), ch); save_item(NAME(m_chan[ch].vol), ch); + save_item(NAME(m_chan[ch].flags), ch); save_item(NAME(m_chan[ch].panl), ch); save_item(NAME(m_chan[ch].panr), ch); } @@ -217,17 +216,14 @@ void zsg2_device::sound_stream_update(sound_stream &stream, stream_sample_t **in m_chan[ch].samples = prepare_samples(m_chan[ch].page | m_chan[ch].cur_pos); } - INT16 sample = m_chan[ch].samples[m_chan[ch].step_ptr >> 16 & 3]; - - //sample = (sample * (m_chan[ch].vol & 0xffff)) / 0x10000; - if (m_chan[ch].vol == 0) sample = 0; // temp hack to prevent stuck notes + INT32 sample = (m_chan[ch].samples[m_chan[ch].step_ptr >> 16 & 3] * m_chan[ch].vol) >> 16; mix_l += (sample * m_chan[ch].panl + sample * (0x1f - m_chan[ch].panr)) >> 5; mix_r += (sample * m_chan[ch].panr + sample * (0x1f - m_chan[ch].panl)) >> 5; } - outputs[0][i] = mix_l / 48; - outputs[1][i] = mix_r / 48; + outputs[0][i] = mix_l; + outputs[1][i] = mix_r; } } @@ -293,10 +289,15 @@ void zsg2_device::chan_w(int ch, int reg, UINT16 data) break; case 0xe: - // channel volume, reg 0xa/0xc is also related? + // volume m_chan[ch].vol = data; break; + case 0xf: + // flags + m_chan[ch].flags = data; + break; + default: break; } @@ -346,7 +347,7 @@ void zsg2_device::control_w(int reg, UINT16 data) case 0x04: case 0x05: case 0x06: { - // key off? + // key off int base = (reg & 3) << 4; for (int i = 0; i < 16; i++) { diff --git a/src/emu/sound/zsg2.h b/src/emu/sound/zsg2.h index 4bc7a916c13..5040c5e5370 100644 --- a/src/emu/sound/zsg2.h +++ b/src/emu/sound/zsg2.h @@ -59,6 +59,7 @@ private: UINT32 loop_pos; UINT32 page; UINT16 vol; + UINT16 flags; UINT8 panl; UINT8 panr; }; diff --git a/src/mame/audio/taito_zm.c b/src/mame/audio/taito_zm.c index 4e505326232..3e0554f78d6 100644 --- a/src/mame/audio/taito_zm.c +++ b/src/mame/audio/taito_zm.c @@ -24,9 +24,8 @@ and a Zoom Corp. ZFX-2 DSP instead of the TMS57002. TODO: -- add TMS57002 -- global volume regs -- a lot more +- add DSP, sound is tinny without it +- howcome taito fx1b sounds worse than gnet? especially raystorm ***************************************************************************/ @@ -44,6 +43,7 @@ const device_type TAITO_ZOOM = &device_creator; taito_zoom_device::taito_zoom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, TAITO_ZOOM, "Taito Zoom Sound System", tag, owner, clock, "taito_zoom", __FILE__), m_soundcpu(*this, ":mn10200"), + m_zsg2(*this, ":zsg2"), m_reg_address(0), m_tms_ctrl(0) { @@ -143,11 +143,17 @@ WRITE16_MEMBER(taito_zoom_device::reg_data_w) switch (m_reg_address) { case 0x04: - // zsg2+dsp global volume ch0 + // zsg2+dsp global volume left + if (data & 0xc0c0) + popmessage("ZOOM gain L %04X, contact MAMEdev", data); + m_zsg2->set_output_gain(0, (data & 0x3f) / 63.0); break; case 0x05: - // zsg2+dsp global volume ch1 + // zsg2+dsp global volume right + if (data & 0xc0c0) + popmessage("ZOOM gain R %04X, contact MAMEdev", data); + m_zsg2->set_output_gain(1, (data & 0x3f) / 63.0); break; default: diff --git a/src/mame/audio/taito_zm.h b/src/mame/audio/taito_zm.h index 5e1ced97615..9604f8319fe 100644 --- a/src/mame/audio/taito_zm.h +++ b/src/mame/audio/taito_zm.h @@ -30,6 +30,7 @@ private: // devices/pointers required_device m_soundcpu; + required_device m_zsg2; // internal state UINT16 m_reg_address;