QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Newbie Homebrewer, a weird crash! plz explain!

This is a discussion on Newbie Homebrewer, a weird crash! plz explain! within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hello All, first post meaning I give up trying to figure my problem out and outstretch my hand to the ...

Reply
 
LinkBack Thread Tools
Old 11-01-2006, 09:24 AM   #1
 
Join Date: Oct 2006
Posts: 6
Trader Feedback: 0
Question Newbie Homebrewer, a weird crash! plz explain!

Hello All, first post meaning I give up trying to figure my problem out and outstretch my hand to the wonderful coders on this form

Im developing the basics for a top down game that sorta looks like Zelda at this point. Im trying to go from my first hard coded 480x272 arena with walls 8 pixels long on each side to a dynamic system that would use a 2 dimensional array of ints to hold possible block values using this code:
//----code

int arena[480][272];
arena[0][0]=4;
/*
Alpha legend for arena
----------------------
0 will be blank
1 will be player
2 will be wall
3 will be gold
4 will be border(to be replaced by wall when I get array working)
*/
//-------endofcode

(Lots of setting up happens inbetween these two points, including lots of png loads and object coordinates)


This is where the error happens:
//-------morecode
arena[xPlayerCoord][yPlayerCoord]=1;
arena[xTargetCoord][yTargetCoord]=3;
/*if this 'if' executes, psp crashes*/ if (arena[0][0]==ARENA_BORDER){
/*if it is commented out, no crash occurs*/
/*the code in this if is vital to my game's growth*/
}
//------endofmorecode


Why is it that I can put values into arena, but if that if statement is allowed to happen it crashes the psp? It boggles my mind.
Help me forum heroes, your my only hope!
TheFool is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-01-2006, 10:24 AM   #2

PSP Developer
 
alatnet's Avatar
 
Join Date: Oct 2005
Real First Name: Alex
Location: ~* Confidential *~
Just Played: N/A
Posts: 839
Trader Feedback: 0
Default

did you define ARENA_BOARDER?
__________________

"Every team needs an idealistic person (whether they are a noob or a pro), my team doesn't have one cus im the idealistic founder."-me
Anime/Manga and Fanfiction is my inspiration!

Creator of:
- PSPSDK makefile creator - Lua Prompt - Animated Sprite Class\Library for Lua - Gmax2PSP -
alatnet is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-01-2006, 10:28 AM   #3
 
Join Date: Oct 2006
Posts: 6
Trader Feedback: 0
Default

Yes, Ive tried hard coding numbers such as 4 (ARENA BORDER). It is the arena[0][0] itself that hangs
TheFool is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-01-2006, 02:15 PM   #4

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

I am heavily assuming that this
Code:
arena[0][0]=4;
Is not written inside a function. If that's the case, you can't assign values to variables outside function scope unless it is done at the same time as you declare them.

eg
Code:
int Hello = 10; // fine
Hello = 54; // Not fine
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-02-2006, 09:42 AM   #5
 
Join Date: Oct 2006
Posts: 6
Trader Feedback: 0
Default In a function

This is actually all in the main function right now. so yes it is in a function, and the assigning(arena[0][0]=4) does not crash it, only in the if statement.
I got nothin
My new thoughts are just making structs and doing comparisons for collision detection instead of a degree. We will have to see
TheFool is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-02-2006, 09:51 AM   #6

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

In which case, I/We need to see more of your code.
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-02-2006, 08:00 PM   #7


Developer
 
JustChris's Avatar
 
Join Date: Oct 2005
Posts: 206
Trader Feedback: 0
Default

Is there any code inside the brackets of the if statment? Maybe by accident it's calling a function that loops endlessly if ARENA_BORDER isn't allowed to change inside that loop.
JustChris is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-03-2006, 05:03 PM   #8
 
JesusXP's Avatar
 
Join Date: Apr 2005
Location: Ontario, Canada
Posts: 34
Trader Feedback: 0
Default

plz post teh source
JesusXP is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-06-2006, 12:44 PM   #9
 
Join Date: Oct 2006
Posts: 6
Trader Feedback: 0
Default

/*
My base game for possible maze games or snake, etciu
*/
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include "graphics.h"

#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) argument 1 o: (Y))
#define pCross PSP_CTRL_CROSS
#define pCircle PSP_CTRL_CIRCLE
#define pSquare PSP_CTRL_SQUARE
#define pTriangle PSP_CTRL_CROSS
#define pUp PSP_CTRL_UP
#define pDown PSP_CTRL_DOWN
#define pLeft PSP_CTRL_LEFT
#define pRight PSP_CTRL_RIGHT
#define blockSize 8

int main() {
char buffer[200];
Image* ourImage;
Image* target;
Image* explosion;
Image* stage;
Image* wall;
int arena[480][272];

arena[0][0]=4;
/*
Alpha legend for arena
----------------------
0 will be blank
1 will be player
2 will be wall
3 will be gold
4 will be border(to be replaced by wall in future)
*/
SceCtrlData pad;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
sprintf(buffer, "stage.png");
stage = loadImage(buffer);
sprintf(buffer, "man.png");
ourImage = loadImage(buffer);
sprintf(buffer, "box.png");
target = loadImage(buffer);
sprintf(buffer, "explosion.png");
explosion = loadImage(buffer);
sprintf(buffer, "wall.png");
wall = loadImage(buffer);
if (!ourImage||!target||!sta ge||!explosion||!wall) {
printf("Image load failed!\n");
} else {
int xPlayerCoord = 0;
int buttonPressed=0;
int start=0;

int yPlayerCoord = 0;
int xTargetCoord = 0;
int yTargetCoord = 0;
sceDisplayWaitVblankStart ();
while(1){
buttonPressed=0;
xPlayerCoord=8;
yPlayerCoord=8;
xTargetCoord = ((rand() % 58)+1)*blockSize;
yTargetCoord = ((rand() % 32)+1)*blockSize;
while(start==0){
clearScreen(0);
arena[xPlayerCoord][yPlayerCoord]=1;
arena[xTargetCoord][yTargetCoord]=3;
/*blitAlphaImageToScreen(0 ,0 ,480 , 272, stage, 0, 0);
blitAlphaImageToScreen(0 ,0 ,8 , 8, ourImage, xPlayerCoord,
yPlayerCoord);
blitAlphaImageToScreen(0 ,0 ,8 , 8, target, xTargetCoord,
yTargetCoord);*/
/*please note helpers at qj.net, this code below isnt actually
working because I cant get up to it yet. So it will be full of errors :P*/
while (a<10){
b=0;
while (b<10){
if (arena[a][b]==4){
blitAlphaImageToScreen(0 ,0 ,480 , 272, stage, 0, 0);
} else if (arena[a][b]==1){
blitAlphaImageToScreen(0, 0, blockSize, blockSize, ourImage, a, b);
} else if (arena[a][b]==2){
blitAlphaImageToScreen(0 ,0 ,blockSize , blockSize, wall, a, b);
} else if (arena[a][b]==3){
blitAlphaImageToScreen(0 ,0 ,blockSize, blockSize, target, a, b);
}
b++;
}
a++;}

flipScreen();
buttonPressed = move(pad,&xPlayerCoord,&y PlayerCoord);
if(xPlayerCoord==xTargetC oord&&yPlayerCoord==yTarg etCoord){
start=1;
break;
}

sceDisplayWaitVblankStart ();
sceDisplayWaitVblankStart ();
sceDisplayWaitVblankStart ();
sceDisplayWaitVblankStart ();
}
clearScreen(0);
sceDisplayWaitVblankStart ();
blitAlphaImageToScreen(0 ,0 ,168 , 148, explosion, 156, (136-(148/2)));
flipScreen();
sceCtrlReadBufferPositive (&pad, 1);
if(pad.Buttons & pCross&&start==1){
start=0;
}
if(pad.Buttons & pCircle){
sceKernelExitGame();
}
}

}
sceKernelSleepThread();
return 0;
}



/*----------------------end code---------------------------*/
Theres the meat n potatoes of my code. its starting to evolve more into a struct based game instead of holding it all in an array. Well see how that goes for now till I can figure this arena stuff out .
Thanks all, sorry for the delay in code .
TheFool is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-06-2006, 12:55 PM   #10

I'm Baaaack!
 
Access_Denied's Avatar
 
Join Date: May 2006
Location: Waukegan,Illinois
Posts: 2,185
Trader Feedback: 0
Default

You don't need 4 of sceDisplayWaitVblankStart ();
__________________
Access_Denied is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-07-2006, 07:15 AM   #11

Muppet Magnet
 
Fanjita's Avatar
 
Join Date: Sep 2005
Location: Edinburgh, UK
Posts: 2,388
Trader Feedback: 0
Default

Most likely you've got some code that is overrunning the bounds of an array or other memory area and scribbling on other variables - this is usually the cause for symptoms that change when you add seemingly unrelated code.

I can't see it after a quick 5 minute glance though - you might like to check what the functions are doing that aren't shown here, like clearScreen(0), for instance.

These assignments looked like the most likely to go out of bounds:
Code:
arena[xPlayerCoord][yPlayerCoord]=1;
arena[xTargetCoord][yTargetCoord]=3;
But I can't see any reason why they would.

Have you verified, BTW, that you're not going through the while() loop even once? i.e. it could be that the bug lies after the strange 'if' statement, and the first pass through the loop is fine, but subsequent passes fail.

BTW your 'MAX' macro looks a little broken...
Fanjita is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-07-2006, 07:48 AM   #12

Developer
 
Join Date: Jul 2006
Posts: 262
Trader Feedback: 0
Default

Yeah I usually add debug printTextScreen statements when I am dealing with strange array and pointer errors. You should try to print the numeric contents of some of your array elements and integer values.

EDIT: I cannot see anything in your posted code (up to the point of the commented non-working stuff) that would cause an overflow. Maybe the compiler is broken? j/k but I did have to rewrite a little game demo from scratch after spending three days trying to find the memory leak but it must have been the compiler because after I re-wrote it there is no observable memory leak.
__________________
http://openpandora.org/

Last edited by the_darkside_986; 11-07-2006 at 08:06 AM..
the_darkside_986 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-21-2006, 03:22 PM   #13
 
Join Date: Oct 2006
Posts: 6
Trader Feedback: 0
Default Definately the compiler...

Damn that GCC....
lol jk
Thanks all for the support I still havent found the issue. But I have moved on and changed the source to arrays of objects that do hit detection. instead of an entire arena. This game is coming along nicely now just doing the big things step by step like AI and such. Thanks again for trying!
TheFool
TheFool is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
crash , explain , homebrewer , newbie , plz , weird

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 12:03 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us