comparison src/joystick/mint/SDL_sysjoystick.c @ 302:8a86bdf34f0f

Added Atari joystick support (thanks Patrice!)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 07 Mar 2002 20:23:11 +0000
parents
children 9c6613983e85
comparison
equal deleted inserted replaced
301:fb4c4c6a2773 302:8a86bdf34f0f
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22
23 #ifdef SAVE_RCSID
24 static char rcsid =
25 "@(#) $Id$";
26 #endif
27
28 /*
29 * Atari Joystick/Joypad drivers
30 *
31 * Patrice Mandin
32 */
33
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include <sys/cookie.h>
38 #include <mint/osbind.h>
39
40 #include "SDL_types.h"
41 #include "SDL_error.h"
42 #include "SDL_joystick.h"
43 #include "SDL_sysjoystick.h"
44 #include "SDL_joystick_c.h"
45
46 #include "../video/ataricommon/SDL_ikbdinterrupt_s.h"
47
48 /*--- Const ---*/
49
50 /* We can have:
51 1 joystick on IKBD port 1 (port 0 is used by mouse)
52 2 joypads on ports A,B
53 or 4 joysticks on joypads ports A,B
54 or 1 lightpen on joypad port A
55 or 2 analog paddles on joypads ports A,B
56 2 joysticks on parallel port
57 */
58
59 enum {
60 IKBD_JOY1=0,
61 PORTA_PAD,
62 PORTB_PAD,
63 PORTA_JOY0,
64 PORTA_JOY1,
65 PORTB_JOY0,
66 PORTB_JOY1,
67 PORTA_LP,
68 PORTA_ANPAD,
69 PORTB_ANPAD,
70 #if 0
71 PARA_JOY0,
72 PARA_JOY1,
73 #endif
74 MAX_JOYSTICKS
75 };
76
77 enum {
78 MCH_ST=0,
79 MCH_STE,
80 MCH_TT,
81 MCH_F30
82 };
83
84 /* Joypad buttons
85 * Procontroller note:
86 * L,R are connected to 4,6
87 * X,Y,Z are connected to 7,8,9
88 */
89
90 enum {
91 JP_UP=0, JP_DOWN, JP_LEFT, JP_RIGHT,
92 JP_KPMULT, JP_KP7, JP_KP4, JP_KP1,
93 JP_KP0, JP_KP8, JP_KP5, JP_KP2,
94 JP_KPNUM, JP_KP9, JP_KP6, JP_KP3,
95 JP_PAUSE, JP_FIRE0, JP_UNDEF0, JP_FIRE1,
96 JP_UNDEF1, JP_FIRE2, JP_UNDEF2, JP_OPTION
97 };
98
99 #define JP_NUM_BUTTONS 17
100
101 #define PORT_JS_RIGHT (1<<0)
102 #define PORT_JS_LEFT (1<<1)
103 #define PORT_JS_DOWN (1<<2)
104 #define PORT_JS_UP (1<<3)
105 #define PORT_JS_FIRE (1<<4)
106
107 /*--- Types ---*/
108
109 typedef struct {
110 SDL_bool enabled;
111 unsigned char *name;
112 Uint32 prevstate;
113 } atarijoy_t;
114
115 /*--- Variables ---*/
116
117 static atarijoy_t atarijoysticks[MAX_JOYSTICKS]={
118 {SDL_FALSE,"IKBD joystick port 1",0},
119 {SDL_FALSE,"Joypad port A",0},
120 {SDL_FALSE,"Joypad port B",0},
121 {SDL_FALSE,"Joystick 0 port A",0},
122 {SDL_FALSE,"Joystick 1 port A",0},
123 {SDL_FALSE,"Joystick 0 port B",0},
124 {SDL_FALSE,"Joystick 1 port B",0},
125 {SDL_FALSE,"Lightpen port A",0},
126 {SDL_FALSE,"Analog paddle port A",0},
127 {SDL_FALSE,"Analog paddle port B",0}
128 #if 0
129 ,{SDL_FALSE,"Joystick 0 parallel port",0},
130 {SDL_FALSE,"Joystick 1 parallel port",0}
131 #endif
132 };
133
134 static const int jp_buttons[JP_NUM_BUTTONS]={
135 JP_KPMULT, JP_KP7, JP_KP4, JP_KP1,
136 JP_KP0, JP_KP8, JP_KP5, JP_KP2,
137 JP_KPNUM, JP_KP9, JP_KP6, JP_KP3,
138 JP_PAUSE, JP_FIRE0, JP_FIRE1, JP_FIRE2,
139 JP_OPTION
140 };
141
142 static SDL_bool joypad_ports_enabled=SDL_FALSE;
143
144 /* Updated joypad ports */
145 static Uint16 jp_paddles[4];
146 static Uint16 jp_lightpens[2];
147 static Uint16 jp_directions;
148 static Uint16 jp_fires;
149 static Uint32 jp_joypads[2];
150
151 /*--- Functions prototypes ---*/
152
153 static int GetEnabledAtariJoystick(int index);
154 static void UpdateJoypads(void);
155
156 /*--- Functions ---*/
157
158 int SDL_SYS_JoystickInit(void)
159 {
160 int i;
161 unsigned long cookie_mch;
162 const char *envr=getenv("SDL_JOYSTICK_ATARI");
163 const char *env_evt=getenv("SDL_ATARI_EVENTSDRIVER");
164 SDL_bool ikbd_enabled=SDL_FALSE;
165
166 #define TEST_JOY_ENABLED(env,idstring,num) \
167 if (strstr(env,idstring"-off")) { \
168 atarijoysticks[num].enabled=SDL_FALSE; \
169 } \
170 if (strstr(env,idstring"-on")) { \
171 atarijoysticks[num].enabled=SDL_TRUE; \
172 }
173
174 /* Cookie _MCH present ? if not, assume ST machine */
175 if (Getcookie(C__MCH, &cookie_mch) != C_FOUND) {
176 cookie_mch = MCH_ST << 16;
177 }
178
179 /* Enable some default joysticks */
180 if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
181 (cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16)) {
182 ikbd_enabled=SDL_TRUE;
183 if (env_evt) {
184 if (!strcmp(env_evt,"ikbd")) {
185 ikbd_enabled=SDL_FALSE;
186 }
187 }
188 atarijoysticks[IKBD_JOY1].enabled=ikbd_enabled;
189 }
190 if ((cookie_mch == MCH_STE<<16) || (cookie_mch == MCH_F30<<16)) {
191 atarijoysticks[PORTA_PAD].enabled=SDL_TRUE;
192 atarijoysticks[PORTB_PAD].enabled=SDL_TRUE;
193 }
194
195 /* Read environment for joysticks to enable */
196 if (envr) {
197 /* IKBD on any Atari, maybe clones */
198 if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
199 (cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16)) {
200 if (env_evt) {
201 if (strcmp(env_evt,"ikbd")) {
202 TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1);
203 }
204 }
205 }
206 /* Joypads ports only on STE and Falcon */
207 if ((cookie_mch == MCH_STE<<16) || (cookie_mch == MCH_F30<<16)) {
208 TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD);
209 if (!atarijoysticks[PORTA_PAD].enabled) {
210 TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0);
211 TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1);
212 if (!(atarijoysticks[PORTA_JOY0].enabled) && !(atarijoysticks[PORTA_JOY1].enabled)) {
213 TEST_JOY_ENABLED(envr, "porta-lp", PORTA_LP);
214 if (!atarijoysticks[PORTA_LP].enabled) {
215 TEST_JOY_ENABLED(envr, "porta-anpad", PORTA_ANPAD);
216 }
217 }
218 }
219
220 TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD);
221 if (!atarijoysticks[PORTB_PAD].enabled) {
222 TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0);
223 TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1);
224 if (!(atarijoysticks[PORTB_JOY0].enabled) && !(atarijoysticks[PORTB_JOY1].enabled)) {
225 TEST_JOY_ENABLED(envr, "portb-anpad", PORTB_ANPAD);
226 }
227 }
228 }
229 #if 0
230 /* Parallel port on any Atari, maybe clones */
231 if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
232 (cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16)) {
233 TEST_JOY_ENABLED(envr, "para-joy0", PARA_JOY0);
234 TEST_JOY_ENABLED(envr, "para-joy1", PARA_JOY1);
235 }
236 #endif
237 }
238
239 /* Need to update joypad ports ? */
240 joypad_ports_enabled=SDL_FALSE;
241 for (i=PORTA_PAD;i<=PORTB_ANPAD;i++) {
242 if (atarijoysticks[i].enabled) {
243 joypad_ports_enabled=SDL_TRUE;
244 break;
245 }
246 }
247
248 SDL_numjoysticks = 0;
249 for (i=0;i<MAX_JOYSTICKS;i++) {
250 if (atarijoysticks[i].enabled) {
251 ++SDL_numjoysticks;
252 }
253 }
254
255 return(SDL_numjoysticks);
256 }
257
258 static int GetEnabledAtariJoystick(int index)
259 {
260 int i,j;
261
262 /* Return the nth'index' enabled atari joystick */
263 j=0;
264 for (i=0;i<MAX_JOYSTICKS;i++) {
265 if (atarijoysticks[i].enabled) {
266 if (j==index) {
267 break;
268 } else {
269 j++;
270 }
271 }
272 }
273 if (i==MAX_JOYSTICKS)
274 return -1;
275
276 return i;
277 }
278
279 const char *SDL_SYS_JoystickName(int index)
280 {
281 int numjoystick;
282
283 numjoystick=GetEnabledAtariJoystick(index);
284 if (numjoystick==-1)
285 return NULL;
286
287 return(atarijoysticks[numjoystick].name);
288 }
289
290 int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
291 {
292 int numjoystick;
293
294 numjoystick=GetEnabledAtariJoystick(joystick->index);
295 if (numjoystick==-1)
296 return -1;
297
298 if ((numjoystick==PORTA_PAD) || (numjoystick==PORTB_PAD)) {
299 joystick->nbuttons=JP_NUM_BUTTONS;
300 } else if ((numjoystick==PORTA_LP) || (numjoystick==PORTA_ANPAD) ||
301 (numjoystick==PORTB_ANPAD)) {
302 joystick->nbuttons=2;
303 } else {
304 joystick->nbuttons=1;
305 }
306 joystick->naxes=2;
307 joystick->nballs=0;
308 joystick->nhats=0;
309
310 return(0);
311 }
312
313 void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
314 {
315 int numjoystick;
316 Uint32 curstate,prevstate;
317 Sint16 curaxis;
318
319 numjoystick=GetEnabledAtariJoystick(joystick->index);
320 if (numjoystick==-1)
321 return;
322
323 prevstate = atarijoysticks[numjoystick].prevstate;
324
325 if (joypad_ports_enabled) {
326 Supexec(UpdateJoypads);
327 }
328
329 switch (numjoystick) {
330 case IKBD_JOY1:
331 {
332 curstate = SDL_AtariIkbd_joystick & 0xff;
333 if (curstate != prevstate) {
334 /* X axis */
335 if ((curstate & (IKBD_JOY_LEFT|IKBD_JOY_RIGHT)) != (prevstate & (IKBD_JOY_LEFT|IKBD_JOY_RIGHT))) {
336 curaxis=0;
337 if (curstate & IKBD_JOY_LEFT) {
338 curaxis=-128;
339 } else if (curstate & IKBD_JOY_RIGHT) {
340 curaxis=127;
341 }
342 SDL_PrivateJoystickAxis(joystick,0,curaxis);
343 }
344 /* Y axis */
345 if ((curstate & (IKBD_JOY_UP|IKBD_JOY_DOWN)) != (prevstate & (IKBD_JOY_UP|IKBD_JOY_DOWN))) {
346 curaxis=0;
347 if (curstate & IKBD_JOY_UP) {
348 curaxis=-128;
349 } else if (curstate & IKBD_JOY_DOWN) {
350 curaxis=127;
351 }
352 SDL_PrivateJoystickAxis(joystick,1,curaxis);
353 }
354 /* Button */
355 if ((curstate & IKBD_JOY_FIRE) && !(prevstate & IKBD_JOY_FIRE)) {
356 SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);
357 }
358 if (!(curstate & IKBD_JOY_FIRE) && (prevstate & IKBD_JOY_FIRE)) {
359 SDL_PrivateJoystickButton(joystick,0,SDL_RELEASED);
360 }
361 }
362 atarijoysticks[IKBD_JOY1].prevstate = curstate;
363 }
364 break;
365 case PORTA_PAD:
366 case PORTB_PAD:
367 {
368 int numjoypad,i;
369
370 numjoypad=0;
371 /* if (numjoystick==PORTA_PAD) numjoypad=0;*/
372 if (numjoystick==PORTB_PAD) numjoypad=1;
373
374 curstate=jp_joypads[numjoypad];
375 if (curstate!=prevstate) {
376 /* X axis */
377 if ((curstate & ((1<<JP_LEFT)|(1<<JP_RIGHT))) != (prevstate & ((1<<JP_LEFT)|(1<<JP_RIGHT)))) {
378 curaxis=0;
379 if (curstate & (1<<JP_LEFT)) {
380 curaxis=-128;
381 } else if (curstate & (1<<JP_RIGHT)) {
382 curaxis=127;
383 }
384 SDL_PrivateJoystickAxis(joystick,0,curaxis);
385 }
386 /* Y axis */
387 if ((curstate & ((1<<JP_UP)|(1<<JP_DOWN))) != (prevstate & ((1<<JP_UP)|(1<<JP_DOWN)))) {
388 curaxis=0;
389 if (curstate & (1<<JP_UP)) {
390 curaxis=-128;
391 } else if (curstate & (1<<JP_DOWN)) {
392 curaxis=127;
393 }
394 SDL_PrivateJoystickAxis(joystick,1,curaxis);
395 }
396 /* Buttons */
397 for (i=0;i<JP_NUM_BUTTONS;i++) {
398 int button;
399
400 button=1<<jp_buttons[i];
401
402 if ((curstate & button) && !(prevstate & button)) {
403 SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
404 }
405 if (!(curstate & button) && (prevstate & button)) {
406 SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
407 }
408 }
409 }
410 atarijoysticks[numjoystick].prevstate = curstate;
411 }
412 break;
413 case PORTA_JOY0:
414 case PORTA_JOY1:
415 case PORTB_JOY0:
416 case PORTB_JOY1:
417 {
418 int fire_shift=0,dir_shift=0;
419
420 if (numjoystick==PORTA_JOY0) { fire_shift=0; dir_shift=0; }
421 if (numjoystick==PORTA_JOY1) { fire_shift=1; dir_shift=4; }
422 if (numjoystick==PORTB_JOY0) { fire_shift=2; dir_shift=8; }
423 if (numjoystick==PORTB_JOY1) { fire_shift=3; dir_shift=12; }
424
425 curstate = (jp_directions>>dir_shift) & 15;
426 curstate |= ((jp_fires>>fire_shift) & 1)<<4;
427
428 if (curstate != prevstate) {
429 /* X axis */
430 if ((curstate & (PORT_JS_LEFT|PORT_JS_RIGHT)) != (prevstate & (PORT_JS_LEFT|PORT_JS_RIGHT))) {
431 curaxis=0;
432 if (curstate & PORT_JS_LEFT) {
433 curaxis=-128;
434 } else if (curstate & PORT_JS_RIGHT) {
435 curaxis=127;
436 }
437 SDL_PrivateJoystickAxis(joystick,0,curaxis);
438 }
439 /* Y axis */
440 if ((curstate & (PORT_JS_UP|PORT_JS_DOWN)) != (prevstate & (PORT_JS_UP|PORT_JS_DOWN))) {
441 curaxis=0;
442 if (curstate & PORT_JS_UP) {
443 curaxis=-128;
444 } else if (curstate & PORT_JS_DOWN) {
445 curaxis=127;
446 }
447 SDL_PrivateJoystickAxis(joystick,1,curaxis);
448 }
449 /* Button */
450 if ((curstate & PORT_JS_FIRE) && !(prevstate & PORT_JS_FIRE)) {
451 SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);
452 }
453 if (!(curstate & PORT_JS_FIRE) && (prevstate & PORT_JS_FIRE)) {
454 SDL_PrivateJoystickButton(joystick,0,SDL_RELEASED);
455 }
456 }
457 atarijoysticks[numjoystick].prevstate = curstate;
458 }
459 break;
460 case PORTA_LP:
461 {
462 int i;
463
464 curstate = jp_lightpens[0]>>1;
465 curstate |= (jp_lightpens[1]>>1)<<15;
466 curstate |= (jp_fires & 3)<<30;
467
468 if (curstate != prevstate) {
469 /* X axis */
470 SDL_PrivateJoystickAxis(joystick,0,(jp_lightpens[0]>>8)-128);
471 /* Y axis */
472 SDL_PrivateJoystickAxis(joystick,1,(jp_lightpens[1]>>8)-128);
473 /* Buttons */
474 for (i=0;i<2;i++) {
475 int button;
476
477 button=1<<(30+i);
478
479 if ((curstate & button) && !(prevstate & button)) {
480 SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
481 }
482 if (!(curstate & button) && (prevstate & button)) {
483 SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
484 }
485 }
486 }
487 atarijoysticks[numjoystick].prevstate = curstate;
488 }
489 break;
490 case PORTA_ANPAD:
491 case PORTB_ANPAD:
492 {
493 int numpaddle, i;
494
495 numpaddle=0<<1;
496 if (numjoystick==PORTB_ANPAD) numpaddle=1<<1;
497
498 curstate = jp_paddles[numpaddle]>>1;
499 curstate |= (jp_paddles[numpaddle+1]>>1)<<15;
500 curstate |= ((jp_fires>>numpaddle) & 3)<<30;
501
502 if (curstate != prevstate) {
503 /* X axis */
504 SDL_PrivateJoystickAxis(joystick,0,(jp_paddles[numpaddle]>>8)-128);
505 /* Y axis */
506 SDL_PrivateJoystickAxis(joystick,1,(jp_paddles[numpaddle+1]>>8)-128);
507 /* Buttons */
508 for (i=0;i<2;i++) {
509 int button;
510
511 button=1<<(30+i);
512
513 if ((curstate & button) && !(prevstate & button)) {
514 SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
515 }
516 if (!(curstate & button) && (prevstate & button)) {
517 SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
518 }
519 }
520 }
521 atarijoysticks[numjoystick].prevstate = curstate;
522 }
523 break;
524 #if 0
525 case PARA_JOY0:
526 case PARA_JOY1:
527 break;
528 #endif
529 };
530
531 return;
532 }
533
534 void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
535 {
536 return;
537 }
538
539 void SDL_SYS_JoystickQuit(void)
540 {
541 SDL_numjoysticks=0;
542 return;
543 }
544
545 /*--- Joypad I/O read/write interface ---*/
546
547 #define JOYPAD_IO_BASE (0xffff9200)
548 struct JOYPAD_IO_S {
549 Uint16 fires;
550 Uint16 directions;
551 Uint16 dummy1[6];
552 Uint16 paddles[4];
553 Uint16 dummy2[4];
554 Uint16 lightpens[2];
555 };
556 #define JOYPAD_IO ((*(volatile struct JOYPAD_IO_S *)JOYPAD_IO_BASE))
557
558 static void UpdateJoypads(void)
559 {
560 Uint16 tmp;
561
562 /*--- This function is called in supervisor mode ---*/
563
564 /* Update joysticks */
565 jp_fires = (~(JOYPAD_IO.fires)) & 15;
566 jp_directions = (~(JOYPAD_IO.directions));
567
568 /* Update lightpen */
569 tmp = JOYPAD_IO.lightpens[0] & 1023;
570 jp_lightpens[0] = (tmp<<6) | (tmp>>4);
571 tmp = JOYPAD_IO.lightpens[1] & 1023;
572 jp_lightpens[1] = (tmp<<6) | (tmp>>4);
573
574 /* Update paddles */
575 tmp = (JOYPAD_IO.paddles[0] & 255);
576 jp_paddles[0] = (tmp<<8) | tmp;
577 tmp = (JOYPAD_IO.paddles[1] & 255);
578 jp_paddles[1] = (tmp<<8) | tmp;
579 tmp = (JOYPAD_IO.paddles[2] & 255);
580 jp_paddles[2] = (tmp<<8) | tmp;
581 tmp = (JOYPAD_IO.paddles[3] & 255);
582 jp_paddles[3] = (tmp<<8) | tmp;
583
584 /* Update joypad 0 */
585 JOYPAD_IO.directions=0xfffe;
586 jp_joypads[0]=((~(JOYPAD_IO.fires)) & 3)<<(16);
587 JOYPAD_IO.directions=0xfffe;
588 jp_joypads[0] |= ((~(JOYPAD_IO.directions))>>8) & 15;
589
590 JOYPAD_IO.directions=0xfffd;
591 jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3)<<(16+2);
592 JOYPAD_IO.directions=0xfffd;
593 jp_joypads[0] |= (((~(JOYPAD_IO.directions))>>8) & 15)<<4;
594
595 JOYPAD_IO.directions=0xfffb;
596 jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3)<<(16+4);
597 JOYPAD_IO.directions=0xfffb;
598 jp_joypads[0] |= (((~(JOYPAD_IO.directions))>>8) & 15)<<8;
599
600 JOYPAD_IO.directions=0xfff7;
601 jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3)<<(16+6);
602 JOYPAD_IO.directions=0xfff7;
603 jp_joypads[0] |= (((~(JOYPAD_IO.directions))>>8) & 15)<<12;
604
605 /* Update joypad 1 */
606 JOYPAD_IO.directions=0xffef;
607 jp_joypads[1]=((~(JOYPAD_IO.fires)) & (3<<2))<<(16-2);
608 JOYPAD_IO.directions=0xffef;
609 jp_joypads[1] |= ((~(JOYPAD_IO.directions))>>12) & 15;
610
611 JOYPAD_IO.directions=0xffdf;
612 jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3<<2))<<(16);
613 JOYPAD_IO.directions=0xffdf;
614 jp_joypads[1] |= (((~(JOYPAD_IO.directions))>>12) & 15)<<4;
615
616 JOYPAD_IO.directions=0xffbf;
617 jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3<<2))<<(16+2);
618 JOYPAD_IO.directions=0xffbf;
619 jp_joypads[1] |= (((~(JOYPAD_IO.directions))>>12) & 15)<<8;
620
621 JOYPAD_IO.directions=0xff7f;
622 jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3<<2))<<(16+4);
623 JOYPAD_IO.directions=0xff7f;
624 jp_joypads[1] |= (((~(JOYPAD_IO.directions))>>12) & 15)<<12;
625 }