From 7c532fbd01eff571a5ecfd561748c87dacd22b65 Mon Sep 17 00:00:00 2001 From: saxxonpike Date: Thu, 15 Aug 2013 09:49:38 +0000 Subject: [PATCH] Commodore64: Experimental video chip things. --- BizHawk.Emulation/BizHawk.Emulation.csproj | 4 + .../Commodore64/Experimental/MOS6569.cs | 14 ++ .../Commodore64/Experimental/Vic.Interface.cs | 126 ++++++++++++++++++ .../Commodore64/Experimental/Vic.Internal.cs | 52 ++++++++ .../Commodore64/Experimental/Vic.Rom.cs | 11 ++ 5 files changed, 207 insertions(+) create mode 100644 BizHawk.Emulation/Computers/Commodore64/Experimental/MOS6569.cs create mode 100644 BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Interface.cs create mode 100644 BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Internal.cs create mode 100644 BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Rom.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 2af4bec652..3e270dcca8 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -98,6 +98,10 @@ + + + + diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/MOS6569.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/MOS6569.cs new file mode 100644 index 0000000000..090587e1b2 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/MOS6569.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64.Experimental +{ + public class MOS6569 : VIC + { + public MOS6569() + { + } + } +} diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Interface.cs new file mode 100644 index 0000000000..bbd0041fc0 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Interface.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64.Experimental +{ + public abstract partial class VIC + { + public Func InputAddress; + public Func InputChipSelect; + public Func InputData; + + class Sprite + { + public int Color; + public bool DataCollision; + public bool Enabled; + public bool ExpandX; + public bool ExpandY; + public bool Multicolor; + public bool Priority; + public bool SpriteCollision; + public int X; + public int Y; + } + + int[] backgroundColor; + bool bitmapMode; + int borderColor; + int characterBitmap; + bool columnSelect; + bool dataCollisionInterrupt; + bool displayEnable; + bool extraColorMode; + byte interruptEnableRegister; + bool lightPenInterrupt; + int lightPenX; + int lightPenY; + bool multiColorMode; + bool rasterInterrupt; + int rasterX; + int rasterY; + bool reset; + bool rowSelect; + bool spriteCollisionInterrupt; + int[] spriteMultiColor; + Sprite[] sprites; + int videoMemory; + int xScroll; + int yScroll; + + public VIC() + { + backgroundColor = new int[4]; + spriteMultiColor = new int[2]; + sprites = new Sprite[8]; + for (int i = 0; i < 8; i++) + sprites[i] = new Sprite(); + } + + /// + /// Desired 14-bit address from the VIC. + /// + public int OutputAddress() + { + return ADDR; + } + + /// + /// AEC pin output. + /// + public bool OutputAEC() + { + return AEC; + } + + /// + /// BA pin output. + /// + public bool OutputBA() + { + return BA; + } + + /// + /// CAS pin output. + /// + public bool OutputCAS() + { + return CAS; + } + + /// + /// 12-bit data output from the VIC. + /// + public int OutputData() + { + return DATA; + } + + /// + /// IRQ pin output. + /// + public bool OutputInterrupt() + { + return IRQ; + } + + /// + /// PHI0 pin output. + /// + public bool OutputPHI0() + { + return PHI0; + } + + /// + /// RAS pin output. + /// + public bool OutputRAS() + { + return RAS; + } + } +} diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Internal.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Internal.cs new file mode 100644 index 0000000000..a72f11e794 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Internal.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64.Experimental +{ + public partial class VIC + { + int ADDR; + bool AEC; + bool BA; + bool CAS; + int DATA; + bool IRQ; + bool PHI0; + bool RAS; + + bool badLineCondition; + bool badLineEnable; + bool idleState; + int pixelTimer; + int rowCounter; + int videoCounter; + int videoCounterBase; + int videoMatrixLineIndex; + + public void Execute() + { + if (pixelTimer == 0) + { + PHI0 = !PHI0; + pixelTimer = 8; + + badLineEnable |= (rasterY == 0x30 && displayEnable); + if (!PHI0) + { + badLineCondition = ( + badLineEnable && + rasterY >= 0x030 && + rasterY <= 0x0F7 && + (rasterY & 0x007) == yScroll + ); + if (!idleState && badLineCondition) + idleState = true; + } + } + pixelTimer--; + + } + } +} diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Rom.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Rom.cs new file mode 100644 index 0000000000..383f8be5e3 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Vic.Rom.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64.Experimental +{ + public partial class Vic + { + } +}