From df4b3a7bdae2ab3942dde952958bb5f52ce1513c Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 8 Jun 2012 22:41:25 +0000 Subject: Added tool kit, updated settings and added more joystick code. --- 3rdparty/Microsoft.Phone.Controls.Toolkit.dll | Bin 0 -> 468480 bytes 3rdparty/Microsoft.Phone.Controls.Toolkit.pdb | Bin 0 -> 732672 bytes wpspec/wpspec/Converters/ConvertCamelToHuman.cs | 19 +++++- wpspec/wpspec/Converters/ConvertFlagsToString.cs | 19 +++++- wpspec/wpspec/Converters/ConvertIntToEnum.cs | 51 +++++++++++++++ wpspec/wpspec/Converters/ConvertIntToHex2.cs | 19 +++++- wpspec/wpspec/Converters/ConvertIntToHex4.cs | 19 +++++- wpspec/wpspec/GamePage.xaml.cs | 35 ++++++++++- wpspec/wpspec/Resources/Strings.Designer.cs | 17 +++-- wpspec/wpspec/Resources/Strings.resx | 11 ++-- wpspec/wpspec/Resources/controls.keyboard | Bin 125 -> 125 bytes wpspec/wpspec/Settings.cs | 11 +++- wpspec/wpspec/SettingsPage.xaml | 77 +++++++++++++---------- wpspec/wpspec/SoundManager.cs | 7 ++- wpspec/wpspec/Spectrum/Emulation.cs | 18 ++++++ wpspec/wpspec/wpspec.csproj | 2 + 16 files changed, 253 insertions(+), 52 deletions(-) create mode 100644 3rdparty/Microsoft.Phone.Controls.Toolkit.dll create mode 100644 3rdparty/Microsoft.Phone.Controls.Toolkit.pdb create mode 100644 wpspec/wpspec/Converters/ConvertIntToEnum.cs diff --git a/3rdparty/Microsoft.Phone.Controls.Toolkit.dll b/3rdparty/Microsoft.Phone.Controls.Toolkit.dll new file mode 100644 index 0000000..44d59b1 Binary files /dev/null and b/3rdparty/Microsoft.Phone.Controls.Toolkit.dll differ diff --git a/3rdparty/Microsoft.Phone.Controls.Toolkit.pdb b/3rdparty/Microsoft.Phone.Controls.Toolkit.pdb new file mode 100644 index 0000000..ac620fd Binary files /dev/null and b/3rdparty/Microsoft.Phone.Controls.Toolkit.pdb differ diff --git a/wpspec/wpspec/Converters/ConvertCamelToHuman.cs b/wpspec/wpspec/Converters/ConvertCamelToHuman.cs index dae96b6..fb5d312 100644 --- a/wpspec/wpspec/Converters/ConvertCamelToHuman.cs +++ b/wpspec/wpspec/Converters/ConvertCamelToHuman.cs @@ -1,4 +1,21 @@ -using System; +// This file is part of the wpspec Spectrum emulator. +// +// wpspec is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// wpspec is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; using System.Net; using System.Windows; using System.Windows.Controls; diff --git a/wpspec/wpspec/Converters/ConvertFlagsToString.cs b/wpspec/wpspec/Converters/ConvertFlagsToString.cs index 5946cc7..3f06f87 100644 --- a/wpspec/wpspec/Converters/ConvertFlagsToString.cs +++ b/wpspec/wpspec/Converters/ConvertFlagsToString.cs @@ -1,4 +1,21 @@ -using System; +// This file is part of the wpspec Spectrum emulator. +// +// wpspec is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// wpspec is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; using System.Net; using System.Windows; using System.Windows.Controls; diff --git a/wpspec/wpspec/Converters/ConvertIntToEnum.cs b/wpspec/wpspec/Converters/ConvertIntToEnum.cs new file mode 100644 index 0000000..ff2d84c --- /dev/null +++ b/wpspec/wpspec/Converters/ConvertIntToEnum.cs @@ -0,0 +1,51 @@ +// This file is part of the wpspec Spectrum emulator. +// +// wpspec is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// wpspec is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; +using System.Windows.Data; + +namespace wpspec.Converters +{ + /// + /// Simply cast between ints and enumerated types. + /// + public class ConvertIntToEnum : IValueConverter + { + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return (int)value; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return Enum.ToObject(targetType, value); + } + + #endregion + } +} diff --git a/wpspec/wpspec/Converters/ConvertIntToHex2.cs b/wpspec/wpspec/Converters/ConvertIntToHex2.cs index e640a00..f67e90d 100644 --- a/wpspec/wpspec/Converters/ConvertIntToHex2.cs +++ b/wpspec/wpspec/Converters/ConvertIntToHex2.cs @@ -1,4 +1,21 @@ -using System; +// This file is part of the wpspec Spectrum emulator. +// +// wpspec is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// wpspec is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; using System.Net; using System.Windows; using System.Windows.Controls; diff --git a/wpspec/wpspec/Converters/ConvertIntToHex4.cs b/wpspec/wpspec/Converters/ConvertIntToHex4.cs index ab2fb86..a42b661 100644 --- a/wpspec/wpspec/Converters/ConvertIntToHex4.cs +++ b/wpspec/wpspec/Converters/ConvertIntToHex4.cs @@ -1,4 +1,21 @@ -using System; +// This file is part of the wpspec Spectrum emulator. +// +// wpspec is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// wpspec is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; using System.Net; using System.Windows; using System.Windows.Controls; diff --git a/wpspec/wpspec/GamePage.xaml.cs b/wpspec/wpspec/GamePage.xaml.cs index b6ca5a1..5ed296f 100644 --- a/wpspec/wpspec/GamePage.xaml.cs +++ b/wpspec/wpspec/GamePage.xaml.cs @@ -118,11 +118,10 @@ namespace wpspec // Shared.Spectrum.ResetKeyboard(); - // Create a keyboard driver - // // Create a keyboard driver // resetPressed = false; + turbo = false; inputManager = new InputManager(); @@ -159,6 +158,8 @@ namespace wpspec new Vector2[2] {new Vector2(280, 100), new Vector2(380, 125)}, 20, 75); + joystick.LockType = Settings.Instance.JoystickLock; + joystick.DigitalEvent += HandleJoystickEvent; if (Shared.IsJoystickDisplayed) @@ -226,6 +227,14 @@ namespace wpspec { inputManager.Update(); Shared.Spectrum.Run(); + + if (turbo) + { + Shared.Spectrum.Run(); + Shared.Spectrum.Run(); + Shared.Spectrum.Run(); + Shared.Spectrum.Run(); + } } /// @@ -248,8 +257,19 @@ namespace wpspec spriteBatch.Draw(screen, location, Color.White); } - keyboard.Draw(spriteBatch); + control.Draw(spriteBatch); + + if (Shared.IsJoystickDisplayed) + { + joystick.Draw(spriteBatch); + } + else + { + keyboard.Draw(spriteBatch); + } + spriteBatch.End(); + SharedGraphicsDeviceManager.Current.GraphicsDevice.Textures[0] = null; } @@ -279,6 +299,15 @@ namespace wpspec case ControlKeySymbol.KeyTurbo: resetPressed = false; turbo = e.Pressed; + + if (turbo) + { + SoundManager.StopSoundManager(); + } + else + { + SoundManager.StopSoundManager(); + } break; case ControlKeySymbol.KeyJoystick: diff --git a/wpspec/wpspec/Resources/Strings.Designer.cs b/wpspec/wpspec/Resources/Strings.Designer.cs index 17a18c4..44e24e3 100644 --- a/wpspec/wpspec/Resources/Strings.Designer.cs +++ b/wpspec/wpspec/Resources/Strings.Designer.cs @@ -380,7 +380,7 @@ namespace wpspec.Resources { } /// - /// Looks up a localized string similar to Cursor Joystick Enabled. + /// Looks up a localized string similar to Cursor. /// public static string SettingsCursorJoystick { get { @@ -389,7 +389,7 @@ namespace wpspec.Resources { } /// - /// Looks up a localized string similar to Fuller Joystick Enabled. + /// Looks up a localized string similar to Fuller. /// public static string SettingsFullerJoystick { get { @@ -406,6 +406,15 @@ namespace wpspec.Resources { } } + /// + /// Looks up a localized string similar to Joysticks. + /// + public static string SettingsJoystick { + get { + return ResourceManager.GetString("SettingsJoystick", resourceCulture); + } + } + /// /// Looks up a localized string similar to Joystick Lock. /// @@ -416,7 +425,7 @@ namespace wpspec.Resources { } /// - /// Looks up a localized string similar to Kempston Joystick Enabled. + /// Looks up a localized string similar to Kempston. /// public static string SettingsKempstonJoystick { get { @@ -425,7 +434,7 @@ namespace wpspec.Resources { } /// - /// Looks up a localized string similar to Miner Willy Joystick. + /// Looks up a localized string similar to Miner Willy. /// public static string SettingsManicJoystick { get { diff --git a/wpspec/wpspec/Resources/Strings.resx b/wpspec/wpspec/Resources/Strings.resx index edd0bd0..8751701 100644 --- a/wpspec/wpspec/Resources/Strings.resx +++ b/wpspec/wpspec/Resources/Strings.resx @@ -251,18 +251,21 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY Tape Contents - Cursor Joystick Enabled + Cursor - Fuller Joystick Enabled + Fuller Joystick Lock - Miner Willy Joystick + Miner Willy - Kempston Joystick Enabled + Kempston + + + Joysticks \ No newline at end of file diff --git a/wpspec/wpspec/Resources/controls.keyboard b/wpspec/wpspec/Resources/controls.keyboard index 5777cc5..7413389 100644 Binary files a/wpspec/wpspec/Resources/controls.keyboard and b/wpspec/wpspec/Resources/controls.keyboard differ diff --git a/wpspec/wpspec/Settings.cs b/wpspec/wpspec/Settings.cs index 5c7f5ef..872384f 100644 --- a/wpspec/wpspec/Settings.cs +++ b/wpspec/wpspec/Settings.cs @@ -127,7 +127,16 @@ namespace wpspec if (!value.Equals(setting)) { setting = value; - IsolatedStorageSettings.ApplicationSettings.Add(name, setting); + + if (IsolatedStorageSettings.ApplicationSettings.Contains(name)) + { + IsolatedStorageSettings.ApplicationSettings[name] = value; + } + else + { + IsolatedStorageSettings.ApplicationSettings.Add(name, value); + } + IsolatedStorageSettings.ApplicationSettings.Save(); } } diff --git a/wpspec/wpspec/SettingsPage.xaml b/wpspec/wpspec/SettingsPage.xaml index 8f3ab9c..af2fb4d 100644 --- a/wpspec/wpspec/SettingsPage.xaml +++ b/wpspec/wpspec/SettingsPage.xaml @@ -8,6 +8,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:res="clr-namespace:wpspec.Resources" xmlns:conv="clr-namespace:wpspec.Converters" + xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" @@ -17,7 +18,7 @@ - + @@ -38,6 +39,7 @@ + @@ -46,39 +48,46 @@ - - - - - - - - - - - - - - Eight Way - Four Way - Two Way Horizontal - Two Way Vertical - - + + + + + + Eight Way + Four Way + Two Way Horizontal + Two Way Vertical + + + + + + + + + + + + + + + + diff --git a/wpspec/wpspec/SoundManager.cs b/wpspec/wpspec/SoundManager.cs index e9d079e..aeb0ee6 100644 --- a/wpspec/wpspec/SoundManager.cs +++ b/wpspec/wpspec/SoundManager.cs @@ -41,8 +41,11 @@ namespace wpspec // static public void Play(byte[] buffer) { - sfx.SubmitBuffer(buffer); - sfx.Play(); + if (sfx != null) + { + sfx.SubmitBuffer(buffer); + sfx.Play(); + } } diff --git a/wpspec/wpspec/Spectrum/Emulation.cs b/wpspec/wpspec/Spectrum/Emulation.cs index c436aab..11e84f2 100644 --- a/wpspec/wpspec/Spectrum/Emulation.cs +++ b/wpspec/wpspec/Spectrum/Emulation.cs @@ -27,6 +27,7 @@ using Microsoft.Xna.Framework; using System.Diagnostics; using Microsoft.Xna.Framework.Graphics; using Noddybox.Emulation.EightBit.Z80.Disassembler; +using Noddybox.Emulation.Xna.Input.Joystick; namespace wpspec.Spectrum { @@ -121,6 +122,11 @@ namespace wpspec.Spectrum private bool soundPlayed = false; private int soundLineCount = 0; + // Joystick + // + private DigitalJoystickState joystickState; + private bool[] joystickButtons; + #endregion #region Private Members @@ -560,6 +566,18 @@ namespace wpspec.Spectrum matrix[m.Row] |= m.Set; } + + /// + /// Called when the joystick is updated. + /// + /// The state of the joystick. + /// The state of the buttons. + public void Joystick(DigitalJoystickState state, bool[] buttons) + { + joystickState = state; + joystickButtons = buttons; + } + /// /// Run the emulation for a frame. /// diff --git a/wpspec/wpspec/wpspec.csproj b/wpspec/wpspec/wpspec.csproj index 30498a9..0b7e639 100644 --- a/wpspec/wpspec/wpspec.csproj +++ b/wpspec/wpspec/wpspec.csproj @@ -49,6 +49,7 @@ + @@ -75,6 +76,7 @@ + -- cgit v1.2.3