diff options
| author | Ian C <ianc@noddybox.co.uk> | 2012-01-01 14:21:26 +0000 |
|---|---|---|
| committer | Ian C <ianc@noddybox.co.uk> | 2012-01-01 14:21:26 +0000 |
| commit | 2b8d49726e448e22b5055da5ba4395d043030984 (patch) | |
| tree | 84df14c05d10d11e293fb74d50364664124b844e /src/Noddybox.Emulation.EightBit/Binary.cs | |
| parent | 4a14a990665f766e349b9027dbf980bc39f395f6 (diff) | |
Moved sources to help in compilation for other platforms and isolated phone projects.
Diffstat (limited to 'src/Noddybox.Emulation.EightBit/Binary.cs')
| -rw-r--r-- | src/Noddybox.Emulation.EightBit/Binary.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Noddybox.Emulation.EightBit/Binary.cs b/src/Noddybox.Emulation.EightBit/Binary.cs new file mode 100644 index 0000000..0b1928b --- /dev/null +++ b/src/Noddybox.Emulation.EightBit/Binary.cs @@ -0,0 +1,63 @@ +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 Noddybox.Emulation.EightBit
+{
+ /// <summary>
+ /// Provides helpers for shifting smaller values around without casts all over the shop.
+ /// </summary>
+ public static class Binary
+ {
+ /// <summary>
+ /// Shift 8-bits to the left.
+ /// </summary>
+ /// <param name="b">The byte.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static byte ShiftLeft(byte b, int shift)
+ {
+ return (byte)((b << shift) & 0xff);
+ }
+
+ /// <summary>
+ /// Shift 8-bits to the right.
+ /// </summary>
+ /// <param name="b">The byte.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static byte ShiftRight(byte b, int shift)
+ {
+ return (byte)((b >> shift) & 0xff);
+ }
+
+ /// <summary>
+ /// Shift 16-bits to the left.
+ /// </summary>
+ /// <param name="w">The word.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static ushort ShiftLeft(ushort w, int shift)
+ {
+ return (ushort)((w << shift) & 0xffff);
+ }
+
+ /// <summary>
+ /// Shift 16-bits to the right.
+ /// </summary>
+ /// <param name="w">The word.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static ushort ShiftRight(ushort w, int shift)
+ {
+ return (ushort)((w >> shift) & 0xffff);
+ }
+ }
+}
|
