# HG changeset patch # User Sam Lantinga # Date 1015731239 0 # Node ID 9c6613983e857b70885191df85d9862002de1983 # Parent ec53caed9fb2b312b9390cf1dcac140059862b93 Atari port cleanups from Patrice diff -r ec53caed9fb2 -r 9c6613983e85 README.MiNT --- a/README.MiNT Sun Mar 10 03:25:47 2002 +0000 +++ b/README.MiNT Sun Mar 10 03:33:59 2002 +0000 @@ -59,9 +59,9 @@ - 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: @@ -79,7 +79,8 @@ 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 @@ -92,6 +93,7 @@ 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. @@ -99,7 +101,6 @@ 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). diff -r ec53caed9fb2 -r 9c6613983e85 src/joystick/mint/SDL_sysjoystick.c --- a/src/joystick/mint/SDL_sysjoystick.c Sun Mar 10 03:25:47 2002 +0000 +++ b/src/joystick/mint/SDL_sysjoystick.c Sun Mar 10 03:33:59 2002 +0000 @@ -31,6 +31,7 @@ * Patrice Mandin */ +#include #include #include @@ -43,12 +44,15 @@ #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 @@ -58,6 +62,7 @@ enum { IKBD_JOY1=0, + XBIOS_JOY1, PORTA_PAD, PORTB_PAD, PORTA_JOY0, @@ -116,6 +121,7 @@ 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}, @@ -132,11 +138,11 @@ }; 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; @@ -160,8 +166,6 @@ 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")) { \ @@ -179,28 +183,23 @@ /* 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 */ @@ -226,6 +225,12 @@ } } } + + 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) || @@ -262,13 +267,15 @@ /* Return the nth'index' enabled atari joystick */ j=0; for (i=0;i +#include +#include + +#include "SDL_events_c.h" +#include "SDL_xbiosevents_c.h" +#include "SDL_xbiosinterrupt_s.h" + +/* Variables */ + +int SDL_AtariXbios_enabled=0; + +static _KBDVECS *kbdvecs; /* Pointer to access vectors */ +static _KBDVECS sys_kbdvecs; /* Backup of system vectors */ +static Uint16 atari_prevmouseb; /* buttons */ + +void SDL_AtariXbios_InstallVectors(int vectors_mask) +{ + void *oldpile; + + /* Clear variables */ + SDL_AtariXbios_mouseb = + SDL_AtariXbios_mousex = + SDL_AtariXbios_mousey = + SDL_AtariXbios_joystick = + atari_prevmouseb = 0; + + /* Read IKBD vectors base */ + kbdvecs=Kbdvbase(); + + /* Go to supervisor mode */ + oldpile=(void *)Super(0); + + /* Backup system vectors */ + memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS)); + + /* Install our vector */ + SDL_AtariXbios_Install( + kbdvecs, + (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL, + (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL + ); + + /* Back to user mode */ + Super(oldpile); + + SDL_AtariXbios_enabled=1; +} + +void SDL_AtariXbios_RestoreVectors(void) +{ + void *oldpile; + + /* Go to supervisor mode */ + oldpile=(void *)Super(NULL); + + /* Reinstall system vector */ + SDL_AtariXbios_Install(kbdvecs,sys_kbdvecs.mousevec,sys_kbdvecs.joyvec); + + /* Back to user mode */ + Super(oldpile); +} + +static int atari_GetButton(int button) +{ + switch(button) + { + case 0: + return SDL_BUTTON_RIGHT; + break; + case 1: + default: + return SDL_BUTTON_LEFT; + break; + } +} + +void SDL_AtariXbios_PostMouseEvents(_THIS) +{ + /* Mouse motion ? */ + if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { + SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); + SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; + } + + /* Mouse button ? */ + if (SDL_AtariXbios_mouseb != atari_prevmouseb) { + int i; + + for (i=0;i<2;i++) { + int curbutton, prevbutton; + + curbutton = SDL_AtariXbios_mouseb & (1<