src/mess/machine/upd7201.c
| r6214 | r6215 | |
| 1 | 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | NEC ?PD7201 Multiprotocol Serial Communications Controller emulation |
| 3 | NEC µPD7201 Multiprotocol Serial Communications Controller |
| 4 | 4 | |
| 5 | 5 | Copyright MESS Team. |
| 6 | 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| r6214 | r6215 | |
| 10 | 10 | #include "driver.h" |
| 11 | 11 | #include "upd7201.h" |
| 12 | 12 | |
| 13 | |
| 13 | 14 | /*************************************************************************** |
| 14 | 15 | PARAMETERS |
| 15 | 16 | ***************************************************************************/ |
| r6214 | r6215 | |
| 19 | 20 | TYPE DEFINITIONS |
| 20 | 21 | ***************************************************************************/ |
| 21 | 22 | |
| 22 | | typedef struct _upd7201_t upd7201_t; |
| 23 | | struct _upd7201_t |
| 23 | typedef struct _upd7201_state upd7201_state; |
| 24 | struct _upd7201_state |
| 24 | 25 | { |
| 25 | | int dummy; |
| 26 | devcb_resolved_write_line out_int_func; |
| 26 | 27 | }; |
| 27 | 28 | |
| 29 | |
| 28 | 30 | /*************************************************************************** |
| 29 | 31 | INLINE FUNCTIONS |
| 30 | 32 | ***************************************************************************/ |
| 31 | 33 | |
| 32 | | INLINE upd7201_t *get_safe_token(const device_config *device) |
| 34 | INLINE upd7201_state *get_safe_token(const device_config *device) |
| 33 | 35 | { |
| 34 | 36 | assert(device != NULL); |
| 35 | 37 | assert(device->token != NULL); |
| 38 | assert(device->type == UPD7201); |
| 36 | 39 | |
| 37 | | return (upd7201_t *)device->token; |
| 40 | return (upd7201_state *)device->token; |
| 38 | 41 | } |
| 39 | 42 | |
| 40 | | INLINE const upd7201_interface *get_interface(const device_config *device) |
| 41 | | { |
| 42 | | assert(device != NULL); |
| 43 | | assert((device->type == UPD7201)); |
| 44 | | return (const upd7201_interface *) device->static_config; |
| 45 | | } |
| 46 | 43 | |
| 47 | 44 | /*************************************************************************** |
| 48 | 45 | IMPLEMENTATION |
| r6214 | r6215 | |
| 88 | 85 | { |
| 89 | 86 | } |
| 90 | 87 | |
| 88 | WRITE_LINE_DEVICE_HANDLER( upd7201_ctsa_w ) |
| 89 | { |
| 90 | |
| 91 | } |
| 92 | |
| 93 | WRITE_LINE_DEVICE_HANDLER( upd7201_ctsb_w ) |
| 94 | { |
| 95 | |
| 96 | } |
| 97 | |
| 98 | /* data terminal ready a, hold acknowledge output */ |
| 99 | READ_LINE_DEVICE_HANDLER( upd7201_dtra_r ) |
| 100 | { |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | /* data terminal ready b */ |
| 105 | READ_LINE_DEVICE_HANDLER( upd7201_dtrb_r ) |
| 106 | { |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | /* hold acknowledge input (same pin as dtrb) */ |
| 111 | WRITE_LINE_DEVICE_HANDLER( upd7201_hoi_w ) |
| 112 | { |
| 113 | |
| 114 | } |
| 115 | |
| 116 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxda_w ) |
| 117 | { |
| 118 | |
| 119 | } |
| 120 | |
| 121 | READ_LINE_DEVICE_HANDLER( upd7201_txda_r ) |
| 122 | { |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxdb_w ) |
| 127 | { |
| 128 | |
| 129 | } |
| 130 | |
| 131 | READ_LINE_DEVICE_HANDLER( upd7201_txdb_r ) |
| 132 | { |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 91 | 136 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxca_w ) |
| 92 | 137 | { |
| 93 | 138 | } |
| r6214 | r6215 | |
| 104 | 149 | { |
| 105 | 150 | } |
| 106 | 151 | |
| 107 | | /*------------------------------------------------- |
| 108 | | DEVICE_START( upd7201 ) |
| 109 | | -------------------------------------------------*/ |
| 110 | 152 | |
| 153 | /***************************************************************************** |
| 154 | DEVICE INTERFACE |
| 155 | *****************************************************************************/ |
| 156 | |
| 111 | 157 | static DEVICE_START( upd7201 ) |
| 112 | 158 | { |
| 113 | | // upd7201_t *upd7201 = get_safe_token(device); |
| 114 | | // const upd7201_interface *intf = get_interface(device); |
| 159 | upd7201_state *upd7201 = get_safe_token(device); |
| 160 | const upd7201_interface *intf = device->static_config; |
| 115 | 161 | |
| 162 | assert(device->static_config != NULL); |
| 163 | |
| 116 | 164 | /* resolve callbacks */ |
| 165 | devcb_resolve_write_line(&upd7201->out_int_func, &intf->out_int_func, device); |
| 117 | 166 | |
| 118 | | /* set initial values */ |
| 119 | | |
| 120 | 167 | /* create the timers */ |
| 121 | 168 | |
| 122 | 169 | /* register for state saving */ |
| 123 | 170 | // state_save_register_device_item(device, 0, upd7201->); |
| 124 | 171 | } |
| 125 | 172 | |
| 126 | | /*------------------------------------------------- |
| 127 | | DEVICE_GET_INFO( upd7201 ) |
| 128 | | -------------------------------------------------*/ |
| 173 | static DEVICE_RESET( upd7201 ) |
| 174 | { |
| 175 | /* set initial values */ |
| 176 | } |
| 129 | 177 | |
| 130 | 178 | DEVICE_GET_INFO( upd7201 ) |
| 131 | 179 | { |
| 132 | 180 | switch (state) |
| 133 | 181 | { |
| 134 | 182 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 135 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(upd7201_t); break; |
| 183 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(upd7201_state); break; |
| 136 | 184 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 137 | 185 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 138 | 186 | |
| 139 | 187 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 140 | 188 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(upd7201); break; |
| 141 | 189 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 142 | | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 190 | case DEVINFO_FCT_RESET: info->start = DEVICE_RESET_NAME(upd7201); break; |
| 143 | 191 | |
| 144 | 192 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 145 | 193 | case DEVINFO_STR_NAME: strcpy(info->s, "NEC ?PD7201"); break; |
src/mess/machine/upd7201.h
| r6214 | r6215 | |
| 1 | 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | NEC ?PD7201 Multiprotocol Serial Communications Controller emulation |
| 3 | NEC µPD7201 Multiprotocol Serial Communications Controller |
| 4 | 4 | |
| 5 | 5 | Copyright MESS Team. |
| 6 | 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| r6214 | r6215 | |
| 30 | 30 | |
| 31 | 31 | **********************************************************************/ |
| 32 | 32 | |
| 33 | | #ifndef __UPD7201__ |
| 34 | | #define __UPD7201__ |
| 33 | #ifndef __UPD7201_H__ |
| 34 | #define __UPD7201_H__ |
| 35 | 35 | |
| 36 | 36 | #include "devcb.h" |
| 37 | 37 | |
| r6214 | r6215 | |
| 93 | 93 | READ8_DEVICE_HANDLER( upd7201_ba_cd_r ); |
| 94 | 94 | WRITE8_DEVICE_HANDLER( upd7201_ba_cd_w ); |
| 95 | 95 | |
| 96 | | /* hold acknowledge input */ |
| 97 | | READ8_DEVICE_HANDLER( upd7201_hai_r ); |
| 98 | | WRITE8_DEVICE_HANDLER( upd7201_hai_w ); |
| 99 | | |
| 100 | 96 | /* interrupt acknowledge */ |
| 101 | 97 | READ8_DEVICE_HANDLER( upd7201_intak_r ); |
| 102 | 98 | |
| r6214 | r6215 | |
| 104 | 100 | WRITE_LINE_DEVICE_HANDLER( upd7201_synca_w ); |
| 105 | 101 | WRITE_LINE_DEVICE_HANDLER( upd7201_syncb_w ); |
| 106 | 102 | |
| 103 | /* clear to send */ |
| 104 | WRITE_LINE_DEVICE_HANDLER( upd7201_ctsa_w ); |
| 105 | WRITE_LINE_DEVICE_HANDLER( upd7201_ctsb_w ); |
| 106 | |
| 107 | /* data terminal ready, hold acknowledge */ |
| 108 | READ_LINE_DEVICE_HANDLER( upd7201_dtra_r ); |
| 109 | READ_LINE_DEVICE_HANDLER( upd7201_dtrb_r ); |
| 110 | WRITE_LINE_DEVICE_HANDLER( upd7201_hoi_w ); |
| 111 | |
| 112 | /* serial data */ |
| 113 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxda_w ); |
| 114 | READ_LINE_DEVICE_HANDLER( upd7201_txda_r ); |
| 115 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxdb_w ); |
| 116 | READ_LINE_DEVICE_HANDLER( upd7201_txdb_r ); |
| 117 | |
| 107 | 118 | /* clock inputs */ |
| 108 | 119 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxca_w ); |
| 109 | 120 | WRITE_LINE_DEVICE_HANDLER( upd7201_rxcb_w ); |
| 110 | 121 | WRITE_LINE_DEVICE_HANDLER( upd7201_txca_w ); |
| 111 | 122 | WRITE_LINE_DEVICE_HANDLER( upd7201_txcb_w ); |
| 112 | 123 | |
| 113 | | #endif |
| 124 | |
| 125 | #endif /* __UPD7201_H__ */ |
src/mess/machine/tf20.c
| r6214 | r6215 | |
| 56 | 56 | IMPLEMENTATION
|
| 57 | 57 | ***************************************************************************/
|
| 58 | 58 | |
| 59 | /* serial clock, 38400 baud by default */
|
| 60 | static TIMER_DEVICE_CALLBACK( serial_clock )
|
| 61 | {
|
| 62 | tf20_state *tf20 = get_safe_token(timer->owner);
|
| 63 | |
| 64 | upd7201_rxca_w(tf20->upd7201, ASSERT_LINE);
|
| 65 | upd7201_txca_w(tf20->upd7201, ASSERT_LINE);
|
| 66 | upd7201_rxcb_w(tf20->upd7201, ASSERT_LINE);
|
| 67 | upd7201_txcb_w(tf20->upd7201, ASSERT_LINE);
|
| 68 | }
|
| 69 | |
| 59 | 70 | /* a read from this location disables the rom */
|
| 60 | 71 | static READ8_HANDLER( tf20_rom_disable )
|
| 61 | 72 | {
|
| r6214 | r6215 | |
| 82 | 93 | /* bit 0, motor on signal */
|
| 83 | 94 | }
|
| 84 | 95 | |
| 96 | |
| 97 | /***************************************************************************
|
| 98 | EXTERNAL INTERFACE
|
| 99 | ***************************************************************************/
|
| 100 | |
| 85 | 101 | /* serial output signal (to the host computer) */
|
| 86 | 102 | READ_LINE_DEVICE_HANDLER( tf20_rxs_r )
|
| 87 | 103 | {
|
| 104 | tf20_state *tf20 = get_safe_token(device);
|
| 88 | 105 | logerror("%s: tf20_rxs_r\n", cpuexec_describe_context(device->machine));
|
| 89 | 106 | |
| 90 | | return 0;
|
| 107 | return upd7201_txda_r(tf20->upd7201);
|
| 91 | 108 | }
|
| 92 | 109 | |
| 93 | 110 | READ_LINE_DEVICE_HANDLER( tf20_pins_r )
|
| 94 | 111 | {
|
| 112 | tf20_state *tf20 = get_safe_token(device);
|
| 95 | 113 | logerror("%s: tf20_pins_r\n", cpuexec_describe_context(device->machine));
|
| 96 | 114 | |
| 97 | | return 0;
|
| 115 | return upd7201_dtra_r(tf20->upd7201);
|
| 98 | 116 | }
|
| 99 | 117 | |
| 100 | 118 | /* serial input signal (from host computer) */
|
| 101 | 119 | WRITE_LINE_DEVICE_HANDLER( tf20_txs_w )
|
| 102 | 120 | {
|
| 121 | tf20_state *tf20 = get_safe_token(device);
|
| 103 | 122 | logerror("%s: tf20_rxd1_w %u\n", cpuexec_describe_context(device->machine), state);
|
| 123 | |
| 124 | upd7201_rxda_w(tf20->upd7201, state);
|
| 104 | 125 | }
|
| 105 | 126 | |
| 106 | 127 | WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w )
|
| 107 | 128 | {
|
| 129 | tf20_state *tf20 = get_safe_token(device);
|
| 108 | 130 | logerror("%s: tf20_pouts_w %u\n", cpuexec_describe_context(device->machine), state);
|
| 131 | |
| 132 | upd7201_ctsa_w(tf20->upd7201, state);
|
| 109 | 133 | }
|
| 110 | 134 | |
| 111 | 135 | /* serial output signal (to another terminal) */
|
| 112 | | READ_LINE_DEVICE_HANDLER( tf20_txc_r )
|
| 136 | WRITE_LINE_DEVICE_HANDLER( tf20_txc_w )
|
| 113 | 137 | {
|
| 114 | | logerror("%s: tf20_txc_r\n", cpuexec_describe_context(device->machine));
|
| 138 | tf20_state *tf20 = get_safe_token(device);
|
| 139 | logerror("%s: tf20_txc_w %u\n", cpuexec_describe_context(device->machine), state);
|
| 115 | 140 | |
| 116 | | return 0;
|
| 141 | upd7201_rxda_w(tf20->upd7201, state);
|
| 117 | 142 | }
|
| 118 | 143 | |
| 119 | 144 | /* serial input signal (from another terminal) */
|
| 120 | | WRITE_LINE_DEVICE_HANDLER( tf20_rxc_w )
|
| 145 | READ_LINE_DEVICE_HANDLER( tf20_rxc_r )
|
| 121 | 146 | {
|
| 122 | | logerror("%s: tf20_rxc_w %u\n", cpuexec_describe_context(device->machine), state);
|
| 147 | tf20_state *tf20 = get_safe_token(device);
|
| 148 | logerror("%s: tf20_rxc_r\n", cpuexec_describe_context(device->machine));
|
| 149 | |
| 150 | return upd7201_txda_r(tf20->upd7201);
|
| 123 | 151 | }
|
| 124 | 152 | |
| 125 | | READ_LINE_DEVICE_HANDLER( tf20_poutc_r )
|
| 153 | WRITE_LINE_DEVICE_HANDLER( tf20_poutc_w )
|
| 126 | 154 | {
|
| 127 | | logerror("%s: tf20_poutc_r\n", cpuexec_describe_context(device->machine));
|
| 155 | tf20_state *tf20 = get_safe_token(device);
|
| 156 | logerror("%s: tf20_poutc_w %u\n", cpuexec_describe_context(device->machine), state);
|
| 128 | 157 | |
| 129 | | return 0;
|
| 158 | upd7201_ctsa_w(tf20->upd7201, state);
|
| 130 | 159 | }
|
| 131 | 160 | |
| 132 | | WRITE_LINE_DEVICE_HANDLER( tf20_pinc_w )
|
| 161 | READ_LINE_DEVICE_HANDLER( tf20_pinc_r )
|
| 133 | 162 | {
|
| 134 | | logerror("%s: tf20_pinc_w %u\n", cpuexec_describe_context(device->machine), state);
|
| 163 | tf20_state *tf20 = get_safe_token(device);
|
| 164 | logerror("%s: tf20_pinc_r\n", cpuexec_describe_context(device->machine));
|
| 165 | |
| 166 | return upd7201_dtra_r(tf20->upd7201);
|
| 135 | 167 | }
|
| 136 | 168 | |
| 137 | 169 | |
| r6214 | r6215 | |
| 229 | 261 | |
| 230 | 262 | /* upd7201 serial interface */
|
| 231 | 263 | MDRV_UPD7201_ADD("3a", XTAL_CR1 / 2, tf20_upd7201_intf)
|
| 264 | MDRV_TIMER_ADD_PERIODIC("serial_timer", serial_clock, HZ(XTAL_CR2 / 128))
|
| 232 | 265 | |
| 233 | 266 | /* 2 floppy drives */
|
| 234 | 267 | MDRV_FLOPPY_2_DRIVES_ADD(tf20_floppy_config)
|
| r6214 | r6215 | |
| 253 | 286 | {
|
| 254 | 287 | tf20_state *tf20 = get_safe_token(device);
|
| 255 | 288 | |
| 289 | /* ram device */
|
| 290 | tf20->ram = device_find_child_by_tag(device, "ram");
|
| 291 | |
| 292 | /* make sure its already running */
|
| 293 | if (!tf20->ram->started)
|
| 294 | {
|
| 295 | device_delay_init(device);
|
| 296 | return;
|
| 297 | }
|
| 298 | |
| 256 | 299 | /* locate child devices */
|
| 257 | | tf20->ram = device_find_child_by_tag(device, "ram");
|
| 258 | 300 | tf20->upd765a = device_find_child_by_tag(device, "5a");
|
| 259 | 301 | tf20->upd7201 = device_find_child_by_tag(device, "3a");
|
| 260 | 302 | |