From b9a791ab3049728946b0d367d4a32efa2a80df3b Mon Sep 17 00:00:00 2001 From: pjgat09 Date: Mon, 12 Mar 2012 21:16:38 +0000 Subject: [PATCH] Atari 2600: Added support to read UDLR from controller M6532: Gives controller data to game program TIA: Fixed player reflecting error --- .../Consoles/Atari/2600/Atari2600.Core.cs | 14 ++++++++++++-- BizHawk.Emulation/Consoles/Atari/2600/M6532.cs | 8 ++++++-- BizHawk.Emulation/Consoles/Atari/2600/TIA.cs | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs index 72a912eb25..850841544a 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs @@ -54,7 +54,6 @@ namespace BizHawk // registers // else // ROM - public byte ReadMemory(ushort addr) { ushort maskedAddr = (ushort)(addr & 0x1FFF); @@ -112,7 +111,7 @@ namespace BizHawk // Setup TIA tia = new TIA(cpu, frameBuffer); // Setup 6532 - m6532 = new M6532(cpu, ram); + m6532 = new M6532(cpu, ram, this); //setup the system state here. for instance.. // Read from the reset vector for where to start @@ -161,5 +160,16 @@ namespace BizHawk //run one frame's worth of cpu cyclees (i.e. do the emulation!) //this should generate the framebuffer as it goes. } + + public byte ReadControls1() + { + byte value = 0xFF; + + if (Controller["P1 Up"]) value &= 0xEF; + if (Controller["P1 Down"]) value &= 0xDF; + if (Controller["P1 Left"]) value &= 0xBF; + if (Controller["P1 Right"]) value &= 0x7F; + return value; + } } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Atari/2600/M6532.cs b/BizHawk.Emulation/Consoles/Atari/2600/M6532.cs index 008ae345f2..b5f65258ae 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/M6532.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/M6532.cs @@ -13,11 +13,14 @@ namespace BizHawk.Emulation.Consoles.Atari public int timerStartValue; public int timerFinishedCycles; public int timerShift; + Atari2600 core; - public M6532(MOS6507 cpu, byte[] ram) + + public M6532(MOS6507 cpu, byte[] ram, Atari2600 core) { Cpu = cpu; this.ram = ram; + this.core = core; // Apparently this will break for some games (Solaris and H.E.R.O.). We shall see timerFinishedCycles = 0; @@ -60,7 +63,8 @@ namespace BizHawk.Emulation.Consoles.Atari Console.WriteLine("6532 register read: " + maskedAddr.ToString("x")); if (maskedAddr == 0x00) // SWCHA { - return 0xFF; + return core.ReadControls1(); + //return 0xFF; } else if (maskedAddr == 0x01) // SWACNT { diff --git a/BizHawk.Emulation/Consoles/Atari/2600/TIA.cs b/BizHawk.Emulation/Consoles/Atari/2600/TIA.cs index 85da9d9856..13faeb2c67 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/TIA.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/TIA.cs @@ -408,11 +408,11 @@ namespace BizHawk.Emulation.Consoles.Atari } else if (maskedAddr == 0x0B) // REFP0 { - player0.reflect = ((value & 0x04) != 0); + player0.reflect = ((value & 0x08) != 0); } else if (maskedAddr == 0x0C) // REFP1 { - player1.reflect = ((value & 0x04) != 0); + player1.reflect = ((value & 0x08) != 0); } else if (maskedAddr == 0x0D) // PF0 {