trunk/src/mame/drivers/twinkle.c
| r22840 | r22841 | |
| 259 | 259 | int m_output_last[ 0x100 ]; |
| 260 | 260 | int m_last_io_offset; |
| 261 | 261 | UINT8 m_sector_buffer[ 4096 ]; |
| 262 | | DECLARE_WRITE32_MEMBER(twinkle_io_w); |
| 263 | | DECLARE_READ32_MEMBER(twinkle_io_r); |
| 264 | | DECLARE_WRITE32_MEMBER(twinkle_output_w); |
| 265 | | DECLARE_WRITE32_MEMBER(serial_w); |
| 266 | | DECLARE_WRITE32_MEMBER(shared_psx_w); |
| 267 | | DECLARE_READ32_MEMBER(shared_psx_r); |
| 262 | DECLARE_WRITE8_MEMBER(twinkle_io_w); |
| 263 | DECLARE_READ8_MEMBER(twinkle_io_r); |
| 264 | DECLARE_WRITE16_MEMBER(twinkle_output_w); |
| 265 | DECLARE_WRITE16_MEMBER(serial_w); |
| 266 | DECLARE_WRITE8_MEMBER(shared_psx_w); |
| 267 | DECLARE_READ8_MEMBER(shared_psx_r); |
| 268 | 268 | DECLARE_WRITE16_MEMBER(twinkle_spu_ctrl_w); |
| 269 | 269 | DECLARE_READ16_MEMBER(twinkle_waveram_r); |
| 270 | 270 | DECLARE_WRITE16_MEMBER(twinkle_waveram_w); |
| r22840 | r22841 | |
| 440 | 440 | 0, // |
| 441 | 441 | }; |
| 442 | 442 | |
| 443 | | WRITE32_MEMBER(twinkle_state::twinkle_io_w) |
| 443 | WRITE8_MEMBER(twinkle_state::twinkle_io_w) |
| 444 | 444 | { |
| 445 | | if( ACCESSING_BITS_16_23 ) |
| 445 | switch( offset ) |
| 446 | 446 | { |
| 447 | | m_io_offset = ( data >> 16 ) & 0xff; |
| 448 | | } |
| 449 | | if( ACCESSING_BITS_0_7 ) |
| 450 | | { |
| 451 | | if( m_output_last[ m_io_offset ] != ( data & 0xff ) ) |
| 447 | case 0: |
| 448 | if( m_output_last[ m_io_offset ] != data ) |
| 452 | 449 | { |
| 453 | | m_output_last[ m_io_offset ] = ( data & 0xff ); |
| 450 | m_output_last[ m_io_offset ] = data; |
| 454 | 451 | |
| 455 | 452 | switch( m_io_offset ) |
| 456 | 453 | { |
| r22840 | r22841 | |
| 492 | 489 | |
| 493 | 490 | if( ( data & 0xfe ) != 0xfe ) |
| 494 | 491 | { |
| 495 | | printf("%02x = %02x\n", m_io_offset, data & 0xff ); |
| 492 | printf("%02x = %02x\n", m_io_offset, data ); |
| 496 | 493 | } |
| 497 | 494 | break; |
| 498 | 495 | |
| 499 | 496 | default: |
| 500 | | printf( "unknown io %02x = %02x\n", m_io_offset, data & 0xff ); |
| 497 | printf( "unknown io %02x = %02x\n", m_io_offset, data ); |
| 501 | 498 | break; |
| 502 | 499 | } |
| 503 | 500 | } |
| 501 | break; |
| 502 | |
| 503 | case 1: |
| 504 | m_io_offset = data; |
| 505 | break; |
| 504 | 506 | } |
| 505 | 507 | } |
| 506 | 508 | |
| 507 | | READ32_MEMBER(twinkle_state::twinkle_io_r) |
| 509 | READ8_MEMBER(twinkle_state::twinkle_io_r) |
| 508 | 510 | { |
| 509 | | UINT32 data = 0; |
| 511 | UINT8 data = 0; |
| 510 | 512 | |
| 511 | | if( ACCESSING_BITS_0_7 ) |
| 513 | switch( offset ) |
| 512 | 514 | { |
| 515 | case 0: |
| 513 | 516 | switch( m_io_offset ) |
| 514 | 517 | { |
| 515 | 518 | case 0x07: |
| 516 | | data |= ioport( "IN0" )->read(); |
| 519 | data = ioport( "IN0" )->read(); |
| 517 | 520 | break; |
| 518 | 521 | |
| 519 | 522 | case 0x0f: |
| 520 | | data |= ioport( "IN1" )->read(); |
| 523 | data = ioport( "IN1" )->read(); |
| 521 | 524 | break; |
| 522 | 525 | |
| 523 | 526 | case 0x17: |
| 524 | | data |= ioport( "IN2" )->read(); |
| 527 | data = ioport( "IN2" )->read(); |
| 525 | 528 | break; |
| 526 | 529 | |
| 527 | 530 | case 0x1f: |
| 528 | | data |= ioport( "IN3" )->read(); |
| 531 | data = ioport( "IN3" )->read(); |
| 529 | 532 | break; |
| 530 | 533 | |
| 531 | 534 | case 0x27: |
| 532 | | data |= ioport( "IN4" )->read(); |
| 535 | data = ioport( "IN4" )->read(); |
| 533 | 536 | break; |
| 534 | 537 | |
| 535 | 538 | case 0x2f: |
| 536 | | data |= ioport( "IN5" )->read(); |
| 539 | data = ioport( "IN5" )->read(); |
| 537 | 540 | break; |
| 538 | 541 | |
| 539 | 542 | default: |
| r22840 | r22841 | |
| 541 | 544 | { |
| 542 | 545 | m_last_io_offset = m_io_offset; |
| 543 | 546 | } |
| 544 | | |
| 545 | 547 | break; |
| 546 | 548 | } |
| 547 | | } |
| 549 | break; |
| 548 | 550 | |
| 549 | | if( ACCESSING_BITS_8_15 ) |
| 550 | | { |
| 551 | case 1: |
| 551 | 552 | /* led status? 1100 */ |
| 553 | break; |
| 552 | 554 | } |
| 553 | 555 | |
| 554 | 556 | return data; |
| 555 | 557 | } |
| 556 | 558 | |
| 557 | | WRITE32_MEMBER(twinkle_state::twinkle_output_w) |
| 559 | WRITE16_MEMBER(twinkle_state::twinkle_output_w) |
| 558 | 560 | { |
| 559 | 561 | switch( offset ) |
| 560 | 562 | { |
| 561 | 563 | case 0x00: |
| 562 | 564 | /* offset */ |
| 563 | 565 | break; |
| 564 | | case 0x02: |
| 566 | case 0x04: |
| 565 | 567 | /* data */ |
| 566 | 568 | break; |
| 567 | | case 0x04: |
| 569 | case 0x08: |
| 568 | 570 | /* ?? */ |
| 569 | 571 | break; |
| 570 | | case 0x08: |
| 572 | case 0x10: |
| 571 | 573 | /* bit 0 = clock?? */ |
| 572 | 574 | /* bit 1 = data?? */ |
| 573 | 575 | /* bit 2 = reset?? */ |
| 574 | 576 | break; |
| 575 | | case 0x0c: |
| 577 | case 0x18: |
| 576 | 578 | /* ?? */ |
| 577 | 579 | break; |
| 578 | | case 0x15: |
| 580 | case 0x30: |
| 579 | 581 | /* ?? */ |
| 580 | 582 | break; |
| 581 | | case 0x24: |
| 583 | case 0x48: |
| 582 | 584 | /* ?? */ |
| 583 | 585 | break; |
| 584 | 586 | } |
| 585 | 587 | } |
| 586 | 588 | |
| 587 | | WRITE32_MEMBER(twinkle_state::serial_w) |
| 589 | WRITE16_MEMBER(twinkle_state::serial_w) |
| 588 | 590 | { |
| 589 | 591 | /* |
| 590 | 592 | int _do = ( data >> 4 ) & 1; |
| r22840 | r22841 | |
| 595 | 597 | */ |
| 596 | 598 | } |
| 597 | 599 | |
| 598 | | WRITE32_MEMBER(twinkle_state::shared_psx_w) |
| 600 | WRITE8_MEMBER(twinkle_state::shared_psx_w) |
| 599 | 601 | { |
| 600 | | if (mem_mask == 0xff) |
| 601 | | { |
| 602 | | m_spu_shared[offset*2] = data; |
| 603 | | // printf("shared_psx_w: %x to %x (%x), mask %x (PC=%x)\n", data, offset, offset*2, mem_mask, space.device().safe_pc()); |
| 604 | | } |
| 605 | | else if (mem_mask == 0xff0000) |
| 606 | | { |
| 607 | | m_spu_shared[(offset*2)+1] = data; |
| 608 | | // printf("shared_psx_w: %x to %x (%x), mask %x (PC=%x)\n", data, offset, (offset*2)+1, mem_mask, space.device().safe_pc()); |
| 609 | | } |
| 610 | | else |
| 611 | | { |
| 612 | | fatalerror("shared_psx_w: Unknown mask %x\n", mem_mask); |
| 613 | | } |
| 602 | m_spu_shared[offset] = data; |
| 603 | // printf("shared_psx_w: %x to %x, mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc()); |
| 614 | 604 | } |
| 615 | 605 | |
| 616 | | READ32_MEMBER(twinkle_state::shared_psx_r) |
| 606 | READ8_MEMBER(twinkle_state::shared_psx_r) |
| 617 | 607 | { |
| 618 | | UINT32 result; |
| 608 | UINT32 result = m_spu_shared[offset]; |
| 619 | 609 | |
| 620 | | result = m_spu_shared[offset*2] | m_spu_shared[(offset*2)+1]<<16; |
| 610 | // printf("shared_psx_r: @ %x, mask %x (PC=%x)\n", offset, mem_mask, result, space.device().safe_pc()); |
| 621 | 611 | |
| 622 | | // printf("shared_psx_r: @ %x (%x %x), mask %x = %x (PC=%x)\n", offset, offset*2, (offset*2)+1, mem_mask, result, space.device().safe_pc()); |
| 623 | | |
| 624 | 612 | result = 0; // HACK to prevent the games from freezing while we sort out the rest of the 68k's boot sequence |
| 625 | 613 | |
| 626 | 614 | return result; |
| 627 | 615 | } |
| 628 | 616 | |
| 629 | 617 | static ADDRESS_MAP_START( main_map, AS_PROGRAM, 32, twinkle_state ) |
| 630 | | AM_RANGE(0x1f000000, 0x1f0007ff) AM_READWRITE(shared_psx_r, shared_psx_w) |
| 618 | AM_RANGE(0x1f000000, 0x1f0007ff) AM_READWRITE8(shared_psx_r, shared_psx_w, 0x00ff00ff) |
| 631 | 619 | AM_RANGE(0x1f200000, 0x1f20001f) AM_DEVREADWRITE8("scsi:am53cf96", am53cf96_device, read, write, 0x00ff00ff) |
| 632 | 620 | AM_RANGE(0x1f20a01c, 0x1f20a01f) AM_WRITENOP /* scsi? */ |
| 633 | 621 | AM_RANGE(0x1f210400, 0x1f2107ff) AM_READNOP |
| 634 | | AM_RANGE(0x1f218000, 0x1f218003) AM_WRITE(watchdog_reset32_w) /* LTC1232 */ |
| 635 | | AM_RANGE(0x1f220000, 0x1f220003) AM_WRITE(twinkle_io_w) |
| 636 | | AM_RANGE(0x1f220004, 0x1f220007) AM_READ(twinkle_io_r) |
| 622 | AM_RANGE(0x1f218000, 0x1f218003) AM_WRITE8(watchdog_reset_w, 0x000000ff) /* LTC1232 */ |
| 623 | AM_RANGE(0x1f220000, 0x1f220003) AM_WRITE8(twinkle_io_w, 0x00ff00ff) |
| 624 | AM_RANGE(0x1f220004, 0x1f220007) AM_READ8(twinkle_io_r, 0x00ff00ff) |
| 637 | 625 | AM_RANGE(0x1f230000, 0x1f230003) AM_WRITENOP |
| 638 | 626 | AM_RANGE(0x1f240000, 0x1f240003) AM_READ_PORT("IN6") |
| 639 | 627 | AM_RANGE(0x1f250000, 0x1f250003) AM_WRITENOP |
| 640 | | AM_RANGE(0x1f260000, 0x1f260003) AM_WRITE(serial_w) |
| 628 | AM_RANGE(0x1f260000, 0x1f260003) AM_WRITE16(serial_w, 0x0000ffff) |
| 641 | 629 | AM_RANGE(0x1f270000, 0x1f270003) AM_WRITE_PORT("OUTSEC") |
| 642 | 630 | AM_RANGE(0x1f280000, 0x1f280003) AM_READ_PORT("INSEC") |
| 643 | 631 | AM_RANGE(0x1f290000, 0x1f29007f) AM_DEVREADWRITE8("rtc", rtc65271_device, rtc_r, rtc_w, 0x00ff00ff) |
| 644 | 632 | AM_RANGE(0x1f2a0000, 0x1f2a007f) AM_DEVREADWRITE8("rtc", rtc65271_device, xram_r, xram_w, 0x00ff00ff) |
| 645 | | AM_RANGE(0x1f2b0000, 0x1f2b00ff) AM_WRITE(twinkle_output_w) |
| 633 | AM_RANGE(0x1f2b0000, 0x1f2b00ff) AM_WRITE16(twinkle_output_w, 0xffffffff) |
| 646 | 634 | ADDRESS_MAP_END |
| 647 | 635 | |
| 648 | 636 | /* SPU board */ |