📄 wl_main.c
字号:
#else
CacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END);
#endif
CA_LoadAllSounds ();
fontnumber=1;
ClearMScreen ();
VWB_DrawPic(112,184,C_MOUSELBACKPIC);
DrawStripes (10);
SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR);
#ifndef SPEAR
DrawWindow (CTL_X-2,CTL_Y-6,280,13*7,BKGDCOLOR);
#else
DrawWindow (CTL_X-2,CTL_Y-26,280,13*10,BKGDCOLOR);
#endif
DrawMenu (&MusicItems,&MusicMenu[start]);
SETFONTCOLOR (READHCOLOR,BKGDCOLOR);
PrintY=15;
WindowX = 0;
WindowY = 320;
US_CPrint ("Robert's Jukebox");
SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR);
VW_UpdateScreen();
MenuFadeIn();
do
{
which = HandleMenu(&MusicItems,&MusicMenu[start],NULL);
if (which>=0)
{
if (lastsong >= 0)
MusicMenu[start+lastsong].active = 1;
StartCPMusic(songs[start + which]);
MusicMenu[start+which].active = 2;
DrawMenu (&MusicItems,&MusicMenu[start]);
VW_UpdateScreen();
lastsong = which;
}
} while(which>=0);
MenuFadeOut();
IN_ClearKeysDown();
#ifdef SPEAR
UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
#else
UnCacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END);
#endif
}
#endif
/*
==========================
=
= InitGame
=
= Load a few things right away
=
==========================
*/
void InitGame (void)
{
int i,x,y;
unsigned *blockstart;
if (MS_CheckParm ("virtual"))
virtualreality = true;
else
virtualreality = false;
MM_Startup (); // so the signon screen can be freed
SignonScreen ();
VW_Startup ();
IN_Startup ();
PM_Startup ();
PM_UnlockMainMem ();
SD_Startup ();
CA_Startup ();
US_Startup ();
#ifndef SPEAR
if (mminfo.mainmem < 235000L)
#else
if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode"))
#endif
{
memptr screen;
CA_CacheGrChunk (ERRORSCREEN);
screen = grsegs[ERRORSCREEN];
ShutdownId();
movedata ((unsigned)screen,7+7*160,0xb800,0,17*160);
gotoxy (1,23);
exit(1);
}
//
// build some tables
//
InitDigiMap ();
for (i=0;i<MAPSIZE;i++)
{
nearmapylookup[i] = &tilemap[0][0]+MAPSIZE*i;
farmapylookup[i] = i*64;
}
for (i=0;i<PORTTILESHIGH;i++)
uwidthtable[i] = UPDATEWIDE*i;
blockstart = &blockstarts[0];
for (y=0;y<UPDATEHIGH;y++)
for (x=0;x<UPDATEWIDE;x++)
*blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;
updateptr = &update[0];
bufferofs = 0;
displayofs = 0;
ReadConfig ();
//
// HOLDING DOWN 'M' KEY?
//
#ifndef SPEARDEMO
if (Keyboard[sc_M])
DoJukebox();
else
#endif
//
// draw intro screen stuff
//
if (!virtualreality)
IntroScreen ();
//
// load in and lock down some basic chunks
//
CA_CacheGrChunk(STARTFONT);
MM_SetLock (&grsegs[STARTFONT],true);
LoadLatchMem ();
BuildTables (); // trig tables
SetupWalls ();
#if 0
{
int temp,i;
temp = viewsize;
profilehandle = open("SCALERS.TXT", O_CREAT | O_WRONLY | O_TEXT);
for (i=1;i<20;i++)
NewViewSize(i);
viewsize = temp;
close(profilehandle);
}
#endif
NewViewSize (viewsize);
//
// initialize variables
//
InitRedShifts ();
if (!virtualreality)
FinishSignon();
displayofs = PAGE1START;
bufferofs = PAGE2START;
if (virtualreality)
{
NoWait = true;
geninterrupt(0x60);
}
}
//===========================================================================
/*
==========================
=
= SetViewSize
=
==========================
*/
boolean SetViewSize (unsigned width, unsigned height)
{
viewwidth = width&~15; // must be divisable by 16
viewheight = height&~1; // must be even
centerx = viewwidth/2-1;
shootdelta = viewwidth/10;
screenofs = ((200-STATUSLINES-viewheight)/2*SCREENWIDTH+(320-viewwidth)/8);
//
// calculate trace angles and projection constants
//
CalcProjection (FOCALLENGTH);
//
// build all needed compiled scalers
//
// MM_BombOnError (false);
SetupScaling (viewwidth*1.5);
#if 0
MM_BombOnError (true);
if (mmerror)
{
Quit ("Can't build scalers!");
mmerror = false;
return false;
}
#endif
return true;
}
void ShowViewSize (int width)
{
int oldwidth,oldheight;
oldwidth = viewwidth;
oldheight = viewheight;
viewwidth = width*16;
viewheight = width*16*HEIGHTRATIO;
DrawPlayBorder ();
viewheight = oldheight;
viewwidth = oldwidth;
}
void NewViewSize (int width)
{
CA_UpLevel ();
MM_SortMem ();
viewsize = width;
SetViewSize (width*16,width*16*HEIGHTRATIO);
CA_DownLevel ();
}
//===========================================================================
/*
==========================
=
= Quit
=
==========================
*/
void Quit (char *error)
{
unsigned finscreen;
memptr screen;
if (virtualreality)
geninterrupt(0x61);
ClearMemory ();
if (!*error)
{
#ifndef JAPAN
CA_CacheGrChunk (ORDERSCREEN);
screen = grsegs[ORDERSCREEN];
#endif
WriteConfig ();
}
else
{
CA_CacheGrChunk (ERRORSCREEN);
screen = grsegs[ERRORSCREEN];
}
ShutdownId ();
if (error && *error)
{
movedata ((unsigned)screen,7,0xb800,0,7*160);
gotoxy (10,4);
puts(error);
gotoxy (1,8);
exit(1);
}
else
if (!error || !(*error))
{
clrscr();
#ifndef JAPAN
movedata ((unsigned)screen,7,0xb800,0,4000);
gotoxy(1,24);
#endif
//asm mov bh,0
//asm mov dh,23 // row
//asm mov dl,0 // collumn
//asm mov ah,2
//asm int 0x10
}
exit(0);
}
//===========================================================================
/*
=====================
=
= DemoLoop
=
=====================
*/
static char *ParmStrings[] = {"baby","easy","normal","hard",""};
void DemoLoop (void)
{
static int LastDemo;
int i,level;
long nsize;
memptr nullblock;
//
// check for launch from ted
//
if (tedlevel)
{
NoWait = true;
NewGame(1,0);
for (i = 1;i < _argc;i++)
{
if ( (level = US_CheckParm(_argv[i],ParmStrings)) != -1)
{
gamestate.difficulty=level;
break;
}
}
#ifndef SPEAR
gamestate.episode = tedlevelnum/10;
gamestate.mapon = tedlevelnum%10;
#else
gamestate.episode = 0;
gamestate.mapon = tedlevelnum;
#endif
GameLoop();
Quit (NULL);
}
//
// main game cycle
//
// nsize = (long)40*1024;
// MM_GetPtr(&nullblock,nsize);
#ifndef DEMOTEST
#ifndef UPLOAD
#ifndef GOODTIMES
#ifndef SPEAR
#ifndef JAPAN
if (!NoWait)
NonShareware();
#endif
#else
#ifndef GOODTIMES
#ifndef SPEARDEMO
CopyProtection();
#endif
#endif
#endif
#endif
#endif
StartCPMusic(INTROSONG);
#ifndef JAPAN
if (!NoWait)
PG13 ();
#endif
#endif
while (1)
{
while (!NoWait)
{
//
// title page
//
MM_SortMem ();
#ifndef DEMOTEST
#ifdef SPEAR
CA_CacheGrChunk (TITLEPALETTE);
CA_CacheGrChunk (TITLE1PIC);
VWB_DrawPic (0,0,TITLE1PIC);
UNCACHEGRCHUNK (TITLE1PIC);
CA_CacheGrChunk (TITLE2PIC);
VWB_DrawPic (0,80,TITLE2PIC);
UNCACHEGRCHUNK (TITLE2PIC);
VW_UpdateScreen ();
VL_FadeIn(0,255,grsegs[TITLEPALETTE],30);
UNCACHEGRCHUNK (TITLEPALETTE);
#else
CA_CacheScreen (TITLEPIC);
VW_UpdateScreen ();
VW_FadeIn();
#endif
if (IN_UserInput(TickBase*15))
break;
VW_FadeOut();
//
// credits page
//
CA_CacheScreen (CREDITSPIC);
VW_UpdateScreen();
VW_FadeIn ();
if (IN_UserInput(TickBase*10))
break;
VW_FadeOut ();
//
// high scores
//
DrawHighScores ();
VW_UpdateScreen ();
VW_FadeIn ();
if (IN_UserInput(TickBase*10))
break;
#endif
//
// demo
//
#ifndef SPEARDEMO
PlayDemo (LastDemo++%4);
#else
PlayDemo (0);
#endif
if (playstate == ex_abort)
break;
StartCPMusic(INTROSONG);
}
VW_FadeOut ();
#ifndef SPEAR
if (Keyboard[sc_Tab] && MS_CheckParm("goobers"))
#else
if (Keyboard[sc_Tab] && MS_CheckParm("debugmode"))
#endif
RecordDemo ();
else
US_ControlPanel (0);
if (startgame || loadedgame)
{
GameLoop ();
VW_FadeOut();
StartCPMusic(INTROSONG);
}
}
}
//===========================================================================
/*
==========================
=
= main
=
==========================
*/
char *nosprtxt[] = {"nospr",nil};
void main (void)
{
int i;
#ifdef BETA
//
// THIS IS FOR BETA ONLY!
//
struct dosdate_t d;
_dos_getdate(&d);
if (d.year > YEAR ||
(d.month >= MONTH && d.day >= DAY))
{
printf("Sorry, BETA-TESTING is over. Thanks for you help.\n");
exit(1);
}
#endif
CheckForEpisodes();
Patch386 ();
InitGame ();
DemoLoop();
Quit("Demo loop exited???");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -