APU fully implemented and working but approx 0.25s latency to fix

This commit is contained in:
2026-05-14 22:31:23 +01:00
parent cafcf625ad
commit 780f8ee790
7 changed files with 160 additions and 18 deletions

View File

@@ -6,14 +6,16 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using Core;
using Desktop.Audio;
namespace Desktop
{
public partial class ParsonsForm1 : Form
{
private SmsMachine _machine = null!;
public SmsMachine _machine = null!;
private DebuggerForm _debugger;
private Bitmap _screenBitmap = new Bitmap(256, 192, PixelFormat.Format32bppArgb);
private NAudioPlayer _audioPlayer;
private Task _emulatorTask;
private double TargetFrameTime = 16.667f;
public int TotalFrameCount = 0;
@@ -34,6 +36,8 @@ namespace Desktop
InitializeComponent();
this.Text = $"Parsons Master System 2026 - {_currentRomName}";
_machine = new SmsMachine();
_audioPlayer = new NAudioPlayer();
_machine.AudioProcessor.AudioDevice = _audioPlayer;
PopulateIncludedRomsMenu();
@@ -157,7 +161,8 @@ namespace Desktop
framesThisSecond = 0;
lastFpsUpdate = currentTime;
BeginInvoke((System.Windows.Forms.MethodInvoker)delegate {
BeginInvoke((System.Windows.Forms.MethodInvoker)delegate
{
this.Text = $"Parsons Master System - {_currentRomName} [FPS/FT: {FramesPerSecond:F0}/{FrameTime:F1}]";
});
}
@@ -299,5 +304,11 @@ namespace Desktop
_machine.IoBus.Joypad1Keyboard |= bitMask; // Target Keyboard!
}
}
private void ParsonsForm1_FormClosing(object sender, FormClosingEventArgs e)
{
IsRunning = false;
_audioPlayer?.Stop();
}
}
}