diff options
author | 2013-05-11 13:20:38 +0000 | |
---|---|---|
committer | 2013-05-11 13:20:38 +0000 | |
commit | 3a8b7344f0af1a77c60fc54dbe69f5d6fce6ff5c (patch) | |
tree | a560a31ab109e6d28501b556bac5cce3fe2e47a3 /src/emu/sound/2203intf.h | |
parent | 725996afbd42bed3fbd2d8ec80f37511c9d7f9c8 (diff) |
modernised YM2203 [smf]
Diffstat (limited to 'src/emu/sound/2203intf.h')
-rw-r--r-- | src/emu/sound/2203intf.h | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/emu/sound/2203intf.h b/src/emu/sound/2203intf.h index 63116cc05a0..5fae690d442 100644 --- a/src/emu/sound/2203intf.h +++ b/src/emu/sound/2203intf.h @@ -3,47 +3,60 @@ #ifndef __2203INTF_H__ #define __2203INTF_H__ -#include "devlegcy.h" - +#include "emu.h" #include "ay8910.h" void ym2203_update_request(void *param); -struct ym2203_interface -{ - const ay8910_interface ay8910_intf; - devcb_write_line irqhandler; -}; +#define MCFG_YM2203_IRQ_HANDLER(_devcb) \ + devcb = &ym2203_device::set_irq_handler(*device, DEVCB2_##_devcb); -DECLARE_READ8_DEVICE_HANDLER( ym2203_r ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2203_w ); - -DECLARE_READ8_DEVICE_HANDLER( ym2203_status_port_r ); -DECLARE_READ8_DEVICE_HANDLER( ym2203_read_port_r ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2203_control_port_w ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2203_write_port_w ); +#define MCFG_YM2203_AY8910_INTF(_ay8910_config) \ + ym2203_device::set_ay8910_config(*device, _ay8910_config); class ym2203_device : public device_t, public device_sound_interface { public: ym2203_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~ym2203_device() { global_free(m_token); } - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } + // static configuration helpers + template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ym2203_device &>(device).m_irq_handler.set_callback(object); } + static void set_ay8910_config(device_t &device, const ay8910_interface *ay8910_config) { downcast<ym2203_device &>(device).m_ay8910_config = ay8910_config; } + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + + DECLARE_READ8_MEMBER( status_port_r ); + DECLARE_READ8_MEMBER( read_port_r ); + DECLARE_WRITE8_MEMBER( control_port_w ); + DECLARE_WRITE8_MEMBER( write_port_w ); + + void *_psg(); + void _IRQHandler(int irq); + void _timer_handler(int c,int count,int clock); + void _ym2203_update_request(); + protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); + virtual void device_post_load(); virtual void device_stop(); virtual void device_reset(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // 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 - void *m_token; + sound_stream * m_stream; + emu_timer * m_timer[2]; + void * m_chip; + void * m_psg; + devcb2_write_line m_irq_handler; + const ay8910_interface *m_ay8910_config; }; extern const device_type YM2203; |