home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9302 / pastrick / abs_disk.pas next >
Encoding:
Pascal/Delphi Source File  |  1993-02-22  |  3.8 KB  |  157 lines

  1. (* ****************************************************** *)
  2. (*                    ABS_DISK.PAS                        *)
  3. (*            Absolute Disk Read/Write Routinen           *)
  4. (*            (c) 1993 Andres Cvitkovich & DMV            *)
  5. (* ****************************************************** *)
  6. UNIT Abs_Disk;
  7.  
  8. INTERFACE
  9.  
  10. FUNCTION AbsoluteDiskRead(Drive : BYTE; Buffer : Pointer;
  11.                           Sector : LongInt;
  12.                           Sectors : Word) : WORD;
  13. FUNCTION AbsoluteDiskWrite(Drive : BYTE; Buffer : Pointer;
  14.                            Sector : LongInt;
  15.                            Sectors : WORD) : WORD;
  16.  
  17. IMPLEMENTATION
  18.  
  19. TYPE
  20.   DOS4_Packet = RECORD
  21.                   Sector  : LongInt;
  22.                   Sectors : WORD;
  23.                   Address : Pointer
  24.                 END;
  25.   PtrRec      = RECORD
  26.                   Off, Sgm : WORD;
  27.                 END;
  28.   LongRec     = RECORD
  29.                   Lo, Hi : WORD;
  30.                 END;
  31.  
  32. VAR
  33.   DOS4Buffer : DOS4_Packet;
  34.  
  35. CONST
  36.   DosVer : WORD = $0000;
  37.  
  38.  
  39.   FUNCTION AbsoluteDiskRead(Drive : BYTE; Buffer : Pointer;
  40.                             Sector : LongInt;
  41.                             Sectors : WORD) : WORD;
  42.   ASSEMBLER;
  43.   ASM
  44.     PUSH  DS
  45.     MOV   AX, DosVer
  46.     OR    AX, AX
  47.     JNZ   @yet_tested
  48.     MOV   AH, 30h
  49.     INT   21h
  50.     XCHG  AL, AH
  51.     MOV   DosVer, AX
  52.   @yet_tested:
  53.     CMP   AH, 4
  54.     JB    @Dos3
  55.     MOV   AX, LongRec(Sector).Lo
  56.     MOV   LongRec(DOS4Buffer.Sector).Lo, AX
  57.     MOV   AX, LongRec(Sector).Hi
  58.     MOV   LongRec(DOS4Buffer.Sector).Hi, AX
  59.     MOV   AX, Sectors
  60.     MOV   DOS4Buffer.Sectors, AX
  61.     MOV   AX, PtrRec(Buffer).Off
  62.     MOV   PtrRec(DOS4Buffer.Address).Off, AX
  63.     MOV   AX, PtrRec(Buffer).Sgm
  64.     MOV   PtrRec(DOS4Buffer.Address).Sgm, AX
  65.     MOV   CX, 0FFFFh
  66.     MOV   BX, Offset DOS4Buffer
  67.     MOV   AX, Seg DOS4Buffer
  68.     MOV   DS, AX
  69.     JMP   @call_it
  70.   @Dos3:
  71.     MOV   CX, Sectors
  72.     MOV   DX, Word(Sector)
  73.     MOV   BX, PtrRec(Buffer).Off
  74.     MOV   AX, PtrRec(Buffer).Sgm
  75.     MOV   DS, AX
  76.   @call_it:
  77.     XOR   AH, AH
  78.     MOV   AL, Drive
  79.     PUSH  BP
  80.     PUSH  CS
  81.     POP   ES
  82.     MOV   BP,((offset @@buggy)-01Eh)
  83.     INT   25h
  84.     POP   DX
  85.     JC    @@1
  86.     XOR   AX, AX
  87.   @@1:
  88.     POP   BP
  89.     POP   DS
  90.     JMP   @@2
  91.   @@buggy:         { Fehler in DOS 3.1 bis 3.3 ausgleichen }
  92.     DW    0
  93.   @@2:
  94.   END;
  95.  
  96.   FUNCTION AbsoluteDiskWrite(Drive : BYTE; Buffer : Pointer;
  97.                              Sector : LongInt;
  98.                              Sectors : WORD) : WORD;
  99.   ASSEMBLER;
  100.   ASM
  101.     PUSH  DS
  102.     MOV   AX, DosVer
  103.     OR    AX, AX
  104.     JNZ   @yet_tested
  105.     MOV   AH, 30h
  106.     INT   21h
  107.     XCHG  AL, AH
  108.     MOV   DosVer, AX
  109.   @yet_tested:
  110.     CMP   AH, 4
  111.     JB    @Dos3
  112.     MOV   AX, LongRec(Sector).Lo
  113.     MOV   LongRec(DOS4Buffer.Sector).Lo, AX
  114.     MOV   AX, LongRec(Sector).Hi
  115.     MOV   LongRec(DOS4Buffer.Sector).Hi, AX
  116.     MOV   AX, Sectors
  117.     MOV   DOS4Buffer.Sectors, AX
  118.     MOV   AX, PtrRec(Buffer).Off
  119.     MOV   PtrRec(DOS4Buffer.Address).Off, AX
  120.     MOV   AX, PtrRec(Buffer).Sgm
  121.     MOV   PtrRec(DOS4Buffer.Address).Sgm, AX
  122.     MOV   CX, 0FFFFh
  123.     MOV   BX, Offset DOS4Buffer
  124.     MOV   AX, Seg DOS4Buffer
  125.     MOV   DS, AX
  126.     JMP   @call_it
  127.   @Dos3:
  128.     MOV   CX, Sectors
  129.     MOV   DX, Word(Sector)
  130.     MOV   BX, PtrRec(Buffer).Off
  131.     MOV   AX, PtrRec(Buffer).Sgm
  132.     MOV   DS, AX
  133.   @call_it:
  134.     XOR   AH, AH
  135.     MOV   AL, Drive
  136.     PUSH  BP
  137.     PUSH  CS
  138.     POP   ES
  139.     MOV   BP,((Offset @@buggy)-01Eh)
  140.     INT   26h
  141.     POP   DX
  142.     JC    @@1
  143.     XOR   AX, AX
  144.   @@1:
  145.     POP   BP
  146.     POP   DS
  147.     JMP   @@2
  148.   @@buggy:
  149.     DW    0
  150.   @@2:
  151.   END;
  152.  
  153. END.
  154. (* ****************************************************** *)
  155. (*                  Ende von ABS_DISK.PAS                 *)
  156.  
  157.