9 =============================================================================
\r
13 An Id Software production
\r
17 =============================================================================
\r
21 =============================================================================
\r
25 =============================================================================
\r
29 #define FOCALLENGTH (0x5700l) // in global coordinates
\r
30 #define VIEWGLOBAL 0x10000 // globals visable flush to wall
\r
32 #define VIEWWIDTH 256 // size of view window
\r
33 #define VIEWHEIGHT 144
\r
36 =============================================================================
\r
40 =============================================================================
\r
43 char str[80],str2[20];
\r
48 int dirangle[9] = {0,ANGLES/8,2*ANGLES/8,3*ANGLES/8,4*ANGLES/8,
\r
49 5*ANGLES/8,6*ANGLES/8,7*ANGLES/8,ANGLES};
\r
52 // proejection variables
\r
59 int shootdelta; // pixels away from centerx a target can be
\r
60 fixed scale,maxslope;
\r
61 long heightnumerator;
\r
65 void Quit (char *error);
\r
67 boolean startgame,loadedgame,virtualreality;
\r
68 int mouseadjustment;
\r
70 char configname[13]="CONFIG.";
\r
74 =============================================================================
\r
78 =============================================================================
\r
83 ====================
\r
87 ====================
\r
90 void ReadConfig(void)
\r
98 if ( (file = open(configname,O_BINARY | O_RDONLY)) != -1)
\r
101 // valid config file
\r
103 read(file,Scores,sizeof(HighScore) * MaxScores);
\r
105 read(file,&sd,sizeof(sd));
\r
106 read(file,&sm,sizeof(sm));
\r
107 read(file,&sds,sizeof(sds));
\r
109 read(file,&mouseenabled,sizeof(mouseenabled));
\r
110 read(file,&joystickenabled,sizeof(joystickenabled));
\r
111 read(file,&joypadenabled,sizeof(joypadenabled));
\r
112 read(file,&joystickprogressive,sizeof(joystickprogressive));
\r
113 read(file,&joystickport,sizeof(joystickport));
\r
115 read(file,&dirscan,sizeof(dirscan));
\r
116 read(file,&buttonscan,sizeof(buttonscan));
\r
117 read(file,&buttonmouse,sizeof(buttonmouse));
\r
118 read(file,&buttonjoy,sizeof(buttonjoy));
\r
120 read(file,&viewsize,sizeof(viewsize));
\r
121 read(file,&mouseadjustment,sizeof(mouseadjustment));
\r
125 if (sd == sdm_AdLib && !AdLibPresent && !SoundBlasterPresent)
\r
131 if ((sds == sds_SoundBlaster && !SoundBlasterPresent) ||
\r
132 (sds == sds_SoundSource && !SoundSourcePresent))
\r
136 mouseenabled = false;
\r
137 if (!JoysPresent[joystickport])
\r
138 joystickenabled = false;
\r
140 MainMenu[6].active=1;
\r
141 MainItems.curpos=0;
\r
146 // no config file, so select by hardware
\r
148 if (SoundBlasterPresent || AdLibPresent)
\r
159 if (SoundBlasterPresent)
\r
160 sds = sds_SoundBlaster;
\r
161 else if (SoundSourcePresent)
\r
162 sds = sds_SoundSource;
\r
167 mouseenabled = true;
\r
169 joystickenabled = false;
\r
170 joypadenabled = false;
\r
172 joystickprogressive = false;
\r
178 SD_SetMusicMode (sm);
\r
179 SD_SetSoundMode (sd);
\r
180 SD_SetDigiDevice (sds);
\r
186 ====================
\r
190 ====================
\r
193 void WriteConfig(void)
\r
197 file = open(configname,O_CREAT | O_BINARY | O_WRONLY,
\r
198 S_IREAD | S_IWRITE | S_IFREG);
\r
202 write(file,Scores,sizeof(HighScore) * MaxScores);
\r
204 write(file,&SoundMode,sizeof(SoundMode));
\r
205 write(file,&MusicMode,sizeof(MusicMode));
\r
206 write(file,&DigiMode,sizeof(DigiMode));
\r
208 write(file,&mouseenabled,sizeof(mouseenabled));
\r
209 write(file,&joystickenabled,sizeof(joystickenabled));
\r
210 write(file,&joypadenabled,sizeof(joypadenabled));
\r
211 write(file,&joystickprogressive,sizeof(joystickprogressive));
\r
212 write(file,&joystickport,sizeof(joystickport));
\r
214 write(file,&dirscan,sizeof(dirscan));
\r
215 write(file,&buttonscan,sizeof(buttonscan));
\r
216 write(file,&buttonmouse,sizeof(buttonmouse));
\r
217 write(file,&buttonjoy,sizeof(buttonjoy));
\r
219 write(file,&viewsize,sizeof(viewsize));
\r
220 write(file,&mouseadjustment,sizeof(mouseadjustment));
\r
227 //===========================================================================
\r
231 ========================
\r
235 = Patch ldiv to use 32 bit instructions
\r
237 ========================
\r
240 char *JHParmStrings[] = {"no386",nil};
\r
241 void Patch386 (void)
\r
243 extern void far jabhack2(void);
\r
244 extern int far CheckIs386(void);
\r
248 for (i = 1;i < _argc;i++)
\r
249 if (US_CheckParm(_argv[i],JHParmStrings) == 0)
\r
264 //===========================================================================
\r
267 =====================
\r
271 = Set up new game to start from the beginning
\r
273 =====================
\r
276 void NewGame (int difficulty,int episode)
\r
278 memset (&gamestate,0,sizeof(gamestate));
\r
279 gamestate.difficulty = difficulty;
\r
280 gamestate.weapon = gamestate.bestweapon
\r
281 = gamestate.chosenweapon = wp_pistol;
\r
282 gamestate.health = 100;
\r
283 gamestate.ammo = STARTAMMO;
\r
284 gamestate.lives = 3;
\r
285 gamestate.nextextra = EXTRAPOINTS;
\r
286 gamestate.episode=episode;
\r
291 //===========================================================================
\r
293 void DiskFlopAnim(int x,int y)
\r
295 static char which=0;
\r
298 VWB_DrawPic(x,y,C_DISKLOADING1PIC+which);
\r
304 long DoChecksum(byte far *source,unsigned size,long checksum)
\r
308 for (i=0;i<size-1;i++)
\r
309 checksum += source[i]^source[i+1];
\r
323 boolean SaveTheGame(int file,int x,int y)
\r
325 struct diskfree_t dfree;
\r
326 long avail,size,checksum;
\r
327 objtype *ob,nullobj;
\r
330 if (_dos_getdiskfree(0,&dfree))
\r
331 Quit("Error in _dos_getdiskfree call");
\r
333 avail = (long)dfree.avail_clusters *
\r
334 dfree.bytes_per_sector *
\r
335 dfree.sectors_per_cluster;
\r
338 for (ob = player; ob ; ob=ob->next)
\r
339 size += sizeof(*ob);
\r
340 size += sizeof(nullobj);
\r
342 size += sizeof(gamestate) +
\r
343 sizeof(LRstruct)*8 +
\r
346 sizeof(laststatobj) +
\r
347 sizeof(statobjlist) +
\r
348 sizeof(doorposition) +
\r
349 sizeof(pwallstate) +
\r
357 Message(STR_NOSPACE1"\n"
\r
366 CA_FarWrite (file,(void far *)&gamestate,sizeof(gamestate));
\r
367 checksum = DoChecksum((byte far *)&gamestate,sizeof(gamestate),checksum);
\r
371 CA_FarWrite (file,(void far *)&LevelRatios[0],sizeof(LRstruct)*20);
\r
372 checksum = DoChecksum((byte far *)&LevelRatios[0],sizeof(LRstruct)*20,checksum);
\r
374 CA_FarWrite (file,(void far *)&LevelRatios[0],sizeof(LRstruct)*8);
\r
375 checksum = DoChecksum((byte far *)&LevelRatios[0],sizeof(LRstruct)*8,checksum);
\r
379 CA_FarWrite (file,(void far *)tilemap,sizeof(tilemap));
\r
380 checksum = DoChecksum((byte far *)tilemap,sizeof(tilemap),checksum);
\r
382 CA_FarWrite (file,(void far *)actorat,sizeof(actorat));
\r
383 checksum = DoChecksum((byte far *)actorat,sizeof(actorat),checksum);
\r
385 CA_FarWrite (file,(void far *)areaconnect,sizeof(areaconnect));
\r
386 CA_FarWrite (file,(void far *)areabyplayer,sizeof(areabyplayer));
\r
388 for (ob = player ; ob ; ob=ob->next)
\r
391 CA_FarWrite (file,(void far *)ob,sizeof(*ob));
\r
393 nullobj.active = ac_badobject; // end of file marker
\r
395 CA_FarWrite (file,(void far *)&nullobj,sizeof(nullobj));
\r
400 CA_FarWrite (file,(void far *)&laststatobj,sizeof(laststatobj));
\r
401 checksum = DoChecksum((byte far *)&laststatobj,sizeof(laststatobj),checksum);
\r
403 CA_FarWrite (file,(void far *)statobjlist,sizeof(statobjlist));
\r
404 checksum = DoChecksum((byte far *)statobjlist,sizeof(statobjlist),checksum);
\r
407 CA_FarWrite (file,(void far *)doorposition,sizeof(doorposition));
\r
408 checksum = DoChecksum((byte far *)doorposition,sizeof(doorposition),checksum);
\r
410 CA_FarWrite (file,(void far *)doorobjlist,sizeof(doorobjlist));
\r
411 checksum = DoChecksum((byte far *)doorobjlist,sizeof(doorobjlist),checksum);
\r
414 CA_FarWrite (file,(void far *)&pwallstate,sizeof(pwallstate));
\r
415 checksum = DoChecksum((byte far *)&pwallstate,sizeof(pwallstate),checksum);
\r
416 CA_FarWrite (file,(void far *)&pwallx,sizeof(pwallx));
\r
417 checksum = DoChecksum((byte far *)&pwallx,sizeof(pwallx),checksum);
\r
418 CA_FarWrite (file,(void far *)&pwally,sizeof(pwally));
\r
419 checksum = DoChecksum((byte far *)&pwally,sizeof(pwally),checksum);
\r
420 CA_FarWrite (file,(void far *)&pwalldir,sizeof(pwalldir));
\r
421 checksum = DoChecksum((byte far *)&pwalldir,sizeof(pwalldir),checksum);
\r
422 CA_FarWrite (file,(void far *)&pwallpos,sizeof(pwallpos));
\r
423 checksum = DoChecksum((byte far *)&pwallpos,sizeof(pwallpos),checksum);
\r
426 // WRITE OUT CHECKSUM
\r
428 CA_FarWrite (file,(void far *)&checksum,sizeof(checksum));
\r
433 //===========================================================================
\r
443 boolean LoadTheGame(int file,int x,int y)
\r
445 long checksum,oldchecksum;
\r
446 objtype *ob,nullobj;
\r
452 CA_FarRead (file,(void far *)&gamestate,sizeof(gamestate));
\r
453 checksum = DoChecksum((byte far *)&gamestate,sizeof(gamestate),checksum);
\r
457 CA_FarRead (file,(void far *)&LevelRatios[0],sizeof(LRstruct)*20);
\r
458 checksum = DoChecksum((byte far *)&LevelRatios[0],sizeof(LRstruct)*20,checksum);
\r
460 CA_FarRead (file,(void far *)&LevelRatios[0],sizeof(LRstruct)*8);
\r
461 checksum = DoChecksum((byte far *)&LevelRatios[0],sizeof(LRstruct)*8,checksum);
\r
468 CA_FarRead (file,(void far *)tilemap,sizeof(tilemap));
\r
469 checksum = DoChecksum((byte far *)tilemap,sizeof(tilemap),checksum);
\r
471 CA_FarRead (file,(void far *)actorat,sizeof(actorat));
\r
472 checksum = DoChecksum((byte far *)actorat,sizeof(actorat),checksum);
\r
474 CA_FarRead (file,(void far *)areaconnect,sizeof(areaconnect));
\r
475 CA_FarRead (file,(void far *)areabyplayer,sizeof(areabyplayer));
\r
481 CA_FarRead (file,(void far *)player,sizeof(*player));
\r
486 CA_FarRead (file,(void far *)&nullobj,sizeof(nullobj));
\r
487 if (nullobj.active == ac_badobject)
\r
490 // don't copy over the links
\r
491 memcpy (new,&nullobj,sizeof(nullobj)-4);
\r
497 CA_FarRead (file,(void far *)&laststatobj,sizeof(laststatobj));
\r
498 checksum = DoChecksum((byte far *)&laststatobj,sizeof(laststatobj),checksum);
\r
500 CA_FarRead (file,(void far *)statobjlist,sizeof(statobjlist));
\r
501 checksum = DoChecksum((byte far *)statobjlist,sizeof(statobjlist),checksum);
\r
504 CA_FarRead (file,(void far *)doorposition,sizeof(doorposition));
\r
505 checksum = DoChecksum((byte far *)doorposition,sizeof(doorposition),checksum);
\r
507 CA_FarRead (file,(void far *)doorobjlist,sizeof(doorobjlist));
\r
508 checksum = DoChecksum((byte far *)doorobjlist,sizeof(doorobjlist),checksum);
\r
511 CA_FarRead (file,(void far *)&pwallstate,sizeof(pwallstate));
\r
512 checksum = DoChecksum((byte far *)&pwallstate,sizeof(pwallstate),checksum);
\r
513 CA_FarRead (file,(void far *)&pwallx,sizeof(pwallx));
\r
514 checksum = DoChecksum((byte far *)&pwallx,sizeof(pwallx),checksum);
\r
515 CA_FarRead (file,(void far *)&pwally,sizeof(pwally));
\r
516 checksum = DoChecksum((byte far *)&pwally,sizeof(pwally),checksum);
\r
517 CA_FarRead (file,(void far *)&pwalldir,sizeof(pwalldir));
\r
518 checksum = DoChecksum((byte far *)&pwalldir,sizeof(pwalldir),checksum);
\r
519 CA_FarRead (file,(void far *)&pwallpos,sizeof(pwallpos));
\r
520 checksum = DoChecksum((byte far *)&pwallpos,sizeof(pwallpos),checksum);
\r
522 CA_FarRead (file,(void far *)&oldchecksum,sizeof(oldchecksum));
\r
524 if (oldchecksum != checksum)
\r
526 Message(STR_SAVECHT1"\n"
\r
531 IN_ClearKeysDown();
\r
534 gamestate.score = 0;
\r
535 gamestate.lives = 1;
\r
537 gamestate.chosenweapon =
\r
538 gamestate.bestweapon = wp_pistol;
\r
539 gamestate.ammo = 8;
\r
545 //===========================================================================
\r
548 ==========================
\r
552 = Shuts down all ID_?? managers
\r
554 ==========================
\r
557 void ShutdownId (void)
\r
569 //===========================================================================
\r
578 = scale projection constant
\r
579 = sintable/costable overlapping fractional tables
\r
584 const float radtoint = (float)FINEANGLES/2/PI;
\r
586 void BuildTables (void)
\r
589 float angle,anglestep;
\r
595 // calculate fine tangents
\r
598 for (i=0;i<FINEANGLES/8;i++)
\r
600 tang = tan( (i+0.5)/radtoint);
\r
601 finetangent[i] = tang*TILEGLOBAL;
\r
602 finetangent[FINEANGLES/4-1-i] = 1/tang*TILEGLOBAL;
\r
606 // costable overlays sintable with a quarter phase shift
\r
607 // ANGLES is assumed to be divisable by four
\r
609 // The low word of the value is the fraction, the high bit is the sign bit,
\r
610 // bits 16-30 should be 0
\r
614 anglestep = PI/2/ANGLEQUAD;
\r
615 for (i=0;i<=ANGLEQUAD;i++)
\r
617 value=GLOBAL1*sin(angle);
\r
619 sintable[i+ANGLES]=
\r
620 sintable[ANGLES/2-i] = value;
\r
621 sintable[ANGLES-i]=
\r
622 sintable[ANGLES/2+i] = value | 0x80000000l;
\r
623 angle += anglestep;
\r
628 //===========================================================================
\r
632 ====================
\r
638 ====================
\r
641 void CalcProjection (long focal)
\r
650 double halfangle,facedist;
\r
653 focallength = focal;
\r
654 facedist = focal+MINDIST;
\r
655 halfview = viewwidth/2; // half view in pixels
\r
658 // calculate scale value for vertical height calculations
\r
659 // and sprite x calculations
\r
661 scale = halfview*facedist/(VIEWGLOBAL/2);
\r
664 // divide heightnumerator by a posts distance to get the posts height for
\r
665 // the heightbuffer. The pixel height is height>>2
\r
667 heightnumerator = (TILEGLOBAL*scale)>>6;
\r
668 minheightdiv = heightnumerator/0x7fff +1;
\r
671 // calculate the angle offset from view angle of each pixel's ray
\r
674 for (i=0;i<halfview;i++)
\r
676 // start 1/2 pixel over, so viewangle bisects two middle pixels
\r
677 tang = (long)i*VIEWGLOBAL/viewwidth/facedist;
\r
678 angle = atan(tang);
\r
679 intang = angle*radtoint;
\r
680 pixelangle[halfview-1-i] = intang;
\r
681 pixelangle[halfview+i] = -intang;
\r
685 // if a point's abs(y/x) is greater than maxslope, the point is outside
\r
688 maxslope = finetangent[pixelangle[0]];
\r
694 //===========================================================================
\r
697 ===================
\r
701 = Map tile values to scaled pics
\r
703 ===================
\r
706 void SetupWalls (void)
\r
710 for (i=1;i<MAXWALLTILES;i++)
\r
712 horizwall[i]=(i-1)*2;
\r
713 vertwall[i]=(i-1)*2+1;
\r
717 //===========================================================================
\r
720 ==========================
\r
724 ==========================
\r
727 void SignonScreen (void) // VGA version
\r
729 unsigned segstart,seglength;
\r
731 VL_SetVGAPlaneMode ();
\r
732 VL_TestPaletteSet ();
\r
733 VL_SetPalette (&gamepal);
\r
735 if (!virtualreality)
\r
737 VW_SetScreen(0x8000,0);
\r
738 VL_MungePic (&introscn,320,200);
\r
739 VL_MemToScreen (&introscn,320,200,0,0);
\r
744 // reclaim the memory from the linked in signon screen
\r
746 segstart = FP_SEG(&introscn);
\r
747 seglength = 64000/16;
\r
748 if (FP_OFF(&introscn))
\r
753 MML_UseSpace (segstart,seglength);
\r
758 ==========================
\r
762 ==========================
\r
765 void FinishSignon (void)
\r
769 VW_Bar (0,189,300,11,peekb(0xa000,0));
\r
775 SETFONTCOLOR(14,4);
\r
778 US_CPrint ("Oprima una tecla");
\r
780 US_CPrint ("Press a key");
\r
789 VW_Bar (0,189,300,11,peekb(0xa000,0));
\r
792 SETFONTCOLOR(10,4);
\r
795 US_CPrint ("pensando...");
\r
797 US_CPrint ("Working...");
\r
802 SETFONTCOLOR(0,15);
\r
809 //===========================================================================
\r
819 boolean MS_CheckParm (char far *check)
\r
824 for (i = 1;i<_argc;i++)
\r
828 while ( !isalpha(*parm) ) // skip - / \ etc.. in front of parm
\r
830 break; // hit end of string without an alphanum
\r
832 if ( !_fstricmp(check,parm) )
\r
839 //===========================================================================
\r
842 =====================
\r
846 =====================
\r
849 static int wolfdigimap[] =
\r
851 // These first sounds are in the upload version
\r
857 ATKMACHINEGUNSND, 4,
\r
865 DEATHSCREAM1SND, 12,
\r
866 DEATHSCREAM2SND, 13,
\r
867 DEATHSCREAM3SND, 13,
\r
878 // These are in all other episodes
\r
895 DEATHSCREAM4SND, 34, // AIIEEE
\r
896 DEATHSCREAM5SND, 35, // DEE-DEE
\r
897 DONNERSND, 36, // EPISODE 4 BOSS DIE
\r
898 EINESND, 37, // EPISODE 4 BOSS SIGHTING
\r
899 ERLAUBENSND, 38, // EPISODE 6 BOSS SIGHTING
\r
900 DEATHSCREAM6SND, 39, // FART
\r
901 DEATHSCREAM7SND, 40, // GASP
\r
902 DEATHSCREAM8SND, 41, // GUH-BOY!
\r
903 DEATHSCREAM9SND, 42, // AH GEEZ!
\r
904 KEINSND, 43, // EPISODE 5 BOSS SIGHTING
\r
905 MEINSND, 44, // EPISODE 6 BOSS DIE
\r
906 ROSESND, 45, // EPISODE 5 BOSS DIE
\r
911 // SPEAR OF DESTINY DIGISOUNDS
\r
916 ATKMACHINEGUNSND, 4,
\r
922 DEATHSCREAM1SND, 10,
\r
923 DEATHSCREAM2SND, 11,
\r
931 DEATHSCREAM4SND, 23, // AIIEEE
\r
932 DEATHSCREAM3SND, 23, // DOUBLY-MAPPED!!!
\r
933 DEATHSCREAM5SND, 24, // DEE-DEE
\r
934 DEATHSCREAM6SND, 25, // FART
\r
935 DEATHSCREAM7SND, 26, // GASP
\r
936 DEATHSCREAM8SND, 27, // GUH-BOY!
\r
937 DEATHSCREAM9SND, 28, // AH GEEZ!
\r
938 GETGATLINGSND, 38, // Got Gat replacement
\r
946 TRANSSIGHTSND, 29, // Trans Sight
\r
947 TRANSDEATHSND, 30, // Trans Death
\r
948 WILHELMSIGHTSND, 31, // Wilhelm Sight
\r
949 WILHELMDEATHSND, 32, // Wilhelm Death
\r
950 UBERDEATHSND, 33, // Uber Death
\r
951 KNIGHTSIGHTSND, 34, // Death Knight Sight
\r
952 KNIGHTDEATHSND, 35, // Death Knight Death
\r
953 ANGELSIGHTSND, 36, // Angel Sight
\r
954 ANGELDEATHSND, 37, // Angel Death
\r
955 GETSPEARSND, 39, // Got Spear replacement
\r
962 void InitDigiMap (void)
\r
966 for (map = wolfdigimap;*map != LASTSOUND;map += 2)
\r
967 DigiMap[map[0]] = map[1];
\r
974 CP_iteminfo MusicItems={CTL_X,CTL_Y,6,0,32};
\r
975 CP_itemtype far MusicMenu[]=
\r
982 {1,"Around The Corner!",0},
\r
984 {1,"Nazi Anthem",0},
\r
985 {1,"Lurking...",0},
\r
986 {1,"Going After Hitler",0},
\r
987 {1,"Pounding Headache",0},
\r
988 {1,"Into the Dungeons",0},
\r
989 {1,"Ultimate Conquest",0},
\r
991 {1,"Kill the S.O.B.",0},
\r
992 {1,"The Nazi Rap",0},
\r
993 {1,"Twelfth Hour",0},
\r
995 {1,"Ultimate Conquest",0},
\r
999 CP_iteminfo MusicItems={CTL_X,CTL_Y-20,9,0,32};
\r
1000 CP_itemtype far MusicMenu[]=
\r
1002 {1,"Funky Colonel Bill",0},
\r
1003 {1,"Death To The Nazis",0},
\r
1004 {1,"Tiptoeing Around",0},
\r
1005 {1,"Is This THE END?",0},
\r
1006 {1,"Evil Incarnate",0},
\r
1007 {1,"Jazzin' Them Nazis",0},
\r
1008 {1,"Puttin' It To The Enemy",0},
\r
1009 {1,"The SS Gonna Get You",0},
\r
1010 {1,"Towering Above",0}
\r
1015 void DoJukebox(void)
\r
1017 int which,lastsong=-1;
\r
1018 unsigned start,songs[]=
\r
1047 XJAZNAZI_MUS, // 18
\r
1049 XGETYOU_MUS, // 22
\r
1053 struct dostime_t time;
\r
1057 IN_ClearKeysDown();
\r
1058 if (!AdLibPresent && !SoundBlasterPresent)
\r
1066 _dos_gettime(&time);
\r
1067 start = (time.hsecond%3)*6;
\r
1076 CA_CacheGrChunk (STARTFONT+1);
\r
1078 CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
\r
1080 CacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END);
\r
1082 CA_LoadAllSounds ();
\r
1086 VWB_DrawPic(112,184,C_MOUSELBACKPIC);
\r
1088 SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR);
\r
1091 DrawWindow (CTL_X-2,CTL_Y-6,280,13*7,BKGDCOLOR);
\r
1093 DrawWindow (CTL_X-2,CTL_Y-26,280,13*10,BKGDCOLOR);
\r
1096 DrawMenu (&MusicItems,&MusicMenu[start]);
\r
1098 SETFONTCOLOR (READHCOLOR,BKGDCOLOR);
\r
1102 US_CPrint ("Robert's Jukebox");
\r
1104 SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR);
\r
1105 VW_UpdateScreen();
\r
1110 which = HandleMenu(&MusicItems,&MusicMenu[start],NULL);
\r
1113 if (lastsong >= 0)
\r
1114 MusicMenu[start+lastsong].active = 1;
\r
1116 StartCPMusic(songs[start + which]);
\r
1117 MusicMenu[start+which].active = 2;
\r
1118 DrawMenu (&MusicItems,&MusicMenu[start]);
\r
1119 VW_UpdateScreen();
\r
1122 } while(which>=0);
\r
1125 IN_ClearKeysDown();
\r
1127 UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
\r
1129 UnCacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END);
\r
1136 ==========================
\r
1140 = Load a few things right away
\r
1142 ==========================
\r
1145 void InitGame (void)
\r
1148 unsigned *blockstart;
\r
1150 if (MS_CheckParm ("virtual"))
\r
1151 virtualreality = true;
\r
1153 virtualreality = false;
\r
1155 MM_Startup (); // so the signon screen can be freed
\r
1162 PM_UnlockMainMem ();
\r
1169 if (mminfo.mainmem < 235000L)
\r
1171 if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode"))
\r
1176 CA_CacheGrChunk (ERRORSCREEN);
\r
1177 screen = grsegs[ERRORSCREEN];
\r
1179 movedata ((unsigned)screen,7+7*160,0xb800,0,17*160);
\r
1186 // build some tables
\r
1190 for (i=0;i<MAPSIZE;i++)
\r
1192 nearmapylookup[i] = &tilemap[0][0]+MAPSIZE*i;
\r
1193 farmapylookup[i] = i*64;
\r
1196 for (i=0;i<PORTTILESHIGH;i++)
\r
1197 uwidthtable[i] = UPDATEWIDE*i;
\r
1199 blockstart = &blockstarts[0];
\r
1200 for (y=0;y<UPDATEHIGH;y++)
\r
1201 for (x=0;x<UPDATEWIDE;x++)
\r
1202 *blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;
\r
1204 updateptr = &update[0];
\r
1212 // HOLDING DOWN 'M' KEY?
\r
1215 if (Keyboard[sc_M])
\r
1220 // draw intro screen stuff
\r
1222 if (!virtualreality)
\r
1226 // load in and lock down some basic chunks
\r
1229 CA_CacheGrChunk(STARTFONT);
\r
1230 MM_SetLock (&grsegs[STARTFONT],true);
\r
1233 BuildTables (); // trig tables
\r
1240 profilehandle = open("SCALERS.TXT", O_CREAT | O_WRONLY | O_TEXT);
\r
1241 for (i=1;i<20;i++)
\r
1244 close(profilehandle);
\r
1248 NewViewSize (viewsize);
\r
1252 // initialize variables
\r
1255 if (!virtualreality)
\r
1258 displayofs = PAGE1START;
\r
1259 bufferofs = PAGE2START;
\r
1261 if (virtualreality)
\r
1264 geninterrupt(0x60);
\r
1268 //===========================================================================
\r
1271 ==========================
\r
1275 ==========================
\r
1278 boolean SetViewSize (unsigned width, unsigned height)
\r
1280 viewwidth = width&~15; // must be divisable by 16
\r
1281 viewheight = height&~1; // must be even
\r
1282 centerx = viewwidth/2-1;
\r
1283 shootdelta = viewwidth/10;
\r
1284 screenofs = ((200-STATUSLINES-viewheight)/2*SCREENWIDTH+(320-viewwidth)/8);
\r
1287 // calculate trace angles and projection constants
\r
1289 CalcProjection (FOCALLENGTH);
\r
1292 // build all needed compiled scalers
\r
1294 // MM_BombOnError (false);
\r
1295 SetupScaling (viewwidth*1.5);
\r
1297 MM_BombOnError (true);
\r
1300 Quit ("Can't build scalers!");
\r
1309 void ShowViewSize (int width)
\r
1311 int oldwidth,oldheight;
\r
1313 oldwidth = viewwidth;
\r
1314 oldheight = viewheight;
\r
1316 viewwidth = width*16;
\r
1317 viewheight = width*16*HEIGHTRATIO;
\r
1318 DrawPlayBorder ();
\r
1320 viewheight = oldheight;
\r
1321 viewwidth = oldwidth;
\r
1325 void NewViewSize (int width)
\r
1330 SetViewSize (width*16,width*16*HEIGHTRATIO);
\r
1336 //===========================================================================
\r
1339 ==========================
\r
1343 ==========================
\r
1346 void Quit (char *error)
\r
1348 unsigned finscreen;
\r
1351 if (virtualreality)
\r
1352 geninterrupt(0x61);
\r
1358 CA_CacheGrChunk (ORDERSCREEN);
\r
1359 screen = grsegs[ORDERSCREEN];
\r
1365 CA_CacheGrChunk (ERRORSCREEN);
\r
1366 screen = grsegs[ERRORSCREEN];
\r
1371 if (error && *error)
\r
1373 movedata ((unsigned)screen,7,0xb800,0,7*160);
\r
1380 if (!error || !(*error))
\r
1384 movedata ((unsigned)screen,7,0xb800,0,4000);
\r
1388 //asm mov dh,23 // row
\r
1389 //asm mov dl,0 // collumn
\r
1397 //===========================================================================
\r
1402 =====================
\r
1406 =====================
\r
1409 static char *ParmStrings[] = {"baby","easy","normal","hard",""};
\r
1411 void DemoLoop (void)
\r
1413 static int LastDemo;
\r
1419 // check for launch from ted
\r
1426 for (i = 1;i < _argc;i++)
\r
1428 if ( (level = US_CheckParm(_argv[i],ParmStrings)) != -1)
\r
1430 gamestate.difficulty=level;
\r
1436 gamestate.episode = tedlevelnum/10;
\r
1437 gamestate.mapon = tedlevelnum%10;
\r
1439 gamestate.episode = 0;
\r
1440 gamestate.mapon = tedlevelnum;
\r
1448 // main game cycle
\r
1452 // nsize = (long)40*1024;
\r
1453 // MM_GetPtr(&nullblock,nsize);
\r
1477 StartCPMusic(INTROSONG);
\r
1497 CA_CacheGrChunk (TITLEPALETTE);
\r
1499 CA_CacheGrChunk (TITLE1PIC);
\r
1500 VWB_DrawPic (0,0,TITLE1PIC);
\r
1501 UNCACHEGRCHUNK (TITLE1PIC);
\r
1503 CA_CacheGrChunk (TITLE2PIC);
\r
1504 VWB_DrawPic (0,80,TITLE2PIC);
\r
1505 UNCACHEGRCHUNK (TITLE2PIC);
\r
1506 VW_UpdateScreen ();
\r
1507 VL_FadeIn(0,255,grsegs[TITLEPALETTE],30);
\r
1509 UNCACHEGRCHUNK (TITLEPALETTE);
\r
1511 CA_CacheScreen (TITLEPIC);
\r
1512 VW_UpdateScreen ();
\r
1515 if (IN_UserInput(TickBase*15))
\r
1521 CA_CacheScreen (CREDITSPIC);
\r
1522 VW_UpdateScreen();
\r
1524 if (IN_UserInput(TickBase*10))
\r
1530 DrawHighScores ();
\r
1531 VW_UpdateScreen ();
\r
1534 if (IN_UserInput(TickBase*10))
\r
1542 PlayDemo (LastDemo++%4);
\r
1547 if (playstate == ex_abort)
\r
1549 StartCPMusic(INTROSONG);
\r
1555 if (Keyboard[sc_Tab] && MS_CheckParm("goobers"))
\r
1557 if (Keyboard[sc_Tab] && MS_CheckParm("debugmode"))
\r
1561 US_ControlPanel (0);
\r
1563 if (startgame || loadedgame)
\r
1567 StartCPMusic(INTROSONG);
\r
1573 //===========================================================================
\r
1577 ==========================
\r
1581 ==========================
\r
1584 char *nosprtxt[] = {"nospr",nil};
\r
1593 // THIS IS FOR BETA ONLY!
\r
1595 struct dosdate_t d;
\r
1598 if (d.year > YEAR ||
\r
1599 (d.month >= MONTH && d.day >= DAY))
\r
1601 printf("Sorry, BETA-TESTING is over. Thanks for you help.\n");
\r
1606 CheckForEpisodes();
\r
1614 Quit("Demo loop exited???");
\r