diff options
author | Aaron Giles <aaron@aarongiles.com> | 2010-09-11 01:00:46 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2010-09-11 01:00:46 +0000 |
commit | 1b062b68157fdb8002c816571eff42f3d0dc2829 (patch) | |
tree | 956ebb4fbdaf74de3fa7202aa636186a870745ce | |
parent | 958c161bccdd1f785c0760b3125db616bc60717c (diff) |
Added definitions for [DECLARE_]READ_LINE_MEMBER and [DECLARE_]WRITE_LINE_MEMBER
so that read/write line callbacks can be defined as member functions.
Added stubs and new macro DEVCB_DEVICE_LINE_MEMBER to allow these to be
referenced from device callbacks.
Modernized the 6522 VIA device:
* changed to use the new device timer mechanism
* removed all trampolines in favor of modern methods
-rw-r--r-- | src/emu/devcb.h | 38 | ||||
-rw-r--r-- | src/emu/machine/6522via.c | 157 | ||||
-rw-r--r-- | src/emu/machine/6522via.h | 60 | ||||
-rw-r--r-- | src/mame/drivers/86lions.c | 15 | ||||
-rw-r--r-- | src/mame/drivers/aristmk4.c | 2 | ||||
-rw-r--r-- | src/mame/drivers/atarisy1.c | 2 | ||||
-rw-r--r-- | src/mame/drivers/beezer.c | 2 | ||||
-rw-r--r-- | src/mame/drivers/bmcbowl.c | 14 | ||||
-rw-r--r-- | src/mame/drivers/gameplan.c | 9 | ||||
-rw-r--r-- | src/mame/drivers/itech32.c | 4 | ||||
-rw-r--r-- | src/mame/drivers/itech8.c | 2 | ||||
-rw-r--r-- | src/mame/drivers/trvquest.c | 13 | ||||
-rw-r--r-- | src/mame/includes/gameplan.h | 11 | ||||
-rw-r--r-- | src/mame/machine/beezer.c | 12 | ||||
-rw-r--r-- | src/mame/video/beezer.c | 4 | ||||
-rw-r--r-- | src/mame/video/gameplan.c | 6 |
16 files changed, 136 insertions, 215 deletions
diff --git a/src/emu/devcb.h b/src/emu/devcb.h index 2f100b6e2e5..d1e8c4e8def 100644 --- a/src/emu/devcb.h +++ b/src/emu/devcb.h @@ -61,6 +61,14 @@ MACROS ***************************************************************************/ +// static template for a read_line stub function that calls through a given READ_LINE_MEMBER +template<class _Class, int (_Class::*_Function)()> +int devcb_stub(device_t *device) +{ + _Class *target = downcast<_Class *>(device); + return (target->*_Function)(); +} + // static template for a read8 stub function that calls through a given READ8_MEMBER template<class _Class, UINT8 (_Class::*_Function)(address_space &, offs_t, UINT8)> UINT8 devcb_stub(device_t *device, offs_t offset) @@ -69,6 +77,14 @@ UINT8 devcb_stub(device_t *device, offs_t offset) return (target->*_Function)(*device->machine->m_nonspecific_space, offset, 0xff); } +// static template for a write_line stub function that calls through a given WRITE_LINE_MEMBER +template<class _Class, void (_Class::*_Function)(int state)> +void devcb_stub(device_t *device, int state) +{ + _Class *target = downcast<_Class *>(device); + (target->*_Function)(state); +} + // static template for a write8 stub function that calls through a given WRITE8_MEMBER template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT8, UINT8)> void devcb_stub(device_t *device, offs_t offset, UINT8 data) @@ -80,15 +96,18 @@ void devcb_stub(device_t *device, offs_t offset, UINT8 data) #define DEVCB_NULL { DEVCB_TYPE_NULL } /* standard line or read/write handlers with the calling device passed */ -#define DEVCB_LINE(func) { DEVCB_TYPE_SELF, NULL, (func), NULL, NULL } -#define DEVCB_LINE_GND { DEVCB_TYPE_SELF, NULL, devcb_line_gnd_r, NULL, NULL } -#define DEVCB_LINE_VCC { DEVCB_TYPE_SELF, NULL, devcb_line_vcc_r, NULL, NULL } -#define DEVCB_HANDLER(func) { DEVCB_TYPE_SELF, NULL, NULL, (func), NULL } +#define DEVCB_LINE(func) { DEVCB_TYPE_SELF, NULL, (func), NULL, NULL } +#define DEVCB_LINE_MEMBER(func) { DEVCB_TYPE_SELF, NULL, &devcb_stub<cls, &cls::memb>, NULL, NULL } +#define DEVCB_LINE_GND { DEVCB_TYPE_SELF, NULL, devcb_line_gnd_r, NULL, NULL } +#define DEVCB_LINE_VCC { DEVCB_TYPE_SELF, NULL, devcb_line_vcc_r, NULL, NULL } +#define DEVCB_HANDLER(func) { DEVCB_TYPE_SELF, NULL, NULL, (func), NULL } +#define DEVCB_MEMBER(cls,memb) { DEVCB_TYPE_SELF, NULL, NULL, &devcb_stub<cls, &cls::memb>, NULL } /* line or read/write handlers for another device */ -#define DEVCB_DEVICE_LINE(tag,func) { DEVCB_TYPE_DEVICE, tag, (func), NULL, NULL } -#define DEVCB_DEVICE_HANDLER(tag,func) { DEVCB_TYPE_DEVICE, tag, NULL, (func), NULL } -#define DEVCB_DEVICE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, tag, NULL, &devcb_stub<cls, &cls::memb>, NULL } +#define DEVCB_DEVICE_LINE(tag,func) { DEVCB_TYPE_DEVICE, tag, (func), NULL, NULL } +#define DEVCB_DEVICE_LINE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, tag, &devcb_stub<cls, &cls::memb>, NULL, NULL } +#define DEVCB_DEVICE_HANDLER(tag,func) { DEVCB_TYPE_DEVICE, tag, NULL, (func), NULL } +#define DEVCB_DEVICE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, tag, NULL, &devcb_stub<cls, &cls::memb>, NULL } /* read/write handlers for a given CPU's address space */ #define DEVCB_MEMORY_HANDLER(cpu,space,func) { DEVCB_TYPE_MEMORY(ADDRESS_SPACE_##space), (cpu), NULL, NULL, (func) } @@ -104,6 +123,11 @@ void devcb_stub(device_t *device, offs_t offset, UINT8 data) #define READ_LINE_DEVICE_HANDLER(name) int name(ATTR_UNUSED device_t *device) #define WRITE_LINE_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_t *device, ATTR_UNUSED int state) +#define DECLARE_READ_LINE_MEMBER(name) int name() +#define READ_LINE_MEMBER(name) int name() +#define DECLARE_WRITE_LINE_MEMBER(name) void name(ATTR_UNUSED int state) +#define WRITE_LINE_MEMBER(name) void name(ATTR_UNUSED int state) + /* macros for inline device handler initialization */ #define MDRV_DEVICE_CONFIG_DEVCB_GENERIC(_access, _struct, _entry, _tag, _type, _linefunc, _devfunc, _spacefunc) \ diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index fa5bbc7eea8..48de6e08e32 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -218,9 +218,9 @@ void via6522_device::device_start() m_t2ll = 0xff; /* taken from vice */ m_t2lh = 0xff; m_time2 = m_time1 = timer_get_time(&m_machine); - m_t1 = timer_alloc(&m_machine, t1_timeout_callback, (void *)this); - m_t2 = timer_alloc(&m_machine, t2_timeout_callback, (void *)this); - m_shift_timer = timer_alloc(&m_machine, shift_callback, (void *)this); + m_t1 = device_timer_alloc(*this); + m_t2 = device_timer_alloc(*this); + m_shift_timer = device_timer_alloc(*this); /* Default clock is from CPU1 */ if (clock() == 0) @@ -415,86 +415,62 @@ void via6522_device::shift() } -/*------------------------------------------------- - TIMER_CALLBACK( via_shift_callback ) --------------------------------------------------*/ - -TIMER_CALLBACK( via6522_device::shift_callback ) -{ - via6522_device *via = reinterpret_cast<via6522_device *>(ptr); - via->shift(); -} - - -/*------------------------------------------------- - TIMER_CALLBACK( via_t1_timeout ) --------------------------------------------------*/ - -TIMER_CALLBACK( via6522_device::t1_timeout_callback ) +void via6522_device::device_timer(emu_timer &timer, int param, void *ptr) { - via6522_device *via = reinterpret_cast<via6522_device *>(ptr); - via->t1_timeout(); -} - -void via6522_device::t1_timeout() -{ - if (T1_CONTINUOUS (m_acr)) - { - if (T1_SET_PB7(m_acr)) - { - m_out_b ^= 0x80; - } - timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0); - } - else - { - if (T1_SET_PB7(m_acr)) - { - m_out_b |= 0x80; - } - m_t1_active = 0; - m_time1 = timer_get_time(&m_machine); - } - if (m_ddr_b) + // shift timer + if (&timer == m_shift_timer) + shift(); + + // t1 timeout + else if (&timer == m_t1) { - UINT8 write_data = (m_out_b & m_ddr_b) | (m_ddr_b ^ 0xff); - devcb_call_write8(&m_out_b_func, 0, write_data); - } - - if (!(m_ifr & INT_T1)) - { - set_int(INT_T1); - } -} - - -/*------------------------------------------------- - TIMER_CALLBACK( via_t2_timeout ) --------------------------------------------------*/ - -TIMER_CALLBACK( via6522_device::t2_timeout_callback ) -{ - via6522_device *via = reinterpret_cast<via6522_device *>(ptr); - via->t2_timeout(); -} + if (T1_CONTINUOUS (m_acr)) + { + if (T1_SET_PB7(m_acr)) + { + m_out_b ^= 0x80; + } + timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0); + } + else + { + if (T1_SET_PB7(m_acr)) + { + m_out_b |= 0x80; + } + m_t1_active = 0; + m_time1 = timer_get_time(&m_machine); + } + if (m_ddr_b) + { + UINT8 write_data = (m_out_b & m_ddr_b) | (m_ddr_b ^ 0xff); + devcb_call_write8(&m_out_b_func, 0, write_data); + } -void via6522_device::t2_timeout() -{ - m_t2_active = 0; - m_time2 = timer_get_time(&m_machine); + if (!(m_ifr & INT_T1)) + { + set_int(INT_T1); + } + } + + // t2 timeout + else if (&timer == m_t2) + { + m_t2_active = 0; + m_time2 = timer_get_time(&m_machine); - if (!(m_ifr & INT_T2)) - { - set_int(INT_T2); - } + if (!(m_ifr & INT_T2)) + { + set_int(INT_T2); + } + } } - /*------------------------------------------------- via_r - CPU interface for VIA read -------------------------------------------------*/ -READ8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_r) +READ8_MEMBER( via6522_device::read ) { int val = 0; @@ -652,15 +628,14 @@ READ8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_r) case VIA_SR: val = m_sr; + m_shift_counter=0; clear_int(INT_SR); if (SO_O2_CONTROL(m_acr)) { - m_shift_counter=0; timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0); } if (SO_T2_CONTROL(m_acr)) { - m_shift_counter=0; timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0); } break; @@ -689,7 +664,7 @@ READ8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_r) via_w - CPU interface for VIA write -------------------------------------------------*/ -WRITE8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_w) +WRITE8_MEMBER( via6522_device::write ) { offset &=0x0f; @@ -858,11 +833,11 @@ WRITE8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_w) clear_int(INT_SR); if (SO_O2_CONTROL(m_acr)) { - timer_set(&m_machine, cycles_to_time(2), (void *)this, 0, shift_callback); + timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0); } if (SO_T2_CONTROL(m_acr)) { - timer_set(&m_machine, cycles_to_time((m_t2ll + 2)*2), (void *)this, 0, shift_callback); + timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0); } break; @@ -959,8 +934,7 @@ WRITE8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_w) ca1_w - interface setting VIA port CA1 input -------------------------------------------------*/ -//void via6522_device::via_ca1_w(UINT8 state) -WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_ca1_w) +WRITE_LINE_MEMBER( via6522_device::write_ca1 ) { /* handle the active transition */ if (state != m_in_ca1) @@ -1008,8 +982,7 @@ WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_ca1_w) ca2_w - interface setting VIA port CA2 input -------------------------------------------------*/ -//void via6522_device::via_ca2_w(UINT8 state) -WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_ca2_w) +WRITE_LINE_MEMBER( via6522_device::write_ca2 ) { /* CA2 is in input mode */ if (CA2_INPUT(m_pcr)) @@ -1034,8 +1007,7 @@ WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_ca2_w) cb1_w - interface setting VIA port CB1 input -------------------------------------------------*/ -//void via6522_device::via_cb1_w(UINT8 state) -WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_cb1_w) +WRITE_LINE_MEMBER( via6522_device::write_cb1 ) { /* handle the active transition */ if (state != m_in_cb1) @@ -1083,8 +1055,7 @@ WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_cb1_w) cb2_w - interface setting VIA port CB2 input -------------------------------------------------*/ -//void via6522_device::via_cb2_w(UINT8 state) -WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_cb2_w) +WRITE_LINE_MEMBER( via6522_device::write_cb2 ) { /* CB2 is in input mode */ if (CB2_INPUT(m_pcr)) @@ -1103,17 +1074,3 @@ WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_cb2_w) } } } - - - -/*************************************************************************** - TRAMPOLINES -***************************************************************************/ - -READ_LINE_DEVICE_HANDLER(via_ca1_r) { return downcast<via6522_device *>(device)->via_ca1_r(); } -READ_LINE_DEVICE_HANDLER(via_ca2_r) { return downcast<via6522_device *>(device)->via_ca2_r(); } -READ_LINE_DEVICE_HANDLER(via_cb1_r) { return downcast<via6522_device *>(device)->via_cb1_r(); } -READ_LINE_DEVICE_HANDLER(via_cb2_r) { return downcast<via6522_device *>(device)->via_cb2_r(); } -WRITE8_DEVICE_HANDLER(via_porta_w) { downcast<via6522_device *>(device)->via_porta_w(data); } -READ8_DEVICE_HANDLER(via_portb_r) { return downcast<via6522_device *>(device)->via_portb_r(); } -WRITE8_DEVICE_HANDLER(via_portb_w) { downcast<via6522_device *>(device)->via_portb_w(data); } diff --git a/src/emu/machine/6522via.h b/src/emu/machine/6522via.h index d1b8daccc09..f8729903332 100644 --- a/src/emu/machine/6522via.h +++ b/src/emu/machine/6522via.h @@ -109,36 +109,31 @@ class via6522_device : public device_t via6522_device(running_machine &_machine, const via6522_device_config &_config); public: - UINT8 via_r(UINT32 offset); - void via_w(UINT32 offset, UINT8 data); + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); - void via_porta_w(UINT8 data) { m_in_a = data; } + DECLARE_WRITE8_MEMBER( write_porta ) { m_in_a = data; } - UINT8 via_portb_r() { return m_in_b; } - void via_portb_w(UINT8 data) { m_in_b = data; } + DECLARE_READ8_MEMBER( read_portb ) { return m_in_b; } + DECLARE_WRITE8_MEMBER( write_portb ) { m_in_b = data; } - UINT8 via_ca1_r() { return m_in_ca1; } - void via_ca1_w(UINT8 data); + DECLARE_READ_LINE_MEMBER( read_ca1 ) { return m_in_ca1; } + DECLARE_WRITE_LINE_MEMBER( write_ca1 ); - UINT8 via_ca2_r() { return m_in_ca2; } - void via_ca2_w(UINT8 data); + DECLARE_READ_LINE_MEMBER( read_ca2 ) { return m_in_ca2; } + DECLARE_WRITE_LINE_MEMBER( write_ca2 ); - UINT8 via_cb1_r() { return m_in_cb1; } - void via_cb1_w(UINT8 data); + DECLARE_READ_LINE_MEMBER( read_cb1 ) { return m_in_cb1; } + DECLARE_WRITE_LINE_MEMBER( write_cb1 ); - UINT8 via_cb2_r() { return m_in_cb2; } - void via_cb2_w(UINT8 data); + DECLARE_READ_LINE_MEMBER( read_cb2 ) { return m_in_cb2; } + DECLARE_WRITE_LINE_MEMBER( write_cb2 ); protected: // device-level overrides virtual void device_start(); virtual void device_reset(); - virtual void device_post_load() { } - virtual void device_clock_changed() { } - - static TIMER_CALLBACK( t1_timeout_callback ); - static TIMER_CALLBACK( t2_timeout_callback ); - static TIMER_CALLBACK( shift_callback ); + virtual void device_timer(emu_timer &timer, int param, void *ptr); private: attotime cycles_to_time(int c); @@ -148,8 +143,6 @@ private: void set_int(int data); void clear_int(int data); void shift(); - void t1_timeout(); - void t2_timeout(); devcb_resolved_read8 m_in_a_func; devcb_resolved_read8 m_in_b_func; @@ -212,29 +205,4 @@ private: extern const device_type VIA6522; - -/*************************************************************************** - PROTOTYPES -***************************************************************************/ - -READ8_DEVICE_HANDLER(via_r); -WRITE8_DEVICE_HANDLER(via_w); - -WRITE8_DEVICE_HANDLER(via_porta_w); - -READ8_DEVICE_HANDLER(via_portb_r); -WRITE8_DEVICE_HANDLER(via_portb_w); - -READ_LINE_DEVICE_HANDLER(via_ca1_r); -WRITE_LINE_DEVICE_HANDLER(via_ca1_w); - -READ_LINE_DEVICE_HANDLER(via_ca2_r); -WRITE_LINE_DEVICE_HANDLER(via_ca2_w); - -READ_LINE_DEVICE_HANDLER(via_cb1_r); -WRITE_LINE_DEVICE_HANDLER(via_cb1_w); - -READ_LINE_DEVICE_HANDLER(via_cb2_r); -WRITE_LINE_DEVICE_HANDLER(via_cb2_w); - #endif /* __6522VIA_H__ */ diff --git a/src/mame/drivers/86lions.c b/src/mame/drivers/86lions.c index d983ed7c3d8..b4ec94182e5 100644 --- a/src/mame/drivers/86lions.c +++ b/src/mame/drivers/86lions.c @@ -74,25 +74,12 @@ static READ8_HANDLER( test_r ) } -static READ8_HANDLER(lions_via_r) -{ - running_device *via_0 = space->machine->device("via6522_0"); - return via_r(via_0, offset); -} - -static WRITE8_HANDLER(lions_via_w) -{ - running_device *via_0 = space->machine->device("via6522_0"); - via_w(via_0, offset, data); -} - - static ADDRESS_MAP_START( lions_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&lions_vram) AM_RANGE(0x0800, 0x0fff) AM_RAM AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("crtc", mc6845_address_w) AM_RANGE(0x1801, 0x1801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w) - AM_RANGE(0x5000, 0x500f) AM_MIRROR(0x0010) AM_READWRITE(lions_via_r, lions_via_w) + AM_RANGE(0x5000, 0x500f) AM_MIRROR(0x0010) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write) AM_RANGE(0x5300, 0x5300) AM_READ(test_r)//AM_READ_PORT("IN0") AM_RANGE(0x5382, 0x5383) AM_DEVWRITE("aysnd", ay8910_data_address_w) AM_RANGE(0xe000, 0xffff) AM_ROM diff --git a/src/mame/drivers/aristmk4.c b/src/mame/drivers/aristmk4.c index 84ea49b72d9..3e75fa2b1e2 100644 --- a/src/mame/drivers/aristmk4.c +++ b/src/mame/drivers/aristmk4.c @@ -688,7 +688,7 @@ static ADDRESS_MAP_START( aristmk4_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x500d, 0x500d) AM_READ_PORT("500d") AM_RANGE(0x500e, 0x500e) AM_READ_PORT("500e") AM_RANGE(0x500f, 0x500f) AM_READ_PORT("500f") - AM_RANGE(0x5010, 0x501f) AM_DEVREADWRITE("via6522_0",via_r,via_w) + AM_RANGE(0x5010, 0x501f) AM_DEVREADWRITE_MODERN("via6522_0",via6522_device,read,write) AM_RANGE(0x5200, 0x5200) AM_READ(cashcade_r) AM_RANGE(0x5201, 0x5201) AM_READ_PORT("5201") AM_RANGE(0x527f, 0x5281) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w) diff --git a/src/mame/drivers/atarisy1.c b/src/mame/drivers/atarisy1.c index 2a070348e98..3f478d5c66a 100644 --- a/src/mame/drivers/atarisy1.c +++ b/src/mame/drivers/atarisy1.c @@ -484,7 +484,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x0fff) AM_RAM - AM_RANGE(0x1000, 0x100f) AM_DEVREADWRITE("via6522_0", via_r, via_w) + AM_RANGE(0x1000, 0x100f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write) AM_RANGE(0x1800, 0x1801) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w) AM_RANGE(0x1810, 0x1810) AM_READWRITE(atarigen_6502_sound_r, atarigen_6502_sound_w) AM_RANGE(0x1820, 0x1820) AM_READ(switch_6502_r) diff --git a/src/mame/drivers/beezer.c b/src/mame/drivers/beezer.c index 699d8c043e7..320001fd9a2 100644 --- a/src/mame/drivers/beezer.c +++ b/src/mame/drivers/beezer.c @@ -23,7 +23,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x07ff) AM_RAM // AM_RANGE(0x1000, 0x10ff) AM_READWRITE(beezer_6840_r, beezer_6840_w) - AM_RANGE(0x1800, 0x18ff) AM_DEVREADWRITE("via6522_1", via_r, via_w) + AM_RANGE(0x1800, 0x18ff) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write) // AM_RANGE(0x8000, 0x9fff) AM_WRITE(beezer_dac_w) AM_RANGE(0xe000, 0xffff) AM_ROM ADDRESS_MAP_END diff --git a/src/mame/drivers/bmcbowl.c b/src/mame/drivers/bmcbowl.c index 50992c2aaa0..c595007e89a 100644 --- a/src/mame/drivers/bmcbowl.c +++ b/src/mame/drivers/bmcbowl.c @@ -211,18 +211,6 @@ static WRITE16_HANDLER( scroll_w ) } -static READ16_HANDLER(bmcbowl_via_r) -{ - running_device *via_0 = space->machine->device("via6522_0"); - return via_r(via_0, offset); -} - -static WRITE16_HANDLER(bmcbowl_via_w) -{ - running_device *via_0 = space->machine->device("via6522_0"); - via_w(via_0, offset, data); -} - static READ8_DEVICE_HANDLER(via_b_in) { return input_port_read(device->machine, "IN3"); @@ -333,7 +321,7 @@ static ADDRESS_MAP_START( bmcbowl_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x091000, 0x091001) AM_WRITENOP AM_RANGE(0x091800, 0x091801) AM_WRITE(scroll_w) - AM_RANGE(0x092000, 0x09201f) AM_READWRITE(bmcbowl_via_r, bmcbowl_via_w) + AM_RANGE(0x092000, 0x09201f) AM_DEVREADWRITE8_MODERN("via6522_0", via6522_device, read, write, 0x00ff) AM_RANGE(0x093000, 0x093003) AM_WRITENOP // related to music AM_RANGE(0x092800, 0x092803) AM_DEVWRITE8("aysnd", ay8910_data_address_w, 0xff00) diff --git a/src/mame/drivers/gameplan.c b/src/mame/drivers/gameplan.c index 4abba351b2b..a1d7dbb265a 100644 --- a/src/mame/drivers/gameplan.c +++ b/src/mame/drivers/gameplan.c @@ -217,9 +217,9 @@ static const riot6532_interface r6532_interface = static ADDRESS_MAP_START( gameplan_main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM - AM_RANGE(0x2000, 0x200f) AM_MIRROR(0x07f0) AM_DEVREADWRITE("via6522_0", via_r, via_w) /* VIA 1 */ - AM_RANGE(0x2800, 0x280f) AM_MIRROR(0x07f0) AM_DEVREADWRITE("via6522_1", via_r, via_w) /* VIA 2 */ - AM_RANGE(0x3000, 0x300f) AM_MIRROR(0x07f0) AM_DEVREADWRITE("via6522_2", via_r, via_w) /* VIA 3 */ + AM_RANGE(0x2000, 0x200f) AM_MIRROR(0x07f0) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write) /* VIA 1 */ + AM_RANGE(0x2800, 0x280f) AM_MIRROR(0x07f0) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write) /* VIA 2 */ + AM_RANGE(0x3000, 0x300f) AM_MIRROR(0x07f0) AM_DEVREADWRITE_MODERN("via6522_2", via6522_device, read, write) /* VIA 3 */ AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -987,9 +987,6 @@ static MACHINE_START( gameplan ) state->maincpu = machine->device("maincpu"); state->audiocpu = machine->device("audiocpu"); state->riot = machine->device("riot"); - state->via_0 = machine->device("via6522_0"); - state->via_1 = machine->device("via6522_1"); - state->via_2 = machine->device("via6522_2"); /* register for save states */ state_save_register_global(machine, state->current_port); diff --git a/src/mame/drivers/itech32.c b/src/mame/drivers/itech32.c index 72c4e0cac8e..ddaf650b36f 100644 --- a/src/mame/drivers/itech32.c +++ b/src/mame/drivers/itech32.c @@ -1109,7 +1109,7 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0800, 0x083f) AM_MIRROR(0x80) AM_DEVREADWRITE("ensoniq", es5506_r, es5506_w) AM_RANGE(0x0c00, 0x0c00) AM_WRITE(sound_bank_w) AM_RANGE(0x1000, 0x1000) AM_WRITENOP /* noisy */ - AM_RANGE(0x1400, 0x140f) AM_DEVREADWRITE("via6522_0", via_r, via_w) + AM_RANGE(0x1400, 0x140f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write) AM_RANGE(0x2000, 0x3fff) AM_RAM AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0xffff) AM_ROM @@ -1728,7 +1728,7 @@ static const es5506_interface es5506_config = * *************************************/ -static MACHINE_CONFIG_START( timekill, driver_device ) +static MACHINE_CONFIG_START( timekill, itech32_state ) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, CPU_CLOCK) diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index abe0a5089a3..bd771ada1a1 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -997,7 +997,7 @@ static ADDRESS_MAP_START( sound3812_external_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x2000, 0x2001) AM_DEVREADWRITE("ymsnd", ym3812_r, ym3812_w) AM_RANGE(0x3000, 0x37ff) AM_RAM AM_RANGE(0x4000, 0x4000) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write) - AM_RANGE(0x5000, 0x500f) AM_DEVREADWRITE("via6522_0", via_r, via_w) + AM_RANGE(0x5000, 0x500f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write) AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END diff --git a/src/mame/drivers/trvquest.c b/src/mame/drivers/trvquest.c index 641a9384d1e..2a668d733ec 100644 --- a/src/mame/drivers/trvquest.c +++ b/src/mame/drivers/trvquest.c @@ -61,9 +61,9 @@ static WRITE8_DEVICE_HANDLER( trvquest_misc_w ) static ADDRESS_MAP_START( cpu_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("nvram") // cmos ram AM_RANGE(0x2000, 0x27ff) AM_RAM // main ram - AM_RANGE(0x3800, 0x380f) AM_DEVREADWRITE("via6522_1", via_r, via_w) - AM_RANGE(0x3810, 0x381f) AM_DEVREADWRITE("via6522_2", via_r, via_w) - AM_RANGE(0x3820, 0x382f) AM_DEVREADWRITE("via6522_0", via_r, via_w) + AM_RANGE(0x3800, 0x380f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write) + AM_RANGE(0x3810, 0x381f) AM_DEVREADWRITE_MODERN("via6522_2", via6522_device, read, write) + AM_RANGE(0x3820, 0x382f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write) AM_RANGE(0x3830, 0x3831) AM_DEVWRITE("ay1", ay8910_address_data_w) AM_RANGE(0x3840, 0x3841) AM_DEVWRITE("ay2", ay8910_address_data_w) AM_RANGE(0x3850, 0x3850) AM_READNOP //watchdog_reset_r ? @@ -188,9 +188,6 @@ static MACHINE_START( trvquest ) gameplan_state *state = machine->driver_data<gameplan_state>(); state->maincpu = machine->device("maincpu"); - state->via_0 = machine->device("via6522_0"); - state->via_1 = machine->device("via6522_1"); - state->via_2 = machine->device("via6522_2"); /* register for save states */ state_save_register_global(machine, state->video_x); @@ -212,8 +209,8 @@ static MACHINE_RESET( trvquest ) static INTERRUPT_GEN( trvquest_interrupt ) { gameplan_state *state = device->machine->driver_data<gameplan_state>(); - via_ca1_w(state->via_2, 1); - via_ca1_w(state->via_2, 0); + state->via_2->write_ca1(1); + state->via_2->write_ca1(0); } static MACHINE_CONFIG_START( trvquest, gameplan_state ) diff --git a/src/mame/includes/gameplan.h b/src/mame/includes/gameplan.h index 31b7ee22586..397bef9df28 100644 --- a/src/mame/includes/gameplan.h +++ b/src/mame/includes/gameplan.h @@ -25,7 +25,10 @@ class gameplan_state : public driver_device { public: gameplan_state(running_machine &machine, const driver_device_config_base &config) - : driver_device(machine, config) { } + : driver_device(machine, config), + via_0(*this, "via6522_0"), + via_1(*this, "via6522_1"), + via_2(*this, "via6522_2") { } /* machine state */ UINT8 current_port; @@ -44,9 +47,9 @@ public: running_device *maincpu; running_device *audiocpu; running_device *riot; - running_device *via_0; - running_device *via_1; - running_device *via_2; + required_device<via6522_device> via_0; + required_device<via6522_device> via_1; + required_device<via6522_device> via_2; }; diff --git a/src/mame/machine/beezer.c b/src/mame/machine/beezer.c index 09f019d7632..8dce90acf13 100644 --- a/src/mame/machine/beezer.c +++ b/src/mame/machine/beezer.c @@ -19,18 +19,18 @@ static WRITE8_DEVICE_HANDLER( b_via_1_pb_w ); const via6522_interface b_via_0_interface = { /*inputs : A/B */ DEVCB_NULL, DEVCB_HANDLER(b_via_0_pb_r), - /*inputs : CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_DEVICE_LINE("via6522_1", via_ca2_r), DEVCB_LINE(b_via_0_ca2_r), DEVCB_DEVICE_LINE("via6522_1", via_ca1_r), + /*inputs : CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_DEVICE_LINE_MEMBER("via6522_1", via6522_device, read_ca2), DEVCB_LINE(b_via_0_ca2_r), DEVCB_DEVICE_LINE_MEMBER("via6522_1", via6522_device, read_ca1), /*outputs: A/B */ DEVCB_HANDLER(b_via_0_pa_w), DEVCB_HANDLER(b_via_0_pb_w), - /*outputs: CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_LINE(b_via_0_ca2_w), DEVCB_DEVICE_LINE("via6522_1", via_ca1_w), + /*outputs: CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_LINE(b_via_0_ca2_w), DEVCB_DEVICE_LINE_MEMBER("via6522_1", via6522_device, write_ca1), /*irq */ DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE) }; const via6522_interface b_via_1_interface = { /*inputs : A/B */ DEVCB_HANDLER(b_via_1_pa_r), DEVCB_HANDLER(b_via_1_pb_r), - /*inputs : CA/B1,CA/B2 */ DEVCB_DEVICE_LINE("via6522_0", via_cb2_r), DEVCB_NULL, DEVCB_DEVICE_LINE("via6522_0", via_cb1_r), DEVCB_NULL, + /*inputs : CA/B1,CA/B2 */ DEVCB_DEVICE_LINE_MEMBER("via6522_0", via6522_device, read_cb2), DEVCB_NULL, DEVCB_DEVICE_LINE_MEMBER("via6522_0", via6522_device, read_cb1), DEVCB_NULL, /*outputs: A/B */ DEVCB_HANDLER(b_via_1_pa_w), DEVCB_HANDLER(b_via_1_pb_w), - /*outputs: CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE("via6522_0", via_cb1_w), DEVCB_NULL, + /*outputs: CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE_MEMBER("via6522_0", via6522_device, write_cb1), DEVCB_NULL, /*irq */ DEVCB_CPU_INPUT_LINE("audiocpu", M6809_IRQ_LINE) }; @@ -108,11 +108,11 @@ WRITE8_HANDLER( beezer_bankswitch_w ) { if ((data & 0x07) == 0) { - running_device *via_0 = space->machine->device("via6522_0"); + via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0"); memory_install_write8_handler(space, 0xc600, 0xc7ff, 0, 0, watchdog_reset_w); memory_install_write8_handler(space, 0xc800, 0xc9ff, 0, 0, beezer_map_w); memory_install_read8_handler(space, 0xca00, 0xcbff, 0, 0, beezer_line_r); - memory_install_readwrite8_device_handler(space, via_0, 0xce00, 0xcfff, 0, 0, via_r, via_w); + space->install_handler(0xce00, 0xcfff, 0, 0, read8_delegate_create(via6522_device, read, *via_0), write8_delegate_create(via6522_device, write, *via_0)); } else { diff --git a/src/mame/video/beezer.c b/src/mame/video/beezer.c index 7c314462a6a..9e1a8b63138 100644 --- a/src/mame/video/beezer.c +++ b/src/mame/video/beezer.c @@ -7,10 +7,10 @@ static int scanline=0; INTERRUPT_GEN( beezer_interrupt ) { - running_device *via_0 = device->machine->device("via6522_0"); + via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0"); scanline = (scanline + 1) % 0x80; - via_ca2_w(via_0, (scanline & 0x10) ? 1 : 0); + via_0->write_ca2((scanline & 0x10) ? 1 : 0); if ((scanline & 0x78) == 0x78) cpu_set_input_line(device, M6809_FIRQ_LINE, ASSERT_LINE); else diff --git a/src/mame/video/gameplan.c b/src/mame/video/gameplan.c index dde8b213b96..b4179948b52 100644 --- a/src/mame/video/gameplan.c +++ b/src/mame/video/gameplan.c @@ -145,7 +145,7 @@ static TIMER_CALLBACK( clear_screen_done_callback ) gameplan_state *state = machine->driver_data<gameplan_state>(); /* indicate that the we are done clearing the screen */ - via_ca1_w(state->via_0, 0); + state->via_0->write_ca1(0); } @@ -195,7 +195,7 @@ static WRITE_LINE_DEVICE_HANDLER( video_command_trigger_w ) case 3: /* indicate that the we are busy */ { - via_ca1_w(driver_state->via_0, 1); + driver_state->via_0->write_ca1(1); } memset(driver_state->videoram, driver_state->video_data & 0x0f, driver_state->videoram_size); @@ -269,7 +269,7 @@ static TIMER_CALLBACK( via_0_ca1_timer_callback ) gameplan_state *state = machine->driver_data<gameplan_state>(); /* !VBLANK is connected to CA1 */ - via_ca1_w(state->via_0, param); + state->via_0->write_ca1(param); if (param) timer_adjust_oneshot(state->via_0_ca1_timer, machine->primary_screen->time_until_pos(VBSTART), 0); |