diff --git a/plugins/GSdx/GPU.cpp b/plugins/GSdx/GPU.cpp index 4583b48b90..a1abe6c9ec 100644 --- a/plugins/GSdx/GPU.cpp +++ b/plugins/GSdx/GPU.cpp @@ -20,6 +20,7 @@ */ #include "stdafx.h" +#include "GSdx.h" #include "GSUtil.h" #include "GPURendererSW.h" #include "GSDevice7.h" @@ -52,30 +53,22 @@ EXPORT_C_(uint32) PSEgetLibVersion() EXPORT_C_(int32) GPUinit() { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // TODO - return 0; } EXPORT_C_(int32) GPUshutdown() { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // TODO - return 0; } EXPORT_C_(int32) GPUclose() { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - delete s_gpu; s_gpu = NULL; +#ifdef _WINDOWS + if(SUCCEEDED(s_hr)) { ::CoUninitialize(); @@ -83,32 +76,47 @@ EXPORT_C_(int32) GPUclose() s_hr = E_FAIL; } +#endif + return 0; } EXPORT_C_(int32) GPUopen(HWND hWnd) { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - if(!GSUtil::CheckDirectX() || !GSUtil::CheckSSE()) - { - return -1; - } - GPUclose(); GPURendererSettings rs; - rs.m_filter = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("filter"), 0); - rs.m_dither = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("dithering"), 1); - rs.m_aspectratio = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("AspectRatio"), 1); - rs.m_vsync = !!AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("vsync"), FALSE); - rs.m_scale.x = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_x"), 0); - rs.m_scale.y = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_y"), 0); + int threads = 1; + int renderer = 1; - int threads = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("swthreads"), 1); +#ifdef _WINDOWS - int renderer = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("Renderer"), 1); + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + + if(!GSUtil::CheckDirectX()) + { + return -1; + } + +#endif + + if(!GSUtil::CheckSSE()) + { + return -1; + } + + rs.m_filter = theApp.GetConfig("filter", 0); + rs.m_dither = theApp.GetConfig("dithering", 1); + rs.m_aspectratio = theApp.GetConfig("AspectRatio", 1); + rs.m_vsync = !!theApp.GetConfig("vsync", 0); + rs.m_scale.x = theApp.GetConfig("scale_x", 0); + rs.m_scale.y = theApp.GetConfig("scale_y", 0); + + threads = theApp.GetConfig("swthreads", 1); + renderer = theApp.GetConfig("Renderer", 1); switch(renderer) { @@ -119,8 +127,6 @@ EXPORT_C_(int32) GPUopen(HWND hWnd) // TODO: case 3: s_gpu = new GPURendererNull(rs, threads); break; } - s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); - if(!s_gpu->Create(hWnd)) { GPUclose(); @@ -133,6 +139,9 @@ EXPORT_C_(int32) GPUopen(HWND hWnd) EXPORT_C_(int32) GPUconfigure() { + +#ifdef _WINDOWS + AFX_MANAGE_STATE(AfxGetStaticModuleState()); GPUSettingsDlg dlg; @@ -143,13 +152,13 @@ EXPORT_C_(int32) GPUconfigure() GPUinit(); } +#endif + return 0; } EXPORT_C_(int32) GPUtest() { - // TODO - return 0; } diff --git a/plugins/GSdx/GPURenderer.h b/plugins/GSdx/GPURenderer.h index d6a091fec1..71125b9227 100644 --- a/plugins/GSdx/GPURenderer.h +++ b/plugins/GSdx/GPURenderer.h @@ -381,6 +381,15 @@ public: virtual bool MakeSnapshot(const string& path) { - return m_dev.SaveCurrent(format("%s_%s", path.c_str(), CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S"))) + ".bmp"); + time_t t = time(NULL); + + char buff[16]; + + if(!strftime(buff, sizeof(buff), "%Y%m%d%H%M%S", localtime(&t))) + { + return false; + } + + return m_dev.SaveCurrent(format("%s_%s.bmp", path.c_str(), buff)); } }; diff --git a/plugins/GSdx/GPUSettingsDlg.cpp b/plugins/GSdx/GPUSettingsDlg.cpp index b1bbc9aa17..96b9e5c28b 100644 --- a/plugins/GSdx/GPUSettingsDlg.cpp +++ b/plugins/GSdx/GPUSettingsDlg.cpp @@ -130,8 +130,6 @@ BOOL GPUSettingsDlg::OnInitDialog() { __super::OnInitDialog(); - CWinApp* pApp = AfxGetApp(); - D3DCAPS9 caps; memset(&caps, 0, sizeof(caps)); caps.PixelShaderVersion = D3DPS_VERSION(0, 0); @@ -154,9 +152,9 @@ BOOL GPUSettingsDlg::OnInitDialog() if(CComPtr d3d = Direct3DCreate9(D3D_SDK_VERSION)) { - uint32 ModeWidth = pApp->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0); - uint32 ModeHeight = pApp->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0); - uint32 ModeRefreshRate = pApp->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0); + uint32 ModeWidth = theApp.GetConfig("ModeWidth", 0); + uint32 ModeHeight = theApp.GetConfig("ModeHeight", 0); + uint32 ModeRefreshRate = theApp.GetConfig("ModeRefreshRate", 0); uint32 nModes = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8); @@ -194,12 +192,12 @@ BOOL GPUSettingsDlg::OnInitDialog() renderers.push_back(g_renderers[i]); } - GSSetting::InitComboBox(&renderers[0], renderers.size(), m_renderer, pApp->GetProfileInt(_T("GPUSettings"), _T("Renderer"), 1)); - GSSetting::InitComboBox(g_psversion, countof(g_psversion), m_psversion, pApp->GetProfileInt(_T("Settings"), _T("PixelShaderVersion2"), D3DPS_VERSION(2, 0)), caps.PixelShaderVersion); - GSSetting::InitComboBox(g_filter, countof(g_filter), m_filter, pApp->GetProfileInt(_T("GPUSettings"), _T("filter"), 0)); - GSSetting::InitComboBox(g_dithering, countof(g_dithering), m_dithering, pApp->GetProfileInt(_T("GPUSettings"), _T("dithering"), 1)); - GSSetting::InitComboBox(g_aspectratio, countof(g_aspectratio), m_aspectratio, pApp->GetProfileInt(_T("GPUSettings"), _T("AspectRatio"), 1)); - GSSetting::InitComboBox(g_internalresolution, countof(g_internalresolution), m_internalresolution, pApp->GetProfileInt(_T("GPUSettings"), _T("scale_x"), 0) | (pApp->GetProfileInt(_T("GPUSettings"), _T("scale_y"), 0) << 2)); + GSSetting::InitComboBox(&renderers[0], renderers.size(), m_renderer, theApp.GetConfig("Renderer", 1)); + GSSetting::InitComboBox(g_psversion, countof(g_psversion), m_psversion, theApp.GetConfig("PixelShaderVersion2", D3DPS_VERSION(2, 0)), caps.PixelShaderVersion); + GSSetting::InitComboBox(g_filter, countof(g_filter), m_filter, theApp.GetConfig("filter", 0)); + GSSetting::InitComboBox(g_dithering, countof(g_dithering), m_dithering, theApp.GetConfig("dithering", 1)); + GSSetting::InitComboBox(g_aspectratio, countof(g_aspectratio), m_aspectratio, theApp.GetConfig("AspectRatio", 1)); + GSSetting::InitComboBox(g_internalresolution, countof(g_internalresolution), m_internalresolution, theApp.GetConfig("scale_x", 0) | (theApp.GetConfig("scale_y", 0) << 2)); OnCbnSelchangeCombo1(); @@ -207,7 +205,7 @@ BOOL GPUSettingsDlg::OnInitDialog() // m_swthreads.SetRange(1, 16); - m_swthreads.SetPos(pApp->GetProfileInt(_T("GPUSettings"), _T("swthreads"), 1)); + m_swthreads.SetPos(theApp.GetConfig("swthreads", 1)); // @@ -219,53 +217,51 @@ BOOL GPUSettingsDlg::OnInitDialog() void GPUSettingsDlg::OnOK() { - CWinApp* pApp = AfxGetApp(); - UpdateData(); if(m_resolution.GetCurSel() >= 0) { D3DDISPLAYMODE& mode = *(D3DDISPLAYMODE*)m_resolution.GetItemData(m_resolution.GetCurSel()); - pApp->WriteProfileInt(_T("Settings"), _T("ModeWidth"), mode.Width); - pApp->WriteProfileInt(_T("Settings"), _T("ModeHeight"), mode.Height); - pApp->WriteProfileInt(_T("Settings"), _T("ModeRefreshRate"), mode.RefreshRate); + theApp.SetConfig("ModeWidth", (int)mode.Width); + theApp.SetConfig("ModeHeight", (int)mode.Height); + theApp.SetConfig("ModeRefreshRate", (int)mode.RefreshRate); } if(m_renderer.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("GPUSettings"), _T("Renderer"), (DWORD)m_renderer.GetItemData(m_renderer.GetCurSel())); + theApp.SetConfig("Renderer", (int)m_renderer.GetItemData(m_renderer.GetCurSel())); } if(m_psversion.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("Settings"), _T("PixelShaderVersion2"), (DWORD)m_psversion.GetItemData(m_psversion.GetCurSel())); + theApp.SetConfig("PixelShaderVersion2", (int)m_psversion.GetItemData(m_psversion.GetCurSel())); } if(m_filter.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("GPUSettings"), _T("filter"), (DWORD)m_filter.GetItemData(m_filter.GetCurSel())); + theApp.SetConfig("filter", (int)m_filter.GetItemData(m_filter.GetCurSel())); } if(m_dithering.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("GPUSettings"), _T("dithering"), (DWORD)m_dithering.GetItemData(m_dithering.GetCurSel())); + theApp.SetConfig("dithering", (int)m_dithering.GetItemData(m_dithering.GetCurSel())); } if(m_aspectratio.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("GPUSettings"), _T("AspectRatio"), (DWORD)m_aspectratio.GetItemData(m_aspectratio.GetCurSel())); + theApp.SetConfig("AspectRatio", (int)m_aspectratio.GetItemData(m_aspectratio.GetCurSel())); } if(m_internalresolution.GetCurSel() >= 0) { - DWORD value = (DWORD)m_internalresolution.GetItemData(m_internalresolution.GetCurSel()); + int value = (int)m_internalresolution.GetItemData(m_internalresolution.GetCurSel()); - pApp->WriteProfileInt(_T("GPUSettings"), _T("scale_x"), value & 3); - pApp->WriteProfileInt(_T("GPUSettings"), _T("scale_y"), (value >> 2) & 3); + theApp.SetConfig("scale_x", value & 3); + theApp.SetConfig("scale_y", (value >> 2) & 3); } - pApp->WriteProfileInt(_T("GPUSettings"), _T("swthreads"), m_swthreads.GetPos()); + theApp.SetConfig("swthreads", m_swthreads.GetPos()); __super::OnOK(); } diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index a06decfe00..ff0133ac0e 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -71,14 +71,11 @@ EXPORT_C GSsetBaseMem(uint8* mem) EXPORT_C_(INT32) GSinit() { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - return 0; } EXPORT_C GSshutdown() { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); } EXPORT_C GSclose() @@ -87,36 +84,51 @@ EXPORT_C GSclose() s_gs = NULL; +#ifdef _WINDOWS + if(SUCCEEDED(s_hr)) { ::CoUninitialize(); s_hr = E_FAIL; } + +#endif } static INT32 GSopen(void* dsp, char* title, int mt, int renderer) { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - if(!GSUtil::CheckDirectX() || !GSUtil::CheckSSE()) - { - return -1; - } - GSclose(); GSRendererSettings rs; - rs.m_interlace = AfxGetApp()->GetProfileInt(_T("Settings"), _T("interlace"), 0); - rs.m_aspectratio = AfxGetApp()->GetProfileInt(_T("Settings"), _T("aspectratio"), 1); - rs.m_filter = AfxGetApp()->GetProfileInt(_T("Settings"), _T("filter"), 1); - rs.m_vsync = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("vsync"), FALSE); - rs.m_nativeres = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("nativeres"), FALSE); - rs.m_aa1 = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("aa1"), FALSE); - rs.m_blur = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("blur"), FALSE); + int threads = 1; - int threads = AfxGetApp()->GetProfileInt(_T("Settings"), _T("swthreads"), 1); +#ifdef _WINDOWS + + s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + + if(!GSUtil::CheckDirectX()) + { + return -1; + } + +#endif + + if(!GSUtil::CheckSSE()) + { + return -1; + } + + rs.m_interlace = theApp.GetConfig("interlace", 0); + rs.m_aspectratio = theApp.GetConfig("aspectratio", 1); + rs.m_filter = theApp.GetConfig("filter", 1); + rs.m_vsync = !!theApp.GetConfig("vsync", 0); + rs.m_nativeres = !!theApp.GetConfig("nativeres", 0); + rs.m_aa1 = !!theApp.GetConfig("aa1", 0); + rs.m_blur = !!theApp.GetConfig("blur", 0); + + threads = theApp.GetConfig("swthreads", 1); switch(renderer) { @@ -131,8 +143,6 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer) case 7: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, rs); break; } - s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); - if(!s_gs->Create(title)) { GSclose(); @@ -151,8 +161,12 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer) EXPORT_C_(INT32) GSopen(void* dsp, char* title, int mt) { +#ifdef _WINDOWS + AFX_MANAGE_STATE(AfxGetStaticModuleState()); +#endif + int renderer; if(mt == 2) @@ -164,7 +178,7 @@ EXPORT_C_(INT32) GSopen(void* dsp, char* title, int mt) else { // normal init - renderer = AfxGetApp()->GetProfileInt(_T("Settings"), _T("renderer"), 0); + renderer = theApp.GetConfig("renderer", 0); } return GSopen(dsp, title, mt, renderer); @@ -212,6 +226,20 @@ EXPORT_C GSgifTransfer3(uint8* mem, uint32 size) EXPORT_C GSvsync(int field) { +#ifdef _WINDOWS + + MSG msg; + + memset(&msg, 0, sizeof(msg)); + + while(msg.message != WM_QUIT && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + +#endif + s_gs->VSync(field); } @@ -220,8 +248,9 @@ EXPORT_C_(uint32) GSmakeSnapshot(char* path) return s_gs->MakeSnapshot(string(path) + "gsdx"); } -EXPORT_C GSkeyEvent(keyEvent* ev) +EXPORT_C GSkeyEvent(GSKeyEventData* e) { + s_gs->KeyEvent(e); } EXPORT_C_(int) GSfreeze(int mode, GSFreezeData* data) @@ -244,6 +273,8 @@ EXPORT_C_(int) GSfreeze(int mode, GSFreezeData* data) EXPORT_C GSconfigure() { +#ifdef _WINDOWS + AFX_MANAGE_STATE(AfxGetStaticModuleState()); GSSettingsDlg dlg; @@ -253,21 +284,14 @@ EXPORT_C GSconfigure() GSshutdown(); GSinit(); } + +#endif + } EXPORT_C_(INT32) GStest() { return 0; - - // TODO - - /* - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - CComPtr dev; - - return SUCCEEDED(D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &dev)) ? 0 : -1; - */ } EXPORT_C GSabout() @@ -294,6 +318,8 @@ EXPORT_C GSsetFrameSkip(int frameskip) s_gs->SetFrameSkip(frameskip); } +#ifdef _WINDOWS + EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { int renderer = -1; @@ -597,3 +623,4 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow fclose(file); } +#endif \ No newline at end of file diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 90ddc3f126..39a799a0f1 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -1163,7 +1163,7 @@ struct GSPrivRegSet #pragma pack(pop) enum {KEYPRESS=1, KEYRELEASE=2}; -struct keyEvent {uint32 key, event;}; +struct GSKeyEventData {uint32 key, type;}; enum {FREEZE_LOAD=0, FREEZE_SAVE=1, FREEZE_SIZE=2}; struct GSFreezeData {int size; uint8* data;}; diff --git a/plugins/GSdx/GSCaptureDlg.cpp b/plugins/GSdx/GSCaptureDlg.cpp index 32432a5df4..9e3ae7c2e3 100644 --- a/plugins/GSdx/GSCaptureDlg.cpp +++ b/plugins/GSdx/GSCaptureDlg.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include +#include "GSdx.h" #include "GSCaptureDlg.h" // GSCaptureDlg dialog @@ -29,9 +30,9 @@ IMPLEMENT_DYNAMIC(GSCaptureDlg, CDialog) GSCaptureDlg::GSCaptureDlg(CWnd* pParent /*=NULL*/) : CDialog(GSCaptureDlg::IDD, pParent) { - m_width = AfxGetApp()->GetProfileInt(_T("Capture"), _T("Width"), 640); - m_height = AfxGetApp()->GetProfileInt(_T("Capture"), _T("Height"), 480); - m_filename = AfxGetApp()->GetProfileString(_T("Capture"), _T("FileName")); + m_width = theApp.GetConfig("CaptureWidth", 640); + m_height = theApp.GetConfig("CaptureHeight", 480); + m_filename = theApp.GetConfig("CaptureFileName", "").c_str(); } GSCaptureDlg::~GSCaptureDlg() @@ -123,7 +124,7 @@ BOOL GSCaptureDlg::OnInitDialog() // - CString DisplayNameToFind = AfxGetApp()->GetProfileString(_T("Capture"), _T("VideoCodecDisplayName")); + CString DisplayNameToFind = theApp.GetConfig("CaptureVideoCodecDisplayName", "").c_str(); for(int i = 0; i < m_codeclist.GetCount(); i++) { @@ -230,10 +231,10 @@ void GSCaptureDlg::OnBnClickedOk() m_enc = c.filter; - AfxGetApp()->WriteProfileInt(_T("Capture"), _T("Width"), m_width); - AfxGetApp()->WriteProfileInt(_T("Capture"), _T("Height"), m_height); - AfxGetApp()->WriteProfileString(_T("Capture"), _T("FileName"), m_filename); - AfxGetApp()->WriteProfileString(_T("Capture"), _T("VideoCodecDisplayName"), CString(c.DisplayName)); + theApp.SetConfig("CaptureWidth", m_width); + theApp.SetConfig("CaptureHeight", m_height); + theApp.SetConfig("CaptureFileName", m_filename); + theApp.SetConfig("CaptureVideoCodecDisplayName", CString(c.DisplayName)); OnOK(); } diff --git a/plugins/GSdx/GSCrc.cpp b/plugins/GSdx/GSCrc.cpp index a4a3fde2e1..b6b98060dc 100644 --- a/plugins/GSdx/GSCrc.cpp +++ b/plugins/GSdx/GSCrc.cpp @@ -82,6 +82,7 @@ CRC::Game CRC::m_games[] = {0xC19A374E, SoTC, US}, {0x7D8F539A, SoTC, EU}, {0x3122B508, OnePieceGrandAdventure, US}, + {0x8DF14A24, OnePieceGrandAdventure, Unknown}, {0x6F8545DB, ICO, US}, {0xB01A4C95, ICO, JP}, {0x5C991F4E, ICO, Unknown}, diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 4e38b0af0d..461cb30842 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -20,6 +20,7 @@ */ #include "stdafx.h" +#include "GSdx.h" #include "GSDevice9.h" #include "resource.h" @@ -102,7 +103,7 @@ bool GSDevice9::Create(HWND hWnd, bool vsync) m_d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_d3dcaps); - bool fs = AfxGetApp()->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0) > 0; + bool fs = theApp.GetConfig("ModeWidth", 0) > 0; if(!Reset(1, 1, fs)) return false; @@ -110,7 +111,7 @@ bool GSDevice9::Create(HWND hWnd, bool vsync) // shaders - DWORD psver = AfxGetApp()->GetProfileInt(_T("Settings"), _T("PixelShaderVersion2"), D3DPS_VERSION(2, 0)); + uint32 psver = (uint32)theApp.GetConfig("PixelShaderVersion2", D3DPS_VERSION(2, 0)); if(psver > m_d3dcaps.PixelShaderVersion) { @@ -262,9 +263,9 @@ bool GSDevice9::Reset(int w, int h, bool fs) // m_pp.Flags |= D3DPRESENTFLAG_VIDEO; // enables tv-out (but I don't think anyone would still use a regular tv...) - int mw = AfxGetApp()->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0); - int mh = AfxGetApp()->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0); - int mrr = AfxGetApp()->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0); + int mw = theApp.GetConfig("ModeWidth", 0); + int mh = theApp.GetConfig("ModeHeight", 0); + int mrr = theApp.GetConfig("ModeRefreshRate", 0); if(fs && mw > 0 && mh > 0 && mrr >= 0) { diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index bb3fb7c34e..a5fc7f3577 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -21,6 +21,7 @@ #pragma once +#include "GSdx.h" #include "GSWnd.h" #include "GSState.h" #include "GSVertexList.h" @@ -43,56 +44,10 @@ class GSRendererBase : public GSState, protected GSRendererSettings protected: bool m_osd; - void ProcessWindowMessages() - { - MSG msg; - - memset(&msg, 0, sizeof(msg)); - - while(msg.message != WM_QUIT && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - if(OnMessage(msg)) - { - continue; - } - - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - virtual bool OnMessage(const MSG& msg) - { - if(msg.message == WM_KEYDOWN) - { - int step = (::GetAsyncKeyState(VK_SHIFT) & 0x8000) ? -1 : 1; - - switch(msg.wParam) - { - case VK_F5: - m_interlace = (m_interlace + 7 + step) % 7; - return true; - case VK_F6: - m_aspectratio = (m_aspectratio + 3 + step) % 3; - return true; - case VK_F7: - m_wnd.SetWindowText(_T("PCSX2")); - m_osd = !m_osd; - return true; - case VK_DELETE: - m_aa1 = !m_aa1; - return true; - case VK_END: - m_blur = !m_blur; - return true; - } - } - - return false; - } - public: GSWnd m_wnd; + GSCapture m_capture; + string m_snapshot; public: GSRendererBase(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs) @@ -108,9 +63,59 @@ public: m_blur = rs.m_blur; }; + void KeyEvent(GSKeyEventData* e) + { + if(e->type == KEYPRESS) + { + // TODO: linux + + int step = (::GetAsyncKeyState(VK_SHIFT) & 0x8000) ? -1 : 1; + + switch(e->key) + { + case VK_F5: + m_interlace = (m_interlace + 7 + step) % 7; + return; + case VK_F6: + m_aspectratio = (m_aspectratio + 3 + step) % 3; + return; + case VK_F7: + m_wnd.SetWindowText(_T("PCSX2")); + m_osd = !m_osd; + return; + case VK_F12: + if(m_capture.IsCapturing()) m_capture.EndCapture(); + else m_capture.BeginCapture(GetFPS()); + return; + case VK_DELETE: + m_aa1 = !m_aa1; + return; + case VK_END: + m_blur = !m_blur; + return; + } + } + } + + bool MakeSnapshot(const string& path) + { + if(m_snapshot.empty()) + { + time_t t = time(NULL); + + char buff[16]; + + if(strftime(buff, sizeof(buff), "%Y%m%d%H%M%S", localtime(&t))) + { + m_snapshot = format("%s_%s", path.c_str(), buff); + } + } + + return true; + } + virtual bool Create(const string& title) = 0; virtual void VSync(int field) = 0; - virtual bool MakeSnapshot(const string& path) = 0; }; template class GSRenderer : public GSRendererBase @@ -382,21 +387,6 @@ protected: } } - virtual bool OnMessage(const MSG& msg) - { - if(msg.message == WM_KEYDOWN) - { - switch(msg.wParam) - { - case VK_F12: - if(m_capture.IsCapturing()) m_capture.EndCapture(); - else m_capture.BeginCapture(GetFPS()); - return true; - } - } - - return __super::OnMessage(msg); - } public: Device m_dev; @@ -407,18 +397,15 @@ public: bool s_save; bool s_savez; - string m_snapshot; - GSCapture m_capture; - public: GSRenderer(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr) : GSRendererBase(base, mt, irq, rs) , m_psrr(psrr) { s_n = 0; - s_dump = !!AfxGetApp()->GetProfileInt(_T("Debug"), _T("dump"), 0); - s_save = !!AfxGetApp()->GetProfileInt(_T("Debug"), _T("save"), 0); - s_savez = !!AfxGetApp()->GetProfileInt(_T("Debug"), _T("savez"), 0); + s_dump = !!theApp.GetConfig("dump", 0); + s_save = !!theApp.GetConfig("save", 0); + s_savez = !!theApp.GetConfig("savez", 0); } bool Create(const string& title) @@ -446,8 +433,6 @@ public: m_perfmon.Put(GSPerfMon::Frame); - ProcessWindowMessages(); - field = field ? 1 : 0; if(!Merge(field)) return; @@ -530,16 +515,6 @@ public: DoCapture(); } - bool MakeSnapshot(const string& path) - { - if(m_snapshot.empty()) - { - m_snapshot = format("%s_%s", path.c_str(), CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S"))); - } - - return true; - } - virtual void MinMaxUV(int w, int h, GSVector4i& r) {r = GSVector4i(0, 0, w, h);} virtual bool CanUpscale() {return !m_nativeres;} }; diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 79cc37c9ad..34df556fbb 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -677,8 +677,8 @@ public: { if(!m_nativeres) { - m_width = AfxGetApp()->GetProfileInt(_T("Settings"), _T("resx"), m_width); - m_height = AfxGetApp()->GetProfileInt(_T("Settings"), _T("resy"), m_height); + m_width = theApp.GetConfig("resx", m_width); + m_height = theApp.GetConfig("resy", m_height); } m_tc = new TextureCache(this); diff --git a/plugins/GSdx/GSRendererHW9.cpp b/plugins/GSdx/GSRendererHW9.cpp index 036290eea3..a5ee0df4fd 100644 --- a/plugins/GSdx/GSRendererHW9.cpp +++ b/plugins/GSdx/GSRendererHW9.cpp @@ -27,8 +27,8 @@ GSRendererHW9::GSRendererHW9(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs) : GSRendererHW(base, mt, irq, rs, false) { - m_fba.enabled = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("fba"), TRUE); - m_logz = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("logz"), FALSE); + m_fba.enabled = !!theApp.GetConfig("fba", 1); + m_logz = !!theApp.GetConfig("logz", 0); InitVertexKick(); } diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 0f3d5577fb..928fa7ecb2 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -141,8 +141,6 @@ BOOL GSSettingsDlg::OnInitDialog() { __super::OnInitDialog(); - CWinApp* pApp = AfxGetApp(); - D3DCAPS9 caps; memset(&caps, 0, sizeof(caps)); caps.PixelShaderVersion = D3DPS_VERSION(0, 0); @@ -165,9 +163,9 @@ BOOL GSSettingsDlg::OnInitDialog() if(CComPtr d3d = Direct3DCreate9(D3D_SDK_VERSION)) { - uint32 ModeWidth = pApp->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0); - uint32 ModeHeight = pApp->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0); - uint32 ModeRefreshRate = pApp->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0); + uint32 ModeWidth = theApp.GetConfig("ModeWidth", 0); + uint32 ModeHeight = theApp.GetConfig("ModeHeight", 0); + uint32 ModeRefreshRate = theApp.GetConfig("ModeRefreshRate", 0); uint32 nModes = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8); @@ -204,27 +202,27 @@ BOOL GSSettingsDlg::OnInitDialog() renderers.push_back(g_renderers[i]); } - GSSetting::InitComboBox(&renderers[0], renderers.size(), m_renderer, pApp->GetProfileInt(_T("Settings"), _T("Renderer"), 0)); - GSSetting::InitComboBox(g_psversion, countof(g_psversion), m_psversion, pApp->GetProfileInt(_T("Settings"), _T("PixelShaderVersion2"), D3DPS_VERSION(2, 0)), caps.PixelShaderVersion); - GSSetting::InitComboBox(g_interlace, countof(g_interlace), m_interlace, pApp->GetProfileInt(_T("Settings"), _T("Interlace"), 0)); - GSSetting::InitComboBox(g_aspectratio, countof(g_aspectratio), m_aspectratio, pApp->GetProfileInt(_T("Settings"), _T("AspectRatio"), 1)); + GSSetting::InitComboBox(&renderers[0], renderers.size(), m_renderer, theApp.GetConfig("Renderer", 0)); + GSSetting::InitComboBox(g_psversion, countof(g_psversion), m_psversion, theApp.GetConfig("PixelShaderVersion2", D3DPS_VERSION(2, 0)), caps.PixelShaderVersion); + GSSetting::InitComboBox(g_interlace, countof(g_interlace), m_interlace, theApp.GetConfig("Interlace", 0)); + GSSetting::InitComboBox(g_aspectratio, countof(g_aspectratio), m_aspectratio, theApp.GetConfig("AspectRatio", 1)); OnCbnSelchangeCombo1(); // - m_filter = pApp->GetProfileInt(_T("Settings"), _T("filter"), 1); - m_vsync = !!pApp->GetProfileInt(_T("Settings"), _T("vsync"), FALSE); - m_logz = !!pApp->GetProfileInt(_T("Settings"), _T("logz"), FALSE); - m_fba = !!pApp->GetProfileInt(_T("Settings"), _T("fba"), TRUE); - m_aa1 = !!pApp->GetProfileInt(_T("Settings"), _T("aa1"), FALSE); - m_blur = !!pApp->GetProfileInt(_T("Settings"), _T("blur"), FALSE); + m_filter = theApp.GetConfig("filter", 1); + m_vsync = !!theApp.GetConfig("vsync", 0); + m_logz = !!theApp.GetConfig("logz", 0); + m_fba = !!theApp.GetConfig("fba", 1); + m_aa1 = !!theApp.GetConfig("aa1", 0); + m_blur = !!theApp.GetConfig("blur", 0); m_resx.SetRange(512, 4096); m_resy.SetRange(512, 4096); - m_resx.SetPos(pApp->GetProfileInt(_T("Settings"), _T("resx"), 1024)); - m_resy.SetPos(pApp->GetProfileInt(_T("Settings"), _T("resy"), 1024)); - m_nativeres = !!pApp->GetProfileInt(_T("Settings"), _T("nativeres"), FALSE); + m_resx.SetPos(theApp.GetConfig("resx", 1024)); + m_resy.SetPos(theApp.GetConfig("resy", 1024)); + m_nativeres = !!theApp.GetConfig("nativeres", 0); m_resx.EnableWindow(!m_nativeres); m_resy.EnableWindow(!m_nativeres); @@ -232,7 +230,7 @@ BOOL GSSettingsDlg::OnInitDialog() m_resyedit.EnableWindow(!m_nativeres); m_swthreads.SetRange(1, 16); - m_swthreads.SetPos(pApp->GetProfileInt(_T("Settings"), _T("swthreads"), 1)); + m_swthreads.SetPos(theApp.GetConfig("swthreads", 1)); // @@ -244,50 +242,48 @@ BOOL GSSettingsDlg::OnInitDialog() void GSSettingsDlg::OnOK() { - CWinApp* pApp = AfxGetApp(); - UpdateData(); if(m_resolution.GetCurSel() >= 0) { D3DDISPLAYMODE& mode = *(D3DDISPLAYMODE*)m_resolution.GetItemData(m_resolution.GetCurSel()); - pApp->WriteProfileInt(_T("Settings"), _T("ModeWidth"), mode.Width); - pApp->WriteProfileInt(_T("Settings"), _T("ModeHeight"), mode.Height); - pApp->WriteProfileInt(_T("Settings"), _T("ModeRefreshRate"), mode.RefreshRate); + theApp.SetConfig("ModeWidth", (int)mode.Width); + theApp.SetConfig("ModeHeight", (int)mode.Height); + theApp.SetConfig("ModeRefreshRate", (int)mode.RefreshRate); } if(m_renderer.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("Settings"), _T("Renderer"), (uint32)m_renderer.GetItemData(m_renderer.GetCurSel())); + theApp.SetConfig("Renderer", (uint32)m_renderer.GetItemData(m_renderer.GetCurSel())); } if(m_psversion.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("Settings"), _T("PixelShaderVersion2"), (uint32)m_psversion.GetItemData(m_psversion.GetCurSel())); + theApp.SetConfig("PixelShaderVersion2", (uint32)m_psversion.GetItemData(m_psversion.GetCurSel())); } if(m_interlace.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("Settings"), _T("Interlace"), (uint32)m_interlace.GetItemData(m_interlace.GetCurSel())); + theApp.SetConfig("Interlace", (uint32)m_interlace.GetItemData(m_interlace.GetCurSel())); } if(m_aspectratio.GetCurSel() >= 0) { - pApp->WriteProfileInt(_T("Settings"), _T("AspectRatio"), (uint32)m_aspectratio.GetItemData(m_aspectratio.GetCurSel())); + theApp.SetConfig("AspectRatio", (uint32)m_aspectratio.GetItemData(m_aspectratio.GetCurSel())); } - pApp->WriteProfileInt(_T("Settings"), _T("filter"), m_filter); - pApp->WriteProfileInt(_T("Settings"), _T("vsync"), m_vsync); - pApp->WriteProfileInt(_T("Settings"), _T("logz"), m_logz); - pApp->WriteProfileInt(_T("Settings"), _T("fba"), m_fba); - pApp->WriteProfileInt(_T("Settings"), _T("aa1"), m_aa1); - pApp->WriteProfileInt(_T("Settings"), _T("blur"), m_blur); + theApp.SetConfig("filter", m_filter); + theApp.SetConfig("vsync", m_vsync); + theApp.SetConfig("logz", m_logz); + theApp.SetConfig("fba", m_fba); + theApp.SetConfig("aa1", m_aa1); + theApp.SetConfig("blur", m_blur); - pApp->WriteProfileInt(_T("Settings"), _T("resx"), m_resx.GetPos()); - pApp->WriteProfileInt(_T("Settings"), _T("resy"), m_resy.GetPos()); - pApp->WriteProfileInt(_T("Settings"), _T("swthreads"), m_swthreads.GetPos()); - pApp->WriteProfileInt(_T("Settings"), _T("nativeres"), m_nativeres); + theApp.SetConfig("resx", m_resx.GetPos()); + theApp.SetConfig("resy", m_resy.GetPos()); + theApp.SetConfig("swthreads", m_swthreads.GetPos()); + theApp.SetConfig("nativeres", m_nativeres); __super::OnOK(); } diff --git a/plugins/GSdx/GSVector.h b/plugins/GSdx/GSVector.h index d3dd190e0f..80a102c146 100644 --- a/plugins/GSdx/GSVector.h +++ b/plugins/GSdx/GSVector.h @@ -182,6 +182,8 @@ public: GSVector4i fit(int preset) const; + #ifdef _WINDOWS + operator LPCRECT() const { return (LPCRECT)this; @@ -192,6 +194,8 @@ public: return (LPRECT)this; } + #endif + // uint32 rgba32() const diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index c01f3390bb..bcb8ff9caa 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -20,6 +20,7 @@ */ #include "StdAfx.h" +#include "GSdx.h" #include "GSWnd.h" BEGIN_MESSAGE_MAP(GSWnd, CWnd) @@ -51,7 +52,7 @@ bool GSWnd::Create(const string& title) r = CRect(r.CenterPoint() - CSize(s.cx / 2, s.cy / 2), s); - LPCTSTR wc = AfxRegisterWndClass(CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS, AfxGetApp()->LoadStandardCursor(IDC_ARROW), 0, 0); + LPCTSTR wc = AfxRegisterWndClass(CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS, theApp.LoadStandardCursor(IDC_ARROW), 0, 0); return !!CreateEx(0, wc, title.c_str(), WS_OVERLAPPEDWINDOW, r, NULL, 0); } diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 48a30d5e92..339263ba7f 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -51,15 +51,12 @@ // details. // -BEGIN_MESSAGE_MAP(GSdxApp, CWinApp) -END_MESSAGE_MAP() +GSdxApp theApp; GSdxApp::GSdxApp() { } -GSdxApp theApp; - BOOL GSdxApp::InitInstance() { __super::InitInstance(); @@ -96,4 +93,24 @@ BOOL GSdxApp::InitInstance() m_pszProfileName = _tcsdup((LPCTSTR)path); return TRUE; -} \ No newline at end of file +} + +string GSdxApp::GetConfig(const char* entry, const char* value) +{ + return string(GetProfileString("Settings", entry, value)); +} + +void GSdxApp::SetConfig(const char* entry, const char* value) +{ + WriteProfileString("Settings", entry, value); +} + +int GSdxApp::GetConfig(const char* entry, int value) +{ + return GetProfileInt("Settings", entry, value); +} + +void GSdxApp::SetConfig(const char* entry, int value) +{ + WriteProfileInt("Settings", entry, value); +} diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h index 5d3be89e27..e1abf14876 100644 --- a/plugins/GSdx/GSdx.h +++ b/plugins/GSdx/GSdx.h @@ -21,17 +21,18 @@ #pragma once -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - class GSdxApp : public CWinApp { +protected: + virtual BOOL InitInstance(); + public: GSdxApp(); -public: - virtual BOOL InitInstance(); - - DECLARE_MESSAGE_MAP() + string GetConfig(const char* entry, const char* value); + void SetConfig(const char* entry, const char* value); + int GetConfig(const char* entry, int value); + void SetConfig(const char* entry, int value); }; + +extern GSdxApp theApp; \ No newline at end of file diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index adf3463f2d..49d9a216c5 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -6,6 +6,8 @@ #pragma warning(disable: 4996 4995 4324 4100) +#ifdef _WINDOWS + #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif @@ -35,11 +37,13 @@ #ifndef _AFX_NO_AFXCMN_SUPPORT #include // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT -//#include + +#endif // stdc #include +#include #include #include @@ -71,17 +75,17 @@ typedef signed long long int64; #define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall #ifndef RESTRICT - #ifdef __INTEL_COMPILER - #define RESTRICT restrict - #elif _MSC_VER >= 1400 // TODO: gcc - #define RESTRICT __restrict - #else - #define RESTRICT - #endif +#ifdef __INTEL_COMPILER + #define RESTRICT restrict +#elif _MSC_VER >= 1400 // TODO: gcc + #define RESTRICT __restrict +#else + #define RESTRICT +#endif #endif #ifdef __x86_64__ - #define _M_AMD64 +#define _M_AMD64 #endif extern "C" uint64 __rdtsc(); // TODO: gcc