Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-05 07:05:16 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-05 07:05:16 +0300
commit01c8b9149f139648ed53fe175bbc955443c2ef01 (patch)
tree5e9ae2af9d2cf2602bbf4ca40ee2348f4af06d2a
parente0b2f51d15924c3353393072be25f8bb3d3e45d2 (diff)
Huge refactoring. Testing required. But need to sleep.
-rw-r--r--Apps/AppTypeCollection.cs36
-rw-r--r--Apps/FdsGame.cs47
-rw-r--r--Apps/ICloverAutofill.cs13
-rw-r--r--Apps/INesMenuElement.cs (renamed from INesMenuElement.cs)0
-rw-r--r--Apps/ISupportsGameGenie.cs14
-rw-r--r--Apps/NesGame.cs130
-rw-r--r--Apps/NesMiniApplication.cs310
-rw-r--r--Apps/SnesGame.cs9
-rw-r--r--GameGenieCodeAddModForm.cs18
-rw-r--r--GameGenieCodeForm.cs8
-rw-r--r--ImageGooglerForm.cs2
-rw-r--r--MainForm.Designer.cs19
-rw-r--r--MainForm.cs103
-rw-r--r--MainForm.resx142
-rw-r--r--NesFile.cs9
-rw-r--r--Properties/Resources.Designer.cs12
-rw-r--r--Properties/Resources.resx3
-rw-r--r--WorkerForm.cs104
-rw-r--r--hakchi_gui.csproj4
-rw-r--r--mods/hmods/tiny7zx-dynamic.hmodbin0 -> 19325 bytes
-rw-r--r--mods/mod_hakchi/hakchi/rootfs/bin/chmenu5
-rw-r--r--mods/mod_hakchi/hakchi/rootfs/bin/clover-canoe-shvc-wr24
-rw-r--r--mods/mod_hakchi/hakchi/rootfs/bin/clover-kachikachi-wr22
-rw-r--r--mods/mod_hakchi/hakchi/rootfs/bin/mcp-restarter10
-rw-r--r--mods/mod_hakchi/hakchi/rootfs/etc/init.d/S82mcp-restarter26
25 files changed, 677 insertions, 393 deletions
diff --git a/Apps/AppTypeCollection.cs b/Apps/AppTypeCollection.cs
index 79061fa3..a43ee78e 100644
--- a/Apps/AppTypeCollection.cs
+++ b/Apps/AppTypeCollection.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
+using System.Text.RegularExpressions;
namespace com.clusterrr.hakchi_gui
{
@@ -24,25 +25,33 @@ namespace com.clusterrr.hakchi_gui
{
new AppInfo
{
- Class = typeof(FdsGame),
- Extensions = new string[] {".fds"},
- DefaultApps = new string[] {},
- Prefix = 'D',
- DefaultCover = Resources.blank_fds
+ Class = typeof(NesGame),
+ Extensions = new string[] {".nes"},
+ DefaultApps = new string[] {"/bin/clover-kachikachi-wr", "/bin/clover-kachikachi", "/bin/nes"},
+ Prefix = 'H',
+ DefaultCover = Resources.blank_nes
},
new AppInfo
{
Class = typeof(NesUGame),
- Extensions = new string[] {".nes", ".unf", ".unif"},
+ Extensions = new string[] {".unf", ".unif", ".nes", ".fds" },
DefaultApps = new string[] {"/bin/nes"},
Prefix = 'I',
DefaultCover = Resources.blank_jp
},
new AppInfo
{
+ Class = typeof(FdsGame),
+ Extensions = new string[] {".fds"},
+ DefaultApps = new string[] {"/bin/clover-kachikachi-wr", "/bin/clover-kachikachi", "/bin/nes"},
+ Prefix = 'D',
+ DefaultCover = Resources.blank_fds
+ },
+ new AppInfo
+ {
Class = typeof(SnesGame),
- Extensions = new string[] { ".sfc", ".smc" },
- DefaultApps = new string[] {"/bin/snes"},
+ Extensions = new string[] { ".sfc", ".smc", ".sfrom" },
+ DefaultApps = new string[] {"/usr/bin/clover-canoe-shvc", "/bin/snes"},
Prefix = 'U',
DefaultCover = Resources.blank_snes_us
},
@@ -146,10 +155,19 @@ namespace com.clusterrr.hakchi_gui
public static AppInfo GetAppByExec(string exec)
{
+ exec = Regex.Replace(exec, "['\\\"]|(\\.7z)", " ")+" ";
foreach (var app in ApplicationTypes)
foreach (var cmd in app.DefaultApps)
if (exec.StartsWith(cmd + " "))
- return app;
+ {
+ if (app.Extensions.Length == 0)
+ return app;
+ foreach (var ext in app.Extensions)
+ {
+ if (exec.Contains(ext + " "))
+ return app;
+ }
+ }
return null;
}
}
diff --git a/Apps/FdsGame.cs b/Apps/FdsGame.cs
index acb656c1..f5072215 100644
--- a/Apps/FdsGame.cs
+++ b/Apps/FdsGame.cs
@@ -11,62 +11,35 @@ namespace com.clusterrr.hakchi_gui
public class FdsGame : NesMiniApplication
{
const string DefaultArgs = "--guest-overscan-dimensions 0,0,9,3 --initial-fadein-durations 10,2 --volume 75 --enable-armet --fds-auto-disk-side-switch-on-keypress";
+ const char Prefix = 'D';
public override string GoogleSuffix
{
get
{
- return "fds";
+ return "(fds | nes | famicom)";
}
}
- public string Args
- {
- get
- {
- if (Command.Contains(".fds"))
- return Command.Substring(Command.IndexOf(".fds") + 4).Trim();
- else
- return "";
- }
- set
- {
- Command = string.Format("/bin/clover-kachikachi-wr /usr/share/games/nes/kachikachi/{0}/{0}.fds {1}", code, value);
- }
- }
-
public FdsGame(string path, bool ignoreEmptyConfig = false)
: base(path, ignoreEmptyConfig)
{
- Args = Args; // To update exec path if need
}
- public static FdsGame Import(string fdsFileName, string sourceFileName, byte[] rawRomData = null)
+ public static bool Patch(string inputFileName, ref byte[] rawRomData, ref char prefix, ref string application, ref string outputFileName, ref string args, ref Image cover, ref uint crc32)
{
- if (rawRomData == null)
- rawRomData = File.ReadAllBytes(fdsFileName);
+ FindPatch(ref rawRomData, inputFileName, crc32);
if (Encoding.ASCII.GetString(rawRomData, 0, 3) == "FDS") // header? cut it!
{
var fdsDataNoHeader = new byte[rawRomData.Length - 0x10];
Array.Copy(rawRomData, 0x10, fdsDataNoHeader, 0, fdsDataNoHeader.Length);
rawRomData = fdsDataNoHeader;
- }
- var crc32 = CRC32(rawRomData);
- var code = GenerateCode(crc32, DefaultPrefix);
- var gamePath = Path.Combine(GamesDirectory, code);
- var fdsPath = Path.Combine(gamePath, code + ".fds");
- Directory.CreateDirectory(gamePath);
- File.WriteAllBytes(fdsPath, rawRomData);
- var game = new FdsGame(gamePath, true);
-
- game.Name = Path.GetFileNameWithoutExtension(fdsFileName);
- game.Name = Regex.Replace(game.Name, @" ?\(.*?\)", string.Empty).Trim();
- game.Name = Regex.Replace(game.Name, @" ?\[.*?\]", string.Empty).Trim();
- game.Name = game.Name.Replace("_", " ").Replace(" ", " ").Trim();
- game.FindCover(fdsFileName, sourceFileName, Resources.blank_fds, crc32);
- game.Args = DefaultArgs;
- game.Save();
- return game;
+ crc32 = CRC32(rawRomData);
+ // Try to find patch again, using new CRC
+ FindPatch(ref rawRomData, inputFileName, crc32);
+ }
+ args = DefaultArgs;
+ return true;
}
}
}
diff --git a/Apps/ICloverAutofill.cs b/Apps/ICloverAutofill.cs
new file mode 100644
index 00000000..50fb88c8
--- /dev/null
+++ b/Apps/ICloverAutofill.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+
+namespace com.clusterrr.hakchi_gui
+{
+ interface ICloverAutofill
+ {
+ bool TryAutofill(uint crc32);
+ }
+}
diff --git a/INesMenuElement.cs b/Apps/INesMenuElement.cs
index 18ece9a5..18ece9a5 100644
--- a/INesMenuElement.cs
+++ b/Apps/INesMenuElement.cs
diff --git a/Apps/ISupportsGameGenie.cs b/Apps/ISupportsGameGenie.cs
new file mode 100644
index 00000000..580572da
--- /dev/null
+++ b/Apps/ISupportsGameGenie.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace com.clusterrr.hakchi_gui
+{
+ interface ISupportsGameGenie
+ {
+ string GameGeniePath { get; }
+ string GameGenie { get; set; }
+ void ApplyGameGenie();
+ }
+}
diff --git a/Apps/NesGame.cs b/Apps/NesGame.cs
index 35a814d5..66dc86a7 100644
--- a/Apps/NesGame.cs
+++ b/Apps/NesGame.cs
@@ -4,6 +4,7 @@ using com.clusterrr.hakchi_gui.Properties;
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@@ -12,15 +13,16 @@ using System.Xml.XPath;
namespace com.clusterrr.hakchi_gui
{
- public class NesGame : NesMiniApplication
+ public class NesGame : NesMiniApplication, ICloverAutofill, ISupportsGameGenie
{
- public delegate bool NeedPatchDelegate(Form parentForm, string nesFileName);
public const char Prefix = 'H';
- public readonly string NesPath;
- public readonly string GameGeniePath;
-
- private string region = null;
+ public string GameGeniePath { private set; get; }
+ public static bool? IgnoreMapper;
const string DefaultArgs = "--guest-overscan-dimensions 0,0,9,3 --initial-fadein-durations 10,2 --volume 75 --enable-armet";
+ private static Dictionary<uint, CachedGameInfo> gameInfoCache = null;
+
+ public const string GameGenieFileName = "gamegenie.txt";
+ private static byte[] supportedMappers = new byte[] { 0, 1, 2, 3, 4, 5, 7, 9, 10, 86, 87, 184 };
public override string GoogleSuffix
{
@@ -30,20 +32,6 @@ namespace com.clusterrr.hakchi_gui
}
}
- public string Args
- {
- get
- {
- if (Command.Contains(".nes"))
- return Command.Substring(Command.IndexOf(".nes") + 4).Trim();
- else
- return "";
- }
- set
- {
- Command = string.Format("/bin/clover-kachikachi-wr /usr/share/games/nes/kachikachi/{0}/{0}.nes {1}", code, value);
- }
- }
private string gameGenie = "";
public string GameGenie
{
@@ -54,28 +42,76 @@ namespace com.clusterrr.hakchi_gui
gameGenie = value;
}
}
- public string Region
- {
- get { return region; }
- private set { region = value; }
- }
-
- private static Dictionary<uint, CachedGameInfo> gameInfoCache = null;
- public const string GameGenieFileName = "gamegenie.txt";
- private static byte[] supportedMappers = new byte[] { 0, 1, 2, 3, 4, 5, 7, 9, 10, 86, 87, 184 };
public NesGame(string path, bool ignoreEmptyConfig = false)
: base(path, ignoreEmptyConfig)
{
- NesPath = Path.Combine(GamePath, Code + ".nes");
- GameGeniePath = Path.Combine(path, GameGenieFileName);
- if (!File.Exists(NesPath)) throw new FileNotFoundException("Invalid game directory: " + path);
-
+ GameGeniePath = System.IO.Path.Combine(path, GameGenieFileName);
if (File.Exists(GameGeniePath))
gameGenie = File.ReadAllText(GameGeniePath);
- Args = Args; // To update exec path if need
}
+
+ public static bool Patch(string inputFileName, ref byte[] rawRomData, ref char prefix, ref string application, ref string outputFileName, ref string args, ref Image cover, ref uint crc32)
+ {
+ // Try to patch before mapper check, maybe it will patch mapper
+ FindPatch(ref rawRomData, inputFileName, crc32);
+ NesFile nesFile;
+ try
+ {
+ nesFile = new NesFile(rawRomData);
+ }
+ catch
+ {
+ application = "/bin/nes";
+ return true;
+ }
+ nesFile.CorrectRom();
+ crc32 = nesFile.CRC32;
+ if (ConfigIni.ConsoleType != MainForm.ConsoleType.NES && ConfigIni.ConsoleType != MainForm.ConsoleType.Famicom)
+ application = "/bin/nes";
+
+ //if (nesFile.Mapper == 71) nesFile.Mapper = 2; // games by Codemasters/Camerica - this is UNROM clone. One exception - Fire Hawk
+ //if (nesFile.Mapper == 88) nesFile.Mapper = 4; // Compatible with MMC3... sometimes
+ //if (nesFile.Mapper == 95) nesFile.Mapper = 4; // Compatible with MMC3
+ //if (nesFile.Mapper == 206) nesFile.Mapper = 4; // Compatible with MMC3
+ if (!supportedMappers.Contains(nesFile.Mapper) && (IgnoreMapper != true))
+ {
+ if (IgnoreMapper != false)
+ {
+ var r = WorkerForm.MessageBoxFromThread(ParentForm,
+ string.Format(Resources.MapperNotSupported, System.IO.Path.GetFileName(inputFileName), nesFile.Mapper),
+ Resources.AreYouSure,
+ MessageBoxButtons.AbortRetryIgnore,
+ MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, true);
+ if (r == DialogResult.Abort)
+ IgnoreMapper = true;
+ if (r == DialogResult.Ignore)
+ return false;
+ }
+ else return false;
+ }
+ if ((nesFile.Mirroring == NesFile.MirroringType.FourScreenVram) && (IgnoreMapper != true))
+ {
+ var r = WorkerForm.MessageBoxFromThread(ParentForm,
+ string.Format(Resources.FourScreenNotSupported, System.IO.Path.GetFileName(inputFileName)),
+ Resources.AreYouSure,
+ MessageBoxButtons.AbortRetryIgnore,
+ MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, true);
+ if (r == DialogResult.Abort)
+ IgnoreMapper = true;
+ if (r == DialogResult.No)
+ return false;
+ }
+
+ // TODO: Make trainer check. I think that the NES Mini doesn't support it.
+ rawRomData = nesFile.GetRaw();
+ if (inputFileName.Contains("(J)")) cover = Resources.blank_jp;
+ args = DefaultArgs;
+ return true;
+ }
+
+ /*
public static NesMiniApplication Import(string nesFileName, string sourceFileName, bool? ignoreMapper, ref bool? needPatch, NeedPatchDelegate needPatchCallback = null, Form parentForm = null, byte[] rawRomData = null)
{
NesFile nesFile;
@@ -114,10 +150,6 @@ namespace com.clusterrr.hakchi_gui
else needPatch = false;
}
- //if (nesFile.Mapper == 71) nesFile.Mapper = 2; // games by Codemasters/Camerica - this is UNROM clone. One exception - Fire Hawk
- //if (nesFile.Mapper == 88) nesFile.Mapper = 4; // Compatible with MMC3... sometimes
- //if (nesFile.Mapper == 95) nesFile.Mapper = 4; // Compatible with MMC3
- //if (nesFile.Mapper == 206) nesFile.Mapper = 4; // Compatible with MMC3
if (!supportedMappers.Contains(nesFile.Mapper) && (ignoreMapper != true))
{
Directory.Delete(gamePath, true);
@@ -156,6 +188,7 @@ namespace com.clusterrr.hakchi_gui
game.Save();
return game;
}
+ */
public bool TryAutofill(uint crc32)
{
@@ -170,7 +203,6 @@ namespace com.clusterrr.hakchi_gui
if (ReleaseDate.Length == 4) ReleaseDate += "-01";
if (ReleaseDate.Length == 7) ReleaseDate += "-01";
Publisher = gameinfo.Publisher.ToUpper();
- Region = gameinfo.Region;
return true;
}
return false;
@@ -178,14 +210,15 @@ namespace com.clusterrr.hakchi_gui
public override bool Save()
{
- if (this.hasUnsavedChanges)
+ var old = hasUnsavedChanges;
+ if (hasUnsavedChanges)
{
if (!string.IsNullOrEmpty(gameGenie))
File.WriteAllText(GameGeniePath, gameGenie);
else
File.Delete(GameGeniePath);
}
- return base.Save() || this.hasUnsavedChanges;
+ return base.Save() || old;
}
public void ApplyGameGenie()
@@ -193,12 +226,16 @@ namespace com.clusterrr.hakchi_gui
if (!string.IsNullOrEmpty(GameGenie))
{
var codes = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
- var nesFile = new NesFile(NesPath);
- foreach (var code in codes)
+ var nesFiles = Directory.GetFiles(this.Path, "*.nes", SearchOption.TopDirectoryOnly);
+ foreach (var f in nesFiles)
{
- nesFile.PRG = GameGeniePatcher.Patch(nesFile.PRG, code.Trim());
+ var nesFile = new NesFile(f);
+ foreach (var code in codes)
+ {
+ nesFile.PRG = GameGeniePatcher.Patch(nesFile.PRG, code.Trim());
+ }
+ nesFile.Save(f);
}
- nesFile.Save(NesPath);
}
}
@@ -215,7 +252,7 @@ namespace com.clusterrr.hakchi_gui
{
try
{
- var xmlDataBasePath = Path.Combine(Path.Combine(Program.BaseDirectoryInternal, "data"), "nescarts.xml");
+ var xmlDataBasePath = System.IO.Path.Combine(System.IO.Path.Combine(Program.BaseDirectoryInternal, "data"), "nescarts.xml");
Debug.WriteLine("Loading " + xmlDataBasePath);
if (File.Exists(xmlDataBasePath))
@@ -254,6 +291,7 @@ namespace com.clusterrr.hakchi_gui
Debug.WriteLine(ex.Message + ex.StackTrace);
}
}
+
}
}
diff --git a/Apps/NesMiniApplication.cs b/Apps/NesMiniApplication.cs
index 3b0ab9bf..437253ce 100644
--- a/Apps/NesMiniApplication.cs
+++ b/Apps/NesMiniApplication.cs
@@ -14,6 +14,14 @@ namespace com.clusterrr.hakchi_gui
{
public class NesMiniApplication : INesMenuElement
{
+ internal const string DefaultApp = "/bin/path-to-your-app";
+ const string DefaultReleaseDate = "1900-01-01";
+ const string DefaultPublisher = "UNKNOWN";
+ public const char DefaultPrefix = 'Z';
+ public static Image DefaultCover = Resources.blank_app;
+ public static Form ParentForm;
+ public static bool? NeedPatch;
+
public static string GamesDirectory
{
get
@@ -23,10 +31,10 @@ namespace com.clusterrr.hakchi_gui
default:
case MainForm.ConsoleType.NES:
case MainForm.ConsoleType.Famicom:
- return Path.Combine(Program.BaseDirectoryExternal, "games");
+ return System.IO.Path.Combine(Program.BaseDirectoryExternal, "games");
case MainForm.ConsoleType.SNES:
case MainForm.ConsoleType.SuperFamicom:
- return Path.Combine(Program.BaseDirectoryExternal, "games_snes");
+ return System.IO.Path.Combine(Program.BaseDirectoryExternal, "games_snes");
}
}
}
@@ -47,23 +55,17 @@ namespace com.clusterrr.hakchi_gui
}
}
- const string DefaultReleaseDate = "1900-01-01";
- const string DefaultPublisher = "UNKNOWN";
-
protected string code;
public string Code
{
get { return code; }
}
- public const char DefaultPrefix = 'Z';
- public static Image DefaultCover { get { return Resources.blank_app; } }
- internal const string DefaultApp = "/bin/path-to-your-app";
public virtual string GoogleSuffix
{
get { return "game"; }
}
- public readonly string GamePath;
+ public readonly string Path;
public readonly string ConfigPath;
public readonly string IconPath;
public readonly string SmallIconPath;
@@ -141,13 +143,6 @@ namespace com.clusterrr.hakchi_gui
if (line.StartsWith("Exec="))
{
string command = line.Substring(5);
- if (command.StartsWith("/usr/bin/clover-kachikachi") || command.StartsWith("/bin/clover-kachikachi-wr"))
- {
- if (command.Contains(".nes"))
- return new NesGame(path, ignoreEmptyConfig);
- if (command.Contains(".fds"))
- return new FdsGame(path, ignoreEmptyConfig);
- }
var app = AppTypeCollection.GetAppByExec(command);
if (app != null)
{
@@ -160,92 +155,92 @@ namespace com.clusterrr.hakchi_gui
return new NesMiniApplication(path, ignoreEmptyConfig);
}
- public static NesMiniApplication Import(string fileName, string sourceFile = null, byte[] rawRomData = null)
+ public static NesMiniApplication Import(string inputFileName, string originalFileName = null, byte[] rawRomData = null)
{
- var extension = Path.GetExtension(fileName).ToLower();
+ var extension = System.IO.Path.GetExtension(inputFileName).ToLower();
if (extension == ".desktop")
- return ImportApp(fileName);
- if (rawRomData == null)
- rawRomData = File.ReadAllBytes(fileName);
- var appinfo = AppTypeCollection.GetAppByExtension(extension);
- if (appinfo != null)
- {
- var import = appinfo.Class.GetMethod("Import", new Type[] { typeof(string), typeof(string), typeof(byte[]) });
- if (import != null)
- return (NesMiniApplication)import.Invoke(null, new object[] { fileName, sourceFile, rawRomData });
- else
- return Import(fileName, sourceFile, rawRomData, appinfo.Prefix,
- appinfo.DefaultApps.Length > 0 ? appinfo.DefaultApps[0] : DefaultApp,
- appinfo.DefaultCover, ConfigIni.Compress);
- }
+ return ImportApp(inputFileName);
+ if (rawRomData == null) // Maybe it's already extracted data?
+ rawRomData = File.ReadAllBytes(inputFileName); // If not, reading file
+ if (originalFileName == null) // Original file name from archive
+ originalFileName = System.IO.Path.GetFileName(inputFileName);
+ char prefix = DefaultPrefix;
string application = extension.Length > 2 ? ("/bin/" + extension.Substring(1)) : DefaultApp;
- return Import(fileName, sourceFile, rawRomData, DefaultPrefix, application, DefaultCover);
- }
+ string args = null;
+ Image cover = DefaultCover;
+ uint crc32 = CRC32(rawRomData);
+ string outputFileName = Regex.Replace(System.IO.Path.GetFileName(inputFileName), @"[^A-Za-z0-9()!\[\]\.\-]", "_").Trim();
- private static NesMiniApplication Import(string fileName, string sourceFile, byte[] rawRomData, char prefixCode, string application, Image defaultCover, bool compress = false)
- {
- var crc32 = CRC32(rawRomData);
- var code = GenerateCode(crc32, prefixCode);
- var gamePath = Path.Combine(GamesDirectory, code);
- bool sevenZipped = false;
- if (compress)
+ // Trying to determine file type
+ var appinfo = AppTypeCollection.GetAppByExtension(extension);
+ bool patched = false;
+ if (appinfo != null)
{
- string temp = null;
- try
- {
- if (!File.Exists(fileName))
- {
- temp = Path.Combine(Path.GetTempPath(), Path.GetFileName(fileName));
- File.WriteAllBytes(temp, rawRomData);
- rawRomData = Compress(temp);
- sevenZipped = true;
- }
- else
- {
- rawRomData = Compress(fileName);
- sevenZipped = true;
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine("Compression error: " + ex.Message + ex.Source);
- }
- finally
+ if (appinfo.DefaultApps.Length > 0)
+ application = appinfo.DefaultApps[0];
+ prefix = appinfo.Prefix;
+ cover = appinfo.DefaultCover;
+ var patch = appinfo.Class.GetMethod("Patch");
+ if (patch != null)
{
- if (!string.IsNullOrEmpty(temp) && File.Exists(temp))
- File.Delete(temp);
+ object[] values = new object[] { inputFileName, rawRomData, prefix, application, outputFileName, args, cover, crc32 };
+ var result = (bool)patch.Invoke(null, values);
+ if (!result) return null;
+ rawRomData = (byte[])values[1];
+ prefix = (char)values[2];
+ application = (string)values[3];
+ outputFileName = (string)values[4];
+ args = (string)values[5];
+ cover = (Image)values[6];
+ crc32 = (uint)values[7];
+ patched = true;
}
}
- var romName = Regex.Replace(Path.GetFileName(fileName), @"[^A-Za-z0-9.-]", "_").Trim() + (sevenZipped ? ".7z" : "");
- var romPath = Path.Combine(gamePath, romName);
+
+ if (!patched)
+ FindPatch(ref rawRomData, inputFileName, crc32);
+
+ var code = GenerateCode(crc32, prefix);
+ var gamePath = System.IO.Path.Combine(GamesDirectory, code);
+ var romPath = System.IO.Path.Combine(gamePath, outputFileName);
if (Directory.Exists(gamePath))
Directory.Delete(gamePath, true);
Directory.CreateDirectory(gamePath);
File.WriteAllBytes(romPath, rawRomData);
var game = new NesMiniApplication(gamePath, true);
- game.Name = Path.GetFileNameWithoutExtension(fileName);
+ game.Name = System.IO.Path.GetFileNameWithoutExtension(inputFileName);
game.Name = Regex.Replace(game.Name, @" ?\(.*?\)", string.Empty).Trim();
game.Name = Regex.Replace(game.Name, @" ?\[.*?\]", string.Empty).Trim();
game.Name = game.Name.Replace("_", " ").Replace(" ", " ").Trim();
- game.FindCover(fileName, sourceFile, defaultCover, crc32);
- game.Command = string.Format("{0} /usr/share/games/nes/kachikachi/{1}/{2}", application, code, romName);
+ game.Command = $"{application} {GamesCloverPath}/{code}/{outputFileName}";
+ if (!string.IsNullOrEmpty(args))
+ game.Command += " " + args;
+ game.FindCover(inputFileName, cover, crc32);
game.Save();
- return NesMiniApplication.FromDirectory(gamePath);
+
+ var app = NesMiniApplication.FromDirectory(gamePath);
+ if (app is ICloverAutofill)
+ (app as ICloverAutofill).TryAutofill(crc32);
+
+ if (ConfigIni.Compress)
+ app.Compress();
+
+ return app;
}
private static NesMiniApplication ImportApp(string fileName)
{
if (!File.Exists(fileName)) // Archives are not allowed
throw new FileNotFoundException("Invalid app folder");
- var code = Path.GetFileNameWithoutExtension(fileName).ToUpper();
- var targetDir = Path.Combine(GamesDirectory, code);
- DirectoryCopy(Path.GetDirectoryName(fileName), targetDir, true);
+ var code = System.IO.Path.GetFileNameWithoutExtension(fileName).ToUpper();
+ var targetDir = System.IO.Path.Combine(GamesDirectory, code);
+ DirectoryCopy(System.IO.Path.GetDirectoryName(fileName), targetDir, true);
return FromDirectory(targetDir);
}
protected NesMiniApplication()
{
- GamePath = null;
+ Path = null;
ConfigPath = null;
Players = 1;
Simultaneous = false;
@@ -256,12 +251,12 @@ namespace com.clusterrr.hakchi_gui
protected NesMiniApplication(string path, bool ignoreEmptyConfig = false)
{
- GamePath = path;
- code = Path.GetFileName(path);
+ Path = path;
+ code = System.IO.Path.GetFileName(path);
Name = Code;
- ConfigPath = Path.Combine(path, Code + ".desktop");
- IconPath = Path.Combine(path, Code + ".png");
- SmallIconPath = Path.Combine(path, Code + "_small.png");
+ ConfigPath = System.IO.Path.Combine(path, Code + ".desktop");
+ IconPath = System.IO.Path.Combine(path, Code + ".png");
+ SmallIconPath = System.IO.Path.Combine(path, Code + "_small.png");
Players = 1;
Simultaneous = false;
ReleaseDate = DefaultReleaseDate;
@@ -390,41 +385,32 @@ namespace com.clusterrr.hakchi_gui
outImageSmall.Save(SmallIconPath, ImageFormat.Png);
}
- internal bool FindCover(string romFileName, string sourceFileName, Image defaultCover, uint crc32 = 0)
+ protected bool FindCover(string inputFileName, Image defaultCover, uint crc32 = 0)
{
// Trying to find cover file
Image cover = null;
- if (!string.IsNullOrEmpty(romFileName))
+ var artDirectory = System.IO.Path.Combine(Program.BaseDirectoryExternal, "art");
+ Directory.CreateDirectory(artDirectory);
+ if (!string.IsNullOrEmpty(inputFileName))
{
- if (!string.IsNullOrEmpty(sourceFileName) && sourceFileName != romFileName)
+ if (crc32 != 0)
{
- var archImagePath = Path.Combine(Path.GetDirectoryName(sourceFileName), Path.GetFileNameWithoutExtension(romFileName) + ".png");
- if (File.Exists(archImagePath))
- cover = LoadBitmap(archImagePath);
- archImagePath = Path.Combine(Path.GetDirectoryName(sourceFileName), Path.GetFileNameWithoutExtension(romFileName) + ".jpg");
- if (File.Exists(archImagePath))
- cover = LoadBitmap(archImagePath);
+ var covers = Directory.GetFiles(artDirectory, string.Format("{0:X8}*.*", crc32), SearchOption.AllDirectories);
+ if (covers.Length > 0)
+ cover = LoadBitmap(covers[0]);
}
- var imagePath = Path.Combine(Path.GetDirectoryName(romFileName), Path.GetFileNameWithoutExtension(romFileName) + ".png");
+ var imagePath = System.IO.Path.Combine(artDirectory, System.IO.Path.GetFileNameWithoutExtension(inputFileName) + ".png");
if (File.Exists(imagePath))
cover = LoadBitmap(imagePath);
- imagePath = Path.Combine(Path.GetDirectoryName(romFileName), Path.GetFileNameWithoutExtension(romFileName) + ".jpg");
+ imagePath = System.IO.Path.Combine(artDirectory, System.IO.Path.GetFileNameWithoutExtension(inputFileName) + ".jpg");
if (File.Exists(imagePath))
cover = LoadBitmap(imagePath);
- var artDirectory = Path.Combine(Program.BaseDirectoryExternal, "art");
- Directory.CreateDirectory(artDirectory);
- imagePath = Path.Combine(artDirectory, Path.GetFileNameWithoutExtension(romFileName) + ".png");
+ imagePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(inputFileName), System.IO.Path.GetFileNameWithoutExtension(inputFileName) + ".png");
if (File.Exists(imagePath))
cover = LoadBitmap(imagePath);
- imagePath = Path.Combine(artDirectory, Path.GetFileNameWithoutExtension(romFileName) + ".jpg");
+ imagePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(inputFileName), System.IO.Path.GetFileNameWithoutExtension(inputFileName) + ".jpg");
if (File.Exists(imagePath))
cover = LoadBitmap(imagePath);
- if (crc32 != 0)
- {
- var covers = Directory.GetFiles(artDirectory, string.Format("{0:X8}*.*", crc32), SearchOption.AllDirectories);
- if (covers.Length > 0)
- cover = LoadBitmap(covers[0]);
- }
}
if (cover == null)
{
@@ -435,6 +421,52 @@ namespace com.clusterrr.hakchi_gui
return true;
}
+ protected static bool FindPatch(ref byte[] rawRomData, string inputFileName, uint crc32 = 0)
+ {
+ string patch = null;
+ var patchesDirectory = System.IO.Path.Combine(Program.BaseDirectoryExternal, "patches");
+ Directory.CreateDirectory(patchesDirectory);
+ if (!string.IsNullOrEmpty(inputFileName))
+ {
+ if (crc32 != 0)
+ {
+ var patches = Directory.GetFiles(patchesDirectory, string.Format("{0:X8}*.*", crc32), SearchOption.AllDirectories);
+ if (patches.Length > 0)
+ patch = patches[0];
+ }
+ var patchesPath = System.IO.Path.Combine(patchesDirectory, System.IO.Path.GetFileNameWithoutExtension(inputFileName) + ".ips");
+ if (File.Exists(patchesPath))
+ patch = patchesPath;
+ patchesPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(inputFileName), System.IO.Path.GetFileNameWithoutExtension(inputFileName) + ".ips");
+ if (File.Exists(patchesPath))
+ patch = patchesPath;
+ }
+
+ if (!string.IsNullOrEmpty(patch))
+ {
+ if (NeedPatch != true)
+ {
+ if (NeedPatch != false)
+ {
+ var r = WorkerForm.MessageBoxFromThread(ParentForm,
+ string.Format(Resources.PatchQ, System.IO.Path.GetFileName(inputFileName)),
+ Resources.PatchAvailable,
+ MessageBoxButtons.AbortRetryIgnore,
+ MessageBoxIcon.Question,
+ MessageBoxDefaultButton.Button2, true);
+ if (r == DialogResult.Abort)
+ NeedPatch = true;
+ if (r == DialogResult.Ignore)
+ return false;
+ }
+ else return false;
+ }
+ IpsPatcher.Patch(patch, ref rawRomData);
+ return true;
+ }
+ return false;
+ }
+
protected static string GenerateCode(uint crc32, char prefixCode)
{
return string.Format("CLV-{5}-{0}{1}{2}{3}{4}",
@@ -448,8 +480,8 @@ namespace com.clusterrr.hakchi_gui
public NesMiniApplication CopyTo(string path)
{
- var targetDir = Path.Combine(path, code);
- DirectoryCopy(GamePath, targetDir, true);
+ var targetDir = System.IO.Path.Combine(path, code);
+ DirectoryCopy(Path, targetDir, true);
return FromDirectory(targetDir);
}
@@ -477,7 +509,7 @@ namespace com.clusterrr.hakchi_gui
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
- string temppath = Path.Combine(destDirName, file.Name);
+ string temppath = System.IO.Path.Combine(destDirName, file.Name);
size += file.CopyTo(temppath, true).Length;
}
@@ -486,7 +518,7 @@ namespace com.clusterrr.hakchi_gui
{
foreach (DirectoryInfo subdir in dirs)
{
- string temppath = Path.Combine(destDirName, subdir.Name);
+ string temppath = System.IO.Path.Combine(destDirName, subdir.Name);
size += DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
@@ -496,7 +528,7 @@ namespace com.clusterrr.hakchi_gui
public long Size(string path = null)
{
if (path == null)
- path = GamePath;
+ path = Path;
long size = 0;
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(path);
@@ -565,17 +597,65 @@ namespace com.clusterrr.hakchi_gui
}
}
- private static byte[] Compress(string filename)
+ public string[] CompressPossible()
{
- SevenZipExtractor.SetLibraryPath(Path.Combine(Program.BaseDirectoryInternal, IntPtr.Size == 8 ? @"tools\7z64.dll" : @"tools\7z.dll"));
- var arch = new MemoryStream();
- var compressor = new SevenZipCompressor();
- compressor.CompressionLevel = CompressionLevel.High;
- compressor.CompressFiles(arch, filename);
- arch.Seek(0, SeekOrigin.Begin);
- var result = new byte[arch.Length];
- arch.Read(result, 0, result.Length);
- return result;
+ var result = new List<string>();
+ var exec = Regex.Replace(Command, "['\\\"]", " ") + " ";
+ var files = Directory.GetFiles(Path, "*.*", SearchOption.TopDirectoryOnly);
+ foreach (var file in files)
+ {
+ if (System.IO.Path.GetExtension(file).ToLower() == ".7z")
+ continue;
+ if (System.IO.Path.GetExtension(file).ToLower() == ".zip")
+ continue;
+ if (exec.Contains(System.IO.Path.GetFileName(file) + " "))
+ result.Add(file);
+ }
+ return result.ToArray();
+ }
+
+ public string[] DecompressPossible()
+ {
+ var result = new List<string>();
+ var exec = Regex.Replace(Command, "['\\\"]", " ") + " ";
+ var files = Directory.GetFiles(Path, "*.7z", SearchOption.TopDirectoryOnly);
+ foreach (var file in files)
+ {
+ if (exec.Contains(System.IO.Path.GetFileName(file) + " "))
+ result.Add(file);
+ }
+ return result.ToArray();
+ }
+
+ public void Compress()
+ {
+ SevenZipExtractor.SetLibraryPath(System.IO.Path.Combine(Program.BaseDirectoryInternal, IntPtr.Size == 8 ? @"tools\7z64.dll" : @"tools\7z.dll"));
+ foreach (var filename in CompressPossible())
+ {
+ var archName = filename + ".7z";
+ var compressor = new SevenZipCompressor();
+ compressor.CompressionLevel = CompressionLevel.High;
+ Debug.WriteLine("Compressing " + filename);
+ compressor.CompressFiles(archName, filename);
+ File.Delete(filename);
+ Command = Command.Replace(System.IO.Path.GetFileName(filename), System.IO.Path.GetFileName(archName));
+ }
+ }
+
+ public void Decompress()
+ {
+ SevenZipExtractor.SetLibraryPath(System.IO.Path.Combine(Program.BaseDirectoryInternal, IntPtr.Size == 8 ? @"tools\7z64.dll" : @"tools\7z.dll"));
+ foreach (var filename in DecompressPossible())
+ {
+ using (var szExtractor = new SevenZipExtractor(filename))
+ {
+ Debug.WriteLine("Decompressing " + filename);
+ szExtractor.ExtractArchive(Path);
+ foreach (var f in szExtractor.ArchiveFileNames)
+ Command = Command.Replace(System.IO.Path.GetFileName(filename), f);
+ }
+ File.Delete(filename);
+ }
}
public class NesMiniAppEqualityComparer : IEqualityComparer<NesMiniApplication>
diff --git a/Apps/SnesGame.cs b/Apps/SnesGame.cs
index 2ff7cb99..49e3d365 100644
--- a/Apps/SnesGame.cs
+++ b/Apps/SnesGame.cs
@@ -1,6 +1,7 @@
#pragma warning disable 0108
using com.clusterrr.hakchi_gui.Properties;
using System.Drawing;
+using System.Windows.Forms;
namespace com.clusterrr.hakchi_gui
{
@@ -18,6 +19,14 @@ namespace com.clusterrr.hakchi_gui
: base(path, ignoreEmptyConfig)
{
}
+
+ public static NesMiniApplication Import(string fileName, string sourceFile = null, byte[] rawRomData = null)
+ {
+ if (ConfigIni.ConsoleType != MainForm.ConsoleType.SNES && ConfigIni.ConsoleType != MainForm.ConsoleType.SuperFamicom)
+ return null;
+
+ return null;
+ }
}
}
diff --git a/GameGenieCodeAddModForm.cs b/GameGenieCodeAddModForm.cs
index 25e75736..99049933 100644
--- a/GameGenieCodeAddModForm.cs
+++ b/GameGenieCodeAddModForm.cs
@@ -1,15 +1,16 @@
using com.clusterrr.Famicom;
using com.clusterrr.hakchi_gui.Properties;
using System;
+using System.IO;
using System.Windows.Forms;
namespace com.clusterrr.hakchi_gui
{
public partial class GameGenieCodeAddModForm : Form
{
- readonly NesGame FGame = null;
+ readonly NesMiniApplication FGame = null;
- public GameGenieCodeAddModForm(NesGame game)
+ public GameGenieCodeAddModForm(NesMiniApplication game)
{
InitializeComponent();
FGame = game;
@@ -47,10 +48,14 @@ namespace com.clusterrr.hakchi_gui
if (FGame != null)
{
- NesFile lGame = new NesFile(FGame.NesPath);
+ var tmpPath = Path.Combine(Path.GetTempPath(), FGame.Code);
try
{
- lGame.PRG = GameGeniePatcher.Patch(lGame.PRG, textBoxCode.Text);
+ FGame.CopyTo(tmpPath);
+ var lGame = NesMiniApplication.FromDirectory(tmpPath);
+ (lGame as ISupportsGameGenie).GameGenie = textBoxCode.Text;
+ lGame.Save();
+ (lGame as ISupportsGameGenie).ApplyGameGenie();
}
catch (GameGenieFormatException)
{
@@ -62,6 +67,11 @@ namespace com.clusterrr.hakchi_gui
MessageBox.Show(this, string.Format(Resources.GameGenieNotFound, textBoxCode.Text, FGame.Name), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
+ finally
+ {
+ if (Directory.Exists(tmpPath))
+ Directory.Delete(tmpPath, true);
+ }
}
if (string.IsNullOrEmpty(textBoxDescription.Text.Trim()))
diff --git a/GameGenieCodeForm.cs b/GameGenieCodeForm.cs
index 7058b451..8f5f34a1 100644
--- a/GameGenieCodeForm.cs
+++ b/GameGenieCodeForm.cs
@@ -8,11 +8,11 @@ namespace com.clusterrr.hakchi_gui
{
public partial class GameGenieCodeForm : Form
{
- private readonly NesGame FGame;
+ private readonly NesMiniApplication FGame;
private GameGenieDataBase FGameGenieDataBase;
private List<string> OtherCodes;
- public GameGenieCodeForm(NesGame AGame)
+ public GameGenieCodeForm(NesMiniApplication AGame)
{
InitializeComponent();
FGame = AGame;
@@ -26,7 +26,7 @@ namespace com.clusterrr.hakchi_gui
checkedListBoxGameCode.Items.Clear();
var lCodeSorted = FGameGenieDataBase.GameCodes.OrderBy(o => o.Description);
- var lSelectedCode = FGame.GameGenie.ToUpper().Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
+ var lSelectedCode = (FGame as ISupportsGameGenie).GameGenie.ToUpper().Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var code in lCodeSorted)
checkedListBoxGameCode.Items.Add(code, lSelectedCode.Contains(code.Code.ToUpper().Trim()));
@@ -46,7 +46,7 @@ namespace com.clusterrr.hakchi_gui
foreach (GameGenieCode code in checkedListBoxGameCode.CheckedItems)
selected.Add(code.Code);
selected.AddRange(OtherCodes);
- FGame.GameGenie = string.Join(",", selected.ToArray());
+ (FGame as ISupportsGameGenie).GameGenie = string.Join(",", selected.ToArray());
}
private void buttonOk_Click(object sender, EventArgs e)
diff --git a/ImageGooglerForm.cs b/ImageGooglerForm.cs
index 92fc2507..4bd352ba 100644
--- a/ImageGooglerForm.cs
+++ b/ImageGooglerForm.cs
@@ -46,7 +46,7 @@ namespace com.clusterrr.hakchi_gui
string responseFromServer = reader.ReadToEnd();
reader.Close();
response.Close();
- Debug.WriteLine("Web response: " + url);
+ //Debug.WriteLine("Web response: " + responseFromServer);
var urls = new List<string>();
string search = @"\""ou\""\:\""(?<url>.+?)\""";
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index 9e41efde..542d3545 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -159,6 +159,8 @@
this.timerConnectionCheck = new System.Windows.Forms.Timer(this.components);
this.saveDumpFileDialog = new System.Windows.Forms.SaveFileDialog();
this.openDumpFileDialog = new System.Windows.Forms.OpenFileDialog();
+ this.checkBoxCompressed = new System.Windows.Forms.CheckBox();
+ this.labelSize = new System.Windows.Forms.Label();
this.menuStrip.SuspendLayout();
this.groupBoxOptions.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArt)).BeginInit();
@@ -802,6 +804,8 @@
// groupBoxOptions
//
resources.ApplyResources(this.groupBoxOptions, "groupBoxOptions");
+ this.groupBoxOptions.Controls.Add(this.labelSize);
+ this.groupBoxOptions.Controls.Add(this.checkBoxCompressed);
this.groupBoxOptions.Controls.Add(this.buttonShowGameGenieDatabase);
this.groupBoxOptions.Controls.Add(this.maskedTextBoxReleaseDate);
this.groupBoxOptions.Controls.Add(this.label1);
@@ -1079,6 +1083,18 @@
//
this.openDumpFileDialog.FileName = "...";
//
+ // checkBoxCompressed
+ //
+ resources.ApplyResources(this.checkBoxCompressed, "checkBoxCompressed");
+ this.checkBoxCompressed.Name = "checkBoxCompressed";
+ this.checkBoxCompressed.UseVisualStyleBackColor = true;
+ this.checkBoxCompressed.CheckedChanged += new System.EventHandler(this.checkBoxCompressed_CheckedChanged);
+ //
+ // labelSize
+ //
+ resources.ApplyResources(this.labelSize, "labelSize");
+ this.labelSize.Name = "labelSize";
+ //
// MainForm
//
this.AllowDrop = true;
@@ -1102,7 +1118,6 @@
this.Shown += new System.EventHandler(this.MainForm_Shown);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.checkedListBoxGames_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.checkedListBoxGames_DragEnter);
- this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyDown);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.groupBoxOptions.ResumeLayout(false);
@@ -1248,6 +1263,8 @@
private System.Windows.Forms.ToolStripMenuItem membootPatchedKernelToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem11;
private System.Windows.Forms.ToolStripMenuItem membootOriginalKernelToolStripMenuItem;
+ private System.Windows.Forms.CheckBox checkBoxCompressed;
+ private System.Windows.Forms.Label labelSize;
}
}
diff --git a/MainForm.cs b/MainForm.cs
index a8770378..e3c9f857 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -142,7 +142,6 @@ namespace com.clusterrr.hakchi_gui
{
SyncConsoleType();
InternalMods = from m in Directory.GetFiles(Path.Combine(Program.BaseDirectoryInternal, "mods/hmods")) select Path.GetFileNameWithoutExtension(m);
- LoadGames();
LoadPresets();
LoadLanguages();
var version = Assembly.GetExecutingAssembly().GetName().Version;
@@ -161,7 +160,7 @@ namespace com.clusterrr.hakchi_gui
epilepsyProtectionToolStripMenuItem.Checked = ConfigIni.AntiArmetLevel > 0;
selectButtonCombinationToolStripMenuItem.Enabled = resetUsingCombinationOfButtonsToolStripMenuItem.Checked = ConfigIni.ResetHack;
enableAutofireToolStripMenuItem.Checked = ConfigIni.AutofireHack;
- useXYOnClassicControllerAsAutofireABToolStripMenuItem.Checked = ConfigIni.AutofireXYHack;
+ useXYOnClassicControllerAsAutofireABToolStripMenuItem.Checked = ConfigIni.AutofireXYHack;
upABStartOnSecondControllerToolStripMenuItem.Checked = ConfigIni.FcStart;
compressGamesIfPossibleToolStripMenuItem.Checked = ConfigIni.Compress;
@@ -235,7 +234,7 @@ namespace com.clusterrr.hakchi_gui
var customFirmware = Clovershell.ExecuteSimple("[ -d /var/lib/hakchi/firmware/ ] && [ -f /var/lib/hakchi/firmware/*.hsqs ] && echo YES || echo NO");
if (customFirmware == "NO")
{
- var board = Clovershell.ExecuteSimple("cat /etc/clover/boardtype", 500, true);
+ var board = Clovershell.ExecuteSimple("cat /etc/clover/boardtype", 500, true);
var region = Clovershell.ExecuteSimple("cat /etc/clover/REGION", 500, true);
Debug.WriteLine(string.Format("Detected board: {0}", board));
Debug.WriteLine(string.Format("Detected region: {0}", region));
@@ -244,7 +243,7 @@ namespace com.clusterrr.hakchi_gui
default:
case "dp-nes":
case "dp-hvc":
- switch(region)
+ switch (region)
{
case "EUR_USA":
ConfigIni.ConsoleType = ConsoleType.NES;
@@ -347,6 +346,7 @@ namespace com.clusterrr.hakchi_gui
groupBoxOptions.Visible = true;
groupBoxOptions.Enabled = false;
labelID.Text = "ID: ";
+ labelSize.Text = Resources.Size;
textBoxName.Text = "";
radioButtonOne.Checked = true;
radioButtonTwo.Checked = false;
@@ -355,6 +355,10 @@ namespace com.clusterrr.hakchi_gui
textBoxPublisher.Text = "";
textBoxArguments.Text = "";
pictureBoxArt.Image = null;
+ buttonShowGameGenieDatabase.Enabled = textBoxGameGenie.Enabled = false;
+ textBoxGameGenie.Text = "";
+ checkBoxCompressed.Enabled = false;
+ checkBoxCompressed.Checked = false;
}
else if (!(selected is NesMiniApplication))
{
@@ -368,6 +372,7 @@ namespace com.clusterrr.hakchi_gui
groupBoxDefaultGames.Visible = false;
groupBoxOptions.Visible = true;
labelID.Text = "ID: " + app.Code;
+ labelSize.Text = Resources.Size + " " + (app.Size() / 1024) + "KB";
textBoxName.Text = app.Name;
if (app.Simultaneous && app.Players == 2)
radioButtonTwoSim.Checked = true;
@@ -377,19 +382,29 @@ namespace com.clusterrr.hakchi_gui
radioButtonOne.Checked = true;
maskedTextBoxReleaseDate.Text = app.ReleaseDate;
textBoxPublisher.Text = app.Publisher;
- if (app is NesGame)
- textBoxArguments.Text = (app as NesGame).Args;
- else if (app is FdsGame)
- textBoxArguments.Text = (app as FdsGame).Args;
- else
- textBoxArguments.Text = app.Command;
+ textBoxArguments.Text = app.Command;
if (File.Exists(app.IconPath))
pictureBoxArt.Image = NesMiniApplication.LoadBitmap(app.IconPath);
else
pictureBoxArt.Image = null;
- buttonShowGameGenieDatabase.Enabled = textBoxGameGenie.Enabled = app is NesGame;
- textBoxGameGenie.Text = (app is NesGame) ? (app as NesGame).GameGenie : "";
+ buttonShowGameGenieDatabase.Enabled = textBoxGameGenie.Enabled = app is ISupportsGameGenie;
+ textBoxGameGenie.Text = (app is ISupportsGameGenie) ? (app as ISupportsGameGenie).GameGenie : "";
groupBoxOptions.Enabled = true;
+ if (app.CompressPossible().Count() > 0)
+ {
+ checkBoxCompressed.Enabled = true;
+ checkBoxCompressed.Checked = false;
+ }
+ else if (app.DecompressPossible().Count() > 0)
+ {
+ checkBoxCompressed.Enabled = true;
+ checkBoxCompressed.Checked = true;
+ }
+ else
+ {
+ checkBoxCompressed.Enabled = false;
+ checkBoxCompressed.Checked = false;
+ }
}
}
@@ -589,12 +604,7 @@ namespace com.clusterrr.hakchi_gui
var selected = checkedListBoxGames.SelectedItem;
if (selected == null || !(selected is NesMiniApplication)) return;
var game = (selected as NesMiniApplication);
- if (game is NesGame)
- (game as NesGame).Args = textBoxArguments.Text;
- else if (game is FdsGame)
- (game as FdsGame).Args = textBoxArguments.Text;
- else
- game.Command = textBoxArguments.Text;
+ game.Command = textBoxArguments.Text;
}
private void maskedTextBoxReleaseDate_TextChanged(object sender, EventArgs e)
@@ -646,7 +656,7 @@ namespace com.clusterrr.hakchi_gui
{
// Maybe type was changed? Need to reload games
if ((game as NesMiniApplication).Save())
- checkedListBoxGames.Items[i] = NesMiniApplication.FromDirectory((game as NesMiniApplication).GamePath);
+ checkedListBoxGames.Items[i] = NesMiniApplication.FromDirectory((game as NesMiniApplication).Path);
}
}
catch (Exception ex)
@@ -1310,7 +1320,7 @@ namespace com.clusterrr.hakchi_gui
var game = checkedListBoxGames.Items[pos] as NesMiniApplication;
if (MessageBox.Show(this, string.Format(Resources.DeleteGame, game.Name), Resources.AreYouSure, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
{
- Directory.Delete(game.GamePath, true);
+ Directory.Delete(game.Path, true);
checkedListBoxGames.Items.RemoveAt(pos);
}
}
@@ -1424,32 +1434,6 @@ namespace com.clusterrr.hakchi_gui
deleteGame(checkedListBoxGames.SelectedIndex);
}
- private void MainForm_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.F5 && e.Modifiers == Keys.Shift)
- {
- int counter = 0;
- foreach (var g in checkedListBoxGames.Items)
- {
- if (g is NesMiniApplication)
- {
- var game = g as NesMiniApplication;
- if (game is NesGame)
- {
- try
- {
- if ((game as NesGame).TryAutofill(new NesFile((game as NesGame).NesPath).CRC32))
- counter++;
- }
- catch { }
- }
- }
- }
- ShowSelected();
- MessageBox.Show(this, string.Format(Resources.AutofillResult, counter), Resources.Wow, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
-
private void toolStripMenuMaxGamesPerFolder_Click(object sender, EventArgs e)
{
ConfigIni.MaxGamesPerFolder = byte.Parse((sender as ToolStripMenuItem).Text);
@@ -1474,11 +1458,11 @@ namespace com.clusterrr.hakchi_gui
private void buttonShowGameGenieDatabase_Click(object sender, EventArgs e)
{
- if (!(checkedListBoxGames.SelectedItem is NesGame)) return;
- NesGame nesGame = checkedListBoxGames.SelectedItem as NesGame;
+ if (!(checkedListBoxGames.SelectedItem is ISupportsGameGenie)) return;
+ NesMiniApplication nesGame = checkedListBoxGames.SelectedItem as NesMiniApplication;
GameGenieCodeForm lFrm = new GameGenieCodeForm(nesGame);
if (lFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- textBoxGameGenie.Text = nesGame.GameGenie;
+ textBoxGameGenie.Text = (nesGame as ISupportsGameGenie).GameGenie;
}
private void pagesModefoldersToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1716,5 +1700,26 @@ namespace com.clusterrr.hakchi_gui
MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+
+ private void checkBoxCompressed_CheckedChanged(object sender, EventArgs e)
+ {
+ try
+ {
+ if (!(checkedListBoxGames.SelectedItem is NesMiniApplication)) return;
+ var selected = checkedListBoxGames.SelectedItem as NesMiniApplication;
+ checkBoxCompressed.Enabled = false;
+ if (checkBoxCompressed.Checked)
+ selected.Compress();
+ else
+ selected.Decompress();
+ selected.Save();
+ ShowSelected();
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
}
}
diff --git a/MainForm.resx b/MainForm.resx
index 1c657dce..40ade027 100644
--- a/MainForm.resx
+++ b/MainForm.resx
@@ -707,8 +707,68 @@
<data name="groupBoxOptions.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>None</value>
</data>
+ <data name="labelSize.AutoSize" type="System.Boolean, mscorlib">
+ <value>True</value>
+ </data>
+ <data name="labelSize.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
+ <value>NoControl</value>
+ </data>
+ <data name="labelSize.Location" type="System.Drawing.Point, System.Drawing">
+ <value>16, 73</value>
+ </data>
+ <data name="labelSize.Size" type="System.Drawing.Size, System.Drawing">
+ <value>30, 13</value>
+ </data>
+ <data name="labelSize.TabIndex" type="System.Int32, mscorlib">
+ <value>19</value>
+ </data>
+ <data name="labelSize.Text" xml:space="preserve">
+ <value>Size:</value>
+ </data>
+ <data name="&gt;&gt;labelSize.Name" xml:space="preserve">
+ <value>labelSize</value>
+ </data>
+ <data name="&gt;&gt;labelSize.Type" xml:space="preserve">
+ <value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+ <data name="&gt;&gt;labelSize.Parent" xml:space="preserve">
+ <value>groupBoxOptions</value>
+ </data>
+ <data name="&gt;&gt;labelSize.ZOrder" xml:space="preserve">
+ <value>0</value>
+ </data>
+ <data name="checkBoxCompressed.AutoSize" type="System.Boolean, mscorlib">
+ <value>True</value>
+ </data>
+ <data name="checkBoxCompressed.Location" type="System.Drawing.Point, System.Drawing">
+ <value>103, 71</value>
+ </data>
+ <data name="checkBoxCompressed.Size" type="System.Drawing.Size, System.Drawing">
+ <value>84, 17</value>
+ </data>
+ <data name="checkBoxCompressed.TabIndex" type="System.Int32, mscorlib">
+ <value>3</value>
+ </data>
+ <data name="checkBoxCompressed.Text" xml:space="preserve">
+ <value>Compressed</value>
+ </data>
+ <data name="checkBoxCompressed.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
+ <value>MiddleCenter</value>
+ </data>
+ <data name="&gt;&gt;checkBoxCompressed.Name" xml:space="preserve">
+ <value>checkBoxCompressed</value>
+ </data>
+ <data name="&gt;&gt;checkBoxCompressed.Type" xml:space="preserve">
+ <value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+ <data name="&gt;&gt;checkBoxCompressed.Parent" xml:space="preserve">
+ <value>groupBoxOptions</value>
+ </data>
+ <data name="&gt;&gt;checkBoxCompressed.ZOrder" xml:space="preserve">
+ <value>1</value>
+ </data>
<data name="buttonShowGameGenieDatabase.Location" type="System.Drawing.Point, System.Drawing">
- <value>252, 286</value>
+ <value>252, 288</value>
</data>
<data name="buttonShowGameGenieDatabase.Size" type="System.Drawing.Size, System.Drawing">
<value>25, 20</value>
@@ -729,10 +789,10 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;buttonShowGameGenieDatabase.ZOrder" xml:space="preserve">
- <value>0</value>
+ <value>2</value>
</data>
<data name="maskedTextBoxReleaseDate.Location" type="System.Drawing.Point, System.Drawing">
- <value>210, 154</value>
+ <value>210, 165</value>
</data>
<data name="maskedTextBoxReleaseDate.Mask" xml:space="preserve">
<value>0000-00-00</value>
@@ -741,7 +801,7 @@
<value>65, 20</value>
</data>
<data name="maskedTextBoxReleaseDate.TabIndex" type="System.Int32, mscorlib">
- <value>6</value>
+ <value>7</value>
</data>
<data name="&gt;&gt;maskedTextBoxReleaseDate.Name" xml:space="preserve">
<value>maskedTextBoxReleaseDate</value>
@@ -753,13 +813,13 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;maskedTextBoxReleaseDate.ZOrder" xml:space="preserve">
- <value>1</value>
+ <value>3</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
- <value>15, 157</value>
+ <value>15, 168</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>150, 13</value>
@@ -780,10 +840,10 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
- <value>2</value>
+ <value>4</value>
</data>
<data name="textBoxGameGenie.Location" type="System.Drawing.Point, System.Drawing">
- <value>19, 286</value>
+ <value>19, 288</value>
</data>
<data name="textBoxGameGenie.Size" type="System.Drawing.Size, System.Drawing">
<value>227, 20</value>
@@ -801,7 +861,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;textBoxGameGenie.ZOrder" xml:space="preserve">
- <value>3</value>
+ <value>5</value>
</data>
<data name="label7.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -810,7 +870,7 @@
<value>NoControl</value>
</data>
<data name="label7.Location" type="System.Drawing.Point, System.Drawing">
- <value>16, 269</value>
+ <value>16, 271</value>
</data>
<data name="label7.Size" type="System.Drawing.Size, System.Drawing">
<value>194, 13</value>
@@ -831,10 +891,10 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;label7.ZOrder" xml:space="preserve">
- <value>4</value>
+ <value>6</value>
</data>
<data name="label6.Location" type="System.Drawing.Point, System.Drawing">
- <value>15, 76</value>
+ <value>15, 93</value>
</data>
<data name="label6.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 63</value>
@@ -858,7 +918,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;label6.ZOrder" xml:space="preserve">
- <value>5</value>
+ <value>7</value>
</data>
<data name="radioButtonTwoSim.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -867,13 +927,13 @@
<value>NoControl</value>
</data>
<data name="radioButtonTwoSim.Location" type="System.Drawing.Point, System.Drawing">
- <value>103, 122</value>
+ <value>103, 137</value>
</data>
<data name="radioButtonTwoSim.Size" type="System.Drawing.Size, System.Drawing">
<value>156, 17</value>
</data>
<data name="radioButtonTwoSim.TabIndex" type="System.Int32, mscorlib">
- <value>5</value>
+ <value>6</value>
</data>
<data name="radioButtonTwoSim.Text" xml:space="preserve">
<value>Two players, simultaneously</value>
@@ -888,7 +948,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;radioButtonTwoSim.ZOrder" xml:space="preserve">
- <value>6</value>
+ <value>8</value>
</data>
<data name="buttonGoogle.Location" type="System.Drawing.Point, System.Drawing">
<value>219, 427</value>
@@ -912,7 +972,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;buttonGoogle.ZOrder" xml:space="preserve">
- <value>7</value>
+ <value>9</value>
</data>
<data name="buttonBrowseImage.Location" type="System.Drawing.Point, System.Drawing">
<value>219, 384</value>
@@ -936,7 +996,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;buttonBrowseImage.ZOrder" xml:space="preserve">
- <value>8</value>
+ <value>10</value>
</data>
<data name="pictureBoxArt.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 316</value>
@@ -960,7 +1020,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;pictureBoxArt.ZOrder" xml:space="preserve">
- <value>9</value>
+ <value>11</value>
</data>
<data name="label4.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 316</value>
@@ -987,10 +1047,10 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
- <value>10</value>
+ <value>12</value>
</data>
<data name="textBoxArguments.Location" type="System.Drawing.Point, System.Drawing">
- <value>18, 237</value>
+ <value>18, 244</value>
</data>
<data name="textBoxArguments.Size" type="System.Drawing.Size, System.Drawing">
<value>257, 20</value>
@@ -1008,22 +1068,22 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;textBoxArguments.ZOrder" xml:space="preserve">
- <value>11</value>
+ <value>13</value>
</data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
- <value>15, 220</value>
+ <value>15, 227</value>
</data>
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
- <value>253, 13</value>
+ <value>201, 13</value>
</data>
<data name="label3.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="label3.Text" xml:space="preserve">
- <value>Command line arguments (for advanced users only!):</value>
+ <value>Command line (for advanced users only!):</value>
</data>
<data name="&gt;&gt;label3.Name" xml:space="preserve">
<value>label3</value>
@@ -1035,10 +1095,10 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
- <value>12</value>
+ <value>14</value>
</data>
<data name="textBoxPublisher.Location" type="System.Drawing.Point, System.Drawing">
- <value>71, 186</value>
+ <value>71, 196</value>
</data>
<data name="textBoxPublisher.Size" type="System.Drawing.Size, System.Drawing">
<value>204, 20</value>
@@ -1056,13 +1116,13 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;textBoxPublisher.ZOrder" xml:space="preserve">
- <value>13</value>
+ <value>15</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
- <value>15, 189</value>
+ <value>15, 199</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 13</value>
@@ -1083,19 +1143,19 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
- <value>14</value>
+ <value>16</value>
</data>
<data name="radioButtonTwo.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="radioButtonTwo.Location" type="System.Drawing.Point, System.Drawing">
- <value>103, 99</value>
+ <value>103, 116</value>
</data>
<data name="radioButtonTwo.Size" type="System.Drawing.Size, System.Drawing">
<value>174, 17</value>
</data>
<data name="radioButtonTwo.TabIndex" type="System.Int32, mscorlib">
- <value>4</value>
+ <value>5</value>
</data>
<data name="radioButtonTwo.Text" xml:space="preserve">
<value>Two players, not simultaneously</value>
@@ -1110,19 +1170,19 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;radioButtonTwo.ZOrder" xml:space="preserve">
- <value>15</value>
+ <value>17</value>
</data>
<data name="radioButtonOne.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="radioButtonOne.Location" type="System.Drawing.Point, System.Drawing">
- <value>103, 76</value>
+ <value>103, 95</value>
</data>
<data name="radioButtonOne.Size" type="System.Drawing.Size, System.Drawing">
<value>76, 17</value>
</data>
<data name="radioButtonOne.TabIndex" type="System.Int32, mscorlib">
- <value>3</value>
+ <value>4</value>
</data>
<data name="radioButtonOne.Text" xml:space="preserve">
<value>One player</value>
@@ -1137,10 +1197,10 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;radioButtonOne.ZOrder" xml:space="preserve">
- <value>16</value>
+ <value>18</value>
</data>
<data name="textBoxName.Location" type="System.Drawing.Point, System.Drawing">
- <value>59, 46</value>
+ <value>59, 44</value>
</data>
<data name="textBoxName.Size" type="System.Drawing.Size, System.Drawing">
<value>216, 20</value>
@@ -1158,13 +1218,13 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;textBoxName.ZOrder" xml:space="preserve">
- <value>17</value>
+ <value>19</value>
</data>
<data name="labelName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelName.Location" type="System.Drawing.Point, System.Drawing">
- <value>15, 49</value>
+ <value>15, 47</value>
</data>
<data name="labelName.Size" type="System.Drawing.Size, System.Drawing">
<value>38, 13</value>
@@ -1185,7 +1245,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;labelName.ZOrder" xml:space="preserve">
- <value>18</value>
+ <value>20</value>
</data>
<data name="labelID.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -1212,7 +1272,7 @@
<value>groupBoxOptions</value>
</data>
<data name="&gt;&gt;labelID.ZOrder" xml:space="preserve">
- <value>19</value>
+ <value>21</value>
</data>
<data name="groupBoxOptions.Location" type="System.Drawing.Point, System.Drawing">
<value>306, 27</value>
diff --git a/NesFile.cs b/NesFile.cs
index 9a977d6c..39c56ff3 100644
--- a/NesFile.cs
+++ b/NesFile.cs
@@ -87,7 +87,7 @@ namespace com.clusterrr.Famicom
this.fileName = fileName;
}
- public void Save(string fileName)
+ public byte[] GetRaw()
{
if (PRG == null) PRG = new byte[0];
if (CHR == null) CHR = new byte[0];
@@ -122,9 +122,12 @@ namespace com.clusterrr.Famicom
data.AddRange(CHR);
if (Trainer != null)
data.AddRange(Trainer);
+ return data.ToArray();
+ }
- //data.AddRange(new byte[127]);
- File.WriteAllBytes(fileName, data.ToArray());
+ public void Save(string fileName)
+ {
+ File.WriteAllBytes(fileName, GetRaw());
}
public byte[] MD5
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index 3afb4a5d..eb5541d8 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -95,7 +95,17 @@ namespace com.clusterrr.hakchi_gui.Properties {
return ResourceManager.GetString("AutofillResult", resourceCulture);
}
}
-
+ /// <summary>
+ /// Looks up a localized string similar to Data automatically filled for {0} game(s)..
+ /// </summary>
+ internal static string Size
+ {
+ get
+ {
+ return ResourceManager.GetString("Size", resourceCulture);
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Hold Select+A/B for a second to enable/disable autofire A/B..
/// </summary>
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
index b4604e1e..8c8957e2 100644
--- a/Properties/Resources.resx
+++ b/Properties/Resources.resx
@@ -652,4 +652,7 @@
<data name="Membooting" xml:space="preserve">
<value>Booting the kernel from RAM...</value>
</data>
+ <data name="Size" xml:space="preserve">
+ <value>Size:</value>
+ </data>
</root> \ No newline at end of file
diff --git a/WorkerForm.cs b/WorkerForm.cs
index 22349f9e..701ec3bd 100644
--- a/WorkerForm.cs
+++ b/WorkerForm.cs
@@ -184,19 +184,19 @@ namespace com.clusterrr.hakchi_gui
private delegate DialogResult MessageBoxFromThreadDelegate(IWin32Window owner, string text, string caption, MessageBoxButtons buttons,
MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool tweak);
- DialogResult MessageBoxFromThread(IWin32Window owner, string text, string caption, MessageBoxButtons buttons,
+ public static DialogResult MessageBoxFromThread(IWin32Window owner, string text, string caption, MessageBoxButtons buttons,
MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool tweak)
{
- if (InvokeRequired)
+ if ((owner as Form).InvokeRequired)
{
- return (DialogResult)Invoke(new MessageBoxFromThreadDelegate(MessageBoxFromThread),
+ return (DialogResult)(owner as Form).Invoke(new MessageBoxFromThreadDelegate(MessageBoxFromThread),
new object[] { owner, text, caption, buttons, icon, defaultButton, tweak });
}
- TaskbarProgress.SetState(this, TaskbarProgress.TaskbarStates.Paused);
+ TaskbarProgress.SetState(owner as Form, TaskbarProgress.TaskbarStates.Paused);
if (tweak) MessageBoxManager.Register(); // Tweak button names
var result = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
if (tweak) MessageBoxManager.Unregister();
- TaskbarProgress.SetState(this, TaskbarProgress.TaskbarStates.Normal);
+ TaskbarProgress.SetState(owner as Form, TaskbarProgress.TaskbarStates.Normal);
return result;
}
@@ -1161,10 +1161,10 @@ namespace com.clusterrr.hakchi_gui
stats.TotalGames++;
try
{
- if (gameCopy is NesGame && File.Exists((gameCopy as NesGame).GameGeniePath))
+ if (gameCopy is ISupportsGameGenie && File.Exists((gameCopy as NesGame).GameGeniePath))
{
- (gameCopy as NesGame).ApplyGameGenie();
- File.Delete((gameCopy as NesGame).GameGeniePath);
+ (gameCopy as ISupportsGameGenie).ApplyGameGenie();
+ File.Delete((gameCopy as ISupportsGameGenie).GameGeniePath);
}
}
catch (GameGenieFormatException ex)
@@ -1263,9 +1263,9 @@ namespace com.clusterrr.hakchi_gui
{
var apps = new List<NesMiniApplication>();
addedApplications = null;
- //bool NoForAllUnsupportedMappers = false;
- bool YesForAllUnsupportedMappers = false;
- YesForAllPatches = false;
+ NesGame.ParentForm = this;
+ NesGame.NeedPatch = null;
+ NesGame.IgnoreMapper = null;
int count = 0;
SetStatus(Resources.AddingGames);
foreach (var sourceFileName in files)
@@ -1292,11 +1292,11 @@ namespace com.clusterrr.hakchi_gui
gameFilesInArchive.Add(f);
filesInArchive.Add(f);
}
- if (gameFilesInArchive.Count == 1) // Only one NES file (or app)
+ if (gameFilesInArchive.Count == 1) // Only one known file (or app)
{
fileName = gameFilesInArchive[0];
}
- else if (gameFilesInArchive.Count > 1) // Many NES files, need to select
+ else if (gameFilesInArchive.Count > 1) // Many known files, need to select
{
var r = SelectFileFromThread(gameFilesInArchive.ToArray());
if (r == DialogResult.OK)
@@ -1305,7 +1305,7 @@ namespace com.clusterrr.hakchi_gui
fileName = sourceFileName;
else continue;
}
- else if (filesInArchive.Count == 1) // No NES files but only one another file
+ else if (filesInArchive.Count == 1) // No known files but only one another file
{
fileName = filesInArchive[0];
}
@@ -1323,7 +1323,9 @@ namespace com.clusterrr.hakchi_gui
var o = new MemoryStream();
if (Path.GetExtension(fileName).ToLower() == ".desktop" // App in archive, need the whole directory
|| szExtractor.ArchiveFileNames.Contains(Path.GetFileNameWithoutExtension(fileName) + ".jpg") // Or it has cover in archive
- || szExtractor.ArchiveFileNames.Contains(Path.GetFileNameWithoutExtension(fileName) + ".png"))
+ || szExtractor.ArchiveFileNames.Contains(Path.GetFileNameWithoutExtension(fileName) + ".png")
+ || szExtractor.ArchiveFileNames.Contains(Path.GetFileNameWithoutExtension(fileName) + ".ips") // Or IPS file
+ )
{
tmp = Path.Combine(Path.GetTempPath(), fileName);
Directory.CreateDirectory(tmp);
@@ -1340,48 +1342,19 @@ namespace com.clusterrr.hakchi_gui
}
}
}
- if (Path.GetExtension(fileName).ToLower() == ".nes")
- {
- try
- {
- app = NesGame.Import(fileName, sourceFileName, YesForAllUnsupportedMappers ? (bool?)true : null, ref needPatch, needPatchCallback, this, rawData);
+ app = NesMiniApplication.Import(fileName, sourceFileName, rawData);
- // Trying to import Game Genie codes
- var lGameGeniePath = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".xml");
- if (File.Exists(lGameGeniePath))
- {
- GameGenieDataBase lGameGenieDataBase = new GameGenieDataBase(app);
- lGameGenieDataBase.ImportCodes(lGameGeniePath, true);
- lGameGenieDataBase.Save();
- }
- }
- catch (Exception ex)
- {
- if (ex is UnsupportedMapperException || ex is UnsupportedFourScreenException)
- {
- var r = MessageBoxFromThread(this,
- (ex is UnsupportedMapperException)
- ? string.Format(Resources.MapperNotSupported, Path.GetFileName(fileName), (ex as UnsupportedMapperException).ROM.Mapper)
- : string.Format(Resources.FourScreenNotSupported, Path.GetFileName(fileName)),
- Resources.AreYouSure,
- files.Count() <= 1 ? MessageBoxButtons.YesNo : MessageBoxButtons.AbortRetryIgnore,
- MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, true);
- if (r == DialogResult.Abort)
- YesForAllUnsupportedMappers = true;
- if (r == DialogResult.Yes || r == DialogResult.Abort || r == DialogResult.Retry)
- app = NesGame.Import(fileName, sourceFileName, true, ref needPatch, needPatchCallback, this, rawData);
- else
- continue;
- }
- else throw ex;
- }
- }
- else
+ var lGameGeniePath = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".xml");
+ if (File.Exists(lGameGeniePath))
{
- app = NesMiniApplication.Import(fileName, sourceFileName, rawData);
+ GameGenieDataBase lGameGenieDataBase = new GameGenieDataBase(app);
+ lGameGenieDataBase.ImportCodes(lGameGeniePath, true);
+ lGameGenieDataBase.Save();
}
+
if (!string.IsNullOrEmpty(tmp) && Directory.Exists(tmp)) Directory.Delete(tmp, true);
- ConfigIni.SelectedGames += ";" + app.Code;
+ if (app != null)
+ ConfigIni.SelectedGames += ";" + app.Code;
}
catch (Exception ex)
{
@@ -1397,31 +1370,6 @@ namespace com.clusterrr.hakchi_gui
return apps; // Added games/apps
}
- private bool needPatchCallback(Form parentForm, string nesFileName)
- {
- if (GamesToAdd == null || GamesToAdd.Count() <= 1)
- {
- return MessageBoxFromThread(parentForm,
- string.Format(Resources.PatchQ, Path.GetFileName(nesFileName)),
- Resources.PatchAvailable,
- MessageBoxButtons.YesNo,
- MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button1, false) == DialogResult.Yes;
- }
- else
- {
- var r = MessageBoxFromThread(parentForm,
- string.Format(Resources.PatchQ, Path.GetFileName(nesFileName)),
- Resources.PatchAvailable,
- MessageBoxButtons.AbortRetryIgnore,
- MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button2, true);
- if (r == DialogResult.Abort)
- YesForAllPatches = true;
- return r != DialogResult.Ignore;
- }
- }
-
private void WorkerForm_FormClosing(object sender, FormClosingEventArgs e)
{
if ((thread != null) && (e.CloseReason == CloseReason.UserClosing))
diff --git a/hakchi_gui.csproj b/hakchi_gui.csproj
index 021d83c1..031e6e58 100644
--- a/hakchi_gui.csproj
+++ b/hakchi_gui.csproj
@@ -122,6 +122,8 @@
<Compile Include="Apps\AppTypeCollection.cs" />
<Compile Include="Apps\ArcadeGame.cs" />
<Compile Include="Apps\Atari2600Game.cs" />
+ <Compile Include="Apps\ICloverAutofill.cs" />
+ <Compile Include="Apps\ISupportsGameGenie.cs" />
<Compile Include="Apps\Sega32XGame.cs" />
<Compile Include="Apps\GenesisGame.cs" />
<Compile Include="Apps\PceGame.cs" />
@@ -351,7 +353,7 @@
<Compile Include="ImageGooglerForm.Designer.cs">
<DependentUpon>ImageGooglerForm.cs</DependentUpon>
</Compile>
- <Compile Include="INesMenuElement.cs" />
+ <Compile Include="Apps\INesMenuElement.cs" />
<Compile Include="IpsPatcher.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
diff --git a/mods/hmods/tiny7zx-dynamic.hmod b/mods/hmods/tiny7zx-dynamic.hmod
new file mode 100644
index 00000000..89476f4d
--- /dev/null
+++ b/mods/hmods/tiny7zx-dynamic.hmod
Binary files differ
diff --git a/mods/mod_hakchi/hakchi/rootfs/bin/chmenu b/mods/mod_hakchi/hakchi/rootfs/bin/chmenu
index 5ae4fdcc..5bc02713 100644
--- a/mods/mod_hakchi/hakchi/rootfs/bin/chmenu
+++ b/mods/mod_hakchi/hakchi/rootfs/bin/chmenu
@@ -3,6 +3,7 @@ source /etc/preinit
script_init
state_file=$installpath/menu
+flag=/tmp/startmpc.flag
[ -z "$1" ] && exit 1
[ -f "$state_file" ] && prev_code=$(cat "$state_file") || prev_code=000
@@ -29,9 +30,9 @@ if [ "$1" != "000" ]; then
fi
fi
-pkill -KILL clover-mcp
pkill -KILL ReedPlayer-Clover
+pkill -KILL clover-mcp
overmount_games
-/etc/init.d/S81clover-mcp start
+touch "$flag"
diff --git a/mods/mod_hakchi/hakchi/rootfs/bin/clover-canoe-shvc-wr b/mods/mod_hakchi/hakchi/rootfs/bin/clover-canoe-shvc-wr
new file mode 100644
index 00000000..62fc841b
--- /dev/null
+++ b/mods/mod_hakchi/hakchi/rootfs/bin/clover-canoe-shvc-wr
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Wrapper for canoe
+# You can add extra command line arguments to all games at once
+# using "cfg_snes_extra_args" variable in p0000_config
+
+source /etc/preinit
+script_init
+
+filename=$1
+filebase=$(basename "$filename")
+extension="${filebase##*.}"
+tmppath=/tmp/rom
+if [ "$extension" == "7z" ]; then
+ mkdir -p $tmppath
+ rm -rf $tmppath/*
+ cd $tmppath
+ tiny7zx x $filename
+ filename=$(ls)
+fi
+shift
+
+args="$filename $@ $cfg_snes_extra_args"
+
+exec /usr/bin/clover-canoe-shvc $args
diff --git a/mods/mod_hakchi/hakchi/rootfs/bin/clover-kachikachi-wr b/mods/mod_hakchi/hakchi/rootfs/bin/clover-kachikachi-wr
index d8ff9899..fd24f406 100644
--- a/mods/mod_hakchi/hakchi/rootfs/bin/clover-kachikachi-wr
+++ b/mods/mod_hakchi/hakchi/rootfs/bin/clover-kachikachi-wr
@@ -7,6 +7,26 @@
source /etc/preinit
script_init
-args="$@ $cfg_nes_extra_args"
+filename=$1
+filebase=$(basename "$filename")
+extension="${filebase##*.}"
+tmppath=/tmp/rom
+if [ "$extension" == "7z" ]; then
+ mkdir -p $tmppath
+ rm -rf $tmppath/*
+ cd $tmppath
+ tiny7zx x $filename
+ filename=$(ls)
+fi
+if [ "$extension" == "gz" ]; then
+ mkdir -p $tmppath
+ rm -rf $tmppath/*
+ gunzip -c > $tmppath/$filebase
+ filename=$tmppath/$filebase
+fi
+shift
+
+args="$filename $@ $cfg_nes_extra_args"
[ "$cfg_disable_armet" == "y" ] && args="$(echo $args | sed 's/--enable-armet//g')"
+
exec /usr/bin/clover-kachikachi $args
diff --git a/mods/mod_hakchi/hakchi/rootfs/bin/mcp-restarter b/mods/mod_hakchi/hakchi/rootfs/bin/mcp-restarter
new file mode 100644
index 00000000..a09f331d
--- /dev/null
+++ b/mods/mod_hakchi/hakchi/rootfs/bin/mcp-restarter
@@ -0,0 +1,10 @@
+#!/bin/sh
+flag=/tmp/startmpc.flag
+while [ true ]; do
+ #sleep 1
+ if [ -f "$flag" ]; then
+ echo Restart!
+ /etc/init.d/S81clover-mcp start
+ rm $flag
+ fi
+done
diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/init.d/S82mcp-restarter b/mods/mod_hakchi/hakchi/rootfs/etc/init.d/S82mcp-restarter
new file mode 100644
index 00000000..964c84de
--- /dev/null
+++ b/mods/mod_hakchi/hakchi/rootfs/etc/init.d/S82mcp-restarter
@@ -0,0 +1,26 @@
+#!/bin/sh -e
+
+start() {
+ mcp-restarter &
+}
+
+stop() {
+ killall mcp-restarter
+}
+
+case "$1" in
+start)
+ start
+;;
+stop)
+ stop
+;;
+restart)
+ stop
+ start
+;;
+*)
+ echo "mcp-restarter: Please use start, stop, or restart."
+ exit 1
+;;
+esac