From bbadd583df89735aa892a07e38fb3cf654eb0675 Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 17 Nov 2015 21:30:46 +0400 Subject: [PATCH] (BigEndian): added ToUInt16 and ToInt16 methods. --- GameRes/Utility.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/GameRes/Utility.cs b/GameRes/Utility.cs index b0e8bcfd..55616d5f 100644 --- a/GameRes/Utility.cs +++ b/GameRes/Utility.cs @@ -108,6 +108,16 @@ namespace GameRes.Utility public static class BigEndian { + public static ushort ToUInt16 (byte[] value, int index) + { + return (ushort)(value[index] << 8 | value[index+1]); + } + + public static short ToInt16 (byte[] value, int index) + { + return (short)(value[index] << 8 | value[index+1]); + } + public static uint ToUInt32 (byte[] value, int index) { return (uint)(value[index] << 24 | value[index+1] << 16 | value[index+2] << 8 | value[index+3]);