Previous 199869 Revisions Next

r34627 Monday 26th January, 2015 at 21:46:33 UTC by Fabio Priuli
(MESS) nes: converted input code to use slot devices. this means that now you
change the emulated controllers (Zapper, NES Four Score Adapter, Bandai
Power Pad and Family Trainer, Famicom Keyboard Component, Arkanoid Vaus
Paddle and Mahjong Controller) via the Slot Device menu of the UI interface and
not anymore from the System Configurations menu. Also, changing controller now
requires to reset the system, so please take some time *before* starting the game
if you want to play a game that uses particular controllers. [Fabio Priuli]

(MESS) nes: added emulation of the Konami Hyper Shot controllers, which are
necessary to play Hyper Olympics and Hyper Sports for Famicom. [Fabio Priuli]

(MESS) nes: added emulation of the Yonezawa Party Tap controllers, which are
necessary to play in more than two players some quiz games for Famicom. [Fabio
Priuli]

(MESS) nes: added emulation of the Pachinko controller used by a few pachinko
games for Famicom. [Fabio Priuli]

(MESS) nes: added emulation of the Epoch Barcode Battler unit (even if only as
Famicom controller, and not as a standalone unit) which is necessary to play
Barcode World for Famicom. [Fabio Priuli]
[src/emu/bus]bus.mak
[src/emu/bus/nes_ctrl]4score.c* 4score.h* arkpaddle.c* arkpaddle.h* bcbattle.c* bcbattle.h* ctrl.c* ctrl.h* fckeybrd.c* fckeybrd.h* ftrainer.c* ftrainer.h* hori.c* hori.h* joypad.c* joypad.h* konamihs.c* konamihs.h* miracle.c* miracle.h* mjpanel.c* mjpanel.h* pachinko.c* pachinko.h* partytap.c* partytap.h* powerpad.c* powerpad.h* suborkey.c* suborkey.h* zapper.c* zapper.h*
[src/mess]mess.mak
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c

trunk/src/emu/bus/bus.mak
r243138r243139
10871087
10881088#-------------------------------------------------
10891089#
1090#@src/emu/bus/nes_ctrl/ctrl.h,BUSES += NES_CTRL
1091#-------------------------------------------------
1092
1093ifneq ($(filter NES_CTRL,$(BUSES)),)
1094OBJDIRS += $(BUSOBJ)/nes_ctrl
1095BUSOBJS += $(BUSOBJ)/nes_ctrl/ctrl.o
1096BUSOBJS += $(BUSOBJ)/nes_ctrl/joypad.o
1097BUSOBJS += $(BUSOBJ)/nes_ctrl/4score.o
1098BUSOBJS += $(BUSOBJ)/nes_ctrl/arkpaddle.o
1099BUSOBJS += $(BUSOBJ)/nes_ctrl/bcbattle.o
1100BUSOBJS += $(BUSOBJ)/nes_ctrl/ftrainer.o
1101BUSOBJS += $(BUSOBJ)/nes_ctrl/fckeybrd.o
1102BUSOBJS += $(BUSOBJ)/nes_ctrl/hori.o
1103BUSOBJS += $(BUSOBJ)/nes_ctrl/konamihs.o
1104BUSOBJS += $(BUSOBJ)/nes_ctrl/miracle.o
1105BUSOBJS += $(BUSOBJ)/nes_ctrl/mjpanel.o
1106BUSOBJS += $(BUSOBJ)/nes_ctrl/pachinko.o
1107BUSOBJS += $(BUSOBJ)/nes_ctrl/partytap.o
1108BUSOBJS += $(BUSOBJ)/nes_ctrl/powerpad.o
1109BUSOBJS += $(BUSOBJ)/nes_ctrl/suborkey.o
1110BUSOBJS += $(BUSOBJ)/nes_ctrl/zapper.o
1111endif
1112
1113#-------------------------------------------------
1114#
10901115#@src/emu/bus/snes/snes_slot.h,BUSES += SNES
10911116#-------------------------------------------------
10921117
trunk/src/emu/bus/nes_ctrl/4score.c
r0r243139
1/**********************************************************************
2
3    Nintendo Entertainment System Four Score Adapter
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8 
9 TODO: current implementation is a HACK, due to limitations of the
10 slot system!
11 A real Four Score would be connected to both the controller ports of
12 the NES, but current core cannot emulate something like this until
13 devices can live their own life and being connected to other devices
14 at request.
15 In current implementation the device has to be mounted separately in
16 the two ports and each enables 2 inputs (this is more or less as hacky
17 as the non-slot previous one, where the 4 ports were always available
18 to the emulated system, but it's not a great consolation :( )
19 Two subdevices are currently used so to warn the user that the first
20 one gives P1+P3 inputs and the second one gives P2+P4 inputs.
21 For the same reason, we don't currently emulate the 2P/4P switch,
22 since we could at best have two switches to disable the second player
23 inputs.
24
25 Note: Two Pads are hardcoded in inputs below, instead of acting as
26 passthrough for 2 standard joypad devices, in order to show in the
27 internal UI that they belong to P1+P3 and P2+P4, otherwise they would
28 be listed as P1+P2 and P3+P4 respectively. This *HAS* to be changed
29 once the slot support in the code has improved (4 standard joypads
30 shall be attached to the unit!)
31
32**********************************************************************/
33
34#include "4score.h"
35
36//**************************************************************************
37//  DEVICE DEFINITIONS
38//**************************************************************************
39
40const device_type NES_4SCORE_P1P3 = &device_creator<nes_4score_p1p3_device>;
41const device_type NES_4SCORE_P2P4 = &device_creator<nes_4score_p2p4_device>;
42
43
44static INPUT_PORTS_START( nes_4score_p1p3 )
45   PORT_START("PAD1")
46   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A") PORT_PLAYER(1)
47   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B") PORT_PLAYER(1)
48   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(1)
49   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(1)
50   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
51   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
52   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
53   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
54
55   PORT_START("PAD3")
56   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A") PORT_PLAYER(3)
57   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B") PORT_PLAYER(3)
58   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(3)
59   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(3)
60   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(3)
61   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3)
62   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3)
63   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3)
64INPUT_PORTS_END
65
66
67static INPUT_PORTS_START( nes_4score_p2p4 )
68   PORT_START("PAD2")
69   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A") PORT_PLAYER(2)
70   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B") PORT_PLAYER(2)
71   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(2)
72   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(2)
73   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
74   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
75   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
76   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
77
78   PORT_START("PAD4")
79   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A") PORT_PLAYER(4)
80   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B") PORT_PLAYER(4)
81   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(4)
82   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(4)
83   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(4)
84   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4)
85   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4)
86   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4)
87INPUT_PORTS_END
88
89
90//-------------------------------------------------
91//  input_ports - device-specific input ports
92//-------------------------------------------------
93
94ioport_constructor nes_4score_p1p3_device::device_input_ports() const
95{
96   return INPUT_PORTS_NAME( nes_4score_p1p3 );
97}
98
99ioport_constructor nes_4score_p2p4_device::device_input_ports() const
100{
101   return INPUT_PORTS_NAME( nes_4score_p2p4 );
102}
103
104
105
106//**************************************************************************
107//  LIVE DEVICE
108//**************************************************************************
109
110//-------------------------------------------------
111//  nes_4score_device - constructor
112//-------------------------------------------------
113
114nes_4score_device::nes_4score_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
115               : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
116                  device_nes_control_port_interface(mconfig, *this)
117{
118}
119
120nes_4score_p1p3_device::nes_4score_p1p3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
121               nes_4score_device(mconfig, NES_4SCORE_P1P3, "Nintendo Four Score Adapter P1/P3", tag, owner, clock, "nes_4score_p1p3", __FILE__),
122               m_joypad1(*this, "PAD1"),
123               m_joypad3(*this, "PAD3")
124{
125}
126
127nes_4score_p2p4_device::nes_4score_p2p4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
128               nes_4score_device(mconfig, NES_4SCORE_P2P4, "Nintendo Four Score Adapter P2/P4", tag, owner, clock, "nes_4score_p2p4", __FILE__),
129               m_joypad2(*this, "PAD2"),
130               m_joypad4(*this, "PAD4")
131{
132}
133
134
135//-------------------------------------------------
136//  device_start
137//-------------------------------------------------
138
139void nes_4score_device::device_start()
140{
141   save_item(NAME(m_latch));
142}
143
144
145//-------------------------------------------------
146//  device_reset
147//-------------------------------------------------
148
149void nes_4score_device::device_reset()
150{
151   m_latch = 0;
152}
153
154
155//-------------------------------------------------
156//  read
157//-------------------------------------------------
158
159UINT8 nes_4score_device::read_bit0()
160{
161   UINT8 ret = m_latch & 1;
162   m_latch >>= 1;
163   return ret;
164}
165
166//-------------------------------------------------
167//  write
168//-------------------------------------------------
169
170void nes_4score_p1p3_device::write(UINT8 data)
171{
172   if (data & 0x01)
173      return;
174   
175   // P3 & P4 inputs in NES Four Score are read serially with P1 & P2
176   m_latch  = m_joypad1->read();
177   m_latch |= (m_joypad3->read() << 8); // pad 3
178   m_latch |= (0x08 << 16); // signature
179}
180
181void nes_4score_p2p4_device::write(UINT8 data)
182{
183   if (data & 0x01)
184      return;
185   
186   // P3 & P4 inputs in NES Four Score are read serially with P1 & P2
187   m_latch = m_joypad2->read();
188   m_latch |= (m_joypad4->read() << 8); // pad 4
189   m_latch |= (0x04 << 16); // signature
190}
trunk/src/emu/bus/nes_ctrl/4score.h
r0r243139
1/**********************************************************************
2
3    Nintendo Entertainment System Four Score Adapter
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_FOURSCORE__
13#define __NES_FOURSCORE__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_4score_device
24
25class nes_4score_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_4score_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
31
32protected:
33   // device-level overrides
34   virtual void device_start();
35   virtual void device_reset();
36
37   virtual UINT8 read_bit0();
38
39protected:
40   UINT32 m_latch;
41};
42
43// ======================> nes_4score_p1p3_device
44
45class nes_4score_p1p3_device : public nes_4score_device
46{
47public:
48   // construction/destruction
49   nes_4score_p1p3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
50   
51   virtual ioport_constructor device_input_ports() const;
52   
53protected:
54   virtual void write(UINT8 data);
55   
56private:
57   required_ioport m_joypad1;
58   required_ioport m_joypad3;
59};
60
61// ======================> nes_4score_p2p4_device
62
63class nes_4score_p2p4_device : public nes_4score_device
64{
65public:
66   // construction/destruction
67   nes_4score_p2p4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
68
69   virtual ioport_constructor device_input_ports() const;
70   
71protected:
72   virtual void write(UINT8 data);
73   
74private:
75   required_ioport m_joypad2;
76   required_ioport m_joypad4;
77};
78
79
80// device type definition
81extern const device_type NES_4SCORE_P1P3;
82extern const device_type NES_4SCORE_P2P4;
83
84
85#endif
trunk/src/emu/bus/nes_ctrl/arkpaddle.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System -
4    Arkanoid Paddle input device
5
6    Copyright MESS Team.
7    Visit http://mamedev.org for licensing and usage restrictions.
8
9**********************************************************************/
10
11#include "arkpaddle.h"
12
13//**************************************************************************
14//  DEVICE DEFINITIONS
15//**************************************************************************
16
17const device_type NES_ARKPADDLE = &device_creator<nes_vaus_device>;
18const device_type NES_ARKPADDLE_FC = &device_creator<nes_vausfc_device>;
19
20
21static INPUT_PORTS_START( arkanoid_paddle )
22   PORT_START("PADDLE")
23   PORT_BIT( 0xff, 0x7f, IPT_PADDLE) PORT_SENSITIVITY(25) PORT_KEYDELTA(25) PORT_CENTERDELTA(0) PORT_MINMAX(0x62,0xf2)
24   PORT_START("BUTTON")
25   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle button")
26INPUT_PORTS_END
27
28
29//-------------------------------------------------
30//  input_ports - device-specific input ports
31//-------------------------------------------------
32
33ioport_constructor nes_vaus_device::device_input_ports() const
34{
35   return INPUT_PORTS_NAME( arkanoid_paddle );
36}
37
38
39
40//**************************************************************************
41//  LIVE DEVICE
42//**************************************************************************
43
44//-------------------------------------------------
45//  nes_vaus_device - constructor
46//-------------------------------------------------
47
48nes_vaus_device::nes_vaus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
49               : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
50                  device_nes_control_port_interface(mconfig, *this),
51                  m_paddle(*this, "PADDLE"),
52                  m_button(*this, "BUTTON")
53{
54}
55
56nes_vaus_device::nes_vaus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
57               device_t(mconfig, NES_ARKPADDLE, "Arkanoid Vaus NES Controller", tag, owner, clock, "nes_vaus", __FILE__),
58               device_nes_control_port_interface(mconfig, *this),
59               m_paddle(*this, "PADDLE"),
60               m_button(*this, "BUTTON")
61{
62}
63
64nes_vausfc_device::nes_vausfc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
65               nes_vaus_device(mconfig, NES_ARKPADDLE_FC, "Arkanoid Vaus FC Controller", tag, owner, clock, "nes_vausfc", __FILE__)
66{
67}
68
69
70//-------------------------------------------------
71//  device_start
72//-------------------------------------------------
73
74void nes_vaus_device::device_start()
75{
76   save_item(NAME(m_latch));
77   save_item(NAME(m_start_conv));
78}
79
80
81//-------------------------------------------------
82//  device_reset
83//-------------------------------------------------
84
85void nes_vaus_device::device_reset()
86{
87   m_latch = 0;
88   m_start_conv = 0;
89}
90
91
92//-------------------------------------------------
93//  read
94//-------------------------------------------------
95
96UINT8 nes_vaus_device::read_bit34()
97{
98   UINT8 ret = (m_button->read() << 3);
99   ret |= (m_latch & 0x80) >> 3;
100   m_latch <<= 1;
101   m_latch &= 0xff;
102   return ret;
103}
104
105UINT8 nes_vausfc_device::read_exp(offs_t offset)
106{
107   UINT8 ret = 0;
108   if (offset == 0)   //$4016
109      ret = m_button->read() << 1;
110   else   //$4017
111   {
112      ret = (m_latch & 0x80) >> 6;
113      m_latch <<= 1;
114      m_latch &= 0xff;
115   }
116   return ret;
117}
118
119//-------------------------------------------------
120//  write
121//-------------------------------------------------
122
123void nes_vaus_device::write(UINT8 data)
124{
125   int old = m_start_conv;
126
127   if (data == 0 && old == 1)
128      m_latch = (UINT8) (m_paddle->read() ^ 0xff);
129
130   m_start_conv = data;
131}
trunk/src/emu/bus/nes_ctrl/arkpaddle.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System -
4    Arkanoid Paddle input device
5
6    Copyright MESS Team.
7    Visit http://mamedev.org for licensing and usage restrictions.
8
9**********************************************************************/
10
11#pragma once
12
13#ifndef __NES_ARKPADDLE__
14#define __NES_ARKPADDLE__
15
16
17#include "emu.h"
18#include "ctrl.h"
19
20//**************************************************************************
21//  TYPE DEFINITIONS
22//**************************************************************************
23
24// ======================> nes_vaus_device
25
26class nes_vaus_device : public device_t,
27                     public device_nes_control_port_interface
28{
29public:
30   // construction/destruction
31   nes_vaus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
32   nes_vaus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
33
34   // optional information overrides
35   virtual ioport_constructor device_input_ports() const;
36
37protected:
38   // device-level overrides
39   virtual void device_start();
40   virtual void device_reset();
41
42   virtual UINT8 read_bit34();
43   virtual void write(UINT8 data);
44
45   required_ioport m_paddle;
46   required_ioport m_button;
47   UINT8 m_start_conv;
48   UINT32 m_latch;
49};
50
51
52// ======================> nes_vaus_device
53
54class nes_vausfc_device : public nes_vaus_device
55{
56public:
57   // construction/destruction
58   nes_vausfc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
59   
60protected:
61   virtual UINT8 read_bit34() { return 0; }
62   virtual UINT8 read_exp(offs_t offset);
63};
64
65
66// device type definition
67extern const device_type NES_ARKPADDLE;
68extern const device_type NES_ARKPADDLE_FC;
69
70
71#endif
trunk/src/emu/bus/nes_ctrl/bcbattle.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer - Epoch Barcode Battler
4
5    TODO: this should be actually emulated as a standalone system with
6    a few 7segments LEDs, once we get a dump of its BIOS
7    At the moment we only emulated the connection with a Famicom
8 
9    Copyright MESS Team.
10    Visit http://mamedev.org for licensing and usage restrictions.
11
12**********************************************************************/
13
14#include "bcbattle.h"
15
16//**************************************************************************
17//  DEVICE DEFINITIONS
18//**************************************************************************
19
20const device_type NES_BARCODE_BATTLER = &device_creator<nes_bcbattle_device>;
21
22
23static INPUT_PORTS_START( nes_battler )
24INPUT_PORTS_END
25
26//-------------------------------------------------
27//  input_ports - device-specific input ports
28//-------------------------------------------------
29
30ioport_constructor nes_bcbattle_device::device_input_ports() const
31{
32   return INPUT_PORTS_NAME( nes_battler );
33}
34
35MACHINE_CONFIG_FRAGMENT( nes_battler )
36   MCFG_BARCODE_READER_ADD("battler")
37MACHINE_CONFIG_END
38
39machine_config_constructor nes_bcbattle_device::device_mconfig_additions() const
40{
41   return MACHINE_CONFIG_NAME( nes_battler );
42}
43
44
45//-------------------------------------------------
46//  device_timer - handler timer events
47//-------------------------------------------------
48
49void nes_bcbattle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
50{
51   if (id == TIMER_BATTLER)
52   {
53      int old = m_new_code;
54      // has something new been scanned?
55      if (old < m_reader->get_pending_code())
56      {
57         if (m_reader->get_byte_length() == 13)
58         {
59            for (int i = 0; i < 13; i++)
60               m_current_barcode[i] = m_reader->read_code() + '0';
61         }
62         else if (m_reader->get_byte_length() == 8)
63         {
64            for (int i = 0; i < 5; i++)
65               m_current_barcode[i] = 0x20;
66            for (int i = 5; i < 13; i++)
67               m_current_barcode[i] = m_reader->read_code() + '0';
68         }
69         // read one more, to reset the internal byte counter
70         m_reader->read_code();
71
72         // the string "SUNSOFT" is accepted as well by Barcode World
73         m_current_barcode[13] = 'E';
74         m_current_barcode[14] = 'P';
75         m_current_barcode[15] = 'O';
76         m_current_barcode[16] = 'C';
77         m_current_barcode[17] = 'H';
78         m_current_barcode[18] = 0x0d;
79         m_current_barcode[19] = 0x0a;
80         m_pending_code = 1;
81      }
82      m_new_code = m_reader->get_pending_code();
83   }
84}
85
86//**************************************************************************
87//  LIVE DEVICE
88//**************************************************************************
89
90//-------------------------------------------------
91//  nes_bcbattle_device - constructor
92//-------------------------------------------------
93
94nes_bcbattle_device::nes_bcbattle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
95               device_t(mconfig, NES_BARCODE_BATTLER, "Epoch Barcode Battler", tag, owner, clock, "nes_bcbattle", __FILE__),
96               device_nes_control_port_interface(mconfig, *this),
97               m_reader(*this, "battler")
98{
99}
100
101
102//-------------------------------------------------
103//  device_start
104//-------------------------------------------------
105
106void nes_bcbattle_device::device_start()
107{
108   // lacking emulation of the standalone Barcode Battler, we refresh periodically the input from the reader
109   // proper emulation would have the standalone unit acknowledging that a new barcode has been scanned
110   // and sending the proper serial bits, instead of our read_current_bit() function!
111   battler_timer = timer_alloc(TIMER_BATTLER);
112   battler_timer->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(1000));
113   
114   save_item(NAME(m_current_barcode));
115   save_item(NAME(m_new_code));
116   save_item(NAME(m_pending_code));
117   save_item(NAME(m_transmitting));
118   save_item(NAME(m_cur_bit));
119   save_item(NAME(m_cur_byte));
120}
121
122
123//-------------------------------------------------
124//  device_reset
125//-------------------------------------------------
126
127void nes_bcbattle_device::device_reset()
128{
129   m_pending_code = 0;
130   m_new_code = 0;
131   m_transmitting = 0;
132   m_cur_bit = 0;
133   m_cur_byte = 0;
134   memset(m_current_barcode, 0, ARRAY_LENGTH(m_current_barcode));
135}
136
137
138//-------------------------------------------------
139//  read
140//-------------------------------------------------
141
142int nes_bcbattle_device::read_current_bit()
143{
144   if (m_pending_code && !m_transmitting)
145   {
146      // we start with 1
147      m_transmitting = 1;
148      m_cur_byte = 0;
149      m_cur_bit = 0;
150      return 1;
151   }
152
153   if (m_transmitting)
154   {
155      if (m_cur_bit == 0)
156      {
157         m_cur_bit++;
158         return 1;
159      }
160      if (m_cur_bit < 9)
161      {
162         int bit = (BIT(m_current_barcode[m_cur_byte], m_cur_bit - 1)) ^ 1;
163         m_cur_bit++;
164         return bit;
165      }
166      if (m_cur_bit == 9)
167      {
168         m_cur_bit = 0;
169         //printf("%X ", m_current_barcode[m_cur_byte]);
170         m_cur_byte++;
171         if (m_cur_byte == 20)
172         {
173            m_cur_byte = 0;
174            m_transmitting = 0;
175            m_pending_code = 0;
176         }
177         return 0;
178      }
179   }
180
181   return 0;
182}
183
184UINT8 nes_bcbattle_device::read_exp(offs_t offset)
185{
186   UINT8 ret = 0;
187   if (offset == 1)   //$4017
188   {
189      ret |= read_current_bit() << 2;
190   }
191
192   return ret;
193}
trunk/src/emu/bus/nes_ctrl/bcbattle.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer - Epoch Barcode Battler
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_BCBATTLE__
13#define __NES_BCBATTLE__
14
15
16#include "emu.h"
17#include "ctrl.h"
18#include "machine/bcreader.h"
19
20//**************************************************************************
21//  TYPE DEFINITIONS
22//**************************************************************************
23
24// ======================> nes_bcbattle_device
25
26class nes_bcbattle_device : public device_t,
27                     public device_nes_control_port_interface
28{
29public:
30   // construction/destruction
31   nes_bcbattle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
32
33   virtual ioport_constructor device_input_ports() const;
34   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
35   virtual machine_config_constructor device_mconfig_additions() const;
36
37protected:
38   // device-level overrides
39   virtual void device_start();
40   virtual void device_reset();
41
42   virtual UINT8 read_exp(offs_t offset);
43   int read_current_bit();
44
45   static const device_timer_id TIMER_BATTLER = 1;
46   required_device<barcode_reader_device> m_reader;
47   UINT8 m_current_barcode[20];
48   int m_pending_code, m_new_code, m_transmitting, m_cur_bit, m_cur_byte;
49   emu_timer *battler_timer;
50};
51
52// device type definition
53extern const device_type NES_BARCODE_BATTLER;
54
55#endif
trunk/src/emu/bus/nes_ctrl/ctrl.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System controller ports
4    and Family Computer expansion port emulation
5
6    Here we emulate in fact 3 different kind of ports, which are
7    connected to different bis of memory locations $4016 and $4017:
8    - NES controller ports: these are hooked to bit 0,3,4 of the
9      corresponding address ($4016 for port1, $4017 for port2)
10    - FC controller ports: these are only hooked to bit 0 of the
11      corresponding address (so that e.g. a NES Zapper could not
12      be connected to a later FC AV model, because its inputs
13      would not be detected)
14    - FC expansion port: this is hooked to bits 0-4 of both addresses
15    To make things a little bit more complex, old FC models have the
16    controller hardwired to the unit, and the P2 controllers are
17    directly hooked also to one of the expansion port lines (namely,
18    microphone inputs from P2 go to $4016 bit 2)
19
20    Even if the controller port and the expansion port are
21    physically different (the FC expansion is a 15pin port, while
22    the controller ports are 7pin), we emulate them as variants of a
23    common device, exposing the following handlers:
24    - read_bit0: for bit0 reads, which are typically used for serial
25      inputs from controllers
26    - read_bit34: for bit3,4 reading, expected to be at the correct
27      offset (but we don't currently check for read_bit34 & 0xf8==0)
28    - read_exp: for reads going through the expansion, with a offset
29      parameter to decide whether we are reading from $4016 and $4017
30    - write: to acknowledge writes to $4016
31
32    The driver emulation will take care to only call the correct
33    handlers they have hooks for: Basic usage is that the expansion
34    port calls read_exp, FC ctrl ports call read_bit0, and NES ctrl
35    ports call both read_bit0 and read_bit34. However, to cope with
36    the original FC microphone, we will have the second controller
37    port calling read_exp too.
38
39    Copyright MESS Team.
40    Visit http://mamedev.org for licensing and usage restrictions.
41
42**********************************************************************/
43
44#include "ctrl.h"
45// slot devices
46#include "4score.h"
47#include "arkpaddle.h"
48#include "bcbattle.h"
49#include "ftrainer.h"
50#include "fckeybrd.h"
51#include "hori.h"
52#include "joypad.h"
53#include "konamihs.h"
54#include "miracle.h"
55#include "mjpanel.h"
56#include "pachinko.h"
57#include "partytap.h"
58#include "powerpad.h"
59#include "suborkey.h"
60#include "zapper.h"
61
62
63//**************************************************************************
64//  GLOBAL VARIABLES
65//**************************************************************************
66
67const device_type NES_CONTROL_PORT = &device_creator<nes_control_port_device>;
68
69
70
71//**************************************************************************
72//  CARD INTERFACE
73//**************************************************************************
74
75//-------------------------------------------------
76//  device_nes_control_port_interface - constructor
77//-------------------------------------------------
78
79device_nes_control_port_interface::device_nes_control_port_interface(const machine_config &mconfig, device_t &device) :
80                           device_slot_card_interface(mconfig, device)
81{
82   m_port = dynamic_cast<nes_control_port_device *>(device.owner());
83}
84
85
86//-------------------------------------------------
87//  ~device_nes_control_port_interface - destructor
88//-------------------------------------------------
89
90device_nes_control_port_interface::~device_nes_control_port_interface()
91{
92}
93
94
95
96//**************************************************************************
97//  LIVE DEVICE
98//**************************************************************************
99
100//-------------------------------------------------
101//  nes_control_port_device - constructor
102//-------------------------------------------------
103
104nes_control_port_device::nes_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
105                  device_t(mconfig, NES_CONTROL_PORT, "Nintendo NES/FC control port", tag, owner, clock, "nes_control_port", __FILE__),
106                  device_slot_interface(mconfig, *this)
107{
108}
109
110
111//-------------------------------------------------
112//  nes_control_port_device - destructor
113//-------------------------------------------------
114
115nes_control_port_device::~nes_control_port_device()
116{
117}
118
119
120//-------------------------------------------------
121//  device_start - device-specific startup
122//-------------------------------------------------
123
124void nes_control_port_device::device_start()
125{
126   m_device = dynamic_cast<device_nes_control_port_interface *>(get_card_device());
127   m_brightpixel_cb.bind_relative_to(*owner());
128}
129
130
131UINT8 nes_control_port_device::read_bit0()
132{
133   UINT8 data = 0;
134   if (m_device)
135      data = m_device->read_bit0();
136   return data;
137}
138
139UINT8 nes_control_port_device::read_bit34()
140{
141   UINT8 data = 0;
142   if (m_device)
143      data = m_device->read_bit34();
144   return data;
145}
146
147UINT8 nes_control_port_device::read_exp(offs_t offset)
148{
149   UINT8 data = 0;
150   if (m_device)
151      data = m_device->read_exp(offset);
152   return data;
153}
154
155void nes_control_port_device::write(UINT8 data)
156{
157   if (m_device)
158      m_device->write(data);
159}
160
161
162
163//-------------------------------------------------
164//  SLOT_INTERFACE( nes_control_port_devices )
165//-------------------------------------------------
166
167SLOT_INTERFACE_START( nes_control_port1_devices )
168   SLOT_INTERFACE("joypad", NES_JOYPAD)
169   SLOT_INTERFACE("zapper", NES_ZAPPER)
170   SLOT_INTERFACE("4score_p1p3", NES_4SCORE_P1P3)
171//   SLOT_INTERFACE("miracle_piano", NES_MIRACLE)
172SLOT_INTERFACE_END
173
174SLOT_INTERFACE_START( nes_control_port2_devices )
175   SLOT_INTERFACE("joypad", NES_JOYPAD)
176   SLOT_INTERFACE("zapper", NES_ZAPPER)
177   SLOT_INTERFACE("vaus", NES_ARKPADDLE)
178   SLOT_INTERFACE("powerpad", NES_POWERPAD)
179   SLOT_INTERFACE("4score_p2p4", NES_4SCORE_P2P4)
180SLOT_INTERFACE_END
181
182SLOT_INTERFACE_START( fc_control_port1_devices )
183   SLOT_INTERFACE("joypad", NES_JOYPAD)
184   SLOT_INTERFACE("ccpad_left", NES_CCPAD_LEFT)
185SLOT_INTERFACE_END
186
187SLOT_INTERFACE_START( fc_control_port2_devices )
188   SLOT_INTERFACE("joypad", NES_JOYPAD)
189   SLOT_INTERFACE("joypad_old", NES_FCPAD_P2)
190   SLOT_INTERFACE("ccpad_right", NES_CCPAD_RIGHT)
191SLOT_INTERFACE_END
192
193SLOT_INTERFACE_START( fc_expansion_devices )
194   SLOT_INTERFACE("joypad", NES_JOYPAD)
195   SLOT_INTERFACE("arcstick", NES_ARCSTICK)
196   SLOT_INTERFACE("fc_keyboard", NES_FCKEYBOARD)
197   SLOT_INTERFACE("zapper", NES_ZAPPER)
198   SLOT_INTERFACE("vaus", NES_ARKPADDLE_FC)
199   SLOT_INTERFACE("family_trainer", NES_FTRAINER)
200   SLOT_INTERFACE("konamihs", NES_KONAMIHS)
201   SLOT_INTERFACE("mj_panel", NES_MJPANEL)
202   SLOT_INTERFACE("pachinko", NES_PACHINKO)
203   SLOT_INTERFACE("partytap", NES_PARTYTAP)
204   SLOT_INTERFACE("hori_twin", NES_HORITWIN)
205   SLOT_INTERFACE("hori_4p", NES_HORI4P)
206   SLOT_INTERFACE("barcode_battler", NES_BARCODE_BATTLER)
207   SLOT_INTERFACE("subor_keyboard", NES_SUBORKEYBOARD)
208SLOT_INTERFACE_END
trunk/src/emu/bus/nes_ctrl/ctrl.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System controller port
4    emulation
5
6    Copyright MESS Team.
7    Visit http://mamedev.org for licensing and usage restrictions.
8
9**********************************************************************
10
11
12**********************************************************************/
13
14#pragma once
15
16#ifndef __NES_CONTROL_PORT__
17#define __NES_CONTROL_PORT__
18
19#include "emu.h"
20
21//**************************************************************************
22//  TYPE DEFINITIONS
23//**************************************************************************
24
25class nes_control_port_device;
26
27// ======================> device_nes_control_port_interface
28
29class device_nes_control_port_interface : public device_slot_card_interface
30{
31public:
32   // construction/destruction
33   device_nes_control_port_interface(const machine_config &mconfig, device_t &device);
34   virtual ~device_nes_control_port_interface();
35   
36   virtual UINT8 read_bit0() { return 0; };
37   virtual UINT8 read_bit34() { return 0; };
38   virtual UINT8 read_exp(offs_t offset) { return 0; };
39   virtual void write(UINT8 data) { };
40   
41protected:
42   nes_control_port_device *m_port;
43};
44
45
46typedef device_delegate<bool (int x, int y)> nesctrl_brightpixel_delegate;
47#define NESCTRL_BRIGHTPIXEL_CB(name)  bool name(int x, int y)
48
49
50// ======================> nes_control_port_device
51
52class nes_control_port_device : public device_t,
53                        public device_slot_interface
54{
55public:
56   // construction/destruction
57   nes_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
58   virtual ~nes_control_port_device();
59
60   static void set_brightpixel_callback(device_t &device, nesctrl_brightpixel_delegate callback) { downcast<nes_control_port_device &>(device).m_brightpixel_cb = callback; }
61
62   UINT8 read_bit0();
63   UINT8 read_bit34();
64   UINT8 read_exp(offs_t offset);
65   void write(UINT8 data);
66
67   nesctrl_brightpixel_delegate m_brightpixel_cb;
68
69protected:
70   // device-level overrides
71   virtual void device_start();
72   device_nes_control_port_interface *m_device;
73};
74
75
76// device type definition
77extern const device_type NES_CONTROL_PORT;
78
79
80//**************************************************************************
81//  INTERFACE CONFIGURATION MACROS
82//**************************************************************************
83
84#define MCFG_NES_CONTROL_PORT_ADD(_tag, _slot_intf, _def_slot) \
85   MCFG_DEVICE_ADD(_tag, NES_CONTROL_PORT, 0) \
86   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
87
88// currently this is emulated as a control port...
89#define MCFG_FC_EXPANSION_PORT_ADD(_tag, _slot_intf, _def_slot) \
90   MCFG_DEVICE_ADD(_tag, NES_CONTROL_PORT, 0) \
91   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
92
93#define MCFG_NESCTRL_BRIGHTPIXEL_CB(_class, _method) \
94   nes_control_port_device::set_brightpixel_callback(*device, nesctrl_brightpixel_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
95
96
97SLOT_INTERFACE_EXTERN( nes_control_port1_devices );
98SLOT_INTERFACE_EXTERN( nes_control_port2_devices );
99SLOT_INTERFACE_EXTERN( fc_control_port1_devices );
100SLOT_INTERFACE_EXTERN( fc_control_port2_devices );
101SLOT_INTERFACE_EXTERN( fc_expansion_devices );
102
103
104#endif
trunk/src/emu/bus/nes_ctrl/fckeybrd.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Keyboard Component
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "fckeybrd.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_FCKEYBOARD = &device_creator<nes_fckeybrd_device>;
17
18
19static INPUT_PORTS_START( fc_keyboard )
20   PORT_START("FCKEY.0")
21   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
22   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)         
23   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR('[')
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']')   
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Kana")                             
26   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RSHIFT)                     
27   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)    PORT_CHAR('\\')
28   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_BACKSPACE)
29
30   PORT_START("FCKEY.1")
31   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
32   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')
33   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')   
34   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';')   
35   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('_')                             
36   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('/')                             
37   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')   
38   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('^')
39
40   PORT_START("FCKEY.2")
41   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
42   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
43   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
44   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
45   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)  PORT_CHAR('.')
46   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')
47   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P')
48   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
49
50   PORT_START("FCKEY.3")
51   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
52   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
53   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
54   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
55   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
56   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
57   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')
58   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
59
60   PORT_START("FCKEY.4")
61   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
62   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
63   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
64   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
65   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
66   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
67   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')
68   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
69
70   PORT_START("FCKEY.5")
71   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
72   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
73   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
74   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
75   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
76   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
77   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')
78   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')
79
80   PORT_START("FCKEY.6")
81   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
82   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
83   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
84   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
85   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
86   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
87   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
88   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
89
90   PORT_START("FCKEY.7")
91   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))         
92   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_MAMEKEY(ESC))       
93   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')                       
94   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2) 
95   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)        PORT_CHAR(UCHAR_SHIFT_1) 
96   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Grph") PORT_CODE(KEYCODE_LALT)     
97   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')           
98   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')           
99
100   PORT_START("FCKEY.8")
101   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Clr")                               
102   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP)    PORT_CHAR(UCHAR_MAMEKEY(UP))     
103   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))   
104   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))     
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))     
106   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)     PORT_CHAR(' ')   
107   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Del") PORT_CODE(KEYCODE_DEL)       
108   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ins") PORT_CODE(KEYCODE_INSERT)     
109INPUT_PORTS_END
110
111
112//-------------------------------------------------
113//  input_ports - device-specific input ports
114//-------------------------------------------------
115
116ioport_constructor nes_fckeybrd_device::device_input_ports() const
117{
118   return INPUT_PORTS_NAME( fc_keyboard );
119}
120
121
122static MACHINE_CONFIG_FRAGMENT( fc_keyboard )
123   MCFG_CASSETTE_ADD("tape")
124   MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)
125   MCFG_CASSETTE_INTERFACE("fc_cass")
126MACHINE_CONFIG_END
127
128
129//-------------------------------------------------
130//  machine_config_additions - device-specific
131//  machine configurations
132//-------------------------------------------------
133
134machine_config_constructor nes_fckeybrd_device::device_mconfig_additions() const
135{
136   return MACHINE_CONFIG_NAME( fc_keyboard );
137}
138
139
140//**************************************************************************
141//  LIVE DEVICE
142//**************************************************************************
143
144//-------------------------------------------------
145//  nes_fckeybrd_device - constructor
146//-------------------------------------------------
147
148nes_fckeybrd_device::nes_fckeybrd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
149               device_t(mconfig, NES_FCKEYBOARD, "Nintendo Family Computer Keyboard Component", tag, owner, clock, "nes_fckeybrd", __FILE__),
150               device_nes_control_port_interface(mconfig, *this),
151               m_cassette(*this, "tape"),
152               m_kbd(*this, "FCKEY")
153{
154}
155
156
157//-------------------------------------------------
158//  device_start
159//-------------------------------------------------
160
161void nes_fckeybrd_device::device_start()
162{
163   save_item(NAME(m_fck_scan));
164   save_item(NAME(m_fck_mode));
165}
166
167
168//-------------------------------------------------
169//  device_reset
170//-------------------------------------------------
171
172void nes_fckeybrd_device::device_reset()
173{
174   m_fck_scan = 0;
175   m_fck_mode = 0;
176}
177
178
179//-------------------------------------------------
180//  read
181//-------------------------------------------------
182
183UINT8 nes_fckeybrd_device::read_exp(offs_t offset)
184{
185   UINT8 ret = 0;
186   if (offset == 0)   //$4016
187   {
188      // FC Keyboard: tape input
189      if ((m_cassette->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)
190      {
191         double level = m_cassette->input();
192         if (level < 0)
193            ret |= 0x00;
194         else
195            ret |= 0x02;
196      }
197   }
198   else   //$4017
199   {
200      // FC Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4
201      if (m_fck_scan < 9)
202         ret |= ~(((m_kbd[m_fck_scan]->read() >> (m_fck_mode * 4)) & 0x0f) << 1) & 0x1e;
203      else
204         ret |= 0x1e;
205   }
206
207   return ret;
208}
209
210//-------------------------------------------------
211//  write
212//-------------------------------------------------
213
214void nes_fckeybrd_device::write(UINT8 data)
215{
216   // tape output (not fully tested)
217   if ((m_cassette->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_RECORD)
218      m_cassette->output(((data & 0x07) == 0x07) ? +1.0 : -1.0);
219   
220   if (BIT(data, 2))   // keyboard active
221   {
222      UINT8 out = BIT(data, 1);   // scan
223     
224      if (m_fck_mode && !out && ++m_fck_scan > 9)
225         m_fck_scan = 0;
226     
227      m_fck_mode = out;   // access lower or upper 4 bits
228     
229      if (BIT(data, 0))   // reset
230         m_fck_scan = 0;
231   }
232}
trunk/src/emu/bus/nes_ctrl/fckeybrd.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Keyboard Component
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_FCKEYBRD__
13#define __NES_FCKEYBRD__
14
15
16#include "emu.h"
17#include "ctrl.h"
18#include "imagedev/cassette.h"
19
20//**************************************************************************
21//  TYPE DEFINITIONS
22//**************************************************************************
23
24// ======================> nes_fckeybrd_device
25
26class nes_fckeybrd_device : public device_t,
27                     public device_nes_control_port_interface
28{
29public:
30   // construction/destruction
31   nes_fckeybrd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
32
33   virtual ioport_constructor device_input_ports() const;
34   virtual machine_config_constructor device_mconfig_additions() const;
35
36protected:
37   // device-level overrides
38   virtual void device_start();
39   virtual void device_reset();
40
41   virtual UINT8 read_exp(offs_t offset);
42   virtual void write(UINT8 data);
43
44private:
45   required_device<cassette_image_device> m_cassette;
46   required_ioport_array<9> m_kbd;
47   UINT8 m_fck_scan, m_fck_mode;
48};
49
50
51// device type definition
52extern const device_type NES_FCKEYBOARD;
53
54
55#endif
trunk/src/emu/bus/nes_ctrl/ftrainer.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer - Bandai Family Trainer Mat
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "ftrainer.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_FTRAINER = &device_creator<nes_ftrainer_device>;
17
18
19static INPUT_PORTS_START( nes_joypad )
20   PORT_START("LAYOUT")
21   PORT_CONFNAME( 0x01, 0x00, "Family Trainer Button Layout")
22   PORT_CONFSETTING(  0x00, "Side A" )
23   PORT_CONFSETTING(  0x01, "Side B" )
24
25   // difference between the two sides is that we mirror the key mapping to match the real pad layout!
26   PORT_START("FT_COL.0")
27   // side A layout
28   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
29   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid1")  PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
30   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
31   // side B layout
32   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 12")    PORT_CODE(KEYCODE_M) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
33   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 8")     PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
34   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 4")     PORT_CODE(KEYCODE_U) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
35
36   PORT_START("FT_COL.1")
37   // side A layout
38   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low1")  PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
39   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid2")  PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
40   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top1")  PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
41   // side B layout
42   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 11")    PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
43   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 7")     PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
44   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 3")     PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
45
46   PORT_START("FT_COL.2")
47   // side A layout
48   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low2")  PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
49   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid3")  PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
50   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top2")  PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
51   // side B layout
52   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 10")    PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
53   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 6")     PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
54   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 2")     PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
55
56   PORT_START("FT_COL.3")
57   // side A layout
58   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
59   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid4")  PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
60   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
61   // side B layout
62   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 9")     PORT_CODE(KEYCODE_V) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
63   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 5")     PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
64   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 1")     PORT_CODE(KEYCODE_R) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
65INPUT_PORTS_END
66
67
68//-------------------------------------------------
69//  input_ports - device-specific input ports
70//-------------------------------------------------
71
72ioport_constructor nes_ftrainer_device::device_input_ports() const
73{
74   return INPUT_PORTS_NAME( nes_joypad );
75}
76
77
78
79//**************************************************************************
80//  LIVE DEVICE
81//**************************************************************************
82
83//-------------------------------------------------
84//  nes_ftrainer_device - constructor
85//-------------------------------------------------
86
87nes_ftrainer_device::nes_ftrainer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
88               device_t(mconfig, NES_FTRAINER, "Bandai Family Trainer", tag, owner, clock, "nes_famtrain", __FILE__),
89               device_nes_control_port_interface(mconfig, *this),
90               m_trainer(*this, "FT_COL")
91{
92}
93
94
95//-------------------------------------------------
96//  device_start
97//-------------------------------------------------
98
99void nes_ftrainer_device::device_start()
100{
101   save_item(NAME(m_row_scan));
102}
103
104
105//-------------------------------------------------
106//  device_reset
107//-------------------------------------------------
108
109void nes_ftrainer_device::device_reset()
110{
111   m_row_scan = 0;
112}
113
114
115//-------------------------------------------------
116//  read
117//-------------------------------------------------
118
119UINT8 nes_ftrainer_device::read_exp(offs_t offset)
120{
121   UINT8 ret = 0;
122   if (offset == 1)   //$4017
123   {
124      if (!BIT(m_row_scan, 0))
125      {
126         // read low line: buttons 9,10,11,12
127         for (int i = 0; i < 4; i++)
128            ret |= ((m_trainer[i]->read() & 0x01) << (1 + i));
129      }
130      else if (!BIT(m_row_scan, 1))
131      {
132         // read mid line: buttons 5,6,7,8
133         for (int i = 0; i < 4; i++)
134            ret |= ((m_trainer[i]->read() & 0x02) << (1 + i));
135      }
136      else if (!BIT(m_row_scan, 2))
137      {
138         // read high line: buttons 1,2,3,4
139         for (int i = 0; i < 4; i++)
140            ret |= ((m_trainer[i]->read() & 0x04) << (1 + i));
141      }
142   }
143   return ret;
144}
145
146//-------------------------------------------------
147//  write
148//-------------------------------------------------
149
150void nes_ftrainer_device::write(UINT8 data)
151{
152   // select row to scan
153   m_row_scan = data & 0x07;
154}
trunk/src/emu/bus/nes_ctrl/ftrainer.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer - Bandai Family Trainer Mat
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_FTRAINER__
13#define __NES_FTRAINER__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_ftrainer_device
24
25class nes_ftrainer_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_ftrainer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_exp(offs_t offset);
40   virtual void write(UINT8 data);
41
42private:
43   required_ioport_array<4> m_trainer;
44   UINT8 m_row_scan;
45};
46
47
48// device type definition
49extern const device_type NES_FTRAINER;
50
51
52#endif
trunk/src/emu/bus/nes_ctrl/hori.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Hori Twin (and 4P?) adapters
4 
5    Emulation of the 4Players adapter is quite pointless: if 2P mode
6    (default mode) it behaves like a Hori Twin adapter, in 4P mode
7    it has P1 and P2 inputs overwriting the inputs coming from the
8    main controllers (possibly creating a bit of confusion, since
9    you get 6 sets of inputs with only 4 acknowledged by the running
10    system).
11    For the moment we keep it available for documentation purposes.
12
13    TODO: find out confirmation whether in 2P mode, inputs from joypads
14    connected to the 4players adapter are really seen as P3 and P4 inputs.
15    it seems the most reasonable setup (so that users with only 2
16    external pads can use the adapter in 4P games), but one never knows...
17
18    Copyright MESS Team.
19    Visit http://mamedev.org for licensing and usage restrictions.
20
21**********************************************************************/
22
23#include "hori.h"
24#include "joypad.h"
25
26//**************************************************************************
27//  DEVICE DEFINITIONS
28//**************************************************************************
29
30const device_type NES_HORITWIN = &device_creator<nes_horitwin_device>;
31const device_type NES_HORI4P = &device_creator<nes_hori4p_device>;
32
33
34static INPUT_PORTS_START( nes_hori4p )
35   PORT_START("CONFIG")
36   PORT_CONFNAME( 0x01, 0x00, "4 Players / 2 Players")
37   PORT_CONFSETTING(  0x00, "2 Players" )
38   PORT_CONFSETTING(  0x01, "4 Players" )
39INPUT_PORTS_END
40
41
42//-------------------------------------------------
43//  input_ports - device-specific input ports
44//-------------------------------------------------
45
46ioport_constructor nes_hori4p_device::device_input_ports() const
47{
48   return INPUT_PORTS_NAME( nes_hori4p );
49}
50
51
52static SLOT_INTERFACE_START( hori_adapter )
53   SLOT_INTERFACE("joypad", NES_JOYPAD)
54SLOT_INTERFACE_END
55
56static MACHINE_CONFIG_FRAGMENT( horitwin )
57   MCFG_FC_EXPANSION_PORT_ADD("port1", hori_adapter, "joypad")
58   MCFG_FC_EXPANSION_PORT_ADD("port2", hori_adapter, "joypad")
59MACHINE_CONFIG_END
60
61static MACHINE_CONFIG_FRAGMENT( hori4p )
62   MCFG_FC_EXPANSION_PORT_ADD("port1", hori_adapter, "joypad")
63   MCFG_FC_EXPANSION_PORT_ADD("port2", hori_adapter, "joypad")
64   MCFG_FC_EXPANSION_PORT_ADD("port3", hori_adapter, "joypad")
65   MCFG_FC_EXPANSION_PORT_ADD("port4", hori_adapter, "joypad")
66MACHINE_CONFIG_END
67
68
69//-------------------------------------------------
70//  machine_config_additions - device-specific
71//  machine configurations
72//-------------------------------------------------
73
74machine_config_constructor nes_horitwin_device::device_mconfig_additions() const
75{
76   return MACHINE_CONFIG_NAME( horitwin );
77}
78
79machine_config_constructor nes_hori4p_device::device_mconfig_additions() const
80{
81   return MACHINE_CONFIG_NAME( hori4p );
82}
83
84
85//**************************************************************************
86//  LIVE DEVICE
87//**************************************************************************
88
89//-------------------------------------------------
90//  nes_horitwin_device - constructor
91//-------------------------------------------------
92
93nes_horitwin_device::nes_horitwin_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
94               device_t(mconfig, NES_HORITWIN, "Hori Twin Adapter", tag, owner, clock, "nes_horitwin", __FILE__),
95               device_nes_control_port_interface(mconfig, *this),
96               m_port1(*this, "port1"),
97               m_port2(*this, "port2")
98{
99}
100
101nes_hori4p_device::nes_hori4p_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
102               device_t(mconfig, NES_HORI4P, "Hori 4P Adapter", tag, owner, clock, "nes_hori4p", __FILE__),
103               device_nes_control_port_interface(mconfig, *this),
104               m_port1(*this, "port1"),
105               m_port2(*this, "port2"),
106               m_port3(*this, "port3"),
107               m_port4(*this, "port4"),
108               m_cfg(*this, "CONFIG")
109{
110}
111
112
113//-------------------------------------------------
114//  read
115//-------------------------------------------------
116
117UINT8 nes_horitwin_device::read_exp(offs_t offset)
118{
119   UINT8 ret = 0;
120   if (offset == 0)   //$4016
121      ret |= (m_port1->read_bit0() << 1);
122   else   //$4017
123      ret |= (m_port2->read_bit0() << 1);
124   return ret;
125}
126
127UINT8 nes_hori4p_device::read_exp(offs_t offset)
128{
129   UINT8 ret = 0;
130   if (m_cfg->read() == 0)   // 2P
131   {
132      if (offset == 0)   //$4016
133         ret |= (m_port1->read_bit0() << 1);
134      else   //$4017
135         ret |= (m_port2->read_bit0() << 1);
136   }
137   else   // 4P
138   {
139      if (offset == 0)   //$4016
140      {
141         ret |= (m_port1->read_bit0() << 0);
142         ret |= (m_port3->read_bit0() << 1);
143      }
144      else   //$4017
145      {
146         ret |= (m_port2->read_bit0() << 0);
147         ret |= (m_port4->read_bit0() << 1);
148      }
149   }
150   return ret;
151}
152
153//-------------------------------------------------
154//  write
155//-------------------------------------------------
156
157void nes_horitwin_device::write(UINT8 data)
158{
159   m_port1->write(data);
160   m_port2->write(data);
161}
162
163void nes_hori4p_device::write(UINT8 data)
164{
165   m_port1->write(data);
166   m_port2->write(data);
167   m_port3->write(data);
168   m_port4->write(data);
169}
trunk/src/emu/bus/nes_ctrl/hori.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Hori Twin (and 4P?) adapters
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_HORI__
13#define __NES_HORI__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_horitwin_device
24
25class nes_horitwin_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_horitwin_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual machine_config_constructor device_mconfig_additions() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start() {}
37
38   virtual UINT8 read_exp(offs_t offset);
39   virtual void write(UINT8 data);
40
41private:
42   required_device<nes_control_port_device> m_port1;
43   required_device<nes_control_port_device> m_port2;
44};
45
46// ======================> nes_hori4p_device
47
48class nes_hori4p_device : public device_t,
49                     public device_nes_control_port_interface
50{
51public:
52   // construction/destruction
53   nes_hori4p_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
54   
55   virtual ioport_constructor device_input_ports() const;
56   virtual machine_config_constructor device_mconfig_additions() const;
57   
58protected:   
59   // device-level overrides
60   virtual void device_start() {}
61   
62   virtual UINT8 read_exp(offs_t offset);
63   virtual void write(UINT8 data);
64   
65private:
66   required_device<nes_control_port_device> m_port1;
67   required_device<nes_control_port_device> m_port2;
68   required_device<nes_control_port_device> m_port3;
69   required_device<nes_control_port_device> m_port4;
70   required_ioport m_cfg;
71};
72
73
74// device type definition
75extern const device_type NES_HORITWIN;
76extern const device_type NES_HORI4P;
77
78
79#endif
trunk/src/emu/bus/nes_ctrl/joypad.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System Joypads
4
5    The original Famicom had two hardwired controller, with the second
6    controller slightly different from the first one: it featured no
7    Start nor Select buttons, but had a built-in microphone (with
8    very limited capabilities, since it basically only detected two
9    states: something blowing into it / nothing blowing into it) for
10    some games to react to users "talking" into it
11 
12    Crazy Climber Pads are not really a kind of separate controllers,
13    but just a couple of small sticks to be put on top of d-pads of
14    the regular controllers. Users should then control the game by
15    using both controllers, turned 90 degrees, as a couple of dual
16    sticks like in the arcade control panel. However, we emulate them
17    separately so to map the controls to a friendlier default.
18
19    The Arcade Stick we emulate is a controller (apparently manufactured
20    by Hori, but possibly licensed by Nintendo, since it use the official
21    logo and brand) which fits into the expansion port and allows to
22    daisy chain a second controller to the first one, to play 4players
23    game (an image of such connection is shown e.g. in Nekketsu Koukou
24    Dodgeball Bu manual)
25 
26    Copyright MESS Team.
27    Visit http://mamedev.org for licensing and usage restrictions.
28
29**********************************************************************/
30
31#include "joypad.h"
32
33//**************************************************************************
34//  DEVICE DEFINITIONS
35//**************************************************************************
36
37const device_type NES_JOYPAD = &device_creator<nes_joypad_device>;
38const device_type NES_FCPAD_P2 = &device_creator<nes_fcpad2_device>;
39const device_type NES_CCPAD_LEFT = &device_creator<nes_ccpadl_device>;
40const device_type NES_CCPAD_RIGHT = &device_creator<nes_ccpadr_device>;
41const device_type NES_ARCSTICK = &device_creator<nes_arcstick_device>;
42
43
44static INPUT_PORTS_START( nes_joypad )
45   PORT_START("JOYPAD")
46   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
47   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
48   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
49   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
50   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
51   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
52   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
53   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
54INPUT_PORTS_END
55
56static INPUT_PORTS_START( nes_fcpad_p2 )
57   PORT_START("JOYPAD")
58   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
59   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
60   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("Microphone")
61   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
62   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
63   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
64   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
65   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
66INPUT_PORTS_END
67
68static INPUT_PORTS_START( nes_ccpad_left )
69   PORT_START("JOYPAD")
70   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
71   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
72   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
73   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
74   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_8WAY
75   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_8WAY
76   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_8WAY
77   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_8WAY
78INPUT_PORTS_END
79
80static INPUT_PORTS_START( nes_ccpad_right )
81   PORT_START("JOYPAD")
82   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
83   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
84   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
85   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
86   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_8WAY
87   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_8WAY
88   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_8WAY
89   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_8WAY
90INPUT_PORTS_END
91
92static INPUT_PORTS_START( nes_arcstick )
93   PORT_START("CONFIG")
94   PORT_CONFNAME( 0x01, 0x01, "4 Way / 8 Way Joystick")
95   PORT_CONFSETTING(  0x00, "4 Way" )
96   PORT_CONFSETTING(  0x01, "8 Way" )
97   PORT_CONFNAME( 0x02, 0x00, "Player ID")
98   PORT_CONFSETTING(  0x00, "Player I" )
99   PORT_CONFSETTING(  0x02, "Player II" )
100
101   PORT_START("JOYPAD")
102   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
103   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
104   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
105   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
106   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY      PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
107   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
108   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
109   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
110   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY      PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
111   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
112   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
113   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
114INPUT_PORTS_END
115
116//-------------------------------------------------
117//  input_ports - device-specific input ports
118//-------------------------------------------------
119
120ioport_constructor nes_joypad_device::device_input_ports() const
121{
122   return INPUT_PORTS_NAME( nes_joypad );
123}
124
125ioport_constructor nes_fcpad2_device::device_input_ports() const
126{
127   return INPUT_PORTS_NAME( nes_fcpad_p2 );
128}
129
130ioport_constructor nes_ccpadl_device::device_input_ports() const
131{
132   return INPUT_PORTS_NAME( nes_ccpad_left );
133}
134
135ioport_constructor nes_ccpadr_device::device_input_ports() const
136{
137   return INPUT_PORTS_NAME( nes_ccpad_right );
138}
139
140ioport_constructor nes_arcstick_device::device_input_ports() const
141{
142   return INPUT_PORTS_NAME( nes_arcstick );
143}
144
145
146
147static SLOT_INTERFACE_START( arcstick_daisy )
148   SLOT_INTERFACE("arcstick", NES_ARCSTICK)
149SLOT_INTERFACE_END
150
151static MACHINE_CONFIG_FRAGMENT( arcstick )
152   // expansion port to allow daisy chaining
153   MCFG_FC_EXPANSION_PORT_ADD("subexp", arcstick_daisy, NULL)
154MACHINE_CONFIG_END
155
156
157//-------------------------------------------------
158//  machine_config_additions - device-specific
159//  machine configurations
160//-------------------------------------------------
161
162machine_config_constructor nes_arcstick_device::device_mconfig_additions() const
163{
164   return MACHINE_CONFIG_NAME( arcstick );
165}
166
167
168
169//**************************************************************************
170//  LIVE DEVICE
171//**************************************************************************
172
173//-------------------------------------------------
174//  nes_joypad_device - constructor
175//-------------------------------------------------
176
177nes_joypad_device::nes_joypad_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
178               device_t(mconfig, type, name, tag, owner, clock, shortname, source),
179               device_nes_control_port_interface(mconfig, *this),
180               m_joypad(*this, "JOYPAD")
181{
182}
183
184nes_joypad_device::nes_joypad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
185               device_t(mconfig, NES_JOYPAD, "Nintendo NES / FC Control Pad", tag, owner, clock, "nes_joypad", __FILE__),
186               device_nes_control_port_interface(mconfig, *this),
187               m_joypad(*this, "JOYPAD")
188{
189}
190
191nes_fcpad2_device::nes_fcpad2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
192               nes_joypad_device(mconfig, NES_FCPAD_P2, "Nintendo Family Computer P2 Pad", tag, owner, clock, "nes_fcpad2", __FILE__)
193{
194}
195
196nes_ccpadl_device::nes_ccpadl_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
197               nes_joypad_device(mconfig, NES_CCPAD_LEFT, "Crazy Climber Left Pad", tag, owner, clock, "nes_ccpadl", __FILE__)
198{
199}
200
201nes_ccpadr_device::nes_ccpadr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
202               nes_joypad_device(mconfig, NES_CCPAD_RIGHT, "Crazy Climber Right Pad", tag, owner, clock, "nes_ccpadr", __FILE__)
203{
204}
205
206nes_arcstick_device::nes_arcstick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
207                  nes_joypad_device(mconfig, NES_ARCSTICK, "Nintendo Family Computer Arcade Stick", tag, owner, clock, "nes_arcstick", __FILE__),
208                  m_daisychain(*this, "subexp"),
209                  m_cfg(*this, "CONFIG")
210{
211}
212
213
214//-------------------------------------------------
215//  device_start
216//-------------------------------------------------
217
218void nes_joypad_device::device_start()
219{
220   save_item(NAME(m_latch));
221}
222
223
224//-------------------------------------------------
225//  device_reset
226//-------------------------------------------------
227
228void nes_joypad_device::device_reset()
229{
230   m_latch = 0;
231}
232
233
234//-------------------------------------------------
235//  read
236//-------------------------------------------------
237
238UINT8 nes_joypad_device::read_bit0()
239{
240   UINT8 ret = m_latch & 1;
241   m_latch >>= 1;
242   return ret;
243}
244
245UINT8 nes_fcpad2_device::read_exp(offs_t offset)
246{
247   UINT8 ret = 0;
248   if (!offset)   // microphone input
249      ret |= m_joypad->read() & 0x04;
250
251   return ret;
252}
253
254// NOTE: I haven't found any documentation about what happens when
255// users connect two arcade stick both set as P1 or P2 in config.
256// does the FC only acknowledge the first one, or do they conflict
257// with each other? currently, we only support the following setup:
258// if the first pad is set as P1, the daisy chained pad is checked
259// for P2 only, and vice versa.
260UINT8 nes_arcstick_device::read_exp(offs_t offset)
261{
262   UINT8 ret = 0;
263   if (offset == 0)   //$4016
264   {
265      if ((m_cfg->read() & 2) == 0)   // we are P1 input
266      {
267         ret |= (m_latch & 1) << 1;
268         m_latch >>= 1;
269      }
270      else
271         ret |= m_daisychain->read_exp(0);
272   }
273   else    //$4017
274   {
275      if ((m_cfg->read() & 2) == 2)   // we are P2 input
276      {
277         ret |= (m_latch & 1) << 1;
278         m_latch >>= 1;
279      }
280      else
281         ret |= m_daisychain->read_exp(1);
282   }
283   
284   return ret;
285}
286
287//-------------------------------------------------
288//  write
289//-------------------------------------------------
290
291void nes_joypad_device::write(UINT8 data)
292{
293   if (data & 0x01)
294      return;
295   
296   m_latch = m_joypad->read();
297}
298
299void nes_fcpad2_device::write(UINT8 data)
300{
301   if (data & 0x01)
302      return;
303
304   // microphone is hooked to expansion bits, not to the controller bit
305   m_latch = m_joypad->read() & ~0x04;
306}
307
308void nes_arcstick_device::write(UINT8 data)
309{
310   m_daisychain->write(data);
311
312   if (data & 0x01)
313      return;
314   
315   m_latch = m_joypad->read();
316}
317
trunk/src/emu/bus/nes_ctrl/joypad.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System Joypads
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_JOYPAD__
13#define __NES_JOYPAD__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_joypad_device
24
25class nes_joypad_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_joypad_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
31   nes_joypad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
32
33   virtual ioport_constructor device_input_ports() const;
34
35protected:
36   // device-level overrides
37   virtual void device_start();
38   virtual void device_reset();
39
40   virtual UINT8 read_bit0();
41   virtual void write(UINT8 data);
42
43   required_ioport m_joypad;
44   UINT32 m_latch;
45};
46
47// ======================> nes_fcpad2_device
48
49class nes_fcpad2_device : public nes_joypad_device
50{
51public:
52   // construction/destruction
53   nes_fcpad2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
54   
55   virtual ioport_constructor device_input_ports() const;
56   
57protected:
58   virtual UINT8 read_exp(offs_t offset);
59   virtual void write(UINT8 data);
60};
61
62// ======================> nes_ccpadl_device
63
64class nes_ccpadl_device : public nes_joypad_device
65{
66public:
67   // construction/destruction
68   nes_ccpadl_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
69   
70   virtual ioport_constructor device_input_ports() const;
71};
72
73// ======================> nes_ccpadr_device
74
75class nes_ccpadr_device : public nes_joypad_device
76{
77public:
78   // construction/destruction
79   nes_ccpadr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
80   
81   virtual ioport_constructor device_input_ports() const;
82};
83
84// ======================> nes_arcstick_device
85
86class nes_arcstick_device : public nes_joypad_device
87{
88public:
89   // construction/destruction
90   nes_arcstick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
91   
92   virtual ioport_constructor device_input_ports() const;
93   virtual machine_config_constructor device_mconfig_additions() const;
94
95protected:
96   virtual UINT8 read_bit0() { return 0; }
97   virtual UINT8 read_exp(offs_t offset);
98   virtual void write(UINT8 data);
99   
100   required_device<nes_control_port_device> m_daisychain;
101   required_ioport m_cfg;
102};
103
104
105// device type definition
106extern const device_type NES_JOYPAD;
107extern const device_type NES_FCPAD_P2;
108extern const device_type NES_CCPAD_LEFT;
109extern const device_type NES_CCPAD_RIGHT;
110extern const device_type NES_ARCSTICK;
111
112#endif
trunk/src/emu/bus/nes_ctrl/konamihs.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Konami Hyper Shot Controllers
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "konamihs.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_KONAMIHS = &device_creator<nes_konamihs_device>;
17
18
19static INPUT_PORTS_START( nes_konamihs )
20   PORT_START("P1")
21   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("PI Run")
22   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("PI Jump")
23
24   PORT_START("P2")
25   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("PII Run")
26   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("PII Jump")
27INPUT_PORTS_END
28
29//-------------------------------------------------
30//  input_ports - device-specific input ports
31//-------------------------------------------------
32
33ioport_constructor nes_konamihs_device::device_input_ports() const
34{
35   return INPUT_PORTS_NAME( nes_konamihs );
36}
37
38//**************************************************************************
39//  LIVE DEVICE
40//**************************************************************************
41
42//-------------------------------------------------
43//  nes_konamihs_device - constructor
44//-------------------------------------------------
45
46nes_konamihs_device::nes_konamihs_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
47               device_t(mconfig, NES_KONAMIHS, "Konami Hyper Shot Controller", tag, owner, clock, "nes_konamihs", __FILE__),
48               device_nes_control_port_interface(mconfig, *this),
49               m_ipt_p1(*this, "P1"),
50               m_ipt_p2(*this, "P2")
51{
52}
53
54
55//-------------------------------------------------
56//  device_start
57//-------------------------------------------------
58
59void nes_konamihs_device::device_start()
60{
61   save_item(NAME(m_latch_p1));
62   save_item(NAME(m_latch_p2));
63}
64
65
66//-------------------------------------------------
67//  device_reset
68//-------------------------------------------------
69
70void nes_konamihs_device::device_reset()
71{
72   m_latch_p1 = 0;
73   m_latch_p2 = 0;
74}
75
76
77//-------------------------------------------------
78//  read
79//-------------------------------------------------
80
81UINT8 nes_konamihs_device::read_exp(offs_t offset)
82{
83   UINT8 ret = 0;
84   if (offset == 1)   //$4017
85   {
86      ret |= m_latch_p1 << 1;
87      ret |= m_latch_p2 << 3;
88   }
89   return ret;
90}
91
92//-------------------------------------------------
93//  write
94//-------------------------------------------------
95
96void nes_konamihs_device::write(UINT8 data)
97{
98   if ((data & 0x02) == 0)
99      m_latch_p1 = m_ipt_p1->read();
100   if ((data & 0x04) == 0)
101      m_latch_p2 = m_ipt_p2->read();
102}
trunk/src/emu/bus/nes_ctrl/konamihs.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Konami Hyper Shot Controllers
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_KONAMIHS__
13#define __NES_KONAMIHS__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_konamihs_device
24
25class nes_konamihs_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_konamihs_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_exp(offs_t offset);
40   virtual void write(UINT8 data);
41
42   required_ioport m_ipt_p1;
43   required_ioport m_ipt_p2;
44   UINT32 m_latch_p1, m_latch_p2;
45};
46
47// device type definition
48extern const device_type NES_KONAMIHS;
49
50#endif
trunk/src/emu/bus/nes_ctrl/miracle.c
r0r243139
1/**********************************************************************
2
3    Nintendo Entertainment System - Miracle Piano Keyboard
4 
5    TODO: basically everything, this is just a skeleton with no
6    real MIDI handling at the moment.
7
8    Copyright MESS Team.
9    Visit http://mamedev.org for licensing and usage restrictions.
10
11**********************************************************************/
12
13#include "miracle.h"
14#include "bus/midi/midi.h"
15
16#define MIRACLE_MIDI_WAITING 0
17#define MIRACLE_MIDI_RECEIVE 1
18#define MIRACLE_MIDI_SEND 2
19
20//**************************************************************************
21//  DEVICE DEFINITIONS
22//**************************************************************************
23
24const device_type NES_MIRACLE = &device_creator<nes_miracle_device>;
25
26
27MACHINE_CONFIG_FRAGMENT( nes_miracle )
28//   MCFG_CPU_ADD("piano_cpu", I8051, XTAL_11_0592MHz)   // xtal to be verified
29
30   MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
31   MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
32MACHINE_CONFIG_END
33
34machine_config_constructor nes_miracle_device::device_mconfig_additions() const
35{
36   return MACHINE_CONFIG_NAME( nes_miracle );
37}
38
39
40//-------------------------------------------------
41//  device_timer - handler timer events
42//-------------------------------------------------
43
44void nes_miracle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
45{
46   if (id == TIMER_STROBE_ON)
47   {
48      m_strobe_clock++;
49   }
50}
51
52//**************************************************************************
53//  LIVE DEVICE
54//**************************************************************************
55
56//-------------------------------------------------
57//  nes_miracle_device - constructor
58//-------------------------------------------------
59
60nes_miracle_device::nes_miracle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
61               device_t(mconfig, NES_MIRACLE, "Miracle Piano Controller", tag, owner, clock, "nes_miracle", __FILE__)
62               , device_nes_control_port_interface(mconfig, *this)
63//               , m_cpu(*this, "piano_cpu")
64{
65}
66
67
68//-------------------------------------------------
69//  device_start
70//-------------------------------------------------
71
72void nes_miracle_device::device_start()
73{
74   strobe_timer = timer_alloc(TIMER_STROBE_ON);
75   strobe_timer->adjust(attotime::never);
76   save_item(NAME(m_strobe_on));
77   save_item(NAME(m_sent_bits));
78   save_item(NAME(m_strobe_clock));
79   save_item(NAME(m_midi_mode));
80}
81
82
83//-------------------------------------------------
84//  device_reset
85//-------------------------------------------------
86
87void nes_miracle_device::device_reset()
88{
89   m_strobe_on = 0;
90   m_sent_bits = 0;
91   m_strobe_clock = 0;
92   m_midi_mode = MIRACLE_MIDI_WAITING;
93}
94
95
96//-------------------------------------------------
97//  read
98//-------------------------------------------------
99
100// TODO: here, reads from serial midi in bit0, when in MIDI_SEND mode
101
102UINT8 nes_miracle_device::read_bit0()
103{
104   UINT8 ret = 0;
105   if (m_strobe_clock >= 66)
106   {
107      // more than 66 clocks since strobe on write means send mode
108      m_midi_mode = MIRACLE_MIDI_SEND;
109      strobe_timer->reset();
110      m_strobe_on = 0;
111      m_strobe_clock = 0;
112//      printf("send start\n");
113   }
114
115   if (m_midi_mode == MIRACLE_MIDI_SEND)
116   {
117      //NES reads from Miracle Piano!
118      // ret |= ...
119   }
120
121   return ret;
122}
123
124//-------------------------------------------------
125//  write
126//-------------------------------------------------
127
128// TODO: here, writes to serial midi in bit0, when in MIDI_RECEIVE mode
129
130void nes_miracle_device::write(UINT8 data)
131{
132   if (data == 1 && !m_strobe_on)
133   {
134      strobe_timer->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(1));
135      m_strobe_on = 1;
136      return;
137   }
138   
139   if (m_strobe_on)
140   {
141      // was timer running?
142      if (m_strobe_clock > 0)
143      {
144         if (m_strobe_clock < 66 && data == 0)
145         {
146            // less than 66 clocks before new write means receive mode
147            m_midi_mode = MIRACLE_MIDI_RECEIVE;
148//            printf("receive start\n");
149            strobe_timer->reset();
150            m_strobe_on = 0;
151            m_strobe_clock = 0;
152            return;
153         }
154      }
155
156      if (m_midi_mode == MIRACLE_MIDI_SEND &&  data == 0)
157      {
158         // strobe off after the end of a byte
159         m_midi_mode = MIRACLE_MIDI_WAITING;
160//         printf("send end\n");
161      }
162   }
163
164   if (m_midi_mode == MIRACLE_MIDI_RECEIVE)
165   {
166      //NES writes (data & 1) to Miracle Piano!
167      // 1st write is data present flag (1=data present)
168      // next 8 writes are actual data bits (with ^1)
169      m_sent_bits++;
170      // then we go back to waiting
171      if (m_sent_bits == 9)
172      {
173//         printf("receive end\n");
174         m_midi_mode = MIRACLE_MIDI_WAITING;
175         m_sent_bits = 0;
176      }
177   }
178}
trunk/src/emu/bus/nes_ctrl/miracle.h
r0r243139
1/**********************************************************************
2
3    Nintendo Entertainment System - Miracle Piano Keyboard
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_MIRACLE__
13#define __NES_MIRACLE__
14
15
16#include "emu.h"
17#include "ctrl.h"
18//#include "cpu/mcs51/mcs51.h"
19
20//**************************************************************************
21//  TYPE DEFINITIONS
22//**************************************************************************
23
24// ======================> nes_miracle_device
25
26class nes_miracle_device : public device_t,
27                     public device_nes_control_port_interface
28{
29public:
30   // construction/destruction
31   nes_miracle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
32
33   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
34   virtual machine_config_constructor device_mconfig_additions() const;
35
36protected:
37   // device-level overrides
38   virtual void device_start();
39   virtual void device_reset();
40
41   virtual UINT8 read_bit0();
42   virtual void write(UINT8 data);
43
44   static const device_timer_id TIMER_STROBE_ON = 0;
45   emu_timer *strobe_timer;
46
47   //required_device<i8051_device> m_cpu;
48   int m_strobe_on, m_midi_mode, m_sent_bits;
49   UINT32 m_strobe_clock;
50};
51
52// device type definition
53extern const device_type NES_MIRACLE;
54
55#endif
trunk/src/emu/bus/nes_ctrl/mjpanel.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Mahjong Panel
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "mjpanel.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_MJPANEL = &device_creator<nes_mjpanel_device>;
17
18
19static INPUT_PORTS_START( nes_mjpanel )
20   PORT_START("MJPANEL.0")
21   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
22
23   PORT_START("MJPANEL.1")
24   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
25   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_N )
26   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_M )
27   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
28   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
29   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
30   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
31
32   PORT_START("MJPANEL.2")
33   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
34   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
35   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
36   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
37   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
38   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
39   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
40   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
41
42   PORT_START("MJPANEL.3")
43   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
44   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_RON )
45   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH )
46   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI )
47   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_PON )
48   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN )
49   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("Mahjong Select")
50   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("Mahjong Start")
51INPUT_PORTS_END
52
53
54//-------------------------------------------------
55//  input_ports - device-specific input ports
56//-------------------------------------------------
57
58ioport_constructor nes_mjpanel_device::device_input_ports() const
59{
60   return INPUT_PORTS_NAME( nes_mjpanel );
61}
62
63
64
65//**************************************************************************
66//  LIVE DEVICE
67//**************************************************************************
68
69//-------------------------------------------------
70//  nes_mjpanel_device - constructor
71//-------------------------------------------------
72
73nes_mjpanel_device::nes_mjpanel_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
74               device_t(mconfig, NES_MJPANEL, "Famicom Mahjong Panel", tag, owner, clock, "nes_mjpanel", __FILE__),
75               device_nes_control_port_interface(mconfig, *this),
76               m_panel(*this, "MJPANEL")
77{
78}
79
80
81//-------------------------------------------------
82//  device_start
83//-------------------------------------------------
84
85void nes_mjpanel_device::device_start()
86{
87   save_item(NAME(m_latch));
88}
89
90
91//-------------------------------------------------
92//  device_reset
93//-------------------------------------------------
94
95void nes_mjpanel_device::device_reset()
96{
97   m_latch = 0;
98}
99
100
101//-------------------------------------------------
102//  read
103//-------------------------------------------------
104
105UINT8 nes_mjpanel_device::read_exp(offs_t offset)
106{
107   UINT8 ret = 0;
108   if (offset)
109   {
110      ret = (m_latch & 1) << 1;
111      m_latch >>= 1;
112   }
113   else
114      logerror("Error: Mahjong panel read from $4016\n");
115
116   return ret;
117}
118
119//-------------------------------------------------
120//  write
121//-------------------------------------------------
122
123void nes_mjpanel_device::write(UINT8 data)
124{
125   if (data & 0x01)
126      return;
127   
128   if (data & 0xf8)
129      logerror("Error: Mahjong panel read with mux data %02x\n", (data & 0xfe));
130   else
131      m_latch = m_panel[(data & 0xfe) >> 1]->read();
132}
trunk/src/emu/bus/nes_ctrl/mjpanel.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Mahjong Panel
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_MJPANEL__
13#define __NES_MJPANEL__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_mjpanel_device
24
25class nes_mjpanel_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_mjpanel_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_exp(offs_t offset);
40   virtual void write(UINT8 data);
41
42private:
43   required_ioport_array<4> m_panel;
44   UINT32 m_latch;
45};
46
47
48// device type definition
49extern const device_type NES_MJPANEL;
50
51
52#endif
trunk/src/emu/bus/nes_ctrl/pachinko.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Pachinko Controller
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "pachinko.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_PACHINKO = &device_creator<nes_pachinko_device>;
17
18
19static INPUT_PORTS_START( nes_pachinko )
20   PORT_START("JOYPAD")
21   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
22   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
23   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
26   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
27   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
28   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
29
30   PORT_START("TRIGGER")
31   PORT_BIT( 0xff, 0, IPT_PEDAL ) PORT_MINMAX(0, 0x63) PORT_SENSITIVITY(25) PORT_KEYDELTA(20)
32INPUT_PORTS_END
33
34//-------------------------------------------------
35//  input_ports - device-specific input ports
36//-------------------------------------------------
37
38ioport_constructor nes_pachinko_device::device_input_ports() const
39{
40   return INPUT_PORTS_NAME( nes_pachinko );
41}
42
43//**************************************************************************
44//  LIVE DEVICE
45//**************************************************************************
46
47//-------------------------------------------------
48//  nes_pachinko_device - constructor
49//-------------------------------------------------
50
51nes_pachinko_device::nes_pachinko_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
52               device_t(mconfig, NES_PACHINKO, "Famicom Pachinko Controller", tag, owner, clock, "nes_pachinko", __FILE__),
53               device_nes_control_port_interface(mconfig, *this),
54               m_joypad(*this, "JOYPAD"),
55               m_trigger(*this, "TRIGGER")
56{
57}
58
59
60//-------------------------------------------------
61//  device_start
62//-------------------------------------------------
63
64void nes_pachinko_device::device_start()
65{
66   save_item(NAME(m_latch));
67}
68
69
70//-------------------------------------------------
71//  device_reset
72//-------------------------------------------------
73
74void nes_pachinko_device::device_reset()
75{
76   m_latch = 0;
77}
78
79
80//-------------------------------------------------
81//  read
82//-------------------------------------------------
83
84UINT8 nes_pachinko_device::read_exp(offs_t offset)
85{
86   UINT8 ret = 0;
87   // this controller behaves like a standard P3 joypad, with longer stream of inputs
88   if (offset == 0)   //$4016
89   {
90      ret |= (m_latch & 1) << 1;
91      m_latch >>= 1;
92   }
93   return ret;
94}
95
96//-------------------------------------------------
97//  write
98//-------------------------------------------------
99
100void nes_pachinko_device::write(UINT8 data)
101{
102   if (data & 0x01)
103      return;
104   
105   m_latch = m_joypad->read();
106   m_latch |= ((m_trigger->read() ^ 0xff) & 0xff) << 8;
107   m_latch |= 0xff0000;
108}
trunk/src/emu/bus/nes_ctrl/pachinko.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Pachinko Controller
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_PACHINKO__
13#define __NES_PACHINKO__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_pachinko_device
24
25class nes_pachinko_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_pachinko_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_exp(offs_t offset);
40   virtual void write(UINT8 data);
41
42   required_ioport m_joypad;
43   required_ioport m_trigger;
44   UINT32 m_latch;
45};
46
47// device type definition
48extern const device_type NES_PACHINKO;
49
50#endif
trunk/src/emu/bus/nes_ctrl/partytap.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Yonezawa / PartyRoom 21 Party Tap Controller
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "partytap.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_PARTYTAP = &device_creator<nes_partytap_device>;
17
18
19static INPUT_PORTS_START( nes_partytap )
20   PORT_START("INPUTS")
21   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
22   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P1 Button") PORT_CODE(KEYCODE_Z)
23   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P2 Button") PORT_CODE(KEYCODE_X)
24   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P3 Button") PORT_CODE(KEYCODE_C)
25   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P4 Button") PORT_CODE(KEYCODE_V)
26   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P5 Button") PORT_CODE(KEYCODE_B)
27   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P6 Button") PORT_CODE(KEYCODE_N)
28INPUT_PORTS_END
29
30//-------------------------------------------------
31//  input_ports - device-specific input ports
32//-------------------------------------------------
33
34ioport_constructor nes_partytap_device::device_input_ports() const
35{
36   return INPUT_PORTS_NAME( nes_partytap );
37}
38
39//**************************************************************************
40//  LIVE DEVICE
41//**************************************************************************
42
43//-------------------------------------------------
44//  nes_partytap_device - constructor
45//-------------------------------------------------
46
47nes_partytap_device::nes_partytap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
48               device_t(mconfig, NES_PARTYTAP, "Yonezawa Party Tap Controller", tag, owner, clock, "nes_partytap", __FILE__),
49               device_nes_control_port_interface(mconfig, *this),
50               m_inputs(*this, "INPUTS")
51{
52}
53
54
55//-------------------------------------------------
56//  device_start
57//-------------------------------------------------
58
59void nes_partytap_device::device_start()
60{
61   save_item(NAME(m_latch));
62   save_item(NAME(m_mode));
63}
64
65
66//-------------------------------------------------
67//  device_reset
68//-------------------------------------------------
69
70void nes_partytap_device::device_reset()
71{
72   m_mode = 0xe0;
73   m_latch = 0;
74}
75
76
77//-------------------------------------------------
78//  read
79//-------------------------------------------------
80
81UINT8 nes_partytap_device::read_exp(offs_t offset)
82{
83   UINT8 ret = 0;
84   if (offset == 1)   //$4017
85   {
86      ret |= m_latch & 0x1c;
87      m_latch >>= 3;
88      // append mode bits
89      m_latch |= m_mode;
90   }
91   return ret;
92}
93
94//-------------------------------------------------
95//  write
96//-------------------------------------------------
97
98void nes_partytap_device::write(UINT8 data)
99{
100   // inputs are read in two chunks of 3 bits, before the second one is read bit2 is written here
101   // probably a mechanism for the game to detect which group of inputs is being read
102   m_mode = BIT(data, 2) ? 0xa0 : 0xe0;
103
104   if (data & 0x01)
105      return;
106
107   m_latch = m_inputs->read();
108}
trunk/src/emu/bus/nes_ctrl/partytap.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Yonezawa / PartyRoom 21 Party Tap Controller
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_PARTYTAP__
13#define __NES_PARTYTAP__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_partytap_device
24
25class nes_partytap_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_partytap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_exp(offs_t offset);
40   virtual void write(UINT8 data);
41
42   required_ioport m_inputs;
43   UINT8 m_mode;
44   UINT32 m_latch;
45};
46
47// device type definition
48extern const device_type NES_PARTYTAP;
49
50#endif
trunk/src/emu/bus/nes_ctrl/powerpad.c
r0r243139
1/**********************************************************************
2
3    Nintendo Entertainment System - Bandai Power Pad
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "powerpad.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_POWERPAD = &device_creator<nes_powerpad_device>;
17
18
19static INPUT_PORTS_START( nes_powerpad )
20   PORT_START("LAYOUT")
21   PORT_CONFNAME( 0x01, 0x00, "Power Pad Button Layout")
22   PORT_CONFSETTING(  0x00, "Side A" )
23   PORT_CONFSETTING(  0x01, "Side B" )
24
25   // difference between the two sides is that we mirror the key mapping to match the real pad layout!
26   PORT_START("POWERPAD1")
27   // side A layout
28   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Top1")  PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
29   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
30   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid1")  PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
31   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
32   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid2")  PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
33   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Low1")  PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
34   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Low2")  PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
35   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid3")  PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
36   // side B layout
37   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 2")     PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
38   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 1")     PORT_CODE(KEYCODE_R) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
39   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 5")     PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
40   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 9")     PORT_CODE(KEYCODE_V) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
41   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 6")     PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
42   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 10")    PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
43   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 11")    PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
44   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 7")     PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
45
46   PORT_START("POWERPAD2")
47   // side A layout
48   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
49   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Top2")  PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
50   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
51   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid4")  PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
52   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00)
53   // side B layout
54   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 4")     PORT_CODE(KEYCODE_U) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
55   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 3")     PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
56   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 12")    PORT_CODE(KEYCODE_M) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
57   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 8")     PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
58   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01)
59INPUT_PORTS_END
60
61
62//-------------------------------------------------
63//  input_ports - device-specific input ports
64//-------------------------------------------------
65
66ioport_constructor nes_powerpad_device::device_input_ports() const
67{
68   return INPUT_PORTS_NAME( nes_powerpad );
69}
70
71
72
73//**************************************************************************
74//  LIVE DEVICE
75//**************************************************************************
76
77//-------------------------------------------------
78//  nes_powerpad_device - constructor
79//-------------------------------------------------
80
81nes_powerpad_device::nes_powerpad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
82               device_t(mconfig, NES_POWERPAD, "Bandai Power Pad", tag, owner, clock, "nes_powerpad", __FILE__),
83               device_nes_control_port_interface(mconfig, *this),
84               m_ipt1(*this, "POWERPAD1"),
85               m_ipt2(*this, "POWERPAD2")
86{
87}
88
89
90//-------------------------------------------------
91//  device_start
92//-------------------------------------------------
93
94void nes_powerpad_device::device_start()
95{
96   save_item(NAME(m_latch));
97}
98
99
100//-------------------------------------------------
101//  device_reset
102//-------------------------------------------------
103
104void nes_powerpad_device::device_reset()
105{
106   m_latch[0] = 0;
107   m_latch[1] = 0;
108}
109
110
111//-------------------------------------------------
112//  read
113//-------------------------------------------------
114
115UINT8 nes_powerpad_device::read_bit34()
116{
117   UINT8 ret = 0;
118   ret |= (m_latch[0] & 0x01) << 3;
119   ret |= (m_latch[1] & 0x01) << 4;
120   m_latch[0] >>= 1;
121   m_latch[1] >>= 1;
122   return ret;
123}
124
125//-------------------------------------------------
126//  write
127//-------------------------------------------------
128
129void nes_powerpad_device::write(UINT8 data)
130{
131   if (data & 0x01)
132      return;
133   
134   m_latch[0] = m_ipt1->read();
135   m_latch[1] = m_ipt2->read() | 0xf0;
136}
trunk/src/emu/bus/nes_ctrl/powerpad.h
r0r243139
1/**********************************************************************
2
3    Nintendo Entertainment System - Bandai Power Pad
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_POWERPAD__
13#define __NES_POWERPAD__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_powerpad_device
24
25class nes_powerpad_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_powerpad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_bit34();
40   virtual void write(UINT8 data);
41
42private:
43   required_ioport m_ipt1;
44   required_ioport m_ipt2;
45   UINT32 m_latch[2];
46};
47
48
49// device type definition
50extern const device_type NES_POWERPAD;
51
52
53#endif
trunk/src/emu/bus/nes_ctrl/suborkey.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Subor Keyboard (used by some Famiclones)
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "suborkey.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_SUBORKEYBOARD = &device_creator<nes_suborkey_device>;
17
18
19static INPUT_PORTS_START( fc_suborkey )
20   PORT_START("SUBOR.0")
21   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')
22   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
23   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
26   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
27   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')
28   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
29
30   PORT_START("SUBOR.1")
31   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')
32   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
33   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
34   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END))
35   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))     
36   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
37   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
38   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
39
40   PORT_START("SUBOR.2")
41   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
42   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)             
43   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NEXT")                                         
44   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
45   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))     
46   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PRIOR")                                     
47   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
48   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME))
49
50   PORT_START("SUBOR.3")
51   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')
52   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
53   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
54   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')       
55   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
56   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
57   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
58   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)  PORT_CHAR('.')
59
60   PORT_START("SUBOR.4")
61   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR(']')       
62   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)             
63   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))     
64   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
65   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))     
66   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')       
67   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')       
68   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
69
70   PORT_START("SUBOR.5")
71   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
72   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
73   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
74   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB)   PORT_CHAR('\t')
75   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))       
76   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
77   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')
78   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2)     
79
80   PORT_START("SUBOR.6")
81   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')
82   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
83   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
84   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
85   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
86   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
87   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
88   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
89
90   PORT_START("SUBOR.7")
91   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')
92   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')
93   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'')
94   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/')
95   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
96   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P)     PORT_CHAR('P')
97   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('=')
98   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)    PORT_CHAR(UCHAR_SHIFT_1) 
99
100   PORT_START("SUBOR.8")
101   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
102   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
103   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
104   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
106   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
107   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
108   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
109
110   PORT_START("SUBOR.9")
111   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
112
113   PORT_START("SUBOR.10")
114   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LMENU")
115   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
116   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
117   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F11)       PORT_CHAR(UCHAR_MAMEKEY(F11))
118   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F12)       PORT_CHAR(UCHAR_MAMEKEY(F12))
119   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
120   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
121   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
122
123   PORT_START("SUBOR.11")
124   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS_PAD)PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
125   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD)  PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))
126   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK)  PORT_CHAR(UCHAR_MAMEKEY(ASTERISK))
127   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))   
128   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))       
129   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))   
130   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH_PAD)PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD))
131   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK)   PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK))
132
133   PORT_START("SUBOR.12")
134   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`')               
135   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
136   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PAUSE")                                         
137   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE2")                                       
138   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))         
139   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
140   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD)       
141   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
142INPUT_PORTS_END
143
144
145//-------------------------------------------------
146//  input_ports - device-specific input ports
147//-------------------------------------------------
148
149ioport_constructor nes_suborkey_device::device_input_ports() const
150{
151   return INPUT_PORTS_NAME( fc_suborkey );
152}
153
154
155
156//**************************************************************************
157//  LIVE DEVICE
158//**************************************************************************
159
160//-------------------------------------------------
161//  nes_suborkey_device - constructor
162//-------------------------------------------------
163
164nes_suborkey_device::nes_suborkey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
165               device_t(mconfig, NES_SUBORKEYBOARD, "FC Subor Keyboard", tag, owner, clock, "nes_suborkey", __FILE__),
166               device_nes_control_port_interface(mconfig, *this),
167               m_kbd(*this, "SUBOR")
168{
169}
170
171
172//-------------------------------------------------
173//  device_start
174//-------------------------------------------------
175
176void nes_suborkey_device::device_start()
177{
178   save_item(NAME(m_fck_scan));
179   save_item(NAME(m_fck_mode));
180}
181
182
183//-------------------------------------------------
184//  device_reset
185//-------------------------------------------------
186
187void nes_suborkey_device::device_reset()
188{
189   m_fck_scan = 0;
190   m_fck_mode = 0;
191}
192
193
194//-------------------------------------------------
195//  read
196//-------------------------------------------------
197
198UINT8 nes_suborkey_device::read_exp(offs_t offset)
199{
200   UINT8 ret = 0;
201   if (offset == 1)   //$4017
202   {
203      // Subor Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4
204      if (m_fck_scan < 13)
205         ret |= ~(((m_kbd[m_fck_scan]->read() >> (m_fck_mode * 4)) & 0x0f) << 1) & 0x1e;
206      else
207         ret |= 0x1e;
208   }
209   
210   return ret;
211}
212
213//-------------------------------------------------
214//  write
215//-------------------------------------------------
216
217void nes_suborkey_device::write(UINT8 data)
218{
219   if (BIT(data, 2))   // keyboard active
220   {
221      UINT8 out = BIT(data, 1);   // scan     
222      if (m_fck_mode && !out && ++m_fck_scan > 12)
223         m_fck_scan = 0;
224     
225      m_fck_mode = out;   // access lower or upper 4 bits
226     
227      if (BIT(data, 0))   // reset
228         m_fck_scan = 0;
229   }
230}
trunk/src/emu/bus/nes_ctrl/suborkey.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer Subor Keyboard (used by some Famiclones)
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_SUBORKEY__
13#define __NES_SUBORKEY__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_suborkey_device
24
25class nes_suborkey_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_suborkey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_exp(offs_t offset);
40   virtual void write(UINT8 data);
41
42private:
43   required_ioport_array<13> m_kbd;
44   UINT8 m_fck_scan, m_fck_mode;
45};
46
47
48// device type definition
49extern const device_type NES_SUBORKEYBOARD;
50
51
52#endif
trunk/src/emu/bus/nes_ctrl/zapper.c
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System Zapper Lightgun
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "zapper.h"
11
12//**************************************************************************
13//  DEVICE DEFINITIONS
14//**************************************************************************
15
16const device_type NES_ZAPPER = &device_creator<nes_zapper_device>;
17
18
19static INPUT_PORTS_START( nes_zapper )
20   PORT_START("ZAPPER_X")
21   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(70) PORT_KEYDELTA(30) PORT_MINMAX(0,255)
22   PORT_START("ZAPPER_Y")
23   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_MINMAX(0,255)
24   PORT_START("ZAPPER_T")
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Lightgun Trigger")
26INPUT_PORTS_END
27
28
29//-------------------------------------------------
30//  input_ports - device-specific input ports
31//-------------------------------------------------
32
33ioport_constructor nes_zapper_device::device_input_ports() const
34{
35   return INPUT_PORTS_NAME( nes_zapper );
36}
37
38
39
40//**************************************************************************
41//  LIVE DEVICE
42//**************************************************************************
43
44//-------------------------------------------------
45//  nes_zapper_device - constructor
46//-------------------------------------------------
47
48nes_zapper_device::nes_zapper_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
49               device_t(mconfig, NES_ZAPPER, "Nintendo Zapper Lightgun", tag, owner, clock, "nes_zapper", __FILE__),
50               device_nes_control_port_interface(mconfig, *this),
51               m_lightx(*this, "ZAPPER_X"),
52               m_lighty(*this, "ZAPPER_Y"),
53               m_trigger(*this, "ZAPPER_T")
54{
55}
56
57
58//-------------------------------------------------
59//  device_start
60//-------------------------------------------------
61
62void nes_zapper_device::device_start()
63{
64}
65
66
67//-------------------------------------------------
68//  device_reset
69//-------------------------------------------------
70
71void nes_zapper_device::device_reset()
72{
73}
74
75
76//-------------------------------------------------
77//  read
78//-------------------------------------------------
79
80UINT8 nes_zapper_device::read_bit34()
81{
82   UINT8 ret = m_trigger->read();
83   if (!m_port->m_brightpixel_cb.isnull() &&
84      m_port->m_brightpixel_cb(m_lightx->read(), m_lighty->read()))
85      ret &= ~0x08; // sprite hit
86   else
87      ret |= 0x08;  // no sprite hit
88   return ret;
89}
90
91UINT8 nes_zapper_device::read_exp(offs_t offset)
92{
93   UINT8 ret = 0;
94   if (offset == 1)   // $4017
95      ret |= nes_zapper_device::read_bit34();
96   return ret;
97}
trunk/src/emu/bus/nes_ctrl/zapper.h
r0r243139
1/**********************************************************************
2
3    Nintendo Family Computer & Entertainment System Zapper Lightgun
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __NES_ZAPPER__
13#define __NES_ZAPPER__
14
15
16#include "emu.h"
17#include "ctrl.h"
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// ======================> nes_zapper_device
24
25class nes_zapper_device : public device_t,
26                     public device_nes_control_port_interface
27{
28public:
29   // construction/destruction
30   nes_zapper_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31
32   virtual ioport_constructor device_input_ports() const;
33
34protected:
35   // device-level overrides
36   virtual void device_start();
37   virtual void device_reset();
38
39   virtual UINT8 read_bit34();
40   virtual UINT8 read_exp(offs_t offset);
41
42private:
43   required_ioport m_lightx;
44   required_ioport m_lighty;
45   required_ioport m_trigger;
46};
47
48
49// device type definition
50extern const device_type NES_ZAPPER;
51
52
53#endif
trunk/src/mess/drivers/nes.c
r243138r243139
4848   // 0x8000-0xffff -> HIGH HANDLER defined on a pcb base
4949ADDRESS_MAP_END
5050
51
52static INPUT_PORTS_START( nes_pads12 )
53   PORT_START("PAD1")
54   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 A") PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
55   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 B") PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
56   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(1)                     PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
57   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(1)                      PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
58   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)                PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
59   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)              PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
60   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)              PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
61   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
62
63   PORT_START("PAD2")
64   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 A") PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
65   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 B") PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
66   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(2)                     PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
67   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(2)                      PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
68   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)                PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
69   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)              PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
70   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)              PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
71   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
72INPUT_PORTS_END
73
74static INPUT_PORTS_START( nes_pads34 )
75   PORT_START("PAD3")
76   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P3 A") PORT_PLAYER(3)  PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
77   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P3 B") PORT_PLAYER(3)  PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
78   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(3)                     PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
79   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(3)                      PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
80   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(3)                PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
81   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3)              PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
82   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3)              PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
83   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3)             PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
84
85   PORT_START("PAD4")
86   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P4 A") PORT_PLAYER(4)  PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
87   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P4 B") PORT_PLAYER(4)  PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
88   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(4)                     PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
89   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(4)                      PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
90   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(4)                PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
91   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4)              PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
92   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4)              PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
93   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4)             PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
94INPUT_PORTS_END
95
96
97static INPUT_PORTS_START( nes_powerpad )
98// difference between the two sides is that we mirror the key mapping to match the real pad layout!
99   PORT_START("POWERPAD1")
100// side A layout
101   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Top1")  PORT_CODE(KEYCODE_Y) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
102   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
103   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid1")  PORT_CODE(KEYCODE_J) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
104   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid2")  PORT_CODE(KEYCODE_H) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
106   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Low1")  PORT_CODE(KEYCODE_N) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
107   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Low2")  PORT_CODE(KEYCODE_B) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
108   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid3")  PORT_CODE(KEYCODE_G) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
109// side B layout
110   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 2")     PORT_CODE(KEYCODE_T) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
111   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 1")     PORT_CODE(KEYCODE_R) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
112   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 5")     PORT_CODE(KEYCODE_F) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
113   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 9")     PORT_CODE(KEYCODE_V) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
114   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 6")     PORT_CODE(KEYCODE_G) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
115   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 10")    PORT_CODE(KEYCODE_B) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
116   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 11")    PORT_CODE(KEYCODE_N) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
117   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 7")     PORT_CODE(KEYCODE_H) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
118   PORT_START("POWERPAD2")
119// side A layout
120   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
121   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Top2")  PORT_CODE(KEYCODE_T) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
122   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
123   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad Mid4")  PORT_CODE(KEYCODE_F) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
124   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0050)
125// side B layout
126   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 4")     PORT_CODE(KEYCODE_U) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
127   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 3")     PORT_CODE(KEYCODE_Y) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
128   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 12")    PORT_CODE(KEYCODE_M) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
129   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("PowerPad 8")     PORT_CODE(KEYCODE_J) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
130   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )                                                  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0060)
131INPUT_PORTS_END
132
133static INPUT_PORTS_START( nes_zapper1 )
134   PORT_START("ZAPPER1_X")
135   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(70) PORT_KEYDELTA(30) PORT_MINMAX(0,255) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
136   PORT_START("ZAPPER1_Y")
137   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_MINMAX(0,255) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
138   PORT_START("ZAPPER1_T")
139   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("P1 Lightgun Trigger") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
140INPUT_PORTS_END
141
142static INPUT_PORTS_START( nes_zapper2 )
143   PORT_START("ZAPPER2_X")
144   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(70) PORT_KEYDELTA(30) PORT_MINMAX(0,255 ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
145   PORT_START("ZAPPER2_Y")
146   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_MINMAX(0,255 ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
147   PORT_START("ZAPPER2_T")
148   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("P2 Lightgun Trigger") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
149INPUT_PORTS_END
150
151static INPUT_PORTS_START( nes_paddle )
152   PORT_START("PADDLE")
153   PORT_BIT( 0xff, 0x7f, IPT_PADDLE) PORT_SENSITIVITY(25) PORT_KEYDELTA(25) PORT_CENTERDELTA(0) PORT_MINMAX(0x62,0xf2) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0040)
154   PORT_START("PADDLE_BUTTON")
155   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle button") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0040)
156INPUT_PORTS_END
157
15851static INPUT_PORTS_START( nes )
159   PORT_INCLUDE( nes_pads12 )
160   PORT_INCLUDE( nes_pads34 )
161   PORT_INCLUDE( nes_powerpad )
162   PORT_INCLUDE( nes_zapper1 )
163   PORT_INCLUDE( nes_zapper2 )
164   PORT_INCLUDE( nes_paddle )
165
166   PORT_START("CTRLSEL")
167   PORT_CONFNAME( 0x000f, 0x0001, "P1 Controller")
168   PORT_CONFSETTING(  0x0000, "Unconnected" )
169   PORT_CONFSETTING(  0x0001, "Gamepad" )
170   PORT_CONFSETTING(  0x0002, "Zapper" )
171   PORT_CONFNAME( 0x00f0, 0x0010, "P2 Controller")
172   PORT_CONFSETTING(  0x0000, "Unconnected" )
173   PORT_CONFSETTING(  0x0010, "Gamepad" )
174   PORT_CONFSETTING(  0x0020, "Zapper" )
175   PORT_CONFSETTING(  0x0040, "Arkanoid paddle" )
176   PORT_CONFSETTING(  0x0050, "Power Pad (Side A layout)" )
177   PORT_CONFSETTING(  0x0060, "Power Pad (Side B layout)" )
178   PORT_CONFNAME( 0x0f00, 0x0000, "P3 Controller")
179   PORT_CONFSETTING(  0x0000, "Unconnected" )
180   PORT_CONFSETTING(  0x0100, "Gamepad" )
181   PORT_CONFNAME( 0xf000, 0x0000, "P4 Controller")
182   PORT_CONFSETTING(  0x0000, "Unconnected" )
183   PORT_CONFSETTING(  0x1000, "Gamepad" )
184
52   // input devices go through slot options
18553   PORT_START("CONFIG")
18654   PORT_CONFNAME( 0x01, 0x00, "Draw Top/Bottom 8 Lines")
18755   PORT_CONFSETTING(    0x01, DEF_STR(No) )
r243138r243139
19159   PORT_CONFSETTING(    0x00, DEF_STR(Yes) )
19260INPUT_PORTS_END
19361
194
195static INPUT_PORTS_START( fc_pads12 )
196   PORT_START("PAD1")
197   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 A") PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
198   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 B") PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
199   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(1)                     PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
200   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(1)                      PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
201   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)                PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
202   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)              PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
203   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)              PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
204   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0001)
205
206   PORT_START("PAD2")
207   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 A") PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
208   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 B") PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
209   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(2)                     PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
210   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(2)                      PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
211   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)                PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
212   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)              PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
213   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)              PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
214   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0010)
215   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 A") PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
216   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 B") PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
217   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("Microphone") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
218   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )                                    PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
219   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)                PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
220   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)              PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
221   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)              PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
222   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x00f0)
223INPUT_PORTS_END
224
225static INPUT_PORTS_START( fc_pads34 )
226   PORT_START("PAD3")
227   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P3 A") PORT_PLAYER(3)  PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
228   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P3 B") PORT_PLAYER(3)  PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
229   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(3)                     PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
230   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(3)                      PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
231   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(3)                PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
232   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3)              PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
233   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3)              PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
234   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3)             PORT_CONDITION("CTRLSEL", 0x0f00, EQUALS, 0x0100)
235
236   PORT_START("PAD4")
237   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P4 A") PORT_PLAYER(4)  PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
238   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P4 B") PORT_PLAYER(4)  PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
239   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(4)                     PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
240   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(4)                      PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
241   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(4)                PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
242   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4)              PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
243   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4)              PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
244   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4)             PORT_CONDITION("CTRLSEL", 0xf000, EQUALS, 0x1000)
245INPUT_PORTS_END
246
247static INPUT_PORTS_START( fc_lightgun )
248   PORT_START("ZAPPER2_X")
249   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(70) PORT_KEYDELTA(30) PORT_MINMAX(0,255) PORT_PLAYER(2) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x01)
250   PORT_START("ZAPPER2_Y")
251   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_MINMAX(0,255) PORT_PLAYER(2) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x01)
252   PORT_START("ZAPPER2_T")
253   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Lightgun Trigger") PORT_PLAYER(2) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x01)
254INPUT_PORTS_END
255
256static INPUT_PORTS_START( fc_paddle )
257   PORT_START("PADDLE")
258   PORT_BIT( 0xff, 0x7f, IPT_PADDLE) PORT_SENSITIVITY(25) PORT_KEYDELTA(25) PORT_CENTERDELTA(0) PORT_MINMAX(0x62,0xf2) PORT_PLAYER(2) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x04)
259   PORT_START("PADDLE_BUTTON")
260   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle button") PORT_PLAYER(2) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x04)
261INPUT_PORTS_END
262
263static INPUT_PORTS_START( fc_cclimb )
264   PORT_START("CC_LEFT")
265   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
266   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
267   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
268   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(1)              PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
269   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_PLAYER(1)    PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
270   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
271   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
272   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x000f, EQUALS, 0x0002)
273
274   PORT_START("CC_RIGHT")
275   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
276   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
277   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
278   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)             PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
279   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_PLAYER(1)   PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
280   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
281   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
282   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_PLAYER(1)PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0020)
283INPUT_PORTS_END
284
285static INPUT_PORTS_START( fc_keyboard )
286   PORT_START("FCKEY0")
287   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
288   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)           PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
289   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR('[')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
290   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']')      PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
291   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Kana")                                PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
292   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RSHIFT)                        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
293   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)    PORT_CHAR('\\') PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
294   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_BACKSPACE)   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
295
296   PORT_START("FCKEY1")
297   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
298   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
299   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')      PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
300   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';')      PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
301   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('_')                               PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
302   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('/')                               PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
303   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')      PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
304   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('^')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
305
306   PORT_START("FCKEY2")
307   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
308   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
309   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
310   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
311   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)  PORT_CHAR('.')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
312   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
313   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
314   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
315
316   PORT_START("FCKEY3")
317   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
318   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
319   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
320   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
321   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
322   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
323   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
324   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
325
326   PORT_START("FCKEY4")
327   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
328   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
329   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
330   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
331   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
332   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
333   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
334   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
335
336   PORT_START("FCKEY5")
337   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
338   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
339   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
340   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
341   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
342   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
343   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
344   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
345
346   PORT_START("FCKEY6")
347   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
348   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
349   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
350   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
351   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
352   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
353   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
354   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
355
356   PORT_START("FCKEY7")
357   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))           PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
358   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_MAMEKEY(ESC))         PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
359   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')                          PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
360   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2)    PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
361   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)        PORT_CHAR(UCHAR_SHIFT_1)    PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
362   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Grph") PORT_CODE(KEYCODE_LALT)        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
363   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')              PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
364   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')              PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
365
366   PORT_START("FCKEY8")
367   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Clr")                                 PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
368   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP)    PORT_CHAR(UCHAR_MAMEKEY(UP))        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
369   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))     PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
370   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
371   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
372   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)     PORT_CHAR(' ')      PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
373   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Del") PORT_CODE(KEYCODE_DEL)          PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
374   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ins") PORT_CODE(KEYCODE_INSERT)       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x02)
375
376INPUT_PORTS_END
377
378static INPUT_PORTS_START( subor_keyboard )
379   PORT_START("SUBKEY0")
380   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
381   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
382   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
383   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
384   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
385   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
386   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
387   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
388
389   PORT_START("SUBKEY1")
390   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
391   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
392   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
393   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
394   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
395   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
396   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
397   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
398
399   PORT_START("SUBKEY2")
400   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
401   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)                PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
402   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NEXT")                                            PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
403   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
404   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
405   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PRIOR")                                       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
406   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
407   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
408
409   PORT_START("SUBKEY3")
410   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
411   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
412   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
413   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')          PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
414   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
415   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
416   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
417   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)  PORT_CHAR('.')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
418
419   PORT_START("SUBKEY4")
420   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR(']')          PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
421   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)               PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
422   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
423   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
424   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))       PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
425   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')          PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
426   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')         PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
427   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
428
429   PORT_START("SUBKEY5")
430   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
431   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
432   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
433   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB)   PORT_CHAR('\t') PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
434   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))         PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
435   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
436   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
437   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2)        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
438
439   PORT_START("SUBKEY6")
440   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
441   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
442   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
443   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
444   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
445   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
446   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
447   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
448
449   PORT_START("SUBKEY7")
450   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
451   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
452   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
453   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
454   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
455   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P)     PORT_CHAR('P')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
456   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('=')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
457   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)    PORT_CHAR(UCHAR_SHIFT_1)    PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
458
459   PORT_START("SUBKEY8")
460   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
461   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
462   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
463   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
464   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
465   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
466   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
467   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
468
469   PORT_START("SUBKEY9")
470   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
471
472   PORT_START("SUBKEY10")
473   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LMENU")   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
474   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
475   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
476   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F11)       PORT_CHAR(UCHAR_MAMEKEY(F11))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
477   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F12)       PORT_CHAR(UCHAR_MAMEKEY(F12))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
478   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
479   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
480   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
481
482   PORT_START("SUBKEY11")
483   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS_PAD)PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
484   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD)  PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
485   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK)  PORT_CHAR(UCHAR_MAMEKEY(ASTERISK))  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
486   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))     PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
487   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))         PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
488   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))     PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
489   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH_PAD)PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD))  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
490   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK)   PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK))   PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
491
492   PORT_START("SUBKEY12")
493   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`')                  PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
494   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
495   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PAUSE")                                           PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
496   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE2")                                          PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
497   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))           PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
498   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
499   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD)         PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
500   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x03)
501
502INPUT_PORTS_END
503
504static INPUT_PORTS_START( mahjong_panel )
505   PORT_START("MAH0")
506   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
507
508   PORT_START("MAH1")
509   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
510   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_N ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
511   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_M ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
512   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_L ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
513   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_K ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
514   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_J ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
515   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_I ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
516
517   PORT_START("MAH2")
518   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_H ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
519   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
520   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_F ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
521   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_E ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
522   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_D ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
523   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_C ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
524   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_B ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
525   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_A ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
526
527   PORT_START("MAH3")
528   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
529   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_RON ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
530   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
531   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
532   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_PON ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
533   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN ) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
534   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P1 Mahjong Select") PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
535   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("P1 Mahjong Start") PORT_CONDITION("EXP", 0x0f, EQUALS, 0x07)
536INPUT_PORTS_END
537
538// these are read differently than the powerpad inputs, but we share the tags, to reduce
539static INPUT_PORTS_START( fc_ftrainer )
540// difference between the two sides is that we mirror the key mapping to match the real pad layout!
541   PORT_START("FT_COL0")
542// side A layout
543   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
544   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid1")  PORT_CODE(KEYCODE_J) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
545   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
546// side B layout
547   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 12")    PORT_CODE(KEYCODE_M) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
548   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 8")     PORT_CODE(KEYCODE_J) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
549   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 4")     PORT_CODE(KEYCODE_U) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
550
551   PORT_START("FT_COL1")
552// side A layout
553   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low1")  PORT_CODE(KEYCODE_N) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
554   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid2")  PORT_CODE(KEYCODE_H) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
555   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top1")  PORT_CODE(KEYCODE_Y) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
556// side B layout
557   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 11")    PORT_CODE(KEYCODE_N) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
558   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 7")     PORT_CODE(KEYCODE_H) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
559   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 3")     PORT_CODE(KEYCODE_Y) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
560
561   PORT_START("FT_COL2")
562// side A layout
563   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low2")  PORT_CODE(KEYCODE_B) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
564   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid3")  PORT_CODE(KEYCODE_G) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
565   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top2")  PORT_CODE(KEYCODE_T) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
566// side B layout
567   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 10")    PORT_CODE(KEYCODE_B) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
568   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 6")     PORT_CODE(KEYCODE_G) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
569   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 2")     PORT_CODE(KEYCODE_T) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
570
571   PORT_START("FT_COL3")
572// side A layout
573   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
574   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid4")  PORT_CODE(KEYCODE_F) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
575   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )                                                        PORT_CONDITION("EXP", 0x0f, EQUALS, 0x05)
576// side B layout
577   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 9")     PORT_CODE(KEYCODE_V) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
578   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 5")     PORT_CODE(KEYCODE_F) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
579   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 1")     PORT_CODE(KEYCODE_R) PORT_CONDITION("EXP", 0x0f, EQUALS, 0x06)
580INPUT_PORTS_END
581
582
583
58462static INPUT_PORTS_START( famicom )
585   PORT_INCLUDE( fc_pads12 )
586   PORT_INCLUDE( fc_pads34 )
587   PORT_INCLUDE( fc_lightgun )
588   // FIXME: was it possible to attache two paddles in a Famicom (as the Arkanoid 2 box suggests)?!? investigate...
589   PORT_INCLUDE( fc_paddle )
590   // Crazy Climber is not really a separate controller, but a couple of small sticks to be
591   // put on top of d-pads of the regular controllers. Users should then control the game
592   // by using both controllers, turned 90 degrees, as a couple of dual sticks as in the arcade
593   PORT_INCLUDE( fc_cclimb )
594   PORT_INCLUDE( fc_keyboard )
595   PORT_INCLUDE( subor_keyboard )
596   PORT_INCLUDE( mahjong_panel )
597   PORT_INCLUDE( fc_ftrainer )
598
599   PORT_START("CTRLSEL")
600   PORT_CONFNAME( 0x000f, 0x0001, "P1 Controller")
601   PORT_CONFSETTING(  0x0000, "Unconnected" )
602   PORT_CONFSETTING(  0x0001, "Gamepad" )
603   PORT_CONFSETTING(  0x0002, "Crazy Climber pad (Left)" )
604   PORT_CONFNAME( 0x00f0, 0x0010, "P2 Controller")
605   PORT_CONFSETTING(  0x0000, "Unconnected" )
606   PORT_CONFSETTING(  0x0010, "Gamepad" )
607   PORT_CONFSETTING(  0x0020, "Crazy Climber pad (Right)" )
608   PORT_CONFSETTING(  0x00f0, "Gamepad (Older Version)" )
609   PORT_CONFNAME( 0x0f00, 0x0000, "P3 Controller") PORT_CONDITION("EXP", 0x0f, EQUALS, 0x08)
610   PORT_CONFSETTING(  0x0000, "Unconnected" )
611   PORT_CONFSETTING(  0x0100, "Gamepad" )
612   PORT_CONFNAME( 0xf000, 0x0000, "P4 Controller") PORT_CONDITION("EXP", 0x0f, EQUALS, 0x08)
613   PORT_CONFSETTING(  0x0000, "Unconnected" )
614   PORT_CONFSETTING(  0x1000, "Gamepad" )
615
616   PORT_START("EXP")
617   PORT_CONFNAME( 0x0f, 0x00, "Expansion Port")
618   PORT_CONFSETTING(  0x00, "(Empty)" )
619   PORT_CONFSETTING(  0x01, "Light Gun" )
620   PORT_CONFSETTING(  0x02, "FC Keyboard" )
621   PORT_CONFSETTING(  0x03, "Subor Keyboard" )
622   PORT_CONFSETTING(  0x04, "Arkanoid paddle" )
623   PORT_CONFSETTING(  0x05, "Family Trainer (Side A)" )
624   PORT_CONFSETTING(  0x06, "Family Trainer (Side B)" )
625   PORT_CONFSETTING(  0x07, "Mahjong Panel" )
626   PORT_CONFSETTING(  0x08, "Hori Twin Adapter" )
627
63   // input devices go through slot options
62864   PORT_START("CONFIG")
62965   PORT_CONFNAME( 0x01, 0x00, "Draw Top/Bottom 8 Lines")
63066   PORT_CONFSETTING(    0x01, DEF_STR(No) )
r243138r243139
63470   PORT_CONFSETTING(    0x00, DEF_STR(Yes) )
63571
63672   PORT_START("FLIPDISK") /* fake key */
637   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Change Disk Side")
73   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Change Disk Side") PORT_CODE(KEYCODE_SPACE)
63874INPUT_PORTS_END
63975
64076
r243138r243139
674110   MCFG_NES_APU_CPU("maincpu")
675111   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
676112
113   MCFG_NES_CONTROL_PORT_ADD("ctrl1", nes_control_port1_devices, "joypad")
114   MCFG_NESCTRL_BRIGHTPIXEL_CB(nes_state, bright_pixel)
115   MCFG_NES_CONTROL_PORT_ADD("ctrl2", nes_control_port2_devices, "joypad")
116   MCFG_NESCTRL_BRIGHTPIXEL_CB(nes_state, bright_pixel)
117
677118   MCFG_NES_CARTRIDGE_ADD("nes_slot", nes_cart, NULL)
678119   MCFG_SOFTWARE_LIST_ADD("cart_list", "nes")
679120   MCFG_SOFTWARE_LIST_ADD("ade_list", "nes_ade")         // Camerica/Codemasters Aladdin Deck Enhancer mini-carts
r243138r243139
729170MACHINE_CONFIG_END
730171
731172static MACHINE_CONFIG_DERIVED( famicom, nes )
732   MCFG_CASSETTE_ADD( "tape" )
733   MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)
734   MCFG_CASSETTE_INTERFACE("fc_cass")
173   MCFG_DEVICE_REMOVE("ctrl1")
174   MCFG_DEVICE_REMOVE("ctrl2")
175   MCFG_NES_CONTROL_PORT_ADD("ctrl1", fc_control_port1_devices, "joypad")
176   MCFG_NES_CONTROL_PORT_ADD("ctrl2", fc_control_port2_devices, "joypad")
177   MCFG_FC_EXPANSION_PORT_ADD("exp", fc_expansion_devices, NULL)
178   MCFG_NESCTRL_BRIGHTPIXEL_CB(nes_state, bright_pixel)
735179
736180   MCFG_SOFTWARE_LIST_ADD("flop_list", "famicom_flop")
737181   MCFG_SOFTWARE_LIST_ADD("cass_list", "famicom_cass")
r243138r243139
769213MACHINE_START_MEMBER( nes_state, fds )
770214{
771215   m_ciram = auto_alloc_array(machine(), UINT8, 0x800);
772   setup_ioports();
773216   setup_disk(m_disk);
774   state_register();
217   
218   // register saves
219   save_item(NAME(m_last_frame_flip));
220   save_pointer(NAME(m_ciram), 0x800);
775221}
776222
777223MACHINE_RESET_MEMBER( nes_state, fds )
r243138r243139
781227
782228   // the rest is the same as for nes/famicom/dendy
783229   m_maincpu->reset();
784
785   memset(m_pad_latch, 0, sizeof(m_pad_latch));
786   memset(m_zapper_latch, 0, sizeof(m_zapper_latch));
787   m_paddle_latch = 0;
788   m_paddle_btn_latch = 0;
789230}
790231
791232static MACHINE_CONFIG_DERIVED( fds, famicom )
792233   MCFG_MACHINE_START_OVERRIDE( nes_state, fds )
793234   MCFG_MACHINE_RESET_OVERRIDE( nes_state, fds )
794   MCFG_DEVICE_REMOVE("tape")
795235
796236   MCFG_DEVICE_REMOVE("nes_slot")
797237   MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0)
r243138r243139
827267
828268   // the rest is the same as for nes/famicom/dendy
829269   m_maincpu->reset();
830
831   memset(m_pad_latch, 0, sizeof(m_pad_latch));
832   memset(m_zapper_latch, 0, sizeof(m_zapper_latch));
833   m_paddle_latch = 0;
834   m_paddle_btn_latch = 0;
835270}
836271
837272static MACHINE_CONFIG_DERIVED( famitwin, famicom )
trunk/src/mess/includes/nes.h
r243138r243139
1313#include "video/ppu2c0x.h"
1414#include "bus/nes/nes_slot.h"
1515#include "bus/nes/nes_carts.h"
16#include "bus/nes_ctrl/ctrl.h"
1617#include "sound/nes_apu.h"
17#include "imagedev/cassette.h"
1818
1919/***************************************************************************
2020    CONSTANTS
r243138r243139
3030    TYPE DEFINITIONS
3131***************************************************************************/
3232
33struct nes_input
34{
35   UINT32 shift;
36   UINT32 i0, i1, i2;
37};
38
3933/*PPU fast banking constants and structures */
4034
4135#define CHRROM 0
r243138r243139
5751class nes_state : public driver_device
5852{
5953public:
60   enum
61   {
62      TIMER_ZAPPER_TICK,
63      TIMER_LIGHTGUN_TICK
64   };
65
6654   nes_state(const machine_config &mconfig, device_type type, const char *tag)
6755      : driver_device(mconfig, type, tag),
6856         m_maincpu(*this, "maincpu"),
6957         m_ppu(*this, "ppu"),
7058         m_sound(*this, "nessound"),
59         m_ctrl1(*this, "ctrl1"),
60         m_ctrl2(*this, "ctrl2"),
61         m_exp(*this, "exp"),
7162         m_cartslot(*this, "nes_slot"),
72         m_disk(*this, "disk"),
73         m_cassette(*this, "tape")
63         m_disk(*this, "disk")
7464      { }
7565
7666   /* video-related */
7767   int m_last_frame_flip;
7868
7969   /* misc */
80   ioport_port       *m_io_ctrlsel;
81   ioport_port       *m_io_fckey[9];
82   ioport_port       *m_io_subkey[13];
83   ioport_port       *m_io_pad[4];
84   ioport_port       *m_io_powerpad[2];
85   ioport_port       *m_io_mahjong[4];
86   ioport_port       *m_io_ftrainer[4];
87   ioport_port       *m_io_cc_left;
88   ioport_port       *m_io_cc_right;
89   ioport_port       *m_io_zapper1_t;
90   ioport_port       *m_io_zapper1_x;
91   ioport_port       *m_io_zapper1_y;
92   ioport_port       *m_io_zapper2_t;
93   ioport_port       *m_io_zapper2_x;
94   ioport_port       *m_io_zapper2_y;
95   ioport_port       *m_io_paddle;
96   ioport_port       *m_io_paddle_btn;
97   ioport_port       *m_io_exp;
9870   ioport_port       *m_io_disksel;
9971
10072   UINT8      *m_vram;
r243138r243139
10375   required_device<cpu_device> m_maincpu;
10476   required_device<ppu2c0x_device> m_ppu;
10577   required_device<nesapu_device> m_sound;
78   required_device<nes_control_port_device> m_ctrl1;
79   required_device<nes_control_port_device> m_ctrl2;
80   optional_device<nes_control_port_device> m_exp;
10681   optional_device<nes_cart_slot_device> m_cartslot;
10782   optional_device<nes_disksys_device> m_disk;
108   optional_device<cassette_image_device> m_cassette;
10983
11084   int nes_ppu_vidaccess(int address, int data);
11185   void ppu_nmi(int *ppu_regs);
r243138r243139
11387   DECLARE_READ8_MEMBER(nes_in0_r);
11488   DECLARE_READ8_MEMBER(nes_in1_r);
11589   DECLARE_WRITE8_MEMBER(nes_in0_w);
116   DECLARE_WRITE8_MEMBER(nes_in1_w);
11790   DECLARE_READ8_MEMBER(fc_in0_r);
11891   DECLARE_READ8_MEMBER(fc_in1_r);
11992   DECLARE_WRITE8_MEMBER(fc_in0_w);
r243138r243139
127100   DECLARE_READ8_MEMBER(psg_4015_r);
128101   DECLARE_WRITE8_MEMBER(psg_4015_w);
129102   DECLARE_WRITE8_MEMBER(psg_4017_w);
130   void state_register();
131   void setup_ioports();
103   NESCTRL_BRIGHTPIXEL_CB(bright_pixel);
132104
133105   DECLARE_DRIVER_INIT(famicom);
134106
r243138r243139
139111   DECLARE_MACHINE_RESET(famitwin);
140112   void setup_disk(nes_disksys_device *slot);
141113
142   // input related
143   UINT32 m_pad_latch[4];
144   UINT8 m_zapper_latch[2][3];
145   UINT8 m_paddle_latch, m_paddle_btn_latch;
146   UINT8 m_mjpanel_latch;
147   UINT8 m_fck_scan, m_fck_mode;
148   UINT8 m_mic_obstruct;
149   UINT8 m_powerpad_latch[2];
150   UINT8 m_ftrainer_scan;
151
152protected:
153   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
154
155114private:
156115   memory_bank       *m_prg_bank_mem[5];
157116};
trunk/src/mess/machine/nes.c
r243138r243139
77 ****************************************************************************/
88
99#include "emu.h"
10#include "crsshair.h"
1110#include "cpu/m6502/m6502.h"
1211#include "includes/nes.h"
13#include "imagedev/flopdrv.h"
1412
1513/***************************************************************************
16    CONSTANTS
17***************************************************************************/
18
19/* Set to dump info about the inputs to the errorlog */
20#define LOG_JOY     0
21
22/* Set to generate prg & chr files when the cart is loaded */
23#define SPLIT_PRG   0
24#define SPLIT_CHR   0
25
26/***************************************************************************
2714    FUNCTIONS
2815***************************************************************************/
2916
r243138r243139
4431      m_cartslot->pcb_reset();
4532
4633   m_maincpu->reset();
47
48   memset(m_pad_latch, 0, sizeof(m_pad_latch));
49   memset(m_zapper_latch, 0, sizeof(m_zapper_latch));
50   m_paddle_latch = 0;
51   m_paddle_btn_latch = 0;
5234}
5335
5436//-------------------------------------------------
5537//  machine_start
5638//-------------------------------------------------
5739
58void nes_state::state_register()
59{
60   save_item(NAME(m_last_frame_flip));
61
62   save_pointer(NAME(m_ciram), 0x800);
63
64   save_item(NAME(m_pad_latch));
65   save_item(NAME(m_zapper_latch));
66   save_item(NAME(m_paddle_latch));
67   save_item(NAME(m_paddle_btn_latch));
68   save_item(NAME(m_mjpanel_latch));
69   save_item(NAME(m_fck_scan));
70   save_item(NAME(m_fck_mode));
71   save_item(NAME(m_mic_obstruct));
72   save_item(NAME(m_powerpad_latch));
73   save_item(NAME(m_ftrainer_scan));
74}
75
76void nes_state::setup_ioports()
77{
78   for (int i = 0; i < 9; i++)
79   {
80      char str[7];
81      sprintf(str, "FCKEY%i", i);
82      m_io_fckey[i] = ioport(str);
83   }
84   for (int i = 0; i < 13; i++)
85   {
86      char str[9];
87      sprintf(str, "SUBKEY%i", i);
88      m_io_subkey[i] = ioport(str);
89   }
90   for (int i = 0; i < 4; i++)
91   {
92      char str[8];
93      sprintf(str, "PAD%i", i + 1);
94      m_io_pad[i] = ioport(str);
95      sprintf(str, "MAH%i", i);
96      m_io_mahjong[i] = ioport(str);
97      sprintf(str, "FT_COL%i", i);
98      m_io_ftrainer[i] = ioport(str);
99   }
100
101   m_io_ctrlsel        = ioport("CTRLSEL");
102   m_io_exp            = ioport("EXP");
103   m_io_paddle         = ioport("PADDLE");
104   m_io_paddle_btn     = ioport("PADDLE_BUTTON");
105   m_io_cc_left        = ioport("CC_LEFT");
106   m_io_cc_right       = ioport("CC_RIGHT");
107   m_io_zapper1_t      = ioport("ZAPPER1_T");
108   m_io_zapper1_x      = ioport("ZAPPER1_X");
109   m_io_zapper1_y      = ioport("ZAPPER1_Y");
110   m_io_zapper2_t      = ioport("ZAPPER2_T");
111   m_io_zapper2_x      = ioport("ZAPPER2_X");
112   m_io_zapper2_y      = ioport("ZAPPER2_Y");
113   m_io_powerpad[0]    = ioport("POWERPAD1");
114   m_io_powerpad[1]    = ioport("POWERPAD2");
115   m_io_disksel        = ioport("FLIPDISK");
116}
117
11840void nes_state::machine_start()
11941{
12042   address_space &space = m_maincpu->space(AS_PROGRAM);
r243138r243139
12648   m_ciram = auto_alloc_array(machine(), UINT8, 0x800);
12749   // other pointers got set in the loading routine, because they 'belong' to the cart itself
12850
129   setup_ioports();
51   m_io_disksel = ioport("FLIPDISK");
13052
13153   if (m_cartslot && m_cartslot->m_cart)
13254   {
r243138r243139
178100      m_cartslot->m_cart->pcb_reg_postload(machine());
179101   }
180102
181   state_register();
103   // register saves
104   save_item(NAME(m_last_frame_flip));
105   save_pointer(NAME(m_ciram), 0x800);
182106}
183107
184108
r243138r243139
188112
189113READ8_MEMBER(nes_state::nes_in0_r)
190114{
191   int cfg = m_io_ctrlsel->read();
192
193   // Some games expect bit 6 to be set because the last entry on the data bus shows up
194   // in the unused upper 3 bits, so typically a read from $4016 leaves 0x40 there.
195115   UINT8 ret = 0x40;
196   ret |= (m_pad_latch[0] & 0x01);
197
198   // shift
199   m_pad_latch[0] >>= 1;
200
201   // zapper
202   if ((cfg & 0x000f) == 0x0002)
203   {
204      int x = m_zapper_latch[0][1];  // x-position
205      int y = m_zapper_latch[0][2];  // y-position
206      UINT32 pix, color_base;
207
208      // get the pixel at the gun position
209      pix = m_ppu->get_pixel(x, y);
210
211      // get the color base from the ppu
212      color_base = m_ppu->get_colorbase();
213
214      // check if the cursor is over a bright pixel
215      if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
216         (pix == color_base + 0x33) || (pix == color_base + 0x34))
217         ret &= ~0x08; // sprite hit
218      else
219         ret |= 0x08;  // no sprite hit
220
221      // light gun trigger
222      ret |= (m_zapper_latch[0][0] << 4);
223   }
224
225   if (LOG_JOY)
226      logerror("joy 0 read, val: %02x, pc: %04x\n", ret, space.device().safe_pc());
227
116   ret |= m_ctrl1->read_bit0();
117   ret |= m_ctrl1->read_bit34();
228118   return ret;
229119}
230120
231121READ8_MEMBER(nes_state::nes_in1_r)
232122{
233   int cfg = m_io_ctrlsel->read();
234
235   // Some games expect bit 6 to be set because the last entry on the data bus shows up
236   // in the unused upper 3 bits, so typically a read from $4017 leaves 0x40 there.
237123   UINT8 ret = 0x40;
238   ret |= (m_pad_latch[1] & 0x01);
239
240   // shift
241   m_pad_latch[1] >>= 1;
242
243   // zapper
244   if ((cfg & 0x00f0) == 0x0020)
245   {
246      int x = m_zapper_latch[1][1];  // x-position
247      int y = m_zapper_latch[1][2];  // y-position
248      UINT32 pix, color_base;
249
250      // get the pixel at the gun position
251      pix = m_ppu->get_pixel(x, y);
252
253      // get the color base from the ppu
254      color_base = m_ppu->get_colorbase();
255
256      // check if the cursor is over a bright pixel
257      if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
258         (pix == color_base + 0x33) || (pix == color_base + 0x34))
259         ret &= ~0x08; // sprite hit
260      else
261         ret |= 0x08;  // no sprite hit
262
263      // light gun trigger
264      ret |= (m_zapper_latch[1][0] << 4);
265   }
266
267   // arkanoid paddle
268   if ((cfg & 0x00f0) == 0x0040)
269   {
270      ret |= (m_paddle_btn_latch << 3);   // button
271      ret |= ((m_paddle_latch & 0x80) >> 3);      // paddle data
272      m_paddle_latch <<= 1;
273      m_paddle_latch &= 0xff;
274   }
275
276   // powerpad
277   if ((cfg & 0x00f0) == 0x0050 || (cfg & 0x00f0) == 0x0060)
278   {
279      ret |= ((m_powerpad_latch[0] & 0x01) << 3);
280      ret |= ((m_powerpad_latch[1] & 0x01) << 4);
281      m_powerpad_latch[0] >>= 1;
282      m_powerpad_latch[1] >>= 1;
283   }
284
285   if (LOG_JOY)
286      logerror("joy 1 read, val: %02x, pc: %04x\n", ret, space.device().safe_pc());
287
124   ret |= m_ctrl2->read_bit0();
125   ret |= m_ctrl2->read_bit34();
288126   return ret;
289127}
290128
291129WRITE8_MEMBER(nes_state::nes_in0_w)
292130{
293   int cfg = m_io_ctrlsel->read();
294
295   if (LOG_JOY)
296      logerror("joy write, val: %02x, pc: %04x\n", data, space.device().safe_pc());
297
298   // Check if lightgun has been chosen as input: if so, enable crosshair
299   timer_set(attotime::zero, TIMER_ZAPPER_TICK);
300
301   if (data & 0x01)
302      return;
303
304   // Toggling bit 0 high then low resets controllers
305   m_pad_latch[0] = 0;
306   m_pad_latch[1] = 0;
307   m_zapper_latch[0][0] = 0;
308   m_zapper_latch[0][1] = 0;
309   m_zapper_latch[0][2] = 0;
310   m_zapper_latch[1][0] = 0;
311   m_zapper_latch[1][1] = 0;
312   m_zapper_latch[1][2] = 0;
313   m_paddle_btn_latch = 0;
314   m_paddle_latch = 0;
315   m_powerpad_latch[0] = 0;
316   m_powerpad_latch[1] = 0;
317
318   // P1 inputs
319   switch (cfg & 0x000f)
320   {
321      case 0x01:  // pad 1
322         m_pad_latch[0] = m_io_pad[0]->read();
323         break;
324
325      case 0x02:  // zapper (secondary)
326         m_zapper_latch[0][0] = m_io_zapper1_t->read();
327         m_zapper_latch[0][1] = m_io_zapper1_x->read();
328         m_zapper_latch[0][2] = m_io_zapper1_y->read();
329         break;
330   }
331
332   // P2 inputs
333   switch ((cfg & 0x00f0) >> 4)
334   {
335      case 0x01:  // pad 2
336         m_pad_latch[1] = m_io_pad[1]->read();
337         break;
338
339      case 0x02:  // zapper (primary) - most games expect pad in port1 & zapper in port2
340         m_zapper_latch[1][0] = m_io_zapper2_t->read();
341         m_zapper_latch[1][1] = m_io_zapper2_x->read();
342         m_zapper_latch[1][2] = m_io_zapper2_y->read();
343         break;
344
345      case 0x04:  // arkanoid paddle
346         m_paddle_btn_latch = m_io_paddle_btn->read();
347         m_paddle_latch = (UINT8) (m_io_paddle->read() ^ 0xff);
348         break;
349
350      case 0x05:  // power pad
351      case 0x06:  // power pad
352         m_powerpad_latch[0] = m_io_powerpad[0]->read();
353         m_powerpad_latch[1] = m_io_powerpad[1]->read() | 0xf0;
354         break;
355   }
356
357   // P3 & P4 inputs in NES Four Score are read serially with P1 & P2
358   // P3 inputs
359   if ((cfg & 0x0f00))
360      m_pad_latch[0] |= ((m_io_pad[2]->read() << 8) | (0x08 << 16));    // pad 3 + signature
361
362   // P4 inputs
363   if ((cfg & 0xf000))
364      m_pad_latch[1] |= ((m_io_pad[3]->read() << 8) | (0x04 << 16));    // pad 4 + signature
131   m_ctrl1->write(data);
132   m_ctrl2->write(data);
365133}
366134
367135
368WRITE8_MEMBER(nes_state::nes_in1_w)
369{
370}
371
372
373136READ8_MEMBER(nes_state::fc_in0_r)
374137{
375   int cfg = m_io_ctrlsel->read();
376   int exp = m_io_exp->read();
377
378   // Some games expect bit 6 to be set because the last entry on the data bus shows up
379   // in the unused upper 3 bits, so typically a read from $4016 leaves 0x40 there.
380138   UINT8 ret = 0x40;
381   ret |= (m_pad_latch[0] & 0x01);
139   // bit 0 to controller port
140   ret |= m_ctrl1->read_bit0();
382141
383   // shift
384   m_pad_latch[0] >>= 1;
142   // expansion port bits (in the original FC, P2 controller was hooked to these lines
143   // too, so in principle some homebrew hardware modification could use the same
144   // connection with P1 controller too)
145   ret |= m_ctrl1->read_exp(0);
146   ret |= m_ctrl2->read_exp(0);
385147
386   // microphone bit
387   if ((cfg & 0x00f0) == 0x00f0)
388      ret |= m_mic_obstruct;  //bit2!
389
390   // EXP input
391   switch (exp & 0x0f)
392   {
393      case 0x02:  // FC Keyboard: tape input
394         if ((m_cassette->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)
395         {
396            double level = m_cassette->input();
397            if (level < 0)
398               ret |= 0x00;
399            else
400               ret |= 0x02;
401         }
402         break;
403
404      case 0x04:  // Arkanoid paddle
405         ret |= (m_paddle_btn_latch << 1);   // button
406         break;
407
408      case 0x07:  // Mahjong Panel
409         ret |= ((m_mjpanel_latch & 0x01) << 1);
410         m_mjpanel_latch >>= 1;
411         break;
412
413      case 0x08:  // 'multitap' p3
414         ret |= ((m_pad_latch[2] & 0x01) << 1);
415         m_pad_latch[2] >>= 1;
416         break;
417   }
418
419   if (LOG_JOY)
420      logerror("joy 0 read, val: %02x, pc: %04x\n", ret, space.device().safe_pc());
421
148   // at the same time, we might have a standard joypad connected to the expansion port which
149   // shall be read as P3 (this is needed here to avoid implementing the expansion port as a
150   // different device compared to the standard control port... it might be changed later)
151   ret |= (m_exp->read_bit0() << 1);
152   // finally, read the expansion port as expected
153   ret |= m_exp->read_exp(0);
422154   return ret;
423155}
424156
425157READ8_MEMBER(nes_state::fc_in1_r)
426158{
427   int exp = m_io_exp->read();
428
429   // Some games expect bit 6 to be set because the last entry on the data bus shows up
430   // in the unused upper 3 bits, so typically a read from $4017 leaves 0x40 there.
431159   UINT8 ret = 0x40;
432   ret |= (m_pad_latch[1] & 0x01);
160   // bit 0 to controller port
161   ret |= m_ctrl2->read_bit0();
433162
434   // shift
435   m_pad_latch[1] >>= 1;
163   // expansion port bits (in the original FC, P2 controller was hooked to these lines
164   // too, so in principle some homebrew hardware modification could use the same
165   // connection with P1 controller too)
166   ret |= m_ctrl1->read_exp(1);
167   ret |= m_ctrl2->read_exp(1);
436168
437
438   // EXP input
439   switch (exp & 0x0f)
440   {
441      case 0x01:  // Lightgun
442         {
443            int x = m_zapper_latch[0][1];  // x-position
444            int y = m_zapper_latch[0][2];  // y-position
445            UINT32 pix, color_base;
446
447            // get the pixel at the gun position
448            pix = m_ppu->get_pixel(x, y);
449
450            // get the color base from the ppu
451            color_base = m_ppu->get_colorbase();
452
453            // check if the cursor is over a bright pixel
454            if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
455               (pix == color_base + 0x33) || (pix == color_base + 0x34))
456               ret &= ~0x08; // sprite hit
457            else
458               ret |= 0x08;  // no sprite hit
459
460            // light gun trigger
461            ret |= (m_zapper_latch[0][0] << 4);
462         }
463         break;
464
465      case 0x02:  // FC Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4
466         if (m_fck_scan < 9)
467            ret |= ~(((m_io_fckey[m_fck_scan]->read() >> (m_fck_mode * 4)) & 0x0f) << 1) & 0x1e;
468         else
469            ret |= 0x1e;
470         break;
471
472      case 0x03:  // Subor Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4
473         if (m_fck_scan < 12)
474            ret |= ~(((m_io_subkey[m_fck_scan]->read() >> (m_fck_mode * 4)) & 0x0f) << 1) & 0x1e;
475         else
476            ret |= 0x1e;
477         break;
478
479      case 0x04:  // Arkanoid paddle
480         ret |= ((m_paddle_latch & 0x80) >> 6);      // paddle data
481         m_paddle_latch <<= 1;
482         m_paddle_latch &= 0xff;
483         break;
484
485      case 0x05:  // family trainer
486      case 0x06:  // family trainer
487         if (!BIT(m_ftrainer_scan, 0))
488         {
489            // read low line: buttons 9,10,11,12
490            for (int i = 0; i < 4; i++)
491               ret |= ((m_io_ftrainer[i]->read() & 0x01) << (1 + i));
492         }
493         else if (!BIT(m_ftrainer_scan, 1))
494         {
495            // read mid line: buttons 5,6,7,8
496            for (int i = 0; i < 4; i++)
497               ret |= ((m_io_ftrainer[i]->read() & 0x02) << (1 + i));
498         }
499         else if (!BIT(m_ftrainer_scan, 2))
500         {
501            // read high line: buttons 1,2,3,4
502            for (int i = 0; i < 4; i++)
503               ret |= ((m_io_ftrainer[i]->read() & 0x04) << (1 + i));
504         }
505         break;
506
507      case 0x07:  // Mahjong Panel
508         ret |= ((m_mjpanel_latch & 0x01) << 1);
509         m_mjpanel_latch >>= 1;
510         break;
511
512      case 0x08:  // 'multitap' p4
513         ret |= ((m_pad_latch[3] & 0x01) << 1);
514         m_pad_latch[3] >>= 1;
515         break;
516   }
517
518   if (LOG_JOY)
519      logerror("joy 1 read, val: %02x, pc: %04x\n", ret, space.device().safe_pc());
520
169   // finally, read the expansion port as expected (standard pad cannot be hooked as P4, so
170   // no read_bit0 here)
171   ret |= m_exp->read_exp(1);
521172   return ret;
522173}
523174
524175WRITE8_MEMBER(nes_state::fc_in0_w)
525176{
526   int cfg = m_io_ctrlsel->read();
527   int exp = m_io_exp->read();
528
529   if (LOG_JOY)
530      logerror("joy write, val: %02x, pc: %04x\n", data, space.device().safe_pc());
531
532   // Check if lightgun has been chosen as input: if so, enable crosshair
533   timer_set(attotime::zero, TIMER_LIGHTGUN_TICK);
534
535   // keyboards
536   if ((exp & 0x0f) == 0x02 || (exp & 0x0f) == 0x03)
537   {
538      // tape output (not fully tested)
539      if ((m_cassette->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_RECORD)
540         m_cassette->output(((data & 0x07) == 0x07) ? +1.0 : -1.0);
541
542      if (BIT(data, 2))   // keyboard active
543      {
544         int lines = ((exp & 0x0f) == 0x02) ? 9 : 12;
545         UINT8 out = BIT(data, 1);   // scan
546
547         if (m_fck_mode && !out && ++m_fck_scan > lines)
548            m_fck_scan = 0;
549
550         m_fck_mode = out;   // access lower or upper 4 bits
551
552         if (BIT(data, 0))   // reset
553            m_fck_scan = 0;
554      }
555   }
556
557   // family trainer
558   if ((exp & 0x0f) == 0x05 || (exp & 0x0f) == 0x06)
559   {
560      // select raw to scan
561      m_ftrainer_scan = data & 0x07;
562   }
563
564   if (data & 0x01)
565      return;
566
567   // Toggling bit 0 high then low resets controllers
568   m_pad_latch[0] = 0;
569   m_pad_latch[1] = 0;
570   m_pad_latch[2] = 0;
571   m_pad_latch[3] = 0;
572   m_zapper_latch[0][0] = 0;
573   m_zapper_latch[0][1] = 0;
574   m_zapper_latch[0][2] = 0;
575   m_paddle_btn_latch = 0;
576   m_paddle_latch = 0;
577   m_mjpanel_latch = 0;
578   m_mic_obstruct = 0;
579
580   // P1 inputs
581   switch (cfg & 0x000f)
582   {
583      case 0x01:  // pad 1
584         m_pad_latch[0] = m_io_pad[0]->read();
585         break;
586
587      case 0x02:  // crazy climber (left stick)
588         m_pad_latch[0] = m_io_cc_left->read();
589         break;
590   }
591
592   // P2 inputs
593   switch ((cfg & 0x00f0) >> 4)
594   {
595      case 0x01:  // pad 2
596         m_pad_latch[1] = m_io_pad[1]->read();
597         break;
598
599      case 0x02:  // crazy climber (right stick)
600         m_pad_latch[1] = m_io_cc_right->read();
601         break;
602
603      case 0x0f:  // pad 2 old style with microphone instead of START/SELECT keys
604         // we only emulate obstruction of mic (when you blow or talk into it)
605         m_mic_obstruct = m_io_pad[1]->read() & 0x04;
606         m_pad_latch[1] = (m_io_pad[1]->read() & ~0x04);
607         break;
608   }
609
610   // P3 & P4 inputs in Famicom (e.g. through Hori Twin Adapter or Hori 4 Players Adapter)
611   // are read in parallel with P1 & P2 (just using diff bits)
612   // P3 inputs
613   if ((exp & 0x0f) == 8 && (cfg & 0x0f00) == 0x0100)
614      m_pad_latch[2] = m_io_pad[2]->read();     // pad 3
615
616   // P4 inputs
617   if ((exp & 0x0f) == 8 && (cfg & 0xf000) == 0x1000)
618      m_pad_latch[3] = m_io_pad[3]->read();     // pad 4
619
620
621   // EXP input
622   switch (exp & 0x0f)
623   {
624      case 0x01:  // Lightgun
625         m_zapper_latch[0][0] = m_io_zapper2_t->read();
626         m_zapper_latch[0][1] = m_io_zapper2_x->read();
627         m_zapper_latch[0][2] = m_io_zapper2_y->read();
628         break;
629
630      case 0x02:  // FC Keyboard
631      case 0x03:  // Subor Keyboard
632         // these are scanned differently than other devices:
633         // writes to $4016 with bit2 set always update the
634         // line counter and writing bit0 set resets the counter
635         break;
636
637      case 0x04:  // Arkanoid paddle
638         m_paddle_btn_latch = m_io_paddle_btn->read();
639         m_paddle_latch = (UINT8) (m_io_paddle->read() ^ 0xff);
640         break;
641
642      case 0x05:  // family trainer
643      case 0x06:  // family trainer
644         // these are scanned differently than other devices:
645         // bit0-bit2 of writes to $4016 select the row to read
646         // from from the mat input "columns"
647         break;
648
649
650      case 0x07:  // Mahjong Panel
651         if (data & 0xf8)
652            logerror("Error: Mahjong panel read with mux data %02x\n", (data & 0xfe));
653         else
654            m_mjpanel_latch = m_io_mahjong[(data & 0xfe) >> 1]->read();
655         break;
656   }
657
177   m_ctrl1->write(data);
178   m_ctrl2->write(data);
179   m_exp->write(data);
658180}
659181
660182
661void nes_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
662{
663   switch (id)
664   {
665      case TIMER_ZAPPER_TICK:
666         if ((m_io_ctrlsel->read() & 0x000f) == 0x0002)
667         {
668            /* enable lightpen crosshair */
669            crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL);
670         }
671         else
672         {
673            /* disable lightpen crosshair */
674            crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE);
675         }
676
677         if ((m_io_ctrlsel->read() & 0x00f0) == 0x0020)
678         {
679            /* enable lightpen crosshair */
680            crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL);
681         }
682         else
683         {
684            /* disable lightpen crosshair */
685            crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_NONE);
686         }
687         break;
688      case TIMER_LIGHTGUN_TICK:
689         if ((m_io_exp->read() & 0x0f) == 0x01)
690         {
691            /* enable lightpen crosshair */
692            crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL);
693         }
694         else
695         {
696            /* disable lightpen crosshair */
697            crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE);
698         }
699         break;
700      default:
701         assert_always(FALSE, "Unknown id in nes_state::device_timer");
702   }
703}
704
705
706183DRIVER_INIT_MEMBER(nes_state,famicom)
707184{
708185   // setup alt input handlers for additional FC input devices
r243138r243139
711188   space.install_write_handler(0x4016, 0x4016, write8_delegate(FUNC(nes_state::fc_in0_w), this));
712189   space.install_read_handler(0x4017, 0x4017, read8_delegate(FUNC(nes_state::fc_in1_r), this));
713190}
191
192NESCTRL_BRIGHTPIXEL_CB(nes_state::bright_pixel)
193{
194   // get the pixel at the gun position
195   UINT32 pix = m_ppu->get_pixel(x, y);
196   
197   // get the color base from the ppu
198   UINT32 color_base = m_ppu->get_colorbase();
199   
200   // check if the cursor is over a bright pixel
201   if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
202      (pix == color_base + 0x33) || (pix == color_base + 0x34))
203      return true;
204   else
205      return false;
206}
trunk/src/mess/mess.mak
r243138r243139
614614BUSES += MSX_SLOT
615615BUSES += NEOGEO
616616BUSES += NES
617BUSES += NES_CTRL
617618BUSES += NUBUS
618619BUSES += O2
619620BUSES += ORICEXT


Previous 199869 Revisions Next


© 1997-2024 The MAME Team