Ejemplo n.º 1
0
Archivo: Curses.cs Proyecto: pabru/YCPU
        public void Render(SpriteBatchExtended spriteBatch, EffectState effect, Vector2 offset)
        {
            const float sixteenth   = 1 / 16f;
            float       horizSpacer = m_AdditionalHorizSpacingPixel ? 1f : 0f;

            for (int y = 0; y < CharsHigh; y++)
            {
                for (int x = 0; x < CharsWide; x++)
                {
                    byte ch = m_CharBuffer[x + y * CharsWide];
                    if (ch == 0)
                    {
                        continue;
                    }
                    float u = ch % 16 * sixteenth;
                    float v = ch / 16 * sixteenth;
                    spriteBatch.DrawSprite(effect, m_Texture,
                                           new Vector3(offset.X + x * (OneCharWidth + horizSpacer), offset.Y + y * OneCharHeight, 0),
                                           new Vector2(OneCharWidth, OneCharHeight),
                                           new Vector4(u, v, u + sixteenth, v + sixteenth),
                                           Color.LightGray);
                }
            }
        }
Ejemplo n.º 2
0
 public DisplayProvider(SpriteBatchExtended spriteBatch)
 {
     m_SpriteBatch = spriteBatch;
     m_Devices = new List<GraphicsDataForDevice>();
 }
Ejemplo n.º 3
0
 public GraphicsDataForDevice(SpriteBatchExtended sb, int busIndex, int width, int height)
 {
     DeviceBusIndex = busIndex;
     Width = width;
     Height = height;
     Texture = sb.NewTexture(Width, Height);
     Data = new uint[Width * Height];
 }
Ejemplo n.º 4
0
 protected override void UnloadContent()
 {
     m_SpriteBatch.Dispose();
     m_SpriteBatch = null;
 }
Ejemplo n.º 5
0
        protected override void Initialize()
        {
            Registry = new ServiceRegistry();

            Registry.Register(m_SpriteBatch = new SpriteBatchExtended(this));
            m_SpriteBatch.Initialize();

            Registry.Register(m_InputManager = new InputManager(Window.Handle));

            m_InputProvider = new InputProvider(m_InputManager);
            m_DisplayProvider = new DisplayProvider(m_SpriteBatch);

            m_Emulator = new Emulator();
            m_Emulator.Initialize(m_DisplayProvider, m_InputProvider);
            m_Curses = new Curses(GraphicsDevice, c_ConsoleWidth, c_ConsoleHeight, c_CursesFont, true);
            m_Effect = new EffectState(m_SpriteBatch.LoadEffectContent("BasicEffect"), SamplerState.PointClamp);
            m_EffectCRT = new EffectState(m_SpriteBatch.LoadEffectContent("CRTEffect"), SamplerState.AnisotropicClamp);

            m_Graphics.PreferredBackBufferWidth = c_WindowW * 2;
            m_Graphics.PreferredBackBufferHeight = c_WindowH;
            m_Graphics.IsFullScreen = false;
            m_Graphics.ApplyChanges();
            IsMouseVisible = true;

            base.Initialize();

            SystemFunctions.SetFocus(Window.Handle);
        }
Ejemplo n.º 6
0
 public void Render(SpriteBatchExtended spriteBatch, EffectState effect, Vector2 offset)
 {
     const float sixteenth = 1 / 16f;
     float horizSpacer = m_AdditionalHorizSpacingPixel ? 1f : 0f;
     for (int y = 0; y < CharsHigh; y++) {
         for (int x = 0; x < CharsWide; x++) {
             byte ch = m_CharBuffer[x + y * CharsWide];
             if (ch == 0)
                 continue;
             float u = ch % 16 * sixteenth;
             float v = ch / 16 * sixteenth;
             spriteBatch.DrawSprite(effect, m_Texture,
                 new Vector3(offset.X + x * (OneCharWidth + horizSpacer), offset.Y + y * OneCharHeight, 0),
                 new Vector2(OneCharWidth, OneCharHeight),
                 new Vector4(u, v, u + sixteenth, v + sixteenth),
                 Color.LightGray);
         }
     }
 }