minor refactoring of IController handling of control updates / frame tracking / movies

This commit is contained in:
beirich 2011-02-05 05:40:19 +00:00
parent 78c7a74a0d
commit 1d00b7fe6b
7 changed files with 34 additions and 52 deletions

View File

@ -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);

View File

@ -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?
The Castle Dies, mapper issue
Othello Doesnt boot
Terebi Oekaki Req Graphic Board peripheral

View File

@ -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)

View File

@ -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; } }
}
}

View File

@ -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; }

View File

@ -23,6 +23,6 @@ namespace BizHawk
void UnpressButton(string button);
void ForceButton(string button);
int FrameNumber { get; set; }
void UpdateControls(int frame);
}
}

View File

@ -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)
{