move HawkFile to BizHawk.Common along with a small web of dependencies and then add "using BizHawk.Common" to 100 files
This commit is contained in:
parent
ee70aefd3a
commit
0acbb11e97
|
@ -95,7 +95,6 @@
|
|||
<Compile Include="CoreFileProvider.cs" />
|
||||
<Compile Include="FirmwareManager.cs" />
|
||||
<Compile Include="Global.cs" />
|
||||
<Compile Include="HawkFile.cs" />
|
||||
<Compile Include="helpers\InputValidate.cs" />
|
||||
<Compile Include="KeyTurbo.cs" />
|
||||
<Compile Include="movie\InputAdapters.cs" />
|
||||
|
@ -114,6 +113,7 @@
|
|||
<Compile Include="helpers\StringHelpers.cs" />
|
||||
<Compile Include="RomGame.cs" />
|
||||
<Compile Include="SavestateManager.cs" />
|
||||
<Compile Include="SevenZipSharpArchiveHandler.cs" />
|
||||
<Compile Include="tools\Cheat.cs" />
|
||||
<Compile Include="tools\CheatList.cs" />
|
||||
<Compile Include="tools\RamSearchEngine.cs" />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of IHawkFileArchiveHandler using SevenZipSharp pure managed code
|
||||
/// </summary>
|
||||
public class SevenZipSharpArchiveHandler : IHawkFileArchiveHandler
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
if (extractor != null)
|
||||
{
|
||||
extractor.Dispose();
|
||||
extractor = null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckSignature(string fileName, out int offset, out bool isExecutable)
|
||||
{
|
||||
SevenZip.FileChecker.ThrowExceptions = false;
|
||||
return SevenZip.FileChecker.CheckSignature(fileName, out offset, out isExecutable) != SevenZip.InArchiveFormat.None;
|
||||
}
|
||||
|
||||
public IHawkFileArchiveHandler Construct(string path)
|
||||
{
|
||||
SevenZipSharpArchiveHandler ret = new SevenZipSharpArchiveHandler();
|
||||
ret.Open(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Open(string path)
|
||||
{
|
||||
extractor = new SevenZip.SevenZipExtractor(path);
|
||||
}
|
||||
|
||||
SevenZip.SevenZipExtractor extractor;
|
||||
|
||||
public List<HawkFileArchiveItem> Scan()
|
||||
{
|
||||
List<HawkFileArchiveItem> ret = new List<HawkFileArchiveItem>();
|
||||
for (int i = 0; i < extractor.ArchiveFileData.Count; i++)
|
||||
{
|
||||
var afd = extractor.ArchiveFileData[i];
|
||||
if (afd.IsDirectory) continue;
|
||||
var ai = new HawkFileArchiveItem { name = HawkFile.Util_FixArchiveFilename(afd.FileName), size = (long)afd.Size, archiveIndex = i, index = ret.Count };
|
||||
ret.Add(ai);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void ExtractFile(int index, Stream stream)
|
||||
{
|
||||
extractor.ExtractFile(index, stream);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class XmlGame
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
#pragma warning disable 219
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@ -31,6 +32,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
@ -42,9 +44,13 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="HawkFile.cs" />
|
||||
<Compile Include="MruStack.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Types.cs" />
|
||||
<Compile Include="UndoHistory.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -0,0 +1,457 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Common
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static string GetDirectory(this Assembly asm)
|
||||
{
|
||||
string codeBase = asm.CodeBase;
|
||||
UriBuilder uri = new UriBuilder(codeBase);
|
||||
string path = Uri.UnescapeDataString(uri.Path);
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
|
||||
public static int LowerBoundBinarySearch<T, TKey>(this IList<T> list, Func<T, TKey> keySelector, TKey key) where TKey : IComparable<TKey>
|
||||
{
|
||||
int min = 0;
|
||||
int max = list.Count;
|
||||
int mid = 0;
|
||||
TKey midKey;
|
||||
while (min < max)
|
||||
{
|
||||
mid = (max + min) / 2;
|
||||
T midItem = list[mid];
|
||||
midKey = keySelector(midItem);
|
||||
int comp = midKey.CompareTo(key);
|
||||
if (comp < 0)
|
||||
{
|
||||
min = mid + 1;
|
||||
}
|
||||
else if (comp > 0)
|
||||
{
|
||||
max = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
|
||||
//did we find it exactly?
|
||||
if (min == max && keySelector(list[min]).CompareTo(key) == 0)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
mid = min;
|
||||
|
||||
//we didnt find it. return something corresponding to lower_bound semantics
|
||||
|
||||
if (mid == list.Count)
|
||||
return max; //had to go all the way to max before giving up; lower bound is max
|
||||
if (mid == 0)
|
||||
return -1; //had to go all the way to min before giving up; lower bound is min
|
||||
|
||||
midKey = keySelector(list[mid]);
|
||||
if (midKey.CompareTo(key) >= 0) return mid - 1;
|
||||
else return mid;
|
||||
}
|
||||
|
||||
public static string ToHexString(this int n, int numdigits)
|
||||
{
|
||||
return string.Format("{0:X" + numdigits + "}", n);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Stream src, Stream dest)
|
||||
{
|
||||
int size = (src.CanSeek) ? Math.Min((int)(src.Length - src.Position), 0x2000) : 0x2000;
|
||||
byte[] buffer = new byte[size];
|
||||
int n;
|
||||
do
|
||||
{
|
||||
n = src.Read(buffer, 0, buffer.Length);
|
||||
dest.Write(buffer, 0, n);
|
||||
} while (n != 0);
|
||||
}
|
||||
|
||||
public static void CopyTo(this MemoryStream src, Stream dest)
|
||||
{
|
||||
dest.Write(src.GetBuffer(), (int)src.Position, (int)(src.Length - src.Position));
|
||||
}
|
||||
|
||||
public static void CopyTo(this Stream src, MemoryStream dest)
|
||||
{
|
||||
if (src.CanSeek)
|
||||
{
|
||||
int pos = (int)dest.Position;
|
||||
int length = (int)(src.Length - src.Position) + pos;
|
||||
dest.SetLength(length);
|
||||
|
||||
while (pos < length)
|
||||
pos += src.Read(dest.GetBuffer(), pos, length - pos);
|
||||
}
|
||||
else
|
||||
src.CopyTo((Stream)dest);
|
||||
}
|
||||
|
||||
|
||||
public static bool IsBinary(this string str)
|
||||
{
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
char c = str[i];
|
||||
if (c == '0' || c == '1')
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Bit(this byte b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
public static bool Bit(this int b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
public static bool Bit(this ushort b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
public static string GetPrecedingString(this string str, string value)
|
||||
{
|
||||
int index = str.IndexOf(value);
|
||||
if (index < 0)
|
||||
return null;
|
||||
if (index == 0)
|
||||
return "";
|
||||
return str.Substring(0, index);
|
||||
}
|
||||
|
||||
public static bool In(this string str, params string[] options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.Equals(str, StringComparison.CurrentCultureIgnoreCase)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool In(this string str, IEnumerable<string> options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.Equals(str, StringComparison.CurrentCultureIgnoreCase)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool In<T>(this string str, IEnumerable<T> options, Func<T, string, bool> eval)
|
||||
{
|
||||
foreach (T opt in options)
|
||||
{
|
||||
if (eval(opt, str) == true)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool NotIn(this string str, params string[] options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.ToLower() == str.ToLower()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool NotIn(this string str, IEnumerable<string> options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.ToLower() == str.ToLower()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool In(this int i, params int[] options)
|
||||
{
|
||||
foreach (int j in options)
|
||||
{
|
||||
if (i == j) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool In(this int i, IEnumerable<int> options)
|
||||
{
|
||||
foreach (int j in options)
|
||||
{
|
||||
if (i == j) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ContainsStartsWith(this IEnumerable<string> options, string str)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.StartsWith(str)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetOptionValue(this IEnumerable<string> options, string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.StartsWith(str))
|
||||
{
|
||||
return opt.Split('=')[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsValidRomExtentsion(this string str, params string[] romExtensions)
|
||||
{
|
||||
string strUpper = str.ToUpper();
|
||||
foreach (string ext in romExtensions)
|
||||
{
|
||||
if (strUpper.EndsWith(ext.ToUpper())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string ToCommaSeparated(this List<string> list)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(",");
|
||||
sb.Append(list[i]);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this byte[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X2}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public unsafe static void SaveAsHexFast(this byte[] buffer, TextWriter writer)
|
||||
{
|
||||
char* table = Util.HexConvPtr;
|
||||
if (buffer.Length > 0)
|
||||
{
|
||||
int len = buffer.Length;
|
||||
fixed (byte* src = &buffer[0])
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
writer.Write(table[src[i] >> 4]);
|
||||
writer.Write(table[src[i] & 15]);
|
||||
}
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this byte[] buffer, TextWriter writer, int length)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
writer.Write("{0:X2}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this short[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X4}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this ushort[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X4}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this int[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X8}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this uint[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X8}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, int[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, uint[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, short[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, ushort[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static int[] ReadInt32s(this BinaryReader br, int num)
|
||||
{
|
||||
int[] ret = new int[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
ret[i] = br.ReadInt32();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static short[] ReadInt16s(this BinaryReader br, int num)
|
||||
{
|
||||
short[] ret = new short[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
ret[i] = br.ReadInt16();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ushort[] ReadUInt16s(this BinaryReader br, int num)
|
||||
{
|
||||
ushort[] ret = new ushort[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
ret[i] = br.ReadUInt16();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this byte[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 2 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 2 < hex.Length; i++)
|
||||
{
|
||||
string bytehex = "" + hex[i * 2] + hex[i * 2 + 1];
|
||||
buffer[i] = byte.Parse(bytehex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
private static int Hex2Int(char c)
|
||||
{
|
||||
if (c <= '9')
|
||||
return c - '0';
|
||||
else if (c <= 'F')
|
||||
return c - '7';
|
||||
else
|
||||
return c - 'W';
|
||||
}
|
||||
|
||||
public static void ReadFromHexFast(this byte[] buffer, string hex)
|
||||
{
|
||||
//if (hex.Length % 2 != 0)
|
||||
// throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 2 < hex.Length; i++)
|
||||
{
|
||||
buffer[i] = (byte)(Hex2Int(hex[i * 2]) * 16 + Hex2Int(hex[i * 2 + 1]));
|
||||
}
|
||||
/*
|
||||
var b = new byte[buffer.Length];
|
||||
b.ReadFromHex(hex);
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
if (b[i] != buffer[i])
|
||||
throw new Exception();
|
||||
}*/
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this short[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 4 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++)
|
||||
{
|
||||
string shorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3];
|
||||
buffer[i] = short.Parse(shorthex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this ushort[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 4 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++)
|
||||
{
|
||||
string ushorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3];
|
||||
buffer[i] = ushort.Parse(ushorthex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this int[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 8 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 8 < hex.Length; i++)
|
||||
{
|
||||
//string inthex = "" + hex[i * 8] + hex[(i * 8) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3] + hex[(i*4
|
||||
string inthex = hex.Substring(i * 8, 8);
|
||||
buffer[i] = int.Parse(inthex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
//public static void SaveAsHex(this uint[] buffer, BinaryWriter bw)
|
||||
//{
|
||||
// for (int i = 0; i < buffer.Length; i++)
|
||||
// bw.Write(buffer[i]);
|
||||
//}
|
||||
|
||||
//these don't work??? they dont get chosen by compiler
|
||||
public static void WriteBit(this BinaryWriter bw, Bit bit) { bw.Write((bool)bit); }
|
||||
public static Bit ReadBit(this BinaryReader br) { return br.ReadBoolean(); }
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -7,101 +7,12 @@ using System.Linq;
|
|||
//This is so we could drop in an unamanged dearchiver library optionally later as a performance optimization without ruining the portability of the code.
|
||||
//Also, we want to be able to use HawkFiles in BizHawk.Common withuot bringing in a large 7-zip dependency
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
namespace BizHawk.Common
|
||||
{
|
||||
//todo:
|
||||
//split into "bind" and "open (the bound thing)"
|
||||
//scan archive to flatten interior directories down to a path (maintain our own archive item list)
|
||||
|
||||
public interface IHawkFileArchiveHandler : IDisposable
|
||||
{
|
||||
//todo - could this receive a hawkfile itself? possibly handy, in very clever scenarios of mounting fake files
|
||||
bool CheckSignature(string fileName, out int offset, out bool isExecutable);
|
||||
|
||||
List<HawkFileArchiveItem> Scan();
|
||||
|
||||
IHawkFileArchiveHandler Construct(string path);
|
||||
|
||||
void ExtractFile(int index, Stream stream);
|
||||
}
|
||||
|
||||
public class HawkFileArchiveItem
|
||||
{
|
||||
/// <summary>
|
||||
/// member name
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// size of member file
|
||||
/// </summary>
|
||||
public long size;
|
||||
|
||||
/// <summary>
|
||||
/// the index of this archive item
|
||||
/// </summary>
|
||||
public int index;
|
||||
|
||||
/// <summary>
|
||||
/// the index WITHIN THE ARCHIVE (for internal tracking by a IHawkFileArchiveHandler) of the member
|
||||
/// </summary>
|
||||
public int archiveIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of IHawkFileArchiveHandler using SevenZipSharp pure managed code
|
||||
/// </summary>
|
||||
class SevenZipSharpArchiveHandler : IHawkFileArchiveHandler
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
if(extractor != null)
|
||||
{
|
||||
extractor.Dispose();
|
||||
extractor = null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckSignature(string fileName, out int offset, out bool isExecutable)
|
||||
{
|
||||
SevenZip.FileChecker.ThrowExceptions = false;
|
||||
return SevenZip.FileChecker.CheckSignature(fileName, out offset, out isExecutable) != SevenZip.InArchiveFormat.None;
|
||||
}
|
||||
|
||||
public IHawkFileArchiveHandler Construct(string path)
|
||||
{
|
||||
SevenZipSharpArchiveHandler ret = new SevenZipSharpArchiveHandler();
|
||||
ret.Open(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Open(string path)
|
||||
{
|
||||
extractor = new SevenZip.SevenZipExtractor(path);
|
||||
}
|
||||
|
||||
SevenZip.SevenZipExtractor extractor;
|
||||
|
||||
public List<HawkFileArchiveItem> Scan()
|
||||
{
|
||||
List<HawkFileArchiveItem> ret = new List<HawkFileArchiveItem>();
|
||||
for (int i = 0; i < extractor.ArchiveFileData.Count; i++)
|
||||
{
|
||||
var afd = extractor.ArchiveFileData[i];
|
||||
if (afd.IsDirectory) continue;
|
||||
var ai = new HawkFileArchiveItem {name = HawkFile.Util_FixArchiveFilename(afd.FileName), size = (long) afd.Size, archiveIndex = i, index = ret.Count};
|
||||
ret.Add(ai);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void ExtractFile(int index, Stream stream)
|
||||
{
|
||||
extractor.ExtractFile(index, stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HawkFile allows a variety of objects (actual files, archive members) to be treated as normal filesystem objects to be opened, closed, and read.
|
||||
/// It can understand paths in 'canonical' format which includes /path/to/archive.zip|member.rom as well as /path/to/file.rom
|
||||
|
@ -113,7 +24,7 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Set this with an instance which can construct archive handlers as necessary for archive handling.
|
||||
/// </summary>
|
||||
public static IHawkFileArchiveHandler ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();
|
||||
public static IHawkFileArchiveHandler ArchiveHandlerFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Utility: Uses full HawkFile processing to determine whether a file exists at the provided path
|
||||
|
@ -506,6 +417,50 @@ namespace BizHawk.Client.Common
|
|||
if (member == null) return root;
|
||||
else return string.Format("{0}|{1}", root, member);
|
||||
}
|
||||
|
||||
} //class HawkFile
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Bridge between HawkFile and the frontend's implementation of archive management
|
||||
/// </summary>
|
||||
public interface IHawkFileArchiveHandler : IDisposable
|
||||
{
|
||||
//todo - could this receive a hawkfile itself? possibly handy, in very clever scenarios of mounting fake files
|
||||
bool CheckSignature(string fileName, out int offset, out bool isExecutable);
|
||||
|
||||
List<HawkFileArchiveItem> Scan();
|
||||
|
||||
IHawkFileArchiveHandler Construct(string path);
|
||||
|
||||
void ExtractFile(int index, Stream stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Members returned by IHawkFileArchiveHandler
|
||||
/// </summary>
|
||||
public class HawkFileArchiveItem
|
||||
{
|
||||
/// <summary>
|
||||
/// member name
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// size of member file
|
||||
/// </summary>
|
||||
public long size;
|
||||
|
||||
/// <summary>
|
||||
/// the index of this archive item
|
||||
/// </summary>
|
||||
public int index;
|
||||
|
||||
/// <summary>
|
||||
/// the index WITHIN THE ARCHIVE (for internal tracking by a IHawkFileArchiveHandler) of the member
|
||||
/// </summary>
|
||||
public int archiveIndex;
|
||||
}
|
||||
|
||||
} //namespace BizHawk.Common
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace BizHawk.Common
|
||||
{
|
||||
|
||||
//I think this is a little faster with uint than with byte
|
||||
public struct Bit
|
||||
{
|
||||
Bit(uint val) { this.val = val; }
|
||||
uint val;
|
||||
public static implicit operator Bit(int rhs) { Debug.Assert((rhs & ~1) == 0); return new Bit((uint)(rhs)); }
|
||||
public static implicit operator Bit(uint rhs) { Debug.Assert((rhs & ~1) == 0); return new Bit((uint)(rhs)); }
|
||||
public static implicit operator Bit(byte rhs) { Debug.Assert((rhs & ~1) == 0); return new Bit((uint)(rhs)); }
|
||||
public static implicit operator Bit(bool rhs) { return new Bit(rhs ? (byte)1 : (byte)0); }
|
||||
public static implicit operator long(Bit rhs) { return (long)rhs.val; }
|
||||
public static implicit operator int(Bit rhs) { return (int)rhs.val; }
|
||||
public static implicit operator uint(Bit rhs) { return (uint)rhs.val; }
|
||||
public static implicit operator byte(Bit rhs) { return (byte)rhs.val; }
|
||||
public static implicit operator bool(Bit rhs) { return rhs.val != 0; }
|
||||
public override string ToString()
|
||||
{
|
||||
return val.ToString();
|
||||
}
|
||||
public static bool operator ==(Bit lhs, Bit rhs) { return lhs.val == rhs.val; }
|
||||
public static bool operator !=(Bit lhs, Bit rhs) { return lhs.val != rhs.val; }
|
||||
public override int GetHashCode() { return val.GetHashCode(); }
|
||||
public override bool Equals(object obj) { return this == (Bit)obj; } //this is probably wrong
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
public unsafe static class Util
|
||||
{
|
||||
static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
static System.Runtime.InteropServices.GCHandle HexConvHandle;
|
||||
public static char* HexConvPtr;
|
||||
static unsafe Util()
|
||||
{
|
||||
HexConvHandle = System.Runtime.InteropServices.GCHandle.Alloc(HexConvArr, System.Runtime.InteropServices.GCHandleType.Pinned);
|
||||
HexConvPtr = (char*)HexConvHandle.AddrOfPinnedObject().ToPointer();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.CPUs.M68000
|
||||
{
|
||||
partial class MC68000
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.CPUs.H6280
|
||||
{
|
||||
public sealed partial class HuC6280
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
//http://nesdev.parodius.com/6502_cpu.txt
|
||||
|
||||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.CPUs.M6502
|
||||
{
|
||||
public partial class MOS6502X
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64
|
||||
{
|
||||
static class SaveState
|
||||
|
|
|
@ -2,6 +2,8 @@ using System;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
|
||||
//http://www.ticalc.org/pub/text/calcinfo/
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Coleco
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
||||
{
|
||||
public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.GB
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.GB
|
||||
{
|
||||
public class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||
{
|
||||
public class N64 : IEmulator, IVideoProvider
|
||||
|
|
|
@ -14,6 +14,7 @@ using System.Collections.Generic;
|
|||
|
||||
//TODO - refactor length counter to be separate component
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 16 & 159
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 071
|
||||
//TODO - apparently this mapper contains good nes timing test cases
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
/*
|
||||
PRG-ROM - 32kb/16kb
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//iNES Mapper 92
|
||||
//Example Games:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class MLT_ACTION52 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class MLT_MAX15 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//aka MMC6 aka StarTropics and StarTropics 2
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118,119,165,205,214,215,245,249,250,254
|
||||
|
||||
using System;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//http://wiki.nesdev.com/w/index.php/INES_Mapper_044
|
||||
public sealed class Mapper049 : MMC3Board_Base
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper52 : MMC3Board_Base
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//this class also handles mapper 248
|
||||
//FCEUX uses 115 to implement 248 as well (as of 09-apr-2012 it does it buggily in the case of Bao Qing Tian (As))
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper191 : MMC3Board_Base
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper245 : MMC3Board_Base
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper249 : MMC3Board_Base
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper015 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper045 : MMC3Board_Base
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper057 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper058 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//Mapper 069 is FME7
|
||||
//or, Sunsoft-5, which is FME7 with additional sound hardware
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper078 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper090 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper116 : NES.NESBoardBase
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper176 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper178 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper200 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
/*
|
||||
* Here are Disch's original notes:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper225 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper226 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper227 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper230 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper231 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper233 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
/*
|
||||
PCB Class: Unknown
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper50 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper61 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Mapper62 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 19 + 210
|
||||
//210 lacks the sound and nametable control
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 105
|
||||
public sealed class NES_EVENT : NES.NESBoardBase
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
/*
|
||||
Example Games:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA MMC2 Mike Tyson's Punch-Out!!
|
||||
//AKA MMC4 (similar enough to combine in one fle)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA Sunsoft-2 chip (SUNSOFT-3 pcb)
|
||||
//game=Tenka no Goikenban: Mito Koumon ; chip=sunsoft-2 ; pcb = SUNSOFT-3
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//game=shanghai ; chip=sunsoft-2 ; pcb=SUNSOFT-3R
|
||||
//game=fantasy zone ; chip=sunsoft-1 ; pcb = SUNSOFT-4
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 67
|
||||
//this may be confusing due to general chaos with the early sunsoft mappers. see docs/sunsoft.txt
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//Mapper 152
|
||||
//Arkanoid 2 (J)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 64
|
||||
public sealed class TENGEN_800032 : NES.NESBoardBase
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 80
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
public sealed class Taito_X1_017 : NES.NESBoardBase
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//AKA mapper 75
|
||||
public sealed class VRC1 : NES.NESBoardBase
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//mapper 21 + 22 + 23 + 25 (docs largely in 021.txt for VRC4 and 22.txt for VRC2)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//mapper 73 AKA salamander
|
||||
//different IRQ logic than other VRC
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//mapper 24 + 26
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
//mapper 85
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//};
|
||||
|
||||
using System;
|
||||
using BizHawk.Common;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
|
|
|
@ -15,6 +15,8 @@ using System.IO;
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||
{
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ using BizHawk.Emulation.Sound;
|
|||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
public sealed class ADPCM : ISoundProvider
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
partial class PCEngine
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.H6280;
|
||||
using BizHawk.Emulation.Sound;
|
||||
using BizHawk.DiscSystem;
|
||||
|
|
|
@ -4,6 +4,8 @@ using BizHawk.Emulation.Sound;
|
|||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
// TODO we can adjust this to have Think take the number of cycles and not require
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
// HuC6260 Video Color Encoder
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.H6280;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.H6280;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Sega
|
||||
{
|
||||
public sealed partial class GenVDP : IVideoProvider
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.M68000;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
using BizHawk.Emulation.Sound;
|
||||
using Native68000;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Sega
|
||||
{
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Sega
|
||||
{
|
||||
public enum VdpMode { SMS, GameGear }
|
||||
|
|
|
@ -5,6 +5,8 @@ using System.Text;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
||||
{
|
||||
public class Yabause : IEmulator, IVideoProvider, ISyncSoundProvider
|
||||
|
|
|
@ -27,6 +27,8 @@ using System;
|
|||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.DiscSystem
|
||||
{
|
||||
partial class Disc
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
{
|
||||
// Emulates PSG audio unit of a PC Engine / Turbografx-16 / SuperGrafx.
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
{
|
||||
public class MMC5Audio
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
{
|
||||
// YM2149F variant
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
{
|
||||
public class VRC6Alt
|
||||
|
|
|
@ -8,450 +8,10 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static string GetDirectory(this Assembly asm)
|
||||
{
|
||||
string codeBase = asm.CodeBase;
|
||||
UriBuilder uri = new UriBuilder(codeBase);
|
||||
string path = Uri.UnescapeDataString(uri.Path);
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
|
||||
public static int LowerBoundBinarySearch<T, TKey>(this IList<T> list, Func<T, TKey> keySelector, TKey key) where TKey : IComparable<TKey>
|
||||
{
|
||||
int min = 0;
|
||||
int max = list.Count;
|
||||
int mid = 0;
|
||||
TKey midKey;
|
||||
while (min < max)
|
||||
{
|
||||
mid = (max + min) / 2;
|
||||
T midItem = list[mid];
|
||||
midKey = keySelector(midItem);
|
||||
int comp = midKey.CompareTo(key);
|
||||
if (comp < 0)
|
||||
{
|
||||
min = mid + 1;
|
||||
}
|
||||
else if (comp > 0)
|
||||
{
|
||||
max = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
|
||||
//did we find it exactly?
|
||||
if (min == max && keySelector(list[min]).CompareTo(key) == 0)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
mid = min;
|
||||
|
||||
//we didnt find it. return something corresponding to lower_bound semantics
|
||||
|
||||
if (mid == list.Count)
|
||||
return max; //had to go all the way to max before giving up; lower bound is max
|
||||
if (mid == 0)
|
||||
return -1; //had to go all the way to min before giving up; lower bound is min
|
||||
|
||||
midKey = keySelector(list[mid]);
|
||||
if (midKey.CompareTo(key) >= 0) return mid - 1;
|
||||
else return mid;
|
||||
}
|
||||
|
||||
public static string ToHexString(this int n, int numdigits)
|
||||
{
|
||||
return string.Format("{0:X" + numdigits + "}", n);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Stream src, Stream dest)
|
||||
{
|
||||
int size = (src.CanSeek) ? Math.Min((int)(src.Length - src.Position), 0x2000) : 0x2000;
|
||||
byte[] buffer = new byte[size];
|
||||
int n;
|
||||
do
|
||||
{
|
||||
n = src.Read(buffer, 0, buffer.Length);
|
||||
dest.Write(buffer, 0, n);
|
||||
} while (n != 0);
|
||||
}
|
||||
|
||||
public static void CopyTo(this MemoryStream src, Stream dest)
|
||||
{
|
||||
dest.Write(src.GetBuffer(), (int)src.Position, (int)(src.Length - src.Position));
|
||||
}
|
||||
|
||||
public static void CopyTo(this Stream src, MemoryStream dest)
|
||||
{
|
||||
if (src.CanSeek)
|
||||
{
|
||||
int pos = (int)dest.Position;
|
||||
int length = (int)(src.Length - src.Position) + pos;
|
||||
dest.SetLength(length);
|
||||
|
||||
while (pos < length)
|
||||
pos += src.Read(dest.GetBuffer(), pos, length - pos);
|
||||
}
|
||||
else
|
||||
src.CopyTo((Stream)dest);
|
||||
}
|
||||
|
||||
|
||||
public static bool IsBinary(this string str)
|
||||
{
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
char c = str[i];
|
||||
if (c == '0' || c == '1')
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Bit(this byte b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
public static bool Bit(this int b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
public static bool Bit(this ushort b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
public static string GetPrecedingString(this string str, string value)
|
||||
{
|
||||
int index = str.IndexOf(value);
|
||||
if (index < 0)
|
||||
return null;
|
||||
if (index == 0)
|
||||
return "";
|
||||
return str.Substring(0, index);
|
||||
}
|
||||
|
||||
public static bool In(this string str, params string[] options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.Equals(str, StringComparison.CurrentCultureIgnoreCase)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool In(this string str, IEnumerable<string> options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.Equals(str, StringComparison.CurrentCultureIgnoreCase)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool In<T>(this string str, IEnumerable<T> options, Func<T, string, bool> eval)
|
||||
{
|
||||
foreach (T opt in options)
|
||||
{
|
||||
if (eval(opt, str) == true)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool NotIn(this string str, params string[] options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.ToLower() == str.ToLower()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool NotIn(this string str, IEnumerable<string> options)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.ToLower() == str.ToLower()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool In(this int i, params int[] options)
|
||||
{
|
||||
foreach (int j in options)
|
||||
{
|
||||
if (i == j) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool In(this int i, IEnumerable<int> options)
|
||||
{
|
||||
foreach (int j in options)
|
||||
{
|
||||
if (i == j) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ContainsStartsWith(this IEnumerable<string> options, string str)
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.StartsWith(str)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetOptionValue(this IEnumerable<string> options, string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (string opt in options)
|
||||
{
|
||||
if (opt.StartsWith(str))
|
||||
{
|
||||
return opt.Split('=')[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsValidRomExtentsion(this string str, params string[] romExtensions)
|
||||
{
|
||||
string strUpper = str.ToUpper();
|
||||
foreach (string ext in romExtensions)
|
||||
{
|
||||
if (strUpper.EndsWith(ext.ToUpper())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string ToCommaSeparated(this List<string> list)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(",");
|
||||
sb.Append(list[i]);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this byte[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X2}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public unsafe static void SaveAsHexFast(this byte[] buffer, TextWriter writer)
|
||||
{
|
||||
char* table = Util.HexConvPtr;
|
||||
if (buffer.Length > 0)
|
||||
{
|
||||
int len = buffer.Length;
|
||||
fixed (byte* src = &buffer[0])
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
writer.Write(table[src[i] >> 4]);
|
||||
writer.Write(table[src[i] & 15]);
|
||||
}
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this byte[] buffer, TextWriter writer, int length)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
writer.Write("{0:X2}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this short[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X4}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this ushort[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X4}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this int[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X8}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void SaveAsHex(this uint[] buffer, TextWriter writer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
writer.Write("{0:X8}", buffer[i]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, int[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, uint[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, short[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static void Write(this BinaryWriter bw, ushort[] buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
bw.Write(buffer[i]);
|
||||
}
|
||||
|
||||
public static int[] ReadInt32s(this BinaryReader br, int num)
|
||||
{
|
||||
int[] ret = new int[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
ret[i] = br.ReadInt32();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static short[] ReadInt16s(this BinaryReader br, int num)
|
||||
{
|
||||
short[] ret = new short[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
ret[i] = br.ReadInt16();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ushort[] ReadUInt16s(this BinaryReader br, int num)
|
||||
{
|
||||
ushort[] ret = new ushort[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
ret[i] = br.ReadUInt16();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this byte[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 2 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 2 < hex.Length; i++)
|
||||
{
|
||||
string bytehex = "" + hex[i * 2] + hex[i * 2 + 1];
|
||||
buffer[i] = byte.Parse(bytehex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
private static int Hex2Int(char c)
|
||||
{
|
||||
if (c <= '9')
|
||||
return c - '0';
|
||||
else if (c <= 'F')
|
||||
return c - '7';
|
||||
else
|
||||
return c - 'W';
|
||||
}
|
||||
|
||||
public static void ReadFromHexFast(this byte[] buffer, string hex)
|
||||
{
|
||||
//if (hex.Length % 2 != 0)
|
||||
// throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 2 < hex.Length; i++)
|
||||
{
|
||||
buffer[i] = (byte)(Hex2Int(hex[i * 2]) * 16 + Hex2Int(hex[i * 2 + 1]));
|
||||
}
|
||||
/*
|
||||
var b = new byte[buffer.Length];
|
||||
b.ReadFromHex(hex);
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
if (b[i] != buffer[i])
|
||||
throw new Exception();
|
||||
}*/
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this short[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 4 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++)
|
||||
{
|
||||
string shorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3];
|
||||
buffer[i] = short.Parse(shorthex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this ushort[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 4 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++)
|
||||
{
|
||||
string ushorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3];
|
||||
buffer[i] = ushort.Parse(ushorthex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadFromHex(this int[] buffer, string hex)
|
||||
{
|
||||
if (hex.Length % 8 != 0)
|
||||
throw new Exception("Hex value string does not appear to be properly formatted.");
|
||||
for (int i = 0; i < buffer.Length && i * 8 < hex.Length; i++)
|
||||
{
|
||||
//string inthex = "" + hex[i * 8] + hex[(i * 8) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3] + hex[(i*4
|
||||
string inthex = hex.Substring(i*8,8);
|
||||
buffer[i] = int.Parse(inthex, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
|
||||
//public static void SaveAsHex(this uint[] buffer, BinaryWriter bw)
|
||||
//{
|
||||
// for (int i = 0; i < buffer.Length; i++)
|
||||
// bw.Write(buffer[i]);
|
||||
//}
|
||||
|
||||
//these don't work??? they dont get chosen by compiler
|
||||
public static void WriteBit(this BinaryWriter bw, Bit bit) { bw.Write((bool)bit); }
|
||||
public static Bit ReadBit(this BinaryReader br) { return br.ReadBoolean(); }
|
||||
}
|
||||
|
||||
public static class Colors
|
||||
{
|
||||
|
@ -471,34 +31,6 @@ namespace BizHawk
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//I think this is a little faster with uint than with byte
|
||||
public struct Bit
|
||||
{
|
||||
Bit(uint val) { this.val = val; }
|
||||
uint val;
|
||||
public static implicit operator Bit(int rhs) { Debug.Assert((rhs & ~1) == 0); return new Bit((uint)(rhs)); }
|
||||
public static implicit operator Bit(uint rhs) { Debug.Assert((rhs & ~1) == 0); return new Bit((uint)(rhs)); }
|
||||
public static implicit operator Bit(byte rhs) { Debug.Assert((rhs & ~1) == 0); return new Bit((uint)(rhs)); }
|
||||
public static implicit operator Bit(bool rhs) { return new Bit(rhs ? (byte)1 : (byte)0); }
|
||||
public static implicit operator long(Bit rhs) { return (long)rhs.val; }
|
||||
public static implicit operator int(Bit rhs) { return (int)rhs.val; }
|
||||
public static implicit operator uint(Bit rhs) { return (uint)rhs.val; }
|
||||
public static implicit operator byte(Bit rhs) { return (byte)rhs.val; }
|
||||
public static implicit operator bool(Bit rhs) { return rhs.val != 0; }
|
||||
public override string ToString()
|
||||
{
|
||||
return val.ToString();
|
||||
}
|
||||
public static bool operator ==(Bit lhs, Bit rhs) { return lhs.val == rhs.val; }
|
||||
public static bool operator !=(Bit lhs, Bit rhs) { return lhs.val != rhs.val; }
|
||||
public override int GetHashCode() { return val.GetHashCode(); }
|
||||
public override bool Equals(object obj) { return this == (Bit)obj; } //this is probably wrong
|
||||
}
|
||||
|
||||
|
||||
|
||||
public unsafe static class Util
|
||||
{
|
||||
static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
|
|
|
@ -22,6 +22,7 @@ using BizHawk.Emulation.Consoles.Nintendo.SNES;
|
|||
using BizHawk.Emulation.Consoles.Sega;
|
||||
using BizHawk.Emulation.Consoles.TurboGrafx;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
|
|
|
@ -12,6 +12,7 @@ using Microsoft.VisualBasic.ApplicationServices;
|
|||
|
||||
#pragma warning disable 618
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
|
@ -68,6 +69,8 @@ namespace BizHawk.MultiClient
|
|||
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath, new Config());
|
||||
Global.Config.ResolveDefaults();
|
||||
|
||||
BizHawk.Common.HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();
|
||||
|
||||
#if WINDOWS
|
||||
try { GlobalWinF.DSound = SoundEnumeration.Create(); }
|
||||
catch
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue