#include "app.h"
extern int guiOptionStateSelected;
extern int saveStateLoad;
extern int saveStateSave;
extern int showAvailMemory;
int sWidth = 640;
int sHeight = 480;
extern int HighRes;
#include "FileMenu.h"
#include "xbinput.h"
#include "custom_launch_params.h"
//extern void closeWave();
#include <string>
#include <vector>
#include <algorithm>
extern int disableCombo;
extern void checkMPOptions();
extern HRESULT stFrameMove();
int screenResizeMPL = 0;
extern int screenResizeMovie;
int screenResizeGP = 0;
extern void initMovie(char*);
extern void setVertex();
extern void loadHelp();
extern void clearHelp();
extern "C" {
extern void stopMovie();
}
extern void searchDirectory(std::string, bool);
extern void processArchiveList();
extern int dimColor;
extern int archiveMode; 
extern void releaseMP();
extern void initMovie(char*);
extern int fontType;
extern void checkGeneralOptionsGGText();
int mpType = 0;
extern void clearAnimation();
extern void switchMP(int i);
extern void loadAnimation();
int x, y, w, h = 0;
int zLeftMP = 10;
extern int vsyncEnabled;
extern void buildGuideList();
int zTopMP = 10;
int usePathINI = 1;
extern int loopModeMP;
extern void resetThemeSong();

extern int tvMode;
extern void buildTGAList();
int musicMode = 0;

extern "C" {
extern unsigned char *ngwinptr;
extern unsigned char *vidbuffer;
extern unsigned char *vidbufferm;	// video buffer mirror
extern unsigned char *vidbufferofsa;	// offset 1
extern unsigned char *vidbufferofsb;	// offset 2
extern unsigned char *vidbufferofsc;	// offset 3
extern unsigned char *vidbufferofsmos;	// mosaic offset for new graphics engine
extern unsigned char *headdata;
extern unsigned char *romdata;		// rom data  (4MB = 4194304)
extern unsigned char *sfxramdata;	// SuperFX Ram Data
extern unsigned char *setaramdata;	// Seta ST010/ST011 SRam Data
extern unsigned char *wramdata;	// stack (64K = 32768)
extern unsigned char *ram7f;		// ram @ 7f = 65536
extern unsigned char *vram;		// vram = 65536
extern unsigned char *sram;		// sram = 32768
extern unsigned char *spritetablea;
extern unsigned char *spcBuffera;
extern unsigned char *debugbuf;
extern unsigned char StereoSound;
}

int screenGeneralOptionsMP = 0;

extern void setTextureMode();
extern void switchSongs();
extern void pauseVGMusic();
int musicPlayer = 0;
extern void stopMusic();
//extern int vgplaying;
extern int lightGun;
extern HRESULT stInitialize();
extern VOID stStart(int s);
extern VOID stStop();
extern void resumeVGMusic();
#include "undocumented.h"
extern void StartLightGun();
extern float timeRumblelg ;
extern HRESULT LightGunRender();
extern void songIsOver();
extern int InitVGMusic(char *path);
extern int correctAppState();
extern int playingMusic;
extern void nextTrack();
extern void previousTrack();

extern HRESULT ProcessLightGun();
extern void updateVGStream();
extern int leftRumblelg ;
extern int rightRumblelg ;
extern float timeRumblelg;
extern LPDIRECTSOUNDBUFFER     vgPrimaryBuffer;
extern int songStop;
std::string romBasePath = "D:\\roms\\";
std::string BOOKMARK_PATH="D:\\bookmarks\\";
std::string ARTWORK_SHOTS_1_PATH="D:\\artwork\\Shots 1\\";
std::string ARTWORK_SHOTS_2_PATH="D:\\artwork\\Shots 2\\";
std::string ARTWORK_SHOTS_3_PATH="D:\\artwork\\Shots 3\\";
std::string ARTWORK_SHOTS_4_PATH="D:\\artwork\\Shots 4\\" ;
std::string ARTWORK_SHOTS_5_PATH="D:\\artwork\\Shots 5\\"; 
std::string ARTWORK_SHOTS_6_PATH="D:\\artwork\\Shots 6\\"; 
std::string ARTWORK_SHOTS_7_PATH="D:\\artwork\\Shots 7\\"; 
std::string ARTWORK_SHOTS_8_PATH="D:\\artwork\\Shots 8\\"; 
std::string SRAM_PATH="D:\\sram\\"; 
std::string SAVE_PATH="D:\\save\\"; 
std::string INI_PATH="D:\\ini\\"; 
std::string RUMBLE_PATH="D:\\rumble\\"; 
std::string CHEATS_PATH="D:\\cheats\\"; 
std::string GARBAGE_PATH="D:\\garbage\\"; 
std::string VIDEO_PATH="D:\\videos\\";
extern HRESULT Mount(const char* szDrive, char* szDevice);
void loadSkinIniFromFolder(char* folder);
extern HRESULT Unmount(const char* szDrive);
extern void checkGUIOptions();
extern int wasThere;
extern IDirect3D8 *Direct3D;
extern void checkGeneralOptionsGG();
extern void drawGameGuideList();
extern bool videoRender;
extern int EnableVideoAudio;

int zLeftRM = 0;
int zTopRM = 0;
extern void LoadRumbleFile(std::string cSum);
extern int fadeColor;
extern void changePreview() ;
extern void changePreviewUp();
extern int fadeColor2;
extern void restoreRomBrowser();
extern int backupChanged;
extern int rWidth;
int analogStill = 0;
extern void loadCheatCommandLine(char* gamename);
extern int favorites;
extern void saveFavorites();
extern void saveFavoritesExit();
extern void buildFavorites();
extern void addToFavorites();
extern void removeFromFavorites();
extern int confirmDelete;
extern int favoriteAdd;
extern int romBrowserCount;




extern void changePreviewDown();
int oldScreenShot = 1;

int screenShotSlotAuto = 1;
extern int HDMode;
extern float zoomSpeed;
extern void updateZipFilename();
extern int aRepeat;
extern int gL;
extern int screenResizeG;
extern int cDist;
extern int currentStationaryFrame;
extern float distA;
extern float minA;
extern float maxA;
//extern void vkInit();
extern void buildCheatCodeList();
extern void buildCheatCodeListAR();
extern void buildCheatCodeListTips();
extern float distA2;
extern float minA2;
extern float maxA2;
using namespace std;
int screenResizeE = 0;
int fontResizeV = 0;
int fontResizeRumble = 0;
extern int vgplaying;
int fontResizeGT = 0;
int fontResizeIT = 0;
extern int fadeOption;
extern int lC;
extern int rC;
extern int lCWidth;
extern int rCHeight;
extern int screenOptionsM;
extern int screenOptionsHelp;
int splash = 1;
int fade = 0;
int fontResizeS = 0;
int fontResizeG = 0;
extern "C" int dprintf(char *format, ...);
int fontResizeCD = 0;
extern int showBorder;
int fontResizeM = 0;
extern void xboxScreenshot();
extern int firstFrame;
extern int automaticScreenShotSwitching;
extern unsigned char leftAnalog;
extern unsigned char rightAnalog;
extern double slow;
extern int FileMenuSelected;
#include <vector>
using namespace std;
char currentSongName[512];
struct fileDisplay {
	string name;
	string path;
	bool isAGame;
	bool isARoot;
	bool isADirectory;
	bool topLevel;
	int soundTrack;
	int song;
	int archive;
};
extern vector<fileDisplay> fileList;
extern int mpOptionSelected;

struct rumbleSetting { 
	bool isActive; 
	unsigned short address; 
	unsigned char bank; 
	int rumbleType; 
	unsigned char currentValue; 
	unsigned char previousValue; 
	std::string description; 
	int motorOneStrength; 
	int motorTwoStrength; 
	float motorOneTime; 
	float motorTwoTime; 
	int controller; 
	int rumbleCount;
	int rumbleTarget;
}; 

vector<rumbleSetting> rumbleList; 
int activeRumble = 0; 


int zTopBR = 0;
int zLeftBR = 8;

int zTopV = 26;
int zLeftV = 46;

int zTopSM = 24;
int zLeftSM = 61;

int zTopGM = 2;
int zLeftGM = 28;

int zTopCD = 2;
int zLeftCD = 28;

int zTopMM = -4;
int zLeftMM = -63;
extern void analogScroll();

int zTopEO = 35;
int zLeftEO = -63;

int zTopCO = 30;
int zLeftCO = -80;

int zTopTO = 38;
int zLeftTO = -6;

int zTopCCO = -12;
int zLeftCCO = -5;
int zTopBF = 1;
int zLeftBF = 0;

int zTopGT = 0;
int zLeftGT = 0;

int zTopIT = 0;
int zLeftIT = 0;

int zTopCC = 0;
int zLeftCC = 0;
char skinPath[512];
extern int errorFound;
extern std::string errorMessage;
extern FLOAT fLeft;//fOriginX;
extern FLOAT fRight;//fOriginX + ( fSizeY * fMovieWidth) / fMovieHeight;
extern FLOAT fTop;//fOriginY;
extern FLOAT fBottom;//fOriginY + fSizeY;
extern int lastChoice;
char LoopQuit=0;
static FILE *DebugFile=NULL;
int LoopMode=0;
bool down;
int fontResizeR = 0;
int fontResizeEO = 0;
int fontResizeCO = 0;
int fontResizeCC = 0;
int fontResizeClip = 0;
int fontResizeTO = 0;
int fontResizeCCO = 0;
int fontResizeF = 0;
extern void setHeight(int);
extern int showNes6502;
extern int showTransparency;
int gFont = 0;
extern void SaveSlot(int slot);
void pauseMusic();
extern char currentPath[260];
void resumeMusic();
extern int SoundEnabled;
extern IDirect3DVertexBuffer8 *VertexBufferLinear;
extern LPDIRECTSOUNDBUFFER     lpPrimaryBuffer;
extern CustomVertex VertexListLinear[4];
extern void makeVertexListLinear();
extern int cheatMenu;
extern int cheatSearchMenu;
extern void checkControllerConfig();
void updateSound();
int initMusic();
extern int zipChanged;
extern int animationFPS;
extern float animationSpeed;
#include <direct.h>
void effectInit();
void updateEffect();
void playEffect(int i);
void stopEffect();
//unsigned char savePartition = 'E';
extern "C" {
	extern unsigned char En2xSaI;
	extern unsigned char Surround;
}
extern int guiOptionSelected;
extern unsigned char SoftwareFilter;
void processOptions();
void setFlickerSoft();
extern float getVolume();
extern void setVolume();

extern "C" void zstart();

extern int render;
extern int transparency;
extern int mouseDist;
void drawTime() {
	return;




}




extern void initKeyboard();
extern void drawKeyboard();
extern void drawXKeyboard();
int keyBoardDraw = 0;



extern int pixelRatio;


void getSNESInput() {




	//if (Inp.held[8]==1 ) {  render = 0; buttonPressed = 8; } 
	//if (Inp.held[9]==1 ) { render = 1; buttonPressed = 9; } 
	//if (Inp.held[10]==1 ) { render = 2; buttonPressed = 10; } 
	//if (Inp.held[11]==1 ) { render = 3; buttonPressed = 11; } 
}
extern "C" unsigned char fnamest[512];


//Called when a game is loaded. 
void createSaveStateDirectories() { 
	//Create the game name directory 
	std::string path = SAVE_PATH;
	std::string path2 = fileList[FileMenuSelected].name;
	path2[path2.size()-4] = '\0';
	path2[path2.size()-3] = '\0';
	path2[path2.size()-2] = '\0';
	path2[path2.size()-1] = '\0';


	std::string t = path2.c_str();
	path = path + t;
	mkdir(path.c_str()); 

	std::string path0 = path + "\\slot0";
	mkdir(path0.c_str());

	std::string path1 = path + "\\slot1";
	mkdir(path1.c_str());

	std::string path22 = path + "\\slot2";
	mkdir(path22.c_str());

	std::string path3 = path + "\\slot3";
	mkdir(path3.c_str());

	std::string path4 = path + "\\slot4";
	mkdir(path4.c_str());

	std::string path5 = path + "\\slot5";
	mkdir(path5.c_str());

	std::string path6 = path + "\\slot6";
	mkdir(path6.c_str());

	std::string path7 = path + "\\slot7";
	mkdir(path7.c_str());

	std::string path8 = path + "\\slot8";
	mkdir(path8.c_str());

	std::string path9 = path + "\\slot9";
	mkdir(path9.c_str());


} 


struct Turbo { 
	int turboA ; 
	int turboB ; 
	int turboX ; 
	int turboY ; 
	int turboL ; 
	int turboR ; 
}; 

extern Turbo tButtons[4];

//****************************************************************
extern void inputInit();
extern void readInput();
extern XINPUT_STATE g_InputStates[4];
// Global instance of custom gamepad devices
extern XBGAMEPAD g_Gamepads[4];
//****************************************************************
extern void initControllers();



int getAnalog() {
	if(!(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) {
		return 1;
	}
	else {
		return 0;
	}
}
extern void loadIni();
extern int y2;

extern float zTop;
extern float zLeft;
extern float zBottom;
extern float zRight;

extern float zTopP;
extern float zLeftP;
extern float zRightP;
extern float zBottomP;

extern float zTopGP;
extern float zLeftGP;
extern float zRightGP;
extern float zBottomGP;

extern float zTopMPL;
extern float zLeftMPL;
extern float zRightMPL;
extern float zBottomMPL;



extern float zTopPB;
extern float zLeftPB;
int zTopHT = -18;
int zLeftHT = -228;

extern float zRightPB;
extern float zBottomPB;

extern float zTopJ;
extern float zLeftJ;
extern float zBottomJ;
extern float zRightJ ;

extern float zTopG;
extern float zLeftG;
extern float zBottomG;
extern float zRightG ;

extern float zTopB;
extern float zLeftB;
extern float zBottomB;
extern float zRightB ;

extern float zTopA;
extern float zLeftA;
extern float zBottomA;
extern float zRightA ;

extern float zTopA2;
extern float zLeftA2;
extern float zBottomA2;
extern float zRightA2 ;


extern float zTopAR;
extern float zLeftAR;
extern float zBottomAR;
extern float zRightAR ;

extern float zTopA2R;
extern float zLeftA2R;
extern float zBottomA2R;
extern float zRightA2R ;

extern float zTopS;
extern float zLeftS;
extern float zBottomS;
extern float zRightS ;

extern int HideFileExtension;
extern int  ReverseStereo;
extern int ScreenshotSaving;
extern int DisableMenuSounds;
extern int Disable34;
struct playerControl {
	int button_A      ;
	int button_B      ;
	int button_X      ;
	int button_Y      ;
	int button_Start  ;
	int button_Select ;
	int button_Left   ;
	int button_Right  ;
	int button_FastForward  ;
	int button_Rewind  ;
	int button_SaveState  ;
	int button_LoadState  ;
	int button_ShowFPS  ;
	int button_ExitGame  ;

};
extern float scrollSpeed;
extern int fadeSpeed;
extern playerControl controllers[4];
extern int map34;
extern "C" {
	extern unsigned char ShowInfo;
}
float BGVol = -250.0f;
extern float XBINPUT_DEADZONE;
#include <stdlib.h>
#include <stdio.h>
extern int vSpace;
void startCommanLine(char* commandLineName);
extern int EnableAudioAdjust;
extern int animationFrames;
extern int repeatAnimation;
extern int screenShotSlot;
extern float screenShotSpeed;
extern float imageMovementSpeed;
extern float imageScaleSpeed;

extern int gameGuideLines ;
extern int gameGuideColor ;
extern int gameGuideFontSize ;
void writeConfig() {
	FILE* f;
	std::string t = INI_PATH + "ZsnexBox.ini";
	f = fopen(t.c_str() , "w+");
	if(f) {
		fprintf(f, "imageMovementSpeed=%f\n", imageMovementSpeed);
		fprintf(f, "imageScaleSpeed=%f\n", imageScaleSpeed);
		fprintf(f, "fLeft=%f\n", fLeft);
		fprintf(f, "fRight=%f\n", fRight);
		fprintf(f, "fTop=%f\n", fTop);
		fprintf(f, "fBottom=%f\n", fBottom);

		string q = currentSongName;
		if(q.size() == 0)
			fprintf(f, "SoundTrack=%s\n", "Default");
		else
			fprintf(f, "SoundTrack=%s\n", currentSongName);
		fprintf(f, "gameGuideLines=%d\n", gameGuideLines);
		fprintf(f, "gameGuideColor=%d\n", gameGuideColor);
		fprintf(f, "gameGuideFontSize=%d\n", gameGuideFontSize);

		fprintf(f, "DimColor=%d\n", dimColor);
		fprintf(f, "RefreshMode=%d\n", vsyncEnabled);
		fprintf(f, "mpType=%d\n", mpType);
        fprintf(f, "FontType=%d\n", fontType);
		fprintf(f, "LoopMode=%d\n", loopModeMP);
		fprintf(f, "zLeftGP=%f\n", zLeftGP);
		fprintf(f, "zRightGP=%f\n", zRightGP);
		fprintf(f, "zTopGP=%f\n", zTopGP);
		fprintf(f, "zBottomGP=%f\n", zBottomGP);
		fprintf(f, "zLeftMPL=%f\n", zLeftMPL);
		fprintf(f, "zRightMPL=%f\n", zRightMPL);
		fprintf(f, "zTopMPL=%f\n", zTopMPL);
		fprintf(f, "zBottomMPL=%f\n", zBottomMPL);
		fprintf(f, "LightgunLeftMotorStrength=%d\n", leftRumblelg);
		fprintf(f, "LightgunRightMotorStrength=%d\n", rightRumblelg);
		fprintf(f, "LightgunRumbleTime=%f\n",timeRumblelg);
		fprintf(f, "10x11PixelRatio=%d\n", pixelRatio);
		fprintf(f, "DisableKeyCombo=%d\n", disableCombo);
		fprintf(f, "RumbleTopText=%d\n", zTopRM);
		fprintf(f, "RumbleLeftText=%d\n", zLeftRM);
		fprintf(f, "RomBrowserCount=%d\n", romBrowserCount);
		fprintf(f, "DefaultScreenshotSaveSlot=%d\n", screenShotSlot);
		fprintf(f, "automaticScreenShotSwitching=%d\n", automaticScreenShotSwitching);
		fprintf(f, "screenShotSpeed=%f\n", screenShotSpeed);
		fprintf(f, "zoomSpeed=%f\n", zoomSpeed);
		fprintf(f, "CDTopText=%d\n", zTopCD);
		fprintf(f, "CDLeftText=%d\n", zLeftCD);
		fprintf(f, "MenuScrollSpeed=%f\n", scrollSpeed);
		fprintf(f, "RombrowserAnimationRepeat=%d\n", repeatAnimation);
		fprintf(f, "MouseScopeSpeed=%d\n", mouseDist);
		fprintf(f, "RomBrowserAnimationFrameCount=%d\n", animationFrames);
		fprintf(f, "BetazLeft=%f\n", zLeft);
		fprintf(f, "zRight=%f\n", zRight);
		fprintf(f, "zTop=%f\n", zTop);
		fprintf(f, "zBottom=%f\n", zBottom);
		fprintf(f, "SoftwareFilter=%d\n", SoftwareFilter);
		fprintf(f, "HardwareFilter=%d\n", HardwareFilter);
		fprintf(f, "FlickerFilter=%d\n", FlickerFilter);
		fprintf(f, "Soften=%d\n", Soften);
		fprintf(f, "ShowFPS=%d\n", ShowFPS);
		fprintf(f, "SoundFrequency=%d\n", SoundFrequency);
		fprintf(f, "SoundInterpolation=%d\n", SoundInterpolation);
		fprintf(f, "LowPassFilter=%d\n", LowPassFilter);
		fprintf(f, "SurroundSound=%d\n", SurroundSound);
		fprintf(f, "DisableMenuSounds=%d\n", DisableMenuSounds);
		fprintf(f, "Disable34=%d\n", Disable34);
		fprintf(f, "DisableSaveStates=%d\n", DisableSaveStates);

		for(int i = 0; i < 4; i++) {
			fprintf(f, "Controller%dButtonA=%d\n", (i+1), controllers[i].button_A);
			fprintf(f, "Controller%dButtonB=%d\n",(i+1), controllers[i].button_B);
			fprintf(f, "Controller%dButtonX=%d\n",(i+1), controllers[i].button_X);
			fprintf(f, "Controller%dButtonY=%d\n",(i+1), controllers[i].button_Y);
			fprintf(f, "Controller%dButtonLeft=%d\n",(i+1), controllers[i].button_Left);
			fprintf(f, "Controller%dButtonRight=%d\n",(i+1), controllers[i].button_Right);
			fprintf(f, "Controller%dButtonSelect=%d\n",(i+1), controllers[i].button_Select);
			fprintf(f, "Controller%dButtonStart=%d\n",(i+1), controllers[i].button_Start);
			fprintf(f, "Controller%dButtonFastForward=%d\n",(i+1), controllers[i].button_FastForward);
			fprintf(f, "Controller%dButtonRewind=%d\n",(i+1), controllers[i].button_Rewind);
			fprintf(f, "Controller%dButtonLoadState=%d\n",(i+1), controllers[i].button_LoadState);
			fprintf(f, "Controller%dButtonSaveState=%d\n",(i+1), controllers[i].button_SaveState);
			fprintf(f, "Controller%dButtonExitGame=%d\n",(i+1), controllers[i].button_ExitGame);
			fprintf(f, "Controller%dButtonShowFPS=%d\n",(i+1), controllers[i].button_ShowFPS);	
		}

		fprintf(f, "HDMode=%d\n", (int)HDMode);

		fprintf(f, "DeadZone=%f\n", XBINPUT_DEADZONE);
		fprintf(f, "ROMInfo=%d\n", ShowInfo);
		fprintf(f, "BGVollume=%f\n", BGVol);
		fprintf(f, "HideFileExtensions=%d\n", HideFileExtension);
		//ReverseStereo
		fprintf(f, "ReverseStereo=%d\n", ReverseStereo);
		fprintf(f, "ScreenshotSaving=%d\n", ScreenshotSaving);

		for(int i = 0; i < 4; i++) {
			fprintf(f, "Controller%dTurboButtonA=%d\n", (i+1), tButtons[i].turboA );
			fprintf(f, "Controller%dTurboButtonB=%d\n",(i+1), tButtons[i].turboB );
			fprintf(f, "Controller%dTurboButtonX=%d\n",(i+1), tButtons[i].turboX );
			fprintf(f, "Controller%dTurboButtonY=%d\n",(i+1), tButtons[i].turboY );
			fprintf(f, "Controller%dTurboButtonLeft=%d\n",(i+1), tButtons[i].turboL);
			fprintf(f, "Controller%dTurboButtonRight=%d\n",(i+1), tButtons[i].turboR);
		}

		fprintf(f, "zLeftP=%f\n", zLeftP);
		fprintf(f, "zRightP=%f\n", zRightP);
		fprintf(f, "zTopP=%f\n", zTopP);
		fprintf(f, "zBottomP=%f\n", zBottomP);

		fprintf(f, "zLeftJ=%f\n", zLeftJ);
		fprintf(f, "zRightJ=%f\n", zRightJ);
		fprintf(f, "zTopJ=%f\n", zTopJ);
		fprintf(f, "zBottomJ=%f\n", zBottomJ);

		fprintf(f, "GameNameColor=%d\n", GameNameColor);
		fprintf(f, "GameNameSelectedColor=%d\n", GameNameSelectedColor);
		fprintf(f, "FolderColor=%d\n", FolderColor);
		fprintf(f, "MenuOption=%d\n", MenuOption);
		fprintf(f, "MenuOptionSelected=%d\n", MenuOptionSelected);
		fprintf(f, "FontSizeGUI=%d\n", FontSizeGUI);
		fprintf(f, "FullNameColor=%d\n", FullNameColor);
		fprintf(f, "showTransparency=%d\n", showTransparency);
		fprintf(f, "HighResScreenshots=%d\n", HighRes);
		//showTransparency

		fprintf(f, "zLeftB=%f\n", zLeftB);
		fprintf(f, "zRightB=%f\n", zRightB);
		fprintf(f, "zTopB=%f\n", zTopB);
		fprintf(f, "zBottomB=%f\n", zBottomB);

		fprintf(f, "EnableAudioAdjust=%d\n", EnableAudioAdjust);

		fprintf(f, "zLeftA=%f\n", zLeftA2);
		fprintf(f, "zRightA=%f\n", zRightA2);
		fprintf(f, "zTopA=%f\n", zTopA2);
		fprintf(f, "zBottomA=%f\n", zBottomA2);

		fprintf(f, "zLeftS=%f\n", zLeftS);
		fprintf(f, "zRightS=%f\n", zRightS);
		fprintf(f, "zTopS=%f\n", zTopS);
		fprintf(f, "zBottomS=%f\n", zBottomS);
		fprintf(f, "MenuVertSpacing=%d\n", vSpace);
		fprintf(f, "FontSize=%d\n", FontSizeGUI);

		fprintf(f, "animationFPS=%d\n", animationFPS);
		fprintf(f, "animationSpeed=%f\n", animationSpeed);
		//fprintf(f, "zLeft=%f\n", zLeft);

		fprintf(f, "zLeftPB=%f\n", zLeftPB);
		fprintf(f, "zRightPB=%f\n", zRightPB);
		fprintf(f, "zTopPB=%f\n", zTopPB);
		fprintf(f, "zBottomPB=%f\n", zBottomPB);

		fprintf(f, "zLeftG=%f\n", zLeftG);
		fprintf(f, "zRightG=%f\n", zRightG);
		fprintf(f, "zTopG=%f\n", zTopG);
		fprintf(f, "zBottomG=%f\n", zBottomG);

		fprintf(f, "previewTransparency=%d\n", transparency);

		fprintf(f, "RomBrowserTopText=%d\n", zTopBR);
		fprintf(f, "RomBrowserLeftText=%d\n", zLeftBR);

		fprintf(f, "FullnameTopText=%d\n", zTopBF);
		fprintf(f, "FullNameLeftText=%d\n", zLeftBF);

		fprintf(f, "VideoTopText=%d\n", zTopV);
		fprintf(f, "VideoLeftText=%d\n", zLeftV);

		fprintf(f, "SoundTopText=%d\n", zTopSM);
		fprintf(f, "SoundLeftText=%d\n", zLeftSM);

		fprintf(f, "GeneralTopText=%d\n", zTopGM);
		fprintf(f, "GeneralLeftText=%d\n", zLeftGM);

		fprintf(f, "MainMenuTopText=%d\n", zTopMM);
		fprintf(f, "MainMenuLeftText=%d\n", zLeftMM);

		fprintf(f, "EmulatorOptionsTopText=%d\n", zTopEO);
		fprintf(f, "EmulatorOptionsLeftText=%d\n", zLeftEO);

		fprintf(f, "ControllerMenuOptionsTopText=%d\n", zTopCO);
		fprintf(f, "ControllerMenuOptionsLeftText=%d\n", zLeftCO);

		fprintf(f, "TurboControllerOptionsTopText=%d\n", zTopTO);
		fprintf(f, "TurboControllerOptionsLeftText=%d\n", zLeftTO);

		fprintf(f, "ControllerOptionsTopText=%d\n", zTopCCO);
		fprintf(f, "ControllerOptionsLeftText=%d\n", zLeftCCO);

		fprintf(f, "previewBorder=%d\n", showBorder);
		fprintf(f, "fadeSpeed=%d\n", fadeSpeed);

		fprintf(f, "ImageTextTopText=%d\n", zTopGT);
		fprintf(f, "ImageTextLeftText=%d\n", zLeftGT);

		fprintf(f, "InGameTopText=%d\n", zTopIT);
		fprintf(f, "InGameLeftText=%d\n", zLeftIT);

		fprintf(f, "CheatTopText=%d\n", zTopCC);
		fprintf(f, "CheatLeftText=%d\n", zLeftCC);

		fprintf(f, "zTopHT=%d\n", zTopHT);
		fprintf(f, "zBottomHT=%d\n", zLeftHT);

		fprintf(f, "leftClip=%d\n", lC);
		fprintf(f, "topClip=%d\n", rC);
		fprintf(f, "clipWidth=%d\n", lCWidth);
		fprintf(f, "clipHeight=%d\n", rCHeight);

		fprintf(f, "RombrowserWidth=%d\n", rWidth);



		fprintf(f, "zLeftAR=%f\n", zLeftA2R);
		fprintf(f, "zRightAR=%f\n", zRightA2R);
		fprintf(f, "zTopAR=%f\n", zTopA2R);
		fprintf(f, "zBottomAR=%f\n", zBottomA2R);



		fprintf(f, "distA=%f\n", distA);
		fprintf(f, "minA=%f\n", minA);
		fprintf(f, "maxA=%f\n", maxA);
		fprintf(f, "distA2=%f\n", distA2);
		fprintf(f, "minA2=%f\n", minA2);
		fprintf(f, "maxA2=%f\n", maxA2);

		fprintf(f, "cDist=%d\n", cDist);

		fprintf(f, "SkinPath=%s\n", skinPath);


		fclose(f);
	}
	else {
		//dprintf("Error opening creating ini in write config\n");
	}
}

void getCD(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			zLeftCD = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}
extern int dimColor;
void getDimColor(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			dimColor = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getZoomSpeed(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			zoomSpeed = (float) atof(&ggdbLeft[i+1]);
			break;
		}
	}
}



void getScreenShotSlot(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			screenShotSlot = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getScreenShotSwitching(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			automaticScreenShotSwitching = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getFontType(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			fontType = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getScreenShotSpeed(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			screenShotSpeed = (float) atof(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getRomBrowserCount(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			romBrowserCount = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getPixelRatio(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			pixelRatio = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getMpType(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			mpType = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getVsync(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			vsyncEnabled = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getDisableKeyCombo(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			disableCombo = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}
void getLeftLGRumble(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			leftRumblelg = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}
void getRightLGRumble(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			rightRumblelg = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}
void getTimeLGRumble(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			timeRumblelg = (float) atof(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getLoop(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			loopModeMP = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

/*
extern int gameGuideLines ;
extern int gameGuideColor ;
extern int gameGuideFontSize ;
		getGuideLines();
		getGuideColor();
		getGuideFontSize();
*/


void getSong(FILE *f) {
	char b[512];
	fgets(b,512, f);
	std::string n = b;
	int p = n.find('=', 0);
	//dprintf("= place: %d\n", p);

	if(p != string::npos) {
		for(int id = p+1; id < 512+p+1; id++) {
			
			if((n[id] == '\0') || (n[id] == '\n') || (n[id] == '\t') || (n[id] == EOF)) {
				currentSongName[id-(p+1)] = '\0';
				return;
			}
			else {
				currentSongName[id-(p+1)] = n[id];
			}
		}
		//dprintf("Current song: %s\n", currentSongName);
	}
	else {
		//dprintf("Error getSong\n");
	}
}
void getGuideLines(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			gameGuideLines = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}
void getGuideColor(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			gameGuideColor = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}
void getGuideFontSize(FILE *f) {
	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			gameGuideFontSize = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}
}

void getRumbleSettings(FILE* f) {
	char baaaayyyyline4oq[100];
	fgets(baaaayyyyline4oq,100, f);
	for(int i = 0; i < 100; i++) {
		if(baaaayyyyline4oq[i] == '=') {
//			char c = baaaayyyyline4oq[i+1];
			zTopRM = (int) atoi(&baaaayyyyline4oq[i+1]);
			break;
		}
	}

	char bbaaaaaayyyyline4oq[100];
	fgets(bbaaaaaayyyyline4oq,100, f);
	for(int i = 0; i < 100; i++) {
		if(bbaaaaaayyyyline4oq[i] == '=') {
//			char c = bbaaaaaayyyyline4oq[i+1];
			zLeftRM = (int) atoi(&bbaaaaaayyyyline4oq[i+1]);
			break;
		}
	}

}

void getGP(FILE* f) {
	char line[100];

	fgets(line,100, f);
	for(int i = 0; i < 100; i++) {
		if(line[i] == '=') {
			//char c = line[i+1];
			zLeftGP =  (float) atof(&line[i+1]);
			break;
		}
	}

	char line2[100];
	fgets(line2,100, f);
	for(int i = 0; i < 100; i++) {
		if(line2[i] == '=') {
//			char c = line2[i+1];
			zRightGP =  (float) atof(&line2[i+1]);;
			break;
		}
	}

	char line3[100];
	fgets(line3,100, f);
	for(int i = 0; i < 100; i++) {
		if(line3[i] == '=') {
//			char c = line3[i+1];
			zTopGP =  (float) atof(&line3[i+1]);
			break;
		}
	}

	char line4[100];
	fgets(line4,100, f);
	for(int i = 0; i < 100; i++) {
		if(line4[i] == '=') {
//			char c = line4[i+1];
			zBottomGP = (float) atof(&line4[i+1]);
			break;
		}
	}
}

void getImage(FILE* f) {
	char line[100];

	fgets(line,100, f);
	for(int i = 0; i < 100; i++) {
		if(line[i] == '=') {
			//char c = line[i+1];
			imageMovementSpeed =  (float) atof(&line[i+1]);
			break;
		}
	}

	char line2[100];
	fgets(line2,100, f);
	for(int i = 0; i < 100; i++) {
		if(line2[i] == '=') {
//			char c = line2[i+1];
			imageScaleSpeed =  (float) atof(&line2[i+1]);;
			break;
		}
	}
}

void getVideo(FILE* f) {
	char line[100];

	fgets(line,100, f);
	for(int i = 0; i < 100; i++) {
		if(line[i] == '=') {
			//char c = line[i+1];
			fLeft =  (float) atof(&line[i+1]);
			break;
		}
	}

	char line2[100];
	fgets(line2,100, f);
	for(int i = 0; i < 100; i++) {
		if(line2[i] == '=') {
//			char c = line2[i+1];
			fRight =  (float) atof(&line2[i+1]);;
			break;
		}
	}

	char line3[100];
	fgets(line3,100, f);
	for(int i = 0; i < 100; i++) {
		if(line3[i] == '=') {
//			char c = line3[i+1];
			fTop =  (float) atof(&line3[i+1]);
			break;
		}
	}

	char line4[100];
	fgets(line4,100, f);
	for(int i = 0; i < 100; i++) {
		if(line4[i] == '=') {
//			char c = line4[i+1];
			fBottom = (float) atof(&line4[i+1]);
			break;
		}
	}
}

void getMPL(FILE* f) {
	char line[100];

	fgets(line,100, f);
	for(int i = 0; i < 100; i++) {
		if(line[i] == '=') {
			//char c = line[i+1];
			zLeftMPL =  (float) atof(&line[i+1]);
			break;
		}
	}

	char line2[100];
	fgets(line2,100, f);
	for(int i = 0; i < 100; i++) {
		if(line2[i] == '=') {
//			char c = line2[i+1];
			zRightMPL =  (float) atof(&line2[i+1]);;
			break;
		}
	}

	char line3[100];
	fgets(line3,100, f);
	for(int i = 0; i < 100; i++) {
		if(line3[i] == '=') {
//			char c = line3[i+1];
			zTopMPL =  (float) atof(&line3[i+1]);
			break;
		}
	}

	char line4[100];
	fgets(line4,100, f);
	for(int i = 0; i < 100; i++) {
		if(line4[i] == '=') {
//			char c = line4[i+1];
			zBottomMPL = (float) atof(&line4[i+1]);
			break;
		}
	}
}

extern void setA(int controller);
unsigned char romPath[260];
void loadIni() {

	//dprintf("Load ini\n");
	FILE* f;
	std::string t = INI_PATH + "ZsnexBox.ini";
	f = fopen(t.c_str() , "r");


	//If there is no ini create one with the default values
	if(!f) {
		//dprintf("Error opening E:\\ZsnexBox\\ini\\ZsnexBox28.ini\n");
		FILE* f;
		std::string t = INI_PATH + "ZsnexBox.ini";
		f = fopen(t.c_str(), "w");
		fclose(f);

		writeConfig();

		loadSkinIniFromFolder(skinPath);

		FILE* f2;
		f2 = fopen("D:\\Path.ini", "r");
		char line[260];
		for(int i = 0; i < 260; i++) line[i] = '\0';
		fgets(line,260, f2);
		for(int i = 0; i < 260; i++) {
			if(line[i] == '\n' || line[i] == '\0') {
				//char c = line[i+1];
				FileMenu.currentPath[i] =  '\0';
				//if(FileMenu.currentPath[i-1] == '\\') FileMenu.currentPath[i-1] = '\0';
				break;
			}
			FileMenu.currentPath[i] =  line[i];
		}
		fclose(f2);
		return;
	}

	for(int i = 0; i < 512; i++) skinPath[i] = '\0';
	//dprintf("skinPath before load from ZsnexBox28.ini: %s\n", skinPath);
	//f = fopen("E:\\ZsnexBox\\ini\\ZsnexBox.ini", "r");
	//dprintf("Screen Before: %d, %d, %d, %d\n", zLeft, zRight, zTop, zBottom);
	if(f) {
		getImage(f);
		getVideo(f);
		getSong(f);
		getGuideLines(f);
		getGuideColor(f);
		getGuideFontSize(f);
		getDimColor(f);
		getVsync(f);
		getMpType(f);
		getFontType(f);
		getLoop(f);
		getGP(f);
		getMPL(f);
		getLeftLGRumble(f);
		getRightLGRumble(f);
		getTimeLGRumble(f);
		getPixelRatio(f);
		getDisableKeyCombo(f);
		getRumbleSettings(f);
		getRomBrowserCount(f);
		getScreenShotSlot(f);
		getScreenShotSwitching(f);
		getScreenShotSpeed(f);
		getZoomSpeed(f);

		char hwcbaaaayyyyline4oq[100];
		fgets(hwcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hwcbaaaayyyyline4oq[i] == '=') {
//				char c = hwcbaaaayyyyline4oq[i+1];
				zTopCD = (int) atoi(&hwcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		getCD(f);




		char hyyydddyyline2uq[100];
		fgets(hyyydddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hyyydddyyline2uq[i] == '=') {
//				char c = hyyydddyyline2uq[i+1];
				scrollSpeed =  (float) atof(&hyyydddyyline2uq[i+1]);;
				break;
			}
		}

		char yldfakbawcbaaaayyyyline4oq[100];
		fgets(yldfakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yldfakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = yldfakbawcbaaaayyyyline4oq[i+1];
				repeatAnimation = (int) atoi(&yldfakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ldfakbawcbaaaayyyyline4oq[100];
		fgets(ldfakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ldfakbawcbaaaayyyyline4oq[i] == '=') {
////				char c = ldfakbawcbaaaayyyyline4oq[i+1];
				mouseDist = (int) atoi(&ldfakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char laine[100];

		fgets(laine,100, f);
		for(int i = 0; i < 100; i++) {
			if(laine[i] == '=') {
				//char c = line[i+1];
				animationFrames =  (int) atoi(&laine[i+1]);
				break;
			}
		}

		char line[100];

		fgets(line,100, f);
		for(int i = 0; i < 100; i++) {
			if(line[i] == '=') {
				//char c = line[i+1];
				zLeft =  (float) atof(&line[i+1]);
				break;
			}
		}

		char line2[100];
		fgets(line2,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2[i] == '=') {
//				char c = line2[i+1];
				zRight =  (float) atof(&line2[i+1]);;
				break;
			}
		}

		char line3[100];
		fgets(line3,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3[i] == '=') {
//				char c = line3[i+1];
				zTop =  (float) atof(&line3[i+1]);
				break;
			}
		}

		char line4[100];
		fgets(line4,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4[i] == '=') {
//				char c = line4[i+1];
				zBottom = (float) atof(&line4[i+1]);
				break;
			}
		}
		char line5[100];
		fgets(line5,100, f);
		for(int i = 0; i < 100; i++) {
			if(line5[i] == '=') {
//				char c = line5[i+1];
				SoftwareFilter = (int) atoi(&line5[i+1]);
				break;
			}
		}

		char line6[100];
		fgets(line6,100, f);
		for(int i = 0; i < 100; i++) {
			if(line6[i] == '=') {
//				char c = line6[i+1];
				HardwareFilter = (int) atoi(&line6[i+1]);
				break;
			}
		}

		char line7[100];
		fgets(line7,100, f);
		for(int i = 0; i < 100; i++) {
			if(line7[i] == '=') {
//				char c = line7[i+1];
				FlickerFilter = (int) atoi(&line7[i+1]);
				break;
			}
		}

		char line8[100];
		fgets(line8,100, f);
		for(int i = 0; i < 100; i++) {
			if(line8[i] == '=') {
//				char c = line8[i+1];
				Soften = (int) atoi(&line8[i+1]);
				break;
			}
		}

		char line9[100];
		fgets(line9,100, f);
		for(int i = 0; i < 100; i++) {
			if(line9[i] == '=') {
//				char c = line9[i+1];
				ShowFPS = (int) atoi(&line9[i+1]);
				break;
			}
		}

		char line10[100];
		fgets(line10,100, f);
		for(int i = 0; i < 100; i++) {
			if(line10[i] == '=') {
//				char c = line10[i+1];
				SoundFrequency = (int) atoi(&line10[i+1]);
				break;
			}
		}

		char line11[100];
		fgets(line11,100, f);
		for(int i = 0; i < 100; i++) {
			if(line11[i] == '=') {
//				char c = line11[i+1];
				SoundInterpolation = (int) atoi(&line11[i+1]);
				break;
			}
		}

		char line12[100];
		fgets(line12,100, f);
		for(int i = 0; i < 100; i++) {
			if(line12[i] == '=') {
//				char c = line12[i+1];
				LowPassFilter = (int) atoi(&line12[i+1]);
				break;
			}
		}

		char line13[100];
		fgets(line13,100, f);
		for(int i = 0; i < 100; i++) {
			if(line13[i] == '=') {
//				char c = line13[i+1];
				SurroundSound = (int) atoi(&line13[i+1]);
				break;
			}
		}

		char line14[100];
		fgets(line14,100, f);
		for(int i = 0; i < 100; i++) {
			if(line14[i] == '=') {
//				char c = line14[i+1];
				DisableMenuSounds = (int) atoi(&line14[i+1]);
				break;
			}
		}

		char line15[100];
		fgets(line15,100, f);
		for(int i = 0; i < 100; i++) {
			if(line15[i] == '=') {
//				char c = line15[i+1];
				Disable34 = (int) atoi(&line15[i+1]);
				break;
			}
		}

		char line16[100];
		fgets(line16,100, f);
		for(int i = 0; i < 100; i++) {
			if(line16[i] == '=') {
//				char c = line16[i+1];
				DisableSaveStates = (int) atoi(&line16[i+1]);
				break;
			}
		}


		for(int i2 = 0; i2 < 4; i2++) {
			char line162[100];
			fgets(line162,100, f);
			for(int i = 0; i < 100; i++) {
				if(line162[i] == '=') {
//					char c = line162[i+1];
					controllers[i2].button_A = (int) atoi(&line162[i+1]);
					break;
				}
			}

			char line17[100];
			fgets(line17,100, f);
			for(int i = 0; i < 100; i++) {
				if(line17[i] == '=') {
//					char c = line17[i+1];
					controllers[i2].button_B = (int) atoi(&line17[i+1]);
					break;
				}
			}

			char line18[100];
			fgets(line18,100, f);
			for(int i = 0; i < 100; i++) {
				if(line18[i] == '=') {
//					char c = line18[i+1];
					controllers[i2].button_X = (int) atoi(&line18[i+1]);
					break;
				}
			}

			char line19[100];
			fgets(line19,100, f);
			for(int i = 0; i < 100; i++) {
				if(line19[i] == '=') {
//					char c = line19[i+1];
					controllers[i2].button_Y = (int) atoi(&line19[i+1]);
					break;
				}
			}

			char line20[100];
			fgets(line20,100, f);
			for(int i = 0; i < 100; i++) {
				if(line20[i] == '=') {
//					char c = line20[i+1];
					controllers[i2].button_Left = (int) atoi(&line20[i+1]);
					break;
				}
			}

			char line21[100];
			fgets(line21,100, f);
			for(int i = 0; i < 100; i++) {
				if(line21[i] == '=') {
//					char c = line21[i+1];
					controllers[i2].button_Right = (int) atoi(&line21[i+1]);
					break;
				}
			}

			char line22[100];
			fgets(line22,100, f);
			for(int i = 0; i < 100; i++) {
				if(line22[i] == '=') {
//					char c = line22[i+1];
					controllers[i2].button_Select = (int) atoi(&line22[i+1]);
					break;
				}
			}

			char line23[100];
			fgets(line23,100, f);
			for(int i = 0; i < 100; i++) {
				if(line23[i] == '=') {
//					char c = line23[i+1];
					controllers[i2].button_Start = (int) atoi(&line23[i+1]);
					break;
				}
			}

			char line24[100];
			fgets(line24,100, f);
			for(int i = 0; i < 100; i++) {
				if(line24[i] == '=') {
//					char c = line24[i+1];
					controllers[i2].button_FastForward = (int) atoi(&line24[i+1]);
					break;
				}
			}

			char line25[100];
			fgets(line25,100, f);
			for(int i = 0; i < 100; i++) {
				if(line25[i] == '=') {
//					char c = line25[i+1];
					controllers[i2].button_Rewind = (int) atoi(&line25[i+1]);
					break;
				}
			}

			char line26[100];
			fgets(line26,100, f);
			for(int i = 0; i < 100; i++) {
				if(line26[i] == '=') {
//					char c = line26[i+1];
					controllers[i2].button_LoadState = (int) atoi(&line26[i+1]);
					break;
				}
			}

			char line27[100];
			fgets(line27,100, f);
			for(int i = 0; i < 100; i++) {
				if(line27[i] == '=') {
//					char c = line27[i+1];
					controllers[i2].button_SaveState = (int) atoi(&line27[i+1]);
					break;
				}
			}

			char line28[100];
			fgets(line28,100, f);
			for(int i = 0; i < 100; i++) {
				if(line28[i] == '=') {
//					char c = line28[i+1];
					controllers[i2].button_ExitGame = (int) atoi(&line28[i+1]);
					break;
				}
			}

			char line29[100];
			fgets(line29,100, f);
			for(int i = 0; i < 100; i++) {
				if(line29[i] == '=') {
//					char c = line29[i+1];
					controllers[i2].button_ShowFPS = (int) atoi(&line29[i+1]);
					break;
				}
			}
		}	

		char line50[100];
		fgets(line50,100, f);
		for(int i = 0; i < 100; i++) {
			if(line50[i] == '=') {
//				char c = line50[i+1];
				HDMode = (unsigned char) atoi(&line50[i+1]);
				if(HDMode != 1 && HDMode != 2 && HDMode != 0) HDMode = 0;
				break;
			}
		}

		char line31[100];
		fgets(line31,100, f);
		for(int i = 0; i < 100; i++) {
			if(line31[i] == '=') {
//				char c = line31[i+1];
				XBINPUT_DEADZONE =  (float) atof(&line31[i+1]);
				break;
			}
		}

		char line291[100];
		fgets(line291,100, f);
		for(int i = 0; i < 100; i++) {
			if(line291[i] == '=') {
//				char c = line291[i+1];
				ShowInfo = (int) atoi(&line291[i+1]);
				break;
			}
		}

		char lline[100];
		fgets(lline,100, f);
		for(int i = 0; i < 100; i++) {
			if(lline[i] == '=') {
				//char c = line[i+1];
				BGVol =  (float) atof(&lline[i+1]);
				break;
			}
		}

		//HideFileExtension
		char line2912[100];
		fgets(line2912,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2912[i] == '=') {
//				char c = line2912[i+1];
				HideFileExtension = (int) atoi(&line2912[i+1]);
				break;
			}
		}


		char line29123[100];
		fgets(line29123,100, f);
		for(int i = 0; i < 100; i++) {
			if(line29123[i] == '=') {
//				char c = line29123[i+1];
				ReverseStereo = (int) atoi(&line29123[i+1]);
				break;
			}
		}

		char eline29123[100];
		fgets(eline29123,100, f);
		for(int i = 0; i < 100; i++) {
			if(eline29123[i] == '=') {
//				char c = eline29123[i+1];
				ScreenshotSaving = (int) atoi(&eline29123[i+1]);
				break;
			}
		}

		for(int i2 = 0; i2 < 4; i2++) {
			char line162[100];
			fgets(line162,100, f);
			for(int i = 0; i < 100; i++) {
				if(line162[i] == '=') {
//					char c = line162[i+1];
					tButtons[i2].turboA = (int) atoi(&line162[i+1]);
					break;
				}
			}

			char line17[100];
			fgets(line17,100, f);
			for(int i = 0; i < 100; i++) {
				if(line17[i] == '=') {
//					char c = line17[i+1];
					tButtons[i2].turboB = (int) atoi(&line17[i+1]);
					break;
				}
			}

			char line18[100];
			fgets(line18,100, f);
			for(int i = 0; i < 100; i++) {
				if(line18[i] == '=') {
//					char c = line18[i+1];
					tButtons[i2].turboX = (int) atoi(&line18[i+1]);
					break;
				}
			}

			char line19[100];
			fgets(line19,100, f);
			for(int i = 0; i < 100; i++) {
				if(line19[i] == '=') {
//					char c = line19[i+1];
					tButtons[i2].turboY = (int) atoi(&line19[i+1]);
					break;
				}
			}

			char line20[100];
			fgets(line20,100, f);
			for(int i = 0; i < 100; i++) {
				if(line20[i] == '=') {
//					char c = line20[i+1];
					tButtons[i2].turboL = (int) atoi(&line20[i+1]);
					break;
				}
			}

			char line21[100];
			fgets(line21,100, f);
			for(int i = 0; i < 100; i++) {
				if(line21[i] == '=') {
//					char c = line21[i+1];
					tButtons[i2].turboR = (int) atoi(&line21[i+1]);
					break;
				}
			}


		}
		//char line212[100];
		//fgets(line212,100, f);
		//for(int i = 0; i < 100; i++) {
		//	if(line212[i] == '=') {
		////		char c = line212[i+1];
		//		map34 = (int) atoi(&line212[i+1]);
		//		break;
		//	}
		//}

		char liney[100];
		fgets(liney,100, f);
		for(int i = 0; i < 100; i++) {
			if(liney[i] == '=') {
				//char c = line[i+1];
				zLeftP =  (float) atof(&liney[i+1]);
				break;
			}
		}

		char line2u[100];
		fgets(line2u,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2u[i] == '=') {
//				char c = line2u[i+1];
				zRightP =  (float) atof(&line2u[i+1]);;
				break;
			}
		}

		char line3i[100];
		fgets(line3i,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3i[i] == '=') {
//				char c = line3i[i+1];
				zTopP =  (float) atof(&line3i[i+1]);
				break;
			}
		}

		char line4o[100];
		fgets(line4o,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4o[i] == '=') {
//				char c = line4o[i+1];
				zBottomP = (float) atof(&line4o[i+1]);
				break;
			}
		}



		char lineyq[100];
		fgets(lineyq,100, f);
		for(int i = 0; i < 100; i++) {
			if(lineyq[i] == '=') {
				//char c = line[i+1];
				zLeftJ =  (float) atof(&lineyq[i+1]);
				break;
			}
		}

		char line2uq[100];
		fgets(line2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2uq[i] == '=') {
//				char c = line2uq[i+1];
				zRightJ =  (float) atof(&line2uq[i+1]);;
				break;
			}
		}

		char line3iq[100];
		fgets(line3iq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3iq[i] == '=') {
//				char c = line3iq[i+1];
				zTopJ =  (float) atof(&line3iq[i+1]);
				break;
			}
		}

		char line4oq[100];
		fgets(line4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4oq[i] == '=') {
//				char c = line4oq[i+1];
				zBottomJ = (float) atof(&line4oq[i+1]);
				break;
			}
		}
		char line20x[100];
		fgets(line20x,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20x[i] == '=') {
//				char c = line20x[i+1];
				GameNameColor = (int) atoi(&line20x[i+1]);
				break;
			}
		}

		char line20xv[100];
		fgets(line20xv,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xv[i] == '=') {
//				char c = line20xv[i+1];
				GameNameSelectedColor = (int) atoi(&line20xv[i+1]);
				break;
			}
		}

		char line20xvg[100];
		fgets(line20xvg,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvg[i] == '=') {
//				char c = line20xvg[i+1];
				FolderColor = (int) atoi(&line20xvg[i+1]);
				break;
			}
		}

		char line20xvgw[100];
		fgets(line20xvgw,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgw[i] == '=') {
//				char c = line20xvgw[i+1];
				MenuOption = (int) atoi(&line20xvgw[i+1]);
				break;
			}
		}

		char line20xvgwq[100];
		fgets(line20xvgwq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwq[i] == '=') {
//				char c = line20xvgwq[i+1];
				MenuOptionSelected = (int) atoi(&line20xvgwq[i+1]);
				break;
			}
		}

		char line20xvgwqe[100];
		fgets(line20xvgwqe,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqe[i] == '=') {
//				char c = line20xvgwqe[i+1];
				FontSizeGUI = (int) atoi(&line20xvgwqe[i+1]);
				break;
			}
		}

		char line20xvgwqeu[100];
		fgets(line20xvgwqeu,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeu[i] == '=') {
//				char c = line20xvgwqeu[i+1];
				FullNameColor = (int) atoi(&line20xvgwqeu[i+1]);
				break;
			}
		}

		char line20xvgwqeue[100];
		fgets(line20xvgwqeue,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeue[i] == '=') {
//				char c = line20xvgwqeue[i+1];
				showTransparency = (int) atoi(&line20xvgwqeue[i+1]);
				break;
			}
		}

		char line20xvgwqeuee[100];
		fgets(line20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeuee[i] == '=') {
//				char c = line20xvgwqeuee[i+1];
				HighRes = (int) atoi(&line20xvgwqeuee[i+1]);
				break;
			}
		}




		char lineyq1[100];
		fgets(lineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(lineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftB =  (float) atof(&lineyq1[i+1]);
				break;
			}
		}

		char line2uq1[100];
		fgets(line2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2uq1[i] == '=') {
//				char c = line2uq1[i+1];
				zRightB =  (float) atof(&line2uq1[i+1]);;
				break;
			}
		}

		char line3iq1[100];
		fgets(line3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3iq1[i] == '=') {
//				char c = line3iq1[i+1];
				zTopB =  (float) atof(&line3iq1[i+1]);
				break;
			}
		}

		char line4oq1[100];
		fgets(line4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4oq1[i] == '=') {
//				char c = line4oq1[i+1];
				zBottomB = (float) atof(&line4oq1[i+1]);
				break;
			}
		}
		//
		char line20xvgwqeue1[100];
		fgets(line20xvgwqeue1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeue1[i] == '=') {
//				char c = line20xvgwqeue1[i+1];
				EnableAudioAdjust = (int) atoi(&line20xvgwqeue1[i+1]);
				break;
			}
		}

		char alineyq1[100];
		fgets(alineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(alineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftA =  (float) atof(&alineyq1[i+1]);
				zLeftA2 = zLeftA;
				break;
			}
		}

		char aaline2uq1[100];
		fgets(aaline2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaline2uq1[i] == '=') {
//				char c = aaline2uq1[i+1];
				zRightA =  (float) atof(&aaline2uq1[i+1]);;
				zRightA2 = zRightA;
				break;
			}
		}

		char aaaline3iq1[100];
		fgets(aaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaline3iq1[i] == '=') {
//				char c = aaaline3iq1[i+1];
				zTopA =  (float) atof(&aaaline3iq1[i+1]);
				zTopA2 = zTopA;
				break;
			}
		}

		char aaaaline4oq1[100];
		fgets(aaaaline4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaaline4oq1[i] == '=') {
//				char c = aaaaline4oq1[i+1];
				zBottomA = (float) atof(&aaaaline4oq1[i+1]);
				zBottomA2 = zBottomA;
				break;
			}
		}

		char qalineyq1[100];
		fgets(qalineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qalineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftS =  (float) atof(&qalineyq1[i+1]);
				break;
			}
		}

		char qqaaline2uq1[100];
		fgets(qqaaline2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qqaaline2uq1[i] == '=') {
//				char c = qqaaline2uq1[i+1];
				zRightS =  (float) atof(&qqaaline2uq1[i+1]);;
				break;
			}
		}

		char qqqaaaline3iq1[100];
		fgets(qqqaaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qqqaaaline3iq1[i] == '=') {
//				char c = qqqaaaline3iq1[i+1];
				zTopS =  (float) atof(&qqqaaaline3iq1[i+1]);
				break;
			}
		}

		char qqqqaaaaline4oq1[100];
		fgets(qqqqaaaaline4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qqqqaaaaline4oq1[i] == '=') {
//				char c = qqqqaaaaline4oq1[i+1];
				zBottomS = (float) atof(&qqqqaaaaline4oq1[i+1]);
				break;
			}
		}

		char laine20xvgwqeuee[100];
		fgets(laine20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(laine20xvgwqeuee[i] == '=') {
//				char c = laine20xvgwqeuee[i+1];
				vSpace = (int) atoi(&laine20xvgwqeuee[i+1]);
				break;
			}
		}

		char laaine20xvgwqeuee[100];
		fgets(laaine20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(laaine20xvgwqeuee[i] == '=') {
//				char c = laaine20xvgwqeuee[i+1];
				FontSizeGUI = (int) atoi(&laaine20xvgwqeuee[i+1]);
				break;
			}
		}

		char rlaaine20xvgwqeuee[100];
		fgets(rlaaine20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(rlaaine20xvgwqeuee[i] == '=') {
//				char c = rlaaine20xvgwqeuee[i+1];
				animationFPS = (int) atoi(&rlaaine20xvgwqeuee[i+1]);
				break;
			}
		}

		char gqqqaaaline3iq1[100];
		fgets(gqqqaaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(gqqqaaaline3iq1[i] == '=') {
//				char c = gqqqaaaline3iq1[i+1];
				animationSpeed =  (float) atof(&gqqqaaaline3iq1[i+1]);
				break;
			}
		}

		char oliney[100];
		fgets(oliney,100, f);
		for(int i = 0; i < 100; i++) {
			if(oliney[i] == '=') {
				//char c = line[i+1];
				zLeftPB =  (float) atof(&oliney[i+1]);
				break;
			}
		}

		char ooline2u[100];
		fgets(ooline2u,100, f);
		for(int i = 0; i < 100; i++) {
			if(ooline2u[i] == '=') {
//				char c = ooline2u[i+1];
				zRightPB =  (float) atof(&ooline2u[i+1]);;
				break;
			}
		}

		char oooline3i[100];
		fgets(oooline3i,100, f);
		for(int i = 0; i < 100; i++) {
			if(oooline3i[i] == '=') {
//				char c = oooline3i[i+1];
				zTopPB =  (float) atof(&oooline3i[i+1]);
				break;
			}
		}

		char ooooline4o[100];
		fgets(ooooline4o,100, f);
		for(int i = 0; i < 100; i++) {
			if(ooooline4o[i] == '=') {
//				char c = ooooline4o[i+1];
				zBottomPB = (float) atof(&ooooline4o[i+1]);
				break;
			}
		}




		char ylineyq[100];
		fgets(ylineyq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ylineyq[i] == '=') {
				//char c = line[i+1];
				zLeftG =  (float) atof(&ylineyq[i+1]);
				break;
			}
		}

		char yyline2uq[100];
		fgets(yyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyline2uq[i] == '=') {
//				char c = yyline2uq[i+1];
				zRightG =  (float) atof(&yyline2uq[i+1]);;
				break;
			}
		}

		char yyyline3iq[100];
		fgets(yyyline3iq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyyline3iq[i] == '=') {
//				char c = yyyline3iq[i+1];
				zTopG =  (float) atof(&yyyline3iq[i+1]);
				break;
			}
		}

		char yyyyline4oq[100];
		fgets(yyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyyyline4oq[i] == '=') {
//				char c = yyyyline4oq[i+1];
				zBottomG = (float) atof(&yyyyline4oq[i+1]);
				break;
			}
		}

		char ayyyyline4oq[100];
		fgets(ayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ayyyyline4oq[i] == '=') {
//				char c = ayyyyline4oq[i+1];
				transparency = (int) atoi(&ayyyyline4oq[i+1]);
				break;
			}
		}

		char aayyyyline4oq[100];
		fgets(aayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aayyyyline4oq[i] == '=') {
//				char c = aayyyyline4oq[i+1];
				zTopBR = (int) atoi(&aayyyyline4oq[i+1]);
				break;
			}
		}

		char aaayyyyline4oq[100];
		fgets(aaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaayyyyline4oq[i] == '=') {
//				char c = aaayyyyline4oq[i+1];
				zLeftBR = (int) atoi(&aaayyyyline4oq[i+1]);
				break;
			}
		}

		char aaaayyyyline4oq[100];
		fgets(aaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaayyyyline4oq[i] == '=') {
//				char c = aaaayyyyline4oq[i+1];
				zTopBF = (int) atoi(&aaaayyyyline4oq[i+1]);
				break;
			}
		}

		char aaaaaayyyyline4oq[100];
		fgets(aaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaaaayyyyline4oq[i] == '=') {
//				char c = aaaaaayyyyline4oq[i+1];
				zLeftBF = (int) atoi(&aaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char baaaayyyyline4oq[100];
		fgets(baaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(baaaayyyyline4oq[i] == '=') {
//				char c = baaaayyyyline4oq[i+1];
				zTopV = (int) atoi(&baaaayyyyline4oq[i+1]);
				break;
			}
		}

		char bbaaaaaayyyyline4oq[100];
		fgets(bbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(bbaaaaaayyyyline4oq[i] == '=') {
//				char c = bbaaaaaayyyyline4oq[i+1];
				zLeftV = (int) atoi(&bbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char cbaaaayyyyline4oq[100];
		fgets(cbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(cbaaaayyyyline4oq[i] == '=') {
//				char c = cbaaaayyyyline4oq[i+1];
				zTopSM = (int) atoi(&cbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ccbbbaaaaaayyyyline4oq[100];
		fgets(ccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ccbbbaaaaaayyyyline4oq[i+1];
				zLeftSM = (int) atoi(&ccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char wcbaaaayyyyline4oq[100];
		fgets(wcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(wcbaaaayyyyline4oq[i] == '=') {
//				char c = wcbaaaayyyyline4oq[i+1];
				zTopGM = (int) atoi(&wcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char wwccbbbaaaaaayyyyline4oq[100];
		fgets(wwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(wwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = wwccbbbaaaaaayyyyline4oq[i+1];
				zLeftGM = (int) atoi(&wwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char awcbaaaayyyyline4oq[100];
		fgets(awcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(awcbaaaayyyyline4oq[i] == '=') {
//				char c = awcbaaaayyyyline4oq[i+1];
				zTopMM = (int) atoi(&awcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char aawwccbbbaaaaaayyyyline4oq[100];
		fgets(aawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = aawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftMM = (int) atoi(&aawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}


		char bawcbaaaayyyyline4oq[100];
		fgets(bawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(bawcbaaaayyyyline4oq[i] == '=') {
//				char c = bawcbaaaayyyyline4oq[i+1];
				zTopEO = (int) atoi(&bawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char bbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(bbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(bbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = bbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftEO = (int) atoi(&bbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}


		char kbawcbaaaayyyyline4oq[100];
		fgets(kbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(kbawcbaaaayyyyline4oq[i] == '=') {
//				char c = kbawcbaaaayyyyline4oq[i+1];
				zTopCO = (int) atoi(&kbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ibbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(ibbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ibbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ibbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftCO = (int) atoi(&ibbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char akbawcbaaaayyyyline4oq[100];
		fgets(akbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(akbawcbaaaayyyyline4oq[i] == '=') {
//				char c = akbawcbaaaayyyyline4oq[i+1];
				zTopTO = (int) atoi(&akbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char sibbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(sibbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sibbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = sibbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftTO = (int) atoi(&sibbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char gakbawcbaaaayyyyline4oq[100];
		fgets(gakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(gakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = gakbawcbaaaayyyyline4oq[i+1];
				zTopCCO = (int) atoi(&gakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ggsibbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(ggsibbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ggsibbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ggsibbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftCCO = (int) atoi(&ggsibbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char fayyyyline4oq[100];
		fgets(fayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(fayyyyline4oq[i] == '=') {
//				char c = fayyyyline4oq[i+1];
				showBorder = (int) atoi(&fayyyyline4oq[i+1]);
				break;
			}
		}

		char tline20xvgwqeue[100];
		fgets(tline20xvgwqeue,100, f);
		for(int i = 0; i < 100; i++) {
			if(tline20xvgwqeue[i] == '=') {
//				char c = tline20xvgwqeue[i+1];
				fadeSpeed = (int) atoi(&tline20xvgwqeue[i+1]);
				break;
			}
		}

		char raaaayyyyline4oq[100];
		fgets(raaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(raaaayyyyline4oq[i] == '=') {
//				char c = raaaayyyyline4oq[i+1];
				zTopGT = (int) atoi(&raaaayyyyline4oq[i+1]);
				break;
			}
		}

		char rraaaaaayyyyline4oq[100];
		fgets(rraaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(rraaaaaayyyyline4oq[i] == '=') {
//				char c = rraaaaaayyyyline4oq[i+1];
				zLeftGT = (int) atoi(&rraaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char draaaayyyyline4oq[100];
		fgets(draaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(draaaayyyyline4oq[i] == '=') {
//				char c = draaaayyyyline4oq[i+1];
				zTopIT = (int) atoi(&draaaayyyyline4oq[i+1]);
				break;
			}
		}

		char jrraaaaaayyyyline4oq[100];
		fgets(jrraaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(jrraaaaaayyyyline4oq[i] == '=') {
//				char c = jrraaaaaayyyyline4oq[i+1];
				zLeftIT = (int) atoi(&jrraaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char sdraaaayyyyline4oq[100];
		fgets(sdraaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sdraaaayyyyline4oq[i] == '=') {
//				char c = sdraaaayyyyline4oq[i+1];
				zTopCC = (int) atoi(&sdraaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ssjrraaaaaayyyyline4oq[100];
		fgets(ssjrraaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ssjrraaaaaayyyyline4oq[i] == '=') {
//				char c = ssjrraaaaaayyyyline4oq[i+1];
				zLeftCC = (int) atoi(&ssjrraaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char sbaaaayyyyline4oq[100];
		fgets(sbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sbaaaayyyyline4oq[i] == '=') {
//				char c = sbaaaayyyyline4oq[i+1];
				zTopHT = (int) atoi(&sbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ssbbaaaaaayyyyline4oq[100];
		fgets(ssbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ssbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ssbbaaaaaayyyyline4oq[i+1];
				zLeftHT = (int) atoi(&ssbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}



		char jgakbawcbaaaayyyyline4oq[100];
		fgets(jgakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(jgakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = jgakbawcbaaaayyyyline4oq[i+1];
				lC = (int) atoi(&jgakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}
		char sakbawcbaaaayyyyline4oq[100];
		fgets(sakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = sakbawcbaaaayyyyline4oq[i+1];
				rC = (int) atoi(&sakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char fakbawcbaaaayyyyline4oq[100];
		fgets(fakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(fakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = fakbawcbaaaayyyyline4oq[i+1];
				lCWidth = (int) atoi(&fakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char hakbawcbaaaayyyyline4oq[100];
		fgets(hakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = hakbawcbaaaayyyyline4oq[i+1];
				rCHeight = (int) atoi(&hakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char dfakbawcbaaaayyyyline4oq[100];
		fgets(dfakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dfakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = dfakbawcbaaaayyyyline4oq[i+1];
				rWidth = (int) atoi(&dfakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}






		char ralineyq1[100];
		fgets(ralineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(ralineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftAR =  (float) atof(&ralineyq1[i+1]);
				zLeftA2R = zLeftAR;
				break;
			}
		}

		char rraaline2uq1[100];
		fgets(rraaline2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(rraaline2uq1[i] == '=') {
//				char c = rraaline2uq1[i+1];
				zRightAR =  (float) atof(&rraaline2uq1[i+1]);;
				zRightA2R = zRightAR;
				break;
			}
		}

		char rrraaaline3iq1[100];
		fgets(rrraaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(rrraaaline3iq1[i] == '=') {
//				char c = rrraaaline3iq1[i+1];
				zTopAR =  (float) atof(&rrraaaline3iq1[i+1]);
				zTopA2R = zTopAR;
				break;
			}
		}

		char rrrraaaaline4oq1[100];
		fgets(rrrraaaaline4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(rrrraaaaline4oq1[i] == '=') {
//				char c = rrrraaaaline4oq1[i+1];
				zBottomAR = (float) atof(&rrrraaaaline4oq1[i+1]);
				zBottomA2R = zBottomAR;
				break;
			}
		}

		char dyyline2uq[100];
		fgets(dyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dyyline2uq[i] == '=') {
//				char c = dyyline2uq[i+1];
				distA =  (float) atof(&dyyline2uq[i+1]);;
				break;
			}
		}

		char ddyyline2uq[100];
		fgets(ddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ddyyline2uq[i] == '=') {
//				char c = ddyyline2uq[i+1];
				minA =  (float) atof(&ddyyline2uq[i+1]);;
				break;
			}
		}

		char dddyyline2uq[100];
		fgets(dddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dddyyline2uq[i] == '=') {
//				char c = dddyyline2uq[i+1];
				maxA =  (float) atof(&dddyyline2uq[i+1]);;
				break;
			}
		}




		char ydyyline2uq[100];
		fgets(ydyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ydyyline2uq[i] == '=') {
//				char c = ydyyline2uq[i+1];
				distA2 =  (float) atof(&ydyyline2uq[i+1]);;
				break;
			}
		}

		char yyddyyline2uq[100];
		fgets(yyddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyddyyline2uq[i] == '=') {
//				char c = yyddyyline2uq[i+1];
				minA2 =  (float) atof(&yyddyyline2uq[i+1]);;
				break;
			}
		}

		char yyydddyyline2uq[100];
		fgets(yyydddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyydddyyline2uq[i] == '=') {
//				char c = yyydddyyline2uq[i+1];
				maxA2 =  (float) atof(&yyydddyyline2uq[i+1]);;
				break;
			}
		}

		char dyyydddyyline2uq[100];
		fgets(dyyydddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dyyydddyyline2uq[i] == '=') {
//				char c = dyyydddyyline2uq[i+1];
				cDist =  (int) atoi(&dyyydddyyline2uq[i+1]);;
				break;
			}
		}
		char hdyyydddyyline2uq[100];
		fgets(hdyyydddyyline2uq,100, f);
		std::string n = hdyyydddyyline2uq;
		int p = n.find('=', 0);
		///dprintf("Going to parse: %s\n", n.c_str());
		for(int id = p+1; id < 512+p+1; id++) {
			////dprintf("id is: %d\n", id);
			if((n[id] == '\0') || (n[id] == '\n') || (n[id] == '\t') || (n[id] == EOF)) {
				////dprintf("Going to break: %d\n", id);
				skinPath[id-(p+1)] = '\0';
				////dprintf("Just set skinPath at %d to NULL. Break Now\n", id-(p+1));
				if(f) fclose(f);

				setA(0);
				setA(1);
				setA(2);
				setA(3);

				FILE* f2;
				f2 = fopen("D:\\Path.ini", "r");
				char line[260];
				for(int i = 0; i < 260; i++) line[i] = '\0';
				fgets(line,260, f2);
				for(int i = 0; i < 260; i++) {
					if(line[i] == '\n' || line[i] == '\0') {
						//char c = line[i+1];
						FileMenu.currentPath[i] =  '\0';
						break;
					}
					FileMenu.currentPath[i] =  line[i];
				}
				fclose(f2);
				return;
				break;
			}
			else {
				skinPath[id-(p+1)] = n[id];
			}
		}
	}
	else {
	}

	if(f) fclose(f);

	setA(0);
	setA(1);
	setA(2);
	setA(3);

	FILE* f2;
	f2 = fopen("D:\\Path.ini", "r");
	char line[260];
	for(int i = 0; i < 260; i++) line[i] = '\0';
	fgets(line,260, f2);
	for(int i = 0; i < 260; i++) {
		if(line[i] == '\n' || line[i] == '\0') {
			//char c = line[i+1];
			FileMenu.currentPath[i] =  '\0';
			break;
		}
		FileMenu.currentPath[i] =  line[i];
	}
	fclose(f2);
	return;
}

extern "C" setHardwareFilter();
extern void initCheatCodes();
extern void loadCheat();

void loadPath() {
	FILE* f;
	f = fopen("D:\\Path.ini" , "r");


	if(!f) {
		//dprintf("Couldn't open Path.ini\n");
		return;
	}

	char ggdbLeft[100];
	fgets(ggdbLeft,100, f);
	for(int i = 0; i < 100; i++) {
		if(ggdbLeft[i] == '=') {
			usePathINI = (int) atoi(&ggdbLeft[i+1]);
			break;
		}
	}

	if(usePathINI == 1) {
		//dprintf("UseINI = 1\n");
		char a1[512]; for(int t = 0; t < 512; t++) a1[t] = '\0'; fgets(a1, 512, f);
		for(int z = 0; z < 512; z++) {
			if(a1[z] == '\n') {
				a1[z] = '\0';
			}
		}
		BOOKMARK_PATH = a1;

		char a[512]; for(int t = 0; t < 512; t++) a[t] = '\0'; fgets(a, 512, f);
		for(int z = 0; z < 512; z++) {
			if(a[z] == '\n') {
				a[z] = '\0';
			}
		}
		ARTWORK_SHOTS_1_PATH = a;

		char b[512]; for(int t = 0; t < 512; t++) b[t] = '\0'; fgets(b, 512, f);
		for(int z = 0; z < 512; z++) {
			if(b[z] == '\n') {
				b[z] = '\0';
			}
		}
		ARTWORK_SHOTS_2_PATH  = b;

		char c[512]; for(int t = 0; t < 512; t++) c[t] = '\0'; fgets(c, 512, f);
		for(int z = 0; z < 512; z++) {
			if(c[z] == '\n') {
				c[z] = '\0';
			}
		}
		ARTWORK_SHOTS_3_PATH = c;

		char d[512]; for(int t = 0; t < 512; t++) d[t] = '\0'; fgets(d, 512, f);
		for(int z = 0; z < 512; z++) {
			if(d[z] == '\n') {
				d[z] = '\0';
			}
		}
		ARTWORK_SHOTS_4_PATH  = d;

		char g[512]; for(int t = 0; t < 512; t++) g[t] = '\0'; fgets(g, 512, f);
		for(int z = 0; z < 512; z++) {
			if(g[z] == '\n') {
				g[z] = '\0';
			}
		}
		ARTWORK_SHOTS_5_PATH  = g;

		char h[512]; for(int t = 0; t < 512; t++) h[t] = '\0'; fgets(h, 512, f);
		for(int z = 0; z < 512; z++) {
			if(h[z] == '\n') {
				h[z] = '\0';
			}
		}
		ARTWORK_SHOTS_6_PATH  = h;

		char j[512]; for(int t = 0; t < 512; t++) j[t] = '\0'; fgets(j, 512, f);
		for(int z = 0; z < 512; z++) {
			if(j[z] == '\n') {
				j[z] = '\0';
			}
		}
		ARTWORK_SHOTS_7_PATH  = j;

		char k[512]; for(int t = 0; t < 512; t++) k[t] = '\0'; fgets(k, 512, f);
		for(int z = 0; z < 512; z++) {
			if(k[z] == '\n') {
				k[z] = '\0';
			}
		}
		ARTWORK_SHOTS_8_PATH  = k;

		char m[512]; for(int t = 0; t < 512; t++) m[t] = '\0'; fgets(m, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m[z] == '\n') {
				m[z] = '\0';
			}
		}
		SRAM_PATH  = m;

		char m3[512]; for(int t = 0; t < 512; t++) m3[t] = '\0'; fgets(m3, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m3[z] == '\n') {
				m3[z] = '\0';
			}
		}
		SAVE_PATH  = m3;

		char m32[512]; for(int t = 0; t < 512; t++) m32[t] = '\0'; fgets(m32, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m32[z] == '\n') {
				m32[z] = '\0';
			}
		}
		INI_PATH  = m32;

		char m322[512]; for(int t = 0; t < 512; t++) m322[t] = '\0'; fgets(m322, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m322[z] == '\n') {
				m322[z] = '\0';
			}
		}
		RUMBLE_PATH  = m322;

		char m3222[512]; for(int t = 0; t < 512; t++) m3222[t] = '\0'; fgets(m3222, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m3222[z] == '\n') {
				m3222[z] = '\0';
			}
		}
		CHEATS_PATH  = m3222;

		char m3222d[512]; for(int t = 0; t < 512; t++) m3222d[t] = '\0'; fgets(m3222d, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m3222d[z] == '\n') {
				m3222d[z] = '\0';
			}
		}
		GARBAGE_PATH  = m3222d;

		char m3222dd[512]; for(int t = 0; t < 512; t++) m3222dd[t] = '\0'; fgets(m3222dd, 512, f);
		for(int z = 0; z < 512; z++) {
			if(m3222dd[z] == '\n') {
				m3222dd[z] = '\0';
			}
		}
		romBasePath  = m3222dd;

		char videoPath[512]; for(int t = 0; t < 512; t++) videoPath[t] = '\0'; fgets(videoPath, 512, f);
		for(int z = 0; z < 512; z++) {
			if(videoPath[z] == '\n') {
				videoPath[z] = '\0';
			}
		}
		VIDEO_PATH  = videoPath;

		FILE *f2 = fopen((INI_PATH + "ZsnexBox.ini").c_str() , "r");
		if(!f2) {
		}
		else {
			fclose(f2);
		}
		fclose(f);
	}
	else {
		//dprintf("Create directores\n");
		mkdir("E:\\ZsnexBox");
		mkdir("E:\\ZsnexBox\\artwork");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 1");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 2");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 3");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 4");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 5");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 6");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 7");
		mkdir("E:\\ZsnexBox\\artwork\\Shots 8");
		mkdir("E:\\ZsnexBox\\sram");
		mkdir("E:\\ZsnexBox\\save");
		mkdir("E:\\ZsnexBox\\ini");
		mkdir("E:\\ZsnexBox\\rumble");
		mkdir("E:\\ZsnexBox\\cheats");
		mkdir("E:\\ZsnexBox\\garbage");
		mkdir("E:\\ZsnexBox\\bookmarks");

		//dprintf("Made bookmarks\n");

		ARTWORK_SHOTS_1_PATH = "E:\\ZsnexBox\\artwork\\Shots 1\\";
		ARTWORK_SHOTS_2_PATH  = "E:\\ZsnexBox\\artwork\\Shots 2\\";
		ARTWORK_SHOTS_3_PATH = "E:\\ZsnexBox\\artwork\\Shots 3\\";
		ARTWORK_SHOTS_4_PATH  = "E:\\ZsnexBox\\artwork\\Shots 4\\";
		ARTWORK_SHOTS_5_PATH  = "E:\\ZsnexBox\\artwork\\Shots 5\\";
		ARTWORK_SHOTS_6_PATH  = "E:\\ZsnexBox\\artwork\\Shots 6\\";
		ARTWORK_SHOTS_7_PATH  = "E:\\ZsnexBox\\artwork\\Shots 7\\";
		ARTWORK_SHOTS_8_PATH  = "E:\\ZsnexBox\\artwork\\Shots 8\\";
		SRAM_PATH  = "E:\\ZsnexBox\\sram\\";
		SAVE_PATH  = "E:\\ZsnexBox\\save\\";
		INI_PATH  = "E:\\ZsnexBox\\ini\\";
		RUMBLE_PATH  = "E:\\ZsnexBox\\rumble\\";
		CHEATS_PATH  = "E:\\ZsnexBox\\cheats\\";
		GARBAGE_PATH  = "E:\\ZsnexBox\\garbage\\";
		romBasePath  = "D:\\roms\\";
		BOOKMARK_PATH = "E:\\ZsnexBox\\bookmarks\\";


		FILE *f2 = fopen((INI_PATH + "ZsnexBox.ini").c_str() , "r");
		if(!f2) {
		}
		else {
			fclose(f2);
		}
		fclose(f);
	}
}



extern int SetupMatrices();

int commandLineLaunch = 0;
extern "C" {
	extern int bCount;
}
extern int screenOptions;
#include "iosupport.h"
#include "iso9660.h"


extern CISO9660 m_iso9660 ;
extern HANDLE m_cdrom ;
extern CIoSupport m_io ;

//-----------------------------------------------------------------------------
// Name: XBUtil_Timer()
// Desc: Performs timer operations. Use the following commands:
//          TIMER_RESET           - to reset the timer
//          TIMER_START           - to start the timer
//          TIMER_STOP            - to stop (or pause) the timer
//          TIMER_ADVANCE         - to advance the timer by 0.1 seconds
//          TIMER_GETABSOLUTETIME - to get the absolute system time
//          TIMER_GETAPPTIME      - to get the current time
//-----------------------------------------------------------------------------
//FLOAT XBUtil_Timer( TIMER_COMMAND command )
extern int animationFPS;
extern float animationSpeed;

float lastTime = 0;
float currentTime = 0;
LARGE_INTEGER ticksPerSecond;
LARGE_INTEGER tick;   // A point in time
LARGE_INTEGER time;   // For converting tick into real time
int animateFrame() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond);
	// what time is it?
	QueryPerformanceCounter(&tick);


	if(lastTime == 0) {
		lastTime = (FLOAT)tick.QuadPart;
		return 0;
	}

	if((((FLOAT)tick.QuadPart) - lastTime) >= (((FLOAT)ticksPerSecond.QuadPart) / 60.0f)) {//1 second has passed
		lastTime = (FLOAT)tick.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}


float lastTimeLightGun = 0;
float currentTimeLightGun = 0;
LARGE_INTEGER ticksPerSecondLightGun;
LARGE_INTEGER tickLightGun;   // A point in time
LARGE_INTEGER timeLightGun;   // For converting tick into real time
int LightGunRumbleOver() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond);
	// what time is it?
	QueryPerformanceCounter(&tickLightGun);


	if(lastTimeLightGun == 0) {
		lastTimeLightGun = (FLOAT)tickLightGun.QuadPart;
		return 0;
	}

	if((((FLOAT)tickLightGun.QuadPart) - lastTimeLightGun) >= (((FLOAT)ticksPerSecondLightGun.QuadPart) * timeRumblelg)) {//1 second has passed
		lastTimeLightGun = (FLOAT)tickLightGun.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}




float lastTimevg = 0;
float currentTimevg = 0;
LARGE_INTEGER ticksPerSecondvg;
LARGE_INTEGER tickvg;   // A point in time
LARGE_INTEGER timevg;   // For converting tick into real time
extern int musicSpeed;
int animateFramevg() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond);
	// what time is it?
	QueryPerformanceCounter(&tickvg);


	if(lastTimevg == 0) {
		lastTimevg = (FLOAT)tickvg.QuadPart;
		return 0;
	}

	if((((FLOAT)tickvg.QuadPart) - lastTimevg) >= 
		((((FLOAT)ticksPerSecondvg.QuadPart) / 60.0f) )) {//1 second has passed
			lastTimevg = (FLOAT)tickvg.QuadPart;
			return 1;
		}
	else {
		return 0;
	}
}


float lastTimevg2 = 0;
float currentTimevg2 = 0;
LARGE_INTEGER ticksPerSecondvg2;
LARGE_INTEGER tickvg2;   // A point in time
LARGE_INTEGER timevg2;   // For converting tick into real time
extern int musicSpeed;
int animateFramevg2() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond);
	// what time is it?
	QueryPerformanceCounter(&tickvg2);


	if(lastTimevg2 == 0) {
		lastTimevg2 = (FLOAT)tickvg2.QuadPart;
		return 0;
	}

	if((((FLOAT)tickvg2.QuadPart) - lastTimevg2) >= 
		((((FLOAT)ticksPerSecondvg2.QuadPart) ) )) {//1 second has passed
			lastTimevg2 = (FLOAT)tickvg2.QuadPart;
			return 1;
		}
	else {
		return 0;
	}
}


float lastTimej = 0;
float currentTimej = 0;
LARGE_INTEGER ticksPerSecondj;
LARGE_INTEGER tickj;   // A point in time
LARGE_INTEGER timej;   // For converting tick into real time
int animateFramej() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond);
	// what time is it?
	QueryPerformanceCounter(&tickj);


	if(lastTimej == 0) {
		lastTimej = (FLOAT)tickj.QuadPart;
		return 0;
	}

	if((((FLOAT)tickj.QuadPart) - lastTimej) >= (((FLOAT)ticksPerSecondj.QuadPart) / 60.0f) * 2) {//1 second has passed
		lastTimej = (FLOAT)tickj.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}


float lastTime2 = 0;
float currentTime2 = 0;
LARGE_INTEGER ticksPerSecond2;
LARGE_INTEGER tick2;   // A point in time
LARGE_INTEGER time2;   // For converting tick into real time
int animateStationaryFrame() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond2);
	// what time is it?
	QueryPerformanceCounter(&tick2);


	if(lastTime2 == 0) {
		lastTime2 = (FLOAT)tick2.QuadPart;
		return 0;
	}


	if((((FLOAT)tick2.QuadPart) - lastTime2) >= ((((FLOAT)ticksPerSecond2.QuadPart) / 60.0f) * animationFPS)) {//1 second has passed
		lastTime2 = (FLOAT)tick2.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}


extern float screenShotSpeed;
float lastTimeScreenShotSwitch = 0;
float currentTimeScreenShotSwitch = 0;
LARGE_INTEGER ticksPerSecondScreenShotSwitch;
LARGE_INTEGER tickScreenShotSwitch;   // A point in time
LARGE_INTEGER timeScreenShotSwitch;   // For converting tick into real time
int screenShotAuto = 1;
int animateScreenShot() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond2);
	// what time is it?
	QueryPerformanceCounter(&tickScreenShotSwitch);


	if(lastTimeScreenShotSwitch == 0) {
		lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
		return 0;
	}


	if((((FLOAT)tickScreenShotSwitch.QuadPart) - lastTimeScreenShotSwitch) >= ((((FLOAT)ticksPerSecondScreenShotSwitch.QuadPart)) * screenShotSpeed)) {//1 second has passed
		lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}


float lastTime23 = 0;
float currentTime23 = 0;
LARGE_INTEGER ticksPerSecond23;
LARGE_INTEGER tick23;   // A point in time
LARGE_INTEGER time23;   // For converting tick into real time
int stransparency = 255;

int animateStationarySplash() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond23);
	// what time is it?
	QueryPerformanceCounter(&tick23);


	if(lastTime23 == 0) {
		lastTime23 = (FLOAT)tick23.QuadPart;
		return 0;
	}

	if(firstFrame == 0) {
		if((((FLOAT)tick23.QuadPart) - lastTime23) >= ((((FLOAT)ticksPerSecond23.QuadPart) * 0.50f))) {//3 second has passed
			lastTime23 = 0;//tick23.QuadPart;
			firstFrame = 1;
			playEffect(3);
			return 0;
		}
		return 0;
	}

	if((((FLOAT)tick23.QuadPart) - lastTime23) >= ((((FLOAT)ticksPerSecond23.QuadPart) * 1.50f))) {//3 second has passed
		lastTime23 = (FLOAT)tick23.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}

float lastTime3 = 0;
float currentTime3 = 0;
LARGE_INTEGER ticksPerSecond3;
LARGE_INTEGER tick3;   // A point in time
LARGE_INTEGER time3;   // For converting tick into real time
int animateStationaryFrame2() {


	// get the high resolution counter's accuracy
	//QueryPerformanceFrequency(&ticksPerSecond3);
	// what time is it?
	QueryPerformanceCounter(&tick3);


	if(lastTime3 == 0) {
		lastTime3 = (FLOAT)tick3.QuadPart;
		return 0;
	}


	float elapsedTime = (((FLOAT)tick3.QuadPart) - lastTime3); 
	float timePassed = (((FLOAT)elapsedTime) / ((FLOAT)ticksPerSecond3.QuadPart));

	if((timePassed) >= (1.0f / 120.0f)) {//1/60 second has passed
		lastTime3 = (FLOAT)tick3.QuadPart;
		return 1;
	}
	else {
		return 0;
	}
}






//Rumble Timers
float lastTimeMotorOneRumble = 0;
float currentTimeMotorOneRumble = 0;
LARGE_INTEGER ticksPerSecondMotorOneRumble;
LARGE_INTEGER tickMotorOneRumble;   // A point in time
LARGE_INTEGER timeMotorOneRumble;   // For converting tick into real time
void resetMotorOneRumbleTimer() {
	QueryPerformanceCounter(&tickMotorOneRumble);
	lastTimeMotorOneRumble = (FLOAT)tickMotorOneRumble.QuadPart;
}
float motorOneTime = 0;
bool MotorOneRumbleOver() {
	QueryPerformanceCounter(&tickMotorOneRumble);
	if(lastTimeMotorOneRumble == 0) {
		lastTimeMotorOneRumble = (FLOAT)tickMotorOneRumble.QuadPart;
		return false;
	}
	if((((FLOAT)tickMotorOneRumble.QuadPart) - lastTimeMotorOneRumble) >= (((FLOAT)ticksPerSecondMotorOneRumble.QuadPart)  *  motorOneTime)) {//1 second has passed
		lastTimeMotorOneRumble = (FLOAT)tickMotorOneRumble.QuadPart;
		return true;
	}
	else {
		return false;
	}
}


float lastTimeMotorTwoRumble = 0;
float currentTimeMotorTwoRumble = 0;
LARGE_INTEGER ticksPerSecondMotorTwoRumble;
LARGE_INTEGER tickMotorTwoRumble;   // A point in time
LARGE_INTEGER timeMotorTwoRumble;   // For converting tick into real time
void resetMotorTwoRumbleTimer() {
	QueryPerformanceCounter(&tickMotorTwoRumble);
	lastTimeMotorTwoRumble = (FLOAT)tickMotorTwoRumble.QuadPart;
}
float motorTwoTime = 0;
bool MotorTwoRumbleOver() {
	QueryPerformanceCounter(&tickMotorTwoRumble);
	if(lastTimeMotorTwoRumble == 0) {
		lastTimeMotorTwoRumble = (FLOAT)tickMotorTwoRumble.QuadPart;
		return false;
	}
	if((((FLOAT)tickMotorTwoRumble.QuadPart) - lastTimeMotorTwoRumble) >= (((FLOAT)ticksPerSecondMotorTwoRumble.QuadPart)  *  motorTwoTime)) {//1 second has passed
		lastTimeMotorTwoRumble = (FLOAT)tickMotorTwoRumble.QuadPart;
		return true;
	}
	else {
		return false;
	}
}

int LoopInit()
{
	for(int i = 0; i < 512; i++) currentSongName[i] = '\0';
	for(int i = 0; i < 512; i++) skinPath[i] = '\0';
	skinPath[0] = 'M';
	skinPath[1] = 'e';
	skinPath[2] = 't';
	skinPath[3] = 'r';
	skinPath[4] = 'o';
	skinPath[5] = 'i';
	skinPath[6] = 'd';
	skinPath[7] = '\0';
	int ret=0;
	QueryPerformanceFrequency(&ticksPerSecond);
	QueryPerformanceFrequency(&ticksPerSecondLightGun);
	QueryPerformanceFrequency(&ticksPerSecondvg);
	QueryPerformanceFrequency(&ticksPerSecondvg2);
	QueryPerformanceFrequency(&ticksPerSecond2);
	QueryPerformanceFrequency(&ticksPerSecond23);
	QueryPerformanceFrequency(&ticksPerSecond3);
	QueryPerformanceFrequency(&ticksPerSecondj);
	QueryPerformanceFrequency(&ticksPerSecondScreenShotSwitch);
	QueryPerformanceFrequency(&ticksPerSecondMotorOneRumble);
	QueryPerformanceFrequency(&ticksPerSecondMotorTwoRumble);
	menuColor[0] = 0xffffffff;
	menuColor[1] = 0xffff0000;
	menuColor[2] = 0xff00ff00;
	menuColor[3] = 0xff0000ff;
	menuColor[4] = 0xffffff00;
	menuColor[5] = 0x00000000;
	ret=EmuInit(); if (ret) return 1;
	Unmount("C:");
	Unmount("E:");
	Unmount("F:");
	Unmount("G:");
	Unmount("R:");
	Unmount("X:");
	Unmount("Y:");
	Unmount("Z:");
	Mount("C:", "Harddisk0\\Partition2");
	Mount("E:", "Harddisk0\\Partition1");
	Mount("F:", "Harddisk0\\Partition6");
	Mount("G:", "Harddisk0\\Partition7");
	Mount("X:", "Harddisk0\\Partition3");
    Mount("Y:", "Harddisk0\\Partition4");
    Mount("Z:", "Harddisk0\\Partition5");
	Mount("R:","Cdrom0");
	
	dprintf("Before load path\n");
	loadPath();
	dprintf("After load path\n");


	selected = 1;
	FileMenu.choiceFocus = 0;
	y2 = 0;
	inputInit();
	optionSelected = 6;
	initControllers();
	SoftwareFilter = 17;
	Surround = 0;
	
	dprintf("Before load ini\n");
	loadIni();
	dprintf("After load ini\n");
	
	
	//loadHelp();




	FileMenu.init();
	ret=DirectInit(); if (ret) return 1;
	setHardwareFilter();
	initCheatCodes();
	initMusic();
	effectInit();
	setVolume();

	


	string q = currentSongName;
	if(q != "Default") {
		FILE *f = fopen(q.c_str(), "r");
		if(f) {
			fclose(f);
			pauseMusic();
			if(InitVGMusic((char*)q.c_str()) == -1) 
				resumeMusic();
		}
	}

	setHeight(FontSizeGUI);
	
	//buildCheatCodeList();
	//buildCheatCodeListAR();
	//buildCheatCodeListTips();
	
	
	//Test
	std::string path = romBasePath;
	searchDirectory(path, false);
	//In LoopInit 
	rumbleList.clear(); 
	activeRumble = 0; 
	for(int i = 0; i < 10; i++) { 
		rumbleSetting r; 
		r.isActive = false; 
		r.address = 0; 
		r.bank = 0; 
		r.rumbleType = 0; 
		r.currentValue = 0; 
		r.previousValue = 0; 
		r.description = "No Description Found" ;
		r.motorOneStrength = 0; 
		r.motorTwoStrength = 0; 
		r.motorOneTime = 0; 
		r.motorTwoTime = 0; 
		r.controller = 0; 
		r.rumbleCount = 0; 
		r.rumbleTarget = 0;
		rumbleList.push_back(r); 
	} 
	StartLightGun();

	commandLineLaunch = 0;
	XGetCustomLaunchData();

	
	if(g_autoLaunchGame == 1) {
		commandLineLaunch = 1;
		SetupMatrices();
		unsigned char *lock=NULL;
		makeVertexListLinear();
		VertexBufferLinear->Lock(0,sizeof(VertexListLinear),&lock,0); if (lock==NULL) return 1;
		memcpy(lock,VertexListLinear,sizeof(VertexListLinear));
		VertexBufferLinear->Unlock();
		Device->SetTexture(0,TexScreen);
		Device->SetStreamSource(0,VertexBufferLinear,sizeof(CustomVertex));
		Device->SetVertexShader(D3DFVF_CUSTOMVERTEX);
		Device->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
		Device->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
		selected = 1;
		FileMenu.choiceFocus = 0;
		y2 = 0;
		lastChoice = 80;
		stransparency = 0; 
		splash = 0;
		fade = 1;
		screenOptionsM = 0;
		startCommanLine(g_launchData.szFilename);
	}
	return 0;
}

void LoopExit()
{
	FileMenu.exit();
	EmuExit();
	//DSoundExit(); DSoundSeg=0;
	//	InputExit();
	DirectExit();

	if (DebugFile) fclose(DebugFile);
	DebugFile=NULL;
}

// ----------------------------------------------------------------

int DoGame()
{
	//EmuFrame();

	//	if (Inp.held[7]==1) { resumeMusic(); LoopMode=2; LoopCode(); } // Right thumb = Toggle Menu

	return 0;
}
// ----------------------------------------------------------------

int buttonPressed = 0;
bool fastScroll = false;

bool a = false;
bool b = false;
bool c = false;
bool gameRunning = false;

extern "C" unsigned char fname[512];
extern "C" unsigned char fnames[512];
extern "C" unsigned char fnamest[512];

int threadIsValid = 1;
int screenResize = 0;
int screenResizeP = 0;
int screenResizeI = 0;

int screenResizePB = 0;
int screenResizeJ = 0;
int screenResizeB = 0;
int screenResizeA = 0;
int screenResizeA2 = 0;
int screenOptionsM = 1;
int screenOptionsHelp = 0;
int screenResizeS = 0;
int screenControllerOptions = 0;
int screenCheatOptions = 0;
int screenVideoOptions = 0;
int screenSoundOptions = 0;
extern int screenMPOptions ;
int screenLightGunOptions = 0;
int screenGeneralOptions = 0;
int screenGeneralOptionsGG = 0;

int screenGeneralOptionsTGA = 0;
int screenGeneralOptionsGGText = 0;
int screenGUIOptions = 0;
int screenOptions = 0;

//DWORD WINAPI ThreadFunc( LPVOID lpParam )  {
//	//zstart();
//	//threadIsValid = 0;
//	return 0;
//}
//
//void startThread() {
//	DWORD dwThreadId, dwThrdParam = 1; 
//	HANDLE hThread; 
//
//
//	hThread = CreateThread( 
//		NULL,                        // (this parameter is ignored)
//		0,                           // use default stack size  
//		ThreadFunc,                  // thread function 
//		&dwThrdParam,                // argument to thread function 
//		0,                           // use default creation flags 
//		&dwThreadId);                // returns the thread identifier 
//}



float zTop = -0.68f;
float zLeft = -0.5f;
float zBottom = 0.7f;
float zRight = 0.64f;


float zTopMPL = -0.179999f;
float zLeftMPL = 1.69f;
float zBottomMPL = 0.33f;
float zRightMPL = -0.85f;

float zTopP = -0.179999f;
float zLeftP = 1.69f;
float zBottomP = 0.33f;
float zRightP = -0.85f;


float zTopGP = -0.179999f;
float zLeftGP = 1.69f;
float zBottomGP = 0.33f;
float zRightGP = -0.85f;


float zTopPB = 0.489999f;
float zLeftPB =0.900001f;
float zBottomPB = -0.7f;
float zRightPB = -0.010000f;


int refreshPal = 0;



void setTexture() {
	Device->SetTexture(0,TexScreen);
	Device->SetStreamSource(0,VertexBufferLinear,sizeof(CustomVertex));
	Device->SetVertexShader(D3DFVF_CUSTOMVERTEX);

	//GUIQuit = 0;
	//Device->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
	//Device->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );

	// Note: The hardware requires CLAMP for linear textures
	Device->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
	Device->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );

}
bool optionScreen = 0;



extern "C" {
	extern unsigned char GUIOn2;
	extern unsigned char SoundInterpType;
	extern unsigned char LowPassFilterType;
	extern unsigned char SoundQuality;
	extern unsigned char cfgSoundQuality;
	extern void AdjustFrequency();
}
extern BOOL InitSound();

extern void showMemory();

extern bool v720pAvailable; 
extern bool v480pAvailable; 
extern bool v1080iAvailable; 
extern int HDMode;
extern int pixelRatio;
int vsyncEnabled = 0;
void restoreResolution() { //done on game exit or resize screen exit 
	

	if(v480pAvailable) { //480p
		sWidth = 640;
		sHeight = 480;

		if(pixelRatio == 1)
			d3dpp.Flags = D3DPRESENTFLAG_PROGRESSIVE  | D3DPRESENTFLAG_10X11PIXELASPECTRATIO;
		else
			d3dpp.Flags = D3DPRESENTFLAG_PROGRESSIVE;

		d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8 ; 
		d3dpp.BackBufferWidth  = sWidth; 
		d3dpp.BackBufferHeight  = sHeight;  

		if(vsyncEnabled == 1) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
		if(vsyncEnabled == 0) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;//DEFAULT;//ONE;
		if(vsyncEnabled == 2) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_TWO;
		if(vsyncEnabled == 3) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_THREE;

		Device->Reset(&d3dpp); 
		Device->Clear(0,NULL,D3DCLEAR_TARGET,0x0,1.0f,0);
		if(showAvailMemory) showMemory();
		Device->Present( NULL, NULL, NULL, NULL ); 
		Device->SetFlickerFilter(FlickerFilter) ; 
		Device->SetSoftDisplayFilter(Soften) ; 
		return; 
	} 
	else { //480i
		if(vsyncEnabled == 1) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
		if(vsyncEnabled == 0) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;//DEFAULT;//ONE;
		if(vsyncEnabled == 2) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_TWO;
		if(vsyncEnabled == 3) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_THREE;

		sWidth = 640;
		sHeight = 480;

		if(pixelRatio == 1)
			d3dpp.Flags = D3DPRESENTFLAG_INTERLACED  | D3DPRESENTFLAG_10X11PIXELASPECTRATIO;
		else
			d3dpp.Flags = D3DPRESENTFLAG_INTERLACED;

		d3dpp.BackBufferFormat = D3DFMT_LIN_R5G6B5 ; 
		d3dpp.BackBufferWidth  = sWidth; 
		d3dpp.BackBufferHeight  = sHeight;  
		Device->Reset(&d3dpp); 
		Device->Clear(0,NULL,D3DCLEAR_TARGET,0x0,1.0f,0);
		if(showAvailMemory) showMemory();
		Device->Present( NULL, NULL, NULL, NULL ); 
		Device->SetFlickerFilter(FlickerFilter) ; 
		Device->SetSoftDisplayFilter(Soften) ; 
		return; 
	} 
	return; 
} 

void startHDMode() { 
	if(HDMode == 0) return; //480i or 480p

	if(HDMode == 1) {//720p 
		if(vsyncEnabled == 1) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
		if(vsyncEnabled == 0) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;//DEFAULT;//ONE;
		if(vsyncEnabled == 2) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_TWO;
		if(vsyncEnabled == 3) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_THREE;
		sWidth = 1280;
		sHeight = 720;
		d3dpp.Flags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN ; 
		d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8 ; 
		d3dpp.BackBufferWidth  = 1280; 
		d3dpp.BackBufferHeight  = 720; 
		Device->Reset(&d3dpp); 
		Device->Clear(0,NULL,D3DCLEAR_TARGET,0x0,1.0f,0);
		if(showAvailMemory) showMemory();
		Device->Present( NULL, NULL, NULL, NULL ); 
		Device->SetFlickerFilter(FlickerFilter) ; 
		Device->SetSoftDisplayFilter(Soften) ; 
	} 
	if(HDMode == 2) { //1080i
		if(vsyncEnabled == 1) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
		if(vsyncEnabled == 0) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;//DEFAULT;//ONE;
		if(vsyncEnabled == 2) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_TWO;
		if(vsyncEnabled == 3) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_THREE;
		sWidth = 1920;
		sHeight = 1080;
		d3dpp.Flags = D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_INTERLACED ; 
		d3dpp.BackBufferFormat = D3DFMT_LIN_R5G6B5 ; 
		d3dpp.BackBufferWidth  = 1920; 
		d3dpp.BackBufferHeight = 1080; 
		Device->Reset(&d3dpp); 
		Device->Clear(0,NULL,D3DCLEAR_TARGET,0x0,1.0f,0); 
		if(showAvailMemory) showMemory();
		Device->Present( NULL, NULL, NULL, NULL ); 
		Device->SetFlickerFilter(FlickerFilter) ; 
		Device->SetSoftDisplayFilter(Soften) ; 
	} 
} 
extern int forcePal;
void setFlickerSoft() {
	DWORD videoFlags = XGetVideoFlags();
	if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
	{
		if(forcePal == 0) { 
			//set pal60 if available.
			if(videoFlags & XC_VIDEO_FLAGS_PAL_60Hz)
				d3dpp.FullScreen_RefreshRateInHz = 60 ;
			else
				d3dpp.FullScreen_RefreshRateInHz = 50 ;
		}
		else {
			d3dpp.FullScreen_RefreshRateInHz = 50 ;
		}
	}
	else
		d3dpp.FullScreen_RefreshRateInHz = 60 ;

	if(vsyncEnabled == 1) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
	if(vsyncEnabled == 0) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;//DEFAULT;//ONE;
	if(vsyncEnabled == 2) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_TWO;
	if(vsyncEnabled == 3) d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_THREE;

	Device->Reset(&d3dpp);
	Device->Clear(0,NULL,D3DCLEAR_TARGET,0x0,1.0f,0);
	if(showAvailMemory) showMemory();
	Device->Present( NULL, NULL, NULL, NULL );
	Device->SetFlickerFilter(FlickerFilter);
	Device->SetSoftDisplayFilter( Soften);
}

void processOptions() {
	if(SoundFrequency == 0) {
		SoundQuality = 5;
		cfgSoundQuality = 5;
	}
	else if(SoundFrequency == 1) {
		SoundQuality = 3;
		cfgSoundQuality = 3;
	}
	else if(SoundFrequency == 2) {
		SoundQuality = 6;
		cfgSoundQuality = 6;
	}
	if(SurroundSound == 1) {
		Surround = 1; 
	}
	else {
		Surround = 0;
	}
	if(SoundInterpolation == 0) {
		SoundInterpType = 1;
	}
	if(SoundInterpolation == 1) {
		SoundInterpType = 2;
	}
	if(SoundInterpolation == 2) {
		SoundInterpType = 3;
	}

	if(LowPassFilter == 0) {
		LowPassFilterType = 0;
	}
	if(LowPassFilter == 1) {
		LowPassFilterType = 1;
	}
	if(LowPassFilter == 2) {
		LowPassFilterType = 2;
	}
	if(LowPassFilter == 3) {
		LowPassFilterType = 3;
	}
}

//extern void setVertex();
int firstVidRender = 0;
extern int d;
extern int y2;

extern "C" {
	extern unsigned char ForceROMTiming;
	extern unsigned char pl3contrl;
	extern unsigned char pl4contrl;
	extern unsigned char KeyQuickRst;

}
int Disable34 = 0;


extern float zA;
int checkOptions() {

	if(optionSelected == 6) { if(DisableMenuSounds == 0) playEffect(2);screenVideoOptions = 1; screenOptions = 0; return 0; } 
	if(optionSelected == 7) { if(DisableMenuSounds == 0) playEffect(2);screenSoundOptions = 1; screenOptions = 0; return 0; }
	if(optionSelected == 8) { if(DisableMenuSounds == 0) playEffect(2);screenControllerOptions = 1;   screenOptions = 0; return 0; }
	if(optionSelected == 9) { if(DisableMenuSounds == 0) playEffect(2);screenGeneralOptions = 1;   screenOptions = 0; return 0; }
	if(optionSelected == 10 ) { if(DisableMenuSounds == 0) playEffect(2); guiOptionSelected = 0; screenOptions = 0; screenGUIOptions = 1; gFont = 3; }
	if(optionSelected == 11) { if(DisableMenuSounds == 0) playEffect(2);screenMPOptions = 1; screenOptions = 0;  return 0; }

	//if(optionSelected == 10) { if(DisableMenuSounds == 0) playEffect(2);screenGUIOptions = 1;   screenOptions = 0; return 0; }
	//if(optionSelected == 10) { 

	//}
	//if(optionSelected == 11) { if(DisableMenuSounds == 0) playEffect(1);screenOptions = 0; screenOptionsM = 1; zA = 0;return 0;}



	return 0;
}
extern int root;

extern "C" {
	extern void blankScreen();

}
extern void freeTexture();
extern  void writeConfig();
extern void checkVideoOptions();
extern void checkSoundOptions();
extern int page;
extern int pageMove;
int romMove = 1;

char commandLinePath[1024];

void startCommanLine(char* commandLineName) {
	for(int i = 0; i < 512; i++) fname[i] = '\0';
	for(int i = 0; i < 512; i++) fnames[i] = '\0';
	for(int i = 0; i < 512; i++) fnamest[i] = '\0';
	for(int i = 0; i < 1024; i++) commandLinePath[i] = '\0';


	for(int i = 0; i < 1024; i++) {
		if(commandLineName[i] == '\0') {
			commandLinePath[i] = '\0';
			break;
		}
		else {
			commandLinePath[i] = commandLineName[i];
		}
	}

	inGame = 1;
	//blankScreen();
	firstVidRender = 1;

	setVertex();

	pauseMusic();
	//gameRunning = true;
	//FileMenu.getFilePath(commandLineName);
	//RomLoad();
	LoopMode=8; // Go to game

	//dprintf("commmandLinePath: %s\n", commandLinePath);



	//g:\c\fzero.zip
	//e = 4
	//size = 14;

	std::string commandName = commandLinePath;
	int e = commandName.rfind("\\");
	//dprintf("Last backslash postition: %d\n", e);
	//dprintf("commandName size: %d\n", commandName.size());

	commandName = commandName.substr(e+1, ((commandName.size())-(e+1))); 
	//dprintf("commandName is: %s\n", commandName.c_str());

	fileDisplay temp;
	temp.archive = 0;
	temp.isADirectory = false;
	temp.isAGame = true;
	temp.isARoot = false;
	temp.name = commandName;
	std::string r = commandLinePath;
	temp.path = r;
	temp.topLevel = false;
	fileList.clear();
	fileList.push_back(temp);
	FileMenuSelected = 0;

	loadCheat();
	//LoadRumbleFile();

	//dprintf("Before fname set in command line\n");

	fname[0] = commandLinePath[0];
	for(int i = 1; i < 1024; i++) {
		if(commandLinePath[i-1] == '\0') {
			fname[i] = commandLinePath[i-1];
			break;
		}
		else {
			fname[i] = commandLinePath[i-1];
		}
	}
	//dprintf("fname is: %s\n", fname);

	//Setup fnames
	FILE* f;
	std::string t = SRAM_PATH;
	std::string a = fileList[FileMenuSelected].name;
	a[a.size()-3] = 's';
	a[a.size()-2] = 'r';
	a[a.size()-1] = 'm';
	t = t + a;
	//dprintf("t is: %s\n", t.c_str());
	for(int i = 0; i < 512; i++) fnames[i] = '\0';
	fnames[0] = t[0];
	for(int i = 1; i < 512+1; i++) {
		if(t[i-1] == '\0') {
			fnames[i] = t[i-1];
			break;
		}
		else {
			fnames[i] = t[i-1];
		}
	}	

	//dprintf("Command Line fnames: %s\n", fnames);
	//Setup fnamest
	std::string t2 = SAVE_PATH;
	std::string a2 =  fileList[FileMenuSelected].name;
	a2[a2.size()-3] = 'z';
	a2[a2.size()-2] = 's';
	a2[a2.size()-1] = 't';
	t2 = t2 + a2;

	//dprintf("t2 is: %s\n", t2.c_str());
	for(int i = 0; i < 512; i++) fnamest[i] = '\0';
	fnamest[0] = t2[0];
	for(int i = 1; i < 512+1; i++) {
		if(t2[i-1] == '\0') {
			fnamest[i] = t2[i-1];
			break;
		}
		else {
			fnamest[i] = t2[i-1];
		}
	}	

	//dprintf("Command Line fnamest: %s\n", fnamest);


	createSaveStateDirectories();
	SaveSlot(0);
	zstart();
}

extern int displayRumbleConfig;


int MenuUpdate()
{
	if (g_Gamepads[0].fY2 > 0 && inGame != 1 
		&& screenResize != 1 && screenResizeP != 1   && screenResizeI != 1 && screenResizeMovie != 1
		&& screenResizeGP != 1 && screenResizeMPL != 1 && screenResizeJ != 1 
		&& screenResizeG != 1 && fontResizeClip != 1 && screenResizeB != 1 
		&& screenResizeA != 1 && screenResizeA2 != 1 && screenResizeS != 1 
		&& musicMode != 1 && screenResizePB != 1) {BGVol += 10.0f; setVolume(); }// Up
	if (g_Gamepads[0].fY2 < 0 && inGame != 1 && screenResize != 1 && screenResizeMovie != 1
		&& screenResizeP != 1   && screenResizeI != 1 && screenResizeGP != 1 
		&& screenResizeMPL != 1 && screenResizeJ != 1 && screenResizeG != 1 
		&& fontResizeClip != 1 && screenResizeB != 1 && screenResizeA != 1 
		&& screenResizeA2 != 1 && screenResizeS != 1 && musicMode != 1 
		&& screenResizePB != 1) {BGVol -= 10.0f; setVolume();}
	if(musicPlayer == 1) {
		if(musicMode == 0) {
			if(g_Gamepads[0].Event == XBGAMEPAD_X) {
				if(vgplaying == 1) stopMusic();
				resetThemeSong();
				//resumeMusic();
				for(int i = 0; i < 512; i++) currentSongName[i] = '\0';
				currentSongName[0] = 'D';
				currentSongName[1] = 'e';
				currentSongName[2] = 'f';
				currentSongName[3] = 'a';
				currentSongName[4] = 'u';
				currentSongName[5] = 'l';
				currentSongName[6] = 't';
				currentSongName[7] = '\0';
				writeConfig();
			}
		}
		else {
			if(g_Gamepads[0].Event == XBGAMEPAD_WHITE) {
				if(vgplaying == 1) nextTrack();  
			}
			if(g_Gamepads[0].Event == XBGAMEPAD_BLACK) {
				if(vgplaying == 1) previousTrack();
			}
			if(g_Gamepads[0].Event == XBGAMEPAD_X) {
				if(vgplaying == 1) {			  
					stopMusic();
					
				}
				for(int i = 0; i < 512; i++) currentSongName[i] = '\0';
				currentSongName[0] = 'D';
				currentSongName[1] = 'e';
				currentSongName[2] = 'f';
				currentSongName[3] = 'a';
				currentSongName[4] = 'u';
				currentSongName[5] = 'l';
				currentSongName[6] = 't';
				currentSongName[7] = '\0';
				resetThemeSong();
				writeConfig();
			}
		}
	}


	if(g_Gamepads[0].Event == XBGAMEPAD_Y && lightGun == 1 && correctAppState() == 1) {
		lightGun = 0;
		Device->SetTexture( 3, NULL );
		Device->SetTextureStageState( 3, D3DTSS_COLOROP, D3DTOP_DISABLE );
		Device->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
		Device->SetRenderState( D3DRS_POINTSCALEENABLE,  FALSE );
		Device->SetRenderState( D3DRS_ALPHABLENDENABLE,  FALSE );
		return 0;
	}

	if(lightGun == 1) {
		ProcessLightGun();
		return 0;
	}

	if(screenSoundOptions == 1) {
		checkSoundOptions();
		return 0;
	}


	if(archiveMode == 1) {
		processArchiveList();
		return 0;
	}


	if(screenGeneralOptionsMP == 1) {
		checkMPOptions();
		return 0;
	}

	if(screenMPOptions == 1) {
		checkMPOptions();
		return 0;
	}

	if(screenGeneralOptions == 1) {
		checkGeneralOptions();
		return 0;
	}

	if(screenGUIOptions == 1) {
		checkGUIOptions();
		return 0;
	}

	if(screenVideoOptions == 1) {
		checkVideoOptions();
		//processOptions();
		return 0;
	}








	if(screenOptions == 1) {
		//Change menu options here
		if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_UP) {  
			if(DisableMenuSounds == 0)playEffect(0);	
			optionSelected -= 1; 
			if(inGame == 1) {
				if(optionSelected < 0) optionSelected = 9; 
			}
			else {
				if(optionSelected < 6) optionSelected = 11;
			}
		}
		if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_DOWN) {  
			if(DisableMenuSounds == 0)playEffect(0);	
			optionSelected += 1; 
			if(inGame == 1) {
				if(optionSelected > 9) optionSelected = 0;
			}
			else {
				if(optionSelected > 11) optionSelected = 6;
			}

		} 

		if(g_Gamepads[0].Event == XBGAMEPAD_A) {
			int r = checkOptions();
			return r;
		}

		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenOptions = 0;
			screenOptionsM = 1;
			//fadeColor = 255;
			//fadeColor2 = 0;
			zA = 0;
			return 0;
		}
		return 0;
	}





	//if (Inp.held[9]==1) { Surround ^= 1; }
	//if (Inp.held[10]==1) { SoftwareFilter = (SoftwareFilter + 1) & 0x03; }



	if(screenControllerOptions == 1) {
		//if(g_Gamepads[0].Event == XBGAMEPAD_A) {
		//	screenController = 0;
		////	screenOptions = 1;
		//	screenResize = 0;
		//	return 0;
		//}
		checkControllerConfig();
		return 0;
	}




	if(screenResize == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResize = 0;
			LoopMode = 2;
			writeConfig();

			screenVideoOptions = 1;
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTop+=0.01f;  zBottom+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTop-=0.01f;  zBottom-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeft-=0.01f; zRight-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeft+=0.01f; zRight+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottom+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottom-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRight-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRight+=0.01f; // Right


		return 0; 

	}
	/*
	
	*/

	if(screenResizeP == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeP = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopP+=0.01f;  zBottomP+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopP-=0.01f;  zBottomP-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftP-=0.01f; zRightP-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftP+=0.01f; zRightP+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomP+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomP-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightP-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightP+=0.01f; // Right


		return 0; 

	}


	if(screenResizeMovie == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeMovie = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			stopMovie();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 < 0) {fTop+=1;  fBottom+=1; }// Up
		if (g_Gamepads[0].fY1 > 0) {fTop-=1;  fBottom-=1; } // Down
		if (g_Gamepads[0].fX1 < 0) {fLeft-=1; fRight-=1; } // Left
		if (g_Gamepads[0].fX1 > 0) {fLeft+=1; fRight+=1; }// Right

		if (g_Gamepads[0].fY2 < 0) fBottom+=1; // Up
		if (g_Gamepads[0].fY2 > 0) fBottom-=1; // Down
		if (g_Gamepads[0].fX2 < 0) fRight-=1; // Left
		if (g_Gamepads[0].fX2 > 0) fRight+=1; // Right


		return 0; 

	}

	if(screenResizeI == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeI = 0;
			LoopMode = 2;
			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopP+=0.01f;  zBottomP+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopP-=0.01f;  zBottomP-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftP-=0.01f; zRightP-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftP+=0.01f; zRightP+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomP+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomP-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightP-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightP+=0.01f; // Right


		return 0; 

	}

	if(screenResizeGP == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeGP = 0; screenMPOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopGP+=0.01f;  zBottomGP+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopGP-=0.01f;  zBottomGP-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftGP-=0.01f; zRightGP-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftGP+=0.01f; zRightGP+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomGP+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomGP-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightGP-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightGP+=0.01f; // Right


		return 0; 

	}


	if(screenResizeMPL == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeMPL = 0; screenMPOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopMPL-=1;  zBottomMPL+=1; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopMPL+=1;  zBottomMPL-=1; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftMPL-=1; zRightMPL-=1; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftMPL+=1; zRightMPL+=1; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomMPL-=1; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomMPL+=1; // Down
		if (g_Gamepads[0].fX2 < 0) zRightMPL-=1; // Left
		if (g_Gamepads[0].fX2 > 0) zRightMPL+=1; // Right


		return 0; 

	}

	if(screenResizeE == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeE = 0; screenOptionsM = 1;
			LoopMode = 2;
			fadeColor = 255;
			fadeColor2 = 255;
			return 0;
		}

		if(g_Gamepads[0].Event == XBGAMEPAD_Y) {
			//closeWave();


			writeConfig();
			LD_LAUNCH_DASHBOARD launch;
			memset(&launch,0,sizeof(launch));
			launch.dwReason=XLD_LAUNCH_DASHBOARD_MAIN_MENU;
			XLaunchNewImage(NULL,(LAUNCH_DATA *)&launch); 
			return 0;
		}
		return 0;
	}

	if(screenResizePB == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizePB = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopPB+=0.01f;  zBottomPB+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopPB-=0.01f;  zBottomPB-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftPB-=0.01f; zRightPB-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftPB+=0.01f; zRightPB+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomPB+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomPB-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightPB-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightPB+=0.01f; // Right


		return 0; 

	}


	if(screenGeneralOptionsGGText == 1) {
		checkGeneralOptionsGGText();
		return 0;
	}

	if(screenOptionsHelp == 1) {
		checkGeneralOptionsGG();
		return 0; 

	}

	if(screenOptionsM == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_A) {
			if(DisableMenuSounds == 0) playEffect(2);


			if(optionSelectedM == 0 ) {
				//dprintf("Loading rombrowser from main menu\n");

				if(backupChanged == 0) {
					FileMenuSelected = 0;
					std::string path = romBasePath;
					searchDirectory(path, false);
				}
				else {
					restoreRomBrowser();
				}

				favorites = 0;
				fadeOption = 0; fadeColor = 255; fadeColor2 = 255;screenOptionsM = 0; 
				screenOptions = 0; currentStationaryFrame = 0; screenGUIOptions = 0;
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
			}

			if(optionSelectedM == 1 ) {
				//dprintf("Loading favorites from main menu\n");
				buildFavorites();
				favorites = 1;
				fadeOption = 0; fadeColor = 255; 
				fadeColor2 = 255;
				screenOptionsM = 0; 
				screenOptions = 0; 
				currentStationaryFrame = 0; 
				screenGUIOptions = 0;
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
			}

			if(optionSelectedM == 2 ) { 
				fadeOption = 2; fadeColor = 255; fadeColor2 = 255;screenOptionsM = 0; 
				screenOptions = 0; screenGUIOptions = 0;
				screenGeneralOptionsMP = 1;
			}

			if(optionSelectedM == 3 ) { fadeOption = 1; fadeColor = 255; fadeColor2 = 255;screenOptionsM = 0; screenOptions = 1; screenGUIOptions = 0;}
			//if(optionSelectedM == 3 ) { fadeOption = 1; fadeColor = 255; fadeColor2 = 255;guiOptionSelected = 0; screenOptionsM = 0; screenGUIOptions = 1; gFont = 3; screenOptions = 0;}
			if(optionSelectedM == 4 ) { fadeOption = 2; fadeColor = 255; fadeColor2 = 255;screenOptionsM = 0; screenOptionsHelp = 1; 
			//loadHelp(); 
			buildGuideList();
			screenOptions = 0; screenGUIOptions = 0;}


			if(optionSelectedM == 5) { 
				screenResizeE = 1; screenOptionsM = 0;
				fadeOption = 1;
				fadeColor = 255;
				fadeColor2 = 255;
			}

			


			zA = 0;

			LoopMode = 2;
			return 0;
		}

		if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_UP)  {  
			if(DisableMenuSounds == 0)playEffect(0);	
			optionSelectedM -= 1; 
			if(optionSelectedM < 0) optionSelectedM = 5;
		}

		if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_DOWN) {  
			if(DisableMenuSounds == 0)playEffect(0);	
			optionSelectedM += 1; 
			if(optionSelectedM > 5) optionSelectedM = 0;

		} 
		return 0;
	}

	if(screenResizeB == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeB = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopB+=0.01f;  zBottomB+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopB-=0.01f;  zBottomB-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftB-=0.01f; zRightB-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftB+=0.01f; zRightB+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomB+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomB-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightB-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightB+=0.01f; // Right


		return 0; 

	}

	if(fontResizeR == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeR = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopBR-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopBR+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftBR-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftBR+=1;  }// Right
		return 0; 

	}

	if(fontResizeEO == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeEO = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopEO-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopEO+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftEO-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftEO+=1;  }// Right
		return 0; 

	}

	if(fontResizeCO == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeCO = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopCO-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopCO+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftCO-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftCO+=1;  }// Right
		return 0; 

	}

	if(fontResizeCC == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeCC = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopCC-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopCC+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftCC-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftCC+=1;  }// Right
		return 0; 

	}

	if(fontResizeClip == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeClip = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {rC-=1;  rCHeight-=1; }// Up
		if (g_Gamepads[0].fY1 < 0) {rC+=1;  rCHeight+=1; } // Down
		if (g_Gamepads[0].fX1 < 0) {lC-=1; lCWidth-=1; } // Left
		if (g_Gamepads[0].fX1 > 0) {lC+=1; lCWidth+=1; }// Right

		if (g_Gamepads[0].fY2 > 0) rCHeight-=1; // Up
		if (g_Gamepads[0].fY2 < 0) rCHeight+=1; // Down
		if (g_Gamepads[0].fX2 < 0) lCWidth-=1; // Left
		if (g_Gamepads[0].fX2 > 0) lCWidth+=1; // Right
		return 0; 

	}
	if(fontResizeTO == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeTO = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopTO-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopTO+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftTO-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftTO+=1;  }// Right
		return 0; 

	}


	if(fontResizeCCO == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeCCO = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopCCO-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopCCO+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftCCO-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftCCO+=1;  }// Right
		return 0; 

	}

	if(fontResizeV == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeV = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopV-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopV+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftV-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftV+=1;  }// Right
		return 0; 

	}

	if(fontResizeRumble == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeRumble = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopRM-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopRM+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftRM-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftRM+=1;  }// Right
		return 0; 

	}

	if(fontResizeGT == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeGT = 0; screenGUIOptions = 1;
			LoopMode = 2;
			gFont = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopGT-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopGT+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftGT-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftGT+=1;  }// Right
		return 0; 

	}

	if(fontResizeIT == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeIT = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopIT-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopIT+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftIT-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftIT+=1;  }// Right
		return 0; 

	}

	if(fontResizeS == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeS = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopSM-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopSM+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftSM-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftSM+=1;  }// Right
		return 0; 

	}

	if(fontResizeG == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeG = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopGM-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopGM+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftGM-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftGM+=1;  }// Right
		return 0; 

	}

	if(fontResizeCD == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeCD = 0; screenGUIOptions = 1;
			gFont = 2;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopCD-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopCD+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftCD-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftCD+=1;  }// Right
		return 0; 

	}

	if(fontResizeM == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeM = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopMM-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopMM+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftMM-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftMM+=1;  }// Right
		return 0; 

	}

	if(fontResizeF == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			fontResizeF = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopBF-=1;   }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopBF+=1;   } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftBF-=1;  } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftBF+=1;  }// Right
		return 0; 

	}
	if(screenResizeA == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeA = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopA+=0.01f;  zBottomA+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopA-=0.01f;  zBottomA-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftA-=0.01f; zRightA-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftA+=0.01f; zRightA+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomA+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomA-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightA-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightA+=0.01f; // Right

		zLeftA2 = zLeftA;
		zRightA2 = zRightA;
		zTopA2 = zTopA;
		zBottomA2 = zBottomA;


		return 0; 

	}
	if(screenResizeJ == 1) {
			if(g_Gamepads[0].Event == XBGAMEPAD_B) {
				if(DisableMenuSounds == 0) playEffect(1);
				screenResizeJ = 0; screenGUIOptions = 1;
				LoopMode = 2;
				writeConfig();
				//restoreResolution();
				return 0;
			}

			if (g_Gamepads[0].fY1 > 0) {zTopJ+=0.01f;  zBottomJ+=0.01f; }// UJ
			if (g_Gamepads[0].fY1 < 0) {zTopJ-=0.01f;  zBottomJ-=0.01f; } // Down
			if (g_Gamepads[0].fX1 < 0) {zLeftJ-=0.01f; zRightJ-=0.01f; } // Left
			if (g_Gamepads[0].fX1 > 0) {zLeftJ+=0.01f; zRightJ+=0.01f; }// Right

			if (g_Gamepads[0].fY2 > 0) zBottomJ+=0.01f; // UJ
			if (g_Gamepads[0].fY2 < 0) zBottomJ-=0.01f; // Down
			if (g_Gamepads[0].fX2 < 0) zRightJ-=0.01f; // Left
			if (g_Gamepads[0].fX2 > 0) zRightJ+=0.01f; // Right
			return 0; 

		}
		if(screenResizeG == 1) {
			if(g_Gamepads[0].Event == XBGAMEPAD_B) {
				if(DisableMenuSounds == 0) playEffect(1);
				screenResizeG = 0; screenGUIOptions = 1;
				LoopMode = 2;
				writeConfig();
				//restoreResolution();
				return 0;
			}

			if (g_Gamepads[0].fY1 > 0) {zTopG+=0.01f;  zBottomG+=0.01f; }// UJ
			if (g_Gamepads[0].fY1 < 0) {zTopG-=0.01f;  zBottomG-=0.01f; } // Down
			if (g_Gamepads[0].fX1 < 0) {zLeftG-=0.01f; zRightG-=0.01f; } // Left
			if (g_Gamepads[0].fX1 > 0) {zLeftG+=0.01f; zRightG+=0.01f; }// Right

			if (g_Gamepads[0].fY2 > 0) zBottomG+=0.01f; // UJ
			if (g_Gamepads[0].fY2 < 0) zBottomG-=0.01f; // Down
			if (g_Gamepads[0].fX2 < 0) zRightG-=0.01f; // Left
			if (g_Gamepads[0].fX2 > 0) zRightG+=0.01f; // Right
			return 0; 

		}


	if(screenResizeA2 == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeA2 = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopAR+=0.01f;  zBottomAR+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopAR-=0.01f;  zBottomAR-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftAR-=0.01f; zRightAR-=0.01f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftAR+=0.01f; zRightAR+=0.01f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomAR+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomAR-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightAR-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightAR+=0.01f; // Right

		zLeftA2R = zLeftAR;
		zRightA2R = zRightAR;
		zTopA2R = zTopAR;
		zBottomA2R = zBottomAR;


		return 0; 

	}

	if(screenResizeS == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			screenResizeS = 0; screenGUIOptions = 1;
			LoopMode = 2;
			writeConfig();
			//restoreResolution();

			return 0;
		}

		if (g_Gamepads[0].fY1 > 0) {zTopS+=0.01f;  zBottomS+=0.01f; }// Up
		if (g_Gamepads[0].fY1 < 0) {zTopS-=0.01f;  zBottomS-=0.01f; } // Down
		if (g_Gamepads[0].fX1 < 0) {zLeftS-=0.1f; zRightS-=0.1f; } // Left
		if (g_Gamepads[0].fX1 > 0) {zLeftS+=0.1f; zRightS+=0.1f; }// Right

		if (g_Gamepads[0].fY2 > 0) zBottomS+=0.01f; // Up
		if (g_Gamepads[0].fY2 < 0) zBottomS-=0.01f; // Down
		if (g_Gamepads[0].fX2 < 0) zRightS-=0.01f; // Left
		if (g_Gamepads[0].fX2 > 0) zRightS+=0.01f; // Right


		return 0; 

	}
	


	
	if(confirmDelete == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			confirmDelete = 0;
			return 0;
		}
		if ((g_Gamepads[0].Event == XBGAMEPAD_A) ) {
			std::string a = GARBAGE_PATH;//
			std::string newName = a + fileList[FileMenuSelected].name.c_str();
			int r = MoveFileEx(fileList[FileMenuSelected].path.c_str(),  newName.c_str(), MOVEFILE_COPY_ALLOWED);
			if(r != 0) {
				fileList.erase(fileList.begin()+FileMenuSelected); 
				if(FileMenuSelected != 0) FileMenuSelected--;
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
			}
			confirmDelete = 0;
			return 0;
		}
		return 0; 

	}

	if(favoriteAdd == 1) {
		if(g_Gamepads[0].Event == XBGAMEPAD_B) {
			if(DisableMenuSounds == 0) playEffect(1);
			favoriteAdd = 0;
			return 0;
		}
		return 0; 
	}

	if(LoopMode != 8) {
		screenControllerOptions = 0;
		screenResize = 0;
		screenResizeP = 0;
		screenResizeI = 0;
		screenResizePB = 0;
		screenResizeJ = 0;
		screenResizeG = 0;
		screenResizeB = 0;
		screenResizeA = 0;
		screenResizeA2 = 0;
		screenOptionsM = 0;
		screenResizeS = 0;
		screenOptions = 0;
//		int	delta=0;
		romMove = 0;


		if(g_Gamepads[0].Event == XBGAMEPAD_B) { 
			if(DisableMenuSounds == 0) playEffect(1);

			if(musicPlayer == 1) {
				musicPlayer = 0;
				screenGeneralOptionsMP = 1;
				//fadeColor = 255;
				//fadeColor2 = 255;
				releaseMP();
				writeConfig();
				return 0;
			}
			stopMovie();
			if(favorites == 1) {
				favorites = 0;
				saveFavoritesExit();
			}
			else {
				saveFavorites();
			}
			
			screenOptionsM = 1;
			fadeColor = 255;			
			fadeColor2 = 255;
			return 0;
		}

		if(g_Gamepads[0].fX2 == 0) analogStill = 1;

		if(g_Gamepads[0].Event == XBGAMEPAD_BLACK &&  favorites == 0 && musicPlayer != 1) {
			if(fileList[FileMenuSelected].isAGame && favorites == 0) {  
				confirmDelete = 1;
			}
			return 0;
		}

		if(g_Gamepads[0].Event == XBGAMEPAD_WHITE && musicPlayer != 1 ) {
			if(fileList[FileMenuSelected].isAGame) {  
				if(favorites == 0) {
					//dprintf("Calling add to favorites\n");
					addToFavorites() ;
					//dprintf("After add to favorites\n");
					favoriteAdd = 1;
				}
				else {
					//dprintf("Calling remove from favorites\n");
					removeFromFavorites();
					//dprintf("After remove from favorites\n");
					screenShotSlotAuto = 1;
					wasThere = 0;
					changePreview();
					lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				}
				//
			}

			return 0;
		}

		if(menuChanged == true 
			&& !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) {
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				updateZipFilename();
				menuChanged = false;
				return 0;
			}
			if(g_Gamepads[0].fX2 < 0 && automaticScreenShotSwitching == 0 && analogStill == 1 && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) {  //left
				analogStill = 0;
				oldScreenShot = screenShotSlotAuto;
				screenShotSlotAuto -= 1;
				if(screenShotSlotAuto < 1) screenShotSlotAuto = 8;
				changePreviewDown();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				return 0;
			}
			if(g_Gamepads[0].fX2 > 0  && automaticScreenShotSwitching == 0 && analogStill == 1 && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) { //right
				analogStill = 0;
				oldScreenShot = screenShotSlotAuto;
				screenShotSlotAuto += 1;
				if(screenShotSlotAuto > 8) screenShotSlotAuto = 1;
				changePreviewUp();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				return 0;
			}

			if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_UP && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) { 

				if(DisableMenuSounds == 0 && FileMenuSelected != 0) playEffect(0);
				FileMenuSelected--; if(FileMenuSelected < 0) FileMenuSelected = 0;  
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				if(FileMenuSelected != 0) updateZipFilename();
				return 0;
			} 
			if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_DOWN && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) {  
				if(DisableMenuSounds == 0 && (FileMenuSelected != (fileList.size() - 1))) playEffect(0);	
				FileMenuSelected++; if(FileMenuSelected >= fileList.size()) FileMenuSelected = fileList.size() - 1;
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				if(FileMenuSelected != (fileList.size() - 1)) updateZipFilename();
				return 0;
			}

			if (g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER] && !g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) {   
				if(slow >= 1)  { slow = 0;}
				if(leftAnalog == 255) {
					slow = scrollSpeed;
				}
				else {
					slow += ((float)leftAnalog/255.0f);
				}
				FileMenuSelected-=((int)slow); if(FileMenuSelected < 0) FileMenuSelected = 0;
				menuChanged=true;
				analogScroll();
				return 0;
			}

			if (g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER] && !g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER]) {	
				if(slow >= 1) { slow = 0; } 
				if(rightAnalog == 255)
					slow = scrollSpeed;
				else
					slow += ((float)rightAnalog/255.0f);
				FileMenuSelected+=((int)slow);
				if(FileMenuSelected >= fileList.size()) 
					FileMenuSelected = fileList.size() - 1;
				menuChanged=true;
				analogScroll();
				return 0;
			}
			if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_RIGHT && g_Gamepads[0].fX2 == 0 && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) { 
				char c = fileList[FileMenuSelected].name[0];	  
				c = tolower(c);
				for(int i = FileMenuSelected; i < fileList.size(); i++) {
					char n = fileList[i].name[0];
					n = tolower(n);
					if(c == '<' && n != '<') {
						FileMenuSelected = i;
						break;
					}
					if(n > c) {
						FileMenuSelected = i;
						break;
					}
				}
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				if(FileMenuSelected != (fileList.size() - 1)) updateZipFilename();
				return 0;
			} 		
			if (g_Gamepads[0].Event == XBGAMEPAD_DPAD_LEFT  && g_Gamepads[0].fX2 == 0 && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) && !(g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER])) {  
				char c = fileList[FileMenuSelected].name[0];	  
				c = tolower(c);
				for(int i = FileMenuSelected; i > 0; i--) {
					char n = fileList[i].name[0];
					n = tolower(n);
					if(c == '<' && n != '<') {
						FileMenuSelected = i;
						break;
					}
					if(n <  c) {
						FileMenuSelected = i;
						break;	
					}
				}
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
				if(FileMenuSelected != 0) updateZipFilename();
				return 0;
			} 
			if (g_Gamepads[0].Event == XBGAMEPAD_Y) {
				FileMenuSelected = 0;
				screenShotSlotAuto = 1;
				wasThere = 0;
				changePreview();
				lastTimeScreenShotSwitch = (FLOAT)tickScreenShotSwitch.QuadPart;
			}
			if ((g_Gamepads[0].Event == XBGAMEPAD_A) && screenResize != 1 && screenResizeMovie != 1 && screenResizeP != 1  && screenResizeI != 1 && 
				screenResizePB != 1 && screenResizeJ != 1  && screenResizeB != 1 && screenResizeA != 1 && 
				screenResizeA2 != 1 && screenResizeG != 1  && screenOptionsM != 1 && screenOptionsHelp != 1 && 
				screenResizeS != 1 && screenOptions != 1 && screenControllerOptions != 1 && screenCheatOptions != 1) // A, X or Start
			{
				//dprintf("FileMenuSelected: %d\n", FileMenuSelected);
				if(fileList[FileMenuSelected].topLevel) {
					//dprintf("Top Level\n");
					searchDirectory(fileList[FileMenuSelected].path, true);
					FileMenuSelected = 0;
					return 0;
				}
				if(fileList[FileMenuSelected].isARoot || fileList[FileMenuSelected].isADirectory) {
					//dprintf("Directory or Root\n");
					searchDirectory(fileList[FileMenuSelected].path, false);
					FileMenuSelected = 0;
					return 0; 
				}
				if(fileList[FileMenuSelected].isAGame == false) return 0;
				if(musicPlayer == 1 && fileList[FileMenuSelected].soundTrack == -1) return 0; 

				if(musicPlayer == 1) {
					//dprintf("Switching tracks in the music player\n");
					pauseMusic();

					if(musicMode == 0) {
						if(vgplaying == 1) stopMusic();
						switchSongs();
						resumeMusic();
					}
					else {
						InitVGMusic((char*)(fileList[FileMenuSelected].path.c_str()));
						for(int i = 0; i < 512; i++) currentSongName[i] = '\0';
						for(int i = 0; i < fileList[FileMenuSelected].path.size(); i++)
							currentSongName[i] = fileList[FileMenuSelected].path[i];
					}
					return 0;
				}
				else {
					stopMovie();
					if(vgplaying == 1) {
						pauseVGMusic();
					}
					else {
						pauseMusic();
					}
				}

				

				//dprintf("Was a game\n");
				inGame = 1;
				firstVidRender = 1;

				setVertex();
				//dprintf("Game Name to load: %s\n", fileList[FileMenuSelected].name.c_str());
				//dprintf("Game Path to load: %s\n", fileList[FileMenuSelected].path.c_str());

				LoopMode=8; // Go to game
				//dprintf("Try and load cheat\n");
				loadCheat();
				//dprintf("Just called load cheat\n");
				//LoadRumbleFile();
				//dprintf("Just called LOad Rumble file\n");

				//Setup fname



				fname[0] = fileList[FileMenuSelected].path[0];
				for(int i = 1; i < (fileList[FileMenuSelected].path.size())+1; i++) {
					if(fileList[FileMenuSelected].path[i-1] == '\0') {
						fname[i] = fileList[FileMenuSelected].path[i-1];
						break;
					}
					else {
						fname[i] = fileList[FileMenuSelected].path[i-1];
					}
				}	

				//dprintf("fname: %s\n", fname);

				//Setup fnames
				std::string t = SRAM_PATH;
				std::string a = fileList[FileMenuSelected].name;
				a[a.size()-3] = 's';
				a[a.size()-2] = 'r';
				a[a.size()-1] = 'm';
				t = t + a;
				for(int i = 0; i < 512; i++) fnames[i] = '\0';
				fnames[0] = t[0];
				for(int i = 1; i < 512+1; i++) {
					if(t[i-1] == '\0') {
						fnames[i] = t[i-1];
						break;
					}
					else {
						fnames[i] = t[i-1];
					}
				}	

				//dprintf("fnames: %s\n", fnames);

				//Setup fnamest
				std::string t2 = SAVE_PATH;
				std::string a2 = fileList[FileMenuSelected].name;
				a2[a2.size()-3] = 'z';
				a2[a2.size()-2] = 's';
				a2[a2.size()-1] = 't';
				t2 = t2 + a2;
				for(int i = 0; i < 512; i++) fnamest[i] = '\0';
				fnamest[0] = t2[0];
				for(int i = 1; i < 512+1; i++) {
					if(t2[i-1] == '\0') {
						fnamest[i] = t2[i-1];
						break;
					}
					else {
						fnamest[i] = t2[i-1];
					}
				}	
				//dprintf("fnamest: %s\n", fnamest);
				videoRender = false;
				
				createSaveStateDirectories();
				SaveSlot(0);
				clearAnimation();
				zstart();
			}
	}
	return 0;
}



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 screenResizeS;
extern int screenOptions;
extern int screenOptionsM;
extern int dF;
extern int dD;

int MenuRender()
{
	
	FileMenu.render();
	if(showAvailMemory) {
		showMemory();
	}
	return 0;
}

// ----------------------------------------------------------------
int ModeUpdate()
{
	if (LoopMode==8) { DoGame(); return 0; }
	if (LoopMode==2) { LoopMode++; return 0; }
	if (LoopMode==3) { MenuUpdate(); return 0; }
	if (LoopMode==9) return 0;
	LoopMode=2; // Unknown mode, go to rom menu
	return 0;
}

int ModeRender()
{
	if(lightGun == 1 || tvMode == 1) {
		if(lightGun == 1) LightGunRender();
		return 0;
	}
	else {
		DirectScreen();
	}
	if(fade == 1 && splash == 1) {
		if(stransparency < 10) stransparency = 0; 
		if(stransparency > 0) {
			stransparency-=8;
		}
		else {
			splash = 0;
			if(TexSplash) { TexSplash->Release(); TexSplash = NULL;}
			if(TexSplashFinal) {TexSplashFinal->Release(); TexSplashFinal = NULL;}
		}
	}

	if(splash == 1 && animateStationarySplash() == 0 && fade == 0) {
		return 0;
	}
	else {
		fade = 1;
	}
	//MenuRender();
	if (LoopMode==3 
		&& screenResizeMovie != 1
		&& screenResize != 1 
		&& screenResizeP != 1 
		&& screenResizeI != 1 
		&& screenResizePB != 1 
		&& screenResizeJ != 1 
		&& screenResizeG != 1 
		&& screenResizeB != 1 
		&& screenResizeA2 != 1 
		&& screenResizeA != 1 
		&& screenOptionsM != 1 
		&& screenResizeS != 1 
		&& screenOptions != 1 
		&& screenVideoOptions != 1 
		&& screenSoundOptions != 1
		&& screenMPOptions != 1
		&& screenGeneralOptions != 1
		&& screenGUIOptions != 1
		&& screenLightGunOptions != 1
		&& screenResize != 1
		&& screenResizeMovie != 1
		&& screenResizeP != 1
		&& screenResizeI != 1
		&& screenResizePB != 1
		&& screenResizeJ != 1
		&& screenResizeB != 1
		&& screenResizeA != 1
		&& screenResizeE != 1
		&& screenResizeA2 != 1
		&& screenOptionsM != 1
		&& screenResizeS != 1
		&& screenOptionsHelp != 1
		&& fontResizeR != 1
		&& fontResizeEO != 1
		&& fontResizeCO != 1
		&& fontResizeCC != 1
		&& fontResizeClip != 1
		&& fontResizeTO != 1
		&& fontResizeCCO != 1
		&& fontResizeF != 1
		&& fontResizeV != 1
		&& fontResizeRumble != 1
		&& fontResizeGT != 1
		&& archiveMode != 1
		&& fontResizeIT != 1
		&& screenMPOptions != 1
		&& fontResizeS != 1
		&& fontResizeG != 1
		&& fontResizeCD != 1
		&& fontResizeM != 1
		&& screenCheatOptions != 1
		&& screenResizeMPL != 1
		&& screenResizeGP != 1
		&& screenGeneralOptionsMP != 1
		&& confirmDelete != 1
		&& favoriteAdd != 1
		&& tvMode != 1
		&& lightGun != 1
		&& saveStateLoad != 1 
		&& saveStateSave != 1
		&& screenControllerOptions != 1) MenuRender();
	//if (LoopMode==4) LightCalRender();

	return 0;
}

int UpdateSound()
{

	//DSoundUpdate();
	//while (DSoundUpdate()) { Sleep(1); }
	//while (DSoundUpdate()==0) { }
	return 0;
}

extern "C" int ZsnesInputUpdate();

extern "C" {
	void debugCore() { }////dprintf("HQ2X Error\n"); }
}

int LoopCode()
{
	LoopQuit = 0;
	// Main loop:
	while (!LoopQuit)
	{
		ModeUpdate();
		//if(animateFrame() == 1) showTransparency ^= 1;


		//		InputUpdate();
		//ZsnesInputUpdate();

		if(lightGun != 1 && tvMode != 1) DirectClear(0);
		ModeRender();
		if(lightGun != 1  && tvMode != 1) DirectPresent();


		updateEffect();
		if(splash == 0) {
			processOptions();

			readInput();
			if(!videoRender || !EnableVideoAudio)
				DirectSoundDoWork();
			if(!videoRender || !EnableVideoAudio) {
				if( vgplaying == 0) {  
					resumeMusic(); 
					updateSound();
				}
				else {
					if(animateFramevg() == 1) updateVGStream();
					if(animateFramevg2() == 1) songIsOver();
				}
			}

		}

	}

	return 0;
}



extern "C" {
	extern void setFrequency();

	extern void setLowPassFilter();
	extern void setSoundInterpolation();
	extern void setSurroundSound();
	extern int aCount;
	extern int bCount;
}
extern int Disable34;
extern  int MakeVertexList();
extern void loadStateImage();
int checkA() {

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

		if(inGame == 1) {

			LoopMode = 8; 
			lpPrimaryBuffer->Play(0,0,DSBPLAY_LOOPING);
			SoundEnabled = 1; 	
			screenOptions = 0; 
			/*unsigned char *lock=NULL;
			makeVertexListLinear();
			VertexBufferLinear->Lock(0,sizeof(VertexListLinear),&lock,0); if (lock==NULL) return 1;
			memcpy(lock,VertexListLinear,sizeof(VertexListLinear));
			VertexBufferLinear->Unlock();
			Device->SetTexture(0,TexScreen);
			Device->SetStreamSource(0,VertexBufferLinear,sizeof(CustomVertex));
			Device->SetVertexShader(D3DFVF_CUSTOMVERTEX);
			Device->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
			Device->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );*/
			setVertex();
			pauseMusic();
			g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_B] = 0;
			bCount = 0;

			//startHDMode();
			return 1;
		}
		else {
			if(DisableMenuSounds == 0) playEffect(1);
			screenOptions = 0;
			screenOptionsM = 1;
			zA = 0;
			//fadeColor = 255;
			//fadeColor2 = 255;
			return 0;
		}


	}

	if(g_Gamepads[0].Event == XBGAMEPAD_A) {
		if(inGame == 1) {
			if(optionSelected == 0) {
				LoopMode = 8; 
				lpPrimaryBuffer->Play(0,0,DSBPLAY_LOOPING);
				SoundEnabled = 1; 	
				screenOptions = 0; 
				setVertex();
				//Device->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
				//Device->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
				pauseMusic();
				g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_A] = 0;
				aCount = 0;
				
				return 1;
			} //return to game

			if(optionSelected == 1) {

				firstVidRender = 1;
				keys[KeyQuickRst] = 1; 
				LoopMode = 8; 
				lpPrimaryBuffer->Play(0,0,DSBPLAY_LOOPING);
				SoundEnabled = 1; 	
				screenOptions = 0; 
				setVertex();
				//Device->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
				//Device->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
				g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_A] = 0;
				pauseMusic();
				aCount = 0;
				return 1;
			}

			if(optionSelected == 2) {
				if(DisableMenuSounds == 0) playEffect(2);
				screenOptions = 0;
				saveStateSave = 1;
				saveStateLoad = 0;
				guiOptionStateSelected = 0;
				SaveSlot(0);
				loadStateImage();
				return 0;
			}
			if(optionSelected == 3) {
				if(DisableMenuSounds == 0) playEffect(2);
				screenOptions = 0;
				saveStateLoad = 1;
				saveStateSave = 0;
				guiOptionStateSelected = 0;
				SaveSlot(0);
				loadStateImage();
				return 0;
			}

			if(optionSelected == 4) {
				if(ScreenshotSaving) {  xboxScreenshot(); } 
				LoopMode = 8; 
				lpPrimaryBuffer->Play(0,0,DSBPLAY_LOOPING);
				SoundEnabled = 1; 	
				screenOptions = 0; 
				setVertex();
				//Device->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
				//Device->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
				g_Gamepads[0].bAnalogButtons[XINPUT_GAMEPAD_A] = 0;
				pauseMusic();
				aCount = 0;
				//startHDMode();
				return 1;
			}

			if(optionSelected == 5) {
				if(DisableMenuSounds == 0) playEffect(2);
				screenCheatOptions = 1; 
				screenOptions = 0; 
				cheatMenu = 0;
				cheatSearchMenu = 0;
				return 0;
			}

			if(optionSelected == 6) { if(DisableMenuSounds == 0) playEffect(2);screenVideoOptions = 1; screenOptions = 0; return 0; } 
			if(optionSelected == 7) { if(DisableMenuSounds == 0) playEffect(2);screenSoundOptions = 1; screenOptions = 0; return 0; }
			if(optionSelected == 8) { if(DisableMenuSounds == 0) playEffect(2);screenControllerOptions = 1;   screenOptions = 0; return 0; }
			if(optionSelected == 9) { if(DisableMenuSounds == 0) playEffect(2);screenGeneralOptions = 1;   screenOptions = 0; return 0; }
			
			
			if(optionSelected == 10) { 
				if(DisableMenuSounds == 0) 
					playEffect(2);
				
				screenGeneralOptionsGG = 1; 
				buildGuideList();
				screenOptions = 0; return 0; } //load game guide
			
			if(optionSelected == 11) { 
				if(DisableMenuSounds == 0) 
					playEffect(2);
				
			screenGeneralOptionsTGA = 1; 
				buildTGAList();
				screenOptions = 0; return 0; } //load game guide

			
			
			if(optionSelected == 12) { 
				loadAnimation();
				
				if(vgplaying == 1) {
					resumeVGMusic();
				}
				else {
					resumeMusic();
				}
				screenOptions = 0; 


				screenOptionsM = 0;
				screenGUIOptions = 0;
				inGame = 0; 
				optionSelected = 6;
				writeConfig();

				if(commandLineLaunch == 1) {
					FileMenuSelected = 0;
					fileList.clear();
					searchDirectory(romBasePath, false);
				}
				commandLineLaunch = 0;
				zA = 0;
				
			} 
		}
		else {
			if(optionSelected == 6) { if(DisableMenuSounds == 0) playEffect(2);screenVideoOptions = 1; screenOptions = 0; return 0; } 
			if(optionSelected == 7) { if(DisableMenuSounds == 0) playEffect(2);screenSoundOptions = 1; screenOptions = 0; return 0; }
			if(optionSelected == 8) { if(DisableMenuSounds == 0) playEffect(2);screenControllerOptions = 1;   screenOptions = 0; return 0; }
			if(optionSelected == 9) { if(DisableMenuSounds == 0) playEffect(2);screenGeneralOptions = 1;   screenOptions = 0; return 0; }
			if(optionSelected == 10 ) { if(DisableMenuSounds == 0) playEffect(2); guiOptionSelected = 0; screenOptions = 0; screenGUIOptions = 1; gFont = 3; }
			if(optionSelected == 11) { if(DisableMenuSounds == 0) playEffect(2);screenMPOptions = 1; screenOptions = 0; return 0; }

		}
		return 0;
	}

	return 0;
}

void loadSkinIniFromFolder(char* folder) {//settings
	//dprintf("Load skin: %s\n", folder);
	FILE* f;

	//
	std::string a = "D:\\skins\\";
	a+=skinPath;
	a+="\\";
	a+=skinPath;
	a+=".ini";




	f = fopen(a.c_str() , "r");
	//dprintf("Trying to Load skin.ini from: %s\n", a.c_str());

	if(!f) {
		//dprintf("Error Trying to Load skin.ini from: %s\n", a.c_str());
		return;
	}
	if(f) {
		getImage(f);
		getVideo(f);
		//dprintf("getSong(f)\n");
		getSong(f);

		//dprintf("getGuideLines(f)\n");
		getGuideLines(f);

		//dprintf("getGuideColor(f)\n");
		getGuideColor(f);

		//dprintf("getGuideFontSize(f)\n");
		getGuideFontSize(f);

		//dprintf("getDimColor(f)\n");
		getDimColor(f);

		//dprintf("getVsync(f)\n");
		getVsync(f);

		//dprintf("getMpType(f)\n");
		getMpType(f);

		//dprintf("getFontType(f)\n");
		getFontType(f);



		getLoop(f);
		getGP(f);
		getMPL(f);
		getLeftLGRumble(f);
		getRightLGRumble(f);
		getTimeLGRumble(f);
		getPixelRatio(f);
		getDisableKeyCombo(f);
		getRumbleSettings(f);
		getRomBrowserCount(f);
		getScreenShotSlot(f);
		getScreenShotSwitching(f);
		getScreenShotSpeed(f);
		getZoomSpeed(f);

		char hwcbaaaayyyyline4oq[100];
		fgets(hwcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hwcbaaaayyyyline4oq[i] == '=') {
//				char c = hwcbaaaayyyyline4oq[i+1];
				zTopCD = (int) atoi(&hwcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char hhwwccbbbaaaaaayyyyline4oq[100];
		fgets(hhwwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hhwwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = hhwwccbbbaaaaaayyyyline4oq[i+1];
				zLeftCD = (int) atoi(&hhwwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char hyyydddyyline2uq[100];
		fgets(hyyydddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hyyydddyyline2uq[i] == '=') {
//				char c = hyyydddyyline2uq[i+1];
				scrollSpeed =  (float) atof(&hyyydddyyline2uq[i+1]);;
				break;
			}
		}

		char yldfakbawcbaaaayyyyline4oq[100];
		fgets(yldfakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yldfakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = yldfakbawcbaaaayyyyline4oq[i+1];
				repeatAnimation = (int) atoi(&yldfakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ldfakbawcbaaaayyyyline4oq[100];
		fgets(ldfakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ldfakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = ldfakbawcbaaaayyyyline4oq[i+1];
				mouseDist = (int) atoi(&ldfakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char laine[100];

		fgets(laine,100, f);
		for(int i = 0; i < 100; i++) {
			if(laine[i] == '=') {
				//char c = line[i+1];
				animationFrames =  (int) atoi(&laine[i+1]);
				break;
			}
		}

		char line[100];

		fgets(line,100, f);
		for(int i = 0; i < 100; i++) {
			if(line[i] == '=') {
				//char c = line[i+1];
				zLeft =  (float) atof(&line[i+1]);
				break;
			}
		}

		char line2[100];
		fgets(line2,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2[i] == '=') {
//				char c = line2[i+1];
				zRight =  (float) atof(&line2[i+1]);;
				break;
			}
		}

		char line3[100];
		fgets(line3,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3[i] == '=') {
//				char c = line3[i+1];
				zTop =  (float) atof(&line3[i+1]);
				break;
			}
		}

		char line4[100];
		fgets(line4,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4[i] == '=') {
//				char c = line4[i+1];
				zBottom = (float) atof(&line4[i+1]);
				break;
			}
		}
		char line5[100];
		fgets(line5,100, f);
		for(int i = 0; i < 100; i++) {
			if(line5[i] == '=') {
//				char c = line5[i+1];
				//SoftwareFilter = (int) atoi(&line5[i+1]);
				break;
			}
		}

		char line6[100];
		fgets(line6,100, f);
		for(int i = 0; i < 100; i++) {
			if(line6[i] == '=') {
//				char c = line6[i+1];
				//HardwareFilter = (int) atoi(&line6[i+1]);
				break;
			}
		}

		char line7[100];
		fgets(line7,100, f);
		for(int i = 0; i < 100; i++) {
			if(line7[i] == '=') {
//				char c = line7[i+1];
				//FlickerFilter = (int) atoi(&line7[i+1]);
				break;
			}
		}

		char line8[100];
		fgets(line8,100, f);
		for(int i = 0; i < 100; i++) {
			if(line8[i] == '=') {
//				char c = line8[i+1];
				//Soften = (int) atoi(&line8[i+1]);
				break;
			}
		}

		char line9[100];
		fgets(line9,100, f);
		for(int i = 0; i < 100; i++) {
			if(line9[i] == '=') {
//				char c = line9[i+1];
				//ShowFPS = (int) atoi(&line9[i+1]);
				break;
			}
		}

		char line10[100];
		fgets(line10,100, f);
		for(int i = 0; i < 100; i++) {
			if(line10[i] == '=') {
//				char c = line10[i+1];
				//SoundFrequency = (int) atoi(&line10[i+1]);
				break;
			}
		}

		char line11[100];
		fgets(line11,100, f);
		for(int i = 0; i < 100; i++) {
			if(line11[i] == '=') {
//				char c = line11[i+1];
				//SoundInterpolation = (int) atoi(&line11[i+1]);
				break;
			}
		}

		char line12[100];
		fgets(line12,100, f);
		for(int i = 0; i < 100; i++) {
			if(line12[i] == '=') {
//				char c = line12[i+1];
				//LowPassFilter = (int) atoi(&line12[i+1]);
				break;
			}
		}

		char line13[100];
		fgets(line13,100, f);
		for(int i = 0; i < 100; i++) {
			if(line13[i] == '=') {
//				char c = line13[i+1];
				//SurroundSound = (int) atoi(&line13[i+1]);
				break;
			}
		}

		char line14[100];
		fgets(line14,100, f);
		for(int i = 0; i < 100; i++) {
			if(line14[i] == '=') {
//				char c = line14[i+1];
				//DisableMenuSounds = (int) atoi(&line14[i+1]);
				break;
			}
		}

		char line15[100];
		fgets(line15,100, f);
		for(int i = 0; i < 100; i++) {
			if(line15[i] == '=') {
//				char c = line15[i+1];
				//Disable34 = (int) atoi(&line15[i+1]);
				break;
			}
		}

		char line16[100];
		fgets(line16,100, f);
		for(int i = 0; i < 100; i++) {
			if(line16[i] == '=') {
//				char c = line16[i+1];
				//DisableSaveStates = (int) atoi(&line16[i+1]);
				break;
			}
		}


		for(int i2 = 0; i2 < 4; i2++) {
			char line162[100];
			fgets(line162,100, f);
			for(int i = 0; i < 100; i++) {
				if(line162[i] == '=') {
//					char c = line162[i+1];
					//controllers[i2].button_A = (int) atoi(&line162[i+1]);
					break;
				}
			}

			char line17[100];
			fgets(line17,100, f);
			for(int i = 0; i < 100; i++) {
				if(line17[i] == '=') {
//					char c = line17[i+1];
					//controllers[i2].button_B = (int) atoi(&line17[i+1]);
					break;
				}
			}

			char line18[100];
			fgets(line18,100, f);
			for(int i = 0; i < 100; i++) {
				if(line18[i] == '=') {
//					char c = line18[i+1];
					//controllers[i2].button_X = (int) atoi(&line18[i+1]);
					break;
				}
			}

			char line19[100];
			fgets(line19,100, f);
			for(int i = 0; i < 100; i++) {
				if(line19[i] == '=') {
//					char c = line19[i+1];
					//controllers[i2].button_Y = (int) atoi(&line19[i+1]);
					break;
				}
			}

			char line20[100];
			fgets(line20,100, f);
			for(int i = 0; i < 100; i++) {
				if(line20[i] == '=') {
//					char c = line20[i+1];
					//controllers[i2].button_Left = (int) atoi(&line20[i+1]);
					break;
				}
			}

			char line21[100];
			fgets(line21,100, f);
			for(int i = 0; i < 100; i++) {
				if(line21[i] == '=') {
//					char c = line21[i+1];
					//controllers[i2].button_Right = (int) atoi(&line21[i+1]);
					break;
				}
			}

			char line22[100];
			fgets(line22,100, f);
			for(int i = 0; i < 100; i++) {
				if(line22[i] == '=') {
//					char c = line22[i+1];
					//controllers[i2].button_Select = (int) atoi(&line22[i+1]);
					break;
				}
			}

			char line23[100];
			fgets(line23,100, f);
			for(int i = 0; i < 100; i++) {
				if(line23[i] == '=') {
//					char c = line23[i+1];
					//controllers[i2].button_Start = (int) atoi(&line23[i+1]);
					break;
				}
			}

			char line24[100];
			fgets(line24,100, f);
			for(int i = 0; i < 100; i++) {
				if(line24[i] == '=') {
//					char c = line24[i+1];
					//controllers[i2].button_FastForward = (int) atoi(&line24[i+1]);
					break;
				}
			}

			char line25[100];
			fgets(line25,100, f);
			for(int i = 0; i < 100; i++) {
				if(line25[i] == '=') {
//					char c = line25[i+1];
					//controllers[i2].button_Rewind = (int) atoi(&line25[i+1]);
					break;
				}
			}

			char line26[100];
			fgets(line26,100, f);
			for(int i = 0; i < 100; i++) {
				if(line26[i] == '=') {
//					char c = line26[i+1];
					////controllers[i2].button_LoadState = (int) atoi(&line26[i+1]);
					break;
				}
			}

			char line27[100];
			fgets(line27,100, f);
			for(int i = 0; i < 100; i++) {
				if(line27[i] == '=') {
//					char c = line27[i+1];
					//controllers[i2].button_SaveState = (int) atoi(&line27[i+1]);
					break;
				}
			}



			//dprintf("A\n");




			char line28[100];
			fgets(line28,100, f);
			for(int i = 0; i < 100; i++) {
				if(line28[i] == '=') {
//					char c = line28[i+1];
					//controllers[i2].button_ExitGame = (int) atoi(&line28[i+1]);
					break;
				}
			}

			char line29[100];
			fgets(line29,100, f);
			for(int i = 0; i < 100; i++) {
				if(line29[i] == '=') {
//					char c = line29[i+1];
					//controllers[i2].button_ShowFPS = (int) atoi(&line29[i+1]);
					break;
				}
			}
		}	

		char line50[100];
		fgets(line50,100, f);
		for(int i = 0; i < 100; i++) {
			if(line50[i] == '=') {
//				char c = line50[i+1];
				HDMode = (unsigned char) atoi(&line50[i+1]);
				if(HDMode != 1 && HDMode != 2 && HDMode != 0) HDMode = 0;
				break;
			}
		}

		char line31[100];
		fgets(line31,100, f);
		for(int i = 0; i < 100; i++) {
			if(line31[i] == '=') {
//				char c = line31[i+1];
				//XBINPUT_DEADZONE =  (float) atof(&line31[i+1]);
				break;
			}
		}

		char line291[100];
		fgets(line291,100, f);
		for(int i = 0; i < 100; i++) {
			if(line291[i] == '=') {
//				char c = line291[i+1];
				//ShowInfo = (int) atoi(&line291[i+1]);
				break;
			}
		}

		char lline[100];
		fgets(lline,100, f);
		for(int i = 0; i < 100; i++) {
			if(lline[i] == '=') {
				//char c = line[i+1];
				//BGVol =  (float) atof(&lline[i+1]);
				break;
			}
		}

		//HideFileExtension
		char line2912[100];
		fgets(line2912,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2912[i] == '=') {
//				char c = line2912[i+1];
				//HideFileExtension = (int) atoi(&line2912[i+1]);
				break;
			}
		}


		char line29123[100];
		fgets(line29123,100, f);
		for(int i = 0; i < 100; i++) {
			if(line29123[i] == '=') {
//				char c = line29123[i+1];
				//ReverseStereo = (int) atoi(&line29123[i+1]);
				break;
			}
		}

		char eline29123[100];
		fgets(eline29123,100, f);
		for(int i = 0; i < 100; i++) {
			if(eline29123[i] == '=') {
//				char c = eline29123[i+1];
				//ScreenshotSaving = (int) atoi(&eline29123[i+1]);
				break;
			}
		}

		for(int i2 = 0; i2 < 4; i2++) {
			char line162[100];
			fgets(line162,100, f);
			for(int i = 0; i < 100; i++) {
				if(line162[i] == '=') {
//					char c = line162[i+1];
					//tButtons[i2].turboA = (int) atoi(&line162[i+1]);
					break;
				}
			}

			char line17[100];
			fgets(line17,100, f);
			for(int i = 0; i < 100; i++) {
				if(line17[i] == '=') {
//					char c = line17[i+1];
					//tButtons[i2].turboB = (int) atoi(&line17[i+1]);
					break;
				}
			}

			char line18[100];
			fgets(line18,100, f);
			for(int i = 0; i < 100; i++) {
				if(line18[i] == '=') {
//					char c = line18[i+1];
					//tButtons[i2].turboX = (int) atoi(&line18[i+1]);
					break;
				}
			}

			char line19[100];
			fgets(line19,100, f);
			for(int i = 0; i < 100; i++) {
				if(line19[i] == '=') {
//					char c = line19[i+1];
					//tButtons[i2].turboY = (int) atoi(&line19[i+1]);
					break;
				}
			}

			char line20[100];
			fgets(line20,100, f);
			for(int i = 0; i < 100; i++) {
				if(line20[i] == '=') {
//					char c = line20[i+1];
					//tButtons[i2].turboL = (int) atoi(&line20[i+1]);
					break;
				}
			}

			char line21[100];
			fgets(line21,100, f);
			for(int i = 0; i < 100; i++) {
				if(line21[i] == '=') {
//					char c = line21[i+1];
					//tButtons[i2].turboR = (int) atoi(&line21[i+1]);
					break;
				}
			}


		}
		//char line212[100];
		//fgets(line212,100, f);
		//for(int i = 0; i < 100; i++) {
		//	if(line212[i] == '=') {
		////		char c = line212[i+1];
		//		map34 = (int) atoi(&line212[i+1]);
		//		break;
		//	}
		//}

		char liney[100];
		fgets(liney,100, f);
		for(int i = 0; i < 100; i++) {
			if(liney[i] == '=') {
				//char c = line[i+1];
				zLeftP =  (float) atof(&liney[i+1]);
				break;
			}
		}

		char line2u[100];
		fgets(line2u,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2u[i] == '=') {
//				char c = line2u[i+1];
				zRightP =  (float) atof(&line2u[i+1]);;
				break;
			}
		}

		char line3i[100];
		fgets(line3i,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3i[i] == '=') {
//				char c = line3i[i+1];
				zTopP =  (float) atof(&line3i[i+1]);
				break;
			}
		}

		dprintf("B\n");

		char line4o[100];
		fgets(line4o,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4o[i] == '=') {
//				char c = line4o[i+1];
				zBottomP = (float) atof(&line4o[i+1]);
				break;
			}
		}



		char lineyq[100];
		fgets(lineyq,100, f);
		for(int i = 0; i < 100; i++) {
			if(lineyq[i] == '=') {
				//char c = line[i+1];
				zLeftJ =  (float) atof(&lineyq[i+1]);
				break;
			}
		}

		char line2uq[100];
		fgets(line2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2uq[i] == '=') {
//				char c = line2uq[i+1];
				zRightJ =  (float) atof(&line2uq[i+1]);;
				break;
			}
		}

		char line3iq[100];
		fgets(line3iq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3iq[i] == '=') {
//				char c = line3iq[i+1];
				zTopJ =  (float) atof(&line3iq[i+1]);
				break;
			}
		}

		char line4oq[100];
		fgets(line4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4oq[i] == '=') {
//				char c = line4oq[i+1];
				zBottomJ = (float) atof(&line4oq[i+1]);
				break;
			}
		}
		char line20x[100];
		fgets(line20x,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20x[i] == '=') {
//				char c = line20x[i+1];
				GameNameColor = (int) atoi(&line20x[i+1]);
				break;
			}
		}

		char line20xv[100];
		fgets(line20xv,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xv[i] == '=') {
//				char c = line20xv[i+1];
				GameNameSelectedColor = (int) atoi(&line20xv[i+1]);
				break;
			}
		}

		char line20xvg[100];
		fgets(line20xvg,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvg[i] == '=') {
//				char c = line20xvg[i+1];
				FolderColor = (int) atoi(&line20xvg[i+1]);
				break;
			}
		}

		char line20xvgw[100];
		fgets(line20xvgw,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgw[i] == '=') {
//				char c = line20xvgw[i+1];
				MenuOption = (int) atoi(&line20xvgw[i+1]);
				break;
			}
		}

		char line20xvgwq[100];
		fgets(line20xvgwq,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwq[i] == '=') {
//				char c = line20xvgwq[i+1];
				MenuOptionSelected = (int) atoi(&line20xvgwq[i+1]);
				break;
			}
		}

		char line20xvgwqe[100];
		fgets(line20xvgwqe,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqe[i] == '=') {
//				char c = line20xvgwqe[i+1];
				FontSizeGUI = (int) atoi(&line20xvgwqe[i+1]);
				break;
			}
		}

		char line20xvgwqeu[100];
		fgets(line20xvgwqeu,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeu[i] == '=') {
//				char c = line20xvgwqeu[i+1];
				FullNameColor = (int) atoi(&line20xvgwqeu[i+1]);
				break;
			}
		}

		char line20xvgwqeue[100];
		fgets(line20xvgwqeue,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeue[i] == '=') {
//				char c = line20xvgwqeue[i+1];
				showTransparency = (int) atoi(&line20xvgwqeue[i+1]);
				break;
			}
		}

		char line20xvgwqeuee[100];
		fgets(line20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeuee[i] == '=') {
//				char c = line20xvgwqeuee[i+1];
				//HighRes = (int) atoi(&line20xvgwqeuee[i+1]);
				break;
			}
		}




		char lineyq1[100];
		fgets(lineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(lineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftB =  (float) atof(&lineyq1[i+1]);
				break;
			}
		}

		char line2uq1[100];
		fgets(line2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line2uq1[i] == '=') {
//				char c = line2uq1[i+1];
				zRightB =  (float) atof(&line2uq1[i+1]);;
				break;
			}
		}

		char line3iq1[100];
		fgets(line3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line3iq1[i] == '=') {
//				char c = line3iq1[i+1];
				zTopB =  (float) atof(&line3iq1[i+1]);
				break;
			}
		}



		char line4oq1[100];
		fgets(line4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line4oq1[i] == '=') {
//				char c = line4oq1[i+1];
				zBottomB = (float) atof(&line4oq1[i+1]);
				break;
			}
		}
		//
		char line20xvgwqeue1[100];
		fgets(line20xvgwqeue1,100, f);
		for(int i = 0; i < 100; i++) {
			if(line20xvgwqeue1[i] == '=') {
//				char c = line20xvgwqeue1[i+1];
				//EnableAudioAdjust = (int) atoi(&line20xvgwqeue1[i+1]);
				break;
			}
		}

		char alineyq1[100];
		fgets(alineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(alineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftA =  (float) atof(&alineyq1[i+1]);
				zLeftA2 = zLeftA;
				break;
			}
		}

		char aaline2uq1[100];
		fgets(aaline2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaline2uq1[i] == '=') {
//				char c = aaline2uq1[i+1];
				zRightA =  (float) atof(&aaline2uq1[i+1]);;
				zRightA2 = zRightA;
				break;
			}
		}

		char aaaline3iq1[100];
		fgets(aaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaline3iq1[i] == '=') {
//				char c = aaaline3iq1[i+1];
				zTopA =  (float) atof(&aaaline3iq1[i+1]);
				zTopA2 = zTopA;
				break;
			}
		}

		char aaaaline4oq1[100];
		fgets(aaaaline4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaaline4oq1[i] == '=') {
//				char c = aaaaline4oq1[i+1];
				zBottomA = (float) atof(&aaaaline4oq1[i+1]);
				zBottomA2 = zBottomA;
				break;
			}
		}

		char qalineyq1[100];
		fgets(qalineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qalineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftS =  (float) atof(&qalineyq1[i+1]);
				break;
			}
		}

		char qqaaline2uq1[100];
		fgets(qqaaline2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qqaaline2uq1[i] == '=') {
//				char c = qqaaline2uq1[i+1];
				zRightS =  (float) atof(&qqaaline2uq1[i+1]);;
				break;
			}
		}

		char qqqaaaline3iq1[100];
		fgets(qqqaaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qqqaaaline3iq1[i] == '=') {
//				char c = qqqaaaline3iq1[i+1];
				zTopS =  (float) atof(&qqqaaaline3iq1[i+1]);
				break;
			}
		}

		char qqqqaaaaline4oq1[100];
		fgets(qqqqaaaaline4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(qqqqaaaaline4oq1[i] == '=') {
//				char c = qqqqaaaaline4oq1[i+1];
				zBottomS = (float) atof(&qqqqaaaaline4oq1[i+1]);
				break;
			}
		}

		char laine20xvgwqeuee[100];
		fgets(laine20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(laine20xvgwqeuee[i] == '=') {
//				char c = laine20xvgwqeuee[i+1];
				vSpace = (int) atoi(&laine20xvgwqeuee[i+1]);
				break;
			}
		}

		char laaine20xvgwqeuee[100];
		fgets(laaine20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(laaine20xvgwqeuee[i] == '=') {
//				char c = laaine20xvgwqeuee[i+1];
				FontSizeGUI = (int) atoi(&laaine20xvgwqeuee[i+1]);
				break;
			}
		}

		char rlaaine20xvgwqeuee[100];
		fgets(rlaaine20xvgwqeuee,100, f);
		for(int i = 0; i < 100; i++) {
			if(rlaaine20xvgwqeuee[i] == '=') {
//				char c = rlaaine20xvgwqeuee[i+1];
				animationFPS = (int) atoi(&rlaaine20xvgwqeuee[i+1]);
				break;
			}
		}

		char gqqqaaaline3iq1[100];
		fgets(gqqqaaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(gqqqaaaline3iq1[i] == '=') {
//				char c = gqqqaaaline3iq1[i+1];
				animationSpeed =  (float) atof(&gqqqaaaline3iq1[i+1]);
				break;
			}
		}

		char oliney[100];
		fgets(oliney,100, f);
		for(int i = 0; i < 100; i++) {
			if(oliney[i] == '=') {
				//char c = line[i+1];
				zLeftPB =  (float) atof(&oliney[i+1]);
				break;
			}
		}

		char ooline2u[100];
		fgets(ooline2u,100, f);
		for(int i = 0; i < 100; i++) {
			if(ooline2u[i] == '=') {
//				char c = ooline2u[i+1];
				zRightPB =  (float) atof(&ooline2u[i+1]);;
				break;
			}
		}

		char oooline3i[100];
		fgets(oooline3i,100, f);
		for(int i = 0; i < 100; i++) {
			if(oooline3i[i] == '=') {
//				char c = oooline3i[i+1];
				zTopPB =  (float) atof(&oooline3i[i+1]);
				break;
			}
		}

		char ooooline4o[100];
		fgets(ooooline4o,100, f);
		for(int i = 0; i < 100; i++) {
			if(ooooline4o[i] == '=') {
//				char c = ooooline4o[i+1];
				zBottomPB = (float) atof(&ooooline4o[i+1]);
				break;
			}
		}




		char ylineyq[100];
		fgets(ylineyq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ylineyq[i] == '=') {
				//char c = line[i+1];
				zLeftG =  (float) atof(&ylineyq[i+1]);
				break;
			}
		}

		char yyline2uq[100];
		fgets(yyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyline2uq[i] == '=') {
//				char c = yyline2uq[i+1];
				zRightG =  (float) atof(&yyline2uq[i+1]);;
				break;
			}
		}

		char yyyline3iq[100];
		fgets(yyyline3iq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyyline3iq[i] == '=') {
//				char c = yyyline3iq[i+1];
				zTopG =  (float) atof(&yyyline3iq[i+1]);
				break;
			}
		}

		char yyyyline4oq[100];
		fgets(yyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyyyline4oq[i] == '=') {
//				char c = yyyyline4oq[i+1];
				zBottomG = (float) atof(&yyyyline4oq[i+1]);
				break;
			}
		}

		char ayyyyline4oq[100];
		fgets(ayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ayyyyline4oq[i] == '=') {
//				char c = ayyyyline4oq[i+1];
				transparency = (int) atoi(&ayyyyline4oq[i+1]);
				break;
			}
		}

		char aayyyyline4oq[100];
		fgets(aayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aayyyyline4oq[i] == '=') {
//				char c = aayyyyline4oq[i+1];
				zTopBR = (int) atoi(&aayyyyline4oq[i+1]);
				break;
			}
		}

		char aaayyyyline4oq[100];
		fgets(aaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaayyyyline4oq[i] == '=') {
//				char c = aaayyyyline4oq[i+1];
				zLeftBR = (int) atoi(&aaayyyyline4oq[i+1]);
				break;
			}
		}

		char aaaayyyyline4oq[100];
		fgets(aaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaayyyyline4oq[i] == '=') {
//				char c = aaaayyyyline4oq[i+1];
				zTopBF = (int) atoi(&aaaayyyyline4oq[i+1]);
				break;
			}
		}

		char aaaaaayyyyline4oq[100];
		fgets(aaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aaaaaayyyyline4oq[i] == '=') {
//				char c = aaaaaayyyyline4oq[i+1];
				zLeftBF = (int) atoi(&aaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char baaaayyyyline4oq[100];
		fgets(baaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(baaaayyyyline4oq[i] == '=') {
//				char c = baaaayyyyline4oq[i+1];
				zTopV = (int) atoi(&baaaayyyyline4oq[i+1]);
				break;
			}
		}

		char bbaaaaaayyyyline4oq[100];
		fgets(bbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(bbaaaaaayyyyline4oq[i] == '=') {
//				char c = bbaaaaaayyyyline4oq[i+1];
				zLeftV = (int) atoi(&bbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char cbaaaayyyyline4oq[100];
		fgets(cbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(cbaaaayyyyline4oq[i] == '=') {
//				char c = cbaaaayyyyline4oq[i+1];
				zTopSM = (int) atoi(&cbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ccbbbaaaaaayyyyline4oq[100];
		fgets(ccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ccbbbaaaaaayyyyline4oq[i+1];
				zLeftSM = (int) atoi(&ccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char wcbaaaayyyyline4oq[100];
		fgets(wcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(wcbaaaayyyyline4oq[i] == '=') {
//				char c = wcbaaaayyyyline4oq[i+1];
				zTopGM = (int) atoi(&wcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char wwccbbbaaaaaayyyyline4oq[100];
		fgets(wwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(wwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = wwccbbbaaaaaayyyyline4oq[i+1];
				zLeftGM = (int) atoi(&wwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char awcbaaaayyyyline4oq[100];
		fgets(awcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(awcbaaaayyyyline4oq[i] == '=') {
//				char c = awcbaaaayyyyline4oq[i+1];
				zTopMM = (int) atoi(&awcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char aawwccbbbaaaaaayyyyline4oq[100];
		fgets(aawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(aawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = aawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftMM = (int) atoi(&aawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}


		char bawcbaaaayyyyline4oq[100];
		fgets(bawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(bawcbaaaayyyyline4oq[i] == '=') {
//				char c = bawcbaaaayyyyline4oq[i+1];
				zTopEO = (int) atoi(&bawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char bbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(bbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(bbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = bbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftEO = (int) atoi(&bbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}


		char kbawcbaaaayyyyline4oq[100];
		fgets(kbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(kbawcbaaaayyyyline4oq[i] == '=') {
//				char c = kbawcbaaaayyyyline4oq[i+1];
				zTopCO = (int) atoi(&kbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ibbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(ibbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ibbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ibbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftCO = (int) atoi(&ibbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char akbawcbaaaayyyyline4oq[100];
		fgets(akbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(akbawcbaaaayyyyline4oq[i] == '=') {
//				char c = akbawcbaaaayyyyline4oq[i+1];
				zTopTO = (int) atoi(&akbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char sibbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(sibbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sibbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = sibbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftTO = (int) atoi(&sibbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char gakbawcbaaaayyyyline4oq[100];
		fgets(gakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(gakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = gakbawcbaaaayyyyline4oq[i+1];
				zTopCCO = (int) atoi(&gakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ggsibbaawwccbbbaaaaaayyyyline4oq[100];
		fgets(ggsibbaawwccbbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ggsibbaawwccbbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ggsibbaawwccbbbaaaaaayyyyline4oq[i+1];
				zLeftCCO = (int) atoi(&ggsibbaawwccbbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char fayyyyline4oq[100];
		fgets(fayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(fayyyyline4oq[i] == '=') {
//				char c = fayyyyline4oq[i+1];
				showBorder = (int) atoi(&fayyyyline4oq[i+1]);
				break;
			}
		}

		char tline20xvgwqeue[100];
		fgets(tline20xvgwqeue,100, f);
		for(int i = 0; i < 100; i++) {
			if(tline20xvgwqeue[i] == '=') {
//				char c = tline20xvgwqeue[i+1];
				fadeSpeed = (int) atoi(&tline20xvgwqeue[i+1]);
				break;
			}
		}

		char raaaayyyyline4oq[100];
		fgets(raaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(raaaayyyyline4oq[i] == '=') {
//				char c = raaaayyyyline4oq[i+1];
				zTopGT = (int) atoi(&raaaayyyyline4oq[i+1]);
				break;
			}
		}

		char rraaaaaayyyyline4oq[100];
		fgets(rraaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(rraaaaaayyyyline4oq[i] == '=') {
//				char c = rraaaaaayyyyline4oq[i+1];
				zLeftGT = (int) atoi(&rraaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char draaaayyyyline4oq[100];
		fgets(draaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(draaaayyyyline4oq[i] == '=') {
//				char c = draaaayyyyline4oq[i+1];
				zTopIT = (int) atoi(&draaaayyyyline4oq[i+1]);
				break;
			}
		}

		char jrraaaaaayyyyline4oq[100];
		fgets(jrraaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(jrraaaaaayyyyline4oq[i] == '=') {
//				char c = jrraaaaaayyyyline4oq[i+1];
				zLeftIT = (int) atoi(&jrraaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char sdraaaayyyyline4oq[100];
		fgets(sdraaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sdraaaayyyyline4oq[i] == '=') {
//				char c = sdraaaayyyyline4oq[i+1];
				zTopCC = (int) atoi(&sdraaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ssjrraaaaaayyyyline4oq[100];
		fgets(ssjrraaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ssjrraaaaaayyyyline4oq[i] == '=') {
//				char c = ssjrraaaaaayyyyline4oq[i+1];
				zLeftCC = (int) atoi(&ssjrraaaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char sbaaaayyyyline4oq[100];
		fgets(sbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sbaaaayyyyline4oq[i] == '=') {
//				char c = sbaaaayyyyline4oq[i+1];
				zTopHT = (int) atoi(&sbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char ssbbaaaaaayyyyline4oq[100];
		fgets(ssbbaaaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ssbbaaaaaayyyyline4oq[i] == '=') {
//				char c = ssbbaaaaaayyyyline4oq[i+1];
				zLeftHT = (int) atoi(&ssbbaaaaaayyyyline4oq[i+1]);
				break;
			}
		}



		char jgakbawcbaaaayyyyline4oq[100];
		fgets(jgakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(jgakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = jgakbawcbaaaayyyyline4oq[i+1];
				lC = (int) atoi(&jgakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}
		char sakbawcbaaaayyyyline4oq[100];
		fgets(sakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(sakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = sakbawcbaaaayyyyline4oq[i+1];
				rC = (int) atoi(&sakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char fakbawcbaaaayyyyline4oq[100];
		fgets(fakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(fakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = fakbawcbaaaayyyyline4oq[i+1];
				lCWidth = (int) atoi(&fakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char hakbawcbaaaayyyyline4oq[100];
		fgets(hakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(hakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = hakbawcbaaaayyyyline4oq[i+1];
				rCHeight = (int) atoi(&hakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}

		char dfakbawcbaaaayyyyline4oq[100];
		fgets(dfakbawcbaaaayyyyline4oq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dfakbawcbaaaayyyyline4oq[i] == '=') {
//				char c = dfakbawcbaaaayyyyline4oq[i+1];
				rWidth = (int) atoi(&dfakbawcbaaaayyyyline4oq[i+1]);
				break;
			}
		}






		char ralineyq1[100];
		fgets(ralineyq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(ralineyq1[i] == '=') {
				//char c = line[i+1];
				zLeftAR =  (float) atof(&ralineyq1[i+1]);
				zLeftA2R = zLeftAR;
				break;
			}
		}

		char rraaline2uq1[100];
		fgets(rraaline2uq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(rraaline2uq1[i] == '=') {
//				char c = rraaline2uq1[i+1];
				zRightAR =  (float) atof(&rraaline2uq1[i+1]);;
				zRightA2R = zRightAR;
				break;
			}
		}

		char rrraaaline3iq1[100];
		fgets(rrraaaline3iq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(rrraaaline3iq1[i] == '=') {
//				char c = rrraaaline3iq1[i+1];
				zTopAR =  (float) atof(&rrraaaline3iq1[i+1]);
				zTopA2R = zTopAR;
				break;
			}
		}

		char rrrraaaaline4oq1[100];
		fgets(rrrraaaaline4oq1,100, f);
		for(int i = 0; i < 100; i++) {
			if(rrrraaaaline4oq1[i] == '=') {
//				char c = rrrraaaaline4oq1[i+1];
				zBottomAR = (float) atof(&rrrraaaaline4oq1[i+1]);
				zBottomA2R = zBottomAR;
				break;
			}
		}
		char dyyline2uq[100];
		fgets(dyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dyyline2uq[i] == '=') {
//				char c = dyyline2uq[i+1];
				distA =  (float) atof(&dyyline2uq[i+1]);;
				break;
			}
		}

		char ddyyline2uq[100];
		fgets(ddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ddyyline2uq[i] == '=') {
//				char c = ddyyline2uq[i+1];
				minA =  (float) atof(&ddyyline2uq[i+1]);;
				break;
			}
		}

		char dddyyline2uq[100];
		fgets(dddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dddyyline2uq[i] == '=') {
//				char c = dddyyline2uq[i+1];
				maxA =  (float) atof(&dddyyline2uq[i+1]);;
				break;
			}
		}




		char ydyyline2uq[100];
		fgets(ydyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(ydyyline2uq[i] == '=') {
//				char c = ydyyline2uq[i+1];
				distA2 =  (float) atof(&ydyyline2uq[i+1]);;
				break;
			}
		}

		char yyddyyline2uq[100];
		fgets(yyddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyddyyline2uq[i] == '=') {
//				char c = yyddyyline2uq[i+1];
				minA2 =  (float) atof(&yyddyyline2uq[i+1]);;
				break;
			}
		}

		char yyydddyyline2uq[100];
		fgets(yyydddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(yyydddyyline2uq[i] == '=') {
//				char c = yyydddyyline2uq[i+1];
				maxA2 =  (float) atof(&yyydddyyline2uq[i+1]);;
				break;
			}
		}

		char dyyydddyyline2uq[100];
		fgets(dyyydddyyline2uq,100, f);
		for(int i = 0; i < 100; i++) {
			if(dyyydddyyline2uq[i] == '=') {
//				char c = dyyydddyyline2uq[i+1];
				cDist =  (int) atoi(&dyyydddyyline2uq[i+1]);;
				break;
			}
		}
	}
	else {
		////dprintf("Unable to load ini in loadinifromfile\n");

	}
	if(f) fclose(f);
	
	dprintf("Load skin.ini from: %s finished\n", a.c_str());
}


extern "C" int dprintf(char *format, ...)
{
  return 0;
  char *name=NULL;
  va_list val=NULL;


  name="d:\\debug.txt";


  if (DebugFile==NULL) DebugFile=fopen(name,"wt");
  if (DebugFile==NULL) return 1;

  va_start(val,format);
  vfprintf(DebugFile,format,val);
  fflush(DebugFile);

  va_end(val);
  return 0;
}
