12 =============================================================================
\r
16 =============================================================================
\r
21 =============================================================================
\r
25 =============================================================================
\r
28 boolean ingame,fizzlein;
\r
29 unsigned latchpics[NUMLATCHPICS];
\r
33 unsigned spearangle;
\r
37 // ELEVATOR BACK MAPS - REMEMBER (-1)!!
\r
39 int ElevatorBackTo[]={1,1,7,3,5,3};
\r
41 void ScanInfoPlane (void);
\r
42 void SetupGameLevel (void);
\r
43 void DrawPlayScreen (void);
\r
44 void LoadLatchMem (void);
\r
45 void GameLoop (void);
\r
48 =============================================================================
\r
52 =============================================================================
\r
57 //===========================================================================
\r
58 //===========================================================================
\r
62 ==========================
\r
64 = SetSoundLoc - Given the location of an object (in terms of global
\r
65 = coordinates, held in globalsoundx and globalsoundy), munges the values
\r
66 = for an approximate distance from the left and right ear, and puts
\r
67 = those values into leftchannel and rightchannel.
\r
71 ==========================
\r
74 fixed globalsoundx,globalsoundy;
\r
75 int leftchannel,rightchannel;
\r
76 #define ATABLEMAX 15
\r
77 byte righttable[ATABLEMAX][ATABLEMAX * 2] = {
\r
78 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 0, 0, 0, 0, 0, 1, 3, 5, 8, 8, 8, 8, 8, 8, 8, 8},
\r
79 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 4, 0, 0, 0, 0, 0, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},
\r
80 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 4, 1, 0, 0, 0, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},
\r
81 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 5, 4, 2, 1, 0, 1, 2, 3, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8},
\r
82 { 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 5, 4, 3, 2, 2, 3, 3, 5, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8},
\r
83 { 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8, 8, 8, 8, 8, 8},
\r
106 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
\r
107 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
\r
108 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
\r
109 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}
\r
113 SetSoundLoc(fixed gx,fixed gy)
\r
119 // translate point to view centered coordinates
\r
127 xt = FixedByFrac(gx,viewcos);
\r
128 yt = FixedByFrac(gy,viewsin);
\r
129 x = (xt - yt) >> TILESHIFT;
\r
134 xt = FixedByFrac(gx,viewsin);
\r
135 yt = FixedByFrac(gy,viewcos);
\r
136 y = (yt + xt) >> TILESHIFT;
\r
138 if (y >= ATABLEMAX)
\r
140 else if (y <= -ATABLEMAX)
\r
144 if (x >= ATABLEMAX)
\r
146 leftchannel = lefttable[x][y + ATABLEMAX];
\r
147 rightchannel = righttable[x][y + ATABLEMAX];
\r
151 US_PrintSigned(leftchannel);
\r
153 US_PrintSigned(rightchannel);
\r
159 ==========================
\r
161 = SetSoundLocGlobal - Sets up globalsoundx & globalsoundy and then calls
\r
162 = UpdateSoundLoc() to transform that into relative channel volumes. Those
\r
163 = values are then passed to the Sound Manager so that they'll be used for
\r
164 = the next sound played (if possible).
\r
168 ==========================
\r
170 void PlaySoundLocGlobal(word s,fixed gx,fixed gy)
\r
172 SetSoundLoc(gx,gy);
\r
173 SD_PositionSound(leftchannel,rightchannel);
\r
174 if (SD_PlaySound(s))
\r
181 void UpdateSoundLoc(void)
\r
183 if (SoundPositioned)
\r
185 SetSoundLoc(globalsoundx,globalsoundy);
\r
186 SD_SetPosition(leftchannel,rightchannel);
\r
196 ==========================
\r
200 ==========================
\r
203 void ClearMemory (void)
\r
205 PM_UnlockMainMem();
\r
206 SD_StopDigitized();
\r
212 ==========================
\r
216 = Spawn all actors and mark down special places
\r
218 ==========================
\r
221 void ScanInfoPlane (void)
\r
225 unsigned far *start;
\r
227 start = mapsegs[1];
\r
228 for (y=0;y<mapheight;y++)
\r
229 for (x=0;x<mapwidth;x++)
\r
241 SpawnPlayer(x,y,NORTH+tile-19);
\r
299 case 73: // TRUCK AND SPEAR!
\r
302 SpawnStatic(x,y,tile-23);
\r
310 gamestate.secrettotal++;
\r
320 if (gamestate.difficulty<gd_hard)
\r
327 if (gamestate.difficulty<gd_medium)
\r
334 SpawnStand(en_guard,x,y,tile-108);
\r
342 if (gamestate.difficulty<gd_hard)
\r
349 if (gamestate.difficulty<gd_medium)
\r
356 SpawnPatrol(en_guard,x,y,tile-112);
\r
360 SpawnDeadGuard (x,y);
\r
369 if (gamestate.difficulty<gd_hard)
\r
376 if (gamestate.difficulty<gd_medium)
\r
383 SpawnStand(en_officer,x,y,tile-116);
\r
391 if (gamestate.difficulty<gd_hard)
\r
398 if (gamestate.difficulty<gd_medium)
\r
405 SpawnPatrol(en_officer,x,y,tile-120);
\r
416 if (gamestate.difficulty<gd_hard)
\r
423 if (gamestate.difficulty<gd_medium)
\r
430 SpawnStand(en_ss,x,y,tile-126);
\r
438 if (gamestate.difficulty<gd_hard)
\r
445 if (gamestate.difficulty<gd_medium)
\r
452 SpawnPatrol(en_ss,x,y,tile-130);
\r
462 if (gamestate.difficulty<gd_hard)
\r
469 if (gamestate.difficulty<gd_medium)
\r
476 SpawnStand(en_dog,x,y,tile-134);
\r
484 if (gamestate.difficulty<gd_hard)
\r
491 if (gamestate.difficulty<gd_medium)
\r
498 SpawnPatrol(en_dog,x,y,tile-138);
\r
518 SpawnSchabbs (x,y);
\r
521 SpawnFakeHitler (x,y);
\r
528 SpawnSpectre (x,y);
\r
555 if (gamestate.difficulty<gd_hard)
\r
562 if (gamestate.difficulty<gd_medium)
\r
569 SpawnStand(en_mutant,x,y,tile-216);
\r
576 if (gamestate.difficulty<gd_hard)
\r
583 if (gamestate.difficulty<gd_medium)
\r
590 SpawnPatrol(en_mutant,x,y,tile-220);
\r
598 SpawnGhosts (en_blinky,x,y);
\r
601 SpawnGhosts (en_clyde,x,y);
\r
604 SpawnGhosts (en_pinky,x,y);
\r
607 SpawnGhosts (en_inky,x,y);
\r
615 //==========================================================================
\r
625 void SetupGameLevel (void)
\r
628 unsigned far *map,tile,spot;
\r
633 gamestate.TimeCount=
\r
634 gamestate.secrettotal=
\r
635 gamestate.killtotal=
\r
636 gamestate.treasuretotal=
\r
637 gamestate.secretcount=
\r
638 gamestate.killcount=
\r
639 gamestate.treasurecount=0;
\r
642 if (demoplayback || demorecord)
\r
643 US_InitRndT (false);
\r
645 US_InitRndT (true);
\r
650 CA_CacheMap (gamestate.mapon+10*gamestate.episode);
\r
651 mapon-=gamestate.episode*10;
\r
653 mapwidth = mapheaderseg[mapon]->width;
\r
654 mapheight = mapheaderseg[mapon]->height;
\r
656 if (mapwidth != 64 || mapheight != 64)
\r
657 Quit ("Map not 64*64!");
\r
661 // copy the wall data to a data segment array
\r
663 memset (tilemap,0,sizeof(tilemap));
\r
664 memset (actorat,0,sizeof(actorat));
\r
666 for (y=0;y<mapheight;y++)
\r
667 for (x=0;x<mapwidth;x++)
\r
673 tilemap[x][y] = tile;
\r
674 (unsigned)actorat[x][y] = tile;
\r
680 (unsigned)actorat[x][y] = 0;
\r
687 InitActorList (); // start spawning things with a clean slate
\r
692 for (y=0;y<mapheight;y++)
\r
693 for (x=0;x<mapwidth;x++)
\r
696 if (tile >= 90 && tile <= 101)
\r
707 SpawnDoor (x,y,1,(tile-90)/2);
\r
715 SpawnDoor (x,y,0,(tile-91)/2);
\r
727 // take out the ambush markers
\r
730 for (y=0;y<mapheight;y++)
\r
731 for (x=0;x<mapwidth;x++)
\r
734 if (tile == AMBUSHTILE)
\r
737 if ( (unsigned)actorat[x][y] == AMBUSHTILE)
\r
738 actorat[x][y] = NULL;
\r
740 if (*map >= AREATILE)
\r
742 if (*(map-1-mapwidth) >= AREATILE)
\r
743 tile = *(map-1-mapwidth);
\r
744 if (*(map-1+mapwidth) >= AREATILE)
\r
745 tile = *(map-1+mapwidth);
\r
746 if ( *(map-2) >= AREATILE)
\r
756 // have the caching manager load and purge stuff to make sure all marks
\r
759 CA_LoadAllSounds ();
\r
764 //==========================================================================
\r
768 ===================
\r
770 = DrawPlayBorderSides
\r
772 = To fix window overwrites
\r
774 ===================
\r
777 void DrawPlayBorderSides (void)
\r
781 xl = 160-viewwidth/2;
\r
782 yl = (200-STATUSLINES-viewheight)/2;
\r
784 VWB_Bar (0,0,xl-1,200-STATUSLINES,127);
\r
785 VWB_Bar (xl+viewwidth+1,0,xl-2,200-STATUSLINES,127);
\r
787 VWB_Vlin (yl-1,yl+viewheight,xl-1,0);
\r
788 VWB_Vlin (yl-1,yl+viewheight,xl+viewwidth,125);
\r
793 ===================
\r
795 = DrawAllPlayBorderSides
\r
797 ===================
\r
800 void DrawAllPlayBorderSides (void)
\r
807 bufferofs = screenloc[i];
\r
808 DrawPlayBorderSides ();
\r
814 ===================
\r
818 ===================
\r
820 void DrawAllPlayBorder (void)
\r
827 bufferofs = screenloc[i];
\r
834 ===================
\r
838 ===================
\r
841 void DrawPlayBorder (void)
\r
845 VWB_Bar (0,0,320,200-STATUSLINES,127);
\r
847 xl = 160-viewwidth/2;
\r
848 yl = (200-STATUSLINES-viewheight)/2;
\r
849 VWB_Bar (xl,yl,viewwidth,viewheight,0);
\r
851 VWB_Hlin (xl-1,xl+viewwidth,yl-1,0);
\r
852 VWB_Hlin (xl-1,xl+viewwidth,yl+viewheight,125);
\r
853 VWB_Vlin (yl-1,yl+viewheight,xl-1,0);
\r
854 VWB_Vlin (yl-1,yl+viewheight,xl+viewwidth,125);
\r
855 VWB_Plot (xl-1,yl+viewheight,124);
\r
861 ===================
\r
865 ===================
\r
868 void DrawPlayScreen (void)
\r
877 CA_CacheGrChunk (STATUSBARPIC);
\r
881 bufferofs = screenloc[i];
\r
883 VWB_DrawPic (0,200-STATUSLINES,STATUSBARPIC);
\r
888 UNCACHEGRCHUNK (STATUSBARPIC);
\r
902 //==========================================================================
\r
912 #define MAXDEMOSIZE 8192
\r
914 void StartDemoRecord (int levelnumber)
\r
916 MM_GetPtr (&demobuffer,MAXDEMOSIZE);
\r
917 MM_SetLock (&demobuffer,true);
\r
918 demoptr = (char far *)demobuffer;
\r
919 lastdemoptr = demoptr+MAXDEMOSIZE;
\r
921 *demoptr = levelnumber;
\r
922 demoptr += 4; // leave space for length
\r
935 char demoname[13] = "DEMO?.";
\r
937 void FinishDemoRecord (void)
\r
941 demorecord = false;
\r
943 length = demoptr - (char far *)demobuffer;
\r
945 demoptr = ((char far *)demobuffer)+1;
\r
946 *(unsigned far *)demoptr = length;
\r
948 CenterWindow(24,3);
\r
950 US_Print(" Demo number (0-9):");
\r
953 if (US_LineInput (px,py,str,NULL,true,2,0))
\r
955 level = atoi (str);
\r
956 if (level>=0 && level<=9)
\r
958 demoname[4] = '0'+level;
\r
959 CA_WriteFile (demoname,(void far *)demobuffer,length);
\r
964 MM_FreePtr (&demobuffer);
\r
967 //==========================================================================
\r
974 = Fades the screen out, then starts a demo. Exits with the screen faded
\r
979 void RecordDemo (void)
\r
983 CenterWindow(26,3);
\r
985 CA_CacheGrChunk(STARTFONT);
\r
987 US_Print(" Demo which level(1-10):");
\r
990 esc = !US_LineInput (px,py,str,NULL,true,2,0);
\r
994 level = atoi (str);
\r
997 SETFONTCOLOR(0,15);
\r
1001 NewGame (gd_hard,level/10);
\r
1002 gamestate.mapon = level%10;
\r
1004 NewGame (gd_hard,0);
\r
1005 gamestate.mapon = level;
\r
1008 StartDemoRecord (level);
\r
1010 DrawPlayScreen ();
\r
1013 startgame = false;
\r
1014 demorecord = true;
\r
1016 SetupGameLevel ();
\r
1018 PM_CheckMainMem ();
\r
1023 demoplayback = false;
\r
1029 FinishDemoRecord ();
\r
1032 //==========================================================================
\r
1035 ==================
\r
1039 = Fades the screen out, then starts a demo. Exits with the screen faded
\r
1041 ==================
\r
1044 void PlayDemo (int demonumber)
\r
1048 #ifdef DEMOSEXTERN
\r
1049 // debug: load chunk
\r
1051 int dems[4]={T_DEMO0,T_DEMO1,T_DEMO2,T_DEMO3};
\r
1053 int dems[1]={T_DEMO0};
\r
1056 CA_CacheGrChunk(dems[demonumber]);
\r
1057 demoptr = grsegs[dems[demonumber]];
\r
1058 MM_SetLock (&grsegs[dems[demonumber]],true);
\r
1060 demoname[4] = '0'+demonumber;
\r
1061 CA_LoadFile (demoname,&demobuffer);
\r
1062 MM_SetLock (&demobuffer,true);
\r
1063 demoptr = (char far *)demobuffer;
\r
1067 gamestate.mapon = *demoptr++;
\r
1068 gamestate.difficulty = gd_hard;
\r
1069 length = *((unsigned far *)demoptr)++;
\r
1071 lastdemoptr = demoptr-4+length;
\r
1075 SETFONTCOLOR(0,15);
\r
1076 DrawPlayScreen ();
\r
1079 startgame = false;
\r
1080 demoplayback = true;
\r
1082 SetupGameLevel ();
\r
1084 PM_CheckMainMem ();
\r
1089 #ifdef DEMOSEXTERN
\r
1090 UNCACHEGRCHUNK(dems[demonumber]);
\r
1092 MM_FreePtr (&demobuffer);
\r
1095 demoplayback = false;
\r
1102 //==========================================================================
\r
1105 ==================
\r
1109 ==================
\r
1112 #define DEATHROTATE 2
\r
1118 int iangle,curangle,clockwise,counter,change;
\r
1120 gamestate.weapon = -1; // take away weapon
\r
1121 SD_PlaySound (PLAYERDEATHSND);
\r
1123 // swing around to face attacker
\r
1125 dx = killerobj->x - player->x;
\r
1126 dy = player->y - killerobj->y;
\r
1128 fangle = atan2(dy,dx); // returns -pi to pi
\r
1130 fangle = M_PI*2+fangle;
\r
1132 iangle = fangle/(M_PI*2)*ANGLES;
\r
1134 if (player->angle > iangle)
\r
1136 counter = player->angle - iangle;
\r
1137 clockwise = ANGLES-player->angle + iangle;
\r
1141 clockwise = iangle - player->angle;
\r
1142 counter = player->angle + ANGLES-iangle;
\r
1145 curangle = player->angle;
\r
1147 if (clockwise<counter)
\r
1150 // rotate clockwise
\r
1152 if (curangle>iangle)
\r
1153 curangle -= ANGLES;
\r
1156 change = tics*DEATHROTATE;
\r
1157 if (curangle + change > iangle)
\r
1158 change = iangle-curangle;
\r
1160 curangle += change;
\r
1161 player->angle += change;
\r
1162 if (player->angle >= ANGLES)
\r
1163 player->angle -= ANGLES;
\r
1167 } while (curangle != iangle);
\r
1172 // rotate counterclockwise
\r
1174 if (curangle<iangle)
\r
1175 curangle += ANGLES;
\r
1178 change = -tics*DEATHROTATE;
\r
1179 if (curangle + change < iangle)
\r
1180 change = iangle-curangle;
\r
1182 curangle += change;
\r
1183 player->angle += change;
\r
1184 if (player->angle < 0)
\r
1185 player->angle += ANGLES;
\r
1189 } while (curangle != iangle);
\r
1195 FinishPaletteShifts ();
\r
1197 bufferofs += screenofs;
\r
1198 VW_Bar (0,0,viewwidth,viewheight,4);
\r
1199 IN_ClearKeysDown ();
\r
1200 FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,70,false);
\r
1201 bufferofs -= screenofs;
\r
1202 IN_UserInput(100);
\r
1203 SD_WaitSoundDone ();
\r
1205 if (tedlevel == false) // SO'S YA DON'T GET KILLED WHILE LAUNCHING!
\r
1206 gamestate.lives--;
\r
1208 if (gamestate.lives > -1)
\r
1210 gamestate.health = 100;
\r
1211 gamestate.weapon = gamestate.bestweapon
\r
1212 = gamestate.chosenweapon = wp_pistol;
\r
1213 gamestate.ammo = STARTAMMO;
\r
1214 gamestate.keys = 0;
\r
1215 gamestate.attackframe = gamestate.attackcount =
\r
1216 gamestate.weaponframe = 0;
\r
1228 //==========================================================================
\r
1231 ===================
\r
1235 ===================
\r
1238 void GameLoop (void)
\r
1240 int i,xl,yl,xh,yh;
\r
1244 clock_t start,end;
\r
1249 SETFONTCOLOR(0,15);
\r
1250 DrawPlayScreen ();
\r
1256 gamestate.score = gamestate.oldscore;
\r
1259 startgame = false;
\r
1261 loadedgame = false;
\r
1263 SetupGameLevel ();
\r
1266 if (gamestate.mapon == 20) // give them the key allways
\r
1268 gamestate.keys |= 1;
\r
1275 PM_CheckMainMem ();
\r
1277 PreloadGraphics ();
\r
1291 SD_PlaySound(GETSPEARSND);
\r
1292 if (DigiMode != sds_Off)
\r
1294 long lasttimecount = TimeCount;
\r
1296 while(TimeCount < lasttimecount+150)
\r
1297 //while(DigiPlaying!=false)
\r
1301 SD_WaitSoundDone();
\r
1304 gamestate.oldscore = gamestate.score;
\r
1305 gamestate.mapon = 20;
\r
1306 SetupGameLevel ();
\r
1308 PM_CheckMainMem ();
\r
1309 player->x = spearx;
\r
1310 player->y = speary;
\r
1311 player->angle = spearangle;
\r
1312 spearflag = false;
\r
1314 goto startplayloop;
\r
1321 if (demorecord && playstate != ex_warped)
\r
1322 FinishDemoRecord ();
\r
1324 if (startgame || loadedgame)
\r
1327 switch (playstate)
\r
1329 case ex_completed:
\r
1330 case ex_secretlevel:
\r
1331 gamestate.keys = 0;
\r
1337 LevelCompleted (); // do the intermission
\r
1339 if (gamestate.mapon == 1)
\r
1341 died = true; // don't "get psyched!"
\r
1347 CheckHighScore (gamestate.score,gamestate.mapon+1);
\r
1351 _fstrcpy(MainMenu[viewscores].string,STR_VS);
\r
1353 MainMenu[viewscores].routine = CP_ViewScores;
\r
1361 if (gamestate.mapon == 3)
\r
1363 died = true; // don't "get psyched!"
\r
1369 CheckHighScore (gamestate.score,gamestate.mapon+1);
\r
1373 _fstrcpy(MainMenu[viewscores].string,STR_VS);
\r
1375 MainMenu[viewscores].routine = CP_ViewScores;
\r
1382 gamestate.oldscore = gamestate.score;
\r
1386 // COMING BACK FROM SECRET LEVEL
\r
1388 if (gamestate.mapon == 9)
\r
1389 gamestate.mapon = ElevatorBackTo[gamestate.episode]; // back from secret
\r
1392 // GOING TO SECRET LEVEL
\r
1394 if (playstate == ex_secretlevel)
\r
1395 gamestate.mapon = 9;
\r
1398 #define FROMSECRET1 3
\r
1399 #define FROMSECRET2 11
\r
1402 // GOING TO SECRET LEVEL
\r
1404 if (playstate == ex_secretlevel)
\r
1405 switch(gamestate.mapon)
\r
1407 case FROMSECRET1: gamestate.mapon = 18; break;
\r
1408 case FROMSECRET2: gamestate.mapon = 19; break;
\r
1412 // COMING BACK FROM SECRET LEVEL
\r
1414 if (gamestate.mapon == 18 || gamestate.mapon == 19)
\r
1415 switch(gamestate.mapon)
\r
1417 case 18: gamestate.mapon = FROMSECRET1+1; break;
\r
1418 case 19: gamestate.mapon = FROMSECRET2+1; break;
\r
1423 // GOING TO NEXT LEVEL
\r
1425 gamestate.mapon++;
\r
1432 died = true; // don't "get psyched!"
\r
1434 if (gamestate.lives > -1)
\r
1435 break; // more lives left
\r
1441 CheckHighScore (gamestate.score,gamestate.mapon+1);
\r
1445 _fstrcpy(MainMenu[viewscores].string,STR_VS);
\r
1447 MainMenu[viewscores].routine = CP_ViewScores;
\r
1452 case ex_victorious:
\r
1457 VL_FadeOut (0,255,0,17,17,300);
\r
1465 CheckHighScore (gamestate.score,gamestate.mapon+1);
\r
1469 _fstrcpy(MainMenu[viewscores].string,STR_VS);
\r
1471 MainMenu[viewscores].routine = CP_ViewScores;
\r