Support up to 6 gamepads.

This commit is contained in:
sorgelig
2019-01-08 17:45:07 +08:00
parent f344ac931a
commit bf19823309
2 changed files with 141 additions and 121 deletions

View File

@@ -609,7 +609,7 @@ int user_io_get_joyswap()
void user_io_analog_joystick(unsigned char joystick, char valueX, char valueY)
{
uint8_t joy = (!joyswap) ? joystick : joystick ? 0 : 1;
uint8_t joy = (joystick>1 || !joyswap) ? joystick : joystick^1;
if (core_type == CORE_TYPE_8BIT)
{
@@ -626,13 +626,7 @@ void user_io_analog_joystick(unsigned char joystick, char valueX, char valueY)
void user_io_digital_joystick(unsigned char joystick, uint16_t map, int newdir)
{
uint8_t joy = (!joyswap) ? joystick : joystick ? 0 : 1;
if (is_minimig())
{
spi_uio_cmd16(UIO_JOYSTICK0 + joy, map);
return;
}
uint8_t joy = (joystick>1 || !joyswap) ? joystick : joystick ^ 1;
// atari ST handles joystick 0 and 1 through the ikbd emulated by the io controller
// but only for joystick 1 and 2
@@ -642,8 +636,9 @@ void user_io_digital_joystick(unsigned char joystick, uint16_t map, int newdir)
return;
}
spi_uio_cmd16(UIO_JOYSTICK0 + joy, map);
if (joy_transl == 1 && newdir)
spi_uio_cmd16((joy < 2) ? (UIO_JOYSTICK0 + joy) : (UIO_JOYSTICK2 + joy - 2), map);
if (!is_minimig() && joy_transl == 1 && newdir)
{
user_io_analog_joystick(joystick, (map & 2) ? 128 : (map & 1) ? 127 : 0, (map & 8) ? 128 : (map & 4) ? 127 : 0);
}
@@ -2943,10 +2938,10 @@ static void adjust_vsize(char force)
if ((res & 0x8000) && (nres != res || force))
{
nres = res;
uint16_t scr_hsize = spi_w(0);
uint16_t scr_vsize = spi_w(0);
uint16_t scr_hsize = spi_w(0);
uint16_t scr_vsize = spi_w(0);
DisableIO();
printf("\033[1;37mVMODE: resolution: %u x %u, mode: %u\033[0m\n", scr_hsize, scr_vsize, res & 255);
static int loaded = 0;
@@ -2991,14 +2986,14 @@ static void store_vsize()
spi_uio_cmd_cont(UIO_GET_VMODE);
uint16_t res = spi_w(0);
uint16_t scr_hsize = spi_w(0);
uint16_t scr_vsize = spi_w(0);
uint16_t scr_hbl_l = spi_w(0);
uint16_t scr_hbl_r = spi_w(0);
uint16_t scr_vbl_t = spi_w(0);
uint16_t scr_vbl_b = spi_w(0);
uint16_t scr_hsize = spi_w(0);
uint16_t scr_vsize = spi_w(0);
uint16_t scr_hbl_l = spi_w(0);
uint16_t scr_hbl_r = spi_w(0);
uint16_t scr_vbl_t = spi_w(0);
uint16_t scr_vbl_b = spi_w(0);
DisableIO();
printf("\033[1;37mVMODE: store position: [%u-%u, %u-%u]\033[0m\n", scr_hbl_l, scr_hbl_r, scr_vbl_t, scr_vbl_b);
uint32_t mode = scr_hsize | (scr_vsize << 12) | ((res & 0xFF) << 24);