commodore64: sprite priority fixed and collision detection added

This commit is contained in:
saxxonpike 2012-11-09 15:50:16 +00:00
parent 66c1fc68f6
commit cd7ab3b6f0
1 changed files with 68 additions and 72 deletions

View File

@ -859,9 +859,10 @@ namespace BizHawk.Emulation.Computers.Commodore64
private void PerformCycleRender() private void PerformCycleRender()
{ {
int spritePixel;
int inputPixel; int inputPixel;
int outputPixel; int outputPixel;
int spriteBits;
int spritePixel;
int spritePixelOwner; int spritePixelOwner;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
@ -902,32 +903,29 @@ namespace BizHawk.Emulation.Computers.Commodore64
// render plotter // render plotter
if (idle) if (idle)
{
inputPixel = regs.BxC[0]; inputPixel = regs.BxC[0];
}
else else
{
inputPixel = Plotter(); inputPixel = Plotter();
}
// render sprites // render sprites
outputPixel = pixelBuffer[pixelBufferIndex]; outputPixel = pixelBuffer[pixelBufferIndex];
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
int spriteBits; if (regs.MD[j])
{
if (regs.MxX[j] == rasterOffsetX) if (regs.MxX[j] == rasterOffsetX)
{ {
regs.MSRA[j] = true; regs.MSRA[j] = true;
regs.MSRC[j] = 24; regs.MSRC[j] = 25;
} }
if (regs.MD[j] && regs.MSRA[j]) if (regs.MSRA[j])
{ {
// multicolor consumes two bits per pixel // multicolor consumes two bits per pixel and is forced wide
if (regs.MxMC[j]) if (regs.MxMC[j])
{ {
spriteBits = (int)((regs.MSR[j] >> 30) & 0x3); spriteBits = (int)((regs.MSR[j] >> 30) & 0x3);
if ((regs.MxXE[j] == false) || (rasterOffsetX & 0x1) != (regs.MxX[j] & 0x1)) if ((rasterOffsetX & 0x1) != (regs.MxX[j] & 0x1))
{ {
regs.MSR[j] <<= 2; regs.MSR[j] <<= 2;
regs.MSRC[j]--; regs.MSRC[j]--;
@ -936,8 +934,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
else else
{ {
spriteBits = (int)((regs.MSR[j] >> 30) & 0x2); spriteBits = (int)((regs.MSR[j] >> 30) & 0x2);
// if ((!regs.MxXE[j]) || (rasterOffsetX & 0x1) != (regs.MxX[j] & 0x1))
if ((regs.MxXE[j] == false) || (rasterOffsetX & 0x1) != (regs.MxX[j] & 0x1))
{ {
regs.MSR[j] <<= 1; regs.MSR[j] <<= 1;
regs.MSRC[j]--; regs.MSRC[j]--;
@ -970,7 +967,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
if (spritePixelOwner == -1) if (spritePixelOwner == -1)
{ {
spritePixelOwner = j; spritePixelOwner = j;
if (regs.MxDP[j] || (!regs.MxDP[j] && !pixelBufferForeground[pixelBufferIndex])) if (!regs.MxDP[j] || (!pixelBufferForeground[pixelBufferIndex]))
{ {
outputPixel = spritePixel; outputPixel = spritePixel;
} }
@ -978,22 +975,21 @@ namespace BizHawk.Emulation.Computers.Commodore64
else else
{ {
// a sprite already occupies this space // a sprite already occupies this space
//regs.MxM[spritePixelOwner] = true; regs.MxM[spritePixelOwner] = true;
//regs.MxM[j] = true; regs.MxM[j] = true;
//regs.IMMC = true; regs.IMMC = true;
} }
if (dataForeground) if (dataForeground)
{ {
//regs.MxD[j] = true; regs.MxD[j] = true;
//regs.IMBC = true; regs.IMBC = true;
} }
} }
} }
if (regs.MSRC[j] == 0) if (regs.MSRC[j] == 0)
regs.MSRA[j] = false; regs.MSRA[j] = false;
} }
}
} }
// send pixel to bitmap // send pixel to bitmap