Huge logging refactoring (doesn't build yet)
This commit is contained in:
parent
47f79d29d7
commit
069767174c
|
@ -34,6 +34,8 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::EEPR
|
||||
#define LOG_PREFIX_INIT CXBXR_MODULE::INIT
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
@ -128,7 +130,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
/* hTemplateFile */nullptr);
|
||||
if (hFileEEPROM == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DbgPrintf("INIT: Couldn't create EEPROM.bin file!\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Couldn't create EEPROM.bin file!\n");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +148,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
/**/nullptr);
|
||||
if (hFileMappingEEPROM == NULL)
|
||||
{
|
||||
DbgPrintf("INIT: Couldn't create EEPROM.bin file mapping!\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Couldn't create EEPROM.bin file mapping!\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -155,7 +157,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
unsigned int FileSize = len_li.u.LowPart;
|
||||
if (FileSize != 256)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestoreEEPROM : EEPROM.bin file is not 256 bytes large!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : EEPROM.bin file is not 256 bytes large!\n", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -167,7 +169,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
/* dwFileOffsetLow */0,
|
||||
EEPROM_SIZE);
|
||||
if (pEEPROM == nullptr) {
|
||||
DbgPrintf("INIT: Couldn't map EEPROM.bin into memory!\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Couldn't map EEPROM.bin into memory!\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -183,12 +185,12 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
// This must be done last to include all initialized data in the CRC
|
||||
gen_section_CRCs(pEEPROM);
|
||||
|
||||
DbgPrintf("INIT: Initialized default EEPROM\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Initialized default EEPROM\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
XboxFactoryGameRegion = pEEPROM->EncryptedSettings.GameRegion;
|
||||
DbgPrintf("INIT: Loaded EEPROM.bin\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Loaded EEPROM.bin\n");
|
||||
}
|
||||
|
||||
// Read the HDD (and eventually also the online) keys stored in the eeprom file. Users can input them in the eeprom menu
|
||||
|
@ -200,7 +202,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
if (memcmp(Checksum, pEEPROM->EncryptedSettings.Checksum, 20))
|
||||
{
|
||||
// The checksums do not match. Log this error and flash the LED (red, off, red, off)
|
||||
EmuWarning("Stored and calculated checksums don't match. Possible eeprom corruption");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Stored and calculated checksums don't match. Possible eeprom corruption");
|
||||
SetLEDSequence(0xA0);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,437 +32,438 @@
|
|||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#if 0 // Reenable this when LLE USB actually works
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// ******************************************************************
|
||||
#if 0 // Reenable this when LLE USB actually works
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::SDL2
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
{
|
||||
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
|
||||
};
|
||||
|
||||
#include "InputConfig.h"
|
||||
#include "SDL2_Device.h"
|
||||
#include "..\devices\usb\XidGamepad.h"
|
||||
#include "..\..\CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include <thread>
|
||||
|
||||
|
||||
InputDeviceManager* g_InputDeviceManager = nullptr;
|
||||
|
||||
InputDeviceManager::InputDeviceManager()
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
|
||||
CxbxKrnlCleanup("Failed to initialize SDL2 input subsystem. The error was: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
InputDeviceManager::~InputDeviceManager()
|
||||
{
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
int InputDeviceManager::EnumSdl2Devices()
|
||||
{
|
||||
int NumOfJoysticks;
|
||||
int NumInvalidJoysticks;
|
||||
SDL2Devices* pDev;
|
||||
SDL_Joystick* pJoystick;
|
||||
std::vector<SDL2Devices*>::iterator it;
|
||||
|
||||
NumOfJoysticks = SDL_NumJoysticks();
|
||||
if (NumOfJoysticks < 0) {
|
||||
EmuWarning("Failed to enumerate joysticks. The error was: %s", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
NumInvalidJoysticks = 0;
|
||||
|
||||
for (int i = 0; i < NumOfJoysticks; i++) {
|
||||
pDev = new SDL2Devices();
|
||||
pDev->m_Index = i;
|
||||
m_Sdl2Devices.push_back(pDev);
|
||||
}
|
||||
|
||||
for (it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end();) {
|
||||
pJoystick = SDL_JoystickOpen((*it)->m_Index);
|
||||
if (pJoystick == nullptr) {
|
||||
EmuWarning("Failed to open joystick %s. The error was %s\n", SDL_GameControllerNameForIndex((*it)->m_Index), SDL_GetError());
|
||||
delete (*it);
|
||||
it = m_Sdl2Devices.erase(it);
|
||||
NumInvalidJoysticks++;
|
||||
}
|
||||
else {
|
||||
printf("Found joystick %s\n", SDL_JoystickName(pJoystick));
|
||||
(*it)->m_Joystick = pJoystick;
|
||||
(*it)->m_jyID = SDL_JoystickInstanceID(pJoystick);
|
||||
(*it)->m_Attached = 1;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
return NumOfJoysticks - NumInvalidJoysticks;
|
||||
}
|
||||
|
||||
int InputDeviceManager::ConnectDeviceToXbox(int port, int type)
|
||||
{
|
||||
int ret = -1;
|
||||
std::vector<SDL2Devices*>::iterator it;
|
||||
|
||||
if (port > 4 || port < 1) { return ret; };
|
||||
|
||||
for (it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end(); ++it) {
|
||||
if ((*it)->m_Index == (port - 1)) {
|
||||
--port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (it == m_Sdl2Devices.end()) {
|
||||
EmuWarning("Attempted to connect a device not yet enumerated.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MS_CONTROLLER_DUKE: {
|
||||
if (g_HubObjArray[port] == nullptr) {
|
||||
g_HubObjArray[port] = new Hub;
|
||||
ret = g_HubObjArray[port]->Init(port + 1);
|
||||
if (ret) {
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
break;
|
||||
}
|
||||
if (g_XidControllerObjArray[port] == nullptr) {
|
||||
g_XidControllerObjArray[port] = new XidGamepad;
|
||||
ret = g_XidControllerObjArray[port]->Init(port + 1);
|
||||
if (ret) {
|
||||
g_HubObjArray[port]->HubDestroy();
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
delete g_XidControllerObjArray[port];
|
||||
g_XidControllerObjArray[port] = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret = -1;
|
||||
g_HubObjArray[port]->HubDestroy();
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
EmuWarning("Xid controller already present at port %d.2\n", port + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
EmuWarning("Hub already present at port %d\n", port + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MS_CONTROLLER_S:
|
||||
case LIGHT_GUN:
|
||||
case STEERING_WHEEL:
|
||||
case MEMORY_UNIT:
|
||||
case IR_DONGLE:
|
||||
case STEEL_BATTALION_CONTROLLER: {
|
||||
printf("This device type is not yet supported\n");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
EmuWarning("Attempted to attach an unknown device type\n");
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
(*it)->m_Type = type;
|
||||
(*it)->m_Attached = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InputDeviceManager::DisconnectDeviceFromXbox(int port)
|
||||
{
|
||||
std::vector<SDL2Devices*>::iterator it;
|
||||
|
||||
if (port < 1) { return; }
|
||||
|
||||
for (it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end(); ++it) {
|
||||
if ((*it)->m_Index == (port - 1)) {
|
||||
--port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (it == m_Sdl2Devices.end()) {
|
||||
// Not necessarily a bug. This could also be triggered by detaching an unsupported joystick
|
||||
return;
|
||||
}
|
||||
|
||||
if (port + 1 > 4) {
|
||||
delete (*it);
|
||||
m_Sdl2Devices.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((*it)->m_Type)
|
||||
{
|
||||
case MS_CONTROLLER_DUKE: {
|
||||
if (g_HubObjArray[port] != nullptr && g_XidControllerObjArray[port] != nullptr) {
|
||||
g_HubObjArray[port]->HubDestroy();
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
delete g_XidControllerObjArray[port];
|
||||
g_XidControllerObjArray[port] = nullptr;
|
||||
delete (*it);
|
||||
m_Sdl2Devices.erase(it);
|
||||
// Here, we could also see if there are detached devices that have a matching type and bound buttons, so that it can immediately
|
||||
// be used instead of remaining inactive (example: 5 controllers and 1st is detached -> 5th can be used if it has bindings)
|
||||
}
|
||||
else {
|
||||
EmuWarning("Attempted to disconnect a device not attached to the Xbox.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MS_CONTROLLER_S:
|
||||
case LIGHT_GUN:
|
||||
case STEERING_WHEEL:
|
||||
case MEMORY_UNIT:
|
||||
case IR_DONGLE:
|
||||
case STEEL_BATTALION_CONTROLLER: {
|
||||
printf("This device type is not yet supported\n");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
EmuWarning("Attempted to detach an unknown device type\n");
|
||||
}
|
||||
}
|
||||
|
||||
void InputDeviceManager::StartInputThread()
|
||||
{
|
||||
std::thread(InputThread, this).detach();
|
||||
}
|
||||
|
||||
void InputDeviceManager::InputThread(InputDeviceManager* pVoid)
|
||||
{
|
||||
bool bContinue = true;
|
||||
SDL_Event event;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
|
||||
CxbxKrnlCleanup("Failed to initialize SDL2 video subsystem. The error was: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
|
||||
while (bContinue)
|
||||
{
|
||||
if (SDL_WaitEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_JOYBUTTONUP:
|
||||
case SDL_JOYBUTTONDOWN: {
|
||||
pVoid->UpdateButtonState(event.jbutton.which, event.jbutton.button, event.jbutton.state);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYHATMOTION: {
|
||||
pVoid->UpdateHatState(event.jhat.which, event.jhat.hat, event.jhat.value);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYAXISMOTION: {
|
||||
pVoid->UpdateAxisState(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEADDED: {
|
||||
bool found = false;
|
||||
for (auto dev : pVoid->m_Sdl2Devices) {
|
||||
if (dev->m_Index == event.jdevice.which) {
|
||||
// already enumerated, skipping
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// for now we only support a single controller at port 1, more will be added later
|
||||
if (!pVoid->IsValidController(event.jdevice.which) && event.jdevice.which == 0) {
|
||||
pVoid->ConnectDeviceToXbox(1, MS_CONTROLLER_DUKE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEREMOVED: {
|
||||
pVoid->DisconnectDeviceFromXbox(event.jdevice.which + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_QUIT: {
|
||||
bContinue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputDeviceManager::UpdateButtonState(SDL_JoystickID id, uint8_t button, uint8_t state)
|
||||
{
|
||||
SDL2Devices* ControllerObj = nullptr;
|
||||
int xbox_button;
|
||||
|
||||
for (auto Obj : m_Sdl2Devices) {
|
||||
if (Obj->m_jyID == id) {
|
||||
ControllerObj = Obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ControllerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
xbox_button = ControllerObj->GetBoundButton(button);
|
||||
|
||||
if (xbox_button == GAMEPAD_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (xbox_button)
|
||||
{
|
||||
case GAMEPAD_A:
|
||||
case GAMEPAD_B:
|
||||
case GAMEPAD_X:
|
||||
case GAMEPAD_Y:
|
||||
case GAMEPAD_BLACK:
|
||||
case GAMEPAD_WHITE:
|
||||
case GAMEPAD_LEFT_TRIGGER:
|
||||
case GAMEPAD_RIGHT_TRIGGER: {
|
||||
ControllerObj->UpdateAnalogButtonState(xbox_button, state);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAMEPAD_BACK:
|
||||
case GAMEPAD_START:
|
||||
case GAMEPAD_LEFT_THUMB:
|
||||
case GAMEPAD_RIGHT_THUMB:
|
||||
case GAMEPAD_DPAD_UP:
|
||||
case GAMEPAD_DPAD_DOWN:
|
||||
case GAMEPAD_DPAD_LEFT:
|
||||
case GAMEPAD_DPAD_RIGHT: {
|
||||
ControllerObj->UpdateDigitalButtonState(xbox_button, state);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InputDeviceManager::UpdateHatState(SDL_JoystickID id, uint8_t hat_index, uint8_t state)
|
||||
{
|
||||
SDL2Devices* ControllerObj = nullptr;
|
||||
int xbox_button;
|
||||
|
||||
for (auto Obj : m_Sdl2Devices) {
|
||||
if (Obj->m_jyID == id) {
|
||||
ControllerObj = Obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ControllerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
xbox_button = ControllerObj->GetBoundButton(hat_index + HAT_CONSTANT);
|
||||
|
||||
if (xbox_button == GAMEPAD_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
ControllerObj->UpdateHatState(state);
|
||||
}
|
||||
|
||||
void InputDeviceManager::UpdateAxisState(SDL_JoystickID id, uint8_t axis_index, int16_t state)
|
||||
{
|
||||
SDL2Devices* ControllerObj = nullptr;
|
||||
int xbox_button;
|
||||
|
||||
for (auto Obj : m_Sdl2Devices) {
|
||||
if (Obj->m_jyID == id) {
|
||||
ControllerObj = Obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ControllerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
xbox_button = ControllerObj->GetBoundButton(axis_index);
|
||||
|
||||
if (xbox_button == GAMEPAD_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
ControllerObj->UpdateAxisState(xbox_button, state);
|
||||
}
|
||||
|
||||
int InputDeviceManager::IsValidController(int index)
|
||||
{
|
||||
SDL2Devices* pDev;
|
||||
SDL_Joystick* pJoystick;
|
||||
|
||||
if (SDL_IsGameController(index)) {
|
||||
pDev = new SDL2Devices();
|
||||
pDev->m_Index = index;
|
||||
m_Sdl2Devices.push_back(pDev);
|
||||
}
|
||||
else {
|
||||
// this joystick is not supported at the moment
|
||||
return -1;
|
||||
}
|
||||
|
||||
pJoystick = SDL_JoystickOpen(pDev->m_Index);
|
||||
if (pJoystick == nullptr) {
|
||||
EmuWarning("Failed to open game controller %s. The error was %s\n", SDL_GameControllerNameForIndex(pDev->m_Index), SDL_GetError());
|
||||
delete pDev;
|
||||
m_Sdl2Devices.erase(m_Sdl2Devices.begin() + index);
|
||||
return -1;
|
||||
}
|
||||
else if (pDev->m_Index > 3) {
|
||||
printf("More than 4 controllers detected. Putting game controller %s in detached state\n", SDL_JoystickName(pJoystick));
|
||||
pDev->m_Attached = 0;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
printf("Found game controller %s\n", SDL_JoystickName(pJoystick));
|
||||
pDev->m_Joystick = pJoystick;
|
||||
pDev->m_jyID = SDL_JoystickInstanceID(pJoystick);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SDL2Devices* InputDeviceManager::FindDeviceFromXboxPort(int port)
|
||||
{
|
||||
if (port > 4 || port < 1) { return nullptr; };
|
||||
|
||||
for (auto it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end(); ++it) {
|
||||
if ((*it)->m_Index == (port - 1)) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#include "InputConfig.h"
|
||||
#include "SDL2_Device.h"
|
||||
#include "..\devices\usb\XidGamepad.h"
|
||||
#include "..\..\CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include <thread>
|
||||
|
||||
|
||||
InputDeviceManager* g_InputDeviceManager = nullptr;
|
||||
|
||||
InputDeviceManager::InputDeviceManager()
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Failed to initialize SDL2 input subsystem. The error was: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
InputDeviceManager::~InputDeviceManager()
|
||||
{
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
int InputDeviceManager::EnumSdl2Devices()
|
||||
{
|
||||
int NumOfJoysticks;
|
||||
int NumInvalidJoysticks;
|
||||
SDL2Devices* pDev;
|
||||
SDL_Joystick* pJoystick;
|
||||
std::vector<SDL2Devices*>::iterator it;
|
||||
|
||||
NumOfJoysticks = SDL_NumJoysticks();
|
||||
if (NumOfJoysticks < 0) {
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Failed to enumerate joysticks. The error was: %s", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
NumInvalidJoysticks = 0;
|
||||
|
||||
for (int i = 0; i < NumOfJoysticks; i++) {
|
||||
pDev = new SDL2Devices();
|
||||
pDev->m_Index = i;
|
||||
m_Sdl2Devices.push_back(pDev);
|
||||
}
|
||||
|
||||
for (it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end();) {
|
||||
pJoystick = SDL_JoystickOpen((*it)->m_Index);
|
||||
if (pJoystick == nullptr) {
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Failed to open joystick %s. The error was %s\n", SDL_GameControllerNameForIndex((*it)->m_Index), SDL_GetError());
|
||||
delete (*it);
|
||||
it = m_Sdl2Devices.erase(it);
|
||||
NumInvalidJoysticks++;
|
||||
}
|
||||
else {
|
||||
printf("Found joystick %s\n", SDL_JoystickName(pJoystick));
|
||||
(*it)->m_Joystick = pJoystick;
|
||||
(*it)->m_jyID = SDL_JoystickInstanceID(pJoystick);
|
||||
(*it)->m_Attached = 1;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
return NumOfJoysticks - NumInvalidJoysticks;
|
||||
}
|
||||
|
||||
int InputDeviceManager::ConnectDeviceToXbox(int port, int type)
|
||||
{
|
||||
int ret = -1;
|
||||
std::vector<SDL2Devices*>::iterator it;
|
||||
|
||||
if (port > 4 || port < 1) { return ret; };
|
||||
|
||||
for (it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end(); ++it) {
|
||||
if ((*it)->m_Index == (port - 1)) {
|
||||
--port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (it == m_Sdl2Devices.end()) {
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Attempted to connect a device not yet enumerated.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MS_CONTROLLER_DUKE: {
|
||||
if (g_HubObjArray[port] == nullptr) {
|
||||
g_HubObjArray[port] = new Hub;
|
||||
ret = g_HubObjArray[port]->Init(port + 1);
|
||||
if (ret) {
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
break;
|
||||
}
|
||||
if (g_XidControllerObjArray[port] == nullptr) {
|
||||
g_XidControllerObjArray[port] = new XidGamepad;
|
||||
ret = g_XidControllerObjArray[port]->Init(port + 1);
|
||||
if (ret) {
|
||||
g_HubObjArray[port]->HubDestroy();
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
delete g_XidControllerObjArray[port];
|
||||
g_XidControllerObjArray[port] = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret = -1;
|
||||
g_HubObjArray[port]->HubDestroy();
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Xid controller already present at port %d.2\n", port + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Hub already present at port %d\n", port + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MS_CONTROLLER_S:
|
||||
case LIGHT_GUN:
|
||||
case STEERING_WHEEL:
|
||||
case MEMORY_UNIT:
|
||||
case IR_DONGLE:
|
||||
case STEEL_BATTALION_CONTROLLER: {
|
||||
printf("This device type is not yet supported\n");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Attempted to attach an unknown device type\n");
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
(*it)->m_Type = type;
|
||||
(*it)->m_Attached = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InputDeviceManager::DisconnectDeviceFromXbox(int port)
|
||||
{
|
||||
std::vector<SDL2Devices*>::iterator it;
|
||||
|
||||
if (port < 1) { return; }
|
||||
|
||||
for (it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end(); ++it) {
|
||||
if ((*it)->m_Index == (port - 1)) {
|
||||
--port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (it == m_Sdl2Devices.end()) {
|
||||
// Not necessarily a bug. This could also be triggered by detaching an unsupported joystick
|
||||
return;
|
||||
}
|
||||
|
||||
if (port + 1 > 4) {
|
||||
delete (*it);
|
||||
m_Sdl2Devices.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((*it)->m_Type)
|
||||
{
|
||||
case MS_CONTROLLER_DUKE: {
|
||||
if (g_HubObjArray[port] != nullptr && g_XidControllerObjArray[port] != nullptr) {
|
||||
g_HubObjArray[port]->HubDestroy();
|
||||
delete g_HubObjArray[port];
|
||||
g_HubObjArray[port] = nullptr;
|
||||
delete g_XidControllerObjArray[port];
|
||||
g_XidControllerObjArray[port] = nullptr;
|
||||
delete (*it);
|
||||
m_Sdl2Devices.erase(it);
|
||||
// Here, we could also see if there are detached devices that have a matching type and bound buttons, so that it can immediately
|
||||
// be used instead of remaining inactive (example: 5 controllers and 1st is detached -> 5th can be used if it has bindings)
|
||||
}
|
||||
else {
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Attempted to disconnect a device not attached to the Xbox.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MS_CONTROLLER_S:
|
||||
case LIGHT_GUN:
|
||||
case STEERING_WHEEL:
|
||||
case MEMORY_UNIT:
|
||||
case IR_DONGLE:
|
||||
case STEEL_BATTALION_CONTROLLER: {
|
||||
printf("This device type is not yet supported\n");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Attempted to detach an unknown device type\n");
|
||||
}
|
||||
}
|
||||
|
||||
void InputDeviceManager::StartInputThread()
|
||||
{
|
||||
std::thread(InputThread, this).detach();
|
||||
}
|
||||
|
||||
void InputDeviceManager::InputThread(InputDeviceManager* pVoid)
|
||||
{
|
||||
bool bContinue = true;
|
||||
SDL_Event event;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Failed to initialize SDL2 video subsystem. The error was: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
|
||||
while (bContinue)
|
||||
{
|
||||
if (SDL_WaitEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_JOYBUTTONUP:
|
||||
case SDL_JOYBUTTONDOWN: {
|
||||
pVoid->UpdateButtonState(event.jbutton.which, event.jbutton.button, event.jbutton.state);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYHATMOTION: {
|
||||
pVoid->UpdateHatState(event.jhat.which, event.jhat.hat, event.jhat.value);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYAXISMOTION: {
|
||||
pVoid->UpdateAxisState(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEADDED: {
|
||||
bool found = false;
|
||||
for (auto dev : pVoid->m_Sdl2Devices) {
|
||||
if (dev->m_Index == event.jdevice.which) {
|
||||
// already enumerated, skipping
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// for now we only support a single controller at port 1, more will be added later
|
||||
if (!pVoid->IsValidController(event.jdevice.which) && event.jdevice.which == 0) {
|
||||
pVoid->ConnectDeviceToXbox(1, MS_CONTROLLER_DUKE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEREMOVED: {
|
||||
pVoid->DisconnectDeviceFromXbox(event.jdevice.which + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_QUIT: {
|
||||
bContinue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputDeviceManager::UpdateButtonState(SDL_JoystickID id, uint8_t button, uint8_t state)
|
||||
{
|
||||
SDL2Devices* ControllerObj = nullptr;
|
||||
int xbox_button;
|
||||
|
||||
for (auto Obj : m_Sdl2Devices) {
|
||||
if (Obj->m_jyID == id) {
|
||||
ControllerObj = Obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ControllerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
xbox_button = ControllerObj->GetBoundButton(button);
|
||||
|
||||
if (xbox_button == GAMEPAD_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (xbox_button)
|
||||
{
|
||||
case GAMEPAD_A:
|
||||
case GAMEPAD_B:
|
||||
case GAMEPAD_X:
|
||||
case GAMEPAD_Y:
|
||||
case GAMEPAD_BLACK:
|
||||
case GAMEPAD_WHITE:
|
||||
case GAMEPAD_LEFT_TRIGGER:
|
||||
case GAMEPAD_RIGHT_TRIGGER: {
|
||||
ControllerObj->UpdateAnalogButtonState(xbox_button, state);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAMEPAD_BACK:
|
||||
case GAMEPAD_START:
|
||||
case GAMEPAD_LEFT_THUMB:
|
||||
case GAMEPAD_RIGHT_THUMB:
|
||||
case GAMEPAD_DPAD_UP:
|
||||
case GAMEPAD_DPAD_DOWN:
|
||||
case GAMEPAD_DPAD_LEFT:
|
||||
case GAMEPAD_DPAD_RIGHT: {
|
||||
ControllerObj->UpdateDigitalButtonState(xbox_button, state);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InputDeviceManager::UpdateHatState(SDL_JoystickID id, uint8_t hat_index, uint8_t state)
|
||||
{
|
||||
SDL2Devices* ControllerObj = nullptr;
|
||||
int xbox_button;
|
||||
|
||||
for (auto Obj : m_Sdl2Devices) {
|
||||
if (Obj->m_jyID == id) {
|
||||
ControllerObj = Obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ControllerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
xbox_button = ControllerObj->GetBoundButton(hat_index + HAT_CONSTANT);
|
||||
|
||||
if (xbox_button == GAMEPAD_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
ControllerObj->UpdateHatState(state);
|
||||
}
|
||||
|
||||
void InputDeviceManager::UpdateAxisState(SDL_JoystickID id, uint8_t axis_index, int16_t state)
|
||||
{
|
||||
SDL2Devices* ControllerObj = nullptr;
|
||||
int xbox_button;
|
||||
|
||||
for (auto Obj : m_Sdl2Devices) {
|
||||
if (Obj->m_jyID == id) {
|
||||
ControllerObj = Obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ControllerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
xbox_button = ControllerObj->GetBoundButton(axis_index);
|
||||
|
||||
if (xbox_button == GAMEPAD_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
ControllerObj->UpdateAxisState(xbox_button, state);
|
||||
}
|
||||
|
||||
int InputDeviceManager::IsValidController(int index)
|
||||
{
|
||||
SDL2Devices* pDev;
|
||||
SDL_Joystick* pJoystick;
|
||||
|
||||
if (SDL_IsGameController(index)) {
|
||||
pDev = new SDL2Devices();
|
||||
pDev->m_Index = index;
|
||||
m_Sdl2Devices.push_back(pDev);
|
||||
}
|
||||
else {
|
||||
// this joystick is not supported at the moment
|
||||
return -1;
|
||||
}
|
||||
|
||||
pJoystick = SDL_JoystickOpen(pDev->m_Index);
|
||||
if (pJoystick == nullptr) {
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Failed to open game controller %s. The error was %s\n", SDL_GameControllerNameForIndex(pDev->m_Index), SDL_GetError());
|
||||
delete pDev;
|
||||
m_Sdl2Devices.erase(m_Sdl2Devices.begin() + index);
|
||||
return -1;
|
||||
}
|
||||
else if (pDev->m_Index > 3) {
|
||||
printf("More than 4 controllers detected. Putting game controller %s in detached state\n", SDL_JoystickName(pJoystick));
|
||||
pDev->m_Attached = 0;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
printf("Found game controller %s\n", SDL_JoystickName(pJoystick));
|
||||
pDev->m_Joystick = pJoystick;
|
||||
pDev->m_jyID = SDL_JoystickInstanceID(pJoystick);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SDL2Devices* InputDeviceManager::FindDeviceFromXboxPort(int port)
|
||||
{
|
||||
if (port > 4 || port < 1) { return nullptr; };
|
||||
|
||||
for (auto it = m_Sdl2Devices.begin(); it != m_Sdl2Devices.end(); ++it) {
|
||||
if ((*it)->m_Index == (port - 1)) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -42,35 +42,45 @@
|
|||
// TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html
|
||||
thread_local std::string _logThreadPrefix;
|
||||
|
||||
std::atomic_bool g_EnabledModules[static_cast<unsigned int>(_CXBXR_MODULE::MAX)] = { false };
|
||||
const char* g_EnumModules2String[static_cast<unsigned int>(_CXBXR_MODULE::MAX)] = {
|
||||
"CXBX",
|
||||
std::atomic_bool g_EnabledModules[static_cast<unsigned int>(CXBXR_MODULE::MAX)] = { false };
|
||||
const char* g_EnumModules2String[static_cast<unsigned int>(CXBXR_MODULE::MAX)] = {
|
||||
"CXBXR",
|
||||
"XBE",
|
||||
"INIT",
|
||||
"VMEM",
|
||||
"PMEM",
|
||||
"GUI,"
|
||||
"EEPR",
|
||||
"RSA",
|
||||
"POOLMEM",
|
||||
"D3D8",
|
||||
"D3DST",
|
||||
"D3DCVT",
|
||||
"DSOUND",
|
||||
"XAPI",
|
||||
"XACT",
|
||||
"XGRP",
|
||||
"XONLINE",
|
||||
"XBDM",
|
||||
"FS",
|
||||
"PSHB",
|
||||
"PXSH",
|
||||
"VTXSH",
|
||||
"VTXB",
|
||||
"DINP",
|
||||
"XINP",
|
||||
"SDL2",
|
||||
"FILE",
|
||||
"FS",
|
||||
"X86",
|
||||
"HLE",
|
||||
"NET",
|
||||
"MCPX",
|
||||
"NV2A",
|
||||
"SMC",
|
||||
"OHCI",
|
||||
"USB",
|
||||
"HUB",
|
||||
"XIDCTRL",
|
||||
"ADM",
|
||||
"KRNL",
|
||||
"LOG",
|
||||
"XBOX",
|
||||
|
@ -78,13 +88,12 @@ const char* g_EnumModules2String[static_cast<unsigned int>(_CXBXR_MODULE::MAX)]
|
|||
"AV",
|
||||
"DBG",
|
||||
"EX",
|
||||
"FS",
|
||||
"FSC",
|
||||
"HAL",
|
||||
"IO",
|
||||
"KD",
|
||||
"KE",
|
||||
"KI",
|
||||
"KD",
|
||||
"MM",
|
||||
"NT",
|
||||
"OB",
|
||||
|
|
|
@ -53,33 +53,43 @@ typedef enum class _LOG_LEVEL {
|
|||
|
||||
typedef enum class _CXBXR_MODULE {
|
||||
// general
|
||||
CXBX = 0,
|
||||
CXBXR = 0,
|
||||
XBE,
|
||||
INIT,
|
||||
VMEM,
|
||||
PMEM,
|
||||
GUI,
|
||||
EEPR,
|
||||
RSA,
|
||||
POOLMEM,
|
||||
D3D8,
|
||||
D3DST,
|
||||
D3DCVT,
|
||||
DSOUND,
|
||||
XAPI,
|
||||
XACT,
|
||||
XGRP,
|
||||
XONLINE,
|
||||
XBDM,
|
||||
FS,
|
||||
PSHB,
|
||||
PXSH,
|
||||
VTXSH,
|
||||
VTXB,
|
||||
DINP,
|
||||
XINP,
|
||||
SDL2,
|
||||
FILE,
|
||||
FS,
|
||||
X86,
|
||||
HLE,
|
||||
NET,
|
||||
MCPX,
|
||||
NV2A,
|
||||
SMC,
|
||||
OHCI,
|
||||
USB,
|
||||
HUB,
|
||||
XIDCTRL,
|
||||
ADM,
|
||||
// kernel
|
||||
KRNL,
|
||||
LOG,
|
||||
|
@ -88,13 +98,12 @@ typedef enum class _CXBXR_MODULE {
|
|||
AV,
|
||||
DBG,
|
||||
EX,
|
||||
FS,
|
||||
FSC,
|
||||
HAL,
|
||||
IO,
|
||||
KD,
|
||||
KE,
|
||||
KI,
|
||||
KD,
|
||||
MM,
|
||||
NT,
|
||||
OB,
|
||||
|
@ -106,8 +115,8 @@ typedef enum class _CXBXR_MODULE {
|
|||
MAX,
|
||||
}CXBXR_MODULE;
|
||||
|
||||
extern std::atomic_bool g_EnabledModules[static_cast<unsigned int>(_CXBXR_MODULE::MAX)];
|
||||
extern const char* g_EnumModules2String[static_cast<unsigned int>(_CXBXR_MODULE::MAX)];
|
||||
extern std::atomic_bool g_EnabledModules[static_cast<unsigned int>(CXBXR_MODULE::MAX)];
|
||||
extern const char* g_EnumModules2String[static_cast<unsigned int>(CXBXR_MODULE::MAX)];
|
||||
extern std::atomic_uint g_CurrentLogLevel;
|
||||
|
||||
//
|
||||
|
@ -241,16 +250,6 @@ extern thread_local std::string _logThreadPrefix;
|
|||
// Checks if this log should be printed or not
|
||||
#define LOG_CHECK_ENABLED(cxbxr_module, level) \
|
||||
if (g_EnabledModules[static_cast<unsigned int>(cxbxr_module)] && static_cast<unsigned int>(level) >= g_CurrentLogLevel)
|
||||
|
||||
// Writes the log to stdout
|
||||
#define LOG_WRITE(cxbxr_module, string) \
|
||||
std::cout << g_EnumModules2String[static_cast<unsigned int>(cxbxr_module)] << ": " << string;
|
||||
|
||||
// Writes the log at debug level
|
||||
#define LOG_WRITE_DEBUG(cxbxr_module, string) \
|
||||
LOG_CHECK_ENABLED(cxbxr_module, LOG_LEVEL::DEBUG) { \
|
||||
LOG_WRITE(cxbxr_module, string) \
|
||||
}
|
||||
|
||||
#define LOG_THREAD_INIT \
|
||||
if (_logThreadPrefix.length() == 0) { \
|
||||
|
@ -319,9 +318,9 @@ extern thread_local std::string _logThreadPrefix;
|
|||
std::cout << _logThreadPrefix << _logFuncPrefix << " returns " << (type)r << "\n";
|
||||
|
||||
// LOG_FORWARD indicates that an api is implemented by a forward to another API
|
||||
#define LOG_FORWARD(cxbxr_module, api) \
|
||||
#define LOG_FORWARD(cxbxr_module, api) \
|
||||
LOG_INIT \
|
||||
LOG_CHECK_ENABLED(cxbxr_module, LOG_LEVEL::DEBUG) { \
|
||||
LOG_INIT \
|
||||
do { if(g_bPrintfOn) { \
|
||||
std::cout << _logThreadPrefix << _logFuncPrefix << " forwarding to "#api"...\n"; \
|
||||
} } while (0); \
|
||||
|
@ -418,14 +417,14 @@ extern thread_local std::string _logThreadPrefix;
|
|||
#define LOG_FUNC_ONE_ARG_OUT(cxbxr_module, arg) LOG_FUNC_BEGIN(cxbxr_module) LOG_FUNC_ARG_OUT(arg) LOG_FUNC_END
|
||||
|
||||
// RETURN logs the given result and then returns it (so this should appear last in functions)
|
||||
#define RETURN(cxbxr_module, r) do { LOG_CHECK_ENABLED(cxbxr_module, LOG_LEVEL::DEBUG) { LOG_FUNC_RESULT(r) return r; } } while (0)
|
||||
#define RETURN(cxbxr_module, r) do { LOG_CHECK_ENABLED(cxbxr_module, LOG_LEVEL::DEBUG) { LOG_FUNC_RESULT(r) } return r; } while (0)
|
||||
|
||||
// RETURN_TYPE logs the given typed result and then returns it (so this should appear last in functions)
|
||||
#define RETURN_TYPE(cxbxr_module, type, r) do { LOG_CHECK_ENABLED(cxbxr_module, LOG_LEVEL::DEBUG) { LOG_FUNC_RESULT_TYPE(type, r) return r; } } while (0)
|
||||
#define RETURN_TYPE(cxbxr_module, type, r) do { LOG_CHECK_ENABLED(cxbxr_module, LOG_LEVEL::DEBUG) { LOG_FUNC_RESULT_TYPE(type, r) } return r; } while (0)
|
||||
|
||||
#define LOG_ONCE(msg, ...) { static bool bFirstTime = true; if(bFirstTime) { bFirstTime = false; DbgPrintf("TRAC: " ## msg, __VA_ARGS__); } }
|
||||
#define LOG_ONCE(msg, ...) { static bool bFirstTime = true; if(bFirstTime) { bFirstTime = false; DbgPrintf(LOG_PREFIX, "TRAC: " ## msg, __VA_ARGS__); } }
|
||||
|
||||
#define LOG_XBOX_CALL(func) DbgPrintf("TRAC: Xbox " ## func ## "() call\n");
|
||||
#define LOG_XBOX_CALL(func) DbgPrintf(LOG_PREFIX, "TRAC: Xbox " ## func ## "() call\n");
|
||||
#define LOG_FIRST_XBOX_CALL(func) LOG_ONCE("First Xbox " ## func ## "() call\n");
|
||||
|
||||
//
|
||||
|
|
|
@ -86,7 +86,7 @@ void EmuShared::Init(DWORD guiProcessID)
|
|||
);
|
||||
|
||||
if(hMapObject == NULL)
|
||||
CxbxKrnlCleanup("Could not map shared memory!");
|
||||
CxbxKrnlCleanup(CXBXR_MODULE::INIT, "Could not map shared memory!");
|
||||
|
||||
if(GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
bRequireConstruction = false;
|
||||
|
@ -106,7 +106,7 @@ void EmuShared::Init(DWORD guiProcessID)
|
|||
);
|
||||
|
||||
if(g_EmuShared == nullptr)
|
||||
CxbxKrnlCleanup("Could not map view of shared memory!");
|
||||
CxbxKrnlCleanup(CXBXR_MODULE::INIT, "Could not map view of shared memory!");
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::XBPM
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
|
|
|
@ -141,9 +141,11 @@ extern volatile bool g_bPrintfOn;
|
|||
|
||||
/*! DbgPrintf enabled if _DEBUG_TRACE is set */
|
||||
#ifdef _DEBUG_TRACE
|
||||
#define DbgPrintf(fmt, ...) { \
|
||||
CXBX_CHECK_INTEGRITY(); \
|
||||
if(g_bPrintfOn) printf("[0x%.4X] "##fmt, GetCurrentThreadId(), ##__VA_ARGS__); \
|
||||
#define DbgPrintf(cxbxr_module, fmt, ...) { \
|
||||
if (g_EnabledModules[static_cast<unsigned int>(cxbxr_module)] && static_cast<unsigned int>(LOG_LEVEL::DEBUG) >= g_CurrentLogLevel) { \
|
||||
CXBX_CHECK_INTEGRITY(); \
|
||||
if(g_bPrintfOn) printf("[0x%.4X] %s: "##fmt, GetCurrentThreadId(), g_EnumModules2String[static_cast<unsigned int>(cxbxr_module)], ##__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
inline void null_func(...) { }
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace xbdm {
|
|||
void DmSendNotificationString(LPCSTR sz)
|
||||
{
|
||||
// Just send this string to Cxbx's debug output :
|
||||
DbgPrintf("%s\n", sz);
|
||||
DbgPrintf(LOG_PREFIX, "%s\n", sz);
|
||||
}
|
||||
|
||||
// 0x0025 (37)
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::GUI
|
||||
|
||||
#include "WndMain.h"
|
||||
#include "DlgAbout.h"
|
||||
#include "DlgControllerConfig.h"
|
||||
|
@ -122,7 +125,7 @@ void WndMain::ResizeWindow(HWND hwnd, bool bForGUI)
|
|||
|
||||
const char* resolution = XBVideoConf.szVideoResolution;
|
||||
if (2 != sscanf(resolution, "%d x %d", &m_w, &m_h)) {
|
||||
DbgPrintf("Couldn't parse resolution : %s.\n", resolution);
|
||||
DbgPrintf(LOG_PREFIX, "Couldn't parse resolution : %s.\n", resolution);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::CXBXR
|
||||
#define LOG_PREFIX_INIT CXBXR_MODULE::INIT
|
||||
|
||||
/* prevent name collisions */
|
||||
namespace xboxkrnl
|
||||
|
@ -199,7 +201,7 @@ void CxbxLaunchXbe(void(*Entry)())
|
|||
}
|
||||
__except (EmuException(GetExceptionInformation()))
|
||||
{
|
||||
EmuWarning("Problem with ExceptionFilter");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +322,7 @@ HANDLE CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
/* hTemplateFile */nullptr);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestoreContiguousMemory : Couldn't create memory.bin file!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : Couldn't create memory.bin file!\n", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +340,7 @@ HANDLE CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
/**/nullptr);
|
||||
if (hFileMapping == NULL)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestoreContiguousMemory : Couldn't create contiguous memory.bin file mapping!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : Couldn't create contiguous memory.bin file mapping!\n", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -347,7 +349,7 @@ HANDLE CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
unsigned int FileSize = len_li.u.LowPart;
|
||||
if (FileSize != CHIHIRO_MEMORY_SIZE)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestoreContiguousMemory : memory.bin file is not 128 MiB large!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : memory.bin file is not 128 MiB large!\n", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -364,7 +366,7 @@ HANDLE CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
if (memory)
|
||||
UnmapViewOfFile(memory);
|
||||
|
||||
CxbxKrnlCleanup("CxbxRestoreContiguousMemory: Couldn't map contiguous memory.bin to 0x80000000!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s: Couldn't map contiguous memory.bin to 0x80000000!", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -401,7 +403,7 @@ HANDLE CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
if (tiled_memory)
|
||||
UnmapViewOfFile(tiled_memory);
|
||||
|
||||
CxbxKrnlCleanup("CxbxRestoreContiguousMemory: Couldn't map contiguous memory.bin into tiled memory at 0xF0000000!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s: Couldn't map contiguous memory.bin into tiled memory at 0xF0000000!", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -436,7 +438,7 @@ HANDLE CxbxRestorePageTablesMemory(char* szFilePath_page_tables)
|
|||
/* hTemplateFile */nullptr);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestorePageTablesMemory : Couldn't create PageTables.bin file!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : Couldn't create PageTables.bin file!\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +455,7 @@ HANDLE CxbxRestorePageTablesMemory(char* szFilePath_page_tables)
|
|||
/**/nullptr);
|
||||
if (hFileMapping == NULL)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestorePageTablesMemory : Couldn't create PageTables.bin file mapping!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : Couldn't create PageTables.bin file mapping!\n", __func__);
|
||||
}
|
||||
|
||||
LARGE_INTEGER len_li;
|
||||
|
@ -461,7 +463,7 @@ HANDLE CxbxRestorePageTablesMemory(char* szFilePath_page_tables)
|
|||
unsigned int FileSize = len_li.u.LowPart;
|
||||
if (FileSize != PAGE_TABLES_SIZE)
|
||||
{
|
||||
CxbxKrnlCleanup("CxbxRestorePageTablesMemory : PageTables.bin file is not 4 MiB large!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : PageTables.bin file is not 4 MiB large!\n", __func__);
|
||||
}
|
||||
|
||||
// Map PageTables.bin contents into memory :
|
||||
|
@ -477,7 +479,7 @@ HANDLE CxbxRestorePageTablesMemory(char* szFilePath_page_tables)
|
|||
if (memory)
|
||||
UnmapViewOfFile(memory);
|
||||
|
||||
CxbxKrnlCleanup("CxbxRestorePageTablesMemory: Couldn't map PageTables.bin to 0xC0000000!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s: Couldn't map PageTables.bin to 0xC0000000!", __func__);
|
||||
}
|
||||
|
||||
printf("[0x%.4X] INIT: Mapped %d MiB of Xbox page tables memory at 0x%.8X to 0x%.8X\n",
|
||||
|
@ -496,7 +498,7 @@ HANDLE CxbxRestorePageTablesMemory(char* szFilePath_page_tables)
|
|||
|
||||
#pragma optimize("", off)
|
||||
|
||||
void CxbxPopupMessage(CxbxMsgDlgIcon icon, const char *message, ...)
|
||||
void CxbxPopupMessage(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, CxbxMsgDlgIcon icon, const char *message, ...)
|
||||
{
|
||||
char Buffer[1024];
|
||||
va_list argp;
|
||||
|
@ -526,7 +528,8 @@ void CxbxPopupMessage(CxbxMsgDlgIcon icon, const char *message, ...)
|
|||
vsprintf(Buffer, message, argp);
|
||||
va_end(argp);
|
||||
|
||||
EmuWarning("Popup : %s\n", Buffer);
|
||||
EmuLog(cxbxr_module, level, "Popup : %s\n", Buffer);
|
||||
|
||||
MessageBox(NULL, Buffer, TEXT("Cxbx-Reloaded"), uType);
|
||||
}
|
||||
|
||||
|
@ -935,7 +938,7 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
Sleep(100);
|
||||
}
|
||||
if (!isReady) {
|
||||
EmuWarning("GUI process is not ready!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "GUI process is not ready!");
|
||||
int mbRet = MessageBox(NULL, "GUI process is not ready, do you wish to retry?", TEXT("Cxbx-Reloaded"),
|
||||
MB_ICONWARNING | MB_RETRYCANCEL | MB_TOPMOST | MB_SETFOREGROUND);
|
||||
if (mbRet == IDRETRY) {
|
||||
|
@ -1019,14 +1022,14 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
// verify base of code of our executable is 0x00001000
|
||||
if (ExeNtHeader->OptionalHeader.BaseOfCode != CXBX_BASE_OF_CODE)
|
||||
{
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Cxbx-Reloaded executuable requires it's base of code to be 0x00001000");
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "Cxbx-Reloaded executuable requires it's base of code to be 0x00001000");
|
||||
return; // TODO : Halt(0);
|
||||
}
|
||||
|
||||
// verify virtual_memory_placeholder is located at 0x00011000
|
||||
if ((UINT_PTR)(&(virtual_memory_placeholder[0])) != (XBE_IMAGE_BASE + CXBX_BASE_OF_CODE))
|
||||
{
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "virtual_memory_placeholder is not loaded to base address 0x00011000 (which is a requirement for Xbox emulation)");
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "virtual_memory_placeholder is not loaded to base address 0x00011000 (which is a requirement for Xbox emulation)");
|
||||
return; // TODO : Halt(0);
|
||||
}
|
||||
|
||||
|
@ -1067,7 +1070,7 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
EEPROM = CxbxRestoreEEPROM(szFilePath_EEPROM_bin);
|
||||
if (EEPROM == nullptr)
|
||||
{
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Couldn't init EEPROM!");
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "Couldn't init EEPROM!");
|
||||
return; // TODO : Halt(0);
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1085,7 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
CxbxKrnl_Xbe = new Xbe(szFilePath_Xbe, false); // TODO : Instead of using the Xbe class, port Dxbx _ReadXbeBlock()
|
||||
|
||||
if (CxbxKrnl_Xbe->HasFatalError()) {
|
||||
CxbxKrnlCleanup(CxbxKrnl_Xbe->GetError().c_str());
|
||||
CxbxKrnlCleanup(LOG_PREFIX, CxbxKrnl_Xbe->GetError().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1094,7 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
printf("[0x%X] INIT: Valid xbe signature. Xbe is legit\n", GetCurrentThreadId());
|
||||
}
|
||||
else {
|
||||
EmuWarning("Invalid xbe signature. Homebrew, tampered or pirated xbe?");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Invalid xbe signature. Homebrew, tampered or pirated xbe?");
|
||||
}
|
||||
|
||||
// Check the integrity of the xbe sections
|
||||
|
@ -1104,7 +1107,7 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
CalcSHA1Hash(SHADigest, CxbxKrnl_Xbe->m_bzSection[sectionIndex], RawSize);
|
||||
|
||||
if (memcmp(SHADigest, (CxbxKrnl_Xbe->m_SectionHeader)[sectionIndex].bzSectionDigest, A_SHA_DIGEST_LEN) != 0) {
|
||||
EmuWarning("SHA hash of section %s doesn't match, possible section corruption", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "SHA hash of section %s doesn't match, possible section corruption", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
}
|
||||
else {
|
||||
printf("[0x%X] INIT: SHA hash check of section %s successful\n", GetCurrentThreadId(), CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
|
@ -1139,7 +1142,7 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
if ((sectionHeaders[i].Flags & XBEIMAGE_SECTION_PRELOAD) != 0) {
|
||||
NTSTATUS result = xboxkrnl::XeLoadSection(§ionHeaders[i]);
|
||||
if (FAILED(result)) {
|
||||
CxbxKrnlCleanup("Failed to preload XBE section: %s", CxbxKrnl_Xbe->m_szSectionName[i]);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Failed to preload XBE section: %s", CxbxKrnl_Xbe->m_szSectionName[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1214,7 +1217,7 @@ void LoadXboxKeys(std::string path)
|
|||
memcpy(xboxkrnl::XboxCertificateKey, &keys[1], xboxkrnl::XBOX_KEY_LENGTH);
|
||||
}
|
||||
else {
|
||||
EmuWarning("Keys.bin has an incorrect filesize. Should be %d bytes", xboxkrnl::XBOX_KEY_LENGTH * 2);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Keys.bin has an incorrect filesize. Should be %d bytes", xboxkrnl::XBOX_KEY_LENGTH * 2);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
@ -1222,7 +1225,7 @@ void LoadXboxKeys(std::string path)
|
|||
}
|
||||
|
||||
// If we didn't already exit the function, keys.bin could not be loaded
|
||||
EmuWarning("Failed to load Keys.bin. Cxbx-Reloaded will be unable to read Save Data from a real Xbox");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Failed to load Keys.bin. Cxbx-Reloaded will be unable to read Save Data from a real Xbox");
|
||||
}
|
||||
|
||||
__declspec(noreturn) void CxbxKrnlInit
|
||||
|
@ -1255,7 +1258,7 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
CxbxInitPerformanceCounters();
|
||||
Timer_Init();
|
||||
#ifdef _DEBUG
|
||||
// CxbxPopupMessage("Attach a Debugger");
|
||||
// CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::INFO, "Attach a Debugger");
|
||||
// Debug child processes using https://marketplace.visualstudio.com/items?itemName=GreggMiskelly.MicrosoftChildProcessDebuggingPowerTool
|
||||
#endif
|
||||
|
||||
|
@ -1361,7 +1364,7 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
CxbxRegisterDeviceHostPath(DeviceHarddisk0Partition7, CxbxBasePath + "Partition7");
|
||||
|
||||
// Create default symbolic links :
|
||||
DbgPrintf("INIT: Creating default symbolic links.\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Creating default symbolic links.\n");
|
||||
{
|
||||
// TODO: DriveD should always point to the Xbe Path
|
||||
// This is the only symbolic link the Xbox Kernel sets, the rest are set by the application, usually via XAPI.
|
||||
|
@ -1425,10 +1428,10 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
|
||||
// Make sure the Xbox1 code runs on one core (as the box itself has only 1 CPU,
|
||||
// this will better aproximate the environment with regard to multi-threading) :
|
||||
DbgPrintf("INIT: Determining CPU affinity.\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Determining CPU affinity.\n");
|
||||
{
|
||||
if (!GetProcessAffinityMask(g_CurrentProcessHandle, &g_CPUXbox, &g_CPUOthers))
|
||||
CxbxKrnlCleanup("INIT: GetProcessAffinityMask failed.");
|
||||
CxbxKrnlCleanup(LOG_PREFIX_INIT, "GetProcessAffinityMask failed.");
|
||||
|
||||
// For the other threads, remove one bit from the processor mask:
|
||||
g_CPUOthers = ((g_CPUXbox - 1) & g_CPUXbox);
|
||||
|
@ -1444,7 +1447,7 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
}
|
||||
|
||||
// initialize graphics
|
||||
DbgPrintf("INIT: Initializing render window.\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Initializing render window.\n");
|
||||
XTL::CxbxInitWindow(true);
|
||||
|
||||
// Now process the boot flags to see if there are any special conditions to handle
|
||||
|
@ -1488,7 +1491,7 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
|
||||
if (!bLLE_GPU)
|
||||
{
|
||||
DbgPrintf("INIT: Initializing Direct3D.\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Initializing Direct3D.\n");
|
||||
XTL::EmuD3DInit();
|
||||
}
|
||||
|
||||
|
@ -1520,13 +1523,13 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
DWORD dwThreadId;
|
||||
HANDLE hThread = (HANDLE)_beginthreadex(NULL, NULL, CxbxKrnlInterruptThread, NULL, NULL, (uint*)&dwThreadId);
|
||||
|
||||
DbgPrintf("INIT: Calling XBE entry point...\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "Calling XBE entry point...\n");
|
||||
CxbxLaunchXbe(Entry);
|
||||
|
||||
// FIXME: Wait for Cxbx to exit or error fatally
|
||||
Sleep(INFINITE);
|
||||
|
||||
DbgPrintf("INIT: XBE entry point returned\n");
|
||||
DbgPrintf(LOG_PREFIX_INIT, "XBE entry point returned\n");
|
||||
fflush(stdout);
|
||||
|
||||
// EmuShared::Cleanup(); FIXME: commenting this line is a bad workaround for issue #617 (https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/617)
|
||||
|
@ -1540,14 +1543,14 @@ void CxbxInitFilePaths()
|
|||
// Make sure our data folder exists :
|
||||
bool result = std::experimental::filesystem::exists(szFolder_CxbxReloadedData);
|
||||
if (!result && !std::experimental::filesystem::create_directory(szFolder_CxbxReloadedData)) {
|
||||
CxbxKrnlCleanup("CxbxInitFilePaths : Couldn't create Cxbx-Reloaded's data folder!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : Couldn't create Cxbx-Reloaded's data folder!", __func__);
|
||||
}
|
||||
|
||||
// Make sure the EmuDisk folder exists
|
||||
std::string emuDisk = std::string(szFolder_CxbxReloadedData) + std::string("\\EmuDisk");
|
||||
result = std::experimental::filesystem::exists(emuDisk);
|
||||
if (!result && !std::experimental::filesystem::create_directory(emuDisk)) {
|
||||
CxbxKrnlCleanup("CxbxInitFilePaths : Couldn't create Cxbx-Reloaded EmuDisk folder!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s : Couldn't create Cxbx-Reloaded EmuDisk folder!", __func__);
|
||||
}
|
||||
|
||||
snprintf(szFilePath_EEPROM_bin, MAX_PATH, "%s\\EEPROM.bin", szFolder_CxbxReloadedData);
|
||||
|
@ -1568,7 +1571,7 @@ void CxbxInitFilePaths()
|
|||
}
|
||||
};*/
|
||||
|
||||
__declspec(noreturn) void CxbxKrnlCleanup(const char *szErrorMessage, ...)
|
||||
__declspec(noreturn) void CxbxKrnlCleanup(CXBXR_MODULE cxbxr_module, const char *szErrorMessage, ...)
|
||||
{
|
||||
g_bEmuException = true;
|
||||
|
||||
|
@ -1584,7 +1587,7 @@ __declspec(noreturn) void CxbxKrnlCleanup(const char *szErrorMessage, ...)
|
|||
vsprintf(szBuffer2, szErrorMessage, argp);
|
||||
va_end(argp);
|
||||
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also DbgPrintf
|
||||
CxbxPopupMessage(cxbxr_module, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also DbgPrintf
|
||||
}
|
||||
|
||||
printf("[0x%.4X] MAIN: Terminating Process\n", GetCurrentThreadId());
|
||||
|
@ -1614,7 +1617,7 @@ void CxbxKrnlRegisterThread(HANDLE hThread)
|
|||
}
|
||||
else {
|
||||
auto message = CxbxGetLastErrorString("DuplicateHandle");
|
||||
EmuWarning(message.c_str());
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, message.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1631,7 +1634,7 @@ void CxbxKrnlRegisterThread(HANDLE hThread)
|
|||
|
||||
if(v == MAXIMUM_XBOX_THREADS)
|
||||
{
|
||||
CxbxKrnlCleanup("There are too many active threads!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "There are too many active threads!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1756,13 +1759,13 @@ void CxbxKrnlPrintUEM(ULONG ErrorCode)
|
|||
xboxkrnl::ExSaveNonVolatileSetting(xboxkrnl::XC_MAX_ALL, Type, &Eeprom, sizeof(Eeprom));
|
||||
}
|
||||
else {
|
||||
CxbxKrnlCleanup("Could not display the fatal error screen");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Could not display the fatal error screen");
|
||||
}
|
||||
|
||||
if (g_bIsChihiro)
|
||||
{
|
||||
// The Chihiro doesn't display the UEM
|
||||
CxbxKrnlCleanup("The running Chihiro xbe has encountered a fatal error and needs to close");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "The running Chihiro xbe has encountered a fatal error and needs to close");
|
||||
}
|
||||
|
||||
g_CxbxFatalErrorCode = ErrorCode;
|
||||
|
@ -1802,11 +1805,11 @@ void CxbxPrintUEMInfo(ULONG ErrorCode)
|
|||
if (it != UEMErrorTable.end())
|
||||
{
|
||||
std::string ErrorMessage = "Fatal error. " + it->second + ". This error screen will persist indefinitely. Stop the emulation to close it";
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Error, ErrorMessage.c_str());
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, ErrorMessage.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Error, "Unknown fatal error. This error screen will persist indefinitely. Stop the emulation to close it");
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "Unknown fatal error. This error screen will persist indefinitely. Stop the emulation to close it");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1817,7 +1820,7 @@ __declspec(noreturn) void CxbxKrnlTerminateThread()
|
|||
|
||||
void CxbxKrnlPanic()
|
||||
{
|
||||
CxbxKrnlCleanup("Kernel Panic!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Kernel Panic!");
|
||||
}
|
||||
|
||||
void CxbxConvertArgToString(std::string &dest, const char* krnlExe, const char* xbeFile, HWND hwndParent, DebugMode krnlDebug, const char* krnlDebugFile) {
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
#define CXBXKRNL_H
|
||||
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Xbe.h"
|
||||
#include "Common/Xbe.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
#include <windows.h>
|
||||
|
@ -205,16 +206,16 @@ typedef enum _CxbxMsgDlgIcon {
|
|||
|
||||
} CxbxMsgDlgIcon;
|
||||
|
||||
void CxbxPopupMessage(CxbxMsgDlgIcon icon, const char *message, ...);
|
||||
void CxbxPopupMessage(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, CxbxMsgDlgIcon icon, const char *message, ...);
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LOG_TEST_CASE(message) do { static bool bTestCaseLogged = false; \
|
||||
#define LOG_TEST_CASE(cxbxr_module, message) do { static bool bTestCaseLogged = false; \
|
||||
if (!bTestCaseLogged) { bTestCaseLogged = true; \
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Info, "Please report that %s shows the following message:\nLOG_TEST_CASE: %s\nIn %s (%s line %d)", \
|
||||
CxbxPopupMessage(cxbxr_module, LOG_LEVEL::INFO, CxbxMsgDlgIcon_Info, "Please report that %s shows the following message:\nLOG_TEST_CASE: %s\nIn %s (%s line %d)", \
|
||||
CxbxKrnl_Xbe->m_szAsciiTitle, message, __func__, __FILE__, __LINE__); } } while(0)
|
||||
// was g_pCertificate->wszTitleName
|
||||
#else
|
||||
#define LOG_TEST_CASE(message) do { static bool bTestCaseLogged = false; \
|
||||
#define LOG_TEST_CASE(cxbxr_module, message) do { static bool bTestCaseLogged = false; \
|
||||
if (!bTestCaseLogged) { bTestCaseLogged = true; \
|
||||
printf("LOG_TEST_CASE: %s\nIn %s (%s line %d)", \
|
||||
message, __func__, __FILE__, __LINE__); } } while(0)
|
||||
|
@ -234,7 +235,7 @@ void CxbxKrnlMain(int argc, char* argv[]);
|
|||
__declspec(noreturn) void CxbxKrnlInit(void *pTLSData, Xbe::TLS *pTLS, Xbe::LibraryVersion *LibraryVersion, DebugMode DbgMode, const char *szDebugFilename, Xbe::Header *XbeHeader, uint32 XbeHeaderSize, void (*Entry)(), int BootFlags);
|
||||
|
||||
/*! cleanup emulation */
|
||||
__declspec(noreturn) void CxbxKrnlCleanup(const char *szErrorMessage, ...);
|
||||
__declspec(noreturn) void CxbxKrnlCleanup(CXBXR_MODULE cxbxr_module, const char *szErrorMessage, ...);
|
||||
|
||||
/*! register a thread handle */
|
||||
void CxbxKrnlRegisterThread(HANDLE hThread);
|
||||
|
|
|
@ -212,7 +212,7 @@ void DbgConsole::ParseCommand()
|
|||
else if(_stricmp(szCmd, "q") == 0 || _stricmp(szCmd, "quit") == 0 || _stricmp(szCmd, "exit") == 0)
|
||||
{
|
||||
printf("CxbxDbg: Goodbye...\n");
|
||||
CxbxKrnlCleanup(NULL);
|
||||
CxbxKrnlCleanup(CXBXR_MODULE::GUI, NULL);
|
||||
}
|
||||
else if(_stricmp(szCmd, "t") == 0 || _stricmp(szCmd, "trace") == 0)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace xboxkrnl
|
|||
#include "EmuShared.h"
|
||||
#include "HLEIntercept.h"
|
||||
#include "CxbxDebugger.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <Dbghelp.h>
|
||||
|
@ -103,32 +102,35 @@ std::string FormatTitleId(uint32_t title_id)
|
|||
}
|
||||
|
||||
// print out a warning message to the kernel debug log file
|
||||
#ifdef _DEBUG_WARNINGS
|
||||
void NTAPI EmuWarning(const char *szWarningMessage, ...)
|
||||
#ifdef _DEBUG_WARNINGS
|
||||
void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarningMessage, ...)
|
||||
{
|
||||
if (szWarningMessage == NULL) {
|
||||
return;
|
||||
}
|
||||
if (szWarningMessage == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_CHECK_ENABLED(cxbxr_module, level) {
|
||||
if (g_bPrintfOn) {
|
||||
|
||||
if(g_bPrintfOn) {
|
||||
va_list argp;
|
||||
|
||||
va_list argp;
|
||||
LOG_THREAD_INIT;
|
||||
|
||||
LOG_THREAD_INIT;
|
||||
std::cout << _logThreadPrefix << (level == LOG_LEVEL::WARNING ? "WARN -> " : "-> ")
|
||||
<< g_EnumModules2String[static_cast<unsigned int>(cxbxr_module)] << ": ";
|
||||
|
||||
std::cout << _logThreadPrefix << "WARN: ";
|
||||
va_start(argp, szWarningMessage);
|
||||
|
||||
va_start(argp, szWarningMessage);
|
||||
vfprintf(stdout, szWarningMessage, argp);
|
||||
|
||||
vfprintf(stdout, szWarningMessage, argp);
|
||||
va_end(argp);
|
||||
|
||||
va_end(argp);
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
fflush(stdout);
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,17 +34,18 @@
|
|||
#ifndef EMU_H
|
||||
#define EMU_H
|
||||
|
||||
#include "Common/Xbe.h"
|
||||
#include "Common/Xbe.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
#include <windows.h>
|
||||
#include <multimon.h>
|
||||
|
||||
// print out a warning message to the kernel debug log file
|
||||
#ifdef _DEBUG_WARNINGS
|
||||
void NTAPI EmuWarning(const char *szWarningMessage, ...);
|
||||
#else
|
||||
inline void NTAPI EmuWarning(const char *szWarningMessage, ...) { }
|
||||
// print out a log message to the kernel debug log file if level is high enough
|
||||
#ifdef _DEBUG_WARNINGS
|
||||
void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarningMessage, ...);
|
||||
#else
|
||||
inline void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarningMessage, ...) { }
|
||||
#endif
|
||||
|
||||
std::string FormatTitleId(uint32_t title_id);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1037,7 +1037,7 @@ XTL::D3DFORMAT XTL::EmuXB2PC_D3DFormat(X_D3DFORMAT Format)
|
|||
{
|
||||
const FormatInfo *info = &FormatInfos[Format];
|
||||
if (info->warning != nullptr) {
|
||||
DbgPrintf("EmuXB2PC_D3DFormat %s\n", info->warning);
|
||||
DbgPrintf(LOG_PREFIX_D3DCVT, "EmuXB2PC_D3DFormat %s\n", info->warning);
|
||||
}
|
||||
|
||||
return info->pc;
|
||||
|
@ -1049,7 +1049,7 @@ XTL::D3DFORMAT XTL::EmuXB2PC_D3DFormat(X_D3DFORMAT Format)
|
|||
case ((X_D3DFORMAT)0xffffffff):
|
||||
return D3DFMT_UNKNOWN; // TODO -oCXBX: Not sure if this counts as swizzled or not...
|
||||
default:
|
||||
CxbxKrnlCleanup("EmuXB2PC_D3DFormat: Unknown Format (0x%.08X)", Format);
|
||||
CxbxKrnlCleanup(LOG_PREFIX_D3DCVT, "EmuXB2PC_D3DFormat: Unknown Format (0x%.08X)", Format);
|
||||
}
|
||||
|
||||
return D3DFMT_UNKNOWN;
|
||||
|
@ -1131,7 +1131,7 @@ XTL::X_D3DFORMAT XTL::EmuPC2XB_D3DFormat(D3DFORMAT Format, bool bPreferLinear)
|
|||
result = X_D3DFMT_VERTEXDATA;
|
||||
break;
|
||||
default:
|
||||
CxbxKrnlCleanup("EmuPC2XB_D3DFormat: Unknown Format (%d)", Format);
|
||||
CxbxKrnlCleanup(LOG_PREFIX_D3DCVT, "EmuPC2XB_D3DFormat: Unknown Format (%d)", Format);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1183,7 +1183,7 @@ XTL::D3DMULTISAMPLE_TYPE XTL::EmuXB2PC_D3DMultiSampleFormat(DWORD Type)
|
|||
result = D3DMULTISAMPLE_9_SAMPLES;
|
||||
break;
|
||||
default:
|
||||
EmuWarning("Unknown Multisample Type (0x%X)!\x0d\x0a.", Type);
|
||||
EmuLog(LOG_PREFIX_D3DCVT, LOG_LEVEL::WARNING, "Unknown Multisample Type (0x%X)!\x0d\x0a.", Type);
|
||||
result = D3DMULTISAMPLE_NONE;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
|
||||
#define VERTICES_PER_TRIANGLE 3
|
||||
#define VERTICES_PER_QUAD 4
|
||||
#define TRIANGLES_PER_QUAD 2
|
||||
#define TRIANGLES_PER_QUAD 2
|
||||
|
||||
#define LOG_PREFIX_D3DCVT CXBXR_MODULE::D3DCVT
|
||||
|
||||
// simple render state encoding lookup table
|
||||
#define X_D3DRSSE_UNK 0x7fffffff
|
||||
|
@ -94,7 +96,7 @@ else if((uint32)State < 20)
|
|||
else if((uint32)State > 255)
|
||||
State = (D3DTRANSFORMSTATETYPE)(State - 250);
|
||||
else
|
||||
CxbxKrnlCleanup("Unknown Transform State Type (%d)", State);
|
||||
CxbxKrnlCleanup(LOG_PREFIX_D3DCVT, "Unknown Transform State Type (%d)", State);
|
||||
//*/
|
||||
|
||||
// convert from xbox to pc texture transform state types
|
||||
|
@ -109,7 +111,7 @@ inline D3DTRANSFORMSTATETYPE EmuXB2PC_D3DTS(D3DTRANSFORMSTATETYPE State)
|
|||
else if((uint32)State == 10) // Max
|
||||
return (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE7 + 1);
|
||||
|
||||
CxbxKrnlCleanup("Unknown Transform State Type (%d)", State);
|
||||
CxbxKrnlCleanup(LOG_PREFIX_D3DCVT, "Unknown Transform State Type (%d)", State);
|
||||
|
||||
return State;
|
||||
}
|
||||
|
@ -131,17 +133,17 @@ inline D3DBLENDOP EmuXB2PC_D3DBLENDOP(X_D3DBLENDOP Value)
|
|||
return D3DBLENDOP_MAX;
|
||||
case 0xF006:
|
||||
{
|
||||
EmuWarning("D3DBLENDOP_ADDSIGNED is not supported!");
|
||||
EmuLog(LOG_PREFIX_D3DCVT, LOG_LEVEL::WARNING, "D3DBLENDOP_ADDSIGNED is not supported!");
|
||||
return D3DBLENDOP_ADD;
|
||||
};
|
||||
case 0xF005:
|
||||
{
|
||||
EmuWarning("D3DBLENDOP_REVSUBTRACTSIGNED is not supported!");
|
||||
EmuLog(LOG_PREFIX_D3DCVT, LOG_LEVEL::WARNING, "D3DBLENDOP_REVSUBTRACTSIGNED is not supported!");
|
||||
return D3DBLENDOP_REVSUBTRACT;
|
||||
}
|
||||
}
|
||||
|
||||
EmuWarning("Unknown D3DBLENDOP (0x%.08X)", Value);
|
||||
EmuLog(LOG_PREFIX_D3DCVT, LOG_LEVEL::WARNING, "Unknown D3DBLENDOP (0x%.08X)", Value);
|
||||
|
||||
return (D3DBLENDOP)D3DBLENDOP_ADD;
|
||||
}
|
||||
|
@ -154,7 +156,7 @@ inline D3DBLEND EmuXB2PC_D3DBLEND(X_D3DBLEND Value)
|
|||
else if(Value < 0x309)
|
||||
return (D3DBLEND)((Value & 0xF) + 3);
|
||||
|
||||
EmuWarning("Unknown Xbox D3DBLEND Extension (0x%.08X)", Value);
|
||||
EmuLog(LOG_PREFIX_D3DCVT, LOG_LEVEL::WARNING, "Unknown Xbox D3DBLEND Extension (0x%.08X)", Value);
|
||||
return D3DBLEND_ONE;
|
||||
}
|
||||
|
||||
|
@ -199,7 +201,7 @@ inline D3DSTENCILOP EmuXB2PC_D3DSTENCILOP(X_D3DSTENCILOP Value)
|
|||
return D3DSTENCILOP_DECR;
|
||||
|
||||
default:
|
||||
CxbxKrnlCleanup("Unknown D3DSTENCILOP (0x%.08X)", Value);
|
||||
CxbxKrnlCleanup(LOG_PREFIX_D3DCVT, "Unknown D3DSTENCILOP (0x%.08X)", Value);
|
||||
}
|
||||
|
||||
return (D3DSTENCILOP) Value;
|
||||
|
|
|
@ -71,6 +71,8 @@
|
|||
// #include <xboxkrnl/xboxkrnl.h>
|
||||
//};
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::PXSH
|
||||
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuFS.h"
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
|
@ -1381,7 +1383,7 @@ bool PSH_IMD_ARGUMENT::Decode(const DWORD Value, DWORD aMask, TArgumentType Argu
|
|||
Type = PARAM_EF_PROD;
|
||||
break;
|
||||
default :
|
||||
DbgPrintf("INVALID ARGUMENT!\n");
|
||||
DbgPrintf(LOG_PREFIX, "INVALID ARGUMENT!\n");
|
||||
|
||||
Result = false;
|
||||
}
|
||||
|
@ -1972,8 +1974,8 @@ void PSH_XBOX_SHADER::Log(const char *PhaseStr)
|
|||
{
|
||||
//if (MayLog(lfUnit))
|
||||
{
|
||||
DbgPrintf("New decoding - %s :\n", PhaseStr);
|
||||
DbgPrintf("%s\n", ToString().c_str());
|
||||
DbgPrintf(LOG_PREFIX, "New decoding - %s :\n", PhaseStr);
|
||||
DbgPrintf(LOG_PREFIX, "%s\n", ToString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2153,7 +2155,7 @@ PSH_RECOMPILED_SHADER PSH_XBOX_SHADER::Decode(XTL::X_D3DPIXELSHADERDEF *pPSDef)
|
|||
//if (MayLog(LogFlags))
|
||||
{
|
||||
// print relevant contents to the debug console
|
||||
DbgPrintf("%s\n", DecodedToString(pPSDef).c_str());
|
||||
DbgPrintf(LOG_PREFIX, "%s\n", DecodedToString(pPSDef).c_str());
|
||||
}
|
||||
|
||||
// TODO:
|
||||
|
@ -2550,7 +2552,7 @@ bool PSH_XBOX_SHADER::MoveRemovableParametersRight()
|
|||
if (Result >= MaxConstantFloatRegisters)
|
||||
Result = 0;
|
||||
|
||||
EmuWarning("; Too many constants to emulate, this pixel shader will give unexpected output!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "; Too many constants to emulate, this pixel shader will give unexpected output!");
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -2730,7 +2732,7 @@ bool PSH_XBOX_SHADER::RemoveUselessWrites()
|
|||
if ( (CurArg->Address < MaxTemporaryRegisters)
|
||||
&& ((RegUsage[CurArg->Type][CurArg->Address] & CurArg->Mask) == 0))
|
||||
{
|
||||
DbgPrintf("; Removed useless assignment to register %s\n", CurArg->ToString().c_str());
|
||||
DbgPrintf(LOG_PREFIX, "; Removed useless assignment to register %s\n", CurArg->ToString().c_str());
|
||||
CurArg->Type = PARAM_DISCARD;
|
||||
Result = true;
|
||||
}
|
||||
|
@ -3027,7 +3029,7 @@ void PSH_XBOX_SHADER::ConvertXFCToNative(int i)
|
|||
|
||||
InsertIntermediate(&Ins, InsertPos);
|
||||
++InsertPos;
|
||||
DbgPrintf("; Inserted final combiner calculation of V1R0_sum register\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Inserted final combiner calculation of V1R0_sum register\n");
|
||||
}
|
||||
|
||||
if (NeedsProd)
|
||||
|
@ -3039,7 +3041,7 @@ void PSH_XBOX_SHADER::ConvertXFCToNative(int i)
|
|||
Ins.Parameters[1] = Cur.Parameters[5]; // F
|
||||
InsertIntermediate(&Ins, InsertPos);
|
||||
++InsertPos;
|
||||
DbgPrintf("; Inserted final combiner calculation of EF_prod register\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Inserted final combiner calculation of EF_prod register\n");
|
||||
}
|
||||
|
||||
// The final combiner calculates : r0.rgb=s0*s1 + (1-s0)*s2 + s3
|
||||
|
@ -3202,7 +3204,7 @@ bool PSH_XBOX_SHADER::FixConstantModifiers()
|
|||
Ins.Parameters[0].Modifiers = 0;
|
||||
Ins.CommentString = "Inserted to avoid constant modifier (applied below on register)";
|
||||
InsertIntermediate(&Ins, i);
|
||||
DbgPrintf("; Used intermediate move to avoid constant modifier\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Used intermediate move to avoid constant modifier\n");
|
||||
Result = true;
|
||||
}
|
||||
}
|
||||
|
@ -3290,7 +3292,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
Op2->Parameters[2] = Op1->Parameters[0];
|
||||
DeleteIntermediate(i);
|
||||
DeleteIntermediate(i);
|
||||
DbgPrintf("; Changed temporary MUL,MUL,CND via MOV,MOV,CND into a single CND\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed temporary MUL,MUL,CND via MOV,MOV,CND into a single CND\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3315,7 +3317,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
Op2->Modifier = Op0->Modifier;
|
||||
DeleteIntermediate(i);
|
||||
DeleteIntermediate(i);
|
||||
DbgPrintf("; Changed temporary MUL,MUL,ADD into a single LRP\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed temporary MUL,MUL,ADD into a single LRP\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3332,7 +3334,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
Op2->Modifier = Op0->Modifier;
|
||||
DeleteIntermediate(i);
|
||||
DeleteIntermediate(i);
|
||||
DbgPrintf("; Changed temporary MUL,MUL,ADD into a single MAD\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed temporary MUL,MUL,ADD into a single MAD\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3347,7 +3349,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
Op1->Parameters[2] = Op0->Output[0];
|
||||
// Remove the trailing ADD :
|
||||
DeleteIntermediate(i+2);
|
||||
DbgPrintf("; Changed temporary MUL,MUL,ADD into a MUL,MAD\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed temporary MUL,MUL,ADD into a MUL,MAD\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3364,7 +3366,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
Op2->Parameters[1] = Op1->Parameters[0];
|
||||
DeleteIntermediate(i);
|
||||
DeleteIntermediate(i);
|
||||
DbgPrintf("; Changed temporary MUL,MUL,ADD into a MUL\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed temporary MUL,MUL,ADD into a MUL\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3389,7 +3391,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
Op0->Opcode = PO_MAD;
|
||||
Op0->Parameters[2] = Op1->Parameters[1];
|
||||
DeleteIntermediate(i+1);
|
||||
DbgPrintf("; Changed MUL,ADD into a single MAD\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MUL,ADD into a single MAD\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3474,7 +3476,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
if (CanOptimize)
|
||||
{
|
||||
DeleteIntermediate(i);
|
||||
DbgPrintf("; Moved MOV input into following instructions\n3");
|
||||
DbgPrintf(LOG_PREFIX, "; Moved MOV input into following instructions\n3");
|
||||
Result = true;
|
||||
}
|
||||
}
|
||||
|
@ -3494,7 +3496,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
// > mul r0.rgb, r0,t0
|
||||
Op0->Output[0] = Op1->Output[0];
|
||||
DeleteIntermediate(i+1);
|
||||
DbgPrintf("; Changed temporary MUL,MOV into a MUL\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed temporary MUL,MOV into a MUL\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3507,7 +3509,7 @@ bool PSH_XBOX_SHADER::CombineInstructions()
|
|||
if (IsRegisterFreeFromIndexOnwards(i, PARAM_R, 1))
|
||||
{
|
||||
ReplaceRegisterFromIndexOnwards(i, Op0->Output[0].Type, Op0->Output[0].Address, PARAM_R, 1);
|
||||
DbgPrintf("; Changed fake register by r1\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed fake register by r1\n");
|
||||
Result = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -3535,7 +3537,7 @@ bool PSH_XBOX_SHADER::SimplifyMOV(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
if (CanSimplify)
|
||||
{
|
||||
Cur->Opcode = PO_NOP; // This nop will be removed in a recursive fixup
|
||||
DbgPrintf("; Changed MOV into a NOP\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MOV into a NOP\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3551,7 +3553,7 @@ bool PSH_XBOX_SHADER::SimplifyMOV(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
Cur->Parameters[0].Address = 0;
|
||||
Cur->Parameters[0].Modifiers = 0;
|
||||
Cur->Parameters[1] = Cur->Parameters[0];
|
||||
DbgPrintf("; Changed MOV 0 into a SUB v0,v0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MOV 0 into a SUB v0,v0\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3588,7 +3590,7 @@ bool PSH_XBOX_SHADER::SimplifyMOV(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
// Try to simulate all factors (0.5, 1.0 and 2.0) using an output modifier :
|
||||
Cur->ScaleOutput(Factor);
|
||||
|
||||
DbgPrintf("; Changed MOV {const} into a SUB_factor 1-v0,-v0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MOV {const} into a SUB_factor 1-v0,-v0\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3601,7 +3603,7 @@ bool PSH_XBOX_SHADER::SimplifyADD(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
{
|
||||
// Change it into a MOV (the first argument is already in-place)
|
||||
Cur->Opcode = PO_MOV;
|
||||
DbgPrintf("; Changed ADD s0,0 into a MOV s0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed ADD s0,0 into a MOV s0\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3615,7 +3617,7 @@ bool PSH_XBOX_SHADER::SimplifyMAD(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
// Change it into s2 :
|
||||
Cur->Opcode = PO_MOV;
|
||||
Cur->Parameters[0] = Cur->Parameters[2];
|
||||
DbgPrintf("; Changed MAD s0,0 into a MOV s0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MAD s0,0 into a MOV s0\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3625,7 +3627,7 @@ bool PSH_XBOX_SHADER::SimplifyMAD(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
// Change it into s0+s2 :
|
||||
Cur->Opcode = PO_ADD;
|
||||
Cur->Parameters[1] = Cur->Parameters[2];
|
||||
DbgPrintf("; Changed MAD s0,1,s2 into a ADD s0,s2\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MAD s0,1,s2 into a ADD s0,s2\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3636,7 +3638,7 @@ bool PSH_XBOX_SHADER::SimplifyMAD(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
Cur->Opcode = PO_SUB;
|
||||
Cur->Parameters[1] = Cur->Parameters[0];
|
||||
Cur->Parameters[0] = Cur->Parameters[2];
|
||||
DbgPrintf("; Changed MAD s0,-1,s2 into a SUB s2,s0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MAD s0,-1,s2 into a SUB s2,s0\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3649,7 +3651,7 @@ bool PSH_XBOX_SHADER::SimplifySUB(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
{
|
||||
// Change it into a MOV (the first argument is already in-place)
|
||||
Cur->Opcode = PO_MOV;
|
||||
DbgPrintf("; Changed SUB x, 0 into a MOV x\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed SUB x, 0 into a MOV x\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3663,7 +3665,7 @@ bool PSH_XBOX_SHADER::SimplifyMUL(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
// Change it into a MOV (the 0 argument will be resolve in a recursive MOV fixup) :
|
||||
Cur->Opcode = PO_MOV;
|
||||
Cur->Parameters[0].SetConstValue(0.0);
|
||||
DbgPrintf("; Changed MUL s0,0 into a MOV 0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MUL s0,0 into a MOV 0\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3673,7 +3675,7 @@ bool PSH_XBOX_SHADER::SimplifyMUL(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
// Change it into a simple MOV and scale the output instead :
|
||||
Cur->Opcode = PO_MOV;
|
||||
Cur->ScaleOutput(Cur->Parameters[1].GetConstValue());
|
||||
DbgPrintf("; Changed MUL s0,{const} into a MOV_factor s0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed MUL s0,{const} into a MOV_factor s0\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3688,7 +3690,7 @@ bool PSH_XBOX_SHADER::SimplifyLRP(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
{
|
||||
// Change it into a MUL (calculating the left part : s0*s1 :
|
||||
Cur->Opcode = PO_MUL;
|
||||
DbgPrintf("; Changed LRP s0,s1,s2 (where (1-s0)*s2=0) into a MUL s0,s1\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed LRP s0,s1,s2 (where (1-s0)*s2=0) into a MUL s0,s1\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3699,7 +3701,7 @@ bool PSH_XBOX_SHADER::SimplifyLRP(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
Cur->Opcode = PO_MUL;
|
||||
Cur->Parameters[0].Invert();
|
||||
Cur->Parameters[1] = Cur->Parameters[2];
|
||||
DbgPrintf("; Changed LRP s0,s1,s2 (where s0*s1=0) into a MUL (1-s0),s2\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed LRP s0,s1,s2 (where s0*s1=0) into a MUL (1-s0),s2\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3710,7 +3712,7 @@ bool PSH_XBOX_SHADER::SimplifyLRP(PPSH_INTERMEDIATE_FORMAT Cur)
|
|||
Cur->Opcode = PO_MAD;
|
||||
Cur->Parameters[2] = Cur->Parameters[0];
|
||||
Cur->Parameters[2].Invert();
|
||||
DbgPrintf("; Changed LRP s0,s1,1 into a MAD s0,s1,1-s0\n");
|
||||
DbgPrintf(LOG_PREFIX, "; Changed LRP s0,s1,1 into a MAD s0,s1,1-s0\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -4221,8 +4223,8 @@ static const
|
|||
|
||||
if (hRet != D3D_OK)
|
||||
{
|
||||
EmuWarning("Could not create pixel shader");
|
||||
EmuWarning(std::string((char*)pErrors->GetBufferPointer(), pErrors->GetBufferSize()).c_str());
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Could not create pixel shader");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, std::string((char*)pErrors->GetBufferPointer(), pErrors->GetBufferSize()).c_str());
|
||||
|
||||
printf(ConvertedPixelShaderStr.c_str());
|
||||
|
||||
|
@ -4236,12 +4238,12 @@ static const
|
|||
/*ppCompilationErrors*/&pErrors);
|
||||
|
||||
if (hRet != D3D_OK) {
|
||||
EmuWarning("Could not create pixel shader");
|
||||
EmuWarning(std::string((char*)pErrors->GetBufferPointer(), pErrors->GetBufferSize()).c_str());
|
||||
XTL::CxbxKrnlCleanup("Cannot fall back to the most simple pixel shader!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Could not create pixel shader");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, std::string((char*)pErrors->GetBufferPointer(), pErrors->GetBufferSize()).c_str());
|
||||
XTL::CxbxKrnlCleanup(LOG_PREFIX, "Cannot fall back to the most simple pixel shader!");
|
||||
}
|
||||
|
||||
EmuWarning("We're lying about the creation of a pixel shader!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "We're lying about the creation of a pixel shader!");
|
||||
}
|
||||
|
||||
if (pShader)
|
||||
|
@ -4608,7 +4610,7 @@ inline void HandleInputOutput
|
|||
// 6928: check this as I doubt whether it works really like that
|
||||
/*if(strcmp(szInput[i], "r1")==0)
|
||||
{
|
||||
// DbgPrintf("channel: %s\n", szChannels[i]);
|
||||
// DbgPrintf(LOG_PREFIX, "channel: %s\n", szChannels[i]);
|
||||
// Sleep(3000);
|
||||
|
||||
if((strcmp(szChannels[i], ".a")==0) && (!bR1AWritten)) {
|
||||
|
@ -4813,7 +4815,7 @@ inline void HandleInputOutput
|
|||
//EmuWarningMsg("THIS IS WRONG, FIX ME!");
|
||||
//if(!szOutput[1][0])
|
||||
// strcpy(szOut1, szOutput[2]);
|
||||
DbgPrintf("(!szOutput[0][0] || !szOutput[1][0]) && szOutput[2][0] = TRUE!\n");
|
||||
DbgPrintf(LOG_PREFIX, "(!szOutput[0][0] || !szOutput[1][0]) && szOutput[2][0] = TRUE!\n");
|
||||
|
||||
BOOL bUsable=TRUE;
|
||||
for(i=2; i<4; i++)
|
||||
|
@ -4827,7 +4829,7 @@ inline void HandleInputOutput
|
|||
|
||||
strcpy(szOut, szOutput[2]);
|
||||
|
||||
DbgPrintf("BUsable = TRUE, new output: %s\n", szOut);
|
||||
DbgPrintf(LOG_PREFIX, "BUsable = TRUE, new output: %s\n", szOut);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -5131,7 +5133,7 @@ inline void HandleInputOutput
|
|||
|
||||
if (bEFProduct)
|
||||
{
|
||||
EmuWarning("EF Product and V1R0 register used at the same time!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EF Product and V1R0 register used at the same time!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5652,7 +5654,7 @@ inline BOOL OptimizeOperation
|
|||
{
|
||||
if (szMod[0])
|
||||
{
|
||||
EmuWarning("Pixel Shader: Destination modifier present!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Destination modifier present!");
|
||||
}
|
||||
switch (eOpTypes[2])
|
||||
{
|
||||
|
@ -5777,7 +5779,7 @@ inline BOOL OptimizeOperation
|
|||
{
|
||||
if (szOutputs[2][0] != 'r')
|
||||
{
|
||||
EmuWarning("Pixel Shader: Destination not temporary register!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Destination not temporary register!");
|
||||
}
|
||||
// ab input
|
||||
iOffset += sprintf(szCommand + iOffset, "mul%s r1, %s, %s\n",
|
||||
|
@ -6109,7 +6111,7 @@ inline BOOL OptimizeOperation
|
|||
}
|
||||
if (!bHandled)
|
||||
{
|
||||
EmuWarning("Unhandled pixel shader instruction!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled pixel shader instruction!");
|
||||
}
|
||||
// if (strcmp(szOps[2], "add") == 0)
|
||||
// {
|
||||
|
@ -6123,7 +6125,7 @@ inline BOOL OptimizeOperation
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
// EmuWarning("Unhandled pixel shader instruction!");
|
||||
// EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled pixel shader instruction!");
|
||||
// }
|
||||
// }
|
||||
// else if (strcmp(szOps[2], "cnd") == 0)
|
||||
|
@ -6138,12 +6140,12 @@ inline BOOL OptimizeOperation
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
// EmuWarning("Unhandled pixel shader instruction!");
|
||||
// EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled pixel shader instruction!");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// EmuWarning("Unhandled pixel shader instruction!");
|
||||
// EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled pixel shader instruction!");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ void XTL::EmuExecutePushBuffer
|
|||
{
|
||||
//Check whether Fixup exists or not.
|
||||
if (pFixup != NULL) {
|
||||
LOG_TEST_CASE("PushBuffer has fixups");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "PushBuffer has fixups");
|
||||
//Interpret address of PushBuffer Data and Fixup Data
|
||||
UINT8* pPushBufferData = (UINT8*)pPushBuffer->Data;
|
||||
UINT8* pFixupData = (UINT8*)(pFixup->Data + pFixup->Run);
|
||||
|
@ -187,7 +187,7 @@ DWORD CxbxGetStrideFromVertexShaderHandle(DWORD dwVertexShader)
|
|||
// Test-case : Prince of Persia: The Sands of Time [5553001d]
|
||||
// Test-case : RPM Tuning [Top Gear RPM Tuning] [4B420007]
|
||||
// Test-case : SpyHunter 2 [4D57001B]
|
||||
//LOG_TEST_CASE("Non-FVF Vertex Shaders not yet (completely) supported for PushBuffer emulation!");
|
||||
//LOG_TEST_CASE(LOG_PREFIX, "Non-FVF Vertex Shaders not yet (completely) supported for PushBuffer emulation!");
|
||||
|
||||
CxbxVertexShader *pVertexShader = MapXboxVertexShaderHandleToCxbxVertexShader(dwVertexShader);
|
||||
if (pVertexShader) {
|
||||
|
@ -196,7 +196,7 @@ DWORD CxbxGetStrideFromVertexShaderHandle(DWORD dwVertexShader)
|
|||
Stride = pVertexShader->VertexShaderInfo.VertexStreams[0].HostVertexStride;
|
||||
}
|
||||
else {
|
||||
LOG_TEST_CASE("Non-FVF Vertex Shaders with multiple streams not supported for PushBuffer emulation!");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Non-FVF Vertex Shaders with multiple streams not supported for PushBuffer emulation!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ DWORD CxbxGetStrideFromVertexShaderHandle(DWORD dwVertexShader)
|
|||
Stride = DxbxFVFToVertexSizeInBytes(dwVertexShader, /*bIncludeTextures=*/true);
|
||||
}
|
||||
else {
|
||||
LOG_TEST_CASE("Invalid Vertex Shader not supported for PushBuffer emulation!");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Invalid Vertex Shader not supported for PushBuffer emulation!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ void HLE_pgraph_handle_method(
|
|||
|
||||
// Skip all commands not intended for channel 0 (3D)
|
||||
if (subchannel > 0) {
|
||||
LOG_TEST_CASE("Pushbuffer subchannel > 0");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer subchannel > 0");
|
||||
return; // For now, don't even attempt to run through
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ void HLE_pgraph_handle_method(
|
|||
switch (method) {
|
||||
|
||||
case 0: {
|
||||
LOG_TEST_CASE("Pushbuffer method == 0");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer method == 0");
|
||||
break;
|
||||
}
|
||||
case NV097_NO_OPERATION: { // 0x00000100, NV2A_NOP, No Operation, followed parameters are no use. this operation triggers DPC which is not implemented in HLE
|
||||
|
@ -264,14 +264,14 @@ void HLE_pgraph_handle_method(
|
|||
case NV2A_VP_UPLOAD_CONST(3): {
|
||||
// Can't use NOINCREMENT_FLAG, parameters is constant matrix, 4X4 matrix has 16 DWORDs, maximum of 32 DWORD writes
|
||||
//load constant matrix to empty slot
|
||||
LOG_TEST_CASE("NV2A_VP_UPLOAD_CONST");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "NV2A_VP_UPLOAD_CONST");
|
||||
break;
|
||||
}
|
||||
case NV097_SET_BEGIN_END: { // 0x000017FC, NV2A_VERTEX_BEGIN_END, D3DPUSH_SET_BEGIN_END, 1 DWORD parameter
|
||||
if (parameter == 0) { // Parameter == 0 means SetEnd, EndPush()
|
||||
// Trigger all draws from here
|
||||
if (pg->draw_arrays_length) {
|
||||
LOG_TEST_CASE("PushBuffer : Draw Arrays");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "PushBuffer : Draw Arrays");
|
||||
assert(pg->inline_buffer_length == 0);
|
||||
assert(pg->inline_array_length == 0);
|
||||
assert(pg->inline_elements_length == 0);
|
||||
|
@ -288,7 +288,7 @@ void HLE_pgraph_handle_method(
|
|||
#endif
|
||||
}
|
||||
else if (pg->inline_buffer_length) {
|
||||
LOG_TEST_CASE("PushBuffer : Inline Buffer");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "PushBuffer : Inline Buffer");
|
||||
assert(pg->draw_arrays_length == 0);
|
||||
assert(pg->inline_array_length == 0);
|
||||
assert(pg->inline_elements_length == 0);
|
||||
|
@ -337,7 +337,7 @@ void HLE_pgraph_handle_method(
|
|||
// retrieve vertex shader
|
||||
XTL::DWORD dwVertexShader = g_CurrentXboxVertexShaderHandle;
|
||||
if (dwVertexShader == 0) {
|
||||
LOG_TEST_CASE("FVF Vertex Shader is null");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "FVF Vertex Shader is null");
|
||||
dwVertexShader = -1;
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ void HLE_pgraph_handle_method(
|
|||
#endif
|
||||
}
|
||||
else {
|
||||
LOG_TEST_CASE("EMPTY NV097_SET_BEGIN_END");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "EMPTY NV097_SET_BEGIN_END");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -420,7 +420,7 @@ void HLE_pgraph_handle_method(
|
|||
break;
|
||||
}
|
||||
case NV097_ARRAY_ELEMENT16: { // 0x1800, NV2A_VB_ELEMENT_U16
|
||||
//LOG_TEST_CASE("NV2A_VB_ELEMENT_U16");
|
||||
//LOG_TEST_CASE(LOG_PREFIX, "NV2A_VB_ELEMENT_U16");
|
||||
// Test-case : Turok (in main menu)
|
||||
// Test-case : Hunter Redeemer
|
||||
// Test-case : Otogi (see https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/pull/1113#issuecomment-385593814)
|
||||
|
@ -432,7 +432,7 @@ void HLE_pgraph_handle_method(
|
|||
break;
|
||||
}
|
||||
case NV097_ARRAY_ELEMENT32: { // 0x1808, NV2A_VB_ELEMENT_U32, Index Array Data
|
||||
//LOG_TEST_CASE("NV2A_VB_ELEMENT_U32");
|
||||
//LOG_TEST_CASE(LOG_PREFIX, "NV2A_VB_ELEMENT_U32");
|
||||
// Test-case : Turok (in main menu)
|
||||
assert(pg->inline_elements_length < NV2A_MAX_BATCH_LENGTH);
|
||||
pg__inline_elements[
|
||||
|
@ -463,13 +463,13 @@ void HLE_pgraph_handle_method(
|
|||
case NV097_SET_TRANSFORM_CONSTANT_LOAD: { // 0x00001EA4, NV2A_VP_UPLOAD_CONST_ID, D3DPUSH_SET_TRANSFORM_CONSTANT_LOAD
|
||||
// Add 96 to constant index parameter, one parameter=CONSTANT + 96
|
||||
// Retrieve transform constant index and add 96 to it.
|
||||
LOG_TEST_CASE("NV2A_VP_UPLOAD_CONST_ID");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "NV2A_VP_UPLOAD_CONST_ID");
|
||||
break;
|
||||
}
|
||||
default: { // default case, handling any other unknown methods.
|
||||
char message[256] = {};
|
||||
sprintf(message, "Unhandled PushBuffer Operation : %s (0x%.04X)", NV2AMethodToString(method), method);
|
||||
LOG_TEST_CASE(message);
|
||||
LOG_TEST_CASE(LOG_PREFIX, message);
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
|
@ -626,7 +626,7 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
while (dma_get != dma_put) {
|
||||
// Check if loop reaches end of pushbuffer
|
||||
if (dma_get >= dma_limit) {
|
||||
LOG_TEST_CASE("Last pushbuffer instruction exceeds END of Data");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Last pushbuffer instruction exceeds END of Data");
|
||||
// TODO : throw DMA_PUSHER(MEM_FAULT);
|
||||
return; // For now, don't even attempt to run through
|
||||
}
|
||||
|
@ -661,18 +661,18 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
case COMMAND_TYPE_NONE:
|
||||
break; // fall through
|
||||
case COMMAND_TYPE_JUMP_LONG:
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_TYPE_JUMP_LONG");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_TYPE_JUMP_LONG");
|
||||
dma_get_jmp_shadow = dma_get;
|
||||
dma_get = (uint32_t *)(CONTIGUOUS_MEMORY_BASE | (word & COMMAND_WORD_MASK_JUMP_LONG));
|
||||
continue; // while
|
||||
case COMMAND_TYPE_CALL: // Note : NV2A return is said not to work?
|
||||
if (subr_active) {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_TYPE_CALL while another call was active!");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_TYPE_CALL while another call was active!");
|
||||
// TODO : throw DMA_PUSHER(CALL_SUBR_ACTIVE);
|
||||
return; // For now, don't even attempt to run through
|
||||
}
|
||||
else {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_TYPE_CALL");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_TYPE_CALL");
|
||||
}
|
||||
|
||||
subr_return = dma_get;
|
||||
|
@ -680,7 +680,7 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
dma_get = (uint32_t *)(CONTIGUOUS_MEMORY_BASE | (word & COMMAND_WORD_MASK_JUMP_LONG));
|
||||
continue; // while
|
||||
default:
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_TYPE unknown");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_TYPE unknown");
|
||||
// TODO : throw DMA_PUSHER(INVALID_CMD);
|
||||
return; // For now, don't even attempt to run through
|
||||
} // switch type
|
||||
|
@ -690,7 +690,7 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
dma_state.ni = false;
|
||||
break;
|
||||
case COMMAND_INSTRUCTION_JUMP:
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_INSTRUCTION_JUMP");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_INSTRUCTION_JUMP");
|
||||
dma_get_jmp_shadow = dma_get;
|
||||
dma_get = (uint32_t *)(CONTIGUOUS_MEMORY_BASE | (word & COMMAND_WORD_MASK_JUMP));
|
||||
continue; // while
|
||||
|
@ -698,7 +698,7 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
dma_state.ni = true;
|
||||
break;
|
||||
default:
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_INSTRUCTION unknown");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_INSTRUCTION unknown");
|
||||
// TODO : throw DMA_PUSHER(INVALID_CMD);
|
||||
return; // For now, don't even attempt to run through
|
||||
} // switch instruction
|
||||
|
@ -711,15 +711,15 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
break; // fall through
|
||||
case COMMAND_FLAGS_RETURN: // Note : NV2A return is said not to work?
|
||||
if (word != 0x00020000) {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_FLAGS_RETURN with additional bits?!");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_FLAGS_RETURN with additional bits?!");
|
||||
return; // For now, don't even attempt to run through
|
||||
}
|
||||
else {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_FLAGS_RETURN");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_FLAGS_RETURN");
|
||||
}
|
||||
|
||||
if (!subr_active) {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_FLAGS_RETURN while another call was active!");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_FLAGS_RETURN while another call was active!");
|
||||
// TODO : throw DMA_PUSHER(RET_SUBR_INACTIVE);
|
||||
return; // For now, don't even attempt to run through
|
||||
}
|
||||
|
@ -729,15 +729,15 @@ extern void XTL::EmuExecutePushBufferRaw
|
|||
continue; // while
|
||||
default:
|
||||
if (command.flags == COMMAND_FLAGS_SLI_CONDITIONAL) {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_FLAGS_SLI_CONDITIONAL (NV40+) not available on NV2A");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_FLAGS_SLI_CONDITIONAL (NV40+) not available on NV2A");
|
||||
} else if (command.flags == COMMAND_FLAGS_LONG_NON_INCREASING_METHODS) {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_FLAGS_LONG_NON_INCREASING_METHODS [IB-mode only] not available on NV2A");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_FLAGS_LONG_NON_INCREASING_METHODS [IB-mode only] not available on NV2A");
|
||||
/// No need to do: dma_state.mthd = command.method; dma_state.ni = true;
|
||||
/// dma_state.mcnt = *dma_get++ & 0x00FFFFFF; // Long NI method command count is read from low 24 bits of next word
|
||||
/// dma_get += dma_state.mcnt; // To be safe, skip method data
|
||||
/// continue;
|
||||
} else {
|
||||
LOG_TEST_CASE("Pushbuffer COMMAND_FLAGS unknown");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Pushbuffer COMMAND_FLAGS unknown");
|
||||
}
|
||||
|
||||
/// dma_get += command.method_count; // To be safe, skip method data
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::D3DST
|
||||
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
|
@ -151,7 +152,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(v != 0 && v != 1 && v != 2 && v != 3 && v != 4 && v != 5 && v != 6 && v != 7
|
||||
&& v != 10 && v != 11 && v != 13 && v != 19 && v != 20 && v != 21 && v != 23 && v != 24
|
||||
&& v != 25 && v != 26 && v != 27 && v != 28 && v != 29 && v != 30 && v != 31 && v != 33)
|
||||
EmuWarning("Unhandled RenderState Change @ %d (%d)", v, v + 82);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled RenderState Change @ %d (%d)", v, v + 82);
|
||||
}
|
||||
}
|
||||
//**/
|
||||
|
@ -171,7 +172,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[0+Adjust2] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[0+Adjust2] == 5)
|
||||
EmuWarning("ClampToEdge is unsupported (temporarily)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "ClampToEdge is unsupported (temporarily)");
|
||||
else
|
||||
g_pD3DDevice->SetSamplerState(v, D3DSAMP_ADDRESSU, pCur[0 + Adjust2]);
|
||||
}
|
||||
|
@ -179,7 +180,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[1+Adjust2] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[1+Adjust2] == 5)
|
||||
EmuWarning("ClampToEdge is unsupported (temporarily)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "ClampToEdge is unsupported (temporarily)");
|
||||
else
|
||||
g_pD3DDevice->SetSamplerState(v, D3DSAMP_ADDRESSV, pCur[1 + Adjust2]);
|
||||
}
|
||||
|
@ -187,7 +188,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[2+Adjust2] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[2+Adjust2] == 5)
|
||||
EmuWarning("ClampToEdge is unsupported (temporarily)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "ClampToEdge is unsupported (temporarily)");
|
||||
else
|
||||
g_pD3DDevice->SetSamplerState(v, D3DSAMP_ADDRESSW, pCur[2 + Adjust2]);
|
||||
}
|
||||
|
@ -195,7 +196,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[3+Adjust2] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[3+Adjust2] == 4)
|
||||
EmuWarning("QuinCunx is unsupported (temporarily)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "QuinCunx is unsupported (temporarily)");
|
||||
else
|
||||
g_pD3DDevice->SetSamplerState(v, D3DSAMP_MAGFILTER, pCur[3 + Adjust2]);
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[4+Adjust2] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[4+Adjust2] == 4)
|
||||
EmuWarning("QuinCunx is unsupported (temporarily)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "QuinCunx is unsupported (temporarily)");
|
||||
else
|
||||
g_pD3DDevice->SetSamplerState(v, D3DSAMP_MINFILTER, pCur[4 + Adjust2]);
|
||||
}
|
||||
|
@ -211,7 +212,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[5+Adjust2] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[5+Adjust2] == 4)
|
||||
EmuWarning("QuinCunx is unsupported (temporarily)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "QuinCunx is unsupported (temporarily)");
|
||||
else
|
||||
g_pD3DDevice->SetSamplerState(v, D3DSAMP_MIPFILTER, pCur[5 + Adjust2]);
|
||||
}
|
||||
|
@ -309,7 +310,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
g_pD3DDevice->SetTextureStageState(v, D3DTSS_COLOROP, D3DTOP_BUMPENVMAPLUMINANCE);
|
||||
break;
|
||||
default:
|
||||
EmuWarning("(Temporarily) Unsupported D3DTSS_COLOROP Value (%d)", pCur[12 - Adjust1]);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "(Temporarily) Unsupported D3DTSS_COLOROP Value (%d)", pCur[12 - Adjust1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +328,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
if(pCur[16-Adjust1] != X_D3DTSS_UNK)
|
||||
{
|
||||
if(pCur[16-Adjust1] > 12 && pCur[16-Adjust1] != 14 && pCur[16-Adjust1] != 13)
|
||||
EmuWarning("(Temporarily) Unsupported D3DTSS_ALPHAOP Value (%d)", pCur[16-Adjust1]);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "(Temporarily) Unsupported D3DTSS_ALPHAOP Value (%d)", pCur[16-Adjust1]);
|
||||
else
|
||||
if( pCur[16-Adjust1] == 14 )
|
||||
g_pD3DDevice->SetTextureStageState(v, D3DTSS_ALPHAOP, D3DTOP_BLENDTEXTUREALPHA);
|
||||
|
@ -380,7 +381,7 @@ void XTL::EmuUpdateDeferredStates()
|
|||
}
|
||||
|
||||
if(pass)
|
||||
EmuWarning("Unhandled TextureState Change @ %d->%d", v, r);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled TextureState Change @ %d->%d", v, r);
|
||||
}
|
||||
}
|
||||
//**/
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::VTXB
|
||||
|
||||
#include "CxbxKrnl/VMManager.h"
|
||||
#include "CxbxKrnl/xxhash32.h" // For XXHash32::hash()
|
||||
|
@ -104,7 +105,7 @@ bool GetCachedVertexBufferObject(DWORD pXboxDataPtr, DWORD size, XTL::IDirect3DV
|
|||
nullptr
|
||||
);
|
||||
if (FAILED(hRet)) {
|
||||
CxbxKrnlCleanup("Failed to create vertex buffer");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Failed to create vertex buffer");
|
||||
}
|
||||
|
||||
g_HostVertexBuffers[pXboxDataPtr] = newBuffer;
|
||||
|
@ -134,7 +135,7 @@ bool GetCachedVertexBufferObject(DWORD pXboxDataPtr, DWORD size, XTL::IDirect3DV
|
|||
nullptr
|
||||
);
|
||||
if (FAILED(hRet)) {
|
||||
CxbxKrnlCleanup("Failed to create vertex buffer");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Failed to create vertex buffer");
|
||||
}
|
||||
|
||||
*pVertexBuffer = buffer->pHostVertexBuffer;
|
||||
|
@ -165,7 +166,7 @@ void ActivatePatchedStream
|
|||
pPatchedStream->uiCachedHostVertexStride);
|
||||
//DEBUG_D3DRESULT(hRet, "g_pD3DDevice->SetStreamSource");
|
||||
if (FAILED(hRet)) {
|
||||
CxbxKrnlCleanup("Failed to set the type patched buffer as the new stream source!\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Failed to set the type patched buffer as the new stream source!\n");
|
||||
// TODO : Cartoon hits the above case when the vertex cache size is 0.
|
||||
}
|
||||
|
||||
|
@ -299,7 +300,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
if (bVshHandleIsFVF) {
|
||||
DWORD dwTexN = (XboxFVF & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
||||
if (dwTexN > X_D3DTS_STAGECOUNT) {
|
||||
LOG_TEST_CASE("FVF,dwTexN > X_D3DTS_STAGECOUNT");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "FVF,dwTexN > X_D3DTS_STAGECOUNT");
|
||||
}
|
||||
|
||||
// Check for active linear textures.
|
||||
|
@ -348,7 +349,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
if (pDrawContext->pXboxVertexStreamZeroData != xbnullptr) {
|
||||
// There should only be one stream (stream zero) in this case
|
||||
if (uiStream != 0) {
|
||||
CxbxKrnlCleanup("Trying to patch a Draw..UP with more than stream zero!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Trying to patch a Draw..UP with more than stream zero!");
|
||||
}
|
||||
|
||||
pXboxVertexData = (uint08 *)pDrawContext->pXboxVertexStreamZeroData;
|
||||
|
@ -359,7 +360,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
if (bNeedStreamCopy) {
|
||||
pHostVertexData = (uint08*)malloc(dwHostVertexDataSize);
|
||||
if (pHostVertexData == nullptr) {
|
||||
CxbxKrnlCleanup("Couldn't allocate the new stream zero buffer");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Couldn't allocate the new stream zero buffer");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -377,7 +378,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
0);
|
||||
// DEBUG_D3DRESULT(hRet, "g_pD3DDevice->SetStreamSource");
|
||||
if (FAILED(hRet)) {
|
||||
EmuWarning("g_pD3DDevice->SetStreamSource(uiStream, nullptr, 0)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "g_pD3DDevice->SetStreamSource(uiStream, nullptr, 0)");
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -395,7 +396,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
GetCachedVertexBufferObject(pXboxVertexBuffer->Data, dwHostVertexDataSize, &pNewHostVertexBuffer);
|
||||
|
||||
if (FAILED(pNewHostVertexBuffer->Lock(0, 0, (D3DLockData **)&pHostVertexData, D3DLOCK_DISCARD))) {
|
||||
CxbxKrnlCleanup("Couldn't lock the new buffer");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Couldn't lock the new buffer");
|
||||
}
|
||||
|
||||
// Copy stream for patching and caching.
|
||||
|
@ -619,7 +620,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
}
|
||||
case X_D3DVSDT_NONE: { // 0x02: // Skip it
|
||||
// Test-case : WWE RAW2
|
||||
LOG_TEST_CASE("X_D3DVSDT_NONE");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "X_D3DVSDT_NONE");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -653,7 +654,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
if (bNeedTextureNormalization) {
|
||||
uiTextureCoordinatesByteOffsetInVertex = XTL::DxbxFVFToVertexSizeInBytes(XboxFVF, /*bIncludeTextures=*/false);
|
||||
if (bNeedVertexPatching) {
|
||||
LOG_TEST_CASE("Potential xbox vs host texture-offset difference! (bNeedVertexPatching within bNeedTextureNormalization)");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Potential xbox vs host texture-offset difference! (bNeedVertexPatching within bNeedTextureNormalization)");
|
||||
}
|
||||
// As long as vertices aren't resized / patched up until the texture coordinates,
|
||||
// the uiTextureCoordinatesByteOffsetInVertex on host will match Xbox
|
||||
|
@ -667,14 +668,14 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
#if 0
|
||||
// Check Z. TODO : Why reset Z from 0.0 to 1.0 ? (Maybe fog-related?)
|
||||
if (pVertexDataAsFloat[2] == 0.0f) {
|
||||
// LOG_TEST_CASE("D3DFVF_XYZRHW (Z)"); // Test-case : Many XDK Samples (AlphaFog, PointSprites)
|
||||
// LOG_TEST_CASE(LOG_PREFIX, "D3DFVF_XYZRHW (Z)"); // Test-case : Many XDK Samples (AlphaFog, PointSprites)
|
||||
pVertexDataAsFloat[2] = 1.0f;
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
// Check RHW. TODO : Why reset from 0.0 to 1.0 ? (Maybe 1.0 indicates that the vertices are not to be transformed)
|
||||
if (pVertexDataAsFloat[3] == 0.0f) {
|
||||
// LOG_TEST_CASE("D3DFVF_XYZRHW (RHW)"); // Test-case : Many XDK Samples (AlphaFog, PointSprites)
|
||||
// LOG_TEST_CASE(LOG_PREFIX, "D3DFVF_XYZRHW (RHW)"); // Test-case : Many XDK Samples (AlphaFog, PointSprites)
|
||||
pVertexDataAsFloat[3] = 1.0f;
|
||||
}
|
||||
#endif
|
||||
|
@ -687,10 +688,10 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
if (pActivePixelContainer[i].bTexIsLinear) {
|
||||
switch (pActivePixelContainer[i].NrTexCoords) {
|
||||
case 0:
|
||||
LOG_TEST_CASE("Normalize 0D?");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Normalize 0D?");
|
||||
break;
|
||||
case 1:
|
||||
LOG_TEST_CASE("Normalize 1D");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Normalize 1D");
|
||||
pVertexUVData[0] /= pActivePixelContainer[i].Width;
|
||||
break;
|
||||
case 2:
|
||||
|
@ -698,14 +699,14 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
pVertexUVData[1] /= pActivePixelContainer[i].Height;
|
||||
break;
|
||||
case 3:
|
||||
LOG_TEST_CASE("Normalize 3D");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Normalize 3D");
|
||||
// Test case : HeatShimmer
|
||||
pVertexUVData[0] /= pActivePixelContainer[i].Width;
|
||||
pVertexUVData[1] /= pActivePixelContainer[i].Height;
|
||||
pVertexUVData[2] /= pActivePixelContainer[i].Depth;
|
||||
break;
|
||||
default:
|
||||
LOG_TEST_CASE("Normalize ?D");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Normalize ?D");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -745,7 +746,7 @@ void XTL::CxbxVertexBufferConverter::ConvertStream
|
|||
void XTL::CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
||||
{
|
||||
if ((pDrawContext->XboxPrimitiveType < X_D3DPT_POINTLIST) || (pDrawContext->XboxPrimitiveType > X_D3DPT_POLYGON))
|
||||
CxbxKrnlCleanup("Unknown primitive type: 0x%.02X\n", pDrawContext->XboxPrimitiveType);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unknown primitive type: 0x%.02X\n", pDrawContext->XboxPrimitiveType);
|
||||
|
||||
if (VshHandleIsVertexShader(pDrawContext->hVertexShader)) {
|
||||
m_pVertexShaderInfo = &(MapXboxVertexShaderHandleToCxbxVertexShader(pDrawContext->hVertexShader)->VertexShaderInfo);
|
||||
|
@ -789,7 +790,7 @@ void XTL::CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
|||
// Convex polygon is the same as a triangle fan.
|
||||
// No need to set : pDrawContext->XboxPrimitiveType = X_D3DPT_TRIANGLEFAN;
|
||||
// Test-case : Panzer Dragoon ORTA (when entering in-game)
|
||||
LOG_TEST_CASE("X_D3DPT_POLYGON");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "X_D3DPT_POLYGON");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -801,24 +802,24 @@ VOID XTL::EmuFlushIVB()
|
|||
bool bFVF = VshHandleIsFVF(g_CurrentXboxVertexShaderHandle);
|
||||
DWORD dwCurFVF = (bFVF) ? g_CurrentXboxVertexShaderHandle : g_InlineVertexBuffer_FVF;
|
||||
|
||||
DbgPrintf("g_InlineVertexBuffer_TableOffset := %d\n", g_InlineVertexBuffer_TableOffset);
|
||||
DbgPrintf(LOG_PREFIX, "g_InlineVertexBuffer_TableOffset := %d\n", g_InlineVertexBuffer_TableOffset);
|
||||
|
||||
// Check the given FVF
|
||||
switch (dwCurFVF & D3DFVF_POSITION_MASK) {
|
||||
case 0: // No position ?
|
||||
if (bFVF) {
|
||||
EmuWarning("EmuFlushIVB(): g_CurrentXboxVertexShaderHandle isn't a valid FVF - using D3DFVF_XYZRHW instead!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuFlushIVB(): g_CurrentXboxVertexShaderHandle isn't a valid FVF - using D3DFVF_XYZRHW instead!");
|
||||
dwCurFVF |= D3DFVF_XYZRHW;
|
||||
}
|
||||
else {
|
||||
EmuWarning("EmuFlushIVB(): using g_InlineVertexBuffer_FVF instead of current FVF!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuFlushIVB(): using g_InlineVertexBuffer_FVF instead of current FVF!");
|
||||
dwCurFVF = g_InlineVertexBuffer_FVF;
|
||||
}
|
||||
break;
|
||||
case D3DFVF_XYZRHW:
|
||||
// D3DFVF_NORMAL isn't allowed in combination with D3DFVF_XYZRHW
|
||||
if (dwCurFVF & D3DFVF_NORMAL) {
|
||||
EmuWarning("EmuFlushIVB(): Normal encountered while D3DFVF_XYZRHW is given - switching back to D3DFVF_XYZ!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuFlushIVB(): Normal encountered while D3DFVF_XYZRHW is given - switching back to D3DFVF_XYZ!");
|
||||
dwCurFVF &= ~D3DFVF_POSITION_MASK;
|
||||
dwCurFVF |= D3DFVF_XYZ;
|
||||
}
|
||||
|
@ -853,37 +854,37 @@ VOID XTL::EmuFlushIVB()
|
|||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Position.z;
|
||||
if (dwPos == D3DFVF_XYZRHW) {
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Rhw;
|
||||
DbgPrintf("IVB Position := {%f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Rhw);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Position := {%f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Rhw);
|
||||
}
|
||||
else { // XYZRHW cannot be combined with NORMAL, but the other XYZ formats can :
|
||||
switch (dwPos) {
|
||||
case D3DFVF_XYZ:
|
||||
DbgPrintf("IVB Position := {%f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Position := {%f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z);
|
||||
break;
|
||||
case D3DFVF_XYZB1:
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[0];
|
||||
DbgPrintf("IVB Position := {%f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0]);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Position := {%f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0]);
|
||||
break;
|
||||
case D3DFVF_XYZB2:
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[0];
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[1];
|
||||
DbgPrintf("IVB Position := {%f, %f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0], g_InlineVertexBuffer_Table[v].Blend[1]);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Position := {%f, %f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0], g_InlineVertexBuffer_Table[v].Blend[1]);
|
||||
break;
|
||||
case D3DFVF_XYZB3:
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[0];
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[1];
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[2];
|
||||
DbgPrintf("IVB Position := {%f, %f, %f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0], g_InlineVertexBuffer_Table[v].Blend[1], g_InlineVertexBuffer_Table[v].Blend[2]);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Position := {%f, %f, %f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0], g_InlineVertexBuffer_Table[v].Blend[1], g_InlineVertexBuffer_Table[v].Blend[2]);
|
||||
break;
|
||||
case D3DFVF_XYZB4:
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[0];
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[1];
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[2];
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Blend[3];
|
||||
DbgPrintf("IVB Position := {%f, %f, %f, %f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0], g_InlineVertexBuffer_Table[v].Blend[1], g_InlineVertexBuffer_Table[v].Blend[2], g_InlineVertexBuffer_Table[v].Blend[3]);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Position := {%f, %f, %f, %f, %f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Position.x, g_InlineVertexBuffer_Table[v].Position.y, g_InlineVertexBuffer_Table[v].Position.z, g_InlineVertexBuffer_Table[v].Blend[0], g_InlineVertexBuffer_Table[v].Blend[1], g_InlineVertexBuffer_Table[v].Blend[2], g_InlineVertexBuffer_Table[v].Blend[3]);
|
||||
break;
|
||||
default:
|
||||
CxbxKrnlCleanup("Unsupported Position Mask (FVF := 0x%.08X dwPos := 0x%.08X)", dwCurFVF, dwPos);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unsupported Position Mask (FVF := 0x%.08X dwPos := 0x%.08X)", dwCurFVF, dwPos);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -891,25 +892,25 @@ VOID XTL::EmuFlushIVB()
|
|||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Normal.x;
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Normal.y;
|
||||
*pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Normal.z;
|
||||
DbgPrintf("IVB Normal := {%f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Normal.x, g_InlineVertexBuffer_Table[v].Normal.y, g_InlineVertexBuffer_Table[v].Normal.z);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Normal := {%f, %f, %f}\n", g_InlineVertexBuffer_Table[v].Normal.x, g_InlineVertexBuffer_Table[v].Normal.y, g_InlineVertexBuffer_Table[v].Normal.z);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 // TODO : Was this supported on Xbox from some point in time (pun intended)?
|
||||
if (dwCurFVF & D3DFVF_PSIZE) {
|
||||
*(DWORD*)pVertexBufferData++ = g_InlineVertexBuffer_Table[v].PointSize;
|
||||
DbgPrintf("IVB PointSize := 0x%.08X\n", g_InlineVertexBuffer_Table[v].PointSize);
|
||||
DbgPrintf(LOG_PREFIX, "IVB PointSize := 0x%.08X\n", g_InlineVertexBuffer_Table[v].PointSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dwCurFVF & D3DFVF_DIFFUSE) {
|
||||
*(DWORD*)pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Diffuse;
|
||||
DbgPrintf("IVB Diffuse := 0x%.08X\n", g_InlineVertexBuffer_Table[v].Diffuse);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Diffuse := 0x%.08X\n", g_InlineVertexBuffer_Table[v].Diffuse);
|
||||
}
|
||||
|
||||
if (dwCurFVF & D3DFVF_SPECULAR) {
|
||||
*(DWORD*)pVertexBufferData++ = g_InlineVertexBuffer_Table[v].Specular;
|
||||
DbgPrintf("IVB Specular := 0x%.08X\n", g_InlineVertexBuffer_Table[v].Specular);
|
||||
DbgPrintf(LOG_PREFIX, "IVB Specular := 0x%.08X\n", g_InlineVertexBuffer_Table[v].Specular);
|
||||
}
|
||||
|
||||
for (uint i = 0; i < dwTexN; i++) {
|
||||
|
@ -926,10 +927,10 @@ VOID XTL::EmuFlushIVB()
|
|||
|
||||
if (g_bPrintfOn) {
|
||||
switch (TexSize[i]) {
|
||||
case 1: DbgPrintf("IVB TexCoord%d := {%f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x); break;
|
||||
case 2: DbgPrintf("IVB TexCoord%d := {%f, %f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x, g_InlineVertexBuffer_Table[v].TexCoord[i].y); break;
|
||||
case 3: DbgPrintf("IVB TexCoord%d := {%f, %f, %f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x, g_InlineVertexBuffer_Table[v].TexCoord[i].y, g_InlineVertexBuffer_Table[v].TexCoord[i].z); break;
|
||||
case 4: DbgPrintf("IVB TexCoord%d := {%f, %f, %f, %f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x, g_InlineVertexBuffer_Table[v].TexCoord[i].y, g_InlineVertexBuffer_Table[v].TexCoord[i].z, g_InlineVertexBuffer_Table[v].TexCoord[i].w); break;
|
||||
case 1: DbgPrintf(LOG_PREFIX, "IVB TexCoord%d := {%f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x); break;
|
||||
case 2: DbgPrintf(LOG_PREFIX, "IVB TexCoord%d := {%f, %f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x, g_InlineVertexBuffer_Table[v].TexCoord[i].y); break;
|
||||
case 3: DbgPrintf(LOG_PREFIX, "IVB TexCoord%d := {%f, %f, %f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x, g_InlineVertexBuffer_Table[v].TexCoord[i].y, g_InlineVertexBuffer_Table[v].TexCoord[i].z); break;
|
||||
case 4: DbgPrintf(LOG_PREFIX, "IVB TexCoord%d := {%f, %f, %f, %f}\n", i + 1, g_InlineVertexBuffer_Table[v].TexCoord[i].x, g_InlineVertexBuffer_Table[v].TexCoord[i].y, g_InlineVertexBuffer_Table[v].TexCoord[i].z, g_InlineVertexBuffer_Table[v].TexCoord[i].w); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -937,7 +938,7 @@ VOID XTL::EmuFlushIVB()
|
|||
if (v == 0) {
|
||||
uint VertexBufferUsage = (uintptr_t)pVertexBufferData - (uintptr_t)g_InlineVertexBuffer_pData;
|
||||
if (VertexBufferUsage != uiStride) {
|
||||
CxbxKrnlCleanup("EmuFlushIVB uses wrong stride!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "EmuFlushIVB uses wrong stride!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::VTXSH
|
||||
|
||||
#define _DEBUG_TRACK_VS
|
||||
|
||||
|
@ -612,7 +613,7 @@ static void VshParseInstruction(uint32 *pShaderToken,
|
|||
pInstruction->A.Address = ConvertCRegister(VshGetField(pShaderToken, FLD_CONST));
|
||||
break;
|
||||
default:
|
||||
EmuWarning("Invalid instruction, parameter A type unknown %d", pInstruction->A.ParameterType);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Invalid instruction, parameter A type unknown %d", pInstruction->A.ParameterType);
|
||||
return;
|
||||
}
|
||||
pInstruction->A.Neg = VshGetField(pShaderToken, FLD_A_NEG);
|
||||
|
@ -959,7 +960,7 @@ static void VshWriteShader(VSH_XBOX_SHADER *pShader,
|
|||
DisassemblyPos += sprintf(pDisassembly + DisassemblyPos, "%s", OReg_Name[pIntermediate->Output.Address]);
|
||||
break;
|
||||
default:
|
||||
CxbxKrnlCleanup("Invalid output register in vertex shader!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Invalid output register in vertex shader!");
|
||||
break;
|
||||
}
|
||||
VshWriteOutputMask(pIntermediate->Output.Mask, pDisassembly, &DisassemblyPos);
|
||||
|
@ -1021,7 +1022,7 @@ static void VshVerifyBufferBounds(VSH_XBOX_SHADER *pShader)
|
|||
{
|
||||
if(pShader->IntermediateCount == VSH_MAX_INTERMEDIATE_COUNT)
|
||||
{
|
||||
CxbxKrnlCleanup("Shader exceeds conversion buffer!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Shader exceeds conversion buffer!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1408,7 +1409,7 @@ static void VshRemoveScreenSpaceInstructions(VSH_XBOX_SHADER *pShader)
|
|||
// them, or (c) doesn't reserve c-38 and c-37 for scale and offset.
|
||||
if(deleted != 3)
|
||||
{
|
||||
EmuWarning("Applying screen space vertex shader patching hack!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Applying screen space vertex shader patching hack!");
|
||||
for (int i = 0; i < pShader->IntermediateCount; i++)
|
||||
{
|
||||
VSH_INTERMEDIATE_FORMAT* pIntermediate = &pShader->Intermediate[i];
|
||||
|
@ -1473,7 +1474,7 @@ static void VshRemoveUndeclaredRegisters(VSH_XBOX_SHADER *pShader, bool *pDeclar
|
|||
|
||||
bool used = pDeclaredRegisters[pIntermediate->Parameters[p].Parameter.Address];
|
||||
if (!used) {
|
||||
EmuWarning("Deleting usage of undeclared register v%d", pIntermediate->Parameters[p].Parameter.Address);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Deleting usage of undeclared register v%d", pIntermediate->Parameters[p].Parameter.Address);
|
||||
VshDeleteIntermediate(pShader, i);
|
||||
}
|
||||
}
|
||||
|
@ -1585,7 +1586,7 @@ static boolean VshConvertShader(VSH_XBOX_SHADER *pShader,
|
|||
break;
|
||||
case 15:
|
||||
default:
|
||||
LOG_TEST_CASE("exp instruction with invalid swizzle");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "exp instruction with invalid swizzle");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1633,7 +1634,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)");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Can't simulate dph for other than output r registers (yet)");
|
||||
|
||||
// attempt to find unused register...
|
||||
int outRegister = -1;
|
||||
|
@ -1734,7 +1735,7 @@ static boolean VshConvertShader(VSH_XBOX_SHADER *pShader,
|
|||
}
|
||||
if(R12Replacement == -1)
|
||||
{
|
||||
EmuWarning("Vertex shader uses all r registers, including r12; impossible to convert!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Vertex shader uses all r registers, including r12; impossible to convert!");
|
||||
return FALSE;
|
||||
}
|
||||
for (int j = 0; j < pShader->IntermediateCount; j++)
|
||||
|
@ -1926,7 +1927,7 @@ static void VshConvertToken_NOP(
|
|||
// D3DVSD_NOP
|
||||
if(*pToken != DEF_VSH_NOP)
|
||||
{
|
||||
EmuWarning("Token NOP found, but extra parameters are given!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Token NOP found, but extra parameters are given!");
|
||||
}
|
||||
DbgVshPrintf("\tD3DVSD_NOP(),\n");
|
||||
}
|
||||
|
@ -2083,7 +2084,7 @@ static void VshConvertToken_STREAMDATA_SKIPBYTES(
|
|||
|
||||
DbgVshPrintf("\tD3DVSD_SKIPBYTES(%d), /* xbox ext. */\n", SkipBytesCount);
|
||||
if (SkipBytesCount % sizeof(XTL::DWORD)) {
|
||||
EmuWarning("D3DVSD_SKIPBYTES can't be converted to D3DVSD_SKIP, not divisble by 4.");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "D3DVSD_SKIPBYTES can't be converted to D3DVSD_SKIP, not divisble by 4.");
|
||||
}
|
||||
|
||||
#ifdef CXBX_USE_D3D9
|
||||
|
@ -2342,7 +2343,7 @@ static void VshConvertToken_STREAMDATA_REG(
|
|||
|
||||
if(HostVertexElementDataType == D3DDECLTYPE_UNUSED)
|
||||
{
|
||||
EmuWarning("/* WARNING: Fatal type mismatch, no fitting type! */");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "/* WARNING: Fatal type mismatch, no fitting type! */");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2504,7 +2505,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
|||
DWORD regNum = *pDeclToken & X_D3DVSD_VERTEXREGMASK;
|
||||
if (regNum >= temporaryCount /*12*/) {
|
||||
// Lego Star Wars hits this
|
||||
LOG_TEST_CASE("RegNum > 12");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "RegNum > 12");
|
||||
pDeclToken++;
|
||||
continue;
|
||||
}
|
||||
|
@ -2523,7 +2524,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
|||
|
||||
if(!pShader)
|
||||
{
|
||||
EmuWarning("Couldn't allocate memory for vertex shader conversion buffer");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Couldn't allocate memory for vertex shader conversion buffer");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
pShader->ShaderHeader = *pShaderHeader;
|
||||
|
@ -2532,15 +2533,15 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
|||
case VERSION_XVS:
|
||||
break;
|
||||
case VERSION_XVSS:
|
||||
EmuWarning("Might not support vertex state shaders?");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Might not support vertex state shaders?");
|
||||
hRet = E_FAIL;
|
||||
break;
|
||||
case VERSION_XVSW:
|
||||
EmuWarning("Might not support vertex read/write shaders?");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Might not support vertex read/write shaders?");
|
||||
hRet = E_FAIL;
|
||||
break;
|
||||
default:
|
||||
EmuWarning("Unknown vertex shader version 0x%02X", pShaderHeader->Version);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown vertex shader version 0x%02X", pShaderHeader->Version);
|
||||
hRet = E_FAIL;
|
||||
break;
|
||||
}
|
||||
|
@ -2563,7 +2564,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
|||
|
||||
// Do not attempt to compile empty shaders
|
||||
if (pShader->IntermediateCount == 0) {
|
||||
EmuWarning("Skipped empty Vertex Shader");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Skipped empty Vertex Shader");
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -2583,7 +2584,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
|||
// HACK: Azurik. Prevent Direct3D from trying to assemble this.
|
||||
if(!strcmp(pShaderDisassembly, "vs.2.x\n"))
|
||||
{
|
||||
EmuWarning("Replacing empty vertex shader with fallback");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Replacing empty vertex shader with fallback");
|
||||
|
||||
static const char dummy[] =
|
||||
"vs.2.x\n"
|
||||
|
@ -2615,8 +2616,8 @@ extern HRESULT XTL::EmuRecompileVshFunction
|
|||
|
||||
if (FAILED(hRet))
|
||||
{
|
||||
EmuWarning("Couldn't assemble recompiled vertex shader");
|
||||
EmuWarning("%s", pErrors->GetBufferPointer());
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Couldn't assemble recompiled vertex shader");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "%s", pErrors->GetBufferPointer());
|
||||
}
|
||||
|
||||
if( pErrors )
|
||||
|
|
|
@ -36,14 +36,13 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define LOG_PREFIX CXBXR_MODULE::DSOUND
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl {
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
};
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::DSOUND
|
||||
|
||||
#include <dsound.h>
|
||||
#include <thread>
|
||||
#include "CxbxKrnl.h"
|
||||
|
@ -218,7 +217,7 @@ static void dsound_thread_worker(LPVOID);
|
|||
#define RETURN_RESULT_CHECK(hRet) { \
|
||||
static bool bPopupShown = false; if (!bPopupShown && hRet) { bPopupShown = true; \
|
||||
printf("Return result report: 0x%08X\nIn %s (%s)\n", hRet, __func__, __FILE__); \
|
||||
EmuWarning("An issue has been found. Please report game title and console's output of return result," \
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "An issue has been found. Please report game title and console's output of return result," \
|
||||
" function, and file name to https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/485"); } return hRet; }
|
||||
|
||||
#include "EmuDSoundInline.hpp"
|
||||
|
@ -303,13 +302,13 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
}
|
||||
|
||||
if (dsErrorMsg != nullptr) {
|
||||
CxbxKrnlCleanup(dsErrorMsg, hRet);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, dsErrorMsg, hRet);
|
||||
}
|
||||
|
||||
hRet = g_pDSound8->SetCooperativeLevel(g_hEmuWindow, DSSCL_PRIORITY);
|
||||
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("g_pDSound8->SetCooperativeLevel Failed!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "g_pDSound8->SetCooperativeLevel Failed!");
|
||||
}
|
||||
|
||||
// clear sound buffer cache
|
||||
|
@ -337,7 +336,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
hRet = g_pDSound8->CreateSoundBuffer(&bufferDesc, &g_pDSoundPrimaryBuffer, nullptr);
|
||||
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Creating primary buffer for DirectSound Failed!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Creating primary buffer for DirectSound Failed!");
|
||||
}
|
||||
|
||||
/* Quote from MDSN "For the primary buffer, you must use the
|
||||
|
@ -350,7 +349,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
hRet = g_pDSoundPrimaryBuffer->QueryInterface(IID_IDirectSound3DListener8, (LPVOID*)&g_pDSoundPrimary3DListener8);
|
||||
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Creating primary 3D Listener for DirectSound Failed!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Creating primary 3D Listener for DirectSound Failed!");
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
|
@ -936,7 +935,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateBuffer)
|
|||
|
||||
hRet = XTL::EMUPATCH(DirectSoundCreate)(NULL, &g_pDSound8, NULL);
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Unable to initialize DirectSound!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unable to initialize DirectSound!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -962,7 +961,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateBuffer)
|
|||
DWORD dwAcceptableMask = 0x00000010 | 0x00000020 | 0x00000080 | 0x00000100 | 0x00020000 | 0x00040000 /*| 0x00080000*/;
|
||||
|
||||
if (pdsbd->dwFlags & (~dwAcceptableMask)) {
|
||||
EmuWarning("Use of unsupported pdsbd->dwFlags mask(s) (0x%.08X)", pdsbd->dwFlags & (~dwAcceptableMask));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Use of unsupported pdsbd->dwFlags mask(s) (0x%.08X)", pdsbd->dwFlags & (~dwAcceptableMask));
|
||||
}
|
||||
|
||||
// HACK: Hot fix for titles not giving CTRL3D flag. Xbox might accept it, however the host does not.
|
||||
|
@ -985,7 +984,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateBuffer)
|
|||
GeneratePCMFormat(DSBufferDesc, pdsbd->lpwfxFormat, (*ppBuffer)->EmuFlags, pdsbd->dwBufferBytes, &(*ppBuffer)->X_BufferCache, (*ppBuffer)->X_BufferCacheSize);
|
||||
(*ppBuffer)->EmuBufferDesc = DSBufferDesc;
|
||||
|
||||
DbgPrintf("EmuDSound: DirectSoundCreateBuffer, *ppBuffer := 0x%08X, bytes := 0x%08X\n", *ppBuffer, (*ppBuffer)->EmuBufferDesc.dwBufferBytes);
|
||||
DbgPrintf(LOG_PREFIX, "DirectSoundCreateBuffer, *ppBuffer := 0x%08X, bytes := 0x%08X\n", *ppBuffer, (*ppBuffer)->EmuBufferDesc.dwBufferBytes);
|
||||
|
||||
DSoundBufferCreate(&DSBufferDesc, (*ppBuffer)->EmuDirectSoundBuffer8);
|
||||
if (pdsbd->dwFlags & DSBCAPS_CTRL3D) {
|
||||
|
@ -1218,7 +1217,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_Lock)
|
|||
}
|
||||
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("DirectSoundBuffer Lock Failed!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "DirectSoundBuffer Lock Failed!");
|
||||
}
|
||||
|
||||
// Host lock position
|
||||
|
@ -1486,7 +1485,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetCurrentPosition)
|
|||
HRESULT hRet = pThis->EmuDirectSoundBuffer8->SetCurrentPosition(dwNewPosition);
|
||||
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("SetCurrentPosition Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "SetCurrentPosition Failed!");
|
||||
}
|
||||
|
||||
leaveCriticalSection;
|
||||
|
@ -1545,7 +1544,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_Play)
|
|||
pThis->X_lock.dwLockBytes2);
|
||||
|
||||
if (dwFlags & ~(X_DSBPLAY_LOOPING | X_DSBPLAY_FROMSTART | X_DSBPLAY_SYNCHPLAYBACK)) {
|
||||
CxbxKrnlCleanup("Unsupported Playing Flags");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unsupported Playing Flags");
|
||||
}
|
||||
pThis->EmuPlayFlags = dwFlags;
|
||||
|
||||
|
@ -1568,7 +1567,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_Play)
|
|||
if (hRet == DS_OK) {
|
||||
if (dwFlags & X_DSBPLAY_FROMSTART) {
|
||||
if (pThis->EmuDirectSoundBuffer8->SetCurrentPosition(0) != DS_OK) {
|
||||
EmuWarning("Rewinding buffer failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Rewinding buffer failed!");
|
||||
}
|
||||
}
|
||||
if ((pThis->EmuFlags & DSE_FLAG_SYNCHPLAYBACK_CONTROL) == 0) {
|
||||
|
@ -1738,7 +1737,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
|
||||
hRet = XTL::EMUPATCH(DirectSoundCreate)(NULL, &g_pDSound8, NULL);
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Unable to initialize DirectSound!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unable to initialize DirectSound!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1766,7 +1765,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
DWORD dwAcceptableMask = 0x00000010; // TODO: Note 0x00040000 is being ignored (DSSTREAMCAPS_LOCDEFER)
|
||||
|
||||
if (pdssd->dwFlags & (~dwAcceptableMask)) {
|
||||
EmuWarning("Use of unsupported pdssd->dwFlags mask(s) (0x%.08X)", pdssd->dwFlags & (~dwAcceptableMask));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Use of unsupported pdssd->dwFlags mask(s) (0x%.08X)", pdssd->dwFlags & (~dwAcceptableMask));
|
||||
}
|
||||
DSBufferDesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
//DSBufferDesc->dwFlags = (pdssd->dwFlags & dwAcceptableMask) | DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2;
|
||||
|
@ -1799,7 +1798,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
(*ppStream)->Xb_lpvContext = pdssd->lpvContext;
|
||||
//TODO: Implement mixbin variable support. Or just merge pdssd struct into DS Stream class.
|
||||
|
||||
DbgPrintf("EmuDSound: DirectSoundCreateStream, *ppStream := 0x%.08X\n", *ppStream);
|
||||
DbgPrintf(LOG_PREFIX, "DirectSoundCreateStream, *ppStream := 0x%.08X\n", *ppStream);
|
||||
|
||||
DSoundBufferCreate(&DSBufferDesc, (*ppStream)->EmuDirectSoundBuffer8);
|
||||
if (DSBufferDesc.dwFlags & DSBCAPS_CTRL3D) {
|
||||
|
@ -1859,7 +1858,7 @@ VOID WINAPI XTL::EMUPATCH(CMcpxStream_Dummy_0x10)(DWORD dwDummy1, DWORD dwDummy2
|
|||
|
||||
// Causes deadlock in Halo...
|
||||
// TODO: Verify that this is a Vista related problem (I HATE Vista!)
|
||||
// EmuWarning("EmuCMcpxStream_Dummy_0x10 is ignored!");
|
||||
// EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuCMcpxStream_Dummy_0x10 is ignored!");
|
||||
|
||||
leaveCriticalSection;
|
||||
|
||||
|
@ -1991,7 +1990,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_GetInfo)
|
|||
LOG_FUNC_END;
|
||||
|
||||
// TODO: A (real) implementation?
|
||||
EmuWarning("EmuDirectSound_CDirectSoundStream_GetInfo is not yet supported!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuDirectSound_CDirectSoundStream_GetInfo is not yet supported!");
|
||||
|
||||
if (pInfo) {
|
||||
pInfo->dwFlags = XMO_STREAMF_FIXED_SAMPLE_SIZE;
|
||||
|
@ -2132,7 +2131,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_Process)
|
|||
//TODO: What to do with output buffer audio variable? Need test case or functional source code.
|
||||
// NOTE: pOutputBuffer is reserved, must be set to NULL from titles.
|
||||
if (pOutputBuffer != xbnullptr) {
|
||||
LOG_TEST_CASE("pOutputBuffer is not nullptr, please report title test case to issue tracker. Thanks!");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "pOutputBuffer is not nullptr, please report title test case to issue tracker. Thanks!");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -3005,7 +3004,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_EnableHeadphones)
|
|||
LOG_FUNC_END;
|
||||
|
||||
//Windows Vista and later does not set speaker configuration from SetSpeakerConfig function.
|
||||
EmuWarning("EmuIDirectSound_EnableHeadphones ignored");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuIDirectSound_EnableHeadphones ignored");
|
||||
|
||||
leaveCriticalSection;
|
||||
|
||||
|
@ -3311,7 +3310,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_PlayEx)
|
|||
|
||||
//TODO: Need implement support for rtTimeStamp.
|
||||
if (rtTimeStamp != 0) {
|
||||
EmuWarning("Not implemented for rtTimeStamp greater than 0 of %08d", rtTimeStamp);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Not implemented for rtTimeStamp greater than 0 of %08d", rtTimeStamp);
|
||||
}
|
||||
|
||||
HRESULT hRet = XTL::EMUPATCH(IDirectSoundBuffer_Play)(pThis, NULL, NULL, dwFlags);
|
||||
|
@ -3348,7 +3347,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_GetCaps)
|
|||
pDSCaps->dwFree2DBuffers = (pDSCaps->dwFreeBufferSGEs == 0 ? 0 : 0x200 /* TODO: Replace me to g_dwFree2DBuffers*/ );
|
||||
pDSCaps->dwFree3DBuffers = (pDSCaps->dwFreeBufferSGEs == 0 ? 0 : 0x200 /* TODO: Replace me to g_dwFree3DBuffers*/ );
|
||||
|
||||
DbgPrintf("X_DSCAPS: dwFree2DBuffers = %8X | dwFree3DBuffers = %8X | dwFreeBufferSGEs = %08X | dwMemAlloc = %08X\n", pDSCaps->dwFree2DBuffers, pDSCaps->dwFree3DBuffers, pDSCaps->dwFreeBufferSGEs, pDSCaps->dwMemoryAllocated);
|
||||
DbgPrintf(LOG_PREFIX, "X_DSCAPS: dwFree2DBuffers = %8X | dwFree3DBuffers = %8X | dwFreeBufferSGEs = %08X | dwMemAlloc = %08X\n", pDSCaps->dwFree2DBuffers, pDSCaps->dwFree3DBuffers, pDSCaps->dwFreeBufferSGEs, pDSCaps->dwMemoryAllocated);
|
||||
}
|
||||
|
||||
leaveCriticalSection;
|
||||
|
@ -3729,12 +3728,12 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetNotificationPositions)
|
|||
if (hRet == DS_OK) {
|
||||
hRet = pNotify->SetNotificationPositions(dwNotifyCount, paNotifies);
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("Could not set notification position(s)!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Could not set notification position(s)!");
|
||||
}
|
||||
|
||||
pNotify->Release();
|
||||
} else {
|
||||
EmuWarning("Could not create notification interface!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Could not create notification interface!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ inline void XADPCM2PCMFormat(LPWAVEFORMATEX lpwfxFormat)
|
|||
{
|
||||
|
||||
#if 0 //For testing purpose if XADPCM to PCM is not accurate.
|
||||
DbgPrintf("EmuDSound: XADPCM WAVEFORMATEX\n"
|
||||
DbgPrintf(LOG_PREFIX, "EmuDSound: XADPCM WAVEFORMATEX\n"
|
||||
"{\n"
|
||||
" wFormatTag : 0x%.04hX\n"
|
||||
" nChannels : 0x%.02hd\n"
|
||||
|
@ -141,7 +141,7 @@ inline void XADPCM2PCMFormat(LPWAVEFORMATEX lpwfxFormat)
|
|||
#endif
|
||||
|
||||
#if 0 //For testing purpose if XADPCM to PCM is not accurate.
|
||||
DbgPrintf("EmuDSound: Converted to PCM WAVEFORMATEX\n"
|
||||
DbgPrintf(LOG_PREFIX, "EmuDSound: Converted to PCM WAVEFORMATEX\n"
|
||||
"{\n"
|
||||
" wFormatTag : 0x%.04hX\n"
|
||||
" nChannels : 0x%.02hd\n"
|
||||
|
@ -255,7 +255,7 @@ inline void GeneratePCMFormat(
|
|||
bIsSpecial = true;
|
||||
dwEmuFlags |= DSE_FLAG_RECIEVEDATA;
|
||||
|
||||
EmuWarning("Creating dummy WAVEFORMATEX (pdsbd->lpwfxFormat = xbnullptr)...");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Creating dummy WAVEFORMATEX (pdsbd->lpwfxFormat = xbnullptr)...");
|
||||
|
||||
// HACK: This is a special sound buffer, create dummy WAVEFORMATEX data.
|
||||
// It's supposed to recieve data rather than generate it. Buffers created
|
||||
|
@ -407,7 +407,7 @@ inline void DSoundBufferCreate(LPDSBUFFERDESC pDSBufferDesc, LPDIRECTSOUNDBUFFER
|
|||
inline void DSound3DBufferCreate(LPDIRECTSOUNDBUFFER8 pDSBuffer, LPDIRECTSOUND3DBUFFER8 &pDS3DBuffer) {
|
||||
HRESULT hRetDS3D = pDSBuffer->QueryInterface(IID_IDirectSound3DBuffer, (LPVOID*)&(pDS3DBuffer));
|
||||
if (hRetDS3D != DS_OK) {
|
||||
EmuWarning("CreateSound3DBuffer Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "CreateSound3DBuffer Failed!");
|
||||
pDS3DBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ inline void DSoundStreamClearPacket(
|
|||
BOOL checkHandle = SetEvent(unionEventContext);
|
||||
if (checkHandle == 0) {
|
||||
DWORD error = GetLastError();
|
||||
EmuWarning("DSOUND: Unable to set event on packet's hCompletionEvent. %8X | error = %8X", unionEventContext, error);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unable to set event on packet's hCompletionEvent. %8X | error = %8X", unionEventContext, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -942,7 +942,7 @@ inline HRESULT HybridDirectSoundBuffer_GetCurrentPosition(
|
|||
HRESULT hRet = pDSBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
|
||||
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("GetCurrentPosition Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "GetCurrentPosition Failed!");
|
||||
}
|
||||
|
||||
if (pdwCurrentPlayCursor != xbnullptr) {
|
||||
|
@ -1070,7 +1070,7 @@ inline HRESULT HybridDirectSoundBuffer_Play(
|
|||
// rewind buffer
|
||||
if ((dwFlags & X_DSBPLAY_FROMSTART)) {
|
||||
if (pDSBuffer->SetCurrentPosition(0) != DS_OK) {
|
||||
EmuWarning("Rewinding buffer failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Rewinding buffer failed!");
|
||||
}
|
||||
|
||||
dwFlags &= ~X_DSBPLAY_FROMSTART;
|
||||
|
@ -1729,7 +1729,7 @@ inline HRESULT HybridDirectSoundBuffer_SetVolume(
|
|||
if (lVolume <= -6400 && lVolume != DSBVOLUME_MIN) {
|
||||
lVolume = DSBVOLUME_MIN;
|
||||
} else if (lVolume > 0) {
|
||||
EmuWarning("HybridDirectSoundBuffer_SetVolume has received greater than 0: %ld", lVolume);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "HybridDirectSoundBuffer_SetVolume has received greater than 0: %ld", lVolume);
|
||||
lVolume = 0;
|
||||
}
|
||||
if ((dwEmuFlags & DSE_FLAG_DEBUG_MUTE) > 0) {
|
||||
|
|
|
@ -500,7 +500,7 @@ void EmuInitFS()
|
|||
fsInstructions.push_back({ { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs58 }); // mov eax, large fs:58
|
||||
fsInstructions.push_back({ { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Eax }); // mov large fs:0, eax
|
||||
|
||||
DbgPrintf("INIT: Patching FS Register Accesses\n");
|
||||
DbgPrintf(CXBXR_MODULE::INIT, "Patching FS Register Accesses\n");
|
||||
DWORD sizeOfImage = CxbxKrnl_XbeHeader->dwSizeofImage;
|
||||
long numberOfInstructions = fsInstructions.size();
|
||||
|
||||
|
@ -510,7 +510,7 @@ void EmuInitFS()
|
|||
continue;
|
||||
}
|
||||
|
||||
DbgPrintf("INIT: Searching for FS Instruction in section %s\n", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
DbgPrintf(CXBXR_MODULE::INIT, "Searching for FS Instruction in section %s\n", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
xbaddr startAddr = CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwVirtualAddr;
|
||||
xbaddr endAddr = startAddr + CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwSizeofRaw;
|
||||
for (xbaddr addr = startAddr; addr < endAddr; addr++)
|
||||
|
@ -527,7 +527,7 @@ void EmuInitFS()
|
|||
|
||||
if (memcmp((void*)addr, &fsInstructions[i].data[0], sizeOfData) == 0)
|
||||
{
|
||||
DbgPrintf("INIT: Patching FS Instruction at 0x%.8X\n", addr);
|
||||
DbgPrintf(CXBXR_MODULE::INIT, "Patching FS Instruction at 0x%.8X\n", addr);
|
||||
|
||||
// Write Call opcode
|
||||
*(uint08*)addr = OPCODE_CALL_E8;
|
||||
|
@ -543,7 +543,7 @@ void EmuInitFS()
|
|||
}
|
||||
}
|
||||
|
||||
DbgPrintf("INIT: Done patching FS Register Accesses\n");
|
||||
DbgPrintf(CXBXR_MODULE::INIT, "Done patching FS Register Accesses\n");
|
||||
}
|
||||
|
||||
// generate fs segment selector
|
||||
|
@ -579,16 +579,16 @@ void EmuGenerateFS(Xbe::TLS *pTLS, void *pTLSData)
|
|||
#ifdef _DEBUG_TRACE
|
||||
// dump raw TLS data
|
||||
if (pNewTLS == nullptr) {
|
||||
DbgPrintf("KRNL: TLS Non-Existant (OK)\n");
|
||||
DbgPrintf(LOG_PREFIX, "TLS Non-Existant (OK)\n");
|
||||
} else {
|
||||
DbgPrintf("KRNL: TLS Data Dump...\n");
|
||||
DbgPrintf(LOG_PREFIX, "TLS Data Dump...\n");
|
||||
if (g_bPrintfOn) {
|
||||
for (uint32 v = 0; v < dwCopySize; v++) {// Note : Don't dump dwZeroSize
|
||||
|
||||
uint08 *bByte = (uint08*)pNewTLS + v;
|
||||
|
||||
if (v % 0x10 == 0) {
|
||||
DbgPrintf("KRNL: 0x%.8X:", (xbaddr)bByte);
|
||||
DbgPrintf(LOG_PREFIX, "0x%.8X:", (xbaddr)bByte);
|
||||
}
|
||||
|
||||
// Note : Use printf instead of DbgPrintf here, which prefixes with GetCurrentThreadId() :
|
||||
|
@ -664,5 +664,5 @@ void EmuGenerateFS(Xbe::TLS *pTLS, void *pTLSData)
|
|||
// Make the KPCR struct available to KeGetPcr()
|
||||
EmuKeSetPcr(NewPcr);
|
||||
|
||||
DbgPrintf("KRNL: Installed KPCR in TIB_ArbitraryDataSlot (with pTLS = 0x%.8X)\n", pTLS);
|
||||
DbgPrintf(LOG_PREFIX, "Installed KPCR in TIB_ArbitraryDataSlot (with pTLS = 0x%.8X)\n", pTLS);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ void CxbxCreatePartitionHeaderFile(std::string filename, bool partition0 = false
|
|||
{
|
||||
HANDLE hf = CreateFile(filename.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
|
||||
if (!hf) {
|
||||
CxbxKrnlCleanup("CxbxCreatePartitionHeaderFile Failed\nUnable to create file: %s (%s)", filename);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "CxbxCreatePartitionHeaderFile Failed\nUnable to create file: %s (%s)", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ XboxPartitionTable CxbxGetPartitionTable()
|
|||
XboxPartitionTable table;
|
||||
FILE* fp = fopen((CxbxBasePath + "Partition0.bin").c_str(), "rb");
|
||||
if (fp == nullptr) {
|
||||
CxbxKrnlCleanup("CxbxGetPartitionTable Failed:\nUnable to open file: %s", (CxbxBasePath + "Partition0.bin").c_str());
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "CxbxGetPartitionTable Failed:\nUnable to open file: %s", (CxbxBasePath + "Partition0.bin").c_str());
|
||||
}
|
||||
|
||||
fread(&table, sizeof(XboxPartitionTable), 1, fp);
|
||||
|
@ -150,7 +150,7 @@ int CxbxGetPartitionNumberFromHandle(HANDLE hFile)
|
|||
// Get which partition number is being accessed, by parsing the filename and extracting the last portion
|
||||
char buffer[MAX_PATH] = {0};
|
||||
if (!GetFinalPathNameByHandle(hFile, buffer, MAX_PATH, VOLUME_NAME_DOS)) {
|
||||
CxbxKrnlCleanup("CxbxGetPartitionNumberFromHandle Failed:\nUnable to determine path for HANDLE 0x%08X", hFile);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "CxbxGetPartitionNumberFromHandle Failed:\nUnable to determine path for HANDLE 0x%08X", hFile);
|
||||
}
|
||||
|
||||
std::string bufferString(buffer);
|
||||
|
@ -166,7 +166,7 @@ std::string CxbxGetPartitionDataPathFromHandle(HANDLE hFile)
|
|||
// Get which partition number is being accessed, by parsing the filename and extracting the last portion
|
||||
char buffer[MAX_PATH] = {0};
|
||||
if (!GetFinalPathNameByHandle(hFile, buffer, MAX_PATH, VOLUME_NAME_DOS)) {
|
||||
CxbxKrnlCleanup("CxbxGetPartitionDataPathFromHandle Failed:\nUnable to determine path for HANDLE 0x%08X", hFile);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "CxbxGetPartitionDataPathFromHandle Failed:\nUnable to determine path for HANDLE 0x%08X", hFile);
|
||||
}
|
||||
|
||||
std::string bufferString(buffer);
|
||||
|
@ -181,7 +181,7 @@ void CxbxFormatPartitionByHandle(HANDLE hFile)
|
|||
|
||||
// Sanity check, make sure we are actually deleting something within the Cxbx-Reloaded folder
|
||||
if (partitionPath.find("Cxbx-Reloaded") == std::string::npos) {
|
||||
EmuWarning("Attempting to format a path that is not within a Cxbx-Reloaded data folder... Ignoring!\n");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Attempting to format a path that is not within a Cxbx-Reloaded data folder... Ignoring!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ NTSTATUS CxbxConvertFilePath(
|
|||
NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir);
|
||||
RelativePath.erase(0, 5); // Remove '$HOME'
|
||||
} else
|
||||
CxbxKrnlCleanup(("Unsupported path macro : " + OriginalPath).c_str());
|
||||
CxbxKrnlCleanup(LOG_PREFIX, ("Unsupported path macro : " + OriginalPath).c_str());
|
||||
}
|
||||
// Check if the path starts with a relative path indicator :
|
||||
else if (RelativePath[0] == '.') // "4x4 Evo 2" needs this
|
||||
|
@ -439,7 +439,7 @@ NTSTATUS CxbxConvertFilePath(
|
|||
replace_all( RelativePath, "\\\\", "\\" );
|
||||
|
||||
if (g_bPrintfOn) {
|
||||
DbgPrintf("FILE: %s Corrected path...\n", aFileAPIName.c_str());
|
||||
DbgPrintf(LOG_PREFIX, "%s Corrected path...\n", aFileAPIName.c_str());
|
||||
printf(" Org:\"%s\"\n", OriginalPath.c_str());
|
||||
if (_strnicmp(HostPath.c_str(), CxbxBasePath.c_str(), CxbxBasePath.length()) == 0) {
|
||||
printf(" New:\"$CxbxPath\\%s%s\"\n", (HostPath.substr(CxbxBasePath.length(), std::string::npos)).c_str(), RelativePath.c_str());
|
||||
|
@ -649,12 +649,12 @@ NTSTATUS EmuNtSymbolicLinkObject::Init(std::string aSymbolicLinkName, std::strin
|
|||
if (RootDirectoryHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
result = STATUS_DEVICE_DOES_NOT_EXIST; // TODO : Is this the correct error?
|
||||
CxbxKrnlCleanup((std::string("Could not map ") + HostSymbolicLinkPath).c_str());
|
||||
CxbxKrnlCleanup(LOG_PREFIX, (std::string("Could not map ") + HostSymbolicLinkPath).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
NtSymbolicLinkObjects[DriveLetter - 'A'] = this;
|
||||
DbgPrintf("FILE: Linked \"%s\" to \"%s\" (residing at \"%s\")\n", aSymbolicLinkName.c_str(), aFullPath.c_str(), HostSymbolicLinkPath.c_str());
|
||||
DbgPrintf(LOG_PREFIX, "Linked \"%s\" to \"%s\" (residing at \"%s\")\n", aSymbolicLinkName.c_str(), aFullPath.c_str(), HostSymbolicLinkPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ extern DWORD ExecuteDpcQueue();
|
|||
void KiUnexpectedInterrupt()
|
||||
{
|
||||
xboxkrnl::KeBugCheck(TRAP_CAUSE_UNKNOWN); // see
|
||||
CxbxKrnlCleanup("Unexpected Software Interrupt!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unexpected Software Interrupt!");
|
||||
}
|
||||
|
||||
void CallSoftwareInterrupt(const xboxkrnl::KIRQL SoftwareIrql)
|
||||
|
@ -166,7 +166,7 @@ void CallSoftwareInterrupt(const xboxkrnl::KIRQL SoftwareIrql)
|
|||
KiUnexpectedInterrupt();
|
||||
break;
|
||||
case APC_LEVEL: // = 1 // HalpApcInterrupt
|
||||
EmuWarning("Unimplemented Software Interrupt (APC)"); // TODO : ExecuteApcQueue();
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unimplemented Software Interrupt (APC)"); // TODO : ExecuteApcQueue();
|
||||
break;
|
||||
case DISPATCH_LEVEL: // = 2
|
||||
ExecuteDpcQueue();
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
}
|
||||
__except (EmuException(GetExceptionInformation()))
|
||||
{
|
||||
EmuWarning("Problem with ExceptionFilter!");
|
||||
EmuLog(CXBXR_MODULE::KRNL, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace NtDll
|
|||
#include "EmuNtDll.h"
|
||||
};
|
||||
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuXTL.h"
|
||||
#include "EmuX86.h"
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace NtDll
|
|||
};
|
||||
|
||||
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x0005 - DbgBreakPoint()
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace NtDll
|
|||
};
|
||||
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuKrnl.h" // For InsertHeadList, InsertTailList, RemoveHeadList
|
||||
|
||||
#include <atomic> // for std::atomic
|
||||
|
@ -145,7 +145,7 @@ static bool eeprom_data_is_valid(xboxkrnl::XC_VALUE_INDEX index)
|
|||
checksum = eeprom_section_checksum(FactorySettings_data, sizeof(EEPROM->FactorySettings));
|
||||
}
|
||||
else {
|
||||
EmuWarning("WARNING: Eeprom ValueIndex 0x%X does not have a checksum\n", index);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Eeprom ValueIndex 0x%X does not have a checksum\n", index);
|
||||
}
|
||||
return checksum == valid_checksum;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::FS
|
||||
#define LOG_PREFIX CXBXR_MODULE::FSC
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
@ -53,7 +53,7 @@ namespace NtDll
|
|||
#include "EmuNtDll.h"
|
||||
};
|
||||
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
|
||||
#define FSCACHE_MAXIMUM_NUMBER_OF_CACHE_PAGES 2048
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace xboxkrnl
|
|||
#include "Logging.h" // For LOG_FUNC()
|
||||
#include "EmuKrnlLogging.h"
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup, CxbxConvertArgToString, and CxbxExec
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuKrnl.h"
|
||||
#include "EmuX86.h" // HalReadWritePciSpace needs this
|
||||
#include "EmuShared.h"
|
||||
|
@ -239,7 +239,7 @@ XBSYSAPI EXPORTNUM(44) xboxkrnl::ULONG NTAPI xboxkrnl::HalGetInterruptVector
|
|||
*Irql = (KIRQL)VECTOR2IRQL(dwVector);
|
||||
|
||||
#ifdef _DEBUG_TRACE
|
||||
DbgPrintf("KRNL: HalGetInterruptVector(): Interrupt vector requested for %d (%s)\n",
|
||||
DbgPrintf(LOG_PREFIX, "HalGetInterruptVector(): Interrupt vector requested for %d (%s)\n",
|
||||
BusInterruptLevel, IRQNames[BusInterruptLevel]);
|
||||
#endif
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ XBSYSAPI EXPORTNUM(49) xboxkrnl::VOID DECLSPEC_NORETURN NTAPI xboxkrnl::HalRetur
|
|||
|
||||
switch (Routine) {
|
||||
case ReturnFirmwareHalt:
|
||||
CxbxKrnlCleanup("Emulated Xbox is halted");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Emulated Xbox is halted");
|
||||
break;
|
||||
|
||||
case ReturnFirmwareReboot:
|
||||
|
@ -583,7 +583,7 @@ XBSYSAPI EXPORTNUM(49) xboxkrnl::VOID DECLSPEC_NORETURN NTAPI xboxkrnl::HalRetur
|
|||
CxbxConvertArgToString(szProcArgsBuffer, szFilePath_CxbxReloaded_Exe, XbePath.c_str(), CxbxKrnl_hEmuParent, CxbxKrnl_DebugMode, CxbxKrnl_DebugFileName.c_str());
|
||||
|
||||
if (!CxbxExec(szProcArgsBuffer, nullptr, false)) {
|
||||
CxbxKrnlCleanup("Could not launch %s", XbePath.c_str());
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Could not launch %s", XbePath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ XBSYSAPI EXPORTNUM(49) xboxkrnl::VOID DECLSPEC_NORETURN NTAPI xboxkrnl::HalRetur
|
|||
CxbxConvertArgToString(szProcArgsBuffer, szFilePath_CxbxReloaded_Exe, szFilePath_Xbe, CxbxKrnl_hEmuParent, CxbxKrnl_DebugMode, CxbxKrnl_DebugFileName.c_str());
|
||||
|
||||
if (!CxbxExec(szProcArgsBuffer, nullptr, false)) {
|
||||
CxbxKrnlCleanup("Could not launch %s", szFilePath_Xbe);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Could not launch %s", szFilePath_Xbe);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace xboxkrnl
|
|||
#include "Logging.h" // For LOG_FUNC()
|
||||
#include "EmuKrnlLogging.h"
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuFile.h" // For CxbxCreateSymbolicLink(), etc.
|
||||
#include "CxbxDebugger.h"
|
||||
|
||||
|
@ -303,11 +303,11 @@ XBSYSAPI EXPORTNUM(66) xboxkrnl::NTSTATUS NTAPI xboxkrnl::IoCreateFile
|
|||
|
||||
if (FAILED(ret))
|
||||
{
|
||||
EmuWarning("KRNL: IoCreateFile Failed! (%s)\n", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "IoCreateFile Failed! (%s)\n", NtStatusToString(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrintf("KRNL: IoCreateFile = 0x%.8X\n", *FileHandle);
|
||||
DbgPrintf(LOG_PREFIX, "IoCreateFile = 0x%.8X\n", *FileHandle);
|
||||
}
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace NtDll
|
|||
};
|
||||
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuKrnl.h" // For InitializeListHead(), etc.
|
||||
#include "EmuKrnlKi.h" // For KiRemoveTreeTimer(), KiInsertTreeTimer()
|
||||
#include "EmuFile.h" // For IsEmuHandle(), NtStatusToString()
|
||||
|
@ -97,7 +97,7 @@ xboxkrnl::KPCR* KeGetPcr()
|
|||
Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot);
|
||||
|
||||
if (Pcr == nullptr) {
|
||||
EmuWarning("KeGetPCR returned nullptr: Was this called from a non-xbox thread?");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KeGetPCR returned nullptr: Was this called from a non-xbox thread?");
|
||||
// Attempt to salvage the situation by calling InitXboxThread to setup KPCR in place
|
||||
InitXboxThread(g_CPUXbox);
|
||||
Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot);
|
||||
|
@ -160,7 +160,7 @@ DWORD ExecuteDpcQueue()
|
|||
pkdpc->Inserted = FALSE;
|
||||
// Set DpcRoutineActive to support KeIsExecutingDpc:
|
||||
KeGetCurrentPrcb()->DpcRoutineActive = TRUE; // Experimental
|
||||
DbgPrintf("KRNL: Global DpcQueue, calling DPC at 0x%.8X\n", pkdpc->DeferredRoutine);
|
||||
DbgPrintf(LOG_PREFIX, "Global DpcQueue, calling DPC at 0x%.8X\n", pkdpc->DeferredRoutine);
|
||||
__try {
|
||||
// Call the Deferred Procedure :
|
||||
pkdpc->DeferredRoutine(
|
||||
|
@ -170,7 +170,7 @@ DWORD ExecuteDpcQueue()
|
|||
pkdpc->SystemArgument2);
|
||||
} __except (EmuException(GetExceptionInformation()))
|
||||
{
|
||||
EmuWarning("Problem with ExceptionFilter!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
|
||||
}
|
||||
|
||||
KeGetCurrentPrcb()->DpcRoutineActive = FALSE; // Experimental
|
||||
|
@ -204,7 +204,7 @@ DWORD ExecuteDpcQueue()
|
|||
if (pkdpc == nullptr)
|
||||
break; // while
|
||||
|
||||
DbgPrintf("KRNL: Global TimerQueue, calling DPC at 0x%.8X\n", pkdpc->DeferredRoutine);
|
||||
DbgPrintf(LOG_PREFIX, "Global TimerQueue, calling DPC at 0x%.8X\n", pkdpc->DeferredRoutine);
|
||||
|
||||
__try {
|
||||
pkdpc->DeferredRoutine(
|
||||
|
@ -214,7 +214,7 @@ DWORD ExecuteDpcQueue()
|
|||
pkdpc->SystemArgument2);
|
||||
} __except (EmuException(GetExceptionInformation()))
|
||||
{
|
||||
EmuWarning("Problem with ExceptionFilter!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ void InitDpcAndTimerThread()
|
|||
InitializeListHead(&(g_DpcData.DpcQueue));
|
||||
InitializeListHead(&(g_DpcData.TimerQueue));
|
||||
|
||||
DbgPrintf("INIT: Creating DPC event\n");
|
||||
DbgPrintf(CXBXR_MODULE::INIT, "Creating DPC event\n");
|
||||
g_DpcData.DpcEvent = CreateEvent(/*lpEventAttributes=*/nullptr, /*bManualReset=*/FALSE, /*bInitialState=*/FALSE, /*lpName=*/nullptr);
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ XBSYSAPI EXPORTNUM(96) xboxkrnl::NTSTATUS NTAPI xboxkrnl::KeBugCheckEx
|
|||
int result = MessageBoxA(g_hEmuWindow, buffer, "KeBugCheck", MB_YESNO | MB_ICONWARNING);
|
||||
|
||||
if (result == IDNO) {
|
||||
CxbxKrnlCleanup(NULL);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, NULL);
|
||||
}
|
||||
|
||||
KeBugCheckIgnored = true;
|
||||
|
@ -1055,7 +1055,7 @@ XBSYSAPI EXPORTNUM(123) xboxkrnl::LONG NTAPI xboxkrnl::KePulseEvent
|
|||
|
||||
// Fetch the host event and signal it, if present
|
||||
if (g_KeEventHandles.find(Event) == g_KeEventHandles.end()) {
|
||||
EmuWarning("KePulseEvent called on a non-existant event!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KePulseEvent called on a non-existant event!");
|
||||
}
|
||||
else {
|
||||
PulseEvent(g_KeEventHandles[Event]);
|
||||
|
@ -1120,9 +1120,9 @@ XBSYSAPI EXPORTNUM(126) xboxkrnl::ULONGLONG NTAPI xboxkrnl::KeQueryPerformanceCo
|
|||
ULONGLONG ret;
|
||||
|
||||
//no matter rdtsc is patched or not, we should always return a scaled performance counter here.
|
||||
DbgPrintf("host tick count : %lu\n", CxbxRdTsc(/*xbox=*/false));
|
||||
DbgPrintf(LOG_PREFIX, "host tick count : %lu\n", CxbxRdTsc(/*xbox=*/false));
|
||||
ret = CxbxRdTsc(/*xbox=*/true);
|
||||
DbgPrintf("emulated tick count : %lu\n", ret);
|
||||
DbgPrintf(LOG_PREFIX, "emulated tick count : %lu\n", ret);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1381,7 +1381,7 @@ XBSYSAPI EXPORTNUM(138) xboxkrnl::LONG NTAPI xboxkrnl::KeResetEvent
|
|||
|
||||
// Fetch the host event and signal it, if present
|
||||
if (g_KeEventHandles.find(Event) == g_KeEventHandles.end()) {
|
||||
EmuWarning("KeResetEvent called on a non-existant event!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KeResetEvent called on a non-existant event!");
|
||||
}
|
||||
else {
|
||||
ResetEvent(g_KeEventHandles[Event]);
|
||||
|
@ -1523,7 +1523,7 @@ XBSYSAPI EXPORTNUM(145) xboxkrnl::LONG NTAPI xboxkrnl::KeSetEvent
|
|||
|
||||
// Fetch the host event and signal it, if present
|
||||
if (g_KeEventHandles.find(Event) == g_KeEventHandles.end()) {
|
||||
EmuWarning("KeSetEvent called on a non-existant event. Creating it!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KeSetEvent called on a non-existant event. Creating it!");
|
||||
// TODO: Find out why some XDKs do not call KeInitializeEvent first
|
||||
|
||||
//We can check the event type from the internal structure, see https://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/kobjects.htm?tx=111
|
||||
|
@ -1631,7 +1631,7 @@ XBSYSAPI EXPORTNUM(150) xboxkrnl::BOOLEAN NTAPI xboxkrnl::KeSetTimerEx
|
|||
LARGE_INTEGER SystemTime;
|
||||
|
||||
if (Timer->Header.Type != TimerNotificationObject && Timer->Header.Type != TimerSynchronizationObject) {
|
||||
CxbxKrnlCleanup("Assertion: '(Timer)->Header.Type == TimerNotificationObject) || ((Timer)->Header.Type == TimerSynchronizationObject)' in KeSetTimerEx()");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Assertion: '(Timer)->Header.Type == TimerNotificationObject) || ((Timer)->Header.Type == TimerSynchronizationObject)' in KeSetTimerEx()");
|
||||
}
|
||||
|
||||
// Same as KeCancelTimer(Timer) :
|
||||
|
@ -1807,7 +1807,7 @@ XBSYSAPI EXPORTNUM(158) xboxkrnl::NTSTATUS NTAPI xboxkrnl::KeWaitForMultipleObje
|
|||
std::vector<HANDLE> ntdllObjects;
|
||||
|
||||
for (uint i = 0; i < Count; i++) {
|
||||
DbgPrintf("Object: 0x%08X\n", Object[i]);
|
||||
DbgPrintf(LOG_PREFIX, "Object: 0x%08X\n", Object[i]);
|
||||
if (g_KeEventHandles.find((PKEVENT)Object[i]) == g_KeEventHandles.end()) {
|
||||
ntdllObjects.push_back(Object[i]);
|
||||
} else {
|
||||
|
@ -1828,7 +1828,7 @@ XBSYSAPI EXPORTNUM(158) xboxkrnl::NTSTATUS NTAPI xboxkrnl::KeWaitForMultipleObje
|
|||
(NtDll::PLARGE_INTEGER)Timeout);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("KeWaitForMultipleObjects failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KeWaitForMultipleObjects failed! (%s)", NtStatusToString(ret));
|
||||
}
|
||||
|
||||
if (nativeObjects.size() > 0) {
|
||||
|
@ -1840,7 +1840,7 @@ XBSYSAPI EXPORTNUM(158) xboxkrnl::NTSTATUS NTAPI xboxkrnl::KeWaitForMultipleObje
|
|||
(NtDll::PLARGE_INTEGER)Timeout);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("KeWaitForMultipleObjects failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KeWaitForMultipleObjects failed! (%s)", NtStatusToString(ret));
|
||||
}
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace xboxkrnl
|
|||
#include "EmuKrnl.h" // For DefaultLaunchDataPage
|
||||
#include "EmuKrnlLogging.h"
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "VMManager.h"
|
||||
#include "EmuShared.h"
|
||||
#include <assert.h>
|
||||
|
@ -407,8 +407,8 @@ XBSYSAPI EXPORTNUM(181) xboxkrnl::NTSTATUS NTAPI xboxkrnl::MmQueryStatistics
|
|||
|
||||
if (!MemoryStatistics)
|
||||
{
|
||||
EmuWarning("KNRL: MmQueryStatistics : PMM_STATISTICS MemoryStatistics is nullptr!\n");
|
||||
LOG_IGNORED();
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "MmQueryStatistics : PMM_STATISTICS MemoryStatistics is nullptr!\n");
|
||||
LOG_IGNORED(LOG_PREFIX);
|
||||
RETURN(LOG_PREFIX, STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
|
@ -416,21 +416,21 @@ XBSYSAPI EXPORTNUM(181) xboxkrnl::NTSTATUS NTAPI xboxkrnl::MmQueryStatistics
|
|||
{
|
||||
g_VMManager.MemoryStatistics(MemoryStatistics);
|
||||
|
||||
DbgPrintf(" MemoryStatistics->Length = 0x%.08X\n", MemoryStatistics->Length);
|
||||
DbgPrintf(" MemoryStatistics->TotalPhysicalPages = 0x%.08X\n", MemoryStatistics->TotalPhysicalPages);
|
||||
DbgPrintf(" MemoryStatistics->AvailablePages = 0x%.08X\n", MemoryStatistics->AvailablePages);
|
||||
DbgPrintf(" MemoryStatistics->VirtualMemoryBytesCommitted = 0x%.08X\n", MemoryStatistics->VirtualMemoryBytesCommitted);
|
||||
DbgPrintf(" MemoryStatistics->VirtualMemoryBytesReserved = 0x%.08X\n", MemoryStatistics->VirtualMemoryBytesReserved);
|
||||
DbgPrintf(" MemoryStatistics->CachePagesCommitted = 0x%.08X\n", MemoryStatistics->CachePagesCommitted);
|
||||
DbgPrintf(" MemoryStatistics->PoolPagesCommitted = 0x%.08X\n", MemoryStatistics->PoolPagesCommitted);
|
||||
DbgPrintf(" MemoryStatistics->StackPagesCommitted = 0x%.08X\n", MemoryStatistics->StackPagesCommitted);
|
||||
DbgPrintf(" MemoryStatistics->ImagePagesCommitted = 0x%.08X\n", MemoryStatistics->ImagePagesCommitted);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->Length = 0x%.08X\n", MemoryStatistics->Length);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->TotalPhysicalPages = 0x%.08X\n", MemoryStatistics->TotalPhysicalPages);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->AvailablePages = 0x%.08X\n", MemoryStatistics->AvailablePages);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->VirtualMemoryBytesCommitted = 0x%.08X\n", MemoryStatistics->VirtualMemoryBytesCommitted);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->VirtualMemoryBytesReserved = 0x%.08X\n", MemoryStatistics->VirtualMemoryBytesReserved);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->CachePagesCommitted = 0x%.08X\n", MemoryStatistics->CachePagesCommitted);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->PoolPagesCommitted = 0x%.08X\n", MemoryStatistics->PoolPagesCommitted);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->StackPagesCommitted = 0x%.08X\n", MemoryStatistics->StackPagesCommitted);
|
||||
DbgPrintf(LOG_PREFIX, " MemoryStatistics->ImagePagesCommitted = 0x%.08X\n", MemoryStatistics->ImagePagesCommitted);
|
||||
|
||||
ret = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
EmuWarning("KRNL: MmQueryStatistics with unusual size -> 0x%.8X", MemoryStatistics->Length);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "MmQueryStatistics with unusual size -> 0x%.8X", MemoryStatistics->Length);
|
||||
ret = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace NtDll
|
|||
};
|
||||
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuFile.h" // For EmuNtSymbolicLinkObject, NtStatusToString(), etc.
|
||||
#include "VMManager.h" // For g_VMManager
|
||||
#include "CxbxDebugger.h"
|
||||
|
@ -117,9 +117,9 @@ XBSYSAPI EXPORTNUM(185) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCancelTimer
|
|||
/*OUT*/CurrentState);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtCancelTimer failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtCancelTimer failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, LOG_PREFIX, ret);
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -135,7 +135,7 @@ XBSYSAPI EXPORTNUM(186) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtClearEvent
|
|||
NTSTATUS ret = NtDll::NtClearEvent(EventHandle);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtClearEvent Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtClearEvent Failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ XBSYSAPI EXPORTNUM(187) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtClose
|
|||
// Delete duplicate threads created by our implementation of NtQueueApcThread()
|
||||
if( GetHandleInformation( g_DuplicateHandles[Handle], &flags ) != 0 )
|
||||
{
|
||||
DbgPrintf( "Closing duplicate handle...\n" );
|
||||
DbgPrintf(LOG_PREFIX, "Closing duplicate handle...\n" );
|
||||
|
||||
CloseHandle( g_DuplicateHandles[Handle] );
|
||||
g_DuplicateHandles.erase(Handle);
|
||||
|
@ -218,9 +218,9 @@ XBSYSAPI EXPORTNUM(188) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateDirectoryObje
|
|||
}
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtCreateDirectoryObject Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtCreateDirectoryObject Failed!");
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateDirectoryObject DirectoryHandle = 0x%.8X\n", *DirectoryHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateDirectoryObject DirectoryHandle = 0x%.8X\n", *DirectoryHandle);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ XBSYSAPI EXPORTNUM(189) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateEvent
|
|||
|
||||
if (FAILED(ret))
|
||||
{
|
||||
EmuWarning("Trying fallback (without object attributes)...\nError code 0x%X", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Trying fallback (without object attributes)...\nError code 0x%X", ret);
|
||||
|
||||
// If it fails, try again but without the object attributes stucture
|
||||
// This fixes Panzer Dragoon games on non-Vista OSes.
|
||||
|
@ -295,12 +295,12 @@ XBSYSAPI EXPORTNUM(189) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateEvent
|
|||
InitialState);
|
||||
|
||||
if(FAILED(ret))
|
||||
EmuWarning("NtCreateEvent Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtCreateEvent Failed!");
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateEvent EventHandle = 0x%.8X\n", *EventHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateEvent EventHandle = 0x%.8X\n", *EventHandle);
|
||||
}
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateEvent EventHandle = 0x%.8X\n", *EventHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateEvent EventHandle = 0x%.8X\n", *EventHandle);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ XBSYSAPI EXPORTNUM(192) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateMutant
|
|||
|
||||
if (FAILED(ret))
|
||||
{
|
||||
EmuWarning("Trying fallback (without object attributes)...\nError code 0x%X", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Trying fallback (without object attributes)...\nError code 0x%X", ret);
|
||||
|
||||
// If it fails, try again but without the object attributes stucture
|
||||
ret = NtDll::NtCreateMutant(
|
||||
|
@ -423,12 +423,12 @@ XBSYSAPI EXPORTNUM(192) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateMutant
|
|||
InitialOwner);
|
||||
|
||||
if(FAILED(ret))
|
||||
EmuWarning("NtCreateMutant Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtCreateMutant Failed!");
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateMutant MutantHandle = 0x%.8X\n", *MutantHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateMutant MutantHandle = 0x%.8X\n", *MutantHandle);
|
||||
}
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateMutant MutantHandle = 0x%.8X\n", *MutantHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateMutant MutantHandle = 0x%.8X\n", *MutantHandle);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ XBSYSAPI EXPORTNUM(193) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateSemaphore
|
|||
|
||||
if (FAILED(ret))
|
||||
{
|
||||
EmuWarning("Trying fallback (without object attributes)...\nError code 0x%X", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Trying fallback (without object attributes)...\nError code 0x%X", ret);
|
||||
|
||||
// If it fails, try again but without the object attributes stucture
|
||||
ret = NtDll::NtCreateSemaphore(
|
||||
|
@ -498,12 +498,12 @@ XBSYSAPI EXPORTNUM(193) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateSemaphore
|
|||
MaximumCount);
|
||||
|
||||
if(FAILED(ret))
|
||||
EmuWarning("NtCreateSemaphore failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtCreateSemaphore failed!");
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateSemaphore SemaphoreHandle = 0x%.8X\n", *SemaphoreHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateSemaphore SemaphoreHandle = 0x%.8X\n", *SemaphoreHandle);
|
||||
}
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateSemaphore SemaphoreHandle = 0x%.8X\n", *SemaphoreHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateSemaphore SemaphoreHandle = 0x%.8X\n", *SemaphoreHandle);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -561,9 +561,9 @@ XBSYSAPI EXPORTNUM(194) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateTimer
|
|||
);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtCreateTimer failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtCreateTimer failed!");
|
||||
else
|
||||
DbgPrintf("KRNL: NtCreateTimer TimerHandle = 0x%.8X\n", *TimerHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtCreateTimer TimerHandle = 0x%.8X\n", *TimerHandle);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ XBSYSAPI EXPORTNUM(195) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtDeleteFile
|
|||
}
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtDeleteFile Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtDeleteFile Failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ XBSYSAPI EXPORTNUM(197) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtDuplicateObject
|
|||
}
|
||||
|
||||
if (ret != STATUS_SUCCESS)
|
||||
EmuWarning("Object was not duplicated!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Object was not duplicated!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -904,9 +904,9 @@ XBSYSAPI EXPORTNUM(203) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtOpenSymbolicLinkObj
|
|||
}
|
||||
|
||||
if (ret != STATUS_SUCCESS)
|
||||
EmuWarning("NtOpenSymbolicLinkObject failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtOpenSymbolicLinkObject failed! (%s)", NtStatusToString(ret));
|
||||
else
|
||||
DbgPrintf("KRNL: NtOpenSymbolicLinkObject LinkHandle^ = 0x%.8X", *LinkHandle);
|
||||
DbgPrintf(LOG_PREFIX, "NtOpenSymbolicLinkObject LinkHandle^ = 0x%.8X", *LinkHandle);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -958,7 +958,7 @@ XBSYSAPI EXPORTNUM(205) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtPulseEvent
|
|||
/*OUT*/PreviousState);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtPulseEvent failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtPulseEvent failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1004,15 +1004,15 @@ XBSYSAPI EXPORTNUM(206) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueueApcThread
|
|||
|
||||
if( FAILED( ret ) )
|
||||
{
|
||||
EmuWarning( "Duplicating handle with THREAD_SET_CONTEXT..." );
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Duplicating handle with THREAD_SET_CONTEXT..." );
|
||||
|
||||
// If we get here, then attempt to duplicate the thread.
|
||||
if(!DuplicateHandle(g_CurrentProcessHandle, ThreadHandle, g_CurrentProcessHandle, &hApcThread, THREAD_SET_CONTEXT,FALSE,0))
|
||||
EmuWarning("DuplicateHandle failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "DuplicateHandle failed!");
|
||||
else
|
||||
{
|
||||
g_DuplicateHandles[ThreadHandle] = hApcThread; // Save this thread because we'll need to de-reference it later
|
||||
DbgPrintf( "DuplicateHandle returned 0x%X (ThreadId 0x%.4X)\n", hApcThread, GetThreadId( hApcThread ) );
|
||||
DbgPrintf(LOG_PREFIX, "DuplicateHandle returned 0x%X (ThreadId 0x%.4X)\n", hApcThread, GetThreadId( hApcThread ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ XBSYSAPI EXPORTNUM(206) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueueApcThread
|
|||
}
|
||||
if (FAILED(ret))
|
||||
{
|
||||
EmuWarning("NtQueueApcThread failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueueApcThread failed!");
|
||||
CloseHandle( g_DuplicateHandles[ThreadHandle] );
|
||||
g_DuplicateHandles.erase( ThreadHandle );
|
||||
}
|
||||
|
@ -1066,7 +1066,7 @@ XBSYSAPI EXPORTNUM(207) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryDirectoryFile
|
|||
NTSTATUS ret;
|
||||
|
||||
if (FileInformationClass != FileDirectoryInformation) // Due to unicode->string conversion
|
||||
CxbxKrnlCleanup("Unsupported FileInformationClass");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Unsupported FileInformationClass");
|
||||
|
||||
NtDll::UNICODE_STRING NtFileMask;
|
||||
|
||||
|
@ -1182,7 +1182,7 @@ XBSYSAPI EXPORTNUM(209) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryEvent
|
|||
/*ReturnLength=*/nullptr);
|
||||
|
||||
if (ret != STATUS_SUCCESS)
|
||||
EmuWarning("NtQueryEvent failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryEvent failed! (%s)", NtStatusToString(ret));
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1219,7 +1219,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)", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryFullAttributesFile failed! (0x%.08X)", ret);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ XBSYSAPI EXPORTNUM(211) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryInformationFil
|
|||
free(ntFileInfo);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtQueryInformationFile failed! (0x%.08X)", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryInformationFile failed! (0x%.08X)", ret);
|
||||
|
||||
// Prioritize the buffer overflow over real return code,
|
||||
// in case the Xbox program decides to follow the same procedure above
|
||||
|
@ -1332,7 +1332,7 @@ XBSYSAPI EXPORTNUM(213) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryMutant
|
|||
/*ReturnLength=*/nullptr);
|
||||
|
||||
if (ret != STATUS_SUCCESS)
|
||||
EmuWarning("NtQueryMutant failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryMutant failed! (%s)", NtStatusToString(ret));
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ XBSYSAPI EXPORTNUM(214) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQuerySemaphore
|
|||
/*ReturnLength=*/nullptr);
|
||||
|
||||
if (ret != STATUS_SUCCESS)
|
||||
EmuWarning("NtQuerySemaphore failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQuerySemaphore failed! (%s)", NtStatusToString(ret));
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1412,7 +1412,7 @@ XBSYSAPI EXPORTNUM(215) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQuerySymbolicLinkOb
|
|||
}
|
||||
}
|
||||
if (ret != STATUS_SUCCESS)
|
||||
EmuWarning("NtQuerySymbolicLinkObject failed! (%s)", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQuerySymbolicLinkObject failed! (%s)", NtStatusToString(ret));
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1460,7 +1460,7 @@ XBSYSAPI EXPORTNUM(217) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryVirtualMemory
|
|||
|
||||
if (!Buffer)
|
||||
{
|
||||
EmuWarning("KNRL: NtQueryVirtualMemory : PMEMORY_BASIC_INFORMATION Buffer is nullptr!\n");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryVirtualMemory : PMEMORY_BASIC_INFORMATION Buffer is nullptr!\n");
|
||||
LOG_IGNORED(LOG_PREFIX);
|
||||
RETURN(LOG_PREFIX, STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
|
@ -1469,18 +1469,18 @@ XBSYSAPI EXPORTNUM(217) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryVirtualMemory
|
|||
|
||||
if (ret == STATUS_SUCCESS)
|
||||
{
|
||||
DbgPrintf(" Buffer->AllocationBase = 0x%.08X\n", Buffer->AllocationBase);
|
||||
DbgPrintf(" Buffer->AllocationProtect = 0x%.08X\n", Buffer->AllocationProtect);
|
||||
DbgPrintf(" Buffer->BaseAddress = 0x%.08X\n", Buffer->BaseAddress);
|
||||
DbgPrintf(" Buffer->RegionSize = 0x%.08X\n", Buffer->RegionSize);
|
||||
DbgPrintf(" Buffer->State = 0x%.08X\n", Buffer->State);
|
||||
DbgPrintf(" Buffer->Protect = 0x%.08X\n", Buffer->Protect);
|
||||
DbgPrintf(" Buffer->Type = 0x%.08X\n", Buffer->Type);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->AllocationBase = 0x%.08X\n", Buffer->AllocationBase);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->AllocationProtect = 0x%.08X\n", Buffer->AllocationProtect);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->BaseAddress = 0x%.08X\n", Buffer->BaseAddress);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->RegionSize = 0x%.08X\n", Buffer->RegionSize);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->State = 0x%.08X\n", Buffer->State);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->Protect = 0x%.08X\n", Buffer->Protect);
|
||||
DbgPrintf(LOG_PREFIX, " Buffer->Type = 0x%.08X\n", Buffer->Type);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (FAILED(ret)) {
|
||||
EmuWarning("NtQueryVirtualMemory failed (%s)!", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryVirtualMemory failed (%s)!", NtStatusToString(ret));
|
||||
|
||||
// Bugfix for "Forza Motorsport", which iterates over 2 Gb of memory in 64kb chunks,
|
||||
// but fails on this last query. It's not done though, as after this Forza tries to
|
||||
|
@ -1499,7 +1499,7 @@ XBSYSAPI EXPORTNUM(217) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryVirtualMemory
|
|||
|
||||
ret = STATUS_SUCCESS;
|
||||
|
||||
DbgPrintf("KRNL: NtQueryVirtualMemory: Applied fix for Forza Motorsport!\n");
|
||||
DbgPrintf(LOG_PREFIX, "NtQueryVirtualMemory: Applied fix for Forza Motorsport!\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1605,7 +1605,7 @@ XBSYSAPI EXPORTNUM(218) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryVolumeInformat
|
|||
break;
|
||||
default:
|
||||
// For all other types, just do a memcpy and hope for the best!
|
||||
EmuWarning("NtQueryVolumeInformationFile: Unknown FileInformationClass");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryVolumeInformationFile: Unknown FileInformationClass");
|
||||
memcpy_s(FileInformation, Length, NativeFileInformation, HostBufferSize);
|
||||
break;
|
||||
}
|
||||
|
@ -1614,7 +1614,7 @@ XBSYSAPI EXPORTNUM(218) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryVolumeInformat
|
|||
_aligned_free(NativeFileInformation);
|
||||
|
||||
if (FAILED(ret)) {
|
||||
EmuWarning("NtQueryVolumeInformationFile failed! (%s)\n", NtStatusToString(ret));
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtQueryVolumeInformationFile failed! (%s)\n", NtStatusToString(ret));
|
||||
}
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
|
@ -1671,7 +1671,7 @@ XBSYSAPI EXPORTNUM(219) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtReadFile
|
|||
/*Key=*/nullptr);
|
||||
|
||||
if (FAILED(ret)) {
|
||||
EmuWarning("NtReadFile Failed! (0x%.08X)", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtReadFile Failed! (0x%.08X)", ret);
|
||||
}
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
|
@ -1726,7 +1726,7 @@ XBSYSAPI EXPORTNUM(221) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtReleaseMutant
|
|||
NTSTATUS ret = NtDll::NtReleaseMutant(MutantHandle, PreviousCount);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtReleaseMutant Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtReleaseMutant Failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, STATUS_SUCCESS); // TODO : RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1753,7 +1753,7 @@ XBSYSAPI EXPORTNUM(222) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtReleaseSemaphore
|
|||
PreviousCount);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtReleaseSemaphore failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtReleaseSemaphore failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1827,7 +1827,7 @@ XBSYSAPI EXPORTNUM(225) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtSetEvent
|
|||
PreviousState);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtSetEvent Failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtSetEvent Failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -1970,7 +1970,7 @@ XBSYSAPI EXPORTNUM(229) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtSetTimerEx
|
|||
/*OUT*/PreviousState);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtSetTimerEx failed!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtSetTimerEx failed!");
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
@ -2053,7 +2053,7 @@ XBSYSAPI EXPORTNUM(232) xboxkrnl::VOID NTAPI xboxkrnl::NtUserIoApcDispatcher
|
|||
|
||||
(CompletionRoutine)(dwErrorCode, dwTransferred, lpOverlapped);
|
||||
|
||||
DbgPrintf("KRNL: NtUserIoApcDispatcher Completed\n");
|
||||
DbgPrintf(LOG_PREFIX, "NtUserIoApcDispatcher Completed\n");
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -2185,7 +2185,7 @@ XBSYSAPI EXPORTNUM(236) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtWriteFile
|
|||
/*Key=*/nullptr);
|
||||
|
||||
if (FAILED(ret))
|
||||
EmuWarning("NtWriteFile Failed! (0x%.08X)", ret);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NtWriteFile Failed! (0x%.08X)", ret);
|
||||
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace xboxkrnl
|
|||
#include "Logging.h" // For LOG_FUNC()
|
||||
#include "EmuKrnlLogging.h"
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "EmuKrnl.h" // For OBJECT_TO_OBJECT_HEADER()
|
||||
#include "EmuFile.h" // For EmuNtSymbolicLinkObject, NtStatusToString(), etc.
|
||||
#include <cassert>
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace xboxkrnl
|
|||
#include "Logging.h" // For LOG_FUNC()
|
||||
#include "EmuKrnlLogging.h"
|
||||
#include "CxbxKrnl.h" // For CxbxKrnl_TLS
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include "EmuFS.h" // For EmuGenerateFS
|
||||
#include "EmuXTL.h"
|
||||
|
||||
|
@ -160,7 +160,7 @@ static unsigned int WINAPI PCSTProxy
|
|||
if (pfnNotificationRoutine == NULL)
|
||||
continue;
|
||||
|
||||
DbgPrintf("KRNL: Calling pfnNotificationRoutine[%d] (0x%.8X)\n", g_iThreadNotificationCount, pfnNotificationRoutine);
|
||||
DbgPrintf(LOG_PREFIX, "Calling pfnNotificationRoutine[%d] (0x%.8X)\n", g_iThreadNotificationCount, pfnNotificationRoutine);
|
||||
|
||||
pfnNotificationRoutine(TRUE);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ static unsigned int WINAPI PCSTProxy
|
|||
}
|
||||
__except (EmuException(GetExceptionInformation()))
|
||||
{
|
||||
EmuWarning("Problem with ExceptionFilter!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
|
||||
}
|
||||
|
||||
callComplete:
|
||||
|
@ -214,7 +214,7 @@ void PspSystemThreadStartup
|
|||
__except (EmuException(GetExceptionInformation()))
|
||||
// TODO : Call PspUnhandledExceptionInSystemThread(GetExceptionInformation())
|
||||
{
|
||||
EmuWarning("Problem with ExceptionFilter!"); // TODO : Disable?
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!"); // TODO : Disable?
|
||||
}
|
||||
|
||||
xboxkrnl::PsTerminateSystemThread(STATUS_SUCCESS);
|
||||
|
@ -309,7 +309,7 @@ XBSYSAPI EXPORTNUM(255) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadE
|
|||
HANDLE hStartedEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("PCSTProxyEvent"));
|
||||
if (hStartedEvent == NULL) {
|
||||
std::string errorMessage = CxbxGetLastErrorString("PsCreateSystemThreadEx could not create PCSTProxyEvent");
|
||||
CxbxKrnlCleanup(errorMessage.c_str());
|
||||
CxbxKrnlCleanup(LOG_PREFIX, errorMessage.c_str());
|
||||
}
|
||||
|
||||
// PCSTProxy is responsible for cleaning up this pointer
|
||||
|
@ -327,18 +327,18 @@ XBSYSAPI EXPORTNUM(255) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadE
|
|||
// Give the thread chance to start
|
||||
Sleep(100);
|
||||
|
||||
EmuWarning("KRNL: Waiting for Xbox proxy thread to start...\n");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KRNL: Waiting for Xbox proxy thread to start...\n");
|
||||
|
||||
while (bWait) {
|
||||
dwThreadWait = WaitForSingleObject(hStartedEvent, 300);
|
||||
switch (dwThreadWait) {
|
||||
case WAIT_TIMEOUT: { // The time-out interval elapsed, and the object's state is nonsignaled.
|
||||
EmuWarning("KRNL: Timeout while waiting for Xbox proxy thread to start...\n");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KRNL: Timeout while waiting for Xbox proxy thread to start...\n");
|
||||
bWait = false;
|
||||
break;
|
||||
}
|
||||
case WAIT_OBJECT_0: { // The state of the specified object is signaled.
|
||||
DbgPrintf("KRNL: Xbox proxy thread is started.\n");
|
||||
DbgPrintf(LOG_PREFIX, "Xbox proxy thread is started.\n");
|
||||
bWait = false;
|
||||
break;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ XBSYSAPI EXPORTNUM(255) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadE
|
|||
bWait = false;
|
||||
|
||||
std::string ErrorStr = CxbxGetLastErrorString("KRNL: While waiting for Xbox proxy thread to start");
|
||||
EmuWarning("%s\n", ErrorStr.c_str());
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "%s\n", ErrorStr.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ XBSYSAPI EXPORTNUM(255) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadE
|
|||
hStartedEvent = NULL;
|
||||
|
||||
// Log ThreadID identical to how GetCurrentThreadID() is rendered :
|
||||
EmuWarning("KRNL: Created Xbox proxy thread. Handle : 0x%X, ThreadId : [0x%.4X]\n", *ThreadHandle, dwThreadId);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "KRNL: Created Xbox proxy thread. Handle : 0x%X, ThreadId : [0x%.4X]\n", *ThreadHandle, dwThreadId);
|
||||
|
||||
CxbxKrnlRegisterThread(*ThreadHandle);
|
||||
|
||||
|
@ -408,7 +408,7 @@ XBSYSAPI EXPORTNUM(257) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsSetCreateThreadNoti
|
|||
|
||||
// I honestly don't expect this to happen, but if it does...
|
||||
if (g_iThreadNotificationCount >= PSP_MAX_CREATE_THREAD_NOTIFY)
|
||||
CxbxKrnlCleanup("Too many thread notification routines installed\n");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Too many thread notification routines installed\n");
|
||||
|
||||
// Find an empty spot in the thread notification array
|
||||
for (int i = 0; i < PSP_MAX_CREATE_THREAD_NOTIFY; i++)
|
||||
|
@ -451,7 +451,7 @@ XBSYSAPI EXPORTNUM(258) xboxkrnl::VOID NTAPI xboxkrnl::PsTerminateSystemThread
|
|||
if (pfnNotificationRoutine == NULL)
|
||||
continue;
|
||||
|
||||
DbgPrintf("KRNL: Calling pfnNotificationRoutine[%d] (0x%.8X)\n", g_iThreadNotificationCount, pfnNotificationRoutine);
|
||||
DbgPrintf(LOG_PREFIX, "Calling pfnNotificationRoutine[%d] (0x%.8X)\n", g_iThreadNotificationCount, pfnNotificationRoutine);
|
||||
|
||||
pfnNotificationRoutine(FALSE);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace NtDll
|
|||
};
|
||||
|
||||
#include "CxbxKrnl.h" // For CxbxKrnlCleanup()
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "Emu.h" // For EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, )
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -80,7 +80,7 @@ static void add_critical_section(
|
|||
critical_sections[xbox_crit_section] = host_crit_section;
|
||||
}
|
||||
else {
|
||||
DbgPrintf("Critical Section key %p already exists\n", xbox_crit_section);
|
||||
DbgPrintf(LOG_PREFIX, "Critical Section key %p already exists\n", xbox_crit_section);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ XBSYSAPI EXPORTNUM(264) xboxkrnl::VOID NTAPI xboxkrnl::RtlAssert
|
|||
LOG_FUNC_ARG(Message)
|
||||
LOG_FUNC_END;
|
||||
|
||||
CxbxPopupMessage(CxbxMsgDlgIcon_Warn, "RtlAssert() raised by emulated program - consult Debug log");
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::WARNING, CxbxMsgDlgIcon_Warn, "RtlAssert() raised by emulated program - consult Debug log");
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -742,7 +742,7 @@ XBSYSAPI EXPORTNUM(277) xboxkrnl::VOID NTAPI xboxkrnl::RtlEnterCriticalSection
|
|||
);
|
||||
if(!NT_SUCCESS(result))
|
||||
{
|
||||
CxbxKrnlCleanup("Waiting for event of a critical section returned %lx.", result);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Waiting for event of a critical section returned %lx.", result);
|
||||
};
|
||||
CriticalSection->OwningThread = thread;
|
||||
CriticalSection->RecursionCount = 1;
|
||||
|
@ -1473,7 +1473,7 @@ XBSYSAPI EXPORTNUM(301) xboxkrnl::ULONG NTAPI xboxkrnl::RtlNtStatusToDosError
|
|||
return LOWORD(Status);
|
||||
|
||||
no_mapping:
|
||||
DbgPrintf("no mapping for %08x\n", Status);
|
||||
DbgPrintf(LOG_PREFIX, "no mapping for %08x\n", Status);
|
||||
ret = ERROR_MR_MID_NOT_FOUND;
|
||||
*/
|
||||
RETURN(LOG_PREFIX, ret);
|
||||
|
@ -2157,6 +2157,6 @@ XBSYSAPI EXPORTNUM(352) xboxkrnl::VOID NTAPI xboxkrnl::RtlRip
|
|||
LOG_FUNC_ARG(Message)
|
||||
LOG_FUNC_END;
|
||||
|
||||
EmuWarning("RtlRip@%s:\n\nASSERT FAILED:\n%s\n\nDescription:\n%s",
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "RtlRip@%s:\n\nASSERT FAILED:\n%s\n\nDescription:\n%s",
|
||||
ApiName, Expression, Message);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace xboxkrnl
|
|||
#include "CxbxKrnl.h" // For CxbxKrnl_Xbe
|
||||
#include "Logging.h" // For LOG_FUNC()
|
||||
#include "EmuKrnlLogging.h"
|
||||
#include "Emu.h" // For EmuWarning()
|
||||
#include "VMManager.h"
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
// This rsa implementation is directly borrowed from the xbedump tool of XQEMU (GPLv2 license)
|
||||
// https://github.com/xqemu/xbedump
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::RSA
|
||||
|
||||
#include "EmuRsa.h"
|
||||
#include "Emu.h" // For EmuWarning
|
||||
#include <cstring>
|
||||
|
@ -225,7 +227,7 @@ giant newgiant(int numshorts)
|
|||
giant thegiant;
|
||||
|
||||
if (numshorts > MAX_SHORTS) {
|
||||
EmuWarning("Requested giant too big.");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Requested giant too big.");
|
||||
}
|
||||
if (numshorts <= 0)
|
||||
numshorts = MAX_SHORTS;
|
||||
|
|
|
@ -95,7 +95,7 @@ uint32_t EmuX86_IORead(xbaddr addr, int size)
|
|||
return value;
|
||||
}
|
||||
|
||||
EmuWarning("EmuX86_IORead(0x%08X, %d) [Unhandled]", addr, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_IORead(0x%08X, %d) [Unhandled]", addr, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ void EmuX86_IOWrite(xbaddr addr, uint32_t value, int size)
|
|||
return;
|
||||
}
|
||||
|
||||
EmuWarning("EmuX86_IOWrite(0x%08X, 0x%04X, %d) [Unhandled]", addr, value, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_IOWrite(0x%08X, 0x%04X, %d) [Unhandled]", addr, value, size);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -158,11 +158,11 @@ uint32_t EmuFlash_Read32(xbaddr addr) // TODO : Move to EmuFlash.cpp
|
|||
r = 0x90; // Luke's hardware revision 1.6 Xbox returns this (also since XboxKrnlVersion is set to 5838)
|
||||
break;
|
||||
default:
|
||||
EmuWarning("Read32 FLASH_ROM (0x%.8X) [Unknown address]", addr);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Read32 FLASH_ROM (0x%.8X) [Unknown address]", addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
DbgPrintf("X86 : Read32 FLASH_ROM (0x%.8X) = 0x%.8X [HANDLED]\n", addr, r);
|
||||
DbgPrintf(LOG_PREFIX, "Read32 FLASH_ROM (0x%.8X) = 0x%.8X [HANDLED]\n", addr, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ uint32_t EmuFlash_Read32(xbaddr addr) // TODO : Move to EmuFlash.cpp
|
|||
uint32_t EmuX86_Read(xbaddr addr, int size)
|
||||
{
|
||||
if ((addr & (size - 1)) != 0) {
|
||||
EmuWarning("EmuX86_Read(0x%08X, %d) [Unaligned unimplemented]", addr, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Read(0x%08X, %d) [Unaligned unimplemented]", addr, size);
|
||||
// LOG_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
@ -192,14 +192,14 @@ uint32_t EmuX86_Read(xbaddr addr, int size)
|
|||
}
|
||||
|
||||
if (g_bEmuException) {
|
||||
EmuWarning("EmuX86_Read(0x%08X, %d) [Unknown address]", addr, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Read(0x%08X, %d) [Unknown address]", addr, size);
|
||||
value = 0;
|
||||
} else {
|
||||
// Outside EmuException, pass the memory-access through to normal memory :
|
||||
value = EmuX86_Mem_Read(addr, size);
|
||||
}
|
||||
|
||||
DbgPrintf("X86 : Read(0x%08X, %d) = 0x%08X\n", addr, size, value);
|
||||
DbgPrintf(LOG_PREFIX, "Read(0x%08X, %d) = 0x%08X\n", addr, size, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -208,13 +208,13 @@ uint32_t EmuX86_Read(xbaddr addr, int size)
|
|||
void EmuX86_Write(xbaddr addr, uint32_t value, int size)
|
||||
{
|
||||
if ((addr & (size - 1)) != 0) {
|
||||
EmuWarning("EmuX86_Write(0x%08X, 0x%08X, %d) [Unaligned unimplemented]", addr, value, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Write(0x%08X, 0x%08X, %d) [Unaligned unimplemented]", addr, value, size);
|
||||
// LOG_UNIMPLEMENTED();
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr >= XBOX_FLASH_ROM_BASE) { // 0xFFF00000 - 0xFFFFFFF
|
||||
EmuWarning("EmuX86_Write(0x%08X, 0x%08X) [FLASH_ROM]", addr, value);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Write(0x%08X, 0x%08X) [FLASH_ROM]", addr, value);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -224,12 +224,12 @@ void EmuX86_Write(xbaddr addr, uint32_t value, int size)
|
|||
}
|
||||
|
||||
if (g_bEmuException) {
|
||||
EmuWarning("EmuX86_Write(0x%08X, 0x%08X) [Unknown address]", addr, value);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Write(0x%08X, 0x%08X) [Unknown address]", addr, value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Outside EmuException, pass the memory-access through to normal memory :
|
||||
DbgPrintf("X86 : Write(0x%.8X, 0x%.8X, %d)\n", addr, value, size);
|
||||
DbgPrintf(LOG_PREFIX, "Write(0x%.8X, 0x%.8X, %d)\n", addr, value, size);
|
||||
EmuX86_Mem_Write(addr, value, size);
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,7 @@ bool EmuX86_Operand_Addr_ForReadWrite(const LPEXCEPTION_POINTERS e, const _DInst
|
|||
case O_IMM:
|
||||
case O_IMM1:
|
||||
case O_IMM2:
|
||||
EmuWarning("Refused operand write-access to immedate value address!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Refused operand write-access to immedate value address!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1050,7 +1050,7 @@ int EmuX86_OpcodeSize(uint8_t *Eip)
|
|||
if (EmuX86_DecodeOpcode((uint8_t*)Eip, info))
|
||||
return info.size;
|
||||
|
||||
EmuWarning("Error decoding opcode size at 0x%.8X", Eip);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Error decoding opcode size at 0x%.8X", Eip);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1063,7 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
|
|||
// that case may be logged, but it shouldn't fail the opcode handler.
|
||||
_DInst info;
|
||||
if (!EmuX86_DecodeOpcode((uint8_t*)e->ContextRecord->Eip, OUT info)) {
|
||||
EmuWarning("Error decoding opcode at 0x%08X", e->ContextRecord->Eip);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Error decoding opcode at 0x%08X", e->ContextRecord->Eip);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1122,7 +1122,7 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
|
|||
// Some titles attempt to manually set the TSC via this instruction
|
||||
// This needs fixing eventually, but should be acceptible to ignore for now!
|
||||
// Chase: Hollywood Stunt Driver hits this
|
||||
EmuWarning("WRMSR instruction ignored");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "WRMSR instruction ignored");
|
||||
break;
|
||||
case I_CLI: {
|
||||
// Disable all interrupts
|
||||
|
@ -1135,7 +1135,7 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
EmuWarning("Unhandled instruction : %u", info.opcode);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unhandled instruction : %u", info.opcode);
|
||||
e->ContextRecord->Eip += info.size;
|
||||
return false;
|
||||
}
|
||||
|
@ -1146,14 +1146,14 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
|
|||
return true;
|
||||
|
||||
opcode_error:
|
||||
EmuWarning("0x%08X: Error while handling instruction %u", e->ContextRecord->Eip, info.opcode); // TODO : format decodedInstructions[0]
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "0x%08X: Error while handling instruction %u", e->ContextRecord->Eip, info.opcode); // TODO : format decodedInstructions[0]
|
||||
e->ContextRecord->Eip += info.size;
|
||||
return false;
|
||||
}
|
||||
|
||||
void EmuX86_Init()
|
||||
{
|
||||
DbgPrintf("X86 : Initializing distorm version %d\n", distorm_version());
|
||||
DbgPrintf(LOG_PREFIX, "Initializing distorm version %d\n", distorm_version());
|
||||
|
||||
AddVectoredExceptionHandler(/*FirstHandler=*/ULONG(true), lleException);
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ VOID WINAPI XTL::EMUPATCH(XGSwizzleRect)
|
|||
else
|
||||
{
|
||||
if(pPoint != NULL && (pPoint->x != 0 || pPoint->y != 0))
|
||||
CxbxKrnlCleanup("Temporarily unsupported swizzle (very easy fix)");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Temporarily unsupported swizzle (very easy fix)");
|
||||
|
||||
DWORD dwMaxY = Height;
|
||||
DWORD dwChunkSize = Width;
|
||||
|
@ -163,7 +163,7 @@ VOID WINAPI XTL::EMUPATCH(XGSwizzleBox)
|
|||
else
|
||||
{
|
||||
if(pPoint != NULL && (pPoint->u != 0 || pPoint->v != 0 || pPoint->w != 0))
|
||||
CxbxKrnlCleanup("Temporarily unsupported swizzle (very easy fix)");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Temporarily unsupported swizzle (very easy fix)");
|
||||
|
||||
DWORD dwMaxY = Height;
|
||||
DWORD dwMaxZ = Depth;
|
||||
|
@ -249,10 +249,10 @@ VOID WINAPI XTL::EMUPATCH(XGSetTextureHeader)
|
|||
LOG_FUNC_END;
|
||||
|
||||
/*if( Data != 0 )
|
||||
CxbxKrnlCleanup( "Data != 0 (XGSetTextureHeader)" );
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Data != 0 (XGSetTextureHeader)" );
|
||||
|
||||
if( Pitch != 0 )
|
||||
CxbxKrnlCleanup( "Pitch != 0 (XGSetTextureHeader)" );*/
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Pitch != 0 (XGSetTextureHeader)" );*/
|
||||
|
||||
pTexture->Common = X_D3DCOMMON_TYPE_TEXTURE + 1; // Set refcount to 1
|
||||
pTexture->Data = Data;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -145,7 +145,8 @@ bool VerifySymbolAddressAgainstXRef(char *SymbolName, xbaddr Address, int XRef)
|
|||
}
|
||||
|
||||
// For XREF_D3DTSS_TEXCOORDINDEX, Kabuki Warriors hits this case
|
||||
CxbxPopupMessage("Verification of %s failed : XREF was 0x%.8X while lookup gave 0x%.8X", SymbolName, XRefAddr, Address);
|
||||
CxbxPopupMessage(LOG_PREFIX, LOG_LEVEL::WARNING, CxbxMsgDlgIcon_Warn,
|
||||
"Verification of %s failed : XREF was 0x%.8X while lookup gave 0x%.8X", SymbolName, XRefAddr, Address);
|
||||
// For XREF_D3DTSS_TEXCOORDINDEX, Kabuki Warriors hits this case
|
||||
return false;
|
||||
}*/
|
||||
|
@ -181,11 +182,11 @@ void CDECL EmuOutputMessage(xb_output_message mFlag,
|
|||
break;
|
||||
}
|
||||
case XB_OUTPUT_MESSAGE_WARN: {
|
||||
EmuWarning("%s", message);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "%s", message);
|
||||
break;
|
||||
}
|
||||
case XB_OUTPUT_MESSAGE_ERROR: {
|
||||
CxbxKrnlCleanup("%s", message);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s", message);
|
||||
break;
|
||||
}
|
||||
case XB_OUTPUT_MESSAGE_DEBUG:
|
||||
|
@ -227,7 +228,7 @@ void CDECL EmuRegisterSymbol(const char* library_str,
|
|||
switch (XRefDataBase[Oovpa->XRefSaveIndex]) {
|
||||
case XREF_ADDR_NOT_FOUND:
|
||||
{
|
||||
EmuWarning("Found OOVPA after first finding nothing?");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Found OOVPA after first finding nothing?");
|
||||
// fallthrough to XREF_ADDR_UNDETERMINED
|
||||
}
|
||||
case XREF_ADDR_UNDETERMINED:
|
||||
|
@ -239,14 +240,14 @@ void CDECL EmuRegisterSymbol(const char* library_str,
|
|||
}
|
||||
case XREF_ADDR_DERIVE:
|
||||
{
|
||||
EmuWarning("Cannot derive a save index!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Cannot derive a save index!");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (XRefDataBase[OovpaTable->Oovpa->XRefSaveIndex] != pFunc) {
|
||||
EmuWarning("Found OOVPA on other address than in XRefDataBase!");
|
||||
EmuWarning("%s: %4d - pFunc: %08X, stored: %08X", OovpaTable->szFuncName, Oovpa->XRefSaveIndex, pFunc, XRefDataBase[Oovpa->XRefSaveIndex]);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Found OOVPA on other address than in XRefDataBase!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "%s: %4d - pFunc: %08X, stored: %08X", OovpaTable->szFuncName, Oovpa->XRefSaveIndex, pFunc, XRefDataBase[Oovpa->XRefSaveIndex]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -414,7 +415,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
std::string cachePath = std::string(szFolder_CxbxReloadedData) + "\\HLECache\\";
|
||||
int result = SHCreateDirectoryEx(nullptr, cachePath.c_str(), nullptr);
|
||||
if ((result != ERROR_SUCCESS) && (result != ERROR_ALREADY_EXISTS)) {
|
||||
CxbxKrnlCleanup("Couldn't create Cxbx-Reloaded HLECache folder!");
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Couldn't create Cxbx-Reloaded HLECache folder!");
|
||||
}
|
||||
|
||||
// Hash the loaded XBE's header, use it as a filename
|
||||
|
@ -507,17 +508,17 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
// Fix up Render state and Texture States
|
||||
if (g_SymbolAddresses.find("D3DDeferredRenderState") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDeferredRenderState"] == 0) {
|
||||
EmuWarning("EmuD3DDeferredRenderState was not found!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuD3DDeferredRenderState was not found!");
|
||||
}
|
||||
|
||||
if (g_SymbolAddresses.find("D3DDeferredTextureState") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDeferredTextureState"] == 0) {
|
||||
EmuWarning("EmuD3DDeferredTextureState was not found!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuD3DDeferredTextureState was not found!");
|
||||
}
|
||||
|
||||
if (g_SymbolAddresses.find("D3DDEVICE") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDEVICE"] == 0) {
|
||||
EmuWarning("D3DDEVICE was not found!");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "D3DDEVICE was not found!");
|
||||
}
|
||||
|
||||
EmuD3D_Init_DeferredStates();
|
||||
|
@ -549,7 +550,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
}
|
||||
#if 0 // NOTE: This is a note for what we should do for above.
|
||||
if (BuildVersion >= 5558 && BuildVersion <= 5659 && QFEVersion > 1) {
|
||||
EmuWarning("D3D8 version 1.0.%d.%d Title Detected: This game uses an alias version 1.0.5788", BuildVersion, QFEVersion);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "D3D8 version 1.0.%d.%d Title Detected: This game uses an alias version 1.0.5788", BuildVersion, QFEVersion);
|
||||
BuildVersion = 5788;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -553,7 +553,7 @@ DWORD PhysicalMemory::PatchXboxPermissions(DWORD Perms)
|
|||
{
|
||||
// One of XBOX_PAGE_READONLY or XBOX_PAGE_READWRITE must be specified
|
||||
|
||||
DbgPrintf("PMEM: PatchXboxPermissions: Memory permissions bug detected\n");
|
||||
DbgPrintf(LOG_PREFIX, "%s: Memory permissions bug detected\n", __func__);
|
||||
return XBOX_PAGE_EXECUTE_READWRITE;
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ DWORD PhysicalMemory::PatchXboxPermissions(DWORD Perms)
|
|||
// If we reach here it means that both XBOX_PAGE_READONLY and XBOX_PAGE_READWRITE were specified, and so the
|
||||
// input is probably invalid
|
||||
|
||||
DbgPrintf("PMEM: PatchXboxPermissions: Memory permissions bug detected\n");
|
||||
DbgPrintf(LOG_PREFIX, "%s: Memory permissions bug detected\n", __func__);
|
||||
return XBOX_PAGE_EXECUTE_READWRITE;
|
||||
}
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ DWORD PhysicalMemory::ConvertXboxToWinProtection(DWORD Perms)
|
|||
// If we reach here it means that more than one permission modifier was specified, and so the input is
|
||||
// probably invalid
|
||||
|
||||
DbgPrintf("PMEM: ConvertXboxToWinProtection: Memory permissions bug detected\n");
|
||||
DbgPrintf(LOG_PREFIX, "%s: Memory permissions bug detected\n", __func__);
|
||||
return PAGE_EXECUTE_READWRITE;
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ bool PhysicalMemory::IsMappable(PFN_COUNT PagesRequested, bool bRetailRegion, bo
|
|||
bool ret = false;
|
||||
if (bRetailRegion && m_PhysicalPagesAvailable >= PagesRequested) { ret = true; }
|
||||
if (bDebugRegion && m_DebuggerPagesAvailable >= PagesRequested) { ret = true; }
|
||||
if (!ret) { EmuWarning(LOG_PREFIX " Out of physical memory!"); }
|
||||
if (!ret) { EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Out of physical memory!"); }
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ VAddr PoolManager::AllocatePool(size_t Size, uint32_t Tag)
|
|||
Unlock();
|
||||
}
|
||||
else {
|
||||
EmuWarning(LOG_PREFIX " AllocatePool returns nullptr");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "AllocatePool returns nullptr");
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ VAddr PoolManager::AllocatePool(size_t Size, uint32_t Tag)
|
|||
Entry = reinterpret_cast<PPOOL_HEADER>(g_VMManager.AllocateSystemMemory(PoolType, XBOX_PAGE_READWRITE, PAGE_SIZE, false));
|
||||
|
||||
if (Entry == nullptr) {
|
||||
EmuWarning(LOG_PREFIX " AllocatePool returns nullptr");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "AllocatePool returns nullptr");
|
||||
Unlock();
|
||||
|
||||
RETURN(LOG_PREFIX, reinterpret_cast<VAddr>(Entry));
|
||||
|
@ -267,7 +267,7 @@ void PoolManager::DeallocatePool(VAddr addr)
|
|||
assert((Entry->PoolType & POOL_TYPE_MASK) != 0);
|
||||
|
||||
if (!IS_POOL_HEADER_MARKED_ALLOCATED(Entry)) {
|
||||
CxbxKrnlCleanup("Pool at address 0x%X is already free!", addr);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Pool at address 0x%X is already free!", addr);
|
||||
}
|
||||
|
||||
MARK_POOL_HEADER_FREED(Entry);
|
||||
|
|
|
@ -89,7 +89,7 @@ void VMManager::Initialize(HANDLE memory_view, HANDLE pagetables_view, int BootF
|
|||
// the xbe has been tampered with: the entry point and the kernel thunk addresses have been xored with a different key to make it
|
||||
// appear to be of a different type.
|
||||
|
||||
CxbxKrnlCleanup("Rebooted xbe type doesn't match with the xbe type that performed the reboot. Tampered xbe or rebooting to the \
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "Rebooted xbe type doesn't match with the xbe type that performed the reboot. Tampered xbe or rebooting to the \
|
||||
dashboard from non-retail xbe?");
|
||||
}
|
||||
}
|
||||
|
@ -178,12 +178,12 @@ dashboard from non-retail xbe?");
|
|||
}
|
||||
|
||||
if (g_bIsChihiro) {
|
||||
printf(LOG_PREFIX " Page table for Chihiro arcade initialized!\n");
|
||||
printf("Page table for Chihiro arcade initialized!\n");
|
||||
}
|
||||
else if (g_bIsDebug) {
|
||||
printf(LOG_PREFIX " Page table for Debug console initialized!\n");
|
||||
printf("Page table for Debug console initialized!\n");
|
||||
}
|
||||
else { printf(LOG_PREFIX " Page table for Retail console initialized!\n"); }
|
||||
else { printf("Page table for Retail console initialized!\n"); }
|
||||
}
|
||||
|
||||
void VMManager::ConstructMemoryRegion(VAddr Start, size_t Size, MemoryRegionType Type)
|
||||
|
@ -434,7 +434,7 @@ void VMManager::ConstructVMA(VAddr Start, size_t Size, MemoryRegionType Type, VM
|
|||
{
|
||||
// Already at the beginning of the map, bail out immediately
|
||||
|
||||
EmuWarning(LOG_PREFIX " Can't find any more free space in the memory region %d! Virtual memory exhausted?", Type);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Can't find any more free space in the memory region %d! Virtual memory exhausted?", Type);
|
||||
m_MemoryRegionArray[Type].LastFree = m_MemoryRegionArray[Type].RegionMap.end();
|
||||
return;
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ void VMManager::ConstructVMA(VAddr Start, size_t Size, MemoryRegionType Type, VM
|
|||
// ergo720: I don't expect this to happen since it would mean we have exhausted the virtual space in the memory region,
|
||||
// but it's just in case it does
|
||||
|
||||
EmuWarning(LOG_PREFIX " Can't find any more free space in the memory region %d! Virtual memory exhausted?", Type);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Can't find any more free space in the memory region %d! Virtual memory exhausted?", Type);
|
||||
|
||||
m_MemoryRegionArray[Type].LastFree = m_MemoryRegionArray[Type].RegionMap.end();
|
||||
|
||||
|
@ -593,7 +593,7 @@ VAddr VMManager::ClaimGpuMemory(size_t Size, size_t* BytesToSkip)
|
|||
}
|
||||
m_NV2AInstanceMemoryBytes = Size;
|
||||
|
||||
DbgPrintf("VMEM: MmClaimGpuInstanceMemory : Allocated bytes remaining = 0x%.8X\n", m_NV2AInstanceMemoryBytes);
|
||||
DbgPrintf(LOG_PREFIX, "MmClaimGpuInstanceMemory : Allocated bytes remaining = 0x%.8X\n", m_NV2AInstanceMemoryBytes);
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
@ -640,12 +640,12 @@ void VMManager::PersistMemory(VAddr addr, size_t Size, bool bPersist)
|
|||
if (bPersist)
|
||||
{
|
||||
*(VAddr*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 4) = addr;
|
||||
DbgPrintf("KNRL: Persisting LaunchDataPage\n");
|
||||
DbgPrintf(LOG_PREFIX, "Persisting LaunchDataPage\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
*(VAddr*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 4) = NULL;
|
||||
DbgPrintf("KNRL: Forgetting LaunchDataPage\n");
|
||||
DbgPrintf(LOG_PREFIX, "Forgetting LaunchDataPage\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -653,12 +653,12 @@ void VMManager::PersistMemory(VAddr addr, size_t Size, bool bPersist)
|
|||
if (bPersist)
|
||||
{
|
||||
*(VAddr*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 8) = addr;
|
||||
DbgPrintf("KNRL: Persisting FrameBuffer\n");
|
||||
DbgPrintf(LOG_PREFIX, "Persisting FrameBuffer\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
*(VAddr*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 8) = NULL;
|
||||
DbgPrintf("KNRL: Forgetting FrameBuffer\n");
|
||||
DbgPrintf(LOG_PREFIX, "Forgetting FrameBuffer\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ void VMManager::RestorePersistentMemory()
|
|||
RestorePersistentAllocation(LauchDataAddress, GetPteAddress(LauchDataAddress)->Hardware.PFN,
|
||||
GetPteAddress(LauchDataAddress)->Hardware.PFN, ContiguousType);
|
||||
|
||||
DbgPrintf("VMEM: Restored LaunchDataPage\n");
|
||||
DbgPrintf(LOG_PREFIX, "Restored LaunchDataPage\n");
|
||||
}
|
||||
|
||||
if (FrameBufferAddress != 0 && IS_PHYSICAL_ADDRESS(FrameBufferAddress)) {
|
||||
|
@ -736,7 +736,7 @@ void VMManager::RestorePersistentMemory()
|
|||
RestorePersistentAllocation(FrameBufferAddress, GetPteAddress(FrameBufferAddress)->Hardware.PFN,
|
||||
GetPteAddress(FrameBufferAddress)->Hardware.PFN + (QuerySize(FrameBufferAddress, false) >> PAGE_SHIFT) - 1, ContiguousType);
|
||||
|
||||
DbgPrintf("VMEM: Restored FrameBuffer\n");
|
||||
DbgPrintf(LOG_PREFIX, "Restored FrameBuffer\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ VAddr VMManager::Allocate(size_t Size)
|
|||
|
||||
VAddr VMManager::AllocateZeroed(size_t Size)
|
||||
{
|
||||
LOG_FORWARD("g_VMManager.Allocate");
|
||||
LOG_FORWARD(LOG_PREFIX, "g_VMManager.Allocate");
|
||||
|
||||
VAddr addr = Allocate(Size);
|
||||
if (addr) { xboxkrnl::RtlFillMemoryUlong((void*)addr, ROUND_UP_4K(Size), 0); }
|
||||
|
@ -1467,7 +1467,7 @@ size_t VMManager::QuerySize(VAddr addr, bool bCxbxCaller)
|
|||
else if(IS_USER_ADDRESS(addr)) { Type = UserRegion; }
|
||||
else
|
||||
{
|
||||
DbgPrintf("VMEM: QuerySize: Unknown memory region queried.\n");
|
||||
DbgPrintf(LOG_PREFIX, "QuerySize: Unknown memory region queried.\n");
|
||||
Unlock();
|
||||
RETURN(LOG_PREFIX, Size);
|
||||
}
|
||||
|
@ -1624,7 +1624,7 @@ xboxkrnl::NTSTATUS VMManager::XbAllocateVirtualMemory(VAddr* addr, ULONG ZeroBit
|
|||
|
||||
if (!ConvertXboxToPteProtection(Protect, &TempPte)) { RETURN(LOG_PREFIX, STATUS_INVALID_PAGE_PROTECTION); }
|
||||
|
||||
DbgPrintf("VMEM: XbAllocateVirtualMemory requested range : 0x%.8X - 0x%.8X\n", CapturedBase, CapturedBase + CapturedSize);
|
||||
DbgPrintf(LOG_PREFIX, "%s requested range : 0x%.8X - 0x%.8X\n", __func__, CapturedBase, CapturedBase + CapturedSize);
|
||||
|
||||
Lock();
|
||||
|
||||
|
@ -1691,8 +1691,7 @@ xboxkrnl::NTSTATUS VMManager::XbAllocateVirtualMemory(VAddr* addr, ULONG ZeroBit
|
|||
{
|
||||
// XBOX_MEM_COMMIT was not specified, so we are done with the allocation
|
||||
|
||||
DbgPrintf("VMEM: XbAllocateVirtualMemory resulting range : 0x%.8X - 0x%.8X\n", AlignedCapturedBase,
|
||||
AlignedCapturedBase + AlignedCapturedSize);
|
||||
DbgPrintf(LOG_PREFIX, "%s resulting range : 0x%.8X - 0x%.8X\n", __func__, AlignedCapturedBase, AlignedCapturedBase + AlignedCapturedSize);
|
||||
|
||||
*addr = AlignedCapturedBase;
|
||||
*Size = AlignedCapturedSize;
|
||||
|
@ -1795,13 +1794,13 @@ xboxkrnl::NTSTATUS VMManager::XbAllocateVirtualMemory(VAddr* addr, ULONG ZeroBit
|
|||
if (!VirtualAlloc((void*)AlignedCapturedBase, AlignedCapturedSize, MEM_COMMIT,
|
||||
(ConvertXboxToWinProtection(PatchXboxPermissions(Protect))) & ~(PAGE_WRITECOMBINE | PAGE_NOCACHE)))
|
||||
{
|
||||
DbgPrintf("VMEM: XbAllocateVirtualMemory: VirtualAlloc failed to commit the memory! The error was %d\n", GetLastError());
|
||||
DbgPrintf(LOG_PREFIX, "%s: VirtualAlloc failed to commit the memory! The error was %d\n", __func__, GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
// Because VirtualAlloc always zeros the memory for us, XBOX_MEM_NOZERO is still unsupported
|
||||
|
||||
if (AllocationType & XBOX_MEM_NOZERO) { DbgPrintf("VMEM: XBOX_MEM_NOZERO flag is not supported!\n"); }
|
||||
if (AllocationType & XBOX_MEM_NOZERO) { DbgPrintf(LOG_PREFIX, "XBOX_MEM_NOZERO flag is not supported!\n"); }
|
||||
|
||||
// If some pte's were detected to have different permissions in the above check, we need to update those as well
|
||||
|
||||
|
@ -1813,8 +1812,7 @@ xboxkrnl::NTSTATUS VMManager::XbAllocateVirtualMemory(VAddr* addr, ULONG ZeroBit
|
|||
XbVirtualProtect(&TempAddr, &TempSize, &TempProtect);
|
||||
}
|
||||
|
||||
DbgPrintf("VMEM: XbAllocateVirtualMemory resulting range : 0x%.8X - 0x%.8X\n", AlignedCapturedBase,
|
||||
AlignedCapturedBase + AlignedCapturedSize);
|
||||
DbgPrintf(LOG_PREFIX, "%s resulting range : 0x%.8X - 0x%.8X\n", __func__, AlignedCapturedBase, AlignedCapturedBase + AlignedCapturedSize);
|
||||
|
||||
*addr = AlignedCapturedBase;
|
||||
*Size = AlignedCapturedSize;
|
||||
|
@ -1973,7 +1971,7 @@ xboxkrnl::NTSTATUS VMManager::XbFreeVirtualMemory(VAddr* addr, size_t* Size, DWO
|
|||
|
||||
if (!VirtualFree((void*)AlignedCapturedBase, AlignedCapturedSize, MEM_DECOMMIT))
|
||||
{
|
||||
DbgPrintf("VMEM: XbFreeVirtualMemory: VirtualFree failed to decommit the memory! The error was %d\n", GetLastError());
|
||||
DbgPrintf(LOG_PREFIX, "%s: VirtualFree failed to decommit the memory! The error was %d\n", __func__, GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2331,7 +2329,7 @@ VAddr VMManager::MapMemoryBlock(MappingFn MappingRoutine, MemoryRegionType Type,
|
|||
{
|
||||
// We are already at the beginning of the map, so bail out immediately
|
||||
|
||||
EmuWarning(LOG_PREFIX " Failed to map a memory block in the virtual region %d!", Type);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Failed to map a memory block in the virtual region %d!", Type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2362,7 +2360,7 @@ VAddr VMManager::MapMemoryBlock(MappingFn MappingRoutine, MemoryRegionType Type,
|
|||
// We have failed to map the block. This is likely because the virtual space is fragmented or there are too many
|
||||
// host allocations in the memory region. Log this error and bail out
|
||||
|
||||
EmuWarning(LOG_PREFIX " Failed to map a memory block in the virtual region %d!", Type);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Failed to map a memory block in the virtual region %d!", Type);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2464,13 +2462,13 @@ PAddr VMManager::TranslateVAddrToPAddr(const VAddr addr)
|
|||
if (Type != COUNTRegion && Type != ContiguousRegion) {
|
||||
if (IsValidVirtualAddress(addr)) {
|
||||
if (Type == UserRegion) {
|
||||
EmuWarning("Applying identity mapping hack to allocation at address 0x%X", addr);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Applying identity mapping hack to allocation at address 0x%X", addr);
|
||||
Unlock();
|
||||
RETURN(LOG_PREFIX, addr); // committed pages in the user region always use VirtualAlloc
|
||||
}
|
||||
VMAIter it = GetVMAIterator(addr, Type);
|
||||
if (it != m_MemoryRegionArray[Type].RegionMap.end() && it->second.type != FreeVma && it->second.bFragmented) {
|
||||
EmuWarning("Applying identity mapping hack to allocation at address 0x%X", addr);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Applying identity mapping hack to allocation at address 0x%X", addr);
|
||||
Unlock();
|
||||
RETURN(LOG_PREFIX, addr); // committed pages in the system-devkit regions can use VirtualAlloc because of fragmentation
|
||||
}
|
||||
|
@ -2644,7 +2642,7 @@ void VMManager::UpdateMemoryPermissions(VAddr addr, size_t Size, DWORD Perms)
|
|||
DWORD dummy;
|
||||
if (!VirtualProtect((void*)addr, Size, WindowsPerms & ~(PAGE_WRITECOMBINE | PAGE_NOCACHE), &dummy))
|
||||
{
|
||||
DbgPrintf("VMEM: VirtualProtect failed. The error code was %d\n", GetLastError());
|
||||
DbgPrintf(LOG_PREFIX, "VirtualProtect failed. The error code was %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2662,14 +2660,14 @@ VMAIter VMManager::CheckExistenceVMA(VAddr addr, MemoryRegionType Type, size_t S
|
|||
{
|
||||
return it;
|
||||
}
|
||||
DbgPrintf("VMEM: Located vma but sizes don't match\n");
|
||||
DbgPrintf(LOG_PREFIX, "Located vma but sizes don't match\n");
|
||||
return m_MemoryRegionArray[Type].RegionMap.end();
|
||||
}
|
||||
return it;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrintf("VMEM: Vma not found or doesn't start at the supplied address\n");
|
||||
DbgPrintf(LOG_PREFIX, "Vma not found or doesn't start at the supplied address\n");
|
||||
return m_MemoryRegionArray[Type].RegionMap.end();
|
||||
}
|
||||
}
|
||||
|
@ -2717,7 +2715,7 @@ void VMManager::DestructVMA(VAddr addr, MemoryRegionType Type, size_t Size)
|
|||
|
||||
if (!ret)
|
||||
{
|
||||
DbgPrintf("VMEM: Deallocation routine failed with error %d\n", GetLastError());
|
||||
DbgPrintf(LOG_PREFIX, "Deallocation routine failed with error %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2743,7 +2741,7 @@ void VMManager::DestructVMA(VAddr addr, MemoryRegionType Type, size_t Size)
|
|||
}
|
||||
else
|
||||
{
|
||||
DbgPrintf("VMEM: std::prev(CarvedVmaIt) was not free\n");
|
||||
DbgPrintf(LOG_PREFIX, "std::prev(CarvedVmaIt) was not free\n");
|
||||
|
||||
it = CarvedVmaIt;
|
||||
|
||||
|
@ -2771,7 +2769,7 @@ void VMManager::DestructVMA(VAddr addr, MemoryRegionType Type, size_t Size)
|
|||
--it;
|
||||
}
|
||||
|
||||
EmuWarning(LOG_PREFIX " Can't find any more free space in the memory region %d! Virtual memory exhausted?", Type);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Can't find any more free space in the memory region %d! Virtual memory exhausted?", Type);
|
||||
|
||||
m_MemoryRegionArray[Type].LastFree = m_MemoryRegionArray[Type].RegionMap.end();
|
||||
|
||||
|
|
|
@ -34,10 +34,11 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::ADM
|
||||
|
||||
#include "ADM1032Device.h"
|
||||
#include "..\CxbxKrnl\Emu.h" // For EmuWarning
|
||||
|
||||
|
||||
void ADM1032Device::Init()
|
||||
{
|
||||
// ergo720: these are the values reported by UnleashX on my modded Xbox after half an hour of playing (in celsius)
|
||||
|
@ -51,7 +52,7 @@ uint8_t ADM1032Device::ReadByte(uint8_t command)
|
|||
if (command == 0x0) { return m_MBTemperature; }
|
||||
else if(command == 0x1) { return m_CPUTemperature; }
|
||||
|
||||
EmuWarning("Unknown read command sent to the temperature sensor. The command was %d", command);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown read command sent to the temperature sensor. The command was %d", command);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -394,7 +394,7 @@ void EmuNVNet_UpdateIRQ()
|
|||
{
|
||||
if (EmuNVNet_GetRegister(NvRegIrqMask, 4) &&
|
||||
EmuNVNet_GetRegister(NvRegIrqStatus, 4)) {
|
||||
DbgPrintf("EmuNVNet: Asserting IRQ\n");
|
||||
DbgPrintf(LOG_PREFIX, "Asserting IRQ\n");
|
||||
HalSystemInterrupts[4].Assert(true);
|
||||
} else {
|
||||
HalSystemInterrupts[4].Assert(false);
|
||||
|
@ -413,7 +413,7 @@ int EmuNVNet_MiiReadWrite(uint64_t val)
|
|||
reg = mii_ctl & ((1 << NVREG_MIICTL_ADDRSHIFT) - 1);
|
||||
write = mii_ctl & NVREG_MIICTL_WRITE;
|
||||
|
||||
DbgPrintf("nvnet mii %s: phy 0x%x %s [0x%x]\n", write ? "write" : "read", phy_addr, EmuNVNet_GetMiiRegisterName(reg), reg);
|
||||
DbgPrintf(LOG_PREFIX, "nvnet mii %s: phy 0x%x %s [0x%x]\n", write ? "write" : "read", phy_addr, EmuNVNet_GetMiiRegisterName(reg), reg);
|
||||
|
||||
if (phy_addr != 1) {
|
||||
return -1;
|
||||
|
@ -444,7 +444,7 @@ int EmuNVNet_MiiReadWrite(uint64_t val)
|
|||
|
||||
uint32_t EmuNVNet_Read(xbaddr addr, int size)
|
||||
{
|
||||
DbgPrintf("NET : Read%d: %s (0x%.8X)\n", size, EmuNVNet_GetRegisterName(addr), addr);
|
||||
DbgPrintf(LOG_PREFIX, "Read%d: %s (0x%.8X)\n", size, EmuNVNet_GetRegisterName(addr), addr);
|
||||
|
||||
switch (addr) {
|
||||
case NvRegMIIData:
|
||||
|
@ -471,8 +471,8 @@ void EmuNVNet_Write(xbaddr addr, uint32_t value, int size)
|
|||
break;
|
||||
case NvRegTxRxControl:
|
||||
if (value == NVREG_TXRXCTL_KICK) {
|
||||
DbgPrintf("NvRegTxRxControl = NVREG_TXRXCTL_KICK!\n");
|
||||
EmuWarning("TODO: nvnet_dma_packet_from_guest");
|
||||
DbgPrintf(LOG_PREFIX, "NvRegTxRxControl = NVREG_TXRXCTL_KICK!\n");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "TODO: nvnet_dma_packet_from_guest");
|
||||
// nvnet_dma_packet_from_guest(s);
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ void EmuNVNet_Write(xbaddr addr, uint32_t value, int size)
|
|||
break;
|
||||
}
|
||||
|
||||
DbgPrintf("NET : Write%d: %s (0x%.8X) = 0x%.8X\n", size, EmuNVNet_GetRegisterName(addr), addr, value);
|
||||
DbgPrintf(LOG_PREFIX, "Write%d: %s (0x%.8X) = 0x%.8X\n", size, EmuNVNet_GetRegisterName(addr), addr, value);
|
||||
}
|
||||
|
||||
/* NVNetDevice */
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
// ******************************************************************
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::SMC
|
||||
|
||||
/* prevent name collisions */
|
||||
namespace xboxkrnl
|
||||
{
|
||||
|
@ -51,7 +53,7 @@ namespace xboxkrnl
|
|||
void SetLEDSequence(LED::Sequence aLEDSequence)
|
||||
{
|
||||
// See http://xboxdevwiki.net/PIC#The_LED
|
||||
DbgPrintf("SMC : SetLEDSequence : %u\n", (byte)aLEDSequence);
|
||||
DbgPrintf(LOG_PREFIX, "SetLEDSequence : %u\n", (byte)aLEDSequence);
|
||||
|
||||
int LedSequence[4] = { XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF };
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ MCPXRevision MCPXRevisionFromHardwareModel(HardwareModel hardwareModel)
|
|||
case Revision1_6:
|
||||
return MCPXRevision::MCPX_X3;
|
||||
case DebugKit:
|
||||
// EmuWarning("Guessing MCPXVersion");
|
||||
// EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Guessing MCPXVersion");
|
||||
return MCPXRevision::MCPX_X2;
|
||||
default:
|
||||
// UNREACHABLE(hardwareModel);
|
||||
|
@ -79,7 +79,7 @@ SCMRevision SCMRevisionFromHardwareModel(HardwareModel hardwareModel)
|
|||
case Revision1_4:
|
||||
case Revision1_5:
|
||||
case Revision1_6:
|
||||
// EmuWarning("Guessing SCMRevision");
|
||||
// EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Guessing SCMRevision");
|
||||
return SCMRevision::P2L; // Assumption; Our SCM returns PIC version string "P05"
|
||||
case DebugKit:
|
||||
return SCMRevision::D01; // Our SCM returns PIC version string "DXB"
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::HUB
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
{
|
||||
|
@ -47,8 +49,6 @@ namespace xboxkrnl
|
|||
#include "CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include "Logging.h"
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::HUB
|
||||
|
||||
#define NUM_PORTS 8
|
||||
|
||||
#define PORT_STAT_CONNECTION 0x0001
|
||||
|
@ -249,7 +249,7 @@ int Hub::UsbHubClaimPort(XboxDeviceState* dev, int port)
|
|||
i++;
|
||||
}
|
||||
if (it == m_UsbDev->m_FreePorts.end()) {
|
||||
EmuWarning("Port requested %d not found (in use?)", port);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Port requested %d not found (in use?)", port);
|
||||
return -1;
|
||||
}
|
||||
dev->Port = *it;
|
||||
|
@ -377,8 +377,8 @@ void Hub::UsbHub_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
goto fail;
|
||||
}
|
||||
port = &m_HubState->ports[n];
|
||||
DbgPrintf("%s %s GetPortStatus -> Address 0x%X, wIndex %d, wPortStatus %d, wPortChange %d\n",
|
||||
LOG_STR_HUB, __func__, m_HubState->dev.Addr, index, port->wPortStatus, port->wPortChange);
|
||||
DbgPrintf(LOG_PREFIX, "%s GetPortStatus -> Address 0x%X, wIndex %d, wPortStatus %d, wPortChange %d\n",
|
||||
__func__, m_HubState->dev.Addr, index, port->wPortStatus, port->wPortChange);
|
||||
data[0] = port->wPortStatus;
|
||||
data[1] = port->wPortStatus >> 8;
|
||||
data[2] = port->wPortChange;
|
||||
|
@ -402,8 +402,8 @@ void Hub::UsbHub_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
USBHubPort* port;
|
||||
XboxDeviceState* dev;
|
||||
|
||||
DbgPrintf("%s %s SetPortFeature -> Address 0x%X, wIndex %d, Feature %s\n",
|
||||
LOG_STR_HUB, __func__, m_HubState->dev.Addr, index, GetFeatureName(value));
|
||||
DbgPrintf(LOG_PREFIX, "%s SetPortFeature -> Address 0x%X, wIndex %d, Feature %s\n",
|
||||
__func__, m_HubState->dev.Addr, index, GetFeatureName(value));
|
||||
|
||||
if (n >= NUM_PORTS) {
|
||||
goto fail;
|
||||
|
@ -440,8 +440,8 @@ void Hub::UsbHub_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
unsigned int n = index - 1;
|
||||
USBHubPort *port;
|
||||
|
||||
DbgPrintf("%s %s ClearPortFeature -> Address 0x%X, wIndex %d, Feature %s\n",
|
||||
LOG_STR_HUB, __func__, m_HubState->dev.Addr, index, GetFeatureName(value));
|
||||
DbgPrintf(LOG_PREFIX, "%s ClearPortFeature -> Address 0x%X, wIndex %d, Feature %s\n",
|
||||
__func__, m_HubState->dev.Addr, index, GetFeatureName(value));
|
||||
|
||||
if (n >= NUM_PORTS) {
|
||||
goto fail;
|
||||
|
@ -527,7 +527,7 @@ void Hub::UsbHub_HandleData(XboxDeviceState* dev, USBPacket* p)
|
|||
p->Status = USB_RET_BABBLE;
|
||||
return;
|
||||
}
|
||||
DbgPrintf("%s %s Address 0x%X, Status %d\n", LOG_STR_HUB, __func__, m_HubState->dev.Addr, status);
|
||||
DbgPrintf(LOG_PREFIX, "%s Address 0x%X, Status %d\n", __func__, m_HubState->dev.Addr, status);
|
||||
for (i = 0; i < n; i++) {
|
||||
buf[i] = status >> (8 * i);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::OHCI
|
||||
|
||||
/* prevent name collisions */
|
||||
namespace xboxkrnl
|
||||
|
@ -45,9 +47,7 @@ namespace xboxkrnl
|
|||
#include "OHCI.h"
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For HalSystemInterrupt
|
||||
#include "CxbxCommon.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::OHCI
|
||||
#include "Logging.h"
|
||||
|
||||
/* Define these two if you want to dump usb packets */
|
||||
//#define DEBUG_ISOCH
|
||||
|
@ -249,7 +249,7 @@ void OHCI::OHCI_FrameBoundaryWorker()
|
|||
m_bFrameTime = true;
|
||||
|
||||
if (OHCI_ReadHCCA(m_Registers.HcHCCA, &hcca)) {
|
||||
EmuWarning("%s HCCA read error at physical address 0x%X", m_Registers.HcHCCA, LOG_STR_OHCI);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "HCCA read error at physical address 0x%X", m_Registers.HcHCCA);
|
||||
OHCI_FatalError();
|
||||
m_bFrameTime = false;
|
||||
return;
|
||||
|
@ -293,7 +293,7 @@ void OHCI::OHCI_FrameBoundaryWorker()
|
|||
if (!m_Registers.HcDoneHead) {
|
||||
// From the standard: "This is set to zero whenever HC writes the content of this
|
||||
// register to HCCA. It also sets the WritebackDoneHead of HcInterruptStatus."
|
||||
CxbxKrnlCleanup("%s HcDoneHead is zero but WritebackDoneHead interrupt is not set!\n", LOG_STR_OHCI);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "HcDoneHead is zero but WritebackDoneHead interrupt is not set!\n");
|
||||
}
|
||||
|
||||
if (m_Registers.HcInterrupt & m_Registers.HcInterruptStatus) {
|
||||
|
@ -320,7 +320,7 @@ void OHCI::OHCI_FrameBoundaryWorker()
|
|||
|
||||
// Writeback HCCA
|
||||
if (OHCI_WriteHCCA(m_Registers.HcHCCA, &hcca)) {
|
||||
EmuWarning("%s HCCA write error at physical address 0x%X", LOG_STR_OHCI, m_Registers.HcHCCA);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "HCCA write error at physical address 0x%X", m_Registers.HcHCCA);
|
||||
OHCI_FatalError();
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ void OHCI::OHCI_FatalError()
|
|||
|
||||
OHCI_SetInterrupt(OHCI_INTR_UE);
|
||||
OHCI_BusStop();
|
||||
DbgPrintf("%s an unrecoverable error occoured!\n", LOG_STR_OHCI);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "an unrecoverable error occoured!\n");
|
||||
}
|
||||
|
||||
bool OHCI::OHCI_ReadHCCA(xbaddr Paddr, OHCI_HCCA* Hcca)
|
||||
|
@ -536,7 +536,7 @@ int OHCI::OHCI_ServiceEDlist(xbaddr Head, int Completion)
|
|||
|
||||
for (current = Head; current; current = next_ed) {
|
||||
if (OHCI_ReadED(current, &ed)) {
|
||||
EmuWarning("%s ED read error at physical address 0x%X", LOG_STR_OHCI, current);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "ED read error at physical address 0x%X", current);
|
||||
OHCI_FatalError();
|
||||
return 0;
|
||||
}
|
||||
|
@ -614,11 +614,11 @@ int OHCI::OHCI_ServiceTD(OHCI_ED* Ed)
|
|||
// See if this TD has already been submitted to the device
|
||||
completion = (addr == m_AsyncTD);
|
||||
if (completion && !m_AsyncComplete) {
|
||||
DbgPrintf("Skipping async TD\n");
|
||||
DbgPrintf(LOG_PREFIX, "Skipping async TD\n");
|
||||
return 1;
|
||||
}
|
||||
if (OHCI_ReadTD(addr, &td)) {
|
||||
EmuWarning("%s TD read error at physical address 0x%X", LOG_STR_OHCI, addr);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "TD read error at physical address 0x%X", addr);
|
||||
OHCI_FatalError();
|
||||
return 0;
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ int OHCI::OHCI_ServiceTD(OHCI_ED* Ed)
|
|||
pid = USB_TOKEN_SETUP;
|
||||
break;
|
||||
default:
|
||||
EmuWarning("%s bad direction", LOG_STR_OHCI);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "bad direction");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -718,7 +718,7 @@ int OHCI::OHCI_ServiceTD(OHCI_ED* Ed)
|
|||
// From XQEMU: "??? The hardware should allow one active packet per endpoint.
|
||||
// We only allow one active packet per controller. This should be sufficient
|
||||
// as long as devices respond in a timely manner."
|
||||
DbgPrintf("%s too many pending packets\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "too many pending packets\n");
|
||||
return 1;
|
||||
}
|
||||
dev = OHCI_FindDevice(OHCI_BM(Ed->Flags, ED_FA));
|
||||
|
@ -792,29 +792,29 @@ int OHCI::OHCI_ServiceTD(OHCI_ED* Ed)
|
|||
}
|
||||
else {
|
||||
if (ret >= 0) {
|
||||
DbgPrintf("%s Underrun\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Underrun\n");
|
||||
OHCI_SET_BM(td.Flags, TD_CC, OHCI_CC_DATAUNDERRUN);
|
||||
}
|
||||
else {
|
||||
switch (ret) {
|
||||
case USB_RET_IOERROR:
|
||||
case USB_RET_NODEV:
|
||||
DbgPrintf("%s Received DEV ERROR\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Received DEV ERROR\n", );
|
||||
OHCI_SET_BM(td.Flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING);
|
||||
break;
|
||||
case USB_RET_NAK:
|
||||
DbgPrintf("%s Received NAK\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Received NAK\n");
|
||||
return 1;
|
||||
case USB_RET_STALL:
|
||||
DbgPrintf("%s Received STALL\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Received STALL\n");
|
||||
OHCI_SET_BM(td.Flags, TD_CC, OHCI_CC_STALL);
|
||||
break;
|
||||
case USB_RET_BABBLE:
|
||||
DbgPrintf("%s Received BABBLE\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Received BABBLE\n");
|
||||
OHCI_SET_BM(td.Flags, TD_CC, OHCI_CC_DATAOVERRUN);
|
||||
break;
|
||||
default:
|
||||
DbgPrintf("%s Bad device response %d\n", LOG_STR_OHCI, ret);
|
||||
DbgPrintf(LOG_PREFIX, "Bad device response %d\n", ret);
|
||||
OHCI_SET_BM(td.Flags, TD_CC, OHCI_CC_UNDEXPETEDPID);
|
||||
OHCI_SET_BM(td.Flags, TD_EC, 3);
|
||||
}
|
||||
|
@ -911,7 +911,7 @@ void OHCI::OHCI_StateReset()
|
|||
|
||||
OHCI_StopEndpoints();
|
||||
|
||||
DbgPrintf("%s Reset mode event.\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Reset mode event.\n");
|
||||
}
|
||||
|
||||
void OHCI::OHCI_BusStart()
|
||||
|
@ -919,7 +919,7 @@ void OHCI::OHCI_BusStart()
|
|||
// Create the EOF timer. Let's try a factor of 50 (1 virtual ms -> 50 real ms)
|
||||
m_pEOFtimer = Timer_Create(OHCI_FrameBoundaryWrapper, this, 50);
|
||||
|
||||
DbgPrintf("%s Operational mode event\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Operational mode event\n");
|
||||
|
||||
// SOF event
|
||||
OHCI_SOF(true);
|
||||
|
@ -966,11 +966,11 @@ void OHCI::OHCI_ChangeState(uint32_t Value)
|
|||
|
||||
case Suspend:
|
||||
OHCI_BusStop();
|
||||
DbgPrintf("%s Suspend mode event\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Suspend mode event\n");
|
||||
break;
|
||||
|
||||
case Resume:
|
||||
DbgPrintf("%s Resume mode event\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Resume mode event\n");
|
||||
break;
|
||||
|
||||
case Reset:
|
||||
|
@ -978,7 +978,7 @@ void OHCI::OHCI_ChangeState(uint32_t Value)
|
|||
break;
|
||||
|
||||
default:
|
||||
EmuWarning("%s Unknown USB mode!", LOG_STR_OHCI);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown USB mode!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +997,7 @@ uint32_t OHCI::OHCI_ReadRegister(xbaddr Addr)
|
|||
|
||||
if (Addr & 3) {
|
||||
// The standard allows only aligned reads to the registers
|
||||
DbgPrintf("%s Unaligned read. Ignoring.\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Unaligned read. Ignoring.\n");
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
@ -1102,7 +1102,7 @@ uint32_t OHCI::OHCI_ReadRegister(xbaddr Addr)
|
|||
break;
|
||||
|
||||
default:
|
||||
EmuWarning("%s Read register operation with bad offset %u. Ignoring.", LOG_STR_OHCI, Addr >> 2);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Read register operation with bad offset %u. Ignoring.", Addr >> 2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ void OHCI::OHCI_WriteRegister(xbaddr Addr, uint32_t Value)
|
|||
{
|
||||
if (Addr & 3) {
|
||||
// The standard allows only aligned writes to the registers
|
||||
DbgPrintf("%s Unaligned write. Ignoring.\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "Unaligned write. Ignoring.\n");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -1189,7 +1189,7 @@ void OHCI::OHCI_WriteRegister(xbaddr Addr, uint32_t Value)
|
|||
case 13: // HcFmInterval
|
||||
{
|
||||
if ((Value & OHCI_FMI_FI) != (m_Registers.HcFmInterval & OHCI_FMI_FI)) {
|
||||
DbgPrintf("%s Changing frame interval duration. New value is %u\n", LOG_STR_OHCI, Value & OHCI_FMI_FI);
|
||||
DbgPrintf(LOG_PREFIX, "Changing frame interval duration. New value is %u\n", Value & OHCI_FMI_FI);
|
||||
}
|
||||
m_Registers.HcFmInterval = Value & ~0xC000;
|
||||
}
|
||||
|
@ -1241,7 +1241,7 @@ void OHCI::OHCI_WriteRegister(xbaddr Addr, uint32_t Value)
|
|||
break;
|
||||
|
||||
default:
|
||||
EmuWarning("%s Write register operation with bad offset %u. Ignoring.", LOG_STR_OHCI, Addr >> 2);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Write register operation with bad offset %u. Ignoring.", Addr >> 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1317,7 +1317,7 @@ void OHCI::OHCI_SetHubStatus(uint32_t Value)
|
|||
for (i = 0; i < 4; i++) {
|
||||
OHCI_PortPower(i, 0);
|
||||
}
|
||||
DbgPrintf("%s powered down all ports\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "powered down all ports\n");
|
||||
}
|
||||
|
||||
if (Value & OHCI_RHS_LPSC) {
|
||||
|
@ -1326,7 +1326,7 @@ void OHCI::OHCI_SetHubStatus(uint32_t Value)
|
|||
for (i = 0; i < 4; i++) {
|
||||
OHCI_PortPower(i, 1);
|
||||
}
|
||||
DbgPrintf("%s powered up all ports\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "powered up all ports\n");
|
||||
}
|
||||
|
||||
if (Value & OHCI_RHS_DRWE) {
|
||||
|
@ -1375,11 +1375,11 @@ void OHCI::OHCI_PortSetStatus(int PortNum, uint32_t Value)
|
|||
OHCI_PortSetIfConnected(PortNum, Value & OHCI_PORT_PES);
|
||||
|
||||
if (OHCI_PortSetIfConnected(PortNum, Value & OHCI_PORT_PSS)) {
|
||||
DbgPrintf("%s port %d: SUSPEND\n", LOG_STR_OHCI, PortNum);
|
||||
DbgPrintf(LOG_PREFIX, "port %d: SUSPEND\n", PortNum);
|
||||
}
|
||||
|
||||
if (OHCI_PortSetIfConnected(PortNum, Value & OHCI_PORT_PRS)) {
|
||||
DbgPrintf("%s port %d: RESET\n", LOG_STR_OHCI, PortNum);
|
||||
DbgPrintf(LOG_PREFIX, "port %d: RESET\n", PortNum);
|
||||
m_UsbDevice->USB_DeviceReset(port->UsbPort.Dev);
|
||||
port->HcRhPortStatus &= ~OHCI_PORT_PRS;
|
||||
// ??? Should this also set OHCI_PORT_PESC
|
||||
|
@ -1447,7 +1447,7 @@ void OHCI::OHCI_Detach(USBPort* Port)
|
|||
port->HcRhPortStatus |= OHCI_PORT_PESC;
|
||||
}
|
||||
|
||||
DbgPrintf("%s Detached port %d\n", LOG_STR_OHCI, Port->PortIndex);
|
||||
DbgPrintf(LOG_PREFIX, "Detached port %d\n", Port->PortIndex);
|
||||
|
||||
if (old_state != port->HcRhPortStatus) {
|
||||
OHCI_SetInterrupt(OHCI_INTR_RHSC);
|
||||
|
@ -1475,7 +1475,7 @@ void OHCI::OHCI_Attach(USBPort* Port)
|
|||
OHCI_SetInterrupt(OHCI_INTR_RD);
|
||||
}
|
||||
|
||||
DbgPrintf("%s Attached port %d\n", LOG_STR_OHCI, Port->PortIndex);
|
||||
DbgPrintf(LOG_PREFIX, "Attached port %d\n", Port->PortIndex);
|
||||
|
||||
if (old_state != port->HcRhPortStatus) {
|
||||
OHCI_SetInterrupt(OHCI_INTR_RHSC);
|
||||
|
@ -1492,14 +1492,14 @@ void OHCI::OHCI_Wakeup(USBPort* port1)
|
|||
OHCIPort* port = &m_Registers.RhPort[port1->PortIndex];
|
||||
uint32_t intr = 0;
|
||||
if (port->HcRhPortStatus & OHCI_PORT_PSS) {
|
||||
DbgPrintf("%s port %d: wakeup\n", LOG_STR_OHCI, port1->PortIndex);
|
||||
DbgPrintf(LOG_PREFIX, "port %d: wakeup\n", port1->PortIndex);
|
||||
port->HcRhPortStatus |= OHCI_PORT_PSSC;
|
||||
port->HcRhPortStatus &= ~OHCI_PORT_PSS;
|
||||
intr = OHCI_INTR_RHSC;
|
||||
}
|
||||
// Note that the controller can be suspended even if this port is not
|
||||
if ((m_Registers.HcControl & OHCI_CTL_HCFS) == Suspend) {
|
||||
DbgPrintf("%s remote-wakeup: SUSPEND->RESUME\n", LOG_STR_OHCI);
|
||||
DbgPrintf(LOG_PREFIX, "remote-wakeup: SUSPEND->RESUME\n");
|
||||
// From the standard: "The only interrupts possible in the USBSUSPEND state are ResumeDetected (the
|
||||
// Host Controller will have changed the HostControllerFunctionalState to the USBRESUME state)
|
||||
// and OwnershipChange."
|
||||
|
@ -1534,8 +1534,7 @@ void OHCI::OHCI_ProcessLists(int completion)
|
|||
// Only process the control list if it is enabled (HcControl) and has available TD's (HcCommandStatus)
|
||||
if ((m_Registers.HcControl & OHCI_CTL_CLE) && (m_Registers.HcCommandStatus & OHCI_STATUS_CLF)) {
|
||||
if (m_Registers.HcControlCurrentED && m_Registers.HcControlCurrentED != m_Registers.HcControlHeadED) {
|
||||
DbgPrintf("%s head 0x%X, current 0x%X\n",
|
||||
LOG_STR_OHCI, m_Registers.HcControlHeadED, m_Registers.HcControlCurrentED);
|
||||
DbgPrintf(LOG_PREFIX, "head 0x%X, current 0x%X\n", m_Registers.HcControlHeadED, m_Registers.HcControlCurrentED);
|
||||
}
|
||||
if (!OHCI_ServiceEDlist(m_Registers.HcControlHeadED, completion)) {
|
||||
m_Registers.HcControlCurrentED = 0;
|
||||
|
@ -1575,7 +1574,7 @@ int OHCI::OHCI_ServiceIsoTD(OHCI_ED* ed, int completion)
|
|||
addr = ed->HeadP & OHCI_DPTR_MASK;
|
||||
|
||||
if (OHCI_ReadIsoTD(addr, &iso_td)) {
|
||||
DbgPrintf("%s ISO_TD read error at physical address 0x%X\n", LOG_STR_OHCI, addr);
|
||||
DbgPrintf(LOG_PREFIX, "ISO_TD read error at physical address 0x%X\n", addr);
|
||||
OHCI_FatalError();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1606,13 +1605,13 @@ int OHCI::OHCI_ServiceIsoTD(OHCI_ED* ed, int completion)
|
|||
if (relative_frame_number < 0) {
|
||||
// From the standard: "If the relative frame number is negative, then the current frame is earlier than the 0th frame
|
||||
// of the Isochronous TD and the Host Controller advances to the next ED."
|
||||
DbgPrintf("%s ISO_TD R=%d < 0\n", LOG_STR_OHCI, relative_frame_number);
|
||||
DbgPrintf(LOG_PREFIX, "ISO_TD R=%d < 0\n", relative_frame_number);
|
||||
return 1;
|
||||
}
|
||||
else if (relative_frame_number > frame_count) {
|
||||
// From the standard: "If the relative frame number is greater than
|
||||
// FrameCount, then the Isochronous TD has expired and a error condition exists."
|
||||
DbgPrintf("%s ISO_TD R=%d > FC=%d\n", LOG_STR_OHCI, relative_frame_number, frame_count);
|
||||
DbgPrintf(LOG_PREFIX, "ISO_TD R=%d > FC=%d\n", relative_frame_number, frame_count);
|
||||
OHCI_SET_BM(iso_td.Flags, TD_CC, OHCI_CC_DATAOVERRUN);
|
||||
ed->HeadP &= ~OHCI_DPTR_MASK;
|
||||
ed->HeadP |= (iso_td.NextTD & OHCI_DPTR_MASK);
|
||||
|
@ -1653,12 +1652,12 @@ int OHCI::OHCI_ServiceIsoTD(OHCI_ED* ed, int completion)
|
|||
pid = USB_TOKEN_SETUP;
|
||||
break;
|
||||
default:
|
||||
EmuWarning("%s Bad direction %d", LOG_STR_OHCI, dir);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Bad direction %d", dir);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!iso_td.BufferPage0 || !iso_td.BufferEnd) {
|
||||
DbgPrintf("%s ISO_TD bp 0x%.8X be 0x%.8X\n", LOG_STR_OHCI, iso_td.BufferPage0, iso_td.BufferEnd);
|
||||
DbgPrintf(LOG_PREFIX, "ISO_TD bp 0x%.8X be 0x%.8X\n", iso_td.BufferPage0, iso_td.BufferEnd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1676,12 +1675,12 @@ int OHCI::OHCI_ServiceIsoTD(OHCI_ED* ed, int completion)
|
|||
if (!(OHCI_BM(start_offset, TD_PSW_CC) & 0xE) ||
|
||||
((relative_frame_number < frame_count) &&
|
||||
!(OHCI_BM(next_offset, TD_PSW_CC) & 0xE))) {
|
||||
DbgPrintf("%s ISO_TD cc != not accessed 0x%.8x 0x%.8x\n", LOG_STR_OHCI, start_offset, next_offset);
|
||||
DbgPrintf(LOG_PREFIX, "ISO_TD cc != not accessed 0x%.8x 0x%.8x\n", start_offset, next_offset);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((relative_frame_number < frame_count) && (start_offset > next_offset)) {
|
||||
printf("%s ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\n", LOG_STR_OHCI, start_offset, next_offset);
|
||||
printf("%s ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\n", start_offset, next_offset);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1779,12 +1778,12 @@ int OHCI::OHCI_ServiceIsoTD(OHCI_ED* ed, int completion)
|
|||
else {
|
||||
// Handle the error condition
|
||||
if (ret > static_cast<ptrdiff_t>(len)) { // Sequence Error
|
||||
DbgPrintf("%s DataOverrun %d > %zu\n", LOG_STR_OHCI, ret, len);
|
||||
DbgPrintf(LOG_PREFIX, "DataOverrun %d > %zu\n", ret, len);
|
||||
OHCI_SET_BM(iso_td.Offset[relative_frame_number], TD_PSW_CC, OHCI_CC_DATAOVERRUN);
|
||||
OHCI_SET_BM(iso_td.Offset[relative_frame_number], TD_PSW_SIZE, len);
|
||||
}
|
||||
else if (ret >= 0) { // Sequence Error
|
||||
DbgPrintf("%s DataUnderrun %d\n", LOG_STR_OHCI, ret);
|
||||
DbgPrintf(LOG_PREFIX, "DataUnderrun %d\n", ret);
|
||||
OHCI_SET_BM(iso_td.Offset[relative_frame_number], TD_PSW_CC, OHCI_CC_DATAUNDERRUN);
|
||||
}
|
||||
else {
|
||||
|
@ -1796,12 +1795,12 @@ int OHCI::OHCI_ServiceIsoTD(OHCI_ED* ed, int completion)
|
|||
break;
|
||||
case USB_RET_NAK: // NAK and STALL
|
||||
case USB_RET_STALL:
|
||||
DbgPrintf("%s got NAK/STALL %d\n", LOG_STR_OHCI, ret);
|
||||
DbgPrintf(LOG_PREFIX, "got NAK/STALL %d\n", ret);
|
||||
OHCI_SET_BM(iso_td.Offset[relative_frame_number], TD_PSW_CC, OHCI_CC_STALL);
|
||||
OHCI_SET_BM(iso_td.Offset[relative_frame_number], TD_PSW_SIZE, 0);
|
||||
break;
|
||||
default: // Unknown Error
|
||||
DbgPrintf("%s Bad device response %d\n", LOG_STR_OHCI, ret);
|
||||
DbgPrintf(LOG_PREFIX, "Bad device response %d\n", ret);
|
||||
OHCI_SET_BM(iso_td.Offset[relative_frame_number], TD_PSW_CC, OHCI_CC_UNDEXPETEDPID);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::USB
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
@ -48,8 +50,6 @@ namespace xboxkrnl
|
|||
#include "CxbxCommon.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::USB
|
||||
|
||||
#define SETUP_STATE_IDLE 0
|
||||
#define SETUP_STATE_SETUP 1
|
||||
#define SETUP_STATE_DATA 2
|
||||
|
@ -283,7 +283,7 @@ void USBDevice::USB_PacketCheckState(USBPacket* p, USBPacketState expected)
|
|||
return;
|
||||
}
|
||||
|
||||
EmuWarning("%s: packet state check failed!", LOG_STR_USB);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "packet state check failed!");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ void USBDevice::USB_DoParameter(XboxDeviceState* s, USBPacket* p)
|
|||
index = (s->SetupBuffer[5] << 8) | s->SetupBuffer[4];
|
||||
|
||||
if (s->SetupLength > sizeof(s->DataBuffer)) {
|
||||
DbgPrintf("%s: ctrl buffer too small (%d > %zu)\n", LOG_STR_USB, s->SetupLength, sizeof(s->DataBuffer));
|
||||
DbgPrintf(LOG_PREFIX, "ctrl buffer too small (%d > %zu)\n", s->SetupLength, sizeof(s->DataBuffer));
|
||||
p->Status = USB_RET_STALL;
|
||||
return;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ void USBDevice::USB_DoTokenSetup(XboxDeviceState* s, USBPacket* p)
|
|||
}
|
||||
else {
|
||||
if (s->SetupLength > sizeof(s->DataBuffer)) {
|
||||
DbgPrintf("%s: ctrl buffer too small (%d > %zu)\n", LOG_STR_USB, s->SetupLength, sizeof(s->DataBuffer));
|
||||
DbgPrintf(LOG_PREFIX, "ctrl buffer too small (%d > %zu)\n", s->SetupLength, sizeof(s->DataBuffer));
|
||||
p->Status = USB_RET_STALL;
|
||||
return;
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ void USBDevice::USB_PacketCopy(USBPacket* p, void* ptr, size_t bytes)
|
|||
IoVecFromBuffer(iov->IoVecStruct, iov->IoVecNumber, p->ActualLength, ptr, bytes);
|
||||
break;
|
||||
default:
|
||||
CxbxKrnlCleanup("%s: %s has an invalid pid: %x\n", LOG_STR_USB, __func__, p->Pid);
|
||||
CxbxKrnlCleanup(LOG_PREFIX, "%s has an invalid pid: %x\n", __func__, p->Pid);
|
||||
}
|
||||
p->ActualLength += bytes;
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ void USBDevice::USBDesc_SetDefaults(XboxDeviceState* dev)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
EmuWarning("%s: unknown speed parameter %d set in %s", LOG_STR_USB, dev->ProductDesc.c_str());
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "unknown speed parameter %d set in %s", dev->Speed, dev->ProductDesc.c_str());
|
||||
}
|
||||
USBDesc_SetConfig(dev, 0);
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ int USBDevice::USBDesc_HandleControl(XboxDeviceState* dev, USBPacket *p,
|
|||
// From the standard: "This request sets the device address for all future device accesses.
|
||||
// The wValue field specifies the device address to use for all subsequent accesses"
|
||||
dev->Addr = value;
|
||||
DbgPrintf("%s: address 0x%X set for device %s\n", LOG_STR_USB, dev->Addr, dev->ProductDesc.c_str());
|
||||
DbgPrintf(LOG_PREFIX, "address 0x%X set for device %s\n", dev->Addr, dev->ProductDesc.c_str());
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -925,8 +925,8 @@ int USBDevice::USBDesc_HandleControl(XboxDeviceState* dev, USBPacket *p,
|
|||
// From the standard: "This request sets the device configuration. The lower byte of the wValue field specifies the desired configuration.
|
||||
// This configuration value must be zero or match a configuration value from a configuration descriptor"
|
||||
ret = USBDesc_SetConfig(dev, value);
|
||||
DbgPrintf("%s: received standard SetConfiguration() request for device at address 0x%X. Configuration selected is %d and returned %d\n",
|
||||
LOG_STR_USB, dev->Addr, value, ret);
|
||||
DbgPrintf(LOG_PREFIX, "received standard SetConfiguration() request for device at address 0x%X. Configuration selected is %d and returned %d\n",
|
||||
dev->Addr, value, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -959,8 +959,8 @@ int USBDevice::USBDesc_HandleControl(XboxDeviceState* dev, USBPacket *p,
|
|||
dev->RemoteWakeup = 0;
|
||||
ret = 0;
|
||||
}
|
||||
DbgPrintf("%s: received standard ClearFeature() request for device at address 0x%X. Feature selected is %d and returned %d\n",
|
||||
LOG_STR_USB, dev->Addr, value, ret);
|
||||
DbgPrintf(LOG_PREFIX, "received standard ClearFeature() request for device at address 0x%X. Feature selected is %d and returned %d\n",
|
||||
dev->Addr, value, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -971,8 +971,8 @@ int USBDevice::USBDesc_HandleControl(XboxDeviceState* dev, USBPacket *p,
|
|||
dev->RemoteWakeup = 1;
|
||||
ret = 0;
|
||||
}
|
||||
DbgPrintf("%s: received standard SetFeature() request for device at address 0x%X. Feature selected is %d and returned %d\n",
|
||||
LOG_STR_USB, dev->Addr, value, ret);
|
||||
DbgPrintf(LOG_PREFIX, "received standard SetFeature() request for device at address 0x%X. Feature selected is %d and returned %d\n",
|
||||
dev->Addr, value, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -992,8 +992,8 @@ int USBDevice::USBDesc_HandleControl(XboxDeviceState* dev, USBPacket *p,
|
|||
// From the standard: "This request allows the host to select an alternate setting for the specified interface"
|
||||
// wValue = Alternative Setting; wIndex = Interface
|
||||
ret = USBDesc_SetInterface(dev, index, value);
|
||||
DbgPrintf("%s: received standard SetInterface() request for device at address 0x%X. Interface selected is %d, Alternative Setting \
|
||||
is %d and returned %d\n", LOG_STR_USB, dev->Addr, index, value, ret);
|
||||
DbgPrintf(LOG_PREFIX, "received standard SetInterface() request for device at address 0x%X. Interface selected is %d, Alternative Setting \
|
||||
is %d and returned %d\n", dev->Addr, index, value, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ int USBDevice::USBDesc_HandleStandardGetDescriptor(XboxDeviceState* dev, USBPack
|
|||
switch (type) {
|
||||
case USB_DT_DEVICE: {
|
||||
ret = USB_ReadDeviceDesc(&desc->id, dev->Device, buf, sizeof(buf));
|
||||
DbgPrintf("%s: read operation of device descriptor of device 0x%X returns %d\n", LOG_STR_USB, dev->Addr, ret);
|
||||
DbgPrintf(LOG_PREFIX, "read operation of device descriptor of device 0x%X returns %d\n", dev->Addr, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1028,13 +1028,13 @@ int USBDevice::USBDesc_HandleStandardGetDescriptor(XboxDeviceState* dev, USBPack
|
|||
if (index < dev->Device->bNumConfigurations) {
|
||||
ret = USB_ReadConfigurationDesc(dev->Device->confs + index, flags, buf, sizeof(buf));
|
||||
}
|
||||
DbgPrintf("%s: read operation of configuration descriptor %d of device 0x%X returns %d\n", LOG_STR_USB, index, dev->Addr, ret);
|
||||
DbgPrintf(LOG_PREFIX, "read operation of configuration descriptor %d of device 0x%X returns %d\n", index, dev->Addr, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
case USB_DT_STRING: {
|
||||
ret = USB_ReadStringDesc(dev, index, buf, sizeof(buf));
|
||||
DbgPrintf("%s: read operation of string descriptor %d of device 0x%X returns %d\n", LOG_STR_USB, index, dev->Addr, ret);
|
||||
DbgPrintf(LOG_PREFIX, "read operation of string descriptor %d of device 0x%X returns %d\n", index, dev->Addr, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ int USBDevice::USBDesc_HandleStandardGetDescriptor(XboxDeviceState* dev, USBPack
|
|||
// USB_DT_BOS (15) and USB_DT_DEBUG (10) -> usb 3.0 only
|
||||
|
||||
default:
|
||||
EmuWarning("%s: %s has a device address %d of unknown type %d (len %zd)", LOG_STR_USB, __func__, dev->Addr, type, len);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "%s has a device address %d of unknown type %d (len %zd)", __func__, dev->Addr, type, len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::XIDCTRL
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
@ -48,9 +50,7 @@ namespace xboxkrnl
|
|||
#include "Common/Input/SDL2_Device.h"
|
||||
#include "OHCI.h"
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include "Logging.h"
|
||||
|
||||
#define LOG_PREFIX CXBXR_MODULE::XIDCTRL
|
||||
#include "Logging.h"
|
||||
|
||||
#define USB_CLASS_XID 0x58
|
||||
#define USB_DT_XID 0x42
|
||||
|
@ -263,7 +263,7 @@ int XidGamepad::UsbXidClaimPort(XboxDeviceState* dev, int port)
|
|||
i++;
|
||||
}
|
||||
if (it == m_UsbDev->m_FreePorts.end()) {
|
||||
EmuWarning("Port requested %d.2 not found (in use?)", port);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Port requested %d.2 not found (in use?)", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ void XidGamepad::UsbXid_Attach(XboxDeviceState* dev)
|
|||
|
||||
void XidGamepad::UsbXid_HandleReset()
|
||||
{
|
||||
DbgPrintf("%s reset event\n", LOG_STR_GAMEPAD);
|
||||
DbgPrintf(LOG_PREFIX, "reset event\n");
|
||||
}
|
||||
|
||||
void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
||||
|
@ -338,7 +338,7 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
{
|
||||
int ret = m_UsbDev->USBDesc_HandleControl(dev, p, request, value, index, length, data);
|
||||
if (ret >= 0) {
|
||||
DbgPrintf("%s handled by USBDesc_HandleControl, ret is %d\n", LOG_STR_GAMEPAD, ret);
|
||||
DbgPrintf(LOG_PREFIX, "handled by USBDesc_HandleControl, ret is %d\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
// From the HID standard: "The Get_Report request allows the host to receive a report via the Control pipe.
|
||||
// The wValue field specifies the Report Type in the high byte and the Report ID in the low byte. Set Report ID
|
||||
// to 0 (zero) if Report IDs are not used. 01 = input, 02 = output, 03 = feature, 04-FF = reserved"
|
||||
DbgPrintf("%s GET_REPORT 0x%X\n", LOG_STR_GAMEPAD, value);
|
||||
DbgPrintf(LOG_PREFIX, "GET_REPORT 0x%X\n", value);
|
||||
// JayFoxRox's analysis: "This 0x0100 case is for input.
|
||||
// This is the case where the Xbox wants to read input data from the controller.
|
||||
// Confirmed with a real Duke controller :
|
||||
|
@ -389,7 +389,7 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
// setting the state of input, output, or feature controls. The meaning of the request fields for the Set_Report
|
||||
// request is the same as for the Get_Report request, however the data direction is reversed and the Report
|
||||
// Data is sent from host to device."
|
||||
DbgPrintf("%s SET_REPORT 0x%X\n", LOG_STR_GAMEPAD, value);
|
||||
DbgPrintf(LOG_PREFIX, "SET_REPORT 0x%X\n", value);
|
||||
// JayFoxRox's analysis: "The 0x0200 case below is for output.
|
||||
// This is the case where the Xbox wants to write rumble data to the controller.
|
||||
// To my knowledge :
|
||||
|
@ -419,7 +419,7 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
|
||||
// XID-specific requests
|
||||
case VendorInterfaceRequest | USB_REQ_GET_DESCRIPTOR: {
|
||||
DbgPrintf("%s GET_DESCRIPTOR 0x%x\n", LOG_STR_GAMEPAD, value);
|
||||
DbgPrintf(LOG_PREFIX, "GET_DESCRIPTOR 0x%x\n", value);
|
||||
if (value == 0x4200) {
|
||||
assert(m_XidState->xid_desc->bLength <= length);
|
||||
std::memcpy(data, m_XidState->xid_desc, m_XidState->xid_desc->bLength);
|
||||
|
@ -433,7 +433,7 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
}
|
||||
|
||||
case VendorInterfaceRequest | XID_GET_CAPABILITIES: {
|
||||
DbgPrintf("%s XID_GET_CAPABILITIES 0x%x\n", LOG_STR_GAMEPAD, value);
|
||||
DbgPrintf(LOG_PREFIX, "XID_GET_CAPABILITIES 0x%x\n", value);
|
||||
if (value == 0x0100) {
|
||||
if (length > m_XidState->in_state_capabilities.bLength) {
|
||||
length = m_XidState->in_state_capabilities.bLength;
|
||||
|
@ -457,7 +457,7 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
|
||||
case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8) | USB_REQ_GET_DESCRIPTOR: {
|
||||
/* FIXME: ! */
|
||||
DbgPrintf("%s unknown xpad request 0x%X: value = 0x%X\n", LOG_STR_GAMEPAD, request, value);
|
||||
DbgPrintf(LOG_PREFIX, "unknown xpad request 0x%X: value = 0x%X\n", request, value);
|
||||
std::memset(data, 0x00, length);
|
||||
//FIXME: Intended for the hub: usbd_get_hub_descriptor, UT_READ_CLASS?!
|
||||
p->Status = USB_RET_STALL;
|
||||
|
@ -467,14 +467,14 @@ void XidGamepad::UsbXid_HandleControl(XboxDeviceState* dev, USBPacket* p,
|
|||
|
||||
case ((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT) << 8) | USB_REQ_CLEAR_FEATURE: {
|
||||
/* FIXME: ! */
|
||||
DbgPrintf("%s unknown xpad request 0x%X: value = 0x%X\n", LOG_STR_GAMEPAD, request, value);
|
||||
DbgPrintf(LOG_PREFIX, "unknown xpad request 0x%X: value = 0x%X\n", request, value);
|
||||
std::memset(data, 0x00, length);
|
||||
p->Status = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
DbgPrintf("%s USB stalled on request 0x%X value 0x%X\n", LOG_STR_GAMEPAD, request, value);
|
||||
DbgPrintf(LOG_PREFIX, "USB stalled on request 0x%X value 0x%X\n", request, value);
|
||||
p->Status = USB_RET_STALL;
|
||||
assert(0);
|
||||
break;
|
||||
|
@ -548,7 +548,7 @@ void XidGamepad::UpdateForceFeedback()
|
|||
// implementation is untested and could potentially contain errors
|
||||
|
||||
/* FIXME: Check actuator endianess */
|
||||
DbgPrintf("Set rumble power to left: 0x%X and right: 0x%X\n",
|
||||
DbgPrintf(LOG_PREFIX, "Set rumble power to left: 0x%X and right: 0x%X\n",
|
||||
m_XidState->out_state.left_actuator_strength,
|
||||
m_XidState->out_state.right_actuator_strength);
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ static void pgraph_handle_method(NV2AState *d,
|
|||
context_surfaces_2d->dest_offset = parameter & 0x07FFFFFF;
|
||||
break;
|
||||
default:
|
||||
EmuWarning("NV2A: Unknown NV_CONTEXT_SURFACES_2D Method: 0x%08X\n", method);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown NV_CONTEXT_SURFACES_2D Method: 0x%08X\n", method);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -730,7 +730,7 @@ static void pgraph_handle_method(NV2AState *d,
|
|||
|
||||
break;
|
||||
default:
|
||||
EmuWarning("NV2A: Unknown NV_IMAGE_BLIT Method: 0x%08X\n", method);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Unknown NV_IMAGE_BLIT Method: 0x%08X\n", method);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -93,14 +93,14 @@ DEVICE_WRITE32(PRMCIO)
|
|||
if (d->prmcio.cr_index == VGA_CRTC_OVERFLOW) {
|
||||
d->prmcio.cr[VGA_CRTC_OVERFLOW] = (d->prmcio.cr[VGA_CRTC_OVERFLOW] & ~0x10) |
|
||||
(value & 0x10);
|
||||
EmuWarning("TODO: vbe_update_vgaregs");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "TODO: vbe_update_vgaregs");
|
||||
//vbe_update_vgaregs();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
d->prmcio.cr[d->prmcio.cr_index] = value;
|
||||
EmuWarning("TODO: vbe_update_vgaregs");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "TODO: vbe_update_vgaregs");
|
||||
//vbe_update_vgaregs();
|
||||
|
||||
switch (d->prmcio.cr_index) {
|
||||
|
@ -112,7 +112,7 @@ DEVICE_WRITE32(PRMCIO)
|
|||
case VGA_CRTC_V_SYNC_END:
|
||||
case VGA_CRTC_MODE:
|
||||
// TODO: s->update_retrace_info(s);
|
||||
EmuWarning("TODO: update_retrace_info");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "TODO: update_retrace_info");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -164,11 +164,11 @@ static void update_irq(NV2AState *d)
|
|||
#include "EmuNV2A_DEBUG.cpp"
|
||||
|
||||
|
||||
#define DEBUG_READ32(DEV) DbgPrintf("X86 : Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Handled %s]\n", addr, result, DebugNV_##DEV##(addr))
|
||||
#define DEBUG_READ32_UNHANDLED(DEV) { DbgPrintf("X86 : Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Unhandled %s]\n", addr, result, DebugNV_##DEV##(addr)); return result; }
|
||||
#define DEBUG_READ32(DEV) DbgPrintf(CXBXR_MODULE::X86, "Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Handled %s]\n", addr, result, DebugNV_##DEV##(addr))
|
||||
#define DEBUG_READ32_UNHANDLED(DEV) { DbgPrintf(CXBXR_MODULE::X86, "Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Unhandled %s]\n", addr, result, DebugNV_##DEV##(addr)); return result; }
|
||||
|
||||
#define DEBUG_WRITE32(DEV) DbgPrintf("X86 : Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Handled %s]\n", addr, value, DebugNV_##DEV##(addr))
|
||||
#define DEBUG_WRITE32_UNHANDLED(DEV) { DbgPrintf("X86 : Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Unhandled %s]\n", addr, value, DebugNV_##DEV##(addr)); return; }
|
||||
#define DEBUG_WRITE32(DEV) DbgPrintf(CXBXR_MODULE::X86, "Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Handled %s]\n", addr, value, DebugNV_##DEV##(addr))
|
||||
#define DEBUG_WRITE32_UNHANDLED(DEV) { DbgPrintf(CXBXR_MODULE::X86, "Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Unhandled %s]\n", addr, value, DebugNV_##DEV##(addr)); return; }
|
||||
|
||||
#define DEVICE_READ32(DEV) uint32_t EmuNV2A_##DEV##_Read32(NV2AState *d, xbaddr addr)
|
||||
#define DEVICE_READ32_SWITCH() uint32_t result = 0; switch (addr)
|
||||
|
@ -987,7 +987,7 @@ void cxbx_gl_render_overlays(NV2AState *d)
|
|||
|
||||
// Detect some special cases, for later finetuning
|
||||
if (overlay_in_s != 0 || overlay_in_t != 0 || !overlay.covers_framebuffer) {
|
||||
LOG_TEST_CASE("Non-standard overlay dimensions");
|
||||
LOG_TEST_CASE(LOG_PREFIX, "Non-standard overlay dimensions");
|
||||
}
|
||||
|
||||
// Convert UV coordinates to [0.0, 1.0]
|
||||
|
@ -1153,7 +1153,7 @@ void CxbxReserveNV2AMemory(NV2AState *d)
|
|||
MEM_RESERVE, // Don't allocate actual physical storage in memory
|
||||
PAGE_NOACCESS); // Any access must result in an access violation exception (handled in EmuException/EmuX86_DecodeException)
|
||||
if (memory == NULL) {
|
||||
EmuWarning("Couldn't reserve NV2A memory, continuing assuming we'll receive (and handle) access violation exceptions anyway...");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Couldn't reserve NV2A memory, continuing assuming we'll receive (and handle) access violation exceptions anyway...");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ void CxbxReserveNV2AMemory(NV2AState *d)
|
|||
MEM_COMMIT, // No MEM_RESERVE |
|
||||
PAGE_READWRITE);
|
||||
if (d->pramin.ramin_ptr == NULL) {
|
||||
EmuWarning("Couldn't allocate NV2A PRAMIN memory");
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Couldn't allocate NV2A PRAMIN memory");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ uint32_t NV2ADevice::MMIORead(int barIndex, uint32_t addr, unsigned size)
|
|||
}
|
||||
}
|
||||
|
||||
EmuWarning("NV2ADevice::MMIORead: Unhandled barIndex %d, addr %08X, size %d", barIndex, addr, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NV2ADevice::MMIORead: Unhandled barIndex %d, addr %08X, size %d", barIndex, addr, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1370,5 +1370,5 @@ void NV2ADevice::MMIOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned
|
|||
}
|
||||
}
|
||||
|
||||
EmuWarning("NV2ADevice::MMIOWrite: Unhandled barIndex %d, addr %08X, value %08X, size %d", barIndex, addr, value, size);
|
||||
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "NV2ADevice::MMIOWrite: Unhandled barIndex %d, addr %08X, value %08X, size %d", barIndex, addr, value, size);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue