added sega mouse support, fixed banked EEPROM access

This commit is contained in:
ekeeke31 2008-08-10 20:40:04 +00:00
parent ea3cdd015f
commit 09657296d4
14 changed files with 324 additions and 145 deletions

View File

@ -4,20 +4,20 @@ Genesis Plus for Gamecube
current:
---------
[Genesis]
- "cycle-accurate" HINT timings: every timing sensitive games/demos are now *finally* working fine
- fixed CRAM/VSRAM DMA timings
- fixed SAT address mask on VRAM writes
- improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu
- disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up
- added support for some additional protected "pirate" games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze)
- improved overall Menacer emulation accuracy
- fixed Menacer support in Terminator 2: Arcade Game
- added Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
- (YM2612) fixed LFO phase update for CH3 special mode in MAME core: fix some SFX in Warlock & Alladin (thanks to AamirM)
- (YM2612) fixed enveloppe attenuation level on "KEY ON" in MAME core: fix Ecco 2's splash sound
- implemented cycle-accurate HINT timings: every timing sensitive games/demos are now *finally* working fine
- fixed a bug affecting CRAM/VSRAM DMA timings
- fixed Sprite Attribute Table address mask for VRAM writes
- improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu
- disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up
- added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze)
- improved Menacer emulation: fix lightgun support in Body Count & T2: The Arcade Game
- implemented Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
- implemented Sega Mouse emulation
[Wii]
- added Wiimote IR pointing for LightGun control (Menacer/Justifier)
- added Wiimote IR support for lightgun (Menacer/Justifier) controls
16/07/2008:
-----------

View File

@ -198,8 +198,7 @@ void cart_hw_init()
SVP CHIP
***********************************************/
svp = NULL;
if ((strstr(rominfo.product,"MK-1229") != NULL) ||
(strstr(rominfo.product,"G-7001") != NULL))
if (strstr(rominfo.international,"Virtua Racing") != NULL)
{
svp_init();
m68k_readmap_16[6] = SVP_DRAM;
@ -211,10 +210,10 @@ void cart_hw_init()
/**********************************************
SEGA MENACER
***********************************************/
input.x_offset = 0;
input.y_offset = 0;
input.x_offset = 0x00;
input.y_offset = 0x00;
if (strstr(rominfo.product,"MK-1658") != NULL) /* Menacer 6-in-1 pack */
if (strstr(rominfo.international,"MENACER") != NULL)
{
/* save current setting */
if (old_system[0] == -1) old_system[0] = input.system[0];
@ -222,32 +221,40 @@ void cart_hw_init()
input.system[0] = NO_SYSTEM;
input.system[1] = SYSTEM_MENACER;
/* specific game adjustment */
input.x_offset = 0x52;
input.y_offset = 0x00;
}
else if (strstr(rominfo.product,"T-081156") != NULL) /* T2: Arcade Game */
else if (strstr(rominfo.international,"T2 ; THE ARCADE GAME") != NULL)
{
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_MENACER;
/* specific game adjustment */
input.x_offset = 0x84;
input.y_offset = 8;
input.y_offset = 0x08;
}
else if (strstr(rominfo.product,"T-95136") != NULL) /* Lethal Enforcers II */
else if (strstr(rominfo.international,"BODY COUNT") != NULL)
{
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_JUSTIFIER;
input.system[0] = SYSTEM_MOUSE;
input.system[1] = SYSTEM_MENACER;
input.x_offset = 0x44;
input.y_offset = 0x18;
}
/* specific game adjustment */
input.x_offset = 0x18;
}
else if ((strstr(rominfo.product,"T-95096") != NULL) || /* Lethal Enforcers (USA,Europe) */
(strstr(rominfo.product,"T-95073") != NULL)) /* Lethal Enforcers (J)*/
/**********************************************
KONAMI JUSTIFIER
***********************************************/
if (strstr(rominfo.international,"LETHAL ENFORCERS II") != NULL)
{
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_JUSTIFIER;
input.x_offset = 0x18;
input.y_offset = 0x00;
}
else if (strstr(rominfo.international,"LETHAL ENFORCERS") != NULL)
{
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_JUSTIFIER;
input.x_offset = 0x00;
input.y_offset = 0x00;
}
/**********************************************

View File

@ -150,8 +150,6 @@ static inline void Detect_STOP()
void eeprom_write(uint32 address, uint32 value, uint32 word_access)
{
error("eeprom write%d 0x%x = 0x%x (0x%x)\n", 8*(1+word_access), address, value, m68k_get_reg (NULL, M68K_REG_PC));
/* decode SCL and SDA value */
if (word_access)
{
@ -418,7 +416,6 @@ void eeprom_write(uint32 address, uint32 value, uint32 word_access)
uint32 eeprom_read(uint32 address, uint32 word_access)
{
error("eeprom read%d 0x%x (0x%x)\n", 8*(1+word_access), address, m68k_get_reg (NULL, M68K_REG_PC));
uint8 sda_out = eeprom.sda;
/* EEPROM state */

View File

@ -89,7 +89,6 @@ static inline void lightgun_update(int num)
else
hc_latch = hc_256[(input.analog[num][0] / 2 + input.x_offset)%171];
}
}
}
@ -97,10 +96,10 @@ static inline void lightgun_update(int num)
unsigned int menacer_read()
{
int retval = 0x70;
if ((input.pad[4] & INPUT_B)) retval |= 0x01;
if ((input.pad[4] & INPUT_A)) retval |= 0x02;
if ((input.pad[4] & INPUT_C)) retval |= 0x04;
if ((input.pad[4] & INPUT_START)) retval |= 0x08;
if (input.pad[4] & INPUT_B) retval |= 0x01;
if (input.pad[4] & INPUT_A) retval |= 0x02;
if (input.pad[4] & INPUT_C) retval |= 0x04;
if (input.pad[4] & INPUT_START) retval |= 0x08;
return retval;
}
@ -118,13 +117,13 @@ unsigned int justifier_read()
return 0x30;
case 0x00: /* gun #1 enabled */
if ((input.pad[4] & INPUT_A)) retval &= ~0x01;
if ((input.pad[4] & INPUT_START)) retval &= ~0x02;
if (input.pad[4] & INPUT_A) retval &= ~0x01;
if (input.pad[4] & INPUT_START) retval &= ~0x02;
return retval;
case 0x20: /* gun #2 enabled */
if ((input.pad[5] & INPUT_A)) retval &= ~0x01;
if ((input.pad[5] & INPUT_START)) retval &= ~0x02;
if (input.pad[5] & INPUT_A) retval &= ~0x01;
if (input.pad[5] & INPUT_START) retval &= ~0x02;
return retval;
default: /* guns disabled */
@ -132,6 +131,108 @@ unsigned int justifier_read()
}
}
/*****************************************************************************
* SEGA MOUSE specific functions
*
*****************************************************************************/
struct mega_mouse
{
uint8 State;
uint8 Counter;
} mouse;
static inline void mouse_reset()
{
mouse.State = 0x60;
mouse.Counter = 0;
}
void mouse_write(unsigned int data)
{
if (mouse.Counter == 0)
{
/* TH 1->0 transition */
if ((mouse.State&0x40) && !(data&0x40))
{
/* start acquisition */
mouse.Counter = 1;
}
}
else
{
/* TR transition */
if ((mouse.State&0x20) != (data&0x20))
{
mouse.Counter ++; /* increment phase */
if (mouse.Counter > 9) mouse.Counter = 9;
}
}
/* end of acquisition (TH=1) */
if (data&0x40) mouse.Counter = 0;
/* update internal state */
mouse.State = data;
}
unsigned int mouse_read()
{
int temp = 0x00;
switch (mouse.Counter)
{
case 0: /* initial */
temp = 0x00;
break;
case 1: /* xxxx1011 */
temp = 0x0B;
break;
case 2: /* xxxx1111 */
temp = 0x0F;
break;
case 3: /* xxxx1111 */
temp = 0x0F;
break;
case 4: /* Axis sign and overflow */
if (input.analog[2][0] < 0) temp |= 0x01;
if (input.analog[2][1] < 0) temp |= 0x02;
break;
case 5: /* Buttons state */
if (input.pad[0] & INPUT_B) temp |= 0x01;
if (input.pad[0] & INPUT_A) temp |= 0x02;
if (input.pad[0] & INPUT_C) temp |= 0x04;
if (input.pad[0] & INPUT_START) temp |= 0x08;
break;
case 6: /* X Axis MSB */
temp = (input.analog[2][0] >> 4) & 0x0f;
break;
case 7: /* X Axis LSB */
temp = (input.analog[2][0] & 0x0f);
break;
case 8: /* Y Axis MSB */
temp = (input.analog[2][1] >> 4) & 0x0f;
break;
case 9: /* Y Axis LSB */
temp = (input.analog[2][1] & 0x0f);
break;
}
/* TR-TL handshaking */
if (mouse.State & 0x20) temp |= 0x10;
return temp;
}
/*****************************************************************************
* GAMEPAD specific functions (2PLAYERS/4WAYPLAY)
*
@ -517,6 +618,13 @@ void input_reset ()
input.dev[i*4] = input.padtype[input.max];
input.max ++;
gamepad_reset(i*4);
break;
case SYSTEM_MOUSE:
if (input.max == MAX_INPUTS) return;
input.dev[i*4] = DEVICE_MOUSE;
input.max ++;
mouse_reset();
break;
case SYSTEM_WAYPLAY:

View File

@ -24,20 +24,14 @@
#ifndef _INPUT_HW_H_
#define _INPUT_HW_H_
/* Available inputs */
#ifdef HW_DOL
#define MAX_INPUTS 4
#else
#define MAX_INPUTS 8
#endif
/* Input devices */
/* Max. number of devices */
#define MAX_DEVICES (8)
/* Device types */
#define DEVICE_3BUTTON (0x00) /* 3-button gamepad */
#define DEVICE_6BUTTON (0x01) /* 6-button gamepad */
#define DEVICE_LIGHTGUN (0x02) /* Sega Menacer */
#define DEVICE_MOUSE (0x03) /* Sega Mouse (not supported) */
#define DEVICE_LIGHTGUN (0x02) /* Sega Menacer or Konami Justifier */
#define DEVICE_MOUSE (0x03) /* Sega Mouse */
#define DEVICE_2BUTTON (0x04) /* 2-button gamepad (not supported) */
#define NO_DEVICE (0x0F) /* unconnected */
@ -55,13 +49,14 @@
#define INPUT_DOWN (0x00000002)
#define INPUT_UP (0x00000001)
/* System bitmasks */
/* System IO ports */
#define NO_SYSTEM (0) /* Unconnected Port*/
#define SYSTEM_GAMEPAD (1) /* Single Gamepad */
#define SYSTEM_MENACER (2) /* Sega Lightgun */
#define SYSTEM_JUSTIFIER (3) /* Konami Lightgun */
#define SYSTEM_TEAMPLAYER (4) /* Sega TeamPlayer */
#define SYSTEM_WAYPLAY (5) /* EA 4-Way Play (use both ports) */
#define SYSTEM_MOUSE (2) /* Sega Mouse */
#define SYSTEM_MENACER (3) /* Sega Menacer (port 2) */
#define SYSTEM_JUSTIFIER (4) /* Konami Justifier (port 2) */
#define SYSTEM_TEAMPLAYER (5) /* Sega TeamPlayer */
#define SYSTEM_WAYPLAY (6) /* EA 4-Way Play (use both ports) */
/* Players Inputs */
#define PLAYER_1A (0)
@ -81,7 +76,7 @@ typedef struct
uint8 system[2]; /* Can be any of the SYSTEM_* bitmasks */
uint8 max; /* maximum number of connected devices */
uint8 current; /* current PAD number (4WAYPLAY) */
int analog[2][2]; /* analog device */
int analog[3][2]; /* analog devices */
int x_offset;
int y_offset;
} t_input;
@ -95,6 +90,8 @@ extern void input_update(void);
extern void input_raz(void);
/* Peripherals specific */
extern void mouse_write(unsigned int data);
extern unsigned int mouse_read(void);
extern unsigned int menacer_read (void);
extern unsigned int justifier_read (void);
extern unsigned int gamepad_1_read (void);

View File

@ -60,6 +60,11 @@ void io_reset(void)
port[0].data_r = gamepad_1_read;
break;
case SYSTEM_MOUSE:
port[0].data_w = mouse_write;
port[0].data_r = mouse_read;
break;
case SYSTEM_WAYPLAY:
port[0].data_w = wayplay_1_write;
port[0].data_r = wayplay_1_read;

View File

@ -215,7 +215,7 @@ void z80_write_banked_memory (unsigned int address, unsigned int data)
return;
case EEPROM:
if ((address == eeprom.type.sda_in_adr) || (address == eeprom.type.scl_adr)) eeprom_write(address, data);
if ((address == eeprom.type.sda_in_adr) || (address == eeprom.type.scl_adr)) eeprom_write(address, data, 0);
else z80bank_unused_w(address, data);
return;
@ -345,7 +345,7 @@ unsigned int z80_read_banked_memory(unsigned int address)
return READ_BYTE(rom_readmap[offset], address & 0x7ffff);
case EEPROM:
if (address == eeprom.type.sda_out_adr) return eeprom_read(address);
if (address == eeprom.type.sda_out_adr) return eeprom_read(address, 0);
return READ_BYTE(rom_readmap[offset], address & 0x7ffff);
case CART_HW:

View File

@ -81,12 +81,11 @@ unsigned int vdp_dma_r(unsigned int address)
return *(uint16 *)(rom_readmap[address >> 19] + (address & 0x7ffff));
case EEPROM:
if (address == eeprom.type.sda_out_adr) return eeprom_read(address);
if (address == (eeprom.type.sda_out_adr & 0xfffffe)) return eeprom_read(address, 1);
return *(uint16 *)(rom_readmap[address >> 19] + (address & 0x7ffff));
case J_CART:
if (address == eeprom.type.sda_out_adr) return eeprom_read(address); /* some games also have EEPROM mapped here */
else return jcart_read();
return jcart_read();
default:
return *(uint16 *)(work_ram + (address & 0xffff));

View File

@ -63,6 +63,7 @@ void set_config_defaults(void)
/* controllers options */
ogc_input__set_defaults();
config.crosshair = 0;
config.gun_cursor = 1;
config.invert_mouse = 1;
}

View File

@ -30,7 +30,8 @@ typedef struct
uint16 pad_keymap[4][MAX_KEYS];
uint32 wpad_keymap[4*3][MAX_KEYS];
t_input_config input[MAX_DEVICES];
uint8 crosshair;
uint8 gun_cursor;
uint8 invert_mouse;
} t_config;
extern t_config config;

View File

@ -413,7 +413,7 @@ void ConfigureJoypads ()
int i = 0;
int quit = 0;
int prevmenu = menu;
char padmenu[7][20];
char padmenu[8][20];
int player = 0;
#ifdef HW_RVL
@ -432,6 +432,11 @@ void ConfigureJoypads ()
sprintf (padmenu[0], "Port 1: GAMEPAD");
max_players ++;
}
else if (input.system[0] == SYSTEM_MOUSE)
{
sprintf (padmenu[0], "Port 1: MOUSE");
max_players ++;
}
else if (input.system[0] == SYSTEM_WAYPLAY)
{
sprintf (padmenu[0], "Port 1: 4-WAYPLAY");
@ -487,29 +492,30 @@ void ConfigureJoypads ()
player = 0;
}
sprintf (padmenu[2], "Gun Cursor: %s", config.crosshair ? " ON":"OFF");
sprintf (padmenu[3], "Set Player: %d%s", player + 1, (j_cart && (player > 1)) ? "-JCART" : "");
sprintf (padmenu[2], "Gun Cursor: %s", config.gun_cursor ? "Y":"N");
sprintf (padmenu[3], "Invert Mouse: %s", config.gun_cursor ? "Y":"N");
sprintf (padmenu[4], "Set Player: %d%s", player + 1, (j_cart && (player > 1)) ? "-JCART" : "");
if (config.input[player].device == 0)
sprintf (padmenu[4], "Device: GAMECUBE %d", config.input[player].port + 1);
sprintf (padmenu[5], "Device: GAMECUBE %d", config.input[player].port + 1);
#ifdef HW_RVL
else if (config.input[player].device == 1)
sprintf (padmenu[4], "Device: WIIMOTE %d", config.input[player].port + 1);
sprintf (padmenu[5], "Device: WIIMOTE %d", config.input[player].port + 1);
else if (config.input[player].device == 2)
sprintf (padmenu[4], "Device: NUNCHUK %d", config.input[player].port + 1);
sprintf (padmenu[5], "Device: NUNCHUK %d", config.input[player].port + 1);
else if (config.input[player].device == 3)
sprintf (padmenu[4], "Device: CLASSIC %d", config.input[player].port + 1);
sprintf (padmenu[5], "Device: CLASSIC %d", config.input[player].port + 1);
#endif
else
sprintf (padmenu[4], "Device: NONE");
sprintf (padmenu[5], "Device: NONE");
/* when using wiimote, force to 3Buttons pad */
if (config.input[player].device == 1) input.padtype[player] = DEVICE_3BUTTON;
sprintf (padmenu[5], "%s", (input.padtype[player] == DEVICE_3BUTTON) ? "Type: 3BUTTONS":"Type: 6BUTTONS");
sprintf (padmenu[6], "%s", (input.padtype[player] == DEVICE_3BUTTON) ? "Type: 3BUTTONS":"Type: 6BUTTONS");
sprintf (padmenu[6], "Configure Input");
sprintf (padmenu[7], "Configure Input");
ret = domenu (&padmenu[0], 7,0);
ret = domenu (&padmenu[0], 8,0);
switch (ret)
{
@ -538,6 +544,7 @@ void ConfigureJoypads ()
break;
}
input.system[1] ++;
if (input.system[1] == SYSTEM_MOUSE) input.system[0] ++;
if (input.system[1] == SYSTEM_WAYPLAY) input.system[0] = SYSTEM_WAYPLAY;
if (input.system[1] > SYSTEM_WAYPLAY)
{
@ -547,10 +554,14 @@ void ConfigureJoypads ()
break;
case 2:
config.crosshair ^= 1;
config.gun_cursor ^= 1;
break;
case 3:
config.invert_mouse ^= 1;
break;
case 4:
/* remove duplicate assigned inputs */
for (i=0; i<8; i++)
{
@ -563,7 +574,7 @@ void ConfigureJoypads ()
player = (player + 1) % max_players;
break;
case 4:
case 5:
#ifdef HW_RVL
if (config.input[player].device == 1)
{
@ -622,19 +633,19 @@ void ConfigureJoypads ()
}
#else
config.input[player].device ++;
if (config.input[player].device > 3)
if (config.input[player].device > 0)
{
config.input[player].device = 0;
}
#endif
break;
case 5:
case 6:
if (config.input[player].device == 1) break;
input.padtype[player] ^= 1;
break;
case 6:
case 7:
ogc_input__config(config.input[player].port, config.input[player].device, input.padtype[player]);
break;

View File

@ -166,12 +166,7 @@ static void pad_update(s8 num, u8 i)
s8 x = PAD_StickX (num);
s8 y = PAD_StickY (num);
u16 p = PAD_ButtonsHeld(num);
/* update keys */
if ((p & PAD_BUTTON_UP) || (y > 70)) input.pad[i] |= INPUT_UP;
else if ((p & PAD_BUTTON_DOWN) || (y < -70)) input.pad[i] |= INPUT_DOWN;
if ((p & PAD_BUTTON_LEFT) || (x < -60)) input.pad[i] |= INPUT_LEFT;
else if ((p & PAD_BUTTON_RIGHT) || (x > 60)) input.pad[i] |= INPUT_RIGHT;
u8 sensitivity = 60;
/* get current key config */
u16 pad_keymap[MAX_KEYS];
@ -201,40 +196,44 @@ static void pad_update(s8 num, u8 i)
ConfigRequested = 1;
}
int temp;
/* LIGHTGUN screen position (x,y) */
if (input.dev[i] == DEVICE_LIGHTGUN)
{
temp = input.analog[i-4][0];
if ((input.pad[i] & INPUT_RIGHT)) temp ++;
else if ((input.pad[i] & INPUT_LEFT)) temp --;
if (temp < 0) temp = 0;
else if (temp > bitmap.viewport.w) temp = bitmap.viewport.w;
input.analog[i-4][0] = temp;
temp = input.analog[i-4][1];
if ((input.pad[i] & INPUT_UP)) temp --;
if ((input.pad[i] & INPUT_DOWN)) temp ++;
if (temp < 0) temp = 0;
else if (temp > bitmap.viewport.h) temp = bitmap.viewport.h;
input.analog[i-4][1] = temp;
input.analog[i-4][0] += x / sensitivity;
input.analog[i-4][1] += y / sensitivity;
if (input.analog[i-4][0] < 0) input.analog[i-4][0] = 0;
else if (input.analog[i-4][0] > bitmap.viewport.w) input.analog[i-4][0] = bitmap.viewport.w;
if (input.analog[i-4][1] < 0) input.analog[i-4][1] = 0;
else if (input.analog[i-4][1] > bitmap.viewport.h) input.analog[i-4][1] = bitmap.viewport.h;
}
/* PEN tablet position (x,y) */
else if ((system_hw == SYSTEM_PICO) && (i == 0))
{
temp = input.analog[0][0];
if ((input.pad[i] & INPUT_RIGHT)) temp ++;
else if ((input.pad[i] & INPUT_LEFT)) temp --;
if (temp < 0x17c) temp = 0x17c;
else if (temp > 0x3c) temp = 0x3c;
input.analog[0][0] = temp;
temp = input.analog[0][1];
if ((input.pad[i] & INPUT_UP)) temp --;
if ((input.pad[i] & INPUT_DOWN)) temp ++;
if (temp < 0x1fc) temp = 0x1fc;
else if (temp > 0x3f3) temp = 0x3f3;
input.analog[0][1] = temp;
input.analog[0][0] += x / sensitivity;
input.analog[0][1] += y / sensitivity;
if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c;
else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c;
if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc;
else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3;
}
/* MOUSE quantity of movement (-256,256) */
else if (input.dev[i] == DEVICE_MOUSE)
{
input.analog[2][0] = x * 2;
input.analog[2][1] = y * 2;
if (config.invert_mouse) input.analog[2][1] = 0 - input.analog[2][1];
}
/* GAMEPAD directional buttons */
else
{
if ((p & PAD_BUTTON_UP) || (y > sensitivity)) input.pad[i] |= INPUT_UP;
else if ((p & PAD_BUTTON_DOWN) || (y < -sensitivity)) input.pad[i] |= INPUT_DOWN;
if ((p & PAD_BUTTON_LEFT) || (x < -sensitivity)) input.pad[i] |= INPUT_LEFT;
else if ((p & PAD_BUTTON_RIGHT) || (x > sensitivity)) input.pad[i] |= INPUT_RIGHT;
}
}
/*******************************
@ -400,6 +399,7 @@ static void wpad_update(s8 num, u8 i, u32 exp)
u32 p = WPAD_ButtonsHeld(num);
/* get analog sticks values */
u8 sensitivity = 60;
s8 x = 0;
s8 y = 0;
if (exp != WPAD_EXP_NONE)
@ -408,12 +408,6 @@ static void wpad_update(s8 num, u8 i, u32 exp)
y = WPAD_StickY(num,0);
}
/* update directional key input */
if ((p & wpad_dirmap[exp][PAD_UP]) || (y > 70)) input.pad[i] |= INPUT_UP;
else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -70)) input.pad[i] |= INPUT_DOWN;
if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -60)) input.pad[i] |= INPUT_LEFT;
else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > 60)) input.pad[i] |= INPUT_RIGHT;
/* retrieve current key mapping */
u32 *wpad_keymap = config.wpad_keymap[exp + (3 * num)];
@ -426,12 +420,28 @@ static void wpad_update(s8 num, u8 i, u32 exp)
if (p & wpad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_Z;
if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START;
/* MODE Button */
if ((p & WPAD_CLASSIC_BUTTON_MINUS) || (p & WPAD_BUTTON_MINUS)) input.pad[i] |= INPUT_MODE;
/* MODE Button (FIXED) */
if (((exp == WPAD_EXP_CLASSIC) && (p & WPAD_CLASSIC_BUTTON_MINUS)) ||
((exp != WPAD_EXP_CLASSIC) && (p & WPAD_BUTTON_MINUS)))
input.pad[i] |= INPUT_MODE;
/* ANALOG Device (use IR pointing by default) */
/* LIGHTGUN screen position (X,Y) */
if (input.dev[i] == DEVICE_LIGHTGUN)
{
if (x || y)
{
/* analog stick */
input.analog[i-4][0] += x / sensitivity;
input.analog[i-4][1] += y / sensitivity;
if (input.analog[i-4][0] < 0) input.analog[i-4][0] = 0;
else if (input.analog[i-4][0] > bitmap.viewport.w) input.analog[i-4][0] = bitmap.viewport.w;
if (input.analog[i-4][1] < 0) input.analog[i-4][1] = 0;
else if (input.analog[i-4][1] > bitmap.viewport.h) input.analog[i-4][1] = bitmap.viewport.h;
}
if (exp != WPAD_EXP_CLASSIC)
{
/* wiimote IR */
struct ir_t ir;
WPAD_IR(num, &ir);
if (ir.valid)
@ -440,8 +450,25 @@ static void wpad_update(s8 num, u8 i, u32 exp)
input.analog[i-4][1] = (ir.y * bitmap.viewport.h) / 480;
}
}
}
/* PEN tablet position (x,y) */
else if ((system_hw == SYSTEM_PICO) && (i == 0))
{
if (x || y)
{
/* analog stick */
input.analog[0][0] += x / sensitivity;
input.analog[0][1] += y / sensitivity;
if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c;
else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c;
if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc;
else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3;
}
if (exp != WPAD_EXP_CLASSIC)
{
/* wiimote IR */
struct ir_t ir;
WPAD_IR(num, &ir);
if (ir.valid)
@ -450,6 +477,25 @@ static void wpad_update(s8 num, u8 i, u32 exp)
input.analog[0][1] = 0x1fc + (ir.y * (0x3f3 - 0x1fc + 1)) / 480;
}
}
}
/* MOUSE quantity of movement (-256,256) */
else if (input.dev[i] == DEVICE_MOUSE)
{
/* analog stick */
input.analog[2][0] = x * 2;
input.analog[2][1] = y * 2;
if (config.invert_mouse) input.analog[2][1] = 0 - input.analog[2][1];
}
/* GAMEPAD directional buttons */
else
{
if ((p & wpad_dirmap[exp][PAD_UP]) || (y > sensitivity)) input.pad[i] |= INPUT_UP;
else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -sensitivity)) input.pad[i] |= INPUT_DOWN;
if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -sensitivity)) input.pad[i] |= INPUT_LEFT;
else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > sensitivity)) input.pad[i] |= INPUT_RIGHT;
}
/* SOFTRESET */
if (((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)) ||

View File

@ -21,6 +21,13 @@
#ifndef _GC_INPUT_H_
#define _GC_INPUT_H_
/* max. supported inputs */
#ifdef HW_DOL
#define MAX_INPUTS 4
#else
#define MAX_INPUTS 8
#endif
/* number of configurable keys */
#define MAX_KEYS 8

View File

@ -687,7 +687,7 @@ void render_line(int line, uint8 odd_frame)
}
/* LightGun mark */
if ((input.dev[4] == DEVICE_LIGHTGUN) && (config.crosshair))
if ((input.dev[4] == DEVICE_LIGHTGUN) && (config.gun_cursor))
{
int dy = v_counter - input.analog[0][1];