src/mess/machine/z80sti.c
| r0 | r4946 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Mostek Z80STI Serial Timer Interrupt Controller emulation |
| 4 | |
| 5 | Copyright (c) 2008, The MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | TODO: |
| 13 | |
| 14 | - everything |
| 15 | |
| 16 | */ |
| 17 | |
| 18 | #include "driver.h" |
| 19 | #include "z80sti.h" |
| 20 | #include "cpu/z80/z80.h" |
| 21 | #include "cpu/z80/z80daisy.h" |
| 22 | |
| 23 | /*************************************************************************** |
| 24 | PARAMETERS |
| 25 | ***************************************************************************/ |
| 26 | |
| 27 | #define VERBOSE 1 |
| 28 | |
| 29 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 30 | |
| 31 | enum |
| 32 | { |
| 33 | Z80STI_REGISTER_IR = 0, |
| 34 | Z80STI_REGISTER_GPIP, |
| 35 | Z80STI_REGISTER_IPRB, |
| 36 | Z80STI_REGISTER_IPRA, |
| 37 | Z80STI_REGISTER_ISRB, |
| 38 | Z80STI_REGISTER_ISRA, |
| 39 | Z80STI_REGISTER_IMRB, |
| 40 | Z80STI_REGISTER_IMRA, |
| 41 | Z80STI_REGISTER_PVR, |
| 42 | Z80STI_REGISTER_TABC, |
| 43 | Z80STI_REGISTER_TBDR, |
| 44 | Z80STI_REGISTER_TADR, |
| 45 | Z80STI_REGISTER_UCR, |
| 46 | Z80STI_REGISTER_RSR, |
| 47 | Z80STI_REGISTER_TSR, |
| 48 | Z80STI_REGISTER_UDR |
| 49 | }; |
| 50 | |
| 51 | /*************************************************************************** |
| 52 | TYPE DEFINITIONS |
| 53 | ***************************************************************************/ |
| 54 | |
| 55 | typedef struct _z80sti_t z80sti_t; |
| 56 | struct _z80sti_t |
| 57 | { |
| 58 | devcb_resolved_read8 in_gpio_func; |
| 59 | devcb_resolved_write8 out_gpio_func; |
| 60 | devcb_resolved_read_line in_si_func; |
| 61 | devcb_resolved_write_line out_so_func; |
| 62 | devcb_resolved_write_line out_tao_func; |
| 63 | devcb_resolved_write_line out_tbo_func; |
| 64 | devcb_resolved_write_line out_tco_func; |
| 65 | devcb_resolved_write_line out_tdo_func; |
| 66 | devcb_resolved_write_line out_irq_func; |
| 67 | }; |
| 68 | |
| 69 | /*************************************************************************** |
| 70 | FUNCTION PROTOTYPES |
| 71 | ***************************************************************************/ |
| 72 | |
| 73 | static int z80sti_irq_state(const device_config *device); |
| 74 | static void z80sti_irq_reti(const device_config *device); |
| 75 | |
| 76 | /*************************************************************************** |
| 77 | INLINE FUNCTIONS |
| 78 | ***************************************************************************/ |
| 79 | |
| 80 | INLINE z80sti_t *get_safe_token(const device_config *device) |
| 81 | { |
| 82 | assert(device != NULL); |
| 83 | assert(device->token != NULL); |
| 84 | assert(device->type == Z80STI); |
| 85 | return (z80sti_t *)device->token; |
| 86 | } |
| 87 | |
| 88 | INLINE const z80sti_interface *get_interface(const device_config *device) |
| 89 | { |
| 90 | assert(device != NULL); |
| 91 | assert((device->type == Z80STI)); |
| 92 | return (const z80sti_interface *) device->static_config; |
| 93 | } |
| 94 | |
| 95 | /*************************************************************************** |
| 96 | IMPLEMENTATION |
| 97 | ***************************************************************************/ |
| 98 | |
| 99 | /*------------------------------------------------- |
| 100 | z80sti_r - register read |
| 101 | -------------------------------------------------*/ |
| 102 | |
| 103 | READ8_DEVICE_HANDLER( z80sti_r ) |
| 104 | { |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | /*------------------------------------------------- |
| 109 | z80sti_w - register write |
| 110 | -------------------------------------------------*/ |
| 111 | |
| 112 | WRITE8_DEVICE_HANDLER( z80sti_w ) |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | /*------------------------------------------------- |
| 117 | z80sti_rc_w - receiver clock write |
| 118 | -------------------------------------------------*/ |
| 119 | |
| 120 | WRITE_LINE_DEVICE_HANDLER( z80sti_rc_w ) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | /*------------------------------------------------- |
| 125 | z80sti_tc_w - transmitter clock write |
| 126 | -------------------------------------------------*/ |
| 127 | |
| 128 | WRITE_LINE_DEVICE_HANDLER( z80sti_tc_w ) |
| 129 | { |
| 130 | } |
| 131 | |
| 132 | /*------------------------------------------------- |
| 133 | z80sti_i0_w - input 0 write |
| 134 | -------------------------------------------------*/ |
| 135 | |
| 136 | WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ) |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | /*------------------------------------------------- |
| 141 | z80sti_i1_w - input 1 write |
| 142 | -------------------------------------------------*/ |
| 143 | |
| 144 | WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ) |
| 145 | { |
| 146 | } |
| 147 | |
| 148 | /*------------------------------------------------- |
| 149 | z80sti_i2_w - input 2 write |
| 150 | -------------------------------------------------*/ |
| 151 | |
| 152 | WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ) |
| 153 | { |
| 154 | } |
| 155 | |
| 156 | /*------------------------------------------------- |
| 157 | z80sti_i3_w - input 3 write |
| 158 | -------------------------------------------------*/ |
| 159 | |
| 160 | WRITE_LINE_DEVICE_HANDLER( z80sti_i3_w ) |
| 161 | { |
| 162 | } |
| 163 | |
| 164 | /*------------------------------------------------- |
| 165 | z80sti_i4_w - input 4 write |
| 166 | -------------------------------------------------*/ |
| 167 | |
| 168 | WRITE_LINE_DEVICE_HANDLER( z80sti_i4_w ) |
| 169 | { |
| 170 | } |
| 171 | |
| 172 | /*------------------------------------------------- |
| 173 | z80sti_i5_w - input 5 write |
| 174 | -------------------------------------------------*/ |
| 175 | |
| 176 | WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ) |
| 177 | { |
| 178 | } |
| 179 | |
| 180 | /*------------------------------------------------- |
| 181 | z80sti_i6_w - input 6 write |
| 182 | -------------------------------------------------*/ |
| 183 | |
| 184 | WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ) |
| 185 | { |
| 186 | } |
| 187 | |
| 188 | /*------------------------------------------------- |
| 189 | z80sti_i7_w - input 7 write |
| 190 | -------------------------------------------------*/ |
| 191 | |
| 192 | WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ) |
| 193 | { |
| 194 | } |
| 195 | |
| 196 | /*------------------------------------------------- |
| 197 | z80sti_irq_state - get interrupt status |
| 198 | -------------------------------------------------*/ |
| 199 | |
| 200 | static int z80sti_irq_state(const device_config *device) |
| 201 | { |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | /*------------------------------------------------- |
| 206 | z80sti_irq_ack - interrupt acknowledge |
| 207 | -------------------------------------------------*/ |
| 208 | |
| 209 | static int z80sti_irq_ack(const device_config *device) |
| 210 | { |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | /*------------------------------------------------- |
| 215 | z80sti_irq_reti - return from interrupt |
| 216 | -------------------------------------------------*/ |
| 217 | |
| 218 | static void z80sti_irq_reti(const device_config *device) |
| 219 | { |
| 220 | } |
| 221 | |
| 222 | /*------------------------------------------------- |
| 223 | DEVICE_START( z80sti ) |
| 224 | -------------------------------------------------*/ |
| 225 | |
| 226 | static DEVICE_START( z80sti ) |
| 227 | { |
| 228 | z80sti_t *z80sti = get_safe_token(device); |
| 229 | const z80sti_interface *intf = device->static_config; |
| 230 | |
| 231 | /* resolve callbacks */ |
| 232 | devcb_resolve_read8(&z80sti->in_gpio_func, &intf->in_gpio_func, device); |
| 233 | devcb_resolve_write8(&z80sti->out_gpio_func, &intf->out_gpio_func, device); |
| 234 | devcb_resolve_read_line(&z80sti->in_si_func, &intf->in_si_func, device); |
| 235 | devcb_resolve_write_line(&z80sti->out_so_func, &intf->out_so_func, device); |
| 236 | devcb_resolve_write_line(&z80sti->out_tao_func, &intf->out_tao_func, device); |
| 237 | devcb_resolve_write_line(&z80sti->out_tbo_func, &intf->out_tbo_func, device); |
| 238 | devcb_resolve_write_line(&z80sti->out_tco_func, &intf->out_tco_func, device); |
| 239 | devcb_resolve_write_line(&z80sti->out_tdo_func, &intf->out_tdo_func, device); |
| 240 | devcb_resolve_write_line(&z80sti->out_irq_func, &intf->out_irq_func, device); |
| 241 | } |
| 242 | |
| 243 | /*------------------------------------------------- |
| 244 | DEVICE_RESET( z80sti ) |
| 245 | -------------------------------------------------*/ |
| 246 | |
| 247 | static DEVICE_RESET( z80sti ) |
| 248 | { |
| 249 | } |
| 250 | |
| 251 | /*------------------------------------------------- |
| 252 | DEVICE_GET_INFO( z80sti ) |
| 253 | -------------------------------------------------*/ |
| 254 | |
| 255 | DEVICE_GET_INFO( z80sti ) |
| 256 | { |
| 257 | switch (state) |
| 258 | { |
| 259 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 260 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80sti_t); break; |
| 261 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 262 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 263 | |
| 264 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 265 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80sti); break; |
| 266 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 267 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80sti); break; |
| 268 | case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80sti_irq_state; break; |
| 269 | case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80sti_irq_ack; break; |
| 270 | case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80sti_irq_reti; break; |
| 271 | |
| 272 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 273 | case DEVINFO_STR_NAME: strcpy(info->s, "Mostek MK3801"); break; |
| 274 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80 STI"); break; |
| 275 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 276 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 277 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 278 | } |
| 279 | } |
src/mess/machine/z80sti.h
| r0 | r4946 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Mostek MK3801 Serial Timer Interrupt Controller emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | _____ _____ |
| 10 | TAO 1 |* \_/ | 40 Vcc |
| 11 | TBO 2 | | 39 RC |
| 12 | TCO 3 | | 38 SI |
| 13 | TDO 4 | | 37 SO |
| 14 | TCK 5 | | 36 TC |
| 15 | _M1 6 | | 35 A0 |
| 16 | _RES 7 | | 34 A1 |
| 17 | I0 8 | | 33 A2 |
| 18 | I1 9 | | 32 A3 |
| 19 | I2 10 | MK3801 | 31 _WR |
| 20 | I3 11 | Z80 STI | 30 _CS |
| 21 | I4 12 | | 29 _RD |
| 22 | I5 13 | | 28 D7 |
| 23 | I6 14 | | 27 D6 |
| 24 | I7 15 | | 26 D5 |
| 25 | IEI 16 | | 25 D4 |
| 26 | _INT 17 | | 24 D3 |
| 27 | IEO 18 | | 23 D2 |
| 28 | _IORQ 19 | | 22 D1 |
| 29 | GND 20 |_____________| 21 D0 |
| 30 | |
| 31 | **********************************************************************/ |
| 32 | |
| 33 | #ifndef __Z80STI__ |
| 34 | #define __Z80STI__ |
| 35 | |
| 36 | #include "driver.h" |
| 37 | #include "devcb.h" |
| 38 | |
| 39 | /*************************************************************************** |
| 40 | MACROS / CONSTANTS |
| 41 | ***************************************************************************/ |
| 42 | |
| 43 | #define Z80STI DEVICE_GET_INFO_NAME( z80sti ) |
| 44 | |
| 45 | #define MDRV_Z80STI_ADD(_tag, _clock, _config) \ |
| 46 | MDRV_DEVICE_ADD((_tag), Z80STI, _clock) \ |
| 47 | MDRV_DEVICE_CONFIG(_config) |
| 48 | |
| 49 | #define MDRV_MK68901_ADD(_tag, _clock, _config) \ |
| 50 | MDRV_DEVICE_ADD((_tag), MK68901, _clock) \ |
| 51 | MDRV_DEVICE_CONFIG(_config) |
| 52 | |
| 53 | #define Z80STI_INTERFACE(name) const z80sti_interface (name) = |
| 54 | |
| 55 | /*************************************************************************** |
| 56 | TYPE DEFINITIONS |
| 57 | ***************************************************************************/ |
| 58 | |
| 59 | typedef struct _z80sti_interface z80sti_interface; |
| 60 | struct _z80sti_interface |
| 61 | { |
| 62 | int rx_clock; /* serial receive clock */ |
| 63 | int tx_clock; /* serial transmit clock */ |
| 64 | |
| 65 | /* this is called on each read of the I/O pins */ |
| 66 | devcb_read8 in_gpio_func; |
| 67 | |
| 68 | /* this is called on each write of the I/O pins */ |
| 69 | devcb_write8 out_gpio_func; |
| 70 | |
| 71 | /* this gets called for each read of the SI pin (pin 38) */ |
| 72 | devcb_read_line in_si_func; |
| 73 | |
| 74 | /* this gets called for each change of the SO pin (pin 37) */ |
| 75 | devcb_write_line out_so_func; |
| 76 | |
| 77 | /* this gets called for each change of the TAO pin (pin 1) */ |
| 78 | devcb_write_line out_tao_func; |
| 79 | |
| 80 | /* this gets called for each change of the TBO pin (pin 2) */ |
| 81 | devcb_write_line out_tbo_func; |
| 82 | |
| 83 | /* this gets called for each change of the TCO pin (pin 3) */ |
| 84 | devcb_write_line out_tco_func; |
| 85 | |
| 86 | /* this gets called for each change of the TDO pin (pin 4) */ |
| 87 | devcb_write_line out_tdo_func; |
| 88 | |
| 89 | /* this gets called on each change of the interrupt line (pin 17) */ |
| 90 | devcb_write_line out_irq_func; |
| 91 | }; |
| 92 | |
| 93 | /*************************************************************************** |
| 94 | PROTOTYPES |
| 95 | ***************************************************************************/ |
| 96 | |
| 97 | /* device interface */ |
| 98 | DEVICE_GET_INFO( z80sti ); |
| 99 | |
| 100 | /* register access */ |
| 101 | READ8_DEVICE_HANDLER( z80sti_r ); |
| 102 | WRITE8_DEVICE_HANDLER( z80sti_w ); |
| 103 | |
| 104 | /* receive clock */ |
| 105 | WRITE_LINE_DEVICE_HANDLER( z80sti_rc_w ); |
| 106 | |
| 107 | /* transmit clock */ |
| 108 | WRITE_LINE_DEVICE_HANDLER( z80sti_tc_w ); |
| 109 | |
| 110 | /* input write */ |
| 111 | WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ); |
| 112 | WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ); |
| 113 | WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ); |
| 114 | WRITE_LINE_DEVICE_HANDLER( z80sti_i3_w ); |
| 115 | WRITE_LINE_DEVICE_HANDLER( z80sti_i4_w ); |
| 116 | WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ); |
| 117 | WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ); |
| 118 | WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ); |
| 119 | |
| 120 | #endif |
src/mess/drivers/prof80.c
| r4945 | r4946 | |
| 12 | 12 | |
| 13 | 13 | TODO: |
| 14 | 14 | |
| 15 | | - Z80 STI |
| 15 | - Z80 STI (Mostek MK3801) push-model |
| 16 | 16 | - PROF-GRIP communications |
| 17 | 17 | - UNIO card (Z80-STI, Z80-SIO, 2x centronics) |
| 18 | 18 | - GRIP-COLOR (192kB color RAM) |
| r4945 | r4946 | |
| 28 | 28 | #include "machine/8255ppi.h" |
| 29 | 29 | #include "machine/nec765.h" |
| 30 | 30 | #include "machine/upd1990a.h" |
| 31 | #include "machine/z80sti.h" |
| 31 | 32 | #include "machine/ctronics.h" |
| 32 | 33 | |
| 33 | 34 | /* PROF-80 */ |
| r4945 | r4946 | |
| 407 | 408 | // AM_RANGE(0x15, 0x15) AM_WRITE(cc2_w) |
| 408 | 409 | // AM_RANGE(0x16, 0x16) AM_WRITE(flash_w) |
| 409 | 410 | // AM_RANGE(0x17, 0x17) AM_WRITE(vol1_w) |
| 410 | | // AM_RANGE(0x20, 0x2f) AM_DEVREADWRITE(Z80STI_TAG, z80sti_r, z80sti_w) |
| 411 | AM_RANGE(0x20, 0x2f) AM_DEVREADWRITE(Z80STI_TAG, z80sti_r, z80sti_w) |
| 411 | 412 | AM_RANGE(0x30, 0x30) AM_READWRITE(lrs_r, lrs_w) |
| 412 | 413 | AM_RANGE(0x40, 0x40) AM_READ(grip_status_r) |
| 413 | 414 | AM_RANGE(0x50, 0x50) AM_DEVWRITE(MC6845_TAG, mc6845_address_w) |
| r4945 | r4946 | |
| 443 | 444 | } |
| 444 | 445 | } |
| 445 | 446 | |
| 446 | | static MC6845_ON_VSYNC_CHANGED( grip_vsync_changed ) |
| 447 | static MC6845_ON_DE_CHANGED( grip_on_de_changed ) |
| 447 | 448 | { |
| 448 | 449 | prof80_state *state = device->machine->driver_data; |
| 449 | 450 | |
| 450 | | state->vsync = vsync; |
| 451 | z80sti_i1_w(state->z80sti, display_enabled); |
| 451 | 452 | } |
| 452 | 453 | |
| 453 | 454 | static const mc6845_interface grip_mc6845_interface = |
| r4945 | r4946 | |
| 457 | 458 | NULL, |
| 458 | 459 | grip_update_row, |
| 459 | 460 | NULL, |
| 461 | grip_on_de_changed, |
| 460 | 462 | NULL, |
| 461 | 463 | NULL, |
| 462 | | grip_vsync_changed |
| 464 | NULL |
| 463 | 465 | }; |
| 464 | 466 | |
| 465 | 467 | static VIDEO_START( prof80 ) |
| r4945 | r4946 | |
| 625 | 627 | DEVCB_HANDLER(grip_ppi8255_c_w) // Port C write |
| 626 | 628 | }; |
| 627 | 629 | |
| 630 | /* Z80-STI Interface */ |
| 631 | |
| 632 | static WRITE_LINE_DEVICE_HANDLER( grip_z80sti_irq_w ) |
| 633 | { |
| 634 | cputag_set_input_line(device->machine, "grip", INPUT_LINE_IRQ0, state); |
| 635 | } |
| 636 | |
| 637 | static Z80STI_INTERFACE( grip_z80sti_interface ) |
| 638 | { |
| 639 | 0, |
| 640 | 0, |
| 641 | DEVCB_NULL, |
| 642 | DEVCB_NULL, |
| 643 | DEVCB_NULL, |
| 644 | DEVCB_NULL, |
| 645 | DEVCB_NULL, |
| 646 | DEVCB_NULL, |
| 647 | DEVCB_NULL, |
| 648 | DEVCB_NULL, |
| 649 | DEVCB_LINE(grip_z80sti_irq_w) |
| 650 | }; |
| 651 | |
| 628 | 652 | /* Machine Initialization */ |
| 629 | 653 | |
| 630 | 654 | static MACHINE_START( prof80 ) |
| r4945 | r4946 | |
| 637 | 661 | state->upd1990a = devtag_get_device(machine, UPD1990A_TAG); |
| 638 | 662 | state->mc6845 = devtag_get_device(machine, MC6845_TAG); |
| 639 | 663 | state->ppi8255 = devtag_get_device(machine, PPI8255_TAG); |
| 664 | state->z80sti = devtag_get_device(machine, Z80STI_TAG); |
| 640 | 665 | state->centronics = devtag_get_device(machine, "centronics"); |
| 641 | 666 | |
| 642 | 667 | /* initialize RTC */ |
| r4945 | r4946 | |
| 667 | 692 | state_save_register_global_array(machine, state->mmu); |
| 668 | 693 | state_save_register_global(machine, state->mme); |
| 669 | 694 | state_save_register_global_pointer(machine, state->video_ram, GRIP_VIDEORAM_SIZE); |
| 670 | | state_save_register_global(machine, state->vsync); |
| 671 | 695 | state_save_register_global(machine, state->rtc_data); |
| 672 | 696 | state_save_register_global(machine, state->fdc_index); |
| 673 | 697 | } |
| r4945 | r4946 | |
| 719 | 743 | MDRV_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, prof80_upd1990a_intf) |
| 720 | 744 | MDRV_NEC765A_ADD(NEC765_TAG, prof80_nec765_interface) |
| 721 | 745 | MDRV_PPI8255_ADD(PPI8255_TAG, grip_ppi8255_interface) |
| 746 | MDRV_Z80STI_ADD(Z80STI_TAG, XTAL_16MHz/4, grip_z80sti_interface) |
| 722 | 747 | |
| 723 | 748 | /* printer */ |
| 724 | 749 | MDRV_CENTRONICS_ADD("centronics", standard_centronics) |