1 // -*- C++ -*-
2 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
3 // Copyright (C) 1999-2003 Forgotten
4 // Copyright (C) 2004 Forgotten and the VBA development team
5 
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or(at your option)
9 // any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 // VBA.h : main header file for the VBA application
21 //
22 
23 #if !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_)
24 #define AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_
25 
26 #if _MSC_VER > 1000
27 #pragma once
28 #endif // _MSC_VER > 1000
29 
30 #ifndef __AFXWIN_H__
31 #error include 'stdafx.h' before including this file for PCH
32 #endif
33 
34 #include <afxtempl.h>
35 
36 #include "AcceleratorManager.h"
37 #include "resource.h"       // main symbols
38 #include "Display.h"
39 #include "Input.h"
40 #include "IUpdate.h"
41 #include "Sound.h"
42 #include "../System.h"
43 
44 /////////////////////////////////////////////////////////////////////////////
45 // VBA:
46 // See VBA.cpp for the implementation of this class
47 //
48 
49 enum {
50   VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X,
51   VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_OTHER
52 };
53 
54 #define REWIND_SIZE 400000
55 
56 class CSkin;
57 class AVIWrite;
58 class WavWriter;
59 
60 class VBA : public CWinApp
61 {
62  public:
63   CMenu m_menu;
64   HMENU menu;
65   HMENU popup;
66   bool mode320Available;
67   bool mode640Available;
68   bool mode800Available;
69   int windowPositionX;
70   int windowPositionY;
71   void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int);
72   void (*ifbFunction)(u8*,u32,int,int);
73   int ifbType;
74   int filterType;
75   int filterWidth;
76   int filterHeight;
77   int fsWidth;
78   int fsHeight;
79   int fsColorDepth;
80   bool fsForceChange;
81   int sizeX;
82   int sizeY;
83   int surfaceSizeX;
84   int surfaceSizeY;
85   int videoOption;
86   bool fullScreenStretch;
87   bool disableStatusMessage;
88   int showSpeed;
89   BOOL showSpeedTransparent;
90   int showRenderedFrames;
91   bool screenMessage;
92   CString screenMessageBuffer;
93   DWORD screenMessageTime;
94   u8 *delta[257*244*4];
95   bool menuToggle;
96   IDisplay *display;
97   int cartridgeType;
98   bool soundInitialized;
99   bool useBiosFile;
100   bool skipBiosFile;
101   CString biosFileName;
102   bool active;
103   bool paused;
104   CString recentFiles[10];
105   bool recentFreeze;
106   bool autoSaveLoadCheatList;
107   FILE *winout;
108   bool removeIntros;
109   bool autoIPS;
110   int winGbBorderOn;
111   int winFlashSize;
112   bool winRtcEnable;
113   int winSaveType;
114   char *rewindMemory;
115   int rewindPos;
116   int rewindTopPos;
117   int rewindCounter;
118   int rewindCount;
119   bool rewindSaveNeeded;
120   int rewindTimer;
121   int captureFormat;
122   bool tripleBuffering;
123   bool autoHideMenu;
124   int throttle;
125   u32 throttleLastTime;
126   u32 autoFrameSkipLastTime;
127   bool autoFrameSkip;
128   bool vsync;
129   bool changingVideoSize;
130   GUID videoDriverGUID;
131   GUID *pVideoDriverGUID;
132   DISPLAY_TYPE renderMethod;
133   bool iconic;
134   bool ddrawEmulationOnly;
135   bool ddrawUsingEmulationOnly;
136   bool ddrawDebug;
137   bool ddrawUseVideoMemory;
138   int d3dFilter;
139   int glFilter;
140   int glType;
141   CSkin *skin;
142   CString skinName;
143   bool skinEnabled;
144   int skinButtons;
145   bool pauseWhenInactive;
146   bool speedupToggle;
147   bool useOldSync;
148   bool winGbPrinterEnabled;
149   int threadPriority;
150   bool disableMMX;
151   int languageOption;
152   CString languageName;
153   HINSTANCE languageModule;
154   int renderedFrames;
155   Input *input;
156   int joypadDefault;
157   int autoFire;
158   bool autoFireToggle;
159   bool winPauseNextFrame;
160   bool soundRecording;
161   WavWriter *soundRecorder;
162   CString soundRecordName;
163   ISound *sound;
164   bool aviRecording;
165   AVIWrite *aviRecorder;
166   CString aviRecordName;
167   int aviFrameNumber;
168   bool painting;
169   bool movieRecording;
170   bool moviePlaying;
171   int movieFrame;
172   int moviePlayFrame;
173   FILE *movieFile;
174   u32 movieLastJoypad;
175   u32 movieNextJoypad;
176   int sensorX;
177   int sensorY;
178   int mouseCounter;
179   bool wasPaused;
180   int frameskipadjust;
181   bool autoLoadMostRecent;
182   int fsMaxScale;
183   int romSize;
184 
185   CList<IUpdateListener *, IUpdateListener*&> updateList;
186   int updateCount;
187 
188   CAcceleratorManager winAccelMgr;
189   HACCEL hAccel;
190 
191   RECT rect;
192   RECT dest;
193 
194   struct EmulatedSystem emulator;
195 
196   CString szFile;
197   CString filename;
198   CString dir;
199 
200   CString wndClass;
201 
202  public:
203   VBA();
204   ~VBA();
205 
206   void adjustDestRect();
207   void updateIFB();
208   void updateFilter();
209   void updateMenuBar();
210   void winAddUpdateListener(IUpdateListener *l);
211   void winRemoveUpdateListener(IUpdateListener *l);
212   CString winLoadFilter(UINT id);
213 
214   // Overrides
215   // ClassWizard generated virtual function overrides
216   //{{AFX_VIRTUAL(VBA)
217  public:
218   virtual BOOL InitInstance();
219   virtual BOOL OnIdle(LONG lCount);
220   //}}AFX_VIRTUAL
221 
222   // Implementation
223 
224  public:
225   void saveSettings();
226   void movieReadNext();
227   bool initInput();
228   HINSTANCE winLoadLanguage(const char *name);
229   void winSetLanguageOption(int option, bool force);
230   bool detectMMX();
231 #ifdef MMX
232 #endif
233   void updatePriority();
234   void winUpdateSkin();
235   void directXMessage(const char *msg);
236   void shutdownDisplay();
237   void winCheckFullscreen();
238   bool updateRenderMethod0(bool force);
239   bool updateRenderMethod(bool force);
240   bool initDisplay();
241   void updateWindowSize(int value);
242   void updateVideoSize(UINT id);
243   void updateFrameSkip();
244   void loadSettings();
245   void addRecentFile(CString file);
246   //{{AFX_MSG(VBA)
247   afx_msg void OnAppAbout();
248   // NOTE - the ClassWizard will add and remove member functions here.
249   //    DO NOT EDIT what you see in these blocks of generated code !
250   //}}AFX_MSG
251   DECLARE_MESSAGE_MAP()
252     };
253 
254     extern VBA theApp;
255 
256 #ifdef MMX
257     extern "C" bool cpu_mmx;
258 #endif
259 
260     /////////////////////////////////////////////////////////////////////////////
261 
262     //{{AFX_INSERT_LOCATION}}
263     // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
264 
265 #endif // !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_)
266