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 youresam The power switch is in the psppower.h file. Look at the PSPSDK sample on how to use ...
-
02-23-2007, 03:03 PM #2911I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I assumed that he was talking about the hold switch, which is in pspctrl.h.
Zitat von youresam

-
02-23-2007, 03:16 PM #2912
Pressing it UP is power access.
Zitat von pspfreak9
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-23-2007, 03:29 PM #2913I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Wouldn't that just turn off the PSP though? Or can you override that?
Zitat von youresam

-
02-23-2007, 03:59 PM #2914
Exactly, he wants to know when that happens. You get about a 1/2 second to detect the power switch before it powers down. This is useful because if youre reading a file...constantly....then you know you NEED_TO stop when power is pressed.
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-23-2007, 04:24 PM #2915
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Ok but how would I make an if statement when the power switch is pulled up?
Would it be like this:
Code:if (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING) {
-
02-23-2007, 06:58 PM #2916QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
to generate a random number u can just use
number = rand() % 100 + 1;[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
02-23-2007, 07:04 PM #2917
Correct,
Zitat von pspfreak9
But note that it must be running in a power thread.牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-24-2007, 05:07 AM #2918Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
the size is 13900225 bytes
then
int buffer = malloc(size);
but buffer returns NULL , is the file to big to store to an int?(i guess but need to be sure)
-= Double Post =-
no need any more
ported all functions to pspIo and fixed it;)
-= Double Post =-
another problem
i am 99% sure the fault is here
fread(&header, sizeof(HEADER), 1, infile);
to
sceIoRead(infile,&header, sizeof(HEADER));
what did I wrong
more info:
I hope someone can help meCode:typedef struct { char signature[4]; int version; int offset[8]; } HEADER; HEADER header; infile=sceIoOpen(path, PSP_O_RDONLY, 0777);Geändert von hallo007 (02-24-2007 um 06:21 AM Uhr) Grund: Automerged Doublepost
-
02-24-2007, 07:44 AM #2919Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Moca
yes, but keep in mind that you will also have to the the random seed. also, read up on the mersenne twister. its much more random.--------------------------------------------------------------------------------------
-
02-24-2007, 12:22 PM #2920
- Registriert seit
- Jan 2007
- Beiträge
- 14
- Points
- 3.496
- Level
- 36
- Downloads
- 0
- Uploads
- 0
umm i was wondering if anyone knows some great basic c tutorials (i did the 6 on psp-prog and already have one homwbrew release but its very basic) so yea i want to get better but i need help with a lot of thing and motly makefiles i just dont get how to set them up
-
02-24-2007, 12:59 PM #2921I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Go to my site. (Link in my sig) I think the C tutorials are all around easier than Yeldarb's. As for Makefile's, you just simply have to understand what the compiler does, and what the linker does. You can look in a general C tutorial for that.
Zitat von Flame4e
@Hallo0007-
This will not do anything:
int buffer = malloc(size);
malloc is used to set the size of a buffer. You'd have to do something like this
char* buffer = malloc(size);
-
02-24-2007, 01:13 PM #2922Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
but smaller files were working , i stiil think the fault is here
Code:fread(&header, sizeof(HEADER), 1, infile); to sceIoRead(infile,&header, sizeof(HEADER)); what did I wrong more info:
I hope someone can help meCode:typedef struct { char signature[4]; int version; int offset[8]; } HEADER; HEADER header; infile=sceIoOpen(path, PSP_O_RDONLY, 0777);
-
02-24-2007, 01:25 PM #2923I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I didn't even look at your code. I was just skimming the page and saw that, so I pointed it out.

-
02-24-2007, 01:53 PM #2924QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
In that case, just learn the language on the easiest development platform you have access which is the PC. Don't start developing on the PSP yet. Plenty of links can be find in the document here:
Zitat von Flame4e
http://parabellumgames.no-ip.org/art...c-programming/
Access_Denied: Some quick comments on your tutorials. You don't explain the difference between various datatypes or what a variable actually does in the program. (ie variable represents a chunk of memory on the stack) or what it abstractly represents. It gets worst as you actually use pointers without explaining what they are.
You also don't cover all areas of functions. Return types, parameter passing, what void means, the difference between a function definiton and declaration.
There are also lot of other things but those two are most important as they are basics.[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]
-
02-24-2007, 06:40 PM #2925
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
PSP Power?!?
Ok I modded the sdk sample of power to this:
Spoiler for Mod:
When I run it it works fine so i went to test it out by just flicking up my poweswitch and then the memory stick light blinked (it was getting ready to write to the txt file) and the it just froze. Why would that happen? Is it beacuse I gave it too much to do before powering down?
-
02-24-2007, 09:47 PM #2926QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Ok Im having a problem with my bullet system, when I press X, no matter what direction im facing it changes my player's position to face north west and fire the bullet south west for some reason,
heres the bulletFire function
Spoiler for function:
Then I call it like this,
Any ideas?Code://Weapon firering if(pad.Buttons & PSP_CTRL_CROSS && (autof == 100) && (firing == false)) { autof = 0; bx = playerX - 15; by = playerY - 16; firing = true; }
EDIT: Can't believe this, while reviewing my post i finally found what was wrong, Sorry for wasting post space
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-24-2007, 10:37 PM #2927words 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 have a question, sorta. What is a reasonable value for fog density so the fog has a large range of area to go from no fog, to light light fog, to light fog, to medium fog, to dense fog, to complete fog... Its hard to explain, so if you dont understand, just say so :o
BS - Just to take a crack at it, even though you fixed it - looks to me like somewhere in your other code your setting Pdir to 4, with out knowing it... Thats all i could really gather from your little snippet.
also, a little otimization trick:
Can be converted to:Code:if(bx > 480) { firing = false; }else if(bx < 0) { firing = false; }else if(by > 272) { firing = false; }else if(by < 0) { firing = false; }
You need to make more usage of the logical operators.Code:if(bx > 480 || bx < 0 || by > 272 || by < 0) firing = false;
Also, another optimization, use a switch case statement instead of:Via:Code:if(Pdir == 1) { by = by - 10; } if (Pdir == 2) { bx = bx + 10; by = by - 10; } if (Pdir == 3) { bx = bx + 10; } if (Pdir = 4) { bx = bx + 10; by = by + 10; } if(Pdir = 5) { by = by + 10; } if(Pdir = 6) { bx = bx - 10; by = by + 10; } if(Pdir = 7) { bx = bx - 10; } if(Pdir = 8) { bx = bx - 10; by = by - 10; }
Code:switch(Pdir) { case 1: { by -= 1; break; } case 2: { bx += 1; by -= 1; break; } case 3: { bx += 1; break; } case 4: { bx += 1; by += 1; break; } case 5: { by += 1; break; } case 6: { bx -= 1; by += 1;break; } case 7: { bx -= 1; break; } case 8: { bx -= 1; by -= 1; break; } default: { Pdir = some_default_value; break; } }
...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-24-2007, 11:55 PM #2928QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
ok thank you, turns out i also set Pdir to 5, 6, and 7 as well, (thats y i was getting such a weird step,
also thanks for the optimization tips, was trying to figure out what the C equivelent of "or" was to lua, now i know its ||, much helpful :), I knew about switch case but wasn't sure I knew enough to implement them, I can study that to use more if needed, thanks again SG
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-25-2007, 12:40 AM #2929words 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
Switch case statements confused me at first as well. I simply skipped them. But later, I learned to love them ;) Hell, i made that TIFF Pixel Repair app just as an excuse to use switch statements ;) If you dive into emulator developing, youll find switch case statements everywhere.

...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-25-2007, 12:41 AM #2930QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Now i just need to figure out how to make the image "rotate" when L or R is pressed (like CsPSP)
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-25-2007, 12:52 AM #2931words 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
You have 2, efficient, options for that.
1. Use hardware rotation, but this will require knowledge of the PSPs GU function calls and how to use them effectively.
2. Pre-defined image rotation by using an image editor and applying the rotation to it, but this can eat up alot of memory if you have 360** of rotation and/or a large image. Your best bet for this would be to place all angles of rotation of the sprite you want, onto a sprite sheet, and also get rid of any unimportant angles of rotation (example, to cut your amount of sprites in 1/2, increment your angles of rotation by 2. This will significantly reduce hte amount of memory taken up (depending on sprite size) and not be 100% noticeable.
I believe CSPSP uses the GU.
...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-25-2007, 01:18 AM #2932QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
yes, he used the GU (got some help from him earlier and thats what he used) My main concern is that if I managed to do the image rotation, how would i do the bullet system? he used a bullet class in C++ so that option is out for me :S
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-25-2007, 02:03 AM #2933words 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
Use TP's little bullet sustem guide thing. Have L and R rotate a point around in a circle, and use those X and Y coordinates with TP's guide (instead of the cursor thing).

...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-25-2007, 02:18 AM #2934QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Where can i find this guide? I remember seeing somewhere not sure were though, (if all else fails ill google it)
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-25-2007, 03:55 AM #2935Mushroom Man
- Registriert seit
- Sep 2005
- Ort
- UK
- Beiträge
- 318
- Points
- 7.283
- Level
- 56
- Downloads
- 0
- Uploads
- 0
For image rotation a software solution really won't cut it unless you can optimise on the usual rotation method. (see attachment)
Your other option is to use OpenGL to render your textures onto a flat surface, after which you can use the basic matrix transformations to rotate the image. Using this method rendering around 180 entities I have got FPS up to 40 or so I believe; certainly alot faster than the software rotation method which trundled along at approx .5 FPS ;)
As SG57 said you have the option of using a tileset of rotations of the original image at intervals of say 15 degrees, however I find this method gives a somewhat static feel to it.
For the OpenGL method read up on the ported "Nehes" OpenGL tutorials for the PSP, in particular Lesson 6(for loading/rendering a texture to a face), Lesson 12(for display lists and rotation) and Lesson 20(for masking/blending).
Links:
Nehe Tutorials 1-10 http://www.qj.net/portage-of-nehe-tu...g/49/aid/47390
Nehe Tutorials 11-20 http://pspupdates.qj.net/Portage-of-...g/49/aid/59254
-
02-25-2007, 04:24 AM #2936QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
vLib does image rotation with the GU for you, but if you're already quite far into your project you're gonna need a lot of changes...
-
02-25-2007, 08:44 AM #2937
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Can some please answer my PSP Power problem on the last page. Thx :)
-
02-25-2007, 09:13 AM #2938
Tell me why you need to know if the PSP is turning off.
Zitat von pspfreak9
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-25-2007, 09:27 AM #2939
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Well because using the code in netlib, if your player 1 and waiting for player 2 and if you turn off the power switch the game wont work any more. I need it to netsend "empty" to the room before powering down, and maybe netunreg.
-= Double Post =-
i was just testing it by writing to a txt fileGeändert von pspfreak9 (02-25-2007 um 09:27 AM Uhr) Grund: Automerged Doublepost
-
02-25-2007, 09:48 AM #2940is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
wait, netlib = lua, isnt this the C/C++ help thread?
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe


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