Micros With The Handicapped
Susan Semancik & C. Marshall Curtis
Developing A Communications Program
This is Part 3 of a series of columns to help the handicapped communicate. The program is for the Apple, PET, and VIC.
The following outline shows the progress we've made so far in developing a, program to help non-verbal, motor impaired individuals in their communication needs:
- Introduction (COMPUTE!, April 1982)
- Menu setup (COMPUTE!, June 1982)
- Selection process
- Menu selection
- Menu storage
- Subscripted variables
- DATA lists
- Screen values
- Peripheral devices
- Memory blocks
- Multiple menus
- Access
- Display
- Menu storage
- Menu selection
Selection Of Menu
Example 9 uses subscripted variables and adds lines to the programs of Example 8 (June, 1982) in order to display a chosen entry of the menu at the top of the screen. The user indicates an entry by giving its menu row number and column number (menu row numbers start at one and increase from top to bottom, and menu column numbers start at one and increase from left to right).
In general, the following changes to Example 8 will produce Example 9: change lines 5, 25, 70, and 130: and add lines 300, 310, and 360. Also, the menu is changed so it will fit on all three computers. Example 9 will work on the VIC if W is changed to 22 in line 20. The Apple computer requires the following changes.
10 TEXT : HOME : REM CLEAR TEXT SCREEN 75 P = S(C) + TP 95 IF BR = 0 THEN TP = TP + W : IF TP > 39 THEN TP = 0 : REM UPDATE TAB IF LINE ENDS WITH NO LF 300 VTAB 2 : INPUT"ROW #, COLUMN #?" ;RN, CN : REM INPUT ON 2ND LINE 310 VTAB 1 : PRINT M$(RN, CN) : REM DESIRED MENU ENTRY PRINTED ON TOP LINE
Since most home computers use memory-mapped video, when you PRINT characters on the computer's display screen, these characters are stored as screen values in a block of memory. Usually, changing the values within this block of memory will change the screen contents faster than using PRINT commands will.
If you PRINT a menu to the screen from DATA statements, as is done in Example 9, you actually have the menu stored in memory twice: once within the program storage area of memory, and once in the video-mapped area of memory. If you also save the menu using subscripted variables, then you've increased the memory areas to three, since it is now also stored in the variables-storage area of memory. This can be disastrous if your computer has only a small amount of memory and/or your program or menu is large!
Entry Selection
We can eliminate subscripted variables by using the RESTORE statement to pick the words out from the program's DATA statements when we need them. This is implemented for the PET and VIC computers in Example 10, which lists the changes to be made to Example 9. Make the same changes to the Apple version of Example 9, along with the following change:
350 READ M$ : VTAB 1 : PRINT M$ : REM DESIRED MENU ENTRY PRINTED ON TOP LINE
This program also allows an entry to be selected by its menu row and column numbers and displayed at the top of the screen. The advantage here is that no extra memory is required to store the entries as would be needed by using subscripted variables. The disadvantage is that no other DATA statements can be read in the program without careful checking on where the RESTORE and rereading have left the DATA pointers.
Note that previous non-menu DATA entries are bypassed in line 310 of Example 10. If there had been any non-menu DATA entries needed after the menu selection, we would have had to read through the rest of the menu to get to the right DATA statement after it. (Some computers don't have this problem, since their extended BASIC allows restoration to a particular DATA statement.)
An alternative to the use of the RESTORE statement and its possible DATA pointer problem is to pick the selected menu entries from the video-mapped area of memory. This will, however, cause loss of program mobility between different home computers, since this area of memory is not a standardized location. This can be seen by examining the differences between the versions of Example 11, which uses the PEEK statement to pick up the screen values of the selected entry, and uses the POKE statement to display the entry at the top of the screen. In particular, the VIC needs to add the following lines, the last of which is used to set the color register for text to be visible when POKEing the top line of the screen:
130 SP = 7680 : P = SP + (SR-1)*W : GOTO 300 312 CL = PEEK(646) : FOR I = 38400 TO 38422 : POKE I, CL : NEXT I
The Apple also needs to add the following lines, the last of which is used to help account for the non-linear mapping of the screen:
130 SP = 1024 : GOTO 300 312 R = SR + RN-1 + (RN-1)*BR : REM R = SCREEN ROW # 315 P1 = SP + 128*(R-1)-984*INT(R/8) + 980*INT(R/24)
The DATA statements in Example 11 are used only once to initially display the menu. We should be able to save this memory space by eliminating the DATA statements and entering the menu directly to the screen from peripherals, such as tape recorders or disk units. This concept will be further explored in our next article.
Example 9: For the PET computer – displays a menu by rows from DATA statements, and uses subscripted variables to allow a user to select by menu row and column numbers an entry for display at the top of the screen.
5 REM EXAMPLE 9A) PET COMPUTER 10 PRINT CHR$(147); : REM CLEAR TEXT SCREEN 20 W = 40 : RM = 6 : BR = 1 : CM = 4 : BC = 1 : RI = 2 : SR = 3 : SC = 1 : REM SET MENU PARAMETERS 25 DIM S(CM), L(CM), M$(RM,CM) : S(1) = SC 30 DATA 3, 3, 5, 8 : REM COLUMN WIDTHS 35 IF CM = 1 THEN 50 38 REM CALCULATE STARTING POSITION OF EACH COLUMN 40 FOR I = 2 TO CM : READ L(I-1) : S(I) = S(I-1) + L(I-1) + BC : NEXT I : READ L(CM) 50 IF SR = 1 THEN 70 60 FOR X = l TO SR-1 : PRINT : NEXT X : REM POSITION ~ CURSOR TO 1ST ROW OF MENU 65 LP = S(CM)+L(CM)-1 : IF LP>W THEN 200 70 TP = 0 : FOR R = 1 TO RM : FOR C = 1 TO CM : READ M$ : M $ (R, C) = M$ 75 P = S(C)-1 + TP 80 PRINT TAB (P) ;M$; :NEXT C 90 IF S(CM) + LEN(M$)-1 <W THEN PRINT: TP = 0 : GOTO1 00 : REM WRAPAROUND ADVANCES A LINE 95 IF BR = 0 THEN TP = TP + W : IF TP>87 THEN TP = 0 : REM UPDATE TAB IF LINE ENDS W/NO LF 100 IF BR = 0 THEN 120 110 FOR B = 1 TO BR : PRINT : NEXT B : REM SKIP BLANK ~ ROWS BETWN COLUMN ENTRIES 120 NEXT R 130 GOTO 300 139 REM ENTER DATA BY ROWS 140 DATA DR., IS, COLD, INGEDS12 145 DATA I, AM, WHEN, " AOTFR34" 150 DATA YOU, ARE, DRINK,.ULHCP56 155 DATA MOM, EAT, WANT, ?MYWKB78 160 DATA DAD, NO, TIME, ",VJQZX90" 165 DATA HOT, YES, SLEEP, ";$%()'+-" 200 PRINT "MENU SIZE ERROR!" : END 300 PRINT CHR$(19) : INPUT "ROW #, COLUMN #"; RN, CN : REM INPUT ON 2ND LINE 310 PRINT CHR$(19) ;M$ (RN, CN) : REM DESIRED MENU ~ ENTRY PRINTED ON TOP LINE 360 GOTO 360 : REM DISPLAY ISN'T DISTURBED UNTIL USER BREAKS PROGRAM
Example 10: For the PET computer – changes to Ex. 9, so RESTORE can be used instead of subscripted variables.
25 DIM S(CM), L(CM) : S(1) = SC 70 TP = 0 : FOR R = 1 TO RM : FOR C = 1 TO CM : READ M$ 310 RESTORE : FOR I = 1 TO CM : READ N : NEXT I : REM BY PASS PREVIOUS DATA 315 IF RN = 1 THEN 330 : REM BYPASS PREVIOUS MENU ~ ROWS 320 FOR R = 1 TO RN-1 : FOR C = 1 TO CM : READ M$ : NEXT C : NEXT R 330 IF CN = 1 THEN 350 : REM BYPASS PREVIOUS COLUM N ENTRIES 340 FOR C = 1 TO CN-1 : READ M$ : NEXT C 350 READ M$ : PRINT CHR$(19); M$ :REM DESIRED MENU ENTRY PRINTED ON TOP LINE
Example 11: For the PET computer – changes to Ex. 10, so PEEK and POKE can be used instead of RESTORE.
129 REM SP = STARTING MEMORY AREA FOR SCREEN, P = STARTING SCREEN POSITION FOR MENU 130 SP = 32768 : P = SP + (SR-1)*W : GOTO 300 310 REM P1 = STARTING SCREEN POSITION FOR DESIRED ENTRY 315 P1 = P + (RN-1)*W+(RN-1)*BR*W 320 P1 = P1 + S(CN)-1 330 REM P2 = ENDING SCREEN POSITION FOR DESIRED ~ ENTRY 340 P2 = P1 + L(CN)-1 350 J = 0 : FOR I = P1 TO P2 : POKE SP + J, PEEK(I) : J = J+1 : NEXT I