static byte[] RLECompression(byte[] indata, string type) { switch (type.ToUpper()) { case "BM5": return(BM5RLE.Compress(indata)); case "SFCW": return(SFCWRLE.Compress(indata)); default: return(BM5RLE.Compress(indata)); } }
static void OutputDecompressedFile(string input, string output, string type, int lztype, int offset, int length) { if (File.Exists(input)) { if (!(output == "")) { byte[] file = File.ReadAllBytes(input); if (lztype > -1) {//then use lunar compress... Console.WriteLine("Commencing decompression with Lunar Compress Type " + lztype.ToString() + "..."); byte[] d1 = LCompress.Decompress(file, offset, 0x10000, (uint)lztype); byte[] d2 = new byte[LCompress.LastDecompressedSize]; Array.Copy(d1, d2, LCompress.LastDecompressedSize); File.WriteAllBytes(output, d2); } else { switch (type.ToLower()) { case "sbm5": Console.WriteLine("Commencing decompression with Super Bomberman 5 RLE Type..."); BM5RLE.Decompress(file, length, output); break; case "sfcw": Console.WriteLine("Commencing decompression with Super Famicom Wars RLE Type..."); byte[] data = SFCWRLE.Decompress(file); File.WriteAllBytes(output, data); break; default: Console.WriteLine("Type argument was invalid. Failed."); break; } } } else { Console.WriteLine("Missing output file argument. Failed."); //message - output file required } } else { Console.WriteLine("Invalid input file argument. Failed."); //message- input file required } }
static void OutputCompressedFile(string input, string output, string type) { if (File.Exists(input)) { if (!(output == "")) { int lztype = -1; try {//if there is no error, then its an LZ type (Lunar) lztype = int.Parse(type); byte[] file = File.ReadAllBytes(input); byte[] outbyte = null; LCompress.Compress(file, out outbyte, LCompress.GetLZType(type)); File.WriteAllBytes(output, outbyte); } catch { switch (type.ToLower()) { case "sbm5": Console.WriteLine("Commencing Compression with Super Bomberman 5 RLE Type..."); BM5RLE.Compress(input, output); break; case "sfcw": Console.WriteLine("Commencing Compression with Super Famicom Wars LZ/RLE Type..."); byte[] data = SFCWRLE.Compress(File.ReadAllBytes(input)); File.WriteAllBytes(output, data); break; default: Console.WriteLine("Type argument was invalid. Failed."); break; } } } else { Console.WriteLine("Missing output file argument. Failed."); //message - output file required } } else { Console.WriteLine("Invalid input file argument. Failed."); //message- input file required } }