![Enhancing Applesoft Using Ampersand Routines](https://data.docslib.org/img/3a60ab92a6e30910dab9bd827208bcff-1.webp)
Behavior Research Methods, Instruments, & Computers 1988, 20 (2), 224-230 Enhancing Applesoft using ampersand routines DOUGLAS B. EAMON University of Wisconsin-Whitewater, Whitewater, Wisconsin Machine language routines, which can provide many useful and unusual applications for BASIC, run faster than BASIC and usually occupy less memory than comparable BASIC routines. Ex­ amples of two types of easy-to-use enhancements to Applesoft BASIC are described. The first type consists of integrated collections of enhancements and extensions that are used as a group. A second type allows program developers to select only those routines that are desired. Features available in several sets of such routines are discussed. Applesoft BASIC's ampersand (&) jump feature gives tor or BLOADing the routines each time the program is the programmer an easy and fast way to connect machine run). language routines to BASIC. When the Applesoft inter­ There are two major approaches to development of preter encounters an "&," it does an immediate and un­ commercially available ampersand utilities. In the first, conditional jump to location $3F5 (decimal 1013). This the routines are provided as an integrated and insepara­ feature, originally described as being "intended for the ble collection. A second approach is to provide routines computer's internal use only" and "not a proper that may be individually selected and added to programs. APPLESOFT command" (Apple Computer, 1978, The major advantage ofthe first approach is that it is pos­ p. 123), has become the favorite procedure for execut­ sible to provide many functions with less memory, since ing machine language routines from a running Applesoft the utilities usually share subroutines. The disadvantages program. are that the programmer must always include the entire Location $3F5 and the 2 bytes that follow are known set of routines (or preselected subsets), even if not all are as the ampersand jump vector. Since the location is in used, and that it is difficult to extend a collected set if RAM, it can be easily modified; that is, it is possible to additional routines are desired. The second approach, us­ place into these locations a IMP (jump) to any location ing individually selected utilities, may be preferable when in memory. If the new location contains a machine lan­ only a few routines are needed or when routines from guage routine followed by an RTS (return from subrou­ different sources may be desired. The disadvantages of tine), the routine will be executed and return control to adding separate routines are that they usually require the Applesoft statement following the "&." The "&" somewhat more memory and that special programs are is faster, shorter, and easier to use than other ways to use needed to add them to the BASIC program. machine language routines from Applesoft. Many routines that use this vector (called ampersand INTEGRATED PACKAGES routines) are available to extend and modify Applesoft. For example, there are routines that replace the missing Blankenship BASIC PRINT USING command (Bongers, 1982), GOTO and Blankenship's BBASIC (Blankenship, 1984) is designed GOSUB named routines (Sander-Cederlof, 1983), time to provide a modular structured BASIC for the Apple. responses and intervals (Sanmartin, 1987), insert and de­ It both modifies and supplements Applesoft as a language, lete rows or columns into an array (Nick, 1987), provide providing REPEAT-UNTIL, WHILE-ENDWHILE, in-line editing ofstrings using word-processor-like com­ IF-THEN-ELSE, CASE, PERFORM named subroutine, mands (Smith, 1985), and so on. In addition to enhanc­ PRINT.USING, SWAP, SEARCH array, INSTR$, ing Applesoft as a language, ampersand routines can pro­ DEL.ARRAY, SORT, INKEY,INLINE, and other state­ vide functions not typically found in high-level languages ments. Graphics capabilities include BOX and BOXFILL (e.g., in-line editing). The routines are also faster than and a very general DRAW.USING command, which ac­ Applesoft routines and usually require less memory than cepts as input a character string. (Each character of the comparable Applesoft statements. string causes the cursor to move in one of eight direc­ This paper describes a number of useful routines and tions, with or without plotting.) collections of general interest, and provides information A special VECTOR address command allows the user on how several ampersand routines can be easily con­ to specify an address to which the program will jump if nected to an Applesoft program to be LOADed and it encounters an ampersand command not recognized by SAVEd along with the program in a "transparent" way BBASIC. This is designed to allow other ampersand com­ (i.e., without POKEing values to the ampersand jump vee- mands to be used with BBASIC. Reprints may be requested from the author at the Department of Psy­ The system also includes a program editor that LISTs chology, Universityof Wisconsin-Whitewater, Whitewater,WI 53190. programs with loops and IF statements indented for read- Copyright 1988 Psychonomic Society, Inc. 224 ENHANCING APPLESOFT 225 ability. Although BBASIC's commands are implemented LISTING 1 by ampersand jumps, no ampersands appear when a pro­ Portion of Program Written in BASIC Demonstrating gram is listed; listings are thus uncluttered and easy to Various Structured Programming Commands follow. All program segments are procedures; no line 1000 COMPILE numbers are referenced or needed (GOTO line number 1010 HGR is not supported). 1020 DIM WSIZE(S,S) Listing I shows a portion of a BBASIC program that 1030 WL= O:WR = 39:WT = O:WB = 23 1040 HOME saves and restores selected portions ofscreen '<windows" 10S0 WNUM= 0 to disk; an example of a screen display produced by the 1060 PRINT spec 14)"WINDOW DEMO" program is shown in Figure I. Although the text in 1070 REPEAT Figure 1 is in uppercase letters, BBASIC also allows 1080 VTAB 3: HTAB 1 lowercase text to be printed on the graphics screen. 1090 PRINT "HOW MANY WINDOWS "j 1100 INLINE A$:N = VAL (A$) The required COMPILE command in Listing 1 causes 1110 UNTIL N < 6 BBASIC to construct a table of addresses of the proce­ 1120 HOME dures defined; use of this table provides much faster pro­ 1130 FOR I = 1 TO N gram execution than would be obtained if the program 1140 PERFORM "GET WINDOW" neededto besearched for the procedures whenever a PER­ 11S0 PERFORM "OPEN WINDOW" 1160 PRINT "THIS IS WINDOW NUMBER "iI FORM command was encountered. Other commands are familiar to users of structured BASICs. 1170 INPUT "PRESS RETURN TO CONTINUE" There are two versions ofBBASIC. The standard ver­ iA$ sion, called simply BBASIC,locates itself in the low end 1180 NEXT I of memory and moves the Applesoft program above high­ 1190 FOR I = 1 TO N resolution graphics page I (HGRI). Since many longer 1200 INPUT "PRESS RETURN"jA$ programs overwrite this memory area, they are commonly moved above HGRI, and the space below the graphics 1240 DEFINE "WINDOW ROUTINES" memory area would be unused anyway. BBASIC is com­ patible with programs that can move DOS 3.3 to a lan­ 12S0 DEFINE "GET WINDOW" guage card (e.g., Basham, 1982), so the space occupied 1260 HCOLOR= 0 by BBASIC (about 8000 bytes) can be recovered in this 1270 BOXFILL WL * 7 ,WT * 8 ,WR * 7 ,W B * 8 way. 1280 REPEAT An alternate version ofBBASIC, called BBASIC.MM 1290 A= - 1:B ~ A:C = A:D A (the '<MM" means "maximum memory"), locates the 1300 REPEAT Applesoft program at the beginning of HGRI memory; 1310 VTAB WT + 1 this allows recovery of the 8000 bytes needed for high­ 1320 HTAB WL + 1 resolution graphics displays but, obviously, does not allow 1330 PRINT "LEFT (0-36) "i 1340 INLINE A$:A = VAL (A$) high-resolution graphics to be used. Neither version of 13S0 UNTIL A > - 1 AND A ( 37 BBASIC supports high-resolution graphics page 2. 1360 REPEAT BBASIC includes 46 new Applesoft commands, an edi­ 1370 VTAB WT + 2 tor, and a renumbering facility. Editing commands ad- 1380 PRINT "RIGHT ("A + 3"-39) ".I 1390 INLINE A$:B = VAL (A$) 1400 UNTIL B > 1 AND B ( 40 AND B - A ) 2 1410 REPEAT 1420 VTAB WT + 3 Note-Substantial portions of the actual program are missing from this listing. TH IS IS· \.j HmOH Nur'1BEF: 2 F'F:ESS PETUF:tl TO corn ItlUE_ here to the modular structured philosophy: to edit a por­ tion of the program, the user enters EDIT "NAME," where NAME is the name of a procedure. BBASIC's LIST command functions similarly. Blankenship also has written a character editor Figure 1. Reproduction of a grapbic:s screen generated by thepro­ (Blankenship, 1985a) and a program that concatenates gram shown in Listing 1. The screen is distorted vertically; the ac­ many program statements on a single line to conserve tual appearance of tbe screen shows more space between the lines. memory (Blankenship, 1985b). 226 EAMON BBASIC's 12-page instruction manual is printed on windows, and an interesting and useful DISK GOSUB brown paper in tiny print (to discourage photocopying) command that executes a subroutine on disk and returns and consists mostly of a simple list of the commands avail­ to the calling Applesoft program in memory. able. A separate book may be obtained that describes TERC commands are identified by preceding them with structured programming with BBASIC (Blankenship, a single quote; for example, 'GOSUB HELP [A$] passes 1986). BBASIC is available for either DOS 3.3 or the variable A$ to the subroutine HELP. Since the am­ ProDOS. persand is not used to interface TERC, no difficulties arise with the use of ampersand commands, and no command Short Cuts is therefore provided to reset the ampersand jump vector. ShortCuts (Puckett, 1983) provides a collection of over Like BBASIC, TERC locates itself in the low end of 30 ampersand routines, including protected INPUT, memory and moves the Applesoftprogram above the high­ PRINT USING, several print justification commands, a resolution graphics area.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages7 Page
-
File Size-