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 / BEEHIVE / COMMS / ZMP-OV16.ARC / ZMO-OX04.Z80 < prev    next >
Text File  |  1991-02-02  |  13KB  |  605 lines

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