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-07 12:29:46 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-07 12:32:01 +0300
commit7b484538db8e30b0a20315ffc448b342dd39c67f (patch)
tree62a105955d9307a732ddc7e1816222df2e4df0ac /Apps
parentc7fc8c5989cd3ae6bb2bdc93c9978fb53fd55829 (diff)
Many tiny fixes, rc5
Diffstat (limited to 'Apps')
-rw-r--r--Apps/NesGame.cs20
-rw-r--r--Apps/NesMiniApplication.cs33
-rw-r--r--Apps/SnesGame.cs10
3 files changed, 48 insertions, 15 deletions
diff --git a/Apps/NesGame.cs b/Apps/NesGame.cs
index 6fedd280..f075e038 100644
--- a/Apps/NesGame.cs
+++ b/Apps/NesGame.cs
@@ -51,7 +51,7 @@ namespace com.clusterrr.hakchi_gui
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 uint crc32)
+ 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)
{
// Try to patch before mapper check, maybe it will patch mapper
FindPatch(ref rawRomData, inputFileName, crc32);
@@ -69,15 +69,22 @@ namespace com.clusterrr.hakchi_gui
nesFile.CorrectRom();
crc32 = nesFile.CRC32;
if (ConfigIni.ConsoleType == MainForm.ConsoleType.NES || ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom)
+ {
application = "/bin/clover-kachikachi-wr";
+ args = DefaultArgs;
+ }
else
+ {
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 (!supportedMappers.Contains(nesFile.Mapper) &&
+ (ConfigIni.ConsoleType == MainForm.ConsoleType.NES || ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom)
+ && (IgnoreMapper != true))
{
if (IgnoreMapper != false)
{
@@ -93,7 +100,9 @@ namespace com.clusterrr.hakchi_gui
}
else return false;
}
- if ((nesFile.Mirroring == NesFile.MirroringType.FourScreenVram) && (IgnoreMapper != true))
+ if ((nesFile.Mirroring == NesFile.MirroringType.FourScreenVram) &&
+ (ConfigIni.ConsoleType == MainForm.ConsoleType.NES || ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom) &&
+ (IgnoreMapper != true))
{
var r = WorkerForm.MessageBoxFromThread(ParentForm,
string.Format(Resources.FourScreenNotSupported, System.IO.Path.GetFileName(inputFileName)),
@@ -109,7 +118,10 @@ namespace com.clusterrr.hakchi_gui
// 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;
+
+ if (nesFile.Battery)
+ saveCount = 3;
+
return true;
}
diff --git a/Apps/NesMiniApplication.cs b/Apps/NesMiniApplication.cs
index ed626e9f..153629f9 100644
--- a/Apps/NesMiniApplication.cs
+++ b/Apps/NesMiniApplication.cs
@@ -131,6 +131,16 @@ namespace com.clusterrr.hakchi_gui
publisher = value;
}
}
+ private byte saveCount;
+ public byte SaveCount
+ {
+ get { return saveCount; }
+ set
+ {
+ if (saveCount != value) hasUnsavedChanges = true;
+ saveCount = value;
+ }
+ }
public static NesMiniApplication FromDirectory(string path, bool ignoreEmptyConfig = false)
{
@@ -168,6 +178,7 @@ namespace com.clusterrr.hakchi_gui
string application = extension.Length > 2 ? ("/bin/" + extension.Substring(1)) : DefaultApp;
string args = null;
Image cover = DefaultCover;
+ byte saveCount = 0;
uint crc32 = CRC32(rawRomData);
string outputFileName = Regex.Replace(System.IO.Path.GetFileName(inputFileName), @"[^A-Za-z0-9()!\[\]\.\-]", "_").Trim();
@@ -183,7 +194,7 @@ namespace com.clusterrr.hakchi_gui
var patch = appinfo.Class.GetMethod("Patch");
if (patch != null)
{
- object[] values = new object[] { inputFileName, rawRomData, prefix, application, outputFileName, args, cover, crc32 };
+ object[] values = new object[] { inputFileName, rawRomData, prefix, application, outputFileName, args, cover, saveCount, crc32 };
var result = (bool)patch.Invoke(null, values);
if (!result) return null;
rawRomData = (byte[])values[1];
@@ -192,7 +203,8 @@ namespace com.clusterrr.hakchi_gui
outputFileName = (string)values[4];
args = (string)values[5];
cover = (Image)values[6];
- crc32 = (uint)values[7];
+ saveCount = (byte)values[7];
+ crc32 = (uint)values[8];
patched = true;
}
}
@@ -224,6 +236,7 @@ namespace com.clusterrr.hakchi_gui
if (!string.IsNullOrEmpty(args))
game.Command += " " + args;
game.FindCover(inputFileName, cover, crc32);
+ game.SaveCount = saveCount;
game.Save();
var app = NesMiniApplication.FromDirectory(gamePath);
@@ -255,6 +268,7 @@ namespace com.clusterrr.hakchi_gui
ReleaseDate = DefaultReleaseDate;
Publisher = DefaultPublisher;
Command = "";
+ SaveCount = 0;
}
protected NesMiniApplication(string path, bool ignoreEmptyConfig = false)
@@ -303,6 +317,9 @@ namespace com.clusterrr.hakchi_gui
case "sortrawpublisher":
Publisher = value;
break;
+ case "savecount":
+ SaveCount = byte.Parse(value);
+ break;
}
}
hasUnsavedChanges = false;
@@ -327,7 +344,7 @@ namespace com.clusterrr.hakchi_gui
$"Players={Players}\n" +
$"Simultaneous={(Simultaneous ? 1 : 0)}\n" +
$"ReleaseDate={ReleaseDate ?? DefaultReleaseDate}\n" +
- $"SaveCount=0\n" +
+ $"SaveCount={SaveCount}\n" +
$"SortRawTitle={(Name ?? Code).ToLower()}\n" +
$"SortRawPublisher={(Publisher ?? DefaultPublisher).ToUpper()}\n" +
$"Copyright=hakchi2 ©2017 Alexey 'Cluster' Avdyukhin\n");
@@ -367,19 +384,19 @@ namespace com.clusterrr.hakchi_gui
if (ConfigIni.ConsoleType == MainForm.ConsoleType.SNES || ConfigIni.ConsoleType == MainForm.ConsoleType.SuperFamicom)
{
maxX = 228;
- maxY = 228;
+ maxY = 204;
}
if ((double)image.Width / (double)image.Height > (double)maxX / (double)maxY)
- outImage = new Bitmap(maxX, (int)((double)maxY * (double)image.Height / (double)image.Width));
+ outImage = new Bitmap(maxX, (int)((double)maxX * (double)image.Height / (double)image.Width));
else
- outImage = new Bitmap((int)(maxX * (double)image.Width / (double)image.Height), maxY);
+ outImage = new Bitmap((int)(maxY * (double)image.Width / (double)image.Height), maxY);
int maxXsmall = 40;
int maxYsmall = 40;
if ((double)image.Width / (double)image.Height > (double)maxXsmall / (double)maxYsmall)
- outImageSmall = new Bitmap(maxXsmall, (int)((double)maxYsmall * (double)image.Height / (double)image.Width));
+ outImageSmall = new Bitmap(maxXsmall, (int)((double)maxXsmall * (double)image.Height / (double)image.Width));
else
- outImageSmall = new Bitmap((int)(maxXsmall * (double)image.Width / (double)image.Height), maxYsmall);
+ outImageSmall = new Bitmap((int)(maxYsmall * (double)image.Width / (double)image.Height), maxYsmall);
gr = Graphics.FromImage(outImage);
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
diff --git a/Apps/SnesGame.cs b/Apps/SnesGame.cs
index f6a89fbd..cf148752 100644
--- a/Apps/SnesGame.cs
+++ b/Apps/SnesGame.cs
@@ -79,7 +79,7 @@ namespace com.clusterrr.hakchi_gui
{
}
- 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)
+ 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)
{
FindPatch(ref rawRomData, inputFileName, crc32);
if (inputFileName.Contains("(E)") || inputFileName.Contains("(J)"))
@@ -97,7 +97,7 @@ namespace com.clusterrr.hakchi_gui
Array.Copy(rawRomData, 512, stripped, 0, stripped.Length);
rawRomData = stripped;
}
- MakeSfrom(ref rawRomData);
+ MakeSfrom(ref rawRomData, ref saveCount);
outputFileName = Path.GetFileNameWithoutExtension(outputFileName) + ".sfrom";
}
}
@@ -109,7 +109,7 @@ namespace com.clusterrr.hakchi_gui
return true;
}
- private static void MakeSfrom(ref byte[] rawRomData)
+ private static void MakeSfrom(ref byte[] rawRomData, ref byte saveCount)
{
var romHeaderLoRom = SnesRomHeader.Read(rawRomData, 0x7FC0);
var romHeaderHiRom = SnesRomHeader.Read(rawRomData, 0xFFC0);
@@ -167,6 +167,10 @@ namespace com.clusterrr.hakchi_gui
Array.Copy(sfromHeader1Raw, 0, result, 0, sfromHeader1Raw.Length);
Array.Copy(rawRomData, 0, result, sfromHeader1Raw.Length, rawRomData.Length);
Array.Copy(sfromHeader2Raw, 0, result, sfromHeader1Raw.Length + rawRomData.Length, sfromHeader2Raw.Length);
+
+ if (romHeader.SramSize > 0)
+ saveCount = 3;
+
rawRomData = result;
}