Skip to content

Commit

Permalink
release updated for 1.10.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
hegyak committed Jun 15, 2015
1 parent 6e535d5 commit 7c3b3c8
Show file tree
Hide file tree
Showing 161 changed files with 18,384 additions and 8,180 deletions.
7 changes: 4 additions & 3 deletions BizHawk.Client.Common/BinarySaveStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,14 @@ private static void WriteVersion(Stream s)
}


public BinaryStateSaver(string path, bool stateVersionTag = true) // stateVersionTag is a hack for reusing this for movie code
public BinaryStateSaver(string path, bool notamovie = true) // notamovie is hack, really should have separate something
{
_zip = new IonicZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
_zip = new IonicZipWriter(path, notamovie ? Global.Config.SaveStateCompressionLevelNormal
: Global.Config.MovieCompressionLevel);
//_zip = new SharpZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
//_zip = new SevenZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);

if (stateVersionTag)
if (notamovie)
{
PutLump(BinaryStateLump.Versiontag, WriteVersion);
}
Expand Down
1 change: 1 addition & 0 deletions BizHawk.Client.Common/BizHawk.Client.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<Compile Include="lua\LuaFile.cs" />
<Compile Include="lua\LuaFileList.cs" />
<Compile Include="lua\LuaFunctionList.cs" />
<Compile Include="lua\LuaHelper.cs" />
<Compile Include="lua\LuaLibraryBase.cs" />
<Compile Include="lua\LuaMemoryBase.cs" />
<Compile Include="lua\NamedLuaFunction.cs" />
Expand Down
6 changes: 5 additions & 1 deletion BizHawk.Client.Common/CoreFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CoreFileProvider(Action<string> showWarning)

public string PathSubfile(string fname)
{
return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname);
return Path.Combine(SubfileDirectory ?? String.Empty, fname);
}

public string DllPath()
Expand Down Expand Up @@ -110,7 +110,11 @@ public byte[] GetFirmwareWithGameInfo(string sysID, string firmwareID, bool requ
// this should go away now
public static void SyncCoreCommInputSignals(CoreComm target)
{
string superhack = null;
if (target.CoreFileProvider != null && target.CoreFileProvider is CoreFileProvider)
superhack = ((CoreFileProvider)target.CoreFileProvider ).SubfileDirectory;
var cfp = new CoreFileProvider(target.ShowMessage);
cfp.SubfileDirectory = superhack;
target.CoreFileProvider = cfp;
cfp.FirmwareManager = Global.FirmwareManager;
}
Expand Down
20 changes: 14 additions & 6 deletions BizHawk.Client.Common/IPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BizHawk.Client.Common
{
public static class IPS
{
public static void Patch(byte[] rom, Stream patch)
public static byte[] Patch(byte[] rom, Stream patch)
{
var ipsHeader = new byte[5];
patch.Read(ipsHeader, 0, 5);
Expand All @@ -16,32 +16,40 @@ public static void Patch(byte[] rom, Stream patch)
if (ipsHeader[i] != header[i])
{
Console.WriteLine("Patch file specified is invalid.");
return;
return null;
}
}

// header verified, loop over patch entries
uint EOF = ('E' * 0x10000 + 'O' * 0x100 + 'F');

var ret = new MemoryStream(rom.Length);
ret.Write(rom, 0, rom.Length);

while (true)
{
uint offset = Read24(patch);
if (offset == EOF) return;
if (offset == EOF)
return ret.ToArray();
ushort size = Read16(patch);

ret.Seek(offset, SeekOrigin.Begin);

if (size != 0) // non-RLE patch
{
var patchData = new byte[size];
patch.Read(patchData, 0, size);
for (int i = 0; i < size; i++)
rom[offset++] = patchData[i];

ret.Write(patchData, 0, patchData.Length);
}
else // RLE patch
{
size = Read16(patch);
byte value = (byte)patch.ReadByte();
for (int i = 0; i < size; i++)
rom[offset++] = value;
{
ret.WriteByte(value);
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions BizHawk.Client.Common/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ public static string SaveStatePrefix(GameInfo game)
name += "." + (Global.Emulator as LibsnesCore).CurrentProfile;
}

if (Global.Emulator.SystemId == "GBA")
{
name += "." + Global.Emulator.Attributes().CoreName;
}

if (Global.MovieSession.Movie.IsActive)
{
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
Expand Down
3 changes: 2 additions & 1 deletion BizHawk.Client.Common/RomGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public RomGame(HawkFile file, string patch)

// read the entire file into FileData.
FileData = new byte[fileLength];
stream.Position = 0;
stream.Read(FileData, 0, fileLength);

// if there was no header offset, RomData is equivalent to FileData
Expand Down Expand Up @@ -90,7 +91,7 @@ public RomGame(HawkFile file, string patch)
patchFile.BindFirstOf("IPS");
if (patchFile.IsBound)
{
IPS.Patch(RomData, patchFile.GetStream());
RomData = IPS.Patch(RomData, patchFile.GetStream());
}
}
}
Expand Down
76 changes: 61 additions & 15 deletions BizHawk.Client.Common/RomLoader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common;
Expand Down Expand Up @@ -159,8 +160,15 @@ private bool PreferredPlatformIsDefined(string extension)
return false;
}

public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = false) // forceAccurateCore is currently just for Quicknes vs Neshawk but could be used for other situations
public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = false,
int recursiveCount = 0) // forceAccurateCore is currently just for Quicknes vs Neshawk but could be used for other situations
{
if (recursiveCount > 1) // hack to stop recursive calls from endlessly rerunning if we can't load it
{
DoLoadErrorCallback("Failed multiple attempts to load ROM.", "");
return false;
}

bool cancel = false;

if (path == null)
Expand Down Expand Up @@ -322,29 +330,59 @@ private bool PreferredPlatformIsDefined(string extension)

switch (game.System)
{
case "GB":
case "DGB":
var left = Database.GetGameInfo(xmlGame.Assets["LeftRom"], "left.gb");
var right = Database.GetGameInfo(xmlGame.Assets["RightRom"], "right.gb");
// adelikat: remove need for tags to be hardcoded to left and right, we should clean this up, also maybe the DGB core should just take the xml file and handle it itself
var leftBytes = xmlGame.Assets.First().Value;
var rightBytes = xmlGame.Assets.Skip(1).First().Value;

var left = Database.GetGameInfo(leftBytes, "left.gb");
var right = Database.GetGameInfo(rightBytes, "right.gb");
nextEmulator = new GambatteLink(
nextComm,
left,
xmlGame.Assets["LeftRom"],
leftBytes,
right,
xmlGame.Assets["RightRom"],
rightBytes,
GetCoreSettings<GambatteLink>(),
GetCoreSyncSettings<GambatteLink>(),
Deterministic);

// other stuff todo
break;
case "AppleII":
var assets = xmlGame.Assets.Select(a => Database.GetGameInfo(a.Value, a.Key));
var roms = xmlGame.Assets.Select(a => a.Value);
nextEmulator = new AppleII(
nextComm,
assets,
roms);
break;
default:
return false;
}
}
catch (Exception ex)
{
DoLoadErrorCallback(ex.ToString(), "DGB", LoadErrorType.XML);
return false;
try
{
// 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
byte[] romData = null;
byte[] xmlData = rom.FileData;

game = rom.GameInfo;
game.System = "SNES";

var snes = new LibsnesCore(game, romData, Deterministic, xmlData, nextComm, GetCoreSettings<LibsnesCore>(), GetCoreSyncSettings<LibsnesCore>());
nextEmulator = snes;
}
catch
{
DoLoadErrorCallback(ex.ToString(), "DGB", LoadErrorType.XML);
return false;
}
}
}
else // most extensions
Expand All @@ -369,7 +407,7 @@ private bool PreferredPlatformIsDefined(string extension)
var result = ChoosePlatform(rom);
if (!string.IsNullOrEmpty(result))
{
rom.GameInfo.System = ChoosePlatform(rom);
rom.GameInfo.System = result;
}
else
{
Expand Down Expand Up @@ -473,13 +511,16 @@ private bool PreferredPlatformIsDefined(string extension)
var c64 = new C64(nextComm, game, rom.RomData, rom.Extension);
nextEmulator = c64;
break;
case "AppleII":
var appleII = new AppleII(nextComm, game, rom.RomData, rom.Extension);
nextEmulator = appleII;
break;
case "GBA":
//core = CoreInventory.Instance["GBA", "Meteor"];
core = CoreInventory.Instance["GBA", "VBA-Next"];
if (Global.Config.GBA_UsemGBA)
{
core = CoreInventory.Instance["GBA", "mGBA"];
}
else
{
core = CoreInventory.Instance["GBA", "VBA-Next"];
}
break;
case "PSX":
nextEmulator = new Octoshock(nextComm, null, null, rom.FileData, GetCoreSettings<Octoshock>(), GetCoreSyncSettings<Octoshock>());
Expand Down Expand Up @@ -526,7 +567,12 @@ private bool PreferredPlatformIsDefined(string extension)
// Specific hack here, as we get more cores of the same system, this isn't scalable
if (ex is UnsupportedGameException)
{
return LoadRom(path, nextComm, forceAccurateCore: true);
if (system == "NES")
{
DoMessageCallback("Unable to use quicknes, using NESHawk instead");
}

return LoadRom(path, nextComm, true, recursiveCount + 1);
}
else if (ex is MissingFirmwareException)
{
Expand All @@ -536,7 +582,7 @@ private bool PreferredPlatformIsDefined(string extension)
{
// Note: GB as SGB was set to false by this point, otherwise we would want to do it here
DoMessageCallback("Failed to load a GB rom in SGB mode. Disabling SGB Mode.");
return LoadRom(path, nextComm);
return LoadRom(path, nextComm, false, recursiveCount + 1);
}
else
{
Expand Down
36 changes: 28 additions & 8 deletions BizHawk.Client.Common/XmlGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ namespace BizHawk.Client.Common
{
public class XmlGame
{
public XmlGame()
{
Assets = new List<KeyValuePair<string, byte[]>>();
GI = new GameInfo();
}

public XmlDocument Xml { get; set; }
public GameInfo GI = new GameInfo();
public Dictionary<string, byte[]> Assets = new Dictionary<string, byte[]>();
public GameInfo GI { get; set; }
public IList<KeyValuePair<string, byte[]>> Assets { get; set; }

public static XmlGame Create(HawkFile f)
{
Expand Down Expand Up @@ -48,9 +54,8 @@ public static XmlGame Create(HawkFile f)

foreach (XmlNode a in n.ChildNodes)
{
string name = a.Name;
string filename = a.Attributes["FileName"].Value;
byte[] data;
byte[] data = new byte[0];
if (filename[0] == '|')
{
// in same archive
Expand All @@ -68,7 +73,7 @@ public static XmlGame Create(HawkFile f)
}
else
{
throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
throw new Exception("Couldn't load XMLGame Asset \"" + filename + "\"");
}
}
else
Expand All @@ -78,15 +83,30 @@ public static XmlGame Create(HawkFile f)
fullpath = Path.Combine(fullpath, filename.Split('|').First());
try
{
data = File.ReadAllBytes(fullpath.Split('|').First());
using (var hf = new HawkFile(fullpath))
{
if (hf.IsArchive)
{
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
hf.Unbind();
hf.BindArchiveMember(archiveItem);
data = hf.GetStream().ReadAllBytes();
}
else
{
data = File.ReadAllBytes(fullpath.Split('|').First());
}
}


}
catch
{
throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
throw new Exception("Couldn't load XMLGame LoadAsset \"" + filename + "\"");
}
}

ret.Assets[name] = data;
ret.Assets.Add(new KeyValuePair<string, byte[]>(filename, data));

using (var sha1 = System.Security.Cryptography.SHA1.Create())
{
Expand Down
2 changes: 2 additions & 0 deletions BizHawk.Client.Common/config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public enum ClientProfile
public int SaveStateCompressionLevelNormal = DefaultSaveStateCompressionLevelNormal;
public const int DefaultSaveStateCompressionLevelRewind = 0;//this isnt actually used yet
public int SaveStateCompressionLevelRewind = DefaultSaveStateCompressionLevelRewind;//this isnt actually used yet
public int MovieCompressionLevel = 2;

/// <summary>use vsync. if VSyncThrottle = false, this will try to use vsync without throttling to it</summary>
public bool VSync = false;
Expand Down Expand Up @@ -410,6 +411,7 @@ public AnalogBind(string Value, float Mult, float Deadzone)
public bool GB_AsSGB = false;
public bool NES_InQuickNES = true;
public bool SNES_InSnes9x = false;
public bool GBA_UsemGBA = false;
}

// These are used in the defctrl.json or wherever
Expand Down
11 changes: 9 additions & 2 deletions BizHawk.Client.Common/config/PathEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ public static List<PathEntry> DefaultValues
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 4 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 5 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 6 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Watch (.wch)", Path = ".", Ordinal = 7 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Watch (.wch)", Path = Path.Combine(".", "Tools"), Ordinal = 7 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "A/V Dumps", Path = ".", Ordinal = 8 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Debug Logs", Path = ".", Ordinal = 9 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Debug Logs", Path = Path.Combine(".", "Tools"), Ordinal = 9 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Macros", Path = Path.Combine(".", "Movies", "Macros"), Ordinal = 10 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "TAStudio states", Path = Path.Combine(".", "Movies", "TAStudio states"), Ordinal = 11 },
new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Multi-Disk Bundles", Path = Path.Combine(".", "Tools"), Ordinal = 12 },

new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Base", Path = Path.Combine(".", "Intellivision"), Ordinal = 0 },
new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "ROM", Path = ".", Ordinal = 1 },
Expand Down Expand Up @@ -304,6 +305,12 @@ public static List<PathEntry> DefaultValues
new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },

new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Base", Path = Path.Combine(".", "Lynx"), Ordinal = 0 },
new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
};
}
}
Expand Down
Loading

0 comments on commit 7c3b3c8

Please sign in to comment.