Make a shim property in Mainform as a step towards reducing the use of Globals

This commit is contained in:
adelikat 2016-12-04 11:19:34 -06:00
parent 4ab2fadc93
commit 9135aea773
1 changed files with 120 additions and 114 deletions

View File

@ -288,7 +288,7 @@ namespace BizHawk.Client.EmuHawk
var comm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(comm);
Global.Emulator = new NullEmulator(comm, Global.Config.GetCoreSettings<NullEmulator>());
Emulator = new NullEmulator(comm, Global.Config.GetCoreSettings<NullEmulator>());
Global.ActiveController = new Controller(NullEmulator.NullController);
Global.AutoFireController = Global.AutofireNullControls;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
@ -497,7 +497,7 @@ namespace BizHawk.Client.EmuHawk
Global.ActiveController.LatchFromPhysical(Global.ControllerInputCoalescer);
Global.ActiveController.ApplyAxisConstraints(
(Global.Emulator is N64 && Global.Config.N64UseCircularAnalogConstraint) ? "Natural Circle" : null);
(Emulator is N64 && Global.Config.N64UseCircularAnalogConstraint) ? "Natural Circle" : null);
Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController);
Global.AutoFireController.LatchFromPhysical(Global.ControllerInputCoalescer);
@ -717,7 +717,13 @@ namespace BizHawk.Client.EmuHawk
return false;
}
// TODO: make this an actual property, set it when loading a Rom, and pass it dialogs, etc
// This is a quick hack to reduce the dependency on Global.Emulator
public IEmulator Emulator
{
get { return Global.Emulator; }
set { Global.Emulator = value; }
}
protected override void OnActivated(EventArgs e)
{
@ -834,7 +840,7 @@ namespace BizHawk.Client.EmuHawk
// also handle floats
conInput.AcceptNewFloats(Input.Instance.GetFloats().Select(o =>
{
var video = Global.Emulator.VideoProvider();
var video = Emulator.VideoProvider();
// hackish
if (o.Item1 == "WMouse X")
{
@ -912,7 +918,7 @@ namespace BizHawk.Client.EmuHawk
public void TakeScreenshotClientToClipboard()
{
using (var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.AsVideoProvider(), Global.Config.Screenshot_CaptureOSD))
using (var bb = GlobalWin.DisplayManager.RenderOffscreen(Emulator.AsVideoProvider(), Global.Config.Screenshot_CaptureOSD))
{
using (var img = bb.ToSysdrawingBitmap())
Clipboard.SetImage(img);
@ -962,7 +968,7 @@ namespace BizHawk.Client.EmuHawk
}
/*
using (var fs = new FileStream(path + "_test.bmp", FileMode.OpenOrCreate, FileAccess.Write))
QuickBmpFile.Save(Global.Emulator.VideoProvider(), fs, r.Next(50, 500), r.Next(50, 500));
QuickBmpFile.Save(Emulator.VideoProvider(), fs, r.Next(50, 500), r.Next(50, 500));
*/
GlobalWin.OSD.AddMessage(fi.Name + " saved.");
}
@ -973,8 +979,8 @@ namespace BizHawk.Client.EmuHawk
// run this entire thing exactly twice, since the first resize may adjust the menu stacking
for (int i = 0; i < 2; i++)
{
var video = Global.Emulator.VideoProvider();
int zoom = Global.Config.TargetZoomFactors[Global.Emulator.SystemId];
var video = Emulator.VideoProvider();
int zoom = Global.Config.TargetZoomFactors[Emulator.SystemId];
var area = Screen.FromControl(this).WorkingArea;
int borderWidth = Size.Width - PresentationPanel.Control.Size.Width;
@ -1179,13 +1185,13 @@ namespace BizHawk.Client.EmuHawk
}
}
private static LibsnesCore AsSNES { get { return Global.Emulator as LibsnesCore; } }
private LibsnesCore AsSNES { get { return Emulator as LibsnesCore; } }
// TODO: Clean Me!
public void SNES_ToggleBG1(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1202,7 +1208,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleBG2(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1219,7 +1225,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleBG3(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1236,7 +1242,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleBG4(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1253,7 +1259,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleObj1(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1270,7 +1276,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleObj2(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1286,7 +1292,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleOBJ3(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1303,7 +1309,7 @@ namespace BizHawk.Client.EmuHawk
public void SNES_ToggleOBJ4(bool? setto = null)
{
if (!(Global.Emulator is LibsnesCore)) return;
if (!(Emulator is LibsnesCore)) return;
var s = AsSNES.GetSettings();
if (setto.HasValue)
{
@ -1405,7 +1411,7 @@ namespace BizHawk.Client.EmuHawk
if (!string.IsNullOrEmpty(VersionInfo.CustomBuildString))
str += VersionInfo.CustomBuildString + " ";
if (Global.Emulator.IsNull())
if (Emulator.IsNull())
{
str = str + "BizHawk" + (VersionInfo.DeveloperBuild ? " (interim) " : string.Empty);
}
@ -1459,7 +1465,7 @@ namespace BizHawk.Client.EmuHawk
DumpStatusButton.Image = Properties.Resources.Blank;
DumpStatusButton.ToolTipText = string.Empty;
if (Global.Emulator.IsNull())
if (Emulator.IsNull())
{
return;
}
@ -1511,17 +1517,17 @@ namespace BizHawk.Client.EmuHawk
annotation = "Verified good dump";
}
if (!string.IsNullOrEmpty(Global.Emulator.CoreComm.RomStatusAnnotation))
if (!string.IsNullOrEmpty(Emulator.CoreComm.RomStatusAnnotation))
{
annotation = Global.Emulator.CoreComm.RomStatusAnnotation;
annotation = Emulator.CoreComm.RomStatusAnnotation;
}
DumpStatusButton.ToolTipText = annotation;
}
private static void LoadSaveRam()
private void LoadSaveRam()
{
if (Global.Emulator.HasSaveRam())
if (Emulator.HasSaveRam())
{
try // zero says: this is sort of sketchy... but this is no time for rearchitecting
{
@ -1529,13 +1535,13 @@ namespace BizHawk.Client.EmuHawk
// GBA meteor core might not know how big the saveram ought to be, so just send it the whole file
// GBA vba-next core will try to eat anything, regardless of size
if (Global.Emulator is GBA || Global.Emulator is VBANext || Global.Emulator is MGBAHawk)
if (Emulator is GBA || Emulator is VBANext || Emulator is MGBAHawk)
{
sram = File.ReadAllBytes(PathManager.SaveRamPath(Global.Game));
}
else
{
var oldram = Global.Emulator.AsSaveRam().CloneSaveRam();
var oldram = Emulator.AsSaveRam().CloneSaveRam();
if (oldram == null)
{
// we're eating this one now. the possible negative consequence is that a user could lose
@ -1552,7 +1558,7 @@ namespace BizHawk.Client.EmuHawk
}
}
Global.Emulator.AsSaveRam().StoreSaveRam(sram);
Emulator.AsSaveRam().StoreSaveRam(sram);
}
catch (IOException)
{
@ -1561,9 +1567,9 @@ namespace BizHawk.Client.EmuHawk
}
}
private static void SaveRam()
private void SaveRam()
{
if (Global.Emulator.HasSaveRam())
if (Emulator.HasSaveRam())
{
var path = PathManager.SaveRamPath(Global.Game);
var f = new FileInfo(path);
@ -1586,7 +1592,7 @@ namespace BizHawk.Client.EmuHawk
}
var writer = new BinaryWriter(new FileStream(path, FileMode.Create, FileAccess.Write));
var saveram = Global.Emulator.AsSaveRam().CloneSaveRam();
var saveram = Emulator.AsSaveRam().CloneSaveRam();
writer.Write(saveram, 0, saveram.Length);
writer.Close();
@ -1603,8 +1609,8 @@ namespace BizHawk.Client.EmuHawk
}
else
{
Global.Emulator.EndAsyncSound();
GlobalWin.Sound.SetSyncInputPin(Global.Emulator.SyncSoundProvider);
Emulator.EndAsyncSound();
GlobalWin.Sound.SetSyncInputPin(Emulator.SyncSoundProvider);
}
}
@ -1615,7 +1621,7 @@ namespace BizHawk.Client.EmuHawk
{
//New Code
//We use SystemID as that has the system we are playing on.
system = Global.Emulator.SystemId;
system = Emulator.SystemId;
//Old Code below.
//system = Global.Game.System;
@ -1684,9 +1690,9 @@ namespace BizHawk.Client.EmuHawk
case "SNES":
case "SGB":
// TODO: fix SNES9x here
if (Global.Emulator is LibsnesCore)
if (Emulator is LibsnesCore)
{
if ((Global.Emulator as LibsnesCore).IsSGB)
if ((Emulator as LibsnesCore).IsSGB)
{
SNESSubMenu.Text = "&SGB";
}
@ -1728,7 +1734,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private static void InitControls()
private void InitControls()
{
var controls = new Controller(
new ControllerDefinition
@ -1743,7 +1749,7 @@ namespace BizHawk.Client.EmuHawk
}
Global.ClientControls = controls;
Global.AutofireNullControls = new AutofireController(NullEmulator.NullController, Global.Emulator);
Global.AutofireNullControls = new AutofireController(NullEmulator.NullController, Emulator);
}
@ -1832,7 +1838,7 @@ namespace BizHawk.Client.EmuHawk
Global.DisableSecondaryThrottling = _unthrottled || turbo || fastForward || rewind;
// realtime throttle is never going to be so exact that using a double here is wrong
_throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
_throttle.SetCoreFps(Emulator.CoreComm.VsyncRate);
_throttle.signal_paused = EmulatorPaused;
_throttle.signal_unthrottle = _unthrottled || turbo;
//zero 26-mar-2016 - vsync and vsync throttle here both is odd, but see comments elsewhere about triple buffering
@ -1893,9 +1899,9 @@ namespace BizHawk.Client.EmuHawk
}
}
private static BitmapBuffer MakeScreenshotImage()
private BitmapBuffer MakeScreenshotImage()
{
return GlobalWin.DisplayManager.RenderVideoProvider(Global.Emulator.AsVideoProvider());
return GlobalWin.DisplayManager.RenderVideoProvider(Emulator.AsVideoProvider());
}
private void SaveSlotSelectedMessage()
@ -1913,7 +1919,7 @@ namespace BizHawk.Client.EmuHawk
return;
}
//private Size _lastVideoSize = new Size(-1, -1), _lastVirtualSize = new Size(-1, -1);
var video = Global.Emulator.VideoProvider();
var video = Emulator.VideoProvider();
//bool change = false;
Size currVideoSize = new Size(video.BufferWidth, video.BufferHeight);
Size currVirtualSize = new Size(video.VirtualWidth, video.VirtualHeight);
@ -2029,7 +2035,7 @@ namespace BizHawk.Client.EmuHawk
{
var ofd = new OpenFileDialog
{
InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId),
InitialDirectory = PathManager.GetRomsPath(Emulator.SystemId),
Filter = RomFilter,
RestoreDirectory = false,
FilterIndex = _lastOpenRomFilter
@ -2090,7 +2096,7 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
public void PutCoreSettings(object o)
{
var settable = new SettingsAdapter(Global.Emulator);
var settable = new SettingsAdapter(Emulator);
if (settable.HasSettings && settable.PutSettings(o))
{
FlagNeedsReboot();
@ -2102,7 +2108,7 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
public void PutCoreSyncSettings(object o)
{
var settable = new SettingsAdapter(Global.Emulator);
var settable = new SettingsAdapter(Emulator);
if (Global.MovieSession.Movie.IsActive)
{
GlobalWin.OSD.AddMessage("Attempt to change sync-relevant settings while recording BLOCKED.");
@ -2195,10 +2201,10 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume);
}
private static void SoftReset()
private void SoftReset()
{
// is it enough to run this for one frame? maybe..
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
if (Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{
@ -2208,10 +2214,10 @@ namespace BizHawk.Client.EmuHawk
}
}
private static void HardReset()
private void HardReset()
{
// is it enough to run this for one frame? maybe..
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Power"))
if (Emulator.ControllerDefinition.BoolButtons.Contains("Power"))
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{
@ -2258,67 +2264,67 @@ namespace BizHawk.Client.EmuHawk
Slot7StatusButton.Visible =
Slot8StatusButton.Visible =
Slot9StatusButton.Visible =
Global.Emulator.HasSavestates();
Emulator.HasSavestates();
}
public BitmapBuffer CaptureOSD()
{
var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.AsVideoProvider(), true);
var bb = GlobalWin.DisplayManager.RenderOffscreen(Emulator.AsVideoProvider(), true);
bb.DiscardAlpha();
return bb;
}
private void IncreaseWindowSize()
{
switch (Global.Config.TargetZoomFactors[Global.Emulator.SystemId])
switch (Global.Config.TargetZoomFactors[Emulator.SystemId])
{
case 1:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 2;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 2;
break;
case 2:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 3;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 3;
break;
case 3:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 4;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 4;
break;
case 4:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 5;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 5;
break;
case 5:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 10;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 10;
break;
case 10:
return;
}
GlobalWin.OSD.AddMessage("Screensize set to " + Global.Config.TargetZoomFactors[Global.Emulator.SystemId] + "x");
GlobalWin.OSD.AddMessage("Screensize set to " + Global.Config.TargetZoomFactors[Emulator.SystemId] + "x");
FrameBufferResized();
}
private void DecreaseWindowSize()
{
switch (Global.Config.TargetZoomFactors[Global.Emulator.SystemId])
switch (Global.Config.TargetZoomFactors[Emulator.SystemId])
{
case 1:
return;
case 2:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 1;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 1;
break;
case 3:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 2;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 2;
break;
case 4:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 3;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 3;
break;
case 5:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 4;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 4;
break;
case 10:
Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 5;
Global.Config.TargetZoomFactors[Emulator.SystemId] = 5;
return;
}
GlobalWin.OSD.AddMessage("Screensize set to " + Global.Config.TargetZoomFactors[Global.Emulator.SystemId] + "x");
GlobalWin.OSD.AddMessage("Screensize set to " + Global.Config.TargetZoomFactors[Emulator.SystemId] + "x");
FrameBufferResized();
}
@ -2485,7 +2491,7 @@ namespace BizHawk.Client.EmuHawk
{
if (MainStatusBar.Visible)
{
var hasDriveLight = Global.Emulator.HasDriveLight() && Global.Emulator.AsDriveLight().DriveLightEnabled;
var hasDriveLight = Emulator.HasDriveLight() && Emulator.AsDriveLight().DriveLightEnabled;
if (hasDriveLight)
{
@ -2494,7 +2500,7 @@ namespace BizHawk.Client.EmuHawk
LedLightStatusLabel.Visible = true;
}
LedLightStatusLabel.Image = Global.Emulator.AsDriveLight().DriveLightOn
LedLightStatusLabel.Image = Emulator.AsDriveLight().DriveLightOn
? StatusBarDiskLightOnImage
: StatusBarDiskLightOffImage;
}
@ -2506,14 +2512,14 @@ namespace BizHawk.Client.EmuHawk
}
}
if (Global.Emulator.UsesLinkCable())
if (Emulator.UsesLinkCable())
{
if (!LinkConnectStatusBarButton.Visible)
{
LinkConnectStatusBarButton.Visible = true;
}
LinkConnectStatusBarButton.Image = Global.Emulator.AsLinkable().LinkConnected
LinkConnectStatusBarButton.Image = Emulator.AsLinkable().LinkConnected
? LinkCableOn
: LinkCableOff;
}
@ -2589,7 +2595,7 @@ namespace BizHawk.Client.EmuHawk
{
FDSControlsMenuItem.DropDownItems.Add(name, null, delegate
{
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(button))
if (Emulator.ControllerDefinition.BoolButtons.Contains(button))
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{
@ -2633,17 +2639,17 @@ namespace BizHawk.Client.EmuHawk
private void UpdateCoreStatusBarButton()
{
if (Global.Emulator.IsNull())
if (Emulator.IsNull())
{
CoreNameStatusBarButton.Visible = false;
return;
}
CoreNameStatusBarButton.Visible = true;
var attributes = Global.Emulator.Attributes();
var attributes = Emulator.Attributes();
CoreNameStatusBarButton.Text = Global.Emulator.DisplayName();
CoreNameStatusBarButton.Image = Global.Emulator.Icon();
CoreNameStatusBarButton.Text = Emulator.DisplayName();
CoreNameStatusBarButton.Image = Emulator.Icon();
CoreNameStatusBarButton.ToolTipText = attributes.Ported ? "(ported) " : string.Empty;
}
@ -2670,9 +2676,9 @@ namespace BizHawk.Client.EmuHawk
{
get
{
if (Global.Emulator.CanPollInput())
if (Emulator.CanPollInput())
{
return Global.Emulator.AsInputPollable().IsLagFrame;
return Emulator.AsInputPollable().IsLagFrame;
}
return false;
@ -2689,7 +2695,7 @@ namespace BizHawk.Client.EmuHawk
double frameAdvanceTimestampDeltaMs = (double)(currentTimestamp - _frameAdvanceTimestamp) / Stopwatch.Frequency * 1000.0;
bool frameProgressTimeElapsed = frameAdvanceTimestampDeltaMs >= Global.Config.FrameProgressDelayMs;
if (Global.Config.SkipLagFrame && IsLagFrame && frameProgressTimeElapsed && Global.Emulator.Frame > 0)
if (Global.Config.SkipLagFrame && IsLagFrame && frameProgressTimeElapsed && Emulator.Frame > 0)
{
runFrame = true;
}
@ -2798,7 +2804,7 @@ namespace BizHawk.Client.EmuHawk
renderSound |= (_currAviWriter != null && _currAviWriter.UsesAudio);
bool render = !_throttle.skipnextframe || (_currAviWriter != null && _currAviWriter.UsesVideo);
Global.Emulator.FrameAdvance(render, renderSound);
Emulator.FrameAdvance(render, renderSound);
Global.MovieSession.HandleMovieAfterFrameLoop();
@ -2833,12 +2839,12 @@ namespace BizHawk.Client.EmuHawk
}
if (GlobalWin.Tools.IsLoaded<TAStudio>() &&
GlobalWin.Tools.TAStudio.LastPositionFrame == Global.Emulator.Frame)
GlobalWin.Tools.TAStudio.LastPositionFrame == Emulator.Frame)
{
if (PauseOnFrame.HasValue &&
PauseOnFrame.Value <= GlobalWin.Tools.TAStudio.LastPositionFrame)
{
TasMovieRecord record = (Global.MovieSession.Movie as TasMovie)[Global.Emulator.Frame];
TasMovieRecord record = (Global.MovieSession.Movie as TasMovie)[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
@ -2846,7 +2852,7 @@ namespace BizHawk.Client.EmuHawk
}
}
if (IsSeeking && Global.Emulator.Frame == PauseOnFrame.Value)
if (IsSeeking && Emulator.Frame == PauseOnFrame.Value)
{
PauseEmulator();
PauseOnFrame = null;
@ -2977,14 +2983,14 @@ namespace BizHawk.Client.EmuHawk
aw = new AudioStretcher(aw);
}
aw.SetMovieParameters(Global.Emulator.CoreComm.VsyncNum, Global.Emulator.CoreComm.VsyncDen);
aw.SetMovieParameters(Emulator.CoreComm.VsyncNum, Emulator.CoreComm.VsyncDen);
if (_avwriterResizew > 0 && _avwriterResizeh > 0)
{
aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh);
}
else
{
var videoProvider = Global.Emulator.AsVideoProvider();
var videoProvider = Emulator.AsVideoProvider();
aw.SetVideoParameters(videoProvider.BufferWidth, videoProvider.BufferHeight);
}
@ -3080,13 +3086,13 @@ namespace BizHawk.Client.EmuHawk
if (_dumpaudiosync)
{
Global.Emulator.EndAsyncSound();
Emulator.EndAsyncSound();
}
else
{
_aviSoundInput = !Global.Emulator.StartAsyncSound()
? new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V)
: Global.Emulator.SoundProvider;
_aviSoundInput = !Emulator.StartAsyncSound()
? new MetaspuAsync(Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V)
: Emulator.SoundProvider;
}
_dumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
RewireSound();
@ -3143,7 +3149,7 @@ namespace BizHawk.Client.EmuHawk
//is this the best time to handle this? or deeper inside?
if (_currAviWriterFrameList != null)
{
if (!_currAviWriterFrameList.Contains(Global.Emulator.Frame))
if (!_currAviWriterFrameList.Contains(Emulator.Frame))
goto HANDLE_AUTODUMP;
}
@ -3162,7 +3168,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
var videoProvider = Global.Emulator.AsVideoProvider();
var videoProvider = Emulator.AsVideoProvider();
bbin = new BitmapBuffer(videoProvider.BufferWidth, videoProvider.BufferHeight, videoProvider.GetVideoBuffer());
}
@ -3174,7 +3180,7 @@ namespace BizHawk.Client.EmuHawk
{
if (_avwriterpad)
{
g.Clear(Color.FromArgb(Global.Emulator.AsVideoProvider().BackgroundColor));
g.Clear(Color.FromArgb(Emulator.AsVideoProvider().BackgroundColor));
g.DrawImageUnscaled(bmpin, (bmpout.Width - bmpin.Width) / 2, (bmpout.Height - bmpin.Height) / 2);
}
else
@ -3202,16 +3208,16 @@ namespace BizHawk.Client.EmuHawk
disposableOutput = (IDisposable)output;
}
else
output = Global.Emulator.AsVideoProvider();
output = Emulator.AsVideoProvider();
}
_currAviWriter.SetFrame(Global.Emulator.Frame);
_currAviWriter.SetFrame(Emulator.Frame);
short[] samp;
int nsamp;
if (_dumpaudiosync)
{
(_currAviWriter as VideoStretcher).DumpAV(output, Global.Emulator.SyncSoundProvider, out samp, out nsamp);
(_currAviWriter as VideoStretcher).DumpAV(output, Emulator.SyncSoundProvider, out samp, out nsamp);
}
else
{
@ -3411,12 +3417,12 @@ namespace BizHawk.Client.EmuHawk
if (result)
{
Global.Emulator = loader.LoadedEmulator;
Emulator = loader.LoadedEmulator;
Global.Game = loader.Game;
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
InputManager.SyncControls();
if (Global.Emulator is TI83 && Global.Config.TI83autoloadKeyPad)
if (Emulator is TI83 && Global.Config.TI83autoloadKeyPad)
{
GlobalWin.Tools.Load<TI83KeyPad>();
}
@ -3446,18 +3452,18 @@ namespace BizHawk.Client.EmuHawk
Global.Rewinder.ResetRewindBuffer();
if (Global.Emulator.CoreComm.RomStatusDetails == null && loader.Rom != null)
if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom != null)
{
Global.Emulator.CoreComm.RomStatusDetails = string.Format(
Emulator.CoreComm.RomStatusDetails = string.Format(
"{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n",
loader.Game.Name,
loader.Rom.RomData.HashSHA1(),
loader.Rom.RomData.HashMD5());
}
if (Global.Emulator.BoardName != null)
if (Emulator.BoardName != null)
{
Console.WriteLine("Core reported BoardID: \"{0}\"", Global.Emulator.BoardName);
Console.WriteLine("Core reported BoardID: \"{0}\"", Emulator.BoardName);
}
// restarts the lua console if a different rom is loaded.
@ -3531,7 +3537,7 @@ namespace BizHawk.Client.EmuHawk
// TODO: put all these in a single method or something
//The ROM has been loaded by a recursive invocation of the LoadROM method.
if (!(Global.Emulator is NullEmulator))
if (!(Emulator is NullEmulator))
{
ApiHawk.ClientApi.OnRomLoaded();
return true;
@ -3558,11 +3564,11 @@ namespace BizHawk.Client.EmuHawk
private string CurrentlyOpenRomPoopForAdvancedLoaderPleaseRefactorME = "";
private static void CommitCoreSettingsToConfig()
private void CommitCoreSettingsToConfig()
{
// save settings object
var t = Global.Emulator.GetType();
var settable = new SettingsAdapter(Global.Emulator);
var t = Emulator.GetType();
var settable = new SettingsAdapter(Emulator);
if (settable.HasSettings)
{
@ -3592,7 +3598,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage("SRAM cleared.");
}
}
else if (Global.Emulator.HasSaveRam() && Global.Emulator.AsSaveRam().SaveRamModified)
else if (Emulator.HasSaveRam() && Emulator.AsSaveRam().SaveRamModified)
{
SaveRam();
}
@ -3609,10 +3615,10 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Tools.Get<TraceLogger>().Restart();
Global.CheatList.SaveOnClose();
Global.Emulator.Dispose();
Emulator.Dispose();
var coreComm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(coreComm);
Global.Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings<NullEmulator>());
Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings<NullEmulator>());
Global.ActiveController = new Controller(NullEmulator.NullController);
Global.AutoFireController = Global.AutofireNullControls;
RewireSound();
@ -3631,7 +3637,7 @@ namespace BizHawk.Client.EmuHawk
CloseGame(clearSram);
var coreComm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(coreComm);
Global.Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings<NullEmulator>());
Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings<NullEmulator>());
Global.Game = GameInfo.NullInstance;
GlobalWin.Tools.Restart();
@ -3709,7 +3715,7 @@ namespace BizHawk.Client.EmuHawk
public void LoadState(string path, string userFriendlyStateName, bool fromLua = false, bool supressOSD = false) // Move to client.common
{
if (!Global.Emulator.HasSavestates())
if (!Emulator.HasSavestates())
{
return;
}
@ -3757,7 +3763,7 @@ namespace BizHawk.Client.EmuHawk
public void LoadQuickSave(string quickSlotName, bool fromLua = false, bool supressOSD = false)
{
if (!Global.Emulator.HasSavestates())
if (!Emulator.HasSavestates())
{
return;
}
@ -3788,7 +3794,7 @@ namespace BizHawk.Client.EmuHawk
public void SaveState(string path, string userFriendlyStateName, bool fromLua)
{
if (!Global.Emulator.HasSavestates())
if (!Emulator.HasSavestates())
{
return;
}
@ -3820,7 +3826,7 @@ namespace BizHawk.Client.EmuHawk
// TODO: should backup logic be stuffed in into Client.Common.SaveStateManager?
public void SaveQuickSave(string quickSlotName)
{
if (!Global.Emulator.HasSavestates())
if (!Emulator.HasSavestates())
{
return;
}
@ -3860,7 +3866,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveStateAs()
{
if (!Global.Emulator.HasSavestates())
if (!Emulator.HasSavestates())
{
return;
}
@ -3897,7 +3903,7 @@ namespace BizHawk.Client.EmuHawk
private void LoadStateAs()
{
if (!Global.Emulator.HasSavestates())
if (!Emulator.HasSavestates())
{
return;
}
@ -3931,7 +3937,7 @@ namespace BizHawk.Client.EmuHawk
private void SelectSlot(int slot)
{
if (Global.Emulator.HasSavestates())
if (Emulator.HasSavestates())
{
if (IsSlave && master.WantsToControlSavestates)
{
@ -3947,7 +3953,7 @@ namespace BizHawk.Client.EmuHawk
private void PreviousSlot()
{
if (Global.Emulator.HasSavestates())
if (Emulator.HasSavestates())
{
if (IsSlave && master.WantsToControlSavestates)
{
@ -3975,7 +3981,7 @@ namespace BizHawk.Client.EmuHawk
private void NextSlot()
{
if (Global.Emulator.HasSavestates())
if (Emulator.HasSavestates())
{
if (IsSlave && master.WantsToControlSavestates)
{