Modernized Sega Speech and Sega USB devices. (nw)

This commit is contained in:
Ivan Vangelista 2013-10-24 19:31:15 +00:00
parent 141c1a7c69
commit e6a9c934a0
7 changed files with 707 additions and 646 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,17 +6,192 @@
*************************************************************************/
#include "cpu/mcs48/mcs48.h"
class speech_sound_device : public device_t,
public device_sound_interface
{
public:
speech_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~speech_sound_device() {}
DECLARE_WRITE8_MEMBER( data_w );
DECLARE_WRITE8_MEMBER( control_w );
DECLARE_READ8_MEMBER( t0_r );
DECLARE_READ8_MEMBER( t1_r );
DECLARE_READ8_MEMBER( p1_r );
DECLARE_READ8_MEMBER( rom_r );
DECLARE_WRITE8_MEMBER( p1_w );
DECLARE_WRITE8_MEMBER( p2_w );
static void drq_w(device_t *device, int level);
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
UINT8 m_drq;
UINT8 m_latch;
UINT8 m_t0;
UINT8 m_p2;
UINT8 *m_speech;
TIMER_CALLBACK_MEMBER( delayed_speech_w );
};
extern const device_type SEGASPEECH;
MACHINE_CONFIG_EXTERN( sega_speech_board );
DECLARE_WRITE8_DEVICE_HANDLER( sega_speech_data_w );
DECLARE_WRITE8_DEVICE_HANDLER( sega_speech_control_w );
MACHINE_CONFIG_EXTERN( sega_universal_sound_board );
MACHINE_CONFIG_EXTERN( sega_universal_sound_board_rom );
struct filter_state
{
filter_state():
capval(0),
exponent(0) {}
double capval; /* current capacitor value */
double exponent; /* constant exponent */
};
DECLARE_READ8_DEVICE_HANDLER( sega_usb_status_r );
DECLARE_WRITE8_DEVICE_HANDLER( sega_usb_data_w );
DECLARE_READ8_DEVICE_HANDLER( sega_usb_ram_r );
DECLARE_WRITE8_DEVICE_HANDLER( sega_usb_ram_w );
struct timer8253_channel
{
timer8253_channel():
holding(0),
latchmode(0),
latchtoggle(0),
clockmode(0),
bcdmode(0),
output(0),
lastgate(0),
gate(0),
subcount(0),
count(0),
remain(0) {}
UINT8 holding; /* holding until counts written? */
UINT8 latchmode; /* latching mode */
UINT8 latchtoggle; /* latching state */
UINT8 clockmode; /* clocking mode */
UINT8 bcdmode; /* BCD mode? */
UINT8 output; /* current output value */
UINT8 lastgate; /* previous gate value */
UINT8 gate; /* current gate value */
UINT8 subcount; /* subcount (2MHz clocks per input clock) */
UINT16 count; /* initial count */
UINT16 remain; /* current down counter value */
};
struct timer8253
{
timer8253()
{
env[0] = 0;
env[1] = 0;
env[2] = 0;
config = 0;
}
timer8253_channel chan[3]; /* three channels' worth of information */
double env[3]; /* envelope value for each channel */
filter_state chan_filter[2]; /* filter states for the first two channels */
filter_state gate1; /* first RC filter state */
filter_state gate2; /* second RC filter state */
UINT8 config; /* configuration for this timer */
};
class usb_sound_device : public device_t,
public device_sound_interface
{
public:
usb_sound_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
usb_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~usb_sound_device() {}
required_device<i8035_device> m_ourcpu; /* CPU index of the 8035 */
DECLARE_READ8_MEMBER( status_r );
DECLARE_WRITE8_MEMBER( data_w );
DECLARE_READ8_MEMBER( ram_r );
DECLARE_WRITE8_MEMBER( ram_w );
DECLARE_READ8_MEMBER( p1_r );
DECLARE_WRITE8_MEMBER( p1_w );
DECLARE_WRITE8_MEMBER( p2_w );
DECLARE_READ8_MEMBER( t1_r );
DECLARE_READ8_MEMBER( workram_r );
DECLARE_WRITE8_MEMBER( workram_w );
TIMER_DEVICE_CALLBACK_MEMBER( increment_t1_clock_timer_cb );
protected:
// device-level overrides
virtual machine_config_constructor device_mconfig_additions() const;
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
// 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
sound_stream *m_stream; /* output stream */
device_t *m_maincpu;
UINT8 m_in_latch; /* input latch */
UINT8 m_out_latch; /* output latch */
UINT8 m_last_p2_value; /* current P2 output value */
UINT8 * m_program_ram; /* pointer to program RAM */
UINT8 * m_work_ram; /* pointer to work RAM */
UINT8 m_work_ram_bank; /* currently selected work RAM bank */
UINT8 m_t1_clock; /* T1 clock value */
UINT8 m_t1_clock_mask; /* T1 clock mask (configured via jumpers) */
timer8253 m_timer_group[3]; /* 3 groups of timers */
UINT8 m_timer_mode[3]; /* mode control for each group */
UINT32 m_noise_shift;
UINT8 m_noise_state;
UINT8 m_noise_subcount;
double m_gate_rc1_exp[2];
double m_gate_rc2_exp[2];
filter_state m_final_filter;
filter_state m_noise_filters[5];
TIMER_CALLBACK_MEMBER( delayed_usb_data_w );
void timer_w(int which, UINT8 offset, UINT8 data);
void env_w(int which, UINT8 offset, UINT8 data);
};
extern const device_type SEGAUSB;
class usb_rom_sound_device : public usb_sound_device
{
public:
usb_rom_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~usb_rom_sound_device() {}
protected:
// device-level overrides
virtual machine_config_constructor device_mconfig_additions() const;
};
extern const device_type SEGAUSBROM;
#define MCFG_SEGAUSB_ADD(_tag) \
MCFG_SOUND_ADD(_tag, SEGAUSB, 0) \
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
#define MCFG_SEGAUSBROM_ADD(_tag) \
MCFG_SOUND_ADD(_tag, SEGAUSBROM, 0) \
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)

View File

@ -111,7 +111,6 @@
#include "sound/dac.h"
#include "sound/sn76496.h"
#include "sound/samples.h"
#include "audio/segasnd.h"
#include "machine/i8255.h"
#include "machine/segacrpt.h"
#include "machine/segag80.h"
@ -187,7 +186,7 @@ WRITE8_MEMBER(segag80r_state::vidram_w){ segag80r_videoram_w(space, decrypt_offs
WRITE8_MEMBER(segag80r_state::monsterb_vidram_w){ monsterb_videoram_w(space, decrypt_offset(space, offset), data); }
WRITE8_MEMBER(segag80r_state::pignewt_vidram_w){ pignewt_videoram_w(space, decrypt_offset(space, offset), data); }
WRITE8_MEMBER(segag80r_state::sindbadm_vidram_w){ sindbadm_videoram_w(space, decrypt_offset(space, offset), data); }
WRITE8_MEMBER(segag80r_state::usb_ram_w){ device_t *device = machine().device("usbsnd"); sega_usb_ram_w(device, space, decrypt_offset(m_maincpu->space(AS_PROGRAM), offset), data); }
WRITE8_MEMBER(segag80r_state::usb_ram_w){ m_usbsnd->ram_w(space, decrypt_offset(m_maincpu->space(AS_PROGRAM), offset), data); }
@ -921,7 +920,7 @@ static MACHINE_CONFIG_DERIVED( pignewt, g80r_base )
MCFG_PALETTE_LENGTH(64+64)
/* sound boards */
MCFG_FRAGMENT_ADD(sega_universal_sound_board)
MCFG_SEGAUSB_ADD("usbsnd")
MACHINE_CONFIG_END
@ -1444,7 +1443,6 @@ void segag80r_state::monsterb_expand_gfx(const char *region)
DRIVER_INIT_MEMBER(segag80r_state,astrob)
{
device_t *speech = machine().device("segaspeech");
address_space &iospace = m_maincpu->space(AS_IO);
/* configure the 315-0062 security chip */
@ -1454,8 +1452,8 @@ DRIVER_INIT_MEMBER(segag80r_state,astrob)
m_background_pcb = G80_BACKGROUND_NONE;
/* install speech board */
iospace.install_legacy_write_handler(*speech, 0x38, 0x38, FUNC(sega_speech_data_w));
iospace.install_legacy_write_handler(*speech, 0x3b, 0x3b, FUNC(sega_speech_control_w));
iospace.install_write_handler(0x38, 0x38, write8_delegate(FUNC(speech_sound_device::data_w), (speech_sound_device*)m_speech));
iospace.install_write_handler(0x3b, 0x3b, write8_delegate(FUNC(speech_sound_device::control_w), (speech_sound_device*)m_speech));
/* install Astro Blaster sound board */
iospace.install_write_handler(0x3e, 0x3f, write8_delegate(FUNC(segag80r_state::astrob_sound_w),this));
@ -1534,7 +1532,6 @@ DRIVER_INIT_MEMBER(segag80r_state,monster2)
DRIVER_INIT_MEMBER(segag80r_state,pignewt)
{
device_t *usbsnd = machine().device("usbsnd");
address_space &iospace = m_maincpu->space(AS_IO);
address_space &pgmspace = m_maincpu->space(AS_PROGRAM);
@ -1551,8 +1548,8 @@ DRIVER_INIT_MEMBER(segag80r_state,pignewt)
pgmspace.install_write_handler(0xe000, 0xffff, write8_delegate(FUNC(segag80r_state::pignewt_vidram_w),this));
/* install Universal sound board */
iospace.install_legacy_readwrite_handler(*usbsnd, 0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
pgmspace.install_legacy_read_handler(*usbsnd, 0xd000, 0xdfff, FUNC(sega_usb_ram_r));
iospace.install_readwrite_handler(0x3f, 0x3f, read8_delegate(FUNC(usb_sound_device::status_r), (usb_sound_device*)m_usbsnd), write8_delegate(FUNC(usb_sound_device::data_w), (usb_sound_device*)m_usbsnd));
pgmspace.install_read_handler(0xd000, 0xdfff, read8_delegate(FUNC(usb_sound_device::ram_r), (usb_sound_device*)m_usbsnd));
pgmspace.install_write_handler(0xd000, 0xdfff, write8_delegate(FUNC(segag80r_state::usb_ram_w),this));
}

View File

@ -138,7 +138,6 @@
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "sound/samples.h"
#include "audio/segasnd.h"
#include "machine/segag80.h"
#include "includes/segag80v.h"
@ -202,7 +201,7 @@ WRITE8_MEMBER(segag80v_state::mainram_w)
m_mainram[decrypt_offset(space, offset)] = data;
}
WRITE8_MEMBER(segag80v_state::usb_ram_w){ sega_usb_ram_w(m_usb, space, decrypt_offset(m_maincpu->space(AS_PROGRAM), offset), data); }
WRITE8_MEMBER(segag80v_state::usb_ram_w){ m_usb->ram_w(space, decrypt_offset(m_maincpu->space(AS_PROGRAM), offset), data); }
WRITE8_MEMBER(segag80v_state::vectorram_w)
{
m_vectorram[decrypt_offset(space, offset)] = data;
@ -950,7 +949,7 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( tacscan, g80v_base )
/* universal sound board */
MCFG_FRAGMENT_ADD(sega_universal_sound_board)
MCFG_SEGAUSB_ADD("usbsnd")
MACHINE_CONFIG_END
@ -960,7 +959,7 @@ static MACHINE_CONFIG_DERIVED( startrek, g80v_base )
MCFG_FRAGMENT_ADD(sega_speech_board)
/* universal sound board */
MCFG_FRAGMENT_ADD(sega_universal_sound_board)
MCFG_SEGAUSB_ADD("usbsnd")
MACHINE_CONFIG_END
@ -1293,7 +1292,6 @@ DRIVER_INIT_MEMBER(segag80v_state,elim2)
m_decrypt = segag80_security(70);
/* configure sound */
m_usb = NULL;
iospace.install_write_handler(0x3e, 0x3e, write8_delegate(FUNC(segag80v_state::elim1_sh_w),this));
iospace.install_write_handler(0x3f, 0x3f, write8_delegate(FUNC(segag80v_state::elim2_sh_w),this));
}
@ -1307,7 +1305,6 @@ DRIVER_INIT_MEMBER(segag80v_state,elim4)
m_decrypt = segag80_security(76);
/* configure sound */
m_usb = NULL;
iospace.install_write_handler(0x3e, 0x3e, write8_delegate(FUNC(segag80v_state::elim1_sh_w),this));
iospace.install_write_handler(0x3f, 0x3f, write8_delegate(FUNC(segag80v_state::elim2_sh_w),this));
@ -1325,9 +1322,8 @@ DRIVER_INIT_MEMBER(segag80v_state,spacfury)
m_decrypt = segag80_security(64);
/* configure sound */
m_usb = NULL;
iospace.install_legacy_write_handler(*machine().device("segaspeech"), 0x38, 0x38, FUNC(sega_speech_data_w));
iospace.install_legacy_write_handler(*machine().device("segaspeech"), 0x3b, 0x3b, FUNC(sega_speech_control_w));
iospace.install_write_handler(0x38, 0x38, write8_delegate(FUNC(speech_sound_device::data_w), (speech_sound_device*)m_speech));
iospace.install_write_handler(0x3b, 0x3b, write8_delegate(FUNC(speech_sound_device::control_w), (speech_sound_device*)m_speech));
iospace.install_write_handler(0x3e, 0x3e, write8_delegate(FUNC(segag80v_state::spacfury1_sh_w),this));
iospace.install_write_handler(0x3f, 0x3f, write8_delegate(FUNC(segag80v_state::spacfury2_sh_w),this));
}
@ -1342,9 +1338,8 @@ DRIVER_INIT_MEMBER(segag80v_state,zektor)
m_decrypt = segag80_security(82);
/* configure sound */
m_usb = NULL;
iospace.install_legacy_write_handler(*machine().device("segaspeech"), 0x38, 0x38, FUNC(sega_speech_data_w));
iospace.install_legacy_write_handler(*machine().device("segaspeech"), 0x3b, 0x3b, FUNC(sega_speech_control_w));
iospace.install_write_handler(0x38, 0x38, write8_delegate(FUNC(speech_sound_device::data_w), (speech_sound_device*)m_speech));
iospace.install_write_handler(0x3b, 0x3b, write8_delegate(FUNC(speech_sound_device::control_w), (speech_sound_device*)m_speech));
iospace.install_write_handler(0x3c, 0x3d, write8_delegate(FUNC(ay8910_device::address_data_w), ay8910));
iospace.install_write_handler(0x3e, 0x3e, write8_delegate(FUNC(segag80v_state::zektor1_sh_w),this));
iospace.install_write_handler(0x3f, 0x3f, write8_delegate(FUNC(segag80v_state::zektor2_sh_w),this));
@ -1364,9 +1359,8 @@ DRIVER_INIT_MEMBER(segag80v_state,tacscan)
m_decrypt = segag80_security(76);
/* configure sound */
m_usb = machine().device("usbsnd");
iospace.install_legacy_readwrite_handler(*m_usb, 0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
pgmspace.install_legacy_read_handler(*m_usb, 0xd000, 0xdfff, FUNC(sega_usb_ram_r));
iospace.install_readwrite_handler(0x3f, 0x3f, read8_delegate(FUNC(usb_sound_device::status_r), (usb_sound_device*)m_usb), write8_delegate(FUNC(usb_sound_device::data_w), (usb_sound_device*)m_usb));
pgmspace.install_read_handler(0xd000, 0xdfff, read8_delegate(FUNC(usb_sound_device::ram_r), (usb_sound_device*)m_usb));
pgmspace.install_write_handler(0xd000, 0xdfff, write8_delegate(FUNC(segag80v_state::usb_ram_w),this));
/* configure inputs */
@ -1384,12 +1378,11 @@ DRIVER_INIT_MEMBER(segag80v_state,startrek)
m_decrypt = segag80_security(64);
/* configure sound */
m_usb = machine().device("usbsnd");
iospace.install_legacy_write_handler(*machine().device("segaspeech"), 0x38, 0x38, FUNC(sega_speech_data_w));
iospace.install_legacy_write_handler(*machine().device("segaspeech"), 0x3b, 0x3b, FUNC(sega_speech_control_w));
iospace.install_write_handler(0x38, 0x38, write8_delegate(FUNC(speech_sound_device::data_w), (speech_sound_device*)m_speech));
iospace.install_write_handler(0x3b, 0x3b, write8_delegate(FUNC(speech_sound_device::control_w), (speech_sound_device*)m_speech));
iospace.install_legacy_readwrite_handler(*m_usb, 0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
pgmspace.install_legacy_read_handler(*m_usb, 0xd000, 0xdfff, FUNC(sega_usb_ram_r));
iospace.install_readwrite_handler(0x3f, 0x3f, read8_delegate(FUNC(usb_sound_device::status_r), (usb_sound_device*)m_usb), write8_delegate(FUNC(usb_sound_device::data_w), (usb_sound_device*)m_usb));
pgmspace.install_read_handler(0xd000, 0xdfff, read8_delegate(FUNC(usb_sound_device::ram_r), (usb_sound_device*)m_usb));
pgmspace.install_write_handler(0xd000, 0xdfff, write8_delegate(FUNC(segag80v_state::usb_ram_w),this));
/* configure inputs */

View File

@ -452,7 +452,7 @@ static ADDRESS_MAP_START( ixion_map, AS_PROGRAM, 8, zaxxon_state )
AM_RANGE(0xc000, 0xc002) AM_MIRROR(0x18f8) AM_WRITE(zaxxon_coin_enable_w)
AM_RANGE(0xc003, 0xc004) AM_MIRROR(0x18f8) AM_WRITE(zaxxon_coin_counter_w)
AM_RANGE(0xc006, 0xc006) AM_MIRROR(0x18f8) AM_WRITE(zaxxon_flipscreen_w)
AM_RANGE(0xe03c, 0xe03c) AM_MIRROR(0x1f00) AM_DEVREADWRITE_LEGACY("usbsnd", sega_usb_status_r, sega_usb_data_w)
AM_RANGE(0xe03c, 0xe03c) AM_MIRROR(0x1f00) AM_DEVREADWRITE("usbsnd", usb_sound_device, status_r, data_w)
AM_RANGE(0xe0f0, 0xe0f0) AM_MIRROR(0x1f00) AM_WRITE(int_enable_w)
AM_RANGE(0xe0f1, 0xe0f1) AM_MIRROR(0x1f00) AM_WRITE(zaxxon_fg_color_w)
AM_RANGE(0xe0f8, 0xe0f9) AM_MIRROR(0x1f00) AM_WRITE(zaxxon_bg_position_w)
@ -1006,7 +1006,7 @@ static MACHINE_CONFIG_DERIVED( razmataz, root )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_FRAGMENT_ADD(sega_universal_sound_board_rom)
MCFG_SEGAUSBROM_ADD("usbsnd")
MACHINE_CONFIG_END

View File

@ -8,6 +8,7 @@
#include "sound/samples.h"
#include "machine/segag80.h"
#include "sound/sn76496.h"
#include "audio/segasnd.h"
class segag80r_state : public driver_device
{
@ -25,13 +26,20 @@ public:
m_sn2(*this, "sn2"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_samples(*this, "samples") { }
m_samples(*this, "samples"),
m_speech(*this, "segaspeech"),
m_usbsnd(*this, "usbsnd") { }
required_shared_ptr<UINT8> m_mainram;
required_shared_ptr<UINT8> m_videoram;
optional_device<sn76496_device> m_sn1;
optional_device<sn76496_device> m_sn2;
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
optional_device<samples_device> m_samples;
optional_device<speech_sound_device> m_speech;
optional_device<usb_sound_device> m_usbsnd;
UINT8 m_sound_state[2];
UINT8 m_sound_rate;
@ -129,9 +137,6 @@ public:
offs_t decrypt_offset(address_space &space, offs_t offset);
inline UINT8 demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0);
void monsterb_expand_gfx(const char *region);
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
optional_device<samples_device> m_samples;
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

View File

@ -7,6 +7,7 @@
*************************************************************************/
#include "sound/samples.h"
#include "machine/segag80.h"
#include "audio/segasnd.h"
class segag80v_state : public driver_device
{
@ -16,17 +17,24 @@ public:
m_mainram(*this, "mainram"),
m_vectorram(*this, "vectorram"),
m_maincpu(*this, "maincpu"),
m_samples(*this, "samples") { }
m_samples(*this, "samples"),
m_speech(*this, "segaspeech"),
m_usb(*this, "usbsnd") { }
required_shared_ptr<UINT8> m_mainram;
device_t *m_usb;
required_shared_ptr<UINT8> m_vectorram;
required_device<cpu_device> m_maincpu;
optional_device<samples_device> m_samples;
optional_device<speech_sound_device> m_speech;
optional_device<usb_sound_device> m_usb;
UINT8 m_mult_data[2];
UINT16 m_mult_result;
UINT8 m_spinner_select;
UINT8 m_spinner_sign;
UINT8 m_spinner_count;
segag80_decrypt_func m_decrypt;
required_shared_ptr<UINT8> m_vectorram;
int m_min_x;
int m_min_y;
DECLARE_WRITE8_MEMBER(mainram_w);
@ -61,6 +69,4 @@ public:
void sega_generate_vector_list();
offs_t decrypt_offset(address_space &space, offs_t offset);
inline UINT8 demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0);
required_device<cpu_device> m_maincpu;
optional_device<samples_device> m_samples;
};