src/mess/machine/com8116.c
| r0 | r4910 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | COM8116 - Dual Baud Rate Generator (Programmable Divider) emulation |
| 4 | |
| 5 | Copyright 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 "com8116.h" |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | PARAMETERS |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #define LOG 0 |
| 26 | |
| 27 | /*************************************************************************** |
| 28 | TYPE DEFINITIONS |
| 29 | ***************************************************************************/ |
| 30 | |
| 31 | typedef struct _com8116_t com8116_t; |
| 32 | struct _com8116_t |
| 33 | { |
| 34 | devcb_resolved_write_line out_fx4_func; |
| 35 | devcb_resolved_write_line out_fr_func; |
| 36 | devcb_resolved_write_line out_ft_func; |
| 37 | |
| 38 | /* timers */ |
| 39 | emu_timer *fx4_timer; |
| 40 | emu_timer *fr_timer; |
| 41 | emu_timer *ft_timer; |
| 42 | }; |
| 43 | |
| 44 | /*************************************************************************** |
| 45 | INLINE FUNCTIONS |
| 46 | ***************************************************************************/ |
| 47 | |
| 48 | INLINE com8116_t *get_safe_token(const device_config *device) |
| 49 | { |
| 50 | assert(device != NULL); |
| 51 | assert(device->token != NULL); |
| 52 | assert(device->type == COM8116); |
| 53 | return (com8116_t *)device->token; |
| 54 | } |
| 55 | |
| 56 | INLINE const com8116_interface *get_interface(const device_config *device) |
| 57 | { |
| 58 | assert(device != NULL); |
| 59 | assert((device->type == COM8116)); |
| 60 | return (const com8116_interface *) device->static_config; |
| 61 | } |
| 62 | |
| 63 | /*************************************************************************** |
| 64 | IMPLEMENTATION |
| 65 | ***************************************************************************/ |
| 66 | |
| 67 | /*------------------------------------------------- |
| 68 | com8116_str_w - receiver strobe write |
| 69 | -------------------------------------------------*/ |
| 70 | |
| 71 | WRITE8_DEVICE_HANDLER( com8116_str_w ) |
| 72 | { |
| 73 | // com8116_t *com8116 = get_safe_token(device); |
| 74 | |
| 75 | if (LOG) logerror("COM8116 '%s' Receiver Divider %01x\n", device->tag, data & 0x0f); |
| 76 | |
| 77 | // timer_adjust_periodic(com8116->fr_timer, attotime_zero, 0, ATTOTIME_IN_HZ(1)); |
| 78 | } |
| 79 | |
| 80 | /*------------------------------------------------- |
| 81 | com8116_stt_w - transmitter strobe write |
| 82 | -------------------------------------------------*/ |
| 83 | |
| 84 | WRITE8_DEVICE_HANDLER( com8116_stt_w ) |
| 85 | { |
| 86 | // com8116_t *com8116 = get_safe_token(device); |
| 87 | |
| 88 | if (LOG) logerror("COM8116 '%s' Transmitter Divider %01x\n", device->tag, data & 0x0f); |
| 89 | |
| 90 | // timer_adjust_periodic(com8116->ft_timer, attotime_zero, 0, ATTOTIME_IN_HZ(1)); |
| 91 | } |
| 92 | |
| 93 | /*------------------------------------------------- |
| 94 | TIMER_CALLBACK( fx4_tick ) |
| 95 | -------------------------------------------------*/ |
| 96 | |
| 97 | static TIMER_CALLBACK( fx4_tick ) |
| 98 | { |
| 99 | const device_config *device = ptr; |
| 100 | com8116_t *com8116 = get_safe_token(device); |
| 101 | |
| 102 | devcb_call_write_line(&com8116->out_fx4_func, 1); |
| 103 | } |
| 104 | |
| 105 | /*------------------------------------------------- |
| 106 | TIMER_CALLBACK( fr_tick ) |
| 107 | -------------------------------------------------*/ |
| 108 | |
| 109 | static TIMER_CALLBACK( fr_tick ) |
| 110 | { |
| 111 | const device_config *device = ptr; |
| 112 | com8116_t *com8116 = get_safe_token(device); |
| 113 | |
| 114 | devcb_call_write_line(&com8116->out_fr_func, 1); |
| 115 | } |
| 116 | |
| 117 | /*------------------------------------------------- |
| 118 | TIMER_CALLBACK( ft_tick ) |
| 119 | -------------------------------------------------*/ |
| 120 | |
| 121 | static TIMER_CALLBACK( ft_tick ) |
| 122 | { |
| 123 | const device_config *device = ptr; |
| 124 | com8116_t *com8116 = get_safe_token(device); |
| 125 | |
| 126 | devcb_call_write_line(&com8116->out_ft_func, 1); |
| 127 | } |
| 128 | |
| 129 | /*------------------------------------------------- |
| 130 | DEVICE_START( com8116 ) |
| 131 | -------------------------------------------------*/ |
| 132 | |
| 133 | static DEVICE_START( com8116 ) |
| 134 | { |
| 135 | com8116_t *com8116 = get_safe_token(device); |
| 136 | const com8116_interface *intf = get_interface(device); |
| 137 | |
| 138 | /* resolve callbacks */ |
| 139 | devcb_resolve_write_line(&com8116->out_fx4_func, &intf->out_fx4_func, device); |
| 140 | devcb_resolve_write_line(&com8116->out_fr_func, &intf->out_fr_func, device); |
| 141 | devcb_resolve_write_line(&com8116->out_ft_func, &intf->out_ft_func, device); |
| 142 | |
| 143 | /* create the timers */ |
| 144 | if (com8116->out_fx4_func.target) |
| 145 | { |
| 146 | com8116->fx4_timer = timer_alloc(device->machine, fx4_tick, (void *)device); |
| 147 | timer_adjust_periodic(com8116->fx4_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 4)); |
| 148 | } |
| 149 | |
| 150 | com8116->fr_timer = timer_alloc(device->machine, fr_tick, (void *)device); |
| 151 | com8116->ft_timer = timer_alloc(device->machine, ft_tick, (void *)device); |
| 152 | |
| 153 | /* register for state saving */ |
| 154 | // state_save_register_global(device->machine, com8116->); |
| 155 | } |
| 156 | |
| 157 | /*------------------------------------------------- |
| 158 | DEVICE_GET_INFO( com8116 ) |
| 159 | -------------------------------------------------*/ |
| 160 | |
| 161 | DEVICE_GET_INFO( com8116 ) |
| 162 | { |
| 163 | switch (state) |
| 164 | { |
| 165 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 166 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(com8116_t); break; |
| 167 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 168 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 169 | |
| 170 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 171 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(com8116); break; |
| 172 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 173 | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 174 | |
| 175 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 176 | case DEVINFO_STR_NAME: strcpy(info->s, "COM8116"); break; |
| 177 | case DEVINFO_STR_FAMILY: strcpy(info->s, "COM8116"); break; |
| 178 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 179 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 180 | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 181 | } |
| 182 | } |
src/mess/machine/com8116.h
| r0 | r4910 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | COM8116 - Dual Baud Rate Generator (Programmable Divider) emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | _____ _____ |
| 10 | XTAL/EXT1 1 |* \_/ | 18 XTAL/EXT2 |
| 11 | +5V 2 | | 17 fT |
| 12 | fR 3 | | 16 Ta |
| 13 | Ra 4 | COM8116 | 15 Tb |
| 14 | Rb 5 | COM8116T | 14 Tc |
| 15 | Rc 6 | COM8136 | 13 Td |
| 16 | Rd 7 | COM8136T | 12 STT |
| 17 | STR 8 | | 11 GND |
| 18 | NC 9 |_____________| 10 fX/4 |
| 19 | |
| 20 | **********************************************************************/ |
| 21 | |
| 22 | #ifndef __COM8116__ |
| 23 | #define __COM8116__ |
| 24 | |
| 25 | #include "devcb.h" |
| 26 | |
| 27 | /*************************************************************************** |
| 28 | MACROS / CONSTANTS |
| 29 | ***************************************************************************/ |
| 30 | |
| 31 | #define COM8116 DEVICE_GET_INFO_NAME(com8116) |
| 32 | |
| 33 | #define MDRV_COM8116_ADD(_tag, _clock, _config) \ |
| 34 | MDRV_DEVICE_ADD(_tag, COM8116, _clock) \ |
| 35 | MDRV_DEVICE_CONFIG(_config) |
| 36 | |
| 37 | #define MDRV_COM8116_REMOVE(_tag) \ |
| 38 | MDRV_DEVICE_REMOVE(_tag) |
| 39 | |
| 40 | #define COM8116_INTERFACE(name) \ |
| 41 | const com8116_interface (name)= |
| 42 | |
| 43 | /*************************************************************************** |
| 44 | TYPE DEFINITIONS |
| 45 | ***************************************************************************/ |
| 46 | |
| 47 | typedef struct _com8116_interface com8116_interface; |
| 48 | struct _com8116_interface |
| 49 | { |
| 50 | /* this gets called for every change of the fX/4 pin (pin 10) */ |
| 51 | devcb_write_line out_fx4_func; |
| 52 | |
| 53 | /* this gets called for every change of the fR pin (pin 3) */ |
| 54 | devcb_write_line out_fr_func; |
| 55 | |
| 56 | /* this gets called for every change of the fT pin (pin 17) */ |
| 57 | devcb_write_line out_ft_func; |
| 58 | |
| 59 | /* receiver divisor ROM */ |
| 60 | UINT32 fr_dividers[16]; |
| 61 | |
| 62 | /* transmitter divisor ROM */ |
| 63 | UINT32 ft_dividers[16]; |
| 64 | }; |
| 65 | |
| 66 | /*************************************************************************** |
| 67 | PROTOTYPES |
| 68 | ***************************************************************************/ |
| 69 | |
| 70 | /* device interface */ |
| 71 | DEVICE_GET_INFO( com8116 ); |
| 72 | |
| 73 | /* receiver strobe */ |
| 74 | WRITE8_DEVICE_HANDLER( com8116_str_w ); |
| 75 | |
| 76 | /* transmitter strobe */ |
| 77 | WRITE8_DEVICE_HANDLER( com8116_stt_w ); |
| 78 | |
| 79 | #endif /* __COM8116__ */ |
src/mess/drivers/xerox820.c
| r4909 | r4910 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | 14 | - add xtals.h |
| 15 | | - baud A/B (COM8116 chip) |
| 15 | - COM8116 |
| 16 | 16 | - type in Monitor v1.0 from manual |
| 17 | 17 | - proper keyboard emulation (MCU?) |
| 18 | 18 | |
| r4909 | r4910 | |
| 30 | 30 | #include "machine/z80ctc.h" |
| 31 | 31 | #include "machine/z80sio.h" |
| 32 | 32 | #include "machine/wd17xx.h" |
| 33 | #include "machine/com8116.h" |
| 33 | 34 | #include "devices/basicdsk.h" |
| 34 | 35 | |
| 35 | 36 | INLINE const device_config *get_floppy_image(running_machine *machine, int drive) |
| r4909 | r4910 | |
| 170 | 171 | z80pio_d_w(device, channel, data); |
| 171 | 172 | } |
| 172 | 173 | |
| 173 | | static WRITE8_HANDLER( bauda_w ) |
| 174 | | { |
| 175 | | // xerox820_state *state = space->machine->driver_data; |
| 176 | | |
| 177 | | // com8116_str_w(state->com8116, data & 0x0f); |
| 178 | | } |
| 179 | | |
| 180 | | static WRITE8_HANDLER( baudb_w ) |
| 181 | | { |
| 182 | | // xerox820_state *state = space->machine->driver_data; |
| 183 | | |
| 184 | | // com8116_stt_w(state->com8116, data & 0x0f); |
| 185 | | } |
| 186 | | |
| 187 | 174 | static WRITE8_HANDLER( scroll_w ) |
| 188 | 175 | { |
| 189 | 176 | xerox820_state *state = space->machine->driver_data; |
| r4909 | r4910 | |
| 203 | 190 | |
| 204 | 191 | static ADDRESS_MAP_START( xerox820_io, ADDRESS_SPACE_IO, 8 ) |
| 205 | 192 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 206 | | AM_RANGE(0x00, 0x00) AM_MIRROR(0x03) AM_WRITE(bauda_w) |
| 193 | AM_RANGE(0x00, 0x00) AM_MIRROR(0x03) AM_DEVWRITE(COM8116_TAG, com8116_str_w) |
| 207 | 194 | AM_RANGE(0x04, 0x04) AM_MIRROR(0x02) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w) |
| 208 | 195 | AM_RANGE(0x05, 0x05) AM_MIRROR(0x02) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w) |
| 209 | 196 | AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE(Z80GPPIO_TAG, z80pio_alt_r, z80pio_alt_w) |
| 210 | | AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x03) AM_WRITE(baudb_w) |
| 197 | AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x03) AM_DEVWRITE(COM8116_TAG, com8116_stt_w) |
| 211 | 198 | AM_RANGE(0x10, 0x13) AM_DEVREADWRITE(WD1771_TAG, wd17xx_r, wd17xx_w) |
| 212 | 199 | AM_RANGE(0x14, 0x14) AM_MIRROR(0x03) AM_WRITE(scroll_w) |
| 213 | 200 | AM_RANGE(0x18, 0x1b) AM_DEVREADWRITE(Z80CTC_TAG, z80ctc_r, z80ctc_w) |
| r4909 | r4910 | |
| 506 | 493 | case WD17XX_DRQ_SET: driver_state->fdc_drq = 1; break; |
| 507 | 494 | } |
| 508 | 495 | |
| 509 | | logerror("halt %u FDC IRQ %u DRQ %u\n", halt, driver_state->fdc_irq, driver_state->fdc_drq); |
| 510 | | |
| 511 | 496 | if (halt && (driver_state->fdc_irq | driver_state->fdc_drq)) |
| 512 | 497 | { |
| 513 | 498 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, ASSERT_LINE); |
| r4909 | r4910 | |
| 524 | 509 | NULL |
| 525 | 510 | }; |
| 526 | 511 | |
| 512 | /* COM8116 Interface */ |
| 513 | |
| 514 | static COM8116_INTERFACE( com8116_intf ) |
| 515 | { |
| 516 | DEVCB_NULL, /* fX/4 output */ |
| 517 | DEVCB_NULL, /* fR output */ |
| 518 | DEVCB_NULL, /* fT output */ |
| 519 | {}, /* receiver ROM */ |
| 520 | {} /* transmitter ROM */ |
| 521 | }; |
| 522 | |
| 527 | 523 | /* Video */ |
| 528 | 524 | |
| 529 | 525 | static VIDEO_START( xerox820 ) |
| r4909 | r4910 | |
| 654 | 650 | MDRV_Z80PIO_ADD(Z80GPPIO_TAG, gppio_intf) |
| 655 | 651 | MDRV_Z80CTC_ADD(Z80CTC_TAG, XTAL_20MHz/8, ctc_intf) |
| 656 | 652 | MDRV_WD1773_ADD(WD1771_TAG, wd1771_intf) // workaround wd17xx.c ready state bug, should be MDRV_WD177X_ADD |
| 657 | | // MDRV_COM8116_ADD(COM8116_TAG, 5068800, com8116_intf) |
| 653 | MDRV_COM8116_ADD(COM8116_TAG, 5068800, com8116_intf) |
| 658 | 654 | MACHINE_DRIVER_END |
| 659 | 655 | |
| 660 | 656 | static MACHINE_DRIVER_START( xerox820ii ) |