summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wpspec/wpspec/Resources/Strings.Designer.cs2
-rw-r--r--wpspec/wpspec/Resources/Strings.resx2
-rw-r--r--wpspec/wpspec/Settings.cs48
-rw-r--r--wpspec/wpspec/SettingsPage.xaml1
-rw-r--r--wpspec/wpspec/Shared.cs1
-rw-r--r--wpspec/wpspec/Spectrum/Emulation.cs33
6 files changed, 81 insertions, 6 deletions
diff --git a/wpspec/wpspec/Resources/Strings.Designer.cs b/wpspec/wpspec/Resources/Strings.Designer.cs
index 8e505a0..2c02935 100644
--- a/wpspec/wpspec/Resources/Strings.Designer.cs
+++ b/wpspec/wpspec/Resources/Strings.Designer.cs
@@ -452,7 +452,7 @@ namespace wpspec.Resources {
}
/// <summary>
- /// Looks up a localized string similar to Reserve joystick/buttons.
+ /// Looks up a localized string similar to Reverse joystick/buttons.
/// </summary>
public static string SettingsJoystickLeftHanded {
get {
diff --git a/wpspec/wpspec/Resources/Strings.resx b/wpspec/wpspec/Resources/Strings.resx
index 40ec107..8e8e5aa 100644
--- a/wpspec/wpspec/Resources/Strings.resx
+++ b/wpspec/wpspec/Resources/Strings.resx
@@ -305,6 +305,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
<value>Value</value>
</data>
<data name="SettingsJoystickLeftHanded" xml:space="preserve">
- <value>Reserve joystick/buttons</value>
+ <value>Reverse joystick/buttons</value>
</data>
</root> \ No newline at end of file
diff --git a/wpspec/wpspec/Settings.cs b/wpspec/wpspec/Settings.cs
index e87c071..2b73b62 100644
--- a/wpspec/wpspec/Settings.cs
+++ b/wpspec/wpspec/Settings.cs
@@ -13,13 +13,15 @@ using System.Collections.Generic;
using Noddybox.Emulation.Xna.Input.Joystick;
using wpspec.Spectrum;
using wpspec.ViewModels;
+using Noddybox.Emulation;
+using System.IO;
namespace wpspec
{
/// <summary>
- /// Holds global settings
+ /// Holds global settings. Also acts as state saver for per-game settings and shared settings.
/// </summary>
- public class Settings
+ public class Settings : IEmulationState
{
/// <summary>
/// Get/set whether sound is enabled.
@@ -215,5 +217,47 @@ namespace wpspec
private SettingValue<bool> joystickLeftHanded;
#endregion
+
+ #region IEmulationState Members
+
+ public int Version
+ {
+ get { return 1; }
+ }
+
+ public void SaveState(EmulationStateSaveManager manager)
+ {
+ BinaryWriter str = manager.Stream;
+
+ str.Write(Shared.IsJoystickDisplayed);
+ str.Write(Shared.IsZoomed);
+ str.Write(keyboardJoystick.Setting);
+ str.Write((int)joystickKeyUp.Setting);
+ str.Write((int)joystickKeyDown.Setting);
+ str.Write((int)joystickKeyLeft.Setting);
+ str.Write((int)joystickKeyRight.Setting);
+ str.Write((int)joystickKeyFire1.Setting);
+ str.Write((int)joystickKeyFire2.Setting);
+ str.Write((int)joystickLock.Setting);
+ str.Write(joystickLeftHanded.Setting);
+ }
+
+ public void LoadState(EmulationStateLoadManager manager)
+ {
+ BinaryReader str = manager.Stream;
+
+ Shared.IsJoystickDisplayed = str.ReadBoolean();
+ Shared.IsZoomed = str.ReadBoolean();
+ keyboardJoystick.Setting = str.ReadBoolean();
+ joystickKeyUp.Setting = (SpectrumKeySymbol)str.ReadInt32();
+ joystickKeyDown.Setting = (SpectrumKeySymbol)str.ReadInt32();
+ joystickKeyLeft.Setting = (SpectrumKeySymbol)str.ReadInt32();
+ joystickKeyRight.Setting = (SpectrumKeySymbol)str.ReadInt32();
+ joystickKeyFire1.Setting = (SpectrumKeySymbol)str.ReadInt32();
+ joystickKeyFire2.Setting = (SpectrumKeySymbol)str.ReadInt32();
+ joystickLeftHanded.Setting = str.ReadBoolean();
+ }
+
+ #endregion
}
}
diff --git a/wpspec/wpspec/SettingsPage.xaml b/wpspec/wpspec/SettingsPage.xaml
index 4a3e846..f8ad53e 100644
--- a/wpspec/wpspec/SettingsPage.xaml
+++ b/wpspec/wpspec/SettingsPage.xaml
@@ -116,6 +116,7 @@
<TextBlock Text="{Binding SettingsTapeUrlText, Source={StaticResource Strings}}"
Grid.Row="0" />
<TextBox Text="{Binding TapeUrl, Mode=TwoWay}"
+ InputScope="Url"
Grid.Row="1" />
</Grid>
</controls:PanoramaItem>
diff --git a/wpspec/wpspec/Shared.cs b/wpspec/wpspec/Shared.cs
index 38c391b..0c59f4d 100644
--- a/wpspec/wpspec/Shared.cs
+++ b/wpspec/wpspec/Shared.cs
@@ -1,5 +1,6 @@
using Noddybox.Emulation.Keyboard.Schema;
using wpspec.Spectrum;
+using Noddybox.Emulation;
namespace wpspec
{
diff --git a/wpspec/wpspec/Spectrum/Emulation.cs b/wpspec/wpspec/Spectrum/Emulation.cs
index 9d1bbef..603ef3c 100644
--- a/wpspec/wpspec/Spectrum/Emulation.cs
+++ b/wpspec/wpspec/Spectrum/Emulation.cs
@@ -34,7 +34,7 @@ namespace wpspec.Spectrum
/// <summary>
/// Provides the emulation for the Spectrum
/// </summary>
- public class Emulation: IMemory, IDevice
+ public class Emulation: IMemory, IDevice, IEmulationState
{
#region Private Data
@@ -70,7 +70,7 @@ namespace wpspec.Spectrum
0xff // End of patch
};
- private readonly byte[] mem = new byte[0x10000];
+ private byte[] mem = new byte[0x10000];
private readonly Clock clock = new Clock(0, 224, 312, 0);
// Keyboard matrix. The 9th entry is used to store the joystick state.
@@ -715,5 +715,34 @@ namespace wpspec.Spectrum
}
#endregion
+
+ #region IEmulationState Members
+
+ public int Version
+ {
+ get { return 1; }
+ }
+
+ public void SaveState(EmulationStateSaveManager manager)
+ {
+ BinaryWriter str = manager.Stream;
+
+ str.Write(mem);
+ str.Write(flash);
+ str.Write(flashCounter);
+ str.Write(border);
+ }
+
+ public void LoadState(EmulationStateLoadManager manager)
+ {
+ BinaryReader str = manager.Stream;
+
+ mem = str.ReadBytes(mem.Length);
+ flash = str.ReadBoolean();
+ flashCounter = str.ReadInt32();
+ border = str.ReadInt32();
+ }
+
+ #endregion
}
}