commodore64: implemented 12 pixel VIC delay when rendering display window
This commit is contained in:
parent
4d1ae5cb30
commit
89344449a2
|
@ -492,6 +492,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
public bool displayEnabled;
|
public bool displayEnabled;
|
||||||
public bool hBlank;
|
public bool hBlank;
|
||||||
public bool idle;
|
public bool idle;
|
||||||
|
public int[] pixelBuffer = new int[12];
|
||||||
|
public int pixelBufferIndex = 0;
|
||||||
public int rasterInterruptLine;
|
public int rasterInterruptLine;
|
||||||
public int rasterLineLeft;
|
public int rasterLineLeft;
|
||||||
public int rasterOffset;
|
public int rasterOffset;
|
||||||
|
@ -503,6 +505,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
public byte[,] spriteData;
|
public byte[,] spriteData;
|
||||||
public int spriteFetchCycle;
|
public int spriteFetchCycle;
|
||||||
public int spriteFetchIndex;
|
public int spriteFetchIndex;
|
||||||
|
public bool spriteForeground;
|
||||||
public ushort[] spritePointers;
|
public ushort[] spritePointers;
|
||||||
public int spriteFetchStartCycle;
|
public int spriteFetchStartCycle;
|
||||||
public VicIITask task;
|
public VicIITask task;
|
||||||
|
@ -623,7 +626,6 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
mem.VicRead(0x3FFF);
|
mem.VicRead(0x3FFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void HardReset()
|
public void HardReset()
|
||||||
{
|
{
|
||||||
idle = true;
|
idle = true;
|
||||||
|
@ -665,7 +667,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
refreshAddress = (refreshAddress - 1) & 0xFF;
|
refreshAddress = (refreshAddress - 1) & 0xFF;
|
||||||
refreshAddress |= 0x3F00;
|
refreshAddress |= 0x3F00;
|
||||||
}
|
}
|
||||||
else if (cycle >= 16 && cycle < 56)
|
else if (cycle >= 15 && cycle < 55)
|
||||||
{
|
{
|
||||||
// screen memory c-access
|
// screen memory c-access
|
||||||
if (badLine)
|
if (badLine)
|
||||||
|
@ -674,10 +676,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
colorMemory[regs.VMLI] = colorDataBus;
|
colorMemory[regs.VMLI] = colorDataBus;
|
||||||
characterMemory[regs.VMLI] = characterDataBus;
|
characterMemory[regs.VMLI] = characterDataBus;
|
||||||
}
|
}
|
||||||
|
signal.VicAEC = !badLine;
|
||||||
}
|
}
|
||||||
else if (cycle == 55)
|
else if (cycle == 56)
|
||||||
{
|
{
|
||||||
//signal.VicAEC = true;
|
signal.VicAEC = true;
|
||||||
}
|
}
|
||||||
else if (cycle == 57)
|
else if (cycle == 57)
|
||||||
{
|
{
|
||||||
|
@ -772,7 +775,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
// draw screen memory if needed
|
// draw screen memory if needed
|
||||||
if (!idle && cycle >= 16 && cycle < 56)
|
if (!idle && cycle >= 15 && cycle < 55)
|
||||||
{
|
{
|
||||||
// todo: implement XSCROLL properly
|
// todo: implement XSCROLL properly
|
||||||
// comparing to (rasterOffsetX & 0x7) seems to align
|
// comparing to (rasterOffsetX & 0x7) seems to align
|
||||||
|
@ -809,14 +812,35 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
borderOnMain = false;
|
borderOnMain = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// render pixel
|
// send pixel to bitmap
|
||||||
if (visibleRenderX && visibleRenderY)
|
if (visibleRenderX && visibleRenderY)
|
||||||
{
|
{
|
||||||
if (borderOnMain || borderOnVertical)
|
if (borderOnMain || borderOnVertical)
|
||||||
|
{
|
||||||
WritePixel(regs.EC);
|
WritePixel(regs.EC);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
WritePixel(Plotter());
|
{
|
||||||
|
WritePixel(pixelBuffer[pixelBufferIndex]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process 12 pixel delay
|
||||||
|
if (idle)
|
||||||
|
{
|
||||||
|
pixelBuffer[pixelBufferIndex] = regs.BxC[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pixelBuffer[pixelBufferIndex] = Plotter();
|
||||||
|
}
|
||||||
|
pixelBufferIndex++;
|
||||||
|
if (pixelBufferIndex == 12)
|
||||||
|
{
|
||||||
|
pixelBufferIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// advance raster X
|
||||||
characterColumn++;
|
characterColumn++;
|
||||||
rasterOffset++;
|
rasterOffset++;
|
||||||
rasterOffsetX++;
|
rasterOffsetX++;
|
||||||
|
@ -844,8 +868,12 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
byte charData = bitmapData;
|
byte charData = bitmapData;
|
||||||
charData <<= characterColumn;
|
charData <<= characterColumn;
|
||||||
if ((charData & 0x80) != 0x00)
|
if ((charData & 0x80) != 0x00)
|
||||||
|
{
|
||||||
|
spriteForeground = true;
|
||||||
return colorData;
|
return colorData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
spriteForeground = false;
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,10 +893,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
switch (charData)
|
switch (charData)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
spriteForeground = false;
|
||||||
return regs.BxC[1];
|
return regs.BxC[1];
|
||||||
case 2:
|
case 2:
|
||||||
|
spriteForeground = true;
|
||||||
return regs.BxC[2];
|
return regs.BxC[2];
|
||||||
case 3:
|
case 3:
|
||||||
|
spriteForeground = true;
|
||||||
return colorData & 0x07;
|
return colorData & 0x07;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -877,6 +908,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
return Plot000();
|
return Plot000();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
spriteForeground = false;
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,8 +920,12 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
byte charData = bitmapData;
|
byte charData = bitmapData;
|
||||||
charData <<= characterColumn;
|
charData <<= characterColumn;
|
||||||
if ((charData & 0x80) != 0x00)
|
if ((charData & 0x80) != 0x00)
|
||||||
|
{
|
||||||
|
spriteForeground = true;
|
||||||
return characterData >> 4;
|
return characterData >> 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
spriteForeground = false;
|
||||||
return characterData & 0xF;
|
return characterData & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,13 +943,17 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
switch (charData)
|
switch (charData)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
spriteForeground = false;
|
||||||
return characterData & 0xF;
|
return characterData & 0xF;
|
||||||
case 2:
|
case 2:
|
||||||
|
spriteForeground = true;
|
||||||
return characterData >> 4;
|
return characterData >> 4;
|
||||||
case 3:
|
case 3:
|
||||||
|
spriteForeground = true;
|
||||||
return colorData & 0xF;
|
return colorData & 0xF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
spriteForeground = false;
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,26 +965,33 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
byte charData = bitmapData;
|
byte charData = bitmapData;
|
||||||
charData <<= characterColumn;
|
charData <<= characterColumn;
|
||||||
if ((charData & 0x80) != 0x00)
|
if ((charData & 0x80) != 0x00)
|
||||||
|
{
|
||||||
|
spriteForeground = true;
|
||||||
return colorData;
|
return colorData;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
spriteForeground = false;
|
||||||
return regs.BxC[characterData >> 6];
|
return regs.BxC[characterData >> 6];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
spriteForeground = false;
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalid mode
|
// invalid mode (TODO: implement)
|
||||||
private int Plot101()
|
private int Plot101()
|
||||||
{
|
{
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalid mode
|
// invalid mode (TODO: implement)
|
||||||
private int Plot110()
|
private int Plot110()
|
||||||
{
|
{
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalid mode
|
// invalid mode (TODO: implement)
|
||||||
private int Plot111()
|
private int Plot111()
|
||||||
{
|
{
|
||||||
return regs.BxC[0];
|
return regs.BxC[0];
|
||||||
|
|
Loading…
Reference in New Issue