Beeper implemented but has noise on the port - to fix

This commit is contained in:
2026-04-21 16:22:30 +01:00
parent dcbb505145
commit b6eb77318d
4 changed files with 65 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ namespace Desktop
private ULA _ula = null!;
private TapManager _tapManager = null!;
private DebuggerForm? _debugger = null;
private BeeperDevice _beeper = null!;
private string _baseTitle = "";
private bool _isRunning = false;
private bool _isPaused = false;
@@ -41,6 +42,7 @@ namespace Desktop
_memoryBus = new MemoryBus();
_simpleIoBus = new IO_Bus();
_ula = new ULA(_memoryBus, _simpleIoBus);
_beeper = new BeeperDevice();
_tapManager = new TapManager();
_memoryBus.CrapRAMData();
byte[] romData = RomLoader.Load("48.rom");
@@ -70,6 +72,7 @@ namespace Desktop
var stopwatch = Stopwatch.StartNew();
var fpsStopwatch = Stopwatch.StartNew();
long scanlineCount = 0;
long audioSampleCount = 0;
while (_isRunning)
{
@@ -90,6 +93,13 @@ namespace Desktop
// --- Execute Instruction ---
_cpu.Step();
//Process audio at the correct time
while (_cpu.TotalTStates >= (long)(audioSampleCount * 79.365))
{
_beeper.AddSample(_simpleIoBus.BeeperState);
audioSampleCount++;
}
// --- Check for End of Frame ---
if (_cpu.TotalTStates >= nextScanlineTarget)
{