diff --git a/Library/Xna/FrameRateCounter.cs b/Library/Xna/FrameRateCounter.cs
index f288dac..67faea4 100644
--- a/Library/Xna/FrameRateCounter.cs
+++ b/Library/Xna/FrameRateCounter.cs
@@ -14,7 +14,7 @@ public FrameRateCounter(GameBase game) :
FontName = "Default";
//game.IsFixedTimeStep = true; // fixed (default)
- //game.TargetElapsedTime = TimeSpan.FromSeconds(1f / 60f);
+ //game.TargetElapsedTime = TimeSpan.FromSeconds(1 / 60f);
//game.IsFixedTimeStep = false; // flatout
//game.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
diff --git a/Virtu/Xna/Jellyfish.Virtu.Xna.csproj b/Virtu/Xna/Jellyfish.Virtu.Xna.csproj
index 261ab4d..09df373 100644
--- a/Virtu/Xna/Jellyfish.Virtu.Xna.csproj
+++ b/Virtu/Xna/Jellyfish.Virtu.Xna.csproj
@@ -69,6 +69,9 @@
False
+
+ 3.0
+
False
diff --git a/Virtu/Xna/MainGame.cs b/Virtu/Xna/MainGame.cs
index 4bac64c..2d28fe7 100644
--- a/Virtu/Xna/MainGame.cs
+++ b/Virtu/Xna/MainGame.cs
@@ -11,13 +11,7 @@ public MainGame() :
base("Virtu")
{
Components.Add(new FrameRateCounter(this) { DrawOrder = 1, FontName = "Consolas" });
-#if XBOX
- GraphicsDeviceManager.PreferredBackBufferWidth = 640;
- GraphicsDeviceManager.PreferredBackBufferHeight = 480;
-#else
- GraphicsDeviceManager.PreferredBackBufferWidth = 560;
- GraphicsDeviceManager.PreferredBackBufferHeight = 384;
-#endif
+
_storageService = new XnaStorageService(_machine, this);
_keyboardService = new XnaKeyboardService(_machine);
_gamePortService = new XnaGamePortService(_machine);
diff --git a/Virtu/Xna/Services/XnaGamePortService.cs b/Virtu/Xna/Services/XnaGamePortService.cs
index aa71d31..a3ad41b 100644
--- a/Virtu/Xna/Services/XnaGamePortService.cs
+++ b/Virtu/Xna/Services/XnaGamePortService.cs
@@ -21,10 +21,10 @@ public override void Update() // main thread
Vector2 right = _state.ThumbSticks.Right;
GamePadDPad dpad = _state.DPad;
- Paddle0 = (int)((1f + left.X) * PaddleScale);
- Paddle1 = (int)((1f - left.Y) * PaddleScale); // invert y
- Paddle2 = (int)((1f + right.X) * PaddleScale);
- Paddle3 = (int)((1f - right.Y) * PaddleScale); // invert y
+ Paddle0 = (int)((1 + left.X) * PaddleScale);
+ Paddle1 = (int)((1 - left.Y) * PaddleScale); // invert y
+ Paddle2 = (int)((1 + right.X) * PaddleScale);
+ Paddle3 = (int)((1 - right.Y) * PaddleScale); // invert y
Joystick0 = GetJoystick(ref left, ref dpad);
Joystick1 = GetJoystick(ref right);
@@ -55,7 +55,7 @@ private static Joystick GetJoystick(ref Vector2 thumbstick, ref GamePadDPad dpad
return new Joystick(isUp, isLeft, isRight, isDown);
}
- private const float PaddleScale = 128f;
+ private const int PaddleScale = 128;
private const float JoystickDeadZone = 0.5f;
private GamePadState _state;
diff --git a/Virtu/Xna/Services/XnaKeyboardService.cs b/Virtu/Xna/Services/XnaKeyboardService.cs
index c162d99..89900c1 100644
--- a/Virtu/Xna/Services/XnaKeyboardService.cs
+++ b/Virtu/Xna/Services/XnaKeyboardService.cs
@@ -106,10 +106,12 @@ private void OnKeyUp(Keys key, bool gamePadControl)
{
Machine.Video.ToggleMonochrome();
}
+#if WINDOWS
else if ((control && (key == Keys.Subtract)) || (gamePadControl && (key == Keys.D0)))
{
Machine.Video.ToggleFullScreen();
}
+#endif
}
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
diff --git a/Virtu/Xna/Services/XnaVideoService.cs b/Virtu/Xna/Services/XnaVideoService.cs
index b4bbeb1..e5df999 100644
--- a/Virtu/Xna/Services/XnaVideoService.cs
+++ b/Virtu/Xna/Services/XnaVideoService.cs
@@ -1,5 +1,8 @@
using System;
using System.Diagnostics.CodeAnalysis;
+#if WINDOWS
+using System.Windows;
+#endif
using Jellyfish.Library;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -32,21 +35,12 @@ public override void SetPixel(int x, int y, uint color)
public override void Update() // main thread
{
+#if WINDOWS
if (_game.GraphicsDeviceManager.IsFullScreen != IsFullScreen)
{
- if (IsFullScreen)
- {
- _game.GraphicsDeviceManager.PreferredBackBufferWidth = _graphicsDevice.DisplayMode.Width; // avoids changing display mode
- _game.GraphicsDeviceManager.PreferredBackBufferHeight = _graphicsDevice.DisplayMode.Height;
- }
- else
- {
- _game.GraphicsDeviceManager.PreferredBackBufferWidth = TextureWidth;
- _game.GraphicsDeviceManager.PreferredBackBufferHeight = TextureHeight;
- }
_game.GraphicsDeviceManager.ToggleFullScreen();
}
-
+#endif
if (_pixelsDirty)
{
_pixelsDirty = false;
@@ -55,7 +49,7 @@ public override void Update() // main thread
_spriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
_graphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point;
- _spriteBatch.Draw(_texture, _texturePosition, null, Color.White, 0f, Vector2.Zero, _textureScale, SpriteEffects.None, 0f);
+ _spriteBatch.Draw(_texture, _texturePosition, null, Color.White, 0, Vector2.Zero, _textureScale, SpriteEffects.None, 0);
_spriteBatch.End();
}
@@ -72,15 +66,25 @@ private void OnGraphicsDeviceManagerPreparingDeviceSettings(object sender, Prepa
{
DisplayMode displayMode = e.GraphicsDeviceInformation.Adapter.CurrentDisplayMode;
PresentationParameters presentationParameters = e.GraphicsDeviceInformation.PresentationParameters;
- _textureScale = Math.Min(presentationParameters.BackBufferWidth / TextureWidth, presentationParameters.BackBufferHeight / TextureHeight);
- while ((presentationParameters.BackBufferWidth + TextureWidth <= displayMode.Width) &&
- (presentationParameters.BackBufferHeight + TextureHeight <= displayMode.Height))
+#if WINDOWS
+ if (presentationParameters.IsFullScreen)
{
- presentationParameters.BackBufferWidth += TextureWidth;
- presentationParameters.BackBufferHeight += TextureHeight;
- _textureScale++;
+ _textureScale = Math.Min((int)SystemParameters.PrimaryScreenWidth / TextureWidth, (int)SystemParameters.PrimaryScreenHeight / TextureHeight);
+ presentationParameters.BackBufferWidth = displayMode.Width; // avoids changing display mode
+ presentationParameters.BackBufferHeight = displayMode.Height;
}
+ else
+ {
+ _textureScale = Math.Min((int)SystemParameters.FullPrimaryScreenWidth / TextureWidth, (int)SystemParameters.FullPrimaryScreenHeight / TextureHeight);
+ presentationParameters.BackBufferWidth = _textureScale * TextureWidth;
+ presentationParameters.BackBufferHeight = _textureScale * TextureHeight;
+ }
+#else
+ _textureScale = Math.Min(displayMode.TitleSafeArea.Width / TextureWidth, displayMode.TitleSafeArea.Height / TextureHeight);
+ presentationParameters.BackBufferWidth = displayMode.Width; // always use display mode
+ presentationParameters.BackBufferHeight = displayMode.Height;
+#endif
}
private void OnGraphicsDeviceServiceDeviceCreated(object sender, EventArgs e)
@@ -94,8 +98,8 @@ private void OnGraphicsDeviceServiceDeviceCreated(object sender, EventArgs e)
private void SetTexturePosition()
{
- _texturePosition.X = (_graphicsDevice.PresentationParameters.BackBufferWidth - TextureWidth * _textureScale) / 2f; // centered
- _texturePosition.Y = (_graphicsDevice.PresentationParameters.BackBufferHeight - TextureHeight * _textureScale) / 2f;
+ _texturePosition.X = (_graphicsDevice.PresentationParameters.BackBufferWidth - TextureWidth * _textureScale) / 2; // centered
+ _texturePosition.Y = (_graphicsDevice.PresentationParameters.BackBufferHeight - TextureHeight * _textureScale) / 2;
}
private const int TextureWidth = 560;