added Sega Mouse emulation

This commit is contained in:
ekeeke31 2008-08-11 15:18:57 +00:00
parent 09657296d4
commit ec3f6c3d37
5 changed files with 36 additions and 10 deletions

View File

@ -14,10 +14,12 @@ current:
- added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze) - 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 - 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 Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
- implemented Sega Mouse emulation - implemented Sega Mouse emulation (Populous 2, Body Count, Shangai 2...)
[Wii] [Wii]
- added Wiimote IR support for lightgun (Menacer/Justifier) controls - added lightgun support (Menacer/Justifier) through Wiimote IR
- added "Gun cursor" option to enable/disable gun position display
- added "Invert Mouse" option to invert Sega Mouse vertical axe (required by some games)
16/07/2008: 16/07/2008:
----------- -----------

View File

@ -1,6 +1,6 @@
/*************************************************************************************** /***************************************************************************************
* Genesis Plus 1.2a * Genesis Plus 1.2a
* Genesis internals & Bus arbitration * Genesis internals & Bus controller
* *
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* modified by Eke-Eke (compatibility fixes & additional code), GC/Wii port * modified by Eke-Eke (compatibility fixes & additional code), GC/Wii port

View File

@ -1,6 +1,6 @@
/*************************************************************************************** /***************************************************************************************
* Genesis Plus 1.2a * Genesis Plus 1.2a
* Genesis internals & Bus arbitration * Genesis internals & Bus controller
* *
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* modified by Eke-Eke (compatibility fixes & additional code), GC/Wii port * modified by Eke-Eke (compatibility fixes & additional code), GC/Wii port

View File

@ -95,7 +95,8 @@ static inline void lightgun_update(int num)
/* Sega Menacer specific */ /* Sega Menacer specific */
unsigned int menacer_read() unsigned int menacer_read()
{ {
int retval = 0x70; /* pins should return 0 by default (fix Body Count when mouse is enabled) */
int retval = 0x00;
if (input.pad[4] & INPUT_B) retval |= 0x01; if (input.pad[4] & INPUT_B) retval |= 0x01;
if (input.pad[4] & INPUT_A) retval |= 0x02; if (input.pad[4] & INPUT_A) retval |= 0x02;
if (input.pad[4] & INPUT_C) retval |= 0x04; if (input.pad[4] & INPUT_C) retval |= 0x04;
@ -139,12 +140,16 @@ struct mega_mouse
{ {
uint8 State; uint8 State;
uint8 Counter; uint8 Counter;
uint8 Wait;
uint8 Port;
} mouse; } mouse;
static inline void mouse_reset() static inline void mouse_reset()
{ {
mouse.State = 0x60; mouse.State = 0x60;
mouse.Counter = 0; mouse.Counter = 0;
mouse.Wait = 0;
mouse.Port = (input.system[0] == SYSTEM_MOUSE) ? 0 : 4;
} }
void mouse_write(unsigned int data) void mouse_write(unsigned int data)
@ -164,6 +169,8 @@ void mouse_write(unsigned int data)
if ((mouse.State&0x20) != (data&0x20)) if ((mouse.State&0x20) != (data&0x20))
{ {
mouse.Counter ++; /* increment phase */ mouse.Counter ++; /* increment phase */
mouse.Wait = 1; /* mouse latency */
if (mouse.Counter > 9) mouse.Counter = 9; if (mouse.Counter > 9) mouse.Counter = 9;
} }
} }
@ -203,10 +210,10 @@ unsigned int mouse_read()
break; break;
case 5: /* Buttons state */ case 5: /* Buttons state */
if (input.pad[0] & INPUT_B) temp |= 0x01; if (input.pad[mouse.Port] & INPUT_B) temp |= 0x01;
if (input.pad[0] & INPUT_A) temp |= 0x02; if (input.pad[mouse.Port] & INPUT_A) temp |= 0x02;
if (input.pad[0] & INPUT_C) temp |= 0x04; if (input.pad[mouse.Port] & INPUT_C) temp |= 0x04;
if (input.pad[0] & INPUT_START) temp |= 0x08; if (input.pad[mouse.Port] & INPUT_START) temp |= 0x08;
break; break;
case 6: /* X Axis MSB */ case 6: /* X Axis MSB */
@ -227,7 +234,19 @@ unsigned int mouse_read()
} }
/* TR-TL handshaking */ /* TR-TL handshaking */
if (mouse.State & 0x20) temp |= 0x10; if (mouse.Wait)
{
/* wait before ACK, fix some buggy mouse routine (Shangai 2, Wack World,...) */
mouse.Wait = 0;
/* TL = !TR */
temp |= (~mouse.State & 0x20) >> 1;
}
else
{
/* TL = TR */
temp |= (mouse.State & 0x20) >> 1;
}
return temp; return temp;
} }

View File

@ -88,6 +88,11 @@ void io_reset(void)
port[1].data_r = gamepad_2_read; port[1].data_r = gamepad_2_read;
break; break;
case SYSTEM_MOUSE:
port[1].data_w = mouse_write;
port[1].data_r = mouse_read;
break;
case SYSTEM_MENACER: case SYSTEM_MENACER:
port[1].data_w = NULL; port[1].data_w = NULL;
port[1].data_r = menacer_read; port[1].data_r = menacer_read;