var scene_music;// = LoadSound("davis_console/davis_wait_1.ogg",true);

var g_skip_console_scene = false;

function DoFirstConsoleScene()
{
	var skip = 0;//1;
	
	g_skip_console_scene = false;
	FadeBlack("out");

	PauseAllMusic();

	PauseHeart();

	if (skip != 1)
	{
	DoFirstConsoleScene1();
	DoFirstConsoleScene2();
	DoFirstConsoleScene3();
	DoFirstConsoleScene4();
	
	DoFirstConsoleScene5();
	}
	
	StartHeart();
	UnPauseAllMusic();
	
	FadeBlack("in");
	for (f=0;f<max_doors;f++)
	{
		if (doors[f].name == "door1_8c")
		{
			doors[f].dir = "closed1";
			doors[f].frame = 0;
			doors[f].active = 1;

			SetPersonIDDirection(doors[f].id1, doors[f].dir);
			SetPersonIDFrame(doors[f].id1, doors[f].frame);
		}
	}
	
	
}

function FadeBlack(type)
{
  var starttime = GetTime();
  var lasttime = GetTime();
  var ftime = 40;
  
  var num = 30;
  for (f=0;f<=num;f++)
  {
		RenderBackground();
		if (type == "out")
			Rectangle(0,0,GetScreenWidth(),GetScreenHeight(), CreateColor(0,0,0,255*f/num));
		else
			Rectangle(0,0,GetScreenWidth(),GetScreenHeight(), CreateColor(0,0,0,255-255*f/num));
		
		FlipScreen();
		while(GetTime()-lasttime < ftime);
		lasttime=GetTime();
	}
}


function CheckCSS()
{
	var key;
	while(AreKeysLeft())
	{
		key = GetKey();
		if (key == KEY_ESCAPE || key == KEY_ENTER || key == KEY_SPACE)
		{
			g_skip_console_scene = true;
		}
	}
}


function DoFirstConsoleScene1()
{
	var images = new Array(22);

	images[0] = LoadImage("davis_console/davis_console_shot1_001.png");
	images[1] = LoadImage("davis_console/davis_console_shot1_002.png");
	images[2] = LoadImage("davis_console/davis_console_shot1_003.png");
	images[3] = LoadImage("davis_console/davis_console_shot1_004.png");
	images[4] = LoadImage("davis_console/davis_console_shot1_005.png");
	images[5] = LoadImage("davis_console/davis_console_shot1_006.png");
	images[6] = LoadImage("davis_console/davis_console_shot1_007.png");
	images[7] = LoadImage("davis_console/davis_console_shot1_008.png");
	images[8] = LoadImage("davis_console/davis_console_shot1_009.png");
	images[9] = LoadImage("davis_console/davis_console_shot1_010.png");
	images[10] = LoadImage("davis_console/davis_console_shot1_011.png");
	images[11] = LoadImage("davis_console/davis_console_shot1_012.png");
	images[12] = LoadImage("davis_console/davis_console_shot1_013.png");
	images[13] = LoadImage("davis_console/davis_console_shot1_014.png");
	images[14] = LoadImage("davis_console/davis_console_shot1_015.png");
	images[15] = LoadImage("davis_console/davis_console_shot1_016.png");
	images[16] = LoadImage("davis_console/davis_console_shot1_017.png");
	images[17] = LoadImage("davis_console/davis_console_shot1_018.png");
	images[18] = LoadImage("davis_console/davis_console_shot1_019.png");
	images[19] = LoadImage("davis_console/davis_console_shot1_020.png");
	images[20] = LoadImage("davis_console/davis_console_shot1_021.png");
	images[21] = LoadImage("davis_console/davis_console_shot1_022.png");

/*
	images[0] = LoadImage("davis_console/davis_console_davis_talk_001.png");
	images[1] = LoadImage("davis_console/davis_console_davis_talk_002.png");
	images[2] = LoadImage("davis_console/davis_console_davis_talk_003.png");
	images[3] = LoadImage("davis_console/davis_console_davis_talk_004.png");
	images[4] = LoadImage("davis_console/davis_console_davis_talk_005.png");
	images[5] = LoadImage("davis_console/davis_console_davis_talk_006.png");
	images[6] = LoadImage("davis_console/davis_console_davis_talk_007.png");

	images[7] = LoadImage("davis_console/davis_console_liegh_forward_001.png");
	images[8] = LoadImage("davis_console/davis_console_liegh_forward_002.png");
	images[9] = LoadImage("davis_console/davis_console_liegh_forward_003.png");
	images[10] = LoadImage("davis_console/davis_console_liegh_forward_004.png");
	images[11] = LoadImage("davis_console/davis_console_liegh_forward_005.png");

	images[12] = LoadImage("davis_console/davis_console_liegh_yell_001.png");
	images[13] = LoadImage("davis_console/davis_console_liegh_yell_002.png");
	images[14] = LoadImage("davis_console/davis_console_liegh_yell_002b.png");
	images[15] = LoadImage("davis_console/davis_console_liegh_yell_003.png");
	images[16] = LoadImage("davis_console/davis_console_liegh_yell_004.png");
	images[17] = LoadImage("davis_console/davis_console_liegh_yell_005.png");
	images[18] = LoadImage("davis_console/davis_console_liegh_yell_006.png");
	images[19] = LoadImage("davis_console/davis_console_liegh_yell_007.png");
	images[20] = LoadImage("davis_console/davis_console_liegh_yell_008.png");
	images[21] = LoadImage("davis_console/davis_console_liegh_yell_009.png");
	images[22] = LoadImage("davis_console/davis_console_liegh_yell_010.png");

	images[45] = LoadImage("davis_console/davis_console_shot2_001.png");

	images[46] = LoadImage("davis_console/davis_wait_001.png");
	images[47] = LoadImage("davis_console/davis_wait_002.png");
	images[48] = LoadImage("davis_console/davis_wait_003.png");
	images[49] = LoadImage("davis_console/davis_wait_004.png");
	images[50] = LoadImage("davis_console/davis_wait_005.png");
	images[51] = LoadImage("davis_console/davis_wait_005b.png");
	images[52] = LoadImage("davis_console/davis_wait_006.png");
	images[53] = LoadImage("davis_console/davis_wait_006b.png");
	images[54] = LoadImage("davis_console/davis_wait_007.png");
	images[55] = LoadImage("davis_console/davis_wait_008.png");
	images[56] = LoadImage("davis_console/davis_wait_009.png");
	images[57] = LoadImage("davis_console/davis_wait_010.png");
*/

	
	var frames = 0;
	var frametime = 30;
	
	var lasttime = GetTime();
	var x=GetScreenWidth()-images[0].width;
	var y=(GetScreenHeight()-images[0].height)/2;
	var amt=1;
	
	var maxshade = 40;
	var shade = 0;
	
	var phase = 0;
	var starttime = GetTime();
	
	var current_text = "";
	var current_text_pos = 0;
		
	function xadd()
	{
		if (shade > 0)
		{
		  Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,shade*255/maxshade));
		  shade++;
		}
		if (current_text_pos < current_text.length)
		  current_text_pos+=1;
			
		frames++;
		while(GetTime()-starttime < frametime*frames);

	}
	


	function DrawText()
	{
		Rectangle(0,225,320,20,CreateColor(0,0,0,255));
		font2.drawText(5,226, current_text.substr(0,current_text_pos));
	}
	function ChangeText(text)
	{
		current_text = text;
		current_text_pos = 0;
	}

	function DoTalk(num, start)
	{
		lasttime = GetTime();
		if (start == undefined)
			start = 3;
		images[start].blit(x,y);
		xadd();
		FlipScreen();
		if (num > 1)
		{
			lasttime = GetTime();
			images[start+1].blit(x,y);
			xadd();
			FlipScreen();

			if (num > 2)
			{
				lasttime = GetTime();
				images[start+2].blit(x,y);
				xadd();
				FlipScreen();
				while(GetTime()-lasttime < frametime);
				lasttime = GetTime();
				images[start+1].blit(x,y);
				xadd();
				FlipScreen();
			}
			lasttime = GetTime();
			images[start].blit(x,y);
			xadd();
			FlipScreen();
			while(GetTime()-lasttime < frametime);
		}
		lasttime = GetTime();
		images[start].blit(x,y);
		xadd();
		FlipScreen();
	}
	
	function DoWait(num,imagey, noskip)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			images[imagey].blit(x,y);
			DrawText();
			xadd();
			FlipScreen();
			if (noskip != true)
				CheckCSS();
		}
		
	}
	

	function DoFade(num,imagey, noskip)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			images[imagey].blit(x,y);
			DrawText();
			xadd();
			Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,255-i*255/num));
			FlipScreen();
			if (noskip != true)
				CheckCSS();
		}
	}
	
	function Display(number,xbool)
	{
		lasttime = GetTime();
		images[number].blit(x,y);
		DrawText();
		xadd();
		FlipScreen();
	}


	starttime = GetTime();

	DoFade(40,1, true)
	DoWait(120,1, true);
	DoWait(4,2, true);
	DoWait(4,3, true);
	while(AreKeysLeft())GetKey();
	DoWait(4,4);
	DoWait(4,5);
	DoWait(40,6);
	DoWait(20,7);
	DoWait(20,8);
	DoWait(20,9);
	
	while(AreKeysLeft())
		GetKey();
		
	DoWait(40,10);
	DoWait(4,11);
	DoWait(4,12);
	DoWait(4,13);
	ChangeText("Davis: Are you there Leigh?  Come in Leigh.");
	DoWait(100,13);
	for (j=14;j<22;j++)
		DoWait(4,j);
	ChangeText("");
}

function DoFirstConsoleScene2()
{
	var images = new Array(22);

/*
	images[0] = LoadImage("davis_console/davis_console_davis_talk_001.png");
	images[1] = LoadImage("davis_console/davis_console_davis_talk_002.png");
	images[2] = LoadImage("davis_console/davis_console_davis_talk_003.png");
	images[3] = LoadImage("davis_console/davis_console_davis_talk_004.png");
	images[4] = LoadImage("davis_console/davis_console_davis_talk_005.png");
	images[5] = LoadImage("davis_console/davis_console_davis_talk_006.png");
	images[6] = LoadImage("davis_console/davis_console_davis_talk_007.png");

	images[7] = LoadImage("davis_console/davis_console_liegh_forward_001.png");
	images[8] = LoadImage("davis_console/davis_console_liegh_forward_002.png");
	images[9] = LoadImage("davis_console/davis_console_liegh_forward_003.png");
	images[10] = LoadImage("davis_console/davis_console_liegh_forward_004.png");
	images[11] = LoadImage("davis_console/davis_console_liegh_forward_005.png");

	images[12] = LoadImage("davis_console/davis_console_liegh_yell_001.png");
	images[13] = LoadImage("davis_console/davis_console_liegh_yell_002.png");
	images[14] = LoadImage("davis_console/davis_console_liegh_yell_002b.png");
	images[15] = LoadImage("davis_console/davis_console_liegh_yell_003.png");
	images[16] = LoadImage("davis_console/davis_console_liegh_yell_004.png");
	images[17] = LoadImage("davis_console/davis_console_liegh_yell_005.png");
	images[18] = LoadImage("davis_console/davis_console_liegh_yell_006.png");
	images[19] = LoadImage("davis_console/davis_console_liegh_yell_007.png");
	images[20] = LoadImage("davis_console/davis_console_liegh_yell_008.png");
	images[21] = LoadImage("davis_console/davis_console_liegh_yell_009.png");
	images[22] = LoadImage("davis_console/davis_console_liegh_yell_010.png");

	images[45] = LoadImage("davis_console/davis_console_shot2_001.png");
*/
	images[0] = LoadImage("davis_console/davis_wait_001.png");
	images[1] = LoadImage("davis_console/davis_wait_002.png");
	images[2] = LoadImage("davis_console/davis_wait_003.png");
	images[3] = LoadImage("davis_console/davis_wait_004.png");
	images[4] = LoadImage("davis_console/davis_wait_005.png");
	images[5] = LoadImage("davis_console/davis_wait_005b.png");
	images[6] = LoadImage("davis_console/davis_wait_006.png");
	images[7] = LoadImage("davis_console/davis_wait_006b.png");
	images[8] = LoadImage("davis_console/davis_wait_007.png");
	images[9] = LoadImage("davis_console/davis_wait_008.png");
	images[10] = LoadImage("davis_console/davis_wait_009.png");
	images[11] = LoadImage("davis_console/davis_wait_010.png");

	
	var frames = 0;
	var frametime = 30;
	
	var lasttime = GetTime();
	var x=GetScreenWidth()-images[0].width;
	var y=(GetScreenHeight()-images[0].height)/2;
	var amt=1;
	
	var maxshade = 40;
	var shade = 0;
	
	var phase = 0;
	var starttime = GetTime();
	
	var current_text = "";
	var current_text_pos = 0;
	var TextSpeed = 1;
		
	function xadd()
	{
		if (shade > 0)
		{
		  Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,shade*255/maxshade));
		  shade++;
		}
		if (current_text_pos < current_text.length)
		  current_text_pos+=TextSpeed;
			
		frames++;
		while(GetTime()-starttime < frametime*frames);

	}
	
	function DrawText()
	{
		Rectangle(0,225,320,20,CreateColor(0,0,0,255));
		font2.drawText(5,226, current_text.substr(0,current_text_pos));
	}
	function ChangeText(text)
	{
	  TextSpeed = 1;
		current_text = text;
		current_text_pos = 0;
	}

	function DoTalk(num, start)
	{
		lasttime = GetTime();
		if (start == undefined)
			start = 3;
		images[start].blit(x,y);
		xadd();
		FlipScreen();
		if (num > 1)
		{
			lasttime = GetTime();
			images[start+1].blit(x,y);
			xadd();
			FlipScreen();

			if (num > 2)
			{
				lasttime = GetTime();
				images[start+2].blit(x,y);
				xadd();
				FlipScreen();
				while(GetTime()-lasttime < frametime);
				lasttime = GetTime();
				images[start+1].blit(x,y);
				xadd();
				FlipScreen();
			}
			lasttime = GetTime();
			images[start].blit(x,y);
			xadd();
			FlipScreen();
			while(GetTime()-lasttime < frametime);
		}
		lasttime = GetTime();
		images[start].blit(x,y);
		xadd();
		FlipScreen();
	}
	
	function DoWait(num,imagey)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			images[imagey].blit(x,y);
			DrawText();
			xadd();
			FlipScreen();
			CheckCSS();
		}
	}
	
	
	function Display(number,xbool)
	{
		lasttime = GetTime();
		images[number].blit(x,y);
		DrawText();
		xadd();
		FlipScreen();
	}


	starttime = GetTime();

	DoWait(10,0);
	DoWait(10,0);
	ChangeText("Davis: Come on.");
	DoWait(4,3);
	DoWait(4,2);
	DoWait(4,0);
	DoWait(4,2);
	DoWait(4,1);
	DoWait(4,0);
	DoWait(25,0);
	ChangeText("");
	DoWait(25,0);
	DoWait(2,4);
	DoWait(2,6);
	DoWait(2,4);
	DoWait(50,0);
	ChangeText("Leigh: YOU BASTARD!");
	DoWait(30,0);
	DoWait(4,8);
	DoWait(4,9);
	DoWait(15,9);
	ChangeText("Davis: Leigh?");
	DoWait(4,10);
	DoWait(4,11);
	DoWait(10,9);
	ChangeText("");
	
}

function DoFirstConsoleScene3()
{
	var images = new Array(22);

/*
	images[0] = LoadImage("davis_console/davis_console_davis_talk_001.png");
	images[1] = LoadImage("davis_console/davis_console_davis_talk_002.png");
	images[2] = LoadImage("davis_console/davis_console_davis_talk_003.png");
	images[3] = LoadImage("davis_console/davis_console_davis_talk_004.png");
	images[4] = LoadImage("davis_console/davis_console_davis_talk_005.png");
	images[5] = LoadImage("davis_console/davis_console_davis_talk_006.png");
	images[6] = LoadImage("davis_console/davis_console_davis_talk_007.png");

	images[7] = LoadImage("davis_console/davis_console_liegh_forward_001.png");
	images[8] = LoadImage("davis_console/davis_console_liegh_forward_002.png");
	images[9] = LoadImage("davis_console/davis_console_liegh_forward_003.png");
	images[10] = LoadImage("davis_console/davis_console_liegh_forward_004.png");
	images[11] = LoadImage("davis_console/davis_console_liegh_forward_005.png");

	images[45] = LoadImage("davis_console/davis_console_shot2_001.png");
*/
	images[0] = LoadImage("davis_console/davis_console_liegh_yell_001.png");
	images[1] = LoadImage("davis_console/davis_console_liegh_yell_002.png");
	images[2] = LoadImage("davis_console/davis_console_liegh_yell_002b.png");
	images[3] = LoadImage("davis_console/davis_console_liegh_yell_003.png");
	images[4] = LoadImage("davis_console/davis_console_liegh_yell_004.png");
	images[5] = LoadImage("davis_console/davis_console_liegh_yell_005.png");
	images[6] = LoadImage("davis_console/davis_console_liegh_yell_006.png");
	images[7] = LoadImage("davis_console/davis_console_liegh_yell_007.png");
	images[8] = LoadImage("davis_console/davis_console_liegh_yell_008.png");
	images[9] = LoadImage("davis_console/davis_console_liegh_yell_009.png");
	images[10] = LoadImage("davis_console/davis_console_liegh_yell_010.png");


	
	var frames = 0;
	var frametime = 30;
	
	var lasttime = GetTime();
	var x=GetScreenWidth()-images[0].width;
	var y=(GetScreenHeight()-images[0].height)/2;
	var amt=1;
	
	var maxshade = 40;
	var shade = 0;
	
	var phase = 0;
	var starttime = GetTime();
	
	var current_text = "";
	var current_text_pos = 0;
	var TextSpeed = 1;
		
	function xadd()
	{
		if (shade > 0)
		{
		  Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,shade*255/maxshade));
		  shade++;
		}
		if (current_text_pos < current_text.length)
		  current_text_pos+=TextSpeed;
			
		frames++;
		while(GetTime()-starttime < frametime*frames);

	}
	
	function DrawText()
	{
		Rectangle(0,225,320,20,CreateColor(0,0,0,255));
		font2.drawText(5,226, current_text.substr(0,current_text_pos));
	}
	function ChangeText(text)
	{
	  TextSpeed = 1;
		current_text = text;
		current_text_pos = 0;
	}

	function DoTalk(num, start)
	{
		lasttime = GetTime();
		if (start == undefined)
			start = 3;
		images[start].blit(x,y);
		xadd();
		FlipScreen();
		if (num > 1)
		{
			lasttime = GetTime();
			images[start+1].blit(x,y);
			xadd();
			FlipScreen();

			if (num > 2)
			{
				lasttime = GetTime();
				images[start+2].blit(x,y);
				xadd();
				FlipScreen();
				while(GetTime()-lasttime < frametime);
				lasttime = GetTime();
				images[start+1].blit(x,y);
				xadd();
				FlipScreen();
			}
			lasttime = GetTime();
			images[start].blit(x,y);
			xadd();
			FlipScreen();
			while(GetTime()-lasttime < frametime);
		}
		lasttime = GetTime();
		images[start].blit(x,y);
		xadd();
		FlipScreen();
	}
	
	function DoWait(num,imagey)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			images[imagey].blit(x,y);
			DrawText();
			xadd();
			FlipScreen();
			CheckCSS();
		}
	}
	
	
	function Display(number,xbool)
	{
		lasttime = GetTime();
		images[number].blit(x,y);
		DrawText();
		xadd();
		FlipScreen();
	}

	function SetFrameTime(amt)
	{
		starttime = GetTime();
		frametime = amt;
		frames = 0;
	}


	function Talk1()
	{
		DoWait(4,2);
		DoWait(4,1);
		DoWait(4,0);
	}
	function Talk2()
	{
		DoWait(4,2);
		DoWait(4,3);
		DoWait(4,1);
	}
	function Talk3()
	{
		DoWait(4,4);
		DoWait(4,2);
		DoWait(4,1);
	}
	function Talk4()
	{
		DoWait(4,3);
		DoWait(4,2);
		DoWait(4,0);
	}
	function Talk5()
	{
		DoWait(4,5);
		DoWait(4,6);
		DoWait(4,7);
		DoWait(4,8);
		DoWait(4,9);
	}




	starttime = GetTime();
	y = -15;



	DoWait(5,0);
	ChangeText("Leigh: You said there wouldn't be reworks.");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	ChangeText("I'm barely inside and they're everywhere.");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	DoWait(20,0);
	ChangeText("Davis: I said there *shouldn't* be...");
	DoWait(5,0);
	DoWait(50,0);
	ChangeText("Leigh: Oh yeah, *THAT* helps.");
	Talk1();
	Talk2();
	SetFrameTime(45);
	Talk5();
	SetFrameTime(30);
	ChangeText("");
}










function DoFirstConsoleScene4()
{
	var images = new Array(22);

	images[0] = LoadImage("davis_console/davis_console_davis_talk_001.png");
	images[1] = LoadImage("davis_console/davis_console_davis_talk_002.png");
	images[2] = LoadImage("davis_console/davis_console_davis_talk_003.png");
	images[3] = LoadImage("davis_console/davis_console_davis_talk_004.png");
	images[4] = LoadImage("davis_console/davis_console_davis_talk_005.png");
	images[5] = LoadImage("davis_console/davis_console_davis_talk_006.png");
	images[6] = LoadImage("davis_console/davis_console_davis_talk_007.png");

	images[7] = LoadImage("davis_console/davis_console_liegh_forward_001.png");
	images[8] = LoadImage("davis_console/davis_console_liegh_forward_002.png");
	images[9] = LoadImage("davis_console/davis_console_liegh_forward_003.png");
	images[10] = LoadImage("davis_console/davis_console_liegh_forward_004.png");
	images[11] = LoadImage("davis_console/davis_console_liegh_forward_005.png");

	images[12] = LoadImage("davis_console/davis_console_shot2_001.png");
	images[13] = LoadImage("davis_console/davis_console_liegh_yell_010.png");

	var frames = 0;
	var frametime = 30;
	
	var lasttime = GetTime();
	var x=GetScreenWidth()-images[0].width;
	var y=(GetScreenHeight()-images[0].height)/2;
	var amt=1;
	
	var maxshade = 40;
	var shade = 0;
	
	var phase = 0;
	var starttime = GetTime();
	
	var current_text = "";
	var current_text_pos = 0;
	var TextSpeed = 1;
		
	function xadd()
	{
		if (shade > 0)
		{
		  Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,shade*255/maxshade));
		  shade++;
		}
		if (current_text_pos < current_text.length)
		  current_text_pos+=TextSpeed;
			
		frames++;
		while(GetTime()-starttime < frametime*frames);
	}
	
	function DrawText()
	{
		Rectangle(0,225,320,20,CreateColor(0,0,0,255));
		font2.drawText(5,226, current_text.substr(0,current_text_pos));
	}
	function ChangeText(text)
	{
	  TextSpeed = 1;
		current_text = text;
		current_text_pos = 0;
	}

	function DoTalk(num, start)
	{
		lasttime = GetTime();
		if (start == undefined)
			start = 3;
		images[start].blit(x,y);
		xadd();
		FlipScreen();
		if (num > 1)
		{
			lasttime = GetTime();
			images[start+1].blit(x,y);
			xadd();
			FlipScreen();

			if (num > 2)
			{
				lasttime = GetTime();
				images[start+2].blit(x,y);
				xadd();
				FlipScreen();
				while(GetTime()-lasttime < frametime);
				lasttime = GetTime();
				images[start+1].blit(x,y);
				xadd();
				FlipScreen();
			}
			lasttime = GetTime();
			images[start].blit(x,y);
			xadd();
			FlipScreen();
			while(GetTime()-lasttime < frametime);
		}
		lasttime = GetTime();
		images[start].blit(x,y);
		xadd();
		FlipScreen();
	}
	
	function DoWait(num,imagey)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			images[imagey].blit(x,y);
			DrawText();
			xadd();
			FlipScreen();
			CheckCSS();
			if (g_skip_console_scene)
				return;
		}
	}
	
	
	function Display(number,xbool)
	{
		lasttime = GetTime();
		images[number].blit(x,y);
		DrawText();
		xadd();
		FlipScreen();
	}

	function SetFrameTime(amt)
	{
		starttime = GetTime();
		frametime = amt;
		frames = 0;
	}


	function Talk1()
	{
		DoWait(4,2);
		DoWait(4,1);
		DoWait(4,0);
	}
	function Talk2()
	{
		DoWait(4,2);
		DoWait(4,3);
		DoWait(4,1);
	}
	function Talk3()
	{
		DoWait(4,4);
		DoWait(4,2);
		DoWait(4,1);
	}
	function Talk4()
	{
		DoWait(4,3);
		DoWait(4,2);
		DoWait(4,0);
	}
	function Talk5()
	{
		DoWait(4,5);
		DoWait(4,6);
		DoWait(4,7);
		DoWait(4,8);
		DoWait(4,9);
	}




	starttime = GetTime();
	y = -15;



	DoWait(5,0);
	ChangeText("Davis: Look, I didn't know OK?");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	ChangeText("It's not like you have any better options here.");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	DoWait(35,7);
	DoWait(5,7);
	DoWait(5,8);
	DoWait(5,9);
	DoWait(5,10);
	DoWait(5,11);
	DoWait(20,10);
	DoWait(5,0);
	ChangeText("Davis: I'll try to help you the best I can.");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	ChangeText("Just keep a lookout for these consoles,");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	ChangeText("and I'll keep you up to date on what I find.");
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	Talk1();
	Talk2();
	Talk3();
	Talk4();
	DoWait(5,12);
	ChangeText("You'll have to go down pretty far.");
	DoWait(100,12);
	ChangeText("I don't know how much or how long it'll take,");
	DoWait(100,12);
	ChangeText("but I'll tell you where to go.");
	DoWait(100,13);
	ChangeText("");
}


function DoFirstConsoleScene5()
{
	var images = new Array(22);

	images[0] = LoadImage("davis_console/davis_wait_001.png");
	images[1] = LoadImage("davis_console/davis_wait_002.png");
	images[2] = LoadImage("davis_console/davis_wait_003.png");
	images[3] = LoadImage("davis_console/davis_wait_004.png");

	images[4] = LoadImage("davis_console/davis_console_liegh_yell_010.png");
	images[5] = LoadImage("davis_console/davis_console_liegh_yell_011.png");
	images[6] = LoadImage("davis_console/davis_console_liegh_yell_012.png");

	var frames = 0;
	var frametime = 30;
	
	var lasttime = GetTime();
	var x=GetScreenWidth()-images[0].width;
	var y=(GetScreenHeight()-images[0].height)/2;
	var amt=1;
	
	var maxshade = 40;
	var shade = 0;
	
	var phase = 0;
	var starttime = GetTime();
	
	var current_text = "";
	var current_text_pos = 0;
	var TextSpeed = 1;
		
	function xadd()
	{
		if (shade > 0)
		{
		  Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,shade*255/maxshade));
		  shade++;
		}
		if (current_text_pos < current_text.length)
		  current_text_pos+=TextSpeed;
			
		frames++;
		while(GetTime()-starttime < frametime*frames);
	}
	
	function DrawText()
	{
		Rectangle(0,225,320,20,CreateColor(0,0,0,255));
		font2.drawText(5,226, current_text.substr(0,current_text_pos));
	}
	function ChangeText(text)
	{
	  TextSpeed = 1;
		current_text = text;
		current_text_pos = 0;
	}

	function DoTalk(num, start)
	{
		lasttime = GetTime();
		if (start == undefined)
			start = 3;
		images[start].blit(x,y);
		xadd();
		FlipScreen();
		if (num > 1)
		{
			lasttime = GetTime();
			images[start+1].blit(x,y);
			xadd();
			FlipScreen();

			if (num > 2)
			{
				lasttime = GetTime();
				images[start+2].blit(x,y);
				xadd();
				FlipScreen();
				while(GetTime()-lasttime < frametime);
				lasttime = GetTime();
				images[start+1].blit(x,y);
				xadd();
				FlipScreen();
			}
			lasttime = GetTime();
			images[start].blit(x,y);
			xadd();
			FlipScreen();
			while(GetTime()-lasttime < frametime);
		}
		lasttime = GetTime();
		images[start].blit(x,y);
		xadd();
		FlipScreen();
	}
	
	function DoWait(num,imagey)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			if (imagey > -1)
				images[imagey].blit(x,y);
			DrawText();
			xadd();
			FlipScreen();
			CheckCSS();
			if (g_skip_console_scene)
				return;
		}
	}
	

	function DoFade(num,imagey)
	{
		for (i=0;i<num;i++)
		{
			if (g_skip_console_scene)
				return;
			lasttime = GetTime();
			if (imagey==undefined)
				imagey=0;
			if (imagey >-1)
				images[imagey].blit(x,y);
			DrawText();
			xadd();
			Rectangle(0,0,GetScreenWidth(),GetScreenHeight(), CreateColor(0,0,0,i*255/num));
			FlipScreen();
			CheckCSS();
			if (g_skip_console_scene)
				return;
		}
	}
	
	function Display(number,xbool)
	{
		lasttime = GetTime();
		images[number].blit(x,y);
		DrawText();
		xadd();
		FlipScreen();
	}

	function SetFrameTime(amt)
	{
		starttime = GetTime();
		frametime = amt;
		frames = 0;
	}


	function Talk1()
	{
		DoWait(4,2);
		DoWait(4,1);
		DoWait(4,0);
	}
	function Talk2()
	{
		DoWait(4,2);
		DoWait(4,3);
		DoWait(4,1);
	}
	function Talk3()
	{
		DoWait(4,4);
		DoWait(4,2);
		DoWait(4,1);
	}
	function Talk4()
	{
		DoWait(4,3);
		DoWait(4,2);
		DoWait(4,0);
	}
	function Talk5()
	{
		DoWait(4,5);
		DoWait(4,6);
		DoWait(4,7);
		DoWait(4,8);
		DoWait(4,9);
	}




	starttime = GetTime();
	y = -15;



	DoWait(25,0);
	ChangeText("Davis: Good luck Leigh.");
	DoWait(4,3);
	DoWait(4,1);
	DoWait(4,0);
	DoWait(4,2);
	DoWait(4,1);
	DoWait(4,0);
	DoWait(4,3);
	DoWait(4,2);
	DoWait(4,0);
	DoWait(20,0);
	DoWait(20,4);
	ChangeText("Leigh: Thanks.");
	DoWait(4,5);
	DoWait(4,6);
	DoWait(4,4);
	DoWait(25,4);
	ChangeText("");
	DoFade(50,4);
	DoWait(25,-1);
	ChangeText("Leigh: ...Asswipe.");
	DoWait(75,-1);
	ChangeText("");
	DoWait(5,-1);
}