From 4f5f276b2e2874a726e59a001bb51af2770ae6e2 Mon Sep 17 00:00:00 2001 From: Blue Date: Sun, 21 Jun 2020 22:15:30 +0200 Subject: [PATCH] Project: Add RunFrame --- ProjectPSX.WinForms/UI/Window.cs | 2 +- ProjectPSX/Core/ProjectPSX.cs | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ProjectPSX.WinForms/UI/Window.cs b/ProjectPSX.WinForms/UI/Window.cs index 2554979..e6b7852 100644 --- a/ProjectPSX.WinForms/UI/Window.cs +++ b/ProjectPSX.WinForms/UI/Window.cs @@ -56,7 +56,7 @@ namespace ProjectPSX { string diskFilename = GetDiskFilename(); psx = new ProjectPSX(this, diskFilename); psx.POWER_ON(); - + psx.RunUncapped(); this.getScreen().MouseDoubleClick += new MouseEventHandler(toggleDebug); diff --git a/ProjectPSX/Core/ProjectPSX.cs b/ProjectPSX/Core/ProjectPSX.cs index c38c0af..dae4e3d 100644 --- a/ProjectPSX/Core/ProjectPSX.cs +++ b/ProjectPSX/Core/ProjectPSX.cs @@ -45,17 +45,32 @@ namespace ProjectPSX { } public void POWER_ON() { + var timer = new System.Timers.Timer(1000); + timer.Elapsed += OnTimedEvent; + timer.Enabled = true; + } + + public void RunUncapped() { Task t = Task.Factory.StartNew(EXECUTE, TaskCreationOptions.LongRunning); } + public void RunFrame() { + //33868800 / 60 = 564480 / 300 (Sync * underclock) = 1882~ + for(int i = 0; i < 1882; i++) { + for (int j = 0; j < SYNC_CYCLES; j++) { + cpu.Run(); + //cpu.handleInterrupts(); + counter++; + } + bus.tick(SYNC_CYCLES * MIPS_UNDERCLOCK); + cpu.handleInterrupts(); + } + } + private void EXECUTE() { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; Thread.CurrentThread.Priority = ThreadPriority.Highest; - var timer = new System.Timers.Timer(1000); - timer.Elapsed += OnTimedEvent; - timer.Enabled = true; - try { while (true) { for (int j = 0; j < SYNC_CYCLES; j++) {