From 1d00b7fe6b0ae3e7eb51fd584f7c4b65df2809e0 Mon Sep 17 00:00:00 2001 From: beirich Date: Sat, 5 Feb 2011 05:40:19 +0000 Subject: [PATCH] minor refactoring of IController handling of control updates / frame tracking / movies --- .../Consoles/PC Engine/PCEngine.cs | 2 +- .../Consoles/Sega/SMS/Compat.txt | 19 ++---------- BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs | 2 +- .../Interfaces/Base Implementations/Movies.cs | 30 ++++++++++--------- .../Base Implementations/NullController.cs | 2 +- BizHawk.Emulation/Interfaces/IController.cs | 2 +- .../Input/ControllerBinding.cs | 29 +++++++----------- 7 files changed, 34 insertions(+), 52 deletions(-) diff --git a/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs index ac91123c47..f89acf7e75 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs @@ -107,7 +107,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx public void FrameAdvance(bool render) { - Controller.FrameNumber = Frame++; + Controller.UpdateControls(Frame++); //Log.Note("CPU","======== FRAME {0} =========",Frame); PSG.BeginFrame(Cpu.TotalExecutedCycles); diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/Compat.txt b/BizHawk.Emulation/Consoles/Sega/SMS/Compat.txt index 1032738c97..4ecee1262c 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/Compat.txt +++ b/BizHawk.Emulation/Consoles/Sega/SMS/Compat.txt @@ -12,19 +12,6 @@ ======= SG-1000 compatibility checklist ======= -Following games are untested (don't have the rom) - - Bomb Jack - C_So! - Champion Kendou - Home Mahjong - Mahjong - Othello - Pachinko - Serizawa Hachidan no Tsumeshogi - Terebi Oekaki - -Following games have issues: - -The Castle dies -Monaco GP graphics are whacked up - wonder if it uses an undoc mode? \ No newline at end of file +The Castle Dies, mapper issue +Othello Doesnt boot +Terebi Oekaki Req Graphic Board peripheral \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs index fbd4e6d56f..6ba39e8fa9 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs @@ -157,7 +157,7 @@ namespace BizHawk.Emulation.Consoles.Sega public void FrameAdvance(bool render) { - Controller.FrameNumber = Frame++; + Controller.UpdateControls(Frame++); PSG.BeginFrame(Cpu.TotalExecutedCycles); if (IsGameGear == false) diff --git a/BizHawk.Emulation/Interfaces/Base Implementations/Movies.cs b/BizHawk.Emulation/Interfaces/Base Implementations/Movies.cs index 14450b7ae0..d738dab819 100644 --- a/BizHawk.Emulation/Interfaces/Base Implementations/Movies.cs +++ b/BizHawk.Emulation/Interfaces/Base Implementations/Movies.cs @@ -49,17 +49,14 @@ namespace BizHawk } private int frame; - public int FrameNumber + + public void UpdateControls(int frame) { - get { return frame; } - set + if (this.frame != frame) { - if (frame != value) - { - frame = value; - RecordFrame(); - } - baseController.FrameNumber = value; + this.frame = frame; + baseController.UpdateControls(frame); + RecordFrame(); } } @@ -92,6 +89,7 @@ namespace BizHawk { private ControllerDefinition def; private int[] input; + private int frame; public InputPlayback(ControllerDefinition controllerDefinition, BinaryReader reader) { @@ -114,19 +112,24 @@ namespace BizHawk public bool IsPressed(string button) { - if (FrameNumber >= input.Length) + if (frame >= input.Length) return false; for (int i = 0; i < def.BoolButtons.Count; i++) { if (def.BoolButtons[i] == button) { - return (input[FrameNumber] & (1 << i)) != 0; + return (input[frame] & (1 << i)) != 0; } } return false; } + public void UpdateControls(int frame) + { + this.frame = frame; + } + public float GetFloat(string name) { throw new System.NotImplementedException(); @@ -136,8 +139,7 @@ namespace BizHawk public void ForceButton(string button) { } public void SetSticky(string button, bool sticky) { } public bool IsSticky(string button) { return false; } - public int FrameNumber { get; set; } - - public bool MovieEnded { get { return FrameNumber >= input.Length; } } + + public bool MovieEnded { get { return frame >= input.Length; } } } } \ No newline at end of file diff --git a/BizHawk.Emulation/Interfaces/Base Implementations/NullController.cs b/BizHawk.Emulation/Interfaces/Base Implementations/NullController.cs index 0c58700773..5630347b93 100644 --- a/BizHawk.Emulation/Interfaces/Base Implementations/NullController.cs +++ b/BizHawk.Emulation/Interfaces/Base Implementations/NullController.cs @@ -6,9 +6,9 @@ public bool this[string button] { get { return false; } } public bool IsPressed(string button) { return false; } public float GetFloat(string name) { return 0f; } + public void UpdateControls(int frame) { } public void UnpressButton(string button) { } public void ForceButton(string button) { } - public int FrameNumber { get; set; } public void SetSticky(string button, bool sticky) { } public bool IsSticky(string button) { return false; } diff --git a/BizHawk.Emulation/Interfaces/IController.cs b/BizHawk.Emulation/Interfaces/IController.cs index 7381f6fdbe..795466f0d9 100644 --- a/BizHawk.Emulation/Interfaces/IController.cs +++ b/BizHawk.Emulation/Interfaces/IController.cs @@ -23,6 +23,6 @@ namespace BizHawk void UnpressButton(string button); void ForceButton(string button); - int FrameNumber { get; set; } + void UpdateControls(int frame); } } diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index 2cdb62798a..72f48ff28f 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -88,25 +88,18 @@ namespace BizHawk.MultiClient } private int frameNumber; - public int FrameNumber - { - get - { - return frameNumber; - } - set - { - if (value != frameNumber) - { - // update - unpressedButtons.RemoveAll(button => IsPressedActually(button) == false); - forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button)); - removeFromForcePressedButtons.Clear(); - } - frameNumber = value; - } - } + public void UpdateControls(int frame) + { + if (frame != frameNumber) + { + // update + unpressedButtons.RemoveAll(button => IsPressedActually(button) == false); + forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button)); + removeFromForcePressedButtons.Clear(); + } + frameNumber = frame; + } public void SetSticky(string button, bool sticky) {