diff options
author | Holger Zickner <[email protected]> | 2004-07-08 15:58:48 +0000 |
---|---|---|
committer | Holger Zickner <[email protected]> | 2004-07-08 15:58:48 +0000 |
commit | 4f13ea26c4f47e54e66926f0700cf631e7bb3352 (patch) | |
tree | a9d434fc462417bb981b1565fd64cea5e7c82c15 /src/jake2/game/EndianHandler.java | |
parent | 76839da3568e20f51220584d1fc92841b216505a (diff) |
import of Jake2 version hannover
Diffstat (limited to 'src/jake2/game/EndianHandler.java')
-rw-r--r-- | src/jake2/game/EndianHandler.java | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/jake2/game/EndianHandler.java b/src/jake2/game/EndianHandler.java index 510541d..06595d2 100644 --- a/src/jake2/game/EndianHandler.java +++ b/src/jake2/game/EndianHandler.java @@ -2,7 +2,7 @@ * AbstractEndianHandler.java * Copyright (C) 2003 * - * $Id: EndianHandler.java,v 1.1 2004-07-07 19:58:52 hzi Exp $ + * $Id: EndianHandler.java,v 1.2 2004-07-08 15:58:43 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,14 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.game; - -/** - * AbstractEndianHandler</code> - */ -public abstract class EndianHandler{ - +public abstract class EndianHandler +{ private static final int mask = 0xFF; - + abstract public float BigFloat(float f); abstract public short BigShort(short s); abstract public int BigLong(int i); @@ -40,38 +36,41 @@ public abstract class EndianHandler{ abstract public short LittleShort(short s); abstract public int LittleLong(int i); - public static float swapFloat(float f) { + public static float swapFloat(float f) + { int i = Float.floatToRawIntBits(f); i = swapInt(i); f = Float.intBitsToFloat(i); - + return f; } - - public static int swapInt(int i) { - + + public static int swapInt(int i) + { + int a = i & mask; i >>>= 8; - + a <<= 24; - + int b = i & mask; - + i >>>= 8; b <<= 16; - + int c = i & mask; i >>>= 8; c <<= 8; return i | c | b | a; } - - public static short swapShort(short s) { + + public static short swapShort(short s) + { int a = s & mask; a <<= 8; int b = (s >>> 8) & mask; - - return (short)(b | a); + + return (short) (b | a); } } |