Strange problem porting app.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
theHobbit
Posts: 65
Joined: Sat Sep 30, 2006 5:26 am

Strange problem porting app.

Post by theHobbit »

Hi there, i'm trying to port vio2play to the psp. vio2play is a nintendo ds sound format (2sf) player for linux.

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&#40;"vio2play", 0x0, 0, 1&#41;;
PSP_MAIN_THREAD_PARAMS&#40;/*Prio*/80, /*Stack KB*/512, PSP_THREAD_ATTR_USER&#41;;//PSP_THREAD_ATTR_USER&#41;;
PSP_MAIN_THREAD_NAME&#40;"Main"&#41;;
PSP_HEAP_SIZE_KB&#40;2 * 1024&#41;;

// 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 &#40; void * userdata, Uint8 * stream, int len &#41;
&#123;
	xsf_gen&#40;stream, len&#41;;
&#125;

char *xsf_tagget&#40;const char *tag, const char *pData, int dwSize&#41;;

/* ao_get_lib&#58; called to load secondary files */
int xsf_get_lib&#40;char *filename, void **buffer, unsigned int *length&#41;
&#123;
	uint8 *filebuf;
	uint32 size;
	FILE *auxfile;

	auxfile = fopen&#40;filename, "rb"&#41;;
	if &#40;!auxfile&#41;
	&#123;
		printf&#40;"Unable to find auxiliary file %s\n", filename&#41;;
		return AO_FAIL;
	&#125;

	fseek&#40;auxfile, 0, SEEK_END&#41;;
	size = ftell&#40;auxfile&#41;;
	fseek&#40;auxfile, 0, SEEK_SET&#41;;

	filebuf = malloc&#40;size&#41;;

	if &#40;!filebuf&#41;
	&#123;
		fclose&#40;auxfile&#41;;
		printf&#40;"ERROR&#58; could not allocate %d bytes of memory\n", size&#41;;
		return AO_FAIL;
	&#125;

	fread&#40;filebuf, size, 1, auxfile&#41;;
	fclose&#40;auxfile&#41;;

	*buffer = filebuf;
	*length = &#40;uint64&#41;size;

	return AO_SUCCESS;
&#125;

static void do_frame&#40;uint32 size, int16 *buffer&#41;
&#123;
	xsf_gen&#40;buffer, size&#41;;
&#125;

// load and set up a 2sf file
int load_file&#40;char *name&#41;
&#123;
	FILE *file;
	uint32 filesig;
	uint8 *filedata;
	uint64 file_len;

	file = fopen&#40;name, "rb"&#41;;

	if &#40;!file&#41;
	&#123;
		fprintf&#40;stderr, "ERROR&#58; could not open file %s\n", name&#41;;
		return -1;
	&#125;

	// get the length of the file by seeking to the end then reading the current position
	fseek&#40;file, 0, SEEK_END&#41;;
	size = ftell&#40;file&#41;;
	// reset the pointer
	fseek&#40;file, 0, SEEK_SET&#41;;

	buffer = malloc&#40;size&#41;;

	if &#40;!buffer&#41;
	&#123;
		fclose&#40;file&#41;;
		fprintf&#40;stderr, "ERROR&#58; could not allocate %d bytes of memory\n", size&#41;;
		return -1;
	&#125;

	// read the file
	fread&#40;buffer, size, 1, file&#41;;
	fclose&#40;file&#41;;

	// init our *SF engine so we can get tags
	if &#40;corlett_decode&#40;buffer, size, &filedata, &file_len, &c&#41; != AO_SUCCESS&#41;
	&#123;
		fprintf&#40;stderr, "Error&#58; Unable to process tags\n"&#41;;
		return -1;
	&#125;
	free&#40;filedata&#41;;	// we don't use this

 	if &#40;xsf_start&#40;buffer, size&#41; != XSF_TRUE&#41;
	&#123;
		fprintf&#40;stderr, "ERROR&#58; vio2sf rejected the file!\n"&#41;;
		return -1;
	&#125;

	return 0;
&#125;

u64 tickFrequency, last, cur, med;
int main&#40; int argc, char *argv&#91;&#93; &#41;
&#123;
	char tune&#91;256&#93;;
	if&#40; argv&#91;1&#93; &#41; strcpy&#40;tune, argv&#91;1&#93;&#41;;
	else strcpy&#40;tune, "test.2sf"&#41;;
	
	if&#40; load_file&#40;tune&#41; < 0 &#41; goto close;
	
	// Get audio info
	samplerate = 44100;
	channels = 2;
	if &#40;&#40;c != NULL&#41; && &#40;c->inf_length != NULL&#41;&#41; length = psfTimeToMS&#40;c->inf_length&#41;;
	else length = 0;	

	if &#40;&#40;c != NULL&#41; && &#40;c->inf_title != NULL&#41;&#41;
	&#123;
		fprintf&#40;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&#41;;
	&#125;
	else
	&#123;
		fprintf&#40;stderr, "Playing %s\n", tune&#41;;
	&#125;
	
	fprintf&#40;stderr, "Samplerate&#58;    %d\n", samplerate&#41;;
	fprintf&#40;stderr, "Channels&#58;      %d\n", channels&#41;;
	fprintf&#40;stderr, "BitsPerSample&#58; %d\n", 0&#41;;
	fprintf&#40;stderr, "Length&#58;        %d\n", length&#41;;
	
	// Check if samplerate is compatible
	if&#40; samplerate != 44100 &#41; &#123;
		fprintf&#40;stderr, "Error&#58; Samplerate not supported&#58; %d\n", samplerate&#41;;
		goto close;
	&#125;
	
	SDL_AudioSpec audioSpec;
	audioSpec.freq 		= samplerate;
    audioSpec.format 	= AUDIO_S16LSB;
    audioSpec.channels 	= channels;
    audioSpec.samples 	= 8192; 
    audioSpec.callback 	= audiocallback;
    
	if &#40;SDL_OpenAudio&#40;&audioSpec, NULL&#41;<0&#41; &#123;
        fprintf&#40;stderr, "Error&#58; Cannot open audio device\n"&#41;;
        return 0;
    &#125;
    
    SDL_PauseAudio&#40;0&#41;;
	
	if&#40; length > 0 &#41; SDL_Delay&#40; length &#41;;
	else SDL_Delay&#40; 5000 &#41;;

close&#58;	    
	fprintf&#40;stderr, "Exiting OK\n"&#41;;
	SDL_CloseAudio&#40;&#41;;
	SDL_Quit&#40;&#41;;
	
	// Terminate engine and free memory
	xsf_term&#40;&#41;;
	free&#40;buffer&#41;;
	
	sceKernelDelayThread&#40; 0 &#41;;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

Code: Select all

# Modplug Player PSP

TARGET = vio2play

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
PSPBIN = D&#58;/cygwin/usr/local/pspdev/psp/bin
PSPDIR=$&#40;shell psp-config --psp-prefix&#41;

PSP_FW_VERSION = 371
BUILD_PRX = 1

CFLAGS  = -O2 -G0 -Wall -DLSB_FIRST=1 -D_strnicmp=strnicmp
CXXFLAGS = $&#40;CFLAGS&#41; -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 $&#40;PSPSDK&#41;/lib/build.mak
The only thing i have found is that something in the vio2sf code is causing it, because if i comment all vio2sf calls (xsf_something) the app loads and run fine. Does anyone have a clue of what is happening? I could share the code if anyone is interested.

Thanks in advance
Post Reply