diff --git a/CHANGES b/CHANGES index 026aaeae4..686e9fc8d 100644 --- a/CHANGES +++ b/CHANGES @@ -68,6 +68,7 @@ Misc: - Util: Add rtrim - GBA Memory: Optimize Load-/StoreMultiple - 3DS: Adjustable filering + - PSP2: Screenshots are now saved into the Photo Gallery 0.4.1: (2016-07-11) Bugfixes: diff --git a/src/core/core.c b/src/core/core.c index c11051c6d..dcb892251 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -21,6 +21,10 @@ #include "gba/gba.h" #endif +#ifdef PSP2 +#include +#endif + static struct mCoreFilter { bool (*filter)(struct VFile*); struct mCore* (*open)(void); @@ -154,7 +158,12 @@ void mCoreTakeScreenshot(struct mCore* core) { color_t* pixels = 0; unsigned width, height; core->desiredVideoDimensions(core, &width, &height); - struct VFile* vf = VDirFindNextAvailable(core->dirs.screenshot, core->dirs.baseName, "-", ".png", O_CREAT | O_TRUNC | O_WRONLY); + struct VFile* vf; +#ifndef PSP2 + vf = VDirFindNextAvailable(core->dirs.screenshot, core->dirs.baseName, "-", ".png", O_CREAT | O_TRUNC | O_WRONLY); +#else + vf = VFileMemChunk(0, 0); +#endif bool success = false; if (vf) { core->getVideoBuffer(core, &pixels, &stride); @@ -162,6 +171,17 @@ void mCoreTakeScreenshot(struct mCore* core) { png_infop info = PNGWriteHeader(png, width, height); success = PNGWritePixels(png, width, height, stride, pixels); PNGWriteClose(png, info); +#ifdef PSP2 + void* data = vf->map(vf, 0, 0); + PhotoExportParam param = { + 0, + NULL, + NULL, + NULL, + { 0 } + }; + scePhotoExportFromData(data, vf->size(vf), ¶m, NULL, NULL, NULL, NULL, 0); +#endif vf->close(vf); } if (success) { diff --git a/src/platform/psp2/CMakeLists.txt b/src/platform/psp2/CMakeLists.txt index fe51b3f7e..5ea4e23de 100644 --- a/src/platform/psp2/CMakeLists.txt +++ b/src/platform/psp2/CMakeLists.txt @@ -15,7 +15,7 @@ source_group("PS Vita-specific code" FILES ${OS_SRC}) list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sce-vfs.c) set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE) -set(OS_LIB -lvita2d -lSceCtrl_stub -lScePgf_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceCommonDialog_stub -lSceMotion_stub -lScePower_stub -lSceSysmodule_stub -lSceTouch_stub -l${M_LIBRARY}) +set(OS_LIB -lvita2d -lSceAppMgr_stub -lSceCtrl_stub -lScePgf_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceCommonDialog_stub -lSceMotion_stub -lScePhotoExport_stub -lScePower_stub -lSceSysmodule_stub -lSceTouch_stub -l${M_LIBRARY}) set(OBJCOPY_CMD ${OBJCOPY} -I binary -O elf32-littlearm -B arm) list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c) diff --git a/src/platform/psp2/main.c b/src/platform/psp2/main.c index d642dfe74..e59401ebf 100644 --- a/src/platform/psp2/main.c +++ b/src/platform/psp2/main.c @@ -153,6 +153,7 @@ int main() { sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); + sceSysmoduleLoadModule(SCE_SYSMODULE_PHOTO_EXPORT); mGUIInit(&runner, "psvita");