-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathU_VARS.PAS
250 lines (211 loc) · 5.54 KB
/
U_VARS.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
{$O+}
unit U_vars;
interface
uses u_adv;
const
MAXOBJS = 254; {255 is a creature, 0 is nil}
MAXCRCS=128; {was 64, so there are now 64 more}
type objnamestype=array[1..12] of string[13];
const OBJNAMES:objnamestype = ('SPACE ',
'SPACE* ','OBSTACLE ','OBSTACLE* ',
'PORTAL ','MISC. ITEM ',
'WEAPON ','RANGED WEAPON','ARMOR ',
'VEHICLE ','SPELL/SKILL ','CURRENCY ');
type
LocPointer = word;
LParray = array[1..80,1..40] of LocPointer;
Objectrec = RECORD
n:string[16];
t:byte;
d:array[1..14] of byte;
END;
Objectarray = array[0..0] of Objectrec;
excrec = RECORD
fn:string[12];
prm:string[30];
gmodein,gmodeout:byte;
c1,c2,c3,c4:byte;
end;
creaturerec = record
n:string[16]; {name}
t:byte; {type, or alignment}
exphi,g1,g2,g3,g4,t1,h,hm,m,mm, {size, graphics(4), type subset,
hitpoints, magicpoints}
touchm,deathm,ws,rws,exp,veh,fw,fr,ar:byte; {str, death macro, weapSk, RweapSk,
experience, vehicle, weapon, rweapon,
armor}
inv:array[1..3] of byte;
invn:array[1..3] of byte;
end;
crcarray=array[1..1] of creaturerec;
Portdestrec = RECORD
region,rx,ry,x,y:byte; {rx is used for room}
used:boolean;
END;
Roomsrec = RECORD
case boolean of
true:(
Name: array[1..16] of string[20];
x1,y1,x2,y2: array[1..16] of byte;
wallgrap: array[1..16] of byte;
wmap:array[1..32,1..32] of byte;
cells:byte; {cells in wmap}
)
END;
Regionrec = RECORD
shadow:byte;
Name: string[30];
rooms:byte; {255 for worldmap}
room:roomsrec;
port:array[1..255] of portdestrec; {portal destinations, 0 is a 2way door}
END;
Loccontrec = RECORD
obj, objcode: byte;
p:locpointer;
END;
LCRarray = array[1..1] of Loccontrec;
Shortmsgrec = RECORD
empty:boolean;
chars:array[1..2] of string[40];
attrs:array[1..2,1..37] of byte;
END;
Longmsgrec = RECORD
empty:boolean;
chars:array[1..22] of string[40];
attrs:array[1..22,1..32] of byte;
END;
Talkrec = RECORD
headertype:byte;
header:string[8];
datatype:byte;
data:string[30];
next:word;
END;
talkarray = array[1..1] of talkrec;
mosaicrec = array[1..16,1..11] of byte;
var
crcsounds:array[1..MAXCRCS] of word; {hi: hostile lo: dying}
shortmsg:shortmsgrec;
longmsg:longmsgrec;
talk:^talkarray;
mosaic:mosaicrec;
region:regionrec;
rmcnt:^LParray; { rmcnt^[10,10] := 1234; }
locnt:^LCRarray; { locnt^[187].obj := 12; }
obj:^Objectarray;
procedure load_objs;
procedure save_shortmsgfile(mn:word);
procedure clear_shortmsg;
procedure load_shortmsgfile(mn:word);
procedure cycle(var v:byte;min,max:word;stepp:integer);
procedure getmem2(var varpointer:pointer;varsize:word);
implementation
procedure load_objs;
var f:file of objectrec;
fc:byte;
begin
assign(f,concat(ADVNAME,OBJECTFILE));
{$I-} reset(f); {$I+}
if IoResult<>0 then exit;
for fc:=1 to MAXOBJS do read(f,obj^[fc]);
close(f);
end;
procedure save_shortmsgfile(mn:word);
var f:file of shortmsgrec;
begin
if mn>255 then
begin
mn:=mn-255;
assign(f,ADVNAME+SHORTMSGFILE2);
end
else assign(f,ADVNAME+SHORTMSGFILE);
{$I-} reset(f); {$I+}
if ioresult<>0 then exit;
shortmsg.empty:=false;
seek(f,mn-1);
write(f,shortmsg);
close(f);
end;
procedure clear_shortmsg;
var i1:integer;
begin
shortmsg.empty:=true;
shortmsg.chars[1]:='';
for i1:=1 to 37 do
begin
shortmsg.attrs[1,i1]:=0;shortmsg.attrs[2,i1]:=0;
shortmsg.chars[1]:=concat(shortmsg.chars[1],#1);
end;
shortmsg.chars[2]:=shortmsg.chars[1];
end;
procedure create_shortmsgfile;
var i,i1:byte;
f:file of shortmsgrec;
begin
assign(f,ADVNAME+SHORTMSGFILE);
{$I-} rewrite(f); {$I+}
if ioresult<>0 then exit;
clear_shortmsg;
write(f,shortmsg);
close(f);
end;
procedure create_shortmsgfile2;
var i:word;
f:file of shortmsgrec;
begin
assign(f,ADVNAME+SHORTMSGFILE2);
{$I-} rewrite(f); {$I+}
{if ioresult<>0 then exit;}
clear_shortmsg;
for i:=1 to 745 do write(f,shortmsg);
close(f);
end;
procedure load_shortmsgfile(mn:word);
var f:file of shortmsgrec;
begin
if (mn=0) or (mn>1000) then exit;
if mn>255 then
begin
assign(f,ADVNAME+SHORTMSGFILE2);
{$I-} reset(f); {$I+}
if ioresult<>0 then begin;create_shortmsgfile2;exit;end;
seek(f,mn-256);
end else
begin
assign(f,ADVNAME+SHORTMSGFILE);
{$I-} reset(f); {$I+}
if ioresult<>0 then begin;create_shortmsgfile;exit;end;
if filesize(f)>=mn then seek(f,mn-1);
end;
read(f,shortmsg);
close(f);
end;
procedure cycle;
begin
v:=v+stepp;if v>max then v:=min;if v<min then v:=max;
end;
procedure getmem2;
var ft:text;
begin
if maxavail>=varsize then
getmem(varpointer,varsize) else
begin
assign(ft,'CON');
rewrite(ft);
writeln('Not enough memory!');
close(ft);
halt;
end;
end;
begin
{each region gets one of these, in a file. The file on disk
is only as big as needs be. The 2nd one may expand or contract
during use, however.}
(*
getmem(talk, 256 * sizeof (talkrec) );
getmem(picture, sizeof(picturerec)+1 );
getmem(rmcnt, 80*40 * sizeof( LocPointer ) );
getmem(locnt, 2560 * sizeof( LocContRec ) );
getmem(obj, MAXOBJS * sizeof ( Objectrec ) );
*) {copy these into program as needed}
end.