PSP2: Screenshots are now saved into the Photo Gallery
Jeffrey Pfau jeffrey@endrift.com
Sun, 21 Aug 2016 20:08:41 -0700
4 files changed,
24 insertions(+),
2 deletions(-)
M
src/core/core.c
→
src/core/core.c
@@ -21,6 +21,10 @@ #include "gba/core.h"
#include "gba/gba.h" #endif +#ifdef PSP2 +#include <psp2/photoexport.h> +#endif + static struct mCoreFilter { bool (*filter)(struct VFile*); struct mCore* (*open)(void);@@ -154,7 +158,12 @@ size_t stride;
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 @@ png_structp png = PNGWriteOpen(vf);
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) {
M
src/platform/psp2/CMakeLists.txt
→
src/platform/psp2/CMakeLists.txt
@@ -15,7 +15,7 @@
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)
M
src/platform/psp2/main.c
→
src/platform/psp2/main.c
@@ -153,6 +153,7 @@ };
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); + sceSysmoduleLoadModule(SCE_SYSMODULE_PHOTO_EXPORT); mGUIInit(&runner, "psvita");