PSP: Add screenshot support

This commit is contained in:
UnknownShadow200 2024-03-30 11:52:25 +11:00
parent cf50e71d12
commit 4f504f8a2e
3 changed files with 26 additions and 19 deletions

View file

@ -1133,6 +1133,7 @@ void Audio_FreeChunks(void** chunks, int numChunks) {
#include <asndlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
struct AudioBuffer {
int available;
@ -1220,7 +1221,7 @@ void Audio_SetVolume(struct AudioContext* ctx, int volume) {
cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 dataSize) {
// Audio buffers must be aligned and padded to a multiple of 32 bytes
if (((uintptr_t)chunk & 0x20) != 0) {
if (((uintptr_t)chunk & 0x1F) != 0) {
Platform_Log1("Audio_QueueData: tried to queue buffer with non-aligned audio buffer 0x%x\n", &chunk);
}
@ -1273,9 +1274,8 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
}
cc_result Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) {
size = (size + 0x1F) & ~0x1F; // round up to nearest multiple of 0x20
cc_uint32 alignedSize = ((size*numChunks) + 0x1F) & ~0x1F; // round up to nearest multiple of 0x20
void* dst = aligned_alloc(0x20, alignedSize);
size = (size + 0x1F) & ~0x1F; // round up to nearest multiple of 0x20
void* dst = memalign(0x20, size);
if (!dst) return ERR_OUT_OF_MEMORY;
for (int i = 0; i < numChunks; i++) {

View file

@ -233,8 +233,25 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
/*########################################################################################################################*
*-----------------------------------------------------------Misc----------------------------------------------------------*
*#########################################################################################################################*/
static BitmapCol* PSP_GetRow(struct Bitmap* bmp, int y, void* ctx) {
cc_uint8* fb = (cc_uint8*)ctx;
return (BitmapCol*)(fb + y * BUFFER_WIDTH * 4);
}
cc_result Gfx_TakeScreenshot(struct Stream* output) {
return ERR_NOT_SUPPORTED;
int fbWidth, fbFormat;
void* fb;
int res = sceDisplayGetFrameBuf(&fb, &fbWidth, &fbFormat, PSP_DISPLAY_SETBUF_NEXTFRAME);
if (res < 0) return res;
if (!fb) return ERR_NOT_SUPPORTED;
struct Bitmap bmp;
bmp.scan0 = NULL;
bmp.width = SCREEN_WIDTH;
bmp.height = SCREEN_HEIGHT;
return Png_Encode(&bmp, output, PSP_GetRow, false, fb);
}
void Gfx_GetApiInfo(cc_string* info) {

View file

@ -563,8 +563,9 @@ void Gfx_Create(void) {
if (!Gfx.Created) InitGPU();
in_scene = false;
Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512;
Gfx.MaxTexWidth = 1024;
Gfx.MaxTexHeight = 1024;
Gfx.MaxTexSize = 512 * 512;
Gfx.Created = true;
gfx_vsync = true;
@ -624,15 +625,11 @@ static void GPUTexture_Unref(GfxResourceID* resource) {
struct GPUTexture* tex = (struct GPUTexture*)(*resource);
if (!tex) return;
*resource = NULL;
cc_uintptr addr = tex;
Platform_Log1("TEX UNREF %h", &addr);
LinkedList_Append(tex, del_textures_head, del_textures_tail);
}
static void GPUTexture_Free(struct GPUTexture* tex) {
cc_uintptr addr = tex;
Platform_Log1("TEX DELETE %h", &addr);
FreeGPUMemory(tex->uid);
Mem_Free(tex);
}
@ -838,9 +835,6 @@ struct GPUBuffer* GPUBuffer_Alloc(int size) {
buffer->data = AllocGPUMemory(size,
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, SCE_GXM_MEMORY_ATTRIB_READ,
&buffer->uid);
cc_uintptr addr = buffer->data;
Platform_Log2("VB ALLOC %h = %i bytes", &addr, &size);
return buffer;
}
@ -851,14 +845,10 @@ static void GPUBuffer_Unref(GfxResourceID* resource) {
if (!buf) return;
*resource = NULL;
cc_uintptr addr = buf;
Platform_Log1("VB UNREF %h", &addr);
LinkedList_Append(buf, del_buffers_head, del_buffers_tail);
}
static void GPUBuffer_Free(struct GPUBuffer* buf) {
cc_uintptr addr = buf;
Platform_Log1("VB DELETE %h", &addr);
FreeGPUMemory(buf->uid);
Mem_Free(buf);
}