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 / I2MC-2.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  14KB  |  508 lines

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