{$APPTYPE CONSOLE} support added

This commit is contained in:
Владислав Джавадов 2020-12-27 01:34:54 +03:00
parent 9888dd9095
commit b52068a7f2
7 changed files with 26 additions and 25 deletions

View File

@ -3,10 +3,7 @@ program GetCurrentDir;
uses
KolibriOS, CRT;
const
AppPath = PPKolibriChar(32);
CmdLine = PPKolibriChar(28);
const
BUFFER_SIZE = 256;
var
@ -17,7 +14,7 @@ begin
GetCurrentDirectory(Buffer, BUFFER_SIZE);
con_printf('AppPath is "%s"'#10, AppPath^);
con_printf('CmdLine is "%s"'#10, CmdLine^);
con_printf('Application Path is "%s"'#10, AppPath);
con_printf('Command Line is "%s"'#10, CmdLine);
con_printf('Current Directory is "%s"'#10, Buffer);
end.

View File

@ -1,9 +1,10 @@
program Hello;
{$APPTYPE CONSOLE}
uses
CRT;
begin
InitConsole('Hello');
WriteLn('Hello, world!');
end.

View File

@ -3,9 +3,6 @@ program DrawImageApp;
uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
type
THeader = packed record
IDLength: Byte;
@ -59,8 +56,8 @@ var
begin
HeapInit;
ExtractFileDirectory(AppPath^, AppPath^);
SetCurrentDirectory(AppPath^);
ExtractFileDirectory(AppPath, AppPath);
SetCurrentDirectory(AppPath);
TargaFile := LoadFile('Lena.tga', FileSize);

View File

@ -4,8 +4,6 @@ uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
Picture1 = 'Flower(4bpp).bmp';
Picture2 = 'Mario(1bpp).bmp';
Picture3 = 'House(24bpp).bmp';
@ -81,8 +79,8 @@ var
begin
HeapInit;
ExtractFileDirectory(AppPath^, AppPath^);
SetCurrentDirectory(AppPath^);
ExtractFileDirectory(AppPath, AppPath);
SetCurrentDirectory(AppPath);
GetFileAttributes(Picture1, FileAttributes);
BitmapFile1 := HeapAllocate(FileAttributes.Size);

View File

@ -4,8 +4,6 @@ uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
ARROW_BUTTON = 2;
POINT_BUTTON = 3;
WAIT_BUTTON = 4;
@ -74,8 +72,8 @@ var
begin
HeapInit;
ExtractFileDirectory(AppPath^, AppPath^);
SetCurrentDirectory(AppPath^);
ExtractFileDirectory(AppPath, AppPath);
SetCurrentDirectory(AppPath);
ArrowBitmapFile := LoadFile('arrow.bmp', FileSize);
PointBitmapFile := LoadFile('point.bmp', FileSize);

View File

@ -237,6 +237,9 @@ initialization
Pointer(@con_write_asciiz) := GetProcAddress(hConsole, 'con_write_asciiz');
Pointer(@con_write_string) := GetProcAddress(hConsole, 'con_write_string');
if IsConsole then
InitConsole(AppPath);
finalization
if Assigned(con_exit) then
con_exit(CloseWindow);

View File

@ -161,6 +161,7 @@ function _LStrToPChar(const S: KolibriString): PKolibriChar;
var
IOResult: Integer;
Input, Output: Text;
IsConsole: Boolean;
function _Flush(var T: TTextRec): Integer;
procedure __IOTest;
@ -184,6 +185,9 @@ procedure _WriteString(var T: TTextRec; const S: ShortString; Width: LongInt);
procedure _WriteLString(var T: TTextRec; const S: KolibriString; Width: LongInt);
procedure _WriteLn(var T: TTextRec);
var
AppPath, CmdLine: PKolibriChar;
{ Console Library API }
type
@ -493,10 +497,13 @@ end;
initialization
asm // InitFPU
FNINIT
FWAIT
FLDCW Default8087CW
end;
asm // InitFPU
FNINIT
FWAIT
FLDCW Default8087CW
end;
AppPath := PPKolibriChar(32)^;
CmdLine := PPKolibriChar(28)^;
end.