objinc.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {---------------------------------------------------------------------------}
  2. { FileClose -> Platforms DOS - Not checked }
  3. {---------------------------------------------------------------------------}
  4. FUNCTION FileClose(Handle: THandle): word;
  5. begin
  6. asm
  7. xor %bx,%bx
  8. movw handle,%bx
  9. movb $0x3e,%ah
  10. pushl %ebp
  11. intl $0x21
  12. popl %ebp
  13. end;
  14. FileClose := 0;
  15. end;
  16. {---------------------------------------------------------------------------}
  17. { FileOpen -> Platforms DOS - Checked 05May1998 CEC }
  18. { Returns 0 on failure }
  19. {---------------------------------------------------------------------------}
  20. FUNCTION FileOpen (Var FileName: AsciiZ; Mode: Word): THandle;
  21. begin
  22. asm
  23. xorl %eax, %eax
  24. movw %ax, DosStreamError
  25. movl FileName, %edx
  26. xorw %cx,%cx
  27. movw Mode, %ax
  28. pushl %ebp
  29. int $0x21
  30. popl %ebp
  31. jnc .Lexit1
  32. movw %ax, DosStreamError { Hold Error }
  33. xorl %eax, %eax { Open Failed }
  34. .Lexit1:
  35. movw %ax, __RESULT
  36. END;
  37. end;
  38. {---------------------------------------------------------------------------}
  39. { FileRead -> Platforms DOS - Checked 05May1998 CEC }
  40. {---------------------------------------------------------------------------}
  41. FUNCTION FileRead (Handle: THandle; Var Buf; Count: Sw_Word;
  42. Var Actual: Sw_Word): Word;
  43. BEGIN
  44. asm
  45. movl count,%ecx
  46. movl buf,%edx
  47. xorl %ebx,%ebx
  48. movw handle,%bx
  49. movb $0x3f,%ah
  50. int $0x21
  51. jnc .LDOSREAD1
  52. movw %ax,DosStreamError
  53. xorl %eax,%eax
  54. .LDOSREAD1:
  55. end;
  56. Actual:=Count;
  57. FileRead:=DosStreamError;
  58. end;
  59. {---------------------------------------------------------------------------}
  60. { FileWrite -> Platforms DOS - Checked 05May1998 CEC }
  61. {---------------------------------------------------------------------------}
  62. FUNCTION FileWrite (Handle: THandle; Var Buf; Count: Sw_Word; Var Actual: Sw_Word): Word;
  63. BEGIN
  64. Actual:=0;
  65. asm
  66. movl Count,%ecx
  67. movl buf,%edx
  68. xorl %ebx,%ebx
  69. movw Handle,%bx
  70. movb $0x40,%ah
  71. pushl %ebp
  72. int $0x21
  73. pop %ebp
  74. jnc .LDOSWRITE1
  75. movw %ax,DosStreamError
  76. .LDOSWRITE1:
  77. end;
  78. Actual:=Count;
  79. FileWrite:=DosStreamError;
  80. end;
  81. {---------------------------------------------------------------------------}
  82. { SetFileSize -> Platforms DOS - Not Checked }
  83. {---------------------------------------------------------------------------}
  84. FUNCTION SetFileSize (Handle: THandle; FileSize: LongInt): Word;
  85. VAR Actual, Buf: LongInt;
  86. BEGIN
  87. If (Actual = FileSize) Then Begin { No position error }
  88. Actual := FileWrite(Handle, Pointer(@Buf), 0,Actual); { Truncate the file }
  89. If (Actual <> -1) Then SetFileSize := 0 Else { No truncate error }
  90. SetFileSize := 103; { File truncate error }
  91. End Else SetFileSize := 103; { File truncate error }
  92. END;
  93. {***************************************************************************}
  94. { DosSetFilePtr -> Platforms DOS - Checked 05May1998 CEC }
  95. {***************************************************************************}
  96. FUNCTION SetFilePos (Handle: THandle; Pos: LongInt; MoveType: Word;
  97. Var Actual: LongInt): Word;
  98. BEGIN
  99. asm
  100. movw MoveType, %ax; { Load move type }
  101. movb $0x42, %ah;
  102. movl pos, %edx; { Load file position }
  103. andl $0xffff,%edx { Only keep low word }
  104. movl pos, %ecx
  105. shrl $16,%ecx;
  106. movw Handle, %bx; { Load file handle }
  107. pushl %ebp;
  108. int $0x21; { Position the file }
  109. popl %ebp;
  110. jc .Lexit4
  111. movl Actual,%edi { New position address }
  112. movw %ax, %bx;
  113. movw %dx, %ax;
  114. shll $0x10, %eax; { Roll to high part }
  115. movw %bx, %ax;
  116. movl %eax, (%edi); { Update new position }
  117. xorl %eax, %eax;
  118. .Lexit4:
  119. movw %ax, DosStreamError { DOS error returned }
  120. END;
  121. SetFilePos := DosStreamError; { Return any error }
  122. END;