src/mess/machine/8530scc.c
| r13736 | r13737 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "8530scc.h" |
| 12 | 12 | |
| 13 | const device_type SCC8530 = &device_creator<scc8530_t>; |
| 13 | 14 | |
| 15 | |
| 14 | 16 | /*************************************************************************** |
| 15 | 17 | PARAMETERS |
| 16 | 18 | ***************************************************************************/ |
| 17 | 19 | |
| 18 | | #define LOG_SCC (0) |
| 20 | #define LOG_SCC (1) |
| 19 | 21 | |
| 20 | | |
| 21 | | |
| 22 | 22 | /*************************************************************************** |
| 23 | | TYPE DEFINITIONS |
| 23 | IMPLEMENTATION |
| 24 | 24 | ***************************************************************************/ |
| 25 | 25 | |
| 26 | | typedef enum |
| 26 | scc8530_t::scc8530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, SCC8530, "Zilog 8530 SCC", tag, owner, clock) |
| 27 | 27 | { |
| 28 | | IRQ_NONE, |
| 29 | | IRQ_A_RX, |
| 30 | | IRQ_A_RX_SPECIAL, |
| 31 | | IRQ_B_RX, |
| 32 | | IRQ_B_RX_SPECIAL, |
| 33 | | IRQ_A_TX, |
| 34 | | IRQ_B_TX, |
| 35 | | IRQ_A_EXT, |
| 36 | | IRQ_B_EXT |
| 37 | | } SCCIRQType; |
| 38 | | |
| 39 | | typedef struct |
| 40 | | { |
| 41 | | int txIRQEnable; |
| 42 | | int rxIRQEnable; |
| 43 | | int extIRQEnable; |
| 44 | | int baudIRQEnable; |
| 45 | | int txIRQPending; |
| 46 | | int rxIRQPending; |
| 47 | | int extIRQPending; |
| 48 | | int baudIRQPending; |
| 49 | | int txEnable; |
| 50 | | int rxEnable; |
| 51 | | int txUnderrun; |
| 52 | | int txUnderrunEnable; |
| 53 | | int syncHunt; |
| 54 | | int DCDEnable; |
| 55 | | int CTSEnable; |
| 56 | | int rxData; |
| 57 | | int txData; |
| 58 | | |
| 59 | | emu_timer *baudtimer; |
| 60 | | |
| 61 | | UINT8 reg_val[16]; |
| 62 | | } sccChan; |
| 63 | | |
| 64 | | typedef struct _scc8530_t scc8530_t; |
| 65 | | struct _scc8530_t |
| 66 | | { |
| 67 | | int mode; |
| 68 | | int reg; |
| 69 | | int status; |
| 70 | | int IRQV; |
| 71 | | int MasterIRQEnable; |
| 72 | | int lastIRQStat; |
| 73 | | int clock; |
| 74 | | SCCIRQType IRQType; |
| 75 | | |
| 76 | | sccChan channel[2]; |
| 77 | | }; |
| 78 | | |
| 79 | | |
| 80 | | |
| 81 | | /*************************************************************************** |
| 82 | | INLINE FUNCTIONS |
| 83 | | ***************************************************************************/ |
| 84 | | |
| 85 | | INLINE scc8530_t *get_token(device_t *device) |
| 86 | | { |
| 87 | | assert(device != NULL); |
| 88 | | assert(device->type() == SCC8530); |
| 89 | | |
| 90 | | return (scc8530_t *) downcast<legacy_device_base *>(device)->token(); |
| 91 | 28 | } |
| 92 | 29 | |
| 93 | | |
| 94 | | INLINE const scc8530_interface *get_interface(device_t *device) |
| 30 | void scc8530_t::set_intrq_cb(intrq_cb_t cb) |
| 95 | 31 | { |
| 96 | | assert(device != NULL); |
| 97 | | assert(device->type() == SCC8530); |
| 98 | | |
| 99 | | return (const scc8530_interface *) downcast<const legacy_device_base *>(device)->inline_config(); |
| 32 | intrq_cb = cb; |
| 100 | 33 | } |
| 101 | 34 | |
| 102 | | |
| 103 | | /*************************************************************************** |
| 104 | | IMPLEMENTATION |
| 105 | | ***************************************************************************/ |
| 106 | | |
| 107 | 35 | /*------------------------------------------------- |
| 108 | 36 | scc_updateirqs |
| 109 | 37 | -------------------------------------------------*/ |
| 110 | 38 | |
| 111 | | static void scc_updateirqs(device_t *device) |
| 39 | void scc8530_t::updateirqs() |
| 112 | 40 | { |
| 113 | | scc8530_t *scc = get_token(device); |
| 114 | 41 | int irqstat; |
| 115 | 42 | |
| 116 | 43 | irqstat = 0; |
| 117 | | if (scc->MasterIRQEnable) |
| 44 | if (MasterIRQEnable) |
| 118 | 45 | { |
| 119 | | if ((scc->channel[0].txIRQEnable) && (scc->channel[0].txIRQPending)) |
| 46 | if ((channel[0].txIRQEnable) && (channel[0].txIRQPending)) |
| 120 | 47 | { |
| 121 | | scc->IRQType = IRQ_B_TX; |
| 48 | IRQType = IRQ_B_TX; |
| 122 | 49 | irqstat = 1; |
| 123 | 50 | } |
| 124 | | else if ((scc->channel[1].txIRQEnable) && (scc->channel[1].txIRQPending)) |
| 51 | else if ((channel[1].txIRQEnable) && (channel[1].txIRQPending)) |
| 125 | 52 | { |
| 126 | | scc->IRQType = IRQ_A_TX; |
| 53 | IRQType = IRQ_A_TX; |
| 127 | 54 | irqstat = 1; |
| 128 | 55 | } |
| 129 | | else if ((scc->channel[0].extIRQEnable) && (scc->channel[0].extIRQPending)) |
| 56 | else if ((channel[0].extIRQEnable) && (channel[0].extIRQPending)) |
| 130 | 57 | { |
| 131 | | scc->IRQType = IRQ_B_EXT; |
| 58 | IRQType = IRQ_B_EXT; |
| 132 | 59 | irqstat = 1; |
| 133 | 60 | } |
| 134 | | else if ((scc->channel[1].extIRQEnable) && (scc->channel[1].extIRQPending)) |
| 61 | else if ((channel[1].extIRQEnable) && (channel[1].extIRQPending)) |
| 135 | 62 | { |
| 136 | | scc->IRQType = IRQ_A_EXT; |
| 63 | IRQType = IRQ_A_EXT; |
| 137 | 64 | irqstat = 1; |
| 138 | 65 | } |
| 139 | 66 | } |
| 140 | 67 | else |
| 141 | 68 | { |
| 142 | | scc->IRQType = IRQ_NONE; |
| 69 | IRQType = IRQ_NONE; |
| 143 | 70 | } |
| 144 | 71 | |
| 145 | | // printf("SCC: irqstat %d, last %d\n", irqstat, scc->lastIRQStat); |
| 146 | | // printf("ch0: en %d pd %d ch1: en %d pd %d\n", scc->channel[0].txIRQEnable, scc->channel[0].txIRQPending, scc->channel[1].txIRQEnable, scc->channel[1].txIRQPending); |
| 72 | // printf("SCC: irqstat %d, last %d\n", irqstat, lastIRQStat); |
| 73 | // printf("ch0: en %d pd %d ch1: en %d pd %d\n", channel[0].txIRQEnable, channel[0].txIRQPending, channel[1].txIRQEnable, channel[1].txIRQPending); |
| 147 | 74 | |
| 148 | 75 | // don't spam the driver with unnecessary transitions |
| 149 | | if (irqstat != scc->lastIRQStat) |
| 76 | if (irqstat != lastIRQStat) |
| 150 | 77 | { |
| 151 | | const scc8530_interface *intf = get_interface(device); |
| 78 | lastIRQStat = irqstat; |
| 152 | 79 | |
| 153 | | scc->lastIRQStat = irqstat; |
| 154 | | |
| 155 | 80 | // tell the driver the new IRQ line status if possible |
| 156 | | if ((intf != NULL) && (intf->irq != NULL)) |
| 157 | | { |
| 158 | | #if LOG_SCC |
| 159 | | printf("SCC8530 IRQ status => %d\n", irqstat); |
| 160 | | #endif |
| 161 | | (*intf->irq)(device, irqstat); |
| 162 | | } |
| 81 | #if LOG_SCC |
| 82 | printf("SCC8530 IRQ status => %d\n", irqstat); |
| 83 | #endif |
| 84 | if(!intrq_cb.isnull()) |
| 85 | intrq_cb(irqstat); |
| 163 | 86 | } |
| 164 | 87 | } |
| 165 | 88 | |
| 166 | 89 | /*------------------------------------------------- |
| 167 | 90 | scc_initchannel |
| 168 | 91 | -------------------------------------------------*/ |
| 169 | | static void scc8530_initchannel(scc8530_t *scc, int ch) |
| 92 | void scc8530_t::initchannel(int ch) |
| 170 | 93 | { |
| 171 | | scc->channel[ch].syncHunt = 1; |
| 94 | channel[ch].syncHunt = 1; |
| 172 | 95 | } |
| 173 | 96 | |
| 174 | 97 | /*------------------------------------------------- |
| 175 | 98 | scc_resetchannel |
| 176 | 99 | -------------------------------------------------*/ |
| 177 | | static void scc8530_resetchannel(scc8530_t *scc, int ch) |
| 100 | void scc8530_t::resetchannel(int ch) |
| 178 | 101 | { |
| 179 | | emu_timer *timersave = scc->channel[ch].baudtimer; |
| 102 | emu_timer *timersave = channel[ch].baudtimer; |
| 180 | 103 | |
| 181 | | memset(&scc->channel[ch], 0, sizeof(sccChan)); |
| 104 | memset(&channel[ch], 0, sizeof(Chan)); |
| 182 | 105 | |
| 183 | | scc->channel[ch].txUnderrun = 1; |
| 184 | | scc->channel[ch].baudtimer = timersave; |
| 106 | channel[ch].txUnderrun = 1; |
| 107 | channel[ch].baudtimer = timersave; |
| 185 | 108 | |
| 186 | | scc->channel[ch].baudtimer->adjust(attotime::never, ch); |
| 109 | channel[ch].baudtimer->adjust(attotime::never, ch); |
| 187 | 110 | } |
| 188 | 111 | |
| 189 | 112 | /*------------------------------------------------- |
| 190 | 113 | scc8530_baud_expire - baud rate timer expiry |
| 191 | 114 | -------------------------------------------------*/ |
| 192 | 115 | |
| 193 | | static TIMER_CALLBACK( scc8530_baud_expire ) |
| 116 | void scc8530_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 194 | 117 | { |
| 195 | | device_t *device = (device_t *)ptr; |
| 196 | | scc8530_t *scc = get_token(device); |
| 197 | | sccChan *pChan = &scc->channel[param]; |
| 118 | Chan *pChan = &channel[id]; |
| 198 | 119 | int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14]; |
| 199 | 120 | int rate; |
| 200 | 121 | |
| 201 | 122 | if (brconst) |
| 202 | 123 | { |
| 203 | | rate = scc->clock / brconst; |
| 124 | rate = clock() / brconst; |
| 204 | 125 | } |
| 205 | 126 | else |
| 206 | 127 | { |
| r13736 | r13737 | |
| 216 | 137 | { |
| 217 | 138 | pChan->extIRQPending = 1; |
| 218 | 139 | pChan->baudIRQPending = 0; |
| 219 | | scc_updateirqs(device); |
| 140 | updateirqs(); |
| 220 | 141 | } |
| 221 | 142 | } |
| 222 | 143 | |
| 223 | 144 | // reset timer according to current register values |
| 224 | 145 | if (rate) |
| 225 | 146 | { |
| 226 | | pChan->baudtimer->adjust(attotime::from_hz(rate), param, attotime::from_hz(rate)); |
| 147 | timer.adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate)); |
| 227 | 148 | } |
| 228 | 149 | else |
| 229 | 150 | { |
| 230 | | pChan->baudtimer->adjust(attotime::never, param, attotime::never); |
| 151 | timer.adjust(attotime::never, 0, attotime::never); |
| 231 | 152 | } |
| 232 | 153 | } |
| 233 | 154 | |
| r13736 | r13737 | |
| 235 | 156 | DEVICE_START( scc8530 ) |
| 236 | 157 | -------------------------------------------------*/ |
| 237 | 158 | |
| 238 | | static DEVICE_START( scc8530 ) |
| 159 | void scc8530_t::device_start() |
| 239 | 160 | { |
| 240 | | scc8530_t *scc = get_token(device); |
| 241 | | memset(scc, 0, sizeof(*scc)); |
| 242 | | scc->clock = device->clock(); |
| 161 | memset(channel, 0, sizeof(channel)); |
| 243 | 162 | |
| 244 | | scc->channel[0].baudtimer = device->machine().scheduler().timer_alloc(FUNC(scc8530_baud_expire), (void *)device); |
| 245 | | scc->channel[1].baudtimer = device->machine().scheduler().timer_alloc(FUNC(scc8530_baud_expire), (void *)device); |
| 163 | mode = 0; |
| 164 | reg = 0; |
| 165 | status = 0; |
| 166 | IRQV = 0; |
| 167 | MasterIRQEnable = 0; |
| 168 | lastIRQStat = 0; |
| 169 | IRQType = IRQ_NONE; |
| 170 | |
| 171 | channel[0].baudtimer = timer_alloc(0); |
| 172 | channel[1].baudtimer = timer_alloc(1); |
| 246 | 173 | } |
| 247 | 174 | |
| 248 | 175 | |
| 249 | 176 | /*------------------------------------------------- |
| 250 | 177 | DEVICE_RESET( scc8530 ) |
| 251 | 178 | -------------------------------------------------*/ |
| 252 | | static DEVICE_RESET( scc8530 ) |
| 179 | void scc8530_t::device_reset() |
| 253 | 180 | { |
| 254 | | scc8530_t *scc = get_token(device); |
| 181 | IRQType = IRQ_NONE; |
| 182 | MasterIRQEnable = 0; |
| 183 | IRQV = 0; |
| 255 | 184 | |
| 256 | | scc->IRQType = IRQ_NONE; |
| 257 | | scc->MasterIRQEnable = 0; |
| 258 | | scc->IRQV = 0; |
| 259 | | |
| 260 | | scc8530_initchannel(scc, 0); |
| 261 | | scc8530_initchannel(scc, 1); |
| 262 | | scc8530_resetchannel(scc, 0); |
| 263 | | scc8530_resetchannel(scc, 1); |
| 185 | initchannel(0); |
| 186 | initchannel(1); |
| 187 | resetchannel(0); |
| 188 | resetchannel(1); |
| 264 | 189 | } |
| 265 | 190 | |
| 266 | 191 | /*------------------------------------------------- |
| 267 | 192 | scc_set_status |
| 268 | 193 | -------------------------------------------------*/ |
| 269 | 194 | |
| 270 | | void scc8530_set_status(device_t *device, int status) |
| 195 | void scc8530_t::set_status(int _status) |
| 271 | 196 | { |
| 272 | | scc8530_t *scc = get_token(device); |
| 273 | | scc->status = status; |
| 197 | status = _status; |
| 274 | 198 | } |
| 275 | 199 | |
| 276 | 200 | /*------------------------------------------------- |
| 277 | 201 | scc_acknowledge |
| 278 | 202 | -------------------------------------------------*/ |
| 279 | 203 | |
| 280 | | static void scc_acknowledge(device_t *device) |
| 204 | void scc8530_t::acknowledge() |
| 281 | 205 | { |
| 282 | | const scc8530_interface *intf = get_interface(device); |
| 283 | | if ((intf != NULL) && (intf->irq != NULL)) |
| 284 | | (*intf->irq)(device, 0); |
| 206 | if(!intrq_cb.isnull()) |
| 207 | intrq_cb(0); |
| 285 | 208 | } |
| 286 | 209 | |
| 287 | 210 | /*------------------------------------------------- |
| 288 | 211 | scc_getareg |
| 289 | 212 | -------------------------------------------------*/ |
| 290 | 213 | |
| 291 | | static int scc_getareg(device_t *device) |
| 214 | UINT8 scc8530_t::getareg() |
| 292 | 215 | { |
| 293 | | scc8530_t *scc = get_token(device); |
| 294 | | |
| 295 | 216 | /* Not yet implemented */ |
| 296 | 217 | #if LOG_SCC |
| 297 | | printf("SCC: port A reg %d read 0x%02x\n", scc->reg, scc->channel[0].reg_val[scc->reg]); |
| 218 | printf("SCC: port A reg %d read 0x%02x\n", reg, channel[0].reg_val[reg]); |
| 298 | 219 | #endif |
| 299 | 220 | |
| 300 | | if (scc->reg == 0) |
| 221 | if (reg == 0) |
| 301 | 222 | { |
| 302 | | UINT8 rv = 0; |
| 223 | UINT8 rv = 5; // TX buffer empty, RX available |
| 303 | 224 | |
| 304 | | sccChan *ourCh = &scc->channel[0]; |
| 225 | Chan *ourCh = &channel[0]; |
| 305 | 226 | |
| 306 | 227 | rv |= (ourCh->txUnderrun) ? 0x40 : 0; |
| 307 | 228 | rv |= (ourCh->syncHunt) ? 0x10 : 0; |
| 308 | 229 | |
| 309 | 230 | return rv; |
| 310 | 231 | } |
| 311 | | else if (scc->reg == 10) |
| 232 | else if (reg == 10) |
| 312 | 233 | { |
| 313 | 234 | return 0; |
| 314 | 235 | } |
| 315 | | return scc->channel[0].reg_val[scc->reg]; |
| 236 | return channel[0].reg_val[reg]; |
| 316 | 237 | } |
| 317 | 238 | |
| 318 | 239 | |
| r13736 | r13737 | |
| 321 | 242 | scc_getareg |
| 322 | 243 | -------------------------------------------------*/ |
| 323 | 244 | |
| 324 | | static int scc_getbreg(device_t *device) |
| 245 | UINT8 scc8530_t::getbreg() |
| 325 | 246 | { |
| 326 | | scc8530_t *scc = get_token(device); |
| 327 | | |
| 328 | 247 | #if LOG_SCC |
| 329 | | printf("SCC: port B reg %i read 0x%02x\n", scc->reg, scc->channel[1].reg_val[scc->reg]); |
| 248 | printf("SCC: port B reg %i read 0x%02x\n", reg, channel[1].reg_val[reg]); |
| 330 | 249 | #endif |
| 331 | 250 | |
| 332 | | if (scc->reg == 0) |
| 251 | if (reg == 0) |
| 333 | 252 | { |
| 334 | | UINT8 rv = 0; |
| 253 | UINT8 rv = 5; // TX buffer empty, RX available |
| 335 | 254 | |
| 336 | | sccChan *ourCh = &scc->channel[1]; |
| 255 | Chan *ourCh = &channel[1]; |
| 337 | 256 | |
| 338 | 257 | rv |= (ourCh->txUnderrun) ? 0x40 : 0; |
| 339 | 258 | rv |= (ourCh->syncHunt) ? 0x10 : 0; |
| r13736 | r13737 | |
| 341 | 260 | |
| 342 | 261 | return rv; |
| 343 | 262 | } |
| 344 | | else if (scc->reg == 2) |
| 263 | else if (reg == 2) |
| 345 | 264 | { |
| 346 | 265 | /* HACK! but lets the Mac Plus mouse move again. Needs further investigation. */ |
| 347 | | scc_acknowledge(device); |
| 266 | acknowledge(); |
| 348 | 267 | |
| 349 | | return scc->status; |
| 268 | return status; |
| 350 | 269 | } |
| 351 | | else if (scc->reg == 10) |
| 270 | else if (reg == 10) |
| 352 | 271 | { |
| 353 | 272 | return 0; |
| 354 | 273 | } |
| 355 | 274 | |
| 356 | | return scc->channel[1].reg_val[scc->reg]; |
| 275 | return channel[1].reg_val[reg]; |
| 357 | 276 | } |
| 358 | 277 | |
| 359 | 278 | |
| r13736 | r13737 | |
| 362 | 281 | scc_putreg |
| 363 | 282 | -------------------------------------------------*/ |
| 364 | 283 | |
| 365 | | static void scc_putreg(device_t *device, int ch, int data) |
| 284 | void scc8530_t::putreg(int ch, UINT8 data) |
| 366 | 285 | { |
| 367 | | scc8530_t *scc = get_token(device); |
| 368 | | sccChan *pChan = &scc->channel[ch]; |
| 286 | Chan *pChan = &channel[ch]; |
| 369 | 287 | |
| 370 | | scc->channel[ch].reg_val[scc->reg] = data; |
| 288 | channel[ch].reg_val[reg] = data; |
| 371 | 289 | #if LOG_SCC |
| 372 | | printf("SCC: port %c reg %d write 0x%02x\n", 'A'+ch, scc->reg, data); |
| 290 | printf("SCC: port %c reg %d write 0x%02x\n", 'A'+ch, reg, data); |
| 373 | 291 | #endif |
| 374 | 292 | |
| 375 | | switch (scc->reg) |
| 293 | switch (reg) |
| 376 | 294 | { |
| 377 | 295 | case 0: // command register |
| 378 | 296 | switch ((data >> 3) & 7) |
| r13736 | r13737 | |
| 386 | 304 | |
| 387 | 305 | case 5: // ack Tx IRQ |
| 388 | 306 | pChan->txIRQPending = 0; |
| 389 | | scc_updateirqs(device); |
| 307 | updateirqs(); |
| 390 | 308 | break; |
| 391 | 309 | |
| 392 | 310 | case 0: // nothing |
| r13736 | r13737 | |
| 404 | 322 | pChan->extIRQEnable = (data & 1); |
| 405 | 323 | pChan->txIRQEnable = (data & 2) ? 1 : 0; |
| 406 | 324 | pChan->rxIRQEnable = (data >> 3) & 3; |
| 407 | | scc_updateirqs(device); |
| 325 | updateirqs(); |
| 408 | 326 | break; |
| 409 | 327 | |
| 410 | 328 | case 2: // IRQ vector |
| 411 | | scc->IRQV = data; |
| 329 | IRQV = data; |
| 412 | 330 | break; |
| 413 | 331 | |
| 414 | 332 | case 3: // Rx parameters and controls |
| r13736 | r13737 | |
| 432 | 350 | break; |
| 433 | 351 | |
| 434 | 352 | case 9: // master IRQ control |
| 435 | | scc->MasterIRQEnable = (data & 8) ? 1 : 0; |
| 436 | | scc_updateirqs(device); |
| 353 | MasterIRQEnable = (data & 8) ? 1 : 0; |
| 354 | updateirqs(); |
| 437 | 355 | |
| 438 | 356 | // channel reset command |
| 439 | 357 | switch ((data>>6) & 3) |
| r13736 | r13737 | |
| 442 | 360 | break; |
| 443 | 361 | |
| 444 | 362 | case 1: // reset channel B |
| 445 | | scc8530_resetchannel(scc, 0); |
| 363 | resetchannel(0); |
| 446 | 364 | break; |
| 447 | 365 | |
| 448 | 366 | case 2: // reset channel A |
| 449 | | scc8530_resetchannel(scc, 1); |
| 367 | resetchannel(1); |
| 450 | 368 | break; |
| 451 | 369 | |
| 452 | 370 | case 3: // force h/w reset (entire chip) |
| 453 | | scc->IRQType = IRQ_NONE; |
| 454 | | scc->MasterIRQEnable = 0; |
| 455 | | scc->IRQV = 0; |
| 371 | IRQType = IRQ_NONE; |
| 372 | MasterIRQEnable = 0; |
| 373 | IRQV = 0; |
| 456 | 374 | |
| 457 | | scc8530_initchannel(scc, 0); |
| 458 | | scc8530_initchannel(scc, 1); |
| 459 | | scc8530_resetchannel(scc, 0); |
| 460 | | scc8530_resetchannel(scc, 1); |
| 375 | initchannel(0); |
| 376 | initchannel(1); |
| 377 | resetchannel(0); |
| 378 | resetchannel(1); |
| 461 | 379 | |
| 462 | 380 | // make sure we stop yanking the IRQ line if we were |
| 463 | | scc_updateirqs(device); |
| 381 | updateirqs(); |
| 464 | 382 | break; |
| 465 | 383 | |
| 466 | 384 | } |
| r13736 | r13737 | |
| 476 | 394 | if (data & 0x01) // baud rate generator enable? |
| 477 | 395 | { |
| 478 | 396 | int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14]; |
| 479 | | int rate = scc->clock / brconst; |
| 397 | int rate = clock() / brconst; |
| 480 | 398 | |
| 481 | | pChan->baudtimer->adjust(attotime::from_hz(rate), ch, attotime::from_hz(rate)); |
| 399 | pChan->baudtimer->adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate)); |
| 482 | 400 | } |
| 483 | 401 | break; |
| 484 | 402 | |
| r13736 | r13737 | |
| 495 | 413 | scc8530_get_reg_a |
| 496 | 414 | -------------------------------------------------*/ |
| 497 | 415 | |
| 498 | | UINT8 scc8530_get_reg_a(device_t *device, int reg) |
| 416 | UINT8 scc8530_t::get_reg_a(int reg) |
| 499 | 417 | { |
| 500 | | scc8530_t *scc = get_token(device); |
| 501 | | return scc->channel[0].reg_val[reg]; |
| 418 | return channel[0].reg_val[reg]; |
| 502 | 419 | } |
| 503 | 420 | |
| 504 | 421 | |
| r13736 | r13737 | |
| 507 | 424 | scc8530_get_reg_b |
| 508 | 425 | -------------------------------------------------*/ |
| 509 | 426 | |
| 510 | | UINT8 scc8530_get_reg_b(device_t *device, int reg) |
| 427 | UINT8 scc8530_t::get_reg_b(int reg) |
| 511 | 428 | { |
| 512 | | scc8530_t *scc = get_token(device); |
| 513 | | return scc->channel[1].reg_val[reg]; |
| 429 | return channel[1].reg_val[reg]; |
| 514 | 430 | } |
| 515 | 431 | |
| 516 | 432 | |
| r13736 | r13737 | |
| 519 | 435 | scc8530_set_reg_a |
| 520 | 436 | -------------------------------------------------*/ |
| 521 | 437 | |
| 522 | | void scc8530_set_reg_a(device_t *device, int reg, UINT8 data) |
| 438 | void scc8530_t::set_reg_a(int reg, UINT8 data) |
| 523 | 439 | { |
| 524 | | scc8530_t *scc = get_token(device); |
| 525 | | scc->channel[0].reg_val[reg] = data; |
| 440 | channel[0].reg_val[reg] = data; |
| 526 | 441 | } |
| 527 | 442 | |
| 528 | 443 | |
| r13736 | r13737 | |
| 531 | 446 | scc8530_set_reg_a |
| 532 | 447 | -------------------------------------------------*/ |
| 533 | 448 | |
| 534 | | void scc8530_set_reg_b(device_t *device, int reg, UINT8 data) |
| 449 | void scc8530_t::set_reg_b(int reg, UINT8 data) |
| 535 | 450 | { |
| 536 | | scc8530_t *scc = get_token(device); |
| 537 | | scc->channel[1].reg_val[reg] = data; |
| 451 | channel[1].reg_val[reg] = data; |
| 538 | 452 | } |
| 539 | 453 | |
| 540 | 454 | |
| r13736 | r13737 | |
| 543 | 457 | scc8530_r |
| 544 | 458 | -------------------------------------------------*/ |
| 545 | 459 | |
| 546 | | READ8_DEVICE_HANDLER(scc8530_r) |
| 460 | READ8_MEMBER( scc8530_t::reg_r) |
| 547 | 461 | { |
| 548 | | scc8530_t *scc = get_token(device); |
| 549 | 462 | UINT8 result = 0; |
| 550 | 463 | |
| 551 | 464 | offset %= 4; |
| r13736 | r13737 | |
| 554 | 467 | { |
| 555 | 468 | case 0: |
| 556 | 469 | /* Channel B (Printer Port) Control */ |
| 557 | | if (scc->mode == 1) |
| 558 | | scc->mode = 0; |
| 470 | if (mode == 1) |
| 471 | mode = 0; |
| 559 | 472 | else |
| 560 | | scc->reg = 0; |
| 473 | reg = 0; |
| 561 | 474 | |
| 562 | | result = scc_getbreg(device); |
| 475 | result = getbreg(); |
| 563 | 476 | break; |
| 564 | 477 | |
| 565 | 478 | case 1: |
| 566 | 479 | /* Channel A (Modem Port) Control */ |
| 567 | | if (scc->mode == 1) |
| 568 | | scc->mode = 0; |
| 480 | if (mode == 1) |
| 481 | mode = 0; |
| 569 | 482 | else |
| 570 | | scc->reg = 0; |
| 483 | reg = 0; |
| 571 | 484 | |
| 572 | | result = scc_getareg(device); |
| 485 | result = getareg(); |
| 573 | 486 | break; |
| 574 | 487 | |
| 575 | 488 | case 2: |
| 576 | 489 | /* Channel B (Printer Port) Data */ |
| 577 | | return scc->channel[1].rxData; |
| 490 | return channel[1].rxData; |
| 578 | 491 | break; |
| 579 | 492 | |
| 580 | 493 | case 3: |
| 581 | 494 | /* Channel A (Modem Port) Data */ |
| 582 | | return scc->channel[0].rxData; |
| 495 | return channel[0].rxData; |
| 583 | 496 | break; |
| 584 | 497 | } |
| 585 | 498 | return result; |
| r13736 | r13737 | |
| 591 | 504 | scc8530_w |
| 592 | 505 | -------------------------------------------------*/ |
| 593 | 506 | |
| 594 | | WRITE8_DEVICE_HANDLER(scc8530_w) |
| 507 | WRITE8_MEMBER( scc8530_t::reg_w ) |
| 595 | 508 | { |
| 596 | | scc8530_t *scc = get_token(device); |
| 597 | | sccChan *pChan; |
| 509 | Chan *pChan; |
| 598 | 510 | |
| 599 | 511 | offset &= 3; |
| 600 | 512 | |
| 601 | | // printf(" mode %d data %x offset %d \n", scc->mode, data, offset); |
| 513 | // printf(" mode %d data %x offset %d \n", mode, data, offset); |
| 602 | 514 | |
| 603 | 515 | switch(offset) |
| 604 | 516 | { |
| 605 | 517 | case 0: |
| 606 | 518 | /* Channel B (Printer Port) Control */ |
| 607 | | if (scc->mode == 0) |
| 519 | if (mode == 0) |
| 608 | 520 | { |
| 609 | 521 | if((data & 0xf0) == 0) // not a reset command |
| 610 | 522 | { |
| 611 | | scc->mode = 1; |
| 612 | | scc->reg = data & 0x0f; |
| 613 | | // scc_putbreg(device, data & 0xf0); |
| 523 | mode = 1; |
| 524 | reg = data & 0x0f; |
| 525 | // putbreg(data & 0xf0); |
| 614 | 526 | } |
| 615 | 527 | else if (data == 0x10) |
| 616 | 528 | { |
| 617 | | pChan = &scc->channel[1]; |
| 529 | pChan = &channel[1]; |
| 618 | 530 | // clear ext. interrupts |
| 619 | 531 | pChan->extIRQPending = 0; |
| 620 | 532 | pChan->baudIRQPending = 0; |
| 621 | | scc_updateirqs(device); |
| 533 | updateirqs(); |
| 622 | 534 | } |
| 623 | 535 | } |
| 624 | 536 | else |
| 625 | 537 | { |
| 626 | | scc->mode = 0; |
| 627 | | scc_putreg(device, 1, data); |
| 538 | mode = 0; |
| 539 | putreg(1, data); |
| 628 | 540 | } |
| 629 | 541 | break; |
| 630 | 542 | |
| 631 | 543 | case 1: |
| 632 | 544 | /* Channel A (Modem Port) Control */ |
| 633 | | if (scc->mode == 0) |
| 545 | if (mode == 0) |
| 634 | 546 | { |
| 635 | 547 | if((data & 0xf0) == 0) // not a reset command |
| 636 | 548 | { |
| 637 | | scc->mode = 1; |
| 638 | | scc->reg = data & 0x0f; |
| 639 | | // scc_putareg(device, data & 0xf0); |
| 549 | mode = 1; |
| 550 | reg = data & 0x0f; |
| 551 | // putareg(data & 0xf0); |
| 640 | 552 | } |
| 641 | 553 | else if (data == 0x10) |
| 642 | 554 | { |
| 643 | | pChan = &scc->channel[0]; |
| 555 | pChan = &channel[0]; |
| 644 | 556 | // clear ext. interrupts |
| 645 | 557 | pChan->extIRQPending = 0; |
| 646 | 558 | pChan->baudIRQPending = 0; |
| 647 | | scc_updateirqs(device); |
| 559 | updateirqs(); |
| 648 | 560 | } |
| 649 | 561 | } |
| 650 | 562 | else |
| 651 | 563 | { |
| 652 | | scc->mode = 0; |
| 653 | | scc_putreg(device, 0, data); |
| 564 | mode = 0; |
| 565 | putreg(0, data); |
| 654 | 566 | } |
| 655 | 567 | break; |
| 656 | 568 | |
| 657 | 569 | case 2: |
| 658 | 570 | /* Channel B (Printer Port) Data */ |
| 659 | | pChan = &scc->channel[1]; |
| 571 | pChan = &channel[1]; |
| 660 | 572 | |
| 661 | 573 | if (pChan->txEnable) |
| 662 | 574 | { |
| r13736 | r13737 | |
| 671 | 583 | pChan->reg_val[0] |= 0x04; // Tx empty |
| 672 | 584 | pChan->txUnderrun = 1; |
| 673 | 585 | pChan->txIRQPending = 1; |
| 674 | | scc_updateirqs(device); |
| 586 | updateirqs(); |
| 675 | 587 | } |
| 676 | 588 | break; |
| 677 | 589 | |
| 678 | 590 | case 3: |
| 679 | 591 | /* Channel A (Modem Port) Data */ |
| 680 | | pChan = &scc->channel[0]; |
| 592 | pChan = &channel[0]; |
| 681 | 593 | |
| 682 | 594 | if (pChan->txEnable) |
| 683 | 595 | { |
| r13736 | r13737 | |
| 692 | 604 | pChan->reg_val[0] |= 0x04; // Tx empty |
| 693 | 605 | pChan->txUnderrun = 1; |
| 694 | 606 | pChan->txIRQPending = 1; |
| 695 | | scc_updateirqs(device); |
| 607 | updateirqs(); |
| 696 | 608 | } |
| 697 | 609 | break; |
| 698 | 610 | } |
| 699 | 611 | } |
| 700 | 612 | |
| 701 | | |
| 702 | | |
| 703 | | /*------------------------------------------------- |
| 704 | | DEVICE_GET_INFO( scc8530 ) |
| 705 | | -------------------------------------------------*/ |
| 706 | | |
| 707 | | DEVICE_GET_INFO( scc8530 ) |
| 708 | | { |
| 709 | | switch (state) |
| 710 | | { |
| 711 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 712 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(scc8530_t); break; |
| 713 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(scc8530_interface); break; |
| 714 | | |
| 715 | | /* --- the following bits of info are returned as pointers to functions --- */ |
| 716 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(scc8530); break; |
| 717 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 718 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(scc8530); break; |
| 719 | | |
| 720 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 721 | | case DEVINFO_STR_NAME: strcpy(info->s, "Zilog 8530 SCC"); break; |
| 722 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Zilog 8530 SCC"); break; |
| 723 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.5"); break; |
| 724 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 725 | | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 726 | | } |
| 727 | | } |
| 728 | | |
| 729 | | DEFINE_LEGACY_DEVICE(SCC8530, scc8530); |
| 730 | | |
| 731 | 613 | /* |
| 732 | 614 | |
| 733 | 615 | AppleTalk check: |
src/mess/drivers/mac.c
| r13736 | r13737 | |
| 920 | 920 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 921 | 921 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 922 | 922 | |
| 923 | | MCFG_SCC8530_ADD("scc", C7M) |
| 924 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 923 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 925 | 924 | MCFG_VIA6522_ADD("via6522_0", 1000000, mac_via6522_intf) |
| 926 | 925 | |
| 927 | 926 | /* internal ram */ |
| r13736 | r13737 | |
| 1006 | 1005 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 1007 | 1006 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1008 | 1007 | |
| 1009 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1010 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1008 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1011 | 1009 | MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_intf) |
| 1012 | 1010 | |
| 1013 | 1011 | MCFG_HARDDISK_CONFIG_ADD( "harddisk1", mac_harddisk_config ) |
| r13736 | r13737 | |
| 1053 | 1051 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 1054 | 1052 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1055 | 1053 | |
| 1056 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1057 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1054 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1058 | 1055 | |
| 1059 | 1056 | MCFG_VIA6522_ADD("via6522_0", C7M/10, mac_via6522_adb_intf) |
| 1060 | 1057 | MCFG_VIA6522_ADD("via6522_1", C7M/10, mac_via6522_2_intf) |
| r13736 | r13737 | |
| 1106 | 1103 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 1107 | 1104 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1108 | 1105 | |
| 1109 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1110 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1106 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1111 | 1107 | |
| 1112 | 1108 | MCFG_VIA6522_ADD("via6522_0", C7M/10, mac_via6522_adb_intf) |
| 1113 | 1109 | |
| r13736 | r13737 | |
| 1310 | 1306 | MCFG_SWIM_ADD("fdc", mac_iwm_interface) |
| 1311 | 1307 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1312 | 1308 | |
| 1313 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1314 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1309 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1315 | 1310 | |
| 1316 | 1311 | MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf) |
| 1317 | 1312 | MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf) |
| r13736 | r13737 | |
| 1363 | 1358 | MCFG_SWIM_ADD("fdc", mac_iwm_interface) |
| 1364 | 1359 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1365 | 1360 | |
| 1366 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1367 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1361 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1368 | 1362 | |
| 1369 | 1363 | MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf) |
| 1370 | 1364 | MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf) |
| r13736 | r13737 | |
| 1436 | 1430 | MCFG_SWIM_ADD("fdc", mac_iwm_interface) |
| 1437 | 1431 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1438 | 1432 | |
| 1439 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1440 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1433 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1441 | 1434 | |
| 1442 | 1435 | MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf) |
| 1443 | 1436 | MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf) |
| r13736 | r13737 | |
| 1612 | 1605 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 1613 | 1606 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1614 | 1607 | |
| 1615 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1616 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1608 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1617 | 1609 | |
| 1618 | 1610 | MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf) |
| 1619 | 1611 | MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf) |
| r13736 | r13737 | |
| 1662 | 1654 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 1663 | 1655 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 1664 | 1656 | |
| 1665 | | MCFG_SCC8530_ADD("scc", C7M) |
| 1666 | | MCFG_SCC8530_IRQ(mac_scc_irq) |
| 1657 | MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner))) |
| 1667 | 1658 | |
| 1668 | 1659 | MCFG_VIA6522_ADD("via6522_0", C7M/10, mac_via6522_adb_intf) |
| 1669 | 1660 | MCFG_VIA6522_ADD("via6522_1", C7M/10, mac_via6522_2_intf) |
src/mess/drivers/x68k.c
| r13736 | r13737 | |
| 538 | 538 | static int x68k_read_mouse(running_machine &machine) |
| 539 | 539 | { |
| 540 | 540 | x68k_state *state = machine.driver_data<x68k_state>(); |
| 541 | | device_t *scc = machine.device("scc"); |
| 541 | scc8530_t *scc = machine.device<scc8530_t>("scc"); |
| 542 | 542 | char val = 0; |
| 543 | 543 | char ipt = 0; |
| 544 | 544 | |
| 545 | | if(!(scc8530_get_reg_b(scc,5) & 0x02)) |
| 545 | if(!(scc->get_reg_b(5) & 0x02)) |
| 546 | 546 | return 0xff; |
| 547 | 547 | |
| 548 | 548 | switch(state->m_mouse.inputtype) |
| r13736 | r13737 | |
| 564 | 564 | state->m_mouse.inputtype++; |
| 565 | 565 | if(state->m_mouse.inputtype > 2) |
| 566 | 566 | { |
| 567 | | int i_val = scc8530_get_reg_b(scc, 0); |
| 567 | int i_val = scc->get_reg_b(0); |
| 568 | 568 | state->m_mouse.inputtype = 0; |
| 569 | 569 | state->m_mouse.bufferempty = 1; |
| 570 | 570 | i_val &= ~0x01; |
| 571 | | scc8530_set_reg_b(scc, 0, i_val); |
| 571 | scc->set_reg_b(0, i_val); |
| 572 | 572 | logerror("SCC: mouse buffer empty\n"); |
| 573 | 573 | } |
| 574 | 574 | |
| r13736 | r13737 | |
| 583 | 583 | */ |
| 584 | 584 | static READ16_HANDLER( x68k_scc_r ) |
| 585 | 585 | { |
| 586 | | device_t *scc = space->machine().device("scc"); |
| 586 | scc8530_t *scc = space->machine().device<scc8530_t>("scc"); |
| 587 | 587 | offset %= 4; |
| 588 | 588 | switch(offset) |
| 589 | 589 | { |
| 590 | 590 | case 0: |
| 591 | | return scc8530_r(scc, 0); |
| 591 | return scc->reg_r(*space, 0); |
| 592 | 592 | case 1: |
| 593 | 593 | return x68k_read_mouse(space->machine()); |
| 594 | 594 | case 2: |
| 595 | | return scc8530_r(scc, 1); |
| 595 | return scc->reg_r(*space, 1); |
| 596 | 596 | case 3: |
| 597 | | return scc8530_r(scc, 3); |
| 597 | return scc->reg_r(*space, 3); |
| 598 | 598 | default: |
| 599 | 599 | return 0xff; |
| 600 | 600 | } |
| r13736 | r13737 | |
| 603 | 603 | static WRITE16_HANDLER( x68k_scc_w ) |
| 604 | 604 | { |
| 605 | 605 | x68k_state *state = space->machine().driver_data<x68k_state>(); |
| 606 | | device_t *scc = space->machine().device("scc"); |
| 606 | scc8530_t *scc = space->machine().device<scc8530_t>("scc"); |
| 607 | 607 | offset %= 4; |
| 608 | 608 | |
| 609 | 609 | switch(offset) |
| 610 | 610 | { |
| 611 | 611 | case 0: |
| 612 | | scc8530_w(scc, 0,(UINT8)data); |
| 613 | | if((scc8530_get_reg_b(scc, 5) & 0x02) != state->m_scc_prev) |
| 612 | scc->reg_w(*space, 0,(UINT8)data); |
| 613 | if((scc->get_reg_b(5) & 0x02) != state->m_scc_prev) |
| 614 | 614 | { |
| 615 | | if(scc8530_get_reg_b(scc, 5) & 0x02) // Request to Send |
| 615 | if(scc->get_reg_b(5) & 0x02) // Request to Send |
| 616 | 616 | { |
| 617 | | int val = scc8530_get_reg_b(scc, 0); |
| 617 | int val = scc->get_reg_b(0); |
| 618 | 618 | state->m_mouse.bufferempty = 0; |
| 619 | 619 | val |= 0x01; |
| 620 | | scc8530_set_reg_b(scc, 0,val); |
| 620 | scc->set_reg_b(0,val); |
| 621 | 621 | } |
| 622 | 622 | } |
| 623 | 623 | break; |
| 624 | 624 | case 1: |
| 625 | | scc8530_w(scc, 2,(UINT8)data); |
| 625 | scc->reg_w(*space, 2,(UINT8)data); |
| 626 | 626 | break; |
| 627 | 627 | case 2: |
| 628 | | scc8530_w(scc, 1,(UINT8)data); |
| 628 | scc->reg_w(*space, 1,(UINT8)data); |
| 629 | 629 | break; |
| 630 | 630 | case 3: |
| 631 | | scc8530_w(scc, 3,(UINT8)data); |
| 631 | scc->reg_w(*space, 3,(UINT8)data); |
| 632 | 632 | break; |
| 633 | 633 | } |
| 634 | | state->m_scc_prev = scc8530_get_reg_b(scc, 5) & 0x02; |
| 634 | state->m_scc_prev = scc->get_reg_b(5) & 0x02; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | static TIMER_CALLBACK(x68k_scc_ack) |
| 638 | 638 | { |
| 639 | 639 | x68k_state *state = machine.driver_data<x68k_state>(); |
| 640 | | device_t *scc = machine.device("scc"); |
| 640 | scc8530_t *scc = machine.device<scc8530_t>("scc"); |
| 641 | 641 | if(state->m_mouse.bufferempty != 0) // nothing to do if the mouse data buffer is empty |
| 642 | 642 | return; |
| 643 | 643 | |
| r13736 | r13737 | |
| 645 | 645 | // return; |
| 646 | 646 | |
| 647 | 647 | // hard-code the IRQ vector for now, until the SCC code is more complete |
| 648 | | if((scc8530_get_reg_a(scc, 9) & 0x08) || (scc8530_get_reg_b(scc, 9) & 0x08)) // SCC reg WR9 is the same for both channels |
| 648 | if((scc->get_reg_a(9) & 0x08) || (scc->get_reg_b(9) & 0x08)) // SCC reg WR9 is the same for both channels |
| 649 | 649 | { |
| 650 | | if((scc8530_get_reg_b(scc, 1) & 0x18) != 0) // if bits 3 and 4 of WR1 are 0, then Rx IRQs are disabled on this channel |
| 650 | if((scc->get_reg_b(1) & 0x18) != 0) // if bits 3 and 4 of WR1 are 0, then Rx IRQs are disabled on this channel |
| 651 | 651 | { |
| 652 | | if(scc8530_get_reg_b(scc, 5) & 0x02) // RTS signal |
| 652 | if(scc->get_reg_b(5) & 0x02) // RTS signal |
| 653 | 653 | { |
| 654 | 654 | state->m_mouse.irqactive = 1; |
| 655 | 655 | state->m_current_vector[5] = 0x54; |
| r13736 | r13737 | |
| 2773 | 2773 | |
| 2774 | 2774 | MCFG_HD63450_ADD( "hd63450", dmac_interface ) |
| 2775 | 2775 | |
| 2776 | | MCFG_SCC8530_ADD( "scc", 5000000 ) |
| 2776 | MCFG_SCC8530_ADD( "scc", 5000000, scc8530_t::intrq_cb_t() ) |
| 2777 | 2777 | |
| 2778 | 2778 | MCFG_RP5C15_ADD(RP5C15_TAG, XTAL_32_768kHz, rtc_intf) |
| 2779 | 2779 | |
src/mess/drivers/ip20.c
| r13736 | r13737 | |
| 22 | 22 | #include "machine/8530scc.h" |
| 23 | 23 | #include "machine/sgi.h" |
| 24 | 24 | #include "machine/eeprom.h" |
| 25 | | #include "machine/8530scc.h" |
| 26 | 25 | #include "machine/wd33c93.h" |
| 27 | 26 | #include "imagedev/harddriv.h" |
| 28 | 27 | #include "imagedev/chd_cd.h" |
| r13736 | r13737 | |
| 106 | 105 | static READ32_HANDLER( hpc_r ) |
| 107 | 106 | { |
| 108 | 107 | ip20_state *state = space->machine().driver_data<ip20_state>(); |
| 109 | | device_t *scc; |
| 108 | scc8530_t *scc; |
| 110 | 109 | running_machine &machine = space->machine(); |
| 111 | 110 | |
| 112 | 111 | offset <<= 2; |
| r13736 | r13737 | |
| 165 | 164 | case 0x0d00: |
| 166 | 165 | verboselog(machine, 2, "HPC DUART0 Channel B Control Read\n" ); |
| 167 | 166 | // return 0x00000004; |
| 168 | | return 0x7c; //scc8530_r(machine, 0); |
| 167 | return 0x7c; //scc->reg_r(*space, 0); |
| 169 | 168 | case 0x0d04: |
| 170 | 169 | verboselog(machine, 2, "HPC DUART0 Channel B Data Read\n" ); |
| 171 | 170 | // return 0; |
| 172 | | scc = space->machine().device("scc"); |
| 173 | | return scc8530_r(scc, 2); |
| 171 | scc = space->machine().device<scc8530_t>("scc"); |
| 172 | return scc->reg_r(*space, 2); |
| 174 | 173 | case 0x0d08: |
| 175 | 174 | verboselog(machine, 2, "HPC DUART0 Channel A Control Read (%08x)\n", mem_mask ); |
| 176 | 175 | // return 0x40; |
| 177 | | return 0x7c; //scc8530_r(machine, 1); |
| 176 | return 0x7c; //scc->reg_r(*space, 1); |
| 178 | 177 | case 0x0d0c: |
| 179 | 178 | verboselog(machine, 2, "HPC DUART0 Channel A Data Read\n" ); |
| 180 | 179 | // return 0; |
| 181 | | scc = space->machine().device("scc"); |
| 182 | | return scc8530_r(scc, 3); |
| 180 | scc = space->machine().device<scc8530_t>("scc"); |
| 181 | return scc->reg_r(*space, 3); |
| 183 | 182 | case 0x0d10: |
| 184 | 183 | // verboselog(machine, 2, "HPC DUART1 Channel B Control Read\n" ); |
| 185 | 184 | return 0x00000004; |
| r13736 | r13737 | |
| 224 | 223 | static WRITE32_HANDLER( hpc_w ) |
| 225 | 224 | { |
| 226 | 225 | ip20_state *state = space->machine().driver_data<ip20_state>(); |
| 227 | | device_t *scc; |
| 226 | scc8530_t *scc; |
| 228 | 227 | eeprom_device *eeprom; |
| 229 | 228 | running_machine &machine = space->machine(); |
| 230 | 229 | |
| r13736 | r13737 | |
| 363 | 362 | break; |
| 364 | 363 | case 0x0d00: |
| 365 | 364 | verboselog(machine, 2, "HPC DUART0 Channel B Control Write: %08x (%08x)\n", data, mem_mask ); |
| 366 | | scc = space->machine().device("scc"); |
| 367 | | scc8530_w(scc, 0, data); |
| 365 | scc = space->machine().device<scc8530_t>("scc"); |
| 366 | scc->reg_w(*space, 0, data); |
| 368 | 367 | break; |
| 369 | 368 | case 0x0d04: |
| 370 | 369 | verboselog(machine, 2, "HPC DUART0 Channel B Data Write: %08x (%08x)\n", data, mem_mask ); |
| 371 | | scc = space->machine().device("scc"); |
| 372 | | scc8530_w(scc, 2, data); |
| 370 | scc = space->machine().device<scc8530_t>("scc"); |
| 371 | scc->reg_w(*space, 2, data); |
| 373 | 372 | break; |
| 374 | 373 | case 0x0d08: |
| 375 | 374 | verboselog(machine, 2, "HPC DUART0 Channel A Control Write: %08x (%08x)\n", data, mem_mask ); |
| 376 | | scc = space->machine().device("scc"); |
| 377 | | scc8530_w(scc, 1, data); |
| 375 | scc = space->machine().device<scc8530_t>("scc"); |
| 376 | scc->reg_w(*space, 1, data); |
| 378 | 377 | break; |
| 379 | 378 | case 0x0d0c: |
| 380 | 379 | verboselog(machine, 2, "HPC DUART0 Channel A Data Write: %08x (%08x)\n", data, mem_mask ); |
| 381 | | scc = space->machine().device("scc"); |
| 382 | | scc8530_w(scc, 3, data); |
| 380 | scc = space->machine().device<scc8530_t>("scc"); |
| 381 | scc->reg_w(*space, 3, data); |
| 383 | 382 | break; |
| 384 | 383 | case 0x0d10: |
| 385 | 384 | if( ( data & 0x000000ff ) >= 0x00000020 ) |
| r13736 | r13737 | |
| 625 | 624 | MCFG_SOUND_ADD( "cdda", CDDA, 0 ) |
| 626 | 625 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 627 | 626 | |
| 628 | | MCFG_SCC8530_ADD("scc", 7000000) |
| 627 | MCFG_SCC8530_ADD("scc", 7000000, scc8530_t::intrq_cb_t()) |
| 629 | 628 | |
| 630 | 629 | MCFG_CDROM_ADD( "cdrom",ip20_cdrom ) |
| 631 | 630 | |