home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / proasm / routines / doslib.r < prev    next >
Text File  |  1992-10-12  |  3KB  |  138 lines

  1.  
  2. ;---;  doslib.r  ;-------------------------------------------------------------
  3. *
  4. *    ****    DOS LIBRARY OPEN AND CLOSE    ****
  5. *
  6. *    Author        Stefan Walter
  7. *    Version        1.00
  8. *    Last Revision    23.08.92
  9. *    Identifier    dlb_defined
  10. *       Prefix        dlb_    (dos library)
  11. *                 ¯   ¯ ¯
  12. *    Functions    OpenDosLib, GetDosBase, CloseDosLib
  13. *
  14. *    NOTE:        dlb_dosver is -1 if V36+, else 0. Can be used.
  15. *
  16. ;------------------------------------------------------------------------------
  17.  
  18. ;------------------
  19.     ifnd    dlb_defined
  20. dlb_defined    =0
  21.  
  22. ;------------------
  23. dlb_oldbase    equ __base
  24.     base    dlb_base
  25. dlb_base:
  26.  
  27. ;------------------
  28.  
  29. ;------------------------------------------------------------------------------
  30. *
  31. * OpenDosLib    Open dos.library once and use a nesting counter.
  32. *
  33. * RESULT:    d0    Dosbase.
  34. *        a6    Dosbase.
  35. *        ccr    On d0.
  36. *
  37. ;------------------------------------------------------------------------------
  38.  
  39. ;------------------
  40. OpenDosLib:
  41.  
  42. ;------------------
  43. ; Open only if dlb_nestcnt=0.
  44. ;
  45. \open:
  46.     movem.l    d1-a5,-(sp)
  47.     lea    dlb_base(pc),a4
  48.     move.l    dlb_nestcnt(pc),d0
  49.     bne.s    \isopen
  50.     move.l    4.w,a6
  51.     lea    dlb_name(pc),a1
  52.     jsr    -408(a6)        ;OldOpenLibrary()
  53.     move.l    d0,dlb_dosbase(a4)
  54.     beq.s    \isopen
  55.     move.l    d0,a1
  56.     cmp.w    #$24,20(a1)
  57.     sge    dlb_dosver(a4)
  58. \isopen:
  59.     addq.l    #1,dlb_nestcnt(a4)
  60.     move.l    dlb_dosbase(pc),d0
  61.     move.l    d0,a6
  62.     movem.l    (sp)+,d1-a5
  63.     rts
  64.  
  65. ;------------------
  66.  
  67. ;------------------------------------------------------------------------------
  68. *
  69. * GetDosBase    Get dosbase in a6.
  70. *
  71. * RESULT:    a6    Dosbase.
  72. *
  73. ;------------------------------------------------------------------------------
  74.  
  75. ;------------------
  76. GetDosBase:
  77.  
  78. ;------------------
  79. ; Dosbase => a6.
  80. ;
  81. \getbase:
  82.     move.l    dlb_dosbase(pc),a6
  83.     rts
  84.  
  85. ;------------------
  86.  
  87. ;------------------------------------------------------------------------------
  88. *
  89. * CloseDosLib    Close dos.library if dlb_nestcnt gets zero.
  90. *
  91. ;------------------------------------------------------------------------------
  92.  
  93. ;------------------
  94. CloseDosLib:
  95.  
  96. ;------------------
  97. ; Decrease dlb_nestcnt and close library if finished.
  98. ;
  99. \close:
  100.     movem.l    d0-a6,-(sp)
  101.     lea    dlb_nestcnt(pc),a4
  102.     subq.l    #1,(a4)
  103.     bhi.s    \end
  104.     move.l    dlb_dosbase(pc),a1
  105.     move.l    a1,d0
  106.     beq.s    \end
  107.     move.l    4.w,a6
  108.     jsr    -414(a6)        ;CloseLibrary()
  109. \end:
  110.     movem.l    (sp)+,d0-a6
  111.     rts
  112.  
  113. ;------------------
  114.  
  115. ;--------------------------------------------------------------------
  116.  
  117. ;------------------
  118. ; Data for library handling.
  119. ;
  120. dlb_name:    dc.b    "dos.library",0
  121. dlb_dosbase:    dc.l    0
  122. dlb_nestcnt:    dc.l    0
  123. dlb_dosver:    dc.b    0    ;-1 if V36+, else 0
  124.         dc.b    0
  125.  
  126. ;------------------
  127.  
  128. ;--------------------------------------------------------------------
  129.  
  130. ;------------------
  131.     base    dlb_oldbase
  132.  
  133. ;------------------
  134.     endif
  135.  
  136.  end
  137.  
  138.