Browse Source

+ initialize more stuff in the system unit. Stdio doesn't work yet... :(

git-svn-id: branches/z80@45097 -
nickysn 5 years ago
parent
commit
c343286b3e
1 changed files with 53 additions and 4 deletions
  1. 53 4
      rtl/zxspectrum/system.pp

+ 53 - 4
rtl/zxspectrum/system.pp

@@ -10,6 +10,10 @@ interface
 
 
 {$define HAS_MEMORYMANAGER}
 {$define HAS_MEMORYMANAGER}
 
 
+{ Use Ansi Char for files }
+{$define FPC_ANSI_TEXTFILEREC}
+{$define FPC_STDOUT_TRUE_ALIAS}
+
 {$I systemh.inc}
 {$I systemh.inc}
 {$I tnyheaph.inc}
 {$I tnyheaph.inc}
 
 
@@ -97,10 +101,6 @@ procedure randomize;
 begin
 begin
 end;
 end;
 
 
-procedure SysInitStdIO;
-begin
-end;
-
 function GetProcessID: SizeUInt;
 function GetProcessID: SizeUInt;
 begin
 begin
   GetProcessID:=0;
   GetProcessID:=0;
@@ -237,4 +237,53 @@ begin
   PrintChar(Char(Y-1));
   PrintChar(Char(Y-1));
 end;
 end;
 
 
+{*****************************************************************************
+                         SystemUnit Initialization
+*****************************************************************************}
+
+var
+  ZXHeap: array [0..{1023}255] of Byte;
+
+procedure InitZXHeap;
+begin
+  RegisterTinyHeapBlock_Simple_Prealigned(@ZXHeap[0],SizeOf(ZXHeap));
+end;
+
+procedure SysInitStdIO;
+begin
+(* TODO: doesn't work yet...
+  OpenStdIO(Input,fmInput,StdInputHandle);
+  OpenStdIO(Output,fmOutput,StdOutputHandle);
+  OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
+{$ifndef FPC_STDOUT_TRUE_ALIAS}
+  OpenStdIO(StdOut,fmOutput,StdOutputHandle);
+  OpenStdIO(StdErr,fmOutput,StdErrorHandle);
+{$endif FPC_STDOUT_TRUE_ALIAS}
+*)
+end;
+
+begin
+{  StackBottom := __stkbottom;
+  StackLength := __stktop - __stkbottom;}
+  { To be set if this is a GUI or console application }
+  IsConsole := TRUE;
+{$ifdef FPC_HAS_FEATURE_DYNLIBS}
+  { If dynlibs feature is disabled,
+    IsLibrary is a constant, which can thus not be set to a value }
+  { To be set if this is a library and not a program  }
+  IsLibrary := FALSE;
+{$endif def FPC_HAS_FEATURE_DYNLIBS}
+{ Setup heap }
+  InitZXHeap;
+  SysInitExceptions;
+{$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
+  initunicodestringmanager;
+{$endif def FPC_HAS_FEATURE_UNICODESTRINGS}
+{ Setup stdin, stdout and stderr }
+  SysInitStdIO;
+{ Reset IO Error }
+  InOutRes:=0;
+{$ifdef FPC_HAS_FEATURE_THREADING}
+  InitSystemThreads;
+{$endif}
 end.
 end.