pizza boy: add the required SPC file as an embedded resource because zeromus said to

This commit is contained in:
nattthebear 2017-07-01 09:06:04 -04:00
parent 94050c161b
commit bdfb859480
6 changed files with 38 additions and 15 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Text;
@ -428,6 +429,24 @@ namespace BizHawk.Common
return true;
}
public static byte[] DecompressGzipFile(Stream src)
{
var tmp = new byte[4];
if (src.Read(tmp, 0, 2) != 2)
throw new InvalidOperationException("Unexpected end of stream");
if (tmp[0] != 0x1f || tmp[1] != 0x8b)
throw new InvalidOperationException("GZIP header not present");
src.Seek(-4, SeekOrigin.End);
src.Read(tmp, 0, 4);
int size = BitConverter.ToInt32(tmp, 0);
var data = new byte[size];
var ms = new MemoryStream(data);
src.Seek(0, SeekOrigin.Begin);
using (var gs = new GZipStream(src, CompressionMode.Decompress, true))
gs.CopyTo(ms);
return data;
}
}
public static class BitConverterLE

View File

@ -30,8 +30,6 @@ namespace BizHawk.Emulation.Common
FirmwareAndOption("A3AF676991391A6DD716C79022D4947206B78164", 4096, "A78", "Bios_HSC", "7800highscore.bin", "Highscore Bios");
FirmwareAndOption("45BEDC4CBDEAC66C7DF59E9E599195C778D86A92", 8192, "Coleco", "Bios", "ColecoBios.bin", "Bios");
FirmwareAndOption("079a7ce93f3fd7d35e444b2fab16b1867c95e2c1", 66084, "SGB", "SPC", "sgb.spc", "Super Gameboy SPC");
var gbaNormal = File("300C20DF6731A33952DED8C436F7F186D25D3492", 16384, "gbabios.rom", "Bios (World)");
var gbaJDebug = File("AA98A2AD32B86106340665D1222D7D973A1361C7", 16384, "gbabios.rom", "Bios (J Debug)");
Firmware("GBA", "Bios", "Bios");

View File

@ -1242,6 +1242,11 @@
<Compile Include="CPUs\Z80\Registers.cs" />
<Compile Include="CPUs\Z80\Tables.cs" />
<Compile Include="CPUs\Z80\Z80A.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="SideBySideVideo.cs" />
<Compile Include="Sound\DualSyncSound.cs" />
<Compile Include="Waterbox\CustomSaverammer.cs" />
@ -1313,7 +1318,12 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BizHawk.Common\BizHawk.Common.csproj">
<Project>{866F8D13-0678-4FF9-80A4-A3993FD4D8A3}</Project>
@ -1335,6 +1345,7 @@
<None Include="Consoles\Nintendo\NES\Docs\BoardTable.xlsx" />
<None Include="Consoles\Nintendo\NES\Docs\MapperCompatibilityList.url" />
<None Include="Consoles\Nintendo\NES\Docs\nesasm.pdf" />
<None Include="Resources\sgb-cart-present.spc.gz" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@ -4,6 +4,7 @@ using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Waterbox;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -19,12 +20,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
[CoreConstructor("SGB")]
public Pizza(byte[] rom, CoreComm comm)
:this(rom, comm, true)
: this(rom, comm, true)
{ }
[CoreConstructor("GB")]
public Pizza(CoreComm comm, byte[] rom)
:this(rom, comm, false)
: this(rom, comm, false)
{ }
public Pizza(byte[] rom, CoreComm comm, bool sgb)
@ -54,7 +55,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
MmapHeapSizeKB = 0
});
var spc = sgb ? comm.CoreFileProvider.GetFirmware("SGB", "SPC", true) : new byte[0];
var spc = sgb
? Util.DecompressGzipFile(new MemoryStream(Properties.Resources.SgbCartPresent_SPC))
: new byte[0];
_sgb = sgb;
if (!_pizza.Init(rom, rom.Length, _sgb, spc, spc.Length))
{

View File

@ -698,15 +698,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
{
using (var fs = new FileStream(gzpath, FileMode.Open, FileAccess.Read))
{
var tmp = new byte[4];
fs.Seek(-4, SeekOrigin.End);
fs.Read(tmp, 0, 4);
int size = BitConverter.ToInt32(tmp, 0);
data = new byte[size];
var ms = new MemoryStream(data);
fs.Seek(0, SeekOrigin.Begin);
using (var gs = new GZipStream(fs, CompressionMode.Decompress))
gs.CopyTo(ms);
data = Util.DecompressGzipFile(fs);
}
}
else