utilApplyIPS(ipsname, rom);
BOOL fileOpen(){  char buffer[2048];  // save battery file before we change the filename...  if(rom != NULL || gbRom != NULL) {    if(autoSaveLoadCheatList)      winSaveCheatListDefault();    writeBatteryFile();    emuCleanUp();    remoteCleanUp();      }  _fullpath(filename, szFile, 1024);  char *p = strrchr(filename, '.');  if(p != NULL)    *p = 0;    if(!dir[0]) {    p = strrchr(filename, '\\');    if(p) {      strncpy(dir, filename, p-filename);      dir[p-filename] = 0;    }  }    if(CPUIsZipFile(szFile)) {    unzFile unz = unzOpen(szFile);    if(unz == NULL) {      systemMessage(IDS_FAILED_TO_OPEN_FILE, "Failed to open file %s", szFile);      return FALSE;    }    int r = unzGoToFirstFile(unz);    if(r != UNZ_OK) {      unzClose(unz);      systemMessage(IDS_FAILED_TO_READ_ZIP_DIR,                    "Failed to read zip directory for file %s", szFile);      return FALSE;    }    bool found = false;    unz_file_info info;        while(1) {      r = unzGetCurrentFileInfo(unz,                                &info,                                buffer,                                sizeof(buffer),                                NULL,                                0,                                NULL,                                0);      if(r != UNZ_OK) {        unzClose(unz);        systemMessage(IDS_FAILED_TO_READ_ZIP_DIR,                      "Failed to read zip directory for file %s", szFile);        return false;      }      if(gbIsGameboyRom(buffer)) {        cartridgeType = 1;        found = true;        break;      }      if(CPUIsGBAImage(buffer)) {        cartridgeType = 0;        found = true;        break;      }      r = unzGoToNextFile(unz);      if(r != UNZ_OK)        break;    }    unzClose(unz);        if(!found) {      systemMessage(MSG_NO_IMAGE_ON_ZIP,                    "No image to found on ZIP file %s", szFile);      return FALSE;    }  } else if(gbIsGameboyRom(szFile)) {    cartridgeType = 1;  } else if(CPUIsGBAImage(szFile)) {    cartridgeType = 0;  } else {    systemMessage(IDS_UNSUPPORTED_FILE_TYPE,                  "Unsupported file type: %s", szFile);    return FALSE;  }  if(cartridgeType == 1) {    if(!gbLoadRom(szFile))      return FALSE;    emuWriteState = gbWriteSaveState;    emuReadState = gbReadSaveState;    emuWriteBattery = gbWriteBatteryFile;    emuReadBattery = gbReadBatteryFile;    emuReset = gbReset;    emuCleanUp = gbCleanUp;    emuWritePNG = gbWritePNGFile;    emuWriteBMP = gbWriteBMPFile;    emuMain = gbEmulate;#ifdef FINAL_VERSION    emuCount = 70000/4;#else    emuCount = 1000;#endif  } else {    if(!CPULoadRom(szFile))      return FALSE;        emuWriteState = CPUWriteState;    emuReadState = CPUReadState;    emuWriteBattery = CPUWriteBatteryFile;    emuReadBattery = CPUReadBatteryFile;    emuReset = CPUReset;    emuCleanUp = CPUCleanUp;    emuWritePNG = CPUWritePNGFile;    emuWriteBMP = CPUWriteBMPFile;    emuMain = CPULoop;#ifdef FINAL_VERSION    emuCount = 250000;#else    emuCount = 5000;#endif    if(removeIntros && rom != NULL) {      *((u32 *)rom)= 0xea00002e;    }  }      if(soundInitialized) {    if(cartridgeType == 1)      gbSoundReset();    else      soundReset();  } else {    if(!soundOffFlag)      soundInit();    soundInitialized = TRUE;  }  if(cartridgeType == 0) {    CPUInit(biosFileName, useBiosFile ? true : false);    CPUReset();  }    readBatteryFile();  if(autoSaveLoadCheatList)    winLoadCheatListDefault();    addRecentFile(szFile);    updateWindowSize(videoOption);    BOOL flag = TRUE;  emulating = TRUE;  if(screenSaverState)    setScreenSaverEnable(FALSE);    return TRUE;}