                        An Overview - Decoding and Displaying
                        RLE Hi-Res Encoded Data Files.
                             By Chrisdos. Cbig Sig Sysop


        This file will help the basic programmer in writing a program that
will translate the captured data for a RLE (Run Lenght Encoded) picture.

        The computer that this is used on should be able to do the following:
                1) Be able to log into CIS and RAM BUFFER capture data online.
                2) Be able to save this RAM data as an ASCII file to Disk.
                3) Have at least a Hi-Resolution screen of 256 x 192 pixels.

        To capture the picture file you want, log onto CIS and goto the page
with the picture. You will be informed that your terminal does not support
the Hi-Res pictures and will be asked if you wish to proceed. You reply YES.
                1) Just before selecting the menu number for the picture
you want, OPEN your RAM BUFFER.
                2) Select the picture. You will see meaningless letters and
symbols scroll across your screen.
                3) When they stop, CLOSE andd SAVE your RAM buffer (in ASCII
format) to Disk.
                4) Press your <ENTER> key to return to the picture menu.

The file you have just saved to disk contains the RLE data required to draw
the image on your screen, all you must now do is decode this data and display
it.

        The picture area is a 256 across by 192 down grid. The ASCII value
of each character in the file represents how many dark and how many light
pixels to draw across each line. The data in the file may be thought of as
pairs, as it is sent as DARK LIGHT  DARK LIGHT  DARK LIGHT .......
The actual value of pixels to turn on or off is the ASCII value of the
character minus 32. This is done so that no control codes are sent that might
upset the recieveing computer or network. All picture codes will be in the
range CHR$(32) (ASCII space) to chr$(127) (ASCII del).
This makes the pixel range for one character 0 to 95.

        What follows is a plain vanilla basic flow chart that you can
follow to help write a program to display the picture on your computer.


1) Open and prepair the previously captured data file for input.
2) Clear and initalize the Hi-Res Screen of your computer. The upper left most
pixel is to be consitered Line 1 Column 1.
Set a line counter variable = 1. Also set a column variable = 1. (LI=1:CO=1)
3) GET one charater from the file and test to see if it equal to chr$(27).
(GET#8,X$: IF X$=CHR$(27) then ...... )
This is an ESC code and indicates the begining of the picture data.
        If the character is not a Chr$(27) then loop back to 3).
4) GET the next character after the ESC. It should equal an ASCII "G".
(GET#8,X$:If X$="G" then ........)
This means Graphics mode. If it is not a "G", either return to 3) or display
an error.
5) GET the next character after the G, it should be an ASCII "H".
(GET#8,X$:IF X$="H" then ......)
This means High-Res. If it is not, return to 3) or display an error.


6) Get the next character. Call it BL$ (Black) Convert it to a value of pixels
by the formula: BP=ASC(BL$)-32 (BlackPixels = ascii value of BL$ minus 32)
    Was the END OF FILE HIT ? If yes then goto 13) (The exit)
Since your screen is already black, it is not required to write black
pixels to the screen, just to update the Line and Column pointers.
You want to add one to the column number for each count of the BP, you also
want to reset this value to 1 and add one to the line count when the column
count equals 257.
Also, should BP = 0 you dont need to do anything here.
7) If BP = 0  then GOTO 9)
8) For Z = 1 to BP
   CO = CO + 1       (Column = column + 1)
   If CO = 257 then LI = LI + 1: CO = 1  (Overflow, increase line, reset column)
   Next Z
   If LI=193 then goto 13)  (Was that the last line? If yes, goto exit)
9) Get the next character, call it WT$ (white) Convert it to the value of white
pixels via: WP=ASC(WT$)-32
    Was the END OF FILE HIT ? If YES GOTO 13) (the exit)
10) Should the value of WP be 0, dont do anything here, return to get the
next black character. (GOTO 6))
The next loop is almost the same as the black loop, only here we need to
set pixels on.
11) For Z=1 to WP
    Set LI,CO    (Set the pixel at line LI, column CO)
    CO = CO + 1
    IF CO = 257 then LI = LI + 1: CO = 1
    Next Z
    If LI=193 then goto 13)
    (Was that the last line ? If yes then exit)
12) GOTO 6)   (Loop back to the next black character)


13) The exit.. CLOSE the disk file. 
    Look at the picture on the screen. Set up a loop to wait for a key press
before you reset or clear the screen.



 Different computers will use different syntaxes in their BASICs, but using
the above brief outline, you should be able to write a program to display
the pictures.

What follows is part of the information avalible in the Technical files
on the VID-1 pages.

*****
    High Resolution Graphics
  <ESC><G><H>
  The screen is cleared to black and high resolution graphics mode (256 x 192
pixels) is entered.  In this mode data is sent as pairs of run length encoded
characters.
  The first character of the pair indicates the number of background pixels. 
The second character indicates the number of foreground pixels.  Each character
of a pair is the actual count plus 32.  The total count + 32 will not exceed
127, so that the parity bit is to be ignored.
  For example, the ASCII sequence <L><W> indicates 44 background pixels and 55
foreground pixels.  The line drawing also should wrap from the last position on
a line to the first position on the next line.
  Thus, if the last pixel set on a line was in position 250, and a sequence of 0
background and 10 foreground is received, then the last 6 pixels are set on the
next line.
*****


For more information, try contacting the SYSOP of the SIGs related
to your computer.

Note to Commodore 64 users: Avalible in DL2 of the CBIG SIG is the terminal
program CBterm/C64. This program displays the RLE Hi-Res pictures ON LINE
and will even dump them to a Star or Epson printer.
The program is avalible for downloading via VIDTEX or XMODEM, and if you can
not download, you may get a free copy in the mail by reading the file
MAILIN.TXT also in DL2 of CBIG. See the files there for more info.
  -Chrisdos CBIG SYSOP
