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 / IMP / I2R4-2.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  10KB  |  352 lines

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