From ae721eef5daf8701da2b4493ecf56fbf23eac1cc Mon Sep 17 00:00:00 2001
From: saxxonpike <saxxonpike@gmail.com>
Date: Sat, 10 Nov 2012 08:31:04 +0000
Subject: [PATCH] commodore64: double-wide multicolor sprites are actually 4x
 wide

---
 .../Computers/Commodore64/VicII.cs              | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/BizHawk.Emulation/Computers/Commodore64/VicII.cs b/BizHawk.Emulation/Computers/Commodore64/VicII.cs
index 1e07796bd3..41a7261440 100644
--- a/BizHawk.Emulation/Computers/Commodore64/VicII.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/VicII.cs
@@ -825,7 +825,6 @@ namespace BizHawk.Emulation.Computers.Commodore64
 					{
 						regs.MSRC[spriteIndex] = 24;
 						regs.MSR[spriteIndex] = mem.VicRead((ushort)((regs.MPTR[spriteIndex] << 6) | (regs.MC[spriteIndex])));
-						regs.MSR[spriteIndex] <<= 8;
 						regs.MC[spriteIndex]++;
 					}
 				}
@@ -837,8 +836,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
 					{
 						for (int i = 0; i < 2; i++)
 						{
-							regs.MSR[spriteIndex] |= mem.VicRead((ushort)((regs.MPTR[spriteIndex] << 6) | (regs.MC[spriteIndex])));
 							regs.MSR[spriteIndex] <<= 8;
+							regs.MSR[spriteIndex] |= mem.VicRead((ushort)((regs.MPTR[spriteIndex] << 6) | (regs.MC[spriteIndex])));
 							regs.MC[spriteIndex]++;
 						}
 					}
@@ -1092,28 +1091,30 @@ namespace BizHawk.Emulation.Computers.Commodore64
 						if (regs.MxX[j] == rasterOffsetX)
 						{
 							regs.MSRA[j] = true;
-							regs.MSRC[j] = 25;
 						}
 						if (regs.MSRA[j])
 						{
 							// multicolor consumes two bits per pixel and is forced wide
 							if (regs.MxMC[j])
 							{
-								spriteBits = (int)((regs.MSR[j] >> 30) & 0x3);
+								spriteBits = (int)((regs.MSR[j] >> 22) & 0x3);
 								if ((rasterOffsetX & 0x1) != (regs.MxX[j] & 0x1))
 								{
-									regs.MSR[j] <<= 2;
-									regs.MSRC[j]--;
+									if ((!regs.MxXE[j]) || ((rasterOffsetX & 0x2) != (regs.MxX[j] & 0x2)))
+									{
+										regs.MSR[j] <<= 2;
+										regs.MSRC[j]--;
+									}
 								}
 							}
 							else
 							{
-								spriteBits = (int)((regs.MSR[j] >> 30) & 0x2);
+								spriteBits = (int)((regs.MSR[j] >> 22) & 0x2);
 								if ((!regs.MxXE[j]) || ((rasterOffsetX & 0x1) != (regs.MxX[j] & 0x1)))
 								{
 									regs.MSR[j] <<= 1;
-									regs.MSRC[j]--;
 								}
+								regs.MSRC[j]--;
 							}
 
 							// if not transparent, process collisions and color