Esempio n. 1
0
        void EmulateCyclesWithout1541()
        {
#if TIMERS
            uint lc = CycleCounter;
            HiResTimer timer = new HiResTimer();
            timer.Start();
            const uint cycleCount = 4000000;
#endif

            thread_running = true;
            while (!quit_thyself)
            {

                // The order of calls is important here
                if (TheVIC.EmulateCycle())
                    TheSID.EmulateLine();
                TheCIA1.CheckIRQs();
                TheCIA2.CheckIRQs();
                TheCIA1.EmulateCycle();
                TheCIA2.EmulateCycle();
                TheCPU.EmulateCycle();

                CycleCounter++;

#if TIMERS
                if (CycleCounter - lc == cycleCount)
                {
                    timer.Stop();
                    lc = CycleCounter;
                    double elapsedSec = timer.ElapsedMilliseconds / 1000.0f;

                    //Debug.WriteLine("------------------------------------");
                    //Debug.WriteLine(string.Format("{0} ms elapsed for {1:N} cycles", timer.ElapsedMilliseconds, cycleCount));
                    //Debug.WriteLine(string.Format("CIA1: TA Interrupts: {0} -> int/s: {1}", TheCIA1.ta_interrupts, TheCIA1.ta_interrupts / elapsedSec));
                    //Debug.WriteLine(string.Format("CPU Instructions: {0} -> ins/s: {1}", TheCPU.ins_counter, TheCPU.ins_counter / elapsedSec));
                    
                    // reset counters
                    TheCIA1.ta_interrupts = 0;
                    TheCIA1.tb_interrupts = 0;
                    TheCIA2.ta_interrupts = 0;
                    TheCIA2.tb_interrupts = 0;
                    TheCPU.ins_counter = 0;

                    timer.Reset();
                    timer.Start();
                    //TheDisplay.Surface.Update();
                }
#endif
            }
        }
 public static HiResTimer StartNew()
 {
     HiResTimer ht = new HiResTimer();
     ht.Start();
     return ht;
 }