Implement FastUpdate() on IToolForm. The intent here is for tools to do the minimum amount necessary when updating. This allows them to avoid slow things like drawing, but do critical activities such as Ram tools incrementing change counters, and loggers can continue logging. When Turboing, instead of bypassing tool updates, the client will run the fast update instead. Note: a few tools still need to be thought out as to what they need to do in a fast update

This commit is contained in:
adelikat 2014-07-25 01:55:21 +00:00
parent c82db1384f
commit 570f77cc68
31 changed files with 239 additions and 3 deletions

View File

@ -2551,6 +2551,10 @@ namespace BizHawk.Client.EmuHawk
{
GlobalWin.Tools.UpdateToolsBefore();
}
else
{
GlobalWin.Tools.FastUpdateBefore();
}
_runloopFps++;
@ -2636,6 +2640,10 @@ namespace BizHawk.Client.EmuHawk
{
UpdateToolsAfter();
}
else
{
GlobalWin.Tools.FastUpdateAfter();
}
}
if (Global.ClientControls["Rewind"] || PressRewind)

View File

@ -21,6 +21,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
if (!(Global.Emulator is NES))

View File

@ -207,6 +207,11 @@ namespace BizHawk.Client.EmuHawk
_programmaticUpdateOfRegisterBoxes = false;
}
public void FastUpdate()
{
/* TODO */
}
private void UpdateTraceLog()
{
var instructions = Global.CoreComm.Tracer.TakeContents().Split('\n');

View File

@ -70,7 +70,12 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues()
{
// Do nothing;
// Do nothing
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()

View File

@ -584,6 +584,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
#endregion
#region mouseovers

View File

@ -35,6 +35,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public GBGameGenie()
{
InitializeComponent();

View File

@ -718,6 +718,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
private void GBAGPUView_Load(object sender, EventArgs e)
{
Restart();

View File

@ -80,6 +80,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public GenGameGenie()
{
InitializeComponent();

View File

@ -132,6 +132,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
Emu = Global.Emulator as GPGX;

View File

@ -110,6 +110,11 @@ namespace BizHawk.Client.EmuHawk
AddressLabel.Text = GenerateAddressString();
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
if (!IsHandleCreated || IsDisposed)

View File

@ -6,7 +6,14 @@
/// Will be called by the client anytime an Update needs to occur, such as after an emulated frame, a loadstate, or a related dialog has made a relevant change
/// </summary>
void UpdateValues();
/// <summary>
/// Will be called by the client when performance is critical,
/// The tool should only do the minimum to still function,
/// Drawing should not occur if possible, during a fast update
/// </summary>
void FastUpdate();
/// <summary>
/// Will be called anytime the dialog needs to be restarted, such as when a new ROM is loaded
/// The tool implementing this needs to account for a Game and Core change

View File

@ -76,7 +76,15 @@ namespace BizHawk.Client.EmuHawk
Owner = Global.Config.LuaSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
public void UpdateValues() { }
public void UpdateValues()
{
// Do nothing
}
public void FastUpdate()
{
// Do nothing
}
public LuaConsole Get() { return this; }

View File

@ -65,6 +65,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
private void UpdateDebugView()
{
DebugView.BlazingFast = true;

View File

@ -55,6 +55,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public NESGameGenie()
{
InitializeComponent();

View File

@ -70,6 +70,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
#endregion
private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile, int* finalpal)

View File

@ -67,6 +67,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
if (Global.Emulator is NES)

View File

@ -125,6 +125,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
#endregion
#region Events

View File

@ -46,6 +46,11 @@ namespace BizHawk.Client.EmuHawk
UpdateDisplay();
}
public void FastUpdate()
{
// TODO
}
public void Restart()
{
if (Global.Emulator is PCEngine)

View File

@ -146,6 +146,11 @@ namespace BizHawk.Client.EmuHawk
lvChannels.EndUpdate();
}
public void FastUpdate()
{
// Todo
}
class PSGEntry
{
public int index;

View File

@ -46,6 +46,10 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.Refresh();
}
public void FastUpdate()
{
// Do nothing
}
unsafe static void Draw16x16(byte* src, int* dest, int pitch, int* pal)
{

View File

@ -150,6 +150,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
if (!(Global.Emulator is SMS))

View File

@ -77,6 +77,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
#endregion
private void SnesGGDecode(string code, ref int val, ref int add)

View File

@ -145,6 +145,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// To do
}
public void UpdateToolsLoadstate()
{
SyncCore();

View File

@ -31,6 +31,17 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// TODO: think more about this
if (StopFrame.HasValue && Global.Emulator.Frame == StopFrame.Value)
{
GlobalWin.MainForm.PauseEmulator();
StopFrame = null;
}
}
public void Restart()
{
if (!IsHandleCreated || IsDisposed)

View File

@ -45,6 +45,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
if (!(Global.Emulator is TI83))

View File

@ -39,6 +39,11 @@ namespace BizHawk.Client.EmuHawk
public bool UpdateBefore { get { return false; } }
public void UpdateValues() { }
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
SetTools();

View File

@ -252,6 +252,32 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdateBefore()
{
var beforeList = _tools.Where(x => x.UpdateBefore);
foreach (var tool in beforeList)
{
if (!tool.IsDisposed ||
(tool is RamWatch && Global.Config.DisplayRamWatch)) // Ram Watch hack, on screen display should run even if Ram Watch is closed
{
tool.FastUpdate();
}
}
}
public void FastUpdateAfter()
{
var afterList = _tools.Where(x => !x.UpdateBefore);
foreach (var tool in afterList)
{
if (!tool.IsDisposed ||
(tool is RamWatch && Global.Config.DisplayRamWatch)) // Ram Watch hack, on screen display should run even if Ram Watch is closed
{
tool.FastUpdate();
}
}
}
// Note: Referencing these properties creates an instance of the tool and persists it. They should be referenced by type if this is not desired
#region Tools

View File

@ -90,6 +90,16 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// TODO: think more about this logic
if (!ToWindowRadio.Checked)
{
LogToFile();
}
}
public void Restart()
{
if (!IsHandleCreated || IsDisposed)

View File

@ -198,6 +198,16 @@ namespace BizHawk.Client.EmuHawk
Pads.ForEach(pad => pad.Refresh());
}
public void FastUpdate()
{
// TODO: SetPrevious logic should go here too or that will get out of whack
if (!Readonly && !Global.Config.VirtualPadSticky)
{
Pads.ForEach(pad => pad.Clear());
}
}
#endregion
#region Events

View File

@ -243,6 +243,19 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
if (_searches.Count > 0)
{
_searches.Update();
if (_autoSearch)
{
DoSearch();
}
}
}
public void Restart()
{
if (!IsHandleCreated || IsDisposed)

View File

@ -240,6 +240,40 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
if (_paused)
{
return;
}
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
{
return;
}
if (_watches.Any())
{
_watches.UpdateValues();
if (Global.Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address ?? 0);
GlobalWin.OSD.AddGUIText(
_watches[i].ToString(),
Global.Config.DispRamWatchx,
Global.Config.DispRamWatchy + (i * 14),
Color.Black,
frozen ? Color.Cyan : Color.White,
0
);
}
}
}
}
#endregion
#region Private Methods