src/mess/machine/z80sti.c
| r4950 | r4951 | |
| 11 | 11 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | | - everything |
| 14 | - timers |
| 15 | - serial |
| 15 | 16 | |
| 16 | 17 | */ |
| 17 | 18 | |
| r4950 | r4951 | |
| 50 | 51 | |
| 51 | 52 | enum |
| 52 | 53 | { |
| 54 | Z80STI_REGISTER_IR_SCR = 0, |
| 55 | Z80STI_REGISTER_IR_TDDR, |
| 56 | Z80STI_REGISTER_IR_TCDR, |
| 57 | Z80STI_REGISTER_IR_AER, |
| 58 | Z80STI_REGISTER_IR_IERB, |
| 59 | Z80STI_REGISTER_IR_IERA, |
| 60 | Z80STI_REGISTER_IR_DDR, |
| 61 | Z80STI_REGISTER_IR_TCDC |
| 62 | }; |
| 63 | |
| 64 | enum |
| 65 | { |
| 53 | 66 | Z80STI_TIMER_A = 0, |
| 54 | 67 | Z80STI_TIMER_B, |
| 55 | 68 | Z80STI_TIMER_C, |
| r4950 | r4951 | |
| 57 | 70 | Z80STI_MAX_TIMERS |
| 58 | 71 | }; |
| 59 | 72 | |
| 73 | enum |
| 74 | { |
| 75 | Z80STI_IR_P0 = 0, |
| 76 | Z80STI_IR_P1, |
| 77 | Z80STI_IR_P2, |
| 78 | Z80STI_IR_P3, |
| 79 | Z80STI_IR_TD, |
| 80 | Z80STI_IR_TC, |
| 81 | Z80STI_IR_P4, |
| 82 | Z80STI_IR_P5, |
| 83 | Z80STI_IR_TB, |
| 84 | Z80STI_IR_XE, |
| 85 | Z80STI_IR_XB, |
| 86 | Z80STI_IR_RE, |
| 87 | Z80STI_IR_RB, |
| 88 | Z80STI_IR_TA, |
| 89 | Z80STI_IR_P6, |
| 90 | Z80STI_IR_P7 |
| 91 | }; |
| 92 | |
| 93 | static const int INT_LEVEL_GPIP[] = |
| 94 | { |
| 95 | Z80STI_IR_P0, Z80STI_IR_P1, Z80STI_IR_P2, Z80STI_IR_P3, Z80STI_IR_P4, Z80STI_IR_P5, Z80STI_IR_P6, Z80STI_IR_P7 |
| 96 | }; |
| 97 | |
| 98 | static const int INT_LEVEL_TIMER[] = |
| 99 | { |
| 100 | Z80STI_IR_TA, Z80STI_IR_TB, Z80STI_IR_TC, Z80STI_IR_TD |
| 101 | }; |
| 102 | |
| 103 | static const UINT8 INT_VECTOR[] = |
| 104 | { |
| 105 | 0x00, 0x01, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e |
| 106 | }; |
| 107 | |
| 108 | static const int PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 }; |
| 109 | |
| 60 | 110 | /*************************************************************************** |
| 61 | 111 | TYPE DEFINITIONS |
| 62 | 112 | ***************************************************************************/ |
| r4950 | r4951 | |
| 85 | 135 | UINT16 isr; /* interrupt in-service register */ |
| 86 | 136 | UINT16 imr; /* interrupt mask register */ |
| 87 | 137 | UINT8 pvr; /* */ |
| 138 | int int_state[16]; /* interrupt state */ |
| 88 | 139 | |
| 89 | 140 | /* timer state */ |
| 90 | | UINT8 tabc; /* */ |
| 91 | | UINT8 tcdc; /* */ |
| 141 | UINT8 tabc; /* timer A/B control register */ |
| 142 | UINT8 tcdc; /* timer C/D control register */ |
| 92 | 143 | UINT8 tdr[Z80STI_MAX_TIMERS]; /* timer data registers */ |
| 93 | 144 | UINT8 tmc[Z80STI_MAX_TIMERS]; /* timer main counters */ |
| 145 | int to[Z80STI_MAX_TIMERS]; /* timer out latch */ |
| 94 | 146 | |
| 95 | 147 | /* serial state */ |
| 96 | 148 | UINT8 scr; /* synchronous character register */ |
| r4950 | r4951 | |
| 139 | 191 | check_interrupts - set the interrupt request |
| 140 | 192 | line state |
| 141 | 193 | -------------------------------------------------*/ |
| 142 | | #ifdef UNUSED_CODE |
| 143 | | static void check_interrupts(const device_config *device) |
| 194 | |
| 195 | static void check_interrupts(z80sti_t *z80sti) |
| 144 | 196 | { |
| 145 | | z80sti_t *z80sti = get_safe_token(device); |
| 146 | | |
| 147 | 197 | if (z80sti->ipr & z80sti->imr) |
| 148 | 198 | { |
| 149 | 199 | devcb_call_write_line(&z80sti->out_int_func, ASSERT_LINE); |
| r4950 | r4951 | |
| 158 | 208 | take_interrupt - mark an interrupt pending |
| 159 | 209 | -------------------------------------------------*/ |
| 160 | 210 | |
| 161 | | static void take_interrupt(const device_config *device, UINT16 mask) |
| 211 | static void take_interrupt(z80sti_t *z80sti, int level) |
| 162 | 212 | { |
| 163 | | z80sti_t *z80sti = get_safe_token(device); |
| 213 | z80sti->ipr |= 1 << level; |
| 164 | 214 | |
| 165 | | z80sti->ipr |= mask; |
| 215 | /* trigger interrupt */ |
| 216 | z80sti->int_state[level] |= Z80_DAISY_INT; |
| 166 | 217 | |
| 167 | | check_interrupts(device); |
| 218 | check_interrupts(z80sti); |
| 168 | 219 | } |
| 169 | | #endif |
| 220 | |
| 170 | 221 | /*------------------------------------------------- |
| 171 | 222 | serial_receive - receive serial bit |
| 172 | 223 | -------------------------------------------------*/ |
| r4950 | r4951 | |
| 213 | 264 | |
| 214 | 265 | READ8_DEVICE_HANDLER( z80sti_r ) |
| 215 | 266 | { |
| 267 | z80sti_t *z80sti = get_safe_token(device); |
| 268 | |
| 269 | switch (offset & 0x0f) |
| 270 | { |
| 271 | case Z80STI_REGISTER_IR: |
| 272 | switch (z80sti->pvr & 0x07) |
| 273 | { |
| 274 | case Z80STI_REGISTER_IR_SCR: return z80sti->scr; |
| 275 | case Z80STI_REGISTER_IR_TDDR: return z80sti->tmc[Z80STI_TIMER_D]; |
| 276 | case Z80STI_REGISTER_IR_TCDR: return z80sti->tmc[Z80STI_TIMER_C]; |
| 277 | case Z80STI_REGISTER_IR_AER: return z80sti->aer; |
| 278 | case Z80STI_REGISTER_IR_IERB: return z80sti->ier & 0xff; |
| 279 | case Z80STI_REGISTER_IR_IERA: return z80sti->ier >> 8; |
| 280 | case Z80STI_REGISTER_IR_DDR: return z80sti->ddr; |
| 281 | case Z80STI_REGISTER_IR_TCDC: return z80sti->tcdc; |
| 282 | } |
| 283 | break; |
| 284 | |
| 285 | case Z80STI_REGISTER_GPIP: z80sti->gpip = (devcb_call_read8(&z80sti->in_gpio_func, 0) & ~z80sti->ddr) | (z80sti->gpip & z80sti->ddr); return z80sti->gpip; |
| 286 | case Z80STI_REGISTER_IPRB: return z80sti->ipr & 0xff; |
| 287 | case Z80STI_REGISTER_IPRA: return z80sti->ipr >> 8; |
| 288 | case Z80STI_REGISTER_ISRB: return z80sti->isr & 0xff; |
| 289 | case Z80STI_REGISTER_ISRA: return z80sti->isr >> 8; |
| 290 | case Z80STI_REGISTER_IMRB: return z80sti->imr & 0xff; |
| 291 | case Z80STI_REGISTER_IMRA: return z80sti->imr >> 8; |
| 292 | case Z80STI_REGISTER_PVR: return z80sti->pvr; |
| 293 | case Z80STI_REGISTER_TABC: return z80sti->tabc; |
| 294 | case Z80STI_REGISTER_TBDR: return z80sti->tmc[Z80STI_TIMER_B]; |
| 295 | case Z80STI_REGISTER_TADR: return z80sti->tmc[Z80STI_TIMER_A]; |
| 296 | case Z80STI_REGISTER_UCR: return z80sti->ucr; |
| 297 | case Z80STI_REGISTER_RSR: return z80sti->rsr; |
| 298 | case Z80STI_REGISTER_TSR: return z80sti->tsr; |
| 299 | case Z80STI_REGISTER_UDR: return z80sti->udr; |
| 300 | } |
| 301 | |
| 216 | 302 | return 0; |
| 217 | 303 | } |
| 218 | 304 | |
| r4950 | r4951 | |
| 222 | 308 | |
| 223 | 309 | WRITE8_DEVICE_HANDLER( z80sti_w ) |
| 224 | 310 | { |
| 311 | z80sti_t *z80sti = get_safe_token(device); |
| 312 | |
| 313 | switch (offset & 0x0f) |
| 314 | { |
| 315 | case Z80STI_REGISTER_IR: |
| 316 | switch (z80sti->pvr & 0x07) |
| 317 | { |
| 318 | /* |
| 319 | case Z80STI_REGISTER_IR_SCR: |
| 320 | LOG(("Z80STI '%s' Sync Character Register: %x\n", device->tag, data)); |
| 321 | z80sti->scr = data; |
| 322 | break; |
| 323 | */ |
| 324 | case Z80STI_REGISTER_IR_TDDR: |
| 325 | LOG(("Z80STI '%s' Timer D Data Register: %x\n", device->tag, data)); |
| 326 | z80sti->tdr[Z80STI_TIMER_D] = data; |
| 327 | break; |
| 328 | |
| 329 | case Z80STI_REGISTER_IR_TCDR: |
| 330 | LOG(("Z80STI '%s' Timer C Data Register: %x\n", device->tag, data)); |
| 331 | z80sti->tdr[Z80STI_TIMER_C] = data; |
| 332 | break; |
| 333 | |
| 334 | case Z80STI_REGISTER_IR_AER: |
| 335 | LOG(("Z80STI '%s' Active Edge Register: %x\n", device->tag, data)); |
| 336 | z80sti->aer = data; |
| 337 | break; |
| 338 | |
| 339 | case Z80STI_REGISTER_IR_IERB: |
| 340 | LOG(("Z80STI '%s' Interrupt Enable B Register: %x\n", device->tag, data)); |
| 341 | z80sti->ier = (z80sti->ier & 0xff00) | data; |
| 342 | check_interrupts(z80sti); |
| 343 | break; |
| 344 | |
| 345 | case Z80STI_REGISTER_IR_IERA: |
| 346 | LOG(("Z80STI '%s' Interrupt Enable A Register: %x\n", device->tag, data)); |
| 347 | z80sti->ier = (data << 8) | (z80sti->ier & 0xff); |
| 348 | check_interrupts(z80sti); |
| 349 | break; |
| 350 | |
| 351 | case Z80STI_REGISTER_IR_DDR: |
| 352 | LOG(("Z80STI '%s' Data Direction Register: %x\n", device->tag, data)); |
| 353 | z80sti->ddr = data; |
| 354 | break; |
| 355 | |
| 356 | case Z80STI_REGISTER_IR_TCDC: |
| 357 | z80sti->tcdc = data; |
| 358 | break; |
| 359 | |
| 360 | default: |
| 361 | LOG(("Z80STI '%s' Unimplemented IR Register %x\n", device->tag, z80sti->pvr & 0x07)); |
| 362 | } |
| 363 | break; |
| 364 | |
| 365 | case Z80STI_REGISTER_GPIP: |
| 366 | LOG(("Z80STI '%s' General Purpose I/O Register: %x\n", device->tag, data)); |
| 367 | z80sti->gpip = data & z80sti->ddr; |
| 368 | devcb_call_write8(&z80sti->out_gpio_func, 0, z80sti->gpip); |
| 369 | break; |
| 370 | |
| 371 | case Z80STI_REGISTER_IPRB: |
| 372 | LOG(("Z80STI '%s' Interrupt Pending B Register: %x\n", device->tag, data)); |
| 373 | z80sti->ipr = (z80sti->ipr & 0xff00) | data; |
| 374 | check_interrupts(z80sti); |
| 375 | break; |
| 376 | |
| 377 | case Z80STI_REGISTER_IPRA: |
| 378 | LOG(("Z80STI '%s' Interrupt Pending A Register: %x\n", device->tag, data)); |
| 379 | z80sti->ipr = (data << 8) | (z80sti->ipr & 0xff); |
| 380 | check_interrupts(z80sti); |
| 381 | break; |
| 382 | |
| 383 | case Z80STI_REGISTER_ISRB: |
| 384 | LOG(("Z80STI '%s' Interrupt In-Service B Register: %x\n", device->tag, data)); |
| 385 | z80sti->isr = (z80sti->isr & 0xff00) | data; |
| 386 | break; |
| 387 | |
| 388 | case Z80STI_REGISTER_ISRA: |
| 389 | LOG(("Z80STI '%s' Interrupt In-Service A Register: %x\n", device->tag, data)); |
| 390 | z80sti->isr = (data << 8) | (z80sti->isr & 0xff); |
| 391 | break; |
| 392 | |
| 393 | case Z80STI_REGISTER_IMRB: |
| 394 | LOG(("Z80STI '%s' Interrupt Mask B Register: %x\n", device->tag, data)); |
| 395 | z80sti->imr = (data << 8) | (z80sti->imr & 0xff); |
| 396 | check_interrupts(z80sti); |
| 397 | break; |
| 398 | |
| 399 | case Z80STI_REGISTER_IMRA: |
| 400 | LOG(("Z80STI '%s' Interrupt Mask A Register: %x\n", device->tag, data)); |
| 401 | z80sti->imr = (data << 8) | (z80sti->imr & 0xff); |
| 402 | check_interrupts(z80sti); |
| 403 | break; |
| 404 | |
| 405 | case Z80STI_REGISTER_PVR: |
| 406 | z80sti->pvr = data; |
| 407 | break; |
| 408 | |
| 409 | case Z80STI_REGISTER_TABC: |
| 410 | z80sti->tabc = data; |
| 411 | break; |
| 412 | |
| 413 | case Z80STI_REGISTER_TBDR: |
| 414 | LOG(("Z80STI '%s' Timer B Data Register: %x\n", device->tag, data)); |
| 415 | z80sti->tdr[Z80STI_TIMER_B] = data; |
| 416 | break; |
| 417 | |
| 418 | case Z80STI_REGISTER_TADR: |
| 419 | LOG(("Z80STI '%s' Timer A Data Register: %x\n", device->tag, data)); |
| 420 | z80sti->tdr[Z80STI_TIMER_A] = data; |
| 421 | break; |
| 422 | /* |
| 423 | case Z80STI_REGISTER_UCR: |
| 424 | z80sti->ucr = data; |
| 425 | break; |
| 426 | |
| 427 | case Z80STI_REGISTER_RSR: |
| 428 | z80sti->rsr = data; |
| 429 | break; |
| 430 | |
| 431 | case Z80STI_REGISTER_TSR: |
| 432 | z80sti->tsr = data; |
| 433 | break; |
| 434 | |
| 435 | case Z80STI_REGISTER_UDR: |
| 436 | z80sti->udr = data; |
| 437 | break; |
| 438 | */ |
| 439 | default: |
| 440 | LOG(("Z80STI '%s' Unimplemented Register %x\n", device->tag, offset & 0x0f)); |
| 441 | } |
| 225 | 442 | } |
| 226 | 443 | |
| 227 | 444 | /*------------------------------------------------- |
| r4950 | r4951 | |
| 258 | 475 | |
| 259 | 476 | static void timer_count(z80sti_t *z80sti, int index) |
| 260 | 477 | { |
| 478 | if (z80sti->tmc[index] == 0x01) |
| 479 | { |
| 480 | /* toggle timer output signal */ |
| 481 | z80sti->to[index] = !z80sti->to[index]; |
| 482 | |
| 483 | switch (index) |
| 484 | { |
| 485 | case Z80STI_TIMER_A: devcb_call_write_line(&z80sti->out_tao_func, z80sti->to[index]); break; |
| 486 | case Z80STI_TIMER_B: devcb_call_write_line(&z80sti->out_tbo_func, z80sti->to[index]); break; |
| 487 | case Z80STI_TIMER_C: devcb_call_write_line(&z80sti->out_tco_func, z80sti->to[index]); break; |
| 488 | case Z80STI_TIMER_D: devcb_call_write_line(&z80sti->out_tdo_func, z80sti->to[index]); break; |
| 489 | } |
| 490 | |
| 491 | if (z80sti->ier & INT_LEVEL_TIMER[index]) |
| 492 | { |
| 493 | /* signal timer elapsed interrupt */ |
| 494 | take_interrupt(z80sti, INT_LEVEL_TIMER[index]); |
| 495 | } |
| 496 | |
| 497 | /* load main counter */ |
| 498 | z80sti->tmc[index] = z80sti->tdr[index]; |
| 499 | } |
| 500 | else |
| 501 | { |
| 502 | /* count down */ |
| 503 | z80sti->tmc[index]--; |
| 504 | } |
| 261 | 505 | } |
| 262 | 506 | |
| 263 | 507 | /*------------------------------------------------- |
| 264 | | TIMER_CALLBACK( timer_a ) |
| 508 | TIMER_CALLBACK( timer_# ) |
| 265 | 509 | -------------------------------------------------*/ |
| 266 | 510 | |
| 267 | 511 | static TIMER_CALLBACK( timer_a ) { z80sti_t *z80sti = get_safe_token(ptr); timer_count(z80sti, Z80STI_TIMER_A); } |
| r4950 | r4951 | |
| 270 | 514 | static TIMER_CALLBACK( timer_d ) { z80sti_t *z80sti = get_safe_token(ptr); timer_count(z80sti, Z80STI_TIMER_D); } |
| 271 | 515 | |
| 272 | 516 | /*------------------------------------------------- |
| 273 | | z80sti_i0_w - input 0 write |
| 517 | gpip_input - GPIP input write |
| 274 | 518 | -------------------------------------------------*/ |
| 275 | 519 | |
| 276 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ) |
| 520 | static void gpip_input(const device_config *device, int bit, int state) |
| 277 | 521 | { |
| 278 | | } |
| 522 | z80sti_t *z80sti = get_safe_token(device); |
| 279 | 523 | |
| 280 | | /*------------------------------------------------- |
| 281 | | z80sti_i1_w - input 1 write |
| 282 | | -------------------------------------------------*/ |
| 524 | int aer = BIT(z80sti->aer, bit); |
| 525 | int old_state = BIT(z80sti->gpip, bit); |
| 283 | 526 | |
| 284 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ) |
| 285 | | { |
| 286 | | } |
| 527 | if ((old_state ^ aer) && !(state ^ aer)) |
| 528 | { |
| 529 | LOG(("Z80STI '%s' Edge Transition Detected on Bit: %u\n", device->tag, bit)); |
| 287 | 530 | |
| 288 | | /*------------------------------------------------- |
| 289 | | z80sti_i2_w - input 2 write |
| 290 | | -------------------------------------------------*/ |
| 531 | if (z80sti->ier & INT_LEVEL_GPIP[bit]) |
| 532 | { |
| 533 | LOG(("Z80STI '%s' Interrupt Pending for P%u\n", device->tag, bit)); |
| 291 | 534 | |
| 292 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ) |
| 293 | | { |
| 535 | take_interrupt(z80sti, INT_LEVEL_GPIP[bit]); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | z80sti->gpip = (z80sti->gpip & ~(1 << bit)) | (state << bit); |
| 294 | 540 | } |
| 295 | 541 | |
| 296 | 542 | /*------------------------------------------------- |
| 297 | | z80sti_i3_w - input 3 write |
| 543 | z80sti_i#_w - input # write |
| 298 | 544 | -------------------------------------------------*/ |
| 299 | 545 | |
| 300 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i3_w ) |
| 301 | | { |
| 302 | | } |
| 546 | WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ) { gpip_input(device, 0, state); } |
| 547 | WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ) { gpip_input(device, 1, state); } |
| 548 | WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ) { gpip_input(device, 2, state); } |
| 549 | WRITE_LINE_DEVICE_HANDLER( z80sti_i3_w ) { gpip_input(device, 3, state); } |
| 550 | WRITE_LINE_DEVICE_HANDLER( z80sti_i4_w ) { gpip_input(device, 4, state); } |
| 551 | WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ) { gpip_input(device, 5, state); } |
| 552 | WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ) { gpip_input(device, 6, state); } |
| 553 | WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ) { gpip_input(device, 7, state); } |
| 303 | 554 | |
| 304 | 555 | /*------------------------------------------------- |
| 305 | | z80sti_i4_w - input 4 write |
| 556 | z80sti_irq_state - get interrupt status |
| 306 | 557 | -------------------------------------------------*/ |
| 307 | 558 | |
| 308 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i4_w ) |
| 559 | static int z80sti_irq_state(const device_config *device) |
| 309 | 560 | { |
| 310 | | } |
| 561 | z80sti_t *z80sti = get_safe_token(device); |
| 562 | int state = 0, i; |
| 311 | 563 | |
| 312 | | /*------------------------------------------------- |
| 313 | | z80sti_i5_w - input 5 write |
| 314 | | -------------------------------------------------*/ |
| 564 | /* loop over all interrupt sources */ |
| 565 | for (i = 15; i >= 0; i--) |
| 566 | { |
| 567 | /* if we're servicing a request, don't indicate more interrupts */ |
| 568 | if (z80sti->int_state[i] & Z80_DAISY_IEO) |
| 569 | { |
| 570 | state |= Z80_DAISY_IEO; |
| 571 | break; |
| 572 | } |
| 315 | 573 | |
| 316 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ) |
| 317 | | { |
| 574 | if (BIT(z80sti->imr, i)) |
| 575 | { |
| 576 | state |= z80sti->int_state[i]; |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | LOG(("Z80STI '%s' Interrupt State: %u\n", device->tag, state)); |
| 581 | |
| 582 | return state; |
| 318 | 583 | } |
| 319 | 584 | |
| 320 | 585 | /*------------------------------------------------- |
| 321 | | z80sti_i6_w - input 6 write |
| 586 | z80sti_irq_ack - interrupt acknowledge |
| 322 | 587 | -------------------------------------------------*/ |
| 323 | 588 | |
| 324 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ) |
| 589 | static int z80sti_irq_ack(const device_config *device) |
| 325 | 590 | { |
| 326 | | } |
| 591 | z80sti_t *z80sti = get_safe_token(device); |
| 592 | int i; |
| 327 | 593 | |
| 328 | | /*------------------------------------------------- |
| 329 | | z80sti_i7_w - input 7 write |
| 330 | | -------------------------------------------------*/ |
| 594 | /* loop over all interrupt sources */ |
| 595 | for (i = 15; i >= 0; i--) |
| 596 | { |
| 597 | /* find the first channel with an interrupt requested */ |
| 598 | if (z80sti->int_state[i] & Z80_DAISY_INT) |
| 599 | { |
| 600 | UINT8 vector = (z80sti->pvr & 0xe0) | INT_VECTOR[i]; |
| 331 | 601 | |
| 332 | | WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ) |
| 333 | | { |
| 334 | | } |
| 602 | /* clear interrupt, switch to the IEO state, and update the IRQs */ |
| 603 | z80sti->int_state[i] = Z80_DAISY_IEO; |
| 335 | 604 | |
| 336 | | /*------------------------------------------------- |
| 337 | | z80sti_irq_state - get interrupt status |
| 338 | | -------------------------------------------------*/ |
| 605 | /* clear interrupt pending register bit */ |
| 606 | z80sti->ipr = (z80sti->ipr) & ~(1 << i); |
| 339 | 607 | |
| 340 | | static int z80sti_irq_state(const device_config *device) |
| 341 | | { |
| 342 | | return 0; |
| 343 | | } |
| 608 | /* set interrupt in-service register bit */ |
| 609 | z80sti->isr |= (1 << i); |
| 610 | |
| 611 | check_interrupts(z80sti); |
| 344 | 612 | |
| 345 | | /*------------------------------------------------- |
| 346 | | z80sti_irq_ack - interrupt acknowledge |
| 347 | | -------------------------------------------------*/ |
| 613 | LOG(("Z80STI '%s' Interrupt Acknowledge Vector: %02x\n", device->tag, vector)); |
| 348 | 614 | |
| 349 | | static int z80sti_irq_ack(const device_config *device) |
| 350 | | { |
| 615 | return vector; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | logerror("z80sti_irq_ack: failed to find an interrupt to ack!\n"); |
| 620 | |
| 351 | 621 | return 0; |
| 352 | 622 | } |
| 353 | 623 | |
| r4950 | r4951 | |
| 357 | 627 | |
| 358 | 628 | static void z80sti_irq_reti(const device_config *device) |
| 359 | 629 | { |
| 630 | z80sti_t *z80sti = get_safe_token(device); |
| 631 | int i; |
| 632 | |
| 633 | LOG(("Z80STI '%s' Return from Interrupt\n", device->tag)); |
| 634 | |
| 635 | /* loop over all interrupt sources */ |
| 636 | for (i = 15; i >= 0; i--) |
| 637 | { |
| 638 | /* find the first channel with an IEO pending */ |
| 639 | if (z80sti->int_state[i] & Z80_DAISY_IEO) |
| 640 | { |
| 641 | /* clear the IEO state and update the IRQs */ |
| 642 | z80sti->int_state[i] &= ~Z80_DAISY_IEO; |
| 643 | |
| 644 | /* clear interrupt in-service register bit */ |
| 645 | z80sti->isr = z80sti->isr & ~(1 << i); |
| 646 | |
| 647 | check_interrupts(z80sti); |
| 648 | return; |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | logerror("z80sti_irq_reti: failed to find an interrupt to clear IEO on!\n"); |
| 360 | 653 | } |
| 361 | 654 | |
| 362 | 655 | /*------------------------------------------------- |
| r4950 | r4951 | |
| 408 | 701 | state_save_register_device_item(device, 0, z80sti->isr); |
| 409 | 702 | state_save_register_device_item(device, 0, z80sti->imr); |
| 410 | 703 | state_save_register_device_item(device, 0, z80sti->pvr); |
| 704 | state_save_register_device_item_array(device, 0, z80sti->int_state); |
| 411 | 705 | state_save_register_device_item(device, 0, z80sti->tabc); |
| 412 | 706 | state_save_register_device_item(device, 0, z80sti->tcdc); |
| 413 | 707 | state_save_register_device_item_array(device, 0, z80sti->tdr); |
| 414 | 708 | state_save_register_device_item_array(device, 0, z80sti->tmc); |
| 709 | state_save_register_device_item_array(device, 0, z80sti->to); |
| 415 | 710 | state_save_register_device_item(device, 0, z80sti->scr); |
| 416 | 711 | state_save_register_device_item(device, 0, z80sti->ucr); |
| 417 | 712 | state_save_register_device_item(device, 0, z80sti->rsr); |