Right now I have compiled the first prx using the sexypsf code to play psf files. This is the source code:
Code: Select all
/* PSF MODULE */
#include <pspkernel.h>
#include <pspthreadman.h>
#include <psppower.h>
#include <pspctrl.h>
#include <pspaudio.h>
#include <pspdebug.h>
#define _SPSF_TYPES_H__
#include "../driver.h"
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("PSFMODULE", 0, 1, 1);
#define SAMPLE_COUNT PSP_AUDIO_SAMPLE_ALIGN(512)
#define SAMPLE_SIZE (SAMPLE_COUNT * 4)
#define BUFFER_COUNT 8
#define BUFFER_SIZE (SAMPLE_SIZE * 64)
#define false 0
#define true 1
static int audio_thread_id;
static u8 audio_thread_exit_flag;
static int sexy_thread_id;
static u8 sexy_thread_exit_flag;
static u8 sound_buffer[BUFFER_COUNT][BUFFER_SIZE];
static u8 sound_buffer_ready[BUFFER_COUNT];
static u8 sound_read_index;
static u32 sound_read_offset;
static u8 sound_write_index;
static u32 sound_write_offset;
static int psf_boost;
static PSFINFO *psf_info;
u8 enable_reverb;
static int pause = false;
static int audio_thread(SceSize args, void *argp)
{
...
}
static int sexy_thread(SceSize args, void *argp)
{
...
}
void sexyd_update(u8 *buffer, int length)
{
...
}
/* PRX EXPORT FUNCTIONS */
// Loas a song
int loadSong(char *zipfile, char *file, int type)
{
}
// Pauses Unpauses song
void pauseSong(int state)
{
}
// Play loaded song
void playSong(void)
{
}
void stopSong()
{
}
// Song lenght in secs
int songLen(void)
{
}
// Song name
char *songName()
{
}
// Song Artist
char *songArtist()
{
}
char *songType()
{
return "PLAYSTATION X SOUND FORMAT";
}
// Fast Forward
void fastForwardSong(int len)
{
}
// Rewind
void rewindSong(int len)
{
}
////////////////////////////////////
int thread_start(SceSize args, void *argp)
{
printf("Inside PSF Module");
return 0;
}
int module_start(SceSize args, void *argp)
{
SceUID thid = sceKernelCreateThread("PSFModule", thread_start, 0x16,
0x00010000, PSP_THREAD_ATTR_USER, NULL);
if (thid < 0) {
return -1;
}
sceKernelStartThread(thid, args, argp);
return 0;
}
Code: Select all
TARGET = psfModule
OBJS = main.o unzip.o $(SEXYPSF)
SEXYPSF = ../PsxCounters.o ../PsxDma.o ../PsxBios.o \
../Spu.o ../PsxHw.o ../PsxMem.o \
../Misc.o ../R3000A.o ../PsxInterpreter.o \
../PsxHLE.o ../spu/spu.o \
# Define to build this as a prx (instead of a static elf)
BUILD_PRX = 1
# Define the name of our custom exports (minus the .exp extension)
PRX_EXPORTS = exports.exp
#USE_PSPSDK_LIBC = 1
#USE_KERNEL_LIBS = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall -DPSP -D__PSP__ -ffast-math
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBS = -lpsppower -lpspaudio -lz
PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
Code: Select all
# 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_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END
# Export our function
PSP_EXPORT_START(ModuleLib, 0, 0x0001)
PSP_EXPORT_FUNC_HASH(loadSong)
PSP_EXPORT_FUNC_HASH(playSong)
PSP_EXPORT_FUNC_HASH(pauseSong)
PSP_EXPORT_FUNC_HASH(stopSong)
PSP_EXPORT_FUNC_HASH(songName)
PSP_EXPORT_FUNC_HASH(songLen)
PSP_EXPORT_FUNC_HASH(songArtist)
PSP_EXPORT_FUNC_HASH(songType)
PSP_EXPORT_FUNC_HASH(fastForwardSong)
PSP_EXPORT_FUNC_HASH(rewindSong)
PSP_EXPORT_END
PSP_END_EXPORTS
the the songType export but it seems the prx can't send the pointer to the string "PLAYSTATION X SONG FORMAT" and the main app just prints garbage..
Well this is the code of the main app:
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <string.h>
PSP_MODULE_INFO("GMP", 0x1000, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(0);
/* Define printf, just to make typing easier */
#define printf pspDebugScreenPrintf
/* Imported function */
int loadSong(char *zipfile, char *file, int type);
void pauseSong(int state);
void playSong(void);
void stopSong();
int songLen(void);
char *songName();
char *songArtist();
char *songType();
void fastForwardSong(int len);
void rewindSong(int len);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0xa0000000, 0);
if (thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
int main(int argc, char *argv[])
{
SceUID modid;
SceModule *mod;
pspDebugScreenInit();
/* Install all our funky err thingamybobs */
pspDebugInstallKprintfHandler(NULL);
pspDebugInstallErrorHandler(NULL);
pspDebugInstallStdoutHandler(pspDebugScreenPrintData);
pspSdkInstallNoPlainModuleCheckPatch();
SetupCallbacks();
printf("\nStart my module\n");
modid = pspSdkLoadStartModule("ms0:/psp/GAME/GMPBeta/modules/PSFModule.prx", PSP_MEMORY_PARTITION_USER);
printf("Module ID %08X\n", modid);
/* Test the module exports */
printf("MODULE SONG TYPE = %s\n", songType);
/* Let's bug out */
sceKernelExitDeleteThread(0);
return 0;
}
Code: Select all
TARGET = GMPBeta
OBJS = main.o ModuleLib.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS = -mno-crt0
LIBS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = GMP Beta 0.1
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Code: Select all
.set noreorder
#include "pspstub.s"
STUB_START "ModuleLib",0x00090000,0x000a0005
STUB_FUNC 0x40B4EC07,loadSong
STUB_FUNC 0x3E60441C,playSong
STUB_FUNC 0xE9C9DF51,pauseSong
STUB_FUNC 0x14414654,stopSong
STUB_FUNC 0x5B8E3357,songName
STUB_FUNC 0xBBD4BC78,songLen
STUB_FUNC 0xF9AFE7D9,songArtist
STUB_FUNC 0x84609128,songType
STUB_FUNC 0xCCFE74ED,fastForwardSong
STUB_FUNC 0x1145E038,rewindSong
STUB_END