home *** CD-ROM | disk | FTP | other *** search
/ 100 af Verdens Bedste Spil / 100Spil.iso / dos / wolf3d / source / wolfsrc.1 / WL_INTER.C < prev    next >
C/C++ Source or Header  |  1994-04-05  |  32KB  |  1,719 lines

  1. // WL_INTER.C
  2.  
  3. #include "WL_DEF.H"
  4. #pragma hdrstop
  5.  
  6.  
  7. //==========================================================================
  8.  
  9. /*
  10. ==================
  11. =
  12. = CLearSplitVWB
  13. =
  14. ==================
  15. */
  16.  
  17. void ClearSplitVWB (void)
  18. {
  19.     memset (update,0,sizeof(update));
  20.     WindowX = 0;
  21.     WindowY = 0;
  22.     WindowW = 320;
  23.     WindowH = 160;
  24. }
  25.  
  26.  
  27. //==========================================================================
  28.  
  29. #ifdef SPEAR
  30. #ifndef SPEARDEMO
  31. ////////////////////////////////////////////////////////
  32. //
  33. // End of Spear of Destiny
  34. //
  35. ////////////////////////////////////////////////////////
  36.  
  37. void EndScreen (int palette, int screen)
  38. {
  39.     CA_CacheScreen (screen);
  40.     VW_UpdateScreen ();
  41.     CA_CacheGrChunk (palette);
  42.     VL_FadeIn(0,255,grsegs[palette],30);
  43.     UNCACHEGRCHUNK (palette);
  44.     IN_ClearKeysDown ();
  45.     IN_Ack ();
  46.     VW_FadeOut ();
  47. }
  48.  
  49.  
  50. void EndSpear(void)
  51. {
  52.     EndScreen (END1PALETTE, ENDSCREEN11PIC);
  53.  
  54.     CA_CacheScreen (ENDSCREEN3PIC);
  55.     VW_UpdateScreen ();
  56.     CA_CacheGrChunk (END3PALETTE);
  57.     VL_FadeIn(0,255,grsegs[END3PALETTE],30);
  58.     UNCACHEGRCHUNK (END3PALETTE);
  59.     fontnumber = 0;
  60.     fontcolor = 0xd0;
  61.     WindowX = 0;
  62.     WindowW = 320;
  63.     PrintX = 0;
  64.     PrintY = 180;
  65.     US_CPrint (STR_ENDGAME1"\n");
  66.     US_CPrint (STR_ENDGAME2);
  67.     VW_UpdateScreen ();
  68.     IN_StartAck ();
  69.     TimeCount = 0;
  70.     while (!IN_CheckAck () && TimeCount < 700);
  71.  
  72.     PrintX = 0;
  73.     PrintY = 180;
  74.     VWB_Bar(0,180,320,20,0);
  75.     US_CPrint (STR_ENDGAME3"\n");
  76.     US_CPrint (STR_ENDGAME4);
  77.     VW_UpdateScreen ();
  78.     IN_StartAck ();
  79.     TimeCount = 0;
  80.     while (!IN_CheckAck () && TimeCount < 700);
  81.  
  82.     VW_FadeOut ();
  83.  
  84.     EndScreen (END4PALETTE, ENDSCREEN4PIC);
  85.     EndScreen (END5PALETTE, ENDSCREEN5PIC);
  86.     EndScreen (END6PALETTE, ENDSCREEN6PIC);
  87.     EndScreen (END7PALETTE, ENDSCREEN7PIC);
  88.     EndScreen (END8PALETTE, ENDSCREEN8PIC);
  89.     EndScreen (END9PALETTE, ENDSCREEN9PIC);
  90.  
  91.     EndScreen (END2PALETTE, ENDSCREEN12PIC);
  92.  
  93.     MainMenu[savegame].active = 0;
  94. }
  95. #endif
  96. #endif
  97.  
  98. //==========================================================================
  99.  
  100. /*
  101. ==================
  102. =
  103. = Victory
  104. =
  105. ==================
  106. */
  107.  
  108. void Victory (void)
  109. {
  110. #ifndef SPEARDEMO
  111.     long    sec;
  112.     int i,min,kr,sr,tr,x;
  113.     char tempstr[8];
  114.  
  115. #define RATIOX    6
  116. #define RATIOY    14
  117. #define TIMEX    14
  118. #define TIMEY    8
  119.  
  120.  
  121. #ifdef SPEAR
  122.     StartCPMusic (XTHEEND_MUS);
  123.  
  124.     CA_CacheGrChunk(BJCOLLAPSE1PIC);
  125.     CA_CacheGrChunk(BJCOLLAPSE2PIC);
  126.     CA_CacheGrChunk(BJCOLLAPSE3PIC);
  127.     CA_CacheGrChunk(BJCOLLAPSE4PIC);
  128.  
  129.     VWB_Bar(0,0,320,200,VIEWCOLOR);
  130.     VWB_DrawPic (124,44,BJCOLLAPSE1PIC);
  131.     VW_UpdateScreen ();
  132.     VW_FadeIn ();
  133.     VW_WaitVBL(2*70);
  134.     VWB_DrawPic (124,44,BJCOLLAPSE2PIC);
  135.     VW_UpdateScreen ();
  136.     VW_WaitVBL(105);
  137.     VWB_DrawPic (124,44,BJCOLLAPSE3PIC);
  138.     VW_UpdateScreen ();
  139.     VW_WaitVBL(105);
  140.     VWB_DrawPic (124,44,BJCOLLAPSE4PIC);
  141.     VW_UpdateScreen ();
  142.     VW_WaitVBL(3*70);
  143.  
  144.     UNCACHEGRCHUNK(BJCOLLAPSE1PIC);
  145.     UNCACHEGRCHUNK(BJCOLLAPSE2PIC);
  146.     UNCACHEGRCHUNK(BJCOLLAPSE3PIC);
  147.     UNCACHEGRCHUNK(BJCOLLAPSE4PIC);
  148.     VL_FadeOut (0,255,0,17,17,5);
  149. #endif
  150.  
  151.     StartCPMusic (URAHERO_MUS);
  152.     ClearSplitVWB ();
  153.     CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);
  154.     CA_CacheGrChunk(STARTFONT);
  155.  
  156. #ifndef SPEAR
  157.     CA_CacheGrChunk(C_TIMECODEPIC);
  158. #endif
  159.  
  160.  
  161.     VWB_Bar (0,0,320,200-STATUSLINES,127);
  162. #ifdef JAPAN
  163. #ifndef JAPDEMO
  164.     CA_CacheGrChunk(C_ENDRATIOSPIC);
  165.     VWB_DrawPic(0,0,C_ENDRATIOSPIC);
  166.     UNCACHEGRCHUNK(C_ENDRATIOSPIC);
  167. #endif
  168. #else
  169.     Write(18,2,STR_YOUWIN);
  170.  
  171.     Write(TIMEX,TIMEY-2,STR_TOTALTIME);
  172.  
  173.     Write(12,RATIOY-2,"averages");
  174.  
  175.     #ifdef SPANISH
  176.     Write(RATIOX+2,  RATIOY,      STR_RATKILL);
  177.     Write(RATIOX+2,  RATIOY+2,  STR_RATSECRET);
  178.     Write(RATIOX+2,  RATIOY+4,STR_RATTREASURE);
  179.     #else
  180.     Write(RATIOX+8,RATIOY,      STR_RATKILL);
  181.     Write(RATIOX+4,RATIOY+2,  STR_RATSECRET);
  182.     Write(RATIOX,  RATIOY+4,STR_RATTREASURE);
  183.     #endif
  184.  
  185. #endif
  186.  
  187. #ifndef JAPDEMO
  188.     VWB_DrawPic (8,4,L_BJWINSPIC);
  189. #endif
  190.  
  191.  
  192. #ifndef SPEAR
  193.     for (kr = sr = tr = sec = i = 0;i < 8;i++)
  194. #else
  195.     for (kr = sr = tr = sec = i = 0;i < 20;i++)
  196. #endif
  197.     {
  198.         sec += LevelRatios[i].time;
  199.         kr += LevelRatios[i].kill;
  200.         sr += LevelRatios[i].secret;
  201.         tr += LevelRatios[i].treasure;
  202.     }
  203.  
  204. #ifndef SPEAR
  205.     kr /= 8;
  206.     sr /= 8;
  207.     tr /= 8;
  208. #else
  209.     kr /= 14;
  210.     sr /= 14;
  211.     tr /= 14;
  212. #endif
  213.  
  214.     min = sec/60;
  215.     sec %= 60;
  216.  
  217.     if (min > 99)
  218.         min = sec = 99;
  219.  
  220.     i = TIMEX*8+1;
  221.     VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min/10));
  222.     i += 2*8;
  223.     VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min%10));
  224.     i += 2*8;
  225.     Write(i/8,TIMEY,":");
  226.     i += 1*8;
  227.     VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec/10));
  228.     i += 2*8;
  229.     VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec%10));
  230.     VW_UpdateScreen ();
  231.  
  232.     itoa(kr,tempstr,10);
  233.     x=RATIOX+24-strlen(tempstr)*2;
  234.     Write(x,RATIOY,tempstr);
  235.  
  236.     itoa(sr,tempstr,10);
  237.     x=RATIOX+24-strlen(tempstr)*2;
  238.     Write(x,RATIOY+2,tempstr);
  239.  
  240.     itoa(tr,tempstr,10);
  241.     x=RATIOX+24-strlen(tempstr)*2;
  242.     Write(x,RATIOY+4,tempstr);
  243.  
  244.  
  245. #ifndef SPANISH
  246. #ifndef UPLOAD
  247. #ifndef SPEAR
  248.     //
  249.     // TOTAL TIME VERIFICATION CODE
  250.     //
  251.     if (gamestate.difficulty>=gd_medium)
  252.     {
  253.         VWB_DrawPic (30*8,TIMEY*8,C_TIMECODEPIC);
  254.         fontnumber = 0;
  255.         fontcolor = READHCOLOR;
  256.         PrintX = 30*8-3;
  257.         PrintY = TIMEY*8+8;
  258.         PrintX+=4;
  259.         tempstr[0] = (((min/10)^(min%10))^0xa)+'A';
  260.         tempstr[1] = (((sec/10)^(sec%10))^0xa)+'A';
  261.         tempstr[2] = (tempstr[0]^tempstr[1])+'A';
  262.         tempstr[3] = 0;
  263.         US_Print(tempstr);
  264.     }
  265. #endif
  266. #endif
  267. #endif
  268.  
  269.  
  270.     fontnumber = 1;
  271.  
  272.     VW_UpdateScreen ();
  273.     VW_FadeIn ();
  274.  
  275.     IN_Ack();
  276.  
  277.     #ifndef SPEAR
  278.     if (Keyboard[sc_P] && MS_CheckParm("goobers"))
  279.         PicturePause();
  280.     #endif
  281.  
  282.     VW_FadeOut ();
  283.  
  284. #ifndef SPEAR
  285.     UNCACHEGRCHUNK(C_TIMECODEPIC);
  286. #endif
  287.     UnCacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);
  288.  
  289. #ifndef SPEAR
  290.     EndText();
  291. #else
  292.     EndSpear();
  293. #endif
  294.  
  295. #endif // SPEARDEMO
  296. }
  297.  
  298.  
  299. //==========================================================================
  300.  
  301. #ifndef JAPAN
  302. /*
  303. ==================
  304. =
  305. = PG13
  306. =
  307. ==================
  308. */
  309.  
  310. void PG13 (void)
  311. {
  312.     VW_FadeOut();
  313.     VWB_Bar(0,0,320,200,0x82);            // background
  314.  
  315.     CA_CacheGrChunk (PG13PIC);
  316.     VWB_DrawPic (216,110,PG13PIC);
  317.     VW_UpdateScreen ();
  318.  
  319.     UNCACHEGRCHUNK (PG13PIC);
  320.  
  321.     VW_FadeIn();
  322.     IN_UserInput(TickBase*7);
  323.  
  324.     VW_FadeOut ();
  325. }
  326. #endif
  327.  
  328.  
  329. //==========================================================================
  330.  
  331. void Write(int x,int y,char *string)
  332. {
  333.  int alpha[]={L_NUM0PIC,L_NUM1PIC,L_NUM2PIC,L_NUM3PIC,L_NUM4PIC,L_NUM5PIC,
  334.     L_NUM6PIC,L_NUM7PIC,L_NUM8PIC,L_NUM9PIC,L_COLONPIC,0,0,0,0,0,0,L_APIC,L_BPIC,
  335.     L_CPIC,L_DPIC,L_EPIC,L_FPIC,L_GPIC,L_HPIC,L_IPIC,L_JPIC,L_KPIC,
  336.     L_LPIC,L_MPIC,L_NPIC,L_OPIC,L_PPIC,L_QPIC,L_RPIC,L_SPIC,L_TPIC,
  337.     L_UPIC,L_VPIC,L_WPIC,L_XPIC,L_YPIC,L_ZPIC};
  338.  
  339.  int i,ox,nx,ny;
  340.  char ch;
  341.  
  342.  
  343.  ox=nx=x*8;
  344.  ny=y*8;
  345.  for (i=0;i<strlen(string);i++)
  346.    if (string[i]=='\n')
  347.    {
  348.     nx=ox;
  349.     ny+=16;
  350.    }
  351.    else
  352.    {
  353.     ch=string[i];
  354.     if (ch>='a')
  355.       ch-=('a'-'A');
  356.     ch-='0';
  357.  
  358.     switch(string[i])
  359.     {
  360.      case '!':
  361.        VWB_DrawPic(nx,ny,L_EXPOINTPIC);
  362.        nx+=8;
  363.        continue;
  364.  
  365.      case '\'':
  366.        VWB_DrawPic(nx,ny,L_APOSTROPHEPIC);
  367.        nx+=8;
  368.        continue;
  369.  
  370.      case ' ': break;
  371.      case 0x3a:    // ':'
  372.  
  373.        VWB_DrawPic(nx,ny,L_COLONPIC);
  374.        nx+=8;
  375.        continue;
  376.  
  377.      case '%':
  378.        VWB_DrawPic(nx,ny,L_PERCENTPIC);
  379.        break;
  380.  
  381.      default:
  382.        VWB_DrawPic(nx,ny,alpha[ch]);
  383.     }
  384.     nx+=16;
  385.    }
  386. }
  387.  
  388.  
  389. //
  390. // Breathe Mr. BJ!!!
  391. //
  392. void BJ_Breathe(void)
  393. {
  394.     static int which=0,max=10;
  395.     int pics[2]={L_GUYPIC,L_GUY2PIC};
  396.  
  397.  
  398.     if (TimeCount>max)
  399.     {
  400.         which^=1;
  401.         VWB_DrawPic(0,16,pics[which]);
  402.         VW_UpdateScreen();
  403.         TimeCount=0;
  404.         max=35;
  405.     }
  406. }
  407.  
  408.  
  409.  
  410. /*
  411. ==================
  412. =
  413. = LevelCompleted
  414. =
  415. = Entered with the screen faded out
  416. = Still in split screen mode with the status bar
  417. =
  418. = Exit with the screen faded out
  419. =
  420. ==================
  421. */
  422.  
  423. #ifndef SPEAR
  424. LRstruct LevelRatios[8];
  425. #else
  426. LRstruct LevelRatios[20];
  427. #endif
  428.  
  429. void LevelCompleted (void)
  430. {
  431.     #define VBLWAIT    30
  432.     #define PAR_AMOUNT    500
  433.     #define PERCENT100AMT    10000
  434.     typedef struct {
  435.             float time;
  436.             char timestr[6];
  437.             } times;
  438.  
  439.     int    x,i,min,sec,ratio,kr,sr,tr;
  440.     unsigned    temp;
  441.     char tempstr[10];
  442.     long bonus,timeleft=0;
  443.     times parTimes[]=
  444.     {
  445. #ifndef SPEAR
  446.      //
  447.      // Episode One Par Times
  448.      //
  449.      {1.5,    "01:30"},
  450.      {2,    "02:00"},
  451.      {2,    "02:00"},
  452.      {3.5,    "03:30"},
  453.      {3,    "03:00"},
  454.      {3,    "03:00"},
  455.      {2.5,    "02:30"},
  456.      {2.5,    "02:30"},
  457.      {0,    "??:??"},    // Boss level
  458.      {0,    "??:??"},    // Secret level
  459.  
  460.      //
  461.      // Episode Two Par Times
  462.      //
  463.      {1.5,    "01:30"},
  464.      {3.5,    "03:30"},
  465.      {3,    "03:00"},
  466.      {2,    "02:00"},
  467.      {4,    "04:00"},
  468.      {6,    "06:00"},
  469.      {1,    "01:00"},
  470.      {3,    "03:00"},
  471.      {0,    "??:??"},
  472.      {0,    "??:??"},
  473.  
  474.      //
  475.      // Episode Three Par Times
  476.      //
  477.      {1.5,    "01:30"},
  478.      {1.5,    "01:30"},
  479.      {2.5,    "02:30"},
  480.      {2.5,    "02:30"},
  481.      {3.5,    "03:30"},
  482.      {2.5,    "02:30"},
  483.      {2,    "02:00"},
  484.      {6,    "06:00"},
  485.      {0,    "??:??"},
  486.      {0,    "??:??"},
  487.  
  488.      //
  489.      // Episode Four Par Times
  490.      //
  491.      {2,    "02:00"},
  492.      {2,    "02:00"},
  493.      {1.5,    "01:30"},
  494.      {1,    "01:00"},
  495.      {4.5,    "04:30"},
  496.      {3.5,    "03:30"},
  497.      {2,    "02:00"},
  498.      {4.5,    "04:30"},
  499.      {0,    "??:??"},
  500.      {0,    "??:??"},
  501.  
  502.      //
  503.      // Episode Five Par Times
  504.      //
  505.      {2.5,    "02:30"},
  506.      {1.5,    "01:30"},
  507.      {2.5,    "02:30"},
  508.      {2.5,    "02:30"},
  509.      {4,    "04:00"},
  510.      {3,    "03:00"},
  511.      {4.5,    "04:30"},
  512.      {3.5,    "03:30"},
  513.      {0,    "??:??"},
  514.      {0,    "??:??"},
  515.  
  516.      //
  517.      // Episode Six Par Times
  518.      //
  519.      {6.5,    "06:30"},
  520.      {4,    "04:00"},
  521.      {4.5,    "04:30"},
  522.      {6,    "06:00"},
  523.      {5,    "05:00"},
  524.      {5.5,    "05:30"},
  525.      {5.5,    "05:30"},
  526.      {8.5,    "08:30"},
  527.      {0,    "??:??"},
  528.      {0,    "??:??"}
  529. #else
  530.      //
  531.      // SPEAR OF DESTINY TIMES
  532.      //
  533.      {1.5,    "01:30"},
  534.      {3.5,    "03:30"},
  535.      {2.75,    "02:45"},
  536.      {3.5,    "03:30"},
  537.      {0,    "??:??"},    // Boss 1
  538.      {4.5,    "04:30"},
  539.      {3.25,    "03:15"},
  540.      {2.75,    "02:45"},
  541.      {4.75,    "04:45"},
  542.      {0,    "??:??"},    // Boss 2
  543.      {6.5,    "06:30"},
  544.      {4.5,    "04:30"},
  545.      {2.75,    "02:45"},
  546.      {4.5,    "04:30"},
  547.      {6,    "06:00"},
  548.      {0,    "??:??"},    // Boss 3
  549.      {6,    "06:00"},
  550.      {0,    "??:??"},    // Boss 4
  551.      {0,    "??:??"},    // Secret level 1
  552.      {0,    "??:??"},    // Secret level 2
  553. #endif
  554.     };
  555.  
  556.  
  557.  
  558.     CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);
  559.     ClearSplitVWB ();            // set up for double buffering in split screen
  560.     VWB_Bar (0,0,320,200-STATUSLINES,127);
  561.     StartCPMusic(ENDLEVEL_MUS);
  562.  
  563. //
  564. // do the intermission
  565. //
  566.     IN_ClearKeysDown();
  567.     IN_StartAck();
  568.  
  569. #ifdef JAPAN
  570.     CA_CacheGrChunk(C_INTERMISSIONPIC);
  571.     VWB_DrawPic(0,0,C_INTERMISSIONPIC);
  572.     UNCACHEGRCHUNK(C_INTERMISSIONPIC);
  573. #endif
  574.     VWB_DrawPic(0,16,L_GUYPIC);
  575.  
  576. #ifndef SPEAR
  577.     if (mapon<8)
  578. #else
  579.     if (mapon != 4 &&
  580.         mapon != 9 &&
  581.         mapon != 15 &&
  582.         mapon < 17)
  583. #endif
  584.     {
  585. #ifndef JAPAN
  586.      #ifdef SPANISH
  587.      Write(14,2,"piso\ncompletado");
  588.      #else
  589.      Write(14,2,"floor\ncompleted");
  590.      #endif
  591.  
  592.      Write(14,7,STR_BONUS"     0");
  593.      Write(16,10,STR_TIME);
  594.      Write(16,12,STR_PAR);
  595.  
  596.      #ifdef SPANISH
  597.      Write(11,14,    STR_RAT2KILL);
  598.      Write(11,16,  STR_RAT2SECRET);
  599.      Write(11,18,STR_RAT2TREASURE);
  600.      #else
  601.      Write(9,14,    STR_RAT2KILL);
  602.      Write(5,16,  STR_RAT2SECRET);
  603.      Write(1,18,STR_RAT2TREASURE);
  604.      #endif
  605.  
  606.      Write(26,2,itoa(gamestate.mapon+1,tempstr,10));
  607. #endif
  608.  
  609.      #ifdef SPANISH
  610.      Write(30,12,parTimes[gamestate.episode*10+mapon].timestr);
  611.      #else
  612.      Write(26,12,parTimes[gamestate.episode*10+mapon].timestr);
  613.      #endif
  614.  
  615.      //
  616.      // PRINT TIME
  617.      //
  618.      sec=gamestate.TimeCount/70;
  619.  
  620.      if (sec > 99*60)        // 99 minutes max
  621.        sec = 99*60;
  622.  
  623.      if (gamestate.TimeCount<parTimes[gamestate.episode*10+mapon].time*4200)
  624.         timeleft=(parTimes[gamestate.episode*10+mapon].time*4200)/70-sec;
  625.  
  626.      min=sec/60;
  627.      sec%=60;
  628.  
  629.      #ifdef SPANISH
  630.      i=30*8;
  631.      #else
  632.      i=26*8;
  633.      #endif
  634.      VWB_DrawPic(i,10*8,L_NUM0PIC+(min/10));
  635.      i+=2*8;
  636.      VWB_DrawPic(i,10*8,L_NUM0PIC+(min%10));
  637.      i+=2*8;
  638.      Write(i/8,10,":");
  639.      i+=1*8;
  640.      VWB_DrawPic(i,10*8,L_NUM0PIC+(sec/10));
  641.      i+=2*8;
  642.      VWB_DrawPic(i,10*8,L_NUM0PIC+(sec%10));
  643.  
  644.      VW_UpdateScreen ();
  645.      VW_FadeIn ();
  646.  
  647.  
  648.      //
  649.      // FIGURE RATIOS OUT BEFOREHAND
  650.      //
  651.      kr = sr = tr = 0;
  652.      if (gamestate.killtotal)
  653.         kr=(gamestate.killcount*100)/gamestate.killtotal;
  654.      if (gamestate.secrettotal)
  655.         sr=(gamestate.secretcount*100)/gamestate.secrettotal;
  656.      if (gamestate.treasuretotal)
  657.         tr=(gamestate.treasurecount*100)/gamestate.treasuretotal;
  658.  
  659.  
  660.      //
  661.      // PRINT TIME BONUS
  662.      //
  663.      bonus=timeleft*PAR_AMOUNT;
  664.      if (bonus)
  665.      {
  666.       for (i=0;i<=timeleft;i++)
  667.       {
  668.        ltoa((long)i*PAR_AMOUNT,tempstr,10);
  669.        x=36-strlen(tempstr)*2;
  670.        Write(x,7,tempstr);
  671.        if (!(i%(PAR_AMOUNT/10)))
  672.          SD_PlaySound(ENDBONUS1SND);
  673.        VW_UpdateScreen();
  674.        while(SD_SoundPlaying())
  675.          BJ_Breathe();
  676.        if (IN_CheckAck())
  677.          goto done;
  678.       }
  679.  
  680.       VW_UpdateScreen();
  681.       SD_PlaySound(ENDBONUS2SND);
  682.       while(SD_SoundPlaying())
  683.         BJ_Breathe();
  684.      }
  685.  
  686.  
  687.      #ifdef SPANISH
  688.      #define RATIOXX        33
  689.      #else
  690.      #define RATIOXX        37
  691.      #endif
  692.      //
  693.      // KILL RATIO
  694.      //
  695.      ratio=kr;
  696.      for (i=0;i<=ratio;i++)
  697.      {
  698.       itoa(i,tempstr,10);
  699.       x=RATIOXX-strlen(tempstr)*2;
  700.       Write(x,14,tempstr);
  701.       if (!(i%10))
  702.         SD_PlaySound(ENDBONUS1SND);
  703.       VW_UpdateScreen ();
  704.       while(SD_SoundPlaying())
  705.         BJ_Breathe();
  706.  
  707.       if (IN_CheckAck())
  708.         goto done;
  709.      }
  710.      if (ratio==100)
  711.      {
  712.        VW_WaitVBL(VBLWAIT);
  713.        SD_StopSound();
  714.        bonus+=PERCENT100AMT;
  715.        ltoa(bonus,tempstr,10);
  716.        x=(RATIOXX-1)-strlen(tempstr)*2;
  717.        Write(x,7,tempstr);
  718.        VW_UpdateScreen();
  719.        SD_PlaySound(PERCENT100SND);
  720.      }
  721.      else
  722.      if (!ratio)
  723.      {
  724.        VW_WaitVBL(VBLWAIT);
  725.        SD_StopSound();
  726.        SD_PlaySound(NOBONUSSND);
  727.      }
  728.      else
  729.      SD_PlaySound(ENDBONUS2SND);
  730.  
  731.      VW_UpdateScreen();
  732.      while(SD_SoundPlaying())
  733.        BJ_Breathe();
  734.  
  735.  
  736.      //
  737.      // SECRET RATIO
  738.      //
  739.      ratio=sr;
  740.      for (i=0;i<=ratio;i++)
  741.      {
  742.       itoa(i,tempstr,10);
  743.       x=RATIOXX-strlen(tempstr)*2;
  744.       Write(x,16,tempstr);
  745.       if (!(i%10))
  746.         SD_PlaySound(ENDBONUS1SND);
  747.       VW_UpdateScreen ();
  748.       while(SD_SoundPlaying())
  749.         BJ_Breathe();
  750.       BJ_Breathe();
  751.  
  752.       if (IN_CheckAck())
  753.         goto done;
  754.      }
  755.      if (ratio==100)
  756.      {
  757.        VW_WaitVBL(VBLWAIT);
  758.        SD_StopSound();
  759.        bonus+=PERCENT100AMT;
  760.        ltoa(bonus,tempstr,10);
  761.        x=(RATIOXX-1)-strlen(tempstr)*2;
  762.        Write(x,7,tempstr);
  763.        VW_UpdateScreen();
  764.        SD_PlaySound(PERCENT100SND);
  765.      }
  766.      else
  767.      if (!ratio)
  768.      {
  769.        VW_WaitVBL(VBLWAIT);
  770.        SD_StopSound();
  771.        SD_PlaySound(NOBONUSSND);
  772.      }
  773.      else
  774.        SD_PlaySound(ENDBONUS2SND);
  775.      VW_UpdateScreen();
  776.      while(SD_SoundPlaying())
  777.        BJ_Breathe();
  778.  
  779.  
  780.      //
  781.      // TREASURE RATIO
  782.      //
  783.      ratio=tr;
  784.      for (i=0;i<=ratio;i++)
  785.      {
  786.       itoa(i,tempstr,10);
  787.       x=RATIOXX-strlen(tempstr)*2;
  788.       Write(x,18,tempstr);
  789.       if (!(i%10))
  790.         SD_PlaySound(ENDBONUS1SND);
  791.       VW_UpdateScreen ();
  792.       while(SD_SoundPlaying())
  793.         BJ_Breathe();
  794.       if (IN_CheckAck())
  795.         goto done;
  796.      }
  797.      if (ratio==100)
  798.      {
  799.        VW_WaitVBL(VBLWAIT);
  800.        SD_StopSound();
  801.        bonus+=PERCENT100AMT;
  802.        ltoa(bonus,tempstr,10);
  803.        x=(RATIOXX-1)-strlen(tempstr)*2;
  804.        Write(x,7,tempstr);
  805.        VW_UpdateScreen();
  806.        SD_PlaySound(PERCENT100SND);
  807.      }
  808.      else
  809.      if (!ratio)
  810.      {
  811.        VW_WaitVBL(VBLWAIT);
  812.        SD_StopSound();
  813.        SD_PlaySound(NOBONUSSND);
  814.      }
  815.      else
  816.      SD_PlaySound(ENDBONUS2SND);
  817.      VW_UpdateScreen();
  818.      while(SD_SoundPlaying())
  819.        BJ_Breathe();
  820.  
  821.  
  822.      //
  823.      // JUMP STRAIGHT HERE IF KEY PRESSED
  824.      //
  825.      done:
  826.  
  827.      itoa(kr,tempstr,10);
  828.      x=RATIOXX-strlen(tempstr)*2;
  829.      Write(x,14,tempstr);
  830.  
  831.      itoa(sr,tempstr,10);
  832.      x=RATIOXX-strlen(tempstr)*2;
  833.      Write(x,16,tempstr);
  834.  
  835.      itoa(tr,tempstr,10);
  836.      x=RATIOXX-strlen(tempstr)*2;
  837.      Write(x,18,tempstr);
  838.  
  839.      bonus=(long)timeleft*PAR_AMOUNT+
  840.            (PERCENT100AMT*(kr==100))+
  841.            (PERCENT100AMT*(sr==100))+
  842.            (PERCENT100AMT*(tr==100));
  843.  
  844.      GivePoints(bonus);
  845.      ltoa(bonus,tempstr,10);
  846.      x=36-strlen(tempstr)*2;
  847.      Write(x,7,tempstr);
  848.  
  849.      //
  850.      // SAVE RATIO INFORMATION FOR ENDGAME
  851.      //
  852.      LevelRatios[mapon].kill=kr;
  853.      LevelRatios[mapon].secret=sr;
  854.      LevelRatios[mapon].treasure=tr;
  855.      LevelRatios[mapon].time=min*60+sec;
  856.     }
  857.     else
  858.     {
  859. #ifdef SPEAR
  860. #ifndef SPEARDEMO
  861.       switch(mapon)
  862.       {
  863.        case 4: Write(14,4," trans\n"
  864.                           " grosse\n"
  865.                           STR_DEFEATED); break;
  866.        case 9: Write(14,4,"barnacle\n"
  867.                           "wilhelm\n"
  868.                           STR_DEFEATED); break;
  869.        case 15: Write(14,4,"ubermutant\n"
  870.                            STR_DEFEATED); break;
  871.        case 17: Write(14,4," death\n"
  872.                            " knight\n"
  873.                            STR_DEFEATED); break;
  874.        case 18: Write(13,4,"secret tunnel\n"
  875.                            "    area\n"
  876.                            "  completed!"); break;
  877.        case 19: Write(13,4,"secret castle\n"
  878.                            "    area\n"
  879.                            "  completed!"); break;
  880.       }
  881. #endif
  882. #else
  883.       Write(14,4,"secret floor\n completed!");
  884. #endif
  885.  
  886.       Write(10,16,"15000 bonus!");
  887.  
  888.       VW_UpdateScreen();
  889.       VW_FadeIn();
  890.  
  891.       GivePoints(15000);
  892.     }
  893.  
  894.  
  895.     DrawScore();
  896.     VW_UpdateScreen();
  897.  
  898.     TimeCount=0;
  899.     IN_StartAck();
  900.     while(!IN_CheckAck())
  901.       BJ_Breathe();
  902.  
  903. //
  904. // done
  905. //
  906. #ifdef SPEARDEMO
  907.     if (gamestate.mapon == 1)
  908.     {
  909.         SD_PlaySound (BONUS1UPSND);
  910.  
  911.         CA_CacheGrChunk (STARTFONT+1);
  912.         Message ("This concludes your demo\n"
  913.                  "of Spear of Destiny! Now,\n"
  914.                  "go to your local software\n"
  915.                  "store and buy it!");
  916.         UNCACHEGRCHUNK (STARTFONT+1);
  917.  
  918.         IN_ClearKeysDown();
  919.         IN_Ack();
  920.     }
  921. #endif
  922.  
  923. #ifdef JAPDEMO
  924.     if (gamestate.mapon == 3)
  925.     {
  926.         SD_PlaySound (BONUS1UPSND);
  927.  
  928.         CA_CacheGrChunk (STARTFONT+1);
  929.         Message ("This concludes your demo\n"
  930.                  "of Wolfenstein 3-D! Now,\n"
  931.                  "go to your local software\n"
  932.                  "store and buy it!");
  933.         UNCACHEGRCHUNK (STARTFONT+1);
  934.  
  935.         IN_ClearKeysDown();
  936.         IN_Ack();
  937.     }
  938. #endif
  939.  
  940.     #ifndef SPEAR
  941.     if (Keyboard[sc_P] && MS_CheckParm("goobers"))
  942.         PicturePause();
  943.     #endif
  944.  
  945.     VW_FadeOut ();
  946.     temp = bufferofs;
  947.     for (i=0;i<3;i++)
  948.     {
  949.         bufferofs = screenloc[i];
  950.         DrawPlayBorder ();
  951.     }
  952.     bufferofs = temp;
  953.  
  954.     UnCacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);
  955. }
  956.  
  957.  
  958.  
  959. //==========================================================================
  960.  
  961.  
  962. /*
  963. =================
  964. =
  965. = PreloadGraphics
  966. =
  967. = Fill the cache up
  968. =
  969. =================
  970. */
  971.  
  972. boolean PreloadUpdate(unsigned current, unsigned total)
  973. {
  974.     unsigned w = WindowW - 10;
  975.  
  976.  
  977.     VWB_Bar(WindowX + 5,WindowY + WindowH - 3,w,2,BLACK);
  978.     w = ((long)w * current) / total;
  979.     if (w)
  980.     {
  981.      VWB_Bar(WindowX + 5,WindowY + WindowH - 3,w,2,0x37); //SECONDCOLOR);
  982.      VWB_Bar(WindowX + 5,WindowY + WindowH - 3,w-1,1,0x32);
  983.  
  984.     }
  985.     VW_UpdateScreen();
  986. //    if (LastScan == sc_Escape)
  987. //    {
  988. //        IN_ClearKeysDown();
  989. //        return(true);
  990. //    }
  991. //    else
  992.         return(false);
  993. }
  994.  
  995. void PreloadGraphics(void)
  996. {
  997.     DrawLevel ();
  998.     ClearSplitVWB ();            // set up for double buffering in split screen
  999.  
  1000.     VWB_Bar (0,0,320,200-STATUSLINES,127);
  1001.  
  1002.     LatchDrawPic (20-14,80-3*8,GETPSYCHEDPIC);
  1003.  
  1004.     WindowX = 160-14*8;
  1005.     WindowY = 80-3*8;
  1006.     WindowW = 28*8;
  1007.     WindowH = 48;
  1008.     VW_UpdateScreen();
  1009.     VW_FadeIn ();
  1010.  
  1011.     PM_Preload (PreloadUpdate);
  1012.     IN_UserInput (70);
  1013.     VW_FadeOut ();
  1014.  
  1015.     DrawPlayBorder ();
  1016.     VW_UpdateScreen ();
  1017. }
  1018.  
  1019.  
  1020. //==========================================================================
  1021.  
  1022. /*
  1023. ==================
  1024. =
  1025. = DrawHighScores
  1026. =
  1027. ==================
  1028. */
  1029.  
  1030. void    DrawHighScores(void)
  1031. {
  1032.     char        buffer[16],*str,buffer1[5];
  1033.     byte        temp,temp1,temp2,temp3;
  1034.     word        i,j,
  1035.                 w,h,
  1036.                 x,y;
  1037.     HighScore    *s;
  1038.  
  1039.  
  1040.     MM_SortMem ();
  1041.  
  1042. #ifndef SPEAR
  1043. //    CA_CacheGrChunk (C_CODEPIC);
  1044.     CA_CacheGrChunk (HIGHSCORESPIC);
  1045.     CA_CacheGrChunk (STARTFONT);
  1046.     CA_CacheGrChunk (C_LEVELPIC);
  1047.     CA_CacheGrChunk (C_SCOREPIC);
  1048.     CA_CacheGrChunk (C_NAMEPIC);
  1049.  
  1050.     ClearMScreen();
  1051.     DrawStripes(10);
  1052.  
  1053.     VWB_DrawPic(48,0,HIGHSCORESPIC);
  1054.     UNCACHEGRCHUNK (HIGHSCORESPIC);
  1055.  
  1056.     VWB_DrawPic(4*8,68,C_NAMEPIC);
  1057.     VWB_DrawPic(20*8,68,C_LEVELPIC);
  1058.     VWB_DrawPic(28*8,68,C_SCOREPIC);
  1059. #ifndef UPLOAD
  1060. //    VWB_DrawPic(35*8,68,C_CODEPIC);
  1061. #endif
  1062.     fontnumber=0;
  1063.  
  1064. #else
  1065.     CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
  1066.     ClearMScreen();
  1067.     DrawStripes(10);
  1068.     UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
  1069.  
  1070.     CacheLump (HIGHSCORES_LUMP_START,HIGHSCORES_LUMP_END);
  1071.     CA_CacheGrChunk (STARTFONT+1);
  1072.     VWB_DrawPic (0,0,HIGHSCORESPIC);
  1073.  
  1074.     fontnumber = 1;
  1075. #endif
  1076.  
  1077.  
  1078. #ifndef SPEAR
  1079.     SETFONTCOLOR(15,0x29);
  1080. #else
  1081.     SETFONTCOLOR(HIGHLIGHT,0x29);
  1082. #endif
  1083.  
  1084.     for (i = 0,s = Scores;i < MaxScores;i++,s++)
  1085.     {
  1086.         PrintY = 76 + (16 * i);
  1087.  
  1088.         //
  1089.         // name
  1090.         //
  1091. #ifndef SPEAR
  1092.         PrintX = 4*8;
  1093. #else
  1094.         PrintX = 16;
  1095. #endif
  1096.         US_Print(s->name);
  1097.  
  1098.         //
  1099.         // level
  1100.         //
  1101.         ultoa(s->completed,buffer,10);
  1102. #ifndef SPEAR
  1103.         for (str = buffer;*str;str++)
  1104.             *str = *str + (129 - '0');    // Used fixed-width numbers (129...)
  1105.         USL_MeasureString(buffer,&w,&h);
  1106.         PrintX = (22 * 8)-w;
  1107. #else
  1108.         USL_MeasureString(buffer,&w,&h);
  1109.         PrintX = 194 - w;
  1110. #endif
  1111.  
  1112. #ifndef UPLOAD
  1113. #ifndef SPEAR
  1114.         PrintX -= 6;
  1115.         itoa(s->episode+1,buffer1,10);
  1116.         US_Print("E");
  1117.         US_Print(buffer1);
  1118.         US_Print("/L");
  1119. #endif
  1120. #endif
  1121.  
  1122. #ifdef SPEAR
  1123.         if (s->completed == 21)
  1124.             VWB_DrawPic (PrintX+8,PrintY-1,C_WONSPEARPIC);
  1125.         else
  1126. #endif
  1127.         US_Print(buffer);
  1128.  
  1129.         //
  1130.         // score
  1131.         //
  1132.         ultoa(s->score,buffer,10);
  1133. #ifndef SPEAR
  1134.         for (str = buffer;*str;str++)
  1135.             *str = *str + (129 - '0');    // Used fixed-width numbers (129...)
  1136.         USL_MeasureString(buffer,&w,&h);
  1137.         PrintX = (34 * 8) - 8 - w;
  1138. #else
  1139.         USL_MeasureString(buffer,&w,&h);
  1140.         PrintX = 292 - w;
  1141. #endif
  1142.         US_Print(buffer);
  1143.  
  1144.         #if 0
  1145. #ifndef UPLOAD
  1146. #ifndef SPEAR
  1147.         //
  1148.         // verification #
  1149.         //
  1150.         if (!i)
  1151.         {
  1152.          temp=(((s->score >> 28)& 0xf)^
  1153.               ((s->score >> 24)& 0xf))+'A';
  1154.          temp1=(((s->score >> 20)& 0xf)^
  1155.                ((s->score >> 16)& 0xf))+'A';
  1156.          temp2=(((s->score >> 12)& 0xf)^
  1157.                ((s->score >> 8)& 0xf))+'A';
  1158.          temp3=(((s->score >> 4)& 0xf)^
  1159.                ((s->score >> 0)& 0xf))+'A';
  1160.  
  1161.          SETFONTCOLOR(0x49,0x29);
  1162.          PrintX = 35*8;
  1163.          buffer[0]=temp;
  1164.          buffer[1]=temp1;
  1165.          buffer[2]=temp2;
  1166.          buffer[3]=temp3;
  1167.          buffer[4]=0;
  1168.          US_Print(buffer);
  1169.          SETFONTCOLOR(15,0x29);
  1170.         }
  1171. #endif
  1172. #endif
  1173.         #endif
  1174.     }
  1175.  
  1176.     VW_UpdateScreen ();
  1177.  
  1178. #ifdef SPEAR
  1179.     UnCacheLump (HIGHSCORES_LUMP_START,HIGHSCORES_LUMP_END);
  1180.     fontnumber = 0;
  1181. #endif
  1182. }
  1183.  
  1184. //===========================================================================
  1185.  
  1186.  
  1187. /*
  1188. =======================
  1189. =
  1190. = CheckHighScore
  1191. =
  1192. =======================
  1193. */
  1194.  
  1195. void    CheckHighScore (long score,word other)
  1196. {
  1197.     word        i,j;
  1198.     int            n;
  1199.     HighScore    myscore;
  1200.  
  1201.     strcpy(myscore.name,"");
  1202.     myscore.score = score;
  1203.     myscore.episode = gamestate.episode;
  1204.     myscore.completed = other;
  1205.  
  1206.     for (i = 0,n = -1;i < MaxScores;i++)
  1207.     {
  1208.         if
  1209.         (
  1210.             (myscore.score > Scores[i].score)
  1211.         ||    (
  1212.                 (myscore.score == Scores[i].score)
  1213.             &&     (myscore.completed > Scores[i].completed)
  1214.             )
  1215.         )
  1216.         {
  1217.             for (j = MaxScores;--j > i;)
  1218.                 Scores[j] = Scores[j - 1];
  1219.             Scores[i] = myscore;
  1220.             n = i;
  1221.             break;
  1222.         }
  1223.     }
  1224.  
  1225. #ifdef SPEAR
  1226.     StartCPMusic (XAWARD_MUS);
  1227. #else
  1228.     StartCPMusic (ROSTER_MUS);
  1229. #endif
  1230.     DrawHighScores ();
  1231.  
  1232.     VW_FadeIn ();
  1233.  
  1234.     if (n != -1)
  1235.     {
  1236.     //
  1237.     // got a high score
  1238.     //
  1239.         PrintY = 76 + (16 * n);
  1240. #ifndef SPEAR
  1241.         PrintX = 4*8;
  1242.         backcolor = BORDCOLOR;
  1243.         fontcolor = 15;
  1244.         US_LineInput(PrintX,PrintY,Scores[n].name,nil,true,MaxHighName,100);
  1245. #else
  1246.         PrintX = 16;
  1247.         fontnumber = 1;
  1248.         VWB_Bar (PrintX-2,PrintY-2,145,15,0x9c);
  1249.         VW_UpdateScreen ();
  1250.         backcolor = 0x9c;
  1251.         fontcolor = 15;
  1252.         US_LineInput(PrintX,PrintY,Scores[n].name,nil,true,MaxHighName,130);
  1253. #endif
  1254.     }
  1255.     else
  1256.     {
  1257.         IN_ClearKeysDown ();
  1258.         IN_UserInput(500);
  1259.     }
  1260.  
  1261. }
  1262.  
  1263.  
  1264. #ifndef UPLOAD
  1265. #ifndef SPEAR
  1266. #ifndef JAPAN
  1267. ////////////////////////////////////////////////////////
  1268. //
  1269. // NON-SHAREWARE NOTICE
  1270. //
  1271. ////////////////////////////////////////////////////////
  1272. void NonShareware(void)
  1273. {
  1274.     VW_FadeOut();
  1275.  
  1276.     ClearMScreen();
  1277.     DrawStripes(10);
  1278.  
  1279.     CA_CacheGrChunk(STARTFONT+1);
  1280.     fontnumber = 1;
  1281.  
  1282.     SETFONTCOLOR(READHCOLOR,BKGDCOLOR);
  1283.     PrintX=110;
  1284.     PrintY=15;
  1285.  
  1286.     #ifdef SPANISH
  1287.     US_Print("Atencion");
  1288.     #else
  1289.     US_Print("Attention");
  1290.     #endif
  1291.  
  1292.     SETFONTCOLOR(HIGHLIGHT,BKGDCOLOR);
  1293.     WindowX=PrintX=40;
  1294.     PrintY=60;
  1295.     #ifdef SPANISH
  1296.     US_Print("Este juego NO es gratis y\n");
  1297.     US_Print("NO es Shareware; favor de\n");
  1298.     US_Print("no distribuirlo.\n\n");
  1299.     #else
  1300.     US_Print("This game is NOT shareware.\n");
  1301.     US_Print("Please do not distribute it.\n");
  1302.     US_Print("Thanks.\n\n");
  1303.     #endif
  1304.     US_Print("        Id Software\n");
  1305.  
  1306.     VW_UpdateScreen ();
  1307.     VW_FadeIn();
  1308.     IN_Ack();
  1309. }
  1310. #endif
  1311. #endif
  1312. #endif
  1313.  
  1314. #ifdef SPEAR
  1315. #ifndef SPEARDEMO
  1316. ////////////////////////////////////////////////////////
  1317. //
  1318. // COPY PROTECTION FOR FormGen
  1319. //
  1320. ////////////////////////////////////////////////////////
  1321. char     far CopyProFailedStrs[][100] = {
  1322.             STR_COPY1,
  1323.             STR_COPY2,
  1324.  
  1325.             STR_COPY3,
  1326.             STR_COPY4,
  1327.  
  1328.             STR_COPY5,
  1329.             STR_COPY6,
  1330.  
  1331.             STR_COPY7,
  1332.             STR_COPY8,
  1333.  
  1334.             STR_COPY9,
  1335.             "",
  1336.  
  1337.             STR_COPY10,
  1338.             STR_COPY11,
  1339.  
  1340.             STR_COPY12,
  1341.             "",
  1342.  
  1343.             STR_COPY13,
  1344.             "",
  1345.  
  1346.             STR_COPY14,
  1347.             ""
  1348.             },
  1349.  
  1350.         far BackDoorStrs[5][16] = {
  1351.             "a spoon?",
  1352.             "bite me!",
  1353.             "joshua",
  1354.             "pelt",
  1355. #ifdef BETA
  1356.             "beta"
  1357. #else
  1358.             "snoops"
  1359. #endif
  1360.             },
  1361.  
  1362.         far GoodBoyStrs[10][40] = {
  1363.             "...is the CORRECT ANSWER!",
  1364.             "",
  1365.  
  1366.             "Consider yourself bitten, sir.",
  1367.             "",
  1368.  
  1369.             "Greetings Professor Falken, would you",
  1370.             "like to play Spear of Destiny?",
  1371.  
  1372.             "Do you have any gold spray paint?",
  1373.             "",
  1374.  
  1375. #ifdef BETA
  1376.             "Beta testing approved.",
  1377. #else
  1378.             "I wish I had a 21\" monitor...",
  1379. #endif
  1380.             ""
  1381.             },
  1382.  
  1383.         far bossstrs[4][24] = {
  1384.             "DEATH KNIGHT",
  1385.             "BARNACLE WILHELM",
  1386.             "UBERMUTANTUBER MUTANT",
  1387.             "TRANS GROSSE"
  1388.             },
  1389.  
  1390.         far WordStr[5][20] = {
  1391.             "New Game",
  1392.             "Sound...F4",
  1393.             "Control...F6",
  1394.             "Change View...F5",
  1395.             "Quit...F10"},
  1396.  
  1397.         far    WordCorrect[5][2] = {"3","4","4","5","5"},
  1398.  
  1399.         far MemberStr[10][40] = {
  1400.             STR_COPY15,
  1401.             "",
  1402.  
  1403.             STR_COPY16,
  1404.             "",
  1405.  
  1406.             STR_COPY17,
  1407.             STR_COPY18,
  1408.  
  1409.             STR_COPY19,
  1410.             STR_COPY20,
  1411.  
  1412.             STR_COPY21,
  1413.             STR_COPY22},
  1414.  
  1415.         far MemberCorrect[5][24] = {
  1416.             "adrian carmack",
  1417.             "john carmackjohn romero",
  1418.             "tom hall",
  1419.             "jay wilbur",
  1420.             "kevin cloud"},
  1421.  
  1422.         far DosMessages[9][80] = {
  1423.             STR_NOPE1,
  1424.             STR_NOPE2,
  1425.             STR_NOPE3,
  1426.             STR_NOPE4,
  1427.             STR_NOPE5,
  1428.             STR_NOPE6,
  1429.             STR_NOPE7,
  1430.             STR_NOPE8,
  1431.             STR_NOPE9},
  1432.  
  1433.         far MiscTitle[4][20] = {
  1434.             "BLOOD TEST",
  1435.             "STRAIGHT-LACED",
  1436.             "QUITE SHAPELY",
  1437.             "I AM WHAT I AMMO"
  1438.             },
  1439.  
  1440.         far MiscStr[12][40] = {
  1441.             STR_MISC1,
  1442.             STR_MISC2,
  1443.             "",
  1444.  
  1445.             STR_MISC3,
  1446.             STR_MISC4,
  1447.             "",
  1448.  
  1449.             STR_MISC5,
  1450.             STR_MISC6,
  1451.             "",
  1452.  
  1453.             STR_MISC7,
  1454.             STR_MISC8,
  1455.             STR_MISC9
  1456.             },
  1457.  
  1458.         far MiscCorrect[4][5] = {"ss","8",STR_STAR,"45"};
  1459.  
  1460.  
  1461. int  BackDoor(char *s)
  1462. {
  1463.     int i;
  1464.  
  1465.  
  1466.     strlwr(s);
  1467.  
  1468.     for (i=0;i<5;i++)
  1469.         if (!_fstrcmp(s,BackDoorStrs[i]))
  1470.         {
  1471.             SETFONTCOLOR(14,15);
  1472.             fontnumber = 0;
  1473.             PrintY = 175;
  1474.             VWB_DrawPic (0,20*8,COPYPROTBOXPIC);
  1475.             US_CPrint(GoodBoyStrs[i*2]);
  1476.             US_CPrint(GoodBoyStrs[i*2+1]);
  1477.             VW_UpdateScreen();
  1478.             return 1;
  1479.         }
  1480.  
  1481.     return 0;
  1482. }
  1483.  
  1484.  
  1485. void CopyProtection(void)
  1486. {
  1487. #define TYPEBOX_Y        177
  1488. #define TYPEBOX_BKGD    0x9c
  1489. #define PRINTCOLOR        HIGHLIGHT
  1490.  
  1491.     int    i,match,whichboss,bossnum,try,whichline,enemypicked[4]={0,0,0,0},
  1492.         bosses[4] = { BOSSPIC1PIC,BOSSPIC2PIC,BOSSPIC3PIC,BOSSPIC4PIC },
  1493.         whichone,whichpicked[4]={0,0,0,0},quiztype,whichmem,
  1494.         memberpicked[5]={0,0,0,0,0},wordpicked[5]={0,0,0,0,0},whichword;
  1495.  
  1496.     char    inputbuffer[20],
  1497.             message[80];
  1498.  
  1499.     enum
  1500.     {
  1501.         debriefing,
  1502.         checkmanual,
  1503.         staffquiz,
  1504.         miscquiz,
  1505.  
  1506.         totaltypes
  1507.     };
  1508.  
  1509.  
  1510.  
  1511.     try = 0;
  1512.     VW_FadeOut();
  1513.     CA_CacheGrChunk(C_BACKDROPPIC);
  1514.     CacheLump(COPYPROT_LUMP_START,COPYPROT_LUMP_END);
  1515.     CA_CacheGrChunk(STARTFONT+1);
  1516.     CA_LoadAllSounds();
  1517.     StartCPMusic(COPYPRO_MUS);
  1518.     US_InitRndT(true);
  1519.  
  1520.     while (try<3)
  1521.     {
  1522.         fontnumber = 1;
  1523.         SETFONTCOLOR(PRINTCOLOR-2,15);
  1524.         VWB_DrawPic (0,0,C_BACKDROPPIC);
  1525.         VWB_DrawPic (0,0,COPYPROTTOPPIC);
  1526.         VWB_DrawPic (0,20*8,COPYPROTBOXPIC);
  1527.         WindowX = WindowY = 0;
  1528.         WindowW = 320;
  1529.         WindowH = 200;
  1530.         PrintY = 65;
  1531.  
  1532.         quiztype = US_RndT()%totaltypes;
  1533.         switch(quiztype)
  1534.         {
  1535.             //
  1536.             // BOSSES QUIZ
  1537.             //
  1538.             case debriefing:
  1539.                 PrintX = 0;
  1540.                 US_Print(STR_DEBRIEF);
  1541.                 SETFONTCOLOR(PRINTCOLOR,15);
  1542.  
  1543.                 while (enemypicked[whichboss = US_RndT()&3]);
  1544.                 enemypicked[whichboss] = 1;
  1545.                 bossnum = bosses[whichboss];
  1546.                 VWB_DrawPic(128,60,bossnum);
  1547.                 fontnumber = 0;
  1548.                 PrintY = 130;
  1549.                 US_CPrint(STR_ENEMY1"\n");
  1550.                 US_CPrint(STR_ENEMY2"\n\n");
  1551.  
  1552.                 VW_UpdateScreen();
  1553.                 VW_FadeIn();
  1554.  
  1555.                 PrintX = 100;
  1556.                 fontcolor = 15;
  1557.                 backcolor = TYPEBOX_BKGD;
  1558.                 inputbuffer[0] = 0;
  1559.                 PrintY = TYPEBOX_Y;
  1560.                 fontnumber = 1;
  1561.                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,20,100);
  1562.  
  1563.                 match = 0;
  1564.                 for (i=0;i<_fstrlen(bossstrs[whichboss]);i++)
  1565.                     if (!_fstrnicmp(inputbuffer,bossstrs[whichboss]+i,strlen(inputbuffer)) &&
  1566.                         strlen(inputbuffer)>3)
  1567.                         match = 1;
  1568.  
  1569.                 match += BackDoor(inputbuffer);
  1570.                 break;
  1571.  
  1572.             //
  1573.             // MANUAL CHECK
  1574.             //
  1575.             case checkmanual:
  1576.                 while (wordpicked[whichword = US_RndT()%5]);
  1577.                 wordpicked[whichword] = 1;
  1578.                 US_CPrint(STR_CHECKMAN);
  1579.                 SETFONTCOLOR(PRINTCOLOR,15);
  1580.                 PrintY += 25;
  1581.                 US_CPrint(STR_MAN1);
  1582.                 US_CPrint(STR_MAN2);
  1583.                 _fstrcpy(message,STR_MAN3" \"");
  1584.                 _fstrcat(message,WordStr[whichword]);
  1585.                 _fstrcat(message,"\" "STR_MAN4);
  1586.                 US_CPrint(message);
  1587.                 VW_UpdateScreen();
  1588.                 VW_FadeIn();
  1589.  
  1590.                 PrintX = 146;
  1591.                 fontcolor = 15;
  1592.                 backcolor = TYPEBOX_BKGD;
  1593.                 inputbuffer[0] = 0;
  1594.                 PrintY = TYPEBOX_Y;
  1595.                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,6,100);
  1596.  
  1597.                 strlwr(inputbuffer);
  1598.                 match = 1-(_fstrcmp(inputbuffer,WordCorrect[whichword])!=0);
  1599.                 match += BackDoor(inputbuffer);
  1600.                 break;
  1601.  
  1602.             //
  1603.             // STAFF QUIZ
  1604.             //
  1605.             case staffquiz:
  1606.                 while (memberpicked[whichmem = US_RndT()%5]);
  1607.                 memberpicked[whichmem] = 1;
  1608.                 US_CPrint(STR_ID1);
  1609.                 SETFONTCOLOR(PRINTCOLOR,15);
  1610.                 PrintY += 25;
  1611.                 US_CPrint(MemberStr[whichmem*2]);
  1612.                 US_CPrint(MemberStr[whichmem*2+1]);
  1613.                 VW_UpdateScreen();
  1614.                 VW_FadeIn();
  1615.  
  1616.                 PrintX = 100;
  1617.                 fontcolor = 15;
  1618.                 backcolor = TYPEBOX_BKGD;
  1619.                 inputbuffer[0] = 0;
  1620.                 PrintY = TYPEBOX_Y;
  1621.                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,20,120);
  1622.  
  1623.                 strlwr(inputbuffer);
  1624.                 match = 0;
  1625.                 for (i=0;i<_fstrlen(MemberCorrect[whichmem]);i++)
  1626.                     if (!_fstrnicmp(inputbuffer,MemberCorrect[whichmem]+i,strlen(inputbuffer)) &&
  1627.                         strlen(inputbuffer)>2)
  1628.                             match = 1;
  1629.                 match += BackDoor(inputbuffer);
  1630.                 break;
  1631.  
  1632.             //
  1633.             // MISCELLANEOUS QUESTIONS
  1634.             //
  1635.             case miscquiz:
  1636.                 while (whichpicked[whichone = US_RndT()&3]);
  1637.                 whichpicked[whichone] = 1;
  1638.                 US_CPrint(MiscTitle[whichone]);
  1639.                 SETFONTCOLOR(PRINTCOLOR,15);
  1640.                 PrintY += 25;
  1641.                 US_CPrint(MiscStr[whichone*3]);
  1642.                 US_CPrint(MiscStr[whichone*3+1]);
  1643.                 US_CPrint(MiscStr[whichone*3+2]);
  1644.                 VW_UpdateScreen();
  1645.                 VW_FadeIn();
  1646.  
  1647.                 PrintX = 146;
  1648.                 fontcolor = 15;
  1649.                 backcolor = TYPEBOX_BKGD;
  1650.                 inputbuffer[0] = 0;
  1651.                 PrintY = TYPEBOX_Y;
  1652.                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,6,100);
  1653.  
  1654.                 strlwr(inputbuffer);
  1655.                 match = 1-(_fstrcmp(inputbuffer,MiscCorrect[whichone])!=0);
  1656.                 match += BackDoor(inputbuffer);
  1657.                 break;
  1658.             }
  1659.  
  1660.         //
  1661.         // IF NO MATCH, WE'VE GOT A (MINOR) PROBLEM!
  1662.         //
  1663.  
  1664.         if (!match)
  1665.         {
  1666.             whichline = 2*(US_RndT()%9);
  1667.             SETFONTCOLOR(14,15);
  1668.             fontnumber = 0;
  1669.             PrintY = 175;
  1670.             VWB_DrawPic (0,20*8,COPYPROTBOXPIC);
  1671.             US_CPrint(CopyProFailedStrs[whichline]);
  1672.             US_CPrint(CopyProFailedStrs[whichline+1]);
  1673.  
  1674.             VW_UpdateScreen();
  1675.             SD_PlaySound(NOWAYSND);
  1676.             IN_UserInput(TickBase*3);
  1677.             VW_FadeOut();
  1678.             try++;
  1679.         }
  1680.         else
  1681.         {
  1682.             int start;
  1683.  
  1684.  
  1685.             SD_PlaySound(BONUS1UPSND);
  1686.             SD_WaitSoundDone();
  1687.             UNCACHEGRCHUNK (STARTFONT+1);
  1688.             UNCACHEGRCHUNK (C_BACKDROPPIC);
  1689.             UnCacheLump (COPYPROT_LUMP_START,COPYPROT_LUMP_END);
  1690.  
  1691.             switch(SoundMode)
  1692.             {
  1693.                 case sdm_Off: return;
  1694.                 case sdm_PC: start = STARTPCSOUNDS; break;
  1695.                 case sdm_AdLib: start = STARTADLIBSOUNDS;
  1696.             }
  1697.  
  1698.             for (i=0;i<NUMSOUNDS;i++,start++)
  1699.                 MM_FreePtr ((memptr *)&audiosegs[start]);
  1700.             return;
  1701.         }
  1702.     }
  1703.  
  1704.     ClearMemory();
  1705.     ShutdownId();
  1706.  
  1707.     _fstrcpy(message,DosMessages[US_RndT()%9]);
  1708.  
  1709.     _AX = 3;
  1710.     geninterrupt(0x10);
  1711.  
  1712.     printf("%s\n",message);
  1713.     exit(1);
  1714. }
  1715.  
  1716. #endif // SPEARDEMO
  1717. #endif // SPEAR
  1718. //===========================================================================
  1719.