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; Zitat von Moca in main.c #include "yourfile.c" No! Never ever include source files (.c or .cpp) in other source files. ...
-
01-27-2007, 04:28 PM #2641QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
No! Never ever include source files (.c or .cpp) in other source files. Place this at the top of the main file:
Zitat von Moca
This tells the compiler when it is compiling the main source file that this variable is in another object file and will be linked by the linker later.Code:extern static unsigned char background[];
[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]
-
01-28-2007, 02:54 AM #2642Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
yeah you helped me:)
Zitat von Moca
-
01-29-2007, 02:25 AM #2643QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- Australia - A.C.T.
- Beiträge
- 1.517
- Points
- 9.253
- Level
- 64
- Downloads
- 0
- Uploads
- 0
ok i realy need help i have been trying to get a prx to load a image but nothing seems to be working would any of you guys be able to help me.
thx mafia1ft
Spoiler for LOL:
-
01-29-2007, 09:46 AM #2644The Unique Developer

- Registriert seit
- Oct 2006
- Ort
- Canada
- Beiträge
- 1.059
- Points
- 7.101
- Level
- 55
- Downloads
- 0
- Uploads
- 0
You 'can' include then so 'Never Ever' is not a good word -_-.
Zitat von yaustar
I don't know what you were talking about and I'm lazy to check -_- , So I guess your right about this case <_< .
Moca usually includes his file.c into his main.c when he's using bin2c ;) .Malloc.Us Network Administrator
Decryption of the Encrypted
You are the unseen, the unstoppable and in power of your code. The God of your software.
-
01-29-2007, 10:19 AM #2645QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
"Never ever include source files" implies that it is a bad thing to do.
Zitat von the unique warrior
"You cannot include source files" implies a fact.
The choice of using "never ever" seems to be fine in terms of choice of words.
When using an IDE or a makefile generation, it will automatically compile any .c or .cpp file. By including a .c or .cpp into another file, you are effectively compiling it twice or more, once directly to the compiler and the other, indirectly from #includes since all #include does is text replacement.
eg:
Code:// source1.c void Hello ( ) { // Do stuff }The compiler compiles source1.c to a seperate .obj file then when it compiles source2.c, it sees this:Code:// source2.c #include "source1.c" int main() { // do more stuff return 0; }
Compiles it, then when the linker tries to link the two obj files, it throws a function redefinition error.Code:void Hello ( ) { // Do stuff } int main() { // do more stuff return 0; }
Technically, you can #include anything (XML, TXT, etc).
I don't know who this Moca is, but I will shoot him if he did that in my codebase/projects.[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]
-
01-29-2007, 12:52 PM #2646
Okay need help again :P
i have tested the psp-programming fourth tute about image blitting,
so i have this main function:
Code:int main() { char buffer[200]; Image* ourImage; pspDebugScreenInit(); SetupCallbacks(); initGraphics(); sprintf(buffer, "ourImage.png"); ourImage = loadImage(buffer); if(!ourImage) { //Image load failed printf("Image load failed!\n"); } else { int x = 0; int y = 0; sceDisplayWaitVblankStart(); while (x < 480) { while (y < 272) { blitAlphaImageToScreen(0, 0, 480, 272, buffer, x, y); y += 272; } x += 480; y = 0; } flipScreen(); } sceKernelSleepThread(); return 0; }
what i want to know is how i blit that image rotated 180 degrees or blitting it reversed?
-
01-29-2007, 03:27 PM #2647The Unique Developer

- Registriert seit
- Oct 2006
- Ort
- Canada
- Beiträge
- 1.059
- Points
- 7.101
- Level
- 55
- Downloads
- 0
- Uploads
- 0
I have to admit that your right that it compiles twice. BUT just try doing what this guy 'Moca' wanted to do . use your SDK too :
Zitat von yaustar
and convert a text file to .C .Code:bin2c text.txt text.c text
Then Do something like this
You'll get an unidentified variable error.Code:#includes. (note: don't include the text.c yet ) int main( int argc, char **argv) { SceUID fd = sceIoOpen("text.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777); sceIoWrite(fd, text_buffer, text_size); sceIoClose(fd); sceKernelExitGame(); return 0; }
Now try the samething with the .c file included and you won't get an error .
This MayBe PSP-SDK's Problem(at least the old one ) and maybe fixed now, or I was doing something wrong the last time I teseted this -_-Malloc.Us Network Administrator
Decryption of the Encrypted
You are the unseen, the unstoppable and in power of your code. The God of your software.
-
01-29-2007, 04:20 PM #2648QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Quoted for emphasis although ther is an error in the code above :/
Zitat von yaustar
You code should have been:
And remove the static keyword from the generated .c file since it limits the variable to file scope.Code:extern unsigned char text_buffer[]; extern int text_size; int main( int argc, char **argv) { SceUID fd = sceIoOpen("text.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777); sceIoWrite(fd, text_buffer, text_size); sceIoClose(fd); sceKernelExitGame(); return 0; }
At the VERY worse, I rename the generated .c file to a .h, put in header guards and then #include it. Renaming the file means that auto generated makefiles/scanners and IDEs want compile it to a seperate .obj file.[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]
-
01-29-2007, 04:28 PM #2649
Hi i have a question if i do:
is there a dif with this:Code:do { } while (Condition);
Code:while (Condition) { }Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
01-29-2007, 04:35 PM #2650QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
The first case will at least run the code in the brackets once, because the condition check is done at the end of the code segment.
Nothing else.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.
-
01-29-2007, 04:35 PM #2651QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Do while loop does a loop before checking the condition.
Zitat von ZereoX
A while loop checks the condition before looping.[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]
-
01-29-2007, 04:43 PM #2652
OK thanks so EG:
So here x will atleast be 1 since it does a loop before checking the condition.Code:int x=0; do {x++;} while ( x < 0)
Thanks I apreciate.Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
01-29-2007, 04:53 PM #2653QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes.
Zitat von ZereoX
-The message you have entered is too short.-[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]
-
01-29-2007, 08:52 PM #2654QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
is there a way to check for files in a folder and if so what libarys/commands do you need?
-= Double Post =-
also how to i save images from the screenGeändert von slicer4ever (01-29-2007 um 08:52 PM Uhr) Grund: Automerged Doublepost
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
01-29-2007, 09:47 PM #2655Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
You need to include stdio.h and open said file, the fopen function will return NULL on failure. See here: http://www.cplusplus.com/reference/c...dio/fopen.html
For saving a screenshot, if you're using graphics.c/.h then the saveImage function is all you need.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
01-30-2007, 11:21 AM #2656
Zitat von SWE_PsYcHo
CAN ANYONE HELP ME?!
-
01-30-2007, 11:29 AM #2657Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
The graphics.c/.h that you are using doesn't support rotation.

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
01-30-2007, 11:41 AM #2658QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
It seems you need OSLib for rotation...
By the way, is it possible to add a function do graphics.c to allow rotation, or does graphics.c use some GU mode which doesn't allow it? I'm not sure how the GU works.
Image rotation is something I need for Bounce, but it uses graphics.c and I don't really want to port the whole thing to OSLib...
-
01-30-2007, 02:03 PM #2659Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
You need to be in an ortho projection to use the sceGumRotate* functions, neither the graphics.c or OSLib uses an ortho projection.

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
01-30-2007, 02:21 PM #2660QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
How do you write to flash?
-
01-30-2007, 02:25 PM #2661likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
How can I blit an image onscreen for five secs. and then sceKernelExitGame()?
-
01-30-2007, 02:59 PM #2662QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Why is everyone asking "how tos"?
Zitat von psphacker12.
Blit the image
Flip the buffer
Wait for VSync 5 * 60 times
Exit game
Done.[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]
-
01-30-2007, 06:36 PM #2663
I have a question when example:
Is there a way of actualy way of entering a number on teh psp, since on that on the pc you just have to press a number.Code:using namespace std; int main() { pspDebugScreenInit(); SetupCallbacks(); int age; int year = 2007; cout<<"Type you age:\n"; cin>> age; cin.ignore() if ( age < 0 ) {BLAH}Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
01-30-2007, 07:55 PM #2664words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Does it look like hte PSP has a keyboard?
Youd have to write your number entering routine. I did somtehing very very similar in coolguy and I's Block Dude clone. I had an array, someting like:
Then something like...Code:char password[4]; int spot=0;
Or something similar and much more defined and working... I made it ~5 months ago, back when I was ~2/3 of what i am now, so it shouldnt be hardCode:if up is pressed and password[spot] != 'a' { password[spot] -= 0x01 } if cross is pressed { spot++ if spot > 3 { compare password to password string from map file } }
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-30-2007, 08:11 PM #2665Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
There is a debug screen keyboard in the PSP SDK.
Check out the pspdebugkb.h header and the sample too.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
01-30-2007, 08:30 PM #2666words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
The debug console has a built-in keyboard? Huh - whats it look like?

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-31-2007, 03:52 AM #2667QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
You have been away from your PSP way too long, seriously.
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.
-
01-31-2007, 12:42 PM #2668QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Or more simply:
Zitat von yaustar
Blit image
Flip the buffer
Delay thread for five secs
Done. :)
Anyway I think that a PSP
should know how to do this
wheeee =:D
-
01-31-2007, 04:23 PM #2669words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
I havent had a PSP since ~2days before the 2.8 eloader came out.... Thanks for rubbing it inthere Raph...

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
02-01-2007, 01:10 AM #2670QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
I wasn't trying to insult you, just stating an obvious fact. If you still had your PSP, you wouldn't have asked such a question.
Actually, I find it rather sad, but props that you still try to keep up in the scene :P I prolly wouldn't have the gutsThe debug console has a built-in keyboard? Huh - whats it look like?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.


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