aboutsummaryrefslogtreecommitdiff
path: root/player/endian.c
diff options
context:
space:
mode:
authorAlex Marshall <SquidMan72@gmail.com>2009-03-16 20:49:04 -0700
committerAlex Marshall <SquidMan72@gmail.com>2009-03-16 20:49:04 -0700
commitc559c71dd9abff1f0e8d0175b3feac792f337670 (patch)
treedca83aa83336e58c36b3a9372f7f4bc399c41340 /player/endian.c
parent47c3f8e593eaaba27de23eb07379ee690859047c (diff)
Added player. It's in XCode project format. If anyone wants to write a makefile for it, please do, it'd be appreciated. Player doesn't play at the moment, but it does read BRLAN into a nice format, and set up SDL.
Diffstat (limited to 'player/endian.c')
-rw-r--r--player/endian.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/player/endian.c b/player/endian.c
new file mode 100644
index 0000000..e09fc0f
--- /dev/null
+++ b/player/endian.c
@@ -0,0 +1,38 @@
+/*
+ * endian.c
+ * BannerPlayer
+ *
+ * Created by Alex Marshall on 09/03/16.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "types.h"
+#include "endian.h"
+
+u16 be16(u16 x)
+{
+ return (x>>8) |
+ (x<<8);
+}
+
+u32 be32(u32 x)
+{
+ return (x>>24) |
+ ((x<<8) & 0x00FF0000) |
+ ((x>>8) & 0x0000FF00) |
+ (x<<24);
+}
+
+// __int64 for MSVC, "long long" for gcc
+u64 be64(u64 x)
+{
+ return (x>>56) |
+ ((x<<40) & (u64)0x00FF000000000000LL) |
+ ((x<<24) & (u64)0x0000FF0000000000LL) |
+ ((x<<8) & (u64)0x000000FF00000000LL) |
+ ((x>>8) & (u64)0x00000000FF000000LL) |
+ ((x>>24) & (u64)0x0000000000FF0000LL) |
+ ((x>>40) & (u64)0x000000000000FF00LL) |
+ (x<<56);
+}