Added what amounts to a working example of a Microphone button. When playing an FDS game, the microphone replaces the input that the Start button would have.

Also added config file option replaceFDSStartWithMicrophone to allow someone to restore the previous functionality. I won't fully detail this unless there's no reasoning against it.
This commit is contained in:
ugetab 2010-04-28 08:06:56 +00:00
parent ed6a9b0684
commit 558c7930ae
2 changed files with 31 additions and 0 deletions

View File

@ -62,6 +62,7 @@ extern bool rightClickEnabled;
extern int CurrentState;
extern bool pauseWhileActive; //adelikat: Cheats dialog
extern bool AVIdisableMovieMessages;
extern bool replaceFDSStartWithMicrophone;
//window positions and sizes:
extern int ChtPosX,ChtPosY;
@ -307,6 +308,7 @@ static CFGSTRUCT fceuconfig[] = {
AC(compressSavestates),
AC(pauseWhileActive),
AC(AVIdisableMovieMessages),
AC(replaceFDSStartWithMicrophone),
ENDCFGSTRUCT
};

View File

@ -85,6 +85,8 @@ static uint8 joy_readbit[2];
uint8 joy[4]={0,0,0,0}; //HACK - should be static but movie needs it
static uint8 LastStrobe;
bool replaceFDSStartWithMicrophone = true;
#ifdef _USE_SHARED_MEMORY_
static uint32 BotPointer = 0; //mbg merge 7/18/06 changed to uint32
#endif
@ -107,12 +109,39 @@ static DECLFR(JPRead)
{
lagFlag = 0;
uint8 ret=0;
bool port=false;
static bool microphone = false;
// Test if the controller 2 start button is being pressed.
// On a famicom, c.2 start shouldn't exist, so it replaces it.
if (replaceFDSStartWithMicrophone) {
if ((joy[1]&8) == 8) {
// Test if this is a Famicom game.
if (GameInfo->type==GIT_FDS) {
port=((A&1)==0);
joy[1]&=0xF7;
} else {
microphone = false;
}
}
}
ret|=joyports[A&1].driver->Read(A&1);
if(portFC.driver)
ret = portFC.driver->Read(A&1,ret);
// Not verified against hardware.
// This line is iffy, may cause trouble. Needs more testing.
if (joy_readbit[1] >= 8) {
if (port) {
microphone = !microphone;
if (microphone) {
ret|=4;
}
}
}
ret|=X.DB&0xC0;
return(ret);
}