From 0ccd832efef72b8dbf0994002ea53f5cd5a21058 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 25 Apr 2010 07:21:29 +0000 Subject: [PATCH] zzogl-pg: Start reworking the way logging works. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2899 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zzogl-pg/opengl/GSmain.cpp | 174 +++++++++++++++--- plugins/zzogl-pg/opengl/GifTransfer.cpp | 2 +- plugins/zzogl-pg/opengl/Linux/Conf.cpp | 7 + plugins/zzogl-pg/opengl/Linux/Linux.cpp | 7 +- .../opengl/Linux/zzogl-pg/zzogl-pg.cbp | 20 +- plugins/zzogl-pg/opengl/Util.h | 58 +++--- plugins/zzogl-pg/opengl/Win32/Win32.cpp | 5 +- plugins/zzogl-pg/opengl/ZZoglCRTC.cpp | 32 ++-- plugins/zzogl-pg/opengl/ZZoglCreate.cpp | 39 ++-- plugins/zzogl-pg/opengl/targets.cpp | 2 +- plugins/zzogl-pg/opengl/targets.h | 3 +- plugins/zzogl-pg/opengl/zerogs.cpp | 10 +- 12 files changed, 266 insertions(+), 93 deletions(-) diff --git a/plugins/zzogl-pg/opengl/GSmain.cpp b/plugins/zzogl-pg/opengl/GSmain.cpp index f1f6900d94..120843f1e0 100644 --- a/plugins/zzogl-pg/opengl/GSmain.cpp +++ b/plugins/zzogl-pg/opengl/GSmain.cpp @@ -134,35 +134,165 @@ bool THR_bShift = false; #endif -void __Log(const char *fmt, ...) +namespace ZZLog { - va_list list; + bool IsLogging() + { + // gsLog can be null if the config dialog is used prior to Pcsx2 starting an emulation session. + // (GSinit won't have been called then) + return (gsLog != NULL && conf.log); + } + void _Message(const char *str) + { + SysMessage(str); + } - // gsLog can be null if the config dialog is used prior to Pcsx2 an emulation session. - // (GSinit won't have been called then) + void _Log(const char *str) + { + if (IsLogging()) fprintf(gsLog, str); + } - if (gsLog == NULL || !conf.log) return; + void _WriteToConsole(const char *str) + { + printf("ZZogl-PG: %s", str); + } - va_start(list, fmt); - vfprintf(gsLog, fmt, list); - va_end(list); -} + void _Print(const char *str) + { + printf("ZZogl-PG: %s", str); + if (IsLogging()) fprintf(gsLog, str); + } + + void Message(const char *fmt, ...) + { + va_list list; + char tmp[512]; -void __LogToConsole(const char *fmt, ...) { - va_list list; + va_start(list, fmt); + vsprintf(tmp, fmt, list); + va_end(list); + + SysMessage(tmp); + } - va_start(list, fmt); + void Log(const char *fmt, ...) + { + va_list list; - // gsLog can be null if the config dialog is used prior to Pcsx2 an emulation session. - // (GSinit won't have been called then) + va_start(list, fmt); + if (IsLogging()) vfprintf(gsLog, fmt, list); + va_end(list); + } - if( gsLog != NULL ) - vfprintf(gsLog, fmt, list); + void WriteToConsole(const char *fmt, ...) + { + va_list list; - printf("ZZogl: "); - vprintf(fmt, list); - va_end(list); -} + va_start(list, fmt); + + printf("ZZogl-PG: "); + vprintf(fmt, list); + va_end(list); + } + + void Print(const char *fmt, ...) + { + va_list list; + + va_start(list, fmt); + if (IsLogging()) vfprintf(gsLog, fmt, list); + printf("ZZogl-PG: "); + vprintf(fmt, list); + va_end(list); + } + + void Greg_Log(const char *fmt, ...) + { + // Not currently used +#if 0 + va_list list; + char tmp[512]; + + va_start(list, fmt); + if (IsLogging()) vfprintf(gsLog, fmt, list); + va_end(list); +#endif + } + + void Prim_Log(const char *fmt, ...) + { +#if ZEROGS_DEVBUILD + va_list list; + char tmp[512]; + + va_start(list, fmt); + + if (conf.log /*& 0x00000010*/) + { + if (IsLogging()) vfprintf(gsLog, fmt, list); + + printf("ZZogl-PG(PRIM): "); + vprintf(fmt, list); + } + va_end(list); + +#endif + } + + void GS_Log(const char *fmt, ...) + { +#if ZEROGS_DEVBUILD + va_list list; + + va_start(list,fmt); + + if (IsLogging()) vfprintf(gsLog, fmt, list); + printf("ZZogl-PG(GS): "); + vprintf(fmt,list); + va_end(list); +#endif + } + + void Warn_Log(const char *fmt, ...) + { +#if ZEROGS_DEVBUILD + va_list list; + + va_start(list,fmt); + if (IsLogging()) vfprintf(gsLog, fmt, list); + printf("ZZogl-PG(Warning): "); + vprintf(fmt, list); + va_end(list); +#endif + } + + void Debug_Log(const char *fmt, ...) + { +#if _DEBUG + va_list list; + + va_start(list,fmt); + if (IsLogging()) vfprintf(gsLog, fmt, list); + printf("ZZogl-PG(Debug): "); + vprintf(fmt, list); + va_end(list); + + +#endif + } + + void Error_Log(const char *fmt, ...) + { + va_list list; + + va_start(list,fmt); + + if (IsLogging()) vfprintf(gsLog, fmt, list); + printf("ZZogl-PG(Error): "); + vprintf(fmt,list); + va_end(list); + } +}; void CALLBACK GSsetBaseMem(void* pmem) { g_pBasePS2Mem = (u8*)pmem; @@ -688,7 +818,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) GLWin.CreateWindow(pDsp); ERROR_LOG("Using %s:%d.%d.%d\n", libraryName, zgsrevision, zgsbuild, zgsminor); - ERROR_LOG("creating zerogs\n"); + ERROR_LOG("Creating zerogs\n"); //if (conf.record) recOpen(); if (!ZeroGS::Create(conf.width, conf.height)) return -1; @@ -834,7 +964,7 @@ void CALLBACK GSvsync(int interlace) { FUNCLOG - GS_LOG("\nGSvsync\n\n"); + //GS_LOG("GSvsync\n"); static u32 dwTime = timeGetTime(); static int nToNextUpdate = 1; diff --git a/plugins/zzogl-pg/opengl/GifTransfer.cpp b/plugins/zzogl-pg/opengl/GifTransfer.cpp index 070ebfbbcc..4c9feb8fae 100644 --- a/plugins/zzogl-pg/opengl/GifTransfer.cpp +++ b/plugins/zzogl-pg/opengl/GifTransfer.cpp @@ -74,7 +74,7 @@ extern HANDLE g_hCurrentThread; __forceinline void gifTransferLog(int index, u32 *pMem, u32 size) { #ifdef _DEBUG - if( conf.log & 0x20 ) + if( conf.log /*& 0x20*/ ) { static int nSaveIndex = 0; GS_LOG("%d: p:%d %x\n", nSaveIndex++, index + 1, size); diff --git a/plugins/zzogl-pg/opengl/Linux/Conf.cpp b/plugins/zzogl-pg/opengl/Linux/Conf.cpp index c7de8d878b..6a8b037f69 100644 --- a/plugins/zzogl-pg/opengl/Linux/Conf.cpp +++ b/plugins/zzogl-pg/opengl/Linux/Conf.cpp @@ -41,6 +41,9 @@ void SaveConfig() fprintf(f, "bilinear = %hhx\n", conf.bilinear); fprintf(f, "aliasing = %hhx\n", conf.aa); fprintf(f, "gamesettings = %x\n", conf.gamesettings); //u32 + fprintf(f, "width = %x\n", conf.width); //u32 + fprintf(f, "height = %x\n", conf.height); //u32 + fprintf(f, "log = %x\n", conf.log); //u32 fclose(f); } @@ -55,6 +58,7 @@ void LoadConfig() conf.width = 640; conf.height = 480; conf.aa = 0; + conf.log = 1; const std::string iniFile( s_strIniPath + "zzogl-pg.ini" ); FILE* f = fopen(iniFile.c_str(), "r"); @@ -70,6 +74,9 @@ void LoadConfig() err = fscanf(f, "bilinear = %hhx\n", &conf.bilinear); err = fscanf(f, "aliasing = %hhx\n", &conf.aa); err = fscanf(f, "gamesettings = %x\n", &conf.gamesettings);//u32 + err = fscanf(f, "width = %x\n", &conf.width);//u32 + err = fscanf(f, "height = %x\n", &conf.height);//u32 + err = fscanf(f, "log = %x\n", &conf.log);//u32 fclose(f); // filter bad files diff --git a/plugins/zzogl-pg/opengl/Linux/Linux.cpp b/plugins/zzogl-pg/opengl/Linux/Linux.cpp index 7663f28156..32a6bec8db 100644 --- a/plugins/zzogl-pg/opengl/Linux/Linux.cpp +++ b/plugins/zzogl-pg/opengl/Linux/Linux.cpp @@ -199,6 +199,7 @@ void DisplayDialog() GtkWidget *main_frame, *main_box; GtkWidget *option_frame, *option_box; + GtkWidget *log_check; GtkWidget *int_label, *int_box; GtkWidget *bilinear_check, *bilinear_label; GtkWidget *aa_label, *aa_box; @@ -224,6 +225,7 @@ void DisplayDialog() GTK_RESPONSE_ACCEPT, NULL); + log_check = gtk_check_button_new_with_label("Logging (For Debugging):"); int_label = gtk_label_new ("Interlacing: (F5 to toggle)"); int_box = gtk_combo_box_new_text (); gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "No Interlacing"); @@ -281,6 +283,7 @@ void DisplayDialog() advanced_scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(advanced_scroll), tree); + gtk_box_pack_start(GTK_BOX(option_box), log_check, false, false, 2); gtk_box_pack_start(GTK_BOX(option_box), int_label, false, false, 2); gtk_box_pack_start(GTK_BOX(option_box), int_box, false, false, 2); gtk_box_pack_start(GTK_BOX(option_box), bilinear_check, false, false, 2); @@ -301,6 +304,7 @@ void DisplayDialog() gtk_box_pack_start(GTK_BOX(main_box), option_frame, false, false, 2); gtk_box_pack_start(GTK_BOX(main_box), advanced_frame, true, true, 2); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_check), conf.log); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bilinear_check), conf.bilinear); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wireframe_check), (conf.options & GSOPTION_WIREFRAME)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(avi_check), (conf.options & GSOPTION_CAPTUREAVI)); @@ -316,7 +320,7 @@ void DisplayDialog() { int fake_options = 0; SaveGameHackTable(tree); - + if (gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)) != -1) conf.interlace = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)); @@ -333,6 +337,7 @@ void DisplayDialog() case 3: fake_options |= GSOPTION_WIN1280; break; } + conf.log = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_check)); conf.bilinear = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bilinear_check)); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wireframe_check))) diff --git a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp index f68a2f5e6d..808c636d02 100644 --- a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp +++ b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp @@ -7,7 +7,7 @@