project64/Source/Project64-core/N64System/Recompiler/x86CodeLog.cpp

57 lines
1.8 KiB
C++
Raw Normal View History

2016-01-27 09:11:59 +00:00
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include "x86CodeLog.h"
#include <Common/path.h>
#include <Windows.h>
static HANDLE hCPULogFile = NULL;
bool bX86Logging = false;
void x86_Log_Message (const char * Message, ...)
{
DWORD dwWritten;
char Msg[400];
va_list ap;
va_start( ap, Message );
vsprintf( Msg, Message, ap );
va_end( ap );
strcat(Msg,"\r\n");
WriteFile( hCPULogFile,Msg,strlen(Msg),&dwWritten,NULL );
}
void Start_x86_Log (void)
{
2016-03-10 11:15:40 +00:00
CPath LogFileName(g_Settings->LoadStringVal(Directory_Log).c_str(), "CPUoutput.log");
2016-01-27 09:11:59 +00:00
if (hCPULogFile) { Stop_x86_Log(); }
hCPULogFile = CreateFile(LogFileName,GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hCPULogFile)
{
bX86Logging = true;
SetFilePointer(hCPULogFile,0,NULL,FILE_BEGIN);
}
}
void Stop_x86_Log (void)
{
if (hCPULogFile)
{
CloseHandle(hCPULogFile);
hCPULogFile = NULL;
bX86Logging = false;
}
}