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-HP12.Z80 < prev    next >
Text File  |  2000-06-30  |  14KB  |  640 lines

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