-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPPS.PAS
134 lines (121 loc) · 2.42 KB
/
APPS.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{$IFDEF debug}
{$A+,B-,D+,F+,G+,I+,L+,N+,P+,Q+,R+,S+,V+,X+,Y+}
{$ELSE}
{$A+,B-,D-,F+,G+,I+,L-,N+,P+,Q-,R-,S-,V+,X+,Y-}
{$ENDIF}
unit Apps;
interface
uses
Crt,
Objects,
MemDrv,
KeyDrv,
Dos,
Utils,
MouseDrv;
type
PApplication = ^TApplication;
TApplication = object(TObject)
private
public
Closed: boolean;
InterfaceMemory: longint;
constructor Create(newId: string; interfaceMem: longint);
procedure Init; virtual;
procedure Run; virtual;
procedure Close; virtual;
procedure MainLoop; virtual;
procedure ProcessEvents; virtual;
destructor Done; virtual;
end;
implementation
var
Keyboard: TKeyboardDriver;
constructor TApplication.Create(newId: string; interfaceMem: longint);
begin
InterfaceMemory := interfaceMem;
Id := newId;
Init;
end;
procedure TApplication.Init;
var
{$IFDEF debug}
filename: string;
debugFile: File;
xmsHandle: word;
xmsControl: pointer;
{$ENDIF}
begin
TObject.Init;
TypeName := 'TApplication';
ClrScr;
{$IFDEF debug}
{ Deallocate the last used XMS handle if the program abnormally terminated}
filename := 'XmsDebug.bin';
if FileExists(FileName) then
begin
Assign(debugFile, filename);
Reset(debugFile, 1);
BlockRead(debugFile, xmsHandle, SizeOf(xmsHandle));
System.Close(debugFile);
asm
push es
mov ax, 4310h
int 2Fh
mov word ptr [xmsControl], bx
mov word ptr [xmsControl + 2], es
pop es
end;
asm
mov ah, 0Ah
mov dx, [xmsHandle]
call [XmsControl]
end;
end;
{$ENDIF}
Memory.Create(InterfaceMemory);
WriteLn('Memory manager initialized.');
if (Memory.XmsEnabled) then
begin
WriteLn
(
'XMS memory enabled.',
#10#13,
longint(Memory.LowerMemAvail),
' bytes lower memory available.',
#10#13,
longint(Memory.XmsMemAvail),
' bytes XMS memory available.'
);
end;
InitMouse;
HideMouse;
WriteLn('Mouse initialized.');
{ Keyboard.Create;}
Closed := false;
end;
procedure TApplication.Run;
begin
repeat
ProcessEvents;
MainLoop;
until Closed;
end;
procedure TApplication.ProcessEvents;
begin
end;
procedure TApplication.Close;
begin
Closed := true;
end;
procedure TApplication.MainLoop;
begin
end;
destructor TApplication.Done;
begin
TObject.Done;
Memory.Done;
{ Keyboard.Done;}
while KeyPressed do ReadKey;
end;
end.