From 0332ec742e3891a7ce7d3c7c08330c33138dd0c3 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Sun, 10 Aug 2008 21:34:22 +0000 Subject: [PATCH] - Added message queue to DX9 plugin. - Added plugin interface function Video_AddMessage to both plugins and to the plugin specs. - Added handling of the Video_AddMessage interface export from the core side. - Added a print on Core::Init for testing purposes (might not be the best place). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@176 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 3 ++ Source/Core/Core/Src/Plugins/Plugin_Video.cpp | 14 ++++- Source/Core/Core/Src/Plugins/Plugin_Video.h | 1 + Source/PluginSpecs/pluginspecs_video.h | 16 ++++-- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 53 +++++++++++++++++++ Source/Plugins/Plugin_VideoDX9/Src/Render.h | 6 +++ Source/Plugins/Plugin_VideoDX9/Src/main.cpp | 8 +++ Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 5 ++ 8 files changed, 101 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 01cf7f3e35..8bd7d21b33 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -133,6 +133,9 @@ bool Init(const SCoreStartupParameter _CoreParameter) emuThreadGoing.Shutdown(); // all right ... here we go Host_SetWaitCursor(false); + + PluginVideo::Video_AddMessage("Emulation started.",3000); + return true; } diff --git a/Source/Core/Core/Src/Plugins/Plugin_Video.cpp b/Source/Core/Core/Src/Plugins/Plugin_Video.cpp index e11d0f2c88..01d4f3fae9 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Video.cpp +++ b/Source/Core/Core/Src/Plugins/Plugin_Video.cpp @@ -33,6 +33,9 @@ typedef void (__cdecl* TVideo_UpdateXFB)(BYTE*, DWORD, DWORD); typedef BOOL (__cdecl* TVideo_Screenshot)(TCHAR*); typedef void (__cdecl* TVideo_EnterLoop)(); +typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); + + //! Function Pointer TGetDllInfo g_GetDllInfo = 0; TDllAbout g_DllAbout = 0; @@ -44,6 +47,7 @@ TVideo_SendFifoData g_Video_SendFifoData = 0; TVideo_UpdateXFB g_Video_UpdateXFB = 0; TVideo_Screenshot g_Video_Screenshot = 0; TVideo_EnterLoop g_Video_EnterLoop = 0; +TVideo_AddMessage g_Video_AddMessage = 0; //! Library Instance DynamicLibrary plugin; @@ -64,6 +68,7 @@ void UnloadPlugin() g_Video_Shutdown = 0; g_Video_SendFifoData = 0; g_Video_UpdateXFB = 0; + g_Video_AddMessage = 0; plugin.Unload(); } @@ -82,6 +87,7 @@ bool LoadPlugin(const char *_Filename) g_Video_UpdateXFB = reinterpret_cast (plugin.Get("Video_UpdateXFB")); g_Video_Screenshot = reinterpret_cast (plugin.Get("Video_Screenshot")); g_Video_EnterLoop = reinterpret_cast (plugin.Get("Video_EnterLoop")); + g_Video_AddMessage = reinterpret_cast (plugin.Get("Video_AddMessage")); if ((g_GetDllInfo != 0) && (g_DllAbout != 0) && @@ -92,7 +98,8 @@ bool LoadPlugin(const char *_Filename) (g_Video_SendFifoData != 0) && (g_Video_UpdateXFB != 0) && (g_Video_EnterLoop != 0) && - (g_Video_Screenshot != 0)) + (g_Video_Screenshot != 0) && + (g_Video_AddMessage != 0)) { return true; } @@ -159,4 +166,9 @@ void Video_EnterLoop() g_Video_EnterLoop(); } +void Video_AddMessage(const char* pstr, unsigned int milliseconds) +{ + g_Video_AddMessage(pstr,milliseconds); +} + } // end of namespace PluginVideo diff --git a/Source/Core/Core/Src/Plugins/Plugin_Video.h b/Source/Core/Core/Src/Plugins/Plugin_Video.h index 4c9bece34d..3c8f9f5c64 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Video.h +++ b/Source/Core/Core/Src/Plugins/Plugin_Video.h @@ -40,6 +40,7 @@ void Video_EnterLoop(); void Video_SendFifoData(BYTE *_uData); void Video_UpdateXFB(BYTE* _pXFB, DWORD _dwHeight, DWORD _dwWidth); bool Video_Screenshot(TCHAR* _szFilename); +void Video_AddMessage(const char* pstr, unsigned int milliseconds); } // end of namespace PluginVideo diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index 5a8665970c..3ee9d02396 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -162,13 +162,21 @@ EXPORT BOOL CALL Video_Screenshot(TCHAR* _szFilename); // __________________________________________________________________________________________________ -// Function: Video_Screenshot -// Purpose: This fucntion is called when you want to do a screenshot -// input: Filename -// output: TRUE if all was okay +// Function: Video_EnterLoop +// Purpose: FIXME! +// input: none +// output: none // EXPORT void CALL Video_EnterLoop(void); +// __________________________________________________________________________________________________ +// Function: Video_AddMessage +// Purpose: Adds a message to the display queue, to be shown forthe specified time +// input: pointer to the null-terminated string, time in milliseconds +// output: none +// +EXPORT void CALL Video_AddMessage(const char* pstr, unsigned int milliseconds); + #undef CALL #if defined(__cplusplus) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 49bddb3ab3..d53045fc23 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -18,11 +18,23 @@ #include "Utils.h" #include "EmuWindow.h" +#include +using namespace std; + float Renderer::m_x,Renderer::m_y,Renderer::m_width, Renderer::m_height, Renderer::xScale,Renderer::yScale; #define NUMWNDRES 6 extern int g_Res[NUMWNDRES][2]; +struct MESSAGE +{ + MESSAGE() {} + MESSAGE(const char* p, u32 dw) { strcpy(str, p); dwTimeStamp = dw; } + char str[255]; + u32 dwTimeStamp; +}; +static std::list s_listMsgs; + void Renderer::Init(SVideoInitialize &_VideoInitialize) { EmuWindow::SetSize(g_Res[g_Config.iWindowedRes][0], g_Res[g_Config.iWindowedRes][1]); @@ -69,6 +81,45 @@ void Renderer::Initialize(void) CVertexHandler::BeginFrame(); } +void Renderer::AddMessage(const char* pstr, u32 ms) +{ + s_listMsgs.push_back(MESSAGE(pstr, timeGetTime()+ms)); +} + +void Renderer::ProcessMessages() +{ + if (s_listMsgs.size() > 0) { + int left = 25, top = 15; + list::iterator it = s_listMsgs.begin(); + + while( it != s_listMsgs.end() ) + { + int time_left = (int)(it->dwTimeStamp - timeGetTime()); + int alpha = 255; + + if(time_left<1024) + { + alpha=time_left>>2; + if(time_left<0) alpha=0; + } + + alpha<<=24; + + RenderText(it->str, left+1, top+1, 0x000000|alpha); + RenderText(it->str, left, top, 0xffff30|alpha); + top += 15; + + if (time_left <= 0) + it = s_listMsgs.erase(it); + else ++it; + } + } +} + +void Renderer::RenderText(const char* pstr, int left, int top, u32 color) +{ + D3D::font.DrawTextScaled(left,top,20,20,0.0f,color,pstr,false); +} void dumpMatrix(D3DXMATRIX &mtx) { @@ -145,6 +196,8 @@ void Renderer::SwapBuffers(void) //end frame } + ProcessMessages(); + #if defined(DVPROFILE) if( g_bWriteProfile ) { //g_bWriteProfile = 0; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.h b/Source/Plugins/Plugin_VideoDX9/Src/Render.h index e8181da999..1351fe8594 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.h @@ -27,4 +27,10 @@ public: static void SetScissorBox(RECT &rc); static void SetViewport(float* _Viewport); static void SetProjection(float* _pProjection, int constantIndex = -1); + + + static void AddMessage(const char* pstr, unsigned int ms); + static void ProcessMessages(); + static void RenderText(const char* pstr, int left, int top, unsigned int color); + }; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index b69421493e..de05a114ca 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -158,6 +158,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; + + Renderer::AddMessage("Dolphin Direct3D9 Video Plugin.",5000); + } void Video_Prepare(void) @@ -265,3 +268,8 @@ BOOL Video_Screenshot(TCHAR* _szFilename) return FALSE; } + +void Video_AddMessage(const char* pstr, u32 milliseconds) +{ + Renderer::AddMessage(pstr,milliseconds); +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index a1c2aae131..1c63f90a33 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -239,3 +239,8 @@ BOOL Video_Screenshot(TCHAR* _szFilename) void Video_UpdateXFB(BYTE* _pXFB, DWORD _dwWidth, DWORD _dwHeight) { } + +void Video_AddMessage(const char* pstr, u32 milliseconds) +{ + Renderer::AddMessage(pstr,milliseconds); +}