
      RLEDEC.BAS
  (c) 1985 by Chrisdos

RLEDEC.BAS is a basic program that will read a captured RLE (Run Lenght Encoded)
Picture File and print it to any STANDARD printer. That is, you do not require
a high resolution bit image printer to use this program. Any printer, including
daisy wheels may be used. This program, being written in basic, is slow, but
does a respectable job. The program operates by crunching the HI-Res data in
to a LOW-RES Ascii character format that can be printed.
Written for the Commodore 64, it can be modified with little trouble for
other machines as there are no fancy tricks used and it is simple basic.
(ie, for TRS computers, change PRINT#4 to LPRINT, etc.)

Operation:
----------
 You must have a terminal program capable of doing a RAM BUFFER capture
of the RLE Picture data. You ask CIS to display the picture, and open your
RAM buffer and capture the data. When it is finished you save the data
to your disk in ASCII format. It is this file that RLEDEC.BAS will use to
build the picture. You capture the pictures you want, then log off.
 You then load and run RLEDEC.BAS and you are prompted for the file name
of your picture file. RLEDEC will read the information from the file, crunch
it into ASCII symbols and print it to your line printer.

Perspective correction.
-----------------------
RLEDEC will print the picture on a 64 by 48 grid, This is  the
original perspective of 256 by 192 but the line printer will space
longer on the vertical axis than it does between characters on the
horizontal axis. This may make the picture a little longer than it should be.
If your printer supports a function to make the lines print closer together
(normal is 6 Lines per inch) then set it to do so. (8 lines or better per inch.)

Grey Scale correction.
----------------------
RLEDEC takes a 16 by 16 chunk of the picture and converts it to printable
ASCII characters on the basis of how black each chunk should be. The chunk
can have a value of 0 to 16 (the array variable A in the program) with
0 being a blank space to 16 being the darkest character you can print.
The program as provided uses 8 characters (plus blank) to decode the chunk,
you may need to alter the characters to suit your printer. These are lines
210 to 250 in the program. You may also wish to chage and add more lines so
that all 16 values produce a different character on your printer should
your printer support a wider range.
As the program stands now, 0 = (blank), 1-2 = ', 3-4 = ., 5-6 = /, 7-8 = :
9-10 = %, 11-12 = $, 13-14 = # and 15-16 = *. You may wish to alter the
weighting of the scale as well to produce different results in the printout.


The following is the program RLEDEC.BAS. It is also avalible in .BIN and .IMG
form in DL2 of the CBIG SIG as RLEDEC.BIN and RLEDEC.IMG.


 If you have any questions or need help, please leave a message to SYSOP
in the CBIG SIG. (GO CBIG from any ! prompt.)

Thank you -Chrisdos Cbig Sysop
--------------------------------------------------------------------------------
10 rem print rle (c) 1985 by chrisdos
20 dim a(64):pc=0:c=0:rem make c=1 to reverse image
30 input"enter picture filename>";f$
40 open8,8,8,f$+",r,s":rem open disk file
50 open4,4:rem open printer
60 get#8,x$:ifx$<>chr$(27)goto60:rem check for esc code
70 get#8,x$,x$:rem skip "gh"
99 rem crunch 4 rle lines into 1 print line
100 for l = 1 to 4:for ol = 1 to 64
105 printl,ol
110 for il = 1 to 4
120 if pc=0 then gosub 500:print"*";
130 a(ol) = a(ol) + c
140 pc=pc-1
150 next:next:next
199 rem grey scale and print line.
200 for p = 1 to 64
210 if a(p)= 0 then print#4," ";:goto300
215 ifa(p)<=2 thenprint#4,"'";:goto300
220 if a(p)<=4 then print#4,".";:goto300
225 ifa(p)<=6 thenprint#4,"/";:goto300
230 if a(p)<=8 then print#4,":";:goto300
235 ifa(p)<=10thenprint#4,"%";:goto300
240 if a(p)<=12thenprint#4,"$";:goto300
245 ifa(p)<=14thenprint#4,"#";:goto300
250 if a(p)<=16thenprint#4,"*";:goto300
300 next p
310 print#4
330 for x=1to64:a(x)=0:next:rem clear array
340 goto 100
500 get#8,i$:pc=asc(i$)-32:rem read next char from file & convert
510 if st=64 goto 1000:rem end of file?
520 c=1+(c=1):rem toggle black/white
    (note: May need to be changed to: 520 if c=1 then c=0 else c=1 )
530 if pc=0 goto 500:rem was zero, do again
540 return
1000 close 8:close 4:rem exit ! the end
1010 stop

Note: To make the program run a little faster, you may want to remove all the
REM statements.

Note to CBterm users: CBterm Ver 4.5 displays the RLE picture to the screen
and does not normally allow you to capture the RLE information in the RAM
buffer. Should you wish to capture the data in CBterms buffer, you may do this:
 LOAD CBTERM, but do not run it yet.
 POKE 2871,255
 RUN
 This will disable CBterm from recieveing ESC codes, so any function that
relies on ESC will not operate (Cursor positioning, graphics mode, etc.)
With this poke in place, you will be able to RAM buffer capture and save
the RLE info to disk, so only use the poke when you want to do so.
The procedure would be to goto page CB65 and there select the picture you
want to capture, just before entering the selection, clear and open your
RAM buffer. (C= Z C= O) Then select the picture and the data will be 
transmitted. When it stops (the bell rings) you close the buffer (C= C) and
do an WRITE to disk (C= W) Save the file as Sequential and Ascii.
