space changes, merge #defines, language fix, and code reorder/cleanup :P

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5614 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-06-05 01:38:22 +00:00
parent c98f8a96d2
commit 2e783d9769
42 changed files with 1870 additions and 1793 deletions

View file

@ -27,12 +27,7 @@
// Force enable logging in the right modes. For some reason, something had changed // Force enable logging in the right modes. For some reason, something had changed
// so that debugfast no longer logged. // so that debugfast no longer logged.
#ifdef _DEBUG #if defined(_DEBUG) || defined(DEBUGFAST)
#undef LOGGING
#define LOGGING 1
#endif
#ifdef DEBUGFAST
#undef LOGGING #undef LOGGING
#define LOGGING 1 #define LOGGING 1
#endif #endif
@ -137,7 +132,7 @@
// A macro to disallow the copy constructor and operator= functions // A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class // This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \ TypeName(const TypeName&); \
void operator=(const TypeName&) void operator=(const TypeName&)
#endif // _COMMON_H_ #endif // _COMMON_H_

View file

@ -38,10 +38,10 @@ public:
int Unload(); int Unload();
// Gets a pointer to the function symbol of funcname by getting it from the // Gets a pointer to the function symbol of funcname by getting it from the
// share object // shared object
void *Get(const char *funcname) const; void *Get(const char *funcname) const;
// Returns true is the library is loaded // Returns true if the library is loaded
bool IsLoaded() const { return library != 0; } bool IsLoaded() const { return library != 0; }
private: private:

View file

@ -61,7 +61,7 @@ CPlugin::CPlugin(const char* _szName) : valid(false)
m_EmuStateChange = reinterpret_cast<TEmuStateChange> m_EmuStateChange = reinterpret_cast<TEmuStateChange>
(m_hInstLib.Get("EmuStateChange")); (m_hInstLib.Get("EmuStateChange"));
// Check if the plugin has all the functions it shold have // Check if the plugin has all the functions it should have
if (m_GetDllInfo != 0 && if (m_GetDllInfo != 0 &&
m_DllConfig != 0 && m_DllConfig != 0 &&
m_DllDebugger != 0 && m_DllDebugger != 0 &&

View file

@ -24,14 +24,14 @@
namespace Common namespace Common
{ {
typedef void (__cdecl * TGetDllInfo)(PLUGIN_INFO*); typedef void (__cdecl * TGetDllInfo)(PLUGIN_INFO*);
typedef void (__cdecl * TDllConfig)(HWND); typedef void (__cdecl * TDllConfig)(HWND);
typedef void (__cdecl * TDllDebugger)(HWND, bool); typedef void (__cdecl * TDllDebugger)(HWND, bool);
typedef void (__cdecl * TSetDllGlobals)(PLUGIN_GLOBALS*); typedef void (__cdecl * TSetDllGlobals)(PLUGIN_GLOBALS*);
typedef void (__cdecl * TInitialize)(void *); typedef void (__cdecl * TInitialize)(void *);
typedef void (__cdecl * TShutdown)(); typedef void (__cdecl * TShutdown)();
typedef void (__cdecl * TDoState)(unsigned char**, int); typedef void (__cdecl * TDoState)(unsigned char**, int);
typedef void (__cdecl * TEmuStateChange)(PLUGIN_EMUSTATE); typedef void (__cdecl * TEmuStateChange)(PLUGIN_EMUSTATE);
class CPlugin class CPlugin
{ {

View file

@ -85,7 +85,7 @@ void SConfig::SaveSettings()
ini.Set("General", tmp, m_ISOFolder[i]); ini.Set("General", tmp, m_ISOFolder[i]);
} }
ini.Set("General", "RecersiveGCMPaths", m_RecursiveISOFolder); ini.Set("General", "RecursiveGCMPaths", m_RecursiveISOFolder);
// Interface // Interface
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop); ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
@ -209,7 +209,7 @@ void SConfig::LoadSettings()
} }
} }
ini.Get("General", "RecersiveGCMPaths", &m_RecursiveISOFolder, false); ini.Get("General", "RecursiveGCMPaths", &m_RecursiveISOFolder, false);
} }
{ {
@ -287,13 +287,13 @@ void SConfig::LoadSettings()
ini.Get("Core", sidevicenum, (u32*)&m_SIDevice[i], i==0 ? SI_GC_CONTROLLER:SI_NONE); ini.Get("Core", sidevicenum, (u32*)&m_SIDevice[i], i==0 ? SI_GC_CONTROLLER:SI_NONE);
} }
ini.Get("Core", "WiiSDCard", &m_WiiSDCard, false); ini.Get("Core", "WiiSDCard", &m_WiiSDCard, false);
ini.Get("Core", "WiiKeyboard", &m_WiiKeyboard, false); ini.Get("Core", "WiiKeyboard", &m_WiiKeyboard, false);
ini.Get("Core", "RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false); ini.Get("Core", "RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false);
ini.Get("Core", "RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false); ini.Get("Core", "RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false);
ini.Get("Core", "TLBHack", &m_LocalCoreStartupParameter.iTLBHack, 0); ini.Get("Core", "TLBHack", &m_LocalCoreStartupParameter.iTLBHack, 0);
ini.Get("Core", "FrameLimit", &m_Framelimit, 1); // auto frame limit by default ini.Get("Core", "FrameLimit", &m_Framelimit, 1); // auto frame limit by default
ini.Get("Core", "UseFPS", &b_UseFPS, false); // use vps as default ini.Get("Core", "UseFPS", &b_UseFPS, false); // use vps as default
// Plugins // Plugins
ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str()); ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str());

View file

@ -130,13 +130,13 @@ bool PanicAlertToVideo(const char* text, bool yes_no)
void DisplayMessage(const std::string &message, int time_in_ms) void DisplayMessage(const std::string &message, int time_in_ms)
{ {
CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message.c_str(), CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message.c_str(),
time_in_ms); time_in_ms);
} }
void DisplayMessage(const char *message, int time_in_ms) void DisplayMessage(const char *message, int time_in_ms)
{ {
CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message, CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message,
time_in_ms); time_in_ms);
} }
void Callback_DebuggerBreak() void Callback_DebuggerBreak()
@ -325,25 +325,25 @@ THREAD_RETURN EmuThread(void *pArg)
// Load the VideoPlugin // Load the VideoPlugin
SVideoInitialize VideoInitialize; SVideoInitialize VideoInitialize;
VideoInitialize.pGetMemoryPointer = Memory::GetPointer; VideoInitialize.pGetMemoryPointer = Memory::GetPointer;
VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt; VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt;
VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent; VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent;
VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe; VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe;
// This is first the m_Panel handle, then it is updated to have the new window handle // This is first the m_Panel handle, then it is updated to have the new window handle
VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow; VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow;
VideoInitialize.pLog = Callback_VideoLog; VideoInitialize.pLog = Callback_VideoLog;
VideoInitialize.pSysMessage = Host_SysMessage; VideoInitialize.pSysMessage = Host_SysMessage;
VideoInitialize.pRequestWindowSize = Callback_VideoRequestWindowSize; VideoInitialize.pRequestWindowSize = Callback_VideoRequestWindowSize;
VideoInitialize.pCopiedToXFB = Callback_VideoCopiedToXFB; VideoInitialize.pCopiedToXFB = Callback_VideoCopiedToXFB;
VideoInitialize.pPeekMessages = NULL; VideoInitialize.pPeekMessages = NULL;
VideoInitialize.pUpdateFPSDisplay = NULL; VideoInitialize.pUpdateFPSDisplay = NULL;
VideoInitialize.pMemoryBase = Memory::base; VideoInitialize.pMemoryBase = Memory::base;
VideoInitialize.pCoreMessage = Callback_CoreMessage; VideoInitialize.pCoreMessage = Callback_CoreMessage;
VideoInitialize.bWii = _CoreParameter.bWii; VideoInitialize.bWii = _CoreParameter.bWii;
VideoInitialize.bOnThread = _CoreParameter.bCPUThread; VideoInitialize.bOnThread = _CoreParameter.bCPUThread;
VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase; VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase;
VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd; VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd;
VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer; VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer;
bool aspectWide = _CoreParameter.bWii; bool aspectWide = _CoreParameter.bWii;
if (aspectWide) if (aspectWide)
{ {
@ -351,7 +351,7 @@ THREAD_RETURN EmuThread(void *pArg)
gameIni.Load(_CoreParameter.m_strGameIni.c_str()); gameIni.Load(_CoreParameter.m_strGameIni.c_str());
gameIni.Get("Wii", "Widescreen", &aspectWide, !!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR")); gameIni.Get("Wii", "Widescreen", &aspectWide, !!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR"));
} }
VideoInitialize.bAutoAspectIs16_9 = aspectWide; VideoInitialize.bAutoAspectIs16_9 = aspectWide;
Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll

View file

@ -194,7 +194,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
m_BootType = BOOT_DOL; m_BootType = BOOT_DOL;
bNTSC = true; bNTSC = true;
} }
else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid()) else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
{ {
const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str()); const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str());
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename); const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);

View file

@ -37,7 +37,7 @@ enum Hotkey {
struct SCoreStartupParameter struct SCoreStartupParameter
{ {
void * hInstance; // HINSTANCE but we don't want to include <windows.h> void* hInstance; // HINSTANCE but we don't want to include <windows.h>
// Windows/GUI related // Windows/GUI related
void* hMainWindow; void* hMainWindow;
@ -93,10 +93,10 @@ struct SCoreStartupParameter
int iHotkeyModifier[NUM_HOTKEYS]; int iHotkeyModifier[NUM_HOTKEYS];
// Display settings // Display settings
bool bFullscreen, bRenderToMain;
std::string strFullscreenResolution; std::string strFullscreenResolution;
int iRenderWindowXPos, iRenderWindowYPos; int iRenderWindowXPos, iRenderWindowYPos;
int iRenderWindowWidth, iRenderWindowHeight; int iRenderWindowWidth, iRenderWindowHeight;
bool bFullscreen, bRenderToMain;
int iTheme; int iTheme;
int iPosX, iPosY, iWidth, iHeight; int iPosX, iPosY, iWidth, iHeight;

View file

@ -27,7 +27,7 @@
#include "../Core.h" #include "../Core.h"
CWII_IPC_HLE_Device_sdio_slot0::CWII_IPC_HLE_Device_sdio_slot0(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_sdio_slot0::CWII_IPC_HLE_Device_sdio_slot0(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
, m_Status(CARD_NOT_EXIST) , m_Status(CARD_NOT_EXIST)
, m_BlockLength(0) , m_BlockLength(0)
, m_BusWidth(0) , m_BusWidth(0)
@ -64,9 +64,9 @@ bool CWII_IPC_HLE_Device_sdio_slot0::Open(u32 _CommandAddress, u32 _Mode)
} }
} }
Memory::Write_U32(GetDeviceID(), _CommandAddress + 0x4); Memory::Write_U32(GetDeviceID(), _CommandAddress + 0x4);
m_Active = true; m_Active = true;
return true; return true;
} }
bool CWII_IPC_HLE_Device_sdio_slot0::Close(u32 _CommandAddress, bool _bForce) bool CWII_IPC_HLE_Device_sdio_slot0::Close(u32 _CommandAddress, bool _bForce)
@ -82,9 +82,9 @@ bool CWII_IPC_HLE_Device_sdio_slot0::Close(u32 _CommandAddress, bool _bForce)
m_BusWidth = 0; m_BusWidth = 0;
if (!_bForce) if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 0x4); Memory::Write_U32(0, _CommandAddress + 0x4);
m_Active = false; m_Active = false;
return true; return true;
} }
// The front SD slot // The front SD slot
@ -94,8 +94,8 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress)
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
// As a safety precaution we fill the out buffer with zeros to avoid // As a safety precaution we fill the out buffer with zeros to avoid
// returning nonsense values // returning nonsense values
@ -230,7 +230,7 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(u32 _CommandAddress)
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
return true; return true;
} }
u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize,
@ -251,13 +251,13 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS
u32 pad0; u32 pad0;
} req; } req;
req.command = Memory::Read_U32(_BufferIn + 0); req.command = Memory::Read_U32(_BufferIn + 0);
req.type = Memory::Read_U32(_BufferIn + 4); req.type = Memory::Read_U32(_BufferIn + 4);
req.resp = Memory::Read_U32(_BufferIn + 8); req.resp = Memory::Read_U32(_BufferIn + 8);
req.arg = Memory::Read_U32(_BufferIn + 12); req.arg = Memory::Read_U32(_BufferIn + 12);
req.blocks = Memory::Read_U32(_BufferIn + 16); req.blocks = Memory::Read_U32(_BufferIn + 16);
req.bsize = Memory::Read_U32(_BufferIn + 20); req.bsize = Memory::Read_U32(_BufferIn + 20);
req.addr = Memory::Read_U32(_BufferIn + 24); req.addr = Memory::Read_U32(_BufferIn + 24);
req.isDMA = Memory::Read_U32(_BufferIn + 28); req.isDMA = Memory::Read_U32(_BufferIn + 28);
req.pad0 = Memory::Read_U32(_BufferIn + 32); req.pad0 = Memory::Read_U32(_BufferIn + 32);
@ -431,5 +431,5 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS
break; break;
} }
return rwFail; return rwFail;
} }

View file

@ -46,7 +46,8 @@ bool g_bPolled = false;
int g_numRerecords = 0; int g_numRerecords = 0;
std::string g_recordFile; std::string g_recordFile;
void FrameUpdate() { void FrameUpdate()
{
g_frameCounter++; g_frameCounter++;
if(!g_bPolled) if(!g_bPolled)
@ -80,7 +81,8 @@ void FrameUpdate() {
g_bPolled = false; g_bPolled = false;
} }
void SetFrameSkipping(unsigned int framesToSkip) { void SetFrameSkipping(unsigned int framesToSkip)
{
cs_frameSkip.Enter(); cs_frameSkip.Enter();
g_framesToSkip = framesToSkip; g_framesToSkip = framesToSkip;
@ -94,11 +96,13 @@ void SetFrameSkipping(unsigned int framesToSkip) {
cs_frameSkip.Leave(); cs_frameSkip.Leave();
} }
int FrameSkippingFactor() { int FrameSkippingFactor()
{
return g_framesToSkip; return g_framesToSkip;
} }
void SetPolledDevice() { void SetPolledDevice()
{
g_bPolled = true; g_bPolled = true;
} }
@ -123,11 +127,13 @@ void SetAutoFire(bool bEnabled, u32 keyOne, u32 keyTwo)
g_bFirstKey = true; g_bFirstKey = true;
} }
bool IsAutoFiring() { bool IsAutoFiring()
{
return g_bAutoFire; return g_bAutoFire;
} }
void SetFrameStepping(bool bEnabled) { void SetFrameStepping(bool bEnabled)
{
g_bFrameStep = bEnabled; g_bFrameStep = bEnabled;
} }
void SetFrameStopping(bool bEnabled) { void SetFrameStopping(bool bEnabled) {
@ -164,7 +170,6 @@ void ModifyController(SPADStatus *PadStatus, int controllerID)
PadStatus->triggerRight = 255; PadStatus->triggerRight = 255;
break; break;
} }
} }
void FrameSkipping() void FrameSkipping()
@ -233,19 +238,19 @@ void EndRecordingInput()
header.filetype[0] = 'D'; header.filetype[1] = 'T'; header.filetype[2] = 'M'; header.filetype[3] = 0x1A; header.filetype[0] = 'D'; header.filetype[1] = 'T'; header.filetype[2] = 'M'; header.filetype[3] = 0x1A;
strncpy((char *)header.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str(), 6); strncpy((char *)header.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str(), 6);
header.bWii = Core::g_CoreStartupParameter.bWii; header.bWii = Core::g_CoreStartupParameter.bWii;
header.numControllers = g_numPads; header.numControllers = g_numPads;
header.bFromSaveState = false; // TODO: add the case where it's true header.bFromSaveState = false; // TODO: add the case where it's true
header.frameCount = g_frameCounter; header.frameCount = g_frameCounter;
header.lagCount = g_lagCounter; header.lagCount = g_lagCounter;
// TODO // TODO
header.uniqueID = 0; header.uniqueID = 0;
header.numRerecords = 0; header.numRerecords = 0;
// header.author; // header.author;
// header.videoPlugin; // header.videoPlugin;
// header.audioPlugin; // header.audioPlugin;
// header.padPlugin; // header.padPlugin;
fwrite(&header, sizeof(DTMHeader), 1, g_recordfd); fwrite(&header, sizeof(DTMHeader), 1, g_recordfd);
@ -262,14 +267,14 @@ void RecordInput(SPADStatus *PadStatus, int controllerID)
if(!IsRecordingInput() || controllerID >= g_numPads || controllerID < 0) if(!IsRecordingInput() || controllerID >= g_numPads || controllerID < 0)
return; return;
g_padStates[controllerID].A = ((PadStatus->button & PAD_BUTTON_A) != 0); g_padStates[controllerID].A = ((PadStatus->button & PAD_BUTTON_A) != 0);
g_padStates[controllerID].B = ((PadStatus->button & PAD_BUTTON_B) != 0); g_padStates[controllerID].B = ((PadStatus->button & PAD_BUTTON_B) != 0);
g_padStates[controllerID].X = ((PadStatus->button & PAD_BUTTON_X) != 0); g_padStates[controllerID].X = ((PadStatus->button & PAD_BUTTON_X) != 0);
g_padStates[controllerID].Y = ((PadStatus->button & PAD_BUTTON_Y) != 0); g_padStates[controllerID].Y = ((PadStatus->button & PAD_BUTTON_Y) != 0);
g_padStates[controllerID].Z = ((PadStatus->button & PAD_TRIGGER_Z) != 0); g_padStates[controllerID].Z = ((PadStatus->button & PAD_TRIGGER_Z) != 0);
g_padStates[controllerID].Start = ((PadStatus->button & PAD_BUTTON_START) != 0); g_padStates[controllerID].Start = ((PadStatus->button & PAD_BUTTON_START) != 0);
g_padStates[controllerID].DPadUp = ((PadStatus->button & PAD_BUTTON_UP) != 0); g_padStates[controllerID].DPadUp = ((PadStatus->button & PAD_BUTTON_UP) != 0);
g_padStates[controllerID].DPadDown = ((PadStatus->button & PAD_BUTTON_DOWN) != 0); g_padStates[controllerID].DPadDown = ((PadStatus->button & PAD_BUTTON_DOWN) != 0);
g_padStates[controllerID].DPadLeft = ((PadStatus->button & PAD_BUTTON_LEFT) != 0); g_padStates[controllerID].DPadLeft = ((PadStatus->button & PAD_BUTTON_LEFT) != 0);
g_padStates[controllerID].DPadRight = ((PadStatus->button & PAD_BUTTON_RIGHT) != 0); g_padStates[controllerID].DPadRight = ((PadStatus->button & PAD_BUTTON_RIGHT) != 0);

View file

@ -108,8 +108,6 @@ CPluginManager::~CPluginManager()
} }
// Init and Shutdown Plugins // Init and Shutdown Plugins
// ------------ // ------------
// Function: Point the m_pad[] and other variables to a certain plugin // Function: Point the m_pad[] and other variables to a certain plugin
@ -122,10 +120,6 @@ bool CPluginManager::InitPlugins()
} }
strcpy(m_PluginGlobals->game_ini, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); strcpy(m_PluginGlobals->game_ini, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str());
strcpy(m_PluginGlobals->unique_id, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str()); strcpy(m_PluginGlobals->unique_id, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str());
if (!GetDSP()) {
PanicAlert("Can't init DSP Plugin");
return false;
}
INFO_LOG(CONSOLE, "Before GetVideo\n"); INFO_LOG(CONSOLE, "Before GetVideo\n");
if (!GetVideo()) { if (!GetVideo()) {
@ -134,6 +128,10 @@ bool CPluginManager::InitPlugins()
} }
INFO_LOG(CONSOLE, "After GetVideo\n"); INFO_LOG(CONSOLE, "After GetVideo\n");
if (!GetDSP()) {
PanicAlert("Can't init DSP Plugin");
return false;
}
// Check if we get at least one pad or wiimote // Check if we get at least one pad or wiimote
bool pad = false; bool pad = false;
bool wiimote = false; bool wiimote = false;
@ -379,8 +377,6 @@ void CPluginManager::ScanForPlugins()
} }
/* Create or return the already created plugin pointers. This will be called /* Create or return the already created plugin pointers. This will be called
often for the Pad and Wiimote from the SI_.cpp files. And often for the DSP often for the Pad and Wiimote from the SI_.cpp files. And often for the DSP
from the DSP files. from the DSP files.
@ -442,7 +438,7 @@ Common::PluginVideo *CPluginManager::GetVideo()
// Check if the video plugin has been changed // Check if the video plugin has been changed
if (m_video->GetFilename() == m_params->m_strVideoPlugin) if (m_video->GetFilename() == m_params->m_strVideoPlugin)
return m_video; return m_video;
// Then free the current video plugin, // Then free the current video plugin
else else
FreeVideo(); FreeVideo();
} }

View file

@ -75,10 +75,10 @@ private:
CPluginInfos m_PluginInfos; CPluginInfos m_PluginInfos;
PLUGIN_GLOBALS *m_PluginGlobals; PLUGIN_GLOBALS *m_PluginGlobals;
Common::PluginPAD *m_pad[4];
Common::PluginVideo *m_video; Common::PluginVideo *m_video;
Common::PluginWiimote *m_wiimote[4];
Common::PluginDSP *m_dsp; Common::PluginDSP *m_dsp;
Common::PluginPAD *m_pad[4];
Common::PluginWiimote *m_wiimote[4];
SCoreStartupParameter * m_params; SCoreStartupParameter * m_params;
CPluginManager(); CPluginManager();

File diff suppressed because it is too large Load diff

View file

@ -39,7 +39,7 @@ public:
long style = wxDEFAULT_DIALOG_STYLE); long style = wxDEFAULT_DIALOG_STYLE);
virtual ~CConfigMain(); virtual ~CConfigMain();
void OnClick(wxMouseEvent& event); void OnOk(wxCommandEvent& event);
void CloseClick(wxCommandEvent& event); void CloseClick(wxCommandEvent& event);
void OnSelectionChanged(wxCommandEvent& event); void OnSelectionChanged(wxCommandEvent& event);
void OnConfig(wxCommandEvent& event); void OnConfig(wxCommandEvent& event);
@ -47,119 +47,131 @@ public:
bool bRefreshList; bool bRefreshList;
private: private:
wxNotebook* Notebook;
DECLARE_EVENT_TABLE(); wxPanel* GeneralPage;
wxPanel* GamecubePage;
wxPanel* DisplayPage;
wxPanel* WiiPage;
wxPanel* PathsPage;
wxPanel* PluginsPage;
wxBoxSizer* sGeneralPage; // General Settings wxBoxSizer* sGeneralPage; // General Settings
wxCheckBox* ConfirmStop, *UsePanicHandlers, *UseFPSForLimiting; wxStaticBoxSizer* sbBasic, *sbAdvanced; // Basic and Advanced sections
wxChoice* InterfaceLang;
wxChoice* Framelimit;
wxRadioBox* Theme;
wxStaticBoxSizer* sbBasic, *sbAdvanced, *sbInterface, *sbDisplay; // Basic
wxCheckBox* AlwaysHLE_BS2;
wxRadioButton* m_RadioInt;
wxRadioButton* m_RadioJIT;
wxRadioButton* m_RadioJITIL;
wxCheckBox* CPUThread; wxCheckBox* CPUThread;
wxCheckBox* DSPThread;
wxCheckBox* LockThreads;
wxCheckBox* SkipIdle; wxCheckBox* SkipIdle;
wxCheckBox* EnableCheats; wxCheckBox* EnableCheats;
wxChoice* Framelimit;
wxCheckBox* UseFPSForLimiting;
// Display settings // Advanced
wxBoxSizer* sDisplayPage; wxCheckBox* AlwaysHLE_BS2;
wxCheckBox* HideCursor; wxRadioBox* CPUEngine;
wxCheckBox* Fullscreen; wxCheckBox* DSPThread;
wxCheckBox* LockThreads;
wxBoxSizer* sDisplayPage; // Display settings
wxStaticBoxSizer* sbDisplay, *sbInterface; // Display and Interface sections
// Display
wxChoice* FullscreenResolution; wxChoice* FullscreenResolution;
wxSpinCtrl *WindowWidth; wxSpinCtrl* WindowWidth, *WindowHeight;
wxSpinCtrl *WindowHeight; wxCheckBox* Fullscreen;
wxCheckBox* HideCursor;
wxCheckBox* RenderToMain; wxCheckBox* RenderToMain;
// Interface
wxCheckBox* ConfirmStop;
wxCheckBox* UsePanicHandlers;
wxRadioBox* Theme;
wxChoice* InterfaceLang;
wxButton* HotkeyConfig; wxButton* HotkeyConfig;
wxBoxSizer* sGamecube; // GC settings
wxBoxSizer* sGamecubePage; // GC settings
wxStaticBoxSizer* sbGamecubeIPLSettings; wxStaticBoxSizer* sbGamecubeIPLSettings;
wxGridBagSizer* sGamecubeIPLSettings; wxGridBagSizer* sGamecubeIPLSettings;
wxStaticText* GCSystemLangText;
// IPL
wxChoice* GCSystemLang; wxChoice* GCSystemLang;
wxChoice *GCEXIDevice[3];
wxButton *GCMemcardPath[2];
wxChoice *GCSIDevice[4];
wxBoxSizer* sWii; // Wii settings // Device
wxStaticBoxSizer* sbWiimoteSettings; wxChoice* GCEXIDevice[3];
wxGridBagSizer* sWiimoteSettings; wxButton* GCMemcardPath[2];
wxStaticBoxSizer* sbWiiIPLSettings; wxChoice* GCSIDevice[4];
wxGridBagSizer* sWiiIPLSettings;
wxStaticBoxSizer* sbWiiDeviceSettings;
wxBoxSizer* sPaths;
wxStaticBoxSizer* sbISOPaths;
wxBoxSizer* sISOButtons;
wxGridBagSizer* sOtherPaths;
wxBoxSizer* sPlugins;
wxStaticBoxSizer* sbGraphicsPlugin;
wxStaticBoxSizer* sbDSPPlugin;
wxStaticBoxSizer* sbPadPlugin;
wxStaticBoxSizer* sbWiimotePlugin;
wxNotebook *Notebook;
wxPanel *GeneralPage;
wxPanel *DisplayPage;
wxPanel *GamecubePage;
wxPanel *WiiPage;
wxPanel *PathsPage;
wxPanel *PluginPage;
wxButton* m_Close; wxBoxSizer* sWiiPage; // Wii settings
wxStaticBoxSizer* sbWiimoteSettings, *sbWiiIPLSettings, *sbWiiDeviceSettings; // Wiimote, Misc and Device sections
wxGridBagSizer* sWiimoteSettings, *sWiiIPLSettings;
FILE* pStream; // Wiimote
wxStaticText* WiiSensBarPosText;
wxChoice* WiiSensBarPos; wxChoice* WiiSensBarPos;
wxCheckBox* WiiScreenSaver; // IPL settings // Misc
wxCheckBox* WiiScreenSaver;
wxCheckBox* WiiProgressiveScan; wxCheckBox* WiiProgressiveScan;
wxCheckBox* WiiEuRGB60; wxCheckBox* WiiEuRGB60;
wxStaticText* WiiAspectRatioText;
wxChoice* WiiAspectRatio; wxChoice* WiiAspectRatio;
wxStaticText* WiiSystemLangText;
wxChoice* WiiSystemLang; wxChoice* WiiSystemLang;
// Device
wxCheckBox* WiiSDCard; wxCheckBox* WiiSDCard;
wxCheckBox* WiiKeyboard; wxCheckBox* WiiKeyboard;
wxBoxSizer* sPathsPage; // Paths settings
wxStaticBoxSizer* sbISOPaths;
wxGridBagSizer* sOtherPaths;
// ISO Directories
wxListBox* ISOPaths; wxListBox* ISOPaths;
wxCheckBox* RecursiveISOPath;
wxButton* AddISOPath; wxButton* AddISOPath;
wxButton* RemoveISOPath; wxButton* RemoveISOPath;
wxCheckBox* RecersiveISOPath;
wxStaticText* DefaultISOText; // DefaultISO, DVD Root, Apploader
wxFilePickerCtrl* DefaultISO; wxFilePickerCtrl* DefaultISO;
wxStaticText* DVDRootText;
wxDirPickerCtrl* DVDRoot; wxDirPickerCtrl* DVDRoot;
wxStaticText* ApploaderPathText;
wxFilePickerCtrl* ApploaderPath; wxFilePickerCtrl* ApploaderPath;
wxStaticText* PADText;
wxButton* PADConfig;
wxChoice* PADSelection;
wxButton* DSPConfig;
wxStaticText* DSPText;
wxChoice* DSPSelection;
wxButton* GraphicConfig;
wxStaticText* GraphicText;
wxChoice* GraphicSelection;
wxButton* WiimoteConfig;
wxStaticText* WiimoteText;
wxChoice* WiimoteSelection;
wxArrayString arrayStringFor_InterfaceLang; wxBoxSizer* sPluginsPage; // Plugins settings
wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin, *sbPadPlugin, *sbWiimotePlugin; // Graphics, DSP, Pad and Wiimote sections
// Graphics
wxChoice* GraphicSelection;
wxButton* GraphicConfig;
// DSP
wxChoice* DSPSelection;
wxButton* DSPConfig;
// Pad
wxChoice* PADSelection;
wxButton* PADConfig;
// Wiimote
wxChoice* WiimoteSelection;
wxButton* WiimoteConfig;
wxButton* m_Ok;
FILE* pStream;
wxArrayString arrayStringFor_Framelimit; wxArrayString arrayStringFor_Framelimit;
wxArrayString arrayStringFor_CPUEngine;
wxArrayString arrayStringFor_Themes;
wxArrayString arrayStringFor_InterfaceLang;
wxArrayString arrayStringFor_FullscreenResolution;
wxArrayString arrayStringFor_GCSystemLang; wxArrayString arrayStringFor_GCSystemLang;
wxArrayString arrayStringFor_WiiSensBarPos; wxArrayString arrayStringFor_WiiSensBarPos;
wxArrayString arrayStringFor_WiiAspectRatio; wxArrayString arrayStringFor_WiiAspectRatio;
wxArrayString arrayStringFor_WiiSystemLang; wxArrayString arrayStringFor_WiiSystemLang;
wxArrayString arrayStringFor_ISOPaths; wxArrayString arrayStringFor_ISOPaths;
wxArrayString arrayStringFor_Themes;
wxArrayString arrayStringFor_FullscreenResolution;
enum enum
{ {
@ -171,33 +183,36 @@ private:
ID_PATHSPAGE, ID_PATHSPAGE,
ID_PLUGINPAGE, ID_PLUGINPAGE,
ID_ALWAYS_HLE_BS2,
ID_RADIOJIT,
ID_RADIOJITIL,
ID_RADIOINT,
ID_CPUTHREAD, ID_CPUTHREAD,
ID_DSPTHREAD,
ID_LOCKTHREADS,
ID_IDLESKIP, ID_IDLESKIP,
ID_ENABLECHEATS, ID_ENABLECHEATS,
ID_FRAMELIMIT_TEXT, ID_FRAMELIMIT,
ID_FRAMELIMIT_USEFPSFORLIMITING,
ID_ALWAYS_HLE_BS2,
ID_CPUENGINE,
ID_LOCKTHREADS,
ID_DSPTHREAD,
ID_INTERFACE_CONFIRMSTOP, // Interface settings
ID_INTERFACE_USEPANICHANDLERS,
ID_DISPLAY_FULLSCREENRES, ID_DISPLAY_FULLSCREENRES,
ID_DISPLAY_WINDOWWIDTH, ID_DISPLAY_WINDOWWIDTH,
ID_DISPLAY_WINDOWHEIGHT, ID_DISPLAY_WINDOWHEIGHT,
ID_DISPLAY_FULLSCREEN, ID_DISPLAY_FULLSCREEN,
ID_DISPLAY_HIDECURSOR, ID_DISPLAY_HIDECURSOR,
ID_DISPLAY_RENDERTOMAIN, ID_DISPLAY_RENDERTOMAIN,
ID_HOTKEY_CONFIG,
ID_INTERFACE_LANG_TEXT, ID_INTERFACE_LANG, // Interface settings
ID_INTERFACE_CONFIRMSTOP,
ID_INTERFACE_USEPANICHANDLERS,
ID_INTERFACE_THEME, ID_INTERFACE_THEME,
ID_FRAMELIMIT_TEXT, ID_INTERFACE_LANG_TEXT, ID_INTERFACE_LANG,
ID_FRAMELIMIT, ID_HOTKEY_CONFIG,
ID_FRAMELIMIT_USEFPSFORLIMITING,
ID_GC_SRAM_LNG_TEXT, ID_GC_SRAM_LNG_TEXT,
ID_GC_SRAM_LNG, ID_GC_SRAM_LNG,
ID_GC_EXIDEVICE_SLOTA_TEXT, ID_GC_EXIDEVICE_SLOTA_TEXT,
ID_GC_EXIDEVICE_SLOTA, ID_GC_EXIDEVICE_SLOTA,
ID_GC_EXIDEVICE_SLOTA_PATH, ID_GC_EXIDEVICE_SLOTA_PATH,
@ -212,8 +227,10 @@ private:
ID_GC_SIDEVICE2, ID_GC_SIDEVICE2,
ID_GC_SIDEVICE3, ID_GC_SIDEVICE3,
ID_WII_BT_BAR_TEXT, ID_WII_BT_BAR_TEXT,
ID_WII_BT_BAR, ID_WII_BT_BAR,
ID_WII_IPL_SSV, ID_WII_IPL_SSV,
ID_WII_IPL_PGS, ID_WII_IPL_PGS,
ID_WII_IPL_E60, ID_WII_IPL_E60,
@ -221,13 +238,16 @@ private:
ID_WII_IPL_AR, ID_WII_IPL_AR,
ID_WII_IPL_LNG_TEXT, ID_WII_IPL_LNG_TEXT,
ID_WII_IPL_LNG, ID_WII_IPL_LNG,
ID_WII_SD_CARD, ID_WII_SD_CARD,
ID_WII_KEYBOARD, ID_WII_KEYBOARD,
ID_ISOPATHS, ID_ISOPATHS,
ID_RECURSIVEISOPATH,
ID_ADDISOPATH, ID_ADDISOPATH,
ID_REMOVEISOPATH, ID_REMOVEISOPATH,
ID_RECERSIVEISOPATH,
ID_DEFAULTISO_TEXT, ID_DEFAULTISO_TEXT,
ID_DEFAULTISO, ID_DEFAULTISO,
ID_DVDROOT_TEXT, ID_DVDROOT_TEXT,
@ -235,22 +255,26 @@ private:
ID_APPLOADERPATH_TEXT, ID_APPLOADERPATH_TEXT,
ID_APPLOADERPATH, ID_APPLOADERPATH,
ID_WIIMOTE_ABOUT,
ID_WIIMOTE_CONFIG, ID_GRAPHIC_TEXT,
ID_WIIMOTE_TEXT, ID_GRAPHIC_CB,
ID_WIIMOTE_CB, ID_GRAPHIC_CONFIG,
ID_PAD_TEXT, ID_GRAPHIC_ABOUT,
ID_PAD_ABOUT ,
ID_PAD_CONFIG,
ID_PAD_CB,
ID_DSP_ABOUT,
ID_DSP_CONFIG,
ID_DSP_TEXT, ID_DSP_TEXT,
ID_DSP_CB, ID_DSP_CB,
ID_GRAPHIC_ABOUT, ID_DSP_CONFIG,
ID_GRAPHIC_CONFIG, ID_DSP_ABOUT,
ID_GRAPHIC_TEXT,
ID_GRAPHIC_CB ID_PAD_TEXT,
ID_PAD_CB,
ID_PAD_CONFIG,
ID_PAD_ABOUT,
ID_WIIMOTE_TEXT,
ID_WIIMOTE_CB,
ID_WIIMOTE_CONFIG,
ID_WIIMOTE_ABOUT
}; };
void InitializeGUILists(); void InitializeGUILists();
@ -260,13 +284,20 @@ private:
void CreateGUIControls(); void CreateGUIControls();
void UpdateGUI(); void UpdateGUI();
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnSpin(wxSpinEvent& event);
void CoreSettingsChanged(wxCommandEvent& event); void CoreSettingsChanged(wxCommandEvent& event);
void DisplaySettingsChanged(wxCommandEvent& event);
void AddResolutions();
void OnSpin(wxSpinEvent& event);
void GCSettingsChanged(wxCommandEvent& event); void GCSettingsChanged(wxCommandEvent& event);
void ChooseMemcardPath(std::string& strMemcard, bool isSlotA); void ChooseMemcardPath(std::string& strMemcard, bool isSlotA);
void ChooseSIDevice(std::string deviceName, int deviceNum); void ChooseSIDevice(std::string deviceName, int deviceNum);
void ChooseEXIDevice(std::string deviceName, int deviceNum); void ChooseEXIDevice(std::string deviceName, int deviceNum);
void WiiSettingsChanged(wxCommandEvent& event); void WiiSettingsChanged(wxCommandEvent& event);
void ISOPathsSelectionChanged(wxCommandEvent& event); void ISOPathsSelectionChanged(wxCommandEvent& event);
void RecursiveDirectoryChanged(wxCommandEvent& event); void RecursiveDirectoryChanged(wxCommandEvent& event);
void AddRemoveISOPaths(wxCommandEvent& event); void AddRemoveISOPaths(wxCommandEvent& event);
@ -277,6 +308,6 @@ private:
void FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename); void FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename);
void CallConfig(wxChoice* _pChoice); void CallConfig(wxChoice* _pChoice);
bool GetFilename(wxChoice* _pChoice, std::string& _rFilename); bool GetFilename(wxChoice* _pChoice, std::string& _rFilename);
void AddResolutions(); DECLARE_EVENT_TABLE();
}; };
#endif #endif

View file

@ -357,7 +357,6 @@ CFrame::CFrame(wxFrame* parent,
#if wxUSE_TIMER #if wxUSE_TIMER
, m_timer(this) , m_timer(this)
#endif #endif
{ {
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true; if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;
@ -616,7 +615,7 @@ void CFrame::OnMove(wxMoveEvent& event)
event.Skip(); event.Skip();
if (!IsMaximized() && if (!IsMaximized() &&
!(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen())) !(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen()))
{ {
SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX = GetPosition().x; SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX = GetPosition().x;
SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY = GetPosition().y; SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY = GetPosition().y;
@ -627,7 +626,7 @@ void CFrame::OnResize(wxSizeEvent& event)
{ {
event.Skip(); event.Skip();
if (!IsMaximized() && if (!IsMaximized() &&
!(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen())) !(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen()))
{ {
SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth = GetSize().GetWidth(); SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth = GetSize().GetWidth();
SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight = GetSize().GetHeight(); SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight = GetSize().GetHeight();
@ -745,7 +744,7 @@ bool CFrame::RendererHasFocus()
// Host_RendererHasFocus()? // Host_RendererHasFocus()?
if (m_RenderParent) if (m_RenderParent)
if (m_RenderParent->GetParent()->GetHWND() == GetForegroundWindow()) if (m_RenderParent->GetParent()->GetHWND() == GetForegroundWindow())
return true; return true;
return false; return false;
#else #else
return m_RenderParent && (m_RenderParent == wxWindow::FindFocus()); return m_RenderParent && (m_RenderParent == wxWindow::FindFocus());
@ -930,15 +929,17 @@ wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxWind
Frame->Show(); Frame->Show();
return Frame; return Frame;
} }
wxPanel* CFrame::CreateEmptyPanel(wxWindowID Id) wxPanel* CFrame::CreateEmptyPanel(wxWindowID Id)
{ {
wxPanel* Panel = new wxPanel(this, Id); wxPanel* Panel = new wxPanel(this, Id);
return Panel; return Panel;
} }
wxAuiNotebook* CFrame::CreateEmptyNotebook() wxAuiNotebook* CFrame::CreateEmptyNotebook()
{ {
wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE); wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE);
return NB; return NB;
} }
void CFrame::DoFullscreen(bool bF) void CFrame::DoFullscreen(bool bF)
@ -1034,22 +1035,22 @@ void CFrame::ListChildren()
void CFrame::ListTopWindows() void CFrame::ListTopWindows()
{ {
wxWindowList::const_iterator i; wxWindowList::const_iterator i;
int j = 0; int j = 0;
const wxWindowList::const_iterator end = wxTopLevelWindows.end(); const wxWindowList::const_iterator end = wxTopLevelWindows.end();
for (i = wxTopLevelWindows.begin(); i != end; ++i) for (i = wxTopLevelWindows.begin(); i != end; ++i)
{ {
wxTopLevelWindow * const Win = wx_static_cast(wxTopLevelWindow *, *i); wxTopLevelWindow * const Win = wx_static_cast(wxTopLevelWindow *, *i);
NOTICE_LOG(CONSOLE, "%i: %i %s", j, Win, (const char *)Win->GetTitle().mb_str()); NOTICE_LOG(CONSOLE, "%i: %i %s", j, Win, (const char *)Win->GetTitle().mb_str());
/* /*
if ( win->ShouldPreventAppExit() ) if ( win->ShouldPreventAppExit() )
{ {
// there remains at least one important TLW, don't exit // there remains at least one important TLW, don't exit
return false; return false;
} }
*/ */
j++; j++;
} }
NOTICE_LOG(CONSOLE, "\n"); NOTICE_LOG(CONSOLE, "\n");
} }

View file

@ -316,7 +316,7 @@ wxString CFrame::GetMenuLabel(int Id)
void CFrame::PopulateToolbar(wxAuiToolBar* ToolBar) void CFrame::PopulateToolbar(wxAuiToolBar* ToolBar)
{ {
int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(), int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(),
h = m_Bitmaps[Toolbar_FileOpen].GetHeight(); h = m_Bitmaps[Toolbar_FileOpen].GetHeight();
ToolBar->SetToolBitmapSize(wxSize(w, h)); ToolBar->SetToolBitmapSize(wxSize(w, h));
@ -549,7 +549,7 @@ void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
void CFrame::DoOpen(bool Boot) void CFrame::DoOpen(bool Boot)
{ {
std::string currentDir = File::GetCurrentDir(); std::string currentDir = File::GetCurrentDir();
wxString path = wxFileSelector( wxString path = wxFileSelector(
_T("Select the file to load"), _T("Select the file to load"),
@ -565,13 +565,13 @@ void CFrame::DoOpen(bool Boot)
bool fileChosen = !path.IsEmpty(); bool fileChosen = !path.IsEmpty();
std::string currentDir2 = File::GetCurrentDir(); std::string currentDir2 = File::GetCurrentDir();
if (currentDir != currentDir2) if (currentDir != currentDir2)
{ {
PanicAlert("Current dir changed from %s to %s after wxFileSelector!",currentDir.c_str(),currentDir2.c_str()); PanicAlert("Current dir changed from %s to %s after wxFileSelector!",currentDir.c_str(),currentDir2.c_str());
File::SetCurrentDir(currentDir.c_str()); File::SetCurrentDir(currentDir.c_str());
} }
// Should we boot a new game or just change the disc? // Should we boot a new game or just change the disc?
@ -1311,7 +1311,7 @@ void CFrame::UpdateGUI()
} }
else else
{ {
// Game has been loaded, enable the play button // Game has been loaded, enable the pause button
if (m_ToolBar) if (m_ToolBar)
m_ToolBar->EnableTool(IDM_PLAY, true); m_ToolBar->EnableTool(IDM_PLAY, true);
GetMenuBar()->FindItem(IDM_PLAY)->Enable(true); GetMenuBar()->FindItem(IDM_PLAY)->Enable(true);
@ -1424,4 +1424,3 @@ void CFrame::OnToggleStatusbar(wxCommandEvent& event)
this->SendSizeEvent(); this->SendSizeEvent();
} }

View file

@ -189,25 +189,25 @@ bool DolphinApp::OnInit()
return false; return false;
} }
#if wxCHECK_VERSION(2, 9, 0) #if wxCHECK_VERSION(2, 9, 0)
UseDebugger = parser.Found("debugger"); UseDebugger = parser.Found(wxT("debugger"));
UseLogger = parser.Found("logger"); UseLogger = parser.Found(wxT("logger"));
LoadElf = parser.Found("elf", &ElfFile); LoadElf = parser.Found(wxT("elf"), &ElfFile);
#else #else
UseDebugger = parser.Found(_("debugger")); UseDebugger = parser.Found(wxT("debugger"));
UseLogger = parser.Found(_("logger")); UseLogger = parser.Found(wxT("logger"));
LoadElf = parser.Found(_("elf"), &ElfFile); LoadElf = parser.Found(wxT("elf"), &ElfFile);
#endif #endif
#if wxCHECK_VERSION(2, 9, 0) #if wxCHECK_VERSION(2, 9, 0)
selectVideoPlugin = parser.Found("video_plugin", &videoPluginFilename); selectVideoPlugin = parser.Found(wxT("video_plugin"), &videoPluginFilename);
selectAudioPlugin = parser.Found("audio_plugin", &audioPluginFilename); selectAudioPlugin = parser.Found(wxT("audio_plugin"), &audioPluginFilename);
selectPadPlugin = parser.Found("pad_plugin", &padPluginFilename); selectPadPlugin = parser.Found(wxT"pad_plugin", &padPluginFilename);
selectWiimotePlugin = parser.Found("wiimote_plugin", &wiimotePluginFilename); selectWiimotePlugin = parser.Found(wxT("wiimote_plugin"), &wiimotePluginFilename);
#else #else
selectVideoPlugin = parser.Found(_T("video_plugin"), &videoPluginFilename); selectVideoPlugin = parser.Found(wxT("video_plugin"), &videoPluginFilename);
selectAudioPlugin = parser.Found(_T("audio_plugin"), &audioPluginFilename); selectAudioPlugin = parser.Found(wxT("audio_plugin"), &audioPluginFilename);
selectPadPlugin = parser.Found(_T("pad_plugin"), &padPluginFilename); selectPadPlugin = parser.Found(_T("pad_plugin"), &padPluginFilename);
selectWiimotePlugin = parser.Found(_T("wiimote_plugin"), &wiimotePluginFilename); selectWiimotePlugin = parser.Found(wxT("wiimote_plugin"), &wiimotePluginFilename);
#endif #endif
#endif // wxUSE_CMDLINE_PARSER #endif // wxUSE_CMDLINE_PARSER
@ -324,21 +324,21 @@ bool DolphinApp::OnInit()
File::CopyDir(SHARED_USER_DIR WII_USER_DIR DIR_SEP, File::GetUserPath(D_WIIUSER_IDX)); File::CopyDir(SHARED_USER_DIR WII_USER_DIR DIR_SEP, File::GetUserPath(D_WIIUSER_IDX));
if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) if (!File::Exists(File::GetUserPath(D_GCUSER_IDX)))
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) if (!File::Exists(File::GetUserPath(D_CACHE_IDX)))
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX)))
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX)))
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX)))
File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX)))
File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX)))
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX)))
File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
#endif #endif
LogManager::Init(); LogManager::Init();
@ -352,7 +352,7 @@ bool DolphinApp::OnInit()
if (selectAudioPlugin && audioPluginFilename != wxEmptyString) if (selectAudioPlugin && audioPluginFilename != wxEmptyString)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin =
std::string(audioPluginFilename.mb_str()); std::string(audioPluginFilename.mb_str());
if (selectPadPlugin && padPluginFilename != wxEmptyString) if (selectPadPlugin && padPluginFilename != wxEmptyString)
{ {
@ -367,7 +367,7 @@ bool DolphinApp::OnInit()
int k; int k;
for(k=0;k<MAXWIIMOTES;k++) for(k=0;k<MAXWIIMOTES;k++)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[k] = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[k] =
std::string(wiimotePluginFilename.mb_str()); std::string(wiimotePluginFilename.mb_str());
} }
// Enable the PNG image handler // Enable the PNG image handler
@ -378,12 +378,10 @@ bool DolphinApp::OnInit()
// Create the window title // Create the window title
#ifdef _DEBUG #ifdef _DEBUG
const char *title = "Dolphin Debug SVN R " SVN_REV_STR; const char *title = "Dolphin Debug SVN R " SVN_REV_STR;
#else #elif defined DEBUGFAST
#ifdef DEBUGFAST
const char *title = "Dolphin Debugfast SVN R " SVN_REV_STR; const char *title = "Dolphin Debugfast SVN R " SVN_REV_STR;
#else #else
const char *title = "Dolphin SVN R " SVN_REV_STR; const char *title = "Dolphin SVN R " SVN_REV_STR;
#endif
#endif #endif
int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX;
@ -493,7 +491,7 @@ void Host_SysMessage(const char *fmt, ...)
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/) bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
{ {
return wxYES == wxMessageBox(wxString::FromAscii(text), return wxYES == wxMessageBox(wxString::FromAscii(text),
wxString::FromAscii(caption), wxString::FromAscii(caption),
(yes_no)?wxYES_NO:wxOK); (yes_no)?wxYES_NO:wxOK);
} }

View file

@ -56,7 +56,7 @@ bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_
// Get device status // Get device status
int numjoy = SDL_NumJoysticks(); int numjoy = SDL_NumJoysticks();
for (int i = 0; i < numjoy; i++ ) for (int i = 0; i < numjoy; i++)
{ {
CONTROLLER_INFO Tmp; CONTROLLER_INFO Tmp;
@ -97,12 +97,12 @@ bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_
// Avoid extreme axis values // Avoid extreme axis values
// --------------------- // ---------------------
/* Function: We have to avoid very big values to becuse some triggers are -0x8000 in the /* Function: We have to avoid very big values because some triggers are -0x8000 in the
unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */ unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */
bool AvoidValues(int value, bool NoTriggerFilter) bool AvoidValues(int value, bool NoTriggerFilter)
{ {
// Avoid detecting very small or very big (for triggers) values // Avoid detecting very small or very big (for triggers) values
if( (value > -0x1000 && value < 0x1000) // Small values if((value > -0x1000 && value < 0x1000) // Small values
|| ((value < -0x7000 || value > 0x7000) && !NoTriggerFilter)) // Big values || ((value < -0x7000 || value > 0x7000) && !NoTriggerFilter)) // Big values
return true; // Avoid return true; // Avoid
else else

View file

@ -48,9 +48,10 @@ namespace XInput
struct CONTROLER_STATE struct CONTROLER_STATE
{ {
XINPUT_STATE state; XINPUT_STATE state;
bool bConnected; bool bConnected;
}; };
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS]; CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
@ -61,33 +62,32 @@ CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
we currently only try to connect to XInput device 0 */ we currently only try to connect to XInput device 0 */
void Init() void Init()
{ {
// Init state // Init state
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS ); //ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
// Declaration // Declaration
DWORD dwResult; DWORD dwResult;
// Calculate the number of connected XInput devices // Calculate the number of connected XInput devices
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ ) for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
{ {
// Simply get the state of the controller from XInput. // Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, &g_Controllers[i].state ); dwResult = XInputGetState( i, &g_Controllers[i].state );
if( dwResult == ERROR_SUCCESS ) if( dwResult == ERROR_SUCCESS )
g_Controllers[i].bConnected = true; g_Controllers[i].bConnected = true;
else else
g_Controllers[i].bConnected = false; g_Controllers[i].bConnected = false;
} }
} }
// Get the trigger status // Get the trigger status
// ------------------- // -------------------
int GetXI(int Controller, int Button) int GetXI(int Controller, int Button)
{ {
// Update the internal status // Update the internal status
DWORD dwResult; DWORD dwResult;
dwResult = XInputGetState(Controller, &g_Controllers[Controller].state); dwResult = XInputGetState(Controller, &g_Controllers[Controller].state);
if (dwResult != ERROR_SUCCESS) return -1; if (dwResult != ERROR_SUCCESS) return -1;
@ -105,7 +105,6 @@ int GetXI(int Controller, int Button)
} }
} }
// Check if a certain controller is connected // Check if a certain controller is connected
// ------------------- // -------------------
bool IsConnected(int Controller) bool IsConnected(int Controller)

View file

@ -36,7 +36,6 @@ void Init();
int GetXI(int Controller, int Button); int GetXI(int Controller, int Button);
bool IsConnected(int Controller); bool IsConnected(int Controller);
} // XInput } // XInput
#endif #endif

View file

@ -17,6 +17,7 @@
#include <cmath> #include <cmath>
#include "VideoConfig.h"
#include "Profiler.h" #include "Profiler.h"
#include "Statistics.h" #include "Statistics.h"
#include "Render.h" #include "Render.h"
@ -35,8 +36,8 @@ using namespace BPFunctions;
void BPInit() void BPInit()
{ {
memset(&bpmem, 0, sizeof(bpmem)); memset(&bpmem, 0, sizeof(bpmem));
bpmem.bpMask = 0xFFFFFF; bpmem.bpMask = 0xFFFFFF;
} }
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight) void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight)
@ -46,22 +47,22 @@ void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xf
void BPWritten(const BPCmd& bp) void BPWritten(const BPCmd& bp)
{ {
/* /*
---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------
Purpose: Writes to the BP registers Purpose: Writes to the BP registers
Called: At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg Called: At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg
How It Works: First the pipeline is flushed then update the bpmem with the new value. How It Works: First the pipeline is flushed then update the bpmem with the new value.
Some of the BP cases have to call certain functions while others just update the bpmem. Some of the BP cases have to call certain functions while others just update the bpmem.
some bp cases check the changes variable, because they might not have to be updated all the time some bp cases check the changes variable, because they might not have to be updated all the time
NOTE: it seems not all bp cases like checking changes, so calling if (bp.changes == 0 ? false : true) NOTE: it seems not all bp cases like checking changes, so calling if (bp.changes == 0 ? false : true)
had to be ditched and the games seem to work fine with out it. had to be ditched and the games seem to work fine with out it.
NOTE2: Yet Another Gamecube Documentation calls them Bypass Raster State Registers but possibly completely wrong NOTE2: Yet Another Gamecube Documentation calls them Bypass Raster State Registers but possibly completely wrong
NOTE3: This controls the register groups: RAS1/2, SU, TF, TEV, C/Z, PEC NOTE3: This controls the register groups: RAS1/2, SU, TF, TEV, C/Z, PEC
TODO: Turn into function table. The (future) DisplayList (DL) jit can then call the functions directly, TODO: Turn into function table. The (future) DisplayList (DL) jit can then call the functions directly,
getting rid of dynamic dispatch. Unfortunately, few games use DLs properly - most\ getting rid of dynamic dispatch. Unfortunately, few games use DLs properly - most\
just stuff geometry in them and don't put state changes there. just stuff geometry in them and don't put state changes there
---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------
*/ */
// Debugging only, this lets you skip a bp update // Debugging only, this lets you skip a bp update
//static int times = 0; //static int times = 0;
@ -83,13 +84,13 @@ void BPWritten(const BPCmd& bp)
//s_bpCritical.Enter(); //s_bpCritical.Enter();
FlushPipeline(); FlushPipeline();
((u32*)&bpmem)[bp.address] = bp.newvalue; ((u32*)&bpmem)[bp.address] = bp.newvalue;
switch (bp.address) switch (bp.address)
{ {
case BPMEM_GENMODE: // Set the Generation Mode case BPMEM_GENMODE: // Set the Generation Mode
{ {
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d", PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, cullmode=%d, ind=%d, zfeeze=%d",
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
bpmem.genMode.numindstages, bpmem.genMode.zfreeze); bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
@ -108,9 +109,9 @@ void BPWritten(const BPCmd& bp)
PixelShaderManager::SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3); PixelShaderManager::SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3);
break; break;
case BPMEM_RAS1_SS0: // Index Texture Coordinate Scale 0 case BPMEM_RAS1_SS0: // Index Texture Coordinate Scale 0
PixelShaderManager::SetIndTexScaleChanged(0x03); PixelShaderManager::SetIndTexScaleChanged(0x03);
case BPMEM_RAS1_SS1: // Index Texture Coordinate Scale 1 case BPMEM_RAS1_SS1: // Index Texture Coordinate Scale 1
PixelShaderManager::SetIndTexScaleChanged(0x0c); PixelShaderManager::SetIndTexScaleChanged(0x0c);
break; break;
// ---------------- // ----------------
// Scissor Control // Scissor Control
@ -161,29 +162,29 @@ void BPWritten(const BPCmd& bp)
// Tokens are similar. // Tokens are similar.
case BPMEM_SETDRAWDONE: case BPMEM_SETDRAWDONE:
switch (bp.newvalue & 0xFF) switch (bp.newvalue & 0xFF)
{ {
case 0x02: case 0x02:
PixelEngine::SetFinish(); // may generate interrupt PixelEngine::SetFinish(); // may generate interrupt
DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF)); DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF));
break; break;
default: default:
WARN_LOG(VIDEO, "GXSetDrawDone ??? (value 0x%02X)", (bp.newvalue & 0xFFFF)); WARN_LOG(VIDEO, "GXSetDrawDone ??? (value 0x%02X)", (bp.newvalue & 0xFFFF));
break; break;
} }
break; break;
case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), FALSE); PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), FALSE);
DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF)); DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF));
break; break;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), TRUE); PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), TRUE);
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF)); DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF));
break; break;
// ------------------------ // ------------------------
// EFB copy command. This copies a rectangle from the EFB to either RAM in a texture format or to XFB as YUYV. // EFB copy command. This copies a rectangle from the EFB to either RAM in a texture format or to XFB as YUYV.
// It can also optionally clear the EFB while copying from it. To emulate this, we of course copy first and clear afterwards. // It can also optionally clear the EFB while copying from it. To emulate this, we of course copy first and clear afterwards.
case BPMEM_TRIGGER_EFB_COPY: // Copy EFB Region or Render to the XFB or Clear the screen. case BPMEM_TRIGGER_EFB_COPY: // Copy EFB Region or Render to the XFB or Clear the screen.
{ {
DVSTARTSUBPROFILE("LoadBPReg:swap"); DVSTARTSUBPROFILE("LoadBPReg:swap");
// The bottom right is within the rectangle // The bottom right is within the rectangle
@ -250,15 +251,15 @@ void BPWritten(const BPCmd& bp)
case BPMEM_LOADTLUT0: // This one updates bpmem.tlutXferSrc, no need to do anything here. case BPMEM_LOADTLUT0: // This one updates bpmem.tlutXferSrc, no need to do anything here.
break; break;
case BPMEM_LOADTLUT1: // Load a Texture Look Up Table case BPMEM_LOADTLUT1: // Load a Texture Look Up Table
{ {
DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut"); DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut");
u32 tlutTMemAddr = (bp.newvalue & 0x3FF) << 9; u32 tlutTMemAddr = (bp.newvalue & 0x3FF) << 9;
u32 tlutXferCount = (bp.newvalue & 0x1FFC00) >> 5; u32 tlutXferCount = (bp.newvalue & 0x1FFC00) >> 5;
u8 *ptr = 0; u8 *ptr = 0;
// TODO - figure out a cleaner way. // TODO - figure out a cleaner way.
if (GetConfig(CONFIG_ISWII)) if (GetConfig(CONFIG_ISWII))
ptr = GetPointer(bpmem.tlutXferSrc << 5); ptr = GetPointer(bpmem.tlutXferSrc << 5);
else else
@ -269,10 +270,10 @@ void BPWritten(const BPCmd& bp)
else else
PanicAlert("Invalid palette pointer %08x %08x %08x", bpmem.tlutXferSrc, bpmem.tlutXferSrc << 5, (bpmem.tlutXferSrc & 0xFFFFF)<< 5); PanicAlert("Invalid palette pointer %08x %08x %08x", bpmem.tlutXferSrc, bpmem.tlutXferSrc << 5, (bpmem.tlutXferSrc & 0xFFFFF)<< 5);
// TODO(ector) : kill all textures that use this palette // TODO(ector) : kill all textures that use this palette
// Not sure if it's a good idea, though. For now, we hash texture palettes // Not sure if it's a good idea, though. For now, we hash texture palettes
break; break;
} }
case BPMEM_FOGRANGE: // Fog Settings Control case BPMEM_FOGRANGE: // Fog Settings Control
case BPMEM_FOGRANGE+1: case BPMEM_FOGRANGE+1:
case BPMEM_FOGRANGE+2: case BPMEM_FOGRANGE+2:
@ -293,11 +294,11 @@ void BPWritten(const BPCmd& bp)
case BPMEM_ALPHACOMPARE: // Compare Alpha Values case BPMEM_ALPHACOMPARE: // Compare Alpha Values
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alphaFunc.ref0, PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alphaFunc.ref0,
bpmem.alphaFunc.ref1, bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1, bpmem.alphaFunc.logic); bpmem.alphaFunc.ref1, bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1, bpmem.alphaFunc.logic);
PixelShaderManager::SetAlpha(bpmem.alphaFunc); PixelShaderManager::SetAlpha(bpmem.alphaFunc);
break; break;
case BPMEM_BIAS: // BIAS case BPMEM_BIAS: // BIAS
PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias); PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias);
PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias); PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias);
break; break;
case BPMEM_ZTEX2: // Z Texture type case BPMEM_ZTEX2: // Z Texture type
{ {
@ -381,8 +382,8 @@ void BPWritten(const BPCmd& bp)
} }
#endif #endif
break; break;
} }
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue); DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue);
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel
@ -395,7 +396,7 @@ void BPWritten(const BPCmd& bp)
9 BC1 - Ind. Tex Stage 1 NTexCoord 9 BC1 - Ind. Tex Stage 1 NTexCoord
6 BI1 - Ind. Tex Stage 1 NTexMap 6 BI1 - Ind. Tex Stage 1 NTexMap
3 BC0 - Ind. Tex Stage 0 NTexCoord 3 BC0 - Ind. Tex Stage 0 NTexCoord
0 BI0 - Ind. Tex Stage 0 NTexMap */ 0 BI0 - Ind. Tex Stage 0 NTexMap*/
case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0 case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0
case BPMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1 case BPMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1
case BPMEM_TEV_KSEL+2:// Texture Environment Swap Mode Table 2 case BPMEM_TEV_KSEL+2:// Texture Environment Swap Mode Table 2
@ -405,7 +406,7 @@ void BPWritten(const BPCmd& bp)
case BPMEM_TEV_KSEL+6:// Texture Environment Swap Mode Table 6 case BPMEM_TEV_KSEL+6:// Texture Environment Swap Mode Table 6
case BPMEM_TEV_KSEL+7:// Texture Environment Swap Mode Table 7 case BPMEM_TEV_KSEL+7:// Texture Environment Swap Mode Table 7
case BPMEM_BP_MASK: // This Register can be used to limit to which bits of BP registers is actually written to. the mask is case BPMEM_BP_MASK: // This Register can be used to limit to which bits of BP registers is actually written to. the mask is
// only valid for the next BP command, and will reset itself. // only valid for the next BP command, and will reset itself.
case BPMEM_IND_IMASK: // Index Mask ? case BPMEM_IND_IMASK: // Index Mask ?
case BPMEM_REVBITS: // Always set to 0x0F when GX_InitRevBits() is called. case BPMEM_REVBITS: // Always set to 0x0F when GX_InitRevBits() is called.
break; break;
@ -439,7 +440,7 @@ void BPWritten(const BPCmd& bp)
break; break;
// ---------------------- // ----------------------
// Set wrap size // Set wrap size
// ---------------------- // ----------------------
case BPMEM_SU_SSIZE: case BPMEM_SU_SSIZE:
case BPMEM_SU_TSIZE: case BPMEM_SU_TSIZE:
case BPMEM_SU_SSIZE+2: case BPMEM_SU_SSIZE+2:
@ -456,12 +457,12 @@ void BPWritten(const BPCmd& bp)
case BPMEM_SU_TSIZE+12: case BPMEM_SU_TSIZE+12:
case BPMEM_SU_SSIZE+14: case BPMEM_SU_SSIZE+14:
case BPMEM_SU_TSIZE+14: case BPMEM_SU_TSIZE+14:
PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1); PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
break; break;
// ------------------------ // ------------------------
// BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S // BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S
// BPMEM_TX_SETMODE1 - (LOD Stuff) - Max LOD, Min LOD // BPMEM_TX_SETMODE1 - (LOD Stuff) - Max LOD, Min LOD
// ------------------------ // ------------------------
case BPMEM_TX_SETMODE0: // (0x90 for linear) case BPMEM_TX_SETMODE0: // (0x90 for linear)
case BPMEM_TX_SETMODE0_4: case BPMEM_TX_SETMODE0_4:
// Shouldn't need to call this here, we call it for each active texture right before rendering // Shouldn't need to call this here, we call it for each active texture right before rendering
@ -476,7 +477,7 @@ void BPWritten(const BPCmd& bp)
// BPMEM_TX_SETIMAGE1 - even LOD address in TMEM - Image Type, Cache Height, Cache Width, TMEM Offset // BPMEM_TX_SETIMAGE1 - even LOD address in TMEM - Image Type, Cache Height, Cache Width, TMEM Offset
// BPMEM_TX_SETIMAGE2 - odd LOD address in TMEM - Cache Height, Cache Width, TMEM Offset // BPMEM_TX_SETIMAGE2 - odd LOD address in TMEM - Cache Height, Cache Width, TMEM Offset
// BPMEM_TX_SETIMAGE3 - Address of Texture in main memory // BPMEM_TX_SETIMAGE3 - Address of Texture in main memory
// -------------------------------------------- // --------------------------------------------
case BPMEM_TX_SETIMAGE0: case BPMEM_TX_SETIMAGE0:
case BPMEM_TX_SETIMAGE0_4: case BPMEM_TX_SETIMAGE0_4:
case BPMEM_TX_SETIMAGE1: case BPMEM_TX_SETIMAGE1:
@ -489,14 +490,14 @@ void BPWritten(const BPCmd& bp)
// ------------------------------- // -------------------------------
// Set a TLUT // Set a TLUT
// BPMEM_TX_SETTLUT - Format, TMEM Offset (offset of TLUT from start of TMEM high bank > > 5) // BPMEM_TX_SETTLUT - Format, TMEM Offset (offset of TLUT from start of TMEM high bank > > 5)
// ------------------------------- // -------------------------------
case BPMEM_TX_SETTLUT: case BPMEM_TX_SETTLUT:
case BPMEM_TX_SETLUT_4: case BPMEM_TX_SETLUT_4:
break; break;
// --------------------------------------------------- // ---------------------------------------------------
// Set the TEV Color // Set the TEV Color
// --------------------------------------------------- // ---------------------------------------------------
case BPMEM_TEV_REGISTER_L: // Reg 1 case BPMEM_TEV_REGISTER_L: // Reg 1
case BPMEM_TEV_REGISTER_H: case BPMEM_TEV_REGISTER_H:
case BPMEM_TEV_REGISTER_L+2: // Reg 2 case BPMEM_TEV_REGISTER_L+2: // Reg 2

View file

@ -163,154 +163,154 @@ void VertexShaderManager::Dirty()
// TODO: A cleaner way to control the matricies without making a mess in the parameters field // TODO: A cleaner way to control the matricies without making a mess in the parameters field
void VertexShaderManager::SetConstants() void VertexShaderManager::SetConstants()
{ {
if (nTransformMatricesChanged[0] >= 0) if (nTransformMatricesChanged[0] >= 0)
{ {
int startn = nTransformMatricesChanged[0] / 4; int startn = nTransformMatricesChanged[0] / 4;
int endn = (nTransformMatricesChanged[1] + 3) / 4; int endn = (nTransformMatricesChanged[1] + 3) / 4;
const float* pstart = (const float*)&xfmem[startn * 4]; const float* pstart = (const float*)&xfmem[startn * 4];
SetMultiVSConstant4fv(C_TRANSFORMMATRICES + startn, endn - startn, pstart); SetMultiVSConstant4fv(C_TRANSFORMMATRICES + startn, endn - startn, pstart);
nTransformMatricesChanged[0] = nTransformMatricesChanged[1] = -1; nTransformMatricesChanged[0] = nTransformMatricesChanged[1] = -1;
} }
if (nNormalMatricesChanged[0] >= 0) if (nNormalMatricesChanged[0] >= 0)
{ {
int startn = nNormalMatricesChanged[0] / 3; int startn = nNormalMatricesChanged[0] / 3;
int endn = (nNormalMatricesChanged[1] + 2) / 3; int endn = (nNormalMatricesChanged[1] + 2) / 3;
const float *pnstart = (const float*)&xfmem[XFMEM_NORMALMATRICES+3*startn]; const float *pnstart = (const float*)&xfmem[XFMEM_NORMALMATRICES+3*startn];
SetMultiVSConstant3fv(C_NORMALMATRICES + startn, endn - startn, pnstart); SetMultiVSConstant3fv(C_NORMALMATRICES + startn, endn - startn, pnstart);
nNormalMatricesChanged[0] = nNormalMatricesChanged[1] = -1; nNormalMatricesChanged[0] = nNormalMatricesChanged[1] = -1;
} }
if (nPostTransformMatricesChanged[0] >= 0) if (nPostTransformMatricesChanged[0] >= 0)
{ {
int startn = nPostTransformMatricesChanged[0] / 4; int startn = nPostTransformMatricesChanged[0] / 4;
int endn = (nPostTransformMatricesChanged[1] + 3 ) / 4; int endn = (nPostTransformMatricesChanged[1] + 3 ) / 4;
const float* pstart = (const float*)&xfmem[XFMEM_POSTMATRICES + startn * 4]; const float* pstart = (const float*)&xfmem[XFMEM_POSTMATRICES + startn * 4];
SetMultiVSConstant4fv(C_POSTTRANSFORMMATRICES + startn, endn - startn, pstart); SetMultiVSConstant4fv(C_POSTTRANSFORMMATRICES + startn, endn - startn, pstart);
} }
if (nLightsChanged[0] >= 0) if (nLightsChanged[0] >= 0)
{ {
// lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats // lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats
int istart = nLightsChanged[0] / 0x10; int istart = nLightsChanged[0] / 0x10;
int iend = (nLightsChanged[1] + 15) / 0x10; int iend = (nLightsChanged[1] + 15) / 0x10;
const float* xfmemptr = (const float*)&xfmem[0x10 * istart + XFMEM_LIGHTS]; const float* xfmemptr = (const float*)&xfmem[0x10 * istart + XFMEM_LIGHTS];
for (int i = istart; i < iend; ++i) for (int i = istart; i < iend; ++i)
{ {
u32 color = *(const u32*)(xfmemptr + 3); u32 color = *(const u32*)(xfmemptr + 3);
float NormalizationCoef = 1 / 255.0f; float NormalizationCoef = 1 / 255.0f;
SetVSConstant4f(C_LIGHTS + 5 * i, SetVSConstant4f(C_LIGHTS + 5 * i,
((color >> 24) & 0xFF) * NormalizationCoef, ((color >> 24) & 0xFF) * NormalizationCoef,
((color >> 16) & 0xFF) * NormalizationCoef, ((color >> 16) & 0xFF) * NormalizationCoef,
((color >> 8) & 0xFF) * NormalizationCoef, ((color >> 8) & 0xFF) * NormalizationCoef,
((color) & 0xFF) * NormalizationCoef); ((color) & 0xFF) * NormalizationCoef);
xfmemptr += 4; xfmemptr += 4;
for (int j = 0; j < 4; ++j, xfmemptr += 3) for (int j = 0; j < 4; ++j, xfmemptr += 3)
{ {
if (j == 1 && if (j == 1 &&
fabs(xfmemptr[0]) < 0.00001f && fabs(xfmemptr[0]) < 0.00001f &&
fabs(xfmemptr[1]) < 0.00001f && fabs(xfmemptr[1]) < 0.00001f &&
fabs(xfmemptr[2]) < 0.00001f) fabs(xfmemptr[2]) < 0.00001f)
{ {
// dist attenuation, make sure not equal to 0!!! // dist attenuation, make sure not equal to 0!!!
SetVSConstant4f(C_LIGHTS+5*i+j+1, 0.00001f, xfmemptr[1], xfmemptr[2], 0); SetVSConstant4f(C_LIGHTS+5*i+j+1, 0.00001f, xfmemptr[1], xfmemptr[2], 0);
} }
else else
SetVSConstant4fv(C_LIGHTS+5*i+j+1, xfmemptr); SetVSConstant4fv(C_LIGHTS+5*i+j+1, xfmemptr);
} }
} }
nLightsChanged[0] = nLightsChanged[1] = -1; nLightsChanged[0] = nLightsChanged[1] = -1;
} }
if (nMaterialsChanged) if (nMaterialsChanged)
{ {
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (nMaterialsChanged & (1 << i)) if (nMaterialsChanged & (1 << i))
SetVSConstant4fv(C_MATERIALS + i, &s_fMaterials[4 * i]); SetVSConstant4fv(C_MATERIALS + i, &s_fMaterials[4 * i]);
nMaterialsChanged = 0; nMaterialsChanged = 0;
} }
if (bPosNormalMatrixChanged) if (bPosNormalMatrixChanged)
{ {
bPosNormalMatrixChanged = false; bPosNormalMatrixChanged = false;
const float *pos = (const float *)xfmem + MatrixIndexA.PosNormalMtxIdx * 4; const float *pos = (const float *)xfmem + MatrixIndexA.PosNormalMtxIdx * 4;
const float *norm = (const float *)xfmem + XFMEM_NORMALMATRICES + 3 * (MatrixIndexA.PosNormalMtxIdx & 31); const float *norm = (const float *)xfmem + XFMEM_NORMALMATRICES + 3 * (MatrixIndexA.PosNormalMtxIdx & 31);
SetMultiVSConstant4fv(C_POSNORMALMATRIX, 3, pos); SetMultiVSConstant4fv(C_POSNORMALMATRIX, 3, pos);
SetMultiVSConstant3fv(C_POSNORMALMATRIX + 3, 3, norm); SetMultiVSConstant3fv(C_POSNORMALMATRIX + 3, 3, norm);
} }
if (bTexMatricesChanged[0]) if (bTexMatricesChanged[0])
{ {
bTexMatricesChanged[0] = false; bTexMatricesChanged[0] = false;
const float *fptrs[] = const float *fptrs[] =
{ {
(const float *)xfmem + MatrixIndexA.Tex0MtxIdx * 4, (const float *)xfmem + MatrixIndexA.Tex1MtxIdx * 4, (const float *)xfmem + MatrixIndexA.Tex0MtxIdx * 4, (const float *)xfmem + MatrixIndexA.Tex1MtxIdx * 4,
(const float *)xfmem + MatrixIndexA.Tex2MtxIdx * 4, (const float *)xfmem + MatrixIndexA.Tex3MtxIdx * 4 (const float *)xfmem + MatrixIndexA.Tex2MtxIdx * 4, (const float *)xfmem + MatrixIndexA.Tex3MtxIdx * 4
}; };
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
SetMultiVSConstant4fv(C_TEXMATRICES + 3 * i, 3, fptrs[i]); SetMultiVSConstant4fv(C_TEXMATRICES + 3 * i, 3, fptrs[i]);
} }
} }
if (bTexMatricesChanged[1]) if (bTexMatricesChanged[1])
{ {
bTexMatricesChanged[1] = false; bTexMatricesChanged[1] = false;
const float *fptrs[] = { const float *fptrs[] = {
(const float *)xfmem + MatrixIndexB.Tex4MtxIdx * 4, (const float *)xfmem + MatrixIndexB.Tex5MtxIdx * 4, (const float *)xfmem + MatrixIndexB.Tex4MtxIdx * 4, (const float *)xfmem + MatrixIndexB.Tex5MtxIdx * 4,
(const float *)xfmem + MatrixIndexB.Tex6MtxIdx * 4, (const float *)xfmem + MatrixIndexB.Tex7MtxIdx * 4 (const float *)xfmem + MatrixIndexB.Tex6MtxIdx * 4, (const float *)xfmem + MatrixIndexB.Tex7MtxIdx * 4
}; };
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
SetMultiVSConstant4fv(C_TEXMATRICES+3 * i + 12, 3, fptrs[i]); SetMultiVSConstant4fv(C_TEXMATRICES+3 * i + 12, 3, fptrs[i]);
} }
} }
if (bViewportChanged) if (bViewportChanged)
{ {
bViewportChanged = false; bViewportChanged = false;
// This is so implementation-dependent that we can't have it here. // This is so implementation-dependent that we can't have it here.
UpdateViewport(); UpdateViewport();
} }
if (bProjectionChanged) if (bProjectionChanged)
{ {
bProjectionChanged = false; bProjectionChanged = false;
if (xfregs.rawProjection[6] == 0) if (xfregs.rawProjection[6] == 0)
{ {
// Perspective // Perspective
g_fProjectionMatrix[0] = xfregs.rawProjection[0] * g_ActiveConfig.fAspectRatioHackW; g_fProjectionMatrix[0] = xfregs.rawProjection[0] * g_ActiveConfig.fAspectRatioHackW;
g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = xfregs.rawProjection[1]; g_fProjectionMatrix[2] = xfregs.rawProjection[1];
g_fProjectionMatrix[3] = 0.0f; g_fProjectionMatrix[3] = 0.0f;
g_fProjectionMatrix[4] = 0.0f; g_fProjectionMatrix[4] = 0.0f;
g_fProjectionMatrix[5] = xfregs.rawProjection[2] * g_ActiveConfig.fAspectRatioHackH; g_fProjectionMatrix[5] = xfregs.rawProjection[2] * g_ActiveConfig.fAspectRatioHackH;
g_fProjectionMatrix[6] = xfregs.rawProjection[3]; g_fProjectionMatrix[6] = xfregs.rawProjection[3];
g_fProjectionMatrix[7] = 0.0f; g_fProjectionMatrix[7] = 0.0f;
g_fProjectionMatrix[8] = 0.0f; g_fProjectionMatrix[8] = 0.0f;
g_fProjectionMatrix[9] = 0.0f; g_fProjectionMatrix[9] = 0.0f;
g_fProjectionMatrix[10] = xfregs.rawProjection[4]; g_fProjectionMatrix[10] = xfregs.rawProjection[4];
g_fProjectionMatrix[11] = xfregs.rawProjection[5]; g_fProjectionMatrix[11] = xfregs.rawProjection[5];
g_fProjectionMatrix[12] = 0.0f; g_fProjectionMatrix[12] = 0.0f;
g_fProjectionMatrix[13] = 0.0f; g_fProjectionMatrix[13] = 0.0f;
// donkopunchstania: GC GPU rounds differently? // donkopunchstania: GC GPU rounds differently?
// -(1 + epsilon) so objects are clipped as they are on the real HW // -(1 + epsilon) so objects are clipped as they are on the real HW
g_fProjectionMatrix[14] = -1.00000011921f; g_fProjectionMatrix[14] = -1.00000011921f;
g_fProjectionMatrix[15] = 0.0f; g_fProjectionMatrix[15] = 0.0f;
SETSTAT_FT(stats.gproj_0, g_fProjectionMatrix[0]); SETSTAT_FT(stats.gproj_0, g_fProjectionMatrix[0]);
SETSTAT_FT(stats.gproj_1, g_fProjectionMatrix[1]); SETSTAT_FT(stats.gproj_1, g_fProjectionMatrix[1]);
@ -328,29 +328,29 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]); SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]);
SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]); SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]);
SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]); SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]);
} }
else else
{ {
// Orthographic Projection // Orthographic Projection
g_fProjectionMatrix[0] = xfregs.rawProjection[0]; g_fProjectionMatrix[0] = xfregs.rawProjection[0];
g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = 0.0f; g_fProjectionMatrix[2] = 0.0f;
g_fProjectionMatrix[3] = xfregs.rawProjection[1]; g_fProjectionMatrix[3] = xfregs.rawProjection[1];
g_fProjectionMatrix[4] = 0.0f; g_fProjectionMatrix[4] = 0.0f;
g_fProjectionMatrix[5] = xfregs.rawProjection[2]; g_fProjectionMatrix[5] = xfregs.rawProjection[2];
g_fProjectionMatrix[6] = 0.0f; g_fProjectionMatrix[6] = 0.0f;
g_fProjectionMatrix[7] = xfregs.rawProjection[3]; g_fProjectionMatrix[7] = xfregs.rawProjection[3];
g_fProjectionMatrix[8] = 0.0f; g_fProjectionMatrix[8] = 0.0f;
g_fProjectionMatrix[9] = 0.0f; g_fProjectionMatrix[9] = 0.0f;
g_fProjectionMatrix[10] = (g_ProjHack1.enabled ? -(g_ProjHack1.value + xfregs.rawProjection[4]) : xfregs.rawProjection[4]); g_fProjectionMatrix[10] = (g_ProjHack1.enabled ? -(g_ProjHack1.value + xfregs.rawProjection[4]) : xfregs.rawProjection[4]);
g_fProjectionMatrix[11] = (g_ProjHack2.enabled ? -(g_ProjHack2.value + xfregs.rawProjection[5]) : xfregs.rawProjection[5]) + (g_ProjHack0 ? 0.1f : 0.0f); g_fProjectionMatrix[11] = (g_ProjHack2.enabled ? -(g_ProjHack2.value + xfregs.rawProjection[5]) : xfregs.rawProjection[5]) + (g_ProjHack0 ? 0.1f : 0.0f);
g_fProjectionMatrix[12] = 0.0f; g_fProjectionMatrix[12] = 0.0f;
g_fProjectionMatrix[13] = 0.0f; g_fProjectionMatrix[13] = 0.0f;
g_fProjectionMatrix[14] = 0.0f; g_fProjectionMatrix[14] = 0.0f;
g_fProjectionMatrix[15] = 1.0f; g_fProjectionMatrix[15] = 1.0f;
SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]); SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]);
SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]); SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]);
@ -375,140 +375,140 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.proj_4, xfregs.rawProjection[4]); SETSTAT_FT(stats.proj_4, xfregs.rawProjection[4]);
SETSTAT_FT(stats.proj_5, xfregs.rawProjection[5]); SETSTAT_FT(stats.proj_5, xfregs.rawProjection[5]);
SETSTAT_FT(stats.proj_6, xfregs.rawProjection[6]); SETSTAT_FT(stats.proj_6, xfregs.rawProjection[6]);
} }
PRIM_LOG("Projection: %f %f %f %f %f %f\n", xfregs.rawProjection[0], xfregs.rawProjection[1], xfregs.rawProjection[2], xfregs.rawProjection[3], xfregs.rawProjection[4], xfregs.rawProjection[5]); PRIM_LOG("Projection: %f %f %f %f %f %f\n", xfregs.rawProjection[0], xfregs.rawProjection[1], xfregs.rawProjection[2], xfregs.rawProjection[3], xfregs.rawProjection[4], xfregs.rawProjection[5]);
if (g_ActiveConfig.bFreeLook) if (g_ActiveConfig.bFreeLook)
{ {
Matrix44 mtxA; Matrix44 mtxA;
Matrix44 mtxB; Matrix44 mtxB;
Matrix44 viewMtx; Matrix44 viewMtx;
Matrix44::Translate(mtxA, s_fViewTranslationVector); Matrix44::Translate(mtxA, s_fViewTranslationVector);
Matrix44::LoadMatrix33(mtxB, s_viewRotationMatrix); Matrix44::LoadMatrix33(mtxB, s_viewRotationMatrix);
Matrix44::Multiply(mtxB, mtxA, viewMtx); // view = rotation x translation Matrix44::Multiply(mtxB, mtxA, viewMtx); // view = rotation x translation
Matrix44::Set(mtxB, g_fProjectionMatrix); Matrix44::Set(mtxB, g_fProjectionMatrix);
Matrix44::Multiply(mtxB, viewMtx, mtxA); // mtxA = projection x view Matrix44::Multiply(mtxB, viewMtx, mtxA); // mtxA = projection x view
SetMultiVSConstant4fv(C_PROJECTION, 4, &mtxA.data[0]); SetMultiVSConstant4fv(C_PROJECTION, 4, &mtxA.data[0]);
} }
else else
{ {
SetMultiVSConstant4fv(C_PROJECTION, 4, &g_fProjectionMatrix[0]); SetMultiVSConstant4fv(C_PROJECTION, 4, &g_fProjectionMatrix[0]);
} }
} }
} }
void VertexShaderManager::InvalidateXFRange(int start, int end) void VertexShaderManager::InvalidateXFRange(int start, int end)
{ {
if (((u32)start >= (u32)MatrixIndexA.PosNormalMtxIdx * 4 && if (((u32)start >= (u32)MatrixIndexA.PosNormalMtxIdx * 4 &&
(u32)start < (u32)MatrixIndexA.PosNormalMtxIdx * 4 + 12) || (u32)start < (u32)MatrixIndexA.PosNormalMtxIdx * 4 + 12) ||
((u32)start >= XFMEM_NORMALMATRICES + ((u32)MatrixIndexA.PosNormalMtxIdx & 31) * 3 && ((u32)start >= XFMEM_NORMALMATRICES + ((u32)MatrixIndexA.PosNormalMtxIdx & 31) * 3 &&
(u32)start < XFMEM_NORMALMATRICES + ((u32)MatrixIndexA.PosNormalMtxIdx & 31) * 3 + 9)) { (u32)start < XFMEM_NORMALMATRICES + ((u32)MatrixIndexA.PosNormalMtxIdx & 31) * 3 + 9)) {
bPosNormalMatrixChanged = true; bPosNormalMatrixChanged = true;
} }
if (((u32)start >= (u32)MatrixIndexA.Tex0MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex0MtxIdx*4+12) || if (((u32)start >= (u32)MatrixIndexA.Tex0MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex0MtxIdx*4+12) ||
((u32)start >= (u32)MatrixIndexA.Tex1MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex1MtxIdx*4+12) || ((u32)start >= (u32)MatrixIndexA.Tex1MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex1MtxIdx*4+12) ||
((u32)start >= (u32)MatrixIndexA.Tex2MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex2MtxIdx*4+12) || ((u32)start >= (u32)MatrixIndexA.Tex2MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex2MtxIdx*4+12) ||
((u32)start >= (u32)MatrixIndexA.Tex3MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex3MtxIdx*4+12)) { ((u32)start >= (u32)MatrixIndexA.Tex3MtxIdx*4 && (u32)start < (u32)MatrixIndexA.Tex3MtxIdx*4+12)) {
bTexMatricesChanged[0] = true; bTexMatricesChanged[0] = true;
} }
if (((u32)start >= (u32)MatrixIndexB.Tex4MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex4MtxIdx*4+12) || if (((u32)start >= (u32)MatrixIndexB.Tex4MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex4MtxIdx*4+12) ||
((u32)start >= (u32)MatrixIndexB.Tex5MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex5MtxIdx*4+12) || ((u32)start >= (u32)MatrixIndexB.Tex5MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex5MtxIdx*4+12) ||
((u32)start >= (u32)MatrixIndexB.Tex6MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex6MtxIdx*4+12) || ((u32)start >= (u32)MatrixIndexB.Tex6MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex6MtxIdx*4+12) ||
((u32)start >= (u32)MatrixIndexB.Tex7MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex7MtxIdx*4+12)) { ((u32)start >= (u32)MatrixIndexB.Tex7MtxIdx*4 && (u32)start < (u32)MatrixIndexB.Tex7MtxIdx*4+12)) {
bTexMatricesChanged[1] = true; bTexMatricesChanged[1] = true;
} }
if (start < XFMEM_POSMATRICES_END) if (start < XFMEM_POSMATRICES_END)
{ {
if (nTransformMatricesChanged[0] == -1) if (nTransformMatricesChanged[0] == -1)
{ {
nTransformMatricesChanged[0] = start; nTransformMatricesChanged[0] = start;
nTransformMatricesChanged[1] = end>XFMEM_POSMATRICES_END?XFMEM_POSMATRICES_END:end; nTransformMatricesChanged[1] = end>XFMEM_POSMATRICES_END?XFMEM_POSMATRICES_END:end;
} }
else else
{ {
if (nTransformMatricesChanged[0] > start) nTransformMatricesChanged[0] = start; if (nTransformMatricesChanged[0] > start) nTransformMatricesChanged[0] = start;
if (nTransformMatricesChanged[1] < end) nTransformMatricesChanged[1] = end>XFMEM_POSMATRICES_END?XFMEM_POSMATRICES_END:end; if (nTransformMatricesChanged[1] < end) nTransformMatricesChanged[1] = end>XFMEM_POSMATRICES_END?XFMEM_POSMATRICES_END:end;
} }
} }
if (start < XFMEM_NORMALMATRICES_END && end > XFMEM_NORMALMATRICES) if (start < XFMEM_NORMALMATRICES_END && end > XFMEM_NORMALMATRICES)
{ {
int _start = start < XFMEM_NORMALMATRICES ? 0 : start-XFMEM_NORMALMATRICES; int _start = start < XFMEM_NORMALMATRICES ? 0 : start-XFMEM_NORMALMATRICES;
int _end = end < XFMEM_NORMALMATRICES_END ? end-XFMEM_NORMALMATRICES : XFMEM_NORMALMATRICES_END-XFMEM_NORMALMATRICES; int _end = end < XFMEM_NORMALMATRICES_END ? end-XFMEM_NORMALMATRICES : XFMEM_NORMALMATRICES_END-XFMEM_NORMALMATRICES;
if (nNormalMatricesChanged[0] == -1) if (nNormalMatricesChanged[0] == -1)
{ {
nNormalMatricesChanged[0] = _start; nNormalMatricesChanged[0] = _start;
nNormalMatricesChanged[1] = _end; nNormalMatricesChanged[1] = _end;
} }
else else
{ {
if (nNormalMatricesChanged[0] > _start) nNormalMatricesChanged[0] = _start; if (nNormalMatricesChanged[0] > _start) nNormalMatricesChanged[0] = _start;
if (nNormalMatricesChanged[1] < _end) nNormalMatricesChanged[1] = _end; if (nNormalMatricesChanged[1] < _end) nNormalMatricesChanged[1] = _end;
} }
} }
if (start < XFMEM_POSTMATRICES_END && end > XFMEM_POSTMATRICES) if (start < XFMEM_POSTMATRICES_END && end > XFMEM_POSTMATRICES)
{ {
int _start = start < XFMEM_POSTMATRICES ? XFMEM_POSTMATRICES : start-XFMEM_POSTMATRICES; int _start = start < XFMEM_POSTMATRICES ? XFMEM_POSTMATRICES : start-XFMEM_POSTMATRICES;
int _end = end < XFMEM_POSTMATRICES_END ? end-XFMEM_POSTMATRICES : XFMEM_POSTMATRICES_END-XFMEM_POSTMATRICES; int _end = end < XFMEM_POSTMATRICES_END ? end-XFMEM_POSTMATRICES : XFMEM_POSTMATRICES_END-XFMEM_POSTMATRICES;
if (nPostTransformMatricesChanged[0] == -1) if (nPostTransformMatricesChanged[0] == -1)
{ {
nPostTransformMatricesChanged[0] = _start; nPostTransformMatricesChanged[0] = _start;
nPostTransformMatricesChanged[1] = _end; nPostTransformMatricesChanged[1] = _end;
} }
else else
{ {
if (nPostTransformMatricesChanged[0] > _start) nPostTransformMatricesChanged[0] = _start; if (nPostTransformMatricesChanged[0] > _start) nPostTransformMatricesChanged[0] = _start;
if (nPostTransformMatricesChanged[1] < _end) nPostTransformMatricesChanged[1] = _end; if (nPostTransformMatricesChanged[1] < _end) nPostTransformMatricesChanged[1] = _end;
} }
} }
if (start < XFMEM_LIGHTS_END && end > XFMEM_LIGHTS) if (start < XFMEM_LIGHTS_END && end > XFMEM_LIGHTS)
{ {
int _start = start < XFMEM_LIGHTS ? XFMEM_LIGHTS : start-XFMEM_LIGHTS; int _start = start < XFMEM_LIGHTS ? XFMEM_LIGHTS : start-XFMEM_LIGHTS;
int _end = end < XFMEM_LIGHTS_END ? end-XFMEM_LIGHTS : XFMEM_LIGHTS_END-XFMEM_LIGHTS; int _end = end < XFMEM_LIGHTS_END ? end-XFMEM_LIGHTS : XFMEM_LIGHTS_END-XFMEM_LIGHTS;
if (nLightsChanged[0] == -1 ) if (nLightsChanged[0] == -1 )
{ {
nLightsChanged[0] = _start; nLightsChanged[0] = _start;
nLightsChanged[1] = _end; nLightsChanged[1] = _end;
} }
else else
{ {
if (nLightsChanged[0] > _start) nLightsChanged[0] = _start; if (nLightsChanged[0] > _start) nLightsChanged[0] = _start;
if (nLightsChanged[1] < _end) nLightsChanged[1] = _end; if (nLightsChanged[1] < _end) nLightsChanged[1] = _end;
} }
} }
} }
void VertexShaderManager::SetTexMatrixChangedA(u32 Value) void VertexShaderManager::SetTexMatrixChangedA(u32 Value)
{ {
if (MatrixIndexA.Hex != Value) if (MatrixIndexA.Hex != Value)
{ {
VertexManager::Flush(); VertexManager::Flush();
if (MatrixIndexA.PosNormalMtxIdx != (Value&0x3f)) if (MatrixIndexA.PosNormalMtxIdx != (Value&0x3f))
bPosNormalMatrixChanged = true; bPosNormalMatrixChanged = true;
bTexMatricesChanged[0] = true; bTexMatricesChanged[0] = true;
MatrixIndexA.Hex = Value; MatrixIndexA.Hex = Value;
} }
} }
void VertexShaderManager::SetTexMatrixChangedB(u32 Value) void VertexShaderManager::SetTexMatrixChangedB(u32 Value)
{ {
if (MatrixIndexB.Hex != Value) if (MatrixIndexB.Hex != Value)
{ {
VertexManager::Flush(); VertexManager::Flush();
bTexMatricesChanged[1] = true; bTexMatricesChanged[1] = true;
MatrixIndexB.Hex = Value; MatrixIndexB.Hex = Value;
} }
} }
void VertexShaderManager::SetViewport(float* _Viewport, int constantIndex) void VertexShaderManager::SetViewport(float* _Viewport, int constantIndex)
@ -521,20 +521,20 @@ void VertexShaderManager::SetViewport(float* _Viewport, int constantIndex)
{ {
xfregs.rawViewport[constantIndex] = _Viewport[0]; xfregs.rawViewport[constantIndex] = _Viewport[0];
} }
/*//Tino: i think this is nod needed so let this commented til confirmed /*//Tino: i think this is not needed so leave this commented till confirmed
// Workaround for paper mario, yep this is bizarre. // Workaround for paper mario, yep this is bizarre.
for (size_t i = 0; i < ARRAYSIZE(xfregs.rawViewport); ++i) for (size_t i = 0; i < ARRAYSIZE(xfregs.rawViewport); ++i)
{ {
if (*(u32*)(_Viewport + i) == 0x7f800000) // invalid fp number if (*(u32*)(_Viewport + i) == 0x7f800000) // invalid fp number
return; return;
} }
memcpy(xfregs.rawViewport, _Viewport, sizeof(xfregs.rawViewport));*/ memcpy(xfregs.rawViewport, _Viewport, sizeof(xfregs.rawViewport));*/
bViewportChanged = true; bViewportChanged = true;
} }
void VertexShaderManager::SetViewportChanged() void VertexShaderManager::SetViewportChanged()
{ {
bViewportChanged = true; bViewportChanged = true;
} }
void VertexShaderManager::SetProjection(float* _pProjection, int constantIndex) void VertexShaderManager::SetProjection(float* _pProjection, int constantIndex)
@ -547,7 +547,7 @@ void VertexShaderManager::SetProjection(float* _pProjection, int constantIndex)
{ {
xfregs.rawProjection[constantIndex] = _pProjection[0]; xfregs.rawProjection[constantIndex] = _pProjection[0];
} }
bProjectionChanged = true; bProjectionChanged = true;
} }
void VertexShaderManager::SetMaterialColor(int index, u32 data) void VertexShaderManager::SetMaterialColor(int index, u32 data)
@ -564,42 +564,42 @@ void VertexShaderManager::SetMaterialColor(int index, u32 data)
void VertexShaderManager::TranslateView(float x, float y) void VertexShaderManager::TranslateView(float x, float y)
{ {
float result[3]; float result[3];
float vector[3] = { x,0,y }; float vector[3] = { x,0,y };
Matrix33::Multiply(s_viewInvRotationMatrix, vector, result); Matrix33::Multiply(s_viewInvRotationMatrix, vector, result);
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
s_fViewTranslationVector[i] += result[i]; s_fViewTranslationVector[i] += result[i];
bProjectionChanged = true; bProjectionChanged = true;
} }
void VertexShaderManager::RotateView(float x, float y) void VertexShaderManager::RotateView(float x, float y)
{ {
s_fViewRotation[0] += x; s_fViewRotation[0] += x;
s_fViewRotation[1] += y; s_fViewRotation[1] += y;
Matrix33 mx; Matrix33 mx;
Matrix33 my; Matrix33 my;
Matrix33::RotateX(mx, s_fViewRotation[1]); Matrix33::RotateX(mx, s_fViewRotation[1]);
Matrix33::RotateY(my, s_fViewRotation[0]); Matrix33::RotateY(my, s_fViewRotation[0]);
Matrix33::Multiply(mx, my, s_viewRotationMatrix); Matrix33::Multiply(mx, my, s_viewRotationMatrix);
// reverse rotation // reverse rotation
Matrix33::RotateX(mx, -s_fViewRotation[1]); Matrix33::RotateX(mx, -s_fViewRotation[1]);
Matrix33::RotateY(my, -s_fViewRotation[0]); Matrix33::RotateY(my, -s_fViewRotation[0]);
Matrix33::Multiply(my, mx, s_viewInvRotationMatrix); Matrix33::Multiply(my, mx, s_viewInvRotationMatrix);
bProjectionChanged = true; bProjectionChanged = true;
} }
void VertexShaderManager::ResetView() void VertexShaderManager::ResetView()
{ {
memset(s_fViewTranslationVector, 0, sizeof(s_fViewTranslationVector)); memset(s_fViewTranslationVector, 0, sizeof(s_fViewTranslationVector));
Matrix33::LoadIdentity(s_viewRotationMatrix); Matrix33::LoadIdentity(s_viewRotationMatrix);
Matrix33::LoadIdentity(s_viewInvRotationMatrix); Matrix33::LoadIdentity(s_viewInvRotationMatrix);
s_fViewRotation[0] = s_fViewRotation[1] = 0.0f; s_fViewRotation[0] = s_fViewRotation[1] = 0.0f;
bProjectionChanged = true; bProjectionChanged = true;
} }

View file

@ -43,53 +43,53 @@ VideoConfig::VideoConfig()
void VideoConfig::Load(const char *ini_file) void VideoConfig::Load(const char *ini_file)
{ {
std::string temp; std::string temp;
IniFile iniFile; IniFile iniFile;
iniFile.Load(ini_file); iniFile.Load(ini_file);
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true); iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true);
iniFile.Get("Settings", "2xResolution", &b2xResolution, false); iniFile.Get("Settings", "2xResolution", &b2xResolution, false);
iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false); iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false);
iniFile.Get("Settings", "AspectRatio", &iAspectRatio, (int)ASPECT_AUTO); iniFile.Get("Settings", "AspectRatio", &iAspectRatio, (int)ASPECT_AUTO);
iniFile.Get("Settings", "Crop", &bCrop, false); iniFile.Get("Settings", "Crop", &bCrop, false);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0); iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0); iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0);
iniFile.Get("Settings", "AutoScale", &bAutoScale, true); iniFile.Get("Settings", "AutoScale", &bAutoScale, true);
iniFile.Get("Settings", "UseNativeMips", &bUseNativeMips, true); iniFile.Get("Settings", "UseNativeMips", &bUseNativeMips, true);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
//Safe texture cache params //Safe texture cache params
iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512); iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512);
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false); iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "OverlayProjStats", &bOverlayProjStats, false); iniFile.Get("Settings", "OverlayProjStats", &bOverlayProjStats, false);
iniFile.Get("Settings", "ShowEFBCopyRegions", &bShowEFBCopyRegions, false); iniFile.Get("Settings", "ShowEFBCopyRegions", &bShowEFBCopyRegions, false);
iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0); iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0);
iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0); iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0);
iniFile.Get("Settings", "HiresTextures", &bHiresTextures, 0); iniFile.Get("Settings", "HiresTextures", &bHiresTextures, 0);
iniFile.Get("Settings", "DumpEFBTarget", &bDumpEFBTarget, 0); iniFile.Get("Settings", "DumpEFBTarget", &bDumpEFBTarget, 0);
iniFile.Get("Settings", "DumpFrames", &bDumpFrames, 0); iniFile.Get("Settings", "DumpFrames", &bDumpFrames, 0);
iniFile.Get("Settings", "FreeLook", &bFreeLook, 0); iniFile.Get("Settings", "FreeLook", &bFreeLook, 0);
iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0); iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0);
iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0); iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Settings", "DstAlphaPass", &bDstAlphaPass, false); iniFile.Get("Settings", "DstAlphaPass", &bDstAlphaPass, false);
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0); iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0); iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0); iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0); iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0);
iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0); iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0);
iniFile.Get("Settings", "DisableFog", &bDisableFog, 0); iniFile.Get("Settings", "DisableFog", &bDisableFog, 0);
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0); iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 1); // NOTE - this is x in (1 << x) iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 1); // NOTE - this is x in (1 << x)
iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, ""); iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, "");
iniFile.Get("Hacks", "EFBAccessEnable", &bEFBAccessEnable, true); iniFile.Get("Hacks", "EFBAccessEnable", &bEFBAccessEnable, true);
iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, false); iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, false);
iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bOSDHotKey, 0); iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bOSDHotKey, 0);
iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToTexture, false); iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToTexture, false);
iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true); iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true);
iniFile.Get("Hacks", "FIFOBPHack", &bFIFOBPhack, false); iniFile.Get("Hacks", "FIFOBPHack", &bFIFOBPhack, false);
@ -109,8 +109,8 @@ void VideoConfig::Load(const char *ini_file)
void VideoConfig::GameIniLoad(const char *ini_file) void VideoConfig::GameIniLoad(const char *ini_file)
{ {
IniFile iniFile; IniFile iniFile;
iniFile.Load(ini_file); iniFile.Load(ini_file);
if (iniFile.Exists("Video", "ForceFiltering")) if (iniFile.Exists("Video", "ForceFiltering"))
iniFile.Get("Video", "ForceFiltering", &bForceFiltering); iniFile.Get("Video", "ForceFiltering", &bForceFiltering);
@ -148,51 +148,51 @@ void VideoConfig::GameIniLoad(const char *ini_file)
void VideoConfig::Save(const char *ini_file) void VideoConfig::Save(const char *ini_file)
{ {
IniFile iniFile; IniFile iniFile;
iniFile.Load(ini_file); iniFile.Load(ini_file);
iniFile.Set("Hardware", "VSync", bVSync); iniFile.Set("Hardware", "VSync", bVSync);
iniFile.Set("Settings", "StretchToFit", bNativeResolution); iniFile.Set("Settings", "StretchToFit", bNativeResolution);
iniFile.Set("Settings", "2xResolution", b2xResolution); iniFile.Set("Settings", "2xResolution", b2xResolution);
iniFile.Set("Settings", "AspectRatio", iAspectRatio); iniFile.Set("Settings", "AspectRatio", iAspectRatio);
iniFile.Set("Settings", "Crop", bCrop); iniFile.Set("Settings", "Crop", bCrop);
iniFile.Set("Settings", "wideScreenHack", bWidescreenHack); iniFile.Set("Settings", "wideScreenHack", bWidescreenHack);
iniFile.Set("Settings", "UseXFB", bUseXFB); iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "UseRealXFB", bUseRealXFB); iniFile.Set("Settings", "UseRealXFB", bUseRealXFB);
iniFile.Set("Settings", "AutoScale", bAutoScale); iniFile.Set("Settings", "AutoScale", bAutoScale);
iniFile.Set("Settings", "UseNativeMips", bUseNativeMips); iniFile.Set("Settings", "UseNativeMips", bUseNativeMips);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache); iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
//safe texture cache params //safe texture cache params
iniFile.Set("Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples); iniFile.Set("Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
iniFile.Set("Settings", "ShowFPS", bShowFPS); iniFile.Set("Settings", "ShowFPS", bShowFPS);
iniFile.Set("Settings", "OverlayStats", bOverlayStats); iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "OverlayProjStats", bOverlayProjStats); iniFile.Set("Settings", "OverlayProjStats", bOverlayProjStats);
iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel); iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel);
iniFile.Set("Settings", "Show", iCompileDLsLevel); iniFile.Set("Settings", "Show", iCompileDLsLevel);
iniFile.Set("Settings", "DumpTextures", bDumpTextures); iniFile.Set("Settings", "DumpTextures", bDumpTextures);
iniFile.Set("Settings", "HiresTextures", bHiresTextures); iniFile.Set("Settings", "HiresTextures", bHiresTextures);
iniFile.Set("Settings", "DumpEFBTarget", bDumpEFBTarget); iniFile.Set("Settings", "DumpEFBTarget", bDumpEFBTarget);
iniFile.Set("Settings", "DumpFrames", bDumpFrames); iniFile.Set("Settings", "DumpFrames", bDumpFrames);
iniFile.Set("Settings", "FreeLook", bFreeLook); iniFile.Set("Settings", "FreeLook", bFreeLook);
iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions); iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions);
iniFile.Set("Settings", "ShowShaderErrors", bShowShaderErrors); iniFile.Set("Settings", "ShowShaderErrors", bShowShaderErrors);
iniFile.Set("Settings", "MSAA", iMultisampleMode); iniFile.Set("Settings", "MSAA", iMultisampleMode);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable); iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter); iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Settings", "Wireframe", bWireFrame); iniFile.Set("Settings", "Wireframe", bWireFrame);
iniFile.Set("Settings", "DisableLighting", bDisableLighting); iniFile.Set("Settings", "DisableLighting", bDisableLighting);
iniFile.Set("Settings", "DisableTexturing", bDisableTexturing); iniFile.Set("Settings", "DisableTexturing", bDisableTexturing);
iniFile.Set("Settings", "DstAlphaPass", bDstAlphaPass); iniFile.Set("Settings", "DstAlphaPass", bDstAlphaPass);
iniFile.Set("Settings", "DisableFog", bDisableFog); iniFile.Set("Settings", "DisableFog", bDisableFog);
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering); iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy); iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader); iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader);
iniFile.Set("Hacks", "EFBAccessEnable", bEFBAccessEnable); iniFile.Set("Hacks", "EFBAccessEnable", bEFBAccessEnable);
iniFile.Set("Hacks", "EFBCopyDisable", bEFBCopyDisable); iniFile.Set("Hacks", "EFBCopyDisable", bEFBCopyDisable);
iniFile.Set("Hacks", "EFBCopyDisableHotKey", bOSDHotKey); iniFile.Set("Hacks", "EFBCopyDisableHotKey", bOSDHotKey);
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToTexture); iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToTexture);
iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled); iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled);
iniFile.Set("Hacks", "FIFOBPHack", bFIFOBPhack); iniFile.Set("Hacks", "FIFOBPHack", bFIFOBPhack);
@ -201,7 +201,7 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Hardware", "Adapter", iAdapter); iniFile.Set("Hardware", "Adapter", iAdapter);
iniFile.Set("Hardware", "SimpleFB", bSimpleFB); iniFile.Set("Hardware", "SimpleFB", bSimpleFB);
iniFile.Save(ini_file); iniFile.Save(ini_file);
} }
// TODO: Figure out a better place for this function. // TODO: Figure out a better place for this function.

View file

@ -60,60 +60,60 @@ class IniFile;
// NEVER inherit from this class. // NEVER inherit from this class.
struct VideoConfig struct VideoConfig
{ {
VideoConfig(); VideoConfig();
void Load(const char *ini_file); void Load(const char *ini_file);
void GameIniLoad(const char *ini_file); void GameIniLoad(const char *ini_file);
void Save(const char *ini_file); void Save(const char *ini_file);
void UpdateProjectionHack(); void UpdateProjectionHack();
// General // General
bool bVSync; bool bVSync;
bool bNativeResolution, b2xResolution, bRunning; // Should possibly be augmented with 2x, 4x native. bool bNativeResolution, b2xResolution, bRunning; // Should possibly be augmented with 2x, 4x native.
bool bWidescreenHack; bool bWidescreenHack;
int iAspectRatio; int iAspectRatio;
bool bCrop; // Aspect ratio controls. bool bCrop; // Aspect ratio controls.
bool bUseXFB; bool bUseXFB;
bool bUseRealXFB; bool bUseRealXFB;
bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly. bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly.
bool bUseNativeMips; bool bUseNativeMips;
// Enhancements // Enhancements
int iMultisampleMode; int iMultisampleMode;
bool bForceFiltering; bool bForceFiltering;
int iMaxAnisotropy; int iMaxAnisotropy;
std::string sPostProcessingShader; std::string sPostProcessingShader;
// Information // Information
bool bShowFPS; bool bShowFPS;
bool bOverlayStats; bool bOverlayStats;
bool bOverlayProjStats; bool bOverlayProjStats;
bool bTexFmtOverlayEnable; bool bTexFmtOverlayEnable;
bool bTexFmtOverlayCenter; bool bTexFmtOverlayCenter;
bool bShowEFBCopyRegions; bool bShowEFBCopyRegions;
// Render // Render
bool bWireFrame; bool bWireFrame;
bool bDisableLighting; bool bDisableLighting;
bool bDisableTexturing; bool bDisableTexturing;
bool bDstAlphaPass; bool bDstAlphaPass;
bool bDisableFog; bool bDisableFog;
// Utility // Utility
bool bDumpTextures; bool bDumpTextures;
bool bHiresTextures; bool bHiresTextures;
bool bDumpEFBTarget; bool bDumpEFBTarget;
bool bDumpFrames; bool bDumpFrames;
bool bFreeLook; bool bFreeLook;
// Hacks // Hacks
bool bEFBAccessEnable; bool bEFBAccessEnable;
bool bEFBCopyDisable; // should reverse polarity of this one :) true=disabled can be confusing bool bEFBCopyDisable; // should reverse polarity of this one :) true=disabled can be confusing
bool bOSDHotKey; bool bOSDHotKey;
bool bHack; bool bHack;
bool bCopyEFBToTexture; bool bCopyEFBToTexture;
bool bCopyEFBScaled; bool bCopyEFBScaled;
bool bSafeTextureCache; bool bSafeTextureCache;
int iSafeTextureCache_ColorSamples; int iSafeTextureCache_ColorSamples;
bool bFIFOBPhack; bool bFIFOBPhack;
int iPhackvalue; int iPhackvalue;
@ -122,12 +122,12 @@ struct VideoConfig
bool bProjHack1; bool bProjHack1;
float fAspectRatioHackW, fAspectRatioHackH; float fAspectRatioHackW, fAspectRatioHackH;
int iLog; // CONF_ bits int iLog; // CONF_ bits
int iSaveTargetId; int iSaveTargetId;
//currently unused: //currently unused:
int iCompileDLsLevel; int iCompileDLsLevel;
bool bShowShaderErrors; bool bShowShaderErrors;
// D3D only config, mostly to be merged into the above // D3D only config, mostly to be merged into the above
int iAdapter; int iAdapter;

View file

@ -23,7 +23,6 @@ enum PLUGIN_COMM
WM_USER_CREATE, WM_USER_CREATE,
WM_USER_SETCURSOR, WM_USER_SETCURSOR,
WM_USER_KEYDOWN, WM_USER_KEYDOWN,
WM_USER_VIDEO_STOP,
VIDEO_DESTROY, // The video debugging window was destroyed VIDEO_DESTROY, // The video debugging window was destroyed
AUDIO_DESTROY, // The audio debugging window was destroyed AUDIO_DESTROY, // The audio debugging window was destroyed
WIIMOTE_DISCONNECT, // Disconnect Wiimote WIIMOTE_DISCONNECT, // Disconnect Wiimote
@ -62,13 +61,13 @@ enum PLUGIN_COMM
// Plugin types // Plugin types
enum PLUGIN_TYPE { enum PLUGIN_TYPE {
PLUGIN_TYPE_VIDEO = 1, PLUGIN_TYPE_VIDEO = 1,
PLUGIN_TYPE_DVD, PLUGIN_TYPE_DVD,
PLUGIN_TYPE_PAD, PLUGIN_TYPE_PAD,
PLUGIN_TYPE_AUDIO, PLUGIN_TYPE_AUDIO,
PLUGIN_TYPE_COMPILER, PLUGIN_TYPE_COMPILER,
PLUGIN_TYPE_DSP, PLUGIN_TYPE_DSP,
PLUGIN_TYPE_WIIMOTE, PLUGIN_TYPE_WIIMOTE,
}; };
#define STATE_MODE_READ 1 #define STATE_MODE_READ 1
@ -100,8 +99,8 @@ typedef struct
// This design is just wrong and ugly - the plugins shouldn't have this much access. // This design is just wrong and ugly - the plugins shouldn't have this much access.
typedef struct typedef struct
{ {
void *eventHandler; void *eventHandler;
void *logManager; void *logManager;
char game_ini[MAX_PATH]; char game_ini[MAX_PATH];
char unique_id[16]; char unique_id[16];
} PLUGIN_GLOBALS; } PLUGIN_GLOBALS;

View file

@ -22,12 +22,12 @@
struct CConfig struct CConfig
{ {
bool m_EnableHLEAudio; bool m_EnableHLEAudio;
CConfig(); CConfig();
void Load(); void Load();
void Save(); void Save();
}; };
extern CConfig g_Config; extern CConfig g_Config;

View file

@ -95,7 +95,7 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
void DSPConfigDialogHLE::AddBackend(const char* backend) void DSPConfigDialogHLE::AddBackend(const char* backend)
{ {
// Update values // Update values
m_BackendSelection->Append(wxString::FromAscii(backend)); m_BackendSelection->Append(wxString::FromAscii(backend));
#ifdef __APPLE__ #ifdef __APPLE__
int num = m_BackendSelection->FindString(wxString::FromAscii(ac_Config.sBackend)); int num = m_BackendSelection->FindString(wxString::FromAscii(ac_Config.sBackend));
#else #else
@ -145,7 +145,7 @@ bool DSPConfigDialogHLE::SupportsVolumeChanges(std::string backend)
// but getting the backend from string etc. is probably // but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider... // too much just to enable/disable a stupid slider...
return (backend == BACKEND_DIRECTSOUND || return (backend == BACKEND_DIRECTSOUND ||
backend == BACKEND_OPENAL); backend == BACKEND_OPENAL);
} }
void DSPConfigDialogHLE::BackendChanged(wxCommandEvent& event) void DSPConfigDialogHLE::BackendChanged(wxCommandEvent& event)

View file

@ -28,38 +28,38 @@ class DSPConfigDialogHLE : public wxDialog
{ {
public: public:
DSPConfigDialogHLE(wxWindow *parent, DSPConfigDialogHLE(wxWindow *parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxString &title = wxT("Dolphin DSP-HLE Plugin Settings"), const wxString &title = wxT("Dolphin DSP-HLE Plugin Settings"),
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE); long style = wxDEFAULT_DIALOG_STYLE);
virtual ~DSPConfigDialogHLE(); virtual ~DSPConfigDialogHLE();
void AddBackend(const char *backend); void AddBackend(const char *backend);
void ClearBackends(); void ClearBackends();
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
wxSlider *m_volumeSlider; wxSlider* m_volumeSlider;
wxStaticText *m_volumeText; wxStaticText* m_volumeText;
wxButton *m_OK; wxButton* m_OK;
wxCheckBox *m_buttonEnableHLEAudio; wxCheckBox* m_buttonEnableHLEAudio;
wxCheckBox *m_buttonEnableDTKMusic; wxCheckBox* m_buttonEnableDTKMusic;
wxCheckBox *m_buttonEnableThrottle; wxCheckBox* m_buttonEnableThrottle;
wxArrayString wxArrayBackends; wxArrayString wxArrayBackends;
wxChoice *m_BackendSelection; wxChoice* m_BackendSelection;
enum enum
{ {
ID_ENABLE_HLE_AUDIO, ID_ENABLE_HLE_AUDIO,
ID_ENABLE_DTK_MUSIC, ID_ENABLE_DTK_MUSIC,
ID_ENABLE_THROTTLE, ID_ENABLE_THROTTLE,
ID_BACKEND, ID_BACKEND,
ID_VOLUME ID_VOLUME
}; };
void OnOK(wxCommandEvent& event); void OnOK(wxCommandEvent& event);
void SettingsChanged(wxCommandEvent& event); void SettingsChanged(wxCommandEvent& event);
void VolumeChanged(wxScrollEvent& event); void VolumeChanged(wxScrollEvent& event);
bool SupportsVolumeChanges(std::string backend); bool SupportsVolumeChanges(std::string backend);
void BackendChanged(wxCommandEvent& event); void BackendChanged(wxCommandEvent& event);

View file

@ -129,13 +129,11 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo)
_PluginInfo->Version = 0x0100; _PluginInfo->Version = 0x0100;
_PluginInfo->Type = PLUGIN_TYPE_DSP; _PluginInfo->Type = PLUGIN_TYPE_DSP;
#ifdef DEBUGFAST #ifdef DEBUGFAST
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (DebugFast) "); sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (DebugFast)");
#elif defined _DEBUG
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (Debug)");
#else #else
#ifndef _DEBUG sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin");
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin ");
#else
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (Debug) ");
#endif
#endif #endif
} }
@ -143,7 +141,7 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo)
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
{ {
globals = _pPluginGlobals; globals = _pPluginGlobals;
LogManager::SetInstance((LogManager *)globals->logManager); LogManager::SetInstance((LogManager*)globals->logManager);
} }
void DllConfig(HWND _hParent) void DllConfig(HWND _hParent)
@ -198,10 +196,6 @@ void Initialize(void *init)
CDSPHandler::CreateInstance(); CDSPHandler::CreateInstance();
} }
void DSP_StopSoundStream()
{
}
void Shutdown() void Shutdown()
{ {
AudioCommon::ShutdownSoundStream(); AudioCommon::ShutdownSoundStream();

View file

@ -312,14 +312,15 @@ void Close()
if (back_buffer_z) if (back_buffer_z)
back_buffer_z->Release(); back_buffer_z->Release();
back_buffer_z = NULL; back_buffer_z = NULL;
back_buffer->Release(); if( back_buffer )
back_buffer->Release();
back_buffer = NULL; back_buffer = NULL;
ULONG references = dev->Release(); ULONG references = dev->Release();
if (references) if (references)
ERROR_LOG(VIDEO, "Unreleased references: %i.", references); ERROR_LOG(VIDEO, "Unreleased references: %i.", references);
dev = 0; dev = NULL;
} }
const D3DCAPS9 &GetCaps() const D3DCAPS9 &GetCaps()
@ -355,12 +356,20 @@ void ShowD3DError(HRESULT err)
{ {
switch (err) switch (err)
{ {
case D3DERR_DEVICELOST: PanicAlert("Device Lost"); break; case D3DERR_DEVICELOST:
case D3DERR_INVALIDCALL: PanicAlert("Invalid Call"); break; PanicAlert("Device Lost");
case D3DERR_DRIVERINTERNALERROR: PanicAlert("Driver Internal Error"); break; break;
case D3DERR_OUTOFVIDEOMEMORY: PanicAlert("Out of vid mem"); break; case D3DERR_INVALIDCALL:
PanicAlert("Invalid Call");
break;
case D3DERR_DRIVERINTERNALERROR:
PanicAlert("Driver Internal Error");
break;
case D3DERR_OUTOFVIDEOMEMORY:
PanicAlert("Out of vid mem");
break;
default: default:
// MessageBoxA(0,"Other error or success","ERROR",0); // MessageBox(0,_T("Other error or success"),_T("ERROR"),0);
break; break;
} }
} }

View file

@ -45,8 +45,8 @@ inline FONT2DVERTEX InitFont2DVertex(float x, float y, u32 color, float tu, floa
CD3DFont::CD3DFont() CD3DFont::CD3DFont()
{ {
m_pTexture = NULL; m_pTexture = NULL;
m_pVB = NULL; m_pVB = NULL;
} }
enum {m_dwTexWidth = 512, m_dwTexHeight = 512}; enum {m_dwTexWidth = 512, m_dwTexHeight = 512};
@ -74,7 +74,7 @@ int CD3DFont::Init()
bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biBitCount = 32;
// Create a DC and a bitmap for the font // Create a DC and a bitmap for the font
HDC hDC = CreateCompatibleDC(NULL); HDC hDC = CreateCompatibleDC(NULL);
HBITMAP hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (VOID**)&pBitmapBits, NULL, 0); HBITMAP hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (VOID**)&pBitmapBits, NULL, 0);
SetMapMode(hDC, MM_TEXT); SetMapMode(hDC, MM_TEXT);
@ -125,7 +125,7 @@ int CD3DFont::Init()
// Create a new texture for the font // Create a new texture for the font
hr = dev->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1, D3DUSAGE_DYNAMIC, hr = dev->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1, D3DUSAGE_DYNAMIC,
D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &m_pTexture, NULL); D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &m_pTexture, NULL);
if (FAILED(hr)) if (FAILED(hr))
{ {
PanicAlert("Failed to create font texture"); PanicAlert("Failed to create font texture");
@ -172,11 +172,11 @@ int CD3DFont::Shutdown()
const int RS[6][2] = const int RS[6][2] =
{ {
{D3DRS_ALPHABLENDENABLE, TRUE}, {D3DRS_ALPHABLENDENABLE, TRUE},
{D3DRS_SRCBLEND, D3DBLEND_SRCALPHA}, {D3DRS_SRCBLEND, D3DBLEND_SRCALPHA},
{D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA}, {D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA},
{D3DRS_CULLMODE, D3DCULL_NONE}, {D3DRS_CULLMODE, D3DCULL_NONE},
{D3DRS_ZENABLE, FALSE}, {D3DRS_ZENABLE, FALSE},
{D3DRS_FOGENABLE, FALSE}, {D3DRS_FOGENABLE, FALSE},
}; };
const int TS[6][2] = const int TS[6][2] =
{ {
@ -193,10 +193,10 @@ bool DXCheck( std::wstring& msg )
HINSTANCE hDll = LoadLibrary(StringFromFormat( _T("d3dx9_%d.dll"), D3DX_SDK_VERSION).c_str()); HINSTANCE hDll = LoadLibrary(StringFromFormat( _T("d3dx9_%d.dll"), D3DX_SDK_VERSION).c_str());
if( !hDll ) if( !hDll )
{ {
msg = _T("Please make sure that you have the latest version of DirectX 9.0c correctly installed."); msg = _T("Please make sure that you have the latest version of DirectX correctly installed.");
return false; return false;
} else } else
msg = _T("DirectX9 is up to date and ready to be used!"); msg = _T("DirectX is up to date and ready to be used!");
FreeLibrary( hDll ); FreeLibrary( hDll );
return true; return true;
} }

View file

@ -274,10 +274,10 @@ struct TabEnhancements : public W32Util::Tab
{ {
void Init(HWND hDlg) void Init(HWND hDlg)
{ {
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEFILTERING),g_Config.bForceFiltering); Button_SetCheck(GetDlgItem(hDlg, IDC_FORCEFILTERING),g_Config.bForceFiltering);
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEANISOTROPY),g_Config.iMaxAnisotropy > 1); Button_SetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY),g_Config.iMaxAnisotropy > 1);
Button_SetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE), g_Config.bHiresTextures); Button_SetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE), g_Config.bHiresTextures);
Button_SetCheck(GetDlgItem(hDlg,IDC_EFBSCALEDCOPY), g_Config.bCopyEFBScaled); Button_SetCheck(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY), g_Config.bCopyEFBScaled);
/* /*
Temporarily disabled the old postprocessing code since it wasn't working anyway. Temporarily disabled the old postprocessing code since it wasn't working anyway.
@ -299,7 +299,7 @@ struct TabEnhancements : public W32Util::Tab
ComboBox_SetCurSel(pp, g_Config.iPostprocessEffect); ComboBox_SetCurSel(pp, g_Config.iPostprocessEffect);
*/ */
} }
void Command(HWND hDlg,WPARAM wParam) void Command(HWND hDlg, WPARAM wParam)
{ {
/* /*
switch (LOWORD(wParam)) switch (LOWORD(wParam))
@ -314,7 +314,7 @@ struct TabEnhancements : public W32Util::Tab
g_Config.iMaxAnisotropy = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY)) ? 8 : 1; g_Config.iMaxAnisotropy = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY)) ? 8 : 1;
g_Config.bForceFiltering = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEFILTERING)) ? true : false; g_Config.bForceFiltering = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEFILTERING)) ? true : false;
g_Config.bHiresTextures = Button_GetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE)) ? true : false; g_Config.bHiresTextures = Button_GetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE)) ? true : false;
g_Config.bCopyEFBScaled = Button_GetCheck(GetDlgItem(hDlg,IDC_EFBSCALEDCOPY)) ? true : false; g_Config.bCopyEFBScaled = Button_GetCheck(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY)) ? true : false;
g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str()); g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
} }
}; };
@ -333,12 +333,10 @@ void DlgSettings_Show(HINSTANCE hInstance, HWND _hParent)
#ifdef DEBUGFAST #ifdef DEBUGFAST
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUGFAST)")); sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUGFAST)"));
#else #elif defined _DEBUG
#ifndef _DEBUG
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin"));
#else
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUG)")); sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUG)"));
#endif #else
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin"));
#endif #endif
if ((tfoe != g_Config.bTexFmtOverlayEnable) || if ((tfoe != g_Config.bTexFmtOverlayEnable) ||

View file

@ -24,7 +24,7 @@
#include "TextureConverter.h" #include "TextureConverter.h"
#undef CHECK #undef CHECK
#define CHECK(hr,Message) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL: %s" ,Message); } #define CHECK(hr, Message) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL: %s" , Message); }
FramebufferManager FBManager; FramebufferManager FBManager;
@ -42,6 +42,7 @@ LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorOffScreenRTSurface()
{ {
return s_efb_color_OffScreenReadBuffer; return s_efb_color_OffScreenReadBuffer;
} }
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthOffScreenRTSurface() LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthOffScreenRTSurface()
{ {
return s_efb_depth_OffScreenReadBuffer; return s_efb_depth_OffScreenReadBuffer;
@ -57,24 +58,31 @@ LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthReadSurface()
return s_efb_depth_ReadBuffer; return s_efb_depth_ReadBuffer;
} }
D3DFORMAT FramebufferManager::GetEFBDepthRTSurfaceFormat(){return s_efb_depth_surface_Format;} D3DFORMAT FramebufferManager::GetEFBDepthRTSurfaceFormat()
D3DFORMAT FramebufferManager::GetEFBDepthReadSurfaceFormat(){return s_efb_depth_ReadBuffer_Format;} {
D3DFORMAT FramebufferManager::GetEFBColorRTSurfaceFormat(){return s_efb_color_surface_Format;} return s_efb_depth_surface_Format;
}
D3DFORMAT FramebufferManager::GetEFBDepthReadSurfaceFormat()
{
return s_efb_depth_ReadBuffer_Format;
}
D3DFORMAT FramebufferManager::GetEFBColorRTSurfaceFormat()
{
return s_efb_color_surface_Format;
}
LPDIRECT3DTEXTURE9 FramebufferManager::GetEFBColorTexture(const EFBRectangle& sourceRc) LPDIRECT3DTEXTURE9 FramebufferManager::GetEFBColorTexture(const EFBRectangle& sourceRc)
{ {
return s_efb_color_texture; return s_efb_color_texture;
} }
LPDIRECT3DTEXTURE9 FramebufferManager::GetEFBDepthTexture(const EFBRectangle &sourceRc) LPDIRECT3DTEXTURE9 FramebufferManager::GetEFBDepthTexture(const EFBRectangle &sourceRc)
{ {
return s_efb_depth_texture; return s_efb_depth_texture;
} }
void FramebufferManager::Create() void FramebufferManager::Create()
{ {
// Simplest possible setup to start with. // Simplest possible setup to start with.
@ -84,22 +92,22 @@ void FramebufferManager::Create()
s_efb_color_surface_Format = D3DFMT_A8R8G8B8; s_efb_color_surface_Format = D3DFMT_A8R8G8B8;
//get the framebuffer texture //get the framebuffer texture
HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format, HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_color_texture, NULL); D3DPOOL_DEFAULT, &s_efb_color_texture, NULL);
if(s_efb_color_texture) if(s_efb_color_texture)
{ {
hr = s_efb_color_texture->GetSurfaceLevel(0,&s_efb_color_surface); hr = s_efb_color_texture->GetSurfaceLevel(0, &s_efb_color_surface);
} }
CHECK(hr,"Create Color Texture"); CHECK(hr, "Create Color Texture");
hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format, hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_colorRead_texture, NULL); D3DPOOL_DEFAULT, &s_efb_colorRead_texture, NULL);
CHECK(hr,"Create Color Read Texture"); CHECK(hr, "Create Color Read Texture");
if(s_efb_colorRead_texture) if(s_efb_colorRead_texture)
{ {
s_efb_colorRead_texture->GetSurfaceLevel(0,&s_efb_color_ReadBuffer); s_efb_colorRead_texture->GetSurfaceLevel(0, &s_efb_color_ReadBuffer);
} }
//create an offscreen surface that we can lock to retrieve the data //create an offscreen surface that we can lock to retrieve the data
hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, s_efb_color_surface_Format, D3DPOOL_SYSTEMMEM, &s_efb_color_OffScreenReadBuffer, NULL ); hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, s_efb_color_surface_Format, D3DPOOL_SYSTEMMEM, &s_efb_color_OffScreenReadBuffer, NULL);
CHECK(hr,"Create Color offScreen Surface"); CHECK(hr, "Create Color offScreen Surface");
//Select Zbuffer format supported by hadware. //Select Zbuffer format supported by hadware.
if (g_ActiveConfig.bEFBAccessEnable) if (g_ActiveConfig.bEFBAccessEnable)
@ -111,19 +119,20 @@ void FramebufferManager::Create()
DepthTexFormats[3] = FOURCC_DF16; DepthTexFormats[3] = FOURCC_DF16;
DepthTexFormats[4] = D3DFMT_D24X8; DepthTexFormats[4] = D3DFMT_D24X8;
for(int i = 0;i<5;i++) for(int i = 0; i < 5; i++)
{ {
s_efb_depth_surface_Format = DepthTexFormats[i]; s_efb_depth_surface_Format = DepthTexFormats[i];
//get the framebuffer Depth texture //get the framebuffer Depth texture
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_DEPTHSTENCIL, s_efb_depth_surface_Format, hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_DEPTHSTENCIL, s_efb_depth_surface_Format,
D3DPOOL_DEFAULT, &s_efb_depth_texture, NULL); D3DPOOL_DEFAULT, &s_efb_depth_texture, NULL);
if (!FAILED(hr)) break; if (!FAILED(hr))
break;
} }
CHECK(hr,"Depth Color Texture"); CHECK(hr,"Depth Color Texture");
//get the Surface //get the Surface
if(s_efb_depth_texture) if(s_efb_depth_texture)
{ {
s_efb_depth_texture->GetSurfaceLevel(0,&s_efb_depth_surface); s_efb_depth_texture->GetSurfaceLevel(0, &s_efb_depth_surface);
} }
//create a 4x4 pixel texture to work as a buffer for peeking //create a 4x4 pixel texture to work as a buffer for peeking
if(s_efb_depth_surface_Format == FOURCC_RAWZ || s_efb_depth_surface_Format == D3DFMT_D24X8) if(s_efb_depth_surface_Format == FOURCC_RAWZ || s_efb_depth_surface_Format == D3DFMT_D24X8)
@ -136,23 +145,24 @@ void FramebufferManager::Create()
} }
DepthTexFormats[1] = D3DFMT_A8R8G8B8; DepthTexFormats[1] = D3DFMT_A8R8G8B8;
for(int i = 0;i<2;i++) for(int i = 0; i < 2; i++)
{ {
s_efb_depth_ReadBuffer_Format = DepthTexFormats[i]; s_efb_depth_ReadBuffer_Format = DepthTexFormats[i];
//get the framebuffer Depth texture //get the framebuffer Depth texture
hr = D3D::dev->CreateTexture(4, 4, 1, D3DUSAGE_RENDERTARGET, s_efb_depth_ReadBuffer_Format, hr = D3D::dev->CreateTexture(4, 4, 1, D3DUSAGE_RENDERTARGET, s_efb_depth_ReadBuffer_Format,
D3DPOOL_DEFAULT, &s_efb_depthRead_texture, NULL); D3DPOOL_DEFAULT, &s_efb_depthRead_texture, NULL);
if (!FAILED(hr)) break; if (!FAILED(hr))
break;
} }
CHECK(hr,"Create Depth Read texture"); CHECK(hr, "Create Depth Read texture");
if(s_efb_depthRead_texture) if(s_efb_depthRead_texture)
{ {
s_efb_depthRead_texture->GetSurfaceLevel(0,&s_efb_depth_ReadBuffer); s_efb_depthRead_texture->GetSurfaceLevel(0, &s_efb_depth_ReadBuffer);
} }
//create an offscreen surface that we can lock to retrieve the data //create an offscreen surface that we can lock to retrieve the data
hr = D3D::dev->CreateOffscreenPlainSurface(4, 4, s_efb_depth_ReadBuffer_Format, D3DPOOL_SYSTEMMEM, &s_efb_depth_OffScreenReadBuffer, NULL ); hr = D3D::dev->CreateOffscreenPlainSurface(4, 4, s_efb_depth_ReadBuffer_Format, D3DPOOL_SYSTEMMEM, &s_efb_depth_OffScreenReadBuffer, NULL);
CHECK(hr,"Create Depth offScreen Surface"); CHECK(hr, "Create Depth offScreen Surface");
delete [] DepthTexFormats; delete [] DepthTexFormats;
} }
else else
@ -160,7 +170,7 @@ void FramebufferManager::Create()
s_efb_depth_surface_Format = D3DFMT_D24X8; s_efb_depth_surface_Format = D3DFMT_D24X8;
hr = D3D::dev->CreateDepthStencilSurface(target_width, target_height, s_efb_depth_surface_Format, hr = D3D::dev->CreateDepthStencilSurface(target_width, target_height, s_efb_depth_surface_Format,
D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_depth_surface, NULL); D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_depth_surface, NULL);
CHECK(hr,"CreateDepthStencilSurface"); CHECK(hr, "CreateDepthStencilSurface");
} }
} }
@ -168,43 +178,43 @@ void FramebufferManager::Destroy()
{ {
if (s_efb_depth_surface) if (s_efb_depth_surface)
s_efb_depth_surface->Release(); s_efb_depth_surface->Release();
s_efb_depth_surface=NULL; s_efb_depth_surface = NULL;
if (s_efb_color_surface) if (s_efb_color_surface)
s_efb_color_surface->Release(); s_efb_color_surface->Release();
s_efb_color_surface=NULL; s_efb_color_surface = NULL;
if (s_efb_color_ReadBuffer) if (s_efb_color_ReadBuffer)
s_efb_color_ReadBuffer->Release(); s_efb_color_ReadBuffer->Release();
s_efb_color_ReadBuffer=NULL; s_efb_color_ReadBuffer = NULL;
if (s_efb_depth_ReadBuffer) if (s_efb_depth_ReadBuffer)
s_efb_depth_ReadBuffer->Release(); s_efb_depth_ReadBuffer->Release();
s_efb_depth_ReadBuffer=NULL; s_efb_depth_ReadBuffer = NULL;
if (s_efb_color_OffScreenReadBuffer) if (s_efb_color_OffScreenReadBuffer)
s_efb_color_OffScreenReadBuffer->Release(); s_efb_color_OffScreenReadBuffer->Release();
s_efb_color_OffScreenReadBuffer=NULL; s_efb_color_OffScreenReadBuffer = NULL;
if (s_efb_depth_OffScreenReadBuffer) if (s_efb_depth_OffScreenReadBuffer)
s_efb_depth_OffScreenReadBuffer->Release(); s_efb_depth_OffScreenReadBuffer->Release();
s_efb_depth_OffScreenReadBuffer=NULL; s_efb_depth_OffScreenReadBuffer = NULL;
if (s_efb_color_texture) if (s_efb_color_texture)
s_efb_color_texture->Release(); s_efb_color_texture->Release();
s_efb_color_texture=NULL; s_efb_color_texture = NULL;
if (s_efb_colorRead_texture) if (s_efb_colorRead_texture)
s_efb_colorRead_texture->Release(); s_efb_colorRead_texture->Release();
s_efb_colorRead_texture=NULL; s_efb_colorRead_texture = NULL;
if (s_efb_depth_texture) if (s_efb_depth_texture)
s_efb_depth_texture->Release(); s_efb_depth_texture->Release();
s_efb_depth_texture=NULL; s_efb_depth_texture = NULL;
if (s_efb_depthRead_texture) if (s_efb_depthRead_texture)
s_efb_depthRead_texture->Release(); s_efb_depthRead_texture->Release();
s_efb_depthRead_texture=NULL; s_efb_depthRead_texture = NULL;
for (VirtualXFBListType::iterator it = m_virtualXFBList.begin(); it != m_virtualXFBList.end(); ++it) for (VirtualXFBListType::iterator it = m_virtualXFBList.begin(); it != m_virtualXFBList.end(); ++it)
{ {
@ -351,7 +361,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
it->xfbSource.texture->Release(); it->xfbSource.texture->Release();
it->xfbSource.texture = NULL; it->xfbSource.texture = NULL;
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format, hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &(it->xfbSource.texture), NULL); D3DPOOL_DEFAULT, &(it->xfbSource.texture), NULL);
} }
@ -371,7 +381,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
// Create a new Virtual XFB and place it at the front of the list. // Create a new Virtual XFB and place it at the front of the list.
D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format, D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &xfbTexture, NULL); D3DPOOL_DEFAULT, &xfbTexture, NULL);
VirtualXFB newVirt; VirtualXFB newVirt;
newVirt.xfbAddr = xfbAddr; newVirt.xfbAddr = xfbAddr;
@ -403,7 +413,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
Renderer::ResetAPIState(); // reset any game specific settings Renderer::ResetAPIState(); // reset any game specific settings
LPDIRECT3DSURFACE9 Rendersurf = NULL; LPDIRECT3DSURFACE9 Rendersurf = NULL;
xfbTexture->GetSurfaceLevel(0,&Rendersurf); xfbTexture->GetSurfaceLevel(0, &Rendersurf);
D3D::dev->SetDepthStencilSurface(NULL); D3D::dev->SetDepthStencilSurface(NULL);
D3D::dev->SetRenderTarget(0, Rendersurf); D3D::dev->SetRenderTarget(0, Rendersurf);
@ -425,11 +435,10 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
D3D::drawShadedTexQuad( D3D::drawShadedTexQuad(
read_texture, read_texture,
&sourcerect, &sourcerect,
Renderer::GetFullTargetWidth() , Renderer::GetFullTargetWidth(),
Renderer::GetFullTargetHeight(), Renderer::GetFullTargetHeight(),
target_width, target_width,
target_height, target_height,
@ -439,12 +448,11 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER); D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER); D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::SetTexture(0,NULL); D3D::SetTexture(0, NULL);
D3D::dev->SetRenderTarget(0, GetEFBColorRTSurface()); D3D::dev->SetRenderTarget(0, GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(GetEFBDepthRTSurface()); D3D::dev->SetDepthStencilSurface(GetEFBDepthRTSurface());
Renderer::RestoreAPIState(); Renderer::RestoreAPIState();
Rendersurf->Release(); Rendersurf->Release();
} }
const XFBSource** FramebufferManager::getRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount) const XFBSource** FramebufferManager::getRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount)
@ -461,7 +469,7 @@ const XFBSource** FramebufferManager::getRealXFBSource(u32 xfbAddr, u32 fbWidth,
if (!m_realXFBSource.texture) if (!m_realXFBSource.texture)
{ {
D3D::dev->CreateTexture(fbWidth, fbHeight, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format, D3D::dev->CreateTexture(fbWidth, fbHeight, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &m_realXFBSource.texture, NULL); D3DPOOL_DEFAULT, &m_realXFBSource.texture, NULL);
} }
// Decode YUYV data from GameCube RAM // Decode YUYV data from GameCube RAM

View file

@ -163,7 +163,6 @@ private:
LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
D3DFORMAT s_efb_color_surface_Format;//Format of the color Surface D3DFORMAT s_efb_color_surface_Format;//Format of the color Surface
D3DFORMAT s_efb_depth_surface_Format;//Format of the Depth Surface D3DFORMAT s_efb_depth_surface_Format;//Format of the Depth Surface
D3DFORMAT s_efb_depth_ReadBuffer_Format;//Format of the Depth color Read Surface D3DFORMAT s_efb_depth_ReadBuffer_Format;//Format of the Depth color Read Surface

View file

@ -116,7 +116,7 @@ static const D3DBLEND d3dDestFactors[8] =
D3DBLEND_INVDESTALPHA D3DBLEND_INVDESTALPHA
}; };
static const D3DBLENDOP d3dLogincOPop[16] = static const D3DBLENDOP d3dLogicOpop[16] =
{ {
D3DBLENDOP_ADD, D3DBLENDOP_ADD,
D3DBLENDOP_ADD, D3DBLENDOP_ADD,
@ -239,7 +239,6 @@ void TeardownDeviceObjects()
FBManager.Destroy(); FBManager.Destroy();
D3D::font.Shutdown(); D3D::font.Shutdown();
TextureCache::Invalidate(false); TextureCache::Invalidate(false);
VertexManager::DestroyDeviceObjects();
VertexLoaderManager::Shutdown(); VertexLoaderManager::Shutdown();
VertexShaderCache::Clear(); VertexShaderCache::Clear();
PixelShaderCache::Clear(); PixelShaderCache::Clear();
@ -1248,10 +1247,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
void Renderer::ResetAPIState() void Renderer::ResetAPIState()
{ {
D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
D3D::SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); D3D::SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZENABLE, FALSE); D3D::SetRenderState(D3DRS_ZENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE); D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA| D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE; DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA| D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask); D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask);
} }
@ -1294,7 +1293,7 @@ void Renderer::SetLogicOpMode()
{ {
s_blendMode = 0; s_blendMode = 0;
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, 1); D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
D3D::SetRenderState(D3DRS_BLENDOP, d3dLogincOPop[bpmem.blendmode.logicmode]); D3D::SetRenderState(D3DRS_BLENDOP, d3dLogicOpop[bpmem.blendmode.logicmode]);
D3D::SetRenderState(D3DRS_SRCBLEND, d3dLogicOpSrcFactors[bpmem.blendmode.logicmode]); D3D::SetRenderState(D3DRS_SRCBLEND, d3dLogicOpSrcFactors[bpmem.blendmode.logicmode]);
D3D::SetRenderState(D3DRS_DESTBLEND, d3dLogicOpDestFactors[bpmem.blendmode.logicmode]); D3D::SetRenderState(D3DRS_DESTBLEND, d3dLogicOpDestFactors[bpmem.blendmode.logicmode]);
} }

View file

@ -131,8 +131,8 @@ void TextureCache::Cleanup()
} }
else else
{ {
++iter; ++iter;
} }
} }
} }
@ -196,7 +196,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
} }
else else
{ {
// Let's reload the new texture data into the same texture, // Let's reload the new texture data into the same texture,
// instead of destroying it and having to create a new one. // instead of destroying it and having to create a new one.
// Might speed up movie playback very, very slightly. // Might speed up movie playback very, very slightly.
@ -274,7 +274,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
else else
{ {
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF); entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[0] = entry.hash; ((u32 *)ptr)[0] = entry.hash;
} }
entry.addr = address; entry.addr = address;
@ -411,115 +411,115 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
float colmat[16]= {0.0f}; float colmat[16]= {0.0f};
float fConstAdd[4] = {0.0f}; float fConstAdd[4] = {0.0f};
if (bFromZBuffer) if (bFromZBuffer)
{ {
switch(copyfmt) switch(copyfmt)
{ {
case 0: // Z4 case 0: // Z4
case 1: // Z8 case 1: // Z8
colmat[0] = colmat[4] = colmat[8] = colmat[12] =1.0f; colmat[0] = colmat[4] = colmat[8] = colmat[12] =1.0f;
break; break;
case 3: // Z16 //? case 3: // Z16 //?
colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f; colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f;
case 11: // Z16 (reverse order) case 11: // Z16 (reverse order)
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1.0f; colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1.0f;
break; break;
case 6: // Z24X8 case 6: // Z24X8
colmat[0] = colmat[5] = colmat[10] = 1.0f; colmat[0] = colmat[5] = colmat[10] = 1.0f;
break; break;
case 9: // Z8M case 9: // Z8M
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1.0f; colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1.0f;
break; break;
case 10: // Z8L case 10: // Z8L
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1.0f; colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1.0f;
break; break;
case 12: // Z16L case 12: // Z16L
colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1.0f; colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1.0f;
break; break;
default: default:
ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x", copyfmt); ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x", copyfmt);
colmat[2] = colmat[5] = colmat[8] = 1.0f; colmat[2] = colmat[5] = colmat[8] = 1.0f;
break; break;
} }
} }
else if (bIsIntensityFmt) else if (bIsIntensityFmt)
{ {
fConstAdd[0] = fConstAdd[1] = fConstAdd[2] = 16.0f/255.0f; fConstAdd[0] = fConstAdd[1] = fConstAdd[2] = 16.0f/255.0f;
switch (copyfmt) switch (copyfmt)
{ {
case 0: // I4 case 0: // I4
case 1: // I8 case 1: // I8
case 2: // IA4 case 2: // IA4
case 3: // IA8 case 3: // IA8
// TODO - verify these coefficients // TODO - verify these coefficients
colmat[0] = 0.257f; colmat[1] = 0.504f; colmat[2] = 0.098f; colmat[0] = 0.257f; colmat[1] = 0.504f; colmat[2] = 0.098f;
colmat[4] = 0.257f; colmat[5] = 0.504f; colmat[6] = 0.098f; colmat[4] = 0.257f; colmat[5] = 0.504f; colmat[6] = 0.098f;
colmat[8] = 0.257f; colmat[9] = 0.504f; colmat[10] = 0.098f; colmat[8] = 0.257f; colmat[9] = 0.504f; colmat[10] = 0.098f;
if (copyfmt < 2) if (copyfmt < 2)
{ {
fConstAdd[3] = 16.0f / 255.0f; fConstAdd[3] = 16.0f / 255.0f;
colmat[12] = 0.257f; colmat[13] = 0.504f; colmat[14] = 0.098f; colmat[12] = 0.257f; colmat[13] = 0.504f; colmat[14] = 0.098f;
} }
else// alpha else// alpha
colmat[15] = 1; colmat[15] = 1;
break; break;
default: default:
ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x", copyfmt); ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x", copyfmt);
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1; colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break; break;
} }
} }
else else
{ {
switch (copyfmt) switch (copyfmt)
{ {
case 0: // R4 case 0: // R4
case 8: // R8 case 8: // R8
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1; colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
break; break;
case 2: // RA4 case 2: // RA4
case 3: // RA8 case 3: // RA8
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1; colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
break; break;
case 7: // A8 case 7: // A8
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1; colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
break; break;
case 9: // G8 case 9: // G8
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1; colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
break; break;
case 10: // B8 case 10: // B8
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1; colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
break; break;
case 11: // RG8 case 11: // RG8
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1; colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
break; break;
case 12: // GB8 case 12: // GB8
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1; colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
break; break;
case 4: // RGB565 case 4: // RGB565
colmat[0] = colmat[5] = colmat[10] = 1; colmat[0] = colmat[5] = colmat[10] = 1;
fConstAdd[3] = 1; // set alpha to 1 fConstAdd[3] = 1; // set alpha to 1
break; break;
case 5: // RGB5A3 case 5: // RGB5A3
case 6: // RGBA8 case 6: // RGBA8
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1; colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break; break;
default: default:
ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x", copyfmt); ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x", copyfmt);
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1; colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break; break;
} }
} }
// Make sure to resolve anything we need to read from. // Make sure to resolve anything we need to read from.
LPDIRECT3DTEXTURE9 read_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source_rect) : FBManager.GetEFBColorTexture(source_rect); LPDIRECT3DTEXTURE9 read_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source_rect) : FBManager.GetEFBColorTexture(source_rect);
// We have to run a pixel shader, for color conversion. // We have to run a pixel shader, for color conversion.
Renderer::ResetAPIState(); // reset any game specific settings Renderer::ResetAPIState(); // reset any game specific settings
LPDIRECT3DSURFACE9 Rendersurf = NULL; LPDIRECT3DSURFACE9 Rendersurf = NULL;
tex->GetSurfaceLevel(0,&Rendersurf); tex->GetSurfaceLevel(0,&Rendersurf);
D3D::dev->SetDepthStencilSurface(NULL); D3D::dev->SetDepthStencilSurface(NULL);
@ -555,7 +555,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
} }
else else
{ {
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
@ -583,3 +583,4 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
Renderer::RestoreAPIState(); Renderer::RestoreAPIState();
Rendersurf->Release(); Rendersurf->Release();
} }

View file

@ -58,9 +58,6 @@ static u16 *PIBuffer;
#define MAXIBUFFERSIZE 0xFFFF #define MAXIBUFFERSIZE 0xFFFF
static bool Flushed=false; static bool Flushed=false;
void CreateDeviceObjects();
void DestroyDeviceObjects();
bool Init() bool Init()
{ {
LocalVBuffer = new u8[MAXVBUFFERSIZE]; LocalVBuffer = new u8[MAXVBUFFERSIZE];
@ -80,7 +77,6 @@ void ResetBuffer()
void Shutdown() void Shutdown()
{ {
DestroyDeviceObjects();
delete [] LocalVBuffer; delete [] LocalVBuffer;
delete [] TIBuffer; delete [] TIBuffer;
delete [] LIBuffer; delete [] LIBuffer;
@ -88,15 +84,6 @@ void Shutdown()
ResetBuffer(); ResetBuffer();
} }
void CreateDeviceObjects()
{
}
void DestroyDeviceObjects()
{
}
void AddIndices(int _primitive, int _numVertices) void AddIndices(int _primitive, int _numVertices)
{ {
switch (_primitive) switch (_primitive)
@ -106,7 +93,7 @@ void AddIndices(int _primitive, int _numVertices)
case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(_numVertices); break; case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(_numVertices); break;
case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(_numVertices); break; case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(_numVertices); break;
case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(_numVertices); break; case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(_numVertices); break;
case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break; case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break;
case GX_DRAW_POINTS: IndexGenerator::AddPoints(_numVertices); break; case GX_DRAW_POINTS: IndexGenerator::AddPoints(_numVertices); break;
} }
} }

View file

@ -30,9 +30,6 @@ void Shutdown();
void AddVertices(int _primitive, int _numVertices); void AddVertices(int _primitive, int _numVertices);
void Flush(); void Flush();
void CreateDeviceObjects();
void DestroyDeviceObjects();
} // namespace } // namespace
#endif #endif

View file

@ -145,22 +145,22 @@ typedef struct
static const GLenum glSrcFactors[8] = static const GLenum glSrcFactors[8] =
{ {
GL_ZERO, GL_ZERO,
GL_ONE, GL_ONE,
GL_DST_COLOR, GL_DST_COLOR,
GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
GL_SRC_ALPHA, GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA, GL_DST_ALPHA,
GL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
}; };
static const GLenum glDestFactors[8] = { static const GLenum glDestFactors[8] = {
GL_ZERO, GL_ZERO,
GL_ONE, GL_ONE,
GL_SRC_COLOR, GL_SRC_COLOR,
GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
GL_SRC_ALPHA, GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA, GL_DST_ALPHA,
GL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
@ -178,7 +178,7 @@ static const GLenum glCmpFuncs[8] = {
}; };
static const GLenum glLogicOpCodes[16] = { static const GLenum glLogicOpCodes[16] = {
GL_CLEAR, GL_CLEAR,
GL_AND, GL_AND,
GL_AND_REVERSE, GL_AND_REVERSE,
GL_COPY, GL_COPY,
@ -199,15 +199,15 @@ static const GLenum glLogicOpCodes[16] = {
void SetDefaultRectTexParams() void SetDefaultRectTexParams()
{ {
// Set some standard texture filter modes. // Set some standard texture filter modes.
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (glGetError() != GL_NO_ERROR) { if (glGetError() != GL_NO_ERROR) {
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
} }
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} }
void HandleCgError(CGcontext ctx, CGerror err, void* appdata) void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
@ -230,7 +230,7 @@ void VideoConfig::UpdateProjectionHack()
bool Renderer::Init() bool Renderer::Init()
{ {
UpdateActiveConfig(); UpdateActiveConfig();
bool bSuccess = true; bool bSuccess = true;
s_blendMode = 0; s_blendMode = 0;
s_MSAACoverageSamples = 0; s_MSAACoverageSamples = 0;
switch (g_ActiveConfig.iMultisampleMode) switch (g_ActiveConfig.iMultisampleMode)
@ -247,49 +247,49 @@ bool Renderer::Init()
s_MSAASamples = 1; s_MSAASamples = 1;
} }
GLint numvertexattribs = 0; GLint numvertexattribs = 0;
g_cgcontext = cgCreateContext(); g_cgcontext = cgCreateContext();
cgGetError(); cgGetError();
cgSetErrorHandler(HandleCgError, NULL); cgSetErrorHandler(HandleCgError, NULL);
// Look for required extensions. // Look for required extensions.
const char *ptoken = (const char*)glGetString(GL_EXTENSIONS); const char *ptoken = (const char*)glGetString(GL_EXTENSIONS);
if (!ptoken) if (!ptoken)
{ {
PanicAlert("Your OpenGL Driver seems to be not working.\n" PanicAlert("Your OpenGL Driver seems to be not working.\n"
"Please make sure your drivers are up-to-date and\n" "Please make sure your drivers are up-to-date and\n"
"that your video hardware is OpenGL 2.x compatible " "that your video hardware is OpenGL 2.x compatible "
); );
return false; return false;
} }
INFO_LOG(VIDEO, "Supported OpenGL Extensions:"); INFO_LOG(VIDEO, "Supported OpenGL Extensions:");
INFO_LOG(VIDEO, ptoken); // write to the log file INFO_LOG(VIDEO, ptoken); // write to the log file
INFO_LOG(VIDEO, ""); INFO_LOG(VIDEO, "");
OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s", (const char*)glGetString(GL_VENDOR), OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s", (const char*)glGetString(GL_VENDOR),
(const char*)glGetString(GL_RENDERER), (const char*)glGetString(GL_RENDERER),
(const char*)glGetString(GL_VERSION)).c_str(), 5000); (const char*)glGetString(GL_VERSION)).c_str(), 5000);
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs); glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
if (numvertexattribs < 11) { if (numvertexattribs < 11) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********Does your video card support OpenGL 2.x?", numvertexattribs); ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********Does your video card support OpenGL 2.x?", numvertexattribs);
bSuccess = false; bSuccess = false;
} }
// Init extension support. // Init extension support.
if (glewInit() != GLEW_OK) { if (glewInit() != GLEW_OK) {
ERROR_LOG(VIDEO, "glewInit() failed!Does your video card support OpenGL 2.x?"); ERROR_LOG(VIDEO, "glewInit() failed!Does your video card support OpenGL 2.x?");
return false; return false;
} }
if (!GLEW_EXT_framebuffer_object) { if (!GLEW_EXT_framebuffer_object) {
ERROR_LOG(VIDEO, "*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********Does your video card support OpenGL 2.x?"); ERROR_LOG(VIDEO, "*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********Does your video card support OpenGL 2.x?");
bSuccess = false; bSuccess = false;
} }
if (!GLEW_EXT_secondary_color) { if (!GLEW_EXT_secondary_color) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********Does your video card support OpenGL 2.x?"); ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********Does your video card support OpenGL 2.x?");
bSuccess = false; bSuccess = false;
} }
s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL; s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL;
if (!s_bHaveFramebufferBlit) if (!s_bHaveFramebufferBlit)
{ {
@ -302,8 +302,8 @@ bool Renderer::Init()
s_MSAACoverageSamples = 0; s_MSAACoverageSamples = 0;
} }
if (!bSuccess) if (!bSuccess)
return false; return false;
// Handle VSync on/off // Handle VSync on/off
#if defined USE_WX && USE_WX #if defined USE_WX && USE_WX
@ -320,7 +320,7 @@ bool Renderer::Init()
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)"); ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)");
#endif #endif
// check the max texture width and height // check the max texture width and height
GLint max_texture_size; GLint max_texture_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size); glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size);
if (max_texture_size < 1024) { if (max_texture_size < 1024) {
@ -330,8 +330,8 @@ bool Renderer::Init()
if (GL_REPORT_ERROR() != GL_NO_ERROR) if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false; bSuccess = false;
if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers) if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers)
glDrawBuffers = glDrawBuffersARB; glDrawBuffers = glDrawBuffersARB;
if (!GLEW_ARB_texture_non_power_of_two) { if (!GLEW_ARB_texture_non_power_of_two) {
WARN_LOG(VIDEO, "ARB_texture_non_power_of_two not supported."); WARN_LOG(VIDEO, "ARB_texture_non_power_of_two not supported.");
@ -377,7 +377,7 @@ bool Renderer::Init()
// Because of the fixed framebuffer size we need to disable the resolution options while running // Because of the fixed framebuffer size we need to disable the resolution options while running
g_Config.bRunning = true; g_Config.bRunning = true;
if (GL_REPORT_ERROR() != GL_NO_ERROR) if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false; bSuccess = false;
// Initialize the FramebufferManager // Initialize the FramebufferManager
@ -385,93 +385,93 @@ bool Renderer::Init()
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
if (GL_REPORT_ERROR() != GL_NO_ERROR) if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false; bSuccess = false;
s_pfont = new RasterFont(); s_pfont = new RasterFont();
// load the effect, find the best profiles (if any) // load the effect, find the best profiles (if any)
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) { if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) {
ERROR_LOG(VIDEO, "arbvp1 not supported"); ERROR_LOG(VIDEO, "arbvp1 not supported");
return false; return false;
} }
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) { if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
ERROR_LOG(VIDEO, "arbfp1 not supported"); ERROR_LOG(VIDEO, "arbfp1 not supported");
return false; return false;
} }
g_cgvProf = cgGLGetLatestProfile(CG_GL_VERTEX); g_cgvProf = cgGLGetLatestProfile(CG_GL_VERTEX);
g_cgfProf = cgGLGetLatestProfile(CG_GL_FRAGMENT); g_cgfProf = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLSetOptimalOptions(g_cgvProf); cgGLSetOptimalOptions(g_cgvProf);
cgGLSetOptimalOptions(g_cgfProf); cgGLSetOptimalOptions(g_cgfProf);
INFO_LOG(VIDEO, "Max buffer sizes: %d %d", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf)); INFO_LOG(VIDEO, "Max buffer sizes: %d %d", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf));
int nenvvertparams, nenvfragparams, naddrregisters[2]; int nenvvertparams, nenvfragparams, naddrregisters[2];
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams); glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvfragparams); glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvfragparams);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[0]); glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[0]);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[1]); glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[1]);
DEBUG_LOG(VIDEO, "Max program env parameters: vert=%d, frag=%d", nenvvertparams, nenvfragparams); DEBUG_LOG(VIDEO, "Max program env parameters: vert=%d, frag=%d", nenvvertparams, nenvfragparams);
DEBUG_LOG(VIDEO, "Max program address register parameters: vert=%d, frag=%d", naddrregisters[0], naddrregisters[1]); DEBUG_LOG(VIDEO, "Max program address register parameters: vert=%d, frag=%d", naddrregisters[0], naddrregisters[1]);
if (nenvvertparams < 238) if (nenvvertparams < 238)
ERROR_LOG(VIDEO, "Not enough vertex shader environment constants!!"); ERROR_LOG(VIDEO, "Not enough vertex shader environment constants!!");
#ifndef _DEBUG #ifndef _DEBUG
cgGLSetDebugMode(GL_FALSE); cgGLSetDebugMode(GL_FALSE);
#endif #endif
glStencilFunc(GL_ALWAYS, 0, 0); glStencilFunc(GL_ALWAYS, 0, 0);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f); glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, GetTargetWidth(), GetTargetHeight()); glScissor(0, 0, GetTargetWidth(), GetTargetHeight());
glBlendColorEXT(0, 0, 0, 0.5f); glBlendColorEXT(0, 0, 0, 0.5f);
glClearDepth(1.0f); glClearDepth(1.0f);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
// legacy multitexturing: select texture channel only. // legacy multitexturing: select texture channel only.
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0); glClientActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
UpdateActiveConfig(); UpdateActiveConfig();
return glGetError() == GL_NO_ERROR && bSuccess; return glGetError() == GL_NO_ERROR && bSuccess;
} }
void Renderer::Shutdown(void) void Renderer::Shutdown(void)
{ {
g_Config.bRunning = false; g_Config.bRunning = false;
UpdateActiveConfig(); UpdateActiveConfig();
delete s_pfont; delete s_pfont;
s_pfont = 0; s_pfont = 0;
if (g_cgcontext) { if (g_cgcontext) {
cgDestroyContext(g_cgcontext); cgDestroyContext(g_cgcontext);
g_cgcontext = 0; g_cgcontext = 0;
} }
if(s_tempScreenshotFramebuffer) if(s_tempScreenshotFramebuffer)
glDeleteFramebuffersEXT(1, &s_tempScreenshotFramebuffer); glDeleteFramebuffersEXT(1, &s_tempScreenshotFramebuffer);
@ -535,12 +535,12 @@ int Renderer::GetTargetHeight()
} }
float Renderer::GetTargetScaleX() float Renderer::GetTargetScaleX()
{ {
return EFBxScale; return EFBxScale;
} }
float Renderer::GetTargetScaleY() float Renderer::GetTargetScaleY()
{ {
return EFByScale; return EFByScale;
} }
@ -553,7 +553,6 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
} }
void Renderer::ResetAPIState() void Renderer::ResetAPIState()
{ {
// Gets us to a reasonably sane state where it's possible to do things like // Gets us to a reasonably sane state where it's possible to do things like
@ -561,12 +560,12 @@ void Renderer::ResetAPIState()
VertexShaderCache::DisableShader(); VertexShaderCache::DisableShader();
PixelShaderCache::DisableShader(); PixelShaderCache::DisableShader();
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
} }
void UpdateViewport(); void UpdateViewport();
@ -582,13 +581,13 @@ void Renderer::RestoreAPIState()
UpdateViewport(); UpdateViewport();
if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE); if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
if (bpmem.zmode.testenable) glEnable(GL_DEPTH_TEST); if (bpmem.zmode.testenable) glEnable(GL_DEPTH_TEST);
if (bpmem.zmode.updateenable) glDepthMask(GL_TRUE); if (bpmem.zmode.updateenable) glDepthMask(GL_TRUE);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
SetScissorRect(); SetScissorRect();
SetColorMask(); SetColorMask();
SetBlendMode(true); SetBlendMode(true);
VertexShaderCache::SetCurrentShader(0); VertexShaderCache::SetCurrentShader(0);
@ -612,9 +611,9 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 newval = bpmem.blendmode.subtract << 2; u32 newval = bpmem.blendmode.subtract << 2;
if (bpmem.blendmode.subtract) { if (bpmem.blendmode.subtract) {
newval |= 0x0049; // enable blending src 1 dst 1 newval |= 0x0049; // enable blending src 1 dst 1
} else if (bpmem.blendmode.blendenable) { } else if (bpmem.blendmode.blendenable) {
newval |= 1; // enable blending newval |= 1; // enable blending
newval |= bpmem.blendmode.srcfactor << 3; newval |= bpmem.blendmode.srcfactor << 3;
newval |= bpmem.blendmode.dstfactor << 6; newval |= bpmem.blendmode.dstfactor << 6;
@ -623,7 +622,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode; u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
if (changes & 1) { if (changes & 1) {
// blend enable change // blend enable change
(newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND); (newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
} }
@ -736,9 +735,9 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// therefore the width and height are (scissorBR + 1) - scissorTL // therefore the width and height are (scissorBR + 1) - scissorTL
bool Renderer::SetScissorRect() bool Renderer::SetScissorRect()
{ {
int xoff = bpmem.scissorOffset.x * 2 - 342; int xoff = bpmem.scissorOffset.x * 2 - 342;
int yoff = bpmem.scissorOffset.y * 2 - 342; int yoff = bpmem.scissorOffset.y * 2 - 342;
float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0 float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0
if (rc_left < 0) rc_left = 0; if (rc_left < 0) rc_left = 0;
float rc_top = (float)bpmem.scissorTL.y - yoff - 342; // right = 0 float rc_top = (float)bpmem.scissorTL.y - yoff - 342; // right = 0
@ -766,7 +765,7 @@ bool Renderer::SetScissorRect()
// Check that the coordinates are good // Check that the coordinates are good
if (rc_right >= rc_left && rc_bottom >= rc_top) if (rc_right >= rc_left && rc_bottom >= rc_top)
{ {
glScissor( glScissor(
(int)(rc_left * EFBxScale), // x = 0 for example (int)(rc_left * EFBxScale), // x = 0 for example
@ -774,8 +773,8 @@ bool Renderer::SetScissorRect()
(int)((rc_right - rc_left)* EFBxScale), // width = 640 for example (int)((rc_right - rc_left)* EFBxScale), // width = 640 for example
(int)((rc_bottom - rc_top) * EFByScale) // height = 480 for example (int)((rc_bottom - rc_top) * EFByScale) // height = 480 for example
); );
return true; return true;
} }
else else
{ {
glScissor( glScissor(
@ -785,7 +784,7 @@ bool Renderer::SetScissorRect()
Renderer::GetTargetHeight() Renderer::GetTargetHeight()
); );
} }
return false; return false;
} }
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
@ -795,10 +794,10 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc); TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
// Always set the scissor in case it was set by the game and has not been reset // Always set the scissor in case it was set by the game and has not been reset
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight()); glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
VertexShaderManager::SetViewportChanged(); VertexShaderManager::SetViewportChanged();
GLbitfield bits = 0; GLbitfield bits = 0;
if (colorEnable) if (colorEnable)
@ -858,9 +857,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
return; return;
} }
DVSTARTPROFILE(); DVSTARTPROFILE();
ResetAPIState(); ResetAPIState();
TargetRectangle back_rc; TargetRectangle back_rc;
ComputeDrawRectangle(m_CustomWidth, m_CustomHeight, true, &back_rc); ComputeDrawRectangle(m_CustomWidth, m_CustomHeight, true, &back_rc);
@ -966,14 +965,14 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
glTexCoord2f(sourceRc.right, sourceRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1); glVertex2f(drawRc.right, drawRc.top); glTexCoord2f(sourceRc.right, sourceRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0); glVertex2f(drawRc.right, drawRc.bottom); glTexCoord2f(sourceRc.right, sourceRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0); glVertex2f(drawRc.right, drawRc.bottom);
glEnd(); glEnd();
PixelShaderCache::DisableShader();; PixelShaderCache::DisableShader();
} }
else else
{ {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(sourceRc.left, sourceRc.bottom); glVertex2f(drawRc.left, drawRc.bottom); glTexCoord2f(sourceRc.left, sourceRc.bottom); glVertex2f(drawRc.left, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.top); glVertex2f(drawRc.left, drawRc.top); glTexCoord2f(sourceRc.left, sourceRc.top); glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top); glVertex2f(drawRc.right, drawRc.top); glTexCoord2f(sourceRc.right, sourceRc.top); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom); glVertex2f(drawRc.right, drawRc.bottom); glTexCoord2f(sourceRc.right, sourceRc.bottom); glVertex2f(drawRc.right, drawRc.bottom);
glEnd(); glEnd();
} }
@ -1172,20 +1171,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Count FPS. // Count FPS.
// ------------- // -------------
static int fpscount = 0; static int fpscount = 0;
static unsigned long lasttime; static unsigned long lasttime;
++fpscount; ++fpscount;
if (Common::Timer::GetTimeMs() - lasttime > 1000) if (Common::Timer::GetTimeMs() - lasttime > 1000)
{ {
lasttime = Common::Timer::GetTimeMs(); lasttime = Common::Timer::GetTimeMs();
s_fps = fpscount - 1; s_fps = fpscount - 1;
fpscount = 0; fpscount = 0;
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
DrawDebugText(); DrawDebugText();
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
// Get the status of the Blend mode // Get the status of the Blend mode
GLboolean blend_enabled = glIsEnabled(GL_BLEND); GLboolean blend_enabled = glIsEnabled(GL_BLEND);
@ -1195,18 +1194,18 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
glEnable(GL_BLEND); glEnable(GL_BLEND);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
#if defined(DVPROFILE) #if defined(DVPROFILE)
if (g_bWriteProfile) { if (g_bWriteProfile) {
//g_bWriteProfile = 0; //g_bWriteProfile = 0;
static int framenum = 0; static int framenum = 0;
const int UPDATE_FRAMES = 8; const int UPDATE_FRAMES = 8;
if (++framenum >= UPDATE_FRAMES) { if (++framenum >= UPDATE_FRAMES) {
DVProfWrite("prof.txt", UPDATE_FRAMES); DVProfWrite("prof.txt", UPDATE_FRAMES);
DVProfClear(); DVProfClear();
framenum = 0; framenum = 0;
} }
} }
#endif #endif
// Copy the rendered frame to the real window // Copy the rendered frame to the real window
OpenGL_SwapBuffers(); OpenGL_SwapBuffers();
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
@ -1219,22 +1218,22 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Clean out old stuff from caches. It's not worth it to clean out the shader caches. // Clean out old stuff from caches. It's not worth it to clean out the shader caches.
DLCache::ProgressiveCleanup(); DLCache::ProgressiveCleanup();
TextureMngr::ProgressiveCleanup(); TextureMngr::ProgressiveCleanup();
frameCount++; frameCount++;
// New frame // New frame
stats.ResetFrame(); stats.ResetFrame();
// Render to the framebuffer. // Render to the framebuffer.
g_framebufferManager.SetFramebuffer(0); g_framebufferManager.SetFramebuffer(0);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
RestoreAPIState(); RestoreAPIState();
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
g_Config.iSaveTargetId = 0; g_Config.iSaveTargetId = 0;
bool last_copy_efb_to_Texture = g_ActiveConfig.bCopyEFBToTexture; bool last_copy_efb_to_Texture = g_ActiveConfig.bCopyEFBToTexture;
UpdateActiveConfig(); UpdateActiveConfig();
@ -1242,8 +1241,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
TextureMngr::ClearRenderTargets(); TextureMngr::ClearRenderTargets();
// For testing zbuffer targets. // For testing zbuffer targets.
// Renderer::SetZBufferRender(); // Renderer::SetZBufferRender();
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight()); // SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
XFBWrited = false; XFBWrited = false;
g_VideoInitialize.pCopiedToXFB(true); g_VideoInitialize.pCopiedToXFB(true);
@ -1265,7 +1264,7 @@ void Renderer::DrawDebugText()
if (g_ActiveConfig.bShowEFBCopyRegions) if (g_ActiveConfig.bShowEFBCopyRegions)
{ {
// Store Line Size // Store Line Size
GLfloat lSize; GLfloat lSize;
glGetFloatv(GL_LINE_WIDTH, &lSize); glGetFloatv(GL_LINE_WIDTH, &lSize);
// Set Line Size // Set Line Size
@ -1277,8 +1276,8 @@ void Renderer::DrawDebugText()
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin(); it != stats.efb_regions.end(); ++it) for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin(); it != stats.efb_regions.end(); ++it)
{ {
GLfloat halfWidth = EFB_WIDTH / 2.0f; GLfloat halfWidth = EFB_WIDTH / 2.0f;
GLfloat halfHeight = EFB_HEIGHT / 2.0f; GLfloat halfHeight = EFB_HEIGHT / 2.0f;
GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth); GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth);
GLfloat y = (GLfloat) 1.0f - ((GLfloat)it->top / halfHeight); GLfloat y = (GLfloat) 1.0f - ((GLfloat)it->top / halfHeight);
GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth); GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth);
GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight); GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight);
@ -1307,10 +1306,10 @@ void Renderer::DrawDebugText()
stats.efb_regions.clear(); stats.efb_regions.clear();
} }
if (g_ActiveConfig.bOverlayStats) if (g_ActiveConfig.bOverlayStats)
{ {
p = Statistics::ToString(p); p = Statistics::ToString(p);
} }
if (g_ActiveConfig.bOverlayProjStats) if (g_ActiveConfig.bOverlayProjStats)
{ {
@ -1406,7 +1405,7 @@ void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth(); int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth();
int nBackbufferHeight = (int)OpenGL_GetBackbufferHeight(); int nBackbufferHeight = (int)OpenGL_GetBackbufferHeight();
glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f, glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f); ((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f);
s_pfont->printMultilineText(pstr, s_pfont->printMultilineText(pstr,
left * 2.0f / (float)nBackbufferWidth - 1, left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight, 1 - top * 2.0f / (float)nBackbufferHeight,
@ -1536,12 +1535,12 @@ void Renderer::FlipImageData(u8 *data, int w, int h)
void UpdateViewport() void UpdateViewport()
{ {
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz) // reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2 // [0] = width/2
// [1] = height/2 // [1] = height/2
// [2] = 16777215 * (farz - nearz) // [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342 // [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342 // [4] = yorig + height/2 + 342
// [5] = 16777215 * farz // [5] = 16777215 * farz
int scissorXOff = bpmem.scissorOffset.x * 2; // 342 int scissorXOff = bpmem.scissorOffset.x * 2; // 342
int scissorYOff = bpmem.scissorOffset.y * 2; // 342 int scissorYOff = bpmem.scissorOffset.y * 2; // 342
@ -1570,12 +1569,12 @@ void UpdateViewport()
void Renderer::SetGenerationMode() void Renderer::SetGenerationMode()
{ {
// none, ccw, cw, ccw // none, ccw, cw, ccw
if (bpmem.genMode.cullmode > 0) if (bpmem.genMode.cullmode > 0)
{ {
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW); glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
} }
else else
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
@ -1608,9 +1607,9 @@ void Renderer::SetLogicOpMode()
void Renderer::SetDitherMode() void Renderer::SetDitherMode()
{ {
if (bpmem.blendmode.dither) if (bpmem.blendmode.dither)
glEnable(GL_DITHER); glEnable(GL_DITHER);
else else
glDisable(GL_DITHER); glDisable(GL_DITHER);
} }

View file

@ -102,15 +102,15 @@ class CWiiMote
public: public:
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote) CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
: m_WiimoteNumber(_WiimoteNumber) : m_WiimoteNumber(_WiimoteNumber)
, m_channelID(0) , m_channelID(0)
, m_pWiiMote(_pWiimote) , m_pWiiMote(_pWiimote)
, m_pCriticalSection(NULL) , m_pCriticalSection(NULL)
, m_LastReportValid(false) , m_LastReportValid(false)
{ {
m_pCriticalSection = new Common::CriticalSection(); m_pCriticalSection = new Common::CriticalSection();
//wiiuse_set_leds(m_pWiiMote, WIIMOTE_LED_4); //wiiuse_set_leds(m_pWiiMote, WIIMOTE_LED_4);
#ifdef _WIN32 #ifdef _WIN32
// F|RES: i dunno if we really need this // F|RES: i dunno if we really need this
@ -120,27 +120,27 @@ CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
virtual ~CWiiMote() virtual ~CWiiMote()
{ {
delete m_pCriticalSection; delete m_pCriticalSection;
}; };
// Queue raw HID data from the core to the wiimote // Queue raw HID data from the core to the wiimote
void SendData(u16 _channelID, const u8* _pData, u32 _Size) void SendData(u16 _channelID, const u8* _pData, u32 _Size)
{ {
m_channelID = _channelID; m_channelID = _channelID;
m_pCriticalSection->Enter(); m_pCriticalSection->Enter();
{ {
SEvent WriteEvent; SEvent WriteEvent;
memcpy(WriteEvent.m_PayLoad, _pData, _Size); memcpy(WriteEvent.m_PayLoad, _pData, _Size);
WriteEvent._Size = _Size; WriteEvent._Size = _Size;
m_EventWriteQueue.push(WriteEvent); m_EventWriteQueue.push(WriteEvent);
// Debugging // Debugging
//std::string Temp = ArrayToString(WriteEvent.m_PayLoad, 28, 0, 30); //std::string Temp = ArrayToString(WriteEvent.m_PayLoad, 28, 0, 30);
//DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s", Temp.c_str()); //DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s", Temp.c_str());
} }
m_pCriticalSection->Leave(); m_pCriticalSection->Leave();
} }
@ -210,22 +210,22 @@ void ReadData()
void Update() void Update()
{ {
// Thread function // Thread function
m_pCriticalSection->Enter(); m_pCriticalSection->Enter();
if (m_EventReadQueue.empty()) if (m_EventReadQueue.empty())
{ {
// Send the data report // Send the data report
if (m_LastReportValid) if (m_LastReportValid)
SendEvent(m_LastReport); SendEvent(m_LastReport);
} }
else else
{ {
// Send a 0x20, 0x21 or 0x22 report // Send a 0x20, 0x21 or 0x22 report
SendEvent(m_EventReadQueue.front()); SendEvent(m_EventReadQueue.front());
m_EventReadQueue.pop(); m_EventReadQueue.pop();
} }
m_pCriticalSection->Leave(); m_pCriticalSection->Leave();
}; };
@ -240,45 +240,45 @@ void ClearEvents()
private: private:
struct SEvent struct SEvent
{ {
SEvent() SEvent()
{ {
memset(m_PayLoad, 0, MAX_PAYLOAD); memset(m_PayLoad, 0, MAX_PAYLOAD);
} }
byte m_PayLoad[MAX_PAYLOAD]; byte m_PayLoad[MAX_PAYLOAD];
u32 _Size; u32 _Size;
}; };
typedef std::queue<SEvent> CEventQueue; typedef std::queue<SEvent> CEventQueue;
u8 m_WiimoteNumber; // Just for debugging u8 m_WiimoteNumber; // Just for debugging
u16 m_channelID; u16 m_channelID;
CEventQueue m_EventReadQueue; // Read from Wiimote CEventQueue m_EventReadQueue; // Read from Wiimote
CEventQueue m_EventWriteQueue; // Write to Wiimote CEventQueue m_EventWriteQueue; // Write to Wiimote
SEvent m_LastReport; SEvent m_LastReport;
wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[] wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[]
Common::CriticalSection* m_pCriticalSection; Common::CriticalSection* m_pCriticalSection;
bool m_LastReportValid; bool m_LastReportValid;
// Send queued data to the core // Send queued data to the core
void SendEvent(SEvent& _rEvent) void SendEvent(SEvent& _rEvent)
{ {
// We don't have an answer channel // We don't have an answer channel
if (m_channelID == 0) if (m_channelID == 0)
return; return;
// Check event buffer // Check event buffer
u8 Buffer[1024]; u8 Buffer[1024];
u32 Offset = 0; u32 Offset = 0;
hid_packet* pHidHeader = (hid_packet*)(Buffer + Offset); hid_packet* pHidHeader = (hid_packet*)(Buffer + Offset);
pHidHeader->type = HID_TYPE_DATA; pHidHeader->type = HID_TYPE_DATA;
pHidHeader->param = HID_PARAM_INPUT; pHidHeader->param = HID_PARAM_INPUT;
// Create the buffer // Create the buffer
memcpy(&Buffer[Offset], pHidHeader, sizeof(hid_packet)); memcpy(&Buffer[Offset], pHidHeader, sizeof(hid_packet));
Offset += sizeof(hid_packet); Offset += sizeof(hid_packet);
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, sizeof(_rEvent.m_PayLoad)); memcpy(&Buffer[Offset], _rEvent.m_PayLoad, sizeof(_rEvent.m_PayLoad));
Offset += sizeof(_rEvent.m_PayLoad); Offset += sizeof(_rEvent.m_PayLoad);
// Send it // Send it
g_WiimoteInitialize.pWiimoteInput(m_WiimoteNumber, m_channelID, Buffer, Offset); g_WiimoteInitialize.pWiimoteInput(m_WiimoteNumber, m_channelID, Buffer, Offset);
@ -348,7 +348,7 @@ int Initialize()
Connected.Init(); Connected.Init();
// Clear the wiimote classes // Clear the wiimote classes
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES); memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
for (int i = 0; i < MAX_WIIMOTES; i++) for (int i = 0; i < MAX_WIIMOTES; i++)
g_WiimoteInUse[i] = false; g_WiimoteInUse[i] = false;
@ -429,7 +429,7 @@ void Allocate()
Initialize(); Initialize();
// Clear the wiimote classes // Clear the wiimote classes
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES); memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
for (int i = 0; i < MAX_WIIMOTES; i++) for (int i = 0; i < MAX_WIIMOTES; i++)
g_WiimoteInUse[i] = false; g_WiimoteInUse[i] = false;
@ -702,7 +702,7 @@ int WiimotePairUp(bool unpair)
//btdi.szName is sometimes missings it's content - it's a bt feature.. //btdi.szName is sometimes missings it's content - it's a bt feature..
if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected && !unpair) if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected && !unpair)
{ {
//TODO: improve the readd of the BT driver, esp. when batteries of the wiimote are removed while beeing fConnected //TODO: improve the read of the BT driver, esp. when batteries of the wiimote are removed while being fConnected
if (btdi.fRemembered) if (btdi.fRemembered)
{ {
// Make Windows forget old expired pairing // Make Windows forget old expired pairing
@ -726,9 +726,9 @@ int WiimotePairUp(bool unpair)
else if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && unpair) else if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && unpair)
{ {
BluetoothRemoveDevice(&btdi.Address); BluetoothRemoveDevice(&btdi.Address);
NOTICE_LOG(WIIMOTE, "Pair-Up: Automatically removed BT Device on shutdown: %08x", GetLastError()); NOTICE_LOG(WIIMOTE, "Pair-Up: Automatically removed BT Device on shutdown: %08x", GetLastError());
nPaired++; nPaired++;
} }
} while (BluetoothFindNextDevice(hFind, &btdi)); } while (BluetoothFindNextDevice(hFind, &btdi));
@ -750,13 +750,13 @@ int WiimotePairUp(bool unpair)
#ifdef HAVE_WIIUSE #ifdef HAVE_WIIUSE
LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch(uMsg) switch(uMsg)
{ {
case WM_DEVICECHANGE: case WM_DEVICECHANGE:
// DBT_DEVNODES_CHANGED 0x007 (devnodes are atm not received); DBT_DEVICEARRIVAL 0x8000 DBT_DEVICEREMOVECOMPLETE 0x8004 // avoiding header file^^ // DBT_DEVNODES_CHANGED 0x007 (devnodes are atm not received); DBT_DEVICEARRIVAL 0x8000 DBT_DEVICEREMOVECOMPLETE 0x8004 // avoiding header file^^
if ( ( wParam == 0x8000 || wParam == 0x8004 || wParam == 0x0007 ) ) if ( ( wParam == 0x8000 || wParam == 0x8004 || wParam == 0x0007 ) )
{ {
if (wiiuse_check_system_notification(uMsg, wParam, lParam)) //extern wiiuse function: returns 1 if the event came from a wiimote if (wiiuse_check_system_notification(uMsg, wParam, lParam)) //extern wiiuse function: returns 1 if the event came from a wiimote
{ {
@ -767,7 +767,7 @@ LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
stoprefresh = 0; stoprefresh = 0;
PaiUpRefreshWiimote(); PaiUpRefreshWiimote();
break; break;
} }
else stoprefresh = 1; //fake arrival wait for second go else stoprefresh = 1; //fake arrival wait for second go
@ -786,7 +786,7 @@ LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
default: default:
return DefWindowProc(hWnd, uMsg, wParam, lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam);
} }
return 0; return 0;
} }
@ -797,14 +797,14 @@ THREAD_RETURN RunInvisibleMessageWindow_ThreadFunc(void* arg)
HWND hwnd; HWND hwnd;
WNDCLASSEX WCEx; WNDCLASSEX WCEx;
ZeroMemory(&WCEx, sizeof(WCEx)); ZeroMemory(&WCEx, sizeof(WCEx));
WCEx.cbSize = sizeof(WCEx); WCEx.cbSize = sizeof(WCEx);
WCEx.lpfnWndProc = CallBackDeviceChange; WCEx.lpfnWndProc = CallBackDeviceChange;
WCEx.hInstance = g_hInstance; WCEx.hInstance = g_hInstance;
WCEx.lpszClassName = L"MSGWND"; WCEx.lpszClassName = L"MSGWND";
if (RegisterClassEx(&WCEx) != 0) if (RegisterClassEx(&WCEx) != 0)
{ {
hwnd = CreateWindowEx(0, WCEx.lpszClassName, NULL,0, hwnd = CreateWindowEx(0, WCEx.lpszClassName, NULL,0,
0, 0, 0, 0, HWND_MESSAGE, NULL, g_hInstance, NULL); 0, 0, 0, 0, HWND_MESSAGE, NULL, g_hInstance, NULL);
@ -816,18 +816,18 @@ THREAD_RETURN RunInvisibleMessageWindow_ThreadFunc(void* arg)
wiiuse_register_system_notification(hwnd); //function moved into wiiuse to avoid ddk/wdk dependicies wiiuse_register_system_notification(hwnd); //function moved into wiiuse to avoid ddk/wdk dependicies
while(GetMessage(&Msg, 0, 0, 0) > 0) while(GetMessage(&Msg, 0, 0, 0) > 0)
{ {
TranslateMessage(&Msg); TranslateMessage(&Msg);
DispatchMessage(&Msg); DispatchMessage(&Msg);
} }
UnregisterClass(WCEx.lpszClassName, g_hInstance); UnregisterClass(WCEx.lpszClassName, g_hInstance);
if (g_Config.bUnpairRealWiimote) if (g_Config.bUnpairRealWiimote)
WiiMoteReal::WiimotePairUp(true); WiiMoteReal::WiimotePairUp(true);
return (int)Msg.wParam; return (int)Msg.wParam;
} }