From 7a16d7c49a4440fecbc984df7ddeffe00411242d Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Mon, 23 May 2016 20:31:55 -0400 Subject: [PATCH] Add data bus state and track it fixes AVGN KO boxing --- .../Consoles/Atari/2600/Atari2600.Core.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs index a72c3ebdf9..af3928a556 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs @@ -36,10 +36,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if ((addr & 0x1080) == 0x0080) { - return M6532.ReadMemory(addr, false); + _tia.bus_state = M6532.ReadMemory(addr, false); + return M6532.ReadMemory(addr, false); } - return Rom[addr & 0x0FFF]; + _tia.bus_state = Rom[addr & 0x0FFF]; + return Rom[addr & 0x0FFF]; } internal byte BasePeekMemory(ushort addr) @@ -52,15 +54,17 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if ((addr & 0x1080) == 0x0080) { - return M6532.ReadMemory(addr, true); + _tia.bus_state = M6532.ReadMemory(addr, false); + return M6532.ReadMemory(addr, true); } - - return Rom[addr & 0x0FFF]; + _tia.bus_state = Rom[addr & 0x0FFF]; + return Rom[addr & 0x0FFF]; } internal void BaseWriteMemory(ushort addr, byte value) { - if (addr != LastAddress) + _tia.bus_state = value; + if (addr != LastAddress) { DistinctAccessCount++; LastAddress = addr; @@ -83,7 +87,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 internal void BasePokeMemory(ushort addr, byte value) { - addr = (ushort)(addr & 0x1FFF); + _tia.bus_state = value; + addr = (ushort)(addr & 0x1FFF); if ((addr & 0x1080) == 0) { _tia.WriteMemory(addr, value); @@ -108,6 +113,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _mapper.Bit13 = addr.Bit(13); var temp = _mapper.ReadMemory((ushort)(addr & 0x1FFF)); + _tia.bus_state = temp; MemoryCallbacks.CallReads(addr); return temp; @@ -116,7 +122,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 internal byte PeekMemory(ushort addr) { var temp = _mapper.ReadMemory((ushort)(addr & 0x1FFF)); - + _tia.bus_state = temp; return temp; }