mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
PSP: Add screenshot support
This commit is contained in:
parent
cf50e71d12
commit
4f504f8a2e
@ -1133,6 +1133,7 @@ void Audio_FreeChunks(void** chunks, int numChunks) {
|
|||||||
#include <asndlib.h>
|
#include <asndlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
struct AudioBuffer {
|
struct AudioBuffer {
|
||||||
int available;
|
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) {
|
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
|
// 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);
|
Platform_Log1("Audio_QueueData: tried to queue buffer with non-aligned audio buffer 0x%x\n", &chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1274,8 +1275,7 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
|
|||||||
|
|
||||||
cc_result Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) {
|
cc_result Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) {
|
||||||
size = (size + 0x1F) & ~0x1F; // round up to nearest multiple of 0x20
|
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 = memalign(0x20, size);
|
||||||
void* dst = aligned_alloc(0x20, alignedSize);
|
|
||||||
if (!dst) return ERR_OUT_OF_MEMORY;
|
if (!dst) return ERR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
for (int i = 0; i < numChunks; i++) {
|
for (int i = 0; i < numChunks; i++) {
|
||||||
|
@ -233,8 +233,25 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------------Misc----------------------------------------------------------*
|
*-----------------------------------------------------------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) {
|
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) {
|
void Gfx_GetApiInfo(cc_string* info) {
|
||||||
|
@ -563,8 +563,9 @@ void Gfx_Create(void) {
|
|||||||
if (!Gfx.Created) InitGPU();
|
if (!Gfx.Created) InitGPU();
|
||||||
in_scene = false;
|
in_scene = false;
|
||||||
|
|
||||||
Gfx.MaxTexWidth = 512;
|
Gfx.MaxTexWidth = 1024;
|
||||||
Gfx.MaxTexHeight = 512;
|
Gfx.MaxTexHeight = 1024;
|
||||||
|
Gfx.MaxTexSize = 512 * 512;
|
||||||
Gfx.Created = true;
|
Gfx.Created = true;
|
||||||
gfx_vsync = true;
|
gfx_vsync = true;
|
||||||
|
|
||||||
@ -625,14 +626,10 @@ static void GPUTexture_Unref(GfxResourceID* resource) {
|
|||||||
if (!tex) return;
|
if (!tex) return;
|
||||||
*resource = NULL;
|
*resource = NULL;
|
||||||
|
|
||||||
cc_uintptr addr = tex;
|
|
||||||
Platform_Log1("TEX UNREF %h", &addr);
|
|
||||||
LinkedList_Append(tex, del_textures_head, del_textures_tail);
|
LinkedList_Append(tex, del_textures_head, del_textures_tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GPUTexture_Free(struct GPUTexture* tex) {
|
static void GPUTexture_Free(struct GPUTexture* tex) {
|
||||||
cc_uintptr addr = tex;
|
|
||||||
Platform_Log1("TEX DELETE %h", &addr);
|
|
||||||
FreeGPUMemory(tex->uid);
|
FreeGPUMemory(tex->uid);
|
||||||
Mem_Free(tex);
|
Mem_Free(tex);
|
||||||
}
|
}
|
||||||
@ -838,9 +835,6 @@ struct GPUBuffer* GPUBuffer_Alloc(int size) {
|
|||||||
buffer->data = AllocGPUMemory(size,
|
buffer->data = AllocGPUMemory(size,
|
||||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, SCE_GXM_MEMORY_ATTRIB_READ,
|
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, SCE_GXM_MEMORY_ATTRIB_READ,
|
||||||
&buffer->uid);
|
&buffer->uid);
|
||||||
|
|
||||||
cc_uintptr addr = buffer->data;
|
|
||||||
Platform_Log2("VB ALLOC %h = %i bytes", &addr, &size);
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,14 +845,10 @@ static void GPUBuffer_Unref(GfxResourceID* resource) {
|
|||||||
if (!buf) return;
|
if (!buf) return;
|
||||||
*resource = NULL;
|
*resource = NULL;
|
||||||
|
|
||||||
cc_uintptr addr = buf;
|
|
||||||
Platform_Log1("VB UNREF %h", &addr);
|
|
||||||
LinkedList_Append(buf, del_buffers_head, del_buffers_tail);
|
LinkedList_Append(buf, del_buffers_head, del_buffers_tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GPUBuffer_Free(struct GPUBuffer* buf) {
|
static void GPUBuffer_Free(struct GPUBuffer* buf) {
|
||||||
cc_uintptr addr = buf;
|
|
||||||
Platform_Log1("VB DELETE %h", &addr);
|
|
||||||
FreeGPUMemory(buf->uid);
|
FreeGPUMemory(buf->uid);
|
||||||
Mem_Free(buf);
|
Mem_Free(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user