RLE Graphics (Part Two)

Author(s): Stan Lemke
Pub Details: Time Designs Magazine v4 n1 (Volume 4, Issue 1)
Date: November/December 1987
Pages: unnumbered (PDF 25-26)

My how time flies when you’re having fun!! I dug through the files and was amazed that almost a full year has passed since I submitted the original RLE article (Jan/Feb ’87). In that article I explained the use of an RLE DECODER program, a short program that would take an RLE encoded picture, and decode it into a form that our beloved TS2068 could display. Now I would like to explain the other half of the process…RLE ENCODING.

As with the Decoder program, the original Encoder program was written by John Ryan and distributed through CompuServe. I modified the program somewhat, and am presenting it here with John’s consent. The RLE Encoder will convert a standard TS2068 screen (256 pixels wide by 176 pixels high) to the RLE format. This is compatible with most of the graphics programs written for the TS2068. The bottom 16 pixel rows are padded with “blanks” to fill out the standard RLE format.

LISTING #1: This is a listing of the RLE ENCODER program entirely in BASIC. It is followed by the CKTYPE output (see May/June ’87 TDM). Although the program works, in this form it could well take in excess of an hour to completely encode a complex picture. (Note: The RLE format counts the number of paper dots and ink dots used to construct the picture.) Simply type in the program as listed. Save it to tape with the command RUN 9999 and ENTER. Load and run the CKTYPE program and compare this with the CKTYPE output listing. To RUN the RLE Encoder, type RUN 2020 and ENTER, or LOAD it from tape. You will be prompted to LOAD a SCREEN$ (picture). The encoding will begin immediately. When completed, you will be asked to NAME and SAVE the RLE Encoded bytes.

LISTING #2: This is a listing of the TIMACHINE COMPILER (by Novelsoft) version of the RLE Encoder program. Type in this version if you have this compiler, save it to tape, and compile it. The TIMACHINE COMPILER “list” output is included after the program listing. If you get anything different, double-check your listing. Save the program/bytes as directed by TIMACHINE. The bottom section of Listing #2 has the BASIC LOAD/SAVE portion of the RLE Encoder program. (Reset your computer before going any further.) Type in this portion of the program, LOAD in the compiled bytes, and SAVE the program with the command RUN 9999 and ENTER. When you run this program by typing RUN and ENTER or LOADing the program, you will be asked to LOAD a SCREEN$ (or picture). Encoding will begin immediately and take 30 to 40 seconds…SAVE this to tape as directed.

Now you are able to SEND some of those great TS2068 SCREEN$ to other computers through the common RLE format bridge!

Listing #1:

   1 REM ***********************

RLE ENCODER

Original program by John Ryan
Presented with author's consent

modified by ... S D Lemke
Lemke Software Development
2144 White Oak
Wichita, Ks. 67207

********************************

10 LET X=0
20 LET Y=175
30 LET B=0
40 LET S=40002
50 LET W=0
60 LET Z=0
70 LET C=176
100 REM ***********************

FIND PAPER (BLACK) FIRST

********************************

110 LET A=POINT (X,Y)
120 IF A=0 THEN LET B=B+1
130 IF 0<A THEN GO TO 200
140 LET X=X+1
150 IF 255<X THEN LET Y=Y-1
155 IF 255<X THEN LET C=C-1
160 IF 255<X THEN LET X=X-256
165 IF C=0 THEN GO TO 200
170 IF B=95 THEN GO TO 200
180 GO TO 110
200 LET B=B+32
210 POKE S,B
220 LET S=S+1
230 LET B=0
240 IF C=0 THEN POKE S,32: LET
S=S+1: GO TO 1000
300 REM ***********************

FIND INK (WHITE) NEXT

********************************

310 LET A=POINT (X,Y)
320 IF 0<A THEN LET W=W+1
330 IF A=0 THEN GO TO 400
340 LET X=X+1
350 IF 255<X THEN LET Y=Y-1
355 IF 255<X THEN LET C=C-1
360 IF 255<X THEN LET X=X-256
370 IF C=0 THEN GO TO 400
380 IF W=95 THEN GO TO 400
390 GO TO 310
400 LET W=W+32
410 POKE S,W
420 LET S=S+1
430 LET W=0
440 IF C=0 THEN GO TO 1000
450 GO TO 110
1000 REM ***********************

FINISH OUT STANDARD FORMAT RLE

********************************

1010 POKE 40000,71
1020 POKE 40001,72
1030 POKE S,127
1040 LET S=S+1
1050 POKE S,32
1060 LET S=S+1
1070 LET Z=Z+1
1080 IF Z=43 THEN GO TO 1100
1090 GO TO 1030
1100 POKE S,43
1110 LET S=S+1
1120 POKE S,7
1130 LET S=S+2
1135 LET S=S-40000
1140 GO TO 2200
2005 REM ***********************

RLE ENCODER BASIC

********************************
2010 REM ENCODE.RLE
2020 CLEAR 39999
2090 REM [inverse LOAD]
2100 CLS : PRINT "Play your TAPE
to LOAD SCREEN$.": LOAD ""SCREE
N$
2110 GO TO 10
2190 REM [inverse SAVE]
2200 INPUT #0;AT 0,0;"File Name
= "; LINE n$: SAVE n$CODE 40000,
S
2210 STOP
9999 SAVE "RLE.ENCODE" LINE 2020
1     : 414  : 33990
10    : 11   : 794
20    : 13   : 1134
30    : 11   : 772
40    : 15   : 1461
50    : 11   : 793
60    : 11   : 796
70    : 13   : 1114
100   : 156  : 9864
110   : 10   : 1278
120   : 24   : 1905
130   : 22   : 2074
140   : 13   : 970
150   : 26   : 2436
155   : 26   : 2348
160   : 28   : 2594
165   : 22   : 2078
170   : 23   : 2178
180   : 11   : 831
200   : 14   : 1064
210   : 5    : 751
220   : 13   : 960
230   : 11   : 772
240   : 48   : 4057
300   : 157  : 9814
310   : 10   : 1278
320   : 24   : 1987
330   : 22   : 1969
340   : 13   : 970
350   : 26   : 2436
355   : 26   : 2348
360   : 28   : 2594
370   : 22   : 1971
380   : 23   : 2147
390   : 11   : 779
400   : 14   : 1106
410   : 5    : 772
420   : 13   : 960
430   : 11   : 793
440   : 23   : 1989
450   : 11   : 831
1000  : 156  : 10345
1010  : 22   : 1642
1020  : 22   : 1648
1030  : 13   : 1044
1040  : 13   : 960
1050  : 12   : 901
1060  : 13   : 960
1070  : 13   : 974
1080  : 24   : 2115
1090  : 12   : 807
1100  : 12   : 926
1110  : 13   : 960
1120  : 11   : 775
1130  : 13   : 962
1135  : 17   : 1630
1140  : 12   : 1105
2005  : 153  : 9435
2010  : 18   : 1849
2020  : 13   : 1328
2090  : 12   : 1244
2100  : 42   : 5474
2110  : 10   : 664
2190  : 12   : 1262
2200  : 64   : 5348
2210  : 2    : 465
9999  : 25   : 2450

Listing #2:

   1 REM ***********************

COMPILED RLE ENCODER

Original Program by John Ryan
presented with Author's consent

modified by ... S D Lemke
Lemke Software Development
2144 White Oak
Wichita, Ks. 67207

********************************

2 REM !USR 30000
3 REM ! LPRINT
5 REM !INT +c,x,y,b,s,w,z,a
8 REM ! LIST
9 REM ! OPEN #
10 LET X=0
20 LET Y=175
30 LET B=0
40 LET S=40002
50 LET W=0
60 LET Z=0
70 LET C=176
100 REM ***********************

FIND PAPER (BLACK) FIRST

********************************

110 LET A=POINT (X,Y)
120 IF A=0 THEN LET B=B+1
130 IF 0<A THEN GO TO 200
140 LET X=X+1
150 IF 255<X THEN LET Y=Y-1
155 IF 255<X THEN LET C=C-1
160 IF 255<X THEN LET X=X-256
165 IF C=0 THEN GO TO 200
170 IF B=95 THEN GO TO 200
180 GO TO 110
200 LET B=B+32
210 POKE S,B
220 LET S=S+1
230 LET B=0
240 IF C=0 THEN POKE S,32: LET
S=S+1: GO TO 1000
300 REM ***********************

FIND INK (WHITE) NEXT

********************************

310 LET A=POINT (X,Y)
320 IF 0<A THEN LET W=W+1
330 IF A=0 THEN GO TO 400
340 LET X=X+1
350 IF 255<X THEN LET Y=Y-1
355 IF 255<X THEN LET C=C-1
360 IF 255<X THEN LET X=X-256
370 IF C=0 THEN GO TO 400
380 IF W=95 THEN GO TO 400
390 GO TO 310
400 LET W=W+32
410 POKE S,W
420 LET S=S+1
430 LET W=0
440 IF C=0 THEN GO TO 1000
450 GO TO 110
1000 REM ***********************

FINISH OUT STANDARD FORMAT RLE

********************************

1010 POKE 40000,71
1020 POKE 40001,72
1030 POKE S,127
1040 LET S=S+1
1050 POKE S,32
1060 LET S=S+1
1070 LET Z=Z+1
1080 IF Z=43 THEN GO TO 1100
1090 GO TO 1030
1100 POKE S,43
1110 LET S=S+1
1120 POKE S,7
1130 LET S=S+2
1135 LET S=S-40000
1140 STOP
1145 REM ! CLOSE #
 LINE 9:  +0
 LINE 9:  30000 #7530

RT20     30584 #7778
RT21     30592 #7780
RT124    30600 #7788
RT129    30605 #778D
c.......... POSINT   30620 #779C
x.......... POSINT   30622 #779E
y.......... POSINT   30624 #77A0
b.......... POSINT   30626 #77A2
s.......... POSINT   30628 #77A4
w.......... POSINT   30630 #77A6
z.......... POSINT   30632 #77A8
a.......... POSINT   30634 #77AA

TIME MACHINE ©1986 Cameron Hayne

M/C: 620 BYTES
+ 16 BYTES FOR M/C VARIABLES
(BASIC WAS 2055 BYTES)

SAVE "m/c"CODE 64732,620
LOAD "m/c"CODE 30000
1005 REM ***********************

RLE -- ENCODER

RLE SAVE/LOAD program...
used with the RLE Compiled BASIC

********************************

1010 REM ENCODE.RLE
1020 CLEAR 39999: LOAD "RLE.ENCO
DE"CODE 30000
1090 REM [inverse LOAD]
1100 CLS : PRINT "Play your TAPE
to LOAD SCREEN$.": LOAD ""SCREE
N$
1110 RANDOMIZE USR 30000
1190 REM [inverse SAVE]
1200 INPUT #0;AT 0,0;"File Name
= "; LINE n$: SAVE n$CODE 40000,
(256*PEEK (30629)+PEEK (30628))
1210 STOP
9999 SAVE "RLE.ENCODE" LINE 1020
: SAVE "RLE.ENCODE"CODE 30000,62
0

THE FUTURE OF RLE: The draw-back as far as RLE graphics are concerned is that this format is strictly for Black and White pictures. That is fine for B&W computers…and B&W printers, but the TS2068 is a COLOR computer with no less than 2 different color resolutions! Whant can we do with color graphics?

Well, it’s no secret, but COMPUSERVE has developed what it calls GIF (Graphics Interface Format). Note: GIF and Graphics Interface Format are trademarks of Compuserve Incorporated (an H&R Block Company. GIF is a standardization of computer graphics (pictures) which have COLOR! I am signed up at CompuServe as a GIF developer for the TS2068, and let me say that this is going to be quite a challenge…so don’t hold your breath for a TS2068-GIF program in the very near future! To be meaningful, the resulting picture will almost certainly have to be an EXTENDED COLOR mode picture. (To my knowledge, two programs currently support this TS2068 video mode: my own PIXEL SKETCH/GRAPHICS EDITOR and Dave Franson‘s EXTENDED PAINT.) The standard color mode would loose too many colors. Remember, we will be trying to decode color pictures created with the AMIGA and the ATARI ST… that have up to 256 different colors (shades) and a wide variety of contrasts. Also, we will be squeezing 640 X 400 pixel graphics into a 256 X 192 picture, or more likely use a window technique to view a portion of this large picture! There is also an added problem of “decompressing” the GIF data. The data may require 32000 bytes of memory in an ATARI ST to display a single picture. This is encoded in GIF to about 6000 bytes, and then further compressed to about 3000 bytes to save upload and download time (and expense). So, first we will have to develop the compression and decompression programs to get at the real GIF data, then develop the decoder and encoder, and finally figure out the best way to display the end result picture (if the TS2068 has enough RAM to handle all this). So, if/when I get this all done, you’ll see it right here in TDM!

RLE picture of a woman's face
RLE picture of a woman's face

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.