Seite 96 von 340 ErsteErste ... 46 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 146 196 ... LetzteLetzte
Zeige Ergebnis 2.851 bis 2.880 von 10174

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 ...

  
  1. #2851
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von BlackShark


    O yes, and MAKE SURE that you put

    Code:
    #include </usr/include/sys/stat.h>
    up were the rest of your #include's are let me know if this works for you.
    #include <sys/stat.h>

    will work aswell;)



  2. #2852
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Mr305
    Did any one ever experience a problem with Start?
    even if I press it once, it acts as if the button's pressed twice, breaking the loop!
    OR is my button faulty?
    I bet it comes from how you poll the button states.
    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.
    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;
    }
    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):
    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.

  3. #2853
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    how would i implement the anolog stick? like what function could i do to use the anolog stick to move my player?
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

  4. #2854
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Put this before your while(1) loop
    Code:
    		  	sceCtrlSetSamplingCycle(0);
    	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
    Then use this:
    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?

    Zitat Zitat von Abe
    Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
    http://forums.qj.net/501501-post26.html

  5. #2855
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    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,

    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;
                 }
    and i did define the statements above the while loop like,
    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
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

  6. #2856
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    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){}
    //up
    What did we think the world would look like in 2015?

    Zitat Zitat von Abe
    Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
    http://forums.qj.net/501501-post26.html

  7. #2857
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    ahh, i though so, thanks again!
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

  8. #2858
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    How do you read from ID3 tags ?

  9. #2859
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    is there a source code from a prx that take screenshots , because i have problems using the graphics.c+prx

  10. #2860
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    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


  11. #2861
    QJ Gamer Silver
    Points: 8.002, Level: 60
    Level completed: 26%, Points required for next Level: 148
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    The Matrix
    Beiträge
    1.090
    Points
    8.002
    Level
    60
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    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.
    cool!
    http://i28.tinypic.com/1znoljt.png
    lolololololol - Reach 100,000 Gamerscore

  12. #2862
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von BlackShark
    thanks very much for your help (also i was going to change the STATE names but thats what they really were, STATEs, so i just decided to keep them, but looks like i won't need alot of them much longer, thanks again!

    EDIT: alright this should be about the last question I but you with for now,
    but how would i go about making a 4 direction bullet system and how do I implement the analogue stick?

    -= Double Post =-



    Try defining this above your while loop...

    Code:
    int GetRandomNum(int lo, int hi) {
     SceKernelUtilsMt19937Context ctx;
     sceKernelUtilsMt19937Init(&ctx, time(NULL)); //SEED TO TIME
     u32 rand_val = sceKernelUtilsMt19937UInt(&ctx);
     rand_val = lo + rand_val % hi;
     return (int)rand_val;
    }
    Then call it like,

    Code:
    GetRandomNum(*INSERT # HERE* , *INSERT # HERE*)

    O yes, and MAKE SURE that you put

    Code:
    #include </usr/include/sys/stat.h>
    up were the rest of your #include's are let me know if this works for you.
    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?
    ...Just Returned To The Scene...

  13. #2863
    QJ Gamer Gold
    Points: 14.678, Level: 78
    Level completed: 57%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Beiträge
    1.523
    Points
    14.678
    Level
    78
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Raphael
    I bet it comes from how you poll the button states.
    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):
    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.
    All these Days, was wondering what Positive, negative -- and also that they were synonymous(the same)!
    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! ]

  14. #2864
    Developer
    Points: 12.154, Level: 72
    Level completed: 26%, Points required for next Level: 296
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Dubuque
    Beiträge
    423
    Points
    12.154
    Level
    72
    My Mood
    Lurking
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von Mr305
    What Does Peek do then (when Negative means, the buttons is pressed down currently)?
    sceCtrlPeekBufferPositive () just skips the vblank wait
    PSP Demo Videos (updated 11/29/08)
    MinerPSP Coder

  15. #2865
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    can anyone here define the functions "UnmapViewOfFile" and "CloseHandle" ?
    I need them...
    I have searched GOOGLE(most of them arent general C, WIN32)

  16. #2866
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Sure.

    Code:
    int UnmapViewOfFile()
    {
    return 0;
    }
    
    int CloseHandle()
    {
    return 0;
    }
    </sarcasm>

    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

  17. #2867
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    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.

  18. #2868
    QJ Gamer Gold
    Points: 14.678, Level: 78
    Level completed: 57%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Beiträge
    1.523
    Points
    14.678
    Level
    78
    Downloads
    0
    Uploads
    0

    Standard

    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);
    }
    .................
    }
    After sending the EBOOT 19th time for testing[after trying several variations], I am posting this...
    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)

  19. #2869
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    what would be the best way to read id3 tags in C?

  20. #2870
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    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


  21. #2871
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von psphacker12.
    what would be the best way to read id3 tags in C?

    google for id3 tag specs. find them, write your own lib.
    --------------------------------------------------------------------------------------

  22. #2872
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    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


  23. #2873
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    couldn't I just do...
    fseek (pFile , -128, SEEK_END);

  24. #2874
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    That's what writing your own lib for it means.

  25. #2875
    QJ Gamer Bronze
    Points: 4.912, Level: 44
    Level completed: 81%, Points required for next Level: 38
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    90
    Points
    4.912
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von psphacker12.
    couldn't I just do...
    fseek (pFile , -128, SEEK_END);
    yeah that would be fine for ID3v1. ID3v2 is a bit different though. Just follow everyone else's advice and google for the formats.

  26. #2876
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    ok i have a prob with my 3d object
    Spoiler for code of rotation:

    Code:
    	float inc_rate = 0.1f;
    	droney[1] += inc_rate;
    	float angle = droney[1]*(PI/180.0f);
    
    	
            dronexrot = (float)sin((angle+90.0f)*(PI/180.0f))*(0.02f);
    	dronezrot = (float)cos((angle+90.0f)*(PI/180.0f))*(0.02f)*-1;
    	dronex[1] = dronexrot;
    	dronez[1] = dronezrot;
    
    	float xtrans = -10-xpos+dronex[1];
    	float ztrans = -10-zpos+dronez[1];
    	float ytrans = -walkbias-0.45f-ypos;
    	float sceneroty = ((360.0f)*(PI/180.0f)) - ((yrot)*(PI/180.0f));
    	sceGumLoadIdentity();
            {
    		ScePspFVector3 move = {xtrans,ytrans, ztrans};
    		sceGumRotateX(lookupdown);
    		sceGumRotateY(sceneroty);
    		sceGumTranslate( &move );
    		sceGumRotateY(angle);
    
    	}

    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 work
    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

  27. #2877
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Mr305
    After sending the EBOOT 19th time for testing[after trying several variations], I am posting this...
    It works if it is used once in one loop, but above it doesn't seem to work!
    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):
    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;
    			}
    		}
    	}
    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).
    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.

  28. #2878
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von JaSo PsP
    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?
    Well? This has been completely ignored....
    ...Just Returned To The Scene...

  29. #2879
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von JaSo PsP
    Well? This has been completely ignored....
    Can't you just call rand() every time you want a new random value...?


  30. #2880
    QJ Gamer Gold
    Points: 14.678, Level: 78
    Level completed: 57%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Beiträge
    1.523
    Points
    14.678
    Level
    78
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Raphael
    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):
    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;
    			}
    		}
    	}
    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).
    danke sehr [I ain't no german!]
    Works like a charm!


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:27 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .