mirror of
https://github.com/joel16/PSP-Everest.git
synced 2025-02-17 02:19:34 +00:00
app: Add ability to take .BMP screenshots using the square button
This commit is contained in:
parent
3e5760c23b
commit
3f29cea8bf
5
app/include/screenshot.h
Normal file
5
app/include/screenshot.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Screenshot {
|
||||||
|
void Capture(int menu);
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#include <pspsdk.h>
|
#include <cstdio>
|
||||||
#include <stdio.h>
|
#include <pspkernel.h>
|
||||||
|
|
||||||
#include "consoleidinfo.h"
|
#include "consoleidinfo.h"
|
||||||
|
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspsdk.h>
|
|
||||||
#include <psputility_sysparam.h>
|
#include <psputility_sysparam.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vlf.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "vlf.h"
|
||||||
|
|
||||||
extern unsigned char kernel_prx_start[], intraFont_prx_start[], kumdman_prx_start[], vlf_prx_start[];
|
extern unsigned char kernel_prx_start[], intraFont_prx_start[], kumdman_prx_start[], vlf_prx_start[];
|
||||||
extern unsigned int kernel_prx_size, intraFont_prx_size, kumdman_prx_size, vlf_prx_size;
|
extern unsigned int kernel_prx_size, intraFont_prx_size, kumdman_prx_size, vlf_prx_size;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <pspsdk.h>
|
#include <cstdarg>
|
||||||
#include <stdarg.h>
|
#include <cstdio>
|
||||||
#include <stdio.h>
|
#include <pspkernel.h>
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspsdk.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "kumdman.h"
|
#include "kumdman.h"
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
//>>> PSP_EVEREST 2
|
//>>> PSP_EVEREST 2
|
||||||
//Copyright(C) 2023, frostegater, Joel16
|
//Copyright(C) 2023, frostegater, Joel16
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
#include <pspctrl.h>
|
#include <pspctrl.h>
|
||||||
#include <pspidstorage.h>
|
#include <pspidstorage.h>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <psppower.h>
|
#include <psppower.h>
|
||||||
#include <pspsdk.h>
|
|
||||||
#include <psputility_sysparam.h>
|
#include <psputility_sysparam.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "consoleidinfo.h"
|
#include "consoleidinfo.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "hardwareinfo.h"
|
#include "hardwareinfo.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "screenshot.h"
|
||||||
#include "systeminfo.h"
|
#include "systeminfo.h"
|
||||||
#include "translate.h"
|
#include "translate.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -42,6 +40,7 @@ namespace Menus {
|
|||||||
static constexpr u8 NUM_DEL_ITEMS_SYSTEM = 7;
|
static constexpr u8 NUM_DEL_ITEMS_SYSTEM = 7;
|
||||||
static constexpr u8 NUM_DEL_ITEMS_CONSOLEID = 8;
|
static constexpr u8 NUM_DEL_ITEMS_CONSOLEID = 8;
|
||||||
|
|
||||||
|
static u8 menu = 0;
|
||||||
static bool battery_break = false;
|
static bool battery_break = false;
|
||||||
static u16 bserialdata[2], serialdata[2];
|
static u16 bserialdata[2], serialdata[2];
|
||||||
static VlfText text_hardware[NUM_DEL_ITEMS_HARDWARE], text_battery[NUM_DEL_ITEMS_BATTERY],
|
static VlfText text_hardware[NUM_DEL_ITEMS_HARDWARE], text_battery[NUM_DEL_ITEMS_BATTERY],
|
||||||
@ -281,28 +280,43 @@ namespace Menus {
|
|||||||
GUI::SetBottomDialog(0, 1, Menus::ConsoleIdInfoHandler, 1);
|
GUI::SetBottomDialog(0, 1, Menus::ConsoleIdInfoHandler, 1);
|
||||||
GUI::SetFade();
|
GUI::SetFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Capture(void *param) {
|
||||||
|
Screenshot::Capture(menu);
|
||||||
|
return VLF_EV_RET_NOTHING;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleScreenshot(int select) {
|
||||||
|
menu = select;
|
||||||
|
vlfGuiRemoveEventHandler(Menus::Capture);
|
||||||
|
vlfGuiAddEventHandler(PSP_CTRL_SQUARE, -1, Menus::Capture, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
int MainMenuHandler(int select) {
|
int MainMenuHandler(int select) {
|
||||||
switch(select) {
|
switch(select) {
|
||||||
case 0:
|
case 0:
|
||||||
vlfGuiCancelCentralMenu();
|
vlfGuiCancelCentralMenu();
|
||||||
Menus::HardwareInfo();
|
Menus::HardwareInfo();
|
||||||
|
Menus::HandleScreenshot(select);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
vlfGuiCancelCentralMenu();
|
vlfGuiCancelCentralMenu();
|
||||||
battery_break = false;
|
battery_break = false;
|
||||||
|
Menus::HandleScreenshot(select);
|
||||||
Menus::BatteryInfo();
|
Menus::BatteryInfo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
vlfGuiCancelCentralMenu();
|
vlfGuiCancelCentralMenu();
|
||||||
Menus::SystemInfo();
|
Menus::SystemInfo();
|
||||||
|
Menus::HandleScreenshot(select);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
vlfGuiCancelCentralMenu();
|
vlfGuiCancelCentralMenu();
|
||||||
Menus::ConsoleIdInfo();
|
Menus::ConsoleIdInfo();
|
||||||
|
Menus::HandleScreenshot(select);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
@ -329,11 +343,7 @@ namespace Menus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
extern "C" int app_main(int argc, char *argv[]) {
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int app_main(int argc, char *argv[]) {
|
|
||||||
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language);
|
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language);
|
||||||
SetupTranslate();
|
SetupTranslate();
|
||||||
|
|
||||||
@ -374,7 +384,3 @@ int app_main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
140
app/source/screenshot.cpp
Normal file
140
app/source/screenshot.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <pspdisplay.h>
|
||||||
|
#include <pspiofilemgr.h>
|
||||||
|
|
||||||
|
namespace Screenshot {
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
char id[2];
|
||||||
|
u32 file_size;
|
||||||
|
u32 reserved;
|
||||||
|
u32 offset;
|
||||||
|
u32 head_size;
|
||||||
|
u32 width;
|
||||||
|
u32 height;
|
||||||
|
u16 planes;
|
||||||
|
u16 bpp;
|
||||||
|
u32 comp;
|
||||||
|
u32 bitmap_size;
|
||||||
|
u32 hres;
|
||||||
|
u32 vres;
|
||||||
|
u32 colors;
|
||||||
|
u32 impcolors;
|
||||||
|
} BitmapHeader;
|
||||||
|
|
||||||
|
static constexpr int SCREEN_WIDTH = 480;
|
||||||
|
static constexpr int SCREEN_HEIGHT = 272;
|
||||||
|
static constexpr u8 BYTES_PER_PIXEL = 3;
|
||||||
|
|
||||||
|
int WriteFile(SceUID fd, void *data, u32 length) {
|
||||||
|
u32 bytes_written = 0;
|
||||||
|
|
||||||
|
while(bytes_written < length) {
|
||||||
|
int ret = sceIoWrite(fd, static_cast<u32 *>(data) + bytes_written, length - bytes_written);
|
||||||
|
if (ret < 0) {
|
||||||
|
bytes_written = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes_written += ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes_written;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WriteBitmap(void *frame_addr, void *tmp_buf, const char *file) {
|
||||||
|
BitmapHeader *bmp = { 0 };
|
||||||
|
void *pixel_data = static_cast<u8 *>(tmp_buf) + sizeof(BitmapHeader);
|
||||||
|
u8 *line = nullptr, *p = nullptr;
|
||||||
|
SceUID fd = 0;
|
||||||
|
|
||||||
|
bmp = static_cast<BitmapHeader *>(tmp_buf);
|
||||||
|
memset(bmp, 0, sizeof(BitmapHeader));
|
||||||
|
memcpy(bmp->id, "BM", sizeof(bmp->id));
|
||||||
|
bmp->file_size = SCREEN_WIDTH * SCREEN_HEIGHT * BYTES_PER_PIXEL + sizeof(BitmapHeader);
|
||||||
|
bmp->offset = sizeof(BitmapHeader);
|
||||||
|
bmp->head_size = 0x28;
|
||||||
|
bmp->width = SCREEN_WIDTH;
|
||||||
|
bmp->height = SCREEN_HEIGHT;
|
||||||
|
bmp->planes = 1;
|
||||||
|
bmp->bpp = 24;
|
||||||
|
bmp->bitmap_size = SCREEN_WIDTH * SCREEN_HEIGHT * BYTES_PER_PIXEL;
|
||||||
|
bmp->hres = 2834;
|
||||||
|
bmp->vres = 2834;
|
||||||
|
|
||||||
|
line = static_cast<u8 *>(pixel_data);
|
||||||
|
|
||||||
|
for(int h = SCREEN_HEIGHT - 1; h >= 0; h--) {
|
||||||
|
p = static_cast<u8 *>(frame_addr) + (h * 512 * 4);
|
||||||
|
|
||||||
|
for(int i = 0; i < SCREEN_WIDTH; i++) {
|
||||||
|
line[(i * BYTES_PER_PIXEL) + 2] = p[i * 4];
|
||||||
|
line[(i * BYTES_PER_PIXEL) + 1] = p[(i * 4) + 1];
|
||||||
|
line[(i * BYTES_PER_PIXEL) + 0] = p[(i * 4) + 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
line += SCREEN_WIDTH * BYTES_PER_PIXEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = sceIoOpen(file, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
|
||||||
|
|
||||||
|
if (fd >= 0) {
|
||||||
|
Screenshot::WriteFile(fd, tmp_buf, bmp->file_size);
|
||||||
|
sceIoClose(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Save(const char *path) {
|
||||||
|
void *framebuf = malloc(SCREEN_WIDTH * SCREEN_HEIGHT * BYTES_PER_PIXEL + sizeof(BitmapHeader));
|
||||||
|
if (!framebuf) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 *vram32 = nullptr;
|
||||||
|
sceDisplayWaitVblankStart();
|
||||||
|
sceDisplayGetFrameBuf(reinterpret_cast<void **>(&vram32), nullptr, nullptr, 0);
|
||||||
|
Screenshot::WriteBitmap(vram32, framebuf, path);
|
||||||
|
free(framebuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DirExists(const char *path) {
|
||||||
|
SceUID dir = sceIoDopen(path);
|
||||||
|
if (dir >= 0) {
|
||||||
|
sceIoDclose(dir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Capture(int menu) {
|
||||||
|
if (!Screenshot::DirExists("ms0:/PSP/PHOTO/")) {
|
||||||
|
sceIoMkdir("ms0:/PSP/PHOTO", 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Screenshot::DirExists("ms0:/PSP/PHOTO/PSP-Everest/")) {
|
||||||
|
sceIoMkdir("ms0:/PSP/PHOTO/PSP-Everest", 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (menu) {
|
||||||
|
case 0:
|
||||||
|
Screenshot::Save("ms0:/PSP/PHOTO/PSP-Everest/hardware_info.bmp");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
Screenshot::Save("ms0:/PSP/PHOTO/PSP-Everest/battery_info.bmp");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
Screenshot::Save("ms0:/PSP/PHOTO/PSP-Everest/system_info.bmp");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
Screenshot::Save("ms0:/PSP/PHOTO/PSP-Everest/consoleid_info.bmp");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspsdk.h>
|
|
||||||
#include <systemctrl.h>
|
#include <systemctrl.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
#include <cstring>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspreg.h>
|
#include <pspreg.h>
|
||||||
#include <psprtc.h>
|
#include <psprtc.h>
|
||||||
#include <pspsdk.h>
|
#include <pspsdk.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ void vlfGuiSetTitleBarVisibility(int visible);
|
|||||||
*
|
*
|
||||||
* @returns a VlfText item on success, NULL on error.
|
* @returns a VlfText item on success, NULL on error.
|
||||||
*/
|
*/
|
||||||
VlfText vlfGuiAddText(int x, int y, char *string);
|
VlfText vlfGuiAddText(int x, int y, const char *string);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new text item from an unicode string.
|
* Adds a new text item from an unicode string.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user