diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs index e44deff1c4..585a9c3d37 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs @@ -25,6 +25,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // 5 bit shift register private int sr5 = 0x1f; + // 9 bit shift register + private int sr9 = 0x1ff; + // 3 state counter private int sr3 = 2; @@ -49,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private bool Run4() { bool ret = (sr4 & 1) != 0; - bool c = (sr4 & 1) != 0 ^ (sr4 & 2) != 0; + bool c = ((sr4 & 1) != 0) ^ ((sr4 & 2) != 0); sr4 = (sr4 >> 1) | (c ? 8 : 0); return ret; } @@ -57,7 +60,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private bool Run5() { bool ret = (sr5 & 1) != 0; - bool c = (sr5 & 1) != 0 ^ (sr5 & 4) != 0; + bool c = ((sr5 & 1) != 0) ^ ((sr5 & 4) != 0); sr5 = (sr5 >> 1) | (c ? 16 : 0); return ret; } @@ -84,12 +87,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private bool Run9() { - bool ret = (sr4 & 1) != 0; - bool c = (sr5 & 1) != 0 ^ (sr4 & 1) != 0; - sr4 = (sr4 >> 1) | ((sr5 & 1) != 0 ? 8 : 0); - sr5 = (sr5 >> 1) | (c ? 16 : 0); - return ret; - } + bool ret = (sr9 & 1) != 0; + bool c = ((sr9 & 1) != 0) ^ ((sr9 & 16) != 0); + sr9 = (sr9 >> 1) | (c ? 256 : 0); + return ret; + } /// /// call me approx 31k times a second @@ -112,20 +114,16 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 case 0x01: // Both run, but the 5 bit is ignored on = Run4(); - Run5(); + //Run5(); break; - case 0x02: if ((sr5 & 0x0f) == 0 || (sr5 & 0x0f) == 0x0f) { on = Run4(); - Run5(); - break; } Run5(); break; - case 0x03: if (Run5()) { @@ -145,10 +143,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 Run4(); on = Run1(); break; - + case 0x06: case 0x0a: - Run4(); // ??? Run5(); if ((sr5 & 0x0f) == 0) { @@ -163,9 +160,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 case 0x07: case 0x09: - Run4(); // ??? on = Run5(); break; + case 0x08: on = Run9(); break; @@ -206,7 +203,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("sr3", ref sr3); ser.Sync("sr4", ref sr4); ser.Sync("sr5", ref sr5); - ser.Sync("freqcnt", ref freqcnt); + ser.Sync("sr9", ref sr9); + ser.Sync("freqcnt", ref freqcnt); ser.Sync("on", ref on); } }