system.pp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. {$i libch.inc}
  23. {$define fpc_softfpu_interface}
  24. {$i softfpu.pp}
  25. {$undef fpc_softfpu_interface}
  26. const
  27. LineEnding = #10;
  28. LFNSupport = true;
  29. CtrlZMarksEOF: boolean = false;
  30. DirectorySeparator = '/';
  31. DriveSeparator = ':';
  32. ExtensionSeparator = '.';
  33. PathSeparator = ';';
  34. AllowDirectorySeparators : set of char = ['\','/'];
  35. AllowDriveSeparators : set of char = [':'];
  36. FileNameCaseSensitive = false;
  37. maxExitCode = 255;
  38. MaxPathLen = 255;
  39. AllFilesMask = '*';
  40. sLineBreak : string[1] = LineEnding;
  41. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
  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. fake_heap_end: ^byte; cvar; external;
  51. procedure randomize(value: integer);
  52. implementation
  53. {$define fpc_softfpu_implementation}
  54. {$i softfpu.pp}
  55. {$undef fpc_softfpu_implementation}
  56. { we get these functions and types from the softfpu code }
  57. {$define FPC_SYSTEM_HAS_float64}
  58. {$define FPC_SYSTEM_HAS_float32}
  59. {$define FPC_SYSTEM_HAS_flag}
  60. {$define FPC_SYSTEM_HAS_extractFloat64Frac0}
  61. {$define FPC_SYSTEM_HAS_extractFloat64Frac1}
  62. {$define FPC_SYSTEM_HAS_extractFloat64Exp}
  63. {$define FPC_SYSTEM_HAS_extractFloat64Sign}
  64. {$define FPC_SYSTEM_HAS_extractFloat32Frac}
  65. {$define FPC_SYSTEM_HAS_extractFloat32Exp}
  66. {$define FPC_SYSTEM_HAS_extractFloat32Sign}
  67. {$i system.inc}
  68. {$i gbabios.inc}
  69. {$i libc.inc}
  70. {$ifdef FPC_HAS_FEATURE_PROCESSES}
  71. function GetProcessID: SizeUInt;
  72. begin
  73. GetProcessID := 0;
  74. end;
  75. {$endif}
  76. {*****************************************************************************
  77. Misc. System Dependent Functions
  78. *****************************************************************************}
  79. procedure System_exit;
  80. begin
  81. end;
  82. {*****************************************************************************
  83. ParamStr/Randomize
  84. *****************************************************************************}
  85. const
  86. QRAN_SHIFT = 15;
  87. QRAN_MASK = ((1 shl QRAN_SHIFT) - 1);
  88. QRAN_MAX = QRAN_MASK;
  89. QRAN_A = 1664525;
  90. QRAN_C = 1013904223;
  91. { set randseed to a new pseudo random value }
  92. procedure randomize();
  93. begin
  94. RandSeed := 63458;
  95. end;
  96. procedure randomize(value: integer);
  97. begin
  98. RandSeed := value;
  99. end;
  100. function random(): integer;
  101. begin
  102. RandSeed := QRAN_A * RandSeed + QRAN_C;
  103. random := (RandSeed shr 16) and QRAN_MAX;
  104. end;
  105. function random(value: integer): integer;
  106. var
  107. a: integer;
  108. begin
  109. RandSeed := QRAN_A * RandSeed + QRAN_C;
  110. a := (RandSeed shr 16) and QRAN_MAX;
  111. random := (a * value) shr 15;
  112. end;
  113. {$ifdef FPC_HAS_FEATURE_COMMANDARGS}
  114. { number of args }
  115. function paramcount : longint;
  116. begin
  117. paramcount:=0;
  118. end;
  119. { argument number l }
  120. function paramstr(l : longint) : string;
  121. begin
  122. paramstr:='';
  123. end;
  124. {$endif FPC_HAS_FEATURE_COMMANDARGS}
  125. {$ifdef FPC_HAS_FEATURE_TEXTIO}
  126. procedure SysInitStdIO;
  127. begin
  128. OpenStdIO(Input,fmInput,StdInputHandle);
  129. OpenStdIO(Output,fmOutput,StdOutputHandle);
  130. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  131. end;
  132. {$endif FPC_HAS_FEATURE_TEXTIO}
  133. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  134. begin
  135. result := stklen;
  136. end;
  137. begin
  138. StackLength := CheckInitialStkLen(InitialStkLen);
  139. StackBottom := StackTop - StackLength;
  140. { OS specific startup }
  141. { Setup heap }
  142. InitHeap;
  143. SysInitExceptions;
  144. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  145. { Setup stdin, stdout and stderr }
  146. SysInitStdIO;
  147. { Reset IO Error }
  148. InOutRes:=0;
  149. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  150. {$ifdef FPC_HAS_FEATURE_THREADING}
  151. { threading }
  152. InitSystemThreads;
  153. {$endif FPC_HAS_FEATURE_THREADING}
  154. initvariantmanager;
  155. end.