2010-03-19 00:31:15 +00:00
|
|
|
/* GSsoft
|
|
|
|
* Copyright (C) 2002-2004 GSsoft Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-07-04 22:49:00 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2010-03-19 00:31:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "GS.h"
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void SaveConfig()
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "zzogl-pg.ini");
|
2010-06-19 06:23:40 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
FILE* f = fopen(iniFile.c_str(), "w");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
if (f == NULL)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-07-30 09:52:34 +00:00
|
|
|
ZZLog::Error_Log("Failed to open '%s'", iniFile.c_str());
|
2010-03-19 00:31:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
fprintf(f, "interlace = %hhx\n", conf.interlace);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
fprintf(f, "mrtdepth = %hhx\n", conf.mrtdepth);
|
2010-07-30 09:52:34 +00:00
|
|
|
fprintf(f, "zzoptions = %x\n", conf.zz_options._u32);
|
2010-11-10 11:15:48 +00:00
|
|
|
fprintf(f, "options = %x\n", conf.hacks._u32);
|
2010-03-19 00:31:15 +00:00
|
|
|
fprintf(f, "bilinear = %hhx\n", conf.bilinear);
|
|
|
|
fprintf(f, "aliasing = %hhx\n", conf.aa);
|
2010-07-30 09:52:34 +00:00
|
|
|
fprintf(f, "width = %x\n", conf.width);
|
|
|
|
fprintf(f, "height = %x\n", conf.height);
|
|
|
|
fprintf(f, "x = %x\n", conf.x);
|
|
|
|
fprintf(f, "y = %x\n", conf.y);
|
|
|
|
fprintf(f, "log = %x\n", conf.log);
|
2010-08-18 13:15:43 +00:00
|
|
|
fprintf(f, "skipdraw = %x\n", conf.SkipDraw);
|
2010-10-15 09:32:41 +00:00
|
|
|
fprintf(f, "disablehacks = %x\n", conf.disableHacks);
|
2010-03-19 00:31:15 +00:00
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void LoadConfig()
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-04-03 12:48:27 +00:00
|
|
|
int err = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
memset(&conf, 0, sizeof(conf));
|
|
|
|
conf.interlace = 0; // on, mode 1
|
|
|
|
conf.mrtdepth = 1;
|
|
|
|
conf.bilinear = 1;
|
2010-04-25 07:21:29 +00:00
|
|
|
conf.log = 1;
|
2010-08-18 13:15:43 +00:00
|
|
|
conf.SkipDraw = 0;
|
2010-09-08 12:03:49 +00:00
|
|
|
conf.width = 800;
|
|
|
|
conf.height = 600;
|
2010-10-15 09:32:41 +00:00
|
|
|
conf.disableHacks = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "zzogl-pg.ini");
|
2010-03-19 00:31:15 +00:00
|
|
|
FILE* f = fopen(iniFile.c_str(), "r");
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
if (f == NULL)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-07-30 09:52:34 +00:00
|
|
|
ZZLog::Error_Log("Failed to open '%s'", iniFile.c_str());
|
2010-03-19 00:31:15 +00:00
|
|
|
SaveConfig();//save and return
|
|
|
|
return;
|
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-03 12:48:27 +00:00
|
|
|
err = fscanf(f, "interlace = %hhx\n", &conf.interlace);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-03 12:48:27 +00:00
|
|
|
err = fscanf(f, "mrtdepth = %hhx\n", &conf.mrtdepth);
|
2010-07-30 09:52:34 +00:00
|
|
|
err = fscanf(f, "zzoptions = %x\n", &conf.zz_options._u32);
|
|
|
|
err = fscanf(f, "options = %x\n", &conf.hacks._u32);
|
2010-04-03 12:48:27 +00:00
|
|
|
err = fscanf(f, "bilinear = %hhx\n", &conf.bilinear);
|
|
|
|
err = fscanf(f, "aliasing = %hhx\n", &conf.aa);
|
2010-07-30 09:52:34 +00:00
|
|
|
err = fscanf(f, "width = %x\n", &conf.width);
|
|
|
|
err = fscanf(f, "height = %x\n", &conf.height);
|
|
|
|
err = fscanf(f, "x = %x\n", &conf.x);
|
|
|
|
err = fscanf(f, "y = %x\n", &conf.y);
|
|
|
|
err = fscanf(f, "log = %x\n", &conf.log);
|
2010-08-18 13:15:43 +00:00
|
|
|
err = fscanf(f, "skipdraw = %x\n", &conf.SkipDraw);
|
2010-10-15 09:32:41 +00:00
|
|
|
err = fscanf(f, "disablehacks = %x\n", &conf.disableHacks);
|
2010-03-19 00:31:15 +00:00
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
// turn off all hacks by default
|
2010-06-19 06:23:40 +00:00
|
|
|
conf.setWireframe(false);
|
|
|
|
conf.setCaptureAvi(false);
|
|
|
|
conf.setLoaded(true);
|
2010-07-30 09:52:34 +00:00
|
|
|
|
|
|
|
conf.isWideScreen = conf.widescreen();
|
|
|
|
|
|
|
|
// filter bad files
|
|
|
|
if (conf.interlace > 2) conf.interlace = 0;
|
|
|
|
if (conf.aa > 4) conf.aa = 0;
|
2010-05-01 20:33:53 +00:00
|
|
|
if (conf.width <= 0 || conf.height <= 0)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-09-08 12:03:49 +00:00
|
|
|
conf.width = 800;
|
|
|
|
conf.height = 600;
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-07-30 09:52:34 +00:00
|
|
|
if (conf.x < 0 || conf.y < 0)
|
2010-04-28 02:56:40 +00:00
|
|
|
{
|
|
|
|
conf.x = 0;
|
|
|
|
conf.y = 0;
|
|
|
|
}
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|