diff options
35 files changed, 813 insertions, 299 deletions
@@ -13,7 +13,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.EightBit EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.EightBit.Z80", "..\Noddybox.Emulation\WindowsPhone\Noddybox.Emulation.EightBit.Z80\Noddybox.Emulation.EightBit.Z80.csproj", "{7F257886-40D3-4E2A-BA9C-C5FEE93C08E9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.EightBit.Z80.Disassembler", "..\Noddybox.Emulation\WindowsPhone\Noddybox.Emulation.EightBit.Z80.Disassembler\Noddybox.Emulation.EightBit.Z80.Disassembler.csproj", "{08D7120E-3D84-49D2-B73D-255E5DB9655C}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.Xna.Input", "..\EmulationKeyboard\WindowsPhone\Noddybox.Emulation.Xna.Input\Noddybox.Emulation.Xna.Input.csproj", "{0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.Keyboard.Schema", "..\EmulationKeyboard\WindowsPhone\Noddybox.Emulation.Keyboard.Schema\Noddybox.Emulation.Keyboard.Schema.csproj", "{0F5AA96A-9253-4E06-A3F9-5517A2A9C558}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -85,16 +87,26 @@ Global {7F257886-40D3-4E2A-BA9C-C5FEE93C08E9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7F257886-40D3-4E2A-BA9C-C5FEE93C08E9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7F257886-40D3-4E2A-BA9C-C5FEE93C08E9}.Release|Windows Phone.ActiveCfg = Release|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Debug|Windows Phone.ActiveCfg = Debug|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Release|Any CPU.Build.0 = Release|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {08D7120E-3D84-49D2-B73D-255E5DB9655C}.Release|Windows Phone.ActiveCfg = Release|Any CPU
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Debug|Mixed Platforms.Build.0 = Debug|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Debug|Windows Phone.Build.0 = Debug|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Release|Any CPU.ActiveCfg = Release|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Release|Mixed Platforms.Build.0 = Release|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Release|Windows Phone.ActiveCfg = Release|Windows Phone
+ {0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}.Release|Windows Phone.Build.0 = Release|Windows Phone
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Windows Phone.ActiveCfg = Debug|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Windows Phone.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/WPZX81/WPZX81/AboutPage.xaml.cs b/WPZX81/WPZX81/AboutPage.xaml.cs index 13c2bca..bfacde2 100644 --- a/WPZX81/WPZX81/AboutPage.xaml.cs +++ b/WPZX81/WPZX81/AboutPage.xaml.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
diff --git a/WPZX81/WPZX81/App.xaml.cs b/WPZX81/WPZX81/App.xaml.cs index b16ca7b..763293d 100644 --- a/WPZX81/WPZX81/App.xaml.cs +++ b/WPZX81/WPZX81/App.xaml.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -15,6 +32,8 @@ using Microsoft.Phone.Shell; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
+using Noddybox.Emulation.Keyboard.Schema;
+using System.IO;
namespace WPZX81
{
@@ -84,6 +103,18 @@ namespace WPZX81 private void Application_Launching(object sender, LaunchingEventArgs e)
{
Shared.ZX81 = new ZX81.Emulation();
+
+ // Dodgy, as these resources really belong to the XNA code, but it saves reloading every time the page is navigated to
+ //
+ using (BinaryReader stream = new BinaryReader(App.GetResourceStream(new Uri("Resources/ZX81.keyboard", UriKind.Relative)).Stream))
+ {
+ Shared.ZX81Keyboard = KeyboardDefinition.Load(stream);
+ }
+
+ using (BinaryReader stream = new BinaryReader(App.GetResourceStream(new Uri("Resources/controls.keyboard", UriKind.Relative)).Stream))
+ {
+ Shared.ControlKeyboard = KeyboardDefinition.Load(stream);
+ }
}
// Code to execute when the application is activated (brought to foreground)
diff --git a/WPZX81/WPZX81/ApplicationIcon.png b/WPZX81/WPZX81/ApplicationIcon.png Binary files differindex a3de0bb..ac20584 100644 --- a/WPZX81/WPZX81/ApplicationIcon.png +++ b/WPZX81/WPZX81/ApplicationIcon.png diff --git a/WPZX81/WPZX81/Background.png b/WPZX81/WPZX81/Background.png Binary files differindex 13e6cfa..98446bf 100644 --- a/WPZX81/WPZX81/Background.png +++ b/WPZX81/WPZX81/Background.png diff --git a/WPZX81/WPZX81/Converters/ConvertFlagsToString.cs b/WPZX81/WPZX81/Converters/ConvertFlagsToString.cs new file mode 100644 index 0000000..0cc17fd --- /dev/null +++ b/WPZX81/WPZX81/Converters/ConvertFlagsToString.cs @@ -0,0 +1,59 @@ +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;
+using Noddybox.Emulation.EightBit.Z80;
+
+namespace WPZX81.Converters
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class ConvertFlagsToString : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ object ret = null;
+
+ if (value is Z80Flags)
+ {
+ int flag = (int)value;
+ char[] names = new char[8] {'C', 'N', 'P', '3', 'H', '5', 'Z', 'S'};
+ char[] flags = new char[8];
+ int f;
+
+ for(f = 0; f < 8; f++)
+ {
+ if ((flag & (1 << f)) == (1 << f))
+ {
+ flags[7-f] = names[7-f];
+ }
+ else
+ {
+ flags[7-f] = '-';
+ }
+ }
+
+ ret = new string(flags);
+ }
+
+ return ret;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/WPZX81/WPZX81/Converters/ConvertIntToHex2.cs b/WPZX81/WPZX81/Converters/ConvertIntToHex2.cs new file mode 100644 index 0000000..2a04953 --- /dev/null +++ b/WPZX81/WPZX81/Converters/ConvertIntToHex2.cs @@ -0,0 +1,42 @@ +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 WPZX81.Converters
+{
+ /// <summary>
+ /// Convert an integer to a 2-digit hex string.
+ /// </summary>
+ public class ConvertIntToHex2 : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ object ret = null;
+
+ if (value is int)
+ {
+ int i = (int)value;
+ ret = i.ToString("X2");
+ }
+
+ return ret;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/WPZX81/WPZX81/Converters/ConvertIntToHex4.cs b/WPZX81/WPZX81/Converters/ConvertIntToHex4.cs new file mode 100644 index 0000000..77d9bd5 --- /dev/null +++ b/WPZX81/WPZX81/Converters/ConvertIntToHex4.cs @@ -0,0 +1,42 @@ +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 WPZX81.Converters
+{
+ /// <summary>
+ /// Convert an integer to a 4-digit hex string.
+ /// </summary>
+ public class ConvertIntToHex4 : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ object ret = null;
+
+ if (value is int)
+ {
+ int i = (int)value;
+ ret = i.ToString("X4");
+ }
+
+ return ret;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/WPZX81/WPZX81/GamePage.xaml.cs b/WPZX81/WPZX81/GamePage.xaml.cs index 6d19bbc..7857007 100644 --- a/WPZX81/WPZX81/GamePage.xaml.cs +++ b/WPZX81/WPZX81/GamePage.xaml.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -7,20 +24,47 @@ using System.Windows.Controls; using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Navigation;
-using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.Diagnostics;
+using WPZX81.ZX81;
+using Noddybox.Emulation.Xna.Input;
+using Noddybox.Emulation.Xna.Input.Keyboard;
+using Microsoft.Xna.Framework.Input.Touch;
+using Noddybox.Emulation.Xna.Input.Joystick;
namespace WPZX81
{
public partial class GamePage : PhoneApplicationPage
{
- ContentManager contentManager;
- GameTimer timer;
- SpriteBatch spriteBatch;
+ private enum ControlKeySymbol
+ {
+ KeyReset, KeyTurbo, KeyJoystick, KeyKeyboard
+ }
+
+ private ContentManager contentManager;
+ private GameTimer timer;
+ private SpriteBatch spriteBatch;
+
+ private Texture2D screen;
+ private Vector2 location;
+ private Rectangle locationZoomed;
+
+ private Texture2D keyboardImage;
+ private Texture2D controlImage;
+ private Texture2D joystickBackgroundImage;
+ private Texture2D joystickButtonImage;
+ private Texture2D joystickImage;
+
+ private InputManager inputManager;
+ private KeyboardDriver<ZX81KeySymbol> keyboard;
+ private KeyboardDriver<ControlKeySymbol> control;
+ private JoystickDriver joystick;
+ private bool resetPressed;
+
+ private bool turbo;
public GamePage()
{
@@ -38,16 +82,116 @@ namespace WPZX81 protected override void OnNavigatedTo(NavigationEventArgs e)
{
+ // Set the sharing mode of the graphics device to turn on XNA rendering
+ //
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);
+
+ // Create a new SpriteBatch, which can be used to draw textures.
+ //
spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
+
+ // Create screen object
+ //
+ screen = new Texture2D
+ (SharedGraphicsDeviceManager.Current.GraphicsDevice,
+ Shared.ZX81.Width,
+ Shared.ZX81.Height,
+ false, Shared.ZX81.ScreenFormat);
+
+ // Start the timer
+ //
timer.Start();
+
+ // Initialise locations for normal and zoomed display
+ //
+ location = new Vector2(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width / 2 - Shared.ZX81.Width / 2, 10);
+ locationZoomed = new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width / 2 - Shared.ZX81.Width * 100 / 140, 10,
+ Shared.ZX81.Height * 100 / 70, Shared.ZX81.Width * 100 / 70);
+
+ // Create a keyboard driver
+ //
+ resetPressed = false;
+
+ inputManager = new InputManager();
+
+ keyboardImage = contentManager.Load<Texture2D>("keyboard");
+ controlImage = contentManager.Load<Texture2D>("controls");
+ joystickBackgroundImage = contentManager.Load<Texture2D>("joystick_background");
+ joystickImage = contentManager.Load<Texture2D>("joystick");
+ joystickButtonImage = contentManager.Load<Texture2D>("button");
+
+ keyboard = new KeyboardDriver<ZX81KeySymbol>
+ (inputManager,
+ SharedGraphicsDeviceManager.Current.GraphicsDevice,
+ keyboardImage,
+ new Vector2(0, 490),
+ Shared.ZX81Keyboard);
+
+ keyboard.KeyEvent += HandleKeyboardEvent;
+
+ control = new KeyboardDriver<ControlKeySymbol>
+ (inputManager,
+ SharedGraphicsDeviceManager.Current.GraphicsDevice,
+ controlImage,
+ new Vector2(0, 450),
+ Shared.ControlKeyboard);
+
+ control.KeyEvent += HandleControlEvent;
+
+ joystick = new JoystickDriver(inputManager,
+ SharedGraphicsDeviceManager.Current.GraphicsDevice,
+ JoystickType.Digital,
+ joystickBackgroundImage, joystickImage, joystickButtonImage,
+ new Vector2(0, 490),
+ new Vector2(125),
+ new Vector2[2] {new Vector2(280, 100), new Vector2(380, 125)},
+ 20, 75);
+
+ joystick.DigitalEvent += HandleJoystickEvent;
+
+ if (Shared.IsJoystickDisplayed)
+ {
+ keyboard.StopKeyboardUpdates();
+ }
+ else
+ {
+ joystick.StopJoystickUpdates();
+ }
+
+ inputManager.TouchEvent += HandleTouchEvent;
+
base.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
+ // Stop the timer
+ //
timer.Stop();
+
+ // Set the sharing mode of the graphics device to turn off XNA rendering
+ //
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false);
+
+ screen.Dispose();
+ screen = null;
+
+ // Remove the inputs
+ //
+ keyboard.StopKeyboardUpdates();
+ joystick.StopJoystickUpdates();
+ control.StopKeyboardUpdates();
+
+ keyboard.KeyEvent -= HandleKeyboardEvent;
+ control.KeyEvent -= HandleControlEvent;
+ joystick.DigitalEvent -= HandleJoystickEvent;
+ inputManager.TouchEvent -= HandleTouchEvent;
+
+ keyboard = null;
+ control = null;
+ joystick = null;
+ inputManager = null;
+
base.OnNavigatedFrom(e);
}
@@ -57,6 +201,7 @@ namespace WPZX81 /// </summary>
private void OnUpdate(object sender, GameTimerEventArgs e)
{
+ inputManager.Update();
Shared.ZX81.Run();
}
@@ -65,15 +210,117 @@ namespace WPZX81 /// </summary>
private void OnDraw(object sender, GameTimerEventArgs e)
{
- Stopwatch s = Stopwatch.StartNew();
-
SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.Black);
+
+ screen.SetData(Shared.ZX81.Screen);
+
spriteBatch.Begin();
- Shared.ZX81.UpdateDisplay(spriteBatch);
+
+ if (Shared.IsZoomed)
+ {
+ spriteBatch.Draw(screen, locationZoomed, Color.White);
+ }
+ else
+ {
+ spriteBatch.Draw(screen, location, Color.White);
+ }
+
+ if (Shared.IsJoystickDisplayed)
+ {
+ joystick.Draw(spriteBatch);
+ }
+ else
+ {
+ keyboard.Draw(spriteBatch);
+ }
+
+ control.Draw(spriteBatch);
+
spriteBatch.End();
- s.Stop();
- Debug.WriteLine("*** RENDER {0} msec {1} ticks", s.ElapsedMilliseconds, s.ElapsedTicks);
+ SharedGraphicsDeviceManager.Current.GraphicsDevice.Textures[0] = null;
+ }
+
+ #region Keyboard driver events
+
+ private void HandleControlEvent(object sender, KeyboardDriver<ControlKeySymbol>.KeyPressEventArgs e)
+ {
+ switch (e.Key)
+ {
+ case ControlKeySymbol.KeyReset:
+ if (!e.Pressed)
+ {
+ if (resetPressed)
+ {
+ resetPressed = false;
+ Shared.ZX81.Reset();
+ }
+ else
+ {
+ resetPressed = true;
+ }
+ }
+ break;
+
+ case ControlKeySymbol.KeyTurbo:
+ resetPressed = false;
+ turbo = e.Pressed;
+ break;
+
+ case ControlKeySymbol.KeyJoystick:
+ resetPressed = false;
+
+ if (!Shared.IsJoystickDisplayed)
+ {
+ joystick.StartJoystickUpdates();
+ keyboard.StopKeyboardUpdates();
+ Shared.IsJoystickDisplayed = true;
+ }
+ break;
+
+ case ControlKeySymbol.KeyKeyboard:
+ resetPressed = false;
+
+ if (Shared.IsJoystickDisplayed)
+ {
+ joystick.StopJoystickUpdates();
+ keyboard.StartKeyboardUpdates();
+ Shared.IsJoystickDisplayed = false;
+ }
+ break;
+ }
+ }
+
+ private void HandleKeyboardEvent(object sender, KeyboardDriver<ZX81KeySymbol>.KeyPressEventArgs e)
+ {
+ resetPressed = false;
+
+ if (e.Pressed)
+ {
+ Shared.ZX81.KeyPressed(e.Key);
+ }
+ else
+ {
+ Shared.ZX81.KeyReleased(e.Key);
+ }
+ }
+
+ private void HandleTouchEvent(object sender, InputManager.TouchLocationEventArgs e)
+ {
+ resetPressed = false;
+
+ if (e.Location.State == TouchLocationState.Released && e.Location.Position.Y < 400)
+ {
+ e.Handled = true;
+ Shared.IsZoomed = !Shared.IsZoomed;
+ }
}
+
+ private void HandleJoystickEvent(object sender, JoystickDriver.DigitalJoystickEventArgs e)
+ {
+ resetPressed = false;
+ }
+
+ #endregion
}
}
\ No newline at end of file diff --git a/WPZX81/WPZX81/MainPage.xaml b/WPZX81/WPZX81/MainPage.xaml index caa591c..b38e2da 100644 --- a/WPZX81/WPZX81/MainPage.xaml +++ b/WPZX81/WPZX81/MainPage.xaml @@ -54,12 +54,12 @@ FontSize="18"
Click="RunEmulationClick">
</Button>
- <!-- Open Remote Tape -->
+ <!-- View Keyboard-->
<Button Height="100"
- Content="{Binding DisassemblerButtonText, Source={StaticResource Strings}}"
+ Content="{Binding ViewKeyboardButtonText, Source={StaticResource Strings}}"
Grid.Row="0" Grid.Column="1"
FontSize="18"
- Click="OpenDisassemblerClick" />
+ Click="ViewKeyboardClick" />
<!-- Open Local Tape -->
<Button Height="100"
Content="{Binding OpenGameStateButtonText, Source={StaticResource Strings}}"
diff --git a/WPZX81/WPZX81/MainPage.xaml.cs b/WPZX81/WPZX81/MainPage.xaml.cs index 940f05c..a7cdc23 100644 --- a/WPZX81/WPZX81/MainPage.xaml.cs +++ b/WPZX81/WPZX81/MainPage.xaml.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -26,9 +43,9 @@ namespace WPZX81 NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));
}
- private void OpenDisassemblerClick(object sender, RoutedEventArgs e)
+ private void ViewKeyboardClick(object sender, RoutedEventArgs e)
{
- NavigationService.Navigate(new Uri("/DisassemblerPage.xaml", UriKind.Relative));
+ NavigationService.Navigate(new Uri("/ViewKeyboardPage.xaml", UriKind.Relative));
}
private void OpenGameStateClick(object sender, RoutedEventArgs e)
diff --git a/WPZX81/WPZX81/Resources/Strings.Designer.cs b/WPZX81/WPZX81/Resources/Strings.Designer.cs index b245b13..b869c1f 100644 --- a/WPZX81/WPZX81/Resources/Strings.Designer.cs +++ b/WPZX81/WPZX81/Resources/Strings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.261
+// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -110,51 +110,6 @@ namespace WPZX81.Resources { }
/// <summary>
- /// Looks up a localized string similar to Disassembler.
- /// </summary>
- public static string DisassemblerButtonText {
- get {
- return ResourceManager.GetString("DisassemblerButtonText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Disassembler.
- /// </summary>
- public static string DisassemblerPageTitle {
- get {
- return ResourceManager.GetString("DisassemblerPageTitle", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Run for a frame.
- /// </summary>
- public static string DisassemblerRunFrameButtonText {
- get {
- return ResourceManager.GetString("DisassemblerRunFrameButtonText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Step.
- /// </summary>
- public static string DisassemblerStepButtonText {
- get {
- return ResourceManager.GetString("DisassemblerStepButtonText", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Z80 State.
- /// </summary>
- public static string DisassemblerZ80Text {
- get {
- return ResourceManager.GetString("DisassemblerZ80Text", resourceCulture);
- }
- }
-
- /// <summary>
/// Looks up a localized string similar to See the GNU General Public License Online.
/// </summary>
public static string LicenseHyperlinkText {
@@ -245,7 +200,7 @@ namespace WPZX81.Resources { }
/// <summary>
- /// Looks up a localized string similar to Copyright of the included ZX81 ROM is held by Nine Tiles Network Ltd and is NOT released under the above license. The ROM image is included with the kind permission of John Grant at Nine Tiles..
+ /// Looks up a localized string similar to Copyright of the included ZX81 ROM is held by Nine Tiles Network Ltd and is NOT released under the above license. The ROM image is included with the kind permission of John Grant at Nine Tiles Network Ltd..
/// </summary>
public static string ROMCopyrightText {
get {
@@ -317,7 +272,7 @@ namespace WPZX81.Resources { }
/// <summary>
- /// Looks up a localized string similar to Copyright of the included ZX81 ROM is held by Nine Tile Network Ltd. The ROM image is included with the kind permission of John Grant at Nine Tiles..
+ /// Looks up a localized string similar to Copyright of the included ZX81 ROM is held by Nine Tiles Network Ltd. The ROM image is included with the kind permission of John Grant..
/// </summary>
public static string ShortROMCopyrightText {
get {
@@ -353,11 +308,11 @@ namespace WPZX81.Resources { }
/// <summary>
- /// Looks up a localized string similar to Sticky Shift Key.
+ /// Looks up a localized string similar to View Keyboard.
/// </summary>
- public static string StickyShiftKeyText {
+ public static string ViewKeyboardButtonText {
get {
- return ResourceManager.GetString("StickyShiftKeyText", resourceCulture);
+ return ResourceManager.GetString("ViewKeyboardButtonText", resourceCulture);
}
}
}
diff --git a/WPZX81/WPZX81/Resources/Strings.resx b/WPZX81/WPZX81/Resources/Strings.resx index 9880707..674127f 100644 --- a/WPZX81/WPZX81/Resources/Strings.resx +++ b/WPZX81/WPZX81/Resources/Strings.resx @@ -154,11 +154,8 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY <data name="OpenGameStatePageTitle" xml:space="preserve">
<value>Load Game</value>
</data>
- <data name="DisassemblerButtonText" xml:space="preserve">
- <value>Disassembler</value>
- </data>
- <data name="DisassemblerPageTitle" xml:space="preserve">
- <value>Disassembler</value>
+ <data name="ViewKeyboardButtonText" xml:space="preserve">
+ <value>View Keyboard</value>
</data>
<data name="ROMCopyrightHyperlinkText" xml:space="preserve">
<value>Nine Tiles Network Ltd.</value>
@@ -167,7 +164,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY <value>http://www.ninetiles.com/</value>
</data>
<data name="ROMCopyrightText" xml:space="preserve">
- <value>Copyright of the included ZX81 ROM is held by Nine Tiles Network Ltd and is NOT released under the above license. The ROM image is included with the kind permission of John Grant at Nine Tiles.</value>
+ <value>Copyright of the included ZX81 ROM is held by Nine Tiles Network Ltd and is NOT released under the above license. The ROM image is included with the kind permission of John Grant at Nine Tiles Network Ltd.</value>
</data>
<data name="RunEmulationButtonText" xml:space="preserve">
<value>Run Sinclair ZX81</value>
@@ -197,7 +194,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY <value>WPZX81 is Copyright © 2012 noddybox</value>
</data>
<data name="ShortROMCopyrightText" xml:space="preserve">
- <value>Copyright of the included ZX81 ROM is held by Nine Tile Network Ltd. The ROM image is included with the kind permission of John Grant at Nine Tiles.</value>
+ <value>Copyright of the included ZX81 ROM is held by Nine Tiles Network Ltd. The ROM image is included with the kind permission of John Grant.</value>
</data>
<data name="RemoteURLForPFileText" xml:space="preserve">
<value>URL for remote location of .P files</value>
@@ -205,19 +202,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY <data name="StaticRamAt0x2000Text" xml:space="preserve">
<value>Static RAM at 0x2000</value>
</data>
- <data name="StickyShiftKeyText" xml:space="preserve">
- <value>Sticky Shift Key</value>
- </data>
<data name="RamPackText" xml:space="preserve">
<value>16K RAM Pack Inserted</value>
</data>
- <data name="DisassemblerRunFrameButtonText" xml:space="preserve">
- <value>Run for a frame</value>
- </data>
- <data name="DisassemblerStepButtonText" xml:space="preserve">
- <value>Step</value>
- </data>
- <data name="DisassemblerZ80Text" xml:space="preserve">
- <value>Z80 State</value>
- </data>
</root>
\ No newline at end of file diff --git a/WPZX81/WPZX81/Resources/ZX81.keyboard b/WPZX81/WPZX81/Resources/ZX81.keyboard Binary files differnew file mode 100644 index 0000000..b9d3461 --- /dev/null +++ b/WPZX81/WPZX81/Resources/ZX81.keyboard diff --git a/WPZX81/WPZX81/Resources/controls.keyboard b/WPZX81/WPZX81/Resources/controls.keyboard Binary files differnew file mode 100644 index 0000000..5777cc5 --- /dev/null +++ b/WPZX81/WPZX81/Resources/controls.keyboard diff --git a/WPZX81/WPZX81/Resources/keyboard_image.png b/WPZX81/WPZX81/Resources/keyboard_image.png Binary files differnew file mode 100644 index 0000000..84e54a9 --- /dev/null +++ b/WPZX81/WPZX81/Resources/keyboard_image.png diff --git a/WPZX81/WPZX81/Settings.cs b/WPZX81/WPZX81/Settings.cs index f9ca28b..4af7c6c 100644 --- a/WPZX81/WPZX81/Settings.cs +++ b/WPZX81/WPZX81/Settings.cs @@ -1,4 +1,21 @@ -using System.Collections.Generic;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System.Collections.Generic;
using System.IO.IsolatedStorage;
namespace WPZX81
@@ -15,22 +32,6 @@ namespace WPZX81 public static int FramesPerUpdate {get {return 2;}}
/// <summary>
- /// Get/set whether there is a sticky shift key.
- /// </summary>
- public static bool StickyShift
- {
- get {return stickyShift;}
- set
- {
- if (stickyShift != value)
- {
- stickyShift = value;
- Save("StickyShift", stickyShift);
- }
- }
- }
-
- /// <summary>
/// Get/set URL to load .P files from.
/// </summary>
public static string PFileUrl
@@ -82,7 +83,6 @@ namespace WPZX81 #region Private code
- private static bool stickyShift = Load("StickyShift", false);
private static string pFileUrl = Load("PFileUrl", "http://enter-a-url.here/");
private static bool staticRamAt0x2000 = Load("StaticRamAt0x2000", false);
private static bool ramPack = Load("RamPack", true);
diff --git a/WPZX81/WPZX81/SettingsPage.xaml b/WPZX81/WPZX81/SettingsPage.xaml index 4243415..4b0fe3c 100644 --- a/WPZX81/WPZX81/SettingsPage.xaml +++ b/WPZX81/WPZX81/SettingsPage.xaml @@ -52,12 +52,9 @@ <CheckBox IsChecked="{Binding RamPackSetting, Mode=TwoWay}"
Content="{Binding RamPackText, Source={StaticResource Strings}}"
Grid.Row="2" />
- <CheckBox IsChecked="{Binding StickyShiftSetting, Mode=TwoWay}"
- Content="{Binding StickyShiftKeyText, Source={StaticResource Strings}}"
- Grid.Row="3" />
<CheckBox IsChecked="{Binding StaticRamAt0x2000Setting, Mode=TwoWay}"
Content="{Binding StaticRamAt0x2000Text, Source={StaticResource Strings}}"
- Grid.Row="4" />
+ Grid.Row="3" />
</Grid>
</Grid>
diff --git a/WPZX81/WPZX81/SettingsPage.xaml.cs b/WPZX81/WPZX81/SettingsPage.xaml.cs index 5bf0c94..0f28a71 100644 --- a/WPZX81/WPZX81/SettingsPage.xaml.cs +++ b/WPZX81/WPZX81/SettingsPage.xaml.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -27,12 +44,6 @@ namespace WPZX81 set {Settings.PFileUrl = value;}
}
- public bool StickyShiftSetting
- {
- get {return Settings.StickyShift;}
- set {Settings.StickyShift = value;}
- }
-
public bool StaticRamAt0x2000Setting
{
get {return Settings.StaticRamAt0x2000;}
diff --git a/WPZX81/WPZX81/Shared.cs b/WPZX81/WPZX81/Shared.cs index 04f4588..cee1e32 100644 --- a/WPZX81/WPZX81/Shared.cs +++ b/WPZX81/WPZX81/Shared.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
@@ -9,6 +26,7 @@ using System.Windows.Media; using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WPZX81.ZX81;
+using Noddybox.Emulation.Keyboard.Schema;
namespace WPZX81
{
@@ -21,5 +39,25 @@ namespace WPZX81 /// The emulation driving the ZX81.
/// </summary>
public static Emulation ZX81 {get; set;}
+
+ /// <summary>
+ /// Whether the display has been zoomed.
+ /// </summary>
+ public static bool IsZoomed {get; set;}
+
+ /// <summary>
+ /// Whether the joystick is displayed.
+ /// </summary>
+ public static bool IsJoystickDisplayed {get; set;}
+
+ /// <summary>
+ /// The layout for the ZX81 keyboard.
+ /// </summary>
+ public static KeyboardDefinition ZX81Keyboard {get; set;}
+
+ /// <summary>
+ /// The layout for the control keyboard.
+ /// </summary>
+ public static KeyboardDefinition ControlKeyboard {get; set;}
}
}
diff --git a/WPZX81/WPZX81/ViewKeyboardPage.xaml b/WPZX81/WPZX81/ViewKeyboardPage.xaml new file mode 100644 index 0000000..1981de5 --- /dev/null +++ b/WPZX81/WPZX81/ViewKeyboardPage.xaml @@ -0,0 +1,24 @@ +<phone:PhoneApplicationPage
+ x:Class="WPZX81.ViewKeyboardPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
+ xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ FontFamily="{StaticResource PhoneFontFamilyNormal}"
+ FontSize="{StaticResource PhoneFontSizeNormal}"
+ Foreground="{StaticResource PhoneForegroundBrush}"
+ SupportedOrientations="Portrait" Orientation="Portrait"
+ mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
+ shell:SystemTray.IsVisible="False">
+
+ <ScrollViewer>
+ <Image Source="/WPZX81;component/Resources/keyboard_image.png">
+ <Image.RenderTransform>
+ <ScaleTransform ScaleX="1" ScaleY="1" />
+ </Image.RenderTransform>
+ </Image>
+ </ScrollViewer>
+
+</phone:PhoneApplicationPage>
diff --git a/WPZX81/WPZX81/ViewKeyboardPage.xaml.cs b/WPZX81/WPZX81/ViewKeyboardPage.xaml.cs new file mode 100644 index 0000000..f2d34a5 --- /dev/null +++ b/WPZX81/WPZX81/ViewKeyboardPage.xaml.cs @@ -0,0 +1,40 @@ +// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+
+namespace WPZX81
+{
+ public partial class ViewKeyboardPage : PhoneApplicationPage
+ {
+ public ViewKeyboardPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file diff --git a/WPZX81/WPZX81/ViewModels/BaseViewModel.cs b/WPZX81/WPZX81/ViewModels/BaseViewModel.cs index 6a96d0b..0ffdca5 100644 --- a/WPZX81/WPZX81/ViewModels/BaseViewModel.cs +++ b/WPZX81/WPZX81/ViewModels/BaseViewModel.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.ComponentModel;
using System.Net;
using System.Windows;
diff --git a/WPZX81/WPZX81/WPZX81.csproj b/WPZX81/WPZX81/WPZX81.csproj index 40b1311..903deac 100644 --- a/WPZX81/WPZX81/WPZX81.csproj +++ b/WPZX81/WPZX81/WPZX81.csproj @@ -72,9 +72,6 @@ <Compile Include="Converters\ConvertFlagsToString.cs" />
<Compile Include="Converters\ConvertIntToHex2.cs" />
<Compile Include="Converters\ConvertIntToHex4.cs" />
- <Compile Include="DisassemblerPage.xaml.cs">
- <DependentUpon>DisassemblerPage.xaml</DependentUpon>
- </Compile>
<Compile Include="GamePage.xaml.cs">
<DependentUpon>GamePage.xaml</DependentUpon>
</Compile>
@@ -93,10 +90,12 @@ <DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
<Compile Include="Shared.cs" />
+ <Compile Include="ViewKeyboardPage.xaml.cs">
+ <DependentUpon>ViewKeyboardPage.xaml</DependentUpon>
+ </Compile>
<Compile Include="ViewModels\BaseViewModel.cs" />
- <Compile Include="ViewModels\DisassemblerLine.cs" />
- <Compile Include="ViewModels\DisassemblerViewModel.cs" />
<Compile Include="ZX81\Emulation.cs" />
+ <Compile Include="ZX81\ZX81KeySymbol.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
@@ -107,10 +106,6 @@ <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="DisassemblerPage.xaml">
- <SubType>Designer</SubType>
- <Generator>MSBuild:Compile</Generator>
- </Page>
<Page Include="GamePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -123,11 +118,18 @@ <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="ViewKeyboardPage.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml" />
+ <Resource Include="Resources\keyboard_image.png" />
<Content Include="Resources\zx81.rom" />
+ <Content Include="Resources\controls.keyboard" />
+ <Content Include="Resources\ZX81.keyboard" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png">
@@ -139,9 +141,13 @@ <Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\..\Noddybox.Emulation\WindowsPhone\Noddybox.Emulation.EightBit.Z80.Disassembler\Noddybox.Emulation.EightBit.Z80.Disassembler.csproj">
- <Project>{08D7120E-3D84-49D2-B73D-255E5DB9655C}</Project>
- <Name>Noddybox.Emulation.EightBit.Z80.Disassembler</Name>
+ <ProjectReference Include="..\..\..\EmulationKeyboard\WindowsPhone\Noddybox.Emulation.Keyboard.Schema\Noddybox.Emulation.Keyboard.Schema.csproj">
+ <Project>{0F5AA96A-9253-4E06-A3F9-5517A2A9C558}</Project>
+ <Name>Noddybox.Emulation.Keyboard.Schema</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\EmulationKeyboard\WindowsPhone\Noddybox.Emulation.Xna.Input\Noddybox.Emulation.Xna.Input.csproj">
+ <Project>{0F95CAB2-B79A-45B5-B5F2-14F4CED2EF20}</Project>
+ <Name>Noddybox.Emulation.Xna.Input</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Noddybox.Emulation\WindowsPhone\Noddybox.Emulation.EightBit.Z80\Noddybox.Emulation.EightBit.Z80.csproj">
<Project>{7F257886-40D3-4E2A-BA9C-C5FEE93C08E9}</Project>
diff --git a/WPZX81/WPZX81/ZX81/Emulation.cs b/WPZX81/WPZX81/ZX81/Emulation.cs index 78a2726..8df4c39 100644 --- a/WPZX81/WPZX81/ZX81/Emulation.cs +++ b/WPZX81/WPZX81/ZX81/Emulation.cs @@ -1,4 +1,21 @@ -using System;
+// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using Noddybox.Emulation;
using Noddybox.Emulation.EightBit;
using Noddybox.Emulation.EightBit.Z80;
@@ -6,7 +23,6 @@ using Microsoft.Xna.Framework.Graphics; using System.Windows.Resources;
using Microsoft.Xna.Framework;
using System.Diagnostics;
-using Noddybox.Emulation.EightBit.Z80.Disassembler;
namespace WPZX81.ZX81
{
@@ -28,7 +44,6 @@ namespace WPZX81.ZX81 private byte[] matrix;
private uint prev_last_key1;
private uint prev_last_key2;
- private Texture2D[] font;
// Some system variables
//
@@ -116,58 +131,6 @@ namespace WPZX81.ZX81 }
/// <summary>
- /// Loads the font from the ZX81 according to the I register.
- /// </summary>
- private void LoadFont()
- {
- ushort[] data = new ushort[64];
- Register16 addr = new Register16(0);
-
- addr.high = Z80.InterruptVector;
-
- Debug.WriteLine("Loading font from 0x{0:X4}", addr.reg);
-
- for(int f = 0 ; f < 64; f++)
- {
- if (font[f] != null)
- {
- font[f].Dispose();
- }
-
- font[f] = new Texture2D(SharedGraphicsDeviceManager.Current.GraphicsDevice, 8, 8, false, SurfaceFormat.Bgr565);
- font[f+128] = new Texture2D(SharedGraphicsDeviceManager.Current.GraphicsDevice, 8, 8, false, SurfaceFormat.Bgr565);
-
- int i = 0;
-
- for(int r = 0 ; r < 8; r++)
- {
- for(int b = 128; b > 0; b /= 2)
- {
- if ((mem[addr.reg] & b) != 0)
- {
- data[i++] = ushort.MaxValue;
- }
- else
- {
- data[i++] = ushort.MinValue;
- }
- }
-
- addr.reg++;
- }
-
- font[f].SetData(data);
-
- for(i = 0; i < 64; i++)
- {
- data[i] ^= ushort.MaxValue;
- }
-
- font[f+128].SetData(data);
- }
- }
-
- /// <summary>
/// Patches a route to an address in memory.
/// </summary>
/// <param name="address">The starting address to patch.</param>
@@ -330,9 +293,26 @@ namespace WPZX81.ZX81 public Z80Cpu Z80 {private set; get;}
/// <summary>
- /// A disassembler for this machine.
+ /// Get the width of the emulated screen in pixels.
+ /// </summary>
+ public int Width {get {return 256;}}
+
+ /// <summary>
+ /// Get the height of the emulated screen in pixels.
/// </summary>
- public Z80Disassembler Disassembler {private set; get;}
+ public int Height {get {return 192;}}
+
+ /// <summary>
+ /// Gets the format of data returned by
+ /// </summary>
+ public SurfaceFormat ScreenFormat {get {return SurfaceFormat.Bgr565;}}
+
+ /// <summary>
+ /// Get the emulated screen contents.
+ /// This array must have <see cref="Width"/> times <see cref="Height"/>
+ /// elements.
+ /// </summary>
+ public ushort[] Screen {get; private set;}
#endregion
@@ -345,115 +325,46 @@ namespace WPZX81.ZX81 {
Stopwatch s = Stopwatch.StartNew();
- for(int f = 1; f <= Settings.FramesPerUpdate; f++)
- {
- if (fast)
- {
- clock.StartFrame();
- Z80.Run();
- clock.StartFrame();
- Z80.Run();
- clock.StartFrame();
- Z80.Run();
- }
-
- clock.StartFrame();
- Z80.Run();
- Z80.MaskableInterrupt(0);
-
- if (Z80.StackPointer < 0x8000)
- {
- Housekeeping();
- }
- }
+ //for(int f = 1; f <= Settings.FramesPerUpdate; f++)
+ //{
+ // if (fast)
+ // {
+ // clock.StartFrame();
+ // Z80.Run();
+ // clock.StartFrame();
+ // Z80.Run();
+ // clock.StartFrame();
+ // Z80.Run();
+ // }
+
+ // clock.StartFrame();
+ // Z80.Run();
+ // Z80.MaskableInterrupt(0);
+
+ // if (Z80.StackPointer < 0x8000)
+ // {
+ // Housekeeping();
+ // }
+ //}
s.Stop();
Debug.WriteLine("*** RUN {0} msec {1} ticks (PC = 0x{2:X4}, opcodes = {3})", s.ElapsedMilliseconds, s.ElapsedTicks, Z80.ProgramCounter, Z80.ExecutedInstructions);
}
/// <summary>
- /// Run the emulation for a step.
+ /// Handle a key press.
/// </summary>
- public void Step()
+ /// <param name="key">The key.</param>
+ public void KeyPressed(ZX81KeySymbol key)
{
- Z80.Step();
-
- if (clock.FrameDone)
- {
- clock.StartFrame();
- Z80.MaskableInterrupt(0);
-
- if (Z80.StackPointer < 0x8000)
- {
- Housekeeping();
- }
- }
}
/// <summary>
- /// Updates the display.
+ /// Handle a key release.
/// </summary>
- /// <param name="batch">The sprite batch to use for updates.</param>
- public void UpdateDisplay(SpriteBatch batch)
+ /// <param name="key">The key.</param>
+ public void KeyReleased(ZX81KeySymbol key)
{
- Stopwatch s = Stopwatch.StartNew();
-
- // Check if character pointer has updated
- //
- if (Z80.InterruptVector != lastI)
- {
- LoadFont();
- lastI = Z80.InterruptVector;
- }
-
- // Update display
- //
- if (fast)
- {
- for(int y = 0; y < 24; y++)
- {
- for(int x = 0; x < 32; x++)
- {
- batch.Draw(font[8], new Vector2(x * 8, y * 8), Color.White);
- }
- }
- }
- else
- {
- ushort dfile = PeekWord(D_FILE);
-
- for(int y = 0; y < 24; y++)
- {
- for(int x = 0; x < 32; x++)
- {
- // Check for HALT on collapsed display files
- //
- if (mem[dfile] == 118)
- {
- batch.Draw(font[0], new Vector2(x * 8, y * 8), Color.White);
- }
- else
- {
- byte c = mem[dfile++];
-
- if ((c > 64 && c < 128) || c > 191)
- {
- c = 0;
- }
-
- batch.Draw(font[c], new Vector2(x * 8, y * 8), Color.White);
- }
- }
-
- if (mem[dfile] == 118)
- {
- dfile++;
- }
- }
- }
-
- s.Stop();
- Debug.WriteLine("*** UPDATE {0} msec {1} ticks", s.ElapsedMilliseconds, s.ElapsedTicks);
}
@@ -503,15 +414,13 @@ namespace WPZX81.ZX81 public Emulation()
{
- font = new Texture2D[256];
matrix = new byte[8];
mem = new byte[0x10000];
- clock = new Clock(16000, 50);
+ Screen = new ushort[Width * Height];
+ clock = new Clock(16000, 50, 1, 50);
Z80 = new Z80Cpu();
Z80.Initialise(this, this, clock);
Z80.EDNopEvent += EDCallback;
- Disassembler = new Z80Disassembler();
- Disassembler.Initialise(this);
Reset();
}
diff --git a/WPZX81/WPZX81/ZX81/ZX81KeySymbol.cs b/WPZX81/WPZX81/ZX81/ZX81KeySymbol.cs new file mode 100644 index 0000000..d70e7fd --- /dev/null +++ b/WPZX81/WPZX81/ZX81/ZX81KeySymbol.cs @@ -0,0 +1,38 @@ +// This file is part of the WPZX81 Windows Phone ZX81 emulator.
+//
+// Noddybox.Emulation 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.
+//
+// Noddybox.Emulation 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 <http://www.gnu.org/licenses/>.
+//
+// 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;
+
+namespace WPZX81.ZX81
+{
+ public enum ZX81KeySymbol
+ {
+ Key1, Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key0,
+ KeyQ, KeyW, KeyE, KeyR, KeyT, KeyY, KeyU, KeyI, KeyO, KeyP,
+ KeyA, KeyS, KeyD, KeyF, KeyG, KeyH, KeyJ, KeyK, KeyL, KeyNewLine,
+ KeyShift, KeyZ, KeyX, KeyC, KeyV, KeyB, KeyN, KeyM, KeyPeriod, KeySpace
+ }
+}
diff --git a/WPZX81/WPZX81LibContent/WPZX81LibContent.contentproj b/WPZX81/WPZX81LibContent/WPZX81LibContent.contentproj index b8d5224..f89df39 100644 --- a/WPZX81/WPZX81LibContent/WPZX81LibContent.contentproj +++ b/WPZX81/WPZX81LibContent/WPZX81LibContent.contentproj @@ -35,6 +35,33 @@ <Private>False</Private>
</Reference>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="button.png">
+ <Name>button</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="controls.png">
+ <Name>controls</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="joystick.png">
+ <Name>joystick</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="joystick_background.png">
+ <Name>joystick_background</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="keyboard.png">
+ <Name>keyboard</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/WPZX81/WPZX81LibContent/button.png b/WPZX81/WPZX81LibContent/button.png Binary files differnew file mode 100644 index 0000000..5b500e9 --- /dev/null +++ b/WPZX81/WPZX81LibContent/button.png diff --git a/WPZX81/WPZX81LibContent/controls.png b/WPZX81/WPZX81LibContent/controls.png Binary files differnew file mode 100644 index 0000000..f71f97a --- /dev/null +++ b/WPZX81/WPZX81LibContent/controls.png diff --git a/WPZX81/WPZX81LibContent/joystick.png b/WPZX81/WPZX81LibContent/joystick.png Binary files differnew file mode 100644 index 0000000..be34d29 --- /dev/null +++ b/WPZX81/WPZX81LibContent/joystick.png diff --git a/WPZX81/WPZX81LibContent/joystick_background.png b/WPZX81/WPZX81LibContent/joystick_background.png Binary files differnew file mode 100644 index 0000000..2fdc76c --- /dev/null +++ b/WPZX81/WPZX81LibContent/joystick_background.png diff --git a/WPZX81/WPZX81LibContent/keyboard.png b/WPZX81/WPZX81LibContent/keyboard.png Binary files differnew file mode 100644 index 0000000..a32ad1d --- /dev/null +++ b/WPZX81/WPZX81LibContent/keyboard.png diff --git a/non-solution items/controls.pspimage b/non-solution items/controls.pspimage Binary files differindex d93c8f5..17a2ec7 100644 --- a/non-solution items/controls.pspimage +++ b/non-solution items/controls.pspimage diff --git a/non-solution items/joystick_background.pspimage b/non-solution items/joystick_background.pspimage Binary files differindex 9f47e1f..4e059f5 100644 --- a/non-solution items/joystick_background.pspimage +++ b/non-solution items/joystick_background.pspimage diff --git a/non-solution items/keyboard_image.jpg b/non-solution items/keyboard_image.jpg Binary files differnew file mode 100644 index 0000000..5c9c2e7 --- /dev/null +++ b/non-solution items/keyboard_image.jpg |