random cleanup

This commit is contained in:
goyuken 2013-12-27 04:41:50 +00:00
parent e3165459d8
commit a005767463
7 changed files with 17 additions and 41 deletions

View File

@ -28,23 +28,8 @@ namespace BizHawk.Client.Common
{ {
public class RomLoader public class RomLoader
{ {
#region Duplicate code to mainform, need to refactor! // helper methods for the settings events
/*
object __SyncSettingsHack = null;
object GetCoreSyncSettings<T>()
where T : IEmulator
{
// if movie 2.0 was finished, this is where you'd decide whether to get a settings object
// from a config file or from the movie file
// since all we have right now is movie 1.0, we get silly hacks instead
return __SyncSettingsHack ?? Global.Config.GetCoreSyncSettings<T>();
}
*/
object GetCoreSettings<T>() object GetCoreSettings<T>()
where T : IEmulator where T : IEmulator
{ {
@ -63,7 +48,6 @@ namespace BizHawk.Client.Common
return e.Settings; return e.Settings;
} }
#endregion
#region SNES specific stuff - clean up or move elsewhere #region SNES specific stuff - clean up or move elsewhere
private readonly Dictionary<string, string> _snesPrepared = new Dictionary<string, string>(); private readonly Dictionary<string, string> _snesPrepared = new Dictionary<string, string>();
@ -357,7 +341,7 @@ namespace BizHawk.Client.Common
, game.System); , game.System);
} }
game.FirmwareHash = Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom.RomData)); game.FirmwareHash = Util.Hash_SHA1(rom.RomData);
nextEmulator = new PCEngine(nextComm, game, disc, rom.RomData, GetCoreSettings<PCEngine>()); nextEmulator = new PCEngine(nextComm, game, disc, rom.RomData, GetCoreSettings<PCEngine>());
break; break;
} }

View File

@ -581,17 +581,10 @@ namespace BizHawk.Client.Common
public bool SNESUseRingBuffer = true; public bool SNESUseRingBuffer = true;
public bool SNESAlwaysDoubleSize = false; public bool SNESAlwaysDoubleSize = false;
//N64 settings
//TI 83 settings
//GB settings //GB settings
//public bool GB_ForceDMG = false; // as this setting spans multiple cores and doesn't actually affect the behavior of any core,
//public bool GB_GBACGB = false; // it hasn't been absorbed into the new system
//public bool GB_MulticartCompat = false;
//public string GB_PaletteFile = "";
public bool GB_AsSGB = false; public bool GB_AsSGB = false;
//public GBColors.ColorType CGBColors = GBColors.ColorType.gambatte;
//GIF Animator Settings //GIF Animator Settings
public int GifAnimatorNumFrames; public int GifAnimatorNumFrames;

View File

@ -2907,8 +2907,8 @@ namespace BizHawk.Client.EmuHawk
Global.Emulator.CoreComm.RomStatusDetails = Global.Emulator.CoreComm.RomStatusDetails =
string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n", string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n",
loader.Game.Name, loader.Game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(loader.Rom.RomData)), Util.Hash_SHA1(loader.Rom.RomData),
Util.BytesToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(loader.Rom.RomData))); Util.Hash_MD5(loader.Rom.RomData));
} }
if (Global.Emulator.BoardName != null) if (Global.Emulator.BoardName != null)

View File

@ -26,6 +26,11 @@ namespace BizHawk.Common
} }
} }
public static string Hash_MD5(byte[] data)
{
return Hash_MD5(data, 0, data.Length);
}
public static string Hash_SHA1(byte[] data, int offset, int len) public static string Hash_SHA1(byte[] data, int offset, int len)
{ {
using (var sha1 = System.Security.Cryptography.SHA1.Create()) using (var sha1 = System.Security.Cryptography.SHA1.Create())
@ -37,11 +42,7 @@ namespace BizHawk.Common
public static string Hash_SHA1(byte[] data) public static string Hash_SHA1(byte[] data)
{ {
using (var sha1 = System.Security.Cryptography.SHA1.Create()) return Hash_SHA1(data, 0, data.Length);
{
sha1.TransformFinalBlock(data, 0, data.Length);
return BytesToHexString(sha1.Hash);
}
} }
public static bool IsPowerOfTwo(int x) public static bool IsPowerOfTwo(int x)

View File

@ -114,11 +114,11 @@ namespace BizHawk.Emulation.Common
if (db.TryGetValue(hash, out cgi)) if (db.TryGetValue(hash, out cgi))
return new GameInfo(cgi); return new GameInfo(cgi);
hash = Util.BytesToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(RomData)); hash = Util.Hash_MD5(RomData);
if (db.TryGetValue(hash, out cgi)) if (db.TryGetValue(hash, out cgi))
return new GameInfo(cgi); return new GameInfo(cgi);
hash = Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(RomData)); hash = Util.Hash_SHA1(RomData);
if (db.TryGetValue(hash, out cgi)) if (db.TryGetValue(hash, out cgi))
return new GameInfo(cgi); return new GameInfo(cgi);

View File

@ -197,8 +197,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
CoreComm.RomStatusDetails = CoreComm.RomStatusDetails =
string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"", string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"",
game.Name, game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom)), Util.Hash_SHA1(rom), Util.Hash_MD5(rom),
Util.BytesToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(rom)),
mapper.GetType()); mapper.GetType());
} }

View File

@ -95,8 +95,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
CoreComm.RomStatusDetails = string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n", CoreComm.RomStatusDetails = string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n",
game.Name, game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(romdata)), Util.Hash_SHA1(romdata), Util.Hash_MD5(romdata)
Util.BytesToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(romdata))
); );
TimeCallback = new LibGambatte.RTCCallback(GetCurrentTime); TimeCallback = new LibGambatte.RTCCallback(GetCurrentTime);