Previous 199869 Revisions Next

r23751 Monday 17th June, 2013 at 17:10:16 UTC by Fabio Priuli
snes.c: simplified input handling and made controller ports 16bits wide, since
this is the way they are accessed by our code. [Fabio Priuli]

(MESS) snes.c: simplified input handling, moved the console specific inputs
to MESS driver and added preliminary Multitap support. Multitap has to be
enabled in the Driver Configuration menu. The code is considered preliminary
because some games recognize 4 pads (e.g. Kunio-kun no Dodge Ball),
other ones recognize 3 pads only (e.g. Super Bomberman 3, 4 & 5) and some
recognize 2 pads only (e.g. FIFA 96 and 97). [Fabio Priuli]
[src/mame/drivers]nss.c sfcbox.c snesb.c
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mess/drivers]snes.c

trunk/src/mame/machine/snes.c
r23750r23751
128128
129129TIMER_CALLBACK_MEMBER(snes_state::snes_update_io)
130130{
131   m_io_read(m_maincpu->space(AS_PROGRAM),0,0,0);
131   io_read(m_maincpu->space(AS_PROGRAM),0,0,0);
132132   SNES_CPU_REG(HVBJOY) &= 0xfe;       /* Clear busy bit */
133133
134134   m_io_timer->adjust(attotime::never);
r23750r23751
423423         value = space.read_byte(0x7e0000 + m_wram_address++);
424424         m_wram_address &= 0x1ffff;
425425         return value;
426
426427      case OLDJOY1:   /* Data for old NES controllers (JOYSER1) */
427         if (m_oldjoy1_latch & 0x1)
428            return 0 | (snes_open_bus_r(space, 0) & 0xfc); //correct?
428         return (oldjoy1_read(m_oldjoy1_latch & 0x1) & 0x03) | (snes_open_bus_r(space, 0) & 0xfc);
429429
430         value = m_oldjoy1_read(space,0,0);
431
432         return (value & 0x03) | (snes_open_bus_r(space, 0) & 0xfc); //correct?
433430      case OLDJOY2:   /* Data for old NES controllers (JOYSER2) */
434         if (m_oldjoy1_latch & 0x1)
435            return 0 | 0x1c | (snes_open_bus_r(space, 0) & 0xe0); //correct?
431         return (oldjoy2_read(m_oldjoy1_latch & 0x1) & 0x03) | 0x1c | (snes_open_bus_r(space, 0) & 0xe0);
436432
437         value = m_oldjoy2_read(space,0,0);
438
439         return value | 0x1c | (snes_open_bus_r(space, 0) & 0xe0); //correct?
440433      case RDNMI:         /* NMI flag by v-blank and version number */
441434         value = (SNES_CPU_REG(RDNMI) & 0x80) | (snes_open_bus_r(space, 0) & 0x70);
442435         SNES_CPU_REG(RDNMI) &= 0x70;   /* NMI flag is reset on read */
r23750r23751
461454      case JOY3H:         /* Joypad 3 status register (high) */
462455      case JOY4L:         /* Joypad 4 status register (low) */
463456      case JOY4H:         /* Joypad 4 status register (high) */
464         if(m_is_nss && m_input_disabled)
457         if (m_is_nss && m_input_disabled)
465458            return 0;
466459         return SNES_CPU_REG(offset);
467460
468461      case 0x4100:        /* NSS Dip-Switches */
469         {
470            if (m_is_nss)
471               return ioport("DSW")->read();
472
473            return snes_open_bus_r(space, 0);
474         }
462         if (m_is_nss)
463            return ioport("DSW")->read();
464         break;
475465//      case 0x4101: //PC: a104 - a10e - a12a   //only nss_actr (DSW actually reads in word units ...)
476466
477467      default:
r23750r23751
538528         m_wram_address &= 0x1ffff;
539529         return;
540530      case OLDJOY1:   /* Old NES joystick support */
541         if (((!(data & 0x1)) && (m_oldjoy1_latch & 0x1)))
542         {
543            m_read_idx[0] = 0;
544            m_read_idx[1] = 0;
545         }
531         write_joy_latch(data);
546532         if (m_is_nss)
547         {
548533            m_game_over_flag = (data & 4) >> 2;
549         }
550         m_oldjoy1_latch = data;
551534         return;
552535      case OLDJOY2:   /* Old NES joystick support */
553536         return;
r23750r23751
622605
623606}
624607
608void snes_state::write_joy_latch(UINT8 data)
609{
610   if (m_oldjoy1_latch == (data & 0x01))
611      return;
612
613   m_oldjoy1_latch = data & 0x01;
614   m_read_idx[0] = 0;
615   m_read_idx[1] = 0;
616   m_read_idx[2] = 0;
617   m_read_idx[3] = 0;
618}
619
620
625621WRITE_LINE_MEMBER(snes_state::snes_extern_irq_w)
626622{
627623   m_maincpu->set_input_line(G65816_LINE_IRQ, state);
r23750r23751
943939
944940*************************************/
945941
946WRITE8_MEMBER(snes_state::nss_io_read)
942WRITE8_MEMBER(snes_state::io_read)
947943{
948   static const char *const portnames[2][4] =
949         {
950            { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" },
951            { "SERIAL2_DATA1_L", "SERIAL2_DATA1_H", "SERIAL2_DATA2_L", "SERIAL2_DATA2_H" },
952         };
953   int port;
944   static const char *const portnames[2][2] =
945   {
946      { "SERIAL1_DATA1", "SERIAL1_DATA2" },
947      { "SERIAL2_DATA1", "SERIAL2_DATA2" }
948   };
954949
955   for (port = 0; port < 2; port++)
950   for (int port = 0; port < 2; port++)
956951   {
957      m_data1[port] = ioport(portnames[port][0])->read() | (ioport(portnames[port][1])->read() << 8);
958      m_data2[port] = ioport(portnames[port][2])->read() | (ioport(portnames[port][3])->read() << 8);
952      m_data1[port] = ioport(portnames[port][0])->read();
953      m_data2[port] = ioport(portnames[port][1])->read();
959954
960955      // avoid sending signals that could crash games
961956      // if left, no right
r23750r23751
964959      // if up, no down
965960      if (m_data1[port] & 0x800)
966961         m_data1[port] &= ~0x400;
967
968      m_joypad[port].buttons = m_data1[port];
962      // if left, no right
963      if (m_data2[port] & 0x200)
964         m_data2[port] &= ~0x100;
965      // if up, no down
966      if (m_data2[port] & 0x800)
967         m_data2[port] &= ~0x400;
969968   }
970969
971970   // is automatic reading on? if so, copy port data1/data2 to joy1l->joy4h
r23750r23751
991990}
992991
993992
994
995READ8_MEMBER(snes_state::nss_oldjoy1_read)
993UINT8 snes_state::oldjoy1_read(int latched)
996994{
997   UINT8 res;
995   if (latched)
996      return 0;
998997
999998   if (m_read_idx[0] >= 16)
1000      res = 0x01;
999      return 1;
10011000   else
1002      res = (m_joypad[0].buttons >> (15 - m_read_idx[0]++)) & 0x01;
1003
1004   return res;
1001      return (m_data1[0] >> (15 - m_read_idx[0]++)) & 0x01;
10051002}
10061003
1007READ8_MEMBER(snes_state::nss_oldjoy2_read)
1004UINT8 snes_state::oldjoy2_read(int latched)
10081005{
1009   UINT8 res;
1006   if (latched)
1007      return 0;
10101008
10111009   if (m_read_idx[1] >= 16)
1012      res = 0x01;
1010      return 1;
10131011   else
1014      res = (m_joypad[1].buttons >> (15 - m_read_idx[1]++)) & 0x01;
1015
1016   return res;
1012      return (m_data1[1] >> (15 - m_read_idx[1]++)) & 0x01;
10171013}
10181014
1015
10191016/*************************************
10201017
10211018    Driver Init
r23750r23751
10651062   SNES_CPU_REG(JOY4L) = SNES_CPU_REG(JOY4H) = 0;
10661063   m_data1[0] = m_data2[0] = m_data1[1] = m_data2[1] = 0;
10671064
1068   m_io_read = write8_delegate(FUNC(snes_state::nss_io_read),this);
1069   m_oldjoy1_read = read8_delegate(FUNC(snes_state::nss_oldjoy1_read),this);
1070   m_oldjoy2_read = read8_delegate(FUNC(snes_state::nss_oldjoy2_read),this);
1071
10721065   // set up some known register power-up defaults
10731066   SNES_CPU_REG(WRIO) = 0xff;
10741067
r23750r23751
10911084
10921085   for (int i = 0; i < 6; i++)
10931086   {
1094      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].dmap);
1095      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].dest_addr);
1096      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].src_addr);
1097      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].bank);
1098      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].trans_size);
1099      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].ibank);
1100      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].hdma_addr);
1101      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].hdma_line_counter);
1102      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].unk);
1103      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].do_transfer);
1104      state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].dma_disabled);
1087      save_item(NAME(m_dma_channel[i].dmap), i);
1088      save_item(NAME(m_dma_channel[i].dest_addr), i);
1089      save_item(NAME(m_dma_channel[i].src_addr), i);
1090      save_item(NAME(m_dma_channel[i].bank), i);
1091      save_item(NAME(m_dma_channel[i].trans_size), i);
1092      save_item(NAME(m_dma_channel[i].ibank), i);
1093      save_item(NAME(m_dma_channel[i].hdma_addr), i);
1094      save_item(NAME(m_dma_channel[i].hdma_line_counter), i);
1095      save_item(NAME(m_dma_channel[i].unk), i);
1096      save_item(NAME(m_dma_channel[i].do_transfer), i);
1097      save_item(NAME(m_dma_channel[i].dma_disabled), i);
11051098   }
11061099
11071100   save_item(NAME(m_hblank_offset));
r23750r23751
11161109   save_item(NAME(m_cpu_regs));
11171110   save_item(NAME(m_oldjoy1_latch));
11181111
1119   for (int i = 0; i < 2; i++)
1120   {
1121      state_save_register_item(machine(), "snes_dma", NULL, i, m_joypad[i].buttons);
1122      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].x);
1123      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].oldx);
1124      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].y);
1125      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].oldy);
1126      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].buttons);
1127      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].deltax);
1128      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].deltay);
1129      state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].speed);
1130      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].x);
1131      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].y);
1132      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].buttons);
1133      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].turbo_lock);
1134      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].pause_lock);
1135      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].fire_lock);
1136      state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].offscreen);
1137   }
1138
11391112   m_is_nss = 0;
11401113   m_is_sfcbox = 0;
11411114}
11421115
11431116void snes_state::machine_reset()
11441117{
1145   int i;
1146
11471118   snes_init_ram();
11481119
11491120   /* init DMA regs to be 0xff */
1150   for(i = 0; i < 8; i++)
1121   for (int i = 0; i < 8; i++)
11511122   {
11521123      m_dma_channel[i].dmap = 0xff;
11531124      m_dma_channel[i].dest_addr = 0xff;
trunk/src/mame/includes/snes.h
r23750r23751
553553   UINT8 rom_bank_map[0x100];
554554};
555555
556struct snes_joypad
557{
558   UINT16 buttons;
559};
560
561struct snes_mouse
562{
563   INT16 x, y, oldx, oldy;
564   UINT8 buttons;
565   UINT8 deltax, deltay;
566   int speed;
567};
568
569struct snes_superscope
570{
571   INT16 x, y;
572   UINT8 buttons;
573   int turbo_lock, pause_lock, fire_lock;
574   int offscreen;
575};
576
577556class snes_state : public driver_device
578557{
579558public:
r23750r23751
642621   UINT8                 m_oldjoy1_latch;
643622
644623   /* input-related */
645   UINT16                m_data1[2];
646   UINT16                m_data2[2];
647   UINT8                 m_read_idx[2];
648   snes_joypad           m_joypad[2];
649   snes_mouse            m_mouse[2];
650   snes_superscope       m_scope[2];
624   UINT16                m_data1[4];   // JOY1/JOY2 + 3rd & 4th only used by multitap (hacky support)
625   UINT16                m_data2[4];   // JOY3/JOY4 + 3rd & 4th only used by multitap (hacky support)
626   UINT8                 m_read_idx[4];   // 3rd & 4th only used by multitap (hacky support)
651627
652   /* input callbacks (to allow MESS to have its own input handlers) */
653   write8_delegate     m_io_read;
654   read8_delegate      m_oldjoy1_read;
655   read8_delegate      m_oldjoy2_read;
656
657628   /* cart related */
658629   snes_cart_info m_cart;   // used by NSS/SFCBox only! to be moved in a derived class!
659630   void rom_map_setup(UINT32 size);
r23750r23751
685656   void hdma_init(address_space &space);
686657   void hdma_update(address_space &space, int dma);
687658   void hirq_tick();
659   void write_joy_latch(UINT8 data);
688660   inline UINT8 snes_rom_access(UINT32 offset);
689661
690662   void snes_init_ram();
691663
692   DECLARE_WRITE8_MEMBER(nss_io_read);
693   DECLARE_READ8_MEMBER(nss_oldjoy1_read);
694   DECLARE_READ8_MEMBER(nss_oldjoy2_read);
664   // input related
665   virtual DECLARE_WRITE8_MEMBER(io_read);
666   virtual UINT8 oldjoy1_read(int latched);
667   virtual UINT8 oldjoy2_read(int latched);
695668
696669   DECLARE_READ8_MEMBER(snes_r_io);
697670   DECLARE_WRITE8_MEMBER(snes_w_io);
trunk/src/mame/drivers/snesb.c
r23750r23751
260260ADDRESS_MAP_END
261261
262262static INPUT_PORTS_START( snes_common )
263   PORT_START("SERIAL1_DATA1_L")
264   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
265   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
266   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
267   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
268   PORT_START("SERIAL1_DATA1_H")
269   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
270   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
271   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
272   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
273   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
274   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
275   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
276   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
277263
278   PORT_START("SERIAL2_DATA1_L")
279   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
280   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
281   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
282   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
283   PORT_START("SERIAL2_DATA1_H")
284   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
285   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
286   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
287   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
288   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
289   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
290   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
291   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
264   PORT_START("SERIAL1_DATA1")
265   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
266   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
267   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
268   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
269   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
270   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
271   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
272   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
273   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
274   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
275   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
276   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
277   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED )
292278
293   PORT_START("SERIAL1_DATA2_L")
294   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
295   PORT_START("SERIAL1_DATA2_H")
296   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
279   PORT_START("SERIAL2_DATA1")
280   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
281   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
282   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
283   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
284   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
285   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
286   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
287   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
288   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
289   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
290   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
291   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
292   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED )
297293
298   PORT_START("SERIAL2_DATA2_L")
299   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
300   PORT_START("SERIAL2_DATA2_H")
301   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
294   PORT_START("SERIAL1_DATA2")
295   PORT_BIT( 0xffff, IP_ACTIVE_HIGH, IPT_UNUSED )
302296
297   PORT_START("SERIAL2_DATA2")
298   PORT_BIT( 0xffff, IP_ACTIVE_HIGH, IPT_UNUSED )
299
303300#if SNES_LAYER_DEBUG
304301   PORT_START("DEBUG1")
305302   PORT_CONFNAME( 0x03, 0x00, "Select BG1 priority" )
trunk/src/mame/drivers/sfcbox.c
r23750r23751
317317   PORT_START("OSD_CS")
318318   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("mb90082", mb90082_device, set_cs_line)
319319
320   PORT_START("SERIAL1_DATA1_L")
321   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
322   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
323   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
324   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
325   PORT_START("SERIAL1_DATA1_H")
326   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
327   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
328   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
329   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
330   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
331   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
332   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
333   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
320   PORT_START("SERIAL1_DATA1")
321   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
322   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
323   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
324   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
325   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
326   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
327   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
328   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
329   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
330   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
331   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
332   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
333   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED )
334334
335   PORT_START("SERIAL2_DATA1_L")
336   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
337   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
338   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
339   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
340   PORT_START("SERIAL2_DATA1_H")
341   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
342   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
343   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
344   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
345   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
346   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
347   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
348   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
335   PORT_START("SERIAL2_DATA1")
336   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
337   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
338   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
339   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
340   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
341   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
342   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
343   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
344   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
345   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
346   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
347   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
348   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED )
349349
350   PORT_START("SERIAL1_DATA2_L")
351   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
352   PORT_START("SERIAL1_DATA2_H")
353   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
350   PORT_START("SERIAL1_DATA2")
351   PORT_BIT( 0xffff, IP_ACTIVE_HIGH, IPT_UNUSED )
354352
355   PORT_START("SERIAL2_DATA2_L")
356   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
357   PORT_START("SERIAL2_DATA2_H")
358   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
353   PORT_START("SERIAL2_DATA2")
354   PORT_BIT( 0xffff, IP_ACTIVE_HIGH, IPT_UNUSED )
359355
360356   PORT_START("DSW")
361357   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
trunk/src/mame/drivers/nss.c
r23750r23751
516516
517517   res = (m_joy_flag) << 7;
518518   res|= (machine().primary_screen->vblank() & 1) << 6;
519   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x80) >> 7) << 5);
520   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x80) >> 7) << 4);
521   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x04) >> 2) << 3);
522   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x08) >> 3) << 2);
523   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x02) >> 1) << 1);
524   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x01) >> 0) << 0);
519   res|= (BIT(ioport("SERIAL1_DATA1")->read(), 15) << 5);
520   res|= (BIT(ioport("SERIAL1_DATA1")->read(),  7) << 4);
521   res|= (BIT(ioport("SERIAL1_DATA1")->read(), 10) << 3);
522   res|= (BIT(ioport("SERIAL1_DATA1")->read(), 11) << 2);
523   res|= (BIT(ioport("SERIAL1_DATA1")->read(),  9) << 1);
524   res|= (BIT(ioport("SERIAL1_DATA1")->read(),  8) << 0);
525525
526526   return res;
527527}
r23750r23751
671671   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNKNOWN )
672672   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, read_bit)
673673
674   PORT_START("SERIAL1_DATA1_L")
675   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
676   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
677   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
678   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
679   PORT_START("SERIAL1_DATA1_H")
680   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
681   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
682   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
683   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
684   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
685   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
686   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
687   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
674   PORT_START("SERIAL1_DATA1")
675   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
676   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
677   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
678   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
679   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
680   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
681   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
682   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
683   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
684   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
685   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
686   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
687   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED )
688688
689   PORT_START("SERIAL2_DATA1_L")
690   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
691   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
692   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
693   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
694   PORT_START("SERIAL2_DATA1_H")
695   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
696   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
697   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
698   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
699   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
700   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
701   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
702   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
689   PORT_START("SERIAL2_DATA1")
690   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
691   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
692   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
693   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
694   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
695   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
696   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
697   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
698   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
699   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
700   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
701   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
702   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED )
703703
704   PORT_START("SERIAL1_DATA2_L")
705   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
706   PORT_START("SERIAL1_DATA2_H")
707   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
704   PORT_START("SERIAL1_DATA2")
705   PORT_BIT( 0xffff, IP_ACTIVE_HIGH, IPT_UNUSED )
708706
709   PORT_START("SERIAL2_DATA2_L")
710   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
711   PORT_START("SERIAL2_DATA2_H")
712   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
707   PORT_START("SERIAL2_DATA2")
708   PORT_BIT( 0xffff, IP_ACTIVE_HIGH, IPT_UNUSED )
713709
714710   PORT_START("DSW")
715711   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
trunk/src/mess/drivers/snes.c
r23750r23751
4747#include "machine/sns_event.h"
4848
4949
50struct snes_mouse
51{
52   INT16 x, y, oldx, oldy;
53   UINT16 buttons;
54   UINT8 deltax, deltay;
55   int speed;
56};
57
58struct snes_superscope
59{
60   INT16 x, y;
61   UINT8 buttons;
62   int turbo_lock, pause_lock, fire_lock;
63   int offscreen;
64};
65
66
5067class snes_console_state : public snes_state
5168{
5269public:
r23750r23751
99116
100117   DECLARE_READ8_MEMBER( spc_ram_100_r );
101118   DECLARE_WRITE8_MEMBER( spc_ram_100_w );
102   CUSTOM_INPUT_MEMBER( snes_mouse_speed_input );
103   CUSTOM_INPUT_MEMBER( snes_superscope_offscreen_input );
104119   TIMER_CALLBACK_MEMBER( lightgun_tick );
105   void snes_gun_latch( INT16 x, INT16 y );
106   void snes_input_read_joy( int port );
107   void snes_input_read_mouse( int port );
108   void snes_input_read_superscope( int port );
109   DECLARE_WRITE8_MEMBER(snes_input_read);
110   DECLARE_READ8_MEMBER(snes_oldjoy1_read);
111   DECLARE_READ8_MEMBER(snes_oldjoy2_read);
112120
121   // input related
122   virtual DECLARE_WRITE8_MEMBER(io_read);
123   virtual UINT8 oldjoy1_read(int latched);
124   virtual UINT8 oldjoy2_read(int latched);
125
126   // pad inputs
127   void input_read_joy(int port, bool multitap);
128   UINT8 input_serial_pad(int port, int latched, bool multitap);
129
130   // mouse inputs
131   void input_read_mouse(int port);
132   UINT8 input_serial_mouse(int port, int latched);
133
134   // superscope inputs
135   DECLARE_CUSTOM_INPUT_MEMBER( sscope_offscreen_input );
136   void input_read_sscope(int port);
137   UINT8 input_serial_sscope(int port, int latched);
138   void gun_latch(INT16 x, INT16 y);
139
113140   virtual void machine_start();
114141   virtual void machine_reset();
115142   int m_type;
116143   optional_device<sns_cart_slot_device> m_cartslot;
117144
118145protected:
146
147   snes_mouse            m_mouse[2];
148   snes_superscope       m_scope[2];
149
119150   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
120151};
121152
r23750r23751
10381069 *
10391070 *************************************/
10401071
1041CUSTOM_INPUT_MEMBER( snes_console_state::snes_mouse_speed_input )
1042{
1043   int port = (FPTR)param;
1044
1045   if (m_oldjoy1_latch & 0x1)
1046   {
1047      m_mouse[port].speed++;
1048      if ((m_mouse[port].speed & 0x03) == 0x03)
1049         m_mouse[port].speed = 0;
1050   }
1051
1052   return m_mouse[port].speed;
1053}
1054
1055CUSTOM_INPUT_MEMBER( snes_console_state::snes_superscope_offscreen_input )
1056{
1057   int port = (FPTR)param;
1058   static const char *const portnames[2][3] =
1059         {
1060            { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" },
1061            { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" },
1062         };
1063
1064   INT16 x = ioport(portnames[port][1])->read();
1065   INT16 y = ioport(portnames[port][2])->read();
1066
1067   /* these are the theoretical boundaries, but we currently are always onscreen... */
1068   if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= m_ppu.m_beam.last_visible_line)
1069      m_scope[port].offscreen = 1;
1070   else
1071      m_scope[port].offscreen = 0;
1072
1073   return m_scope[port].offscreen;
1074}
1075
10761072void snes_console_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
10771073{
10781074   switch (id)
r23750r23751
11101106   }
11111107}
11121108
1113
11141109static INPUT_PORTS_START( snes_joypads )
1115   PORT_START("SERIAL1_DATA1_L")
1116   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1117   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1118   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1119   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1120   PORT_START("SERIAL1_DATA1_H")
1121   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1122   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1123   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P1 Select") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1124   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1125   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1126   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1127   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1128   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
11291110
1130   PORT_START("SERIAL2_DATA1_L")
1131   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1132   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1133   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1134   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1135   PORT_START("SERIAL2_DATA1_H")
1136   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1137   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1138   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P2 Select") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1139   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1140   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1141   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1142   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1143   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1111   PORT_START("JOY1")
1112   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1113   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1114   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P1 Select") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1115   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1116   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1117   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1118   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1119   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1120   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1121   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1122   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1123   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
1124   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
11441125
1145   PORT_START("SERIAL1_DATA2_L")
1146   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
1147   PORT_START("SERIAL1_DATA2_H")
1148   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
1126   PORT_START("JOY2")
1127   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1128   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1129   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P2 Select") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1130   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1131   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1132   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1133   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1134   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1135   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1136   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1137   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1138   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1139   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
1140// temp hack to share the same port both for P2 alone and P2 through MP5 adapter
1141   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1142   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1143   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P2 Select") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1144   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1145   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1146   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1147   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1148   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1149   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1150   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1151   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1152   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1153   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
11491154
1150   PORT_START("SERIAL2_DATA2_L")
1151   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
1152   PORT_START("SERIAL2_DATA2_H")
1153   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
1155   PORT_START("JOY3")
1156   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P3 Button B") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1157   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P3 Button Y") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1158   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P3 Select") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1159   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START3 ) PORT_NAME("P3 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1160   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1161   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1162   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1163   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1164   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P3 Button A") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1165   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P3 Button X") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1166   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P3 Button L") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1167   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P3 Button R") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1168   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1169
1170   PORT_START("JOY4")
1171   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P4 Button B") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1172   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P4 Button Y") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1173   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P4 Select") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1174   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START4 ) PORT_NAME("P4 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1175   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1176   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1177   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1178   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1179   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P4 Button A") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1180   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P4 Button X") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1181   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P4 Button L") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1182   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P4 Button R") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1183   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1184
1185   PORT_START("JOY5")
1186   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P5 Button B") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1187   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P5 Button Y") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1188   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P5 Select") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1189   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START5 ) PORT_NAME("P5 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1190   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1191   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1192   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1193   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1194   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P5 Button A") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1195   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P5 Button X") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1196   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P5 Button L") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1197   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P5 Button R") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1198   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50)
1199
11541200INPUT_PORTS_END
11551201
11561202static INPUT_PORTS_START( snes_mouse )
11571203   PORT_START("MOUSE1")
11581204   /* bits 0,3 = mouse signature (must be 1) */
1159   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
1160   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
1161   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
1162   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
1205   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED )
1206   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED )
1207   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED )
1208   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
11631209   /* bits 4,5 = mouse speed: 0 = slow, 1 = normal, 2 = fast, 3 = unused */
1164   PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_mouse_speed_input, (void *)0)
1210   PORT_BIT( 0x0030, IP_ACTIVE_HIGH, IPT_UNUSED )
11651211   /* bits 6,7 = mouse buttons */
1166   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Mouse Button Left") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
1167   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Mouse Button Right") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
1212   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Mouse Button Left") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
1213   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Mouse Button Right") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
1214   PORT_BIT( 0xff00, IP_ACTIVE_HIGH, IPT_SPECIAL ) // these must be 0!
11681215
11691216   PORT_START("MOUSE1_X")
1170   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
1217   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
11711218
11721219   PORT_START("MOUSE1_Y")
1173   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
1220   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
11741221
11751222   PORT_START("MOUSE2")
11761223   /* bits 0,3 = mouse signature (must be 1) */
r23750r23751
11791226   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
11801227   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
11811228   /* bits 4,5 = mouse speed: 0 = slow, 1 = normal, 2 = fast, 3 = unused */
1182   PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_mouse_speed_input, (void *)1)
1229   PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_UNUSED )
11831230   /* bits 6,7 = mouse buttons */
11841231   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Mouse Button Left") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20)
11851232   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Mouse Button Right") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20)
11861233
11871234   PORT_START("MOUSE2_X")
1188   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20)
1235   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20)
11891236
11901237   PORT_START("MOUSE2_Y")
1191   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20)
1238   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20)
11921239INPUT_PORTS_END
11931240
11941241static INPUT_PORTS_START( snes_superscope )
11951242   PORT_START("SUPERSCOPE1")
11961243   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )    // Noise
1197   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_superscope_offscreen_input, (void *)0)
1244   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, sscope_offscreen_input, (void *)0)
11981245   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
11991246   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
12001247   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Port1 Superscope Pause") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
r23750r23751
12101257
12111258   PORT_START("SUPERSCOPE2")
12121259   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )    // Noise
1213   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_superscope_offscreen_input, (void *)1)
1260   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, sscope_offscreen_input, (void *)1)
12141261   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
12151262   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
12161263   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Port2 Superscope Pause") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
r23750r23751
12401287   PORT_CONFSETTING(  0x20, "Mouse" )
12411288   PORT_CONFSETTING(  0x30, "Superscope" )
12421289//  PORT_CONFSETTING(  0x40, "Justfier" )
1243//  PORT_CONFSETTING(  0x50, "Multitap" )
1290   PORT_CONFSETTING(  0x50, "Multitap" )
12441291
12451292   PORT_INCLUDE(snes_joypads)
12461293   PORT_INCLUDE(snes_mouse)
r23750r23751
13111358 *
13121359 *************************************/
13131360
1314void snes_console_state::snes_gun_latch( INT16 x, INT16 y )
1315{
1316   /* these are the theoretical boundaries */
1317   if (x < 0)
1318      x = 0;
1319   if (x > (SNES_SCR_WIDTH - 1))
1320      x = SNES_SCR_WIDTH - 1;
1361// Mouse handling
13211362
1322   if (y < 0)
1323      y = 0;
1324   if (y > (m_ppu.m_beam.last_visible_line - 1))
1325      y = m_ppu.m_beam.last_visible_line - 1;
1326
1327   m_ppu.m_beam.latch_horz = x;
1328   m_ppu.m_beam.latch_vert = y;
1329   m_ppu.m_stat78 |= 0x40;
1330}
1331
1332void snes_console_state::snes_input_read_joy( int port )
1363void snes_console_state::input_read_mouse(int port)
13331364{
1334   static const char *const portnames[2][4] =
1335         {
1336            { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" },
1337            { "SERIAL2_DATA1_L", "SERIAL2_DATA1_H", "SERIAL2_DATA2_L", "SERIAL2_DATA2_H" },
1338         };
1339
1340   m_data1[port] = ioport(portnames[port][0])->read() | (ioport(portnames[port][1])->read() << 8);
1341   m_data2[port] = ioport(portnames[port][2])->read() | (ioport(portnames[port][3])->read() << 8);
1342
1343   // avoid sending signals that could crash games
1344   // if left, no right
1345   if (m_data1[port] & 0x200)
1346      m_data1[port] &= ~0x100;
1347   // if up, no down
1348   if (m_data1[port] & 0x800)
1349      m_data1[port] &= ~0x400;
1350
1351   m_joypad[port].buttons = m_data1[port];
1352}
1353
1354void snes_console_state::snes_input_read_mouse( int port )
1355{
13561365   INT16 var;
13571366   static const char *const portnames[2][3] =
1358         {
1359            { "MOUSE1", "MOUSE1_X", "MOUSE1_Y" },
1360            { "MOUSE2", "MOUSE2_X", "MOUSE2_Y" },
1361         };
1367   {
1368      { "MOUSE1", "MOUSE1_X", "MOUSE1_Y" },
1369      { "MOUSE2", "MOUSE2_X", "MOUSE2_Y" },
1370   };
13621371
13631372   m_mouse[port].buttons = ioport(portnames[port][0])->read();
13641373   m_mouse[port].x = ioport(portnames[port][1])->read();
13651374   m_mouse[port].y = ioport(portnames[port][2])->read();
1375
13661376   var = m_mouse[port].x - m_mouse[port].oldx;
13671377
13681378   if (var < -127)
r23750r23751
14091419      m_mouse[port].oldy = m_mouse[port].y;
14101420   }
14111421
1412   m_data1[port] = m_mouse[port].buttons | (0x00 << 8);
1422   m_data1[port] = m_mouse[port].buttons;
14131423   m_data2[port] = 0;
14141424}
14151425
1416void snes_console_state::snes_input_read_superscope( int port )
1426UINT8 snes_console_state::input_serial_mouse(int port, int latched)
14171427{
1428   UINT8 res = 0;
1429
1430   if (latched)
1431   {
1432      m_mouse[port].speed = (m_mouse[port].speed + 1) % 3;
1433      return res;
1434   }
1435
1436   if (m_read_idx[port] >= 32)
1437      res |= 0x01;
1438   else if (m_read_idx[port] >= 24)
1439      res |= (m_mouse[port].deltax >> (31 - m_read_idx[port]++)) & 0x01;
1440   else if (m_read_idx[port] >= 16)
1441      res |= (m_mouse[port].deltay >> (23 - m_read_idx[port]++)) & 0x01;
1442   else if (m_read_idx[port] == 11)
1443   {
1444      res |= (m_mouse[port].speed >> 0) & 0x01;
1445      m_read_idx[port]++;
1446   }
1447   else if (m_read_idx[port] == 10)
1448   {
1449      res |= (m_mouse[port].speed >> 1) & 0x01;
1450      m_read_idx[port]++;
1451   }
1452   else
1453      res |= (m_mouse[port].buttons >> (15 - m_read_idx[port]++)) & 0x01;
1454
1455   return res;
1456}
1457
1458// Superscope handling
1459
1460CUSTOM_INPUT_MEMBER( snes_console_state::sscope_offscreen_input )
1461{
1462   int port = (FPTR)param;
14181463   static const char *const portnames[2][3] =
1419         {
1420            { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" },
1421            { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" },
1422         };
1464   {
1465      { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" },
1466      { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" },
1467   };
1468
1469   INT16 x = ioport(portnames[port][1])->read();
1470   INT16 y = ioport(portnames[port][2])->read();
1471
1472   /* these are the theoretical boundaries, but we currently are always onscreen... */
1473   if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= m_ppu.m_beam.last_visible_line)
1474      m_scope[port].offscreen = 1;
1475   else
1476      m_scope[port].offscreen = 0;
1477
1478   return m_scope[port].offscreen;
1479}
1480
1481
1482void snes_console_state::gun_latch(INT16 x, INT16 y)
1483{
1484   /* these are the theoretical boundaries */
1485   if (x < 0)
1486      x = 0;
1487   if (x > (SNES_SCR_WIDTH - 1))
1488      x = SNES_SCR_WIDTH - 1;
1489
1490   if (y < 0)
1491      y = 0;
1492   if (y > (m_ppu.m_beam.last_visible_line - 1))
1493      y = m_ppu.m_beam.last_visible_line - 1;
1494
1495   m_ppu.m_beam.latch_horz = x;
1496   m_ppu.m_beam.latch_vert = y;
1497   m_ppu.m_stat78 |= 0x40;
1498}
1499
1500void snes_console_state::input_read_sscope(int port)
1501{
1502   static const char *const portnames[2][3] =
1503   {
1504      { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" },
1505      { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" },
1506   };
14231507   UINT8 input;
14241508
14251509   /* first read input bits */
r23750r23751
14641548      m_scope[port].pause_lock = 0;
14651549
14661550   /* If we have pressed fire or cursor and we are on-screen and SuperScope is in Port2, then latch video signal.
1467   Notice that we only latch Port2 because its IOBit pin is connected to bit7 of the IO Port, while Port1 has
1468   IOBit pin connected to bit6 of the IO Port, and the latter is not detected by the H/V Counters. In other
1469   words, you can connect SuperScope to Port1, but there is no way SNES could detect its on-screen position */
1551    Notice that we only latch Port2 because its IOBit pin is connected to bit7 of the IO Port, while Port1 has
1552    IOBit pin connected to bit6 of the IO Port, and the latter is not detected by the H/V Counters. In other
1553    words, you can connect SuperScope to Port1, but there is no way SNES could detect its on-screen position */
14701554   if ((m_scope[port].buttons & 0xc0) && !(m_scope[port].buttons & 0x02) && port == 1)
1471      snes_gun_latch(m_scope[port].x, m_scope[port].y);
1555      gun_latch(m_scope[port].x, m_scope[port].y);
14721556
14731557   m_data1[port] = 0xff | (m_scope[port].buttons << 8);
14741558   m_data2[port] = 0;
14751559}
14761560
1477WRITE8_MEMBER(snes_console_state::snes_input_read)
1561UINT8 snes_console_state::input_serial_sscope(int port, int latched)
14781562{
1563   UINT8 res = 0;
1564
1565   if (m_read_idx[port] >= 8)
1566      res |= 0x01;
1567   else
1568      res |= (m_scope[port].buttons >> (7 - m_read_idx[port]++)) & 0x01;
1569
1570   return res;
1571}
1572
1573// Joypad + Multitap handling
1574// input_read_joy is used both for standard joys and for the MP5 multitap
1575
1576void snes_console_state::input_read_joy( int port, bool multitap )
1577{
1578   static const char *const portnames[4][2] =
1579         {
1580            { "JOY1", "JOY3" },
1581            { "JOY2", "JOY3" },
1582            { "JOY4", "JOY5" },
1583            { "JOY4", "JOY5" }
1584         };
1585
1586   if (!multitap)
1587   {
1588      m_data1[port] = ioport(portnames[port][0])->read();
1589      m_data2[port] = 0;
1590      // avoid sending signals that could crash games
1591      // if left, no right
1592      if (m_data1[port] & 0x200)
1593         m_data1[port] &= ~0x100;
1594      // if up, no down
1595      if (m_data1[port] & 0x800)
1596         m_data1[port] &= ~0x400;
1597      // if left, no right
1598      if (m_data2[port] & 0x200)
1599         m_data2[port] &= ~0x100;
1600      // if up, no down
1601      if (m_data2[port] & 0x800)
1602         m_data2[port] &= ~0x400;
1603   }
1604   else
1605   {
1606      m_data1[port] = ioport(portnames[port][0])->read();
1607      m_data2[port] = ioport(portnames[port][1])->read();
1608      m_data1[port + 2] = ioport(portnames[port + 2][0])->read();
1609      m_data2[port + 2] = ioport(portnames[port + 2][1])->read();
1610      // avoid sending signals that could crash games
1611      // if left, no right
1612      if (m_data1[port] & 0x200)
1613         m_data1[port] &= ~0x100;
1614      // if up, no down
1615      if (m_data1[port] & 0x800)
1616         m_data1[port] &= ~0x400;
1617      // if left, no right
1618      if (m_data2[port] & 0x200)
1619         m_data2[port] &= ~0x100;
1620      // if up, no down
1621      if (m_data2[port] & 0x800)
1622         m_data2[port] &= ~0x400;
1623      // if left, no right
1624      if (m_data1[port + 2] & 0x200)
1625         m_data1[port + 2] &= ~0x100;
1626      // if up, no down
1627      if (m_data1[port + 2] & 0x800)
1628         m_data1[port + 2] &= ~0x400;
1629      // if left, no right
1630      if (m_data2[port + 2] & 0x200)
1631         m_data2[port + 2] &= ~0x100;
1632      // if up, no down
1633      if (m_data2[port + 2] & 0x800)
1634         m_data2[port + 2] &= ~0x400;
1635   }
1636}
1637
1638UINT8 snes_console_state::input_serial_pad(int port, int latched, bool multitap)
1639{
1640   UINT8 res = 0;
1641
1642   // multitap signature? Super Bomberman 3-5 do not like this at all...
1643   if (multitap)
1644      res |= 2;
1645   if (latched)
1646      return res;
1647
1648   if (!multitap)
1649   {
1650      if (m_read_idx[port] >= 16)
1651         res |= 0x01;
1652      else
1653      {
1654         res |= (BIT(m_data1[port], (15 - m_read_idx[port])));
1655         res |= (BIT(m_data2[port], (15 - m_read_idx[port])) << 1);
1656         m_read_idx[port]++;
1657      }
1658   }
1659   else
1660   {
1661      int shift = !(SNES_CPU_REG(WRIO) & 0x80) ? 2 : 0;
1662      if (m_read_idx[port + shift] >= 16)
1663         res |= 0x03;
1664      else
1665      {
1666         res |= (BIT(m_data1[port + shift], (15 - m_read_idx[port + shift])));
1667         res |= (BIT(m_data2[port + shift], (15 - m_read_idx[port + shift])) << 1);
1668         m_read_idx[port + shift]++;
1669      }
1670   }
1671   return res;
1672}
1673
1674
1675// input handling from the system side
1676
1677WRITE8_MEMBER(snes_console_state::io_read)
1678{
14791679   UINT8 ctrl1 = ioport("CTRLSEL")->read() & 0x0f;
14801680   UINT8 ctrl2 = (ioport("CTRLSEL")->read() & 0xf0) >> 4;
1681   bool multitap0 = FALSE;
1682   bool multitap1 = FALSE;
14811683
1482   /* Check if lightgun has been chosen as input: if so, enable crosshair */
1684   // Check if lightgun has been chosen as input: if so, enable crosshair
14831685   timer_set(attotime::zero, TIMER_LIGHTGUN_TICK);
14841686
14851687   switch (ctrl1)
14861688   {
1487   case 1: /* SNES joypad */
1488      snes_input_read_joy(0);
1489      break;
1490   case 2: /* SNES Mouse */
1491      snes_input_read_mouse(0);
1492      break;
1493   case 3: /* SNES Superscope */
1494      snes_input_read_superscope(0);
1495      break;
1496   case 0: /* no controller in port1 */
1497   default:
1498      m_data1[0] = 0;
1499      m_data2[0] = 0;
1500      break;
1689      case 1: // SNES joypad
1690         input_read_joy(0, FALSE);
1691         break;
1692      case 2: // SNES Mouse
1693         input_read_mouse(0);
1694         break;
1695      case 3: // SNES Superscope
1696         input_read_sscope(0);
1697         break;
1698      case 5: // SNES joypad(s) through MP5 multitap
1699         input_read_joy(0, TRUE);
1700         multitap0 = TRUE;
1701         break;
1702      case 0: // empty port1
1703      default:
1704         m_data1[0] = 0;
1705         m_data2[0] = 0;
1706         break;
15011707   }
15021708
15031709   switch (ctrl2)
15041710   {
1505   case 1: /* SNES joypad */
1506      snes_input_read_joy(1);
1507      break;
1508   case 2: /* SNES Mouse */
1509      snes_input_read_mouse(1);
1510      break;
1511   case 3: /* SNES Superscope */
1512      snes_input_read_superscope(1);
1513      break;
1514   case 0: /* no controller in port2 */
1515   default:
1516      m_data1[1] = 0;
1517      m_data2[1] = 0;
1518      break;
1711      case 1: // SNES joypad
1712         input_read_joy(1, FALSE);
1713         break;
1714      case 2: // SNES Mouse
1715         input_read_mouse(1);
1716         break;
1717      case 3: // SNES Superscope
1718         input_read_sscope(1);
1719         break;
1720      case 5: // SNES joypad(s) through MP5 multitap
1721         input_read_joy(1, TRUE);
1722         multitap1 = TRUE;
1723         break;
1724      case 0: // empty port2
1725      default:
1726         m_data1[1] = 0;
1727         m_data2[1] = 0;
1728         break;
15191729   }
15201730
15211731   // is automatic reading on? if so, copy port data1/data2 to joy1l->joy4h
15221732   // this actually works like reading the first 16bits from oldjoy1/2 in reverse order
15231733   if (SNES_CPU_REG(NMITIMEN) & 1)
15241734   {
1525      SNES_CPU_REG(JOY1L) = (m_data1[0] & 0x00ff) >> 0;
1526      SNES_CPU_REG(JOY1H) = (m_data1[0] & 0xff00) >> 8;
1527      SNES_CPU_REG(JOY2L) = (m_data1[1] & 0x00ff) >> 0;
1528      SNES_CPU_REG(JOY2H) = (m_data1[1] & 0xff00) >> 8;
1529      SNES_CPU_REG(JOY3L) = (m_data2[0] & 0x00ff) >> 0;
1530      SNES_CPU_REG(JOY3H) = (m_data2[0] & 0xff00) >> 8;
1531      SNES_CPU_REG(JOY4L) = (m_data2[1] & 0x00ff) >> 0;
1532      SNES_CPU_REG(JOY4H) = (m_data2[1] & 0xff00) >> 8;
1735      int shift0 = (multitap0 && !(SNES_CPU_REG(WRIO) & 0x80)) ? 2 : 0;
1736      int shift1 = (multitap1 && !(SNES_CPU_REG(WRIO) & 0x80)) ? 2 : 0;
15331737
1738      SNES_CPU_REG(JOY1L) = (m_data1[0 + shift0] & 0x00ff) >> 0;
1739      SNES_CPU_REG(JOY1H) = (m_data1[0 + shift0] & 0xff00) >> 8;
1740      SNES_CPU_REG(JOY2L) = (m_data1[1 + shift1] & 0x00ff) >> 0;
1741      SNES_CPU_REG(JOY2H) = (m_data1[1 + shift1] & 0xff00) >> 8;
1742      SNES_CPU_REG(JOY3L) = (m_data2[0 + shift0] & 0x00ff) >> 0;
1743      SNES_CPU_REG(JOY3H) = (m_data2[0 + shift0] & 0xff00) >> 8;
1744      SNES_CPU_REG(JOY4L) = (m_data2[1 + shift1] & 0x00ff) >> 0;
1745      SNES_CPU_REG(JOY4H) = (m_data2[1 + shift1] & 0xff00) >> 8;
1746
15341747      // make sure read_idx starts returning all 1s because the auto-read reads it :-)
1535      m_read_idx[0] = 16;
1536      m_read_idx[1] = 16;
1748      m_read_idx[0 + shift0] = 16;
1749      m_read_idx[1 + shift1] = 16;
15371750   }
1538
15391751}
15401752
1541READ8_MEMBER(snes_console_state::snes_oldjoy1_read)
1753UINT8 snes_console_state::oldjoy1_read(int latched)
15421754{
15431755   UINT8 ctrl1 = ioport("CTRLSEL")->read() & 0x0f;
1544   UINT8 res = 0;
15451756
15461757   switch (ctrl1)
15471758   {
1548   case 1: /* SNES joypad */
1549      if (m_read_idx[0] >= 16)
1550         res = 0x01;
1551      else
1552         res = (m_joypad[0].buttons >> (15 - m_read_idx[0]++)) & 0x01;
1553      break;
1554   case 2: /* SNES Mouse */
1555      if (m_read_idx[0] >= 32)
1556         res = 0x01;
1557      else if (m_read_idx[0] >= 24)
1558         res = (m_mouse[0].deltax >> (31 - m_read_idx[0]++)) & 0x01;
1559      else if (m_read_idx[0] >= 16)
1560         res = (m_mouse[0].deltay >> (23 - m_read_idx[0]++)) & 0x01;
1561      else if (m_read_idx[0] >= 8)
1562         res = (m_mouse[0].buttons >> (15 - m_read_idx[0]++)) & 0x01;
1563      else
1564         res = 0;
1565      break;
1566   case 3: /* SNES Superscope */
1567      if (m_read_idx[0] >= 8)
1568         res = 0x01;
1569      else
1570         res = (m_scope[0].buttons >> (7 - m_read_idx[0]++)) & 0x01;
1571      break;
1572   case 0: /* no controller in port2 */
1573   default:
1574      break;
1759      case 1: // SNES joypad
1760         return input_serial_pad(0, latched, FALSE);
1761
1762      case 2: // SNES Mouse
1763         return input_serial_mouse(0, latched);
1764
1765      case 3: // SNES Superscope
1766         return input_serial_sscope(0, latched);
1767
1768      case 5: // SNES multipad
1769         return input_serial_pad(0, latched, TRUE);
1770
1771      case 0: // empty port1
1772      default:
1773         return 0;
15751774   }
1576
1577   return res;
15781775}
15791776
1580READ8_MEMBER(snes_console_state::snes_oldjoy2_read)
1777UINT8 snes_console_state::oldjoy2_read(int latched)
15811778{
15821779   UINT8 ctrl2 = (ioport("CTRLSEL")->read() & 0xf0) >> 4;
1583   UINT8 res = 0;
15841780
15851781   switch (ctrl2)
15861782   {
1587   case 1: /* SNES joypad */
1588      if (m_read_idx[1] >= 16)
1589         res = 0x01;
1590      else
1591         res = (m_joypad[1].buttons >> (15 - m_read_idx[1]++)) & 0x01;
1592      break;
1593   case 2: /* SNES Mouse */
1594      if (m_read_idx[1] >= 32)
1595         res = 0x01;
1596      else if (m_read_idx[1] >= 24)
1597         res = (m_mouse[1].deltax >> (31 - m_read_idx[1]++)) & 0x01;
1598      else if (m_read_idx[1] >= 16)
1599         res = (m_mouse[1].deltay >> (23 - m_read_idx[1]++)) & 0x01;
1600      else if (m_read_idx[1] >= 8)
1601         res = (m_mouse[1].buttons >> (15 - m_read_idx[1]++)) & 0x01;
1602      else
1603         res = 0;
1604      break;
1605   case 3: /* SNES Superscope */
1606      if (m_read_idx[1] >= 8)
1607         res = 0x01;
1608      else
1609         res = (m_scope[1].buttons >> (7 - m_read_idx[1]++)) & 0x01;
1610      break;
1611   case 0: /* no controller in port2 */
1612   default:
1613      break;
1783      case 1: // SNES joypad
1784         return input_serial_pad(1, latched, FALSE);
1785
1786      case 2: // SNES Mouse
1787         return input_serial_mouse(1, latched);
1788
1789      case 3: // SNES Superscope
1790         return input_serial_sscope(1, latched);
1791
1792      case 5: // SNES multipad
1793         return input_serial_pad(1, latched, TRUE);
1794
1795      case 0: // empty port1
1796      default:
1797         return 0;
16141798   }
1615
1616   return res;
16171799}
16181800
16191801/*************************************
r23750r23751
17841966//          set_5a22_map(m_maincpu);
17851967         break;
17861968   }
1969
1970   for (int i = 0; i < 2; i++)
1971   {
1972      save_item(NAME(m_mouse[i].x), i);
1973      save_item(NAME(m_mouse[i].oldx), i);
1974      save_item(NAME(m_mouse[i].y), i);
1975      save_item(NAME(m_mouse[i].oldy), i);
1976      save_item(NAME(m_mouse[i].buttons), i);
1977      save_item(NAME(m_mouse[i].deltax), i);
1978      save_item(NAME(m_mouse[i].deltay), i);
1979      save_item(NAME(m_mouse[i].speed), i);
1980      save_item(NAME(m_scope[i].x), i);
1981      save_item(NAME(m_scope[i].y), i);
1982      save_item(NAME(m_scope[i].buttons), i);
1983      save_item(NAME(m_scope[i].turbo_lock), i);
1984      save_item(NAME(m_scope[i].pause_lock), i);
1985      save_item(NAME(m_scope[i].fire_lock), i);
1986      save_item(NAME(m_scope[i].offscreen), i);
1987   }
17871988}
17881989
17891990void snes_console_state::machine_reset()
17901991{
17911992   snes_state::machine_reset();
1792
1793   m_io_read = write8_delegate(FUNC(snes_console_state::snes_input_read),this);
1794   m_oldjoy1_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy1_read),this);
1795   m_oldjoy2_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy2_read),this);
17961993}
17971994
17981995

Previous 199869 Revisions Next


© 1997-2024 The MAME Team