コード例 #1
0
ファイル: TasStateManager.cs プロジェクト: TechnoTaff/BizHawk
        private void StateAccessed(int frame)
        {
            if (frame == 0 && _movie.StartsFromSavestate)
            {
                return;
            }

            tsmState state   = States[frame];
            bool     removed = accessed.Remove(state);

            accessed.Add(state);

            if (States[frame].IsOnDisk)
            {
                if (!States[accessed[0].Frame].IsOnDisk)
                {
                    MoveStateToDisk(accessed[0].Frame);
                }
                MoveStateToMemory(frame);
            }

            if (!removed && accessed.Count > maxStates)
            {
                accessed.RemoveAt(0);
            }
        }
コード例 #2
0
ファイル: TasStateManager.cs プロジェクト: TechnoTaff/BizHawk
        public void ClearStateHistory()
        {
            if (States.Any())
            {
                tsmState power = States.Values.FirstOrDefault(s => s.Frame == 0);
                StateAccessed(power.Frame);

                States.Clear();
                accessed.Clear();

                SetState(0, power.State);
                Used = (ulong)power.State.Length;

                clearDiskStates();
            }
        }
コード例 #3
0
ファイル: TasStateManager.cs プロジェクト: TechnoTaff/BizHawk
        private Point findState(tsmState s)
        {
            Point ret = new Point(0, -1);

            ret.X = s.Frame;
            if (!States.ContainsValue(s))
            {
                if (BranchStates.ContainsKey(s.Frame))
                {
                    ret.Y = BranchStates[s.Frame].Values.IndexOf(s);
                }
                if (ret.Y == -1)
                {
                    return(new Point(-1, -2));
                }
            }

            return(ret);
        }
コード例 #4
0
		private Point findState(tsmState s)
		{
			Point ret = new Point(0, -1);
			ret.X = s.Frame;
			if (!States.ContainsValue(s))
			{
				if (BranchStates.ContainsKey(s.Frame))
					ret.Y = BranchStates[s.Frame].Values.IndexOf(s);
				if (ret.Y == -1)
					return new Point(-1, -2);
			}

			return ret;
		}
コード例 #5
0
ファイル: TasStateManager.cs プロジェクト: TechnoTaff/BizHawk
        /// <summary>
        /// X is the frame of the state, Y is the branch (-1 for current).
        /// </summary>
        private Point StateToRemove()
        {
            int markerSkips = maxStates / 2;

            // X is frame, Y is branch
            Point shouldRemove = new Point(-1, -1);
            int   i            = 0;

            // lowPrioritySates (e.g. states with only lag frames between them)
            do
            {
                if (lowPriorityStates.Count > i)
                {
                    shouldRemove = findState(lowPriorityStates[i]);
                }
                else
                {
                    break;
                }

                // Keep marker states
                markerSkips--;
                if (markerSkips < 0)
                {
                    shouldRemove.X = -1;
                }
                i++;
            } while (StateIsMarker(shouldRemove.X, shouldRemove.Y) && markerSkips > -1 || shouldRemove.X == 0);

            // by last accessed
            markerSkips = maxStates / 2;
            if (shouldRemove.X < 1)
            {
                i = 0;
                do
                {
                    shouldRemove = findState(accessed[i]);

                    // Keep marker states
                    markerSkips--;
                    if (markerSkips < 0)
                    {
                        shouldRemove.X = -1;
                    }
                    i++;
                } while (StateIsMarker(shouldRemove.X, shouldRemove.Y) && markerSkips > -1 || shouldRemove.X == 0);
            }

            if (shouldRemove.X < 1)             // only found marker states above
            {
                if (BranchStates.Any())
                {
                    var kvp = BranchStates.ElementAt(1);
                    shouldRemove.X = kvp.Key;
                    shouldRemove.Y = kvp.Value.Keys[0];
                }
                else
                {
                    tsmState s = States.Values[1];
                    shouldRemove.X = s.Frame;
                    shouldRemove.Y = -1;
                }
            }

            return(shouldRemove);
        }