Previous 199869 Revisions Next

r23735 Sunday 16th June, 2013 at 07:52:52 UTC by Fabio Priuli
(MESS) nes.c: added emulation of the FC Family Trainer controller,
to be enabled in Expansion Port through the Driver Configuration
submenu, and mapped by default like the Power Pad. [Fabio Priuli]
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c

trunk/src/mess/drivers/nes.c
r23734r23735
544544   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("P1 Mahjong Start") PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
545545INPUT_PORTS_END
546546
547// these are read differently than the powerpad inputs, but we share the tags, to reduce
548static 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)
589INPUT_PORTS_END
590
591
592
547593static INPUT_PORTS_START( famicom )
548594   PORT_INCLUDE( fc_pads12 )
549595   PORT_INCLUDE( fc_pads34 )
r23734r23735
557603   PORT_INCLUDE( fc_keyboard )
558604   PORT_INCLUDE( subor_keyboard )
559605   PORT_INCLUDE( mahjong_panel )
606   PORT_INCLUDE( fc_ftrainer )
560607
561608   PORT_START("CTRLSEL")
562609   PORT_CONFNAME( 0x000f, 0x0001, "P1 Controller")
r23734r23735
582629   PORT_CONFSETTING(  0x02, "FC Keyboard" )
583630   PORT_CONFSETTING(  0x03, "Subor Keyboard" )
584631   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" )
588636
589637   PORT_START("CONFIG")
590638   PORT_CONFNAME( 0x01, 0x00, "Draw Top/Bottom 8 Lines")
trunk/src/mess/machine/nes.c
r23734r23735
7979   save_item(NAME(m_fck_scan));
8080   save_item(NAME(m_fck_mode));
8181   save_item(NAME(m_mic_obstruct));
82   save_item(NAME(m_powerpad_latch));
83   save_item(NAME(m_ftrainer_scan));
8284}
8385
8486
r23734r23735
102104   }
103105   for (int i = 0; i < 4; i++)
104106   {
105      char str[5];
107      char str[8];
106108      sprintf(str, "PAD%i", i + 1);
107109      m_io_pad[i] = ioport(str);
108110      sprintf(str, "MAH%i", i);
109111      m_io_mahjong[i] = ioport(str);
112      sprintf(str, "FT_COL%i", i);
113      m_io_ftrainer[i] = ioport(str);
110114   }
111115
112116   m_io_ctrlsel        = ioport("CTRLSEL");
r23734r23735
427431         ret |= (m_paddle_btn_latch << 1);   // button
428432         break;
429433         
430      case 0x06:  // Mahjong Panel
434      case 0x07:  // Mahjong Panel
431435         ret |= ((m_mjpanel_latch & 0x01) << 1);
432436         m_mjpanel_latch >>= 1;
433437         break;
434438         
435      case 0x07:  // 'multitap' p3
439      case 0x08:  // 'multitap' p3
436440         ret |= ((m_pad_latch[2] & 0x01) << 1);
437441         m_pad_latch[2] >>= 1;
438442         break;
r23734r23735
504508         m_paddle_latch &= 0xff;
505509         break;
506510         
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
508534         ret |= ((m_mjpanel_latch & 0x01) << 1);
509535         m_mjpanel_latch >>= 1;
510536         break;
511537         
512      case 0x07:  // 'multitap' p4
538      case 0x08:  // 'multitap' p4
513539         ret |= ((m_pad_latch[3] & 0x01) << 1);
514540         m_pad_latch[3] >>= 1;
515541         break;
r23734r23735
532558   // Check if lightgun has been chosen as input: if so, enable crosshair
533559   timer_set(attotime::zero, TIMER_LIGHTGUN_TICK);
534560
561   // keyboards
535562   if ((exp & 0x0f) == 0x02 || (exp & 0x0f) == 0x03)
536563   {
537564      // tape output (not fully tested)
r23734r23735
553580      }
554581   }
555582
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
556590   if (data & 0x01)
557591      return;
558592   
r23734r23735
602636   // P3 & P4 inputs in Famicom (e.g. through Hori Twin Adapter or Hori 4 Players Adapter)
603637   // are read in parallel with P1 & P2 (just using diff bits)
604638   // P3 inputs
605   if ((exp & 0x0f) == 7 && (cfg & 0x0f00) == 0x0100)
639   if ((exp & 0x0f) == 8 && (cfg & 0x0f00) == 0x0100)
606640      m_pad_latch[2] = m_io_pad[2]->read();     // pad 3
607641   
608642   // P4 inputs
609   if ((exp & 0x0f) == 7 && (cfg & 0xf000) == 0x1000)
643   if ((exp & 0x0f) == 8 && (cfg & 0xf000) == 0x1000)
610644      m_pad_latch[3] = m_io_pad[3]->read();     // pad 4
611645
612646
r23734r23735
630664         m_paddle_btn_latch = m_io_paddle_btn->read();
631665         m_paddle_latch = (UINT8) (m_io_paddle->read() ^ 0xff);
632666         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;
633674         
634      case 0x06:  // Mahjong Panel
675         
676      case 0x07:  // Mahjong Panel
635677         if (data & 0xf8)
636678            logerror("Error: Mahjong panel read with mux data %02x\n", (data & 0xfe));
637679         else
trunk/src/mess/includes/nes.h
r23734r23735
472472   ioport_port       *m_io_pad[4];
473473   ioport_port       *m_io_powerpad[2];
474474   ioport_port       *m_io_mahjong[4];
475   ioport_port       *m_io_ftrainer[3];
475476   ioport_port       *m_io_cc_left;
476477   ioport_port       *m_io_cc_right;
477478   ioport_port       *m_io_zapper1_t;
r23734r23735
561562   UINT8 m_fck_scan, m_fck_mode;
562563   UINT8 m_mic_obstruct;
563564   UINT8 m_powerpad_latch[2];
565   UINT8 m_ftrainer_scan;
564566
565567protected:
566568   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team