Ejemplo n.º 1
0
        bool TestQuick()
        {
            Console.Write("Running general quick tests... ");

            using (FileStream file = new FileStream("quick.bin", FileMode.Open, FileAccess.Read))
                _ram.Load(file, 0x4000);

            // Set reset vector to the start of the code
            _ram.Write16(0xFFFC, 0x4000);
            // Set IRQ vector to test BRK
            _ram.Write16(0xFFFE, 0x45A4); // IRQ
            _cpu.Reset();

            Display = true;
            while (_cpu.PC != 0x45CA)
            {
                _cpu.Process();
            }
            Display = false;

            byte result = _ram.Read(0x0210);

            //Console.SetCursorPosition(x, y);
            if (result == 0xFF)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("OK!");
                Console.ResetColor();
                return(true);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("FAIL: " + result.ToString("X2"));
            Console.ResetColor();
            return(false);
        }
Ejemplo n.º 2
0
    void ExecuteLine(ushort lineNum, bool visible)
    {
        UpdateLineCounterAndIRQ(lineNum);

        int targetCycles = VIC2.CYCLES_PER_LINE * lineNum;

        while (_processor.Cycles < targetCycles && !_processor.Jam)
        {
            _processor.Process();
        }

        if (visible)
        {
            _vic2.RenderNextLine();
        }
    }
Ejemplo n.º 3
0
        void Run()
        {
            _ram = new RAM64K();
            _cpu = new MOS6502(_ram);

            Console.Title           = "6502";
            Console.BackgroundColor = (ConsoleColor)6;
            Console.ForegroundColor = (ConsoleColor)14;
            Console.SetWindowSize(40, 26);
            Console.SetBufferSize(40, 26);
            Console.CursorSize = 100;

            //TestB();
            //return;

            //_ram.Write(0x0000, 0x2F);
            //_ram.Write(0x0001, 0x37);

            //_ram.Write(0xD018, 21);

            using (FileStream file = new FileStream("BASIC.ROM", FileMode.Open, FileAccess.Read))
                _ram.Load(file, 0xA000, 8192);

            using (FileStream file = new FileStream("CHAR.ROM", FileMode.Open, FileAccess.Read))
                _ram.Load(file, 0xD000, 4096);

            using (FileStream file = new FileStream("KERNAL.ROM", FileMode.Open, FileAccess.Read))
                _ram.Load(file, 0xE000, 8192);

            byte[] screenbuffer = new byte[1000];

            byte raster = 0;

            while (true)
            {
                _cpu.Process();
                //Console.WriteLine(cpu.PC.ToString("X4"));
                _ram.Write(0xD012, raster);
                raster++;// if (raster == 312) raster = 0;
                //Console.Clear();
                if (_cpu.Cycles % 10000 == 0)
                {
                    if (Console.KeyAvailable)
                    {
                        ConsoleKeyInfo key = Console.ReadKey(true);
                        _ram.Write16(0xDC00, (ushort)key.Key);
                    }
                    else
                    {
                        _ram.Write16(0xDC00, 0x0);
                    }

                    //Console.Title = _cpu.PC.ToString("X4");
                    Console.Title = _ram.Read16(0xDC00).ToString();

                    // Address where the C64 character screen buffer is located
                    ushort screenAddress = (ushort)(_ram[0x0288] << 8);

                    for (ushort i = 0; i < 1000; i++)
                    {
                        byte data = _ram.Read((ushort)(i + screenAddress));
                        if (data < 0x20)
                        {
                            data += 0x40;
                        }
                        //data &= 0x7F; // Reverse
                        if (data != screenbuffer[i])
                        {
                            Console.CursorVisible = false;
                            if ((data & 0x80) != 0)
                            {
                                Console.BackgroundColor = (ConsoleColor)14;
                                Console.ForegroundColor = (ConsoleColor)6;
                            }
                            Console.SetCursorPosition(i % 40, i / 40);
                            Console.Write((char)(data));
                            if ((data & 0x80) != 0)
                            {
                                Console.BackgroundColor = (ConsoleColor)6;
                                Console.ForegroundColor = (ConsoleColor)14;
                            }
                        }
                        screenbuffer[i] = data;
                    }
                    if (_ram[0x00CC] == 0) // Draw cursor when visible
                    {
                        int x = _ram[0x00CA];
                        int y = _ram[0x00C9];
                        if (Console.CursorLeft != x || Console.CursorTop != y)
                        {
                            Console.SetCursorPosition(x, y);
                        }
                        if (!Console.CursorVisible)
                        {
                            Console.CursorVisible = true;
                        }
                    }
                }
                //System.Threading.Thread.Sleep(50);

                /*
                 * cpu.Op();
                 * Console.WriteLine("test00: " + ram.Read(0x022A).ToString("X2"));
                 * Console.WriteLine("test01: " + ram.Read(0xA9).ToString("X2"));
                 * Console.WriteLine("test02: " + ram.Read(0x71).ToString("X2"));
                 * System.Threading.Thread.Sleep(50);
                 * if (cpu.PC == 0x45C0)
                 * {
                 *
                 *  Console.WriteLine("FINAL: " + ram.Read(0x0210).ToString("X2"));
                 *  System.Threading.Thread.Sleep(50);
                 * }
                 */
            }
        }