COLOR COMPUTER GENERAL – PURPOSE DATA BASE
Jeffrey S Yohay
This concludes a two-part tutorial and model program for creating data bases on the TI/99-4A and TRS-80 Color Computer. The model program is called "Video Movie Data Base Program" (VMDP), because it was designed to catalog and manage a collection of movies on videotape. Here the author discusses screen displays and program structure, and presents the data base program itself. The Color Computer program requires 16K RAM memory and Extended BASIC.
Before utilizing this data base manager, there are a few more details to explore. We'll pick up where we left off in March with a discussion of how to add new records.
Adding A Record
When you add a new record, the "add record" routine of the VMDP will prompt you for all of the information necessary to fill the 17 fields. Since the field lengths are all fixed (see Table 1), the "add record" routine will also display a left arrow at the point where the length of the input will match the length of the field.
If you write over this arrow while answering an input prompt, your answer will be too big to fit into the field being filled. You should then backspace and start over, using abbreviations where possible. If you don't, your input will be larger than the field size and will be truncated. If your input is smaller than the field size, the field will be filled with blanks to keep the field (and the record) size constant.
Note that your answer to a field input question will be displayed (in its final length) after you press ENTER; so if your answer was truncated, you'll see it on the screen immediately. You'll have to delete and reenter the record if the truncated data isn't correct.
As I mentioned before, several of the fields contain a code that can be expanded by the VMDP into usable information. The "type of movie" field is a two-byte code that describes the movie; the code can be any of the following:
CO – Comedy (or any light drama)
DR – Drama (a good death scene qualifies)
HI – History (war movies, costume dramas, etc.)
HO – Horror (Bela and Boris, or "Halloween XXIII")
MU – Musical (that's entertainment!)
MY – Mystery (from my favorite director, I presume)
The "commercials" field is a one-byte code that describes how you dealt with commercials when you recorded the movie:
N – None (a pre-recorded tape, or a movie broadcast on non-commercial television)
E – Edited (you removed them)
F – Few (you tried for an "E" but fell asleep!)
M – Many (you deleted a few, then decided it wasn't worth the effort)
A – All (you weren't home, or you just got lazy)
And finally, the "recording speed" field will vary depending on the video format of your VCR. VHS owners will put an S, L or E in this field, for SP, LP or EP recording speed. Beta owners will use 1, 2 or 3 in this field, for Beta I, Beta II, or Beta III recording speed. Beta owners might also want to change line 490 of the "add record" routine from "SPEED (S,L,E)" to "SPEED (1,2,3)" and line 250 of the "display full-data" routine from "P VIEW TIME: " to "B VIEW TIME: ".
The rest of the fields are self-explanatory. You may have to do some thinking to fit a particularly long name into the "title," "director," or "actor/actress" fields, but that shouldn't happen often (unless you have a lot of movies like Abbott and Costello Meet Dr. Jekyll and Mr. Hyde).
And filling the "approximate viewing time" and "approximate time remaining" fields will require some extra effort on your part. You'll need to make a chart of your VCR's counter number vs. recording time, or buy one of the commercially available ones (if there is one for your machine). Note that if the movie is the last one on a particular videotape, you can answer "EOT" (end-of-tape) to the "time remaining" question instead of calculating the few minutes remaining.
Text Screen Displays
The text screen of the Color Computer consists of 512 bytes of RAM at memory locations 1024-1535. This allows for 16 lines of 32 characters, or 512 characters total.
It takes a lot of planning to use this text screen properly, since the small number of characters doesn't allow you to display very much information at once. So I designed the text screens of the VMDP to display as much information in as little space as I could. I also made ample use of the reverse video feature of the text screen (green letters on a black background instead of the usual black letters on a green background) to highlight various portions of the screen. Since lowercase letters are displayed in reverse video, you'll see a lot of PRINT output in lowercase in the program listing.
You might also notice a lot of POKEs into the text screen memory area. Since there is no way to PRINT spaces or special characters (colon, comma, period, etc.) in reverse video, I wondered how I could do the highlighting I had in mind. Luckily, I discovered from the TRS-80 Color Computer Technical Reference Manual that POKEing the ASCII value of these characters directly into the video memory locations in RAM will cause them to appear on the screen in reverse video. Just add 1024 to the desired "PRINT @" screen location to get the correct memory address for the POKE.
I have included some "screen prints" of the VMDP's main text screen displays: Figure 1 is the main menu, Figure 2 is a sample full-data output for a particular movie, and Figure 3 is a sample titles-only movie display. These figures will give you a good idea of how the VMDP displays will look on your screen.
The program itself is 5211 bytes long, leaving ample room for movie data: up to 60 movie records in a 16K computer, and up to 180 in a 32K computer. But this storage is available only if you don't reserve any RAM for graphics (which the VMDP doesn't need anyway). This means not reserving even one graphics page (1536 bytes). Since the Color Computer does not have a "PCLEAR 0" command to clear all the graphics memory for programs and data, you'll have to do it yourself.
Before loading the program, type in the line:
POKE 25,6: NEW <ENTER>
This does the same thing as the missing "PCLEAR 0" command. Then load and run the VMDP. If you forget to clear the graphics memory, the VMDP will remind you by generating an OM (Out of Memory) error in line 40 when it tries to CLEAR the string space for the movie record array.
Note that I use a POKE to test for a 32K machine (line 40), then CLEAR the appropriate amount of string space for the available RAM. I can do this because memory location 16384 (16K+1) will be 255 in a 16K computer (since it doesn't really exist), but will contain whatever you POKE into it in a 32K machine.
Table 2 shows the structure of the VMDP, and Table 3 is a list of the program variables.
Line 40 reserves RAM for movie record storage as described before. Lines 50-80 display the main menu of program options and get the desired option from a two-character command. To check for a correct response and then run the desired subroutine, I used a technique to truncate every answer to one size and then compare it to a string of all the correct answers (CC$) that I previously defined.
Lines 120-200 are global subroutines, i.e., subroutines called from various places in the program. Lines 240-360 are the display routines, including "full-data" and "titles-only" displays of movie data as well as the "search and display" of a particular movie.
Lines 400-430 repeat the "full-data" and "titles-only" displays for a printer. Here is where you might want to use your own imagination to customize the program. Though I have a very capable printer (the NEC 8023), I hesitated to use any of its special features in these routines in order to keep the VMDP as general as possible. So feel free to add the control codes for your printer to enhance the printed output in any way you want.
Lines 470-560 perform the "add record" and "delete record" functions. The "add record" function will prompt you for all the data necessary to build a movie record. The "delete record" function will just find and delete an existing movie record. Note that there is no way to edit an existing record to change only one or more fields. I felt this would require too much memory to implement, and I wanted to keep the VMDP as small as possible to leave ample room for movie data in a 16K machine.
Lines 600-690 are the sort routines. Using a Shell-Metzger sorting algorithm, I provided three sort routines (with many of the required program lines shared by all three) to sort the movie records:
- Alphabetically by title.
- Alphabetically by type and, within types, by title.
- Numerically by videotape number and, within videotapes, numerically by VCR counter number.
You can sort the movie records whenever you want before displaying or printing the movie data.
And finally, lines 730-770 perform all cassette I/O operations to load and save movie data files.
|Table 1:VMDP Record Format|
|Position In Record||Length In Bytes||Information|
|1-28||28||Title of movie|
|29-32||4||Year of release|
|97-98||2||Type of movie (code)|
|101-104||4||Start of movie (VCR counter number)|
|105-108||4||End of movie (VCR counter number)|
|109||1||Reserved for future use (now "/")|
|110||1||Recording speed (code)|
|111-113||3||Approximate viewing time of movie|
|114-116||3||Approximate time remaining on tape|
|117||1||Reserved for future use (now "/")|
|Table 2: VMDP Structure|
|40||Tests for memory size and CLEAR space for data|
|50-80||Display main menu and get command|
|120-130||Expand type of movie code (subroutine)|
|140-180||Assign data fields to variables (subroutine)|
|190-200||Search for a movie record (subroutine)|
|240-280||Display full data for all movies|
|290-330||Display titles only for all movies|
|340||Searches and displays full data for any movie|
|400-420||Print full data for all movies|
|430||Prints titles only for all movies|
|470-550||Add record for new movie|
|560||Deletes record of an existing movie|
|600-690||Sort movies by title, type, or videotape|
|730-740||Load data file|
|750||Saves data file|
|Table 3:VMDP Variables|
|A$||Answer to question|
|A1$,A2$,A3$||Actor/Actress #1, #2, #3|
|C,C$,CC$||Main Menu command variables|
|CN$||VCR counter numbers|
|F$||Data file name|
|I1,I2,I3,I4||Shell-Metzger sort counters|
|IL,IO,IP||Line and page counters for display and print|
|IR||Number of records counter|
|K$||Input from keyboard|
|L||Add Record field length|
|MP||Maximum number of pages in titles-only display|
|N||Shell-Metzger sort variable|
|Q,Q$||Add Record field input question variables|
|R$,R$()||Individual movie record and movie record array|
|RP||Add Record input field location in movie record|
|S||Add Record field input question screen location|
|S$||Print output spacing variable|
|SP$||Recording speed code|
|T$||Title to search for to display or delete|
|TY$||Type of movie code|
|VR$,VT$||Remaining time on tape and viewing time of movie|
|X$,X1$,X2$||Subroutine call variables|
|W||Loop Variable to pause program|
Notes On TI-99/4A Version
An effort was made to keep the translation as close to the author's version as possible. The VMDP record format is the same and the variables used in the program are the same as in the TRS-80 CC version. The line numbers with the explanation are the same in most cases; sometimes lines were added in the TI version because TI BASIC does not allow multi-statement lines.
The TI printed screen is 28 columns wide and 24 lines long. The TI does not have PRINT AT capabilities, so while you are adding a record the screen will scroll, rather than using separate screens.
The cassette file processing procedure is similar to the TRS-80. Line 734 OPENs file device #1, "CS1" or cassette 1. INPUT is used to read in previously saved data. INTERNAL format is used rather than DISPLAY format for more efficiency in this application. Each record is a FIXED length of 127. The TI cassette tape device will use record lengths of 64, 128, or 192 positions in FIXED record type, so we need to specify FIXED 128.
Line 752 OPENs file device #2 to save data in the same format required to read in data.
This program does not check your INPUT as you are adding a record to make sure your answers are logical. Follow the instructions listed in the TRS-80 version for each item entered.
Cassette file processing does not have an EOF function to signal the last data record (disk file processing does). To signal the last record, this program will read the record, then check to see if the first three characters are "ZZZ". Therefore, just before you choose the option to save your data, enter a title of ZZZ (or ZZZZ, etc.). You may press ENTER on each of the remaining INPUT prompts.
Since you may have nearly any type of printer connected to your TI, you will be asked to enter your printer configuration when you choose the printing options. Be sure to use the quotation marks. For example, if you have a TI 825 printer, your printer configuration will be:
"RS232.BA = 600"
For a teletype, the configuration may be:
This program illustrates the power of string manipulation. The data is saved as one long string of characters (127 long), then certain segments are examined for the sort routines or the displays. SEG$ is a function that will return a specific SEGment of a string variable. For example, R$ is the data record. SEG$(R$,1,28) is the segment of R$ starting with the first character and taking 28 characters – the title. SEG$(R$,97,2) is the segment of R$ starting with the 97th character and taking two characters (the TYpe of movie). String variables need to be combined with &, not +.