示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ROM          rom;
            MemoryRouter mr;
            GbBootUp     boot;
            CPU          cpu;

            try
            {
                // Load ROM
                rom = new ROM(@"I:\rom.gb", "");

                // Setup MemoryRouter
                mr = new MemoryRouter(rom.Memory);

                // Setup CPU
                cpu = new CPU(mr);

                // Give the MemoryRouter access to the CPU;
                mr.CPU = cpu;

                // BOOT!
                boot = new GbBootUp();
                boot.InitCPU(cpu);

                int time1 = Environment.TickCount;
                int ops   = 0;

                while (cpu.Running)
                {
                    //Console.WriteLine("AF: 0x{0} BC: 0x{1} DE: 0x{2}, HL: 0x{3} PC: 0x{4} SP: 0x{5}, Z: {6} N: {7} H: {8} C: {9}",
                    //                   ((cpu.A << 8) + cpu.F).ToString("X"),
                    //                   ((cpu.B << 8) + cpu.C).ToString("X"),
                    //                   ((cpu.D << 8) + cpu.E).ToString("X"),
                    //                   ((cpu.H << 8) + cpu.L).ToString("X"),
                    //                   cpu.PC.ToString("X"),
                    //                   cpu.SP.ToString("X"),
                    //                   cpu.FLAG_Z, cpu.FLAG_N, cpu.FLAG_HC, cpu.FLAG_C);
                    cpu.ExecuteOP();
                    ops++;

                    if (Environment.TickCount > time1 + 1000)
                    {
                        Console.Title = ops.ToString();
                        ops           = 0;
                        time1         = Environment.TickCount;
                        //Application.DoEvents();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nException: {0}", ex.Message);
            }
        }
示例#2
0
文件: Gameboy.cs 项目: RykoL/geekboy
        public Gameboy(Rom rom, bool useBios = true)
        {
            MemoryRouter = new MemoryRouter(rom.Memory);
            Cpu = new Cpu(MemoryRouter);
            timer = new GameboyTimer();
            Video = new Video();
            Joypad = new Joypad();
            Audio = new Audio();
            Disassembler = new Disassembler(MemoryRouter);

            Video.MemoryRouter = MemoryRouter;
            MemoryRouter.Video = Video;
            Joypad.MemoryRouter = MemoryRouter;
            MemoryRouter.Joypad = Joypad;
            timer.MemoryRouter = MemoryRouter;
            MemoryRouter.Timer = timer;
            MemoryRouter.Audio = Audio;

            if (!useBios) InitDevice();
        }