 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Wed Sep 17, 2008 12:48 pm Post subject: help with my homebrew |
|
|
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: |
#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("deathcore", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback() {
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, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int SetupMenuBG(){
char buff[200];
Image* menu;
pspDebugScreenInit();
sprintf(buff, "menu.png");
menu = loadImage(buff);
if(!menu)
{
pspDebugScreenClear();
printf("error upon displaying image\n");
printf("Autoexiting...");
sceKernelSleepThread();
}
else
{
sceDisplayWaitVblankStart();
blitImageToScreen(0, 0, 480, 272, menu, 0, 0);
flipScreen();
sceKernelSleepThread();
}
return 0;
}
int Music_player(char* fileName)
{
MP3_Init(1);
MP3_Load(fileName);
MP3_Play();
return *fileName;
}
int main(){
SceCtrlData pad;
pspDebugScreenInit();
initGraphics();
SetupCallbacks;
SetupMenuBG();
pspAudioInit();
Music_player("menu.mp3");
pspDebugScreenSetXY(25, 0);
pspDebugScreenSetTextColor(0xFF9900); // orange or red-orange
printf("<--DeathCore_V1.0 By Rangu2057-->");
pspDebugScreenSetXY(25, 5);
printf("New Game");
pspDebugScreenSetXY(25, 8);
printf("Load Save");
pspDebugScreenSetXY(25, 11);
printf("Options");
pspDebugScreenSetXY(25, 14);
printf("Credits");
int current = 0;
return current;
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
}
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_DOWN)
{
current += 1;
}
if(pad.Buttons & PSP_CTRL_UP)
{
current -= 1;
}
if(pad.Buttons & PSP_CTRL_HOME)
{
sceKernelExitGame();
}
}
}
|
_________________ the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2) |
|
| Back to top |
|
 |
GORETHRASHER
Joined: 10 Sep 2008 Posts: 12
|
Posted: Wed Sep 17, 2008 1:06 pm Post subject: |
|
|
| Code: | int current = 0;
return current; |
return current; |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Wed Sep 17, 2008 1:27 pm Post subject: |
|
|
nope still nothing, i got the feeling that i set something to always true so
| Code: |
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) |
|
| Back to top |
|
 |
GORETHRASHER
Joined: 10 Sep 2008 Posts: 12
|
Posted: Wed Sep 17, 2008 3:14 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Wed Sep 17, 2008 3:26 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
GORETHRASHER
Joined: 10 Sep 2008 Posts: 12
|
Posted: Wed Sep 17, 2008 4:24 pm Post subject: |
|
|
Since you say that menu is always 0, then loadImage is failing.
You can modify loadImage to print error messages
| Code: | Image* loadImage(const char* filename)
{
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 = (Image*) malloc(sizeof(Image));
if (!image) return NULL;
if ((fp = fopen(filename, "rb")) == NULL)
{
pspDebugScreenPrintf("cannot open file: %s\n", filename );
return NULL;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL)
{
free(image);
fclose(fp);
pspDebugScreenPrintf("png_ptr == NULL\n");
return NULL;
}
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, user_warning_fn);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
pspDebugScreenPrintf("info_ptr == NULL\n");
return NULL;
}
png_init_io(png_ptr, fp);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL);
if (width > 512 || height > 512)
{
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
pspDebugScreenPrintf("Image exceeds 512x515\n");
return NULL;
}
image->imageWidth = width;
image->imageHeight = height;
image->textureWidth = getNextPower2(width);
image->textureHeight = getNextPower2(height);
png_set_strip_16(png_ptr);
png_set_packing(png_ptr);
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
image->data = (Color*) memalign(16, image->textureWidth * image->textureHeight * sizeof(Color));
if (!image->data)
{
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
pspDebugScreenPrintf("!image->data\n");
return NULL;
}
line = (u32*) malloc(width * 4);
if (!line)
{
free(image->data);
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
pspDebugScreenPrintf("!line\n");
return NULL;
}
for (y = 0; y < height; y++) {
png_read_row(png_ptr, (u8*) line, png_bytep_NULL);
for (x = 0; x < width; x++) {
u32 color = line[x];
image->data[x + y * image->textureWidth] = color;
}
}
free(line);
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
return image;
} |
|
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Wed Sep 17, 2008 4:56 pm Post subject: |
|
|
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: |
#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("deathcore", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback() {
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, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
// draws the menu.png to the screen
int SetupMenuBG(void){
char buff[200];
Image* menu;
sprintf(buff, "menu.png");
menu = loadImage(buff);
if(!menu)
{
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF9900);
printf("error upon displaying image\n");
printf("%d", menu);
}
else
{
blitImageToScreen(0, 0, 480, 272, menu, 0, 0);
sceDisplayWaitVblankStart();
flipScreen();
}
}
int Music_player(char* fileName)
{
MP3_Init(1);
MP3_Load(fileName);
MP3_Play();
return *fileName;
}
int main()
{
scePowerSetClockFrequency(333, 333, 166);
SetupCallbacks;
pspDebugScreenInit();
initGraphics();
//pspAudioInit();
//Music_player("menu.mp3");
pspDebugScreenSetXY(25, 0);
pspDebugScreenSetTextColor(0xFF9900); // orange or red-orange
printf("<--DeathCore_V1.0 By Rangu2057-->");
pspDebugScreenSetXY(25, 5);
printf("New Game");
pspDebugScreenSetXY(25, 8);
printf("Load Save");
pspDebugScreenSetXY(25, 11);
printf("Options");
pspDebugScreenSetXY(25, 14);
printf("Credits");
/*
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
}
*/
while(1){
SetupMenuBG();
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_DOWN)
{
current += 1;
}
if(pad.Buttons & PSP_CTRL_UP)
{
current -= 1;
}
if(pad.Buttons & PSP_CTRL_HOME)
{
sceKernelExitGame();
}
}
}
|
_________________ the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2) |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Thu Sep 18, 2008 12:34 pm Post subject: |
|
|
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: |
#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 (r, g, b) ((r)|((g)<<8)|((b)<<16))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
PSP_MODULE_INFO("deathcore", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback() {
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, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main()
{
char buff[200];
Image* menu;
const char curse = ']--->';
pspDebugScreenInit();
SetupCallbacks;
initGraphics();
sprintf(buff, "menu.png");
menu = loadImage(buff);
if(!menu)
{
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF9900);
printf("error upon displaying image\n");
printf("%d", menu);
return -1;
}
else
{
int x = 0;
int y = 0;
sceDisplayWaitVblankStart();
{
while(x < 480 && y < 272)
{
blitImageToScreen(0, 0, 480, 272, menu, 0, 0);
}
flipScreen();
}
sceKernelSleepThread();
return 0;
}
scePowerSetClockFrequency(333, 333, 166);
MP3_Init(1);
MP3_Load("menu.mp3");
MP3_Play();
pspAudioInit();
//Music_player("menu.mp3");
pspDebugScreenSetXY(25, 0);
pspDebugScreenSetTextColor(0xFF9900); // orange or red-orange
printf("<--DeathCore_V1.0 By Rangu2057-->");
pspDebugScreenSetXY(25, 5);
printf("New Game");
pspDebugScreenSetXY(25, 8);
printf("Load Save");
pspDebugScreenSetXY(25, 11);
printf("Options");
pspDebugScreenSetXY(25, 14);
printf("Credits");
while(1){
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
int current = 0;
if(pad.Buttons & PSP_CTRL_DOWN)
{
if(current > 3)
{
current = 0;
current ++;
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
default:
break;
}
}
}
else if(pad.Buttons & PSP_CTRL_UP)
{
if(current < 0)
{
current = 3;
current --;
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
default:
break;
}
}
if(pad.Buttons & PSP_CTRL_HOME)
{
sceKernelExitGame();
}
if(pad.Buttons & PSP_CTRL_CIRCLE)
{
break;
}
else if(pad.Buttons & PSP_CTRL_CROSS)
{
MP3_Pause();
}
if(MP3_EndOfStream() == 1)
{
MP3_Stop();
}
}
}
|
_________________ the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2) |
|
| Back to top |
|
 |
BobJelly
Joined: 20 Nov 2007 Posts: 3
|
Posted: Thu Sep 18, 2008 2:13 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Thu Sep 18, 2008 2:36 pm Post subject: |
|
|
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: |
TARGET = DeathCore_V1.0
OBJS = framebuffer.o graphics.o mp3player.o main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
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=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
_________________ the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2) |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Fri Sep 19, 2008 12:32 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Sat Sep 20, 2008 4:41 am Post subject: |
|
|
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) |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Sep 20, 2008 5:12 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Sat Sep 20, 2008 5:51 am Post subject: |
|
|
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 _________________ the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Last edited by Rangu2057 on Sat Sep 20, 2008 8:14 am; edited 2 times in total |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Sep 20, 2008 7:57 am Post subject: |
|
|
| 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: | PSP_MODULE_INFO("BasiliskII", 0, PSP_VERS, PSP_REVS);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-256);
|
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. |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Sat Sep 20, 2008 8:28 am Post subject: |
|
|
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: |
#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(x, y) ((x) > (y) ? (x) : (y))
PSP_MODULE_INFO("deathcore", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_KB(10*1024);
#define printf pspDebugScreenPrintf
|
main.c
| Code: |
int main()
{
char buffer[200];
Image* menu;
const char curse = ']--->';
pspDebugScreenInit();
SetupCallbacks;
initGraphics();
sprintf(buffer, "menu.png");
menu = loadImage(buffer);
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;
}
scePowerSetClockFrequency(333, 333, 166);
pspAudioInit();
MP3_Init(1);
MP3_Load("menu.mp3");
if(!MP3_Load("menu.mp3"))
{
printf("error playing menu.mp3...");
}
else
{
MP3_Play();
}
pspDebugScreenSetXY(25, 0);
pspDebugScreenSetTextColor(0xFF9900); // orange or red-orange
printf("<--DeathCore_V1.0 By Rangu2057-->");
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // orange or red-orange
printf("]--->");
pspDebugScreenSetXY(25, 5);
printf("New Game");
pspDebugScreenSetXY(25, 8);
printf("Load Save");
pspDebugScreenSetXY(25, 11);
printf("Options");
pspDebugScreenSetXY(25, 14);
printf("Credits");
while(1){
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
int current = 0;
if(pad.Buttons & PSP_CTRL_DOWN)
{
if(current > 3)
{
current = 0;
current ++;
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
default:
break;
}
}
}
else if(pad.Buttons & PSP_CTRL_UP)
{
if(current < 0)
{
current = 3;
current --;
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
break;
default:
break;
}
}
}
}
}
|
_________________ the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2) |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Sep 20, 2008 11:03 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Sat Sep 20, 2008 2:23 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sat Sep 20, 2008 2:58 pm Post subject: |
|
|
| Quote: |
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 |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Sat Sep 20, 2008 4:30 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sun Sep 21, 2008 12:47 am Post subject: |
|
|
If you can't figure out what's wrong with this block of code:
| Code: |
int picx = 480;
int picy = 272;
sceDisplayWaitVblankStart();
{
PING? while(picx == 480 && picy == 272)
{
blitImageToScreen(0, 0, picx, picy, menu, 0, 0);
flipScreen();
}PONG?
}
PING?sceKernelSleepThread(); PONG?
PING^PING!return 0; PONG?
|
Then no one can't really help you. You should learn the basics first...
Just a hint :
| Code: |
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;
}
///
*/
///
|
while running :
blit menu image , print stuff , flip screen... |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Sun Sep 21, 2008 2:32 am Post subject: |
|
|
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) |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sun Sep 21, 2008 4:25 am Post subject: |
|
|
| Quote: | | uhm, i already know the basics |
No , you don't.
You should know that your program will never pass this block of code:
| Code: |
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;
}
|
a = If image pointer is null the following code will be executed:
| Code: |
{
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF9900);
printf("error upon displaying image\n");
printf("%d", menu);
return -1;
}
|
ELSE
| Code: |
{
int picx = 480;
int picy = 272;
sceDisplayWaitVblankStart();
{
while(picx == 480 && picy == 272)
{
blitImageToScreen(0, 0, picx, picy, menu, 0, 0);
flipScreen();
}
}
sceKernelSleepThread();
return 0;
}
|
{
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 ) |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Sep 21, 2008 5:59 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Rangu2057
Joined: 23 Jul 2007 Posts: 87 Location: wilmington, NC
|
Posted: Mon Sep 22, 2008 5:55 am Post subject: |
|
|
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) |
|
| Back to top |
|
 |
|
|
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
|