Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/mupen64plus-video-rice/src/Config.cpp
2 views
1
/*
2
Copyright (C) 2003 Rice1964
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
*/
19
20
#include <vector>
21
#include <fstream>
22
23
#include <stdlib.h>
24
25
#define M64P_PLUGIN_PROTOTYPES 1
26
#include "osal_preproc.h"
27
#include "m64p_types.h"
28
#include "m64p_plugin.h"
29
#include "m64p_config.h"
30
31
#include "Config.h"
32
#include "Debugger.h"
33
#include "DeviceBuilder.h"
34
#include "RenderBase.h"
35
#include "TextureManager.h"
36
#include "Video.h"
37
38
#define INI_FILE "RiceVideoLinux.ini"
39
40
static m64p_handle l_ConfigVideoRice = NULL;
41
static m64p_handle l_ConfigVideoGeneral = NULL;
42
43
static int FindIniEntry(uint32 dwCRC1, uint32 dwCRC2, uint8 nCountryID, char* szName, int PrintInfo);
44
45
const char *frameBufferSettings[] =
46
{
47
"None (default)",
48
"Hide Framebuffer Effects",
49
"Basic Framebuffer",
50
"Basic & Write Back",
51
"Write Back & Reload",
52
"Write Back Every Frame",
53
"With Emulator",
54
"Basic Framebuffer & With Emulator",
55
"With Emulator Read Only",
56
"With Emulator Write Only",
57
};
58
59
const int resolutions[][2] =
60
{
61
{320, 240},
62
{400, 300},
63
{480, 360},
64
{512, 384},
65
{640, 480},
66
{800, 600},
67
{1024, 768},
68
{1152, 864},
69
{1280, 960},
70
{1400, 1050},
71
{1600, 1200},
72
{1920, 1440},
73
{2048, 1536},
74
};
75
const int numberOfResolutions = sizeof(resolutions)/sizeof(int)/2;
76
77
const char* resolutionsS[] =
78
{
79
"320 x 240",
80
"400 x 300",
81
"480 x 360",
82
"512 x 384",
83
"640 x 480",
84
"800 x 600",
85
"1024 x 768",
86
"1152 x 864",
87
"1280 x 960",
88
"1400 x 1050",
89
"1600 x 1200",
90
"1920 x 1440",
91
"2048 x 1536"
92
};
93
94
const char *frameBufferWriteBackControlSettings[] =
95
{
96
"Every Frame (default)",
97
"Every 2 Frames",
98
"Every 3 Frames",
99
"Every 4 Frames",
100
"Every 5 Frames",
101
"Every 6 Frames",
102
"Every 7 Frames",
103
"Every 8 Frames",
104
};
105
106
const char *renderToTextureSettings[] =
107
{
108
"None (default)",
109
"Hide Render-to-texture Effects",
110
"Basic Render-to-texture",
111
"Basic & Write Back",
112
"Write Back & Reload",
113
};
114
115
const char *screenUpdateSettings[] =
116
{
117
"At VI origin update",
118
"At VI origin change",
119
"At CI change",
120
"At the 1st CI change",
121
"At the 1st drawing",
122
"Before clear the screen",
123
"At VI origin update after screen is drawn (default)",
124
};
125
126
WindowSettingStruct windowSetting;
127
GlobalOptions options;
128
RomOptions defaultRomOptions;
129
RomOptions currentRomOptions;
130
FrameBufferOptions frameBufferOptions;
131
std::vector<IniSection> IniSections;
132
bool bIniIsChanged = false;
133
char szIniFileName[300];
134
135
SettingInfo TextureQualitySettings[] =
136
{
137
{"Default", FORCE_DEFAULT_FILTER},
138
{"32-bit Texture", FORCE_POINT_FILTER},
139
{"16-bit Texture", FORCE_LINEAR_FILTER},
140
};
141
142
SettingInfo ForceTextureFilterSettings[] =
143
{
144
{"N64 Default Texture Filter", FORCE_DEFAULT_FILTER},
145
{"Force Nearest Filter (faster, low quality)", FORCE_POINT_FILTER},
146
{"Force Linear Filter (slower, better quality)", FORCE_LINEAR_FILTER},
147
};
148
149
SettingInfo TextureEnhancementSettings[] =
150
{
151
{"N64 original texture (No enhancement)", TEXTURE_NO_ENHANCEMENT},
152
{"2x (Double the texture size)", TEXTURE_2X_ENHANCEMENT},
153
{"2xSaI", TEXTURE_2XSAI_ENHANCEMENT},
154
{"hq2x", TEXTURE_HQ2X_ENHANCEMENT},
155
{"lq2x", TEXTURE_LQ2X_ENHANCEMENT},
156
{"hq4x", TEXTURE_HQ4X_ENHANCEMENT},
157
{"Sharpen", TEXTURE_SHARPEN_ENHANCEMENT},
158
{"Sharpen More", TEXTURE_SHARPEN_MORE_ENHANCEMENT},
159
};
160
161
SettingInfo TextureEnhancementControlSettings[] =
162
{
163
{"Normal", TEXTURE_ENHANCEMENT_NORMAL},
164
{"Smooth", TEXTURE_ENHANCEMENT_WITH_SMOOTH_FILTER_1},
165
{"Less smooth", TEXTURE_ENHANCEMENT_WITH_SMOOTH_FILTER_2},
166
{"2xSaI smooth", TEXTURE_ENHANCEMENT_WITH_SMOOTH_FILTER_3},
167
{"Less 2xSaI smooth", TEXTURE_ENHANCEMENT_WITH_SMOOTH_FILTER_4},
168
};
169
170
SettingInfo colorQualitySettings[] =
171
{
172
{"16-bit", TEXTURE_FMT_A4R4G4B4},
173
{"32-bit (def)", TEXTURE_FMT_A8R8G8B8},
174
};
175
176
const char* strDXDeviceDescs[] = { "HAL", "REF" };
177
178
SettingInfo openGLDepthBufferSettings[] =
179
{
180
{"16-bit (def)", 16},
181
{"32-bit", 32},
182
};
183
184
RenderEngineSetting OpenGLRenderSettings[] =
185
{
186
{"To Fit Your Video Card", OGL_DEVICE},
187
{"OpenGL 1.1 (Lowest)", OGL_1_1_DEVICE},
188
{"OpenGL 1.2/1.3", OGL_1_2_DEVICE},
189
{"OpenGL 1.4", OGL_1_4_DEVICE},
190
//{"OpenGL 1.4, the 2nd combiner", OGL_1_4_V2_DEVICE},
191
{"OpenGL for Nvidia TNT or better", OGL_TNT2_DEVICE},
192
{"OpenGL for Nvidia GeForce or better ", NVIDIA_OGL_DEVICE},
193
{"OpenGL Fragment Program Extension", OGL_FRAGMENT_PROGRAM},
194
};
195
196
SettingInfo OnScreenDisplaySettings[] =
197
{
198
{"Display Nothing", ONSCREEN_DISPLAY_NOTHING},
199
{"Display DList Per Second", ONSCREEN_DISPLAY_DLIST_PER_SECOND},
200
{"Display Frame Per Second", ONSCREEN_DISPLAY_FRAME_PER_SECOND},
201
{"Display Debug Information Only", ONSCREEN_DISPLAY_DEBUG_INFORMATION_ONLY},
202
{"Display Messages From CPU Core Only", ONSCREEN_DISPLAY_TEXT_FROM_CORE_ONLY},
203
{"Display DList Per Second With Core Msgs", ONSCREEN_DISPLAY_DLIST_PER_SECOND_WITH_CORE_MSG},
204
{"Display Frame Per Second With Core Msgs", ONSCREEN_DISPLAY_FRAME_PER_SECOND_WITH_CORE_MSG},
205
{"Display Debug Information With Core Msgs", ONSCREEN_DISPLAY_DEBUG_INFORMATION_WITH_CORE_MSG},
206
};
207
208
const int numberOfOpenGLRenderEngineSettings = sizeof(OpenGLRenderSettings)/sizeof(RenderEngineSetting);
209
210
void GenerateFrameBufferOptions(void)
211
{
212
if( CDeviceBuilder::GetGeneralDeviceType() == OGL_DEVICE )
213
{
214
// OpenGL does not support much yet
215
if( currentRomOptions.N64FrameBufferEmuType != FRM_BUF_NONE )
216
currentRomOptions.N64FrameBufferEmuType = FRM_BUF_IGNORE;
217
if( currentRomOptions.N64RenderToTextureEmuType != TXT_BUF_NONE )
218
currentRomOptions.N64RenderToTextureEmuType = TXT_BUF_IGNORE;
219
}
220
221
frameBufferOptions.bUpdateCIInfo = false;
222
223
frameBufferOptions.bCheckBackBufs = false;
224
frameBufferOptions.bWriteBackBufToRDRAM = false;
225
frameBufferOptions.bLoadBackBufFromRDRAM = false;
226
227
frameBufferOptions.bIgnore = true;
228
229
frameBufferOptions.bSupportRenderTextures = false;
230
frameBufferOptions.bCheckRenderTextures = false;
231
frameBufferOptions.bRenderTextureWriteBack = false;
232
frameBufferOptions.bLoadRDRAMIntoRenderTexture = false;
233
234
frameBufferOptions.bProcessCPUWrite = false;
235
frameBufferOptions.bProcessCPURead = false;
236
frameBufferOptions.bAtEachFrameUpdate = false;
237
frameBufferOptions.bIgnoreRenderTextureIfHeightUnknown = false;
238
239
switch( currentRomOptions.N64FrameBufferEmuType )
240
{
241
case FRM_BUF_NONE:
242
break;
243
case FRM_BUF_COMPLETE:
244
frameBufferOptions.bAtEachFrameUpdate = true;
245
frameBufferOptions.bProcessCPUWrite = true;
246
frameBufferOptions.bProcessCPURead = true;
247
frameBufferOptions.bUpdateCIInfo = true;
248
break;
249
case FRM_BUF_WRITEBACK_AND_RELOAD:
250
frameBufferOptions.bLoadBackBufFromRDRAM = true;
251
case FRM_BUF_BASIC_AND_WRITEBACK:
252
frameBufferOptions.bWriteBackBufToRDRAM = true;
253
case FRM_BUF_BASIC:
254
frameBufferOptions.bCheckBackBufs = true;
255
case FRM_BUF_IGNORE:
256
frameBufferOptions.bUpdateCIInfo = true;
257
break;
258
case FRM_BUF_BASIC_AND_WITH_EMULATOR:
259
// Banjo Kazooie
260
frameBufferOptions.bCheckBackBufs = true;
261
case FRM_BUF_WITH_EMULATOR:
262
frameBufferOptions.bUpdateCIInfo = true;
263
frameBufferOptions.bProcessCPUWrite = true;
264
frameBufferOptions.bProcessCPURead = true;
265
break;
266
case FRM_BUF_WITH_EMULATOR_READ_ONLY:
267
frameBufferOptions.bUpdateCIInfo = true;
268
frameBufferOptions.bProcessCPURead = true;
269
break;
270
case FRM_BUF_WITH_EMULATOR_WRITE_ONLY:
271
frameBufferOptions.bUpdateCIInfo = true;
272
frameBufferOptions.bProcessCPUWrite = true;
273
break;
274
}
275
276
switch( currentRomOptions.N64RenderToTextureEmuType )
277
{
278
case TXT_BUF_NONE:
279
frameBufferOptions.bSupportRenderTextures = false;
280
break;
281
case TXT_BUF_WRITE_BACK_AND_RELOAD:
282
frameBufferOptions.bLoadRDRAMIntoRenderTexture = true;
283
case TXT_BUF_WRITE_BACK:
284
frameBufferOptions.bRenderTextureWriteBack = true;
285
case TXT_BUF_NORMAL:
286
frameBufferOptions.bCheckRenderTextures = true;
287
frameBufferOptions.bIgnore = false;
288
case TXT_BUF_IGNORE:
289
frameBufferOptions.bUpdateCIInfo = true;
290
frameBufferOptions.bSupportRenderTextures = true;
291
break;
292
}
293
294
if( currentRomOptions.screenUpdateSetting >= SCREEN_UPDATE_AT_CI_CHANGE )
295
{
296
frameBufferOptions.bUpdateCIInfo = true;
297
}
298
}
299
300
BOOL InitConfiguration(void)
301
{
302
if (ConfigOpenSection("Video-General", &l_ConfigVideoGeneral) != M64ERR_SUCCESS)
303
{
304
DebugMessage(M64MSG_ERROR, "Unable to open Video-General configuration section");
305
return FALSE;
306
}
307
if (ConfigOpenSection("Video-Rice", &l_ConfigVideoRice) != M64ERR_SUCCESS)
308
{
309
DebugMessage(M64MSG_ERROR, "Unable to open Video-Rice configuration section");
310
return FALSE;
311
}
312
313
ConfigSetDefaultBool(l_ConfigVideoGeneral, "Fullscreen", 0, "Use fullscreen mode if True, or windowed mode if False ");
314
ConfigSetDefaultInt(l_ConfigVideoGeneral, "ScreenWidth", 640, "Width of output window or fullscreen width");
315
ConfigSetDefaultInt(l_ConfigVideoGeneral, "ScreenHeight", 480, "Height of output window or fullscreen height");
316
ConfigSetDefaultBool(l_ConfigVideoGeneral, "VerticalSync", 0, "If true, activate the SDL_GL_SWAP_CONTROL attribute");
317
318
ConfigSetDefaultInt(l_ConfigVideoRice, "FrameBufferSetting", FRM_BUF_NONE, "Frame Buffer Emulation (0=ROM default, 1=disable)");
319
ConfigSetDefaultInt(l_ConfigVideoRice, "FrameBufferWriteBackControl", FRM_BUF_WRITEBACK_NORMAL, "Frequency to write back the frame buffer (0=every frame, 1=every other frame, etc)");
320
ConfigSetDefaultInt(l_ConfigVideoRice, "RenderToTexture", TXT_BUF_NONE, "Render-to-texture emulation (0=none, 1=ignore, 2=normal, 3=write back, 4=write back and reload)");
321
#if defined(WIN32)
322
ConfigSetDefaultInt(l_ConfigVideoRice, "ScreenUpdateSetting", SCREEN_UPDATE_AT_1ST_CI_CHANGE, "Control when the screen will be updated (0=ROM default, 1=VI origin update, 2=VI origin change, 3=CI change, 4=first CI change, 5=first primitive draw, 6=before screen clear, 7=after screen drawn)"); // SCREEN_UPDATE_AT_VI_UPDATE_AND_DRAWN
323
#else
324
ConfigSetDefaultInt(l_ConfigVideoRice, "ScreenUpdateSetting", SCREEN_UPDATE_AT_VI_UPDATE, "Control when the screen will be updated (0=ROM default, 1=VI origin update, 2=VI origin change, 3=CI change, 4=first CI change, 5=first primitive draw, 6=before screen clear, 7=after screen drawn)"); // SCREEN_UPDATE_AT_VI_UPDATE_AND_DRAWN
325
#endif
326
ConfigSetDefaultBool(l_ConfigVideoRice, "NormalAlphaBlender", FALSE, "Force to use normal alpha blender");
327
ConfigSetDefaultBool(l_ConfigVideoRice, "FastTextureLoading", FALSE, "Use a faster algorithm to speed up texture loading and CRC computation");
328
ConfigSetDefaultBool(l_ConfigVideoRice, "AccurateTextureMapping", TRUE, "Use different texture coordinate clamping code");
329
ConfigSetDefaultBool(l_ConfigVideoRice, "InN64Resolution", FALSE, "Force emulated frame buffers to be in N64 native resolution");
330
ConfigSetDefaultBool(l_ConfigVideoRice, "SaveVRAM", FALSE, "Try to reduce Video RAM usage (should never be used)");
331
ConfigSetDefaultBool(l_ConfigVideoRice, "DoubleSizeForSmallTxtrBuf", FALSE, "Enable this option to have better render-to-texture quality");
332
ConfigSetDefaultBool(l_ConfigVideoRice, "DefaultCombinerDisable", FALSE, "Force to use normal color combiner");
333
334
ConfigSetDefaultBool(l_ConfigVideoRice, "EnableHacks", TRUE, "Enable game-specific settings from INI file");
335
ConfigSetDefaultBool(l_ConfigVideoRice, "WinFrameMode", FALSE, "If enabled, graphics will be drawn in WinFrame mode instead of solid and texture mode");
336
ConfigSetDefaultBool(l_ConfigVideoRice, "FullTMEMEmulation", FALSE, "N64 Texture Memory Full Emulation (may fix some games, may break others)");
337
ConfigSetDefaultBool(l_ConfigVideoRice, "OpenGLVertexClipper", FALSE, "Enable vertex clipper for fog operations");
338
ConfigSetDefaultBool(l_ConfigVideoRice, "EnableSSE", TRUE, "Enable/Disable SSE optimizations for capable CPUs");
339
ConfigSetDefaultBool(l_ConfigVideoRice, "EnableVertexShader", FALSE, "Use GPU vertex shader");
340
ConfigSetDefaultBool(l_ConfigVideoRice, "SkipFrame", FALSE, "If this option is enabled, the plugin will skip every other frame");
341
ConfigSetDefaultBool(l_ConfigVideoRice, "TexRectOnly", FALSE, "If enabled, texture enhancement will be done only for TxtRect ucode");
342
ConfigSetDefaultBool(l_ConfigVideoRice, "SmallTextureOnly", FALSE, "If enabled, texture enhancement will be done only for textures width+height<=128");
343
ConfigSetDefaultBool(l_ConfigVideoRice, "LoadHiResCRCOnly", TRUE, "Select hi-resolution textures based only on the CRC and ignore format+size information (Glide64 compatibility)");
344
ConfigSetDefaultBool(l_ConfigVideoRice, "LoadHiResTextures", FALSE, "Enable hi-resolution texture file loading");
345
ConfigSetDefaultBool(l_ConfigVideoRice, "DumpTexturesToFiles", FALSE, "Enable texture dumping");
346
ConfigSetDefaultBool(l_ConfigVideoRice, "ShowFPS", FALSE, "Display On-screen FPS");
347
348
ConfigSetDefaultInt(l_ConfigVideoRice, "Mipmapping", 2, "Use Mipmapping? 0=no, 1=nearest, 2=bilinear, 3=trilinear");
349
ConfigSetDefaultInt(l_ConfigVideoRice, "FogMethod", 0, "Enable, Disable or Force fog generation (0=Disable, 1=Enable n64 choose, 2=Force Fog)");
350
ConfigSetDefaultInt(l_ConfigVideoRice, "ForceTextureFilter", 0, "Force to use texture filtering or not (0=auto: n64 choose, 1=force no filtering, 2=force filtering)");
351
ConfigSetDefaultInt(l_ConfigVideoRice, "TextureEnhancement", 0, "Primary texture enhancement filter (0=None, 1=2X, 2=2XSAI, 3=HQ2X, 4=LQ2X, 5=HQ4X, 6=Sharpen, 7=Sharpen More, 8=External, 9=Mirrored)");
352
ConfigSetDefaultInt(l_ConfigVideoRice, "TextureEnhancementControl", 0, "Secondary texture enhancement filter (0 = none, 1-4 = filtered)");
353
ConfigSetDefaultInt(l_ConfigVideoRice, "TextureQuality", TXT_QUALITY_DEFAULT, "Color bit depth to use for textures (0=default, 1=32 bits, 2=16 bits)");
354
ConfigSetDefaultInt(l_ConfigVideoRice, "OpenGLDepthBufferSetting", 16, "Z-buffer depth (only 16 or 32)");
355
ConfigSetDefaultInt(l_ConfigVideoRice, "MultiSampling", 0, "Enable/Disable MultiSampling (0=off, 2,4,8,16=quality)");
356
ConfigSetDefaultInt(l_ConfigVideoRice, "ColorQuality", TEXTURE_FMT_A8R8G8B8, "Color bit depth for rendering window (0=32 bits, 1=16 bits)");
357
ConfigSetDefaultInt(l_ConfigVideoRice, "OpenGLRenderSetting", OGL_DEVICE, "OpenGL level to support (0=auto, 1=OGL_1.1, 2=OGL_1.2, 3=OGL_1.3, 4=OGL_1.4, 5=OGL_1.4_V2, 6=OGL_TNT2, 7=NVIDIA_OGL, 8=OGL_FRAGMENT_PROGRAM)");
358
ConfigSetDefaultInt(l_ConfigVideoRice, "AnisotropicFiltering", 0, "Enable/Disable Anisotropic Filtering for Mipmapping (0=no filtering, 2-16=quality). This is uneffective if Mipmapping is 0. If the given value is to high to be supported by your graphic card, the value will be the highest value your graphic card can support. Better result with Trilinear filtering");
359
360
// Per-game hacks
361
ConfigSetDefaultBool(l_ConfigVideoRice, "DisableTextureCRC", FALSE, "...?");
362
ConfigSetDefaultBool(l_ConfigVideoRice, "DisableCulling", FALSE, "...?");
363
ConfigSetDefaultBool(l_ConfigVideoRice, "IncTexRectEdge", FALSE, "...?");
364
ConfigSetDefaultBool(l_ConfigVideoRice, "ZHack", FALSE, "...?");
365
ConfigSetDefaultBool(l_ConfigVideoRice, "TextureScaleHack", FALSE, "...?");
366
ConfigSetDefaultBool(l_ConfigVideoRice, "PrimaryDepthHack", FALSE, "...?");
367
ConfigSetDefaultBool(l_ConfigVideoRice, "Texture1Hack", FALSE, "...?");
368
ConfigSetDefaultBool(l_ConfigVideoRice, "FastLoadTile", FALSE, "...?");
369
ConfigSetDefaultBool(l_ConfigVideoRice, "UseSmallerTexture", FALSE, "...?");
370
371
ConfigSetDefaultInt(l_ConfigVideoRice, "VIWidth", -1, "...?");
372
ConfigSetDefaultInt(l_ConfigVideoRice, "VIHeight", -1, "...?");
373
ConfigSetDefaultInt(l_ConfigVideoRice, "UseCIWidthAndRatio", NOT_USE_CI_WIDTH_AND_RATIO, "...?");
374
ConfigSetDefaultInt(l_ConfigVideoRice, "FullTMEM", 0, "...?");
375
376
ConfigSetDefaultBool(l_ConfigVideoRice, "TxtSizeMethod2", FALSE, "...?");
377
ConfigSetDefaultBool(l_ConfigVideoRice, "EnableTxtLOD", FALSE, "...?");
378
379
ConfigSetDefaultInt(l_ConfigVideoRice, "FastTextureCRC", 0, "...?");
380
381
ConfigSetDefaultBool(l_ConfigVideoRice, "EmulateClear", FALSE, "...?");
382
ConfigSetDefaultBool(l_ConfigVideoRice, "ForceScreenClear", FALSE, "...?");
383
384
ConfigSetDefaultInt(l_ConfigVideoRice, "AccurateTextureMappingHack", 0, "...?");
385
ConfigSetDefaultInt(l_ConfigVideoRice, "NormalBlender", 0, "...?");
386
387
ConfigSetDefaultBool(l_ConfigVideoRice, "DisableBlender", FALSE, "...?");
388
389
ConfigSetDefaultInt(l_ConfigVideoRice, "NormalCombiner", 0, "...?");
390
391
ConfigSetDefaultBool(l_ConfigVideoRice, "ForceDepthBuffer", FALSE, "...?");
392
ConfigSetDefaultBool(l_ConfigVideoRice, "DisableObjBG", FALSE, "...?");
393
394
ConfigSetDefaultInt(l_ConfigVideoRice, "FrameBufferOption", 0, "...?");
395
ConfigSetDefaultInt(l_ConfigVideoRice, "RenderToTextureOption", 0, "...?");
396
ConfigSetDefaultInt(l_ConfigVideoRice, "ScreenUpdateSettingHack", 0, "...?");
397
398
ConfigSetDefaultInt(l_ConfigVideoRice, "EnableHacksForGame", NO_HACK_FOR_GAME, "...?");
399
400
return TRUE;
401
}
402
403
bool isMMXSupported()
404
{
405
int IsMMXSupported = 0;
406
407
#if !defined(__GNUC__) && !defined(NO_ASM)
408
__asm
409
{
410
mov eax,1 // CPUID level 1
411
cpuid // EDX = feature flag
412
and edx,0x800000 // test bit 23 of feature flag
413
mov IsMMXSupported,edx // != 0 if MMX is supported
414
}
415
#elif defined(__GNUC__) && defined(__x86_64__) && !defined(NO_ASM)
416
return true;
417
#elif !defined(NO_ASM) // GCC assumed
418
asm volatile (
419
"push %%ebx \n"
420
"mov $1, %%eax \n" // CPUID level 1
421
"cpuid \n" // EDX = feature flag
422
"and $0x800000, %%edx \n" // test bit 23 of feature flag
423
"pop %%ebx \n"
424
: "=d"(IsMMXSupported)
425
:
426
: "memory", "cc", "eax", "ecx"
427
);
428
#endif
429
if (IsMMXSupported != 0)
430
return true;
431
else
432
return false;
433
}
434
435
bool isSSESupported()
436
{
437
int SSESupport = 0;
438
439
// And finally, check the CPUID for Streaming SIMD Extensions support.
440
#if !defined(__GNUC__) && !defined(NO_ASM)
441
_asm
442
{
443
mov eax, 1 // Put a "1" in eax to tell CPUID to get the feature bits
444
cpuid // Perform CPUID (puts processor feature info into EDX)
445
and edx, 02000000h // Test bit 25, for Streaming SIMD Extensions existence.
446
mov SSESupport, edx // SIMD Extensions). Set return value to 1 to indicate,
447
}
448
#elif defined(__GNUC__) && defined(__x86_64__) && !defined(NO_ASM)
449
return true;
450
#elif !defined(NO_ASM) // GCC assumed
451
asm volatile (
452
"push %%ebx \n"
453
"mov $1, %%eax \n" // Put a "1" in eax to tell CPUID to get the feature bits
454
"cpuid \n" // Perform CPUID (puts processor feature info into EDX)
455
"and $0x02000000, %%edx \n" // Test bit 25, for Streaming SIMD Extensions existence.
456
"pop %%ebx \n"
457
: "=d"(SSESupport)
458
:
459
: "memory", "cc", "eax", "ecx"
460
);
461
# endif
462
463
if (SSESupport != 0)
464
return true;
465
else
466
return false;
467
}
468
469
static void ReadConfiguration(void)
470
{
471
windowSetting.bDisplayFullscreen = ConfigGetParamBool(l_ConfigVideoGeneral, "Fullscreen");
472
windowSetting.uDisplayWidth = ConfigGetParamInt(l_ConfigVideoGeneral, "ScreenWidth");
473
windowSetting.uDisplayHeight = ConfigGetParamInt(l_ConfigVideoGeneral, "ScreenHeight");
474
windowSetting.bVerticalSync = ConfigGetParamBool(l_ConfigVideoGeneral, "VerticalSync");
475
476
defaultRomOptions.N64FrameBufferEmuType = ConfigGetParamInt(l_ConfigVideoRice, "FrameBufferSetting");
477
defaultRomOptions.N64FrameBufferWriteBackControl = ConfigGetParamInt(l_ConfigVideoRice, "FrameBufferWriteBackControl");
478
defaultRomOptions.N64RenderToTextureEmuType = ConfigGetParamInt(l_ConfigVideoRice, "RenderToTexture");
479
defaultRomOptions.screenUpdateSetting = ConfigGetParamInt(l_ConfigVideoRice, "screenUpdateSetting");
480
481
defaultRomOptions.bNormalBlender = ConfigGetParamBool(l_ConfigVideoRice, "NormalAlphaBlender");
482
defaultRomOptions.bFastTexCRC = ConfigGetParamBool(l_ConfigVideoRice, "FastTextureLoading");
483
defaultRomOptions.bAccurateTextureMapping = ConfigGetParamBool(l_ConfigVideoRice, "AccurateTextureMapping");
484
defaultRomOptions.bInN64Resolution = ConfigGetParamBool(l_ConfigVideoRice, "InN64Resolution");
485
defaultRomOptions.bSaveVRAM = ConfigGetParamBool(l_ConfigVideoRice, "SaveVRAM");
486
defaultRomOptions.bDoubleSizeForSmallTxtrBuf = ConfigGetParamBool(l_ConfigVideoRice, "DoubleSizeForSmallTxtrBuf");
487
defaultRomOptions.bNormalCombiner = ConfigGetParamBool(l_ConfigVideoRice, "DefaultCombinerDisable");
488
489
options.bEnableHacks = ConfigGetParamBool(l_ConfigVideoRice, "EnableHacks");
490
options.bWinFrameMode = ConfigGetParamBool(l_ConfigVideoRice, "WinFrameMode");
491
options.bFullTMEM = ConfigGetParamBool(l_ConfigVideoRice, "FullTMEMEmulation");
492
options.bOGLVertexClipper = ConfigGetParamBool(l_ConfigVideoRice, "OpenGLVertexClipper");
493
options.bEnableSSE = ConfigGetParamBool(l_ConfigVideoRice, "EnableSSE");
494
options.bEnableVertexShader = ConfigGetParamBool(l_ConfigVideoRice, "EnableVertexShader");
495
options.bSkipFrame = ConfigGetParamBool(l_ConfigVideoRice, "SkipFrame");
496
options.bTexRectOnly = ConfigGetParamBool(l_ConfigVideoRice, "TexRectOnly");
497
options.bSmallTextureOnly = ConfigGetParamBool(l_ConfigVideoRice, "SmallTextureOnly");
498
options.bLoadHiResTextures = ConfigGetParamBool(l_ConfigVideoRice, "LoadHiResTextures");
499
options.bLoadHiResCRCOnly = ConfigGetParamBool(l_ConfigVideoRice, "LoadHiResCRCOnly");
500
options.bDumpTexturesToFiles = ConfigGetParamBool(l_ConfigVideoRice, "DumpTexturesToFiles");
501
options.bShowFPS = ConfigGetParamBool(l_ConfigVideoRice, "ShowFPS");
502
503
options.mipmapping = ConfigGetParamInt(l_ConfigVideoRice, "Mipmapping");
504
options.fogMethod = ConfigGetParamInt(l_ConfigVideoRice, "FogMethod");
505
options.forceTextureFilter = ConfigGetParamInt(l_ConfigVideoRice, "ForceTextureFilter");
506
options.textureEnhancement = ConfigGetParamInt(l_ConfigVideoRice, "TextureEnhancement");
507
options.textureEnhancementControl = ConfigGetParamInt(l_ConfigVideoRice, "TextureEnhancementControl");
508
options.textureQuality = ConfigGetParamInt(l_ConfigVideoRice, "TextureQuality");
509
options.OpenglDepthBufferSetting = ConfigGetParamInt(l_ConfigVideoRice, "OpenGLDepthBufferSetting");
510
options.multiSampling = ConfigGetParamInt(l_ConfigVideoRice, "MultiSampling");
511
options.colorQuality = ConfigGetParamInt(l_ConfigVideoRice, "ColorQuality");
512
options.OpenglRenderSetting = ConfigGetParamInt(l_ConfigVideoRice, "OpenGLRenderSetting");
513
options.anisotropicFiltering = ConfigGetParamInt(l_ConfigVideoRice, "AnisotropicFiltering");
514
515
CDeviceBuilder::SelectDeviceType((SupportedDeviceType)options.OpenglRenderSetting);
516
517
status.isMMXSupported = isMMXSupported();
518
status.isSSESupported = isSSESupported();
519
status.isVertexShaderSupported = false;
520
521
status.isSSEEnabled = status.isSSESupported && options.bEnableSSE;
522
#if !defined(NO_ASM)
523
if( status.isSSEEnabled )
524
{
525
ProcessVertexData = ProcessVertexDataSSE;
526
DebugMessage(M64MSG_INFO, "SSE processing enabled.");
527
}
528
else
529
#endif
530
{
531
ProcessVertexData = ProcessVertexDataNoSSE;
532
DebugMessage(M64MSG_INFO, "Disabled SSE processing.");
533
}
534
535
status.isVertexShaderEnabled = status.isVertexShaderSupported && options.bEnableVertexShader;
536
status.bUseHW_T_L = false;
537
}
538
539
BOOL LoadConfiguration(void)
540
{
541
IniSections.clear();
542
bIniIsChanged = false;
543
/*
544
strcpy(szIniFileName, INI_FILE);
545
546
if (!ReadIniFile())
547
{
548
DebugMessage(M64MSG_ERROR, "Unable to read ini file from disk");
549
return FALSE;
550
}
551
*/
552
553
if (l_ConfigVideoGeneral == NULL || l_ConfigVideoRice == NULL)
554
{
555
DebugMessage(M64MSG_ERROR, "Rice Video configuration sections are not open!");
556
return FALSE;
557
}
558
559
// Read config parameters from core config API and set up internal variables
560
ReadConfiguration();
561
562
return TRUE;
563
}
564
565
void GenerateCurrentRomOptions()
566
{
567
currentRomOptions.N64FrameBufferEmuType =g_curRomInfo.dwFrameBufferOption;
568
currentRomOptions.N64FrameBufferWriteBackControl =defaultRomOptions.N64FrameBufferWriteBackControl;
569
currentRomOptions.N64RenderToTextureEmuType =g_curRomInfo.dwRenderToTextureOption;
570
currentRomOptions.screenUpdateSetting =g_curRomInfo.dwScreenUpdateSetting;
571
currentRomOptions.bNormalCombiner =g_curRomInfo.dwNormalCombiner;
572
currentRomOptions.bNormalBlender =g_curRomInfo.dwNormalBlender;
573
currentRomOptions.bFastTexCRC =g_curRomInfo.dwFastTextureCRC;
574
currentRomOptions.bAccurateTextureMapping =g_curRomInfo.dwAccurateTextureMapping;
575
576
options.enableHackForGames = NO_HACK_FOR_GAME;
577
if ((strncmp((char*)g_curRomInfo.szGameName, "BANJO TOOIE", 11) == 0))
578
{
579
options.enableHackForGames = HACK_FOR_BANJO_TOOIE;
580
}
581
else if ((strncmp((char*)g_curRomInfo.szGameName, "DR.MARIO", 8) == 0))
582
{
583
options.enableHackForGames = HACK_FOR_DR_MARIO;
584
}
585
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "Pilot", 5) == 0))
586
{
587
options.enableHackForGames = HACK_FOR_PILOT_WINGS;
588
}
589
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "YOSHI", 5) == 0))
590
{
591
options.enableHackForGames = HACK_FOR_YOSHI;
592
}
593
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "NITRO", 5) == 0))
594
{
595
options.enableHackForGames = HACK_FOR_NITRO;
596
}
597
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "TONY HAWK", 9) == 0))
598
{
599
options.enableHackForGames = HACK_FOR_TONYHAWK;
600
}
601
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "THPS", 4) == 0))
602
{
603
options.enableHackForGames = HACK_FOR_TONYHAWK;
604
}
605
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "SPIDERMAN", 9) == 0))
606
{
607
options.enableHackForGames = HACK_FOR_TONYHAWK;
608
}
609
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "NASCAR", 6) == 0))
610
{
611
options.enableHackForGames = HACK_FOR_NASCAR;
612
}
613
else if ((strstr((char*)g_curRomInfo.szGameName, "ZELDA") != 0) && (strstr((char*)g_curRomInfo.szGameName, "MASK") != 0))
614
{
615
options.enableHackForGames = HACK_FOR_ZELDA_MM;
616
}
617
else if ((strstr((char*)g_curRomInfo.szGameName, "ZELDA") != 0))
618
{
619
options.enableHackForGames = HACK_FOR_ZELDA;
620
}
621
else if ((strstr((char*)g_curRomInfo.szGameName, "Ogre") != 0))
622
{
623
options.enableHackForGames = HACK_FOR_OGRE_BATTLE;
624
}
625
else if ((strstr((char*)g_curRomInfo.szGameName, "TWINE") != 0))
626
{
627
options.enableHackForGames = HACK_FOR_TWINE;
628
}
629
else if ((strstr((char*)g_curRomInfo.szGameName, "Squadron") != 0))
630
{
631
options.enableHackForGames = HACK_FOR_ROGUE_SQUADRON;
632
}
633
else if ((strstr((char*)g_curRomInfo.szGameName, "Baseball") != 0) && (strstr((char*)g_curRomInfo.szGameName, "Star") != 0))
634
{
635
options.enableHackForGames = HACK_FOR_ALL_STAR_BASEBALL;
636
}
637
else if ((strstr((char*)g_curRomInfo.szGameName, "Tigger") != 0) && (strstr((char*)g_curRomInfo.szGameName, "Honey") != 0))
638
{
639
options.enableHackForGames = HACK_FOR_TIGER_HONEY_HUNT;
640
}
641
else if ((strstr((char*)g_curRomInfo.szGameName, "Bust") != 0) && (strstr((char*)g_curRomInfo.szGameName, "Move") != 0))
642
{
643
options.enableHackForGames = HACK_FOR_BUST_A_MOVE;
644
}
645
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "MarioTennis",11) == 0))
646
{
647
options.enableHackForGames = HACK_FOR_MARIO_TENNIS;
648
}
649
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "SUPER BOWLING",13) == 0))
650
{
651
options.enableHackForGames = HACK_FOR_SUPER_BOWLING;
652
}
653
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "CONKER",6) == 0))
654
{
655
options.enableHackForGames = HACK_FOR_CONKER;
656
}
657
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "MK_MYTHOLOGIES",14) == 0))
658
{
659
options.enableHackForGames = HACK_REVERSE_Y_COOR;
660
}
661
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "Fighting Force",14) == 0))
662
{
663
options.enableHackForGames = HACK_REVERSE_XY_COOR;
664
}
665
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "GOLDENEYE",9) == 0))
666
{
667
options.enableHackForGames = HACK_FOR_GOLDEN_EYE;
668
}
669
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "F-ZERO",6) == 0))
670
{
671
options.enableHackForGames = HACK_FOR_FZERO;
672
}
673
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "Command&Conquer",15) == 0))
674
{
675
options.enableHackForGames = HACK_FOR_COMMANDCONQUER;
676
}
677
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "READY 2 RUMBLE",14) == 0))
678
{
679
options.enableHackForGames = HACK_FOR_RUMBLE;
680
}
681
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "READY to RUMBLE",15) == 0))
682
{
683
options.enableHackForGames = HACK_FOR_RUMBLE;
684
}
685
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "South Park Rally",16) == 0))
686
{
687
options.enableHackForGames = HACK_FOR_SOUTH_PARK_RALLY;
688
}
689
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "Extreme G 2",11) == 0))
690
{
691
options.enableHackForGames = HACK_FOR_EXTREME_G2;
692
}
693
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "MarioGolf64",11) == 0))
694
{
695
options.enableHackForGames = HACK_FOR_MARIO_GOLF;
696
}
697
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "MLB FEATURING",13) == 0))
698
{
699
options.enableHackForGames = HACK_FOR_MLB;
700
}
701
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "POLARISSNOCROSS",15) == 0))
702
{
703
options.enableHackForGames = HACK_FOR_POLARISSNOCROSS;
704
}
705
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "TOP GEAR RALLY",14) == 0))
706
{
707
options.enableHackForGames = HACK_FOR_TOPGEARRALLY;
708
}
709
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "DUKE NUKEM",10) == 0))
710
{
711
options.enableHackForGames = HACK_FOR_DUKE_NUKEM;
712
}
713
else if ((strncasecmp((char*)g_curRomInfo.szGameName, "MARIOKART64",11) == 0))
714
{
715
options.enableHackForGames = HACK_FOR_MARIO_KART;
716
}
717
718
options.enableHackForGames = (HACK_FOR_GAMES)ConfigGetParamInt(l_ConfigVideoRice, "EnableHacksForGame");
719
720
if (options.enableHackForGames != NO_HACK_FOR_GAME)
721
DebugMessage(M64MSG_INFO, "Enabled hacks for game: '%s'", g_curRomInfo.szGameName);
722
723
if( currentRomOptions.N64FrameBufferEmuType == 0 ) currentRomOptions.N64FrameBufferEmuType = defaultRomOptions.N64FrameBufferEmuType;
724
else currentRomOptions.N64FrameBufferEmuType--;
725
if( currentRomOptions.N64RenderToTextureEmuType == 0 ) currentRomOptions.N64RenderToTextureEmuType = defaultRomOptions.N64RenderToTextureEmuType;
726
else currentRomOptions.N64RenderToTextureEmuType--;
727
if( currentRomOptions.screenUpdateSetting == 0 ) currentRomOptions.screenUpdateSetting = defaultRomOptions.screenUpdateSetting;
728
if( currentRomOptions.bNormalCombiner == 0 ) currentRomOptions.bNormalCombiner = defaultRomOptions.bNormalCombiner;
729
else currentRomOptions.bNormalCombiner--;
730
if( currentRomOptions.bNormalBlender == 0 ) currentRomOptions.bNormalBlender = defaultRomOptions.bNormalBlender;
731
else currentRomOptions.bNormalBlender--;
732
if( currentRomOptions.bFastTexCRC == 0 ) currentRomOptions.bFastTexCRC = defaultRomOptions.bFastTexCRC;
733
else currentRomOptions.bFastTexCRC--;
734
if( currentRomOptions.bAccurateTextureMapping == 0 ) currentRomOptions.bAccurateTextureMapping = defaultRomOptions.bAccurateTextureMapping;
735
else currentRomOptions.bAccurateTextureMapping--;
736
737
options.bUseFullTMEM = ((options.bFullTMEM && (g_curRomInfo.dwFullTMEM == 0)) || g_curRomInfo.dwFullTMEM == 2);
738
739
GenerateFrameBufferOptions();
740
741
if( options.enableHackForGames == HACK_FOR_MARIO_GOLF || options.enableHackForGames == HACK_FOR_MARIO_TENNIS )
742
{
743
frameBufferOptions.bIgnoreRenderTextureIfHeightUnknown = true;
744
}
745
}
746
747
void Ini_GetRomOptions(LPGAMESETTING pGameSetting)
748
{
749
/*
750
int i;
751
752
i = FindIniEntry(pGameSetting->romheader.dwCRC1,
753
pGameSetting->romheader.dwCRC2,
754
pGameSetting->romheader.nCountryID,
755
(char*)pGameSetting->szGameName, 1);
756
*/
757
758
pGameSetting->bDisableTextureCRC = ConfigGetParamBool(l_ConfigVideoRice, "DisableTextureCRC");
759
pGameSetting->bDisableCulling = ConfigGetParamBool(l_ConfigVideoRice, "DisableCulling");
760
pGameSetting->bIncTexRectEdge = ConfigGetParamBool(l_ConfigVideoRice, "IncTexRectEdge");
761
pGameSetting->bZHack = ConfigGetParamBool(l_ConfigVideoRice, "ZHack");
762
pGameSetting->bTextureScaleHack = ConfigGetParamBool(l_ConfigVideoRice, "TextureScaleHack");
763
pGameSetting->bPrimaryDepthHack = ConfigGetParamBool(l_ConfigVideoRice, "PrimaryDepthHack");
764
pGameSetting->bTexture1Hack = ConfigGetParamBool(l_ConfigVideoRice, "Texture1Hack");
765
pGameSetting->bFastLoadTile = ConfigGetParamBool(l_ConfigVideoRice, "FastLoadTile");
766
pGameSetting->bUseSmallerTexture = ConfigGetParamBool(l_ConfigVideoRice, "UseSmallerTexture");
767
768
pGameSetting->VIWidth = ConfigGetParamInt(l_ConfigVideoRice, "VIWidth");
769
pGameSetting->VIHeight = ConfigGetParamInt(l_ConfigVideoRice, "VIHeight");
770
pGameSetting->UseCIWidthAndRatio = ConfigGetParamInt(l_ConfigVideoRice, "UseCIWidthAndRatio");
771
pGameSetting->dwFullTMEM = ConfigGetParamInt(l_ConfigVideoRice, "FullTMEM");
772
pGameSetting->bTxtSizeMethod2 = ConfigGetParamBool(l_ConfigVideoRice, "TxtSizeMethod2");
773
pGameSetting->bEnableTxtLOD = ConfigGetParamBool(l_ConfigVideoRice, "EnableTxtLOD");
774
775
pGameSetting->dwFastTextureCRC = ConfigGetParamInt(l_ConfigVideoRice, "FastTextureCRC");
776
pGameSetting->bEmulateClear = ConfigGetParamBool(l_ConfigVideoRice, "EmulateClear");
777
pGameSetting->bForceScreenClear = ConfigGetParamBool(l_ConfigVideoRice, "ForceScreenClear");
778
pGameSetting->dwAccurateTextureMapping = ConfigGetParamInt(l_ConfigVideoRice, "AccurateTextureMappingHack");
779
pGameSetting->dwNormalBlender = ConfigGetParamInt(l_ConfigVideoRice, "NormalBlender");
780
pGameSetting->bDisableBlender = ConfigGetParamBool(l_ConfigVideoRice, "DisableBlender");
781
pGameSetting->dwNormalCombiner = ConfigGetParamInt(l_ConfigVideoRice, "NormalCombiner");
782
pGameSetting->bForceDepthBuffer = ConfigGetParamBool(l_ConfigVideoRice, "ForceDepthBuffer");
783
pGameSetting->bDisableObjBG = ConfigGetParamBool(l_ConfigVideoRice, "DisableObjBG");
784
pGameSetting->dwFrameBufferOption = ConfigGetParamInt(l_ConfigVideoRice, "FrameBufferOption");
785
pGameSetting->dwRenderToTextureOption = ConfigGetParamInt(l_ConfigVideoRice, "RenderToTextureOption");
786
pGameSetting->dwScreenUpdateSetting = ConfigGetParamInt(l_ConfigVideoRice, "ScreenUpdateSettingHack");
787
}
788
789
void Ini_StoreRomOptions(LPGAMESETTING pGameSetting)
790
{
791
int i;
792
793
i = FindIniEntry(pGameSetting->romheader.dwCRC1,
794
pGameSetting->romheader.dwCRC2,
795
pGameSetting->romheader.nCountryID,
796
(char*)pGameSetting->szGameName, 0);
797
798
if( IniSections[i].bDisableTextureCRC !=pGameSetting->bDisableTextureCRC )
799
{
800
IniSections[i].bDisableTextureCRC =pGameSetting->bDisableTextureCRC ;
801
bIniIsChanged=true;
802
}
803
804
if( IniSections[i].bDisableCulling !=pGameSetting->bDisableCulling )
805
{
806
IniSections[i].bDisableCulling =pGameSetting->bDisableCulling ;
807
bIniIsChanged=true;
808
}
809
810
if( IniSections[i].dwFastTextureCRC !=pGameSetting->dwFastTextureCRC )
811
{
812
IniSections[i].dwFastTextureCRC =pGameSetting->dwFastTextureCRC ;
813
bIniIsChanged=true;
814
}
815
816
if( IniSections[i].bEmulateClear !=pGameSetting->bEmulateClear )
817
{
818
IniSections[i].bEmulateClear =pGameSetting->bEmulateClear ;
819
bIniIsChanged=true;
820
}
821
822
if( IniSections[i].dwNormalBlender !=pGameSetting->dwNormalBlender )
823
{
824
IniSections[i].dwNormalBlender =pGameSetting->dwNormalBlender ;
825
bIniIsChanged=true;
826
}
827
828
if( IniSections[i].bDisableBlender !=pGameSetting->bDisableBlender )
829
{
830
IniSections[i].bDisableBlender =pGameSetting->bDisableBlender ;
831
bIniIsChanged=true;
832
}
833
834
if( IniSections[i].bForceScreenClear !=pGameSetting->bForceScreenClear )
835
{
836
IniSections[i].bForceScreenClear =pGameSetting->bForceScreenClear ;
837
bIniIsChanged=true;
838
}
839
if( IniSections[i].dwAccurateTextureMapping !=pGameSetting->dwAccurateTextureMapping )
840
{
841
IniSections[i].dwAccurateTextureMapping =pGameSetting->dwAccurateTextureMapping ;
842
bIniIsChanged=true;
843
}
844
if( IniSections[i].dwNormalCombiner !=pGameSetting->dwNormalCombiner )
845
{
846
IniSections[i].dwNormalCombiner =pGameSetting->dwNormalCombiner ;
847
bIniIsChanged=true;
848
}
849
if( IniSections[i].bForceDepthBuffer !=pGameSetting->bForceDepthBuffer )
850
{
851
IniSections[i].bForceDepthBuffer =pGameSetting->bForceDepthBuffer ;
852
bIniIsChanged=true;
853
}
854
if( IniSections[i].bDisableObjBG !=pGameSetting->bDisableObjBG )
855
{
856
IniSections[i].bDisableObjBG =pGameSetting->bDisableObjBG ;
857
bIniIsChanged=true;
858
}
859
if( IniSections[i].dwFrameBufferOption !=pGameSetting->dwFrameBufferOption )
860
{
861
IniSections[i].dwFrameBufferOption =pGameSetting->dwFrameBufferOption ;
862
bIniIsChanged=true;
863
}
864
if( IniSections[i].dwRenderToTextureOption !=pGameSetting->dwRenderToTextureOption )
865
{
866
IniSections[i].dwRenderToTextureOption =pGameSetting->dwRenderToTextureOption ;
867
bIniIsChanged=true;
868
}
869
if( IniSections[i].dwScreenUpdateSetting !=pGameSetting->dwScreenUpdateSetting )
870
{
871
IniSections[i].dwScreenUpdateSetting =pGameSetting->dwScreenUpdateSetting ;
872
bIniIsChanged=true;
873
}
874
if( IniSections[i].bIncTexRectEdge != pGameSetting->bIncTexRectEdge )
875
{
876
IniSections[i].bIncTexRectEdge =pGameSetting->bIncTexRectEdge;
877
bIniIsChanged=true;
878
}
879
if( IniSections[i].bZHack != pGameSetting->bZHack )
880
{
881
IniSections[i].bZHack =pGameSetting->bZHack;
882
bIniIsChanged=true;
883
}
884
if( IniSections[i].bTextureScaleHack != pGameSetting->bTextureScaleHack )
885
{
886
IniSections[i].bTextureScaleHack =pGameSetting->bTextureScaleHack;
887
bIniIsChanged=true;
888
}
889
if( IniSections[i].bPrimaryDepthHack != pGameSetting->bPrimaryDepthHack )
890
{
891
IniSections[i].bPrimaryDepthHack =pGameSetting->bPrimaryDepthHack;
892
bIniIsChanged=true;
893
}
894
if( IniSections[i].bTexture1Hack != pGameSetting->bTexture1Hack )
895
{
896
IniSections[i].bTexture1Hack =pGameSetting->bTexture1Hack;
897
bIniIsChanged=true;
898
}
899
if( IniSections[i].bFastLoadTile != pGameSetting->bFastLoadTile )
900
{
901
IniSections[i].bFastLoadTile =pGameSetting->bFastLoadTile;
902
bIniIsChanged=true;
903
}
904
if( IniSections[i].bUseSmallerTexture != pGameSetting->bUseSmallerTexture )
905
{
906
IniSections[i].bUseSmallerTexture =pGameSetting->bUseSmallerTexture;
907
bIniIsChanged=true;
908
}
909
if( IniSections[i].VIWidth != pGameSetting->VIWidth )
910
{
911
IniSections[i].VIWidth =pGameSetting->VIWidth;
912
bIniIsChanged=true;
913
}
914
if( IniSections[i].VIHeight != pGameSetting->VIHeight )
915
{
916
IniSections[i].VIHeight =pGameSetting->VIHeight;
917
bIniIsChanged=true;
918
}
919
if( IniSections[i].UseCIWidthAndRatio != pGameSetting->UseCIWidthAndRatio )
920
{
921
IniSections[i].UseCIWidthAndRatio =pGameSetting->UseCIWidthAndRatio;
922
bIniIsChanged=true;
923
}
924
if( IniSections[i].dwFullTMEM != pGameSetting->dwFullTMEM )
925
{
926
IniSections[i].dwFullTMEM =pGameSetting->dwFullTMEM;
927
bIniIsChanged=true;
928
}
929
if( IniSections[i].bTxtSizeMethod2 != pGameSetting->bTxtSizeMethod2 )
930
{
931
IniSections[i].bTxtSizeMethod2 =pGameSetting->bTxtSizeMethod2;
932
bIniIsChanged=true;
933
}
934
if( IniSections[i].bEnableTxtLOD != pGameSetting->bEnableTxtLOD )
935
{
936
IniSections[i].bEnableTxtLOD =pGameSetting->bEnableTxtLOD;
937
bIniIsChanged=true;
938
}
939
940
if( bIniIsChanged )
941
{
942
WriteIniFile();
943
TRACE0("Rom option is changed and saved");
944
}
945
}
946
947
std::ifstream& getline( std::ifstream &is, char *str );
948
949
char * left(const char * src, int nchars)
950
{
951
static char dst[300];
952
strncpy(dst,src,nchars);
953
dst[nchars]=0;
954
return dst;
955
}
956
957
char * right(const char *src, int nchars)
958
{
959
static char dst[300];
960
int srclen = strlen(src);
961
if (nchars >= srclen)
962
{
963
strcpy(dst, src);
964
}
965
else
966
{
967
strncpy(dst, src + srclen - nchars, nchars);
968
dst[nchars]=0;
969
}
970
return dst;
971
}
972
973
char * tidy(char * s)
974
{
975
char * p = s + strlen(s);
976
977
p--;
978
while (p >= s && (*p == ' ' || *p == 0xa || *p == '\n') )
979
{
980
*p = 0;
981
p--;
982
}
983
return s;
984
985
}
986
987
BOOL ReadIniFile()
988
{
989
std::ifstream inifile;
990
char readinfo[100];
991
//const char *ini_filepath = ConfigGetSharedDataFilepath(szIniFileName);
992
const char *ini_filepath = ".\\RiceVideoLinux.ini";
993
994
DebugMessage(M64MSG_VERBOSE, "Reading .ini file: %s", ini_filepath);
995
inifile.open(ini_filepath);
996
997
if (inifile.fail())
998
{
999
return FALSE;
1000
}
1001
1002
while (getline(inifile,readinfo)/*&&sectionno<999*/)
1003
{
1004
tidy(readinfo);
1005
1006
if (readinfo[0] == '/')
1007
continue;
1008
1009
if (!strcasecmp(readinfo,"")==0)
1010
{
1011
if (readinfo[0] == '{') //if a section heading
1012
{
1013
section newsection;
1014
1015
readinfo[strlen(readinfo)-1]='\0';
1016
strcpy(newsection.crccheck, readinfo+1);
1017
1018
newsection.bDisableTextureCRC = FALSE;
1019
newsection.bDisableCulling = FALSE;
1020
newsection.bIncTexRectEdge = FALSE;
1021
newsection.bZHack = FALSE;
1022
newsection.bTextureScaleHack = FALSE;
1023
newsection.bFastLoadTile = FALSE;
1024
newsection.bUseSmallerTexture = FALSE;
1025
newsection.bPrimaryDepthHack = FALSE;
1026
newsection.bTexture1Hack = FALSE;
1027
newsection.bDisableObjBG = FALSE;
1028
newsection.VIWidth = -1;
1029
newsection.VIHeight = -1;
1030
newsection.UseCIWidthAndRatio = NOT_USE_CI_WIDTH_AND_RATIO;
1031
newsection.dwFullTMEM = 0;
1032
newsection.bTxtSizeMethod2 = FALSE;
1033
newsection.bEnableTxtLOD = FALSE;
1034
1035
newsection.bEmulateClear = FALSE;
1036
newsection.bForceScreenClear = FALSE;
1037
newsection.bDisableBlender = FALSE;
1038
newsection.bForceDepthBuffer = FALSE;
1039
newsection.dwFastTextureCRC = 0;
1040
newsection.dwAccurateTextureMapping = 0;
1041
newsection.dwNormalBlender = 0;
1042
newsection.dwNormalCombiner = 0;
1043
newsection.dwFrameBufferOption = 0;
1044
newsection.dwRenderToTextureOption = 0;
1045
newsection.dwScreenUpdateSetting = 0;
1046
1047
IniSections.push_back(newsection);
1048
1049
}
1050
else
1051
{
1052
int sectionno = IniSections.size() - 1;
1053
1054
if (strcasecmp(left(readinfo,4), "Name")==0)
1055
strcpy(IniSections[sectionno].name,right(readinfo,strlen(readinfo)-5));
1056
1057
if (strcasecmp(left(readinfo,17), "DisableTextureCRC")==0)
1058
IniSections[sectionno].bDisableTextureCRC=true;
1059
1060
if (strcasecmp(left(readinfo,14), "DisableCulling")==0)
1061
IniSections[sectionno].bDisableCulling=true;
1062
1063
if (strcasecmp(left(readinfo,16), "PrimaryDepthHack")==0)
1064
IniSections[sectionno].bPrimaryDepthHack=true;
1065
1066
if (strcasecmp(left(readinfo,12), "Texture1Hack")==0)
1067
IniSections[sectionno].bTexture1Hack=true;
1068
1069
if (strcasecmp(left(readinfo,12), "FastLoadTile")==0)
1070
IniSections[sectionno].bFastLoadTile=true;
1071
1072
if (strcasecmp(left(readinfo,17), "UseSmallerTexture")==0)
1073
IniSections[sectionno].bUseSmallerTexture=true;
1074
1075
if (strcasecmp(left(readinfo,14), "IncTexRectEdge")==0)
1076
IniSections[sectionno].bIncTexRectEdge=true;
1077
1078
if (strcasecmp(left(readinfo,5), "ZHack")==0)
1079
IniSections[sectionno].bZHack=true;
1080
1081
if (strcasecmp(left(readinfo,16), "TexRectScaleHack")==0)
1082
IniSections[sectionno].bTextureScaleHack=true;
1083
1084
if (strcasecmp(left(readinfo,7), "VIWidth")==0)
1085
IniSections[sectionno].VIWidth = strtol(right(readinfo,3),NULL,10);
1086
1087
if (strcasecmp(left(readinfo,8), "VIHeight")==0)
1088
IniSections[sectionno].VIHeight = strtol(right(readinfo,3),NULL,10);
1089
1090
if (strcasecmp(left(readinfo,18), "UseCIWidthAndRatio")==0)
1091
IniSections[sectionno].UseCIWidthAndRatio = strtol(right(readinfo,1),NULL,10);
1092
1093
if (strcasecmp(left(readinfo,8), "FullTMEM")==0)
1094
IniSections[sectionno].dwFullTMEM = strtol(right(readinfo,1),NULL,10);
1095
1096
if (strcasecmp(left(readinfo,24), "AlternativeTxtSizeMethod")==0)
1097
IniSections[sectionno].bTxtSizeMethod2 = strtol(right(readinfo,1),NULL,10);
1098
1099
if (strcasecmp(left(readinfo,12), "EnableTxtLOD")==0)
1100
IniSections[sectionno].bEnableTxtLOD = strtol(right(readinfo,1),NULL,10);
1101
1102
if (strcasecmp(left(readinfo,12), "DisableObjBG")==0)
1103
IniSections[sectionno].bDisableObjBG = strtol(right(readinfo,1),NULL,10);
1104
1105
if (strcasecmp(left(readinfo,16), "ForceScreenClear")==0)
1106
IniSections[sectionno].bForceScreenClear = strtol(right(readinfo,1),NULL,10);
1107
1108
if (strcasecmp(left(readinfo,22), "AccurateTextureMapping")==0)
1109
IniSections[sectionno].dwAccurateTextureMapping = strtol(right(readinfo,1),NULL,10);
1110
1111
if (strcasecmp(left(readinfo,14), "FastTextureCRC")==0)
1112
IniSections[sectionno].dwFastTextureCRC = strtol(right(readinfo,1),NULL,10);
1113
1114
if (strcasecmp(left(readinfo,12), "EmulateClear")==0)
1115
IniSections[sectionno].bEmulateClear = strtol(right(readinfo,1),NULL,10);
1116
1117
if (strcasecmp(left(readinfo,18), "NormalAlphaBlender")==0)
1118
IniSections[sectionno].dwNormalBlender = strtol(right(readinfo,1),NULL,10);
1119
1120
if (strcasecmp(left(readinfo,19), "DisableAlphaBlender")==0)
1121
IniSections[sectionno].bDisableBlender = strtol(right(readinfo,1),NULL,10);
1122
1123
if (strcasecmp(left(readinfo,19), "NormalColorCombiner")==0)
1124
IniSections[sectionno].dwNormalCombiner = strtol(right(readinfo,1),NULL,10);
1125
1126
if (strcasecmp(left(readinfo,16), "ForceDepthBuffer")==0)
1127
IniSections[sectionno].bForceDepthBuffer = strtol(right(readinfo,1),NULL,10);
1128
1129
if (strcasecmp(left(readinfo,20), "FrameBufferEmulation")==0)
1130
IniSections[sectionno].dwFrameBufferOption = strtol(readinfo+21,NULL,10);
1131
1132
if (strcasecmp(left(readinfo,15), "RenderToTexture")==0)
1133
IniSections[sectionno].dwRenderToTextureOption = strtol(right(readinfo,1),NULL,10);
1134
1135
if (strcasecmp(left(readinfo,19), "ScreenUpdateSetting")==0)
1136
IniSections[sectionno].dwScreenUpdateSetting = strtol(right(readinfo,1),NULL,10);
1137
}
1138
}
1139
}
1140
inifile.close();
1141
1142
return TRUE;
1143
}
1144
1145
//read a line from the ini file
1146
std::ifstream & getline(std::ifstream & is, char *str)
1147
{
1148
char buf[100];
1149
1150
is.getline(buf,100);
1151
strcpy( str,buf);
1152
return is;
1153
}
1154
1155
void WriteIniFile()
1156
{
1157
uint32 i;
1158
FILE * fhIn;
1159
FILE * fhOut;
1160
1161
/* get path to game-hack INI file and read it */
1162
const char *ini_filepath = ConfigGetSharedDataFilepath(szIniFileName);
1163
if (ini_filepath == NULL)
1164
return;
1165
fhIn = fopen(ini_filepath, "r");
1166
if (fhIn == NULL)
1167
return;
1168
fseek(fhIn, 0L, SEEK_END);
1169
long filelen = ftell(fhIn);
1170
fseek(fhIn, 0L, SEEK_SET);
1171
char *chIniData = (char *) malloc(filelen + 1);
1172
if (chIniData == NULL)
1173
{
1174
fclose(fhIn);
1175
return;
1176
}
1177
long bytesread = fread(chIniData, 1, filelen, fhIn);
1178
fclose(fhIn);
1179
if (bytesread != filelen)
1180
{
1181
free(chIniData);
1182
return;
1183
}
1184
chIniData[filelen] = 0;
1185
1186
/* now try to open the file for writing */
1187
fhOut = fopen(ini_filepath, "w");
1188
if (fhOut == NULL)
1189
{
1190
free(chIniData);
1191
return;
1192
}
1193
1194
// Mark all sections and needing to be written
1195
for (i = 0; i < IniSections.size(); i++)
1196
{
1197
IniSections[i].bOutput = false;
1198
}
1199
1200
char *thisline = chIniData;
1201
while ((thisline - chIniData) < filelen)
1202
{
1203
char *nextline = strchr(thisline, '\n');
1204
if (nextline == NULL)
1205
nextline = thisline + strlen(thisline) + 1;
1206
else
1207
nextline++;
1208
if (thisline[0] == '{')
1209
{
1210
BOOL bFound = FALSE;
1211
// Start of section
1212
tidy((char*) thisline);
1213
thisline[strlen(thisline) - 1] = '\0';
1214
for (i = 0; i < IniSections.size(); i++)
1215
{
1216
if (IniSections[i].bOutput)
1217
continue;
1218
if (strcasecmp((char*) thisline + 1, IniSections[i].crccheck) == 0)
1219
{
1220
// Output this CRC
1221
OutputSectionDetails(i, fhOut);
1222
IniSections[i].bOutput = true;
1223
bFound = TRUE;
1224
break;
1225
}
1226
}
1227
if (!bFound)
1228
{
1229
// Do what? This should never happen, unless the user
1230
// replaces the inifile while game is running!
1231
}
1232
}
1233
else if (thisline[0] == '/')
1234
{
1235
// Comment
1236
fputs((char*) thisline, fhOut);
1237
}
1238
thisline = nextline;
1239
}
1240
1241
// Input buffer done- process any new entries!
1242
for (i = 0; i < IniSections.size(); i++)
1243
{
1244
// Skip any that have not been done.
1245
if (IniSections[i].bOutput)
1246
continue;
1247
// Output this CRC
1248
OutputSectionDetails(i, fhOut);
1249
IniSections[i].bOutput = true;
1250
}
1251
1252
fclose(fhOut);
1253
free(chIniData);
1254
1255
bIniIsChanged = false;
1256
}
1257
1258
void OutputSectionDetails(uint32 i, FILE * fh)
1259
{
1260
fprintf(fh, "{%s}\n", IniSections[i].crccheck);
1261
1262
fprintf(fh, "Name=%s\n", IniSections[i].name);
1263
//fprintf(fh, "UCode=%d\n", IniSections[i].ucode);
1264
1265
// Tri-state variables
1266
if (IniSections[i].dwAccurateTextureMapping != 0)
1267
fprintf(fh, "AccurateTextureMapping=%d\n", IniSections[i].dwAccurateTextureMapping);
1268
1269
if (IniSections[i].dwFastTextureCRC != 0)
1270
fprintf(fh, "FastTextureCRC=%d\n", IniSections[i].dwFastTextureCRC);
1271
1272
if (IniSections[i].dwNormalBlender != 0)
1273
fprintf(fh, "NormalAlphaBlender=%d\n", IniSections[i].dwNormalBlender);
1274
1275
if (IniSections[i].dwNormalCombiner != 0)
1276
fprintf(fh, "NormalColorCombiner=%d\n", IniSections[i].dwNormalCombiner);
1277
1278
1279
// Normal bi-state variables
1280
if (IniSections[i].bDisableTextureCRC)
1281
fprintf(fh, "DisableTextureCRC\n");
1282
1283
if (IniSections[i].bDisableCulling)
1284
fprintf(fh, "DisableCulling\n");
1285
1286
if (IniSections[i].bPrimaryDepthHack)
1287
fprintf(fh, "PrimaryDepthHack\n");
1288
1289
if (IniSections[i].bTexture1Hack)
1290
fprintf(fh, "Texture1Hack\n");
1291
1292
if (IniSections[i].bFastLoadTile)
1293
fprintf(fh, "FastLoadTile\n");
1294
1295
if (IniSections[i].bUseSmallerTexture)
1296
fprintf(fh, "UseSmallerTexture\n");
1297
1298
if (IniSections[i].bIncTexRectEdge)
1299
fprintf(fh, "IncTexRectEdge\n");
1300
1301
if (IniSections[i].bZHack)
1302
fprintf(fh, "ZHack\n");
1303
1304
if (IniSections[i].bTextureScaleHack)
1305
fprintf(fh, "TexRectScaleHack\n");
1306
1307
if (IniSections[i].VIWidth > 0)
1308
fprintf(fh, "VIWidth=%d\n", IniSections[i].VIWidth);
1309
1310
if (IniSections[i].VIHeight > 0)
1311
fprintf(fh, "VIHeight=%d\n", IniSections[i].VIHeight);
1312
1313
if (IniSections[i].UseCIWidthAndRatio > 0)
1314
fprintf(fh, "UseCIWidthAndRatio=%d\n", IniSections[i].UseCIWidthAndRatio);
1315
1316
if (IniSections[i].dwFullTMEM > 0)
1317
fprintf(fh, "FullTMEM=%d\n", IniSections[i].dwFullTMEM);
1318
1319
if (IniSections[i].bTxtSizeMethod2 != FALSE )
1320
fprintf(fh, "AlternativeTxtSizeMethod=%d\n", IniSections[i].bTxtSizeMethod2);
1321
1322
if (IniSections[i].bEnableTxtLOD != FALSE )
1323
fprintf(fh, "EnableTxtLOD=%d\n", IniSections[i].bEnableTxtLOD);
1324
1325
if (IniSections[i].bDisableObjBG != 0 )
1326
fprintf(fh, "DisableObjBG=%d\n", IniSections[i].bDisableObjBG);
1327
1328
if (IniSections[i].bForceScreenClear != 0)
1329
fprintf(fh, "ForceScreenClear=%d\n", IniSections[i].bForceScreenClear);
1330
1331
if (IniSections[i].bEmulateClear != 0)
1332
fprintf(fh, "EmulateClear=%d\n", IniSections[i].bEmulateClear);
1333
1334
if (IniSections[i].bDisableBlender != 0)
1335
fprintf(fh, "DisableAlphaBlender=%d\n", IniSections[i].bDisableBlender);
1336
1337
if (IniSections[i].bForceDepthBuffer != 0)
1338
fprintf(fh, "ForceDepthBuffer=%d\n", IniSections[i].bForceDepthBuffer);
1339
1340
if (IniSections[i].dwFrameBufferOption != 0)
1341
fprintf(fh, "FrameBufferEmulation=%d\n", IniSections[i].dwFrameBufferOption);
1342
1343
if (IniSections[i].dwRenderToTextureOption != 0)
1344
fprintf(fh, "RenderToTexture=%d\n", IniSections[i].dwRenderToTextureOption);
1345
1346
if (IniSections[i].dwScreenUpdateSetting != 0)
1347
fprintf(fh, "ScreenUpdateSetting=%d\n", IniSections[i].dwScreenUpdateSetting);
1348
1349
fprintf(fh, "\n"); // Spacer
1350
}
1351
1352
// Find the entry corresponding to the specified rom.
1353
// If the rom is not found, a new entry is created
1354
// The resulting value is returned
1355
void __cdecl DebuggerAppendMsg (const char * Message, ...);
1356
1357
static int FindIniEntry(uint32 dwCRC1, uint32 dwCRC2, uint8 nCountryID, char* szName, int PrintInfo)
1358
{
1359
uint32 i;
1360
unsigned char szCRC[50+1];
1361
1362
// Generate the CRC-ID for this rom:
1363
sprintf((char*)szCRC, "%08x%08x-%02x", (unsigned int)dwCRC1, (unsigned int)dwCRC2, nCountryID);
1364
1365
for (i = 0; i < IniSections.size(); i++)
1366
{
1367
if (strcasecmp((char*)szCRC, IniSections[i].crccheck) == 0)
1368
{
1369
if (PrintInfo)
1370
DebugMessage(M64MSG_INFO, "Found ROM '%s', CRC %s", IniSections[i].name, szCRC);
1371
return i;
1372
}
1373
}
1374
1375
// Add new entry!!!
1376
section newsection;
1377
1378
if (PrintInfo)
1379
DebugMessage(M64MSG_INFO, "ROM (CRC %s) not found in INI file", szCRC);
1380
1381
strcpy(newsection.crccheck, (char*)szCRC);
1382
1383
strncpy(newsection.name, szName, 50);
1384
newsection.bDisableTextureCRC = FALSE;
1385
newsection.bDisableCulling = FALSE;
1386
newsection.bIncTexRectEdge = FALSE;
1387
newsection.bZHack = FALSE;
1388
newsection.bTextureScaleHack = FALSE;
1389
newsection.bFastLoadTile = FALSE;
1390
newsection.bUseSmallerTexture = FALSE;
1391
newsection.bPrimaryDepthHack = FALSE;
1392
newsection.bTexture1Hack = FALSE;
1393
newsection.bDisableObjBG = FALSE;
1394
newsection.VIWidth = -1;
1395
newsection.VIHeight = -1;
1396
newsection.UseCIWidthAndRatio = NOT_USE_CI_WIDTH_AND_RATIO;
1397
newsection.dwFullTMEM = 0;
1398
newsection.bTxtSizeMethod2 = FALSE;
1399
newsection.bEnableTxtLOD = FALSE;
1400
1401
newsection.bEmulateClear = FALSE;
1402
newsection.bForceScreenClear = FALSE;
1403
newsection.bDisableBlender = FALSE;
1404
newsection.bForceDepthBuffer = FALSE;
1405
newsection.dwFastTextureCRC = 0;
1406
newsection.dwAccurateTextureMapping = 0;
1407
newsection.dwNormalBlender = 0;
1408
newsection.dwNormalCombiner = 0;
1409
newsection.dwFrameBufferOption = 0;
1410
newsection.dwRenderToTextureOption = 0;
1411
newsection.dwScreenUpdateSetting = 0;
1412
1413
IniSections.push_back(newsection);
1414
1415
bIniIsChanged = true; // Flag to indicate we should be updated
1416
return IniSections.size()-1; // -1 takes into account increment
1417
}
1418
1419
GameSetting g_curRomInfo;
1420
1421
void ROM_GetRomNameFromHeader(unsigned char * szName, ROMHeader * pHdr)
1422
{
1423
unsigned char * p;
1424
1425
memcpy(szName, pHdr->szName, 20);
1426
szName[20] = '\0';
1427
1428
p = szName + (strlen((char*)szName) -1); // -1 to skip null
1429
while (p >= szName && *p == ' ')
1430
{
1431
*p = 0;
1432
p--;
1433
}
1434
}
1435
1436
uint32 CountryCodeToTVSystem(uint32 countryCode)
1437
{
1438
uint32 system;
1439
switch(countryCode)
1440
{
1441
/* Demo */
1442
case 0:
1443
system = TV_SYSTEM_NTSC;
1444
break;
1445
1446
case '7':
1447
system = TV_SYSTEM_NTSC;
1448
break;
1449
1450
case 0x41:
1451
system = TV_SYSTEM_NTSC;
1452
break;
1453
1454
/* Germany */
1455
case 0x44:
1456
system = TV_SYSTEM_PAL;
1457
break;
1458
1459
/* USA */
1460
case 0x45:
1461
system = TV_SYSTEM_NTSC;
1462
break;
1463
1464
/* France */
1465
case 0x46:
1466
system = TV_SYSTEM_PAL;
1467
break;
1468
1469
/* Italy */
1470
case 'I':
1471
system = TV_SYSTEM_PAL;
1472
break;
1473
1474
/* Japan */
1475
case 0x4A:
1476
system = TV_SYSTEM_NTSC;
1477
break;
1478
1479
/* Europe - PAL */
1480
case 0x50:
1481
system = TV_SYSTEM_PAL;
1482
break;
1483
1484
case 'S': /* Spain */
1485
system = TV_SYSTEM_PAL;
1486
break;
1487
1488
/* Australia */
1489
case 0x55:
1490
system = TV_SYSTEM_PAL;
1491
break;
1492
1493
case 0x58:
1494
system = TV_SYSTEM_PAL;
1495
break;
1496
1497
/* Australia */
1498
case 0x59:
1499
system = TV_SYSTEM_PAL;
1500
break;
1501
1502
case 0x20:
1503
case 0x21:
1504
case 0x38:
1505
case 0x70:
1506
system = TV_SYSTEM_PAL;
1507
break;
1508
1509
/* ??? */
1510
default:
1511
system = TV_SYSTEM_PAL;
1512
break;
1513
}
1514
1515
return system;
1516
}
1517
1518
1519
1520