Commits

wahrhaft committed 5c7caaa

Use M64P API for storing/loading configuration settings
(still need to add support for global screen values though),
static ROM-specific options will remain in Glide64.ini

Comments (0)

Files changed (9)

-;_____________________________________________________________________
-; SETTINGS:
-; This section contains the plugin settings, such as
-; resolution.
-;
-; resolution - specifies which resolution to use
-;  Resolutions are as follows:
-; 0  - 320, 200
-; 1  - 320, 240
-; 2  - 400, 256
-; 3  - 512, 384
-; 4  - 640, 200
-; 5  - 640, 350
-; 6  - 640, 400
-; 7  - 640, 480
-; 8  - 800, 600
-; 9  - 960, 720
-; 10 - 856, 480
-; 11 - 512, 256
-; 12 - 1024, 768
-; 13 - 1280, 1024
-; 14 - 1600, 1200
-; 15 - 400, 300
-; 16 - 1152, 864
-; 17 - 1280, 960
-; 18 - 1600, 1024
-; 19 - 1792, 1344
-; 20 - 1856, 1392
-; 21 - 1920, 1440
-; 22 - 2048, 1536
-; 23 - 2048, 2048
-; Note: some video cards or monitors do not support all
-; resolutions!
-;
-; Note#2:For compatibility issues always distribute this
-; file with the resolution: 640, 480 (7)  
-;
-
-[SETTINGS]
-card_id = 0
-resolution = 7
-filter_cache = 0
-autodetect_ucode = 1
-ucode = 2
-wireframe = 0
-wfmode = 2
-filtering = 1
-depthmode = 0
-fog = 1
-buff_clear = 1
-vsync = 0
-swapmode = 1
-filter_cache = 0
-show_fps = 9
-clock = 0
-clock_24_hr = 0
-wrap_big_tex = 0
-custom_ini = 1
-hotkeys = 1
-logging = 0
-log_clear = 0
-unk_as_red = 0
-log_unk = 0
-unk_clear = 0
-new_swap = 1
-hires_motionblur = 0
-fillrec_depth_compare = 0
-flame_corona = 0
-fb_smart = 0
-fb_read_alpha = 0
-fb_read_always = 0
-fb_clear = 0
-fb_hires = 1
-fb_depth_clear = 0
-motionblur = 1
-elogging = 0
-fillrect_depth_compare = 0
-fast_crc = 0
-lodmode = 0
-fb_get_info = 0
-fb_render = 0
-detect_cpu_write = 0
-depth_bias = 0
-full_res = 7
-tex_filter = 0
-noditheredalpha = 1
-noglsl = 1
-fbo = 0
-disable_auxbuf = 0
-
 ; UCODE:
 ; These are ucode crcs used in the uCode detector.
 ; If a crc is not found here, the plugin will ask you
 
 [MISCHIEF MAKERS]
 filtering = 2
-depthmode = 1
+depthmode = 1
 fog = 0
 buff_clear = 1
 swapmode = 1
 fb_clear = 1
 fb_read_alpha = 0
 
-;EOF
-
+;EOF
+

projects/unix/Makefile

 	$(SRCDIR)/3dmath.cpp \
 	$(SRCDIR)/CRC.cpp \
 	$(SRCDIR)/Combine.cpp \
+	$(SRCDIR)/Config.cpp \
 	$(SRCDIR)/Debugger.cpp \
 	$(SRCDIR)/DepthBufferRender.cpp \
 	$(SRCDIR)/Ini.cpp \
+/*
+* Glide64 - Glide video plugin for Nintendo 64 emulators.
+* Copyright (c) 2010  Jon Ring
+* Copyright (c) 2002  Dave2001
+*
+* 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
+* 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
+* Licence along with this program; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+* Boston, MA  02110-1301, USA
+*/
+#include "Config.h"
+#include "m64p.h"
+
+static m64p_handle video_general_section;
+static m64p_handle video_glide64_section;
+
+
+BOOL Config_Open()
+{
+    if (ConfigOpenSection("Video-General", &video_general_section) != M64ERR_SUCCESS ||
+        ConfigOpenSection("Video-Glide64", &video_glide64_section) != M64ERR_SUCCESS)
+    {
+        printf("Could not open configuration\n", M64MSG_ERROR);
+        return FALSE;
+    }
+    ConfigSetDefaultBool(video_general_section, "Fullscreen", false, "Use fullscreen mode if True, or windowed mode if False");
+    ConfigSetDefaultInt(video_general_section, "ScreenWidth", 640, "Width of output window or fullscreen width");
+    ConfigSetDefaultInt(video_general_section, "ScreenHeight", 480, "Height of output window or fullscreen height");
+    return TRUE;
+}
+
+void Config_ReadScreenSettings(int *width, int *height, int *fullscreen)
+{
+    *width = ConfigGetParamInt(video_general_section, "ScreenWidth");
+    *height = ConfigGetParamInt(video_general_section, "ScreenHeight");
+    *fullscreen = ConfigGetParamBool(video_general_section, "Fullscreen");
+}
+
+int Config_ReadInt(const char *itemname, int def_value, BOOL create)
+{
+    printf("Getting value %s\n", itemname);
+    ConfigSetDefaultInt(video_glide64_section, itemname, def_value, itemname);
+    return ConfigGetParamInt(video_glide64_section, itemname);
+}
+/*
+* Glide64 - Glide video plugin for Nintendo 64 emulators.
+* Copyright (c) 2010  Jon Ring
+* Copyright (c) 2002  Dave2001
+*
+* 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
+* 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
+* Licence along with this program; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+* Boston, MA  02110-1301, USA
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "winlnxdefs.h"
+
+BOOL Config_Open();
+void Config_ReadScreenSettings(int *width, int *height, int *fullscreen);
+int Config_ReadInt(const char *itemname, int def_value, BOOL create=TRUE);
+
+
+#endif /* CONFIG_H */
+
     {
         strncpy(path, configdir, PATH_MAX);
         // make sure there's a trailing '/'
-        if(path[strlen(path)-1] != '/')
-            strncat(path, "/", PATH_MAX - strlen(path));
+        //if(path[strlen(path)-1] != '/')
+        //    strncat(path, "/", PATH_MAX - strlen(path));
     }
     else
     {
 #endif // _WIN32
     }
    
-    strncat (path, "Glide64.ini", PATH_MAX - strlen(path));
+    //strncat (path, "Glide64.ini", PATH_MAX - strlen(path));
     printf("opening %s\n", path);
     // Open the file
     ini = fopen (path, "r+b");
 #include "Combine.h"
 
 #include "Ini.h"
+#include "Config.h"
 
 #include "TexCache.h"
 #include "CRC.h"
 void ReadSettings ()
 {
   //  LOG("ReadSettings\n");
-  INI_Open ();
-  INI_FindSection ("SETTINGS");
-  settings.card_id = (BYTE)INI_ReadInt ("card_id", 0);
+  if (!Config_Open())
+  {
+    LOG("Could not open configuration!");
+    return;
+  }
+  settings.card_id = (BYTE)Config_ReadInt ("card_id", 0);
   
-  settings.depth_bias = -INI_ReadInt ("depth_bias", 0);
-  settings.res_data = (DWORD) INI_ReadInt ("resolution", 7);
+  settings.depth_bias = -Config_ReadInt ("depth_bias", 0);
+  //TODO: use general settings resolution
+  settings.res_data = (DWORD) Config_ReadInt ("resolution", 7);
   if (settings.res_data >= 24) settings.res_data = 12;
   settings.scr_res_x = settings.res_x = resolutions[settings.res_data][0];
   settings.scr_res_y = settings.res_y = resolutions[settings.res_data][1];
-  settings.autodetect_ucode = (BOOL)INI_ReadInt ("autodetect_ucode", 1);
-  settings.ucode = (DWORD)INI_ReadInt ("ucode", 2);
+  settings.autodetect_ucode = (BOOL)Config_ReadInt ("autodetect_ucode", 1);
+  settings.ucode = (DWORD)Config_ReadInt ("ucode", 2);
   
-  settings.wireframe = (BOOL)INI_ReadInt ("wireframe", 0);
-  settings.wfmode = (int)INI_ReadInt ("wfmode", 1);
-  settings.filtering = (BYTE)INI_ReadInt ("filtering", 1);
-  settings.fog = (BOOL)INI_ReadInt ("fog", 1);
-  settings.buff_clear = (BOOL)INI_ReadInt ("buff_clear", 1);
-  settings.vsync = (BOOL)INI_ReadInt ("vsync", 0);
-  settings.fast_crc = (BOOL)INI_ReadInt ("fast_crc", 0);
-  settings.swapmode = (BYTE)INI_ReadInt ("swapmode", 1);
-  settings.lodmode = (BYTE)INI_ReadInt ("lodmode", 0);
+  settings.wireframe = (BOOL)Config_ReadInt ("wireframe", 0);
+  settings.wfmode = (int)Config_ReadInt ("wfmode", 1);
+  settings.filtering = (BYTE)Config_ReadInt ("filtering", 1);
+  settings.fog = (BOOL)Config_ReadInt ("fog", 1);
+  settings.buff_clear = (BOOL)Config_ReadInt ("buff_clear", 1);
+  settings.vsync = (BOOL)Config_ReadInt ("vsync", 0);
+  settings.fast_crc = (BOOL)Config_ReadInt ("fast_crc", 0);
+  settings.swapmode = (BYTE)Config_ReadInt ("swapmode", 1);
+  settings.lodmode = (BYTE)Config_ReadInt ("lodmode", 0);
   
-  settings.logging = (BOOL)INI_ReadInt ("logging", 0);
-  settings.log_clear = (BOOL)INI_ReadInt ("log_clear", 0);
-  settings.elogging = (BOOL)INI_ReadInt ("elogging", 0);
-  settings.filter_cache = (BOOL)INI_ReadInt ("filter_cache", 0);
-  settings.cpu_write_hack = (BOOL)INI_ReadInt ("detect_cpu_write", 0);
-  settings.unk_as_red = (BOOL)INI_ReadInt ("unk_as_red", 0);
-  settings.log_unk = (BOOL)INI_ReadInt ("log_unk", 0);
-  settings.unk_clear = (BOOL)INI_ReadInt ("unk_clear", 0);
+  settings.logging = (BOOL)Config_ReadInt ("logging", 0);
+  settings.log_clear = (BOOL)Config_ReadInt ("log_clear", 0);
+  settings.elogging = (BOOL)Config_ReadInt ("elogging", 0);
+  settings.filter_cache = (BOOL)Config_ReadInt ("filter_cache", 0);
+  settings.cpu_write_hack = (BOOL)Config_ReadInt ("detect_cpu_write", 0);
+  settings.unk_as_red = (BOOL)Config_ReadInt ("unk_as_red", 0);
+  settings.log_unk = (BOOL)Config_ReadInt ("log_unk", 0);
+  settings.unk_clear = (BOOL)Config_ReadInt ("unk_clear", 0);
   
-  settings.wrap_big_tex = (BOOL)INI_ReadInt ("wrap_big_tex", 0);
-  settings.flame_corona = (BOOL)INI_ReadInt ("flame_corona", 0);
+  settings.wrap_big_tex = (BOOL)Config_ReadInt ("wrap_big_tex", 0);
+  settings.flame_corona = (BOOL)Config_ReadInt ("flame_corona", 0);
   //  settings.RE2_native_video = (BOOL)INI_ReadInt ("RE2_native_video", 0);
   
-  settings.show_fps = (BYTE)INI_ReadInt ("show_fps", 9);
+  settings.show_fps = (BYTE)Config_ReadInt ("show_fps", 9);
   
-  settings.clock = (BOOL)INI_ReadInt ("clock", 0);
-  settings.clock_24_hr = (BOOL)INI_ReadInt ("clock_24_hr", 0);
+  settings.clock = (BOOL)Config_ReadInt ("clock", 0);
+  settings.clock_24_hr = (BOOL)Config_ReadInt ("clock_24_hr", 0);
   
-  settings.fb_read_always = (BOOL)INI_ReadInt ("fb_read_always", 0);
-  settings.fb_read_alpha = (BOOL)INI_ReadInt ("fb_read_alpha", 0);
-  settings.fb_smart = (BOOL)INI_ReadInt ("fb_smart", 0);
-  settings.fb_motionblur = (BOOL)INI_ReadInt ("motionblur", 0);
-  settings.fb_hires = (BOOL)INI_ReadInt ("fb_hires", 1);
-  settings.fb_get_info = (BOOL)INI_ReadInt ("fb_get_info", 0);
-  settings.fb_depth_clear = (BOOL)INI_ReadInt ("fb_clear", 0);
-  settings.fb_depth_render = (BOOL)INI_ReadInt ("fb_render", 0);
+  settings.fb_read_always = (BOOL)Config_ReadInt ("fb_read_always", 0);
+  settings.fb_read_alpha = (BOOL)Config_ReadInt ("fb_read_alpha", 0);
+  settings.fb_smart = (BOOL)Config_ReadInt ("fb_smart", 0);
+  settings.fb_motionblur = (BOOL)Config_ReadInt ("motionblur", 0);
+  settings.fb_hires = (BOOL)Config_ReadInt ("fb_hires", 1);
+  settings.fb_get_info = (BOOL)Config_ReadInt ("fb_get_info", 0);
+  settings.fb_depth_clear = (BOOL)Config_ReadInt ("fb_clear", 0);
+  settings.fb_depth_render = (BOOL)Config_ReadInt ("fb_render", 0);
   if (settings.fb_depth_render)
     settings.fb_depth_clear = TRUE;
   
-  settings.custom_ini = (BOOL)INI_ReadInt ("custom_ini", 1);
-  settings.hotkeys = (BOOL)INI_ReadInt ("hotkeys", 1);
+  settings.custom_ini = (BOOL)Config_ReadInt ("custom_ini", 1);
+  settings.hotkeys = (BOOL)Config_ReadInt ("hotkeys", 1);
 
-  settings.full_res = (BOOL)INI_ReadInt ("full_res", 7);
-  settings.tex_filter = (BOOL)INI_ReadInt ("tex_filter", 0);
-  settings.noditheredalpha = (BOOL)INI_ReadInt ("noditheredalpha", 1);
-  settings.noglsl = (BOOL)INI_ReadInt ("noglsl", 1);
-  settings.FBO = (BOOL)INI_ReadInt ("fbo", 0);
-  settings.disable_auxbuf = (BOOL)INI_ReadInt ("disable_auxbuf", 0);
-  
-  INI_Close ();
+  settings.full_res = (BOOL)Config_ReadInt ("full_res", 7);
+  settings.tex_filter = (BOOL)Config_ReadInt ("tex_filter", 0);
+  settings.noditheredalpha = (BOOL)Config_ReadInt ("noditheredalpha", 1);
+  settings.noglsl = (BOOL)Config_ReadInt ("noglsl", 1);
+  settings.FBO = (BOOL)Config_ReadInt ("fbo", 0);
+  settings.disable_auxbuf = (BOOL)Config_ReadInt ("disable_auxbuf", 0);
+
 }
 
 void ReadSpecialSettings (const char name[21])
     settings.KI = TRUE;
   else if (strstr(name, (const char *)"LEGORacers"))
     settings.lego = TRUE;
-  /*
+
   INI_Open ();
   if (INI_FindSection (name,FALSE) == FALSE)
   {
     INI_Close ();
     return;
   }
-  */
+
   int offset_x = INI_ReadInt ("offset_x", -1, 0);
   int offset_y = INI_ReadInt ("offset_y", -1, 0);
   int scale_x = INI_ReadInt ("scale_x", -1, 0);
   INI_Close ();
 }
 
-//
-// WriteRegistry - writes the settings in the registry
-//
-
-void WriteSettings ()
-{
-  INI_Open ();
-  INI_FindSection ("SETTINGS");
-  INI_WriteInt ("card_id", settings.card_id);
-  INI_WriteInt ("resolution", settings.res_data);
-  INI_WriteInt ("autodetect_ucode", settings.autodetect_ucode);
-  INI_WriteInt ("ucode", settings.ucode);
-  
-  INI_WriteInt ("wireframe", settings.wireframe);
-  INI_WriteInt ("wfmode", settings.wfmode);
-  INI_WriteInt ("filtering", settings.filtering);
-  INI_WriteInt ("fog", settings.fog);
-  INI_WriteInt ("buff_clear", settings.buff_clear);
-  INI_WriteInt ("vsync", settings.vsync);
-  INI_WriteInt ("fast_crc", settings.fast_crc);
-  INI_WriteInt ("swapmode", settings.swapmode);
-  INI_WriteInt ("lodmode", settings.lodmode);
-  
-  INI_WriteInt ("logging", settings.logging);
-  INI_WriteInt ("log_clear", settings.log_clear);
-  INI_WriteInt ("elogging", settings.elogging);
-  INI_WriteInt ("filter_cache", settings.filter_cache);
-  INI_WriteInt ("detect_cpu_write", settings.cpu_write_hack);
-  INI_WriteInt ("unk_as_red", settings.unk_as_red);
-  INI_WriteInt ("log_unk", settings.log_unk);
-  INI_WriteInt ("unk_clear", settings.unk_clear);
-  
-  INI_WriteInt ("wrap_big_tex", settings.wrap_big_tex);
-  INI_WriteInt ("flame_corona", settings.flame_corona);
-  //  INI_WriteInt ("RE2_native_video", settings.RE2_native_video);
-  
-  
-  INI_WriteInt ("show_fps", settings.show_fps);
-  
-  INI_WriteInt ("clock", settings.clock);
-  INI_WriteInt ("clock_24_hr", settings.clock_24_hr);
-  
-  INI_WriteInt ("fb_read_always", settings.fb_read_always);
-  INI_WriteInt ("fb_read_alpha", settings.fb_read_alpha);
-  INI_WriteInt ("fb_smart", settings.fb_smart);
-  INI_WriteInt ("motionblur", settings.fb_motionblur);
-  INI_WriteInt ("fb_hires", settings.fb_hires);
-  INI_WriteInt ("fb_get_info", settings.fb_get_info);
-  INI_WriteInt ("fb_clear", settings.fb_depth_clear);
-  INI_WriteInt ("fb_render", settings.fb_depth_render);
-  
-  INI_WriteInt ("custom_ini", settings.custom_ini);
-  INI_WriteInt ("hotkeys", settings.hotkeys);
-
-  INI_WriteInt ("full_res", settings.full_res);
-  INI_WriteInt ("tex_filter", settings.tex_filter);
-  INI_WriteInt ("noditheredalpha", settings.noditheredalpha);
-  INI_WriteInt ("noglsl", settings.noglsl);
-  INI_WriteInt ("fbo", settings.FBO);
-  
-  INI_Close ();
-}
-
 #include "font.h"
 #include "cursor.h"
 
         return M64ERR_INCOMPATIBLE;
     }
 
-    SetConfigDir(ConfigGetUserDataPath());
+    SetConfigDir(ConfigGetSharedDataFilepath("Glide64.ini"));
 
     CoreVideo_Init();
     return M64ERR_SUCCESS;

src/config.h

-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-*
-* 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
-* 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
-* Licence along with this program; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
-* Boston, MA  02110-1301, USA
-*/
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#define GTK2_SUPPORT 1
-
-#endif /* CONFIG_H */
-
 
 #define LOG(...)
 
+/* definitions of pointers to Core config functions */
+extern ptr_ConfigOpenSection      ConfigOpenSection;
+extern ptr_ConfigSetParameter     ConfigSetParameter;
+extern ptr_ConfigGetParameter     ConfigGetParameter;
+extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
+extern ptr_ConfigSetDefaultInt    ConfigSetDefaultInt;
+extern ptr_ConfigSetDefaultFloat  ConfigSetDefaultFloat;
+extern ptr_ConfigSetDefaultBool   ConfigSetDefaultBool;
+extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
+extern ptr_ConfigGetParamInt      ConfigGetParamInt;
+extern ptr_ConfigGetParamFloat    ConfigGetParamFloat;
+extern ptr_ConfigGetParamBool     ConfigGetParamBool;
+extern ptr_ConfigGetParamString   ConfigGetParamString;
+
+extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
+extern ptr_ConfigGetUserConfigPath     ConfigGetUserConfigPath;
+extern ptr_ConfigGetUserDataPath       ConfigGetUserDataPath;
+extern ptr_ConfigGetUserCachePath      ConfigGetUserCachePath;
+
+
 extern ptr_VidExt_Init                  CoreVideo_Init;
 extern ptr_VidExt_Quit                  CoreVideo_Quit;
 extern ptr_VidExt_ListFullscreenModes   CoreVideo_ListFullscreenModes;
 #include "Combine.h"
 #include "Util.h"
 #include "Ini.h"
+#include "Config.h"
 #include "Tmem.h"
 #include "TexCache.h"
 #include "TexCache.h"
     INI_FindSection ("UCODE");
     FRDP("ucode = %s\n", str);
     int uc = INI_ReadInt (str, -2, 0);
-    
+    printf("ucode = %d\n", uc);
     if (uc == -2 && ucode_error_report)
     {
-        INI_FindSection ("SETTINGS");
-        settings.ucode = INI_ReadInt ("ucode", 0);
-        INI_Close ();
+        Config_Open();
+        settings.ucode = Config_ReadInt ("ucode", 0);
         
         ReleaseGfx ();
         sprintf (out_buf, "Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", (unsigned long)uc_crc);
     }
     else if (uc == -1 && ucode_error_report)
     {
-        INI_FindSection ("SETTINGS");
-        settings.ucode = INI_ReadInt ("ucode", 0);
-        INI_Close ();
+        Config_Open();
+        settings.ucode = Config_ReadInt ("ucode", 0);
         
         ReleaseGfx ();
         sprintf (out_buf, "Error: Unsupported uCode!\n\ncrc: %08lx", (unsigned long)uc_crc);
         old_ucode = settings.ucode;
         settings.ucode = uc;
         FRDP("microcheck: old ucode: %d,  new ucode: %d\n", old_ucode, uc);
-        INI_FindSection ("SETTINGS");
-        INI_WriteInt ("ucode", uc);
-        INI_Close ();
     }
 }