Beispiel #1
0
        public void TestRegisterPC()
        {
            ushort value;

            byte[]  blankMemory = new byte[65536];
            Lock    cpuLock     = new AlwaysOpenLock();
            CPU6510 cpu         = new CPU6510(blankMemory, cpuLock);

            value  = 0x00;
            cpu.PC = value;
            Assert.AreEqual(value, cpu.PC);

            // all bits in PCL
            value  = 0xff;
            cpu.PC = value;
            Assert.AreEqual(value, cpu.PC);

            // overflow into PCH
            value  = 0x0100;
            cpu.PC = value;
            Assert.AreEqual(value, cpu.PC);

            // do some random tests of the register
            Random rnd = new Random();

            for (int i = NUMBER_TEST_RUNS; i > 0; i--)
            {
                value  = (ushort)rnd.Next(0x00, 0xffff);
                cpu.PC = value;
                Assert.AreEqual(value, cpu.PC);
            }
        }
Beispiel #2
0
        public void TestRegisterPCH()
        {
            byte value, pcl;

            byte[]  blankMemory = new byte[65536];
            Lock    cpuLock     = new AlwaysOpenLock();
            CPU6510 cpu         = new CPU6510(blankMemory, cpuLock);

            value   = 0x00;
            cpu.PCH = value;
            Assert.AreEqual(value, cpu.PCH);

            // all bits set
            value   = 0xff;
            cpu.PCH = value;
            Assert.AreEqual(value, cpu.PCH);

            // do some random tests of the register
            Random rnd = new Random();

            for (int i = NUMBER_TEST_RUNS; i > 0; i--)
            {
                cpu.PC  = (ushort)rnd.Next(0x0000, 0xffff);
                pcl     = cpu.PCL;
                value   = (byte)rnd.Next(0x00, 0xff);
                cpu.PCH = value;
                Assert.AreEqual(value, cpu.PCH);
                Assert.AreEqual(pcl, cpu.PCL);
            }
        }
Beispiel #3
0
        public C64(string basicRomFileName, string characterRomFileName, string kernalRomFileName, bool isPal = true)
        {
            log = log = NLog.LogManager.GetCurrentClassLogger();

            if (isPal)
            {
                systemClockRate = CLOCK_PAL;
            }
            else
            {
                systemClockRate = CLOCK_NTSC;
            }

            memory = new byte[ushort.MaxValue + 1];
            Lock cpuLock = new AutoResetLock();

            cpu = new CPU6510(memory, cpuLock);

            basicRom = new byte[8192];
            loadRomFromFile(basicRom, basicRomFileName);
            characterRom = new byte[4096];
            loadRomFromFile(characterRom, characterRomFileName);
            kernalRom = new byte[8192];
            loadRomFromFile(kernalRom, kernalRomFileName);

            y1 = new SystemClock(cpuLock);
        }
Beispiel #4
0
        public static void Start(RendererSDL r, Network n)
        {
            string appDir =
                Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) +
                Path.DirectorySeparatorChar.ToString();

            renderer = r;
            renderer.ResetDrawState();
            network = n;
            kernal  = new Kernal(appDir + KERNALROM);
            basic   = new BASIC(appDir + BASICROM);
            charset = new Char(appDir + CHARROM);
            palette = new Palette();
            ram     = new Memory();
            vic     = new VIC();
            sid     = new SID();
            cia1    = new CIA1();
            cia2    = new CIA2();
            io      = new IO();
            cpu     = new CPU6510();

            cpu.Start();
        }
Beispiel #5
0
        public static void Dispose()
        {
            if (cpu != null)
            {
                cpu.Stop();

                while (!cpu.ThreadExited)
                {
                    Thread.Sleep(20);
                }
            }

            kernal  = null;
            basic   = null;
            charset = null;
            palette = null;
            ram     = null;
            vic     = null;
            sid     = null;
            cia1    = null;
            cia2    = null;
            io      = null;
            cpu     = null;
        }