Esempio n. 1
0
        static void Main(string[] args)
        {
            short[]        colorMap = new short[] { 1, 2 };
            IntPtr         screen   = default;
            NCursesDisplay display  = null;
            IChip8Device   device   = null;

            Func <bool>[] initializers =
            {
                () => InitializeNCurses(ref screen,        colorMap,        DefaultWidth, DefaultHeight),
                () => InitializeDisplayBuffer(ref display, screen,          colorMap),
                () => BuildDevice(ref device,              display.Buffer),
                () => LoadProgram(device,                  "program")
            };

            try
            {
                if (initializers.All(p => p()))
                {
                    Run(device, display);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine($"Caught an exception: {e.Message}");
            }

            NCurses.EndWin();
        }
Esempio n. 2
0
 private static void Run(IChip8Device device, NCursesDisplay display)
 {
     while (true)
     {
         device.Tick();
         display.Draw();
         System.Threading.Thread.Sleep(100);
     }
 }
Esempio n. 3
0
 private static bool InitializeDisplayBuffer(ref NCursesDisplay display, IntPtr screen, short[] colorMap)
 {
     display = new NCursesDisplay(DefaultWidth, DefaultHeight, screen, colorMap);
     return(true);
 }