summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ivan Vangelista <mesgnet@yahoo.it>2013-11-03 08:58:11 +0000
committer Ivan Vangelista <mesgnet@yahoo.it>2013-11-03 08:58:11 +0000
commita802f7a99ebe65befdbb0cecff3da5233f51c126 (patch)
tree955a771a4bb07649b283564afbd6526b55483189
parentac82fce12dec34794722a24aa502c65b01cbdb91 (diff)
Modernized the sega005 sound device. (nw)
-rw-r--r--src/mame/audio/segag80r.c125
-rw-r--r--src/mame/includes/segag80r.h36
2 files changed, 78 insertions, 83 deletions
diff --git a/src/mame/audio/segag80r.c b/src/mame/audio/segag80r.c
index 6d5a6254244..49bd46c0c0a 100644
--- a/src/mame/audio/segag80r.c
+++ b/src/mame/audio/segag80r.c
@@ -17,8 +17,6 @@
#include "sound/samples.h"
#include "sound/tms36xx.h"
#include "sound/dac.h"
-#include "devlegcy.h"
-
/*************************************
@@ -30,29 +28,13 @@
#define SEGA005_555_TIMER_FREQ (1.44 / ((15000 + 2 * 4700) * 1.5e-6))
#define SEGA005_COUNTER_FREQ (100000) /* unknown, just a guess */
-class sega005_sound_device : public device_t,
- public device_sound_interface
-{
-public:
- sega005_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
-
- // sound stream update overrides
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-private:
- // internal state
-};
-
-extern const device_type SEGA005;
-
const device_type SEGA005 = &device_creator<sega005_sound_device>;
sega005_sound_device::sega005_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SEGA005, "005 Custom", tag, owner, clock, "sega005_sound", __FILE__),
- device_sound_interface(mconfig, *this)
+ device_sound_interface(mconfig, *this),
+ m_sega005_sound_timer(NULL),
+ m_sega005_stream(NULL)
{
}
@@ -70,10 +52,19 @@ void sega005_sound_device::device_config_complete()
// device_start - device-specific startup
//-------------------------------------------------
-static DEVICE_START( sega005_sound );
void sega005_sound_device::device_start()
{
- DEVICE_START_NAME( sega005_sound )(this);
+ segag80r_state *state = machine().driver_data<segag80r_state>();
+
+ /* create the stream */
+ m_sega005_stream = machine().sound().stream_alloc(*this, 0, 1, SEGA005_COUNTER_FREQ, this);
+
+ /* create a timer for the 555 */
+ m_sega005_sound_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sega005_sound_device::sega005_auto_timer), this));
+
+ /* set the initial sound data */
+ state->m_sound_data = 0x00;
+ state->sega005_update_sound_data();
}
//-------------------------------------------------
@@ -82,8 +73,24 @@ void sega005_sound_device::device_start()
void sega005_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- // should never get here
- fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
+ segag80r_state *state = machine().driver_data<segag80r_state>();
+ const UINT8 *sound_prom = state->memregion("proms")->base();
+ int i;
+
+ /* no implementation yet */
+ for (i = 0; i < samples; i++)
+ {
+ if (!(state->m_sound_state[1] & 0x10) && (++state->m_square_count & 0xff) == 0)
+ {
+ state->m_square_count = sound_prom[state->m_sound_data & 0x1f];
+
+ /* hack - the RC should filter this out */
+ if (state->m_square_count != 0xff)
+ state->m_square_state += 2;
+ }
+
+ outputs[0][i] = (state->m_square_state & 2) ? 0x7fff : 0x0000;
+ }
}
@@ -355,9 +362,6 @@ WRITE8_MEMBER(segag80r_state::astrob_sound_w)
*
*************************************/
-static STREAM_UPDATE( sega005_stream_update );
-static TIMER_CALLBACK( sega005_auto_timer );
-
/*
005
@@ -495,29 +499,28 @@ WRITE8_MEMBER(segag80r_state::sega005_sound_a_w)
}
-INLINE void sega005_update_sound_data(running_machine &machine)
+inline void segag80r_state::sega005_update_sound_data()
{
- segag80r_state *state = machine.driver_data<segag80r_state>();
- UINT8 newval = state->memregion("005")->base()[state->m_sound_addr];
- UINT8 diff = newval ^ state->m_sound_data;
+ UINT8 newval = memregion("005")->base()[m_sound_addr];
+ UINT8 diff = newval ^ m_sound_data;
- //mame_printf_debug(" [%03X] = %02X\n", state->m_sound_addr, newval);
+ //mame_printf_debug(" [%03X] = %02X\n", m_sound_addr, newval);
/* latch the new value */
- state->m_sound_data = newval;
+ m_sound_data = newval;
/* if bit 5 goes high, we reset the timer */
if ((diff & 0x20) && !(newval & 0x20))
{
//mame_printf_debug("Stopping timer\n");
- state->m_sega005_sound_timer->adjust(attotime::never);
+ m_005snd->m_sega005_sound_timer->adjust(attotime::never);
}
/* if bit 5 goes low, we start the timer again */
if ((diff & 0x20) && (newval & 0x20))
{
//mame_printf_debug("Starting timer\n");
- state->m_sega005_sound_timer->adjust(attotime::from_hz(SEGA005_555_TIMER_FREQ), 0, attotime::from_hz(SEGA005_555_TIMER_FREQ));
+ m_005snd->m_sega005_sound_timer->adjust(attotime::from_hz(SEGA005_555_TIMER_FREQ), 0, attotime::from_hz(SEGA005_555_TIMER_FREQ));
}
}
@@ -536,7 +539,7 @@ WRITE8_MEMBER(segag80r_state::sega005_sound_b_w)
//mame_printf_debug("sound[%d] = %02X\n", 1, data);
/* force a stream update */
- m_sega005_stream->update();
+ m_005snd->m_sega005_stream->update();
/* ROM address */
m_sound_addr = ((data & 0x0f) << 7) | (m_sound_addr & 0x7f);
@@ -553,7 +556,7 @@ WRITE8_MEMBER(segag80r_state::sega005_sound_b_w)
m_sound_addr = (m_sound_addr & 0x780) | ((m_sound_addr + 1) & 0x07f);
/* update the sound data */
- sega005_update_sound_data(machine());
+ sega005_update_sound_data();
}
@@ -564,55 +567,17 @@ WRITE8_MEMBER(segag80r_state::sega005_sound_b_w)
*
*************************************/
-static DEVICE_START( sega005_sound )
-{
- segag80r_state *state = device->machine().driver_data<segag80r_state>();
- running_machine &machine = device->machine();
-
- /* create the stream */
- state->m_sega005_stream = device->machine().sound().stream_alloc(*device, 0, 1, SEGA005_COUNTER_FREQ, NULL, sega005_stream_update);
-
- /* create a timer for the 555 */
- state->m_sega005_sound_timer = machine.scheduler().timer_alloc(FUNC(sega005_auto_timer));
-
- /* set the initial sound data */
- state->m_sound_data = 0x00;
- sega005_update_sound_data(machine);
-}
-static STREAM_UPDATE( sega005_stream_update )
+TIMER_CALLBACK_MEMBER( sega005_sound_device::sega005_auto_timer )
{
- segag80r_state *state = device->machine().driver_data<segag80r_state>();
- const UINT8 *sound_prom = state->memregion("proms")->base();
- int i;
-
- /* no implementation yet */
- for (i = 0; i < samples; i++)
- {
- if (!(state->m_sound_state[1] & 0x10) && (++state->m_square_count & 0xff) == 0)
- {
- state->m_square_count = sound_prom[state->m_sound_data & 0x1f];
-
- /* hack - the RC should filter this out */
- if (state->m_square_count != 0xff)
- state->m_square_state += 2;
- }
-
- outputs[0][i] = (state->m_square_state & 2) ? 0x7fff : 0x0000;
- }
-}
-
-
-static TIMER_CALLBACK( sega005_auto_timer )
-{
- segag80r_state *state = machine.driver_data<segag80r_state>();
+ segag80r_state *state = machine().driver_data<segag80r_state>();
/* force an update then clock the sound address if not held in reset */
- state->m_sega005_stream->update();
+ m_sega005_stream->update();
if ((state->m_sound_state[1] & 0x20) && !(state->m_sound_state[1] & 0x10))
{
state->m_sound_addr = (state->m_sound_addr & 0x780) | ((state->m_sound_addr + 1) & 0x07f);
- sega005_update_sound_data(machine);
+ state->sega005_update_sound_data();
}
}
diff --git a/src/mame/includes/segag80r.h b/src/mame/includes/segag80r.h
index cb8670658ca..b850948d642 100644
--- a/src/mame/includes/segag80r.h
+++ b/src/mame/includes/segag80r.h
@@ -10,6 +10,9 @@
#include "sound/sn76496.h"
#include "audio/segasnd.h"
+
+class sega005_sound_device;
+
class segag80r_state : public driver_device
{
public:
@@ -28,7 +31,8 @@ public:
m_audiocpu(*this, "audiocpu"),
m_samples(*this, "samples"),
m_speech(*this, "segaspeech"),
- m_usbsnd(*this, "usbsnd") { }
+ m_usbsnd(*this, "usbsnd"),
+ m_005snd(*this, "005") { }
required_shared_ptr<UINT8> m_mainram;
required_shared_ptr<UINT8> m_videoram;
@@ -40,6 +44,7 @@ public:
optional_device<samples_device> m_samples;
optional_device<speech_sound_device> m_speech;
optional_device<usb_sound_device> m_usbsnd;
+ optional_device<sega005_sound_device> m_005snd;
UINT8 m_sound_state[2];
UINT8 m_sound_rate;
@@ -47,8 +52,6 @@ public:
UINT8 m_sound_data;
UINT8 m_square_state;
UINT8 m_square_count;
- emu_timer *m_sega005_sound_timer;
- sound_stream *m_sega005_stream;
UINT8 m_n7751_command;
UINT8 m_n7751_busy;
segag80_decrypt_func m_decrypt;
@@ -121,6 +124,7 @@ public:
INTERRUPT_GEN_MEMBER(sindbadm_vblank_start);
DECLARE_WRITE8_MEMBER(sega005_sound_a_w);
DECLARE_WRITE8_MEMBER(sega005_sound_b_w);
+ inline void sega005_update_sound_data();
DECLARE_WRITE8_MEMBER(monsterb_sound_a_w);
DECLARE_WRITE8_MEMBER(monsterb_sound_b_w);
DECLARE_READ8_MEMBER(n7751_status_r);
@@ -145,6 +149,32 @@ protected:
/*----------- defined in audio/segag80r.c -----------*/
+
+class sega005_sound_device : public device_t,
+ public device_sound_interface
+{
+public:
+ sega005_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ emu_timer *m_sega005_sound_timer;
+ sound_stream *m_sega005_stream;
+
+protected:
+ // device-level overrides
+ virtual void device_config_complete();
+ virtual void device_start();
+
+ // sound stream update overrides
+ virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
+
+private:
+ // internal state
+ TIMER_CALLBACK_MEMBER( sega005_auto_timer );
+};
+
+extern const device_type SEGA005;
+
+
MACHINE_CONFIG_EXTERN( astrob_sound_board );
MACHINE_CONFIG_EXTERN( 005_sound_board );
MACHINE_CONFIG_EXTERN( spaceod_sound_board );