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
path: root/Apps
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-10 10:17:00 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-10 10:17:00 +0300
commitc69fe813667edb0c3161c00ec3adfddaced2e375 (patch)
tree7ae9e32130722cb5927cbdc52de9480a95cde51f /Apps
parentd54bdf45f08e0772eb53de7ea2e18b69924804b2 (diff)
Added GameGenie for SNES but it glitchy and commented out
Diffstat (limited to 'Apps')
-rw-r--r--Apps/ISupportsGameGenie.cs2
-rw-r--r--Apps/NesGame.cs65
-rw-r--r--Apps/NesMiniApplication.cs25
-rw-r--r--Apps/SnesGame.cs43
4 files changed, 83 insertions, 52 deletions
diff --git a/Apps/ISupportsGameGenie.cs b/Apps/ISupportsGameGenie.cs
index 580572da..98803c6d 100644
--- a/Apps/ISupportsGameGenie.cs
+++ b/Apps/ISupportsGameGenie.cs
@@ -7,8 +7,6 @@ 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 b184c010..3f1a1877 100644
--- a/Apps/NesGame.cs
+++ b/Apps/NesGame.cs
@@ -16,12 +16,10 @@ namespace com.clusterrr.hakchi_gui
public class NesGame : NesMiniApplication, ICloverAutofill, ISupportsGameGenie
{
public const char Prefix = 'H';
- 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
@@ -32,23 +30,9 @@ namespace com.clusterrr.hakchi_gui
}
}
- private string gameGenie = "";
- public string GameGenie
- {
- get { return gameGenie; }
- set
- {
- if (gameGenie != value) hasUnsavedChanges = true;
- gameGenie = value;
- }
- }
-
public NesGame(string path, bool ignoreEmptyConfig = false)
: base(path, ignoreEmptyConfig)
{
- GameGeniePath = System.IO.Path.Combine(path, GameGenieFileName);
- if (File.Exists(GameGeniePath))
- gameGenie = File.ReadAllText(GameGeniePath);
}
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 byte saveCount, ref uint crc32)
@@ -149,37 +133,6 @@ namespace com.clusterrr.hakchi_gui
return false;
}
- public override bool Save()
- {
- var old = hasUnsavedChanges;
- if (hasUnsavedChanges)
- {
- if (!string.IsNullOrEmpty(gameGenie))
- File.WriteAllText(GameGeniePath, gameGenie);
- else
- File.Delete(GameGeniePath);
- }
- return base.Save() || old;
- }
-
- public void ApplyGameGenie()
- {
- if (!string.IsNullOrEmpty(GameGenie))
- {
- var codes = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
- var nesFiles = Directory.GetFiles(this.GamePath, "*.nes", SearchOption.TopDirectoryOnly);
- foreach (var f in nesFiles)
- {
- var nesFile = new NesFile(f);
- foreach (var code in codes)
- {
- nesFile.PRG = GameGeniePatcher.Patch(nesFile.PRG, code.Trim());
- }
- nesFile.Save(f);
- }
- }
- }
-
private struct CachedGameInfo
{
public string Name;
@@ -232,6 +185,24 @@ namespace com.clusterrr.hakchi_gui
Debug.WriteLine(ex.Message + ex.StackTrace);
}
}
+
+ public void ApplyGameGenie()
+ {
+ if (!string.IsNullOrEmpty(GameGenie))
+ {
+ var codes = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
+ var nesFiles = Directory.GetFiles(this.GamePath, "*.nes", SearchOption.TopDirectoryOnly);
+ foreach (var f in nesFiles)
+ {
+ var nesFile = new NesFile(f);
+ foreach (var code in codes)
+ {
+ nesFile.PRG = GameGeniePatcherNes.Patch(nesFile.PRG, code.Trim());
+ }
+ nesFile.Save(f);
+ }
+ }
+ }
}
}
diff --git a/Apps/NesMiniApplication.cs b/Apps/NesMiniApplication.cs
index 7bc8478d..a45d43e1 100644
--- a/Apps/NesMiniApplication.cs
+++ b/Apps/NesMiniApplication.cs
@@ -67,6 +67,20 @@ namespace com.clusterrr.hakchi_gui
get { return "game"; }
}
+
+ public const string GameGenieFileName = "gamegenie.txt";
+ public string GameGeniePath { private set; get; }
+ private string gameGenie = "";
+ public string GameGenie
+ {
+ get { return gameGenie; }
+ set
+ {
+ if (gameGenie != value) hasUnsavedChanges = true;
+ gameGenie = value;
+ }
+ }
+
public readonly string GamePath;
public readonly string ConfigPath;
public readonly string IconPath;
@@ -324,6 +338,11 @@ namespace com.clusterrr.hakchi_gui
break;
}
}
+
+ GameGeniePath = Path.Combine(path, GameGenieFileName);
+ if (File.Exists(GameGeniePath))
+ gameGenie = File.ReadAllText(GameGeniePath);
+
hasUnsavedChanges = false;
}
@@ -350,6 +369,12 @@ namespace com.clusterrr.hakchi_gui
$"SortRawTitle={(Name ?? Code).ToLower()}\n" +
$"SortRawPublisher={(Publisher ?? DefaultPublisher).ToUpper()}\n" +
$"Copyright=hakchi2 ©2017 Alexey 'Cluster' Avdyukhin\n");
+
+ if (!string.IsNullOrEmpty(gameGenie))
+ File.WriteAllText(GameGeniePath, gameGenie);
+ else if (File.Exists(GameGeniePath))
+ File.Delete(GameGeniePath);
+
hasUnsavedChanges = false;
return true;
}
diff --git a/Apps/SnesGame.cs b/Apps/SnesGame.cs
index 0a52d7ca..e0dbad22 100644
--- a/Apps/SnesGame.cs
+++ b/Apps/SnesGame.cs
@@ -12,7 +12,7 @@ using System.Xml.XPath;
namespace com.clusterrr.hakchi_gui
{
- public class SnesGame : NesMiniApplication, ICloverAutofill
+ public class SnesGame : NesMiniApplication, ICloverAutofill /*, ISupportsGameGenie*/
{
public enum SnesRomType { LoRom = 0x14, HiRom = 0x15 };
@@ -213,7 +213,7 @@ namespace com.clusterrr.hakchi_gui
return true;
}
- private static SnesRomHeader GetCorrectHeader(byte[] rawRomData, out SnesRomType romType, out string gameTitle)
+ public static SnesRomHeader GetCorrectHeader(byte[] rawRomData, out SnesRomType romType, out string gameTitle)
{
var romHeaderLoRom = SnesRomHeader.Read(rawRomData, 0x7FC0);
var romHeaderHiRom = SnesRomHeader.Read(rawRomData, 0xFFC0);
@@ -382,7 +382,7 @@ namespace com.clusterrr.hakchi_gui
[StructLayout(LayoutKind.Sequential)]
- private struct SnesRomHeader
+ public struct SnesRomHeader
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 21)]
public byte[] GameTitleArr;
@@ -712,6 +712,43 @@ namespace com.clusterrr.hakchi_gui
}
return false;
}
+
+ public void ApplyGameGenie()
+ {
+ if (!string.IsNullOrEmpty(GameGenie))
+ {
+ var codes = GameGenie.Split(new char[] { ',', '\t', ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
+ var nesFiles = Directory.GetFiles(this.GamePath, "*.*", SearchOption.TopDirectoryOnly);
+ foreach (var f in nesFiles)
+ {
+ byte[] data;
+ var ext = Path.GetExtension(f).ToLower();
+ int offset;
+ if (ext == ".sfrom")
+ {
+ data = File.ReadAllBytes(f);
+ offset = 48;
+ } else if (ext == ".sfc" || ext == ".smc")
+ {
+ data = File.ReadAllBytes(f);
+ if ((data.Length % 1024) != 0)
+ offset = 512;
+ else
+ offset = 0;
+ }
+ else continue;
+
+ var rawData = new byte[data.Length - offset];
+ Array.Copy(data, offset, rawData, 0, rawData.Length);
+
+ foreach (var code in codes)
+ rawData = GameGeniePatcherSnes.Patch(rawData, code);
+
+ Array.Copy(rawData, 0, data, offset, rawData.Length);
+ File.WriteAllBytes(f, data);
+ }
+ }
+ }
}
}