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-H89.Z80 < prev    next >
Text File  |  1991-02-02  |  14KB  |  628 lines

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ;    Zenith Z89 Overlay for ZMP (Z-Modem Program)
  4. ;
  5. ;    Name    ZMO-H89.Z80
  6. ;
  7. ;    Dated   December 16 1988
  8. ;
  9. ;    Written by -
  10. ;      Ron Murray, c/o Z-Node 62, 061-9-450-0200, Perth, Western Australia.
  11. ;
  12. ;    Modified to ZMP v1.2 standard rjm 15/9/88
  13. ;    Modified to ZMP v1.3 standard rjm 11/10/88
  14. ;    Modified to ZMP v1.4 standard rjm 20/11/88
  15. ;       
  16. ;       This overlay has been modified for the ZENITH Z89 running CP/M 2.23.
  17. ;       using an 8250 UART with built in baud rate generator.
  18. ;       Modified by Malcolm Smith, Murray Bridge, South Australia, 16/12/88
  19. ;
  20. ;-----------------------------------------------------------------------------
  21. ;
  22. ;
  23. ;    System-dependent code overlay for ZMODEM
  24. ;
  25. ;
  26. ;
  27. ;    Insert your own code as necessary in this file. Code contained herein
  28. ; has been written in Z80 code for use with M80 or SLR. Assemble as follows:
  29. ;
  30. ;    SLR ZMO-xx01/h
  31. ;    MLOAD ZMP.COM=ZMODEM.COM,ZMO-xx01.HEX
  32. ; or
  33. ;    M80 =ZMO-xx01.Z80
  34. ;    RELHEX ZMO-xx01
  35. ;    MLOAD ZMP.COM=ZMODEM.COM,ZMO-xx01.HEX
  36. ;
  37. ;
  38. ;       (Don't use L80 without changing the source for assembly as a
  39. ;         cseg file.)
  40. ;
  41. ;-----------------------------------------------------------------------------
  42. ;
  43. ;
  44. ; Notes on modifying this file:
  45. ;
  46. ;    C requires that functions do not change either index register (IX or IY).
  47. ; If your overlay requires either of these to be changed, ensure they are
  48. ; restored to the original values on return.
  49. ;    Since collecting parameters from C functions can be tricky, only change
  50. ; the parts marked 'Insert your own code here'. Do NOT modify the jump
  51. ; table at the start. Do NOT modify the entry/exit sections of each
  52. ; function. Do NOT pass 'GO'. Do NOT collect $200.
  53. ;    Apart from defining modem functions, this file also defines terminal
  54. ; characteristics. Examples provided are for ADM-3A (with a few of my own
  55. ; additions). Modify to suit your own terminal. An inline print routine
  56. ; is provided for printing strings in the usual way: usage is
  57. ;
  58. ;    call    print
  59. ;    db    'required string',0
  60. ;
  61. ;-----------------------------------------------------------------------------
  62. ;
  63. ;
  64. ;    Don't forget to set your clock speed at the clkspd variable.
  65. ;
  66. ;
  67. ;    If you find your overlay exceeds the maximum size (currently 0400h),
  68. ; you will have to contact me for another version. If too many people need 
  69. ; to do it, we haven't allowed enough room.
  70. ;
  71. ; Ron Murray 15/8/88
  72. ;
  73. ;
  74. ;
  75. ;---------------------------------------------------------------------------
  76.  
  77. false    equ    0
  78. true    equ    not false
  79.  
  80. ;------------------------------------------------------------------------------
  81.  
  82. ; Zenith specific equates **********************************
  83.  
  84. port    equ     0d8h         ;Zenith modem port address
  85. mdctl   equ     port+5       ;control port
  86. mddatp  equ     port         ;data port
  87. mdrcv   equ     01h          ;receive ready
  88. mdsnd   equ     20h          ;send ready
  89. mdtxe   equ     60h          ;send buffer empty
  90.  
  91. ; End Zenith equates **************************************
  92.  
  93. ; User-set variables: 
  94.  
  95. clkspd    equ    2        ; Processor clock speed in MHz
  96. debug    equ    false        ; to allow debugging of overlay with Z8E etc.
  97.  
  98. ;Set the following two equates to the drive and user area which will contain
  99. ;   ZMP's .OVR files, .CFG file, .FON file and .HLP file. Set both to zero
  100. ;   (null) to locate them on the drive from which ZMP was invoked.
  101.  
  102. overdrive    equ    'C'    ; Drive to find overlay files on ('A'-'P')
  103. overuser    equ    0    ; User area to find files
  104.  
  105. ;------------------------------------------------------------------------------
  106.  
  107.  
  108. ; NOT user-set variables
  109.  
  110. userdef    equ    0145h        ; origin of this overlay
  111.                 ; This address should not change with
  112.                 ; subsequent revisions.
  113. mspeed    equ    03ch        ; location of current baud rate. 
  114. ovsize    equ    0400h        ; max size of this overlay
  115.  
  116.     .z80            ; use z80 code
  117.     aseg            ; absolute
  118.  
  119.      if    debug
  120.     org    100h        ; so you can debug it with cebug, zsid, etc
  121.      else
  122.     org    userdef
  123.      endif
  124.  
  125.  
  126. esc    equ    1bh
  127. ctrlq    equ    11h
  128. cr    equ    0dh
  129. lf    equ    0ah
  130. bdos    equ    5
  131.  
  132.  
  133. codebgn    equ    $
  134.  
  135. ;Jump table for the overlay: do NOT change this
  136. jump_tab:
  137.     jp    scrnpr        ; screen print
  138.     jp    mrd        ; modem read with timeout
  139.     jp    mchin        ; get a character from modem
  140.     jp    mchout        ; send a character to the modem
  141.     jp    mordy        ; test for tx buffer empty
  142.     jp    mirdy        ; test for character received
  143.     jp    sndbrk        ; send break
  144.     jp    cursadd        ; cursor addressing
  145.     jp    cls        ; clear screen
  146.     jp    invon        ; inverse video on
  147.     jp    invoff        ; inverse video off
  148.     jp    hide        ; hide cursor
  149.     jp    show        ; show cursor
  150.     jp    savecu        ; save cursor position
  151.     jp    rescu        ; restore cursor position
  152.     jp    mint        ; service modem interrupt
  153.     jp    invec        ; initialise interrupt vectors
  154.     jp    dinvec        ; de-initialise interrupt vectors
  155.     jp    mdmerr        ; test uart flags for error
  156.     jp    dtron        ; turn DTR on
  157.     jp    dtroff        ; turn DTR OFF
  158.     jp    init        ; initialise uart
  159.     jp    wait        ; wait seconds
  160.     jp    mswait        ; wait milliseconds
  161.     jp    userin        ; user-defined entry routine
  162.     jp    userout        ; user-defined exit routine
  163.     jp    getvars        ; get system variables
  164.  
  165. ; Spare jumps for compatibility with future versions
  166.     jp    spare        ; spare for later use
  167.     jp    spare        ; spare for later use
  168.     jp    spare        ; spare for later use
  169.     jp    spare        ; spare for later use
  170.     jp    spare        ; spare for later use
  171.     jp    spare        ; spare for later use
  172.  
  173. ;
  174. ; Main code starts here
  175. ;
  176. ;Screen print function
  177. scrnpr:
  178.                 ; <== Insert your own code here
  179.     call    print
  180.     db    'This function not supported.',cr,lf,0
  181.                 ; <== End of your own code
  182. spare:
  183.     ret
  184.  
  185. ; User-defined entry routine: leave empty if not needed
  186. userin:
  187.     ret
  188.  
  189. ; User-defined exit routine: leave empty if not needed
  190. userout:
  191.     ret
  192.  
  193.  
  194. ;Get a character from the modem: return in HL
  195. mchin:
  196.     push    bc
  197.                 ; <== Insert your own code here
  198.  
  199.         in      a,(port)
  200.                 ; <== End of your own code
  201.  
  202.     ld    l,a        ; put in HL
  203.     ld    h,0
  204.     or    a        ; set/clear Z
  205.     pop    bc
  206.     ret
  207.  
  208. ;Send a character to the modem
  209. mchout:
  210.     ld    hl,2        ; get the character
  211.     add    hl,sp
  212.     ld    a,(hl)
  213.                 ; <== Insert your own code here
  214.     out     (port),a          ;send it
  215.                                 ; <== End of your own code
  216.     ret            ; done
  217.  
  218. ;Test for output ready: return TRUE (1) in HL if ok
  219. mordy:
  220.                 ; <== Insert your own code here
  221.         in      a,(mdctl)       ; Get status
  222.         and     20h             ; check out ready
  223.         jp      z,mordf         ; if no then ld hl with 0
  224.         ld      hl,0001h        ; if yes then ld hl with 1 ,exit
  225.         jp      morde
  226. mordf:
  227.         ld      hl,0000h
  228.                                  ; <== End of your own code
  229. morde:
  230.     ld    a,l        ; set/clear Z
  231.     or    a
  232.     ret
  233.  
  234. ;Test for character at modem: return TRUE (1) in HL if so
  235. mirdy:
  236.                 ; <== Insert your own code here
  237.         in      a,(mdctl)       ; get status
  238.         and     01h             ; check recieve ready
  239.         jp      z,mirdf
  240.         ld      hl,0001h
  241.         jp      mirde
  242. mirdf:
  243.         ld      hl,0000h
  244.  
  245. mirde:
  246.     ld    a,l        ; set/clear Z
  247.     or    a
  248.     ret
  249.  
  250. ;Send a break to the modem: leave empty if your system can't do it
  251. sndbrk:
  252.                 ; <== Insert your own code here
  253.  
  254.     ld    hl,300        ; wait 300 mS
  255.     call    waithlms
  256.  
  257.                 ; <== End of your own code
  258.     ret
  259. ;
  260. ;Test UART flags for error: return TRUE (1) in HL if error.
  261. mdmerr:
  262.                 ; <== Insert your own code here
  263.  
  264.                 ; <== End of your own code
  265.     ld    a,l        ; set/clear Z
  266.     or    a
  267.     ret
  268.  
  269.  
  270.  
  271. ;Turn DTR ON
  272. dtron:
  273.                 ; <== Insert your own code here
  274.  
  275.                 ; <== End of your own code
  276.     ret
  277.  
  278.  
  279.  
  280. ;Turn DTR OFF
  281. dtroff:
  282.                 ; <== Insert your own code here
  283.  
  284.  
  285.                 ; <== End of your own code
  286.     ret
  287.  
  288.  
  289.  
  290. ;Initialise the uart
  291.  
  292. init:
  293.  
  294.     ld    hl,2        ; get parameters
  295.     add    hl,sp
  296.     ex    de,hl
  297.     call    getparm        ; in HL
  298.     ld    (brate),hl    ; baud rate
  299.     call    getparm
  300.     ld    (parity),hl    ; parity
  301.     call    getparm
  302.     ld    (data),hl    ; data bits (BINARY 7 or 8)
  303.     call    getparm
  304.     ld    (stop),hl    ; stop bits (BINARY 1 or 2)
  305.  
  306.  
  307.     
  308.  
  309.                       ; <== Insert your own code here
  310.     LD    A,(brate)       ;Get the selected value
  311.     CP    1        ; 300 bps
  312.     JP    Z,OK300
  313.     CP    5        ; 1200 bps
  314.     JP    Z,OK1200
  315.     CP    6        ; 2400 bps
  316.     JP    Z,OK2400
  317.     CP    8        ; 9600 bps
  318.     JP    Z,OK9600
  319.  
  320.  
  321. loadbd: di                      ; Turn off interupts
  322.         xor     a
  323.         out     (port+1),a      ; interupt enable
  324.         ld      a,80h           ; ensure out of mode to set baud
  325.         out     (port+3),a      ; 
  326.         ld      a,l             ; get lsb of baud
  327.         out     (port),a
  328.         ld      a,h             ; get msb of baud
  329.         out     (port+1),a
  330.         ld      a,03h           ; set 8 bit,1 stop,no parity
  331.         out     (port+3),a
  332.         ld      a,01h           ; set dtr to normal
  333.         out     (port+4),a
  334.         ei                      ; restore interupts
  335.         ld      a,(brate)
  336.     ld    (mspeed),a    ; don't forget to load mspeed with the
  337.                 ; current brate value if the new rate is
  338.                 ; valid. See table of values below.
  339.                 ; <== End of your own code
  340.     ret
  341. ;--------------------------------------------------------------------------
  342.  
  343. stop:    dw    1        ; stop bits
  344. parity:    dw    'N'        ; parity
  345. data:    dw    8        ; data bits
  346. brate:    dw    5        ; baud rate:
  347.  
  348. ;--------------------------------------------------------------------------
  349. OK300:    LD    A,1        ; MSPEED 300 baud value
  350.     LD    HL,BD300    ; Get 300 baud parameters in HL
  351.     JP    LOADBD        ; Go load them
  352. ;
  353. OK1200:    LD    A,5
  354.     LD    HL,BD1200
  355.     JP    LOADBD
  356. ;
  357. OK2400:    
  358.     LD    A,6
  359.     LD    HL,BD2400
  360.     JP    LOADBD
  361. ;
  362. OK4800: LD      A,7
  363.         LD      HL,BD4800
  364.         JP      LOADBD
  365. ;
  366. OK9600:    LD    A,8
  367.     LD    HL,BD9600
  368.         JP      LOADBD
  369. ;
  370. OK19200:LD      A,9
  371.         LD      HL,BD19200
  372.         JP      LOADBD
  373. ;
  374. ;Values of brate for each baud rate
  375. ;
  376. ;            multiplier         baud rate    brate
  377. ;
  378.                              ;   110         0
  379. bd300   equ     180h         ;   300         1
  380.                              ;   450         2
  381.                              ;   600         3
  382.                              ;   710         4
  383. bd1200  equ     60h          ;  1200         5
  384. bd2400  equ     30h          ;  2400         6
  385. bd4800  equ     18h          ;  4800         7
  386. bd9600  equ     0ch          ;  9600         8
  387. bd19200 equ     06h          ; 19200         9
  388.                              ; 38400        10
  389.                              ; 57600            11
  390.                              ; 76800            12
  391. ;
  392.  
  393. ;****************************************************************************
  394. ;Video terminal sequences: these are for Zenith Z19/89: Modify as you wish
  395. ;Cursor addressing: 
  396. cursadd:
  397.     ld    hl,2        ; get parameters
  398.     add    hl,sp
  399.     ex    de,hl
  400.     call    getparm        ; in HL
  401.     ld    (row),hl    ; row
  402.     call    getparm
  403.     ld    (col),hl    ; column
  404.                 ; <== Insert your own code here
  405.                 ; using values in row and col
  406.     call    print
  407.     db    esc,'Y',0    ; ADM-3A leadin
  408.     ld    a,(row)        ; row first
  409.     add    a,' '        ; add offset
  410.     call    cout
  411.     ld    a,(col)        ; sane for column
  412.     add    a,' '
  413.     call    cout
  414.                 ; <== end of your own code
  415.     ret
  416.  
  417. row:    ds    2        ; row
  418. col:    ds    2        ; column
  419.  
  420.  
  421. ;Clear screen:
  422. cls:
  423.     call    print
  424.     db    esc,'E',0
  425.     ret
  426.  
  427. ;Inverse video on:
  428. invon:
  429.     call    print
  430.     db    esc,'p',0
  431.     ret
  432.  
  433. ;Inverse video off:
  434. invoff:
  435.     call    print
  436.     db    esc,'q',0
  437.     ret
  438.  
  439. ;Turn off cursor:
  440. hide:
  441.     call    print
  442.     db    esc,'x5',0
  443.     ret
  444.  
  445. ;Turn on cursor:
  446. show:
  447.     call    print
  448.     db    esc,'y5',0
  449.     ret
  450.  
  451. ;Save cursor position:
  452. savecu:
  453.         call    print
  454.         db      esc,'j',0
  455.     ret
  456.  
  457. ;Restore cursor position:
  458. rescu:
  459.         call    print
  460.         db      esc,'k',0
  461.     ret
  462.  
  463. ;****************************************************************************
  464.  
  465. ;Service modem interrupt:
  466. mint:
  467.     ret            ; my system doesn't need this
  468.  
  469. ;Initialise interrupt vectors:
  470. invec:
  471.     ret            ; ditto
  472.  
  473. ;De-initialise interrupt vectors:
  474. dinvec:
  475.     ret            ; ditto
  476.  
  477. ;****************** End of user-defined code ********************************
  478. ;        Do not change anything below here.
  479.  
  480. ;Modem character test for 100 ms
  481. mrd:
  482.     push    bc        ; save bc
  483.     ld    bc,100        ; set limit
  484. mrd1:
  485.     call    mirdy        ; char at modem?
  486.     jr    nz,mrd2        ; yes, exit
  487.     ld    hl,1        ; else wait 1ms
  488.     call    waithlms
  489.     dec    bc        ; loop till done
  490.     ld    a,b
  491.     or    c
  492.     jr    nz,mrd1
  493.     ld    hl,0        ; none there, result=0
  494.     xor    a
  495. mrd2:
  496.     pop    bc
  497.     ret
  498.  
  499. ; Inline print routine: destroys A and HL
  500.  
  501. print:
  502.     ex    (sp),hl        ; get address of string
  503. ploop:
  504.     ld    a,(hl)        ; get next
  505.     inc    hl        ; bump pointer
  506.     or    a        ; done if zero
  507.     jr    z,pdone
  508.     call    cout        ; else print
  509.     jr    ploop        ; and loop
  510. pdone:
  511.     ex    (sp),hl        ; restore return address
  512.     ret            ; and quit
  513.  
  514. ;
  515. ;Output a character in A to the console
  516. ;
  517. cout:
  518.     push    bc        ; save regs
  519.     push    de
  520.     push    hl
  521.     ld    e,a        ; character to E
  522.     ld    c,2
  523.     call    bdos        ; print it
  524.     pop    hl
  525.     pop    de
  526.     pop    bc
  527.     ret
  528.  
  529. ;Wait(seconds)
  530. wait:
  531.     ld    hl,2
  532.     add    hl,sp
  533.     ex    de,hl        ; get delay size
  534.     call    getparm
  535.                 ; fall thru to..
  536. ;Wait seconds in HL
  537. waithls:
  538.     push    bc        ; save bc
  539.     push    de        ; de
  540.     push    ix        ; and ix
  541.     ld    ix,0        ; then point ix to 0
  542.                 ; so we don't upset memory-mapped i/o
  543.  
  544. ;Calculate values for loop constants. Need to have two loops to avoid
  545. ;   16-bit overflow with clock speeds above 9 MHz.
  546.  
  547. outerval    equ    (clkspd / 10) + 1
  548. innerval    equ    (6667 / outerval) * clkspd
  549.  
  550. wait10:
  551.     ld    b,outerval
  552.  
  553. wait11:
  554.     ld    de,innerval
  555.  
  556. wait12:
  557.     bit    0,(ix)        ; time-wasters
  558.     bit    0,(ix)
  559.     bit    0,(ix)        ; 20 T-states each
  560.     bit    0,(ix)
  561.     bit    0,(ix)
  562.     bit    0,(ix)
  563.     dec    de
  564.     ld    a,e
  565.     ld    a,d
  566.     or    e
  567.     jr    nz,wait12    ; 150 T-states per inner loop
  568.     djnz    wait11        ; decrement outer loop
  569.     dec    hl        ; ok, decrement count in hl
  570.     ld    a,h
  571.     or    l
  572.     jr    nz,wait10
  573.     pop    ix        ; done -- restore ix
  574.     pop    de        ; de
  575.     pop    bc        ; and bc
  576.     ret
  577.  
  578. ;Wait milliseconds
  579. mswait:
  580.     ld    hl,2
  581.     add    hl,sp
  582.     ex    de,hl        ; get delay size
  583.     call    getparm
  584.                 ; fall thru to..
  585. ;Wait milliseconds in HL
  586. waithlms:
  587.     push    de
  588. w1ms0:
  589.     ld    de,39 * clkspd
  590. w1ms1:
  591.     dec    de
  592.     ld    a,d
  593.     or    e
  594.     jr    nz,w1ms1
  595.     dec    hl
  596.     ld    a,h
  597.     or    l
  598.     jr    nz,w1ms0
  599.     pop    de
  600.     ret
  601.  
  602. ;Get next parameter from (de) into hl
  603. getparm:
  604.     ex    de,hl        ; get address into hl
  605.     ld    e,(hl)        ; get lo
  606.     inc    hl
  607.     ld    d,(hl)        ; then hi
  608.     inc    hl        ; bump for next
  609.     ex    de,hl        ; result in hl, address still in de
  610.     ret
  611.  
  612. ;Get address of user-defined variables
  613.  
  614. getvars:
  615.     ld    hl,uservars
  616.     ret
  617.  
  618. uservars:
  619.     dw    overdrive    ; .OVR etc. drive/user
  620.     dw    overuser
  621.  
  622.  
  623.      if    ($ - codebgn) gt ovsize
  624. toobig:    jp    errval        ; Overlay too large!
  625.      endif
  626.  
  627.     end
  628.