1 #pragma once 2 3 #ifndef __AFXWIN_H__ 4 #error include 'stdafx.h' before including this file for PCH 5 #endif 6 7 #include "resource.h" 8 9 #include "AcceleratorManager.h" 10 #include "Display.h" 11 #include "Input.h" 12 #include "IUpdate.h" 13 #include "../System.h" 14 #include "common/ConfigManager.h" 15 #include "../Util.h" 16 17 ///////////////////////////////////////////////////////////////////////////// 18 // VBA: 19 // See VBA.cpp for the implementation of this class 20 // 21 22 enum VIDEO_SIZE{ 23 VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X, VIDEO_5X, VIDEO_6X, 24 VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_1024x768, VIDEO_1280x1024, 25 VIDEO_OTHER 26 }; 27 28 enum pixelFilterType 29 { 30 FILTER_NONE, 31 32 FILTER_SIMPLE2X, FILTER_PIXELATE, FILTER_TVMODE, FILTER_SCANLINES, 33 FILTER_PLUGIN, 34 FILTER_BILINEAR, FILTER_BILINEARPLUS, FILTER_MAMESCALE2X, 35 FILTER_2XSAI, FILTER_SUPER2XSAI, FILTER_SUPEREAGLE, FILTER_LQ2X, FILTER_HQ2X, FILTER_XBRZ2X, 36 37 FILTER_SIMPLE3X, FILTER_HQ3X, FILTER_XBRZ3X, 38 39 FILTER_SIMPLE4X, FILTER_HQ4X, FILTER_XBRZ4X, 40 41 FILTER_XBRZ5X, 42 43 FILTER_XBRZ6X, 44 45 FILTER_LAST = FILTER_XBRZ6X 46 }; 47 48 enum AUDIO_API { 49 DIRECTSOUND = 0 50 #ifndef NO_OAL 51 , OPENAL_SOUND = 1 52 #endif 53 #ifndef NO_XAUDIO2 54 , XAUDIO2 = 2 55 #endif 56 }; 57 58 #define REWIND_SIZE 400000 59 60 class AVIWrite; 61 class WavWriter; 62 63 class VBA : public CWinApp 64 { 65 public: 66 CMenu m_menu; 67 HMENU menu; 68 HMENU popup; 69 70 AVIWrite *aviRecorder; 71 72 char *rewindMemory; 73 char pluginName[MAX_PATH]; 74 CString aviRecordName; 75 CString biosFileNameGB; 76 CString biosFileNameGBA; 77 CString biosFileNameGBC; 78 CString languageName; 79 CString linkHostAddr; 80 CString recentFiles[10]; 81 CString screenMessageBuffer; 82 CString soundRecordName; 83 DISPLAY_TYPE renderMethod; 84 DWORD screenMessageTime; 85 FILE *movieFile; 86 FILE *winout; 87 HMODULE languageModule; 88 IDisplay *display; 89 IMAGE_TYPE cartridgeType; 90 91 bool soundInitialized; 92 93 Input *input; 94 95 u8 *delta[257 * 244 * 4]; 96 unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect 97 unsigned int skipAudioFrames; 98 void(*filterFunction)(u8*, u32, u8*, u8*, u32, int, int); 99 void(*ifbFunction)(u8*, u32, int, int); 100 WavWriter *soundRecorder; 101 102 bool changingVideoSize; 103 AUDIO_API audioAPI; 104 #ifndef NO_OAL 105 TCHAR *oalDevice; 106 int oalBufferCount; 107 #endif 108 #ifndef NO_XAUDIO2 109 UINT32 xa2Device; 110 UINT32 xa2BufferCount; 111 bool xa2Upmixing; 112 #endif 113 #ifndef NO_D3D 114 int d3dFilter; 115 bool d3dMotionBlur; 116 #endif 117 bool iconic; 118 bool painting; 119 int romSize; 120 VIDEO_SIZE lastWindowed; 121 VIDEO_SIZE lastFullscreen; 122 123 CList<IUpdateListener *, IUpdateListener*&> updateList; 124 int updateCount; 125 126 CAcceleratorManager winAccelMgr; 127 HACCEL hAccel; 128 129 RECT rect; 130 RECT dest; 131 132 struct EmulatedSystem emulator; 133 134 CString szFile; 135 CString filename; 136 CString dir; 137 138 CString loadDotCodeFile; 139 CString saveDotCodeFile; 140 141 CString wndClass; 142 143 public: 144 VBA(); 145 ~VBA(); 146 147 void adjustDestRect(); 148 void updateIFB(); 149 void updateFilter(); 150 void updateThrottle( unsigned short throttle ); 151 void updateMenuBar(); 152 void winAddUpdateListener(IUpdateListener *l); 153 void winRemoveUpdateListener(IUpdateListener *l); 154 CString winLoadFilter(UINT id); 155 156 // Overrides 157 // ClassWizard generated virtual function overrides 158 //{{AFX_VIRTUAL(VBA) 159 public: 160 virtual BOOL InitInstance(); 161 virtual BOOL OnIdle(LONG lCount); 162 //}}AFX_VIRTUAL 163 164 // Implementation 165 166 public: 167 void saveSettings(); 168 void movieReadNext(); 169 bool initInput(); 170 HMODULE winLoadLanguage(const char *name); 171 void winSetLanguageOption(int option, bool force); 172 #ifdef MMX 173 bool detectMMX(); 174 #endif 175 void updatePriority(); 176 void directXMessage(const char *msg); 177 void shutdownDisplay(); 178 bool preInitialize(); 179 bool updateRenderMethod0(bool force); 180 bool updateRenderMethod(bool force); 181 bool initDisplay(); 182 void updateWindowSize(int value); 183 void updateVideoSize(UINT id); 184 void updateFrameSkip(); 185 void loadSettings(); 186 void addRecentFile(CString file); 187 188 private: 189 unsigned int detectCpuCores(); 190 }; 191 192 extern VBA theApp; 193 extern int emulating; 194 195 #ifdef MMX 196 extern "C" bool cpu_mmx; 197 #endif 198