forked from snes9xgit/snes9x
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwsnes9x.h
465 lines (411 loc) · 10.5 KB
/
wsnes9x.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
/*****************************************************************************\
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
This file is licensed under the Snes9x License.
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
/*****************************************************************************/
/* Snes9x: Win32 */
/*****************************************************************************/
#if !defined(SNES9X_H_INCLUDED)
#define SNES9X_H_INCLUDED
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifndef STRICT
#define STRICT
#endif
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <ddraw.h>
#include <mmsystem.h>
#ifndef __BORLANDC__
#include <dsound.h>
#endif
#include "rsrc/resource.h"
#include "port.h"
#define COUNT(a) (sizeof (a) / sizeof (a[0]))
#define MAX_AUDIO_NAME_LENGTH 1024
#define MAX_RECENT_GAMES_LIST_SIZE 32
#define MAX_RECENT_HOSTS_LIST_SIZE 16
#define SAVE_SLOTS_PER_BANK 10
#define LAST_SAVE_SLOT_IN_BANK (SAVE_SLOTS_PER_BANK - 1)
#define NUM_SAVE_BANKS 10
#define LAST_SAVE_BANK (NUM_SAVE_BANKS - 1)
#include "_tfwopen.h"
#ifdef UNICODE
#define _tToChar WideToUtf8
#define _tFromChar Utf8ToWide
#define _tFromMS932(x) CPToWide(x,932)
#else
#define _tToChar
#define _tFromChar
#define _tFromMS932
#endif
/****************************************************************************/
inline static void Log (const char *str)
{
FILE *fs = fopen ("snes9x.log", "a");
if (fs)
{
fprintf (fs, "%s\n", str);
fflush (fs);
fclose (fs);
}
}
enum RenderFilter{
FILTER_NONE = 0,
FILTER_SIMPLE1X,
FILTER_SIMPLE2X,
FILTER_SCANLINES,
FILTER_TVMODE,
FILTER_BLARGGRF,
FILTER_BLARGGCOMP,
FILTER_BLARGGSVID,
FILTER_BLARGGRGB,
FILTER_SUPEREAGLE,
FILTER_SUPER2XSAI,
FILTER_2XSAI,
FILTER_HQ2X,
FILTER_HQ2XS,
FILTER_HQ2XBOLD,
FILTER_EPXA,
FILTER_EPXB,
FILTER_EPXC,
FILTER_SIMPLE3X,
FILTER_TVMODE3X,
FILTER_DOTMATRIX3X,
FILTER_HQ3X,
FILTER_HQ3XS,
FILTER_HQ3XBOLD,
FILTER_LQ3XBOLD,
FILTER_EPX3,
FILTER_SIMPLE4X,
FILTER_HQ4X,
FILTER_2XBRZ,
FILTER_3XBRZ,
FILTER_4XBRZ,
FILTER_5XBRZ,
FILTER_6XBRZ,
NUM_FILTERS
};
enum OutputMethod {
DIRECTDRAW = 0,
DIRECT3D,
OPENGL
};
struct dMode
{
long height;
long width;
long depth;
long rate;
};
struct sCustomRomDlgSettings {
int columnFilename;
int columnDescription;
int columnSize;
int folderPaneWidth;
RECT window_size;
bool window_maximized;
};
struct sGUI {
HWND hWnd;
HMENU hMenu;
HINSTANCE hInstance;
DWORD hFrameTimer;
DWORD hHotkeyTimer;
HANDLE ClientSemaphore;
HANDLE FrameTimerSemaphore;
HANDLE ServerTimerSemaphore;
BYTE Language;
//Graphic Settings
dMode FullscreenMode;
RenderFilter Scale;
RenderFilter ScaleHiRes;
bool BlendHiRes;
bool AVIHiRes;
bool DoubleBuffered;
bool FullScreen;
bool Stretch;
bool HeightExtend;
bool AspectRatio;
bool IntegerScaling;
OutputMethod outputMethod;
int AspectWidth;
bool AlwaysCenterImage;
bool EmulateFullscreen;
bool EmulatedFullscreen;
bool LocalVidMem;
bool Vsync;
bool ReduceInputLag;
bool shaderEnabled;
bool DWMSync;
TCHAR D3DshaderFileName[MAX_PATH];
TCHAR OGLshaderFileName[MAX_PATH];
bool OGLdisablePBOs;
bool filterMessagFont;
bool IgnoreNextMouseMove;
RECT window_size;
bool window_maximized;
sCustomRomDlgSettings customRomDlgSettings;
int MouseX;
int MouseY;
unsigned int MouseButtons;
int superscope_turbo;
int superscope_pause;
int FrameAdvanceJustPressed;
HCURSOR Blank;
HCURSOR GunSight;
HCURSOR Arrow;
int CursorTimer;
HDC hDC;
HACCEL Accelerators;
bool NeedDepthConvert;
bool DepthConverted;
bool NTSCScanlines;
bool InactivePause;
bool CustomRomOpen;
bool ConfirmSaveLoad;
bool FASkipsNonInput;
bool FAMute;
int ScreenDepth;
int RedShift;
int GreenShift;
int BlueShift;
int ControlForced;
int CurrentSaveSlot;
int CurrentSaveBank;
int MaxRecentGames;
int ControllerOption;
int ValidControllerOptions;
int SoundChannelEnable;
bool BackgroundInput;
bool BackgroundKeyHotkeys;
bool JoystickHotkeys;
bool MovieClearSRAM;
bool MovieStartFromReset;
bool MovieReadOnly;
bool NetplayUseJoypad1;
unsigned int FlipCounter;
unsigned int NumFlipFrames;
int SoundDriver;
int SoundBufferSize;
bool Mute;
unsigned int VolumeRegular;
unsigned int VolumeTurbo;
bool AutomaticInputRate;
// used for sync sound synchronization
CRITICAL_SECTION SoundCritSect;
HANDLE SoundSyncEvent;
TCHAR AudioDevice[MAX_AUDIO_NAME_LENGTH];
bool AllowSoundSync;
TCHAR RomDir [_MAX_PATH];
TCHAR ScreensDir [_MAX_PATH];
TCHAR MovieDir [_MAX_PATH];
TCHAR SPCDir [_MAX_PATH];
TCHAR FreezeFileDir [_MAX_PATH];
TCHAR SRAMFileDir [_MAX_PATH];
TCHAR PatchDir [_MAX_PATH];
TCHAR CheatDir [_MAX_PATH];
TCHAR BiosDir [_MAX_PATH];
TCHAR SatDir [_MAX_PATH];
bool LockDirectories;
TCHAR RecentGames [MAX_RECENT_GAMES_LIST_SIZE][MAX_PATH];
TCHAR RecentHostNames [MAX_RECENT_HOSTS_LIST_SIZE][MAX_PATH];
//turbo switches -- SNES-wide
unsigned short TurboMask;
COLORREF InfoColor;
bool HideMenu;
// avi writing
struct AVIFile* AVIOut;
long FrameCount;
long LastFrameCount;
unsigned long IdleCount;
// rewinding
unsigned int rewindBufferSize;
unsigned int rewindGranularity;
};
//TURBO masks
#define TURBO_A_MASK 0x0001
#define TURBO_B_MASK 0x0002
#define TURBO_X_MASK 0x0004
#define TURBO_Y_MASK 0x0008
#define TURBO_L_MASK 0x0010
#define TURBO_R_MASK 0x0020
#define TURBO_STA_MASK 0x0040
#define TURBO_SEL_MASK 0x0080
#define TURBO_LEFT_MASK 0x0100
#define TURBO_UP_MASK 0x0200
#define TURBO_RIGHT_MASK 0x0400
#define TURBO_DOWN_MASK 0x0800
struct sLanguages {
int idMenu;
TCHAR *errInitDD;
TCHAR *errModeDD;
TCHAR *errInitDS;
TCHAR *ApplyNeedRestart;
TCHAR *errFrameTimer;
};
#define CUSTKEY_ALT_MASK 0x01
#define CUSTKEY_CTRL_MASK 0x02
#define CUSTKEY_SHIFT_MASK 0x04
struct SCustomKey {
WORD key;
WORD modifiers;
};
struct SCustomKeys {
SCustomKey SpeedUp;
SCustomKey SpeedDown;
SCustomKey Pause;
SCustomKey FrameAdvance;
SCustomKey SkipUp;
SCustomKey SkipDown;
SCustomKey ScopeTurbo;
SCustomKey ScopePause;
SCustomKey FrameCount;
SCustomKey ReadOnly;
SCustomKey Save [SAVE_SLOTS_PER_BANK];
SCustomKey Load [SAVE_SLOTS_PER_BANK];
SCustomKey FastForward;
SCustomKey FastForwardToggle;
SCustomKey ShowPressed;
SCustomKey SaveScreenShot;
SCustomKey SlotPlus;
SCustomKey SlotMinus;
SCustomKey SlotSave;
SCustomKey SlotLoad;
SCustomKey BankPlus;
SCustomKey BankMinus;
SCustomKey DialogSave;
SCustomKey DialogLoad;
SCustomKey BGL1;
SCustomKey BGL2;
SCustomKey BGL3;
SCustomKey BGL4;
SCustomKey BGL5;
SCustomKey ClippingWindows;
SCustomKey Transparency;
SCustomKey JoypadSwap;
SCustomKey SwitchControllers;
SCustomKey TurboA, TurboB, TurboY, TurboX, TurboL, TurboR, TurboStart, TurboSelect, TurboLeft, TurboUp, TurboRight, TurboDown;
SCustomKey SelectSave [SAVE_SLOTS_PER_BANK];
SCustomKey ResetGame;
SCustomKey ToggleCheats;
SCustomKey QuitS9X;
SCustomKey Rewind;
SCustomKey SaveFileSelect;
SCustomKey LoadFileSelect;
SCustomKey Mute;
};
struct SJoypad {
BOOL Enabled;
union {
WORD Left;
WORD Autohold;
};
union {
WORD Right;
WORD ClearAll;
};
union {
WORD Up;
WORD TempTurbo;
};
union {
WORD Down;
WORD Autofire;
};
WORD Left_Up;
WORD Left_Down;
WORD Right_Up;
WORD Right_Down;
WORD Start;
WORD Select;
WORD A;
WORD B;
WORD X;
WORD Y;
WORD L;
WORD R;
};
#define S9X_JOY_NEUTRAL 60
struct SJoyState{
bool Attached;
JOYCAPS Caps;
int Threshold;
bool Left;
bool Right;
bool Up;
bool Down;
bool PovLeft;
bool PovRight;
bool PovUp;
bool PovDown;
bool PovDnLeft;
bool PovDnRight;
bool PovUpLeft;
bool PovUpRight;
bool RUp;
bool RDown;
bool UUp;
bool UDown;
bool VUp;
bool VDown;
bool ZUp;
bool ZDown;
bool Button[32];
};
enum
{
SNES_JOYPAD,
SNES_MOUSE,
SNES_SUPERSCOPE,
SNES_MULTIPLAYER5,
SNES_JUSTIFIER,
SNES_MOUSE_SWAPPED,
SNES_MULTIPLAYER8,
SNES_JUSTIFIER_2,
SNES_MACSRIFLE,
SNES_MAX_CONTROLLER_OPTIONS
};
/*****************************************************************************/
void SetInfoDlgColor(unsigned char r, unsigned char g, unsigned char b);
extern struct sGUI GUI;
extern struct sLanguages Languages[];
extern struct SJoypad Joypad[16];
extern struct SJoypad ToggleJoypadStorage[8];
extern struct SJoypad TurboToggleJoypadStorage[8];
extern struct SCustomKeys CustomKeys;
enum
{
WIN_SNES9X_DIRECT_SOUND_DRIVER=0,
WIN_FMOD_DIRECT_SOUND_DRIVER,
WIN_FMOD_WAVE_SOUND_DRIVER,
WIN_FMOD_A3D_SOUND_DRIVER,
WIN_XAUDIO2_SOUND_DRIVER,
WIN_FMODEX_DEFAULT_DRIVER,
WIN_FMODEX_ASIO_DRIVER,
WIN_FMODEX_OPENAL_DRIVER,
WIN_WAVEOUT_DRIVER
};
#define S9X_REG_KEY_BASE MY_REG_KEY
#define S9X_REG_KEY_VERSION REG_KEY_VER
#define WIN32_WHITE RGB(255,255,255)
/*****************************************************************************/
void S9xSetWinPixelFormat ();
//int CheckKey( WORD Key, int OldJoypad);
//void TranslateKey(WORD keyz,char *out);
#define S9X_CONF_FILE_NAME "snes9x.conf"
const char* GetFilterName(RenderFilter filterID);
int GetFilterScale(RenderFilter filterID);
bool GetFilterHiResSupport(RenderFilter filterID);
const TCHAR * S9xGetDirectoryT (enum s9x_getdirtype);
RECT GetWindowMargins(HWND hwnd, UINT width);
void GetSlotFilename(int slot, char filename[_MAX_PATH + 1]);
void FreezeUnfreezeSlot(int slot, bool8 freeze);
void FreezeUnfreezeDialog(bool8 freeze);
void FreezeUnfreezeDialogPreview(bool8 freeze);
void FreezeUnfreeze(const char *filename, bool8 freeze);
bool UnfreezeScreenshotSlot(int slot, uint16 **image_buffer, int &width, int &height);
#endif // !defined(SNES9X_H_INCLUDED)