-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEGATTY.PAS
208 lines (182 loc) · 4.11 KB
/
EGATTY.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
unit EGATTY;
interface
uses
Crt, Objects, Win, TeleType,HistTTY;
type
PEGATTY = ^TEGATTY;
TEGATTY =
object( THistTTY )
constructor Init( R: TRect);
destructor Done; virtual;
procedure Page; virtual;
procedure PaperTop; virtual;
procedure PaperBottom; virtual;
procedure SendLeftMargin; virtual;
procedure SendRightMargin; virtual;
end;
const
len = 255;
Chr : array [char, 1..14] of char = ( {$i FortFnt.Def} );
implementation
uses
TTY;
function RndLeftCh:char;
const
count = 20;
PosibleChars:array[1..count] of char='ÛÛÛÛÛÛÛÛÛÛÛÛÛáããåáãå';
begin
RndLeftCh := PosibleChars[random(count)+1];
end;
function RndRightCh:char;
const
count = 20;
PosibleChars:array[1..count] of char='ÛÛÛÛêêêÛÛÛÛÛââäääæææ';
begin
RndRightCh := PosibleChars[random(count)+1];
end;
procedure SetEGARes; assembler;
asm
mov ax, $1201
mov bl, $30
int $10
mov ax, $0003
int $10
end;
procedure SetVGARes; assembler;
asm
mov ax, $1202
mov bl, $30
int $10
mov ax, $0003
int $10
end;
procedure EnableRAMAccessing; near; assembler;
asm
cli
mov DX, 03C4h
mov AX, 0402h
out DX, AX
mov AX, 0704h
out DX, AX
mov DL, 0CEh
mov AX, 0204h
out DX, AX
mov AX, 0005h
out DX, AX
mov AX, 0006h
out DX, AX
end; { EnableRAMAccessing }
procedure DisableRAMAccessing; near; assembler;
asm
mov DX, 03C4h
mov AX, 0302h
out DX, AX
mov AX, 0304h
out DX, AX
mov DL, 0CEh
mov AX, 0004h
out DX, AX
mov AX, 1005h
out DX, AX
mov AX, 0E06h
out DX, AX
sti
end; { DisableRAMAccessing }
procedure InstallChars;
type
PCharTable = ^TCharTable;
TCharTable = array[char, 0..31] of byte;
var
aux : PCharTable;
i : char;
begin
if IsEGA
then
begin
asm
push BP
mov AX, $1201
mov BL, $30;
int $10
mov AX, $0003
int $10
end;
EnableRAMAccessing;
{$ifndef msdos}
aux := ptr(SegA000, 0);
{$else}
aux := ptr($A000, 0);
{$endif}
for i := #0 to #255 do
move(chr[i], aux^[i], sizeof(chr[i]));
DisableRAMAccessing
end
end;
{ EGATTY }
destructor TEGATTY.Done;
begin
SetVGARes;
THistTTY.Done
end;
constructor TEGATTY.Init;
begin
InstallChars;
THistTTY.Init(R);
SetMaxStrLen(Bounds.B.X -Bounds.A.X - length(prompt) - 4);
end;
procedure TEGATTY.PaperTop;
const
header = 'la fortaleza II';
begin
SetMarginState(mgTop);
SendNewLine;
SetMarginState(mgMiddle);
SendNewLine;
SendNewLine;
{
writeStr( Bounds.B.x - Bounds.A.x - length(header) - 2, whereY, header, cGround );
}
end;
procedure TEGATTY.Page;
begin
{
SetColor;
SendNewLine;
writechar( 2, whereY, Bounds.B.x - Bounds.A.x - 3, 'ú', cHighText );
SendNewLine;
ClrToEol;
}
end;
procedure TEGATTY.SendLeftMargin;
begin
case mgState of
mgTop: writeStr( 1, whereY, 'ƒ', cInv);
mgMiddle: writeStr(1, whereY, RndLeftCh, cInv);
end;
end;
procedure TEGATTY.SendRightMargin;
begin
case mgState of
mgTop: writeStr( Bounds.B.x - 2, whereY, '„…', cInv );
mgMiddle: writeStr( Bounds.B.x - 3, whereY, RndRightCh+' ', cInv );
end;
end;
procedure TEGATTY.PaperBottom;
const
paper : string[30] = 'Š‹ŒŽÛŽŒÛÛŽ‹ŒŽÛŽŽ‹ŒŽŒ';
var
i : byte;
j : byte;
begin
BreakSound;
SendNewLine;
j := succ(random(30));
for i := 1 to Bounds.B.x - Bounds.A.x - 1 do
begin
writechar( i, whereY, 1, paper[j], $7 );
if j < 30
then inc(j)
else j := 1
end;
end;
end.