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 / I2CR-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  11KB  |  355 lines

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