summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands.c1
-rw-r--r--src/demo.c14
-rw-r--r--src/pack.c22
3 files changed, 18 insertions, 19 deletions
diff --git a/src/commands.c b/src/commands.c
index 23ab0de..ca258b5 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -178,4 +178,3 @@ int exportmap(FILE *out, demo *demo)
return 1;
}
-
diff --git a/src/demo.c b/src/demo.c
index 250cd5f..c242447 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -6,13 +6,13 @@
#include <stdlib.h>
#include <string.h>
-#define CHUNK_TICK_MASK 0b10000000
-#define CHUNK_TICK_KEYFRAME_MASK 0b01000000
-#define CHUNK_TICK_INLINE_MASK 0b00100000
-#define CHUNK_TICK_DELTA_V3_MASK 0b00111111
-#define CHUNK_TICK_DELTA_V5_MASK 0b00011111
-#define CHUNK_NORMAL_TYPE_MASK 0b01100000
-#define CHUNK_NORMAL_SIZE_MASK 0b00011111
+#define CHUNK_TICK_MASK 0x80 // 0b10000000
+#define CHUNK_TICK_KEYFRAME_MASK 0x40 // 0b01000000
+#define CHUNK_TICK_INLINE_MASK 0x20 // 0b00100000
+#define CHUNK_TICK_DELTA_V3_MASK 0x3f // 0b00111111
+#define CHUNK_TICK_DELTA_V5_MASK 0x1f // 0b00011111
+#define CHUNK_NORMAL_TYPE_MASK 0x60 // 0b01100000
+#define CHUNK_NORMAL_SIZE_MASK 0x1f // 0b00011111
const char headermagic[7] = "TWDEMO\0";
const unsigned char mapmagic[] = {0x6b, 0xe6, 0xda, 0x4a, 0xce, 0xbd, 0x38, 0x0c,
diff --git a/src/pack.c b/src/pack.c
index 14c2e40..db47781 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -24,12 +24,12 @@ int readint(char **cp)
(*cp)++;
int sign = ((src >> 6) & 1);
- result |= (src & 0b00111111);
+ result |= (src & 0x3f);
for (int i = 0; i < 4; i++)
{
// printf("(%d, ", src);
- if ((src & 0b10000000) == 0)
+ if ((src & 0x80) == 0)
break;
src = **cp;
@@ -37,12 +37,12 @@ int readint(char **cp)
len++;
- if (i == 3 && (src & 0b11110000) != 0)
+ if (i == 3 && (src & 0xf0) != 0)
printf("[ WARNING ] Non zero int padding!\n");
- result |= (src & 0b01111111) << (6 + 7 * i);
+ result |= (src & 0x7f) << (6 + 7 * i);
}
- if (len > 1 && src == 0b00000000)
+ if (len > 1 && src == 0x00)
printf("[ WARNING ] Overlong int encoding!\n");
result ^= -sign;
@@ -57,25 +57,25 @@ void writeint(int i, char **cp)
int sign = i < 0;
unsigned int in = i;
in = (in ^ -sign);
- char next = (in & 0b00111111);
+ char next = (in & 0x3f);
in >>= 6;
- char head = 0;
+ unsigned char head = 0;
if (in != 0)
- head |= 0b10000000;
+ head |= 0x80;
if (sign != 0)
- head |= 0b01000000;
+ head |= 0x40;
**cp = head | next;
(*cp)++;
while (in != 0)
{
- next = (in & 0b01111111);
+ next = (in & 0x7f);
in >>= 7;
if (in != 0)
- head = 0b10000000;
+ head = 0x80;
else
head = 0;