Changed Qt GUI to use FCEU core autofire pattern logic instead of attempting to calculate its own.

This commit is contained in:
mjbudd77 2021-05-21 06:28:14 -04:00
parent 596c27ea5e
commit 20a691e608
3 changed files with 14 additions and 39 deletions

View File

@ -3084,9 +3084,11 @@ void consoleWin_t::emuSetFrameAdvDelay(void)
void consoleWin_t::setAutoFireOnFrames(void) void consoleWin_t::setAutoFireOnFrames(void)
{ {
int ret; int ret, autoFireOnFrames, autoFireOffFrames;
QInputDialog dialog(this); QInputDialog dialog(this);
GetAutoFirePattern( &autoFireOnFrames, &autoFireOffFrames );
dialog.setWindowTitle( tr("AutoFire Pattern ON Frames") ); dialog.setWindowTitle( tr("AutoFire Pattern ON Frames") );
dialog.setLabelText( tr("Specify desired number of ON frames in autofire pattern:") ); dialog.setLabelText( tr("Specify desired number of ON frames in autofire pattern:") );
dialog.setOkButtonText( tr("Ok") ); dialog.setOkButtonText( tr("Ok") );
@ -3098,15 +3100,19 @@ void consoleWin_t::setAutoFireOnFrames(void)
if ( QDialog::Accepted == ret ) if ( QDialog::Accepted == ret )
{ {
autoFireOnFrames = dialog.intValue(); autoFireOnFrames = dialog.intValue();
SetAutoFirePattern( autoFireOnFrames, autoFireOffFrames );
} }
} }
void consoleWin_t::setAutoFireOffFrames(void) void consoleWin_t::setAutoFireOffFrames(void)
{ {
int ret; int ret, autoFireOnFrames, autoFireOffFrames;
QInputDialog dialog(this); QInputDialog dialog(this);
GetAutoFirePattern( &autoFireOnFrames, &autoFireOffFrames );
dialog.setWindowTitle( tr("AutoFire Pattern OFF Frames") ); dialog.setWindowTitle( tr("AutoFire Pattern OFF Frames") );
dialog.setLabelText( tr("Specify desired number of OFF frames in autofire pattern:") ); dialog.setLabelText( tr("Specify desired number of OFF frames in autofire pattern:") );
dialog.setOkButtonText( tr("Ok") ); dialog.setOkButtonText( tr("Ok") );
@ -3118,7 +3124,9 @@ void consoleWin_t::setAutoFireOffFrames(void)
if ( QDialog::Accepted == ret ) if ( QDialog::Accepted == ret )
{ {
autoFireOffFrames = dialog.intValue(); autoFireOffFrames = dialog.intValue();
SetAutoFirePattern( autoFireOnFrames, autoFireOffFrames );
} }
} }

View File

@ -49,8 +49,6 @@
/** GLOBALS **/ /** GLOBALS **/
int NoWaiting = 0; int NoWaiting = 0;
int autoFireOnFrames = 1;
int autoFireOffFrames = 1;
extern Config *g_config; extern Config *g_config;
extern bool bindSavestate, frameAdvanceLagSkip, lagCounterDisplay; extern bool bindSavestate, frameAdvanceLagSkip, lagCounterDisplay;
@ -1377,29 +1375,10 @@ UpdateGamepad(void)
return; return;
} }
static int rapid[4][2] = { 0 };
uint32 JS = 0; uint32 JS = 0;
int x; int x;
int wg; int wg;
int onFrames; bool fire;
int offFrames;
int totalFrames;
bool fire, emuUpdated = false;
static unsigned int emuCount = 0;
if ( emulatorCycleCount != emuCount)
{
emuUpdated = true;
emuCount = emulatorCycleCount;
}
onFrames = autoFireOnFrames;
offFrames = autoFireOffFrames;
if ( onFrames < 1 ) onFrames = 1;
if ( offFrames < 1 ) offFrames = 1;
totalFrames = onFrames + offFrames;
int opposite_dirs; int opposite_dirs;
g_config->getOption("SDL.Input.EnableOppositeDirectionals", &opposite_dirs); g_config->getOption("SDL.Input.EnableOppositeDirectionals", &opposite_dirs);
@ -1451,22 +1430,12 @@ UpdateGamepad(void)
{ {
if (DTestButton (&GamePad[wg].bmap[8 + x])) if (DTestButton (&GamePad[wg].bmap[8 + x]))
{ {
fire = (rapid[wg][x] < onFrames); fire = GetAutoFireState(x);
//printf("wg:%i x:%i %i Fire:%i \n", wg, x, rapid[wg][x], fire );
if ( fire ) if ( fire )
{ {
JS |= (1 << x) << (wg << 3); JS |= (1 << x) << (wg << 3);
} }
if ( emuUpdated )
{
rapid[wg][x] = (rapid[wg][x] + 1) % totalFrames;
}
}
else
{
rapid[wg][x] = 0;
} }
} }
} }

View File

@ -27,8 +27,6 @@ struct ButtConfig
}; };
extern int NoWaiting; extern int NoWaiting;
extern int autoFireOnFrames;
extern int autoFireOffFrames;
extern CFGSTRUCT InputConfig[]; extern CFGSTRUCT InputConfig[];
extern ARGPSTRUCT InputArgs[]; extern ARGPSTRUCT InputArgs[];
void ParseGIInput(FCEUGI *GI); void ParseGIInput(FCEUGI *GI);