tsm decay: remove states within internal state gap

states settings: clamp things harder
This commit is contained in:
feos 2018-03-11 17:57:03 +03:00
parent 8165fdaaeb
commit 661a15dc2c
3 changed files with 40 additions and 11 deletions

View File

@ -53,6 +53,7 @@ namespace BizHawk.Client.Common
_align = false;
}
// todo: go through all states once, remove as many as we need. refactor to not need goto
public void Trigger(int decayStates)
{
for (; decayStates > 0 && _tsm.StateCount > 1;)
@ -72,6 +73,15 @@ namespace BizHawk.Client.Common
{
continue;
}
else if (currentFrame % _step > 0)
{
// ignore the pattern if the state doesn't belong already, drop it blindly and skip everything
_tsm.RemoveState(currentFrame);
decayStates--;
// this is the kind of highly complex loops that might justify goto
goto next_state;
}
else
{
currentFrame /= _step;
@ -96,10 +106,23 @@ namespace BizHawk.Client.Common
{
int currentFrame = _tsm.GetStateFrameByIndex(currentStateIndex) / _step;
if (_tsm.StateIsMarker(currentFrame * _step))
if (_tsm.StateIsMarker(currentFrame))
{
continue;
}
else if (currentFrame % _step > 0)
{
// ignore the pattern if the state doesn't belong already, drop it blindly and skip everything
_tsm.RemoveState(currentFrame);
decayStates--;
// this is the kind of highly complex loops that might justify goto
goto next_state;
}
else
{
currentFrame /= _step;
}
int zeroCount = _zeros[currentFrame & _mask];
int priority = ((currentFrame - baseStateFrame) >> zeroCount);
@ -139,6 +162,15 @@ namespace BizHawk.Client.Common
_tsm.RemoveState(backwardFrame * _step);
decayStates--;
}
else
{
// we're very sorry about failing to find states to remove, but we can't go beyond capacity, so remove at least something
// this shouldn't happen, but if we don't do it here, nothing good will happen either
_tsm.RemoveState(_tsm.GetStateFrameByIndex(1));
}
// this is the kind of highly complex loops that might justify goto
next_state:;
}
}

View File

@ -25,18 +25,15 @@ namespace BizHawk.Client.EmuHawk
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
MemCapacityNumeric.Maximum = 1024 * 8;
MemCapacityNumeric.Value = _settings.Capacitymb < MemCapacityNumeric.Maximum ?
_settings.Capacitymb : MemCapacityNumeric.Maximum;
DiskCapacityNumeric.Value = _settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
_settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
FileCapacityNumeric.Value = _settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
_settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
MemCapacityNumeric.Minimum = _stateSizeMb + 1;
MemStateGapDividerNumeric.Maximum = Statable.SaveStateBinary().Length / 1024 / 2 + 1;
MemStateGapDividerNumeric.Minimum = Math.Max(Statable.SaveStateBinary().Length / 1024 / 16, 1);
MemStateGapDividerNumeric.Value = NumberExtensions.Clamp(_settings.MemStateGapDivider,
MemStateGapDividerNumeric.Minimum, MemStateGapDividerNumeric.Maximum);
MemCapacityNumeric.Value = NumberExtensions.Clamp(_settings.Capacitymb, MemCapacityNumeric.Minimum, MemCapacityNumeric.Maximum);
DiskCapacityNumeric.Value = NumberExtensions.Clamp(_settings.DiskCapacitymb, MemCapacityNumeric.Minimum, MemCapacityNumeric.Maximum);
FileCapacityNumeric.Value = NumberExtensions.Clamp(_settings.DiskSaveCapacitymb, MemCapacityNumeric.Minimum, MemCapacityNumeric.Maximum);
MemStateGapDividerNumeric.Value = NumberExtensions.Clamp(_settings.MemStateGapDivider, MemStateGapDividerNumeric.Minimum, MemStateGapDividerNumeric.Maximum);
FileStateGapNumeric.Value = _settings.FileStateGap;
SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " MB";

View File

@ -940,7 +940,7 @@ namespace BizHawk.Client.EmuHawk
SplicerStatusLabel.Text =
"Selected: " + TasView.SelectedRows.Count() + " frame" +
(TasView.SelectedRows.Count() == 1 ? "" : "s") +
", State count: " + CurrentTasMovie.TasStateManager.StateCount.ToString() +
", States: " + CurrentTasMovie.TasStateManager.StateCount.ToString() +
", Clipboard: " + (_tasClipboard.Any() ? _tasClipboard.Count + " frame" +
(_tasClipboard.Count == 1 ? "" : "s") : "empty");
}