diff options
| author | johannes <johannes.herman@gmail.com> | 2024-05-03 13:32:31 +0200 |
|---|---|---|
| committer | johannes <johannes.herman@gmail.com> | 2024-05-03 13:32:31 +0200 |
| commit | 671771cfc54b47f7393caa7c3fab83eb09884d27 (patch) | |
| tree | 686a15ebcbd89b166967ad4e77fa290e64d2ef33 /src | |
| parent | 60334a5c4fef17ec7944fc26da5c1497c7f22bec (diff) | |
changed all binary numbers to hex
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.c | 1 | ||||
| -rw-r--r-- | src/demo.c | 14 | ||||
| -rw-r--r-- | src/pack.c | 22 |
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; } - @@ -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, @@ -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; |
