summaryrefslogtreecommitdiff
path: root/tools/lz/nullcomp.c
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-06-14 17:49:36 -0400
committerGitHub <noreply@github.com>2020-06-14 17:49:36 -0400
commit7f6bc3d3826fe7727bdc8714aa0295a712a548c3 (patch)
treeaca0979818b88f0e27f18b95d87a006767cf89fb /tools/lz/nullcomp.c
parentdd97bedd52f97122c0d4a06eb30c0b571ddda343 (diff)
parent0e5edf03ff4ba5ad0c6740eefd0e28ae5eca10c4 (diff)
Merge pull request #50 from entrpntr/pics2
Switch to building binary pic files from pngs
Diffstat (limited to 'tools/lz/nullcomp.c')
-rw-r--r--tools/lz/nullcomp.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/lz/nullcomp.c b/tools/lz/nullcomp.c
new file mode 100644
index 00000000..33d0b726
--- /dev/null
+++ b/tools/lz/nullcomp.c
@@ -0,0 +1,20 @@
+#include "proto.h"
+
+/*
+ Null compressor: stores data uncompressed, using literal (0) commands only.
+ Methods defined: 2
+ Flags values: 0 = split a trailing 33-to-64-byte block at the end into two short blocks; 1 = don't
+*/
+
+struct command * store_uncompressed (const unsigned char * data, const unsigned char * bitflipped, unsigned short * size, unsigned flags) {
+ unsigned short position, block, remainder = *size;
+ struct command * result = NULL;
+ *size = 0;
+ for (position = 0; remainder; position += block, remainder -= block) {
+ block = (remainder > MAX_COMMAND_COUNT) ? MAX_COMMAND_COUNT : remainder;
+ if (!(flags & 1) && (block <= (2 * SHORT_COMMAND_COUNT)) && (block > SHORT_COMMAND_COUNT)) block = SHORT_COMMAND_COUNT;
+ result = realloc(result, sizeof(struct command) * (1 + *size));
+ result[(*size) ++] = (struct command) {.command = 0, .count = block, .value = position};
+ }
+ return result;
+}