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-XE05.Z80 < prev    next >
Text File  |  2000-06-30  |  13KB  |  635 lines

  1. ; 89/04/12 - Modified to ZMP v1.5        - George Conover
  2. ; Xerox 820-II mods by David I. Wright   Nov 29, '88
  3. ;              to overlay written by S.V. Hovater
  4. ;              -minor correction to section LOADED:
  5. ;           -enable print screen function
  6. ;           Email: Houston NW Znode 713-937-8886
  7. ;
  8. ; Xerox/Kaypro overlay written by S.V. Hovater            Oct 12, 88
  9. ; 24 Sep 1988  Email: Houston NW Znode 713-937-8886
  10. ;
  11. ; Modified to V1.4 standard by Ken Reid Dec12, 88
  12. ; Modified to v1.3 standard Ron Murray Oct 12, 88
  13. ;
  14. ;-----------------------------------------------------------------------
  15. ;
  16. ;    System-dependent code overlay for ZMODEM
  17. ;
  18. ;   Insert your own code as  necessary    in  this  file.  Code  contained
  19. ; herein  has been written in Z80 code for use with M80 or SLR. Assemble
  20. ; as follows:
  21. ;
  22. ;    SLR ZMO-XE05/h
  23. ;    MLOAD ZMP.COM=ZMODEM.COM,ZMO-XE05.HEX
  24. ;  or
  25. ;    M80 =ZMO-XE05.Z80
  26. ;    RELHEX ZMO-XE05
  27. ;    MLOAD ZMP.COM=ZMODEM.COM,ZMO-XE05.HEX
  28. ;
  29. ;
  30. ; (Don't use L80 without changing the source  for  assembly  as  a  CSEG
  31. ; file.)
  32. ;
  33. ;-----------------------------------------------------------------------
  34. ;
  35. ; Notes on modifying this file:
  36. ;
  37. ;    C    requires  that functions do not change either index register (IX
  38. ; or IY). If your overlay requires either of these to be changed, ensure
  39. ; they are restored to the original values on return.
  40. ;
  41. ;    Since  collecting    parameters  from C functions can be tricky, only
  42. ; change the parts marked 'Insert your own code here'. Do NOT modify the
  43. ; jump table at the start. Do NOT modify the entry/exit sections of each
  44. ; function. Do NOT pass 'GO'. Do NOT collect $200.
  45. ;
  46. ;    Apart  from  defining  modem  functions,  this  file  also  defines
  47. ; terminal characteristics. Examples provided are for ADM-3A (with a few
  48. ; of my own additions). Modify to suit    your  own  terminal.  An  inline
  49. ; print routine is provided for printing strings in the usual way, usage
  50. ; is:
  51. ;
  52. ;              CALL    PRINT
  53. ;              DB    'required string',0
  54. ;
  55. ;-----------------------------------------------------------------------
  56. ;
  57. ;    Don't forget to set your clock speed at the clkspd variable.
  58. ;
  59. ;    If you find  your    overlay  exceeds  the  maximum    size  (currently
  60. ; 0400h),  you    will have to contact me for another version. If too many
  61. ; people need to do it, we haven't allowed enough room.
  62. ;
  63. ; Ron Murray Aug 15, 88
  64. ;
  65. ;-----------------------------------------------------------------------
  66. ;
  67. NO    EQU    0
  68. YES    EQU    NOT NO
  69. ;
  70. ; User-set variables
  71. ;
  72. CLKSPD    EQU    4        ; Processor clock speed in MHz
  73. ;
  74. DEBUG    EQU    NO
  75. ;
  76. OVERDRIVE EQU    'A'         ; Drive that zmp overlays are on
  77. OVERUSER  EQU    0        ; User that zmp overlays are on
  78. ;
  79. USERDEF    EQU    0145H        ; Origin of this overlay.  This address
  80. ;                ;   may change with subsequent revisions
  81. ; NOT user-set variables
  82. ;
  83. MSPEED    EQU    03CH        ; Location of current baud rate. 3CH IS NORMAL
  84. OVSIZE    EQU    0400H        ; Max size of this overlay
  85. ;
  86.     .Z80            ; Use z80 code
  87.     ASEG            ; Absolute
  88. ;
  89.      IF    DEBUG
  90.     ORG    100H        ; So you can debug it with CEBUG, ZSID,
  91. ;                ;   etc.
  92.      ELSE
  93.     ORG    USERDEF
  94.      ENDIF            ; DEBUG
  95. ;
  96. ESC    EQU    1BH
  97. CTRLQ    EQU    11H
  98. CR    EQU    0DH
  99. LF    EQU    0AH
  100. BDOS    EQU    5
  101. ;
  102. PORT    EQU    04H        ; Xerox base port (data or status)
  103. MDCTL1    EQU    PORT+2        ; Modem control port
  104. MDDATP    EQU    PORT        ; Modem data port
  105. MDRCV    EQU    01H        ; Modem receive ready
  106. MDSND    EQU    04H        ; Modem send ready bit
  107. MDTXE    EQU    01H        ; Modem send buffer empty, holding
  108. ;                ;   buffer empty
  109. BRPORT    EQU    00H        ; 8116 port for baudrate
  110. ;
  111. ; Jump table for the overlay: do NOT change this
  112. ;
  113. CODEBGN    EQU    $
  114. ;
  115. JUMPTAB:JP    SCRNPR        ; Screen print
  116.     JP    MRD        ; Modem read with timeout
  117.     JP    MCHIN        ; Get a character from modem
  118.     JP    MCHOUT        ; Send a character to the modem
  119.     JP    MORDY        ; Test for tx buffer empty
  120.     JP    MIRDY        ; Test for character received
  121.     JP    SNDBRK        ; Send break
  122.     JP    CURSADD        ; Cursor addressing
  123.     JP    CLS        ; Clear screen
  124.     JP    INVON        ; Inverse video on
  125.     JP    INVOFF        ; Inverse video off
  126.     JP    HIDE        ; Hide cursor
  127.     JP    SHOW        ; Show cursor
  128.     JP    SAVECU        ; Save cursor position
  129.     JP    RESCU        ; Restore cursor position
  130.     JP    MINT        ; Service modem interrupt
  131.     JP    INVEC        ; Initialise interrupt vectors
  132.     JP    DINVEC        ; De-initialise interrupt vectors
  133.     JP    MDMERR        ; Test uart flags for error
  134.     JP    DTRON        ; Turn DTR on
  135.     JP    DTROFF        ; Turn DTR OFF
  136.     JP    INIT        ; Initialise uart
  137.     JP    WAIT        ; Wait seconds
  138.     JP    MSWAIT        ; Wait milliseconds
  139.     JP    USERIN        ; User-defined entry routine
  140.     JP    USEROUT        ; User-defined exit routine
  141.     JP    GETVARS        ; Get user defined variables
  142.       JP    SETPORT        ; Set port (0 or 1)
  143.     JP    SPARE    
  144.     JP    SPARE        ; Spare for later use
  145.     JP    SPARE        ; Spare for later use
  146.     JP    SPARE        ; Spare for later use
  147.     JP    SPARE        ; Spare for later use
  148.     JP    SPARE        ; Spare for later use
  149. ;
  150. ; Screen print function
  151. ;
  152. SCRNPR:    DS    0    
  153. ;
  154. ; <== Insert your own code here
  155. ;
  156. ;    CALL    PRINT
  157. ;    DB    'This function not supported.',CR,LF,0
  158. ;       
  159. ;      Caution this is a jump into the bios routines of the
  160. ;    Xerox-820II system, delete it out if using this overlay
  161. ;    to modify for another computer system David I. Wright
  162. ;
  163.     JP    0F045H        ; this bios routine will print the 
  164.                 ; screen to the serial printer, my
  165.                 ; bios is modified for two 40 Meg drives
  166.                 ; but this routine should be the same.
  167.                 ; I have not tested this on a normal
  168.                 ; 820-II system, but it should work.
  169.                 ;                David I. Wright 10/29/88
  170. ;
  171. ; <== End of your own code
  172. ;
  173. SPARE:    RET
  174. ;
  175. ; User-defined entry routine
  176. ;
  177. USERIN:    RET
  178. ;
  179. ; User-defined exit routine
  180. ;
  181. USEROUT:RET
  182. ;
  183. ; Get a character from the modem: return in HL
  184. ; It is not necessary to test for status
  185. ;
  186. MCHIN:    PUSH    BC
  187.     IN    A,(MDDATP)    ; Get the character in A
  188. ;
  189.     LD    L,A        ; Put in HL
  190.     LD    H,0
  191.     OR    A        ; Set/clear Z
  192.     POP    BC
  193.     RET
  194. ;
  195. ;Send a character to the modem
  196. ;
  197. MCHOUT:    LD    HL,2        ; Get the character
  198.     ADD    HL,SP
  199.     LD    A,(HL)        ; In A
  200. ;
  201.     PUSH    BC
  202.     LD    C,A
  203. ;
  204. MCHOUT1:IN    A,(MDCTL1)
  205.     AND    MDSND
  206.     JR    Z,MCHOUT1
  207.     LD    A,C
  208.     OUT    (MDDATP),A
  209.     POP    BC
  210. ;
  211.     RET            ; Done
  212. ;
  213. ;Test for output ready: return TRUE (1) in HL if ok
  214. ;
  215. MORDY:    DS    0
  216. ;
  217.     IN    A,(MDCTL1)
  218.     AND    MDTXE
  219.     JR    Z,MORDYX
  220.     LD    L,1
  221.     LD    H,0
  222. ;
  223. MORDYX:    DS    0
  224. ;
  225.     LD    A,L        ; Set/clear Z
  226.     OR    A
  227.     RET
  228. ;
  229. ;Test for character at modem: return TRUE (1) in HL if so
  230. ;
  231. MIRDY:    DS    0
  232. ;
  233.     IN    A,(MDCTL1)
  234.     AND    MDRCV
  235.     JR    Z,MIRDY1
  236.     LD    L,1
  237.     JR    MIRDYX
  238. ;
  239. MIRDY1:    LD    L,0
  240. ;
  241. MIRDYX:    LD    H,00H
  242. ;
  243.     LD    A,L        ; Set/clear Z
  244.     OR    A
  245.     RET
  246. ;
  247. ;Send a break to the modem: leave empty if your system can't do it
  248. ;
  249. SNDBRK:    DS    0
  250. ;
  251.     LD    A,5
  252.     OUT    (MDCTL1),A    ; Send to the status port
  253.     LD    A,0F8H        ; DTR normal, send break tone
  254.     OUT    (MDCTL1),A
  255. ;
  256.     LD    HL,300
  257.     CALL    WAITHLMS    ; Wait 300 milliseconds
  258. ;
  259.     LD    A,5        ; Restore normal, 8 bits, DTR on, etc.
  260.     OUT    (MDCTL1),A
  261.     LD    A,0E8H
  262.     OUT    (MDCTL1),A
  263. ;
  264.     RET
  265. ;
  266. ; Test UART flags for error: return TRUE (1) in HL if error
  267. ;
  268. MDMERR:    DS    0
  269. ;
  270.     LD    A,010H        ; Register 0, reset interrupts
  271.     OUT    (MDCTL1),A
  272.     IN    A,(MDCTL1)
  273. ;
  274.     LD    A,L        ; Set/clear Z
  275.     OR    A
  276.     RET
  277. ;
  278. ; Turn DTR (and optionally RTS) ON
  279. ;
  280. DTRON:    DS    0
  281. ;
  282.     LD    A,05H
  283.     OUT    (MDCTL1),A
  284.     LD    A,0E8H
  285.     OUT    (MDCTL1),A
  286. ;
  287.     RET
  288. ;
  289. ; Turn DTR ( and RTS?) OFF
  290. ;
  291. DTROFF:    DS    0
  292. ;
  293.     LD    A,05H
  294.     OUT    (MDCTL1),A
  295.     LD    A,078H
  296.     OUT    (MDCTL1),A
  297. ;
  298.     RET
  299. ;
  300. ;Initialise the UART
  301. ;
  302. INIT:    LD    HL,2        ; Get parameters
  303.     ADD    HL,SP
  304.     EX    DE,HL
  305.     CALL    GETPARM        ; In HL
  306.     LD    (BRATE),HL    ; Baud rate
  307.     CALL    GETPARM
  308.     LD    (PARITY),HL    ; Parity
  309.     CALL    GETPARM
  310.     LD    (DATA),HL    ; Data bits
  311.     CALL    GETPARM
  312.     LD    (STOP),HL    ; Stop bits
  313. ;
  314.     PUSH    BC
  315.     LD    A,0        ; Select register
  316.     OUT    (MDCTL1),A
  317.     LD    A,018H        ; Throw out of mode
  318.     OUT    (MDCTL1),A
  319.     LD    A,04H        ; Select register
  320.     OUT    (MDCTL1),A
  321.     LD    A,044H        ; Set ASCII parameters (44=1, 4C=2 stop)
  322.     OUT    (MDCTL1),A
  323.     LD    A,03H        ; Select register
  324.     OUT    (MDCTL1),A
  325.     LD    A,0C1H        ; Enable receive
  326.     OUT    (MDCTL1),A
  327.     LD    A,05H        ; Select register
  328.     OUT    (MDCTL1),A
  329.     LD    A,0EAH        ; Enable send, 'DTR', RTS'
  330.     OUT    (MDCTL1),A
  331. ;
  332.         LD    A,(BRATE)    ; minor correction - DIW
  333. ;
  334.     CP    1        ; 300 bps
  335.     JP    Z,OK300
  336.     CP    5        ; 1200 bps
  337.     JP    Z,OK1200
  338.     CP    6        ; 2400 bps
  339.     JP    Z,OK2400
  340.     CP    8        ; 9600 bps
  341.     JP    Z,OK9600
  342.     CP    9        ; 19.2k bps
  343.     JP    Z,OK19200
  344.     JR    SETBRX        ; Not valid
  345. ;
  346. OK300:    LD    A,1        ; MSPEED 300 bps value
  347.     LD    B,BD300
  348.     JP    LOADED
  349. ;
  350. OK1200:    LD    A,5
  351.     LD    B,BD1200
  352.     JP    LOADED
  353. ;
  354. OK2400:    LD    A,6
  355.     LD    B,BD2400
  356.     JP    LOADED
  357. ;
  358. OK9600:    LD    A,8
  359.     LD    B,BD9600
  360.     JP    LOADED
  361. ;
  362. OK19200:LD    A,9
  363.     LD    B,BD19200
  364. ;
  365. LOADED:    LD    (MSPEED),A    ; Change time-to-send baudrate
  366.     LD    A,B
  367.     OUT    (BRPORT),A
  368.     LD    A,(BRATE)    ; Tell zmp it's ok
  369.     LD    (MSPEED),A
  370. ;
  371. SETBRX:    POP    BC
  372. ;
  373.     XOR    A
  374.     LD    (MSPEED),A     ; CLEAR IT
  375. ;
  376.     RET
  377. ;
  378. BD300    EQU    5
  379. BD1200    EQU    7
  380. BD2400    EQU    10
  381. BD9600    EQU    14
  382. BD19200    EQU    15
  383.                 ; Using values below
  384.     RET
  385. ;
  386. BRATE:    DS    2        ; Baud rate:
  387.                 ; 0 = 110 baud    1 = 300 baud    2 = 450 baud
  388.                 ; 3 = 600 baud    4 = 710 baud    5 = 1200 baud
  389.                 ; 6 = 2400 baud 7 = 4800 baud    8 = 9600 baud
  390.                 ; 9 = 19200 baud
  391. PARITY:    DS    2        ; Parity (will be 'N', 'E' or 'O')
  392. DATA:    DS    2        ; Data bits (will be 7 or 8)
  393. STOP:    DS    2        ; Stop bits (will be 1 or 2)
  394. ;
  395. ; Set the port. ZMP supplies either 0 or 1 as a parameter.
  396. ;
  397. setport:
  398.     ld    hl,2        ; get port number
  399.     add    hl,sp
  400.     ex    de,hl
  401.     call    getparm        ; in HL (values are 0 and 1)
  402.  
  403.                 ; <== Insert your own code here
  404.  
  405.                 ; <== End of your own code
  406.     ret
  407. ;
  408. ;-----------------------------------------------------------------------
  409. ;
  410. ; Video terminal sequences: these are for ADM-3A: Modify as you wish
  411. ;
  412. ; Cursor addressing
  413. ;
  414. CURSADD:LD    HL,2        ; Get parameters
  415.     ADD    HL,SP
  416.     EX    DE,HL
  417.     CALL    GETPARM        ; In HL
  418.     LD    (ROW),HL    ; Row
  419.     CALL    GETPARM
  420.     LD    (COL),HL    ; Column
  421. ;
  422. ; <== Insert your own code here, using values in row and column
  423. ;
  424.     CALL    PRINT
  425.     DB    ESC,'=',0    ; ADM-3A leadin
  426.     LD    A,(ROW)        ; Row first
  427.     ADD    A,' '        ; Add offset
  428.     CALL    COUT
  429.     LD    A,(COL)        ; Sane for column
  430.     ADD    A,' '
  431.     CALL    COUT
  432. ;
  433. ; <== end of your own code
  434. ;
  435.     RET
  436. ;
  437. ROW:    DS    2        ; Row
  438. COL:    DS    2        ; Column
  439. ;
  440. ;Clear screen
  441. ;
  442. CLS:    CALL    PRINT
  443.     DB    01AH,0
  444.     RET
  445. ;
  446. ; Inverse video on
  447. ;
  448. INVON:    CALL    PRINT
  449.     DB    ESC,')',0
  450.     RET
  451. ;
  452. ; Inverse video off
  453. ;
  454. INVOFF:    CALL    PRINT
  455.     DB    ESC,'(',0
  456.     RET
  457. ;
  458. ; Turn off cursor
  459. ;
  460. HIDE:    CALL    PRINT
  461.     DB    ESC,'z',0
  462.     RET
  463. ;
  464. ; Turn on cursor
  465. ;
  466. SHOW:    CALL    PRINT
  467.     DB    ESC,'v',0
  468.     RET
  469. ;
  470. ; Save cursor position
  471. ;
  472. SAVECU:    RET
  473. ;
  474. ; Restore cursor position
  475. ;
  476. RESCU:    RET
  477. ;
  478. ;-----------------------------------------------------------------------
  479. ;
  480. ; Service modem interrupt
  481. ;
  482. MINT:    RET            ; My system doesn't need this
  483. ;
  484. ; Initialise interrupt vectors
  485. ;
  486. INVEC:    RET            ; Ditto
  487. ;
  488. ; De-initialise interrupt vectors
  489. ;
  490. DINVEC:    RET            ; Ditto
  491. ;
  492. ;------------------- End of user-defined code --------------------------
  493. ;         Do not change anything below here
  494. ;
  495. ; Modem character test for 100 ms
  496. ;
  497. MRD:    PUSH    BC        ; Save BC
  498.     LD    BC,100        ; Set limit
  499. ;
  500. MRD1:    CALL    MIRDY        ; Char at modem?
  501.     JR    NZ,MRD2        ; Yes, exit
  502.     LD    HL,1        ; Else wait 1 ms
  503.     CALL    WAITHLMS
  504.     DEC    BC        ; Loop till done
  505.     LD    A,B
  506.     OR    C
  507.     JR    NZ,MRD1
  508.     LD    HL,0        ; None there, result=0
  509.     XOR    A
  510. ;
  511. MRD2:    POP    BC
  512.     RET
  513. ;
  514. ; Inline print routine: destroys A and HL
  515. ;
  516. PRINT:    EX    (SP),HL        ; Get address of string
  517. ;
  518. PLOOP:    LD    A,(HL)        ; Get next
  519.     INC    HL        ; Bump pointer
  520.     OR    A        ; Done if zero
  521.     JR    Z,PDONE
  522.     CALL    COUT        ; Else print
  523.     JR    PLOOP        ; And loop
  524. ;
  525. PDONE:    EX    (SP),HL        ; Restore return address
  526.     RET            ; And quit
  527. ;
  528. ; Output a character in A to the console
  529. ;
  530. COUT:    PUSH    BC        ; Save registers
  531.     PUSH    DE
  532.     PUSH    HL
  533.     LD    E,A        ; Character to E
  534.     LD    C,2
  535.     CALL    BDOS        ; Print it
  536.     POP    HL
  537.     POP    DE
  538.     POP    BC
  539.     RET
  540. ;
  541. ; Wait(seconds)
  542. ;
  543. WAIT:    LD    HL,2
  544.     ADD    HL,SP
  545.     EX    DE,HL        ; Get delay size
  546.     CALL    GETPARM
  547. ;                ; Fall thru to...
  548. ; Wait seconds in HL
  549. ;
  550. WAITHLS:PUSH    BC        ; Save BC
  551.     PUSH    DE        ; DE
  552.     PUSH    IX        ; And IX
  553.     LD    IX,0        ; Then point IX to 0
  554. ;                ;   so we don't upset memory-mapped I/O
  555. ;
  556. ; Calculate values for loop constants. Need to have two loops to avoid
  557. ; 16-bit overflow with clock speeds above 9 MHz.
  558. ;
  559. OUTERVAL EQU    (CLKSPD    / 10) +    1
  560. ;
  561. INNERVAL EQU    (6667 /    OUTERVAL) * CLKSPD
  562. ;
  563. WAIT10:    LD    B,OUTERVAL
  564. ;
  565. WAIT11:    LD    DE,INNERVAL
  566. ;
  567. WAIT12:    BIT    0,(IX)        ; Time-wasters
  568.     BIT    0,(IX)
  569.     BIT    0,(IX)        ; 20 T-states each
  570.     BIT    0,(IX)
  571.     BIT    0,(IX)
  572.     BIT    0,(IX)
  573.     DEC    DE
  574.     LD    A,E
  575.     LD    A,D
  576.     OR    E
  577.     JR    NZ,WAIT12    ; 150 T-states per inner loop
  578.     DJNZ    WAIT11        ; Decrement outer loop
  579.     DEC    HL        ; Ok, decrement count in HL
  580.     LD    A,H
  581.     OR    L
  582.     JR    NZ,WAIT10
  583.     POP    IX        ; Done -- restore IX
  584.     POP    DE        ; DE
  585.     POP    BC        ; And BC
  586.     RET
  587. ;
  588. ; Wait milliseconds
  589. ;
  590. MSWAIT:    LD    HL,2
  591.     ADD    HL,SP
  592.     EX    DE,HL        ; Get delay size
  593.     CALL    GETPARM
  594. ;
  595. ; Wait milliseconds in HL
  596. ;
  597. WAITHLMS:
  598.     PUSH    DE
  599. ;
  600. W1MS0:    LD    DE,39 *    CLKSPD
  601. ;
  602. W1MS1:    DEC    DE
  603.     LD    A,D
  604.     OR    E
  605.     JR    NZ,W1MS1
  606.     DEC    HL
  607.     LD    A,H
  608.     OR    L
  609.     JR    NZ,W1MS0
  610.     POP    DE
  611.     RET
  612. ;
  613. ; Get next parameter from (DE) into HL
  614. ;
  615. GETPARM:EX    DE,HL        ; Get address into HL
  616.     LD    E,(HL)        ; Get low
  617.     INC    HL
  618.     LD    D,(HL)        ; Then hihi
  619.     INC    HL        ; Bump for next
  620.     EX    DE,HL        ; Result in HL, address still in DE
  621.     RET
  622. ;
  623. GETVARS: 
  624.     LD    HL,USERVARS
  625.     RET
  626. USERVARS:
  627.     DW    OVERDRIVE
  628.     DW    OVERUSER
  629. ;
  630.      IF    ($ - CODEBGN) GT OVSIZE
  631. TOOBIG:    JP    ERRVAL        ; Overlay is too large
  632.      ENDIF
  633. ;
  634.     END
  635.