Added AY38912 support

This commit is contained in:
2026-04-30 14:35:12 +01:00
parent 3d13425d51
commit d90537de59
7 changed files with 223 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
using System.Diagnostics;
using Core.Audio;
using Core.Interfaces;
using Core.Memory;
using System.Diagnostics;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Core.Io
@@ -8,6 +9,7 @@ namespace Core.Io
public class IO_Bus
{
public byte BorderColourIndex { get; set; } = 7;
public Ay38912 AyChip { get; private set; } = new Ay38912();
public byte KempstonState { get; set; } = 0x00;
public bool BeeperState { get; private set; } = false;
public byte[] KeyboardRows = new byte[8] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
@@ -49,9 +51,13 @@ namespace Core.Io
{
return KempstonState;
}
// AY-3-8912 Data Read (Port 0xFFFD)
if ((portAddress & 0xC002) == 0xC000)
{
return AyChip.ReadRegister();
}
//Return 0xFF for unhandled ports
return 0x00;
return 0xFF; // Default floating bus
}
public void WritePort(ushort portAddress, byte portValue)
@@ -79,6 +85,16 @@ namespace Core.Io
{
_memory.HandlePaging(0x1FFD, portValue);
}
// AY-3-8912 Register Select (Port 0xFFFD)
if ((portAddress & 0xC002) == 0xC000)
{
AyChip.SelectRegister(portValue);
}
// AY-3-8912 Data Write (Port 0xBFFD)
else if ((portAddress & 0xC002) == 0x8000)
{
AyChip.WriteRegister(portValue);
}
}
}
}