Example #1
0
        public void PowerOn()
        {
            if (_isRunnning)
            {
                return;
            }

            Initialize();

            // Apply ROM patches
            if (Settings.Default.KernalWhiteTextColor)
            {
                PatchKernalRomTextColor(0x01);
            }

            Cpu.Reset();

            _isRunnning = true;
            _tcsStop    = new TaskCompletionSource <bool>();

            var swCpuClock = Stopwatch.StartNew();

            var t = new Thread(() => {
                while (_isRunnning)
                {
                    // CPU clock
                    if (swCpuClock.Elapsed.TotalMilliseconds >= CpuPeriodMilliseconds)
                    {
                        CpuPeriodMillisecondsReal = swCpuClock.Elapsed.TotalMilliseconds;
                        CpuClockSpeedRealHz       = 1 / (CpuPeriodMillisecondsReal / 1000.0f);

                        swCpuClock.Restart();

                        // Clock CIA 1
                        Cia.Clock();

                        // Cycle VIC-II
                        Vic.Cycle();

                        // Cycle the CPU
                        Cpu.Cycle();
                    }
                }

                _tcsStop.SetResult(true);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }