Develop and Download Open Source Software

Browse CVS Repository

Contents of /mame32jp/mame32jp/src/inptport.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Tue May 7 00:17:30 2002 UTC (21 years, 11 months ago) by zero
Branch: MAIN
CVS Tags: ver_0_60_1, ver0_60_2, ver0_60_3, ver0_60_4, ver0_60_5, HEAD
Changes since 1.5: +15 -2 lines
File MIME type: text/x-chdr
*** empty log message ***

1 #ifndef INPTPORT_H
2 #define INPTPORT_H
3
4 #include "memory.h"
5 #include "input.h"
6
7 /* input ports handling */
8
9 /* Don't confuse this with the I/O ports in memory.h. This is used to handle game */
10 /* inputs (joystick, coin slots, etc). Typically, you will read them using */
11 /* input_port_[n]_r(), which you will associate to the appropriate memory */
12 /* address or I/O port. */
13
14 /***************************************************************************/
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 struct InputPortTiny
20 {
21 UINT16 mask; /* bits affected */
22 UINT16 default_value; /* default value for the bits affected */
23 /* you can also use one of the IP_ACTIVE defines below */
24 UINT32 type; /* see defines below */
25 const char *name; /* name to display */
26 };
27
28 struct InputPort
29 {
30 UINT16 mask; /* bits affected */
31 UINT16 default_value; /* default value for the bits affected */
32 /* you can also use one of the IP_ACTIVE defines below */
33 UINT32 type; /* see defines below */
34 const char *name; /* name to display */
35 InputSeq seq; /* input sequence affecting the input bits */
36 #ifdef MESS
37 UINT32 arg; /* extra argument needed in some cases */
38 UINT16 min, max; /* for analog controls */
39 #endif
40 };
41
42
43 #define IP_ACTIVE_HIGH 0x0000
44 #define IP_ACTIVE_LOW 0xffff
45
46 enum { IPT_END=1,IPT_PORT,
47 /* use IPT_JOYSTICK for panels where the player has one single joystick */
48 IPT_JOYSTICK_UP, IPT_JOYSTICK_DOWN, IPT_JOYSTICK_LEFT, IPT_JOYSTICK_RIGHT,
49 /* use IPT_JOYSTICKLEFT and IPT_JOYSTICKRIGHT for dual joystick panels */
50 IPT_JOYSTICKRIGHT_UP, IPT_JOYSTICKRIGHT_DOWN, IPT_JOYSTICKRIGHT_LEFT, IPT_JOYSTICKRIGHT_RIGHT,
51 IPT_JOYSTICKLEFT_UP, IPT_JOYSTICKLEFT_DOWN, IPT_JOYSTICKLEFT_LEFT, IPT_JOYSTICKLEFT_RIGHT,
52 IPT_BUTTON1, IPT_BUTTON2, IPT_BUTTON3, IPT_BUTTON4, /* action buttons */
53 IPT_BUTTON5, IPT_BUTTON6, IPT_BUTTON7, IPT_BUTTON8, IPT_BUTTON9, IPT_BUTTON10,
54
55 #ifdef MAME32JP
56 IPT_NEOGEO1, IPT_NEOGEO2, IPT_NEOGEO3, IPT_NEOGEO4, IPT_NEOGEO5,
57 IPT_NEOGEO6, IPT_NEOGEO7, IPT_NEOGEO8, IPT_NEOGEO9, IPT_NEOGEO10,
58 IPT_CPS1, IPT_CPS2, IPT_CPS3, IPT_CPS4, IPT_CPS5, IPT_CPS6, IPT_CPS7,
59 IPT_SPEC,
60 #endif
61
62 /* analog inputs */
63 /* the "arg" field contains the default sensitivity expressed as a percentage */
64 /* (100 = default, 50 = half, 200 = twice) */
65 IPT_ANALOG_START,
66 IPT_PADDLE, IPT_PADDLE_V,
67 IPT_DIAL, IPT_DIAL_V,
68 IPT_TRACKBALL_X, IPT_TRACKBALL_Y,
69 IPT_AD_STICK_X, IPT_AD_STICK_Y,
70 IPT_PEDAL,
71 IPT_ANALOG_END,
72
73 IPT_START1, IPT_START2, IPT_START3, IPT_START4, /* start buttons */
74 IPT_COIN1, IPT_COIN2, IPT_COIN3, IPT_COIN4, /* coin slots */
75 IPT_SERVICE1, IPT_SERVICE2, IPT_SERVICE3, IPT_SERVICE4, /* service coin */
76 IPT_SERVICE, IPT_TILT,
77 IPT_DIPSWITCH_NAME, IPT_DIPSWITCH_SETTING,
78 /* Many games poll an input bit to check for vertical blanks instead of using */
79 /* interrupts. This special value allows you to handle that. If you set one of the */
80 /* input bits to this, the bit will be inverted while a vertical blank is happening. */
81 IPT_VBLANK,
82 IPT_UNKNOWN,
83 IPT_OSD_RESERVED,
84 IPT_OSD_1,
85 IPT_OSD_2,
86 IPT_OSD_3,
87 IPT_OSD_4,
88 IPT_EXTENSION, /* this is an extension on the previous InputPort, not a real inputport. */
89 /* It is used to store additional parameters for analog inputs */
90
91 /* the following are special codes for user interface handling - not to be used by drivers! */
92 IPT_UI_CONFIGURE,
93 IPT_UI_ON_SCREEN_DISPLAY,
94 IPT_UI_PAUSE,
95 IPT_UI_RESET_MACHINE,
96 IPT_UI_SHOW_GFX,
97 IPT_UI_FRAMESKIP_DEC,
98 IPT_UI_FRAMESKIP_INC,
99 IPT_UI_THROTTLE,
100 IPT_UI_SHOW_FPS,
101 IPT_UI_SNAPSHOT,
102 IPT_UI_TOGGLE_CHEAT,
103 IPT_UI_UP,
104 IPT_UI_DOWN,
105 IPT_UI_LEFT,
106 IPT_UI_RIGHT,
107 IPT_UI_SELECT,
108 IPT_UI_CANCEL,
109 IPT_UI_PAN_UP, IPT_UI_PAN_DOWN, IPT_UI_PAN_LEFT, IPT_UI_PAN_RIGHT,
110 IPT_UI_SHOW_PROFILER,
111 IPT_UI_TOGGLE_UI,
112 IPT_UI_TOGGLE_DEBUG,
113 IPT_UI_SAVE_STATE,
114 IPT_UI_LOAD_STATE,
115 IPT_UI_ADD_CHEAT,
116 IPT_UI_DELETE_CHEAT,
117 IPT_UI_SAVE_CHEAT,
118 IPT_UI_WATCH_VALUE,
119 IPT_UI_EDIT_CHEAT,
120 #ifdef MAME32JP
121 IPT_UI_TOGGLE_AUTOFIRE,
122 IPT_UI_TOGGLE_LOGWAVE,
123 IPT_UI_COMMAND,
124 #endif
125 __ipt_max
126 };
127
128 #define IPT_UNUSED IPF_UNUSED
129 #define IPT_SPECIAL IPT_UNUSED /* special meaning handled by custom functions */
130
131 #define IPF_MASK 0xffffff00
132 #define IPF_UNUSED 0x80000000 /* The bit is not used by this game, but is used */
133 /* by other games running on the same hardware. */
134 /* This is different from IPT_UNUSED, which marks */
135 /* bits not connected to anything. */
136 #define IPF_COCKTAIL IPF_PLAYER2 /* the bit is used in cocktail mode only */
137
138 #define IPF_CHEAT 0x40000000 /* Indicates that the input bit is a "cheat" key */
139 /* (providing invulnerabilty, level advance, and */
140 /* so on). MAME will not recognize it when the */
141 /* -nocheat command line option is specified. */
142
143 #ifdef MAME32JP
144 #define IPF_AUTOFIRE_ON 0x10000000 /* Autofire enable bit */
145 #define IPF_AUTOFIRE_TOGGLE 0x20000000 /* Autofire toggle enable bit */
146 #define IPF_AUTOFIRE_MASK 0x30000000 /* Autofire flag mask */
147 #define IPF_AUTOFIRE_SHIFT 28 /* Autofire flag shift */
148 #endif
149
150 #define IPF_PLAYERMASK 0x00030000 /* use IPF_PLAYERn if more than one person can */
151 #define IPF_PLAYER1 0 /* play at the same time. The IPT_ should be the same */
152 #define IPF_PLAYER2 0x00010000 /* for all players (e.g. IPT_BUTTON1 | IPF_PLAYER2) */
153 #define IPF_PLAYER3 0x00020000 /* IPF_PLAYER1 is the default and can be left out to */
154 #define IPF_PLAYER4 0x00030000 /* increase readability. */
155
156 #define IPF_8WAY 0 /* Joystick modes of operation. 8WAY is the default, */
157 #define IPF_4WAY 0x00080000 /* it prevents left/right or up/down to be pressed at */
158 #define IPF_2WAY 0 /* the same time. 4WAY prevents diagonal directions. */
159 /* 2WAY should be used for joysticks wich move only */
160 /* on one axis (e.g. Battle Zone) */
161
162 #define IPF_IMPULSE 0x00100000 /* When this is set, when the key corrisponding to */
163 /* the input bit is pressed it will be reported as */
164 /* pressed for a certain number of video frames and */
165 /* then released, regardless of the real status of */
166 /* the key. This is useful e.g. for some coin inputs. */
167 /* The number of frames the signal should stay active */
168 /* is specified in the "arg" field. */
169 #define IPF_TOGGLE 0x00200000 /* When this is set, the key acts as a toggle - press */
170 /* it once and it goes on, press it again and it goes off. */
171 /* useful e.g. for sone Test Mode dip switches. */
172 #define IPF_REVERSE 0x00400000 /* By default, analog inputs like IPT_TRACKBALL increase */
173 /* when going right/up. This flag inverts them. */
174
175 #define IPF_CENTER 0x00800000 /* always preload in->default, autocentering the STICK/TRACKBALL */
176
177 #define IPF_CUSTOM_UPDATE 0x01000000 /* normally, analog ports are updated when they are accessed. */
178 /* When this flag is set, they are never updated automatically, */
179 /* it is the responsibility of the driver to call */
180 /* update_analog_port(int port). */
181
182 #define IPF_RESETCPU 0x02000000 /* when the key is pressed, reset the first CPU */
183
184
185 /* The "arg" field contains 4 bytes fields */
186 #define IPF_SENSITIVITY(percent) ((percent & 0xff) << 8)
187 #define IPF_DELTA(val) ((val & 0xff) << 16)
188
189 #define IP_GET_IMPULSE(port) (((port)->type >> 8) & 0xff)
190 #define IP_GET_SENSITIVITY(port) ((((port)+1)->type >> 8) & 0xff)
191 #define IP_SET_SENSITIVITY(port,val) ((port)+1)->type = ((port+1)->type & 0xffff00ff)|((val&0xff)<<8)
192 #define IP_GET_DELTA(port) ((((port)+1)->type >> 16) & 0xff)
193 #define IP_SET_DELTA(port,val) ((port)+1)->type = ((port+1)->type & 0xff00ffff)|((val&0xff)<<16)
194 #define IP_GET_MIN(port) (((port)+1)->mask)
195 #define IP_GET_MAX(port) (((port)+1)->default_value)
196 #define IP_GET_CODE_OR1(port) ((port)->mask)
197 #define IP_GET_CODE_OR2(port) ((port)->default_value)
198
199 #define IP_NAME_DEFAULT ((const char *)-1)
200
201 /* Wrapper for compatibility */
202 #define IP_KEY_DEFAULT CODE_DEFAULT
203 #define IP_JOY_DEFAULT CODE_DEFAULT
204 #define IP_KEY_PREVIOUS CODE_PREVIOUS
205 #define IP_JOY_PREVIOUS CODE_PREVIOUS
206 #define IP_KEY_NONE CODE_NONE
207 #define IP_JOY_NONE CODE_NONE
208
209 /* start of table */
210 #define INPUT_PORTS_START(name) \
211 static const struct InputPortTiny input_ports_##name[] = {
212
213 /* end of table */
214 #define INPUT_PORTS_END \
215 { 0, 0, IPT_END, 0 } \
216 };
217 /* start of a new input port */
218 #define PORT_START \
219 { 0, 0, IPT_PORT, 0 },
220
221 /* input bit definition */
222 #define PORT_BIT_NAME(mask,default,type,name) \
223 { mask, default, type, name },
224 #define PORT_BIT(mask,default,type) \
225 PORT_BIT_NAME(mask, default, type, IP_NAME_DEFAULT)
226
227 /* impulse input bit definition */
228 #define PORT_BIT_IMPULSE_NAME(mask,default,type,duration,name) \
229 PORT_BIT_NAME(mask, default, type | IPF_IMPULSE | ((duration & 0xff) << 8), name)
230 #define PORT_BIT_IMPULSE(mask,default,type,duration) \
231 PORT_BIT_IMPULSE_NAME(mask, default, type, duration, IP_NAME_DEFAULT)
232
233 /* key/joy code specification */
234 #define PORT_CODE(key,joy) \
235 { key, joy, IPT_EXTENSION, 0 },
236
237 /* input bit definition with extended fields */
238 #define PORT_BITX(mask,default,type,name,key,joy) \
239 PORT_BIT_NAME(mask, default, type, name) \
240 PORT_CODE(key,joy)
241
242 /* analog input */
243 #define PORT_ANALOG(mask,default,type,sensitivity,delta,min,max) \
244 PORT_BIT(mask, default, type) \
245 { min, max, IPT_EXTENSION | IPF_SENSITIVITY(sensitivity) | IPF_DELTA(delta), IP_NAME_DEFAULT },
246
247 #define PORT_ANALOGX(mask,default,type,sensitivity,delta,min,max,keydec,keyinc,joydec,joyinc) \
248 PORT_BIT(mask, default, type) \
249 { min, max, IPT_EXTENSION | IPF_SENSITIVITY(sensitivity) | IPF_DELTA(delta), IP_NAME_DEFAULT }, \
250 PORT_CODE(keydec,joydec) \
251 PORT_CODE(keyinc,joyinc)
252
253 /* dip switch definition */
254 #define PORT_DIPNAME(mask,default,name) \
255 PORT_BIT_NAME(mask, default, IPT_DIPSWITCH_NAME, name)
256
257 #define PORT_DIPSETTING(default,name) \
258 PORT_BIT_NAME(0, default, IPT_DIPSWITCH_SETTING, name)
259
260
261 #define PORT_SERVICE(mask,default) \
262 PORT_BITX( mask, mask & default, IPT_DIPSWITCH_NAME | IPF_TOGGLE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE ) \
263 PORT_DIPSETTING( mask & default, DEF_STR( Off ) ) \
264 PORT_DIPSETTING( mask &~default, DEF_STR( On ) )
265
266 #define PORT_SERVICE_NO_TOGGLE(mask,default) \
267 PORT_BITX( mask, mask & default, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
268
269 #define MAX_DEFSTR_LEN 20
270 extern char ipdn_defaultstrings[][MAX_DEFSTR_LEN];
271
272 /* this must match the ipdn_defaultstrings list in inptport.c */
273 enum {
274 STR_Off,
275 STR_On,
276 STR_No,
277 STR_Yes,
278 STR_Lives,
279 STR_Bonus_Life,
280 STR_Difficulty,
281 STR_Demo_Sounds,
282 STR_Coinage,
283 STR_Coin_A,
284 STR_Coin_B,
285 STR_9C_1C,
286 STR_8C_1C,
287 STR_7C_1C,
288 STR_6C_1C,
289 STR_5C_1C,
290 STR_4C_1C,
291 STR_3C_1C,
292 STR_8C_3C,
293 STR_4C_2C,
294 STR_2C_1C,
295 STR_5C_3C,
296 STR_3C_2C,
297 STR_4C_3C,
298 STR_4C_4C,
299 STR_3C_3C,
300 STR_2C_2C,
301 STR_1C_1C,
302 STR_4C_5C,
303 STR_3C_4C,
304 STR_2C_3C,
305 STR_4C_7C,
306 STR_2C_4C,
307 STR_1C_2C,
308 STR_2C_5C,
309 STR_2C_6C,
310 STR_1C_3C,
311 STR_2C_7C,
312 STR_2C_8C,
313 STR_1C_4C,
314 STR_1C_5C,
315 STR_1C_6C,
316 STR_1C_7C,
317 STR_1C_8C,
318 STR_1C_9C,
319 STR_Free_Play,
320 STR_Cabinet,
321 STR_Upright,
322 STR_Cocktail,
323 STR_Flip_Screen,
324 STR_Service_Mode,
325 STR_Unused,
326 STR_Unknown,
327 STR_TOTAL
328 };
329
330 enum { IKT_STD, IKT_IPT, IKT_IPT_EXT, IKT_OSD_KEY, IKT_OSD_JOY };
331
332 #define DEF_STR(str_num) (ipdn_defaultstrings[STR_##str_num])
333
334 #define MAX_INPUT_PORTS 20
335
336
337 int load_input_port_settings(void);
338 void save_input_port_settings(void);
339
340 const char *input_port_name(const struct InputPort *in);
341 InputSeq* input_port_type_seq(int type);
342 InputSeq* input_port_seq(const struct InputPort *in);
343
344 struct InputPort* input_port_allocate(const struct InputPortTiny *src);
345 void input_port_free(struct InputPort* dst);
346
347 #ifdef MAME_NET
348 void set_default_player_controls(int player);
349 #endif /* MAME_NET */
350
351 void update_analog_port(int port);
352 void update_input_ports(void); /* called by cpuintrf.c - not for external use */
353 void inputport_vblank_end(void); /* called by cpuintrf.c - not for external use */
354
355 int readinputport(int port);
356 READ_HANDLER( input_port_0_r );
357 READ_HANDLER( input_port_1_r );
358 READ_HANDLER( input_port_2_r );
359 READ_HANDLER( input_port_3_r );
360 READ_HANDLER( input_port_4_r );
361 READ_HANDLER( input_port_5_r );
362 READ_HANDLER( input_port_6_r );
363 READ_HANDLER( input_port_7_r );
364 READ_HANDLER( input_port_8_r );
365 READ_HANDLER( input_port_9_r );
366 READ_HANDLER( input_port_10_r );
367 READ_HANDLER( input_port_11_r );
368 READ_HANDLER( input_port_12_r );
369 READ_HANDLER( input_port_13_r );
370 READ_HANDLER( input_port_14_r );
371 READ_HANDLER( input_port_15_r );
372 READ_HANDLER( input_port_16_r );
373 READ_HANDLER( input_port_17_r );
374 READ_HANDLER( input_port_18_r );
375 READ_HANDLER( input_port_19_r );
376
377 READ16_HANDLER( input_port_0_word_r );
378 READ16_HANDLER( input_port_1_word_r );
379 READ16_HANDLER( input_port_2_word_r );
380 READ16_HANDLER( input_port_3_word_r );
381 READ16_HANDLER( input_port_4_word_r );
382 READ16_HANDLER( input_port_5_word_r );
383 READ16_HANDLER( input_port_6_word_r );
384 READ16_HANDLER( input_port_7_word_r );
385 READ16_HANDLER( input_port_8_word_r );
386 READ16_HANDLER( input_port_9_word_r );
387 READ16_HANDLER( input_port_10_word_r );
388 READ16_HANDLER( input_port_11_word_r );
389 READ16_HANDLER( input_port_12_word_r );
390 READ16_HANDLER( input_port_13_word_r );
391 READ16_HANDLER( input_port_14_word_r );
392 READ16_HANDLER( input_port_15_word_r );
393 READ16_HANDLER( input_port_16_word_r );
394 READ16_HANDLER( input_port_17_word_r );
395 READ16_HANDLER( input_port_18_word_r );
396 READ16_HANDLER( input_port_19_word_r );
397
398 struct ipd
399 {
400 UINT32 type;
401 const char *name;
402 InputSeq seq;
403 };
404
405 struct ik
406 {
407 char *name;
408 UINT32 type;
409 UINT32 val;
410 };
411 extern struct ik input_keywords[];
412 extern struct ik *osd_input_keywords;
413 extern int num_ik;
414
415 void seq_set_string(InputSeq* a, const char *buf);
416
417 #ifdef __cplusplus
418 }
419 #endif
420
421
422 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26