diff --git a/ArcFormats/ImageMCG.cs b/ArcFormats/ImageMCG.cs
index 3feb3c50..b459c41c 100644
--- a/ArcFormats/ImageMCG.cs
+++ b/ArcFormats/ImageMCG.cs
@@ -26,9 +26,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
-using System.Diagnostics;
using System.IO;
using System.Windows.Media;
+using GameRes.Formats.Properties;
using GameRes.Utility;
namespace GameRes.Formats.FC01
@@ -102,6 +102,7 @@ namespace GameRes.Formats.FC01
uint m_width;
uint m_height;
uint m_pixels;
+ byte m_key;
public byte[] Data { get { return m_output; } }
@@ -115,6 +116,7 @@ namespace GameRes.Formats.FC01
m_height = info.Height;
m_pixels = m_width*m_height;
m_output = new byte[m_pixels*3];
+ m_key = Settings.Default.MCGLastKey;
}
static readonly byte[] ChannelOrder = { 1, 0, 2 };
@@ -122,9 +124,9 @@ namespace GameRes.Formats.FC01
public void Unpack ()
{
var reader = new MrgDecoder (m_input, 0, m_pixels);
- for (int key = 0; key < 0x100; ++key)
+ do
{
- reader.ResetKey ((byte)key);
+ reader.ResetKey (m_key);
try
{
for (int i = 0; i < 3; ++i)
@@ -141,18 +143,19 @@ namespace GameRes.Formats.FC01
}
catch (InvalidFormatException)
{
+ m_key++;
continue;
}
Transform();
+ Settings.Default.MCGLastKey = m_key;
return;
}
+ while (m_key != Settings.Default.MCGLastKey);
throw new UnknownEncryptionScheme();
}
void Transform ()
{
- // esi = m_input
- // dst = m_output
uint dst = 0;
uint stride = (m_width - 1) * 3;
for (uint y = m_height-1; y > 0; --y) // @@1a
diff --git a/ArcFormats/Properties/AssemblyInfo.cs b/ArcFormats/Properties/AssemblyInfo.cs
index fc62dbc4..9bbba203 100644
--- a/ArcFormats/Properties/AssemblyInfo.cs
+++ b/ArcFormats/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion ("1.0.7.79")]
-[assembly: AssemblyFileVersion ("1.0.7.79")]
+[assembly: AssemblyVersion ("1.0.7.80")]
+[assembly: AssemblyFileVersion ("1.0.7.80")]
diff --git a/ArcFormats/Properties/Settings.Designer.cs b/ArcFormats/Properties/Settings.Designer.cs
index 4c44636b..0de953b7 100644
--- a/ArcFormats/Properties/Settings.Designer.cs
+++ b/ArcFormats/Properties/Settings.Designer.cs
@@ -381,5 +381,17 @@ namespace GameRes.Formats.Properties {
this["ISFScheme"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public byte MCGLastKey {
+ get {
+ return ((byte)(this["MCGLastKey"]));
+ }
+ set {
+ this["MCGLastKey"] = value;
+ }
+ }
}
}
diff --git a/ArcFormats/Properties/Settings.settings b/ArcFormats/Properties/Settings.settings
index 0685eef3..ae03c51c 100644
--- a/ArcFormats/Properties/Settings.settings
+++ b/ArcFormats/Properties/Settings.settings
@@ -92,5 +92,8 @@
+
+ 0
+
\ No newline at end of file
diff --git a/ArcFormats/app.config b/ArcFormats/app.config
index 5944f914..67fefa59 100644
--- a/ArcFormats/app.config
+++ b/ArcFormats/app.config
@@ -94,6 +94,9 @@
+
+ 0
+