diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 91b61ea46f..ec530d95d6 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -3082,8 +3082,6 @@ static int ingame_menu_resize(uint8_t menu_type, uint64_t input) static int ingame_menu_screenshot(uint8_t menu_type, uint64_t input) { - DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; - g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_DRAW); if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_INGAME)) @@ -3094,9 +3092,21 @@ static int ingame_menu_screenshot(uint8_t menu_type, uint64_t input) g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_DRAW); } +#ifdef HAVE_SCREENSHOTS if (input & (1ULL << RMENU_DEVICE_NAV_B)) - if (device_ptr->ctx_driver->rmenu_screenshot_dump) - device_ptr->ctx_driver->rmenu_screenshot_dump(NULL); + { + const uint16_t *data = (const uint16_t*)g_extern.frame_cache.data; + unsigned width = g_extern.frame_cache.width; + unsigned height = g_extern.frame_cache.height; + int pitch = g_extern.frame_cache.pitch; + + // Negative pitch is needed as screenshot takes bottom-up, + // but we use top-down. + screenshot_dump(g_settings.screenshot_directory, + data + (height - 1) * (pitch >> 1), + width, height, -pitch, false); + } +#endif } return 0; diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 56f750514e..6e61df5367 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -100,11 +100,6 @@ static void rmenu_ctx_ps3_screenshot_enable(bool enable) #endif } -static void rmenu_ctx_ps3_screenshot_dump(void *data) -{ - (void)data; -} - static void gfx_ctx_get_available_resolutions (void) { bool defaultresolution; @@ -343,7 +338,6 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { "ps3", #ifdef HAVE_RMENU rmenu_ctx_ps3_screenshot_enable, - rmenu_ctx_ps3_screenshot_dump, #endif }; diff --git a/gfx/context/xdk_ctx.c b/gfx/context/xdk_ctx.c index b986d553a5..4ad92fb856 100644 --- a/gfx/context/xdk_ctx.c +++ b/gfx/context/xdk_ctx.c @@ -30,10 +30,6 @@ #include "config.h" #endif -#include - -#include "../../screenshot.h" - #include "../fonts/d3d_font.h" #if defined(_XBOX1) @@ -88,33 +84,6 @@ static void gfx_ctx_xdk_menu_screenshot_enable(bool enable) { } -static void gfx_ctx_xdk_menu_screenshot_dump(void *data) -{ - xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; - HRESULT ret = S_OK; - char filename[PATH_MAX]; - char shotname[PATH_MAX]; - - fill_dated_filename(shotname, "bmp", sizeof(shotname)); - snprintf(filename, sizeof(filename), "%s\\%s", default_paths.screenshots_dir, shotname); - -#if defined(_XBOX1) - D3DSurface *surf = NULL; - d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &surf); - ret = XGWriteSurfaceToFile(surf, filename); - surf->Release(); -#elif defined(_XBOX360) - ret = 1; //false - //ret = D3DXSaveTextureToFile(filename, D3DXIFF_BMP, d3d->lpTexture, NULL); -#endif - - if(ret == S_OK) - { - RARCH_LOG("Screenshot saved: %s.\n", filename); - msg_queue_push(g_extern.msg_queue, "Screenshot saved.", 1, 30); - } -} - static void gfx_ctx_xdk_update_window_title(bool reset) { } static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height) @@ -260,8 +229,6 @@ static void gfx_ctx_xdk_destroy(void) static void gfx_ctx_xdk_input_driver(const input_driver_t **input, void **input_data) { } - - static bool gfx_ctx_xdk_bind_api(enum gfx_ctx_api api) { #if defined(_XBOX1) @@ -302,6 +269,5 @@ const gfx_ctx_driver_t gfx_ctx_xdk = { "xdk", #if defined(HAVE_RMENU) gfx_ctx_xdk_menu_screenshot_enable, - gfx_ctx_xdk_menu_screenshot_dump, #endif }; diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index 359ce7955c..db3a73105c 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -109,7 +109,6 @@ typedef struct gfx_ctx_driver #if defined(HAVE_RMENU) void (*rmenu_screenshot_enable)(bool enable); - void (*rmenu_screenshot_dump)(void *data); #endif } gfx_ctx_driver_t; diff --git a/griffin/griffin.c b/griffin/griffin.c index f8f4b7f89f..2579175ec5 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -435,7 +435,9 @@ NETPLAY /*============================================================ SCREENSHOTS ============================================================ */ -#ifdef HAVE_SCREENSHOTS +#if defined(_XBOX1) +#include "../xdk/screenshot_xdk1.c" +#elif defined(HAVE_SCREENSHOTS) #include "../screenshot.c" #endif diff --git a/xdk/screenshot_xdk1.c b/xdk/screenshot_xdk1.c new file mode 100644 index 0000000000..9a742e9386 --- /dev/null +++ b/xdk/screenshot_xdk1.c @@ -0,0 +1,49 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include +#include "../screenshot.h" + +bool screenshot_dump(const char *folder, const void *frame, + unsigned width, unsigned height, int pitch, bool bgr24) +{ + (void)folder; + (void)frame; + (void)width; + (void)height; + (void)pitch; + (void)bgr24; + + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + HRESULT ret = S_OK; + char filename[PATH_MAX]; + char shotname[PATH_MAX]; + + fill_dated_filename(shotname, "bmp", sizeof(shotname)); + snprintf(filename, sizeof(filename), "%s\\%s", default_paths.screenshots_dir, shotname); + + D3DSurface *surf = NULL; + d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &surf); + ret = XGWriteSurfaceToFile(surf, filename); + surf->Release(); + + if(ret == S_OK) + { + RARCH_LOG("Screenshot saved: %s.\n", filename); + msg_queue_push(g_extern.msg_queue, "Screenshot saved.", 1, 30); + } +}