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 BlackShark O yes, and MAKE SURE that you put Code: #include </usr/include/sys/stat.h> up were the rest of your ...
-
02-20-2007, 12:54 AM #2851Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
#include <sys/stat.h>
Zitat von BlackShark
will work aswell;)
-
02-20-2007, 01:42 AM #2852QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
I bet it comes from how you poll the button states.
Zitat von Mr305
Some facts about that (a lecture about button state polling and logical ops):
A call to sceCtrlPeek/Read* will only return the *current* button state and does not return changed button states or whatever. Therefore, calling the function twice will return the same button state twice (unless the user pressed a button in the timeframe between the two calls, which is unprobable because it's only a hand full of clock cycles and thats clock cycles/222000000 seconds of time, supposing your PSP runs at stock speed).
Therefore you need to recognize if a button that was pressed previously, was released once before you check again.
That's what the Peek/ReadBufferNegative does. So call it once before your Positive read. Then check if the buttons that were previously pressed, were released again by comparing the last_button_positive bitmasks to the button_negative bitmask.
That's what logical ops are for. If you have problems understanding the if statement, read up what & (AND), ~ (NOT) and ^ (XOR) does. It's nothing more then memorizing a 2x2 table of single digits. Then simplify the case for a 1bit button mask and go through the possible cases when you want to check for a button that is currently pressed (button_positive flag is 1):Code:sceCtrl last_buttons_positive; sceCtrl buttons_positive; sceCtrl buttons_negative; while(blubb) { sceCtrlReadBufferNegative( &buttons_negative ); sceCtrlReadBufferPositive( &buttons_positive ); if (~(last_buttons_positive.buttons & (last_buttons_positive.buttons ^ buttons_negative.buttons)) & buttons_positive.buttons & BUTTON_MASK) { // the button that was previously pressed, was released before, so this is // a new "press" event. Same if the button wasn't pressed before. } last_buttons_positive = buttons_positive; }
last_button was pressed (the flag is 1):
- button was released (button_negative flag is 1)
- button was not released (button_negative flag is 0)
last_button was not pressed (the flag is 0):
- see above two subsequent cases
You'll notice that the masks evaluate to 0 when the button was pressed before and wasn't released (or when the button isn't pressed at all currently), and to 1 else.
PS: Alternatively you could use the famous "last_button" method, though that will also recognize button releases as presses (ie you will still have two recognized button events for one down&release event), unless you create a negative mask through that yourself.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.
-
02-20-2007, 02:07 AM #2853QJ 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
how would i implement the anolog stick? like what function could i do to use the anolog stick to move my player?
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-20-2007, 02:37 AM #2854is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Put this before your while(1) loop
Then use this:Code:sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
Code:sceCtrlReadBufferPositive(&pad, 1); if(pad.Lx==whatever) { do whatever } if(pad.Ly==whatever) { do whatever }What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
02-20-2007, 02:55 AM #2855QJ 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
Awsome thanks

-= Double Post =-
Ok im having problems with this, it sorta works, problem is, at the start the player moves diagonaly down and to the right and off the screen, here is the code,
and i did define the statements above the while loop like,Code://Analog stick if(pad.Lx >= 40 && playerX < 480) { playerX = playerX + 2; } if(pad.Lx <= -40 && playerX > 0) { playerX = playerX - 2; } if(pad.Ly >= 40 && playerY < 272) { playerY = playerY + 2; } if(pad.Ly <= -40 && playerY > 0) { playerY = playerY - 2; }
Code:sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
It compiles HOWEVER it does give me two warnings,
Code:[Warning] comparison is always false due to limited range of data type [Warning] comparison is always false due to limited range of data type
My guess is that I can't have negatives when comparing the analog stick? if not, how do i make it so that if up is pressed, player goes up, down is pressed, player goes down, right is pressed player goes right, left is pres...etc...? as in what do i compare it to?Geändert von BlackShark (02-20-2007 um 03:33 AM Uhr) Grund: Automerged Doublepost
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-20-2007, 03:33 AM #2856is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
analog stick can't go negative
this is the code I used for iMockPod's going up and down:
Code:if(pad.Ly>230){} //down if(pad.Ly<30){} //upWhat did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
02-20-2007, 03:35 AM #2857QJ 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
ahh, i though so, thanks again!
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-20-2007, 05:50 AM #2858likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
How do you read from ID3 tags ?
-
02-20-2007, 06:15 AM #2859Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
is there a source code from a prx that take screenshots , because i have problems using the graphics.c+prx
-
02-20-2007, 07:22 AM #2860words 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
Ill post some screenshots of my current game build. Its a first-person sword fighter in 3D, and i have it all working. Running, standing and attacking animation, each for there respective button presses. Its really nice right now. I should be able to finish the game within 2 weeks.

...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-20-2007, 08:19 AM #2861QJ Gamer Silver
- Registriert seit
- Aug 2006
- Ort
- The Matrix
- Beiträge
- 1.090
- Points
- 8.002
- Level
- 60
- Downloads
- 0
- Uploads
- 0
cool!
Zitat von SG57
http://i28.tinypic.com/1znoljt.png
lolololololol - Reach 100,000 Gamerscore
-
02-20-2007, 10:14 AM #2862QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
It does work man, thanx alot, but there is a big problem. My game needs random numbers to be chosen quicker than once every second. Is there any way to make it generate a number qucker?
Zitat von BlackShark
...Just Returned To The Scene...
-
02-20-2007, 12:26 PM #2863
All these Days, was wondering what Positive, negative -- and also that they were synonymous(the same)!
Zitat von Raphael
It's all now Clear! Thanx.
What Does Peek do then (when Negative means, the buttons is pressed down currently)?
[I remember using it once & getting all wierd results! ]
-
02-20-2007, 12:51 PM #2864Developer

- Registriert seit
- Oct 2005
- Ort
- Dubuque
- Beiträge
- 423
- Points
- 12.154
- Level
- 72
- My Mood
-
- Downloads
- 1
- Uploads
- 0
sceCtrlPeekBufferPositive () just skips the vblank wait
Zitat von Mr305
-
02-20-2007, 12:54 PM #2865likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
can anyone here define the functions "UnmapViewOfFile" and "CloseHandle" ?
I need them...
I have searched GOOGLE(most of them arent general C, WIN32)
-
02-20-2007, 01:41 PM #2866Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Sure.
</sarcasm>Code:int UnmapViewOfFile() { return 0; } int CloseHandle() { return 0; }
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
-
02-20-2007, 02:02 PM #2867QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
That's IWN's way to say: "What the **** are you talking about?" ;P
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.
-
02-20-2007, 02:07 PM #2868
After sending the EBOOT 19th time for testing[after trying several variations], I am posting this...Code:Outer while { .............. sceCtrlPeekBufferPositive (&positive, 1); sceCtrlPeekBufferNegative (&negative, 1); if (~(lastpositive.Buttons & (lastpositive.Buttons ^ negative.Buttons)) & positive.Buttons & 0x000008){ clearScreen(0x000000); printTextScreen(150,136,statuspause,RGB(0,0,255)); flipScreen(); lastpositive = positive; do { sceCtrlPeekBufferPositive (&positive, 1); sceCtrlPeekBufferNegative (&negative, 1); if (~(lastpositive.Buttons & (lastpositive.Buttons ^ negative.Buttons)) & positive.Buttons & 0x000008) { lastpositive=positive; break; } }while (1); } ................. }
It works if it is used once in one loop, but above it doesn't seem to work!Geändert von Mr305 (02-20-2007 um 02:54 PM Uhr)
-
02-20-2007, 05:32 PM #2869likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
what would be the best way to read id3 tags in C?
-
02-20-2007, 05:40 PM #2870words 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
Uh, use your the logical - thinking lobe of your brain to google, or use that library for what your saying. Maybe... search?

...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-20-2007, 05:40 PM #2871Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von psphacker12.
google for id3 tag specs. find them, write your own lib.--------------------------------------------------------------------------------------
-
02-20-2007, 05:45 PM #2872words 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
First thing that popped up in google:
http://dl.qj.net/MP3-ID3-v0.01-Beta-...5445/catid/151
Consult the author for his library (i believe he released it...)
...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-20-2007, 06:39 PM #2873likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
couldn't I just do...
fseek (pFile , -128, SEEK_END);
-
02-20-2007, 06:43 PM #2874QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
That's what writing your own lib for it means.
-
02-20-2007, 07:07 PM #2875QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 90
- Points
- 4.912
- Level
- 44
- Downloads
- 0
- Uploads
- 0
yeah that would be fine for ID3v1. ID3v2 is a bit different though. Just follow everyone else's advice and google for the formats.
Zitat von psphacker12.
-
02-20-2007, 10:14 PM #2876QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
ok i have a prob with my 3d object
Spoiler for code of rotation:
thats just for rotation i got it to rotate in degrees instead of radians but now i can't get the object to move in the direction it is faceing and i'm not sure why i believe that code should work but it won't and it's makeing mad i've made countless modifications 2 it yet it still won't work1. 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
-
02-21-2007, 12:06 AM #2877QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
I tried the code and it seemed to work for me (maybe your Start button really is just pretty sensitive? in that case you should try adding delays into the button polling to make it poll only ~5-10 times per second - see bottom of post for the delay function), however, I noticed that BufferNegative behaves something different from what I assumed. That made me test it a bit more and the logic seems to be 90% a simple !positive, but in some cases it doesn't recognize button events while the positive does. Well, anyhow I need to revise my sample for propper Button event polling (though it worked, but the logic behind it was not the logic I was trying to show):
Zitat von Mr305
That code works same as my previous version did, but it's easier to understand and easier to handle the button down (presses) and button up (releases) events. You maybe could put the Button masking into a seperate function that updates the global presses and releases flags, just to make the code more readable. Or put the inner loop into it's own "WaitForButtonPress( int ButtonMask );" function and insert a sceKernelDelayThread(1000 000) if you're gonna use it inside XMB/multithreaded application or just want to limit the number of button events received per second (a delay of 100000 means at most 10 polls per second - 200000 means 5 polls per second).Code:SceCtrlData positive, lastpositive, presses, releases; lastpositive.Buttons = 0; while(outer_loop) { sceCtrlPeekBufferPositive (&positive, 1); presses.Buttons = ~lastpositive.Buttons & positive.Buttons; releases.Buttons = lastpositive.Buttons & ~positive.Buttons; lastpositive = positive; if (presses.Buttons & BUTTON_MASK) { // do what should happen if button was pressed (not released!) // for example, wait for another button press: while (1) { sceCtrlPeekBufferPositive (&positive, 1); presses.Buttons = ~lastpositive.Buttons & positive.Buttons; releases.Buttons = lastpositive.Buttons & ~positive.Buttons; lastpositive = positive; if (presses.Buttons & BUTTON_MASK) break; } } }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.
-
02-21-2007, 11:38 AM #2878QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Well? This has been completely ignored....
Zitat von JaSo PsP
...Just Returned To The Scene...
-
02-21-2007, 12:19 PM #2879Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Can't you just call rand() every time you want a new random value...?
Zitat von JaSo PsP
-
02-21-2007, 12:45 PM #2880
danke sehr
Zitat von Raphael
[I ain't no german!]
Works like a charm!


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