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 / I2NA-3.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  12KB  |  393 lines

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