trunk/src/mess/drivers/nes.c
r23734 | r23735 | |
544 | 544 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("P1 Mahjong Start") PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
545 | 545 | INPUT_PORTS_END |
546 | 546 | |
| 547 | // these are read differently than the powerpad inputs, but we share the tags, to reduce |
| 548 | static INPUT_PORTS_START( fc_ftrainer ) |
| 549 | // difference between the two sides is that we mirror the key mapping to match the real pad layout! |
| 550 | PORT_START("FT_COL0") |
| 551 | // side A layout |
| 552 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 553 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid1") PORT_CODE(KEYCODE_J) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 554 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 555 | // side B layout |
| 556 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 12") PORT_CODE(KEYCODE_M) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 557 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 8") PORT_CODE(KEYCODE_J) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 558 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 4") PORT_CODE(KEYCODE_U) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 559 | |
| 560 | PORT_START("FT_COL1") |
| 561 | // side A layout |
| 562 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low1") PORT_CODE(KEYCODE_N) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 563 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid2") PORT_CODE(KEYCODE_H) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 564 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top1") PORT_CODE(KEYCODE_Y) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 565 | // side B layout |
| 566 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 11") PORT_CODE(KEYCODE_N) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 567 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 7") PORT_CODE(KEYCODE_H) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 568 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 3") PORT_CODE(KEYCODE_Y) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 569 | |
| 570 | PORT_START("FT_COL2") |
| 571 | // side A layout |
| 572 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low2") PORT_CODE(KEYCODE_B) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 573 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid3") PORT_CODE(KEYCODE_G) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 574 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top2") PORT_CODE(KEYCODE_T) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 575 | // side B layout |
| 576 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 10") PORT_CODE(KEYCODE_B) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 577 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 6") PORT_CODE(KEYCODE_G) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 578 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 2") PORT_CODE(KEYCODE_T) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 579 | |
| 580 | PORT_START("FT_COL3") |
| 581 | // side A layout |
| 582 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 583 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid4") PORT_CODE(KEYCODE_F) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 584 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05) |
| 585 | // side B layout |
| 586 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 9") PORT_CODE(KEYCODE_V) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 587 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 5") PORT_CODE(KEYCODE_F) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 588 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 1") PORT_CODE(KEYCODE_R) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06) |
| 589 | INPUT_PORTS_END |
| 590 | |
| 591 | |
| 592 | |
547 | 593 | static INPUT_PORTS_START( famicom ) |
548 | 594 | PORT_INCLUDE( fc_pads12 ) |
549 | 595 | PORT_INCLUDE( fc_pads34 ) |
r23734 | r23735 | |
557 | 603 | PORT_INCLUDE( fc_keyboard ) |
558 | 604 | PORT_INCLUDE( subor_keyboard ) |
559 | 605 | PORT_INCLUDE( mahjong_panel ) |
| 606 | PORT_INCLUDE( fc_ftrainer ) |
560 | 607 | |
561 | 608 | PORT_START("CTRLSEL") |
562 | 609 | PORT_CONFNAME( 0x000f, 0x0001, "P1 Controller") |
r23734 | r23735 | |
582 | 629 | PORT_CONFSETTING( 0x02, "FC Keyboard" ) |
583 | 630 | PORT_CONFSETTING( 0x03, "Subor Keyboard" ) |
584 | 631 | PORT_CONFSETTING( 0x04, "Arkanoid paddle" ) |
585 | | // PORT_CONFSETTING( 0x05, "Family Trainer" ) |
586 | | PORT_CONFSETTING( 0x06, "Mahjong Panel" ) |
587 | | PORT_CONFSETTING( 0x07, "Hori Twin Adapter" ) |
| 632 | PORT_CONFSETTING( 0x05, "Family Trainer (Side A)" ) |
| 633 | PORT_CONFSETTING( 0x06, "Family Trainer (Side B)" ) |
| 634 | PORT_CONFSETTING( 0x07, "Mahjong Panel" ) |
| 635 | PORT_CONFSETTING( 0x08, "Hori Twin Adapter" ) |
588 | 636 | |
589 | 637 | PORT_START("CONFIG") |
590 | 638 | PORT_CONFNAME( 0x01, 0x00, "Draw Top/Bottom 8 Lines") |
trunk/src/mess/machine/nes.c
r23734 | r23735 | |
79 | 79 | save_item(NAME(m_fck_scan)); |
80 | 80 | save_item(NAME(m_fck_mode)); |
81 | 81 | save_item(NAME(m_mic_obstruct)); |
| 82 | save_item(NAME(m_powerpad_latch)); |
| 83 | save_item(NAME(m_ftrainer_scan)); |
82 | 84 | } |
83 | 85 | |
84 | 86 | |
r23734 | r23735 | |
102 | 104 | } |
103 | 105 | for (int i = 0; i < 4; i++) |
104 | 106 | { |
105 | | char str[5]; |
| 107 | char str[8]; |
106 | 108 | sprintf(str, "PAD%i", i + 1); |
107 | 109 | m_io_pad[i] = ioport(str); |
108 | 110 | sprintf(str, "MAH%i", i); |
109 | 111 | m_io_mahjong[i] = ioport(str); |
| 112 | sprintf(str, "FT_COL%i", i); |
| 113 | m_io_ftrainer[i] = ioport(str); |
110 | 114 | } |
111 | 115 | |
112 | 116 | m_io_ctrlsel = ioport("CTRLSEL"); |
r23734 | r23735 | |
427 | 431 | ret |= (m_paddle_btn_latch << 1); // button |
428 | 432 | break; |
429 | 433 | |
430 | | case 0x06: // Mahjong Panel |
| 434 | case 0x07: // Mahjong Panel |
431 | 435 | ret |= ((m_mjpanel_latch & 0x01) << 1); |
432 | 436 | m_mjpanel_latch >>= 1; |
433 | 437 | break; |
434 | 438 | |
435 | | case 0x07: // 'multitap' p3 |
| 439 | case 0x08: // 'multitap' p3 |
436 | 440 | ret |= ((m_pad_latch[2] & 0x01) << 1); |
437 | 441 | m_pad_latch[2] >>= 1; |
438 | 442 | break; |
r23734 | r23735 | |
504 | 508 | m_paddle_latch &= 0xff; |
505 | 509 | break; |
506 | 510 | |
507 | | case 0x06: // Mahjong Panel |
| 511 | case 0x05: // family trainer |
| 512 | case 0x06: // family trainer |
| 513 | if (!BIT(m_ftrainer_scan, 0)) |
| 514 | { |
| 515 | // read low line: buttons 9,10,11,12 |
| 516 | for (int i = 0; i < 4; i++) |
| 517 | ret |= ((m_io_ftrainer[i]->read() & 0x01) << (1 + i)); |
| 518 | } |
| 519 | else if (!BIT(m_ftrainer_scan, 1)) |
| 520 | { |
| 521 | // read mid line: buttons 5,6,7,8 |
| 522 | for (int i = 0; i < 4; i++) |
| 523 | ret |= ((m_io_ftrainer[i]->read() & 0x02) << (1 + i)); |
| 524 | } |
| 525 | else if (!BIT(m_ftrainer_scan, 2)) |
| 526 | { |
| 527 | // read high line: buttons 1,2,3,4 |
| 528 | for (int i = 0; i < 4; i++) |
| 529 | ret |= ((m_io_ftrainer[i]->read() & 0x04) << (1 + i)); |
| 530 | } |
| 531 | break; |
| 532 | |
| 533 | case 0x07: // Mahjong Panel |
508 | 534 | ret |= ((m_mjpanel_latch & 0x01) << 1); |
509 | 535 | m_mjpanel_latch >>= 1; |
510 | 536 | break; |
511 | 537 | |
512 | | case 0x07: // 'multitap' p4 |
| 538 | case 0x08: // 'multitap' p4 |
513 | 539 | ret |= ((m_pad_latch[3] & 0x01) << 1); |
514 | 540 | m_pad_latch[3] >>= 1; |
515 | 541 | break; |
r23734 | r23735 | |
532 | 558 | // Check if lightgun has been chosen as input: if so, enable crosshair |
533 | 559 | timer_set(attotime::zero, TIMER_LIGHTGUN_TICK); |
534 | 560 | |
| 561 | // keyboards |
535 | 562 | if ((exp & 0x0f) == 0x02 || (exp & 0x0f) == 0x03) |
536 | 563 | { |
537 | 564 | // tape output (not fully tested) |
r23734 | r23735 | |
553 | 580 | } |
554 | 581 | } |
555 | 582 | |
| 583 | // family trainer |
| 584 | if ((exp & 0x0f) == 0x05 || (exp & 0x0f) == 0x06) |
| 585 | { |
| 586 | // select raw to scan |
| 587 | m_ftrainer_scan = data & 0x07; |
| 588 | } |
| 589 | |
556 | 590 | if (data & 0x01) |
557 | 591 | return; |
558 | 592 | |
r23734 | r23735 | |
602 | 636 | // P3 & P4 inputs in Famicom (e.g. through Hori Twin Adapter or Hori 4 Players Adapter) |
603 | 637 | // are read in parallel with P1 & P2 (just using diff bits) |
604 | 638 | // P3 inputs |
605 | | if ((exp & 0x0f) == 7 && (cfg & 0x0f00) == 0x0100) |
| 639 | if ((exp & 0x0f) == 8 && (cfg & 0x0f00) == 0x0100) |
606 | 640 | m_pad_latch[2] = m_io_pad[2]->read(); // pad 3 |
607 | 641 | |
608 | 642 | // P4 inputs |
609 | | if ((exp & 0x0f) == 7 && (cfg & 0xf000) == 0x1000) |
| 643 | if ((exp & 0x0f) == 8 && (cfg & 0xf000) == 0x1000) |
610 | 644 | m_pad_latch[3] = m_io_pad[3]->read(); // pad 4 |
611 | 645 | |
612 | 646 | |
r23734 | r23735 | |
630 | 664 | m_paddle_btn_latch = m_io_paddle_btn->read(); |
631 | 665 | m_paddle_latch = (UINT8) (m_io_paddle->read() ^ 0xff); |
632 | 666 | break; |
| 667 | |
| 668 | case 0x05: // family trainer |
| 669 | case 0x06: // family trainer |
| 670 | // these are scanned differently than other devices: |
| 671 | // bit0-bit2 of writes to $4016 select the row to read |
| 672 | // from from the mat input "columns" |
| 673 | break; |
633 | 674 | |
634 | | case 0x06: // Mahjong Panel |
| 675 | |
| 676 | case 0x07: // Mahjong Panel |
635 | 677 | if (data & 0xf8) |
636 | 678 | logerror("Error: Mahjong panel read with mux data %02x\n", (data & 0xfe)); |
637 | 679 | else |