2009-07-28 21:32:10 +00:00
// Copyright (C) 2003 Dolphin Project.
2008-12-08 05:25:12 +00:00
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
# include "Common.h"
2009-09-04 17:29:16 +00:00
# include "Atomic.h"
2009-07-12 21:58:32 +00:00
# include "Thread.h"
# include "LogManager.h"
2009-09-20 03:29:43 +00:00
# include "debugger/debugger.h"
2008-12-08 05:25:12 +00:00
2010-06-13 19:41:07 +00:00
# if defined(HAVE_WX) && HAVE_WX
# include "DlgSettings.h"
GFXConfigDialogDX * m_ConfigFrame = NULL ;
# endif // HAVE_WX
2009-09-02 06:33:41 +00:00
# if defined(HAVE_WX) && HAVE_WX
# include "Debugger/Debugger.h"
GFXDebuggerDX9 * m_DebuggerFrame = NULL ;
# endif // HAVE_WX
2008-12-08 05:25:12 +00:00
# include "main.h"
2009-09-13 09:23:30 +00:00
# include "VideoConfig.h"
2008-12-08 05:25:12 +00:00
# include "Fifo.h"
# include "OpcodeDecoding.h"
# include "TextureCache.h"
2009-06-22 09:31:30 +00:00
# include "BPStructs.h"
2008-12-08 05:25:12 +00:00
# include "VertexManager.h"
2008-12-25 20:07:13 +00:00
# include "VertexLoaderManager.h"
2009-03-07 23:20:14 +00:00
# include "VertexShaderManager.h"
# include "PixelShaderManager.h"
# include "VertexShaderCache.h"
# include "PixelShaderCache.h"
2009-10-10 21:19:39 +00:00
# include "CommandProcessor.h"
# include "PixelEngine.h"
2009-09-03 20:37:35 +00:00
# include "OnScreenDisplay.h"
2008-12-08 05:25:12 +00:00
# include "DlgSettings.h"
# include "D3DTexture.h"
# include "D3DUtil.h"
# include "EmuWindow.h"
# include "VideoState.h"
# include "XFBConvert.h"
2009-09-20 03:29:43 +00:00
# include "render.h"
2008-12-08 05:25:12 +00:00
HINSTANCE g_hInstance = NULL ;
SVideoInitialize g_VideoInitialize ;
2009-03-18 17:17:58 +00:00
PLUGIN_GLOBALS * globals = NULL ;
2010-03-14 18:57:50 +00:00
static bool s_PluginInitialized = false ;
2008-12-08 05:25:12 +00:00
2010-03-14 18:57:50 +00:00
volatile u32 s_swapRequested = FALSE ;
2009-09-04 17:29:16 +00:00
static u32 s_efbAccessRequested = FALSE ;
2010-01-03 22:18:50 +00:00
static volatile u32 s_FifoShuttingDown = FALSE ;
2010-01-01 03:55:39 +00:00
2009-09-20 03:29:43 +00:00
static volatile struct
{
u32 xfbAddr ;
FieldType field ;
u32 fbWidth ;
u32 fbHeight ;
} s_beginFieldArgs ;
2009-09-04 17:29:16 +00:00
2009-07-02 17:45:09 +00:00
static volatile EFBAccessType s_AccessEFBType ;
2009-08-09 12:12:29 +00:00
bool HandleDisplayList ( u32 address , u32 size )
{
return false ;
}
2009-09-02 06:33:41 +00:00
2009-09-13 21:18:04 +00:00
bool IsD3D ( )
{
return true ;
}
2009-09-02 06:33:41 +00:00
// This is used for the functions right below here which use wxwidgets
# if defined(HAVE_WX) && HAVE_WX
2010-06-18 18:40:58 +00:00
WXDLLIMPEXP_BASE void wxSetInstance ( HINSTANCE hInst ) ;
2009-09-02 06:33:41 +00:00
wxWindow * GetParentedWxWindow ( HWND Parent )
{
wxSetInstance ( ( HINSTANCE ) g_hInstance ) ;
wxWindow * win = new wxWindow ( ) ;
win - > SetHWND ( ( WXHWND ) Parent ) ;
win - > AdoptAttributesFromHWND ( ) ;
return win ;
}
# endif
2008-12-08 05:25:12 +00:00
void DllDebugger ( HWND _hParent , bool Show )
{
2010-02-24 19:32:32 +00:00
# if defined(HAVE_WX) && HAVE_WX
2009-09-02 06:33:41 +00:00
if ( ! m_DebuggerFrame )
m_DebuggerFrame = new GFXDebuggerDX9 ( GetParentedWxWindow ( _hParent ) ) ;
if ( Show )
m_DebuggerFrame - > Show ( ) ;
else
m_DebuggerFrame - > Hide ( ) ;
# endif
2010-02-24 19:32:32 +00:00
}
2009-09-02 06:33:41 +00:00
# if defined(HAVE_WX) && HAVE_WX
class wxDLLApp : public wxApp
{
bool OnInit ( )
{
return true ;
}
} ;
IMPLEMENT_APP_NO_MAIN ( wxDLLApp )
WXDLLIMPEXP_BASE void wxSetInstance ( HINSTANCE hInst ) ;
# endif
2009-09-12 15:00:08 +00:00
BOOL APIENTRY DllMain ( HINSTANCE hinstDLL , DWORD dwReason , LPVOID lpvReserved )
2008-12-08 05:25:12 +00:00
{
switch ( dwReason )
{
case DLL_PROCESS_ATTACH :
2009-09-02 06:33:41 +00:00
{
2010-02-24 19:32:32 +00:00
# if defined(HAVE_WX) && HAVE_WX
2009-09-02 06:33:41 +00:00
wxSetInstance ( ( HINSTANCE ) hinstDLL ) ;
2010-02-24 19:32:32 +00:00
wxInitialize ( ) ;
# endif
2009-09-02 06:33:41 +00:00
}
2008-12-08 05:25:12 +00:00
break ;
case DLL_PROCESS_DETACH :
2010-02-24 19:32:32 +00:00
# if defined(HAVE_WX) && HAVE_WX
wxUninitialize ( ) ;
# endif
2008-12-08 05:25:12 +00:00
break ;
}
g_hInstance = hinstDLL ;
return TRUE ;
}
2008-12-11 15:12:17 +00:00
unsigned int Callback_PeekMessages ( )
2008-12-08 05:25:12 +00:00
{
MSG msg ;
while ( PeekMessage ( & msg , 0 , 0 , 0 , PM_REMOVE ) )
{
if ( msg . message = = WM_QUIT )
return FALSE ;
TranslateMessage ( & msg ) ;
DispatchMessage ( & msg ) ;
}
return TRUE ;
}
void UpdateFPSDisplay ( const char * text )
{
2010-05-23 02:29:23 +00:00
TCHAR temp [ 512 ] ;
2010-07-08 15:25:01 +00:00
swprintf_s ( temp , 512 , _T ( " SVN R%s: DX9: %hs " ) , svn_rev_str , text ) ;
2010-07-08 15:56:09 +00:00
SetWindowText ( EmuWindow : : GetWnd ( ) , temp ) ;
2008-12-08 05:25:12 +00:00
}
2009-01-15 06:48:15 +00:00
void GetDllInfo ( PLUGIN_INFO * _PluginInfo )
2008-12-08 05:25:12 +00:00
{
_PluginInfo - > Version = 0x0100 ;
_PluginInfo - > Type = PLUGIN_TYPE_VIDEO ;
2009-01-15 06:48:15 +00:00
# ifdef DEBUGFAST
2008-12-25 20:07:13 +00:00
sprintf_s ( _PluginInfo - > Name , 100 , " Dolphin Direct3D9 (DebugFast) " ) ;
2008-12-08 05:25:12 +00:00
# else
# ifndef _DEBUG
2008-12-25 20:07:13 +00:00
sprintf_s ( _PluginInfo - > Name , 100 , " Dolphin Direct3D9 " ) ;
2008-12-08 05:25:12 +00:00
# else
2008-12-25 20:07:13 +00:00
sprintf_s ( _PluginInfo - > Name , 100 , " Dolphin Direct3D9 (Debug) " ) ;
2008-12-08 05:25:12 +00:00
# endif
# endif
}
2010-05-23 02:29:23 +00:00
void SetDllGlobals ( PLUGIN_GLOBALS * _pPluginGlobals )
{
2009-03-18 17:17:58 +00:00
globals = _pPluginGlobals ;
2010-05-23 02:29:23 +00:00
LogManager : : SetInstance ( ( LogManager * ) globals - > logManager ) ;
2009-01-08 12:12:15 +00:00
}
2009-01-15 06:48:15 +00:00
void DllAbout ( HWND _hParent )
2008-12-08 05:25:12 +00:00
{
2010-06-13 20:08:20 +00:00
//DialogBox(g_hInstance,(LPCTSTR)IDD_ABOUT,_hParent,(DLGPROC)AboutProc);
2008-12-08 05:25:12 +00:00
}
void DllConfig ( HWND _hParent )
{
2009-09-12 15:00:08 +00:00
// If not initialized, only init D3D so we can enumerate resolutions.
2010-05-23 02:29:23 +00:00
if ( ! s_PluginInitialized )
D3D : : Init ( ) ;
2010-06-13 19:41:07 +00:00
g_Config . Load ( ( std : : string ( File : : GetUserPath ( D_CONFIG_IDX ) ) + " gfx_dx9.ini " ) . c_str ( ) ) ;
g_Config . GameIniLoad ( globals - > game_ini ) ;
UpdateActiveConfig ( ) ;
# if defined(HAVE_WX) && HAVE_WX
wxWindow * frame = GetParentedWxWindow ( _hParent ) ;
m_ConfigFrame = new GFXConfigDialogDX ( frame ) ;
// Prevent user to show more than 1 config window at same time
frame - > Disable ( ) ;
m_ConfigFrame - > CreateGUIControls ( ) ;
m_ConfigFrame - > ShowModal ( ) ;
frame - > Enable ( ) ;
frame - > SetFocus ( ) ;
frame - > SetHWND ( NULL ) ;
m_ConfigFrame - > Destroy ( ) ;
m_ConfigFrame = NULL ;
frame - > Destroy ( ) ;
# endif
2010-05-23 02:29:23 +00:00
if ( ! s_PluginInitialized )
D3D : : Shutdown ( ) ;
2008-12-08 05:25:12 +00:00
}
2009-01-15 06:48:15 +00:00
void Initialize ( void * init )
2008-12-08 05:25:12 +00:00
{
frameCount = 0 ;
2010-01-20 07:47:41 +00:00
SVideoInitialize * _pVideoInitialize = ( SVideoInitialize * ) init ;
2008-12-08 05:25:12 +00:00
g_VideoInitialize = * _pVideoInitialize ;
2010-01-20 07:47:41 +00:00
InitXFBConvTables ( ) ;
2009-09-13 17:46:33 +00:00
2010-02-02 21:56:29 +00:00
g_Config . Load ( ( std : : string ( File : : GetUserPath ( D_CONFIG_IDX ) ) + " gfx_dx9.ini " ) . c_str ( ) ) ;
2009-09-13 17:46:33 +00:00
g_Config . GameIniLoad ( globals - > game_ini ) ;
UpdateProjectionHack ( g_Config . iPhackvalue ) ; // DX9 projection hack could be disabled by commenting out this line
2010-01-20 07:47:41 +00:00
UpdateActiveConfig ( ) ;
g_VideoInitialize . pWindowHandle = ( void * ) EmuWindow : : Create ( ( HWND ) g_VideoInitialize . pWindowHandle , g_hInstance , _T ( " Loading - Please wait. " ) ) ;
2009-09-13 17:46:33 +00:00
if ( g_VideoInitialize . pWindowHandle = = NULL )
{
ERROR_LOG ( VIDEO , " An error has occurred while trying to create the window. " ) ;
return ;
}
2010-01-20 07:47:41 +00:00
else if ( FAILED ( D3D : : Init ( ) ) )
2009-09-13 17:46:33 +00:00
{
2010-05-23 02:29:23 +00:00
MessageBox ( GetActiveWindow ( ) , _T ( " Unable to initialize Direct3D. Please make sure that you have the latest version of DirectX 9.0c correctly installed. " ) , _T ( " Fatal Error " ) , MB_ICONERROR | MB_OK ) ;
2009-09-13 17:46:33 +00:00
return ;
}
2010-01-20 07:47:41 +00:00
2010-05-23 02:29:23 +00:00
std : : wstring msg ;
if ( ! D3D : : DXCheck ( msg ) )
{
msg . insert ( 0 , _T ( " Unable to initialize Direct3D. " ) ) ;
msg . append ( _T ( " \n \n Have a nice crash. :P " ) ) ;
MessageBox ( ( HWND ) g_VideoInitialize . pWindowHandle , msg . c_str ( ) , _T ( " Critical Error " ) , MB_ICONERROR | MB_OK ) ;
ShellExecute ( NULL , NULL , _T ( " http://www.microsoft.com/downloads/details.aspx?FamilyID=2da43d38-db71-4c1b-bc6a-9b6652cd92a3 " ) , NULL , NULL , SW_SHOWNORMAL ) ;
}
2010-01-20 07:47:41 +00:00
g_VideoInitialize . pPeekMessages = & Callback_PeekMessages ;
g_VideoInitialize . pUpdateFPSDisplay = & UpdateFPSDisplay ;
2010-05-23 02:29:23 +00:00
_pVideoInitialize - > pPeekMessages = g_VideoInitialize . pPeekMessages ;
_pVideoInitialize - > pUpdateFPSDisplay = g_VideoInitialize . pUpdateFPSDisplay ;
_pVideoInitialize - > pWindowHandle = g_VideoInitialize . pWindowHandle ;
2010-01-20 07:47:41 +00:00
OSD : : AddMessage ( " Dolphin Direct3D9 Video Plugin. " , 5000 ) ;
2010-03-14 18:57:50 +00:00
s_PluginInitialized = true ;
2009-08-08 01:39:56 +00:00
}
2009-02-20 22:04:52 +00:00
2009-09-13 17:46:33 +00:00
void Video_Prepare ( )
2008-12-08 05:25:12 +00:00
{
2010-01-01 03:55:39 +00:00
// Better be safe...
s_efbAccessRequested = FALSE ;
s_FifoShuttingDown = FALSE ;
2010-03-14 18:57:50 +00:00
s_swapRequested = FALSE ;
2009-09-03 20:37:35 +00:00
Renderer : : Init ( ) ;
2008-12-08 05:25:12 +00:00
TextureCache : : Init ( ) ;
2009-06-22 09:31:30 +00:00
BPInit ( ) ;
2008-12-08 05:25:12 +00:00
VertexManager : : Init ( ) ;
Fifo_Init ( ) ;
2008-12-25 20:07:13 +00:00
VertexLoaderManager : : Init ( ) ;
2008-12-08 05:25:12 +00:00
OpcodeDecoder_Init ( ) ;
2009-03-07 23:20:14 +00:00
VertexShaderManager : : Init ( ) ;
PixelShaderManager : : Init ( ) ;
2010-05-23 02:29:23 +00:00
CommandProcessor : : Init ( ) ;
PixelEngine : : Init ( ) ;
2010-04-15 20:58:34 +00:00
// Tell the host the window is ready
g_VideoInitialize . pCoreMessage ( WM_USER_CREATE ) ;
2008-12-08 05:25:12 +00:00
}
2009-09-13 17:46:33 +00:00
void Shutdown ( )
2008-12-08 05:25:12 +00:00
{
2009-09-13 17:46:33 +00:00
s_efbAccessRequested = FALSE ;
2010-01-01 03:55:39 +00:00
s_FifoShuttingDown = FALSE ;
2010-03-14 18:57:50 +00:00
s_swapRequested = FALSE ;
2008-12-08 05:25:12 +00:00
Fifo_Shutdown ( ) ;
2010-06-12 15:49:21 +00:00
CommandProcessor : : Shutdown ( ) ;
2008-12-08 05:25:12 +00:00
VertexManager : : Shutdown ( ) ;
2009-03-07 23:20:14 +00:00
VertexLoaderManager : : Shutdown ( ) ;
2009-09-13 17:46:33 +00:00
VertexShaderManager : : Shutdown ( ) ;
2009-03-07 23:20:14 +00:00
PixelShaderManager : : Shutdown ( ) ;
2008-12-08 05:25:12 +00:00
TextureCache : : Shutdown ( ) ;
2009-09-13 17:46:33 +00:00
OpcodeDecoder_Shutdown ( ) ;
2008-12-08 05:25:12 +00:00
Renderer : : Shutdown ( ) ;
2009-09-13 17:46:33 +00:00
D3D : : Shutdown ( ) ;
EmuWindow : : Close ( ) ;
2010-03-14 18:57:50 +00:00
s_PluginInitialized = false ;
2008-12-08 05:25:12 +00:00
}
2009-09-12 15:00:08 +00:00
void DoState ( unsigned char * * ptr , int mode ) {
// Clear texture cache because it might have written to RAM
2010-04-17 20:14:38 +00:00
CommandProcessor : : FifoCriticalEnter ( ) ;
2009-09-12 15:00:08 +00:00
TextureCache : : Invalidate ( false ) ;
2010-04-17 20:14:38 +00:00
CommandProcessor : : FifoCriticalLeave ( ) ;
2009-09-15 19:53:22 +00:00
// No need to clear shader caches.
2009-09-12 15:00:08 +00:00
PointerWrap p ( ptr , mode ) ;
VideoCommon_DoState ( p ) ;
}
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
void EmuStateChange ( PLUGIN_EMUSTATE newState )
{
2010-01-07 20:01:41 +00:00
Fifo_RunLoop ( ( newState = = PLUGIN_EMUSTATE_PLAY ) ? true : false ) ;
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
}
2009-09-12 15:00:08 +00:00
void Video_EnterLoop ( )
{
Fifo_EnterLoop ( g_VideoInitialize ) ;
}
void Video_ExitLoop ( )
{
Fifo_ExitLoop ( ) ;
2010-01-01 03:55:39 +00:00
s_FifoShuttingDown = TRUE ;
2009-09-12 15:00:08 +00:00
}
void Video_SetRendering ( bool bEnabled ) {
Fifo_SetRendering ( bEnabled ) ;
}
2010-06-29 14:40:37 +00:00
// Run from the graphics thread (from Fifo.cpp)
2009-07-11 02:34:16 +00:00
void VideoFifo_CheckSwapRequest ( )
{
2010-06-29 14:40:37 +00:00
if ( g_ActiveConfig . bUseXFB )
2009-09-20 03:29:43 +00:00
{
2010-06-29 14:40:37 +00:00
if ( Common : : AtomicLoadAcquire ( s_swapRequested ) )
2009-09-20 03:29:43 +00:00
{
2010-07-02 17:09:53 +00:00
EFBRectangle rc ;
Renderer : : Swap ( s_beginFieldArgs . xfbAddr , s_beginFieldArgs . field , s_beginFieldArgs . fbWidth , s_beginFieldArgs . fbHeight , rc ) ;
2010-06-29 14:40:37 +00:00
Common : : AtomicStoreRelease ( s_swapRequested , FALSE ) ;
2009-09-20 03:29:43 +00:00
}
}
2009-07-11 02:34:16 +00:00
}
2010-03-14 18:57:50 +00:00
inline bool addrRangesOverlap ( u32 aLower , u32 aUpper , u32 bLower , u32 bUpper )
{
return ! ( ( aLower > = bUpper ) | | ( bLower > = aUpper ) ) ;
}
2010-06-29 14:40:37 +00:00
// Run from the graphics thread (from Fifo.cpp)
2009-07-11 02:34:16 +00:00
void VideoFifo_CheckSwapRequestAt ( u32 xfbAddr , u32 fbWidth , u32 fbHeight )
{
2010-06-29 14:40:37 +00:00
if ( g_ActiveConfig . bUseXFB )
2010-03-14 18:57:50 +00:00
{
2010-06-29 14:40:37 +00:00
if ( Common : : AtomicLoadAcquire ( s_swapRequested ) )
{
u32 aLower = xfbAddr ;
u32 aUpper = xfbAddr + 2 * fbWidth * fbHeight ;
u32 bLower = s_beginFieldArgs . xfbAddr ;
u32 bUpper = s_beginFieldArgs . xfbAddr + 2 * s_beginFieldArgs . fbWidth * s_beginFieldArgs . fbHeight ;
2010-03-14 18:57:50 +00:00
2010-06-29 14:40:37 +00:00
if ( addrRangesOverlap ( aLower , aUpper , bLower , bUpper ) )
VideoFifo_CheckSwapRequest ( ) ;
}
}
2009-07-11 16:52:34 +00:00
}
2009-09-20 03:29:43 +00:00
// Run from the CPU thread (from VideoInterface.cpp)
2009-07-11 02:34:16 +00:00
void Video_BeginField ( u32 xfbAddr , FieldType field , u32 fbWidth , u32 fbHeight )
2008-12-08 05:25:12 +00:00
{
2010-03-25 02:26:12 +00:00
if ( s_PluginInitialized & & g_ActiveConfig . bUseXFB )
2010-06-29 14:40:37 +00:00
{
2009-10-23 15:26:35 +00:00
if ( g_VideoInitialize . bOnThread )
2009-09-20 03:29:43 +00:00
{
2010-03-14 18:57:50 +00:00
while ( Common : : AtomicLoadAcquire ( s_swapRequested ) & & ! s_FifoShuttingDown )
//Common::SleepCurrentThread(1);
Common : : YieldCPU ( ) ;
2009-09-20 03:29:43 +00:00
}
else
2010-06-29 14:40:37 +00:00
VideoFifo_CheckSwapRequest ( ) ;
s_beginFieldArgs . xfbAddr = xfbAddr ;
s_beginFieldArgs . field = field ;
s_beginFieldArgs . fbWidth = fbWidth ;
s_beginFieldArgs . fbHeight = fbHeight ;
Common : : AtomicStoreRelease ( s_swapRequested , TRUE ) ;
2009-09-20 03:29:43 +00:00
}
2008-12-08 05:25:12 +00:00
}
2009-07-15 22:20:59 +00:00
void Video_EndField ( )
{
}
2009-02-20 22:04:52 +00:00
void Video_AddMessage ( const char * pstr , u32 milliseconds )
{
2009-09-03 20:37:35 +00:00
OSD : : AddMessage ( pstr , milliseconds ) ;
2009-02-20 22:04:52 +00:00
}
2008-12-08 05:25:12 +00:00
2009-02-27 03:56:34 +00:00
HRESULT ScreenShot ( const char * File )
2008-12-08 05:25:12 +00:00
{
2010-01-27 22:07:59 +00:00
Renderer : : SetScreenshot ( File ) ;
2008-12-08 05:25:12 +00:00
return S_OK ;
}
2009-02-27 03:56:34 +00:00
void Video_Screenshot ( const char * _szFilename )
2008-12-08 05:25:12 +00:00
{
2009-03-01 10:53:23 +00:00
if ( ScreenShot ( _szFilename ) ! = S_OK )
2009-02-27 03:56:34 +00:00
PanicAlert ( " Error while capturing screen " ) ;
2009-02-27 11:45:07 +00:00
else {
std : : string message = " Saved " ;
message + = _szFilename ;
2009-09-03 20:37:35 +00:00
OSD : : AddMessage ( message . c_str ( ) , 2000 ) ;
2009-02-27 11:45:07 +00:00
}
2008-12-08 05:25:12 +00:00
}
2009-07-02 17:45:09 +00:00
2009-09-04 17:29:16 +00:00
static struct
2009-07-02 17:45:09 +00:00
{
2009-09-04 17:29:16 +00:00
EFBAccessType type ;
u32 x ;
u32 y ;
2010-06-15 21:19:09 +00:00
u32 Data ;
2009-09-04 17:29:16 +00:00
} s_accessEFBArgs ;
2009-07-02 17:45:09 +00:00
2009-09-04 17:29:16 +00:00
static u32 s_AccessEFBResult = 0 ;
2009-07-02 17:45:09 +00:00
2009-09-04 17:29:16 +00:00
void VideoFifo_CheckEFBAccess ( )
{
if ( Common : : AtomicLoadAcquire ( s_efbAccessRequested ) )
{
s_AccessEFBResult = Renderer : : AccessEFB ( s_accessEFBArgs . type , s_accessEFBArgs . x , s_accessEFBArgs . y ) ;
2009-07-02 17:45:09 +00:00
2009-09-04 17:29:16 +00:00
Common : : AtomicStoreRelease ( s_efbAccessRequested , FALSE ) ;
2009-07-02 17:45:09 +00:00
}
}
2010-06-15 21:19:09 +00:00
u32 Video_AccessEFB ( EFBAccessType type , u32 x , u32 y , u32 InputData )
2009-07-02 17:45:09 +00:00
{
2010-03-14 18:57:50 +00:00
if ( s_PluginInitialized )
{
s_accessEFBArgs . type = type ;
s_accessEFBArgs . x = x ;
s_accessEFBArgs . y = y ;
2010-06-15 21:19:09 +00:00
s_accessEFBArgs . Data = InputData ;
2009-10-07 19:54:56 +00:00
2010-03-14 18:57:50 +00:00
Common : : AtomicStoreRelease ( s_efbAccessRequested , TRUE ) ;
2009-07-02 17:45:09 +00:00
2010-03-14 18:57:50 +00:00
if ( g_VideoInitialize . bOnThread )
{
while ( Common : : AtomicLoadAcquire ( s_efbAccessRequested ) & & ! s_FifoShuttingDown )
2010-03-25 22:01:33 +00:00
//Common::SleepCurrentThread(1);
Common : : YieldCPU ( ) ;
2010-03-14 18:57:50 +00:00
}
else
VideoFifo_CheckEFBAccess ( ) ;
2009-07-02 17:45:09 +00:00
2010-03-14 18:57:50 +00:00
return s_AccessEFBResult ;
2009-09-04 17:29:16 +00:00
}
2009-08-31 16:10:36 +00:00
2010-03-14 18:57:50 +00:00
return 0 ;
2009-07-02 17:45:09 +00:00
}
2009-10-10 21:19:39 +00:00
void Video_CommandProcessorRead16 ( u16 & _rReturnValue , const u32 _Address )
{
2010-05-23 02:29:23 +00:00
CommandProcessor : : Read16 ( _rReturnValue , _Address ) ;
2009-10-10 21:19:39 +00:00
}
void Video_CommandProcessorWrite16 ( const u16 _Data , const u32 _Address )
{
2010-05-23 02:29:23 +00:00
CommandProcessor : : Write16 ( _Data , _Address ) ;
2009-10-10 21:19:39 +00:00
}
void Video_PixelEngineRead16 ( u16 & _rReturnValue , const u32 _Address )
{
2010-05-23 02:29:23 +00:00
PixelEngine : : Read16 ( _rReturnValue , _Address ) ;
2009-10-10 21:19:39 +00:00
}
void Video_PixelEngineWrite16 ( const u16 _Data , const u32 _Address )
{
2010-05-23 02:29:23 +00:00
PixelEngine : : Write16 ( _Data , _Address ) ;
2009-10-10 21:19:39 +00:00
}
void Video_PixelEngineWrite32 ( const u32 _Data , const u32 _Address )
{
2010-05-23 02:29:23 +00:00
PixelEngine : : Write32 ( _Data , _Address ) ;
2009-10-10 21:19:39 +00:00
}
inline void Video_GatherPipeBursted ( void )
{
2010-05-23 02:29:23 +00:00
CommandProcessor : : GatherPipeBursted ( ) ;
2009-10-10 21:19:39 +00:00
}
void Video_WaitForFrameFinish ( void )
{
2010-05-23 02:29:23 +00:00
CommandProcessor : : WaitForFrameFinish ( ) ;
2009-10-10 21:19:39 +00:00
}
2010-06-24 13:28:54 +00:00
bool Video_IsFifoBusy ( void )
{
return CommandProcessor : : isFifoBusy ;
}