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 / I2NS-6.AZM / I2NS-6.ASM
Assembly Source File  |  2000-06-30  |  14KB  |  482 lines

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