From 6279a820646c856b93056e714b697c6254c7881e Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 24 Nov 2024 07:57:51 -0800 Subject: [PATCH] Prep DCGR slideshow --- src/utilsrc/apple/dcgrshow.pla | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/utilsrc/apple/dcgrshow.pla diff --git a/src/utilsrc/apple/dcgrshow.pla b/src/utilsrc/apple/dcgrshow.pla new file mode 100644 index 0000000..492fa44 --- /dev/null +++ b/src/utilsrc/apple/dcgrshow.pla @@ -0,0 +1,82 @@ +include "inc/cmdsys.plh" +include "inc/dcgrlib.plh" +include "inc/dcgrutils.plh" +include "inc/args.plh" +include "inc/fileio.plh" +include "inc/matchfiles.plh" +include "inc/lz4.plh" + +sysflags resxtxt1|reshgr1|resxhgr1|reshgr2 + +def lz4ReadBlock(flags, dstbuf)#2 + word size[2], block, len + + len = fileio:read(inref, @size, 4) + if len <> 4 or size[0] == 0 or size[1] & $7FFF + return NULL, 0 + fin + block = dstbuf + if block + len = fileio:read(inref, block, size[0]) + if len <> size[0] + return NULL, 0 + fin + else + return NULL, 0 + fin + if size[1] & $8000 + // + // Uncompressed block + // + data = block + else + // + // Decompress block + // + len = heapavail - 256 // Allocate almost entire heap to decompress into + data = heapalloc(len) + if data + len = lz4Unpack(block, block + size[0], data, data + len) + memcpy(block, data, len) + data = block + else + len = 0 + fin + fin + if flags & $10 // Block Checksum + fileio:read(inref, @size, 4) + fin + return len +end +def lz4ReadFrame#0 + word data, len + byte header[t_header], opt + + fileio:read(inref, @header, t_header) + if header:magic[1] <> $184D or header:magic[0] <> $2204 + puts("Not LZ4 file.\n") + return + fin + if header.FLG & $C0 <> $40 + puts("Wrong LZ4 version.\n") + return + fin + if header.BD & $70 <> $40 + puts("Not 64K block size.\n") + return + fin + opt = 1 + if header.FLG & $08 // Content Size + opt = opt + 8 + fin + if header.FLG & $01 // Dictionary ID + opt = opt + 4 + fin + fileio:read(inref, heapmark, opt) // Read rest of header and throw away + repeat + len = lz4ReadBlock(header.FLG, $2000) + until len == 0 + if header.FLG & $04 // Content Checksun + fileio:read(inref, heapmark, 4) + fin +end