[Glide64] Clean up some code related to screen capture

This commit is contained in:
zilmar 2016-01-25 22:00:45 +11:00
parent 76a3db6568
commit 5c9962684f
2 changed files with 32 additions and 55 deletions

View File

@ -42,9 +42,9 @@
#include "Version.h" #include "Version.h"
#include <Settings/Settings.h> #include <Settings/Settings.h>
#include <Common/CriticalSection.h> #include <Common/CriticalSection.h>
#include <Common/path.h>
#include <wx/fileconf.h> #include "Config.h"
#include <wx/wfstream.h>
#include "Util.h" #include "Util.h"
#include "3dmath.h" #include "3dmath.h"
#include "Debugger.h" #include "Debugger.h"
@ -89,7 +89,7 @@ int exception = FALSE;
int evoodoo = 0; int evoodoo = 0;
int ev_fullscreen = 0; int ev_fullscreen = 0;
#ifdef __WINDOWS__ #ifdef _WIN32
#define WINPROC_OVERRIDE #define WINPROC_OVERRIDE
HINSTANCE hinstDLL = NULL; HINSTANCE hinstDLL = NULL;
#endif #endif
@ -181,27 +181,7 @@ uint32_t offset_textures = 0;
uint32_t offset_texbuf1 = 0; uint32_t offset_texbuf1 = 0;
int capture_screen = 0; int capture_screen = 0;
wxString capture_path; std::string capture_path;
wxString pluginPath;
wxMutex *mutexProcessDList = NULL;
static void PluginPath()
{
wxDynamicLibraryDetailsArray dlls = wxDynamicLibrary::ListLoaded();
const size_t count = dlls.GetCount();
for (size_t n = 0; n < count; ++n)
{
const wxDynamicLibraryDetails& details = dlls[n];
if (details.GetName().Find("Glide64") != wxNOT_FOUND)
{
wxFileName libname(details.GetPath());
pluginPath = libname.GetPath();
return;
}
}
pluginPath = wxGetCwd() + _T("/Plugin"); //if ListLoaded is not supported by OS use default path
}
void _ChangeSize() void _ChangeSize()
{ {
@ -324,7 +304,9 @@ void ConfigWrapper()
void UseUnregisteredSetting(int /*SettingID*/) void UseUnregisteredSetting(int /*SettingID*/)
{ {
#ifdef _WIN32
DebugBreak(); DebugBreak();
#endif
} }
void ReadSettings() void ReadSettings()
@ -922,7 +904,9 @@ int InitGfx()
if (!gfx_context) if (!gfx_context)
{ {
wxMessageBox(_T("Error setting display mode"), _T("Error"), wxOK | wxICON_EXCLAMATION); #ifdef _WIN32
MessageBox(gfx.hWnd, "Error setting display mode", "Error", MB_OK | MB_ICONEXCLAMATION);
#endif
// grSstWinClose (gfx_context); // grSstWinClose (gfx_context);
grGlideShutdown(); grGlideShutdown();
return FALSE; return FALSE;
@ -1151,7 +1135,6 @@ bool wxDLLApp::OnInit()
{ {
wxImage::AddHandler(new wxPNGHandler); wxImage::AddHandler(new wxPNGHandler);
wxImage::AddHandler(new wxJPEGHandler); wxImage::AddHandler(new wxJPEGHandler);
PluginPath();
return true; return true;
} }
@ -1189,9 +1172,7 @@ int DllUnload(void)
void wxSetInstance(HINSTANCE hInstance); void wxSetInstance(HINSTANCE hInstance);
CriticalSection * g_ProcessDListCS = NULL; CriticalSection * g_ProcessDListCS = NULL;
extern "C" int WINAPI DllMain(HINSTANCE hinst, extern "C" int WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID /*lpReserved*/)
DWORD fdwReason,
LPVOID /*lpReserved*/)
{ {
sprintf(out_buf, "DllMain (%0p - %d)\n", hinst, fdwReason); sprintf(out_buf, "DllMain (%0p - %d)\n", hinst, fdwReason);
LOG(out_buf); LOG(out_buf);
@ -1294,7 +1275,7 @@ output: none
EXPORT void CALL CaptureScreen(char * Directory) EXPORT void CALL CaptureScreen(char * Directory)
{ {
capture_screen = 1; capture_screen = 1;
capture_path = wxString::FromAscii(Directory); capture_path = Directory;
} }
/****************************************************************** /******************************************************************
@ -1852,7 +1833,7 @@ void CALL UpdateScreen(void)
} }
#endif #endif
char out_buf[128]; char out_buf[128];
sprintf(out_buf, "UpdateScreen (). Origin: %08lx, Old origin: %08lx, width: %d\n", *gfx.VI_ORIGIN_REG, rdp.vi_org_reg, *gfx.VI_WIDTH_REG); sprintf(out_buf, "UpdateScreen (). Origin: %08x, Old origin: %08x, width: %d\n", *gfx.VI_ORIGIN_REG, rdp.vi_org_reg, *gfx.VI_WIDTH_REG);
LOG(out_buf); LOG(out_buf);
LRDP(out_buf); LRDP(out_buf);
@ -2070,26 +2051,27 @@ void newSwapBuffers()
if (capture_screen) if (capture_screen)
{ {
//char path[256]; CPath path(capture_path);
// Make the directory if it doesn't exist if (!path.DirectoryExists())
if (!wxDirExists(capture_path)) {
wxMkdir(capture_path); path.DirectoryCreate();
wxString path; }
wxString romName = rdp.RomName; stdstr romName = rdp.RomName;
romName.Replace(" ", "_", true); romName.Replace(" ", "_");
romName.Replace(":", ";", true); romName.Replace(":", ";");
if (settings.ssformat > NumOfFormats)
{
settings.ssformat = 0;
}
for (int i = 1;; i++) for (int i = 1;; i++)
{ {
path = capture_path; stdstr_f filename("Glide64_%s_%s%d.%s", romName.c_str(), i < 10 ? "0" : "", i, ScreenShotFormats[settings.ssformat].extension);
path += "Glide64_"; path.SetNameExtension(filename.c_str());
path += romName; if (!path.Exists())
path += "_"; {
if (i < 10)
path += "0";
path << i << "." << ScreenShotFormats[settings.ssformat].extension;
if (!wxFileName::FileExists(path))
break; break;
}
} }
const uint32_t offset_x = (uint32_t)rdp.offset_x; const uint32_t offset_x = (uint32_t)rdp.offset_x;
@ -2099,12 +2081,7 @@ void newSwapBuffers()
GrLfbInfo_t info; GrLfbInfo_t info;
info.size = sizeof(GrLfbInfo_t); info.size = sizeof(GrLfbInfo_t);
if (grLfbLock(GR_LFB_READ_ONLY, if (grLfbLock(GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_565, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info))
GR_BUFFER_BACKBUFFER,
GR_LFBWRITEMODE_565,
GR_ORIGIN_UPPER_LEFT,
FXFALSE,
&info))
{ {
uint8_t *ssimg = (uint8_t*)malloc(image_width * image_height * 3); // will be free in wxImage destructor uint8_t *ssimg = (uint8_t*)malloc(image_width * image_height * 3); // will be free in wxImage destructor
int sspos = 0; int sspos = 0;
@ -2148,7 +2125,8 @@ void newSwapBuffers()
// Unlock the backbuffer // Unlock the backbuffer
grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER); grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER);
wxImage screenshot(image_width, image_height, ssimg); wxImage screenshot(image_width, image_height, ssimg);
screenshot.SaveFile(path, ScreenShotFormats[settings.ssformat].type); wxString wxPath((const char *)path);
screenshot.SaveFile(wxPath, ScreenShotFormats[settings.ssformat].type);
capture_screen = 0; capture_screen = 0;
} }
} }

View File

@ -801,7 +801,6 @@ extern uint32_t offset_texbuf1;
extern int ucode_error_report; extern int ucode_error_report;
extern wxString pluginPath;
extern wxString iniPath; extern wxString iniPath;
// RDP functions // RDP functions