Commit b2c856d7 authored by Patrice Mandin's avatar Patrice Mandin

Add teamtap support

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402093
parent f2bc03ca
...@@ -124,12 +124,12 @@ SDL_JOYSTICK_ATARI: ...@@ -124,12 +124,12 @@ SDL_JOYSTICK_ATARI:
'ikbd-joy1-[on|off]' for IKBD joystick on port 1 (hardware access) 'ikbd-joy1-[on|off]' for IKBD joystick on port 1 (hardware access)
'xbios-joy1-[on|off]' for IKBD joystick on port 1 (xbios access) 'xbios-joy1-[on|off]' for IKBD joystick on port 1 (xbios access)
'porta-pad-[on|off]' for joypad on port A 'porta-pad-[on|off]' for joypad and/or teamtap on port A
'porta-joy0-[on|off]' for joystick 0 on port A 'porta-joy0-[on|off]' for joystick 0 on port A
'porta-joy1-[on|off]' for joystick 1 on port A 'porta-joy1-[on|off]' for joystick 1 on port A
'porta-lp-[on|off]' for lightpen on port A 'porta-lp-[on|off]' for lightpen on port A
'porta-anpad-[on|off]' for analog paddle on port A 'porta-anpad-[on|off]' for analog paddle on port A
'portb-pad-[on|off]' for joypad on port B 'portb-pad-[on|off]' for joypad and/or teamtap on port B
'portb-joy0-[on|off]' for joystick 0 on port B 'portb-joy0-[on|off]' for joystick 0 on port B
'portb-joy1-[on|off]' for joystick 1 on port B 'portb-joy1-[on|off]' for joystick 1 on port B
'portb-anpad-[on|off]' for analog paddle on port B 'portb-anpad-[on|off]' for analog paddle on port B
......
...@@ -44,11 +44,14 @@ ...@@ -44,11 +44,14 @@
/* We can have: /* We can have:
1 joystick on IKBD port 1, read via hardware I/O 1 joystick on IKBD port 1, read via hardware I/O
or same joystick on IKBD port 1, read via xbios or same joystick on IKBD port 1, read via xbios
2 joypads on ports A,B 1 joypad on port A (up to 4 with teamtap)
or 4 joysticks on joypads ports A,B or 2 joysticks on joypad port A
or 1 analog paddle on joypad port A
or 1 lightpen on joypad port A or 1 lightpen on joypad port A
or 2 analog paddles on joypads ports A,B 1 joypad on port B (up to 4 with teamtap)
or 2 joysticks on joypad port B
or 1 analog paddle on joypad port B
2 joysticks on parallel port 2 joysticks on parallel port
*/ */
...@@ -56,8 +59,14 @@ enum ...@@ -56,8 +59,14 @@ enum
{ {
IKBD_JOY1 = 0, IKBD_JOY1 = 0,
XBIOS_JOY1, XBIOS_JOY1,
PORTA_PAD, PORTA_PAD0,
PORTB_PAD, PORTA_PAD1,
PORTA_PAD2,
PORTA_PAD3,
PORTB_PAD0,
PORTB_PAD1,
PORTB_PAD2,
PORTB_PAD3,
PORTA_JOY0, PORTA_JOY0,
PORTA_JOY1, PORTA_JOY1,
PORTB_JOY0, PORTB_JOY0,
...@@ -120,8 +129,14 @@ typedef struct ...@@ -120,8 +129,14 @@ typedef struct
static atarijoy_t atarijoysticks[MAX_JOYSTICKS] = { static atarijoy_t atarijoysticks[MAX_JOYSTICKS] = {
{SDL_FALSE, "IKBD joystick port 1", 0}, {SDL_FALSE, "IKBD joystick port 1", 0},
{SDL_FALSE, "Xbios joystick port 1", 0}, {SDL_FALSE, "Xbios joystick port 1", 0},
{SDL_FALSE, "Joypad port A", 0}, {SDL_FALSE, "Joypad 0 port A", 0},
{SDL_FALSE, "Joypad port B", 0}, {SDL_FALSE, "Joypad 1 port A", 0},
{SDL_FALSE, "Joypad 2 port A", 0},
{SDL_FALSE, "Joypad 3 port A", 0},
{SDL_FALSE, "Joypad 0 port B", 0},
{SDL_FALSE, "Joypad 1 port B", 0},
{SDL_FALSE, "Joypad 2 port B", 0},
{SDL_FALSE, "Joypad 3 port B", 0},
{SDL_FALSE, "Joystick 0 port A", 0}, {SDL_FALSE, "Joystick 0 port A", 0},
{SDL_FALSE, "Joystick 1 port A", 0}, {SDL_FALSE, "Joystick 1 port A", 0},
{SDL_FALSE, "Joystick 0 port B", 0}, {SDL_FALSE, "Joystick 0 port B", 0},
...@@ -150,7 +165,7 @@ static Uint16 jp_paddles[4]; ...@@ -150,7 +165,7 @@ static Uint16 jp_paddles[4];
static Uint16 jp_lightpens[2]; static Uint16 jp_lightpens[2];
static Uint16 jp_directions; static Uint16 jp_directions;
static Uint16 jp_fires; static Uint16 jp_fires;
static Uint32 jp_joypads[2]; static Uint32 jp_joypads[8];
/*--- Functions prototypes ---*/ /*--- Functions prototypes ---*/
...@@ -186,8 +201,14 @@ SDL_SYS_JoystickInit(void) ...@@ -186,8 +201,14 @@ SDL_SYS_JoystickInit(void)
atarijoysticks[IKBD_JOY1].enabled = (SDL_AtariIkbd_enabled != 0); atarijoysticks[IKBD_JOY1].enabled = (SDL_AtariIkbd_enabled != 0);
} }
if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) { if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) {
atarijoysticks[PORTA_PAD].enabled = SDL_TRUE; atarijoysticks[PORTA_PAD0].enabled =
atarijoysticks[PORTB_PAD].enabled = SDL_TRUE; atarijoysticks[PORTA_PAD1].enabled =
atarijoysticks[PORTA_PAD2].enabled =
atarijoysticks[PORTA_PAD3].enabled =
atarijoysticks[PORTB_PAD0].enabled =
atarijoysticks[PORTB_PAD1].enabled =
atarijoysticks[PORTB_PAD2].enabled =
atarijoysticks[PORTB_PAD3].enabled = SDL_TRUE;
} }
if (!atarijoysticks[IKBD_JOY1].enabled) { if (!atarijoysticks[IKBD_JOY1].enabled) {
atarijoysticks[XBIOS_JOY1].enabled = (SDL_AtariXbios_enabled != 0); atarijoysticks[XBIOS_JOY1].enabled = (SDL_AtariXbios_enabled != 0);
...@@ -205,8 +226,8 @@ SDL_SYS_JoystickInit(void) ...@@ -205,8 +226,8 @@ SDL_SYS_JoystickInit(void)
} }
/* Joypads ports only on STE and Falcon */ /* Joypads ports only on STE and Falcon */
if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) { if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) {
TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD); TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD0);
if (!atarijoysticks[PORTA_PAD].enabled) { if (!atarijoysticks[PORTA_PAD0].enabled) {
TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0); TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0);
TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1); TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1);
if (!(atarijoysticks[PORTA_JOY0].enabled) if (!(atarijoysticks[PORTA_JOY0].enabled)
...@@ -218,8 +239,8 @@ SDL_SYS_JoystickInit(void) ...@@ -218,8 +239,8 @@ SDL_SYS_JoystickInit(void)
} }
} }
TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD); TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD0);
if (!atarijoysticks[PORTB_PAD].enabled) { if (!atarijoysticks[PORTB_PAD0].enabled) {
TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0); TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0);
TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1); TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1);
if (!(atarijoysticks[PORTB_JOY0].enabled) if (!(atarijoysticks[PORTB_JOY0].enabled)
...@@ -247,7 +268,7 @@ SDL_SYS_JoystickInit(void) ...@@ -247,7 +268,7 @@ SDL_SYS_JoystickInit(void)
/* Need to update joypad ports ? */ /* Need to update joypad ports ? */
joypad_ports_enabled = SDL_FALSE; joypad_ports_enabled = SDL_FALSE;
for (i = PORTA_PAD; i <= PORTB_ANPAD; i++) { for (i = PORTA_PAD0; i <= PORTB_ANPAD; i++) {
if (atarijoysticks[i].enabled) { if (atarijoysticks[i].enabled) {
joypad_ports_enabled = SDL_TRUE; joypad_ports_enabled = SDL_TRUE;
break; break;
...@@ -314,8 +335,14 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick) ...@@ -314,8 +335,14 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
joystick->nballs = 0; joystick->nballs = 0;
switch (numjoystick) { switch (numjoystick) {
case PORTA_PAD: case PORTA_PAD0:
case PORTB_PAD: case PORTA_PAD1:
case PORTA_PAD2:
case PORTA_PAD3:
case PORTB_PAD0:
case PORTB_PAD1:
case PORTB_PAD2:
case PORTB_PAD3:
joystick->nhats = 1; joystick->nhats = 1;
joystick->nbuttons = JP_NUM_BUTTONS; joystick->nbuttons = JP_NUM_BUTTONS;
break; break;
...@@ -393,14 +420,36 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) ...@@ -393,14 +420,36 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
atarijoysticks[numjoystick].prevstate = curstate; atarijoysticks[numjoystick].prevstate = curstate;
} }
break; break;
case PORTA_PAD: case PORTA_PAD0:
case PORTB_PAD: case PORTA_PAD1:
case PORTA_PAD2:
case PORTA_PAD3:
case PORTB_PAD0:
case PORTB_PAD1:
case PORTB_PAD2:
case PORTB_PAD3:
{ {
int numjoypad, i; int numjoypad, i;
numjoypad = 0; numjoypad = 0;
if (numjoystick == PORTB_PAD) switch(numjoystick) {
numjoypad = 1; case PORTA_PAD0:
numjoypad = 0; break;
case PORTA_PAD1:
numjoypad = 1; break;
case PORTA_PAD2:
numjoypad = 2; break;
case PORTA_PAD3:
numjoypad = 3; break;
case PORTB_PAD0:
numjoypad = 4; break;
case PORTB_PAD1:
numjoypad = 5; break;
case PORTB_PAD2:
numjoypad = 6; break;
case PORTB_PAD3:
numjoypad = 7; break;
}
curstate = jp_joypads[numjoypad]; curstate = jp_joypads[numjoypad];
if (curstate != prevstate) { if (curstate != prevstate) {
...@@ -598,6 +647,17 @@ struct JOYPAD_IO_S ...@@ -598,6 +647,17 @@ struct JOYPAD_IO_S
}; };
#define JOYPAD_IO ((*(volatile struct JOYPAD_IO_S *)JOYPAD_IO_BASE)) #define JOYPAD_IO ((*(volatile struct JOYPAD_IO_S *)JOYPAD_IO_BASE))
static const Uint16 joypad_masks[8*4]={
0xfffe, 0xfffd, 0xfffb, 0xfff7,
0xfff0, 0xfff1, 0xfff2, 0xfff3,
0xfff4, 0xfff5, 0xfff6, 0xfff8,
0xfff9, 0xfffa, 0xfffc, 0xffff,
0xffef, 0xffdf, 0xffbf, 0xff7f,
0xff0f, 0xff1f, 0xff2f, 0xff3f,
0xff4f, 0xff5f, 0xff6f, 0xff8f,
0xff9f, 0xffaf, 0xffcf, 0xffff
};
static void static void
UpdateJoypads(void) UpdateJoypads(void)
{ {
...@@ -625,47 +685,35 @@ UpdateJoypads(void) ...@@ -625,47 +685,35 @@ UpdateJoypads(void)
tmp = (JOYPAD_IO.paddles[3] & 255); tmp = (JOYPAD_IO.paddles[3] & 255);
jp_paddles[3] = (tmp << 8) | tmp; jp_paddles[3] = (tmp << 8) | tmp;
/* Update joypad 0 */ /* Update joypads on teamtap port A */
JOYPAD_IO.directions = 0xfffe; for (i=0; i<4; i++) {
jp_joypads[0] = ((~(JOYPAD_IO.fires)) & 3) << (16); jp_joypads[i] = 0;
JOYPAD_IO.directions = 0xfffe; for (j=0; j<4; j++) {
jp_joypads[0] |= ((~(JOYPAD_IO.directions)) >> 8) & 15; JOYPAD_IO.directions = joypad_masks[(i*4)+j];
JOYPAD_IO.directions = 0xfffd; cur_fire = (~(JOYPAD_IO.fires) & 3)<<16;
jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3) << (16 + 2); cur_dir = (~(JOYPAD_IO.directions)>>8) & 15;
JOYPAD_IO.directions = 0xfffd;
jp_joypads[0] |= (((~(JOYPAD_IO.directions)) >> 8) & 15) << 4; jp_joypads[i] |= cur_fire<<(j*2);
jp_joypads[i] |= cur_dir<<(j*4);
JOYPAD_IO.directions = 0xfffb; }
jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3) << (16 + 4); }
JOYPAD_IO.directions = 0xfffb;
jp_joypads[0] |= (((~(JOYPAD_IO.directions)) >> 8) & 15) << 8; /* Update joypads on teamtap port B */
for (i=4; i<8; i++) {
JOYPAD_IO.directions = 0xfff7; jp_joypads[i] = 0;
jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3) << (16 + 6); for (j=0; j<4; j++) {
JOYPAD_IO.directions = 0xfff7; JOYPAD_IO.directions = joypad_masks[(i*4)+j];
jp_joypads[0] |= (((~(JOYPAD_IO.directions)) >> 8) & 15) << 12;
cur_fire = (~(JOYPAD_IO.fires) & 0xc)<<14;
/* Update joypad 1 */ cur_dir = (~(JOYPAD_IO.directions)>>12) & 15;
JOYPAD_IO.directions = 0xffef;
jp_joypads[1] = ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16 - 2); jp_joypads[i] |= cur_fire<<(j*2);
JOYPAD_IO.directions = 0xffef; jp_joypads[i] |= cur_dir<<(j*4);
jp_joypads[1] |= ((~(JOYPAD_IO.directions)) >> 12) & 15; }
}
JOYPAD_IO.directions = 0xffdf;
jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16); JOYPAD_IO.directions=0xffff;
JOYPAD_IO.directions = 0xffdf;
jp_joypads[1] |= (((~(JOYPAD_IO.directions)) >> 12) & 15) << 4;
JOYPAD_IO.directions = 0xffbf;
jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16 + 2);
JOYPAD_IO.directions = 0xffbf;
jp_joypads[1] |= (((~(JOYPAD_IO.directions)) >> 12) & 15) << 8;
JOYPAD_IO.directions = 0xff7f;
jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16 + 4);
JOYPAD_IO.directions = 0xff7f;
jp_joypads[1] |= (((~(JOYPAD_IO.directions)) >> 12) & 15) << 12;
} }
#endif /* SDL_JOYSTICK_MINT */ #endif /* SDL_JOYSTICK_MINT */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment