diff options
author | R. Belmont <rb6502@users.noreply.github.com> | 2019-03-31 17:00:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-31 17:00:05 -0400 |
commit | 104e42014ed5f78c6d9cdfe09deba8e0f02f4708 (patch) | |
tree | f8973d79fb8482a9bb55b2a20645fea946b1b433 | |
parent | 88d055a065b17e1f09eb03e768d6908495a49920 (diff) | |
parent | 6a96ec51913434e1edd46d6e49ece928a882eb18 (diff) |
ymf278b.cpp : Add DO1/2 Output, Fix buffer when clock is changed (#3806)
* ymf278b.cpp : Add DO1/2 Output, Fix timer/buffer when clock is changed
fuukifg3.h : Remove unused clock
* ymf278b.cpp : Fix sync
* ymf278b.cpp : Add notes
-rw-r--r-- | src/devices/bus/msx_cart/moonsound.cpp | 7 | ||||
-rw-r--r-- | src/devices/sound/ymf278b.cpp | 44 | ||||
-rw-r--r-- | src/devices/sound/ymf278b.h | 3 | ||||
-rw-r--r-- | src/mame/drivers/fuukifg3.cpp | 6 | ||||
-rw-r--r-- | src/mame/includes/fuukifg3.h | 1 |
5 files changed, 46 insertions, 15 deletions
diff --git a/src/devices/bus/msx_cart/moonsound.cpp b/src/devices/bus/msx_cart/moonsound.cpp index e01498c57bc..d6b62f81347 100644 --- a/src/devices/bus/msx_cart/moonsound.cpp +++ b/src/devices/bus/msx_cart/moonsound.cpp @@ -41,15 +41,18 @@ void msx_cart_moonsound_device::device_add_mconfig(machine_config &config) // The moonsound cartridge has a separate stereo output. SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); + YMF278B(config, m_ymf278b, YMF278B_STD_CLOCK); m_ymf278b->set_addrmap(0, &msx_cart_moonsound_device::ymf278b_map); m_ymf278b->irq_handler().set(FUNC(msx_cart_moonsound_device::irq_w)); m_ymf278b->add_route(0, "lspeaker", 0.50); m_ymf278b->add_route(1, "rspeaker", 0.50); - m_ymf278b->add_route(2, "lspeaker", 0.40); - m_ymf278b->add_route(3, "rspeaker", 0.40); + m_ymf278b->add_route(2, "lspeaker", 0.50); + m_ymf278b->add_route(3, "rspeaker", 0.50); m_ymf278b->add_route(4, "lspeaker", 0.40); m_ymf278b->add_route(5, "rspeaker", 0.40); + m_ymf278b->add_route(6, "lspeaker", 0.40); + m_ymf278b->add_route(7, "rspeaker", 0.40); } diff --git a/src/devices/sound/ymf278b.cpp b/src/devices/sound/ymf278b.cpp index c25b519ae4e..2ccab0f0420 100644 --- a/src/devices/sound/ymf278b.cpp +++ b/src/devices/sound/ymf278b.cpp @@ -50,6 +50,8 @@ #include "ymf278b.h" #include "ymf262.h" +#include <algorithm> + #define VERBOSE 0 #define LOG(x) do { if (VERBOSE) logerror x; } while (0) @@ -221,11 +223,12 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t * if (&stream == m_stream_ymf262) { + // TODO : FM only output is DO0, DO2 is actually mixed FM+PCM outputs ymf262_update_one(m_ymf262, outputs, samples); return; } - memset(m_mix_buffer.get(), 0, sizeof(m_mix_buffer[0])*samples*2); + std::fill(m_mix_buffer.begin(), m_mix_buffer.end(), 0); for (i = 0; i < 24; i++) { @@ -233,7 +236,7 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t * if (slot->active) { - mixp = m_mix_buffer.get(); + mixp = &m_mix_buffer[0]; for (j = 0; j < samples; j++) { @@ -274,8 +277,20 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t * break; } - *mixp++ += (sample * m_volume[slot->TL+m_pan_left [slot->pan]+(slot->env_vol>>23)])>>17; - *mixp++ += (sample * m_volume[slot->TL+m_pan_right[slot->pan]+(slot->env_vol>>23)])>>17; + if (slot->CH) // DO1 out + { + mixp++; + mixp++; + *mixp++ += (sample * m_volume[slot->TL+m_pan_left [slot->pan]+(slot->env_vol>>23)])>>17; + *mixp++ += (sample * m_volume[slot->TL+m_pan_right[slot->pan]+(slot->env_vol>>23)])>>17; + } + else // DO2 out + { + *mixp++ += (sample * m_volume[slot->TL+m_pan_left [slot->pan]+(slot->env_vol>>23)])>>17; + *mixp++ += (sample * m_volume[slot->TL+m_pan_right[slot->pan]+(slot->env_vol>>23)])>>17; + mixp++; + mixp++; + } // update frequency slot->stepptr += slot->step; @@ -293,13 +308,15 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t * } } - mixp = m_mix_buffer.get(); + mixp = &m_mix_buffer[0]; vl = m_mix_level[m_pcm_l]; vr = m_mix_level[m_pcm_r]; for (i = 0; i < samples; i++) { outputs[0][i] = (*mixp++ * vl) >> 16; outputs[1][i] = (*mixp++ * vr) >> 16; + outputs[2][i] = *mixp++; + outputs[3][i] = *mixp++; } } @@ -780,6 +797,7 @@ u8 ymf278b_device::read(offs_t offset) //------------------------------------------------- // device_post_load - device-specific post load //------------------------------------------------- + void ymf278b_device::device_post_load() { ymf262_post_load(m_ymf262); @@ -851,9 +869,16 @@ void ymf278b_device::device_stop() void ymf278b_device::device_clock_changed() { - m_stream->set_sample_rate(clock()/768); - + int old_rate = m_rate; m_clock = clock(); + m_rate = m_clock/768; + + if (m_rate > old_rate) + { + m_mix_buffer.resize(m_rate*4,0); + } + m_stream->set_sample_rate(m_rate); + m_timer_base = m_clock ? attotime::from_hz(m_clock) * (19 * 36) : attotime::zero; // YMF262 related @@ -969,6 +994,7 @@ void ymf278b_device::device_start() int i; m_clock = clock(); + m_rate = m_clock / 768; m_irq_handler.resolve(); m_timer_base = m_clock ? attotime::from_hz(m_clock) * (19*36) : attotime::zero; @@ -982,8 +1008,8 @@ void ymf278b_device::device_start() m_slots[i].num = i; } - m_stream = machine().sound().stream_alloc(*this, 0, 2, clock()/768); - m_mix_buffer = std::make_unique<int32_t[]>(44100*2); + m_stream = machine().sound().stream_alloc(*this, 0, 4, m_rate); + m_mix_buffer.resize(m_rate*4,0); // rate tables precompute_rate_tables(); diff --git a/src/devices/sound/ymf278b.h b/src/devices/sound/ymf278b.h index 480397c1d0c..d0f9fb1e879 100644 --- a/src/devices/sound/ymf278b.h +++ b/src/devices/sound/ymf278b.h @@ -127,9 +127,10 @@ private: emu_timer *m_timer_a, *m_timer_b; int m_clock; + int m_rate; sound_stream * m_stream; - std::unique_ptr<int32_t[]> m_mix_buffer; + std::vector<int32_t> m_mix_buffer; devcb_write_line m_irq_handler; uint8_t m_last_fm_data; diff --git a/src/mame/drivers/fuukifg3.cpp b/src/mame/drivers/fuukifg3.cpp index 531b49c1a63..035aa15cb57 100644 --- a/src/mame/drivers/fuukifg3.cpp +++ b/src/mame/drivers/fuukifg3.cpp @@ -545,10 +545,12 @@ void fuuki32_state::fuuki32(machine_config &config) ymf.irq_handler().set_inputline("soundcpu", 0); ymf.add_route(0, "lspeaker", 0.50); ymf.add_route(1, "rspeaker", 0.50); - ymf.add_route(2, "lspeaker", 0.40); - ymf.add_route(3, "rspeaker", 0.40); + ymf.add_route(2, "lspeaker", 0.50); + ymf.add_route(3, "rspeaker", 0.50); ymf.add_route(4, "lspeaker", 0.40); ymf.add_route(5, "rspeaker", 0.40); + ymf.add_route(6, "lspeaker", 0.40); + ymf.add_route(7, "rspeaker", 0.40); } /*************************************************************************** diff --git a/src/mame/includes/fuukifg3.h b/src/mame/includes/fuukifg3.h index 9f0293fc7de..cb354e07506 100644 --- a/src/mame/includes/fuukifg3.h +++ b/src/mame/includes/fuukifg3.h @@ -13,7 +13,6 @@ #define CPU_CLOCK (XTAL(40'000'000) / 2) /* clock for 68020 */ #define SOUND_CPU_CLOCK (XTAL(12'000'000) / 2) /* clock for Z80 sound CPU */ -#define FM_SOUND_CLOCK (XTAL(33'868'800) / 2) /* FM clock */ /* NOTE: YMF278B_STD_CLOCK is defined in /src/emu/sound/ymf278b.h */ |