doslib.pp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2004 Karoly Balogh for Genesi S.a.r.l. <www.genesi.lu>
  5. dos.library interface unit for MorphOS/PowerPC
  6. MorphOS port was done on a free Pegasos II/G4 machine
  7. provided by Genesi S.a.r.l. <www.genesi.lu>
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  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. implementation
  37. { * dos stdio definitions
  38. *********************************************************************
  39. * }
  40. function ReadChar: LongInt; Inline;
  41. begin
  42. ReadChar:=FGetC(dosInput);
  43. end;
  44. function WriteChar(ch: Char): LongInt; Inline;
  45. begin
  46. WriteChar:=FPutC(dosOutput,Byte(ch));
  47. end;
  48. function UnReadChar(ch: Char): LongInt; Inline;
  49. begin
  50. UnReadChar:=UnGetC(dosInput,Byte(ch));
  51. end;
  52. function ReadChars(buf: Pointer; num: LongInt): LongInt; Inline;
  53. begin
  54. ReadChars:=FRead(dosInput,buf,1,num);
  55. end;
  56. function dosReadLn(buf: PChar; num: LongInt): PChar; Inline;
  57. begin
  58. dosReadLn:=FGets(dosInput,buf,num);
  59. end;
  60. function WriteStr(str: PChar): LongInt; Inline;
  61. begin
  62. WriteStr:=FPuts(dosOutput,str);
  63. end;
  64. procedure VWritef(format: PChar; argv: Pointer); Inline;
  65. begin
  66. VFWritef(dosOutput,format,argv);
  67. end;
  68. { * dos global definitions (V50)
  69. *********************************************************************
  70. * }
  71. function BADDR(x: LongInt): Pointer; Inline;
  72. begin
  73. BADDR:=Pointer(x Shl 2);
  74. end;
  75. function MKBADDR(x: Pointer): LongInt; Inline;
  76. begin
  77. MKBADDR:=LongInt(x) Shr 2;
  78. end;
  79. begin
  80. DosBase:=MOS_DOSBase;
  81. end.
  82. {
  83. $Log$
  84. Revision 1.2 2004-08-09 00:10:19 karoly
  85. + added most of missing stuff
  86. Revision 1.1 2004/06/26 20:46:17 karoly
  87. * initial revision
  88. }