From 0246c952ebb58a6a0bb9aff1146f71d760a68560 Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 28 Aug 2016 01:08:43 +0300 Subject: [PATCH 01/11] tastudio: complete overhaul of seek logic, replicating taseditor todo: fix lastpositionframe dying if editing the same row twice with no autorestore, probably improve cursor color and rename old seek related vars --- BizHawk.Client.EmuHawk/MainForm.Hotkey.cs | 4 -- BizHawk.Client.EmuHawk/MainForm.cs | 12 +++- .../tools/TAStudio/PlaybackBox.cs | 2 - .../tools/TAStudio/TAStudio.IToolForm.cs | 1 - .../tools/TAStudio/TAStudio.ListView.cs | 65 +++++++++++-------- .../tools/TAStudio/TAStudio.cs | 11 +++- 6 files changed, 55 insertions(+), 40 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index fd361818c8..c5fd91a6c2 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -14,10 +14,6 @@ namespace BizHawk.Client.EmuHawk // General case "Pause": - // check this here since TogglePause() has no idea who triggered it - // and we need to treat pause hotkey specially in tastudio - if (GlobalWin.MainForm.EmulatorPaused && GlobalWin.Tools.IsLoaded()) - GlobalWin.Tools.TAStudio.IgnoreSeekFrame = true; TogglePause(); break; case "Toggle Throttle": diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index f5a8fbf3f7..4729fc9c37 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2687,8 +2687,6 @@ namespace BizHawk.Client.EmuHawk runFrame = true; _runloopFrameadvance = true; _frameAdvanceTimestamp = currentTimestamp; - if (GlobalWin.Tools.IsLoaded()) - GlobalWin.Tools.TAStudio.IgnoreSeekFrame = false; } else { @@ -2864,6 +2862,16 @@ namespace BizHawk.Client.EmuHawk UpdateToolsAfter(); } + if (GlobalWin.Tools.IsLoaded() && + GlobalWin.Tools.TAStudio.LastPositionFrame == Global.Emulator.Frame) + { + TasMovieRecord record = (Global.MovieSession.Movie as TasMovie)[Global.Emulator.Frame]; + if (!record.Lagged.HasValue && IsSeeking) + // haven't yet greenzoned the frame, hence it's after editing + // then we want to pause here. taseditor fasion + PauseEmulator(); + } + if (IsSeeking && Global.Emulator.Frame == PauseOnFrame.Value) { PauseEmulator(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs index 915484a313..1be21f7c95 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs @@ -136,8 +136,6 @@ namespace BizHawk.Client.EmuHawk private void PauseButton_Click(object sender, EventArgs e) { - if (GlobalWin.MainForm.EmulatorPaused) - Tastudio.IgnoreSeekFrame = true; Tastudio.TogglePause(); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index a9cc1f74eb..9b848f5069 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -100,7 +100,6 @@ namespace BizHawk.Client.EmuHawk return true; } - IgnoreSeekFrame = false; // don't unpause StopSeeking(); if (CurrentTasMovie != null && CurrentTasMovie.Changes) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 810ef6c8e3..ba73876e90 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -68,11 +68,10 @@ namespace BizHawk.Client.EmuHawk } GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame); - StartSeeking(_autoRestoreFrame, true); } } - private void StartSeeking(int? frame, bool pause = false) + private void StartSeeking(int? frame) { if (!frame.HasValue) return; @@ -81,10 +80,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.MainForm.PauseOnFrame = frame.Value; int? diff = GlobalWin.MainForm.PauseOnFrame - _seekStartFrame; - if (pause) - GlobalWin.MainForm.PauseEmulator(); - else - GlobalWin.MainForm.UnpauseEmulator(); + GlobalWin.MainForm.UnpauseEmulator(); if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows) _seekBackgroundWorker.RunWorkerAsync(); @@ -98,11 +94,6 @@ namespace BizHawk.Client.EmuHawk TastudioRecordMode(); _wasRecording = false; } - if (IgnoreSeekFrame) - { - GlobalWin.MainForm.UnpauseEmulator(); - IgnoreSeekFrame = false; - } } public bool FloatEditingMode @@ -171,7 +162,7 @@ namespace BizHawk.Client.EmuHawk ts_v_arrow_blue : ts_h_arrow_blue; } - else if (index == GlobalWin.MainForm.PauseOnFrame) + else if (index == LastPositionFrame) { bitmap = TasView.HorizontalOrientation ? ts_v_arrow_green : @@ -226,7 +217,15 @@ namespace BizHawk.Client.EmuHawk int player = Global.Emulator.ControllerDefinition.PlayerNumber(columnName); if (player != 0 && player % 2 == 0) color = Color.FromArgb(0x0D000000); + + if (GlobalWin.MainForm.IsSeeking && + GlobalWin.MainForm.PauseOnFrame == index && + columnName != CursorColumnName) + { + color = Color.FromArgb(unchecked((int)0x70B5E7F7)); + } } + private void TasView_QueryRowBkColor(int index, ref Color color) { TasMovieRecord record = CurrentTasMovie[index]; @@ -405,8 +404,17 @@ namespace BizHawk.Client.EmuHawk if (e.Button == MouseButtons.Middle) { if (GlobalWin.MainForm.EmulatorPaused) - IgnoreSeekFrame = false; - TogglePause(); + { + TasMovieRecord record = CurrentTasMovie[LastPositionFrame]; + if (!record.Lagged.HasValue && LastPositionFrame > Global.Emulator.Frame) + StartSeeking(LastPositionFrame); + else + GlobalWin.MainForm.UnpauseEmulator(); + } + else + { + GlobalWin.MainForm.PauseEmulator(); + } return; } @@ -420,6 +428,7 @@ namespace BizHawk.Client.EmuHawk if (e.Button == MouseButtons.Left) { + bool wasHeld = _leftButtonHeld; _leftButtonHeld = true; // SuuperW: Exit float editing mode, or re-enter mouse editing if (_floatEditRow != -1) @@ -460,6 +469,10 @@ namespace BizHawk.Client.EmuHawk else // User changed input { bool wasPaused = GlobalWin.MainForm.EmulatorPaused; + + if (wasPaused && !GlobalWin.MainForm.IsSeeking) + LastPositionFrame = Emulator.Frame; + if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName)) { CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame); @@ -534,9 +547,6 @@ namespace BizHawk.Client.EmuHawk // taseditor behavior if (!wasPaused) GlobalWin.MainForm.UnpauseEmulator(); - - if (!Settings.AutoRestoreLastPosition) - IgnoreSeekFrame = true; } } else if (e.Button == System.Windows.Forms.MouseButtons.Right) @@ -653,20 +663,19 @@ namespace BizHawk.Client.EmuHawk { _supressContextMenu = true; int notch = e.Delta / 120; + if (notch > 1) + notch *= 2; - if (GlobalWin.MainForm.IsSeeking) + if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) { - if (e.Delta < 0) - GlobalWin.MainForm.PauseOnFrame++; - else + GlobalWin.MainForm.PauseOnFrame -= notch; + // that's a weird condition here, but for whatever reason it works best + if (notch > 0 && Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) { - GlobalWin.MainForm.PauseOnFrame--; - if (Global.Emulator.Frame == GlobalWin.MainForm.PauseOnFrame) - { - GlobalWin.MainForm.PauseEmulator(); - GlobalWin.MainForm.PauseOnFrame = null; - StopSeeking(); - } + GlobalWin.MainForm.PauseEmulator(); + GlobalWin.MainForm.PauseOnFrame = null; + StopSeeking(); + GoToFrame(Emulator.Frame - notch); } RefreshDialog(); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 27267f404d..305aceb5d4 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -50,7 +50,6 @@ namespace BizHawk.Client.EmuHawk } public bool IsInMenuLoop { get; private set; } - public bool IgnoreSeekFrame { get; set; } [ConfigPersist] public TAStudioSettings Settings { get; set; } @@ -111,6 +110,13 @@ namespace BizHawk.Client.EmuHawk get { return Global.MovieSession.Movie as TasMovie; } } + /// + /// Separates "restore last position" logic from seeking caused by navigation. + /// TASEditor never kills LastPositionFrame, and it only pauses on it, + /// if it hasn't been greenzoned beforehand and middle mouse button was pressed + /// + public int LastPositionFrame { get; set; } + #region "Initializing" public TAStudio() @@ -158,7 +164,7 @@ namespace BizHawk.Client.EmuHawk TasView.PointedCellChanged += TasView_PointedCellChanged; TasView.MultiSelect = true; TasView.MaxCharactersInHorizontal = 1; - IgnoreSeekFrame = false; + LastPositionFrame = -1; } private void AutosaveTimerEventProcessor(object sender, EventArgs e) @@ -795,7 +801,6 @@ namespace BizHawk.Client.EmuHawk if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value) { // this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses - IgnoreSeekFrame = true; GlobalWin.MainForm.UnpauseEmulator(); } _autoRestorePaused = null; From 4f2468228936108f9d86b2226c16d53ad3d01f8d Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 28 Aug 2016 15:34:18 +0300 Subject: [PATCH 02/11] taseditor: fix LastPositionFrame resets --- BizHawk.Client.Common/movie/tasproj/TasMovie.cs | 17 ++++++++++++----- .../tools/TAStudio/TAStudio.ListView.cs | 10 ++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index 1bec1774b1..aa2037a39c 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -85,6 +85,7 @@ namespace BizHawk.Client.Common public TasMovieMarkerList Markers { get; set; } public bool BindMarkersToInput { get; set; } public bool UseInputCache { get; set; } + public bool LastPositionStable = true; public string NewBranchText = ""; public int CurrentBranch { get; set; } public int BranchCount { get { return Branches.Count; } } @@ -310,12 +311,18 @@ namespace BizHawk.Client.Common public void GreenzoneCurrentFrame() { - LagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame; + if (Global.Emulator.Frame > LastValidFrame) + { + // emulated a new frame, current editing segment may change now. taseditor logic + LastPositionStable = false; + } - if (!StateManager.HasState(Global.Emulator.Frame)) - { - StateManager.Capture(); - } + LagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame; + + if (!StateManager.HasState(Global.Emulator.Frame)) + { + StateManager.Capture(); + } } public void ClearLagLog() diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index ba73876e90..d769797c63 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -470,8 +470,14 @@ namespace BizHawk.Client.EmuHawk { bool wasPaused = GlobalWin.MainForm.EmulatorPaused; - if (wasPaused && !GlobalWin.MainForm.IsSeeking) - LastPositionFrame = Emulator.Frame; + if (Emulator.Frame > frame || CurrentTasMovie.LastValidFrame > frame) + { + if (wasPaused && !GlobalWin.MainForm.IsSeeking && !CurrentTasMovie.LastPositionStable) + { + LastPositionFrame = Emulator.Frame; + CurrentTasMovie.LastPositionStable = true; // until new frame is emulated + } + } if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName)) { From 670501163b21ba2ba44b5f25cb0daf0551b6da3c Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 28 Aug 2016 17:13:14 +0300 Subject: [PATCH 03/11] tastudio: - rewind hotkey works like wheelup+RMB - < > buttons fire instantly but can't be held yet - prettify cursor colors --- .../tools/TAStudio/PlaybackBox.Designer.cs | 4 +-- .../tools/TAStudio/PlaybackBox.cs | 26 ++++++++++++++-- .../TAStudio/TAStudio.IControlMainForm.cs | 30 ++++++++++--------- .../tools/TAStudio/TAStudio.ListView.cs | 16 +++++----- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs index 315e2f2284..4a2d335959 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs @@ -126,7 +126,7 @@ this.FrameAdvanceButton.TabIndex = 3; this.FrameAdvanceButton.Text = ">"; this.FrameAdvanceButton.UseVisualStyleBackColor = true; - this.FrameAdvanceButton.Click += new System.EventHandler(this.FrameAdvanceButton_Click); + this.FrameAdvanceButton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FrameAdvanceButton_MouseDown); // // PauseButton // @@ -148,7 +148,7 @@ this.RewindButton.TabIndex = 1; this.RewindButton.Text = "<"; this.RewindButton.UseVisualStyleBackColor = true; - this.RewindButton.Click += new System.EventHandler(this.RewindButton_Click); + this.RewindButton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RewindButton_MouseDown); // // PreviousMarkerButton // diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs index 1be21f7c95..5fff881a94 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs @@ -117,14 +117,16 @@ namespace BizHawk.Client.EmuHawk private void RewindButton_Click(object sender, EventArgs e) { - if (GlobalWin.MainForm.IsSeeking) + if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) { GlobalWin.MainForm.PauseOnFrame--; - if (Global.Emulator.Frame == GlobalWin.MainForm.PauseOnFrame) + // that's a weird condition here, but for whatever reason it works best + if (Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) { GlobalWin.MainForm.PauseEmulator(); GlobalWin.MainForm.PauseOnFrame = null; Tastudio.StopSeeking(); + Tastudio.GoToPreviousFrame(); } Tastudio.RefreshDialog(); } @@ -141,9 +143,17 @@ namespace BizHawk.Client.EmuHawk private void FrameAdvanceButton_Click(object sender, EventArgs e) { - if (GlobalWin.MainForm.IsSeeking) + if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) { GlobalWin.MainForm.PauseOnFrame++; + // that's a weird condition here, but for whatever reason it works best + if (Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) + { + GlobalWin.MainForm.PauseEmulator(); + GlobalWin.MainForm.PauseOnFrame = null; + Tastudio.StopSeeking(); + Tastudio.GoToNextFrame(); + } Tastudio.RefreshDialog(); } else @@ -191,5 +201,15 @@ namespace BizHawk.Client.EmuHawk { RecordingMode ^= true; } + + private void RewindButton_MouseDown(object sender, MouseEventArgs e) + { + RewindButton_Click(sender, e); + } + + private void FrameAdvanceButton_MouseDown(object sender, MouseEventArgs e) + { + FrameAdvanceButton_Click(sender, e); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs index 0b0605edb3..31cbf2dadc 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs @@ -78,21 +78,23 @@ namespace BizHawk.Client.EmuHawk public bool Rewind() { - //if (GlobalWin.MainForm.IsSeeking) - //{ - // GlobalWin.MainForm.PauseOnFrame--; - // if (Emulator.Frame == GlobalWin.MainForm.PauseOnFrame) - // { - // GlobalWin.MainForm.PauseEmulator(); - // GlobalWin.MainForm.PauseOnFrame = null; - // StopSeeking(); - // } - // RefreshDialog(); - //} - //else - //{ + if (GlobalWin.MainForm.IsSeeking) + { + GlobalWin.MainForm.PauseOnFrame--; + // that's a weird condition here, but for whatever reason it works best + if (Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) + { + GlobalWin.MainForm.PauseEmulator(); + GlobalWin.MainForm.PauseOnFrame = null; + StopSeeking(); + GoToPreviousFrame(); + } + RefreshDialog(); + } + else + { GoToPreviousFrame(); - //} + } return true; } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index d769797c63..08eddc6d41 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -102,7 +102,8 @@ namespace BizHawk.Client.EmuHawk } // public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why? - public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7); + public static Color CurrentFrame_InputLog = Color.FromArgb(0x00B5E7F7); + public static Color SeekFrame_InputLog = Color.FromArgb(0x70B5E7F7); public static Color GreenZone_FrameCol = Color.FromArgb(0xDDFFDD); public static Color GreenZone_InputLog = Color.FromArgb(0xD2F9D3); @@ -217,20 +218,17 @@ namespace BizHawk.Client.EmuHawk int player = Global.Emulator.ControllerDefinition.PlayerNumber(columnName); if (player != 0 && player % 2 == 0) color = Color.FromArgb(0x0D000000); - - if (GlobalWin.MainForm.IsSeeking && - GlobalWin.MainForm.PauseOnFrame == index && - columnName != CursorColumnName) - { - color = Color.FromArgb(unchecked((int)0x70B5E7F7)); - } } private void TasView_QueryRowBkColor(int index, ref Color color) { TasMovieRecord record = CurrentTasMovie[index]; - if (Emulator.Frame == index) + if (GlobalWin.MainForm.IsSeeking && GlobalWin.MainForm.PauseOnFrame == index) + { + color = CurrentFrame_InputLog; + } + else if (!GlobalWin.MainForm.IsSeeking && Emulator.Frame == index) { color = CurrentFrame_InputLog; } From 2b0dc82d166baaf137287652b8f428a95f69f72d Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 28 Aug 2016 18:42:59 +0300 Subject: [PATCH 04/11] tastudio: finally make < > buttons operate identically to advance/rewind hotkeys --- BizHawk.Client.EmuHawk/MainForm.cs | 7 +- .../tools/TAStudio/PlaybackBox.Designer.cs | 4 ++ .../tools/TAStudio/PlaybackBox.cs | 68 +++++++------------ .../TAStudio/TAStudio.IControlMainForm.cs | 1 + .../tools/TAStudio/TAStudio.ListView.cs | 1 + 5 files changed, 34 insertions(+), 47 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 4729fc9c37..582c2bb2f1 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -607,7 +607,8 @@ namespace BizHawk.Client.EmuHawk public LoadRomArgs CurrentlyOpenRomArgs; public bool PauseAVI = false; public bool PressFrameAdvance = false; - public bool PressRewind = false; + public bool HoldFrameAdvance = false; // necessary for tastudio > button + public bool PressRewind = false; // necessary for tastudio < button public bool FastForward = false; public bool TurboFastForward = false; public bool RestoreReadWriteOnStop = false; @@ -2678,7 +2679,7 @@ namespace BizHawk.Client.EmuHawk runFrame = true; } - if (Global.ClientControls["Frame Advance"] || PressFrameAdvance) + if (Global.ClientControls["Frame Advance"] || PressFrameAdvance || HoldFrameAdvance) { // handle the initial trigger of a frame advance if (_frameAdvanceTimestamp == 0) @@ -2890,7 +2891,7 @@ namespace BizHawk.Client.EmuHawk if (Global.ClientControls["Rewind"] || PressRewind) { UpdateToolsAfter(); - PressRewind = false; + //PressRewind = false; } if (UpdateFrame) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs index 4a2d335959..dade7783ff 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.Designer.cs @@ -127,6 +127,8 @@ this.FrameAdvanceButton.Text = ">"; this.FrameAdvanceButton.UseVisualStyleBackColor = true; this.FrameAdvanceButton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FrameAdvanceButton_MouseDown); + this.FrameAdvanceButton.MouseLeave += new System.EventHandler(this.FrameAdvanceButton_MouseLeave); + this.FrameAdvanceButton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FrameAdvanceButton_MouseUp); // // PauseButton // @@ -149,6 +151,8 @@ this.RewindButton.Text = "<"; this.RewindButton.UseVisualStyleBackColor = true; this.RewindButton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RewindButton_MouseDown); + this.RewindButton.MouseLeave += new System.EventHandler(this.RewindButton_MouseLeave); + this.RewindButton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.RewindButton_MouseUp); // // PreviousMarkerButton // diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs index 5fff881a94..82c3d9cf39 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs @@ -115,53 +115,11 @@ namespace BizHawk.Client.EmuHawk Tastudio.GoToPreviousMarker(); } - private void RewindButton_Click(object sender, EventArgs e) - { - if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) - { - GlobalWin.MainForm.PauseOnFrame--; - // that's a weird condition here, but for whatever reason it works best - if (Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) - { - GlobalWin.MainForm.PauseEmulator(); - GlobalWin.MainForm.PauseOnFrame = null; - Tastudio.StopSeeking(); - Tastudio.GoToPreviousFrame(); - } - Tastudio.RefreshDialog(); - } - else - { - Tastudio.GoToPreviousFrame(); - } - } - private void PauseButton_Click(object sender, EventArgs e) { Tastudio.TogglePause(); } - private void FrameAdvanceButton_Click(object sender, EventArgs e) - { - if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) - { - GlobalWin.MainForm.PauseOnFrame++; - // that's a weird condition here, but for whatever reason it works best - if (Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) - { - GlobalWin.MainForm.PauseEmulator(); - GlobalWin.MainForm.PauseOnFrame = null; - Tastudio.StopSeeking(); - Tastudio.GoToNextFrame(); - } - Tastudio.RefreshDialog(); - } - else - { - Tastudio.GoToNextFrame(); - } - } - private void NextMarkerButton_Click(object sender, EventArgs e) { Tastudio.GoToNextMarker(); @@ -204,12 +162,34 @@ namespace BizHawk.Client.EmuHawk private void RewindButton_MouseDown(object sender, MouseEventArgs e) { - RewindButton_Click(sender, e); + GlobalWin.MainForm.PressRewind = true; + } + + private void RewindButton_MouseUp(object sender, MouseEventArgs e) + { + GlobalWin.MainForm.PressRewind = false; + } + + private void RewindButton_MouseLeave(object sender, EventArgs e) + { + GlobalWin.MainForm.PressRewind = false; } private void FrameAdvanceButton_MouseDown(object sender, MouseEventArgs e) { - FrameAdvanceButton_Click(sender, e); + GlobalWin.MainForm.HoldFrameAdvance = true; } + + private void FrameAdvanceButton_MouseLeave(object sender, EventArgs e) + { + GlobalWin.MainForm.HoldFrameAdvance = false; + } + + private void FrameAdvanceButton_MouseUp(object sender, MouseEventArgs e) + { + GlobalWin.MainForm.HoldFrameAdvance = false; + } + + } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs index 31cbf2dadc..892ea86cfe 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs @@ -78,6 +78,7 @@ namespace BizHawk.Client.EmuHawk public bool Rewind() { + // copypasted from TasView_MouseWheel(), just without notch logic if (GlobalWin.MainForm.IsSeeking) { GlobalWin.MainForm.PauseOnFrame--; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 08eddc6d41..b5b066aebf 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -670,6 +670,7 @@ namespace BizHawk.Client.EmuHawk if (notch > 1) notch *= 2; + // warning: tastudio rewind hotket/button logic is copypasted from here! if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) { GlobalWin.MainForm.PauseOnFrame -= notch; From 11b4f5a5b10413d4e4a153d3a2ad7ae67c9ff23c Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 28 Aug 2016 12:07:26 -0400 Subject: [PATCH 05/11] Lua - fix #691 - When calling client.reboot_core we still want to re-inject dependencies to the lua libraries --- .../tools/Lua/Libraries/EmuLuaLibrary.cs | 8 ++++++++ BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 7 +++++++ BizHawk.Client.EmuHawk/tools/ToolManager.cs | 6 +----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs index e23924fc39..b28f720227 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs @@ -94,6 +94,14 @@ namespace BizHawk.Client.EmuHawk EmulatorLuaLibrary.YieldCallback = EmuYield; } + public void Restart() + { + foreach (var lib in Libraries) + { + ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, lib.Value); + } + } + public LuaDocumentation Docs { get; private set; } public bool IsRunning { get; set; } public EventWaitHandle LuaWait { get; private set; } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index ac8482ffff..c5471b4e7e 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -135,6 +135,13 @@ namespace BizHawk.Client.EmuHawk public void Restart() { + // Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies + if (IsRebootingCore) + { + LuaImp.Restart(); + return; + } + if (LuaImp != null && LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface) { LuaImp.GuiLibrary.DrawFinish(); diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index fc7de1142c..6749e2d55c 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -456,12 +456,8 @@ namespace BizHawk.Client.EmuHawk if (ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool.GetType())) { ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, tool); - bool restartTool = false; + if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch) // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic - restartTool = true; - if (tool is LuaConsole && ((LuaConsole)tool).IsRebootingCore) - restartTool = false; - if (restartTool) { tool.Restart(); } From 1b2f24502f0628613d6ff187b433cfa95b04d065 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 29 Aug 2016 10:21:30 -0400 Subject: [PATCH 06/11] fix when importing .fm2 and other "legacy" imports, add the .bk2 extension instead of replacing the old move with its old extension --- BizHawk.Client.Common/movie/import/MovieImport.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index 94059338f6..2bed3b7826 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -199,6 +199,8 @@ namespace BizHawk.Client.Common errorMsg = except.ToString(); } + m.Filename += "." + BkmMovie.Extension; + return m; } From 812221cfdfd255295341d9152f139b84587ffad3 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Mon, 29 Aug 2016 10:32:24 -0400 Subject: [PATCH 07/11] Fixes Flintstones Rescue of Dino and Hoppy Simple registry write error now fixed --- .../Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs index eb0da2a162..c770bef585 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs @@ -57,9 +57,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (delay > 0) { + delay--; - if(delay==0) + if(delay==0 && irq_pending) board.IRQSignal = true; + } } } @@ -187,11 +189,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; case 0x4002: if (!pal16) break; - mmc3.WritePRG(0x6000, value); + mmc3.WritePRG(0x6001, value); break; case 0x4003: if (!pal16) break; - mmc3.WritePRG(0x6001, value); + mmc3.WritePRG(0x6000, value); break; case 0x6000: From 05feca4e4ea1719f52a116d8319e40809aa356e7 Mon Sep 17 00:00:00 2001 From: feos Date: Mon, 29 Aug 2016 19:38:36 +0300 Subject: [PATCH 08/11] tastudio: GlobalWin.MainForm alias almost 100 cases of usage is worth it make "recent rom not found" window topmost --- .../Extensions/ToolExtensions.cs | 3 +- .../TAStudio/TAStudio.IControlMainForm.cs | 10 ++-- .../tools/TAStudio/TAStudio.ListView.cs | 42 ++++++++-------- .../tools/TAStudio/TAStudio.MenuItems.cs | 48 +++++++++---------- .../tools/TAStudio/TAStudio.Navigation.cs | 6 +-- .../tools/TAStudio/TAStudio.cs | 35 ++++++++------ 6 files changed, 75 insertions(+), 69 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs index be6f7dc225..5f9d3d4832 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs @@ -221,7 +221,8 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions } else { - var result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); + // ensure topmost, not to have to minimize everything to see and use our modal window, if it somehow got covered + var result = MessageBox.Show(new Form(){TopMost = true},"Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { if (encodedPath != null) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs index 892ea86cfe..2ecc788c54 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs @@ -79,14 +79,14 @@ namespace BizHawk.Client.EmuHawk public bool Rewind() { // copypasted from TasView_MouseWheel(), just without notch logic - if (GlobalWin.MainForm.IsSeeking) + if (Mainform.IsSeeking) { - GlobalWin.MainForm.PauseOnFrame--; + Mainform.PauseOnFrame--; // that's a weird condition here, but for whatever reason it works best - if (Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) + if (Emulator.Frame >= Mainform.PauseOnFrame) { - GlobalWin.MainForm.PauseEmulator(); - GlobalWin.MainForm.PauseOnFrame = null; + Mainform.PauseEmulator(); + Mainform.PauseOnFrame = null; StopSeeking(); GoToPreviousFrame(); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index b5b066aebf..d1b35b139e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -62,9 +62,9 @@ namespace BizHawk.Client.EmuHawk { if (_autoRestorePaused == null) { - _autoRestorePaused = GlobalWin.MainForm.EmulatorPaused; - if (GlobalWin.MainForm.IsSeeking) // If seeking, do not shorten seek. - _autoRestoreFrame = GlobalWin.MainForm.PauseOnFrame; + _autoRestorePaused = Mainform.EmulatorPaused; + if (Mainform.IsSeeking) // If seeking, do not shorten seek. + _autoRestoreFrame = Mainform.PauseOnFrame; } GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame); @@ -77,10 +77,10 @@ namespace BizHawk.Client.EmuHawk return; _seekStartFrame = Emulator.Frame; - GlobalWin.MainForm.PauseOnFrame = frame.Value; - int? diff = GlobalWin.MainForm.PauseOnFrame - _seekStartFrame; + Mainform.PauseOnFrame = frame.Value; + int? diff = Mainform.PauseOnFrame - _seekStartFrame; - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows) _seekBackgroundWorker.RunWorkerAsync(); @@ -151,7 +151,7 @@ namespace BizHawk.Client.EmuHawk if (columnName == CursorColumnName) { - if (index == Emulator.Frame && index == GlobalWin.MainForm.PauseOnFrame) + if (index == Emulator.Frame && index == Mainform.PauseOnFrame) { bitmap = TasView.HorizontalOrientation ? ts_v_arrow_green_blue : @@ -224,11 +224,11 @@ namespace BizHawk.Client.EmuHawk { TasMovieRecord record = CurrentTasMovie[index]; - if (GlobalWin.MainForm.IsSeeking && GlobalWin.MainForm.PauseOnFrame == index) + if (Mainform.IsSeeking && Mainform.PauseOnFrame == index) { color = CurrentFrame_InputLog; } - else if (!GlobalWin.MainForm.IsSeeking && Emulator.Frame == index) + else if (!Mainform.IsSeeking && Emulator.Frame == index) { color = CurrentFrame_InputLog; } @@ -401,17 +401,17 @@ namespace BizHawk.Client.EmuHawk if (e.Button == MouseButtons.Middle) { - if (GlobalWin.MainForm.EmulatorPaused) + if (Mainform.EmulatorPaused) { TasMovieRecord record = CurrentTasMovie[LastPositionFrame]; if (!record.Lagged.HasValue && LastPositionFrame > Global.Emulator.Frame) StartSeeking(LastPositionFrame); else - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } else { - GlobalWin.MainForm.PauseEmulator(); + Mainform.PauseEmulator(); } return; } @@ -466,11 +466,11 @@ namespace BizHawk.Client.EmuHawk } else // User changed input { - bool wasPaused = GlobalWin.MainForm.EmulatorPaused; + bool wasPaused = Mainform.EmulatorPaused; if (Emulator.Frame > frame || CurrentTasMovie.LastValidFrame > frame) { - if (wasPaused && !GlobalWin.MainForm.IsSeeking && !CurrentTasMovie.LastPositionStable) + if (wasPaused && !Mainform.IsSeeking && !CurrentTasMovie.LastPositionStable) { LastPositionFrame = Emulator.Frame; CurrentTasMovie.LastPositionStable = true; // until new frame is emulated @@ -550,7 +550,7 @@ namespace BizHawk.Client.EmuHawk // taseditor behavior if (!wasPaused) - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else if (e.Button == System.Windows.Forms.MouseButtons.Right) @@ -670,15 +670,15 @@ namespace BizHawk.Client.EmuHawk if (notch > 1) notch *= 2; - // warning: tastudio rewind hotket/button logic is copypasted from here! - if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused) + // warning: tastudio rewind hotkey/button logic is copypasted from here! + if (Mainform.IsSeeking && !Mainform.EmulatorPaused) { - GlobalWin.MainForm.PauseOnFrame -= notch; + Mainform.PauseOnFrame -= notch; // that's a weird condition here, but for whatever reason it works best - if (notch > 0 && Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame) + if (notch > 0 && Global.Emulator.Frame >= Mainform.PauseOnFrame) { - GlobalWin.MainForm.PauseEmulator(); - GlobalWin.MainForm.PauseOnFrame = null; + Mainform.PauseEmulator(); + Mainform.PauseOnFrame = null; StopSeeking(); GoToFrame(Emulator.Frame - notch); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 9957ac3051..1bd8be02f4 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk private void NewTasMenuItem_Click(object sender, EventArgs e) { - if (GlobalWin.MainForm.GameIsClosing) + if (Mainform.GameIsClosing) { Close(); } @@ -387,7 +387,7 @@ namespace BizHawk.Client.EmuHawk // TODO: if highlighting 2 rows and pasting 3, only paste 2 of them // FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs - var wasPaused = GlobalWin.MainForm.EmulatorPaused; + var wasPaused = Mainform.EmulatorPaused; if (_tasClipboard.Any()) { @@ -404,7 +404,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -416,7 +416,7 @@ namespace BizHawk.Client.EmuHawk private void PasteInsertMenuItem_Click(object sender, EventArgs e) { - var wasPaused = GlobalWin.MainForm.EmulatorPaused; + var wasPaused = Mainform.EmulatorPaused; if (_tasClipboard.Any()) { @@ -433,7 +433,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -447,7 +447,7 @@ namespace BizHawk.Client.EmuHawk { if (TasView.AnyRowsSelected) { - var wasPaused = GlobalWin.MainForm.EmulatorPaused; + var wasPaused = Mainform.EmulatorPaused; var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; var rollBackFrame = TasView.FirstSelectedIndex.Value; @@ -480,7 +480,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -494,7 +494,7 @@ namespace BizHawk.Client.EmuHawk { if (TasView.AnyRowsSelected) { - bool wasPaused = GlobalWin.MainForm.EmulatorPaused; + bool wasPaused = Mainform.EmulatorPaused; bool needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame); int rollBackFrame = TasView.FirstSelectedIndex.Value; @@ -514,7 +514,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -528,7 +528,7 @@ namespace BizHawk.Client.EmuHawk { if (TasView.AnyRowsSelected) { - var wasPaused = GlobalWin.MainForm.EmulatorPaused; + var wasPaused = Mainform.EmulatorPaused; var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; var rollBackFrame = TasView.FirstSelectedIndex.Value; if (rollBackFrame >= CurrentTasMovie.InputLogLength) @@ -549,7 +549,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -563,7 +563,7 @@ namespace BizHawk.Client.EmuHawk { if (TasView.AnyRowsSelected) { - var wasPaused = GlobalWin.MainForm.EmulatorPaused; + var wasPaused = Mainform.EmulatorPaused; var framesToInsert = TasView.SelectedRows.ToList(); var insertionFrame = Math.Min(TasView.LastSelectedIndex.Value + 1, CurrentTasMovie.InputLogLength); var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; @@ -583,7 +583,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -595,7 +595,7 @@ namespace BizHawk.Client.EmuHawk private void InsertFrameMenuItem_Click(object sender, EventArgs e) { - var wasPaused = GlobalWin.MainForm.EmulatorPaused; + var wasPaused = Mainform.EmulatorPaused; var insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0; var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; @@ -610,7 +610,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -621,7 +621,7 @@ namespace BizHawk.Client.EmuHawk private void InsertNumFramesMenuItem_Click(object sender, EventArgs e) { - bool wasPaused = GlobalWin.MainForm.EmulatorPaused; + bool wasPaused = Mainform.EmulatorPaused; int insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0; bool needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame; @@ -641,7 +641,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } } else @@ -720,7 +720,7 @@ namespace BizHawk.Client.EmuHawk int goToFrame = CurrentTasMovie.TasStateManager.LastEmulatedFrame; do { - GlobalWin.MainForm.FrameAdvance(); + Mainform.FrameAdvance(); if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame)) { @@ -936,7 +936,7 @@ namespace BizHawk.Client.EmuHawk { new MovieHeaderEditor(CurrentTasMovie) { - Owner = GlobalWin.MainForm, + Owner = Mainform, Location = this.ChildPointToScreen(TasView) }.Show(); UpdateChangesIndicator(); @@ -946,7 +946,7 @@ namespace BizHawk.Client.EmuHawk { new StateHistorySettingsForm(CurrentTasMovie.TasStateManager.Settings) { - Owner = GlobalWin.MainForm, + Owner = Mainform, Location = this.ChildPointToScreen(TasView), Statable = this.StatableEmulator }.ShowDialog(); @@ -1231,13 +1231,13 @@ namespace BizHawk.Client.EmuHawk StartFromNowSeparator.Visible =StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible; RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this). - CancelSeekContextMenuItem.Enabled = GlobalWin.MainForm.PauseOnFrame.HasValue; + CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue; BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame; } private void CancelSeekContextMenuItem_Click(object sender, EventArgs e) { - GlobalWin.MainForm.PauseOnFrame = null; + Mainform.PauseOnFrame = null; RefreshTasView(); } @@ -1255,7 +1255,7 @@ namespace BizHawk.Client.EmuHawk TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( index, (byte[])StatableEmulator.SaveStateBinary().Clone()); - GlobalWin.MainForm.PauseEmulator(); + Mainform.PauseEmulator(); LoadFile(new FileInfo(newProject.Filename), true); } } @@ -1270,7 +1270,7 @@ namespace BizHawk.Client.EmuHawk TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie( SaveRamEmulator.CloneSaveRam()); - GlobalWin.MainForm.PauseEmulator(); + Mainform.PauseEmulator(); LoadFile(new FileInfo(newProject.Filename), true); } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index f7186c1239..63232eb129 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -43,10 +43,10 @@ namespace BizHawk.Client.EmuHawk { if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame { - bool wasPaused = GlobalWin.MainForm.EmulatorPaused; - GlobalWin.MainForm.FrameAdvance(); + bool wasPaused = Mainform.EmulatorPaused; + Mainform.FrameAdvance(); if (!wasPaused) - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } else { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 305aceb5d4..453e4bf494 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -110,10 +110,15 @@ namespace BizHawk.Client.EmuHawk get { return Global.MovieSession.Movie as TasMovie; } } + public MainForm Mainform + { + get { return GlobalWin.MainForm; } + } + /// /// Separates "restore last position" logic from seeking caused by navigation. /// TASEditor never kills LastPositionFrame, and it only pauses on it, - /// if it hasn't been greenzoned beforehand and middle mouse button was pressed + /// if it hasn't been greenzoned beforehand and middle mouse button was pressed. /// public int LastPositionFrame { get; set; } @@ -250,7 +255,7 @@ namespace BizHawk.Client.EmuHawk } int diff = Global.Emulator.Frame - _seekStartFrame.Value; - int unit = GlobalWin.MainForm.PauseOnFrame.Value - _seekStartFrame.Value; + int unit = Mainform.PauseOnFrame.Value - _seekStartFrame.Value; double progress = 0; if (diff != 0 && unit != 0) @@ -509,16 +514,16 @@ namespace BizHawk.Client.EmuHawk private void EngageTastudio() { - GlobalWin.MainForm.PauseOnFrame = null; + Mainform.PauseOnFrame = null; GlobalWin.OSD.AddMessage("TAStudio engaged"); SetTasMovieCallbacks(); SetTextProperty(); - GlobalWin.MainForm.PauseEmulator(); - GlobalWin.MainForm.RelinquishControl(this); + Mainform.PauseEmulator(); + Mainform.RelinquishControl(this); _originalEndAction = Global.Config.MovieEndAction; - GlobalWin.MainForm.ClearRewindData(); + Mainform.ClearRewindData(); Global.Config.MovieEndAction = MovieEndAction.Record; - GlobalWin.MainForm.SetMainformMovieInfo(); + Mainform.SetMainformMovieInfo(); Global.MovieSession.ReadOnly = true; } @@ -652,7 +657,7 @@ namespace BizHawk.Client.EmuHawk if (movie == null) movie = CurrentTasMovie; SetTasMovieCallbacks(movie as TasMovie); - bool result = GlobalWin.MainForm.StartNewMovie(movie, record); + bool result = Mainform.StartNewMovie(movie, record); TastudioPlayMode(); _initializing = false; @@ -704,17 +709,17 @@ namespace BizHawk.Client.EmuHawk private void TastudioStopMovie() { Global.MovieSession.StopMovie(false); - GlobalWin.MainForm.SetMainformMovieInfo(); + Mainform.SetMainformMovieInfo(); } private void DisengageTastudio() { - GlobalWin.MainForm.PauseOnFrame = null; + Mainform.PauseOnFrame = null; GlobalWin.OSD.AddMessage("TAStudio disengaged"); Global.MovieSession.Movie = MovieService.DefaultInstance; - GlobalWin.MainForm.TakeBackControl(); + Mainform.TakeBackControl(); Global.Config.MovieEndAction = _originalEndAction; - GlobalWin.MainForm.SetMainformMovieInfo(); + Mainform.SetMainformMovieInfo(); // Do not keep TAStudio's disk save states. //if (Directory.Exists(statesPath)) Directory.Delete(statesPath, true); //TODO - do we need to dispose something here instead? @@ -801,7 +806,7 @@ namespace BizHawk.Client.EmuHawk if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value) { // this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses - GlobalWin.MainForm.UnpauseEmulator(); + Mainform.UnpauseEmulator(); } _autoRestorePaused = null; } @@ -824,7 +829,7 @@ namespace BizHawk.Client.EmuHawk // frame == Emualtor.Frame when frame == 0 if (frame > Emulator.Frame) { - if (GlobalWin.MainForm.EmulatorPaused || GlobalWin.MainForm.IsSeeking) // make seek frame keep up with emulation on fast scrolls + if (Mainform.EmulatorPaused || Mainform.IsSeeking) // make seek frame keep up with emulation on fast scrolls { StartSeeking(frame); } @@ -866,7 +871,7 @@ namespace BizHawk.Client.EmuHawk public void TogglePause() { - GlobalWin.MainForm.TogglePause(); + Mainform.TogglePause(); } private void SetSplicer() From 2911e498e16435f0f607d41e36114fe20c7f5b7c Mon Sep 17 00:00:00 2001 From: feos Date: Mon, 29 Aug 2016 21:18:55 +0300 Subject: [PATCH 09/11] tastudio history: fix bug where undoing the movie extension (caused by drawing beyond the movie length) would swallow all the movie --- BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs index d59a8b82e5..1b00ba1d3c 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -335,6 +335,8 @@ namespace BizHawk.Client.Common var minuend = Math.Min(lastFrame + 1, movie.InputLogLength); if (firstFrame > minuend) undoLength = minuend; + else if (firstFrame == minuend) + undoLength = Math.Max(lastFrame + 1, movie.InputLogLength) - firstFrame; else undoLength = minuend - firstFrame; From 8570b50a4e849efa276b68df99edcb522b7ae60f Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Tue, 30 Aug 2016 10:50:10 -0400 Subject: [PATCH 10/11] Fix Skull and Crossbones --- .../Consoles/Nintendo/NES/Boards/TENGEN-800032.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs index 797f8e1d23..7a59062a2a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs @@ -236,7 +236,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { irq_pending = true; SyncIRQ(); - } + } } } @@ -251,6 +251,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (irq_countdown == 0) { ClockIRQ(); + if (irq_mode==true) + irq_countdown = 12; } } } From 92f2959e436d096704817b39e011995221ce60a1 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Wed, 31 Aug 2016 10:53:15 -0400 Subject: [PATCH 11/11] fix somari --- .../Consoles/Nintendo/NES/Boards/Mapper015.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs index c8d64e94de..389a6d243e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs @@ -44,17 +44,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int mode = addr & 3; int prg_high = value & 0x3F; bool prg_low = value.Bit(7); - int prg_low_val = prg_low ? 1 : 0; + int prg_low_val = 0; + if (mode==2) + prg_low_val = prg_low ? 1 : 0; bool mirror = value.Bit(6); - SetMirrorType(mirror ? EMirrorType.Horizontal : EMirrorType.Vertical); + SetMirrorType(!mirror ? EMirrorType.Horizontal : EMirrorType.Vertical); switch(mode) { case 0: prg_banks_8k[0] = (byte)((prg_high * 2 + 0) ^ prg_low_val); prg_banks_8k[1] = (byte)((prg_high * 2 + 1) ^ prg_low_val); - prg_banks_8k[2] = (byte)((prg_high * 2 + 2) ^ prg_low_val); - prg_banks_8k[3] = (byte)((prg_high * 2 + 3) ^ prg_low_val); + prg_high = prg_high | 0x01; + prg_banks_8k[2] = (byte)((prg_high * 2 + 0) ^ prg_low_val); + prg_banks_8k[3] = (byte)((prg_high * 2 + 1) ^ prg_low_val); break; case 1: prg_banks_8k[0] = (byte)((prg_high*2+0) ^ prg_low_val);