Seite 42 von 340 ErsteErste ... 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 92 142 ... LetzteLetzte
Zeige Ergebnis 1.231 bis 1.260 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; You need that doc thingy thing for the pspsdk to install the docs though......

  
  1. #1231
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    You need that doc thingy thing for the pspsdk to install the docs though...




    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  2. #1232
    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

    To answer a few off the last posts....

    Doxygen is that doc thingy ;)

    'remove' or 'unlink' works fine.

    The sceIo* functions are in at least one sample, see samples/kernel/fileio for one.

    I'd recommend using the newlib variants though over the SDK versions.

    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

  3. #1233
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    hmm, what is newlib? Google doesn't really say much on this

  4. #1234
    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

    http://en.wikipedia.org/wiki/Newlib

    When I say newlib variants, I mean the regular stdio functions, see here:

    http://www.cplusplus.com/ref/cstdio/

    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

  5. #1235
    Developer
    Points: 19.136, Level: 87
    Level completed: 58%, Points required for next Level: 214
    Overall activity: 33,0%

    Registriert seit
    Dec 2005
    Beiträge
    1.899
    Points
    19.136
    Level
    87
    Downloads
    0
    Uploads
    0

    Standard

    Can any one tell me what sceAudioOutputPannedBlock ing dose exacly

    it is not documented and am currently using sceAudioOutputPanned for audio out, and need to now play longer sample files and was looking at this funtion sceAudioOutputPannedBlock ing and needed to know what it ment exacly by blocking.

  6. #1236
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Thanks Inso

    Another short question, hope I'm not beginning to get on yer nerves:

    Can you only free() variables that have been declared using xalloc? And, I'm pretty sure it is the case, but just wanna -know- it - do (non-static) variables get freed automatically at the end of a function?

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

    You can only free allocated memory yes.

    Variables declared within a function only exist until that function ends.

    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

  8. #1238
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    You can only free allocated memory yes.
    Thanks
    Variables declared within a function only exist until that function ends.
    By now I find my question more than embarrassing.

  9. #1239
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    hehe i also had a few errors because of variables inside functions hehe

  10. #1240
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    question on fgets: I read a file artists.txt which contains:

    1234567890
    A perfect Circle
    using this code

    Code:
    	FILE *f = fopen("artists.txt", "r");
    	fgets(timestamp, 16, f);
    	fclose (f);
    timestamp then contains "1234567890"

    How do I get rid of that last symbol?

    PS: I wrote that file using windows, is that symbol probably a fragment of the widows-carriage-return?

  11. #1241
    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

    Yeah I seem to remember it's the \r or something.

    Instead of saving the end of line as ending \n, it's saved as \r\n, or something like that.

    Try it with a different editor, I seem to remember that one of the native Windows applications saves it how we need it.

    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

  12. #1242
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    it is a command to go to the next lin i think you can hex edit it away

  13. #1243
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I am confused; I'm trying to send a list of artists that I read from a file via TCP to the PSP and save it there as a file again. The problem is, the transferred list isn't complete. Im having length-outputs in the server and the client, but it confuses me even more:

    Server Code (read file and send string-length and contents):
    Code:
    		pFile = fopen ( "artists.txt" , "rb" );
    		fseek (pFile , 0 , SEEK_END);
    		lSize = ftell (pFile);
    		rewind (pFile);
    		buffer = (char*) malloc (lSize); 
    		fread (buffer,1,lSize,pFile);
    		fclose (pFile);
    
    		printf("Sending artist-list-length (");
    		sprintf(answer_l, "%i", strlen(buffer));
    		printf("%s)\n", answer_l);
    		rc=send(sock,answer_l,strlen(answer_l),0);
    
    		printf("Sending list of artists...\n");
    		if (rc=send(sock,buffer,strlen(buffer),0) != strlen(buffer)) {
    			printf("send different lenghts; buffer=%i rc=%i\n", strlen(buffer), rc);
    		}
    
    		printf("sizeof(buf)=%i strlen(buf)=%i rc=%i\n", sizeof(buffer), strlen(buffer), rc);
    Client code (recive length and contents and write to file):
    Code:
    		if((rc = recv(socket, artist_list_length_c, 8,0)) < 0) {
    			printf("Error while recieving the artist-list-length; error-code: %s\n",strerror(errno));
    			return 0;
    		}
    		if(rc==0) {
    			printf("Client has closed the connection before sending the artist-list-length\n");
    			return 0;
    		}
    
    		artist_list_length_c[rc]='\0';
    		artist_list_length = atoi(artist_list_length_c);
    		artist_list_length++;
    
    		char buf[artist_list_length];
    
    
    		// Recieve artist-list
    		rc = recv(socket,buf,artist_list_length,0);
    		if(rc==0)
    		{
    			printf("Server has closed the connnection before sending the artist-list\n");
    			return 0;
    		}
    		if(rc==SOCKET_ERROR)
    		{
    			printf("Error: recv, error-code: %s\n",strerror(errno));
    			return 0;
    		}
    		buf[rc]='\0';
    
    		printf("sizeof(buf)=%i strlen(buf)=%i\n", sizeof(buf), strlen(buf));
    
    		f = fopen("artists.txt", "w+");
    		fprintf(f, "%s\n%s", timestamp_server, buf);
    		fclose(f);
    The Server output is:
    Sending artist-list-length (5180)
    Sending list of artists...
    sizeof(buf)=4 strlen(buf)=5180 rc=0
    The Client output is:
    sizeof(buf)=5181 strlen(buf)=1448
    I'm really confused

    PS: I checked the file on the PSP and visually judging it, it could be ~1448 chars
    -= Double Post =-
    Is there probalby a maximum length in send or recieve?
    -= Double Post =-
    Ok, I'll just accept that it doesn't work with such a long string (probably because you can't send a string longer than 1448 chars) so I'll have to split it. Does anyone know how to do this (split a string at X bytes)?
    -= Double Post =-
    Nevermind, it's easy to split strings.. afer all it's an array so that'll be no problem
    -= Double Post =-
    Can you somewhere find out what the current MTU is?
    -= Double Post =-
    The german wikipedia says typical MTU for ethernet is 1500... that could be it!

    However I thought the socket would do the MTU/splitting-job?!
    Geändert von Lukeson (10-12-2006 um 09:25 AM Uhr) Grund: Automerged Doublepost

  14. #1244
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    However I thought the socket would do the MTU/splitting-job?!
    Apparently not
    I don't know much about network/wifi coding so I won't be able to help


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  15. #1245
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    СУ&am from psp-programming.com answered this issue. You can send any length of bytes but that doesn't mean that you'll recieve it as one chunk. You have to use a loop and recive until recv returns 0.
    -= Double Post =-
    ...but that doesn't mean it's the end of troubles! The output now is
    sizeof(recievedMessage)=5 181 strlen(recievedMessage)=8101
    and in the middle of the file there's a line like
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ[...a thousand more...]ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ
    no idea why
    -= Double Post =-
    ^^ I forgot the code:
    Code:
    		printf("waiting to recieve artists\n");
    		// Recieve artist-list-length
    		if((rc = recv(socket, artist_list_length_c, 8,0)) < 0) {
    			printf("Error while recieving the artist-list-length; error-code: %s\n",strerror(errno));
    			return 0;
    		}
    		if(rc==0) {
    			printf("Client has closed the connection before sending the artist-list-length\n");
    			return 0;
    		}
    
    		artist_list_length_c[rc]='\0';
    		artist_list_length = atoi(artist_list_length_c);
    		artist_list_length++;
    
    		char recievedMessage[artist_list_length];
    		char buf[artist_list_length];
    
    
    		// Recieve artist-list
    		while(rc!=SOCKET_ERROR)
    		{
    			rc = recv(socket,buf,artist_list_length,0);
    			if(rc==0)
    			{
    				printf("Server stopped sending\n");
    				break;
    			}
    			if(rc==SOCKET_ERROR)
    			{
    				printf("Error: recv, error-code: %s\n",strerror(errno));
    				break;
    			}
    			buf[rc]='\0';
    			strcat(recievedMessage, buf);
    		}
    		//recievedMessage[artist_list_length]='\0';
    
    		printf("sizeof(recievedMessage)=%i strlen(recievedMessage)=%i\n", sizeof(recievedMessage), strlen(recievedMessage));
    
    		f = fopen("artists.txt", "w+");
    		fprintf(f, "%s\n%s", timestamp_server, recievedMessage);
    		fclose(f);
    Geändert von Lukeson (10-12-2006 um 11:27 AM Uhr) Grund: Automerged Doublepost

  16. #1246
    QJ Gamer Blue
    Points: 4.831, Level: 44
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    Michigan
    Beiträge
    211
    Points
    4.831
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Im trying to make my second actual program using this guide but I don't know what's wrong with my code. The guide isnt specific on where to put each string of code. Can someone help me out by re arranging my code so it works and just telling me what I did wrong please?
    Code:
    #include <pspdebug.h>
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    
    
    PSP_MODULE_INFO("Counter", 0, 1, 1);
    
    /* Exit callback */
    int exit_callback(int arg1, int arg2, void *common) {
              sceKernelExitGame();
              return 0;
    }
    
    /* Callback thread */
    int CallbackThread(SceSize args, void *argp) {
              int cbid;
              cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
              sceKernelRegisterExitCallback(cbid);
              sceKernelSleepThreadCB();
              return 0;
    }
    
    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
              int thid = 0;
              thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
              if(thid >= 0) {
                        sceKernelStartThread(thid, 0, 0);
              }
              return thid;
    }
    
    int main() {
        SetupCallbacks();
    int counter = 0;
    int i = 0;
        SceCtrlData pad;
        printf("Press [X] To Start the Timer");
        while(1) {
        sceCtrlReadBufferPositive(&pad, 1);
        if(pad.Buttons & PSP_CTRL_CROSS) {
                    break;
              }
    }
         while(1) {
              sceCtrlReadBufferPositive(&pad, 1);
              if(pad.Buttons & PSP_CTRL_CIRCLE) {
                        break;
              } 
        pspDebugScreenInit();
        pspDebugScreen
        sceKernelSleepThread();
        printf("Press [O] To Stop the Timer\n");
        printf("Counter: %i", counter);
        counter++;
        for(i=0; i<5; i++) {
                        sceDisplayWaitVblankStart();
              }
        pspDebugScreenClear();
        printf("Counter Finished.");
        printf("Final Count: %i", counter);
        return 0;
    }
    Geändert von Nolimitsdude313 (10-12-2006 um 11:32 AM Uhr) Grund: Automerged Doublepost

  17. #1247
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    I'm trying to port my first C game to PSP. It's a very simple game, only like 2 pages of code. But I need to know the equivelent of fflush(); on the PSP. Does anyone know? Also, how do I make the PSP wait for any button to be pressed, then continue?

  18. #1248
    QJ Gamer Blue
    Points: 4.831, Level: 44
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    Michigan
    Beiträge
    211
    Points
    4.831
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    This guide explains how to make the psp wait for the button to be pressed. :)

  19. #1249
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nolimitsdude313
    This guide explains how to make the psp wait for the button to be pressed. :)
    OK, I see now. Now I just need my other question answered.

  20. #1250
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    But I need to know the equivelent of fflush(); on the PSP.
    psp-programming.com says there is fflush() in the PSPSDK...

  21. #1251
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Yeah, the sdk has newlib. So fflush should be the same as on a Pc.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  22. #1252
    QJ Gamer Blue
    Points: 4.831, Level: 44
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    Michigan
    Beiträge
    211
    Points
    4.831
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nolimitsdude313
    Im trying to make my second actual program using this guide but I don't know what's wrong with my code. The guide isnt specific on where to put each string of code. Can someone help me out by re arranging my code so it works and just telling me what I did wrong please?
    Code:
    #include <pspdebug.h>
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    
    
    PSP_MODULE_INFO("Counter", 0, 1, 1);
    
    /* Exit callback */
    int exit_callback(int arg1, int arg2, void *common) {
              sceKernelExitGame();
              return 0;
    }
    
    /* Callback thread */
    int CallbackThread(SceSize args, void *argp) {
              int cbid;
              cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
              sceKernelRegisterExitCallback(cbid);
              sceKernelSleepThreadCB();
              return 0;
    }
    
    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
              int thid = 0;
              thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
              if(thid >= 0) {
                        sceKernelStartThread(thid, 0, 0);
              }
              return thid;
    }
    
    int main() {
        SetupCallbacks();
    int counter = 0;
    int i = 0;
        SceCtrlData pad;
        printf("Press [X] To Start the Timer");
        while(1) {
        sceCtrlReadBufferPositive(&pad, 1);
        if(pad.Buttons & PSP_CTRL_CROSS) {
                    break;
              }
    }
         while(1) {
              sceCtrlReadBufferPositive(&pad, 1);
              if(pad.Buttons & PSP_CTRL_CIRCLE) {
                        break;
              } 
        pspDebugScreenInit();
        pspDebugScreen
        sceKernelSleepThread();
        printf("Press [O] To Stop the Timer\n");
        printf("Counter: %i", counter);
        counter++;
        for(i=0; i<5; i++) {
                        sceDisplayWaitVblankStart();
              }
        pspDebugScreenClear();
        printf("Counter Finished.");
        printf("Final Count: %i", counter);
        return 0;
    }
    Still need help with this

  23. #1253
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Does anyone have an idea why my psp freezes? http://forums.qj.net/f-psp-developme...ml#post1100739
    Sorry for the nagging, but in this 1-thread-'solution' things are being forgotten so easily when they are not on the last page anymore
    -= Double Post =-
    Code:
        for(i=0; i<5; i++) {
                        sceDisplayWaitVblankStart();
              }
        pspDebugScreenClear();
        printf("Coun
    Missing a }, check the tutorial
    Geändert von Lukeson (10-12-2006 um 11:57 AM Uhr) Grund: Automerged Doublepost

  24. #1254
    QJ Gamer Platinum
    Points: 57.528, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    h0000000rj
    Beiträge
    12.867
    Points
    57.528
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nolimitsdude313
    Code:
    int main() {
        SetupCallbacks();
    int counter = 0;
    int i = 0;
        SceCtrlData pad;
        printf("Press [X] To Start the Timer");
        while(1) {
        sceCtrlReadBufferPositive(&pad, 1);
        if(pad.Buttons & PSP_CTRL_CROSS) {
                    break;
              }
    }
         while(1) {
              sceCtrlReadBufferPositive(&pad, 1);
              if(pad.Buttons & PSP_CTRL_CIRCLE) {
                        break;
              } 
        pspDebugScreenInit();
        pspDebugScreen
        sceKernelSleepThread();
        printf("Press [O] To Stop the Timer\n");
        printf("Counter: %i", counter);
        counter++;
        for(i=0; i<5; i++) {
                        sceDisplayWaitVblankStart();
              }
        pspDebugScreenClear();
        printf("Counter Finished.");
        printf("Final Count: %i", counter);
        return 0;
    }
    Here's the problem: You're using printf before pspDebugScreenInit(). You have to call this before doing anything with the output screen. Also, you have
    Code:
        pspDebugScreenInit();
        pspDebugScreen
        sceKernelSleepThread();
    The second line is an incomplete command, and the third one needs an argument (the number of microseconds to sleep - e.g. 1000000 = 1 second). There might be more, but that's what I saw at a brief glance.
    [I fail @ life]

  25. #1255
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Pretty sure this should work
    Code:
    #include <pspdebug.h>
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    
    #define printf pspDebugScreenPrintf
    
    PSP_MODULE_INFO("Counter", 0, 1, 1);
    
    /* Exit callback */
    int exit_callback(int arg1, int arg2, void *common) {
              sceKernelExitGame();
              return 0;
    }
    
    /* Callback thread */
    int CallbackThread(SceSize args, void *argp) {
              int cbid;
              cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
              sceKernelRegisterExitCallback(cbid);
              sceKernelSleepThreadCB();
              return 0;
    }
    
    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
              int thid = 0;
              thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
              if(thid >= 0) {
                        sceKernelStartThread(thid, 0, 0);
              }
              return thid;
    }
    
    int main() {
        SetupCallbacks();
        
        pspDebugScreenInit();
        
        int counter = 0;
        int i = 0;
        SceCtrlData pad;
        printf("Press [X] To Start the Timer");
        while(1) {
          sceCtrlReadBufferPositive(&pad, 1);
          if(pad.Buttons & PSP_CTRL_CROSS) {
            break;
          }
        }
        while(1) {
          sceCtrlReadBufferPositive(&pad, 1);
          if(pad.Buttons & PSP_CTRL_CIRCLE) {
            break;
          } 
           
          pspDebugScreenClear();
          printf("Press [O] To Stop the Timer\n");
        	printf("Counter: %i", counter);
        	counter++;
        	for(i=0; i<5; i++) {
          	sceDisplayWaitVblankStart();
        	}
        }
        pspDebugScreenClear();
        printf("Counter Finished.");
        printf("Final Count: %i", counter);
        return 0;
    }
    EDIT: You never defined printf either, I believe that could cause some problems.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  26. #1256
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    The correct version would be
    Code:
        for(i=0; i<5; i++) {
                        sceDisplayWaitVblankStart();
              }
        }
        pspDebugScreenClear();
        printf("Coun
    -= Double Post =-
    PS http://forums.qj.net/f-psp-developme...ml#post1100739
    Geändert von Lukeson (10-12-2006 um 12:07 PM Uhr) Grund: Automerged Doublepost

  27. #1257
    QJ Gamer Blue
    Points: 4.831, Level: 44
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    Michigan
    Beiträge
    211
    Points
    4.831
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Thanks, homer. That worked perfectly :) I have a feeling I will need to use this thread often now that I am getting started with programming. Thanks for your help.

  28. #1258
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nolimitsdude313
    Thanks, homer. That worked perfectly :) I have a feeling I will need to use this thread often now that I am getting started with programming. Thanks for your help.
    Don't overuse it though. You learn alot more by trying to solve your problems yourself *wink to Lukeson*


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  29. #1259
    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

    Zitat Zitat von FreePlay
    ...and the third one needs an argument (the number of microseconds to sleep - e.g. 1000000 = 1 second).
    You're getting your functions mixed up.

    sceKernelSleepThread() requires no arguments and puts the thread to sleep. sceKernelDelayThread(x) will delay the thread for x amount of microseconds (1000000 microseconds in a second).

    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

  30. #1260
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    http://forums.qj.net/f-psp-developme...ml#post1100739
    Sorry again for reposting this, it's just this one-thread-solution sucks so hard, everything that's not on the last page is just lost :?

    -= Double Post =-

    I commented out lines and found out the PSP freezes due to strcat(recievedMessage, buf); (recieved message has the size 5181 and the strlen 8101 (can somebody tell me why?), for some reason the PSP doesn't freeze whe cat-ing the string, but when exiting the function (=when trying to free recievedMessage?). Does anyone have an idea how to fix this? How would you merge the parts of the string?
    -= Double Post =-
    Ok, the problem again was that recievedMessage was initialized but not declared... .
    Geändert von Lukeson (10-13-2006 um 12:12 PM Uhr) Grund: Automerged Doublepost


 

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:15 PM Uhr.

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