src/mess/devices/coco_232.c
| r0 | r4364 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | coco_232.c |
| 4 | |
| 5 | Code for emulating the CoCo RS-232 PAK |
| 6 | |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | #include "driver.h" |
| 10 | #include "device.h" |
| 11 | #include "cococart.h" |
| 12 | #include "machine/6551.h" |
| 13 | |
| 14 | |
| 15 | /*************************************************************************** |
| 16 | CONSTANTS |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #define UART_TAG "uart" |
| 20 | |
| 21 | |
| 22 | /*************************************************************************** |
| 23 | TYPE DEFINITIONS |
| 24 | ***************************************************************************/ |
| 25 | |
| 26 | typedef struct _coco_rs232_pcb_t coco_rs232_pcb_t; |
| 27 | struct _coco_rs232_pcb_t |
| 28 | { |
| 29 | const device_config *cococart; |
| 30 | const device_config *cart; |
| 31 | const device_config *uart; |
| 32 | }; |
| 33 | |
| 34 | |
| 35 | /*************************************************************************** |
| 36 | INLINE FUNCTIONS |
| 37 | ***************************************************************************/ |
| 38 | |
| 39 | INLINE coco_rs232_pcb_t *get_token(const device_config *device) |
| 40 | { |
| 41 | assert(device != NULL); |
| 42 | assert(device->type == COCO_CARTRIDGE_PCB_RS232); |
| 43 | return (coco_rs232_pcb_t *) device->token; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | /*************************************************************************** |
| 48 | IMPLEMENTATION |
| 49 | ***************************************************************************/ |
| 50 | |
| 51 | /*------------------------------------------------- |
| 52 | DEVICE_START(coco_rs232) |
| 53 | -------------------------------------------------*/ |
| 54 | |
| 55 | static DEVICE_START(coco_rs232) |
| 56 | { |
| 57 | coco_rs232_pcb_t *pak_pcb = get_token(device); |
| 58 | astring *tempstring = astring_alloc(); |
| 59 | |
| 60 | memset(pak_pcb, 0, sizeof(*pak_pcb)); |
| 61 | pak_pcb->cococart = device->owner->owner; |
| 62 | pak_pcb->cart = device->owner; |
| 63 | pak_pcb->uart = devtag_get_device(device->machine, ACIA6551, device_build_tag(tempstring, device, UART_TAG)); |
| 64 | |
| 65 | astring_free(tempstring); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | /*------------------------------------------------- |
| 70 | READ8_DEVICE_HANDLER(coco_rs232_ff40_r) |
| 71 | -------------------------------------------------*/ |
| 72 | |
| 73 | static READ8_DEVICE_HANDLER(coco_rs232_ff40_r) |
| 74 | { |
| 75 | UINT8 result = 0x00; |
| 76 | coco_rs232_pcb_t *pak_pcb = get_token(device); |
| 77 | |
| 78 | if ((offset >= 0x28) && (offset <= 0x2F)) |
| 79 | result = acia_6551_r(pak_pcb->uart, offset - 0x28); |
| 80 | |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /*------------------------------------------------- |
| 86 | WRITE8_DEVICE_HANDLER(coco_rs232_ff40_r) |
| 87 | -------------------------------------------------*/ |
| 88 | |
| 89 | static WRITE8_DEVICE_HANDLER(coco_rs232_ff40_w) |
| 90 | { |
| 91 | coco_rs232_pcb_t *pak_pcb = get_token(device); |
| 92 | |
| 93 | if ((offset >= 0x28) && (offset <= 0x2F)) |
| 94 | acia_6551_w(pak_pcb->uart, offset - 0x28, data); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | /*------------------------------------------------- |
| 99 | DEVICE_GET_INFO(coco_cartridge_pcb_rs232) |
| 100 | -------------------------------------------------*/ |
| 101 | |
| 102 | DEVICE_GET_INFO(coco_cartridge_pcb_rs232) |
| 103 | { |
| 104 | static MACHINE_DRIVER_START(coco_rs232) |
| 105 | MDRV_ACIA6551_ADD(UART_TAG) |
| 106 | MACHINE_DRIVER_END |
| 107 | |
| 108 | switch(state) |
| 109 | { |
| 110 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 111 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(coco_rs232_pcb_t); break; |
| 112 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 113 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 114 | |
| 115 | /* --- the following bits of info are returned as pointers to data --- */ |
| 116 | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(coco_rs232); break; |
| 117 | |
| 118 | /* --- the following bits of info are returned as pointers to functions --- */ |
| 119 | case DEVINFO_FCT_SET_INFO: /* Nothing */ break; |
| 120 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(coco_rs232); break; |
| 121 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 122 | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 123 | case COCOCARTINFO_FCT_FF40_R: info->f = (genf *) coco_rs232_ff40_r; break; |
| 124 | case COCOCARTINFO_FCT_FF40_W: info->f = (genf *) coco_rs232_ff40_w; break; |
| 125 | |
| 126 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 127 | case DEVINFO_STR_NAME: strcpy(info->s, "CoCo RS-232 PAK"); break; |
| 128 | case DEVINFO_STR_FAMILY: strcpy(info->s, "CoCo RS-232 PAK"); break; |
| 129 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 130 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 131 | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 132 | } |
| 133 | } |
src/mess/devices/cococart.c
| r4363 | r4364 | |
| 348 | 348 | MDRV_CARTSLOT_PCBTYPE(0, "coco_fdc", COCO_CARTRIDGE_PCB_FDC_COCO) |
| 349 | 349 | MDRV_CARTSLOT_PCBTYPE(1, "banked_16k", COCO_CARTRIDGE_PCB_PAK_BANKED16K) |
| 350 | 350 | MDRV_CARTSLOT_PCBTYPE(2, "orch90", COCO_CARTRIDGE_PCB_ORCH90) |
| 351 | | //MDRV_CARTSLOT_PCBTYPE(3, "coco_ssc", COCO_CARTRIDGE_PCB_SSC) |
| 352 | | MDRV_CARTSLOT_PCBTYPE(3, "", COCO_CARTRIDGE_PCB_PAK) |
| 351 | MDRV_CARTSLOT_PCBTYPE(3, "rs232", COCO_CARTRIDGE_PCB_RS232) |
| 352 | //MDRV_CARTSLOT_PCBTYPE(4, "coco_ssc", COCO_CARTRIDGE_PCB_SSC) |
| 353 | MDRV_CARTSLOT_PCBTYPE(4, "", COCO_CARTRIDGE_PCB_PAK) |
| 353 | 354 | MACHINE_DRIVER_END |
| 354 | 355 | |
| 355 | 356 | /*------------------------------------------------- |