-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathACK02.PAS
More file actions
311 lines (254 loc) · 6.63 KB
/
ACK02.PAS
File metadata and controls
311 lines (254 loc) · 6.63 KB
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
{$M 50000,280000,640000}
uses xms,overlay,overlay2,u_sound,u_help,u_io,u_vars,
graph,u_graph,u_adv,crt2,dos,u_fonts,u_graps,
o_play0,o_play0a,o_play2,o_play1,o_play3,u_delay2;
{$O o_play3}
{$O o_play2}
{$O o_play1}
{.O o_play0}
{.O o_play0a}
var
savedexitproc:pointer; {for custom exit routine}
{$F+}
function digit(n:byte):char; {digit, convertTOhex, and numtostr}
begin {are used only in converting the}
if n<10 then digit:=chr(ord('0')+n) {run-time error into something that}
else digit:=chr(ord('A')+(n-10)); {can be written to the //LOG.}
end;
function convertTOhex(number:integer):string;
var boofer:array[1..4] of char;
begin
boofer[1]:=digit(hi(number) DIV 16);
boofer[2]:=digit(hi(number) MOD 16);
boofer[3]:=digit(lo(number) DIV 16);
boofer[4]:=digit(lo(number) MOD 16);
convertToHex:=boofer;
end;
function numtostr(number:integer):string;
var s:string;
begin
str(number,s);
numtostr:=s;
end;
procedure CustomExit;
var re:string;
begin
if erroraddr<>NIL then
begin
re:=concat('RUNTIME ERROR ',
numtostr(exitcode)
,
' AT ',
converttohex(seg(erroraddr^)),':',
converttohex(ofs(erroraddr^)));
say(2,2,0,re);erroraddr:=nil;exitcode:=0;readln;
end;
exitproc:=savedexitproc;
end;
procedure Ack_Walk_Server;
var old_rr,rr,xc,yc,xx,yy:byte;
begin
swapinfo^.data[7]:=0;
action_weap:=0;
keybuffer:=false;
arcade:=false;
macroloaded:=0;
macro_teleport:=false;
entrancemacro:=0;
pass_message:=0;block_message:=0;
if ack.anim_speed=0 then animate:=false else animate:=true;
nextanim:=1;anim_phase_one:=true;
rr:=Ack.PLregion;
xc:=Ack.PLxch;yc:=Ack.PLych;
xx:=Ack.PLxloc;yy:=Ack.PLyloc;
old_rr:=0;
readkey_time:=R150;
if arcade then readkey_default:=#255 else
readkey_default:=#1;
if rr=0 then
begin
clearscreen;
say(1,1,0,'THE PLAYER HAS NOT BEEN PLACED');
say(1,11,0,'ON THE MAP. ABORTING...');
say(1,21,1,'PRESS A KEY.');
repeat until readkey<>#0;
halt;
end;
repeat
if brandnewgame then
begin
run_macro(ack.hourmacro);
brandnewgame:=false;
saveconfig;
fullgamesave;
end;
if rr<>0 then
begin
if old_rr<>rr then
begin
lastaggro:=255;
if old_rr<>0 then
begin
ack.criminal:=0;
loadmap(rr);
old_rr:=rr;
case region.shadow of
0,255:ack.viewdistance:=17;
1:if ack.time_cycle=0 then ack.viewdistance:=17 else cycletime;
2..21:ack.viewdistance:=region.shadow - 1;
end;
entrancemacro:=region.room.wallgrap[3]; {new entrance macro: wallgrap 3}
oldtimepic:=99;
end else
begin
entrancemacro:=0;
loadmap(rr);
case region.shadow of
0,255:ack.viewdistance:=17;
2..21:ack.viewdistance:=region.shadow - 1;
1:if ack.time_cycle<>0 then cycletime;
end;
old_rr:=rr;
oldtimepic:=99;
end;
end;
initmouse;
{ stopmusic;}
if region.rooms>20 then
begin
walkworldmap(rr,xc,yc,xx,yy)
end
else if region.rooms>0 then
begin
walkroom(rr,xc,yc,xx,yy);
if rr<>old_rr then savemap;
end;
end;
newwmapload:=true;
until rr=0;
saveconfig;
end;
{$I PTR_PORT.PAS}
var p4ts:^swapinfo_rec absolute f4b;
procedure prerender_dark(dark,back:byte);
var g,x,y:byte;
begin
for g:=0 to 240 do
for x:=1 to 16 do for y:=1 to 16 do
if graphic^[g,x,y]=back then graphicdark^[g,x,y]:=back
else graphicdark^[g,x,y]:=dark;
end;
procedure Ack_Main;
begin
key_report:=false;
for i:=1 to 99 do modified[i]:=false;
if ovrresult<>0 then if ovrresult<>-5 then
writeln('Overlay error: ',ovrresult);
barcolor:=0;
savedexitproc:=exitproc; {Set up for custom exit routine}
exitproc:=@CustomExit;
{ getmem2(pointer(wbuffer),sizeof(windowbuffertype));}
getmem2(pointer(rmcnt), 6400);
getmem2(pointer(graphic2), (GRAPS+1)*256 );
getmem2(pointer(graphicdark), (GRAPS+1)*256 );
{ getmem2(pointer(bank1),64000); }
getmem2(pointer(screenstrip),6400);
getmem2(pointer(locnt), LOCNTMAX * sizeof(loccontrec));
getmem2(pointer(obj), (MAXOBJS+2) * sizeof(objectrec));
getmem2(pointer(wander_index), (WANDERMAX+1) * sizeof(wander_record));
getmem2(pointer(rcrc), (RCMAX+1) * sizeof(rregioncreature));
obj^[0].d[1]:=0; obj^[0].t:=1; {this used to be 255, going to try it as 1}
xinloc:=255;
obj^[xinloc].t:=3;
obj^[xinloc].d[4]:=0;
obj^[xinloc].d[2]:=0;
obj^[xinloc].d[7]:=0;
obj^[xinloc].d[9]:=0;
obj^[xinloc].d[11]:=0;
obj^[xinloc].d[8]:=0;
getmem2(pointer(crc), MAXCRCS * sizeof(creaturerec));
getmem2(pointer(talk), 1001 * sizeof (talkrec) );
getmem2(pointer(macro), 102 * sizeof (macrorec) );
getmem2(pointer(bmptemp), 65080);
if copy(paramstr(4),1,2)<>'CH' then begin;
writeln('ACK v',(ACKVERSION DIV 10),'.',(ACKVERSION MOD 10),
' program file.');
for i:=0 to paramcount do writeln(paramstr(i));writeln;readln;halt;end;
usepointers;
byte4(copy(paramstr(4),3,length(paramstr(4))-2),f4b);
swapinfo:=@p4ts^;
ss:=paramstr(1);
i:=pos('*',ss);
if ss[1]<>'.' then disablemouse:=true;
ADVNAME:=copy(ss,i+1,length(ss)-i);
bgi_dir:=copy(ss,2,i-2);
calibratedelay(bgi_dir+'\SPEED.DAT');
loadconfig;
case ack.hour of
6..9:timephase:=3;
19..22:timephase:=4;
end;
TEXTC0:=ack.textcolors[0];
TEXTC1:=ack.textcolors[1];
TEXTC2:=ack.textcolors[2];
TEXTC4:=ack.textcolors[4];
TEXTC5:=ack.textcolors[5];
TEXTC6:=ack.textcolors[6];
blank0(ack.darkbackground);
doublepass:=false;
helpindex:=2;
u_graph_setup;
graphicsmode;
(* initgraph; {shouldn't need this! } *)
check_requiredfiles;
loadcreatures;loadobjs;
loadgraps2(true);
preparemask;
initmouse;
if swapinfo^.data[3]=1 then
begin
startupgraph;
loadbmppalette(ack.ackversion,ADVNAME,bgi_dir);
initmouse;
end;
if swapinfo^.data[1]=1 then titlebars;
helpfile:=bgi_dir+'\ACKDATA1.HLP';
if swapinfo^.data[1]=1 then
if swapinfo^.data[7]>0 then
begin
run_macro(swapinfo^.data[6]);
swapinfo^.data[1]:=0;
startup_sequence;
ack_walk_server;
halt;
{back into title-screen stream}
end else
begin
MASTERFILE:=TEMPMASTERFILE;
MAPAFILE:='.1';
MAPBFILE:='.2';
MAPCFILE:='.3';
REGIONFILE:='.RGT';
loadconfig;
loadmap(ack.PLregion);
if region.rooms>250 then loadwmap;
run_macro(swapinfo^.data[6]);
swapinfo^.data[1]:=0;
Ack_Walk_Server;
halt;
end;
starting_up_clearscreen:=true;
loadconfig;
(* assign(printer,'PRN');
{$I-} rewrite(printer); {$I+} *)
startup_sequence;
oldhour:=ack.hour;
prerender_dark(ack.darkforeground,ack.darkbackground);
Ack_Walk_Server;
end;
begin
{ ovrinit('ACK02.OVR');}
starting_up_clearscreen:=false;
allowmix;
ack_main;
end.