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

@@ -1,13 +1,13 @@
using System.Diagnostics;
using Core.Interfaces;
using Core.Interfaces;
using System.Diagnostics;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Core.Io
{
public class IO_Bus
{
public byte BorderColorIndex { get; private set; } = 7; // 7 is White
// 8 rows representing the Spectrum keyboard matrix. Default to 0xFF (unpressed).
public byte BorderColorIndex { get; private set; } = 7;
public bool BeeperState { get; private set; } = false;
public byte[] KeyboardRows = new byte[8] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
public byte ReadPort(ushort portAddress)
@@ -42,11 +42,13 @@ namespace Core.Io
// The ULA intercepts any write to an even port address
if ((portAddress & 0x01) == 0)
{
// The bottom 3 bits (0-2) define the border color!
// The bottom 3 bits (0-2) define the border color
BorderColorIndex = (byte)(portValue & 0x07);
// (Bits 3 and 4 handle the cassette MIC output and the internal speaker,
// which we will need when we start playing audio!)
// Bit 4 controls the speaker
BeeperState = (portValue & 0x10) != 0;
// Bit 3 handles the cassette MIC output
}
}
}