Previous 199869 Revisions Next

r22825 Tuesday 14th May, 2013 at 21:39:57 UTC by Carl
(mess) pc_joy_sw: add MS Sidewinder pad [Carl]
[src/mess]mess.mak
[src/mess/drivers]pc.c
[src/mess/machine]pc_joy.c pc_joy_sw.c* pc_joy_sw.h*

trunk/src/mess/drivers/pc.c
r22824r22825
15381538   MCFG_CPU_PROGRAM_MAP(iskr1031_map)
15391539   MCFG_CPU_IO_MAP(asst128_io)
15401540
1541   MCFG_DEVICE_REMOVE("fdc:0");
1542   MCFG_DEVICE_REMOVE("fdc:1");
1541   MCFG_DEVICE_REMOVE("dma8237")
1542   MCFG_DEVICE_REMOVE("fdc:0")
1543   MCFG_DEVICE_REMOVE("fdc:1")
15431544
15441545   MCFG_FLOPPY_DRIVE_ADD("fdc:0", asst128_floppies, "525ssqd", 0, pc_state::asst128_formats)
15451546   MCFG_FLOPPY_DRIVE_ADD("fdc:1", asst128_floppies, "525ssqd", 0, pc_state::asst128_formats)
trunk/src/mess/mess.mak
r22824r22825
15421542$(MESSOBJ)/pcshare.a:           \
15431543   $(MESS_MACHINE)/pc_fdc.o    \
15441544   $(MESS_MACHINE)/pc_joy.o    \
1545   $(MESS_MACHINE)/pc_joy_sw.o \
15451546   $(MESS_MACHINE)/pc_keyboards.o \
15461547   $(MESS_MACHINE)/kb_keytro.o \
15471548   $(MESS_MACHINE)/kb_msnat.o  \
trunk/src/mess/machine/pc_joy_sw.c
r0r22825
1//TODO: determine when to switch modes and add single bit mode
2
3#include "machine/pc_joy_sw.h"
4
5const device_type PC_MSSW_PAD = &device_creator<pc_mssw_pad_device>;
6
7pc_mssw_pad_device::pc_mssw_pad_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
8   device_t(mconfig, PC_MSSW_PAD, "Microsoft Sidewinder Pad", tag, owner, clock, "mssw_pad", __FILE__),
9   device_pc_joy_interface(mconfig, *this),
10   m_btn1(*this, "btn1"),
11   m_btn2(*this, "btn2"),
12   m_btn3(*this, "btn3"),
13   m_btn4(*this, "btn4"),
14   m_conf(*this, "CONFIG")
15{
16}
17
18void pc_mssw_pad_device::device_start()
19{
20   m_timer = timer_alloc();
21}
22
23void pc_mssw_pad_device::device_reset()
24{
25   m_count = 0;
26   m_state = 0xf;
27   m_active = false;
28   m_timer->adjust(attotime::never, 0);
29}
30
31void pc_mssw_pad_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
32{
33   UINT16 pad_state = 0;
34   // only multibit mode for now
35   if(m_count == -1)
36   {
37      reset();
38      return;
39   }
40
41   if((m_count / 5) > m_conf->read())
42   {
43      m_timer->adjust(attotime::from_usec(50), 0);
44      m_state &= ~1;
45      m_count = -1;
46      return;
47   }
48
49   if(m_state & 1)
50   {
51      m_state &= ~1;
52      return;
53   }
54
55   switch(m_count / 5)
56   {
57      case 0:
58         pad_state = m_btn1->read();
59         break;
60      case 1:
61         pad_state = m_btn2->read();
62         break;
63      case 2:
64         pad_state = m_btn3->read();
65         break;
66      case 3:
67         pad_state = m_btn4->read();
68         break;
69   }
70
71   switch(m_count % 5)
72   {
73      case 0:
74         m_state = ((pad_state & 7) << 1) | 1;
75         break;
76      case 1:
77         m_state = ((pad_state & 0x38) >> 2) | 1;
78         break;
79      case 2:
80         m_state = ((pad_state & 0x1c0) >> 5) | 1;
81         break;
82      case 3:
83         m_state = ((pad_state & 0xe00) >> 8) | 1;
84         break;
85      case 4:
86      {
87         UINT8 parity = (pad_state >> 8) ^ pad_state;
88         parity = (parity >> 4) ^ parity;
89         parity = (parity >> 2) ^ parity;
90         parity = (((parity >> 1) ^ parity) & 1);
91
92         m_state = ((pad_state & 0x3000) >> 11) | (parity << 3) | 1;
93         break;
94      }
95   }
96   m_count++;
97}
98
99static INPUT_PORTS_START( sidewinder_pad )
100   PORT_START("btn1")
101   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
102   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
103   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
104   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
105   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("A")
106   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("B")
107   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("C")
108   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("X")
109   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Y")
110   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Z")
111   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("L")
112   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("R")
113   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Start")
114   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("M")
115   PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED )
116   PORT_START("btn2")
117   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
118   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
119   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
120   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
121   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("A") PORT_PLAYER(2)
122   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("B") PORT_PLAYER(2)
123   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("C") PORT_PLAYER(2)
124   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("X") PORT_PLAYER(2)
125   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Y") PORT_PLAYER(2)
126   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Z") PORT_PLAYER(2)
127   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("L") PORT_PLAYER(2)
128   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("R") PORT_PLAYER(2)
129   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Start") PORT_PLAYER(2)
130   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("M") PORT_PLAYER(2)
131   PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED )
132   PORT_START("btn3")
133   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(3)
134   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3)
135   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3)
136   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3)
137   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("A") PORT_PLAYER(3)
138   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("B") PORT_PLAYER(3)
139   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("C") PORT_PLAYER(3)
140   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("X") PORT_PLAYER(3)
141   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Y") PORT_PLAYER(3)
142   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Z") PORT_PLAYER(3)
143   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("L") PORT_PLAYER(3)
144   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("R") PORT_PLAYER(3)
145   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Start") PORT_PLAYER(3)
146   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("M") PORT_PLAYER(3)
147   PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED )
148   PORT_START("btn4")
149   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(4)
150   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4)
151   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4)
152   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4)
153   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("A") PORT_PLAYER(4)
154   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("B") PORT_PLAYER(4)
155   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("C") PORT_PLAYER(4)
156   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("X") PORT_PLAYER(4)
157   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Y") PORT_PLAYER(4)
158   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Z") PORT_PLAYER(4)
159   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("L") PORT_PLAYER(4)
160   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("R") PORT_PLAYER(4)
161   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Start") PORT_PLAYER(4)
162   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("M") PORT_PLAYER(4)
163   PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED )
164   PORT_START("CONFIG")
165   PORT_CONFNAME(0x03, 0x00, "Number of Sidewinder Pads")
166   PORT_CONFSETTING( 0x00, "1")
167   PORT_CONFSETTING( 0x01, "2")
168   PORT_CONFSETTING( 0x02, "3")
169   PORT_CONFSETTING( 0x03, "4")
170INPUT_PORTS_END
171
172ioport_constructor pc_mssw_pad_device::device_input_ports() const
173{
174   return INPUT_PORTS_NAME( sidewinder_pad );
175}
176
177
Property changes on: trunk/src/mess/machine/pc_joy_sw.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mess/machine/pc_joy_sw.h
r0r22825
1#ifndef PC_JOY_SW_H_
2#define PC_JOY_SW_H_
3
4#include "machine/pc_joy.h"
5
6class pc_mssw_pad_device :  public device_t,
7                     public device_pc_joy_interface
8{
9public:
10   pc_mssw_pad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
11   virtual ioport_constructor device_input_ports() const;
12
13   virtual UINT8 btn() { return m_state; }
14   // timing is guessed, calibrated for at486
15   virtual void port_write() { if(!m_active) { m_timer->adjust(attotime::from_usec(50), 0, attotime::from_usec(5)); m_active = true; } }
16
17protected:
18   virtual void device_start();
19   virtual void device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr);
20   virtual void device_reset();
21
22private:
23   required_ioport m_btn1;
24   required_ioport m_btn2;
25   required_ioport m_btn3;
26   required_ioport m_btn4;
27   required_ioport m_conf;
28   emu_timer *m_timer;
29   int m_count;
30   UINT8 m_state;
31   bool m_active;
32};
33
34extern const device_type PC_MSSW_PAD;
35
36#endif /* PC_JOY_SW_H_ */
Property changes on: trunk/src/mess/machine/pc_joy_sw.h
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/mess/machine/pc_joy.c
r22824r22825
77 *************************************************************************/
88
99#include "pc_joy.h"
10#include "pc_joy_sw.h"
1011
1112const device_type PC_JOY = &device_creator<pc_joy_device>;
1213
r22824r22825
8687
8788SLOT_INTERFACE_START(pc_joysticks)
8889   SLOT_INTERFACE("basic_joy", PC_BASIC_JOY)
90   SLOT_INTERFACE("mssw_pad", PC_MSSW_PAD)
8991SLOT_INTERFACE_END

Previous 199869 Revisions Next


© 1997-2024 The MAME Team