Skip to content

Commit

Permalink
Merge from TASVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathor86 committed Nov 1, 2015
2 parents 0f0cba0 + 1ce0437 commit f70a2c8
Show file tree
Hide file tree
Showing 154 changed files with 8,125 additions and 24,273 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,5 @@
.hgignore
.hgtags
/output/*.manifest
/output/dll/*.iobj
/output/dll/*.ipdb
5 changes: 4 additions & 1 deletion BizHawk.Client.Common/BinarySaveStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public class BinaryStateLump
public static BinaryStateLump ClientSettings { get; private set; }
[Name("VerificationLog", "txt")]
public static BinaryStateLump VerificationLog { get; private set; }

[Name("UserData", "txt")]
public static BinaryStateLump UserData { get; private set; }
[Name("Session", "txt")]
public static BinaryStateLump Session { get; private set; }

// branchstuff
[Name("Branches\\CoreData", "bin")]
Expand All @@ -64,6 +65,8 @@ public class BinaryStateLump
public static BinaryStateLump BranchHeader { get; private set; }
[Name("Branches\\Markers", "txt")]
public static BinaryStateLump BranchMarkers { get; private set; }
[Name("Branches\\GreenZone")]
public static BinaryStateLump BranchStateHistory { get; private set; }

[AttributeUsage(AttributeTargets.Property)]
private class NameAttribute : Attribute
Expand Down
8 changes: 3 additions & 5 deletions BizHawk.Client.Common/BizHawk.Client.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -113,9 +112,6 @@
<Compile Include="CoreFileProvider.cs" />
<Compile Include="ExceptionClasses.cs" />
<Compile Include="FirmwareManager.cs" />
<Compile Include="GLManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Global.cs" />
<Compile Include="inputAdapters\AutoPattern.cs" />
<Compile Include="inputAdapters\BitwiseAdapters.cs" />
Expand Down Expand Up @@ -158,6 +154,7 @@
<Compile Include="movie\bk2\Bk2Movie.HeaderApi.cs">
<DependentUpon>Bk2Movie.cs</DependentUpon>
</Compile>
<Compile Include="movie\import\PXMImport.cs" />
<Compile Include="movie\tasproj\StateManagerState.cs" />
<Compile Include="movie\tasproj\TasBranch.cs" />
<Compile Include="movie\tasproj\TasMovie.History.cs" />
Expand Down Expand Up @@ -212,6 +209,7 @@
</Compile>
<Compile Include="movie\tasproj\TasMovie.cs" />
<Compile Include="movie\tasproj\TasMovieMarker.cs" />
<Compile Include="movie\tasproj\TasSession.cs" />
<Compile Include="movie\tasproj\TasStateManager.cs" />
<Compile Include="movie\tasproj\TasMovieRecord.cs" />
<Compile Include="movie\tasproj\TasStateManagerSettings.cs" />
Expand All @@ -231,12 +229,12 @@
<Compile Include="SevenZipWriter.cs" />
<Compile Include="SharpZipWriter.cs" />
<Compile Include="SystemInfo.cs" />
<Compile Include="TempFileCleaner.cs" />
<Compile Include="tools\Cheat.cs" />
<Compile Include="tools\CheatList.cs" />
<Compile Include="tools\RamSearchEngine.cs" />
<Compile Include="tools\Watch.cs" />
<Compile Include="tools\WatchList.cs" />
<Compile Include="UIHelper.cs" />
<Compile Include="XmlGame.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions BizHawk.Client.Common/RomLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace BizHawk.Client.Common
{
public class RomLoader
{
public enum LoadErrorType { Unknown, MissingFirmware, XML }
public enum LoadErrorType { Unknown, MissingFirmware, XML, DiscError }

// helper methods for the settings events
private object GetCoreSettings<T>()
Expand Down Expand Up @@ -265,7 +265,7 @@ public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = fal

if (discMountJob.OUT_SlowLoadAborted)
{
System.Windows.Forms.MessageBox.Show("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk");
DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", "", LoadErrorType.DiscError);
return false;
}

Expand Down Expand Up @@ -324,7 +324,7 @@ public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = fal

if (discMountJob.OUT_SlowLoadAborted)
{
System.Windows.Forms.MessageBox.Show("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk");
DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", "", LoadErrorType.DiscError);
return false;
}

Expand Down Expand Up @@ -460,7 +460,7 @@ public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = fal

if (discMountJob.OUT_SlowLoadAborted)
{
System.Windows.Forms.MessageBox.Show("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk");
DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", "PSX", LoadErrorType.DiscError);
return false;
}

Expand Down Expand Up @@ -515,7 +515,7 @@ public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = fal
{
// need to get rid of this hack at some point
rom = new RomGame(file);
((CoreFileProvider)nextComm.CoreFileProvider).SubfileDirectory = Path.GetDirectoryName(path.Replace("|", String.Empty)); // Dirty hack to get around archive filenames (since we are just getting the directory path, it is safe to mangle the filename
((CoreFileProvider)nextComm.CoreFileProvider).SubfileDirectory = Path.GetDirectoryName(path.Replace("|", string.Empty)); // Dirty hack to get around archive filenames (since we are just getting the directory path, it is safe to mangle the filename
byte[] romData = null;
byte[] xmlData = rom.FileData;

Expand Down
61 changes: 61 additions & 0 deletions BizHawk.Client.Common/TempFileCleaner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.IO;

namespace BizHawk.Client.Common
{
/// <summary>
/// Starts a thread which cleans any filenames in %temp% beginning with bizhawk.bizdelete.
/// Files shouldn't be named that unless they're safe to delete, but notably, they may stil be in use. That won't hurt this component.
/// When they're no longer in use, this component will then be able to delete them.
/// </summary>
public static class TempFileCleaner
{
//todo - manage paths other than %temp%, make not static, or allow adding multiple paths to static instance

public static void Start()
{
lock (typeof(TempFileCleaner))
{
if (thread != null)
return;

thread = new System.Threading.Thread(ThreadProc);
thread.IsBackground = true;
thread.Priority = System.Threading.ThreadPriority.Lowest;
thread.Start();
}
}

static void ThreadProc()
{
var di = new DirectoryInfo(Path.GetTempPath());
for (; ; )
{
var fis = di.GetFiles("bizhawk.bizdelete*");
foreach (var fi in fis)
{
try
{
fi.Delete();
}
catch
{
}

//try not to do more than one thing per frame
System.Threading.Thread.Sleep(100);
}

//try not to slam the filesystem too hard, we dont want this to cause any hiccups
System.Threading.Thread.Sleep(5000);
}
}

public static void Stop()
{
}

static System.Threading.Thread thread;
}

}
17 changes: 13 additions & 4 deletions BizHawk.Client.Common/config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ public enum EDispMethod { OpenGL, GdiPlus, SlimDX9 };

public enum ESoundOutputMethod { DirectSound, XAudio2, OpenAL, Dummy };

public enum EDispManagerAR { None, System, Custom };
public enum EDispManagerAR { None, System,
//actually, custom SIZE (fixme on major release)
Custom,
CustomRatio
};

public enum SaveStateTypeE { Default, Binary, Text };

Expand Down Expand Up @@ -273,9 +277,14 @@ public const int
public bool DispChrome_Fullscreen_AutohideMouse = true;
public bool DispChrome_AllowDoubleClickFullscreen = true;

public EDispManagerAR DispManagerAR = EDispManagerAR.System;
public int DispCustomUserARWidth = 1;
public int DispCustomUserARHeight = 1;
public EDispManagerAR DispManagerAR = EDispManagerAR.System;

//these are misnomers. they're actually a fixed size (fixme on major release)
public int DispCustomUserARWidth = -1;
public int DispCustomUserARHeight = -1;
//these are more like the actual AR ratio (i.e. 4:3) (fixme on major release)
public float DispCustomUserARX = -1;
public float DispCustomUserARY = -1;

// Sound options
#if WINDOWS
Expand Down
36 changes: 22 additions & 14 deletions BizHawk.Client.Common/lua/LuaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public LuaFile(string path)
{
Name = string.Empty;
Path = path;
Enabled = true;
Paused = false;
State = RunState.Running;
FrameWaiting = false;
}

Expand All @@ -29,51 +28,60 @@ public LuaFile(bool isSeparator)
IsSeparator = isSeparator;
Name = string.Empty;
Path = string.Empty;
Enabled = false;
State = RunState.Disabled;
}

public LuaFile(LuaFile file)
{
Name = file.Name;
Path = file.Path;
Enabled = file.Enabled;
Paused = file.Paused;
State = file.State;
IsSeparator = file.IsSeparator;
CurrentDirectory = file.CurrentDirectory;
}

public string Name { get; set; }
public string Path { get; set; }
public bool Enabled { get; set; }
public bool Paused { get; set; }
public bool Enabled { get { return State != RunState.Disabled; } }
public bool Paused { get { return State == RunState.Paused; } }
public bool IsSeparator { get; set; }
public LuaInterface.Lua Thread { get; set; }
public bool FrameWaiting { get; set; }
public string CurrentDirectory { get; set; }

public enum RunState
{
Disabled, Running, Paused
}

public RunState State { get; set; }

public static LuaFile SeparatorInstance
{
get { return new LuaFile(true); }
}

public void Stop()
{
Enabled = false;
State = RunState.Disabled;
Thread = null;
}

public void Toggle()
{
Enabled ^= true;
if (Enabled)
{
Paused = false;
}
if (State == RunState.Paused)
State = RunState.Running;
else if (State == RunState.Disabled)
State = RunState.Running;
else State = RunState.Disabled;
}

public void TogglePause()
{
Paused ^= true;
if (State == RunState.Paused)
State = RunState.Running;
else if(State == RunState.Running)
State = RunState.Paused;
}
}
}
8 changes: 5 additions & 3 deletions BizHawk.Client.Common/lua/LuaFileList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public string Filename

public void StopAllScripts()
{
ForEach(x => x.Enabled = false);
ForEach(x => x.State = LuaFile.RunState.Disabled);
}

public new void Clear()
Expand Down Expand Up @@ -105,8 +105,10 @@ public bool LoadLuaSession(string path)

Add(new LuaFile(scriptPath)
{
Enabled = !Global.Config.DisableLuaScriptsOnLoad &&
line.Substring(0, 1) == "1",
State = (
!Global.Config.DisableLuaScriptsOnLoad
&& line.Substring(0, 1) == "1"
) ? LuaFile.RunState.Running : LuaFile.RunState.Disabled
});
}
}
Expand Down
19 changes: 6 additions & 13 deletions BizHawk.Client.Common/lua/LuaFunctionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public NamedLuaFunction this[string guid]

public new bool Remove(NamedLuaFunction function)
{
if (Global.Emulator.CanPollInput())
if (Global.Emulator.InputCallbacksAvailable())
{
Global.Emulator.AsInputPollable().InputCallbacks.Remove(function.Callback);
}

if (Global.Emulator.CanDebug() && Global.Emulator.MemoryCallbacksAvailable())
if (Global.Emulator.MemoryCallbacksAvailable())
{
Global.Emulator.AsDebuggable().MemoryCallbacks.Remove(function.Callback);
}
Expand All @@ -33,22 +33,15 @@ public NamedLuaFunction this[string guid]

public void ClearAll()
{
if (Global.Emulator.CanPollInput())
if (Global.Emulator.InputCallbacksAvailable())
{
Global.Emulator.AsInputPollable().InputCallbacks.RemoveAll(this.Select(x => x.Callback));
}

if (Global.Emulator.CanDebug())
if (Global.Emulator.MemoryCallbacksAvailable())
{
try
{
var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks;
cbSys.RemoveAll(this.Select(x => x.Callback));
}
catch
{
//swallow exceptions here. many cores havent implemented memorycallbacks, we ought to have more granular feature querying
}
var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks;
cbSys.RemoveAll(this.Select(x => x.Callback));
}

Clear();
Expand Down
Loading

0 comments on commit f70a2c8

Please sign in to comment.