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 / ZCAT / DISCIOP.Z80 < prev    next >
Text File  |  2000-06-30  |  6KB  |  249 lines

  1. ; DISCIOP.Z80
  2. ;
  3. ;    You can use this to implement an iop recorder that will
  4. ;    record all console output to disc.
  5. ;    You can take one of the sample iop's that are available
  6. ;    and with just a little butchering end up with a console
  7. ;    recorder iop.
  8. ;    ** Be sure to set the high order
  9. ;    bit in the iop's id byte.** 
  10. ;    The 5 equates at the beginning of the code block should
  11. ;    be modified as required to be compatible with the code
  12. ;    you are already using.
  13. ;    i.e. aiobyte should be changed, along with any references
  14. ;    made to it, to whatever your program calls the address
  15. ;    of iobyte.
  16. ;    bel, bdos, eof, and iops should already be defined in
  17. ;    your code. If not, fix this code to be compatible.
  18. ;
  19. ;    This module attempts to first delete, and then create a
  20. ;    file named RECORDER.  When recording is turned on, the
  21. ;    recorder file will be opened on the current default disc
  22. ;    at creation time.
  23. ;
  24. ;    Once recording is on, selecting con device 3 allows
  25. ;    recording.  After that, as long as con device 3 is
  26. ;    selected, all console output will be sent to disc.
  27. ;
  28. ;    Selecting a con device other than 3 will stop output
  29. ;    into the RECORDER file.
  30. ;
  31. ;    Using record to set recording off will the close the
  32. ;    file.
  33. ;
  34. ;    Now for the bad news.......
  35. ;    there is little (and i mean none) error checking in
  36. ;    this code.  I suggest that you add in some.
  37. ;
  38. ;    This code segment, which includes, an fcb, a 147 byte
  39. ;    dos parameter save area, a 128 byte disc buffer, and
  40. ;    a whopping 20 byte stack occupies 659 bytes. I admit
  41. ;    that this is rather tubby.  Feel free to shrink this
  42. ;    further.
  43. ;
  44. ;    THIS IS NOT MEANT TO BE A COMPLETE PACKAGE!
  45. ;    IT IS MEANT TO SERVE AS AN EXAMPLE. I HAVE YET TO SEE
  46. ;    ON ANY OF THE Z-NODES ANY EXAMPLES OF RECORDING
  47. ;    TECHNIQUES. LET ALONE ANY GOOD DOCUMENTATION ON HOW
  48. ;    TO IMPLEMENT IT. (not that this represents good
  49. ;    documentation)
  50. ;
  51. ;    It shouldnt be too much of a problem to fit this into
  52. ;    your iop, at least you get a shot of seeing how its
  53. ;    done. 
  54. ;
  55. ;    This file was assembled with zas 2.4
  56. ;
  57. ;    You can message me on the 24th street exchange
  58. ;    in sacramento calif 916 451 7179
  59. ;    by the way my name is
  60. ;      jeff herr
  61. ;
  62. VERSION EQU 00        ;DATE OF REV 08/30/86        TIME OF REV 10:37:23P  
  63. ;........................disc support............................
  64.     ext    print    ;should be somewhere in your iop code too.
  65. ;
  66. bel    equ    7
  67. bdos    equ    5
  68. eof    equ    1ah
  69. iops    equ    12
  70. aiobyte    equ    3        ;location of iobyte
  71. ;
  72. copen
  73.     ld    hl,(0006)    ;location of dos entry
  74.     ld    de,5        ;offset into dos buffers
  75.     add    hl,de
  76.     ld    (dosadd),hl
  77.     ld    hl,initarea
  78.     ld    b,endinit-initarea
  79.     ld    a,(iopflg)
  80.     or    a
  81.     jr    z,ccopen
  82.     call    print
  83.     db    bel,' [ALREADY ON]  ',0
  84.     ret
  85. ccopen
  86.     ld    (hl),a
  87.     inc    hl
  88.     djnz    ccopen
  89.  
  90.  
  91.     ld    c,25        ;get current disc
  92.     call    bdos        ;will use until next open
  93.     inc    a        ;make it compatable
  94.     ld    (iopfcb),a    ;and place in drivecode byte of fcb
  95.     ld    de,iopfcb
  96.     ld    c,19        ;see if u can delete it
  97.     call    bdos
  98.     ld    de,iopfcb
  99.     ld    c,22        ;create
  100.     call    bdos
  101.     CP    0ffh
  102.     jr    nz,openok
  103.     call    print
  104.     db    bel,'create failure',0
  105.     ret
  106. openok
  107.     ld    e,0ffh
  108.     ld    c,32        ;<---get user
  109.     call    bdos
  110.     ld    (ouruser),a
  111.     ld    hl,iopflg
  112.     ld    (hl),0ffh    ;file is marked open
  113.     inc    hl        ;bump ptr
  114.     LD    (HL),128    ;set to empty buffer
  115.     ld    hl,iopbuf
  116.     ld    (iopptr),hl
  117.     ret
  118. ;
  119. cclose
  120.     ld    a,(iopflg)
  121.     or    a
  122.     jr    nz,ccclose
  123.     call    print
  124.     db    bel,' [ALREADY OFF]  ',0
  125.     ret
  126.  
  127. ccclose
  128.     ld    a,eof
  129.     ld    (closeflg),a
  130.     call    bytewrite
  131.     ld    a,(closeflg)
  132.     or    a
  133.     jr    nz,ccclose
  134.     ld    (iopflg),a
  135.     ret
  136. ;
  137. conrecord
  138.     ld    a,(aiobyte)
  139.     and    3        ;mask all but con: bits
  140.     cp    3        ;check if device 3
  141.     ret    nz        ;if dev not = 3 quit
  142.     ld    a,(iopflg)    ;if record file already open..
  143.     or    a        ;..open=not zero..
  144.     ret    z        ;..then quit
  145.  
  146.     ld    (ostack),sp    ;now were gonna do it
  147.     ld    sp,stack    ;well use about 10 stack entries
  148.     push    af
  149.     push    bc
  150.     push    de
  151.     push    hl
  152.     ld    a,c
  153.     call    bytewrite
  154.     pop    hl
  155.     pop    de
  156.     pop    bc
  157.     pop    af
  158.     ld    sp,(ostack)
  159.     ret
  160. ;
  161. bytewrite
  162.     ld    hl,(iopptr)    ;get the pointer
  163.     ld    (hl),a        ;stash data byte
  164.     inc    hl        ;bump to next output byte
  165.     ld    (iopptr),hl    ;stash it
  166.     ld    a,(iopcnt)    ;get adrs of count
  167.     dec     a
  168.     ld    (iopcnt),a    ;bump it
  169.     ret    nz
  170.  
  171. ;here is the write operation. simple block write.
  172.  
  173.     ld    a,128
  174.     ld    (iopcnt),a    ;set for next time
  175.     ld    hl,iopbuf    ;
  176.     ld    (iopptr),hl    ;set pointer for next time
  177.  
  178.     ld    hl,(dosadd)    ;get pointer to dos
  179.     ld    de,savbuf    ;get pointer to save loc
  180.     ld    bc,147        ;set cnt
  181.     ldir            ;save dos buffers for reentrant ops
  182.  
  183.     ld    c,47        ;<---return dma adrs
  184.     call    bdos        
  185.     ld    (dosptr),hl    ;stash 
  186.  
  187.     ld    de,iopbuf
  188.     ld    c,26        ;<---set dma adrs for our ops
  189.     call    bdos
  190.  
  191.     ld    a,(ouruser)
  192.     ld    e,a
  193.     ld    c,32        ;<---set user for our ops
  194.     call    bdos
  195.  
  196.     ld    de,iopfcb
  197.     ld    c,21        ;<---write
  198.     call    bdos
  199.  
  200.     ld    a,(closeflg)
  201.     or    a
  202.     jr    z,noclose
  203.  
  204.     xor    a
  205.     ld    (closeflg),a
  206.     ld    de,iopfcb
  207.     ld    c,16        ;<---close the file if cclose set the flag
  208.     call    bdos
  209.     
  210. noclose
  211.     ld    de,(dosptr)
  212.     ld    c,26        ;<---restore the old dma adrs
  213.     call    bdos
  214.  
  215.     ld    de,(dosadd)
  216.     ld    hl,savbuf
  217.     ld    bc,147
  218.     ldir
  219.  
  220.     ret
  221. ;
  222. iopflg    db    0        ;Output file opened flag (z=no)
  223. iopcnt    db    0        ;Output char count
  224. iopptr    dw    iopbuf        ;Output char ptr
  225. iopfcb    db    0
  226.     db    'RECORDER   '
  227. initarea
  228.     ds    24,version
  229. closeflg
  230.     db    0
  231. iopbuf    ds    128,version
  232. endinit
  233. dosadd    dw    0    
  234. dosptr    dw    0
  235. ouruser    db    0
  236.     ds    20,version
  237. stack    dw    0
  238. ostack    dw    0
  239. savbuf    ds    147,version
  240. ;    ds    iops*128-$,version
  241.  
  242.     if $ gt iops*128
  243. hoser hoser hoser to large
  244.     endif
  245. ;
  246.     end
  247. ostack    dw    0
  248. savbuf    ds    147,version
  249. ;    ds    iops*