home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Pascal / HISOFTPASCAL2,0-3.DMS / in.adf / Units / Disk.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-05-20  |  2.2 KB  |  134 lines

  1. unit Disk;
  2.  
  3. INTERFACE
  4. uses Exec;
  5.  
  6.  
  7. type
  8.     pDiscResourceUnit = ^tDiscResourceUnit;
  9.     pDiscResource = ^tDiscResource;
  10.     tDiscResource = record
  11.         dr_Library: tLibrary;
  12.         dr_Current: pDiscResourceUnit;
  13.         dr_Flags: byte;
  14.         dr_pad: byte;
  15.         dr_SysLib: pLibrary;
  16.         dr_CiaResource: pLibrary;
  17.         dr_UnitID: array [0..3] of long;
  18.         dr_Waiting: tList;
  19.         dr_DiscBlock: tInterrupt;
  20.         dr_DiscSync: tInterrupt;
  21.         dr_Index: tInterrupt;
  22.         dr_CurrTask: pTask;
  23.         end;
  24.  
  25.     tDiscResourceUnit = record
  26.         dru_Message: tMessage;
  27.         dru_DiscBlock: tInterrupt;
  28.         dru_DiscSync: tInterrupt;
  29.         dru_Index: tInterrupt;
  30.         end;
  31.  
  32.  
  33.  
  34. var
  35.     DiskBase: pDiscResource;
  36.  
  37.  
  38. const
  39.     DRT_150RPM = $AAAAAAAA;
  40.     DRB_ALLOC0 = 0;
  41.     DRB_ALLOC1 = 1;
  42.     DRB_ALLOC2 = 2;
  43.     DRB_ALLOC3 = 3;
  44.     DRF_ALLOC0 = 1;
  45.     DR_ALLOCUNIT = $FFFFFFFA;
  46.     DRF_ALLOC1 = 2;
  47.     DRF_ALLOC2 = 4;
  48.     DR_GETUNITID = $FFFFFFE2;
  49.     DRT_EMPTY = $FFFFFFFF;
  50.     DRF_ALLOC3 = 8;
  51.     DR_LASTCOMM = $FFFFFFDC;
  52.     DR_FREEUNIT = $FFFFFFF4;
  53.     DRB_ACTIVE = 7;
  54.     DSKDMAOFF = $4000;
  55.     DRF_ACTIVE = $80;
  56.     DR_GIVEUNIT = $FFFFFFE8;
  57.     DRT_AMIGA = 0;
  58.     DR_READUNITID = $FFFFFFDC;
  59.     DRT_37422D2S = $55555555;
  60.     DR_GETUNIT = $FFFFFFEE;
  61.     DISKNAME = 'disk.resource';
  62.  
  63.  
  64. function AllocUnit (unitNum: longint): boolean;
  65. procedure FreeUnit (unitNum: longint);
  66. function GetUnit (unitPointer: pDiscResourceUnit): pDiscResourceUnit;
  67. procedure GiveUnit;
  68. function GetUnitID (unitNum: longint): longint;
  69. function ReadUnitID (unitNum: longint): longint;
  70.  
  71.  
  72. IMPLEMENTATION
  73. function AllocUnit; xassembler;
  74. asm
  75.     move.l    a6,-(sp)
  76.     move.l    8(sp),d0
  77.     move.l    DiskBase,a6
  78.     jsr        -6(a6)
  79.     tst.l    d0
  80.     sne        d0
  81.     neg.b    d0
  82.     move.b    d0,$C(sp)
  83.     move.l    (sp)+,a6
  84. end;
  85.  
  86. procedure FreeUnit; xassembler;
  87. asm
  88.     move.l    a6,-(sp)
  89.     move.l    8(sp),d0
  90.     move.l    DiskBase,a6
  91.     jsr        -$C(a6)
  92.     move.l    (sp)+,a6
  93. end;
  94.  
  95. function GetUnit; xassembler;
  96. asm
  97.     move.l    a6,-(sp)
  98.     move.l    8(sp),a1
  99.     move.l    DiskBase,a6
  100.     jsr        -$12(a6)
  101.     move.l    d0,$C(sp)
  102.     move.l    (sp)+,a6
  103. end;
  104.  
  105. procedure GiveUnit; xassembler;
  106. asm
  107.     move.l    a6,-(sp)
  108.     move.l    DiskBase,a6
  109.     jsr        -$18(a6)
  110.     move.l    (sp)+,a6
  111. end;
  112.  
  113. function GetUnitID; xassembler;
  114. asm
  115.     move.l    a6,-(sp)
  116.     move.l    8(sp),d0
  117.     move.l    DiskBase,a6
  118.     jsr        -$1E(a6)
  119.     move.l    d0,$C(sp)
  120.     move.l    (sp)+,a6
  121. end;
  122.  
  123. function ReadUnitID; xassembler;
  124. asm
  125.     move.l    a6,-(sp)
  126.     move.l    8(sp),d0
  127.     move.l    DiskBase,a6
  128.     jsr        -$24(a6)
  129.     move.l    d0,$C(sp)
  130.     move.l    (sp)+,a6
  131. end;
  132.  
  133. end.
  134.