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 / ENTERPRS / CPM / TERMS / RZMP-SRC.LZH / RZMPOVL.MAC < prev   
Text File  |  2000-06-30  |  11KB  |  469 lines

  1. ;
  2. ; System-dependent code / assembly code overlay for RZMP
  3. ;
  4. ;    Insert your own code as necessary in this file. Code contained herein
  5. ; has been written in Z80 code for use with M80. Once assembled,
  6. ; convert to hex with RELHEX and use MLOAD to overlay it over the main
  7. ; RZMPX.COM file to produce your very own RZMP.COM.
  8. ;
  9. ; Notes on modifying this file:
  10. ;    Hi-Tech C requires that functions do not change either index register
  11. ; (IX or IY). If your overlay requires either of these to be changed, ensure
  12. ; they are restored to their original values on return.
  13. ;    Since collecting parameters from C functions can be tricky, only change
  14. ; the parts marked 'Insert your own code here'. Do NOT modify the jump
  15. ; table at the start. Do NOT modify the entry/exit sections of each
  16. ; function. Do NOT pass 'GO'. Do NOT collect $200. You should, however,
  17. ; modify the section marked 'user-set variables' to reflect your system
  18. ; configuration.
  19. ;    This file is derived from the main ZMP installation overlay file, and
  20. ; even contains the same jokes. It has, however, been modified to remove the
  21. ; necessity for modem stuff to be included. These are handled by BYE5 and
  22. ; later: note that BYE must be running for it to work.
  23. ;    Terminal characteristics are also included: these are useful if you are
  24. ; monitoring a call on the remote system. Most have been set up for ADM-3A
  25. ; (with a few of my own additions). Modify to suit your own terminal. An
  26. ; inline print routine is provided for printing strings in the usual way:
  27. ; usage is
  28. ;
  29. ;    call    print
  30. ;    db    'required string',0
  31. ;
  32. ;    If you find your overlay exceeds the maximum size (currently 0400h),
  33. ; you will have to re-compile the whole thing. Good luck. You might try
  34. ; informing us if you need to do this: if too many people need to do it, we
  35. ; haven't allowed enough room.
  36. ;
  37. ; Ron Murray 8/9/88
  38. ;
  39. ;******************************************************************************
  40.  
  41. ;User-set variables:
  42. whladd    equ    03eh        ; Address of wheel byte
  43.                 ; If your system doesn't support a wheel byte
  44.                 ; for system security, set this to point to a
  45.                 ; byte which is permanently zero. All incoming
  46.                 ; callers will then have the same security
  47.                 ; level -- there will be no special features
  48.                 ; for the sysop.
  49. mspeed    equ    03ch        ; Address of mspeed byte
  50.  
  51. ;The following two addresses point to memory which will be incremented on
  52. ; each upload/download. If your system doesn't use this feature, set them
  53. ; to point to 'junk'.
  54. uploads    equ    junk        ; Address of upload count byte
  55. dnloads    equ    junk        ; Address of download count byte
  56.  
  57. defdrv    equ    'B'        ; Default upload du: for non-wheels
  58. defusr    equ    0        ; B0:
  59. logdrv    equ    'B'        ; du: for .LOG file
  60. logusr    equ    14        ; B14:    (not yet implemented)
  61. upridrv    equ    'B'        ; du: for private uploads
  62. upriusr    equ    15        ; B15:
  63. dpridrv    equ    'B'        ; du: for private downloads
  64. dpriusr    equ    14        ; B14:
  65. tempdrv    equ    'E'        ; du: for temporary files (5k max)
  66. tempusr    equ    0        ; E0: (RAM drive if possible)
  67.  
  68. clkspd    equ    4        ; Processor clock speed in MHz
  69.  
  70. ;******************************************************************************
  71.  
  72. ;Don't change the following equates
  73. userdef    equ    0145h        ; origin of this overlay: get this value
  74.                 ; from the .SYM file produced when RZMP.COM
  75.                 ; is linked
  76. ovsize    equ    0400h        ; max size of this overlay
  77.  
  78. ;******************************************************************************
  79.  
  80.     .z80            ; use z80 code
  81.     aseg            ; absolute
  82.  
  83.     org    userdef
  84.  
  85. esc    equ    1bh
  86. ctrlq    equ    11h
  87. cr    equ    0dh
  88. lf    equ    0ah
  89. bdos    equ    5
  90.  
  91. codebgn    equ    $
  92.  
  93. ;Jump table for the overlay: do NOT change this
  94. jump_tab:
  95.     jp    getvars        ; get system variables
  96.     jp    mrd        ; modem read with timeout
  97.     jp    mchin        ; get a character from modem
  98.     jp    mchout        ; send a character to the modem
  99.     jp    mordy        ; test for tx buffer empty
  100.     jp    mirdy        ; test for character received
  101.     jp    sndbrk        ; send break
  102.     jp    cursadd        ; cursor addressing
  103.     jp    cls        ; clear screen
  104.     jp    invon        ; inverse video on
  105.     jp    invoff        ; inverse video off
  106.     jp    hide        ; hide cursor
  107.     jp    show        ; show cursor
  108.     jp    savecu        ; save cursor position
  109.     jp    rescu        ; restore cursor position
  110.     jp    mint        ; service modem interrupt
  111.     jp    invec        ; initialise interrupt vectors
  112.     jp    dinvec        ; de-initialise interrupt vectors
  113.     jp    mdmerr        ; test uart flags for error
  114.     jp    dtron        ; turn DTR on
  115.     jp    dtroff        ; turn DTR OFF
  116.     jp    init        ; initialise uart
  117.     jp    wait        ; wait seconds
  118.     jp    mswait        ; wait milliseconds
  119.     jp    userin        ; user-defined entry routine
  120.     jp    userout        ; user-defined exit routine
  121.  
  122. ;Spares to accommodate future additions
  123.     jp    spare        ; spares for later use
  124.     jp    spare        ; spares for later use
  125.     jp    spare        ; spares for later use
  126.     jp    spare        ; spares for later use
  127.     jp    spare        ; spares for later use
  128.  
  129. ;
  130. ; Main code starts here
  131. ;
  132. ;User-defined entry routine
  133. userin:
  134.     ret
  135.  
  136. ;User-defined exit routine
  137. userout:
  138.     ret
  139.  
  140. ;Bad filetypes: rzmp won't send these unless WHEEL is set. They will be
  141. ;  renamed to .OBJ on receive, also unless WHEEL is set. They can be in upper
  142. ;  or lower case, but must be exactly THREE characters long. A null terminates
  143. ;  the list. There's no limit to the size of the list, consistent with the
  144. ;  maximum overlay size.
  145.  
  146. badtypes:
  147.     db    'com'        ; No .COM files
  148.     db    'env'        ; No ZCPR3 .ENV
  149.     db    'fcp'        ; or .FCP
  150.     db    'iop'        ; or .IOP
  151.     db    'ndr'        ; or .NDR
  152.     db    'rcp'        ; or .RCP
  153.  
  154.     db    0        ; end of list: leave this!
  155.  
  156. ;****************************************************************************
  157. ;Video terminal sequences: these are for ADM-3A: Modify as you wish
  158. ;Cursor addressing: 
  159. cursadd:
  160.     ld    hl,2        ; get parameters
  161.     add    hl,sp
  162.     ex    de,hl
  163.     call    getparm        ; in HL
  164.     ld    (row),hl    ; row
  165.     call    getparm
  166.     ld    (col),hl    ; column
  167.                 ; <== Insert your own code here
  168.                 ; using values in row and col
  169.     call    print
  170.     db    esc,'=',0    ; ADM-3A leadin
  171.     ld    a,(row)        ; row first
  172.     add    a,' '        ; add offset
  173.     call    cout
  174.     ld    a,(col)        ; same for column
  175.     add    a,' '
  176.     call    cout
  177.                 ; <== end of your own code
  178.     ret
  179.  
  180. row:    ds    2        ; row
  181. col:    ds    2        ; column
  182.  
  183.  
  184. ;Clear screen:
  185. cls:
  186.     call    print
  187.     db    01ah,0
  188.     ret
  189.  
  190. ;Inverse video on:
  191. invon:
  192.     call    print
  193.     db    esc,')',0
  194.     ret
  195.  
  196. ;Inverse video off:
  197. invoff:
  198.     call    print
  199.     db    esc,'(',0
  200.     ret
  201.  
  202. ;Turn off cursor:
  203. hide:
  204.     ret
  205.  
  206. ;Turn on cursor:
  207. show:
  208.     ret
  209.  
  210. ;Save cursor position:
  211. savecu:
  212.     ret
  213.  
  214. ;Restore cursor position:
  215. rescu:
  216.     ret
  217.  
  218. ;****************************************************************************
  219.  
  220. ;Service modem interrupt:
  221. mint:
  222.     ret            ; my system doesn't need this
  223.  
  224. ;Initialise interrupt vectors:
  225. invec:
  226.     ret            ; ditto
  227.  
  228. ;De-initialise interrupt vectors:
  229. dinvec:
  230.     ret            ; ditto
  231.  
  232. ;****************** End of user-defined code ********************************
  233. ;*************** Don't change anything below this point *********************
  234.  
  235. spare:
  236.     ret
  237.  
  238. ;Get a character from the modem: return in HL
  239. mchin:
  240.     ld    c,64        ; BYE function 64
  241.     call    bdos
  242.     ld    h,0
  243.     ld    l,a
  244.     or    a
  245.     ret
  246.  
  247. ;Send a character to the modem
  248. mchout:
  249.     ld    hl,2        ; get the character
  250.     add    hl,sp
  251.     ld    e,(hl)
  252.     ld    c,63        ; BYE function 63
  253.     call    bdos
  254.     ret            ; done
  255.  
  256. ;Test for output ready: return TRUE (1) in HL if ok
  257. mordy:
  258.     ld    c,62        ; BYE function 62
  259.     call    bdos
  260.     ld    hl,0        ; assume not ready
  261.     or    a
  262.     jr    z,mordy1
  263.     ld    hl,1        ; ready
  264. mordy1:
  265.     ret
  266.  
  267. ;Test for character at modem: return TRUE (1) in HL if so
  268. mirdy:
  269.     push    bc        ; must save bc for mrd()
  270.     ld    c,61        ; BYE function 61
  271.     call    bdos
  272.     ld    hl,0        ; assume not ready
  273.     or    a
  274.     jr    z,mirdy1
  275.     ld    hl,1
  276. mirdy1:
  277.     pop    bc
  278.     ret
  279.  
  280. ;Send a break to the modem: leave empty if your system can't do it
  281. sndbrk:
  282.     ret            ; It's not going to be easy with BYE
  283.  
  284. ;Test UART flags for error: return TRUE (1) in HL if error
  285. mdmerr:
  286.     ld    hl,0
  287.     xor    a        ; set no error
  288.     ret            ; not used
  289.  
  290. ;Turn DTR ON
  291. dtron:
  292.     ret            ; not used
  293.  
  294. ;Turn DTR OFF
  295. dtroff:
  296.     ret            ; not used
  297.  
  298. ;Initialise the UART
  299. init:
  300.     ret            ; not used
  301.  
  302. ;Return pointer to system variables
  303. getvars:
  304.     ld    hl,sysvars
  305.     ret
  306.  
  307. ;Modem character test for 100 ms
  308. mrd:
  309.     push    bc        ; save bc
  310.     ld    bc,100        ; set limit
  311. mrd1:
  312.     call    mirdy        ; char at modem?
  313.     jr    nz,mrd2        ; yes, exit
  314.     ld    hl,1        ; else wait 1ms
  315.     call    waithlms
  316.     dec    bc        ; loop till done
  317.     ld    a,b
  318.     or    c
  319.     jr    nz,mrd1
  320.     ld    hl,0        ; none there, result=0
  321.     xor    a
  322. mrd2:
  323.     pop    bc
  324.     ret
  325.  
  326. ; Inline print routine: destroys A and HL
  327.  
  328. print:
  329.     ex    (sp),hl        ; get address of string
  330. ploop:
  331.     ld    a,(hl)        ; get next
  332.     inc    hl        ; bump pointer
  333.     or    a        ; done if zero
  334.     jr    z,pdone
  335.     call    cout        ; else print
  336.     jr    ploop        ; and loop
  337. pdone:
  338.     ex    (sp),hl        ; restore return address
  339.     ret            ; and quit
  340.  
  341. ;
  342. ;Output a character in A to the local console only
  343. ;
  344. cout:
  345.     push    bc        ; save regs
  346.     push    de
  347.     push    hl
  348.     ld    e,a        ; character to E
  349.     ld    c,68        ; BYE function 68
  350.     call    bdos        ; print it
  351.     pop    hl
  352.     pop    de
  353.     pop    bc
  354.     ret
  355.  
  356. ;Wait(seconds)
  357. wait:
  358.     ld    hl,2
  359.     add    hl,sp
  360.     ex    de,hl        ; get delay size
  361.     call    getparm
  362.                 ; fall thru to..
  363. ;Wait seconds in HL
  364. waithls:
  365.     push    bc        ; save bc
  366.     push    de        ; de
  367.     push    ix        ; and ix
  368.     ld    ix,0        ; then point ix to 0
  369.                 ; so we don't upset memory-mapped i/o
  370.  
  371. ;Calculate values for loop constants. Need to have two loops to avoid
  372. ;   16-bit overflow with clock speeds above 9 MHz.
  373.  
  374. outerval    equ    (clkspd / 10) + 1
  375. innerval    equ    (6667 / outerval) * clkspd
  376.  
  377. wait10:
  378.     ld    b,outerval
  379.  
  380. wait11:
  381.     ld    de,innerval
  382.  
  383. wait12:
  384.     bit    0,(ix)        ; time-wasters
  385.     bit    0,(ix)
  386.     bit    0,(ix)        ; 20 T-states each
  387.     bit    0,(ix)
  388.     bit    0,(ix)
  389.     bit    0,(ix)
  390.     dec    de
  391.     ld    a,e
  392.     ld    a,d
  393.     or    e
  394.     jr    nz,wait12    ; 150 T-states per inner loop
  395.     djnz    wait11        ; decrement outer loop
  396.     dec    hl        ; ok, decrement count in hl
  397.     ld    a,h
  398.     or    l
  399.     jr    nz,wait10
  400.     pop    ix        ; done -- restore ix
  401.     pop    de        ; de
  402.     pop    bc        ; and bc
  403.     ret
  404.  
  405. ;Wait milliseconds
  406. mswait:
  407.     ld    hl,2
  408.     add    hl,sp
  409.     ex    de,hl        ; get delay size
  410.     call    getparm
  411.                 ; fall thru to..
  412. ;Wait milliseconds in HL
  413. waithlms:
  414.     push    de
  415. w1ms0:
  416.     ld    de,39 * clkspd
  417. w1ms1:
  418.     dec    de
  419.     ld    a,d
  420.     or    e
  421.     jr    nz,w1ms1
  422.     dec    hl
  423.     ld    a,h
  424.     or    l
  425.     jr    nz,w1ms0
  426.     pop    de
  427.     ret
  428.  
  429. ;Get next parameter from (de) into hl
  430. getparm:
  431.     ex    de,hl        ; get address into hl
  432.     ld    e,(hl)        ; get lo
  433.     inc    hl
  434.     ld    d,(hl)        ; then hi
  435.     inc    hl        ; bump for next
  436.     ex    de,hl        ; result in hl, address still in de
  437.     ret
  438.  
  439. ;------------------------------------------------------------------------------
  440.  
  441. ;User variables appear here
  442. sysvars:
  443.     dw    whladd        ; address of wheel byte
  444.     dw    mspeed        ; address of mspeed byte
  445.     dw    uploads        ; address of upload count
  446.     dw    dnloads        ; address of download count
  447.     dw    badtypes    ; bad filetype list
  448.     dw    junk        ; spare
  449.     dw    junk        ; spare
  450.     dw    junk        ; spare
  451.     dw    junk        ; spare
  452.     dw    junk        ; spare
  453.     db    defdrv,defusr    ; default upload du:
  454.     db    logdrv,logusr    ; du: for .LOG files
  455.     db    upridrv,upriusr    ; du: for private uploads
  456.     db    dpridrv,dpriusr    ; du: for private downloads
  457.     db    tempdrv,tempusr    ; du: for temporary files
  458.  
  459. ;------------------------------------------------------------------------------
  460.  
  461. junk:
  462.     ds    2        ; junk bytes: no significance
  463.  
  464.      if    ($ - codebgn) gt ovsize
  465. toobig:    jp    errval        ; Overlay too large!
  466.      endif
  467.  
  468.     end
  469.