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
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,10 +87,9 @@ 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);
bool ret = (sr9 & 1) != 0;
bool c = ((sr9 & 1) != 0) ^ ((sr9 & 16) != 0);
sr9 = (sr9 >> 1) | (c ? 256 : 0);
return ret;
}
@ -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())
{
@ -148,7 +146,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
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,6 +203,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("sr3", ref sr3);
ser.Sync("sr4", ref sr4);
ser.Sync("sr5", ref sr5);
ser.Sync("sr9", ref sr9);
ser.Sync("freqcnt", ref freqcnt);
ser.Sync("on", ref on);
}