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 / QTERM / QTO-HP1C.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  9KB  |  288 lines

  1. ; QTO-HP1C.ASM - QTERM Overlay for Hewlett-Packard HP-125 Computer
  2. ;
  3. ; Author: Mike Freeman 17-Apr-89
  4. ; 301 N.E. 107th Street; Vancouver, Wa 98685; (206)574-8221
  5. ;
  6. ; See QTERM.PAT for documentation of QTERM's patch area
  7. ;
  8. ; I claim no copyright on this overlay; as a road-sign in Oklahoma
  9. ; once said:  "No Speed Limit -- Do Your Damnedest"
  10. ;
  11. ; The program QTERM is Copyright 1989 by DPG (David Goodenough)
  12. ;
  13. ; Revised 04/19-89 to save/restore all Z80 registers (including IX and IY)
  14. ; during BDOS calls; Ymodem Batch transfers now work -- Mike Freeman
  15. ; Revised 04/25/89 to home cursor/clear screen upon QTERM entry/exit
  16. ; Also made Z80-specific code more obvious by commenting in Zilog instructions
  17. ; -- Mike Freeman --
  18. ; Revised 04/26/89 to map/unmap RDR/PUN last to avoid escape sequences
  19. ; showing up/not being interpreted properly after QTERM exits if the HP-125
  20. ; has been placed in Remote Mode -- Mike Freeman
  21. ; Revised 04/28/89 to trim screen-clearing code at startup/exit -- Mike Freeman
  22. ;
  23. ;This overlay adapts QTERM.COM from QTERMxxx.LBR to run on the Hewlett-Packard
  24. ;HP-125 Series 100 Business Computer running a HP-modified CP/M Version 2.2
  25. ;operating system.  This overlay is a full QTERM implementation except that:
  26. ;(1) Break is not implemented (a Break can be sent from the Keyboard only);
  27. ;(2) The DTR-manipulation/modem hangup routines are not implemented; (3) The
  28. ;routine to change Baud-rate is not implemented (this is changed from the
  29. ;Keyboard's Configuration Menu); (4) Stop-bit manipulation is not implemented
  30. ;(HP gives the user no way to do this) and (5) changing of parity is not
  31. ;implemented (this is also changed from the Configuration Menu).  The Hp-125
  32. ;consists of 2 Z80 processors: one is the CPU and the other handles terminal
  33. ;I/O.  HP does not allow the user to access the Z80 I/O ports directly.
  34. ;However, HP does provide the CP/M Reader and Punch BDOS calls along with
  35. ;a "subfunction" call (passed in BC) to get Reader status.  When properly
  36. ;mapped, the Reader takes input from Datacomm Port 1 and the Punch sends output
  37. ;to Datacomm Port 1.  All data is in the form 8N1 and special provisions must
  38. ;be made to insure that all 8 bits of data are sent/received by DAtacomm 1.
  39. ;(Datacomm 2, the Printer Port, can only accommodate 7-bit data).  Device
  40. ;mapping of Reader/Punch to Datacomm Port 1 is accomplished by sending a series
  41. ;of escape sequences to the HP-125's Console (rather than using the IO byte).
  42. ;
  43. ;To assemble QTO-HP1C.ASM using ASM:
  44. ;A>ASM QTO-HP1C
  45.  
  46. ;To produce the modified QTERM.COM ready for use with the HP-125 using MLOAD:
  47. ;A>MLOAD QTO-HP1=QTERM.COM,QTO-HP1C.HEX
  48. ;
  49. ;
  50. ; Parameters
  51. ;
  52. HAYES    EQU    000H        ;Nonzero means HAYES-style hang-up string
  53. ;
  54. ;BDOS equates
  55. ;
  56. BOOT    EQU    0        ;CP/M Warm-start
  57. RDR    EQU    3        ; Reader input
  58. PUN    EQU    4        ; Punch output
  59. BDOS    EQU    5        ; BDOS entry
  60. DCONIO    EQU    6        ;Direct Console I/O
  61. PRT    EQU    9        ; Print "$"-terminated string to Console
  62. ;
  63. ;Special HP subfunctions
  64. ;
  65. RDRSTS    EQU    70FFH        ; Get Reader status (A nonzero if char ready)
  66. BITS8    EQU    73FFH        ; Set Datacomm 1 to pass 8-bit data
  67. BITS7    EQU    74FFH        ; Set Datacomm 1 to allow only 7-bit data
  68. JVT    EQU    7EFFH        ; Jump-vector (BIOS routine address) transfer
  69. ;
  70. ;Ascii equates
  71. ;
  72. ESC    EQU    1BH        ; <ESC>
  73. ;
  74. ;Routine addresses
  75. ;
  76. CONOUT    EQU    0109H        ; Character in C to Console
  77. DECOUT    EQU    010CH        ; Number in HL to Console in decimal
  78. ;
  79.     ORG    0110H        ; Overlay starts here
  80. ;
  81. ;Get modem (Reader) status
  82. ;
  83.     PUSH    B        ;Protect BC
  84.     LXI    B,RDRSTS    ; Set subfunction call to
  85.     CALL    ENTRY        ; Get Reader status
  86.     POP    B        ;Restore registers
  87.     RET            ; And return
  88.     DS    120H-$ AND 0FFH
  89. ;
  90. ;Get modem character into A
  91. ;
  92.     PUSH    B        ;Save BC
  93.     MVI    C,RDR        ; Set function call to
  94.     CALL    ENTRY        ;Get character
  95.     POP    B        ;Restore BC
  96.     RET            ;and return
  97.     DS    130H-$ AND 0FFH
  98. ;
  99. ;Get Punch status (always true)
  100. ;
  101.     XRA    A        ;Set Z
  102.     INR    A        ;Clear Z
  103.     RET            ; And return
  104.     DS    140H-$ AND 0FFH
  105. ;
  106. ;Send character in A to Punch
  107. ;
  108.     PUSH    PSW        ;Save registers
  109.     PUSH    B        ;...
  110.     PUSH    D        ;...
  111.     MOV    E,A        ; Put character in E
  112.     MVI    C,PUN        ; Set function call to
  113.     CALL    ENTRY        ;Send character
  114.     POP    D        ;Restore registers
  115.     POP    B        ;...
  116.     POP    PSW        ;...
  117.     RET            ;and return
  118.     DS    150H-$ AND 0FFH
  119. ;
  120. ;Set Break (not implemented)
  121. ;
  122.     RET            ; ...
  123.     DS    160H-$ AND 0FFH
  124. ;
  125. ;Clear break (not implemented)
  126. ;
  127.     RET            ; ...
  128.     DS    170H-$ AND 0FFH
  129. ;
  130. ;Kill DTR routines/modem hang-up string (not implemented)
  131. IF HAYES
  132. ;
  133.     RET            ;Modem hangup string follows
  134.     DB    10,0FEH,'+++',0FEH,'ATH0',0DH
  135. ;
  136. ENDIF ; HAYES
  137. ;
  138. IF NOT HAYES
  139. ;
  140. ;
  141.     DB    0,0C9H        ; ...
  142. ;
  143. ENDIF ;NOT HAYES
  144. ;
  145.     DS    180H-$ AND 0FFH
  146. ;
  147. ;Restore DTR (not implemented)
  148. ;
  149.     RET            ; ...
  150.     DS    190H-$ AND 0FFH
  151. ;
  152. ;Baud-rate setting routine (not implemented
  153. ;
  154.     RET            ; ...
  155.     DS    1B0H-$ AND 0FFH
  156. ;
  157. ;Set Parity/Stop-bits (not implemented)
  158. ;
  159.     RET            ; ...
  160.     DS    1CCH-$ AND 0FFH
  161. ;
  162.     DS    1        ;Reserved for future use
  163. ;
  164.     DS    1        ; Transfer size
  165. ;
  166.     DB    4        ; Processor speed in mHz
  167. ;
  168.     DB    '\'-40H        ; Escape character
  169. ;
  170.     DB    'HP-125 Series 100',0 ; Sign-on id
  171.     DS    1F0H-$ AND 0FFH
  172. ;
  173. HOMCLR:    DB    ESC,'H',ESC,'J',0 ; Home cursor/clear screen
  174.     DS    200H-$ AND 0FFH
  175. ;
  176. ;MOVETO - Place cursor in row/column H/L
  177. ;
  178. MOVETO:    PUSH    H        ; Save row/column
  179.     MVI    C,ESC        ; Send cursor leadin
  180.     CALL    CONOUT        ; ...
  181.     MVI    C,'&'        ; ...
  182.     CALL    CONOUT        ; ...
  183.     MVI    C,'A'+20H    ; ...
  184.     CALL    CONOUT        ; ...
  185.     POP    H        ; Get row/column
  186.     PUSH    H        ; Save again
  187.     MOV    L,H        ; Get row
  188.     MVI    H,0        ; Make 16-bit integer
  189.     CALL    DECOUT        ; Type in decimal to Console
  190.     MVI    C,'R'+20H    ; Say it was a row
  191.     CALL    CONOUT        ; ...
  192.     POP    H        ; Get row/column
  193.     MVI    H,0        ; Isolate column as 16-bit integer
  194.     CALL    DECOUT        ; Type in decimal
  195.     MVI    C,'C'        ; Terminate sequence - column
  196.     JMP    CONOUT        ; And return
  197.     DS    22FH-$ AND 0FFH
  198. ;
  199.     DB    0FFH        ; Terminal capabilities (all)
  200. ;
  201.     DB    ESC,'&@',0,0,0,0,0 ; Enhancement off
  202.     DB    ESC,'&F',0,0,0,0,0 ; Enhancement on
  203.     DB    ESC,'M',0,0,0,0,0,0 ; Delete line
  204.     DB    ESC,'L',0,0,0,0,0,0 ; Insert line
  205.     DB    ESC,'P',0,0,0,0,0,0 ; Delete character
  206.     DB    ESC,'R',20H,ESC,'Q',08H,0,0 ; Insert character
  207.     DB    ESC,'K',0,0,0,0,0,0 ; Clear to end-of-line
  208.     DB    ESC,'J',0,0,0,0,0,0 ; Clear to end-of-screen
  209. ;
  210. ;
  211.     JMP    INIT        ; Initialization
  212.     JMP    FINISH        ; Termination
  213. ;
  214. ;Initialization code
  215. ;
  216. INIT:    LXI    D,JBUF        ; Point to dispatch vector address arg block
  217.     LXI    B,JVT        ; Set subfunction call to
  218.     CALL    BDOS        ; Get Reader input routine address
  219.     LHLD    JBUF+3        ; Remember this address
  220.     SHLD    READ8+1        ; For 8-bit Reader routine
  221.     LXI    H,READ8        ; Put this address in BIOS dispatch table
  222.     LXI    B,BITS8        ; Set up to set 8-bit passthru
  223.                 ; And fall into common code
  224. ;
  225. COMCOD:    PUSH    B        ; Save passthru function code
  226.     SHLD    JBUF+3        ; Put BIOS dispatch address in arg block
  227.     MVI    A,1        ; Say we want to write into dispatch table
  228.     STA    JBUF+1        ; ...
  229.     LXI    D,JBUF        ; Point to jump vector argument block
  230.     LXI    B,JVT        ; Set subfunction call to
  231.     CALL    BDOS        ; Write routine address into dispatch table
  232.     LXI    H,HOMCLR    ;Start/end with a clean screen
  233.     MVI    B,4        ;4 characters in the escape sequence
  234. COMCO0:    MOV    E,M        ;Get character from escape sequence
  235.     INX    H        ;Increment pointer
  236.     MVI    C,DCONIO    ;Send character directly to the Console
  237.     CALL    ENTRY        ;...
  238. ;    DJNZ    COMCO0        ;Get all characters
  239.     DB    10H,COMCO0-$-1 AND 0FFH;...
  240.     POP    B        ; Get passthru code
  241.     CALL    BDOS        ;Set Passthru
  242.     LXI    D,MAPSEQ    ; Send mapping escape sequences
  243.     MVI    C,PRT        ; To the Console
  244.     JMP    BDOS        ; To do/undo Reader/Datacomm Port 1 mappings
  245.                 ;and return
  246. ;
  247. ;Final (exit) code
  248. ;
  249. FINISH:    LHLD    READ8+1        ; Point to real Reader input address
  250.     LXI    B,BITS7        ; Set for 7-bit terminal passthru
  251.     MVI    A,'9'        ; Set to turn off Datacomm mappings
  252.     STA    MAPSEQ+8    ; ...
  253.     STA    MAPSEQ+19    ; ...
  254. ;    JR    COMCOD        ; And branch to common code
  255.     DB    18H,COMCOD-$-1 AND 0FFH;...
  256. ;
  257. ;Routine to read 8-bit data from Datacomm Port 1
  258. ;
  259. READ8:    CALL    $-$        ; Read data
  260.     MOV    A,B        ; Get 8-bit data
  261.     RET            ; And return
  262. ;
  263. ;Put BIOS routine address vector block here
  264. ;
  265. JBUF:    DB    7,0,0C3H,0,0    ; ...
  266. ;
  267. ;Escape sequence string to map Reader/Punch to Datacomm Port 1
  268. ;
  269. MAPSEQ:    DB    ESC,'&i0s25d2M'    ; Map Datacomm 1 to Reader
  270.     DB    ESC,'&i10s16d2M$' ; And Punch to Datacomm 1
  271. ;
  272. ;ENTRY - Save/restore registers BC-IY and call BDOS
  273. ;
  274. ENTRY:    PUSH    B        ;Save registers
  275.     PUSH    D        ;...
  276.     PUSH    H        ;...
  277.     DB    0DDH,0E5H    ;PUSH IX
  278.     DB    0FDH,0E5H    ;PUSH IY
  279.     CALL    BDOS        ;Do BDOS call
  280.     DB    0FDH,0E1H    ;Restore registers - POP IY
  281.     DB    0DDH,0E1H    ;POP IX
  282.     POP    H        ;...
  283.     POP    D        ;...
  284.     POP    B        ;...
  285.     RET            ;and return
  286. ;
  287.     END            ; End of overlay
  288.