doslib.pp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2004 Karoly Balogh for Genesi S.a.r.l. <www.genesi.lu>
  4. dos.library interface unit for MorphOS/PowerPC
  5. MorphOS port was done on a free Pegasos II/G4 machine
  6. provided by Genesi S.a.r.l. <www.genesi.lu>
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$INLINE ON}
  14. unit doslib;
  15. interface
  16. uses Exec, Timer;
  17. var
  18. DosBase: Pointer;
  19. {$include doslibd.inc}
  20. {$include doslibf.inc}
  21. { * dos global definitions (V50)
  22. *********************************************************************
  23. * }
  24. function BADDR(x: LongInt): Pointer; Inline;
  25. function MKBADDR(x: Pointer): LongInt; Inline;
  26. { * dos stdio definitions
  27. *********************************************************************
  28. * }
  29. function ReadChar: LongInt; Inline;
  30. function WriteChar(ch: Char): LongInt; Inline;
  31. function UnReadChar(ch: Char): LongInt; Inline;
  32. function ReadChars(buf: Pointer; num: LongInt): LongInt; Inline;
  33. function dosReadLn(buf: PChar; num: LongInt): PChar; Inline;
  34. function WriteStr(str: PChar): LongInt; Inline;
  35. procedure VWritef(format: PChar; argv: Pointer); Inline;
  36. { * calls with tags workarounds (should be removed later)
  37. *********************************************************************
  38. * }
  39. function CreateNewProcTags(tags: array of dword): PProcess; Inline;
  40. implementation
  41. { * dos stdio definitions
  42. *********************************************************************
  43. * }
  44. function ReadChar: LongInt; Inline;
  45. begin
  46. ReadChar:=FGetC(dosInput);
  47. end;
  48. function WriteChar(ch: Char): LongInt; Inline;
  49. begin
  50. WriteChar:=FPutC(dosOutput,Byte(ch));
  51. end;
  52. function UnReadChar(ch: Char): LongInt; Inline;
  53. begin
  54. UnReadChar:=UnGetC(dosInput,Byte(ch));
  55. end;
  56. function ReadChars(buf: Pointer; num: LongInt): LongInt; Inline;
  57. begin
  58. ReadChars:=FRead(dosInput,buf,1,num);
  59. end;
  60. function dosReadLn(buf: PChar; num: LongInt): PChar; Inline;
  61. begin
  62. dosReadLn:=FGets(dosInput,buf,num);
  63. end;
  64. function WriteStr(str: PChar): LongInt; Inline;
  65. begin
  66. WriteStr:=FPuts(dosOutput,str);
  67. end;
  68. procedure VWritef(format: PChar; argv: Pointer); Inline;
  69. begin
  70. VFWritef(dosOutput,format,argv);
  71. end;
  72. { * dos global definitions (V50)
  73. *********************************************************************
  74. * }
  75. function BADDR(x: LongInt): Pointer; Inline;
  76. begin
  77. BADDR:=Pointer(x Shl 2);
  78. end;
  79. function MKBADDR(x: Pointer): LongInt; Inline;
  80. begin
  81. MKBADDR:=LongInt(x) Shr 2;
  82. end;
  83. { * calls with tags workarounds (should be removed later)
  84. *********************************************************************
  85. * }
  86. function CreateNewProcTags(tags: array of DWord): PProcess; Inline;
  87. begin
  88. CreateNewProcTags:=CreateNewProc(@tags);
  89. end;
  90. begin
  91. DosBase:=MOS_DOSBase;
  92. end.