diff src/win32/MainWnd.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/MainWnd.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,1511 @@
     1.4 +// MainWnd.cpp : implementation file
     1.5 +//
     1.6 +
     1.7 +#include "stdafx.h"
     1.8 +#include <winsock.h>
     1.9 +
    1.10 +#include "resource.h"
    1.11 +#include "MainWnd.h"
    1.12 +
    1.13 +#include "CmdAccelOb.h"
    1.14 +#include "FileDlg.h"
    1.15 +#include "ModeConfirm.h"
    1.16 +#include "Reg.h"
    1.17 +#include "WinResUtil.h"
    1.18 +#include "WinMiscUtil.h"
    1.19 +#include "Input.h"
    1.20 +#include "7zip/7zip.h"
    1.21 +#include "7zip/OpenArchive.h"
    1.22 +#include "LuaOpenDialog.h"
    1.23 +#include "ram_search.h"
    1.24 +#include "ramwatch.h"
    1.25 +#include "Sound.h"
    1.26 +#include "VBA.h"
    1.27 +
    1.28 +#include "../version.h"
    1.29 +#include "../common/Util.h"
    1.30 +#include "../common/movie.h"
    1.31 +#include "../common/vbalua.h"
    1.32 +#include "../gba/GBASound.h"
    1.33 +#include "../gba/GBAGlobals.h"
    1.34 +#include "../gb/gbGlobals.h"
    1.35 +
    1.36 +#define VBA_CONFIRM_MODE WM_APP + 100
    1.37 +
    1.38 +/////////////////////////////////////////////////////////////////////////////
    1.39 +// MainWnd
    1.40 +
    1.41 +MainWnd::MainWnd()
    1.42 +{
    1.43 +	m_hAccelTable = NULL;
    1.44 +	arrow		  = LoadCursor(NULL, IDC_ARROW);
    1.45 +
    1.46 +	InitDecoder();
    1.47 +}
    1.48 +
    1.49 +MainWnd::~MainWnd()
    1.50 +{
    1.51 +	CleanupDecoder();
    1.52 +}
    1.53 +
    1.54 +BEGIN_MESSAGE_MAP(MainWnd, CWnd)
    1.55 +//{{AFX_MSG_MAP(MainWnd)
    1.56 +ON_WM_MOVE()
    1.57 +ON_WM_SIZE()
    1.58 +ON_WM_CLOSE()
    1.59 +ON_WM_INITMENUPOPUP()
    1.60 +ON_WM_INITMENU()
    1.61 +ON_WM_CONTEXTMENU()
    1.62 +ON_WM_MOUSEMOVE()
    1.63 +ON_WM_ACTIVATE()
    1.64 +ON_WM_ACTIVATEAPP()
    1.65 +ON_WM_DROPFILES()
    1.66 +ON_WM_PAINT()
    1.67 +
    1.68 +ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
    1.69 +ON_COMMAND(ID_HELP_FAQ, OnHelpFaq)
    1.70 +ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
    1.71 +ON_COMMAND(ID_FILE_OPENGAMEBOY, OnFileOpenGBx)
    1.72 +ON_COMMAND(ID_FILE_PAUSE, OnFilePause)
    1.73 +ON_UPDATE_COMMAND_UI(ID_FILE_PAUSE, OnUpdateFilePause)
    1.74 +ON_COMMAND(ID_FILE_RESET, OnFileReset)
    1.75 +ON_UPDATE_COMMAND_UI(ID_FILE_RESET, OnUpdateFileReset)
    1.76 +ON_UPDATE_COMMAND_UI(ID_FILE_RECENT_FREEZE, OnUpdateFileRecentFreeze)
    1.77 +ON_COMMAND(ID_FILE_RECENT_RESET, OnFileRecentReset)
    1.78 +ON_COMMAND(ID_FILE_RECENT_FREEZE, OnFileRecentFreeze)
    1.79 +ON_COMMAND(ID_FILE_EXIT, OnFileExit)
    1.80 +ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
    1.81 +ON_UPDATE_COMMAND_UI(ID_FILE_CLOSE, OnUpdateFileClose)
    1.82 +ON_COMMAND(ID_FILE_LOAD, OnFileLoad)
    1.83 +ON_UPDATE_COMMAND_UI(ID_FILE_LOAD, OnUpdateFileLoad)
    1.84 +ON_COMMAND(ID_FILE_SAVE, OnFileSave)
    1.85 +ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
    1.86 +ON_COMMAND(ID_FILE_IMPORT_BATTERYFILE, OnFileImportBatteryfile)
    1.87 +ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_BATTERYFILE, OnUpdateFileImportBatteryfile)
    1.88 +ON_COMMAND(ID_FILE_IMPORT_GAMESHARKCODEFILE, OnFileImportGamesharkcodefile)
    1.89 +ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_GAMESHARKCODEFILE, OnUpdateFileImportGamesharkcodefile)
    1.90 +ON_COMMAND(ID_FILE_IMPORT_GAMESHARKSNAPSHOT, OnFileImportGamesharksnapshot)
    1.91 +ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_GAMESHARKSNAPSHOT, OnUpdateFileImportGamesharksnapshot)
    1.92 +ON_COMMAND(ID_FILE_EXPORT_BATTERYFILE, OnFileExportBatteryfile)
    1.93 +ON_UPDATE_COMMAND_UI(ID_FILE_EXPORT_BATTERYFILE, OnUpdateFileExportBatteryfile)
    1.94 +ON_COMMAND(ID_FILE_EXPORT_GAMESHARKSNAPSHOT, OnFileExportGamesharksnapshot)
    1.95 +ON_UPDATE_COMMAND_UI(ID_FILE_EXPORT_GAMESHARKSNAPSHOT, OnUpdateFileExportGamesharksnapshot)
    1.96 +ON_COMMAND(ID_FILE_QUICKSCREENCAPTURE, OnFileQuickScreencapture)
    1.97 +ON_COMMAND(ID_FILE_SCREENCAPTURE, OnFileScreencapture)
    1.98 +ON_UPDATE_COMMAND_UI(ID_FILE_SCREENCAPTURE, OnUpdateFileScreencapture)
    1.99 +ON_COMMAND(ID_FILE_ROMINFORMATION, OnFileRominformation)
   1.100 +ON_UPDATE_COMMAND_UI(ID_FILE_ROMINFORMATION, OnUpdateFileRominformation)
   1.101 +ON_COMMAND(ID_FILE_TOGGLEMENU, OnFileTogglemenu)
   1.102 +ON_UPDATE_COMMAND_UI(ID_FILE_TOGGLEMENU, OnUpdateFileTogglemenu)
   1.103 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_6, OnUpdateOptionsFrameskipThrottle6)
   1.104 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_15, OnUpdateOptionsFrameskipThrottle15)
   1.105 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_25, OnUpdateOptionsFrameskipThrottle25)
   1.106 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_50, OnUpdateOptionsFrameskipThrottle50)
   1.107 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_75, OnUpdateOptionsFrameskipThrottle75)
   1.108 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_100, OnUpdateOptionsFrameskipThrottle100)
   1.109 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_125, OnUpdateOptionsFrameskipThrottle125)
   1.110 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnUpdateOptionsFrameskipThrottle150)
   1.111 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnUpdateOptionsFrameskipThrottle200)
   1.112 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_300, OnUpdateOptionsFrameskipThrottle300)
   1.113 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_400, OnUpdateOptionsFrameskipThrottle400)
   1.114 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_600, OnUpdateOptionsFrameskipThrottle600)
   1.115 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_1000, OnUpdateOptionsFrameskipThrottle1000)
   1.116 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnUpdateOptionsFrameskipThrottleOther)
   1.117 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, OnUpdateOptionsFrameskipThrottleIncrease)
   1.118 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, OnUpdateOptionsFrameskipThrottleDecrease)
   1.119 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_6, OnOptionsFrameskipThrottle6)
   1.120 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_15, OnOptionsFrameskipThrottle15)
   1.121 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_25, OnOptionsFrameskipThrottle25)
   1.122 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_50, OnOptionsFrameskipThrottle50)
   1.123 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_75, OnOptionsFrameskipThrottle75)
   1.124 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_100, OnOptionsFrameskipThrottle100)
   1.125 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_125, OnOptionsFrameskipThrottle125)
   1.126 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnOptionsFrameskipThrottle150)
   1.127 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnOptionsFrameskipThrottle200)
   1.128 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_300, OnOptionsFrameskipThrottle300)
   1.129 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_400, OnOptionsFrameskipThrottle400)
   1.130 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_600, OnOptionsFrameskipThrottle600)
   1.131 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_1000, OnOptionsFrameskipThrottle1000)
   1.132 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnOptionsFrameskipThrottleOther)
   1.133 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, OnOptionsFrameskipThrottleIncrease)
   1.134 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, OnOptionsFrameskipThrottleDecrease)
   1.135 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_ACCURATEPITCH, OnOptionsFrameskipAccuratePitch)
   1.136 +ON_COMMAND(ID_OPTIONS_FRAMESKIP_ACCURATESPEED, OnOptionsFrameskipAccurateSpeed)
   1.137 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_ACCURATEPITCH, OnUpdateOptionsFrameskipAccuratePitch)
   1.138 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_ACCURATESPEED, OnUpdateOptionsFrameskipAccurateSpeed)
   1.139 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_0, OnUpdateOptionsVideoFrameskip0)
   1.140 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_1, OnUpdateOptionsVideoFrameskip1)
   1.141 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_2, OnUpdateOptionsVideoFrameskip2)
   1.142 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_3, OnUpdateOptionsVideoFrameskip3)
   1.143 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_4, OnUpdateOptionsVideoFrameskip4)
   1.144 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_5, OnUpdateOptionsVideoFrameskip5)
   1.145 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_6, OnUpdateOptionsVideoFrameskip6)
   1.146 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_7, OnUpdateOptionsVideoFrameskip7)
   1.147 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_8, OnUpdateOptionsVideoFrameskip8)
   1.148 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_9, OnUpdateOptionsVideoFrameskip9)
   1.149 +ON_COMMAND(ID_OPTIONS_VIDEO_VSYNC, OnOptionsVideoVsync)
   1.150 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_VSYNC, OnUpdateOptionsVideoVsync)
   1.151 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X1, OnUpdateOptionsVideoX1)
   1.152 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X2, OnUpdateOptionsVideoX2)
   1.153 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X3, OnUpdateOptionsVideoX3)
   1.154 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X4, OnUpdateOptionsVideoX4)
   1.155 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN320X240, OnUpdateOptionsVideoFullscreen320x240)
   1.156 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN640X480, OnUpdateOptionsVideoFullscreen640x480)
   1.157 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN800X600, OnUpdateOptionsVideoFullscreen800x600)
   1.158 +ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN320X240, OnOptionsVideoFullscreen320x240)
   1.159 +ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN640X480, OnOptionsVideoFullscreen640x480)
   1.160 +ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN800X600, OnOptionsVideoFullscreen800x600)
   1.161 +ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN, OnOptionsVideoFullscreen)
   1.162 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN, OnUpdateOptionsVideoFullscreen)
   1.163 +ON_COMMAND(ID_OPTIONS_VIDEO_DISABLESFX, OnOptionsVideoDisablesfx)
   1.164 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DISABLESFX, OnUpdateOptionsVideoDisablesfx)
   1.165 +ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT, OnOptionsVideoFullscreenstretchtofit)
   1.166 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT, OnUpdateOptionsVideoFullscreenstretchtofit)
   1.167 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_GDI, OnOptionsVideoRendermethodGdi)
   1.168 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_GDI, OnUpdateOptionsVideoRendermethodGdi)
   1.169 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW, OnOptionsVideoRendermethodDirectdraw)
   1.170 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW, OnUpdateOptionsVideoRendermethodDirectdraw)
   1.171 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D, OnOptionsVideoRendermethodDirect3d)
   1.172 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D, OnUpdateOptionsVideoRendermethodDirect3d)
   1.173 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL, OnOptionsVideoRendermethodOpengl)
   1.174 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL, OnUpdateOptionsVideoRendermethodOpengl)
   1.175 +ON_COMMAND(ID_OPTIONS_VIDEO_TRIPLEBUFFERING, OnOptionsVideoTriplebuffering)
   1.176 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_TRIPLEBUFFERING, OnUpdateOptionsVideoTriplebuffering)
   1.177 +ON_COMMAND(ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY, OnOptionsVideoDdrawemulationonly)
   1.178 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY, OnUpdateOptionsVideoDdrawemulationonly)
   1.179 +ON_COMMAND(ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY, OnOptionsVideoDdrawusevideomemory)
   1.180 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY, OnUpdateOptionsVideoDdrawusevideomemory)
   1.181 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER, OnOptionsVideoRenderoptionsD3dnofilter)
   1.182 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER, OnUpdateOptionsVideoRenderoptionsD3dnofilter)
   1.183 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR, OnOptionsVideoRenderoptionsD3dbilinear)
   1.184 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR, OnUpdateOptionsVideoRenderoptionsD3dbilinear)
   1.185 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST, OnOptionsVideoRenderoptionsGlnearest)
   1.186 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST, OnUpdateOptionsVideoRenderoptionsGlnearest)
   1.187 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR, OnOptionsVideoRenderoptionsGlbilinear)
   1.188 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR, OnUpdateOptionsVideoRenderoptionsGlbilinear)
   1.189 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnOptionsVideoRenderoptionsGltriangle)
   1.190 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnUpdateOptionsVideoRenderoptionsGltriangle)
   1.191 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnOptionsVideoRenderoptionsGlquads)
   1.192 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnUpdateOptionsVideoRenderoptionsGlquads)
   1.193 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnOptionsVideoRenderoptionsSelectskin)
   1.194 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnUpdateOptionsVideoRenderoptionsSelectskin)
   1.195 +ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnOptionsVideoRenderoptionsSkin)
   1.196 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnUpdateOptionsVideoRenderoptionsSkin)
   1.197 +ON_COMMAND(ID_OPTIONS_EMULATOR_ASSOCIATE, OnOptionsEmulatorAssociate)
   1.198 +ON_COMMAND(ID_OPTIONS_EMULATOR_DIRECTORIES, OnOptionsEmulatorDirectories)
   1.199 +ON_COMMAND_RANGE(ID_OPTIONS_PREFER_ARCHIVE_NAME, ID_OPTIONS_PREFER_ROM_NAME, OnOptionsEmulatorFilenamePreference)
   1.200 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_PREFER_ARCHIVE_NAME, ID_OPTIONS_PREFER_ROM_NAME, OnUpdateOptionsEmulatorFilenamePreference)
   1.201 +ON_COMMAND(ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES, OnOptionsVideoDisablestatusmessages)
   1.202 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES, OnUpdateOptionsVideoDisablestatusmessages)
   1.203 +ON_COMMAND(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnOptionsEmulatorSynchronize)
   1.204 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnUpdateOptionsEmulatorSynchronize)
   1.205 +
   1.206 +ON_COMMAND(ID_OPTIONS_EMULATOR_ALWAYSONTOP, OnOptionsEmulatorAlwaysOnTop)
   1.207 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_ALWAYSONTOP, OnUpdateOptionsEmulatorAlwaysOnTop)
   1.208 +ON_COMMAND(ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE, OnOptionsEmulatorPausewheninactive)
   1.209 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE, OnUpdateOptionsEmulatorPausewheninactive)
   1.210 +ON_COMMAND(ID_OPTIONS_EMULATOR_BACKGROUNDINPUT, OnOptionsEmulatorEnableBackgroundInput)
   1.211 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_BACKGROUNDINPUT, OnUpdateOptionsEmulatorEnableBackgroundInput)
   1.212 +ON_COMMAND(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnOptionsEmulatorSpeeduptoggle)
   1.213 +
   1.214 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnUpdateOptionsEmulatorSpeeduptoggle)
   1.215 +ON_COMMAND(ID_OPTIONS_EMULATOR_REMOVEINTROSGBA, OnOptionsEmulatorRemoveintrosgba)
   1.216 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REMOVEINTROSGBA, OnUpdateOptionsEmulatorRemoveintrosgba)
   1.217 +ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnOptionsEmulatorAutomaticallyipspatch)
   1.218 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnUpdateOptionsEmulatorAutomaticallyipspatch)
   1.219 +ON_COMMAND(ID_OPTIONS_EMULATOR_AGBPRINT, OnOptionsEmulatorAgbprint)
   1.220 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AGBPRINT, OnUpdateOptionsEmulatorAgbprint)
   1.221 +ON_COMMAND(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnOptionsEmulatorRealtimeclock)
   1.222 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnUpdateOptionsEmulatorRealtimeclock)
   1.223 +ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOHIDEMENU, OnOptionsEmulatorAutohidemenu)
   1.224 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOHIDEMENU, OnUpdateOptionsEmulatorAutohidemenu)
   1.225 +ON_COMMAND(ID_OPTIONS_EMULATOR_REWINDINTERVAL, OnOptionsEmulatorRewindinterval)
   1.226 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnOptionsEmulatorSavetypeAutomatic)
   1.227 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnUpdateOptionsEmulatorSavetypeAutomatic)
   1.228 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnOptionsEmulatorSavetypeEeprom)
   1.229 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnUpdateOptionsEmulatorSavetypeEeprom)
   1.230 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_SRAM, OnOptionsEmulatorSavetypeSram)
   1.231 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_SRAM, OnUpdateOptionsEmulatorSavetypeSram)
   1.232 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH, OnOptionsEmulatorSavetypeFlash)
   1.233 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH, OnUpdateOptionsEmulatorSavetypeFlash)
   1.234 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR, OnOptionsEmulatorSavetypeEepromsensor)
   1.235 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR, OnUpdateOptionsEmulatorSavetypeEepromsensor)
   1.236 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_NONE, OnOptionsEmulatorSavetypeNone)
   1.237 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_NONE, OnUpdateOptionsEmulatorSavetypeNone)
   1.238 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnOptionsEmulatorSavetypeFlash512k)
   1.239 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnUpdateOptionsEmulatorSavetypeFlash512k)
   1.240 +ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnOptionsEmulatorSavetypeFlash1m)
   1.241 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnUpdateOptionsEmulatorSavetypeFlash1m)
   1.242 +ON_COMMAND(ID_OPTIONS_EMULATOR_USEBIOSFILE, OnOptionsEmulatorUsebiosfile)
   1.243 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_USEBIOSFILE, OnUpdateOptionsEmulatorUsebiosfile)
   1.244 +ON_COMMAND(ID_OPTIONS_EMULATOR_SKIPBIOS, OnOptionsEmulatorSkipbios)
   1.245 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SKIPBIOS, OnUpdateOptionsEmulatorSkipbios)
   1.246 +ON_COMMAND(ID_OPTIONS_EMULATOR_SELECTBIOSFILE, OnOptionsEmulatorSelectbiosfile)
   1.247 +
   1.248 +ON_COMMAND(ID_EMULATOR_USE_OLD_FRAME_TIMING, OnOptionsEmulatorUseOldGBTiming)
   1.249 +ON_UPDATE_COMMAND_UI(ID_EMULATOR_USE_OLD_FRAME_TIMING, OnUpdateOptionsEmulatorUseOldGBTiming)
   1.250 +ON_COMMAND(ID_EMULATOR_USE_GB_INPUT_KLUDGE, OnOptionsEmulatorUseGBNullInputKludge)
   1.251 +ON_UPDATE_COMMAND_UI(ID_EMULATOR_USE_GB_INPUT_KLUDGE, OnUpdateOptionsEmulatorUseGBNullInputKludge)
   1.252 +ON_COMMAND(ID_EMULATOR_GBALAG, OnOptionsEmulatorGBALag)
   1.253 +ON_UPDATE_COMMAND_UI(ID_EMULATOR_GBALAG, OnUpdateOptionsEmulatorGBALag)
   1.254 +
   1.255 +ON_COMMAND(ID_OPTIONS_EMULATOR_PNGFORMAT, OnOptionsEmulatorPngformat)
   1.256 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PNGFORMAT, OnUpdateOptionsEmulatorPngformat)
   1.257 +ON_COMMAND(ID_OPTIONS_EMULATOR_BMPFORMAT, OnOptionsEmulatorBmpformat)
   1.258 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_BMPFORMAT, OnUpdateOptionsEmulatorBmpformat)
   1.259 +ON_COMMAND(ID_OPTIONS_SOUND_DISABLE, OnOptionsSoundDisable)
   1.260 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DISABLE, OnUpdateOptionsSoundDisable)
   1.261 +ON_COMMAND(ID_OPTIONS_SOUND_MUTE, OnOptionsSoundMute)
   1.262 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTE, OnUpdateOptionsSoundMute)
   1.263 +ON_COMMAND(ID_OPTIONS_SOUND_OFF, OnOptionsSoundOff)
   1.264 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_OFF, OnUpdateOptionsSoundOff)
   1.265 +ON_COMMAND(ID_OPTIONS_SOUND_ON, OnOptionsSoundOn)
   1.266 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_ON, OnUpdateOptionsSoundOn)
   1.267 +ON_COMMAND(ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION, OnOptionsSoundUseoldsynchronization)
   1.268 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION, OnUpdateOptionsSoundUseoldsynchronization)
   1.269 +ON_COMMAND(ID_OPTIONS_SOUND_ECHO, OnOptionsSoundEcho)
   1.270 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_ECHO, OnUpdateOptionsSoundEcho)
   1.271 +ON_COMMAND(ID_OPTIONS_SOUND_LOWPASSFILTER, OnOptionsSoundLowpassfilter)
   1.272 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_LOWPASSFILTER, OnUpdateOptionsSoundLowpassfilter)
   1.273 +ON_COMMAND(ID_OPTIONS_SOUND_REVERSESTEREO, OnOptionsSoundReversestereo)
   1.274 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_REVERSESTEREO, OnUpdateOptionsSoundReversestereo)
   1.275 +ON_COMMAND(ID_OPTIONS_SOUND_MUTEFRAMEADVANCE, OnOptionsSoundMuteFrameAdvance)
   1.276 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTEFRAMEADVANCE, OnUpdateOptionsSoundMuteFrameAdvance)
   1.277 +ON_COMMAND(ID_OPTIONS_SOUND_MUTEWHENINACTIVE, OnOptionsSoundMuteWhenInactive)
   1.278 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTEWHENINACTIVE, OnUpdateOptionsSoundMuteWhenInactive)
   1.279 +ON_COMMAND(ID_OPTIONS_SOUND_11KHZ, OnOptionsSound11khz)
   1.280 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_11KHZ, OnUpdateOptionsSound11khz)
   1.281 +ON_COMMAND(ID_OPTIONS_SOUND_22KHZ, OnOptionsSound22khz)
   1.282 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_22KHZ, OnUpdateOptionsSound22khz)
   1.283 +ON_COMMAND(ID_OPTIONS_SOUND_44KHZ, OnOptionsSound44khz)
   1.284 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_44KHZ, OnUpdateOptionsSound44khz)
   1.285 +ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL1, OnOptionsSoundChannel1)
   1.286 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL1, OnUpdateOptionsSoundChannel1)
   1.287 +ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL2, OnOptionsSoundChannel2)
   1.288 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL2, OnUpdateOptionsSoundChannel2)
   1.289 +ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL3, OnOptionsSoundChannel3)
   1.290 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL3, OnUpdateOptionsSoundChannel3)
   1.291 +ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL4, OnOptionsSoundChannel4)
   1.292 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL4, OnUpdateOptionsSoundChannel4)
   1.293 +ON_COMMAND(ID_OPTIONS_SOUND_DIRECTSOUNDA, OnOptionsSoundDirectsounda)
   1.294 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DIRECTSOUNDA, OnUpdateOptionsSoundDirectsounda)
   1.295 +ON_COMMAND(ID_OPTIONS_SOUND_DIRECTSOUNDB, OnOptionsSoundDirectsoundb)
   1.296 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DIRECTSOUNDB, OnUpdateOptionsSoundDirectsoundb)
   1.297 +ON_COMMAND(ID_OPTIONS_GAMEBOY_BORDER, OnOptionsGameboyBorder)
   1.298 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_BORDER, OnUpdateOptionsGameboyBorder)
   1.299 +ON_COMMAND(ID_OPTIONS_GAMEBOY_PRINTER, OnOptionsGameboyPrinter)
   1.300 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_PRINTER, OnUpdateOptionsGameboyPrinter)
   1.301 +ON_COMMAND(ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC, OnOptionsGameboyBorderAutomatic)
   1.302 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC, OnUpdateOptionsGameboyBorderAutomatic)
   1.303 +ON_COMMAND(ID_OPTIONS_GAMEBOY_AUTOMATIC, OnOptionsGameboyAutomatic)
   1.304 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_AUTOMATIC, OnUpdateOptionsGameboyAutomatic)
   1.305 +ON_COMMAND(ID_OPTIONS_GAMEBOY_GBA, OnOptionsGameboyGba)
   1.306 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GBA, OnUpdateOptionsGameboyGba)
   1.307 +ON_COMMAND(ID_OPTIONS_GAMEBOY_CGB, OnOptionsGameboyCgb)
   1.308 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_CGB, OnUpdateOptionsGameboyCgb)
   1.309 +ON_COMMAND(ID_OPTIONS_GAMEBOY_SGB, OnOptionsGameboySgb)
   1.310 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_SGB, OnUpdateOptionsGameboySgb)
   1.311 +ON_COMMAND(ID_OPTIONS_GAMEBOY_SGB2, OnOptionsGameboySgb2)
   1.312 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_SGB2, OnUpdateOptionsGameboySgb2)
   1.313 +ON_COMMAND(ID_OPTIONS_GAMEBOY_GB, OnOptionsGameboyGb)
   1.314 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GB, OnUpdateOptionsGameboyGb)
   1.315 +ON_COMMAND(ID_OPTIONS_GAMEBOY_REALCOLORS, OnOptionsGameboyRealcolors)
   1.316 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_REALCOLORS, OnUpdateOptionsGameboyRealcolors)
   1.317 +ON_COMMAND(ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS, OnOptionsGameboyGameboycolors)
   1.318 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS, OnUpdateOptionsGameboyGameboycolors)
   1.319 +ON_COMMAND(ID_OPTIONS_GAMEBOY_COLORS, OnOptionsGameboyColors)
   1.320 +ON_COMMAND(ID_OPTIONS_FILTER_DISABLEMMX, OnOptionsFilterDisablemmx)
   1.321 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_FILTER_DISABLEMMX, OnUpdateOptionsFilterDisablemmx)
   1.322 +ON_COMMAND(ID_OPTIONS_LANGUAGE_SYSTEM, OnOptionsLanguageSystem)
   1.323 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_SYSTEM, OnUpdateOptionsLanguageSystem)
   1.324 +ON_COMMAND(ID_OPTIONS_LANGUAGE_ENGLISH, OnOptionsLanguageEnglish)
   1.325 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_ENGLISH, OnUpdateOptionsLanguageEnglish)
   1.326 +ON_COMMAND(ID_OPTIONS_LANGUAGE_OTHER, OnOptionsLanguageOther)
   1.327 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_OTHER, OnUpdateOptionsLanguageOther)
   1.328 +ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_1, OnOptionsJoypadConfigure1)
   1.329 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_1, OnUpdateOptionsJoypadConfigure1)
   1.330 +ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_2, OnOptionsJoypadConfigure2)
   1.331 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_2, OnUpdateOptionsJoypadConfigure2)
   1.332 +ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_3, OnOptionsJoypadConfigure3)
   1.333 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_3, OnUpdateOptionsJoypadConfigure3)
   1.334 +ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_4, OnOptionsJoypadConfigure4)
   1.335 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_4, OnUpdateOptionsJoypadConfigure4)
   1.336 +ON_COMMAND(ID_OPTIONS_JOYPAD_MOTIONCONFIGURE, OnOptionsJoypadMotionconfigure)
   1.337 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_MOTIONCONFIGURE, OnUpdateOptionsJoypadMotionconfigure)
   1.338 +ON_COMMAND(ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT, OnOptionsJoypadAllowLeftRight)
   1.339 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT, OnUpdateOptionsJoypadAllowLeftRight)
   1.340 +ON_COMMAND(ID_OPTIONS_JOYPAD_AUTOFIRE_ACCOUNTFORLAG, OnOptionsJoypadAutofireAccountForLag)
   1.341 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_AUTOFIRE_ACCOUNTFORLAG, OnUpdateOptionsJoypadAutofireAccountForLag)
   1.342 +ON_COMMAND(ID_CHEATS_SEARCHFORCHEATS, OnCheatsSearchforcheats)
   1.343 +ON_UPDATE_COMMAND_UI(ID_CHEATS_SEARCHFORCHEATS, OnUpdateCheatsSearchforcheats)
   1.344 +ON_COMMAND(ID_CHEATS_CHEATLIST, OnCheatsCheatlist)
   1.345 +ON_UPDATE_COMMAND_UI(ID_CHEATS_CHEATLIST, OnUpdateCheatsCheatlist)
   1.346 +ON_COMMAND(ID_CHEATS_AUTOMATICSAVELOADCHEATS, OnCheatsAutomaticsaveloadcheats)
   1.347 +ON_COMMAND(ID_CHEATS_PAUSEDURINGCHEATSEARCH, OnCheatsPauseDuringCheatSearch)
   1.348 +ON_COMMAND(ID_CHEATS_LOADCHEATLIST, OnCheatsLoadcheatlist)
   1.349 +ON_UPDATE_COMMAND_UI(ID_CHEATS_LOADCHEATLIST, OnUpdateCheatsLoadcheatlist)
   1.350 +ON_COMMAND(ID_CHEATS_SAVECHEATLIST, OnCheatsSavecheatlist)
   1.351 +ON_UPDATE_COMMAND_UI(ID_CHEATS_SAVECHEATLIST, OnUpdateCheatsSavecheatlist)
   1.352 +ON_COMMAND(ID_TOOLS_DISASSEMBLE, OnToolsDisassemble)
   1.353 +ON_UPDATE_COMMAND_UI(ID_TOOLS_DISASSEMBLE, OnUpdateToolsDisassemble)
   1.354 +ON_COMMAND(ID_TOOLS_LOGGING, OnToolsLogging)
   1.355 +ON_UPDATE_COMMAND_UI(ID_TOOLS_LOGGING, OnUpdateToolsLogging)
   1.356 +ON_COMMAND(ID_TOOLS_IOVIEWER, OnToolsIoviewer)
   1.357 +ON_UPDATE_COMMAND_UI(ID_TOOLS_IOVIEWER, OnUpdateToolsIoviewer)
   1.358 +ON_COMMAND(ID_TOOLS_MAPVIEW, OnToolsMapview)
   1.359 +ON_UPDATE_COMMAND_UI(ID_TOOLS_MAPVIEW, OnUpdateToolsMapview)
   1.360 +ON_COMMAND(ID_TOOLS_MEMORYVIEWER, OnToolsMemoryviewer)
   1.361 +ON_UPDATE_COMMAND_UI(ID_TOOLS_MEMORYVIEWER, OnUpdateToolsMemoryviewer)
   1.362 +ON_COMMAND(ID_TOOLS_OAMVIEWER, OnToolsOamviewer)
   1.363 +ON_UPDATE_COMMAND_UI(ID_TOOLS_OAMVIEWER, OnUpdateToolsOamviewer)
   1.364 +ON_COMMAND(ID_TOOLS_PALETTEVIEW, OnToolsPaletteview)
   1.365 +ON_UPDATE_COMMAND_UI(ID_TOOLS_PALETTEVIEW, OnUpdateToolsPaletteview)
   1.366 +ON_COMMAND(ID_TOOLS_TILEVIEWER, OnToolsTileviewer)
   1.367 +ON_UPDATE_COMMAND_UI(ID_TOOLS_TILEVIEWER, OnUpdateToolsTileviewer)
   1.368 +
   1.369 +ON_COMMAND(ID_DEBUG_NEXTFRAME, OnDebugNextframe)
   1.370 +ON_UPDATE_COMMAND_UI(ID_DEBUG_NEXTFRAME, OnUpdateDebugNextframe)
   1.371 +ON_COMMAND(ID_DEBUG_NEXTFRAME_ACCOUNTFORLAG, OnDebugNextframeAccountForLag)
   1.372 +ON_UPDATE_COMMAND_UI(ID_DEBUG_NEXTFRAME_ACCOUNTFORLAG, OnUpdateDebugNextframeAccountForLag)
   1.373 +ON_COMMAND(ID_DEBUG_FRAMESEARCH, OnDebugFramesearch)
   1.374 +ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCH, OnUpdateDebugFramesearch)
   1.375 +ON_COMMAND(ID_DEBUG_FRAMESEARCHPREV, OnDebugFramesearchPrev)
   1.376 +ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCHPREV, OnUpdateDebugFramesearchPrev)
   1.377 +ON_COMMAND(ID_DEBUG_FRAMESEARCHLOAD, OnDebugFramesearchLoad)
   1.378 +ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCHLOAD, OnUpdateDebugFramesearchLoad)
   1.379 +ON_UPDATE_COMMAND_UI(ID_CHEATS_AUTOMATICSAVELOADCHEATS, OnUpdateCheatsAutomaticsaveloadcheats)
   1.380 +ON_UPDATE_COMMAND_UI(ID_CHEATS_PAUSEDURINGCHEATSEARCH, OnUpdateCheatsPauseDuringCheatSearch)
   1.381 +ON_COMMAND(ID_TOOLS_FRAMECOUNTER, OnToolsFrameCounter)
   1.382 +ON_UPDATE_COMMAND_UI(ID_TOOLS_FRAMECOUNTER, OnUpdateToolsFrameCounter)
   1.383 +ON_COMMAND(ID_TOOLS_LAGCOUNTER, OnToolsLagCounter)
   1.384 +ON_UPDATE_COMMAND_UI(ID_TOOLS_LAGCOUNTER, OnUpdateToolsLagCounter)
   1.385 +ON_COMMAND(ID_TOOLS_EXTRACOUNTER, OnToolsExtraCounter)
   1.386 +ON_UPDATE_COMMAND_UI(ID_TOOLS_EXTRACOUNTER, OnUpdateToolsExtraCounter)
   1.387 +ON_COMMAND(ID_TOOLS_EXTRACOUNTERRESET, OnToolsExtraCounterReset)
   1.388 +ON_COMMAND(ID_TOOLS_INPUTDISPLAY, OnToolsInputDisplay)
   1.389 +ON_UPDATE_COMMAND_UI(ID_TOOLS_INPUTDISPLAY, OnUpdateToolsInputDisplay)
   1.390 +ON_COMMAND(ID_TOOLS_DEBUG_GDB, OnToolsDebugGdb)
   1.391 +ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_GDB, OnUpdateToolsDebugGdb)
   1.392 +ON_COMMAND(ID_TOOLS_DEBUG_LOADANDWAIT, OnToolsDebugLoadandwait)
   1.393 +ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_LOADANDWAIT, OnUpdateToolsDebugLoadandwait)
   1.394 +ON_COMMAND(ID_TOOLS_DEBUG_BREAK, OnToolsDebugBreak)
   1.395 +ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_BREAK, OnUpdateToolsDebugBreak)
   1.396 +ON_COMMAND(ID_TOOLS_DEBUG_DISCONNECT, OnToolsDebugDisconnect)
   1.397 +ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_DISCONNECT, OnUpdateToolsDebugDisconnect)
   1.398 +
   1.399 +ON_COMMAND(ID_TOOLS_SOUNDRECORDING, OnToolsSoundRecording)
   1.400 +ON_UPDATE_COMMAND_UI(ID_TOOLS_SOUNDRECORDING, OnUpdateToolsSoundRecording)
   1.401 +ON_COMMAND(ID_TOOLS_AVIRECORDING, OnToolsAVIRecording)
   1.402 +ON_UPDATE_COMMAND_UI(ID_TOOLS_AVIRECORDING, OnUpdateToolsAVIRecording)
   1.403 +ON_COMMAND(ID_TOOLS_PAUSEAVIRECORDING, OnToolsPauseAVIRecording)
   1.404 +ON_UPDATE_COMMAND_UI(ID_TOOLS_PAUSEAVIRECORDING, OnUpdateToolsPauseAVIRecording)
   1.405 +
   1.406 +ON_COMMAND(ID_MOVIE_RECORD, OnToolsRecordMovie)
   1.407 +ON_UPDATE_COMMAND_UI(ID_MOVIE_RECORD, OnUpdateToolsRecordMovie)
   1.408 +ON_COMMAND(ID_MOVIE_STOP, OnToolsStopMovie)
   1.409 +ON_UPDATE_COMMAND_UI(ID_MOVIE_STOP, OnUpdateToolsStopMovie)
   1.410 +ON_COMMAND(ID_MOVIE_PLAY, OnToolsPlayMovie)
   1.411 +ON_UPDATE_COMMAND_UI(ID_MOVIE_PLAY, OnUpdateToolsPlayMovie)
   1.412 +ON_COMMAND(ID_MOVIE_READONLY, OnToolsPlayReadOnly)
   1.413 +ON_UPDATE_COMMAND_UI(ID_MOVIE_READONLY, OnUpdateToolsPlayReadOnly)
   1.414 +ON_COMMAND(ID_MOVIE_ASSC_WITH_SAVESTATE, OnAsscWithSaveState)
   1.415 +ON_UPDATE_COMMAND_UI(ID_MOVIE_ASSC_WITH_SAVESTATE, OnUpdateAsscWithSaveState)
   1.416 +ON_COMMAND(ID_MOVIE_RESUME_RECORD, OnToolsResumeRecord)
   1.417 +ON_UPDATE_COMMAND_UI(ID_MOVIE_RESUME_RECORD, OnUpdateToolsResumeRecord)
   1.418 +ON_COMMAND(ID_MOVIE_RESTART_PLAY, OnToolsPlayRestart)
   1.419 +ON_UPDATE_COMMAND_UI(ID_MOVIE_RESTART_PLAY, OnUpdateToolsPlayRestart)
   1.420 +
   1.421 +ON_COMMAND(ID_MOVIE_END_PAUSE, OnToolsOnMovieEndPause)
   1.422 +ON_UPDATE_COMMAND_UI(ID_MOVIE_END_PAUSE, OnUpdateToolsOnMovieEndPause)
   1.423 +ON_COMMAND(ID_MOVIE_END_STOP, OnToolsOnMovieEndStop)
   1.424 +ON_UPDATE_COMMAND_UI(ID_MOVIE_END_STOP, OnUpdateToolsOnMovieEndStop)
   1.425 +ON_COMMAND(ID_MOVIE_END_RESTART, OnToolsOnMovieEndRestart)
   1.426 +ON_UPDATE_COMMAND_UI(ID_MOVIE_END_RESTART, OnUpdateToolsOnMovieEndRestart)
   1.427 +ON_COMMAND(ID_MOVIE_END_APPEND, OnToolsOnMovieEndAppend)
   1.428 +ON_UPDATE_COMMAND_UI(ID_MOVIE_END_APPEND, OnUpdateToolsOnMovieEndAppend)
   1.429 +ON_COMMAND(ID_MOVIE_END_KEEP, OnToolsOnMovieEndKeep)
   1.430 +ON_UPDATE_COMMAND_UI(ID_MOVIE_END_KEEP, OnUpdateToolsOnMovieEndKeep)
   1.431 +
   1.432 +ON_COMMAND(ID_MOVIE_TOOL_SET_PAUSE_AT, OnToolsMovieSetPauseAt)
   1.433 +ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_SET_PAUSE_AT, OnUpdateToolsSetMoviePauseAt)
   1.434 +ON_COMMAND(ID_MOVIE_TOOL_CONVERT, OnToolsMovieConvertCurrent)
   1.435 +ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_CONVERT, OnUpdateToolsMovieConvertCurrent)
   1.436 +ON_COMMAND(ID_MOVIE_TOOL_AUTO_CONVERT, OnToolsMovieAutoConvert)
   1.437 +ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_AUTO_CONVERT, OnUpdateToolsMovieAutoConvert)
   1.438 +ON_COMMAND(ID_MOVIE_TOOL_FIX_HEADER, OnToolsMovieFixHeader)
   1.439 +ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_FIX_HEADER, OnUpdateToolsMovieFixHeader)
   1.440 +ON_COMMAND(ID_MOVIE_TOOL_TRUNCATE, OnToolsMovieTruncateAtCurrent)
   1.441 +ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_TRUNCATE, OnUpdateToolsMovieTruncateAtCurrent)
   1.442 +ON_COMMAND(ID_MOVIE_TOOL_EXTRACT_FROM_SAVEGAME, OnToolsMovieExtractFromSavegame)
   1.443 +ON_UPDATE_COMMAND_UI(ID_MOVIE_TOOL_EXTRACT_FROM_SAVEGAME, OnUpdateToolsMovieExtractFromSavegame)
   1.444 +
   1.445 +ON_COMMAND(ID_TOOLS_REWIND, OnToolsRewind)
   1.446 +ON_UPDATE_COMMAND_UI(ID_TOOLS_REWIND, OnUpdateToolsRewind)
   1.447 +ON_COMMAND(ID_TOOLS_CUSTOMIZE, OnToolsCustomize)
   1.448 +ON_UPDATE_COMMAND_UI(ID_TOOLS_CUSTOMIZE, OnUpdateToolsCustomize)
   1.449 +// ON_COMMAND(ID_TOOLS_CUSTOMIZE_COMMON, OnToolsCustomizeCommon)
   1.450 +// ON_UPDATE_COMMAND_UI(ID_TOOLS_CUSTOMIZE_COMMON, OnUpdateToolsCustomizeCommon)
   1.451 +ON_COMMAND(ID_HELP_BUGREPORT, OnHelpBugreport)
   1.452 +
   1.453 +ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE10, OnFileRecentFile)
   1.454 +ON_COMMAND_EX_RANGE(ID_FILE_LOADGAME_SLOT1, ID_FILE_LOADGAME_SLOT10, OnFileLoadSlot)
   1.455 +ON_COMMAND_EX_RANGE(ID_FILE_SAVEGAME_SLOT1, ID_FILE_SAVEGAME_SLOT10, OnFileSaveSlot)
   1.456 +ON_COMMAND_EX_RANGE(ID_SELECT_SLOT1, ID_SELECT_SLOT10, OnSelectSlot)
   1.457 +ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE10, OnUpdateFileRecentFile)
   1.458 +ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_LOADGAME_SLOT1, ID_FILE_LOADGAME_SLOT10, OnUpdateFileLoadSlot)
   1.459 +ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_SAVEGAME_SLOT1, ID_FILE_SAVEGAME_SLOT10, OnUpdateFileSaveSlot)
   1.460 +ON_UPDATE_COMMAND_UI_RANGE(ID_SELECT_SLOT1, ID_SELECT_SLOT10, OnUpdateSelectSlot)
   1.461 +
   1.462 +ON_COMMAND(ID_FILE_SAVEGAME_OLDESTSLOT, OnFileSavegameOldestslot)
   1.463 +ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_OLDESTSLOT, OnUpdateFileSavegameOldestslot)
   1.464 +ON_COMMAND(ID_FILE_LOADGAME_MOSTRECENT, OnFileLoadgameMostrecent)
   1.465 +ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MOSTRECENT, OnUpdateFileLoadgameMostrecent)
   1.466 +ON_COMMAND(ID_FILE_SAVEGAME_CURRENT, OnFileSavegameCurrent)
   1.467 +ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_CURRENT, OnUpdateFileSavegameCurrent)
   1.468 +ON_COMMAND(ID_FILE_LOADGAME_CURRENT, OnFileLoadgameCurrent)
   1.469 +ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_CURRENT, OnUpdateFileLoadgameCurrent)
   1.470 +ON_COMMAND(ID_FILE_LOADGAME_MAKECURRENT, OnFileLoadgameMakeCurrent)
   1.471 +ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MAKECURRENT, OnUpdateFileLoadgameMakeCurrent)
   1.472 +ON_COMMAND(ID_FILE_SAVEGAME_MAKECURRENT, OnFileSavegameMakeCurrent)
   1.473 +ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_MAKECURRENT, OnUpdateFileSavegameMakeCurrent)
   1.474 +
   1.475 +ON_COMMAND(ID_FILE_SAVEGAME_INCREMENTSLOT, OnFileSavegameIncrementSlot)
   1.476 +ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_INCREMENTSLOT, OnUpdateFileSavegameIncrementSlot)
   1.477 +ON_COMMAND(ID_FILE_SAVEGAME_DECREMENTSLOT, OnFileSavegameDecrementSlot)
   1.478 +ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_DECREMENTSLOT, OnUpdateFileSavegameDecrementSlot)
   1.479 +ON_COMMAND(ID_FILE_SLOT_DISPLAYMODIFICATIONTIME, OnFileSlotDisplayModificationTime)
   1.480 +ON_UPDATE_COMMAND_UI(ID_FILE_SLOT_DISPLAYMODIFICATIONTIME, OnUpdateFileSlotDisplayModificationTime)
   1.481 +
   1.482 +ON_COMMAND(ID_FILE_LOADGAME_AUTOLOADMOSTRECENT, OnFileLoadgameAutoloadmostrecent)
   1.483 +ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_AUTOLOADMOSTRECENT, OnUpdateFileLoadgameAutoloadmostrecent)
   1.484 +ON_COMMAND(ID_FILE_LOADGAME_MAKERECENT, OnFileLoadgameMakeRecent)
   1.485 +ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MAKERECENT, OnUpdateFileLoadgameMakeRecent)
   1.486 +
   1.487 +ON_COMMAND(ID_OPTIONS_SOUND_VOLUME_25X, OnOptionsSoundVolume25x)
   1.488 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_VOLUME_25X, OnUpdateOptionsSoundVolume25x)
   1.489 +ON_COMMAND(ID_OPTIONS_SOUND_VOLUME_5X, OnOptionsSoundVolume5x)
   1.490 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_VOLUME_5X, OnUpdateOptionsSoundVolume5x)
   1.491 +ON_COMMAND(ID_CHEATS_DISABLECHEATS, OnCheatsDisablecheats)
   1.492 +ON_UPDATE_COMMAND_UI(ID_CHEATS_DISABLECHEATS, OnUpdateCheatsDisablecheats)
   1.493 +ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE, OnOptionsVideoFullscreenmaxscale)
   1.494 +
   1.495 +ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_FRAMESKIP_0, ID_OPTIONS_VIDEO_FRAMESKIP_9, OnOptionsFrameskip)
   1.496 +ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_X1, ID_OPTIONS_VIDEO_X4, OnOptionVideoSize)
   1.497 +ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_LAYERS_BG0, ID_OPTIONS_VIDEO_LAYERS_OBJWIN, OnVideoLayer)
   1.498 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_VIDEO_LAYERS_BG0, ID_OPTIONS_VIDEO_LAYERS_OBJWIN, OnUpdateVideoLayer)
   1.499 +ON_COMMAND(ID_SYSTEM_MINIMIZE, OnSystemMinimize)
   1.500 +ON_COMMAND(ID_SYSTEM_MAXIMIZE, OnSystemMaximize)
   1.501 +ON_COMMAND_EX_RANGE(ID_OPTIONS_EMULATOR_SHOWSPEED_NONE, ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT, OnOptionsEmulatorShowSpeed)
   1.502 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_EMULATOR_SHOWSPEED_NONE,
   1.503 +                           ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT,
   1.504 +                           OnUpdateOptionsEmulatorShowSpeed)
   1.505 +ON_COMMAND_EX_RANGE(ID_OPTIONS_SOUND_VOLUME_1X, ID_OPTIONS_SOUND_VOLUME_4X, OnOptionsSoundVolume)
   1.506 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_SOUND_VOLUME_1X, ID_OPTIONS_SOUND_VOLUME_4X, OnUpdateOptionsSoundVolume)
   1.507 +ON_COMMAND_EX_RANGE(ID_OPTIONS_PRIORITY_HIGHEST, ID_OPTIONS_PRIORITY_BELOWNORMAL, OnOptionsPriority)
   1.508 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_PRIORITY_HIGHEST, ID_OPTIONS_PRIORITY_BELOWNORMAL, OnUpdateOptionsPriority)
   1.509 +
   1.510 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_NORMAL, ID_OPTIONS_FILTER_TVMODE, OnOptionsFilter)
   1.511 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL, ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL, OnOptionsFilter)
   1.512 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X, ID_OPTIONS_FILTER16BIT_SIMPLE2X, OnOptionsFilter)
   1.513 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_BILINEAR, ID_OPTIONS_FILTER_BILINEARPLUS, OnOptionsFilter)
   1.514 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_SCANLINES, ID_OPTIONS_FILTER_SCANLINES, OnOptionsFilter)
   1.515 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_LQ2X, ID_OPTIONS_FILTER_HQ3X2, OnOptionsFilter)
   1.516 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_SIMPLE3X, ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X, OnOptionsFilter)
   1.517 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_NORMAL, ID_OPTIONS_FILTER_TVMODE, OnUpdateOptionsFilter)
   1.518 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL, ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL, OnUpdateOptionsFilter)
   1.519 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X, ID_OPTIONS_FILTER16BIT_SIMPLE2X, OnUpdateOptionsFilter)
   1.520 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_BILINEAR, ID_OPTIONS_FILTER_BILINEARPLUS, OnUpdateOptionsFilter)
   1.521 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_SCANLINES, ID_OPTIONS_FILTER_SCANLINES, OnUpdateOptionsFilter)
   1.522 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_LQ2X, ID_OPTIONS_FILTER_HQ3X2, OnUpdateOptionsFilter)
   1.523 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_SIMPLE3X, ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL4X, OnUpdateOptionsFilter)
   1.524 +ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE, ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART, OnOptionsFilterIFB)
   1.525 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE,
   1.526 +                           ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART,
   1.527 +                           OnUpdateOptionsFilterIFB)
   1.528 +
   1.529 +ON_COMMAND_EX_RANGE(ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1, ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4, OnOptionsJoypadDefault)
   1.530 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1, ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4, OnUpdateOptionsJoypadDefault)
   1.531 +ON_COMMAND_EX_RANGE(ID_OPTIONS_JOYPAD_AUTOFIRE_A, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, OnOptionsJoypadAutofire)
   1.532 +ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_JOYPAD_AUTOFIRE_A, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, OnUpdateOptionsJoypadAutofire)
   1.533 +ON_COMMAND_EX_RANGE(ID_STICKY_A, ID_STICKY_CLEAR, OnOptionsJoypadSticky)
   1.534 +ON_UPDATE_COMMAND_UI_RANGE(ID_STICKY_A, ID_STICKY_CLEAR, OnUpdateOptionsJoypadSticky)
   1.535 +ON_MESSAGE(VBA_CONFIRM_MODE, OnConfirmMode)
   1.536 +ON_MESSAGE(WM_SYSCOMMAND, OnMySysCommand)
   1.537 +ON_COMMAND(ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS, OnOptionsVideoTextdisplayoptions)
   1.538 +ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS, OnUpdateOptionsVideoTextdisplayoptions)
   1.539 +
   1.540 +ON_COMMAND(ID_FILE_LUA_OPEN, OnFileLuaOpen)
   1.541 +ON_UPDATE_COMMAND_UI(ID_FILE_LUA_OPEN, OnUpdateFileLuaOpen)
   1.542 +ON_COMMAND(ID_FILE_LUA_CLOSE_ALL, OnFileLuaCloseAll)
   1.543 +ON_UPDATE_COMMAND_UI(ID_FILE_LUA_CLOSE_ALL, OnUpdateFileLuaCloseAll)
   1.544 +ON_COMMAND(ID_FILE_LUA_RELOAD, OnFileLuaReload)
   1.545 +ON_COMMAND(ID_FILE_LUA_STOP, OnFileLuaStop)
   1.546 +ON_COMMAND(ID_RAM_SEARCH, OnFileRamSearch)
   1.547 +ON_UPDATE_COMMAND_UI(ID_RAM_SEARCH, OnUpdateFileRamSearch)
   1.548 +ON_COMMAND(ID_RAM_WATCH, OnFileRamWatch)
   1.549 +ON_UPDATE_COMMAND_UI(ID_RAM_WATCH, OnUpdateFileRamWatch)
   1.550 +//}}AFX_MSG_MAP
   1.551 +END_MESSAGE_MAP()
   1.552 +
   1.553 +/////////////////////////////////////////////////////////////////////////////
   1.554 +// MainWnd message handlers
   1.555 +
   1.556 +bool vbaShuttingDown = false;
   1.557 +
   1.558 +void MainWnd::OnClose()
   1.559 +{
   1.560 +	vbaShuttingDown = true; // HACK to fix crash on exit while memory viewer is open
   1.561 +
   1.562 +	CWnd::OnClose();
   1.563 +
   1.564 +	delete this;
   1.565 +}
   1.566 +
   1.567 +void MainWnd::OnMove(int x, int y)
   1.568 +{
   1.569 +	CWnd::OnMove(x, y);
   1.570 +
   1.571 +	if (!theApp.changingVideoSize)
   1.572 +	{
   1.573 +		if (this)
   1.574 +		{
   1.575 +			if (!IsIconic() && !IsZoomed())
   1.576 +			{
   1.577 +				RECT r;
   1.578 +
   1.579 +				GetWindowRect(&r);
   1.580 +				theApp.windowPositionX = r.left;
   1.581 +				theApp.windowPositionY = r.top;
   1.582 +				theApp.adjustDestRect();
   1.583 +				regSetDwordValue("windowX", theApp.windowPositionX);
   1.584 +				regSetDwordValue("windowY", theApp.windowPositionY);
   1.585 +			}
   1.586 +		}
   1.587 +	}
   1.588 +}
   1.589 +
   1.590 +void MainWnd::OnSize(UINT nType, int cx, int cy)
   1.591 +{
   1.592 +	CWnd::OnSize(nType, cx, cy);
   1.593 +
   1.594 +	static int lastType = -1;
   1.595 +
   1.596 +	// FIXME: hack to re-maximize window after it auto-unmaximizes while loading a ROM
   1.597 +	if (nType == SIZE_MAXIMIZED && lastType == SIZE_MAXIMIZED)
   1.598 +	{
   1.599 +		lastType = -1;
   1.600 +		ShowWindow(SW_SHOWMAXIMIZED);
   1.601 +		MoveWindow(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
   1.602 +		return;
   1.603 +	}
   1.604 +
   1.605 +	lastType = nType;
   1.606 +
   1.607 +	if (IsIconic())
   1.608 +	{
   1.609 +		theApp.iconic = true;
   1.610 +		return;
   1.611 +	}
   1.612 +	else if (theApp.iconic)
   1.613 +	{
   1.614 +		theApp.iconic = false;
   1.615 +	}
   1.616 +
   1.617 +	if (!theApp.changingVideoSize)
   1.618 +	{
   1.619 +		if (this)
   1.620 +		{
   1.621 +			if (theApp.videoOption <= VIDEO_4X)
   1.622 +			{
   1.623 +				theApp.surfaceSizeX = cx;
   1.624 +				theApp.surfaceSizeY = cy;
   1.625 +				theApp.adjustDestRect();
   1.626 +				if (theApp.display)
   1.627 +					theApp.display->resize(theApp.dest.right - theApp.dest.left, theApp.dest.bottom - theApp.dest.top);
   1.628 +				systemRefreshScreen();  // useful when shrinking
   1.629 +			}
   1.630 +		}
   1.631 +	}
   1.632 +}
   1.633 +
   1.634 +void MainWnd::OnContextMenu(CWnd *pWnd, CPoint point)
   1.635 +{
   1.636 +	winMouseOn();
   1.637 +}
   1.638 +
   1.639 +void MainWnd::OnSystemMinimize()
   1.640 +{
   1.641 +	ShowWindow(SW_SHOWMINIMIZED);
   1.642 +}
   1.643 +
   1.644 +void MainWnd::OnSystemMaximize()
   1.645 +{
   1.646 +	ShowWindow(SW_SHOWMAXIMIZED);
   1.647 +}
   1.648 +
   1.649 +void MainWnd::OnPaint()
   1.650 +{
   1.651 +	CPaintDC dc(this); // device context for painting, calling BeginPaint/EndPaint internally
   1.652 +	if (emulating && (!theApp.active || theApp.paused))
   1.653 +	{
   1.654 +		systemRedrawScreen();
   1.655 +	}
   1.656 +}
   1.657 +
   1.658 +static bool translatingAccelerator = false;
   1.659 +
   1.660 +// FIXME: this fix for accel keys is ugly
   1.661 +//   using too many static variables for a single accel key kludge
   1.662 +static bool	  recursiveCall	  = true;
   1.663 +static bool	  fullUpdated	  = false;
   1.664 +static bool	  lastKeyModifier = false;  // maybe better check current key press status instead
   1.665 +static WPARAM lastKey		  = 0;
   1.666 +
   1.667 +BOOL MainWnd::PreTranslateMessage(MSG *pMsg)
   1.668 +{
   1.669 +	if (RamSearchHWnd && ::IsDialogMessage(RamSearchHWnd, pMsg))
   1.670 +	{
   1.671 +		return TRUE;
   1.672 +	}
   1.673 +	else if (RamWatchHWnd && ::IsDialogMessage(RamWatchHWnd, pMsg))
   1.674 +	{
   1.675 +		if (RamWatchAccels)
   1.676 +			TranslateAccelerator(RamWatchHWnd, RamWatchAccels, pMsg);
   1.677 +		return TRUE;
   1.678 +	}
   1.679 +	else if (LuaConsoleHWnd && ::IsDialogMessage(LuaConsoleHWnd, pMsg))
   1.680 +	{
   1.681 +		return TRUE;
   1.682 +	}
   1.683 +	else if (CWnd::PreTranslateMessage(pMsg))
   1.684 +	{
   1.685 +		return TRUE;
   1.686 +	}
   1.687 +	else if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)
   1.688 +	{
   1.689 +		translatingAccelerator = true;
   1.690 +
   1.691 +		bool bHit		= theApp.hAccel != NULL &&  ::TranslateAccelerator(m_hWnd, theApp.hAccel, pMsg);
   1.692 +		bool isModifier = pMsg->wParam == VK_SHIFT || pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_MENU;
   1.693 +
   1.694 +		// HACK to get around the fact that TranslateAccelerator can't handle modifier-only accelerators
   1.695 +		// (it would be better to fix TranslateAccelerator, but its code is in a Microsoft library...)
   1.696 +		if (!bHit)
   1.697 +		{
   1.698 +			if (isModifier)
   1.699 +			{
   1.700 +				// do a linear loop through all accelerators to find modifier-only ones...
   1.701 +				CCmdAccelOb *pCmdAccel;
   1.702 +				WORD		 wKey;
   1.703 +				CAccelsOb *	 pAccelOb;
   1.704 +				POSITION	 pos	   = theApp.winAccelMgr.m_mapAccelTable.GetStartPosition();
   1.705 +				const int	 modifiers = ((pMsg->wParam == VK_SHIFT) ? FSHIFT : ((pMsg->wParam == VK_CONTROL) ? FCONTROL : FALT));
   1.706 +				while (pos != NULL)
   1.707 +				{
   1.708 +					theApp.winAccelMgr.m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
   1.709 +					POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
   1.710 +					while (pos != NULL)
   1.711 +					{
   1.712 +						pAccelOb = pCmdAccel->m_Accels.GetNext(pos);
   1.713 +
   1.714 +						if (pAccelOb->m_wKey == 0) // if accelerator-only
   1.715 +						{
   1.716 +							if ((pAccelOb->m_cVirt & modifiers) == modifiers) // if modifier matches
   1.717 +							{
   1.718 +								bHit = true;
   1.719 +								SendMessage(WM_COMMAND, pCmdAccel->m_wIDCommand, 0); // tell Windows to call the right function
   1.720 +							}
   1.721 +						}
   1.722 +					}
   1.723 +				}
   1.724 +			}
   1.725 +
   1.726 +			if (!bHit)
   1.727 +			{
   1.728 +				lastKeyModifier = true;
   1.729 +			}
   1.730 +		}
   1.731 +
   1.732 +		if (bHit)
   1.733 +		{
   1.734 +			if (lastKeyModifier && !isModifier)
   1.735 +			{
   1.736 +				fullUpdated		= false;
   1.737 +				lastKeyModifier = false;
   1.738 +			}
   1.739 +
   1.740 +			if (lastKey != pMsg->wParam)
   1.741 +			{
   1.742 +				fullUpdated = false;
   1.743 +				lastKey		= pMsg->wParam;
   1.744 +			}
   1.745 +		}
   1.746 +
   1.747 +		translatingAccelerator = false;
   1.748 +		return bHit ? TRUE : FALSE;
   1.749 +	}
   1.750 +
   1.751 +	return FALSE;
   1.752 +}
   1.753 +
   1.754 +void MainWnd::OnMouseMove(UINT nFlags, CPoint point)
   1.755 +{
   1.756 +	winMouseOn();
   1.757 +
   1.758 +	CWnd::OnMouseMove(nFlags, point);
   1.759 +}
   1.760 +
   1.761 +// recursive kludge
   1.762 +static void InitMenuKludge(CMenu *pParentMenu, CMenu *pMenu, CCmdTarget *pWnd)
   1.763 +{
   1.764 +	ASSERT(pMenu != NULL);
   1.765 +
   1.766 +	CCmdUI state;
   1.767 +	state.m_pParentMenu = pParentMenu;
   1.768 +	state.m_pMenu		= pMenu;
   1.769 +	ASSERT(state.m_pOther == NULL);
   1.770 +
   1.771 +	state.m_nIndexMax = pMenu->GetMenuItemCount();
   1.772 +	for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
   1.773 +	     state.m_nIndex++)
   1.774 +	{
   1.775 +		state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
   1.776 +		if (state.m_nID == 0)
   1.777 +			continue;  // menu separator or invalid cmd - ignore it
   1.778 +
   1.779 +		ASSERT(state.m_pOther == NULL);
   1.780 +		ASSERT(state.m_pMenu != NULL);
   1.781 +		if (state.m_nID == (UINT)-1)
   1.782 +		{
   1.783 +			// possibly a popup menu, route to first item of that popup
   1.784 +			state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
   1.785 +			if (state.m_pSubMenu == NULL)
   1.786 +			{
   1.787 +				continue; // first item of popup can't be routed to
   1.788 +			}
   1.789 +
   1.790 +			state.DoUpdate(pWnd, false);
   1.791 +			if (recursiveCall)
   1.792 +			{
   1.793 +				// FIXME: slow recursive calls to fix enabling/disabling of accel keys
   1.794 +				InitMenuKludge(state.m_pMenu, state.m_pSubMenu, pWnd);
   1.795 +			}
   1.796 +		}
   1.797 +		else
   1.798 +		{
   1.799 +			// normal menu item
   1.800 +			// Auto enable/disable if frame window has 'm_bAutoMenuEnable'
   1.801 +			//    set and command is _not_ a system command.
   1.802 +			state.m_pSubMenu = NULL;
   1.803 +			state.DoUpdate(pWnd, state.m_nID < 0xF000);
   1.804 +		}
   1.805 +
   1.806 +		// adjust for menu deletions and additions
   1.807 +		UINT nCount = pMenu->GetMenuItemCount();
   1.808 +		if (nCount < state.m_nIndexMax)
   1.809 +		{
   1.810 +			state.m_nIndex -= (state.m_nIndexMax - nCount);
   1.811 +			while (state.m_nIndex < nCount &&
   1.812 +			       pMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
   1.813 +			{
   1.814 +				state.m_nIndex++;
   1.815 +			}
   1.816 +		}
   1.817 +		state.m_nIndexMax = nCount;
   1.818 +	}
   1.819 +}
   1.820 +
   1.821 +void MainWnd::OnInitMenuPopup(CMenu *pMenu, UINT nIndex, BOOL bSysMenu)
   1.822 +{
   1.823 +	ASSERT(pMenu != NULL);
   1.824 +
   1.825 +	CCmdUI state;
   1.826 +	state.m_pMenu = pMenu;
   1.827 +	ASSERT(state.m_pOther == NULL);
   1.828 +	ASSERT(state.m_pParentMenu == NULL);
   1.829 +
   1.830 +	// determine if menu is popup in top-level menu and set m_pOther to
   1.831 +	//  it if so (m_pParentMenu == NULL indicates that it is secondary popup)
   1.832 +	HMENU hParentMenu;
   1.833 +	if (AfxGetThreadState()->m_hTrackingMenu == pMenu->m_hMenu)
   1.834 +		state.m_pParentMenu = pMenu;  // parent == child for tracking popup
   1.835 +	else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
   1.836 +	{
   1.837 +		CWnd *pParent = GetTopLevelParent();
   1.838 +		// children windows don't have menus -- need to go to the top!
   1.839 +		if (pParent != NULL &&
   1.840 +		    (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
   1.841 +		{
   1.842 +			int nIndexMax = ::GetMenuItemCount(hParentMenu);
   1.843 +			for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
   1.844 +			{
   1.845 +				if (::GetSubMenu(hParentMenu, nIndex) == pMenu->m_hMenu)
   1.846 +				{
   1.847 +					// when popup is found, m_pParentMenu is containing menu
   1.848 +					state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
   1.849 +					break;
   1.850 +				}
   1.851 +			}
   1.852 +		}
   1.853 +	}
   1.854 +
   1.855 +	// FIXME: magic to workaround the accel key bug without slowing down too much
   1.856 +	if (translatingAccelerator && !fullUpdated && state.m_pParentMenu == &theApp.m_menu)
   1.857 +	{
   1.858 +		state.m_pMenu = state.m_pParentMenu;
   1.859 +		recursiveCall = true;
   1.860 +		fullUpdated	  = true;
   1.861 +	}
   1.862 +	else if (!translatingAccelerator && fullUpdated)
   1.863 +	{
   1.864 +		fullUpdated = false;
   1.865 +	}
   1.866 +
   1.867 +	InitMenuKludge(state.m_pParentMenu, state.m_pMenu, this);
   1.868 +
   1.869 +	recursiveCall = false;
   1.870 +}
   1.871 +
   1.872 +void MainWnd::OnInitMenu(CMenu *pMenu)
   1.873 +{
   1.874 +//	CWnd::OnInitMenu(pMenu);
   1.875 +
   1.876 +	if (translatingAccelerator)
   1.877 +	{}
   1.878 +	else
   1.879 +	{
   1.880 +		// HACK: we only want to call this if the user is pulling down the menu,
   1.881 +		// but TranslateAccelerator also causes OnInitMenu to be called, so ignore that
   1.882 +
   1.883 +		systemSoundPause();
   1.884 +	}
   1.885 +}
   1.886 +
   1.887 +void MainWnd::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
   1.888 +{
   1.889 +	CWnd::OnActivate(nState, pWndOther, bMinimized);
   1.890 +
   1.891 +	bool activated = (nState == WA_ACTIVE || nState == WA_CLICKACTIVE) && !bMinimized;
   1.892 +
   1.893 +	theApp.active = activated || !theApp.pauseWhenInactive;
   1.894 +
   1.895 +	extern bool inputActive;
   1.896 +	inputActive = activated || (!theApp.pauseWhenInactive && theApp.enableBackgroundInput);
   1.897 +
   1.898 +	if (theApp.active)
   1.899 +	{
   1.900 +		if (theApp.input)
   1.901 +		{
   1.902 +			theApp.input->activate();
   1.903 +		}
   1.904 +
   1.905 +		if (!theApp.paused && emulating)
   1.906 +		{
   1.907 +			systemSoundResume();
   1.908 +		}
   1.909 +	}
   1.910 +	else
   1.911 +	{
   1.912 +		theApp.wasPaused = true;
   1.913 +
   1.914 +		if (!theApp.paused && emulating)
   1.915 +		{
   1.916 +			systemSoundPause();
   1.917 +		}
   1.918 +
   1.919 +		memset(theApp.delta, 255, sizeof(theApp.delta));
   1.920 +	}
   1.921 +
   1.922 +	if (theApp.muteWhenInactive)
   1.923 +	{
   1.924 +		theApp.winMuteForNow = !activated;
   1.925 +	}
   1.926 +
   1.927 +	if (theApp.paused && emulating)
   1.928 +	{
   1.929 +		systemRefreshScreen();
   1.930 +	}
   1.931 +}
   1.932 +
   1.933 +#if _MSC_VER <= 1200
   1.934 +void MainWnd::OnActivateApp(BOOL bActive, HTASK hTask)
   1.935 +#else
   1.936 +void MainWnd::OnActivateApp(BOOL bActive, DWORD hTask)
   1.937 +#endif
   1.938 +{
   1.939 +	CWnd::OnActivateApp(bActive, hTask);
   1.940 +
   1.941 +	if (theApp.tripleBuffering && theApp.videoOption > VIDEO_4X)
   1.942 +	{
   1.943 +		if (bActive)
   1.944 +		{
   1.945 +			if (theApp.display)
   1.946 +				theApp.display->clear();
   1.947 +		}
   1.948 +	}
   1.949 +}
   1.950 +
   1.951 +LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam)
   1.952 +{
   1.953 +	if (emulating && !theApp.paused)
   1.954 +	{
   1.955 +		if ((wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER)
   1.956 +			return 0;
   1.957 +	}
   1.958 +	return Default();
   1.959 +}
   1.960 +
   1.961 +void MainWnd::OnDropFiles(HDROP hDropInfo)
   1.962 +{
   1.963 +	// FIXME: required for the accel key fix
   1.964 +	fullUpdated = false;
   1.965 +
   1.966 +	systemSoundClearBuffer();
   1.967 +
   1.968 +	char szFile[1024];
   1.969 +	char ext[1024];
   1.970 +
   1.971 +	if (DragQueryFile(hDropInfo, 0, szFile, 1024))
   1.972 +	{
   1.973 +		DragFinish(hDropInfo);
   1.974 +
   1.975 +		_splitpath(szFile, NULL, NULL, NULL, ext);
   1.976 +		if (strcasecmp(ext, ".lua") == 0)
   1.977 +		{
   1.978 +			if (VBALoadLuaCode(szFile))
   1.979 +			{
   1.980 +				// success, there is nothing to do
   1.981 +			}
   1.982 +			else
   1.983 +			{
   1.984 +				// Errors are displayed by the Lua code.
   1.985 +			}
   1.986 +		}
   1.987 +		else if (strcasecmp(ext, ".vbm") == 0)
   1.988 +		{
   1.989 +			SMovie movieInfo;
   1.990 +			char * movieName = szFile;
   1.991 +			char   romTitle [12];
   1.992 +			uint32 romGameCode;
   1.993 +			uint16 checksum;
   1.994 +			uint8  crc;
   1.995 +
   1.996 +			if (VBAMovieGetInfo(movieName, &movieInfo) != MOVIE_SUCCESS)
   1.997 +			{
   1.998 +				return;
   1.999 +			}
  1.1000 +
  1.1001 +			int cartType = movieInfo.header.typeFlags & 1 ? 0 : 1;
  1.1002 +
  1.1003 +			if (!emulating)
  1.1004 +			{
  1.1005 +				theApp.winCheckFullscreen();
  1.1006 +				if (winFileOpenSelect(cartType))
  1.1007 +				{
  1.1008 +					if (VBAMovieActive())
  1.1009 +						VBAMovieStop(false);  // will only get here on user selecting to play a ROM, canceling movie
  1.1010 +					if (!winFileRun())
  1.1011 +						return;
  1.1012 +				}
  1.1013 +				else
  1.1014 +					return;
  1.1015 +			}
  1.1016 +			VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
  1.1017 +
  1.1018 +			while (movieInfo.header.romCRC != crc
  1.1019 +			       || strncmp(movieInfo.header.romTitle, romTitle, 12) != 0
  1.1020 +			       || movieInfo.header.romOrBiosChecksum != checksum
  1.1021 +			       && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) == 0 && checksum == 0))
  1.1022 +			{
  1.1023 +				char msg[1024], warning1[1024], warning2[1024], buffer[1024];
  1.1024 +
  1.1025 +				strcpy(warning1, "");
  1.1026 +				strcpy(warning2, "");
  1.1027 +				{
  1.1028 +					char str [13];
  1.1029 +					strncpy(str, movieInfo.header.romTitle, 12);
  1.1030 +					str[12] = '\0';
  1.1031 +					sprintf(buffer, "title=%s  ", str);
  1.1032 +					strcat(warning1, buffer);
  1.1033 +
  1.1034 +					strncpy(str, romTitle, 12);
  1.1035 +					str[12] = '\0';
  1.1036 +					sprintf(buffer, "title=%s  ", str);
  1.1037 +					strcat(warning2, buffer);
  1.1038 +				}
  1.1039 +				{
  1.1040 +					sprintf(buffer, "type=%s  ",
  1.1041 +					        (movieInfo.header.typeFlags & MOVIE_TYPE_GBA) ?
  1.1042 +					        "GBA" : (movieInfo.header.typeFlags & MOVIE_TYPE_GBC) ?
  1.1043 +					        "GBC" : (movieInfo.header.typeFlags & MOVIE_TYPE_SGB) ? "SGB" : "GB");
  1.1044 +					strcat(warning1, buffer);
  1.1045 +
  1.1046 +					sprintf(buffer, "type=%s  ", systemCartridgeType ==
  1.1047 +					        0 ? "GBA" : (gbRom[0x143] & 0x80 ? "GBC" : (gbRom[0x146] == 0x03 ? "SGB" : "GB")));
  1.1048 +					strcat(warning2, buffer);
  1.1049 +				}
  1.1050 +				{
  1.1051 +					sprintf(buffer, "crc=%02x  ", movieInfo.header.romCRC);
  1.1052 +					strcat(warning1, buffer);
  1.1053 +
  1.1054 +					sprintf(buffer, "crc=%02x  ", crc);
  1.1055 +					strcat(warning2, buffer);
  1.1056 +				}
  1.1057 +				{
  1.1058 +					char code [5];
  1.1059 +					if (movieInfo.header.typeFlags & MOVIE_TYPE_GBA)
  1.1060 +					{
  1.1061 +						memcpy(code, &movieInfo.header.romGameCode, 4);
  1.1062 +						code[4] = '\0';
  1.1063 +						sprintf(buffer, "code=%s  ", code);
  1.1064 +						strcat(warning1, buffer);
  1.1065 +					}
  1.1066 +
  1.1067 +					if (systemCartridgeType == 0)
  1.1068 +					{
  1.1069 +						memcpy(code, &romGameCode, 4);
  1.1070 +						code[4] = '\0';
  1.1071 +						sprintf(buffer, "code=%s  ", code);
  1.1072 +						strcat(warning2, buffer);
  1.1073 +					}
  1.1074 +				}
  1.1075 +				{
  1.1076 +					sprintf(buffer,
  1.1077 +					        movieInfo.header.typeFlags &
  1.1078 +					        MOVIE_TYPE_GBA ? ((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) ==
  1.1079 +					                          0 ? "(bios=none)  " : "(bios=%04x)  ") : "check=%04x  ",
  1.1080 +					        movieInfo.header.romOrBiosChecksum);
  1.1081 +					strcat(warning1, buffer);
  1.1082 +
  1.1083 +					sprintf(buffer,
  1.1084 +					        checksum == 0 ? "(bios=none)  " : systemCartridgeType == 0 ? "(bios=%04x)  " : "check=%04x  ",
  1.1085 +					        checksum);
  1.1086 +					strcat(warning2, buffer);
  1.1087 +				}
  1.1088 +
  1.1089 +				strcpy(msg, "");
  1.1090 +				sprintf(buffer, "Movie ROM: %s\n", warning1);
  1.1091 +				strcat(msg, buffer);
  1.1092 +				sprintf(buffer, "Your ROM: %s\n", warning2);
  1.1093 +				strcat(msg, buffer);
  1.1094 +				strcat(msg, "still want to play the movie?");
  1.1095 +
  1.1096 +				int sel = MessageBox(msg, TEXT("ROM Mismatch"), MB_ABORTRETRYIGNORE | MB_ICONQUESTION);
  1.1097 +				switch (sel)
  1.1098 +				{
  1.1099 +				case IDABORT:
  1.1100 +					return;
  1.1101 +				case IDRETRY:
  1.1102 +					theApp.winCheckFullscreen();
  1.1103 +					if (winFileOpenSelect(cartType))
  1.1104 +					{
  1.1105 +						if (VBAMovieActive())
  1.1106 +							VBAMovieStop(false);  // will only get here on user selecting to play a ROM, canceling movie
  1.1107 +						if (!winFileRun())
  1.1108 +							return;
  1.1109 +						VBAMovieGetRomInfo(movieInfo, romTitle, romGameCode, checksum, crc);
  1.1110 +					}
  1.1111 +					else
  1.1112 +						return;
  1.1113 +					break;
  1.1114 +				default:
  1.1115 +					goto romcheck_exit;
  1.1116 +				}
  1.1117 +			}
  1.1118 +romcheck_exit:
  1.1119 +
  1.1120 +			bool useBIOSFile = (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0;
  1.1121 +			if (useBIOSFile)
  1.1122 +			{
  1.1123 +				extern bool systemLoadBIOS(const char *biosFileName, bool useBiosFile);
  1.1124 +				if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
  1.1125 +				{
  1.1126 +					systemMessage(0, "This movie requires a valid GBA BIOS file to play.\nPlease locate a BIOS file.");
  1.1127 +					((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile();
  1.1128 +					if (!systemLoadBIOS(theApp.biosFileName, useBIOSFile))
  1.1129 +					{
  1.1130 +						systemMessage(0, "\"%s\" is not a valid BIOS file; cannot play movie without one.", theApp.biosFileName);
  1.1131 +						return;
  1.1132 +					}
  1.1133 +				}
  1.1134 +			}
  1.1135 +
  1.1136 +			int code = VBAMovieOpen(movieName, TRUE);
  1.1137 +
  1.1138 +			if (code != MOVIE_SUCCESS)
  1.1139 +			{
  1.1140 +				if (code == MOVIE_FILE_NOT_FOUND)
  1.1141 +					systemMessage(0, "Could not find movie file \"%s\".", (const char *)movieName);
  1.1142 +				else if (code == MOVIE_WRONG_FORMAT)
  1.1143 +					systemMessage(0, "Movie file \"%s\" is not in proper VBM format.", (const char *)movieName);
  1.1144 +				else if (code == MOVIE_WRONG_VERSION)
  1.1145 +					systemMessage(0, "Movie file \"%s\" is not a supported version.", (const char *)movieName);
  1.1146 +				else
  1.1147 +					systemMessage(0, "Failed to open movie \"%s\".", (const char *)movieName);
  1.1148 +				return;
  1.1149 +			}
  1.1150 +		}
  1.1151 +		else if (strcasecmp(ext, ".wch") == 0)
  1.1152 +		{
  1.1153 +			if (emulating)
  1.1154 +			{
  1.1155 +				MainWnd::OnFileRamWatch();
  1.1156 +				Load_Watches(true, szFile);
  1.1157 +			}
  1.1158 +		}
  1.1159 +		else
  1.1160 +		{
  1.1161 +			theApp.romFilename = szFile;
  1.1162 +			if (winFileRun())
  1.1163 +			{
  1.1164 +				SetForegroundWindow();
  1.1165 +			}
  1.1166 +		}
  1.1167 +	}
  1.1168 +	else
  1.1169 +		DragFinish(hDropInfo);
  1.1170 +}
  1.1171 +
  1.1172 +/////////////////////
  1.1173 +
  1.1174 +void MainWnd::winMouseOn()
  1.1175 +{
  1.1176 +	SetCursor(arrow);
  1.1177 +	if (theApp.videoOption > VIDEO_4X)
  1.1178 +	{
  1.1179 +		theApp.mouseCounter = 120;
  1.1180 +	}
  1.1181 +	else
  1.1182 +		theApp.mouseCounter = 0;
  1.1183 +}
  1.1184 +
  1.1185 +void MainWnd::winConfirmMode()
  1.1186 +{
  1.1187 +	if (theApp.renderMethod == DIRECT_DRAW && theApp.videoOption > VIDEO_4X)
  1.1188 +	{
  1.1189 +		theApp.winCheckFullscreen();
  1.1190 +		ModeConfirm dlg(this);
  1.1191 +
  1.1192 +		if (!dlg.DoModal())
  1.1193 +		{
  1.1194 +			theApp.updateVideoSize(ID_OPTIONS_VIDEO_X2);
  1.1195 +		}
  1.1196 +	}
  1.1197 +}
  1.1198 +
  1.1199 +bool MainWnd::winFileOpenSelect(int cartridgeType)
  1.1200 +{
  1.1201 +	int selectedFilter = regQueryDwordValue("selectedFilter", 0);
  1.1202 +	if (selectedFilter < 0 || selectedFilter > 2)
  1.1203 +		selectedFilter = 0;
  1.1204 +
  1.1205 +	LPCTSTR exts[] = { NULL };
  1.1206 +	CString filter = winResLoadFilter(IDS_FILTER_ROM);
  1.1207 +	CString title  = winResLoadString(IDS_SELECT_ROM);
  1.1208 +
  1.1209 +	bool	isOverrideEmpty = false;
  1.1210 +	CString initialDir		= regQueryStringValue(cartridgeType == 0 ? IDS_ROM_DIR : IDS_GBXROM_DIR, NULL);
  1.1211 +	if (initialDir.IsEmpty())
  1.1212 +	{
  1.1213 +		isOverrideEmpty = true;
  1.1214 +		CString altDir = regQueryStringValue(cartridgeType != 0 ? IDS_ROM_DIR : IDS_GBXROM_DIR, NULL);
  1.1215 +		initialDir = altDir.IsEmpty() ? theApp.exeDir : altDir;
  1.1216 +	}
  1.1217 +
  1.1218 +	FileDlg dlg(this, "", filter, selectedFilter, "ROM", exts, initialDir, title, false, true);
  1.1219 +
  1.1220 +	if (dlg.DoModal() == IDOK)
  1.1221 +	{
  1.1222 +		regSetDwordValue("selectedFilter", dlg.m_ofn.nFilterIndex);
  1.1223 +		theApp.romFilename = dlg.GetPathName();
  1.1224 +		initialDir		   = winGetDirFromFilename(theApp.romFilename);
  1.1225 +
  1.1226 +		// we have directory override for that purpose
  1.1227 +		// but this can be...desirable
  1.1228 +		if (isOverrideEmpty)
  1.1229 +			regSetStringValue(cartridgeType == 0 ? IDS_ROM_DIR : IDS_GBXROM_DIR, initialDir);
  1.1230 +		return true;
  1.1231 +	}
  1.1232 +	return false;
  1.1233 +}
  1.1234 +
  1.1235 +// some extensions that might commonly be near emulation-related files that we almost certainly can't open, or at least not
  1.1236 +// directly.
  1.1237 +// also includes definitely non-ROM extensions we know about, since we only use this variable in a ROM opening function.
  1.1238 +// we do this by exclusion instead of inclusion because we don't want to exclude extensions used for any archive files, even
  1.1239 +// extensionless or unusually-named archives.
  1.1240 +static const char *s_romIgnoreExtensions[] = {
  1.1241 +	"vbm", "sgm",  "clt",  "dat",	"gbs",	"gcf",	"spc", "xpc", "pal", "act", "dmp", "avi", "ini", "txt", "nfo",
  1.1242 +	"htm", "html", "jpg",  "jpeg",	"png",	"bmp",	"gif", "mp3", "wav", "lnk", "exe", "bat", "sav", "luasav"
  1.1243 +};
  1.1244 +
  1.1245 +#include "GBACheatsDlg.h"
  1.1246 +#include "GBCheatsDlg.h"
  1.1247 +
  1.1248 +#include "../common/CheatSearch.h"
  1.1249 +#include "../gba/GBA.h"
  1.1250 +#include "../gb/GB.h"
  1.1251 +#include "../gba/Flash.h"
  1.1252 +#include "../gba/RTC.h"
  1.1253 +
  1.1254 +void MainWnd::winFileClose(bool reopening)
  1.1255 +{
  1.1256 +	if (rom != NULL || gbRom != NULL)
  1.1257 +	{
  1.1258 +		if (theApp.autoSaveLoadCheatList)
  1.1259 +			winSaveCheatListDefault();
  1.1260 +
  1.1261 +		if (!reopening)
  1.1262 +		{
  1.1263 +			// save battery file before we change the filename...
  1.1264 +			winWriteBatteryFile();
  1.1265 +			cheatSearchCleanup(&cheatSearchData);
  1.1266 +			capturePrevious = 0;
  1.1267 +			captureNumber	= 0;
  1.1268 +		}
  1.1269 +
  1.1270 +		theApp.emulator.emuCleanUp();
  1.1271 +
  1.1272 +		extern void remoteCleanUp();
  1.1273 +		remoteCleanUp();
  1.1274 +	}
  1.1275 +
  1.1276 +	if (VBAMovieActive())
  1.1277 +		VBAMovieStop(false);  // will only get here on user selecting to open a ROM, canceling movie
  1.1278 +
  1.1279 +	theApp.frameSearching	   = false;
  1.1280 +	theApp.frameSearchSkipping = false;
  1.1281 +	emulating = 0;
  1.1282 +
  1.1283 +	if (this)
  1.1284 +		RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
  1.1285 +	systemSetTitle(VBA_NAME_AND_VERSION);
  1.1286 +}
  1.1287 +
  1.1288 +bool MainWnd::winFileRun(bool reopening)
  1.1289 +{
  1.1290 +	int prevCartridgeType = systemCartridgeType;
  1.1291 +
  1.1292 +	//bool requiresInitRAMSearch = (rom == NULL && gbRom == NULL) || !reopening;
  1.1293 +	winFileClose(reopening);
  1.1294 +
  1.1295 +	// use ObtainFile to support opening files within archives (.7z, .rar, .zip, .zip.rar.7z, etc.)
  1.1296 +	if (theApp.romFilename.GetLength() > 2048) theApp.romFilename.Truncate(2048);
  1.1297 +
  1.1298 +	char logicalName[2048], physicalName[2048];
  1.1299 +
  1.1300 +	// FIXME: assertion failure in fopen.c if canceled
  1.1301 +	if (ObtainFile(theApp.romFilename, logicalName, physicalName, "rom", s_romIgnoreExtensions,
  1.1302 +	               sizeof(s_romIgnoreExtensions) / sizeof(*s_romIgnoreExtensions)))
  1.1303 +	{
  1.1304 +		// theApp.romFilename is exactly the filename used for opening, while theApp.gameFilename is always the logical name
  1.1305 +		theApp.romFilename = theApp.gameFilename = logicalName;
  1.1306 +		ReleaseTempFileCategory("rom", physicalName);
  1.1307 +	}
  1.1308 +	else
  1.1309 +	{
  1.1310 +		return false;
  1.1311 +	}
  1.1312 +
  1.1313 +	IMAGE_TYPE type = utilFindType(physicalName);
  1.1314 +
  1.1315 +	if (type == IMAGE_UNKNOWN)
  1.1316 +	{
  1.1317 +		systemMessage(IDS_UNSUPPORTED_FILE_TYPE,
  1.1318 +		              "The file \"%s\" is an unsupported type.", logicalName);
  1.1319 +		return false;
  1.1320 +	}
  1.1321 +	systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
  1.1322 +	systemCartridgeType		= (int)type;
  1.1323 +	if (type == IMAGE_GB)
  1.1324 +	{
  1.1325 +		if (!gbLoadRom(physicalName))
  1.1326 +			return false;
  1.1327 +
  1.1328 +		gbBorderOn		= theApp.winGbBorderOn;
  1.1329 +		theApp.emulator = GBSystem;
  1.1330 +		theApp.romSize	= gbRomSize;
  1.1331 +		if (theApp.autoIPS)
  1.1332 +		{
  1.1333 +			CString ipsname = winGetDestFilename(logicalName, IDS_IPS_DIR, ".ips");
  1.1334 +			int		size	= gbRomSize;
  1.1335 +			utilApplyIPS(ipsname, &gbRom, &size);
  1.1336 +			if (size != gbRomSize)
  1.1337 +			{
  1.1338 +				extern bool gbUpdateSizes();
  1.1339 +				gbUpdateSizes();
  1.1340 +				theApp.romSize = size;
  1.1341 +			}
  1.1342 +		}
  1.1343 +
  1.1344 +		useBios = false;    // FIXME
  1.1345 +		
  1.1346 +		if (reopening)
  1.1347 +		{
  1.1348 +			bool winGbCheatReaddress();
  1.1349 +			winGbCheatReaddress();
  1.1350 +		}
  1.1351 +	}
  1.1352 +	else
  1.1353 +	{
  1.1354 +		int size = CPULoadRom(physicalName);
  1.1355 +		if (!size)
  1.1356 +			return false;
  1.1357 +
  1.1358 +		flashSetSize(theApp.winFlashSize);
  1.1359 +		rtcEnable(theApp.winRtcEnable);
  1.1360 +		cpuSaveType = theApp.winSaveType;
  1.1361 +
  1.1362 +		//    if(cpuEnhancedDetection && winSaveType == 0) {
  1.1363 +		//      utilGBAFindSave(rom, size);
  1.1364 +		//    }
  1.1365 +
  1.1366 +		char buffer[5];
  1.1367 +		strncpy(buffer, (const char *)&rom[0xac], 4);
  1.1368 +		buffer[4] = 0;
  1.1369 +
  1.1370 +		// vba-over.ini
  1.1371 +		CString vbaOverINI = theApp.exeDir;
  1.1372 +		vbaOverINI += "\\vba-over.ini";
  1.1373 +
  1.1374 +		UINT i = GetPrivateProfileInt(buffer, "rtcEnabled", -1, vbaOverINI);
  1.1375 +		if (i != (UINT)-1)
  1.1376 +			rtcEnable(i == 0 ? false : true);
  1.1377 +
  1.1378 +		i = GetPrivateProfileInt(buffer, "flashSize", -1, vbaOverINI);
  1.1379 +		if (i != (UINT)-1 && (i == 0x10000 || i == 0x20000))
  1.1380 +			flashSetSize((int)i);
  1.1381 +
  1.1382 +		i = GetPrivateProfileInt(buffer, "saveType", -1, vbaOverINI);
  1.1383 +		if (i != (UINT)-1 && (i <= 5))
  1.1384 +			cpuSaveType = (int)i;
  1.1385 +
  1.1386 +		/* disabled due to problems
  1.1387 +		   if(theApp.removeIntros && rom != NULL) {
  1.1388 +		   *((u32 *)rom)= 0xea00002e;
  1.1389 +		   }
  1.1390 +		 */
  1.1391 +		theApp.emulator = GBASystem;
  1.1392 +		theApp.romSize	= size;
  1.1393 +		if (theApp.autoIPS)
  1.1394 +		{
  1.1395 +			CString ipsname = winGetDestFilename(logicalName, IDS_IPS_DIR, ".ips");
  1.1396 +			int		size	= 0x2000000;
  1.1397 +			utilApplyIPS(ipsname, &rom, &size);
  1.1398 +		}
  1.1399 +
  1.1400 +		skipBios = theApp.skipBiosFile ? true : false;
  1.1401 +		CPUInit();
  1.1402 +		CPULoadBios(theApp.biosFileName, theApp.useBiosFile ? true : false);
  1.1403 +		CPUReset();
  1.1404 +
  1.1405 +		if (reopening)
  1.1406 +		{
  1.1407 +			bool winGbaCheatReaddress();
  1.1408 +			winGbaCheatReaddress();
  1.1409 +		}
  1.1410 +	}
  1.1411 +
  1.1412 +	if (theApp.soundInitialized)
  1.1413 +	{
  1.1414 +		if (systemCartridgeType == 1)
  1.1415 +			gbSoundReset();
  1.1416 +		else
  1.1417 +			soundReset();
  1.1418 +	}
  1.1419 +	else
  1.1420 +	{
  1.1421 +		if (!soundOffFlag)
  1.1422 +			soundInit();
  1.1423 +		theApp.soundInitialized = true;
  1.1424 +	}
  1.1425 +
  1.1426 +	winReadBatteryFile();
  1.1427 +
  1.1428 +	emulating = true;
  1.1429 +
  1.1430 +	if (theApp.autoSaveLoadCheatList)
  1.1431 +		winLoadCheatListDefault();
  1.1432 +
  1.1433 +	if (theApp.filenamePreference == 0)
  1.1434 +		theApp.addRecentFile(winGetOriginalFilename(logicalName));
  1.1435 +	else
  1.1436 +		theApp.addRecentFile(logicalName);
  1.1437 +
  1.1438 +	theApp.updateWindowSize(theApp.videoOption);
  1.1439 +
  1.1440 +	theApp.updateFrameSkip();
  1.1441 +
  1.1442 +	if (theApp.autoHideMenu && theApp.videoOption > VIDEO_4X && theApp.menuToggle)
  1.1443 +		OnFileTogglemenu();
  1.1444 +
  1.1445 +	if (theApp.autoLoadMostRecent && !VBAMovieActive() && !VBAMovieLoading()) // would cause desync in movies...
  1.1446 +		OnFileLoadgameMostrecent();
  1.1447 +
  1.1448 +	theApp.renderedFrames = 0;
  1.1449 +
  1.1450 +	theApp.rewindCount		= 0;
  1.1451 +	theApp.rewindCounter	= 0;
  1.1452 +	theApp.rewindSaveNeeded = false;
  1.1453 +
  1.1454 +	{
  1.1455 +		extern bool playMovieFile, playMovieFileReadOnly, outputWavFile, outputAVIFile, flagHideMenu; // from VBA.cpp
  1.1456 +		extern char movieFileToPlay[1024], wavFileToOutput[1024]; // from VBA.cpp
  1.1457 +		extern int	pauseAfterTime; // from VBA.cpp
  1.1458 +		if (playMovieFile)
  1.1459 +		{
  1.1460 +			playMovieFile = false;
  1.1461 +			VBAMovieOpen(movieFileToPlay, playMovieFileReadOnly);
  1.1462 +		}
  1.1463 +		if (outputWavFile)
  1.1464 +		{
  1.1465 +			outputWavFile = false;
  1.1466 +			theApp.soundRecordName = wavFileToOutput;
  1.1467 +			theApp.soundRecording  = true;
  1.1468 +		}
  1.1469 +		if (outputAVIFile)
  1.1470 +		{
  1.1471 +			outputAVIFile = false;
  1.1472 +			OnToolsStartAVIRecording();
  1.1473 +		}
  1.1474 +		if (pauseAfterTime >= 0)
  1.1475 +		{
  1.1476 +			VBAMovieSetPauseAt(pauseAfterTime);
  1.1477 +		}
  1.1478 +		if (flagHideMenu)
  1.1479 +		{
  1.1480 +			OnFileTogglemenu();
  1.1481 +			theApp.updateWindowSize(theApp.videoOption);
  1.1482 +		}
  1.1483 +	}
  1.1484 +
  1.1485 +	if (systemCartridgeType != prevCartridgeType)
  1.1486 +	{
  1.1487 +		extern GBACheatSearch gbaDlg;
  1.1488 +		extern GBCheatSearch  gbDlg;
  1.1489 +		if (!theApp.pauseDuringCheatSearch && theApp.modelessCheatDialogIsOpen)
  1.1490 +		{
  1.1491 +			gbaDlg.DestroyWindow();
  1.1492 +			gbDlg.DestroyWindow();
  1.1493 +			theApp.modelessCheatDialogIsOpen = false;
  1.1494 +		}
  1.1495 +	}
  1.1496 +
  1.1497 +	theApp.winCheckFullscreen();
  1.1498 +	ReopenRamWindows();
  1.1499 +
  1.1500 +	// FIXME
  1.1501 +	reset_address_info();
  1.1502 +	//if (requiresInitRAMSearch)
  1.1503 +	{
  1.1504 +		// extern void soft_reset_address_info();
  1.1505 +		// soft_reset_address_info();
  1.1506 +	}
  1.1507 +
  1.1508 +	VBAUpdateButtonPressDisplay();
  1.1509 +	VBAUpdateFrameCountDisplay();
  1.1510 +	systemRefreshScreen();
  1.1511 +
  1.1512 +	return true;
  1.1513 +}
  1.1514 +