Simplify the common combination of sprintf() and OutputDebugString() (PR #1031)

- Update LogOutput() and LogFileOutput().
- Add StrFormat() to produce std::string out of snprintf() & add StrFormat.cpp to projects.
- Add PTRDIFF_T_FMT in parallel to SIZE_T_FMT to StdAfx.h, for completeness.
- In Log.cpp, changed to get timestamp using posix functions.
- Removed TCHAR usage throughout - simply use char.
This commit is contained in:
Kelvin Lee 2022-02-14 08:37:05 +11:00 committed by GitHub
parent 83e56924f7
commit 9a3832084a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 222 additions and 133 deletions

View File

@ -294,6 +294,14 @@
RelativePath=".\source\StdAfx.h" RelativePath=".\source\StdAfx.h"
> >
</File> </File>
<File
RelativePath=".\source\StrFormat.cpp"
>
</File>
<File
RelativePath=".\source\StrFormat.h"
>
</File>
<File <File
RelativePath=".\source\Utilities.cpp" RelativePath=".\source\Utilities.cpp"
> >

View File

@ -111,6 +111,7 @@
<ClInclude Include="source\SSI263.h" /> <ClInclude Include="source\SSI263.h" />
<ClInclude Include="source\SSI263Phonemes.h" /> <ClInclude Include="source\SSI263Phonemes.h" />
<ClInclude Include="source\StdAfx.h" /> <ClInclude Include="source\StdAfx.h" />
<ClInclude Include="source\StrFormat.h" />
<ClInclude Include="source\SynchronousEventManager.h" /> <ClInclude Include="source\SynchronousEventManager.h" />
<ClInclude Include="source\Tape.h" /> <ClInclude Include="source\Tape.h" />
<ClInclude Include="source\Tfe\Bpf.h" /> <ClInclude Include="source\Tfe\Bpf.h" />
@ -214,6 +215,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release v141_xp|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release v141_xp|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release NoDX|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release NoDX|Win32'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="source\StrFormat.cpp" />
<ClCompile Include="source\SynchronousEventManager.cpp" /> <ClCompile Include="source\SynchronousEventManager.cpp" />
<ClCompile Include="source\Tape.cpp" /> <ClCompile Include="source\Tape.cpp" />
<ClCompile Include="source\Tfe\tfe.cpp"> <ClCompile Include="source\Tfe\tfe.cpp">

View File

@ -247,6 +247,9 @@
<ClCompile Include="source\6522.cpp"> <ClCompile Include="source\6522.cpp">
<Filter>Source Files\Emulator</Filter> <Filter>Source Files\Emulator</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\StrFormat.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="source\CommonVICE\6510core.h"> <ClInclude Include="source\CommonVICE\6510core.h">
@ -567,6 +570,9 @@
<ClInclude Include="source\6522.h"> <ClInclude Include="source\6522.h">
<Filter>Source Files\Emulator</Filter> <Filter>Source Files\Emulator</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\StrFormat.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="resource\Applewin.bmp"> <Image Include="resource\Applewin.bmp">

View File

@ -339,9 +339,7 @@ static void DebugHddEntrypoint(const USHORT PC)
if (!bOldPCAtC7xx /*&& PC != 0xc70a*/) if (!bOldPCAtC7xx /*&& PC != 0xc70a*/)
{ {
Count++; Count++;
char szDebug[100]; LogOutput("HDD Entrypoint: $%04X\n", PC);
sprintf(szDebug, "HDD Entrypoint: $%04X\n", PC);
OutputDebugString(szDebug);
} }
bOldPCAtC7xx = true; bOldPCAtC7xx = true;

View File

@ -2,6 +2,8 @@
#include "Card.h" #include "Card.h"
#include "Common.h" #include "Common.h"
#include "StrFormat.h"
#include "Log.h"
void LogFileTimeUntilFirstKeyReadReset(void); void LogFileTimeUntilFirstKeyReadReset(void);
void LogFileTimeUntilFirstKeyRead(void); void LogFileTimeUntilFirstKeyRead(void);

View File

@ -3820,11 +3820,10 @@ Update_t CmdConfigSetDebugDir (int nArgs)
while ((iPathSeparator = sNewPath.find( PATH_SEPARATOR, iPrevSeparator )) != std::string::npos) while ((iPathSeparator = sNewPath.find( PATH_SEPARATOR, iPrevSeparator )) != std::string::npos)
{ {
#if _DEBUG #if _DEBUG
char zDebug[128]; LogOutput( "Prev: %" SIZE_T_FMT "\n", iPrevSeparator );
sprintf( zDebug, "Prev: %d\n", iPrevSeparator ); OutputDebugStringA( zDebug ); LogOutput( "Next: %" SIZE_T_FMT "\n", iPathSeparator );
sprintf( zDebug, "Next: %d\n", iPathSeparator ); OutputDebugStringA( zDebug ); LogOutput( "%s\n", sNewPath.c_str() );
sprintf( zDebug, "%s\n", sNewPath.c_str() ); OutputDebugStringA( zDebug ); LogOutput( "%*s%s\n", int(iPathSeparator), "", "^" );
sprintf( zDebug, "%*s%s\n", iPathSeparator, "", "^"); OutputDebugStringA( zDebug );
#endif #endif
std::string sSubDir = sNewPath.substr( iPrevSeparator, iPathSeparator - iPrevSeparator + 1 ); std::string sSubDir = sNewPath.substr( iPrevSeparator, iPathSeparator - iPrevSeparator + 1 );
@ -3843,9 +3842,9 @@ Update_t CmdConfigSetDebugDir (int nArgs)
if (nLastSeperator != std::string::npos) if (nLastSeperator != std::string::npos)
{ {
#if _DEBUG #if _DEBUG
sprintf( zDebug, "Last: %d\n", nLastSeperator ); OutputDebugStringA( zDebug ); LogOutput( "Last: %" SIZE_T_FMT "\n", nLastSeperator );
sprintf( zDebug, "%s\n", g_sCurrentDir.c_str() ); OutputDebugStringA( zDebug ); LogOutput( "%s\n", g_sCurrentDir.c_str() );
sprintf( zDebug, "%*s%s\n", nLastSeperator, "", "^"); OutputDebugStringA( zDebug ); LogOutput( "%*s%s\n", int(nLastSeperator), "", "^" );
#endif #endif
std::string sCurrentDir = g_sCurrentDir.substr( 0, nLastSeperator + 1 ); // Path always has trailing slash so include it std::string sCurrentDir = g_sCurrentDir.substr( 0, nLastSeperator + 1 ); // Path always has trailing slash so include it
g_sCurrentDir = sCurrentDir; g_sCurrentDir = sCurrentDir;
@ -4741,7 +4740,7 @@ Update_t CmdNTSC (int nArgs)
public: public:
static void update( const char *pPrefixText ) static void update( const char *pPrefixText )
{ {
TCHAR text[ CONSOLE_WIDTH*2 ] = TEXT(""); char text[ CONSOLE_WIDTH*2 ] = "";
size_t len1 = strlen( pPrefixText ); size_t len1 = strlen( pPrefixText );
size_t len2 = sPaletteFilePath.size(); size_t len2 = sPaletteFilePath.size();
@ -4752,11 +4751,9 @@ Update_t CmdNTSC (int nArgs)
ConsoleBufferPush( pPrefixText ); // TODO: Add a ": " separator ConsoleBufferPush( pPrefixText ); // TODO: Add a ": " separator
#if _DEBUG #if _DEBUG
sprintf( text, "Filename.length.1: %d\n", len1 ); LogOutput( "Filename.length.1: %d\n", len1 );
OutputDebugString( text ); LogOutput( "Filename.length.2: %d\n", len2 );
sprintf( text, "Filename.length.2: %d\n", len2 ); OutputDebugStringA( sPaletteFilePath.c_str() );
OutputDebugString( text );
OutputDebugString( sPaletteFilePath.c_str() );
#endif #endif
// File path is too long // File path is too long
// TODO: Need to split very long path names // TODO: Need to split very long path names
@ -4892,9 +4889,7 @@ Update_t CmdNTSC (int nArgs)
if (iDstX == 15) if (iDstX == 15)
iSrcX = 15; iSrcX = 15;
#if 0 // _DEBUG #if 0 // _DEBUG
char text[ 128 ]; LogOutput( "[ %X ] = [ %X ]\n", iDstX, iSrcX );
sprintf( text, "[ %X ] = [ %X ]\n", iDstX, iSrcX );
OutputDebugStringA( text );
#endif #endif
pTmp[ iDstX + 16*iPhase ] = pPhase0[ iSrcX ]; pTmp[ iDstX + 16*iPhase ] = pPhase0[ iSrcX ];
} }
@ -6205,11 +6200,9 @@ int FindSourceLine( WORD nAddress )
// iSourceLine = g_aSourceDebug.find( nAddress ); // iSourceLine = g_aSourceDebug.find( nAddress );
#if 0 // _DEBUG #if 0 // _DEBUG
{ {
TCHAR sText[ CONSOLE_WIDTH ];
for (int i = 0; i < g_vSourceLines.size(); i++ ) for (int i = 0; i < g_vSourceLines.size(); i++ )
{ {
wsprintf( sText, "%d: %s\n", i, g_vSourceLines[ i ] ); LogOutput( "%d: %s\n", i, g_vSourceLines[ i ] );
OutputDebugString( sText );
} }
} }
#endif #endif
@ -6221,9 +6214,7 @@ int FindSourceLine( WORD nAddress )
iLine = iSource->second; iLine = iSource->second;
#if 0 // _DEBUG #if 0 // _DEBUG
TCHAR sText[ CONSOLE_WIDTH ]; LogOutput( "%04X -> %d line\n", iAddress, iLine );
wsprintf( sText, "%04X -> %d line\n", iAddress, iLine );
OutputDebugString( sText );
#endif #endif
if (iAddress == nAddress) if (iAddress == nAddress)

View File

@ -911,10 +911,10 @@ void AssemblerHashOpcodes ()
nMnemonicHash = AssemblerHashMnemonic( pMnemonic ); nMnemonicHash = AssemblerHashMnemonic( pMnemonic );
g_aOpcodesHash[ iOpcode ] = nMnemonicHash; g_aOpcodesHash[ iOpcode ] = nMnemonicHash;
#if DEBUG_ASSEMBLER #if DEBUG_ASSEMBLER
//OutputDebugString( "" ); //OutputDebugString( "" );
char sText[ 128 ]; char sText[ 128 ];
ConsolePrintFormat( sText, "%s : %08X ", pMnemonic, nMnemonicHash ); ConsolePrintFormat( sText, "%s : %08X ", pMnemonic, nMnemonicHash );
// CLC: 002B864 // CLC: 002B864
#endif #endif
} }
ConsoleUpdate(); ConsoleUpdate();

View File

@ -183,9 +183,9 @@ bool DebuggerSetColor( const int iScheme, const int iColor, const COLORREF nColo
//=========================================================================== //===========================================================================
static void _SetupColorRamp(const int iPrimary, int & iColor_) static void _SetupColorRamp(const int iPrimary, int & iColor_)
{ {
TCHAR sRamp[CONSOLE_WIDTH * 2] = TEXT(""); std::string strRamp;
#if DEBUG_COLOR_RAMP #if DEBUG_COLOR_RAMP
TCHAR sText[CONSOLE_WIDTH]; char sText[CONSOLE_WIDTH];
#endif #endif
bool bR = (iPrimary & 1) ? true : false; bool bR = (iPrimary & 1) ? true : false;
@ -202,16 +202,15 @@ static void _SetupColorRamp(const int iPrimary, int & iColor_)
DWORD nColor = RGB(nR, nG, nB); DWORD nColor = RGB(nR, nG, nB);
g_aColorPalette[iColor_] = nColor; g_aColorPalette[iColor_] = nColor;
#if DEBUG_COLOR_RAMP #if DEBUG_COLOR_RAMP
wsprintf(sText, TEXT("RGB(%3d,%3d,%3d), "), nR, nG, nB); int len = snprintf_s(sText, _TRUNCATE, "RGB(%3d,%3d,%3d), ", nR, nG, nB);
strcat(sRamp, sText); strRamp.append(sText, len);
#endif #endif
iColor_++; iColor_++;
} }
#if DEBUG_COLOR_RAMP #if DEBUG_COLOR_RAMP
wsprintf(sText, TEXT(" // %d%d%d\n"), bB, bG, bR); int len = snprintf_s(sText, _TRUNCATE, " // %d%d%d\n", bB, bG, bR);
strcat(sRamp, sText); strRamp.append(sText, len);
OutputDebugString(sRamp); OutputDebugStringA(strRamp.c_str());
sRamp[0] = 0;
#endif #endif
} }
#endif // _DEBUG #endif // _DEBUG

View File

@ -733,9 +733,7 @@ void DisasmCalcTopFromCurAddress(bool bUpdateTop)
// .20 Fixed: DisasmCalcTopFromCurAddress() // .20 Fixed: DisasmCalcTopFromCurAddress()
//if ((eMode >= AM_1) && (eMode <= AM_3)) //if ((eMode >= AM_1) && (eMode <= AM_3))
#if 0 // _DEBUG #if 0 // _DEBUG
TCHAR sText[CONSOLE_WIDTH]; LogOutput("%04X : %d bytes\n", iAddress, nOpbytes);
wsprintf(sText, "%04X : %d bytes\n", iAddress, nOpbytes);
OutputDebugString(sText);
#endif #endif
iAddress += nOpbytes; iAddress += nOpbytes;
} }

View File

@ -1449,15 +1449,13 @@ void Disk2InterfaceCard::DumpTrackWOZ(FloppyDisk floppy) // pass a copy of m_flo
floppy.m_bitMask = 1 << remainder; floppy.m_bitMask = 1 << remainder;
bool newLine = true; bool newLine = true;
TCHAR str[20];
while (1) while (1)
{ {
if (newLine) if (newLine)
{ {
newLine = false; newLine = false;
StringCbPrintf(str, sizeof(str), "%04X:", floppy.m_bitOffset & 0xffff); LogOutput("%04X:", floppy.m_bitOffset & 0xffff);
OutputDebugString(str);
} }
BYTE n = floppy.m_trackimage[floppy.m_byte]; BYTE n = floppy.m_trackimage[floppy.m_byte];
@ -1483,9 +1481,8 @@ void Disk2InterfaceCard::DumpTrackWOZ(FloppyDisk floppy) // pass a copy of m_flo
nibbleCount++; nibbleCount++;
char syncBits = zeroCount <= 9 ? '0'+zeroCount : '+'; char syncBits = zeroCount <= 9 ? '0'+zeroCount : '+';
if (zeroCount == 0) StringCbPrintf(str, sizeof(str), " %02X", shiftReg); if (zeroCount == 0) LogOutput(" %02X", shiftReg);
else StringCbPrintf(str, sizeof(str), "(%c)%02X", syncBits, shiftReg); else LogOutput("(%c)%02X", syncBits, shiftReg);
OutputDebugString(str);
formatTrack.DecodeLatchNibbleRead(shiftReg); formatTrack.DecodeLatchNibbleRead(shiftReg);
@ -1509,15 +1506,13 @@ void Disk2InterfaceCard::DumpTrackWOZ(FloppyDisk floppy) // pass a copy of m_flo
if (zeroCount) if (zeroCount)
{ {
char syncBits = zeroCount <= 9 ? '0'+zeroCount : '+'; char syncBits = zeroCount <= 9 ? '0'+zeroCount : '+';
StringCbPrintf(str, sizeof(str), "(%c)", syncBits); LogOutput("(%c)", syncBits);
OutputDebugString(str);
} }
// Output any partial nibble // Output any partial nibble
if (shiftReg) if (shiftReg)
{ {
StringCbPrintf(str, sizeof(str), "%02X/Partial Nibble", shiftReg); LogOutput("%02X/Partial Nibble", shiftReg);
OutputDebugString(str);
} }
// Output any remaining "read D5AAxx detected" // Output any remaining "read D5AAxx detected"

View File

@ -29,6 +29,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h" #include "StdAfx.h"
#include "Log.h" #include "Log.h"
#include <time.h>
FILE* g_fh = NULL; FILE* g_fh = NULL;
#ifdef _MSC_VER #ifdef _MSC_VER
@ -42,6 +45,20 @@ FILE* g_fh = NULL;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
inline std::string GetTimeStamp()
{
time_t ltime;
time(&ltime);
#ifdef _MSC_VER
char ct[32];
ctime_s(ct, sizeof(ct), &ltime);
#else
char ctbuf[32];
const char* ct = ctime_r(&ltime, ctbuf);
#endif
return std::string(ct, 24);
}
void LogInit(void) void LogInit(void)
{ {
if (g_fh) if (g_fh)
@ -55,10 +72,8 @@ void LogInit(void)
} }
setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf) setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf)
CHAR aDateStr[80], aTimeStr[80];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr)); fprintf(g_fh, "*** Logging started: %s\n", GetTimeStamp().c_str());
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aTimeStr, sizeof(aTimeStr));
fprintf(g_fh, "*** Logging started: %s %s\n", aDateStr, aTimeStr);
} }
void LogDone(void) void LogDone(void)
@ -73,31 +88,27 @@ void LogDone(void)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void LogOutput(LPCTSTR format, ...) void LogOutput(const char* format, ...)
{ {
TCHAR output[256];
va_list args; va_list args;
va_start(args, format); va_start(args, format);
_vsntprintf(output, sizeof(output) - 1, format, args); OutputDebugStringA(StrFormat(format, args).c_str());
output[sizeof(output) - 1] = 0;
OutputDebugString(output); va_end(args);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void LogFileOutput(LPCTSTR format, ...) void LogFileOutput(const char* format, ...)
{ {
if (!g_fh) if (!g_fh)
return; return;
TCHAR output[256];
va_list args; va_list args;
va_start(args, format); va_start(args, format);
_vsntprintf(output, sizeof(output) - 1, format, args); vfprintf(g_fh, format, args);
output[sizeof(output) - 1] = 0;
fprintf(g_fh, "%s", output); va_end(args);
} }

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#include <cstdio>
#include "StrFormat.h"
#ifndef _VC71 // __VA_ARGS__ not supported on MSVC++ .NET 7.x #ifndef _VC71 // __VA_ARGS__ not supported on MSVC++ .NET 7.x
#ifdef _DEBUG #ifdef _DEBUG
#define LOG(format, ...) LogOutput(format, __VA_ARGS__) #define LOG(format, ...) LogOutput(format, __VA_ARGS__)
@ -8,15 +12,10 @@
#endif #endif
#endif #endif
extern FILE* g_fh; // Filehandle for log file extern FILE* g_fh; // File handle for log file
void LogInit(void); void LogInit(void);
void LogDone(void); void LogDone(void);
#ifdef _MSC_VER void LogOutput(const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
void LogOutput(LPCTSTR format, ...); void LogFileOutput(const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
void LogFileOutput(LPCTSTR format, ...);
#else
void LogOutput(LPCTSTR format, ...) __attribute__ ((format (printf, 1, 2)));
void LogFileOutput(LPCTSTR format, ...) __attribute__ ((format (printf, 1, 2)));
#endif

View File

@ -1095,7 +1095,7 @@ void SetMemMode(DWORD uNewMemMode)
psz += sprintf(psz, "CX=%d " , SW_INTCXROM ? 1 : 0); psz += sprintf(psz, "CX=%d " , SW_INTCXROM ? 1 : 0);
psz += sprintf(psz, "WRAM=%d " , SW_WRITERAM ? 1 : 0); psz += sprintf(psz, "WRAM=%d " , SW_WRITERAM ? 1 : 0);
psz += sprintf(psz, "\n"); psz += sprintf(psz, "\n");
OutputDebugString(szStr); OutputDebugStringA(szStr);
} }
#endif #endif
memmode = uNewMemMode; memmode = uNewMemMode;
@ -1978,9 +1978,7 @@ static void DebugFlip(WORD address, ULONG nExecutedCycles)
const double fFreq = CLK_6502 / (double)uCyclesBetweenFlips; const double fFreq = CLK_6502 / (double)uCyclesBetweenFlips;
char szStr[100]; LogOutput("Cycles between flips = %d (%f Hz)\n", uCyclesBetweenFlips, fFreq);
sprintf(szStr, "Cycles between flips = %d (%f Hz)\n", uCyclesBetweenFlips, fFreq);
OutputDebugString(szStr);
} }
#endif #endif

View File

@ -325,7 +325,6 @@ void CMouseInterface::OnCommand()
{ {
#ifdef _DEBUG_SPURIOUS_IRQ #ifdef _DEBUG_SPURIOUS_IRQ
static UINT uSpuriousIrqCount = 0; static UINT uSpuriousIrqCount = 0;
char szDbg[200];
BYTE byOldState = m_byState; BYTE byOldState = m_byState;
#endif #endif
@ -353,7 +352,7 @@ void CMouseInterface::OnCommand()
m_byBuff[5] = m_byState; // button 0/1 interrupt status m_byBuff[5] = m_byState; // button 0/1 interrupt status
m_byState &= ~STAT_MOVEMENT_SINCE_READMOUSE; m_byState &= ~STAT_MOVEMENT_SINCE_READMOUSE;
#ifdef _DEBUG_SPURIOUS_IRQ #ifdef _DEBUG_SPURIOUS_IRQ
sprintf(szDbg, "[MOUSE_READ] Old=%02X New=%02X\n", byOldState, m_byState); OutputDebugString(szDbg); LogOutput("[MOUSE_READ] Old=%02X New=%02X\n", byOldState, m_byState);
#endif #endif
break; break;
case MOUSE_SERV: case MOUSE_SERV:
@ -363,11 +362,11 @@ void CMouseInterface::OnCommand()
if ((m_byMode & MODE_INT_ALL) && (m_byBuff[1] & MODE_INT_ALL) == 0) if ((m_byMode & MODE_INT_ALL) && (m_byBuff[1] & MODE_INT_ALL) == 0)
{ {
uSpuriousIrqCount++; uSpuriousIrqCount++;
sprintf(szDbg, "[MOUSE_SERV] 0x%04X Buff[1]=0x%02X, ***\n", uSpuriousIrqCount, m_byBuff[1]); OutputDebugString(szDbg); LogOutput("[MOUSE_SERV] 0x%04X Buff[1]=0x%02X, ***\n", uSpuriousIrqCount, m_byBuff[1]);
} }
else else
{ {
sprintf(szDbg, "[MOUSE_SERV] ------ Buff[1]=0x%02X\n", m_byBuff[1]); OutputDebugString(szDbg); LogOutput("[MOUSE_SERV] ------ Buff[1]=0x%02X\n", m_byBuff[1]);
} }
#endif #endif
CpuIrqDeassert(IS_MOUSE); CpuIrqDeassert(IS_MOUSE);
@ -472,7 +471,7 @@ void CMouseInterface::OnMouseEvent(bool bEventVBL)
m_byState |= byState; m_byState |= byState;
CpuIrqAssert(IS_MOUSE); CpuIrqAssert(IS_MOUSE);
#ifdef _DEBUG_SPURIOUS_IRQ #ifdef _DEBUG_SPURIOUS_IRQ
char szDbg[200]; sprintf(szDbg, "[MOUSE EVNT] 0x%02X Mode=0x%02X\n", m_byState, m_byMode); OutputDebugString(szDbg); LogOutput("[MOUSE EVNT] 0x%02X Mode=0x%02X\n", m_byState, m_byMode);
#endif #endif
} }
} }

View File

@ -2438,9 +2438,7 @@ static bool CheckVideoTables2( eApple2Type type, uint32_t mode )
_ASSERT(addr1 == addr2); _ASSERT(addr1 == addr2);
if (addr1 != addr2) if (addr1 != addr2)
{ {
char str[80]; LogOutput("vpos=%04X, hpos=%02X, Video_adr=$%04X, NTSC_adr=$%04X\n", g_nVideoClockVert, g_nVideoClockHorz, addr1, addr2);
sprintf(str, "vpos=%04X, hpos=%02X, Video_adr=$%04X, NTSC_adr=$%04X\n", g_nVideoClockVert, g_nVideoClockHorz, addr1, addr2);
OutputDebugString(str);
return false; return false;
} }

View File

@ -1112,14 +1112,12 @@ void CSuperSerialCard::CheckCommEvent(DWORD dwEvtMask)
DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter) DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter)
{ {
CSuperSerialCard* pSSC = (CSuperSerialCard*) lpParameter; CSuperSerialCard* pSSC = (CSuperSerialCard*) lpParameter;
char szDbg[100];
BOOL bRes = SetCommMask(pSSC->m_hCommHandle, EV_RLSD | EV_DSR | EV_CTS | EV_TXEMPTY | EV_RXCHAR); BOOL bRes = SetCommMask(pSSC->m_hCommHandle, EV_RLSD | EV_DSR | EV_CTS | EV_TXEMPTY | EV_RXCHAR);
if (!bRes) if (!bRes)
{ {
sprintf(szDbg, "SSC: CommThread(): SetCommMask() failed\n"); LogOutput("SSC: CommThread(): SetCommMask() failed\n");
LogOutput("%s", szDbg); LogFileOutput("SSC: CommThread(): SetCommMask() failed\n");
LogFileOutput("%s", szDbg);
return -1; return -1;
} }
@ -1145,11 +1143,15 @@ DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter)
COMSTAT Stat; COMSTAT Stat;
ClearCommError(pSSC->m_hCommHandle, &dwErrors, &Stat); ClearCommError(pSSC->m_hCommHandle, &dwErrors, &Stat);
if (dwErrors & CE_RXOVER) if (dwErrors & CE_RXOVER)
sprintf(szDbg, "SSC: CommThread(): LastError=0x%08X, CommError=CE_RXOVER (0x%08X): InQueue=0x%08X\n", dwRet, dwErrors, Stat.cbInQue); {
LogOutput("SSC: CommThread(): LastError=0x%08X, CommError=CE_RXOVER (0x%08X): InQueue=0x%08X\n", dwRet, dwErrors, Stat.cbInQue);
LogFileOutput("SSC: CommThread(): LastError=0x%08X, CommError=CE_RXOVER (0x%08X): InQueue=0x%08X\n", dwRet, dwErrors, Stat.cbInQue);
}
else else
sprintf(szDbg, "SSC: CommThread(): LastError=0x%08X, CommError=Other (0x%08X): InQueue=0x%08X, OutQueue=0x%08X\n", dwRet, dwErrors, Stat.cbInQue, Stat.cbOutQue); {
LogOutput("%s", szDbg); LogOutput("SSC: CommThread(): LastError=0x%08X, CommError=Other (0x%08X): InQueue=0x%08X, OutQueue=0x%08X\n", dwRet, dwErrors, Stat.cbInQue, Stat.cbOutQue);
LogFileOutput("%s", szDbg); LogFileOutput("SSC: CommThread(): LastError=0x%08X, CommError=Other (0x%08X): InQueue=0x%08X, OutQueue=0x%08X\n", dwRet, dwErrors, Stat.cbInQue, Stat.cbOutQue);
}
return -1; return -1;
} }
@ -1175,7 +1177,7 @@ DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter)
} }
dwWaitResult -= WAIT_OBJECT_0; // Determine event # that signaled dwWaitResult -= WAIT_OBJECT_0; // Determine event # that signaled
//sprintf(szDbg, "CommThread: GotEvent1: %d\n", dwWaitResult); OutputDebugString(szDbg); //LogOutput("CommThread: GotEvent1: %d\n", dwWaitResult);
if (dwWaitResult == (nNumEvents-1)) if (dwWaitResult == (nNumEvents-1))
break; // Termination event break; // Termination event

View File

@ -488,7 +488,6 @@ static int nDbgSpkrCnt = 0;
static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSamples) static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSamples)
{ {
//char szDbg[200];
nDbgSpkrCnt++; nDbgSpkrCnt++;
if(!SpeakerVoice.bActive) if(!SpeakerVoice.bActive)
@ -514,7 +513,7 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
dwByteOffset = dwCurrentPlayCursor + (g_dwDSSpkrBufferSize/8)*3; // Ideal: 0.375 is between 0.25 & 0.50 full dwByteOffset = dwCurrentPlayCursor + (g_dwDSSpkrBufferSize/8)*3; // Ideal: 0.375 is between 0.25 & 0.50 full
dwByteOffset %= g_dwDSSpkrBufferSize; dwByteOffset %= g_dwDSSpkrBufferSize;
//sprintf(szDbg, "[Submit_FS] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X [REINIT]\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); //LogOutput("[Submit_FS] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X [REINIT]\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
} }
else else
{ {
@ -525,7 +524,7 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
// |-----PxxxxxW-----| // |-----PxxxxxW-----|
if((dwByteOffset > dwCurrentPlayCursor) && (dwByteOffset < dwCurrentWriteCursor)) if((dwByteOffset > dwCurrentPlayCursor) && (dwByteOffset < dwCurrentWriteCursor))
{ {
//sprintf(szDbg, "[Submit_FS] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); //LogOutput("[Submit_FS] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
dwByteOffset = dwCurrentWriteCursor; dwByteOffset = dwCurrentWriteCursor;
} }
} }
@ -534,7 +533,7 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
// |xxW----------Pxxx| // |xxW----------Pxxx|
if((dwByteOffset > dwCurrentPlayCursor) || (dwByteOffset < dwCurrentWriteCursor)) if((dwByteOffset > dwCurrentPlayCursor) || (dwByteOffset < dwCurrentWriteCursor))
{ {
//sprintf(szDbg, "[Submit_FS] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); //LogOutput("[Submit_FS] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
dwByteOffset = dwCurrentWriteCursor; dwByteOffset = dwCurrentWriteCursor;
} }
} }
@ -590,7 +589,7 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
if(nNumSamples) if(nNumSamples)
{ {
//sprintf(szDbg, "[Submit_FS] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X ***\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); //LogOutput("[Submit_FS] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X ***\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
if(nNumSamples*sizeof(short) <= dwDSLockedBufferSize0) if(nNumSamples*sizeof(short) <= dwDSLockedBufferSize0)
{ {
@ -624,7 +623,7 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
if(nNumPadSamples) if(nNumPadSamples)
{ {
//sprintf(szDbg, "[Submit_FS] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, PS=%08X, Data=%04X\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumPadSamples, g_nSpeakerData); OutputDebugString(szDbg); //LogOutput("[Submit_FS] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, PS=%08X, Data=%04X\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumPadSamples, g_nSpeakerData);
dwBufferSize0 = dwDSLockedBufferSize0 - dwBufferSize0; dwBufferSize0 = dwDSLockedBufferSize0 - dwBufferSize0;
dwBufferSize1 = dwDSLockedBufferSize1 - dwBufferSize1; dwBufferSize1 = dwDSLockedBufferSize1 - dwBufferSize1;
@ -662,7 +661,6 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples) static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
{ {
//char szDbg[200];
nDbgSpkrCnt++; nDbgSpkrCnt++;
if(!SpeakerVoice.bActive) if(!SpeakerVoice.bActive)
@ -702,7 +700,7 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
dwByteOffset = dwCurrentPlayCursor + (g_dwDSSpkrBufferSize/8)*3; // Ideal: 0.375 is between 0.25 & 0.50 full dwByteOffset = dwCurrentPlayCursor + (g_dwDSSpkrBufferSize/8)*3; // Ideal: 0.375 is between 0.25 & 0.50 full
dwByteOffset %= g_dwDSSpkrBufferSize; dwByteOffset %= g_dwDSSpkrBufferSize;
//sprintf(szDbg, "[Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X [REINIT]\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset); OutputDebugString(szDbg); //LogOutput("[Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X [REINIT]\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset);
} }
else else
{ {
@ -714,9 +712,8 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
if((dwByteOffset > dwCurrentPlayCursor) && (dwByteOffset < dwCurrentWriteCursor)) if((dwByteOffset > dwCurrentPlayCursor) && (dwByteOffset < dwCurrentWriteCursor))
{ {
double fTicksSecs = (double)GetTickCount() / 1000.0; double fTicksSecs = (double)GetTickCount() / 1000.0;
//sprintf(szDbg, "%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); //LogOutput("%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
//OutputDebugString(szDbg); //LogFileOutput("%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
//if (g_fh) fprintf(g_fh, szDbg);
dwByteOffset = dwCurrentWriteCursor; dwByteOffset = dwCurrentWriteCursor;
nNumSamplesError = 0; nNumSamplesError = 0;
@ -729,9 +726,8 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
if((dwByteOffset > dwCurrentPlayCursor) || (dwByteOffset < dwCurrentWriteCursor)) if((dwByteOffset > dwCurrentPlayCursor) || (dwByteOffset < dwCurrentWriteCursor))
{ {
double fTicksSecs = (double)GetTickCount() / 1000.0; double fTicksSecs = (double)GetTickCount() / 1000.0;
//sprintf(szDbg, "%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); //LogOutput("%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
//OutputDebugString(szDbg); //LogFileOutput("%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples);
//if (g_fh) fprintf(g_fh, "%s", szDbg);
dwByteOffset = dwCurrentWriteCursor; dwByteOffset = dwCurrentWriteCursor;
nNumSamplesError = 0; nNumSamplesError = 0;
@ -776,7 +772,7 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
if(nNumSamplesToUse) if(nNumSamplesToUse)
{ {
//sprintf(szDbg, "[Submit] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X +++\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamplesToUse); OutputDebugString(szDbg); //LogOutput("[Submit] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X +++\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamplesToUse);
hr = DSGetLock(SpeakerVoice.lpDSBvoice, hr = DSGetLock(SpeakerVoice.lpDSBvoice,
dwByteOffset, (DWORD)nNumSamplesToUse * sizeof(short), dwByteOffset, (DWORD)nNumSamplesToUse * sizeof(short),
@ -941,8 +937,7 @@ bool Spkr_DSInit()
hr = SpeakerVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor); hr = SpeakerVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
LogFileOutput("Spkr_DSInit: GetCurrentPosition kludge (%08X)\n", hr); LogFileOutput("Spkr_DSInit: GetCurrentPosition kludge (%08X)\n", hr);
char szDbg[100]; LogOutput("[DSInit] PC=%08X, WC=%08X, Diff=%08X\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor);
sprintf(szDbg, "[DSInit] PC=%08X, WC=%08X, Diff=%08X\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor); OutputDebugString(szDbg);
} }
return true; return true;

View File

@ -35,6 +35,7 @@ typedef UINT64 uint64_t;
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#include <cstdarg>
// SM_CXPADDEDBORDER is not supported on 2000 & XP: // SM_CXPADDEDBORDER is not supported on 2000 & XP:
// http://msdn.microsoft.com/en-nz/library/windows/desktop/ms724385(v=vs.85).aspx // http://msdn.microsoft.com/en-nz/library/windows/desktop/ms724385(v=vs.85).aspx
@ -43,3 +44,17 @@ typedef UINT64 uint64_t;
#endif #endif
#define USE_SPEECH_API #define USE_SPEECH_API
#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || \
(!defined(_MSC_VER) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L))
#ifdef _WIN64
#define SIZE_T_FMT "llu"
#define PTRDIFF_T_FMT "lld"
#else
#define SIZE_T_FMT "lu"
#define PTRDIFF_T_FMT "ld"
#endif
#else
#define SIZE_T_FMT "zu"
#define PTRDIFF_T_FMT "td"
#endif

67
source/StrFormat.cpp Normal file
View File

@ -0,0 +1,67 @@
#include "StdAfx.h"
#include "StrFormat.h"
#include <cassert>
std::string StrFormat(const char* format, ...)
{
va_list va;
va_start(va, format);
std::string s = StrFormatV(format, va);
va_end(va);
return s;
}
std::string StrFormatV(const char* format, va_list va)
{
size_t const bufsz_base = 2048; // Big enough for most cases.
char buf[bufsz_base];
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(push)
#pragma warning(disable: 4996) // warning _vsnprintf() is unsafe.
// VS2013 or before, _vsnprintf() cannot return required buffer size in case of overflow.
// MSVC seems fine not needing va_copy(), otherwise va_copy() may need to be called twice
// to be accurate. Not calling va_copy() here to keep things simpler.
int len = _vsnprintf(buf, sizeof(buf), format, va);
if (len >= 0 && size_t(len) <= sizeof(buf))
{
// _vsnprintf() can fill up the full buffer without nul termination.
return std::string(buf, size_t(len)); // No overflow.
}
else
{
// Overflow, need bigger buffer.
len = _vsnprintf(NULL, 0, format, va); // Get required buffer size.
std::string s(size_t(len), '\0');
len = _vsnprintf(&(*s.begin()), s.length() + 1, format, va);
assert(size_t(len) == s.length());
return s;
}
#pragma warning(pop)
#else
// Need to call va_copy() so va can be used potentially for a second time.
// glibc on Linux *certainly* needs this while MSVC is fine without it though.
va_list va_copied;
va_copy(va_copied, va);
int len = vsnprintf(buf, sizeof(buf), format, va_copied);
va_end(va_copied);
if (len < 0)
{
return std::string(); // Error.
}
else if (size_t(len) < sizeof(buf))
{
return std::string(buf, size_t(len)); // No overflow.
}
else
{
// Overflow, need bigger buffer.
std::string s(size_t(len), '\0');
len = vsnprintf(&(*s.begin()), s.length() + 1, format, va);
assert(size_t(len) == s.length());
return s;
}
#endif
}

13
source/StrFormat.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include <string>
#include <cstdarg>
#ifdef _MSC_VER
#define ATTRIBUTE_FORMAT_PRINTF(a, b)
#else
#define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
#endif
std::string StrFormat(const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
std::string StrFormatV(const char* format, va_list va);

View File

@ -194,8 +194,7 @@ void debug_output( const char *text, BYTE *what, int count )
int len1 = count; int len1 = count;
int i; int i;
sprintf(buffer, "\n%s: length = %u\n", text, len1); LogOutput("\n%s: length = %u\n", text, len1);
OutputDebugString(buffer);
do { do {
p = buffer; p = buffer;
for (i=0; (i<8) && len1>0; len1--, i++) { for (i=0; (i<8) && len1>0; len1--, i++) {
@ -203,7 +202,7 @@ void debug_output( const char *text, BYTE *what, int count )
p += 3; p += 3;
} }
*(p-1) = '\n'; *p = 0; *(p-1) = '\n'; *p = 0;
OutputDebugString(buffer); OutputDebugStringA(buffer);
} while (len1>0); } while (len1>0);
} }
#endif // #ifdef TFE_DEBUG_PKTDUMP #endif // #ifdef TFE_DEBUG_PKTDUMP

View File

@ -623,9 +623,7 @@ void Win32Frame::FrameDrawDiskStatus( HDC passdc )
#if _DEBUG && 0 #if _DEBUG && 0
if (nDOS33track != nDisk1Track) if (nDOS33track != nDisk1Track)
{ {
char text[128]; LogOutput( "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", nDOS33track, nDOS33track, nDisk1Track, nDisk1Track );
sprintf( text, "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", nDOS33track, nDOS33track, nDisk1Track, nDisk1Track );
OutputDebugString( text );
} }
#endif // _DEBUG #endif // _DEBUG
@ -1648,9 +1646,9 @@ LRESULT Win32Frame::WndProc(
case WM_SYSCOLORCHANGE: case WM_SYSCOLORCHANGE:
#if DEBUG_DD_PALETTE #if DEBUG_DD_PALETTE
if( g_bIsFullScreen ) if( g_bIsFullScreen )
OutputDebugString( "WM_SYSCOLORCHANGE: Full Screen\n" ); OutputDebugStringA( "WM_SYSCOLORCHANGE: Full Screen\n" );
else else
OutputDebugString( "WM_SYSCOLORCHANGE: Windowed\n" ); OutputDebugStringA( "WM_SYSCOLORCHANGE: Windowed\n" );
#endif #endif
DeleteGdiObjects(); DeleteGdiObjects();
@ -1841,9 +1839,7 @@ void Win32Frame::ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
bool bAllowFadeIn = true; bool bAllowFadeIn = true;
#if DEBUG_DD_PALETTE #if DEBUG_DD_PALETTE
char _text[ 80 ]; LogOutput( "Button: F%d Full Screen: %d\n", button+1, g_bIsFullScreen );
sprintf( _text, "Button: F%d Full Screen: %d\n", button+1, g_bIsFullScreen );
OutputDebugString( _text );
#endif #endif
switch (button) { switch (button) {
@ -2552,14 +2548,13 @@ void Win32Frame::FrameSetCursorPosByMousePos()
SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY);
#if defined(_DEBUG) && 0 // OutputDebugString() when cursor position changes since last time #if defined(_DEBUG) && 0 // OutputDebugString() when cursor position changes since last time
static int OldX=0, OldY=0; static int OldX = 0, OldY = 0;
char szDbg[200]; int X = Point.x + iWindowX - VIEWPORTX;
int X=Point.x+iWindowX-VIEWPORTX; int Y = Point.y + iWindowY - VIEWPORTY;
int Y=Point.y+iWindowY-VIEWPORTY;
if (X != OldX || Y != OldY) if (X != OldX || Y != OldY)
{ {
sprintf(szDbg, "[FrameSetCursorPosByMousePos] x,y=%d,%d (MaxX,Y=%d,%d)\n", X,Y, iMaxX,iMaxY); OutputDebugString(szDbg); LogOutput("[FrameSetCursorPosByMousePos] x,y=%d,%d (MaxX,Y=%d,%d)\n", X, Y, iMaxX, iMaxY);
OldX=X; OldY=Y; OldX = X; OldY = Y;
} }
#endif #endif
} }
@ -2573,7 +2568,6 @@ void Win32Frame::FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool
if (!GetCardMgr().IsMouseCardInstalled()) if (!GetCardMgr().IsMouseCardInstalled())
return; return;
// char szDbg[200];
if (!g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen)) if (!g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen))
return; return;
@ -2598,11 +2592,11 @@ void Win32Frame::FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool
POINT Point = {viewportx+2, viewporty+2}; // top-left POINT Point = {viewportx+2, viewporty+2}; // top-left
ClientToScreen(g_hFrameWindow, &Point); ClientToScreen(g_hFrameWindow, &Point);
SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY);
// sprintf(szDbg, "[MOUSE_LEAVING ] x=%d, y=%d (Scale: x,y=%f,%f; iX,iY=%d,%d)\n", iWindowX, iWindowY, fScaleX, fScaleY, iX, iY); OutputDebugString(szDbg); //LogOutput("[MOUSE_LEAVING ] x=%d, y=%d (Scale: x,y=%f,%f; iX,iY=%d,%d)\n", iWindowX, iWindowY, fScaleX, fScaleY, iX, iY);
} }
else // Mouse entering Apple screen area else // Mouse entering Apple screen area
{ {
// sprintf(szDbg, "[MOUSE_ENTERING] x=%d, y=%d\n", x, y); OutputDebugString(szDbg); //LogOutput("[MOUSE_ENTERING] x=%d, y=%d\n", x, y);
if (!g_bIsFullScreen) // GH#464 if (!g_bIsFullScreen) // GH#464
{ {
x -= (viewportx+2-VIEWPORTX); if (x < 0) x = 0; x -= (viewportx+2-VIEWPORTX); if (x < 0) x = 0;