DERLE

This piece doesnt say much about how DERLE works, just how it could be used. For details, download the toolkit from the previous page and RTFC!

The functional de-RLE code was lifted out of the SMSQ/E sources. To my mind, there should be hooks in SMSQ/E to allow easy access to the internal utility. Perhaps one day there will be.. It can be useful for things like preparing a large compressed sprite for viewing in a smaller window, or for transforming the image in some way.

100 REMark Simple harness for DERLE
110 REMark Decompress a simple, single,
120 REMark solid GD2 sprite.
130 REMark Minimal error trapping!
140 REMark Overwrites tnm$!
150 :
160 fnm$ = 'win3_spr_New200C_spr'
170 tnm$ = 'ram1_test_spr'
180 :
190 er = DeCompress(fnm$, tnm$)
200 IF er < 0 THEN
210  PRINT 'Error'! er
220 ELSE
230  PRINT 'Done!'
240 END IF
250 :
260 :
270 DEFine FuNction DeCompress(f$, t$)
280 LOCal ch, spc, spu, fl
290 :
300 REMark     Load sprite
310 ch = FOP_IN(f$): IF ch < 0: RETurn ch
320 fl = FLEN(#ch): CLOSE#ch
330 spc = ALCHP(fl)
340 LBYTES f$, spc
350 :
360 REMark     Check if solid, single, compressed sprite
370 IF PEEK_L(spc + 16) OR PEEK_L(spc + 20) OR PEEK(spc + 3) <> 64 THEN
380  RECHP spc: RETurn -19
390 END IF
400 :
410 REMark     Get buffer of required size
420 fl = PEEK_L(spc + PEEK_L(spc + 12) + 16) + 24
430 spu = ALCHP(fl)
440 :
450 REMark     Transfer and patch header
460 POKE$ spu, PEEK$(spc, 24)
470 POKE spu + 3, 0
480 :
490 REMark     Decompress
500 DERLE spc + 24, spu + 24
510 :
520 REMark     Save, tidy, and return
530 SBYTES_O t$, spu, fl
540 RECHP spu: RECHP spc
550 RETurn 0
560 END DEFine DeCompress
570 :
580 :
  
Generated with sb2htm on 2019 Mar 21
©pjwitte March 2oi9