C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I'm trying to make a Slim friendly app, testing in 1.50 kernel isn't the best idea, thats why I asked ...
-
12-19-2007, 12:39 PM #7171I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I'm trying to make a Slim friendly app, testing in 1.50 kernel isn't the best idea, thats why I asked specifically about 3.XX, plus I want to use the reset vsh command, which just crashes in 1.50.
-Aura
-
12-19-2007, 12:53 PM #7172
Zitat von Raphael
thanx it did take a little thinking, this is what i came up with.
-= Double Post =-Code:{ ifstream OpenFile("name.conn"); if( !OpenFile ) { cerr << "Error opening file" << endl; return -1; } string loadname= ""; while ( OpenFile >> loadname) { name += loadname; } }
is there a way to check if a string is equal to a textual value,
like to check if the person typed in a valid gender or not.
-= Double Post =-
i no how to use the
if (#==#)Geändert von Blackbelttcon (12-19-2007 um 12:57 PM Uhr) Grund: Automerged Doublepost
-
12-19-2007, 01:00 PM #7173I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
You can use the string compair function I believe...
http://www.cplusplus.com/reference/c...g/strncmp.html
That should help a little.
-Aura
-
12-19-2007, 01:05 PM #7174
alright thanx, and thanx yaustar for helping me before, u did give me the right code, i just mess is up, by adding the wrong stuff.
-
12-19-2007, 03:16 PM #7175QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Don't forget that this is case sensitive.Code:string gender = "Male"; if( "Male" == gender ) { cout << "Hey, this guy is Male" << endl; }
PS: Pick up a book on C++ programming. You really shouldn't be needing to ask questions like this if you are learning properly.
Read: http://parabellumgames.wordpress.com...c-programming/[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
12-19-2007, 03:17 PM #7176
alright thanx
-
12-19-2007, 04:46 PM #7177I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
How exactly does a psar work? And how could I make my own containing everything that needs to be installed to flash? Just to make things easier.
-Aura
-
12-20-2007, 03:08 PM #7178I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I've made an error check for Project4, it reads the arguments that are normally passed to vshmain.prx, and from there reads what the error code should be, I had it working fine the other day and I somehow managed to mess it up big time today, so I was wondering if anyone could help me out as I think I just fluked it the first time.
When it loads, it does nothing, it doesn't even print the error code, just hangs. That is the entire code for the start, nothing comes before it, and the error definatly comes at that point.Code:pspDebugScreenInit(); SceCtrlData pad; unsigned int* errorCode; errorCode = (unsigned int*) malloc(sizeof(unsigned int)); *errorCode = *argp[0x14/4]; _printf("0x%X - ", *errorCode); if(*errorCode==0x80020148) _printf("File loaded in incorrect kernel."); if(*errorCode==0x0AE1BCE4) _printf("Project4 Internal Error."); if(*errorCode==0xDADADADA) _printf("Sony updater blocked."); if(*errorCode==0x80020321) _printf("Device not found, using wrong NoUMD mode?"); if(*errorCode<0) _printf("Error unknown, please post error code on forums.");
-Aura
-
12-20-2007, 03:24 PM #7179It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Why are you allocating memory for something you can do easily on the stack?
Also, are you sure that argp is a pointer to a pointer?Code:pspDebugScreenInit(); SceCtrlData pad; unsigned int errorCode = *argp[0x14/4]; _printf("0x%X - ", errorCode); switch(errorCode) { case 0x80020148: _printf("File loaded in incorrect kernel."); break; //Note: this error isn't strictly true; it should be that the PRX type isn't supported by the current kernel case 0x0AE1BCE4: _printf("Project4 Internal Error."); break; //Also, this error code is non-negative, so it may be passed on something successful happening and non necessarily on an error case 0xDADADADA: _printf("Sony updater blocked."); break; case 0x80020321: _printf("Device not found, using wrong NoUMD mode?"); break; default: if(errorCode < 0) _printf("Error unknown, please post error code on forums."); break; }pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
12-20-2007, 03:48 PM #7180I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
To be honest I have no idea, I'm just working from the warnings I've got when compiling, it says argument 2 should be **char. As for allocating memory, I assumed I had an error somewhere with a pointer and using a guide I found online, I allocated the memory as it showed, just to make sure that the error wasn't occuring there.
The final thing, 0x80020148 normally only occurs when the user is running something in the wrong kernel, Project4 is aimed at users not programmers so this is generally the reason, although if you think I should change it still then I will do so.
I've just tested the code you supplied, same problem, so I'll have another crack at it. Thanks for the help.
-Aura
-
12-20-2007, 06:09 PM #7181It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
There's your problem. You're dereferencing a char** into an int. You can't do that (3/4 of the time), and even when you can, you probably don't want to.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
12-21-2007, 03:13 AM #7182QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
Hey guys, Iv been trying to figure out a way to get around my problem for the past 1-2 hours and i just cant get it. Iv got my function for an enemy to walk left and another one to walk right along with animation. If you use one of the functions it will return 1. The thing is i have another bit of code to reset the sprite to a normal standing position but it wont work properly. It simply works by the functions
andCode:enemy_walkL
both returning 0. To begin with, it works fine because enemy_walkL and enemy_walkR return 0, but the moment you use one of the function one will return 1. My question is, how would i define what a function returns when its not being used like:Code:enemy_walkR
Any help would be great, thanksCode:}else{ return0; }
-
12-21-2007, 07:59 AM #7183I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
That probably explains it. I got access to my old backup and it appears that it always gives the same code, so it never was working unfortunatly. Have you got any idea how I can check the errors and keep warnings out of the compliation?
Zitat von Archaemic
Thanks.
-Aura
-
12-21-2007, 08:59 AM #7184It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Can I see more code? What you've given is valid except for the dereferencing of a char** into an int. You can't exactly store an error code in a char because it's way too short.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
12-21-2007, 09:04 AM #7185I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I deleted the code, but what I had shown before was the code used.
Thats pretty much what I had last. Could I copy the content of argp into a new variable, u32 errorCode[0x20/4] ? That should hold all the values, and I can then access a signle section right?Code:int main(int args, char** argp) { pspDebugScreenInit(); SceCtrlData pad; unsigned int errorCode = *argp[0x14/4]; _printf("0x%X - ", errorCode); switch(errorCode) { case 0x80020148: _printf("File loaded in incorrect kernel."); break; case 0x0AE1BCE4: _printf("Project4 Internal Error."); break; case 0xDADADADA: _printf("Sony updater blocked."); break; case 0x80020321: _printf("Device not found, using wrong NoUMD mode?"); break; default: if(errorCode < 0) _printf("Error unknown, please post error code on forums."); break; } __main(); }
-Aura
-
12-21-2007, 09:47 AM #7186QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
If the error code is really submitted starting at offset 0x14 in the argument string. A check for the args (>=0x18) would be good too, to avoid reading from memory that doesn't belong to the argument string anymore. Also a check for argp and *argp to be non-NULL would be good.Code:unsigned int errorCode = ((unsigned int*)*argp)[0x14/4];
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
12-21-2007, 11:44 AM #7187I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I had tried this in the past, but that actually caused another error, although that may have been linked to the fact it was never working in the first place. I'll have another go at getting it working tonight maybe.
Zitat von Raphael
-Aura
-
12-21-2007, 01:03 PM #7188Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
I have never seen anything like it.Code:psp-gcc: : No such file or directory cc1: error: to generate dependencies you must specify either -M or -MM psp-gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../include -O20 -G0 -ffast-math -fsigned-char -g -O2 -MT bitwise.lo -MD -MP -MF .deps/bitwise.Tpo -c bitwise.c -o bitwise.o make[2]: *** [framing.lo] Error 1 make[2]: *** Waiting for unfinished jobs.... mv -f .deps/bitwise.Tpo .deps/bitwise.Plo make[2]: Leaving directory `/home/G.Ninja/psplibraries/build/libogg/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/G.Ninja/psplibraries/build/libogg' make: *** [all] Error 2 ../scripts/008-libogg.sh: Failed.
-
12-21-2007, 03:36 PM #7189I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I need help quickly so I can get this release out on the 24th, my code un-assigns and re-assigns flash0 into read/write mode so I can install Project4 into it, the code is exactly the same on the 3 installers but on the 3.7X installer it returns 0x8001000D, I have no idea what this error means, but it appears to happen when trying to un-assign flash0.
I've also tested the 3.5X installer, that works fine, and as I said the code is exactly the same, so I'm not sure what the error is, so any information about the error is a major help at the moment.
Thanks.
-Aura
-= Double Post =-
Solved... I changed the code from 0x0 (user) to 0x800 (VSH).Geändert von Auraomega (12-21-2007 um 03:42 PM Uhr) Grund: Automerged Doublepost
-
12-21-2007, 06:13 PM #7190QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
Zitat von Xsjado7
Could anyone help me with this?
It was late and i kind of rambled on bit the jist of it is i wanna know how to return a different variable from a function when its not being used. Thanks
-
12-22-2007, 12:13 AM #7191QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
How do you make your program check if two buttons were pressed at once?
is for one button (that was off the top of my head) but what is it for two?:oCode:if(pad.Buttons & PSP_CTRL_CIRCLE)
WHA!?
-
12-22-2007, 12:22 AM #7192QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Zitat von BigSanFrey
It's called boolean logic.Code:if(pad.Buttons & (PSP_CTRL_CIRCLE | PSP_CTRL_CROSS))
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
12-22-2007, 12:22 AM #7193QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
For circle and crossCode:if(pad.Buttons & PSP_CTRL_CIRCLE && pad.Buttons & PSP_CTRL_CROSS)
-
12-22-2007, 12:44 AM #7194QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Is this not like a double if statement in one? In this case it is used like that anyway:o
Zitat von Raphael
edit: just noticed the title has something to do with ISOs but i can't read that language so, sorry! I was just using the code as an example ;)
Ahh, brilliant thank you :)
Zitat von Xsjado7
WHA!?
-
12-22-2007, 12:54 AM #7195QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
Any time
-
12-22-2007, 12:13 PM #7196It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Pssst: that will do if either button is pressed, not only if both buttons are pressed.
Zitat von Raphael
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
12-22-2007, 12:43 PM #7197QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
If you're referring to the following:
Zitat von BigSanFrey
That code is bull****, as it will always evaluate to true.Code:if(pad.Buttons & PSP_CTRL_CIRCLE || PSP_CTRL_CROSS || PSP_CTRL_TRIANGLE || PSP_CTRL_SQUARE)
Ahh... I always forget about the important thing in that case...
Zitat von Archaemic
That actually makes the other solution shorter now, but only if you don't alias the ORed button masks.Code:if((pad.Buttons & (PSP_CTRL_CIRCLE | PSP_CTRL_CROSS)) == (PSP_CTRL_CIRCLE | PSP_CTRL_CROSS))
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
12-22-2007, 01:52 PM #7198I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Surely
will only work if both buttons are pressed, which makes the code smaller again.Code:if(pad.Buttons & (PSP_CTRL_CIRCLE & PSP_CTRL_CROSS))
-Aura
-
12-22-2007, 01:54 PM #7199QJ Gamer Silver
- Registriert seit
- Feb 2007
- Ort
- Melbourne, Australia
- Beiträge
- 1.773
- Points
- 8.717
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Does it really matter if the code is longer or something?
Zitat von Auraomega
works fine ;)Code:if(pad.Buttons & PSP_CTRL_CIRCLE && pad.Buttons & PSP_CTRL_CROSS)
WHA!?
-
12-22-2007, 01:58 PM #7200I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Nope, but I normally code from memory, and the shorter to code the easier to remember
Zitat von BigSanFrey

-Aura


LinkBack URL
About LinkBacks

Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum