trunk/src/mess/drivers/mz2000.c
r17662 | r17663 | |
35 | 35 | { |
36 | 36 | public: |
37 | 37 | mz2000_state(const machine_config &mconfig, device_type type, const char *tag) |
38 | | : driver_device(mconfig, type, tag) { } |
| 38 | : driver_device(mconfig, type, tag), |
| 39 | m_cass(*this, CASSETTE_TAG) |
| 40 | { } |
39 | 41 | |
| 42 | required_device<cassette_image_device> m_cass; |
| 43 | |
40 | 44 | UINT8 m_ipl_enable; |
41 | 45 | UINT8 m_tvram_enable; |
42 | 46 | UINT8 m_gvram_enable; |
r17662 | r17663 | |
273 | 277 | |
274 | 278 | WRITE8_MEMBER(mz2000_state::mz2000_gvram_bank_w) |
275 | 279 | { |
276 | | |
277 | 280 | m_gvram_bank = data & 3; |
278 | 281 | } |
279 | 282 | |
r17662 | r17663 | |
563 | 566 | |
564 | 567 | static READ8_DEVICE_HANDLER( mz2000_portb_r ) |
565 | 568 | { |
| 569 | mz2000_state *state = device->machine().driver_data<mz2000_state>(); |
566 | 570 | /* |
567 | 571 | x--- ---- break key |
568 | 572 | -x-- ---- read tape data |
r17662 | r17663 | |
571 | 575 | ---- x--- end of tape reached |
572 | 576 | ---- ---x "blank" control |
573 | 577 | */ |
574 | | UINT8 res = 0xff ^ 0xe0; |
| 578 | UINT8 res = 0x80; |
575 | 579 | |
576 | | res |= ((device->machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.00) ? 0x40 : 0x00; |
577 | | res |= (((device->machine().device<cassette_image_device>(CASSETTE_TAG))->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY) ? 0x00 : 0x20; |
| 580 | res |= (state->m_cass->input() > 0.0038) ? 0x40 : 0x00; |
| 581 | res |= ((state->m_cass->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY) ? 0x00 : 0x20; |
| 582 | res |= (state->m_cass->get_position() >= state->m_cass->get_length()) ? 0x08 : 0x00; |
| 583 | res |= (device->machine().primary_screen->vblank()) ? 0x00 : 0x01; |
578 | 584 | |
579 | | popmessage("%02x",res); |
| 585 | // popmessage("%02x",res); |
580 | 586 | |
581 | 587 | return res; |
582 | 588 | } |
r17662 | r17663 | |
590 | 596 | static WRITE8_DEVICE_HANDLER( mz2000_porta_w ) |
591 | 597 | { |
592 | 598 | /* |
| 599 | TODO: it's likely to be a 0->1 transition |
593 | 600 | x--- ---- tape "APSS" |
594 | 601 | -x-- ---- tape "APLAY" |
595 | 602 | --x- ---- tape "AREW" |
r17662 | r17663 | |
599 | 606 | ---- --x- tape ff |
600 | 607 | ---- ---x tape rewind |
601 | 608 | */ |
602 | | //printf("A W %02x\n",data); |
| 609 | mz2000_state *state = device->machine().driver_data<mz2000_state>(); |
603 | 610 | |
604 | | // ... |
| 611 | if((data & 8) == 0) // stop |
| 612 | { |
| 613 | state->m_cass->change_state(CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 614 | state->m_cass->change_state(CASSETTE_STOPPED,CASSETTE_MASK_UISTATE); |
| 615 | } |
| 616 | if((data & 4) == 0) // play |
| 617 | { |
| 618 | state->m_cass->change_state(CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 619 | state->m_cass->change_state(CASSETTE_PLAY,CASSETTE_MASK_UISTATE); |
| 620 | } |
605 | 621 | } |
606 | 622 | |
607 | 623 | static WRITE8_DEVICE_HANDLER( mz2000_portb_w ) |
608 | 624 | { |
609 | | printf("B W %02x\n",data); |
| 625 | //printf("B W %02x\n",data); |
610 | 626 | |
611 | 627 | // ... |
612 | 628 | } |
r17662 | r17663 | |
623 | 639 | ---- -x-- beeper state |
624 | 640 | ---- --x- 0->1 transition = Work RAM reset |
625 | 641 | */ |
626 | | printf("C W %02x\n",data); |
| 642 | //printf("C W %02x\n",data); |
627 | 643 | |
628 | 644 | if(((state->m_old_portc & 8) == 0) && data & 8) |
629 | 645 | state->m_ipl_enable = 1; |
r17662 | r17663 | |
762 | 778 | |
763 | 779 | static MACHINE_CONFIG_START( mz2000, mz2000_state ) |
764 | 780 | /* basic machine hardware */ |
765 | | MCFG_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 781 | MCFG_CPU_ADD("maincpu",Z80, XTAL_17_73447MHz/5) /* TODO: was 4 MHz, but otherwise cassette won't work */ |
766 | 782 | MCFG_CPU_PROGRAM_MAP(mz2000_map) |
767 | 783 | MCFG_CPU_IO_MAP(mz2000_io) |
768 | 784 | |