From 7415b0cc4d4b1c3587cf785c9b65080bbc3586f8 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 23 Feb 2023 05:18:39 +0100 Subject: [PATCH 1/2] Make debug helper dumpmsg work like printf --- SOUND.CPP | 8 ++---- Sysstuff.h | 2 +- main.cpp | 83 ++++++++++++++++++------------------------------------ video.h | 15 ++++------ 4 files changed, 35 insertions(+), 73 deletions(-) diff --git a/SOUND.CPP b/SOUND.CPP index a2360f4..72ace53 100644 --- a/SOUND.CPP +++ b/SOUND.CPP @@ -265,9 +265,7 @@ void RenderDots(unsigned char *VS1) vol = (high - low) / 256.0; - //char buf[64]; - //sprintf(buf, "%f", vol); - //dumpmsg(buf); + //dumpmsg("%f", vol); // saver: low & high are around 10000-20000 (pos. or neg.) // vol is around 80-120 @@ -401,9 +399,7 @@ void RenderWave(unsigned char *VS1) int fact = 2;//(FXW==320) ? 1 : 2; int base = 150; - //char buf[64]; - //sprintf(buf, "%f", current_vol); - //dumpmsg(buf); + //dumpmsg("%f", current_vol); base = (current_vol*4 + avg_vol * 0.4) - 10; //base = (current_vol*4.5 + avg_vol * 0.45) - 10; diff --git a/Sysstuff.h b/Sysstuff.h index 1f44420..12f02dc 100644 --- a/Sysstuff.h +++ b/Sysstuff.h @@ -431,7 +431,7 @@ void ReadConfigRegistry() // DAMMIT! This was screening out the 320x200's because of the 200 part // in v3.21. Big bug. Damn! Fixed now. if (ScrMode==smSaver && (FXW<320 || (FXW%4) != 0 || FXH<200 || (FXH%4) != 0 || (iDispBits%8) != 0)) - dumpmsg("invalid reg params: width<320, height<200, or iDispBits%8 or FXW%4 or FXH%4 nonzero.");// { ScrMode = smConfig; g_bFirstRun = true; } + dumpmsg("invalid reg params: width<320, height<200, or iDispBits%%8 or FXW%%4 or FXH%%4 nonzero.");// { ScrMode = smConfig; g_bFirstRun = true; } OnFxwFxhUpdated(); diff --git a/main.cpp b/main.cpp index ca01978..7c8e9b3 100644 --- a/main.cpp +++ b/main.cpp @@ -501,6 +501,7 @@ saving favorite combinations (10 or so) #pragma hdrstop #include "resource.h" #include // for sprintf() for fps display +#include #if SAVER #include // for mci/cd stuff #endif @@ -1208,7 +1209,7 @@ void GetWindowsPath(); // sets winpath void ReadConfigRegistry(); void WriteConfigRegistry(); bool Try_To_Recover(); -void dumpmsg(char *s); +void dumpmsg(const char *format, ...); #include "effects.h" @@ -1947,7 +1948,7 @@ void __cdecl GeissProc( void *p ) case DDERR_UNSUPPORTED: dumpmsg(" [DDERR_UNSUPPORTED]"); break; case DDERR_WRONGMODE: dumpmsg(" [DDERR_WRONGMODE]"); break; case DD_OK: dumpmsg(" [OK]"); break; - default: { char buf[256]; sprintf(buf, " [UNKNOWN: %08x]"); dumpmsg(buf); } break; + default: { dumpmsg(" [UNKNOWN: %08x]", ddrval); } break; } Sleep(50); } @@ -1969,7 +1970,7 @@ void __cdecl GeissProc( void *p ) case DDERR_UNSUPPORTED: dumpmsg(" [DDERR_UNSUPPORTED]"); break; case DDERR_WRONGMODE: dumpmsg(" [DDERR_WRONGMODE]"); break; case DD_OK: dumpmsg(" [OK]"); break; - default: { char buf[256]; sprintf(buf, " [UNKNOWN: %08x]"); dumpmsg(buf); } break; + default: { dumpmsg(" [UNKNOWN: %08x]", ddrval); } break; } Sleep(50); } @@ -2186,9 +2187,7 @@ void __cdecl GeissProc( void *p ) { // heh heh... this should never execute. - char buf[256]; // pwr mgmt - sprintf(buf, "[GEISSPROC MESSAGE] frame %d: msg=0x%x, wParam=0x%x", intframe, msg.message, msg.wParam); - dumpmsg(buf); + dumpmsg("[GEISSPROC MESSAGE] frame %d: msg=0x%x, wParam=0x%x", intframe, msg.message, msg.wParam); TranslateMessage(&msg); DispatchMessage(&msg); @@ -2405,9 +2404,7 @@ BOOL DoSaver(HWND hparwnd, HINSTANCE hInstance) //Sleep(10); // milliseconds } - char buf[256]; // pwr mgmt - sprintf(buf, "frame %d: msg=0x%x, wParam=0x%x", intframe, msg.message, msg.wParam); - dumpmsg(buf); + dumpmsg("frame %d: msg=0x%x, wParam=0x%x", intframe, msg.message, msg.wParam); TranslateMessage(&msg); DispatchMessage(&msg); @@ -2431,9 +2428,7 @@ BOOL DoSaver(HWND hparwnd, HINSTANCE hInstance) // finish up message queue... while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { - char buf[256]; // pwr mgmt - sprintf(buf, "frame %d: msg=0x%x, wParam=0x%x", intframe, msg.message, msg.wParam); - dumpmsg(buf); + dumpmsg("frame %d: msg=0x%x, wParam=0x%x", intframe, msg.message, msg.wParam); TranslateMessage(&msg); DispatchMessage(&msg); @@ -3517,9 +3512,7 @@ int WINAPI WinMain(HINSTANCE h,HINSTANCE,LPSTR,int) DWORD dwDXVersion;//, dwDXPlatform; dumpmsg("GetDXVersion()..."); GetDXVersion(&dwDXVersion);//, &dwDXPlatform); - char buf[128]; - sprintf(buf, "DirectX version is %x.", dwDXVersion); - dumpmsg(buf); + dumpmsg("DirectX version is %x.", dwDXVersion); if (dwDXVersion == 0) { @@ -3739,27 +3732,21 @@ int render1(struct winampVisModule *this_mod) #ifdef PLUGIN if (g_this_mod != this_mod) { - char buf[128]; - sprintf(buf, "**********ALERT******** Frame %d: value of this_mod changed", intframe); - dumpmsg(buf); + dumpmsg("**********ALERT******** Frame %d: value of this_mod changed", intframe); g_this_mod = this_mod; } if (this_mod_hwndParent != this_mod->hwndParent) { - char buf[128]; - sprintf(buf, "**********ALERT******** Frame %d: this_mod->hwndParent changed", intframe); - dumpmsg(buf); + dumpmsg("**********ALERT******** Frame %d: this_mod->hwndParent changed", intframe); this_mod_hwndParent = this_mod->hwndParent; } if (this_mod_hDllInstance != this_mod->hDllInstance) { - char buf[128]; - sprintf(buf, "**********ALERT******** Frame %d: this_mod->hDllInstance changed", intframe); - dumpmsg(buf); + dumpmsg("**********ALERT******** Frame %d: this_mod->hDllInstance changed", intframe); this_mod_hDllInstance = this_mod->hDllInstance; } @@ -4664,9 +4651,7 @@ void FX_Apply_Mode(bool bLoadPreset, int iPresetNum) // sets up DATA_X a end_pos = FXW*(FXH-FX_YCUT); } - //char buf[64]; - //sprintf(buf, "endpos=%d", end_pos); - //dumpmsg(buf); + //dumpmsg("endpos=%d", end_pos); y = y_map_pos / FXW; x = y_map_pos % FXW; @@ -5827,8 +5812,7 @@ BOOL doInit( HINSTANCE hInstance, int nCmdShow ) */ dumpmsg("directdrawcreate()..."); - sprintf(buf, " guid = %p", &g_DDrawDeviceGUID ); - dumpmsg(buf); + dumpmsg(" guid = %p", &g_DDrawDeviceGUID); #if (GRFX==1) ddrval = DirectDrawCreate( &g_DDrawDeviceGUID, &lpDD, NULL ); //first param = GUID of adapter to use @@ -5895,8 +5879,7 @@ BOOL doInit( HINSTANCE hInstance, int nCmdShow ) if (ddrval==DD_OK && VidMode >= 0) { - sprintf(buf, "WARNING: SetDisplayMode failed at %d x %d x %d...", FXW, FXH, iDispBits); - dumpmsg(buf); + dumpmsg("WARNING: SetDisplayMode failed at %d x %d x %d...", FXW, FXH, iDispBits); SetWindowPos(hMainWnd, NULL, 0, 0, FXW, FXH, SWP_NOMOVE|SWP_NOZORDER); @@ -5907,8 +5890,7 @@ BOOL doInit( HINSTANCE hInstance, int nCmdShow ) OnFxwFxhUpdated(); - sprintf(buf, "...trying again at nearest match: %d x %d x %d...", FXW, FXH, iDispBits); - dumpmsg(buf); + dumpmsg("...trying again at nearest match: %d x %d x %d...", FXW, FXH, iDispBits); ddrval = lpDD->SetDisplayMode( FXW, FXH, iDispBits ); } @@ -6523,9 +6505,7 @@ long FAR PASCAL WindowProc( HWND hWnd, UINT message, szMsg[0] = 0; PrintWindowsMessage(message, szMsg); - char buf[512]; - sprintf(buf, "frame %d: %s, msg=0x%x, wParam=0x%x, lParam=0x%x", intframe, szMsg, message, wParam, lParam); - dumpmsg(buf); + dumpmsg("frame %d: %s, msg=0x%x, wParam=0x%x, lParam=0x%x", intframe, szMsg, message, wParam, lParam); } #endif @@ -8073,9 +8053,7 @@ void GetWaveData() if (i < FXW/2) // trigger. { - //char buf[64]; - //sprintf(buf, "trigger: frame=%d, pos=%d", intframe, i); - //dumpmsg(buf); + //dumpmsg("trigger: frame=%d, pos=%d", intframe, i); int iShift = i; for (i=iShift; i 0)//(intframe <= 4) { - char buf[64]; - sprintf(buf, "frame %d: clearing edges", intframe); - dumpmsg(buf); + dumpmsg("frame %d: clearing edges", intframe); //temp_clock = clock(); clearframes--; @@ -480,9 +476,8 @@ void Check_For_New_Song_Title() FX_YCUT_HIDE_xLINESIZE = FX_YCUT_HIDE * linesize; LINES_TO_DISPLAY = (FXH-FX_YCUT_HIDE*2); - //char buf[64]; - //sprintf(buf, "ltd=%d\n", LINES_TO_DISPLAY); dumpmsg(buf); - //sprintf(buf, "linesize_over_FXW=%d\n", linesize_over_FXW); dumpmsg(buf); + //dumpmsg("ltd=%d", LINES_TO_DISPLAY); + //dumpmsg("linesize_over_FXW=%d", linesize_over_FXW); @@ -604,7 +599,7 @@ void Check_For_New_Song_Title() } else { - dumpmsg("BAD VIDEO MODE: (FXH % 32 != 0 and FXH % 40 != 0)"); + dumpmsg("BAD VIDEO MODE: (FXH %% 32 != 0 and FXH %% 40 != 0)"); } } From 97912597187b6a7cc4706c44e64f0bbb49357ba3 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 23 Feb 2023 05:03:24 +0100 Subject: [PATCH 2/2] Flush in dumpmsg --- main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.cpp b/main.cpp index 7c8e9b3..e549378 100644 --- a/main.cpp +++ b/main.cpp @@ -9492,6 +9492,7 @@ void dumpmsg(const char *format, ...) if (infile) { fprintf(infile, "[Geiss debug file]\n"); + fflush(infile); fclose(infile); } } @@ -9504,6 +9505,7 @@ void dumpmsg(const char *format, ...) va_start(args, format); vfprintf(infile2, format, args); fprintf(infile2, "\n"); + fflush(infile2); fclose(infile2); } }