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 / MODEMS / ZMODEM / ZMO-ROB5.Z80 < prev    next >
Text File  |  2000-06-30  |  14KB  |  664 lines

  1.     .TITLE    'DEC VT180 computer overlay file for ZMP'
  2.     NAME    VT180
  3. ;  PROGRAM: ZMO-ROB.Z80
  4. ;  AUTHOR:  Ron Murray
  5. ;  VERSION: 1.5
  6. ;  DATE:  03 Mar, 1989
  7. ;-----------------------------------------------------------------------
  8. ;    This Overlay File supports the DEC Micro VT180 (aka ROBIN).
  9. ;-----------------------------------------------------------------------
  10. ; 89/04/12 - Modified to ZMP v1.5        - George Conover
  11. ; 89/03/15 - Removed the beginning remarks to make the file
  12. ;             smaller. If you need the remarks there are in the
  13. ;             file ZMP-BLNK.Z80             - George Conover
  14. ; 88/03/03 - First version of this file               - George Conover
  15. ;
  16. ;    Written by -
  17. ;      Ron Murray, c/o Z-Node 62, 061-9-450-0200, Perth, Western Australia.
  18. ;-----------------------------------------------------------------------
  19. ;
  20. ;We use the COMM-Port of the Micro's. Baud-rates are "parallel"
  21. ;to the console Baud-rates - no need for a "special" baud-rate
  22. ;routine.  Since the COMM-port is I/O-wise Reader/Punch, we use
  23. ;the BDOS calls.
  24. ;
  25. ;To test for COMM-status , we use I/O byte redirection in
  26. ;conjunction with direct BIOS-CONSTAT call.
  27. ;
  28. ;This technique although a little bit slower than direct I/O
  29. ;using Interrupt on INPUT is general enough to be system
  30. ;independent.
  31. ;
  32. ;    - George N. Conover
  33. ;
  34. ;-----------------------------------------------------------------------
  35. ; Notes on modifying this file:
  36. ;
  37. ; See Sample Overlay ZMO-BLNK.Z80
  38. ;    Written by - Ron Murray, c/o Z-Node 62, 061-9-450-0200
  39. ;             Perth, Western Australia.
  40. ;
  41. ;-----------------------------------------------------------------------
  42. ;
  43. ; User-set variables:
  44. ;
  45. BDOS    EQU    0005        ; Address of BDOS entry
  46. PUNCH    EQU    4        ; Punch function
  47. READER    EQU    3        ; Reader function
  48. MODDCDB EQU    4        ; Carrier detect bit
  49. MODDCDA EQU    0        ; Value when active
  50. MODRCVB EQU    0FFH        ; Bit to test for recedive
  51. MODRCVR EQU    0FFH        ; Value when ready
  52. MODSNDB EQU    0FFH        ; Bit to test for send
  53. MODSNDR EQU    0FFH        ; Value when ready
  54. ;
  55. CLKSPD    EQU    4        ; Processor clock speed in MHz
  56. ;
  57.  
  58. ;Set the following two equates to the drive and user area which will contain
  59. ;   ZMP's .OVR files, .CFG file, .FON file and .HLP file. Set both to zero
  60. ;   (null) to locate them on the drive from which ZMP was invoked.
  61.  
  62. OVERDRIVE    EQU    0    ; Drive to find overlay files on ('A'-'P')
  63. OVERUSER    EQU    0    ; User area to find files
  64.  
  65. ;-----------------------------------------------------------------------
  66. ; NOT user-set variables
  67.  
  68. USERDEF    EQU    0145H        ; origin of this overlay
  69.                 ; This address should not change with
  70.                 ; subsequent revisions.
  71. MSPEED    EQU    03CH        ; location of current baud rate.
  72. OVSIZE    EQU    0400H        ; Max size of this overlay
  73. ;
  74. ;
  75. ESC    EQU    1BH
  76. CR    EQU    0DH
  77. LF    EQU    0AH
  78.  
  79.     ORG    USERDEF
  80. ;
  81. ;Jump table for the overlay: do NOT change this
  82. ;
  83. JUMPTAB:JP    SCRNPR        ; Screen print
  84.     JP    MRD        ; Modem read with timeout
  85.     JP    MCHIN        ; Get a character from modem
  86.     JP    MCHOUT        ; Send a character to the modem
  87.     JP    MORDY        ; Test for tx buffer empty
  88.     JP    MIRDY        ; Test for character received
  89.     JP    SNDBRK        ; Send break
  90.     JP    CURSADD        ; Cursor addressing
  91.     JP    CLS        ; Clear screen
  92.     JP    INVON        ; Highlight (inverse video) on
  93.     JP    INVOFF        ; Highlight (inverse video) off
  94.     JP    HIDE        ; Hide cursor
  95.     JP    SHOW        ; Show cursor
  96.     JP    SAVECU        ; Save cursor position
  97.     JP    RESCU        ; Restore cursor position
  98.     JP    MINT        ; Service modem interrupt
  99.     JP    INVEC        ; Initialise interrupt vectors
  100.     JP    DINVEC        ; De-initialise interrupt vectors
  101.     JP    MDMERR        ; Test uart flags for error
  102.     JP    DTRON        ; Turn DTR (and RTS) ON
  103.     JP    DTROFF        ; Turn DTR (and RTS) OFF
  104.     JP    INIT        ; Initialise uart
  105.     JP    WAIT        ; Wait seconds
  106.     JP    MSWAIT        ; Wait milliseconds
  107.     JP    USERIN        ; user-defined entry routine
  108.     JP    USEROUT        ; user-defined exit routine
  109.     JP    GETVARS        ; get system variables
  110.       JP    SETPORT        ; Set port (0 or 1)
  111.  
  112. ; Spare jumps for compatibility with future versions
  113.     JP    SPARE        ; spare for later use
  114.     JP    SPARE        ; spare for later use
  115.     JP    SPARE        ; spare for later use
  116.     JP    SPARE        ; spare for later use
  117.     JP    SPARE        ; spare for later use
  118.     JP    SPARE        ; spare for later use
  119.  
  120. ;
  121. ; Main code starts here
  122. ;
  123. CODEBGN:
  124. ;
  125. ; Screen print function
  126. ;
  127. SCRNPR:
  128. ;
  129. ; <== Insert your own code here
  130. ;
  131.     CALL    PRINT
  132.     DB    CR,LF
  133.     DB    'Screen-print function not supported.',CR,LF,LF
  134.     DB    0
  135. ;
  136. ; <== End of your own code
  137. ;
  138. SPARE:
  139.     RET
  140.  
  141. ; User-defined entry routine: leave empty if not needed
  142. USERIN:
  143.     LD    HL,(1)        ; Get BIOS Jump-table adress
  144.     LD    DE,3
  145.     ADD    HL,DE        ; CONSTAT routine in BIOS
  146.     LD    (BCONST+1),HL    ; modify our "routine"
  147.     RET
  148. ;
  149. BCONST:    JP    $-$        ; address "filled in" by above code
  150. ;
  151. ; User-defined exit routine: leave empty if not needed
  152. USEROUT:
  153.     RET
  154. ;
  155. ; Get a character from the modem: return in HL
  156. ; It is not necessary to test for status
  157. ;
  158. MCHIN:    PUSH    BC
  159. ;
  160. ; <== Insert your own code here
  161. ;
  162. ;.....
  163. ;
  164. ; Subroutine to input a character from the modem.
  165. ; This routine will wait until one becomes available.
  166. ;
  167.     LD    C,READER    ; Use the BDOS function
  168.     CALL    BBDOS        ; Go
  169. ;
  170. ; <== End of your own code
  171. ;
  172.     LD    L,A        ; Put in HL
  173.     LD    H,0
  174.     OR    A        ; Set/clear Z
  175.     POP    BC
  176.     RET
  177. ;
  178. ; Send a character to the modem
  179. ;
  180. MCHOUT:
  181.     LD    HL,2        ; Get the character
  182.     ADD    HL,SP
  183.     LD    A,(HL)        ; In A
  184. ;
  185. ; <== Insert your own code here
  186. ;
  187.     LD    E,A        ; Move output byte into E
  188.     LD    C,PUNCH        ; Use the BDOS function
  189.     CALL    BBDOS        ; Go
  190. ;
  191. ; <== End of your own code
  192. ;
  193.     RET            ; Done
  194. ;
  195. ; Test for output ready: return YES (1) in HL if ok
  196. ;
  197. MORDY:
  198. ;
  199. ; <== Insert your own code here
  200. ;
  201.     LD    HL,01H        ; Assume ready
  202. ;
  203. ; <== End of your own code
  204. ;
  205.     LD    A,L        ; Set/clear Z
  206.     OR    A
  207.     RET
  208. ;
  209. ; Test for character at modem: return YES (1) in HL if so
  210. ;
  211. MIRDY:
  212. ;
  213. ; <== Insert your own code here
  214. ;
  215.     CALL    INCTL        ; In modem control port
  216.     LD    HL,00H        ; Assume not ready for now
  217.           AND    MODRCVB        ; Bit to test for receive ready
  218.     CP    MODRCVR        ; Value of rcv. bit when ready
  219.     JR    NZ,MIRDY1    ; Still not ready
  220.     INC    HL        ; Ready, so set HL
  221. ;
  222. MIRDY1:
  223. ;
  224. ; <== End of your own code
  225. ;
  226.     LD    A,L        ; Set/clear Z
  227.     OR    A
  228.     RET
  229. ;
  230. ; The Check for characters at COMM-Port using I/O redirection
  231. ;
  232. IOBYTE    EQU    3        ; some definitions
  233. DEFIO    EQU    95H        ; the "standard" setting
  234. BATIO    EQU    56H        ;
  235. ;
  236. INCTL:    PUSH    BC
  237.     PUSH    DE
  238.     PUSH    HL        ; save the environment
  239.     PUSH    IY
  240.     PUSH    IX
  241.  
  242.     LD    A,BATIO        ; change I/O byte
  243.     LD    (IOBYTE),A
  244.     CALL    BCONST        ; call BIOS direct - see INITMOD
  245.     PUSH    AF
  246.     LD    A,DEFIO        ; change I/O byte back
  247.     LD    (IOBYTE),A
  248.     POP    AF
  249.  
  250.     POP    IX
  251.     POP    IY
  252.     POP    HL        ; restore environment
  253.     POP    DE
  254.     POP    BC
  255.     RET
  256. ;
  257. ; Send a break to the modem: leave empty if your system can't do it
  258. ;
  259. SNDBRK:
  260. ;
  261. ; <== Insert your own code here, tTo go to 'break' level
  262. ;
  263. ;pbausl EQU    90H    ;The Baud-Rate register.
  264. PRNTST    EQU    49H        ; Printer
  265. ;prndat    EQU    48H
  266. CONTST    EQU    41H        ; Console
  267. ;condat    EQU    40H
  268. GENTST    EQU    51H        ; General port.
  269. ;gendat    EQU    50H
  270. COMTST    EQU    59H        ; COMM-Port
  271. ;comdat    EQU    58H
  272. ;output    EQU    01H    ;Output ready bit.
  273. ;input    EQU    02H    ;Input ready bit.
  274. COMCTL    EQU    59H        ; VT180 communications port
  275. CRTCTL    EQU    41H        ; VT180 crt port
  276. ;VT180 serial port command bits
  277. TXE    EQU    1        ; Transmit enable
  278. DTR    EQU    2        ; Dtr on
  279. RXE    EQU    4         ; Rx enable
  280. SDBRK    EQU    8
  281. RERR    EQU    10H        ; Reset error
  282. RTS    EQU    20H        ; RTS on
  283. RESET    EQU    40H        ; Port reset
  284. ;Send a break to the communications port.
  285. ;
  286.     LD    A,COMCTL    ; Get address of selected port
  287.     LD    C,A        ; Into C
  288.     LD    A,SDBRK+DTR
  289.     OUT    C,A        ;Want to send to port addressed by C
  290. ; <== End of your own code
  291. ;
  292.     LD    HL,300
  293.     CALL    WAITHLMS    ; Wait 300 ms
  294. ;
  295. ; <== Insert your own code here, to restore
  296.     LD    A,COMCTL    ; Get the address for the port
  297.     LD    C,A        ; Into C
  298.     LD    A,TXE+DTR+RXE+RERR+RTS ; Enable tr/rc, dtr, reset error
  299.     OUT    C,A        ;Z-80 only instruction
  300.     OUT    (CONTST),A    ; Reset ports
  301. ;
  302. ; <== End of your own code
  303. ;
  304.     RET
  305. ;
  306. ; Test UART flags for error: return YES (1) in HL if error
  307. ;
  308. MDMERR:
  309. ;
  310. ; <== Insert your own code here
  311. ;
  312.     LD    HL,00H        ; Not yet implemented
  313. ;
  314. ; <== End of your own code
  315. ;
  316.     LD    A,L        ; Set/clear Z
  317.     OR    A
  318.     RET
  319. ;
  320. ; Turn DTR (and RTS) ON. (reset)
  321. ;
  322. DTRON:
  323. ;
  324. ; <== Insert your own code here
  325. ;
  326. ;
  327. ; <== End of your own code
  328. ;
  329.     RET
  330. ;
  331. ;Turn DTR OFF
  332. ;
  333. DTROFF:
  334. ;
  335. ; <== Insert your own code here
  336. ;
  337. ;
  338. ; <== End of your own code
  339. ;
  340.     RET
  341. ;
  342. ; Initializ the UART
  343. ;
  344. INIT:
  345.     LD    HL,2        ; Get parameters
  346.     ADD    HL,SP
  347.     EX    DE,HL
  348.     CALL    GETPARM        ; In HL
  349.     LD    (BRATE),HL    ; Baud rate
  350.     CALL    GETPARM
  351.     LD    (PARITY),HL    ; Parity
  352.     CALL    GETPARM
  353.     LD    (DATA),HL    ; Data bits
  354.     CALL    GETPARM
  355.     LD    (STOP),HL    ; Stop bits
  356. ;
  357. ; <== Insert your own code here
  358. ;
  359.     LD    A,5
  360.                 ; using values below
  361.     LD    (MSPEED),A    ; don't forget to load mspeed with the
  362.                 ; current brate value if the new rate is
  363.                 ; valid. See table of values below.
  364. ;
  365. ; <== End of your own code
  366. ;
  367.     RET
  368. ;
  369. BRATE:    DS    2        ; Baud rate:
  370.                 ; 0 =  110 baud 1 =   300 baud 3 =  600 baud
  371.                 ; 5 = 1200 baud 6 =  2400 baud 7 = 4800 baud
  372.                 ; 8 = 9600 baud 9 = 19200 baud
  373. PARITY:    DS    2        ; Parity (will be 'N', 'E' or 'O')
  374. DATA:    DS    2        ; Data bits (will be 7 or 8)
  375. STOP:    DS    2        ; Stop bits (will be 1 or 2)
  376. ;
  377. ; Set the port. ZMP supplies either 0 or 1 as a parameter.
  378. ;
  379. setport:
  380.     ld    hl,2        ; get port number
  381.     add    hl,sp
  382.     ex    de,hl
  383.     call    getparm        ; in HL (values are 0 and 1)
  384.  
  385.                 ; <== Insert your own code here
  386.  
  387.                 ; <== End of your own code
  388.     ret
  389. ;
  390. ;-----------------------------------------------------------------------
  391. ;
  392. ; Video terminal sequences: these are for VT-100 -- Modify as you
  393. ; wish
  394. ;
  395. ;Cursor addressing:
  396. ;
  397. CURSADD:    LD    HL,2        ; Get parameters
  398.     ADD    HL,SP
  399.     EX    DE,HL
  400.     CALL    GETPARM          ; In HL
  401.     INC    HL
  402.     LD    (ROW),HL    ; Row
  403.     CALL    GETPARM
  404.     INC    HL
  405.     LD    (COL),HL    ; Column
  406. ;
  407. ; <== Insert your own code here, Using values in row and col
  408. ;
  409.     CALL    PRINT
  410.     DB    ESC,'[',0    ; Cursor leadin
  411.     LD    HL,(ROW)    ; Row first
  412.     CALL    NOUT        ; output in decimal
  413.     LD    A,';'        ; follow with semicolon
  414.     CALL    COUT        ; print it
  415.     LD    HL,(COL)    ; Same for column
  416.     CALL    NOUT
  417.     LD    A,'H'        ; terminate with 'move cursor' command
  418.     CALL    COUT        ; print it
  419. ;
  420. ; <== end of your own code
  421. ;
  422.     RET
  423. ;
  424. ROW:    DS    2        ; Row
  425. COL:    DS    2        ; Column
  426. ;
  427. ; Clear screen:
  428. ;
  429. CLS:
  430.     CALL    PRINT
  431.     DB    ESC,'[2J'    ;clear whole screen
  432.     DB    ESC,'[H',0    ;HOME
  433.     RET
  434. ;
  435. ; Highlight on:
  436. ;
  437. INVON:
  438.     CALL    PRINT
  439.     DB    ESC,'[0;7m',0
  440.     RET
  441. ;
  442. ; Highlight off:
  443. ;
  444. INVOFF:
  445.     CALL    PRINT
  446.     DB    ESC,'[0m',0
  447.     RET
  448. ;
  449. ; Turn off cursor:
  450. ;
  451. HIDE:
  452.     RET
  453. ;
  454. ; Turn on cursor:
  455. ;
  456. SHOW:
  457.     RET
  458. ;
  459. ; Save cursor position:
  460. ;
  461. SAVECU:
  462.     CALL    PRINT
  463.     DB    ESC,'7',0
  464.     RET
  465. ;
  466. ; Restore cursor position:
  467. ;
  468. RESCU:
  469.     CALL    PRINT
  470.     DB    ESC,'8',0
  471.     RET
  472. ;
  473. ;-----------------------------------------------------------------------
  474. ;
  475. ; Service modem interrupt:
  476. ;
  477. MINT:                ; My system doesn't need this
  478.     RET
  479. ;
  480. ; Initialise interrupt vectors:
  481. ;
  482. INVEC:
  483.     RET
  484. ;
  485. ; De-initialise interrupt vectors:
  486. ;
  487. DINVEC:
  488.     RET
  489. ;
  490. ;------------------- End of user-defined code --------------------------
  491. ;         Do not change anything below here
  492. ;
  493. ; Modem character test for 100 ms
  494. ;
  495. MRD:    PUSH    BC        ; Save BC
  496.     LD    BC,100        ; Set limit
  497. ;
  498. MRD1:    CALL    MIRDY        ; Char at modem?
  499.     JR    NZ,MRD2        ; Yes, exit
  500.     LD    HL,1        ; Else wait 1ms
  501.     CALL    WAITHLMS
  502.     DEC    BC        ; Loop till done
  503.     LD    A,B
  504.     OR    C
  505.     JR    NZ,MRD1
  506.     LD    HL,0        ; None there, result=0
  507.     XOR    A
  508. ;
  509. MRD2:    POP    BC
  510.       RET
  511. ;
  512. ;    This routine prints the number in HL on the screen in decimal.
  513. ;    Uses all ACs.
  514.  
  515. NOUT:    LD    BC,-10        ; Get some useful constants.
  516. NOUT1:    LD    DE,-1
  517.  
  518. NOUT2:    ADD    HL,BC        ; Subtract as many 10s as possible.
  519.     INC    DE        ; Count them.
  520.     JP    C,NOUT2        ; If some left keep going.
  521.     PUSH    HL        ; Save remainder - 10
  522.     EX    DE,HL        ; Swap the remainder and the quotient.
  523.     LD    A,H        ; Get the number of 10s found.
  524.     OR    L        ; Check for quotient non zero
  525.     CALL    NZ,NOUT1    ; If non zero, recurse.
  526.     POP    HL        ; Get the remainder - 10
  527.     LD    A,L        ; In a
  528.     ADD    A,'0'+10    ; Make the number printable and add the 10 back
  529.     JP    COUT        ; output the digit and return
  530. ;
  531. ; Inline print routine: destroys A and HL
  532. ;
  533. PRINT:    EX    (SP),HL        ; Get address of string
  534. ;
  535. PLOOP:    LD    A,(HL)        ; Get next
  536.     INC    HL        ; Bump pointer
  537.     OR    A        ; Done if zero
  538.     JR    Z,PDONE
  539.     CALL    COUT        ; Else print
  540.     JR    PLOOP        ; And loop
  541. ;
  542. PDONE:    EX    (SP),HL        ; Restore return address
  543.     RET            ; And quit
  544. ;
  545. ; Output a character in A to the console
  546. ;
  547. COUT:    PUSH    BC        ; Save registers
  548.     PUSH    DE
  549.     PUSH    HL
  550.     LD    E,A        ; Character to E
  551.     LD    C,2
  552.     CALL    BBDOS        ; Print it
  553.     POP    HL
  554.     POP    DE
  555.     POP    BC
  556.     RET
  557. BBDOS:
  558.     PUSH    IX
  559.     PUSH    IY
  560.     CALL    BDOS
  561.     POP    IY
  562.     POP    IX
  563.     RET
  564. ;
  565. ; Wait(seconds)
  566. ;
  567. WAIT:    LD    HL,2
  568.     ADD    HL,SP
  569.     EX    DE,HL        ; Get delay size
  570.     CALL    GETPARM
  571. ;                ; Fall thru to...
  572. ; Wait seconds in HL
  573. ;
  574. WAITHLS:PUSH    BC        ; Save BC
  575.     PUSH    DE        ; DE
  576.     PUSH    IX        ; And IX
  577.     LD    IX,0        ; Then point IX to 0
  578. ;                ;   so we don't upset memory-mapped I/O
  579. ;
  580. ; Calculate values for loop constants. Need to have two loops to avoid
  581. ; 16-bit overflow with clock speeds above 9 MHz.
  582. ;
  583. OUTERVAL EQU    (CLKSPD/10)+1
  584. ;
  585. INNERVAL EQU    (6667/OUTERVAL)*CLKSPD
  586. ;
  587. WAIT10:    LD    B,OUTERVAL
  588. ;
  589. WAIT11:    LD    DE,INNERVAL
  590. ;
  591. WAIT12:    BIT    0,(IX)        ; Time-wasters
  592.     BIT    0,(IX)
  593.     BIT    0,(IX)        ; 20 T-states each
  594.     BIT    0,(IX)
  595.     BIT    0,(IX)
  596.     BIT    0,(IX)
  597.     DEC    DE
  598.     LD    A,E
  599.     LD    A,D
  600.     OR    E
  601.     JR    NZ,WAIT12    ; 150 T-states per inner loop
  602.     DJNZ    WAIT11        ; Decrement outer loop
  603.     DEC    HL        ; Ok, decrement count in HL
  604.     LD    A,H
  605.     OR    L
  606.     JR    NZ,WAIT10
  607.     POP    IX        ; Done -- restore IX
  608.     POP    DE        ; DE
  609.     POP    BC        ; And BC
  610.     RET
  611. ;
  612. ; Wait milliseconds
  613. ;
  614. MSWAIT:    LD    HL,2
  615.     ADD    HL,SP
  616.     EX    DE,HL        ; Get delay size
  617.     CALL    GETPARM
  618. ;
  619. ; Wait milliseconds in HL
  620. ;
  621. WAITHLMS:
  622.     PUSH    DE
  623. ;
  624. W1MS0:    LD    DE,39 *    CLKSPD
  625. ;
  626. W1MS1:    DEC    DE
  627.     LD    A,D
  628.     OR    E
  629.     JR    NZ,W1MS1
  630.     DEC    HL
  631.     LD    A,H
  632.     OR    L
  633.     JR    NZ,W1MS0
  634.     POP    DE
  635.     RET
  636. ;
  637. ; Get next parameter from (DE) into HL
  638. ;
  639. GETPARM:EX    DE,HL        ; Get address into HL
  640.     LD    E,(HL)        ; Get low
  641.     INC    HL
  642.     LD    D,(HL)        ; Then hihi
  643.     INC    HL        ; Bump for next
  644.     EX    DE,HL        ; Result in HL, address still in DE
  645.     RET
  646. ;
  647.  
  648. ;Get address of user-defined variables
  649.  
  650. GETVARS:
  651.     LD    HL,USERVARS
  652.     RET
  653.  
  654. USERVARS:
  655.     DW    OVERDRIVE    ; .OVR etc. drive/user
  656.     DW    OVERUSER
  657.  
  658.  
  659.      IF    ($-CODEBGN) GT OVSIZE    ;
  660. TOOBIG:    JP    ERRVAL        ; Overlay is too large
  661.      ENDIF
  662. ;
  663.     END
  664.