Ejemplo n.º 1
0
 private void TreeNode_MouseHover(object sender, TreeNodeMouseHoverEventArgs e)
 {
     if (e.Node.Tag is FileInfo)
     {
         BinaryStateLoader.LoadAndDetect(Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.State", e.Node.FullPath))).GetLump(BinaryStateLump.Framebuffer, false, PopulatePictureBox);
     }
 }
Ejemplo n.º 2
0
        public bool LoadStateFile(string path, string name)
        {
            var core = Emulator.AsStatable();

            // try to detect binary first
            var bl = BinaryStateLoader.LoadAndDetect(path);

            if (bl != null)
            {
                try
                {
                    var succeed = false;

                    // TODO
                    if (IAmMaster)
                    {
                        if (Global.MovieSession.Movie.IsActive)
                        {
                            bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep1(tr));
                            if (!succeed)
                            {
                                return(false);
                            }

                            bl.GetLump(BinaryStateLump.Input, true, tr => succeed = Global.MovieSession.HandleMovieLoadState_HackyStep2(tr));
                            if (!succeed)
                            {
                                return(false);
                            }
                        }
                    }

                    using (new SimpleTime("Load Core"))
                        bl.GetCoreState(br => core.LoadStateBinary(br), tr => core.LoadStateText(tr));

                    bl.GetLump(BinaryStateLump.Framebuffer, false, PopulateFramebuffer);
                }
                catch
                {
                    return(false);
                }
                finally
                {
                    bl.Dispose();
                }

                return(true);
            }
            else             // text mode
            {
                if (Global.MovieSession.HandleMovieLoadState(path))
                {
                    using (var reader = new StreamReader(path))
                    {
                        core.LoadStateText(reader);

                        while (true)
                        {
                            var str = reader.ReadLine();
                            if (str == null)
                            {
                                break;
                            }

                            if (str.Trim() == string.Empty)
                            {
                                continue;
                            }

                            var args = str.Split(' ');
                            if (args[0] == "Framebuffer")
                            {
                                Emulator.VideoProvider().GetVideoBuffer().ReadFromHex(args[1]);
                            }
                        }
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }