Merge pull request #641 from alyosha-tas/master

fixes poly9 sound
This commit is contained in:
alyosha-tas 2016-06-06 11:13:05 -04:00
commit c7c706d085
1 changed files with 15 additions and 17 deletions

View File

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