diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs index adf307eaa1..f9527c215c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs @@ -323,6 +323,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 Rom.HashSHA1(), Rom.HashMD5(), _mapper.GetType()); + + + // as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves. + // some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532 + // executing a reset sequence at power on, but it's needed so let's hard code it for now + Cpu.S = 0xFD; } private bool _pal; @@ -345,7 +351,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 M6532 = new M6532(this); Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8)); // set the initial PC - } + + // as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves. + // some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532 + // executing a reset sequence at power on, but it's needed so let's hard code it for now + Cpu.S = 0xFD; + } public void FrameAdvance(bool render, bool rendersound) { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs index 92849ef9a9..5f5155a5f3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs @@ -9,6 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public byte DDRa = 0x00; public byte DDRb = 0x00; + public byte outputA = 0x00; public TimerData Timer; @@ -35,9 +36,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { // Read Output reg A // Combine readings from player 1 and player 2 - var temp = (byte)(_core.ReadControls1(peek) & 0xF0 | ((_core.ReadControls2(peek) >> 4) & 0x0F)); - temp = (byte)(temp & ~DDRa); - return temp; + // actually depends on setting in SWCHCNTA (aka DDRa) + + var temp = (byte)(_core.ReadControls1(peek) & 0xF0 | ((_core.ReadControls2(peek) >> 4) & 0x0F)); + temp = (byte)(temp & ~DDRa); + temp = (byte)(temp + (outputA & DDRa)); + return temp; + } if (registerAddr == 0x01) @@ -150,7 +155,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if (registerAddr == 0x00) { - // Write Output reg A + // Write Output reg A + outputA = value; } else if (registerAddr == 0x01) { @@ -159,7 +165,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (registerAddr == 0x02) { - // Write Output reg B + // Write Output reg B + // But is read only } else if (registerAddr == 0x03) { @@ -175,7 +182,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.BeginSection("M6532"); ser.Sync("ddra", ref DDRa); ser.Sync("ddrb", ref DDRb); - Timer.SyncState(ser); + ser.Sync("OutputA", ref outputA); + Timer.SyncState(ser); ser.EndSection(); }