![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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 ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
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!
|
|
|
|
|
|
|
#2 |
![]() ![]() PSP Developer
Join Date: Oct 2005
Real First Name: Alex
Location: ~* Confidential *~
Just Played: N/A
Posts: 839
Trader Feedback: 0
|
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 - |
|
|
|
|
|
#4 |
![]() ![]() Developer
|
I am heavily assuming that this
Code:
arena[0][0]=4; eg Code:
int Hello = 10; // fine Hello = 54; // Not fine |
|
|
|
|
|
#5 |
|
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
|
|
|
|
|
|
|
#9 |
|
/*
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 . |
|
|
|
|
|
|
#11 |
![]() ![]() Muppet Magnet
|
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; 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...
__________________
Using firmware v2.00-v3.50? Open up a whole world of homebrew here
The PSP Homebrew Database needs YOU! Your ISP may be illegally wiretapping all your web activity. Stop Phorm Now! Visiting the Edinburgh Festivals? Get practical advice from experts. |
|
|
|
|
|
#12 |
![]() ![]() Developer
|
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.. |
|
|
|
|
|
#13 |
|
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 |
|
|
|
|
![]() |
| Tags |
| crash , explain , homebrewer , newbie , plz , weird |
| Thread Tools | |
|
|