diff --git a/NetMFAPatcher/GUI/FrameViewer.Designer.cs b/NetMFAPatcher/GUI/FrameViewer.Designer.cs index b59460f..d20095d 100644 --- a/NetMFAPatcher/GUI/FrameViewer.Designer.cs +++ b/NetMFAPatcher/GUI/FrameViewer.Designer.cs @@ -96,14 +96,12 @@ namespace DotNetCTFDumper.GUI this.ResumeLayout(false); } - private System.Windows.Forms.ScrollableControl scrollableControl1; - + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem deleteObjBtn; private System.Windows.Forms.ToolStripMenuItem infoMenuItem; private System.Windows.Forms.ToolStripMenuItem nameMenuItem; private System.Windows.Forms.ToolStripMenuItem positionMenuItem; - - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem deleteObjBtn; + private System.Windows.Forms.ScrollableControl scrollableControl1; #endregion } diff --git a/NetMFAPatcher/GUI/MainForm.Designer.cs b/NetMFAPatcher/GUI/MainForm.Designer.cs index 4151ac4..615941c 100644 --- a/NetMFAPatcher/GUI/MainForm.Designer.cs +++ b/NetMFAPatcher/GUI/MainForm.Designer.cs @@ -115,7 +115,6 @@ this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(180, 281); this.listBox1.TabIndex = 5; - // // GameInfo // @@ -302,7 +301,6 @@ this.showHexBtn.Text = "Show hex"; this.showHexBtn.UseVisualStyleBackColor = false; this.showHexBtn.Visible = false; - // // dumpSortedBtn // @@ -325,7 +323,6 @@ this.ChunkCombo.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.saveChunkBtn, this.viewHexBtn, this.previewFrameBtn}); this.ChunkCombo.Name = "Save"; this.ChunkCombo.Size = new System.Drawing.Size(152, 70); - this.ChunkCombo.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ChunkCombo_ItemSelected); // // saveChunkBtn @@ -443,33 +440,30 @@ this.PerformLayout(); } - private System.Windows.Forms.ToolStripMenuItem previewFrameBtn; - - private System.Windows.Forms.Button musicsButton; - - private System.Windows.Forms.ProgressBar imageBar; - private System.Windows.Forms.Label imageLabel; - private System.Windows.Forms.Button imagesButton; - private System.Windows.Forms.ProgressBar musicBar; - private System.Windows.Forms.Label musicLabel; - private System.Windows.Forms.ProgressBar soundBar; - private System.Windows.Forms.Label soundLabel; - private System.Windows.Forms.Button soundsButton; - private System.Windows.Forms.Button button1; private System.Windows.Forms.ContextMenuStrip ChunkCombo; private System.Windows.Forms.Button cryptKeyBtn; private System.Windows.Forms.Button dumpSortedBtn; private System.Windows.Forms.Button FolderBTN; private System.Windows.Forms.Label GameInfo; + private System.Windows.Forms.ProgressBar imageBar; + private System.Windows.Forms.Label imageLabel; + private System.Windows.Forms.Button imagesButton; private System.Windows.Forms.Label label1; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Label loadingLabel; private System.Windows.Forms.Button MFABtn; + private System.Windows.Forms.ProgressBar musicBar; + private System.Windows.Forms.Label musicLabel; + private System.Windows.Forms.Button musicsButton; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.Button packDataBtn; + private System.Windows.Forms.ToolStripMenuItem previewFrameBtn; private System.Windows.Forms.ToolStripMenuItem saveChunkBtn; private System.Windows.Forms.Button showHexBtn; + private System.Windows.Forms.ProgressBar soundBar; + private System.Windows.Forms.Label soundLabel; + private System.Windows.Forms.Button soundsButton; private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.ToolStripMenuItem viewHexBtn; diff --git a/NetMFAPatcher/MMFParser/Data/MFA.cs b/NetMFAPatcher/MMFParser/Data/MFA.cs index 6dc038c..31e34c5 100644 --- a/NetMFAPatcher/MMFParser/Data/MFA.cs +++ b/NetMFAPatcher/MMFParser/Data/MFA.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Numerics; using DotNetCTFDumper.MMFParser.ChunkLoaders; using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; using DotNetCTFDumper.MMFParser.MFALoaders; @@ -27,6 +28,8 @@ namespace DotNetCTFDumper.MMFParser.Data public string Description; public string Path; + public List BinaryFiles = new List(); + public FontBank Fonts; public SoundBank Sounds; public MusicBank Music; @@ -47,6 +50,7 @@ namespace DotNetCTFDumper.MMFParser.Data public ValueList GlobalValues; public ValueList GlobalStrings; public Color BorderColor; + public BitDict DisplayFlags = new BitDict(new string[] { "MaximizedOnBoot", @@ -63,9 +67,9 @@ namespace DotNetCTFDumper.MMFParser.Data "NoCenter", "DisableClose", "HiddenAtStart", - "MDI" - + "MDI" }); + public BitDict GraphicFlags = new BitDict(new string[] { "MultiSamples", @@ -83,8 +87,10 @@ namespace DotNetCTFDumper.MMFParser.Data "NoDebugger", "NoSubappSharing" }); + public string HelpFile; - public int VitalizePreview; + public string unknown_string; //Found in original mfa build 283 + public byte[] VitalizePreview; public int InitialScore; public int InitialLifes; public int FrameRate; @@ -95,7 +101,7 @@ namespace DotNetCTFDumper.MMFParser.Data public uint MenuSize; public AppMenu Menu; private int windowMenuIndex; - private int[] menuImages; + private Dictionary menuImages; private byte[] GlobalEvents; private int GraphicMode; private int IcoCount; @@ -107,18 +113,15 @@ namespace DotNetCTFDumper.MMFParser.Data public List Frames; - - public override void Print() { //Logger.Log($"MFA Product:{product}"); //Logger.Log($"MFA Build:{mfaBuild}"); //Logger.Log($"MFA Product:{buildVersion}"); - } + public override void Write(ByteWriter Writer) { - Writer.WriteAscii("MFU2"); Writer.WriteInt32(MfaBuild); Writer.WriteInt32(Product); @@ -128,25 +131,25 @@ namespace DotNetCTFDumper.MMFParser.Data Writer.AutoWriteUnicode(Description); Writer.AutoWriteUnicode(Path); - Writer.WriteUInt32((uint)Stamp.Length); + Writer.WriteUInt32((uint) Stamp.Length); Writer.WriteBytes(Stamp); Writer.WriteAscii(FontBankId); Fonts.Write(Writer); Writer.WriteAscii(SoundBankId); Sounds.Write(Writer); - + Writer.WriteAscii(MusicBankId); - //music.Write(); - Writer.WriteInt32(0);//someone is using musics lol? + // music.Write(); + Writer.WriteInt32(0); //someone is using musics lol? //TODO: Do music - + Writer.WriteAscii(ImageBankId); Icons.Write(Writer); - + Writer.WriteAscii(ImageBankId); Images.Write(Writer); - - + + Writer.AutoWriteUnicode(Name); Writer.AutoWriteUnicode(Author); Writer.AutoWriteUnicode(Description); @@ -158,6 +161,10 @@ namespace DotNetCTFDumper.MMFParser.Data Writer.WriteColor(Color.White); Writer.WriteInt32((int) DisplayFlags.flag); Writer.WriteInt32((int) GraphicFlags.flag); + Writer.AutoWriteUnicode(HelpFile); + Writer.AutoWriteUnicode(unknown_string); + Writer.WriteInt32(VitalizePreview.Length); + Writer.WriteBytes(VitalizePreview); Writer.WriteUInt32((uint) InitialScore); Writer.WriteUInt32((uint) InitialLifes); Writer.WriteInt32(FrameRate); @@ -165,35 +172,40 @@ namespace DotNetCTFDumper.MMFParser.Data Writer.AutoWriteUnicode(BuildPath); Writer.AutoWriteUnicode(CommandLine); Writer.AutoWriteUnicode(Aboutbox); - Menu = null; //TODO:Menu + + Writer.WriteInt32(BinaryFiles.Count); + foreach (byte[] binaryFile in BinaryFiles) + { + Writer.WriteInt32(binaryFile.Length); + Writer.WriteBytes(binaryFile); + } + + Controls.Write(Writer); + + // Menu = null; //TODO:Menu if (Menu != null) { - byte[] menuData = new byte[1]; //Menu.Generate; - Writer.WriteInt32(menuData.Length); - Writer.WriteBytes(menuData); + using (ByteWriter menuWriter = new ByteWriter(new MemoryStream())) + { + Menu.Write(menuWriter); + + Writer.WriteUInt32((uint) menuWriter.BaseStream.Position); + Writer.WriteWriter(menuWriter); + } } else { Writer.WriteInt32(0); } - - - - - - - - - - - - - - - - - + Writer.WriteInt32(windowMenuIndex); + Writer.WriteInt32(menuImages.Count); + foreach (KeyValuePair valuePair in menuImages) + { + Writer.WriteInt32(valuePair.Key); + Writer.WriteInt32(valuePair.Value); + } + } public override void Read() @@ -216,7 +228,7 @@ namespace DotNetCTFDumper.MMFParser.Data Sounds = new SoundBank(Reader); Sounds.IsCompressed = false; Sounds.Read(); - + if (Reader.ReadAscii(4) != MusicBankId) throw new Exception("Invalid Music Bank"); Music = new MusicBank(Reader); Music.Read(); @@ -229,9 +241,9 @@ namespace DotNetCTFDumper.MMFParser.Data Images = new AgmiBank(Reader); Images.Read(); - Helper.CheckPattern(Helper.AutoReadUnicode(Reader),Name); + Helper.CheckPattern(Helper.AutoReadUnicode(Reader), Name); Author = Helper.AutoReadUnicode(Reader); - Helper.CheckPattern(Helper.AutoReadUnicode(Reader),Description); + Helper.CheckPattern(Helper.AutoReadUnicode(Reader), Description); Copyright = Helper.AutoReadUnicode(Reader); Company = Helper.AutoReadUnicode(Reader); Version = Helper.AutoReadUnicode(Reader); @@ -241,11 +253,14 @@ namespace DotNetCTFDumper.MMFParser.Data DisplayFlags.flag = Reader.ReadUInt32(); GraphicFlags.flag = Reader.ReadUInt32(); HelpFile = Helper.AutoReadUnicode(Reader); - VitalizePreview = Reader.ReadInt32(); + unknown_string = Helper.AutoReadUnicode(Reader); + Int32 vit_size = Reader.ReadInt32(); + VitalizePreview = Reader.ReadBytes(vit_size); + InitialScore = Reader.ReadInt32(); InitialLifes = Reader.ReadInt32(); FrameRate = Reader.ReadInt32(); - BuildType = Reader.ReadInt32(); + BuildType = Reader.ReadInt32(); BuildPath = Helper.AutoReadUnicode(Reader); //Console.WriteLine(BuildPath); //Helper.CheckPattern(Reader.ReadInt32(),0); @@ -253,13 +268,14 @@ namespace DotNetCTFDumper.MMFParser.Data CommandLine = Helper.AutoReadUnicode(Reader); Aboutbox = Helper.AutoReadUnicode(Reader); 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++) { - Reader.ReadBytes(Reader.ReadInt32());//binaryfiles + BinaryFiles.Add(Reader.ReadBytes(Reader.ReadInt32())); } + Controls = new Controls(Reader); Controls.Read(); @@ -270,24 +286,22 @@ namespace DotNetCTFDumper.MMFParser.Data Reader.Seek(MenuSize + currentPosition); windowMenuIndex = Reader.ReadInt32(); - menuImages = new int[65535];//govnokod suka - var miCount = Reader.ReadInt32(); + menuImages = new Dictionary(); + int miCount = Reader.ReadInt32(); for (int i = 0; i < miCount; i++) { - var id = Reader.ReadInt32(); + int id = Reader.ReadInt32(); menuImages[id] = Reader.ReadInt32(); } - - GlobalValues = new ValueList(Reader); GlobalValues.Read(); GlobalStrings = new ValueList(Reader); GlobalStrings.Read(); GlobalEvents = Reader.ReadBytes(Reader.ReadInt32()); - GraphicMode = Reader.ReadInt32();; - + GraphicMode = Reader.ReadInt32(); + ; IcoCount = Reader.ReadInt32(); @@ -296,35 +310,37 @@ namespace DotNetCTFDumper.MMFParser.Data { IconImages.Add(Reader.ReadInt32()); } - + //I STUCK HERE QualCount = Reader.ReadInt32(); CustomQuals = new List>(); - for (int i = 0; i < QualCount; i++)//qualifiers + for (int i = 0; i < QualCount; i++) //qualifiers { var name = Reader.ReadAscii(Reader.ReadInt32()); var handle = Reader.ReadInt32(); - CustomQuals.Add(new Tuple(name,handle)); - + CustomQuals.Add(new Tuple(name, handle)); } + var extCount = Reader.ReadInt32(); Extensions = new List>(); - for (int i = 0; i < extCount; i++)//extensions + for (int i = 0; i < extCount; i++) //extensions { var handle = Reader.ReadInt32(); var filename = Helper.AutoReadUnicode(Reader); var name = Helper.AutoReadUnicode(Reader); var magic = Reader.ReadInt32(); var data = Reader.ReadBytes(Reader.ReadInt32()); - var tuple = new Tuple(handle,filename,name,magic,data); + var tuple = new Tuple(handle, filename, name, magic, data); Extensions.Add(tuple); } + List frameOffsets = new List(); var offCount = Reader.ReadInt32(); for (int i = 0; i < offCount; i++) { frameOffsets.Add(Reader.ReadInt32()); } + var nextOffset = Reader.ReadInt32(); Frames = new List(); foreach (var item in frameOffsets) @@ -333,25 +349,18 @@ namespace DotNetCTFDumper.MMFParser.Data var testframe = new Frame(Reader); testframe.Read(); Frames.Add(testframe); - } + Reader.Seek(nextOffset); var chunks = new MFALoaders.ChunkList(Reader); chunks.Read(); return; + } + - - - - - - - } public MFA(ByteReader reader) : base(reader) { } - - } -} +} \ No newline at end of file diff --git a/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs b/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs index 16d9452..0a1bfb6 100644 --- a/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs +++ b/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs @@ -6,7 +6,7 @@ namespace DotNetCTFDumper.MMFParser.Decompiling { public static class MFAGenerator { - public static readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\testNoFrames.mfa"; + public static readonly string TemplatePath = @"F:\CPP\DotNetCTFDumper\testNoFrames.mfa"; public static void BuildMFA() { @@ -16,7 +16,7 @@ namespace DotNetCTFDumper.MMFParser.Decompiling template.Read(); //Loading template - var gameMFA = template;//Pame2Mfa.Translate(template, Exe.LatestInst.GameData); //Translation + var gameMFA = template; //Pame2Mfa.Translate(template, Exe.LatestInst.GameData); //Translation var mfaWriter = new ByteWriter( diff --git a/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs b/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs index 623d563..4355c95 100644 --- a/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs +++ b/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs @@ -42,7 +42,7 @@ namespace DotNetCTFDumper.MMFParser.Decompiling mfa.WindowY = game.Header.WindowHeight; mfa.BorderColor = game.Header.BorderColor; mfa.HelpFile = ""; - mfa.VitalizePreview = 0; + mfa.VitalizePreview = new byte[]{0x0}; mfa.InitialScore = game.Header.InitialScore; mfa.InitialLifes = game.Header.InitialLives; mfa.FrameRate = game.Header.FrameRate; diff --git a/NetMFAPatcher/Utils/ByteWriter.cs b/NetMFAPatcher/Utils/ByteWriter.cs index 3f27d38..7472ef5 100644 --- a/NetMFAPatcher/Utils/ByteWriter.cs +++ b/NetMFAPatcher/Utils/ByteWriter.cs @@ -61,9 +61,9 @@ namespace DotNetCTFDumper.Utils public void WriteInt16(short value)=>Write(value); public void WriteInt32(int value) => Write(value); public void WriteInt64(long value) => Write(value); - + public void WriteUInt16(ushort value) => Write(value); - public void WriteUInt32(uint value) => Write(value); + public void WriteUInt32(UInt32 value) => Write(value); public void WriteUInt64(ulong value) => Write(value); public void WriteSingle(float value) => Write(value); @@ -94,7 +94,7 @@ namespace DotNetCTFDumper.Utils WriteInt8(color.R); WriteInt8(color.G); WriteInt8(color.B); - Skip(1); + WriteInt8(0); } diff --git a/NetMFAPatcher/Utils/Decompressor.cs b/NetMFAPatcher/Utils/Decompressor.cs index c2847d8..2387c20 100644 --- a/NetMFAPatcher/Utils/Decompressor.cs +++ b/NetMFAPatcher/Utils/Decompressor.cs @@ -40,5 +40,23 @@ namespace DotNetCTFDumper.Utils Array.Resize(ref decompressedData, decompSize); return decompressedData; } + + public static byte[] compress_block(byte[] data) + { + ZLibCompressOptions compOpts = new ZLibCompressOptions(); + compOpts.Level = ZLibCompLevel.Default; + MemoryStream decompressedStream = new MemoryStream(data); + MemoryStream compressedStream = new MemoryStream(); + byte[] compressedData = null; + Int32 compressed_size = 0; + ZLibStream zs = new ZLibStream(compressedStream, compOpts); + decompressedStream.CopyTo(zs); + zs.Close(); + + compressedData = compressedStream.GetBuffer(); + Array.Resize(ref compressedData, (int) zs.TotalOut); + + return compressedData; + } } } \ No newline at end of file diff --git a/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs b/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs index 63ed89f..aaac63f 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs @@ -13,7 +13,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks { public class ImageBank : ChunkLoader { - public bool SaveImages=true; + public bool SaveImages = true; public Dictionary Images = new Dictionary(); public uint NumberOfItems; @@ -36,20 +36,21 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks $"Number of images: {NumberOfItems}" }; } - public void Read(bool load,bool save) + + public void Read(bool load, bool save) { var cache = Settings.DumpImages; Settings.DumpImages = load; SaveImages = save; Read(); Settings.DumpImages = cache; - } + public override void Read() { - if (!Settings.DoMFA)Reader.Seek(0);//Reset the reader to avoid bugs when dumping more than once + if (!Settings.DoMFA) Reader.Seek(0); //Reset the reader to avoid bugs when dumping more than once Images = new Dictionary(); - + NumberOfItems = Reader.ReadUInt32(); @@ -67,11 +68,11 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks var item = new ImageItem(Reader); item.Read(); Images.Add(item.Handle, item); - - if(SaveImages)item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png"); - - Helper.OnImageSaved(i, (int) NumberOfItems); - + + if (SaveImages) item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png"); + + Helper.OnImageSaved(i, (int) NumberOfItems); + if (Exe.Instance.GameData.ProductBuild >= 284) item.Handle -= 1; @@ -123,7 +124,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks public override void Read() { - Handle = Reader.ReadInt32()-1; + Handle = Reader.ReadInt32() - 1; Position = (int) Reader.Tell(); Load(); } @@ -228,23 +229,20 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks public void Save(string filename) { - - using (var bmp = new Bitmap(_width, _height, PixelFormat.Format32bppArgb)) - { - BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, - bmp.Width, - bmp.Height), - ImageLockMode.WriteOnly, - bmp.PixelFormat); + using (var bmp = new Bitmap(_width, _height, PixelFormat.Format32bppArgb)) + { + 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); + IntPtr pNative = bmpData.Scan0; + Marshal.Copy(_colorArray, 0, pNative, _colorArray.Length); - bmp.UnlockBits(bmpData); - bmp.Save(filename); - } - - + bmp.UnlockBits(bmpData); + bmp.Save(filename); + } } public Bitmap Bitmap @@ -265,50 +263,67 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks Marshal.Copy(_colorArray, 0, pNative, _colorArray.Length); _bitmap.UnlockBits(bmpData); - } return _bitmap; } + } + // private byte[] GenerateImage() + // { + // Int32 pad = ImageHelper.GetPadding(_width, 3); + // byte[] points = new byte[(_width * _height + pad * _height)*3]; + // for (UInt32 y = 0; y < _height; y++) + // { + // for (UInt32 x = 0; x < _height; x++) + // { + // + // } + // } + // + // return points; + // } - } - public void Write(ByteWriter writer) { ByteWriter chunk = new ByteWriter(new MemoryStream()); chunk.WriteInt32(_checksum); chunk.WriteInt32(_references); - chunk.WriteInt32(_colorArray.Length); - chunk.WriteInt16((short) _width); - chunk.WriteInt16((short) _height); - chunk.WriteInt8((byte) _graphicMode); - if (Flags["Alpha"]) + byte[] compressedImg = null; + if (Flags["LZX"]) { - chunk.WriteInt8(16); + compressedImg = Decompressor.compress_block(rawImg); + chunk.WriteUInt32((uint) compressedImg.Length+4); } else { - chunk.WriteInt8(0); + chunk.WriteUInt32((uint) rawImg.Length); } - chunk.Skip(2); + chunk.WriteInt16((short) _width); + chunk.WriteInt16((short) _height); + chunk.WriteInt8((byte) _graphicMode); + chunk.WriteInt8((byte) Flags.flag); + chunk.WriteInt16(0); chunk.WriteInt16((short) XHotspot); chunk.WriteInt16((short) YHotspot); chunk.WriteInt16((short) ActionX); chunk.WriteInt16((short) ActionY); chunk.WriteBytes(_transparent); + if (Flags["LZX"]) + { + chunk.WriteInt32(rawImg.Length); + chunk.WriteBytes(compressedImg); + } + + else + { + chunk.WriteBytes(rawImg); + } - chunk.WriteBytes(_colorArray); - - if(Flags["Alpha"])chunk.WriteBytes(rawAlpha); - writer.WriteInt32(Handle); - - + writer.WriteInt32(Handle + 1); writer.WriteWriter(chunk); - //MemoryStream ms = (MemoryStream) chunk.BaseStream; - //writer.WriteBytes(ms.GetBuffer()); } diff --git a/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs b/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs index 5deffaf..a8a1d75 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs @@ -13,7 +13,7 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders private int GraphicMode; private int PaletteVersion; private int PaletteEntries; - public Dictionary Items = new Dictionary(); + public Dictionary Items = new Dictionary(); private List Palette; public override void Print() @@ -32,28 +32,25 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders PaletteEntries = Reader.ReadInt16(); Logger.Log($"PaletteEntries:{PaletteEntries}"); - Palette = new List();//Color[256]; + Palette = new List(); for (int i = 0; i < 256; i++) { Palette.Add(Reader.ReadColor()); } + var count = Reader.ReadInt32(); Logger.Log($"Number of image items: {count.ToString()}"); - + for (int i = 0; i < count; i++) { - var item = new ImageItem(Reader); item.Debug = true; item.Read(); //item.Save($"{Settings.ImagePath}\\{i}.png"); - Items.Add(item.Handle,item); - + Items.Add(item.Handle, item); } - } - public override void Write(ByteWriter writer) { @@ -65,12 +62,14 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders writer.WriteColor(Palette[i]); } - writer.WriteInt32(0);//(Items.Count); + + writer.WriteInt32(Items.Count); foreach (var key in Items.Keys) { - //Items[key].Write(writer); + Items[key].Write(writer); } } + public AgmiBank(ByteReader reader) : base(reader) { } @@ -79,4 +78,4 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders { } } -} +} \ No newline at end of file