Skip to content

Commit

Permalink
Make debug helper dumpmsg work like printf
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Feb 23, 2023
1 parent 482cbc8 commit 7415b0c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 73 deletions.
8 changes: 2 additions & 6 deletions SOUND.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Sysstuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
83 changes: 27 additions & 56 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ saving favorite combinations (10 or so)
#pragma hdrstop
#include "resource.h"
#include <stdio.h> // for sprintf() for fps display
#include <stdarg.h>
#if SAVER
#include <mmsystem.h> // for mci/cd stuff
#endif
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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 );
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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<BUFSIZE; i++)
{
Expand Down Expand Up @@ -8212,9 +8190,7 @@ void GetWaveData()
}
char buf[99];
sprintf(buf, "blob_x[2] = %f, blob_str[2] = %f", blob_x[2], blob_str[2]);
dumpmsg(buf);
dumpmsg("blob_x[2] = %f, blob_str[2] = %f", blob_x[2], blob_str[2]);
*/

// write matrix - sloppy
Expand Down Expand Up @@ -8394,9 +8370,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
Expand Down Expand Up @@ -8677,9 +8651,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.5 + avg_vol * 0.45) - 10;
#ifdef PLUGIN
Expand Down Expand Up @@ -9108,9 +9080,7 @@ void RenderWave(unsigned char *VS1)
/*
if ((intframe % 50)==0)
{
char msg[64];
sprintf(msg, "sound: wave#/ready/active/empty = %d/%d/%d/%d", waveform, SoundReady, SoundActive, SoundEmpty);
dumpmsg(msg);
dumpmsg("sound: wave#/ready/active/empty = %d/%d/%d/%d", waveform, SoundReady, SoundActive, SoundEmpty);
}
*/
//EXPERIMENT
Expand All @@ -9125,9 +9095,7 @@ void RenderWave(unsigned char *VS1)
/*
if ((intframe % 50)==0)
{
char msg[64];
sprintf(msg, "wave: r=%d g=%d b=%d", r, g, b);
dumpmsg(msg);
dumpmsg("wave: r=%d g=%d b=%d", r, g, b);
}
r = 100;
g = 120;
Expand Down Expand Up @@ -9513,7 +9481,7 @@ void RenderWave(unsigned char *VS1)
}


void dumpmsg(char *s)
void dumpmsg(const char *format, ...)
{
if (g_bDebugMode)
{
Expand All @@ -9532,7 +9500,10 @@ void dumpmsg(char *s)
infile2 = fopen("c:\\g_debug.txt", "a");
if (infile2)
{
fprintf(infile2, "%s\n", s);
va_list args;
va_start(args, format);
vfprintf(infile2, format, args);
fprintf(infile2, "\n");
fclose(infile2);
}
}
Expand Down
15 changes: 5 additions & 10 deletions video.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,12 @@ void Check_For_New_Song_Title()

if (intframe<20)
{
char buf[32];
sprintf(buf, "[frame %d/20 ok]", intframe);
dumpmsg(buf);
dumpmsg("[frame %d/20 ok]", intframe);
}

if (clearframes > 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--;
Expand Down Expand Up @@ -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);



Expand Down Expand Up @@ -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)");
}

}
Expand Down

0 comments on commit 7415b0c

Please sign in to comment.