Image bank refactor + global variables/members name refactor

master
REDxEYE 5 years ago
parent 0fa315477d
commit 0609171eaf

@ -72,8 +72,9 @@
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Ionic.Zlib"> <Reference Include="Ionic.Zlib, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c">
<HintPath>E:\ClickTFReader-master\DUMP\fnaf-world\CHUNKS\Ionic.Zlib.dll</HintPath> <HintPath>..\packages\Ionic.Zlib.1.9.1.5\lib\Ionic.Zlib.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -95,7 +96,6 @@
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MMFParser\ChunkLoaders\AppMenu.cs" /> <Compile Include="MMFParser\ChunkLoaders\AppMenu.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\DebugImageBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Events.cs" /> <Compile Include="MMFParser\ChunkLoaders\Events\Events.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\EventsParts.cs" /> <Compile Include="MMFParser\ChunkLoaders\Events\EventsParts.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Expressions\Expression.cs" /> <Compile Include="MMFParser\ChunkLoaders\Events\Expressions\Expression.cs" />
@ -143,6 +143,7 @@
<Compile Include="MMFParser\ChunkLoaders\StringChunk.cs" /> <Compile Include="MMFParser\ChunkLoaders\StringChunk.cs" />
<Compile Include="MMFParser\ChunkLoaders\yves.cs" /> <Compile Include="MMFParser\ChunkLoaders\yves.cs" />
<Compile Include="MMFParser\Constants.cs" /> <Compile Include="MMFParser\Constants.cs" />
<Compile Include="utils\BitDict.cs" />
<Compile Include="utils\ByteFlag.cs" /> <Compile Include="utils\ByteFlag.cs" />
<Compile Include="utils\ByteWriter.cs" /> <Compile Include="utils\ByteWriter.cs" />
<Compile Include="utils\Helper.cs" /> <Compile Include="utils\Helper.cs" />

@ -38,7 +38,7 @@
// //
// button1 // button1
// //
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.button1.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.Lime; this.button1.ForeColor = System.Drawing.Color.Lime;
this.button1.Location = new System.Drawing.Point(12, 12); this.button1.Location = new System.Drawing.Point(12, 12);
@ -115,16 +115,15 @@
this.Load += new System.EventHandler(this.MainForm_Load); this.Load += new System.EventHandler(this.MainForm_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
#endregion
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label GameInfo; private System.Windows.Forms.Label GameInfo;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TreeView treeView1;
#endregion
} }
} }

@ -14,7 +14,7 @@ namespace NetMFAPatcher.GUI
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
public Thread loaderThread; public Thread LoaderThread;
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
@ -57,28 +57,28 @@ namespace NetMFAPatcher.GUI
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{ {
var currentFrame = EXE.LatestInst.game_data.Frames[treeView1.SelectedNode.Index]; var currentFrame = Exe.LatestInst.GameData.Frames[treeView1.SelectedNode.Index];
listBox1.Items.Clear(); listBox1.Items.Clear();
listBox1.Items.Add($"Size: {currentFrame.width}x{currentFrame.height}"); listBox1.Items.Add($"Size: {currentFrame.Width}x{currentFrame.Height}");
listBox1.Items.Add($"Number of objects: {currentFrame.CountOfObjs}"); listBox1.Items.Add($"Number of objects: {currentFrame.CountOfObjs}");
} }
public void AfterLoad() public void AfterLoad()
{ {
var gameData = EXE.LatestInst.game_data; var gameData = Exe.LatestInst.GameData;
foreach (var item in gameData.Frames) foreach (var item in gameData.Frames)
{ {
treeView1.Nodes.Add(item.name); treeView1.Nodes.Add(item.Name);
} }
string toLog = ""; string toLog = "";
toLog += $"Title:{EXE.LatestInst.game_data.Name}\n"; toLog += $"Title:{Exe.LatestInst.GameData.Name}\n";
toLog += $"Copyright:{EXE.LatestInst.game_data.Copyright}\n"; toLog += $"Copyright:{Exe.LatestInst.GameData.Copyright}\n";
toLog += $"Editor Filename: {EXE.LatestInst.game_data.EditorFilename}\n"; toLog += $"Editor Filename: {Exe.LatestInst.GameData.EditorFilename}\n";
//toLog += $"Build Filename: {EXE.LatestInst.game_data.TargetFilename}\n"; //toLog += $"Build Filename: {EXE.LatestInst.game_data.TargetFilename}\n";
toLog += $"Product Build: {EXE.LatestInst.game_data.product_build}\n"; toLog += $"Product Build: {Exe.LatestInst.GameData.ProductBuild}\n";
toLog += $"Build: {EXE.LatestInst.game_data.build}\n"; toLog += $"Build: {Exe.LatestInst.GameData.Build}\n";
toLog += $"Runtime Version: {EXE.LatestInst.game_data.runtime_version}\n"; toLog += $"Runtime Version: {Exe.LatestInst.GameData.RuntimeVersion}\n";

@ -1,5 +1,4 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.Utils;
using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -34,37 +33,37 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{ {
while(true) while(true)
{ {
var identifier = reader.ReadAscii(4); var identifier = Reader.ReadAscii(4);
if (identifier == Header) if (identifier == Header)
{ {
MaxObjects = reader.ReadInt16(); MaxObjects = Reader.ReadInt16();
MaxObjectInfo = reader.ReadInt16(); MaxObjectInfo = Reader.ReadInt16();
NumberOfPlayers = reader.ReadInt16(); NumberOfPlayers = Reader.ReadInt16();
for (int i = 0; i < 17; i++) for (int i = 0; i < 17; i++)
{ {
NumberOfConditions.Add(reader.ReadInt16()); NumberOfConditions.Add(Reader.ReadInt16());
} }
var QualifierCount = reader.ReadInt16();//should be 0, so i dont give a fuck var qualifierCount = Reader.ReadInt16();//should be 0, so i dont give a fuck
Quailifers = new Quailifer[QualifierCount + 1]; Quailifers = new Quailifer[qualifierCount + 1];
for (int i = 0; i < QualifierCount; i++) for (int i = 0; i < qualifierCount; i++)
{ {
var NewQualifier = new Quailifer(reader); var newQualifier = new Quailifer(Reader);
QualifiersList.Add(NewQualifier);//fucking python types QualifiersList.Add(newQualifier);//fucking python types
//THIS IS NOT DONE //THIS IS NOT DONE
} }
} }
else if (identifier == EventCount) else if (identifier == EventCount)
{ {
var size = reader.ReadInt32(); var size = Reader.ReadInt32();
} }
else if (identifier == EventgroupData) else if (identifier == EventgroupData)
{ {
var size = reader.ReadInt32(); var size = Reader.ReadInt32();
var end_position = reader.Tell() + size; var endPosition = Reader.Tell() + size;
while (true) while (true)
{ {
var eg = new EventGroup(reader); var eg = new EventGroup(Reader);
eg.Read(); eg.Read();
} }
} }
@ -77,10 +76,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public class Quailifer : ChunkLoader public class Quailifer : ChunkLoader
{ {
public int objectInfo; public int ObjectInfo;
public int type; public int Type;
public Quailifer qualifier; public Quailifer Qualifier;
List<int> Objects = new List<int>(); List<int> _objects = new List<int>();
public Quailifer(Chunk chunk) : base(chunk) { } public Quailifer(Chunk chunk) : base(chunk) { }
public Quailifer(ByteIO reader) : base(reader) { } public Quailifer(ByteIO reader) : base(reader) { }
@ -92,9 +91,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read() public override void Read()
{ {
objectInfo = reader.ReadUInt16(); ObjectInfo = Reader.ReadUInt16();
type = reader.ReadInt16(); Type = Reader.ReadInt16();
qualifier = this; Qualifier = this;
} }
} }
@ -104,9 +103,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{ {
public int Flags; public int Flags;
public int IsRestricted; public int IsRestricted;
public int restrictCPT; public int RestrictCpt;
public int identifier; public int Identifier;
public int undo; public int Undo;
public List<Condition> Conditions = new List<Condition>(); public List<Condition> Conditions = new List<Condition>();
public List<Action> Actions = new List<Action>(); public List<Action> Actions = new List<Action>();
@ -120,27 +119,27 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read() public override void Read()
{ {
var currentPosition = reader.Tell(); var currentPosition = Reader.Tell();
var size = reader.ReadInt16() * -1; var size = Reader.ReadInt16() * -1;
var NumberOfConditions = reader.ReadByte(); var numberOfConditions = Reader.ReadByte();
var NumberOfActions = reader.ReadByte(); var numberOfActions = Reader.ReadByte();
var flags = reader.ReadUInt16(); var flags = Reader.ReadUInt16();
var nop = reader.ReadInt16(); var nop = Reader.ReadInt16();
IsRestricted = reader.ReadInt32(); IsRestricted = Reader.ReadInt32();
restrictCPT = reader.ReadInt32(); RestrictCpt = Reader.ReadInt32();
for (int i = 0; i < NumberOfConditions; i++) for (int i = 0; i < numberOfConditions; i++)
{ {
var item = new Condition(reader); var item = new Condition(Reader);
item.Read(); item.Read();
Conditions.Add(item); Conditions.Add(item);
} }
for (int i = 0; i < NumberOfActions; i++) for (int i = 0; i < numberOfActions; i++)
{ {
var item = new Action(reader); var item = new Action(Reader);
item.Read(); item.Read();
Actions.Add(item); Actions.Add(item);
} }
reader.Seek(currentPosition + size); Reader.Seek(currentPosition + size);
Console.WriteLine("IF:"); Console.WriteLine("IF:");
if (Conditions!=null) if (Conditions!=null)
{ {

@ -1,5 +1,4 @@
using mmfparser; using mmfparser;
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.MMFParser.Data; using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
@ -7,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.utils;
using static NetMFAPatcher.mmfparser.Constants; using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
@ -18,11 +18,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public int DefType; public int DefType;
public int NumberOfParameters; public int NumberOfParameters;
public ObjectType ObjectType; public ObjectType ObjectType;
public int num; public int Num;
public int ObjectInfo; public int ObjectInfo;
public int Identifier; public int Identifier;
public int ObjectInfoList; public int ObjectInfoList;
public List<Parameter> items = new List<Parameter>(); public List<Parameter> Items = new List<Parameter>();
public Condition(ByteIO reader) : base(reader) { } public Condition(ByteIO reader) : base(reader) { }
public override void Print() public override void Print()
{ {
@ -31,31 +31,31 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read() public override void Read()
{ {
var currentPosition = reader.Tell(); var currentPosition = Reader.Tell();
var size = reader.ReadUInt16(); var size = Reader.ReadUInt16();
ObjectType = (ObjectType)reader.ReadInt16(); ObjectType = (ObjectType)Reader.ReadInt16();
num = reader.ReadInt16(); Num = Reader.ReadInt16();
ObjectInfo = reader.ReadUInt16(); ObjectInfo = Reader.ReadUInt16();
ObjectInfoList = reader.ReadInt16(); ObjectInfoList = Reader.ReadInt16();
Flags = reader.ReadSByte(); Flags = Reader.ReadSByte();
OtherFlags = reader.ReadSByte(); OtherFlags = Reader.ReadSByte();
NumberOfParameters = reader.ReadByte(); NumberOfParameters = Reader.ReadByte();
DefType = reader.ReadByte(); DefType = Reader.ReadByte();
Identifier = reader.ReadInt16(); Identifier = Reader.ReadInt16();
for (int i = 0; i < NumberOfParameters; i++) for (int i = 0; i < NumberOfParameters; i++)
{ {
var item = new Parameter(reader); var item = new Parameter(Reader);
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }
reader.Seek(currentPosition + size); Reader.Seek(currentPosition + size);
} }
public override string ToString() public override string ToString()
{ {
return $"Condition {ObjectType}-{num}-{(items.Count > 0 ? items[0].ToString() : "cock")}"; return $"Condition {ObjectType}-{Num}-{(Items.Count > 0 ? Items[0].ToString() : "cock")}";
} }
} }
@ -66,10 +66,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public int OtherFlags; public int OtherFlags;
public int DefType; public int DefType;
public ObjectType ObjectType; public ObjectType ObjectType;
public int num; public int Num;
public int ObjectInfo; public int ObjectInfo;
public int ObjectInfoList; public int ObjectInfoList;
public List<Parameter> items = new List<Parameter>(); public List<Parameter> Items = new List<Parameter>();
public Action(ByteIO reader) : base(reader) { } public Action(ByteIO reader) : base(reader) { }
public override void Print( ) public override void Print( )
{ {
@ -78,21 +78,21 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read() public override void Read()
{ {
var currentPosition = reader.Tell(); var currentPosition = Reader.Tell();
var size = reader.ReadUInt16(); var size = Reader.ReadUInt16();
ObjectType = (ObjectType)reader.ReadInt16(); ObjectType = (ObjectType)Reader.ReadInt16();
num = reader.ReadInt16(); Num = Reader.ReadInt16();
ObjectInfo = reader.ReadUInt16(); ObjectInfo = Reader.ReadUInt16();
ObjectInfoList = reader.ReadInt16(); ObjectInfoList = Reader.ReadInt16();
Flags = reader.ReadSByte(); Flags = Reader.ReadSByte();
OtherFlags = reader.ReadSByte(); OtherFlags = Reader.ReadSByte();
var number_of_parameters=reader.ReadByte(); var numberOfParameters=Reader.ReadByte();
DefType = reader.ReadByte(); DefType = Reader.ReadByte();
for (int i = 0; i < DefType; i++) for (int i = 0; i < DefType; i++)
{ {
var item = new Parameter(reader); var item = new Parameter(Reader);
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }
@ -100,7 +100,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override string ToString() public override string ToString()
{ {
return $"Action {ObjectType}-{num}-{(items.Count>0?items[0].ToString():"cock")}"; return $"Action {ObjectType}-{Num}-{(Items.Count>0?Items[0].ToString():"cock")}";
} }
} }
@ -108,7 +108,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public class Parameter : DataLoader public class Parameter : DataLoader
{ {
public int Code; public int Code;
public DataLoader loader; public DataLoader Loader;
public Parameter(ByteIO reader) : base(reader) { } public Parameter(ByteIO reader) : base(reader) { }
@ -119,36 +119,36 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read() public override void Read()
{ {
var current_position = reader.Tell(); var currentPosition = Reader.Tell();
var size = reader.ReadInt16(); var size = Reader.ReadInt16();
Code = reader.ReadInt16(); Code = Reader.ReadInt16();
var ActualLoader = Helper.LoadParameter(Code,reader); var actualLoader = Helper.LoadParameter(Code,Reader);
this.loader = ActualLoader; this.Loader = actualLoader;
if (loader!=null) if (Loader!=null)
{ {
loader.Read(); Loader.Read();
} }
else else
{ {
//throw new Exception("Loader is null"); //throw new Exception("Loader is null");
} }
reader.Seek(current_position+size); Reader.Seek(currentPosition+size);
} }
public object value public object Value
{ {
get get
{ {
if (loader != null) if (Loader != null)
{ {
if (loader.GetType().GetField("value") != null) if (Loader.GetType().GetField("value") != null)
{ {
return loader.GetType().GetField("value").GetValue(loader); return Loader.GetType().GetField("value").GetValue(Loader);
} }
else else
{ {
@ -160,7 +160,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
} }
public override string ToString() public override string ToString()
{ {
if (loader != null) return loader.ToString(); if (Loader != null) return Loader.ToString();
else return "UNK-PARAMETER"; else return "UNK-PARAMETER";
} }

@ -12,7 +12,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Expressions
class Expression : DataLoader class Expression : DataLoader
{ {
public ObjectType ObjectType; public ObjectType ObjectType;
public int num; public int Num;
public int ObjectInfo; public int ObjectInfo;
public int ObjectInfoList; public int ObjectInfoList;
public Expression(ByteIO reader) : base(reader) { } public Expression(ByteIO reader) : base(reader) { }

@ -17,7 +17,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
} }
public override string ToString() public override string ToString()
{ {
return $"AlterableValue{Convert.ToChar(value).ToString().ToUpper()}"; return $"AlterableValue{Convert.ToChar(Value).ToString().ToUpper()}";
} }
} }
} }

@ -10,13 +10,13 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{ {
class Colour : ParameterCommon class Colour : ParameterCommon
{ {
public Color value; public Color Value;
public Colour(ByteIO reader) : base(reader) { } public Colour(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
var bytes = reader.ReadBytes(4); var bytes = Reader.ReadBytes(4);
value = Color.FromArgb(bytes[0], bytes[1], bytes[2]); Value = Color.FromArgb(bytes[0], bytes[1], bytes[2]);
} }

@ -16,10 +16,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Create(ByteIO reader) : base(reader) { } public Create(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
Position = new Position(reader); Position = new Position(Reader);
Position.Read(); Position.Read();
ObjectInstances = reader.ReadUInt16(); ObjectInstances = Reader.ReadUInt16();
ObjectInfo = reader.ReadUInt16(); ObjectInfo = Reader.ReadUInt16();
} }

@ -16,8 +16,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Every(ByteIO reader) : base(reader) { } public Every(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
Delay = reader.ReadInt32(); Delay = Reader.ReadInt32();
Compteur = reader.ReadInt32(); Compteur = Reader.ReadInt32();
} }
public override string ToString() public override string ToString()

@ -9,17 +9,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{ {
class Float : ParameterCommon class Float : ParameterCommon
{ {
public float value; public float Value;
public Float(ByteIO reader) : base(reader) { } public Float(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
value = reader.ReadSingle(); Value = Reader.ReadSingle();
} }
public override string ToString() public override string ToString()
{ {
return $"{this.GetType().Name} value: {value}"; return $"{this.GetType().Name} value: {Value}";
} }
} }
} }

@ -18,8 +18,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
} }
public override string ToString() public override string ToString()
{ {
if(value>26) return $"GlobalValue{value}"; if(Value>26) return $"GlobalValue{Value}";
return $"GlobalValue{Convert.ToChar(value).ToString().ToUpper()}"; return $"GlobalValue{Convert.ToChar(Value).ToString().ToUpper()}";
} }
} }
} }

@ -14,7 +14,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Int(ByteIO reader) : base(reader) { } public Int(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
value = (short)reader.ReadInt32(); Value = (short)Reader.ReadInt32();
} }
} }

@ -15,9 +15,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public ParamObject(ByteIO reader) : base(reader) { } public ParamObject(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
ObjectInfoList = reader.ReadInt16(); ObjectInfoList = Reader.ReadInt16();
ObjectInfo = reader.ReadUInt16(); ObjectInfo = Reader.ReadUInt16();
ObjectType = reader.ReadInt16(); ObjectType = Reader.ReadInt16();
} }
public override string ToString() public override string ToString()
{ {

@ -23,16 +23,16 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Position(ByteIO reader) : base(reader) { } public Position(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
ObjectInfoParent = reader.ReadInt16(); ObjectInfoParent = Reader.ReadInt16();
Flags = reader.ReadUInt16(); Flags = Reader.ReadUInt16();
X = reader.ReadInt16(); X = Reader.ReadInt16();
Y = reader.ReadInt16(); Y = Reader.ReadInt16();
Slope = reader.ReadInt16(); Slope = Reader.ReadInt16();
Angle = reader.ReadInt16(); Angle = Reader.ReadInt16();
Direction = reader.ReadSingle(); Direction = Reader.ReadSingle();
TypeParent = reader.ReadInt16(); TypeParent = Reader.ReadInt16();
ObjectInfoList = reader.ReadInt16(); ObjectInfoList = Reader.ReadInt16();
Layer = reader.ReadInt16(); Layer = Reader.ReadInt16();
} }

@ -9,20 +9,20 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{ {
class Sample : ParameterCommon class Sample : ParameterCommon
{ {
public int handle; public int Handle;
public string name; public string Name;
public int flags; public int Flags;
public Sample(ByteIO reader) : base(reader) { } public Sample(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
handle = reader.ReadInt16(); Handle = Reader.ReadInt16();
flags = reader.ReadUInt16(); Flags = Reader.ReadUInt16();
name = reader.ReadWideString(); Name = Reader.ReadWideString();
} }
public override string ToString() public override string ToString()
{ {
return $"Sample '{name}' handle: {handle}"; return $"Sample '{Name}' handle: {Handle}";
} }
} }
} }

@ -9,17 +9,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{ {
class Short : ParameterCommon class Short : ParameterCommon
{ {
public short value; public short Value;
public Short(ByteIO reader) : base(reader) { } public Short(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
value = reader.ReadInt16(); Value = Reader.ReadInt16();
} }
public override string ToString() public override string ToString()
{ {
return $"{this.GetType().Name} value: {value}"; return $"{this.GetType().Name} value: {Value}";
} }
} }
} }

@ -15,8 +15,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Time(ByteIO reader) : base(reader) { } public Time(ByteIO reader) : base(reader) { }
public override void Read() public override void Read()
{ {
Timer = reader.ReadInt32(); Timer = Reader.ReadInt32();
Loops = reader.ReadInt32(); Loops = Reader.ReadInt32();
} }
public override string ToString() public override string ToString()

@ -1,5 +1,4 @@
using NetMFAPatcher.chunkloaders; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -18,7 +17,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Read() public override void Read()
{ {
var filename = reader.ReadAscii(); var filename = Reader.ReadAscii();
//var data = reader.ReadBytes(); //var data = reader.ReadBytes();
} }
} }

@ -1,5 +1,4 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -12,7 +11,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public class GlobalValues : ChunkLoader public class GlobalValues : ChunkLoader
{ {
public List<float> items = new List<float>(); public List<float> Items = new List<float>();
public GlobalValues(Chunk chunk) : base(chunk) { } public GlobalValues(Chunk chunk) : base(chunk) { }
public override void Print(bool ext) public override void Print(bool ext)
{ {
@ -21,15 +20,15 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Read() public override void Read()
{ {
var numberOfItems = reader.ReadUInt16(); var numberOfItems = Reader.ReadUInt16();
var templist = new List<ByteIO>(); var templist = new List<ByteIO>();
for (int i = 0; i < numberOfItems; i++) for (int i = 0; i < numberOfItems; i++)
{ {
templist.Add(new ByteIO(reader.ReadBytes(4))); templist.Add(new ByteIO(Reader.ReadBytes(4)));
} }
foreach (var item in templist) foreach (var item in templist)
{ {
var globalType = reader.ReadSByte(); var globalType = Reader.ReadSByte();
float newGlobal = 0f; float newGlobal = 0f;
if((Constants.ValueType)globalType==Constants.ValueType.Float) if((Constants.ValueType)globalType==Constants.ValueType.Float)
{ {
@ -43,7 +42,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
throw new Exception("unknown global type"); throw new Exception("unknown global type");
} }
items.Add(newGlobal); Items.Add(newGlobal);
} }
@ -51,7 +50,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
} }
public class GlobalStrings : ChunkLoader public class GlobalStrings : ChunkLoader
{ {
public List<string> items = new List<string>(); public List<string> Items = new List<string>();
public GlobalStrings(Chunk chunk) : base(chunk) { } public GlobalStrings(Chunk chunk) : base(chunk) { }
public override void Print(bool ext) public override void Print(bool ext)
{ {
@ -60,10 +59,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Read() public override void Read()
{ {
var count = reader.ReadUInt32(); var count = Reader.ReadUInt32();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
items.Add(reader.ReadAscii()); Items.Add(Reader.ReadAscii());
} }
} }

@ -1,13 +1,13 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.Utils;
using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
class ObjectNames : ChunkLoader//Fucking trash class ObjectNames : ChunkLoader//Fucking trash
{ {
@ -18,13 +18,13 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read() public override void Read()
{ {
var start = reader.Tell(); var start = Reader.Tell();
var endpos = start + chunk.size; var endpos = start + Chunk.Size;
while(true) while(true)
{ {
if (reader.Tell() >= endpos+4) break; if (Reader.Tell() >= endpos+4) break;
Console.WriteLine(reader.ReadWideString()); Console.WriteLine(Reader.ReadWideString());
} }
} }

@ -1,40 +1,40 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events; using NetMFAPatcher.MMFParser.ChunkLoaders.Events;
using NetMFAPatcher.utils; using NetMFAPatcher.utils;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using static NetMFAPatcher.mmfparser.Constants; using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.Data namespace NetMFAPatcher.MMFParser.Data
{ {
public class ChunkList public class ChunkList
{ {
public List<Chunk> chunks = new List<Chunk>(); public List<Chunk> Chunks = new List<Chunk>();
public bool verbose = false; public bool Verbose = false;
public List<Frame> Frames = new List<Frame>(); public List<Frame> Frames = new List<Frame>();
public void Read(ByteIO exeReader) public void Read(ByteIO exeReader)
{ {
chunks.Clear(); Chunks.Clear();
while (true) while (true)
{ {
Chunk chunk = new Chunk(chunks.Count, this); Chunk chunk = new Chunk(Chunks.Count, this);
chunk.verbose = verbose; chunk.Verbose = Verbose;
chunk.Read(exeReader); chunk.Read(exeReader);
chunk.loader = LoadChunk(chunk); chunk.Loader = LoadChunk(chunk);
if (chunk.loader != null) if (chunk.Loader != null)
{ {
if (chunk.loader.verbose) if (chunk.Loader.Verbose)
{ {
//chunk.loader.Print(Program.LogAll); //chunk.loader.Print(Program.LogAll);
} }
} }
if (chunk.verbose) if (chunk.Verbose)
{ {
chunk.Print(Program.LogAll); chunk.Print(Program.LogAll);
if(Program.LogAll) Console.ReadKey(); if(Program.LogAll) Console.ReadKey();
@ -44,15 +44,15 @@ namespace NetMFAPatcher.MMFParser.Data
} }
chunks.Add(chunk); Chunks.Add(chunk);
if (chunk.id == 8750) if (chunk.Id == 8750)
{ {
chunk.BuildKey(); chunk.BuildKey();
} }
if (chunk.id == 32639) break; //LAST chunkID if (chunk.Id == 32639) break; //LAST chunkID
} }
//Logger.Log(verbose ? $" Total Chunks Count: {chunks.Count}":"ChunkList Done", true, ConsoleColor.Blue); //Logger.Log(verbose ? $" Total Chunks Count: {chunks.Count}":"ChunkList Done", true, ConsoleColor.Blue);
@ -60,62 +60,62 @@ namespace NetMFAPatcher.MMFParser.Data
public class Chunk public class Chunk
{ {
ChunkList chunk_list; ChunkList _chunkList;
public string name = "UNKNOWN"; public string Name = "UNKNOWN";
int uid; int _uid;
public int id = 0; public int Id = 0;
public ChunkLoader loader; public ChunkLoader Loader;
public byte[] chunk_data; public byte[] ChunkData;
public ChunkFlags flag; public ChunkFlags Flag;
public int size = 0; public int Size = 0;
public int decompressed_size = 0; public int DecompressedSize = 0;
public bool verbose = false; public bool Verbose = false;
public Chunk(int Actualuid, ChunkList actual_chunk_list) public Chunk(int actualuid, ChunkList actualChunkList)
{ {
uid = Actualuid; _uid = actualuid;
chunk_list = actual_chunk_list; _chunkList = actualChunkList;
} }
public ByteIO get_reader() public ByteIO get_reader()
{ {
return new ByteIO(chunk_data); return new ByteIO(ChunkData);
} }
public void Read(ByteIO exeReader) public void Read(ByteIO exeReader)
{ {
id = exeReader.ReadInt16(); Id = exeReader.ReadInt16();
name = ((ChunkNames) id).ToString(); Name = ((ChunkNames) Id).ToString();
flag = (ChunkFlags) exeReader.ReadInt16(); Flag = (ChunkFlags) exeReader.ReadInt16();
size = exeReader.ReadInt32(); Size = exeReader.ReadInt32();
switch (flag) switch (Flag)
{ {
case ChunkFlags.Encrypted: case ChunkFlags.Encrypted:
chunk_data = Decryption.DecodeChunk(exeReader.ReadBytes(size),size); ChunkData = Decryption.DecodeChunk(exeReader.ReadBytes(Size),Size);
break; break;
case ChunkFlags.CompressedAndEncrypyed: case ChunkFlags.CompressedAndEncrypyed:
chunk_data = Decryption.DecodeMode3(exeReader.ReadBytes(size), size,id); ChunkData = Decryption.DecodeMode3(exeReader.ReadBytes(Size), Size,Id);
break; break;
case ChunkFlags.Compressed: case ChunkFlags.Compressed:
chunk_data = Decompressor.Decompress(exeReader); ChunkData = Decompressor.Decompress(exeReader);
break; break;
case ChunkFlags.NotCompressed: case ChunkFlags.NotCompressed:
chunk_data = exeReader.ReadBytes(size); ChunkData = exeReader.ReadBytes(Size);
break; break;
} }
if (chunk_data != null) if (ChunkData != null)
{ {
decompressed_size = chunk_data.Length; DecompressedSize = ChunkData.Length;
string path = $"{Program.DumpPath}\\CHUNKS\\{name}.chunk"; // string path = $"{Program.DumpPath}\\CHUNKS\\{Name}.chunk";
File.WriteAllBytes(path, chunk_data); // File.WriteAllBytes(path, ChunkData);
} }
int tempId=0; int tempId=0;
int.TryParse(name,out tempId); int.TryParse(Name,out tempId);
if(tempId==id) if(tempId==Id)
{ {
//chunk_data.Log(true, "X2"); //chunk_data.Log(true, "X2");
} }
@ -126,22 +126,22 @@ namespace NetMFAPatcher.MMFParser.Data
{ {
if(extented) if(extented)
{ {
Logger.Log($"Chunk: {name} ({uid})", true, ConsoleColor.DarkCyan); Logger.Log($"Chunk: {Name} ({_uid})", true, ConsoleColor.DarkCyan);
Logger.Log($" ID: {id} - 0x{id.ToString("X")}", true, ConsoleColor.DarkCyan); Logger.Log($" ID: {Id} - 0x{Id.ToString("X")}", true, ConsoleColor.DarkCyan);
Logger.Log($" Flags: {flag}", true, ConsoleColor.DarkCyan); Logger.Log($" Flags: {Flag}", true, ConsoleColor.DarkCyan);
Logger.Log($" Loader: {(loader != null ? loader.GetType().Name : "Empty Loader")}", true,ConsoleColor.DarkCyan); Logger.Log($" Loader: {(Loader != null ? Loader.GetType().Name : "Empty Loader")}", true,ConsoleColor.DarkCyan);
Logger.Log($" Size: {size} B", true, ConsoleColor.DarkCyan); Logger.Log($" Size: {Size} B", true, ConsoleColor.DarkCyan);
Logger.Log($" Decompressed Size: {decompressed_size} B", true, ConsoleColor.DarkCyan); Logger.Log($" Decompressed Size: {DecompressedSize} B", true, ConsoleColor.DarkCyan);
Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan); Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan);
} }
else else
{ {
Logger.Log($"Chunk: {name} ({uid})", true, ConsoleColor.DarkCyan); Logger.Log($"Chunk: {Name} ({_uid})", true, ConsoleColor.DarkCyan);
Logger.Log($" ID: {id} - 0x{id.ToString("X")}", true, ConsoleColor.DarkCyan); Logger.Log($" ID: {Id} - 0x{Id.ToString("X")}", true, ConsoleColor.DarkCyan);
Logger.Log($" Decompressed Size: {decompressed_size} B", true, ConsoleColor.DarkCyan); Logger.Log($" Decompressed Size: {DecompressedSize} B", true, ConsoleColor.DarkCyan);
Logger.Log($" Flags: {flag}", true, ConsoleColor.DarkCyan); Logger.Log($" Flags: {Flag}", true, ConsoleColor.DarkCyan);
Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan); Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan);
} }
@ -152,16 +152,16 @@ namespace NetMFAPatcher.MMFParser.Data
string copyright = ""; string copyright = "";
string project = ""; string project = "";
var titleChunk = chunk_list.get_chunk<AppName>(); var titleChunk = _chunkList.get_chunk<AppName>();
if (titleChunk != null) title = titleChunk.value; if (titleChunk != null) title = titleChunk.Value;
var copyrightChunk = chunk_list.get_chunk<Copyright>(); var copyrightChunk = _chunkList.get_chunk<Copyright>();
if (copyrightChunk != null) copyright = copyrightChunk.value; if (copyrightChunk != null) copyright = copyrightChunk.Value;
var projectChunk = chunk_list.get_chunk<EditorFilename>(); var projectChunk = _chunkList.get_chunk<EditorFilename>();
if (projectChunk != null) project = projectChunk.value; if (projectChunk != null) project = projectChunk.Value;
if (EXE.LatestInst.game_data.product_build >= 284) if (Exe.LatestInst.GameData.ProductBuild >= 284)
{ {
Decryption.MakeKey(title, copyright, project); Decryption.MakeKey(title, copyright, project);
} }
@ -188,7 +188,7 @@ namespace NetMFAPatcher.MMFParser.Data
public ChunkLoader LoadChunk(Chunk chunk) public ChunkLoader LoadChunk(Chunk chunk)
{ {
ChunkLoader loader = null; ChunkLoader loader = null;
switch (chunk.id) switch (chunk.Id)
{ {
case 8739: case 8739:
loader = new AppHeader(chunk); loader = new AppHeader(chunk);
@ -277,13 +277,13 @@ namespace NetMFAPatcher.MMFParser.Data
public T get_chunk<T>() where T : ChunkLoader public T get_chunk<T>() where T : ChunkLoader
{ {
foreach (Chunk chunk in chunks) foreach (Chunk chunk in Chunks)
{ {
if (chunk.loader != null) if (chunk.Loader != null)
{ {
if (chunk.loader.GetType().Name == typeof(T).Name) if (chunk.Loader.GetType().Name == typeof(T).Name)
{ {
return (T) chunk.loader; return (T) chunk.Loader;
} }
} }
} }

@ -10,18 +10,18 @@ namespace mmfparser
{ {
public abstract class DataLoader public abstract class DataLoader
{ {
private Chunk chunk; private Chunk _chunk;
public ByteIO reader; public ByteIO Reader;
public bool verbose = true; public bool Verbose = true;
protected DataLoader(ByteIO reader) protected DataLoader(ByteIO reader)
{ {
this.reader = reader; this.Reader = reader;
} }
protected DataLoader(Chunk chunk) protected DataLoader(Chunk chunk)
{ {
this.chunk = chunk; this._chunk = chunk;
this.reader = chunk.get_reader(); this.Reader = chunk.get_reader();
} }
public abstract void Read(); public abstract void Read();

@ -8,19 +8,19 @@ using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.Data namespace NetMFAPatcher.MMFParser.Data
{ {
class EXE class Exe
{ {
public PackData pack_data; public PackData PackData;
public GameData game_data; public GameData GameData;
public static EXE LatestInst; public static Exe LatestInst;
public void ParseExe(ByteIO exeReader) public void ParseExe(ByteIO exeReader)
{ {
LatestInst = this; LatestInst = this;
Logger.Log($"Executable: {Program.GameName}\n", true, ConsoleColor.DarkRed); Logger.Log($"Executable: {Program.GameName}\n", true, ConsoleColor.DarkRed);
string Header1 = exeReader.ReadAscii(2); string header1 = exeReader.ReadAscii(2);
Logger.Log("EXE Header: " + Header1, true, ConsoleColor.Yellow); Logger.Log("EXE Header: " + header1, true, ConsoleColor.Yellow);
if (Header1 != "MZ") if (header1 != "MZ")
{ {
Console.WriteLine("Invalid executable signature"); Console.WriteLine("Invalid executable signature");
Console.ReadKey(); Console.ReadKey();
@ -29,35 +29,35 @@ namespace NetMFAPatcher.MMFParser.Data
exeReader.Seek(60, SeekOrigin.Begin); exeReader.Seek(60, SeekOrigin.Begin);
UInt16 hdr_offset = exeReader.ReadUInt16(); UInt16 hdrOffset = exeReader.ReadUInt16();
exeReader.Seek(hdr_offset, SeekOrigin.Begin); exeReader.Seek(hdrOffset, SeekOrigin.Begin);
string peHdr = exeReader.ReadAscii(2); string peHdr = exeReader.ReadAscii(2);
Logger.Log("PE Header: " + peHdr, true, ConsoleColor.Yellow); Logger.Log("PE Header: " + peHdr, true, ConsoleColor.Yellow);
exeReader.Skip(4); exeReader.Skip(4);
UInt16 num_of_sections = exeReader.ReadUInt16(); UInt16 numOfSections = exeReader.ReadUInt16();
exeReader.Skip(16); exeReader.Skip(16);
int optional_header = 28 + 68; int optionalHeader = 28 + 68;
int data_dir = 16 * 8; int dataDir = 16 * 8;
exeReader.Skip(optional_header + data_dir); exeReader.Skip(optionalHeader + dataDir);
int possition = 0; int possition = 0;
for (int i = 0; i < num_of_sections; i++) for (int i = 0; i < numOfSections; i++)
{ {
var entry = exeReader.Tell(); var entry = exeReader.Tell();
var section_name = exeReader.ReadAscii(); var sectionName = exeReader.ReadAscii();
if (section_name == ".extra") if (sectionName == ".extra")
{ {
exeReader.Seek(entry + 20); exeReader.Seek(entry + 20);
possition = (int)exeReader.ReadUInt32(); possition = (int)exeReader.ReadUInt32();
break; break;
} }
if (i >= num_of_sections - 1) if (i >= numOfSections - 1)
{ {
exeReader.Seek(entry + 16); exeReader.Seek(entry + 16);
uint size = exeReader.ReadUInt32(); uint size = exeReader.ReadUInt32();
@ -70,16 +70,16 @@ namespace NetMFAPatcher.MMFParser.Data
} }
exeReader.Seek((int)possition); exeReader.Seek((int)possition);
UInt16 first_short = exeReader.PeekUInt16(); UInt16 firstShort = exeReader.PeekUInt16();
Logger.Log("First Short: " + first_short.ToString("X2"), true, ConsoleColor.Yellow); Logger.Log("First Short: " + firstShort.ToString("X2"), true, ConsoleColor.Yellow);
if (first_short == 0x7777) if (firstShort == 0x7777)
{ {
Logger.Log("Found PackData header!\nReading PackData header.", true, ConsoleColor.Blue); Logger.Log("Found PackData header!\nReading PackData header.", true, ConsoleColor.Blue);
pack_data = new PackData(); PackData = new PackData();
pack_data.Read(exeReader); PackData.Read(exeReader);
game_data = new GameData(); GameData = new GameData();
game_data.Read(exeReader); GameData.Read(exeReader);
Console.ForegroundColor = ConsoleColor.DarkGreen; Console.ForegroundColor = ConsoleColor.DarkGreen;
} }
else else

@ -1,30 +1,30 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using static NetMFAPatcher.mmfparser.Constants; using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.Data namespace NetMFAPatcher.MMFParser.Data
{ {
public class GameData public class GameData
{ {
public int runtime_version; public int RuntimeVersion;
public int runtime_subversion; public int RuntimeSubversion;
public int product_build; public int ProductBuild;
public int product_version; public int ProductVersion;
public Products build; public Products Build;
public ChunkList gameChunks; public ChunkList GameChunks;
public string Name; public string Name;
public string Author; public string Author;
public string Copyright; public string Copyright;
public string aboutText; public string AboutText;
public string Doc; public string Doc;
public string EditorFilename; public string EditorFilename;
@ -45,7 +45,7 @@ namespace NetMFAPatcher.MMFParser.Data
public GlobalValues GValues; public GlobalValues GValues;
public GlobalStrings GStrings; public GlobalStrings GStrings;
public static FrameItems testItems; public static FrameItems TestItems;
//public Extensions Ext; //public Extensions Ext;
@ -59,72 +59,72 @@ namespace NetMFAPatcher.MMFParser.Data
string magic = exeReader.ReadAscii(4); //Reading header string magic = exeReader.ReadAscii(4); //Reading header
//Checking for header //Checking for header
if (magic == Constants.UNICODE_GAME_HEADER) Constants.isUnicode = true;//PAMU if (magic == Constants.UnicodeGameHeader) Constants.IsUnicode = true;//PAMU
else if (magic == Constants.GAME_HEADER) Constants.isUnicode = false;//PAME else if (magic == Constants.GameHeader) Constants.IsUnicode = false;//PAME
else Logger.Log("Couldn't found any known headers", true, ConsoleColor.Red);//Header not found else Logger.Log("Couldn't found any known headers", true, ConsoleColor.Red);//Header not found
runtime_version = exeReader.ReadUInt16(); // RuntimeVersion = exeReader.ReadUInt16(); //
runtime_subversion = exeReader.ReadUInt16(); //0 RuntimeSubversion = exeReader.ReadUInt16(); //0
product_version = exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC ProductVersion = exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC
product_build = exeReader.ReadInt32(); //CTF Build ProductBuild = exeReader.ReadInt32(); //CTF Build
build = (Products)runtime_version; Build = (Products)RuntimeVersion;
gameChunks = new ChunkList(); //Reading game chunks GameChunks = new ChunkList(); //Reading game chunks
gameChunks.Read(exeReader); GameChunks.Read(exeReader);
//Load chunks into gamedata for easier access //Load chunks into gamedata for easier access
if (gameChunks.get_chunk<AppName>() != null) Name = gameChunks.get_chunk<AppName>().value; if (GameChunks.get_chunk<AppName>() != null) Name = GameChunks.get_chunk<AppName>().Value;
if (gameChunks.get_chunk<Copyright>() != null) Copyright = gameChunks.get_chunk<Copyright>().value; if (GameChunks.get_chunk<Copyright>() != null) Copyright = GameChunks.get_chunk<Copyright>().Value;
if (gameChunks.get_chunk<AppAuthor>()!=null) Author = gameChunks.get_chunk<AppAuthor>().value; if (GameChunks.get_chunk<AppAuthor>()!=null) Author = GameChunks.get_chunk<AppAuthor>().Value;
if (gameChunks.get_chunk<EditorFilename>() != null) EditorFilename = gameChunks.get_chunk<EditorFilename>().value; if (GameChunks.get_chunk<EditorFilename>() != null) EditorFilename = GameChunks.get_chunk<EditorFilename>().Value;
if (gameChunks.get_chunk<TargetFilename>() != null) TargetFilename = gameChunks.get_chunk<TargetFilename>().value; if (GameChunks.get_chunk<TargetFilename>() != null) TargetFilename = GameChunks.get_chunk<TargetFilename>().Value;
if (gameChunks.get_chunk<AppMenu>() != null) Menu = gameChunks.get_chunk<AppMenu>(); if (GameChunks.get_chunk<AppMenu>() != null) Menu = GameChunks.get_chunk<AppMenu>();
if (gameChunks.get_chunk<AppHeader>() != null) Header = gameChunks.get_chunk<AppHeader>(); if (GameChunks.get_chunk<AppHeader>() != null) Header = GameChunks.get_chunk<AppHeader>();
if (gameChunks.get_chunk<SoundBank>() != null) Sounds = gameChunks.get_chunk<SoundBank>(); if (GameChunks.get_chunk<SoundBank>() != null) Sounds = GameChunks.get_chunk<SoundBank>();
if (gameChunks.get_chunk<MusicBank>() != null) Music = gameChunks.get_chunk<MusicBank>(); if (GameChunks.get_chunk<MusicBank>() != null) Music = GameChunks.get_chunk<MusicBank>();
if (gameChunks.get_chunk<FontBank>() != null) Fonts = gameChunks.get_chunk<FontBank>(); if (GameChunks.get_chunk<FontBank>() != null) Fonts = GameChunks.get_chunk<FontBank>();
if (gameChunks.get_chunk<ImageBank>() != null) Images = gameChunks.get_chunk<ImageBank>(); if (GameChunks.get_chunk<ImageBank>() != null) Images = GameChunks.get_chunk<ImageBank>();
if (gameChunks.get_chunk<AppIcon>() != null) Icon = gameChunks.get_chunk<AppIcon>(); if (GameChunks.get_chunk<AppIcon>() != null) Icon = GameChunks.get_chunk<AppIcon>();
if (gameChunks.get_chunk<GlobalStrings>() != null) GStrings = gameChunks.get_chunk<GlobalStrings>(); if (GameChunks.get_chunk<GlobalStrings>() != null) GStrings = GameChunks.get_chunk<GlobalStrings>();
if (gameChunks.get_chunk<GlobalValues>() != null) GValues = gameChunks.get_chunk<GlobalValues>(); if (GameChunks.get_chunk<GlobalValues>() != null) GValues = GameChunks.get_chunk<GlobalValues>();
if (gameChunks.get_chunk<FrameItems>() != null) Frameitems = gameChunks.get_chunk<FrameItems>(); if (GameChunks.get_chunk<FrameItems>() != null) Frameitems = GameChunks.get_chunk<FrameItems>();
Frames = gameChunks.Frames; //Its a list, so i have to manually parse them in chunk list. Frames = GameChunks.Frames; //Its a list, so i have to manually parse them in chunk list.
Print(); Print();
} }
public void Print() public void Print()
{ {
Logger.Log($"GameData Info:", true, ConsoleColor.DarkGreen); Logger.Log($"GameData Info:", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Version: {runtime_version}", true, ConsoleColor.DarkGreen); Logger.Log($" Runtime Version: {RuntimeVersion}", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Subversion: { runtime_subversion}", true, ConsoleColor.DarkGreen); Logger.Log($" Runtime Subversion: { RuntimeSubversion}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Version: { ((Products)product_version).ToString()}", true, ConsoleColor.DarkGreen); Logger.Log($" Product Version: { ((Products)ProductVersion).ToString()}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Build: {product_build}", true, ConsoleColor.DarkGreen); Logger.Log($" Product Build: {ProductBuild}", true, ConsoleColor.DarkGreen);
Logger.Log($" {(isUnicode ? "Unicode" : "NonUnicode")} Game", true, ConsoleColor.DarkGreen); Logger.Log($" {(IsUnicode ? "Unicode" : "NonUnicode")} Game", true, ConsoleColor.DarkGreen);
Logger.Log($"Game Info:", true, ConsoleColor.Cyan); Logger.Log($"Game Info:", true, ConsoleColor.Cyan);
Logger.Log($" Name:{Name}", true, ConsoleColor.Cyan); Logger.Log($" Name:{Name}", true, ConsoleColor.Cyan);
Logger.Log($" Author:{Author}", true, ConsoleColor.Cyan); Logger.Log($" Author:{Author}", true, ConsoleColor.Cyan);
Logger.Log($" Copyright:{Copyright}", true, ConsoleColor.Cyan); Logger.Log($" Copyright:{Copyright}", true, ConsoleColor.Cyan);
Logger.Log($" Editor Filename:{EditorFilename}", true, ConsoleColor.Cyan); Logger.Log($" Editor Filename:{EditorFilename}", true, ConsoleColor.Cyan);
Logger.Log($" Target Filename:{TargetFilename}", true, ConsoleColor.Cyan); Logger.Log($" Target Filename:{TargetFilename}", true, ConsoleColor.Cyan);
Logger.Log($" Screen Resolution: {Header.windowWidth}x{Header.windowHeight}", true, ConsoleColor.Cyan); Logger.Log($" Screen Resolution: {Header.WindowWidth}x{Header.WindowHeight}", true, ConsoleColor.Cyan);
Logger.Log($" Frame Count:{Header.numberOfFrames}", true, ConsoleColor.Cyan); Logger.Log($" Frame Count:{Header.NumberOfFrames}", true, ConsoleColor.Cyan);
if (GStrings != null && GStrings.items.Count > 0) if (GStrings != null && GStrings.Items.Count > 0)
{ {
Logger.Log($" Global Strings:", true, ConsoleColor.Cyan); Logger.Log($" Global Strings:", true, ConsoleColor.Cyan);
foreach (var item in GStrings.items) foreach (var item in GStrings.Items)
{ {
Logger.Log($" {item}"); Logger.Log($" {item}");
} }
} }
if (GValues != null && GValues.items.Count > 0) if (GValues != null && GValues.Items.Count > 0)
{ {
Logger.Log($" Global Values:", true, ConsoleColor.Cyan); Logger.Log($" Global Values:", true, ConsoleColor.Cyan);
foreach (var item in GValues.items) foreach (var item in GValues.Items)
{ {
Logger.Log($" {item.ToString()}"); Logger.Log($" {item.ToString()}");
} }
@ -134,7 +134,7 @@ namespace NetMFAPatcher.MMFParser.Data
Logger.Log("Frames: ", true, ConsoleColor.Cyan); Logger.Log("Frames: ", true, ConsoleColor.Cyan);
foreach (var item in Frames) foreach (var item in Frames)
{ {
Logger.Log($" Frame: {item.name}, Size: {item.width}x{item.height}, Number of objects: {item.CountOfObjs}", true, ConsoleColor.Cyan); Logger.Log($" Frame: {item.Name}, Size: {item.Width}x{item.Height}, Number of objects: {item.CountOfObjs}", true, ConsoleColor.Cyan);
} }

@ -1,53 +1,53 @@
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using mmfparser.mfaloaders;
using NetMFAPatcher.chunkloaders;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.mmfparser.chunkloaders;
using System.IO; using System.IO;
using Frame = NetMFAPatcher.mmfparser.mfaloaders.Frame; using Frame = NetMFAPatcher.mmfparser.mfaloaders.Frame;
using mmfparser; using mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.MFALoaders;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mfa namespace NetMFAPatcher.mfa
{ {
class MFA : DataLoader class Mfa : DataLoader
{ {
public static readonly string FontBankID = "ATNF"; public static readonly string FontBankId = "ATNF";
public static readonly string ImageBankID = "AGMI"; public static readonly string ImageBankId = "AGMI";
public static readonly string MusicBankID = "ASUM"; public static readonly string MusicBankId = "ASUM";
public static readonly string SoundBankID = "APMS"; public static readonly string SoundBankId = "APMS";
public int mfaBuild; public int MfaBuild;
public int product; public int Product;
public int buildVersion; public int BuildVersion;
public int langID; public int LangId;
public string name; public string Name;
public string description; public string Description;
public string path; public string Path;
public FontBank fonts; public FontBank Fonts;
public SoundBank sounds; public SoundBank Sounds;
public MusicBank music; public MusicBank Music;
public string author; public string Author;
public string copyright; public string Copyright;
public string company; public string Company;
public string version; public string Version;
public byte[] stamp; public byte[] Stamp;
public int windowX; public int WindowX;
public int windowY; public int WindowY;
public ValueList globalValues; public ValueList GlobalValues;
public ValueList globalStrings; public ValueList GlobalStrings;
public override void Print() public override void Print()
@ -61,21 +61,21 @@ namespace NetMFAPatcher.mfa
{ {
writer.WriteAscii("MFU2"); writer.WriteAscii("MFU2");
writer.WriteInt32(mfaBuild); writer.WriteInt32(MfaBuild);
writer.WriteInt32(product); writer.WriteInt32(Product);
writer.WriteInt32(buildVersion); writer.WriteInt32(BuildVersion);
writer.WriteInt32(langID); writer.WriteInt32(LangId);
writer.AutoWriteUnicode(name); writer.AutoWriteUnicode(Name);
writer.AutoWriteUnicode(description); writer.AutoWriteUnicode(Description);
writer.AutoWriteUnicode(path); writer.AutoWriteUnicode(Path);
writer.WriteUInt32((uint)stamp.Length); writer.WriteUInt32((uint)Stamp.Length);
writer.WriteBytes(stamp); writer.WriteBytes(Stamp);
writer.WriteAscii(FontBankID); writer.WriteAscii(FontBankId);
fonts.Write(writer); Fonts.Write(writer);
writer.WriteAscii(SoundBankID); writer.WriteAscii(SoundBankId);
sounds.Write(writer); Sounds.Write(writer);
writer.WriteAscii(MusicBankID); writer.WriteAscii(MusicBankId);
//music.Write();//cum cum cum cum cum cum cum cum //music.Write();//cum cum cum cum cum cum cum cum
writer.WriteInt32(0);//someone is using musics lol? writer.WriteInt32(0);//someone is using musics lol?
@ -89,181 +89,181 @@ namespace NetMFAPatcher.mfa
public override void Read() public override void Read()
{ {
Logger.Log($"MFA HEADER:{reader.ReadAscii(4)}\n"); Logger.Log($"MFA HEADER:{Reader.ReadAscii(4)}\n");
mfaBuild = reader.ReadInt32(); MfaBuild = Reader.ReadInt32();
product = reader.ReadInt32(); Product = Reader.ReadInt32();
buildVersion = reader.ReadInt32(); BuildVersion = Reader.ReadInt32();
Console.WriteLine($"mfaBuild: {mfaBuild}, product: {product}, buildVersion: {buildVersion}"); Console.WriteLine($"mfaBuild: {MfaBuild}, product: {Product}, buildVersion: {BuildVersion}");
langID = reader.ReadInt32(); LangId = Reader.ReadInt32();
name = Helper.AutoReadUnicode(reader); Name = Helper.AutoReadUnicode(Reader);
description = Helper.AutoReadUnicode(reader); Description = Helper.AutoReadUnicode(Reader);
path = Helper.AutoReadUnicode(reader); Path = Helper.AutoReadUnicode(Reader);
Console.WriteLine($"\nMFAName: {name}\nDescription: {description}\nPath: {path}"); Console.WriteLine($"\nMFAName: {Name}\nDescription: {Description}\nPath: {Path}");
stamp = reader.ReadBytes(reader.ReadInt32()); Stamp = Reader.ReadBytes(Reader.ReadInt32());
if (reader.ReadAscii(4) != "ATNF") if (Reader.ReadAscii(4) != "ATNF")
{ {
throw new Exception("Invalid Font Bank"); throw new Exception("Invalid Font Bank");
} }
fonts = new FontBank(reader); Fonts = new FontBank(Reader);
fonts.Read(); Fonts.Read();
Console.WriteLine("FONTS: " + fonts.numberOfItems); Console.WriteLine("FONTS: " + Fonts.NumberOfItems);
if (reader.ReadAscii(4) != "APMS") if (Reader.ReadAscii(4) != "APMS")
{ {
throw new Exception("Invalid Sound Bank"); throw new Exception("Invalid Sound Bank");
} }
sounds = new SoundBank(reader); Sounds = new SoundBank(Reader);
sounds.isCompressed = false; Sounds.IsCompressed = false;
sounds.Read(); Sounds.Read();
if (reader.ReadAscii(4) != "ASUM") if (Reader.ReadAscii(4) != "ASUM")
{ {
throw new Exception("Invalid Music Bank"); throw new Exception("Invalid Music Bank");
} }
music = new MusicBank(reader); Music = new MusicBank(Reader);
music.Read(); Music.Read();
if (reader.ReadAscii(4) != "AGMI") if (Reader.ReadAscii(4) != "AGMI")
{ {
throw new Exception("Invalid Icon Bank"); throw new Exception("Invalid Icon Bank");
} }
var icons = new AGMIBank(reader); var icons = new AgmiBank(Reader);
icons.Read(); icons.Read();
if (reader.ReadAscii(4) != "AGMI") if (Reader.ReadAscii(4) != "AGMI")
{ {
throw new Exception("Invalid Image Bank"); throw new Exception("Invalid Image Bank");
} }
var images = new AGMIBank(reader); var images = new AgmiBank(Reader);
images.Read(); images.Read();
if (Helper.AutoReadUnicode(reader) != name) throw new Exception("Invalid name"); if (Helper.AutoReadUnicode(Reader) != Name) throw new Exception("Invalid name");
author = Helper.AutoReadUnicode(reader); Author = Helper.AutoReadUnicode(Reader);
var newDesc = Helper.AutoReadUnicode(reader); var newDesc = Helper.AutoReadUnicode(Reader);
if ( newDesc!= description) throw new Exception("Invalid description: "+newDesc); if ( newDesc!= Description) throw new Exception("Invalid description: "+newDesc);
copyright = Helper.AutoReadUnicode(reader); Copyright = Helper.AutoReadUnicode(Reader);
company = Helper.AutoReadUnicode(reader); Company = Helper.AutoReadUnicode(Reader);
Console.WriteLine("Company: "+company); Console.WriteLine("Company: "+Company);
version = Helper.AutoReadUnicode(reader); Version = Helper.AutoReadUnicode(Reader);
Console.WriteLine("Version: " + version); Console.WriteLine("Version: " + Version);
windowX = reader.ReadInt32(); WindowX = Reader.ReadInt32();
windowY = reader.ReadInt32(); WindowY = Reader.ReadInt32();
Console.WriteLine($"Window:{windowX}x{windowY}"); Console.WriteLine($"Window:{WindowX}x{WindowY}");
var borderColor = reader.ReadColor(); var borderColor = Reader.ReadColor();
var displayFlags = reader.ReadUInt32(); var displayFlags = Reader.ReadUInt32();
var graphicFlags = reader.ReadUInt32(); var graphicFlags = Reader.ReadUInt32();
var helpFile = Helper.AutoReadUnicode(reader); var helpFile = Helper.AutoReadUnicode(Reader);
Console.WriteLine(reader.Tell()); Console.WriteLine(Reader.Tell());
var vitalizePreview = reader.ReadInt32(); var vitalizePreview = Reader.ReadInt32();
var initialScore = reader.ReadInt32(); var initialScore = Reader.ReadInt32();
var initialLifes = reader.ReadInt32(); var initialLifes = Reader.ReadInt32();
var frameRate = reader.ReadInt32(); var frameRate = Reader.ReadInt32();
var buildType = reader.ReadInt32(); var buildType = Reader.ReadInt32();
var buildPath = Helper.AutoReadUnicode(reader); var buildPath = Helper.AutoReadUnicode(Reader);
reader.ReadInt32(); Reader.ReadInt32();
var commandLine = Helper.AutoReadUnicode(reader); var commandLine = Helper.AutoReadUnicode(Reader);
var aboutbox = Helper.AutoReadUnicode(reader); var aboutbox = Helper.AutoReadUnicode(Reader);
Console.WriteLine(aboutbox); Console.WriteLine(aboutbox);
reader.ReadInt32(); Reader.ReadInt32();
var binCount = reader.ReadInt32();//wtf i cant put it in loop fuck shit var binCount = Reader.ReadInt32();//wtf i cant put it in loop fuck shit
for (int i = 0; i < binCount; i++) for (int i = 0; i < binCount; i++)
{ {
reader.ReadBytes(reader.ReadInt32());//binaryfiles Reader.ReadBytes(Reader.ReadInt32());//binaryfiles
} }
var controls = new mmfparser.mfaloaders.Controls(reader); var controls = new mmfparser.mfaloaders.Controls(Reader);
controls.Read(); controls.Read();
var menuSize = reader.ReadUInt32(); var menuSize = Reader.ReadUInt32();
var currentPosition = reader.Tell(); var currentPosition = Reader.Tell();
var menu = new AppMenu(reader); var menu = new AppMenu(Reader);
menu.Read(); menu.Read();
reader.Seek(menuSize + currentPosition); Reader.Seek(menuSize + currentPosition);
var windowMenuIndex = reader.ReadInt32(); var windowMenuIndex = Reader.ReadInt32();
int[] menuImages = new int[65535];//govnokod suka int[] menuImages = new int[65535];//govnokod suka
var MICount = reader.ReadInt32(); var miCount = Reader.ReadInt32();
for (int i = 0; i < MICount; i++) for (int i = 0; i < miCount; i++)
{ {
var id = reader.ReadInt32(); var id = Reader.ReadInt32();
menuImages[id] = reader.ReadInt32(); menuImages[id] = Reader.ReadInt32();
} }
globalValues = new ValueList(reader); GlobalValues = new ValueList(Reader);
globalValues.Read(); GlobalValues.Read();
globalStrings = new ValueList(reader); GlobalStrings = new ValueList(Reader);
globalStrings.Read(); GlobalStrings.Read();
var globalEvents = reader.ReadBytes(reader.ReadInt32()); var globalEvents = Reader.ReadBytes(Reader.ReadInt32());
var graphicMode = reader.ReadInt32();; var graphicMode = Reader.ReadInt32();;
var icoCount = reader.ReadInt32(); var icoCount = Reader.ReadInt32();
for (int i = 0; i < icoCount; i++) for (int i = 0; i < icoCount; i++)
{ {
reader.ReadInt32(); Reader.ReadInt32();
} }
var qualCount = reader.ReadInt32(); var qualCount = Reader.ReadInt32();
for (int i = 0; i < qualCount; i++)//qualifiers for (int i = 0; i < qualCount; i++)//qualifiers
{ {
var nameQ = reader.ReadAscii(reader.ReadInt32()); var nameQ = Reader.ReadAscii(Reader.ReadInt32());
var handleQ = reader.ReadInt32(); var handleQ = Reader.ReadInt32();
} }
var extCount = reader.ReadInt32(); var extCount = Reader.ReadInt32();
for (int i = 0; i < extCount; i++)//extensions for (int i = 0; i < extCount; i++)//extensions
{ {
var handleE = reader.ReadInt32(); var handleE = Reader.ReadInt32();
var filenameE = Helper.AutoReadUnicode(reader); var filenameE = Helper.AutoReadUnicode(Reader);
var nameE = Helper.AutoReadUnicode(reader); var nameE = Helper.AutoReadUnicode(Reader);
var magicE = reader.ReadInt32(); var magicE = Reader.ReadInt32();
var subType = reader.ReadBytes(reader.ReadInt32()); var subType = Reader.ReadBytes(Reader.ReadInt32());
} }
List<int> frameOffsets = new List<int>(); List<int> frameOffsets = new List<int>();
var offCount = reader.ReadInt32(); var offCount = Reader.ReadInt32();
for (int i = 0; i < offCount; i++) for (int i = 0; i < offCount; i++)
{ {
frameOffsets.Add(reader.ReadInt32()); frameOffsets.Add(Reader.ReadInt32());
} }
var nextOffset = reader.ReadInt32(); var nextOffset = Reader.ReadInt32();
foreach (var item in frameOffsets) foreach (var item in frameOffsets)
{ {
reader.Seek(item); Reader.Seek(item);
var testframe = new Frame(reader); var testframe = new Frame(Reader);
testframe.Read(); testframe.Read();
} }
reader.Seek(nextOffset); Reader.Seek(nextOffset);
var chunks = new ChunkList(reader); var chunks = new ChunkList(Reader);
chunks.Read(); chunks.Read();
return; return;
@ -275,7 +275,7 @@ namespace NetMFAPatcher.mfa
} }
public MFA(ByteIO reader) : base(reader) public Mfa(ByteIO reader) : base(reader)
{ {
} }

@ -12,7 +12,7 @@ namespace NetMFAPatcher.MMFParser.Data
{ {
public class PackData public class PackData
{ {
public PackFile[] items; public PackFile[] Items;
public PackData() public PackData()
{ {
@ -23,14 +23,14 @@ namespace NetMFAPatcher.MMFParser.Data
byte[] header = exeReader.ReadBytes(8); byte[] header = exeReader.ReadBytes(8);
exeReader.Skip(8); exeReader.Skip(8);
uint header_size = exeReader.ReadUInt32(); uint headerSize = exeReader.ReadUInt32();
uint data_size = exeReader.ReadUInt32(); uint dataSize = exeReader.ReadUInt32();
exeReader.Seek((int)(start + data_size - 32)); exeReader.Seek((int)(start + dataSize - 32));
exeReader.Skip(4); exeReader.Skip(4);
exeReader.Seek(start + 16); exeReader.Seek(start + 16);
uint format_version = exeReader.ReadUInt32(); uint formatVersion = exeReader.ReadUInt32();
exeReader.Skip(8); exeReader.Skip(8);
uint count = exeReader.ReadUInt32(); uint count = exeReader.ReadUInt32();
@ -48,7 +48,7 @@ namespace NetMFAPatcher.MMFParser.Data
if (!exeReader.Check(value)) break; if (!exeReader.Check(value)) break;
} }
exeReader.BaseStream.Position -= 5;//wtf lol exeReader.BaseStream.Position -= 5;//wtf lol
header = exeReader.ReadFourCC(); header = exeReader.ReadFourCc();
exeReader.Seek(offset); exeReader.Seek(offset);
for (int i = 0; i < count; i++) new PackFile().Read(exeReader); for (int i = 0; i < count; i++) new PackFile().Read(exeReader);
@ -60,24 +60,24 @@ namespace NetMFAPatcher.MMFParser.Data
} }
public class PackFile public class PackFile
{ {
string PackFilename = "ERROR"; string _packFilename = "ERROR";
int bingo = 0; int _bingo = 0;
byte[] data; byte[] _data;
public void Read(ByteIO exeReader) public void Read(ByteIO exeReader)
{ {
UInt16 len = exeReader.ReadUInt16(); UInt16 len = exeReader.ReadUInt16();
PackFilename = exeReader.ReadWideString(len); _packFilename = exeReader.ReadWideString(len);
bingo = exeReader.ReadInt32(); _bingo = exeReader.ReadInt32();
data = exeReader.ReadBytes(exeReader.ReadInt32()); _data = exeReader.ReadBytes(exeReader.ReadInt32());
Dump(); Dump();
} }
public void Dump() public void Dump()
{ {
Logger.Log($"Dumping {PackFilename}", true, ConsoleColor.DarkBlue); Logger.Log($"Dumping {_packFilename}", true, ConsoleColor.DarkBlue);
string path = $"{Program.DumpPath}\\extensions\\" + PackFilename; string path = $"{Program.DumpPath}\\extensions\\" + _packFilename;
File.WriteAllBytes(path, data); File.WriteAllBytes(path, _data);
} }
} }

@ -1,6 +1,4 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.Utils;
using NetMFAPatcher.Utils;
using NetMFAPatcher.mmfparser;
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
@ -15,111 +13,109 @@ namespace NetMFAPatcher
{ {
class Program class Program
{ {
//public static string path = @"H:\fnaf-world.exe";//test //public static string path = @"H:\fnaf-world.exe";//test
//public static string path = @"D:\SteamLibrary\steamapps\common\Five Nights at Freddy's Sister Location\SisterLocation.exe"; //public static string path = @"D:\SteamLibrary\steamapps\common\Five Nights at Freddy's Sister Location\SisterLocation.exe";
public static string path = "";//TODO: Make Selectable public static string Path = ""; //TODO: Make Selectable
public static string GameName;// = Path.GetFileNameWithoutExtension(path); public static string GameName; // = Path.GetFileNameWithoutExtension(path);
public static string DumpPath;// = $"DUMP\\{GameName}"; public static string DumpPath; // = $"DUMP\\{GameName}";
public static bool doMFA=false; public static bool DoMfa = false;
public static bool DumpImages = false; public static bool DumpImages = false;
public static bool DumpSounds = false; public static bool DumpSounds = false;
public static bool verbose; public static bool Verbose;
public static bool LogAll=false; public static bool LogAll = false;
public static bool UseGUI = false; public static bool UseGui = false;
[STAThread] [STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
string Path=""; string path = "";
bool Verbose=false; bool verbose = false;
bool DumpImages=true; bool dumpImages = true;
bool DumpSounds=true; bool dumpSounds = true;
if(args.Length==0) if (args.Length == 0)
{ {
UseGUI = true; UseGui = true;
var form = new MainForm(); var form = new MainForm();
Application.Run(form); Application.Run(form);
} }
if (args.Length > 0) if (args.Length > 0)
{ {
Path = args[0]; path = args[0];
} }
if (args.Length > 1) if (args.Length > 1)
{ {
Boolean.TryParse(args[1],out Verbose); Boolean.TryParse(args[1], out verbose);
} }
if (args.Length > 2) if (args.Length > 2)
{ {
Boolean.TryParse(args[2],out DumpImages); Boolean.TryParse(args[2], out dumpImages);
} }
if(args.Length>3)
if (args.Length > 3)
{ {
Boolean.TryParse(args[3],out DumpSounds); Boolean.TryParse(args[3], out dumpSounds);
} }
if(args[0]=="-h"||args[0]=="-help")
if (args.Length > 0 && (args[0] == "-h" || args[0] == "-help"))
{ {
Logger.Log($"DotNetCTFDumper: 0.0.5",true,ConsoleColor.Green); Logger.Log($"DotNetCTFDumper: 0.0.5", true, ConsoleColor.Green);
Logger.Log($"Lauch Args:", true, ConsoleColor.Green); Logger.Log($"Lauch Args:", true, ConsoleColor.Green);
Logger.Log($" Filename - path to your exe or mfa", true, ConsoleColor.Green); Logger.Log($" Filename - path to your exe or mfa", true, ConsoleColor.Green);
Logger.Log($" Info - Dump debug info to console(default:true)", true, ConsoleColor.Green); Logger.Log($" Info - Dump debug info to console(default:true)", true, ConsoleColor.Green);
Logger.Log($" DumpImages - Dump images to 'DUMP\\[your game]\\ImageBank'(default:false)", true, ConsoleColor.Green); Logger.Log($" DumpImages - Dump images to 'DUMP\\[your game]\\ImageBank'(default:false)", true,
Logger.Log($" DumpSounds - Dump sounds to 'DUMP\\[your game]\\SoundBank'(default:true)\n", true, ConsoleColor.Green); ConsoleColor.Green);
Logger.Log($"Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true, ConsoleColor.Green); Logger.Log($" DumpSounds - Dump sounds to 'DUMP\\[your game]\\SoundBank'(default:true)\n", true,
ConsoleColor.Green);
Logger.Log($"Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true,
ConsoleColor.Green);
Console.ReadKey(); Console.ReadKey();
Environment.Exit(0); Environment.Exit(0);
} }
if(args.Length>0) ReadFile(Path, Verbose, DumpImages, DumpSounds); if (args.Length > 0) ReadFile(path, verbose, dumpImages, dumpSounds);
} }
public static void ReadFile(string path,bool verbose=false,bool dumpImages=false,bool dumpSounds=true)
public static void ReadFile(string path, bool verbose = false, bool dumpImages = false, bool dumpSounds = true)
{ {
GameName = Path.GetFileNameWithoutExtension(path); GameName = System.IO.Path.GetFileNameWithoutExtension(path);
DumpPath = $"DUMP\\{GameName}"; DumpPath = $"DUMP\\{GameName}";
PrepareFolders(); PrepareFolders();
DumpImages = dumpImages; DumpImages = dumpImages;
DumpSounds = dumpSounds; DumpSounds = dumpSounds;
Program.verbose = verbose; Program.Verbose = verbose;
if (File.Exists(path)) if (File.Exists(path))
{ {
if (path.EndsWith(".exe")) if (path.EndsWith(".exe"))
{ {
doMFA = false; DoMfa = false;
ByteIO exeReader = new ByteIO(path, FileMode.Open); ByteIO exeReader = new ByteIO(path, FileMode.Open);
EXE currentEXE = new EXE(); Exe currentExe = new Exe();
currentEXE.ParseExe(exeReader); currentExe.ParseExe(exeReader);
Logger.Log("Finished!", true, ConsoleColor.Yellow); Logger.Log("Finished!", true, ConsoleColor.Yellow);
if(!UseGUI) Console.ReadKey(); if (!UseGui) Console.ReadKey();
} }
else if (path.EndsWith(".mfa")) else if (path.EndsWith(".mfa"))
{ {
doMFA = true; DoMfa = true;
Logger.Log("MFA reading is currently unstable"); Logger.Log("MFA reading is currently unstable");
Logger.Log("Are you sure?"); Logger.Log("Are you sure?");
Console.ReadKey(); Console.ReadKey();
ByteIO mfaReader = new ByteIO(path, FileMode.Open); ByteIO mfaReader = new ByteIO(path, FileMode.Open);
var mfa = new MFA(mfaReader); var mfa = new Mfa(mfaReader);
mfa.Read(); mfa.Read();
Console.WriteLine("Writing"); Console.WriteLine("Writing");
var MFAWriter = new ByteWriter("out.mfa",FileMode.Create); var mfaWriter = new ByteWriter("out.mfa", FileMode.Create);
mfa.Write(MFAWriter); mfa.Write(mfaWriter);
Console.ReadKey(); Console.ReadKey();
} }
else else
@ -129,14 +125,10 @@ namespace NetMFAPatcher
} }
else else
{ {
Logger.Log($"File '{path}' does not exist",true,ConsoleColor.Red); Logger.Log($"File '{path}' does not exist", true, ConsoleColor.Red);
} }
} }
public static void PrepareFolders() public static void PrepareFolders()
{ {
Directory.CreateDirectory($"{DumpPath}\\CHUNKS\\OBJECTINFO"); Directory.CreateDirectory($"{DumpPath}\\CHUNKS\\OBJECTINFO");
@ -146,7 +138,5 @@ namespace NetMFAPatcher
Directory.CreateDirectory($"{DumpPath}\\SoundBank"); Directory.CreateDirectory($"{DumpPath}\\SoundBank");
Directory.CreateDirectory($"{DumpPath}\\extensions"); Directory.CreateDirectory($"{DumpPath}\\extensions");
} }
} }
} }

@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace NetMFAPatcher.utils
{
public class BitDict
{
private String[] Keys;
public UInt32 flag { get; set; }
public BitDict(String[] keys)
{
Keys = keys;
}
public bool this[String key]
{
get => GetFlag(key);
}
public bool GetFlag(String key)
{
Int32 pos = Array.IndexOf(Keys, key);
if (pos >= 0)
{
return (flag & ((UInt32) Math.Pow(2, pos))) != 0;
}
return false;
}
public static string ToDebugString<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
{
return "{" + string.Join(",", dictionary.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}";
}
public override string ToString()
{
Dictionary<String, bool> actualKeys = new Dictionary<string, bool>();
foreach (var key in Keys)
{
actualKeys[key] = this[key];
}
return ToDebugString(actualKeys);
}
}
}

@ -8,12 +8,11 @@ namespace NetMFAPatcher.utils
{ {
public static class ByteFlag public static class ByteFlag
{ {
public static bool getFlag(int flagbyte,int pos) public static bool GetFlag(UInt32 flagbyte, int pos)
{ {
var mask = Math.Pow(2, pos); UInt32 mask = (uint) (2 << pos);
var result = flagbyte & (int)mask; UInt32 result = flagbyte & mask;
return result == mask; return result == mask;
} }
} }
} }

@ -36,7 +36,7 @@ namespace NetMFAPatcher.Utils
{ {
BaseStream.Seek(count, SeekOrigin.Current); BaseStream.Seek(count, SeekOrigin.Current);
} }
public byte[] ReadFourCC() public byte[] ReadFourCc()
{ {
return Encoding.UTF8.GetBytes(ReadAscii(4)); return Encoding.UTF8.GetBytes(ReadAscii(4));
} }
@ -56,7 +56,7 @@ namespace NetMFAPatcher.Utils
return Size() - Tell() >= size; return Size() - Tell() >= size;
} }
public bool eof() public bool Eof()
{ {
return BaseStream.Position < BaseStream.Length; return BaseStream.Position < BaseStream.Length;
} }

@ -53,7 +53,7 @@ namespace NetMFAPatcher.Utils
return Size() - Tell() >= size; return Size() - Tell() >= size;
} }
public bool eof() public bool Eof()
{ {
return BaseStream.Position < BaseStream.Length; return BaseStream.Position < BaseStream.Length;
} }

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
namespace NetMFAPatcher.Utils namespace NetMFAPatcher.Utils
{ {
@ -6,37 +7,36 @@ namespace NetMFAPatcher.Utils
{ {
public static byte[] Decompress(ByteIO exeReader) public static byte[] Decompress(ByteIO exeReader)
{ {
Int32 decomp_size = exeReader.ReadInt32(); Int32 decompSize = exeReader.ReadInt32();
Int32 comp_size = exeReader.ReadInt32(); Int32 compSize = exeReader.ReadInt32();
return decompress_block(exeReader, comp_size, decomp_size); return decompress_block(exeReader, compSize, decompSize);
} }
public static ByteIO DecompressAsReader(ByteIO exeReader) public static ByteIO DecompressAsReader(ByteIO exeReader)
{ {
Int32 decomp_size = exeReader.ReadInt32(); Int32 decompSize = exeReader.ReadInt32();
Int32 comp_size = exeReader.ReadInt32(); Int32 compSize = exeReader.ReadInt32();
byte[] compressedData = exeReader.ReadBytes(comp_size); byte[] compressedData = exeReader.ReadBytes(compSize);
byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData); byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData);
Debug.Assert(actualData.Length == decompSize);
return new ByteIO(actualData); return new ByteIO(actualData);
} }
public static byte[] decompress_block(ByteIO reader,int size,int decomp_size)
public static byte[] decompress_block(ByteIO reader, int size, int decompSize)
{ {
byte[] compressedData = reader.ReadBytes(size); byte[] compressedData = reader.ReadBytes(size);
byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData); byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData);
return actualData; return actualData;
} }
public static ByteIO decompress_asReader(ByteIO image_data, int v, int decompressed_size) public static ByteIO decompress_asReader(ByteIO imageData, int v, int decompressedSize)
{ {
return new ByteIO(decompress_block(image_data, v, decompressed_size)); return new ByteIO(decompress_block(imageData, v, decompressedSize));
} }
internal static byte[] decompress_block(ByteIO data, uint compressed_size, uint decompressedSize) internal static byte[] decompress_block(ByteIO data, uint compressedSize, uint decompressedSize)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

@ -13,69 +13,69 @@ namespace NetMFAPatcher.utils
{ {
public static byte[] DecryptionKey; public static byte[] DecryptionKey;
public static byte MagicChar=54; public static byte MagicChar=54;
public static void MakeKey(string STitle, string SCopyright,string SProject) public static void MakeKey(string sTitle, string sCopyright,string sProject)
{ {
var RawKey = ""; var rawKey = "";
RawKey += STitle; rawKey += sTitle;
RawKey += SCopyright; rawKey += sCopyright;
RawKey += SProject; rawKey += sProject;
Logger.Log("Combined data "+RawKey,true,ConsoleColor.Yellow); Logger.Log("Combined data "+rawKey,true,ConsoleColor.Yellow);
var RawKeyPTR = Marshal.StringToHGlobalAnsi(RawKey); var rawKeyPtr = Marshal.StringToHGlobalAnsi(rawKey);
var ptr = Decryption.make_key_combined(RawKeyPTR, MagicChar); var ptr = Decryption.make_key_combined(rawKeyPtr, MagicChar);
byte[] Key = new byte[257]; byte[] key = new byte[257];
Marshal.Copy(ptr, Key, 0, 256); Marshal.Copy(ptr, key, 0, 256);
Marshal.FreeHGlobal(RawKeyPTR); Marshal.FreeHGlobal(rawKeyPtr);
DecryptionKey = Key; DecryptionKey = key;
Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}",true,ConsoleColor.Yellow); Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}",true,ConsoleColor.Yellow);
File.WriteAllBytes($"{Program.DumpPath}\\key.bin", DecryptionKey); File.WriteAllBytes($"{Program.DumpPath}\\key.bin", DecryptionKey);
} }
public static byte[] DecodeMode3(byte[] ChunkData, int ChunkSize,int ChunkID) public static byte[] DecodeMode3(byte[] chunkData, int chunkSize,int chunkId)
{ {
var reader = new ByteIO(ChunkData); var reader = new ByteIO(chunkData);
var DecompressedSize = reader.ReadUInt32(); var decompressedSize = reader.ReadUInt32();
var chunkData = reader.ReadBytes((int)reader.Size()); var rawData = reader.ReadBytes((int)reader.Size());
if (ChunkID % 2 != 0) if (chunkId % 2 != 0)
{ {
chunkData[0] ^= (byte)(((byte)ChunkID & 0xFF) ^ ((byte)ChunkID >> 0x8)); rawData[0] ^= (byte)(((byte)chunkId & 0xFF) ^ ((byte)chunkId >> 0x8));
} }
var rawData = DecodeChunk(chunkData, ChunkSize); rawData = DecodeChunk(rawData, chunkSize);
var data = new ByteIO(rawData); var data = new ByteIO(rawData);
var compressed_size = data.ReadUInt32(); var compressedSize = data.ReadUInt32();
return Decompressor.decompress_block(data, (int)compressed_size, (int)DecompressedSize); return Decompressor.decompress_block(data, (int)compressedSize, (int)decompressedSize);
} }
public static byte[] DecodeChunk(byte[] ChunkData, int ChunkSize) public static byte[] DecodeChunk(byte[] chunkData, int chunkSize)
{ {
IntPtr InputChunkPtr = Marshal.AllocHGlobal(ChunkData.Length); IntPtr inputChunkPtr = Marshal.AllocHGlobal(chunkData.Length);
Marshal.Copy(ChunkData, 0, InputChunkPtr, ChunkData.Length); Marshal.Copy(chunkData, 0, inputChunkPtr, chunkData.Length);
IntPtr KeyPtr = Marshal.AllocHGlobal(DecryptionKey.Length); IntPtr keyPtr = Marshal.AllocHGlobal(DecryptionKey.Length);
Marshal.Copy(DecryptionKey, 0, KeyPtr, DecryptionKey.Length); Marshal.Copy(DecryptionKey, 0, keyPtr, DecryptionKey.Length);
var OutputChunkPtr = decode_chunk(InputChunkPtr, ChunkSize, MagicChar, KeyPtr); var outputChunkPtr = decode_chunk(inputChunkPtr, chunkSize, MagicChar, keyPtr);
byte[] DecodedChunk = new byte[ChunkSize]; byte[] decodedChunk = new byte[chunkSize];
Marshal.Copy(OutputChunkPtr, DecodedChunk,0,ChunkSize); Marshal.Copy(outputChunkPtr, decodedChunk,0,chunkSize);
Marshal.FreeHGlobal(InputChunkPtr); Marshal.FreeHGlobal(inputChunkPtr);
Marshal.FreeHGlobal(KeyPtr); Marshal.FreeHGlobal(keyPtr);
return DecodedChunk; return decodedChunk;
} }
[DllImport("Decrypter-x64.dll", EntryPoint = "decode_chunk", CharSet = CharSet.Auto)] [DllImport("Decrypter-x64.dll", EntryPoint = "decode_chunk", CharSet = CharSet.Auto)]
public static extern IntPtr decode_chunk(IntPtr chunk_data, int chunk_size, byte magic_char,IntPtr wrapper_key); public static extern IntPtr decode_chunk(IntPtr chunkData, int chunkSize, byte magicChar,IntPtr wrapperKey);
[DllImport("Decrypter-x64.dll", EntryPoint = "make_key", CharSet = CharSet.Auto)] [DllImport("Decrypter-x64.dll", EntryPoint = "make_key", CharSet = CharSet.Auto)]
public static extern IntPtr make_key(IntPtr c_title, IntPtr c_copyright, IntPtr c_project, byte magic_char); public static extern IntPtr make_key(IntPtr cTitle, IntPtr cCopyright, IntPtr cProject, byte magicChar);
[DllImport("Decrypter-x64.dll", EntryPoint = "make_key_combined", CharSet = CharSet.Auto)] [DllImport("Decrypter-x64.dll", EntryPoint = "make_key_combined", CharSet = CharSet.Auto)]
public static extern IntPtr make_key_combined(IntPtr data, byte magic_char); public static extern IntPtr make_key_combined(IntPtr data, byte magicChar);
} }
} }

@ -1,16 +1,12 @@
using mmfparser; using System;
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher namespace NetMFAPatcher.utils
{ {
static class Helper static class Helper
{ {
@ -31,18 +27,18 @@ namespace NetMFAPatcher
public static string Log(this byte[] bytes, bool log = true, string format = "") public static string Log(this byte[] bytes, bool log = true, string format = "")
{ {
string Temp = String.Empty; string temp = String.Empty;
for (int i = 0; i < bytes.Length; i++) for (int i = 0; i < bytes.Length; i++)
{ {
var item = bytes[i]; var item = bytes[i];
if (i > 0) if (i > 0)
{ {
Temp += " " + item.ToString(format); temp += " " + item.ToString(format);
} }
else else
{ {
Temp += item.ToString(format); temp += item.ToString(format);
} }
} }
@ -50,9 +46,9 @@ namespace NetMFAPatcher
{ {
Console.WriteLine(Temp); Console.WriteLine(temp);
} }
return Temp; return temp;
} }
@ -110,7 +106,7 @@ namespace NetMFAPatcher
if (b < 128 && b > 32) charAcc += Convert.ToChar(b); if (b < 128 && b > 32) charAcc += Convert.ToChar(b);
else charAcc += '.'; else charAcc += '.';
} }
var b_len = block.Count(); var bLen = block.Count();
//var accLen= //var accLen=

@ -5,39 +5,118 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
namespace NetMFAPatcher.utils namespace NetMFAPatcher.utils
{ {
public static class ImageHelper public static class ImageHelper
{ {
public static Color ReadPoint(byte[] data,int position) public static (byte[], int) ReadPoint(byte[] data, int width, int height)
{ {
//byte b2 = binaryReader.ReadByte(); byte[] colorArray = new byte[width * height * 4];
//byte b3 = binaryReader.ReadByte(); int stride = width * 4;
//byte b4 = binaryReader.ReadByte(); int pad = GetPadding(width, 3);
byte b2 = data[position]; int position = 0;
byte b3 = data[position+1]; for (int y = 0; y < height; y++)
byte b4 = data[position+2]; {
return Color.FromArgb((int)b4, (int)b3, (int)b2); for (int x = 0; x < width; x++)
{
colorArray[(y * stride) + (x * 4) + 0] = data[position];
colorArray[(y * stride) + (x * 4) + 1] = data[position + 1];
colorArray[(y * stride) + (x * 4) + 2] = data[position + 2];
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 3;
}
position += pad * 3;
}
return (colorArray, position);
} }
public static Color ReadSixteen(byte[] data, int position)
public static (byte[], int) ReadSixteen(byte[] data, int width, int height)
{
byte[] colorArray = new byte[width * height * 4];
int stride = width * 4;
int pad = GetPadding(width, 3);
int position = 0;
for (int y = 0; y < height; y++)
{ {
var newShort = (data[position] | data[position + 1] << 8); for (int x = 0; x < width; x++)
byte r = (byte)((newShort & 31744) >> 10); {
byte g = (byte)((newShort & 992) >> 5); UInt16 newShort = (ushort) (data[position] | data[position + 1] << 8);
byte b = (byte)((newShort & 31)); byte r = (byte) ((newShort & 31744) >> 10);
return Color.FromArgb((int)b, (int)g, (int)r); byte g = (byte) ((newShort & 992) >> 5);
byte b = (byte) ((newShort & 31));
colorArray[(y * stride) + (x * 4) + 0] = (byte) (r << 3);
colorArray[(y * stride) + (x * 4) + 1] = (byte) (g << 2);
colorArray[(y * stride) + (x * 4) + 2] = (byte) (b << 3);
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 2;
} }
public static int getPadding(int width, int pad = 2)
position += pad * 2;
}
return (colorArray, position);
}
public static (byte[], int) ReadFifteen(byte[] data, int width, int height)
{ {
int num = pad - width * 3 % pad; byte[] colorArray = new byte[width * height * 4];
if (num == pad) int stride = width * 4;
int pad = GetPadding(width, 3);
int position = 0;
for (int y = 0; y < height; y++)
{ {
num = 0; for (int x = 0; x < width; x++)
{
UInt16 newShort = (ushort) (data[position] | data[position + 1] << 8);
byte r = (byte) ((newShort & 31744) >> 10);
byte g = (byte) ((newShort & 992) >> 5);
byte b = (byte) ((newShort & 31));
colorArray[(y * stride) + (x * 4) + 0] = (byte) (r << 3);
colorArray[(y * stride) + (x * 4) + 1] = (byte) (g << 3);
colorArray[(y * stride) + (x * 4) + 2] = (byte) (b << 3);
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 2;
}
position += pad * 2;
} }
return (int)Math.Ceiling((double)((float)num / 3f));
return (colorArray, position);
}
public static byte[,] ReadAlpha(byte[] data, int width, int height, int possition)
{
int pad = GetPadding(width, 1, 4);
byte[,] alpha = new byte[width, height];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
alpha[j, i] = data[possition];
possition += 1;
}
possition += pad;
}
return alpha;
}
public static int GetPadding(int width, int pointSize, int bytes = 2)
{
int pad = bytes - ((width * pointSize) % bytes);
if (pad == bytes)
{
return 0;
}
return (int) Math.Ceiling((double) ((float) pad / (float) pointSize));
} }
} }
} }

@ -9,17 +9,17 @@ namespace NetMFAPatcher.Utils
{ {
public static class Logger public static class Logger
{ {
static StreamWriter writer; static StreamWriter _writer;
public static void Log(string text, bool logToScreen = true,ConsoleColor color = ConsoleColor.White) public static void Log(string text, bool logToScreen = true,ConsoleColor color = ConsoleColor.White)
{ {
if (writer == null) if (_writer == null)
{ {
File.Delete("Dump.log"); File.Delete("Dump.log");
writer = new StreamWriter("Dump.log", true); _writer = new StreamWriter("Dump.log", true);
writer.AutoFlush = true; _writer.AutoFlush = true;
} }
writer.WriteLine(text); _writer.WriteLine(text);
if (logToScreen) if (logToScreen)
{ {

@ -8,15 +8,15 @@ namespace NetMFAPatcher.mmfparser
{ {
public static class Constants public static class Constants
{ {
public static readonly string GAME_HEADER = "PAME"; public static readonly string GameHeader = "PAME";
public static readonly string UNICODE_GAME_HEADER = "PAMU";//"50 41 4D 55"; public static readonly string UnicodeGameHeader = "PAMU";//"50 41 4D 55";
public static bool isUnicode; public static bool IsUnicode;
public enum Products public enum Products
{ {
MMF1=1, Mmf1=1,
MMF15=2, Mmf15=2,
MMF2=3, Mmf2=3,
CNC1=0 Cnc1=0
} }
public enum ValueType public enum ValueType
@ -44,9 +44,9 @@ namespace NetMFAPatcher.mmfparser
Score=5, Score=5,
Lives = 6, Lives = 6,
Counter=7, Counter=7,
RTF=8, Rtf=8,
SubApplication=9, SubApplication=9,
INI=33, Ini=33,
IniPp=32, IniPp=32,
File=34, File=34,
TextEntry=35 TextEntry=35
@ -66,7 +66,7 @@ namespace NetMFAPatcher.mmfparser
GlobalEvents=8746, GlobalEvents=8746,
FrameHandles=8747, FrameHandles=8747,
ExtData=8748, ExtData=8748,
Additional_Extension=8749, AdditionalExtension=8749,
AppEditorFilename=8750, AppEditorFilename=8750,
AppTargetFilename=8751, AppTargetFilename=8751,
AppDoc=8752, AppDoc=8752,
@ -83,7 +83,7 @@ namespace NetMFAPatcher.mmfparser
Copyright=8763, Copyright=8763,
GlobalValuesNames=8764, GlobalValuesNames=8764,
GlobalStringNames=8765, GlobalStringNames=8765,
MVTexts=8766, MvTexts=8766,
FrameItems2=8767, FrameItems2=8767,
ExeOnly=8768, ExeOnly=8768,
Protection=8770, Protection=8770,
@ -109,7 +109,7 @@ namespace NetMFAPatcher.mmfparser
RandomSeed=13124, RandomSeed=13124,
FrameLayerEffects=13125, FrameLayerEffects=13125,
BlurayFrameOptions=13126, BlurayFrameOptions=13126,
MVTimerBase=13127, MvTimerBase=13127,
MosaicImageTable=13128, MosaicImageTable=13128,
FrameEffects=13129, FrameEffects=13129,
FrameIphoneOptions=13130, FrameIphoneOptions=13130,

@ -5,48 +5,49 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.mmfparser.mfaloaders; using NetMFAPatcher.mmfparser.mfaloaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public class AppHeader : ChunkLoader public class AppHeader : ChunkLoader
{ {
public int size; public int Size;
public int windowWidth; public int WindowWidth;
public int windowHeight; public int WindowHeight;
public int initialScore; public int InitialScore;
public int initialLives; public int InitialLives;
public int numberOfFrames; public int NumberOfFrames;
public override void Read() public override void Read()
{ {
reader = new ByteIO(chunk.chunk_data); Reader = new ByteIO(Chunk.ChunkData);
size = reader.ReadInt32(); Size = Reader.ReadInt32();
var flags = reader.ReadInt16(); //raw,need convert var flags = Reader.ReadInt16(); //raw,need convert
var new_flags = reader.ReadInt16(); //read flags or no balls var newFlags = Reader.ReadInt16(); //read flags or no balls
var graphics_mode = reader.ReadInt16(); //i am serious var graphicsMode = Reader.ReadInt16(); //i am serious
var otherflags = reader.ReadInt16(); //last chance to get balls back var otherflags = Reader.ReadInt16(); //last chance to get balls back
windowWidth = reader.ReadInt16(); WindowWidth = Reader.ReadInt16();
windowHeight = reader.ReadInt16(); WindowHeight = Reader.ReadInt16();
initialScore = (int) (reader.ReadUInt32() ^ 0xffffffff); InitialScore = (int) (Reader.ReadUInt32() ^ 0xffffffff);
initialLives = (int) (reader.ReadUInt32() ^ 0xffffffff); InitialLives = (int) (Reader.ReadUInt32() ^ 0xffffffff);
var controls = new Controls(reader); var controls = new Controls(Reader);
controls.Read(); controls.Read();
// controls.Print(false); // controls.Print(false);
var borderColor = reader.ReadBytes(4); var borderColor = Reader.ReadBytes(4);
numberOfFrames = reader.ReadInt32(); NumberOfFrames = Reader.ReadInt32();
var frameRate = reader.ReadInt32(); var frameRate = Reader.ReadInt32();
var windowsMenuIndex = reader.ReadSByte(); var windowsMenuIndex = Reader.ReadSByte();
} }
public override void Print(bool ext) public override void Print(bool ext)
{ {
Logger.Log($"ScreenRes: {windowWidth}x{windowHeight}", true, ConsoleColor.DarkMagenta); Logger.Log($"ScreenRes: {WindowWidth}x{WindowHeight}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Score: {initialScore}, Lives: {initialLives}", true, ConsoleColor.DarkMagenta); Logger.Log($"Score: {InitialScore}, Lives: {InitialLives}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Frame count: {numberOfFrames}", true, ConsoleColor.DarkMagenta); Logger.Log($"Frame count: {NumberOfFrames}", true, ConsoleColor.DarkMagenta);
Logger.Log(""); Logger.Log("");
} }
@ -63,23 +64,22 @@ namespace NetMFAPatcher.chunkloaders
public class Controls:ChunkLoader public class Controls:ChunkLoader
{ {
public List<PlayerControl> items; public List<PlayerControl> Items;
ByteIO reader;
public Controls(ByteIO reader) : base(reader) public Controls(ByteIO reader) : base(reader)
{ {
this.reader = reader; this.Reader = reader;
} }
public override void Read() public override void Read()
{ {
items = new List<PlayerControl>(); Items = new List<PlayerControl>();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
var item = new PlayerControl(reader); var item = new PlayerControl(Reader);
items.Add(item); Items.Add(item);
item.Read(); item.Read();
} }
} }
@ -87,7 +87,7 @@ namespace NetMFAPatcher.chunkloaders
public override void Print(bool ext) public override void Print(bool ext)
{ {
Logger.Log("Controls: ",true,ConsoleColor.Yellow); Logger.Log("Controls: ",true,ConsoleColor.Yellow);
foreach (var item in items) foreach (var item in Items)
{ {
item.Print(); item.Print();
} }
@ -96,70 +96,70 @@ namespace NetMFAPatcher.chunkloaders
public class PlayerControl public class PlayerControl
{ {
int controlType = 0; int _controlType = 0;
ByteIO reader; ByteIO _reader;
Keys keys; Keys _keys;
public PlayerControl(ByteIO reader) public PlayerControl(ByteIO reader)
{ {
this.reader = reader; this._reader = reader;
} }
public void Read() public void Read()
{ {
keys = new Keys(reader); _keys = new Keys(_reader);
controlType = reader.ReadInt16(); _controlType = _reader.ReadInt16();
keys.Read(); _keys.Read();
} }
public void Print() public void Print()
{ {
Logger.Log(" PlayerControl:", true, ConsoleColor.Yellow); Logger.Log(" PlayerControl:", true, ConsoleColor.Yellow);
Logger.Log($" ControlType: {controlType}", true, ConsoleColor.Yellow); Logger.Log($" ControlType: {_controlType}", true, ConsoleColor.Yellow);
keys.Print(); _keys.Print();
} }
} }
public class Keys public class Keys
{ {
int up; int _up;
int down; int _down;
int left; int _left;
int right; int _right;
int button1; int _button1;
int button2; int _button2;
int button3; int _button3;
int button4; int _button4;
ByteIO reader; ByteIO _reader;
public Keys(ByteIO reader) public Keys(ByteIO reader)
{ {
this.reader = reader; this._reader = reader;
} }
public void Read() public void Read()
{ {
up = reader.ReadInt16(); _up = _reader.ReadInt16();
down = reader.ReadInt16(); _down = _reader.ReadInt16();
left = reader.ReadInt16(); _left = _reader.ReadInt16();
right = reader.ReadInt16(); _right = _reader.ReadInt16();
button1 = reader.ReadInt16(); _button1 = _reader.ReadInt16();
button2 = reader.ReadInt16(); _button2 = _reader.ReadInt16();
button3 = reader.ReadInt16(); _button3 = _reader.ReadInt16();
button4 = reader.ReadInt16(); _button4 = _reader.ReadInt16();
} }
public void Print() public void Print()
{ {
Logger.Log($" Up: {up}", true, ConsoleColor.Yellow); Logger.Log($" Up: {_up}", true, ConsoleColor.Yellow);
Logger.Log($" Down: {down}", true, ConsoleColor.Yellow); Logger.Log($" Down: {_down}", true, ConsoleColor.Yellow);
Logger.Log($" Left: {left}", true, ConsoleColor.Yellow); Logger.Log($" Left: {_left}", true, ConsoleColor.Yellow);
Logger.Log($" Right: {right}", true, ConsoleColor.Yellow); Logger.Log($" Right: {_right}", true, ConsoleColor.Yellow);
Logger.Log($" Button1: {button1}", true, ConsoleColor.Yellow); Logger.Log($" Button1: {_button1}", true, ConsoleColor.Yellow);
Logger.Log($" Button2: {button2}", true, ConsoleColor.Yellow); Logger.Log($" Button2: {_button2}", true, ConsoleColor.Yellow);
Logger.Log($" Button3: {button3}", true, ConsoleColor.Yellow); Logger.Log($" Button3: {_button3}", true, ConsoleColor.Yellow);
Logger.Log($" Button4: {button4}", true, ConsoleColor.Yellow); Logger.Log($" Button4: {_button4}", true, ConsoleColor.Yellow);
} }
} }
} }

@ -1,18 +1,18 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.utils;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public class AppMenu : ChunkLoader public class AppMenu : ChunkLoader
{ {
public List<AppMenuItem> items = new List<AppMenuItem>(); public List<AppMenuItem> Items = new List<AppMenuItem>();
public AppMenu(ByteIO reader) : base(reader) public AppMenu(ByteIO reader) : base(reader)
{ {
} }
@ -27,27 +27,27 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read() public override void Read()
{ {
var current_position = reader.Tell(); var currentPosition = Reader.Tell();
var header_size = reader.ReadUInt32(); var headerSize = Reader.ReadUInt32();
var menu_offset = reader.ReadInt32(); var menuOffset = Reader.ReadInt32();
var menu_size = reader.ReadInt32(); var menuSize = Reader.ReadInt32();
if (menu_size == 0) return; if (menuSize == 0) return;
var accel_offset = reader.ReadInt32(); var accelOffset = Reader.ReadInt32();
var accel_size = reader.ReadInt32(); var accelSize = Reader.ReadInt32();
reader.Seek(current_position + menu_offset); Reader.Seek(currentPosition + menuOffset);
reader.Skip(4); Reader.Skip(4);
Load(); Load();
reader.Seek(current_position + accel_offset); Reader.Seek(currentPosition + accelOffset);
for (int i = 0; i < accel_size/8; i++) for (int i = 0; i < accelSize/8; i++)
{ {
reader.ReadByte(); Reader.ReadByte();
reader.Skip(1); Reader.Skip(1);
reader.ReadInt16(); Reader.ReadInt16();
reader.ReadInt16(); Reader.ReadInt16();
reader.Skip(2); Reader.Skip(2);
} }
} }
@ -55,11 +55,11 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
while(true) while(true)
{ {
var new_item = new AppMenuItem(reader); var newItem = new AppMenuItem(Reader);
new_item.Read(); newItem.Read();
items.Add(new_item); Items.Add(newItem);
if (new_item.name.Contains("About")) break; if (newItem.Name.Contains("About")) break;
if (true)//ByteFlag.getFlag(new_item.flags,4)) if (true)//ByteFlag.getFlag(new_item.flags,4))
{ {
Load(); Load();
@ -79,10 +79,10 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
} }
public class AppMenuItem : ChunkLoader public class AppMenuItem : ChunkLoader
{ {
public string name = ""; public string Name = "";
public int flags = 0; public int Flags = 0;
public int id = 0; public int Id = 0;
public string mnemonic = ""; public string Mnemonic = "";
public AppMenuItem(ByteIO reader) : base(reader) public AppMenuItem(ByteIO reader) : base(reader)
{ {
} }
@ -97,24 +97,24 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read() public override void Read()
{ {
var flags = reader.ReadInt16(); uint flags = (uint) Reader.ReadInt16();
if (!ByteFlag.getFlag(flags,4)) if (!ByteFlag.GetFlag(flags,4))
{ {
id = reader.ReadInt16(); Id = Reader.ReadInt16();
} }
name = reader.ReadWideString(); Name = Reader.ReadWideString();
for (int i = 0; i < name.Length; i++) for (int i = 0; i < Name.Length; i++)
{ {
if(name[i]=='&') if(Name[i]=='&')
{ {
mnemonic = name[i + 1].ToString().ToUpper(); Mnemonic = Name[i + 1].ToString().ToUpper();
} }
name = name.Replace("&", ""); Name = Name.Replace("&", "");
} }
Console.WriteLine(name); Console.WriteLine(Name);
} }
public void Load() public void Load()
{ {

@ -1,28 +1,22 @@
using NetMFAPatcher.mfa; using NetMFAPatcher.Utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public abstract class ChunkLoader//:DataLoader public abstract class ChunkLoader//:DataLoader
{ {
public Chunk chunk; public Chunk Chunk;
public ByteIO reader; public ByteIO Reader;
public bool verbose = false; public bool Verbose = false;
protected ChunkLoader(ByteIO reader) protected ChunkLoader(ByteIO reader)
{ {
this.reader = reader; this.Reader = reader;
} }
protected ChunkLoader(Chunk chunk) protected ChunkLoader(Chunk chunk)
{ {
this.chunk = chunk; this.Chunk = chunk;
this.reader = chunk.get_reader(); this.Reader = chunk.get_reader();
} }

@ -7,8 +7,9 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
class FrameName : StringChunk class FrameName : StringChunk
{ {
@ -34,52 +35,51 @@ namespace NetMFAPatcher.chunkloaders
public class Frame : ChunkLoader public class Frame : ChunkLoader
{ {
ByteIO reader; public string Name;
public string name; public string Password;
public string password; public int Width;
public int width; public int Height;
public int height; public byte[] Background;
public byte[] background; public int Flags;
public int flags;
public int CountOfObjs; public int CountOfObjs;
int top; int _top;
int bottom; int _bottom;
int left; int _left;
int right; int _right;
public override void Print(bool ext) public override void Print(bool ext)
{ {
Logger.Log($"Frame: {name}", true, ConsoleColor.Green); Logger.Log($"Frame: {Name}", true, ConsoleColor.Green);
Logger.Log($" Password: {(password!=null ? password : "None")}", true, ConsoleColor.Green); Logger.Log($" Password: {(Password!=null ? Password : "None")}", true, ConsoleColor.Green);
Logger.Log($" Size: {width}x{height}", true, ConsoleColor.Green); Logger.Log($" Size: {Width}x{Height}", true, ConsoleColor.Green);
Logger.Log($" Objects: {CountOfObjs}", true, ConsoleColor.Green); Logger.Log($" Objects: {CountOfObjs}", true, ConsoleColor.Green);
Logger.Log($"-------------------------", true, ConsoleColor.Green); Logger.Log($"-------------------------", true, ConsoleColor.Green);
} }
public override void Read() public override void Read()
{ {
var FrameReader = new ByteIO(chunk.chunk_data); var frameReader = new ByteIO(Chunk.ChunkData);
var chunks = new ChunkList(); var chunks = new ChunkList();
chunks.verbose = false; chunks.Verbose = false;
chunks.Read(FrameReader); chunks.Read(frameReader);
var name = chunks.get_chunk<FrameName>(); var name = chunks.get_chunk<FrameName>();
if (name != null) //Just to be sure if (name != null) //Just to be sure
{ {
this.name = name.value; this.Name = name.Value;
} }
var password = chunks.get_chunk<FramePassword>(); var password = chunks.get_chunk<FramePassword>();
if (password != null) //Just to be sure if (password != null) //Just to be sure
{ {
this.password = password.value; this.Password = password.Value;
} }
var header = chunks.get_chunk<FrameHeader>(); var header = chunks.get_chunk<FrameHeader>();
width = header.width; Width = header.Width;
height = header.height; Height = header.Height;
background = header.background; Background = header.Background;
flags = header.flags; Flags = header.Flags;
var objects = chunks.get_chunk<ObjectInstances>(); var objects = chunks.get_chunk<ObjectInstances>();
if(objects!=null) if(objects!=null)
{ {
@ -91,7 +91,7 @@ namespace NetMFAPatcher.chunkloaders
foreach (var item in chunks.chunks) foreach (var item in chunks.Chunks)
{ {
//Directory.CreateDirectory($"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}"); //Directory.CreateDirectory($"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}");
//string path = $"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}\\{chunk.name}.chunk"; //string path = $"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}\\{chunk.name}.chunk";
@ -115,10 +115,10 @@ namespace NetMFAPatcher.chunkloaders
class FrameHeader : ChunkLoader class FrameHeader : ChunkLoader
{ {
public int width; public int Width;
public int height; public int Height;
public int flags; public int Flags;
public byte[] background; public byte[] Background;
public FrameHeader(ByteIO reader) : base(reader) public FrameHeader(ByteIO reader) : base(reader)
{ {
} }
@ -134,10 +134,10 @@ namespace NetMFAPatcher.chunkloaders
public override void Read() public override void Read()
{ {
width = reader.ReadInt32(); Width = Reader.ReadInt32();
height = reader.ReadInt32(); Height = Reader.ReadInt32();
background = reader.ReadBytes(4); Background = Reader.ReadBytes(4);
flags = (int)reader.ReadUInt32(); Flags = (int)Reader.ReadUInt32();
@ -147,7 +147,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
public int CountOfObjects=0; public int CountOfObjects=0;
public List<ObjectInstances> items = new List<ObjectInstances>(); public List<ObjectInstances> Items = new List<ObjectInstances>();
public ObjectInstances(ByteIO reader) : base(reader) public ObjectInstances(ByteIO reader) : base(reader)
{ {
@ -165,13 +165,13 @@ namespace NetMFAPatcher.chunkloaders
public override void Read() public override void Read()
{ {
CountOfObjects = (int)reader.ReadUInt32(); CountOfObjects = (int)Reader.ReadUInt32();
return; return;
for (int i = 0; i < CountOfObjects; i++) for (int i = 0; i < CountOfObjects; i++)
{ {
var item = new ObjectInstances(reader); var item = new ObjectInstances(Reader);
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }

@ -1,19 +1,19 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public class FrameItems : ChunkLoader public class FrameItems : ChunkLoader
{ {
public Dictionary<int, ObjectInfo> ItemDict = new Dictionary<int, ObjectInfo>(); public Dictionary<int, ObjectInfo> ItemDict = new Dictionary<int, ObjectInfo>();
public List<string> names = new List<string>(); public List<string> Names = new List<string>();
public FrameItems(Chunk chunk) : base(chunk) { } public FrameItems(Chunk chunk) : base(chunk) { }
public FrameItems(ByteIO reader) : base(reader) { } public FrameItems(ByteIO reader) : base(reader) { }
public override void Print(bool ext) public override void Print(bool ext)
@ -23,18 +23,18 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read() public override void Read()
{ {
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var item = new ObjectInfo(reader); var item = new ObjectInfo(Reader);
item.verbose = false; item.Verbose = false;
item.Read(); item.Read();
ItemDict.Add(item.handle, item); ItemDict.Add(item.Handle, item);
names.Add(item.name); Names.Add(item.Name);
//Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta); //Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta);
} }
GameData.testItems = this; GameData.TestItems = this;
} }
} }

@ -1,68 +1,69 @@
using NetMFAPatcher.chunkloaders; using System;
using NetMFAPatcher.MMFParser.Data; using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils; using NetMFAPatcher.utils;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System.Collections.Generic; using System.Collections.Generic;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public class ObjectInfo : ChunkLoader public class ObjectInfo : ChunkLoader
{ {
public List<Chunk> chunks = new List<Chunk>(); public List<Chunk> Chunks = new List<Chunk>();
public int properties = 0; public int Properties = 0;
public string name = "ERROR"; public string Name = "ERROR";
public int handle; public int Handle;
public int objectType; public int ObjectType;
public int flags; public UInt32 Flags;
public bool transparent; public bool Transparent;
public bool antialias; public bool Antialias;
public int inkEffect; public int InkEffect;
public int inkEffectValue; public int InkEffectValue;
public int shaderId; public int ShaderId;
public int items; public int Items;
public ObjectInfo(Chunk chunk) : base(chunk) { }
public ObjectInfo(ByteIO reader) : base(reader) { } public ObjectInfo(Chunk chunk) : base(chunk)
public override void Print(bool ext)
{ {
}
public ObjectInfo(ByteIO reader) : base(reader)
{
}
public override void Print(bool ext)
{
} }
public override void Read() public override void Read()
{ {
var infoChunks = new ChunkList(); var infoChunks = new ChunkList();
infoChunks.verbose = false; infoChunks.Verbose = false;
infoChunks.Read(reader); infoChunks.Read(Reader);
foreach (var chunk in infoChunks.chunks) foreach (var infoChunk in infoChunks.Chunks)
{ {
chunk.verbose = false; infoChunk.Verbose = false;
var loader = chunk.loader; var loader = infoChunk.Loader;
if(loader is ObjectName) if (loader is ObjectName)
{ {
var actualLoader = infoChunks.get_loader<ObjectName>(loader); var actualLoader = infoChunks.get_loader<ObjectName>(loader);
name = actualLoader.value; Name = actualLoader.Value;
} }
else if(loader is ObjectHeader) else if (loader is ObjectHeader)
{ {
var actualLoader = infoChunks.get_loader<ObjectHeader>(loader); var actualLoader = infoChunks.get_loader<ObjectHeader>(loader);
handle = actualLoader.handle; Handle = actualLoader.Handle;
objectType = actualLoader.objectType; ObjectType = actualLoader.ObjectType;
flags = actualLoader.flags; Flags = actualLoader.Flags;
var inkEffect = actualLoader.inkEffect; UInt32 inkEffect = actualLoader.InkEffect;
transparent = ByteFlag.getFlag(inkEffect, 28); Transparent = ByteFlag.GetFlag(inkEffect, 28);
antialias = ByteFlag.getFlag(inkEffect, 29); Antialias = ByteFlag.GetFlag(inkEffect, 29);
} }
} }
} }
} }
class ObjectName : StringChunk class ObjectName : StringChunk
{ {
public ObjectName(ByteIO reader) : base(reader) public ObjectName(ByteIO reader) : base(reader)
@ -73,13 +74,15 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
} }
} }
class ObjectHeader : ChunkLoader class ObjectHeader : ChunkLoader
{ {
public int handle; public Int16 Handle;
public int objectType; public Int16 ObjectType;
public int flags; public UInt32 Flags;
public int inkEffect; public UInt32 InkEffect;
public int inkEffectParameter; public UInt32 InkEffectParameter;
public ObjectHeader(ByteIO reader) : base(reader) public ObjectHeader(ByteIO reader) : base(reader)
{ {
} }
@ -90,18 +93,16 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Print(bool ext) public override void Print(bool ext)
{ {
} }
public override void Read() public override void Read()
{ {
handle = reader.ReadInt16(); Handle = Reader.ReadInt16();
objectType = reader.ReadInt16(); ObjectType = Reader.ReadInt16();
flags = reader.ReadUInt16(); Flags = Reader.ReadUInt16();
var reserved = reader.ReadInt16(); Int16 reserved = Reader.ReadInt16();
inkEffect = (int)reader.ReadUInt32(); InkEffect = Reader.ReadUInt32();
inkEffectParameter = (int)reader.ReadUInt32(); InkEffectParameter = Reader.ReadUInt32();
} }
} }
} }

@ -5,24 +5,25 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
class StringChunk : ChunkLoader class StringChunk : ChunkLoader
{ {
public string value; public string Value;
public override void Read() public override void Read()
{ {
reader = new ByteIO(chunk.chunk_data); Reader = new ByteIO(Chunk.ChunkData);
value = reader.ReadWideString(); Value = Reader.ReadWideString();
} }
public override void Print(bool ext) public override void Print(bool ext)
{ {
Logger.Log($"{chunk.name} contains: {value}\n",true,ConsoleColor.DarkCyan); Logger.Log($"{Chunk.Name} contains: {Value}\n",true,ConsoleColor.DarkCyan);
} }

@ -1,194 +0,0 @@
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class DebugImageBank : ChunkLoader
{
Dictionary<int, DebugImageItem> images = new Dictionary<int, DebugImageItem>();
public DebugImageBank(ByteIO reader) : base(reader)
{
}
public DebugImageBank(Chunk chunk) : base(chunk)
{
}
public override void Print(bool ext)
{
}
public override void Read()
{
reader = new ByteIO(chunk.chunk_data);
var number_of_items = reader.ReadUInt32();
Console.WriteLine($"Found {number_of_items} images");
for (int i = 0; i < number_of_items; i++)
{
var item = new DebugImageItem(reader);
item.Read();
item.handle -= 1;
//images[item.handle] = item;
}
}
}
class DebugImageItem : ChunkLoader
{
public int handle;
int position;
int checksum;
int references;
int width;
int height;
int graphic_mode;
int x_hotspot;
int y_hotspot;
int action_x;
int action_y;
public int flags;
public int size;
//tranparent,add later
int indexed;
byte[] image;
byte[] alpha;
ByteIO image_data;
public bool isCompressed = true;
public override void Read()
{
handle = reader.ReadInt32();
position = (int)reader.Tell();
if (!Program.DumpImages) return;
Save($"{Program.DumpPath}\\ImageBank\\{handle}.png");
}
public void Save(string filename)
{
Bitmap result;
var image_data = Decompressor.DecompressAsReader(reader);
using (ByteIO binaryReader = image_data)
{
int num = 0;
byte b = 0;
short num2;
short num3;
if (true)
{
binaryReader.ReadInt32();
binaryReader.ReadInt32();
num = (int)binaryReader.ReadUInt32();
num2 = binaryReader.ReadInt16();
num3 = binaryReader.ReadInt16();
graphic_mode = binaryReader.ReadByte();
b = (byte)binaryReader.ReadSByte();
binaryReader.BaseStream.Position += 2;
binaryReader.ReadInt16();
binaryReader.ReadInt16();
binaryReader.ReadInt16();
binaryReader.ReadInt16();
binaryReader.ReadByte();
binaryReader.ReadByte();
binaryReader.ReadByte();
binaryReader.ReadByte();
}
var colorSize = 3;
Bitmap bitmap = new Bitmap((int)num2, (int)num3);
Color[,] array = new Color[(int)num2, (int)num3];
int num4 = ImageHelper.getPadding((int)num2, 2);
int num5 = 0;
for (int i = 0; i < (int)num3; i++)
{
for (int j = 0; j < (int)num2; j++)
{
byte[] colorData=null;
if(graphic_mode==4)
{
colorSize = 3;
colorData = binaryReader.ReadBytes(colorSize);
array[j, i] = ImageHelper.ReadPoint(colorData, 0);
}
else
{
colorSize = 2;
colorData = binaryReader.ReadBytes(colorSize);
array[j, i] = ImageHelper.ReadSixteen(colorData, 0);
}
num5 += 3;
}
binaryReader.ReadBytes(num4 * 3);
num5 += num4 * 3;
}
int num6 = num - num5;
if (b == 16)
{
num4 = (num6 - (int)(num2 * num3)) / (int)num3;
for (int k = 0; k < (int)num3; k++)
{
for (int l = 0; l < (int)num2; l++)
{
byte b5 = binaryReader.ReadByte();
Color color = array[l, k];
array[l, k] = Color.FromArgb((int)b5, (int)color.R, (int)color.G, (int)color.B);
}
binaryReader.ReadBytes(num4);
}
}
for (int m = 0; m < (int)num3; m++)
{
for (int n = 0; n < (int)num2; n++)
{
bitmap.SetPixel(n, m, array[n, m]);
}
}
result = bitmap;
}
result.Save(filename);
}
public override void Print(bool ext)
{
}
public DebugImageItem(ByteIO reader) : base(reader)
{
}
public DebugImageItem(Chunk chunk) : base(chunk)
{
}
}
}

@ -1,30 +1,23 @@
 using NetMFAPatcher.Utils;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{ {
public class FontBank : ChunkLoader public class FontBank : ChunkLoader
{ {
public int numberOfItems; public int NumberOfItems;
public override void Print(bool ext) public override void Print(bool ext)
{ {
Logger.Log($"FontCount:{numberOfItems.ToString()}"); Logger.Log($"FontCount:{NumberOfItems.ToString()}");
} }
public override void Read() public override void Read()
{ {
numberOfItems = reader.ReadInt32(); NumberOfItems = Reader.ReadInt32();
} }
public void Write(ByteWriter writer) public void Write(ByteWriter writer)
{ {
writer.WriteInt32(numberOfItems); writer.WriteInt32(NumberOfItems);
//i am testing with no fonts suck pinus haha //i am testing with no fonts suck pinus haha
} }

@ -1,22 +1,22 @@
using NetMFAPatcher.mmfparser; using System;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Numerics; using System.Net;
using System.Text; using System.Runtime.InteropServices;
using System.Threading.Tasks; using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{ {
public class ImageBank : ChunkLoader public class ImageBank : ChunkLoader
{ {
Dictionary<int, ImageItem> images = new Dictionary<int, ImageItem>(); Dictionary<int, ImageItem> _images = new Dictionary<int, ImageItem>();
public ImageBank(ByteIO reader) : base(reader) public ImageBank(ByteIO reader) : base(reader)
{ {
} }
@ -24,212 +24,187 @@ namespace NetMFAPatcher.chunkloaders
public ImageBank(Chunk chunk) : base(chunk) public ImageBank(Chunk chunk) : base(chunk)
{ {
} }
public override void Print(bool ext) public override void Print(bool ext)
{ {
} }
public override void Read() public override void Read()
{ {
reader = new ByteIO(chunk.chunk_data); Reader = new ByteIO(Chunk.ChunkData);
var number_of_items = reader.ReadUInt32();
if (!Program.DumpImages) return;
Console.WriteLine($"Found {number_of_items} images");
for (int i = 0; i < number_of_items; i++)
{
var item = new ImageItem(reader);
//item.isCompressed = false;
var numberOfItems = Reader.ReadUInt32();
Console.WriteLine(@"Found {numberOfItems} images");
for (int i = 0; i < numberOfItems; i++)
{
var item = new ImageItem(Reader);
item.Read(); item.Read();
item.handle -= 1; if (Program.DumpImages)
item.Save($"{Program.DumpPath}\\ImageBank\\" + item.Handle.ToString() + ".png");
//images[item.handle] = item;
if (Exe.LatestInst.GameData.ProductBuild >= 284)
item.Handle -= 1;
//images[item.handle] = item;
} }
} }
} }
public class ImageItem : ChunkLoader public class ImageItem : ChunkLoader
{ {
public int Handle;
int Position;
int _checksum;
int _references;
int _width;
int _height;
int _graphicMode;
int _xHotspot;
int _yHotspot;
int _actionX;
int _actionY;
BitDict Flags = new BitDict(new string[]
{
"RLE",
"RLEW",
"RLET",
"LZX",
"Alpha",
"ACE",
"Mac"
});
public int Size;
public int handle;
int position;
int checksum;
int references;
int width;
int height;
int graphic_mode;
int x_hotspot;
int y_hotspot;
int action_x;
int action_y;
public int flags;
public int size;
//tranparent,add later //tranparent,add later
int indexed; byte[] _transparent;
byte[] image; byte[] _colorArray;
byte[] alpha; int _indexed;
ByteIO image_data;
public bool isCompressed = true; public bool IsCompressed = true;
public override void Read() public override void Read()
{ {
handle = reader.ReadInt32(); Handle = Reader.ReadInt32();
position = (int)reader.Tell(); Position = (int) Reader.Tell();
if (Program.DumpImages)
{
Load(); Load();
return;
}
else
{
if (isCompressed)
{
reader.Skip(8);
size = (int)reader.ReadUInt32();
reader.Skip(size + 20);
}
else
{
reader.Skip(4);
size = (int)reader.ReadUInt32();
reader.Seek(size + position);
}
} }
}
public void Load() public void Load()
{ {
Reader.Seek(Position);
ByteIO imageReader;
reader.Seek(position); if (IsCompressed)
if (isCompressed)
{ {
image_data = Decompressor.DecompressAsReader(reader); imageReader = Decompressor.DecompressAsReader(Reader);
} }
else else
{ {
image_data = reader; imageReader = Reader;
} }
var start = image_data.Tell(); long start = imageReader.Tell();
if (!isCompressed)
{
_checksum = imageReader.ReadInt32();
_references = imageReader.ReadInt32();
Size = (int) imageReader.ReadUInt32();
if (!IsCompressed)
{
imageReader = new ByteIO(imageReader.ReadBytes(Size + 20));
} }
checksum = image_data.ReadInt32();
_width = imageReader.ReadInt16();
_height = imageReader.ReadInt16();
_graphicMode = imageReader.ReadByte(); //Graphic mode is always 4 for SL
Flags.flag = imageReader.ReadByte();
references = image_data.ReadInt32(); imageReader.Skip(2);
size = (int)image_data.ReadUInt32(); _xHotspot = imageReader.ReadInt16();
if (!isCompressed) _yHotspot = imageReader.ReadInt16();
_actionX = imageReader.ReadInt16();
_actionY = imageReader.ReadInt16();
_transparent = imageReader.ReadBytes(4);
Logger.Log($"{Handle.ToString(),4} Size: {_width,4}x{_height,4}, flags: {Flags}");
byte[] imageData;
if (Flags["LZX"])
{ {
image_data = new ByteIO(image_data.ReadBytes(size + 20)); throw new NotImplementedException();
imageData = new byte[1];
} }
width = image_data.ReadInt16(); else
height = image_data.ReadInt16();
graphic_mode = image_data.ReadByte();//Graphic mode is always 4 for SL
flags = image_data.ReadByte();
image_data.Skip(2);
x_hotspot = image_data.ReadInt16();
y_hotspot = image_data.ReadInt16();
action_x = image_data.ReadInt16();
action_y = image_data.ReadInt16();
Logger.Log($"Size: {width}x{height}");
for (int i = 0; i < 4; i++)
{ {
image_data.ReadByte(); imageData = imageReader.ReadBytes((int) (imageReader.Size() - imageReader.Tell()));
} }
//Save($"{Program.DumpPath}\\ImageBank\\" + handle.ToString() + ".png"); int bytesRead = 0;
Save("cum.png"); if (Flags["RLE"] || Flags["RLEW"] || Flags["RLET"])
return;
}
public void Save(string filename)
{ {
Bitmap bitmap = new Bitmap((int)width, (int)height); }
Color[,] array = new Color[(int)width, (int)height]; else
int num4 = ImageHelper.getPadding((int)width, 2);
int num5 = 0;
using (ByteIO binaryReader = image_data)
{ {
int colorSize = 3; switch (_graphicMode)
for (int i = 0; i < (int)height; i++)
{ {
for (int j = 0; j < (int)width; j++) case 4:
{ {
byte[] colorData = null; (_colorArray, bytesRead) = ImageHelper.ReadPoint(imageData, _width, _height);
if (graphic_mode == 4) break;
}
case 6:
{ {
colorSize = 3; (_colorArray, bytesRead) = ImageHelper.ReadFifteen(imageData, _width, _height);
colorData = binaryReader.ReadBytes(colorSize); break;
array[j, i] = ImageHelper.ReadPoint(colorData, 0);
} }
else case 7:
{ {
colorSize = 2; (_colorArray, bytesRead) = ImageHelper.ReadSixteen(imageData, _width, _height);
colorData = binaryReader.ReadBytes(colorSize); break;
array[j, i] = ImageHelper.ReadSixteen(colorData, 0);
} }
num5 += 3;
} }
binaryReader.ReadBytes(num4 * 3);
num5 += num4 * 3;
} }
int num6 = size - num5;
if (flags == 16) int alphaSize = Size - bytesRead;
if (Flags["Alpha"])
{ {
num4 = (num6 - (int)(width * height)) / (int)height; byte[,] alpha = ImageHelper.ReadAlpha(imageData, _width, _height, Size - alphaSize);
for (int k = 0; k < (int)height; k++) int stride = _width * 4;
for (int y = 0; y < _height; y++)
{ {
for (int l = 0; l < (int)width; l++) for (int x = 0; x < _width; x++)
{ {
byte Calpha = binaryReader.ReadByte(); _colorArray[(y * stride) + (x * 4) + 3] = alpha[x, y];
Color color = array[l, k]; }
array[l, k] = Color.FromArgb(Calpha, color.R, color.G, color.B);
} }
binaryReader.ReadBytes(num4);
} }
return;
} }
for (int m = 0; m < (int)height; m++)
public void Save(string filename)
{ {
for (int n = 0; n < (int)width; n++) using (var bmp = new Bitmap(_width, _height, PixelFormat.Format32bppArgb))
{ {
bitmap.SetPixel(n, m, array[n, m]); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0,
} bmp.Width,
} bmp.Height),
ImageLockMode.WriteOnly,
bmp.PixelFormat);
IntPtr pNative = bmpData.Scan0;
Marshal.Copy(_colorArray, 0, pNative, _colorArray.Length);
bmp.UnlockBits(bmpData);
bmp.Save(filename);
} }
bitmap.Save(filename, ImageFormat.Png);
} }
public override void Print(bool ext) public override void Print(bool ext)
{ {
} }
public ImageItem(ByteIO reader) : base(reader) public ImageItem(ByteIO reader) : base(reader)
{ {
} }
@ -241,7 +216,8 @@ namespace NetMFAPatcher.chunkloaders
public class TestPoint public class TestPoint
{ {
public int size = 3; public int Size = 3;
public (byte r, byte g, byte b) Read(byte[] data, int position) public (byte r, byte g, byte b) Read(byte[] data, int position)
{ {
byte r = 0; byte r = 0;
@ -249,22 +225,16 @@ namespace NetMFAPatcher.chunkloaders
byte b = 0; byte b = 0;
try try
{ {
b = data[position]; b = data[position];
g = data[position + 1]; g = data[position + 1];
r = data[position + 2]; r = data[position + 2];
} }
catch catch
{ {
Console.WriteLine(position); Console.WriteLine(position);
} }
return (r, g, b); return (r, g, b);
} }
} }
} }

@ -1,20 +1,14 @@
using NetMFAPatcher.Utils; using System.Collections.Generic;
using System; using NetMFAPatcher.Utils;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{ {
public class MusicBank : ChunkLoader public class MusicBank : ChunkLoader
{ {
public int num_of_items = 0; public int NumOfItems = 0;
public int references = 0; public int References = 0;
public List<MusicFile> items; public List<MusicFile> Items;
public override void Print(bool ext) public override void Print(bool ext)
{ {
@ -23,13 +17,13 @@ namespace NetMFAPatcher.chunkloaders
public override void Read() public override void Read()
{ {
//Someone is using this lol? //Someone is using this lol?
items = new List<MusicFile>(); Items = new List<MusicFile>();
num_of_items = reader.ReadInt32(); NumOfItems = Reader.ReadInt32();
for (int i = 0; i < num_of_items; i++) for (int i = 0; i < NumOfItems; i++)
{ {
var item = new MusicFile(reader); var item = new MusicFile(Reader);
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }
} }
@ -44,9 +38,9 @@ namespace NetMFAPatcher.chunkloaders
public class MusicFile : ChunkLoader public class MusicFile : ChunkLoader
{ {
public int handle; public int Handle;
public string name = "ERROR"; public string Name = "ERROR";
public byte[] data; public byte[] Data;
public override void Print(bool ext) public override void Print(bool ext)
{ {

@ -1,21 +1,18 @@
using NetMFAPatcher.Utils; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using NetMFAPatcher.utils;
using System.Text; using NetMFAPatcher.Utils;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{ {
public class SoundBank : ChunkLoader public class SoundBank : ChunkLoader
{ {
public int num_of_items = 0; public int NumOfItems = 0;
public int references = 0; public int References = 0;
public List<SoundItem> items; public List<SoundItem> Items;
public bool isCompressed = true; public bool IsCompressed = true;
public override void Print(bool ext) public override void Print(bool ext)
{ {
@ -24,22 +21,22 @@ namespace NetMFAPatcher.chunkloaders
public override void Read() public override void Read()
{ {
//Implementing for standalone-only because of my lazyness //Implementing for standalone-only because of my lazyness
items = new List<SoundItem>(); Items = new List<SoundItem>();
num_of_items = reader.ReadInt32(); NumOfItems = Reader.ReadInt32();
for (int i = 0; i < num_of_items; i++) for (int i = 0; i < NumOfItems; i++)
{ {
var item = new SoundItem(reader); var item = new SoundItem(Reader);
item.isCompressed = isCompressed; item.IsCompressed = IsCompressed;
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }
} }
public void Write(ByteWriter writer) public void Write(ByteWriter writer)
{ {
writer.WriteInt32(num_of_items); writer.WriteInt32(NumOfItems);
foreach (var item in items) foreach (var item in Items)
{ {
item.Write(writer); item.Write(writer);
} }
@ -56,9 +53,9 @@ namespace NetMFAPatcher.chunkloaders
public class SoundBase : ChunkLoader public class SoundBase : ChunkLoader
{ {
public int handle; public int Handle;
public string name = "ERROR"; public string Name = "ERROR";
public byte[] data; public byte[] Data;
public override void Print(bool ext) public override void Print(bool ext)
{ {
@ -79,63 +76,63 @@ namespace NetMFAPatcher.chunkloaders
public class SoundItem : SoundBase public class SoundItem : SoundBase
{ {
public bool compressed; public bool Compressed;
public int checksum; public int Checksum;
public int references; public int References;
public int flags; public int Flags;
public bool isCompressed = true; public bool IsCompressed = true;
public override void Read() public override void Read()
{ {
var start = reader.Tell(); var start = Reader.Tell();
handle = (int) reader.ReadUInt32(); Handle = (int) Reader.ReadUInt32();
checksum = reader.ReadInt32(); Checksum = Reader.ReadInt32();
references = reader.ReadInt32(); References = Reader.ReadInt32();
var decompressed_size = reader.ReadInt32(); var decompressedSize = Reader.ReadInt32();
flags = (int)reader.ReadUInt32(); //flags Flags = (int)Reader.ReadUInt32(); //flags
var reserved = reader.ReadInt32(); var reserved = Reader.ReadInt32();
var name_lenght = reader.ReadInt32(); var nameLenght = Reader.ReadInt32();
ByteIO SoundData; ByteIO soundData;
if (isCompressed) //compressed if (IsCompressed) //compressed
{ {
var size = reader.ReadInt32(); var size = Reader.ReadInt32();
SoundData = new ByteIO(Decompressor.decompress_block(reader, size, decompressed_size)); soundData = new ByteIO(Decompressor.decompress_block(Reader, size, decompressedSize));
} }
else else
{ {
SoundData = new ByteIO(reader.ReadBytes(decompressed_size)); soundData = new ByteIO(Reader.ReadBytes(decompressedSize));
} }
if (isCompressed) if (IsCompressed)
{ {
name = SoundData.ReadWideString(name_lenght); Name = soundData.ReadWideString(nameLenght);
} }
else else
{ {
name = SoundData.ReadAscii(name_lenght); Name = soundData.ReadAscii(nameLenght);
} }
this.data = SoundData.ReadBytes((int) SoundData.Size()); this.Data = soundData.ReadBytes((int) soundData.Size());
name = Helper.CleanInput(name); Name = Helper.CleanInput(Name);
Console.WriteLine($"Dumping {name}"); Console.WriteLine($"Dumping {Name}");
string path = $"{Program.DumpPath}\\SoundBank\\{name}.wav"; string path = $"{Program.DumpPath}\\SoundBank\\{Name}.wav";
File.WriteAllBytes(path, data); File.WriteAllBytes(path, Data);
} }
public void Write(ByteWriter writer) public void Write(ByteWriter writer)
{ {
writer.WriteUInt32((uint)handle); writer.WriteUInt32((uint)Handle);
writer.WriteInt32(checksum); writer.WriteInt32(Checksum);
writer.WriteInt32(references); writer.WriteInt32(References);
writer.WriteInt32(data.Length+name.Length+1); writer.WriteInt32(Data.Length+Name.Length+1);
writer.WriteInt32(flags); writer.WriteInt32(Flags);
writer.WriteInt32(0); writer.WriteInt32(0);
writer.WriteInt32(name.Length+1); writer.WriteInt32(Name.Length+1);
if (isCompressed) writer.WriteUnicode(name); if (IsCompressed) writer.WriteUnicode(Name);
else writer.WriteAscii(name); else writer.WriteAscii(Name);
writer.WriteBytes(data); writer.WriteBytes(Data);

@ -8,13 +8,14 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.MMFParser.ChunkLoaders
{ {
public class AppIcon:ChunkLoader public class AppIcon : ChunkLoader
{ {
List<byte> points; List<byte> _points;
public AppIcon(ByteIO reader) : base(reader) public AppIcon(ByteIO reader) : base(reader)
@ -29,47 +30,40 @@ namespace NetMFAPatcher.chunkloaders
{ {
return; return;
Logger.Log("dumpingIcon"); Logger.Log("dumpingIcon");
reader.ReadBytes(reader.ReadInt32() - 4); Reader.ReadBytes(Reader.ReadInt32() - 4);
List<byte> color_indexes = new List<byte>(); List<byte> colorIndexes = new List<byte>();
for (int i = 0; i < 16*16; i++) for (int i = 0; i < 16 * 16; i++)
{ {
var b = Reader.ReadByte();
var b = reader.ReadByte(); var g = Reader.ReadByte();
var g = reader.ReadByte(); var r = Reader.ReadByte();
var r = reader.ReadByte(); Reader.ReadByte();
reader.ReadByte(); colorIndexes.Add(r);
color_indexes.Add(r); colorIndexes.Add(g);
color_indexes.Add(g); colorIndexes.Add(b);
color_indexes.Add(b);
} }
points = new List<byte>();
_points = new List<byte>();
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
var x_list = new List<byte>(); var xList = new List<byte>();
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
{ {
x_list.Add(color_indexes[reader.ReadByte()]); xList.Add(colorIndexes[Reader.ReadByte()]);
} }
//x_list.AddRange(points); //x_list.AddRange(points);
//points = x_list; //points = x_list;
x_list.AddRange(points); xList.AddRange(_points);
points = x_list; _points = xList;
} }
File.WriteAllBytes("fatcock.raw", points.ToArray());
File.WriteAllBytes("fatcock.raw", _points.ToArray());
} }
public override void Print(bool ext) public override void Print(bool ext)
{ {
} }
} }
} }

@ -10,7 +10,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
{ {
class ChunkList : DataLoader//This is used for MFA reading/writing class ChunkList : DataLoader//This is used for MFA reading/writing
{ {
List<DataLoader> items = new List<DataLoader>(); List<DataLoader> _items = new List<DataLoader>();
public override void Print() public override void Print()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -18,10 +18,10 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
var start = reader.Tell(); var start = Reader.Tell();
while(true) while(true)
{ {
var id = reader.ReadByte(); var id = Reader.ReadByte();
if(id==0) break; if(id==0) break;
Console.WriteLine("ChunkFound:"+id); Console.WriteLine("ChunkFound:"+id);

@ -10,7 +10,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
{ {
class Controls : DataLoader class Controls : DataLoader
{ {
public List<PlayerControl> items; public List<PlayerControl> Items;
public Controls(ByteIO reader) : base(reader) public Controls(ByteIO reader) : base(reader)
{ {
@ -24,12 +24,12 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
items = new List<PlayerControl>(); Items = new List<PlayerControl>();
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var item = new mmfparser.mfaloaders.PlayerControl(reader); var item = new mmfparser.mfaloaders.PlayerControl(Reader);
items.Add(item); Items.Add(item);
item.Read(); item.Read();
} }
} }
@ -37,7 +37,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
class PlayerControl : DataLoader class PlayerControl : DataLoader
{ {
int controlType; int _controlType;
@ -54,19 +54,19 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
controlType = reader.ReadInt32(); _controlType = Reader.ReadInt32();
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
var up = reader.ReadInt32(); var up = Reader.ReadInt32();
var down = reader.ReadInt32(); var down = Reader.ReadInt32();
var left = reader.ReadInt32(); var left = Reader.ReadInt32();
var right = reader.ReadInt32(); var right = Reader.ReadInt32();
var button1 = reader.ReadInt32(); var button1 = Reader.ReadInt32();
var button2 = reader.ReadInt32(); var button2 = Reader.ReadInt32();
var button3 = reader.ReadInt32(); var button3 = Reader.ReadInt32();
var button4 = reader.ReadInt32(); var button4 = Reader.ReadInt32();
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
reader.ReadInt32(); Reader.ReadInt32();
} }

@ -6,16 +6,17 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders namespace NetMFAPatcher.mmfparser.mfaloaders
{ {
class Frame : DataLoader class Frame : DataLoader
{ {
public string name = "ERROR"; public string Name = "ERROR";
public int sizeX; public int SizeX;
public int sizeY; public int SizeY;
public Color background; public Color Background;
public int maxObjects; public int MaxObjects;
public Frame(ByteIO reader) : base(reader) public Frame(ByteIO reader) : base(reader)
{ {
@ -29,32 +30,32 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
var handle = reader.ReadInt32(); var handle = Reader.ReadInt32();
name = Helper.AutoReadUnicode(reader); Name = Helper.AutoReadUnicode(Reader);
Console.WriteLine(name); Console.WriteLine(Name);
sizeX = reader.ReadInt32(); SizeX = Reader.ReadInt32();
sizeY = reader.ReadInt32(); SizeY = Reader.ReadInt32();
var background = reader.ReadColor(); var background = Reader.ReadColor();
var flags = reader.ReadInt32(); var flags = Reader.ReadInt32();
maxObjects = reader.ReadInt32(); MaxObjects = Reader.ReadInt32();
var password = Helper.AutoReadUnicode(reader); var password = Helper.AutoReadUnicode(Reader);
reader.Skip(4); Reader.Skip(4);
var lastViewedX = reader.ReadInt32(); var lastViewedX = Reader.ReadInt32();
var lastViewedY = reader.ReadInt32(); var lastViewedY = Reader.ReadInt32();
var paletteNum = reader.ReadInt32(); var paletteNum = Reader.ReadInt32();
List<Color> palette = new List<Color>(); List<Color> palette = new List<Color>();
for (int i = 0; i < paletteNum; i++) for (int i = 0; i < paletteNum; i++)
{ {
palette.Add(reader.ReadColor()); palette.Add(Reader.ReadColor());
} }
var stampHandle = reader.ReadInt32(); var stampHandle = Reader.ReadInt32();
var activeLayer = reader.ReadInt32(); var activeLayer = Reader.ReadInt32();
var layersCunt = reader.ReadInt32(); var layersCunt = Reader.ReadInt32();
var layers = new List<Layer>(); var layers = new List<Layer>();
for (int i = 0; i < layersCunt; i++) for (int i = 0; i < layersCunt; i++)
{ {
var layer = new Layer(reader); var layer = new Layer(Reader);
layer.Read(); layer.Read();
layers.Add(layer); layers.Add(layer);
@ -62,13 +63,13 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
//fadein //fadein
//fadeout //fadeout
reader.Skip(2); Reader.Skip(2);
var frameitems = new List<FrameItem>(); var frameitems = new List<FrameItem>();
var frameitemsCount = reader.ReadInt32(); var frameitemsCount = Reader.ReadInt32();
for (int i = 0; i < frameitemsCount; i++) for (int i = 0; i < frameitemsCount; i++)
{ {
var frameitem = new FrameItem(reader); var frameitem = new FrameItem(Reader);
frameitem.Read(); frameitem.Read();
frameitems.Add(frameitem); frameitems.Add(frameitem);
//break; //break;

@ -7,50 +7,51 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders namespace NetMFAPatcher.mmfparser.mfaloaders
{ {
class FrameItem : DataLoader class FrameItem : DataLoader
{ {
public int objectType; public int ObjectType;
public int handle; public int Handle;
public string name; public string Name;
public bool transparent; public bool Transparent;
public int inkEffect; public int InkEffect;
public int inkEffectParameter; public int InkEffectParameter;
public int antiAliasing; public int AntiAliasing;
public int flags; public int Flags;
public int iconType; public int IconType;
public override void Print() public override void Print()
{ {
Console.WriteLine($"Name: {name}"); Console.WriteLine($"Name: {Name}");
} }
public override void Read() public override void Read()
{ {
objectType = reader.ReadInt32(); ObjectType = Reader.ReadInt32();
handle = reader.ReadInt32(); Handle = Reader.ReadInt32();
name = Helper.AutoReadUnicode(reader); Name = Helper.AutoReadUnicode(Reader);
var transparent1 = reader.ReadInt32(); var transparent1 = Reader.ReadInt32();
inkEffect = reader.ReadInt32(); InkEffect = Reader.ReadInt32();
inkEffectParameter = reader.ReadInt32(); InkEffectParameter = Reader.ReadInt32();
antiAliasing = reader.ReadInt32(); AntiAliasing = Reader.ReadInt32();
flags = reader.ReadInt32(); Flags = Reader.ReadInt32();
iconType = reader.ReadInt32(); IconType = Reader.ReadInt32();
if(iconType==1) if(IconType==1)
{ {
var iconHandle = reader.ReadInt32(); var iconHandle = Reader.ReadInt32();
} }
else else
{ {
throw new NotImplementedException("invalid icon"); throw new NotImplementedException("invalid icon");
} }
var chunks = new mmfparser.mfaloaders.ChunkList(reader); var chunks = new mmfparser.mfaloaders.ChunkList(Reader);
chunks.Read(); chunks.Read();
if(objectType>=32)//extension base if(ObjectType>=32)//extension base
{ {
//swallow some cum //swallow some cum
@ -58,7 +59,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
else else
{ {
var loader = new Active(reader); var loader = new Active(Reader);
loader.Read(); loader.Read();

@ -1,16 +1,12 @@
using NetMFAPatcher.chunkloaders; using System;
using NetMFAPatcher.mmfparser; using mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace mmfparser.mfaloaders namespace NetMFAPatcher.MMFParser.MFALoaders
{ {
class AGMIBank : DataLoader class AgmiBank : DataLoader
{ {
public override void Print() public override void Print()
{ {
@ -20,27 +16,27 @@ namespace mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
Logger.Log("TEX READ"); Logger.Log("TEX READ");
var graphicMode = reader.ReadInt32(); var graphicMode = Reader.ReadInt32();
Logger.Log($"GraphicMode:{graphicMode}"); Logger.Log($"GraphicMode:{graphicMode}");
var paletteVersion = reader.ReadInt16(); var paletteVersion = Reader.ReadInt16();
Logger.Log($"PaletteVersion:{paletteVersion}"); Logger.Log($"PaletteVersion:{paletteVersion}");
var paletteEntries = reader.ReadInt16(); var paletteEntries = Reader.ReadInt16();
Logger.Log($"PaletteEntries:{paletteEntries}"); Logger.Log($"PaletteEntries:{paletteEntries}");
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
reader.ReadColor(); Reader.ReadColor();
} }
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
Logger.Log($"Number of image items: {count.ToString()}"); Logger.Log($"Number of image items: {count.ToString()}");
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var item = new ImageItem(reader); var item = new ImageItem(Reader);
item.isCompressed = true; item.IsCompressed = true;
var currentPos = reader.Tell(); var currentPos = Reader.Tell();
item.Read(); item.Read();
@ -51,11 +47,11 @@ namespace mmfparser.mfaloaders
} }
} }
public AGMIBank(ByteIO reader) : base(reader) public AgmiBank(ByteIO reader) : base(reader)
{ {
} }
public AGMIBank(Chunk chunk) : base(chunk) public AgmiBank(Chunk chunk) : base(chunk)
{ {
} }
} }

@ -5,15 +5,16 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders namespace NetMFAPatcher.mmfparser.mfaloaders
{ {
class Layer : DataLoader class Layer : DataLoader
{ {
public string name="ERROR"; public string Name="ERROR";
public float xCoefficient; public float XCoefficient;
public float yCoefficient; public float YCoefficient;
public int flags; public int Flags;
public override void Print() public override void Print()
@ -23,10 +24,10 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
name = Helper.AutoReadUnicode(reader); Name = Helper.AutoReadUnicode(Reader);
flags = reader.ReadInt32(); Flags = Reader.ReadInt32();
xCoefficient = reader.ReadSingle(); XCoefficient = Reader.ReadSingle();
yCoefficient = reader.ReadSingle(); YCoefficient = Reader.ReadSingle();

@ -5,12 +5,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders namespace NetMFAPatcher.mmfparser.mfaloaders
{ {
class ValueList : DataLoader class ValueList : DataLoader
{ {
public List<ValueItem> items = new List<ValueItem>(); public List<ValueItem> Items = new List<ValueItem>();
public ValueList(ByteIO reader) : base(reader) public ValueList(ByteIO reader) : base(reader)
{ {
} }
@ -23,12 +24,12 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var item = new ValueItem(reader); var item = new ValueItem(Reader);
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }
@ -37,8 +38,8 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
} }
class ValueItem: DataLoader class ValueItem: DataLoader
{ {
public object value; public object Value;
public string name; public string Name;
public ValueItem(ByteIO reader) : base(reader) public ValueItem(ByteIO reader) : base(reader)
{ {
@ -52,18 +53,18 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read() public override void Read()
{ {
name = Helper.AutoReadUnicode(reader); Name = Helper.AutoReadUnicode(Reader);
var type = reader.ReadInt32(); var type = Reader.ReadInt32();
switch (type) switch (type)
{ {
case 2://string case 2://string
value = Helper.AutoReadUnicode(reader); Value = Helper.AutoReadUnicode(Reader);
break; break;
case 0://int case 0://int
value = reader.ReadInt32(); Value = Reader.ReadInt32();
break; break;
case 1://double case 1://double
value = reader.ReadDouble(); Value = Reader.ReadDouble();
break; break;
} }

@ -10,18 +10,18 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{ {
class AnimationObject:ObjectLoader class AnimationObject:ObjectLoader
{ {
List<Animation> items = new List<Animation>(); List<Animation> _items = new List<Animation>();
public override void Read() public override void Read()
{ {
base.Read(); base.Read();
if(reader.ReadByte()!=0) if(Reader.ReadByte()!=0)
{ {
var animationCount = reader.ReadInt32(); var animationCount = Reader.ReadInt32();
for (int i = 0; i < animationCount; i++) for (int i = 0; i < animationCount; i++)
{ {
var item = new Animation(reader); var item = new Animation(Reader);
item.Read(); item.Read();
items.Add(item); _items.Add(item);
} }
} }
@ -31,20 +31,20 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
} }
class Animation : DataLoader class Animation : DataLoader
{ {
public string name = "Animation-UNKNOWN"; public string Name = "Animation-UNKNOWN";
public override void Print() public override void Print()
{ {
Logger.Log($" Found animation: {name} "); Logger.Log($" Found animation: {Name} ");
} }
public override void Read() public override void Read()
{ {
name = reader.ReadAscii(reader.ReadInt32()); Name = Reader.ReadAscii(Reader.ReadInt32());
var directionCount = reader.ReadInt32(); var directionCount = Reader.ReadInt32();
var directions = new List<AnimationDirection>(); var directions = new List<AnimationDirection>();
for (int i = 0; i < directionCount; i++) for (int i = 0; i < directionCount; i++)
{ {
var direction = new AnimationDirection(reader); var direction = new AnimationDirection(Reader);
direction.Read(); direction.Read();
directions.Add(direction); directions.Add(direction);
} }
@ -56,7 +56,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
} }
class AnimationDirection : DataLoader class AnimationDirection : DataLoader
{ {
public string name = "Animation-UNKNOWN"; public string Name = "Animation-UNKNOWN";
public override void Print() public override void Print()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -64,11 +64,11 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read() public override void Read()
{ {
var index = reader.ReadInt32(); var index = Reader.ReadInt32();
var minSpeed = reader.ReadInt32(); var minSpeed = Reader.ReadInt32();
var maxSpeed= reader.ReadInt32(); var maxSpeed= Reader.ReadInt32();
var repeat= reader.ReadInt32(); var repeat= Reader.ReadInt32();
var backTo= reader.ReadInt32(); var backTo= Reader.ReadInt32();
var frames = new List<int>(); var frames = new List<int>();
} }

@ -10,7 +10,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{ {
class Behaviours : DataLoader class Behaviours : DataLoader
{ {
List<Behaviour> items = new List<Behaviour>(); List<Behaviour> _items = new List<Behaviour>();
public override void Print() public override void Print()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -18,20 +18,20 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read() public override void Read()
{ {
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var item = new Behaviour(reader); var item = new Behaviour(Reader);
item.Read(); item.Read();
items.Add(item); _items.Add(item);
} }
} }
public Behaviours(ByteIO reader) : base(reader) { } public Behaviours(ByteIO reader) : base(reader) { }
} }
class Behaviour : DataLoader class Behaviour : DataLoader
{ {
public string name = "ERROR"; public string Name = "ERROR";
public ByteIO data; public ByteIO Data;
public override void Print() public override void Print()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -39,8 +39,8 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read() public override void Read()
{ {
name = reader.ReadAscii(reader.ReadInt32()); Name = Reader.ReadAscii(Reader.ReadInt32());
data = new ByteIO(reader.ReadBytes(reader.ReadInt32())); Data = new ByteIO(Reader.ReadBytes(Reader.ReadInt32()));
} }
public Behaviour(ByteIO reader) : base(reader) { } public Behaviour(ByteIO reader) : base(reader) { }

@ -5,12 +5,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{ {
class Movements : DataLoader class Movements : DataLoader
{ {
public List<Movement> items = new List<Movement>(); public List<Movement> Items = new List<Movement>();
public override void Print() public override void Print()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -18,12 +19,12 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read() public override void Read()
{ {
var count = reader.ReadInt32(); var count = Reader.ReadInt32();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var item = new Movement(reader); var item = new Movement(Reader);
item.Read(); item.Read();
items.Add(item); Items.Add(item);
} }
@ -33,7 +34,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
} }
class Movement : DataLoader class Movement : DataLoader
{ {
public string name="ERROR"; public string Name="ERROR";
public override void Print() public override void Print()
{ {
@ -42,23 +43,23 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read() public override void Read()
{ {
name = Helper.AutoReadUnicode(reader); Name = Helper.AutoReadUnicode(Reader);
var extension = Helper.AutoReadUnicode(reader); var extension = Helper.AutoReadUnicode(Reader);
var identifier = reader.ReadInt32(); var identifier = Reader.ReadInt32();
var dataSize = reader.ReadInt32(); var dataSize = Reader.ReadInt32();
if(extension.Length>0) if(extension.Length>0)
{ {
var newReader = new ByteIO(reader.ReadBytes(dataSize)); var newReader = new ByteIO(Reader.ReadBytes(dataSize));
} }
else else
{ {
var player = reader.ReadInt16(); var player = Reader.ReadInt16();
var type = reader.ReadInt16(); var type = Reader.ReadInt16();
var movingAtStart = reader.ReadByte(); var movingAtStart = Reader.ReadByte();
reader.Skip(3); Reader.Skip(3);
var directionAtStart = reader.ReadInt32(); var directionAtStart = Reader.ReadInt32();
//implement types, but i am tired, fuck this shit //implement types, but i am tired, fuck this shit
} }

@ -11,62 +11,62 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{ {
class ObjectLoader : DataLoader class ObjectLoader : DataLoader
{ {
public int objectFlags; public int ObjectFlags;
public int newObjectFlags; public int NewObjectFlags;
public Color backgroundColor; public Color BackgroundColor;
List<short> qualifiers = new List<short>(); List<short> _qualifiers = new List<short>();
public ValueList values; public ValueList Values;
public ValueList strings; public ValueList Strings;
public Movements movements; public Movements Movements;
public Behaviours behaviours; public Behaviours Behaviours;
public override void Print() public override void Print()
{ {
Logger.Log("Object Loader: "); Logger.Log("Object Loader: ");
Logger.Log(" Values:"); Logger.Log(" Values:");
foreach (var item in values.items) foreach (var item in Values.Items)
{ {
Logger.Log($" Value {item.name} contains '{item.value}'"); Logger.Log($" Value {item.Name} contains '{item.Value}'");
} }
Logger.Log("\n Strings:"); Logger.Log("\n Strings:");
foreach (var item in strings.items) foreach (var item in Strings.Items)
{ {
Logger.Log($" String {item.name} contains '{item.value}'"); Logger.Log($" String {item.Name} contains '{item.Value}'");
} }
Logger.Log("\n Movements:"); Logger.Log("\n Movements:");
foreach (var item in movements.items) foreach (var item in Movements.Items)
{ {
Logger.Log($" Movement {item.name}"); Logger.Log($" Movement {item.Name}");
} }
Logger.Log("\n"); Logger.Log("\n");
} }
public override void Read() public override void Read()
{ {
objectFlags = reader.ReadInt32(); ObjectFlags = Reader.ReadInt32();
newObjectFlags = reader.ReadInt32(); NewObjectFlags = Reader.ReadInt32();
backgroundColor = reader.ReadColor(); BackgroundColor = Reader.ReadColor();
var end = reader.Tell() + 2 * 9; var end = Reader.Tell() + 2 * 9;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
var value = reader.ReadInt16(); var value = Reader.ReadInt16();
if(value==-1) if(value==-1)
{ {
break; break;
} }
qualifiers.Add(value); _qualifiers.Add(value);
} }
reader.Seek(end); Reader.Seek(end);
values = new ValueList(reader); Values = new ValueList(Reader);
values.Read(); Values.Read();
strings = new ValueList(reader); Strings = new ValueList(Reader);
strings.Read(); Strings.Read();
movements = new Movements(reader); Movements = new Movements(Reader);
movements.Read(); Movements.Read();
behaviours = new Behaviours(reader); Behaviours = new Behaviours(Reader);
behaviours.Read(); Behaviours.Read();
reader.Skip(56); Reader.Skip(56);
Print(); Print();

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Ionic.Zlib" version="1.9.1.5" targetFramework="net472" />
<package id="SharpZipLib" version="1.3.0" targetFramework="net472" /> <package id="SharpZipLib" version="1.3.0" targetFramework="net472" />
</packages> </packages>
Loading…
Cancel
Save