A7800Hawk: refactor sound for pokey

This commit is contained in:
alyosha-tas 2017-08-25 11:28:19 -04:00 committed by GitHub
parent 5b1c6d2862
commit f6f55c09de
4 changed files with 47 additions and 2 deletions

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
public partial class A7800Hawk : IEmulator, IVideoProvider
public partial class A7800Hawk : IEmulator, IVideoProvider, ISoundProvider
{
public IEmulatorServiceProvider ServiceProvider { get; }
@ -351,5 +351,45 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
};
#endregion
#region Sound provider
private int _spf;
public bool CanProvideAsync => false;
public void SetSyncMode(SyncSoundMode mode)
{
if (mode != SyncSoundMode.Sync)
{
throw new InvalidOperationException("Only Sync mode is supported.");
}
}
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
public void GetSamplesSync(out short[] samples, out int nsamp)
{
short[] ret = new short[_spf * 2];
nsamp = _spf;
tia.GetSamples(ret);
// add pokey samples here
samples = ret;
}
public void GetSamplesAsync(short[] samples)
{
throw new NotSupportedException("Async is not available");
}
public void DiscardSamples()
{
tia.AudioClocks = 0;
}
#endregion
}
}

View File

@ -62,6 +62,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
ser.Sync("A7800_control_register", ref A7800_control_register);
ser.Sync("_isPAL", ref _isPAL);
ser.Sync("_spf", ref _spf);
ser.Sync("Maria_regs", ref Maria_regs, false);
ser.Sync("RAM", ref RAM, false);

View File

@ -227,7 +227,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
pokey.Core = this;
ser.Register<IVideoProvider>(this);
ser.Register<ISoundProvider>(tia);
ser.Register<ISoundProvider>(this);
ServiceProvider = ser;
_tracer = new TraceBuffer { Header = cpu.TraceHeader };
@ -262,6 +262,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
cpu_cycle = 0;
_vidbuffer = new int[VirtualWidth * VirtualHeight];
_spf = (_frameHz > 55) ? 740 : 880;
}
private void ExecFetch(ushort addr)

View File

@ -46,6 +46,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public void WriteReg(int reg, byte value)
{
Regs[reg] = value;
}
public void Tick()