When I started to put MTERM II onto the LARKEN system I had some ideas of what I wanted to do. Primarily I wanted to be able to make disk saves of the buffer at any time while on-line. I soon found that as MTERM was constituted, this was impractical. MTERM as presently constituted cleared out any BASIC program and variables that were initial- ly present. Thus my idea of having a BASIC program ready to perform the disk-save immediately upon an exit from MTERM was not possible. I have overcome this by a few judicious POKEs into MTERM, plus some unique ideas in a companion BASIC program. The following notes describe the changes and their purpose.
I found that one of the first things that MTERM does upon initialisation is to look at the system variables VARS and PROG. It uses these values to clear out the BASIC program and variables, also to help in determining the ongoing buffer status.
Bytes which do this are located at 54035/37, 54043/45, and 61165/66. I modified the program by POKEing new values into several MTERM addresses, as follows.
54034,33: 54035,12: 54036,123
54043,33: 54044,12: 54045,123
54523 to 54537, POKE all zero's in these addresses.
The first six POKEs cause MTERM to set the start of the buffer space. This figure could be set anywhere; it is simply a trade-off between buffer size and BASIC program size. Initially, I considered having MTERM look at the system variable E-LINE, however I found that this became corrupted whenever I entered a direct command. I fastened on an arbitrary value of 31500 since I felt that with a disk-save routine in place, maximizing buffer space was less important than having sufficient space for the BASIC program. This sizing will allow a LARKEN-modified LOADER V to be used.
I found that with this, even though the BASIC remained untouched, the program variables were being wiped out. Looking around, I found a block of MTERM code (54523/54537) that appeared to do this. I simply wiped it out with no apparent ill-effect.
Addresses 61164/65 store the used/free buffer status. They are loaded with the values found in addresses 54044/45 (i.e. the starting address of the buffer) at initialisation, and are incremented as the buffer fills. I have made use of this in LINE 22 of the BASIC program to determine the size of the block of data to be saved.
These addresses 61164/65 can be useful in another way. If, for example, you inadvertently erase the buffer while in the Buffer Menu mode it is possible to restore it. Option 4 in the menu allows you to insert an arbitrary buffer length. This will change the “buffer used/free” pointer in MTERM so that one can view and/or save the buffer.
These addresses 61164/65 can be useful in another way. If, for example, you inadvertently erase the buffer while in the Buffer Menu mode it is possible to restore it by POKEing address 61165 with a value between 124 and 211. The buffer itself has not been erased, simply the pointer, and this POKE creates an arbitrarily-sized buffer.
There a number of features about the program which are worthy of explanation. LINE 100 contains POKEs to addresses 23662/63. It’s purpose is this. Usually, if you execute a RAND USR from a BASIC program and return, the BASIC program will continue from where you left it. However with MTERM this is not the case. You will come out to an OK report at the bottom of the screen. I was unable to find the MTERM code which caused this. Failing that, I solved the dilemma by POKEing a number into the system variable OLDPPC (address 23662/63) corresponding to the LINE number where I wish to continue in the BASIC program. Then, when I exit from MTERM it is simply necessary to press the C key (CONT), and the ENTER key, to find myself back into the running BASIC program at the spot where I want to be.
The BASIC has a couple of other things about it which are of interest. If one accesses MTERM by a RAND USR 54016 the program is reinitalized with the buffer set as cleared. However, if it is desired to re-enter MTERM without disturbing the state of the buffer then one can use RAND USR 54089. This option has been included in the BASIC at LINES 30 and 32.
There probably will be occasions when several successive buffer SAVES will be required during the same download. The BASIC contains an arrangement whereby the name of the saved buffer remains the same while it’s suffix is incremented. Where the initial SAVE has a suffix of “Ca”, the suffix in subsequent SAVEs will be incremented as “Cb”, “Cc”, etc.
Although we have shown an original BASIC program here for use with MTERM there is every reason to imbed these program ideas into LOADER IV or LOADER V. They will work there in the same way, and provide for the additional features of these programs.
Also, even without a disk system, these features may prove to have some merit, and are worth considering.
In adapting this program you will have to watch carefully when you tamper with the makeup of LINES 20 21, 32, and 100. What you are trying to do is direct the return of the computer to the appropriate line and statement number, and this can be tricky.
Note that the program is designed to be used in the LARKEN AUTOSTART mode. That is, you should save it to disk with a GOTO 3.
0 REM Modified MTERM II for the LARKEN disk system by G. Chambers
2 GO TO VAL "9"
4 CLEAR VAL "31499": RANDOMIZE USR VAL "102"
6 CLEAR VAL "54015": RANDOMIZE USR VAL "100": OPEN #4,"dd"
7 PRINT #4: LOAD "mterm2.C1"CODE
9 LET g$="buffer"
10 LET g=VAL "150": LET q=VAL "97": LET f=VAL "20": LET o=NOT PI: LET i=PI/PI: BORDER o: PAPER o: INK VAL "7": CLS : PRINT TAB VAL "10";"MTERM II"''''TAB PI*PI;"MAIN MENU:"''''TAB PI+PI;"1) RUN MTERM"'''TAB PI+PI;"2) LOAD BUFFER"'''TAB PI+PI;"3) NAME A BUFFER FILE"'''TAB PI+PI;"4) RESTORE BUFFER"'''TAB PI+PI;"5) SCAN DISK FILE":: GO SUB VAL "13": IF LEN z$<>i OR z$<"1" OR z$>"5" THEN RUN
12 GO TO VAL z$*f
13 INPUT "Your Choice? "; LINE z$: RETURN
20 GO SUB g: RANDOMIZE USR VAL "54016"
21 CLS : CLS : LET q$=CHR$ q: PRINT AT VAL "10",NOT PI;"Save buffer to disk?(Y/N)"'''"File Name is "; FLASH PI/PI;g$+".C"+q$: FLASH o: PAUSE o: IF INKEY$="n" OR INKEY$="N" THEN GO TO VAL "24"
22 LET n=PEEK VAL "61164"+VAL "256"*PEEK VAL "61165"-VAL "31500"
23 LET q$=CHR$ q: LET q=q+PI/PI: PRINT #4: SAVE g$+".C"+q$CODE VAL "31500",n
24 IF INKEY$<>"" THEN GO TO VAL "24"
25 CLS : PRINT AT VAL "10",NOT PI;"Press ENTER if you wish to clear the buffer"''"Otherwise press any other key": PAUSE o
30 IF CODE INKEY$=VAL "13" THEN GO TO VAL "20"
32 GO SUB g: RANDOMIZE USR VAL "54089"
40 CLS : PRINT TAB 9;"LARKEN/MTERM II"''''''''"Insert disk containing program to be loaded & press a key": PAUSE o: CLS : PRINT #4: CAT "",: PRINT ''"Full name of File (9 char$): ";: INPUT "Filename? "; LINE n$
44 PRINT #4: LOAD n$CODE VAL "31500"
48 INPUT "Enter the file length"''" (approx. if not known)";l: LET l=l+VAL "31500": IF l>VAL "53966" THEN LET l=VAL "53966"
50 POKE VAL "61164",l-256*(INT (l/256)): POKE VAL "61165",INT (l/256)
55 CLS : GO TO VAL "32"
60 CLS : INPUT "Buffer Name (6 Chars) ";g$: GO TO VAL "10"
80 IF Z$="4" THEN GO TO 48
100 CLS : PRINT AT VAL "17",NOT PI;"Enter full Disk File Name ": INPUT g$
110 PRINT #4: PRINT g$
115 GO TO 10
150 POKE VAL "23662",VAL "21": POKE VAL "23663",NOT PI: RETURN
COMMENTS: An old “ZX’er can readily recognize another by his programming style which minimizes byte waste. <LET i=PI/PI> saves four bytes of memory as opposed to <LET i=1>. George Chambers started computing with a ZX-80 back in 1981, graduated to a ZX-81, and then to his TS-2068. He chartered the Toronto Timex Club in 1982 and has served in an executive role since. He is retired from the engineering dept of Bell Canada, a Cub Scout Leader, and a volenteer worker for the National Institute for the Blind. About the program: I have tried for a year to cut into MTERM II and make it dump data to disk. Now George has dude it where I failed. SALUTE! and Thanks George! Now you Oliger or Aerco users: The line numbers to edit and change to your disk syntax are: 6, 7, 27, 40, 44, and 100. Also, <RANDOMIZE USR 100> and <PRINT #4> are LARKEN SYNTAX and each use must be deleted for other disk systems or cassette. (Ed.)
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.