From 0041fc5f1853625776f72ca1bcc507b998f37097 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Tue, 29 Oct 2024 18:44:19 +0100 Subject: [PATCH] Dummy initial files --- include/me.h | 14 +++++++++ src/example/CMakeLists.txt | 21 +++++++++++-- src/example/main.c | 62 ++++++++++++++++++++++++++++++++++++++ src/lib/me.c | 6 ++++ src/module/CMakeLists.txt | 16 +++++++--- src/module/exports.exp | 12 ++++++++ src/module/main.c | 33 ++++++++++++++++++++ 7 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 include/me.h create mode 100644 src/example/main.c create mode 100644 src/lib/me.c create mode 100644 src/module/exports.exp create mode 100644 src/module/main.c diff --git a/include/me.h b/include/me.h new file mode 100644 index 0000000..d718d95 --- /dev/null +++ b/include/me.h @@ -0,0 +1,14 @@ +#ifndef ME_H +#define ME_H + +#ifdef __cplusplus +extern "C" { +#endif + +void foo_me(); + +#ifdef __cplusplus +} +#endif + +#endif // ME_H \ No newline at end of file diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 5429b9f..ae6eebe 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -7,9 +7,24 @@ file(GLOB EXAMPLE_SOURCES *.c) # Define the executable target add_executable(fooME ${EXAMPLE_SOURCES}) -# Link against the static library and the module -target_link_libraries(fooME pspme_static pspme_module) +# Link against the static library +target_link_libraries(fooME pspme_static) + +# TODO: Copy the generated PRX pspme_prx module to the bin directory +# add_custom_command( +# TARGET fooME POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR}/bin +# ) # Set output name to "fooME.elf" set_target_properties(fooME PROPERTIES OUTPUT_NAME "fooME") -target_include_directories(fooME PRIVATE ${CMAKE_SOURCE_DIR}/include) \ No newline at end of file +target_include_directories(fooME PRIVATE ${CMAKE_SOURCE_DIR}/include) + +# Use create_pbp_file to generate a PBP file after building fooME.elf +create_pbp_file( + TARGET fooME + ICON_PATH NULL + BACKGROUND_PATH NULL + PREVIEW_PATH NULL + TITLE "fooME" +) \ No newline at end of file diff --git a/src/example/main.c b/src/example/main.c new file mode 100644 index 0000000..fb43c0e --- /dev/null +++ b/src/example/main.c @@ -0,0 +1,62 @@ +#include + +#include +#include +#include +#include + +#include + +#define VERS 1 +#define REVS 0 +PSP_MODULE_INFO("FooME", 0, VERS, REVS); +PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); + +static int exitRequest = 0; + +static int isRunning() +{ + return !exitRequest; +} + +static int exitCallback(int arg1, int arg2, void *common) +{ + exitRequest = 1; + return 0; +} + +static int callbackThread(SceSize args, void *argp) +{ + int callbackID; + + callbackID = sceKernelCreateCallback("Exit Callback", exitCallback, NULL); + sceKernelRegisterExitCallback(callbackID); + + sceKernelSleepThreadCB(); + + return 0; +} + +static int setupExitCallback() +{ + int threadID = 0; + + threadID = sceKernelCreateThread("Callback Update Thread", callbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0); + + if (threadID >= 0) + { + sceKernelStartThread(threadID, 0, 0); + } + + return threadID; +} + +int main(int argc, char **argv) +{ + // basic init + setupExitCallback(); + + foo_me(); + + return 0; +} \ No newline at end of file diff --git a/src/lib/me.c b/src/lib/me.c new file mode 100644 index 0000000..55a119f --- /dev/null +++ b/src/lib/me.c @@ -0,0 +1,6 @@ +#include + +void foo_me() +{ + printf("static lib: FooME\n"); +} \ No newline at end of file diff --git a/src/module/CMakeLists.txt b/src/module/CMakeLists.txt index f093df4..1c7a985 100644 --- a/src/module/CMakeLists.txt +++ b/src/module/CMakeLists.txt @@ -4,9 +4,15 @@ project(pspme_prx) # Collect source files for the PRX module file(GLOB MODULE_SOURCES *.c) -# Define the PRX target -add_library(pspme_module MODULE ${MODULE_SOURCES}) +# Set BUILD_PRX variable to ON +set(BUILD_PRX ON) +set(PRX_EXPORTS exports.exp) -# Set output name to "pspme.prx" -set_target_properties(pspme_module PROPERTIES OUTPUT_NAME "pspme") -target_include_directories(pspme_module PUBLIC ${CMAKE_SOURCE_DIR}/include) \ No newline at end of file +# TODO: Improve .cmake file to handle PRX exports + +# # Define the PRX target +# add_executable(pspme_prx ${MODULE_SOURCES}) + +# # Set output name to "pspme.prx" +# set_target_properties(pspme_prx PROPERTIES OUTPUT_NAME "pspme") +# target_include_directories(pspme_prx PUBLIC ${CMAKE_SOURCE_DIR}/include) diff --git a/src/module/exports.exp b/src/module/exports.exp new file mode 100644 index 0000000..b7940e8 --- /dev/null +++ b/src/module/exports.exp @@ -0,0 +1,12 @@ +# Define the exports for the prx +PSP_BEGIN_EXPORTS + +# These four lines are mandatory (although you can add other functions like module_stop) +# syslib is a psynonym for the single mandatory export. +PSP_EXPORT_START(syslib, 0, 0x8000) +PSP_EXPORT_FUNC(module_start) +PSP_EXPORT_FUNC(module_stop) +PSP_EXPORT_VAR(module_info) +PSP_EXPORT_END + +PSP_END_EXPORTS diff --git a/src/module/main.c b/src/module/main.c new file mode 100644 index 0000000..48f7942 --- /dev/null +++ b/src/module/main.c @@ -0,0 +1,33 @@ +#include + +#include + +#define VERS 1 +#define REVS 0 +PSP_MODULE_INFO("PSPME", PSP_MODULE_KERNEL, VERS, REVS); + +int main_thread(SceSize args, void *argp) +{ + printf("PSPME Module\n"); + + return 0; +} + +/* Entry point */ +int module_start(SceSize args, void *argp) +{ + int thid; + + thid = sceKernelCreateThread("template", main_thread, 7, 0x800, 0, NULL); + if(thid >= 0) + { + sceKernelStartThread(thid, args, argp); + } + return 0; +} + +/* Module stop entry */ +int module_stop(SceSize args, void *argp) +{ + return 0; +}