From 27fa8d9a612ef8fecf73b06f9048bc895395bc10 Mon Sep 17 00:00:00 2001 From: goyuken Date: Fri, 23 May 2014 16:37:49 +0000 Subject: [PATCH] atari 2600: PAL support should be mostly good to go now --- .../Consoles/Atari/2600/Atari2600.cs | 9 ++++++++- BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index a1d93218af..4c64afb340 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -101,7 +101,14 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public ISoundProvider SoundProvider { get { return _dcfilter; } } - public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(_dcfilter, 735); } } + // todo: make this not so ugly + public ISyncSoundProvider SyncSoundProvider + { + get + { + return new FakeSyncSound(_dcfilter, CoreComm.VsyncRate > 55.0 ? 735 : 882); + } + } public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs index 9c16e3564c..b6ecb67c0c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs @@ -188,6 +188,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private bool _vblankEnabled; private bool _vsyncEnabled; private int _CurrentScanLine; + private int _audioClocks; // not savestated private PlayerData _player0; private PlayerData _player1; @@ -278,6 +279,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _vblankEnabled = false; _vsyncEnabled = false; _CurrentScanLine = 0; + _audioClocks = 0; _player0 = new PlayerData(); _player1 = new PlayerData(); @@ -614,6 +616,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _hmove.LateHBlankReset = false; _CurrentScanLine++; LineCount++; + _audioClocks += 2; // TODO: increment this at the appropriate places twice per line } } @@ -1050,9 +1053,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } + // TODO: more accurate would be to have audio.Cycle() occur at + // the explicit exact times in the scanline, instead of just approximately spaced public void GetSamples(short[] samples) { - var samples31khz = new short[((samples.Length / 2) * 31380) / 44100]; + var samples31khz = new short[_audioClocks]; // mono int elapsedCycles = frameEndCycles - frameStartCycles; if (elapsedCycles == 0) @@ -1079,6 +1084,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 samples[i * 2] = samples31khz[(int)(((double)samples31khz.Length / (double)(samples.Length / 2)) * i)]; samples[(i * 2) + 1] = samples[i * 2]; } + + _audioClocks = 0; } public void GetSamplesImmediate(short[] samples, int start, int len) @@ -1093,6 +1100,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public void DiscardSamples() { commands.Clear(); + _audioClocks = 0; } #endregion