C5_GAME.C 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658
  1. /* Catacomb Armageddon Source Code
  2. * Copyright (C) 1993-2014 Flat Rock Software
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. // C3_GAME.C
  19. #include <stdlib.h>
  20. #include "DEF.H"
  21. #include "gelib.h"
  22. #pragma hdrstop
  23. #ifdef PROFILE
  24. #include "TIME.H"
  25. #endif
  26. /*
  27. =============================================================================
  28. LOCAL CONSTANTS
  29. =============================================================================
  30. */
  31. #define NUMLUMPS 61
  32. #define SUCCUBUSLUMP 0
  33. #define FATDEMONLUMP 1
  34. #define BOLTLUMP 2
  35. #define NUKELUMP 3
  36. #define POTIONLUMP 4
  37. #define RKEYLUMP 5
  38. #define YKEYLUMP 6
  39. #define GKEYLUMP 7
  40. #define BKEYLUMP 8
  41. //#define SCROLLLUMP 9
  42. #define CHESTLUMP 10
  43. #define PLAYERLUMP 11
  44. #define WALL1LUMP 12
  45. #define WALL2LUMP 13
  46. #define BDOORLUMP 14
  47. #define GODESSLUMP 15
  48. #define MAGELUMP 16
  49. #define BATLUMP 17
  50. #define GRELLUMP 18
  51. #define TOMBSTONESLUMP 19
  52. #define ZOMBIELUMP 20
  53. #define ANTLUMP 21
  54. #define SKELETONLUMP 22
  55. #define RGEMLUMP 23
  56. #define GGEMLUMP 24
  57. #define BGEMLUMP 25
  58. #define YGEMLUMP 26
  59. #define PGEMLUMP 27
  60. //#define RKEY2LUMP 28
  61. #define DRAGONLUMP 29
  62. #define OBJ_WARPLUMP 30
  63. #define EYELUMP 31
  64. #define REDDEMONLUMP 32
  65. //#define PITLUMP 33
  66. #define FTIMELUMP 34
  67. #define WATERCHESTLUMP 35
  68. #define TREELUMP 36
  69. #define ARCH1LUMP 37
  70. #define BUNNYLUMP 38
  71. #define ANTHILLLUMP 39
  72. #define COLUMNLUMP 40
  73. #define SULPHURGASLUMP 41
  74. #define FIREPOTLUMP 42
  75. //#define WHIRLPOOLLUMP 43
  76. #define FOUNTAINLUMP 44
  77. #define FORCEFIELDLUMP 45
  78. #define ARCH2LUMP 46
  79. #define ARCH3LUMP 47
  80. #define ARCH4LUMP 48
  81. #define ARCH5LUMP 49
  82. #define ARCH6LUMP 50
  83. #define SKELHANGLUMP 51
  84. //#define SKELPILELUMP 52
  85. #define ARCH7LUMP 53
  86. #define ARCH8LUMP 54
  87. #define ARCH9LUMP 55
  88. #define ARCH10LUMP 56
  89. #define ARCH11LUMP 57
  90. #define ARCH12LUMP 58
  91. #define ARCH13LUMP 59
  92. int lumpstart[NUMLUMPS] = {
  93. SUCCUBUS_LUMP_START,
  94. FATDEMON_LUMP_START,
  95. BOLT_LUMP_START,
  96. NUKE_LUMP_START,
  97. POTION_LUMP_START,
  98. RKEY_LUMP_START,
  99. YKEY_LUMP_START,
  100. GKEY_LUMP_START,
  101. BKEY_LUMP_START,
  102. 0,
  103. //SCROLL_LUMP_START,
  104. CHEST_LUMP_START,
  105. PLAYER_LUMP_START,
  106. //WALL1_LUMP_START,
  107. //WALL2_LUMP_START,
  108. //BDOOR_LUMP_START,
  109. 0,0,0,
  110. GODESS_LUMP_START,
  111. MAGE_LUMP_START,
  112. BAT_LUMP_START,
  113. GREL_LUMP_START,
  114. TOMBSTONES_LUMP_START,
  115. ZOMBIE_LUMP_START,
  116. ANT_LUMP_START,
  117. SKELDUDE_LUMP_START,
  118. RGEM_LUMP_START,
  119. GGEM_LUMP_START,
  120. BGEM_LUMP_START,
  121. YGEM_LUMP_START,
  122. PGEM_LUMP_START,
  123. 0, //RKEY2_LUMP_START,
  124. DRAGON_LUMP_START,
  125. OBJ_WARP_LUMP_START,
  126. EYE_LUMP_START,
  127. REDDEMON_LUMP_START,
  128. 0, //PIT_LUMP_START,
  129. TIME_LUMP_START,
  130. O_WATER_CHEST_LUMP_START,
  131. TREE_LUMP_START,
  132. ARCH1_LUMP_START,
  133. BUNNY_LUMP_START,
  134. ANTHILL_LUMP_START,
  135. COLUMN_LUMP_START,
  136. SULPHURGAS_LUMP_START,
  137. FIREPOT_LUMP_START,
  138. 0, //WHIRLPOOL_LUMP_START,
  139. FOUNTAIN_LUMP_START,
  140. FORCEFIELD_LUMP_START,
  141. ARCH2_LUMP_START,
  142. ARCH3_LUMP_START,
  143. ARCH4_LUMP_START,
  144. ARCH5_LUMP_START,
  145. ARCH6_LUMP_START,
  146. SKELHANG_LUMP_START,
  147. 0, //SKELPILE_LUMP_START,
  148. ARCH7_LUMP_START,
  149. ARCH8_LUMP_START,
  150. ARCH9_LUMP_START,
  151. ARCH10_LUMP_START,
  152. ARCH11_LUMP_START,
  153. ARCH12_LUMP_START,
  154. ARCH13_LUMP_START,
  155. };
  156. int lumpend[NUMLUMPS] = {
  157. SUCCUBUS_LUMP_END,
  158. FATDEMON_LUMP_END,
  159. BOLT_LUMP_END,
  160. NUKE_LUMP_END,
  161. POTION_LUMP_END,
  162. RKEY_LUMP_END,
  163. YKEY_LUMP_END,
  164. GKEY_LUMP_END,
  165. BKEY_LUMP_END,
  166. 0,
  167. //SCROLL_LUMP_END,
  168. CHEST_LUMP_END,
  169. PLAYER_LUMP_END,
  170. 0,0,0,
  171. GODESS_LUMP_END,
  172. MAGE_LUMP_END,
  173. BAT_LUMP_END,
  174. GREL_LUMP_END,
  175. TOMBSTONES_LUMP_END,
  176. ZOMBIE_LUMP_END,
  177. ANT_LUMP_END,
  178. SKELDUDE_LUMP_END,
  179. RGEM_LUMP_END,
  180. GGEM_LUMP_END,
  181. BGEM_LUMP_END,
  182. YGEM_LUMP_END,
  183. PGEM_LUMP_END,
  184. 0, //RKEY2_LUMP_END,
  185. DRAGON_LUMP_END,
  186. OBJ_WARP_LUMP_END,
  187. EYE_LUMP_END,
  188. REDDEMON_LUMP_END,
  189. 0, //PIT_LUMP_END,
  190. TIME_LUMP_END,
  191. O_WATER_CHEST_LUMP_END,
  192. TREE_LUMP_END,
  193. ARCH1_LUMP_END,
  194. BUNNY_LUMP_END,
  195. ANTHILL_LUMP_END,
  196. COLUMN_LUMP_END,
  197. SULPHURGAS_LUMP_END,
  198. FIREPOT_LUMP_END,
  199. 0, //WHIRLPOOL_LUMP_END,
  200. FOUNTAIN_LUMP_END,
  201. FORCEFIELD_LUMP_END,
  202. ARCH2_LUMP_END,
  203. ARCH3_LUMP_END,
  204. ARCH4_LUMP_END,
  205. ARCH5_LUMP_END,
  206. ARCH6_LUMP_END,
  207. SKELHANG_LUMP_END,
  208. 0, //SKELPILE_LUMP_END,
  209. ARCH7_LUMP_END,
  210. ARCH8_LUMP_END,
  211. ARCH9_LUMP_END,
  212. ARCH10_LUMP_END,
  213. ARCH11_LUMP_END,
  214. ARCH12_LUMP_END,
  215. ARCH13_LUMP_END,
  216. };
  217. //extern unsigned scolor,gcolor;
  218. /*
  219. =============================================================================
  220. GLOBAL VARIABLES
  221. =============================================================================
  222. */
  223. unsigned latchpics[NUMLATCHPICS];
  224. unsigned tileoffsets[NUMTILE16];
  225. unsigned textstarts[27];
  226. boolean splitscreen=false;
  227. /*
  228. =============================================================================
  229. LOCAL VARIABLES
  230. =============================================================================
  231. */
  232. boolean lumpneeded[NUMLUMPS];
  233. //===========================================================================
  234. //==========================================================================
  235. //
  236. //
  237. // LOCAL PROTOTYPES
  238. //
  239. //
  240. //==========================================================================
  241. void CashPoints(void);
  242. /*
  243. ==========================
  244. =
  245. = ScanInfoPlane
  246. =
  247. = Spawn all actors and mark down special places
  248. =
  249. ==========================
  250. */
  251. void ScanInfoPlane (void)
  252. {
  253. unsigned char hibyte;
  254. unsigned x,y,i,j;
  255. unsigned int tile;
  256. unsigned far *start;
  257. InitObjList(); // start spawning things with a clean slate
  258. scolor = gcolor = 0;
  259. skycolor = &scolor;
  260. groundcolor = &gcolor;
  261. memset (lumpneeded,0,sizeof(lumpneeded));
  262. start = mapsegs[2];
  263. for (y=0;y<mapheight;y++)
  264. for (x=0;x<mapwidth;x++)
  265. {
  266. tile = *start++;
  267. hibyte = tile >> 8;
  268. tile &= 0xff;
  269. switch (hibyte)
  270. {
  271. char hi;
  272. case 0xFB:
  273. wall_anim_time = tile;
  274. tile = 0;
  275. break;
  276. case 0xfa: // sky/ground color
  277. case 0xf9: // sky/ground 'strip'
  278. x++;
  279. tile = *start++;
  280. hi = tile >> 8;
  281. tile &= 0xff;
  282. switch (hibyte)
  283. {
  284. case 0xfa: // sky / ground color
  285. scolor = ((hi)|(hi<<8));
  286. gcolor = ((tile)|(tile<<8));
  287. skycolor = &scolor;
  288. groundcolor = &gcolor;
  289. break;
  290. case 0xf9: // sky / ground 'strip'
  291. break;
  292. }
  293. break;
  294. }
  295. if ((!tile) || (hibyte))
  296. continue;
  297. switch (tile)
  298. {
  299. case 1:
  300. case 2:
  301. case 3:
  302. case 4:
  303. lumpneeded[PLAYERLUMP] = true;
  304. SpawnPlayer(x,y,NORTH+tile-1);
  305. break;
  306. case 5:
  307. case 6:
  308. case 7:
  309. case 8:
  310. case 9:
  311. case 10:
  312. case 11:
  313. lumpneeded[tile-5+BOLTLUMP] = true;
  314. SpawnBonus(x,y,tile-5);
  315. break;
  316. #if 0
  317. case 12:
  318. case 13:
  319. case 14:
  320. case 15:
  321. case 16:
  322. case 17:
  323. case 18:
  324. case 19:
  325. lumpneeded[SCROLLLUMP] = true;
  326. SpawnBonus(x,y,B_SCROLL1+tile-12);
  327. break;
  328. #endif
  329. case 20:
  330. lumpneeded[REDDEMONLUMP] = true;
  331. SpawnRedDemon (x,y);
  332. break;
  333. #if 0
  334. case 20: // goal
  335. lumpneeded[GOALLUMP] = true;
  336. SpawnBonus(x,y,B_GOAL);
  337. break;
  338. #endif
  339. case 21:
  340. lumpneeded[GODESSLUMP] = true;
  341. SpawnGodess (x,y);
  342. break;
  343. case 22:
  344. lumpneeded[FATDEMONLUMP] = true;
  345. SpawnFatDemon (x,y);
  346. break;
  347. case 23:
  348. lumpneeded[SUCCUBUSLUMP] = true;
  349. SpawnSuccubus (x,y);
  350. break;
  351. case 24:
  352. lumpneeded[DRAGONLUMP] = true;
  353. SpawnDragon(x,y);
  354. break;
  355. case 25:
  356. lumpneeded[BATLUMP] = true;
  357. SpawnBat (x,y);
  358. break;
  359. case 26:
  360. lumpneeded[EYELUMP] = true;
  361. SpawnEye(x,y);
  362. break;
  363. case 27:
  364. lumpneeded[MAGELUMP] = true;
  365. SpawnMage (x,y);
  366. break;
  367. case 28:
  368. lumpneeded[RKEYLUMP] = lumpneeded[GRELLUMP] = true;
  369. SpawnGrelminar (x,y);
  370. break;
  371. case 30:
  372. lumpneeded[ANTLUMP] = true;
  373. SpawnAnt(x,y);
  374. break;
  375. case 31:
  376. case 32:
  377. case 33:
  378. case 34:
  379. case 35:
  380. lumpneeded[OBJ_WARPLUMP] = true;
  381. SpawnWarp (x,y,tile-30);
  382. break;
  383. case 36:
  384. lumpneeded[ZOMBIELUMP] = true;
  385. SpawnZombie(x,y);
  386. break;
  387. case 37:
  388. lumpneeded[SKELETONLUMP] = true;
  389. SpawnSkeleton(x,y);
  390. break;
  391. case 38:
  392. lumpneeded[SKELETONLUMP] = true;
  393. SpawnWallSkeleton(x,y);
  394. break;
  395. case 39:
  396. lumpneeded[FTIMELUMP] = true;
  397. SpawnFTime(x,y);
  398. break;
  399. case 40:
  400. case 41:
  401. case 42:
  402. case 43:
  403. case 44:
  404. lumpneeded[tile-40+RGEMLUMP] = true;
  405. SpawnBonus(x,y,tile-40+B_RGEM);
  406. break;
  407. case 45:
  408. case 46:
  409. case 47:
  410. lumpneeded[TOMBSTONESLUMP] = true;
  411. SpawnTombstone(x,y,tile-45);
  412. break;
  413. #if 0
  414. case 48:
  415. lumpneeded[PITLUMP] = true;
  416. SpawnWarp(x,y,0);
  417. break;
  418. #endif
  419. case 49: // chest
  420. if (gcolor == 0x0101)
  421. lumpneeded[WATERCHESTLUMP] = true;
  422. else
  423. lumpneeded[CHESTLUMP] = true;
  424. SpawnBonus(x,y,B_CHEST);
  425. break;
  426. case 50:
  427. lumpneeded[TREELUMP] = true;
  428. SpawnTree(x,y);
  429. break;
  430. case 51:
  431. lumpneeded[BUNNYLUMP] = true;
  432. SpawnBunny(x,y);
  433. break;
  434. case 52:
  435. lumpneeded[ARCH1LUMP] = true;
  436. SpawnArch(x,y,1);
  437. break;
  438. case 53:
  439. lumpneeded[ANTHILLLUMP] = true;
  440. SpawnWarp(x,y,0);
  441. break;
  442. case 54:
  443. lumpneeded[COLUMNLUMP] = true;
  444. SpawnMiscObjects(x,y,1); //1=column,2=sulphur hole,3=fire pot,4=fountain
  445. break;
  446. case 55:
  447. lumpneeded[SULPHURGASLUMP] = true;
  448. SpawnMiscObjects(x,y,2);
  449. break;
  450. case 56:
  451. lumpneeded[FIREPOTLUMP] = true;
  452. SpawnMiscObjects(x,y,3);
  453. break;
  454. case 57:
  455. lumpneeded[ARCH13LUMP] = true;
  456. SpawnArch(x,y,13);
  457. break;
  458. case 58:
  459. lumpneeded[FOUNTAINLUMP] = true;
  460. SpawnMiscObjects(x,y,4);
  461. break;
  462. case 59:
  463. lumpneeded[FORCEFIELDLUMP] = true;
  464. SpawnForceField(x,y);
  465. break;
  466. case 60:
  467. lumpneeded[ARCH2LUMP] = true;
  468. SpawnArch(x,y,2);
  469. break;
  470. case 61:
  471. lumpneeded[ARCH3LUMP] = true;
  472. SpawnArch(x,y,3);
  473. break;
  474. case 62:
  475. lumpneeded[ARCH4LUMP] = true;
  476. SpawnArch(x,y,4);
  477. break;
  478. case 63:
  479. lumpneeded[ARCH5LUMP] = true;
  480. SpawnArch(x,y,5);
  481. break;
  482. case 64:
  483. lumpneeded[ARCH6LUMP] = true;
  484. SpawnArch(x,y,6);
  485. break;
  486. case 65:
  487. lumpneeded[SKELHANGLUMP] = true;
  488. lumpneeded[SKELETONLUMP] = true;
  489. SpawnSkeletonHanging(x,y);
  490. break;
  491. case 66:
  492. lumpneeded[ARCH12LUMP] = true;
  493. SpawnArch(x,y,12);
  494. break;
  495. case 67:
  496. lumpneeded[ARCH7LUMP] = true;
  497. SpawnArch(x,y,7);
  498. break;
  499. case 68:
  500. lumpneeded[ARCH8LUMP] = true;
  501. SpawnArch(x,y,8);
  502. break;
  503. case 69:
  504. lumpneeded[ARCH9LUMP] = true;
  505. SpawnArch(x,y,9);
  506. break;
  507. case 70:
  508. lumpneeded[ARCH10LUMP] = true;
  509. SpawnArch(x,y,10);
  510. break;
  511. case 71:
  512. lumpneeded[ARCH11LUMP] = true;
  513. SpawnArch(x,y,11);
  514. break;
  515. }
  516. }
  517. }
  518. //==========================================================================
  519. /*
  520. ==================
  521. =
  522. = ScanText
  523. =
  524. ==================
  525. */
  526. void ScanText (void)
  527. {
  528. int i;
  529. char far *text;
  530. text = (char _seg *)grsegs[LEVEL1TEXT+mapon];
  531. textstarts[0] = 0;
  532. for (i=1;i<=26;i++)
  533. {
  534. while (*text != '\n')
  535. {
  536. if (*text == '\r')
  537. *text = 0;
  538. text++;
  539. }
  540. text++;
  541. textstarts[i] = FP_OFF(text);
  542. }
  543. }
  544. //==========================================================================
  545. /*
  546. ==================
  547. =
  548. = DrawEnterScreen
  549. =
  550. ==================
  551. */
  552. #if 0
  553. static char *levelnames[] =
  554. {
  555. "Programmers Test Map",
  556. "The Garden of Tears",
  557. "The Den of Zombies",
  558. "The Mausoleum Grounds",
  559. "The Main Floor of the Mausoleum",
  560. "Mike's Blastable Passage",
  561. "The Crypt of Nemesis the Undead",
  562. "The Subterranean Vault",
  563. "The Ancient Aqueduct",
  564. "The Orc Mines",
  565. "The Lair of the Troll",
  566. "The Demon's Inferno",
  567. "The Battleground of the Titans",
  568. "The Coven of Mages",
  569. "The Inner Sanctum",
  570. "The Haunt of Nemesis",
  571. "The Passage to the Surface",
  572. "Big Jim's Domain",
  573. "Nolan",
  574. "19",
  575. "20",
  576. "21",
  577. "22",
  578. "23",
  579. "24",
  580. "25",
  581. "26",
  582. "27",
  583. "28",
  584. "29",
  585. "30",
  586. "31",
  587. "32",
  588. "33",
  589. "34",
  590. "35",
  591. "36",
  592. "37",
  593. "38",
  594. "39",
  595. };
  596. #endif
  597. void DrawEnterScreen (void)
  598. {
  599. int width;
  600. bufferofs = displayofs = screenloc[screenpage];
  601. VW_Bar(0,0,VIEWWIDTH,VIEWHEIGHT,0);
  602. // width = strlen(levelnames[gamestate.mapon]);
  603. width = strlen("You enter a new area ...");
  604. if (width < 20)
  605. width = 20;
  606. CenterWindow(width,3);
  607. US_CPrint("\nYou enter a new area ...\n");
  608. // US_CPrint(levelnames[gamestate.mapon]);
  609. }
  610. //==========================================================================
  611. boolean tileneeded[NUMFLOORS];
  612. /*
  613. ==================
  614. =
  615. = CacheScaleds
  616. =
  617. ==================
  618. */
  619. void CacheScaleds (void)
  620. {
  621. int i,j;
  622. unsigned source,dest;
  623. FreeUpMemory ();
  624. CA_CacheGrChunk(LEVEL1TEXT+mapon);
  625. ScanText ();
  626. //
  627. // make sure we are displaying screenpage 0
  628. //
  629. if (screenpage)
  630. {
  631. source = screenloc[screenpage];
  632. dest = screenloc[0];
  633. VW_ScreenToScreen (source,dest,40,VIEWHEIGHT);
  634. screenpage = 0;
  635. VW_SetScreen (dest,0);
  636. displayofs = dest;
  637. }
  638. //
  639. // cache wall pictures
  640. //
  641. for (i=1;i<NUMFLOORS;i++)
  642. if (tileneeded[i])
  643. {
  644. SetupScaleWall (walllight1[i]);
  645. SetupScaleWall (walldark1[i]);
  646. }
  647. //
  648. // cache the actor pictures
  649. //
  650. for (i=0;i<NUMLUMPS;i++)
  651. if (lumpneeded[i])
  652. for (j=lumpstart[i];j<=lumpend[i];j++)
  653. SetupScalePic(j);
  654. source = screenloc[0];
  655. for (i=1;i<=2;i++)
  656. {
  657. dest = screenloc[i];
  658. VW_ScreenToScreen (source,dest,40,VIEWHEIGHT);
  659. }
  660. screenpage = 1;
  661. }
  662. //==========================================================================
  663. /*
  664. ==================
  665. =
  666. = SetupGameLevel
  667. =
  668. ==================
  669. */
  670. void SetupGameLevel ()
  671. {
  672. int x,y,i,loop;
  673. unsigned far *map,tile,far *spotptr,spot;
  674. unsigned search_tile;
  675. boolean exploding_walls_present = false;
  676. memset (tileneeded,0,sizeof(tileneeded));
  677. //
  678. // randomize if not a demo
  679. //
  680. #if 0
  681. if (DemoMode)
  682. {
  683. US_InitRndT(false);
  684. gamestate.difficulty = gd_Normal;
  685. }
  686. else
  687. #endif
  688. US_InitRndT(true);
  689. //
  690. // load the level
  691. //
  692. CA_CacheMap (gamestate.mapon);
  693. mapwidth = mapheaderseg[mapon]->width;
  694. mapheight = mapheaderseg[mapon]->height;
  695. //
  696. // make a lookup table for the maps left edge
  697. //
  698. spot = 0;
  699. for (y=0;y<mapheight;y++)
  700. {
  701. farmapylookup[y] = spot;
  702. spot += mapwidth;
  703. }
  704. //
  705. // copy the wall data to a data segment array
  706. //
  707. memset (tilemap,0,sizeof(tilemap));
  708. memset (actorat,0,sizeof(actorat));
  709. map = mapsegs[0];
  710. spotptr = mapsegs[2];
  711. for (y=0;y<mapheight;y++)
  712. for (x=0;x<mapwidth;x++)
  713. {
  714. tile = *map++;
  715. if (((*spotptr)>>8) == EXP_WALL_CODE)
  716. {
  717. exploding_walls_present = true;
  718. }
  719. if (tile<NUMFLOORS)
  720. {
  721. #if 0
  722. if (tile == WALL_SKELETON_CODE)
  723. {
  724. tileneeded[tile+1] = tileneeded[tile+2] = true;
  725. tilemap[x][y] = tile;
  726. }
  727. #endif
  728. if ((tile == 66) || (tile == 67) || (tile == 68) || (tile == 69))
  729. {
  730. if ((tile == 66) || (tile == 67))
  731. tileneeded[tile+2] = true;
  732. tileneeded[21] = tileneeded[tile] = true;
  733. tilemap[x][y] = tile;
  734. }
  735. else
  736. if (tile != INVISIBLEWALL)
  737. {
  738. tileneeded[tile] = true;
  739. tilemap[x][y] = tile;
  740. if (ANIM_FLAGS(tile))
  741. {
  742. search_tile = tile+(char signed)ANIM_FLAGS(tile);
  743. if (!tileneeded[search_tile])
  744. while (search_tile != tile)
  745. {
  746. tileneeded[search_tile] = true;
  747. if (ANIM_FLAGS(search_tile))
  748. search_tile += (char signed)ANIM_FLAGS(search_tile);
  749. else
  750. TrashProg("Unending Tile Animation!");
  751. }
  752. }
  753. }
  754. if (tile>0)
  755. (unsigned)actorat[x][y] = tile;
  756. }
  757. spotptr++;
  758. }
  759. //
  760. // Mark any gfx chunks needed
  761. //
  762. // CA_MarkGrChunk(NORTHICONSPR);
  763. // CA_CacheMarks(NULL);
  764. //
  765. // decide which graphics are needed and spawn actors
  766. //
  767. zombie_base_delay = 0; // (1*60) + random(1*60);
  768. ScanInfoPlane ();
  769. _fmemset(wall_anim_pos,0,sizeof(wall_anim_pos));
  770. //
  771. // mark which exploding walls are needed ---- the check for floor color
  772. // is preformed in ScanInfoPlane.
  773. //
  774. if (exploding_walls_present)
  775. {
  776. extern unsigned gnd_colors[];
  777. if (gcolor == 0x0101)
  778. tileneeded[WATEREXP] = tileneeded[WATEREXP+1] = tileneeded[WATEREXP+2] = true;
  779. else
  780. tileneeded[WALLEXP] = tileneeded[WALLEXP+1] = tileneeded[WALLEXP+2] = true;
  781. }
  782. //
  783. // have the caching manager load and purge stuff to make sure all marks
  784. // are in memory
  785. //
  786. CA_LoadAllSounds ();
  787. }
  788. //==========================================================================
  789. /*
  790. =====================
  791. =
  792. = LatchDrawPic
  793. =
  794. =====================
  795. */
  796. void LatchDrawPic (unsigned x, unsigned y, unsigned picnum)
  797. {
  798. unsigned height, source, dest;
  799. unsigned wide;
  800. wide = pictable[picnum-STARTPICS].width;
  801. height = pictable[picnum-STARTPICS].height;
  802. dest = bufferofs + ylookup[y]+x;
  803. source = latchpics[picnum-FIRSTLATCHPIC];
  804. EGAWRITEMODE(1);
  805. EGAMAPMASK(15);
  806. asm mov bx,[linewidth]
  807. asm sub bx,[wide]
  808. asm mov ax,[screenseg]
  809. asm mov es,ax
  810. asm mov ds,ax
  811. asm mov si,[source]
  812. asm mov di,[dest]
  813. asm mov dx,[height] // scan lines to draw
  814. asm mov ax,[wide]
  815. lineloop:
  816. asm mov cx,ax
  817. asm rep movsb
  818. asm add di,bx
  819. asm dec dx
  820. asm jnz lineloop
  821. asm mov ax,ss
  822. asm mov ds,ax // restore turbo's data segment
  823. EGAWRITEMODE(0);
  824. }
  825. #if USE_STRIPS
  826. //--------------------------------------------------------------------------
  827. // LatchDrawPicStrip() - srcoff is distance into source file (in PIXELS!)
  828. //--------------------------------------------------------------------------
  829. void LatchDrawPicStrip (unsigned x, unsigned y, unsigned picnum, unsigned srcoff)
  830. {
  831. unsigned wide, height, source, dest, shift, srcmod;
  832. shift = (srcoff & 7) >> 1;
  833. srcoff >>= 3;
  834. wide = pictable[picnum-STARTPICS].width;
  835. srcmod = wide - linewidth + (shift != 3);
  836. if (wide > linewidth)
  837. wide = linewidth;
  838. height = pictable[picnum-STARTPICS].height;
  839. dest = bufferofs + ylookup[y]+x;
  840. picnum = ((picnum - (FIRSTSTRIPPIC+1)) >> 2) + (shift);
  841. source = latchpics[(FIRSTSTRIPPIC-FIRSTLATCHPIC+1)+picnum];
  842. EGAWRITEMODE(1);
  843. EGAMAPMASK(15);
  844. asm mov bx,[linewidth]
  845. asm sub bx,[wide]
  846. asm mov ax,[screenseg]
  847. asm mov es,ax
  848. asm mov ds,ax
  849. asm mov si,[source]
  850. asm add si,[srcoff]
  851. asm mov di,[dest]
  852. asm mov dx,[height] // scan lines to draw
  853. asm mov ax,[wide]
  854. lineloop:
  855. asm mov cx,ax
  856. asm rep movsb
  857. asm add di,bx
  858. asm add si,[srcmod]
  859. asm dec dx
  860. asm jnz lineloop
  861. asm mov ax,ss
  862. asm mov ds,ax // restore turbo's data segment
  863. EGAWRITEMODE(0);
  864. }
  865. #endif
  866. //==========================================================================
  867. /*
  868. =====================
  869. =
  870. = Victory
  871. =
  872. =====================
  873. */
  874. void Victory (boolean playsounds)
  875. {
  876. struct Shape shape;
  877. if (playsounds)
  878. {
  879. SD_PlaySound (GETBOLTSND);
  880. SD_WaitSoundDone ();
  881. SD_PlaySound (GETNUKESND);
  882. SD_WaitSoundDone ();
  883. SD_PlaySound (GETPOTIONSND);
  884. SD_WaitSoundDone ();
  885. SD_PlaySound (GETKEYSND);
  886. SD_WaitSoundDone ();
  887. SD_PlaySound (GETSCROLLSND);
  888. SD_WaitSoundDone ();
  889. SD_PlaySound (GETPOINTSSND);
  890. }
  891. FreeUpMemory();
  892. if (!screenfaded)
  893. VW_FadeOut();
  894. NormalScreen ();
  895. screenpage = bufferofs = 0;
  896. CA_CacheGrChunk (FINALEPIC);
  897. UNMARKGRCHUNK(FINALEPIC);
  898. VW_DrawPic(0, 0, FINALEPIC);
  899. VW_FadeIn();
  900. }
  901. //==========================================================================
  902. #if 0
  903. /*
  904. ===================
  905. =
  906. = Died
  907. =
  908. ===================
  909. */
  910. void Died (void)
  911. {
  912. unsigned page1,page2;
  913. //
  914. // fizzle fade screen to grey
  915. //
  916. FreeUpMemory ();
  917. SD_PlaySound (GAMEOVERSND);
  918. bufferofs = screenloc[(screenpage+1)%3];
  919. DisplayMsg("Though fallen, your Spirit ...",NULL);
  920. // LatchDrawPic(0,0,DEADPIC);
  921. // FizzleFade(bufferofs,displayofs,VIEWWIDTH,VIEWHEIGHT,false);
  922. IN_ClearKeysDown();
  923. while (!Keyboard[sc_Enter]);
  924. // IN_Ack();
  925. VW_SetScreen (bufferofs,0);
  926. VW_ColorBorder(0);
  927. }
  928. #endif
  929. //==========================================================================
  930. /*
  931. ===================
  932. =
  933. = NormalScreen
  934. =
  935. ===================
  936. */
  937. void NormalScreen (void)
  938. {
  939. VW_SetSplitScreen (200);
  940. bufferofs = displayofs = SCREEN1START;
  941. VW_Bar(0,0,320,200,0);
  942. bufferofs = SCREEN2START;
  943. VW_Bar(0,0,320,200,0);
  944. VW_SetScreen (displayofs,0);
  945. splitscreen = false;
  946. }
  947. //==========================================================================
  948. /*
  949. ===================
  950. =
  951. = DrawPlayScreen
  952. =
  953. ===================
  954. */
  955. void DrawPlayScreen (void)
  956. {
  957. int i,j,p,m;
  958. screenpage = 0;
  959. bufferofs = 0;
  960. VW_Bar (0,0,320,STATUSLINES,0);
  961. for (i=0;i<3;i++)
  962. {
  963. bufferofs = screenloc[i];
  964. VW_Bar (0,0,320,VIEWHEIGHT,0);
  965. }
  966. splitscreen = true;
  967. VW_SetSplitScreen(120);
  968. VW_SetScreen(screenloc[0],0);
  969. CA_CacheGrChunk (STATUSPIC);
  970. bufferofs = 0;
  971. VW_DrawPic (0,0,STATUSPIC);
  972. grneeded[STATUSPIC] &= ~ca_levelbit;
  973. MM_SetPurge(&grsegs[STATUSPIC],3);
  974. RedrawStatusWindow ();
  975. bufferofs = displayofs = screenloc[0];
  976. }
  977. //==========================================================================
  978. /*
  979. ===================
  980. =
  981. = LoadLatchMem
  982. =
  983. ===================
  984. */
  985. unsigned latchmemavail;
  986. void LoadLatchMem (void)
  987. {
  988. static unsigned base_destoff=0;
  989. static int base_numpics=0;
  990. int i,j,p,m,numpics;
  991. byte far *src, far *dest;
  992. unsigned destoff;
  993. EGAWRITEMODE(0);
  994. //
  995. // draw some pics into latch memory
  996. //
  997. if (!base_numpics)
  998. {
  999. //
  1000. // tile 8s
  1001. //
  1002. latchpics[0] = freelatch;
  1003. src = (byte _seg *)grsegs[STARTTILE8];
  1004. dest = MK_FP(0xa000,freelatch);
  1005. for (i=0;i<NUMTILE8;i++)
  1006. {
  1007. for (p=0;p<4;p++)
  1008. {
  1009. m = 1<<p;
  1010. asm mov dx,SC_INDEX
  1011. asm mov al,SC_MAPMASK
  1012. asm mov ah,[BYTE PTR m]
  1013. asm out dx,ax
  1014. for (j=0;j<8;j++)
  1015. *(dest+j)=*src++;
  1016. }
  1017. dest+=8;
  1018. }
  1019. //
  1020. // tile 16s
  1021. //
  1022. src = (byte _seg *)grsegs[STARTTILE16];
  1023. for (i=0;i<NUMTILE16;i++)
  1024. {
  1025. CA_CacheGrChunk (STARTTILE16+i);
  1026. src = (byte _seg *)grsegs[STARTTILE16+i];
  1027. if (src)
  1028. {
  1029. tileoffsets[i] = FP_OFF(dest);
  1030. for (p=0;p<4;p++)
  1031. {
  1032. m = 1<<p;
  1033. asm mov dx,SC_INDEX
  1034. asm mov al,SC_MAPMASK
  1035. asm mov ah,[BYTE PTR m]
  1036. asm out dx,ax
  1037. for (j=0;j<32;j++)
  1038. *(dest+j)=*src++;
  1039. }
  1040. dest+=32;
  1041. MM_FreePtr (&grsegs[STARTTILE16+i]);
  1042. UNMARKGRCHUNK(STARTTILE16+i);
  1043. }
  1044. else
  1045. tileoffsets[i] = 0;
  1046. }
  1047. //
  1048. // pics
  1049. //
  1050. numpics=1;
  1051. destoff = FP_OFF(dest);
  1052. for (i=FIRSTLATCHPIC+1;i<FIRSTGROUNDPIC;i++)
  1053. {
  1054. latchpics[numpics++] = destoff;
  1055. CA_CacheGrChunk (i);
  1056. j = pictable[i-STARTPICS].width * pictable[i-STARTPICS].height;
  1057. VW_MemToScreen (grsegs[i],destoff,j,1);
  1058. destoff+=j;
  1059. MM_FreePtr (&grsegs[i]);
  1060. UNMARKGRCHUNK(i);
  1061. }
  1062. base_numpics = numpics;
  1063. base_destoff = destoff;
  1064. }
  1065. numpics = base_numpics;
  1066. destoff = base_destoff;
  1067. #if USE_STRIPS
  1068. //
  1069. // ground pics
  1070. //
  1071. numpics++;
  1072. for (i=FIRSTGROUNDPIC+1;i<FIRSTSTRIPPIC;i++)
  1073. {
  1074. int shape = (*groundcolor & 0xf0) - 16;
  1075. // Is current shape needed?
  1076. //
  1077. if (shape != (i-(FIRSTGROUNDPIC+1)))
  1078. {
  1079. numpics++;
  1080. continue;
  1081. }
  1082. latchpics[numpics++] = destoff;
  1083. CA_CacheGrChunk (i);
  1084. j = pictable[i-STARTPICS].width * pictable[i-STARTPICS].height;
  1085. VW_MemToScreen (grsegs[i],destoff,j,1);
  1086. destoff+=j;
  1087. MM_FreePtr (&grsegs[i]);
  1088. UNMARKGRCHUNK(i);
  1089. }
  1090. //
  1091. // 'parallax' strips - used in place of a sky color
  1092. //
  1093. // Under current setup, each strip takes about 7k in latch memory.
  1094. // To create 2 pixel scrolling, 4 strips are needed, that's 28k of
  1095. // latch memory needed to produce this effect.
  1096. //
  1097. numpics++;
  1098. for (i=FIRSTSTRIPPIC+1;i<FIRSTSCALEPIC;i++)
  1099. {
  1100. memptr work;
  1101. unsigned workdest,stripsize,planesize;
  1102. short loop,pic=i-STARTPICS;
  1103. int shape = (*skycolor & 0xf0) - 16;
  1104. // Is current shape needed?
  1105. //
  1106. if (shape != (i-(FIRSTSTRIPPIC+1)))
  1107. {
  1108. numpics++;
  1109. continue;
  1110. }
  1111. // CAL_ShiftSprite() works with the SRC and DST in the same
  1112. // segment. So we must allocate memory for two strips, and
  1113. // move the base strip into that segment. Then we can use the
  1114. // 2nd half of that memory for each shifted strip.
  1115. //
  1116. CA_CacheGrChunk (i);
  1117. planesize = (pictable[pic].width+1) * pictable[pic].height;
  1118. stripsize = planesize * 4;
  1119. // MM_GetPtr(&work,(stripsize*2)+0000);
  1120. MM_GetPtr(&work,65536);
  1121. movedata((unsigned)grsegs[i],0,(unsigned)work,0,stripsize);
  1122. workdest = 32768; //(stripsize+15) & 0xFFF0;
  1123. // Free base strip
  1124. //
  1125. MM_FreePtr (&grsegs[i]);
  1126. UNMARKGRCHUNK(i);
  1127. // Create three shifted strips and move 'em to latch!
  1128. //
  1129. for (loop=3; loop; loop--)
  1130. {
  1131. // Produce current shift for this strip
  1132. //
  1133. latchpics[numpics++] = destoff;
  1134. CAL_ShiftSprite ((unsigned)work,0,workdest,pictable[pic].width,
  1135. pictable[pic].height,loop*2,false);
  1136. // Copy this shift to latch memory
  1137. //
  1138. VW_MemToScreen ((memptr)((unsigned)work+(workdest>>4)),destoff,planesize,1);
  1139. destoff+=planesize;
  1140. }
  1141. // Copy unshifted strip to latch
  1142. //
  1143. latchpics[numpics++] = destoff;
  1144. planesize = pictable[pic].width * pictable[pic].height;
  1145. VW_MemToScreen (work,destoff,planesize,1);
  1146. destoff+=planesize;
  1147. // Free work buffer
  1148. //
  1149. MM_FreePtr(&work);
  1150. }
  1151. #endif
  1152. // Keep track of how much latch memory we have...
  1153. //
  1154. latchmemavail = 65535-destoff;
  1155. EGAMAPMASK(15);
  1156. }
  1157. //==========================================================================
  1158. /*
  1159. ===================
  1160. =
  1161. = FizzleOut
  1162. =
  1163. ===================
  1164. */
  1165. void FizzleOut (int showlevel)
  1166. {
  1167. unsigned page1,page2;
  1168. //
  1169. // fizzle fade screen to grey
  1170. //
  1171. bufferofs = screenloc[(screenpage+1)%3];
  1172. if (showlevel)
  1173. DrawEnterScreen ();
  1174. FizzleFade(bufferofs,displayofs,VIEWWIDTH,VIEWHEIGHT,false);
  1175. }
  1176. //==========================================================================
  1177. /*
  1178. ====================
  1179. =
  1180. = FreeUpMemory
  1181. =
  1182. ====================
  1183. */
  1184. void FreeUpMemory (void)
  1185. {
  1186. int i;
  1187. for (i=0;i<NUMSCALEPICS;i++)
  1188. if (shapedirectory[i])
  1189. MM_SetPurge (&(memptr)shapedirectory[i],3);
  1190. for (i=0;i<NUMSCALEWALLS;i++)
  1191. if (walldirectory[i])
  1192. MM_SetPurge (&(memptr)walldirectory[i],3);
  1193. }
  1194. //==========================================================================
  1195. #if 0
  1196. /*
  1197. ==================
  1198. =
  1199. = DrawHighScores
  1200. =
  1201. ==================
  1202. */
  1203. void DrawHighScores(void)
  1204. {
  1205. char buffer[16],*str;
  1206. word i,j,
  1207. w,h,
  1208. x,y;
  1209. HighScore *s;
  1210. CA_CacheGrChunk (HIGHSCORESPIC);
  1211. VWB_DrawPic (0,0,HIGHSCORESPIC);
  1212. MM_SetPurge (&grsegs[HIGHSCORESPIC],3);
  1213. UNMARKGRCHUNK(HIGHSCORESPIC);
  1214. for (i = 0,s = Scores;i < MaxScores;i++,s++)
  1215. {
  1216. PrintY = 68 + (16 * i);
  1217. //
  1218. // name
  1219. //
  1220. PrintX = 60;
  1221. US_Print(s->name);
  1222. //
  1223. // level
  1224. //
  1225. ultoa(s->completed,buffer,10);
  1226. for (str = buffer;*str;str++)
  1227. *str = *str + (129 - '0'); // Used fixed-width numbers (129...)
  1228. USL_MeasureString(buffer,&w,&h);
  1229. PrintX = (25 * 8) - 8 - w;
  1230. US_Print(buffer);
  1231. //
  1232. // score
  1233. //
  1234. ultoa(s->score,buffer,10);
  1235. for (str = buffer;*str;str++)
  1236. *str = *str + (129 - '0'); // Used fixed-width numbers (129...)
  1237. USL_MeasureString(buffer,&w,&h);
  1238. PrintX = (34 * 8) - 8 - w;
  1239. US_Print(buffer);
  1240. }
  1241. fontcolor = F_BLACK;
  1242. }
  1243. /*
  1244. =======================
  1245. =
  1246. = CheckHighScore
  1247. =
  1248. =======================
  1249. */
  1250. void CheckHighScore (long score,word other)
  1251. {
  1252. word i,j;
  1253. int n;
  1254. HighScore myscore;
  1255. strcpy(myscore.name,"");
  1256. myscore.score = score;
  1257. myscore.completed = other;
  1258. for (i = 0,n = -1;i < MaxScores;i++)
  1259. {
  1260. if
  1261. (
  1262. (myscore.score > Scores[i].score)
  1263. || (
  1264. (myscore.score == Scores[i].score)
  1265. && (myscore.completed > Scores[i].completed)
  1266. )
  1267. )
  1268. {
  1269. for (j = MaxScores;--j > i;)
  1270. Scores[j] = Scores[j - 1];
  1271. Scores[i] = myscore;
  1272. n = i;
  1273. HighScoresDirty = true;
  1274. break;
  1275. }
  1276. }
  1277. if (n != -1)
  1278. {
  1279. //
  1280. // got a high score
  1281. //
  1282. DrawHighScores ();
  1283. PrintY = 68 + (16 * n);
  1284. PrintX = 60;
  1285. US_LineInput(PrintX,PrintY,Scores[n].name,nil,true,MaxHighName,100);
  1286. }
  1287. }
  1288. #endif
  1289. //==========================================================================
  1290. /*
  1291. ===================
  1292. =
  1293. = GameLoop
  1294. =
  1295. ===================
  1296. */
  1297. void GameLoop (void)
  1298. {
  1299. boolean wait = false;
  1300. int i,xl,yl,xh,yh;
  1301. char num[20];
  1302. #ifdef PROFILE
  1303. clock_t start,end;
  1304. #endif
  1305. DrawPlayScreen ();
  1306. IN_ClearKeysDown();
  1307. restart:
  1308. if (!loadedgame)
  1309. {
  1310. gamestate.difficulty = restartgame;
  1311. restartgame = gd_Continue;
  1312. DrawEnterScreen ();
  1313. if (gamestate.mapon != 8)
  1314. fizzlein = true;
  1315. wait = true;
  1316. }
  1317. do
  1318. {
  1319. playstate = gd_Continue;
  1320. if (!loadedgame)
  1321. SetupGameLevel ();
  1322. else
  1323. loadedgame = false;
  1324. FreeUpMemory();
  1325. LoadLatchMem();
  1326. CacheScaleds ();
  1327. if (EASYMODEON)
  1328. DisplaySMsg("*** NOVICE ***", NULL);
  1329. else
  1330. DisplaySMsg("*** WARRIOR ***", NULL);
  1331. status_delay = 250;
  1332. RedrawStatusWindow();
  1333. if (wait)
  1334. {
  1335. VW_WaitVBL(120);
  1336. wait = false;
  1337. }
  1338. #ifdef PROFILE
  1339. start = clock();
  1340. while (start == clock());
  1341. start++;
  1342. #endif
  1343. PlayLoop ();
  1344. #ifdef PROFILE
  1345. end = clock();
  1346. itoa(end-start,str,10);
  1347. Quit (str);
  1348. #endif
  1349. switch (playstate)
  1350. {
  1351. case ex_abort:
  1352. FreeUpMemory ();
  1353. return;
  1354. case ex_resetgame:
  1355. NewGame();
  1356. case ex_loadedgame:
  1357. case ex_warped:
  1358. FreeUpMemory();
  1359. if (playstate != ex_resetgame)
  1360. DisplayMsg(" ", NULL);
  1361. DisplaySMsg(" ", NULL);
  1362. goto restart;
  1363. case ex_victorious:
  1364. screenpage = 0;
  1365. bufferofs = 0;
  1366. status_flag = 0;
  1367. return;
  1368. }
  1369. } while (1);
  1370. }
  1371. #if 0
  1372. //
  1373. // make wall pictures purgable
  1374. //
  1375. for (i=0;i<NUMSCALEWALLS;i++)
  1376. if (walldirectory[i])
  1377. MM_SetPurge (&(memptr)walldirectory[i],3);
  1378. //
  1379. // cache wall pictures back in
  1380. //
  1381. for (i=1;i<NUMFLOORS;i++)
  1382. if (tileneeded[i])
  1383. {
  1384. SetupScaleWall (walllight1[i]);
  1385. SetupScaleWall (walllight2[i]);
  1386. SetupScaleWall (walldark1[i]);
  1387. SetupScaleWall (walldark2[i]);
  1388. }
  1389. #endif