Previous 15994 Revisions Next

r8382 Saturday 3rd July, 2010 at 16:25:13 UTC by Fabio Priuli
[NES] added Crazy Climber controller (default mappings for the two sticks is the same as cclimber in MAME)
[src/mess/drivers]nes.c
[src/mess/machine]nes.c

src/mess/machine/nes.c
r8381r8382
310310   int cfg = input_port_read(space->machine, "CTRLSEL");
311311   int ret;
312312
313   if ((cfg & 0x000f) >= 0x04)   // for now we treat the FC keyboard separately from other inputs!
313   if ((cfg & 0x000f) >= 0x07)   // for now we treat the FC keyboard separately from other inputs!
314314   {
315315      // here we should have the tape input
316316      ret = 0;
r8381r8382
378378   int cfg = input_port_read(space->machine, "CTRLSEL");
379379   int ret;
380380
381   if ((cfg & 0x000f) == 0x04)   // for now we treat the FC keyboard separately from other inputs!
381   if ((cfg & 0x000f) == 0x07)   // for now we treat the FC keyboard separately from other inputs!
382382   {
383383      if (state->fck_scan < 9)
384384         ret = ~nes_read_fc_keyboard_line(space->machine, state->fck_scan, state->fck_mode) & 0x1e;
r8381r8382
449449}
450450
451451
452
453static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port, int supports_zapper, int paddle_port )
452// FIXME: this is getting messier and messier (no pun intended). inputs reading should be simplified and port_categories cleaned up
453// to also emulate the fact that nothing should be in Port 2 if there is a Crazy Climber pad, etc.
454static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port, int supports_zapper )
454455{
455   static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4" };
456
456   nes_state *state = (nes_state *)machine->driver_data;
457   static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4", "CC_LEFT", "CC_RIGHT" };
458   
457459   vals->i0 = 0;
458460   vals->i1 = 0;
459461   vals->i2 = 0;
460
461   switch(cfg & 0x0f)
462   
463   switch (cfg & 0x0f)
462464   {
463465      case 0x01:   /* gamepad */
464466         if (pad_port >= 0)
465467            vals->i0 = input_port_read(machine, padnames[pad_port]);
466468         break;
467
469         
468470      case 0x02:   /* zapper 1 */
469471         if (supports_zapper)
470472         {
r8381r8382
473475            vals->i2 = input_port_read(machine, "ZAPPER1_Y");
474476         }
475477         break;
476
478         
477479      case 0x03:   /* zapper 2 */
478480         if (supports_zapper)
479481         {
r8381r8382
482484            vals->i2 = input_port_read(machine, "ZAPPER2_Y");
483485         }
484486         break;
485
487         
486488      case 0x04:   /* arkanoid paddle */
487         if (paddle_port >= 0)
489         if (pad_port == 1)
488490            vals->i0 = (UINT8) ((UINT8) input_port_read(machine, "PADDLE") + (UINT8)0x52) ^ 0xff;
489491         break;
492         
493      case 0x05:   /* crazy climber controller */
494         if (pad_port == 0)
495         {
496            state->in_0.i0 = input_port_read(machine, padnames[4]);
497            state->in_1.i0 = input_port_read(machine, padnames[5]);
498         }
499         break;
490500   }
491501}
492502
r8381r8382
524534   /* Check if lightgun has been chosen as input: if so, enable crosshair */
525535   timer_set(space->machine, attotime_zero, NULL, 0, lightgun_tick);
526536
527   if ((cfg & 0x000f) >= 0x04)   // for now we treat the FC keyboard separately from other inputs!
537   if ((cfg & 0x000f) >= 0x07)   // for now we treat the FC keyboard separately from other inputs!
528538   {
529539      // here we should also have the tape output
530540
r8381r8382
546556   {
547557      if (data & 0x01)
548558         return;
549
559     
550560      if (LOG_JOY)
551561         logerror("joy 0 bits read: %d\n", state->in_0.shift);
552
562     
553563      /* Toggling bit 0 high then low resets both controllers */
554564      state->in_0.shift = 0;
555565      state->in_1.shift = 0;
556
566     
557567      /* Read the input devices */
558      nes_read_input_device(space->machine, cfg >>  0, &state->in_0, 0,  TRUE, -1);
559      nes_read_input_device(space->machine, cfg >>  4, &state->in_1, 1,  TRUE,  1);
560      nes_read_input_device(space->machine, cfg >>  8, &state->in_2, 2, FALSE, -1);
561      nes_read_input_device(space->machine, cfg >> 12, &state->in_3, 3, FALSE, -1);
562
568      if ((cfg & 0x000f) != 0x06)
569      {
570         nes_read_input_device(space->machine, cfg >>  0, &state->in_0, 0,  TRUE);
571         nes_read_input_device(space->machine, cfg >>  4, &state->in_1, 1,  TRUE);
572         nes_read_input_device(space->machine, cfg >>  8, &state->in_2, 2, FALSE);
573         nes_read_input_device(space->machine, cfg >> 12, &state->in_3, 3, FALSE);
574      }
575      else // crazy climber pad
576      {
577         nes_read_input_device(space->machine, 0, &state->in_1, 1,  TRUE);
578         nes_read_input_device(space->machine, 0, &state->in_2, 2, FALSE);
579         nes_read_input_device(space->machine, 0, &state->in_3, 3, FALSE);
580         nes_read_input_device(space->machine, cfg >>  0, &state->in_0, 0,  TRUE);
581      }
582     
563583      if (cfg & 0x0f00)
564584         state->in_0.i0 |= (state->in_2.i0 << 8) | (0x08 << 16);
565
585     
566586      if (cfg & 0xf000)
567587         state->in_1.i0 |= (state->in_3.i0 << 8) | (0x04 << 16);
568588   }
src/mess/drivers/nes.c
r8381r8382
6161   PORT_CATEGORY_ITEM(  0x0000, "Unconnected",      0 )
6262   PORT_CATEGORY_ITEM(  0x0001, "Gamepad",         1 )
6363   PORT_CATEGORY_ITEM(  0x0002, "Zapper",         5 )
64   PORT_CATEGORY_ITEM(  0x0006, "Crazy Climber pad", 10 )
6465   PORT_CATEGORY_CLASS( 0x00f0, 0x0010, "P2 Controller")
6566   PORT_CATEGORY_ITEM(  0x0000, "Unconnected",      0 )
6667   PORT_CATEGORY_ITEM(  0x0010, "Gamepad",         2 )
6768   PORT_CATEGORY_ITEM(  0x0030, "Zapper",         6 )
6869   PORT_CATEGORY_ITEM(  0x0040, "Arkanoid paddle",   7 )
70//   PORT_CATEGORY_ITEM(  0x0050, "Family Trainer",  11 )
6971   PORT_CATEGORY_CLASS( 0x0f00, 0x0000, "P3 Controller")
7072   PORT_CATEGORY_ITEM(  0x0000, "Unconnected",      0 )
7173   PORT_CATEGORY_ITEM(  0x0100, "Gamepad",         3 )
r8381r8382
129131
130132   PORT_START("PADDLE")  /* Arkanoid paddle */
131133   PORT_BIT( 0xff, 0x7f, IPT_PADDLE) PORT_SENSITIVITY(25) PORT_KEYDELTA(3) PORT_MINMAX(0x62,0xf2)                                                   PORT_CATEGORY(7)
134
135   PORT_START("CC_LEFT")
136   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1)
137   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1)
138   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_CATEGORY(10) PORT_PLAYER(1)
139   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_CATEGORY(10) PORT_PLAYER(1)
140   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_CATEGORY(10) PORT_PLAYER(1)
141   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_CATEGORY(10) PORT_PLAYER(1)
142   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_CATEGORY(10) PORT_PLAYER(1)
143   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_CATEGORY(10) PORT_PLAYER(1)
144
145   PORT_START("CC_RIGHT")
146   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1)
147   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1)
148   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1)
149   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1)
150   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_CATEGORY(10) PORT_PLAYER(1)
151   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_CATEGORY(10) PORT_PLAYER(1)
152   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_CATEGORY(10) PORT_PLAYER(1)
153   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_CATEGORY(10) PORT_PLAYER(1)
154
132155INPUT_PORTS_END
133156
134157static INPUT_PORTS_START( nes )
r8381r8382
379402   PORT_CATEGORY_ITEM(  0x0000, "Unconnected",      0 )
380403   PORT_CATEGORY_ITEM(  0x0001, "Gamepad",         1 )
381404   PORT_CATEGORY_ITEM(  0x0002, "Zapper",         5 )
382   PORT_CATEGORY_ITEM(  0x0004, "FC Keyboard",      8 )
405   PORT_CATEGORY_ITEM(  0x0006, "Crazy Climber pad", 10 )
406   PORT_CATEGORY_ITEM(  0x0007, "FC Keyboard",      8 )
383407   PORT_CATEGORY_ITEM(  0x0008, "Subor Keyboard",   9 )
384408   PORT_CATEGORY_CLASS( 0x00f0, 0x0010, "P2 Controller")
385409   PORT_CATEGORY_ITEM(  0x0000, "Unconnected",      0 )
386410   PORT_CATEGORY_ITEM(  0x0010, "Gamepad",         2 )
387411   PORT_CATEGORY_ITEM(  0x0030, "Zapper",         6 )
388412   PORT_CATEGORY_ITEM(  0x0040, "Arkanoid paddle",   7 )
413//   PORT_CATEGORY_ITEM(  0x0050, "Family Trainer",  11 )
389414   PORT_CATEGORY_CLASS( 0x0f00, 0x0000, "P3 Controller")
390415   PORT_CATEGORY_ITEM(  0x0000, "Unconnected",      0 )
391416   PORT_CATEGORY_ITEM(  0x0100, "Gamepad",         3 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team