Beispiel #1
0
        public void InputCallback(string keyName)
        {
            Console.WriteLine("Input recieved!# Input " + keyName);
            //Console.WriteLine(Gimme() + "+ data");
            if (keyName == "Up")
            {
                SDLWrapper.AddDrawableLib(SDLWrapper.GliPath + "glbasis.gli", "CURSORL");
            }
            if (keyName == "Down")
            {
                Drawable.drawers[new Random().Next(0, Drawable.drawers.Count)].position.x += 2;
            }
            if (keyName == "Left")
            {
                Console.WriteLine("FPS: " + SDLWrapper.GetFPS());
            }
            if (keyName == "Right")
            {
                a = GFXLib.Create(SDLWrapper.GliPath + "glbasis.gli");

                Console.WriteLine(a.pointer);
            }
            if (keyName == "D")
            {
                Console.WriteLine(a.GetAllImageNames()[0]);
            }
        }
Beispiel #2
0
        public frmMainForm()
        {
            InitializeComponent();

            // set up the graphics
            _sdlSDLWrapper = new SDLWrapper();
            _sdlSDLWrapper.Initialize();
            //sdl.CreateWindow(sWindowTitle, 100, 100, CHIP8.GRAPHICS_WIDTH * sizeMultiplier, CHIP8.GRAPHICS_HEIGHT * sizeMultiplier, WindowFlags.WINDOW_SHOWN);
            _sdlSDLWrapper.CreateWindowFor(this.Handle);
            _sdlSDLWrapper.CreateRenderer(SDLWrapper.DEFAULT_RENDERING_DRIVER, RendererFlags.RENDERER_ACCELERATED /* | RendererFlags.RENDERER_PRESENTVSYNC*/);
            //sdl.CreateRendererForWindow(f.Handle, SDLWrapper.DEFAULT_RENDERING_DRIVER, RendererFlags.RENDERER_SOFTWARE);
            _txDisplayTexture = _sdlSDLWrapper.CreateDynamicTexture(CHIP8.GRAPHICS_WIDTH, CHIP8.GRAPHICS_HEIGHT);
            _txLogoTexture    = _sdlSDLWrapper.CreateTextureFromBMP("CHIP-8.bmp");

            _sdlSDLWrapper.OnKeyPressed  += sdl_OnKeyPressedOrReleased;
            _sdlSDLWrapper.OnKeyReleased += sdl_OnKeyPressedOrReleased;

            SDLMixerWrapper mixer = new SDLMixerWrapper();

            mixer.Initialize();
            _sampleDing = mixer.LoadSample(@"Ding.wav");

            Application.Idle += Application_Idle;

            c8CHIP8.Init();
            c8CHIP8.onPlaySound    += c8CHIP8_onPlaySound;
            c8CHIP8.onDebugMessage += c8CHIP8_onDebugMessage;

            dbgConsole.Shown      += dbgConsole_Shown;
            dbgConsole.FormClosed += dbgConsole_FormClosed;
            dbgConsole.Disposed   += dbgConsole_Disposed;

            dbgWindow.Disposed += dbgWindow_Disposed;
            dbgWindow.onStart  += dbgWindow_onStart;
            dbgWindow.onStep   += dbgWindow_onStep;

            _palette = new SimpleSDLWrapperDotNET.Color[] {
                new SimpleSDLWrapperDotNET.Color(0, 0, 0, 255),
                new SimpleSDLWrapperDotNET.Color(128, 255, 0, 255)
            };

            // init the debug windows
            memMap.UpdateTable(c8CHIP8.Memory);
        }
        static void Main(string[] args)
        {
            SDLWrapper sdl = new SDLWrapper();
            sdl.Initialize();
            sdl.CreateWindow("Test window", 100, 100, 640, 320, WindowFlags.WINDOW_SHOWN);
            sdl.CreateRenderer(SDLWrapper.DEFAULT_RENDERING_DRIVER, RendererFlags.RENDERER_ACCELERATED/* | RendererFlags.RENDERER_PRESENTVSYNC*/);
            Texture txDisplayTexture = sdl.CreateDynamicTexture(64, 32);

            sdl.OnQuit += sdl_onQuit;
            sdl.OnKeyPressed += sdl_OnKeyPressedOrReleased;
            sdl.OnKeyReleased += sdl_OnKeyPressedOrReleased;

            SDLMixerWrapper mixer = new SDLMixerWrapper();
            mixer.Initialize();
            sample = mixer.LoadSample(@"Ding.wav");

            bRunning = true;
            while (bRunning)
            {
                // call this at the beginning of ever loop to capture the events
                sdl.HandleEvents();

                //sdl.FrameRateCapper();
                System.Threading.Thread.Sleep(delay);

                Color[] caPixelPile = new Color[64 * 32];
                for (int i = 0; i < caPixelPile.Length; i++)
                {
                    caPixelPile[i] = new Color(rndRandom.Next(255), rndRandom.Next(255), rndRandom.Next(255), rndRandom.Next(255));
                }
                txDisplayTexture.Lock();
                txDisplayTexture.SetPixels(caPixelPile);
                txDisplayTexture.Unlock();

                sdl.ClearScreen();
                sdl.RenderTexture(txDisplayTexture);
                sdl.Render();
            }
        }
Beispiel #4
0
 public CallbackManager()
 {
     c = new Cursor(SDLWrapper.AddDrawableLib(SDLWrapper.GliPath + "glbasis.gli", "CURSOR"));
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            c8CHIP8.Init();
            string sFileName = string.Empty;

            if (args.Length > 0)
            {
                sFileName = args[0];
            }
            else
            {
                sFileName = @"..\..\..\roms\Zero Demo [zeroZshadow, 2007].ch8";
            }
            string sWindowTitle = new FileInfo(sFileName).Name;

            c8CHIP8.LoadRom(sFileName);
            c8CHIP8.onPlaySound += c8CHIP8_onPlaySound;

            System.Windows.Forms.Form f = new System.Windows.Forms.Form();
            f.Width  = CHIP8.GRAPHICS_WIDTH * sizeMultiplier;
            f.Height = CHIP8.GRAPHICS_HEIGHT * sizeMultiplier;


            System.Windows.Forms.MenuStrip         menuStrip1            = new System.Windows.Forms.MenuStrip();
            System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();

            menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                fileToolStripMenuItem
            });
            menuStrip1.Location = new System.Drawing.Point(0, 0);
            menuStrip1.Name     = "menuStrip1";
            menuStrip1.Size     = new System.Drawing.Size(171, 24);
            menuStrip1.TabIndex = 2;
            menuStrip1.Text     = "menuStrip1";
            menuStrip1.Visible  = false;
            //
            // fileToolStripMenuItem
            //
            fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                openToolStripMenuItem,
                exitToolStripMenuItem
            });
            fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            fileToolStripMenuItem.Text = "File";
            //
            // openToolStripMenuItem
            //
            openToolStripMenuItem.Name = "openToolStripMenuItem";
            openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            openToolStripMenuItem.Text = "Open";
            //
            // exitToolStripMenuItem
            //
            exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            exitToolStripMenuItem.Text = "Exit";

            f.Controls.Add(menuStrip1);
            f.Height += menuStrip1.Height;


            // set up the graphics
            SDLWrapper sdl = new SDLWrapper();

            sdl.Initialize();
            //sdl.CreateWindow(sWindowTitle, 100, 100, CHIP8.GRAPHICS_WIDTH * sizeMultiplier, CHIP8.GRAPHICS_HEIGHT * sizeMultiplier, WindowFlags.WINDOW_SHOWN);
            sdl.CreateWindowFor(f.Handle);
            sdl.CreateRenderer(SDLWrapper.DEFAULT_RENDERING_DRIVER, RendererFlags.RENDERER_ACCELERATED /* | RendererFlags.RENDERER_PRESENTVSYNC*/);
            //sdl.CreateRendererForWindow(f.Handle, SDLWrapper.DEFAULT_RENDERING_DRIVER, RendererFlags.RENDERER_SOFTWARE);
            Texture txDisplayTexture = sdl.CreateDynamicTexture(CHIP8.GRAPHICS_WIDTH, CHIP8.GRAPHICS_HEIGHT);

            f.Show();

            sdl.OnQuit        += sdl_onQuit;
            sdl.OnKeyPressed  += sdl_OnKeyPressedOrReleased;
            sdl.OnKeyReleased += sdl_OnKeyPressedOrReleased;

            SDLMixerWrapper mixer = new SDLMixerWrapper();

            mixer.Initialize();
            sample = mixer.LoadSample(@"Ding.wav");

            Color[] palette = new Color[] {
                new Color(0, 0, 0, 255),
                new Color(128, 255, 0, 255)
            };

            // set up the debug windows
            Registers winRegisters = new Registers();

            winRegisters.InitializeRegisters(CHIP8.REGISTERCOUNT);
            winRegisters.Show();


            bRunning = true;
            while (bRunning)
            {
                // call this at the beginning of ever loop to capture the events
                sdl.HandleEvents();

                //sdl.FrameRateCapper();
                System.Threading.Thread.Sleep(delay);

                c8CHIP8.EmulateCycle();
                if (winRegisters.Visible)
                {
                    winRegisters.UpdateRegisters(c8CHIP8.V);
                }

                if (c8CHIP8.GraphicsMemoryChanged)
                {
                    Color[] caPixelPile = new Color[CHIP8.GRAPHICS_WIDTH * CHIP8.GRAPHICS_HEIGHT];
                    for (int i = 0; i < caPixelPile.Length; i++)
                    {
                        caPixelPile[i] = palette[c8CHIP8.GraphicsMemory[i]];
                    }
                    txDisplayTexture.Lock();
                    txDisplayTexture.SetPixels(caPixelPile);
                    txDisplayTexture.Unlock();

                    c8CHIP8.GraphicsMemoryChanged = false;
                }

                sdl.ClearScreen();
                sdl.RenderTexture(txDisplayTexture, null, new Rectangle(0, menuStrip1.Height, 640, 320 - menuStrip1.Height));
                sdl.Render();
            }
        }