-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathU_ADV.PAS
344 lines (283 loc) · 7.69 KB
/
U_ADV.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
{$O+}
unit u_adv;
interface
uses dos, u_delay2;
type string4 = string[4];
string2 = string[2];
const
ACKVERSION:byte=032; {021 = v2.1, 010 = v1.0}
ADVNAME:string='NONAME';
GRAPHICSFILE:string4='.GRP';
FONTFILE:string4='.FNT';
OBJECTFILE:string4='.ITM';
SHORTMSGFILE:string4='.SMS';
SHORTMSGFILE2:string4='.SM2';
{PICTUREMSGFILE:string4='.PMS';}
LONGMSGFILE:string4='.LMS';
DIALOGUEFILE:string4='.DLG';
MOSAICFILE:string4='.MOS';
CREATUREFILE:string4='.PPL';
CREATURESOUNDFILE:string4='.PSF';
MACROFILE:string4='.MCR';
MASTERFILE:string4='.MST';
PLAYMASTERFILE:string4='.PLY';
TEMPMASTERFILE:string4='.TPF';
REGIONFILE:string4='.RGN'; {.RGX,.RGT}
EXCFILE:string4='.EXC';
LISTFILE:string4='.LST';
MAPAFILE:string2='.A'; {.A, .X, .1}
MAPBFILE:string2='.B'; {.B, .Y, .2}
MAPCFILE:string2='.C'; {.C, .Z, .3}
MAPWFILE:string2='.W';
DOCUMENTFILE:string4='.DOC';
TEXTC0:word=15*256;
TEXTC1:word=8*256;
TEXTC2:word=7*256;
TEXTC4:word=8;
TEXTC5:word=7;
TEXTC6:word=15;
type
paletterec=array[1..3] of byte;
var mouseon:boolean;
disablemouse:boolean;
mouseregs:registers;
mousex,mousey:integer;
mouseLB,mouseRB:boolean;
mousekey:char;
nochar:char;
nonum:byte;
mouseactive:boolean;
pausemouse:boolean;
{procedure loadpalette; }
procedure loadbmppalette(version:byte;advname,homedir:string);
procedure initmouse;
procedure closemouse;
procedure restartmouse;
procedure showmouse;
procedure hidemouse;
function mousein(x1,y1,x2,y2:integer):boolean;
function checkmouse(x1,y1,x2,y2,nv,n:integer;var cv:char;c:char):integer;
procedure trackmouse;
procedure delay(d:word);
implementation
procedure loadbmppalette(version:byte;advname,homedir:string);
var bmpf:file of byte;
header:array[1..54] of byte;
pal:array[0..255,0..2] of byte;
b,b2:byte;
w:word;
s1:string[2];
greg:registers;
begin
{
writeln(version);
writeln(advname);
writeln(homedir);
readln;}
assign(bmpf,'PALETTE.BMP');
{$I-} reset(bmpf); {$I+}
if ioresult<>0 then
begin
if version>19 then s1:='2' else s1:='1';
assign(bmpf,homedir+'PALETTE'+s1+'.DAT');
{ writeln(homedir+'PALETTE'+s1+'.DAT'); readln; }
{$I-} reset(bmpf); {$I+}
if ioresult<>0 then exit;
end;
{BlockRead(bmpf,header[1],54);}
seek(bmpf,54);
{w:=header[51];}
{if w=0 then w:=256;}
for b:=0 to 255 do
begin
{ blockread(bmpf,pal[b,2],1);
blockread(bmpf,pal[b,1],1);
blockread(bmpf,pal[b,0],1);
blockread(bmpf,b2,1); }
read(bmpf,pal[b,2]);
read(bmpf,pal[b,1]);
read(bmpf,pal[b,0]);
read(bmpf,b2);
end;
close(bmpf);
for b:=0 to 255 do for b2:=0 to 2 do
pal[b,b2]:=pal[b,b2] SHR 2;
greg.ax:=$1012;
greg.bx:=0;
greg.cx:=256;
greg.es:=seg(pal[0,0]);
greg.dx:=ofs(pal[0,0]);
intr($10,greg);
end;
(*
var
greg:registers;
procedure loadpalette;
var x,y:byte;
pal1:array[0..255] of paletterec;
procedure readyrgbpalette(cc,rr,gg,bb:byte);
begin
{ setrgbpalette(cc,rr,bb,gg);}
pal1[cc,1]:=rr;
pal1[cc,2]:=gg;
pal1[cc,3]:=bb;
end;
begin
greg.ax:=$1017;
greg.bx:=0;
greg.cx:=256;
greg.es:=seg(pal1[0]);
greg.dx:=ofs(pal1[0]);
intr($10,greg);
{greens}
for x:=0 to 7 do
readyrgbpalette(x+32,0,round(63*((x+3)/10)),0);
for x:=8 to 15 do
readyrgbpalette(x+32,round(40/(20-x)),round(230/(20-x)),round(120/(20-x)));
{browns}
readyrgbpalette(15*16+0,62 SHR 2,34 SHR 2,15 SHR 2);
readyrgbpalette(15*16+1,86 SHR 2,47 SHR 2,21 SHR 2);
readyrgbpalette(15*16+2,101 SHR 2,55 SHR 2,25 SHR 2);
readyrgbpalette(15*16+3,121 SHR 2,66 SHR 2,30 SHR 2);
readyrgbpalette(15*16+4,155 SHR 2,85 SHR 2,38 SHR 2);
readyrgbpalette(15*16+5,189 SHR 2,103 SHR 2,47 SHR 2);
for x:=0 to 4 do for y:=3 to 5 do
readyrgbpalette(x+y*16,round(63*(x/4)),0,round(63*((y-2)/3)));
for x:=5 to 10 do for y:=3 to 5 do
readyrgbpalette(x+y*16,round(63*((10-x)/5)),18,round(63*((y-2)/3)));
for x:=11 to 15 do for y:=3 to 5 do
readyrgbpalette(x+y*16,round(63*((x-11)/4)),20,round(63*((y-2)/3)));
for x:=0 to 4 do for y:=2 to 4 do
readyrgbpalette(x+(y+4)*16,round(63*(x/4)),22,round(63*((5-y)/3)));
for x:=5 to 10 do for y:=2 to 4 do
readyrgbpalette(x+(y+4)*16,round(63*((10-x)/5)),35,round(63*((5-y)/3)));
for x:=11 to 15 do for y:=2 to 4 do
readyrgbpalette(x+(y+4)*16,round(63*((x-11)/4)),37,round(63*((5-y)/3)));
for x:=0 to 4 do for y:=3 to 5 do
readyrgbpalette(x+(y+6)*16,round(63*(x/4)),40,round(63*((y-2)/3)));
for x:=5 to 10 do for y:=3 to 5 do
readyrgbpalette(x+(y+6)*16,round(63*((10-x)/5)),52,round(63*((y-2)/3)));
for x:=11 to 15 do for y:=3 to 5 do
readyrgbpalette(x+(y+6)*16,round(63*((x-11)/4)),63,round(63*((y-2)/3)));
for x:=0 to 4 do for y:=2 to 4 do
readyrgbpalette(x+(y+10)*16,round(63*(x/4)) DIV 2,10 DIV 2,round(63*((5-y)/3)) DIV 2);
for x:=5 to 10 do for y:=2 to 4 do
readyrgbpalette(x+(y+10)*16,round(63*((10-x)/5)) DIV 2,35 DIV 2,round(63*((5-y)/3)) DIV 2);
for x:=11 to 15 do for y:=2 to 4 do
readyrgbpalette(x+(y+10)*16,round(63*((x-11)/4)) DIV 2,50 DIV 2,round(63*((5-y)/3)) DIV 2);
greg.ax:=$1012;
greg.bx:=0;
greg.cx:=256;
greg.es:=seg(pal1[0]);
greg.dx:=ofs(pal1[0]);
intr($10,greg);
end;
*)
procedure initmouse;
begin
if pausemouse then exit;
if disablemouse then exit;
mouseregs.ax:=0;
intr($33,mouseregs);
if mouseregs.ax=0 then mouseon:=false else mouseon:=true;
mouseregs.ax:=1;
intr($33,mouseregs);
if mouseon then mouseactive:=true;
end;
procedure closemouse;
begin
if pausemouse then exit;
if disablemouse then exit;
mouseactive:=false;
mouseregs.ax:=0;
intr($33,mouseregs);
mouseregs.ax:=2;
intr($33,mouseregs);
end;
procedure restartmouse;
begin
if pausemouse then exit;
if disablemouse then exit;
mouseactive:=true;
mouseregs.ax:=0;
intr($33,mouseregs);
{ mouseregs.ax:=1;
intr($33,mouseregs); }
end;
procedure showmouse;
begin
if mouseactive then exit;
if pausemouse then exit;
if disablemouse then exit;
mouseactive:=true;
mouseregs.ax:=1;
intr($33,mouseregs);
end;
procedure hidemouse;
begin
if not mouseactive then exit;
if pausemouse then exit;
if disablemouse then exit;
mouseactive:=false;
mouseregs.ax:=2;
intr($33,mouseregs);
end;
{ Checks if mouse has had a button pressed within a certain area }
function mousein;
var answer:boolean;
begin
if not mouseon then begin;mousein:=false;exit;end;
if (mouseLB) = FALSE then mousein:=false else
begin
if (((mousex DIV 8) >= x1) AND ((mousex DIV 8) <= x2) AND
(mousey >= y1) AND (mousey <= y2)) then answer:=true
else answer:=false;
if answer=true then delay(200);
mousein:=answer;
end;
end;
{ Weird function: checks mousein(), and if it returns true, it
will set a number (returned by function) and a character
(in parameter list) to the specified values. }
function checkmouse;
begin
if mousein(x1,y1,x2,y2) then
begin
nv:=n;
cv:=c;
end;
checkmouse:=nv;
end;
procedure trackmouse;
begin
if disablemouse then exit;
if mouseLB then delay(100);
mouseregs.ax:=3;
intr($33,mouseregs);
mousey:=mouseregs.dx;
mousex:=mouseregs.cx;
mouseLB:=((mouseregs.bx AND 1)<>0);
mouseRB:=((mouseregs.bx AND 2)<>0);
end;
procedure delay;
begin
delay2(d);
end;
(*
procedure logentry;
var f:text;i:byte;
begin
assign(f,'ACK.LOG');
{$I-} append(f);{$I+}
if ioresult<>0 then rewrite(f);
write(f,'Entry: ');
for i:=0 to paramcount do write(f,paramstr(i)+' ');writeln(f,'');
close(f);
end;
*)
begin
mouseon:=false;
mouseactive:=false;
pausemouse:=false;
disablemouse:=false;
end.