//Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg
        public static void ReadSplash(bool bLogo = false)
        {
            string[] lof = aw.GetListOfFiles();
            string   filename;

            if (splashName > 0x0f)
            {
                return;
            }
            filename = !bLogo
                ? bNames
                    ? lof.First(x => x.ToLower().Contains($"{names}{splashName.ToString("D2")}"))
                    : lof.First(x => x.ToLower().Contains($"{loops}{splashLoop.ToString("D2")}"))
                : lof.First(x => x.ToLower().Contains($"ff8.lzs"));

            byte[] buffer     = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MAIN, filename);
            uint   uncompSize = BitConverter.ToUInt32(buffer, 0);

            buffer = buffer.Skip(4).ToArray(); //hotfix for new LZSS
            buffer = LZSS.DecompressAllNew(buffer);

            if (splashTex != null && !splashTex.IsDisposed)
            {
                splashTex.Dispose();
            }

            splashTex = TIM2.Overture(buffer);
            //using (FileStream fs = File.Create(Path.Combine("D:\\main", Path.GetFileNameWithoutExtension(filename) + ".png")))
            //    splashTex.SaveAsPng(fs, splashTex.Width, splashTex.Height);

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Beispiel #2
0
        private static Data read(string file)
        {
            byte[] decmp;

            using (FileStream fs = File.OpenRead(file))
                using (BinaryReader br = new BinaryReader(fs))
                {
                    uint size = br.ReadUInt32();
                    //uint fsLen = BitConverter.ToUInt32(FI, loc * 12);
                    //uint fSpos = BitConverter.ToUInt32(FI, (loc * 12) + 4);
                    //bool compe = BitConverter.ToUInt32(FI, (loc * 12) + 8) != 0;
                    //fs.Seek(0, SeekOrigin.Begin);
                    byte[] tmp = br.ReadBytes((int)fs.Length - 4);
                    decmp = LZSS.DecompressAllNew(tmp);
                }
            //using (FileStream fs = File.Create(Path.Combine(@"d:\", Path.GetFileName(file))))
            //using (BinaryWriter bw = new BinaryWriter(fs))
            //{
            //    bw.Write(decmp);
            //}
            using (MemoryStream ms = new MemoryStream(decmp))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    ms.Seek(0x184, SeekOrigin.Begin);
                    Data d = new Data();
                    d.Read(br);

                    return(d);
                }
        }
Beispiel #3
0
 public static byte[] GetBinaryFile(string archiveName, string fileName)
 {
     byte[] isComp = GetBin(Extended.GetUnixFullPath(archiveName), fileName);
     if (isComp == null)
     {
         throw new FileNotFoundException($"Searched {archiveName} and could not find {fileName}.", fileName);
     }
     if (_compressed)
     {
         isComp = isComp.Skip(4).ToArray();
     }
     return(isComp == null ? null : _compressed?LZSS.DecompressAllNew(isComp) : isComp);
 }
Beispiel #4
0
        /// <summary>
        /// Give me three archives as bytes uncompressed please!
        /// </summary>
        /// <param name="FI">FileIndex</param>
        /// <param name="FS">FileSystem</param>
        /// <param name="FL">FileList</param>
        /// <param name="filename">Filename of the file to get</param>
        /// <returns></returns>
        public static byte[] FileInTwoArchives(byte[] FI, byte[] FS, byte[] FL, string filename)
        {
            string a = filename.TrimEnd('\0');

            string flText = System.Text.Encoding.UTF8.GetString(FL);

            flText = flText.Replace(Convert.ToString(0x0d), "");
            int loc = -1;

            string[] files = flText.Split((char)0x0a);
            for (int i = 0; i != files.Length; i++) //check archive for filename
            {
                if (string.IsNullOrWhiteSpace(files[i]))
                {
                    Debug.WriteLine("ArchiveWorker::File entry is null. Returning null");
                    return(null);
                }
                string testme = files[i].Substring(0, files[i].Length - 1).ToUpper().TrimEnd('\0');
                if (testme != a.ToUpper())
                {
                    continue;
                }
                loc = i;
                break;
            }
            if (loc == -1)
            {
                Debug.WriteLine("ArchiveWorker: NO SUCH FILE!");
                return(null);
                //throw new Exception("ArchiveWorker: No such file!");
            }


            uint fsLen = BitConverter.ToUInt32(FI, loc * 12);
            uint fSpos = BitConverter.ToUInt32(FI, (loc * 12) + 4);
            bool compe = BitConverter.ToUInt32(FI, (loc * 12) + 8) != 0;

            byte[] file = new byte[fsLen];

            Array.Copy(FS, fSpos, file, 0, file.Length);
            return(compe ? LZSS.DecompressAllNew(file) : file);
        }