From 7e30f2844fd23b72907707c161cc908ee3043d74 Mon Sep 17 00:00:00 2001
From: adelikat <adelikat@tasvideos.org>
Date: Sat, 31 Mar 2012 20:32:40 +0000
Subject: [PATCH] Atri - implement mapper F6

---
 BizHawk.Emulation/BizHawk.Emulation.csproj    |  2 +
 .../Consoles/Atari/2600/Atari2600.Core.cs     |  3 ++
 .../Consoles/Atari/2600/Mappers/mCV.cs        | 12 ++++++
 .../Consoles/Atari/2600/Mappers/mF6.cs        | 38 +++++++++++++++++++
 4 files changed, 55 insertions(+)
 create mode 100644 BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs
 create mode 100644 BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs

diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj
index 870f8f3736..9cbefa4c9a 100644
--- a/BizHawk.Emulation/BizHawk.Emulation.csproj
+++ b/BizHawk.Emulation/BizHawk.Emulation.csproj
@@ -78,8 +78,10 @@
     <Compile Include="Buffer.cs" />
     <Compile Include="Consoles\Atari\2600\Atari2600.cs" />
     <Compile Include="Consoles\Atari\2600\Atari2600.Core.cs" />
+    <Compile Include="Consoles\Atari\2600\Mappers\mCV.cs" />
     <Compile Include="Consoles\Atari\2600\Mappers\m2K.cs" />
     <Compile Include="Consoles\Atari\2600\Mappers\m4K.cs" />
+    <Compile Include="Consoles\Atari\2600\Mappers\mF6.cs" />
     <Compile Include="Consoles\Atari\2600\Mappers\mF8.cs" />
     <Compile Include="Consoles\Atari\2600\oldTIA.cs" />
     <Compile Include="Consoles\Atari\2600\M6532.cs" />
diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs
index c8105d0aea..58d174cf58 100644
--- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs
+++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.IO;
 using BizHawk.Emulation.CPUs.M6502;
 using BizHawk.Emulation.Consoles.Atari;
+using BizHawk.Emulation.Consoles.Atari._2600;
 
 namespace BizHawk
 {
@@ -109,7 +110,9 @@ namespace BizHawk
 			{
 				case "4K": mapper = new m4K(); break;
 				case "2K": mapper = new m2K(); break;
+				case "CV": mapper = new mCV(); break;
 				case "F8": mapper = new mF8(); break;
+				case "F6": mapper = new mF6(); break;
 				default: throw new InvalidOperationException("mapper not supported: " + game.GetOptionsDict()["m"]);
 			}
 			mapper.core = this;
diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs
new file mode 100644
index 0000000000..96f6bd094c
--- /dev/null
+++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Consoles.Atari._2600
+{
+	class mCV: MapperBase
+	{
+
+	}
+}
diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs
new file mode 100644
index 0000000000..4d5605beb6
--- /dev/null
+++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Consoles.Atari._2600
+{
+	class mF6 : MapperBase 
+	{
+		int toggle = 0;
+
+		public override byte ReadMemory(ushort addr)
+		{
+			Address(addr);
+			if (addr < 0x1000) return base.ReadMemory(addr);
+			return core.rom[toggle * 4 * 1024 + (addr & 0xFFF)];
+		}
+		public override void WriteMemory(ushort addr, byte value)
+		{
+			Address(addr);
+			if (addr < 0x1000) base.WriteMemory(addr, value);
+		}
+
+		public override void SyncState(Serializer ser)
+		{
+			base.SyncState(ser);
+			ser.Sync("toggle", ref toggle);
+		}
+
+		void Address(ushort addr)
+		{
+			if (addr == 0x1FF6) toggle = 0;
+			if (addr == 0x1FF7) toggle = 1;
+			if (addr == 0x1FF8) toggle = 2;
+			if (addr == 0x1FF9) toggle = 3;
+		}
+	}
+}