minor input code cleanup & fixes

it's now possible to change the input configuration when J-CART is detected: this let you play 6-player mode in Super Skidmarks by connecting 4-WayPlay
This commit is contained in:
ekeeke31 2010-07-28 12:01:03 +00:00
parent 283c251cc8
commit c44daa134b
5 changed files with 57 additions and 40 deletions

View File

@ -56,6 +56,7 @@ of samples per frame and keeping PSG & FM chips in sync.
* added accurate TMSS emulation (VDP lock-out)
* fixed Realtec mapper emulation: fixes missing sound in Balloon Boy / Funny World.
* fixed lightgun auto-detection: fixes default cursor position in Lethal Enforcers II.
* enabled simultaneous use of multitap & J-CART (Super Skidmarks 6-player mode)
* lots of code cleanup, bugfixes & optimization.

View File

@ -609,8 +609,8 @@ unsigned int jcart_read(unsigned int address)
void jcart_write(unsigned int address, unsigned int data)
{
gamepad_write(5, (data&1) << 6);
gamepad_write(6, (data&1) << 6);
gamepad_write(5, (data & 1) << 6);
gamepad_write(6, (data & 1) << 6);
return;
}
@ -706,8 +706,12 @@ void input_init(void)
/* J-CART: add two gamepad inputs */
if (cart.jcart)
{
input.dev[5] = config.input[2].padtype;
input.dev[6] = config.input[3].padtype;
if (player == MAX_INPUTS) return;
input.dev[5] = config.input[player].padtype;
player ++;
if (player == MAX_INPUTS) return;
input.dev[6] = config.input[player].padtype;
player ++;
}
}
@ -715,7 +719,7 @@ void input_reset(void)
{
/* Reset Controller device */
int i;
for (i=0; i<MAX_INPUTS; i++)
for (i=0; i<MAX_DEVICES; i++)
{
switch (input.dev[i])
{
@ -746,10 +750,10 @@ void input_reset(void)
wayplay.current = 0;
}
void input_update(void)
void input_refresh(void)
{
int i;
for (i=0; i<MAX_INPUTS; i++)
for (i=0; i<MAX_DEVICES; i++)
{
switch (input.dev[i])
{
@ -870,15 +874,12 @@ void input_autodetect(void)
{
cart.jcart = 1;
/* save current setting */
if (old_system[0] == -1)
old_system[0] = input.system[0];
if (old_system[1] == -1)
/* set default port 1 setting */
if (input.system[1] != SYSTEM_WAYPLAY)
{
old_system[1] = input.system[1];
/* set default settings */
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_GAMEPAD;
}
}
}
}

View File

@ -72,8 +72,7 @@ extern t_input input;
/* Function prototypes */
extern void input_init(void);
extern void input_reset(void);
extern void input_update(void);
extern void input_raz(void);
extern void input_refresh(void);
extern void input_autodetect(void);
/* Peripherals specific */

View File

@ -1472,53 +1472,70 @@ static void ctrlmenu_raz(void)
}
/* update buttons navigation */
if (input.dev[0] != NO_DEVICE)
m->buttons[0].shift[3] = 2;
else if (input.dev[4] != NO_DEVICE)
m->buttons[0].shift[3] = 6;
else if (input.dev[5] != NO_DEVICE)
m->buttons[0].shift[3] = 7;
else
m->buttons[0].shift[3] = 0;
if (input.dev[4] != NO_DEVICE)
m->buttons[1].shift[3] = 5;
else if (input.dev[5] != NO_DEVICE)
m->buttons[1].shift[3] = 6;
else if (input.dev[0] != NO_DEVICE)
m->buttons[1].shift[3] = 1;
else
m->buttons[1].shift[3] = 0;
if (input.dev[1] != NO_DEVICE)
m->buttons[2].shift[1] = 1;
else if (input.dev[4] != NO_DEVICE)
m->buttons[2].shift[1] = 4;
else if (input.dev[5] != NO_DEVICE)
m->buttons[2].shift[1] = 5;
else
m->buttons[2].shift[1] = 0;
if (input.dev[4] != NO_DEVICE)
m->buttons[5].shift[1] = 1;
else if (input.dev[5] != NO_DEVICE)
m->buttons[5].shift[1] = 2;
else
m->buttons[5].shift[1] = 0;
if (input.dev[3] != NO_DEVICE)
m->buttons[6].shift[0] = 1;
else if (input.dev[0] != NO_DEVICE)
m->buttons[6].shift[0] = 4;
else
m->buttons[6].shift[0] = 0;
if (input.dev[4] != NO_DEVICE)
m->buttons[5].shift[1] = 1;
else
m->buttons[5].shift[1] = 0;
if (input.dev[5] != NO_DEVICE)
{
m->buttons[6].shift[1] = 1;
if (input.dev[6] != NO_DEVICE)
{
m->buttons[7].shift[1] = 1;
if (input.dev[7] != NO_DEVICE) m->buttons[8].shift[1] = 1;
else m->buttons[8].shift[1] = 0;
}
else
{
m->buttons[7].shift[1] = 0;
}
}
else
{
m->buttons[6].shift[1] = 0;
}
if (input.dev[6] != NO_DEVICE)
m->buttons[7].shift[1] = 1;
else
m->buttons[7].shift[1] = 0;
if (input.dev[7] != NO_DEVICE)
m->buttons[8].shift[1] = 1;
else
m->buttons[8].shift[1] = 0;
if (input.dev[4] != NO_DEVICE)
m->buttons[7].shift[0] = 1;
else if (input.dev[3] != NO_DEVICE)
m->buttons[7].shift[0] = 2;
else if (input.dev[0] != NO_DEVICE)
m->buttons[7].shift[0] = 5;
else
m->buttons[7].shift[0] = 0;
}
static void ctrlmenu(void)
@ -1643,7 +1660,6 @@ static void ctrlmenu(void)
switch (m->selected)
{
case 0: /* update port 1 system */
if (cart.jcart) break;
if (input.system[0] == SYSTEM_MOUSE)
input.system[0] +=3; /* lightguns are never used on Port 1 */
else
@ -1658,7 +1674,7 @@ static void ctrlmenu(void)
input.system[1] = SYSTEM_GAMEPAD;
}
io_init();
io_reset();
input_reset();
old_system[0] = input.system[0];
old_system[1] = input.system[1];
@ -1708,7 +1724,7 @@ static void ctrlmenu(void)
input.system[0] = SYSTEM_GAMEPAD;
}
io_init();
io_reset();
input_reset();
old_system[0] = input.system[0];
old_system[1] = input.system[1];

View File

@ -395,8 +395,8 @@ void system_frame (int do_skip)
/* update VCounter */
v_counter = line;
/* update 6-Buttons or Menacer */
input_update();
/* update 6-Buttons & Lightguns */
input_refresh();
/* update VDP DMA */
if (dma_length) vdp_update_dma();