; RUN-LENGTH ENCODEING & DECODEING OF HP-IMAGE. ; For HP-28S. ; Reduction up to 75%. ; By Eugeni Bobrov, 1989. ; Use : ; place a string on the stack, and call ARC. ; UnUse : ; place the arced string on the stack and call UNARC. ; Remarks : ; Can't handle more than 255 equal characters in a run. ; List of files : ; ARC, UNARC. ; History : ; I tryed the RLE/RLD by Randy, but there was some mistakes in it. ; So here it comes. ARC << 0 CHR 0 "." -> Str null n busy << " ;3 times writeline " 1 DISP "" Str 1 1 SUB 2 Str SIZE FOR j Str j DUP DUP IF 24 MOD NOT THEN busy "." + DUP 1 DISP 'busy' STO END SUB IF DUP2 == THEN DROP n 1 + 'n' STO ELSE IF n 2 >= THEN null ROT + n CHR + ROT SWAP + SWAP 0 'n' STO ELSE 3 ROLLD IF DUP null == THEN DUP DUP + + END IF n 1 == THEN DUP + 0 'n' STO END + SWAP END END NEXT IF n 2 >= THEN null SWAP + n CHR + END IF DUP null == THEN DUP DUP + + END IF n 1 == THEN DUP + END + "Reduced " OVER SIZE Str SIZE SWAP %CH ->STR 1 5 SUB + " %" + 2 DISP >> >> UNARC << -> Str << CLLCD "" WHILE DUP ->LCD Str 0 CHR POS DUP REPEAT -> pos << Str 1 pos 1 - SUB + "" Str pos 1 + DUP SUB SWAP 0 Str pos 2 + DUP SUB NUM START OVER + NEXT SWAP DROP + Str pos 3 + OVER SIZE SUB 'Str' STO >> END DROP Str + DUP ->LCD >> >> Hans Ostergard