Documentation for XMDM26, for TRS-80 Model 100 Version 2.6 of 5/23/87 by Leonard Erickson 70465,203 (from XMODEM.312 by Rick Perry, without which this would never have been done) "If I seem to see farther than others, it is because I stand upon the shoulders of giants." This program performs auto-dial-redial, auto-logon, and buffered text file transfers (.DO) using either regular ASCII Xon/Xoff protocol or the Xmodem Christensen checksum protocol. Communication parameters are 8N1D during Xmodem file transfers and 7I1E for terminal emulation and Xon/Xoff transfers. The program will operate using the 300 baud internal modem or an external modem (Hayes compatible) at 300, 1200, or 2400 baud. Files may be Up/Down loaded directly from/to RAM, disk or cassette. Graphics characters were used to remove the need for several strange routines to set up string varibles and function keys. Due to uploading problems those lines (32, 41, 53, & 67) have been left out. You need to run the following program which will create a file called MERGE.DO. 10 OPEN"merge"FOROUTPUTAS1:Q$=CHR$(34) 20 PRINT#1,"32 POKE-86,0:D=0:ONERRORGOTO44:POKE63056,64:A$="+Q$+"Pre"+CHR$(246) +"Dow"+CHR$(238)+"U"+CHR$(240)+"Ter"+CHR$(237)+"Br"+CHR$(235)+"Fr"+CHR$(229)+"D i"+CHR$(242)+"By"+CHR$(229)+Q$+":GOSUB54" 30 PRINT#1,"41 GOSUB92:IFA$="+Q$+"Y"+Q$+"THENE=0:GOTO7ELSEA$="+Q$+"Pre"+CHR$ (246)+"@@@"+CHR$(192)+CHR$(128)+"Ter"+CHR$(237)+"Br"+CHR$(235)+"Fr"+CHR$(229)+" Di"+CHR$(242)+"By"+CHR$(229)+Q$+":GOSUB54:N=-1:D=-1:GOTO33" 40 PRINT#1,"53 A$="+Q$+STRING$(7,128)+"Abr"+CHR$(244)+Q$ 50 PRINT#1,"67 N$=CHR$(0):G$="+Q$+CHR$(255)+Q$+":F$="+Q$+CHR$(248)+CHR$(249)+CH R$(250)+CHR$(251)+CHR$(252)+CHR$(253)+CHR$(254)+CHR$(255)+Q$+":U$=chr$(27)+"+Q$ +"A"+Q$+":POKE63056,64:CALL17875:POKE63056,0:CALL27804" After running this, load XMDM26 into BASIC. Then type MERGE"MERGE". This will merge the new lines into XMDM26. Now you can save the completed version. AUTO-DIAL/LOGON: The program starts with a "Find:" prompt and will attempt to retrieve a phone number and auto-logon sequence from the ADRS.DO file and logon to a host computer. When using the internal modem, if no carrier is detected within 20 seconds after dialing, or if you press any key, the program will hang up the phone. After waiting 2 seconds more, it will retry the number unless you press any key. If the carrier is detected, it will BEEP and proceed through the auto-logon sequence as specified in the ADRS line, then jump to the terminal emulation mode of the program. At the "Find:" prompt you may: 1. press F1 (or enter "Files") to change the search file. (normally the ADRS.DO file is used). You will be prompted ("File:") for the file to use. Both RAM & disk files (DVI and Chipmunk, *not* TDD!) may be used. 2. press F8 (or enter "Menu") to return to the Menu 3. enter "Dial" if you wish to manually dial a telephone number. After dialing and hearing the carrier tone, press "M", "3", "5" or "6" (see below for to details on which to use) to allow the program to Connect, or press any other key to return to the "Find:" prompt. 4. enter a string to search for in the search file. ONLY LINES CONTAINING COMPUTER PHONE NUMBERS WILL SEARCHED! If the string is not found you will be returned to the "Find:" prompt. If match is found you may: 1. press "M" to begin auto-dial using the internal modem 2. press "3" to dial through an external Hayes-compatible modem at 300 baud 3. press "5" to use Hayes at 1200 baud 4. press "6" to use Hayes at 2400 baud 5. press ESC to return to the "Find:" prompt 6. press any other key (such as ENTER) to continue searching. TERMINAL EMULATION: Once in terminal emulation mode, the program is transparent to all control characters entered from the keyboard and these characters (like CTRL/C/S/Q) will be sent to the host. But Function key F5 (Brk) may be used to STOP the program if needed. F1 (Prev) will display the previous screen, same as in TELCOM. (unless you are using a TV or monitor with a DVI) F2 (Down) will initiate a file download transfer and F3 (Up) will initiate uploading. F4 (Term) is used to jump directly to TELCOM's Term mode while remaining connected to the host. Once in TELCOM you cannot return to the program without logging off and disconnecting from the host unless you are connected through an external modem. F6 (Free) provides a display of how many bytes of RAM are currently available. F7 (Dir) lists the RAM file directory in the same way as the BASIC FILES command. F8 (Bye) is used to exit the program and return to the Model 100 Main Menu. FILE TRANSFERS: After pressing F2 or F3 and entering file name, program prompts "Append?" if downloading. Then it prompts "Use XMODEM protocol?" -- press "Y" or "N". Responding with "N" means that buffered Xon/Xoff protocol will be used. For uploading using Xon/Xoff protocol answer "Width?" prompt by pressing ENTER if no wrapping is desired, otherwise enter desired width for word wrapping. During Xon/Xoff download, F3 is blanked and F2=@@@@. Press F2 to end download. During upload, use F8 to abort. DOWNLOADING WITH XMODEM PROTOCOL: The host should be ready to send the file before entering this mode. While downloading, the received file is not displayed on the screen. When a NAK (negative acknowledge) is sent, the program prints an "X". When ACK (acknowledge) is sent, the program prints ".". You can abort the download at any time by pressing F8 (Abrt). The program itself will automatically abort the download only if one of the following circumstances occur: - The host sends a CANcel. - The received block number is neither the current block number nor the previous block number. - An error trap occurs in the program (this could be caused by an "Out of Memory" condition on the Model 100). UPLOADING WITH XMODEM PROTOCOL: The host should be ready to receive the file before entering this mode. While uploading, the transmitted file is not displayed on the screen. When a NAK is received, the program prints an "X". When ACK is received, the program prints ".". If nothing is received after waiting 10 seconds, or if anything other than NAK, ACK or CAN is received, the program prints a "?". You can abort the upload at any time by pressing F8 (Abrt). The program itself will automatically abort the upload only if the host sends a CANcel or if an error trap occurs (e.g. due to an IO Error when uploading from cassette). PROGRAM NOTES: The program itself does not count the number of NAK's sent or received per block and will not automatically abort if an excessive number of NAK's occur. It is up to you to use F8 (Abrt) to cancel the file transfer if you feel that too many NAK's are occuring. When aborting a file transfer the program sends a single CANcel character (CTRL/X) to the host and returns to its terminal emulation mode. If you then notice that the host has not responded to the CANcel, you may send additional CAN's by pressing CTRL/X. Some hosts expect to receive three CTRL/C chars in a row to signal an abort; that's dumb, but anyway, if CTRL/X doesn't work, try that. Most hosts will automatically abort an Xmodem transfer if no chars are received for 1 or 2 minutes. MAXFILES is set to 3 at the beginning and reset to 1 upon normal exit to the Menu or TELCOM. Function key definitions are restored to their previous user-defined values upon exit from the program to the Menu or TELCOM. The following ROM calls and POKEs are used: 6118 - set serial interface parameters and activate modem. 16969 - turn cursor on. 17061 - set and display temporary function key strings. 17875 - fill previous screen with blanks. 21172 - keep phone off hook. 21179 - hang up phone. 21264 - 2 second delay. 21274 - 1/2 second delay. 21293 - dial a phone number. 21392 - execute auto-logon sequence. (internal modem *only* 21443 - execute auto-logon sequence. (external modem) 21608 - jump to TELCOM's Term mode. 21795 - display previous screen. 27804 - restore function key definitions. POKE 63056,64 - enable scrolling into previous screen area and also disables Break and ON KEY and makes F1...F8 return chars 248...255. POKE -86,0 - purge keyboard buffer. MACHINE LANGUAGE SUBROUTINES: The integer array M(0)..M(60) is used to hold six position independent machine language subroutines. Entry points are at M(0), M(3), M(16), M(21), M(24) & M(59). The assembly source listing follows: ; ENTRY M(0) - check MDM: for carrier detect. ; calling sequence: CALL VARPTR(M(0)),0,VARPTR(X) ; where X is an integer variable. M(0) call 6EEF ; check for carrier detect mov m,a ; X=0 if carrier detected, ret ; FF if no carrier nop ; ENTRY M(3) - convert string to uppercase. ; calling sequence: CALL VARPTR(M(3)),0,VARPTR(A$) ; where A$ is a string variable. M(3) mov a,m ; check length of string ora a ; if zero rz ; then return mov c,a ; save length in counter C inx h ; get string address mov a,m ; that's the low byte inx h mov h,m ; that's the high byte mov l,a ; HL --> string lxi d,2 ; here comes the tricky part call 31E9 ; in ROM there is XTHL, PCHL $PC1 dad d ; now HL = loop pop d ; and DE --> string loop ldax d ; A = char from string call 0FE9 ; let ROM convert to uppercase stax d ; restore converted char inx d ; point to next char dcr c ; decrement counter rz ; done when counter = 0 pchl ; otherwise jump to loop ; ENTRY M(16) - check MDM: or COM: queue for received chars. ; calling sequence: CALL VARPTR(M(16)),0,VARPTR(X(0)) ; where X(0)..X(1) is an integer array. M(16) mvi m,0 ; set flag, X(0)=0, for no char call 6D6D ; check queue for chars rz ; return if no chars available inr m ; set flag, X(0)=1, for char received inx h inx h ; HL --> received char buffer, X(1) nop ; ENTRY M(21) - retrieve char from MDM: or COM: queue. ; if entry was made at M(16) and the queue contained a char ; then the code will fall through to this point and the ; received char will be placed in X(1). ; M(21) may also be called independently of M(16) to receive ; a char if it's already known that one is there (due to an ; ON MDM GOSUB.. interrupt for example). ; calling sequence: CALL VARPTR(M(21)),0,VARPTR(X) ; where X is an integer variable. M(21) call 6D7E ; get char from queue mov m,a ; store it ret nop ; ENTRY M(24) - timed read of 131 chars from MDM: or COM: queue. ; calling sequence: CALL VARPTR(M(24)),0,VARPTR(Z(0)) ; where Z(0)..Z(131) is an integer array. ; Z(0) is used as a flag. ; Upon return, if Z(0)=0 then a timeout occurred. ; Z(0)=1 implies successful return and in this case ; Z(1)..Z(131) will contain the 131 received characters. x1 equ 39. ; get_ch - $PC2 x2 equ 7. ; ck_que - $PC2 x3 equ 4. ; init - $PC2 M(24) mvi m,0 ; set flag for failure mov d,h mov e,l ; DE = HL --> flag call 31E9 ; xthl, pchl $PC2 mvi b,131. ; char counter push b push h ; stack now contains: ; ; address of flag ; char counter ; sp --> $PC2 init lxi h,7282. ; HL = 1 second timeout counter ck_que call 6D6D ; check queue pop b push b push b ; extra $PC2 on stack xthl ; counter on stack, HL = $PC2 lxi b,x1 ; offset to get_ch dad b xthl rnz ; jnz get_ch pop b ; clear stack dcx h ; decrement timeout counter mov a,h ora l pop b push b push b ; extra $PC2 on stack xthl ; counter on stack, HL = $PC2 lxi b,x2 ; offset to ck_que dad b xthl rnz ; jnz ck_que pop b pop b pop b pop b ret ; timeout exit get_ch call 6D7E ; get char from queue inx d inx d stax d ; store it in buffer pop h pop b dcr b ; decrement char counter push b push h ; HL = $PC2 lxi b,x3 ; offset to init dad b push h rnz ; jnz init pop h pop h pop h pop h inr m ; set flag for success ! ret ; ENTRY M(59) - delay A*2 milliseconds ; calling sequence: CALL VARPTR(M(59),A ; where A is an integer from 0 to 127. M(59) mov c,a jmp 531C --------------------------------------- Sysop Note: The current version of XMDM26 in the library (5-July-87) will work WITHOUT merging the lines with the graphic characters into the program, as instructed in the DOC file. You may also remove the statement at the end of line 67 that says you should download the DOC file. Sysop Tony 11/3/88