2010-03-19 00:31:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "GS.h"
|
|
|
|
#include "Win32.h"
|
|
|
|
|
|
|
|
extern HINSTANCE hInst;
|
|
|
|
|
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
void SaveConfig()
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
char szValue[256];
|
2010-05-01 23:34:44 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "zzogl-pg.ini");
|
|
|
|
|
|
|
|
sprintf(szValue, "%u", conf.interlace);
|
|
|
|
WritePrivateProfileString("Settings", "Interlace", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.aa);
|
|
|
|
WritePrivateProfileString("Settings", "Antialiasing", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.bilinear);
|
|
|
|
WritePrivateProfileString("Settings", "Bilinear", szValue, iniFile.c_str());
|
2010-06-19 09:07:21 +00:00
|
|
|
sprintf(szValue, "%u", conf.zz_options);
|
|
|
|
WritePrivateProfileString("Settings", "ZZOptions", szValue, iniFile.c_str());
|
2010-06-19 08:46:40 +00:00
|
|
|
sprintf(szValue, "%u", conf.hacks);
|
2010-05-01 23:34:44 +00:00
|
|
|
WritePrivateProfileString("Settings", "AdvancedOptions", szValue, iniFile.c_str());
|
2010-05-02 03:09:20 +00:00
|
|
|
sprintf(szValue, "%u", conf.width);
|
|
|
|
WritePrivateProfileString("Settings", "Width", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.height);
|
|
|
|
WritePrivateProfileString("Settings", "Height", szValue, iniFile.c_str());
|
2010-08-18 13:15:43 +00:00
|
|
|
sprintf(szValue, "%u", conf.SkipDraw);
|
|
|
|
WritePrivateProfileString("Settings", "SkipDraw", szValue, iniFile.c_str());
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
void LoadConfig()
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
char szValue[256];
|
2010-05-01 23:34:44 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "zzogl-pg.ini");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
memset(&conf, 0, sizeof(conf));
|
|
|
|
conf.interlace = 0; // on, mode 1
|
|
|
|
conf.mrtdepth = 1;
|
2010-06-19 09:07:21 +00:00
|
|
|
conf.zz_options._u32 = 0;
|
|
|
|
conf.hacks._u32 = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.bilinear = 1;
|
|
|
|
conf.width = 640;
|
|
|
|
conf.height = 480;
|
2010-08-18 13:15:43 +00:00
|
|
|
conf.SkipDraw = 0;
|
2010-10-15 09:32:41 +00:00
|
|
|
conf.disableHacks = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
FILE *fp = fopen(iniFile.c_str(), "rt");
|
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
if (!fp)
|
|
|
|
{
|
2010-07-24 08:08:42 +00:00
|
|
|
SysMessage("Unable to open ZZOgl-PG's ini file!");
|
2010-05-01 23:34:44 +00:00
|
|
|
CreateDirectory(s_strIniPath.c_str(), NULL);
|
2010-03-19 00:31:15 +00:00
|
|
|
SaveConfig();//save and return
|
|
|
|
return ;
|
|
|
|
}
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
GetPrivateProfileString("Settings", "Interlace", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.interlace = (u8)strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "Antialiasing", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.aa = (u8)strtoul(szValue, NULL, 10);
|
2010-06-19 09:07:21 +00:00
|
|
|
GetPrivateProfileString("Settings", "ZZOptions", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.zz_options._u32 = strtoul(szValue, NULL, 10);
|
2010-03-19 00:31:15 +00:00
|
|
|
GetPrivateProfileString("Settings", "AdvancedOptions", NULL, szValue, 20, iniFile.c_str());
|
2010-06-19 09:07:21 +00:00
|
|
|
conf.hacks._u32 = strtoul(szValue, NULL, 10);
|
2010-03-19 00:31:15 +00:00
|
|
|
GetPrivateProfileString("Settings", "Bilinear", NULL, szValue, 20, iniFile.c_str());
|
2010-07-10 12:41:49 +00:00
|
|
|
conf.bilinear = (u8)strtoul(szValue, NULL, 10);
|
2010-05-02 03:09:20 +00:00
|
|
|
GetPrivateProfileString("Settings", "Width", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.width = strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "Height", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.height = strtoul(szValue, NULL, 10);
|
2010-08-18 13:15:43 +00:00
|
|
|
GetPrivateProfileString("Settings", "SkipDraw", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.SkipDraw = strtoul(szValue, NULL, 10);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
if (conf.aa < 0 || conf.aa > 4) conf.aa = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-06-19 06:23:40 +00:00
|
|
|
conf.isWideScreen = (conf.widescreen() != 0);
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
switch (conf.zz_options.dimensions)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-06-19 08:46:40 +00:00
|
|
|
case GSDim_640:
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.width = 640;
|
|
|
|
conf.height = conf.isWideScreen ? 360 : 480;
|
|
|
|
break;
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
case GSDim_800:
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.width = 800;
|
|
|
|
conf.height = conf.isWideScreen ? 450 : 600;
|
|
|
|
break;
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
case GSDim_1024:
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.width = 1024;
|
|
|
|
conf.height = conf.isWideScreen ? 576 : 768;
|
|
|
|
break;
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
case GSDim_1280:
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.width = 1280;
|
|
|
|
conf.height = conf.isWideScreen ? 720 : 960;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-19 06:23:40 +00:00
|
|
|
// turn off all hacks by default
|
|
|
|
conf.setWireframe(false);
|
|
|
|
conf.setCaptureAvi(false);
|
|
|
|
conf.setLoaded(true);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
if (conf.width <= 0 || conf.height <= 0)
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.width = 640;
|
|
|
|
conf.height = 480;
|
|
|
|
}
|
|
|
|
}
|