segag80v, segasnd: Removed machine().device, nw

This commit is contained in:
mooglyguy 2018-05-31 19:44:38 +02:00
parent 0a455b0eff
commit 31c514df18
7 changed files with 86 additions and 47 deletions

View File

@ -70,14 +70,17 @@ inline double usb_sound_device::g80_filter_state::step_cr(double input)
DEFINE_DEVICE_TYPE(SEGASPEECH, speech_sound_device, "sega_speech_sound", "Sega Speech Sound Board")
#define SEGASPEECH_REGION "speech"
speech_sound_device::speech_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, SEGASPEECH, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_int_cb(*this),
m_speech(*this, SEGASPEECH_REGION),
m_drq(0),
m_latch(0),
m_t0(0),
m_p2(0),
m_speech(nullptr)
m_p2(0)
{
}
@ -87,7 +90,7 @@ speech_sound_device::speech_sound_device(const machine_config &mconfig, const ch
void speech_sound_device::device_start()
{
m_speech = machine().root_device().memregion("speech")->base();
m_int_cb.resolve();
save_item(NAME(m_latch));
save_item(NAME(m_t0));
@ -121,7 +124,7 @@ READ8_MEMBER( speech_sound_device::p1_r )
READ8_MEMBER( speech_sound_device::rom_r )
{
return m_speech[0x100 * (m_p2 & 0x3f) + offset];
return m_speech->base()[0x100 * (m_p2 & 0x3f) + offset];
}
WRITE8_MEMBER( speech_sound_device::p1_w )
@ -165,7 +168,7 @@ TIMER_CALLBACK_MEMBER( speech_sound_device::delayed_speech_w )
m_latch = data;
/* the high bit goes directly to the INT line */
machine().device("audiocpu")->execute().set_input_line(0, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
m_int_cb((data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
/* a clock on the high bit clocks a 1 into T0 */
if (!(old & 0x80) && (data & 0x80))
@ -193,6 +196,16 @@ void speech_sound_device::sound_stream_update(sound_stream &stream, stream_sampl
{
}
/*************************************
*
* Speech board functions
*
*************************************/
WRITE_LINE_MEMBER(segag80snd_common::segaspeech_int_w)
{
m_audiocpu->set_input_line(0, state);
}
/*************************************
*
@ -233,6 +246,7 @@ MACHINE_CONFIG_START(segag80snd_common::sega_speech_board)
/* sound hardware */
MCFG_DEVICE_ADD("segaspeech", SEGASPEECH, 0)
MCFG_SEGASPEECH_INT_CALLBACK(WRITELINE(*this, segag80snd_common, segaspeech_int_w))
MCFG_DEVICE_ADD("speech", SP0250, SPEECH_MASTER_CLOCK)
MCFG_SP0250_DRQ_CALLBACK(WRITELINE("segaspeech", speech_sound_device, drq_w))
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 1.0)
@ -250,6 +264,7 @@ usb_sound_device::usb_sound_device(const machine_config &mconfig, device_type ty
: device_t(mconfig, type, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_ourcpu(*this, "ourcpu"),
m_maincpu(*this, finder_base::DUMMY_TAG),
m_stream(nullptr),
m_in_latch(0),
m_out_latch(0),
@ -276,13 +291,6 @@ usb_sound_device::usb_sound_device(const machine_config &mconfig, const char *ta
void usb_sound_device::device_start()
{
g80_filter_state temp;
int tchan, tgroup;
/* find the CPU we are associated with */
m_maincpu = machine().device("maincpu");
assert(m_maincpu != nullptr);
/* create a sound stream */
m_stream = machine().sound().stream_alloc(*this, 0, 1, SAMPLE_RATE);
@ -297,6 +305,7 @@ void usb_sound_device::device_start()
g.gate2.configure(2 * 100e3, 0.01e-6);
}
g80_filter_state temp;
temp.configure(100e3, 0.01e-6);
m_gate_rc1_exp[0] = temp.exponent;
temp.configure(1e3, 0.01e-6);
@ -321,10 +330,10 @@ void usb_sound_device::device_start()
save_item(NAME(m_work_ram_bank));
save_item(NAME(m_t1_clock));
for (tgroup = 0; tgroup < 3; tgroup++)
for (int tgroup = 0; tgroup < 3; tgroup++)
{
timer8253 *group = &m_timer_group[tgroup];
for (tchan = 0; tchan < 3; tchan++)
for (int tchan = 0; tchan < 3; tchan++)
{
timer8253::channel *channel = &group->chan[tchan];
save_item(NAME(channel->holding), tgroup * 3 + tchan);
@ -395,7 +404,7 @@ READ8_MEMBER( usb_sound_device::status_r )
{
LOG("%s:usb_data_r = %02X\n", machine().describe_context(), (m_out_latch & 0x81) | (m_in_latch & 0x7e));
m_maincpu->execute().adjust_icount(-200);
m_maincpu->adjust_icount(-200);
/* only bits 0 and 7 are controlled by the I8035; the remaining */
/* bits 1-6 reflect the current input latch values */

View File

@ -15,23 +15,36 @@
class segag80snd_common : public driver_device {
public:
segag80snd_common(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
{}
segag80snd_common(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_audiocpu(*this, "audiocpu")
{ }
virtual ~segag80snd_common() = default;
DECLARE_WRITE_LINE_MEMBER(segaspeech_int_w);
void sega_speech_board(machine_config &config);
protected:
void speech_map(address_map &map);
void speech_portmap(address_map &map);
optional_device<cpu_device> m_audiocpu;
};
#define SEGASND_SEGASPEECH_REGION "segaspeech:speech"
#define MCFG_SEGASPEECH_INT_CALLBACK(_devcb) \
devcb = &downcast<speech_sound_device&>(*device).set_int_cb(DEVCB_##_devcb);
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, u32 clock);
template <class Object> devcb_base &set_int_cb(Object &&cb) { return m_int_cb.set_callback(std::forward<Object>(cb)); }
DECLARE_WRITE8_MEMBER( data_w );
DECLARE_WRITE8_MEMBER( control_w );
@ -52,24 +65,30 @@ protected:
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
private:
devcb_write_line m_int_cb;
required_memory_region m_speech;
// internal state
u8 m_drq;
u8 m_latch;
u8 m_t0;
u8 m_p2;
u8 *m_speech;
TIMER_CALLBACK_MEMBER( delayed_speech_w );
};
DECLARE_DEVICE_TYPE(SEGASPEECH, speech_sound_device)
class usb_sound_device : public device_t, public device_sound_interface
{
public:
template <typename T> usb_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, T &&maincpu_tag)
: usb_sound_device(mconfig, tag, owner, clock)
{
m_maincpu.set_tag(maincpu_tag);
}
usb_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
required_device<i8035_device> m_ourcpu; /* CPU index of the 8035 */
DECLARE_READ8_MEMBER( status_r );
DECLARE_WRITE8_MEMBER( data_w );
@ -84,6 +103,7 @@ public:
void usb_map(address_map &map);
void usb_map_rom(address_map &map);
void usb_portmap(address_map &map);
protected:
usb_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
@ -95,6 +115,9 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
required_device<i8035_device> m_ourcpu;
required_device<cpu_device> m_maincpu;
private:
struct g80_filter_state
{
@ -140,10 +163,8 @@ private:
u8 config = 0; // configuration for this timer
};
// internal state
sound_stream *m_stream; // output stream
device_t *m_maincpu;
u8 m_in_latch; // input latch
u8 m_out_latch; // output latch
u8 m_last_p2_value; // current P2 output value
@ -178,6 +199,12 @@ DECLARE_DEVICE_TYPE(SEGAUSB, usb_sound_device)
class usb_rom_sound_device : public usb_sound_device
{
public:
template <typename T> usb_rom_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, T &&maincpu_tag)
: usb_rom_sound_device(mconfig, tag, owner, clock)
{
m_maincpu.set_tag(maincpu_tag);
}
usb_rom_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
@ -188,12 +215,12 @@ protected:
DECLARE_DEVICE_TYPE(SEGAUSBROM, usb_rom_sound_device)
#define MCFG_SEGAUSB_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, SEGAUSB, 0) \
#define MCFG_SEGAUSB_ADD(_tag, _cputag) \
MCFG_DEVICE_ADD(_tag, SEGAUSB, 0, _cputag) \
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 1.0)
#define MCFG_SEGAUSBROM_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, SEGAUSBROM, 0) \
#define MCFG_SEGAUSBROM_ADD(_tag, _cputag) \
MCFG_DEVICE_ADD(_tag, SEGAUSBROM, 0, _cputag) \
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 1.0)
#endif // MAME_AUDIO_SEGASND_H

View File

@ -84,7 +84,7 @@ protected:
class zac1b11142_audio_device : public zac1b111xx_melody_base
{
public:
template <class Object> devcb_base &set_acs_cb(device_t &device, Object &&cb) { return m_acs_cb.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_acs_cb(Object &&cb) { return m_acs_cb.set_callback(std::forward<Object>(cb)); }
zac1b11142_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock = 0);

View File

@ -955,7 +955,7 @@ MACHINE_CONFIG_START(segag80r_state::pignewt)
SPEAKER(config, "speaker").front_center();
/* sound boards */
MCFG_SEGAUSB_ADD("usbsnd")
MCFG_SEGAUSB_ADD("usbsnd", "maincpu")
MACHINE_CONFIG_END
@ -1029,7 +1029,7 @@ ROM_START( astrob )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808b.speech-u7", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "809a.speech-u6", 0x0000, 0x0800, CRC(893f228d) SHA1(41c08210d322105f5446cfaa1258c194dd078a34) )
ROM_LOAD( "810.speech-u5", 0x0800, 0x0800, CRC(ff0163c5) SHA1(158a12f9bf01d25c7e98f34fce56df51d49e5a85) )
ROM_LOAD( "811.speech-u4", 0x1000, 0x0800, CRC(219f3978) SHA1(728edb9251f7cde237fa3b005971366a099c6342) )
@ -1062,7 +1062,7 @@ ROM_START( astrob2 )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808b.speech-u7", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "809a.speech-u6", 0x0000, 0x0800, CRC(893f228d) SHA1(41c08210d322105f5446cfaa1258c194dd078a34) )
ROM_LOAD( "810.speech-u5", 0x0800, 0x0800, CRC(ff0163c5) SHA1(158a12f9bf01d25c7e98f34fce56df51d49e5a85) )
ROM_LOAD( "811.speech-u4", 0x1000, 0x0800, CRC(219f3978) SHA1(728edb9251f7cde237fa3b005971366a099c6342) )
@ -1095,7 +1095,7 @@ ROM_START( astrob2a )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808b.speech-u7", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "809a.speech-u6", 0x0000, 0x0800, CRC(893f228d) SHA1(41c08210d322105f5446cfaa1258c194dd078a34) )
ROM_LOAD( "810.speech-u5", 0x0800, 0x0800, CRC(ff0163c5) SHA1(158a12f9bf01d25c7e98f34fce56df51d49e5a85) )
ROM_LOAD( "811.speech-u4", 0x1000, 0x0800, CRC(219f3978) SHA1(728edb9251f7cde237fa3b005971366a099c6342) )
@ -1125,7 +1125,7 @@ ROM_START( astrob1 )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808b.speech-u7", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "809a.speech-u6", 0x0000, 0x0800, CRC(893f228d) SHA1(41c08210d322105f5446cfaa1258c194dd078a34) )
ROM_LOAD( "810.speech-u5", 0x0800, 0x0800, CRC(ff0163c5) SHA1(158a12f9bf01d25c7e98f34fce56df51d49e5a85) )
ROM_LOAD( "811.speech-u4", 0x1000, 0x0800, CRC(219f3978) SHA1(728edb9251f7cde237fa3b005971366a099c6342) )
@ -1155,7 +1155,7 @@ ROM_START( astrobg )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808b_speech_de.u07", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "830_speech_de.u06", 0x0000, 0x0800, CRC(2d840552) SHA1(7a2a7b54378b6cc85b8ab5c26e42266aa747c635) )
ROM_LOAD( "831_speech_de.u05", 0x0800, 0x0800, CRC(46b30ee4) SHA1(c9e19a9b9ebc9b3b853e79f93ad74e4ec5dfd1ae) )
ROM_LOAD( "832_speech_de.u04", 0x1000, 0x0800, CRC(d05280b8) SHA1(8d30b23b83b32465a8a2decd2ce9bfed24394e7e) )

View File

@ -139,7 +139,6 @@
#include "machine/segag80.h"
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "sound/samples.h"
#include "speaker.h"
@ -964,7 +963,7 @@ MACHINE_CONFIG_START(segag80v_state::tacscan)
g80v_base(config);
/* universal sound board */
MCFG_SEGAUSB_ADD("usbsnd")
MCFG_SEGAUSB_ADD("usbsnd", "maincpu")
MACHINE_CONFIG_END
@ -975,7 +974,7 @@ MACHINE_CONFIG_START(segag80v_state::startrek)
sega_speech_board(config);
/* universal sound board */
MCFG_SEGAUSB_ADD("usbsnd")
MCFG_SEGAUSB_ADD("usbsnd", "maincpu")
MACHINE_CONFIG_END
@ -1115,7 +1114,7 @@ ROM_START( spacfury ) /* Revision C */
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808c.speech-u7", 0x0000, 0x0800, CRC(b779884b) SHA1(ac07e99717a1f51b79f3e43a5d873ebfa0559320) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "970c.speech-u6", 0x0000, 0x1000, CRC(979d8535) SHA1(1ed097e563319ca6d2b7df9875ce7ee921eae468) )
ROM_LOAD( "971c.speech-u5", 0x1000, 0x1000, CRC(022dbd32) SHA1(4e0504b5ccc28094078912673c49571cf83804ab) )
ROM_LOAD( "972c.speech-u4", 0x2000, 0x1000, CRC(fad9346d) SHA1(784e5ab0fb00235cfd733c502baf23960923504f) )
@ -1142,7 +1141,7 @@ ROM_START( spacfurya ) /* Revision A */
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808a.speech-u7", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "970.speech-u6", 0x0000, 0x1000, CRC(f3b47b36) SHA1(6ae0b627349664140a7f70799645b368e452d69c) )
ROM_LOAD( "971.speech-u5", 0x1000, 0x1000, CRC(e72bbe88) SHA1(efadf8aa448c289cf4d0cf1831255b9ac60820f2) )
ROM_LOAD( "972.speech-u4", 0x2000, 0x1000, CRC(8b3da539) SHA1(3a0c4af96a2116fc668a340534582776b2018663) )
@ -1169,7 +1168,7 @@ ROM_START( spacfuryb ) /* Revision B */
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "808a.speech-u7", 0x0000, 0x0800, CRC(5988c767) SHA1(3b91a8cd46aa7e714028cc40f700fea32287afb1) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "970.speech-u6", 0x0000, 0x1000, CRC(f3b47b36) SHA1(6ae0b627349664140a7f70799645b368e452d69c) )
ROM_LOAD( "971.speech-u5", 0x1000, 0x1000, CRC(e72bbe88) SHA1(efadf8aa448c289cf4d0cf1831255b9ac60820f2) )
ROM_LOAD( "972.speech-u4", 0x2000, 0x1000, CRC(8b3da539) SHA1(3a0c4af96a2116fc668a340534582776b2018663) )
@ -1209,7 +1208,7 @@ ROM_START( zektor )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "1607.speech-u7", 0x0000, 0x0800, CRC(b779884b) SHA1(ac07e99717a1f51b79f3e43a5d873ebfa0559320) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "1608.speech-u6", 0x0000, 0x1000, CRC(637e2b13) SHA1(8a470f9a8a722f7ced340c4d32b4cf6f05b3e848) )
ROM_LOAD( "1609.speech-u5", 0x1000, 0x1000, CRC(675ee8e5) SHA1(e314482028b8925ad02e833a1d22224533d0a683) )
ROM_LOAD( "1610.speech-u4", 0x2000, 0x1000, CRC(2915c7bd) SHA1(3ed98747b5237aa1b3bab6866292370dc2c7655a) )
@ -1282,7 +1281,7 @@ ROM_START( startrek )
ROM_REGION( 0x0800, "audiocpu", 0 )
ROM_LOAD( "1670.speech-u7", 0x0000, 0x0800, CRC(b779884b) SHA1(ac07e99717a1f51b79f3e43a5d873ebfa0559320) )
ROM_REGION( 0x4000, "speech", 0 )
ROM_REGION( 0x4000, SEGASND_SEGASPEECH_REGION, 0 )
ROM_LOAD( "1871.speech-u6", 0x0000, 0x1000, CRC(03713920) SHA1(25a0158cab9983248e91133f96d1849c9e9bcbd2) )
ROM_LOAD( "1872.speech-u5", 0x1000, 0x1000, CRC(ebb5c3a9) SHA1(533b6f0499b311f561cf7aba14a7f48ca7c47321) )
@ -1348,7 +1347,6 @@ void segag80v_state::init_spacfury()
void segag80v_state::init_zektor()
{
address_space &iospace = m_maincpu->space(AS_IO);
ay8912_device *ay8912 = machine().device<ay8912_device>("aysnd");
/* configure security */
m_decrypt = segag80_security(82);
@ -1356,7 +1354,7 @@ void segag80v_state::init_zektor()
/* configure sound */
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(ay8912_device::address_data_w), ay8912));
iospace.install_write_handler(0x3c, 0x3d, write8_delegate(FUNC(ay8912_device::address_data_w), (ay8912_device*)m_aysnd));
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));

View File

@ -1020,7 +1020,7 @@ MACHINE_CONFIG_START(zaxxon_state::razmataze)
/* sound hardware */
SPEAKER(config, "speaker").front_center();
MCFG_SEGAUSBROM_ADD("usbsnd")
MCFG_SEGAUSBROM_ADD("usbsnd", "maincpu")
MACHINE_CONFIG_END
MACHINE_CONFIG_START(zaxxon_state::ixion)

View File

@ -5,10 +5,13 @@
Sega vector hardware
*************************************************************************/
#include "sound/samples.h"
#include "machine/segag80.h"
#include "audio/segasnd.h"
#include "machine/segag80.h"
#include "sound/ay8910.h"
#include "sound/samples.h"
#include "video/vector.h"
#include "screen.h"
class segag80v_state : public segag80snd_common
@ -22,6 +25,7 @@ public:
m_samples(*this, "samples"),
m_speech(*this, "segaspeech"),
m_usb(*this, "usbsnd"),
m_aysnd(*this, "aysnd"),
m_vector(*this, "vector"),
m_screen(*this, "screen"){ }
@ -32,6 +36,7 @@ public:
optional_device<samples_device> m_samples;
optional_device<speech_sound_device> m_speech;
optional_device<usb_sound_device> m_usb;
optional_device<ay8912_device> m_aysnd;
required_device<vector_device> m_vector;
required_device<screen_device> m_screen;