Beispiel #1
0
void PicturePause (void)
{
	id0_int_t	y;
	id0_unsigned_t	source;

	source = displayofs+panadjust;

//	VW_ColorBorder (15);
	VW_SetLineWidth (40);
	VW_SetScreen (0,0);

	if (source<0x10000l-200*64)
	{
	//
	// copy top line first
	//
		for (y=0;y<200;y++)
			VW_ScreenToScreen (source+y*64,y*40,40,1);
	}
	else
	{
	//
	// copy bottom line first
	//
		for (y=199;y>=0;y--)
			VW_ScreenToScreen (source+y*64,y*40,40,1);
	}

	IN_Shutdown ();

	VW_WaitVBL(70);
	BE_ST_BiosScanCode(0);
	VW_WaitVBL(70);
	Quit (NULL);
}
Beispiel #2
0
void UpdatePaletteShifts (void)
{
	int	red,white;

	if (bonuscount)
	{
		white = bonuscount/WHITETICS +1;
		if (white>NUMWHITESHIFTS)
			white = NUMWHITESHIFTS;
		bonuscount -= tics;
		if (bonuscount < 0)
			bonuscount = 0;
	}
	else
		white = 0;


	if (damagecount)
	{
		red = damagecount/10 +1;
		if (red>NUMREDSHIFTS)
			red = NUMREDSHIFTS;

		damagecount -= tics;
		if (damagecount < 0)
			damagecount = 0;
	}
	else
		red = 0;

	if (red)
	{
		VW_WaitVBL(1);
		VL_SetPalette (redshifts[red-1]);
		palshifted = True;
	}
	else if (white)
	{
		VW_WaitVBL(1);
		VL_SetPalette (whiteshifts[white-1]);
		palshifted = True;
	}
	else if (palshifted)
	{
		VW_WaitVBL(1);
		VL_SetPalette (&gamepal);		// back to normal
		palshifted = False;
	}
}
Beispiel #3
0
void FinishPaletteShifts()
{
    if (palshifted) {
        palshifted = false;
        VW_WaitVBL(1);
        VL_SetPalette(0, 256, vgapal);
    }
}
Beispiel #4
0
void UpdatePaletteShifts()
{
    int red = 0;
    int white = 0;

    if (bonuscount > 0) {
        white = (bonuscount / WHITETICS) + 1;

        if (white > NUMWHITESHIFTS)
            white = NUMWHITESHIFTS;

        bonuscount -= tics;

        if (bonuscount < 0)
            bonuscount = 0;
    } else
        white = 0;

    if (damagecount > 0) {
        red = (damagecount / 10) + 1;

        if (red > NUMREDSHIFTS)
            red = NUMREDSHIFTS;

        damagecount -= tics;

        if (damagecount < 0)
            damagecount = 0;
    } else
        red = 0;

    if (red > 0) {
        VW_WaitVBL(1);
        VL_SetPalette(0, 256, redshifts[red - 1], false);
        palshifted = true;
    } else if (white > 0) {
        VW_WaitVBL(1);
        VL_SetPalette(0, 256, whiteshifts[white - 1], false);
        palshifted = true;
    } else if (palshifted) {
        VW_WaitVBL(1);
        VL_SetPalette(0, 256, vgapal, false); // back to normal
        palshifted = false;
    }
}
Beispiel #5
0
void FinishPaletteShifts (void)
{
	if (palshifted)
	{
		palshifted = 0;
		VW_WaitVBL(1);
		VL_SetPalette (&gamepal);
	}
}
Beispiel #6
0
void PicturePause()
{

	FinishPaletteShifts();

	IN_Ack();
	
	if (LastScan != sc_Enter)
	{
		return;
	}

	/* TODO: save picture to file */
	
	VL_SetPalette(gamepal);

	VW_WaitVBL(70);
	VW_WaitVBL(70);
	Quit(NULL);
}
void Quit (const char *errorStr, ...)
{
    char error[256];
    if(errorStr != NULL)
    {
        va_list vlist;
        va_start(vlist, errorStr);
        vsprintf(error, errorStr, vlist);
        va_end(vlist);
    }
    else
        error[0] = 0;

    /* don't try to display the red box before it's loaded */
    if (!pictable)
    {
        ShutdownId();
        if (error && *error)
        {
            puts(error);
            VW_WaitVBL(100);
        }
        exit(1);
    }

    if (!error || !*error)
        WriteConfig ();

    ShutdownId ();

    if (error && *error)
    {
        puts(error);
        VW_WaitVBL(200);
        exit(1);
    }

    exit(0);
}
Beispiel #8
0
void PicturePause()
{

	FinishPaletteShifts();

	IN_Ack();
	
	if (LastScan != sc_Enter)
	{
		return;
	}

	/* TODO: save picture to file */
	if (w0 == true || w1 == true){
		VL_SetPalette(gamepalWL6);
	} else {
		VL_SetPalette(gamepalSOD);
	}

	VW_WaitVBL(70);
	VW_WaitVBL(70);
	Quit(NULL);
}
Beispiel #9
0
void VW_FadeDown(void)
{
	if ((GRMODE != EGAGR) || fakecgamode) // REFKEEN - Patch for 2015 port
		return;
	id0_int_t i;

	for (i=5;i>2;i--)
	{
	  colors[i][16] = bordercolor;
	  BE_ST_EGASetPaletteAndBorder((id0_byte_t *)&colors[i]);
	  VW_WaitVBL(6);
	}
	screenfaded = false;
}
Beispiel #10
0
id0_int_t WaitOrKey (id0_int_t vbls)
{
	while (vbls--)
	{
		IN_ReadControl(0,&c);           // get player input
		if (LastScan || c.button0 || c.button1)
		{
			IN_ClearKeysDown ();
			return 1;
		}
		VW_WaitVBL(1);
	}
	return 0;
}
Beispiel #11
0
void VW_FadeUp(void)
{
#if GRMODE == EGAGR
	id0_int_t i;

	for (i=3;i<6;i++)
	{
	  colors[i][16] = bordercolor;
	  BE_ST_EGASetPaletteAndBorder((id0_byte_t *)&colors[i]);
	  VW_WaitVBL(6);
	}
	screenfaded = true;
#endif
}
Beispiel #12
0
void VW_FadeDown(void)
{
#if GRMODE == EGAGR
	id0_int_t i;

	for (i=5;i>2;i--)
	{
	  colors[i][16] = bordercolor;
	  BE_ST_EGASetPaletteAndBorder((id0_byte_t *)&colors[i]);
	  VW_WaitVBL(6);
	}
	screenfaded = false;
#endif
}
Beispiel #13
0
void	DemoLoop (void)
{

/////////////////////////////////////////////////////////////////////////////
// main game cycle
/////////////////////////////////////////////////////////////////////////////

	displayofs = bufferofs = 0;
	VW_Bar (0,0,320,200,0);
	VW_SetScreen(0,0);

//
// Read in all the graphic images needed for the title sequence
//
		VW_WaitVBL(1);
		IN_ReadControl(0,&control);

//	set EASYMODE
//
	if (BE_Cross_strcasecmp(id0_argv[2], "1") == 0)
		EASYMODEON = true;
	else
		EASYMODEON = false;

// restore game
//
	if (BE_Cross_strcasecmp(id0_argv[3], "1") == 0)
	{
		VW_FadeOut();
		bufferofs = displayofs = 0;
		VW_Bar(0,0,320,200,0);
		if (GE_LoadGame())
		{
			loadedgame = true;
			playstate = ex_loadedgame;
			Keyboard[sc_Enter] = true;
			VW_Bar(0,0,320,200,0);
			ColoredPalette();
		}
		VW_Bar(0,0,320,200,0);
		VW_FadeIn();
	}

	// Play a game
	//
		restartgame = gd_Normal;
		NewGame();
		GameLoop();
}
static void FinishSignon (void)
{
#ifndef SPEAR
    VW_Bar (0,189,300,11,VL_GetPixel(0,0));
    WindowX = 0;
    WindowW = 320;
    PrintY = 190;

#ifndef JAPAN
    SETFONTCOLOR(14,4);

#ifdef SPANISH
    US_CPrint ("Oprima una tecla");
#else
    US_CPrint ("Press a key");
#endif

#endif

    VW_UpdateScreen();

    if (!param_nowait)
        IN_Ack ();

#ifndef JAPAN
    VW_Bar (0,189,300,11,VL_GetPixel(0,0));

    PrintY = 190;
    SETFONTCOLOR(10,4);

#ifdef SPANISH
    US_CPrint ("pensando...");
#else
    US_CPrint ("Working...");
#endif

    VW_UpdateScreen();
#endif

    SETFONTCOLOR(0,15);
#else
    VW_UpdateScreen();

    if (!param_nowait)
        VW_WaitVBL(3*70);
#endif
}
Beispiel #15
0
//--------------------------------------------------------------------------
// ShowQuickInstructions()
//--------------------------------------------------------------------------
void ShowQuickInstructions()
{
	ShowQuickMsg=false;

	if ((demoplayback) || (gamestate.mapon) || (gamestate.flags & GS_QUICKRUN))
		return;

	ThreeDRefresh();
	ThreeDRefresh();
	ClearMemory();
	WindowX=0; WindowY=16; WindowW=320; WindowH=168;
	CacheMessage(QUICK_INFO1_TEXT);
	VW_WaitVBL(120);
	CacheMessage(QUICK_INFO2_TEXT);
	IN_Ack();
	IN_ClearKeysDown();
	CleanDrawPlayBorder();
}
Beispiel #16
0
void VW_SetSplitScreen (id0_int_t linenum)
{
	VW_WaitVBL (1);
	if (videocard==VGAcard)
		linenum=linenum*2-1;
	BE_ST_EGASetSplitScreen(linenum);
#if 0 
	outportb (CRTC_INDEX,CRTC_LINECOMPARE);
	outportb (CRTC_INDEX+1,linenum % 256);
	outportb (CRTC_INDEX,CRTC_OVERFLOW);
	outportb (CRTC_INDEX+1, 1+16*(linenum/256));
	if (videocard==VGAcard)
	{
		outportb (CRTC_INDEX,CRTC_MAXSCANLINE);
		outportb (CRTC_INDEX+1,inportb(CRTC_INDEX+1) & (255-64));
	}
#endif
}
Beispiel #17
0
void PlayLoop (void)
{
	int		give;
	int	helmetangle;

	playstate = ex_stillplaying;
	TimeCount = lasttimecount = 0;
	frameon = 0;
	running = False;
	anglefrac = 0;
	facecount = 0;
	funnyticount = 0;
	memset (buttonstate,0,sizeof(buttonstate));
	ClearPaletteShifts ();

	//if (MousePresent) // PORT
		//Mouse(MDelta);	// Clear accumulated mouse movement

	if (demoplayback)
		IN_StartAck ();

	do
	{
		if (virtualreality)
		{
			//helmetangle = peek (0x40,0xf0); // PORT
			player->angle += helmetangle;
			if (player->angle >= ANGLES)
				player->angle -= ANGLES;
		}


		PollControls();

//
// actor thinking
//
		madenoise = False;

		MoveDoors ();
		MovePWalls ();

		for (obj = player;obj;obj = obj->next)
			DoActor (obj);

		UpdatePaletteShifts ();

		ThreeDRefresh ();

		//
		// MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
		//
		#ifdef SPEAR
		funnyticount += tics;
		if (funnyticount > 30l*70)
		{
			funnyticount = 0;
			StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
			facecount = 0;
		}
		#endif

		gamestate.TimeCount+=tics;

		SD_Poll ();
		UpdateSoundLoc();	// JAB

		if (screenfaded)
			VW_FadeIn ();

		CheckKeys();

//
// debug aids
//
		if (singlestep)
		{
			VW_WaitVBL(14);
			lasttimecount = TimeCount;
		}
		if (extravbls)
			VW_WaitVBL(extravbls);

		if (demoplayback)
		{
			if (IN_CheckAck ())
			{
				IN_ClearKeysDown ();
				playstate = ex_abort;
			}
		}


		if (virtualreality)
		{
			player->angle -= helmetangle;
			if (player->angle < 0)
				player->angle += ANGLES;
		}

	}while (!playstate && !startgame);

	if (playstate != ex_died)
		FinishPaletteShifts ();
}
Beispiel #18
0
void Quit (const char *errorStr, ...)
{
#ifdef NOTYET
    byte *screen;
#endif
    char error[256];
    if(errorStr != NULL)
    {
        va_list vlist;
        va_start(vlist, errorStr);
        vsprintf(error, errorStr, vlist);
        va_end(vlist);
    }
    else error[0] = 0;

    if (!pictable)  // don't try to display the red box before it's loaded
    {
        ShutdownId();
        if (error && *error)
        {
#ifdef NOTYET
            SetTextCursor(0,0);
#endif
            puts(error);
#ifdef NOTYET
            SetTextCursor(0,2);
#endif
            VW_WaitVBL(100);
        }
        exit(1);
    }

    if (!error || !*error)
    {
#ifdef NOTYET
        #ifndef JAPAN
        CA_CacheGrChunk (ORDERSCREEN);
        screen = grsegs[ORDERSCREEN];
        #endif
#endif
        WriteConfig ();
    }
#ifdef NOTYET
    else
    {
        CA_CacheGrChunk (ERRORSCREEN);
        screen = grsegs[ERRORSCREEN];
    }
#endif

    ShutdownId ();

    if (error && *error)
    {
#ifdef NOTYET
        memcpy((byte *)0xb8000,screen+7,7*160);
        SetTextCursor(9,3);
#endif
        puts(error);
#ifdef NOTYET
        SetTextCursor(0,7);
#endif
        VW_WaitVBL(200);
        exit(1);
    }
    else
    if (!error || !(*error))
    {
#ifdef NOTYET
        #ifndef JAPAN
        memcpy((byte *)0xb8000,screen+7,24*160); // 24 for SPEAR/UPLOAD compatibility
        #endif
        SetTextCursor(0,23);
#endif
    }

    exit(0);
}
Beispiel #19
0
void PlayLoop (void)
{
	boolean reset_areas=false;
	objtype *obj;

    lasttimecount = 0;
    TimeCount = 0;
	playstate = ex_stillplaying;

	framecount = frameon = 0;
	pwallstate = anglefrac = 0;
	memset (buttonstate,0,sizeof(buttonstate));
	ClearPaletteShifts ();
   ForceUpdateStatusBar();

    ::in_clear_mouse_deltas();

	tics = 1;			// for first time through
	if (demoplayback)
		IN_StartAck ();

	do
	{
		PollControls();

//
// actor thinking
//
		madenoise = false;

		if (alerted)
			alerted--;

		MoveDoors ();
		MovePWalls ();

		for (obj = player;obj;obj = obj->next)
		{
			if ((obj != player) && (Keyboard[sc_6] || Keyboard[sc_7]) && Keyboard[sc_8] && DebugOk)
			{
				if (!reset_areas)
					memset(areabyplayer,1,sizeof(areabyplayer));
				reset_areas=true;

				if ((((!(obj->flags & FL_INFORMANT)) && (obj->flags & FL_SHOOTABLE))) ||
					 (obj->obclass == liquidobj && !(obj->flags & FL_DEADGUY)))
					DamageActor(obj,1000,player);
			}
			else
				if (reset_areas)
				{
					ConnectAreas();
					reset_areas=false;
				}
			DoActor (obj);
		}

		if (NumEAWalls)
			CheckSpawnEA();

		if ((!GoldsternInfo.GoldSpawned) && GoldsternInfo.SpawnCnt)
			CheckSpawnGoldstern();

		UpdatePaletteShifts ();


		ThreeDRefresh ();

		gamestate.TimeCount+=tics;

		UpdateSoundLoc();	// JAB

		if (screenfaded & !playstate)
			VW_FadeIn();

	// Display first-time instructions.
	//
		if (ShowQuickMsg)
			ShowQuickInstructions();

		CheckKeys();

		if (demoplayback && demoptr == lastdemoptr)
			playstate = ex_title;

//
// debug aids
//
		if (singlestep)
		{
			VW_WaitVBL(14);
			lasttimecount = TimeCount;
		}
		if (extravbls)
			VW_WaitVBL(extravbls);

		if ((demoplayback) && (IN_CheckAck()))
		{
			IN_ClearKeysDown ();
			playstate = ex_abort;
		}


	}while (!playstate && !startgame);

	if (playstate != ex_died)
		FinishPaletteShifts ();

	gamestate.flags &= ~GS_VIRGIN_LEVEL;
}
Beispiel #20
0
void Victory (void)
{
#ifndef SPEARDEMO
	long	sec;
	int i,min,kr,sr,tr,x;
	char tempstr[8];

#define RATIOX	6
#define RATIOY	14
#define TIMEX	14
#define TIMEY	8


#ifdef SPEAR
	StartCPMusic (XTHEEND_MUS);

	CA_CacheGrChunk(BJCOLLAPSE1PIC);
	CA_CacheGrChunk(BJCOLLAPSE2PIC);
	CA_CacheGrChunk(BJCOLLAPSE3PIC);
	CA_CacheGrChunk(BJCOLLAPSE4PIC);

	VWB_Bar(0,0,320,200,VIEWCOLOR);
	VWB_DrawPic (124,44,BJCOLLAPSE1PIC);
	VW_UpdateScreen ();
	VW_FadeIn ();
	VW_WaitVBL(2*70);
	VWB_DrawPic (124,44,BJCOLLAPSE2PIC);
	VW_UpdateScreen ();
	VW_WaitVBL(105);
	VWB_DrawPic (124,44,BJCOLLAPSE3PIC);
	VW_UpdateScreen ();
	VW_WaitVBL(105);
	VWB_DrawPic (124,44,BJCOLLAPSE4PIC);
	VW_UpdateScreen ();
	VW_WaitVBL(3*70);

	UNCACHEGRCHUNK(BJCOLLAPSE1PIC);
	UNCACHEGRCHUNK(BJCOLLAPSE2PIC);
	UNCACHEGRCHUNK(BJCOLLAPSE3PIC);
	UNCACHEGRCHUNK(BJCOLLAPSE4PIC);
	VL_FadeOut (0,255,0,17,17,5);
#endif

	StartCPMusic (URAHERO_MUS);
	ClearSplitVWB ();
	CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);
	CA_CacheGrChunk(STARTFONT);

#ifndef SPEAR
	CA_CacheGrChunk(C_TIMECODEPIC);
#endif


	VWB_Bar (0,0,320,200-STATUSLINES,127);
#ifdef JAPAN
#ifndef JAPDEMO
	CA_CacheGrChunk(C_ENDRATIOSPIC);
	VWB_DrawPic(0,0,C_ENDRATIOSPIC);
	UNCACHEGRCHUNK(C_ENDRATIOSPIC);
#endif
#else
	Write(18,2,STR_YOUWIN);

	Write(TIMEX,TIMEY-2,STR_TOTALTIME);

	Write(12,RATIOY-2,"averages");

	#ifdef SPANISH
	Write(RATIOX+2,  RATIOY,      STR_RATKILL);
	Write(RATIOX+2,  RATIOY+2,  STR_RATSECRET);
	Write(RATIOX+2,  RATIOY+4,STR_RATTREASURE);
	#else
	Write(RATIOX+8,RATIOY,      STR_RATKILL);
	Write(RATIOX+4,RATIOY+2,  STR_RATSECRET);
	Write(RATIOX,  RATIOY+4,STR_RATTREASURE);
	#endif

#endif

#ifndef JAPDEMO
	VWB_DrawPic (8,4,L_BJWINSPIC);
#endif


#ifndef SPEAR
	for (kr = sr = tr = sec = i = 0;i < 8;i++)
#else
	for (kr = sr = tr = sec = i = 0;i < 20;i++)
#endif
	{
		sec += LevelRatios[i].time;
		kr += LevelRatios[i].kill;
		sr += LevelRatios[i].secret;
		tr += LevelRatios[i].treasure;
	}

#ifndef SPEAR
	kr /= 8;
	sr /= 8;
	tr /= 8;
#else
	kr /= 14;
	sr /= 14;
	tr /= 14;
#endif

	min = sec/60;
	sec %= 60;

	if (min > 99)
		min = sec = 99;

	i = TIMEX*8+1;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min/10));
	i += 2*8;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min%10));
	i += 2*8;
	Write(i/8,TIMEY,":");
	i += 1*8;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec/10));
	i += 2*8;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec%10));
	VW_UpdateScreen ();

	itoa(kr,tempstr,10);
	x=RATIOX+24-strlen(tempstr)*2;
	Write(x,RATIOY,tempstr);

	itoa(sr,tempstr,10);
	x=RATIOX+24-strlen(tempstr)*2;
	Write(x,RATIOY+2,tempstr);

	itoa(tr,tempstr,10);
	x=RATIOX+24-strlen(tempstr)*2;
	Write(x,RATIOY+4,tempstr);


#ifndef SPANISH
#ifndef UPLOAD
#ifndef SPEAR
	//
	// TOTAL TIME VERIFICATION CODE
	//
	if (gamestate.difficulty>=gd_medium)
	{
		VWB_DrawPic (30*8,TIMEY*8,C_TIMECODEPIC);
		fontnumber = 0;
		fontcolor = READHCOLOR;
		PrintX = 30*8-3;
		PrintY = TIMEY*8+8;
		PrintX+=4;
		tempstr[0] = (((min/10)^(min%10))^0xa)+'A';
		tempstr[1] = (((sec/10)^(sec%10))^0xa)+'A';
		tempstr[2] = (tempstr[0]^tempstr[1])+'A';
		tempstr[3] = 0;
		US_Print(tempstr);
	}
#endif
#endif
#endif


	fontnumber = 1;

	VW_UpdateScreen ();
	VW_FadeIn ();

	IN_Ack();

	#ifndef SPEAR
	if (Keyboard[sc_P] && MS_CheckParm("goobers"))
		PicturePause();
	#endif

	VW_FadeOut ();

#ifndef SPEAR
	UNCACHEGRCHUNK(C_TIMECODEPIC);
#endif
	UnCacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);

#ifndef SPEAR
	EndText();
#else
	EndSpear();
#endif

#endif // SPEARDEMO
}
int DebugKeys (void)
{
	boolean esc;
	int level,i;

#if DEBUG_KEYS_AVAILABLE
	if (Keyboard[sc_R])
	{
		CenterWindow (12,2);
		if (autofire)
		  US_PrintCentered ("Rapid-Fire OFF");
		else
		  US_PrintCentered ("Rapid-Fire ON");
		VW_UpdateScreen();
		IN_Ack();
		autofire ^= 1;
		return 1;
	}
#endif

#if DEBUG_KEYS_AVAILABLE
	if (Keyboard[sc_A])
	{
		char levelstr[50];
		unsigned org_tile,org_mapon,msgnum;
		boolean newmsg=true,newlevel=false;

		VW_FixRefreshBuffer ();
		CenterWindow (16,3);
		US_Print("\n");
		US_CPrint("Message Test");
		VW_UpdateScreen();

		org_mapon = mapon;
		msgnum = (org_tile = *(mapsegs[0]+farmapylookup[player->tiley]+player->tilex))-NAMESTART;
		while (1)
		{
	// Get outta' here
	//
			if (Keyboard[sc_Escape])
			{
				while (Keyboard[sc_Escape]);
				break;
			}

	// Move to previous message
	//
			if (Keyboard[sc_UpArrow])
			{
				if (msgnum)
				{
					msgnum--;
					newmsg = true;
				}
			}

	// Move to next message
	//
			if (Keyboard[sc_DownArrow])
			{
				if (msgnum < 24)
				{
					msgnum++;
					newmsg = true;
				}
			}

	// Move to previous level
	//
			if (Keyboard[sc_LeftArrow])
			{
				if (mapon)
				{
					MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3);
					mapon--;
					newlevel = true;
				}
			}

	// Move to next level
	//
			if (Keyboard[sc_RightArrow])
			{
				if (mapon < LASTMAP-1)
				{
					MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3);
					mapon++;
					newlevel = true;
				}
			}

	// Load new level text
	//
			if (newlevel)
			{
				CA_CacheGrChunk(LEVEL1TEXT+mapon);
				ScanText();
				newmsg = true;
				newlevel=false;
			}

	// Display new message text
	//
			if (newmsg)
			{
				*(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) = msgnum+NAMESTART;
				DrawText(true);
				strcpy(levelstr,"Level: ");
				itoa(mapon,levelstr+strlen(levelstr),10);
				strcat(levelstr,"  Msg: ");
				itoa(msgnum,levelstr+strlen(levelstr),10);
				DisplaySMsg(levelstr,NULL);
				newmsg = false;

				if (Keyboard[sc_UpArrow] || Keyboard[sc_DownArrow] || Keyboard[sc_LeftArrow] || Keyboard[sc_RightArrow])
					VW_WaitVBL(6);
			}

		}
// Restore game
//
		MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3);
		mapon = org_mapon;
		CA_CacheGrChunk(LEVEL1TEXT+mapon);
		ScanText();
		*(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) = org_tile;
		DrawText(true);
		status_flag = 0;
	}


	if (Keyboard[sc_V])
	{
		displayofs = bufferofs = screenloc[screenpage];
		CenterWindow (16,4);
		US_CPrint("\n"GAMENAME);
		US_CPrint(VERSION);
		US_CPrint(REVISION);
		VW_UpdateScreen();
		IN_Ack ();
	}

#endif
	if (Keyboard[sc_Q])			// Q = Insta-Quit!
		Quit("Insta-Quit!");
#if 0
	if (Keyboard[sc_Z])		// Z = freeze Time
	{
		if (FreezeTime)
		  FreezeTime = 1;		// Allow refresh to dec to zero..
		else
			StopTime();

		IN_Ack();
		return 1;
	}
#endif


//	if (Keyboard[sc_E])
//		FaceDoor((player->x>>16l)+1,(player->y>>16l));
//		FaceAngle(90);

#if 0
	if (Keyboard[sc_B])		// B = border color
	{
		CenterWindow(24,3);
		PrintY+=6;
		US_Print(" Border color (0-15):");
		VW_UpdateScreen();
		esc = !US_LineInput (px,py,str,NULL,true,2,0);
		if (!esc)
		{
			level = atoi (str);
			if (level>=0 && level<=15)
				VW_ColorBorder (level);
		}
		return 1;
	}
#endif


#if 1//DEBUG_KEYS_AVAILABLE
	if (Keyboard[sc_O])
	{
		extern unsigned objectcount,latchmemavail;
		unsigned unused,total;

		CenterWindow (30,13);
		US_Print ("Objects: ");
		US_PrintUnsigned (objectcount);

		US_Print("\n\nTics: ");
		US_PrintUnsigned (tics);
		US_Print("      Real Tics: ");
		US_PrintUnsigned(realtics);

		US_Print ("\n\n    Total Available: ");
		US_PrintUnsigned (mminfo.mainmem/1024);
		US_Print ("k\n        Mem In Use: ");
		unused=MM_UnusedMemory()/1024;
		US_PrintUnsigned (unused);
		US_Print ("k\n Mem After Purge: ");
		total=MM_TotalFree()/1024;
		US_PrintUnsigned (total);
		US_Print ("k (");
		US_PrintUnsigned (total-unused);

		US_Print (")\n\nLatch Mem Free: ");
		US_PrintUnsigned (latchmemavail);
		US_Print ("\n");
		VW_UpdateScreen();
		IN_Ack();
	}

	if (colordelay<1)
	{
		if (Keyboard[26])
		{
			extern unsigned *groundcolor,debug_gnd;

			groundcolor = &debug_gnd;
			debug_gnd += 0x0101;
			if (debug_gnd == 0x1010)
				debug_gnd = 0;
			colordelay = 10;
		}

		if (Keyboard[27])
		{
			extern unsigned *skycolor,debug_sky;

			skycolor = &debug_sky;
			debug_sky += 0x0101;
			if (debug_sky == 0x1010)
				debug_sky = 0;
			colordelay = 10;
		}
	}
	else
		colordelay -= realtics;
#endif


#if 0
	if (Keyboard[sc_C])		// C = count objects
	{
		CountObjects();
		return 1;
	}


	if (Keyboard[sc_D])		// D = start / end demo record
	{
		if (DemoMode == demo_Off)
			StartDemoRecord ();
		else if (DemoMode == demo_Record)
		{
			EndDemoRecord ();
			playstate = ex_completed;
		}
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_E])		// E = quit level
	{
		if (tedlevel)
			TEDDeath();
		playstate = ex_warped;
		gamestate.mapon++;
	}
#endif

#if 0
	if (Keyboard[sc_F])		// F = facing spot
	{
		CenterWindow (12,4);
		US_Print ("X:");
		US_PrintUnsigned (player->x);
		US_Print ("Y:");
		US_PrintUnsigned (player->y);
		US_Print ("A:");
		US_PrintUnsigned (player->angle);
		VW_UpdateScreen();
		IN_Ack();
		return 1;
	}
#endif

	if (Keyboard[sc_G])		// G = god mode
	{
		CenterWindow (12,2);
		if (godmode)
		  US_PrintCentered ("God mode OFF");
		else
		  US_PrintCentered ("God mode ON");
		VW_UpdateScreen();
		IN_Ack();
		godmode ^= 1;
		return 1;
	}

#if 0
	if (Keyboard[sc_H])		// H = hurt self
	{
		TakeDamage (5);
	}
#endif

	if (Keyboard[sc_I])			// I = item cheat
	{
		extern boolean redraw_gems;

		CenterWindow (12,3);
		US_PrintCentered ("Free items!");
		VW_UpdateScreen();
		for (i=0;i<4;i++)
		{
			GiveBolt ();
			GiveNuke ();
			GivePotion ();
//			if (!gamestate.keys[i])
				GiveKey (i);
			gamestate.gems[i] = GEM_DELAY_TIME;
		}
		gamestate.gems[4] = GEM_DELAY_TIME;
		redraw_gems = true;
/////////		for (i=0;i<8;i++)
/////////			GiveScroll (i,false);

		IN_Ack ();
		return 1;
	}

#if DEBUG_OVERHEAD
	if (Keyboard[sc_Z])			// O is used elsewhere...
	{
		ViewMap();
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_P])			// P = pause with no screen disruptioon
	{
		PicturePause ();
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_S])	// S = slow motion
	{
		singlestep^=1;
		CenterWindow (18,3);
		if (singlestep)
			US_PrintCentered ("Slow motion ON");
		else
			US_PrintCentered ("Slow motion OFF");
		VW_UpdateScreen();
		IN_Ack ();
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_V])			// V = extra VBLs
	{
		CenterWindow(30,3);
		PrintY+=6;
		US_Print("  Add how many extra VBLs(0-8):");
		VW_UpdateScreen();
		esc = !US_LineInput (px,py,str,NULL,true,2,0);
		if (!esc)
		{
			level = atoi (str);
			if (level>=0 && level<=8)
				extravbls = level;
		}
		return 1;
	}
#endif

	if (Keyboard[sc_W])	// W = warp to level
	{
		CenterWindow(26,3);
		PrintY+=6;
		US_Print("  Warp to which level(0-17):");
		VW_UpdateScreen();
		esc = !US_LineInput (px,py,str,NULL,true,2,0);
		if (!esc)
		{
			level = atoi (str);
			if (level>=0 && level<=LASTMAP-1)
			{
				gamestate.mapon = level;
				playstate = ex_warped;
				lasttext = -1;
			}
		}
		return 1;
	}

#if 0
	if (Keyboard[sc_X])			// X = item cheat
	{
		CenterWindow (12,3);
		US_PrintCentered ("Extra stuff!");
		VW_UpdateScreen();
		for (i=0;i<4;i++)
		{
			GiveBolt ();
			GiveNuke ();
			GivePotion ();
		}
		IN_Ack ();
		return 1;
	}
#endif

////////	if (LastScan >= sc_1 && LastScan <= sc_8)	// free scrolls
////////	{
////////		GiveScroll (LastScan-sc_1,false);
////////		IN_ClearKeysDown ();
////////	}

	return 0;
}
Beispiel #22
0
void PlayLoop (void)
{
	id0_int_t		give;

	void (*think)(struct objstruct *); // REFKEEN: C++ patch

	ingame = true;
	SD_SetTimeCount(0);
	playstate = (exittype)0;
	//playstate = TimeCount = 0;
	gamestate.shotpower = handheight = 0;
	pointcount = pointsleft = 0;

	DrawLevelNumber (gamestate.mapon);
	DrawBars ();

#ifndef PROFILE
	fizzlein = true;				// fizzle fade in the first refresh
#endif
	/*TimeCount = */lasttimecount = lastnuke = 0;

	PollControls ();				// center mouse
	StartMusic ();
	do
	{
#ifndef PROFILE
		PollControls();
#else
		c.xaxis = 1;
//		if (++TimeCount == 300)
//			return;
		SD_SetTimeCount(SD_GetTimeCount()+1);
		if (SD_GetTimeCount() == 300)
			return;
#endif

		for (obj = player;obj;obj = obj->next)
			if (obj->active)
			{
				if (obj->ticcount)
				{
					obj->ticcount-=tics;
					while ( obj->ticcount <= 0)
					{
						think = obj->state->thinkptr;
						if (think)
						{
							think (obj);
							if (!obj->state)
							{
								RemoveObj (obj);
								goto nextactor;
							}
						}

						obj->state = obj->state->next;
						if (!obj->state)
						{
							RemoveObj (obj);
							goto nextactor;
						}
						if (!obj->state->tictime)
						{
							obj->ticcount = 0;
							goto nextactor;
						}
						if (obj->state->tictime>0)
							obj->ticcount += obj->state->tictime;
					}
				}
				think =	obj->state->thinkptr;
				if (think)
				{
					think (obj);
					if (!obj->state)
						RemoveObj (obj);
				}
nextactor:;
			}


		if (bordertime)
		{
			bordertime -= tics;
			if (bordertime<=0)
			{
				bordertime = 0;
				VW_ColorBorder (3);
			}
		}

		if (pointcount)
		{
			pointcount -= tics;
			if (pointcount <= 0)
			{
				pointcount += POINTTICS;
				give = (pointsleft > 1000)? 1000 :
						(
							(pointsleft > 100)? 100 :
								((pointsleft < 20)? pointsleft : 20)
						);
				SD_PlaySound (GETPOINTSSND);
				AddPoints (give);
				pointsleft -= give;
				if (!pointsleft)
					pointcount = 0;
			}
		}

		ThreeDRefresh ();

		CheckKeys();
		// (REFKEEN) SPECIAL - Without this the game
		// can run very fast, even if it's not noticeable
		// (a lot of PlayLoop iterations and consumed CPU power)
		//
		// Notes:
		// 1. Should NOT be called from ThreeDRefresh/CalcTics,
		// because we don't always want that to be done
		// (e.g., FizzleFade effect right after loading C4 saved game).
		// 2. SHOULD be called AFTER CheckKeys. That function resets
		// lasttimecount (just like CalcTics) if the debug key modifier
		// (F10 in Cat. 3-D/Abyss, Backspace in Armageddon/Apocalypse)
		// is held. As a consequence, if the wait is done before the
		// call to CheckKeys then the game may seem to get stuck while
		// the debug key modifier is held.
		BE_ST_TimeCountWaitFromSrc(SD_GetTimeCount(), 1);
		//
		if (singlestep)
		{
			VW_WaitVBL(14);
			lasttimecount = SD_GetTimeCount();
		}
		if (extravbls)
			VW_WaitVBL(extravbls);

	}while (!playstate);
	StopMusic ();

	ingame = false;
	if (bordertime)
	{
		bordertime = 0;
		VW_ColorBorder (3);
	}

	if (!abortgame)
		AddPoints (pointsleft);
	else
		abortgame = false;
}
Beispiel #23
0
id0_int_t DebugKeys (void)
{
	id0_boolean_t esc;
	id0_int_t level,i;

#if 0
	if (Keyboard[sc_A])
	{
		id0_char_t levelstr[50];
		id0_unsigned_t org_tile,org_mapon,msgnum;
		id0_boolean_t newmsg=true,newlevel=false;

		VW_FixRefreshBuffer ();
		CenterWindow (16,3);
		US_Print("\n");
		US_CPrint("Message Test");
		VW_UpdateScreen();

		org_mapon = mapon;
		msgnum = (org_tile = *(mapsegs[0]+farmapylookup[player->tiley]+player->tilex))-NAMESTART;
		while (1)
		{
	// Get outta' here
	//
			if (Keyboard[sc_Escape])
			{
				while (Keyboard[sc_Escape])
				{
					BE_ST_ShortSleep();
				}
				break;
			}

	// Move to previous message
	//
			if (Keyboard[sc_UpArrow])
			{
				if (msgnum)
				{
					msgnum--;
					newmsg = true;
				}
			}

	// Move to next message
	//
			if (Keyboard[sc_DownArrow])
			{
				if (msgnum < 24)
				{
					msgnum++;
					newmsg = true;
				}
			}

	// Move to previous level
	//
			if (Keyboard[sc_LeftArrow])
			{
				if (mapon)
				{
					MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3);
					mapon--;
					newlevel = true;
				}
			}

	// Move to next level
	//
			if (Keyboard[sc_RightArrow])
			{
				if (mapon < LASTMAP-2)
				{
					MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3);
					mapon++;
					newlevel = true;
				}
			}

	// Load new level text
	//
			if (newlevel)
			{
				CA_CacheGrChunk(LEVEL1TEXT+mapon);
				ScanText();
				newmsg = true;
				newlevel=false;
			}

	// Display new message text
	//
			if (newmsg)
			{
				*(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) = msgnum+NAMESTART;
				DrawText(true);
				strcpy(levelstr,"Level: ");
				itoa(mapon,levelstr+strlen(levelstr),10);
				strcat(levelstr,"  Msg: ");
				itoa(msgnum,levelstr+strlen(levelstr),10);
				DisplaySMsg(levelstr,NULL);
				newmsg = false;

				if (Keyboard[sc_UpArrow] || Keyboard[sc_DownArrow] || Keyboard[sc_LeftArrow] || Keyboard[sc_RightArrow])
					VW_WaitVBL(6);
			}

			BE_ST_ShortSleep();
		}
// Restore game
//
		MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3);
		mapon = org_mapon;
		CA_CacheGrChunk(LEVEL1TEXT+mapon);
		ScanText();
		*(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) = org_tile;
		DrawText(true);
		status_flag = 0;
	}
#endif

	if (Keyboard[sc_T])
	{
		VW_FixRefreshBuffer ();
		CenterWindow (16,4);

		US_Print("Tics      :");
		US_PrintUnsigned (tics);
		US_Print("\nReal Tics :");
		US_PrintUnsigned(realtics);
		VW_UpdateScreen();
		IN_Ack ();
	}

	if (Keyboard[sc_V])
	{
		displayofs = bufferofs = screenloc[screenpage];
		CenterWindow (20,5);
		US_CPrint(refkeen_compat_gelib_c4_debug_str_with_gamename);
		//US_CPrint("\n"GAMENAME);
		US_CPrint(VERSION);
		US_CPrint(REVISION);
		VW_UpdateScreen();
		IN_Ack ();
	}

	if (Keyboard[sc_Q])			// Q = Insta-Quit!
		Quit("Insta-Quit!");

	if (Keyboard[sc_Z])		// Z = freeze Time
	{
		if (FreezeTime)
		  FreezeTime = 1;		// Allow refresh to dec to zero..
		else
			StopTime();

		IN_Ack();
		return 1;
	}

//	if (Keyboard[sc_E])
//		FaceDoor((player->x>>16l)+1,(player->y>>16l));
//		FaceAngle(90);

#if 0
	if (Keyboard[sc_B])		// B = border color
	{
		CenterWindow(24,3);
		PrintY+=6;
		US_Print(" Border color (0-15):");
		VW_UpdateScreen();
		esc = !US_LineInput (px,py,str,NULL,true,2,0);
		if (!esc)
		{
			level = atoi (str);
			if (level>=0 && level<=15)
				VW_ColorBorder (level);
		}
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_C])		// C = count objects
	{
		CountObjects();
		return 1;
	}


	if (Keyboard[sc_D])		// D = start / end demo record
	{
		if (DemoMode == demo_Off)
			StartDemoRecord ();
		else if (DemoMode == demo_Record)
		{
			EndDemoRecord ();
			playstate = ex_completed;
		}
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_E])		// E = quit level
	{
		if (tedlevel)
			TEDDeath();
		playstate = ex_warped;
		gamestate.mapon++;
	}
#endif

#if 0
	if (Keyboard[sc_F])		// F = facing spot
	{
		CenterWindow (12,4);
		US_Print ("X:");
		US_PrintUnsigned (player->x);
		US_Print ("Y:");
		US_PrintUnsigned (player->y);
		US_Print ("A:");
		US_PrintUnsigned (player->angle);
		VW_UpdateScreen();
		IN_Ack();
		return 1;
	}
#endif

	if (Keyboard[sc_G])		// G = god mode
	{
		CenterWindow (12,2);
		if (godmode)
		  US_PrintCentered ("God mode OFF");
		else
		  US_PrintCentered ("God mode ON");
		VW_UpdateScreen();
		IN_Ack();
		godmode ^= 1;
		return 1;
	}

#if 0
	if (Keyboard[sc_H])		// H = hurt self
	{
		TakeDamage (5);
	}
#endif

	if (Keyboard[sc_I])			// I = item cheat
	{
		extern id0_boolean_t redraw_gems;

		CenterWindow (12,3);
		US_PrintCentered ("Free items!");
		VW_UpdateScreen();
		for (i=0;i<4;i++)
		{
			GiveBolt ();
			GiveNuke ();
			GivePotion ();
//			if (!gamestate.keys[i])
				GiveKey (i);
			gamestate.gems[i] = GEM_DELAY_TIME;
		}
		gamestate.gems[4] = GEM_DELAY_TIME;
		redraw_gems = true;
		for (i=0;i<8;i++)
			GiveScroll (i,false);

		IN_Ack ();
		return 1;
	}

	if (Keyboard[sc_M])			// M = memory info
	{
		DebugMemory();
		return 1;
	}

#if DEBUG_OVERHEAD
	if (Keyboard[sc_O])			// O = overhead
	{
		ViewMap();
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_P])			// P = pause with no screen disruptioon
	{
		PicturePause ();
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_S])	// S = slow motion
	{
		singlestep^=1;
		CenterWindow (18,3);
		if (singlestep)
			US_PrintCentered ("Slow motion ON");
		else
			US_PrintCentered ("Slow motion OFF");
		VW_UpdateScreen();
		IN_Ack ();
		return 1;
	}
#endif

#if 0
	if (Keyboard[sc_V])			// V = extra VBLs
	{
		CenterWindow(30,3);
		PrintY+=6;
		US_Print("  Add how many extra VBLs(0-8):");
		VW_UpdateScreen();
		esc = !US_LineInput (px,py,str,NULL,true,2,0);
		if (!esc)
		{
			level = atoi (str);
			if (level>=0 && level<=8)
				extravbls = level;
		}
		return 1;
	}
#endif

	if (Keyboard[sc_W])	// W = warp to level
	{
		CenterWindow(26,3);
		PrintY+=6;
		US_Print("  Warp to which level(0-18):");
		VW_UpdateScreen();
		esc = !US_LineInput (px,py,str,NULL,true,2,0);
		if (!esc)
		{
			level = atoi (str);
			if (level>=0 && level<=LASTMAP-1)
			{
				gamestate.mapon = level;
				playstate = ex_warped;
				lasttext = -1;
			}
		}
		return 1;
	}

#if 0
	if (Keyboard[sc_X])			// X = item cheat
	{
		CenterWindow (12,3);
		US_PrintCentered ("Extra stuff!");
		VW_UpdateScreen();
		for (i=0;i<4;i++)
		{
			GiveBolt ();
			GiveNuke ();
			GivePotion ();
		}
		IN_Ack ();
		return 1;
	}
#endif

	if (LastScan >= sc_1 && LastScan <= sc_8)	// free scrolls
	{
		GiveScroll (LastScan-sc_1,false);
		IN_ClearKeysDown ();
	}

	return 0;
}
Beispiel #24
0
void PlayLoop (void)
{
#if defined(USE_FEATUREFLAGS) && defined(USE_CLOUDSKY)
    if(GetFeatureFlags() & FF_CLOUDSKY)
        InitSky();
#endif

#ifdef USE_SHADING
    InitLevelShadeTable();
#endif

    playstate = ex_stillplaying;
    lasttimecount = GetTimeCount();
    frameon = 0;
    anglefrac = 0;
    facecount = 0;
    funnyticount = 0;
    memset (buttonstate, 0, sizeof (buttonstate));
    ClearPaletteShifts ();

    if (MousePresent && IN_IsInputGrabbed())
        IN_CenterMouse();         // Clear accumulated mouse movement

    if (demoplayback)
        IN_StartAck ();

    do
    {
        PollControls ();

//
// actor thinking
//
        madenoise = false;

        MoveDoors ();
        MovePWalls ();

        for (obj = player; obj; obj = obj->next)
            DoActor (obj);

        UpdatePaletteShifts ();

        ThreeDRefresh ();

        //
        // MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
        //
#ifdef SPEAR
        funnyticount += tics;
        if (funnyticount > 30l * 70)
        {
            funnyticount = 0;
            if(viewsize != 21)
                StatusDrawFace(BJWAITING1PIC + (US_RndT () & 1));
            facecount = 0;
        }
#endif

        gamestate.TimeCount += tics;

        UpdateSoundLoc ();      // JAB
        if (screenfaded)
            VW_FadeIn ();

        CheckKeys ();

//
// debug aids
//
        if (singlestep)
        {
            VW_WaitVBL (singlestep);
            lasttimecount = GetTimeCount();
        }
        if (extravbls)
            VW_WaitVBL (extravbls);

        if (demoplayback)
        {
            if (IN_CheckAck ())
            {
                IN_ClearKeysDown ();
                playstate = ex_abort;
            }
        }
    }
    while (!playstate && !startgame);

    if (playstate != ex_died)
        FinishPaletteShifts ();
}
Beispiel #25
0
void CheckKeys (void)
{
	//extern id0_boolean_t autofire;

	if (screenfaded)			// don't do anything with a faded screen
		return;

#if 0
//
// pause key wierdness can't be checked as a scan code
//
	if (Paused)
	{
		CenterWindow (8,3);
		US_PrintCentered ("PAUSED");
		VW_UpdateScreen ();
//		SD_MusicOff();
		IN_Ack();
//		SD_MusicOn();
		Paused = false;
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
	}
	else
	if (Keyboard[sc_Enter])			// P = pause with no screen disruptioon
	{
//		SD_MusicOff();
		DisplaySMsg("PAUSED",NULL);
		IN_Ack();
//		SD_MusicOn();
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
	}
	else
	if (Keyboard[sc_S])
	{
		id0_char_t *Text[] = {{"Slow Mode ON"},{"Slow Mode OFF"}};

		SlowMode ^= 1;
		extravbls = SlowMode << 3;
		CenterWindow (8,3);
		US_PrintCentered (Text[SlowMode]);
		VW_UpdateScreen ();
//		SD_MusicOff();
		IN_Ack();
//		SD_MusicOn();
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
	}
#endif


// F2 - SOUND OPTIONS
//
	if (Keyboard[sc_F2])
	{
		id0_int_t height=7;
		id0_boolean_t ChoiceMade = false;

		if (AdLibPresent)
			height++;

		VW_FixRefreshBuffer();
		CenterWindow(22,height);
		US_Print( "\n        1 )  NO SOUND \n");
		US_Print(   "        2 )  PC  AUDIO \n");

		if (AdLibPresent)
			US_Print("        3 ) ADLIB AUDIO\n");

		US_Print( "\n       ESC)    EXIT    ");
		VW_UpdateScreen();

		// REFKEEN - Alternative controllers support
		extern BE_ST_ControllerMapping g_ingame_altcontrol_mapping_soundoptions;
		g_ingame_altcontrol_mapping_soundoptions.buttons[BE_ST_CTRL_BUT_X].mapClass = AdLibPresent ? BE_ST_CTRL_MAP_KEYSCANCODE : BE_ST_CTRL_MAP_NONE; // A bit of patching
		BE_ST_AltControlScheme_Push();
		BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_soundoptions);

		// Switch audio device ON/OFF & load sounds if there
		// was a change in the device.

		do {

			if (Keyboard[1]) 								// ESC - Exit
				ChoiceMade = true;
			else
			if (Keyboard[2]) 							 	// 1 - No Sound
			{
				SD_SetSoundMode(sdm_Off);
				ChoiceMade = true;
			}
			else
			if (Keyboard[3])  							// 2 - PC Audio
			{
				SD_SetSoundMode(sdm_PC);
//				if (oldsoundmode != sdm_PC)
					CA_LoadAllSounds();
				ChoiceMade = true;
			}
			else
			if ((Keyboard[4]) &&	AdLibPresent)		// 3 - AdLib Audio
			{
				SD_SetSoundMode(sdm_AdLib);
//				if (oldsoundmode != sdm_AdLib)
					CA_LoadAllSounds();
				ChoiceMade = true;
			}

			BE_ST_ShortSleep();

		} while (!ChoiceMade);

		// REFKEEN - Alternative controllers support
		BE_ST_AltControlScheme_Pop();

		tics = realtics = 1;
		IN_ClearKeysDown();
	}

// F5 - CALIBRATE JOYSTICK
//
	if (Keyboard[sc_F5])
	{
		CalibrateJoystick(0);
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

deadloop:;
// ESCAPE - quits game
//
	if ((Keyboard[sc_Escape]) || (Flags & FL_DEAD))
	{
		id0_char_t ch;

		DisplaySMsg("Options", NULL);
		status_flag = S_NONE;


		if (Flags & FL_DEAD)
		{
			id0_char_t choices[] = {sc_Escape,sc_R,sc_N,sc_Q,0};
			ch = DisplayMsg("Restore          New          Quit",choices);
		}
		else
		{
			id0_char_t choices[] = {sc_Escape,sc_S,sc_R,sc_N,sc_Q,0};
			ch = DisplayMsg("Save       Restore       New       Quit",choices);
		}
		DrawText(true);

		switch (ch)
		{
			case sc_S:
				if (!(Flags & FL_DEAD))
					Keyboard[sc_F3] = true;
			break;

			case sc_R:
				Keyboard[sc_F4] = true;
			break;

			case sc_N:
				DisplaySMsg("Starting anew", NULL);
				VW_WaitVBL(60);
				playstate = ex_resetgame;
				Flags &= ~FL_DEAD;
			break;

			case sc_Q:
				// REFKEEN - Alternative controllers support
				{
					extern BE_ST_ControllerMapping g_ingame_altcontrol_mapping_inackback;
					BE_ST_AltControlScheme_Push();
					BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_inackback);
					// REFKEEN - We don't pop this since we quit...
				}
				DisplaySMsg("FARE THEE WELL!", NULL);
				VW_WaitVBL(120);
				if (!Flags & FL_QUICK)
					VW_FadeOut();
				NormalScreen();
				FreeUpMemory();
				Quit(NULL);
			break;
		}
		tics = realtics = 1;
	}

// F1 - DISPLAY HELP
//
	if (Keyboard[sc_F1])
	{
		PrintHelp();

#ifdef TEXT_PRESENTER

		extern PresenterInfo MainHelpText;

		VW_FadeOut();

		FreeUpMemory();
		if (!LoadPresenterScript("HELP.TXT",&MainHelpText))
		{
			VW_FadeIn();
			CenterWindow(30,5);
			US_CPrint("\nError loading HELP file.\n");
			US_CPrint("Press any key.");
			IN_Ack();
			VW_FadeOut();
		}
		else
		{
			VW_SetSplitScreen(200);
			bufferofs = displayofs = screenloc[0];
			VW_Bar(0,0,320,200,0);

			Display640();
			Presenter(&MainHelpText);
			Display320();
		}
		FreePresenterScript(&MainHelpText);
#endif
		VW_SetSplitScreen(120);
		VW_SetScreen(screenloc[0],0);
		screenpage = 0;
		CacheScaleds();

		bufferofs = 0;
		RedrawStatusWindow();
		ThreeDRefresh();
		VW_FadeIn();
		Keyboard[sc_F1] = false;
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

// F3 - SAVE GAME
//
	if ((Keyboard[sc_F3]) && (!(Flags & FL_DEAD)))
	{
		PreFullDisplay();
		GE_SaveGame();
		PostFullDisplay(true);
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

// F4 - LOAD GAME
//
	if (Keyboard[sc_F4])
	{
		PreFullDisplay();
		if (GE_LoadGame())
		{
			loadedgame = true;
			playstate = ex_loadedgame;
			Flags &= ~FL_DEAD;
			lasttext = -1;
			PostFullDisplay(false);
		}
		else
		if (playstate == ex_victorious)
		{
			PostFullDisplay(false);
			Victory(false);
			IN_Ack();
//			gamestate.mapon++;
		}
		else
			PostFullDisplay(true);
		Keyboard[sc_F5] = false;
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

	if (Flags & FL_DEAD)
		goto deadloop;

//
// F10-? debug keys
//
	if (Keyboard[sc_BackSpace])
	{
		DebugKeys();
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
		lasttimecount = SD_GetTimeCount();
	}
}
Beispiel #26
0
void Victory()
{
#ifndef SPEARDEMO
	long	sec;
	int i,min,kr,sr,tr,x;
	char tempstr[8];

#define RATIOX	6
#define RATIOY	14
#define TIMEX	14
#define TIMEY	8


#ifdef SPEAR
	StartCPMusic(XTHEEND_MUS);

	CA_CacheGrChunk(BJCOLLAPSE1PIC);
	CA_CacheGrChunk(BJCOLLAPSE2PIC);
	CA_CacheGrChunk(BJCOLLAPSE3PIC);
	CA_CacheGrChunk(BJCOLLAPSE4PIC);

	VW_Bar(0,0,320,200,VIEWCOLOR);
	VWB_DrawPic (124,44,BJCOLLAPSE1PIC);
	VW_UpdateScreen ();
	VW_FadeIn ();
	VW_WaitVBL(2*70);
	VWB_DrawPic (124,44,BJCOLLAPSE2PIC);
	VW_UpdateScreen ();
	VW_WaitVBL(105);
	VWB_DrawPic (124,44,BJCOLLAPSE3PIC);
	VW_UpdateScreen ();
	VW_WaitVBL(105);
	VWB_DrawPic (124,44,BJCOLLAPSE4PIC);
	VW_UpdateScreen ();
	VW_WaitVBL(3*70);

	CA_UnCacheGrChunk(BJCOLLAPSE1PIC);
	CA_UnCacheGrChunk(BJCOLLAPSE2PIC);
	CA_UnCacheGrChunk(BJCOLLAPSE3PIC);
	CA_UnCacheGrChunk(BJCOLLAPSE4PIC);
	VL_FadeOut (0,255,0,17,17,5);
#endif

	StartCPMusic (URAHERO_MUS);
	ClearSplitVWB ();
	CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);
	CA_CacheGrChunk(STARTFONT);

	VW_Bar (0,0,320,200-STATUSLINES,127);

	Write(18,2,STR_YOUWIN);

	Write(TIMEX,TIMEY-2,STR_TOTALTIME);

	Write(12,RATIOY-2,"averages");

	Write(RATIOX+8,RATIOY,      STR_RATKILL);
	Write(RATIOX+4,RATIOY+2,  STR_RATSECRET);
	Write(RATIOX,  RATIOY+4,STR_RATTREASURE);

	VWB_DrawPic (8,4,L_BJWINSPIC);

#ifndef SPEAR
	for (kr = sr = tr = sec = i = 0;i < 8;i++)
#else
	for (kr = sr = tr = sec = i = 0;i < 20;i++)
#endif
	{
		sec += LevelRatios[i].time;
		kr += LevelRatios[i].kill;
		sr += LevelRatios[i].secret;
		tr += LevelRatios[i].treasure;
	}

#ifndef SPEAR
	kr /= 8;
	sr /= 8;
	tr /= 8;
#else
	kr /= 14;
	sr /= 14;
	tr /= 14;
#endif

	min = sec/60;
	sec %= 60;

	if (min > 99)
		min = sec = 99;

	i = TIMEX*8+1;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min/10));
	i += 2*8;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min%10));
	i += 2*8;
	Write(i/8,TIMEY,":");
	i += 1*8;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec/10));
	i += 2*8;
	VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec%10));
	VW_UpdateScreen ();

	itoa(kr,tempstr,10);
	x=RATIOX+24-strlen(tempstr)*2;
	Write(x,RATIOY,tempstr);

	itoa(sr,tempstr,10);
	x=RATIOX+24-strlen(tempstr)*2;
	Write(x,RATIOY+2,tempstr);

	itoa(tr,tempstr,10);
	x=RATIOX+24-strlen(tempstr)*2;
	Write(x,RATIOY+4,tempstr);

	fontnumber = 1;

	VW_UpdateScreen ();
	VW_FadeIn ();

	IN_Ack();

	#ifndef SPEAR
	if (IN_KeyDown(sc_P) && MS_CheckParm("debugmode"))
		PicturePause();
	#endif

	VW_FadeOut ();

	UnCacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);

#ifndef SPEAR
	EndText();
#else
	EndSpear();
#endif

#endif /* SPEARDEMO */
}