forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with PRX for music app

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Sat Sep 30, 2006 5:52 am    Post subject: Help with PRX for music app Reply with quote

Hello everyone I've been reading about prxes and had an idea about using them like plugins for my music app wich I released some time ago like GameMusicEmu so it would be easier to add more plugins (prx for other song formats) and just load them from the main app.

Right now I have compiled the first prx using the sexypsf code to play psf files. This is the source code:

Code:


/*  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;
}


and here is the makefile:
Code:

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

and the exports.exp:
Code:

# 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

Now I have a main app that just tries to load the prx and test
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:

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

And the makefile:
Code:

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

And the ModuleLib.S:
Code:

   .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


Well that is I really hope anybody helps because I've been trying for some days now and I can's seem to solve this : (
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group