/[pcsx2_0.9.7]/trunk/plugins/spu2-x/src/Linux/ConfigDebug.cpp
ViewVC logotype

Contents of /trunk/plugins/spu2-x/src/Linux/ConfigDebug.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 290 - (show annotations) (download)
Sat Dec 25 02:51:30 2010 UTC (9 years ago) by william
File size: 11411 byte(s)
Auto Commited Import of: pcsx2-0.9.7-DEBUG (upstream: v0.9.7.4139 local: v0.9.7.283-latest) in ./trunk
1 /* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
2 * Developed and maintained by the Pcsx2 Development Team.
3 *
4 * Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
5 *
6 * SPU2-X is free software: you can redistribute it and/or modify it under the terms
7 * of the GNU Lesser General Public License as published by the Free Software Found-
8 * ation, either version 3 of the License, or (at your option) any later version.
9 *
10 * SPU2-X is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with SPU2-X. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "Global.h"
19 #include "Dialogs.h"
20 #include "Config.h"
21 #include "Utilities/Path.h"
22
23 bool DebugEnabled=false;
24 bool _MsgToConsole=false;
25 bool _MsgKeyOnOff=false;
26 bool _MsgVoiceOff=false;
27 bool _MsgDMA=false;
28 bool _MsgAutoDMA=false;
29 bool _MsgOverruns=false;
30 bool _MsgCache=false;
31
32 bool _AccessLog=false;
33 bool _DMALog=false;
34 bool _WaveLog=false;
35
36 bool _CoresDump=false;
37 bool _MemDump=false;
38 bool _RegDump=false;
39
40 // this is set true if PCSX2 invokes the SetLogDir callback, which tells SPU2-X to use that over
41 // the configured crap in the ini file.
42 static bool LogLocationSetByPcsx2 = false;
43
44 static wxDirName LogsFolder;
45 static wxDirName DumpsFolder;
46
47 wxString AccessLogFileName;
48 wxString WaveLogFileName;
49 wxString DMA4LogFileName;
50 wxString DMA7LogFileName;
51
52 wxString CoresDumpFileName;
53 wxString MemDumpFileName;
54 wxString RegDumpFileName;
55
56 void CfgSetLogDir( const char* dir )
57 {
58 LogsFolder = (dir==NULL) ? wxString(L"logs") : fromUTF8(dir);
59 DumpsFolder = (dir==NULL) ? wxString(L"logs") : fromUTF8(dir);
60 LogLocationSetByPcsx2 = (dir!=NULL);
61 }
62
63 FILE* OpenBinaryLog( const wxString& logfile )
64 {
65 return wxFopen( Path::Combine(LogsFolder, logfile), L"wb" );
66 }
67
68 FILE* OpenLog( const wxString& logfile )
69 {
70 return wxFopen( Path::Combine(LogsFolder, logfile), L"w" );
71 }
72
73 FILE* OpenDump( const wxString& logfile )
74 {
75 return wxFopen( Path::Combine(DumpsFolder, logfile), L"w" );
76 }
77
78 namespace DebugConfig {
79 static const wchar_t* Section = L"DEBUG";
80
81 static void set_default_filenames()
82 {
83 AccessLogFileName = L"SPU2Log.txt";
84 WaveLogFileName = L"SPU2log.wav";
85 DMA4LogFileName = L"SPU2dma4.dat";
86 DMA7LogFileName = L"SPU2dma7.dat";
87
88 CoresDumpFileName = L"SPU2Cores.txt";
89 MemDumpFileName = L"SPU2mem.dat";
90 RegDumpFileName = L"SPU2regs.dat";
91 }
92
93 void ReadSettings()
94 {
95 DebugEnabled = CfgReadBool(Section, L"Global_Enable",0);
96 _MsgToConsole= CfgReadBool(Section, L"Show_Messages",0);
97 _MsgKeyOnOff = CfgReadBool(Section, L"Show_Messages_Key_On_Off",0);
98 _MsgVoiceOff = CfgReadBool(Section, L"Show_Messages_Voice_Off",0);
99 _MsgDMA = CfgReadBool(Section, L"Show_Messages_DMA_Transfer",0);
100 _MsgAutoDMA = CfgReadBool(Section, L"Show_Messages_AutoDMA",0);
101 _MsgOverruns = CfgReadBool(Section, L"Show_Messages_Overruns",0);
102 _MsgCache = CfgReadBool(Section, L"Show_Messages_CacheStats",0);
103
104 _AccessLog = CfgReadBool(Section, L"Log_Register_Access",0);
105 _DMALog = CfgReadBool(Section, L"Log_DMA_Transfers",0);
106 _WaveLog = CfgReadBool(Section, L"Log_WAVE_Output",0);
107
108 _CoresDump = CfgReadBool(Section, L"Dump_Info",0);
109 _MemDump = CfgReadBool(Section, L"Dump_Memory",0);
110 _RegDump = CfgReadBool(Section, L"Dump_Regs",0);
111
112 set_default_filenames();
113
114 CfgReadStr(Section,L"Access_Log_Filename",AccessLogFileName, L"logs/SPU2Log.txt");
115 CfgReadStr(Section,L"WaveLog_Filename", WaveLogFileName, L"logs/SPU2log.wav");
116 CfgReadStr(Section,L"DMA4Log_Filename", DMA4LogFileName, L"logs/SPU2dma4.dat");
117 CfgReadStr(Section,L"DMA7Log_Filename", DMA7LogFileName, L"logs/SPU2dma7.dat");
118
119 CfgReadStr(Section,L"Info_Dump_Filename",CoresDumpFileName, L"logs/SPU2Cores.txt");
120 CfgReadStr(Section,L"Mem_Dump_Filename", MemDumpFileName, L"logs/SPU2mem.dat");
121 CfgReadStr(Section,L"Reg_Dump_Filename", RegDumpFileName, L"logs/SPU2regs.dat");
122 }
123
124
125 void WriteSettings()
126 {
127 CfgWriteBool(Section,L"Global_Enable",DebugEnabled);
128
129 CfgWriteBool(Section,L"Show_Messages", _MsgToConsole);
130 CfgWriteBool(Section,L"Show_Messages_Key_On_Off", _MsgKeyOnOff);
131 CfgWriteBool(Section,L"Show_Messages_Voice_Off", _MsgVoiceOff);
132 CfgWriteBool(Section,L"Show_Messages_DMA_Transfer",_MsgDMA);
133 CfgWriteBool(Section,L"Show_Messages_AutoDMA", _MsgAutoDMA);
134 CfgWriteBool(Section,L"Show_Messages_Overruns", _MsgOverruns);
135 CfgWriteBool(Section,L"Show_Messages_CacheStats", _MsgCache);
136
137 CfgWriteBool(Section,L"Log_Register_Access",_AccessLog);
138 CfgWriteBool(Section,L"Log_DMA_Transfers", _DMALog);
139 CfgWriteBool(Section,L"Log_WAVE_Output", _WaveLog);
140
141 CfgWriteBool(Section,L"Dump_Info", _CoresDump);
142 CfgWriteBool(Section,L"Dump_Memory",_MemDump);
143 CfgWriteBool(Section,L"Dump_Regs", _RegDump);
144
145 set_default_filenames();
146 CfgWriteStr(Section,L"Access_Log_Filename",AccessLogFileName);
147 CfgWriteStr(Section,L"WaveLog_Filename", WaveLogFileName);
148 CfgWriteStr(Section,L"DMA4Log_Filename", DMA4LogFileName);
149 CfgWriteStr(Section,L"DMA7Log_Filename", DMA7LogFileName);
150
151 CfgWriteStr(Section,L"Info_Dump_Filename",CoresDumpFileName);
152 CfgWriteStr(Section,L"Mem_Dump_Filename", MemDumpFileName);
153 CfgWriteStr(Section,L"Reg_Dump_Filename", RegDumpFileName);
154
155 }
156
157 void DisplayDialog()
158 {
159 GtkWidget *dialog;
160 int return_value;
161
162 GtkWidget *msg_box, *log_box, *dump_box, *main_box;
163 GtkWidget *msg_frame, *log_frame, *dump_frame, *main_frame;
164
165 GtkWidget *msg_console_check, *msg_key_check, *msg_voice_check, *msg_dma_check;
166 GtkWidget *msg_autodma_check, *msg_overrun_check, *msg_cache_check;
167
168 GtkWidget *log_access_check, *log_dma_check, *log_wave_check;
169 GtkWidget *dump_core_check, *dump_mem_check, *dump_reg_check;
170
171 ReadSettings();
172
173 // Create the widgets
174 dialog = gtk_dialog_new_with_buttons (
175 "Spu2-X Config",
176 NULL, // parent window
177 (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
178 GTK_STOCK_OK,
179 GTK_RESPONSE_ACCEPT,
180 GTK_STOCK_CANCEL,
181 GTK_RESPONSE_REJECT,
182 NULL);
183
184 main_box = gtk_hbox_new(false, 5);
185 main_frame = gtk_frame_new ("Spu2-X Config");
186 gtk_container_add (GTK_CONTAINER(main_frame), main_box);
187
188 // Message Section
189
190 msg_box = gtk_vbox_new(false, 5);
191
192 msg_console_check = gtk_check_button_new_with_label("Show In Console");
193 msg_key_check = gtk_check_button_new_with_label("KeyOn/Off Events");
194 msg_voice_check = gtk_check_button_new_with_label("Voice Stop Events");
195 msg_dma_check = gtk_check_button_new_with_label("DMA Operations");
196 msg_autodma_check = gtk_check_button_new_with_label("AutoDMA Operations");
197 msg_overrun_check = gtk_check_button_new_with_label("Buffer Over/Underruns");
198 msg_cache_check = gtk_check_button_new_with_label("ADPCM Cache Statistics");
199
200 gtk_container_add(GTK_CONTAINER(msg_box), msg_console_check);
201 gtk_container_add(GTK_CONTAINER(msg_box), msg_key_check);
202 gtk_container_add(GTK_CONTAINER(msg_box), msg_voice_check);
203 gtk_container_add(GTK_CONTAINER(msg_box), msg_dma_check);
204 gtk_container_add(GTK_CONTAINER(msg_box), msg_autodma_check);
205 gtk_container_add(GTK_CONTAINER(msg_box), msg_overrun_check);
206 gtk_container_add(GTK_CONTAINER(msg_box), msg_cache_check);
207
208 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_console_check), _MsgToConsole);
209 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_key_check), _MsgKeyOnOff);
210 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_voice_check), _MsgVoiceOff);
211 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_dma_check), _MsgDMA);
212 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_autodma_check), _MsgAutoDMA);
213 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_overrun_check), _MsgOverruns);
214 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_cache_check), _MsgCache);
215
216 msg_frame = gtk_frame_new ("Message/Log Options");
217 gtk_container_add (GTK_CONTAINER(msg_frame), msg_box);
218
219 // Log Section
220 log_box = gtk_vbox_new(false, 5);
221
222 log_access_check = gtk_check_button_new_with_label("Log Register/DMA Actions");
223 log_dma_check = gtk_check_button_new_with_label("Log DMA Writes");
224 log_wave_check = gtk_check_button_new_with_label("Log Audio Output");
225
226 gtk_container_add(GTK_CONTAINER(log_box), log_access_check);
227 gtk_container_add(GTK_CONTAINER(log_box), log_dma_check);
228 gtk_container_add(GTK_CONTAINER(log_box), log_wave_check);
229
230 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_access_check), _AccessLog);
231 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_dma_check), _DMALog);
232 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_wave_check), _WaveLog);
233
234 log_frame = gtk_frame_new ("Log Options");
235 gtk_container_add (GTK_CONTAINER(log_frame), log_box);
236
237 // Dump Section
238 dump_box = gtk_vbox_new(false, 5);
239
240 dump_core_check = gtk_check_button_new_with_label("Dump Core and Voice State");
241 dump_mem_check = gtk_check_button_new_with_label("Dump Memory Contents");
242 dump_reg_check = gtk_check_button_new_with_label("Dump Register Data");
243
244 gtk_container_add(GTK_CONTAINER(dump_box), dump_core_check);
245 gtk_container_add(GTK_CONTAINER(dump_box), dump_mem_check);
246 gtk_container_add(GTK_CONTAINER(dump_box), dump_reg_check);
247
248 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_core_check), _CoresDump);
249 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_mem_check), _MemDump);
250 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_reg_check), _RegDump);
251
252 dump_frame = gtk_frame_new ("Dumps (on close)");
253 gtk_container_add (GTK_CONTAINER(dump_frame), dump_box);
254
255 // Add everything
256
257 gtk_container_add (GTK_CONTAINER(main_box), msg_frame);
258 gtk_container_add (GTK_CONTAINER(main_box), log_frame);
259 gtk_container_add (GTK_CONTAINER(main_box), dump_frame);
260
261 // Add all our widgets, and show everything we've added to the dialog.
262 gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame);
263 gtk_widget_show_all (dialog);
264
265 return_value = gtk_dialog_run (GTK_DIALOG (dialog));
266
267 if (return_value == GTK_RESPONSE_ACCEPT)
268 {
269 _MsgToConsole = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_console_check));
270 _MsgKeyOnOff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_key_check));
271 _MsgVoiceOff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_voice_check));
272 _MsgDMA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_dma_check));
273 _MsgAutoDMA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_autodma_check));
274 _MsgOverruns = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_overrun_check));
275 _MsgCache = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_cache_check));
276
277 _AccessLog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_access_check));
278 _DMALog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_dma_check));
279 _WaveLog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_wave_check));
280
281 _CoresDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_core_check));
282 _MemDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_mem_check));
283 _RegDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_reg_check));
284 }
285
286 gtk_widget_destroy (dialog);
287
288 WriteSettings();
289 }
290
291 }

  ViewVC Help
Powered by ViewVC 1.1.22