Ejemplo n.º 1
0
void Quit (const id0_char_t *error, ...)
{
	id0_short_t exit_code=0;
	void *finscreen;
	//id0_unsigned_t	finscreen;

	va_list ap;

	va_start(ap,error);

	if (!error)
	{
		CA_SetAllPurge ();
		if (!refkeen_compat_c4_main_def_catalog)
		{
			CA_CacheGrChunk (PIRACY);
			finscreen = grsegs[PIRACY];
			//finscreen = (id0_unsigned_t)grsegs[PIRACY];
		}
	}
	ShutdownId ();

	if (error && *error)
	{
		BE_ST_vprintf(error,ap);
		exit_code = 1;
	}

	else if (!refkeen_compat_c4_main_def_catalog)
	{
		if ((refkeen_current_gamever == BE_GAMEVER_CATABYSS124) || !NoWait)
		{
			memcpy(BE_ST_GetTextModeMemoryPtr(), finscreen, 4000);
			BE_ST_MarkGfxForUpdate();
			//movedata (finscreen,0,0xb800,0,4000);
			if (refkeen_current_gamever == BE_GAMEVER_CATABYSS124)
			{
				if (BE_ST_KbHit())
				{
					while (BE_ST_KbHit())
						BE_ST_BiosScanCode(0);
				}
			}
			BE_ST_BiosScanCode(0);
		}
	}

	va_end(ap);

	if (!refkeen_compat_c4_main_def_catalog)
	{
		if (!error)
		{

			id0_argc = 2;
			id0_argv[1] = "LAST.SHL";
			id0_argv[2] = "ENDSCN.SCN";
			id0_argv[3] = NULL;
	#if 0
			if (execv("LOADSCN.EXE", id0_argv) == -1)
			{
				BE_ST_clrscr();
				BE_ST_puts("Couldn't find executable LOADSCN.EXE.\n");
				BE_ST_HandleExit(1);
			}
	#endif
			void loadscn_exe_main(void);
			BE_Cross_Bexecv(loadscn_exe_main, id0_argv, NULL, false);
		}
	}

	BE_ST_HandleExit(exit_code);
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
static void CAL_SetupGrFile()
{
	char fname[13];
	int handle;
	byte *grtemp;
	int i;

/* load vgadict.ext (huffman dictionary for graphics files) */
	strcpy(fname, gdictname);
	strcat(fname, extension);

	handle = OpenRead(fname);
	if (handle == -1)
		CA_CannotOpen(fname);

	for (i = 0; i < 256; i++) {
		grhuffman[i].bit0 = ReadInt16(handle);
		grhuffman[i].bit1 = ReadInt16(handle);
	}
	
	CloseRead(handle);
	
/* load the data offsets from vgahead.ext */
	if (w0 == true){
		MM_GetPtr((memptr)&grstarts, (NUMCHUNKSWL1+1)*4);
		MM_GetPtr((memptr)&grtemp, (NUMCHUNKSWL1+1)*3);
	}else if (w1 == true){
		MM_GetPtr((memptr)&grstarts, (NUMCHUNKSWL6+1)*4);
		MM_GetPtr((memptr)&grtemp, (NUMCHUNKSWL6+1)*3);
	}else if (s0 == true){
		MM_GetPtr((memptr)&grstarts, (NUMCHUNKSSDM+1)*4);
		MM_GetPtr((memptr)&grtemp, (NUMCHUNKSSDM+1)*3);
	}else{
		MM_GetPtr((memptr)&grstarts, (NUMCHUNKSSOD+1)*4);
		MM_GetPtr((memptr)&grtemp, (NUMCHUNKSSOD+1)*3);
	}
	
	strcpy(fname, gheadname);
	strcat(fname, extension);

	handle = OpenRead(fname);
	if (handle == -1)
		CA_CannotOpen(fname);
	if (w0 == true){
		ReadBytes(handle, grtemp, (NUMCHUNKSWL1+1)*3);
	
		for (i = 0; i < NUMCHUNKSWL1+1; i++)
			grstarts[i] = (grtemp[i*3+0]<<0)|(grtemp[i*3+1]<<8)|(grtemp[i*3+2]<<16);
	}else if (w1 == true){
		ReadBytes(handle, grtemp, (NUMCHUNKSWL6+1)*3);
	
		for (i = 0; i < NUMCHUNKSWL6+1; i++)
			grstarts[i] = (grtemp[i*3+0]<<0)|(grtemp[i*3+1]<<8)|(grtemp[i*3+2]<<16);
	}else if (s0 == true){
		ReadBytes(handle, grtemp, (NUMCHUNKSSDM+1)*3);
	
		for (i = 0; i < NUMCHUNKSSDM+1; i++)
			grstarts[i] = (grtemp[i*3+0]<<0)|(grtemp[i*3+1]<<8)|(grtemp[i*3+2]<<16);
	}else{
		ReadBytes(handle, grtemp, (NUMCHUNKSSOD+1)*3);
	
		for (i = 0; i < NUMCHUNKSSOD+1; i++)
			grstarts[i] = (grtemp[i*3+0]<<0)|(grtemp[i*3+1]<<8)|(grtemp[i*3+2]<<16);
	}

	MM_FreePtr((memptr)&grtemp);
	
	CloseRead(handle);
	
/* Open the graphics file, leaving it open until the game is finished */
	strcpy(fname, gfilename);
	strcat(fname, extension);

	grhandle = OpenRead(fname);
	if (grhandle == -1)
		CA_CannotOpen(fname);

/* load the pic headers into pictable */
	CA_CacheGrChunk(STRUCTPIC);

	if (w0 == true){
		grtemp = grsegsWL1[STRUCTPIC];
		for (i = 0; i < NUMPICSWL1; i++) {
			pictableWL1[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8);
			pictableWL1[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8);
		}
	}else if (w1 == true){
		grtemp = grsegsWL6[STRUCTPIC];
		for (i = 0; i < NUMPICSWL6; i++) {
			pictableWL6[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8);
			pictableWL6[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8);
		}
	}else if (s0 == true){
		grtemp = grsegsSDM[STRUCTPIC];
		for (i = 0; i < NUMPICSSDM; i++) {
			pictableSDM[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8);
			pictableSDM[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8);
		}
	}else{
		grtemp = grsegsSOD[STRUCTPIC];
		for (i = 0; i < NUMPICSSOD; i++) {
			pictableSOD[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8);
			pictableSOD[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8);
		}
	}

	CA_UnCacheGrChunk(STRUCTPIC);
}
Ejemplo n.º 5
0
void ShowArticle(const char *article)
{
	unsigned oldfontnumber;
	boolean newpage, firstpage;


	text = article;
	oldfontnumber = fontnumber;
	fontnumber = 0;
	CA_CacheGrChunk(STARTFONT);
	VW_Bar (0,0,320,200,BACKCOLOR);
	CacheLayoutGraphics();

	newpage = true;
	firstpage = true;

	do
	{
		if (newpage)
		{
			newpage = false;
			PageLayout(true);
			VW_UpdateScreen();
			if (firstpage)
			{
				if (w0 == true || w1 == true){
					VL_FadeIn(0,255,gamepalWL6,10);
				} else {
					VL_FadeIn(0,255,gamepalSOD,10);
				}
				firstpage = false;
			}
		}

		LastScan = 0;
		while (!LastScan) IN_CheckAck(); /* update events */

		switch (LastScan)
		{
		case sc_UpArrow:
		case sc_PgUp:
		case sc_LeftArrow:
			if (pagenum>1)
			{
				BackPage ();
				BackPage ();
				newpage = true;
			}
			break;

		case sc_Enter:
		case sc_DownArrow:
		case sc_PgDn:
		case sc_RightArrow:		// the text already points at next page
			if (pagenum<numpages)
			{
				newpage = true;
			}
			break;
		}

		if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("debugmode"))
			PicturePause();

	} while (LastScan != sc_Escape);

	IN_ClearKeysDown ();
	fontnumber = oldfontnumber;
}
Ejemplo n.º 6
0
//------------------------------------------------------------------------
// PreDemo()
//------------------------------------------------------------------------
void PreDemo()
{
#if !SKIP_TITLE_AND_CREDITS
#if TECH_SUPPORT_VERSION

	fontnumber=4;
	SETFONTCOLOR(0,15*3);
	CenterWindow (26,7);
	US_Print(EnterBetaCode);
	VW_UpdateScreen();
	CA_LoadAllSounds();
	PM_CheckMainMem();
	SD_PlaySound(INFORMDEATH2SND);		// Nooooo!
	IN_UserInput(TickBase*20);
	ClearMemory();

#elif BETA_TEST

	boolean param=false;

	for (i=1; i<g_argc; i++)
		switch (US_CheckParm(g_argv[i],MainStrs))
		{
			case 13:
				param=true;
			break;
		}

	if (!param)
	{
		char buffer[15] = {0};

		fontnumber=4;
		CenterWindow (26,7);
		US_Print(EnterBetaCode);
		VW_UpdateScreen();
		SETFONTCOLOR(0,15*3);
		US_LineInput(24*8,92,buffer,buffer,true,14,100);
		if (_fstricmp(buffer,bc_buffer))
			Quit("Bad beta code!");
	}
#endif



#if GAME_VERSION == SHAREWARE_VERSION
#if IN_DEVELOPMENT || GEORGE_CHEAT
	if (!MS_CheckParm("nochex"))
#endif
	{
#if  (!SKIP_CHECKSUMS)
//	CheckValidity("MAPTEMP.",MAPTEMP_CHECKSUM,"LEVELS");
	CheckValidity("MAPTEMP.",MAPTEMP_CHECKSUM);
#endif
	}
#else
#if  (!SKIP_CHECKSUMS)
	if (ChecksumFile("FILE_ID.DIZ",0) != DIZFILE_CHECKSUM)
		gamestate.flags |= GS_BAD_DIZ_FILE;
#endif
#endif

	VL_SetPaletteIntensity(0,255,vgapal,0);

	if (!(gamestate.flags & GS_NOWAIT))
	{
#if (0)				// GAME_VERSION != SHAREWARE_VERSION
//---------------------
// Anti-piracy screen
//---------------------
	// Cache pic
	//
		CA_CacheScreen(PIRACYPIC);

	// Cache and set palette.  AND  Fade it in!
	//
		CA_CacheGrChunk(PIRACYPALETTE);
		VL_SetPalette (0,256,grsegs[PIRACYPALETTE]);
		VL_SetPaletteIntensity(0,255,grsegs[PIRACYPALETTE],0);
		VW_UpdateScreen();

		VL_FadeOut (0, 255, 0, 0, 25, 20);
		VL_FadeIn(0,255,grsegs[PIRACYPALETTE],30);

	// Wait a little
	//
		IN_UserInput(TickBase*20);

	// Free palette
	//
		UNCACHEGRCHUNK(PIRACYPALETTE);

		VL_FadeOut (0, 255, 0, 0, 25, 20);
		VW_FadeOut();

	// Cleanup screen for upcoming SetPalette call
	//
		{
		Uint16 old_bufferofs=bufferofs;

		bufferofs=displayofs;
		VL_Bar(0,0,320,200,0);
		bufferofs=old_bufferofs;
		}
#endif

//---------------------
// Apogee presents
//---------------------
        // ISG --> this fixes intro timing
        IN_UserInput(TickBase*1);
        
	// Cache pic
	//
		CA_CacheScreen(APOGEEPIC);

	// Load and start music
	//
		CA_CacheAudioChunk(STARTMUSIC+APOGFNFM_MUS);

        ::SD_StartMusic(APOGFNFM_MUS);

	// Cache and set palette.  AND  Fade it in!
	//
		CA_CacheGrChunk(APOGEEPALETTE);
		VL_SetPalette (0,256,static_cast<const Uint8*>(grsegs[APOGEEPALETTE]));
		VL_SetPaletteIntensity(0,255,static_cast<const Uint8*>(grsegs[APOGEEPALETTE]),0);
		VW_UpdateScreen();
    
		VL_FadeOut (0, 255, 25, 29, 53, 20);
		VL_FadeIn(0,255,static_cast<const Uint8*>(grsegs[APOGEEPALETTE]),30);

	// Wait for end of fanfare
	//
		if (MusicMode==smm_AdLib)
		{
			IN_StartAck();
			while ((!sqPlayedOnce) && (!IN_CheckAck()));
      }
		else
			IN_UserInput(TickBase*6);

		SD_MusicOff();

	// Free palette and music.  AND  Restore palette
	//
		UNCACHEGRCHUNK(APOGEEPALETTE);

        delete [] audiosegs[STARTMUSIC + APOGFNFM_MUS];
        audiosegs[STARTMUSIC + APOGFNFM_MUS] = NULL;

      // Do A Blue Flash!

      VL_FadeOut (0, 255, 25, 29, 53, 20);
      VL_FadeOut (0, 255, 0, 	0,  0,  30);

//---------------------
// JAM logo intro
//---------------------
	// Load and start music
	//
		CA_CacheAudioChunk(STARTMUSIC+TITLE_LOOP_MUSIC);
        ::SD_StartMusic(TITLE_LOOP_MUSIC);

	// Show JAM logo
	//
		if (!DoMovie(mv_intro,0))
			MAIN_ERROR(PREDEMO_NOJAM);

		if (PowerBall)
      {
      	Sint16 i;

			for (i=0;i<60 && (!DebugOk);i++)
   	   {
      		VL_WaitVBL(1);

            // BBi
            ::in_handle_events();

				if (Keyboard[sc_left_shift] && Keyboard[sc_right_shift])
		      {
					CA_LoadAllSounds();

					SD_MusicOff();

                   ::sd_play_player_sound(SHOOTDOORSND, bstone::AC_ITEM);

		         SD_WaitSoundDone();

				   ClearMemory();
		      	DebugOk = 1;

					CA_CacheAudioChunk(STARTMUSIC+TITLE_LOOP_MUSIC);
                    ::SD_StartMusic(TITLE_LOOP_MUSIC);
      		}
         }
      }

//---------------------
// PC-13
//---------------------
		VL_Bar(0,0,320,200,0x14);
		CacheDrawPic(0,64,PC13PIC);
		VW_UpdateScreen();
		VW_FadeIn();
		IN_UserInput(TickBase*2);

      // Do A Red Flash!

      VL_FadeOut (0, 255, 39, 0, 0, 20);
		VW_FadeOut();
	}
#endif // SKIP_TITLE_AND_CREDITS
}
Ejemplo n.º 7
0
static void DemoLoop()
{
    int LastDemo = 0;

//
// check for launch from ted
//
    if (param_tedlevel != -1)
    {
        param_nowait = true;
        EnableEndGameMenuItem();
        NewGame(param_difficulty,0);

#ifndef SPEAR
        gamestate.episode = param_tedlevel/10;
        gamestate.mapon = param_tedlevel%10;
#else
        gamestate.episode = 0;
        gamestate.mapon = param_tedlevel;
#endif
        GameLoop();
        Quit (NULL);
    }


//
// main game cycle
//

#ifndef DEMOTEST

    #ifndef UPLOAD

        #ifndef GOODTIMES
        #ifndef SPEAR
        #ifndef JAPAN
        if (!param_nowait)
            NonShareware();
        #endif
        #else
            #ifndef GOODTIMES
            #ifndef SPEARDEMO
            extern void CopyProtection(void);
            if(!param_goodtimes)
                CopyProtection();
            #endif
            #endif
        #endif
        #endif
    #endif

    StartCPMusic(INTROSONG);

#ifndef JAPAN
    if (!param_nowait)
        PG13 ();
#endif

#endif

    while (1)
    {
        while (!param_nowait)
        {
//
// title page
//
#ifndef DEMOTEST

#ifdef SPEAR
            SDL_Color pal[256];
            CA_CacheGrChunk (TITLEPALETTE);
            VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256);

            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,pal,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;
            VW_FadeOut();
            if(screenHeight % 200 != 0)
                VL_ClearScreen(0);
            StartCPMusic(INTROSONG);
        }

        VW_FadeOut ();

#ifdef DEBUGKEYS
        if (Keyboard[sc_Tab] && param_debugmode)
            RecordDemo ();
        else
            US_ControlPanel (0);
#else
        US_ControlPanel (0);
#endif

        if (startgame || loadedgame)
        {
            GameLoop ();
            if(!param_nowait)
            {
                VW_FadeOut();
                StartCPMusic(INTROSONG);
            }
        }
    }
}
Ejemplo n.º 8
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);
}
Ejemplo n.º 9
0
static void InitGame()
{
#ifndef SPEARDEMO
    boolean didjukebox=false;
#endif

    // initialize SDL
#if defined _WIN32
    putenv("SDL_VIDEODRIVER=directx");
#endif
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
    {
        printf("Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }
    atexit(SDL_Quit);

    int numJoysticks = SDL_NumJoysticks();
    if(param_joystickindex && (param_joystickindex < -1 || param_joystickindex >= numJoysticks))
    {
        if(!numJoysticks)
            printf("No joysticks are available to SDL!\n");
        else
            printf("The joystick index must be between -1 and %i!\n", numJoysticks - 1);
        exit(1);
    }

#if defined(GP2X_940)
    GP2X_MemoryInit();
#endif

    SignonScreen ();

#if defined _WIN32
    if(!fullscreen)
    {
        struct SDL_SysWMinfo wmInfo;
        SDL_VERSION(&wmInfo.version);

        if(SDL_GetWMInfo(&wmInfo) != -1)
        {
            HWND hwndSDL = wmInfo.window;
            DWORD style = GetWindowLong(hwndSDL, GWL_STYLE) & ~WS_SYSMENU;
            SetWindowLong(hwndSDL, GWL_STYLE, style);
            SetWindowPos(hwndSDL, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
        }
    }
#endif
	VW_UpdateScreen();

    VH_Startup ();
    IN_Startup ();
    PM_Startup ();
    SD_Startup ();
    CA_Startup ();
    US_Startup ();

    // TODO: Will any memory checking be needed someday??
#ifdef NOTYET
#ifndef SPEAR
    if (mminfo.mainmem < 235000L)
#else
    if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode"))
#endif
    {
        byte *screen;

        CA_CacheGrChunk (ERRORSCREEN);
        screen = grsegs[ERRORSCREEN];
        ShutdownId();
/*        memcpy((byte *)0xb8000,screen+7+7*160,17*160);
        gotoxy (1,23);*/
        exit(1);
    }
#endif


//
// build some tables
//
    InitDigiMap ();

    ReadConfig ();

    SetupSaveGames();

//
// HOLDING DOWN 'M' KEY?
//
	IN_ProcessEvents();

#ifndef SPEARDEMO
    if (Keyboard[sc_M])
    {
        DoJukebox();
        didjukebox=true;
    }
    else
#endif

//
// draw intro screen stuff
//
    IntroScreen ();

#ifdef _arch_dreamcast
    //TODO: VMU Selection Screen
#endif

//
// load in and lock down some basic chunks
//

    CA_CacheGrChunk(STARTFONT);
    CA_CacheGrChunk(STATUSBARPIC);

    LoadLatchMem ();
    BuildTables ();          // trig tables
    SetupWalls ();

    NewViewSize (viewsize);

//
// initialize variables
//
    InitRedShifts ();
#ifndef SPEARDEMO
    if(!didjukebox)
#endif
        FinishSignon();

#ifdef NOTYET
    vdisp = (byte *) (0xa0000+PAGE1START);
    vbuf = (byte *) (0xa0000+PAGE2START);
#endif
}
Ejemplo n.º 10
0
void DoJukebox(void)
{
    int which,lastsong=-1;
    unsigned start;
    unsigned songs[]=
        {
#ifndef SPEAR
            GETTHEM_MUS,
            SEARCHN_MUS,
            POW_MUS,
            SUSPENSE_MUS,
            WARMARCH_MUS,
            CORNER_MUS,

            NAZI_OMI_MUS,
            PREGNANT_MUS,
            GOINGAFT_MUS,
            HEADACHE_MUS,
            DUNGEON_MUS,
            ULTIMATE_MUS,

            INTROCW3_MUS,
            NAZI_RAP_MUS,
            TWELFTH_MUS,
            ZEROHOUR_MUS,
            ULTIMATE_MUS,
            PACMAN_MUS
#else
            XFUNKIE_MUS,             // 0
            XDEATH_MUS,              // 2
            XTIPTOE_MUS,             // 4
            XTHEEND_MUS,             // 7
            XEVIL_MUS,               // 17
            XJAZNAZI_MUS,            // 18
            XPUTIT_MUS,              // 21
            XGETYOU_MUS,             // 22
            XTOWER2_MUS              // 23
#endif
        };

    IN_ClearKeysDown();
    if (!AdLibPresent && !SoundBlasterPresent)
        return;

    MenuFadeOut();

#ifndef SPEAR
#ifndef UPLOAD
    start = ((SDL_GetTicks()/10)%3)*6;
#else
    start = 0;
#endif
#else
    start = 0;
#endif

    CA_CacheGrChunk (STARTFONT+1);
#ifdef SPEAR
    CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
#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
}