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-OT05.ZZ0 / ZMO-OT05.Z80
Text File  |  2000-06-30  |  13KB  |  638 lines

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