Пример #1
0
 private double Benchmark(string name, string romPath)
 {
     Nes nes = new Nes(romPath);
     bool render;
     int cycles = 341*262*60*10;
     Stopwatch sw = new Stopwatch();
     sw.Start();
     for(int i=0; i<10*60; ++i)
         nes.RunOneFrame();//cycles, out render);
     sw.Stop();
     double time = sw.ElapsedTicks / (double)Stopwatch.Frequency;
     textBox.AppendText(String.Format("{0}: {1:0.000} s\r\n", name, time));
     Refresh();
     return time;
 }
Пример #2
0
        private double Benchmark(string name, string romPath)
        {
            Nes       nes = new Nes(romPath);
            bool      render;
            int       cycles = 341 * 262 * 60 * 10;
            Stopwatch sw     = new Stopwatch();

            sw.Start();
            for (int i = 0; i < 10 * 60; ++i)
            {
                nes.RunOneFrame();//cycles, out render);
            }
            sw.Stop();
            double time = sw.ElapsedTicks / (double)Stopwatch.Frequency;

            textBox.AppendText(String.Format("{0}: {1:0.000} s\r\n", name, time));
            Refresh();
            return(time);
        }
Пример #3
0
        void Application_Idle(object sender, EventArgs e)
        {
            while (AppStillIdle())
            {
                if (nes.Cpu.Paused)
                {
                    return;
                }

                const float  deadZone = 0.3f;
                GamePadState state    = GamePad.GetState(PlayerIndex.One);
                nes.Controller1.A      = state.Buttons.A == (Microsoft.Xna.Framework.Input.ButtonState.Pressed);
                nes.Controller1.B      = state.Buttons.X == (Microsoft.Xna.Framework.Input.ButtonState.Pressed);
                nes.Controller1.Start  = state.Buttons.Start == (Microsoft.Xna.Framework.Input.ButtonState.Pressed);
                nes.Controller1.Select = state.Buttons.Back == (Microsoft.Xna.Framework.Input.ButtonState.Pressed);
                nes.Controller1.Left   = state.ThumbSticks.Left.X < -deadZone;
                nes.Controller1.Right  = state.ThumbSticks.Left.X > deadZone;
                nes.Controller1.Up     = state.ThumbSticks.Left.Y > deadZone;
                nes.Controller1.Down   = state.ThumbSticks.Left.Y < -deadZone;

                double deltaT = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
                deltaT *= 5;
                sw.Reset();
                sw.Start();
                if (deltaT > 0.1f)
                {
                    deltaT = 0.1f;
                }
                double clockRate = 341 * 262 * 60;

                int cycles = (int)Math.Round(clockRate * deltaT);
                //Console.WriteLine("{0:0} ms = {1} cycles", deltaT * 1000.0, cycles);

                //bool render=false;

                /*while (!nes.Cpu.Paused && cycles > 0)
                 * {
                 *  bool tmpRender = false;
                 *  cycles = nes.Run(cycles, out tmpRender);
                 *
                 *  if(tmpRender)
                 *      render = true;
                 * }*/
                nes.RunOneFrame();

                if (nes.Cpu.Paused)
                {
                    UpdateTitle();
                    UpdateScreen();
                    disassembly2.SelectAddress(nes.Cpu.PC);
                    return;
                }

                //if(render)
                outputWindow.Invalidate();

                counter++;
                if (counter > 10)
                {
                    outputWindow.Text = String.Format("NES Emulator - {0:0.0} FPS", nes.FPS);
                    counter           = 0;
                }
            }
        }