C5_MAIN.C 20 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  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_MAIN.C
  19. #define CATALOG
  20. #include <time.h>
  21. #include <stdarg.h>
  22. #include "DEF.H"
  23. #include "GELIB.H"
  24. #pragma hdrstop
  25. #include <dir.h>
  26. /*
  27. =============================================================================
  28. LOCAL CONSTANTS
  29. =============================================================================
  30. */
  31. /*
  32. =============================================================================
  33. GLOBAL VARIABLES
  34. =============================================================================
  35. */
  36. PresenterInfo MainHelpText;
  37. GameDiff restartgame;
  38. boolean loadedgame,abortgame,ingame;
  39. memptr scalesegs[NUMPICS];
  40. char str[80],str2[20];
  41. unsigned tedlevelnum;
  42. boolean tedlevel;
  43. gametype gamestate;
  44. exittype playstate;
  45. char SlowMode = 0;
  46. int starting_level;
  47. //extern unsigned scolor,gcolor; //NPM
  48. short NumGames=0;
  49. unsigned Flags=0;
  50. boolean LoadShapes = true;
  51. boolean EASYMODEON = false;
  52. void DisplayIntroText(void);
  53. /*
  54. =============================================================================
  55. LOCAL VARIABLES
  56. =============================================================================
  57. */
  58. //===========================================================================
  59. #if 0
  60. // JAB Hack begin
  61. #define MyInterrupt 0x60
  62. void interrupt (*intaddr)();
  63. void interrupt (*oldintaddr)();
  64. char *JHParmStrings[] = {"no386",nil};
  65. void
  66. jabhack(void)
  67. {
  68. extern void far jabhack2(void);
  69. extern int far CheckIs386(void);
  70. int i;
  71. oldintaddr = getvect(MyInterrupt);
  72. for (i = 1;i < _argc;i++)
  73. if (US_CheckParm(_argv[i],JHParmStrings) == 0)
  74. return;
  75. if (CheckIs386())
  76. {
  77. jabhack2();
  78. setvect(MyInterrupt,intaddr);
  79. }
  80. }
  81. void
  82. jabunhack(void)
  83. {
  84. setvect(MyInterrupt,oldintaddr);
  85. }
  86. // JAB Hack end
  87. #endif
  88. //===========================================================================
  89. /*
  90. =====================
  91. =
  92. = NewGame
  93. =
  94. = Set up new game to start from the beginning
  95. =
  96. =====================
  97. */
  98. void NewGame (void)
  99. {
  100. if (!loadedgame)
  101. {
  102. memset (&gamestate,0,sizeof(gamestate));
  103. gamestate.mapon = starting_level;
  104. gamestate.body = MAXBODY;
  105. }
  106. BGFLAGS = BGF_NOT_LIGHTNING;
  107. Flags &= FL_CLEAR;
  108. boltsleft = bolttimer = 0;
  109. // memset (gamestate.levels,-1,sizeof(gamestate.levels));
  110. }
  111. //===========================================================================
  112. #define RLETAG 0xABCD
  113. /*
  114. ==================
  115. =
  116. = SaveTheGame
  117. =
  118. ==================
  119. */
  120. boolean SaveTheGame(int file)
  121. {
  122. word i,compressed,expanded;
  123. objtype *o;
  124. memptr bigbuffer;
  125. // save the sky and ground colors
  126. if (!CA_FarWrite(file,(void far *)&skycolor,sizeof(skycolor)))
  127. return(false);
  128. if (!CA_FarWrite(file,(void far *)&groundcolor,sizeof(groundcolor)))
  129. return(false);
  130. if (!CA_FarWrite(file,(void far *)&FreezeTime,sizeof(FreezeTime)))
  131. return(false);
  132. if (!CA_FarWrite(file,(void far *)&gamestate,sizeof(gamestate)))
  133. return(false);
  134. if (!CA_FarWrite(file,(void far *)&EASYMODEON,sizeof(EASYMODEON)))
  135. return(false);
  136. expanded = mapwidth * mapheight * 2;
  137. MM_GetPtr (&bigbuffer,expanded);
  138. for (i = 0;i < 3;i+=2) // Write planes 0 and 2
  139. {
  140. //
  141. // leave a word at start of compressed data for compressed length
  142. //
  143. compressed = (unsigned)CA_RLEWCompress ((unsigned huge *)mapsegs[i]
  144. ,expanded,((unsigned huge *)bigbuffer)+1,RLETAG);
  145. *(unsigned huge *)bigbuffer = compressed;
  146. if (!CA_FarWrite(file,(void far *)bigbuffer,compressed+2) )
  147. {
  148. MM_FreePtr (&bigbuffer);
  149. return(false);
  150. }
  151. }
  152. for (o = player;o;o = o->next)
  153. if (!CA_FarWrite(file,(void far *)o,sizeof(objtype)))
  154. {
  155. MM_FreePtr (&bigbuffer);
  156. return(false);
  157. }
  158. MM_FreePtr (&bigbuffer);
  159. return(true);
  160. }
  161. //===========================================================================
  162. /*
  163. ==================
  164. =
  165. = LoadTheGame
  166. =
  167. ==================
  168. */
  169. boolean LoadTheGame(int file)
  170. {
  171. unsigned i,x,y;
  172. objtype *obj,*prev,*next,*followed;
  173. unsigned compressed,expanded;
  174. unsigned far *map,tile;
  175. memptr bigbuffer;
  176. screenpage = 0;
  177. FreeUpMemory();
  178. playstate = ex_loadedgame;
  179. // load the sky and ground colors
  180. if (!CA_FarRead(file,(void far *)&skycolor,sizeof(skycolor)))
  181. return(false);
  182. if (!CA_FarRead(file,(void far *)&groundcolor,sizeof(groundcolor)))
  183. return(false);
  184. if (!CA_FarRead(file,(void far *)&FreezeTime,sizeof(FreezeTime)))
  185. return(false);
  186. if (!CA_FarRead(file,(void far *)&gamestate,sizeof(gamestate)))
  187. return(false);
  188. if (!CA_FarRead(file,(void far *)&EASYMODEON,sizeof(EASYMODEON)))
  189. return(false);
  190. SetupGameLevel (); // load in and cache the base old level
  191. if (!FindFile(Filename,"SAVE GAME",-1))
  192. Quit("Error: Can't find saved game file!");
  193. expanded = mapwidth * mapheight * 2;
  194. MM_GetPtr (&bigbuffer,expanded);
  195. for (i = 0;i < 3;i+=2) // Read planes 0 and 2
  196. {
  197. if (!CA_FarRead(file,(void far *)&compressed,sizeof(compressed)) )
  198. {
  199. MM_FreePtr (&bigbuffer);
  200. return(false);
  201. }
  202. if (!CA_FarRead(file,(void far *)bigbuffer,compressed) )
  203. {
  204. MM_FreePtr (&bigbuffer);
  205. return(false);
  206. }
  207. CA_RLEWexpand ((unsigned huge *)bigbuffer,
  208. (unsigned huge *)mapsegs[i],expanded,RLETAG);
  209. }
  210. MM_FreePtr (&bigbuffer);
  211. //
  212. // copy the wall data to a data segment array again, to handle doors and
  213. // bomb walls that are allready opened
  214. //
  215. memset (tilemap,0,sizeof(tilemap));
  216. memset (actorat,0,sizeof(actorat));
  217. map = mapsegs[0];
  218. for (y=0;y<mapheight;y++)
  219. for (x=0;x<mapwidth;x++)
  220. {
  221. tile = *map++;
  222. if (tile<NUMFLOORS)
  223. {
  224. if (tile != INVISIBLEWALL)
  225. tilemap[x][y] = tile;
  226. if (tile>0)
  227. (unsigned)actorat[x][y] = tile;
  228. }
  229. }
  230. // Read the object list back in - assumes at least one object in list
  231. InitObjList ();
  232. new = player;
  233. while (true)
  234. {
  235. prev = new->prev;
  236. next = new->next;
  237. if (!CA_FarRead(file,(void far *)new,sizeof(objtype)))
  238. return(false);
  239. followed = new->next;
  240. new->prev = prev;
  241. new->next = next;
  242. actorat[new->tilex][new->tiley] = new; // drop a new marker
  243. if (followed)
  244. GetNewObj (false);
  245. else
  246. break;
  247. }
  248. return(true);
  249. }
  250. //===========================================================================
  251. /*
  252. ==================
  253. =
  254. = ResetGame
  255. =
  256. ==================
  257. */
  258. void ResetGame(void)
  259. {
  260. NewGame ();
  261. ca_levelnum--;
  262. ca_levelbit>>=1;
  263. CA_ClearMarks();
  264. ca_levelbit<<=1;
  265. ca_levelnum++;
  266. }
  267. //===========================================================================
  268. /*
  269. ==========================
  270. =
  271. = ShutdownId
  272. =
  273. = Shuts down all ID_?? managers
  274. =
  275. ==========================
  276. */
  277. void ShutdownId (void)
  278. {
  279. US_Shutdown ();
  280. #ifndef PROFILE
  281. SD_Shutdown ();
  282. IN_Shutdown ();
  283. #endif
  284. VW_Shutdown ();
  285. CA_Shutdown ();
  286. MM_Shutdown ();
  287. }
  288. //===========================================================================
  289. /*
  290. ==========================
  291. =
  292. = InitGame
  293. =
  294. = Load a few things right away
  295. =
  296. ==========================
  297. */
  298. void InitGame (void)
  299. {
  300. unsigned segstart,seglength;
  301. int i,x,y;
  302. unsigned *blockstart;
  303. // US_TextScreen();
  304. MM_Startup ();
  305. VW_Startup ();
  306. #ifndef PROFILE
  307. IN_Startup ();
  308. SD_Startup ();
  309. #endif
  310. US_Startup ();
  311. // US_UpdateTextScreen();
  312. CA_Startup ();
  313. US_Setup ();
  314. US_SetLoadSaveHooks(LoadTheGame,SaveTheGame,ResetGame);
  315. //
  316. // load in and lock down some basic chunks
  317. //
  318. CA_ClearMarks ();
  319. CA_MarkGrChunk(STARTFONT);
  320. CA_MarkGrChunk(STARTTILE8);
  321. CA_MarkGrChunk(STARTTILE8M);
  322. CA_MarkGrChunk(HAND1PICM);
  323. CA_MarkGrChunk(NORTHICONSPR);
  324. CA_CacheMarks (NULL);
  325. MM_SetLock (&grsegs[STARTFONT],true);
  326. MM_SetLock (&grsegs[STARTTILE8],true);
  327. MM_SetLock (&grsegs[STARTTILE8M],true);
  328. MM_SetLock (&grsegs[HAND1PICM],true);
  329. fontcolor = WHITE;
  330. //
  331. // build some tables
  332. //
  333. for (i=0;i<MAPSIZE;i++)
  334. nearmapylookup[i] = &tilemap[0][0]+MAPSIZE*i;
  335. for (i=0;i<PORTTILESHIGH;i++)
  336. uwidthtable[i] = UPDATEWIDE*i;
  337. blockstart = &blockstarts[0];
  338. for (y=0;y<UPDATEHIGH;y++)
  339. for (x=0;x<UPDATEWIDE;x++)
  340. *blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;
  341. BuildTables (); // 3-d tables
  342. SetupScaling ();
  343. #ifndef PROFILE
  344. // US_FinishTextScreen();
  345. #endif
  346. #if 0
  347. //
  348. // reclaim the memory from the linked in text screen
  349. //
  350. segstart = FP_SEG(&introscn);
  351. seglength = 4000/16;
  352. if (FP_OFF(&introscn))
  353. {
  354. segstart++;
  355. seglength--;
  356. }
  357. MML_UseSpace (segstart,seglength);
  358. #endif
  359. VW_SetScreenMode (GRMODE);
  360. ge_textmode = false;
  361. // VW_ColorBorder (3);
  362. VW_ClearVideo (BLACK);
  363. //
  364. // initialize variables
  365. //
  366. updateptr = &update[0];
  367. *(unsigned *)(updateptr + UPDATEWIDE*PORTTILESHIGH) = UPDATETERMINATE;
  368. bufferofs = 0;
  369. displayofs = 0;
  370. VW_SetLineWidth(SCREENWIDTH);
  371. }
  372. //===========================================================================
  373. void clrscr (void); // can't include CONIO.H because of name conflicts...
  374. /*
  375. ==========================
  376. =
  377. = Quit
  378. =
  379. ==========================
  380. */
  381. void Quit (char *error, ...)
  382. {
  383. short exit_code=0;
  384. unsigned finscreen;
  385. va_list ap;
  386. va_start(ap,error);
  387. #ifndef CATALOG
  388. if (!error)
  389. {
  390. CA_SetAllPurge ();
  391. CA_CacheGrChunk (PIRACY);
  392. finscreen = (unsigned)grsegs[PIRACY];
  393. }
  394. #endif
  395. ShutdownId ();
  396. if (error && *error)
  397. {
  398. vprintf(error,ap);
  399. exit_code = 1;
  400. }
  401. #ifndef CATALOG
  402. else
  403. if (!NoWait)
  404. {
  405. movedata (finscreen,0,0xb800,0,4000);
  406. bioskey (0);
  407. }
  408. #endif
  409. va_end(ap);
  410. #ifndef CATALOG
  411. if (!error)
  412. {
  413. _argc = 2;
  414. _argv[1] = "LAST.SHL";
  415. _argv[2] = "ENDSCN.SCN";
  416. _argv[3] = NULL;
  417. if (execv("LOADSCN.EXE", _argv) == -1)
  418. {
  419. clrscr();
  420. puts("Couldn't find executable LOADSCN.EXE.\n");
  421. exit(1);
  422. }
  423. }
  424. #endif
  425. exit(exit_code);
  426. }
  427. //===========================================================================
  428. /*
  429. ==================
  430. =
  431. = TEDDeath
  432. =
  433. ==================
  434. */
  435. void TEDDeath(void)
  436. {
  437. ShutdownId();
  438. execlp("TED5.EXE","TED5.EXE","/LAUNCH",NULL);
  439. }
  440. //===========================================================================
  441. /*
  442. ====================
  443. =
  444. = DisplayDepartment
  445. =
  446. ====================
  447. */
  448. void DisplayDepartment(char *text)
  449. {
  450. short temp;
  451. // bufferofs = 0;
  452. PrintY = 1;
  453. WindowX = 0;
  454. WindowW = 320;
  455. VW_Bar(WindowX,PrintY+1,WindowW,7,7);
  456. temp = fontcolor;
  457. fontcolor = 2;
  458. US_CPrintLine (text);
  459. fontcolor = temp;
  460. }
  461. /*
  462. =====================
  463. =
  464. = DemoLoop
  465. =
  466. =====================
  467. */
  468. void DemoLoop (void)
  469. {
  470. /////////////////////////////////////////////////////////////////////////////
  471. // main game cycle
  472. /////////////////////////////////////////////////////////////////////////////
  473. displayofs = bufferofs = 0;
  474. VW_Bar (0,0,320,200,0);
  475. VW_SetScreen(0,0);
  476. //
  477. // Read in all the graphic images needed for the title sequence
  478. //
  479. VW_WaitVBL(1);
  480. IN_ReadControl(0,&control);
  481. // set EASYMODE
  482. //
  483. if (stricmp(_argv[2], "1") == 0)
  484. EASYMODEON = true;
  485. else
  486. EASYMODEON = false;
  487. // restore game
  488. //
  489. if (stricmp(_argv[3], "1") == 0)
  490. {
  491. VW_FadeOut();
  492. bufferofs = displayofs = 0;
  493. VW_Bar(0,0,320,200,0);
  494. if (GE_LoadGame())
  495. {
  496. loadedgame = true;
  497. playstate = ex_loadedgame;
  498. Keyboard[sc_Enter] = true;
  499. VW_Bar(0,0,320,200,0);
  500. ColoredPalette();
  501. }
  502. VW_Bar(0,0,320,200,0);
  503. VW_FadeIn();
  504. }
  505. // Play a game
  506. //
  507. restartgame = gd_Normal;
  508. NewGame();
  509. GameLoop();
  510. }
  511. //-------------------------------------------------------------------------
  512. // DisplayIntroText()
  513. //-------------------------------------------------------------------------
  514. void DisplayIntroText()
  515. {
  516. PresenterInfo pi;
  517. #ifdef TEXT_PRESENTER
  518. char *toptext = "You stand before the gate leading into the Towne "
  519. "of Morbidity.... "
  520. "^XX";
  521. char *bottomtext = "Enter now boldly to defeat the evil Nemesis "
  522. "deep inside the catacombs."
  523. "
  524. "^XX";
  525. #endif
  526. char oldfontcolor=fontcolor;
  527. fontcolor = 14;
  528. #ifdef TEXT_PRESENTER
  529. pi.xl = 0;
  530. pi.yl = 0;
  531. pi.xh = 319;
  532. pi.yh = 1;
  533. pi.bgcolor = 0;
  534. pi.script[0] = (char far *)toptext;
  535. Presenter(&pi);
  536. pi.yl = 160;
  537. pi.yh = 161;
  538. pi.script[0] = (char far *)bottomtext;
  539. Presenter(&pi);
  540. #else
  541. PrintY = 1;
  542. PrintX = 0;
  543. WindowX = 0;
  544. WindowW = 320;
  545. US_Print (" You stand before the gate leading into\n");
  546. US_Print (" the Towne of Morbidity...\n");
  547. PrintY = 180;
  548. US_Print (" Enter now boldly to defeat the evil Nemesis\n");
  549. US_Print (" deep inside the catacombs.\n");
  550. #endif
  551. fontcolor = oldfontcolor;
  552. }
  553. #if 0
  554. boolean ChooseGameLevel()
  555. {
  556. char choices[] = {sc_Escape,sc_E,sc_N,sc_H,0},ch;
  557. CenterWindow(20,10);
  558. US_Print("\n Choose difficulty level:\n");
  559. US_Print(" (E)asy\n");
  560. US_Print(" (N)ormal\n");
  561. US_Print(" (H)ard\n");
  562. US_Print("\n (ESC)ape aborts\n");
  563. // VW_UpdateScreen();
  564. if ((ch=GetKeyChoice(choices)) == sc_Escape)
  565. {
  566. while (Keyboard[sc_Escape]);
  567. LastScan = 0;
  568. return(false);
  569. }
  570. if (ch == sc_E)
  571. restartgame = gd_Easy;
  572. else
  573. if (ch == sc_N)
  574. restartgame = gd_Normal;
  575. else
  576. restartgame = gd_Hard;
  577. return(true);
  578. }
  579. #endif
  580. //===========================================================================
  581. /*
  582. ==========================
  583. =
  584. = SetupScalePic
  585. =
  586. ==========================
  587. */
  588. void SetupScalePic (unsigned picnum)
  589. {
  590. unsigned scnum;
  591. if (picnum == 1)
  592. return;
  593. scnum = picnum-FIRSTSCALEPIC;
  594. if (shapedirectory[scnum])
  595. {
  596. MM_SetPurge (&(memptr)shapedirectory[scnum],0);
  597. return; // allready in memory
  598. }
  599. CA_CacheGrChunk (picnum);
  600. DeplanePic (picnum);
  601. shapesize[scnum] = BuildCompShape (&shapedirectory[scnum]);
  602. grneeded[picnum]&= ~ca_levelbit;
  603. MM_FreePtr (&grsegs[picnum]);
  604. }
  605. //===========================================================================
  606. /*
  607. ==========================
  608. =
  609. = SetupScaleWall
  610. =
  611. ==========================
  612. */
  613. void SetupScaleWall (unsigned picnum)
  614. {
  615. int x,y;
  616. unsigned scnum;
  617. byte far *dest;
  618. if (picnum == 1)
  619. return;
  620. scnum = picnum-FIRSTWALLPIC;
  621. if (walldirectory[scnum])
  622. {
  623. MM_SetPurge (&walldirectory[scnum],0);
  624. return; // allready in memory
  625. }
  626. CA_CacheGrChunk (picnum);
  627. DeplanePic (picnum);
  628. MM_GetPtr(&walldirectory[scnum],64*64);
  629. dest = (byte far *)walldirectory[scnum];
  630. for (x=0;x<64;x++)
  631. for (y=0;y<64;y++)
  632. *dest++ = spotvis[y][x];
  633. grneeded[picnum]&= ~ca_levelbit;
  634. MM_FreePtr (&grsegs[picnum]);
  635. }
  636. //===========================================================================
  637. /*
  638. ==========================
  639. =
  640. = SetupScaling
  641. =
  642. ==========================
  643. */
  644. void SetupScaling (void)
  645. {
  646. int i,x,y;
  647. byte far *dest;
  648. //
  649. // build the compiled scalers
  650. //
  651. for (i=1;i<=VIEWWIDTH/2;i++)
  652. BuildCompScale (i*2,&scaledirectory[i]);
  653. }
  654. //===========================================================================
  655. int showscorebox;
  656. void RF_FixOfs (void)
  657. {
  658. }
  659. void HelpScreens (void)
  660. {
  661. }
  662. #if 0
  663. /*
  664. ==================
  665. =
  666. = CheckMemory
  667. =
  668. ==================
  669. */
  670. #define MINMEMORY 400000l
  671. void CheckMemory(void)
  672. {
  673. unsigned finscreen;
  674. if (Flags & FL_NOMEMCHECK)
  675. return;
  676. if (mminfo.nearheap+mminfo.farheap+mminfo.EMSmem+mminfo.XMSmem
  677. >= MINMEMORY)
  678. return;
  679. CA_CacheGrChunk (OUTOFMEM);
  680. finscreen = (unsigned)grsegs[OUTOFMEM];
  681. ShutdownId ();
  682. movedata (finscreen,7,0xb800,0,4000);
  683. gotoxy (1,24);
  684. exit(1);
  685. }
  686. #endif
  687. //===========================================================================
  688. /*
  689. ==========================
  690. =
  691. = main
  692. =
  693. ==========================
  694. */
  695. char *MainParmStrings[] = {"q","l","ver","nomemcheck","helptest",nil};
  696. void main (void)
  697. {
  698. short i;
  699. starting_level = 0;
  700. for (i = 1;i < _argc;i++)
  701. {
  702. switch (US_CheckParm(_argv[i],MainParmStrings))
  703. {
  704. case 0:
  705. Flags |= FL_QUICK;
  706. break;
  707. case 1:
  708. starting_level = atoi(_argv[i]+1);
  709. if ((starting_level < 0) || (starting_level > LASTMAP-1))
  710. starting_level = 0;
  711. break;
  712. case 2:
  713. printf("%s\n", GAMENAME);
  714. printf("Copyright 1992-93 Softdisk Publishing\n");
  715. printf("%s %s\n",VERSION,REVISION);
  716. printf("\n");
  717. exit(0);
  718. break;
  719. case 3:
  720. Flags |= FL_NOMEMCHECK;
  721. break;
  722. case 4:
  723. Flags |= (FL_HELPTEST|FL_QUICK);
  724. break;
  725. }
  726. }
  727. if (stricmp(_argv[1], "^(a@&r`"))
  728. Quit("You must type CATARM to run CATACOMB ARMAGEDDON 3-D\n");
  729. MainHelpText.xl = 0;
  730. MainHelpText.yl = 0;
  731. MainHelpText.xh = 639;
  732. MainHelpText.yh = 199;
  733. MainHelpText.bgcolor = 7;
  734. MainHelpText.ltcolor = 15;
  735. MainHelpText.dkcolor = 8;
  736. // jabhack();
  737. randomize();
  738. InitGame ();
  739. // CheckMemory ();
  740. LoadLatchMem ();
  741. // if (!LoadTextFile("MAINHELP."EXT,&MainHelpText))
  742. // Quit("Can't load MAINHELP."EXT);
  743. #ifdef PROFILE
  744. NewGame ();
  745. GameLoop ();
  746. #endif
  747. DemoLoop();
  748. Quit(NULL);
  749. }
  750. //-------------------------------------------------------------------------
  751. // Display640()
  752. //-------------------------------------------------------------------------
  753. void Display640()
  754. {
  755. // Can you believe it takes all this just to change to 640 mode!!???!
  756. //
  757. VW_ScreenToScreen(0,FREESTART-STATUSLEN,40,80);
  758. VW_SetLineWidth(80);
  759. MoveScreen(0,0);
  760. VW_Bar (0,0,640,200,0);
  761. VW_SetScreenMode(EGA640GR);
  762. VW_SetLineWidth(80);
  763. BlackPalette();
  764. }
  765. //-------------------------------------------------------------------------
  766. // Display320()
  767. //-------------------------------------------------------------------------
  768. void Display320()
  769. {
  770. // Can you believe it takes all this just to change to 320 mode!!???!
  771. //
  772. VW_ColorBorder(0);
  773. VW_FadeOut();
  774. VW_SetLineWidth(40);
  775. MoveScreen(0,0);
  776. VW_Bar (0,0,320,200,0);
  777. VW_SetScreenMode(EGA320GR);
  778. BlackPalette();
  779. VW_ScreenToScreen(FREESTART-STATUSLEN,0,40,80);
  780. }
  781. void PrintHelp(void)
  782. {
  783. char oldfontcolor = fontcolor;
  784. PrintY = 1;
  785. WindowX = 135;
  786. WindowW = 640;
  787. VW_FadeOut();
  788. bufferofs = displayofs = screenloc[0];
  789. VW_Bar(0,0,320,200,0);
  790. Display640();
  791. VW_Bar(0, 0, 640, 200, 7);
  792. fontcolor = (7 ^ 1);
  793. US_Print ("\n\n SUMMARY OF GAME CONTROLS\n\n");
  794. fontcolor = (7 ^ 4);
  795. US_Print (" ACTION\n\n");
  796. US_Print ("Arrow keys, joystick, or mouse\n");
  797. US_Print ("TAB or V while turning\n");
  798. US_Print ("ALT or Button 2 while turning\n");
  799. US_Print ("CTRL or Button 1\n");
  800. US_Print ("Z\n");
  801. US_Print ("X or Enter\n");
  802. US_Print ("F1\n");
  803. US_Print ("F2\n");
  804. US_Print ("F3\n");
  805. US_Print ("F4\n");
  806. US_Print ("F5\n");
  807. US_Print ("ESC\n\n");
  808. #ifndef CATALOG
  809. fontcolor = (7 ^ 0);
  810. US_Print (" (See complete Instructions for more info)\n");
  811. #endif
  812. fontcolor = (7 ^ 8);
  813. PrintX = 400;
  814. PrintY = 37;
  815. WindowX = 400;
  816. US_Print (" REACTION\n\n");
  817. US_Print ("Move and turn\n");
  818. US_Print ("Turn quickly (Quick Turn)\n");
  819. US_Print ("Move sideways\n");
  820. US_Print ("Shoot a Missile\n");
  821. US_Print ("Shoot a Zapper\n");
  822. US_Print ("Shoot an Xterminator\n");
  823. US_Print ("Help (this screen)\n");
  824. US_Print ("Sound control\n");
  825. US_Print ("Save game position\n");
  826. US_Print ("Restore a saved game\n");
  827. US_Print ("Joystick control\n");
  828. US_Print ("System options\n\n\n");
  829. VW_UpdateScreen();
  830. VW_FadeIn();
  831. VW_ColorBorder(8 | 56);
  832. IN_Ack();
  833. Display320();
  834. fontcolor = oldfontcolor;
  835. }