home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol273 / i2rs-1.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  10.8 KB  |  367 lines

  1. ; I2TRS-1.ASM - IMP overlay for various TRS-80 computers - 01/18/86
  2. ;
  3. ;     Using TR1865 UART and BR1943 Baudrate generator (or similar)
  4. ;
  5. ;         This overlay for the following models:
  6. ;
  7. ;            TRS-80 Model IV
  8. ;            TRS-80 Model 4P/4D
  9. ;            TRS-80 Model III
  10. ;            LNW-80
  11. ;
  12. ;         NOTE:    If using CP/M 3.0 (sometimes
  13. ;            called CP/M+), your terminal
  14. ;            may need a 45h at CLEAR: in-
  15. ;            stead of 1Ah for clear screen.
  16. ;
  17. ; You will want to look this file over carefully.  There are a number of
  18. ; options that you can use to configure the program to suit your taste.
  19. ; This file adapts the above computers to IMP2xx.COM.
  20. ;
  21. ; Edit this file for your preferences then follow the "TO USE:" example
  22. ; shown below.
  23. ;
  24. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  25. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  26. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  27. ; (The ESC will automatically be typed with no CTL-character present.)
  28. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP2
  29. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  30. ; looking at the function key table, typing CTL-Z in command mode, etc.
  31. ;
  32. ; Use the "SET" command to change the baudrate when desired.  The value
  33. ; at MSPEED controls the baudrate when the program is first called up.
  34. ;
  35. ;    TO USE: First edit this file filling in answers for your own
  36. ;        equipment.  Then assemble with ASM.COM or equivalent
  37. ;        assembler.  Then use MLOAD to merge into the main file:
  38. ;
  39. ;        MLOAD IMP.COM=IMP2xx.COM,I2R4-x.HEX
  40. ;
  41. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  42. ;
  43. ; 01/18/86  Added equate for 7,E,1 support.  (7 bits, even parity, one
  44. ;        stop bit.)            - Tom Brady Decibel RCPM
  45. ; 09/01/85  Added CP/M 3.0 note     - Dave Lane
  46. ; 07/17/85  Written to work with IMP    - Irv Hoff
  47. ;
  48. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  49. ;
  50. ;
  51. YES    EQU    0FFH
  52. NO    EQU    0
  53. ;
  54. ;
  55. ; Optional equate - set to suit your system requirements
  56. ;
  57. SET8N    EQU    YES    ; Yes = 8,N,1 (standard)  No = 7,E,1
  58. ;
  59. ;
  60. ; Values shown are for the TR1865 or similar
  61. ;
  62. PORT    EQU    0EBH
  63. MDCTL1    EQU    PORT-1    ; Modem control port
  64. MDCTL2    EQU    PORT-2    ; Modem baudrate port
  65. MDCTL3    EQU    PORT-3    ; Modem reset port
  66. MDDATP    EQU    PORT    ; Modem data port
  67. MDRCV    EQU    80H    ; Modem receive ready
  68. MDSND    EQU    40H    ; Modem send ready bit
  69. MDTXE    EQU    40H    ; Modem send buffer empty, holding buffer empty
  70. ;
  71. ;
  72. ;-----------------------------------------------------------------------
  73. ;
  74. ESC    EQU    '['-40H    ; ^[ = Escape
  75. BELL    EQU    'G'-40H    ; ^G = Bell character
  76. LF    EQU    'J'-40H    ; ^J = Linefeed
  77. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  78. CR    EQU    'M'-40H    ; ^M = Carriage return
  79. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  80. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  81. ;
  82. ;
  83. ;-----------------------------------------------------------------------
  84. ;
  85. ;
  86.     ORG    0100H
  87. ;
  88. ;
  89.     DS    3    ; Skip the data area below
  90. ;
  91. ;
  92. ; These routines and equates are at the beginning of the program so
  93. ; they can be patched by a monitor or overlay file without re-assembling
  94. ; the program.
  95. ;
  96. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  97.             ; 6=2400 7=4800 8=9600 9=19200 default
  98. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  99. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  100. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  101. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  102. RESVD1:     DB    NO    ; Reserved for special modems            108H
  103. RESVD2:     DB    NO    ; Reserved for special modems            109H
  104. ;
  105. ;
  106. CLEAR:     DB    1AH    ; Clear screen character (ESC not needed)    10AH
  107. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  108.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  109. BYTDLY:     DB    6    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  110.             ;   default time to send character in ter-
  111.             ;   minal mode file transfer for slow BBS
  112. CRDLY:     DB    6    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  113.             ;   default time for extra wait after CRLF
  114.             ;   in terminal mode file transfer
  115. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  116. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  117. ;.....
  118. ;
  119. ;
  120. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  121.             ;   mode (normally added by remote echo)
  122. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  123. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  124. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  125. ;.....
  126. ;
  127. ;
  128. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  129. EXITCHR: DB    'E'    ; Exit character                115H
  130. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  131. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  132. LOGCHR:     DB    'L'    ; Send logon                    118H
  133. LSTCHR:     DB    'P'    ; Toggle printer                119H
  134. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  135. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  136. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  137. SPARE1:     DB    0    ; For future development            11DH
  138. SPARE2:     DB    0    ; For future development            11EH
  139. ;.....
  140. ;
  141. ;
  142. ; Handles in/out ports for data and status
  143. ;
  144. I$MDCTL1: IN    MDCTL1        ; modem control port            11FH
  145.       RET            ;                    121H
  146.       DB    0,0,0,0,0,0,0    ;                    122H
  147. ;
  148. I$MDTXE:  IN    MDCTL1        ; modem control port            129H
  149.       RET            ;                    12BH
  150.       DB    0,0,0,0,0,0,0    ;                    12CH
  151. ;
  152. I$MDDATP: IN    MDDATP        ;                    133H
  153.       RET            ;                    135H
  154.       DB    0,0,0,0,0,0,0    ;                    136H
  155. ;
  156. O$MDDATP: OUT    MDDATP        ;                    13DH
  157.       RET            ;                    13FH
  158.       DB    0,0,0,0,0,0,0    ;                    140H
  159. ;.....
  160. ;
  161. ;
  162. A$MDRCV:  ANI    MDRCV        ;                    147H
  163.       RET            ;                    149H
  164. ;
  165. C$MDRCV:  CPI    MDRCV        ;                    14AH
  166.       RET            ;                    14CH
  167. ;
  168. A$MDSND:  ANI    MDSND        ;                    14DH
  169.       RET            ;                    14FH
  170. ;
  171. C$MDSND:  CPI    MDSND        ;                    150H
  172.       RET            ;                    152H
  173. ;
  174. A$MDTXE:  ANI    MDTXE        ;                    153H
  175.       RET            ;                    155H
  176. ;
  177. C$MDTXE:  CPI    MDTXE        ;                    156H
  178.       RET            ;                    158H
  179. ;.....
  180. ;
  181. ;
  182. ; Special exit vector, used by some computers to reset interrupt vectors
  183. ;
  184. J$EXITVEC:RET            ;                    159H
  185.       DB    0,0        ;                    15AH
  186. ;.....
  187. ;
  188. ;
  189. ; Jump vectors needed by each overlay
  190. ;
  191. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  192. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  193. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  194. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  195. ;.....
  196. ;
  197. ;
  198. ; "AT" command strings, can be replaced in individual overlay if needed
  199. ;
  200. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  201. J$STRNG1: DS    3        ; 2400 bps "AT" string            16B:IMP
  202. ;
  203. ;
  204. ; Next fourteen lines should not be changed by user overlay as these go
  205. ; to specific locations in the main program, not in the overlay.
  206. ;
  207. ;
  208. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  209. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  210. J$DIAL:      DS    3        ; Start of dialing routine        174H
  211. J$DSCONT: DS    3        ; Terminates modem use            177H
  212. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  213. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  214. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  215. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  216. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  217. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  218. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  219. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  220. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  221. J$NEW1:      DB    0,0,0        ; For future needs            195H
  222. J$NEW2:      DB    0,0,0        ; For future needs            198H
  223. ;.....
  224. ;
  225. ;
  226. ; For 2400 bps auto-stepdown units
  227. ;
  228. MANUAL:      DB    0        ; For manual selection flag        19BH
  229. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  230. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  231. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  232. ;.....
  233. ;
  234. ;
  235. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  236. ;
  237. ;-----------------------------------------------------------------------
  238. ;
  239. ; NOTE:  You can change the SYSVR message to be longer or shorter.  The
  240. ;     end of your last routine should terminate by 0400H (601 bytes
  241. ;     available after start of SYSVR).
  242. ;
  243. ;-----------------------------------------------------------------------
  244. ;
  245. SYSVR:      CALL    J$ILPRT            ; Display the following line    1A7H
  246.       DB    'TRS-80 Model IV using port with 0EBH '    ;        1AAH
  247.       DB    CR,LF,0
  248.       RET
  249. ;.....
  250. ;
  251. ;
  252. ; You can put in a message at this location which can be called up with
  253. ; (special character-L).  You can put in several lines.  End with a 0.
  254. ;
  255. LOGON:      DB    'Hello from a fellow computer user... ',CR,LF,0
  256. ;
  257. ;-----------------------------------------------------------------------
  258. ;
  259. ; This routine sets DTR low for 1 second to disconnect the phone
  260. ;
  261. GOODBYE:
  262.     MVI    B,'S'-40H    ; X-off to stop host if needed
  263.     CALL    J$SNDCHR
  264.     MVI    B,1        ; Wait a moment to let it react
  265.     CALL    J$TIMER
  266.     MVI    A,0EBH        ; Send break, turn off DTR
  267.     OUT    MDCTL1        ; Send to status port
  268.     MVI    B,10        ; Delay 1 second
  269.     CALL    J$TIMER
  270.     MVI    A,0ECH        ; Normal send/receive with DTR
  271.     OUT    MDCTL1        ; Send to status port
  272.     RET
  273. ;.....
  274. ;
  275. ;
  276. ; Initialization, also sets baudrate to that requested.
  277. ;
  278. INITMOD:
  279.     LDA    MSPEED        ; Get the selected value
  280.     CPI    1        ; 300 bps
  281.     JZ    OK300
  282.     CPI    5        ; 1200 bps
  283.     JZ    OK1200
  284.     CPI    6        ; 2400 bps
  285.     JZ    OK2400
  286.     CPI    8        ; 9600 bps
  287.     JZ    OK9600
  288.     JMP    STUPR1        ; Else ask what is wanted
  289. ;.....
  290. ;
  291. ;
  292. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  293.     JNC    STUPR2
  294. ;
  295. STUPR1:    CALL    J$ILPRT
  296.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  297.     LXI    D,BAUDBUF    ; Point to new input buffer
  298.     CALL    J$INBUF
  299.     CALL    J$CRLF
  300.     LXI    D,BAUDBUF+2
  301. ;
  302. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  303.     DB    '300',0
  304.     JNC    OK300        ; Go if got match
  305.     CALL    J$INLNCP
  306.     DB    '1200',0
  307.     JNC    OK1200
  308.     CALL    J$INLNCP
  309.     DB    '2400',0
  310.     JNC    OK2400
  311.     CALL    J$INLNCP
  312.     DB    '9600',0
  313.     JNC    OK9600
  314.     CALL    J$ILPRT        ; All matches failed, tell operator
  315.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  316.     JMP    STUPR1        ; Try again
  317. ;
  318. OK300:    MVI    A,1        ; MSPEED 300 baud value
  319.     MVI    B,BD300        ; Get 300 baud parameters in 'HL'
  320.     JMP    LOADBD        ; Go load them
  321. ;
  322. OK1200:    MVI    A,5
  323.     MVI    B,BD1200
  324.     JMP    LOADBD
  325. ;
  326. OK2400:    XRA    A
  327.     STA    MANUAL
  328.     MVI    A,6
  329.     MVI    B,BD2400
  330.     JMP    LOADBD
  331. ;
  332. OK9600:    MVI    A,8
  333.     MVI    B,BD9600
  334. ;
  335. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  336.     MVI    A,1        ; Reset UART and enable it
  337.     OUT    MDCTL3        ; Baudrate control port
  338.     MVI    C,0ECH        ; 8 bits, no parity, 1 stop (normal)
  339.     MVI    A,SET8N
  340.     ORA    A
  341.     JNZ    $+5        ; If yes, skip next line
  342.     MVI    C,0A4H        ; 7 bits, even parity, 1 stop
  343.     MOV    A,C        ; Put value into 'A' register
  344.     OUT    MDCTL1
  345.     MOV    A,B        ; Get baudrate byte
  346.     OUT    MDCTL2
  347.     RET
  348. ;.....
  349. ;
  350. ;
  351. ; Baudrate table
  352. ;
  353. BD300    EQU    055H        ; 300 baud
  354. BD1200    EQU    077H        ; 1200 bps
  355. BD2400    EQU    0AAH        ; 2400 bps
  356. BD9600    EQU    0EEH        ; 9600 bps
  357. ;
  358. BAUDBUF:DB    10,0,0,0,0,0
  359.     DB    0,0,0,0,0,0
  360. ;
  361. ;                   end
  362. ;-----------------------------------------------------------------------
  363. ;
  364. ; NOTE: Must terminate prior to 0400H
  365. ;
  366.     END
  367.