mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2025-02-17 04:32:21 +00:00
Added debug service.
Fixed code analysis warnings. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4047095
This commit is contained in:
parent
2ba3146299
commit
d22639c563
@ -71,11 +71,13 @@ namespace Jellyfish.Library
|
||||
{
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
public GeneralSecurity(bool isContainer, ResourceType resourceType, SafeHandle handle, AccessControlSections includeSections = AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner) :
|
||||
base(isContainer, resourceType, handle, includeSections)
|
||||
{
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
public GeneralSecurity(bool isContainer, ResourceType resourceType, string name, AccessControlSections includeSections = AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner) :
|
||||
base(isContainer, resourceType, name, includeSections)
|
||||
{
|
||||
@ -103,12 +105,14 @@ namespace Jellyfish.Library
|
||||
base.AddAuditRule(rule);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
[SecurityCritical]
|
||||
public void GetSecurityAttributes(Action<SecurityAttributes> action, bool inheritable = false)
|
||||
{
|
||||
GetSecurityAttributes(this, action, inheritable);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
[SecurityCritical]
|
||||
public static void GetSecurityAttributes(ObjectSecurity security, Action<SecurityAttributes> action, bool inheritable = false)
|
||||
{
|
||||
|
@ -47,6 +47,8 @@ namespace Jellyfish.Library
|
||||
return alloc;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
[SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")]
|
||||
[SecurityCritical]
|
||||
public static SafeGlobalAllocHandle Allocate(int size, uint flags = 0x0)
|
||||
{
|
||||
@ -110,6 +112,8 @@ namespace Jellyfish.Library
|
||||
return alloc;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
[SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")]
|
||||
[SecurityCritical]
|
||||
public static SafeLocalAllocHandle Allocate(int size, uint flags = 0x0)
|
||||
{
|
||||
|
@ -6,7 +6,12 @@ namespace Jellyfish.Library
|
||||
{
|
||||
public class ApplicationBase : Application
|
||||
{
|
||||
public ApplicationBase(string name = null)
|
||||
public ApplicationBase() :
|
||||
this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public ApplicationBase(string name)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
|
@ -10,7 +10,13 @@ namespace Jellyfish.Library
|
||||
public class ApplicationBase : Application
|
||||
{
|
||||
[SecurityCritical]
|
||||
public ApplicationBase(string name = null)
|
||||
public ApplicationBase() :
|
||||
this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
public ApplicationBase(string name)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
|
@ -8,6 +8,7 @@ namespace Jellyfish.Library
|
||||
public static class XmlSerializerHelpers
|
||||
{
|
||||
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
public static T Deserialize<T>(Stream stream, string defaultNamespace = null)
|
||||
{
|
||||
using (var reader = XmlReader.Create(stream))
|
||||
@ -17,6 +18,7 @@ namespace Jellyfish.Library
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
public static void Serialize<T>(Stream stream, T instance, string defaultNamespace = null)
|
||||
{
|
||||
using (var writer = XmlWriter.Create(stream))
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
|
||||
namespace Jellyfish.Virtu.Services
|
||||
@ -13,7 +14,7 @@ namespace Jellyfish.Virtu.Services
|
||||
public void Output(int data) // machine thread
|
||||
{
|
||||
_buffer[_index + 0] = (byte)(data & 0xFF);
|
||||
_buffer[_index + 1] = (byte)((data >> 8) & 0xFF);
|
||||
_buffer[_index + 1] = (byte)(data >> 8);
|
||||
_index = (_index + 2) % SampleSize;
|
||||
if (_index == 0)
|
||||
{
|
||||
@ -55,6 +56,7 @@ namespace Jellyfish.Virtu.Services
|
||||
public const int SampleLatency = 40; // ms
|
||||
public const int SampleSize = (SampleRate * SampleLatency / 1000) * SampleChannels * (SampleBits / 8);
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
|
||||
protected static readonly byte[] SampleZero = new byte[SampleSize];
|
||||
|
||||
private byte[] _buffer = new byte[SampleSize];
|
||||
|
18
Virtu/Services/DebugService.cs
Normal file
18
Virtu/Services/DebugService.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
public class DebugService : MachineService
|
||||
{
|
||||
public DebugService(Machine machine) :
|
||||
base(machine)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void WriteLine(string message)
|
||||
{
|
||||
Debug.WriteLine(string.Concat(DateTime.Now, " ", message));
|
||||
}
|
||||
}
|
||||
}
|
@ -35,5 +35,6 @@ namespace Jellyfish.Virtu.Services
|
||||
}
|
||||
|
||||
protected Machine Machine { get; private set; }
|
||||
protected DebugService DebugService { get { return Machine.Services.GetService<DebugService>(); } }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
@ -14,6 +15,7 @@ namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
|
||||
public static Stream GetResourceStream(string resourceName, int resourceSize = 0)
|
||||
{
|
||||
var resourceManager = new ResourceManager("Jellyfish.Virtu.g", Assembly.GetExecutingAssembly()) { IgnoreCase = true };
|
||||
|
@ -155,6 +155,9 @@
|
||||
<Compile Include="..\Services\AudioService.cs">
|
||||
<Link>Services\AudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\DebugService.cs">
|
||||
<Link>Services\DebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\GamePortService.cs">
|
||||
<Link>Services\GamePortService.cs</Link>
|
||||
</Compile>
|
||||
@ -187,6 +190,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\SilverlightAudioService.cs" />
|
||||
<Compile Include="Services\SilverlightDebugService.cs" />
|
||||
<Compile Include="Services\SilverlightKeyboardService.cs" />
|
||||
<Compile Include="Services\SilverlightVideoService.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -13,9 +13,9 @@
|
||||
<Grid>
|
||||
<Image x:Name="_image" MinWidth="280" MinHeight="192"/>
|
||||
<MediaElement x:Name="_media"/>
|
||||
<!--<ScrollViewer BorderThickness="0" IsTabStop="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer BorderThickness="0" IsTabStop="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock x:Name="_debug" FontFamily="Consolas" FontSize="12" Foreground="White"/>
|
||||
</ScrollViewer>-->
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</tk:DockPanel>
|
||||
</UserControl>
|
||||
|
@ -13,12 +13,14 @@ namespace Jellyfish.Virtu
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_debugService = new SilverlightDebugService(_machine, this);
|
||||
_storageService = new IsolatedStorageService(_machine);
|
||||
_keyboardService = new SilverlightKeyboardService(_machine, this);
|
||||
_gamePortService = new GamePortService(_machine); // not connected
|
||||
_audioService = new SilverlightAudioService(_machine, this, _media);
|
||||
_videoService = new SilverlightVideoService(_machine, this, _image);
|
||||
|
||||
_machine.Services.AddService(typeof(DebugService), _debugService);
|
||||
_machine.Services.AddService(typeof(StorageService), _storageService);
|
||||
_machine.Services.AddService(typeof(KeyboardService), _keyboardService);
|
||||
_machine.Services.AddService(typeof(GamePortService), _gamePortService);
|
||||
@ -36,6 +38,7 @@ namespace Jellyfish.Virtu
|
||||
public void Dispose()
|
||||
{
|
||||
_machine.Dispose();
|
||||
_debugService.Dispose();
|
||||
_storageService.Dispose();
|
||||
_keyboardService.Dispose();
|
||||
_gamePortService.Dispose();
|
||||
@ -68,6 +71,7 @@ namespace Jellyfish.Virtu
|
||||
|
||||
private Machine _machine = new Machine();
|
||||
|
||||
private DebugService _debugService;
|
||||
private StorageService _storageService;
|
||||
private KeyboardService _keyboardService;
|
||||
private GamePortService _gamePortService;
|
||||
|
@ -141,6 +141,9 @@
|
||||
<Compile Include="..\..\Services\AudioService.cs">
|
||||
<Link>Services\AudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Services\DebugService.cs">
|
||||
<Link>Services\DebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\Services\GamePortService.cs">
|
||||
<Link>Services\GamePortService.cs</Link>
|
||||
</Compile>
|
||||
@ -174,6 +177,9 @@
|
||||
<Compile Include="..\Services\SilverlightAudioService.cs">
|
||||
<Link>Services\SilverlightAudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\SilverlightDebugService.cs">
|
||||
<Link>Services\SilverlightDebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\SilverlightKeyboardService.cs">
|
||||
<Link>Services\SilverlightKeyboardService.cs</Link>
|
||||
</Compile>
|
||||
|
@ -23,9 +23,9 @@
|
||||
<Grid>
|
||||
<Image x:Name="_image" MinWidth="280" MinHeight="192"/>
|
||||
<MediaElement x:Name="_media"/>
|
||||
<!--<ScrollViewer BorderThickness="0" IsTabStop="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer BorderThickness="0" IsTabStop="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock x:Name="_debug" FontFamily="Consolas" FontSize="12" Foreground="White"/>
|
||||
</ScrollViewer>-->
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<!--</tk:DockPanel>-->
|
||||
|
@ -21,8 +21,9 @@ namespace Jellyfish.Virtu.Services
|
||||
_page = page;
|
||||
_media = media;
|
||||
_mediaSource = new WaveMediaStreamSource(SampleRate, SampleChannels, SampleBits, SampleSize, SampleLatency, OnMediaSourceUpdate);
|
||||
_media.SetSource(_mediaSource);
|
||||
|
||||
_page.Loaded += (sender, e) => { _media.SetSource(_mediaSource); _media.Play(); };
|
||||
_page.Loaded += (sender, e) => _media.Play();
|
||||
#if !WINDOWS_PHONE
|
||||
_page.Unloaded += (sender, e) => _media.Stop();
|
||||
#endif
|
||||
@ -42,10 +43,7 @@ namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
//if (_count++ % (1000 / SampleLatency) == 0)
|
||||
//{
|
||||
// _page.Dispatcher.BeginInvoke(() =>
|
||||
// {
|
||||
// ((MainPage)_page)._debug.Text += string.Concat(DateTime.Now, " OnMediaSourceUpdate", Environment.NewLine);
|
||||
// });
|
||||
// DebugService.WriteLine("OnMediaSourceUpdate");
|
||||
//}
|
||||
|
||||
Update(bufferSize, (source, count) => Buffer.BlockCopy(source, 0, buffer, 0, count));
|
||||
|
34
Virtu/Silverlight/Services/SilverlightDebugService.cs
Normal file
34
Virtu/Silverlight/Services/SilverlightDebugService.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
public sealed class SilverlightDebugService : DebugService
|
||||
{
|
||||
public SilverlightDebugService(Machine machine, MainPage page) :
|
||||
base(machine)
|
||||
{
|
||||
if (page == null)
|
||||
{
|
||||
throw new ArgumentNullException("page");
|
||||
}
|
||||
|
||||
_page = page;
|
||||
}
|
||||
|
||||
public override void WriteLine(string message)
|
||||
{
|
||||
message = string.Concat(DateTime.Now, " ", message, Environment.NewLine);
|
||||
|
||||
if (_page.CheckAccess())
|
||||
{
|
||||
_page._debug.Text += message;
|
||||
}
|
||||
else
|
||||
{
|
||||
_page.Dispatcher.BeginInvoke(() => _page._debug.Text += message);
|
||||
}
|
||||
}
|
||||
|
||||
private MainPage _page;
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnPageKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
//((MainPage)_page)._debug.Text += string.Concat("OnPageKeyDn: Key=", e.Key, " PlatformKeyCode=", e.PlatformKeyCode, Environment.NewLine);
|
||||
//DebugService.WriteLine(string.Concat("OnPageKeyDn: Key=", e.Key, " PlatformKeyCode=", e.PlatformKeyCode));
|
||||
|
||||
_states[(int)e.Key] = true;
|
||||
_updateAnyKeyDown = false;
|
||||
@ -80,7 +80,7 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnPageKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
//((MainPage)_page)._debug.Text += string.Concat("OnPageKeyUp: Key=", e.Key, " PlatformKeyCode=", e.PlatformKeyCode, Environment.NewLine);
|
||||
//DebugService.WriteLine(string.Concat("OnPageKeyUp: Key=", e.Key, " PlatformKeyCode=", e.PlatformKeyCode));
|
||||
|
||||
_states[(int)e.Key] = false;
|
||||
_updateAnyKeyDown = true;
|
||||
|
@ -135,6 +135,9 @@
|
||||
<Compile Include="..\Services\AudioService.cs">
|
||||
<Link>Services\AudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\DebugService.cs">
|
||||
<Link>Services\DebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\GamePortService.cs">
|
||||
<Link>Services\GamePortService.cs</Link>
|
||||
</Compile>
|
||||
@ -167,6 +170,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\WpfAudioService.cs" />
|
||||
<Compile Include="Services\WpfDebugService.cs" />
|
||||
<Compile Include="Services\WpfKeyboardService.cs" />
|
||||
<Compile Include="Services\WpfStorageService.cs" />
|
||||
<Compile Include="Services\WpfVideoService.cs" />
|
||||
|
@ -11,9 +11,9 @@
|
||||
</StackPanel>
|
||||
<Grid>
|
||||
<Image x:Name="_image" MinWidth="560" MinHeight="384" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
|
||||
<!--<ScrollViewer BorderThickness="0" Focusable="False" IsTabStop="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer BorderThickness="0" Focusable="False" IsTabStop="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock x:Name="_debug" FontFamily="Consolas" FontSize="12" Foreground="White"/>
|
||||
</ScrollViewer>-->
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
@ -14,12 +14,14 @@ namespace Jellyfish.Virtu
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_debugService = new WpfDebugService(_machine, this);
|
||||
_storageService = new WpfStorageService(_machine);
|
||||
_keyboardService = new WpfKeyboardService(_machine, this);
|
||||
_gamePortService = new GamePortService(_machine); // not connected
|
||||
_audioService = new WpfAudioService(_machine, this);
|
||||
_videoService = new WpfVideoService(_machine, this, _image);
|
||||
|
||||
_machine.Services.AddService(typeof(DebugService), _debugService);
|
||||
_machine.Services.AddService(typeof(StorageService), _storageService);
|
||||
_machine.Services.AddService(typeof(KeyboardService), _keyboardService);
|
||||
_machine.Services.AddService(typeof(GamePortService), _gamePortService);
|
||||
@ -37,6 +39,7 @@ namespace Jellyfish.Virtu
|
||||
public void Dispose()
|
||||
{
|
||||
_machine.Dispose();
|
||||
_debugService.Dispose();
|
||||
_storageService.Dispose();
|
||||
_keyboardService.Dispose();
|
||||
_gamePortService.Dispose();
|
||||
@ -78,6 +81,7 @@ namespace Jellyfish.Virtu
|
||||
|
||||
private Machine _machine = new Machine();
|
||||
|
||||
private DebugService _debugService;
|
||||
private StorageService _storageService;
|
||||
private KeyboardService _keyboardService;
|
||||
private GamePortService _gamePortService;
|
||||
|
@ -38,10 +38,7 @@ namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
//if (_count++ % (1000 / SampleLatency) == 0)
|
||||
//{
|
||||
// _window.Dispatcher.BeginInvoke(() =>
|
||||
// {
|
||||
// ((MainWindow)_window)._debug.Text += string.Concat(DateTime.Now, " OnDirectSoundUpdate", Environment.NewLine);
|
||||
// });
|
||||
// DebugService.WriteLine("OnDirectSoundUpdate");
|
||||
//}
|
||||
|
||||
Update(bufferSize, (source, count) => Marshal.Copy(source, 0, buffer, count));
|
||||
|
34
Virtu/Wpf/Services/WpfDebugService.cs
Normal file
34
Virtu/Wpf/Services/WpfDebugService.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
public sealed class WpfDebugService : DebugService
|
||||
{
|
||||
public WpfDebugService(Machine machine, MainWindow window) :
|
||||
base(machine)
|
||||
{
|
||||
if (window == null)
|
||||
{
|
||||
throw new ArgumentNullException("window");
|
||||
}
|
||||
|
||||
_window = window;
|
||||
}
|
||||
|
||||
public override void WriteLine(string message)
|
||||
{
|
||||
message = string.Concat(DateTime.Now, " ", message, Environment.NewLine);
|
||||
|
||||
if (_window.CheckAccess())
|
||||
{
|
||||
_window._debug.Text += message;
|
||||
}
|
||||
else
|
||||
{
|
||||
_window.Dispatcher.BeginInvoke(new Action(() => _window._debug.Text += message));
|
||||
}
|
||||
}
|
||||
|
||||
private MainWindow _window;
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnWindowKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
//((MainWindow)_window)._debug.Text += string.Concat("OnWindowKeyDn: Key=", e.Key, Environment.NewLine);
|
||||
//DebugService.WriteLine(string.Concat("OnWindowKeyDn: Key=", e.Key));
|
||||
|
||||
_states[(int)((e.Key == Key.System) ? e.SystemKey : e.Key)] = true;
|
||||
_updateAnyKeyDown = false;
|
||||
@ -80,7 +80,7 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnWindowKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
//((MainWindow)_window)._debug.Text += string.Concat("OnWindowKeyUp: Key=", e.Key, Environment.NewLine);
|
||||
//DebugService.WriteLine(string.Concat("OnWindowKeyUp: Key=", e.Key));
|
||||
|
||||
_states[(int)((e.Key == Key.System) ? e.SystemKey : e.Key)] = false;
|
||||
_updateAnyKeyDown = true;
|
||||
|
@ -147,6 +147,9 @@
|
||||
<Compile Include="..\Services\AudioService.cs">
|
||||
<Link>Services\AudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\DebugService.cs">
|
||||
<Link>Services\DebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\GamePortService.cs">
|
||||
<Link>Services\GamePortService.cs</Link>
|
||||
</Compile>
|
||||
|
@ -158,6 +158,9 @@
|
||||
<Compile Include="..\Services\AudioService.cs">
|
||||
<Link>Services\AudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\DebugService.cs">
|
||||
<Link>Services\DebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\GamePortService.cs">
|
||||
<Link>Services\GamePortService.cs</Link>
|
||||
</Compile>
|
||||
|
@ -159,6 +159,9 @@
|
||||
<Compile Include="..\Services\AudioService.cs">
|
||||
<Link>Services\AudioService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\DebugService.cs">
|
||||
<Link>Services\DebugService.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Services\GamePortService.cs">
|
||||
<Link>Services\GamePortService.cs</Link>
|
||||
</Compile>
|
||||
|
@ -22,6 +22,7 @@ namespace Jellyfish.Virtu
|
||||
frameRateCounter.DrawOrder = 1;
|
||||
frameRateCounter.FontName = "Consolas";
|
||||
|
||||
_debugService = new DebugService(_machine);
|
||||
#if WINDOWS_PHONE
|
||||
_storageService = new IsolatedStorageService(_machine);
|
||||
#else
|
||||
@ -32,6 +33,7 @@ namespace Jellyfish.Virtu
|
||||
_audioService = new XnaAudioService(_machine, this);
|
||||
_videoService = new XnaVideoService(_machine, this);
|
||||
|
||||
_machine.Services.AddService(typeof(DebugService), _debugService);
|
||||
_machine.Services.AddService(typeof(StorageService), _storageService);
|
||||
_machine.Services.AddService(typeof(KeyboardService), _keyboardService);
|
||||
_machine.Services.AddService(typeof(GamePortService), _gamePortService);
|
||||
@ -44,6 +46,7 @@ namespace Jellyfish.Virtu
|
||||
if (disposing)
|
||||
{
|
||||
_machine.Dispose();
|
||||
_debugService.Dispose();
|
||||
_storageService.Dispose();
|
||||
_keyboardService.Dispose();
|
||||
_gamePortService.Dispose();
|
||||
@ -82,6 +85,7 @@ namespace Jellyfish.Virtu
|
||||
|
||||
private Machine _machine = new Machine();
|
||||
|
||||
private DebugService _debugService;
|
||||
private StorageService _storageService;
|
||||
private KeyboardService _keyboardService;
|
||||
private GamePortService _gamePortService;
|
||||
|
@ -35,10 +35,16 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnDynamicSoundEffectBufferNeeded(object sender, EventArgs e) // audio thread
|
||||
{
|
||||
//if (_count++ % (1000 / SampleLatency) == 0)
|
||||
//{
|
||||
// DebugService.WriteLine("OnDynamicSoundEffectBufferNeeded");
|
||||
//}
|
||||
|
||||
Update(SampleSize, (source, count) => _dynamicSoundEffect.SubmitBuffer(source, 0, count));
|
||||
}
|
||||
|
||||
private GameBase _game;
|
||||
private DynamicSoundEffectInstance _dynamicSoundEffect = new DynamicSoundEffectInstance(SampleRate, (AudioChannels)SampleChannels);
|
||||
//private int _count;
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,8 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnKeyDown(Keys key, bool gamePadControl)
|
||||
{
|
||||
//DebugService.WriteLine(string.Concat("OnKeyDn: Key=", key));
|
||||
|
||||
int asciiKey = GetAsciiKey(key, gamePadControl);
|
||||
if (asciiKey >= 0)
|
||||
{
|
||||
@ -92,6 +94,8 @@ namespace Jellyfish.Virtu.Services
|
||||
|
||||
private void OnKeyUp(Keys key, bool gamePadControl)
|
||||
{
|
||||
//DebugService.WriteLine(string.Concat("OnKeyUp: Key=", key));
|
||||
|
||||
bool control = IsKeyDown(Keys.LeftControl) || IsKeyDown(Keys.RightControl);
|
||||
|
||||
if (key == Keys.CapsLock)
|
||||
|
Loading…
x
Reference in New Issue
Block a user