I've already compiled a library with the vio2sf code and a simple test player. But when i try to run the app in the psp i get an 0x80020148 error, wich means 'Unsupported prx'. This error was supposed to occur when you tryied to run a 1.5 kernel app in a 3xx kernel if i'm not wrong (?)
But i'm creating the app as a user mode prx, so i don't know why i'm getting that error code.
Here is the simple player and the makefile:
Code: Select all
#include <pspkernel.h>
#include <psppower.h>
#include <SDL/SDL.h>
#include "ao.h"
#include "corlett.h"
#include "vio2sf/vio2sf.h"
PSP_MODULE_INFO("vio2play", 0x0, 0, 1);
PSP_MAIN_THREAD_PARAMS(/*Prio*/80, /*Stack KB*/512, PSP_THREAD_ATTR_USER);//PSP_THREAD_ATTR_USER);
PSP_MAIN_THREAD_NAME("Main");
PSP_HEAP_SIZE_KB(2 * 1024);
// Variables
static uint8 *buffer; // buffer containing 2sf file
static uint32 size; // size of buffer
static corlett_t *c = NULL;
// Audio info variables
int channels = 2;
int samplerate = 44100;
int length = 0;
static void audiocallback ( void * userdata, Uint8 * stream, int len )
{
xsf_gen(stream, len);
}
char *xsf_tagget(const char *tag, const char *pData, int dwSize);
/* ao_get_lib: called to load secondary files */
int xsf_get_lib(char *filename, void **buffer, unsigned int *length)
{
uint8 *filebuf;
uint32 size;
FILE *auxfile;
auxfile = fopen(filename, "rb");
if (!auxfile)
{
printf("Unable to find auxiliary file %s\n", filename);
return AO_FAIL;
}
fseek(auxfile, 0, SEEK_END);
size = ftell(auxfile);
fseek(auxfile, 0, SEEK_SET);
filebuf = malloc(size);
if (!filebuf)
{
fclose(auxfile);
printf("ERROR: could not allocate %d bytes of memory\n", size);
return AO_FAIL;
}
fread(filebuf, size, 1, auxfile);
fclose(auxfile);
*buffer = filebuf;
*length = (uint64)size;
return AO_SUCCESS;
}
static void do_frame(uint32 size, int16 *buffer)
{
xsf_gen(buffer, size);
}
// load and set up a 2sf file
int load_file(char *name)
{
FILE *file;
uint32 filesig;
uint8 *filedata;
uint64 file_len;
file = fopen(name, "rb");
if (!file)
{
fprintf(stderr, "ERROR: could not open file %s\n", name);
return -1;
}
// get the length of the file by seeking to the end then reading the current position
fseek(file, 0, SEEK_END);
size = ftell(file);
// reset the pointer
fseek(file, 0, SEEK_SET);
buffer = malloc(size);
if (!buffer)
{
fclose(file);
fprintf(stderr, "ERROR: could not allocate %d bytes of memory\n", size);
return -1;
}
// read the file
fread(buffer, size, 1, file);
fclose(file);
// init our *SF engine so we can get tags
if (corlett_decode(buffer, size, &filedata, &file_len, &c) != AO_SUCCESS)
{
fprintf(stderr, "Error: Unable to process tags\n");
return -1;
}
free(filedata); // we don't use this
if (xsf_start(buffer, size) != XSF_TRUE)
{
fprintf(stderr, "ERROR: vio2sf rejected the file!\n");
return -1;
}
return 0;
}
u64 tickFrequency, last, cur, med;
int main( int argc, char *argv[] )
{
char tune[256];
if( argv[1] ) strcpy(tune, argv[1]);
else strcpy(tune, "test.2sf");
if( load_file(tune) < 0 ) goto close;
// Get audio info
samplerate = 44100;
channels = 2;
if ((c != NULL) && (c->inf_length != NULL)) length = psfTimeToMS(c->inf_length);
else length = 0;
if ((c != NULL) && (c->inf_title != NULL))
{
fprintf(stderr, "Playing \"%s\" by %s from %s. Copyright %s %s.\n", c->inf_title, c->inf_artist, c->inf_game, c->inf_copy, c->inf_year);
}
else
{
fprintf(stderr, "Playing %s\n", tune);
}
fprintf(stderr, "Samplerate: %d\n", samplerate);
fprintf(stderr, "Channels: %d\n", channels);
fprintf(stderr, "BitsPerSample: %d\n", 0);
fprintf(stderr, "Length: %d\n", length);
// Check if samplerate is compatible
if( samplerate != 44100 ) {
fprintf(stderr, "Error: Samplerate not supported: %d\n", samplerate);
goto close;
}
SDL_AudioSpec audioSpec;
audioSpec.freq = samplerate;
audioSpec.format = AUDIO_S16LSB;
audioSpec.channels = channels;
audioSpec.samples = 8192;
audioSpec.callback = audiocallback;
if (SDL_OpenAudio(&audioSpec, NULL)<0) {
fprintf(stderr, "Error: Cannot open audio device\n");
return 0;
}
SDL_PauseAudio(0);
if( length > 0 ) SDL_Delay( length );
else SDL_Delay( 5000 );
close:
fprintf(stderr, "Exiting OK\n");
SDL_CloseAudio();
SDL_Quit();
// Terminate engine and free memory
xsf_term();
free(buffer);
sceKernelDelayThread( 0 );
sceKernelExitGame();
return 0;
}
Code: Select all
# Modplug Player PSP
TARGET = vio2play
PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = D:/cygwin/usr/local/pspdev/psp/bin
PSPDIR=$(shell psp-config --psp-prefix)
PSP_FW_VERSION = 371
BUILD_PRX = 1
CFLAGS = -O2 -G0 -Wall -DLSB_FIRST=1 -D_strnicmp=strnicmp
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions
INCDIR = vio2sf
OBJS = vio2play.o corlett.o
LIBS = -l2sf -lSDL -lm -lz \
-lpsppower -lpsprtc -lpspaudio
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = vio2play v
include $(PSPSDK)/lib/build.mak
Thanks in advance