From 1c65f79e9017ec11a5b34ad648ee2abefb4bc5d4 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 24 Apr 2013 15:03:21 +1000 Subject: [PATCH] Glide64: Change settings to go through the emu --- Config/Project64.rdb | 163 ++++++ Project64.sln | 7 +- Source/Glide64/Config.cpp | 6 +- Source/Glide64/Config.h | 31 +- Source/Glide64/Gfx #1.3.h | 14 +- Source/Glide64/Main.cpp | 499 ++++++++++-------- Source/Glide64/rdp.cpp | 9 +- Source/Project64/Plugins/Audio Plugin.cpp | 12 +- Source/Project64/Plugins/Audio Plugin.h | 1 + .../Project64/Plugins/Controller Plugin.cpp | 12 +- Source/Project64/Plugins/Controller Plugin.h | 1 + Source/Project64/Plugins/GFX plugin.cpp | 12 +- Source/Project64/Plugins/GFX plugin.h | 1 + Source/Project64/Plugins/Plugin Class.h | 18 +- Source/Project64/Plugins/RSP Plugin.cpp | 12 +- Source/Project64/Plugins/RSP Plugin.h | 1 + Source/Project64/Project64.vcproj | 8 + .../Settings/SettingType/SettingsType-Base.h | 1 + .../SettingsType-RomDatabaseSetting.cpp | 190 +++++++ .../SettingsType-RomDatabaseSetting.h | 51 ++ Source/Project64/Settings/Settings Class.cpp | 48 +- Source/Project64/Settings/Settings Class.h | 3 +- Source/Settings/Settings.cpp | 52 +- Source/Settings/Settings.h | 17 +- 24 files changed, 882 insertions(+), 287 deletions(-) create mode 100644 Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp create mode 100644 Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h diff --git a/Config/Project64.rdb b/Config/Project64.rdb index 8917a8d51..a78090d21 100644 --- a/Config/Project64.rdb +++ b/Config/Project64.rdb @@ -47,6 +47,169 @@ Homepage=www.pj64-emu.com //35A16874=0 //Quake 64 Intro (PD), On load (Gent) //A21D415B=0 //TRSI Intro by Ayatollah (POM '99) (PD), On load (Gent) +// UCODE: +// These are ucode crcs used in the uCode detector. +// If a crc is not found here, the plugin will ask you +// to add it. All these values are in hexadecimal. +// +// uCodes: +// -1 - Unknown, display error +// 0 - RSP SW 2.0X (Super Mario 64) +// 1 - F3DEX 1.XX (Star Fox 64) +// 2 - F3DEX 2.XX (The Legend of Zelda: Ocarina of Time) +// 3 - F3DEX ? (WaveRace) +// 4 - RSP SW 2.0D EXT (Star Wars: Shadows of the Empire) +// 5 - RSP SW 2.0 (Diddy Kong Racing); +// 6 - S2DEX 1.XX (Yoshi's Story - SimCity 2000) +// 7 - RSP SW PD (Perfect Dark) +// 8 - F3DEXBG 2.08 (Conker's Bad Fur Day) +[Glide64-ucode] +006bd77f=0 +03044b84=2 +030f4b84=2 +05165579=1 +05777c62=1 +057e7c62=1 +07200895=0 +0bf36d36=9 +0d7bbffb=-1 +0d7cbffb=5 +0ff79527=2 +0ff795bf=-1 +1118b3e0=1 +1517a281=1 +168e9cd5=2 +1a1e18a0=2 +1a1e1920=2 +1a62dbaf=2 +1a62dc2f=2 +1de712ff=1 +1ea9e30f=6 +1f120bbb=21 +21f91834=2 +21f91874=2 +22099872=2 +24cd885b=1 +26a7879a=1 +299d5072=6 +2b291027=2 +2b5a89c2=6 +2c7975d6=1 +2d3fe3f1=1 +2f71d1d5=2 +2f7dd1d5=2 +327b933d=1 +339872a6=1 +377359b6=2 +3a1c2b34=0 +3a1cbac3=0 +3f7247fb=0 +3ff1a4ca=1 +4165e1fd=0 +4340ac9b=1 +440cfad6=1 +47d46e86=7 +485abff2=2 +4fe6df78=1 +5182f610=0 +5257cd2a=1 +5414030c=1 +5414030d=1 +559ff7d4=1 +5b5d36e3=4 +5b5d3763=3 +5d1d6f53=0 +5d3099f1=2 +5df1408c=1 +5ef4e34a=1 +6075e9eb=1 +60c1dcc4=1 +6124a508=2 +630a61fb=2 +63be08b1=5 +63be08b3=5 +64ed27e5=1 +65201989=2 +65201a09=2 +66c0b10a=1 +679e1205=2 +6bb745c9=6 +6d8f8f8a=2 +6e4d50af=0 +6eaa1da8=1 +72a4f34e=1 +73999a23=1 +74af0a74=6 +753be4a5=2 +794c3e28=6 +7df75834=1 +7f2d0a2e=1 +82f48073=1 +832fcb99=1 +841ce10f=1 +844b55b5=-1 +863e1ca7=1 +86b1593e=-1 +8805ffea=1 +8d5735b2=1 +8d5735b3=1 +8ec3e124=-1 +93d11f7b=2 +93d11ffb=2 +93d1ff7b=2 +9551177b=2 +955117fb=2 +95cd0062=2 +97d1b58a=1 +a2d0f88e=2 +a346a5cc=1 +aa86cb1d=2 +aae4a5b9=2 +ad0a6292=2 +ad0a6312=2 +ae08d5b9=0 +b1821ed3=1 +b4577b9c=1 +b54e7f93=0 +b62f900f=2 +ba65ea1e=2 +ba86cb1d=8 +bc03e969=0 +bc45382e=2 +be78677c=1 +bed8b069=1 +c3704e41=1 +c46dbc3d=1 +c99a4c6c=1 +c901ce73=2 +c901cef3=2 +cb8c9b6c=2 +cee7920f=1 +cfa35a45=2 +d1663234=1 +d20dedbf=6 +d2a9f59c=1 +d41db5f7=1 +d5604971=0 +d57049a5=1 +d5c4dc96=-1 +d5d68b1f=0 +d67c2f8b=0 +d802ec04=1 +da13ab96=2 +de7d67d4=2 +e1290fa2=2 +e41ec47e=0 +e65cb4ad=2 +e89c2b92=1 +e9231df2=1 +ec040469=1 +ee47381b=1 +ef54ee35=1 +f9893f70=21 +fb816260=1 +ff372492=21 + [Rom Status] // Setting up ROM browser status categories & colour definitions: // diff --git a/Project64.sln b/Project64.sln index 65b4186b8..8f2206686 100644 --- a/Project64.sln +++ b/Project64.sln @@ -37,6 +37,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Glide64", "Source\Glide64\G {25A25249-C284-4C5A-8DC2-26FC3EB13703} = {25A25249-C284-4C5A-8DC2-26FC3EB13703} {B4A4B994-9111-42B1-93C2-6F1CA8BC4421} = {B4A4B994-9111-42B1-93C2-6F1CA8BC4421} {2DADDAA5-0F57-46ED-A974-747908DDC7F3} = {2DADDAA5-0F57-46ED-A974-747908DDC7F3} + {8B9961B1-88D9-4EA3-A752-507A00DD9F3D} = {8B9961B1-88D9-4EA3-A752-507A00DD9F3D} {427F1DCD-3BED-4010-9322-077A4C06D871} = {427F1DCD-3BED-4010-9322-077A4C06D871} {93CFEDF3-9A75-4484-B169-D9D8074F5AC2} = {93CFEDF3-9A75-4484-B169-D9D8074F5AC2} EndProjectSection @@ -177,13 +178,13 @@ Global {731BD205-2826-4631-B7AF-117658E88DBC} = {AA8F7F8E-5377-4911-859D-8A8817B0DB26} {1379F817-7E3D-4F58-9C22-7E364E46E842} = {AA8F7F8E-5377-4911-859D-8A8817B0DB26} {3326E128-33AF-422C-BB7C-67CC6B915610} = {AA8F7F8E-5377-4911-859D-8A8817B0DB26} + {462C2608-182F-452C-944F-AF201E19300B} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} + {A4D13408-A794-4199-8FC7-4A9A32505005} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} + {2DADDAA5-0F57-46ED-A974-747908DDC7F3} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} {93447136-FACD-4740-8F35-FC46FB4A9E82} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {427F1DCD-3BED-4010-9322-077A4C06D871} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {93CFEDF3-9A75-4484-B169-D9D8074F5AC2} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {05B9CB11-12D1-47CD-8E4A-88E12162119B} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {25A25249-C284-4C5A-8DC2-26FC3EB13703} = {1379F817-7E3D-4F58-9C22-7E364E46E842} - {A4D13408-A794-4199-8FC7-4A9A32505005} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} - {462C2608-182F-452C-944F-AF201E19300B} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} - {2DADDAA5-0F57-46ED-A974-747908DDC7F3} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} EndGlobalSection EndGlobal diff --git a/Source/Glide64/Config.cpp b/Source/Glide64/Config.cpp index e8a3cdbe7..27ca80bf6 100644 --- a/Source/Glide64/Config.cpp +++ b/Source/Glide64/Config.cpp @@ -53,6 +53,7 @@ // begin wxGlade: ::extracode // end wxGlade +short Set_basic_mode = 0; ConfigNotebook::ConfigNotebook(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size, long /*style*/): @@ -97,7 +98,6 @@ wxNotebook(parent, id, pos, size, 0) }; cmbResolution = new wxComboBox(BasicSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 24, cmbResolution_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY); cbxVSync = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Vertical sync")); - cbxAdvancedSettings = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Show advanced emulation options")); cbxTextureSettings = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Show texture enhancement options")); lblScreenShotFormat = new wxStaticText(BasicSettingsPanel, wxID_ANY, _("Screenshot format:")); cmbScreenShotFormat = new wxComboBox(BasicSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY); @@ -446,8 +446,6 @@ void ConfigNotebook::set_properties() cbxClock24->SetToolTip(_("Display hours as 24-hour clock.\n[Recommended: your preference]")); cbxTextTransparent->SetToolTip(_("Transparent text background\nIf this is checked, all on-screen messages will have a transparent background. Otherwise, it will have a solid black background.\n[Recommended: your preference]")); cbxTextTransparent->SetValue((settings.show_fps&8) > 0); - cbxAdvancedSettings->SetValue(settings.advanced_options > 0); - cbxAdvancedSettings->SetToolTip(_("Enable \"Emulation settings\" panel. For experienced users only!\nIt shows default emulation settings when game is not loaded, or current game settings otherwise.")); cbxTextureSettings->SetValue(settings.texenh_options > 0); cbxTextureSettings->SetToolTip(_("Enable \"Texture enhancement\" panel.\nIt shows various enhancement options for original textures as well as options for hi-resolution textures.")); tooltip = _("Full screen resolution:\nThis sets the full screen resolution for non-3dfx video cards.\nAll the resolutions that your video card/monitor support should be displayed.\n[Recommended: native (max) resolution of your monitor - unless performance becomes an issue]"); @@ -702,7 +700,6 @@ void ConfigNotebook::do_layout() OnScreenInfoSizer->Add(InfoMainSizer, 1, wxEXPAND, 0); ConfigUpperSizer->Add(OnScreenInfoSizer, 1, wxLEFT|wxRIGHT|wxEXPAND, 10); ConfigMainSizer->Add(ConfigUpperSizer, 1, wxEXPAND, 0); - ShowPanelsSizer->Add(cbxAdvancedSettings, 1, 0, 10); ShowPanelsSizer->Add(cbxTextureSettings, 1, wxLEFT, 10); OtherSizer->Add(ShowPanelsSizer, 0, wxTOP|wxBOTTOM|wxEXPAND, 10); ScreenShotFormatSizer->Add(lblScreenShotFormat, 0, 0, 0); @@ -927,7 +924,6 @@ void ConfigNotebook::SaveSettings() } #endif //TEXTURE_FILTER - settings.advanced_options = (int)cbxAdvancedSettings->GetValue(); settings.texenh_options = (int)cbxTextureSettings->GetValue(); #ifndef _ENDUSER_RELEASE_ diff --git a/Source/Glide64/Config.h b/Source/Glide64/Config.h index e7e19b001..6cd27b909 100644 --- a/Source/Glide64/Config.h +++ b/Source/Glide64/Config.h @@ -106,7 +106,6 @@ protected: wxStaticText* lblMb; wxCheckBox* cbxFBO; wxStaticBox* OtherSizer_staticbox; - wxCheckBox* cbxAdvancedSettings; wxCheckBox* cbxTextureSettings; wxStaticText* lblScreenShotFormat; wxComboBox* cmbScreenShotFormat; @@ -257,4 +256,34 @@ protected: // end wxGlade }; // wxGlade: end class +enum { + // General Settings + Set_CardId, Set_Resolution, Set_vsync, Set_ssformat, Set_ShowFps, Set_clock, + Set_clock_24_hr, Set_texenh_options, Set_hotkeys, Set_wrpResolution, Set_wrpVRAM, + Set_wrpFBO, Set_wrpAnisotropic, Set_autodetect_ucode, Set_ucode, Set_wireframe, + Set_wfmode, Set_logging, Set_log_clear, Set_elogging, Set_run_in_window, + Set_filter_cache, Set_unk_as_red, Set_log_unk, Set_unk_clear, Set_ghq_fltr, + Set_ghq_cmpr, Set_ghq_enht, Set_ghq_hirs, Set_ghq_enht_cmpr, Set_ghq_enht_tile, + Set_ghq_enht_f16bpp, Set_ghq_enht_gz, Set_ghq_enht_nobg, Set_ghq_hirs_cmpr, + Set_ghq_hirs_tile, Set_ghq_hirs_f16bpp, Set_ghq_hirs_gz, Set_ghq_hirs_altcrc, + Set_ghq_cache_save, Set_ghq_cache_size, Set_ghq_hirs_let_texartists_fly, + Set_ghq_hirs_dump, + + //Game Settings + Set_alt_tex_size, Set_use_sts1_only, Set_force_calc_sphere, Set_correct_viewport, + Set_increase_texrect_edge, Set_decrease_fillrect_edge, Set_texture_correction, + Set_pal230, Set_stipple_mode, Set_stipple_pattern, Set_force_microcheck, Set_force_quad3d, + Set_clip_zmin, Set_clip_zmax, Set_fast_crc, Set_adjust_aspect, Set_zmode_compare_less, + Set_old_style_adither, Set_n64_z_scale, Set_optimize_texrect, Set_ignore_aux_copy, + Set_hires_buf_clear, Set_fb_read_alpha, Set_useless_is_useless, Set_fb_crc_mode, + Set_filtering, Set_fog, Set_buff_clear, Set_swapmode, Set_aspect, Set_lodmode, + Set_fb_smart, Set_fb_hires, Set_fb_read_always, Set_read_back_to_screen, + Set_detect_cpu_write, Set_fb_get_info, Set_fb_render, + + //RDB Setting + Set_ucodeLookup, +}; + +extern short Set_basic_mode; + #endif // CONFIG_H diff --git a/Source/Glide64/Gfx #1.3.h b/Source/Glide64/Gfx #1.3.h index c99682fe3..119b985a6 100644 --- a/Source/Glide64/Gfx #1.3.h +++ b/Source/Glide64/Gfx #1.3.h @@ -89,9 +89,12 @@ the plugin #include #include // offsetof #include +#include +#include #include "GlideExtensions.h" #include "rdp.h" #include "Keys.h" +#include "config.h" #if defined __VISUALC__ typedef unsigned char boolean; @@ -708,16 +711,7 @@ output: Values are return in the FrameBufferInfo structure ************************************************************************/ EXPORT void CALL FBGetFrameBufferInfo(void *pinfo); -/****************************************************************** - NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE - ORIGINAL SPEC - Function: SetConfigDir - Purpose: To pass the location where config files should be read/ - written to. - input: path to config directory - output: none -*******************************************************************/ -EXPORT void CALL SetConfigDir(char *configDir); +EXPORT void CALL PluginLoaded (void); #if defined(__cplusplus) } diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index a3242ca3f..6559f7911 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -39,6 +39,8 @@ #include "Gfx #1.3.h" #include +#include + #include #include #include "Util.h" @@ -181,30 +183,8 @@ int capture_screen = 0; wxString capture_path; wxString pluginPath; -wxString iniPath; -wxString iniName; wxMutex *mutexProcessDList = NULL; -/****************************************************************** - NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE - ORIGINAL SPEC - Function: SetConfigDir - Purpose: To pass the location where config files should be read/ - written to. - input: path to config directory - output: none -*******************************************************************/ -EXPORT void CALL SetConfigDir(char *configDir) -{ - wxString dirName(configDir, wxConvUTF8); - wxString path = wxPathOnly(dirName); - if (wxDirExists(path)) - { - iniName = path + wxT("/Glide64.ini"); - iniPath = path; - } -} - static void PluginPath() { wxDynamicLibraryDetailsArray dlls = wxDynamicLibrary::ListLoaded(); @@ -342,101 +322,86 @@ void ConfigWrapper() grConfigWrapperExt(settings.wrpResolution, settings.wrpVRAM * 1024 * 1024, settings.wrpFBO, settings.wrpAnisotropic); } -static wxConfigBase * OpenIni() +void UseUnregisteredSetting (int /*SettingID*/) { - wxConfigBase * ini = wxConfigBase::Get(false); - if (!ini) - { - if (iniName.IsEmpty()) - iniName = pluginPath + wxT("/Glide64.ini"); - if (wxFileExists(iniName)) - { - wxFileInputStream is(iniName); - wxFileConfig * fcfg = new wxFileConfig(is, wxConvISO8859_1); - wxConfigBase::Set(fcfg); - ini = fcfg; - } - } - if (!ini) - wxMessageBox(_T("Can not find ini file! Plugin will not run properly."), _T("File not found"), wxOK|wxICON_EXCLAMATION); - return ini; + _asm int 3 } void ReadSettings () { - // LOG("ReadSettings\n"); - wxConfigBase * ini = OpenIni(); - if (!ini || !ini->HasGroup(_T("/SETTINGS"))) - return; - ini->SetPath(_T("/SETTINGS")); + //Config.h - settings.card_id = ini->Read(_T("card_id"), 0l); - settings.res_data = (wxUint32)ini->Read(_T("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.vsync = ini->Read(_T("vsync"), 0l); - settings.ssformat = (wxUint8)ini->Read(_T("ssformat"), 0l); - settings.show_fps = (wxUint8)ini->Read(_T("show_fps"), 0l); - settings.clock = ini->Read(_T("clock"), 0l); - settings.clock_24_hr = ini->Read(_T("clock_24_hr"), 0l); - settings.advanced_options = ini->Read(_T("advanced_options"), 0l); - settings.texenh_options = ini->Read(_T("texenh_options"), 0l); - settings.use_hotkeys = ini->Read(_T("hotkeys"), 1l); + //PluginLoaded - settings.wrpResolution = ini->Read(_T("wrpResolution"), 0l); - settings.wrpVRAM = ini->Read(_T("wrpVRAM"), 0l); - settings.wrpFBO = ini->Read(_T("wrpFBO"), 0l); - settings.wrpAnisotropic = ini->Read(_T("wrpAnisotropic"), 0l); + settings.card_id = GetSetting(Set_CardId); + settings.res_data = (wxUint32)GetSetting(Set_Resolution); + 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.vsync = GetSetting(Set_vsync); + settings.ssformat = (wxUint8)GetSetting(Set_ssformat); + settings.show_fps = (wxUint8)GetSetting(Set_ShowFps); + settings.clock = GetSetting(Set_clock); + settings.clock_24_hr = GetSetting(Set_clock_24_hr); + settings.advanced_options = Set_basic_mode ? !GetSystemSetting(Set_basic_mode) : 0; + settings.texenh_options = GetSetting(Set_texenh_options); + settings.use_hotkeys = GetSetting(Set_hotkeys); + + settings.wrpResolution = GetSetting(Set_wrpResolution); + settings.wrpVRAM = GetSetting(Set_wrpVRAM); + settings.wrpFBO = GetSetting(Set_wrpFBO); + settings.wrpAnisotropic = GetSetting(Set_wrpAnisotropic); #ifndef _ENDUSER_RELEASE_ - settings.autodetect_ucode = ini->Read(_T("autodetect_ucode"), 1); - settings.ucode = ini->Read(_T("ucode"), 2); - settings.wireframe = ini->Read(_T("wireframe"), 0l); - settings.wfmode = ini->Read(_T("wfmode"), 1); - settings.logging = ini->Read(_T("logging"), 0l); - settings.log_clear = ini->Read(_T("log_clear"), 0l); - settings.run_in_window = ini->Read(_T("run_in_window"), 0l); - settings.elogging = ini->Read(_T("elogging"), 0l); - settings.filter_cache = ini->Read(_T("filter_cache"), 0l); - settings.unk_as_red = ini->Read(_T("unk_as_red"), 0l); - settings.log_unk = ini->Read(_T("log_unk"), 0l); - settings.unk_clear = ini->Read(_T("unk_clear"), 0l); + settings.autodetect_ucode = GetSetting(Set_autodetect_ucode); + settings.ucode = GetSetting(Set_ucode); + settings.wireframe = GetSetting(Set_wireframe); + settings.wfmode = GetSetting(Set_wfmode); + settings.logging = GetSetting(Set_logging); + settings.log_clear = GetSetting(Set_log_clear); + settings.run_in_window = GetSetting(Set_run_in_window); + settings.elogging = GetSetting(Set_elogging); + settings.filter_cache = GetSetting(Set_filter_cache); + settings.unk_as_red = GetSetting(Set_unk_as_red); + settings.log_unk = GetSetting(Set_log_unk); + settings.unk_clear = GetSetting(Set_unk_clear); #else - settings.autodetect_ucode = TRUE; - settings.ucode = 2; - settings.wireframe = FALSE; - settings.wfmode = 0; - settings.logging = FALSE; - settings.log_clear = FALSE; - settings.run_in_window = FALSE; - settings.elogging = FALSE; - settings.filter_cache = FALSE; - settings.unk_as_red = FALSE; - settings.log_unk = FALSE; - settings.unk_clear = FALSE; + settings.autodetect_ucode = TRUE; + settings.ucode = 2; + settings.wireframe = FALSE; + settings.wfmode = 0; + settings.logging = FALSE; + settings.log_clear = FALSE; + settings.run_in_window = FALSE; + settings.elogging = FALSE; + settings.filter_cache = FALSE; + settings.unk_as_red = FALSE; + settings.log_unk = FALSE; + settings.unk_clear = FALSE; #endif + #ifdef TEXTURE_FILTER - settings.ghq_fltr = (wxUint8)ini->Read(_T("ghq_fltr"), 0l); - settings.ghq_cmpr = (wxUint8)ini->Read(_T("ghq_cmpr"), 0l); - settings.ghq_enht = (wxUint8)ini->Read(_T("ghq_enht"), 0l); - settings.ghq_hirs = (wxUint8)ini->Read(_T("ghq_hirs"), 0l); - settings.ghq_enht_cmpr = ini->Read(_T("ghq_enht_cmpr"), 0l); - settings.ghq_enht_tile = ini->Read(_T("ghq_enht_tile"), 0l); - settings.ghq_enht_f16bpp = ini->Read(_T("ghq_enht_f16bpp"), 0l); - settings.ghq_enht_gz = ini->Read(_T("ghq_enht_gz"), 1L); - settings.ghq_enht_nobg = ini->Read(_T("ghq_enht_nobg"), 0l); - settings.ghq_hirs_cmpr = ini->Read(_T("ghq_hirs_cmpr"), 0l); - settings.ghq_hirs_tile = ini->Read(_T("ghq_hirs_tile"), 0l); - settings.ghq_hirs_f16bpp = ini->Read(_T("ghq_hirs_f16bpp"), 0l); - settings.ghq_hirs_gz = ini->Read(_T("ghq_hirs_gz"), 1); - settings.ghq_hirs_altcrc = ini->Read(_T("ghq_hirs_altcrc"), 1); - settings.ghq_cache_save = ini->Read(_T("ghq_cache_save"), 1); - settings.ghq_cache_size = ini->Read(_T("ghq_cache_size"), 0l); - settings.ghq_hirs_let_texartists_fly = ini->Read(_T("ghq_hirs_let_texartists_fly"), 0l); - settings.ghq_hirs_dump = ini->Read(_T("ghq_hirs_dump"), 0l); + settings.ghq_fltr = (wxUint8)GetSetting(Set_ghq_fltr); + settings.ghq_cmpr = (wxUint8)GetSetting(Set_ghq_cmpr); + settings.ghq_enht = (wxUint8)GetSetting(Set_ghq_enht); + settings.ghq_hirs = (wxUint8)GetSetting(Set_ghq_hirs); + settings.ghq_enht_cmpr = GetSetting(Set_ghq_enht_cmpr); + settings.ghq_enht_tile = GetSetting(Set_ghq_enht_tile); + settings.ghq_enht_f16bpp = GetSetting(Set_ghq_enht_f16bpp); + settings.ghq_enht_gz = GetSetting(Set_ghq_enht_gz); + settings.ghq_enht_nobg = GetSetting(Set_ghq_enht_nobg); + settings.ghq_hirs_cmpr = GetSetting(Set_ghq_hirs_cmpr); + settings.ghq_hirs_tile = GetSetting(Set_ghq_hirs_tile); + settings.ghq_hirs_f16bpp = GetSetting(Set_ghq_hirs_f16bpp); + settings.ghq_hirs_gz = GetSetting(Set_ghq_hirs_gz); + settings.ghq_hirs_altcrc = GetSetting(Set_ghq_hirs_altcrc); + settings.ghq_cache_save = GetSetting(Set_ghq_cache_save); + settings.ghq_cache_size = GetSetting(Set_ghq_cache_size); + settings.ghq_hirs_let_texartists_fly = GetSetting(Set_ghq_hirs_let_texartists_fly); + settings.ghq_hirs_dump = GetSetting(Set_ghq_hirs_dump); #endif + ConfigWrapper(); } @@ -509,45 +474,36 @@ void ReadSpecialSettings (const char * name) else if (strstr(name, (const char *)"PUZZLE LEAGUE")) settings.hacks |= hack_PPL; - wxString groupName = wxT("/"); - groupName += wxString::FromAscii(name); - wxConfigBase * ini = OpenIni(); - if (!ini || !ini->HasGroup(groupName)) - return; - ini->SetPath(groupName); - - ini->Read(_T("alt_tex_size"), &(settings.alt_tex_size)); - ini->Read(_T("use_sts1_only"), &(settings.use_sts1_only)); - ini->Read(_T("force_calc_sphere"), &(settings.force_calc_sphere)); - ini->Read(_T("correct_viewport"), &(settings.correct_viewport)); - ini->Read(_T("increase_texrect_edge"), &(settings.increase_texrect_edge)); - ini->Read(_T("decrease_fillrect_edge"), &(settings.decrease_fillrect_edge)); - if (ini->Read(_T("texture_correction"), -1) == 0) settings.texture_correction = 0; - else settings.texture_correction = 1; - if (ini->Read(_T("pal230"), -1) == 1) settings.pal230 = 1; - else settings.pal230 = 0; - ini->Read(_T("stipple_mode"), &(settings.stipple_mode)); - int stipple_pattern = ini->Read(_T("stipple_pattern"), -1); + settings.alt_tex_size = GetSetting(Set_alt_tex_size); + settings.use_sts1_only = GetSetting(Set_use_sts1_only); + settings.force_calc_sphere = GetSetting(Set_force_calc_sphere); + settings.correct_viewport = GetSetting(Set_correct_viewport); + settings.increase_texrect_edge = GetSetting(Set_increase_texrect_edge); + settings.decrease_fillrect_edge = GetSetting(Set_decrease_fillrect_edge); + settings.texture_correction = GetSetting(Set_texture_correction) == 0 ? 0 : 1; + settings.pal230 = GetSetting(Set_pal230) == 1 ? 1 : 0; + settings.stipple_mode = GetSetting(Set_stipple_mode); + int stipple_pattern = GetSetting(Set_stipple_pattern); if (stipple_pattern > 0) settings.stipple_pattern = (wxUint32)stipple_pattern; - ini->Read(_T("force_microcheck"), &(settings.force_microcheck)); - ini->Read(_T("force_quad3d"), &(settings.force_quad3d)); - ini->Read(_T("clip_zmin"), &(settings.clip_zmin)); - ini->Read(_T("clip_zmax"), &(settings.clip_zmax)); - ini->Read(_T("fast_crc"), &(settings.fast_crc)); - ini->Read(_T("adjust_aspect"), &(settings.adjust_aspect), 1); - ini->Read(_T("zmode_compare_less"), &(settings.zmode_compare_less)); - ini->Read(_T("old_style_adither"), &(settings.old_style_adither)); - ini->Read(_T("n64_z_scale"), &(settings.n64_z_scale)); + settings.force_microcheck = GetSetting(Set_force_microcheck); + settings.force_quad3d = GetSetting(Set_force_quad3d); + settings.clip_zmin = GetSetting(Set_clip_zmin); + settings.clip_zmax = GetSetting(Set_clip_zmax); + settings.fast_crc = GetSetting(Set_fast_crc); + settings.adjust_aspect = GetSetting(Set_adjust_aspect); + settings.zmode_compare_less = GetSetting(Set_zmode_compare_less); + settings.old_style_adither = GetSetting(Set_old_style_adither); + settings.n64_z_scale = GetSetting(Set_n64_z_scale); if (settings.n64_z_scale) ZLUT_init(); //frame buffer - int optimize_texrect = ini->Read(_T("optimize_texrect"), -1); - int ignore_aux_copy = ini->Read(_T("ignore_aux_copy"), -1); - int hires_buf_clear = ini->Read(_T("hires_buf_clear"), -1); - int read_alpha = ini->Read(_T("fb_read_alpha"), -1); - int useless_is_useless = ini->Read(_T("useless_is_useless"), -1); - int fb_crc_mode = ini->Read(_T("fb_crc_mode"), -1); + int optimize_texrect = GetSetting(Set_optimize_texrect); + int ignore_aux_copy = GetSetting(Set_ignore_aux_copy); + int hires_buf_clear = GetSetting(Set_hires_buf_clear); + int read_alpha = GetSetting(Set_fb_read_alpha); + int useless_is_useless = GetSetting(Set_useless_is_useless); + int fb_crc_mode = GetSetting(Set_fb_crc_mode); if (optimize_texrect > 0) settings.frame_buffer |= fb_optimize_texrect; else if (optimize_texrect == 0) settings.frame_buffer &= ~fb_optimize_texrect; @@ -563,14 +519,14 @@ void ReadSpecialSettings (const char * name) // if (settings.custom_ini) { - ini->Read(_T("filtering"), &(settings.filtering)); - ini->Read(_T("fog"), &(settings.fog)); - ini->Read(_T("buff_clear"), &(settings.buff_clear)); - ini->Read(_T("swapmode"), &(settings.swapmode)); - ini->Read(_T("aspect"), &(settings.aspectmode)); - ini->Read(_T("lodmode"), &(settings.lodmode)); - int resolution; - if (ini->Read(_T("resolution"), &resolution)) + settings.filtering = GetSetting(Set_filtering); + settings.fog = GetSetting(Set_fog); + settings.buff_clear = GetSetting(Set_buff_clear); + settings.swapmode = GetSetting(Set_swapmode); + settings.aspectmode = GetSetting(Set_aspect); + settings.lodmode = GetSetting(Set_lodmode); + int resolution = GetSetting(Set_Resolution); + if (resolution >= 0) { settings.res_data = (wxUint32)resolution; if (settings.res_data >= 0x18) settings.res_data = 12; @@ -579,13 +535,13 @@ void ReadSpecialSettings (const char * name) } //frame buffer - int smart_read = ini->Read(_T("fb_smart"), -1); - int hires = ini->Read(_T("fb_hires"), -1); - int read_always = ini->Read(_T("fb_read_always"), -1); - int read_back_to_screen = ini->Read(_T("read_back_to_screen"), -1); - int cpu_write_hack = ini->Read(_T("detect_cpu_write"), -1); - int get_fbinfo = ini->Read(_T("fb_get_info"), -1); - int depth_render = ini->Read(_T("fb_render"), -1); + int smart_read = GetSetting(Set_fb_smart); + int hires = GetSetting(Set_fb_hires); + int read_always = GetSetting(Set_fb_read_always); + int read_back_to_screen = GetSetting(Set_read_back_to_screen); + int cpu_write_hack = GetSetting(Set_detect_cpu_write); + int get_fbinfo = GetSetting(Set_fb_get_info); + int depth_render = GetSetting(Set_fb_render); if (smart_read > 0) settings.frame_buffer |= fb_emulation; else if (smart_read == 0) settings.frame_buffer &= ~fb_emulation; @@ -609,95 +565,81 @@ void ReadSpecialSettings (const char * name) void WriteSettings (bool saveEmulationSettings) { - wxConfigBase * ini = OpenIni(); - if (!ini || !ini->HasGroup(_T("/SETTINGS"))) - return; - ini->SetPath(_T("/SETTINGS")); + SetSetting(Set_CardId,settings.card_id); + SetSetting(Set_Resolution,(int)settings.res_data); + SetSetting(Set_ssformat,settings.ssformat); + SetSetting(Set_vsync,settings.vsync); + SetSetting(Set_ShowFps,settings.show_fps); + SetSetting(Set_clock,settings.clock); + SetSetting(Set_clock_24_hr,settings.clock_24_hr); + //SetSetting(Set_advanced_options,settings.advanced_options); + SetSetting(Set_texenh_options,settings.texenh_options); - ini->Write(_T("card_id"), settings.card_id); - ini->Write(_T("resolution"), (int)settings.res_data); - ini->Write(_T("ssformat"), settings.ssformat); - ini->Write(_T("vsync"), settings.vsync); - ini->Write(_T("show_fps"), settings.show_fps); - ini->Write(_T("clock"), settings.clock); - ini->Write(_T("clock_24_hr"), settings.clock_24_hr); - ini->Write(_T("advanced_options"), settings.advanced_options); - ini->Write(_T("texenh_options"), settings.texenh_options); - - ini->Write(_T("wrpResolution"), settings.wrpResolution); - ini->Write(_T("wrpVRAM"), settings.wrpVRAM); - ini->Write(_T("wrpFBO"), settings.wrpFBO); - ini->Write(_T("wrpAnisotropic"), settings.wrpAnisotropic); + SetSetting(Set_wrpResolution,settings.wrpResolution); + SetSetting(Set_wrpVRAM,settings.wrpVRAM); + SetSetting(Set_wrpFBO,settings.wrpFBO); + SetSetting(Set_wrpAnisotropic,settings.wrpAnisotropic); #ifndef _ENDUSER_RELEASE_ - ini->Write(_T("autodetect_ucode"), settings.autodetect_ucode); - ini->Write(_T("ucode"), (int)settings.ucode); - ini->Write(_T("wireframe"), settings.wireframe); - ini->Write(_T("wfmode"), settings.wfmode); - ini->Write(_T("logging"), settings.logging); - ini->Write(_T("log_clear"), settings.log_clear); - ini->Write(_T("run_in_window"), settings.run_in_window); - ini->Write(_T("elogging"), settings.elogging); - ini->Write(_T("filter_cache"), settings.filter_cache); - ini->Write(_T("unk_as_red"), settings.unk_as_red); - ini->Write(_T("log_unk"), settings.log_unk); - ini->Write(_T("unk_clear"), settings.unk_clear); + SetSetting(Set_autodetect_ucode,settings.autodetect_ucode); + SetSetting(Set_ucode,(int)settings.ucode); + SetSetting(Set_wireframe,settings.wireframe); + SetSetting(Set_wfmode,settings.wfmode); + SetSetting(Set_logging,settings.logging); + SetSetting(Set_log_clear,settings.log_clear); + SetSetting(Set_run_in_window,settings.run_in_window); + SetSetting(Set_elogging,settings.elogging); + SetSetting(Set_filter_cache,settings.filter_cache); + SetSetting(Set_unk_as_red,settings.unk_as_red); + SetSetting(Set_log_unk,settings.log_unk); + SetSetting(Set_unk_clear,settings.unk_clear); #endif //_ENDUSER_RELEASE_ #ifdef TEXTURE_FILTER - ini->Write(_T("ghq_fltr"), settings.ghq_fltr); - ini->Write(_T("ghq_cmpr"), settings.ghq_cmpr); - ini->Write(_T("ghq_enht"), settings.ghq_enht); - ini->Write(_T("ghq_hirs"), settings.ghq_hirs); - ini->Write(_T("ghq_enht_cmpr"), settings.ghq_enht_cmpr); - ini->Write(_T("ghq_enht_tile"), settings.ghq_enht_tile); - ini->Write(_T("ghq_enht_f16bpp"), settings.ghq_enht_f16bpp); - ini->Write(_T("ghq_enht_gz"), settings.ghq_enht_gz); - ini->Write(_T("ghq_enht_nobg"), settings.ghq_enht_nobg); - ini->Write(_T("ghq_hirs_cmpr"), settings.ghq_hirs_cmpr); - ini->Write(_T("ghq_hirs_tile"), settings.ghq_hirs_tile); - ini->Write(_T("ghq_hirs_f16bpp"), settings.ghq_hirs_f16bpp); - ini->Write(_T("ghq_hirs_gz"), settings.ghq_hirs_gz); - ini->Write(_T("ghq_hirs_altcrc"), settings.ghq_hirs_altcrc); - ini->Write(_T("ghq_cache_save"), settings.ghq_cache_save); - ini->Write(_T("ghq_cache_size"), settings.ghq_cache_size); - ini->Write(_T("ghq_hirs_let_texartists_fly"), settings.ghq_hirs_let_texartists_fly); - ini->Write(_T("ghq_hirs_dump"), settings.ghq_hirs_dump); + SetSetting(Set_ghq_fltr,settings.ghq_fltr); + SetSetting(Set_ghq_cmpr,settings.ghq_cmpr); + SetSetting(Set_ghq_enht,settings.ghq_enht); + SetSetting(Set_ghq_hirs,settings.ghq_hirs); + SetSetting(Set_ghq_enht_cmpr,settings.ghq_enht_cmpr); + SetSetting(Set_ghq_enht_tile,settings.ghq_enht_tile); + SetSetting(Set_ghq_enht_f16bpp,settings.ghq_enht_f16bpp); + SetSetting(Set_ghq_enht_gz,settings.ghq_enht_gz); + SetSetting(Set_ghq_enht_nobg,settings.ghq_enht_nobg); + SetSetting(Set_ghq_hirs_cmpr,settings.ghq_hirs_cmpr); + SetSetting(Set_ghq_hirs_tile,settings.ghq_hirs_tile); + SetSetting(Set_ghq_hirs_f16bpp,settings.ghq_hirs_f16bpp); + SetSetting(Set_ghq_hirs_gz,settings.ghq_hirs_gz); + SetSetting(Set_ghq_hirs_altcrc,settings.ghq_hirs_altcrc); + SetSetting(Set_ghq_cache_save,settings.ghq_cache_save); + SetSetting(Set_ghq_cache_size,settings.ghq_cache_size); + SetSetting(Set_ghq_hirs_let_texartists_fly,settings.ghq_hirs_let_texartists_fly); + SetSetting(Set_ghq_hirs_dump,settings.ghq_hirs_dump); #endif if (saveEmulationSettings) { - if (romopen) - { - wxString S = _T("/"); - ini->SetPath(S+rdp.RomName); - } - else - ini->SetPath(_T("/DEFAULT")); - ini->Write(_T("filtering"), settings.filtering); - ini->Write(_T("fog"), settings.fog); - ini->Write(_T("buff_clear"), settings.buff_clear); - ini->Write(_T("swapmode"), settings.swapmode); - ini->Write(_T("lodmode"), settings.lodmode); - ini->Write(_T("aspect"), settings.aspectmode); + SetSetting(Set_filtering, settings.filtering); + SetSetting(Set_fog, settings.fog); + SetSetting(Set_buff_clear, settings.buff_clear); + SetSetting(Set_swapmode, settings.swapmode); + SetSetting(Set_lodmode, settings.lodmode); + SetSetting(Set_aspect, settings.aspectmode); - ini->Write(_T("fb_read_always"), settings.frame_buffer&fb_ref ? 1 : 0l); - ini->Write(_T("fb_smart"), settings.frame_buffer & fb_emulation ? 1 : 0l); - // ini->Write("motionblur", settings.frame_buffer & fb_motionblur ? 1 : 0); - ini->Write(_T("fb_hires"), settings.frame_buffer & fb_hwfbe ? 1 : 0l); - ini->Write(_T("fb_get_info"), settings.frame_buffer & fb_get_info ? 1 : 0l); - ini->Write(_T("fb_render"), settings.frame_buffer & fb_depth_render ? 1 : 0l); - ini->Write(_T("detect_cpu_write"), settings.frame_buffer & fb_cpu_write_hack ? 1 : 0l); + SetSetting(Set_fb_read_always, settings.frame_buffer&fb_ref ? 1 : 0l); + SetSetting(Set_fb_smart, settings.frame_buffer & fb_emulation ? 1 : 0l); + SetSetting(Set_fb_hires, settings.frame_buffer & fb_hwfbe ? 1 : 0l); + SetSetting(Set_fb_get_info, settings.frame_buffer & fb_get_info ? 1 : 0l); + SetSetting(Set_fb_render, settings.frame_buffer & fb_depth_render ? 1 : 0l); + SetSetting(Set_detect_cpu_write, settings.frame_buffer & fb_cpu_write_hack ? 1 : 0l); if (settings.frame_buffer & fb_read_back_to_screen) - ini->Write(_T("read_back_to_screen"), 1); + SetSetting(Set_read_back_to_screen, 1); else if (settings.frame_buffer & fb_read_back_to_screen2) - ini->Write(_T("read_back_to_screen"), 2); + SetSetting(Set_read_back_to_screen, 2); else - ini->Write(_T("read_back_to_screen"), 0l); + SetSetting(Set_read_back_to_screen, 0l); } - wxFileOutputStream os(iniName); - ((wxFileConfig*)ini)->Save(os); + FlushSettings(); } GRTEXBUFFEREXT grTextureBufferExt = NULL; @@ -1236,6 +1178,7 @@ class wxDLLApp : public wxApp { public: virtual bool OnInit(); + virtual void CleanUp(); }; IMPLEMENT_APP_NO_MAIN(wxDLLApp) @@ -1250,6 +1193,16 @@ bool wxDLLApp::OnInit() return true; } +void wxDLLApp::CleanUp() +{ + wxApp::CleanUp(); + if (mutexProcessDList) + { + delete mutexProcessDList; + mutexProcessDList = NULL; + } +} + #ifndef __WINDOWS__ int __attribute__ ((constructor)) DllLoad(void); int __attribute__ ((destructor)) DllUnload(void); @@ -1541,7 +1494,7 @@ output: none void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo ) { LOG ("GetDllInfo ()\n"); - PluginInfo->Version = 0x0103; // Set to 0x0103 + PluginInfo->Version = 0x0104; // Set to 0x0104 PluginInfo->Type = PLUGIN_TYPE_GFX; // Set to PLUGIN_TYPE_GFX #ifdef _DEBUG sprintf(PluginInfo->Name,"Glide64 For PJ64 (Debug): %s",VersionInfo(VERSION_PRODUCT_VERSION,hinstDLL).c_str()); @@ -1652,10 +1605,104 @@ output: none *******************************************************************/ void CALL MoveScreen (int xpos, int ypos) { + xpos = xpos; + ypos = ypos; LOG ("MoveScreen (" << xpos << ", " << ypos << ")\n"); rdp.window_changed = TRUE; } +void CALL PluginLoaded (void) +{ + SetModuleName("default"); + Set_basic_mode = FindSystemSettingId("Basic Mode"); + + SetModuleName("Glide64"); + RegisterSetting(Set_CardId, Data_DWORD_General,"card_id",NULL,0l,NULL); + RegisterSetting(Set_Resolution, Data_DWORD_General,"resolution",NULL,7,NULL); + RegisterSetting(Set_vsync, Data_DWORD_General,"vsync",NULL,0l,NULL); + RegisterSetting(Set_ssformat, Data_DWORD_General,"ssformat",NULL,0l,NULL); + RegisterSetting(Set_ShowFps, Data_DWORD_General,"show_fps",NULL,0l,NULL); + RegisterSetting(Set_clock, Data_DWORD_General,"clock",NULL,0l,NULL); + RegisterSetting(Set_clock_24_hr, Data_DWORD_General,"clock_24_hr",NULL,0l,NULL); + RegisterSetting(Set_texenh_options, Data_DWORD_General,"texenh_options",NULL,0l,NULL); + RegisterSetting(Set_hotkeys, Data_DWORD_General,"hotkeys",NULL,1l,NULL); + RegisterSetting(Set_wrpResolution, Data_DWORD_General,"wrpResolution",NULL,0l,NULL); + RegisterSetting(Set_wrpVRAM, Data_DWORD_General,"wrpVRAM",NULL,0l,NULL); + RegisterSetting(Set_wrpFBO, Data_DWORD_General,"wrpFBO",NULL,0l,NULL); + RegisterSetting(Set_wrpAnisotropic, Data_DWORD_General,"wrpAnisotropic",NULL,0l,NULL); + RegisterSetting(Set_autodetect_ucode, Data_DWORD_General,"autodetect_ucode",NULL, 1,NULL); + RegisterSetting(Set_ucode, Data_DWORD_General,"ucode",NULL, 2,NULL); + RegisterSetting(Set_wireframe, Data_DWORD_General,"wireframe",NULL, 0l,NULL); + RegisterSetting(Set_wfmode, Data_DWORD_General,"wfmode",NULL, 1,NULL); + RegisterSetting(Set_logging, Data_DWORD_General,"logging",NULL, 0l,NULL); + RegisterSetting(Set_log_clear, Data_DWORD_General,"log_clear",NULL, 0l,NULL); + RegisterSetting(Set_run_in_window, Data_DWORD_General,"run_in_window",NULL, 0l,NULL); + RegisterSetting(Set_elogging, Data_DWORD_General,"elogging",NULL, 0l,NULL); + RegisterSetting(Set_filter_cache, Data_DWORD_General,"filter_cache",NULL, 0l,NULL); + RegisterSetting(Set_unk_as_red, Data_DWORD_General,"unk_as_red",NULL, 0l,NULL); + RegisterSetting(Set_log_unk, Data_DWORD_General,"log_unk",NULL, 0l,NULL); + RegisterSetting(Set_unk_clear, Data_DWORD_General,"unk_clear",NULL, 0l,NULL); + RegisterSetting(Set_ghq_fltr, Data_DWORD_General,"ghq_fltr",NULL, 0l,NULL); + RegisterSetting(Set_ghq_cmpr, Data_DWORD_General,"ghq_cmpr",NULL, 0l,NULL); + RegisterSetting(Set_ghq_enht, Data_DWORD_General,"ghq_enht",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs, Data_DWORD_General,"ghq_hirs",NULL, 0l,NULL); + RegisterSetting(Set_ghq_enht_cmpr, Data_DWORD_General,"ghq_enht_cmpr",NULL, 0l,NULL); + RegisterSetting(Set_ghq_enht_tile, Data_DWORD_General,"ghq_enht_tile",NULL, 0l,NULL); + RegisterSetting(Set_ghq_enht_f16bpp, Data_DWORD_General,"ghq_enht_f16bpp",NULL, 0l,NULL); + RegisterSetting(Set_ghq_enht_gz, Data_DWORD_General,"ghq_enht_gz",NULL, 1L,NULL); + RegisterSetting(Set_ghq_enht_nobg, Data_DWORD_General,"ghq_enht_nobg",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs_cmpr, Data_DWORD_General,"ghq_hirs_cmpr",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs_tile, Data_DWORD_General,"ghq_hirs_tile",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs_f16bpp, Data_DWORD_General,"ghq_hirs_f16bpp",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs_gz, Data_DWORD_General,"ghq_hirs_gz",NULL, 1,NULL); + RegisterSetting(Set_ghq_hirs_altcrc, Data_DWORD_General,"ghq_hirs_altcrc",NULL, 1,NULL); + RegisterSetting(Set_ghq_cache_save, Data_DWORD_General,"ghq_cache_save",NULL, 1,NULL); + RegisterSetting(Set_ghq_cache_size, Data_DWORD_General,"ghq_cache_size",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs_let_texartists_fly, Data_DWORD_General,"ghq_hirs_let_texartists_fly",NULL, 0l,NULL); + RegisterSetting(Set_ghq_hirs_dump, Data_DWORD_General,"ghq_hirs_dump",NULL, 0l,NULL); + + RegisterSetting(Set_alt_tex_size,Data_DWORD_Game,"alt_tex_size",NULL,0l,NULL); + RegisterSetting(Set_use_sts1_only,Data_DWORD_Game,"use_sts1_only",NULL,0l,NULL); + RegisterSetting(Set_force_calc_sphere,Data_DWORD_Game,"force_calc_sphere",NULL,0l,NULL); + RegisterSetting(Set_correct_viewport,Data_DWORD_Game,"correct_viewport",NULL,0l,NULL); + RegisterSetting(Set_increase_texrect_edge,Data_DWORD_Game,"increase_texrect_edge",NULL,0,NULL); + RegisterSetting(Set_decrease_fillrect_edge,Data_DWORD_Game,"decrease_fillrect_edge",NULL,0l,NULL); + RegisterSetting(Set_texture_correction,Data_DWORD_Game,"texture_correction",NULL,1,NULL); + RegisterSetting(Set_pal230,Data_DWORD_Game,"pal230",NULL,0l,NULL); + RegisterSetting(Set_stipple_mode,Data_DWORD_Game,"stipple_mode",NULL,2,NULL); + + RegisterSetting(Set_stipple_pattern,Data_DWORD_Game,"stipple_pattern",NULL,1041204192,NULL); + RegisterSetting(Set_force_microcheck,Data_DWORD_Game,"force_microcheck",NULL,0l,NULL); + RegisterSetting(Set_force_quad3d,Data_DWORD_Game,"force_quad3d",NULL,0l,NULL); + RegisterSetting(Set_clip_zmin,Data_DWORD_Game,"clip_zmin",NULL,0l,NULL); + RegisterSetting(Set_clip_zmax,Data_DWORD_Game,"clip_zmax",NULL,1,NULL); + RegisterSetting(Set_fast_crc,Data_DWORD_Game,"fast_crc",NULL,1,NULL); + RegisterSetting(Set_adjust_aspect,Data_DWORD_Game,"adjust_aspect",NULL,1,NULL); + RegisterSetting(Set_zmode_compare_less,Data_DWORD_Game,"zmode_compare_less",NULL,0l,NULL); + RegisterSetting(Set_old_style_adither,Data_DWORD_Game,"old_style_adither",NULL,0l,NULL); + RegisterSetting(Set_n64_z_scale,Data_DWORD_Game,"n64_z_scale",NULL,0l,NULL); + RegisterSetting(Set_optimize_texrect,Data_DWORD_Game,"optimize_texrect",NULL,1,NULL); + RegisterSetting(Set_ignore_aux_copy,Data_DWORD_Game,"ignore_aux_copy",NULL,(unsigned int)-1,NULL); + RegisterSetting(Set_hires_buf_clear,Data_DWORD_Game,"hires_buf_clear",NULL,1,NULL); + RegisterSetting(Set_fb_read_alpha,Data_DWORD_Game,"fb_read_alpha",NULL,0l,NULL); + RegisterSetting(Set_useless_is_useless,Data_DWORD_Game,"useless_is_useless",NULL,(unsigned int)-1,NULL); + RegisterSetting(Set_fb_crc_mode,Data_DWORD_Game,"fb_crc_mode",NULL,1,NULL); + RegisterSetting(Set_filtering,Data_DWORD_Game,"filtering",NULL,0l,NULL); + RegisterSetting(Set_fog,Data_DWORD_Game,"fog",NULL,0l,NULL); + RegisterSetting(Set_buff_clear,Data_DWORD_Game,"buff_clear",NULL,1,NULL); + RegisterSetting(Set_swapmode,Data_DWORD_Game,"swapmode",NULL,1,NULL); + RegisterSetting(Set_aspect,Data_DWORD_Game,"aspect",NULL,0l,NULL); + RegisterSetting(Set_lodmode,Data_DWORD_Game,"lodmode",NULL,0l,NULL); + + RegisterSetting(Set_fb_smart,Data_DWORD_Game,"fb_smart",NULL,0l,NULL); + RegisterSetting(Set_fb_hires,Data_DWORD_Game,"fb_hires",NULL,1,NULL); + RegisterSetting(Set_fb_read_always,Data_DWORD_Game,"fb_read_always",NULL,0l,NULL); + RegisterSetting(Set_read_back_to_screen,Data_DWORD_Game,"read_back_to_screen",NULL,0l,NULL); + RegisterSetting(Set_detect_cpu_write,Data_DWORD_Game,"detect_cpu_write",NULL,0l,NULL); + RegisterSetting(Set_fb_get_info,Data_DWORD_Game,"fb_get_info",NULL,0l,NULL); + RegisterSetting(Set_fb_render,Data_DWORD_Game,"fb_render",NULL,0,NULL); +} + /****************************************************************** Function: RomClosed Purpose: This function is called when a rom is closed. diff --git a/Source/Glide64/rdp.cpp b/Source/Glide64/rdp.cpp index edb8d06e9..5b8812136 100644 --- a/Source/Glide64/rdp.cpp +++ b/Source/Glide64/rdp.cpp @@ -320,15 +320,14 @@ void microcheck () FRDP("ucode = %08lx\n", uc_crc); - wxConfigBase * ini = wxConfigBase::Get(false); - ini->SetPath(wxT("/UCODE")); wxString str; str.Printf(wxT("%08lx"), uc_crc); - int uc = ini->Read(str, -2); + RegisterSetting(Set_ucodeLookup,Data_DWORD_RDB_Setting,str,"ucode",(unsigned int)-2,NULL); + int uc = GetSetting(Set_ucodeLookup); if (uc == -2 && ucode_error_report) { - settings.ucode = ini->Read(_T("/SETTINGS/ucode"), 0l); + settings.ucode = GetSetting(Set_ucode); ReleaseGfx (); str.Printf(_T("Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx"), uc_crc); @@ -338,7 +337,7 @@ void microcheck () } else if (uc == -1 && ucode_error_report) { - settings.ucode = ini->Read(_T("/SETTINGS/ucode"), 0l); + settings.ucode = GetSetting(Set_ucode); ReleaseGfx (); str.Printf(_T("Error: Unsupported uCode!\n\ncrc: %08lx"), uc_crc); diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 453612bb4..e38c1cd66 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -83,11 +83,19 @@ void CAudioPlugin::Init ( const char * FileName ) if (RomClosed == NULL) { UnloadPlugin(); return; } if (ProcessAList == NULL) { UnloadPlugin(); return; } - SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); + SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); + if (SetSettingInfo3) + { + PLUGIN_SETTINGS3 info; + info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings; + SetSettingInfo3(&info); + } + + SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); if (SetSettingInfo2) { PLUGIN_SETTINGS2 info; - info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindGameSetting; + info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindSetting; SetSettingInfo2(&info); } diff --git a/Source/Project64/Plugins/Audio Plugin.h b/Source/Project64/Plugins/Audio Plugin.h index da01eb3be..dc8a4b4d1 100644 --- a/Source/Project64/Plugins/Audio Plugin.h +++ b/Source/Project64/Plugins/Audio Plugin.h @@ -48,6 +48,7 @@ private: void (__cdecl *PluginOpened) ( void ); void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info ); void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info ); + void (__cdecl *SetSettingInfo3) ( PLUGIN_SETTINGS3 * info ); //Function used in a thread for using audio static void AudioThread (CAudioPlugin * _this); diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 0990c53eb..c54f925ea 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -83,11 +83,19 @@ void CControl_Plugin::Init ( const char * FileName ) if (InitFunc == NULL) { UnloadPlugin(); return; } if (CloseDLL == NULL) { UnloadPlugin(); return; } - SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); + SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); + if (SetSettingInfo3) + { + PLUGIN_SETTINGS3 info; + info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings; + SetSettingInfo3(&info); + } + + SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); if (SetSettingInfo2) { PLUGIN_SETTINGS2 info; - info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindGameSetting; + info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindSetting; SetSettingInfo2(&info); } diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index d133ed8cd..8d71b89a4 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -115,6 +115,7 @@ private: void (__cdecl *PluginOpened) ( void ); void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info ); void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info ); + void (__cdecl *SetSettingInfo3) ( PLUGIN_SETTINGS3 * info ); CCONTROL * m_Controllers[4]; }; diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index 6be513197..03ec1e5d7 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -119,11 +119,19 @@ void CGfxPlugin::Init ( const char * FileName ) } - SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); + SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); + if (SetSettingInfo3) + { + PLUGIN_SETTINGS3 info; + info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings; + SetSettingInfo3(&info); + } + + SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); if (SetSettingInfo2) { PLUGIN_SETTINGS2 info; - info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindGameSetting; + info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindSetting; SetSettingInfo2(&info); } diff --git a/Source/Project64/Plugins/GFX plugin.h b/Source/Project64/Plugins/GFX plugin.h index c32e5e294..9f49b4e55 100644 --- a/Source/Project64/Plugins/GFX plugin.h +++ b/Source/Project64/Plugins/GFX plugin.h @@ -99,6 +99,7 @@ private: void (__cdecl *PluginOpened) ( void ); void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info ); void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info ); + void (__cdecl *SetSettingInfo3) ( PLUGIN_SETTINGS3 * info ); static void __cdecl DummyDrawScreen ( void ) {} static void __cdecl DummyMoveScreen ( int /*xpos*/, int /*ypos*/ ) {} diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index 28cc0297c..3c8bc3173 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -36,12 +36,14 @@ typedef struct { // enum's enum SETTING_DATA_TYPE { - Data_DWORD_General, // A unsigned int setting used anywhere - Data_String_General, // A string setting used anywhere - Data_DWORD_Game, // A unsigned int associated with the current game - Data_String_Game, // A string associated with the current game - Data_DWORD_RDB, // A unsigned int associated with the current game in the rom database - Data_String_RDB, // A string associated with the current game in the rom database + Data_DWORD_General = 0, // A unsigned int setting used anywhere + Data_String_General = 1, // A string setting used anywhere + Data_DWORD_Game = 2, // A unsigned int associated with the current game + Data_String_Game = 3, // A string associated with the current game + Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database + Data_String_RDB = 5, // A string associated with the current game in the rom database + Data_DWORD_RDB_Setting = 6, // A unsigned int read from the rom database, with config file + Data_String_RDB_Setting = 7, // A string read from the rom database, with config file }; typedef struct { @@ -65,6 +67,10 @@ typedef struct { unsigned int (*FindSystemSettingId) ( void * handle, const char * Name ); } PLUGIN_SETTINGS2; +typedef struct { + void (*FlushSettings) ( void * handle ); +} PLUGIN_SETTINGS3; + enum PLUGIN_TYPE { PLUGIN_TYPE_NONE = 0, PLUGIN_TYPE_RSP = 1, diff --git a/Source/Project64/Plugins/RSP Plugin.cpp b/Source/Project64/Plugins/RSP Plugin.cpp index cc8bdeb59..ba1228124 100644 --- a/Source/Project64/Plugins/RSP Plugin.cpp +++ b/Source/Project64/Plugins/RSP Plugin.cpp @@ -78,11 +78,19 @@ void CRSP_Plugin::Init ( const char * FileName ) if (RomClosed == NULL) { UnloadPlugin(); return; } if (CloseDLL == NULL) { UnloadPlugin(); return; } - SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); + SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); + if (SetSettingInfo3) + { + PLUGIN_SETTINGS3 info; + info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings; + SetSettingInfo3(&info); + } + + SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); if (SetSettingInfo2) { PLUGIN_SETTINGS2 info; - info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindGameSetting; + info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindSetting; SetSettingInfo2(&info); } diff --git a/Source/Project64/Plugins/RSP Plugin.h b/Source/Project64/Plugins/RSP Plugin.h index 813a9e87f..08e383708 100644 --- a/Source/Project64/Plugins/RSP Plugin.h +++ b/Source/Project64/Plugins/RSP Plugin.h @@ -87,4 +87,5 @@ private: void (__cdecl *PluginOpened) ( void ); void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info ); void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info ); + void (__cdecl *SetSettingInfo3) ( PLUGIN_SETTINGS3 * info ); }; diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index f3f62d362..1cc8d13ab 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -327,6 +327,10 @@ RelativePath="Settings\SettingType\SettingsType-RomDatabaseIndex.cpp" > + + @@ -1028,6 +1032,10 @@ RelativePath="Settings\SettingType\SettingsType-RomDatabaseIndex.h" > + + diff --git a/Source/Project64/Settings/SettingType/SettingsType-Base.h b/Source/Project64/Settings/SettingType/SettingsType-Base.h index 1ea95b21b..93385759c 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Base.h +++ b/Source/Project64/Settings/SettingType/SettingsType-Base.h @@ -25,6 +25,7 @@ enum SettingType { SettingType_NumberVariable = 10, SettingType_StringVariable = 11, SettingType_SelectedDirectory = 12, + SettingType_RdbSetting = 13, }; class CSettingType diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp new file mode 100644 index 000000000..6d49e7321 --- /dev/null +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "stdafx.h" +#include "SettingsType-RomDatabaseSetting.h" + +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, int DefaultValue, bool DeleteOnDefault ) : + CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault), + m_SectionIdent(SectionIdent) +{ + m_SectionIdent.Replace("\\","-"); +} + +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, bool DefaultValue, bool DeleteOnDefault ) : + CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault), + m_SectionIdent(SectionIdent) +{ + m_SectionIdent.Replace("\\","-"); +} + +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, LPCSTR DefaultValue, bool DeleteOnDefault ) : + CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault), + m_SectionIdent(SectionIdent) +{ + m_SectionIdent.Replace("\\","-"); +} + +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, SettingID DefaultSetting, bool DeleteOnDefault ) : + CSettingTypeRomDatabase(Name, DefaultSetting, DeleteOnDefault), + m_SectionIdent(SectionIdent) +{ + m_SectionIdent.Replace("\\","-"); +} + +CSettingTypeRomDatabaseSetting::~CSettingTypeRomDatabaseSetting() +{ +} + +bool CSettingTypeRomDatabaseSetting::Load ( int Index, bool & Value ) const +{ + g_Notify->BreakPoint(__FILE__,__LINE__); +/* DWORD temp_value = Value; + bool bRes = Load(Index,temp_value); + Value = temp_value != 0; + return bRes;*/ + return false; +} + +bool CSettingTypeRomDatabaseSetting::Load ( int Index, ULONG & Value ) const +{ + bool bRes = m_SettingsIniFile->GetNumber(m_SectionIdent.c_str(),m_KeyName.c_str(),Value,Value); + if (!bRes) + { + LoadDefault(Index,Value); + } + return bRes; +} + +bool CSettingTypeRomDatabaseSetting::Load ( int Index, stdstr & Value ) const +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*stdstr temp_value; + bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,temp_value); + if (bRes) + { + Value = temp_value; + } + else + { + LoadDefault(Index,Value); + } + return bRes;*/ + return false; +} + +//return the default values +void CSettingTypeRomDatabaseSetting::LoadDefault ( int /*Index*/, bool & Value ) const +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (m_DefaultSetting != Default_None) + { + if (m_DefaultSetting == Default_Constant) + { + Value = m_DefaultValue != 0; + } else { + g_Settings->LoadBool(m_DefaultSetting,Value); + } + }*/ +} + +void CSettingTypeRomDatabaseSetting::LoadDefault ( int /*Index*/, ULONG & Value ) const +{ + if (m_DefaultSetting == Default_None) { return; } + + if (m_DefaultSetting == Default_Constant) + { + Value = m_DefaultValue; + } else { + g_Settings->LoadDword(m_DefaultSetting,Value); + } +} + +void CSettingTypeRomDatabaseSetting::LoadDefault ( int /*Index*/, stdstr & Value ) const +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (m_DefaultSetting != Default_None) + { + if (m_DefaultSetting == Default_Constant) + { + Value = m_DefaultStr; + } else { + g_Settings->LoadString(m_DefaultSetting,Value); + } + }*/ +} + +//Update the settings +void CSettingTypeRomDatabaseSetting::Save ( int /*Index*/, bool Value ) +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (!g_Settings->LoadBool(Setting_RdbEditor)) + { + return; + } + if (m_DeleteOnDefault) + { + Notify().BreakPoint(__FILE__,__LINE__); + } + m_SettingsIniFile->SaveNumber(m_SectionIdent->c_str(),m_KeyName.c_str(),Value); + */ +} + +void CSettingTypeRomDatabaseSetting::Save ( int Index, ULONG Value ) +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (!g_Settings->LoadBool(Setting_RdbEditor)) + { + return; + } + if (m_DeleteOnDefault) + { + ULONG defaultValue = 0; + LoadDefault(Index,defaultValue); + if (defaultValue == Value) + { + Delete(Index); + return; + } + } + m_SettingsIniFile->SaveNumber(m_SectionIdent->c_str(),m_KeyName.c_str(),Value); + */ +} + +void CSettingTypeRomDatabaseSetting::Save ( int /*Index*/, const stdstr & Value ) +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (!g_Settings->LoadBool(Setting_RdbEditor)) + { + return; + } + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value.c_str()); + */ +} + +void CSettingTypeRomDatabaseSetting::Save ( int /*Index*/, const char * Value ) +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (!g_Settings->LoadBool(Setting_RdbEditor)) + { + return; + } + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value);*/ +} + +void CSettingTypeRomDatabaseSetting::Delete ( int /*Index*/ ) +{ + g_Notify->BreakPoint(__FILE__,__LINE__); + /*if (!g_Settings->LoadBool(Setting_RdbEditor)) + { + return; + } + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),NULL);*/ +} diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h new file mode 100644 index 000000000..d4f0c9499 --- /dev/null +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h @@ -0,0 +1,51 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once + +#include "SettingsType-RomDatabase.h" + +class CSettingTypeRomDatabaseSetting : + public CSettingTypeRomDatabase +{ +public: + CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, LPCSTR DefaultValue, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, bool DefaultValue, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, int DefaultValue, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, SettingID DefaultSetting, bool DeleteOnDefault = false ); + + virtual ~CSettingTypeRomDatabaseSetting(); + + virtual bool IndexBasedSetting ( void ) const { return false; } + virtual SettingType GetSettingType ( void ) const { return SettingType_RdbSetting; } + + //return the values + virtual bool Load ( int Index, bool & Value ) const; + virtual bool Load ( int Index, ULONG & Value ) const; + virtual bool Load ( int Index, stdstr & Value ) const; + + //return the default values + virtual void LoadDefault ( int Index, bool & Value ) const; + virtual void LoadDefault ( int Index, ULONG & Value ) const; + virtual void LoadDefault ( int Index, stdstr & Value ) const; + + //Update the settings + virtual void Save ( int Index, bool Value ); + virtual void Save ( int Index, ULONG Value ); + virtual void Save ( int Index, const stdstr & Value ); + virtual void Save ( int Index, const char * Value ); + + // Delete the setting + virtual void Delete ( int Index ); + +private: + stdstr m_SectionIdent; +}; + diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index ba6346a5b..17b64631e 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -18,6 +18,7 @@ #include "SettingType/SettingsType-GameSettingIndex.h" #include "SettingType/SettingsType-RelativePath.h" #include "SettingType/SettingsType-RomDatabase.h" +#include "SettingType/SettingsType-RomDatabaseSetting.h" #include "SettingType/SettingsType-RomDatabaseIndex.h" #include "SettingType/SettingsType-RDBCpuType.h" #include "SettingType/SettingsType-RDBRamSize.h" @@ -320,26 +321,39 @@ void CSettings::AddHowToHandleSetting () AddHandler(Cheat_RangeNotes, new CSettingTypeCheats("_RN")); } -DWORD CSettings::FindGameSetting ( CSettings * _this, char * Name ) +DWORD CSettings::FindSetting ( CSettings * _this, char * Name ) { for (SETTING_MAP::iterator iter = _this->m_SettingInfo.begin(); iter != _this->m_SettingInfo.end(); iter++) { CSettingType * Setting = iter->second; - if (Setting->GetSettingType() != SettingType_GameSetting) + if (Setting->GetSettingType() == SettingType_GameSetting) { - continue; + CSettingTypeGame * GameSetting = (CSettingTypeGame *)Setting; + if (_stricmp(GameSetting->GetKeyName(),Name) != 0) + { + continue; + } + return iter->first; } - - CSettingTypeGame * GameSetting = (CSettingTypeGame *)Setting; - if (_stricmp(GameSetting->GetKeyName(),Name) != 0) + if (Setting->GetSettingType() == SettingType_CfgFile) { - continue; + CSettingTypeApplication * CfgSetting = (CSettingTypeApplication *)Setting; + if (_stricmp(CfgSetting->GetKeyName(),Name) != 0) + { + continue; + } + return iter->first; } - return iter->first; } return 0; } +void CSettings::FlushSettings ( CSettings * /*_this*/ ) +{ + CSettingTypeCheats::FlushChanges(); + CSettingTypeApplication::Flush(); +} + DWORD CSettings::GetSetting ( CSettings * _this, SettingID Type ) { return _this->LoadDword(Type); @@ -463,6 +477,24 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def g_Notify->BreakPoint(__FILE__,__LINE__); } break; + case SettingType_RdbSetting: + switch (DataType) + { + case Data_DWORD: + if (DefaultID == Default_None) + { + _this->AddHandler(ID,new CSettingTypeRomDatabaseSetting(Category, DefaultStr,(int)Value,true)); + } else { + SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; + _this->m_NextAutoSettingId += 1; + _this->AddHandler(RdbSetting,new CSettingTypeRomDatabaseSetting(Category, DefaultStr,DefaultID,true)); + _this->AddHandler(ID,new CSettingTypeApplication(Category,DefaultStr,RdbSetting)); + } + break; + default: + g_Notify->BreakPoint(__FILE__,__LINE__); + } + break; default: g_Notify->BreakPoint(__FILE__,__LINE__); } diff --git a/Source/Project64/Settings/Settings Class.h b/Source/Project64/Settings/Settings Class.h index 73b52a64d..6f45e5797 100644 --- a/Source/Project64/Settings/Settings Class.h +++ b/Source/Project64/Settings/Settings Class.h @@ -111,7 +111,8 @@ public: static void RegisterSetting ( CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType, SettingType Type, const char * Category, const char * DefaultStr, DWORD Value ); - static DWORD FindGameSetting ( CSettings * _this, char * Name ); + static DWORD FindSetting ( CSettings * _this, char * Name ); + static void FlushSettings ( CSettings * _this ); private: void NotifyCallBacks ( SettingID Type ); diff --git a/Source/Settings/Settings.cpp b/Source/Settings/Settings.cpp index 8c7b2b141..d6c3855c5 100644 --- a/Source/Settings/Settings.cpp +++ b/Source/Settings/Settings.cpp @@ -3,8 +3,20 @@ #include "Settings.h" enum SettingLocation { - ConstString = 0, ConstValue = 1, LocalSettings = 2, InRegistry = 3, RelativePath = 4, TemporarySetting = 5, - RomSetting = 6, CheatSetting = 7, GameSetting = 8, + SettingType_ConstString = 0, + SettingType_ConstValue = 1, + SettingType_CfgFile = 2, + SettingType_Registry = 3, + SettingType_RelativePath = 4, + TemporarySetting = 5, + SettingType_RomDatabase = 6, + SettingType_CheatSetting = 7, + SettingType_GameSetting = 8, + SettingType_BoolVariable = 9, + SettingType_NumberVariable = 10, + SettingType_StringVariable = 11, + SettingType_SelectedDirectory = 12, + SettingType_RdbSetting = 13, }; enum SettingDataType { @@ -32,14 +44,20 @@ typedef struct { unsigned int (*FindSystemSettingId) ( void * handle, const char * Name ); } PLUGIN_SETTINGS2; +typedef struct { + void (*FlushSettings) ( void * handle ); +} PLUGIN_SETTINGS3; + static PLUGIN_SETTINGS g_PluginSettings; static PLUGIN_SETTINGS2 g_PluginSettings2; +static PLUGIN_SETTINGS3 g_PluginSettings3; static bool g_PluginInitilized = false; static char g_PluginSettingName[300]; extern "C" { __declspec(dllexport) void SetSettingInfo (PLUGIN_SETTINGS * info); __declspec(dllexport) void SetSettingInfo2 (PLUGIN_SETTINGS2 * info); +__declspec(dllexport) void SetSettingInfo3 (PLUGIN_SETTINGS3 * info); } @@ -52,7 +70,12 @@ __declspec(dllexport) void SetSettingInfo (PLUGIN_SETTINGS * info) __declspec(dllexport) void SetSettingInfo2 (PLUGIN_SETTINGS2 * info) { - g_PluginSettings2 = *info; + g_PluginSettings2 = *info; +} + +__declspec(dllexport) void SetSettingInfo3 (PLUGIN_SETTINGS3 * info) +{ + g_PluginSettings3 = *info; } BOOL SettingsInitilized ( void ) @@ -82,11 +105,15 @@ void RegisterSetting ( short SettingID, SETTING_DATA_TYPE Type, const char * { case Data_DWORD_Game: case Data_String_Game: - Location = GameSetting; + Location = SettingType_GameSetting; break; case Data_DWORD_RDB: case Data_String_RDB: - Location = RomSetting; + Location = SettingType_RomDatabase; + break; + case Data_DWORD_RDB_Setting: + case Data_String_RDB_Setting: + Location = SettingType_RdbSetting; break; } @@ -98,12 +125,13 @@ void RegisterSetting ( short SettingID, SETTING_DATA_TYPE Type, const char * break; case Data_DWORD_General: case Data_DWORD_RDB: + case Data_DWORD_RDB_Setting: if (DefaultDW != 0) { //create default DefaultID = SettingID + g_PluginSettings.DefaultStartRange; g_PluginSettings.RegisterSetting(g_PluginSettings.handle,DefaultID,g_PluginSettings.NoDefault, - Data_DWORD,ConstValue,g_PluginSettingName,"",DefaultDW); + Data_DWORD,SettingType_ConstValue,g_PluginSettingName,"",DefaultDW); } g_PluginSettings.RegisterSetting(g_PluginSettings.handle,SettingID + g_PluginSettings.SettingStartRange, @@ -112,12 +140,13 @@ void RegisterSetting ( short SettingID, SETTING_DATA_TYPE Type, const char * case Data_String_General: case Data_String_Game: case Data_String_RDB: + case Data_String_RDB_Setting: if (DefaultStr != NULL && strlen(DefaultStr) > 0) { //create default DefaultID = SettingID + g_PluginSettings.DefaultStartRange; g_PluginSettings.RegisterSetting(g_PluginSettings.handle,DefaultID,g_PluginSettings.NoDefault, - Data_String,ConstString,g_PluginSettingName,DefaultStr,0); + Data_String,SettingType_ConstString,g_PluginSettingName,DefaultStr,0); } g_PluginSettings.RegisterSetting(g_PluginSettings.handle,SettingID + g_PluginSettings.SettingStartRange, @@ -130,11 +159,18 @@ short FindSystemSettingId ( const char * Name ) { if (g_PluginSettings2.FindSystemSettingId && g_PluginSettings.handle) { - return g_PluginSettings2.FindSystemSettingId(g_PluginSettings.handle,Name); + return (short)g_PluginSettings2.FindSystemSettingId(g_PluginSettings.handle,Name); } return 0; } +void FlushSettings ( void ) +{ + if (g_PluginSettings3.FlushSettings && g_PluginSettings.handle) + { + g_PluginSettings3.FlushSettings(g_PluginSettings.handle); + } +} unsigned int GetSetting ( short SettingID ) { diff --git a/Source/Settings/Settings.h b/Source/Settings/Settings.h index 28a955430..62a32868c 100644 --- a/Source/Settings/Settings.h +++ b/Source/Settings/Settings.h @@ -1,3 +1,5 @@ +#pragma once + #if defined(__cplusplus) extern "C" { #endif @@ -16,12 +18,14 @@ void SetSettingSz ( short SettingID, const char * Value ); // enum's enum SETTING_DATA_TYPE { - Data_DWORD_General = 0, // A unsigned int setting used anywhere - Data_String_General = 1, // A string setting used anywhere - Data_DWORD_Game = 2, // A unsigned int associated with the current game - Data_String_Game = 3, // A string associated with the current game - Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database - Data_String_RDB = 5, // A string associated with the current game in the rom database + Data_DWORD_General = 0, // A unsigned int setting used anywhere + Data_String_General = 1, // A string setting used anywhere + Data_DWORD_Game = 2, // A unsigned int associated with the current game + Data_String_Game = 3, // A string associated with the current game + Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database + Data_String_RDB = 5, // A string associated with the current game in the rom database + Data_DWORD_RDB_Setting = 6, // A unsigned int read from the rom database, with config file + Data_String_RDB_Setting = 7, // A string read from the rom database, with config file }; @@ -31,6 +35,7 @@ void SetModuleName ( const char * Name ); void RegisterSetting ( short SettingID, SETTING_DATA_TYPE Type, const char * Name, const char * Category, unsigned int DefaultDW, const char * DefaultStr ); short FindSystemSettingId ( const char * Name ); +void FlushSettings ( void ); // this must be implemented to be notified when a setting is used but has not been set up void UseUnregisteredSetting (int SettingID);