home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MODEMS / MODEM7 / M7R3-1.AQM / M7R3-1.ASM
Assembly Source File  |  2000-06-30  |  12KB  |  392 lines

  1. ; M7R3-1.ASM -- TRS-80 Model III w/Omikron Mapper overlay for MDM7xx
  2. ;  includes options for Lynx autodial modem and standard RS-232 board
  3. ; (should also work with Model 4 and CP/M 2.2)
  4. ; 01/15/84
  5. ;
  6. ; You will want to look this file over carefully. There are a number of
  7. ; options that you can use to configure the program to suit your taste.
  8. ; This file adapts the TRS-80 (Zero ORG CP/M) computer to the modem pro-
  9. ; gram.  Much of  the information contained here is not in the MDM7xx.ASM
  10. ; file. Set the Lynx options switch to NO to run with the RS-232 board.
  11. ;
  12. ; Edit this file for your preferences then follow the "TO USE:" example
  13. ; shown below.
  14. ;
  15. ; With the Lynx, the "SET" command will force the modem to go
  16. ; on-line, but cannot change the fixed baud rate of 300. With RS-232,
  17. ; use the "SET" command to change the baudrate when desired.  It starts
  18. ; out at 300 baud when the program is first called up.
  19. ;
  20. ;    TO USE: First edit this file filling in answers for your own
  21. ;        equipment.  Then assemble with ASM.COM or equivalent
  22. ;        assembler.  Then use DDT to overlay the the results
  23. ;        of this program to the original .COM file:
  24. ;
  25. ;        A>DDT MDM7xx.COM
  26. ;        DDT VERS 2.2
  27. ;        NEXT  PC
  28. ;        4580 0100
  29. ;        -IM7R3-1.HEX        (note the "I" command)
  30. ;        -R            ("R" loads in the .HEX file)
  31. ;        NEXT  PC
  32. ;        4580 0000
  33. ;        -G0            (return to CP/M)
  34. ;        A>SAVE 69 MODEM7.COM    (now have a modified .COM file)
  35. ;
  36. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  37. ;
  38. ; 01/15/84 - Revised for Model 3 and Lynx modem - Gary Phillips
  39. ; 11/11/83 - Renamed to M7R1-1.ASM, no changes    - Irv Hoff
  40. ; 08/27/83 - Revised to work with MDM712    - Irv Hoff
  41. ; 07/25/83 - Adapted for TRS-80 (zero ORG CP/M)    - Phil Becker
  42. ; 06/22/83 - Revised to work with MDM710    - Irv Hoff
  43. ; 05/27/83 - Updated to work with MDM709    - Irv Hoff
  44. ; 05/15/83 - Revised to work with MDM708    - Irv Hoff
  45. ; 04/11/83 - Updated to work with MDM707    - Irv Hoff
  46. ; 04/04/83 - First version of this file        - Irv Hoff
  47. ;
  48. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  49. ;
  50. BELL:        EQU    07H        ;bell
  51. CR:        EQU    0DH        ;carriage return
  52. ESC:        EQU    1BH        ;escape
  53. LF:        EQU    0AH        ;linefeed
  54. ;
  55. YES:        EQU    0FFH
  56. NO:        EQU    0
  57. ;
  58. ;
  59. ; Change the following information to match your equipment
  60. ;
  61. ;PORT should be set to the base port address for either the Lynx or RS-232
  62. PORT:        EQU    0E8H
  63. MODCTL1:    EQU    PORT+2        ;MODEM CONTROL PORT
  64. MODDATP:    EQU    PORT+3        ;MODEM DATA IN PORT
  65. MODDCDB:    EQU    20H        ;CARRIER DETECT BIT
  66. BAUDRP:        EQU    PORT+1        ;BAUD RATE PORT
  67. MODCTL2:    EQU    PORT+2        ;2ND MODEM CONTROL PORT
  68. MODRCVB:    EQU    80H        ;BIT TO TEST FOR RECEIVE
  69. MODRCVR:    EQU    80H        ;VALUE WHEN READY
  70. MODSNDB:    EQU    40H        ;BIT TO TEST FOR SEND
  71. MODSNDR:    EQU    40H        ;VALUE WHEN READY
  72. ;
  73.         ORG    100H
  74. ;
  75. ;
  76. ; Change the clock speed to suit your system
  77. ;
  78.         DS    3    ;(for  "JMP   START" instruction)
  79. LYNX:        EQU    YES    ;yes if Lynx in use
  80. PMMIMODEM:    DB    LYNX    ;yes=PMMI S-100 Modem            103H
  81. SMARTMODEM:    DB    NO    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  82. TOUCHPULSE:    DB    'P'    ;T=touch, P=pulse (Smartmodem-only)    105H
  83. CLOCK:        DB    21    ;clock speed in MHz x10, 25.5 MHz max.    106H
  84.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  85. MSPEED:        DB    1    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  86.                 ;6=2400 7=4800 8=9600 9=19200 default
  87. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  88.                 ;default time to send character in ter-
  89.                 ;minal mode file transfer for slow BBS.
  90. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  91.                 ;default time for extra wait after CRLF
  92.                 ;in terminal mode file transfer
  93. NOOFCOL:    DB    4    ;number of DIR columns shown        10AH
  94. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  95. SCRNTEST:    DB    YES    ;Cursor control routine         10CH
  96.         DS    1    ;reserved (old ACKNAK flag)        10DH
  97. BAKUPBYTE:    DB    NO    ;yes=change any file same name to .BAK    10EH
  98. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  99. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  100. CONVBKSP:    DB    NO    ;yes=convert backspace to rub        111H
  101. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  102. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  103.                 ;terminal mode (added by remote echo)
  104. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  105. TRANLOGON:    DB    YES    ;yes=allow transmission of logon    115H
  106.                 ;write logon sequence at location LOGON
  107. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  108. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  109.                 ;no=external command if EXTCHR precedes
  110. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  111. LSTTST:        DB    YES    ;yes=allow toggling of printer on/off    119H
  112. XOFFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  113.                 ;sending a file in terminal mode
  114. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  115.                 ;sending a file in terminal mode
  116. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  117. IGNORCTL:    DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  118. EXTRA1:        DB    0    ;for future expansion            11EH
  119. EXTRA2:        DB    0    ;for future expansion            11FH
  120. BRKCHR:        DB    'K'-40H    ;^K = Send 300 ms. break tone        120H
  121. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  122. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  123. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  124. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  125. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  126. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  127. ;    note that ESC is SHIFT-BREAK under Omikron CP/M
  128. EXTCHR:        DB    ESC    ;ESC = Send next character        127H
  129. ;
  130. ;
  131. ;    a value of 55 gives a pulse rate of about 20/sec.
  132. ;    a higher value will slow the dialing down for older
  133. ;    phone systems.
  134. PULSERATE:    DB    55    ;pulse rate for dialing
  135. CHGBAUD:    DB    'B'-40H    ;will force Lynx on-line
  136.                 ;from terminal mode
  137. IN$MODCTL1:    IN    MODCTL1     ;in modem control port        12AH
  138.         PUSH    B
  139.         ANI    0DFH
  140.         MOV    B,A        ;save status
  141.         JMP    CTLPT2        ;continue
  142.         DS    1
  143. ;
  144. OUT$MODDATP:    OUT    MODDATP ! RET    ;out modem data port        134H
  145. ;
  146. ;
  147. ; CONTINUE STATUS READ
  148. ;
  149. CTLPT2:        IN    PORT        ;READ CD PORT
  150.         ANI    MODDCDB        ;ISOLATE CD
  151.         ORA    B        ;MERGE STATUS
  152.         POP    B
  153.         RET
  154. ;
  155. IN$MODDATP:    IN    MODDATP ! RET    ;in modem data port        13EH
  156.         DS    7
  157. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to test for receive ready    148H
  158. CPI$MODRCVR:    CPI    MODRCVR    ! RET    ;value of rcv. bit when ready    14BH
  159. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to test for send ready    14EH
  160. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when ready    151H
  161.     IF    LYNX
  162. IN$BAUDRP:    JMP    DTIMER        ;simulate PMMI timer
  163. OUT$BAUDRP:    RET ! NOP ! NOP        ;don't need this one
  164. OUT$MODCTL1:    JMP    DIALHOOK    ;dial port
  165.     ENDIF
  166.     IF    NOT LYNX
  167.         DS    6
  168. OUT$MODCTL1:    OUT    MODCTL1 ! RET    ;out modem control port #1    15AH
  169.     ENDIF
  170. OUT$MODCTL2:    RET ! NOP ! NOP        ;don't need this one        15DH
  171. ;
  172. LOGONPTR:    DW    LOGON        ;for user message.        160H
  173. JMP$DIAL:    DS    3        ;autodial rtn jump            162H
  174. JMP$DISCONNT:    JMP    GOODBYE        ;disconnect rtn
  175. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  176. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  177. JMP$NEWBAUD:    JMP    SETUPR        ;force Lynx on-line            16EH
  178. JMP$NOPARITY:    RET ! NOP ! NOP        ;(by-pass PMMI routine)        171H
  179. JMP$PARITY:    RET ! NOP ! NOP        ;(by-pass PMMI routine)        174H
  180. JMP$SETUPR:    JMP    SETUPR        ;                177H
  181. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  182. JMP$SYSVER:    JMP    SYSVER        ;                17DH
  183. JMP$BREAK:    JMP    SENDBRK        ;                180H
  184. ; Do not change the following six lines.
  185. JMP$ILPRT:    DS    3        ;                183H
  186. JMP$INBUF:    DS    3        ;                186H
  187. JMP$INLNCOMP:    DS    3        ;                189H
  188. JMP$INMODEM:    DS    3        ;                18CH
  189. JMP$NXTSCRN:    DS    3        ;                18FH
  190. JMP$TIMER:    DS    3        ;                192H
  191. ;
  192. ;
  193. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  194. ; SCRNTEST to YES at 010AH (above).
  195. ;
  196. CLREOS:        CALL    JMP$ILPRT    ;                195H
  197.         DB    1FH,0,0,0,0    ;                198H
  198.         RET            ;                19DH
  199. ;
  200. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  201.         DB    1CH,1FH,0,0,0    ;                1A1H
  202.         RET            ;                1A6H
  203.     
  204. ;
  205. SYSVER:        CALL    JMP$ILPRT    ;                1A7H
  206.         DB    'TRS-80 Model III W/Omikron Mapper',CR,LF
  207.     IF    LYNX
  208.         DB    'Lynx autodial modem',CR,LF
  209.     ENDIF
  210.         DB    0        ;end msg
  211.         RET
  212. ;.....
  213. ;
  214. ;
  215. ;-----------------------------------------------------------------------
  216. ;
  217. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  218. ;     end of your last routine should terminate by 0400H (601 bytes
  219. ;     available after start of SYSVER) if using the Hayes Smartmodem
  220. ;     or by address 0C00H (2659 bytes) otherwise.
  221. ;
  222. ;-----------------------------------------------------------------------
  223. ;
  224. ; You can put in a message at this location which can be called up with
  225. ; CTL-L if TRANLOGON has been set TRUE.  You can use several lines if
  226. ; desired.  End with a 0.
  227. ;
  228. LOGON:        DB    'This is a TRS-80 using CP/M',CR,LF,0
  229. ;.....
  230. ;
  231. ;
  232. ; Add your own routine here to send a break tone to reset some time-share
  233. ; computers, if desired.
  234. ;
  235. SENDBRK:    MVI    A,0E3H        ;send break
  236.         JMP    GBYE1
  237. ;
  238. ; Add your own routine here to put DTR low and/or send a break tone.
  239. ; Check other routines such as MDM709DP.ASM which is using this feature.
  240. ;
  241.     IF    LYNX
  242. GOODBYE:
  243.         XRA    A    ;disconnect phone line
  244.         OUT    BAUDRP
  245.         RET
  246.     ENDIF
  247.     IF    NOT LYNX
  248. GOODBYE:    MVI    A,0EBH    ;DTR off, send BRK
  249.     ENDIF
  250. GBYE1:      OUT    MODCTL1        ;SEND CMD
  251.       MVI    B,3
  252.       CALL    JMP$TIMER    ;DELAY 300 MS
  253.       MVI    A,0ECH        ;NORMAL DTR ON
  254.       OUT    MODCTL1
  255.       RET
  256. ;.....
  257. ;
  258. ;
  259. ; You can use this area for any special initialization or setup you may
  260. ; wish to include.  Each must stop with a RET.    You can check the other
  261. ; available overlays for ideas how to write your own routines if that
  262. ; may be of some help.
  263. ;
  264. INITMOD:  MVI    A,1
  265.       OUT    PORT        ;RESET RS232
  266.       MVI    A,0ECH        ;8/N/1 DTR & RTS ON
  267.       OUT    MODCTL1
  268. ;
  269. INITM1:      MVI    A,1        ;SET FILE XFER TIME
  270.       STA    MSPEED
  271. ;
  272.     IF    NOT LYNX
  273. INITM2:      MVI    A,55H        ;INIT TO 300 BAUD
  274.       OUT    BAUDRP
  275.     ENDIF
  276.       RET
  277. ;
  278. ;.....
  279. ;
  280. ;  SETS THE MODEM SPEED VIA THE SET COMMAND.
  281. ;
  282.     IF    NOT LYNX
  283. SETUPR:      LXI    D,BAUDBUF    ;POINT TO INPUT BUFFER
  284.       CALL    JMP$ILPRT
  285.       DB    'INPUT BAUD RATE (300, 1200, 2400, 4800): ',0
  286.       CALL    JMP$INBUF
  287.       LXI    D,BAUDBUF+2
  288.       CALL    JMP$INLNCOMP    ;TEST INPUT PARAM
  289.       DB    '300',0
  290.       JNC    OK300
  291.       CALL    JMP$INLNCOMP
  292.       DB    '1200',0
  293.       JNC    OK1200
  294.       CALL    JMP$INLNCOMP
  295.       DB    '2400',0
  296.       JNC    OK2400
  297.       CALL    JMP$INLNCOMP
  298.       DB    '4800',0
  299.       JNC    OK4800
  300.       CALL    JMP$ILPRT    ;BAD PARAM
  301.       DB    '++ INCORRECT ENTRY ++',CR,LF,0
  302.       JMP    SETUPR        ;TRY AGAIN
  303. ;
  304. OK300:      MVI    A,1
  305.       LHLD    BD300
  306.       JMP    LOADBD
  307. ;
  308. OK1200:      MVI    A,5
  309.       LHLD    BD1200
  310.       JMP    LOADBD
  311. ;
  312. OK2400:      MVI    A,6
  313.       LHLD    BD2400
  314.       JMP    LOADBD
  315. ;
  316. OK4800:      MVI    A,7
  317.       LHLD    BD4800
  318. ;
  319. LOADBD:      STA    INITM1+1    ;CHANGE MSPEED PARAM
  320.       MOV    A,L        ;GET BRG BYTE
  321.       STA    INITM2+1    ;SET IT IN
  322.       JMP    INITM1        ;REINIT BAUD RATE AND RET
  323. ;.....
  324. ;
  325. ;
  326. ; TABLE OF BAUD RATE PARAMS
  327. ;
  328. BD300:      DW    0055H
  329. BD1200:      DW    0077H
  330. BD2400:      DW    00AAH
  331. BD4800:      DW    00CCH
  332. ;
  333. BAUDBUF:  DB    10,0
  334.       DS    10
  335.     ENDIF
  336. ;.....
  337.     IF    LYNX
  338. SETUPR:    MVI    A,02H    ;code to go on-line
  339.     OUT    BAUDRP
  340.     RET
  341. ;
  342. DIALHOOK:        ;flip dial hook
  343.     ORA    A    ;if A=0 put on hook
  344.     JZ    DIALH2
  345.     MVI    A,02H    ;else take off hook
  346. DIALH2:    OUT    BAUDRP
  347.     RET
  348. ;
  349. DTIMER:        ;simulate PMMI timer function
  350.     DB    0D9H    ;Z-80 EXX instruction
  351.     LDA    PULSERATE    ;msec between flips
  352.     MOV    B,A    ;put in counter
  353. DTIMER0:
  354.     MVI    C,126    ;delay for 1 msec @ 2MHz
  355. DTIMER1:
  356.     DCR    C
  357.     JNZ    DTIMER1
  358.     DCR    B
  359.     JNZ    DTIMER0
  360.     LDA    DCNT    ;check last value passed
  361.     ANI    80H    ;was bit 7 set?
  362.     JNZ    DTIMER2
  363.     ORI    80H    ;zero last time, set this
  364.     JMP    DTIMER3
  365. DTIMER2:
  366.     XRA    A
  367. DTIMER3:
  368.     MOV    B,A    ;save value
  369.     IN    PORT    ;check carrier detect value
  370.     ANI    MODDCDB
  371.     JZ    DTIMER4
  372.     MVI    A,04H    ;set PMMI carrier detect flag
  373. DTIMER4:
  374.     ORA    B    ;add timer bit value
  375.     DB    0D9H    ;EXX to restore regs
  376.     STA    DCNT
  377.     RET        ;return with flags
  378. DCNT    DB    0
  379.     ENDIF
  380. ;
  381. ; If using Smartmodem or Lynx this is unavailable without a special
  382. ; change.
  383. ;
  384. SPCLMENU:  RET
  385. ;
  386. ;
  387. ; NOTE:  MUST TERMINATE PRIOR TO 0400H (with Smartmodem or Lynx)
  388. ;                 0C00H (without Smartmodem)
  389. ;.....
  390. ;
  391.       END
  392.