isle-portable/CONFIG/vita/src/paf_runtime.cpp
olebeck 47736862a7
Add PSVita port (#541)
* add psvita to cmake

* no PIE for vita

* add modules to vpk

* use custom pvr apphint

* select correct renderer for sdl renderer

* patch sdl3 shaders, got something on screen!

* use proper cmake patch for sdl

* add missing module

* remove test window which causes a bug in the vita sdl port to show up

* add gxm renderer (not working with display yet)

* avoid sdl renderer for vita, seems broken

* make gxm renderer work with new d3drm

* fix rendering somewhat, some geometry shows up

* support paletted textures directly to avoid copying the texture twice

* fix Draw2DImage

* make 3d work, broken lights

* clean up a bit

* fix normals matrix

* remove some unneeded changes

* forgot env var

* wrong env dest

* run clang format

* correct texture address mode, use tlsf instead of sceClibMspace

* double buffered uniforms seem to work now

* missed a line

* update GXMRenderer_EnumDevice

* hopefully actually fix uniform buffers

* run clang-format

* remove a change thats not needed

* improve fragment shader performance

* add vita to dist folder

* add base for vita config app

* add config self to vpk

* transform touch events to virtual size

* add livearea graphics

* Update cmake file to include livearea assets

* put manual in the right place

* add sample rco

* add messagebox on vita

* triple buffer textures because fences arent a thing on vita and making draw&cpu sync would be too slow

* make config app not crash on launch

* change defaults

* update gxm renderer with interface changes

* split 2d and 3d shaders completely

* update gxm renderer

* fix transition on gxm

* clang format

* move config cmake

* move CONFIG_vita

* always clear before drawing 2d image

* hopefully fix windows build

* clang-format fix broken includes

* order again

* undo moving qt cmake to its own list

* move uic search path

* use ifdefs for all d3drm backends, cpack to generate vpk

* cmake wrong escape

* small cleanups in gxm renderer

* defer texture delete to avoid overwriting the texture during a frame

* clang-format

* more of the layout for config

* remove top buttons

* use SceAppSettings instead of custom ui

* use select for back to info center on vita, to make screenshots possible again

* remove accidentally left in add_subdirectory

* adjust diskpath to be like other ports

* use vita_create_vpk and not cpack

* gxm: msaa support, fix wrong file path

* gxm: add mipmaps (disabled)

* clang-format

* fix open isle.ini with fopen

* add missing strings

* use iniparser_set not dictionary_set

* add default save path to config

* load config app after initializing ini on vita

* fix config build

* change the default disk & cd path, update the paf library

* update paf library headers

* include orders for clang-format

* clean up

* make shader compiler not required

* move asm language

* warn instead of error when shader source is changed when no compiler is found

---------

Co-authored-by: Li <li@silica.codes>
Co-authored-by: Christian Semmler <mail@csemmler.com>
2025-10-31 23:23:12 +00:00

170 lines
2.9 KiB
C++

#include <paf.h>
#include <psp2/kernel/clib.h>
#include <psp2/kernel/modulemgr.h>
#include <psp2/kernel/processmgr.h>
#include <psp2/sysmodule.h>
char sceUserMainThreadName[] = "isle_config";
int sceUserMainThreadPriority = 0x10000100;
int sceUserMainThreadCpuAffinityMask = 0x70000;
SceSize sceUserMainThreadStackSize = 0x4000;
void operator delete(void* ptr, unsigned int n)
{
return sce_paf_free(ptr);
}
extern "C"
{
void user_malloc_init()
{
}
void user_malloc_finalize(void)
{
}
void* user_malloc(size_t size)
{
return sce_paf_malloc(size);
}
void user_free(void* ptr)
{
sce_paf_free(ptr);
}
void* user_calloc(size_t nelem, size_t size)
{
return sce_paf_calloc(nelem, size);
}
void* user_realloc(void* ptr, size_t new_size)
{
return sce_paf_realloc(ptr, new_size);
}
void* user_memalign(size_t boundary, size_t size)
{
return sce_paf_memalign(boundary, size);
}
void* user_reallocalign(void* ptr, size_t size, size_t boundary)
{
sceClibPrintf("[PAF2LIBC] reallocalign is not supported\n");
abort();
return NULL;
}
int user_malloc_stats(struct malloc_managed_size* mmsize)
{
sceClibPrintf("malloc_stats\n");
abort();
return 0;
}
int user_malloc_stats_fast(struct malloc_managed_size* mmsize)
{
sceClibPrintf("user_malloc_stats_fast\n");
abort();
return 0;
}
size_t user_malloc_usable_size(void* ptr)
{
return sce_paf_musable_size(ptr);
}
}
void* user_new(std::size_t size)
{
return sce_paf_malloc(size);
}
void* user_new(std::size_t size, const std::nothrow_t& x)
{
return sce_paf_malloc(size);
}
void* user_new_array(std::size_t size)
{
return sce_paf_malloc(size);
}
void* user_new_array(std::size_t size, const std::nothrow_t& x)
{
return sce_paf_malloc(size);
}
void user_delete(void* ptr)
{
sce_paf_free(ptr);
}
void user_delete(void* ptr, const std::nothrow_t& x)
{
sce_paf_free(ptr);
}
void user_delete_array(void* ptr)
{
sce_paf_free(ptr);
}
void user_delete_array(void* ptr, const std::nothrow_t& x)
{
sce_paf_free(ptr);
}
int paf_init()
{
int load_res;
ScePafInit init_param;
SceSysmoduleOpt sysmodule_opt;
init_param.global_heap_size = 0x1000000;
init_param.cdlg_mode = 0;
init_param.global_heap_alignment = 0;
init_param.global_heap_disable_assert_on_alloc_failure = 0;
load_res = 0xDEADBEEF;
sysmodule_opt.flags = 0;
sysmodule_opt.result = &load_res;
int res = sceSysmoduleLoadModuleInternalWithArg(
SCE_SYSMODULE_INTERNAL_PAF,
sizeof(init_param),
&init_param,
&sysmodule_opt
);
if ((res | load_res) != 0) {
sceClibPrintf(
"[PAF PRX Loader] Failed to load the PAF prx. (return value 0x%x, result code 0x%x )\n",
res,
load_res
);
return -1;
}
return 0;
}
int main();
extern "C" int module_start(SceSize args, void* argp)
{
int res = paf_init();
if (res < 0) {
sceKernelExitProcess(res);
return SCE_KERNEL_START_FAILED;
}
res = main();
sceKernelExitProcess(res);
return SCE_KERNEL_START_SUCCESS;
}
extern "C" void _start()
{
module_start(0, nullptr);
}