summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar cam900 <dbtlrchl@naver.com>2019-09-13 23:28:53 +0900
committerGravatarGravatar R. Belmont <rb6502@users.noreply.github.com>2019-09-13 10:28:52 -0400
commitad4e4d1129348c74727bbab5606436f113136e09 (patch) (github)
tree908712a35d19a559dd29ff35168aef1a016dd7ca
parent9eed905eba7c1588332aa1c9388f2e993da931f9 (diff)
downloadmame-ad4e4d1129348c74727bbab5606436f113136e09.tar.bz2
mame-ad4e4d1129348c74727bbab5606436f113136e09.zip
mega32x.cpp : Fix crash in vgmplay (#5624)
-rw-r--r--src/mame/drivers/megadriv.cpp6
-rw-r--r--src/mame/drivers/vgmplay.cpp2
-rw-r--r--src/mame/machine/mega32x.cpp22
-rw-r--r--src/mame/machine/mega32x.h6
4 files changed, 31 insertions, 5 deletions
diff --git a/src/mame/drivers/megadriv.cpp b/src/mame/drivers/megadriv.cpp
index dfb691a7d59..4b84971b561 100644
--- a/src/mame/drivers/megadriv.cpp
+++ b/src/mame/drivers/megadriv.cpp
@@ -614,6 +614,8 @@ void md_cons_state::genesis_32x(machine_config &config)
SEGA_32X_NTSC(config, m_32x, (MASTER_CLOCK_NTSC * 3) / 7, m_maincpu, m_scan_timer);
m_32x->set_screen("megadriv");
+ m_32x->add_route(0, "lspeaker", 1.00);
+ m_32x->add_route(1, "rspeaker", 1.00);
subdevice<screen_device>("megadriv")->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console));
@@ -647,6 +649,8 @@ void md_cons_state::mdj_32x(machine_config &config)
SEGA_32X_NTSC(config, m_32x, (MASTER_CLOCK_NTSC * 3) / 7, m_maincpu, m_scan_timer);
m_32x->set_screen("megadriv");
+ m_32x->add_route(0, "lspeaker", 1.00);
+ m_32x->add_route(1, "rspeaker", 1.00);
subdevice<screen_device>("megadriv")->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console));
@@ -680,6 +684,8 @@ void md_cons_state::md_32x(machine_config &config)
SEGA_32X_PAL(config, m_32x, (MASTER_CLOCK_PAL * 3) / 7, m_maincpu, m_scan_timer);
m_32x->set_screen("megadriv");
+ m_32x->add_route(0, "lspeaker", 1.00);
+ m_32x->add_route(1, "rspeaker", 1.00);
subdevice<screen_device>("megadriv")->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console));
diff --git a/src/mame/drivers/vgmplay.cpp b/src/mame/drivers/vgmplay.cpp
index 66f4e190b4f..1e3f687f712 100644
--- a/src/mame/drivers/vgmplay.cpp
+++ b/src/mame/drivers/vgmplay.cpp
@@ -3644,6 +3644,8 @@ void vgmplay_state::vgmplay(machine_config &config)
/// TODO: rewrite to generate audio without using DAC devices
SEGA_32X_NTSC(config, m_sega32x, 0, "sega32x_maincpu", "sega32x_scanline_timer");
+ m_sega32x->add_route(0, "lspeaker", 1.00);
+ m_sega32x->add_route(1, "rspeaker", 1.00);
auto& sega32x_maincpu(M68000(config, "sega32x_maincpu", 0));
sega32x_maincpu.set_disable();
diff --git a/src/mame/machine/mega32x.cpp b/src/mame/machine/mega32x.cpp
index d1d65e80c3b..42e976beae6 100644
--- a/src/mame/machine/mega32x.cpp
+++ b/src/mame/machine/mega32x.cpp
@@ -225,6 +225,7 @@ DEFINE_DEVICE_TYPE(SEGA_32X_PAL, sega_32x_pal_device, "sega_32x_pal", "Sega 3
sega_32x_device::sega_32x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, device_palette_interface(mconfig, *this)
+ , device_sound_interface(mconfig, *this)
, device_video_interface(mconfig, *this, false)
, m_sh2_shared(*this, "sh2_shared")
, m_main_cpu(*this, finder_base::DUMMY_TAG)
@@ -233,6 +234,7 @@ sega_32x_device::sega_32x_device(const machine_config &mconfig, device_type type
, m_ldac(*this, "ldac")
, m_rdac(*this, "rdac")
, m_scan_timer(*this, finder_base::DUMMY_TAG)
+ , m_stream(nullptr)
{
}
@@ -827,6 +829,7 @@ TIMER_CALLBACK_MEMBER(sega_32x_device::handle_pwm_callback)
{
if (m_lch_size > 0)
{
+ m_stream->update();
switch(m_pwm_ctrl & 3)
{
case 0: /*Speaker OFF*/ break;
@@ -842,6 +845,7 @@ TIMER_CALLBACK_MEMBER(sega_32x_device::handle_pwm_callback)
if (m_rch_size > 0)
{
+ m_stream->update();
switch((m_pwm_ctrl & 0xc) >> 2)
{
case 0: /*Speaker OFF*/ break;
@@ -935,6 +939,15 @@ WRITE16_MEMBER( sega_32x_device::m68k_pwm_w )
pwm_w(space,offset,data,mem_mask);
}
+void sega_32x_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+{
+ for (int s = 0; s < samples; s++)
+ {
+ outputs[0][s] = inputs[0][s];
+ outputs[1][s] = inputs[1][s];
+ }
+}
+
/**********************************************************************************************/
// 68k side a15180
// framebuffer control
@@ -1706,8 +1719,8 @@ void sega_32x_ntsc_device::device_add_mconfig(machine_config &config)
m_master_cpu->set_addrmap(AS_PROGRAM, &sega_32x_ntsc_device::sh2_main_map);
m_slave_cpu->set_addrmap(AS_PROGRAM, &sega_32x_ntsc_device::sh2_slave_map);
- DAC_12BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, ":lspeaker", 0.4); // unknown DAC
- DAC_12BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, ":rspeaker", 0.4); // unknown DAC
+ DAC_12BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, *this, 0.4, 0); // unknown DAC
+ DAC_12BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, *this, 0.4, 1); // unknown DAC
}
void sega_32x_pal_device::device_add_mconfig(machine_config &config)
@@ -1717,8 +1730,8 @@ void sega_32x_pal_device::device_add_mconfig(machine_config &config)
m_master_cpu->set_addrmap(AS_PROGRAM, &sega_32x_pal_device::sh2_main_map);
m_slave_cpu->set_addrmap(AS_PROGRAM, &sega_32x_pal_device::sh2_slave_map);
- DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, ":lspeaker", 0.4); // unknown DAC
- DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, ":rspeaker", 0.4); // unknown DAC
+ DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, *this, 0.4, 0); // unknown DAC
+ DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, *this, 0.4, 1); // unknown DAC
}
@@ -1733,6 +1746,7 @@ void sega_32x_device::device_start()
set_pen_color(i, pal5bit(r), pal5bit(g), pal5bit(b));
}
+ m_stream = stream_alloc(2, 2, 48000 * 4);
m_32x_pwm_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sega_32x_device::handle_pwm_callback), this));
m_32x_dram0 = std::make_unique<uint16_t[]>(0x40000/2);
diff --git a/src/mame/machine/mega32x.h b/src/mame/machine/mega32x.h
index e88dcd41266..d6e80400b92 100644
--- a/src/mame/machine/mega32x.h
+++ b/src/mame/machine/mega32x.h
@@ -14,7 +14,7 @@
#include "emupal.h"
#include "screen.h"
-class sega_32x_device : public device_t, public device_palette_interface, public device_video_interface
+class sega_32x_device : public device_t, public device_palette_interface, public device_sound_interface, public device_video_interface
{
public:
void pause_cpu();
@@ -109,6 +109,9 @@ protected:
// device_palette_interface overrides
virtual uint32_t palette_entries() const override { return 32*32*32/**2*/; }
+ // device_sound_interface overrides
+ virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
+
void update_total_scanlines(bool mode3) { m_total_scanlines = mode3 ? (m_base_total_scanlines * 2) : m_base_total_scanlines; } // this gets set at each EOF
/* our main vblank handler resets this */
@@ -125,6 +128,7 @@ protected:
int m_32x_240mode;
uint16_t m_32x_a1518a_reg;
+ sound_stream *m_stream;
TIMER_CALLBACK_MEMBER(handle_pwm_callback);
void calculate_pwm_timer();
uint16_t m_pwm_ctrl, m_pwm_cycle, m_pwm_tm_reg;