From 8e9b5afbd9d8c4e9d22cf2fe8a93505dc1838e49 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Sun, 5 Nov 2017 22:34:58 +0300 Subject: [PATCH] smart state gap for greenzone. fix #915 disable disk capacity setting --- .../movie/tasproj/TasStateManager.cs | 14 +- .../movie/tasproj/TasStateManagerSettings.cs | 32 +- .../TAStudio/GreenzoneSettings.Designer.cs | 293 ++++++++++++------ .../tools/TAStudio/GreenzoneSettings.cs | 36 ++- 4 files changed, 255 insertions(+), 120 deletions(-) diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index b4fe3b0138..af3006e4e4 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -44,14 +44,16 @@ private string StatePath private readonly TasMovie _movie; private ulong _expectedStateSize; - private readonly int _minFrequency = VersionInfo.DeveloperBuild ? 2 : 1; + private readonly int _minFrequency = 1; private const int MaxFrequency = 16; + private int MaxStates => (int)(Settings.Cap / _expectedStateSize) + (int)((ulong)Settings.DiskCapacitymb * 1024 * 1024 / _expectedStateSize); + private int FileStateGap => 1 << Settings.FileStateGap; private int StateFrequency { get { - int freq = (int)(_expectedStateSize / 65536); + int freq = (int)_expectedStateSize / Settings.MemStateGapDivider / 1024; if (freq < _minFrequency) { @@ -66,11 +68,7 @@ private int StateFrequency return freq; } } - - private int MaxStates => (int)(Settings.Cap / _expectedStateSize) + (int)((ulong)Settings.DiskCapacitymb * 1024 * 1024 / _expectedStateSize); - - private int StateGap => 1 << Settings.StateGap; - + public TasStateManager(TasMovie movie) { _movie = movie; @@ -585,7 +583,7 @@ private List ExcludeStates() for (int i = 1; i < _states.Count; i++) { if (_movie.Markers.IsMarker(_states.ElementAt(i).Key + 1) - || _states.ElementAt(i).Key % StateGap == 0) + || _states.ElementAt(i).Key % FileStateGap == 0) { continue; } diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs index e834d62666..24aff44e13 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManagerSettings.cs @@ -11,8 +11,9 @@ public TasStateManagerSettings() { DiskSaveCapacitymb = 512; Capacitymb = 512; - DiskCapacitymb = 512; - StateGap = 4; + DiskCapacitymb = 1; // not working yet + MemStateGapDivider = 64; + FileStateGap = 4; BranchStatesInTasproj = false; EraseBranchStatesFirst = true; } @@ -22,7 +23,8 @@ public TasStateManagerSettings(TasStateManagerSettings settings) DiskSaveCapacitymb = settings.DiskSaveCapacitymb; Capacitymb = settings.Capacitymb; DiskCapacitymb = settings.DiskCapacitymb; - StateGap = settings.StateGap; + MemStateGapDivider = settings.MemStateGapDivider; + FileStateGap = settings.FileStateGap; BranchStatesInTasproj = settings.BranchStatesInTasproj; EraseBranchStatesFirst = settings.EraseBranchStatesFirst; } @@ -55,12 +57,19 @@ public TasStateManagerSettings(TasStateManagerSettings settings) [Description("The size limit of the state history buffer on the disk. When this limit is reached it will start removing previous savestates")] public int DiskCapacitymb { get; set; } + /// + /// Gets or sets the divider that determines memory state gap + /// + [DisplayName("Divider for memory state interval")] + [Description("The actual state gap in frames is calculated as ExpectedStateSize / div / 1024")] + public int MemStateGapDivider { get; set; } + /// /// Gets or sets the amount of states to skip during project saving /// [DisplayName("State interval for .tasproj")] [Description("The actual state gap in frames is calculated as Nth power on 2")] - public int StateGap { get; set; } + public int FileStateGap { get; set; } /// /// Gets or sets a value indicating whether or not to save branch states into the movie file @@ -99,7 +108,8 @@ public override string ToString() sb.AppendLine(DiskCapacitymb.ToString()); sb.AppendLine(BranchStatesInTasproj.ToString()); sb.AppendLine(EraseBranchStatesFirst.ToString()); - sb.AppendLine(StateGap.ToString()); + sb.AppendLine(FileStateGap.ToString()); + sb.AppendLine(MemStateGapDivider.ToString()); return sb.ToString(); } @@ -123,13 +133,13 @@ public void PopulateFromString(string settings) DiskSaveCapacitymb = refCapacity; } - DiskCapacitymb = lines.Length > 2 ? int.Parse(lines[2]) : 512; - - BranchStatesInTasproj = lines.Length > 3 && bool.Parse(lines[3]); - - EraseBranchStatesFirst = lines.Length <= 4 || bool.Parse(lines[4]); + int i = 2; - StateGap = lines.Length > 5 ? int.Parse(lines[5]) : 4; + DiskCapacitymb = lines.Length > i ? int.Parse(lines[i++]) : 1; + BranchStatesInTasproj = lines.Length > i && bool.Parse(lines[i++]); + EraseBranchStatesFirst = lines.Length <= i || bool.Parse(lines[i++]); + FileStateGap = lines.Length > i ? int.Parse(lines[i++]) : 4; + FileStateGap = lines.Length > i ? int.Parse(lines[i++]) : 64; } catch (Exception) // TODO: this is bad { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.Designer.cs index 783645dcce..9a15b7e7e3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.Designer.cs @@ -48,28 +48,38 @@ private void InitializeComponent() this.DiskCapacityNumeric = new System.Windows.Forms.NumericUpDown(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); - this.SaveCapacityNumeric = new System.Windows.Forms.NumericUpDown(); + this.FileCapacityNumeric = new System.Windows.Forms.NumericUpDown(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.NumSaveStatesLabel = new System.Windows.Forms.Label(); this.BranchStatesInTasproj = new System.Windows.Forms.CheckBox(); this.EraseBranchStatesFirst = new System.Windows.Forms.CheckBox(); - this.StateGap = new System.Windows.Forms.NumericUpDown(); + this.FileStateGapNumeric = new System.Windows.Forms.NumericUpDown(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); - this.NumFramesLabel = new System.Windows.Forms.Label(); + this.FileNumFramesLabel = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.label14 = new System.Windows.Forms.Label(); + this.MemFramesLabel = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.MemStateGapDividerNumeric = new System.Windows.Forms.NumericUpDown(); + this.label12 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); ((System.ComponentModel.ISupportInitialize)(this.MemCapacityNumeric)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.DiskCapacityNumeric)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.SaveCapacityNumeric)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.StateGap)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.FileCapacityNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.FileStateGapNumeric)).BeginInit(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.MemStateGapDividerNumeric)).BeginInit(); + this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // CancelBtn // this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBtn.Location = new System.Drawing.Point(217, 220); + this.CancelBtn.Location = new System.Drawing.Point(242, 259); this.CancelBtn.Name = "CancelBtn"; this.CancelBtn.Size = new System.Drawing.Size(60, 23); this.CancelBtn.TabIndex = 0; @@ -80,7 +90,7 @@ private void InitializeComponent() // OkBtn // this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OkBtn.Location = new System.Drawing.Point(151, 220); + this.OkBtn.Location = new System.Drawing.Point(176, 259); this.OkBtn.Name = "OkBtn"; this.OkBtn.Size = new System.Drawing.Size(60, 23); this.OkBtn.TabIndex = 1; @@ -90,7 +100,7 @@ private void InitializeComponent() // // MemCapacityNumeric // - this.MemCapacityNumeric.Location = new System.Drawing.Point(15, 49); + this.MemCapacityNumeric.Location = new System.Drawing.Point(12, 36); this.MemCapacityNumeric.Maximum = new decimal(new int[] { 1024, 0, @@ -114,20 +124,20 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(70, 52); + this.label1.Location = new System.Drawing.Point(73, 39); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(21, 13); + this.label1.Size = new System.Drawing.Size(23, 13); this.label1.TabIndex = 4; - this.label1.Text = "mb"; + this.label1.Text = "MB"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 32); + this.label2.Location = new System.Drawing.Point(9, 19); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(88, 13); + this.label2.Size = new System.Drawing.Size(48, 13); this.label2.TabIndex = 5; - this.label2.Text = "Memory Capacity"; + this.label2.Text = "Capacity"; // // label3 // @@ -150,7 +160,7 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(12, 136); + this.label4.Location = new System.Drawing.Point(160, 9); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(84, 13); this.label4.TabIndex = 8; @@ -159,17 +169,18 @@ private void InitializeComponent() // NumStatesLabel // this.NumStatesLabel.AutoSize = true; - this.NumStatesLabel.Location = new System.Drawing.Point(99, 136); + this.NumStatesLabel.Location = new System.Drawing.Point(250, 9); this.NumStatesLabel.Name = "NumStatesLabel"; - this.NumStatesLabel.Size = new System.Drawing.Size(25, 13); + this.NumStatesLabel.Size = new System.Drawing.Size(13, 13); this.NumStatesLabel.TabIndex = 9; - this.NumStatesLabel.Text = "1kb"; + this.NumStatesLabel.Text = "1"; // // DiskCapacityNumeric // - this.DiskCapacityNumeric.Location = new System.Drawing.Point(15, 113); + this.DiskCapacityNumeric.Enabled = false; + this.DiskCapacityNumeric.Location = new System.Drawing.Point(24, 241); this.DiskCapacityNumeric.Maximum = new decimal(new int[] { - 65536, + 1, 0, 0, 0}); @@ -182,7 +193,7 @@ private void InitializeComponent() this.DiskCapacityNumeric.Size = new System.Drawing.Size(55, 20); this.DiskCapacityNumeric.TabIndex = 3; this.DiskCapacityNumeric.Value = new decimal(new int[] { - 512, + 1, 0, 0, 0}); @@ -191,61 +202,63 @@ private void InitializeComponent() // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(70, 116); + this.label5.Enabled = false; + this.label5.Location = new System.Drawing.Point(79, 244); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(21, 13); + this.label5.Size = new System.Drawing.Size(23, 13); this.label5.TabIndex = 4; - this.label5.Text = "mb"; + this.label5.Text = "MB"; // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(12, 96); + this.label6.Enabled = false; + this.label6.Location = new System.Drawing.Point(21, 224); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(72, 13); this.label6.TabIndex = 5; this.label6.Text = "Disk Capacity"; // - // SaveCapacityNumeric + // FileCapacityNumeric // - this.SaveCapacityNumeric.Location = new System.Drawing.Point(150, 49); - this.SaveCapacityNumeric.Maximum = new decimal(new int[] { + this.FileCapacityNumeric.Location = new System.Drawing.Point(12, 36); + this.FileCapacityNumeric.Maximum = new decimal(new int[] { 65536, 0, 0, 0}); - this.SaveCapacityNumeric.Name = "SaveCapacityNumeric"; - this.SaveCapacityNumeric.Size = new System.Drawing.Size(55, 20); - this.SaveCapacityNumeric.TabIndex = 3; - this.SaveCapacityNumeric.Value = new decimal(new int[] { + this.FileCapacityNumeric.Name = "FileCapacityNumeric"; + this.FileCapacityNumeric.Size = new System.Drawing.Size(55, 20); + this.FileCapacityNumeric.TabIndex = 3; + this.FileCapacityNumeric.Value = new decimal(new int[] { 512, 0, 0, 0}); - this.SaveCapacityNumeric.ValueChanged += new System.EventHandler(this.SaveCapacityNumeric_ValueChanged); + this.FileCapacityNumeric.ValueChanged += new System.EventHandler(this.SaveCapacityNumeric_ValueChanged); // // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(205, 52); + this.label7.Location = new System.Drawing.Point(73, 39); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(21, 13); + this.label7.Size = new System.Drawing.Size(23, 13); this.label7.TabIndex = 4; - this.label7.Text = "mb"; + this.label7.Text = "MB"; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(147, 32); + this.label8.Location = new System.Drawing.Point(9, 19); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(112, 13); + this.label8.Size = new System.Drawing.Size(48, 13); this.label8.TabIndex = 5; - this.label8.Text = "Project Save Capacity"; + this.label8.Text = "Capacity"; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(147, 72); + this.label9.Location = new System.Drawing.Point(9, 59); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(84, 13); this.label9.TabIndex = 8; @@ -254,21 +267,21 @@ private void InitializeComponent() // NumSaveStatesLabel // this.NumSaveStatesLabel.AutoSize = true; - this.NumSaveStatesLabel.Location = new System.Drawing.Point(234, 72); + this.NumSaveStatesLabel.Location = new System.Drawing.Point(96, 59); this.NumSaveStatesLabel.Name = "NumSaveStatesLabel"; - this.NumSaveStatesLabel.Size = new System.Drawing.Size(25, 13); + this.NumSaveStatesLabel.Size = new System.Drawing.Size(13, 13); this.NumSaveStatesLabel.TabIndex = 9; - this.NumSaveStatesLabel.Text = "1kb"; + this.NumSaveStatesLabel.Text = "1"; // // BranchStatesInTasproj // this.BranchStatesInTasproj.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.BranchStatesInTasproj.AutoSize = true; - this.BranchStatesInTasproj.Location = new System.Drawing.Point(15, 165); + this.BranchStatesInTasproj.Location = new System.Drawing.Point(12, 153); this.BranchStatesInTasproj.Name = "BranchStatesInTasproj"; - this.BranchStatesInTasproj.Size = new System.Drawing.Size(158, 17); + this.BranchStatesInTasproj.Size = new System.Drawing.Size(118, 17); this.BranchStatesInTasproj.TabIndex = 10; - this.BranchStatesInTasproj.Text = "Put branch states to .tasproj"; + this.BranchStatesInTasproj.Text = "Save branch states"; this.BranchStatesInTasproj.UseVisualStyleBackColor = true; this.BranchStatesInTasproj.CheckedChanged += new System.EventHandler(this.BranchStatesInTasproj_CheckedChanged); // @@ -278,7 +291,7 @@ private void InitializeComponent() this.EraseBranchStatesFirst.AutoSize = true; this.EraseBranchStatesFirst.Checked = true; this.EraseBranchStatesFirst.CheckState = System.Windows.Forms.CheckState.Checked; - this.EraseBranchStatesFirst.Location = new System.Drawing.Point(15, 190); + this.EraseBranchStatesFirst.Location = new System.Drawing.Point(6, 153); this.EraseBranchStatesFirst.Name = "EraseBranchStatesFirst"; this.EraseBranchStatesFirst.Size = new System.Drawing.Size(139, 17); this.EraseBranchStatesFirst.TabIndex = 11; @@ -286,50 +299,146 @@ private void InitializeComponent() this.EraseBranchStatesFirst.UseVisualStyleBackColor = true; this.EraseBranchStatesFirst.CheckedChanged += new System.EventHandler(this.EraseBranchStatesFIrst_CheckedChanged); // - // StateGap + // FileStateGapNumeric // - this.StateGap.Location = new System.Drawing.Point(151, 112); - this.StateGap.Maximum = new decimal(new int[] { + this.FileStateGapNumeric.Location = new System.Drawing.Point(12, 100); + this.FileStateGapNumeric.Maximum = new decimal(new int[] { 8, 0, 0, 0}); - this.StateGap.Name = "StateGap"; - this.StateGap.Size = new System.Drawing.Size(55, 20); - this.StateGap.TabIndex = 12; - this.StateGap.Value = new decimal(new int[] { + this.FileStateGapNumeric.Name = "FileStateGapNumeric"; + this.FileStateGapNumeric.Size = new System.Drawing.Size(55, 20); + this.FileStateGapNumeric.TabIndex = 12; + this.FileStateGapNumeric.Value = new decimal(new int[] { 1, 0, 0, 0}); - this.StateGap.ValueChanged += new System.EventHandler(this.StateGap_ValueChanged); + this.FileStateGapNumeric.ValueChanged += new System.EventHandler(this.FileStateGap_ValueChanged); // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(148, 96); + this.label10.Location = new System.Drawing.Point(9, 84); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(91, 13); + this.label10.Size = new System.Drawing.Size(55, 13); this.label10.TabIndex = 13; - this.label10.Text = "Project State Gap"; + this.label10.Text = "State Gap"; // // label11 // this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(147, 135); + this.label11.Location = new System.Drawing.Point(8, 123); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(61, 13); this.label11.TabIndex = 14; this.label11.Text = "State every"; // - // NumFramesLabel - // - this.NumFramesLabel.AutoSize = true; - this.NumFramesLabel.Location = new System.Drawing.Point(204, 135); - this.NumFramesLabel.Name = "NumFramesLabel"; - this.NumFramesLabel.Size = new System.Drawing.Size(47, 13); - this.NumFramesLabel.TabIndex = 15; - this.NumFramesLabel.Text = "0 frames"; + // FileNumFramesLabel + // + this.FileNumFramesLabel.AutoSize = true; + this.FileNumFramesLabel.Location = new System.Drawing.Point(65, 123); + this.FileNumFramesLabel.Name = "FileNumFramesLabel"; + this.FileNumFramesLabel.Size = new System.Drawing.Size(47, 13); + this.FileNumFramesLabel.TabIndex = 15; + this.FileNumFramesLabel.Text = "0 frames"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.label14); + this.groupBox1.Controls.Add(this.MemFramesLabel); + this.groupBox1.Controls.Add(this.label13); + this.groupBox1.Controls.Add(this.MemStateGapDividerNumeric); + this.groupBox1.Controls.Add(this.label12); + this.groupBox1.Controls.Add(this.EraseBranchStatesFirst); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.MemCapacityNumeric); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(12, 34); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(143, 176); + this.groupBox1.TabIndex = 16; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Memory Usage"; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(73, 102); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(21, 13); + this.label14.TabIndex = 17; + this.label14.Text = "KB"; + // + // MemFramesLabel + // + this.MemFramesLabel.AutoSize = true; + this.MemFramesLabel.Location = new System.Drawing.Point(66, 123); + this.MemFramesLabel.Name = "MemFramesLabel"; + this.MemFramesLabel.Size = new System.Drawing.Size(47, 13); + this.MemFramesLabel.TabIndex = 16; + this.MemFramesLabel.Text = "0 frames"; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(9, 123); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(61, 13); + this.label13.TabIndex = 15; + this.label13.Text = "State every"; + // + // MemStateGapDividerNumeric + // + this.MemStateGapDividerNumeric.Location = new System.Drawing.Point(12, 100); + this.MemStateGapDividerNumeric.Maximum = new decimal(new int[] { + 1024, + 0, + 0, + 0}); + this.MemStateGapDividerNumeric.Minimum = new decimal(new int[] { + 64, + 0, + 0, + 0}); + this.MemStateGapDividerNumeric.Name = "MemStateGapDividerNumeric"; + this.MemStateGapDividerNumeric.Size = new System.Drawing.Size(55, 20); + this.MemStateGapDividerNumeric.TabIndex = 7; + this.MemStateGapDividerNumeric.Value = new decimal(new int[] { + 65, + 0, + 0, + 0}); + this.MemStateGapDividerNumeric.ValueChanged += new System.EventHandler(this.MemStateGapDivider_ValueChanged); + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(9, 84); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(91, 13); + this.label12.TabIndex = 6; + this.label12.Text = "State Gap Divider"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label8); + this.groupBox2.Controls.Add(this.FileCapacityNumeric); + this.groupBox2.Controls.Add(this.FileNumFramesLabel); + this.groupBox2.Controls.Add(this.label7); + this.groupBox2.Controls.Add(this.BranchStatesInTasproj); + this.groupBox2.Controls.Add(this.label11); + this.groupBox2.Controls.Add(this.label9); + this.groupBox2.Controls.Add(this.label10); + this.groupBox2.Controls.Add(this.NumSaveStatesLabel); + this.groupBox2.Controls.Add(this.FileStateGapNumeric); + this.groupBox2.Location = new System.Drawing.Point(163, 34); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(138, 176); + this.groupBox2.TabIndex = 17; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Project File"; // // StateHistorySettingsForm // @@ -337,28 +446,16 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.CancelBtn; - this.ClientSize = new System.Drawing.Size(289, 255); - this.Controls.Add(this.NumFramesLabel); - this.Controls.Add(this.label11); - this.Controls.Add(this.label10); - this.Controls.Add(this.StateGap); - this.Controls.Add(this.EraseBranchStatesFirst); - this.Controls.Add(this.BranchStatesInTasproj); - this.Controls.Add(this.NumSaveStatesLabel); - this.Controls.Add(this.NumStatesLabel); - this.Controls.Add(this.label9); - this.Controls.Add(this.label4); + this.ClientSize = new System.Drawing.Size(315, 294); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.DiskCapacityNumeric); + this.Controls.Add(this.label5); this.Controls.Add(this.SavestateSizeLabel); - this.Controls.Add(this.label3); - this.Controls.Add(this.label8); - this.Controls.Add(this.label7); this.Controls.Add(this.label6); - this.Controls.Add(this.label5); - this.Controls.Add(this.SaveCapacityNumeric); - this.Controls.Add(this.label2); - this.Controls.Add(this.DiskCapacityNumeric); - this.Controls.Add(this.label1); - this.Controls.Add(this.MemCapacityNumeric); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.NumStatesLabel); this.Controls.Add(this.OkBtn); this.Controls.Add(this.CancelBtn); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -369,8 +466,13 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.StateHistorySettings_Load); ((System.ComponentModel.ISupportInitialize)(this.MemCapacityNumeric)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.DiskCapacityNumeric)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.SaveCapacityNumeric)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.StateGap)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.FileCapacityNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.FileStateGapNumeric)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.MemStateGapDividerNumeric)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -388,16 +490,23 @@ private void InitializeComponent() private NumericUpDown DiskCapacityNumeric; private Label label5; private Label label6; - private NumericUpDown SaveCapacityNumeric; + private NumericUpDown FileCapacityNumeric; private Label label7; private Label label8; private Label label9; private Label NumSaveStatesLabel; private CheckBox BranchStatesInTasproj; private CheckBox EraseBranchStatesFirst; - private NumericUpDown StateGap; + private NumericUpDown FileStateGapNumeric; private Label label10; private Label label11; - private Label NumFramesLabel; + private Label FileNumFramesLabel; + private GroupBox groupBox1; + private NumericUpDown MemStateGapDividerNumeric; + private Label label12; + private GroupBox groupBox2; + private Label MemFramesLabel; + private Label label13; + private Label label14; } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs index 2c81c328fe..bcf2d50104 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs @@ -36,11 +36,16 @@ private void StateHistorySettings_Load(object sender, EventArgs e) _settings.Capacitymb : MemCapacityNumeric.Maximum; DiskCapacityNumeric.Value = _settings.DiskCapacitymb < MemCapacityNumeric.Maximum ? _settings.DiskCapacitymb : MemCapacityNumeric.Maximum; - SaveCapacityNumeric.Value = _settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ? + FileCapacityNumeric.Value = _settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ? _settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum; - StateGap.Value = _settings.StateGap; - SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb"; + MemStateGapDividerNumeric.Maximum = Statable.SaveStateBinary().Length / 1024 / 2 + 1; + MemStateGapDividerNumeric.Minimum = Statable.SaveStateBinary().Length / 1024 / 16; + MemStateGapDividerNumeric.Value = _settings.MemStateGapDivider < MemStateGapDividerNumeric.Minimum ? + MemStateGapDividerNumeric.Minimum : _settings.MemStateGapDivider; + + FileStateGapNumeric.Value = _settings.FileStateGap; + SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " MB"; CapacityNumeric_ValueChanged(null, null); SaveCapacityNumeric_ValueChanged(null, null); BranchStatesInTasproj.Checked = _settings.BranchStatesInTasproj; @@ -54,8 +59,9 @@ private void OkBtn_Click(object sender, EventArgs e) { _settings.Capacitymb = (int)MemCapacityNumeric.Value; _settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value; - _settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value; - _settings.StateGap = (int)StateGap.Value; + _settings.DiskSaveCapacitymb = (int)FileCapacityNumeric.Value; + _settings.MemStateGapDivider = (int)MemStateGapDividerNumeric.Value; + _settings.FileStateGap = (int)FileStateGapNumeric.Value; DialogResult = DialogResult.OK; Close(); } @@ -75,7 +81,7 @@ private void CapacityNumeric_ValueChanged(object sender, EventArgs e) private void SaveCapacityNumeric_ValueChanged(object sender, EventArgs e) { - NumSaveStatesLabel.Text = ((int)Math.Floor(SaveCapacityNumeric.Value / _stateSizeMb)).ToString(); + NumSaveStatesLabel.Text = ((int)Math.Floor(FileCapacityNumeric.Value / _stateSizeMb)).ToString(); } private void BranchStatesInTasproj_CheckedChanged(object sender, EventArgs e) @@ -88,11 +94,23 @@ private void EraseBranchStatesFIrst_CheckedChanged(object sender, EventArgs e) _settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked; } - private void StateGap_ValueChanged(object sender, EventArgs e) + private void FileStateGap_ValueChanged(object sender, EventArgs e) { - NumFramesLabel.Text = StateGap.Value == 0 + FileNumFramesLabel.Text = FileStateGapNumeric.Value == 0 + ? "frame" + : $"{1 << (int)FileStateGapNumeric.Value} frames"; + } + + private void MemStateGapDivider_ValueChanged(object sender, EventArgs e) + { + int val = (int)(Statable.SaveStateBinary().Length / MemStateGapDividerNumeric.Value / 1024); + + if (val <= 1) + MemStateGapDividerNumeric.Maximum = MemStateGapDividerNumeric.Value; + + MemFramesLabel.Text = val <= 1 ? "frame" - : $"{1 << (int)StateGap.Value} frames"; + : $"{val} frames"; } } }