                             OVERVIEW
     PICDRIVE is a data management system which allows data to be  
organized, saved to, and recovered from pictures.  Saved games and other 
records are easily corrupted by other programs when kept in lists or 
matrixes.  PICDRIVE minimizes this corruption by allowing data from many
programs to be archived on to a picture in binary form.  PICDRIVE can  
use pictures 1-5, and on this space can store 60 games of Minesweeper,
35 games of Laserchess, or ten grade records of 99 assignments each.  Not
only is this data kept safer from being overwritten, but it is stored in
a much more memory efficient manner.  To illustrate: 60 games of
Minesweeper stored on matrixes would require 140160 bytes of memory 
(584 bytes per matrix * 4 matrixes * 60 games).  PICDRIVE allows all 60 
games to be stored in 3820 bytes, a 97% savings.  (By the way, versions
of Minesweeper, Laserchess, and a grade records database program are 
included.)  PICDRIVE makes it practical to play only part of a game at
a time, then save, run other programs, and return to the game exactly as
it was left.

                              PICDRIVE
     PICDRIVE handles the allocation of area on each picture for data
storage.  The first two lines of each picture comprise the File Allocation
table (FAT).  When a program asks to load data, PICDRIVE interprets the
FAT to determine the location of the data requested.  When a program 
requests to save data, PICDRIVE coordinates the creation of the new record.

                              SPECIFICS
To run PICDRIVE, variables A,B,C,D, and  are used to communicate commands
between the program running PICDRIVE and PICDRIVE itself.
Variable 'A' is the command.  When A=0, PICDRIVE is in loading mode, and
finds the location of the data requested.  When A>0, PICDRIVE is in save
mode, with the value of A being the number of lines the program requests 
to store its data on.  When A=-1, PICDRIVE stores the current picture to
the picture of the number contained in variable 'C'.
Variable 'B' is the identification number of the program running PICDRIVE.  
PICDRIVE's FAT can only distinguish between 8 programs, 'B' values 0-7.  
The included programs use the following values: GRADES, B=0;
LASERCHS, B=1; and SWEEPER, B=2.  It doesn't matter what number is used
for B, as long as each program has a unique identity that is an integer
between 0 and 7.
Variable 'C' is the picture used by PICDRIVE.
Variable 'D' is the line number returned by PICDRIVE.  When loading or
saving, PICDRIVE returns the line number of the screen to which the 
program should load or save to.  Lines are numbered starting with 0 at
the top edge of the screen.  When a program asks to load a record, and 
no records from that program exist on that picture, PICDRIVE returns 
D to be -1.
Variable '' is a flag.  When =log , PICDRIVE will load/save.  If it
is not, PICDRIVE will display available space on the picture.


     PICDRIVE does not handle the actual loading or saving of numbers, it
points the program to where it should load or save on the picture.  Here
are some examples of loading or saving code.  When loading or saving, the
size of the numbers being loaded or saved is of great importance.  Space 
is saved by representing each number with the fewest number of bits. 
Here is a table of how many bits numbers should be represented by.  (This
only works for positive numbers.)
Maximum number to be saved:             Number of bits:
            1                                  1
            3                                  2
            7                                  3
            15                                 4
            31                                 5
            63                                 6
            127                                7
            255                                8
            511                                9
            1023                               10
            2047                               11
            4095                               12
            ....                               ....
            2^n-1                              n

Example code:
Save values of matrix [A], dim {8,8}, when the maximum value of A is 15
and program id# of 3
log  (store)                 * Flag 
3 (store) A                    * Save command.  Choose 3 because:
                                     8*8 elements*4 bits per element
                                     -------------------------------
                                               95 bits per line
                                     (rounded up)
3 (store) B                    * Program id#
prgmPICDRIVE
0 (store) W                    * X coordinate of write pixel
For(F,1,8
For(G,1,8
[A](F,G) (store) Q
For(H,3,0,-1                   * H goes from 3 to 0 so 4 bits are used in
If Q2^H:Then                        the writing.  (3,2,1,0)
Q-2^H (store) Q
Pxl-On(D,W)                    * D is given by PICDRIVE
End
W+1 (store) W                  * Move write pixel
If W=95:Then                   * If write pixel off edge of screen, wrap to
0 (store) W:D+1 (store) D            next line
End
End
End
-1 (store) A                   * Command - save picture
prgm PICDRIVE                  * Store saved data
0 (store)                     * Clear flag


Load to matrix [A], dim {8,8}, when the maximum value of A is 2047 
and program id# is 3
Lbl 1
log  (store)                 * Set flag
0 (store) A                    * Load command
3 (store) B                    * Program id# 3
prgmPICDRIVE
0 (store)                     * Clear flag
If D=-1:Goto 1                 * Error trap: if no record was found, 
                                      restart
0 (store) W                    * X coordinate of read pixel              
For(F,1,8
For(G,1,8
0 (store) Q 
For(H,10,0,-1                  * 11 bits per element
pxl-Test(D,W)*2^H+Q (store) Q  * Read number
W+1 (store) W                  * Move read pixel
If W=95:Then:0 (store) W       
D+1 (store) D
End
End
Q (store) [A](F,G)
End
End

Similar things can be done with lists/variables/whatever.
------
Any program included that starts with  is a subroutine.

                         FINAL WORDS
Also included in the group is a sample Pic1 with assorted records for the
accompanying programs.
Direct any and all comments, complaints, suggestions, wishes or other
forms of communication to pac@printrak.com.  I really would like to know
what you think of these programs, and I will take suggestions for programs
which you would like to be adapted for use with PICDRIVE.  Distribute 
these programs however you would like, however, I would like it if the
documentation accompanied PICDRIVE/ LASERCHS, otherwise the programs
won't make sense.  Thanks!
Bryan Catanzaro pac@printrak.com

Picdrive uses /theta/range as a subroutine.
\START82\
\COMMENT=Program file dated 03/12/97, 18:10
\NAME=PICDRIVE
\FILE=C:\BRYAN\TI\UPLOAD\PICDRIVE.82P
:If A<0:Goto U
:prgm\@\RANGE:ClrDraw:ClrHome
:If A>0 and \@\=log \pi\:Goto 0
:Lbl D
:If A=0 and \@\=log \pi\:Menu("LOAD FROM DRIVE:","A",1,"B",2,"C",3,"D",\#\
4,"E",5
:If \@\=log \pi\
:Menu(" SAVE TO DRIVE: ","A",1,"B",2,"C",3,"D",4,"E",5
:Menu("     DRIVE:     ","A",1,"B",2,"C",3,"D",4,"E",5
:Lbl 1
:1\->\C
:RecallPic Pic1
:Goto A
:Lbl 2
:2\->\C
:RecallPic Pic2
:Goto A
:Lbl 3
:3\->\C
:RecallPic Pic3
:Goto A
:Lbl 4
:4\->\C
:RecallPic Pic4
:Goto A
:Lbl 5
:5\->\C
:RecallPic Pic5
:Goto A
:Lbl 0
:Menu("    SAVE TO:    ","EXISTING DISK",D,"NEW DISK",B
:Lbl B
:8\->\dim \L5\:8\->\dim \L6\:0\L5\\->\\L5\:0\L6\\->\\L6\
:Line(0,62,3,62
:Pt-On(5,62
:61\->\X:1\->\U
:Menu("DISK ON DRIVE"," A",E," B",F," C",G," D",H," E",I
:Lbl E
:1\->\C
:Goto U
:Lbl F
:2\->\C
:Goto U
:Lbl G
:3\->\C
:Goto U
:Lbl H
:4\->\C
:Goto U
:Lbl I
:5\->\C
:Goto U
:Lbl A
:ClrList \L4\,\L5\,\L6\
:0\->\W:0\->\X
:ClrHome
:Output(4,5,"WORKING.
:For(I,5,0,\(-)\1
:pxl-Test(0,W)2^I+X\->\X
:W+1\->\W
:End
:If \@\\<>\log \pi\:Then
:ClrHome
:Output(2,8,round(95X/8,0
:Output(3,4,"BYTES FREE
:Output(5,8,round(100X/61,0
:Output(6,3,"PERCENT FREE
:Output(8,15,"bc
:Stop
:End
:0\->\Z:1\->\U:0\->\Q:1\->\H:0\->\V
:While Q=0 and H<21
:0\->\S:0\->\T
:For(I,2,0,\(-)\1
:pxl-Test(V,W)2^I+S\->\S
:W+1\->\W
:If W=95:Then:0\->\W:V+1\->\V:End
:End
:For(I,5,0,\(-)\1
:pxl-Test(V,W)2^I+T\->\T
:W+1\->\W
:If W=95:Then:0\->\W:V+1\->\V:End
:End
:If T=0:1\->\Q
:If T\<>\0:Then:U+1\->\U:S\->\\L5\(H):T\->\\L6\(H)
:H\->\\L4\(H):End
:H+1\->\H
:End
:SortA(\L5\,\L6\,\L4\
:0\->\N:0\->\O
:For(I,1,dim \L5\
:If \L5\(I)=B and \L6\(I)\<>\0:Then
:If O=0:I\->\N
:O+1\->\O
:End
:End
:If O\>=\1:Then
:For(I,N,N+O-1
:\L4\(I)\->\\L4\(I-N+1
:\L5\(I)\->\\L5\(I-N+1
:\L6\(I)\->\\L6\(I-N+1
:End
:O\->\dim \L4\
:O\->\dim \L5\
:O\->\dim \L6\
:SortA(\L4\,\L5\,\L6\
:1\->\N
:End
:If A\<>\0:Goto K
:If O=0:Then
:ClrHome
:Disp "THERE ARE NO","RECORDS FROM THE","CURRENTLY","RUNNING","PROGRAM \#\
ON THIS","ARCHIVE.
:Pause 
:\(-)\1\->\D
:End
:If O=0:Goto Y
:If O>1:Then
:ClrHome
:Disp "THERE ARE","RECORDS FROM","THE CURRENTLY","RUNNING PROGRAM","ON \#\
THIS DISK.","CHOOSE WHICH TO","LOAD (1-  ).
:Output(7,9,O
:Output(1,11,O
:Input P
:P-1+N\->\N
:End
:Lbl Z
:\L6\(N)\->\D
:Goto Y
:Lbl K
:If O=0:Goto L
:Menu("     RECORD:    ","OVERWRITE OLD",N,"CREATE NEW",L
:Lbl N
:If O\<>\1:Then
:ClrHome
:Disp "THERE ARE","RECORDS OF THE","CURRENTLY","RUNNING PROGRAM.","OVER\#\
WRITE WHICH","RECORD?  (1-  )
:Output(1,11,O
:Output(6,13,O
:Input I
:End
:If O=1:1\->\I
:\L6\(I)\->\D
:Lbl T
:For(I,D,D+A-1
:Line(0,62-I,94,62-I,0
:End
:Goto Y
:Lbl L
:If A>X or U=21:Then
:ClrHome
:Disp "THIS DISK","DOES NOT HAVE","ENOUGH SPACE","TO STORE THIS","DATA.\#\
:Pause 
:End
:If A>X or U=21:Goto 0
:63-X\->\D:D\->\R
:X-A\->\X:0\->\W
:For(I,5,0,\(-)\1
:If X\>=\2^I:Then:X-2^I\->\X:Pxl-On(0,W):Else:Pxl-Off(0,W):End
:W+1\->\W
:End
:0\->\V
:9U-3\->\W:If W>94:Then:W-95\->\W:1\->\V:End
:For(I,2,0,\(-)\1
:If B\>=\2^I:Then
:Pxl-On(V,W
:B-2^I\->\B
:End
:W+1\->\W
:If W=95:Then:0\->\W:V+1\->\V:End
:End
:For(I,5,0,\(-)\1
:If R\>=\2^I:Then
:R-2^I\->\R
:Pxl-On(V,W
:End
:W+1\->\W
:If W=95:Then:0\->\W:V+1\->\V:End
:End
:Goto Y
:Lbl U
:If C=1:StorePic Pic1
:If C=2:StorePic Pic2
:If C=3:StorePic Pic3
:If C=4:StorePic Pic4
:If C=5:StorePic Pic5
:If A<0:Return
:Goto L
:Lbl Y
:ClrList \L4\,\L5\,\L6\
\STOP82\
\START82\
\COMMENT=Program file dated 03/12/97, 18:12
\NAME=\@\RANGE
\FILE=C:\BRYAN\TI\UPLOAD\ZRANGE.82P
:FullScreen
:FnOff :PlotsOff :AxesOff:Func:0\->\Xmin:94\->\Xmax:0\->\Ymin:62\->\Yma\#\
x
\STOP82\
