1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-04-07 16:41:59 +00:00

Prep DCGR slideshow

This commit is contained in:
David Schmenk 2024-11-24 07:57:51 -08:00
parent 325e74c4ba
commit 6279a82064

View File

@ -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