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 / ENTERPRS / CPM / TERMS / QTPATCH.ARC / QT-ZORBA.ASM < prev    next >
Assembly Source File  |  1989-09-08  |  7KB  |  279 lines

  1. ; QTO-ZB10.ASM - QTERM Overlay for Telcon Zorba Computer
  2. ;
  3. ; 04/12/89 - Created this overlay - Mike Freeman
  4. ;
  5. ; See QTERM.PAT for documentation of QTERM's patch area
  6. ;
  7. ; This overlay is a full implementation of QTERM for the Telcon Industries Inc.
  8. ; Zorba computer except that (a) 38.4 KBaud is not supporte  and
  9. ; (b) the terminal capabilities of Character Insertion and Character
  10. ; Deletion are absent.  This does not, however, affect either VT100-
  11. ; emulation or the <esc> W Window mode of operation.
  12. ; Communication is accomplished through Port A (the Communications Port).
  13. ;
  14. ; This overlay may be assembled by ASM, LASM or equivalent:
  15. ; A>ASM QT-ZORBA.AAZ
  16. ; and may be loaded over QTERM.COM with MLOAD:
  17. ; A>MLOAD QTERM.COM,QT-ZORBA.HEX
  18. ; to produce QTERM.COM adapted for the Zorba.
  19. ;
  20. ;**NOTE** as written, this overlay initializes the Zorba to start in 8N1 mode
  21. ; at 1200 Baud.  Change the parameters at INIT: to set a different 
  22. ; initialization configuration.
  23. ;
  24. ; The program QTERM is Copyright 1989 by DPG (David Goodenough).
  25. ; It may be found in the latest release of QTERMxxx.lbr (where xxx = version)
  26. ;
  27. ; I make no claim of copyright to this overlay.  As a road-sign in Oklahoma
  28. ; used to say, "No Speed Limit -- Do Your Damnedest"
  29. ; -- Mike Freeman; 301 N.E. 107th Street; Vancouver, Wa 98685;
  30. ; (206)574-8221
  31. ;
  32. ; Parameters
  33. ;
  34. HAYES    EQU    000H        ;Nonzero means use "+++ATH0" to hang up modem
  35. ;
  36. ; Symbols
  37. ;
  38. BOOT    EQU    00H        ;CP/M Warm-boot vector
  39. BDOS    EQU    05H        ;BDOS entry
  40. ;
  41. ;Port addresses
  42. ;
  43. BRPORT    EQU    00H        ;8254-2 Baud Rate Generator Timer for Port A
  44. COMMND    EQU    03H        ;8254-2 Timer Control Port
  45. MDDATP    EQU    20H        ;Modem Data Port (A)
  46. MDCTL1    EQU    21H        ;Modem Status (Port A)
  47. ;
  48. ;Modem status bits
  49. ;
  50. MDSND    EQU    1        ;Output Send Ready bit
  51. MDRCV    EQU    2        ;Receive (Input) Ready bit
  52. ;
  53. ;Port commands
  54. ;
  55. MDMODE    EQU    82H    ; Insures 8251 is out of mode with DTR high
  56. MDRSET    EQU    42H    ; Resets USART for additional commands
  57. MDSET1    EQU    4EH    ; 1 stop bit, no parity, 8 bits, 16x
  58. MDSET2    EQU    0CEH    ; 2 stop bits, no parity, 8 bits, 16x
  59. MDCOM    EQU    17H    ; Reset error flags, RCV, DTR, TX ready
  60. ;;
  61. ;Values for 8254-2 baud rate timer generator
  62. ;
  63. BD300    EQU    1667        ; 300 bps
  64. BD600    EQU    833        ;600 bps
  65. BD1200    EQU    417        ; 1200 bps
  66. BD2400    EQU    208        ; 2400 bps
  67. BD4800    EQU    104        ;4800 bps
  68. BD9600    EQU    52        ; 9600 bps
  69. BD19200    EQU    26        ;19200 bps
  70. ;
  71. ;Routine addresses
  72. ;
  73. CONOUT    EQU    109H        ;Output character in C to Console
  74. DECOUT    EQU    10CH        ;Output number in HL in decimal to Console
  75. ;
  76.     ORG    110H        ;Overlay starts here - Get Port input status
  77. ;
  78.     IN    MDCTL1        ;Check port status
  79.     ANI    MDRCV        ;Check for receive-ready
  80.     RET            ;and return
  81.     DS    120H-$ AND 0FFH
  82. ;
  83. ;Get character from port
  84. ;
  85.     IN    MDDATP        ;Get character from port
  86.     RET            ;and return
  87.     DS    130H-$ AND 0FFH
  88. ;
  89. ;Check output ready status
  90. ;
  91.     IN    MDCTL1        ;Get port status
  92.     ANI    MDSND        ;Check for output-ready
  93.     RET            ;and return
  94.     DS    140H-$ AND 0FFH
  95. ;
  96. ;Send character to output
  97. ;
  98.     OUT    MDDATP        ;Send character in A to port
  99.     RET            ;and return
  100.     DS    150H-$ AND 0FFH
  101. ;
  102. ;Start Break
  103. ;
  104.     MVI    A,3FH        ;DTR-normal, break on
  105.     OUT    MDCTL1        ;...
  106.     RET            ;Return
  107.     DS    160H-$ AND 0FFH
  108. ;
  109. ;Clear Break
  110. ;
  111.     MVI    A,37H        ;DTR-normal, send-receive normal
  112.     OUT    MDCTL1        ;...
  113.     RET            ;Return
  114.     DS    170H-$ AND 0FFH
  115. ;
  116. ;Drop DTR
  117. ;
  118. IF NOT HAYES
  119. ;
  120.     MVI    A,3DH        ;Drop DTR
  121.     OUT    MDCTL1        ;Drop DTR
  122.     RET            ;Return
  123.     DS    180H-$ AND 0FFH
  124. ;
  125. ;Raise DTR
  126. ;
  127.     MVI    A,37H        ;DTR, send, receive normal
  128.     OUT    MDCTL1        ;...
  129.     RET            ;Return
  130.     DS    190H-$ AND 0FFH
  131. ;
  132. ENDIF ;NOT HAYES
  133. ;
  134. IF HAYES
  135. ;
  136.     RET            ;Use hangup string
  137.     DB    10,0FEH,'+++',0FEH,'ATH0',0DH;Hang up string
  138.     DS    190H-$ AND 0FFH
  139. ;
  140. ENDIF ;HAYES
  141. ;
  142. ;Set baud rate
  143. ;
  144.     JMP    LOADBD        ;Load baud rate
  145.     DS    1A0H-$ AND 0FFH
  146. ;
  147. ;Baud rate index table
  148. ;
  149. BDTABL:    DB    0,0        ;38 KBaud (not implemented)
  150.     DB    1,0FFH        ;19.2 KBaud
  151.     DB    2,0FFH        ;9600 Baud
  152.     DB    3,0FFH        ;4800 baud
  153.     DB    4,0ffh        ;2400 baud
  154.     DB    5,0FFH        ;1200 Baud
  155.     DB    6,0ffh        ;600 baud
  156.     DB    7,0FFH        ;300 Baud
  157. ;
  158.     JMP    STUART        ;1B0H - Set word-width, parity, stop-bits, x16
  159.     DS    1C0H-$ AND 0FFH
  160. ;
  161. ;Table of parity/bits/stopbits
  162. ;
  163.     DB    4AH        ;7N1
  164.     DB    4EH        ;8N1
  165.     DB    0CAH        ;7N2
  166.     DB    0CEH        ;8N2
  167.     DB    7AH        ;7E1
  168.     DB    7EH        ;8E1
  169.     DB    0FAH        ;7E2
  170.     DB    0FEH        ;8E2
  171.     DB    5AH        ;7O1
  172.     DB    5EH        ;8O1
  173.     DB    0DAH        ;7O2
  174.     DB    0DEH        ;8O2
  175. ;
  176.     DS    1        ;1CCH - Reserved
  177. ;
  178.     DS    1        ;1CDH - Transfer buffer size
  179. ;
  180.     DB    4        ;1CEH - Clock speed
  181. ;
  182.     DB    ']'-40H        ;1CFH - Escape character
  183. ;
  184. ;1D0H - Signon message
  185.     DB    'Telcon Zorba',0 ;...
  186.     DS    1F0H-$ AND 0FFH
  187. ;
  188. ;Clear screen
  189. ;
  190.     DB    1BH,'H',1BH,'E',0
  191.     DS    200H-$ AND 0FFH
  192. ;
  193. ;MOVETO - Cursor positioning
  194. ;
  195. MOVETO:    PUSH    H        ;Save coordinates
  196.     MVI    C,1BH        ;Transmit <esc>
  197.     CALL    CONOUT        ;...
  198.     MVI    C,'Y'        ;Cursor follows
  199.     CALL    CONOUT        ;...
  200.     POP    H        ;Get row/column
  201.     PUSH    H        ;Save again
  202.     MOV    A,H        ;Get row
  203.     CALL    CUROUT        ;Type it
  204.     POP    H        ;Get row/column again
  205.     MOV    A,L        ;Get row
  206. CUROUT:    ADI    20H        ;Make ASCII character
  207.     MOV    C,A        ;Put in C
  208.     JMP    CONOUT        ;and Output to Console
  209.     DS    22FH-$ AND 0FFH
  210. ;
  211. ;Terminal capability mask
  212. ;
  213.     DB    0CFH        ;Everything except char deletion/insertion
  214. ;
  215.     DB    1BH,71H,0,0,0,0,0,0;Alternate video off
  216.     DB    1BH,70H,0,0,0,0,0,0;Alternate video on
  217.     DB    1BH,'M',0,0,0,0,0,0;Delete line
  218.     DB    1BH,'L',0,0,0,0,0,0;Insert line
  219.     DB    0,0,0,0,0,0,0,0    ;No delete character
  220.     DB    0,0,0,0,0,0,0,0    ;or insert character
  221.     DB    1BH,'K',0,0,0,0,0,0;Clear to end-of-line
  222.     DB    1BH,'J',0,0,0,0,0,0;Clear to end-of-screen
  223. ;
  224. ;
  225.     JMP    INIT        ;Jump to initialization code
  226.     RET            ;No termination is needed
  227.     NOP            ;...
  228.     NOP            ;...
  229. ;
  230. ;INIT - Initialization routine
  231. ;
  232. INIT:    MVI    A,MDSET1    ;Set 1 stop-bit, no parity, 8-bit, x16
  233.     CALL    STUART        ;...
  234.     MVI    A,5        ;Set initial speed to 1200 Baud
  235.                 ;and fall into load baud-rate routine
  236. ;
  237. ;LOADBD - Load Baud rate
  238. ;
  239. LOADBD:    DCR    A        ;Make index zero-offset
  240.     RLC        ;times 2
  241.     LXI    H,BDTBL1    ;Point to real Baud-rate table
  242.     MOV    E,A        ;Put offset into DE
  243.     MVI    D,0        ;...
  244.     DAD    D        ;Compute address of correct Baud rate
  245. LOADB0:    MVI    A,36H        ;Set square wave
  246.     OUT    COMMND        ;...
  247.     MOV    A,M        ;Get LSB of Baud rate
  248.     OUT    BRPORT        ;Send to generator
  249.     INX    H        ;Point to MSB
  250.     MOV    A,M        ;Get it
  251.     OUT    BRPORT        ;Send to Baud rate generator
  252.     RET            ;and return
  253. ;
  254. BDTBL1:                ;Zorba Baud-rate table
  255.     DW    BD19200,BD9600,BD4800,BD2400,BD1200,BD600,BD300
  256. ;
  257. ;STUART - Set UART (Word-width, Stop-bits, Parity, x16) - Parameter in A
  258. ;
  259. STUART:    PUSH    PSW        ;Save settings
  260.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  261.     OUT    MDCTL1
  262.     XTHL            ; Small delay to complete command
  263.     XTHL
  264.     MVI    A,MDRSET    ; Reset the 8251A for new command
  265.     OUT    MDCTL1
  266.     XTHL            ; Small delay to complete command
  267.     XTHL
  268.     POP    PSW        ;Get parameters
  269.     OUT    MDCTL1        ;Set stop-bits, parity, word-width, x16
  270.     XTHL            ; Small delay to complete command
  271.     XTHL
  272.     MVI    A,MDCOM        ; Error reset, RCV, DTR, TX ready
  273.     OUT    MDCTL1
  274.     XTHL            ; Small delay to complete command
  275.     XTHL
  276.     RET            ;Return
  277. ;
  278.     END            ;End of overlay
  279.