From 6751728809ac7e1e3323e7220cc7de5e27a8224c Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 21 May 2012 22:41:56 +0000 Subject: Revert sound back to 13 raster line update. Update GFX for keyboard and joysticks. --- non-solution-items/joystick.pspimage | Bin 177807 -> 434055 bytes non-solution-items/keyboard.pspimage | Bin 179160 -> 283395 bytes non-solution-items/keypad.pspimage | Bin 177378 -> 475500 bytes wpspec/wpspec/GamePage.xaml.cs | 2 +- wpspec/wpspec/Resources/Spectrum.keyboard | Bin 1032 -> 1032 bytes wpspec/wpspec/Spectrum/Emulation.cs | 34 +++++++++++++++++++++--------- wpspec/wpspecLibContent/keyboard.png | Bin 46980 -> 27208 bytes 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/non-solution-items/joystick.pspimage b/non-solution-items/joystick.pspimage index b19dc3c..6efe0c0 100644 Binary files a/non-solution-items/joystick.pspimage and b/non-solution-items/joystick.pspimage differ diff --git a/non-solution-items/keyboard.pspimage b/non-solution-items/keyboard.pspimage index 7bbadad..90cc1cc 100644 Binary files a/non-solution-items/keyboard.pspimage and b/non-solution-items/keyboard.pspimage differ diff --git a/non-solution-items/keypad.pspimage b/non-solution-items/keypad.pspimage index a9796fa..29a3003 100644 Binary files a/non-solution-items/keypad.pspimage and b/non-solution-items/keypad.pspimage differ diff --git a/wpspec/wpspec/GamePage.xaml.cs b/wpspec/wpspec/GamePage.xaml.cs index fef97d2..c20fde4 100644 --- a/wpspec/wpspec/GamePage.xaml.cs +++ b/wpspec/wpspec/GamePage.xaml.cs @@ -110,7 +110,7 @@ namespace wpspec keyboard = new KeyboardDriver (SharedGraphicsDeviceManager.Current.GraphicsDevice, keyboardImage, - new Vector2(0, 540), + new Vector2(0, 470), Shared.SpectrumKeyboard); keyboard.KeyEvent += HandleKeyboardEvent; diff --git a/wpspec/wpspec/Resources/Spectrum.keyboard b/wpspec/wpspec/Resources/Spectrum.keyboard index 065b5b2..7dcd95a 100644 Binary files a/wpspec/wpspec/Resources/Spectrum.keyboard and b/wpspec/wpspec/Resources/Spectrum.keyboard differ diff --git a/wpspec/wpspec/Spectrum/Emulation.cs b/wpspec/wpspec/Spectrum/Emulation.cs index d832f53..b6fa03a 100644 --- a/wpspec/wpspec/Spectrum/Emulation.cs +++ b/wpspec/wpspec/Spectrum/Emulation.cs @@ -116,8 +116,10 @@ namespace wpspec.Spectrum // Sound buffer // - private byte[] soundBuffer = new byte[960 * 2]; // 48000kzh / 50 = 960hz + private byte[] soundBuffer = new byte[40 * 2]; // 48000kzh / 50 / 24 = 40hz private const float samplesPerCycle = 960f / 69888f; + private bool soundPlayed = false; + private int soundLineCount = 0; #endregion @@ -150,6 +152,25 @@ namespace wpspec.Spectrum int p = clock.RasterLine * Width; byte b; + // Check for sound + // + if (++soundLineCount >= 13) + { + if (soundPlayed) + { + if (Settings.Sound) + { + SoundManager.Play(soundBuffer); + } + + soundBuffer = new byte[soundBuffer.Length]; + soundPlayed = false; + } + + soundLineCount = 0; + clock.CycleCount = 0; + } + // Just draw border for these lines // if (clock.RasterLine < 64 || clock.RasterLine > 255) @@ -217,15 +238,6 @@ namespace wpspec.Spectrum flash = !flash; } - - if (Settings.Sound) - { - SoundManager.Play(soundBuffer); - } - - clock.CycleCount = 0; - soundBuffer = new byte[soundBuffer.Length]; - Z80.MaskableInterrupt(0xff); } @@ -435,6 +447,8 @@ namespace wpspec.Spectrum if ((value & 0x10) == 0x10) { + soundPlayed = true; + int index = (int)(clock.CycleCount * samplesPerCycle * 2); if (index >= soundBuffer.Length - 1) diff --git a/wpspec/wpspecLibContent/keyboard.png b/wpspec/wpspecLibContent/keyboard.png index 73a29a7..7657f3d 100644 Binary files a/wpspec/wpspecLibContent/keyboard.png and b/wpspec/wpspecLibContent/keyboard.png differ -- cgit v1.2.3