help with my homebrew

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

Moderators: cheriff, TyRaNiD

Post Reply
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

help with my homebrew

Post by Rangu2057 »

im having a little bit of trouble in my homebrew app, it runs fine, but it seems to always bring up the error showing image text on the screen and im pretty sure that nothing is wrong. Also i set it up where if i pressed the home button, the game would exit, but it doesnt read the button input even though i have coded it in a way that its supposed to. Here is my code, can someone please tell me what im doing wrong here?

main.c

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudiolib.h>
#include <pspaudio.h>
#include <psppower.h>
#include <stdio.h>
#include <pspgu.h>
// #include <math.h>
// #include <string.h>

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

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO&#40;"deathcore", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;&#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 thread id */
int SetupCallbacks&#40;void&#41; &#123;
	int thid = 0;
	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 SetupMenuBG&#40;&#41;&#123;

char buff&#91;200&#93;;
Image* menu;

pspDebugScreenInit&#40;&#41;;

sprintf&#40;buff, "menu.png"&#41;;
menu = loadImage&#40;buff&#41;;

if&#40;!menu&#41;
	&#123;
	pspDebugScreenClear&#40;&#41;;
	printf&#40;"error upon displaying image\n"&#41;;
	printf&#40;"Autoexiting..."&#41;;
	sceKernelSleepThread&#40;&#41;;
	&#125;
else
	&#123;
	sceDisplayWaitVblankStart&#40;&#41;;
	blitImageToScreen&#40;0, 0, 480, 272, menu, 0, 0&#41;;
	flipScreen&#40;&#41;;
	sceKernelSleepThread&#40;&#41;;
	&#125;
	return 0;
&#125;

int Music_player&#40;char* fileName&#41;
&#123;
	MP3_Init&#40;1&#41;;
	MP3_Load&#40;fileName&#41;;
	MP3_Play&#40;&#41;;
	return *fileName;
&#125;


int main&#40;&#41;&#123;
SceCtrlData pad;

pspDebugScreenInit&#40;&#41;;
initGraphics&#40;&#41;;
SetupCallbacks;

SetupMenuBG&#40;&#41;;

pspAudioInit&#40;&#41;;
Music_player&#40;"menu.mp3"&#41;;

pspDebugScreenSetXY&#40;25, 0&#41;;
pspDebugScreenSetTextColor&#40;0xFF9900&#41;;	// orange or red-orange
printf&#40;"<--DeathCore_V1.0 By Rangu2057-->"&#41;;

pspDebugScreenSetXY&#40;25, 5&#41;;
printf&#40;"New Game"&#41;;

pspDebugScreenSetXY&#40;25, 8&#41;;
printf&#40;"Load Save"&#41;;

pspDebugScreenSetXY&#40;25, 11&#41;;
printf&#40;"Options"&#41;;

pspDebugScreenSetXY&#40;25, 14&#41;;
printf&#40;"Credits"&#41;;

int current = 0;
return current;

switch &#40;current&#41; &#123;
	case 0&#58;
	pspDebugScreenSetXY&#40;20, 5&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	case 1&#58;
	pspDebugScreenSetXY&#40;20, 8&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	case 2&#58;
	pspDebugScreenSetXY&#40;20, 11&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	case 3&#58;
	pspDebugScreenSetXY&#40;20, 14&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	&#125;


while&#40;1&#41;&#123;
	sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

if&#40;pad.Buttons & PSP_CTRL_DOWN&#41;
	&#123;
	current += 1;
	&#125;
if&#40;pad.Buttons & PSP_CTRL_UP&#41;
	&#123;
	current -= 1;
	&#125;
if&#40;pad.Buttons & PSP_CTRL_HOME&#41;
	&#123;
	sceKernelExitGame&#40;&#41;;
	&#125;
&#125;
&#125;
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
GORETHRASHER
Posts: 12
Joined: Wed Sep 10, 2008 12:28 pm

Post by GORETHRASHER »

Code: Select all

int current = 0;
return current;
return current;
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

nope still nothing, i got the feeling that i set something to always true so

Code: Select all

error upon displaying image
autoexiting...
comes up everytime i start, so far, the only problem resides in the image area, i just dont know where / how i messed up on it though. BTW, i tried doing what u said goreth, but the same thing happened, do you have any other suggestions?
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
GORETHRASHER
Posts: 12
Joined: Wed Sep 10, 2008 12:28 pm

Post by GORETHRASHER »

I would suggest doing more error checking after the loadImage call.

Try printing the address of menu after the load to make sure it isn't null.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

i did what you said, and it seems menu is set to "0", im still pretty new to this stuff, but im pretty sure menu is always set to NULL, correct me if im mistaken here

EDIT: i changed "return 0;" to "return home;" thinking it would change, but obviously it did not
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
GORETHRASHER
Posts: 12
Joined: Wed Sep 10, 2008 12:28 pm

Post by GORETHRASHER »

Since you say that menu is always 0, then loadImage is failing.

You can modify loadImage to print error messages

Code: Select all

Image* loadImage&#40;const char* filename&#41;
&#123;
	png_structp png_ptr;
	png_infop info_ptr;
	unsigned int sig_read = 0;
	png_uint_32 width, height;
	int bit_depth, color_type, interlace_type, x, y;
	u32* line;
	FILE *fp;
	Image* image = &#40;Image*&#41; malloc&#40;sizeof&#40;Image&#41;&#41;;
	if &#40;!image&#41; return NULL;

	if &#40;&#40;fp = fopen&#40;filename, "rb"&#41;&#41; == NULL&#41;
	&#123;
		pspDebugScreenPrintf&#40;"cannot open file&#58; %s\n", filename &#41;;
		return NULL;
	&#125;
	png_ptr = png_create_read_struct&#40;PNG_LIBPNG_VER_STRING, NULL, NULL, NULL&#41;;
	if &#40;png_ptr == NULL&#41; 
	&#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		pspDebugScreenPrintf&#40;"png_ptr == NULL\n"&#41;;
		return NULL;
	&#125;
	png_set_error_fn&#40;png_ptr, &#40;png_voidp&#41; NULL, &#40;png_error_ptr&#41; NULL, user_warning_fn&#41;;
	info_ptr = png_create_info_struct&#40;png_ptr&#41;;
	if &#40;info_ptr == NULL&#41; 
	&#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		pspDebugScreenPrintf&#40;"info_ptr == NULL\n"&#41;;
		return NULL;
	&#125;
	png_init_io&#40;png_ptr, fp&#41;;
	png_set_sig_bytes&#40;png_ptr, sig_read&#41;;
	png_read_info&#40;png_ptr, info_ptr&#41;;
	png_get_IHDR&#40;png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL&#41;;
	if &#40;width > 512 || height > 512&#41; 
	&#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		pspDebugScreenPrintf&#40;"Image exceeds 512x515\n"&#41;;
		return NULL;
	&#125;
	image->imageWidth = width;
	image->imageHeight = height;
	image->textureWidth = getNextPower2&#40;width&#41;;
	image->textureHeight = getNextPower2&#40;height&#41;;
	png_set_strip_16&#40;png_ptr&#41;;
	png_set_packing&#40;png_ptr&#41;;
	if &#40;color_type == PNG_COLOR_TYPE_PALETTE&#41; png_set_palette_to_rgb&#40;png_ptr&#41;;
	if &#40;color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8&#41; png_set_gray_1_2_4_to_8&#40;png_ptr&#41;;
	if &#40;png_get_valid&#40;png_ptr, info_ptr, PNG_INFO_tRNS&#41;&#41; png_set_tRNS_to_alpha&#40;png_ptr&#41;;
	png_set_filler&#40;png_ptr, 0xff, PNG_FILLER_AFTER&#41;;
	image->data = &#40;Color*&#41; memalign&#40;16, image->textureWidth * image->textureHeight * sizeof&#40;Color&#41;&#41;;
	if &#40;!image->data&#41; 
	&#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		pspDebugScreenPrintf&#40;"!image->data\n"&#41;;
		return NULL;
	&#125;
	line = &#40;u32*&#41; malloc&#40;width * 4&#41;;
	if &#40;!line&#41; 
	&#123;
		free&#40;image->data&#41;;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		pspDebugScreenPrintf&#40;"!line\n"&#41;;
		return NULL;
	&#125;
	for &#40;y = 0; y < height; y++&#41; &#123;
		png_read_row&#40;png_ptr, &#40;u8*&#41; line, png_bytep_NULL&#41;;
		for &#40;x = 0; x < width; x++&#41; &#123;
			u32 color = line&#91;x&#93;;
			image->data&#91;x + y * image->textureWidth&#93; =  color;
		&#125;
	&#125;
	free&#40;line&#41;;
	png_read_end&#40;png_ptr, info_ptr&#41;;
	png_destroy_read_struct&#40;&png_ptr, &info_ptr, png_infopp_NULL&#41;;
	fclose&#40;fp&#41;;
	return image;
&#125;
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

ok, here is my main.c now, it prints the error code to the screen and menu still returns "0", BUT it seems that right after it does so, the memstick flashes as if its trying to load something up. Im tired and i have work tomorrow, so ima relook over my whole code and check again tomorrow when i get off work, im too tired right now.

main.c

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudiolib.h>
#include <pspaudio.h>
#include <psppower.h>
#include <stdio.h>
#include <pspgu.h>
// #include <math.h>
// #include <string.h>

#include "framebuffer.h"
#include "main.h"
#include "graphics.h"
#include "mp3player.h"

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO&#40;"deathcore", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;&#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 thread id */
int SetupCallbacks&#40;void&#41; &#123;
	int thid = 0;
	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;
// draws the menu.png to the screen
int SetupMenuBG&#40;void&#41;&#123;

char buff&#91;200&#93;;
Image* menu;

sprintf&#40;buff, "menu.png"&#41;;
menu = loadImage&#40;buff&#41;;

if&#40;!menu&#41;
	&#123;
	pspDebugScreenClear&#40;&#41;;
	pspDebugScreenSetTextColor&#40;0xFF9900&#41;;
	printf&#40;"error upon displaying image\n"&#41;;
	printf&#40;"%d", menu&#41;;
	&#125;
else
	&#123;
	blitImageToScreen&#40;0, 0, 480, 272, menu, 0, 0&#41;;
	sceDisplayWaitVblankStart&#40;&#41;;
	flipScreen&#40;&#41;;
	&#125;
&#125;

int Music_player&#40;char* fileName&#41;
&#123;
	MP3_Init&#40;1&#41;;
	MP3_Load&#40;fileName&#41;;
	MP3_Play&#40;&#41;;
	return *fileName;
&#125;


int main&#40;&#41;
&#123;
scePowerSetClockFrequency&#40;333, 333, 166&#41;;

SetupCallbacks;
pspDebugScreenInit&#40;&#41;;
initGraphics&#40;&#41;;

//pspAudioInit&#40;&#41;;
//Music_player&#40;"menu.mp3"&#41;;

pspDebugScreenSetXY&#40;25, 0&#41;;
pspDebugScreenSetTextColor&#40;0xFF9900&#41;;	// orange or red-orange
printf&#40;"<--DeathCore_V1.0 By Rangu2057-->"&#41;;

pspDebugScreenSetXY&#40;25, 5&#41;;
printf&#40;"New Game"&#41;;

pspDebugScreenSetXY&#40;25, 8&#41;;
printf&#40;"Load Save"&#41;;

pspDebugScreenSetXY&#40;25, 11&#41;;
printf&#40;"Options"&#41;;

pspDebugScreenSetXY&#40;25, 14&#41;;
printf&#40;"Credits"&#41;;

/*
switch &#40;current&#41; &#123;
	case 0&#58;
	pspDebugScreenSetXY&#40;20, 5&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	case 1&#58;
	pspDebugScreenSetXY&#40;20, 8&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	case 2&#58;
	pspDebugScreenSetXY&#40;20, 11&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	case 3&#58;
	pspDebugScreenSetXY&#40;20, 14&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	&#125;
*/


while&#40;1&#41;&#123;
	SetupMenuBG&#40;&#41;;

	SceCtrlData pad;
	sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

if&#40;pad.Buttons & PSP_CTRL_DOWN&#41;
	&#123;
	current += 1;
	&#125;
if&#40;pad.Buttons & PSP_CTRL_UP&#41;
	&#123;
	current -= 1;
	&#125;
if&#40;pad.Buttons & PSP_CTRL_HOME&#41;
	&#123;
	sceKernelExitGame&#40;&#41;;
	&#125;
&#125;
&#125;
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

nvm, i managed to compile it, but for some reason menu keeps returning 0, i had decided to put everything in the MAIN function to reduce the complexity, but it seems like nothing is working, any more suggestions?

If you would like the full source, and the compiled eboot itself?

btw, i compiled it for 3xx kernel

main.c

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudiolib.h>
#include <pspaudio.h>
#include <psppower.h>
#include <stdio.h>
#include <pspgu.h>
// #include <math.h>
// #include <string.h>

#include "framebuffer.h"
#include "main.h"
#include "graphics.h"
#include "mp3player.h"

#define printf pspDebugScreenPrintf
#define &#40;r, g, b&#41; &#40;&#40;r&#41;|&#40;&#40;g&#41;<<8&#41;|&#40;&#40;b&#41;<<16&#41;&#41;
#define MAX&#40;x, y&#41; &#40;&#40;x&#41; > &#40;y&#41; ? &#40;x&#41; &#58; &#40;y&#41;&#41;

PSP_MODULE_INFO&#40;"deathcore", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;&#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 thread id */
int SetupCallbacks&#40;void&#41; &#123;
	int thid = 0;
	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;
char buff&#91;200&#93;;
Image* menu;

const char curse = '&#93;--->';

pspDebugScreenInit&#40;&#41;;
SetupCallbacks;
initGraphics&#40;&#41;;

sprintf&#40;buff, "menu.png"&#41;;
menu = loadImage&#40;buff&#41;;

if&#40;!menu&#41;
	&#123;
	pspDebugScreenClear&#40;&#41;;
	pspDebugScreenSetTextColor&#40;0xFF9900&#41;;
	printf&#40;"error upon displaying image\n"&#41;;
	printf&#40;"%d", menu&#41;;
	return -1;
	&#125;
else
	&#123;
	int x = 0;
	int y = 0;
	sceDisplayWaitVblankStart&#40;&#41;;
		&#123;
		while&#40;x < 480 && y < 272&#41;
			&#123;
			blitImageToScreen&#40;0, 0, 480, 272, menu, 0, 0&#41;;
			&#125;
		flipScreen&#40;&#41;;
		&#125;
	sceKernelSleepThread&#40;&#41;;
	return 0;
	&#125;

scePowerSetClockFrequency&#40;333, 333, 166&#41;;
MP3_Init&#40;1&#41;;
MP3_Load&#40;"menu.mp3"&#41;;
MP3_Play&#40;&#41;;

pspAudioInit&#40;&#41;;
//Music_player&#40;"menu.mp3"&#41;;

pspDebugScreenSetXY&#40;25, 0&#41;;
pspDebugScreenSetTextColor&#40;0xFF9900&#41;;	// orange or red-orange
printf&#40;"<--DeathCore_V1.0 By Rangu2057-->"&#41;;

pspDebugScreenSetXY&#40;25, 5&#41;;
printf&#40;"New Game"&#41;;

pspDebugScreenSetXY&#40;25, 8&#41;;
printf&#40;"Load Save"&#41;;

pspDebugScreenSetXY&#40;25, 11&#41;;
printf&#40;"Options"&#41;;

pspDebugScreenSetXY&#40;25, 14&#41;;
printf&#40;"Credits"&#41;;

while&#40;1&#41;&#123;
	SceCtrlData pad;
	sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
	int current = 0;

if&#40;pad.Buttons & PSP_CTRL_DOWN&#41;
	&#123;
	if&#40;current > 3&#41;
		&#123;
		current = 0;
		current ++;
switch &#40;current&#41; &#123;
	case 0&#58;
	pspDebugScreenSetXY&#40;20, 5&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 1&#58;
	pspDebugScreenSetXY&#40;20, 8&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 2&#58;
	pspDebugScreenSetXY&#40;20, 11&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 3&#58;
	pspDebugScreenSetXY&#40;20, 14&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	default&#58;
	break;
	&#125;

		&#125;
	&#125;
else if&#40;pad.Buttons & PSP_CTRL_UP&#41;
	&#123;
	if&#40;current < 0&#41;
		&#123;
		current = 3;
		current --;
switch &#40;current&#41; &#123;
	case 0&#58;
	pspDebugScreenSetXY&#40;20, 5&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 1&#58;
	pspDebugScreenSetXY&#40;20, 8&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 2&#58;
	pspDebugScreenSetXY&#40;20, 11&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 3&#58;
	pspDebugScreenSetXY&#40;20, 14&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	default&#58;
	break;
			&#125;
		&#125;

if&#40;pad.Buttons & PSP_CTRL_HOME&#41;
	&#123;
	sceKernelExitGame&#40;&#41;;
	&#125;

if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
	&#123;
	break;
	&#125;
else if&#40;pad.Buttons & PSP_CTRL_CROSS&#41;
	&#123;
	MP3_Pause&#40;&#41;;
	&#125;

if&#40;MP3_EndOfStream&#40;&#41; == 1&#41;
	&#123;
	MP3_Stop&#40;&#41;;
	&#125;
&#125;
&#125;
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
BobJelly
Posts: 3
Joined: Tue Nov 20, 2007 10:50 am

Post by BobJelly »

Have you modified loadImage like GORETHRASHER suggested ? With his code, you should be able to seen why loadImage keeps failing.

This code won't give you much info:
printf("error upon displaying image\n");
printf("%d", menu);

Since you already know that menu is NULL ;)

Good luck!
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

yes, i have done it the way that GORETH said but it didnt work, so i tried to come up with another method of getting it to load by changing

if(!menu) to if(menu < 0)

and after that i did a "else if(menu > 0)" (do all the image blitting, etc..)

after using that method, the only thing that came up on my screen was this:

"!image->data"

comes up on the screen and then as soon as it comes up, you can hear a popping sound and the psp automatically shuts off

maybe it might be something wrong with my makefile?

makefile:

Code: Select all

TARGET = DeathCore_V1.0
OBJS = framebuffer.o graphics.o mp3player.o main.o

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


BUILD_PRX=1
#PSP_FW_VERSION=390

PSP_EBOOT_ICON= icon0.png
#PSP_EBOOT_PIC1 = pspwrite-pic.png
#PSP_EBOOT_SND0  =


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

LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = DeathCore_V1.0
PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

libpng needs a heap. Declare PSP_HEAP_SIZE_MAX(); or PSP_HEAP_SIZE_KB(.....) in your program.

And you can't read the Home button from a user mode program. You need to make and load a kernel mode PRX which uses the kernel mode ctrl functions to read the Home button, and check with the PRX from your main program code.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

alright, i recompiled it setting up the heap size and since you told me i had to make and load a kernel mode prx, i just went ahead and compiled this version for 150, i already know that 3xx is the kernel mode i should be building my apps in, but i built it in 150 this time just to make sure my sdk is set up right (as far playing music and showing pictures goes as i want to make sure everything is running correctly), so if you want to test it out here is the link

DeathCorev1.0 build 15x
http://www.megaupload.com/?d=NY7OO8SN

@note -> remember this is just a test build to make sure graphics and music runs properly, so dont flame me. I dont feel like doing all that stuff to make it work for 3xx kernel if the graphics and music doesnt play properly, so yea...

also thanks for all your help guys :)
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You don't seem to understand - if you run in kernel mode (1.50 mode), you can read the Home key directly. Loading a kernel mode prx is only needed if you're running a 3.xx/4.xx USER mode app.

If this is just for yourself, 1.50 is acceptable, but if you plan to have people run this, 1.50 software is unacceptable these days given the number of Slim users. Anyone working on something for general release MUST be working on 3.xx/4.xx.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

for my general release i do plan have it in 3xx kernel, and it will have many features as well, but what im trying to say is that i read somewhere that you can run everything normally if you put BUILD_PRX=1 in your makefile and everything will be fine

also im sorry to be a bother but can you explain how its in user mode, im kinda new to this stuff
Last edited by Rangu2057 on Sat Sep 20, 2008 8:14 am, edited 2 times in total.
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Rangu2057 wrote:for my general release i do plan have it in 3xx kernel, and it will have many features as well, but what im trying to say is that i read somewhere that you can run everything normally if you put BUILD_PRX=1 in your makefile and everything will be fine

also im sorry to be a bother but can you explain how its in user mode, im kinda new to this stuff

Code: Select all

PSP_MODULE_INFO&#40;"BasiliskII", 0, PSP_VERS, PSP_REVS&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;
PSP_HEAP_SIZE_KB&#40;-256&#41;;
That sets your program as user mode with a heap size equal to all the memory minus 256KB. Add PSP_THREAD_ATTR_VFPU if you use the VFPU. If you need to load kernel mode PRX libraries to do things like read the Home button or use the ME, you need to make the app a PRX as well by setting BUILD_PRX=1 in the makefile. 3.xx/4.xx runs user mode apps that are either PRXs or not, but only PRXs can load kernel mode PRXs. So the BUILD_PRX=1 is only dependent on whether or not you use other PRXs - the three most common being to read the Home button, use the ME, and to use the TV output.

Note that if you use the SDL I posted in another thread with automatic TV support, your program MUST be a 3.xx/4.xx user mode PRX or it won't work since that version of SDL tries to load/start the TV support prx.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

alright, thanks for all the help here is my code now, and i got my image to show up, but my text doesnt show up, and neither does my mp3. btw when loading a mp3 does it have to be a certain sampling frequency or something?

main stuff

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudiolib.h>
#include <pspaudio.h>
#include <psppower.h>
#include <stdio.h>
#include <pspgu.h>
// #include <math.h>
// #include <string.h>

#include "framebuffer.h"
#include "main.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;

PSP_MODULE_INFO&#40;"deathcore", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_VFPU&#41;;
PSP_HEAP_SIZE_KB&#40;10*1024&#41;;

#define printf pspDebugScreenPrintf
main.c

Code: Select all

int main&#40;&#41;
&#123;

char buffer&#91;200&#93;;
Image* menu;

const char curse = '&#93;--->';

pspDebugScreenInit&#40;&#41;;
SetupCallbacks;
initGraphics&#40;&#41;;

sprintf&#40;buffer, "menu.png"&#41;;
menu = loadImage&#40;buffer&#41;;

if&#40;!menu&#41;
	&#123;
	pspDebugScreenClear&#40;&#41;;
	pspDebugScreenSetTextColor&#40;0xFF9900&#41;;
	printf&#40;"error upon displaying image\n"&#41;;
	printf&#40;"%d", menu&#41;;
	return -1;
	&#125;
else
	&#123;
	int picx = 480;
	int picy = 272;
	sceDisplayWaitVblankStart&#40;&#41;;
		&#123;
		while&#40;picx == 480 && picy == 272&#41;
			&#123;
			blitImageToScreen&#40;0, 0, picx, picy, menu, 0, 0&#41;;
			flipScreen&#40;&#41;;
			&#125;
		&#125;
	sceKernelSleepThread&#40;&#41;;
	return 0;
	&#125;

scePowerSetClockFrequency&#40;333, 333, 166&#41;;
pspAudioInit&#40;&#41;;
MP3_Init&#40;1&#41;;
MP3_Load&#40;"menu.mp3"&#41;;

if&#40;!MP3_Load&#40;"menu.mp3"&#41;&#41;
	&#123;
	printf&#40;"error playing menu.mp3..."&#41;;
	&#125;
else
	&#123;
	MP3_Play&#40;&#41;;
	&#125;

pspDebugScreenSetXY&#40;25, 0&#41;;
pspDebugScreenSetTextColor&#40;0xFF9900&#41;;	// orange or red-orange
printf&#40;"<--DeathCore_V1.0 By Rangu2057-->"&#41;;

pspDebugScreenSetXY&#40;20, 5&#41;;
pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// orange or red-orange
printf&#40;"&#93;--->"&#41;;

pspDebugScreenSetXY&#40;25, 5&#41;;
printf&#40;"New Game"&#41;;

pspDebugScreenSetXY&#40;25, 8&#41;;
printf&#40;"Load Save"&#41;;

pspDebugScreenSetXY&#40;25, 11&#41;;
printf&#40;"Options"&#41;;

pspDebugScreenSetXY&#40;25, 14&#41;;
printf&#40;"Credits"&#41;;

while&#40;1&#41;&#123;
	SceCtrlData pad;
	sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
	int current = 0;

if&#40;pad.Buttons & PSP_CTRL_DOWN&#41;
	&#123;
	if&#40;current > 3&#41;
		&#123;
		current = 0;
		current ++;
switch &#40;current&#41; &#123;
	case 0&#58;
	pspDebugScreenSetXY&#40;20, 5&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 1&#58;
	pspDebugScreenSetXY&#40;20, 8&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 2&#58;
	pspDebugScreenSetXY&#40;20, 11&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 3&#58;
	pspDebugScreenSetXY&#40;20, 14&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	default&#58;
	break;
	&#125;

		&#125;
	&#125;
else if&#40;pad.Buttons & PSP_CTRL_UP&#41;
	&#123;
	if&#40;current < 0&#41;
		&#123;
		current = 3;
		current --;
switch &#40;current&#41; &#123;
	case 0&#58;
	pspDebugScreenSetXY&#40;20, 5&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 1&#58;
	pspDebugScreenSetXY&#40;20, 8&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 2&#58;
	pspDebugScreenSetXY&#40;20, 11&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	case 3&#58;
	pspDebugScreenSetXY&#40;20, 14&#41;;
	pspDebugScreenSetTextColor&#40;0x28AE7B&#41;;	// emerald
	printf&#40;"&#93;--->"&#41;;
	break;
	default&#58;
	break;
			&#125;
		&#125;
	&#125;

&#125;
&#125;
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

If you use the graphics functions, you need to re-init the debug printing to see any text afterwards. The two aren't compatible with each other - you have to do the init for each every time you switch between them. MP3s on the PSP should be 44100 Hz.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

ok, i reinited using pspDebugScreenInit(); right after the if function that checks to see if the image is loaded, but the text doesnt show up still, i dont think anything should be going wrong here, also my mp3 file is equivalent to that of 44100 Hz, but no progress so far, what else am i doing wrong here?
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

if(!menu)
{
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF9900);
printf("error upon displaying image\n");
printf("%d", menu);
return -1;
}
else
{
int picx = 480;
int picy = 272;
sceDisplayWaitVblankStart();
{
while(picx == 480 && picy == 272)
{
blitImageToScreen(0, 0, picx, picy, menu, 0, 0);
flipScreen();
}
}
sceKernelSleepThread();
return 0;
}
What are you doing?...lawl
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

using that method was the only one that worked as far as getting the image displayed, i realized what i was doing wrong before, and like i said, the only other problems is the text and the music. I re-inited the debug printing and my mp3 file is exactly 41000Hz, so im not sure what the problem is. If you feel that my method displaying the image could be done better Posx100, then please correct me
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

If you can't figure out what's wrong with this block of code:

Code: Select all

int picx = 480;
int picy = 272;
sceDisplayWaitVblankStart&#40;&#41;;
&#123; 
PING? while&#40;picx == 480 && picy == 272&#41;
&#123;
blitImageToScreen&#40;0, 0, picx, picy, menu, 0, 0&#41;;
flipScreen&#40;&#41;;
&#125;PONG? 
&#125;
PING?sceKernelSleepThread&#40;&#41;; PONG?
PING^PING!return 0; PONG?
Then no one can't really help you. You should learn the basics first...

Just a hint :

Code: Select all

if&#40;!menu&#41;
   &#123;
   pspDebugScreenClear&#40;&#41;;
   pspDebugScreenSetTextColor&#40;0xFF9900&#41;;
   printf&#40;"error upon displaying image\n"&#41;;
   printf&#40;"%d", menu&#41;;
   return 1;
   &#125;
///
/*
///
else
   &#123;
   int picx = 480;
   int picy = 272;
   sceDisplayWaitVblankStart&#40;&#41;;
      &#123;
      while&#40;picx == 480 && picy == 272&#41;
         &#123;
         blitImageToScreen&#40;0, 0, picx, picy, menu, 0, 0&#41;;
         flipScreen&#40;&#41;;
         &#125;
      &#125;
   sceKernelSleepThread&#40;&#41;;
   return 0;
   &#125; 

///
*/
///
while running :

blit menu image , print stuff , flip screen...
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

uhm, i already know the basics, i usually code utility apps and such for the pc basically, and im new to the psp. Also, i did as you said, the first attempt with bliting the image, then printing the text, the screen and text flickered on and off. The second time, the text didnt show up. What else can i do?
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

uhm, i already know the basics
No , you don't.

You should know that your program will never pass this block of code:

Code: Select all

if&#40;!menu&#41;
   &#123;
   pspDebugScreenClear&#40;&#41;;
   pspDebugScreenSetTextColor&#40;0xFF9900&#41;;
   printf&#40;"error upon displaying image\n"&#41;;
   printf&#40;"%d", menu&#41;;
   return -1;
   &#125;
else
   &#123;
   int picx = 480;
   int picy = 272;
   sceDisplayWaitVblankStart&#40;&#41;;
      &#123;
      while&#40;picx == 480 && picy == 272&#41;
         &#123;
         blitImageToScreen&#40;0, 0, picx, picy, menu, 0, 0&#41;;
         flipScreen&#40;&#41;;
         &#125;
      &#125;
   sceKernelSleepThread&#40;&#41;;
   return 0;
   &#125; 
a = If image pointer is null the following code will be executed:

Code: Select all

   &#123;
   pspDebugScreenClear&#40;&#41;;
   pspDebugScreenSetTextColor&#40;0xFF9900&#41;;
   printf&#40;"error upon displaying image\n"&#41;;
   printf&#40;"%d", menu&#41;;
   return -1;
   &#125;
ELSE

Code: Select all

   &#123;
   int picx = 480;
   int picy = 272;
   sceDisplayWaitVblankStart&#40;&#41;;
      &#123;
      while&#40;picx == 480 && picy == 272&#41;
         &#123;
         blitImageToScreen&#40;0, 0, picx, picy, menu, 0, 0&#41;;
         flipScreen&#40;&#41;;
         &#125;
      &#125;
   sceKernelSleepThread&#40;&#41;;
   return 0;
   &#125; 

{
LOOP FOR EVER SINCE PIC X & Y WILL ALWAYS BE 480,272
IF A MIRACLE HAPPENS ,AND SOMEHOW JUMP OUT OF THE LOOP THE PROGRAM WILL
EXIT IMMEDIATELY ( sceKernelSleepThread(),RETURN 0; )
}

( Sorry for the CAPS )
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Rangu2057 wrote:uhm, i already know the basics, i usually code utility apps and such for the pc basically, and im new to the psp. Also, i did as you said, the first attempt with bliting the image, then printing the text, the screen and text flickered on and off. The second time, the text didnt show up. What else can i do?
He meant the basics in making games. None of your questions have ANYTHING to do with the PSP, and everything to do with not knowing anything about making games. Your code is also fairly low-quality, even for utilities.

You might try doing this on a PC first, THEN come back to the PSP. The PSP is not a good platform to learn on.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

ok, i realized what posx said, so i redid it, and now the pic displays, and the text shows up as well, so far everythings going well with it
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Post Reply