From 6e1cde27938ea4cd9301bc9fbceba58ea3df3179 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 20 Jul 2015 23:11:00 -0500 Subject: [PATCH] hookup PSF support --- BizHawk.Client.Common/RomLoader.cs | 33 ++++++++++++++----- BizHawk.Client.EmuHawk/MainForm.cs | 4 +-- BizHawk.Client.MultiHawk/Mainform.cs | 2 +- BizHawk.Emulation.Common/Database/Database.cs | 1 + BizHawk.Emulation.Cores/FileID.cs | 3 +- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index c5198cc317..063328eccd 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -238,7 +238,7 @@ namespace BizHawk.Client.Common try { - var ext = file.Extension.ToLower(); + var ext = file.Extension.ToLowerInvariant(); if (ext == ".m3u") { //HACK ZONE - currently only psx supports m3u @@ -398,7 +398,7 @@ namespace BizHawk.Client.Common break; } } - else if (file.Extension.ToLower() == ".xml") + else if (file.Extension.ToLowerInvariant() == ".xml") { try { @@ -463,22 +463,39 @@ namespace BizHawk.Client.Common } } } + else if (file.Extension.ToLowerInvariant() == ".psf" || file.Extension.ToLowerInvariant() == ".minipsf") + { + Func cbDeflater = (Stream instream, int size) => + { + var inflater = new ICSharpCode.SharpZipLib.Zip.Compression.Inflater(false); + var iis = new ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(instream, inflater); + MemoryStream ret = new MemoryStream(); + iis.CopyTo(ret); + return ret.ToArray(); + }; + PSF psf = new PSF(); + psf.Load(path, cbDeflater); + nextEmulator = new Octoshock(nextComm, psf, GetCoreSettings(), GetCoreSyncSettings()); + nextEmulator.CoreComm.RomStatusDetails = "It's a PSF, what do you want."; + + //total garbage, this + rom = new RomGame(file); + game = rom.GameInfo; + } else // most extensions { rom = new RomGame(file); //hacky for now - if (file.Extension.ToLower() == ".exe") - { + if (file.Extension.ToLowerInvariant() == ".exe") rom.GameInfo.System = "PSX"; - } if (string.IsNullOrEmpty(rom.GameInfo.System)) { // Has the user picked a preference for this extension? - if (PreferredPlatformIsDefined(rom.Extension.ToLower())) + if (PreferredPlatformIsDefined(rom.Extension.ToLowerInvariant())) { - rom.GameInfo.System = Global.Config.PreferredPlatformsForExtensions[rom.Extension.ToLower()]; + rom.GameInfo.System = Global.Config.PreferredPlatformsForExtensions[rom.Extension.ToLowerInvariant()]; } else if (ChoosePlatform != null) { @@ -499,7 +516,7 @@ namespace BizHawk.Client.Common var isXml = false; // other xml has already been handled - if (file.Extension.ToLower() == ".xml") + if (file.Extension.ToLowerInvariant() == ".xml") { game.System = "SNES"; isXml = true; diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index ce3e4f6018..9c9843d5ee 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1864,7 +1864,7 @@ namespace BizHawk.Client.EmuHawk { return FormatFilter( "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.lnx;*.m3u;*.cue;*.ccd;*.exe;*.gb;*.gbc;*.gba;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;*.dsk;*.do;*.po;%ARCH%", - "Music Files", "*.psf;*.sid;*.nsf", + "Music Files", "*.psf;*.minipsf;*.sid;*.nsf", "Disc Images", "*.cue;*.ccd;*.m3u", "NES", "*.nes;*.fds;*.nsf;%ARCH%", "Super NES", "*.smc;*.sfc;*.xml;%ARCH%", @@ -1882,7 +1882,7 @@ namespace BizHawk.Client.EmuHawk "Colecovision", "*.col;%ARCH%", "Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%", "PSX Executables (experimental)", "*.exe", - "PSF Playstation Sound File (not supported)", "*.psf", + "PSF Playstation Sound File", "*.psf;*.minipsf", "Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%", "SID Commodore 64 Music File", "*.sid;%ARCH%", "Nintendo 64", "*.z64;*.v64;*.n64", diff --git a/BizHawk.Client.MultiHawk/Mainform.cs b/BizHawk.Client.MultiHawk/Mainform.cs index f913a775f5..4483834a48 100644 --- a/BizHawk.Client.MultiHawk/Mainform.cs +++ b/BizHawk.Client.MultiHawk/Mainform.cs @@ -217,7 +217,7 @@ namespace BizHawk.Client.MultiHawk "Colecovision", "*.col;%ARCH%", "Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%", "PSX Executables (experimental)", "*.exe", - "PSF Playstation Sound File (not supported)", "*.psf", + "PSF Playstation Sound File", "*.psf;*.minipsf", "Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%", "SID Commodore 64 Music File", "*.sid;%ARCH%", "Nintendo 64", "*.z64;*.v64;*.n64", diff --git a/BizHawk.Emulation.Common/Database/Database.cs b/BizHawk.Emulation.Common/Database/Database.cs index 44f9035e4e..16d6b65e85 100644 --- a/BizHawk.Emulation.Common/Database/Database.cs +++ b/BizHawk.Emulation.Common/Database/Database.cs @@ -284,6 +284,7 @@ namespace BizHawk.Emulation.Common break; case ".PSF": + case ".MINIPSF": game.System = "PSX"; break; diff --git a/BizHawk.Emulation.Cores/FileID.cs b/BizHawk.Emulation.Cores/FileID.cs index 3367a04906..edc5252484 100644 --- a/BizHawk.Emulation.Cores/FileID.cs +++ b/BizHawk.Emulation.Cores/FileID.cs @@ -280,6 +280,7 @@ namespace BizHawk.Emulation.Cores public static SimpleMagicRecord PSX = new SimpleMagicRecord { Offset = 0x24E0, Key = " Licensed by Sony Computer Entertainment" }; //there might be other ideas for checking in mednafen sources, if we need them public static SimpleMagicRecord PSX_EXE = new SimpleMagicRecord { Key = "PS-X EXE\0" }; public static SimpleMagicRecord PSP = new SimpleMagicRecord { Offset = 0x8000, Key = "\x01CD001\x01\0x00PSP GAME" }; + public static SimpleMagicRecord PSF = new SimpleMagicRecord { Offset = 0, Key = "PSF\x1" }; //https://sites.google.com/site/atari7800wiki/a78-header public static SimpleMagicRecord A78 = new SimpleMagicRecord { Offset = 0, Key = "\x01ATARI7800" }; @@ -348,7 +349,7 @@ namespace BizHawk.Emulation.Cores { "GEN", new ExtensionInfo(FileIDType.SMD, null ) }, //nothing yet... - { "PSF", new ExtensionInfo(FileIDType.PSF, null) }, + { "PSF", new ExtensionInfo(FileIDType.PSF, (j)=>Test_Simple(j,FileIDType.PSF,SimpleMagics.PSF) ) }, { "INT", new ExtensionInfo(FileIDType.INT, null) }, { "SFC", new ExtensionInfo(FileIDType.SFC, null) }, { "SMC", new ExtensionInfo(FileIDType.SFC, null) },