c64- clean tabs, document some regs, VIC screen memory fetch added
This commit is contained in:
parent
747c3db7cb
commit
97bdd9be9c
|
@ -44,6 +44,9 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
// initialize memory (this must be done AFTER all other chips are initialized)
|
||||
string romPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "C64Kernal");
|
||||
mem = new Memory(romPath, vic, sid, cia1, cia2);
|
||||
vic.mem = mem;
|
||||
|
||||
// initialize ports
|
||||
cia2.ReadPortA = mem.CIA2ReadPortA;
|
||||
cia2.ReadPortB = mem.CIA2ReadPortB;
|
||||
cia2.WritePortA = mem.CIA2WritePortA;
|
||||
|
|
|
@ -53,16 +53,20 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
public bool characterFetch;
|
||||
public int characterFetchOffset;
|
||||
public int characterMemoryOffset;
|
||||
public byte[] charBuffer;
|
||||
public int charBufferOffset;
|
||||
public bool fetching;
|
||||
public int fetchOffsetX;
|
||||
public int screenMemoryOffset;
|
||||
|
||||
// lightpen
|
||||
public int lightPenX;
|
||||
public int lightPenY;
|
||||
public int lightPenX; // LPX
|
||||
public int lightPenY; // LPY
|
||||
|
||||
// raster
|
||||
public int[] backgroundColor;
|
||||
public bool backgroundMode;
|
||||
public bool bitmapMode;
|
||||
public int[] backgroundColor; // B0C
|
||||
public bool backgroundMode; // ECM
|
||||
public bool bitmapMode; // BMM
|
||||
public int borderBottom;
|
||||
public int borderColor;
|
||||
public int borderLeft;
|
||||
|
@ -70,22 +74,21 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
public bool borderOnVertical;
|
||||
public int borderRight;
|
||||
public int borderTop;
|
||||
public byte[] charBuffer;
|
||||
public int charBufferOffset;
|
||||
public bool extendHeight;
|
||||
public bool extendWidth;
|
||||
public int horizontalScroll;
|
||||
public bool multiColorMode;
|
||||
public bool extendHeight; // RSEL
|
||||
public bool extendWidth; // CSEL
|
||||
public int horizontalScroll; // XSCROLL
|
||||
public bool multiColorMode; // MCM
|
||||
public int rasterInterruptLine;
|
||||
public int rasterLineLeft;
|
||||
public int rasterOffset;
|
||||
public int rasterOffsetX;
|
||||
public int rasterOffsetY;
|
||||
public int rasterOffsetY; // RASTER, RST8
|
||||
public int rasterTotalLines;
|
||||
public int rasterWidth;
|
||||
public int renderOffset;
|
||||
public bool screenEnabled;
|
||||
public int verticalScroll;
|
||||
public bool resetBit; // RES
|
||||
public bool screenEnabled; // DEN
|
||||
public int verticalScroll; // YSCROLL
|
||||
public int visibleBottom;
|
||||
public int visibleHeight;
|
||||
public int visibleLeft;
|
||||
|
@ -96,19 +99,20 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
public int visibleWidth;
|
||||
|
||||
// sprites
|
||||
public bool[] spriteBackgroundCollision;
|
||||
public bool[] spriteCollision;
|
||||
public int[] spriteColor;
|
||||
public bool[] spriteEnabled;
|
||||
public int[] spriteExtraColor;
|
||||
public bool[] spriteMultiColor;
|
||||
public bool[] spritePriority;
|
||||
public bool[] spriteStretchHorizontal;
|
||||
public bool[] spriteStretchVertical;
|
||||
public int[] spriteX;
|
||||
public int[] spriteY;
|
||||
public bool[] spriteBackgroundCollision; // M0D
|
||||
public bool[] spriteCollision; // M0M
|
||||
public int[] spriteColor; // M0C
|
||||
public bool[] spriteEnabled; // M0E
|
||||
public int[] spriteExtraColor; // MM0
|
||||
public bool[] spriteMultiColor; // M0MC
|
||||
public bool[] spritePriority; // M0DP
|
||||
public bool[] spriteStretchHorizontal; // M0XE
|
||||
public bool[] spriteStretchVertical; // M0YE
|
||||
public int[] spriteX; // M0X, M0X8
|
||||
public int[] spriteY; // M0Y
|
||||
|
||||
public VicSignals cpuSignal;
|
||||
public Memory mem;
|
||||
public byte[] regs;
|
||||
|
||||
public VicII(VicSignals signals, VicIIMode videoMode)
|
||||
|
@ -134,6 +138,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
borderRight = 0x158;
|
||||
borderTop = 0x033;
|
||||
borderBottom = 0x0FA;
|
||||
characterFetchOffset = rasterWidth - 3;
|
||||
break;
|
||||
case VicIIMode.PAL:
|
||||
break;
|
||||
|
@ -204,6 +209,29 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
if (rasterOffsetX == borderRight)
|
||||
borderOnHorizontal = true;
|
||||
|
||||
if ((rasterOffsetX == fetchOffsetX) && ((rasterOffsetY & 0x07) == verticalScroll))
|
||||
{
|
||||
cpuSignal.Lock();
|
||||
fetching = true;
|
||||
characterFetchOffset = (rasterOffsetY >> 3) * 40;
|
||||
charBufferOffset = 0;
|
||||
}
|
||||
|
||||
if (fetching)
|
||||
{
|
||||
if (charBufferOffset >= 0)
|
||||
{
|
||||
charBuffer[charBufferOffset] = mem.VicRead((ushort)(screenMemoryOffset + characterFetchOffset));
|
||||
characterFetchOffset++;
|
||||
}
|
||||
charBufferOffset++;
|
||||
if (charBufferOffset == 40)
|
||||
{
|
||||
fetching = false;
|
||||
cpuSignal.Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
if (borderOnVertical || borderOnHorizontal)
|
||||
{
|
||||
WritePixel(borderColor);
|
||||
|
@ -353,7 +381,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
horizontalScroll = val & 0x07;
|
||||
extendWidth = ((val & 0x08) != 0x00);
|
||||
multiColorMode = ((val & 0x10) != 0x00);
|
||||
bitmapMode = ((val & 0x20) != 0x00);
|
||||
resetBit = ((val & 0x20) != 0x00);
|
||||
val |= 0xC0;
|
||||
break;
|
||||
case 0x17:
|
||||
|
|
Loading…
Reference in New Issue