// ****************************************************************** // * EmuIXACTSoundBank_Play // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTSoundBank_Play ( X_XACTSoundBank* pThis, DWORD dwSoundCueIndex, X_XACTSoundSource* pSoundSource, DWORD dwFlags, X_XACTSoundCue** ppSoundCue ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTSoundBank_Play\n" "(\n" " pThis : 0x%.08X\n" " dwSoundCueIndex : 0x%.08X\n" " pSoundSource : 0x%.08X\n" " dwFlags : 0x%.08X\n" " ppSoundCue : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, dwSoundCueIndex, pSoundSource, dwFlags, ppSoundCue); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_CreateSoundBank // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_CreateSoundBank ( X_XACTEngine* pThis, LPVOID pvData, DWORD dwSize, X_XACTSoundBank** ppSoundBank ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_CreateSoundBank\n" "(\n" " pThis : 0x%.08X\n" " pvData : 0x%.08X\n" " dwSize : 0x%.08X\n" " ppSoundBank : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, pvData, dwSize, ppSoundBank); // TODO: Implement *ppSoundBank = (X_XACTSoundBank*) CxbxMalloc( sizeof( X_XACTSoundBank ) ); EmuSwapFS(); // Xbox FS return S_OK; }
// ****************************************************************** // * EmuIXACTSoundSource_SetVelocity // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTSoundSource_SetVelocity ( X_XACTSoundSource* pThis, FLOAT x, FLOAT y, FLOAT z, DWORD dwApply ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTSoundSource_SetVelocity\n" "(\n" " pThis : 0x%.08X\n" " x : %f\n" " y : %f\n" " z : %f\n" " dwApply : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, x, y, z, dwApply); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_SetListenerVelocity // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_SetListenerVelocity ( X_XACTEngine* pThis, float x, float y, float z, DWORD dwApply ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_SetListenerVelocity\n" "(\n" " pThis : 0x%.08X\n" " x : %f" " y : %f" " z : %f" " dwApply : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, x, y, z, dwApply); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_SetListenerOrientation // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_SetListenerOrientation ( X_XACTEngine* pThis, float xFront, float yFront, float zFront, float xTop, float yTop, float zTop, DWORD dwApply ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_SetListenerOrientation\n" "(\n" " pThis : 0x%.08X\n" " xFront : %f" " yFront : %f" " zFront : %f" " xTop : %f" " yTop : %f" " zTop : %f" " dwApply : 0x%.08X" ");\n", GetCurrentThreadId(), pThis, xFront, yFront, zFront, xTop, yTop, zTop, dwApply); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_DownloadEffectsImage // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_DownloadEffectsImage ( X_XACTEngine* pThis, PVOID pvData, DWORD dwSize, LPVOID pEffectLoc, LPVOID* ppImageDesc ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_DownloadEffectsImage\n" "(\n" " pThis : 0x%.08X\n" " pvData : 0x%.08X\n" " dwSize : 0x%.08X\n" " pEffectLoc : 0x%.08X\n" " ppImageDesc : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, dwSize, pEffectLoc, ppImageDesc); // TODO: Implement EmuSwapFS(); // Xbox FS return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_RegisterStreamedWaveBank // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_RegisterStreamedWaveBank ( X_XACTEngine* pThis, X_XACT_WAVEBANK_STREAMING_PARAMETERS* pParams, X_XACTWaveBank** ppWaveBank ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_RegisterWaveBank\n" "(\n" " pThis : 0x%.08X\n" " pParams : 0x%.08X\n" " ppWaveBank : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, pParams, ppWaveBank); // TODO: Implement *ppWaveBank = (X_XACTWaveBank*) CxbxMalloc( sizeof( X_XACTWaveBank ) ); EmuSwapFS(); // Xbox FS return S_OK; }
extern "C" CXBXKRNL_API void CxbxKrnlNoFunc() { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuMain (0x%X): CxbxKrnlNoFunc()\n", GetCurrentThreadId()); EmuSwapFS(); // XBox FS }
extern "C" CXBXKRNL_API void CxbxKrnlPanic() { if(EmuIsXboxFS()) EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuMain (0x%X): CxbxKrnlPanic()\n", GetCurrentThreadId()); CxbxKrnlCleanup("Kernel Panic!"); EmuSwapFS(); // XBox FS }
// ****************************************************************** // * EmuIXACTEngine_CommitDeferredSettings // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_CommitDeferredSettings(X_XACTEngine* pThis) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_CommitDeferredSettings\n" "(\n" " pThis : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuXACTEngineDoWork // ****************************************************************** void WINAPI XTL::EmuXACTEngineDoWork() { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuXACTEngineCreate()\n", GetCurrentThreadId() ); // TODO: Anything else required here? // AFAIK, this function just calls DirectSoundDoWork() //EmuSwapFS(); //EmuDirectSoundDoWork(); //EmuSwapFS(); EmuSwapFS(); // Xbox FS }
extern "C" CXBXKRNL_API void CxbxKrnlTerminateThread() { if(EmuIsXboxFS()) EmuSwapFS(); // Win2k/XP FS EmuCleanupFS(); TerminateThread(GetCurrentThread(), 0); }
// ****************************************************************** // * EmuIXACTEngine_RegisterNotification // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_RegisterNotification ( X_XACTEngine* pThis, PCXACT_NOTIFICATION_DESCRIPTION pNotificationDesc ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_RegisterNotification\n" "(\n" " pThis : 0x%.08X\n" " pNotificationDesc : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, pNotificationDesc); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_EnableHeadphones // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_EnableHeadphones ( X_XACTEngine* pThis, BOOL fEnabled ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_EnableHeadphones\n" "(\n" " pThis : 0x%.08X\n" " fEnabled : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, fEnabled); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTSoundBank_GetSoundCueIndexFromFriendlyName // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTSoundBank_GetSoundCueIndexFromFriendlyName ( X_XACTEngine* pThis, PCSTR pFriendlyName, DWORD* pdwSoundCueIndex ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTSoundBank_GetSoundCueIndexFromFriendlyName\n" "(\n" " pThis : 0x%.08X\n" " pFriendlyName : (%s)\n" " pdwSoundCueIndex : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, pFriendlyName, pdwSoundCueIndex); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_SetMasterVolume // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_SetMasterVolume ( X_XACTEngine* pThis, WORD wCategory, LONG lVolume ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_SetMasterVolume\n" "(\n" " pThis : 0x%.08X\n" " wCategory : 0x%.08X\n" " lVolume : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, wCategory, lVolume); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * func: EmuXGIsSwizzledFormat // ****************************************************************** PVOID WINAPI XTL::EmuXGIsSwizzledFormat ( XTL::D3DFORMAT Format ) { // ****************************************************************** // * debug trace // ****************************************************************** #ifdef _DEBUG_TRACE { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGIsSwizzledFormat\n" "(\n" " Format : 0x%.08X\n" ");\n", GetCurrentThreadId(), Format); EmuSwapFS(); // Xbox FS } #endif return FALSE; }
// ****************************************************************** // * func: EmuXACTEngineCreate // ****************************************************************** HRESULT WINAPI XTL::EmuXACTEngineCreate ( X_XACT_RUNTIME_PARAMETERS* pParams, X_XACTEngine** ppEngine ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuXACTEngineCreate\n" "(\n" " pParams : 0x%.08X\n" " ppEngine : 0x%.08X\n" ");\n", GetCurrentThreadId(), pParams, ppEngine); // TODO: Any other form of initialization? *ppEngine = (X_XACTEngine*) CxbxMalloc( sizeof( X_XACTEngine ) ); EmuSwapFS(); // Xbox FS return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_CreateSoundSource // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_CreateSoundSource ( X_XACTEngine* pThis, DWORD dwFlags, X_XACTSoundSource** ppSoundSource ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_CreateSoundSource\n" "(\n" " pThis : 0x%.08X\n" " dwFlags : 0x%.08X\n" " ppSoundSource : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, dwFlags, ppSoundSource); *ppSoundSource = (X_XACTSoundSource*) CxbxMalloc( sizeof( X_XACTSoundSource ) ); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_GetNotification // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_GetNotification ( X_XACTEngine* pThis, PCXACT_NOTIFICATION_DESCRIPTION pNotificationDesc, LPVOID pNotification ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_GetNotification\n" "(\n" " pThis : 0x%.08X\n" " pNotificationDesc : 0x%.08X\n" " pNotification : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, pNotificationDesc, pNotification); // TODO: The contents of XACT_NOTIFICATION can vary from one XDK to the next. // The definition for 4627 is different than 5558. EmuSwapFS(); return S_OK; }
// ****************************************************************** // * func: EmuXGSetTextureHeader // ****************************************************************** VOID WINAPI XTL::EmuXGSetTextureHeader ( UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, X_D3DTexture* pTexture, UINT Data, UINT Pitch ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGSetTextureHeader\n" "(\n" " Width : 0x%.08X\n" " Height : 0x%.08X\n" " Levels : 0x%.08X\n" " Usage : 0x%.08X\n" " Format : 0x%.08X\n" " Pool : 0x%.08X\n" " pTexture : 0x%.08X\n" " Data : 0x%.08X\n" " Pitch : 0x%.08X\n" ");\n", GetCurrentThreadId(), Width, Height, Levels, Usage, Format, Pool, pTexture, Data, Pitch); // NOTES: This function simply creates a texture that needs to be registered // via D3DDevice_Register afterwards. So, do I just create the texture via // EmuIDirect3DDevice8_CreateTexture, or just fill in the interface and let // EmuIDirect3DDevice8_Register do the rest? Trial and error. X_D3DTexture* pTempTexture = NULL; DWORD l2w = (DWORD) log( (float)Width ) / log(2.0f); DWORD l2h = (DWORD) log( (float)Height ) / log(2.0f); /*if( Data != 0 ) CxbxKrnlCleanup( "Data != 0 (XGSetTextureHeader)" ); if( Pitch != 0 ) CxbxKrnlCleanup( "Pitch != 0 (XGSetTextureHeader)" );*/ // Generate a temporary texture and fill in the necessary fields within // the X_D3DTexture interface (lazy, I know). EmuSwapFS(); pTempTexture = (X_D3DTexture*) XTL::EmuIDirect3DDevice8_CreateTexture2(Width, Height, 0, Levels, Usage, Format, XTL::D3DRTYPE_TEXTURE); EmuSwapFS(); pTexture->Data = pTempTexture->Data; pTexture->Common = X_D3DCOMMON_TYPE_TEXTURE; //pTempTexture->Common; // pTexture->Format = pTempTexture->Format; pTexture->Lock = pTempTexture->Lock; // 0; pTexture->Size = pTempTexture->Size; EmuSwapFS(); XTL::EmuIDirect3DResource8_Release(pTempTexture); EmuSwapFS(); // Manually fill in Format parameters /*pTexture->Format |= ( ( ( Width >> 1 ) & 0xF ) << X_D3DFORMAT_USIZE_SHIFT ) | // Width ( ( ( Height>> 1 ) & 0xF ) << X_D3DFORMAT_VSIZE_SHIFT ) | // Height ( ( ( Levels ) & 0xF ) << X_D3DFORMAT_MIPMAP_SHIFT ) | // Mip Levels // ( ( ( ((DWORD)Format)) & 0xFF ) << X_D3DFORMAT_FORMAT_SHIFT ) | // Format (Already set) ( ( ( 2 ) & 0xF ) << X_D3DFORMAT_DIMENSION_SHIFT ); // Dimensions */ pTexture->Format |= ( ( l2w & 0xF ) << X_D3DFORMAT_USIZE_SHIFT ); pTexture->Format |= ( ( l2h & 0xF ) << X_D3DFORMAT_VSIZE_SHIFT ); pTexture->Format |= ( ( Levels & 0xF ) << X_D3DFORMAT_MIPMAP_SHIFT ); pTexture->Format |= ( ( ( ((DWORD)Format)) & 0xFF ) << X_D3DFORMAT_FORMAT_SHIFT ); pTexture->Format |= ( ( 2 & 0xF ) << X_D3DFORMAT_DIMENSION_SHIFT ); // D3DCOLOR_XRGB( DbgPrintf( "pTexture->Format:= 0x%.08X\n", pTexture->Format ); EmuSwapFS(); // Xbox FS }
extern "C" CXBXKRNL_API void CxbxKrnlInit ( HWND hwndParent, void *pTLSData, Xbe::TLS *pTLS, Xbe::LibraryVersion *pLibraryVersion, DebugMode DbgMode, char *szDebugFilename, Xbe::Header *pXbeHeader, uint32 dwXbeHeaderSize, void (*Entry)()) { // update caches CxbxKrnl_TLS = pTLS; CxbxKrnl_TLSData = pTLSData; CxbxKrnl_XbeHeader = pXbeHeader; CxbxKrnl_hEmuParent = IsWindow(hwndParent) ? hwndParent : NULL; // for unicode conversions setlocale(LC_ALL, "English"); // debug console allocation (if configured) if(DbgMode == DM_CONSOLE) { if(AllocConsole()) { freopen("CONOUT$", "wt", stdout); freopen("CONIN$", "rt", stdin); SetConsoleTitle("Cxbx : Kernel Debug Console"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); printf("EmuMain (0x%X): Cxbx Version %s\n", GetCurrentThreadId(), _CXBX_VERSION); printf("EmuMain (0x%X): Debug Console Allocated (DM_CONSOLE).\n", GetCurrentThreadId()); } } else if(DbgMode == DM_FILE) { FreeConsole(); freopen(szDebugFilename, "wt", stdout); printf("EmuMain (0x%X): Cxbx Version %s\n", GetCurrentThreadId(), _CXBX_VERSION); printf("EmuMain (0x%X): Debug Console Allocated (DM_FILE).\n", GetCurrentThreadId()); } else { FreeConsole(); char buffer[16]; if(GetConsoleTitle(buffer, 16) != NULL) freopen("nul", "w", stdout); } // // debug trace // { #ifdef _DEBUG_TRACE printf("EmuMain (0x%X): Debug Trace Enabled.\n", GetCurrentThreadId()); printf("EmuMain (0x%X): CxbxKrnlInit\n" "(\n" " hwndParent : 0x%.08X\n" " pTLSData : 0x%.08X\n" " pTLS : 0x%.08X\n" " pLibraryVersion : 0x%.08X\n" " DebugConsole : 0x%.08X\n" " DebugFilename : \"%s\"\n" " pXBEHeader : 0x%.08X\n" " pXBEHeaderSize : 0x%.08X\n" " Entry : 0x%.08X\n" ");\n", GetCurrentThreadId(), hwndParent, pTLSData, pTLS, pLibraryVersion, DbgMode, szDebugFilename, pXbeHeader, dwXbeHeaderSize, Entry); #else printf("EmuMain (0x%X): Debug Trace Disabled.\n", GetCurrentThreadId()); #endif } // // load the necessary pieces of XbeHeader // { Xbe::Header *MemXbeHeader = (Xbe::Header*)0x00010000; uint32 old_protection = 0; VirtualProtect(MemXbeHeader, 0x1000, PAGE_READWRITE, &old_protection); // we sure hope we aren't corrupting anything necessary for an .exe to survive :] MemXbeHeader->dwSizeofHeaders = pXbeHeader->dwSizeofHeaders; MemXbeHeader->dwCertificateAddr = pXbeHeader->dwCertificateAddr; MemXbeHeader->dwPeHeapReserve = pXbeHeader->dwPeHeapReserve; MemXbeHeader->dwPeHeapCommit = pXbeHeader->dwPeHeapCommit; memcpy(&MemXbeHeader->dwInitFlags, &pXbeHeader->dwInitFlags, sizeof(pXbeHeader->dwInitFlags)); memcpy((void*)pXbeHeader->dwCertificateAddr, &((uint08*)pXbeHeader)[pXbeHeader->dwCertificateAddr - 0x00010000], sizeof(Xbe::Certificate)); } // // initialize current directory // { char szBuffer[260]; g_EmuShared->GetXbePath(szBuffer); if(szBuffer && *szBuffer) SetCurrentDirectory(szBuffer); else GetCurrentDirectory(260, szBuffer); g_strCurDrive = _strdup(szBuffer); g_hCurDir = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if(g_hCurDir == INVALID_HANDLE_VALUE) CxbxKrnlCleanup("Could not map D:\\\n"); DbgPrintf("EmuMain (0x%X): CurDir := %s\n", GetCurrentThreadId(), szBuffer); } // // initialize EmuDisk // { char szBuffer[260]; SHGetSpecialFolderPath(NULL, szBuffer, CSIDL_APPDATA, TRUE); strcat(szBuffer, "\\Cxbx\\"); CreateDirectory(szBuffer, NULL); sint32 spot = -1; for(int v=0;v<260;v++) { if(szBuffer[v] == '\\') { spot = v; } else if(szBuffer[v] == '\0') { break; } } if(spot != -1) { szBuffer[spot] = '\0'; } Xbe::Certificate *pCertificate = (Xbe::Certificate*)pXbeHeader->dwCertificateAddr; // // create EmuDisk directory // strcpy(&szBuffer[spot], "\\EmuDisk"); CreateDirectory(szBuffer, NULL); // // create T:\ directory // { strcpy(&szBuffer[spot], "\\EmuDisk\\T"); CreateDirectory(szBuffer, NULL); sprintf(&szBuffer[spot+10], "\\%08x", pCertificate->dwTitleId); CreateDirectory(szBuffer, NULL); g_strTDrive = _strdup(szBuffer); g_hTDrive = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if(g_hTDrive == INVALID_HANDLE_VALUE) CxbxKrnlCleanup("Could not map T:\\\n"); DbgPrintf("EmuMain (0x%X): T Data := %s\n", GetCurrentThreadId(), szBuffer); } // // create U:\ directory // { strcpy(&szBuffer[spot], "\\EmuDisk\\U"); CreateDirectory(szBuffer, NULL); sprintf(&szBuffer[spot+10], "\\%08x", pCertificate->dwTitleId); CreateDirectory(szBuffer, NULL); g_strUDrive = _strdup(szBuffer); g_hUDrive = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if(g_hUDrive == INVALID_HANDLE_VALUE) CxbxKrnlCleanup("Could not map U:\\\n"); DbgPrintf("EmuMain (0x%X): U Data := %s\n", GetCurrentThreadId(), szBuffer); } // // create Z:\ directory // { strcpy(&szBuffer[spot], "\\EmuDisk\\Z"); CreateDirectory(szBuffer, NULL); //* is it necessary to make this directory title unique? sprintf(&szBuffer[spot+10], "\\%08x", pCertificate->dwTitleId); CreateDirectory(szBuffer, NULL); //*/ g_strZDrive = _strdup(szBuffer); g_hZDrive = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if(g_hUDrive == INVALID_HANDLE_VALUE) CxbxKrnlCleanup("Could not map Z:\\\n"); DbgPrintf("EmuMain (0x%X): Z Data := %s\n", GetCurrentThreadId(), szBuffer); } } // // initialize FS segment selector // { EmuInitFS(); EmuGenerateFS(pTLS, pTLSData); } // // duplicate handle in order to retain Suspend/Resume thread rights from a remote thread // { HANDLE hDupHandle = NULL; DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hDupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS); CxbxKrnlRegisterThread(hDupHandle); } // // Clear critical section list // //extern void InitializeSectionStructures(void); InitializeSectionStructures(); DbgPrintf("EmuMain (0x%X): Initializing Direct3D.\n", GetCurrentThreadId()); XTL::EmuD3DInit(pXbeHeader, dwXbeHeaderSize); EmuHLEIntercept(pLibraryVersion, pXbeHeader); DbgPrintf("EmuMain (0x%X): Initial thread starting.\n", GetCurrentThreadId()); // // Xbe entry point // __try { EmuSwapFS(); // XBox FS // _USE_XGMATH Disabled in mesh :[ // halo : dword_0_2E2D18 // halo : 1744F0 (bink) //_asm int 3; /* for(int v=0;v<sizeof(funcAddr)/sizeof(uint32);v++) { bool bExclude = false; for(int r=0;r<sizeof(funcExclude)/sizeof(uint32);r++) { if(funcAddr[v] == funcExclude[r]) { bExclude = true; break; } } if(!bExclude) { *(uint08*)(funcAddr[v]) = 0xCC; } } //*/ Entry(); EmuSwapFS(); // Win2k/XP FS } __except(EmuException(GetExceptionInformation())) { printf("Emu: WARNING!! Problem with ExceptionFilter\n"); } DbgPrintf("EmuMain (0x%X): Initial thread ended.\n", GetCurrentThreadId()); fflush(stdout); CxbxKrnlTerminateThread(); return; }
// ****************************************************************** // * func: EmuXGSwizzleRect // ****************************************************************** VOID WINAPI XTL::EmuXGSwizzleRect ( LPCVOID pSource, DWORD Pitch, LPCRECT pRect, LPVOID pDest, DWORD Width, DWORD Height, CONST LPPOINT pPoint, DWORD BytesPerPixel ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGSwizzleRect\n" "(\n" " pSource : 0x%.08X\n" " Pitch : 0x%.08X\n" " pRect : 0x%.08X\n" " pDest : 0x%.08X\n" " Width : 0x%.08X\n" " Height : 0x%.08X\n" " pPoint : 0x%.08X\n" " BytesPerPixel : 0x%.08X\n" ");\n", GetCurrentThreadId(), pSource, Pitch, pRect, pDest, Width, Height, pPoint, BytesPerPixel); if(pRect == NULL && pPoint == NULL && Pitch == 0) { memcpy(pDest, pSource, Width*Height*BytesPerPixel); } else { if(pPoint != NULL && (pPoint->x != 0 || pPoint->y != 0)) CxbxKrnlCleanup("Temporarily unsupported swizzle (very easy fix)"); DWORD dwMaxY = Height; DWORD dwChunkSize = Width; uint08 *pSrc = (uint08*)pSource; uint08 *pDst = (uint08*)pDest; if(pRect != 0) { pSrc += pRect->top*Pitch; pSrc += pRect->left; dwMaxY = pRect->bottom - pRect->top; dwChunkSize = pRect->right - pRect->left; } for(DWORD y=0;y<dwMaxY;y++) { memcpy(pSrc, pDst, dwChunkSize); pSrc += Pitch; pDst += Pitch; } } EmuSwapFS(); // Xbox FS return; }
// ****************************************************************** // * func: EmuXGSwizzleBox // ****************************************************************** VOID WINAPI XTL::EmuXGSwizzleBox ( LPCVOID pSource, DWORD RowPitch, DWORD SlicePitch, CONST D3DBOX *pBox, LPVOID pDest, DWORD Width, DWORD Height, DWORD Depth, CONST XGPOINT3D *pPoint, DWORD BytesPerPixel ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGSwizzleBox\n" "(\n" " pSource : 0x%.08X\n" " RowPitch : 0x%.08X\n" " SlicePitch : 0x%.08X\n" " pBox : 0x%.08X\n" " pDest : 0x%.08X\n" " Width : 0x%.08X\n" " Height : 0x%.08X\n" " Depth : 0x%.08X\n" " pPoint : 0x%.08X\n" " BytesPerPixel : 0x%.08X\n" ");\n", GetCurrentThreadId(), pSource, RowPitch, SlicePitch, pBox, pDest, Width, Height, Depth, pPoint, BytesPerPixel); if(pDest != (LPVOID) 0x80000000) { if(pBox == NULL && pPoint == NULL && RowPitch == 0 && SlicePitch == 0) { memcpy(pDest, pSource, Width*Height*Depth*BytesPerPixel); } else { if(pPoint != NULL && (pPoint->u != 0 || pPoint->v != 0 || pPoint->w != 0)) CxbxKrnlCleanup("Temporarily unsupported swizzle (very easy fix)"); DWORD dwMaxY = Height; DWORD dwMaxZ = Depth; DWORD dwChunkSize = Width; uint08 *pSrc = (uint08*)pSource; uint08 *pDst = (uint08*)pDest; if(pBox != 0) { pSrc += pBox->Top*RowPitch; pSrc += pBox->Left; dwMaxY = pBox->Bottom - pBox->Top; dwChunkSize = pBox->Right - pBox->Left; } for(DWORD y=0;y<dwMaxY;y++) { memcpy(pSrc, pDst, dwChunkSize); pSrc += RowPitch; pDst += RowPitch; } } } EmuSwapFS(); // Xbox FS return; }