예제 #1
0
 public static void DumpTexture(Texture2D tex, string s)
 {
     if (Directory.Exists(Path.GetDirectoryName(s)))
     {
         Extended.Save_As_PNG(tex, s, tex.Width, tex.Height);
     }
 }
예제 #2
0
 public static int setEstharZones(int i)
 {
     if (true) // esthar replace flag
     {
         if (Extended.In(i, 373, 380))
         {
             return(i + 395);
         }
         if (Extended.In(i, 405, 412))
         {
             return(i + 371);
         }
         if (Extended.In(i, 437, 444))
         {
             return(i + 347);
         }
         if (Extended.In(i, 469, 476))
         {
             return(i + 323);
         }
         if (Extended.In(i, 501, 508))
         {
             return(i + 299);
         }
         if (Extended.In(i, 533, 540))
         {
             return(i + 275);
         }
         if (Extended.In(i, 565, 572))
         {
             return(i + 251);
         }
     }
     return(i); //compiler sake
 }
예제 #3
0
        /// <summary>
        /// Skeleton data section
        /// </summary>
        /// <param name="v"></param>
        /// <param name="ms"></param>
        /// <param name="br"></param>
        private void ReadSection1(uint v, BinaryReader br, string fileName)
        {
            br.BaseStream.Seek(v, SeekOrigin.Begin);
#if _WINDOWS //looks like Linux Mono doesn't like marshalling structure with LPArray to Bone[]
            skeleton = Extended.ByteArrayToStructure <Skeleton>(br.ReadBytes(16));
#else
            skeleton = new Skeleton()
            {
                cBones = br.ReadUInt16(),
                scale  = br.ReadUInt16(),
                unk2   = br.ReadUInt16(),
                unk3   = br.ReadUInt16(),
                unk4   = br.ReadUInt16(),
                unk5   = br.ReadUInt16(),
                unk6   = br.ReadUInt16(),
                unk7   = br.ReadUInt16()
            };
#endif
            skeleton.bones = new Bone[skeleton.cBones];
            for (int i = 0; i < skeleton.cBones; i++)
            {
                skeleton.bones[i] = Extended.ByteArrayToStructure <Bone>(br.ReadBytes(48));
            }
            //string debugBuffer = string.Empty;
            //for (int i = 0; i< skeleton.cBones; i++)
            //    debugBuffer += $"{i}|{skeleton.bones[i].parentId}|{skeleton.bones[i].boneSize}|{skeleton.bones[i].Size}\n";
            //Console.WriteLine(debugBuffer);
            return;
        }
예제 #4
0
 private FI GetFi(int loc)
 {
     using (var br = new BinaryReader(new FileStream(Archive.FI, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))//File.OpenRead(archive.FI)))
     {
         br.BaseStream.Seek(loc * 12, SeekOrigin.Begin);
         return(Extended.ByteArrayToClass <FI>(br.ReadBytes(12)));
     }
 }
예제 #5
0
 public override void SaveCLUT(string path)
 {
     using (var clut = new Texture2D(Memory.Graphics.GraphicsDevice, _texture.NumOfColors, _texture.NumOfCluts))
     {
         for (ushort i = 0; i < _texture.NumOfCluts; i++)
         {
             clut.SetData(0, new Rectangle(0, i, _texture.NumOfColors, 1), GetClutColors(i), 0, _texture.NumOfColors);
         }
         Extended.Save_As_PNG(clut, path, _texture.NumOfColors, _texture.NumOfCluts);
     }
 }
예제 #6
0
        /*
         *      public static Matrix CreateConstrainedBillboard(Vector3 pos, Vector3 rotateAxis) => Matrix.CreateConstrainedBillboard(pos, CenterOfScreen, rotateAxis, null, null);
         */

        public static void Draw()
        {
            Memory.SpriteBatch.GraphicsDevice.Clear(Color.Black);
            switch (BattleModule)
            {
            case BattleModule.DrawGeometry:
                //DrawGeometry();
                DrawMonsters();
                DrawCharactersWeapons();
                _regularPyramid.Draw(WorldMatrix, ViewMatrix, ProjectionMatrix);
                Stage?.Draw();
                var v = GetIndicatorPoint(-1);
                v.Y -= 5f;
                if (!_bUseFPSCamera)
                {
                    Menu.BattleMenus.Draw();
                }
                break;

            case BattleModule.Active:
                break;

            case BattleModule.Init:
                break;

            case BattleModule.ReadData:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (Memory.GameTime != null)
            {
                Memory.ImGui.BeforeLayout(Memory.GameTime);
            }
            ImGui.Begin("BATTLE DEBUG INFO");
            ImGui.Text($"Encounter ready at: {Memory.Encounters.ID} - {Memory.Encounters.Filename}");
            ImGui.Text($"Debug variable: {DebugFrame} ({DebugFrame >> 4},{DebugFrame & 0b1111})\n");
            ImGui.Text($"1000/deltaTime milliseconds: {(Memory.ElapsedGameTime.TotalSeconds > 0 ? 1d / Memory.ElapsedGameTime.TotalSeconds : 0d)}\n");
            ImGui.Text($"Average FrameRate: {FPSCounter.AverageFramesPerSecond}\n");
            ImGui.Text($"camera frame: {Camera.Cam.CurrentTime}/{Camera.Cam.TotalTime}\n");
            ImGui.Text($"Camera.World.Position: {Extended.RemoveBrackets(_camPosition.ToString())}\n");
            ImGui.Text($"Camera.World.Target: {Extended.RemoveBrackets(_camTarget.ToString())}\n");
            ImGui.Text($"Camera.FOV: {MathHelper.Lerp(Camera.Cam.StartingFov, Camera.Cam.EndingFov, Camera.Cam.CurrentTime.Ticks / (float)Camera.Cam.TotalTime.Ticks)}\n");
            ImGui.Text($"Camera.Mode: {Camera.Cam.ControlWord & 1}\n");
            ImGui.Text($"DEBUG: Press 0 to switch between FPSCamera/Camera anim: {_bUseFPSCamera}\n");
            ImGui.Text($"Sequence ID: {_sid}, press F10 to activate sequence, F11 SID--, F12 SID++");
            ImGui.End();
            Memory.ImGui.AfterLayout();
        }
예제 #7
0
        public static void Init(GraphicsDeviceManager graphics, SpriteBatch spriteBatch, ContentManager content)
        {
            if (Log == null)
            {
                Log = new Log();
            }
            Log.WriteLine($"{nameof(Memory)} :: {nameof(Init)}");
            Log.WriteLine($"{nameof(GraphicsDeviceManager)} :: {graphics}");
            Log.WriteLine($"{nameof(GraphicsDeviceManager)} :: {nameof(graphics.GraphicsDevice.Adapter.CurrentDisplayMode)} :: {graphics?.GraphicsDevice.Adapter.CurrentDisplayMode}");
            if (graphics != null)
            {
                foreach (DisplayMode i in graphics.GraphicsDevice.Adapter.SupportedDisplayModes)
                {
                    Log.WriteLine($"{nameof(GraphicsDeviceManager)} :: {nameof(graphics.GraphicsDevice.Adapter.SupportedDisplayModes)} :: {i}");
                }
            }
            //Log.WriteLine($"{nameof(GraphicsDeviceManager)} :: {graphics.GraphicsDevice.Adapter.DeviceName}");
            //Log.WriteLine($"{nameof(SpriteBatch)} :: {spriteBatch}");
            Log.WriteLine($"{nameof(ContentManager)} :: {content}");

            Memory.Log.WriteLine($"{nameof(Random)} :: new");
            Random = new Random((int)DateTime.Now.Ticks);
            Memory.Log.WriteLine($"{nameof(Memory)} :: {nameof(mainThreadID)} = {nameof(Thread)} :: {nameof(Thread.CurrentThread)} :: {nameof(Thread.ManagedThreadId)} = {Thread.CurrentThread.ManagedThreadId}");
            mainThreadID = Thread.CurrentThread.ManagedThreadId;
            Memory.Log.WriteLine($"{nameof(Memory)} :: {nameof(MainThreadOnlyActions)}");
            MainThreadOnlyActions = new ConcurrentQueue <Action>();

            FF8DIR = GameLocation.Current.DataPath;
            Memory.Log.WriteLine($"{nameof(Memory)} :: {nameof(FF8DIR)} = {FF8DIR}");
            FF8DIRdata = Extended.GetUnixFullPath(Path.Combine(FF8DIR, "Data"));
            Memory.Log.WriteLine($"{nameof(Memory)} :: {nameof(FF8DIRdata)} = {FF8DIRdata}");
            string testdir = Extended.GetUnixFullPath(Path.Combine(FF8DIRdata, $"lang-{Extended.GetLanguageShort()}"));

            Memory.Log.WriteLine($"{nameof(Extended)} :: {nameof(Extended.GetLanguageShort)} = {Extended.GetLanguageShort()}");
            FF8DIRdata_lang = Directory.Exists(testdir) ? testdir : FF8DIRdata;
            Memory.Log.WriteLine($"{nameof(Memory)} :: {nameof(FF8DIRdata_lang)} = {FF8DIRdata_lang}");

            Memory.graphics                = graphics;
            Memory.spriteBatch             = spriteBatch;
            Memory.content                 = content;
            Memory.FieldHolder.FieldMemory = new int[1024];

            FF8StringReference.Init();
            TokenSource = new CancellationTokenSource();
            Token       = TokenSource.Token;
            InitTask    = new Task <int>(InitTaskMethod, Token);
            InitTask.Start();
        }
예제 #8
0
 public override void SaveCLUT(string path)
 {
     if (!CLP)
     {
         return;
     }
     using (var br = new BinaryReader(new MemoryStream(Buffer)))
         using (var clut = new Texture2D(Memory.Graphics.GraphicsDevice, Texture.NumOfColors, Texture.NumOfCluts))
         {
             for (ushort i = 0; i < Texture.NumOfCluts; i++)
             {
                 clut.SetData(0, new Rectangle(0, i, Texture.NumOfColors, 1), GetClutColors(br, i), 0, Texture.NumOfColors);
             }
             Extended.Save_As_PNG(clut, path, Texture.NumOfColors, Texture.NumOfCluts);
         }
 }
예제 #9
0
        private void ReadSkeleton()
        {
            ms.Seek(pBase + pBones, SeekOrigin.Begin);

            if (ms.Position > ms.Length)
            {
                return; //error handler
            }
            bones = new Bone[cSkeletonBones];
            for (int i = 0; i < cSkeletonBones; i++)
            {
                bones[i] = Extended.ByteArrayToStructure <Bone>(br.ReadBytes(64));
            }

            return;
        }
예제 #10
0
        protected override void Draw(GameTime gameTime)
        {
            ModuleHandler.Draw(gameTime);
            base.Draw(gameTime);
            if (!Extended.bRequestedBackBuffer)
            {
                return;
            }
            var tex = new Texture2D(_graphics.GraphicsDevice, _graphics.GraphicsDevice.Viewport.Width, _graphics.GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color);
            var b   = new byte[tex.Width * tex.Height * 4];

            _graphics.GraphicsDevice.GetBackBufferData(b);
            tex.SetData(b);
            Extended.BackBufferTexture    = tex;
            Extended.bRequestedBackBuffer = false;
            Extended.bBackBufferAvailable = true;
            Extended.postBackBufferDelegate();
        }
예제 #11
0
        public static void Init(GraphicsDeviceManager graphics, SpriteBatch spriteBatch, ContentManager content)
        {
            FF8DIR     = GameLocation.Current.DataPath;
            FF8DIRdata = Extended.GetUnixFullPath(Path.Combine(FF8DIR, "Data"));
            string testdir = Extended.GetUnixFullPath(Path.Combine(FF8DIRdata, $"lang-{Extended.GetLanguageShort()}"));

            FF8DIRdata_lang = Directory.Exists(testdir) ? testdir : FF8DIRdata;

            Memory.graphics                = graphics;
            Memory.spriteBatch             = spriteBatch;
            Memory.content                 = content;
            Memory.FieldHolder.FieldMemory = new int[1024];

            FF8StringReference.Init();
            TokenSource = new CancellationTokenSource();
            Token       = TokenSource.Token;
            InitTask    = new Task <int>(InitTaskMethod, Token);
            InitTask.Start();
        }
예제 #12
0
 public static void Init()
 {
     movieDirs = new string[] {
         Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata, "movies")),     //this folder has most movies
         Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata_lang, "movies")) //this folder has rest of movies
     };
     _movies = new List <string>();
     foreach (string s in movieDirs)
     {
         if (Directory.Exists(s))
         {
             _movies.AddRange(Directory.GetFiles(s, "*", SearchOption.AllDirectories).Where(x =>
                                                                                            x.EndsWith(".avi", StringComparison.OrdinalIgnoreCase) ||
                                                                                            x.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) ||
                                                                                            x.EndsWith(".bik", StringComparison.OrdinalIgnoreCase)));
         }
     }
     ReturnState = Memory.MODULE_MAINMENU_DEBUG;
 }
예제 #13
0
 private static void NormalSwirlDraw_stage1()
 {
     if (sequenceTimer < 0.50) //frame repeat by scaling on un-cleaned buffer
     {
         scaleModifier += 0.003f;
         Memory.SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive);
         var resolution       = new Vector2(backBufferTexture.Width, backBufferTexture.Height);
         var transformedScale = Vector2.Transform(resolution, Matrix.CreateScale(scaleModifier));
         Memory.SpriteBatch.Draw(backBufferTexture, new Rectangle((int)(transformedScale.X - resolution.X) / -3
                                                                  , 0 /*(int)(transformedScale.Y - resolution.Y) / -3*/
                                                                  , (int)transformedScale.X, (int)transformedScale.Y),
                                 Color.White * 0.15f);
         Memory.SpriteBatch.End();
     }
     if (sequenceTimer > 0.50) //black lines going from left (grayscale 127 transition mask-just like in RPG Maker)
     {
         Extended.postBackBufferDelegate = ContinueStage;
         Extended.RequestBackBuffer();
     }
 }
예제 #14
0
        private void ReadGeometry()
        {
            ms.Seek(pBase + pVertices, SeekOrigin.Begin);
            if (ms.Position > ms.Length || pVertices + ms.Position > ms.Length) //pvert error handler
            {
                return;                                                         //error handler
            }
            vertices = new Vector4[cVertices];
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = new Vector4(br.ReadInt16(), br.ReadInt16(), br.ReadInt16(), br.ReadInt16());
            }

            ms.Seek(pBase + pFaces, SeekOrigin.Begin);
            List <Face> face = new List <Face>();

            for (int i = 0; i < cFaces; i++)
            {
                face.Add(Extended.ByteArrayToStructure <Face>(br.ReadBytes(64)));
            }
            faces = face.ToArray();
            return;
        }
예제 #15
0
        public static void Init()
        {
            bInitialized = false;
            //Memory.Encounters.Current().BattleFlags. //which flags is about the boss or normal swirl?
            Memory.Module     = Module.BattleSwirl;
            backBufferTexture = Extended.BackBufferTexture;
            bInitialized      = true;
            bFirstClear       = true;
            swirlStage        = 0;
            sequenceTimer     = 0.0;
            activeFrameTimer  = 0.0;
            scaleModifier     = 1.0f; //maybe create this swirl as non-static class?
            translateModifier = 0.0f;

            //let's now generate the black lines screen cleaning buffer
            blackLines = new Texture2D(Memory.Graphics.GraphicsDevice, 0xFF + 120, //ok, so 0xff to fade alpha and 120 for maximum delay
                                       Memory.Graphics.GraphicsDevice.Viewport.Height, false,
                                       SurfaceFormat.Color);
            var colors = new Color[blackLines.Height * blackLines.Width];

            for (var i = 0; i < blackLines.Height; i++)
            {
                //we are incrementing by line- full width is 0xff+120
                var lineBuffer = Memory.Random.Next(0, 120);            //generate the delay
                var scanAlpha  = 255;
                for (var n = 0; n < blackLines.Width - lineBuffer; n++) //fill with black
                {
                    colors[i * blackLines.Width + n] = new Color(Color.Black, 0xFF);
                }
                for (var n = lineBuffer; n < blackLines.Width; n++)                     //fill with fading black
                {
                    colors[i * blackLines.Width + n] = new Color(0, 0, 0, scanAlpha--); //debug for red
                }
            }
            blackLines.SetData(colors);
            Extended.DumpTexture(blackLines, @"D:\out.png");
        }
예제 #16
0
        public override void SavePNG(string path, short clut = -1)
        {
            if (Buffer == null || Memory.Graphics == null)
            {
                return;
            }
            if (clut == -1)
            {
                if (Texture.NumOfCluts > 0)
                {
                    Enumerable.Range(0, Texture.NumOfCluts).ForEach(x => SavePNG(path, (short)x));
                    return;
                }

                clut = 0;
            }

            using (var br = new BinaryReader(new MemoryStream(Buffer)))
                using (var tex = GetTexture(br, !CLP ? null : GetClutColors(br, (ushort)clut)))
                    if (tex != null)
                    {
                        Extended.Save_As_PNG(tex, $"{path}{(CLP && Texture.NumOfCluts > 1 ? "_" + clut.ToString("D") : "")}.png", GetWidth, GetHeight);
                    }
        }
예제 #17
0
 private void ReadSection7(uint v, MemoryStream ms, BinaryReader br)
 {
     ms.Seek(v, SeekOrigin.Begin);
     information = Extended.ByteArrayToStructure <Information>(br.ReadBytes(Section7Size));
 }
예제 #18
0
        /// <summary>
        /// This method returns the origX and origY coordinates for segment replacement for pre-parsing
        /// </summary>
        /// <param name="i">index of wm block</param>
        /// <returns></returns>
        public static int GetInterchangableSegmentReplacementIndex(int i)
        {
            if (i < 768)
            {
                return(i);
            }

            if (i == (int)interZone.prisonNormal) //correct
            {
                return((int)interZone.prisonGround);
            }

            if (i == (int)interZone.missileBaseNormal)
            {
                return((int)interZone.missileBaseDestroyed);
            }

            if (i == (int)interZone.balambGardenE_static) //correct;
            {
                return((int)interZone.balambGardenE_mobile + 1);
            }
            if (i == (int)interZone.balambGardenW_static)
            {
                return((int)interZone.balambGardenW_mobile - 1);
            }

            if (i == (int)interZone.galbadiaGarden_static)
            {
                return((int)interZone.galbadiaGarden_mobile);
            }

            if (i == (int)interZone.trabiaGardenE_state0)
            {
                return((int)interZone.trabiaGardenE_state1);
            }
            if (i == (int)interZone.trabiaGardenW_state0)
            {
                return((int)interZone.trabiaGardenW_state1);
            }

            if (i == (int)interZone.lunarCryCraterE_state0)
            {
                return((int)interZone.lunarCryCraterE_state1);
            }
            if (i == (int)interZone.lunarCryCraterW_state0)
            {
                return((int)interZone.lunarCryCraterW_state1);
            }

            if (i == (int)interZone.lunarCryCreaterN_state0)
            {
                return((int)interZone.lunarCryCraterN_state1);
            }
            if (i == (int)interZone.lunarCryCraterS_state0)
            {
                return((int)interZone.lunarCryCraterS_state1);
            }

            if (Extended.In(i, 768, 775))
            {
                return(i - 395);
            }
            if (Extended.In(i, 776, 783))
            {
                return(i - 371);
            }
            if (Extended.In(i, 784, 791))
            {
                return(i - 347);
            }
            if (Extended.In(i, 792, 799))
            {
                return(i - 323);
            }
            if (Extended.In(i, 800, 807))
            {
                return(i - 299);
            }
            if (Extended.In(i, 808, 815))
            {
                return(i - 275);
            }
            if (Extended.In(i, 816, 823))
            {
                return(i - 251);
            }

            return(0);
        }
예제 #19
0
 private void ReadSection7(uint v, BinaryReader br, string fileName)
 {
     br.BaseStream.Seek(v, SeekOrigin.Begin);
     information = Extended.ByteArrayToStructure <Information>(br.ReadBytes(Section7Size));
 }
예제 #20
0
 /// <summary>
 /// Information
 /// </summary>
 /// <param name="start"></param>
 /// <param name="br"></param>
 /// <param name="fileName"></param>
 private void ReadSection7(uint start)
 {
     br.BaseStream.Seek(start, SeekOrigin.Begin);
     information = Extended.ByteArrayToStructure <Information>(br.ReadBytes(Section7Size));
 }