diff --git a/src/driver.h b/src/driver.h index 70e853a0..5edd33eb 100644 --- a/src/driver.h +++ b/src/driver.h @@ -77,6 +77,8 @@ void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib); void FCEUI_SetInputFourscore(bool attachFourscore); //tells whether a fourscore is attached bool FCEUI_GetInputFourscore(); +//tells whether the microphone is used +bool FCEUI_GetInputMicrophone(); void FCEUI_UseInputPreset(int preset); @@ -167,7 +169,7 @@ void FCEUD_LoadStateFrom(void); //at the minimum, you should call FCEUI_SetInput, FCEUI_SetInputFC, and FCEUI_SetInputFourscore //you may also need to maintain your own internal state -void FCEUD_SetInput(bool fourscore, ESI port0, ESI port1, ESIFC fcexp); +void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, ESIFC fcexp); void FCEUD_MovieRecordTo(void); diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index d214b5dd..2b40311e 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -62,7 +62,7 @@ extern bool rightClickEnabled; extern int CurrentState; extern bool pauseWhileActive; //adelikat: Cheats dialog extern bool AVIdisableMovieMessages; -extern bool replaceFDSStartWithMicrophone; +extern bool replaceP2StartWithMicrophone; //window positions and sizes: extern int ChtPosX,ChtPosY; @@ -308,7 +308,7 @@ static CFGSTRUCT fceuconfig[] = { AC(compressSavestates), AC(pauseWhileActive), AC(AVIdisableMovieMessages), - AC(replaceFDSStartWithMicrophone), + AC(replaceP2StartWithMicrophone), ENDCFGSTRUCT }; diff --git a/src/drivers/win/input.cpp b/src/drivers/win/input.cpp index 6885917e..ef97c21c 100644 --- a/src/drivers/win/input.cpp +++ b/src/drivers/win/input.cpp @@ -46,6 +46,7 @@ int tempwinsync = 0; //Temp variable used by turbo to turn of sync settings int tempsoundquality = 0; //Temp variable used by turbo to turn of sound quality settings extern int winsync; extern int soundquality; +extern bool replaceP2StartWithMicrophone; //UsrInputType[] is user-specified. InputType[] is current // (game/savestate/movie loading can override user settings) @@ -371,11 +372,13 @@ void FCEUD_UpdateInput() } } -void FCEUD_SetInput(bool fourscore, ESI port0, ESI port1, ESIFC fcexp) +void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, ESIFC fcexp) { eoptions &= ~EO_FOURSCORE; if(fourscore) eoptions |= EO_FOURSCORE; + replaceP2StartWithMicrophone = microphone; + InputType[0]=port0; InputType[1]=port1; InputType[2]=fcexp; @@ -1086,6 +1089,9 @@ BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara //update the fourscore checkbox CheckDlgButton(hwndDlg,CHECK_ENABLE_FOURSCORE,(eoptions & EO_FOURSCORE)?BST_CHECKED:BST_UNCHECKED); + //update the microphone checkbox + CheckDlgButton(hwndDlg,CHECK_ENABLE_MICROPHONE,replaceP2StartWithMicrophone?BST_CHECKED:BST_UNCHECKED); + // Initialize the controls for the input ports for(unsigned int port = 0; port < NUMBER_OF_PORTS; port++) { @@ -1219,10 +1225,18 @@ BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == CHECK_ENABLE_FOURSCORE) { eoptions ^= EO_FOURSCORE; - FCEU_printf("Fourscore toggled to \n",(eoptions & EO_FOURSCORE)?"ON":"OFF"); + FCEU_printf("Fourscore toggled to %s\n",(eoptions & EO_FOURSCORE)?"ON":"OFF"); UpdateFourscoreState(hwndDlg); } + //Handle the fourscore button + if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == CHECK_ENABLE_MICROPHONE) + { + replaceP2StartWithMicrophone = !replaceP2StartWithMicrophone; + FCEU_printf("Microphone toggled to %s\n",replaceP2StartWithMicrophone?"ON":"OFF"); + } + + if(HIWORD(wParam) == CBN_SELENDOK) { switch(LOWORD(wParam)) diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index de77d609..5f381ea0 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -664,6 +664,8 @@ BEGIN CTEXT "3",IDC_STATIC,18,128,8,8 CONTROL "Attach four-score (implies four gamepads)",CHECK_ENABLE_FOURSCORE, "Button",BS_AUTOCHECKBOX,18,18,142,12 + CONTROL "Replace Port 2 Start With Microphone",CHECK_ENABLE_MICROPHONE, + "Button",BS_AUTOCHECKBOX,174,18,142,12 END MAHJONGDIALOG DIALOG 65510, 106, 340, 110 diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 1a42ba0d..42599c9f 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -264,6 +264,7 @@ #define IDC_CHEAT_CHECK_NE_BY 401 #define IDC_WINSIZE_MUL_Y 401 #define CHECK_ENABLE_FOURSCORE 401 +#define CHECK_ENABLE_MICROPHONE 407 #define IDC_CHEAT_CHECK_GT_BY 402 #define IDC_FORCE_INT_VIDEO_SCALARS 402 #define IDC_CHEAT_CHECK_LT_BY 403 diff --git a/src/input.cpp b/src/input.cpp index 39fd959b..a9ff4e33 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -85,7 +85,7 @@ 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; +bool replaceP2StartWithMicrophone = false; #ifdef _USE_SHARED_MEMORY_ static uint32 BotPointer = 0; //mbg merge 7/18/06 changed to uint32 @@ -109,40 +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); + // Test if the port 2 start button is being pressed. + // On a famicom, port 2 start shouldn't exist, so this removes it. + // Games can't automatically be checked for NES/Famicom status, + // so it's an all-encompassing change in the input config menu. + if ((replaceP2StartWithMicrophone) && (A&1) && (joy_readbit[1] == 4)) { + // Nullify Port 2 Start Button + ret&=0xFE; + } + if(portFC.driver) ret = portFC.driver->Read(A&1,ret); // Not verified against hardware. + if (replaceP2StartWithMicrophone) { // This line is iffy, may cause trouble. Needs more testing. - if (joy_readbit[1] >= 8) { - if (port) { - microphone = !microphone; - if (microphone) { - ret|=4; + if (joy_readbit[1] >= 8) { + if (joy[1]&8) { + microphone = !microphone; + if (microphone) { + ret|=4; + } + } else { + microphone = false; } } } ret|=X.DB&0xC0; + return(ret); } @@ -500,6 +499,10 @@ bool FCEUI_GetInputFourscore() { return FSAttached; } +bool FCEUI_GetInputMicrophone() +{ + return replaceP2StartWithMicrophone; +} void FCEUI_SetInputFourscore(bool attachFourscore) { FSAttached = attachFourscore; diff --git a/src/movie.cpp b/src/movie.cpp index 02c54a7c..da178591 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -97,6 +97,7 @@ SFORMAT FCEUMOV_STATEINFO[]={ char curMovieFilename[512] = {0}; MovieData currMovieData; +MovieData defaultMovieData; int currRerecordCount; void MovieData::clearRecordRange(int start, int len) @@ -347,6 +348,7 @@ MovieData::MovieData() , rerecordCount(0) , binaryFlag(false) , greenZoneCount(0) + , microphone(false) { memset(&romChecksum,0,sizeof(MD5DATA)); } @@ -377,6 +379,8 @@ void MovieData::installValue(std::string& key, std::string& val) guid = FCEU_Guid::fromString(val); else if(key == "fourscore") installBool(val,fourscore); + else if(key == "microphone") + installBool(val,microphone); else if(key == "port0") installInt(val,ports[0]); else if(key == "port1") @@ -416,6 +420,7 @@ int MovieData::dump(std::ostream *os, bool binary) *os << "romChecksum " << BytesToString(romChecksum.data,MD5DATA::size) << endl; *os << "guid " << guid.toString() << endl; *os << "fourscore " << (fourscore?1:0) << endl; + *os << "microphone " << (microphone?1:0) << endl; *os << "port0 " << ports[0] << endl; *os << "port1 " << ports[1] << endl; *os << "port2 " << ports[2] << endl; @@ -783,7 +788,7 @@ void FCEUMOV_EnterTasEdit() //todo - think about this //ResetInputTypes(); //todo - maybe this instead - //FCEUD_SetInput(currMovieData.fourscore,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]); + //FCEUD_SetInput(currMovieData.fourscore,currMovieData.microphone,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]); //pause the emulator FCEUI_SetEmulationPaused(1); @@ -877,7 +882,7 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus FCEUI_SetVidSystem(0); //force the input configuration stored in the movie to apply - FCEUD_SetInput(currMovieData.fourscore,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]); + FCEUD_SetInput(currMovieData.fourscore,currMovieData.microphone,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]); //stuff that should only happen when we're ready to positively commit to the replay if(tasedit) @@ -945,6 +950,7 @@ void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author) currMovieData.romChecksum = GameInfo->MD5; currMovieData.romFilename = FileBase; currMovieData.fourscore = FCEUI_GetInputFourscore(); + currMovieData.microphone = FCEUI_GetInputMicrophone(); currMovieData.ports[0] = joyports[0].type; currMovieData.ports[1] = joyports[1].type; currMovieData.ports[2] = portFC.type; diff --git a/src/movie.h b/src/movie.h index c3707f47..e3e62cbb 100644 --- a/src/movie.h +++ b/src/movie.h @@ -158,7 +158,7 @@ class MovieData { public: MovieData(); - + // Default Values: MovieData::MovieData() int version; int emuVersion; @@ -182,6 +182,8 @@ public: int ports[3]; //whether fourscore is enabled bool fourscore; + //whether microphone is enabled + bool microphone; //----TasEdit stuff--- int greenZoneCount;