
GrafPack/CMD
Shareware Graphics Compression/Expansion Driver
Copyright 1988 by Mel Patrick

Graphics Background

When the Model 4 was a popular machine and the high resolution boards were starting to catch on, no one appeared to be interested in the file format used for saving and loading a high resolution screen. In the Model 4 mode, you had 640 x 240 (640 pixels across by 240 rows down). Of that 640 pixels across, they were made up of 80 bytes. Since a byte can contain 8 bits, the bits of each byte were set to represent the total 640 required. i.e. 80 bytes x 8 bits = 640 pixels. So much for the technical portion.

When saving or loading files, a standard file extension was used, /HR. This indicated a HIGH RES file and was almost always 19.5K on your disk. Why 19.5K? Easy. If you consider the fact that you have 80 bytes per row and 240 rows, you get 80 x 240 = 19,200 bytes. You got that size regardless of the actual image you had on the screen. Even if there was only 1 pixel showing on the whole display, you got a 19.5K file. The reason for the directory showing 19.5K instead of the 19.2K is a limitation of the DOS. The smallest size block on disk is 1.5K (floppy) so if the file writes even 1 byte over the previous 1.5K block, it is going to allocate another 1.5K block for that 1 byte. On a hard drive, you have a minimum 4K block size.

Add both of these to the fact that there were two companies making a graphic Basic for the high resolution market. On one hand you had Radio Shack with BasicG (Basic Graphics) and on the other you had MicroLabs with GBasic (Graphics Basic). Not only that but the two boards differ in control port configurations. The MicroLabs board has 20K of memory on board (remember we need 19.2K for the screen image shown) but the Radio Shack has 32K. Can that extra memory be used on the Radio Shack board? Yes it can and it was designed so that you could designate the viewing plane on the board. The MicroLabs can not. For example, the normal viewing coordinates are 0-639 horizontal and 0-239 vertical for a MicroLabs. The same size exists for the Radio Shack board but remember that additional memory. Radio Shack offers three more controlling ports for the graphics board than MicroLabs does. We can view any 640 x 240 area anywhere on that 32K memory, so two ports control the offset into that area for viewing. By using these additional ports you can control the offset where the normal 640 x 240 viewing plane exists. On a RS board you have 0-1015 for horizontal and 0-255 for vertical resolution. If we convert that to bytes, we have 127 bytes by 256 rows or 127 x 256 = 32512 bytes. Normally this size is never saved to disk since our viewing display screen size is still only 640 x 240. But it is available.  The last port controls the mode where you can have the normal screen AND the high res screen on at the same time (MicroLabs offers this as well but with a different port).

As you can see the Model 4 high resolution graphics have come from two different directions with two different Basic
s and two different circuit boards. The only standard item amongst the lot is the size of the files. That
s where GRAFPACK, FASTPACK and the rest of the support utilities come into play.

GBASIC vs BASICG

I am not about to get into a debate on the benefits of each Basic. Sufficient to say that for all the features of either of them, the fact still remains that you have to deal with a 19.5K file on almost every graphics program. The exception is the program called xTCAD. It uses a special format and you will obtain no benefits by using my driver software.

What is GRAFPACK?

GRAFPACK/CMD is a graphics software driver which, when used with either GBASIC or BASICG, will compress a standard 19.2K file during a save or expand a previously compressed image during a load and result in much smaller disk files. 

GrafPack once executed, will reside in high memory and remain invisible in the background during normal operations but may be called at any time for saving or loading a compressed high res screen very easily.

Invoking GrafPack couldn
t be easier. For example when you want to load a standard 19.2K file from whatever program you are in, you normally use the file extension /HR. Saving works the same way. However with GrafPack in the background, you may use its special compression routine for saving and loading and take advantage of the much smaller disk file sizes. To invoke GrafPack, use the extension /CHR which stands for Compressed High Resolution. The same holds true for loading, just use the /CHR extension. GrafPack will take care of all the compression and expansion automatically. For you.

The disk space savings you will obtain make it worth your while to use GrafPack. For example, if you set ONE PIXEL (anyone will do) and save as a normal /HR screen, it will take 19.5K on your disk. If you instead use the extension /CHR you
ll find it only takes 1.5K. That alone is a 18K saving! Regardless of the image on your screen, GrafPack will ALWAYS be able to save it in under 19.5K so that you will always benefit from using it.

Besides the benefit from the extra disk space you
ll have, you may experience faster loading times. This is because of the special compression routines used by GrafPack. In most applications you won
t notice too much difference in speed.

While GrafPack may be left installed during your current work session, I recommend that you only use it when you plan on doing some high res work. It does take approximately 800 bytes of high memory and you require the use of that memory. Other programs which use the alternate banks of memory may not function correctly with GrafPack (at worst you will get a reboot). Create a JCL file to autoload GrafPack with your chosen version of BasicG or GBasic and drawing program.

A utility called UNGRAF/CMD has ben provided to remove the special routines GrafPack installs and reset memory size for you. It is advised that you always use this routine when you have completed your drawing tasks.

Rather than spend the next two days of your time loading and saving your high resolution screens in the new compressed format, a utility called FASTPACK/CMD has been provided. This program will allow either any one file or a batch of files with either the /CHR or /HR extension to be automatically expanded or compressed. Sizes of the files and a graphic representation of the space saving will be shown as the files are processed. The program is basically simple to use with the letters for the commands residing within the <> signs. Use the arrow keys for filename selection in the SINGLE file mode, [ENTER] to select. Use the [BREAK] key to exit back to Dos.

FASTPACK will also allow those without a High Res board to store files on their disks (for printing only obviously) in a usable format. If you compress a standard /HR file you will find that if you ARC (using ARC4/CMD) the same 19.5K file, the ARC file will be smaller by about 20%. However once the file is in the /ARC format, the only way to use it is de-arcing it. Not so with GrafPack. When in compressed mode the files are still in a usable format.

Working Programs

The following is a current list of programs which work with GrafPack.

Prodraw, Draw , 3-D Plot, BizGraph, and Draw 11

While they may be others, I am not aware of them. If you find not on this list, please let me know which one it is by the program name, author (if known), which hi res board it runs on, and which Basic you were using. These will be added to the manual as they are available. At the same time, if you find a program which will not work on it, please detail your findings and pass those along too.

HIRES4/CMD

About two years ago I wrote a program called HIRES4/CMD which would load, print, display either the 19.5K files (/HR) MacPaint type files (from the Apple Macintosh) or a compressed /CHR file. Unfortunately there was a small error in the original HIRES4/CMD file which didn
t always compress a file correctly. In the new release in this file that has been fixed so that your GRAFPACKed files can be viewed easily without having to use a Basic program to do it. As well, if required, you can load a /HR file type and save it as a /CHR file.

Summary

GrafPack, FastPack and supporting utilities are copyright by Mel Patrick (me), and are NOT public domain. Much time and effort has gone into their development. Considering their versatility and benefits they should be a part of every Model 4 high res owner. These programs are SHAREWARE. As with any shareware programs I have written, you will always receive a printed manual and latest version of the program (if one exists). By using the GrafPack driver and FastPack utilities you can save a lot of disk space and the diskettes you save will more than easily pay for the small shareware fee asked.

 The cost of supporting the shareware concept is only $15.00 and you may send a personal check or money order directly to me at :

Mel Patrick, 13699 70A Ave., Surrey, B.C., Canada, V3W 2J8

The cost covers the printed manual, disk and postage with a small amount remaining for my time and efforts. As with any of my other shareware programs, support for registered owners is always available to the limit of my own ability.


GrafPack /CHR File Format

Rather than keep formats a secret so that no one else can capitalize on your format, I am releasing the information about the format itself. This will allow others who are writing software to utilize the format directly if they so desire.

The GrafPack format is actually a modified version of the MacPaint image format. While the MacPaint image is significantly different so the two are NOT interchangeable, they are similar in other respects.

A high res screen is made of 640 pixels by 240 pixels. However the format of the graphics board itself divides those 640 horizontal pixels into 80 bytes (which is 8 pixels each) to give you a total of 640 again.

During a normal save or load routine each byte horizontally is read off the screen and written to disk. Therefore you have 80 bytes per row, or 80 x 240 for your 19.2K file. When the graphics are being reloaded as the information is read in the row fills up until the end is reached and then processing resumes on the next row for a total of 240 rows.

GrafPack format works in a similiar fashion except that only one row is handled at a time. Encoded into each row is information to tell GrafPack how to handle the following bytes. Two special identifier bytes tell the software when it reloads two things. Either the following bytes are not alike, or repeating.

For example, if the following values were read from the high res screen and stored in the buffer for a write to disk (only a partial buffer is given here for sample purposes all VALUES IN DECIMAL; and this would be the format for the normal /HR extension) :

0 0 0 25 25 25 1 2 3 4 5 5 5 5 ......

GrafPack would convert them and write to disk the following (in DECIMAL) :

131 0 131 25 4 1 2 3 4 132 5

As shown you notice a 0 0 0 in the first sample which gets converted to 131 0. Any byte read which has BIT 7 SET indicates a repeating pattern and the following byte indicates the repeating pattern. The count is added to 128, so in our example we have 131 - 128 = 3 bytes of the next value read from disk or in our example 0. The same holds true with the 25 25 25. We have 131 - 128 = 3 bytes of the next value, or 25
s.

Now we get to the second byte id code. A NON-repeating pattern. This is where successive bytes are not similar. This id byte contains the number of bytes to follow which are not alike and BIT 7 is always RESET. In our original sample we had 1 2 3 4 and on output was converted to 4 1 2 3 4. Which tells the loading routine that the next 4 bytes are to be used as read from the disk. So we read back in the 1 2 3 4 and store them. However not the 5 as it then matches a repeating pattern.

Last we have the 5
s. The 5 5 5 5 gets converted to 132 5 to indicate 132 - 128 = 4 repeating patterns of the next byte, in this case a 5.

Had you saved the example file with an HR extension it would have taken 14 bytes for our short example. In the CHR extension you would have saved only 11 bytes. You can see how space saving it can be. Just imagine a whole blank line. The standard HR format would save 80 bytes to your disk, whereas GrafPack would save only 2 bytes. A 208 and 0. You would then have a whole line of graphics represented by only 2 bytes whereas before it used 80 on your disk.

The loading and saving portions of the GrafPack software keep track of the X and Y position and process 80 bytes per line before going to the next line (Y position + 1).

Technical Information

If you are a programmer or just want to know how the GrafPack format works, please indicate this when placing your order. GrafPack compress/expand routines in Z80 machine language are available when you initially support the GrafPack series. Due to the extra printing required, there is a small additional charge for the source to the subroutines of $5.00. If you require the source code (complete) to the FastPack, GrafPack or other parts of this series they made be obtained in their entirety for double the shareware cost.


GrafPack & FastPack copyright 1988 : Mel Patrick