system.pp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by Francesco Lombardi.
  4. System unit for Gameboy Advance
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit System;
  12. interface
  13. {$define __ARM__}
  14. {$define FPC_IS_SYSTEM}
  15. {$define FPC_HAS_FEATURE_THREADING}
  16. {$define FPC_HAS_FEATURE_CONSOLEIO}
  17. {$define FPC_HAS_FEATURE_COMMANDARGS}
  18. {$define FPC_HAS_FEATURE_TEXTIO}
  19. {$define FPC_HAS_FEATURE_FILEIO}
  20. {$i systemh.inc}
  21. {$i gbabiosh.inc}
  22. {$define fpc_softfpu_interface}
  23. {$i softfpu.pp}
  24. {$undef fpc_softfpu_interface}
  25. const
  26. LineEnding = #10;
  27. LFNSupport = true;
  28. CtrlZMarksEOF: boolean = false;
  29. DirectorySeparator = '/';
  30. DriveSeparator = ':';
  31. ExtensionSeparator = '.';
  32. PathSeparator = ';';
  33. AllowDirectorySeparators : set of char = ['\','/'];
  34. AllowDriveSeparators : set of char = [':'];
  35. FileNameCaseSensitive = false;
  36. maxExitCode = 255;
  37. MaxPathLen = 255;
  38. AllFilesMask = '*';
  39. sLineBreak : string[1] = LineEnding;
  40. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
  41. const
  42. UnusedHandle = $ffff;
  43. StdInputHandle = 0;
  44. StdOutputHandle = 1;
  45. StdErrorHandle = $ffff;
  46. var
  47. argc: LongInt = 0;
  48. argv: PPChar;
  49. envp: PPChar;
  50. errno: integer;
  51. fake_heap_end: ^byte; cvar; external;
  52. procedure randomize(value: integer);
  53. implementation
  54. {$define fpc_softfpu_implementation}
  55. {$i softfpu.pp}
  56. {$undef fpc_softfpu_implementation}
  57. { we get these functions and types from the softfpu code }
  58. {$define FPC_SYSTEM_HAS_float64}
  59. {$define FPC_SYSTEM_HAS_float32}
  60. {$define FPC_SYSTEM_HAS_flag}
  61. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  62. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  63. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  64. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  65. {$define FPC_SYSTEM_HAS_extractFloat32Frac}
  66. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  67. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  68. {$i system.inc}
  69. {$i gbabios.inc}
  70. {$ifdef FPC_HAS_FEATURE_PROCESSES}
  71. function GetProcessID: SizeUInt;
  72. begin
  73. end;
  74. {$endif}
  75. {*****************************************************************************
  76. Misc. System Dependent Functions
  77. *****************************************************************************}
  78. procedure System_exit;
  79. begin
  80. end;
  81. {*****************************************************************************
  82. ParamStr/Randomize
  83. *****************************************************************************}
  84. const
  85. QRAN_SHIFT = 15;
  86. QRAN_MASK = ((1 shl QRAN_SHIFT) - 1);
  87. QRAN_MAX = QRAN_MASK;
  88. QRAN_A = 1664525;
  89. QRAN_C = 1013904223;
  90. { set randseed to a new pseudo random value }
  91. procedure randomize();
  92. begin
  93. RandSeed := 63458;
  94. end;
  95. procedure randomize(value: integer);
  96. begin
  97. RandSeed := value;
  98. end;
  99. function random(): integer;
  100. begin
  101. RandSeed := QRAN_A * RandSeed + QRAN_C;
  102. random := (RandSeed shr 16) and QRAN_MAX;
  103. end;
  104. function random(value: integer): integer;
  105. var
  106. a: integer;
  107. begin
  108. RandSeed := QRAN_A * RandSeed + QRAN_C;
  109. a := (RandSeed shr 16) and QRAN_MAX;
  110. random := (a * value) shr 15;
  111. end;
  112. {$ifdef FPC_HAS_FEATURE_COMMANDARGS}
  113. { number of args }
  114. function paramcount : longint;
  115. begin
  116. paramcount:=0;
  117. end;
  118. { argument number l }
  119. function paramstr(l : longint) : string;
  120. begin
  121. paramstr:='';
  122. end;
  123. {$endif}
  124. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  125. procedure SysInitStdIO;
  126. begin
  127. OpenStdIO(Input,fmInput,StdInputHandle);
  128. OpenStdIO(Output,fmOutput,StdOutputHandle);
  129. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  130. end;
  131. {$endif}
  132. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  133. begin
  134. result := stklen;
  135. end;
  136. begin
  137. StackLength := CheckInitialStkLen(InitialStkLen);
  138. StackBottom := StackTop - StackLength;
  139. { OS specific startup }
  140. { Setup heap }
  141. InitHeap;
  142. SysInitExceptions;
  143. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  144. { Setup stdin, stdout and stderr }
  145. SysInitStdIO;
  146. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  147. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  148. { Reset IO Error }
  149. InOutRes:=0;
  150. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  151. {$ifdef FPC_HAS_FEATURE_THREADING}
  152. { threading }
  153. InitSystemThreads;
  154. {$endif FPC_HAS_FEATURE_THREADING}
  155. initvariantmanager;
  156. end.