(MESS) svision: handling sound IRQ via a device delegate allows

to finally untangle the sound device from the main state. also given
the sound device its own .h file. nw.
This commit is contained in:
Fabio Priuli 2014-10-12 06:37:59 +00:00
parent 1281a5a7fd
commit 5654fcee2b
6 changed files with 184 additions and 180 deletions

3
.gitattributes vendored
View File

@ -8048,7 +8048,8 @@ src/mess/audio/socrates.c svneol=native#text/plain
src/mess/audio/socrates.h svneol=native#text/plain
src/mess/audio/specimx_snd.c svneol=native#text/plain
src/mess/audio/specimx_snd.h svneol=native#text/plain
src/mess/audio/svision.c svneol=native#text/plain
src/mess/audio/svis_snd.c svneol=native#text/plain
src/mess/audio/svis_snd.h svneol=native#text/plain
src/mess/audio/tvc_snd.c svneol=native#text/plain
src/mess/audio/tvc_snd.h svneol=native#text/plain
src/mess/audio/upd1771.c svneol=native#text/plain

View File

@ -5,11 +5,11 @@
***************************************************************************/
#include "emu.h"
#include "includes/svision.h"
#include "svis_snd.h"
// device type definition
const device_type SVISION = &device_creator<svision_sound_device>;
const device_type SVISION_SND = &device_creator<svision_sound_device>;
//**************************************************************************
@ -21,7 +21,7 @@ const device_type SVISION = &device_creator<svision_sound_device>;
//-------------------------------------------------
svision_sound_device::svision_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SVISION, "Super Vision Audio Custom", tag, owner, clock, "svision_sound", __FILE__),
: device_t(mconfig, SVISION_SND, "Super Vision Audio Custom", tag, owner, clock, "svision_sound", __FILE__),
device_sound_interface(mconfig, *this),
m_mixer_channel(NULL)
{
@ -34,6 +34,9 @@ svision_sound_device::svision_sound_device(const machine_config &mconfig, const
void svision_sound_device::device_start()
{
// bind callbacks
m_irq_cb.bind_relative_to(*owner());
memset(&m_dma, 0, sizeof(m_dma));
memset(&m_noise, 0, sizeof(m_noise));
memset(m_channel, 0, sizeof(m_channel));
@ -146,17 +149,16 @@ void svision_sound_device::sound_stream_update(sound_stream &stream, stream_samp
m_dma.pos += m_dma.step;
if (m_dma.pos >= m_dma.size)
{
svision_state *sv_state = machine().driver_data<svision_state>();
m_dma.finished = TRUE;
m_dma.on = FALSE;
sv_state->svision_irq();
m_irq_cb();
}
}
}
}
WRITE8_MEMBER( svision_sound_device::svision_sounddma_w )
WRITE8_MEMBER( svision_sound_device::sounddma_w )
{
logerror("%.6f svision snddma write %04x %02x\n", space.machine().time().as_double(),offset+0x18,data);
m_dma.reg[offset] = data;
@ -186,7 +188,7 @@ WRITE8_MEMBER( svision_sound_device::svision_sounddma_w )
}
WRITE8_MEMBER( svision_sound_device::svision_noise_w )
WRITE8_MEMBER( svision_sound_device::noise_w )
{
// logerror("%.6f svision noise write %04x %02x\n",machine.time(),offset+0x28,data);
m_noise.reg[offset]=data;

140
src/mess/audio/svis_snd.h Normal file
View File

@ -0,0 +1,140 @@
/*****************************************************************************
*
* svis_snd.h
*
****************************************************************************/
#ifndef SVIS_SND_H_
#define SVIS_SND_H_
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
enum SVISION_NOISE_Type
{
SVISION_NOISE_Type7Bit,
SVISION_NOISE_Type14Bit
};
struct SVISION_NOISE
{
SVISION_NOISE() :
on(0),
right(0),
left(0),
play(0),
type(SVISION_NOISE_Type7Bit),
state(0),
volume(0),
count(0),
step(0.0),
pos(0.0),
value(0)
{
memset(reg, 0, sizeof(UINT8)*3);
}
UINT8 reg[3];
int on, right, left, play;
SVISION_NOISE_Type type;
int state;
int volume;
int count;
double step, pos;
int value; // currently simple random function
};
struct SVISION_DMA
{
SVISION_DMA() :
on(0),
right(0),
left(0),
ca14to16(0),
start(0),
size(0),
pos(0.0),
step(0.0),
finished(0)
{
memset(reg, 0, sizeof(UINT8)*5);
}
UINT8 reg[5];
int on, right, left;
int ca14to16;
int start,size;
double pos, step;
int finished;
};
struct SVISION_CHANNEL
{
SVISION_CHANNEL() :
on(0),
waveform(0),
volume(0),
pos(0),
size(0),
count(0)
{
memset(reg, 0, sizeof(UINT8)*4);
}
UINT8 reg[4];
int on;
int waveform, volume;
int pos;
int size;
int count;
};
typedef device_delegate<void (void)> svision_snd_irq_delegate;
#define SVISION_SND_IRQ_MEMBER(_name) void _name(void)
#define SVISION_SND_IRQ_CB(_class, _method) \
svision_sound_device::set_irq_callback(*device, svision_snd_irq_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
// ======================> svision_sound_device
class svision_sound_device : public device_t,
public device_sound_interface
{
public:
svision_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~svision_sound_device() { }
// static configuration
static void set_irq_callback(device_t &device, svision_snd_irq_delegate callback) { downcast<svision_sound_device &>(device).m_irq_cb = callback; }
protected:
// device-level overrides
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);
public:
DECLARE_WRITE8_MEMBER( sounddma_w );
DECLARE_WRITE8_MEMBER( noise_w );
public:
int *dma_finished();
void sound_decrement();
void soundport_w(int which, int offset, int data);
private:
svision_snd_irq_delegate m_irq_cb;
sound_stream *m_mixer_channel;
SVISION_DMA m_dma;
SVISION_NOISE m_noise;
SVISION_CHANNEL m_channel[2];
};
extern const device_type SVISION_SND;
#endif /* SVIS_SND_H_ */

View File

@ -5,7 +5,6 @@
******************************************************************************/
#include "emu.h"
#include "includes/svision.h"
#include "svision.lh"
@ -172,11 +171,11 @@ WRITE8_MEMBER(svision_state::svision_w)
break;
case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c:
m_sound->svision_sounddma_w(space, offset - 0x18, data);
m_sound->sounddma_w(space, offset - 0x18, data);
break;
case 0x28: case 0x29: case 0x2a:
m_sound->svision_noise_w(space, offset - 0x28, data);
m_sound->noise_w(space, offset - 0x28, data);
break;
default:
@ -255,21 +254,21 @@ WRITE8_MEMBER(svision_state::tvlink_w)
}
static ADDRESS_MAP_START( svision_mem , AS_PROGRAM, 8, svision_state )
AM_RANGE( 0x0000, 0x1fff) AM_RAM
AM_RANGE( 0x2000, 0x3fff) AM_READWRITE(svision_r, svision_w) AM_SHARE("reg")
AM_RANGE( 0x4000, 0x5fff) AM_RAM AM_SHARE("videoram")
AM_RANGE( 0x6000, 0x7fff) AM_NOP
AM_RANGE( 0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE( 0xc000, 0xffff) AM_ROMBANK("bank2")
AM_RANGE(0x0000, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x3fff) AM_READWRITE(svision_r, svision_w) AM_SHARE("reg")
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_SHARE("videoram")
AM_RANGE(0x6000, 0x7fff) AM_NOP
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xffff) AM_ROMBANK("bank2")
ADDRESS_MAP_END
static ADDRESS_MAP_START( tvlink_mem , AS_PROGRAM, 8, svision_state )
AM_RANGE( 0x0000, 0x1fff) AM_RAM
AM_RANGE( 0x2000, 0x3fff) AM_READWRITE(tvlink_r, tvlink_w) AM_SHARE("reg")
AM_RANGE( 0x4000, 0x5fff) AM_RAM AM_SHARE("videoram")
AM_RANGE( 0x6000, 0x7fff) AM_NOP
AM_RANGE( 0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE( 0xc000, 0xffff) AM_ROMBANK("bank2")
AM_RANGE(0x0000, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x3fff) AM_READWRITE(tvlink_r, tvlink_w) AM_SHARE("reg")
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_SHARE("videoram")
AM_RANGE(0x6000, 0x7fff) AM_NOP
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xffff) AM_ROMBANK("bank2")
ADDRESS_MAP_END
static INPUT_PORTS_START( svision )
@ -351,27 +350,18 @@ static const unsigned char svisionn_palette[] =
PALETTE_INIT_MEMBER(svision_state, svision)
{
int i;
for( i = 0; i < sizeof(svision_palette) / 3; i++ ) {
palette.set_pen_color(i, svision_palette[i*3], svision_palette[i*3+1], svision_palette[i*3+2] );
}
for (int i = 0; i < sizeof(svision_palette) / 3; i++)
palette.set_pen_color(i, svision_palette[i*3], svision_palette[i*3+1], svision_palette[i*3+2]);
}
PALETTE_INIT_MEMBER(svision_state,svisionn)
{
int i;
for ( i = 0; i < sizeof(svisionn_palette) / 3; i++ ) {
palette.set_pen_color(i, svisionn_palette[i*3], svisionn_palette[i*3+1], svisionn_palette[i*3+2] );
}
for (int i = 0; i < sizeof(svisionn_palette) / 3; i++)
palette.set_pen_color(i, svisionn_palette[i*3], svisionn_palette[i*3+1], svisionn_palette[i*3+2]);
}
PALETTE_INIT_MEMBER(svision_state,svisionp)
{
int i;
for ( i = 0; i < sizeof(svisionn_palette) / 3; i++ ) {
palette.set_pen_color(i, svisionp_palette[i*3], svisionp_palette[i*3+1], svisionp_palette[i*3+2] );
}
for (int i = 0; i < sizeof(svisionn_palette) / 3; i++)
palette.set_pen_color(i, svisionp_palette[i*3], svisionp_palette[i*3+1], svisionp_palette[i*3+2]);
}
UINT32 svision_state::screen_update_svision(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
@ -438,24 +428,22 @@ UINT32 svision_state::screen_update_tvlink(screen_device &screen, bitmap_rgb32 &
INTERRUPT_GEN_MEMBER(svision_state::svision_frame_int)
{
if (BANK&1)
if (BANK & 1)
device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
m_sound->sound_decrement();
}
DRIVER_INIT_MEMBER(svision_state,svision)
DRIVER_INIT_MEMBER(svision_state, svision)
{
m_svision.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_timer),this));
m_sound = machine().device<svision_sound_device>("custom");
m_dma_finished = m_sound->dma_finished();
m_pet.on = FALSE;
}
DRIVER_INIT_MEMBER(svision_state,svisions)
DRIVER_INIT_MEMBER(svision_state, svisions)
{
m_svision.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_timer),this));
m_sound = machine().device<svision_sound_device>("custom");
m_dma_finished = m_sound->dma_finished();
m_pet.on = TRUE;
m_pet.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_pet_timer),this));
@ -534,9 +522,10 @@ static MACHINE_CONFIG_START( svision, svision_state )
/* sound hardware */
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD("custom", SVISION, 0)
MCFG_SOUND_ADD("custom", SVISION_SND, 0)
MCFG_SOUND_ROUTE(0, "lspeaker", 0.50)
MCFG_SOUND_ROUTE(1, "rspeaker", 0.50)
SVISION_SND_IRQ_CB(svision_state, svision_irq)
/* cartridge */
MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "svision_cart")
@ -545,7 +534,7 @@ static MACHINE_CONFIG_START( svision, svision_state )
MCFG_GENERIC_LOAD(svision_state, svision_cart)
/* Software lists */
MCFG_SOFTWARE_LIST_ADD("cart_list","svision")
MCFG_SOFTWARE_LIST_ADD("cart_list", "svision")
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( svisions, svision )
@ -558,7 +547,7 @@ static MACHINE_CONFIG_DERIVED( svisionp, svision )
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_REFRESH_RATE(50)
MCFG_PALETTE_MODIFY("palette")
MCFG_PALETTE_INIT_OWNER(svision_state, svisionp )
MCFG_PALETTE_INIT_OWNER(svision_state, svisionp)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( svisionn, svision )
@ -567,14 +556,14 @@ static MACHINE_CONFIG_DERIVED( svisionn, svision )
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_REFRESH_RATE(60)
MCFG_PALETTE_MODIFY("palette")
MCFG_PALETTE_INIT_OWNER(svision_state, svisionn )
MCFG_PALETTE_INIT_OWNER(svision_state, svisionn)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( tvlinkp, svisionp )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(tvlink_mem)
MCFG_MACHINE_RESET_OVERRIDE(svision_state, tvlink )
MCFG_MACHINE_RESET_OVERRIDE(svision_state, tvlink)
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_NO_PALETTE

View File

@ -8,6 +8,7 @@
#define SVISION_H_
#include "cpu/m6502/m65c02.h"
#include "audio/svis_snd.h"
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"
@ -31,14 +32,13 @@ struct tvlink_t
int palette_on;
};
class svision_sound_device; // defined below
class svision_state : public driver_device
{
public:
svision_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_sound(*this, "custom"),
m_cart(*this, "cartslot"),
m_reg(*this, "reg"),
m_videoram(*this, "videoram"),
@ -46,7 +46,6 @@ public:
m_joy2(*this, "JOY2"),
m_palette(*this, "palette") { }
svision_sound_device *m_sound;
int *m_dma_finished;
svision_t m_svision;
svision_pet_t m_pet;
@ -75,6 +74,7 @@ public:
protected:
required_device<cpu_device> m_maincpu;
required_device<svision_sound_device> m_sound;
required_device<generic_slot_device> m_cart;
required_shared_ptr<UINT8> m_reg;
required_shared_ptr<UINT8> m_videoram;
@ -87,132 +87,4 @@ protected:
memory_bank *m_bank2;
};
/*----------- defined in drivers/svision.c -----------*/
void svision_irq( running_machine &machine );
/*----------- defined in audio/svision.c -----------*/
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
enum SVISION_NOISE_Type
{
SVISION_NOISE_Type7Bit,
SVISION_NOISE_Type14Bit
};
struct SVISION_NOISE
{
SVISION_NOISE() :
on(0),
right(0),
left(0),
play(0),
type(SVISION_NOISE_Type7Bit),
state(0),
volume(0),
count(0),
step(0.0),
pos(0.0),
value(0)
{
memset(reg, 0, sizeof(UINT8)*3);
}
UINT8 reg[3];
int on, right, left, play;
SVISION_NOISE_Type type;
int state;
int volume;
int count;
double step, pos;
int value; // currently simple random function
};
struct SVISION_DMA
{
SVISION_DMA() :
on(0),
right(0),
left(0),
ca14to16(0),
start(0),
size(0),
pos(0.0),
step(0.0),
finished(0)
{
memset(reg, 0, sizeof(UINT8)*5);
}
UINT8 reg[5];
int on, right, left;
int ca14to16;
int start,size;
double pos, step;
int finished;
};
struct SVISION_CHANNEL
{
SVISION_CHANNEL() :
on(0),
waveform(0),
volume(0),
pos(0),
size(0),
count(0)
{
memset(reg, 0, sizeof(UINT8)*4);
}
UINT8 reg[4];
int on;
int waveform, volume;
int pos;
int size;
int count;
};
// ======================> svision_sound_device
class svision_sound_device : public device_t,
public device_sound_interface
{
public:
svision_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~svision_sound_device() { }
protected:
// device-level overrides
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);
public:
DECLARE_WRITE8_MEMBER( svision_sounddma_w );
DECLARE_WRITE8_MEMBER( svision_noise_w );
public:
int *dma_finished();
void sound_decrement();
void soundport_w(int which, int offset, int data);
private:
sound_stream *m_mixer_channel;
SVISION_DMA m_dma;
SVISION_NOISE m_noise;
SVISION_CHANNEL m_channel[2];
};
extern const device_type SVISION;
#endif /* SVISION_H_ */

View File

@ -1640,7 +1640,7 @@ $(MESSOBJ)/svi.a: \
$(MESS_DRIVERS)/svi318.o $(MESS_MACHINE)/svi318.o \
$(MESSOBJ)/svision.a: \
$(MESS_DRIVERS)/svision.o $(MESS_AUDIO)/svision.o \
$(MESS_DRIVERS)/svision.o $(MESS_AUDIO)/svis_snd.o \
$(MESSOBJ)/swtpc09.a: \
$(MESS_DRIVERS)/swtpc09.o $(MESS_MACHINE)/swtpc09.o \