Compiles, but shuts down when booted..

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

Moderators: cheriff, TyRaNiD

Post Reply
JesusXP
Posts: 79
Joined: Tue Jan 17, 2006 11:16 am
Location: Ontario, Canada

Compiles, but shuts down when booted..

Post by JesusXP »

Hey guys,

My new prog im workin on, is basically just blending a few of the Yeldarb tut's, the Sprite, and MP3 . I boot it up, and after loading it just powers the PSP off.

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include <pspdisplay.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>

#include "graphics.h"
#include "mp3player.h"

#define printf pspDebugScreenPrintf
#define MAX&#40;X,Y&#41; &#40;&#40;X&#41;>&#40;Y&#41;?&#40;X&#41;&#58;&#40;Y&#41;&#41;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;&#123;
	int cbid;
	
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	
	sceKernelSleepThreadCB&#40;&#41;;
	
	return 0;
&#125;

/* Sets up the callback thread and returns its threat id */
int SetupCallbacks&#40;void&#41;&#123;
	int thid;
	
	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;
	
	return thid;
&#125;

int main&#40;&#41;&#123;
	// Set the power frequency
	scePowerSetClockFrequency&#40;333, 333, 166&#41;;
	
	SceCtrlData pad;
	char hero_buffer&#91;200&#93;;
	/* char enemy_buffer&#91;200&#93;; */
	Image* ourHero;
	/* Image* ourEnemy; */
	
	
	SetupCallbacks&#40;&#41;;
	pspDebugScreenInit&#40;&#41;;
	initGraphics&#40;&#41;;
	pspAudioInit&#40;&#41;;
	
	MP3_Init&#40;1&#41;;
	MP3_Load&#40;"Camron, Jim  Jones - I Am Dame Dash.mp3"&#41;;
	MP3_Play&#40;&#41;;
		
	sprintf&#40;hero_buffer, "character.png"&#41;;
	ourHero = loadImage&#40;hero_buffer&#41;;
	
	/* sprintf&#40;enemy_buffer, "enemyDude.png"&#41;;
	ourEnemy = loadImage&#40;enemy_buffer&#41;; */
	
	if&#40;!ourHero&#41;&#123;
		//Image load failed
		printf&#40;"Image load failed!\n"&#41;;
	&#125;/*else if&#40;!ourEnemy&#41;&#123;
		//Image load failed
		printf&#40;"Image load failed!\n"&#41;;
	&#125;*/else&#123;
		int hero_x = 0/*, enemy_x = 150*/;
		int hero_y = 0/*, enemy_y = 0*/;
		sceDisplayWaitVblankStart&#40;&#41;;
		
		while&#40;1&#41;&#123;
			clearScreen&#40;0&#41;;
			blitAlphaImageToScreen&#40;0, 0, 32, 32, ourHero, hero_x, hero_y&#41;;
			/* blitAlphaImageToScreen&#40;0, 0, 32, 32, ourEnemy, enemy_x, enemy_y&#41;; */
			
			
			sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
			
			//meDude controls
			if&#40;pad.Buttons & PSP_CTRL_LEFT&#41;&#123;
				if&#40;hero_x>0&#41;&#123;hero_x--;&#125;
			&#125;

			if&#40;pad.Buttons & PSP_CTRL_RIGHT&#41;&#123;
				if&#40;hero_x<&#40;480-32&#41;&#41;&#123;hero_x++;&#125;
			&#125;
			
			if&#40;pad.Buttons & PSP_CTRL_UP&#41;&#123;
				if&#40;hero_y>0&#41;&#123;hero_y--;&#125;
			&#125;
			
			if&#40;pad.Buttons & PSP_CTRL_DOWN&#41;&#123;
				if&#40;hero_y<&#40;272-32&#41;&#41;&#123;hero_y++;&#125;
			&#125;
			
			/* Enemy Controls
			if&#40;pad.Buttons & PSP_CTRL_SQUARE&#41;&#123;
				if&#40;enemy_x>0&#41;&#123;enemy_x--;&#125;
			&#125;

			if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;&#123;
				if&#40;enemy_x<&#40;480-32&#41;&#41;&#123;enemy_x++;&#125;
			&#125;
			
			if&#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;&#123;
				if&#40;enemy_y>0&#41;&#123;enemy_y--;&#125;
			&#125;
			
			if&#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
				if&#40;enemy_y<&#40;272-32&#41;&#41;&#123;enemy_y++;&#125;
			&#125; */
			
			//if the MP3 finishes, stop it.
			if&#40;MP3_EndOfStream&#40;&#41; == 1&#41;&#123;
			MP3_Stop&#40;&#41;;
			&#125;
			
			sceDisplayWaitVblank&#40;&#41;;
			flipScreen&#40;&#41;;
		&#125;	
	
	&#125;
	
	/* Stop MP3 & Free Memory */
	MP3_Stop&#40;&#41;;
	MP3_FreeTune&#40;&#41;;
	
	sceKernelSleepThread&#40;&#41;;
	return 0;
&#125;
Makefile:

Code: Select all

TARGET = gamebeta
OBJS = mp3player.o graphics.o framebuffer.o game.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lmad -lpspaudiolib -lpspaudio -lpsppower 
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MP3 Player Example

PSPSDK=/usr/local/pspdev/psp/sdk
include $&#40;PSPSDK&#41;/lib/build.mak
any tips
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Are you sure the MP3 file is in your game directory on your psp? If it is, try removing spaces, im not sure if that is the problem but i dont see anything else.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

where is your PSP_MODULE_INFO?
10011011 00101010 11010111 10001001 10111010
JesusXP
Posts: 79
Joined: Tue Jan 17, 2006 11:16 am
Location: Ontario, Canada

Post by JesusXP »

thanks dot_blank, I completely missed that :P sorry for the mistake
Post Reply