Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error no ROM file specified");
                return;
            }
            else
            {
                if (!File.Exists(args[0]))
                {
                    Console.WriteLine($"Error ROM file ({args[0]}) not found.");
                }
                else
                {
                    ConsoleAudio    audio    = new ConsoleAudio();
                    ConsoleInput    input    = new ConsoleInput();
                    ConsoleGraphics graphics = new ConsoleGraphics();

                    graphics.ClearScreen();
                    Chip8 chp8 = new Chip8(graphics, audio, input);

                    byte[] rom = LoadROMFile(args[0]);
                    //LoadROM
                    chp8.LoadROM(rom);

                    Console.WriteLine("Starting Emulator");

                    try
                    {
                        while (true)
                        {
                            chp8.Tick();
                            graphics.BlitScreen();
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error no ROM file specified");
                return;
            }
            else
            {
                bool debugMode     = false;
                int  filePathIndex = 0;

                if (args[0].ToUpper() == "-DEBUG")
                {
                    debugMode     = true;
                    filePathIndex = 1;
                }

                if (!File.Exists(args[filePathIndex]))
                {
                    Console.WriteLine($"Error ROM file ({args[filePathIndex]}) not found.");
                }
                else
                {
                    audio    = new Audio();
                    input    = new Input();
                    graphics = new Graphics();

                    chp8 = new Chip8(graphics, audio, input);

                    //byte[] rom = LoadROMFile(@"/home/chippy/src/dotnet/core-chip8/chip8.roms/PONG");
                    byte[] rom = LoadROMFile(args[filePathIndex]);
                    //LoadROM
                    chp8.LoadROM(rom);

                    try
                    {
                        Gtk.Application.Init();
                        emulatorWindow              = new EmulatorWindow("Core Chip8");
                        emulatorWindow.DeleteEvent += delegate
                        {
                            KILL_EMULATION = true;
                            Gtk.Application.Quit();
                        };

                        if (debugMode)
                        {
                            LoadDebugEnvironment();
                        }

                        emulatorWindow.KeyPressEvent += new KeyPressEventHandler(input.KeyPressEventHandler);
                        emulatorWindow.ShowAll();

                        Thread t = new Thread(new ThreadStart(BackgroundTick));
                        t.Start();

                        Gtk.Application.Run();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }
        }