src/emu/machine/i8214.c
| r0 | r11136 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Intel 8214 Priority Interrupt Controller emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "emu.h" |
| 11 | #include "i8214.h" |
| 12 | #include "machine/devhelpr.h" |
| 13 | |
| 14 | |
| 15 | |
| 16 | //************************************************************************** |
| 17 | // MACROS / CONSTANTS |
| 18 | //************************************************************************** |
| 19 | |
| 20 | #define LOG 0 |
| 21 | |
| 22 | |
| 23 | |
| 24 | //************************************************************************** |
| 25 | // GLOBAL VARIABLES |
| 26 | //************************************************************************** |
| 27 | |
| 28 | // devices |
| 29 | const device_type I8214 = i8214_device_config::static_alloc_device_config; |
| 30 | |
| 31 | |
| 32 | |
| 33 | //************************************************************************** |
| 34 | // DEVICE CONFIGURATION |
| 35 | //************************************************************************** |
| 36 | |
| 37 | GENERIC_DEVICE_CONFIG_SETUP(i8214, "I8214") |
| 38 | |
| 39 | |
| 40 | //------------------------------------------------- |
| 41 | // device_config_complete - perform any |
| 42 | // operations now that the configuration is |
| 43 | // complete |
| 44 | //------------------------------------------------- |
| 45 | |
| 46 | void i8214_device_config::device_config_complete() |
| 47 | { |
| 48 | // inherit a copy of the static data |
| 49 | const i8214_interface *intf = reinterpret_cast<const i8214_interface *>(static_config()); |
| 50 | if (intf != NULL) |
| 51 | *static_cast<i8214_interface *>(this) = *intf; |
| 52 | |
| 53 | // or initialize to defaults if none provided |
| 54 | else |
| 55 | { |
| 56 | memset(&m_out_int_func, 0, sizeof(m_out_int_func)); |
| 57 | memset(&m_out_enlg_func, 0, sizeof(m_out_enlg_func)); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | |
| 62 | |
| 63 | //************************************************************************** |
| 64 | // INLINE HELPERS |
| 65 | //************************************************************************** |
| 66 | |
| 67 | //------------------------------------------------- |
| 68 | // trigger_interrupt - |
| 69 | //------------------------------------------------- |
| 70 | |
| 71 | inline void i8214_device::trigger_interrupt(int level) |
| 72 | { |
| 73 | if (LOG) logerror("I8214 '%s' Interrupt Level %u\n", tag(), level); |
| 74 | |
| 75 | m_a = level; |
| 76 | |
| 77 | // disable interrupts |
| 78 | m_int_dis = 1; |
| 79 | |
| 80 | // disable next level group |
| 81 | devcb_call_write_line(&m_out_enlg_func, 0); |
| 82 | |
| 83 | // toggle interrupt line |
| 84 | devcb_call_write_line(&m_out_int_func, ASSERT_LINE); |
| 85 | devcb_call_write_line(&m_out_int_func, CLEAR_LINE); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | //------------------------------------------------- |
| 90 | // check_interrupt - |
| 91 | //------------------------------------------------- |
| 92 | |
| 93 | inline void i8214_device::check_interrupt() |
| 94 | { |
| 95 | int level; |
| 96 | |
| 97 | if (m_int_dis || !m_etlg) return; |
| 98 | |
| 99 | for (level = 7; level >= 0; level--) |
| 100 | { |
| 101 | if (!BIT(m_r, 7 - level)) |
| 102 | { |
| 103 | if (m_sgs) |
| 104 | { |
| 105 | if (level > m_b) |
| 106 | { |
| 107 | trigger_interrupt(level); |
| 108 | } |
| 109 | } |
| 110 | else |
| 111 | { |
| 112 | trigger_interrupt(level); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | |
| 119 | |
| 120 | //************************************************************************** |
| 121 | // LIVE DEVICE |
| 122 | //************************************************************************** |
| 123 | |
| 124 | //------------------------------------------------- |
| 125 | // i8214_device - constructor |
| 126 | //------------------------------------------------- |
| 127 | |
| 128 | i8214_device::i8214_device(running_machine &_machine, const i8214_device_config &config) |
| 129 | : device_t(_machine, config), |
| 130 | m_config(config) |
| 131 | { |
| 132 | } |
| 133 | |
| 134 | |
| 135 | //------------------------------------------------- |
| 136 | // device_start - device-specific startup |
| 137 | //------------------------------------------------- |
| 138 | |
| 139 | void i8214_device::device_start() |
| 140 | { |
| 141 | // resolve callbacks |
| 142 | devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); |
| 143 | devcb_resolve_write_line(&m_out_enlg_func, &m_config.m_out_enlg_func, this); |
| 144 | |
| 145 | // register for state saving |
| 146 | save_item(NAME(m_inte)); |
| 147 | save_item(NAME(m_int_dis)); |
| 148 | save_item(NAME(m_a)); |
| 149 | save_item(NAME(m_b)); |
| 150 | save_item(NAME(m_r)); |
| 151 | save_item(NAME(m_sgs)); |
| 152 | save_item(NAME(m_etlg)); |
| 153 | } |
| 154 | |
| 155 | |
| 156 | //------------------------------------------------- |
| 157 | // a_r - |
| 158 | //------------------------------------------------- |
| 159 | |
| 160 | UINT8 i8214_device::a_r() |
| 161 | { |
| 162 | UINT8 a = m_a & 0x07; |
| 163 | |
| 164 | if (LOG) logerror("I8214 '%s' A: %01x\n", tag(), a); |
| 165 | |
| 166 | return a; |
| 167 | } |
| 168 | |
| 169 | |
| 170 | //------------------------------------------------- |
| 171 | // b_w - |
| 172 | //------------------------------------------------- |
| 173 | |
| 174 | void i8214_device::b_w(UINT8 data) |
| 175 | { |
| 176 | m_b = data & 0x07; |
| 177 | |
| 178 | if (LOG) logerror("I8214 '%s' B: %01x\n", tag(), m_b); |
| 179 | |
| 180 | // enable interrupts |
| 181 | m_int_dis = 0; |
| 182 | |
| 183 | // enable next level group |
| 184 | devcb_call_write_line(&m_out_enlg_func, 1); |
| 185 | |
| 186 | check_interrupt(); |
| 187 | } |
| 188 | |
| 189 | |
| 190 | //------------------------------------------------- |
| 191 | // r_w - |
| 192 | //------------------------------------------------- |
| 193 | |
| 194 | void i8214_device::r_w(UINT8 data) |
| 195 | { |
| 196 | if (LOG) logerror("I8214 '%s' R: %02x\n", tag(), data); |
| 197 | |
| 198 | m_r = data; |
| 199 | |
| 200 | check_interrupt(); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | //------------------------------------------------- |
| 205 | // sgs_w - |
| 206 | //------------------------------------------------- |
| 207 | |
| 208 | WRITE_LINE_MEMBER( i8214_device::sgs_w ) |
| 209 | { |
| 210 | if (LOG) logerror("I8214 '%s' SGS: %u\n", tag(), state); |
| 211 | |
| 212 | m_sgs = state; |
| 213 | |
| 214 | check_interrupt(); |
| 215 | } |
| 216 | |
| 217 | |
| 218 | //------------------------------------------------- |
| 219 | // etlg_w - |
| 220 | //------------------------------------------------- |
| 221 | |
| 222 | WRITE_LINE_MEMBER( i8214_device::etlg_w ) |
| 223 | { |
| 224 | if (LOG) logerror("I8214 '%s' ETLG: %u\n", tag(), state); |
| 225 | |
| 226 | m_etlg = state; |
| 227 | } |
| 228 | |
| 229 | |
| 230 | //------------------------------------------------- |
| 231 | // inte_w - |
| 232 | //------------------------------------------------- |
| 233 | |
| 234 | WRITE_LINE_MEMBER( i8214_device::inte_w ) |
| 235 | { |
| 236 | if (LOG) logerror("I8214 '%s' INTE: %u\n", tag(), state); |
| 237 | |
| 238 | m_inte = state; |
| 239 | } |
src/emu/machine/i8214.h
| r0 | r11136 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Intel 8214 Priority Interrupt Controller emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | _____ _____ |
| 10 | _B0 1 |* \_/ | 24 Vcc |
| 11 | _B1 2 | | 23 _ECS |
| 12 | _B2 3 | | 22 _R7 |
| 13 | _SGS 4 | | 21 _R6 |
| 14 | _INT 5 | | 20 _R5 |
| 15 | _CLK 6 | 8214 | 19 _R4 |
| 16 | INTE 7 | | 18 _R3 |
| 17 | _A0 8 | | 17 _R2 |
| 18 | _A1 9 | | 16 _R1 |
| 19 | _A2 10 | | 15 _R0 |
| 20 | _ELR 11 | | 14 ENLG |
| 21 | GND 12 |_____________| 13 ETLG |
| 22 | |
| 23 | **********************************************************************/ |
| 24 | |
| 25 | #pragma once |
| 26 | |
| 27 | #ifndef __I8214__ |
| 28 | #define __I8214__ |
| 29 | |
| 30 | #include "emu.h" |
| 31 | |
| 32 | |
| 33 | |
| 34 | ///************************************************************************* |
| 35 | // INTERFACE CONFIGURATION MACROS |
| 36 | ///************************************************************************* |
| 37 | |
| 38 | #define MCFG_I8214_ADD(_tag, _clock, _config) \ |
| 39 | MCFG_DEVICE_ADD(_tag, I8214, _clock) \ |
| 40 | MCFG_DEVICE_CONFIG(_config) |
| 41 | |
| 42 | |
| 43 | #define I8214_INTERFACE(name) \ |
| 44 | const i8214_interface (name) = |
| 45 | |
| 46 | |
| 47 | |
| 48 | ///************************************************************************* |
| 49 | // TYPE DEFINITIONS |
| 50 | ///************************************************************************* |
| 51 | |
| 52 | // ======================> i8214_interface |
| 53 | |
| 54 | struct i8214_interface |
| 55 | { |
| 56 | devcb_write_line m_out_int_func; |
| 57 | devcb_write_line m_out_enlg_func; |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | // ======================> i8214_device_config |
| 62 | |
| 63 | class i8214_device_config : public device_config, |
| 64 | public i8214_interface |
| 65 | { |
| 66 | friend class i8214_device; |
| 67 | |
| 68 | // construction/destruction |
| 69 | i8214_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 70 | |
| 71 | public: |
| 72 | // allocators |
| 73 | static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 74 | virtual device_t *alloc_device(running_machine &machine) const; |
| 75 | |
| 76 | protected: |
| 77 | // device_config overrides |
| 78 | virtual void device_config_complete(); |
| 79 | }; |
| 80 | |
| 81 | |
| 82 | |
| 83 | // ======================> i8214_device |
| 84 | |
| 85 | class i8214_device : public device_t |
| 86 | { |
| 87 | friend class i8214_device_config; |
| 88 | |
| 89 | // construction/destruction |
| 90 | i8214_device(running_machine &_machine, const i8214_device_config &_config); |
| 91 | |
| 92 | public: |
| 93 | DECLARE_WRITE_LINE_MEMBER( sgs_w ); |
| 94 | DECLARE_WRITE_LINE_MEMBER( etlg_w ); |
| 95 | DECLARE_WRITE_LINE_MEMBER( inte_w ); |
| 96 | |
| 97 | UINT8 a_r(); |
| 98 | void b_w(UINT8 data); |
| 99 | void r_w(UINT8 data); |
| 100 | |
| 101 | protected: |
| 102 | // device-level overrides |
| 103 | virtual void device_start(); |
| 104 | |
| 105 | private: |
| 106 | inline void trigger_interrupt(int level); |
| 107 | inline void check_interrupt(); |
| 108 | |
| 109 | devcb_resolved_write_line m_out_int_func; |
| 110 | devcb_resolved_write_line m_out_enlg_func; |
| 111 | |
| 112 | int m_inte; // interrupt enable |
| 113 | int m_int_dis; // interrupt disable flip-flop |
| 114 | int m_a; // request level |
| 115 | int m_b; // current status register |
| 116 | UINT8 m_r; // interrupt request latch |
| 117 | int m_sgs; // status group select |
| 118 | int m_etlg; // enable this level group |
| 119 | |
| 120 | const i8214_device_config &m_config; |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | // device type definition |
| 125 | extern const device_type I8214; |
| 126 | |
| 127 | |
| 128 | |
| 129 | #endif |
src/mess/machine/i8214.c
| r11135 | r11136 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Intel 8214 Priority Interrupt Controller emulation |
| 4 | | |
| 5 | | Copyright MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | **********************************************************************/ |
| 9 | | |
| 10 | | #include "emu.h" |
| 11 | | #include "i8214.h" |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | PARAMETERS |
| 15 | | ***************************************************************************/ |
| 16 | | |
| 17 | | #define LOG 0 |
| 18 | | |
| 19 | | /*************************************************************************** |
| 20 | | TYPE DEFINITIONS |
| 21 | | ***************************************************************************/ |
| 22 | | |
| 23 | | typedef struct _i8214_t i8214_t; |
| 24 | | struct _i8214_t |
| 25 | | { |
| 26 | | devcb_resolved_write_line out_int_func; |
| 27 | | devcb_resolved_write_line out_enlg_func; |
| 28 | | |
| 29 | | int inte; /* interrupt enable */ |
| 30 | | int int_dis; /* interrupt disable flip-flop */ |
| 31 | | int a; /* request level */ |
| 32 | | int b; /* current status register */ |
| 33 | | UINT8 r; /* interrupt request latch */ |
| 34 | | int sgs; /* status group select */ |
| 35 | | int etlg; /* enable this level group */ |
| 36 | | }; |
| 37 | | |
| 38 | | /*************************************************************************** |
| 39 | | INLINE FUNCTIONS |
| 40 | | ***************************************************************************/ |
| 41 | | |
| 42 | | INLINE i8214_t *get_safe_token(device_t *device) |
| 43 | | { |
| 44 | | assert(device != NULL); |
| 45 | | assert(device->type() == I8214); |
| 46 | | |
| 47 | | return (i8214_t *)downcast<legacy_device_base *>(device)->token(); |
| 48 | | } |
| 49 | | |
| 50 | | INLINE const i8214_interface *get_interface(device_t *device) |
| 51 | | { |
| 52 | | assert(device != NULL); |
| 53 | | assert((device->type() == I8214)); |
| 54 | | |
| 55 | | return (const i8214_interface *) device->baseconfig().static_config(); |
| 56 | | } |
| 57 | | |
| 58 | | INLINE void trigger_interrupt(device_t *device, int level) |
| 59 | | { |
| 60 | | i8214_t *i8214 = get_safe_token(device); |
| 61 | | |
| 62 | | if (LOG) logerror("I8214 '%s' Interrupt Level %u\n", device->tag(), level); |
| 63 | | |
| 64 | | i8214->a = level; |
| 65 | | |
| 66 | | /* disable interrupts */ |
| 67 | | i8214->int_dis = 1; |
| 68 | | |
| 69 | | /* disable next level group */ |
| 70 | | devcb_call_write_line(&i8214->out_enlg_func, 0); |
| 71 | | |
| 72 | | /* toggle interrupt line */ |
| 73 | | devcb_call_write_line(&i8214->out_int_func, ASSERT_LINE); |
| 74 | | devcb_call_write_line(&i8214->out_int_func, CLEAR_LINE); |
| 75 | | } |
| 76 | | |
| 77 | | INLINE void check_interrupt(device_t *device) |
| 78 | | { |
| 79 | | i8214_t *i8214 = get_safe_token(device); |
| 80 | | int level; |
| 81 | | |
| 82 | | if (i8214->int_dis || !i8214->etlg) return; |
| 83 | | |
| 84 | | for (level = 7; level >= 0; level--) |
| 85 | | { |
| 86 | | if (!BIT(i8214->r, 7 - level)) |
| 87 | | { |
| 88 | | if (i8214->sgs) |
| 89 | | { |
| 90 | | if (level > i8214->b) |
| 91 | | { |
| 92 | | trigger_interrupt(device, level); |
| 93 | | } |
| 94 | | } |
| 95 | | else |
| 96 | | { |
| 97 | | trigger_interrupt(device, level); |
| 98 | | } |
| 99 | | } |
| 100 | | } |
| 101 | | } |
| 102 | | |
| 103 | | /*************************************************************************** |
| 104 | | IMPLEMENTATION |
| 105 | | ***************************************************************************/ |
| 106 | | |
| 107 | | /*------------------------------------------------- |
| 108 | | i8214_a_r - request level read |
| 109 | | -------------------------------------------------*/ |
| 110 | | |
| 111 | | READ8_DEVICE_HANDLER( i8214_a_r ) |
| 112 | | { |
| 113 | | i8214_t *i8214 = get_safe_token(device); |
| 114 | | |
| 115 | | UINT8 a = i8214->a & 0x07; |
| 116 | | |
| 117 | | if (LOG) logerror("I8214 '%s' A: %01x\n", device->tag(), a); |
| 118 | | |
| 119 | | return a; |
| 120 | | } |
| 121 | | |
| 122 | | /*------------------------------------------------- |
| 123 | | i8214_b_w - current status register write |
| 124 | | -------------------------------------------------*/ |
| 125 | | |
| 126 | | WRITE8_DEVICE_HANDLER( i8214_b_w ) |
| 127 | | { |
| 128 | | i8214_t *i8214 = get_safe_token(device); |
| 129 | | |
| 130 | | i8214->b = data & 0x07; |
| 131 | | i8214->sgs = BIT(data, 3); |
| 132 | | |
| 133 | | if (LOG) logerror("I8214 '%s' B: %01x\n", device->tag(), i8214->b); |
| 134 | | if (LOG) logerror("I8214 '%s' SGS: %u\n", device->tag(), i8214->sgs); |
| 135 | | |
| 136 | | /* enable interrupts */ |
| 137 | | i8214->int_dis = 0; |
| 138 | | |
| 139 | | /* enable next level group */ |
| 140 | | devcb_call_write_line(&i8214->out_enlg_func, 1); |
| 141 | | |
| 142 | | check_interrupt(device); |
| 143 | | } |
| 144 | | |
| 145 | | /*------------------------------------------------- |
| 146 | | i8214_etlg_w - enable this level group write |
| 147 | | -------------------------------------------------*/ |
| 148 | | |
| 149 | | WRITE_LINE_DEVICE_HANDLER( i8214_etlg_w ) |
| 150 | | { |
| 151 | | i8214_t *i8214 = get_safe_token(device); |
| 152 | | |
| 153 | | if (LOG) logerror("I8214 '%s' ETLG: %u\n", device->tag(), state); |
| 154 | | |
| 155 | | i8214->etlg = state; |
| 156 | | } |
| 157 | | |
| 158 | | /*------------------------------------------------- |
| 159 | | i8214_inte_w - interrupt enable write |
| 160 | | -------------------------------------------------*/ |
| 161 | | |
| 162 | | WRITE_LINE_DEVICE_HANDLER( i8214_inte_w ) |
| 163 | | { |
| 164 | | i8214_t *i8214 = get_safe_token(device); |
| 165 | | |
| 166 | | if (LOG) logerror("I8214 '%s' INTE: %u\n", device->tag(), state); |
| 167 | | |
| 168 | | i8214->inte = state; |
| 169 | | } |
| 170 | | |
| 171 | | /*------------------------------------------------- |
| 172 | | i8214_r_w - request level write |
| 173 | | -------------------------------------------------*/ |
| 174 | | |
| 175 | | WRITE8_DEVICE_HANDLER( i8214_r_w ) |
| 176 | | { |
| 177 | | i8214_t *i8214 = get_safe_token(device); |
| 178 | | |
| 179 | | if (LOG) logerror("I8214 '%s' R: %02x\n", device->tag(), data); |
| 180 | | |
| 181 | | i8214->r = data; |
| 182 | | |
| 183 | | check_interrupt(device); |
| 184 | | } |
| 185 | | |
| 186 | | /*------------------------------------------------- |
| 187 | | DEVICE_START( i8214 ) |
| 188 | | -------------------------------------------------*/ |
| 189 | | |
| 190 | | static DEVICE_START( i8214 ) |
| 191 | | { |
| 192 | | i8214_t *i8214 = get_safe_token(device); |
| 193 | | const i8214_interface *intf = get_interface(device); |
| 194 | | |
| 195 | | /* resolve callbacks */ |
| 196 | | devcb_resolve_write_line(&i8214->out_int_func, &intf->out_int_func, device); |
| 197 | | devcb_resolve_write_line(&i8214->out_enlg_func, &intf->out_enlg_func, device); |
| 198 | | |
| 199 | | /* register for state saving */ |
| 200 | | device->save_item(NAME(i8214->inte)); |
| 201 | | device->save_item(NAME(i8214->int_dis)); |
| 202 | | device->save_item(NAME(i8214->a)); |
| 203 | | device->save_item(NAME(i8214->b)); |
| 204 | | device->save_item(NAME(i8214->r)); |
| 205 | | device->save_item(NAME(i8214->sgs)); |
| 206 | | device->save_item(NAME(i8214->etlg)); |
| 207 | | } |
| 208 | | |
| 209 | | /*------------------------------------------------- |
| 210 | | DEVICE_GET_INFO( i8214 ) |
| 211 | | -------------------------------------------------*/ |
| 212 | | |
| 213 | | DEVICE_GET_INFO( i8214 ) |
| 214 | | { |
| 215 | | switch (state) |
| 216 | | { |
| 217 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 218 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8214_t); break; |
| 219 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 220 | | |
| 221 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 222 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8214); break; |
| 223 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 224 | | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 225 | | |
| 226 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 227 | | case DEVINFO_STR_NAME: strcpy(info->s, "Intel 8214"); break; |
| 228 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Intel MCS-80"); break; |
| 229 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 230 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 231 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 232 | | } |
| 233 | | } |
| 234 | | |
| 235 | | DEFINE_LEGACY_DEVICE(I8214, i8214); |
src/mess/machine/i8214.h
| r11135 | r11136 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Intel 8214 Priority Interrupt Controller emulation |
| 4 | | |
| 5 | | Copyright MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | ********************************************************************** |
| 9 | | _____ _____ |
| 10 | | _B0 1 |* \_/ | 24 Vcc |
| 11 | | _B1 2 | | 23 _ECS |
| 12 | | _B2 3 | | 22 _R7 |
| 13 | | _SGS 4 | | 21 _R6 |
| 14 | | _INT 5 | | 20 _R5 |
| 15 | | _CLK 6 | 8214 | 19 _R4 |
| 16 | | INTE 7 | | 18 _R3 |
| 17 | | _A0 8 | | 17 _R2 |
| 18 | | _A1 9 | | 16 _R1 |
| 19 | | _A2 10 | | 15 _R0 |
| 20 | | _ELR 11 | | 14 ENLG |
| 21 | | GND 12 |_____________| 13 ETLG |
| 22 | | |
| 23 | | **********************************************************************/ |
| 24 | | |
| 25 | | #ifndef __I8214__ |
| 26 | | #define __I8214__ |
| 27 | | |
| 28 | | #include "devcb.h" |
| 29 | | |
| 30 | | /*************************************************************************** |
| 31 | | MACROS / CONSTANTS |
| 32 | | ***************************************************************************/ |
| 33 | | |
| 34 | | DECLARE_LEGACY_DEVICE(I8214, i8214); |
| 35 | | |
| 36 | | #define MCFG_I8214_ADD(_tag, _clock, _intrf) \ |
| 37 | | MCFG_DEVICE_ADD(_tag, I8214, _clock) \ |
| 38 | | MCFG_DEVICE_CONFIG(_intrf) |
| 39 | | |
| 40 | | #define I8214_INTERFACE(name) \ |
| 41 | | const i8214_interface (name)= |
| 42 | | |
| 43 | | /*************************************************************************** |
| 44 | | TYPE DEFINITIONS |
| 45 | | ***************************************************************************/ |
| 46 | | |
| 47 | | typedef struct _i8214_interface i8214_interface; |
| 48 | | struct _i8214_interface |
| 49 | | { |
| 50 | | devcb_write_line out_int_func; |
| 51 | | devcb_write_line out_enlg_func; |
| 52 | | }; |
| 53 | | |
| 54 | | /*************************************************************************** |
| 55 | | PROTOTYPES |
| 56 | | ***************************************************************************/ |
| 57 | | /* request level read */ |
| 58 | | READ8_DEVICE_HANDLER( i8214_a_r ); |
| 59 | | |
| 60 | | /* current status register write (bit 3 is SGS) */ |
| 61 | | WRITE8_DEVICE_HANDLER( i8214_b_w ); |
| 62 | | |
| 63 | | /* enable this level group */ |
| 64 | | WRITE_LINE_DEVICE_HANDLER( i8214_etlg_w ); |
| 65 | | |
| 66 | | /* interrupt enable */ |
| 67 | | WRITE_LINE_DEVICE_HANDLER( i8214_inte_w ); |
| 68 | | |
| 69 | | /* interrupt requests */ |
| 70 | | WRITE8_DEVICE_HANDLER( i8214_r_w ); |
| 71 | | |
| 72 | | #endif |
src/mess/drivers/v1050.c
| r11135 | r11136 | |
| 102 | 102 | |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | | #define ADDRESS_MAP_MODERN |
| 106 | | |
| 107 | | #include "emu.h" |
| 108 | 105 | #include "includes/v1050.h" |
| 109 | | #include "cpu/z80/z80.h" |
| 110 | | #include "cpu/m6502/m6502.h" |
| 111 | | #include "cpu/mcs48/mcs48.h" |
| 112 | | #include "imagedev/flopdrv.h" |
| 113 | | #include "machine/ram.h" |
| 114 | | #include "formats/basicdsk.h" |
| 115 | | #include "machine/ctronics.h" |
| 116 | | #include "machine/i8214.h" |
| 117 | | #include "machine/i8255a.h" |
| 118 | | #include "machine/msm58321.h" |
| 119 | | #include "machine/msm8251.h" |
| 120 | | #include "machine/wd17xx.h" |
| 121 | | #include "video/mc6845.h" |
| 122 | | #include "sound/discrete.h" |
| 123 | 106 | |
| 124 | 107 | void v1050_state::set_interrupt(UINT8 mask, int state) |
| 125 | 108 | { |
| r11135 | r11136 | |
| 132 | 115 | m_int_state &= ~mask; |
| 133 | 116 | } |
| 134 | 117 | |
| 135 | | i8214_r_w(m_pic, 0, ~(m_int_state & m_int_mask)); |
| 118 | m_pic->r_w(~(m_int_state & m_int_mask)); |
| 136 | 119 | } |
| 137 | 120 | |
| 138 | 121 | void v1050_state::bankswitch() |
| r11135 | r11136 | |
| 310 | 293 | |
| 311 | 294 | WRITE8_MEMBER( v1050_state::v1050_i8214_w ) |
| 312 | 295 | { |
| 313 | | i8214_b_w(m_pic, 0, (data >> 1) & 0x0f); |
| 296 | m_pic->b_w((data >> 1) & 0x07); |
| 297 | m_pic->sgs_w(BIT(data, 4)); |
| 314 | 298 | } |
| 315 | 299 | |
| 316 | 300 | READ8_MEMBER( v1050_state::vint_clr_r ) |
| r11135 | r11136 | |
| 1100 | 1084 | { |
| 1101 | 1085 | v1050_state *state = device->machine().driver_data<v1050_state>(); |
| 1102 | 1086 | |
| 1103 | | UINT8 vector = 0xf0 | (i8214_a_r(state->m_pic, 0) << 1); |
| 1087 | UINT8 vector = 0xf0 | (state->m_pic->a_r() << 1); |
| 1104 | 1088 | |
| 1105 | 1089 | //logerror("Interrupt Acknowledge Vector: %02x\n", vector); |
| 1106 | 1090 | |
| r11135 | r11136 | |
| 1114 | 1098 | address_space *program = m_maincpu->memory().space(AS_PROGRAM); |
| 1115 | 1099 | |
| 1116 | 1100 | /* initialize I8214 */ |
| 1117 | | i8214_etlg_w(m_pic, 1); |
| 1118 | | i8214_inte_w(m_pic, 1); |
| 1101 | m_pic->etlg_w(1); |
| 1102 | m_pic->inte_w(1); |
| 1119 | 1103 | |
| 1120 | 1104 | /* initialize RTC */ |
| 1121 | 1105 | msm58321_cs1_w(m_rtc, 1); |
src/mess/drivers/pc8801.c
| r11135 | r11136 | |
| 160 | 160 | |
| 161 | 161 | //#define USE_PROPER_I8214 |
| 162 | 162 | |
| 163 | | #define UPD1990A_TAG "upd1990a" |
| 163 | #define I8214_TAG "i8214" |
| 164 | #define UPD1990A_TAG "upd1990a" |
| 164 | 165 | |
| 165 | 166 | class pc8801_state : public driver_device |
| 166 | 167 | { |
| 167 | 168 | public: |
| 168 | 169 | pc8801_state(running_machine &machine, const driver_device_config_base &config) |
| 169 | 170 | : driver_device(machine, config), |
| 171 | m_pic(*this, I8214_TAG), |
| 170 | 172 | m_rtc(*this, UPD1990A_TAG) |
| 171 | 173 | { } |
| 172 | 174 | |
| 175 | optional_device<i8214_device> m_pic; |
| 173 | 176 | required_device<upd1990a_device> m_rtc; |
| 174 | 177 | }; |
| 175 | 178 | |
| r11135 | r11136 | |
| 975 | 978 | static WRITE8_HANDLER( i8214_irq_level_w ) |
| 976 | 979 | { |
| 977 | 980 | if(data & 8) |
| 978 | | i8214_b_w(space->machine().device("i8214"), 0, (7)); |
| 981 | m_pic->b_w(7); |
| 979 | 982 | else |
| 980 | | i8214_b_w(space->machine().device("i8214"), 0, (data & 0x07)); |
| 983 | m_pic->b_w(data & 0x07); |
| 981 | 984 | } |
| 982 | 985 | |
| 983 | 986 | static WRITE8_HANDLER( i8214_irq_mask_w ) |
| r11135 | r11136 | |
| 1865 | 1868 | { |
| 1866 | 1869 | m_int_state |= irq; |
| 1867 | 1870 | |
| 1868 | | i8214_r_w(machine.device("i8214"), 0, ~irq); |
| 1871 | m_pic->r_w(~irq); |
| 1869 | 1872 | |
| 1870 | 1873 | cputag_set_input_line(machine,"maincpu",0,ASSERT_LINE); |
| 1871 | 1874 | } |
| r11135 | r11136 | |
| 1899 | 1902 | |
| 1900 | 1903 | static IRQ_CALLBACK( pc8801_irq_callback ) |
| 1901 | 1904 | { |
| 1902 | | UINT8 vector = (7 - i8214_a_r(device->machine().device("i8214"), 0)); |
| 1905 | UINT8 vector = (7 - m_pic->a_r()); |
| 1903 | 1906 | |
| 1904 | 1907 | m_int_state &= ~(1<<vector); |
| 1905 | 1908 | cputag_set_input_line(device->machine(),"maincpu",0,CLEAR_LINE); |
| r11135 | r11136 | |
| 2025 | 2028 | #ifdef USE_PROPER_I8214 |
| 2026 | 2029 | { |
| 2027 | 2030 | /* initialize I8214 */ |
| 2028 | | i8214_etlg_w(machine.device("i8214"), 1); |
| 2029 | | i8214_inte_w(machine.device("i8214"), 1); |
| 2031 | m_pic->etlg_w(1); |
| 2032 | m_pic->inte_w(1); |
| 2030 | 2033 | } |
| 2031 | 2034 | #else |
| 2032 | 2035 | { |
| r11135 | r11136 | |
| 2154 | 2157 | |
| 2155 | 2158 | MCFG_UPD765A_ADD("upd765", pc8801_upd765_interface) |
| 2156 | 2159 | #ifdef USE_PROPER_I8214 |
| 2157 | | MCFG_I8214_ADD("i8214", MASTER_CLOCK, pic_intf) |
| 2160 | MCFG_I8214_ADD(I8214_TAG, MASTER_CLOCK, pic_intf) |
| 2158 | 2161 | #endif |
| 2159 | 2162 | MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, pc8801_upd1990a_intf) |
| 2160 | 2163 | //MCFG_CENTRONICS_ADD("centronics", standard_centronics) |