mirror of https://github.com/stella-emu/stella.git
improved states interval factor calculation
a little code cleanup
This commit is contained in:
parent
4dfc3ed9ad
commit
a43e7f9d58
|
@ -680,8 +680,10 @@ void DeveloperDialog::saveConfig()
|
||||||
// define interval growth factor
|
// define interval growth factor
|
||||||
uInt32 size = myStateSizeWidget->getValue();
|
uInt32 size = myStateSizeWidget->getValue();
|
||||||
uInt32 uncompressed = myUncompressedWidget->getValue();
|
uInt32 uncompressed = myUncompressedWidget->getValue();
|
||||||
|
|
||||||
|
const double MAX_FACTOR = 1E8;
|
||||||
uInt64 horizon = HORIZON_CYCLES[myStateHorizonWidget->getValue()];
|
uInt64 horizon = HORIZON_CYCLES[myStateHorizonWidget->getValue()];
|
||||||
double factor, minFactor = 1, maxFactor = 2;
|
double factor, minFactor = 1, maxFactor = MAX_FACTOR;
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
|
@ -689,11 +691,14 @@ void DeveloperDialog::saveConfig()
|
||||||
double cycleSum = interval * uncompressed;
|
double cycleSum = interval * uncompressed;
|
||||||
// calculate next factor
|
// calculate next factor
|
||||||
factor = (minFactor + maxFactor) / 2;
|
factor = (minFactor + maxFactor) / 2;
|
||||||
|
// horizon not reachable?
|
||||||
|
if(factor == MAX_FACTOR)
|
||||||
|
break;
|
||||||
// sum up interval cycles
|
// sum up interval cycles
|
||||||
for(uInt32 i = uncompressed; i < size; ++i)
|
for(uInt32 i = uncompressed; i < size; ++i)
|
||||||
{
|
{
|
||||||
cycleSum += interval;
|
|
||||||
interval *= factor;
|
interval *= factor;
|
||||||
|
cycleSum += interval;
|
||||||
}
|
}
|
||||||
double diff = cycleSum - horizon;
|
double diff = cycleSum - horizon;
|
||||||
//cerr << "factor " << factor << ", diff " << diff << endl;
|
//cerr << "factor " << factor << ", diff " << diff << endl;
|
||||||
|
@ -960,11 +965,11 @@ void DeveloperDialog::handleRewind()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::handleSize()
|
void DeveloperDialog::handleSize()
|
||||||
{
|
{
|
||||||
bool found = false;
|
|
||||||
uInt32 size = myStateSizeWidget->getValue();
|
uInt32 size = myStateSizeWidget->getValue();
|
||||||
uInt32 uncompressed = myUncompressedWidget->getValue();
|
uInt32 uncompressed = myUncompressedWidget->getValue();
|
||||||
uInt32 interval = myStateIntervalWidget->getValue();
|
uInt32 interval = myStateIntervalWidget->getValue();
|
||||||
uInt32 horizon = myStateHorizonWidget->getValue();
|
uInt32 horizon = myStateHorizonWidget->getValue();
|
||||||
|
bool found = false;
|
||||||
Int32 i;
|
Int32 i;
|
||||||
|
|
||||||
myStateSizeLabelWidget->setValue(size);
|
myStateSizeLabelWidget->setValue(size);
|
||||||
|
@ -984,15 +989,9 @@ void DeveloperDialog::handleSize()
|
||||||
} while(!found);
|
} while(!found);
|
||||||
|
|
||||||
if(size < uncompressed)
|
if(size < uncompressed)
|
||||||
{
|
|
||||||
myUncompressedWidget->setValue(size);
|
myUncompressedWidget->setValue(size);
|
||||||
myUncompressedLabelWidget->setValue(myStateSizeWidget->getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
myStateHorizonWidget->setValue(i);
|
|
||||||
myStateHorizonLabelWidget->setLabel(HORIZONS[i]);
|
|
||||||
myStateIntervalWidget->setValue(interval);
|
myStateIntervalWidget->setValue(interval);
|
||||||
myStateIntervalLabelWidget->setLabel(INTERVALS[interval]);
|
myStateHorizonWidget->setValue(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1002,21 +1001,19 @@ void DeveloperDialog::handleUncompressed()
|
||||||
uInt32 uncompressed = myUncompressedWidget->getValue();
|
uInt32 uncompressed = myUncompressedWidget->getValue();
|
||||||
|
|
||||||
myUncompressedLabelWidget->setValue(myUncompressedWidget->getValue());
|
myUncompressedLabelWidget->setValue(myUncompressedWidget->getValue());
|
||||||
if(uncompressed > size)
|
|
||||||
{
|
if(size < uncompressed)
|
||||||
myStateSizeWidget->setValue(uncompressed);
|
myStateSizeWidget->setValue(uncompressed);
|
||||||
myStateSizeLabelWidget->setValue(myUncompressedWidget->getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::handleInterval()
|
void DeveloperDialog::handleInterval()
|
||||||
{
|
{
|
||||||
bool found = false;
|
|
||||||
uInt32 size = myStateSizeWidget->getValue();
|
uInt32 size = myStateSizeWidget->getValue();
|
||||||
uInt32 uncompressed = myUncompressedWidget->getValue();
|
uInt32 uncompressed = myUncompressedWidget->getValue();
|
||||||
uInt32 interval = myStateIntervalWidget->getValue();
|
uInt32 interval = myStateIntervalWidget->getValue();
|
||||||
uInt32 horizon = myStateHorizonWidget->getValue();
|
uInt32 horizon = myStateHorizonWidget->getValue();
|
||||||
|
bool found = false;
|
||||||
Int32 i;
|
Int32 i;
|
||||||
|
|
||||||
myStateIntervalLabelWidget->setLabel(INTERVALS[interval]);
|
myStateIntervalLabelWidget->setLabel(INTERVALS[interval]);
|
||||||
|
@ -1035,26 +1032,20 @@ void DeveloperDialog::handleInterval()
|
||||||
size -= myStateSizeWidget->getStepValue();
|
size -= myStateSizeWidget->getStepValue();
|
||||||
} while(!found);
|
} while(!found);
|
||||||
|
|
||||||
myStateHorizonWidget->setValue(i);
|
|
||||||
myStateHorizonLabelWidget->setLabel(HORIZONS[i]);
|
|
||||||
myStateSizeWidget->setValue(size);
|
myStateSizeWidget->setValue(size);
|
||||||
myStateSizeLabelWidget->setValue(myStateSizeWidget->getValue());
|
|
||||||
|
|
||||||
if(size < uncompressed)
|
if(size < uncompressed)
|
||||||
{
|
|
||||||
myUncompressedWidget->setValue(size);
|
myUncompressedWidget->setValue(size);
|
||||||
myUncompressedLabelWidget->setValue(myStateSizeWidget->getValue());
|
myStateHorizonWidget->setValue(i);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::handleHorizon()
|
void DeveloperDialog::handleHorizon()
|
||||||
{
|
{
|
||||||
bool found = false;
|
|
||||||
uInt32 size = myStateSizeWidget->getValue();
|
uInt32 size = myStateSizeWidget->getValue();
|
||||||
uInt32 uncompressed = myUncompressedWidget->getValue();
|
uInt32 uncompressed = myUncompressedWidget->getValue();
|
||||||
uInt32 interval = myStateIntervalWidget->getValue();
|
uInt32 interval = myStateIntervalWidget->getValue();
|
||||||
uInt32 horizon = myStateHorizonWidget->getValue();
|
uInt32 horizon = myStateHorizonWidget->getValue();
|
||||||
|
bool found = false;
|
||||||
Int32 i;
|
Int32 i;
|
||||||
|
|
||||||
myStateHorizonLabelWidget->setLabel(HORIZONS[horizon]);
|
myStateHorizonLabelWidget->setLabel(HORIZONS[horizon]);
|
||||||
|
@ -1073,12 +1064,10 @@ void DeveloperDialog::handleHorizon()
|
||||||
size -= myStateSizeWidget->getStepValue();
|
size -= myStateSizeWidget->getStepValue();
|
||||||
} while(!found);
|
} while(!found);
|
||||||
|
|
||||||
myStateIntervalWidget->setValue(i);
|
|
||||||
myStateIntervalLabelWidget->setLabel(INTERVALS[i]);
|
|
||||||
myStateSizeWidget->setValue(size);
|
myStateSizeWidget->setValue(size);
|
||||||
if(size < uncompressed)
|
if(size < uncompressed)
|
||||||
myUncompressedWidget->setValue(size);
|
myUncompressedWidget->setValue(size);
|
||||||
myStateSizeLabelWidget->setValue(myStateSizeWidget->getValue());
|
myStateIntervalWidget->setValue(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -191,6 +191,7 @@ class DeveloperDialog : public Dialog
|
||||||
void handleUncompressed();
|
void handleUncompressed();
|
||||||
void handleInterval();
|
void handleInterval();
|
||||||
void handleHorizon();
|
void handleHorizon();
|
||||||
|
|
||||||
void handleFontSize();
|
void handleFontSize();
|
||||||
|
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
Loading…
Reference in New Issue