Merge remote-tracking branch 'refs/remotes/origin/master' into distorm

This commit is contained in:
PatrickvL 2017-01-10 17:59:38 +01:00
commit df7c0eaa6e
23 changed files with 1725 additions and 1158 deletions

2
.gitignore vendored
View File

@ -78,4 +78,4 @@ packages/
*.testsettings
src/Version.h
*.opendb
build/win32/Cxbx.VC.db
*.db

View File

@ -199,6 +199,7 @@
<ClInclude Include="..\..\src\Cxbx.h" />
<ClInclude Include="..\..\src\CxbxKrnl\CxbxKrnl.h" />
<ClInclude Include="..\..\src\CxbxKrnl\DbgConsole.h" />
<ClInclude Include="..\..\src\CxbxKrnl\device.h" />
<ClInclude Include="..\..\src\CxbxKrnl\Emu.h" />
<ClInclude Include="..\..\src\CxbxKrnl\EmuAlloc.h" />
<ClInclude Include="..\..\src\CxbxKrnl\EmuD3D8.h" />
@ -472,6 +473,7 @@
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="..\..\src\CxbxKrnl\device.cpp" />
<ClCompile Include="..\..\src\CxbxKrnl\Emu.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -147,7 +147,7 @@ extern thread_local std::string _logPrefix;
do { if(g_bPrintfOn) { \
bool _had_arg = false; \
std::stringstream tmp; \
tmp << __FILENAME__ << " (" << hex2((uint16_t)GetCurrentThreadId()) << "): "; \
tmp << "[" << hex2((uint16_t)GetCurrentThreadId()) << "] " << __FILENAME__ << ": "; \
_logPrefix = tmp.str(); \
std::stringstream msg; \
msg << _logPrefix << __func__ << "(";

View File

@ -106,7 +106,7 @@ extern volatile bool g_bPrintfOn;
/*! DbgPrintf enabled if _DEBUG_TRACE is set */
#ifdef _DEBUG_TRACE
#define DbgPrintf(fmt, ...) do { if(g_bPrintfOn) printf(fmt, ##__VA_ARGS__); } while (0)
#define DbgPrintf(fmt, ...) do { if(g_bPrintfOn) printf("[0x%X] "##fmt, GetCurrentThreadId(), ##__VA_ARGS__); } while (0)
#else
inline void null_func(...) { }
#define DbgPrintf null_func

View File

@ -397,8 +397,8 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
SetConsoleTextAttribute(StdHandle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
printf("EmuMain (0x%X): Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), _CXBX_VERSION);
printf("EmuMain (0x%X): Debug Console Allocated (DM_CONSOLE).\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), _CXBX_VERSION);
printf("[0x%X] EmuMain: Debug Console Allocated (DM_CONSOLE).\n", GetCurrentThreadId());
}
}
else if (DbgMode == DM_FILE)
@ -407,8 +407,8 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
freopen(szDebugFilename, "wt", stdout);
printf("EmuMain (0x%X): Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), _CXBX_VERSION);
printf("EmuMain (0x%X): Debug Console Allocated (DM_FILE).\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), _CXBX_VERSION);
printf("[0x%X] EmuMain: Debug Console Allocated (DM_FILE).\n", GetCurrentThreadId());
}
else
{
@ -426,9 +426,9 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
{
#ifdef _DEBUG_TRACE
printf("EmuMain (0x%X): Debug Trace Enabled.\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Debug Trace Enabled.\n", GetCurrentThreadId());
printf("EmuMain (0x%X): CxbxKrnlInit\n"
printf("[0x%X] EmuMain: CxbxKrnlInit\n"
"(\n"
" hwndParent : 0x%.08X\n"
" pTLSData : 0x%.08X\n"
@ -443,7 +443,7 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
GetCurrentThreadId(), hwndParent, pTLSData, pTLS, pLibraryVersion, DbgMode, szDebugFilename, pXbeHeader, dwXbeHeaderSize, Entry);
#else
printf("EmuMain (0x%X): Debug Trace Disabled.\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Debug Trace Disabled.\n", GetCurrentThreadId());
#endif
}
@ -600,17 +600,17 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
//
// initialize grapchics
//
DbgPrintf("EmuMain (0x%X): Initializing render window.\n", GetCurrentThreadId());
DbgPrintf("EmuMain: Initializing render window.\n");
XTL::CxbxInitWindow(pXbeHeader, dwXbeHeaderSize);
if (bLLE_GPU)
{
DbgPrintf("EmuMain (0x%X): Initializing OpenGL.\n", GetCurrentThreadId());
DbgPrintf("EmuMain: Initializing OpenGL.\n");
InitOpenGLContext();
}
else
{
DbgPrintf("EmuMain (0x%X): Initializing Direct3D.\n", GetCurrentThreadId());
DbgPrintf("EmuMain: Initializing Direct3D.\n");
XTL::EmuD3DInit(pXbeHeader, dwXbeHeaderSize);
}
@ -628,11 +628,11 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
EmuX86_Init();
DbgPrintf("EmuMain (0x%X): Initial thread starting.\n", GetCurrentThreadId());
DbgPrintf("EmuMain: Initial thread starting.\n");
CxbxLaunchXbe(Entry);
DbgPrintf("EmuMain (0x%X): Initial thread ended.\n", GetCurrentThreadId());
DbgPrintf("EmuMain: Initial thread ended.\n");
fflush(stdout);
@ -655,7 +655,7 @@ extern "C" CXBXKRNL_API void CxbxKrnlCleanup(const char *szErrorMessage, ...)
va_list argp;
sprintf(szBuffer1, "EmuMain (0x%X): Recieved Fatal Message:\n\n* ", GetCurrentThreadId());
sprintf(szBuffer1, "[0x%X] EmuMain: Recieved Fatal Message:\n\n* ", GetCurrentThreadId());
va_start(argp, szErrorMessage);
@ -797,12 +797,12 @@ extern "C" CXBXKRNL_API void CxbxKrnlTerminateThread()
extern "C" CXBXKRNL_API void CxbxKrnlPanic()
{
DbgPrintf("EmuMain (0x%X): CxbxKrnlPanic()\n", GetCurrentThreadId());
DbgPrintf("EmuMain: CxbxKrnlPanic()\n");
CxbxKrnlCleanup("Kernel Panic!");
}
extern "C" CXBXKRNL_API void CxbxKrnlNoFunc()
{
DbgPrintf("EmuMain (0x%X): CxbxKrnlNoFunc()\n", GetCurrentThreadId());
DbgPrintf("EmuMain: CxbxKrnlNoFunc()\n");
}

View File

@ -124,7 +124,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuWarning(const char *szWarningMessage, ...)
va_list argp;
sprintf(szBuffer1, "EmuWarn (0x%X): ", GetCurrentThreadId());
sprintf(szBuffer1, "[0x%X] EmuWarn: ", GetCurrentThreadId());
va_start(argp, szWarningMessage);
@ -150,9 +150,9 @@ void EmuExceptionPrintDebugInformation(LPEXCEPTION_POINTERS e, bool IsBreakpoint
// print debug information
{
if (IsBreakpointException)
printf("EmuMain (0x%X): Recieved Breakpoint Exception (int 3)\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Recieved Breakpoint Exception (int 3)\n", GetCurrentThreadId());
else
printf("EmuMain (0x%X): Recieved Exception (Code := 0x%.08X)\n", GetCurrentThreadId(), e->ExceptionRecord->ExceptionCode);
printf("[0x%X] EmuMain: Recieved Exception (Code := 0x%.08X)\n", GetCurrentThreadId(), e->ExceptionRecord->ExceptionCode);
printf("\n"
" EIP := 0x%.08X EFL := 0x%.08X\n"
@ -176,7 +176,7 @@ void EmuExceptionPrintDebugInformation(LPEXCEPTION_POINTERS e, bool IsBreakpoint
void EmuExceptionExitProcess()
{
printf("EmuMain (0x%X): Aborting Emulation\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Aborting Emulation\n", GetCurrentThreadId());
fflush(stdout);
if (CxbxKrnl_hEmuParent != NULL)
@ -205,7 +205,7 @@ bool EmuExceptionBreakpointAsk(LPEXCEPTION_POINTERS e)
}
else if (ret == IDIGNORE)
{
printf("EmuMain (0x%X): Ignored Breakpoint Exception\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Ignored Breakpoint Exception\n", GetCurrentThreadId());
fflush(stdout);
e->ContextRecord->Eip += 1; // TODO : Skip actual instruction size bytes
@ -298,9 +298,9 @@ int ExitException(LPEXCEPTION_POINTERS e)
static int count = 0;
// debug information
printf("EmuMain (0x%X): * * * * * EXCEPTION * * * * *\n", GetCurrentThreadId());
printf("EmuMain (0x%X): Recieved Exception [0x%.08X]@0x%.08X\n", GetCurrentThreadId(), e->ExceptionRecord->ExceptionCode, e->ContextRecord->Eip);
printf("EmuMain (0x%X): * * * * * EXCEPTION * * * * *\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: * * * * * EXCEPTION * * * * *\n", GetCurrentThreadId());
printf("[0x%X] EmuMain: Recieved Exception [0x%.08X]@0x%.08X\n", GetCurrentThreadId(), e->ExceptionRecord->ExceptionCode, e->ContextRecord->Eip);
printf("[0x%X] EmuMain: * * * * * EXCEPTION * * * * *\n", GetCurrentThreadId());
fflush(stdout);

File diff suppressed because it is too large Load Diff

View File

@ -804,7 +804,7 @@ HRESULT XTL::CreatePixelShaderFunction(X_D3DPIXELSHADERDEF *pPSD, LPD3DXBUFFER*
if (FAILED(hRet))
{
EmuWarning("Couldn't assemble recompiled pixel shader\n");
EmuWarning("Couldn't assemble recompiled pixel shader");
if (pCompilationErrors)
{
EmuWarning((const char*)pCompilationErrors->GetBufferPointer());
@ -813,7 +813,7 @@ HRESULT XTL::CreatePixelShaderFunction(X_D3DPIXELSHADERDEF *pPSD, LPD3DXBUFFER*
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DbgPrintf("Pixel Shader : Exception while creating pixel shader 0x%.8X", pPSD);
DbgPrintf("Pixel Shader : Exception while creating pixel shader 0x%.8X\n", pPSD);
}
if (pCompilationErrors)
{
@ -1426,7 +1426,7 @@ inline void HandleInputOutput
if (bEFProduct)
{
EmuWarning("EF Product and V1R0 register used at the same time!\n");
EmuWarning("EF Product and V1R0 register used at the same time!");
}
else
{
@ -1947,7 +1947,7 @@ inline BOOL OptimizeOperation
{
if (szMod[0])
{
EmuWarning("Pixel Shader: Destination modifier present!\n");
EmuWarning("Pixel Shader: Destination modifier present!");
}
switch (eOpTypes[2])
{
@ -2072,7 +2072,7 @@ inline BOOL OptimizeOperation
{
if (szOutputs[2][0] != 'r')
{
EmuWarning("Pixel Shader: Destination not temporary register!\n");
EmuWarning("Pixel Shader: Destination not temporary register!");
}
// ab input
iOffset += sprintf(szCommand + iOffset, "mul%s r1, %s, %s\n",
@ -2404,7 +2404,7 @@ inline BOOL OptimizeOperation
}
if (!bHandled)
{
EmuWarning("Unhandled pixel shader instruction!\n");
EmuWarning("Unhandled pixel shader instruction!");
}
// if (strcmp(szOps[2], "add") == 0)
// {
@ -2418,7 +2418,7 @@ inline BOOL OptimizeOperation
// }
// else
// {
// EmuWarning("Unhandled pixel shader instruction!\n");
// EmuWarning("Unhandled pixel shader instruction!");
// }
// }
// else if (strcmp(szOps[2], "cnd") == 0)
@ -2433,12 +2433,12 @@ inline BOOL OptimizeOperation
// }
// else
// {
// EmuWarning("Unhandled pixel shader instruction!\n");
// EmuWarning("Unhandled pixel shader instruction!");
// }
// }
// else
// {
// EmuWarning("Unhandled pixel shader instruction!\n");
// EmuWarning("Unhandled pixel shader instruction!");
// }
}
}

View File

@ -534,7 +534,7 @@ static void VshParseInstruction(uint32 *pShaderToken,
pInstruction->A.Address = ConvertCRegister(VshGetField(pShaderToken, FLD_CONST));
break;
default:
EmuWarning("Invalid instruction, parameter A type unknown %d\n", pInstruction->A.ParameterType);
EmuWarning("Invalid instruction, parameter A type unknown %d", pInstruction->A.ParameterType);
return;
}
pInstruction->A.Neg = VshGetField(pShaderToken, FLD_A_NEG);
@ -1300,7 +1300,7 @@ static boolean VshConvertShader(VSH_XBOX_SHADER *pShader,
if(pIntermediate->Output.Type != IMD_OUTPUT_R)
{
// TODO: Complete dph support
EmuWarning("Can't simulate dph for other than output r registers (yet)\n");
EmuWarning("Can't simulate dph for other than output r registers (yet)");
// attempt to find unused register...
int outRegister = -1;
@ -1573,7 +1573,7 @@ static void VshConvertToken_NOP(DWORD *pToken)
// D3DVSD_NOP
if(*pToken != DEF_VSH_NOP)
{
EmuWarning("Token NOP found, but extra parameters are given!\n");
EmuWarning("Token NOP found, but extra parameters are given!");
}
DbgVshPrintf("\tD3DVSD_NOP(),\n");
}
@ -1882,7 +1882,7 @@ static void VshConvertToken_STREAMDATA_REG(DWORD *pToken,
if(NewDataType == 0xFF)
{
EmuWarning("/* WARNING: Fatal type mismatch, no fitting type! */\n");
EmuWarning("/* WARNING: Fatal type mismatch, no fitting type! */");
}
}
@ -2046,7 +2046,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
hRet = E_FAIL;
break;
default:
EmuWarning("Unknown vertex shader version 0x%02X\n", pShaderHeader->Version);
EmuWarning("Unknown vertex shader version 0x%02X", pShaderHeader->Version);
hRet = E_FAIL;
break;
}
@ -2104,8 +2104,8 @@ extern HRESULT XTL::EmuRecompileVshFunction
if (FAILED(hRet))
{
EmuWarning("Couldn't assemble recompiled vertex shader\n");
EmuWarning("%s\n", pErrors->GetBufferPointer());
EmuWarning("Couldn't assemble recompiled vertex shader");
EmuWarning("%s", pErrors->GetBufferPointer());
}
if( pErrors )

File diff suppressed because it is too large Load Diff

View File

@ -358,26 +358,27 @@ void EmuGenerateFS(Xbe::TLS *pTLS, void *pTLSData)
#ifdef _DEBUG_TRACE
if (pNewTLS == 0)
{
DbgPrintf("EmuFS (0x%X): TLS Non-Existant (OK)\n", GetCurrentThreadId());
DbgPrintf("EmuFS: TLS Non-Existant (OK)\n");
}
else
{
DbgPrintf("EmuFS (0x%X): TLS Data Dump...\n", GetCurrentThreadId());
DbgPrintf("EmuFS (0x%X): 0x%.08X: ", GetCurrentThreadId(), pNewTLS);
DbgPrintf("EmuFS: TLS Data Dump...\n");
DbgPrintf("EmuFS: 0x%.08X: ", pNewTLS);
uint32 stop = pTLS->dwDataEndAddr - pTLS->dwDataStartAddr + pTLS->dwSizeofZeroFill;
// Note : Use printf instead of DbgPrintf here, which prefixes with GetCurrentThreadId() :
for (uint32 v = 0;v<stop;v++)
{
uint08 *bByte = (uint08*)pNewTLS + v;
DbgPrintf("%.01X", (uint32)*bByte);
if (g_bPrintfOn) printf("%.01X", (uint32)*bByte);
if ((v + 1) % 0x10 == 0 && v + 1<stop)
DbgPrintf("\nEmuFS (0x%X): 0x%.08X: ", GetCurrentThreadId(), ((uint32)pNewTLS + v));
if (g_bPrintfOn) printf("\nEmuFS (0x%X): 0x%.08X: ", GetCurrentThreadId(), ((uint32)pNewTLS + v));
}
DbgPrintf("\n");
if (g_bPrintfOn) printf("\n");
}
#endif
}
@ -435,5 +436,5 @@ void EmuGenerateFS(Xbe::TLS *pTLS, void *pTLSData)
mov fs : [0x14], eax
}
DbgPrintf("EmuFS (0x%X): OrgFS=%d NewFS=%d pTLS=0x%.08X\n", GetCurrentThreadId(), OrgFS, NewFS, pTLS);
DbgPrintf("EmuFS: OrgFS=%d NewFS=%d pTLS=0x%.08X\n", OrgFS, NewFS, pTLS);
}

View File

@ -280,11 +280,11 @@ XBSYSAPI EXPORTNUM(66) xboxkrnl::NTSTATUS NTAPI xboxkrnl::IoCreateFile
if (FAILED(ret))
{
DbgPrintf("EmuKrnl (0x%X): IoCreateFile Failed! (0x%.08X)\n", GetCurrentThreadId(), ret);
EmuWarning("EmuKrnl: IoCreateFile Failed! (0x%.08X)\n", ret);
}
else
{
DbgPrintf("EmuKrnl (0x%X): IoCreateFile = 0x%.08X\n", GetCurrentThreadId(), *FileHandle);
DbgPrintf("EmuKrnl: IoCreateFile = 0x%.08X\n", *FileHandle);
}
RETURN(ret);

View File

@ -180,7 +180,7 @@ XBSYSAPI EXPORTNUM(168) xboxkrnl::PVOID NTAPI xboxkrnl::MmClaimGpuInstanceMemory
MI_CONVERT_PFN_TO_PHYSICAL(MM_INSTANCE_PHYSICAL_PAGE + MM_INSTANCE_PAGE_COUNT);
// Chihiro arcade should use *NumberOfPaddingBytes = 0;
EmuWarning("*NumberOfPaddingBytes = 0x%08X\n", *NumberOfPaddingBytes);
EmuWarning("*NumberOfPaddingBytes = 0x%08X", *NumberOfPaddingBytes);
if (NumberOfBytes != MAXULONG_PTR)
{
@ -238,7 +238,7 @@ XBSYSAPI EXPORTNUM(169) xboxkrnl::PVOID NTAPI xboxkrnl::MmCreateKernelStack
/*Protect=*/PAGE_READWRITE);
if (FAILED(ret))
EmuWarning("MmCreateKernelStack failed!\n");
EmuWarning("MmCreateKernelStack failed!");
else
BaseAddress = (PVOID)((ULONG)BaseAddress + NumberOfBytes);
@ -268,7 +268,7 @@ XBSYSAPI EXPORTNUM(170) xboxkrnl::VOID NTAPI xboxkrnl::MmDeleteKernelStack
/*FreeType=*/MEM_RELEASE);
if (FAILED(ret))
EmuWarning("MmDeleteKernelStack failed!\n");
EmuWarning("MmDeleteKernelStack failed!");
}
// ******************************************************************
@ -545,7 +545,7 @@ XBSYSAPI EXPORTNUM(181) xboxkrnl::NTSTATUS NTAPI xboxkrnl::MmQueryStatistics
}
else
{
EmuWarning("EmuKrnl (0x%X): MmQueryStatistics with unusual size -> 0x%.08X\n", GetCurrentThreadId(), MemoryStatistics->Length);
EmuWarning("EmuKrnl: MmQueryStatistics with unusual size -> 0x%.08X", MemoryStatistics->Length);
ret = STATUS_INVALID_PARAMETER;
}
@ -573,7 +573,7 @@ XBSYSAPI EXPORTNUM(182) xboxkrnl::VOID NTAPI xboxkrnl::MmSetAddressProtect
if (!VirtualProtect(BaseAddress, NumberOfBytes, NewProtect & (~PAGE_WRITECOMBINE), &dwOldProtect))
EmuWarning("VirtualProtect Failed!");
DbgPrintf("EmuKrnl (0x%X): VirtualProtect was 0x%.08X -> 0x%.08X\n", GetCurrentThreadId(), dwOldProtect, NewProtect & (~PAGE_WRITECOMBINE));
DbgPrintf("EmuKrnl: VirtualProtect was 0x%.08X -> 0x%.08X\n", dwOldProtect, NewProtect & (~PAGE_WRITECOMBINE));
}
// ******************************************************************

View File

@ -209,7 +209,7 @@ XBSYSAPI EXPORTNUM(188) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateDirectoryObje
if (FAILED(ret))
EmuWarning("NtCreateDirectoryObject Failed!");
else
DbgPrintf("EmuKrnl (0x%X): NtCreateDirectoryObject DirectoryHandle = 0x%.08X\n", GetCurrentThreadId(), *DirectoryHandle);
DbgPrintf("EmuKrnl: NtCreateDirectoryObject DirectoryHandle = 0x%.08X\n", *DirectoryHandle);
RETURN(ret);
}
@ -253,7 +253,7 @@ XBSYSAPI EXPORTNUM(189) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateEvent
if (FAILED(ret))
EmuWarning("NtCreateEvent Failed!");
else
DbgPrintf("EmuKrnl (0x%X): NtCreateEvent EventHandle = 0x%.08X\n", GetCurrentThreadId(), *EventHandle);
DbgPrintf("EmuKrnl: NtCreateEvent EventHandle = 0x%.08X\n", *EventHandle);
RETURN(ret);
}
@ -322,7 +322,7 @@ XBSYSAPI EXPORTNUM(192) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateMutant
if (FAILED(ret))
EmuWarning("NtCreateMutant Failed!");
else
DbgPrintf("EmuKrnl (0x%X): NtCreateMutant MutantHandle = 0x%.08X\n", GetCurrentThreadId(), *MutantHandle);
DbgPrintf("EmuKrnl: NtCreateMutant MutantHandle = 0x%.08X\n", *MutantHandle);
RETURN(ret);
}
@ -362,7 +362,7 @@ XBSYSAPI EXPORTNUM(193) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateSemaphore
if (FAILED(ret))
EmuWarning("NtCreateSemaphore failed!");
else
DbgPrintf("EmuKrnl (0x%X): NtCreateSemaphore SemaphoreHandle = 0x%.08X\n", GetCurrentThreadId(), *SemaphoreHandle);
DbgPrintf("EmuKrnl: NtCreateSemaphore SemaphoreHandle = 0x%.08X\n", *SemaphoreHandle);
RETURN(ret);
}
@ -402,7 +402,7 @@ XBSYSAPI EXPORTNUM(194) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateTimer
if (FAILED(ret))
EmuWarning("NtCreateTimer failed!");
else
DbgPrintf("EmuKrnl (0x%X): NtCreateTimer TimerHandle = 0x%.08X\n", GetCurrentThreadId(), *TimerHandle);
DbgPrintf("EmuKrnl: NtCreateTimer TimerHandle = 0x%.08X\n", *TimerHandle);
RETURN(ret);
}
@ -919,7 +919,7 @@ XBSYSAPI EXPORTNUM(210) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryFullAttributes
NTToXboxFileInformation(&nativeNetOpenInfo, Attributes, FileNetworkOpenInformation, sizeof(xboxkrnl::FILE_NETWORK_OPEN_INFORMATION));
if (FAILED(ret))
EmuWarning("NtQueryFullAttributesFile failed! (0x%.08X)\n", ret);
EmuWarning("NtQueryFullAttributesFile failed! (0x%.08X)", ret);
RETURN(ret);
}
@ -1196,7 +1196,7 @@ XBSYSAPI EXPORTNUM(217) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryVirtualMemory
ret = STATUS_SUCCESS;
DbgPrintf("EmuKrnl (0x%X): NtQueryVirtualMemory: Applied fix for Forza Motorsport!\n", GetCurrentThreadId());
DbgPrintf("EmuKrnl: NtQueryVirtualMemory: Applied fix for Forza Motorsport!\n");
}
}
@ -1606,7 +1606,7 @@ XBSYSAPI EXPORTNUM(232) xboxkrnl::VOID NTAPI xboxkrnl::NtUserIoApcDispatcher
popad
}
DbgPrintf("EmuKrnl (0x%X): NtUserIoApcDispatcher Completed\n", GetCurrentThreadId());
DbgPrintf("EmuKrnl: NtUserIoApcDispatcher Completed\n");
}
// ******************************************************************

View File

@ -133,7 +133,7 @@ static unsigned int WINAPI PCSTProxy
if (pfnNotificationRoutine == NULL)
continue;
DbgPrintf("EmuKrnl (0x%X): Calling pfnNotificationRoutine[%d] (0x%.08X)\n", GetCurrentThreadId(), g_iThreadNotificationCount, pfnNotificationRoutine);
DbgPrintf("EmuKrnl: Calling pfnNotificationRoutine[%d] (0x%.08X)\n", g_iThreadNotificationCount, pfnNotificationRoutine);
pfnNotificationRoutine(TRUE);
}
@ -299,7 +299,7 @@ XBSYSAPI EXPORTNUM(255) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadE
// *ThreadHandle = CreateThread(NULL, NULL, PCSTProxy, iPCSTProxyParam, NULL, &dwThreadId);
DbgPrintf("EmuKrnl (0x%X): ThreadHandle : 0x%X, ThreadId : 0x%.08X\n", GetCurrentThreadId(), *ThreadHandle, dwThreadId);
DbgPrintf("EmuKrnl: ThreadHandle : 0x%X, ThreadId : 0x%.08X\n", *ThreadHandle, dwThreadId);
// we must duplicate this handle in order to retain Suspend/Resume thread rights from a remote thread
{
@ -377,7 +377,7 @@ XBSYSAPI EXPORTNUM(258) xboxkrnl::VOID NTAPI xboxkrnl::PsTerminateSystemThread
if (pfnNotificationRoutine == NULL)
continue;
DbgPrintf("EmuKrnl (0x%X): Calling pfnNotificationRoutine[%d] (0x%.08X)\n", GetCurrentThreadId(), g_iThreadNotificationCount, pfnNotificationRoutine);
DbgPrintf("EmuKrnl: Calling pfnNotificationRoutine[%d] (0x%.08X)\n", g_iThreadNotificationCount, pfnNotificationRoutine);
pfnNotificationRoutine(FALSE);
}

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,9 @@
#ifndef EMUNV2A_H
#define EMUNV2A_H
// Valid after PCI init :
#define NV20_REG_BASE_KERNEL 0xFD000000
#define NV2A_ADDR 0xFD000000
#define NV2A_SIZE 0x01000000

View File

@ -96,27 +96,27 @@ uint32_t EmuX86_Read32(uint32_t addr)
uint16_t EmuX86_Read16(uint32_t addr)
{
EmuWarning("EmuX86_Read16(0x%08X) Forwarding to EmuX86_Read32...", addr);
DbgPrintf("EmuX86_Read16(0x%08X) Forwarding to EmuX86_Read32...", addr);
uint16_t value;
if (addr & 2)
value = (uint16_t)(EmuX86_Read32(addr - 2) >> 16);
else
value = (uint16_t)EmuX86_Read32(addr);
EmuWarning("EmuX86_Read16(0x%08X) = 0x%04X", addr, value);
DbgPrintf("EmuX86_Read16(0x%08X) = 0x%04X", addr, value);
return value;
}
uint8_t EmuX86_Read8(uint32_t addr)
{
EmuWarning("EmuX86_Read8(0x%08X) Forwarding to EmuX86_Read16...", addr);
DbgPrintf("EmuX86_Read8(0x%08X) Forwarding to EmuX86_Read16...", addr);
uint8_t value;
if (addr & 1)
value = (uint8_t)(EmuX86_Read16(addr - 1) >> 8);
else
value = (uint8_t)EmuX86_Read16(addr);
EmuWarning("EmuX86_Read8(0x%08X) = 0x%02X", addr, value);
DbgPrintf("EmuX86_Read8(0x%08X) = 0x%02X", addr, value);
return value;
}
@ -716,7 +716,7 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
// and check if it successfully decoded one instruction :
if (decodedInstructionsCount != 1)
{
EmuWarning("EmuX86: Error decoding opcode at 0x%08X\n", e->ContextRecord->Eip);
EmuWarning("EmuX86: Error decoding opcode at 0x%08X", e->ContextRecord->Eip);
}
else
{

View File

@ -187,7 +187,7 @@ DWORD WINAPI XTL::EmuXGetDevices
if(DeviceType->Reserved[0] == 0 && DeviceType->Reserved[1] == 0 && DeviceType->Reserved[2] == 0)
ret = (1 << 0); // Return 1 Controller
else
EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X)\n", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2]);
EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X)", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2]);
RETURN(ret);
}
@ -224,7 +224,7 @@ BOOL WINAPI XTL::EmuXGetDeviceChanges
else
{
// TODO: What if it's not a controller?
EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X)\n", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2]);
EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X)", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2]);
}
}
else
@ -735,13 +735,13 @@ LPVOID WINAPI XTL::EmuCreateFiber
LPVOID lpParameter
)
{
DbgPrintf("EmuXapi (0x%X): EmuCreateFiber\n"
DbgPrintf("EmuXapi: EmuCreateFiber\n"
"(\n"
" dwStackSize : 0x%.08X\n"
" lpStartRoutine : 0x%.08X\n"
" lpParameter : 0x%.08X\n"
");\n",
GetCurrentThreadId(), dwStackSize, lpStartRoutine, lpParameter);
dwStackSize, lpStartRoutine, lpParameter);
LPVOID pFiber = CreateFiber( dwStackSize, lpStartRoutine, lpParameter );
if( !pFiber )
@ -767,11 +767,11 @@ VOID WINAPI XTL::EmuDeleteFiber
)
{
DbgPrintf("EmuXapi (0x%X): EmuDeleteFiber\n"
DbgPrintf("EmuXapi: EmuDeleteFiber\n"
"(\n"
" lpFiber : 0x%.08X\n"
");\n",
GetCurrentThreadId(), lpFiber );
lpFiber );
DeleteFiber( lpFiber );
@ -786,11 +786,11 @@ VOID WINAPI XTL::EmuSwitchToFiber
)
{
DbgPrintf("EmuXapi (0x%X): EmuSwitchToFiber\n"
DbgPrintf("EmuXapi: EmuSwitchToFiber\n"
"(\n"
" lpFiber : 0x%.08X\n"
");\n",
GetCurrentThreadId(), lpFiber );
lpFiber );
// SwitchToFiber( lpFiber ); // <- Hangs/crashes...
@ -816,11 +816,11 @@ LPVOID WINAPI XTL::EmuConvertThreadToFiber
LPVOID lpParameter
)
{
DbgPrintf("EmuXapi (0x%X): EmuConvertThreadToFiber\n"
DbgPrintf("EmuXapi: EmuConvertThreadToFiber\n"
"(\n"
" lpParameter : 0x%.08X\n"
");\n",
GetCurrentThreadId(), lpParameter );
lpParameter );
LPVOID pRet = ConvertThreadToFiber( lpParameter );
@ -836,11 +836,11 @@ LPVOID WINAPI XTL::EmuConvertThreadToFiber
VOID WINAPI XTL::EmuXapiFiberStartup(DWORD dwDummy)
{
DbgPrintf("EmuXapi (0x%X): EmuXapiFiberStarup()\n"
DbgPrintf("EmuXapi: EmuXapiFiberStarup()\n"
"(\n"
" dwDummy : 0x%.08X\n"
");\n",
GetCurrentThreadId(), dwDummy);
dwDummy);
typedef void (__stdcall *pfDummyFunc)(DWORD dwDummy);

View File

@ -169,13 +169,14 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead
uint32 LastUnResolvedXRefs = UnResolvedXRefs+1;
uint32 OrigUnResolvedXRefs = UnResolvedXRefs;
bool bFoundD3D = false;
for(int p=0;UnResolvedXRefs < LastUnResolvedXRefs;p++)
{
DbgPrintf("HLE: Starting pass #%d...\n", p+1);
LastUnResolvedXRefs = UnResolvedXRefs;
bool bFoundD3D = false;
for(uint32 v=0;v<dwLibraryVersions;v++)
{
uint16 MajorVersion = pLibraryVersion[v].wMajorVersion;

146
src/CxbxKrnl/device.cpp Normal file
View File

@ -0,0 +1,146 @@
// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
// * Cxbx->Win32->CxbxKrnl->Device.cpp
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2016 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
// ******************************************************************
// Some symbols, code and ideas in here are based on MAME diexec.* :
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
diexec.c
Device execution interfaces.
***************************************************************************/
#include "device.h"
//**************************************************************************
// DEVICE INPUT
//**************************************************************************
//-------------------------------------------------
// device_input - constructor
//-------------------------------------------------
device_execute_interface::device_input::device_input()
: //m_execute(nullptr),
m_linenum(0),
m_stored_vector(0),
m_curvector(0),
m_curstate(CLEAR_LINE),
m_qindex(0)
{
// memset(m_queue, 0, sizeof(m_queue));
}
//-------------------------------------------------
// start - called by interface_pre_start so we
// can set ourselves up
//-------------------------------------------------
void device_execute_interface::device_input::start(device_execute_interface *execute, int linenum)
{
// m_execute = execute;
m_linenum = linenum;
reset();
/*
device_t &device = m_execute->device();
device.save_item(NAME(m_stored_vector), m_linenum);
device.save_item(NAME(m_curvector), m_linenum);
device.save_item(NAME(m_curstate), m_linenum);
*/
}
//-------------------------------------------------
// reset - reset our input states
//-------------------------------------------------
void device_execute_interface::device_input::reset()
{
m_curvector = m_stored_vector = 0; // m_execute->default_irq_vector();
m_qindex = 0;
}
//-------------------------------------------------
// set_state_synced - enqueue an event for later
// execution via timer
//-------------------------------------------------
void device_execute_interface::device_input::set_state_synced(int state, int vector)
{
/*
LOG(("set_state_synced('%s',%d,%d,%02x)\n", m_execute->device().tag(), m_linenum, state, vector));
if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linenum, state, (vector == USE_STORED_VECTOR) ? 0 : vector);
assert(state == ASSERT_LINE || state == HOLD_LINE || state == CLEAR_LINE || state == PULSE_LINE);
*/
// treat PULSE_LINE as ASSERT+CLEAR
if (state == PULSE_LINE)
{
// catch errors where people use PULSE_LINE for devices that don't support it
if (m_linenum != INPUT_LINE_NMI && m_linenum != INPUT_LINE_RESET)
;// throw emu_fatalerror("device '%s': PULSE_LINE can only be used for NMI and RESET lines\n", m_execute->device().tag());
set_state_synced(ASSERT_LINE, vector);
set_state_synced(CLEAR_LINE, vector);
return;
}
// if we're full of events, flush the queue and log a message
int event_index = m_qindex++;
if (event_index >= ARRAY_LENGTH(m_queue))
{
m_qindex--;
// empty_event_queue(nullptr,0);
event_index = m_qindex++;
// m_execute->device().logerror("Exceeded pending input line event queue on device '%s'!\n", m_execute->device().tag());
}
// enqueue the event
if (event_index < ARRAY_LENGTH(m_queue))
{
if (vector == USE_STORED_VECTOR)
vector = m_stored_vector;
m_queue[event_index] = (state & 0xff) | (vector << 8);
// if this is the first one, set the timer
if (event_index == 0)
;// m_execute->scheduler().synchronize(timer_expired_delegate(FUNC(device_execute_interface::device_input::empty_event_queue),this), 0, this);
}
}

163
src/CxbxKrnl/device.h Normal file
View File

@ -0,0 +1,163 @@
// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
// * Cxbx->Win32->CxbxKrnl->Device.h
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2016 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
// ******************************************************************
// Some symbols, code and ideas in here are based on MAME diexec.* :
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
device.h
Device execution interfaces.
***************************************************************************/
#pragma once
#ifndef __CXBX_DEVICE_H__
#define __CXBX_DEVICE_H__
// From MAME osdcomm.h :
//#include <stdio.h>
//#include <string.h>
#include <cstdint>
#include <type_traits>
// Highly useful template for compile-time knowledge of an array size
template <typename T, size_t N> constexpr size_t ARRAY_LENGTH(T (&)[N]) { return N;}
// From MAME emucore.h :
class device_t;
// this macro passes an item followed by a string version of itself as two consecutive parameters
#define NAME(x) x, #x
// this macro wraps a function 'x' and can be used to pass a function followed by its name
#define FUNC(x) &x, #x
// From MAME diexec.h :
// I/O line states
enum line_state
{
CLEAR_LINE = 0, // clear (a fired or held) line
ASSERT_LINE, // assert an interrupt immediately
HOLD_LINE, // hold interrupt line until acknowledged
PULSE_LINE // pulse interrupt line instantaneously (only for NMI, RESET)
};
// I/O line definitions
enum
{
// input lines
MAX_INPUT_LINES = 32+3,
INPUT_LINE_IRQ0 = 0,
INPUT_LINE_IRQ1 = 1,
INPUT_LINE_IRQ2 = 2,
INPUT_LINE_IRQ3 = 3,
INPUT_LINE_IRQ4 = 4,
INPUT_LINE_IRQ5 = 5,
INPUT_LINE_IRQ6 = 6,
INPUT_LINE_IRQ7 = 7,
INPUT_LINE_IRQ8 = 8,
INPUT_LINE_IRQ9 = 9,
INPUT_LINE_NMI = MAX_INPUT_LINES - 3,
// special input lines that are implemented in the core
INPUT_LINE_RESET = MAX_INPUT_LINES - 2,
INPUT_LINE_HALT = MAX_INPUT_LINES - 1
};
//**************************************************************************
// MACROS
//**************************************************************************
#define TIMER_CALLBACK_MEMBER(name) void name(void *ptr, int32_t param)
// IRQ callback to be called by device implementations when an IRQ is actually taken
#define IRQ_CALLBACK_MEMBER(func) int func(device_t &device, int irqline)
// interrupt generator callback called as a VBLANK or periodic interrupt
#define INTERRUPT_GEN_MEMBER(func) void func(device_t &device)
class device_execute_interface
{
public:
// input and interrupt management
void set_input_line(int linenum, int state) { m_input[linenum].set_state_synced(state); }
protected:
// internal information about the state of inputs
class device_input
{
static const int USE_STORED_VECTOR = 0xff000000;
public:
device_input();
void start(device_execute_interface *execute, int linenum);
void reset();
void set_state_synced(int state, int vector = USE_STORED_VECTOR);
void set_vector(int vector) { m_stored_vector = vector; }
int default_irq_callback();
// device_execute_interface *m_execute;// pointer to the execute interface
int m_linenum; // which input line we are
int32_t m_stored_vector; // most recently written vector
int32_t m_curvector; // most recently processed vector
uint8_t m_curstate; // most recently processed state
int32_t m_queue[32]; // queue of pending events
int m_qindex; // index within the queue
private:
// TIMER_CALLBACK_MEMBER(empty_event_queue);
};
// input states and IRQ callbacks
// device_irq_acknowledge_delegate m_driver_irq; // driver-specific IRQ callback
device_input m_input[MAX_INPUT_LINES]; // data about inputs
};
#endif /* __CXBX_DEVICE_H__ */

View File

@ -18,28 +18,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#define NV_NUM_BLOCKS 21
#define NV_PMC 0 /* card master control */
#define NV_PBUS 1 /* bus control */
#define NV_PFIFO 2 /* MMIO and DMA FIFO submission to PGRAPH and VPE */
#define NV_PFIFO_CACHE 3
#define NV_PRMA 4 /* access to BAR0/BAR1 from real mode */
#define NV_PVIDEO 5 /* video overlay */
#define NV_PTIMER 6 /* time measurement and time-based alarms */
#define NV_PCOUNTER 7 /* performance monitoring counters */
#define NV_PVPE 8 /* MPEG2 decoding engine */
#define NV_PTV 9 /* TV encoder */
#define NV_PRMFB 10 /* aliases VGA memory window */
#define NV_PRMVIO 11 /* aliases VGA sequencer and graphics controller registers */
#define NV_PFB 12 /* memory interface */
#define NV_PSTRAPS 13 /* straps readout / override */
#define NV_PGRAPH 14 /* accelerated 2d/3d drawing engine */
#define NV_PCRTC 15 /* more CRTC controls */
#define NV_PRMCIO 16 /* aliases VGA CRTC and attribute controller registers */
#define NV_PRAMDAC 17 /* RAMDAC, cursor, and PLL control */
#define NV_PRMDIO 18 /* aliases VGA palette registers */
#define NV_PRAMIN 19 /* RAMIN access */
#define NV_USER 20 /* PFIFO MMIO and DMA submission area */
#define NV_PMC_BOOT_0 0x00000000
#define NV_PMC_INTR_0 0x00000100