Advertisement
nnevatie

Paybacktime 2 / Main Program

Apr 23rd, 2011
3,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 27.20 KB | None | 0 0
  1. {$F+}
  2. {$M 50000,0,147000}
  3. uses overlay,crt,sbunit,varunit,pbtunit,extunit,gamemisc;
  4. {$O pbtunit}
  5. {$O extunit}
  6. {$O sbunit}
  7. {$O gamemisc}
  8.  
  9. label finalend,finalend1;
  10.  
  11. procedure musicint;interrupt;
  12. begin
  13. asm mov al,20h;out 20h,al;end;
  14. if(mver=1)and(musics=1)then playmusic;
  15. end;
  16.  
  17. procedure getvect(vec:byte);
  18. begin asm mov ah,$35;mov al,vec;int $21;mov oldintseg,es;mov oldintofs,bx;end;end;
  19.  
  20. procedure setvect(vec:byte;tseg,tofs:word);
  21. begin asm push ds;mov ah,$25;mov al,vec;mov dx,tofs;mov ds,tseg;int $21;pop ds;end;end;
  22.  
  23. procedure menufl(row:byte);
  24. begin
  25. if(mline<>row)then begin menuflash(row,bcolo,4,15,15);wait(10);menuflash(row,4,bcolo,15,15);end else
  26. begin menuflash(row,15,4,bcolo,15);wait(10);menuflash(row,15,bcolo,4,15);end;
  27. end;
  28.  
  29. function keypress:boolean;label nt;begin asm mov ah,1;int $16;jnz nt end;keypress:=false;nt:end;
  30.  
  31. begin        { THE 3DGAME BEGINS FROM THIS LINE }
  32. { Check the config-file somewhere here in the begining !!! }
  33.  
  34. ovrinit('3dgame.ovr');
  35. {writeln(ovrgetbuf);asm xor ax,ax;int 16h;end;}
  36. ovrinitems;
  37.  
  38. randomize;
  39. asm mov ax,13h;int 10h;end;
  40. losseg:=seg(map);losofs:=ofs(map)+1290;
  41. entseg:=seg(firable);entofs:=ofs(firable);
  42.  
  43. getmem(ma,6000);wepseg:=seg(ma^);
  44. getmem(ma,1900);itemseg:=seg(ma^);
  45. getmem(ma,48600);gfxseg:=seg(ma^);
  46. getmem(ma,12600);infoseg:=seg(ma^);
  47. getmem(ma,8000);mgfxseg:=seg(ma^);
  48. getmem(ma,4000);minfoseg:=seg(ma^);
  49. getmem(ma,280);igfxseg:=seg(ma^);
  50. getmem(ma,280);iinfoseg:=seg(ma^);
  51. getmem(ma,40100);visibseg:=seg(ma^);
  52.  
  53. getmem(ma,6000);fontseg:=seg(ma^);
  54. assign(f,'gfx\font.fnt');reset(f,6000);blockread(f,mem[fontseg:0],1);close(f);
  55.  
  56. new(wseen_p);
  57.  
  58. { Checking the parameters given by payback.exe }
  59. mver:=0;ver:=0;sounds:=false;musics:=0;
  60. if(paramcount>0)then begin
  61. val(paramstr(1),ver,code);if(ver=1)then sounds:=true;
  62. val(paramstr(2),mver,code);if(mver=1)then musics:=1;
  63. val(paramstr(3),base,code);
  64. val(paramstr(4),dma,code);
  65. val(paramstr(5),irq,code);
  66. val(paramstr(6),ownseg,code);
  67. val(paramstr(7),musaseg,code);
  68. val(paramstr(8),wo,code);memw[seg(musaptr):ofs(musaptr)]:=wo;
  69. val(paramstr(9),wo,code);memw[seg(musaptr):ofs(musaptr)+2]:=wo;
  70. val(paramstr(10),debug,code);
  71. val(paramstr(11),tuneseg,code);
  72. end else begin
  73. asm mov ax,3h;int 10h;end;for i:=1 to 26 do writeln;goxy(0,0);
  74. writeln('Error occured     : STARTED THE WRONG FILE.');
  75. writeln('Solution proposed : TRY EXECUTING ''PAYBACK.EXE'' FILE PLEASE.');
  76. goto finalend1;
  77. end;
  78. { Checking the parameters given by payback.exe }
  79.  
  80. tch:=true;pntr:=true;turn:=1;pln:=1;grp:=0;icol:=242;
  81. cle:='                                          ';mline:=1;
  82.  
  83. enter[1]:=true;enter[2]:=true;enter[3]:=true;enter[4]:=true;enter[36]:=true;enter[37]:=true;enter[40]:=true;enter[41]:=true;
  84. enter[65]:=true;enter[66]:=true;enter[67]:=true;enter[68]:=true;enter[69]:=true;enter[70]:=true;enter[71]:=true;
  85. enter[72]:=true;enter[73]:=true;enter[74]:=true;enter[75]:=true;enter[76]:=true;enter[77]:=true;enter[78]:=true;
  86. enter[79]:=true;
  87.  
  88. oply[34]:=true;oply[35]:=true;oply[36]:=true;oply[37]:=true;
  89. oply[38]:=true;oply[39]:=true;oply[40]:=true;oply[41]:=true;
  90.  
  91. open[36]:=true;open[37]:=true;open[40]:=true;open[41]:=true;
  92.  
  93. firable[1]:=true;firable[2]:=true;firable[3]:=true;firable[4]:=true;firable[16]:=true;firable[17]:=true;firable[36]:=true;
  94. firable[37]:=true;firable[40]:=true;firable[41]:=true;firable[45]:=true;firable[46]:=true;firable[47]:=true;firable[48]:=true;
  95. firable[49]:=true;firable[50]:=true;firable[51]:=true;firable[52]:=true;firable[53]:=true;firable[54]:=true;firable[56]:=true;
  96. firable[61]:=true;firable[62]:=true;firable[63]:=true;firable[64]:=true;firable[65]:=true;firable[66]:=true;firable[67]:=true;
  97. firable[68]:=true;firable[69]:=true;firable[70]:=true;firable[71]:=true;firable[72]:=true;firable[73]:=true;firable[74]:=true;
  98. firable[75]:=true;firable[76]:=true;firable[77]:=true;firable[78]:=true;firable[79]:=true;
  99.  
  100. lightable[1]:=true;
  101. lightable[2]:=true;
  102. lightable[3]:=true;
  103. lightable[4]:=true;
  104. lightable[16]:=true;
  105. lightable[17]:=true;
  106. lightable[36]:=true;
  107. lightable[37]:=true;
  108. lightable[40]:=true;
  109. lightable[41]:=true;
  110. lightable[42]:=true;
  111. lightable[43]:=true;
  112. lightable[45]:=true;
  113. lightable[46]:=true;
  114. lightable[47]:=true;
  115. lightable[48]:=true;
  116. lightable[49]:=true;
  117. lightable[50]:=true;
  118. lightable[51]:=true;
  119. lightable[52]:=true;
  120. lightable[53]:=true;
  121. lightable[54]:=true;
  122. lightable[55]:=true;
  123. lightable[56]:=true;
  124. lightable[57]:=true;
  125. lightable[58]:=true;
  126. lightable[59]:=true;
  127. lightable[60]:=true;
  128. lightable[61]:=true;
  129. lightable[62]:=true;
  130. lightable[63]:=true;
  131. lightable[64]:=true;
  132. lightable[65]:=true;
  133. lightable[66]:=true;
  134. lightable[67]:=true;
  135. lightable[68]:=true;
  136. lightable[69]:=true;
  137. lightable[70]:=true;
  138. lightable[71]:=true;
  139. lightable[72]:=true;
  140. lightable[73]:=true;
  141. lightable[74]:=true;
  142. lightable[75]:=true;
  143. lightable[76]:=true;
  144. lightable[77]:=true;
  145. lightable[78]:=true;
  146. lightable[79]:=true;
  147.  
  148. interable[1]:=true;
  149. interable[2]:=true;
  150. interable[3]:=true;
  151. interable[4]:=true;
  152. interable[16]:=false;
  153. interable[17]:=false;
  154. interable[36]:=false;
  155. interable[37]:=false;
  156. interable[40]:=false;
  157. interable[41]:=false;
  158. interable[42]:=false;
  159. interable[43]:=false;
  160. interable[45]:=false;
  161. interable[46]:=false;
  162. interable[47]:=false;
  163. interable[48]:=false;
  164. interable[49]:=false;
  165. interable[50]:=false;
  166. interable[51]:=false;
  167. interable[52]:=false;
  168. interable[53]:=false;
  169. interable[54]:=false;
  170. interable[55]:=false;
  171. interable[56]:=false;
  172. interable[57]:=false;
  173. interable[58]:=false;
  174. interable[59]:=false;
  175. interable[60]:=false;
  176. interable[61]:=false;
  177. interable[62]:=false;
  178. interable[63]:=false;
  179. interable[64]:=false;
  180. interable[65]:=true;
  181. interable[66]:=true;
  182. interable[67]:=true;
  183. interable[68]:=false;
  184. interable[69]:=false;
  185. interable[70]:=false;
  186. interable[71]:=false;
  187. interable[72]:=false;
  188. interable[73]:=false;
  189. interable[74]:=true;
  190. interable[75]:=false;
  191. interable[76]:=false;
  192. interable[77]:=false;
  193. interable[78]:=false;
  194. interable[79]:=false;
  195.  
  196. for i:=5 to 35 do wall[i]:=true;
  197. wall[38]:=true;
  198. wall[39]:=true;
  199. wall[44]:=true;
  200.  
  201. fcx[0]:=-1;fcy[0]:=-1;
  202. fcx[1]:=0;fcy[1]:=-1;
  203. fcx[2]:=+1;fcy[2]:=-1;
  204. fcx[3]:=+1;fcy[3]:=0;
  205. fcx[4]:=+1;fcy[4]:=+1;
  206. fcx[5]:=0;fcy[5]:=+1;
  207. fcx[6]:=-1;fcy[6]:=+1;
  208. fcx[7]:=-1;fcy[7]:=0;
  209. for a:=0 to teams do for i:=1 to warriors do begin oppor[a,i]:=true;mode[a,i]:=0;end;
  210.  
  211. initsound;
  212.  
  213. clear(tuneseg,2500);
  214. s:='music\start.svm';
  215. assign(f1,s);reset(f1);wo:=filesize(f1);close(f1);
  216. assign(f,s);reset(f,wo);blockread(f,mem[tuneseg:0],1);close(f);
  217. getvect(8);
  218. initplayer(tuneseg);
  219. musics:=1;
  220. setvect(8,seg(musicint),ofs(musicint));{setintvec(8,Addr(musicint));}
  221. timer:=round(1193180/52);
  222. { ajastimen alustus }
  223. asm
  224. cli;push ax;push cx;mov al,36h;out 43h,al;pusha;popa;mov cx,timer;mov al,cl;
  225. out 40h,al;pusha;popa;mov al,ch;out 40h,al;pusha;popa;pop cx;pop ax;sti;
  226. end;
  227.  
  228. error:=false;
  229. if checkfile('data\groups.dat')=false then begin asm mov ax,3h;int 10h;end;for i:=1 to 26 do writeln;
  230. goxy(0,0);writeln('Error occured : Groups.dat file does not exist.');error:=true;end;
  231.  
  232. {$IFNDEF unregistered}
  233. if checkfile('data\weapons.dat')=false then begin
  234. if error=false then begin asm mov ax,3h;int 10h;end;for i:=1 to 26 do writeln;goxy(0,0);end;
  235. writeln('Error occured : Weapons.dat file does not exist.');error:=true;end;
  236. if checkfile('data\items.dat')=false then begin
  237. if error=false then begin asm mov ax,3h;int 10h;end;for i:=1 to 26 do writeln;goxy(0,0);end;
  238. writeln('Error occured : Items.dat file does not exist.');error:=true;end;
  239. {$ENDIF}
  240.  
  241. if error=true then goto finalend;
  242.  
  243. clear(ownseg,16000);
  244. clear(wepseg,1500);
  245.  
  246. assign(f,'gamedata\mds.dat');reset(f,768);blockread(f,mem[ownseg:0],1);close(f);
  247. for i:=0 to 255 do begin
  248. frontpal[i*3]:=mem[ownseg:i*3];
  249. frontpal[i*3+1]:=mem[ownseg:i*3+1];
  250. frontpal[i*3+2]:=mem[ownseg:i*3+2];
  251. setpal(i,mem[ownseg:i*3],mem[ownseg:i*3+1],mem[ownseg:i*3+2]);
  252. end;
  253. {loadpic('gfx\modes.svf');}
  254. assign(f,'gfx\modes.svf');reset(f,64000);blockread(f,mem[ownseg:0],1);close(f);
  255.  
  256. wipe(ownseg,$a000,0,0,16000);
  257. away:=false;i:=1;
  258. uselight:=1;
  259. ambientl:=0;
  260. reports:=1;
  261. repeat
  262. if reports=1 then fastfont('On ',194,55,33,193,ownseg,0,0) else
  263. fastfont('Off',194,55,33,193,ownseg,0,0);
  264. str(ambientl,s);
  265. if ambientl<10 then s:=s+' ';
  266. fastfont(s,198,66,33,193,ownseg,0,0);
  267.  
  268. point(67,42+(i*11),253,52+(i*11),33);
  269. wipe(ownseg,$a000,0,0,16000);
  270. point(67,42+(i*11),253,52+(i*11),179);
  271. asm xor ax,ax;int 16h;mov c1,ah;end;
  272. if(c1=#72)then begin dec(i);if i<1 then i:=6;if i=3 then i:=2;end;
  273. if(c1=#80)then begin inc(i);if i>6 then i:=1;if i=3 then i:=4;end;
  274. if((c1=#75)or(c1=#77))and(i=1)then reports:=1-reports;
  275. if(c1=#75)and(i=2)and(ambientl>0)then dec(ambientl);
  276. if(c1=#77)and(i=2)and(ambientl<10)then inc(ambientl);
  277.  
  278. if(c1=#1)then begin away:=true;c1:=#28;i:=3;end;
  279. until (c1=#28)and(i>=3);
  280. gmode:=i-3;if(away=true)then begin asm mov ax,3h;int 10h;end;goto finalend;end;
  281.  
  282. if(ambientl=10)then uselight:=0;
  283. if(uselight=0)then
  284. for yt:=1 to 100 do for xt:=1 to 100 do inc(lightmap[xt,yt],ambientl+1);
  285.  
  286. palswap;
  287. fade(4);
  288.  
  289. { Load map begins here }
  290. s:=filload('maps','*.map');
  291. mapname:=s;
  292. chdir('..');
  293. if nofils=true then begin asm mov ax,3h;int 10h;end;
  294. for i:=1 to 26 do writeln;goxy(0,0);writeln('Error occured : No map files in the directory.');
  295. goto finalend;end;
  296. if away=true then begin asm mov ax,3h;int 10h;end;goto finalend;end;
  297. chdir('maps');
  298.  
  299. {$IFNDEF unregistered}
  300. assign(f,s);reset(f,100);for i:=1 to 100 do blockread(f,map[i,1],1);close(f);
  301. clear(musaseg,3500);
  302. assign(f,s);reset(f,10000);seek(f,1);blockread(f,mem[musaseg:0],1);close(f);
  303. reset(f,20606);blockread(f,mem[ownseg:0],1);close(f);
  304. {$ELSE}
  305. assign(f,'mintegr.dat');
  306. reset(f,20606);
  307. seek(f,filline-1);
  308. blockread(f,mem[ownseg:0],1);
  309. close(f);
  310.  
  311. wor3:=0;
  312. for wor1:=1 to 100 do
  313. for wor2:=1 to 100 do begin map[wor1,wor2]:=mem[ownseg:wor3];
  314. inc(wor3);end;
  315.  
  316. clear(musaseg,3500);
  317. for wor1:=0 to 9999 do
  318. mem[musaseg:wor1]:=mem[ownseg:10000+wor1];
  319.  
  320. {$ENDIF}
  321. chdir('..');
  322.  
  323. lightamo:=0;
  324. for wo:=1 to 200 do { lights }
  325. begin
  326. lightsx[wo]:=mem[ownseg:20000+wo*3-3];
  327. lightsy[wo]:=mem[ownseg:20000+wo*3+1-3];
  328. lightst[wo]:=mem[ownseg:20000+wo*3+2-3];
  329. if(lightst[wo]>0)then inc(lightamo);
  330. end;
  331.  
  332. mapx:=mem[ownseg:20600];
  333. mapy:=mem[ownseg:20601];
  334. walldam:=mem[ownseg:20602];
  335. doordam:=mem[ownseg:20603];
  336. itempd:=mem[ownseg:20604];
  337. itemm:=mem[ownseg:20605];
  338. clear(ownseg,16000);
  339.  
  340. { Load map ends here }
  341.  
  342. { If swapfile exists then NO choose units nor controller selection}
  343. { Select controllers for different teams begins here }
  344.  
  345. selectcontroller;
  346. for byt:=0 to teams do drawable[byt]:=1;
  347. if(away=true)then begin asm mov ax,$3;int $10;end;goto finalend;end;
  348.  
  349. { Select controllers for different teams ends here }
  350.  
  351. { Choose units begins here, if no swapfile }
  352.  
  353. for byt:=0 to teams do if(control[byt]=1)then begin
  354. chooseunits(byt);
  355. if(pntr=true)then begin asm mov ax,$3;int $10;end;goto finalend;end;
  356. chooseplayers(byt);
  357. end;
  358. itemtoseg;wepstoseg;
  359. for byt:=0 to teams do if(control[byt]>1)then cpuchooseplayers(byt);
  360.  
  361. { Choose units ends here, Fix players into units begins here }
  362.  
  363. for nu:=0 to teams do begin a:=0;
  364. for wo:=1 to 20 do if(chosen[nu,wo]=true)then begin inc(a);plnnum[nu,a]:=wo;end;
  365. end;
  366.  
  367. for nu:=0 to teams do if(control[nu]=1)then begin a:=0;
  368. for wo:=1 to 20 do begin
  369. if(chosen[nu,wo]=true)then begin inc(a);
  370. c3:=16;move_custom(mem[seg(c3):ofs(c3)],plname[nu,a][0],1);
  371. c3:=1+((gr1[nu]-1)*1440+280)+((wo-1)*58);
  372. move_custom(mem[gfxseg:c3],plname[nu,a][1],16);
  373. move_custom(mem[gfxseg:c3+16],mem[seg(exp[nu,a]):ofs(exp[nu,a])],4);
  374. move_custom(mem[gfxseg:c3+20],mem[seg(skpoints[nu,a]):ofs(skpoints[nu,a])],4);
  375. arminuse[nu,a]:=mem[gfxseg:c3+24];tothps[nu,a]:=mem[gfxseg:c3+25];
  376. basmp[nu,a]:=mem[gfxseg:c3+26];mps[nu,a]:=basmp[nu,a];
  377. react[nu,a]:=mem[gfxseg:c3+27];firaccu[nu,a]:=mem[gfxseg:c3+28];
  378. melaccu[nu,a]:=mem[gfxseg:c3+29];throaccu[nu,a]:=mem[gfxseg:c3+30];
  379. for i:=1 to 6 do begin lochps[nu,a,i]:=mem[gfxseg:c3+30+i];
  380. e:=mem[gfxseg:c3+36+i];locaps[nu,a,i]:=e;totaps[nu,a,i]:=e;end;
  381. move_custom(mem[gfxseg:c3+43],mem[seg(invtype[nu,a,1]):ofs(invtype[nu,a,1])],15);
  382. end;end;end;
  383. { Fix players into units ends here }
  384.  
  385. clear(gfxseg,12150);
  386. clear(infoseg,3150);
  387. clear(mgfxseg,2000);
  388. clear(minfoseg,1000);
  389. clear(igfxseg,70);
  390. clear(iinfoseg,70);
  391. clear(visibseg,10000);
  392.  
  393. assign(f1,'gamedata\tgfx.dat');reset(f1);le1:=filesize(f1);close(f1);
  394. assign(f1,'gamedata\tinfo.dat');reset(f1);le2:=filesize(f1);close(f1);
  395. assign(f,'gamedata\tgfx.dat');reset(f,le1);blockread(f,mem[gfxseg:0],1);close(f);
  396. assign(f,'gamedata\tinfo.dat');reset(f,le2);blockread(f,mem[infoseg:0],1);close(f);
  397. assign(f,'gamedata\mgfx.dat');reset(f,7652);blockread(f,mem[mgfxseg:0],1);close(f);
  398. assign(f,'gamedata\minfo.dat');reset(f,3920);blockread(f,mem[minfoseg:0],1);close(f);
  399. assign(f,'gamedata\igfx.dat');reset(f,221);blockread(f,mem[igfxseg:0],1);close(f);
  400. assign(f,'gamedata\iinfo.dat');reset(f,188);blockread(f,mem[iinfoseg:0],1);close(f);
  401.  
  402.  
  403. wepstoseg;itemtoseg;
  404. for nu:=0 to teams do if(control[nu]>0)then begin
  405. for wo:=1 to gr[nu] do begin armin:=false;
  406. for a:=1 to 15 do begin
  407.  
  408. if(invtype[nu,wo,a]>=1)and(invtype[nu,wo,a]<=100)then begin
  409. c3:=1;s:='    ';for e:=1 to 4 do begin by1:=mem[wepseg:((invtype[nu,wo,a])-1)*59+49+e];
  410. if(by1<>32)then inc(c3);s[e]:=chr(by1);end;delete(s,c3,5-c3);val(s,clsize,code);
  411. invammo[nu,wo,a]:=clsize;end;
  412.  
  413. if(invtype[nu,wo,a]>=101)and(invtype[nu,wo,a]<=200)then begin
  414. c3:=1;s:='    ';for e:=1 to 4 do begin by1:=mem[wepseg:((invtype[nu,wo,a])-101)*59+49+e];
  415. if(by1<>32)then inc(c3);s[e]:=chr(by1);end;delete(s,c3,5-c3);val(s,clsize,code);
  416. invammo[nu,wo,a]:=clsize;end;
  417.  
  418. if(invtype[nu,wo,a]>=200)and(invtype[nu,wo,a]<=250)then invammo[nu,wo,a]:=mem[itemseg:(invtype[nu,wo,a]-201)*30+24];
  419.  
  420. if(armin=false)and(invtype[nu,wo,a]>=1)and(invtype[nu,wo,a]<=100)then begin
  421. if(mem[wepseg:((invtype[nu,wo,a])-1)*59+32]=1)and(lochps[nu,wo,3]>0)then begin rarm[nu,wo]:=a;armin:=true;end;
  422. if(mem[wepseg:((invtype[nu,wo,a])-1)*59+32]=1)and(lochps[nu,wo,4]>0)then begin larm[nu,wo]:=a;armin:=true;end;
  423. if(mem[wepseg:((invtype[nu,wo,a])-1)*59+32]=2)and(lochps[nu,wo,3]>0)and(lochps[nu,wo,4]>0)then
  424. begin rarm[nu,wo]:=a;larm[nu,wo]:=a;armin:=true;end;
  425. end;
  426. end;end;end;
  427.  
  428. for a:=0 to teams do if(control[a]=0)then gr[a]:=0;
  429. for a:=0 to teams do for wo:=1 to warriors do dead[a,wo]:=true;
  430. for a:=0 to teams do if(control[a]>0)then for wo:=1 to gr[a] do dead[a,wo]:=false;
  431. for a:=0 to teams do for i:=1 to warriors do xpgain[a,i]:=0;
  432. wepstoseg;itemtoseg;
  433.  
  434. { Fix drawers begins here }
  435. a:=0;for x1:=1 to mapx do for y1:=1 to mapy do if(map[x1,y1]=59)or(map[x1,y1]=60)then inc(a);
  436. { a=drawers in battlefield }
  437. if a>0 then begin
  438. i:=itemm;itemm:=round(50/a);if(itemm>i)then itemm:=i;if(itemm=0)then itemm:=1;
  439. if(itempd<>0)then for x1:=1 to mapx do for y1:=1 to mapy do  { drawer stuff }
  440. if(map[x1,y1]=59)or(map[x1,y1]=60)then begin
  441.  
  442. for c2:=1 to itemm do if((random(100)+1)<(itempd))and(dritem<50)then
  443. begin                                      { some items into 1 drawer }
  444.  
  445. inc(dritem);
  446. itemx[dritem]:=x1;
  447. itemy[dritem]:=y1;
  448. itemp[dritem]:=0;
  449. itemhide[dritem]:=1;
  450.  
  451. i:=0;for a:=1 to 49 do if(mem[itemseg:1+(a-1)*30]=2)then inc(i);
  452.  
  453. byt:=0;if(i>0)and(random(5)=4)then begin a:=1+random(i);byt:=1;
  454. if(mem[itemseg:1+(a-1)*30]=2)then itemt[dritem]:=200+a;
  455. end else itemt[dritem]:=1+random(weapon_amount);
  456.  
  457. if(byt=0)then begin c3:=1;s:='    ';
  458. for e:=1 to 4 do begin by1:=mem[wepseg:(itemt[dritem]-1)*59+49+e];
  459. if(by1<>32)then inc(c3);s[e]:=chr(by1);end;
  460. delete(s,c3,5-c3);val(s,itema[dritem],code);
  461. end else itema[dritem]:=mem[itemseg:24+(a-1)*30];
  462. end;                                       { some items into 1 drawer }
  463. end;                                       { drawer stuff }
  464. end;
  465. { Fix drawers ends here }
  466.  
  467. assign(f,'gamedata\light.dat');reset(f,768);blockread(f,mem[ownseg:0],1);close(f);
  468. for i:=0 to 255 do begin
  469. frontpal[i*3]:=mem[ownseg:i*3];
  470. frontpal[i*3+1]:=mem[ownseg:i*3+1];
  471. frontpal[i*3+2]:=mem[ownseg:i*3+2];
  472. end;
  473.  
  474. assign(f,'gamedata\tile2.dat');reset(f,768);blockread(f,mem[ownseg:0],1);close(f);
  475. for i:=240 to 254 do begin
  476. frontpal[i*3]:=mem[ownseg:i*3];
  477. frontpal[i*3+1]:=mem[ownseg:i*3+1];
  478. frontpal[i*3+2]:=mem[ownseg:i*3+2];
  479. end;
  480. for wo:=0 to 768 do defpal[wo]:=0;
  481. fade(4);
  482.  
  483. for wo:=0 to 255 do topcol[wo]:=wo;
  484.  
  485. for wo:=0 to 255 do begin
  486. if(wo>=16)and(wo<=37) then topcol[wo]:=37;
  487. if(wo>=38)and(wo<=63) then topcol[wo]:=63;
  488. if(wo>=96)and(wo<=111) then topcol[wo]:=111;
  489. if(wo>=112)and(wo<=145) then topcol[wo]:=145;
  490. if(wo>=146)and(wo<=171) then topcol[wo]:=171;
  491. if(wo>=172)and(wo<=188) then topcol[wo]:=188;
  492. if(wo>=189)and(wo<=213) then topcol[wo]:=213;
  493. if(wo>=214)and(wo<=239) then topcol[wo]:=239;
  494. end;
  495.  
  496. precalcl;
  497. calclights;
  498.  
  499. clear(ownseg,16000);
  500. wipe(ownseg,$a000,0,0,16000);
  501. init(0);wepstoseg;clear(itemseg,450);
  502. assign(f,'gamedata\depinfo.dat');reset(f,448);blockread(f,mem[itemseg:0],1);close(f);
  503. for a:=0 to teams do for i:=1 to gr[a] do begin wo:=0;
  504. for c2:=1 to 6 do inc(wo,lochps[a,i,c2]);bleeded[a,i]:=tothps[a,i]-wo;end;
  505.  
  506. init_fastp_586(ownseg,gfxseg,infoseg);
  507.  
  508.                       { Deployment begins }
  509.  
  510. for i:=0 to teams do for a:=1 to warriors do begin
  511. plx[i,a]:=200;ply[i,a]:=200;insi[i,a]:=true;inhusi[i,a]:=true;end;
  512.  
  513. for byt2:=0 to teams do
  514. if(control[byt2]=1)then begin
  515. if(byt2=0)then begin s1:='Blue will deploy now.  ';setpal(255,10,10,63);end;
  516. if(byt2=1)then begin s1:='Red will deploy now.   ';setpal(255,63,0,0);end;
  517. if(byt2=2)then begin s1:='Green will deploy now. ';setpal(255,0,63,0);end;
  518. if(byt2=3)then begin s1:='Yellow will deploy now.';setpal(255,63,63,0);end;
  519. inftxt('Press enter to deploy. ',255,1,0);
  520. inftxt(s1,255,2,0);
  521. repeat asm mov ah,0;int 16h;mov c1,ah;end;until c1=#28;
  522. deployment(byt2,gr[byt2]);
  523. inftxt(cle,0,1,0);inftxt(cle,0,2,0);
  524. clear(ownseg,16000);
  525. for i:=0 to 127 do wipe(ownseg,$a000,0,i*320,64);
  526. end;
  527. for byt2:=0 to teams do if(control[byt2]>1)then cpudeploy(byt2,gr[byt2]);
  528.  
  529.                       { Deployment ends }
  530.  
  531. clear(musaseg,3500);clear(itemseg,450);itemtoseg;
  532. if(gmode=1)then for wo:=0 to 40000 do mem[visibseg:wo]:=2;
  533.  
  534. visimode:=true;
  535. fastmode:=false;
  536. grp:=teams; { Due to the first turn }
  537. turn:=0;
  538. pntr:=true;
  539.  
  540. a:=musics;
  541. musics:=0;
  542. s:='music\a1.svm';
  543. assign(f1,s);reset(f1);wo:=filesize(f1);close(f1);
  544. assign(f,s);reset(f,wo);blockread(f,mem[tuneseg:0],1);close(f);
  545. initplayer(tuneseg);
  546. musics:=a;
  547.  
  548. timer:=round(1193180/50);
  549. { ajastimen alustus }
  550. asm
  551. cli;push ax;push cx;mov al,36h;out 43h,al;pusha;popa;mov cx,timer;mov al,cl;
  552. out 40h,al;pusha;popa;mov al,ch;out 40h,al;pusha;popa;pop cx;pop ax;sti;
  553. end;
  554.  
  555. repeat
  556. chturn;
  557. until(lop=true)or(control[grp]=1);
  558. ch:=#0;
  559. inftxt(cle,0,1,0);inftxt(cle,0,2,0);cnt;see;
  560. grpmps[grp]:=0;for a:=1 to gr[grp] do inc(grpmps[grp],basmp[grp,a]);
  561.  
  562. for a:=0 to teams do        {We've seen nobody}
  563. for i:=1 to warriors do
  564. for tm:=0 to teams do
  565. for wo:=1 to warriors do
  566. for a1:=1 to 4 do wseen_p^[a,i,tm,wo,a1]:=-10;
  567.  
  568. repeat             { GAMELOOP }
  569. tm:=0;for i:=1 to 6 do begin inc(tm,lochps[grp,pln,i]);end;
  570. tem:=(tm/tothps[grp,pln]);if tem>1 then tem:=1.0;tem:=2.0-tem;
  571. if(lochps[grp,pln,1]<round(tothps[grp,pln]*0.04))then tem:=tem+0.3;
  572. if(lochps[grp,pln,3]=0)then tem:=tem+0.2;
  573. if(lochps[grp,pln,4]=0)then tem:=tem+0.2;
  574. if(lochps[grp,pln,5]=0)then tem:=tem+0.4;
  575. if(lochps[grp,pln,6]=0)then tem:=tem+0.4;
  576. tem2:=tem*tem;
  577. ico:=false;
  578.  
  579. drawmap;
  580.  
  581. if(oppor[grp,pln]=true)then fastfont(' ON',234,160,tcolo,bcolo,$a000,0,0) else fastfont('OFF',234,160,tcolo,bcolo,$a000,0,0);
  582.  
  583. fastfont(rank_short(grp,pln)+plname[grp,pln]+'  ',14,162,tcolo,bcolo,$a000,0,0);
  584.  
  585. fastfont('Health : ',14,180,tcolo,bcolo,$a000,0,0);
  586. s:='Where am I ?    ';
  587. if tem<=1.75 then s:='Critical        ';
  588. if tem<=1.5 then s:='Heavily wounded ';
  589. if tem<=1.25 then s:='Slightly wounded';
  590. if tem<=1.1 then s:='OK              ';
  591. fastfont(s,70,180,tcolo,bcolo,$a000,0,0);
  592.  
  593. str(mps[grp,pln],s);
  594. if(mps[grp,pln]<10)then insert('  ',s,1);
  595. if(mps[grp,pln]<100)and(mps[grp,pln]>=10)then insert(' ',s,1);
  596. fastfont(s,276,24,tcolo,87,$a000,0,0);
  597.  
  598. str(turn,s);
  599. if(turn<10)then insert('  ',s,1);
  600. if(turn<100)and(turn>=10)then insert(' ',s,1);
  601. fastfont(s,276,53,tcolo,bcolo,$a000,0,0);
  602.  
  603. if(reports=1) then reportwar(grp,pln);
  604.  
  605. if(lop=false)then ch:=readk;  { case ch of }
  606.  
  607. if(ch=#14)then begin
  608. play('tick.svs',10000);
  609. menuflash(mline,15,4,bcolo,15);wait(10);menuflash(mline,15,bcolo,4,15);
  610. case mline of
  611. 1:ch:=#57;
  612. 2:ch:=#28;
  613. 3:ch:=#50;
  614. 4:ch:=#20;
  615. 5:ch:=#25;
  616. 6:ch:=#30;
  617. 7:ch:=#35;
  618. 8:ch:=#23;
  619. 9:ch:=#31;
  620. 10:ch:=#34;
  621. 11:ch:=#47;
  622. 12:ch:=#38;
  623. 13:ch:=#33;
  624. 14:ch:=#17;
  625. 15:ch:=#49;
  626. 16:ch:=#19;
  627. 17:ch:=#18;
  628. 18:ch:=#1;
  629. 19:ch:=#16;
  630. end;
  631. end;
  632.  
  633. if(ch=#28)and(free=false)then begin
  634. menufl(2);exgrp:=grp;expln:=pln;calcvisi1all;shoot;dell;
  635. if(broken=1)then calclights;
  636. if(shooted=true)then pguard;calcvisiall;see;
  637. drawmap;ch:=#0;end;
  638.  
  639. if(ch=#46)then cnt;
  640.  
  641. if(ch=#34)then if(free=false)then begin
  642. menufl(10);if(oppor[grp,pln]=false)then oppor[grp,pln]:=true else oppor[grp,pln]:=false;end;
  643.  
  644. if(ch=#35)then if(free=false)then begin
  645. menufl(7);health;ch:=#0;menufill(mline);end;
  646.  
  647. if(ch=#49)then if(free=false)then begin menufl(15);nguy;end;
  648.  
  649. if(ch=#38)then if(free=false)and(visimode=false)then begin menufl(12);
  650. {for visiy:=1 to mapy do for visix:=1 to mapx do begin
  651. i:=visiofsi(plx[grp,pln],ply[grp,pln],visix,visiy);
  652. if(i=1)then if(secheck(plx[grp,pln],ply[grp,pln],visix,visiy,fc[grp,pln])=1)then
  653. mem[visibseg:grp*10000+visiy*100+visix]:=1;
  654. end;}
  655. {mem[visibseg:grp*10000+ply[grp,pln]*100+plx[grp,pln]]:=1;}
  656. visimode:=true;
  657. {inftxt('You are now in visibility-mode. ',15,1,0);
  658. }
  659. inftxt('Dummy light disabled.           ',15,1,0);
  660. wait(30);
  661. inftxt(cle,0,1,0);end
  662. else
  663. if(visimode=true)then begin menufl(12);
  664. inftxt('Dummy light enabled.            ',15,1,0);
  665. wait(30);
  666. inftxt(cle,0,1,0);
  667. visimode:=false;pntr:=true;
  668. {cnt;
  669. calcvisiall;
  670. fillvisi;
  671. see;}
  672. drawmap;
  673. end;
  674.  
  675. if(ch=#17)then if(free=false)then begin menufl(14);wepstat;ch:=#0;end;
  676.  
  677. if(ch=#31)then if(free=false)then begin menufl(9);statscreen;ch:=#0;menufill(mline);end;
  678.  
  679. if(ch=#47)then if(free=false)then begin menufl(11);viewmap;ch:=#0;menufill(mline);end;
  680.  
  681. if(ch=#23)then if(free=false)then begin menufl(8);invscreen;see;ch:=#0;menufill(mline);end;
  682.  
  683. if(ch=#25)then if(free=false)then begin menufl(5);pickup;see;if(pickuped=true)then pguard;see;ch:=#0;end;
  684.  
  685. if(ch=#30)then if(free=false)then begin menufl(6);healing;see;if(healed=true)then pguard;see;ch:=#0;end;
  686.  
  687. if(ch=#20)then if(free=false)then begin menufl(4);calcvisi1all;throwing;see;if(throwed=true)then pguard;see;ch:=#0;end;
  688.  
  689. if(ch=#57)then if(free=false)then begin menufl(1);usedoor;calcvisi1;see;if(doped=true)then pguard;see;ch:=#0;end;
  690.  
  691. if(ch=#50)then if(free=false)then begin
  692. menufl(3);exgrp:=grp;expln:=pln;melee;calcvisi1;see;if meled=true then pguard;see;ch:=#0;end;
  693.  
  694. if(ch=#18)then if(free=false)then begin
  695. menufl(17);snd:=false;if(ver<>0)and(sounds=true)then
  696. begin sounds:=false;snd:=true;inftxt('Effects are disabled.           ',15,1,0);wait(30);end;
  697. if(snd=false)and(ver<>0)and(sounds=false)then
  698. begin sounds:=true;inftxt('Effects are enabled.            ',15,1,0);wait(30);end;
  699. inftxt(cle,0,1,0);see;end;
  700.  
  701. if(ch=#19)then if(free=false)then begin
  702. menufl(16);snd:=false;if(mver<>0)and(musics=1)then
  703. begin musics:=0;endplayer;
  704. snd:=true;inftxt('Music disabled.                 ',15,1,0);wait(30);end;
  705. if(snd=false)and(mver<>0)and(musics=0)then
  706. begin musics:=1;initplayer(tuneseg);
  707. inftxt('Music enabled.                  ',15,1,0);wait(30);end;
  708. inftxt(cle,0,1,0);see;end;
  709.  
  710. if(ch=#33)then if(free=true)then begin
  711. menufl(13);free:=false;pntr:=true;inftxt(cle,0,1,0);cnt;see;drawmap;end else begin
  712. menufl(13);calcvisi1all;pntr:=false;free:=true;inftxt('You are now in freescroll-mode. ',15,1,0);end;
  713.  
  714. if(ch=#73)then begin menufill(mline);dec(mline);if(mline<1)then mline:=19;menufill(mline);end;
  715.  
  716. if(ch=#81)then begin menufill(mline);inc(mline);if(mline>19)then mline:=1;menufill(mline);end;
  717.  
  718. if(ch=#72)then if free=false then begin
  719. fw:=true;moving;cnt;calcvisi1;see;if moved=true then pguard;see;end
  720. else begin if cx>0 then dec(cx);if cy>0 then dec(cy);end;
  721.  
  722. if(ch=#80)then if free=false then begin fw:=false;moving;cnt;calcvisi1;see;if moved=true then pguard;see;end
  723. else begin if cx<mapx-7 then inc(cx);if cy<mapy-7 then inc(cy);end;
  724.  
  725. if(ch=#75)then if free=false then begin
  726. if mps[grp,pln]<round(tem2) then mpsflash;
  727. if mps[grp,pln]>=round(tem2) then begin
  728. play('turn.svs',12000);dec(mps[grp,pln],round(tem2));
  729. if fc[grp,pln]>0 then dec(fc[grp,pln])else fc[grp,pln]:=7;calcvisi1;see;pguard;see;end;end
  730. else begin if cx>0 then dec(cx);if cy<mapy-7 then inc(cy);end;
  731.  
  732. if(ch=#77)then if free=false then begin
  733. if mps[grp,pln]<round(tem2) then mpsflash;
  734. if mps[grp,pln]>=round(tem2) then begin
  735. play('turn.svs',12000);dec(mps[grp,pln],round(tem2));
  736. if fc[grp,pln]<7 then inc(fc[grp,pln]) else fc[grp,pln]:=0;calcvisi1;see;pguard;see;end;end
  737. else begin if cx<mapx-7 then inc(cx);if cy>0 then dec(cy);end;
  738.  
  739. if(ch=#59)then helpscreen;
  740.  
  741. if(ch=#60)then
  742. if(fastmode=true) then
  743. begin
  744. fastmode:=false;
  745. inftxt('Fast game-mode disabled.        ',15,1,0);wait(30);
  746. inftxt(cle,0,1,0);see;
  747. end else
  748. begin
  749. fastmode:=true;
  750. inftxt('Fast game-mode enabled.         ',15,1,0);wait(30);
  751. inftxt(cle,0,1,0);see;
  752. end;
  753.  
  754. if(ch=#16)then begin menufl(19);play('quit.svs',8000);
  755. inftxt('Want to quit already ?          ',15,1,0);inftxt('Press [F10] to confirm...       ',15,2,0);
  756. ch:=readk;if ch=#68 then begin lop:=true;esced:=1;end else begin
  757. if free=false then inftxt(cle,0,1,0);inftxt(cle,0,2,0);see;
  758. if free=true then inftxt('You are now in freescroll-mode. ',15,1,0);end;end;
  759.  
  760. if(ch=#1)then if(free=false)then begin
  761. menufl(18);inftxt('Do you want to end your turn ? ',15,1,0);ch:=readk;
  762. if(ch=#21)then
  763. begin
  764.  repeat chturn;until(control[grp]=1)or(lop=true);
  765. end
  766.  else begin inftxt(cle,0,1,0);see;end;
  767. end
  768. else begin visimode:=false;free:=false;pntr:=true;cnt;calcvisiall;fillvisi;inftxt(cle,0,1,0);see;end;
  769.  
  770. {end;} { case ch of }
  771.  
  772. { Check if guys are dead }
  773. i:=0;
  774. for a:=1 to gr[grp] do if(dead[grp,a]=false)then i:=1;
  775. if(i=0)then repeat chturn;until(control[grp]=1)or(lop=true);
  776. { Check if guys are dead }
  777.  
  778. { End game check }
  779. if(lop=false)then begin
  780. {i:=0;
  781. for wo:=0 to teams do begin c3:=0;
  782. for a:=1 to gr[wo] do if(dead[wo,a]=false)and(c3=0)then begin c3:=1;inc(i);end;end;
  783. if(i<2)then lop:=true;}
  784. lop:=true;
  785. for i:=0 to teams do begin wiped[i]:=1;
  786. for c3:=1 to warriors do if(dead[i,c3]=false)then wiped[i]:=0;end;
  787. for i:=0 to teams do if(wiped[i]=0)then c3:=i;
  788. for i:=0 to teams do if(wiped[i]=0)and(ally[i]<>ally[c3])then lop:=false;
  789.  
  790. end;
  791. { End game check }
  792.  
  793. until lop=true;    { GAMELOOP }
  794. endstuff;
  795. if(esced=0)then begin
  796. endplayer;
  797. a:=musics;musics:=0;s:='music\endtune.svm';
  798. assign(f1,s);reset(f1);wo:=filesize(f1);close(f1);
  799. assign(f,s);reset(f,wo);blockread(f,mem[tuneseg:0],1);close(f);
  800. initplayer(tuneseg);musics:=a;
  801. endstatisticsscreen;
  802. end;
  803. asm mov ax,3h;int 10h end;
  804. finalend:
  805.  
  806. wait(10);
  807. freesound;
  808.  
  809. musics:=0;endplayer;
  810. setvect(8,oldintseg,oldintofs);
  811. asm mov al,54;out $43,al;pusha;popa;mov cx,0; { Ajastimen ja ajan palautus }
  812. mov al,cl;out $40,al;pusha;popa;mov al,ch;out $40,al;
  813. mov ah,4;int $1a;mov ah,2;int $1a;mov bl,10;mov al,ch;and ch,15;shr al,4;mul bl;add ch,al;mov al,cl;and cl,15;
  814. shr al,4;mul bl;add cl,al;mov al,dh;and dh,15;shr al,4;mul bl;add dh,al;mov dl,0;mov ah,$2d;int $21;end;
  815. finalend1:
  816.  
  817. {writeln(memavail);
  818. asm xor ax,ax;int $16;end;}
  819.  
  820. end.         { THE 3DGAME ENDS TO THIS LINE }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement