Added the APU Class and wired it all up ready for the maths

This commit is contained in:
2026-05-14 21:27:05 +01:00
parent 708c1ba458
commit cafcf625ad
6 changed files with 549 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
using Core.Interfaces;
using Core.Audio;
using Core.Interfaces;
using Core.Video;
namespace Core.Io
@@ -6,7 +7,7 @@ namespace Core.Io
public class SmsIoBus : IIoBus
{
public SmsVdp VideoProcessor { get; set; }
// public Psg AudioProcessor { get; set; }
public SmsApu AudioProcessor { get; set; }
// Joypad State (0xFF means no buttons pressed - the SMS uses Active-Low logic!)
public byte Joypad1Keyboard = 0xFF;
@@ -42,15 +43,19 @@ namespace Core.Io
{
byte lowerPort = (byte)(port & 0xFF);
if (lowerPort >= 0x40 && lowerPort <= 0x7F)
// Audio Ports
if (lowerPort == 0x7E || lowerPort == 0x7F)
{
// PSG Audio Write (Usually written exactly to 0x7F)
// AudioProcessor.WriteData(value);
AudioProcessor.WritePort7F(value);
}
else if (lowerPort >= 0x80 && lowerPort <= 0xBF)
// Video Ports
else if (lowerPort == 0xBE)
{
if ((lowerPort & 0x01) == 0) VideoProcessor.WriteDataPort(value);
else VideoProcessor.WriteControlPort(value);
VideoProcessor.WriteDataPort(value);
}
else if (lowerPort == 0xBF)
{
VideoProcessor.WriteControlPort(value);
}
else if (lowerPort <= 0x3F)
{