diff --git a/images/apple/DCGR-RGB.PO b/images/apple/DCGR-RGB.PO index 475ba71..6406fc9 100755 Binary files a/images/apple/DCGR-RGB.PO and b/images/apple/DCGR-RGB.PO differ diff --git a/images/apple/DCGR-TK.PO b/images/apple/DCGR-TK.PO index 5b8e8f9..ea5ec39 100755 Binary files a/images/apple/DCGR-TK.PO and b/images/apple/DCGR-TK.PO differ diff --git a/src/samplesrc/lz4cat.pla b/src/samplesrc/lz4cat.pla index ca5a59a..b31cf4f 100644 --- a/src/samplesrc/lz4cat.pla +++ b/src/samplesrc/lz4cat.pla @@ -3,24 +3,28 @@ include "inc/args.plh" include "inc/fileio.plh" include "inc/lz4.plh" +const ERASE_DST = 1 struc t_header word magic[2] byte FLG byte BD end word arg -byte ref +byte ioflags +byte inref, outref +char[64] infile, outfile +word[2] eof def lz4ReadBlock(flags)#2 word size[2], block, data, len - - len = fileio:read(ref, @size, 4) + + len = fileio:read(inref, @size, 4) if len <> 4 or size[0] == 0 or size[1] & $7FFF return NULL, 0 fin block = heapalloc(size[0]) if block - len = fileio:read(ref, block, size[0]) + len = fileio:read(inref, block, size[0]) if len <> size[0] heaprelease(block) return NULL, 0 @@ -49,7 +53,7 @@ def lz4ReadBlock(flags)#2 heaprelease(block + len) fin if flags & $10 // Block Checksum - fileio:read(ref, @size, 4) + fileio:read(inref, @size, 4) fin return data, len end @@ -57,7 +61,7 @@ def lz4ReadFrame#0 word data, len byte header[t_header], opt - fileio:read(ref, @header, t_header) + fileio:read(inref, @header, t_header) if header:magic[1] <> $184D or header:magic[0] <> $2204 puts("Not LZ4 file.\n") return @@ -77,31 +81,69 @@ def lz4ReadFrame#0 if header.FLG & $01 // Dictionary ID opt = opt + 4 fin - fileio:read(ref, heapmark, opt) // Read rest of header and throw away + fileio:read(inref, heapmark, opt) // Read rest of header and throw away repeat data, len = lz4ReadBlock(header.FLG) if len - while len - putc(^data <> $0A ?? ^data :: $0D) - data++ - len-- - loop + if outref + fileio:write(outref, data, len) + else + while len + putc(^data <> $0A ?? ^data :: $0D) + data++ + len-- + loop + fin heaprelease(data) fin until not data if header.FLG & $04 // Content Checksun - fileio:read(ref, heapmark, 4) + fileio:read(inref, heapmark, 4) fin end + arg = argNext(argFirst) if ^arg - ref = fileio:open(arg) - if ref - lz4ReadFrame - fileio:close(ref) - else - puts("File not found.\n") + while ^(arg + 1) == '-' + when toupper(^(arg + 2)) + is 'E' + ioflags = ioflags | ERASE_DST + break + wend + arg = argNext(arg) + loop + strcpy(@infile, arg) + arg = argNext(arg) + if ^arg + strcpy(@outfile, arg) + fin + if infile + fileio:iobufalloc(2) // Reserve two I/O buffers + inref = fileio:open(@infile) + if inref + if outfile + if ioflags & ERASE_DST + fileio:destroy(@outfile) + fin + outref = fileio:open(@outfile) + if outref + eof[0], eof[1] = fileio:geteof(outref)#2 + fileio:setmark(outref, eof[0], eof[1]) + else + if fileio:create(@outfile, 0, 0) == FILE_ERR_OK + outref = fileio:open(@outfile) + else + puts("Error creating:"); puts(@outfile); putln + fin + fin + fin + lz4ReadFrame + fileio:close(0) + return 0 + else + puts("Error reading:"); puts(@infile); putln + fin fin fin - +puts("Usage: lz4cat [output file]\n") done