autoIPS = regQueryDwordValue("autoIPS", 1);
BOOL initApp(HINSTANCE hInstance, int nCmdShow){  remoteSetProtocol(0);    if(GetDllVersion("comctl32.dll") < PACKVERSION(4,71)) {    systemMessage(0, "Error: COMCTL32.DLL needs to be at least version 4.71");    return FALSE;  }  memset(delta,255, 257*244*2);  systemVerbose = GetPrivateProfileInt("config",                                       "verbose",                                       0,                                       "VBA.ini");    systemDebug = GetPrivateProfileInt("config",                                     "debug",                                     0,                                     "VBA.ini");    WNDCLASS                    wc;   // Set up and register window class  wc.style = CS_HREDRAW | CS_VREDRAW;  wc.lpfnWndProc = WindowProc;  wc.cbClsExtra = 0;  wc.cbWndExtra = 0;  wc.hInstance = hInstance;  wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON));  wc.hCursor = LoadCursor(NULL, IDC_ARROW);  wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);  wc.lpszMenuName = "GBA";  wc.lpszClassName = "GBA";  RegisterClass(&wc);  ::hInstance = hInstance;  ::nCmdShow = nCmdShow;  arrow = LoadCursor(NULL, IDC_ARROW);    regInit();  languageOption = regQueryDwordValue("language", 1);  if(languageOption < 0 || languageOption > 2)    languageOption = 1;  char *lang = regQueryStringValue("languageName", NULL);  if(lang) {    strncpy(languageName, lang, 4);    languageName[3] = 0;  } else    languageName[0] = 0;    winSetLanguageOption(languageOption, true);    frameSkip = regQueryDwordValue("frameSkip", 2);  if(frameSkip < 0 || frameSkip > 9)    frameSkip = 2;  gbFrameSkip = regQueryDwordValue("gbFrameSkip", 0);  if(gbFrameSkip < 0 || gbFrameSkip > 9)    gbFrameSkip = 0;    vsync = regQueryDwordValue("vsync", 0);  synchronize = regQueryDwordValue("synchronize", 1) ? true : false;  fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false;  videoOption = regQueryDwordValue("video", 0);  if(videoOption < 0 || videoOption > VIDEO_800x600)    videoOption = 0;  windowPositionX = regQueryDwordValue("windowX", 0);  if(windowPositionX < 0)    windowPositionX = 0;  windowPositionY = regQueryDwordValue("windowY", 0);  if(windowPositionY < 0)    windowPositionY = 0;  useBiosFile = regQueryDwordValue("useBios", 0) ? true: false;  char * c = regQueryStringValue("biosFile", NULL);  if(c) {    strcpy(biosFileName, c);  }    int res = regQueryDwordValue("soundEnable", 0x30f);    soundEnable(res);  soundDisable(~res);  soundOffFlag = (regQueryDwordValue("soundOff", 0)) ? true : false;  soundQuality = regQueryDwordValue("soundQuality", 2);  soundEcho = regQueryDwordValue("soundEcho", 0) ? true : false;  soundLowPass = regQueryDwordValue("soundLowPass", 0) ? true : false;  soundReverse = regQueryDwordValue("soundReverse", 0) ? true : false;  ddrawEmulationOnly = regQueryDwordValue("ddrawEmulationOnly", 0);  ddrawUseVideoMemory = regQueryDwordValue("ddrawUseVideoMemory", 0);  filterType = regQueryDwordValue("filter", 0);  if(filterType < 0 || filterType > 8)    filterType = 0;  disableMMX = regQueryDwordValue("disableMMX", 0) ? true: false;  disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false;  winGbPrinterEnabled = regQueryDwordValue("gbPrinter", 0);  pauseWhenInactive = regQueryDwordValue("pauseWhenInactive", 1) ?    true : false;  useOldSync = regQueryDwordValue("useOldSync", 0) ?    TRUE : FALSE;  captureFormat = regQueryDwordValue("captureFormat", 0);  removeIntros = regQueryDwordValue("removeIntros", 0);  recentFreeze = regQueryDwordValue("recentFreeze", 0);  cpuSaveType = regQueryDwordValue("saveType", 0);  if(cpuSaveType < 0 || cpuSaveType > 4)    cpuSaveType = 0;  winFlashSize = regQueryDwordValue("flashSize", 0x10000);  if(winFlashSize != 0x10000 && winFlashSize != 0x20000)    winFlashSize = 0x10000;  if(!initDirectDraw()) {    if(videoOption >= VIDEO_320x240)      regSetDwordValue("video", VIDEO_1X);        return FALSE;  }  if(!initDirectInput())    return FALSE;  readKeys();  if(regQueryDwordValue("joyVersion", 0) == 0) {    convertKeys();  }    checkKeys();  hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));  winAccelMgr.Connect(hWindow);  winAccelMgr.SetRegKey(HKEY_CURRENT_USER, "Software\\Emulators\\VisualBoyAdvance");  extern void winAccelAddCommands(CAcceleratorManager&);  winAccelAddCommands(winAccelMgr);  winAccelMgr.CreateDefaultTable();  winAccelMgr.Load();  winAccelMgr.UpdateWndTable();  char buffer[50];    for(int i = 0; i < 10; i++) {    sprintf(buffer, "recent%d", i);    char *s = regQueryStringValue(buffer, NULL);    if(s == NULL)      break;    recentFiles[i] = strdup(s);  }    gbBorderOn = regQueryDwordValue("borderOn", 0);  gbEmulatorType = regQueryDwordValue("emulatorType", 1);  if(gbEmulatorType < 0 || gbEmulatorType > 4)    gbEmulatorType = 1;  gbColorOption = regQueryDwordValue("colorOption", 0);  threadPriority = regQueryDwordValue("priority", 2);  if(threadPriority < 0 || threadPriority >3)    threadPriority = 2;  updatePriority();  autoSaveLoadCheatList = regQueryDwordValue("autoSaveCheatList", 0) ?    true : false;  gbPaletteOption = regQueryDwordValue("gbPaletteOption", 0);  if(gbPaletteOption < 0)    gbPaletteOption = 0;  if(gbPaletteOption > 2)    gbPaletteOption = 2;  regQueryBinaryValue("gbPalette", (char *)systemGbPalette,                      24*sizeof(u16));  return TRUE;}