summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjohannes <johannes.herman@gmail.com>2024-02-06 12:54:10 +0100
committerjohannes <johannes.herman@gmail.com>2024-02-06 12:54:10 +0100
commitf8e8e6622eda179bc6f88b0c064fb2629c98fac2 (patch)
treeccbe6f1bffcf4fc804290cd1cf7e2726455e1f8c /src
parent808883b430e869413046b87a12095068677fe383 (diff)
moved reverseint to pack
Diffstat (limited to 'src')
-rw-r--r--src/demo.c21
-rw-r--r--src/pack.c5
2 files changed, 13 insertions, 13 deletions
diff --git a/src/demo.c b/src/demo.c
index f3f250c..fd1f310 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -6,20 +6,15 @@
#include <stdlib.h>
#include <string.h>
-const unsigned char CHUNK_TICK_MASK = 0b10000000;
-const unsigned char CHUNK_TICK_KEYFRAME_MASK = 0b01000000;
-const unsigned char CHUNK_TICK_INLINE_MASK = 0b00100000;
-const unsigned char CHUNK_TYPE_MASK = 0b01100000; // TODO add NORMAL_
-const unsigned char CHUNK_SIZE_MASK = 0b00011111;
+#define CHUNK_TICK_MASK 0b10000000
+#define CHUNK_TICK_KEYFRAME_MASK 0b01000000
+#define CHUNK_TICK_INLINE_MASK 0b00100000
+#define CHUNK_NORMAL_TYPE_MASK 0b01100000
+#define CHUNK_NORMAL_SIZE_MASK 0b00011111
const unsigned char mapmagic[] = {0x6b, 0xe6, 0xda, 0x4a, 0xce, 0xbd, 0x38, 0x0c,
0x9b, 0x5b, 0x12, 0x89, 0xc8, 0x42, 0xd7, 0x80};
-int reverseint(const unsigned char in[4])
-{
- return (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3];
-}
-
// TODO make version sensitive
int readdemoheader(FILE *fp, demoheader *dh)
{
@@ -161,7 +156,7 @@ int readdemochunk(FILE *fp, demochunk *chunk, unsigned char ver)
demotick *tick = (demotick *)malloc(sizeof(demotick));
if (readdemotick(fp, chunkhead, tick, ver))
{
- chunk->type = 4;
+ chunk->type = 0;
chunk->data.tick = tick;
printf("TICK={keyframe: %d, innline: %d, delta: %d}\n", tick->keyframe, tick->innline, tick->delta);
}
@@ -173,8 +168,8 @@ int readdemochunk(FILE *fp, demochunk *chunk, unsigned char ver)
}
else
{
- unsigned char type = (chunkhead & CHUNK_TYPE_MASK) >> 5;
- short size = (chunkhead & CHUNK_SIZE_MASK);
+ unsigned char type = (chunkhead & CHUNK_NORMAL_TYPE_MASK) >> 5;
+ short size = (chunkhead & CHUNK_NORMAL_SIZE_MASK);
if (size == 30)
size = (short)fgetc(fp);
diff --git a/src/pack.c b/src/pack.c
index f7be2c8..0fa3274 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -1,5 +1,10 @@
#include <stdio.h>
+int reverseint(const unsigned char in[4])
+{
+ return (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3];
+}
+
int readint(unsigned char **cp)
{
int result = 0;