コード例 #1
0
        protected override void OnDrawing(UltravioletTime time)
        {
            var window = Ultraviolet.GetPlatform().Windows.GetCurrent();
            var input  = Ultraviolet.GetInput();

            if (input.GetKeyboard().IsKeyDown(Key.Backslash))
            {
                window.Position = new Point2(0, 40);
            }
            this.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            _colorList  = new List <Color>();
            cpu._Halted = false;
            cpu.Loop();
            for (int y = 0; y < _height; y++)
            {
                for (int yScale = 0; yScale < _scale; yScale++)
                {
                    for (int x = 0; x < _width; x++)
                    {
                        for (int xScale = 0; xScale < _scale; xScale++)
                        {
                            switch (cpu._PPU._frameData[y, x])
                            {
                            case 0:
                                _colorList.Add(_white);
                                break;

                            case 1:
                                _colorList.Add(_dark);
                                break;

                            case 2:
                                _colorList.Add(_light);
                                break;

                            case 3:
                                _colorList.Add(_black);
                                break;
                            }
                        }
                    }
                }
            }
            _canvas.Clear(_black);
            _canvas.SetData(_colorList.ToArray());
            _canvas.Flip(SurfaceFlipDirection.Vertical);
            _frameBuffer.SetData(_canvas);
            this.spriteBatch.Flush();
            this.spriteBatch.Draw(_frameBuffer, new Vector2(0, 0), null, Color.White, 0f, new Vector2(0, 0), 1, SpriteEffects.None, 0f);
            this.spriteBatch.End();

            _canvas.Clear(_black);
            base.OnDrawing(time);
        }