#include <xtl.h>
#include "xbinput.h"
extern int vSpace;
extern int screenOptions;
extern int screenResize;
extern int screenResizeP;
extern int screenResizeI;
extern int screenResizePB;
extern int screenResizeJ;
extern int screenResizeG;
extern int screenResizeB;
extern int screenResizeA;
extern int screenResizeA2;
extern int screenOptionsM;

extern int screenResizeS;
extern int screenControllerOptions;
extern int screenCheatOptions;
extern int screenVideoOptions;
extern int screenSoundOptions;
extern int screenLightGunOptions;
extern int screenGeneralOptions;
extern int screenGUIOptions;
extern int GameNameColor;
extern int GameNameSelectedColor;
extern int FolderColor;
extern int MenuOption;
extern  BOOL m_bVideoModeChanged;
extern int MenuOptionSelected;
extern int zTopV;
extern int zLeftV;
extern int refreshPal;
extern int zTopSM;
extern int zLeftSM;
extern int flipScreen;
int forcePal = 0;

extern int zTopGM;
extern int zLeftGM;

extern int zTopCD;
extern int zLeftCD;

extern int zTopMM;
extern int zLeftMM;
int pixelRatio = 0;

extern int FontSizeGUI;
extern int FullNameColor;
extern DWORD menuColor[5];
// Global instance of custom gamepad devices
extern int DisableMenuSounds;
extern void playEffect(int i);
extern  void writeConfig();
extern XBGAMEPAD g_Gamepads[4];
extern int inGame;
unsigned char NewGrfx = 1;
unsigned char OldMode2 = 0;
int HDMode = 0;
extern int GameNameColor;
extern int GameNameSelectedColor;
extern int FolderColor;
extern int MenuOption;
extern int MenuOptionSelected;
extern int FontSizeGUI;
extern int FullNameColor;
extern DWORD menuColor[5];
unsigned char HighResMode7 = 0;
unsigned char GrayScaleMode = 0;
unsigned char EnableGameClock = 0;
extern void restoreResolution();
extern int firstVidRender;
extern int FlickerFilter;
extern int vsyncEnabled;
extern int dimColor;
extern "C" {
	extern unsigned char FPSAtStart;
	extern  unsigned char FPSOn;

	extern  unsigned char KeyBGDisble0;
	extern  unsigned char KeyBGDisble1;
	extern  unsigned char KeyBGDisble2;
	extern  unsigned char KeyBGDisble3;
	extern  unsigned char KeySprDisble;
}
int tvMode = 0;
extern "C" {
	extern unsigned char FPSAtStart;
	extern unsigned char FPSOn;
	extern unsigned char KeyLoadState;
	extern unsigned char KeyQuickClock;
	extern unsigned char cfgnewgfx;
	extern unsigned char GrayscaleMode;
	extern unsigned char Mode7HiRes16b;
	extern unsigned char NewEngEnForce;
	//extern unsigned char newgfx;
	extern unsigned char newgfx16b;
	extern unsigned char OldGfxMode2;
	extern unsigned char KeyNewGfxSwt;

}
extern unsigned char* keys;
extern int zLeftV;
extern int zRightV;
extern  int HardwareFilter;
extern unsigned char SoftwareFilter;
extern  int FlickerFilter;
extern  int ShowFPS;
extern  int Soften;
int videoOptionSelected = 0;
extern void setFlickerSoft();
extern void startHDMode();
extern "C" {
	extern void setHardwareFilter();
}


bool v720pAvailable = false; 
bool v480pAvailable = false; 
bool v1080iAvailable = false; 
void checkForHDTVResolutions() { //Done on init 
	DWORD videoFlags = XGetVideoFlags(); 
	v480pAvailable = false; 
	v720pAvailable = false; 
	v1080iAvailable = false; 
	if ( XGetAVPack() == XC_AV_PACK_HDTV) 
	{ 
		if ( videoFlags & XC_VIDEO_FLAGS_HDTV_480p ) 
		{ 
			v480pAvailable = true; 
		} 
		if ( videoFlags & XC_VIDEO_FLAGS_HDTV_720p ) 
		{ 
			v720pAvailable = true; 
		} 
		if ( videoFlags & XC_VIDEO_FLAGS_HDTV_1080i ) 
		{ 
			v1080iAvailable = true; 
		} 
	} 
} 

extern "C" {
	extern void blankScreen();

}

int bg0 = 1;
int bg1 = 1;
int bg2 = 1;
int bg3 = 1;
int spr = 1;
int videoSelect = 1;
void checkVideoOptions() {
	if(g_Gamepads[0].Event == XBGAMEPAD_B) {
		if(DisableMenuSounds == 0) playEffect(1);
		if(videoSelect == 2) {
			videoOptionSelected = 0;
			videoSelect = 1;
		}
		else {
			screenVideoOptions = 0;
			videoOptionSelected = 0;
			screenOptions     = 1;
			screenResize = 0;
			screenResizeP = 0;
			screenResizeI = 0;
			screenResizePB = 0;
			screenResizeJ = 0;
			screenResizeG = 0;
			screenResizeB = 0;
			screenResizeA = 0;
			screenOptionsM = 0;
			screenResizeS = 0;
			screenControllerOptions = 0;
			writeConfig();      
		}
		return;
	} 

	if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_DOWN)  {  
		if(DisableMenuSounds == 0) playEffect(0);	
		videoOptionSelected++;

		if(inGame == 1) {
			if(videoSelect == 1) {
				if(videoOptionSelected > 15) videoOptionSelected = 0;   
			} 
			else {
				if(videoOptionSelected > 3) videoOptionSelected = 0; 
			}
			//if(videoOptionSelected < 0) videoOptionSelected = 13;   
		}
		else {
			if(videoOptionSelected > 11) videoOptionSelected = 0;
			//if(videoOptionSelected < 0) videoOptionSelected = 8;   
		}
	}

	if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_UP)  {  
		if(DisableMenuSounds == 0) playEffect(0);	
		videoOptionSelected--; 
		if(inGame == 1) {
			//if(videoOptionSelected > 8) videoOptionSelected = 0;
			if(videoSelect == 1) {
				if(videoOptionSelected < 0) videoOptionSelected = 15;   
			} 
			else {
				if(videoOptionSelected < 0) videoOptionSelected = 3; 
			} 

		}
		else {
			//if(videoOptionSelected > 13) videoOptionSelected = 0;
			if(videoOptionSelected < 0) videoOptionSelected = 11;   
		}
	}  

	if(g_Gamepads[0].Event == XBGAMEPAD_X) {
		if(DisableMenuSounds == 0) playEffect(2);
		if(videoOptionSelected == 0) { HardwareFilter--; if(HardwareFilter < 0) HardwareFilter = 6; setHardwareFilter();}
		if(videoOptionSelected == 1) { firstVidRender = 1;  if(SoftwareFilter == 0) SoftwareFilter = 20; else SoftwareFilter--; }
		if(videoOptionSelected == 2) { FlickerFilter--; if(FlickerFilter < 0) FlickerFilter = 5; setFlickerSoft(); }
		if(videoOptionSelected == 3) { Soften = (Soften - 1) & 1; setFlickerSoft();  }
		if(videoOptionSelected == 4) { ShowFPS = (ShowFPS - 1) & 1; FPSAtStart = ShowFPS; FPSOn = ShowFPS;  }
		if(videoOptionSelected == 5) { OldMode2 = (OldMode2 - 1) & 1; OldGfxMode2 = OldMode2; }


		//if(videoOptionSelected == 8) { HighResMode7 = (HighResMode7 + 1) & 1; Mode7HiRes16b = HighResMode7; }

		if(inGame == 0) {
			if(videoOptionSelected == 6) { GrayScaleMode = (GrayScaleMode - 1) & 1; GrayscaleMode = GrayScaleMode; }//only before the game is started
		}


	}





	if(g_Gamepads[0].Event == XBGAMEPAD_A) {

		if(DisableMenuSounds == 0) playEffect(2);
		if(videoSelect == 1) {
			if(videoOptionSelected == 0) { HardwareFilter++; if(HardwareFilter > 6) HardwareFilter = 0; setHardwareFilter();}
			if(videoOptionSelected == 1) { firstVidRender = 1;  SoftwareFilter++; if(SoftwareFilter > 20) SoftwareFilter = 0; }
			if(videoOptionSelected == 2) { FlickerFilter++; if(FlickerFilter > 5) FlickerFilter = 0; setFlickerSoft(); }
			if(videoOptionSelected == 3) { Soften = (Soften + 1) & 1; setFlickerSoft();  }
			if(videoOptionSelected == 4) { ShowFPS = (ShowFPS + 1) & 1; FPSAtStart = ShowFPS; FPSOn = ShowFPS;  }
			if(videoOptionSelected == 5) { OldMode2 = (OldMode2 + 1) & 1; OldGfxMode2 = OldMode2; }
		}
	
		//if(videoOptionSelected == 8) { HighResMode7 = (HighResMode7 + 1) & 1; Mode7HiRes16b = HighResMode7; }

		if(inGame == 0) {
			if(videoOptionSelected == 6) { GrayScaleMode = (GrayScaleMode + 1) & 1; GrayscaleMode = GrayScaleMode; }//only before the game is started
			if(videoOptionSelected == 7) { 
				m_bVideoModeChanged=  true;
				checkForHDTVResolutions(); 
				HDMode++; 

				if(!v720pAvailable && !v1080iAvailable) { 
					HDMode = 0; 
					return; 
				} 
				if(!v720pAvailable && HDMode == 1) { 
					HDMode = 2; 
				} 
				if(v720pAvailable && HDMode == 1) { 
					startHDMode(); 
					return; 
				} 
				if(!v1080iAvailable && HDMode == 2) { 
					HDMode = 3; 
				} 
				if(v1080iAvailable && HDMode == 2) { 
					startHDMode(); 
					return; 
				} 

				if(HDMode == 3) { 
					HDMode = 0; 
					restoreResolution();
				} 
				return; 

			}
			if(videoOptionSelected == 8) {screenOptions = 0; screenResize = 1; screenVideoOptions = 0; return; } 

			if(videoOptionSelected == 9) { 
				if(HDMode == 0) {
					if(pixelRatio == 0)
						pixelRatio = 1;
					else
						pixelRatio = 0;
					restoreResolution();	
				}
			}

			//if(videoOptionSelected == 9) { initTVVars(); initTV(); screenOptions = 0; tvMode = 1; screenVideoOptions = 0; return;  } 
			if(videoOptionSelected == 10) { vsyncEnabled++; if(vsyncEnabled > 3) vsyncEnabled = 0; setFlickerSoft(); }
			if(videoOptionSelected == 11) { dimColor++; if(dimColor > 1) dimColor = 0; }
		}
		if(inGame == 1) {
			if(videoSelect == 1) {
				if(videoOptionSelected == 6) { NewGrfx = (NewGrfx + 1) & 1;  keys[KeyNewGfxSwt] = 1;}
				if(videoOptionSelected == 7) { 
					m_bVideoModeChanged=  true;
					checkForHDTVResolutions(); 
					HDMode++; 

					if(!v720pAvailable && !v1080iAvailable) { 
						HDMode = 0; 
						return; 
					} 
					if(!v720pAvailable && HDMode == 1) { 
						HDMode = 2; 
					} 
					if(v720pAvailable && HDMode == 1) { 
						startHDMode(); 
						return; 
					} 
					if(!v1080iAvailable && HDMode == 2) { 
						HDMode = 3; 
					} 
					if(v1080iAvailable && HDMode == 2) { 
						startHDMode(); 
						return; 
					} 

					if(HDMode == 3) { 
						HDMode = 0; 
						restoreResolution();
					} 
					return; 
				}

				if(videoOptionSelected == 8) {  screenOptions = 0; screenResizeP = 1;screenResizeJ = 1; screenResizeB = 1; screenResizeA = 1; screenResizeS = 1; screenResize = 1; screenControllerOptions = 0; screenVideoOptions = 0; return; } 
				if(videoOptionSelected == 9) { keys[KeyBGDisble0] = 1; bg0 ^= 1; }
				if(videoOptionSelected == 10) {keys[KeyBGDisble1] = 1;  bg1 ^= 1;}
				if(videoOptionSelected == 11) { keys[KeyBGDisble2] = 1; bg2 ^= 1;}
				if(videoOptionSelected == 12) {keys[KeyBGDisble3] = 1;  bg3 ^= 1;}
				if(videoOptionSelected == 13) {keys[KeySprDisble] = 1;  spr ^= 1;}


				if(videoOptionSelected == 14) { 
					if(HDMode == 0) {
						if(pixelRatio == 0)
							pixelRatio = 1;
						else
							pixelRatio = 0;
						restoreResolution();	
					}
				}
				if(videoOptionSelected == 15) { videoOptionSelected = 0; videoSelect = 2; }
			}
			else {
				if(videoOptionSelected == 0) { vsyncEnabled++; if(vsyncEnabled > 3) vsyncEnabled = 0; setFlickerSoft(); }
				if(videoOptionSelected == 1) { dimColor++; if(dimColor > 1) dimColor = 0; }
				if(videoOptionSelected == 2) { forcePal++; if(forcePal > 1) forcePal = 0; setFlickerSoft();}
				if(videoOptionSelected == 3) { flipScreen++; if(flipScreen > 1) flipScreen = 0; }
			}
		}
	}
	return;
} 







extern int FontSetColour(unsigned int colour);
extern int FontText(WCHAR *,int,int, int);
extern int FontSmallText(WCHAR *,int,int, int);

//*************************************************************************
//DRAW
int yV = 0;
int drawV_Count = 0;

void drawVDText(char* text) {
	DWORD color = menuColor[MenuOption];

	// WCHAR text2345678_[80]={0};
	// wsprintfW(text2345678_,  L"Option Selected: %d, ShowFPS: %d", controllerConfigSelected, B[0].Button_ShowFPS);
	// FontSetColour(0xffff00);
	// FontText(text2345678_,50,300, 600);



	if(drawV_Count == videoOptionSelected) color = menuColor[MenuOptionSelected]; 

	//Draw the text string
	WCHAR text23456789[80]={0};
	//wsprintfW(text2345678_, (LPCWSTR)text);

	for(int i = 0; i < 1000; i++) {
		if(text[i] == '\0') {
			text23456789[i] = '\0';
			break;
		}
		text23456789[i] = text[i];
	}
	FontSetColour(color);
	FontText(text23456789,340+zLeftV,yV+zTopV, 600);
	yV += vSpace;
	drawV_Count++;
}

void drawVText(char* text) {
	DWORD color = menuColor[MenuOption];

	// WCHAR text2345678_[80]={0};
	// wsprintfW(text2345678_,  L"Option Selected: %d, ShowFPS: %d", controllerConfigSelected, B[0].Button_ShowFPS);
	// FontSetColour(0xffff00);
	// FontText(text2345678_,50,300, 600);



	if(drawV_Count == videoOptionSelected) color = menuColor[MenuOptionSelected]; 

	//Draw the text string
	WCHAR text23456789[80]={0};
	//wsprintfW(text2345678_, (LPCWSTR)text);

	for(int i = 0; i < 1000; i++) {
		if(text[i] == '\0') {
			text23456789[i] = '\0';
			break;
		}
		text23456789[i] = text[i];
	}
	FontSetColour(color);
	FontText(text23456789,125+zLeftV,yV+zTopV, 600);
	//yV += 20;
	//drawV_Count++;
}

extern int sWidth;
extern int sHeight;

void drawVideoOptionsMenu() {
	/*WCHAR text2345[280]={0};
	wsprintfW(text2345,L"Press \"B\" to exit.");
	FontSetColour(0xffff00);
	FontSmallText(text2345,sWidth/2,70, 600);	*/

	//WCHAR atext2345[280]={0};
	//wsprintfW(atext2345,L"Select an option and press \"A\" to increase or \"X\" to decrease.");
	//FontSetColour(0xffff00);
	//FontSmallText(atext2345,sWidth/2,100, 600);	

	drawV_Count = 0;
	yV = 110;

	if(videoSelect == 1) {
		if(HardwareFilter == 0) {  drawVText("Hardware Filter: "); drawVDText("None"); }
		if(HardwareFilter == 1) {  drawVText("Hardware Filter: "); drawVDText("Point"); }
		if(HardwareFilter == 2) {  drawVText("Hardware Filter: "); drawVDText("Bilinear"); }
		if(HardwareFilter == 3) {  drawVText("Hardware Filter: "); drawVDText("Trilinear"); }
		if(HardwareFilter == 4) {  drawVText("Hardware Filter: "); drawVDText("Anisotropic"); }
		if(HardwareFilter == 5) {  drawVText("Hardware Filter: "); drawVDText("Quincunx"); }
		if(HardwareFilter == 6) {  drawVText("Hardware Filter: "); drawVDText("Gaussian Cubic"); }
		if(SoftwareFilter == 0) {  drawVText("Software Filter: ");  drawVDText("None"); }
		if(SoftwareFilter == 1) {  drawVText("Software Filter: ");  drawVDText("Scanlines - 25%"); }
		if(SoftwareFilter == 2) {  drawVText("Software Filter: ");  drawVDText("Scanlines - 50%"); }
		if(SoftwareFilter == 3) {  drawVText("Software Filter: ");  drawVDText("Scanlines - 100%"); }
		if(SoftwareFilter == 4) {  drawVText("Software Filter: ");  drawVDText("Interpolation"); }
		if(SoftwareFilter == 5) {  drawVText("Software Filter: ");  drawVDText("Interpolation + 25% SL"); }
		if(SoftwareFilter == 6) {  drawVText("Software Filter: ");  drawVDText("Interpolation + 50% SL"); }
		if(SoftwareFilter == 7) {  drawVText("Software Filter: ");  drawVDText("Interpolation + 100% SL"); }
		if(SoftwareFilter == 8) {  drawVText("Software Filter: "); drawVDText("Super Eagle"); }
		if(SoftwareFilter == 9) {  drawVText("Software Filter: ");  drawVDText("2XSai"); }
		if(SoftwareFilter == 10) {  drawVText("Software Filter: "); drawVDText("Super 2XSai"); }
		if(SoftwareFilter == 11) {  drawVText("Software Filter: "); drawVDText("Advance MAME 2X"); }
		if(SoftwareFilter == 12) {  drawVText("Software Filter: ");  drawVDText("Simple2X"); }
		if(SoftwareFilter == 13) {  drawVText("Software Filter: ");  drawVDText("HR Mode 7"); }
		if(SoftwareFilter == 14) {  drawVText("Software Filter: ");  drawVDText("Simple2X + HRM7"); }
		if(SoftwareFilter == 15) {  drawVText("Software Filter: ");  drawVDText("AdvMAME2X + HRM7"); }
		if(SoftwareFilter == 16) {  drawVText("Software Filter: ");  drawVDText("Hq2X"); }
		if(SoftwareFilter == 17) {  drawVText("Software Filter: ");  drawVDText("SuperScale2X"); }
		if(SoftwareFilter == 18) {  drawVText("Software Filter: ");  drawVDText("SuperScale2X + 75% SL"); }
		if(SoftwareFilter == 19) {  drawVText("Software Filter: ");  drawVDText("SuperScale2X + HRM7"); }
		if(SoftwareFilter == 20) {  drawVText("Software Filter: ");  drawVDText("SuperScale2X + SL + HRM7"); }





		if(FlickerFilter == 0) {  drawVText("Flicker Filter: "); drawVDText("Off"); }
		if(FlickerFilter == 1) {  drawVText("Flicker Filter: "); drawVDText("1"); }
		if(FlickerFilter == 2) {  drawVText("Flicker Filter: "); drawVDText("2"); }
		if(FlickerFilter == 3) {  drawVText("Flicker Filter: "); drawVDText("3"); }
		if(FlickerFilter == 4) {  drawVText("Flicker Filter: "); drawVDText("4"); }
		if(FlickerFilter == 5) {  drawVText("Flicker Filter: "); drawVDText("5"); }

		if(Soften == 0) {  
			drawVText("Soften Display: "); drawVDText("Off");
		}
		else {
			drawVText("Soften Display: "); drawVDText("On");
		}

		if(ShowFPS == 0) {  
			drawVText("FPS Display: "); drawVDText("Off");
		}
		else {
			drawVText("FPS Display: "); drawVDText("On");
		}


		if(OldMode2 == 0) {  
			drawVText("Old Graphics Mode 2: "); drawVDText("Off");
		}
		else {
			drawVText("Old Graphics Mode 2: "); drawVDText("On");
		}
	}


	if(inGame == 0) {
		if(GrayScaleMode == 0) {  
			drawVText("Grayscale Mode:"); drawVDText("Off");
		}
		else {
			drawVText("Grayscale Mode:"); drawVDText("On");
		}
		if(HDMode == 0) {  drawVText("HDTV Mode: "); drawVDText("480i/480p"); }
		if(HDMode == 1) {  drawVText("HDTV Mode: "); drawVDText("720p"); }
		if(HDMode == 2) {  drawVText("HDTV Mode: "); drawVDText("1080i"); }
		drawVText("Screen Size/Position"); drawVDText("");
		if(pixelRatio == 1) { drawVText("10x11 Pixel Ratio:"); drawVDText("On");}
		if(pixelRatio == 0) { drawVText("10x11 Pixel Ratio:"); drawVDText("Off");}
		//	if(refreshPal == 1) { drawVText("Force PAL Mode:"); drawVDText("On");}
		//	if(refreshPal == 0) { drawVText("Force PAL Mode:"); drawVDText("Off");}
		if(vsyncEnabled == 1) { drawVText("Video Refresh:"); drawVDText("Vsync (Recommended)");}
		if(vsyncEnabled == 0) { drawVText("Video Refresh:"); drawVDText("Immediate");}
		if(vsyncEnabled == 2) { drawVText("Video Refresh:"); drawVDText("Every other frame");}
		if(vsyncEnabled == 3) { drawVText("Video Refresh:"); drawVDText("Every third frame");}
		if(dimColor == 1) { drawVText("Dim Resize Screen:"); drawVDText("On");}
		if(dimColor == 0) { drawVText("Dim Resize Screen:"); drawVDText("Off");}
	}

	if(inGame == 1) {
		if(videoSelect == 1) {
			if(NewGrfx == 0) {  
				drawVText("New Graphics Engine:"); drawVDText("Off");
			}
			else {
				drawVText("New Graphics Engine:"); drawVDText("On");
			}
			if(HDMode == 0) {  drawVText("HDTV Mode: "); drawVDText("480i/480p"); }
			if(HDMode == 1) {  drawVText("HDTV Mode: "); drawVDText("720p"); }
			if(HDMode == 2) {  drawVText("HDTV Mode: "); drawVDText("1080i"); }
			drawVText("Adjust Screen Size/Position"); drawVDText("");

			if(bg0 == 1) {
				drawVText("Background Layer 1:"); drawVDText("Enabled");
			} else {
				drawVText("Background Layer 1:"); drawVDText("Disabled");
			}

			if(bg1 == 1) {
				drawVText("Background Layer 2:"); drawVDText("Enabled");
			} else {
				drawVText("Background Layer 2:"); drawVDText("Disabled");
			}

			if(bg2 == 1) {
				drawVText("Background Layer 3:"); drawVDText("Enabled");
			} else {
				drawVText("Background Layer 3:"); drawVDText("Disabled");
			}
			if(bg3 == 1) {
				drawVText("Background Layer 4:"); drawVDText("Enabled");
			} else {
				drawVText("Background Layer 4:"); drawVDText("Disabled");
			}
			if(spr == 1) {
				drawVText("Sprite Layer:"); drawVDText("Enabled");
			} else {
				drawVText("Sprite Layer:"); drawVDText("Disabled");
			}

			if(pixelRatio == 1) { drawVText("10x11 Pixel Ratio:"); drawVDText("On");}
			if(pixelRatio == 0) { drawVText("10x11 Pixel Ratio:"); drawVDText("Off");}
			drawVText("Page 2"); drawVDText("");
		}
		else {
			if(vsyncEnabled == 1) { drawVText("Video Refresh:"); drawVDText("Vsync (Recommended)");}
			if(vsyncEnabled == 0) { drawVText("Video Refresh:"); drawVDText("Immediate");}
			if(vsyncEnabled == 2) { drawVText("Video Refresh:"); drawVDText("Every other frame");}
			if(vsyncEnabled == 3) { drawVText("Video Refresh:"); drawVDText("Every third frame");}
			if(dimColor == 1) { drawVText("Dim Resize Screen:"); drawVDText("On");}
			if(dimColor == 0) { drawVText("Dim Resize Screen:"); drawVDText("Off");}
			if(forcePal == 1) { drawVText("Force PAL 50 Video:"); drawVDText("On");}
			if(forcePal == 0) { drawVText("Force PAL 50 Video:"); drawVDText("Off");}
			if(flipScreen == 1) { drawVText("Flip Screen:"); drawVDText("On");}
			if(flipScreen == 0) { drawVText("Flip Screen:"); drawVDText("Off");}
		}
		

	}

}