|
| 1 | +/* ka10_cart.c: Stanford cart, with audiovisual system indicators. |
| 2 | +
|
| 3 | + Copyright (c) 2021, Lars Brinkhoff |
| 4 | +
|
| 5 | + Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | + copy of this software and associated documentation files (the "Software"), |
| 7 | + to deal in the Software without restriction, including without limitation |
| 8 | + the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | + and/or sell copies of the Software, and to permit persons to whom the |
| 10 | + Software is furnished to do so, subject to the following conditions: |
| 11 | +
|
| 12 | + The above copyright notice and this permission notice shall be included in |
| 13 | + all copies or substantial portions of the Software. |
| 14 | +
|
| 15 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | + LARS BRINKHOFF BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 19 | + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 20 | + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | +
|
| 22 | + This is a device which interfaces with the Stanford cart. It also |
| 23 | + controls three lights and a solenoid to ring a bell. It's specific |
| 24 | + to the SAIL PDP-10. The hardware interface is documented in the |
| 25 | + UUO manual. |
| 26 | +*/ |
| 27 | + |
| 28 | +#include "kx10_defs.h" |
| 29 | + |
| 30 | +#if NUM_DEVS_CART > 0 |
| 31 | + |
| 32 | +#define CART_DEVNUM 0354 |
| 33 | + |
| 34 | +/* CONO bits. */ |
| 35 | +#define CART_UDP 0000001LL /* UDP in use. */ |
| 36 | +#define CART_RED 0000004LL /* System crash. */ |
| 37 | +#define CART_YEL 0000010LL /* System crash. */ |
| 38 | +#define CART_TUN 0000720LL /* TV tuner. */ |
| 39 | +#define CART_BEL 0001000LL /* System being debugged. */ |
| 40 | +#define CART_DRV 0001000LL /* Cart drive direction. */ |
| 41 | +#define CART_ON 0002000LL /* Cart drive on. */ |
| 42 | +#define CART_STR 0004000LL /* Cart steer right. */ |
| 43 | +#define CART_STL 0010000LL /* Cart steer left. */ |
| 44 | +#define CART_PNR 0020000LL /* Cart pan right. */ |
| 45 | +#define CART_PNL 0040000LL /* Cart pan left. */ |
| 46 | +#define CART_MASK 0177777LL |
| 47 | +#define CART_GRN 0200000LL /* One-shot: system running. */ |
| 48 | +#define CART_OFF 0400000LL |
| 49 | + |
| 50 | +/* Delay for one-shot action, in microseconds. */ |
| 51 | +#define CART_ONESHOT 1000000 |
| 52 | + |
| 53 | +/* Device state is 18 bits. */ |
| 54 | +#define cart_bits cart_unit.u3 |
| 55 | + |
| 56 | +static t_stat cart_devio(uint32 dev, uint64 *data); |
| 57 | +static t_stat cart_svc(UNIT *uptr); |
| 58 | +static t_stat cart_reset (DEVICE *dptr); |
| 59 | +static const char *cart_description (DEVICE *dptr); |
| 60 | + |
| 61 | +DIB cart_dib = { CART_DEVNUM, 1, &cart_devio, NULL }; |
| 62 | + |
| 63 | +UNIT cart_unit = { |
| 64 | + UDATA (&cart_svc, UNIT_IDLE, 0) |
| 65 | +}; |
| 66 | + |
| 67 | +REG cart_reg[] = { |
| 68 | + {ORDATA(BITS, cart_bits, 18)}, |
| 69 | + {0} |
| 70 | +}; |
| 71 | + |
| 72 | +DEVICE cart_dev = { |
| 73 | + "CART", &cart_unit, cart_reg, NULL, |
| 74 | + 1, 8, 0, 1, 8, 36, |
| 75 | + NULL, NULL, &cart_reset, NULL, NULL, NULL, |
| 76 | + &cart_dib, DEV_DISABLE | DEV_DIS | DEV_DEBUG, 0, NULL, |
| 77 | + NULL, NULL, NULL, NULL, NULL, &cart_description |
| 78 | +}; |
| 79 | + |
| 80 | +void cart_on (uint64 bits) |
| 81 | +{ |
| 82 | + bits &= ~cart_bits; |
| 83 | + cart_bits |= bits; |
| 84 | + if (bits & CART_UDP) |
| 85 | + sim_debug (DEBUG_CMD, &cart_dev, "UDP in use lamp on."); |
| 86 | + if (bits & CART_RED) |
| 87 | + sim_debug (DEBUG_CMD, &cart_dev, "Red lamp on."); |
| 88 | + if (bits & CART_YEL) |
| 89 | + sim_debug (DEBUG_CMD, &cart_dev, "Yellow lamp on."); |
| 90 | + if (bits & CART_BEL) |
| 91 | + sim_debug (DEBUG_CMD, &cart_dev, "Bell!"); |
| 92 | + if (bits & CART_GRN) |
| 93 | + sim_debug (DEBUG_CMD, &cart_dev, "Green lamp on."); |
| 94 | + if (bits & CART_TUN) |
| 95 | + sim_debug (DEBUG_CMD, &cart_dev, "Frobbing TV tuner."); |
| 96 | +} |
| 97 | + |
| 98 | +void cart_off (uint64 bits) |
| 99 | +{ |
| 100 | + bits &= cart_bits; |
| 101 | + cart_bits &= ~bits; |
| 102 | + if (bits & CART_UDP) |
| 103 | + sim_debug (DEBUG_CMD, &cart_dev, "UDP in use lamp off."); |
| 104 | + if (bits & CART_RED) |
| 105 | + sim_debug (DEBUG_CMD, &cart_dev, "Red lamp off."); |
| 106 | + if (bits & CART_YEL) |
| 107 | + sim_debug (DEBUG_CMD, &cart_dev, "Yellow lamp off."); |
| 108 | + if (bits & CART_GRN) |
| 109 | + sim_debug (DEBUG_CMD, &cart_dev, "Green lamp off."); |
| 110 | + if (bits & CART_TUN) |
| 111 | + sim_debug (DEBUG_CMD, &cart_dev, "Frobbing TV tuner."); |
| 112 | +} |
| 113 | + |
| 114 | +void cart_oneshot (void) |
| 115 | +{ |
| 116 | + /* This is a "one-shot" action. */ |
| 117 | + sim_debug(DEBUG_DETAIL, &cart_dev, "Trigger one shot."); |
| 118 | + cart_on (CART_GRN); |
| 119 | + cart_off (CART_GRN << 1); |
| 120 | + sim_cancel (&cart_unit); |
| 121 | + sim_activate_after (&cart_unit, CART_ONESHOT); |
| 122 | +} |
| 123 | + |
| 124 | +static t_stat cart_svc(UNIT *uptr) |
| 125 | +{ |
| 126 | + sim_debug(DEBUG_DETAIL, &cart_dev, "One shot expired."); |
| 127 | + cart_off (CART_GRN); |
| 128 | + cart_on (CART_GRN << 1); |
| 129 | + return SCPE_OK; |
| 130 | +} |
| 131 | + |
| 132 | +t_stat cart_devio(uint32 dev, uint64 *data) |
| 133 | +{ |
| 134 | + uint64 bits; |
| 135 | + |
| 136 | + switch(dev & 07) { |
| 137 | + case CONO|4: |
| 138 | + bits = *data; |
| 139 | + sim_debug(DEBUG_CONO, &cart_dev, "%06llo", bits); |
| 140 | + if (bits & CART_GRN) |
| 141 | + cart_oneshot (); |
| 142 | + bits &= CART_MASK; |
| 143 | + if (*data & CART_OFF) |
| 144 | + cart_off (bits); |
| 145 | + else |
| 146 | + cart_on (bits); |
| 147 | + break; |
| 148 | + case CONI|4: |
| 149 | + *data = cart_bits & CART_MASK; |
| 150 | + break; |
| 151 | + /* This device doesn't respond to DATAI/O. */ |
| 152 | + } |
| 153 | + |
| 154 | + return SCPE_OK; |
| 155 | +} |
| 156 | + |
| 157 | +static t_stat cart_reset (DEVICE *dptr) |
| 158 | +{ |
| 159 | + if (sim_switches & SWMASK('P')) |
| 160 | + cart_bits = 0; |
| 161 | + return SCPE_OK; |
| 162 | +} |
| 163 | + |
| 164 | +const char *cart_description (DEVICE *dptr) |
| 165 | +{ |
| 166 | + return "Stanford cart"; |
| 167 | +} |
| 168 | +#endif |
0 commit comments