home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol273 / i2ns-3.aqm / I2NS-3.ASM
Encoding:
Assembly Source File  |  1986-06-11  |  12.8 KB  |  455 lines

  1. ; I2NS-3.ASM - North Star Horizon w/HSIO-4 & Advantage IMP24x 10/27/85
  2. ;
  3. ;             For 8251 USART
  4. ;
  5. ; You will want to look this file over carefully. There are a number of
  6. ; options that you can use to configure the program to suit your taste.
  7. ; This file adapts the North Star Horizon w/HSIO-4 to IMP.COM.
  8. ;
  9. ; Edit this file for your preferences then follow the "TO USE:" example
  10. ; shown below.
  11. ;
  12. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  13. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  14. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  15. ; (The ESC will automatically be typed with no CTL-character present.)
  16. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  17. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  18. ; looking at the function key table, typing CTL-Z in command mode, etc.
  19. ;
  20. ; Use the "SET" command to change the baudrate when desired.  The value
  21. ; at MSPEED controls the baudrate when the program is first called up.
  22. ;
  23. ;    TO USE: First edit this file filling in answers for your own
  24. ;        equipment.  Then assemble with ASM.COM or equivalent
  25. ;        assembler.  Then use MLOAD to merge into the main file:
  26. ;
  27. ;        MLOAD IMP.COM=IMP.COM,I2NS-x.HEX
  28. ;
  29. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  30. ;
  31. ; 10/27/85 - Added equates to permit selection of Advantage configura-
  32. ;         tion for various SIO boardlets and baud rates. Easier to
  33. ;         configure both systems.    - Don Appleby
  34. ;
  35. ; 10/05/85 - Changed SPARE2 to NODTR and set it to 00
  36. ;                    - Don Appleby
  37. ;
  38. ; 08/31/85 - Added equates to permit selection of any of 4 ports on
  39. ;         HSIO-4. Seems to have problem with taking modem off hook
  40. ;         at 300 baud.        - Don Appleby
  41. ;
  42. ; 08/23/85 - I2NA-1 written to work with North Star Advantage
  43. ;                    - R. Gaspari
  44. ;
  45. ; 08/17/85 - Adapted from I2DP-1 for North Star Horizon - Don Appleby
  46. ;
  47. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  48. ;
  49. ;
  50. YES    EQU    0FFH
  51. NO    EQU    0
  52. ;
  53. HORZ    EQU    YES
  54. ADV    EQU    NO
  55. ;
  56. ;
  57. ; Values shown are for an 8251
  58. ;
  59.      IF    HORZ
  60. PORTA    EQU    12H    ; HSIO-4 Port A data port
  61. PORTB    EQU    PORTA+4    ; Port B data port
  62. PORTC    EQU    PORTB+4    ; Port C data port
  63. PORTD    EQU    PORTC+4    ; Port D data port
  64. ;
  65. PORT    EQU    PORTA    ; Select which port to use here  <--
  66. MDCTL1    EQU    PORT+1    ; Modem control port
  67. MDDATP    EQU    PORT    ; Modem data port
  68. BDPORT    EQU    PORT-2    ; HSIO-4 baud rate port
  69.      ENDIF        ; HORZ
  70. ;
  71.      IF    ADV
  72. PORT    EQU    2    ; Location of SIO board in your Advantage
  73.             ;   (card slot 1,2,3,4,5, or 6)
  74. PADDR    EQU    60H-(10H*PORT)
  75. MDDATP    EQU    PADDR    ; Modem data port
  76. MDCTL1    EQU    PADDR+1    ; Modem control port
  77. BDPORT    EQU    PADDR+8    ; Modem baud rate port
  78.      ENDIF        ; ADV
  79. ;
  80. ;
  81. MDMODE    EQU    82H    ; Insures 8251 is out of mode with DTR high
  82. MDRSET    EQU    42H    ; Resets USART for additional commands
  83. MDSET1    EQU    4EH    ; 1 stop bit, no parity, 8 bits, x16
  84. MDSET2    EQU    0CEH    ; 2 stop bits, no parity, 8 bits, x16
  85. MDCOM    EQU    37H    ; Reset error flags, RCV, DTR, TX ready
  86. ;
  87. MDRCV    EQU    02H    ; Modem receive ready
  88. MDSND    EQU    01H    ; Modem send ready bit
  89. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  90. ;
  91. ;
  92. ;-----------------------------------------------------------------------
  93. ;
  94. ESC    EQU    '['-40H    ; ^[ = Escape
  95. BELL    EQU    'G'-40H    ; ^G = Bell character
  96. LF    EQU    'J'-40H    ; ^J = Linefeed
  97. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  98. CR    EQU    'M'-40H    ; ^M = Carriage return
  99. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  100. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  101. ;
  102. ;
  103. ;-----------------------------------------------------------------------
  104. ;
  105. ;
  106.     ORG    0100H
  107. ;
  108. ;
  109.     DS    3    ; Skip the data area below            100H
  110. ;
  111. ;
  112. ; These routines and equates are at the beginning of the program so
  113. ; they can be patched by a monitor or overlay file without re-assembling
  114. ; the program.
  115. ;
  116. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  117.             ; 6=2400 7=4800 8=9600 9=19200 default
  118. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  119. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  120. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  121. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  122. RESVD1:     DB    NO    ; Reserved for special modems            108H
  123. RESVD2:     DB    NO    ; Reserved for special modems            109H
  124. ;
  125. ;
  126. CLEAR:     DB    1AH    ; Clear screen character (ESC not needed)    10AH
  127. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  128.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  129. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  130.             ;   default time to send character in ter-
  131.             ;   minal mode file transfer for slow BBS
  132. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  133.             ;   default time for extra wait after CRLF
  134.             ;   in terminal mode file transfer
  135. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  136. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  137. ;.....
  138. ;
  139. ;
  140. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  141.             ;   mode (normally added by remote echo)
  142. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  143. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  144. IGNRCTL: DB    NO    ; Yes=CTL-chars above ^M not displayed        113H
  145. ;.....
  146. ;
  147. ;
  148. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  149. EXITCHR: DB    'E'    ; Exit character                115H
  150. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  151. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  152. LOGCHR:     DB    'L'    ; Send logon                    118H
  153. LSTCHR:     DB    'P'    ; Toggle printer                119H
  154. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  155. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  156. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  157. SPARE1:     DB    0    ; For future development            11DH
  158. NODTR:     DB    NO    ; Yes if no DTR and need +++ to disconnect    11EH
  159. ;.....
  160. ;
  161. ;
  162. ; Handles in/out ports for data and status
  163. ;
  164. I$MDCTL1: IN    MDCTL1        ;                    11FH
  165.       RET            ; IN modem control port         121H
  166.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  167. ;
  168. I$MDTXE:  IN    MDCTL1        ; (Needed for SIO or DART register 1    129H
  169.       RET            ;                    12BH
  170.       DB    0,0,0,0,0,0,0    ;                    12CH
  171. ;
  172. I$MDDATP: MVI    A,37H        ;                    133H
  173.       OUT    MDCTL1        ;                    135H
  174.       IN    MDDATP        ;                    137H
  175.       RET            ;                    139H
  176.       DB    0,0,0        ; Spares if needed            13AH
  177. ;
  178. O$MDDATP: OUT    MDDATP        ;                    13DH
  179.       RET            ; OUT modem data port            13FH
  180.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  181. ;.....
  182. ;
  183. ;
  184. A$MDRCV:  ANI    MDRCV        ;                    147H
  185.       RET            ;                    149H
  186. ;
  187. C$MDRCV:  CPI    MDRCV        ;                    14AH
  188.       RET            ;                    14CH
  189. ;
  190. A$MDSND:  ANI    MDSND        ;                    14DH
  191.       RET            ;                    14FH
  192. ;
  193. C$MDSND:  CPI    MDSND        ;                    150H
  194.       RET            ;                    152H
  195. ;
  196. A$MDTXE:  ANI    MDTXE        ;                    153H
  197.       RET            ;                    155H
  198. ;
  199. C$MDTXE:  CPI    MDTXE        ;                    156H
  200.       RET            ;                    158H
  201. ;.....
  202. ;
  203. ;
  204. ; Special exit vector, used by some computers to reset interrupt vectors
  205. ;
  206. J$EXITVEC:RET            ;                    159H
  207.       DB    0,0        ;                    15AH
  208. ;.....
  209. ;
  210. ;
  211. ; Jump vectors needed by each overlay
  212. ;
  213. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  214. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  215. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  216. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  217. ;.....
  218. ;
  219. ;
  220. ; "AT" command strings, can be replaced in individual overlay if needed
  221. ;
  222. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  223. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  224. ;
  225. ;
  226. ; Next fourteen lines should not be changed by user overlay as these go
  227. ; to specific locations in the main program, not in the overlay.
  228. ;
  229. ;
  230. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  231. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  232. J$DIAL:      DS    3        ; Start of dialing routine        174H
  233. J$DSCONT: DS    3        ; Terminates modem use            177H
  234. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  235. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  236. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  237. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  238. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  239. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  240. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  241. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  242. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  243. J$NEW1:      DB    0,0,0        ; For future needs            195H
  244. J$NEW2:      DB    0,0,0        ; For future needs            198H
  245. ;.....
  246. ;
  247. ;
  248. ; For 2400 bps auto-stepdown units
  249. ;
  250. MANUAL:    DB    0        ; For manual selection flag        19BH
  251. J$300:    JMP    OK300        ; Sets baudrate to 300 baud        19CH
  252. J$1200:    JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  253. J$2400:    JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  254. ;.....
  255. ;
  256. ;
  257. LOGPTR:    DW    LOGON        ; Pointer to display LOGON message    1A5H
  258. ;
  259. SYSVR:    CALL    J$ILPRT        ; Display the following line        1A7H
  260.     DB    'Version for North Star '          ;        1AAH
  261. ;
  262.      IF    HORZ
  263.     DB    'Horizon HSIO-4 Port ',((PORT-15)/4)+65,' '
  264.      ENDIF            ;HORZ
  265. ;
  266.      IF    ADV
  267.     DB    'Advantage - Slot ',PORT+30H,' '
  268.      ENDIF            ;ADV
  269. ;
  270.     DB    CR,LF,0
  271.     RET
  272. ;.....
  273. ;
  274. ;
  275. ;-----------------------------------------------------------------------
  276. ;
  277. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  278. ;     end of your last routine should terminate by 0400H (601 bytes
  279. ;     available after start of SYSVER).
  280. ;
  281. ;
  282. ;-----------------------------------------------------------------------
  283. ;
  284. ; You can put in a message at this location which can be called up with
  285. ; (special character-L).  You can put in several lines.  End with a 0.
  286. ;
  287. LOGON:    DB    'This is a North Star computer...',CR,LF,0
  288. ;
  289. ;
  290. ;-----------------------------------------------------------------------
  291. ;
  292. ;
  293. ; This routine sets DTR low for 300 ms to disconnect the phone
  294. ;
  295. GOODBYE:
  296.     MVI    B,'S'-40H    ; X-off to stop host if needed
  297.     CALL    J$SNDCHR
  298.     MVI    B,1        ; Wait a moment to let it react
  299.     CALL    J$TIMER
  300.     MVI    A,3DH        ; Send break, turn off DTR
  301.     OUT    MDCTL1        ; Send to status port
  302.     MVI    B,3        ; Delay 300 ms to hang up phone
  303.     CALL    J$TIMER
  304.     MVI    A,37H        ; Normal send/receive with DTR
  305.     OUT    MDCTL1        ; Send to status port
  306.     RET
  307. ;.....
  308. ;
  309. ;
  310. ; Sets 8251 to 8 bits, DTR, RCV and TX ready
  311. ;
  312.      IF    HORZ
  313. INITMOD:MVI    A,MDMODE    ; Insure 8251 is out of mode
  314.     OUT    MDCTL1
  315.     XTHL            ; Small delay to complete command
  316.     XTHL
  317.     MVI    A,MDRSET    ; Reset the 8251 for new command
  318.     OUT    MDCTL1
  319.     XTHL            ; Small delay to complete command
  320.     XTHL
  321.     MVI    A,MDSET1    ; Set stop pulse, no parity 8 bits, x16
  322.     OUT    MDCTL1
  323.     XTHL            ; Small delay to complete command
  324.     XTHL
  325.     MVI    A,MDCOM        ; Error reset, RCV, DTR, TX ready
  326.     OUT    MDCTL1
  327.     XTHL            ; Small delay to complete command
  328.     XTHL
  329.      ENDIF            ; HORZ
  330. ;
  331. ;
  332. ; 8251 initializaion, sets to 8 bits, DTR, RCV and TX ready, etc.
  333. ;
  334.      IF    ADV
  335. INITMOD:IN    MDCTL1        ; Clear control port of any garbage
  336.     XTHL
  337.     XTHL
  338.     XRA    A        ; Set A to zero
  339.     OUT    MDCTL1        ; STEP 1  -  RESET
  340.     XTHL            ; ...reset the 8251 USART chip
  341.     XTHL
  342.     OUT    MDCTL1        ; ...using the 0,0,0,40 technique
  343.     XTHL
  344.     XTHL
  345.     OUT    MDCTL1
  346.     XTHL
  347.     XTHL
  348.     MVI    A,MDRSET
  349.     OUT    MDCTL1
  350.     XTHL            ; Step 2 - mode
  351.     XTHL
  352.     MVI    A,MDSET1    ; Mode is asynch, 16X, 1 stop bit,
  353.     OUT    MDCTL1        ;   ...8 data bits, no parity
  354.     XTHL
  355.     XTHL
  356.      ENDIF            ; ADV
  357. ;
  358.     LDA    MSPEED        ; Get the selected value
  359.     CPI    1        ; 300 bps
  360.     JZ    OK300
  361.     CPI    5        ; 1200 bps
  362.     JZ    OK1200
  363.     CPI    6        ; 2400 bps
  364.     JZ    OK2400
  365.     CPI    8        ; 9600 bps
  366.     JZ    OK9600
  367.     JMP    STUPR1        ; Else ask what is wanted
  368. ;.....
  369. ;
  370. ;
  371. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  372.     JNC    STUPR2
  373. ;
  374. STUPR1:    CALL    J$ILPRT
  375.     DB    'Input Baud Rate (300, 1200, 2400, 9600, 19200): ',0
  376.     LXI    D,BAUDBUF    ; Point to new input buffer
  377.     CALL    J$INBUF
  378.     CALL    J$CRLF
  379.     LXI    D,BAUDBUF+2
  380. ;
  381. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  382.     DB    '300',0
  383.     JNC    OK300        ; Go if got match
  384.     CALL    J$INLNCP
  385.     DB    '1200',0
  386.     JNC    OK1200
  387.     CALL    J$INLNCP
  388.     DB    '2400',0
  389.     JNC    OK2400
  390.     CALL    J$INLNCP
  391.     DB    '9600',0
  392.     JNC    OK9600
  393.     CALL    J$INLNCP
  394.     DB    '19200',0
  395.     JNC    OK19200
  396.     CALL    J$ILPRT        ; All matches failed, tell operator
  397.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  398.     JMP    STUPR1        ; Try again
  399. ;
  400. OK300:    MVI    A,1        ; MSPEED 300 baud value
  401.     MVI    B,BD300        ; Get 300 baud parameters in 'HL'
  402.     JMP    LOADBD        ; Go load them
  403. ;
  404. OK1200:    MVI    A,5
  405.     MVI    B,BD1200
  406.     JMP    LOADBD
  407. ;
  408. OK2400:    XRA    A
  409.     STA    MANUAL        ; Reset to maximum auto-speed
  410.     MVI    A,6
  411.     MVI    B,BD2400
  412.     JMP    LOADBD
  413. ;
  414. OK9600:    MVI    A,8
  415.     MVI    B,BD9600
  416.     JMP    LOADBD
  417. ;
  418. OK19200:MVI    A,8
  419.     MVI    B,BD19200
  420. ;
  421. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  422.     MOV    A,B
  423.     OUT    BDPORT        ; Give to baudrate port
  424.     RET
  425. ;.....
  426. ;
  427. ;
  428. ; Table of baudrate parameters
  429. ;
  430.      IF    HORZ
  431. BD300    EQU    6        ; 300  baud
  432. BD1200    EQU    4        ; 1200
  433. BD2400    EQU    3        ; 2400
  434. BD9600    EQU    1        ; 9600
  435. BD19200    EQU    0        ; 19200
  436.      ENDIF            ; HORZ
  437. ;
  438.      IF    ADV
  439. BD300    EQU    40H        ; N* Advantage code for 300 baud
  440. BD1200    EQU    70H        ; 1200
  441. BD2400    EQU    78H        ; 2400
  442. BD9600    EQU    7EH        ; 9600
  443. BD19200    EQU    7FH        ; 19200
  444.      ENDIF            ; ADV
  445. ;
  446. BAUDBUF:DB    10,0,0,0,0,0
  447.     DB    0,0,0,0,0,0
  448. ;.....
  449. ;
  450. ;
  451. ;-----------------------------------------------------------------------
  452. ; NOTE: Must terminate by 0400H
  453. ;
  454.     END
  455.