示例#1
0
        protected override void Initialize()
        {
            FFmpeg.AutoGen.Example.FFmpegBinariesHelper.RegisterFFmpegBinaries();
            Memory.graphics    = graphics;
            Memory.spriteBatch = spriteBatch;
            Memory.content     = Content;

            init_debugger_Audio.DEBUG();            //this initializes the DirectAudio, it's true that it gets loaded AFTER logo, but we will do the opposite
            init_debugger_Audio.DEBUG_SoundAudio(); //this initalizes the WAVE format audio.dat
            Init_debugger_fields.DEBUG();           //this initializes the field module, it's worth to have this at the beginning
            Init_debugger_battle.DEBUG();           //this initializes the encounters
            Memory.font = new Font();               //this initializes the fonts and drawing system- holds fonts in-memory
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);

            TEX tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                          aw.GetListOfFiles().First(x => x.ToLower().Contains("icon.tex"))));

            Memory.iconsTex = new Texture2D[tex.TextureData.NumOfPalettes];
            for (int i = 0; i < Memory.iconsTex.Length; i++)
            {
                Memory.iconsTex[i] = tex.GetTexture(i);
            }
            Memory.FieldHolder.FieldMemory = new int[1024];

            base.Initialize();
        }
        //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();
        }
示例#3
0
        protected virtual void Init()
        {
            ArchiveWorker aw = new ArchiveWorker(ArchiveString);

            InitEntries(aw);
            InitTextures(aw);
            InsertCustomEntries();
        }
示例#4
0
文件: Font.cs 项目: Albeoris/OpenVIII
        public void LoadFonts()
        {
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
            string        sysfntTdwFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tdw"));
            string        sysfntFilepath    = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tex"));
            TEX           tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath));

            sysfnt    = tex.GetTexture((int)ColorID.White);
            sysfntbig = new TextureHandler("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White);

            ReadTdw(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath));
        }
示例#5
0
 public ArchiveSearch(FF8String searchstring)
 {
     byte[] s = searchstring;
     foreach (string a in ArchiveList)
     {
         ArchiveWorker aw  = new ArchiveWorker(a);
         string[]      lof = aw.GetListOfFiles();
         foreach (string f in lof)
         {
             byte[] bf = aw.GetBinaryFile(f);
             int    i  = 0;
             do
             {
                 i = Array.FindIndex(bf, i, bf.Length - i, x => x == s[0]);
                 if (i >= 0 && bf != null)
                 {
                     var full = bf.Skip(i).Take(s.Length).ToArray();
                     if (full.SequenceEqual(s))
                     {
                         results.Add(new Tuple <string, string, long>(a, f, i));
                     }
                     i++;
                 }
             }while (i > 0);
             //bf = bf.Reverse().ToArray();
             //i = 0;
             //do
             //{
             //    i = Array.FindIndex(bf, i, bf.Length - i, x => x == s[0]);
             //    if (i >= 0 && bf != null)
             //    {
             //        var full = bf.Skip(i).Take(s.Length).ToArray();
             //        if (full.SequenceEqual(s))
             //        {
             //            results.Add(new Tuple<string, string, long>(a, f, i));
             //        }
             //        i++;
             //    }
             //}
             //while (i > 0);
             //string decodedarchive = Memory.DirtyEncoding.GetString(aw.GetBinaryFile(f));
             //Regex r = new Regex(searchstring, RegexOptions.IgnoreCase);
             //Match m = r.Match(f);
             //if(m.Success)
             //{
             //    results.Add(new Tuple<string, string, long>(a, f, m.Index));
             //}
         }
     }
 }
示例#6
0
 public TextureHandler(string filename, uint cols = 1, uint rows = 1, int pallet = -1)
 {
     if (cols == 1 && rows == 1)
     {
         ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
         filename = aw.GetListOfFiles().First(x => x.IndexOf(filename, StringComparison.OrdinalIgnoreCase) >= 0);
         TEX tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, filename));
         Init(filename, tex, cols, rows);
     }
     else
     {
         Init(filename, null, cols, rows);
     }
 }
示例#7
0
        internal void LoadFonts()
        {
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
            string        sysfntTdwFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tdw"));
            string        sysfntFilepath    = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tex"));
            string        sysfnt00Filepath  = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt00.tex"));
            TEX           tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath));

            sysfnt   = tex.GetTexture();
            tex      = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfnt00Filepath));
            sysfnt00 = tex.GetTexture();

            ReadTdw(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath));
        }
 public static void ResetModule()
 {
     internalModule = 0;
     internalTimer  = 0.0f;
     bFadingIn      = true;
     bWaitingSplash = false;
     fSplashWait    = 0.0f;
     bFadingOut     = false;
     Fade           = 0;
     Memory.spriteBatch.GraphicsDevice.Clear(Color.Black);
     Memory.module  = Memory.MODULE_OVERTURE_DEBUG;
     internalModule = OvertureInternalModule._4Squaresoft;
     Module_movie_test.ReturnState = Memory.MODULE_OVERTURE_DEBUG;
     aw = null; // was getting exception when running the overture again as the aw target changed.
 }
示例#9
0
        private static void ReadData()
        {
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_BATTLE);

            string[] test = aw.GetListOfFiles();
            battlename       = test.First(x => x.ToLower().Contains(battlename));
            stageBuffer      = ArchiveWorker.GetBinaryFile(Memory.Archives.A_BATTLE, battlename);
            pbs              = new PseudoBufferedStream(stageBuffer);
            bs_cameraPointer = GetCameraPointer();
            pbs.Seek(bs_cameraPointer, 0);
            ReadCamera();
            uint sectionCounter = pbs.ReadUInt();

            if (sectionCounter != 6)
            {
                Console.WriteLine($"BS_PARSER_PRE_OBJECTSECTION: Main geometry section has no 6 pointers at: {pbs.Tell()}");
                battleModule++;
                return;
            }
            MainGeometrySection MainSection = ReadObjectGroupPointers();

            ObjectsGroup[] objectsGroups = new ObjectsGroup[4]
            {
                ReadObjectsGroup(MainSection.Group1Pointer),
                ReadObjectsGroup(MainSection.Group2Pointer),
                ReadObjectsGroup(MainSection.Group3Pointer),
                ReadObjectsGroup(MainSection.Group4Pointer)
            };

            modelGroups = new ModelGroup[4]
            {
                ReadModelGroup(objectsGroups[0].objectListPointer),
                ReadModelGroup(objectsGroups[1].objectListPointer),
                ReadModelGroup(objectsGroups[2].objectListPointer),
                ReadModelGroup(objectsGroups[3].objectListPointer)
            };

            ReadTexture(MainSection.TexturePointer);

            ReadCharacters();
            ReadMonster();

            //for frames indexes monsters are first, then after n monsters characters appear with weapons
            frame = new int[monstersData.Length + charactersData.Length * 2];

            battleModule++;
        }
示例#10
0
        public static void Init()
        {
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_FIELD);

            string[] lists   = aw.GetListOfFiles();
            string   maplist = lists.First(x => x.ToLower().Contains("mapdata.fs"));

            maplist = maplist.Substring(0, maplist.Length - 3);
            byte[] fs  = ArchiveWorker.GetBinaryFile(Memory.Archives.A_FIELD, $"{maplist}{Memory.Archives.B_FileArchive}");
            byte[] fl  = ArchiveWorker.GetBinaryFile(Memory.Archives.A_FIELD, $"{maplist}{Memory.Archives.B_FileList}");
            byte[] fi  = ArchiveWorker.GetBinaryFile(Memory.Archives.A_FIELD, $"{maplist}{Memory.Archives.B_FileIndex}");
            string map = System.Text.Encoding.UTF8.GetString(fl).TrimEnd();

            string[] maplistb = System.Text.Encoding.UTF8.GetString(
                ArchiveWorker.FileInTwoArchives(fi, fs, fl, map))
                                .Replace("\r", "")
                                .Split('\n');
            Memory.FieldHolder.fields = maplistb;
        }
示例#11
0
        protected virtual void InitEntries(ArchiveWorker aw = null)
        {
            if (Entries == null)
            {
                if (aw == null)
                {
                    aw = new ArchiveWorker(ArchiveString);
                }
                using (MemoryStream ms = new MemoryStream(ArchiveWorker.GetBinaryFile(ArchiveString,
                                                                                      aw.GetListOfFiles().First(x => x.IndexOf(IndexFilename, StringComparison.OrdinalIgnoreCase) >= 0))))
                {
                    ushort[] locs;
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Count   = br.ReadUInt32();
                        locs    = new ushort[Count];//br.ReadUInt32(); 32 valid values in face.sp2 rest is invalid
                        Entries = new Dictionary <uint, Entry>((int)Count);
                        for (uint i = 0; i < Count; i++)
                        {
                            locs[i] = br.ReadUInt16();
                            ms.Seek(2, SeekOrigin.Current);
                        }
                        byte  fid  = 0;
                        Entry Last = null;
                        for (uint i = 0; i < Count; i++)
                        {
                            ms.Seek(locs[i] + 6, SeekOrigin.Begin);
                            byte t = br.ReadByte();
                            if (t == 0 || t == 96) // known invalid entries in sp2 files have this value. there might be more to it.
                            {
                                Count = i;
                                break;
                            }

                            Entries[i] = new Entry();
                            Entries[i].LoadfromStreamSP2(br, locs[i], Last, ref fid);

                            Last = Entries[i];
                        }
                    }
                }
            }
        }
示例#12
0
        protected override void InitTextures(ArchiveWorker aw = null)
        {
            TEX tex;

            tex = new TEX(ArchiveWorker.GetBinaryFile(ArchiveString,
                                                      aw.GetListOfFiles().First(x => x.IndexOf(TextureFilename[0], StringComparison.OrdinalIgnoreCase) >= 0)));
            Textures = new List <TextureHandler>(tex.TextureData.NumOfPalettes);
            for (int i = 0; i < tex.TextureData.NumOfPalettes; i++)
            {
                if (FORCE_ORIGINAL == false && TextureBigFilename != null && TextureBigSplit != null)
                {
                    Textures.Add(new TextureHandler(TextureBigFilename[0], tex, 2, TextureBigSplit[0] / 2, i));
                }
                else
                {
                    Textures.Add(new TextureHandler(TextureFilename[0], tex, 1, 1, i));
                }
            }
        }
示例#13
0
 public Faces()
 {
     if (entries == null)
     {
         ArchiveWorker aw   = new ArchiveWorker(Memory.Archives.A_MENU);
         byte[]        test = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                          aw.GetListOfFiles().First(x => x.ToLower().Contains("face.sp2")));
         using (MemoryStream ms = new MemoryStream(test))
         {
             ushort[] locs;
             using (BinaryReader br = new BinaryReader(ms))
             {
                 ms.Seek(4, SeekOrigin.Begin);
                 locs    = new UInt16[32];//br.ReadUInt32(); 32 valid values in face.sp2 rest is invalid
                 entries = new Entry[locs.Length];
                 for (int i = 0; i < locs.Length; i++)
                 {
                     locs[i] = br.ReadUInt16();
                     ms.Seek(2, SeekOrigin.Current);
                 }
                 byte fid = 0;
                 for (int i = 0; i < locs.Length; i++)
                 {
                     entries[i] = new Entry();
                     fid        = entries[i].LoadfromStreamSP2(br, locs[i], (byte)(i - 1 < 0 ?  0: entries[i - 1].Y), fid);
                 }
             }
         }
         //using (FileStream fs = File.OpenWrite(Path.Combine("d:\\", "face.sp2")))
         //{
         //    fs.Write(test, 0, test.Length);
         //}
         TEX tex;
         tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                   aw.GetListOfFiles().First(x => x.ToLower().Contains("face1.tex"))));
         faces[0] = tex.GetTexture();
         tex      = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                        aw.GetListOfFiles().First(x => x.ToLower().Contains("face2.tex"))));
         faces[1] = tex.GetTexture();
     }
 }
示例#14
0
        protected virtual void InitTextures(ArchiveWorker aw = null)
        {
            if (Textures == null)
            {
                Textures = new List <TextureHandler>(TextureCount.Sum());
            }
            if (Textures.Count <= 0)
            {
                if (aw == null)
                {
                    aw = new ArchiveWorker(ArchiveString);
                }
                TEX tex;
                Scale = new Dictionary <uint, Vector2>(TextureCount.Sum());
                int b = 0;
                for (int j = 0; j < TextureCount.Length; j++)
                {
                    for (uint i = 0; i < TextureCount[j]; i++)
                    {
                        string path = aw.GetListOfFiles().First(x => x.ToLower().Contains(string.Format(TextureFilename[j], i + TextureStartOffset)));
                        tex = new TEX(ArchiveWorker.GetBinaryFile(ArchiveString, path));
                        if (TextureBigFilename != null && FORCE_ORIGINAL == false && b < TextureBigFilename.Length && b < TextureBigSplit.Length)
                        {
                            TextureHandler th = new TextureHandler(TextureBigFilename[b], tex, 2, TextureBigSplit[b++] / 2);

                            Textures.Add(th);
                            Scale[i] = Vector2.One;//th.GetScale();
                        }
                        else
                        {
                            TextureHandler th = new TextureHandler(path, tex);
                            Textures.Add(th);
                            Scale[i] = th.GetScale();
                        }
                    }
                }
            }
        }
示例#15
0
 protected override void InitEntries(ArchiveWorker aw = null)
 {
     if (Entries == null)
     {
         //read from icon.sp1
         using (MemoryStream ms = new MemoryStream(ArchiveWorker.GetBinaryFile(ArchiveString,
                                                                               aw.GetListOfFiles().First(x => x.IndexOf(IndexFilename, StringComparison.OrdinalIgnoreCase) >= 0))))
         {
             using (BinaryReader br = new BinaryReader(ms))
             {
                 Loc[] locs = new Loc[br.ReadUInt32()];
                 for (int i = 0; i < locs.Length; i++)
                 {
                     locs[i].seek   = br.ReadUInt16();
                     locs[i].length = br.ReadUInt16();
                 }
                 Entries = new Dictionary <ID, EntryGroup>(locs.Length + 10);
                 for (int i = 0; i < locs.Length; i++)
                 {
                     ms.Seek(locs[i].seek, SeekOrigin.Begin);
                     byte c = (byte)locs[i].length;
                     Entries[(ID)i] = new EntryGroup(c);
                     for (int e = 0; e < c; e++)
                     {
                         Entry tmp = new Entry();
                         tmp.LoadfromStreamSP1(br);
                         tmp.Part = (byte)e;
                         tmp.SetLoc(locs[i]);
                         Entries[(ID)i].Add(tmp);
                     }
                 }
             }
             //custom stuff not in sp1
             InsertCustomEntries();
         }
     }
 }
示例#16
0
        private static void Init()
        {
            ArchiveWorker aw = new ArchiveWorker($"{Memory.Archives.A_FIELD}.fs");

            string[] test = aw.GetListOfFiles();
            if (Memory.FieldHolder.FieldID >= Memory.FieldHolder.fields.Length ||
                Memory.FieldHolder.FieldID < 0)
            {
                return;
            }
            var CollectionEntry = test.Where(x => x.ToLower().Contains(Memory.FieldHolder.fields[Memory.FieldHolder.FieldID]));

            if (!CollectionEntry.Any())
            {
                return;
            }
            string fieldArchive = CollectionEntry.First();
            int    fieldLen     = fieldArchive.Length - 2;

            fieldArchive = fieldArchive.Substring(0, fieldLen);
            byte[] fs = ArchiveWorker.GetBinaryFile(Memory.Archives.A_FIELD, $"{fieldArchive}fs");
            byte[] fi = ArchiveWorker.GetBinaryFile(Memory.Archives.A_FIELD, $"{fieldArchive}fi");
            byte[] fl = ArchiveWorker.GetBinaryFile(Memory.Archives.A_FIELD, $"{fieldArchive}fl");
            if (fs == null || fi == null || fl == null)
            {
                return;
            }
            string[] test_ = ArchiveWorker.GetBinaryFileList(fl);
            string   mim   = null;
            string   map   = null;

            try
            {
                mim = test_.First(x => x.ToLower().Contains(".mim"));
            }
            catch {}
            try
            {
                map = test_.First(x => x.ToLower().Contains(".map"));
            }
            catch {}

            if (mim != null && map != null)
            {
                byte[] mimb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, mim);
                byte[] mapb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, map);

                ParseBackground(mimb, mapb);
            }

#if DEBUG
            if (Memory.FieldHolder.FieldID == 180)
            {
                goto safeDebugpoint;                                    //delete me
            }
#endif
            //let's start with scripts
            byte[] jsm   = null;
            byte[] sy    = null;
            string s_jsm = null;
            string s_sy  = null;
            try
            {
                s_jsm = test_.First(x => x.ToLower().Contains(".jsm"));
            }
            catch { }
            try
            {
                s_sy = test_.First(x => x.ToLower().Contains(".sy"));
            }
            catch { }
            if (s_jsm != null && s_sy != null)
            {
                jsm = ArchiveWorker.FileInTwoArchives(fi, fs, fl, s_jsm);
                sy  = ArchiveWorker.FileInTwoArchives(fi, fs, fl, s_sy);

                ParseScripts(jsm, sy);
            }
            Stack = new List <int>();
#if DEBUG
            OutputAllParsedScripts();
#endif

            //string mch = test_.Where(x => x.ToLower().Contains(".mch")).First();
            //string one = test_.Where(x => x.ToLower().Contains(".one")).First();
            //string msd = test_.Where(x => x.ToLower().Contains(".msd")).First();
            //string inf = test_.Where(x => x.ToLower().Contains(".inf")).First();
            //string id = test_.Where(x => x.ToLower().Contains(".id")).First();
            //string ca = test_.Where(x => x.ToLower().Contains(".ca")).First();
            //string tdw = test_.Where(x => x.ToLower().Contains(".tdw")).First();
            //string msk = test_.Where(x => x.ToLower().Contains(".msk")).First();
            //string rat = test_.Where(x => x.ToLower().Contains(".rat")).First();
            //string pmd = test_.Where(x => x.ToLower().Contains(".pmd")).First();
            //string sfx = test_.Where(x => x.ToLower().Contains(".sfx")).First();

            //byte[] mchb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, mch); //Field character models
            //byte[] oneb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, one); //Field character models container
            //byte[] msdb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, msd); //dialogs
            //byte[] infb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, inf); //gateways
            //byte[] idb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, id); //walkmesh
            //byte[] cab = ArchiveWorker.FileInTwoArchives(fi, fs, fl, ca); //camera
            //byte[] tdwb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, tdw); //extra font
            //byte[] mskb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, msk); //movie cam
            //byte[] ratb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, rat); //battle on field
            //byte[] pmdb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, pmd); //particle info
            //byte[] sfxb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, sfx); //sound effects



safeDebugpoint:
            mod++;
            return;
        }
示例#17
0
        public static Dictionary <Abilities, Equipable_Ability> EquipableAbilities; // contains 4 types;

        /// <summary>
        /// Read binary data from into structures and arrays
        /// </summary>
        /// <see cref="http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain/wiki/Kernel.bin"/>
        public Kernel_bin()
        {
            aw = new ArchiveWorker(ArchiveString);
            byte[]     buffer       = aw.GetBinaryFile(Memory.Strings.Filenames[(int)Strings.FileID.KERNEL]);
            List <Loc> subPositions = Memory.Strings.Files[Strings.FileID.KERNEL].subPositions;

            using (MemoryStream ms = new MemoryStream(buffer))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    BattleCommands = Battle_Commands.Read(br);
                    ms.Seek(subPositions[Magic_Data.id], SeekOrigin.Begin);
                    MagicData = Magic_Data.Read(br);
                    ms.Seek(subPositions[Junctionable_GFs_Data.id], SeekOrigin.Begin);
                    JunctionableGFsData = Junctionable_GFs_Data.Read(br);
                    ms.Seek(subPositions[Enemy_Attacks_Data.id], SeekOrigin.Begin);
                    EnemyAttacksData = Enemy_Attacks_Data.Read(br);
                    ms.Seek(subPositions[Weapons_Data.id], SeekOrigin.Begin);
                    WeaponsData = Weapons_Data.Read(br);
                    ms.Seek(subPositions[Renzokuken_Finishers_Data.id], SeekOrigin.Begin);
                    RenzokukenFinishersData = Renzokuken_Finishers_Data.Read(br);
                    ms.Seek(subPositions[Character_Stats.id], SeekOrigin.Begin);
                    CharacterStats = Character_Stats.Read(br);
                    ms.Seek(subPositions[Battle_Items_Data.id], SeekOrigin.Begin);
                    BattleItemsData    = Battle_Items_Data.Read(br);
                    NonbattleItemsData = Non_battle_Items_Data.Read();
                    ms.Seek(subPositions[Non_Junctionable_GFs_Attacks_Data.id], SeekOrigin.Begin);
                    NonJunctionableGFsAttacksData = Non_Junctionable_GFs_Attacks_Data.Read(br);
                    ms.Seek(subPositions[Command_ability_data.id], SeekOrigin.Begin);
                    Commandabilitydata = Command_ability_data.Read(br);
                    ms.Seek(subPositions[Junction_abilities.id], SeekOrigin.Begin);
                    Junctionabilities = Junction_abilities.Read(br);
                    ms.Seek(subPositions[Command_abilities.id], SeekOrigin.Begin);
                    Commandabilities = Command_abilities.Read(br);
                    ms.Seek(subPositions[Stat_percent_abilities.id], SeekOrigin.Begin);
                    Statpercentabilities = Stat_percent_abilities.Read(br);
                    ms.Seek(subPositions[Character_abilities.id], SeekOrigin.Begin);
                    Characterabilities = Character_abilities.Read(br);
                    ms.Seek(subPositions[Party_abilities.id], SeekOrigin.Begin);
                    Partyabilities = Party_abilities.Read(br);
                    ms.Seek(subPositions[GF_abilities.id], SeekOrigin.Begin);
                    GFabilities = GF_abilities.Read(br);
                    ms.Seek(subPositions[Menu_abilities.id], SeekOrigin.Begin);
                    Menuabilities = Menu_abilities.Read(br);
                    ms.Seek(subPositions[Temporary_character_limit_breaks.id], SeekOrigin.Begin);
                    Temporarycharacterlimitbreaks = Temporary_character_limit_breaks.Read(br);
                    ms.Seek(subPositions[Blue_magic_Quistis_limit_break.id], SeekOrigin.Begin);
                    BluemagicQuistislimitbreak = Blue_magic_Quistis_limit_break.Read(br);
                    //ms.Seek(subPositions[Quistis_limit_break_parameters.id], SeekOrigin.Begin);
                    //Quistislimitbreakparameters = Quistis_limit_break_parameters.Read(br);
                    ms.Seek(subPositions[Shot_Irvine_limit_break.id], SeekOrigin.Begin);
                    ShotIrvinelimitbreak = Shot_Irvine_limit_break.Read(br);
                    ms.Seek(subPositions[Duel_Zell_limit_break.id], SeekOrigin.Begin);
                    DuelZelllimitbreak = Duel_Zell_limit_break.Read(br);
                    ms.Seek(subPositions[Zell_limit_break_parameters.id], SeekOrigin.Begin);
                    Zelllimitbreakparameters = Zell_limit_break_parameters.Read(br);
                    ms.Seek(subPositions[Rinoa_limit_breaks_part_1.id], SeekOrigin.Begin);
                    Rinoalimitbreakspart1 = Rinoa_limit_breaks_part_1.Read(br);
                    ms.Seek(subPositions[Rinoa_limit_breaks_part_2.id], SeekOrigin.Begin);
                    Rinoalimitbreakspart2 = Rinoa_limit_breaks_part_2.Read(br);
                    ms.Seek(subPositions[Slot_array.id], SeekOrigin.Begin);
                    Slotarray = Slot_array.Read(br);
                    ms.Seek(subPositions[Selphie_limit_break_sets.id], SeekOrigin.Begin);
                    Selphielimitbreaksets = Selphie_limit_break_sets.Read(br);
                    ms.Seek(subPositions[Devour.id], SeekOrigin.Begin);
                    Devour_ = Devour.Read(br);
                    ms.Seek(subPositions[Misc_section.id], SeekOrigin.Begin);
                    Miscsection      = Misc_section.Read(br);
                    Misctextpointers = Misc_text_pointers.Read();

                    EquipableAbilities = new Dictionary <Abilities, Equipable_Ability>(
                        Stat_percent_abilities.count +
                        Character_abilities.count +
                        Party_abilities.count +
                        GF_abilities.count);
                    foreach (Abilities ability in (Abilities[])Enum.GetValues(typeof(Abilities)))
                    {
                        if (Statpercentabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Statpercentabilities[ability];
                        }
                        else if (Characterabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Characterabilities[ability];
                        }
                        else if (Partyabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Partyabilities[ability];
                        }
                        else if (Characterabilities.ContainsKey(ability))
                        {
                            EquipableAbilities[ability] = Characterabilities[ability];
                        }
                    }
                }
        }
示例#18
0
        public Icons()
        {
            if (entries == null)
            {
                ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
                TEX           tex;
                byte[]        test = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                                 aw.GetListOfFiles().First(x => x.ToLower().Contains("icon.tex")));

                tex         = new TEX(test);
                PalletCount = tex.TextureData.NumOfPalettes;
                icons       = new Texture2D[PalletCount];
                for (int i = 0; i < PalletCount; i++)
                {
                    icons[i] = tex.GetTexture(i);
                    //using (FileStream fs = File.OpenWrite($"d:\\icons.{i}.png"))
                    //{
                    //    //fs.Write(test, 0, test.Length);

                    //    icons[i].SaveAsPng(fs, 256, 256);
                    //}
                }
                test = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                   aw.GetListOfFiles().First(x => x.ToLower().Contains("icon.sp1")));
                //using (FileStream fs = File.OpenWrite(Path.Combine("d:\\", "icons.sp1")))
                //{
                //    fs.Write(test, 0, test.Length);
                //}
                //read from icon.sp1
                using (MemoryStream ms = new MemoryStream(test))
                {
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Count = br.ReadUInt32();
                        Loc[] locs = new Loc[Count];
                        for (int i = 0; i < Count; i++)
                        {
                            locs[i].pos   = br.ReadUInt16();
                            locs[i].count = br.ReadUInt16();
                            //if (locs[i].count > 1) Count += (uint)(locs[i].count - 1);
                        }
                        entries = new Dictionary <ID, EntryGroup>((int)Count + 10);
                        for (int i = 0; i < Count; i++)
                        {
                            ms.Seek(locs[i].pos, SeekOrigin.Begin);
                            byte c = (byte)locs[i].count;
                            entries[(ID)i] = new EntryGroup(c);
                            for (int e = 0; e < c; e++)
                            {
                                Entry tmp = new Entry();
                                tmp.LoadfromStreamSP1(br);
                                tmp.Part = (byte)e;
                                tmp.SetLoc(locs[i]);
                                entries[(ID)i].Add(tmp);
                            }
                        }
                    }
                    //custom stuff not in sp1
                    Entry BG = new Entry
                    {
                        X            = 0,
                        Y            = 48,
                        Width        = 256,
                        Height       = 16,
                        CustomPallet = 1,
                        Tile         = Vector2.UnitY,
                    };
                    Entry Border_TopLeft = new Entry
                    {
                        X            = 16,
                        Y            = 0,
                        Width        = 8,
                        Height       = 8,
                        CustomPallet = 0,
                    };
                    Entry Border_Top = new Entry
                    {
                        X            = 24,
                        Y            = 0,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        Offset_X     = 8,
                        Offset_X2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_Bottom = new Entry
                    {
                        X            = 24,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        Snap_Bottom  = true,
                        Offset_Y     = -8,
                        Offset_X     = 8,
                        Offset_X2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_TopRight = new Entry
                    {
                        X            = 32,
                        Y            = 0,
                        Width        = 8,
                        Height       = 8,
                        Snap_Right   = true,
                        Offset_X     = -8,
                        CustomPallet = 0
                    };
                    Entry Border_Left = new Entry
                    {
                        X            = 16,
                        Y            = 8,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitY,
                        Offset_Y     = 8,
                        Offset_Y2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_Right = new Entry
                    {
                        X            = 32,
                        Y            = 8,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitY,
                        Snap_Right   = true,
                        Offset_X     = -8,
                        Offset_Y     = 8,
                        Offset_Y2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_BottomLeft = new Entry
                    {
                        X            = 16,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Snap_Bottom  = true,
                        Offset_Y     = -8,
                        CustomPallet = 0
                    };
                    Entry Border_BottomRight = new Entry
                    {
                        X            = 32,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Snap_Bottom  = true,
                        Snap_Right   = true,
                        Offset_X     = -8,
                        Offset_Y     = -8,
                        CustomPallet = 0
                    };

                    entries[ID.Bar_BG] = new EntryGroup(new Entry
                    {
                        X            = 16,
                        Y            = 24,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        CustomPallet = 0
                    });
                    entries[ID.Bar_Fill] = new EntryGroup(new Entry
                    {
                        X            = 0,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        Offset_Y     = 1,
                        CustomPallet = 5
                    });
                    entries[ID.Menu_BG_256] = new EntryGroup(BG, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
                    entries[ID.Menu_BG_368] = new EntryGroup(BG, new Entry
                    {
                        X            = 0,
                        Y            = 64,
                        Offset_X     = 256,
                        Width        = 112,
                        Height       = 16,
                        CustomPallet = 1,
                        Tile         = Vector2.UnitY
                    }, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
                    Count = (uint)entries.Count;

                    entries[ID.DEBUG] = new EntryGroup(
                        new Entry {
                        X = 128, Y = 24, Width = 7, Height = 8
                    },
                        new Entry {
                        X = 65, Y = 8, Width = 6, Height = 8, Offset_X = 7
                    },
                        new Entry {
                        X = 147, Y = 24, Width = 6, Height = 8, Offset_X = 13
                    },
                        new Entry {
                        X = 141, Y = 24, Width = 6, Height = 8, Offset_X = 19
                    },
                        new Entry {
                        X = 104, Y = 16, Width = 6, Height = 8, Offset_X = 25
                    }
                        );
                }
            }
        }
示例#19
0
        //Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg
        internal static void ReadSplash(bool bLogo = false)
        {
            if (!bLogo)
            {
                if (splashName > 0x0f)
                {
                    return;
                }

                string[] lof      = aw.GetListOfFiles();
                string   fileName = bNames
                    ? lof.First(x => x.ToLower().Contains($"{names}{splashName.ToString("D2")}"))
                    : lof.First(x => x.ToLower().Contains($"{loops}{splashLoop.ToString("D2")}"));
                byte[] buffer     = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MAIN, fileName);
                uint   uncompSize = BitConverter.ToUInt32(buffer, 0);
                buffer = LZSS.DecompressAll(buffer, (uint)buffer.Length);

                if (splashTex != null && !splashTex.IsDisposed)
                {
                    splashTex.Dispose();
                }
                splashTex = new Texture2D(Memory.graphics.GraphicsDevice, 640, 400, false, SurfaceFormat.Color);
                byte[] rgbBuffer        = new byte[splashTex.Width * splashTex.Height * 4];
                int    innerBufferIndex = 0;
                for (int i = 0; i < rgbBuffer.Length; i += 4)
                {
                    if (innerBufferIndex + 1 >= buffer.Length)
                    {
                        break;
                    }

                    ushort pixel = (ushort)((buffer[innerBufferIndex + 1] << 8) | buffer[innerBufferIndex]);
                    byte   red   = (byte)((pixel) & 0x1F);
                    byte   green = (byte)((pixel >> 5) & 0x1F);
                    byte   blue  = (byte)((pixel >> 10) & 0x1F);
                    red               = (byte)MathHelper.Clamp((red * 8), 0, 255);
                    green             = (byte)MathHelper.Clamp((green * 8), 0, 255);
                    blue              = (byte)MathHelper.Clamp((blue * 8), 0, 255);
                    rgbBuffer[i]      = red;
                    rgbBuffer[i + 1]  = green;
                    rgbBuffer[i + 2]  = blue;
                    rgbBuffer[i + 3]  = 255;//(byte)(((pixel >> 7) & 0x1) == 1 ? 255 : 0);
                    innerBufferIndex += 2;
                }
                splashTex.SetData(rgbBuffer);
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            else
            {
                string[] lof      = aw.GetListOfFiles();
                string   fileName = lof.First(x => x.ToLower().Contains($"ff8.lzs"));

                byte[] buffer     = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MAIN, fileName);
                uint   uncompSize = BitConverter.ToUInt32(buffer, 0);
                buffer = LZSS.DecompressAll(buffer, (uint)buffer.Length);
                if (splashTex != null && !splashTex.IsDisposed)
                {
                    splashTex.Dispose();
                }
                splashTex = new Texture2D(Memory.graphics.GraphicsDevice, 640, 400, false, SurfaceFormat.Color);
                byte[] rgbBuffer        = new byte[splashTex.Width * splashTex.Height * 4];
                int    innerBufferIndex = 0;
                for (int i = 0; i < rgbBuffer.Length; i += 4)
                {
                    if (innerBufferIndex + 1 >= buffer.Length)
                    {
                        break;
                    }

                    ushort pixel = (ushort)((buffer[innerBufferIndex + 1] << 8) | buffer[innerBufferIndex]);
                    byte   red   = (byte)((pixel) & 0x1F);
                    byte   green = (byte)((pixel >> 5) & 0x1F);
                    byte   blue  = (byte)((pixel >> 10) & 0x1F);
                    red               = (byte)MathHelper.Clamp((red * 8), 0, 255);
                    green             = (byte)MathHelper.Clamp((green * 8), 0, 255);
                    blue              = (byte)MathHelper.Clamp((blue * 8), 0, 255);
                    rgbBuffer[i]      = red;
                    rgbBuffer[i + 1]  = green;
                    rgbBuffer[i + 2]  = blue;
                    rgbBuffer[i + 3]  = 255;//(byte)(((pixel >> 7) & 0x1) == 1 ? 255 : 0);
                    innerBufferIndex += 2;
                }
                splashTex.SetData(rgbBuffer);
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
示例#20
0
 /// <summary>
 /// not used in magzine there is no sp2 file.
 /// </summary>
 /// <param name="aw"></param>
 protected override void InitEntries(ArchiveWorker aw = null)
 {
 }
示例#21
0
        internal static void SplashUpdate(ref int _splashIndex)
        {
            if (aw == null)
            {
                aw = new ArchiveWorker(Memory.Archives.A_MAIN);
            }

            if (splashTex == null)
            {
                ReadSplash();
            }

            if (bFadingIn)
            {
                Fade += Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f * 2f;
                if (Fade > 1.0f)
                {
                    Fade           = 1.0f;
                    bFadingIn      = false;
                    bWaitingSplash = true;
                }
            }
            if (bFadingOut)
            {
                if (splashLoop + 1 >= 0x0F && splashName >= 0x0F)
                {
                    bFadingIn      = false;
                    bFadingOut     = true;
                    bWaitingSplash = false;
                    internalTimer  = 0.0f;
                    Fade           = 1.0f;
                    internalModule++;
                    return;
                }
                Fade -= Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f * 2f;
                if (Fade < 0.0f)
                {
                    bFadingIn  = true;
                    bFadingOut = false;
                    Fade       = 0.0f;
                    _splashIndex++;
                    if (bNames)
                    {
                        splashName++;
                    }
                    else
                    {
                        splashLoop++;
                    }

                    if (_splashIndex > 1)
                    {
                        bNames       = !bNames;
                        _splashIndex = 0;
                    }

                    ReadSplash();
                }
            }
            if (bWaitingSplash)
            {
                if (bNames)
                {
                    if (fSplashWait > 4.8f)
                    {
                        bWaitingSplash = false;
                        bFadingOut     = true;
                        fSplashWait    = 0.0f;
                    }
                }
                else
                {
                    if (fSplashWait > 6.5f)
                    {
                        bWaitingSplash = false;
                        bFadingOut     = true;
                        fSplashWait    = 0.0f;
                    }
                }
                Memory.SuppressDraw = true;
                fSplashWait        += Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
            }
            //loop 01-14 + name01-14;
        }