Пример #1
0
        public MainPage()
        {
            if (!TestRenderMode())
                return;

            screenData = new uint[640 * 320];

            spriteBatch = new SpriteBatch(GraphicsDeviceManager.Current.GraphicsDevice);

            RomItems = new List<string>(RomLoader.GetRomList());

            texture = new Texture2D(GraphicsDeviceManager.Current.GraphicsDevice, 640, 320, false, SurfaceFormat.Color);

            InitializeComponent();

            this.KeyDown += new KeyEventHandler(RootVisual_KeyDown);
            this.KeyUp += new KeyEventHandler(RootVisual_KeyUp);

            cpu = new Chip8();
            timer = new DispatcherTimer();
            bitmap = new WriteableBitmap(640, 320);

            //screen.Source = bitmap;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / FPU);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            string programpath = "test.bin";
            var chip8 = new Chip8();

            if(args.Length > 0) {
                programpath = args[0];
                chip8.Run(programpath);
            }
        }
Пример #3
0
        private Chip8 GetCpuInstance(byte[] rom, int steps = 0)
        {
            Chip8 cpu = new Chip8();
            cpu.LoadRom(rom);

            if (steps == 0)
                steps = rom.Length / 2;

            ExecuteCommandsNTime(cpu, steps);

            return cpu;
        }
Пример #4
0
 private void ExecuteCommandsNTime(Chip8 cpu, int number)
 {
     for (int i = 0; i < number; i++)
         cpu.ExecuteNextOpcode();
 }