Skip to content

Commit

Permalink
Dummy initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Oct 29, 2024
1 parent d65a088 commit 0041fc5
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 8 deletions.
14 changes: 14 additions & 0 deletions include/me.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef ME_H
#define ME_H

#ifdef __cplusplus
extern "C" {
#endif

void foo_me();

#ifdef __cplusplus
}
#endif

#endif // ME_H
21 changes: 18 additions & 3 deletions src/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_FILE:pspme_prx> ${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)
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"
)
62 changes: 62 additions & 0 deletions src/example/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <stdio.h>

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspkernel.h>

#include <me.h>

#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;
}
6 changes: 6 additions & 0 deletions src/lib/me.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

void foo_me()
{
printf("static lib: FooME\n");
}
16 changes: 11 additions & 5 deletions src/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# 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)
12 changes: 12 additions & 0 deletions src/module/exports.exp
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions src/module/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>

#include <pspkernel.h>

#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;
}

0 comments on commit 0041fc5

Please sign in to comment.