Skip to content

Commit

Permalink
Atari port cleanups from Patrice
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Mar 10, 2002
1 parent 3812670 commit bd0994d
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 85 deletions.
11 changes: 6 additions & 5 deletions README.MiNT
Expand Up @@ -59,9 +59,9 @@ Threads support (TOS)
- Driver combinations:
Video Kbd Mouse Timer Jstick Joypads
xbios ikbd ikbd vbl ikbd hardware
xbios gemdos xbios vbl - hardware
xbios bios xbios vbl - hardware
gem gem gem vbl - hardware
xbios gemdos xbios vbl xbios hardware
xbios bios xbios vbl xbios hardware
gem gem gem vbl xbios hardware

==============================================================================
V. Environment variables:
Expand All @@ -79,7 +79,8 @@ SDL_JOYSTICK_ATARI:
Use any of these strings in the environment variable to enable or
disable a joystick:

'ikbd-joy1-[on|off]' for IKBD joystick on port 1
'ikbd-joy1-[on|off]' for IKBD joystick on port 1 (hardware access)
'xbios-joy1-[on|off]' for IKBD joystick on port 1 (xbios access)
'porta-pad-[on|off]' for joypad on port A
'porta-joy0-[on|off]' for joystick 0 on port A
'porta-joy1-[on|off]' for joystick 1 on port A
Expand All @@ -92,14 +93,14 @@ SDL_JOYSTICK_ATARI:

Default configuration is:
'ikbd-joy1-on' (if IKBD events driver enabled)
'xbios-joy1-on' (if gemdos/bios/gem events driver enabled)
'porta-pad-on portb-pad-on' (if available on the machine)

port[a|b]-[pad|joy?|lp|anpad]-* strings are mutually exclusives.
On such a port, you can only use a joypad OR 1 or 2 joysticks OR
a lightpen OR an analog paddle. You must disable joypad before
setting another controller.

IKBD joystick only available when the IKBD events driver is enabled.
The second joystick port on IKBD is used by the mouse, so not usable.

Joypads are multibuttons controller (Atari Jaguar console-like).
Expand Down
72 changes: 44 additions & 28 deletions src/joystick/mint/SDL_sysjoystick.c
Expand Up @@ -31,6 +31,7 @@ static char rcsid =
* Patrice Mandin
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand All @@ -43,12 +44,15 @@ static char rcsid =
#include "SDL_sysjoystick.h"
#include "SDL_joystick_c.h"

#include "../video/ataricommon/SDL_ikbdinterrupt_s.h"
#include "SDL_ikbdinterrupt_s.h"
#include "SDL_xbiosevents_c.h"
#include "SDL_xbiosinterrupt_s.h"

/*--- Const ---*/

/* We can have:
1 joystick on IKBD port 1 (port 0 is used by mouse)
1 joystick on IKBD port 1, read via hardware I/O
or same joystick on IKBD port 1, read via xbios
2 joypads on ports A,B
or 4 joysticks on joypads ports A,B
or 1 lightpen on joypad port A
Expand All @@ -58,6 +62,7 @@ static char rcsid =

enum {
IKBD_JOY1=0,
XBIOS_JOY1,
PORTA_PAD,
PORTB_PAD,
PORTA_JOY0,
Expand Down Expand Up @@ -116,6 +121,7 @@ typedef struct {

static atarijoy_t atarijoysticks[MAX_JOYSTICKS]={
{SDL_FALSE,"IKBD joystick port 1",0},
{SDL_FALSE,"Xbios joystick port 1",0},
{SDL_FALSE,"Joypad port A",0},
{SDL_FALSE,"Joypad port B",0},
{SDL_FALSE,"Joystick 0 port A",0},
Expand All @@ -132,11 +138,11 @@ static atarijoy_t atarijoysticks[MAX_JOYSTICKS]={
};

static const int jp_buttons[JP_NUM_BUTTONS]={
JP_KPMULT, JP_KP7, JP_KP4, JP_KP1,
JP_KP0, JP_KP8, JP_KP5, JP_KP2,
JP_KPNUM, JP_KP9, JP_KP6, JP_KP3,
JP_PAUSE, JP_FIRE0, JP_FIRE1, JP_FIRE2,
JP_OPTION
JP_FIRE0, JP_FIRE1, JP_FIRE2, JP_PAUSE,
JP_OPTION, JP_KPMULT, JP_KPNUM, JP_KP0,
JP_KP1, JP_KP2, JP_KP3, JP_KP4,
JP_KP5, JP_KP6, JP_KP7, JP_KP8,
JP_KP9
};

static SDL_bool joypad_ports_enabled=SDL_FALSE;
Expand All @@ -160,8 +166,6 @@ int SDL_SYS_JoystickInit(void)
int i;
unsigned long cookie_mch;
const char *envr=getenv("SDL_JOYSTICK_ATARI");
const char *env_evt=getenv("SDL_ATARI_EVENTSDRIVER");
SDL_bool ikbd_enabled=SDL_FALSE;

#define TEST_JOY_ENABLED(env,idstring,num) \
if (strstr(env,idstring"-off")) { \
Expand All @@ -179,28 +183,23 @@ int SDL_SYS_JoystickInit(void)
/* Enable some default joysticks */
if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
(cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16)) {
ikbd_enabled=SDL_TRUE;
if (env_evt) {
if (!strcmp(env_evt,"ikbd")) {
ikbd_enabled=SDL_FALSE;
}
}
atarijoysticks[IKBD_JOY1].enabled=ikbd_enabled;
atarijoysticks[IKBD_JOY1].enabled=(SDL_AtariIkbd_enabled!=0);
}
if ((cookie_mch == MCH_STE<<16) || (cookie_mch == MCH_F30<<16)) {
atarijoysticks[PORTA_PAD].enabled=SDL_TRUE;
atarijoysticks[PORTB_PAD].enabled=SDL_TRUE;
}
if (!atarijoysticks[IKBD_JOY1].enabled) {
atarijoysticks[XBIOS_JOY1].enabled=(SDL_AtariXbios_enabled!=0);
}

/* Read environment for joysticks to enable */
if (envr) {
/* IKBD on any Atari, maybe clones */
if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
(cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16)) {
if (env_evt) {
if (strcmp(env_evt,"ikbd")) {
TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1);
}
if (SDL_AtariIkbd_enabled!=0) {
TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1);
}
}
/* Joypads ports only on STE and Falcon */
Expand All @@ -226,6 +225,12 @@ int SDL_SYS_JoystickInit(void)
}
}
}

if (!atarijoysticks[IKBD_JOY1].enabled) {
if (SDL_AtariXbios_enabled!=0) {
TEST_JOY_ENABLED(envr, "xbios-joy1", XBIOS_JOY1);
}
}
#if 0
/* Parallel port on any Atari, maybe clones */
if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
Expand Down Expand Up @@ -262,13 +267,15 @@ static int GetEnabledAtariJoystick(int index)
/* Return the nth'index' enabled atari joystick */
j=0;
for (i=0;i<MAX_JOYSTICKS;i++) {
if (atarijoysticks[i].enabled) {
if (j==index) {
break;
} else {
j++;
}
if (!atarijoysticks[i].enabled) {
continue;
}

if (j==index) {
break;
}

++j;
}
if (i==MAX_JOYSTICKS)
return -1;
Expand Down Expand Up @@ -328,8 +335,17 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)

switch (numjoystick) {
case IKBD_JOY1:
case XBIOS_JOY1:
{
curstate = SDL_AtariIkbd_joystick & 0xff;
curstate = 0;

if (numjoystick==IKBD_JOY1) {
curstate = SDL_AtariIkbd_joystick & 0xff;
}
if (numjoystick==XBIOS_JOY1) {
curstate = SDL_AtariXbios_joystick & 0xff;
}

if (curstate != prevstate) {
/* X axis */
if ((curstate & (IKBD_JOY_LEFT|IKBD_JOY_RIGHT)) != (prevstate & (IKBD_JOY_LEFT|IKBD_JOY_RIGHT))) {
Expand Down Expand Up @@ -359,7 +375,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
SDL_PrivateJoystickButton(joystick,0,SDL_RELEASED);
}
}
atarijoysticks[IKBD_JOY1].prevstate = curstate;
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_PAD:
Expand Down
8 changes: 4 additions & 4 deletions src/video/ataricommon/Makefile.am
Expand Up @@ -25,7 +25,7 @@ ATARICOMMON_SRCS = \
SDL_ikbdevents_c.h \
SDL_ikbdinterrupt.S \
SDL_ikbdinterrupt_s.h \
SDL_xbiosmouseevents.c \
SDL_xbiosmouseevents_c.h \
SDL_xbiosmouseinterrupt.S \
SDL_xbiosmouseinterrupt_s.h
SDL_xbiosevents.c \
SDL_xbiosevents_c.h \
SDL_xbiosinterrupt.S \
SDL_xbiosinterrupt_s.h
8 changes: 4 additions & 4 deletions src/video/ataricommon/SDL_biosevents.c
Expand Up @@ -41,7 +41,7 @@ static char rcsid =
#include "SDL_events_c.h"

#include "SDL_atarikeys.h"
#include "SDL_xbiosmouseevents_c.h"
#include "SDL_xbiosevents_c.h"

/* To save state of keyboard */
#define ATARIBIOS_MAXKEYS 128
Expand Down Expand Up @@ -104,7 +104,7 @@ void AtariBios_InitOSKeymap(_THIS)
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;

AtariXbios_InstallMouseVector();
SDL_AtariXbios_InstallVectors(ATARI_XBIOS_MOUSEEVENTS|ATARI_XBIOS_JOYSTICKEVENTS);
}

void AtariBios_PumpEvents(_THIS)
Expand Down Expand Up @@ -142,7 +142,7 @@ void AtariBios_PumpEvents(_THIS)
SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, bios_currentascii[i], &keysym));
}

AtariXbios_PostMouseEvents(this);
SDL_AtariXbios_PostMouseEvents(this);

/* Will be previous table */
memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
Expand Down Expand Up @@ -183,5 +183,5 @@ static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)

void AtariBios_ShutdownEvents(void)
{
AtariXbios_RestoreMouseVector();
SDL_AtariXbios_RestoreVectors();
}
8 changes: 4 additions & 4 deletions src/video/ataricommon/SDL_gemdosevents.c
Expand Up @@ -41,7 +41,7 @@ static char rcsid =
#include "SDL_events_c.h"

#include "SDL_atarikeys.h"
#include "SDL_xbiosmouseevents_c.h"
#include "SDL_xbiosevents_c.h"

/* To save state of keyboard */
#define ATARIBIOS_MAXKEYS 128
Expand Down Expand Up @@ -109,7 +109,7 @@ void AtariGemdos_InitOSKeymap(_THIS)
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;

AtariXbios_InstallMouseVector();
SDL_AtariXbios_InstallVectors(ATARI_XBIOS_MOUSEEVENTS|ATARI_XBIOS_JOYSTICKEVENTS);
}

void AtariGemdos_PumpEvents(_THIS)
Expand Down Expand Up @@ -147,7 +147,7 @@ void AtariGemdos_PumpEvents(_THIS)
SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, gemdos_currentascii[i], &keysym));
}

AtariXbios_PostMouseEvents(this);
SDL_AtariXbios_PostMouseEvents(this);

/* Will be previous table */
memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
Expand Down Expand Up @@ -188,5 +188,5 @@ static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)

void AtariGemdos_ShutdownEvents(void)
{
AtariXbios_RestoreMouseVector();
SDL_AtariXbios_RestoreVectors();
}
7 changes: 7 additions & 0 deletions src/video/ataricommon/SDL_ikbdinterrupt.S
Expand Up @@ -42,6 +42,8 @@ static char rcsid =
.globl _SDL_AtariIkbd_mousey
.globl _SDL_AtariIkbd_joystick

.globl _SDL_AtariIkbd_enabled

/*--- Install our IKBD vector ---*/

_SDL_AtariIkbdInstall:
Expand Down Expand Up @@ -72,6 +74,8 @@ _SDL_AtariIkbdInstall:

| Interrupts done

movew #0xffff,_SDL_AtariIkbd_enabled

moveml sp@+,d0-d1/a0-a1
rts

Expand Down Expand Up @@ -208,6 +212,9 @@ ikbd_joystick:
.data

.even
_SDL_AtariIkbd_enabled:
.word 0
.even
.comm _SDL_AtariIkbd_keyboard,128
.even
.comm _SDL_AtariIkbd_mousex,2*1
Expand Down
18 changes: 15 additions & 3 deletions src/video/ataricommon/SDL_ikbdinterrupt_s.h
Expand Up @@ -38,13 +38,25 @@ static char rcsid =

#include "SDL_types.h"

/* Const */

#define IKBD_JOY_UP (1<<0)
#define IKBD_JOY_DOWN (1<<1)
#define IKBD_JOY_LEFT (1<<2)
#define IKBD_JOY_RIGHT (1<<3)
#define IKBD_JOY_FIRE (1<<7)

/* Variables */

extern Uint8 SDL_AtariIkbd_keyboard[128]; /* Keyboard table */
extern Uint16 SDL_AtariIkbd_mouseb; /* buttons */
extern Sint16 SDL_AtariIkbd_mousex; /* X relative motion */
extern Sint16 SDL_AtariIkbd_mousey; /* Y relative motion */
extern Uint16 SDL_AtariIkbd_mouseb; /* Mouse on port 0, buttons */
extern Sint16 SDL_AtariIkbd_mousex; /* Mouse X relative motion */
extern Sint16 SDL_AtariIkbd_mousey; /* Mouse Y relative motion */
extern Uint16 SDL_AtariIkbd_joystick; /* Joystick on port 1 */

extern Uint16 SDL_AtariIkbd_enabled; /* For joystick driver to know
if this is usable */

/* Functions */

extern void SDL_AtariIkbdInstall(void);
Expand Down

0 comments on commit bd0994d

Please sign in to comment.