mirror of
https://github.com/Pecusx/libretro-atari800.git
synced 2026-05-20 22:33:22 +02:00
Add support for four controllers.
This commit is contained in:
+15
-8
@@ -63,7 +63,7 @@ int touch=-1; // gui mouse btn
|
|||||||
//JOY
|
//JOY
|
||||||
int al[2][2];//left analog1
|
int al[2][2];//left analog1
|
||||||
int ar[2][2];//right analog1
|
int ar[2][2];//right analog1
|
||||||
unsigned char MXjoy[2]; // joy
|
unsigned char MXjoy[4]; // joy
|
||||||
|
|
||||||
#define JOYRANGE_UP_VALUE -16384 /* Joystick ranges in XY */
|
#define JOYRANGE_UP_VALUE -16384 /* Joystick ranges in XY */
|
||||||
#define JOYRANGE_DOWN_VALUE 16383
|
#define JOYRANGE_DOWN_VALUE 16383
|
||||||
@@ -171,7 +171,7 @@ int RSTOPON=-1;
|
|||||||
int CTRLON=-1;
|
int CTRLON=-1;
|
||||||
|
|
||||||
extern unsigned short int bmp[400*300];
|
extern unsigned short int bmp[400*300];
|
||||||
extern unsigned atari_devices[ 2 ];
|
extern unsigned atari_devices[ 4 ];
|
||||||
|
|
||||||
extern int UI_is_active;
|
extern int UI_is_active;
|
||||||
extern int CURRENT_TV;
|
extern int CURRENT_TV;
|
||||||
@@ -448,7 +448,9 @@ int Retro_PollEvent()
|
|||||||
|
|
||||||
int SAVPAS=PAS;
|
int SAVPAS=PAS;
|
||||||
int i,j;
|
int i,j;
|
||||||
static int vbt[2][16]={
|
static int vbt[4][16]={
|
||||||
|
{0x0,0x0,0x0,0x0,0x01,0x02,0x04,0x08,0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0},
|
||||||
|
{0x0,0x0,0x0,0x0,0x01,0x02,0x04,0x08,0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0},
|
||||||
{0x0,0x0,0x0,0x0,0x01,0x02,0x04,0x08,0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0},
|
{0x0,0x0,0x0,0x0,0x01,0x02,0x04,0x08,0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0},
|
||||||
{0x0,0x0,0x0,0x0,0x01,0x02,0x04,0x08,0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0},
|
{0x0,0x0,0x0,0x0,0x01,0x02,0x04,0x08,0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0},
|
||||||
};
|
};
|
||||||
@@ -462,14 +464,15 @@ int Retro_PollEvent()
|
|||||||
|
|
||||||
if(SHOWKEY==-1 && pauseg==0)Process_key();
|
if(SHOWKEY==-1 && pauseg==0)Process_key();
|
||||||
|
|
||||||
|
|
||||||
//Joy mode
|
//Joy mode
|
||||||
for(j=0;j<2;j++){
|
for(j=0;j<4;j++){
|
||||||
|
|
||||||
for(i=4;i<10;i++)
|
for(i=4;i<10;i++)
|
||||||
{
|
{
|
||||||
if( input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, i))
|
if( input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, i)) {
|
||||||
MXjoy[j] |= vbt[j][i]; // Joy press
|
MXjoy[j] |= vbt[j][i]; // Joy press
|
||||||
|
fprintf(stderr, "[Libretro-atari800]: MXjoy press controller %u slot %u.\n", j, i);
|
||||||
|
}
|
||||||
else if( MXjoy[j]&vbt[j][i])MXjoy[j] &= ~vbt[j][i]; // Joy press
|
else if( MXjoy[j]&vbt[j][i])MXjoy[j] &= ~vbt[j][i]; // Joy press
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,8 +508,10 @@ int Retro_PollEvent()
|
|||||||
// 0 1 2 3
|
// 0 1 2 3
|
||||||
for(i=0;i<4;i++){
|
for(i=0;i<4;i++){
|
||||||
|
|
||||||
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
|
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 ) {
|
||||||
mbt[i]=1;
|
mbt[i]=1;
|
||||||
|
fprintf(stderr, "[Libretro-atari800]: atari_devices press slot %u.\n", i);
|
||||||
|
}
|
||||||
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
|
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
|
||||||
{
|
{
|
||||||
mbt[i]=0;
|
mbt[i]=0;
|
||||||
@@ -517,8 +522,10 @@ int Retro_PollEvent()
|
|||||||
// 10 11 12 13 14 15
|
// 10 11 12 13 14 15
|
||||||
for(i=10;i<16;i++){
|
for(i=10;i<16;i++){
|
||||||
|
|
||||||
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
|
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 ) {
|
||||||
|
fprintf(stderr, "[Libretro-atari800]: atari_devices press slot %u.\n", i);
|
||||||
mbt[i]=1;
|
mbt[i]=1;
|
||||||
|
}
|
||||||
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
|
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
|
||||||
{
|
{
|
||||||
mbt[i]=0;
|
mbt[i]=0;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ int retroh=300;
|
|||||||
#define RETRO_DEVICE_ATARI_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 0)
|
#define RETRO_DEVICE_ATARI_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 0)
|
||||||
#define RETRO_DEVICE_ATARI_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
#define RETRO_DEVICE_ATARI_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
||||||
|
|
||||||
unsigned atari_devices[ 2 ];
|
unsigned atari_devices[ 4 ];
|
||||||
|
|
||||||
int keyboard_type=0;
|
int keyboard_type=0;
|
||||||
int autorun5200=0;
|
int autorun5200=0;
|
||||||
@@ -72,11 +72,20 @@ void retro_set_environment(retro_environment_t cb)
|
|||||||
{ "ATARI Joystick", RETRO_DEVICE_ATARI_JOYSTICK },
|
{ "ATARI Joystick", RETRO_DEVICE_ATARI_JOYSTICK },
|
||||||
{ "ATARI Keyboard", RETRO_DEVICE_ATARI_KEYBOARD },
|
{ "ATARI Keyboard", RETRO_DEVICE_ATARI_KEYBOARD },
|
||||||
};
|
};
|
||||||
|
static const struct retro_controller_description p3_controllers[] = {
|
||||||
|
{ "ATARI Joystick", RETRO_DEVICE_ATARI_JOYSTICK },
|
||||||
|
{ "ATARI Keyboard", RETRO_DEVICE_ATARI_KEYBOARD },
|
||||||
|
};
|
||||||
|
static const struct retro_controller_description p4_controllers[] = {
|
||||||
|
{ "ATARI Joystick", RETRO_DEVICE_ATARI_JOYSTICK },
|
||||||
|
{ "ATARI Keyboard", RETRO_DEVICE_ATARI_KEYBOARD },
|
||||||
|
};
|
||||||
|
|
||||||
static const struct retro_controller_info ports[] = {
|
static const struct retro_controller_info ports[] = {
|
||||||
{ p1_controllers, 2 }, // port 1
|
{ p1_controllers, 2 }, // port 1
|
||||||
{ p2_controllers, 2 }, // port 2
|
{ p2_controllers, 2 }, // port 2
|
||||||
|
{ p3_controllers, 2 }, // port 3
|
||||||
|
{ p4_controllers, 2 }, // port 4
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -551,7 +560,7 @@ unsigned retro_api_version(void)
|
|||||||
|
|
||||||
void retro_set_controller_port_device( unsigned port, unsigned device )
|
void retro_set_controller_port_device( unsigned port, unsigned device )
|
||||||
{
|
{
|
||||||
if ( port < 2 )
|
if ( port < 4 )
|
||||||
{
|
{
|
||||||
atari_devices[ port ] = device;
|
atari_devices[ port ] = device;
|
||||||
|
|
||||||
|
|||||||
+59
-12
@@ -49,7 +49,9 @@ extern int UI_is_active;
|
|||||||
static int swap_joysticks = FALSE;
|
static int swap_joysticks = FALSE;
|
||||||
int PLATFORM_kbd_joy_0_enabled = TRUE; /* enabled by default, doesn't hurt */
|
int PLATFORM_kbd_joy_0_enabled = TRUE; /* enabled by default, doesn't hurt */
|
||||||
int PLATFORM_kbd_joy_1_enabled = TRUE;//FALSE; /* disabled, would steal normal keys */
|
int PLATFORM_kbd_joy_1_enabled = TRUE;//FALSE; /* disabled, would steal normal keys */
|
||||||
extern unsigned char MXjoy[2]; // joy
|
int PLATFORM_kbd_joy_2_enabled = TRUE;//FALSE; /* disabled, would steal normal keys */
|
||||||
|
int PLATFORM_kbd_joy_3_enabled = TRUE;//FALSE; /* disabled, would steal normal keys */
|
||||||
|
extern unsigned char MXjoy[4]; // joy
|
||||||
extern int mbt[16];
|
extern int mbt[16];
|
||||||
extern int retro_sound_finalized;
|
extern int retro_sound_finalized;
|
||||||
|
|
||||||
@@ -655,10 +657,10 @@ void PLATFORM_PaletteUpdate(void)
|
|||||||
retro_PaletteUpdate();
|
retro_PaletteUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_platform_PORT(unsigned char *s0, unsigned char *s1)
|
static void get_platform_PORT(unsigned char *s0, unsigned char *s1, unsigned char *s2, unsigned char *s3)
|
||||||
{
|
{
|
||||||
int stick0, stick1;
|
int stick0, stick1, stick2, stick3;
|
||||||
stick0 = stick1 = INPUT_STICK_CENTRE;
|
stick0 = stick1 = stick2 = stick3 = INPUT_STICK_CENTRE;
|
||||||
|
|
||||||
if (PLATFORM_kbd_joy_0_enabled) {
|
if (PLATFORM_kbd_joy_0_enabled) {
|
||||||
if (MXjoy[0]&0x04)
|
if (MXjoy[0]&0x04)
|
||||||
@@ -680,24 +682,47 @@ static void get_platform_PORT(unsigned char *s0, unsigned char *s1)
|
|||||||
stick1 &= INPUT_STICK_FORWARD;
|
stick1 &= INPUT_STICK_FORWARD;
|
||||||
if (MXjoy[1]&0x02)
|
if (MXjoy[1]&0x02)
|
||||||
stick1 &= INPUT_STICK_BACK;
|
stick1 &= INPUT_STICK_BACK;
|
||||||
|
}
|
||||||
|
if (PLATFORM_kbd_joy_2_enabled) {
|
||||||
|
if (MXjoy[2]&0x04)
|
||||||
|
stick2 &= INPUT_STICK_LEFT;
|
||||||
|
if (MXjoy[2]&0x08)
|
||||||
|
stick2 &= INPUT_STICK_RIGHT;
|
||||||
|
if (MXjoy[2]&0x01)
|
||||||
|
stick2 &= INPUT_STICK_FORWARD;
|
||||||
|
if (MXjoy[2]&0x02)
|
||||||
|
stick2 &= INPUT_STICK_BACK;
|
||||||
|
}
|
||||||
|
if (PLATFORM_kbd_joy_3_enabled) {
|
||||||
|
if (MXjoy[3]&0x04)
|
||||||
|
stick3 &= INPUT_STICK_LEFT;
|
||||||
|
if (MXjoy[3]&0x08)
|
||||||
|
stick3 &= INPUT_STICK_RIGHT;
|
||||||
|
if (MXjoy[3]&0x01)
|
||||||
|
stick3 &= INPUT_STICK_FORWARD;
|
||||||
|
if (MXjoy[3]&0x02)
|
||||||
|
stick3 &= INPUT_STICK_BACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swap_joysticks) {
|
if (swap_joysticks) {
|
||||||
*s1 = stick0;
|
*s1 = stick0;
|
||||||
*s0 = stick1;
|
*s0 = stick1;
|
||||||
|
*s2 = stick2;
|
||||||
|
*s3 = stick3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*s0 = stick0;
|
*s0 = stick0;
|
||||||
*s1 = stick1;
|
*s1 = stick1;
|
||||||
|
*s2 = stick2;
|
||||||
|
*s3 = stick3;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_platform_TRIG(unsigned char *t0, unsigned char *t1)
|
static void get_platform_TRIG(unsigned char *t0, unsigned char *t1, unsigned char *t2, unsigned char *t3)
|
||||||
{
|
{
|
||||||
int trig0, trig1;
|
int trig0, trig1, trig2, trig3;
|
||||||
trig0 = trig1 = 1;
|
trig0 = trig1 = trig2 = trig3 = 1;
|
||||||
|
|
||||||
if (PLATFORM_kbd_joy_0_enabled) {
|
if (PLATFORM_kbd_joy_0_enabled) {
|
||||||
trig0 = MXjoy[0]&0x80?0:1;
|
trig0 = MXjoy[0]&0x80?0:1;
|
||||||
@@ -707,13 +732,25 @@ static void get_platform_TRIG(unsigned char *t0, unsigned char *t1)
|
|||||||
trig1 = MXjoy[1]&0x80?0:1;
|
trig1 = MXjoy[1]&0x80?0:1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PLATFORM_kbd_joy_2_enabled) {
|
||||||
|
trig2 = MXjoy[2]&0x80?0:1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PLATFORM_kbd_joy_3_enabled) {
|
||||||
|
trig3 = MXjoy[3]&0x80?0:1;
|
||||||
|
}
|
||||||
|
|
||||||
if (swap_joysticks) {
|
if (swap_joysticks) {
|
||||||
*t1 = trig0;
|
*t1 = trig0;
|
||||||
*t0 = trig1;
|
*t0 = trig1;
|
||||||
|
*t2 = trig2;
|
||||||
|
*t3 = trig3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*t0 = trig0;
|
*t0 = trig0;
|
||||||
*t1 = trig1;
|
*t1 = trig1;
|
||||||
|
*t2 = trig2;
|
||||||
|
*t3 = trig3;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -721,25 +758,35 @@ static void get_platform_TRIG(unsigned char *t0, unsigned char *t1)
|
|||||||
int PLATFORM_PORT(int num)
|
int PLATFORM_PORT(int num)
|
||||||
{
|
{
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
UBYTE a, b;
|
UBYTE a, b, c, d;
|
||||||
get_platform_PORT(&a, &b);
|
get_platform_PORT(&a, &b, &c, &d);
|
||||||
|
|
||||||
return (b << 4) | (a & 0x0f);
|
return (b << 4) | (a & 0x0f);
|
||||||
}
|
}
|
||||||
|
if (num == 1) {
|
||||||
|
UBYTE a, b, c, d;
|
||||||
|
get_platform_PORT(&a, &b, &c, &d);
|
||||||
|
|
||||||
|
return (d << 4) | (c & 0x0f);
|
||||||
|
}
|
||||||
|
|
||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PLATFORM_TRIG(int num)
|
int PLATFORM_TRIG(int num)
|
||||||
{
|
{
|
||||||
UBYTE a, b;
|
UBYTE a, b, c, d;
|
||||||
get_platform_TRIG(&a, &b);
|
get_platform_TRIG(&a, &b, &c, &d);
|
||||||
|
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case 0:
|
case 0:
|
||||||
return a;
|
return a;
|
||||||
case 1:
|
case 1:
|
||||||
return b;
|
return b;
|
||||||
|
case 2:
|
||||||
|
return c;
|
||||||
|
case 3:
|
||||||
|
return d;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user