Sound fixed and complete. More OpCodes to implement

This commit is contained in:
2026-04-21 17:12:42 +01:00
parent b6eb77318d
commit a63152b04d
4 changed files with 69 additions and 5 deletions

View File

@@ -7,6 +7,8 @@ namespace Desktop
{
private WaveOutEvent _waveOut;
private BufferedWaveProvider _buffer;
private float _lastSample = 0.0f;
private float _lastFiltered = 0.0f;
public BeeperDevice()
{
@@ -25,16 +27,19 @@ namespace Desktop
public void AddSample(bool isHigh)
{
//Buffer overrun check and dump
if (_buffer.BufferedDuration.TotalMilliseconds > 100)
while (_buffer.BufferedDuration.TotalMilliseconds > 80)
{
_buffer.ClearBuffer();
Thread.Sleep(1);
}
// Convert the boolean into a physical sound wave (-0.2 or +0.2)
float sampleValue = isHigh ? 0.2f : -0.2f;
float rawSample = isHigh ? 0.2f : -0.2f;
float filteredSample = rawSample - _lastSample + 0.995f * _lastFiltered;
_lastSample = rawSample;
_lastFiltered = filteredSample;
// Convert the float to bytes and drop it in the pipe
byte[] bytes = BitConverter.GetBytes(sampleValue);
byte[] bytes = BitConverter.GetBytes(filteredSample);
_buffer.AddSamples(bytes, 0, 4);
}
}

View File

@@ -835,6 +835,20 @@ namespace Desktop
mnemonic = $"LD L, (IX{sign}{d})";
instructionLength = 3;
}
else if (ddOpcode == 0x71) // LD (IX+d), B
{
sbyte offset = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
string sign = offset >= 0 ? "+" : "";
mnemonic = $"LD (IX{sign}{offset}), B";
instructionLength = 3;
}
else if (ddOpcode == 0x71) // LD (IX+d), C
{
sbyte offset = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
string sign = offset >= 0 ? "+" : "";
mnemonic = $"LD (IX{sign}{offset}), C";
instructionLength = 3;
}
else if (ddOpcode == 0x72) // LD (IX+d), D
{
sbyte offset = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
@@ -1154,6 +1168,13 @@ namespace Desktop
mnemonic = $"LD (IY{sign}{d}), D";
instructionLength = 3;
}
else if (fdOpcode == 0x73) // LD (IY+d), E
{
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
string sign = d >= 0 ? "+" : "";
mnemonic = $"LD (IY{sign}{d}), E";
instructionLength = 3;
}
else if (fdOpcode == 0x74) // LD (IY+d), H
{
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));

View File

@@ -79,6 +79,8 @@ namespace Desktop
if (_isPaused)
{
stopwatch.Restart();
scanlineCount = 0;
Thread.Sleep(10);
continue;
}
@@ -174,6 +176,7 @@ namespace Desktop
private void loadTAPToolStripMenuItem_Click(object sender, EventArgs e)
{
_isPaused = true;
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Filter = "Spectrum TAP Files|*.tap";
@@ -183,9 +186,11 @@ namespace Desktop
_cpu._tapManager.LoadTapData(tapBytes);
}
}
_isPaused = false;
}
private void openSNAToolStripMenuItem_Click(object sender, EventArgs e)
{
_isPaused = true;
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Filter = "Snapshot Files (sna,z80)|*.sna";
@@ -195,6 +200,7 @@ namespace Desktop
_cpu.LoadSNA(snaBytes);
}
}
_isPaused = false;
}
private void btnRun_Click(object sender, EventArgs e) => _isPaused = false;