home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol273 / i2mc-1.aqm / I2MC-1.ASM
Encoding:
Assembly Source File  |  1986-06-11  |  13.5 KB  |  501 lines

  1.  
  2. ; I2MC-1.ASM - MOLECULAR Computer Series X overlay for IMP - 10/27/85
  3. ;
  4. ;           Zilog DART and 8430 CTC timer
  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 either port of an AP8020 to the modem program.
  9. ; The software break-disable method used is now dependent of the N/STAR
  10. ; revision.
  11. ;
  12. ; The following cabling is recommended from the AP B port to the modem:
  13. ;
  14. ;        AP-Bl            MODEM
  15. ;        2 --------------------- 3
  16. ;        3 --------------------- 2
  17. ;        4 --------------------- 8
  18. ;        6 -------------------- 20
  19. ;        7 --------------------- 7
  20. ;        8 --------------------- 4
  21. ;           20 --------------------- 6
  22. ;
  23. ; Edit this file for your preferences then follow the "TO USE:" example
  24. ; shown below.
  25. ;
  26. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  27. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  28. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  29. ; (The ESC will automatically be typed with no CTL-character present.)
  30. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  31. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  32. ; looking at the function key table, typing CTL-Z in command mode, etc.
  33. ;
  34. ; Use the "SET" command to change the baudrate when desired.  The value
  35. ; at MSPEED controls the baudrate when the program is first called up.
  36. ;
  37. ;    TO USE: First edit this file filling in answers for your own
  38. ;        equipment.  Then assemble with ASM.COM or equivalent
  39. ;        assembler.  Then use MLOAD to merge the results
  40. ;        of this program to the original .COM file:
  41. ;
  42. ;        A>MLOAD IMP.COM=IMP.COM,I2MC-x.HEX
  43. ;
  44. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  45. ;
  46. ; 10/27/85 - Taken from I2CC-1.asm and M7MCX4.asm - Dave Rogers
  47. ; 07/17/85 - Written for use with IMP          - Irv Hoff
  48. ;
  49. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  50. ;
  51. ;
  52. YES    EQU    0FFH
  53. NO    EQU    0
  54. ;
  55. ;
  56. ; Operation under N/STAR 3.11 or higher is recommended but not required
  57. ;
  58. NS311    EQU    YES    ; Set to no if using 3.10 or lower
  59. BPORT    EQU    YES    ; Set to no for A-port version
  60. ;
  61. ;
  62. APORT    EQU    NOT BPORT
  63. ;
  64.      IF    BPORT
  65. PORT    EQU    062H    ; "B" port = 062H
  66. BRPORT    EQU    031H    ; "B" port = 031H
  67.      ENDIF        ; BPORT
  68. ;
  69.      IF    APORT
  70. PORT    EQU    060H    ; "A" port = 060H
  71. BRPORT    EQU    030H    ; "A" port = 030H
  72.      ENDIF        ; APORT
  73. ;
  74. ;
  75. MDCTL1    EQU    PORT+1    ; Modem control port
  76. MDDATP    EQU    PORT    ; Modem data port
  77. MDRCV    EQU    01H    ; Modem receive ready
  78. MDSND    EQU    04H    ; Modem send ready bit
  79. MDTXE    EQU    01H    ; Modem send buffer empty, holding buffer empty
  80. ;
  81. ;
  82. ESC    EQU    '['-40H    ; ^[ = Escape
  83. BELL    EQU    'G'-40H    ; ^G = Bell character
  84. LF    EQU    'J'-40H    ; ^J = Linefeed
  85. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  86. CR    EQU    'M'-40H    ; ^M = Carriage return
  87. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  88. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  89. ;
  90. ;
  91. ;-----------------------------------------------------------------------
  92. ;
  93. ;
  94.     ORG    0100H
  95. ;
  96. ;
  97.     DS    3    ; Skip the data area below
  98. ;
  99. ;
  100. ; These routines and equates are at the beginning of the program so
  101. ; they can be patched by a monitor or overlay file without re-assembling
  102. ; the program.
  103. ;
  104. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  105.             ; 6=2400 7=4800 8=9600 9=19200 default
  106. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  107. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  108. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  109. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  110. RESVD1:     DB    NO    ; Reserved for special modems            108H
  111. RESVD2:     DB    NO    ; Reserved for special modems            109H
  112. ;
  113. ;
  114. CLEAR:     DB    '*'    ; Clear screen character (ESC supplied by IMP    10AH
  115. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  116.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  117. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  118.             ;   default time to send character in ter-
  119.             ;   minal mode file transfer for slow BBS
  120. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  121.             ;   default time for extra wait after CRLF
  122.             ;   in terminal mode file transfer
  123. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  124. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  125. ;.....
  126. ;
  127. ;
  128. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  129.             ;   mode (normally added by remote echo)
  130. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  131. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  132. IGNRCTL: DB    NO    ; Yes=CTL-chars above ^M not displayed        113H
  133. ;.....
  134. ;
  135. ;
  136. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  137. EXITCHR: DB    'E'    ; Exit character                115H
  138. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  139. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  140. LOGCHR:     DB    'L'    ; Send logon                    118H
  141. LSTCHR:     DB    'P'    ; Toggle printer                119H
  142. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  143. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  144. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  145. SPARE1:     DB    0    ; For future development            11DH
  146. NODTR:     DB    NO    ; Yes if no DTR and need +++ to disconnect    11EH
  147. ;.....
  148. ;
  149. ;
  150. ; Handles in/out ports for data and status
  151. ;
  152. I$MDCTL1: MVI    A,10H        ; Register 0, reset interrupts        11FH
  153.       OUT    MDCTL1        ;                    121H
  154.       IN    MDCTL1        ;                    123H
  155.       RET            ; IN modem control port         125H
  156.       DB    0,0,0        ; Spares if needed            126H
  157. ;
  158. I$MDTXE:  MVI    A,11H        ; Read register 1 for "all sent"    129H
  159.       OUT    MDCTL1        ; Select read register 1        12BH
  160.       IN    MDCTL1        ; (Needed for SIO or DART register 1    12DH
  161.       RET            ;                    12FH
  162.       DB    0,0,0        ;                    130H
  163. ;
  164. I$MDDATP: IN    MDDATP        ;                    133H
  165.       RET            ;                    135H
  166.       DB    0,0,0,0,0,0,0    ; Spares if needed            136H
  167. ;
  168. O$MDDATP: OUT    MDDATP        ;                    13DH
  169.       RET            ; OUT modem data port            13FH
  170.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  171. ;.....
  172. ;
  173. ;
  174. A$MDRCV:  ANI    MDRCV        ;                    147H
  175.       RET            ;                    149H
  176. ;
  177. C$MDRCV:  CPI    MDRCV        ;                    14AH
  178.       RET            ;                    14CH
  179. ;
  180. A$MDSND:  ANI    MDSND        ;                    14DH
  181.       RET            ;                    14FH
  182. ;
  183. C$MDSND:  CPI    MDSND        ;                    150H
  184.       RET            ;                    152H
  185. ;
  186. A$MDTXE:  ANI    MDTXE        ;                    153H
  187.       RET            ;                    155H
  188. ;
  189. C$MDTXE:  CPI    MDTXE        ;                    156H
  190.       RET            ;                    158H
  191. ;.....
  192. ;
  193. ;
  194. ; Special exit vector, used by some computers to reset interrupt vectors
  195. ;
  196. J$EXITVEC:JMP    BRKON        ;                    159H
  197. ;;;      RET            ;                    159H
  198. ;;;      DB    0,0        ;                    15AH
  199. ;.....
  200. ;
  201. ;
  202. ; Jump vectors needed by each overlay
  203. ;
  204. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  205. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  206. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  207. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  208. ;.....
  209. ;
  210. ;
  211. ; "AT" command strings, can be replaced in individual overlay if needed
  212. ;
  213. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  214. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  215. ;
  216. ;
  217. ; Next fourteen lines should not be changed by user overlay as these go
  218. ; to specific locations in the main program, not in the overlay.
  219. ;
  220. ;
  221. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  222. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  223. J$DIAL:      DS    3        ; Start of dialing routine        174H
  224. J$DSCONT: DS    3        ; Terminates modem use            177H
  225. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  226. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  227. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  228. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  229. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  230. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  231. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  232. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  233. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  234. J$NEW1:      DB    0,0,0        ; For future needs            195H
  235. J$NEW2:      DB    0,0,0        ; For future needs            198H
  236. ;.....
  237. ;
  238. ;
  239. ; For 2400 bps auto-stepdown units
  240. ;
  241. MANUAL:      DB    0        ; For manual selection flag        19BH
  242. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  243. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  244. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  245. ;.....
  246. ;
  247. ;
  248. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  249. ;
  250. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  251.        IF    BPORT
  252.       DB    'Version for Molecular Series X B-Port';        1AAH
  253.        ENDIF        ; BPORT
  254. ;
  255.        IF    APORT
  256.       DB    'Version for Molecular Series X A-Port'    ;        1AAH
  257.        ENDIF        ; APORT
  258. ;
  259.       DB    CR,LF,0
  260.       RET
  261. ;.....
  262. ;
  263. ;
  264. ;-----------------------------------------------------------------------
  265. ;
  266. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  267. ;     end of your last routine should terminate by 0400H (601 bytes
  268. ;     available after start of SYSVER).
  269. ;
  270. ;-----------------------------------------------------------------------
  271. ;
  272. ; You can put in a message at this location which can be called up with
  273. ; (special character-L).  You can put in several lines.  End with a 0.
  274. ;
  275. LOGON:    DB    'This is a Molecular Computer...',CR,LF,0
  276. ;
  277. ;-----------------------------------------------------------------------
  278. ;
  279. ;
  280. ; This routine sets DTR low for 300 ms to disconnect the phone
  281. ;
  282. GOODBYE:
  283.     MVI    B,'S'-40H    ; X-off to stop host if needed
  284.     CALL    J$SNDCHR
  285.     MVI    B,1        ; Wait a moment to let it react
  286.     CALL    J$TIMER
  287.     MVI    A,5
  288.     OUT    MDCTL1        ; Send to the status port
  289.     MVI    A,0E8H        ; Turn off DTR
  290.     OUT    MDCTL1
  291.     MVI    B,3        ; Wait 300 ms
  292.     CALL    J$TIMER
  293.     MVI    A,5
  294.     OUT    MDCTL1
  295.     MVI    A,0EAH        ; Restore to normal, 8 bits, DTR on, etc.
  296.     OUT    MDCTL1
  297.     RET
  298. ;.....
  299. ;
  300. ;
  301. ; IMS baud rate change.  Sets CTC for baud rate.
  302. ;
  303. INITMOD:
  304.     MVI    A,0        ; Select register
  305.     OUT    MDCTL1        ; Send to the status port
  306.     MVI    A,18H        ; Reset the Z8SIO chip
  307.     OUT    MDCTL1        ; Send to the status port
  308.     MVI    A,4        ; Select register
  309.     OUT    MDCTL1        ; Send to the status port
  310.     MVI    A,44H        ; 16x, 2-stop, no parity (1=44, 2=4C)
  311.     OUT    MDCTL1        ; Send to the status port
  312.     MVI    A,3        ; Select register
  313.     OUT    MDCTL1        ; Send to the status port
  314.     MVI    A,0C1H        ; Enable receive section
  315.     OUT    MDCTL1        ; Send to the status port
  316.     MVI    A,5        ; Select register
  317.     OUT    MDCTL1        ; Send to the status port
  318.     MVI    A,0EAH        ; DTR, RTS, 8-bits, enable send section
  319.     OUT    MDCTL1        ; Send to the status port
  320. ;
  321.     CALL    BRKOFF        ; disable BREAK hardware reset
  322. ;
  323.     LDA    MSPEED        ; Get the selected value
  324.     CPI    1        ; 300 bps
  325.     JZ    OK300
  326.     CPI    5        ; 1200 bps
  327.     JZ    OK1200
  328.     CPI    6        ; 2400 bps
  329.     JZ    OK2400
  330.     CPI    8        ; 9600 bps
  331.     JZ    OK9600
  332.     JMP    STUPR1        ; Else ask what is wanted
  333. ;.....
  334. ;
  335. ;
  336. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  337.     JNC    STUPR2
  338. ;
  339. STUPR1:    LXI    D,BAUDBUF    ; Point to new input buffer
  340.     CALL    J$ILPRT
  341.     DB    'Input Baud Rate (300, 1200, 2400, 9600, 19200):',0
  342.     LXI    D,BAUDBUF    ; Point to new input buffer
  343.     CALL    J$INBUF
  344.     CALL    J$CRLF
  345.     LXI    D,BAUDBUF+2
  346. ;
  347. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  348.     DB    '300',0
  349.     JNC    OK300        ; Go if got match
  350.     CALL    J$INLNCP
  351.     DB    '1200',0
  352.     JNC    OK1200
  353.     CALL    J$INLNCP
  354.     DB    '2400',0
  355.     JNC    OK2400
  356.     CALL    J$INLNCP
  357.     DB    '9600',0
  358.     JNC    OK9600
  359.     CALL    J$INLNCP
  360.     DB    '19200',0
  361.     JNC    OK19200
  362.     CALL    J$INLNCP
  363.     DB    '38400',0
  364.     JNC    OK38400
  365.     CALL    J$INLNCP
  366.     DB    '76800',0
  367.     JNC    OK76800
  368.     CALL    J$ILPRT        ; All matches failed, tell operator
  369.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  370.     JMP    STUPR1        ; Try again
  371. ;
  372. OK300:    MVI    A,1        ; MSPEED 300 baud value
  373.     LXI    H,BD300        ; Get 300 bps parameters in 'HL'
  374.     JMP    LOADBD        ; Go load them
  375. ;
  376. OK1200:    MVI    A,5
  377.     LXI    H,BD1200
  378.     JMP    LOADBD
  379. ;
  380. OK2400:    XRA    A
  381.     STA    MANUAL        ; Reset to maximum auto-speed
  382.     MVI    A,6
  383.     LXI    H,BD2400
  384.     JMP    LOADBD
  385. ;
  386. OK9600:    MVI    A,8
  387.     LXI    H,BD9600
  388.     JMP    LOADBD
  389. ;
  390. OK19200:MVI    A,9
  391.     LXI    H,BD19200
  392.     JMP    LOADBD
  393. ;
  394. OK38400:MVI    A,9        ; use 19200 value so time routines
  395.     LXI    H,BD38400    ;    don't blow
  396.     JMP    LOADBD
  397. ;
  398. OK76800:MVI    A,9        ; use 19200 value so time routines
  399.     LXI    H,BD76800    ;   don't blow
  400. ;
  401. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  402.     MOV    A,H        ; CTC command word
  403.     OUT    BRPORT
  404.     MOV    A,L        ; Baudrate
  405.     OUT    BRPORT
  406.     RET
  407. ;.....
  408. ;
  409. ;
  410. ; TABLE OF BAUD RATE PARAMETERS
  411. ;
  412. BD300    EQU    0734H        ;
  413. BD1200    EQU    4740H        ;
  414. BD2400    EQU    4720H        ;
  415. BD9600    EQU    4708H        ;
  416. BD19200    EQU    4704H        ;
  417. BD38400    EQU    4702H        ;
  418. BD76800    EQU    4701H        ;
  419. ;
  420. ;
  421. BAUDBUF:DB    10,0,0,0,0,0
  422.     DB    0,0,0,0,0,0
  423. ;.....
  424. ;
  425. ;
  426. ;----------------------------------------------------------------------
  427. ;    This code is a fix to disable the BREAK key Hardware reset
  428. ;    on the X series AP8020 Application Processors.    This is easier
  429. ;    than changing the jumpers on the board.
  430. ;
  431. BRKOFF:     IF    NS311
  432.     MVI    A,2        ; Get disable break request - 3.11+ only
  433.     CALL    0F806H        ;   this does the trick
  434.     RET
  435.      ENDIF            ; NS311
  436. ;.....
  437. ;
  438. ;
  439. ; Old stuff left in for reference
  440. ;
  441.      IF    NOT NS311
  442.     LHLD    0F804H        ; Get MBUS request vector
  443.     SHLD    MBRQST+1
  444.     LXI    H,MBRQST
  445.     SHLD    0F804H        ; Trap requests
  446. ;    \ /
  447.     LHLD    0F81EH        ; Get MBUS interrupt vector
  448.     SHLD    MBINT+1
  449.     LXI    H,MBINT
  450.     SHLD    0F81EH        ; Trap interrupts
  451.     RET            ; Continue on
  452.      ENDIF            ; Old code disable
  453. ;.....
  454. ;
  455. ;
  456. BRKON:     IF    NS311
  457.     MVI    A,3        ; Get break enable code
  458.     CALL    0F806H
  459.     RET
  460.      ENDIF
  461. ;...
  462. ;
  463. ;
  464.      IF    NOT NS311
  465.     LHLD    MBRQST+1    ; Get MBUS request vector
  466.     SHLD    0F804H        ; Restore vector
  467. ;    \ /
  468.     LHLD    MBINT+1        ; Get MBUS interrupt vector
  469.     SHLD    0F81EH        ; Restore vector
  470. ;    \ /
  471.     RET            ; Continue on
  472. ;.....
  473. ;
  474. ;
  475. ; Code to interrcept and reset the BREAK key bit in the system control
  476. ; register
  477. ;
  478. SCR    EQU    80H        ; Port address
  479. NLEDON    EQU    80H        ; LED off
  480. ADCPEN    EQU    40H        ; No address compare
  481.  
  482. MBRQST:    CALL    0        ; Filled at runtime
  483.     JMP    RETRN
  484.  
  485. MBINT:    CALL    0        ; Filled at runtime
  486. ;    \ /
  487. RETRN:    PUSH    PSW
  488.     MVI    A,NLEDON+ADCPEN
  489.     OUT    SCR
  490.     POP    PSW
  491.     RET
  492.      ENDIF            ; NOT NS311
  493. ;.....
  494. ;
  495. ;                   end
  496. ;-----------------------------------------------------------------------
  497. ;
  498. ; NOTE: Must terminate prior to 0400H
  499. ;
  500.     END
  501.