Modified Machine.State to use volatile field.

Added WPF and XNA define constants to projects.
Modified default video colours to match platform format
- BGRA for Silverlight and WPF; RGBA for everything else.
This commit is contained in:
Sean Fausett 2012-05-12 13:27:56 +12:00
parent 992d205c06
commit 7e09b214de
8 changed files with 37 additions and 13 deletions

View File

@ -206,7 +206,7 @@ namespace Jellyfish.Virtu
public MachineEvents Events { get; private set; }
public MachineServices Services { get; private set; }
public MachineState State { get; private set; }
public MachineState State { get { return _state; } private set { _state = value; } }
public Cpu Cpu { get; private set; }
public Memory Memory { get; private set; }
@ -235,6 +235,7 @@ namespace Jellyfish.Virtu
private DebugService _debugService;
private StorageService _storageService;
private volatile MachineState _state;
private AutoResetEvent _pauseEvent = new AutoResetEvent(false);
private AutoResetEvent _unpauseEvent = new AutoResetEvent(false);

View File

@ -7,7 +7,10 @@
{
}
public abstract void SetFullScreen(bool isFullScreen);
public virtual void SetFullScreen(bool isFullScreen)
{
}
public abstract void SetPixel(int x, int y, uint color);
public abstract void Update(); // main thread
}

View File

@ -29,6 +29,7 @@ namespace Jellyfish.Virtu
_memory = Machine.Memory;
_videoService = Machine.Services.GetService<VideoService>();
#if SILVERLIGHT || WPF
_colorBlack = 0xFF000000; // BGRA
_colorDarkBlue = 0xFF000099;
_colorDarkGreen = 0xFF117722;
@ -46,6 +47,25 @@ namespace Jellyfish.Virtu
_colorYellow = 0xFFFFFF11;
_colorWhite = 0xFFFFFFFF;
_colorMonochrome = 0xFF00AA00;
#else
_colorBlack = 0xFF000000; // RGBA
_colorDarkBlue = 0xFF990000;
_colorDarkGreen = 0xFF227711;
_colorMediumBlue = 0xFFFF0000;
_colorBrown = 0xFF005588;
_colorLightGrey = 0xFFAAAA99;
_colorGreen = 0xFF11EE00;
_colorAquamarine = 0xFFAAFF55;
_colorDeepRed = 0xFF1111FF;
_colorPurple = 0xFFDD00DD;
_colorDarkGrey = 0xFF555544;
_colorLightBlue = 0xFFFFAA33;
_colorOrange = 0xFF1144FF;
_colorPink = 0xFF8899FF;
_colorYellow = 0xFF11FFFF;
_colorWhite = 0xFFFFFFFF;
_colorMonochrome = 0xFF00AA00;
#endif
SetPalette();
IsFullScreen = false;

View File

@ -23,7 +23,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS;CODE_ANALYSIS</DefineConstants>
<DefineConstants>DEBUG;TRACE;WPF;WINDOWS;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@ -35,7 +35,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;WINDOWS;CODE_ANALYSIS</DefineConstants>
<DefineConstants>TRACE;WPF;WINDOWS;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

View File

@ -30,7 +30,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Windows Phone\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS_PHONE;CODE_ANALYSIS</DefineConstants>
<DefineConstants>DEBUG;TRACE;XNA;WINDOWS_PHONE;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
@ -45,7 +45,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Windows Phone\</OutputPath>
<DefineConstants>TRACE;WINDOWS_PHONE;CODE_ANALYSIS</DefineConstants>
<DefineConstants>TRACE;XNA;WINDOWS_PHONE;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>

View File

@ -24,7 +24,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Xbox 360\</OutputPath>
<DefineConstants>DEBUG;TRACE;XBOX;XBOX360;CODE_ANALYSIS</DefineConstants>
<DefineConstants>DEBUG;TRACE;XNA;XBOX;XBOX360;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
@ -39,7 +39,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Xbox 360\</OutputPath>
<DefineConstants>TRACE;XBOX;XBOX360;CODE_ANALYSIS</DefineConstants>
<DefineConstants>TRACE;XNA;XBOX;XBOX360;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>

View File

@ -24,7 +24,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS;CODE_ANALYSIS</DefineConstants>
<DefineConstants>DEBUG;TRACE;XNA;WINDOWS;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
@ -39,7 +39,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x86\</OutputPath>
<DefineConstants>TRACE;WINDOWS;CODE_ANALYSIS</DefineConstants>
<DefineConstants>TRACE;XNA;WINDOWS;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>

View File

@ -26,22 +26,22 @@ namespace Jellyfish.Virtu.Services
_game.GraphicsDeviceService.DeviceCreated += OnGraphicsDeviceServiceDeviceCreated;
}
#if WINDOWS
public override void SetFullScreen(bool isFullScreen)
{
#if WINDOWS
var graphicsDeviceManager = _game.GraphicsDeviceManager;
if (graphicsDeviceManager.IsFullScreen != isFullScreen)
{
graphicsDeviceManager.IsFullScreen = isFullScreen;
_game.SynchronizationContext.Send(state => graphicsDeviceManager.ApplyChanges(), null);
}
#endif
}
#endif
[SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow")]
public override void SetPixel(int x, int y, uint color)
{
_pixels[y * TextureWidth + x] = (color & 0xFF00FF00) | ((color << 16) & 0x00FF0000) | ((color >> 16) & 0x000000FF); // RGBA
_pixels[y * TextureWidth + x] = color;
_pixelsDirty = true;
}