Seite 155 von 340 ErsteErste ... 55 105 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 205 255 ... LetzteLetzte
Zeige Ergebnis 4.621 bis 4.650 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; Either that, or the libs are in the wrong order. Edit: Too late....

  
  1. #4621
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Either that, or the libs are in the wrong order.

    Edit: Too late.



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

    @hello: These two implementations are equivalent:
    Code:
    char array[5][10];
    char x = array[4][7];
    Code:
    char array[5*10];
    char x = array[4*10 + 7];
    Now think how you would properly copy an array. Also, as a note, you don't have to copy the array if you just want to access the elements differently. In that case you could just create a pointer to the structure.
    Code:
    char array[x][y];
    char* array2 = array;
    array2[x*y-1] = 5; // same as array[x-1][y-1] = 5;
    Also, a char* array[x][y] is the same (in regards to memory usage and binary contents) as an int array[x][y], just that every int is actually a memory address (a pointer).
    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. #4623
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    and what about pointers
    ..
    char *array[4][4];
    char *array[16];
    ?
    It exactly the same. I am more concerned on why you would want to do this as there will be problems such as non NULL terminated strings which can lead to severe buffer overruns.
    -= Double Post =-
    Eg
    Code:
    char aString[16] "Hello World";
    char aString2[4][4];
    int k = 0;
    for( int i = 0; i < 4; i += 1 )
    {
        for( int j = 0; j < 4; j += 1, k +=1 )
        {
            aString2[i][j] = aString[k];
        }
    }
    
    printf( "%s", aString2[0] ); // Buffer overrun, C string not NULL terminated
    // Undefined behaviour. If you are lucky, it will just print out "Hello World"
    Geändert von yaustar (05-20-2007 um 07:00 AM Uhr) Grund: Automerged Doublepost

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

    Code:
    #include <stdio.h>
    
    int main()
    {
        char  *aString[4] = {"Hello World" , "nothing" , "nothing" , "nothing"};
        char *aString2[2][2];
        int k = 0;
        for( int i = 0; i < 4; i += 1 )
        {
             for( int j = 0; j < 4; j += 1, k +=1 )
             {
                  aString2[i][j] = aString[k];
                  }
        }
    
        printf( "%s", aString2[0][0] ); // Buffer overrun, C string not NULL terminated
        // Undefined behaviour. If you are lucky, it will just print out "Hello World"
        getchar();
    }
    this works fine for me:) , thnx;)

  5. #4625
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    Code:
    #include <stdio.h>
    
    int main()
    {
        char  *aString[4] = {"Hello World" , "nothing" , "nothing" , "nothing"};
        char *aString2[2][2];
        int k = 0;
        for( int i = 0; i < 4; i += 1 )
        {
             for( int j = 0; j < 4; j += 1, k +=1 )
             {
                  aString2[i][j] = aString[k];
                  }
        }
    
        printf( "%s", aString2[0][0] ); // Buffer overrun, C string not NULL terminated
        // Undefined behaviour. If you are lucky, it will just print out "Hello World"
        getchar();
    }
    this works fine for me:) , thnx;)
    Oh god. ... I just don't know what to say.....
    Remind me not to use any of your flashers.

  6. #4626
    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

    uh? whats wrong ?

  7. #4627
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    It's completely unsafe.

    http://en.wikipedia.org/wiki/Buffer_overflow - Read up.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  8. #4628
    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

    and what has that to do with my flasher :/ if i am asking something here , then i dindt tried it yet :/

  9. #4629
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Unsafe programming can lead to a myriad of problems, including writing the wrong data, writing too much data, security vulnerabilities, etc. If one of these problems affects a flasher...goodbye PSP!
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  10. #4630
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    If the quality of the code that you have shown here is the same as your flasher, then I dread to see what possible bugs exist in your flasher.

    Either way, the code that you have shown in that last snippet doesn't give me any confidence that any of your programs are 'safe'. This isn't much of a problem if it was a game or an application, but since you mostly write flashers, this kind of error can lead to a PSP brick.

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

    but i dindt use it in the app , but can you show mee how to mkae it safe?

  12. #4632
    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

    He never said you did use it in your flashers. He's saying that the quality of that last snippet you posted was unsafe/horrible, leading him to believe all of your code quality is unsafe/horrible, even the flashers you write.

    As for making it safe, you need some memory allocations, buffer overrun safeties (strncpy, strncat, snprintf,etc..) and seeing as how your using C++ (int i = 0 in for loop) Id use some of it's abilities
    Code:
    #include <iostream>
    
    int main() {
        const NUM_OF_ASTRING = 4,
              NUM_OF_ASTRING2 = 2;
    
        const std::string aString[NUM_OF_ASTRING] = {
                       "Hello World" , "nothing" , "nothing" , "anothing"
        };
    
        std::string aString2[NUM_OF_ASTRING2];
        
        for( int i = 0; i < NUM_OF_ASTRING2; i++ )
             for( int j = 0; j < NUM_OF_ASTRING; j++ )
                  aString2[i] = aString[j];
    
        std::cout << aString2[0] << aString2[1] << std::endl;
        
        system("PAUSE"); // you used 'getchar()' some im assuming your on PC
        
        return 0;
    }
    Now, im not 100% sure what it is you want to happen, as running your code spits out Hello World, no nothing, nothing, etc defeating the purpose of having the nothing's. This here spits out 'nothingnothing' AKA the last element in aString array because your 2 for loops (it sets aString2[0 & 1] to all 4 elements of aString array but over writes the last) Please elaborate on what you want it to do if this isnt 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


  13. #4633
    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

    I dont really understand that so i just going to explain for what i am goign to use it.
    I call a function that gets all file paths in a folder
    it will be stored to
    char *filePaths[200];

    now I want to use it and blit it to screen like a desktop
    so structured in
    X-as : 15 files
    y-as : 10 files
    (so 150 files)

    to make the code a bit more clearly and easy,I will store it in something like
    char *paths[15][10];
    -= Double Post =-
    nvm , i just had the change to chekc your cod
    this is exactly what I need
    Code:
    #include <iostream>
    
    int main() {
        const int NUM_OF_ASTRING = 4,
                  NUM_OF_ASTRING2 = 2;
        int z = 0;
    
        const std::string aString[NUM_OF_ASTRING] = {
                       "Hello World" , "nothing" , "nothing" , "anothing"
        };
    
        std::string aString2[2][2];
        
        for( int i = 0; i < 2; i++ )
             for( int j = 0; j < 2; j++ )
             {
                  aString2[i][j] = aString[z];
                  z++;
                  }
    
        std::cout << aString2[0][0] << " " << aString2[0][1] << std::endl;
        std::cout << aString2[1][0] << " " << aString2[1][1] << std::endl;
        
        system("PAUSE"); // you used 'getchar()' some im assuming your on PC
        
        return 0;
    }
    Geändert von hallo007 (05-20-2007 um 12:42 PM Uhr) Grund: Automerged Doublepost

  14. #4634
    QJ Gamer Blue
    Points: 4.031, Level: 40
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    c:\Program Files\World of Warcraft\WoW.exe
    Beiträge
    98
    Points
    4.031
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Hi guys. I posted a while back and got no responce to this.
    why doesn't this run?
    It does compile but whenever i try to run it, it just freezes up. (not a crash, a freeze)
    thanks for your help.

    Code:
    #include <pspdisplay.h>
    #include <stdlib.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <png.h>
    #include <stdio.h>
    #include <time.h>
    #include <psppower.h>
    #include <pspaudio.h>
    #include <pspaudiolib.h>
    #include "graphics.h"
    #include "mp3player.h"
    
    
    #define true 1
    #define false 0
    
    PSP_MODULE_INFO("DotsC v0.0.3 Alpha", 0, 0, 3);
    
    /* 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;
    }
    char *path[13] = { "Player.png",  //0
                   "Background.png",  //1
                   "Spot.png",        //2
                   "zero.png",        //3
                   "one.png",         //4
                   "two.png",         //5
                   "three.png",       //6
                   "four.png",        //7
                   "five.png",        //8
                   "six.png",         //9
                   "seven.png",       //10
                   "eight.png",       //11
                   "nine.png"};       //12
                   
    
    int main()
    {
    
        srand(time(NULL));
        pspDebugScreenInit();
        initGraphics();
        int spotx = rand()%(465);
        int spoty = rand()%(257);
        int x=0;
        int y=0;
        int Scoreo=0;
        int Scoret=0;
        int Scoreh=0;
        int Scoreth=0;
        SceCtrlData pad;
        Image* images[14];
        int i;
        for(i = 0; i > 13; i++)
        {
              images[i] = loadImage(path[i]);
              }
    
        while (1)
        {
    
              sceCtrlReadBufferPositive(&pad, 1);
      		  
              blitAlphaImageToScreen(0 ,0 ,32 , 32, images[0], x, y);
              blitAlphaImageToScreen(0 ,0 ,480 , 272, images[1], 0, 0);
              blitAlphaImageToScreen(0 ,0 ,16 , 16, images[2], spotx, spoty);
              blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoreo + 3], 50, 1);
              blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoret + 3], 35, 1);
              blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreh + 3], 20, 1);
              blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreth + 3], 5, 1);
    
    
              if (x + 32 > spotx && x < spotx + 16 && y + 32 > spoty && y < spoty + 16)
              {
                    Scoreo = Scoreo + 2;
                    spotx = rand()%(465);
                    spoty = rand()%(257);                
                    }
    
              if (Scoreo == 10)
              {
                         Scoreo = 0;
    		     Scoret++;
                         }
              if (Scoret == 10)
              {
                        Scoret = 0;
    		    Scoreh++;
                        }
              if (Scoreh == 10)
              {
                         Scoreh = 0;
    			         Scoreth++;
    				     }
    	  if (x < 0)
              {
    			   x = 0;
    			   }
              if (y < 0)
              {
    			   y = 0;
    			   }
    	  if (x > 448)
              {
                    x = 448;
    	        }
    	  if (y > 240)
              {
                    y = 240;
    		}
              
              if(pad.Buttons & PSP_CTRL_RIGHT)
              {
                      	x += 5;
                        }
    	  else if(pad.Buttons & PSP_CTRL_LEFT)
              {
                      	x -= 5;
                        }
    	  else if(pad.Buttons & PSP_CTRL_UP)
              {
                      	y -= 5;
                        }
    	  else if(pad.Buttons & PSP_CTRL_DOWN)
              {
                      	y += 5;
                        }
    	  else if(pad.Buttons & PSP_CTRL_START)
              {
    			sceKernelExitGame();
    			}
    	    		
    		  flipScreen();
     	 	  }
    
        sceKernelSleepThread();
        return 0;
    }
    makefile:
    Code:
    TARGET = Square_Game
    OBJS = main.o graphics.o framebuffer.o mp3player.o
    
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBDIR =
    LIBS = -lpspgu -lpng -lz -lm -lpsprtc -lmad -lpspaudiolib -lpspaudio -lpsppower
    LDFLAGS =
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = DotsC v0.0.3 Alpha
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak

  15. #4635
    QJ Gamer Green
    Points: 5.784, Level: 49
    Level completed: 17%, Points required for next Level: 166
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    France
    Beiträge
    753
    Points
    5.784
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    for(i = 0; i > 13; i++)
        {
              images[i] = loadImage(path[i]);
              }
    Shouldn't it be i < 13 ?

    ++ B.
    if I make mistakes in english, feel free to correct me or else i won't progress :D .

  16. #4636
    QJ Gamer Blue
    Points: 4.031, Level: 40
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    c:\Program Files\World of Warcraft\WoW.exe
    Beiträge
    98
    Points
    4.031
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    heh....
    thats funny.
    that guy tried to clean up my code, but he actually screwed it up... :)
    well, thanks to both of you anyway.
    yeah! it works!
    thanks a lot.

    my player wont move for some reason....

    my start button exit works....
    must be something with the graphics...

    dont i need a sceWaitVblankStart() in there somewhere?
    Geändert von Nicko01 (05-20-2007 um 02:39 PM Uhr)

  17. #4637
    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

    not sure, by all means it should, try loading any thing that has to move/sprites, normal way like,
    Image* playerimg = loadImage("./sprites/player.png");

    or something like that, im sure theres a work around for your problem so just wait till someone comes up with something better.....Zeegyboogydo
    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.

  18. #4638
    QJ Gamer Blue
    Points: 4.295, Level: 41
    Level completed: 73%, Points required for next Level: 55
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Homebrewland, CA
    Beiträge
    191
    Points
    4.295
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    This is what I have, try it out. BTW your indentation is horrible..
    Code:
    #include <pspdisplay.h>
    #include <stdlib.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <png.h>
    #include <stdio.h>
    #include <time.h>
    #include <psppower.h>
    #include <pspaudio.h>
    #include <pspaudiolib.h>
    #include "graphics.h"
    #include "mp3player.h"
    #define true 1
    #define false 0
    PSP_MODULE_INFO("DotsC v0.0.3 Alpha", 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;
    }
    char *path[13] = { "Player.png",  //0
                   "Background.png",  //1
                   "Spot.png",        //2
                   "zero.png",        //3
                   "one.png",         //4
                   "two.png",         //5
                   "three.png",       //6
                   "four.png",        //7
                   "five.png",        //8
                   "six.png",         //9
                   "seven.png",       //10
                   "eight.png",       //11
                   "nine.png"};       //12
    int main()
    {
    
        srand(time(NULL));
    	SetupCallbacks();
        pspDebugScreenInit();
        initGraphics();
        int spotx = rand()%(465);
        int spoty = rand()%(257);
        int x = 0;
        int y = 0;
        int Scoreo = 0;
        int Scoret = 0;
        int Scoreh = 0;
        int Scoreth = 0;
        SceCtrlData pad;
        Image* images[14];
        int i;
        for(i = 0; i < 13; i++)
        {
              images[i] = loadImage(path[i]);
        }
        while(1)
        {
        if (x + 32 > spotx && x < spotx + 16 && y + 32 > spoty && y < spoty + 16)
        {
            Scoreo = Scoreo + 2;
            spotx = rand()%(465);
            spoty = rand()%(257);                
        }
        if (Scoreo == 10)
        {
            Scoreo = 0;
    	    Scoret++;
        }
        if (Scoret == 10)
        {
    		Scoret = 0;
    		Scoreh++;
        }
        if (Scoreh == 10)
        {
            Scoreh = 0;
    		Scoreth++;
    	}
    	if (x < 0){x = 0;}
        if (y < 0){y = 0;}
    	if (x > 448){x = 448;}
    	if (y > 240){y = 240;}
        sceCtrlReadBufferPositive(&pad, 1);
        if(pad.Buttons & PSP_CTRL_RIGHT){x += 5;}
    	if(pad.Buttons & PSP_CTRL_LEFT){x -= 5;}
    	if(pad.Buttons & PSP_CTRL_UP){y -= 5;}
    	if(pad.Buttons & PSP_CTRL_DOWN){y += 5;}
    	//image loop- I don't know if your character array is correct, didn't look.  If if is correct this should work.
    	blitAlphaImageToScreen(0 ,0 ,32 , 32, images[0], x, y);
        blitAlphaImageToScreen(0 ,0 ,480 , 272, images[1], 0, 0);
        blitAlphaImageToScreen(0 ,0 ,16 , 16, images[2], spotx, spoty);
        blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoreo + 3], 50, 1);
        blitAlphaImageToScreen(0, 0, 15 ,15, images[Scoret + 3], 35, 1);
        blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreh + 3], 20, 1);
        blitAlphaImageToScreen(0 ,0 ,15 ,15, images[Scoreth + 3], 5, 1);    		
    	flipScreen();
     	}
        sceKernelSleepThread();
        return 0;
    }

  19. #4639
    QJ Gamer Green
    Points: 8.459, Level: 62
    Level completed: 3%, Points required for next Level: 291
    Overall activity: 32,0%

    Registriert seit
    Apr 2007
    Beiträge
    886
    Points
    8.459
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    I want to load recovery menu from a prx with an eboot. heres my code:

    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspdisplay.h>
    #include <pspsdk.h>
    #include <string.h>
    #include <pspctrl.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    PSP_MODULE_INFO("LAUNCH_RECOV", 0x1000, 1, 1);
    
    PSP_MAIN_THREAD_ATTR(0);
    
    
    #define printf	pspDebugScreenPrintf
    
    
    int exit_callback(int arg1, int arg2, void *arg)
    {
    	sceKernelExitGame();
    
    	return 0;
    }
    
    
    void CallbackThread(void *arg)
    {
    	int cbid;
    
    	cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
    	sceKernelRegisterExitCallback(cbid);
    
    	sceKernelSleepThreadCB();
    }
    
    
    int SetupCallbacks(void)
    {
    	int thid = 0;
    
    	thid = sceKernelCreateThread("update_thread", (void*) CallbackThread, 0x11, 0xFA0, 0xa0000000, 0);
    	if(thid >= 0)
    	{
    		sceKernelStartThread(thid, 0, 0);
    	}
    
    	return thid;
    }
    
    void restart()
    {
    	sceKernelExitGame();
    }
    
    SceUID load_module(const char *path, int flags, int type)
    {
    	SceKernelLMOption option;
    	SceUID mpid;
    
    	if (type == 0) {
    		mpid = 1;
    	} else {
    		mpid = 2;
    	}
    
    	memset(&option, 0, sizeof(option));
    	option.size = sizeof(option);
    	option.mpidtext = mpid;
    	option.mpiddata = mpid;
    	option.position = 0;
    	option.access = 1;
    
    	return sceKernelLoadModule(path, flags, type > 0 ? &option : NULL);
    }
    
    
    void *getModuleInfo(void);
    
    int main(void)
    {
    	SceUID modid;
    	SceModule *mod;
    
    	pspDebugScreenInit();
    
    
    	pspDebugInstallKprintfHandler(NULL);
    	pspDebugInstallErrorHandler(NULL);
    	pspDebugInstallStdoutHandler(pspDebugScreenPrintData);
    	pspSdkInstallNoPlainModuleCheckPatch();
    	SetupCallbacks();
    
    while (1)
    	{
    	SceCtrlData pad; sceCtrlPeekBufferPositive(&pad, 1);
    	
        if (pad.Buttons & PSP_CTRL_WLAN_UP){
        modid = load_module("ms0:/recovery.prx", 0, 0);
    }
    
        else {
        sceKernelExitGame();
    }	
    
    		sceKernelExitDeleteThread(0);
    }
    	return 0;
    }
    when I run the app this appears on my psp screen
    Code:
    stdio.c : stdoutReopen : id=0x00000001
    stdio.c : stdoutReopen : id=0x00000002
    obviously there is an error loading the prx but i cant see why. please help

  20. #4640
    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

    Code:
    #ifndef DESKTOP_H
    #define DESKTOP_H
    
    #include <stdlib.h>
    #include <malloc.h>
    #include <pspdisplay.h>
    #include <psputils.h>
    #include <png.h>
    #include <pspgu.h>
    #include <string.h>
    #include "../main.h"
    #include "../graphics/graphics.h"
    
    #define imageDrawAlpha blitImage
    #define START 0
    #define BALK  1
    #define IMAGE_ICON 2
    #define EXE_ICON 3
    #define FLASH_ICON 4
    #define PSPFILE_ICON 5
    #define AUDIO_ICON 6
    #define UNKNOW_ICON 7
    #define THISPSP_ICON 8
    #define TEXT_ICON 9
    #define FOLDER_ICON 10
    
    int mainMenu(SceSize args, void *argp);
    
    #endif
    since i went over to c++ i have a problem with includes , if the first .o includes a header , it wont be anymore included by the second and it says , undeclarded :-S

  21. #4641
    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

    extern "C" {
    #include "_Headers_here_"
    }

  22. #4642
    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

    That wasnt the problem , i did that in the headers , no i was forgotten to set up some macro's that i always use , nvm

  23. #4643
    QJ Gamer Blue
    Points: 4.031, Level: 40
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 91,0%

    Registriert seit
    Feb 2007
    Ort
    Florida
    Beiträge
    214
    Points
    4.031
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Oh god.

    Whenever I compile anything, it will come up with the error:

    main.cpp: UNDEFINED REFRENCE OF [variable_name] AT C:/[Location_name].

    I searced it, and at the location it spits at me, it shows no reference, and there is no refrence, anyone know what the problem is? (Let me guess...I coded the program wrong?)


    EDIT: I tried to compile a hello world, just to make sure, and it gave me the same error...

  24. #4644
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Post the code.

  25. #4645
    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

    Oh, alow! :ROFL:

    Will passing variables as arguments instead of direct arguements add overhead time just like functions do when called? [Donot say -- it's a tenth-tenth of a sec or something a& it doesn't matter] --- IT does for me, that time is so valuable for me...

    My assumption is, it doesn't make a difference because even the direct argument as well as a variable reside in some memory location --- which the function has to fetch... Am I right?

    ------

    I am so concerned becz the variable changes every once per function call, in that function a lot of sub functions use this variable....

  26. #4646
    QJ Gamer Blue
    Points: 4.031, Level: 40
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 91,0%

    Registriert seit
    Feb 2007
    Ort
    Florida
    Beiträge
    214
    Points
    4.031
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    Post the code.
    Code:
     
    
    #include <pspkernel.h>
    #include <pspdebug.h>
    
    PSP_MODULE_INFO("Test Hello World:, 0, 1, 1);
    #define printf pspDebugScreenPrintf
    
    /* I don't want to post callbacks here, takes to much space up, but they ARE in my code */
    
    int main() {
    SetupCallbacks();
    pspDebugScreenInit();
    
    printf("Test Hello World.");
    sceKernelSleepThread();
    return 0;
    }
    Like I said, I used a hello world for a test.

    It gives me the error of the refrence of SetupCallbacks();

  27. #4647
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von MrChaos
    [code]// Some stuff
    Show ALL the code ¬¬
    -= Double Post =-
    Zitat Zitat von Mr305
    Oh, alow! :ROFL:

    Will passing variables as arguments instead of direct arguements add overhead time just like functions do when called? [Donot say -- it's a tenth-tenth of a sec or something a& it doesn't matter] --- IT does for me, that time is so valuable for me...

    My assumption is, it doesn't make a difference because even the direct argument as well as a variable reside in some memory location --- which the function has to fetch... Am I right?

    ------

    I am so concerned becz the variable changes every once per function call, in that function a lot of sub functions use this variable....
    Depends on a large number of factors.
    Are you passing by pointer?
    Are you passing by reference?
    Are you passing by value?
    What type are the objects being passed?
    What do you mean by direct argurements?
    Do you have the code in question to post up?
    Geändert von yaustar (05-22-2007 um 01:40 PM Uhr) Grund: Automerged Doublepost

  28. #4648
    QJ Gamer Blue
    Points: 4.031, Level: 40
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 91,0%

    Registriert seit
    Feb 2007
    Ort
    Florida
    Beiträge
    214
    Points
    4.031
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    Show ALL the code ¬¬
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    
    PSP_MODULE_INFO("Test Hello World", 0, 1, 1);
    #define printf pspDebugScreenPrintf
    
    /* 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();
    
    printf("Test Hello World.");
    sceKernelSleepThread();
    return 0;
    }
    makefile

    Code:
    TARGET = hello
    OBJS = main.cpp
    
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Hello World Test
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak

  29. #4649
    QJ Gamer Green
    Points: 5.712, Level: 48
    Level completed: 81%, Points required for next Level: 38
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    USA SC/NC
    Beiträge
    699
    Points
    5.712
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von MrChaos
    Code:
     
    
    #include <pspkernel.h>
    #include <pspdebug.h>
    
    PSP_MODULE_INFO("Test Hello World:, 0, 1, 1);
    #define printf pspDebugScreenPrintf
    
    /* I don't want to post callbacks here, takes to much space up, but they ARE in my code */
    
    int main() {
    SetupCallbacks();
    pspDebugScreenInit();
    
    printf("Test Hello World.");
    sceKernelSleepThread();
    return 0;
    }
    Like I said, I used a hello world for a test.

    It gives me the error of the refrence of SetupCallbacks();
    1.) PSP_MODULE_INFO("Test Hello World:, 0, 1, 1);
    See the error?

    2.) It gives me the error of the refrence of SetupCallbacks();
    Undefined reference to the function SetupCallbacks.
    It will give you that error if you remove the callbacks from the program, and try to call a nonexistent function. Just remove SetupCallbacks(); or put the callbacks in.
    [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]

  30. #4650
    QJ Gamer Blue
    Points: 4.031, Level: 40
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 91,0%

    Registriert seit
    Feb 2007
    Ort
    Florida
    Beiträge
    214
    Points
    4.031
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    yaustar, I tried again, and heres the errors:

    /cygdrive/c/DOCU~1/Owner/LOCALS~1/Temp/cc2wayHC.o.eh_frame+0x11): undefined reference to '__gxx_personality_v0'

    Moca: Yeah, I saw that, and fixed it.
    Moca: I removed the callbacks and SetupCallbacks();...no help.


 

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 .