for(int i = 0; i < count; i++) { wchar_t buffer[256]; MENUITEMINFOW info; ZeroMemory(&info, sizeof(info)); info.cbSize = sizeof(info); info.fMask = MIIM_STRING | MIIM_SUBMENU; info.dwTypeData = buffer; info.cch = 256; GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info); AppendMenuW(popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer);
OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx(&info);  if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { for(int i = 0; i < count; i++) { char buffer[256]; MENUITEMINFO info; ZeroMemory(&info, sizeof(info)); info.cbSize = sizeof(info) - sizeof(HBITMAP); info.fMask = MIIM_STRING | MIIM_SUBMENU; info.dwTypeData = buffer; info.cch = 256; if(!GetMenuItemInfo(menu, i, MF_BYPOSITION, &info)) { } if(!AppendMenu(popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer)) { } } } else { for(int i = 0; i < count; i++) { wchar_t buffer[256]; MENUITEMINFOW info; ZeroMemory(&info, sizeof(info)); info.cbSize = sizeof(info) - sizeof(HBITMAP); info.fMask = MIIM_STRING | MIIM_SUBMENU; info.dwTypeData = buffer; info.cch = 256; if(!GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info)) { } if(!AppendMenuW(popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer)) { } }
WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){  switch (message) {  case WM_ACTIVATE:    {      BOOL a = (wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE);      //      if(videoOption > VIDEO_4X && menuToggle && tripleBuffering)      //        a = FALSE;      if(a && pDevices) {        active = a;        // Pause if minimized or not the top window        for(int i = 0; i < numDevices; i++) {          if(pDevices != NULL && pDevices[i].device != NULL)            pDevices[i].device->Acquire();        }        if(!paused) {          if(emulating)            soundResume();        }      } else {        wasPaused = TRUE;        if(pauseWhenInactive) {          if(emulating)            soundPause();          active = a;        }        memset(delta,255,sizeof(delta));              }    }    if(paused && emulating)      systemDrawScreen();    break;  case WM_ACTIVATEAPP:    if(tripleBuffering && videoOption > VIDEO_4X) {      if(wParam) {        if(display)          display->clear();      }    }    break;  case WM_DESTROY:    if(!changingVideoSize) {      PostQuitMessage(0);      emulating = 0;    }    return 0L;  case WM_PAINT:    {      PAINTSTRUCT ps;      BeginPaint(hWnd, &ps);      if(emulating) {        painting = true;        systemDrawScreen();        painting = false;        renderedFrames--;      }              EndPaint(hWnd, &ps);    }    return TRUE;  case WM_MOVE:    {      if(!changingVideoSize) {        if(hWindow) {          if(!IsIconic(hWindow)) {            RECT r;                        GetWindowRect(hWindow,&r);            windowPositionX = r.left;            windowPositionY = r.top;            adjustDestRect();            regSetDwordValue("windowX", windowPositionX);            regSetDwordValue("windowY", windowPositionY);          }        }      }      return 0L;            }  case WM_SIZE:    {      if(!changingVideoSize) {        if(hWindow) {          if(!IsIconic(hWindow)) {            if(iconic) {              if(emulating) {                soundResume();                paused = FALSE;              }            }            if(videoOption <= VIDEO_4X) {              surfaceSizeX = LOWORD(lParam);              surfaceSizeY = HIWORD(lParam);              adjustDestRect();              if(display)                display->resize(dest.right-dest.left, dest.bottom-dest.top);            }          } else {            if(emulating) {              if(!paused) {                paused = TRUE;                soundPause();              }            }            iconic = TRUE;                            }        }      }    }    break;  case WM_DROPFILES:    {      HDROP hDrop = (HDROP)wParam;      if(DragQueryFile(hDrop,                       0,                       szFile,                       1024)) {        if(fileOpen()) {          SetForegroundWindow(hWindow);          emulating = TRUE;        } else {          emulating = FALSE;          soundPause();        }      }      DragFinish(hDrop);    }    return 0L;  case WM_INITMENU:    soundPause();    break;  case WM_INITMENUPOPUP:    {      HMENU menu = (HMENU)wParam;      int menuNum = LOWORD(lParam);      int top = HIWORD(lParam);      if(!top) {        switch(menuNum) {        case MENU_FILE:          updateFileMenu(menu);          break;        case MENU_OPTIONS:          updateFrameSkipMenu(menu);          updateVideoMenu(menu);          updateEmulatorMenu(menu);          updateSoundMenu(menu);          updateGameboyMenu(menu);          updatePriorityMenu(menu);          updateFilterMenu(menu);          updateJoypadMenu(menu);          updateLanguageMenu(menu);          break;        case MENU_CHEATS:          updateCheatsMenu(menu);          break;        case MENU_TOOLS:          updateToolsMenu(menu);          break;        }      }    }    break;  case WM_KEYDOWN:    // Handle any non-accelerated key commands    switch (wParam) {    case VK_ESCAPE:      fileToggleMenu();      return 0L;    }    break;  case WM_MOUSEMOVE:    winMouseOn();    break;  case WM_LBUTTONDOWN:    winMouseOn();    break;  case WM_LBUTTONUP:    winMouseOn();    break;  case WM_RBUTTONDOWN:    winMouseOn();    break;  case WM_RBUTTONUP:    winMouseOn();    break;  case WM_CONTEXTMENU:    winMouseOn();    if(skin) {      if(popup == NULL) {        popup = CreatePopupMenu();        if(menu != NULL) {          int count = GetMenuItemCount(menu);          for(int i = 0; i < count; i++) {            wchar_t buffer[256];            MENUITEMINFOW info;            ZeroMemory(&info, sizeof(info));            info.cbSize = sizeof(info);            info.fMask = MIIM_STRING | MIIM_SUBMENU;            info.dwTypeData = buffer;            info.cch = 256;            GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info);            AppendMenuW(popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer);          }        }      }      TrackPopupMenu(popup, 0, LOWORD(lParam), HIWORD(lParam), 0, hWindow, NULL);    }    break;  case WM_MBUTTONDOWN:    winMouseOn();    break;  case WM_MBUTTONUP:    winMouseOn();    break;  case WM_COMMAND:    switch(wParam & 0xFFFF) {    case ID_FILE_OPEN:      winCheckFullscreen();      if(fileOpenSelect()) {        if(fileOpen())          emulating = TRUE;        else {          emulating = FALSE;          soundPause();        }      }      break;    case ID_FILE_OPENGAMEBOY:      winCheckFullscreen();            if(fileOpenSelectGB()) {        if(fileOpen())          emulating = TRUE;        else {          emulating = FALSE;          soundPause();        }      }      break;    case ID_FILE_LOAD:      winCheckFullscreen();            if(emulating)        loadSaveGame();      break;    case ID_FILE_SAVE:      winCheckFullscreen();            if(emulating)        writeSaveGame();      break;    case ID_FILE_LOADGAME_SLOT1:    case ID_FILE_LOADGAME_SLOT2:    case ID_FILE_LOADGAME_SLOT3:    case ID_FILE_LOADGAME_SLOT4:    case ID_FILE_LOADGAME_SLOT5:    case ID_FILE_LOADGAME_SLOT6:    case ID_FILE_LOADGAME_SLOT7:    case ID_FILE_LOADGAME_SLOT8:    case ID_FILE_LOADGAME_SLOT9:    case ID_FILE_LOADGAME_SLOT10:      if(emulating)        loadSaveGame((wParam&0xffff)+1-ID_FILE_LOADGAME_SLOT1);      break;    case ID_FILE_SAVEGAME_SLOT1:    case ID_FILE_SAVEGAME_SLOT2:    case ID_FILE_SAVEGAME_SLOT3:    case ID_FILE_SAVEGAME_SLOT4:    case ID_FILE_SAVEGAME_SLOT5:    case ID_FILE_SAVEGAME_SLOT6:    case ID_FILE_SAVEGAME_SLOT7:    case ID_FILE_SAVEGAME_SLOT8:    case ID_FILE_SAVEGAME_SLOT9:    case ID_FILE_SAVEGAME_SLOT10:      if(emulating)        writeSaveGame((wParam&0xffff)+1-ID_FILE_SAVEGAME_SLOT1);      break;    case ID_FILE_CLOSE:      if(emulating)        fileClose();      break;    case ID_FILE_RECENT_RESET:      resetRecentList();      break;    case ID_FILE_RECENT_FREEZE:      recentFreeze = !recentFreeze;      regSetDwordValue("recentFreeze", recentFreeze);      break;    case ID_FILE_MRU_FILE1:    case ID_FILE_MRU_FILE2:    case ID_FILE_MRU_FILE3:    case ID_FILE_MRU_FILE4:    case ID_FILE_MRU_FILE5:    case ID_FILE_MRU_FILE6:    case ID_FILE_MRU_FILE7:    case ID_FILE_MRU_FILE8:    case ID_FILE_MRU_FILE9:    case ID_FILE_MRU_FILE10:      if(recentFiles[(wParam&0xFFFF)-ID_FILE_MRU_FILE1]) {        strcpy(szFile, recentFiles[(wParam&0xFFFF)-ID_FILE_MRU_FILE1]);        if(fileOpen())          emulating = TRUE;        else {          emulating = FALSE;          soundPause();        }      }      break;    case ID_FILE_IMPORT_GAMESHARKCODEFILE:      winCheckFullscreen();            fileImportGSCodeFile();      break;    case ID_FILE_IMPORT_GAMESHARKSNAPSHOT:      winCheckFullscreen();            fileImportGSSnapshot();      break;    case ID_FILE_IMPORT_BATTERYFILE:      winCheckFullscreen();            fileImportBatteryFile();      break;    case ID_FILE_EXPORT_BATTERYFILE:      winCheckFullscreen();            fileExportBatteryFile();      break;    case ID_FILE_EXPORT_SETTINGSTOINI:      regExportSettingsToINI();      break;    case ID_FILE_EXPORT_GAMESHARKSNAPSHOT:      winCheckFullscreen();            fileExportGSASnapshot();      break;    case ID_FILE_PAUSE:      paused = !paused;      if(emulating) {        if(paused) {          wasPaused = TRUE;          soundPause();          setScreenSaverEnable(screenSaverState);        } else {          soundResume();          if(screenSaverState)            setScreenSaverEnable(FALSE);        }      }      break;    case ID_FILE_RESET:      if(emulating) {        emuReset();        systemScreenMessage((char *)winResLoadString(IDS_RESET));      }      break;    case ID_FILE_SCREENCAPTURE:      winCheckFullscreen();            screenCapture();      break;    case ID_FILE_ROMINFORMATION:      winCheckFullscreen();            if(cartridgeType == 0)        winGBARomInfo(rom);      else        winGBRomInfo(gbRom);      break;    case ID_FILE_EXIT:      fileExit();      break;    case ID_OPTIONS_VIDEO_FRAMESKIP_0:    case ID_OPTIONS_VIDEO_FRAMESKIP_1:    case ID_OPTIONS_VIDEO_FRAMESKIP_2:    case ID_OPTIONS_VIDEO_FRAMESKIP_3:    case ID_OPTIONS_VIDEO_FRAMESKIP_4:    case ID_OPTIONS_VIDEO_FRAMESKIP_5:      if(cartridgeType == 0) {        frameSkip = (wParam&0xffff) - ID_OPTIONS_VIDEO_FRAMESKIP_0;        regSetDwordValue("frameSkip", frameSkip);      } else {        gbFrameSkip = (wParam&0xffff) - ID_OPTIONS_VIDEO_FRAMESKIP_0;        regSetDwordValue("gbFrameSkip", gbFrameSkip);         }      if(emulating)        updateFrameSkip();      break;    case ID_OPTIONS_VIDEO_FRAMESKIP_6:    case ID_OPTIONS_VIDEO_FRAMESKIP_7:    case ID_OPTIONS_VIDEO_FRAMESKIP_8:    case ID_OPTIONS_VIDEO_FRAMESKIP_9:      if(cartridgeType == 0) {        frameSkip = 6 + (wParam&0xffff) - ID_OPTIONS_VIDEO_FRAMESKIP_6;        regSetDwordValue("frameSkip", frameSkip);      } else {        gbFrameSkip = 6 + (wParam&0xffff) - ID_OPTIONS_VIDEO_FRAMESKIP_6;        regSetDwordValue("gbFrameSkip", gbFrameSkip);         }      if(emulating)        updateFrameSkip();            break;    case ID_OPTIONS_FRAMESKIP_AUTOMATIC:      autoFrameSkip = !autoFrameSkip;      regSetDwordValue("autoFrameSkip", autoFrameSkip);      if(!autoFrameSkip && emulating)        updateFrameSkip();      break;    case ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE:      throttle = 0;      break;    case ID_OPTIONS_FRAMESKIP_THROTTLE_25:      throttle = 25;      break;    case ID_OPTIONS_FRAMESKIP_THROTTLE_50:      throttle = 50;      break;    case ID_OPTIONS_FRAMESKIP_THROTTLE_150:      throttle = 150;      break;    case ID_OPTIONS_FRAMESKIP_THROTTLE_200:      throttle = 200;      break;    case ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER:      {        int res = optionsThrottleOther(throttle);        if(res)          throttle = res;      }      break;    case ID_OPTIONS_VIDEO_VSYNC:      vsync = !vsync;      regSetDwordValue("vsync", vsync);      break;    case ID_OPTIONS_VIDEO_RENDERMETHOD_GDI:      renderMethod = GDI;      updateRenderMethod(false);      break;    case ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW:      renderMethod = DIRECT_DRAW;      updateRenderMethod(false);      break;    case ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D:      renderMethod = DIRECT_3D;      updateRenderMethod(false);      break;    case ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL:      renderMethod = OPENGL;      updateRenderMethod(false);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER:      d3dFilter = 0;      regSetDwordValue("d3dFilter", d3dFilter);      if(display)        display->setOption("d3dFilter", d3dFilter);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR:      d3dFilter = 1;      regSetDwordValue("d3dFilter", d3dFilter);      if(display)        display->setOption("d3dFilter", d3dFilter);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST:      glFilter = 0;      regSetDwordValue("glFilter", glFilter);      if(display)        display->setOption("glFilter", glFilter);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR:      glFilter = 1;      regSetDwordValue("glFilter", glFilter);      if(display)        display->setOption("glFilter", glFilter);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE:      glType = 0;      regSetDwordValue("glType", glType);      if(display)        display->setOption("glType", glType);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS:      glType = 1;      regSetDwordValue("glType", glType);      if(display)        display->setOption("glType", glType);      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN:      winSelectSkin();      break;    case ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN:      skinEnabled = !skinEnabled;      regSetDwordValue("skinEnabled", skinEnabled);      updateRenderMethod(true);      break;    case ID_OPTIONS_VIDEO_LAYERS_BG0:    case ID_OPTIONS_VIDEO_LAYERS_BG1:    case ID_OPTIONS_VIDEO_LAYERS_BG2:    case ID_OPTIONS_VIDEO_LAYERS_BG3:    case ID_OPTIONS_VIDEO_LAYERS_OBJ:    case ID_OPTIONS_VIDEO_LAYERS_WIN0:    case ID_OPTIONS_VIDEO_LAYERS_WIN1:    case ID_OPTIONS_VIDEO_LAYERS_OBJWIN:      layerSettings ^= 0x0100 <<        ((wParam & 0xFFFF) - ID_OPTIONS_VIDEO_LAYERS_BG0);      layerEnable = DISPCNT & layerSettings;      break;    case ID_OPTIONS_VIDEO_X1:    case ID_OPTIONS_VIDEO_X2:    case ID_OPTIONS_VIDEO_X3:    case ID_OPTIONS_VIDEO_X4:    case ID_OPTIONS_VIDEO_FULLSCREEN320X240:    case ID_OPTIONS_VIDEO_FULLSCREEN640X480:    case ID_OPTIONS_VIDEO_FULLSCREEN800X600:      updateVideoSize(wParam&0xffff);      winConfirmMode();      break;    case ID_OPTIONS_VIDEO_FULLSCREEN:      {        winCheckFullscreen();                GUID *pGUID = NULL;        int size = display->selectFullScreenMode(&pGUID);        if(size != -1) {          int width = (size >> 12) & 4095;          int height = (size & 4095);          int colorDepth = (size >> 24);          if(width != fsWidth ||             height != fsHeight ||             colorDepth != fsColorDepth ||             pGUID != pVideoDriverGUID ||             videoOption != VIDEO_OTHER) {            fsForceChange = true;            fsWidth = width;            fsHeight = height;            fsColorDepth = colorDepth;            pVideoDriverGUID = pGUID;            if(pGUID) {              videoDriverGUID = *pGUID;              regSetDwordValue("defaultVideoDriver", FALSE);              regSetBinaryValue("videoDriverGUID",                                (char *)pGUID, sizeof(GUID));            } else {              regSetDwordValue("defaultVideoDriver", TRUE);            }            updateVideoSize(wParam & 0xffff);            winConfirmMode();                      }        }      }      break;    case ID_OPTIONS_VIDEO_DISABLESFX:      cpuDisableSfx = !cpuDisableSfx;      regSetDwordValue("disableSfx", cpuDisableSfx);      if(emulating && cartridgeType == 0)        CPUUpdateRender();      break;    case ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT:      fullScreenStretch = !fullScreenStretch;      regSetDwordValue("stretch", fullScreenStretch);      updateWindowSize(videoOption);      if(display)        display->clear();      break;    case ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY:      ddrawEmulationOnly = !ddrawEmulationOnly;      regSetDwordValue("ddrawEmulationOnly", ddrawEmulationOnly);      if(ddrawUseVideoMemory && ddrawEmulationOnly) {        systemMessage(IDS_DISABLING_VIDEO_MEMORY,                      "Disabling Use Video Memory setting");        ddrawUseVideoMemory = false;        regSetDwordValue("ddrawUseVideoMemory", ddrawUseVideoMemory);         }      systemMessage(IDS_SETTING_WILL_BE_EFFECTIVE,                    "Setting will be effective the next time you start the emulator");      break;    case ID_OPTIONS_VIDEO_TRIPLEBUFFERING:      regSetDwordValue("tripleBuffering", !tripleBuffering);      systemMessage(IDS_SETTING_WILL_BE_EFFECTIVE,                    "Setting will be effective the next time you start the emulator");      break;    case ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY:      ddrawUseVideoMemory = !ddrawUseVideoMemory;      regSetDwordValue("ddrawUseVideoMemory", ddrawUseVideoMemory);      if(ddrawUseVideoMemory && ddrawEmulationOnly) {        systemMessage(IDS_DISABLING_EMULATION_ONLY,                      "Disabling Emulation Only setting");        ddrawEmulationOnly = false;        regSetDwordValue("ddrawEmulationOnly", ddrawEmulationOnly);           }      systemMessage(IDS_SETTING_WILL_BE_EFFECTIVE,                    "Setting will be effective the next time you start the emulator");      break;          case ID_OPTIONS_EMULATOR_DIRECTORIES:      winCheckFullscreen();            showDirectories(hWindow);      break;    case ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE:      pauseWhenInactive = !pauseWhenInactive;      regSetDwordValue("pauseWhenInactive", pauseWhenInactive);      break;    case ID_OPTIONS_EMULATOR_DISABLESTATUSMESSAGES:      disableStatusMessage = !disableStatusMessage;      regSetDwordValue("disableStatus", disableStatusMessage);      break;    case ID_OPTIONS_EMULATOR_SYNCHRONIZE:      synchronize = !synchronize;      regSetDwordValue("synchronize", synchronize);      break;    case ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE:      speedupToggle = !speedupToggle;      break;    case ID_OPTIONS_EMULATOR_REMOVEINTROSGBA:      removeIntros = !removeIntros;      regSetDwordValue("removeIntros", removeIntros);      break;    case ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH:      autoIPS = !autoIPS;      regSetDwordValue("autoIPS", autoIPS);      break;    case ID_OPTIONS_EMULATOR_USEBIOSFILE:      if(biosFileName[0]) {        useBiosFile = !useBiosFile;        regSetDwordValue("useBios", useBiosFile);      }      break;    case ID_OPTIONS_EMULATOR_SELECTBIOSFILE:      winCheckFullscreen();            if(emulatorSelectBiosFile()) {        regSetStringValue("biosFile", biosFileName);      }      break;    case ID_OPTIONS_EMULATOR_ASSOCIATE:      winCheckFullscreen();            emulatorAssociate();      break;    case ID_OPTIONS_EMULATOR_PNGFORMAT:      captureFormat = 0;      regSetDwordValue("captureFormat", 0);      break;    case ID_OPTIONS_EMULATOR_BMPFORMAT:      captureFormat = 1;      regSetDwordValue("captureFormat", 1);            break;    case ID_OPTIONS_EMULATOR_STORESETTINGSINREGISTRY:      regEnabled = !regEnabled;      regSetDwordValue("regEnabled", regEnabled, true);      break;    case ID_OPTIONS_EMULATOR_AGBPRINT:      agbPrintEnable(!agbPrintIsEnabled());      regSetDwordValue("agbPrint", agbPrintIsEnabled());      break;    case ID_OPTIONS_EMULATOR_REALTIMECLOCK:      winRtcEnable = !winRtcEnable;      rtcEnable(winRtcEnable);      regSetDwordValue("rtcEnabled", winRtcEnable);      break;    case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE:      showSpeed = 0;      systemSetTitle("VisualBoyAdvance");      regSetDwordValue("showSpeed", showSpeed);      break;    case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE:      showSpeed = 1;      regSetDwordValue("showSpeed", showSpeed);      break;    case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED:      showSpeed = 2;      regSetDwordValue("showSpeed", showSpeed);      break;    case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT:      showSpeedTransparent = !showSpeedTransparent;      regSetDwordValue("showSpeedTransparent", showSpeedTransparent);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC:      winSaveType = 0;      regSetDwordValue("saveType", 0);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM:      winSaveType = 1;      regSetDwordValue("saveType", 1);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_SRAM:      winSaveType = 2;      regSetDwordValue("saveType", 2);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_FLASH:      winSaveType = 3;      regSetDwordValue("saveType", 3);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR:      winSaveType = 4;      regSetDwordValue("saveType", 4);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K:      flashSetSize(0x10000);      winFlashSize = 0x10000;      regSetDwordValue("flashSize", winFlashSize);      break;    case ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M:      flashSetSize(0x20000);      winFlashSize = 0x20000;      regSetDwordValue("flashSize", winFlashSize);      break;    case ID_OPTIONS_SOUND_OFF:      soundOffFlag = true;      soundShutdown();      regSetDwordValue("soundOff", soundOffFlag);      break;    case ID_OPTIONS_SOUND_MUTE:      soundDisable(0x30f);      regSetDwordValue("soundEnable",                       soundGetEnable());      break;    case ID_OPTIONS_SOUND_ON:      if(soundOffFlag) {        soundOffFlag = false;        soundInit();      }      soundEnable(0x30f);      regSetDwordValue("soundEnable",                       soundGetEnable());      regSetDwordValue("soundOff", soundOffFlag);      break;    case ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION:      useOldSync = !useOldSync;      regSetDwordValue("useOldSync",                       useOldSync);      systemMessage(IDS_SETTING_WILL_BE_EFFECTIVE,                    "Setting will be effective the next time you start the emulator");            break;    case ID_OPTIONS_SOUND_ECHO:      soundEcho = !soundEcho;      regSetDwordValue("soundEcho", soundEcho);      break;    case ID_OPTIONS_SOUND_LOWPASSFILTER:      soundLowPass = !soundLowPass;      regSetDwordValue("soundLowPass", soundLowPass);            break;    case ID_OPTIONS_SOUND_REVERSESTEREO:      soundReverse = !soundReverse;      regSetDwordValue("soundReverse", soundReverse);      break;    case ID_OPTIONS_SOUND_CHANNEL1:    case ID_OPTIONS_SOUND_CHANNEL2:    case ID_OPTIONS_SOUND_CHANNEL3:    case ID_OPTIONS_SOUND_CHANNEL4:    case ID_OPTIONS_SOUND_DIRECTSOUNDA:    case ID_OPTIONS_SOUND_DIRECTSOUNDB:      updateSoundChannels(wParam&0xffff);      regSetDwordValue("soundEnable",                       soundGetEnable());            break;          case ID_OPTIONS_SOUND_11KHZ:      if(cartridgeType == 0)        soundSetQuality(4);      else        gbSoundSetQuality(4);      regSetDwordValue("soundQuality",                       soundQuality);      break;    case ID_OPTIONS_SOUND_22KHZ:      if(cartridgeType == 0)        soundSetQuality(2);      else        gbSoundSetQuality(2);      regSetDwordValue("soundQuality",                       soundQuality);            break;    case ID_OPTIONS_SOUND_44KHZ:      if(cartridgeType == 0)        soundSetQuality(1);      else        gbSoundSetQuality(1);      regSetDwordValue("soundQuality",                       soundQuality);            break;    case ID_OPTIONS_SOUND_VOLUME_1X:      soundVolume = 0;      regSetDwordValue("soundVolume",                       soundVolume);      break;    case ID_OPTIONS_SOUND_VOLUME_2X:      soundVolume = 1;      regSetDwordValue("soundVolume",                       soundVolume);      break;    case ID_OPTIONS_SOUND_VOLUME_3X:      soundVolume = 2;      regSetDwordValue("soundVolume",                       soundVolume);      break;    case ID_OPTIONS_SOUND_VOLUME_4X:      soundVolume = 3;      regSetDwordValue("soundVolume",                       soundVolume);      break;    case ID_OPTIONS_SOUND_STARTRECORDING:      winCheckFullscreen();            fileSoundRecord();      break;    case ID_OPTIONS_SOUND_STOPRECORDING:      winCheckFullscreen();            if(soundRecorder) {        delete soundRecorder;        soundRecorder = NULL;      }      soundRecording = FALSE;      break;    case ID_OPTIONS_GAMEBOY_BORDER:      gbBorderOn = !gbBorderOn;      if(emulating && cartridgeType == 1 && gbBorderOn) {        gbSgbRenderBorder();      }      updateWindowSize(videoOption);      regSetDwordValue("borderOn", gbBorderOn);      break;    case ID_OPTIONS_GAMEBOY_PRINTER:      winGbPrinterEnabled = !winGbPrinterEnabled;      if(winGbPrinterEnabled)        gbSerialFunction = gbPrinterSend;      else        gbSerialFunction = NULL;      regSetDwordValue("gbPrinter", winGbPrinterEnabled);      break;    case ID_OPTIONS_GAMEBOY_AUTOMATIC:      gbEmulatorType = 0;      regSetDwordValue("emulatorType", gbEmulatorType);            break;    case ID_OPTIONS_GAMEBOY_GBA:      gbEmulatorType = 4;      regSetDwordValue("emulatorType", gbEmulatorType);                  break;    case ID_OPTIONS_GAMEBOY_CGB:      gbEmulatorType = 1;      regSetDwordValue("emulatorType", gbEmulatorType);                  break;    case ID_OPTIONS_GAMEBOY_SGB:      gbEmulatorType = 2;      regSetDwordValue("emulatorType", gbEmulatorType);                  break;    case ID_OPTIONS_GAMEBOY_GB:      gbEmulatorType = 3;      regSetDwordValue("emulatorType", gbEmulatorType);                  break;    case ID_OPTIONS_GAMEBOY_SGB2:      gbEmulatorType = 5;      regSetDwordValue("emulatorType", gbEmulatorType);                  break;    case ID_OPTIONS_GAMEBOY_REALCOLORS:      gbColorOption = 0;      regSetDwordValue("colorOption", 0);      break;    case ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS:      gbColorOption = 1;      regSetDwordValue("colorOption", 1);      break;    case ID_OPTIONS_GAMEBOY_COLORS:      winCheckFullscreen();            optionsGameboyColors();      break;    case ID_OPTIONS_PRIORITY_HIGHEST:      threadPriority = 0;      regSetDwordValue("priority", 0);      updatePriority();      break;    case ID_OPTIONS_PRIORITY_ABOVENORMAL:      threadPriority = 1;      regSetDwordValue("priority", 1);      updatePriority();      break;    case ID_OPTIONS_PRIORITY_NORMAL:      threadPriority = 2;      regSetDwordValue("priority", 2);      updatePriority();      break;    case ID_OPTIONS_PRIORITY_BELOWNORMAL:      threadPriority = 3;      regSetDwordValue("priority", 3);      updatePriority();      break;    case ID_OPTIONS_FILTER_NORMAL:      filterType = 0;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_TVMODE:      filterType = 1;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_2XSAI:      filterType = 2;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_SUPER2XSAI:      filterType = 3;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_SUPEREAGLE:      filterType = 4;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL:      filterType = 5;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL:      filterType = 6;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X:      filterType = 7;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER16BIT_SIMPLE2X:      filterType = 8;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_BILINEAR:      filterType = 9;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_BILINEARPLUS:      filterType = 10;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_SCANLINES:      filterType = 11;      regSetDwordValue("filter", filterType);      updateFilter();      break;    case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE:      ifbType = 0;      regSetDwordValue("ifbType", ifbType);      updateIFB();      break;          case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR:      ifbType = 1;      regSetDwordValue("ifbType", ifbType);      updateIFB();      break;          case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART:      ifbType = 2;      regSetDwordValue("ifbType", ifbType);      updateIFB();      break;          case ID_OPTIONS_FILTER_DISABLEMMX:      disableMMX = !disableMMX;      if(!disableMMX)        cpu_mmx = detectMMX();      else        cpu_mmx = 0;      regSetDwordValue("disableMMX", disableMMX);      break;    case ID_OPTIONS_JOYPAD_CONFIGURE_1:      winCheckFullscreen();      configurePad(0);      break;    case ID_OPTIONS_JOYPAD_CONFIGURE_2:      winCheckFullscreen();            configurePad(1);      break;    case ID_OPTIONS_JOYPAD_CONFIGURE_3:      winCheckFullscreen();      configurePad(2);      break;    case ID_OPTIONS_JOYPAD_CONFIGURE_4:      winCheckFullscreen();      configurePad(3);      break;    case ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1:      joypadDefault = 0;      regSetDwordValue("joypadDefault", joypadDefault);      break;    case ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2:      joypadDefault = 1;      regSetDwordValue("joypadDefault", joypadDefault);      break;    case ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3:      joypadDefault = 2;      regSetDwordValue("joypadDefault", joypadDefault);      break;    case ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4:      joypadDefault = 3;      regSetDwordValue("joypadDefault", joypadDefault);      break;    case ID_OPTIONS_JOYPAD_MOTIONCONFIGURE:      winCheckFullscreen();            motionConfigurePad();      break;    case ID_OPTIONS_JOYPAD_AUTOFIRE_A:      if(autoFire & 1) {        autoFire &= ~1;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_A_DISABLED));      } else {        autoFire |= 1;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_A));      }      break;    case ID_OPTIONS_JOYPAD_AUTOFIRE_B:      if(autoFire & 2) {        autoFire &= ~2;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_B_DISABLED));      } else {        autoFire |= 2;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_B));      }      break;    case ID_OPTIONS_JOYPAD_AUTOFIRE_L:      if(autoFire & 512) {        autoFire &= ~512;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_L_DISABLED));      } else {        autoFire |= 512;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_L));      }      break;    case ID_OPTIONS_JOYPAD_AUTOFIRE_R:      if(autoFire & 256) {        autoFire &= ~256;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_R_DISABLED));      } else {        autoFire |= 256;        systemScreenMessage((char *)winResLoadString(IDS_AUTOFIRE_R));      }      break;    case ID_OPTIONS_LANGUAGE_SYSTEM:      winSetLanguageOption(0, false);      break;    case ID_OPTIONS_LANGUAGE_ENGLISH:      winSetLanguageOption(1, false);      break;    case ID_OPTIONS_LANGUAGE_OTHER:      winCheckFullscreen();      winSetLanguageOption(2, false);      break;    case ID_CHEATS_SEARCHFORCHEATS:      winCheckFullscreen();      if(cartridgeType == 0)        winCheatsDialog();      else        winGbCheatsDialog();      break;    case ID_CHEATS_CHEATLIST:      winCheckFullscreen();      if(cartridgeType == 0)        winCheatsListDialog();      else        winGbCheatsListDialog();      break;    case ID_DEBUG_NEXTFRAME:      if(paused)        paused=FALSE;      winPauseNextFrame = TRUE;      break;    case ID_CHEATS_AUTOMATICSAVELOADCHEATS:      autoSaveLoadCheatList = !autoSaveLoadCheatList;      regSetDwordValue("autoSaveCheatList", autoSaveLoadCheatList);      break;    case ID_CHEATS_LOADCHEATLIST:      winCheckFullscreen();            winLoadCheatList();      break;    case ID_CHEATS_SAVECHEATLIST:      winCheckFullscreen();            winSaveCheatList();      break;    case ID_TOOLS_DISASSEMBLE:      winCheckFullscreen();      if(cartridgeType == 0)        toolsDisassemble();      else        toolsGBDisassemble();      break;    case ID_TOOLS_LOGGING:      winCheckFullscreen();            toolsLogging();      break;    case ID_TOOLS_MAPVIEW:      winCheckFullscreen();      if(cartridgeType == 0)        toolsMapView();      else        toolsGBMapView();      break;    case ID_TOOLS_MEMORYVIEWER:      winCheckFullscreen();      if(cartridgeType == 0)        toolsMemoryViewer();      else        toolsGBMemoryViewer();      break;    case ID_TOOLS_PALETTEVIEW:      winCheckFullscreen();      if(cartridgeType == 0)        toolsPaletteView();      else        toolsGBPaletteView();      break;    case ID_TOOLS_OAMVIEWER:      winCheckFullscreen();      if(cartridgeType == 0)        toolsOamViewer();      else        toolsGBOamViewer();      break;    case ID_TOOLS_TILEVIEWER:      winCheckFullscreen();      if(cartridgeType == 0)        toolsTileViewer();      else        toolsGBTileViewer();      break;    case ID_TOOLS_CUSTOMIZE:      winCheckFullscreen();      toolsCustomize();      break;    case ID_TOOLS_RECORD_STARTAVIRECORDING:      winCheckFullscreen();            fileAVIRecord();      break;    case ID_TOOLS_RECORD_STOPAVIRECORDING:      if(aviRecorder != NULL) {        delete aviRecorder;        aviRecorder = NULL;        aviFrameNumber = 0;      }      aviRecording = FALSE;      break;    case ID_TOOLS_DEBUG_GDB:      winCheckFullscreen();            toolsDebugGDB();      break;    case ID_TOOLS_DEBUG_LOADANDWAIT:      winCheckFullscreen();            toolsDebugGDBLoad();      break;    case ID_TOOLS_DEBUG_DISCONNECT:      remoteCleanUp();      debugger = false;      break;    case ID_TOOLS_DEBUG_BREAK:      if(armState) {        armNextPC -= 4;        reg[15].I -= 4;      } else {        armNextPC -= 2;        reg[15].I -= 2;      }      debugger = true;      break;    case ID_HELP_ABOUT:      winCheckFullscreen();            helpAbout();      break;    }    return 0L;  }  return DefWindowProc(hWnd, message, wParam, lParam);}