Commodore64: Fix sprites and tweaked timing, should now be pixel perfect with test intro "rem-17".
This commit is contained in:
parent
4bd6103574
commit
3dc1e8dba2
|
@ -110,6 +110,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
public void ExecutePhase1()
|
public void ExecutePhase1()
|
||||||
{
|
{
|
||||||
// unsure if the timer actually operates in ph1
|
// unsure if the timer actually operates in ph1
|
||||||
|
pinIRQ = !(
|
||||||
|
(intTimer[0] && enableIntTimer[0]) ||
|
||||||
|
(intTimer[1] && enableIntTimer[1]) ||
|
||||||
|
(intAlarm && enableIntAlarm) ||
|
||||||
|
(intSP && enableIntSP) ||
|
||||||
|
(intFlag && enableIntFlag)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExecutePhase2()
|
public void ExecutePhase2()
|
||||||
|
@ -151,14 +158,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
cntPos = false;
|
cntPos = false;
|
||||||
underflow[0] = false;
|
underflow[0] = false;
|
||||||
underflow[1] = false;
|
underflow[1] = false;
|
||||||
|
|
||||||
pinIRQ = !(
|
|
||||||
(intTimer[0] && enableIntTimer[0]) ||
|
|
||||||
(intTimer[1] && enableIntTimer[1]) ||
|
|
||||||
(intAlarm && enableIntAlarm) ||
|
|
||||||
(intSP && enableIntSP) ||
|
|
||||||
(intFlag && enableIntFlag)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
}
|
}
|
||||||
else if (parsefetchType == 0x200)
|
else if (parsefetchType == 0x200)
|
||||||
{
|
{
|
||||||
// fetch C
|
delayC = xScroll;
|
||||||
if (!idle)
|
if (!idle)
|
||||||
{
|
{
|
||||||
if (badline)
|
if (badline)
|
||||||
|
@ -78,6 +78,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
dataC = 0;
|
dataC = 0;
|
||||||
bufferC[vmli] = dataC;
|
bufferC[vmli] = dataC;
|
||||||
}
|
}
|
||||||
|
srC <<= 12;
|
||||||
|
srC |= dataC;
|
||||||
}
|
}
|
||||||
else if (parsefetchType == 0x300)
|
else if (parsefetchType == 0x300)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +97,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
parseaddr &= 0x39FF;
|
parseaddr &= 0x39FF;
|
||||||
dataG = ReadMemory(parseaddr);
|
dataG = ReadMemory(parseaddr);
|
||||||
sr |= dataG << (7 - xScroll);
|
sr |= dataG << (7 - xScroll);
|
||||||
|
srSync |= 0xAA << (7 - xScroll);
|
||||||
if (!idle)
|
if (!idle)
|
||||||
{
|
{
|
||||||
bufferG[vmli] = dataG;
|
bufferG[vmli] = dataG;
|
||||||
|
@ -107,7 +110,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
// fetch I
|
// fetch I
|
||||||
parseaddr = (extraColorMode ? 0x39FF : 0x3FFF);
|
parseaddr = (extraColorMode ? 0x39FF : 0x3FFF);
|
||||||
dataG = ReadMemory(parseaddr);
|
dataG = ReadMemory(parseaddr);
|
||||||
dataC = 0;
|
//dataC = 0;
|
||||||
}
|
}
|
||||||
else if (parsefetchType == 0x500)
|
else if (parsefetchType == 0x500)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,16 +7,16 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
sealed public partial class Vic
|
sealed public partial class Vic
|
||||||
{
|
{
|
||||||
int borderSR;
|
int delayC;
|
||||||
int ecmPixel;
|
int ecmPixel;
|
||||||
int pixel;
|
int pixel;
|
||||||
int pixelData;
|
int pixelData;
|
||||||
int pixelOwner;
|
//int pixelOwner;
|
||||||
|
Sprite pixelOwner;
|
||||||
int sprData;
|
int sprData;
|
||||||
int sprPixel;
|
int sprPixel;
|
||||||
int srOutput = 0;
|
int srC = 0;
|
||||||
int srOutputMC = 0;
|
int srSync = 0;
|
||||||
int hblankSR = 0;
|
|
||||||
VicVideoMode videoMode;
|
VicVideoMode videoMode;
|
||||||
|
|
||||||
enum VicVideoMode : int
|
enum VicVideoMode : int
|
||||||
|
@ -45,17 +45,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
renderEnabled = (!hblank && !vblank);
|
renderEnabled = (!hblank && !vblank);
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
// fill shift register
|
|
||||||
if (bitmapColumn >= 8)
|
if (delayC > 0)
|
||||||
{
|
delayC--;
|
||||||
displayC >>= 12;
|
else
|
||||||
displayC &= 0xFFF;
|
displayC = (srC >> 12) & 0xFFF;
|
||||||
if (!idle)
|
|
||||||
{
|
|
||||||
displayC |= (dataC << 12);
|
|
||||||
}
|
|
||||||
bitmapColumn &= 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (borderCheckLEnable && (rasterX == borderL))
|
if (borderCheckLEnable && (rasterX == borderL))
|
||||||
{
|
{
|
||||||
|
@ -67,20 +62,18 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
borderOnMain = false;
|
borderOnMain = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
srOutput = sr & srMask2;
|
|
||||||
if ((bitmapColumn & 1) == 0)
|
|
||||||
srOutputMC = sr & srMask3;
|
|
||||||
switch (videoMode)
|
switch (videoMode)
|
||||||
{
|
{
|
||||||
case VicVideoMode.Mode000:
|
case VicVideoMode.Mode000:
|
||||||
pixelData = srOutput;
|
pixelData = sr & srMask2;
|
||||||
pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0;
|
pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0;
|
||||||
break;
|
break;
|
||||||
case VicVideoMode.Mode001:
|
case VicVideoMode.Mode001:
|
||||||
if ((displayC & 0x800) != 0)
|
if ((displayC & 0x800) != 0)
|
||||||
{
|
{
|
||||||
// multicolor 001
|
// multicolor 001
|
||||||
pixelData = srOutputMC;
|
if ((srSync & srMask2) != 0)
|
||||||
|
pixelData = sr & srMask3;
|
||||||
|
|
||||||
if (pixelData == srMask0)
|
if (pixelData == srMask0)
|
||||||
pixel = backgroundColor0;
|
pixel = backgroundColor0;
|
||||||
|
@ -94,16 +87,17 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// standard 001
|
// standard 001
|
||||||
pixelData = srOutput;
|
pixelData = sr & srMask2;
|
||||||
pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0;
|
pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VicVideoMode.Mode010:
|
case VicVideoMode.Mode010:
|
||||||
pixelData = srOutput;
|
pixelData = sr & srMask2;
|
||||||
pixel = (pixelData != 0) ? (displayC >> 4) : (displayC);
|
pixel = (pixelData != 0) ? (displayC >> 4) : (displayC);
|
||||||
break;
|
break;
|
||||||
case VicVideoMode.Mode011:
|
case VicVideoMode.Mode011:
|
||||||
pixelData = srOutputMC;
|
if ((srSync & srMask2) != 0)
|
||||||
|
pixelData = sr & srMask3;
|
||||||
|
|
||||||
if (pixelData == srMask0)
|
if (pixelData == srMask0)
|
||||||
pixel = backgroundColor0;
|
pixel = backgroundColor0;
|
||||||
|
@ -115,7 +109,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
pixel = (displayC >> 8);
|
pixel = (displayC >> 8);
|
||||||
break;
|
break;
|
||||||
case VicVideoMode.Mode100:
|
case VicVideoMode.Mode100:
|
||||||
pixelData = srOutput;
|
pixelData = sr & srMask2;
|
||||||
if (pixelData != 0)
|
if (pixelData != 0)
|
||||||
{
|
{
|
||||||
pixel = displayC >> 8;
|
pixel = displayC >> 8;
|
||||||
|
@ -140,16 +134,16 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
}
|
}
|
||||||
pixel &= 0xF;
|
pixel &= 0xF;
|
||||||
sr <<= 1;
|
sr <<= 1;
|
||||||
|
srSync <<= 1;
|
||||||
|
|
||||||
// render sprite
|
// render sprite
|
||||||
pixelOwner = 8;
|
//pixelOwner = 8;
|
||||||
for (int j = 0; j < 8; j++)
|
pixelOwner = null;
|
||||||
|
foreach (Sprite spr in sprites)
|
||||||
{
|
{
|
||||||
sprData = 0;
|
sprData = 0;
|
||||||
sprPixel = pixel;
|
sprPixel = pixel;
|
||||||
|
|
||||||
Sprite spr = sprites[j];
|
|
||||||
|
|
||||||
if (spr.x == rasterX)
|
if (spr.x == rasterX)
|
||||||
spr.shiftEnable = true;
|
spr.shiftEnable = true;
|
||||||
|
|
||||||
|
@ -157,14 +151,14 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
if (spr.multicolor)
|
if (spr.multicolor)
|
||||||
{
|
{
|
||||||
sprData = (spr.sr & 0xC00000);
|
sprData = (spr.sr & srSpriteMaskMC);
|
||||||
if (spr.multicolorCrunch && spr.xCrunch && !rasterXHold)
|
if (spr.multicolorCrunch && spr.xCrunch && !rasterXHold)
|
||||||
spr.sr <<= 2;
|
spr.sr <<= 2;
|
||||||
spr.multicolorCrunch ^= spr.xCrunch;
|
spr.multicolorCrunch ^= spr.xCrunch;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprData = (spr.sr & 0x800000);
|
sprData = (spr.sr & srSpriteMask);
|
||||||
if (spr.xCrunch && !rasterXHold)
|
if (spr.xCrunch && !rasterXHold)
|
||||||
spr.sr <<= 1;
|
spr.sr <<= 1;
|
||||||
}
|
}
|
||||||
|
@ -172,31 +166,31 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
|
|
||||||
if (sprData != 0)
|
if (sprData != 0)
|
||||||
{
|
{
|
||||||
if (sprData == 0x400000)
|
|
||||||
sprPixel = spriteMulticolor0;
|
|
||||||
else if (sprData == 0x800000)
|
|
||||||
sprPixel = spr.color;
|
|
||||||
else if (sprData == 0xC00000)
|
|
||||||
sprPixel = spriteMulticolor1;
|
|
||||||
|
|
||||||
// sprite-sprite collision
|
// sprite-sprite collision
|
||||||
if (pixelOwner >= 8)
|
if (pixelOwner == null)
|
||||||
{
|
{
|
||||||
if (!spr.priority || ((sr & srMask) == 0))
|
if (!spr.priority || (pixelData == 0))
|
||||||
pixel = sprPixel;
|
{
|
||||||
pixelOwner = j;
|
if (sprData == srSpriteMask1)
|
||||||
|
pixel = spriteMulticolor0;
|
||||||
|
else if (sprData == srSpriteMask2)
|
||||||
|
pixel = spr.color;
|
||||||
|
else if (sprData == srSpriteMask3)
|
||||||
|
pixel = spriteMulticolor1;
|
||||||
|
}
|
||||||
|
pixelOwner = spr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!borderOnVertical)
|
if (!borderOnVertical)
|
||||||
{
|
{
|
||||||
spr.collideSprite = true;
|
spr.collideSprite = true;
|
||||||
sprites[pixelOwner].collideSprite = true;
|
pixelOwner.collideSprite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sprite-data collision
|
// sprite-data collision
|
||||||
if (!borderOnVertical && ((sr & srMask) != 0))
|
if (!borderOnVertical && (pixelData < srMask2))
|
||||||
{
|
{
|
||||||
spr.collideData = true;
|
spr.collideData = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
int srMask2;
|
int srMask2;
|
||||||
int srMask3;
|
int srMask3;
|
||||||
int srMaskMC;
|
int srMaskMC;
|
||||||
|
int srSpriteMask;
|
||||||
|
int srSpriteMask0;
|
||||||
|
int srSpriteMask1;
|
||||||
|
int srSpriteMask2;
|
||||||
|
int srSpriteMask3;
|
||||||
|
int srSpriteMaskMC;
|
||||||
bool vblank;
|
bool vblank;
|
||||||
int vblankEnd;
|
int vblankEnd;
|
||||||
int vblankStart;
|
int vblankStart;
|
||||||
|
@ -92,6 +98,20 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
|
|
||||||
public void HardReset()
|
public void HardReset()
|
||||||
{
|
{
|
||||||
|
// *** SHIFT REGISTER BITMASKS ***
|
||||||
|
srMask0 = 0x00000;
|
||||||
|
srMask1 = 0x20000;
|
||||||
|
srMask2 = srMask1 << 1;
|
||||||
|
srMask3 = srMask1 | srMask2;
|
||||||
|
srMask = srMask2;
|
||||||
|
srMaskMC = srMask3;
|
||||||
|
srSpriteMask0 = 0x000000;
|
||||||
|
srSpriteMask1 = 0x400000;
|
||||||
|
srSpriteMask2 = srSpriteMask1 << 1;
|
||||||
|
srSpriteMask3 = srSpriteMask1 | srSpriteMask2;
|
||||||
|
srSpriteMask = srSpriteMask2;
|
||||||
|
srSpriteMaskMC = srSpriteMask3;
|
||||||
|
|
||||||
pinAEC = true;
|
pinAEC = true;
|
||||||
pinBA = true;
|
pinBA = true;
|
||||||
pinIRQ = true;
|
pinIRQ = true;
|
||||||
|
@ -141,12 +161,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
spriteMulticolor0 = 0;
|
spriteMulticolor0 = 0;
|
||||||
spriteMulticolor1 = 0;
|
spriteMulticolor1 = 0;
|
||||||
sr = 0;
|
sr = 0;
|
||||||
srMask0 = 0x000000;
|
|
||||||
srMask1 = 0x200000;
|
|
||||||
srMask2 = srMask1 << 1;
|
|
||||||
srMask3 = srMask1 | srMask2;
|
|
||||||
srMask = srMask2;
|
|
||||||
srMaskMC = srMask3;
|
|
||||||
vblank = true;
|
vblank = true;
|
||||||
vc = 0;
|
vc = 0;
|
||||||
vcbase = 0;
|
vcbase = 0;
|
||||||
|
|
|
@ -38,9 +38,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
else
|
else
|
||||||
result.Add(0);
|
result.Add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hBlankL = false;
|
|
||||||
bool hBlankR = false;
|
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
// pipeline raster X delay
|
// pipeline raster X delay
|
||||||
|
@ -48,13 +45,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
result[i] |= pipelineHoldX;
|
result[i] |= pipelineHoldX;
|
||||||
|
|
||||||
// pipeline border checks
|
// pipeline border checks
|
||||||
if (timing[i] == 0x01C)
|
if (timing[i] == 0x018)
|
||||||
result[i] |= pipelineChkBrdL1;
|
result[i] |= pipelineChkBrdL1;
|
||||||
if (timing[i] == 0x020)
|
if (timing[i] == 0x01C)
|
||||||
result[i] |= pipelineChkBrdL0;
|
result[i] |= pipelineChkBrdL0;
|
||||||
if (timing[i] == 0x150)
|
if (timing[i] == 0x14C)
|
||||||
result[i] |= pipelineChkBrdR0;
|
result[i] |= pipelineChkBrdR0;
|
||||||
if (timing[i] == 0x15C)
|
if (timing[i] == 0x158)
|
||||||
result[i] |= pipelineChkBrdR1;
|
result[i] |= pipelineChkBrdR1;
|
||||||
if (timing[i] == (hblankStart & 0xFFD))
|
if (timing[i] == (hblankStart & 0xFFD))
|
||||||
result[i] |= pipelineHBlankR;
|
result[i] |= pipelineHBlankR;
|
||||||
|
|
|
@ -72,7 +72,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
public void ExecutePhase1()
|
public void ExecutePhase1()
|
||||||
{
|
{
|
||||||
//xScroll = 1;
|
//xScroll = 1;
|
||||||
bitmapColumn = 8 - xScroll;
|
|
||||||
{
|
{
|
||||||
// raster IRQ compare
|
// raster IRQ compare
|
||||||
if ((cycle == rasterIrqLineXCycle && rasterLine > 0) || (cycle == rasterIrqLine0Cycle && rasterLine == 0))
|
if ((cycle == rasterIrqLineXCycle && rasterLine > 0) || (cycle == rasterIrqLine0Cycle && rasterLine == 0))
|
||||||
|
@ -177,10 +176,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
|
|
||||||
{
|
{
|
||||||
//borderL = columnSelect ? 0x018 : 0x01F;
|
borderL = columnSelect ? 0x018 : 0x01F;
|
||||||
//borderR = columnSelect ? 0x158 : 0x14F;
|
borderR = columnSelect ? 0x158 : 0x14F;
|
||||||
borderL = columnSelect ? 28 : 35;
|
//borderL = columnSelect ? 28 : 35;
|
||||||
borderR = columnSelect ? 348 : 339;
|
//borderR = columnSelect ? 348 : 339;
|
||||||
borderT = rowSelect ? 0x033 : 0x037;
|
borderT = rowSelect ? 0x033 : 0x037;
|
||||||
borderB = rowSelect ? 0x0FB : 0x0F7;
|
borderB = rowSelect ? 0x0FB : 0x0F7;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue