trunk/src/emu/machine/ins8154.c
| r29192 | r29193 | |
| 44 | 44 | //------------------------------------------------- |
| 45 | 45 | |
| 46 | 46 | ins8154_device::ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 47 | | : device_t(mconfig, INS8154, "INS8154", tag, owner, clock, "ins8154", __FILE__) |
| 47 | : device_t(mconfig, INS8154, "INS8154", tag, owner, clock, "ins8154", __FILE__), |
| 48 | m_in_a_cb(*this), |
| 49 | m_out_a_cb(*this), |
| 50 | m_in_b_cb(*this), |
| 51 | m_out_b_cb(*this), |
| 52 | m_out_irq_cb(*this) |
| 48 | 53 | { |
| 49 | 54 | } |
| 50 | 55 | |
| 51 | | |
| 52 | 56 | //------------------------------------------------- |
| 53 | | // device_config_complete - perform any |
| 54 | | // operations now that the configuration is |
| 55 | | // complete |
| 56 | | //------------------------------------------------- |
| 57 | | |
| 58 | | void ins8154_device::device_config_complete() |
| 59 | | { |
| 60 | | // inherit a copy of the static data |
| 61 | | const ins8154_interface *intf = reinterpret_cast<const ins8154_interface *>(static_config()); |
| 62 | | if (intf != NULL) |
| 63 | | { |
| 64 | | *static_cast<ins8154_interface *>(this) = *intf; |
| 65 | | } |
| 66 | | |
| 67 | | // or initialize to defaults if none provided |
| 68 | | else |
| 69 | | { |
| 70 | | memset(&m_in_a_cb, 0, sizeof(m_in_a_cb)); |
| 71 | | memset(&m_in_b_cb, 0, sizeof(m_in_b_cb)); |
| 72 | | memset(&m_out_a_cb, 0, sizeof(m_out_a_cb)); |
| 73 | | memset(&m_out_b_cb, 0, sizeof(m_out_b_cb)); |
| 74 | | memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb)); |
| 75 | | } |
| 76 | | } |
| 77 | | |
| 78 | | |
| 79 | | //------------------------------------------------- |
| 80 | 57 | // device_start - device-specific startup |
| 81 | 58 | //------------------------------------------------- |
| 82 | 59 | |
| 83 | 60 | void ins8154_device::device_start() |
| 84 | 61 | { |
| 85 | 62 | /* resolve callbacks */ |
| 86 | | m_in_a_func.resolve(m_in_a_cb, *this); |
| 87 | | m_out_a_func.resolve(m_out_a_cb, *this); |
| 88 | | m_in_b_func.resolve(m_in_b_cb, *this); |
| 89 | | m_out_b_func.resolve(m_out_b_cb, *this); |
| 90 | | m_out_irq_func.resolve(m_out_irq_cb, *this); |
| 63 | m_in_a_cb.resolve(); |
| 64 | m_out_a_cb.resolve_safe(); |
| 65 | m_in_b_cb.resolve(); |
| 66 | m_out_b_cb.resolve_safe(); |
| 67 | m_out_irq_cb.resolve_safe(); |
| 91 | 68 | |
| 92 | 69 | /* register for state saving */ |
| 93 | 70 | save_item(NAME(m_in_a)); |
| r29192 | r29193 | |
| 132 | 109 | switch (offset) |
| 133 | 110 | { |
| 134 | 111 | case 0x20: |
| 135 | | if(!m_in_a_func.isnull()) |
| 112 | if(!m_in_a_cb.isnull()) |
| 136 | 113 | { |
| 137 | | val = m_in_a_func(0); |
| 114 | val = m_in_a_cb(0); |
| 138 | 115 | } |
| 139 | 116 | m_in_a = val; |
| 140 | 117 | break; |
| 141 | 118 | |
| 142 | 119 | case 0x21: |
| 143 | | if(!m_in_b_func.isnull()) |
| 120 | if(!m_in_b_cb.isnull()) |
| 144 | 121 | { |
| 145 | | val = m_in_b_func(0); |
| 122 | val = m_in_b_cb(0); |
| 146 | 123 | } |
| 147 | 124 | m_in_b = val; |
| 148 | 125 | break; |
| r29192 | r29193 | |
| 150 | 127 | default: |
| 151 | 128 | if (offset < 0x08) |
| 152 | 129 | { |
| 153 | | if(!m_in_a_func.isnull()) |
| 130 | if(!m_in_a_cb.isnull()) |
| 154 | 131 | { |
| 155 | | val = (m_in_a_func(0) << (8 - offset)) & 0x80; |
| 132 | val = (m_in_a_cb(0) << (8 - offset)) & 0x80; |
| 156 | 133 | } |
| 157 | 134 | m_in_a = val; |
| 158 | 135 | } |
| 159 | 136 | else |
| 160 | 137 | { |
| 161 | | if(!m_in_b_func.isnull()) |
| 138 | if(!m_in_b_cb.isnull()) |
| 162 | 139 | { |
| 163 | | val = (m_in_b_func(0) << (8 - (offset >> 4))) & 0x80; |
| 140 | val = (m_in_b_cb(0) << (8 - (offset >> 4))) & 0x80; |
| 164 | 141 | } |
| 165 | 142 | m_in_b = val; |
| 166 | 143 | } |
| r29192 | r29193 | |
| 177 | 154 | /* Test if any pins are set as outputs */ |
| 178 | 155 | if (m_odra) |
| 179 | 156 | { |
| 180 | | m_out_a_func(0, (data & m_odra) | (m_odra ^ 0xff)); |
| 157 | m_out_a_cb((offs_t)0, (data & m_odra) | (m_odra ^ 0xff)); |
| 181 | 158 | } |
| 182 | 159 | } |
| 183 | 160 | |
| r29192 | r29193 | |
| 188 | 165 | /* Test if any pins are set as outputs */ |
| 189 | 166 | if (m_odrb) |
| 190 | 167 | { |
| 191 | | m_out_b_func(0, (data & m_odrb) | (m_odrb ^ 0xff)); |
| 168 | m_out_b_cb((offs_t)0, (data & m_odrb) | (m_odrb ^ 0xff)); |
| 192 | 169 | } |
| 193 | 170 | } |
| 194 | 171 | |
trunk/src/emu/machine/ins8154.h
| r29192 | r29193 | |
| 44 | 44 | DEVICE CONFIGURATION MACROS |
| 45 | 45 | ***************************************************************************/ |
| 46 | 46 | |
| 47 | | #define MCFG_INS8154_ADD(_tag, _intrf) \ |
| 48 | | MCFG_DEVICE_ADD(_tag, INS8154, 0) \ |
| 49 | | MCFG_DEVICE_CONFIG(_intrf) |
| 47 | #define MCFG_INS8154_IN_A_CB(_devcb) \ |
| 48 | devcb = &ins8154_device::set_in_a_callback(*device, DEVCB2_##_devcb); |
| 49 | |
| 50 | #define MCFG_INS8154_OUT_A_CB(_devcb) \ |
| 51 | devcb = &ins8154_device::set_out_a_callback(*device, DEVCB2_##_devcb); |
| 52 | |
| 53 | #define MCFG_INS8154_IN_B_CB(_devcb) \ |
| 54 | devcb = &ins8154_device::set_in_b_callback(*device, DEVCB2_##_devcb); |
| 55 | |
| 56 | #define MCFG_INS8154_OUT_B_CB(_devcb) \ |
| 57 | devcb = &ins8154_device::set_out_b_callback(*device, DEVCB2_##_devcb); |
| 50 | 58 | |
| 59 | #define MCFG_INS8154_OUT_IRQ_CB(_devcb) \ |
| 60 | devcb = &ins8154_device::set_out_irq_callback(*device, DEVCB2_##_devcb); //currently unused |
| 51 | 61 | |
| 52 | 62 | /*************************************************************************** |
| 53 | 63 | TYPE DEFINITIONS |
| 54 | 64 | ***************************************************************************/ |
| 55 | 65 | |
| 56 | | |
| 57 | | // ======================> ins8154_interface |
| 58 | | |
| 59 | | struct ins8154_interface |
| 60 | | { |
| 61 | | devcb_read8 m_in_a_cb; |
| 62 | | devcb_write8 m_out_a_cb; |
| 63 | | devcb_read8 m_in_b_cb; |
| 64 | | devcb_write8 m_out_b_cb; |
| 65 | | devcb_write_line m_out_irq_cb; |
| 66 | | }; |
| 67 | | |
| 68 | | |
| 69 | | |
| 70 | 66 | // ======================> ins8154_device |
| 71 | 67 | |
| 72 | | class ins8154_device : public device_t, |
| 73 | | public ins8154_interface |
| 68 | class ins8154_device : public device_t |
| 74 | 69 | { |
| 75 | 70 | public: |
| 76 | 71 | // construction/destruction |
| 77 | 72 | ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 78 | 73 | |
| 74 | template<class _Object> static devcb2_base &set_in_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_a_cb.set_callback(object); } |
| 75 | template<class _Object> static devcb2_base &set_out_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_a_cb.set_callback(object); } |
| 76 | template<class _Object> static devcb2_base &set_in_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_b_cb.set_callback(object); } |
| 77 | template<class _Object> static devcb2_base &set_out_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_b_cb.set_callback(object); } |
| 78 | template<class _Object> static devcb2_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_irq_cb.set_callback(object); } |
| 79 | |
| 79 | 80 | DECLARE_READ8_MEMBER( ins8154_r ); |
| 80 | 81 | DECLARE_WRITE8_MEMBER( ins8154_w ); |
| 81 | 82 | |
| r29192 | r29193 | |
| 84 | 85 | |
| 85 | 86 | protected: |
| 86 | 87 | // device-level overrides |
| 87 | | virtual void device_config_complete(); |
| 88 | 88 | virtual void device_start(); |
| 89 | 89 | virtual void device_reset(); |
| 90 | 90 | virtual void device_post_load() { } |
| r29192 | r29193 | |
| 93 | 93 | private: |
| 94 | 94 | |
| 95 | 95 | /* i/o lines */ |
| 96 | | devcb_resolved_read8 m_in_a_func; |
| 97 | | devcb_resolved_write8 m_out_a_func; |
| 98 | | devcb_resolved_read8 m_in_b_func; |
| 99 | | devcb_resolved_write8 m_out_b_func; |
| 100 | | devcb_resolved_write_line m_out_irq_func; |
| 96 | devcb2_read8 m_in_a_cb; |
| 97 | devcb2_write8 m_out_a_cb; |
| 98 | devcb2_read8 m_in_b_cb; |
| 99 | devcb2_write8 m_out_b_cb; |
| 100 | devcb2_write_line m_out_irq_cb; |
| 101 | 101 | |
| 102 | 102 | /* registers */ |
| 103 | 103 | UINT8 m_in_a; /* Input Latch Port A */ |
trunk/src/mess/drivers/acrnsys1.c
| r29192 | r29193 | |
| 233 | 233 | MACHINE DRIVERS |
| 234 | 234 | ***************************************************************************/ |
| 235 | 235 | |
| 236 | | static const ins8154_interface ins8154_b1 = |
| 237 | | { |
| 238 | | DEVCB_DRIVER_MEMBER(acrnsys1_state, ins8154_b1_port_a_r), |
| 239 | | DEVCB_DRIVER_MEMBER(acrnsys1_state, ins8154_b1_port_a_w), |
| 240 | | DEVCB_NULL, |
| 241 | | DEVCB_DRIVER_MEMBER(acrnsys1_state, acrnsys1_led_segment_w), |
| 242 | | DEVCB_NULL |
| 243 | | }; |
| 244 | | |
| 245 | 236 | static MACHINE_CONFIG_START( acrnsys1, acrnsys1_state ) |
| 246 | 237 | /* basic machine hardware */ |
| 247 | 238 | MCFG_CPU_ADD("maincpu", M6502, 1008000) /* 1.008 MHz */ |
| r29192 | r29193 | |
| 255 | 246 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 256 | 247 | |
| 257 | 248 | /* devices */ |
| 258 | | MCFG_INS8154_ADD("b1", ins8154_b1) |
| 249 | MCFG_DEVICE_ADD("b1", INS8154, 0) |
| 250 | MCFG_INS8154_IN_A_CB(READ8(acrnsys1_state, ins8154_b1_port_a_r)) |
| 251 | MCFG_INS8154_OUT_A_CB(WRITE8(acrnsys1_state, ins8154_b1_port_a_w)) |
| 252 | MCFG_INS8154_OUT_B_CB(WRITE8(acrnsys1_state, acrnsys1_led_segment_w)) |
| 259 | 253 | MCFG_DEVICE_ADD("ic8_7445", TTL74145, 0) |
| 260 | 254 | MCFG_CASSETTE_ADD( "cassette", default_cassette_interface ) |
| 261 | 255 | MCFG_TIMER_DRIVER_ADD_PERIODIC("acrnsys1_c", acrnsys1_state, acrnsys1_c, attotime::from_hz(4800)) |
trunk/src/mame/drivers/vega.c
| r29192 | r29193 | |
| 807 | 807 | }; |
| 808 | 808 | |
| 809 | 809 | |
| 810 | | static const ins8154_interface ins8154_intf = |
| 811 | | { |
| 812 | | DEVCB_DRIVER_MEMBER(vega_state, ins8154_pa_r), |
| 813 | | DEVCB_DRIVER_MEMBER(vega_state, ins8154_pa_w), |
| 814 | | DEVCB_DRIVER_MEMBER(vega_state, ins8154_pb_r), |
| 815 | | DEVCB_DRIVER_MEMBER(vega_state, ins8154_pb_w), |
| 816 | | DEVCB_NULL |
| 817 | | }; |
| 818 | | |
| 819 | | |
| 820 | 810 | static const ay8910_interface ay8910_inf = |
| 821 | 811 | { |
| 822 | 812 | AY8910_LEGACY_OUTPUT, |
| r29192 | r29193 | |
| 843 | 833 | |
| 844 | 834 | |
| 845 | 835 | MCFG_I8255A_ADD( "ppi8255", ppi8255_intf ) |
| 846 | | MCFG_INS8154_ADD( "ins8154", ins8154_intf) |
| 836 | MCFG_DEVICE_ADD( "ins8154", INS8154, 0 ) |
| 837 | MCFG_INS8154_IN_A_CB(READ8(vega_state, ins8154_pa_r)) |
| 838 | MCFG_INS8154_OUT_A_CB(WRITE8(vega_state, ins8154_pa_w)) |
| 839 | MCFG_INS8154_IN_B_CB(READ8(vega_state, ins8154_pb_r)) |
| 840 | MCFG_INS8154_OUT_B_CB(WRITE8(vega_state, ins8154_pb_w)) |
| 847 | 841 | |
| 848 | 842 | /* video hardware */ |
| 849 | 843 | MCFG_SCREEN_ADD("screen", RASTER) |