Seite 80 von 340 ErsteErste ... 30 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 130 180 ... LetzteLetzte
Zeige Ergebnis 2.371 bis 2.400 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 head_54us I still think he is under allocating as he is explictly allocating 4 bytes for the string ...

  
  1. #2371
    Developer
    Points: 7.058, Level: 55
    Level completed: 54%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    408
    Points
    7.058
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    I still think he is under allocating as he is explictly allocating 4 bytes for the string whereas

    char * text = "dslkfljsf";

    Would be fine.
    You may be right, but I'm pretty sure that as long as he doesn't try to modify the contents, it should work. I'd think the compiler would raise warnings if it wasn't valid. Apparently that's not the case.



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

    Code:
    if (ourImage) {
    //Image load unsuccessful
    printf("Image Load Unsuccessful! \n")
    } else
    Missing ; at the end of the code line. Should be
    Code:
    if (ourImage) {
    //Image load unsuccessful
    printf("Image Load Unsuccessful! \n");
    } else
    -= Double Post =-
    Zitat Zitat von Samstag
    You may be right, but I'm pretty sure that as long as he doesn't try to modify the contents, it should work. I'd think the compiler would raise warnings if it wasn't valid. Apparently that's not the case.
    Code:
    char Nuts[4] = "defg";
    This threw up a compiler error on DevKitPSP. I am surprised it was okay on that code was posted up. Maybe it was with the older PSPDEV SDK?
    Geändert von yaustar (12-17-2006 um 03:46 PM Uhr) Grund: Automerged Doublepost

  3. #2373
    Developer
    Points: 7.058, Level: 55
    Level completed: 54%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    408
    Points
    7.058
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us[code
    char Nuts[4] = "defg";[/code]
    This threw up a compiler error on DevKitPSP. I am surprised it was okay on that code was posted up. Maybe it was with the older PSPDEV SDK?
    That should be a GCC issue rather than being PSP-specific, but I guess it's possible an older psp-gcc let that through. Maybe the original poster only got a warning and didn't mention it? I don't see a lot of people posting warnings when they ask for help (heck, I know professionals who might ignore a warning if they don't see an immediate problem).

  4. #2374
    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 Samstag
    That should be a GCC issue rather than being PSP-specific, but I guess it's possible an older psp-gcc let that through. Maybe the original poster only got a warning and didn't mention it? I don't see a lot of people posting warnings when they ask for help (heck, I know professionals who might ignore a warning if they don't see an immediate problem).
    Possibly. It does seem odd behaviour from the compiler though.

    Where I work, we don't get that luxury, all warnings are treated as errors in our builds.

  5. #2375
    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 head_54us
    Code:
    if (ourImage) {
    //Image load unsuccessful
    printf("Image Load Unsuccessful! \n")
    } else
    Missing ; at the end of the code line. Should be
    Code:
    if (ourImage) {
    //Image load unsuccessful
    printf("Image Load Unsuccessful! \n");
    } else
    Thanks a lot. I always make those kinds of mistakes :P.
    It is either a spelling or one of those:ROFL: . Other than that, my code is usually fine.
    [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]

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

    Moca - I somehow doubt your priorexperience in C++ if you dont understandone of the msot common of errors the compiler spits out. But, i may be wrong and you just have never encountered such an error, but it doesnt matter in the end (although the error is self explanatory)

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


  7. #2377
    Points: 3.593, Level: 37
    Level completed: 62%, Points required for next Level: 57
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Beiträge
    11
    Points
    3.593
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Samstag
    That should be a GCC issue rather than being PSP-specific, but I guess it's possible an older psp-gcc let that through. Maybe the original poster only got a warning and didn't mention it? I don't see a lot of people posting warnings when they ask for help (heck, I know professionals who might ignore a warning if they don't see an immediate problem).
    Nope, I would have caught it if there was an error. I am almost sure my compiler did not issue an error, but I might be wrong. I am using cygwin by the way.

    EDIT: I tested it out agian, char test1 [4] = "1000"; made my glitch that I posted previously, but had no warnings in cgywin. char test1 [1] = "1000";, however, made a warning

    Anywho, I ran into another problem; how do I split a string into multiple parts in C?

    ex:
    char test[8] = "Test";

    How would I break apart the string into individual charactors (T, e, s, and t)? I want to use something like "if the second letter of string test equals e, then"

    And is there a command to determine the length of the string? Does something like length(test) exist? (I don't want the length of the array of characters, I just want the length of the string held by test, which is "Test", which should be 4)

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

    zwnage - It already is. A string is an array of characters, and your asking for how to get a character.

    Simply provide the argument/parameter with whatever element the charactere is in.

    ex:

    char Test[8] = "Test";

    if (Test[1] == 'e') { this will execute }

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


  9. #2379
    Developer
    Points: 7.058, Level: 55
    Level completed: 54%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    408
    Points
    7.058
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von zwnage
    And is there a command to determine the length of the string? Does something like length(test) exist? (I don't want the length of the array of characters, I just want the length of the string held by test, which is "Test", which should be 4)
    int length = strlen(Test);

  10. #2380
    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

    some question about printtexttoscreen
    if you wanne do a "\n" in printf but you are using print , how many pixels will you need to go down?? ,

    one space how many pixels need that???


    thnx in advance;)

  11. #2381
    The Unique Developer
    Points: 7.101, Level: 55
    Level completed: 76%, Points required for next Level: 49
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Canada
    Beiträge
    1.059
    Points
    7.101
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    some question about printtexttoscreen
    if you wanne do a "\n" in printf but you are using print , how many pixels will you need to go down?? ,

    one space how many pixels need that???


    thnx in advance;)
    printtexttoscreen is not like printf :) as you know your self
    params -->
    Code:
    printTextScreen(int x, int y, const char* text, u32 color);
    /*
    @param x: the starting position of the text (x-Coordinate)
    @param y: The level of the text on the screen (y-Coordinate_
    @param text: The text to be written.
    @param color : a Color if your not using RGB mode simply use hex color (example black = 0x000000)
    Stil confused ? -->
    /**
     * Print a text (pixels out of the screen or image are clipped).
     *
     * @param x - left position of text
     * @param y - top position of text
     * @param text - the text to print
     * @param color - new color for the pixels
     */
    */
    Hope I helped :)
    there is no code for a new line just add 10+ to y current position of the text :)
    Malloc.Us Network Administrator

    Decryption of the Encrypted


    You are the unseen, the unstoppable and in power of your code. The God of your software.

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

    This program compiles right that I made, but whe I run it, it doesnt operate exactly how I want. It does what its supposed to do, but it also does something very irritating. The text continuously repeats when I hold a button. Dont attack. I just started to code yesterday :P

    Anyways, heres some screenshots with IR-SHELL of what happens.

    Spoiler for Pictures of What is happening:



    For fun...


    Spoiler for Code Stuff:
    /*My personal app to delete ceertain files in Flash0 when needed like Location free or Update.*/




    #include <stdio.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/unistd.h>

    #include <pspctrl.h>
    #include <pspdebug.h>
    #include <pspkernel.h>
    #include <pspiofilemgr.h>
    #include <pspdisplay.h>
    #include <psptypes.h>

    PSP_MODULE_INFO("TEST", 0x1000, 1, 1); /* 0x1000 = Kernel MODE*/
    PSP_MAIN_THREAD_ATTR(0); /* 0 for kernel mode*/

    #define printf pspDebugScreenPrintf


    void dump_threadstatus(void);

    int done = 0;


    /* 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);
    sceKernelRegisterExitCall back(cbid);

    sceKernelSleepThreadCB();

    return 0;
    }

    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
    int thid = 0;

    thid = sceKernelCreateThread("up date_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if(thid >= 0) {
    sceKernelStartThread(thid , 0, 0);
    }

    return thid;
    }

    //Everything below is expertly crafted. ;)


    int main(void)

    {
    pspDebugScreenInit();
    SceCtrlData pad;
    SetupCallbacks();


    /* to mount flash0 as a writable mass storage */

    sceIoUnassign("flash0:");
    sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", 0, NULL, 0);


    printf("Push Cross to Delete Flash0:/vsh/resource/02.BMP... \n \n");

    printf("Push Triangle to Delete Flash0:/vsh/resource/03.BMP...\n \n");

    printf("Push Circe to Delete Location Free Files. \n \n");



    while(done !=1) {

    sceCtrlReadBufferPositive (&pad, 1);

    //Removes "Flash0:/vsh/resource/02.bmp" when Cross is pressed.

    if(pad.Buttons & PSP_CTRL_CROSS)
    {
    sceIoRemove("flash0:/vsh/resource/02.BMP");
    printf("Cross pressed...Deleting flash0:/vsh/resource/02.BMP \n \n");
    printf("Done! Files deleted \n");
    printf("~~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }





    //Removes "Flash0:/vsh/resource/03.bmp" when triangle is pressed.
    if(pad.Buttons & PSP_CTRL_TRIANGLE)
    {
    sceIoRemove("flash0:/vsh/resource/03.BMP");
    printf("Triangle pressed...Deleting flash0:/vsh/resource/02.BMP \n \n");
    printf("Done! Files deleted \n");
    printf("~~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }



    //Removes Location Free TV files when Circle is pressed.
    if(pad.Buttons & PSP_CTRL_CIRCLE)
    {
    printf("Cross pressed...Deleting flash0:/vsh/resource/02.BMP \n");
    sceIoRemove("flash0:/vsh/nodule/lftv_main_plugin.prx");
    sceIoRemove("flash0:/vsh/nodule/lftv_middleware.prx");
    sceIoRemove("flash0:/vsh/nodule/lftv_plugin.prx");
    sceIoRemove("flash0:/vsh/resource/lftv_main_plugin.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_plugin.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_tuner_jp_jp.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_tuner_us_en.rco");
    printf("Done! Deleted Files for Location Free TV \n");
    printf("~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }

    }


    sceKernelDelayThread(1000 *7000);
    sceKernelExitGame();
    return 0;
    }
    [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]

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

    It's because the sensitivity of the controls is very high. What you deem as one keypress may well be 8 or more to the PSP.

    The solution is to use the old faithful 'lastpad' method, like so (with comments):

    Spoiler for Correct Code:
    Code:
    /*My personal app to delete ceertain files in Flash0 when needed like Location free or Update.*/
    
    
    
    
    #include <stdio.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/unistd.h>
    
    #include <pspctrl.h>
    #include <pspdebug.h>
    #include <pspkernel.h>
    #include <pspiofilemgr.h>
    #include <pspdisplay.h>
    #include <psptypes.h>
    
    PSP_MODULE_INFO("TEST", 0x1000, 1, 1); /* 0x1000 = Kernel MODE*/
    PSP_MAIN_THREAD_ATTR(0); /* 0 for kernel mode*/
    
    #define printf pspDebugScreenPrintf
    
    
    void dump_threadstatus(void);
    
    int done = 0;
    
    
    /* 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);
    sceKernelRegisterExitCall back(cbid);
    
    sceKernelSleepThreadCB();
    
    return 0;
    }
    
    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
    int thid = 0;
    
    thid = sceKernelCreateThread("up date_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if(thid >= 0) {
    sceKernelStartThread(thid , 0, 0);
    }
    
    return thid;
    }
    
    //Everything below is expertly crafted.
    
    
    int main(void)
    
    {
    pspDebugScreenInit();
    SceCtrlData pad, lastpad; // ADDED 'lastpad' HERE
    sceCtrlReadBufferPositive(&lastpad, 1); // INIT THE 'lastpad' VARIABLE
    SetupCallbacks();
    
    
    /* to mount flash0 as a writable mass storage */
    
    sceIoUnassign("flash0:");
    sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", 0, NULL, 0);
    
    
    printf("Push Cross to Delete Flash0:/vsh/resource/02.BMP... \n \n");
    
    printf("Push Triangle to Delete Flash0:/vsh/resource/03.BMP...\n \n");
    
    printf("Push Circe to Delete Location Free Files. \n \n");
    
    
    
    while(done !=1) {
    
    sceCtrlReadBufferPositive (&pad, 1);
    
    if (pad.Buttons != lastpad.Buttons) {
       // DIFFERENT BUTTON HAS BEEN PRESSED
       lastpad = pad; // SET LAST BUTTON PRESSED
    
    //Removes "Flash0:/vsh/resource/02.bmp" when Cross is pressed.
    
    if(pad.Buttons & PSP_CTRL_CROSS)
    {
    sceIoRemove("flash0:/vsh/resource/02.BMP");
    printf("Cross pressed...Deleting flash0:/vsh/resource/02.BMP \n \n");
    printf("Done! Files deleted \n");
    printf("~~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }
    
    
    
    
    
    //Removes "Flash0:/vsh/resource/03.bmp" when triangle is pressed.
    if(pad.Buttons & PSP_CTRL_TRIANGLE)
    {
    sceIoRemove("flash0:/vsh/resource/03.BMP");
    printf("Triangle pressed...Deleting flash0:/vsh/resource/02.BMP \n \n");
    printf("Done! Files deleted \n");
    printf("~~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }
    
    
    
    //Removes Location Free TV files when Circle is pressed.
    if(pad.Buttons & PSP_CTRL_CIRCLE)
    {
    printf("Cross pressed...Deleting flash0:/vsh/resource/02.BMP \n");
    sceIoRemove("flash0:/vsh/nodule/lftv_main_plugin.prx");
    sceIoRemove("flash0:/vsh/nodule/lftv_middleware.prx");
    sceIoRemove("flash0:/vsh/nodule/lftv_plugin.prx");
    sceIoRemove("flash0:/vsh/resource/lftv_main_plugin.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_plugin.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_tuner_jp_jp.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_tuner_us_en.rco");
    printf("Done! Deleted Files for Location Free TV \n");
    printf("~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }
    
    } // END 'lastpad' CHECK
    
    }
    
    
    sceKernelDelayThread(1000 *7000);
    sceKernelExitGame();
    return 0;
    }


    A few tips. There's no need for the 'break' statements, you could have just set 'done = 1'. On a similar note, 'while(!done)' reads better than what you have currently.

    Learn to indent code correctly, it helps you read your code and others who have to read it too and is generally good practise.

    Finally you should check the return value of the sceIoRemove calls to ensure the file was deleted successfully.

    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

  14. #2384
    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 the unique warrior
    printtexttoscreen is not like printf :) as you know your self
    params -->
    Code:
    printTextScreen(int x, int y, const char* text, u32 color);
    /*
    @param x: the starting position of the text (x-Coordinate)
    @param y: The level of the text on the screen (y-Coordinate_
    @param text: The text to be written.
    @param color : a Color if your not using RGB mode simply use hex color (example black = 0x000000)
    Stil confused ? -->
    /**
     * Print a text (pixels out of the screen or image are clipped).
     *
     * @param x - left position of text
     * @param y - top position of text
     * @param text - the text to print
     * @param color - new color for the pixels
     */
    */
    Hope I helped :)
    there is no code for a new line just add 10+ to y current position of the text :)
    and one space how many pixels are that?

  15. #2385
    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 Insert_Witty_Name
    It's because the sensitivity of the controls is very high. What you deem as one keypress may well be 8 or more to the PSP.

    The solution is to use the old faithful 'lastpad' method, like so (with comments):

    Spoiler for Correct Code:
    Code:
    /*My personal app to delete ceertain files in Flash0 when needed like Location free or Update.*/
    
    
    
    
    #include <stdio.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/unistd.h>
    
    #include <pspctrl.h>
    #include <pspdebug.h>
    #include <pspkernel.h>
    #include <pspiofilemgr.h>
    #include <pspdisplay.h>
    #include <psptypes.h>
    
    PSP_MODULE_INFO("TEST", 0x1000, 1, 1); /* 0x1000 = Kernel MODE*/
    PSP_MAIN_THREAD_ATTR(0); /* 0 for kernel mode*/
    
    #define printf pspDebugScreenPrintf
    
    
    void dump_threadstatus(void);
    
    int done = 0;
    
    
    /* 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);
    sceKernelRegisterExitCall back(cbid);
    
    sceKernelSleepThreadCB();
    
    return 0;
    }
    
    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
    int thid = 0;
    
    thid = sceKernelCreateThread("up date_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if(thid >= 0) {
    sceKernelStartThread(thid , 0, 0);
    }
    
    return thid;
    }
    
    //Everything below is expertly crafted.
    
    
    int main(void)
    
    {
    pspDebugScreenInit();
    SceCtrlData pad, lastpad; // ADDED 'lastpad' HERE
    sceCtrlReadBufferPositive(&lastpad, 1); // INIT THE 'lastpad' VARIABLE
    SetupCallbacks();
    
    
    /* to mount flash0 as a writable mass storage */
    
    sceIoUnassign("flash0:");
    sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", 0, NULL, 0);
    
    
    printf("Push Cross to Delete Flash0:/vsh/resource/02.BMP... \n \n");
    
    printf("Push Triangle to Delete Flash0:/vsh/resource/03.BMP...\n \n");
    
    printf("Push Circe to Delete Location Free Files. \n \n");
    
    
    
    while(done !=1) {
    
    sceCtrlReadBufferPositive (&pad, 1);
    
    if (pad.Buttons != lastpad.Buttons) {
       // DIFFERENT BUTTON HAS BEEN PRESSED
       lastpad = pad; // SET LAST BUTTON PRESSED
    
    //Removes "Flash0:/vsh/resource/02.bmp" when Cross is pressed.
    
    if(pad.Buttons & PSP_CTRL_CROSS)
    {
    sceIoRemove("flash0:/vsh/resource/02.BMP");
    printf("Cross pressed...Deleting flash0:/vsh/resource/02.BMP \n \n");
    printf("Done! Files deleted \n");
    printf("~~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }
    
    
    
    
    
    //Removes "Flash0:/vsh/resource/03.bmp" when triangle is pressed.
    if(pad.Buttons & PSP_CTRL_TRIANGLE)
    {
    sceIoRemove("flash0:/vsh/resource/03.BMP");
    printf("Triangle pressed...Deleting flash0:/vsh/resource/02.BMP \n \n");
    printf("Done! Files deleted \n");
    printf("~~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }
    
    
    
    //Removes Location Free TV files when Circle is pressed.
    if(pad.Buttons & PSP_CTRL_CIRCLE)
    {
    printf("Cross pressed...Deleting flash0:/vsh/resource/02.BMP \n");
    sceIoRemove("flash0:/vsh/nodule/lftv_main_plugin.prx");
    sceIoRemove("flash0:/vsh/nodule/lftv_middleware.prx");
    sceIoRemove("flash0:/vsh/nodule/lftv_plugin.prx");
    sceIoRemove("flash0:/vsh/resource/lftv_main_plugin.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_plugin.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_tuner_jp_jp.rco");
    sceIoRemove("flash0:/vsh/resource/lftv_tuner_us_en.rco");
    printf("Done! Deleted Files for Location Free TV \n");
    printf("~~~~~~Returning to XMB in 7 seconds~~~~~~~ \n");
    break;
    }
    
    } // END 'lastpad' CHECK
    
    }
    
    
    sceKernelDelayThread(1000 *7000);
    sceKernelExitGame();
    return 0;
    }


    A few tips. There's no need for the 'break' statements, you could have just set 'done = 1'. On a similar note, 'while(!done)' reads better than what you have currently.

    Learn to indent code correctly, it helps you read your code and others who have to read it too and is generally good practise.

    Finally you should check the return value of the sceIoRemove calls to ensure the file was deleted successfully.
    Thank you so much for that. It works and now I can continue with my work.



    BTW, I do indent. I use Bloodshed. It indents everything very nicely. You should see my code in Dev C++. Ooooh. Sexy. I usially comment every single line, but a lot of it was removed to make forum space. Thank you for your help. Now all I need to do it have better spelling. That is the reason for most of my errors because I type the entire code manually.

    I truly appreciate your help. Thanks.
    [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]

  16. #2386
    The Unique Developer
    Points: 7.101, Level: 55
    Level completed: 76%, Points required for next Level: 49
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Canada
    Beiträge
    1.059
    Points
    7.101
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    and one space how many pixels are that?
    usage:
    Code:
    printTextScreen(10, 10, "This Text Is Written On The Screen As Its Shown HERE With The Spaces!", 0xff00ff);
    printTextScreen(i10, 20, "This Text Is Under The Other Line Of Text", 0x00ffff);
    I Think now you know whats going on eh ;)
    Malloc.Us Network Administrator

    Decryption of the Encrypted


    You are the unseen, the unstoppable and in power of your code. The God of your software.

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

    Ok, I need help. I dont know how to write a file to flash0. I already know how to delete. I want to be able to restore files.

    Could someone write a baisic program that only writes a file to flash0. I tried looking through source codes, but there is too much stuff that I cant tell if it is needed or not.

    What I am requesting is a simple file with the #include's, and the rest of the file.
    Nothing else. I can manage from there. I was hoping you would only post what is needed to write a file. Thanks. :)
    [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]

  18. #2388
    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 can I use fillScreenRect with 50% transparent?

  19. #2389
    Developer
    Points: 10.075, Level: 67
    Level completed: 7%, Points required for next Level: 375
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    Sweden
    Beiträge
    941
    Points
    10.075
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von psphacker12.
    how can I use fillScreenRect with 50% transparent?
    You can't. But there is an example further back in this thread of a function that does the same that insert_witty_name gave me. Try searching ;)

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

    SodR - Cant you just make a 32 bit RGBA value and have 50% transparency? Seems like that would work and I believe Ive done it before...

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

    Not with fillScreenRect. It only fills the framebuffer with the colorvalue and doesn't do any blending or similar. Just render a fullscreen rect (GU_SPRITES primitive) over the screen and enable blending.
    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.

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

    I havent heard from you in a long... long...

    ...

    long time... But anyways, thanks for clearing that up, I guess I was just using an image with half transprency.

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

    Time is short and there's already few of it. Too few to enjoy all the goods of life at the same time (coding, games and girls ;P).

    PS: I think there should be a special FAQ thread for all those graphics.c questions, they are always the same. Or even better, someone should change a lot of the graphics.c library to be more newb-friendly (and faster at the same time... I still can't believe someone coded direct framebuffer access to clear the screen on PSP).
    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.

  24. #2394
    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

    Hmm... Not havinga PSP, I suppose I now have time to think about what you said... True time is short, and that brought me to googling time travel months ago, I found out that astronauts traveling to the moon are going nano-seconds into the future... Since, as you get closer to the speed of light, time slows down.

    But back on topic... Isn't the graphics library already GU accelerated, the parts that arent,Im sure someone wanting to could easily make it GU accelerated... Unless theres a more efficient way (Media Engine is for sound any sound card activity (or some variation of that statement) right? I never got into using it when I had a PSP)...

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


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

    this just shows black screens

    Spoiler for code:
    #include <pspdisplay.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <psputility.h>
    #include <psppower.h>

    #include "graphics/graphics.h"
    /************************* ************************* ************************* ***********************/
    PSP_MODULE_INFO("Customiz e your firmware", 0x1000, 1, 1);
    PSP_MAIN_THREAD_ATTR(0);
    /************************* ************************* ************************* ********************/
    int checkpower(void) {

    int battery;
    int adaptor;

    if(scePowerIsBatteryExist ()) {

    battery =scePowerGetBatteryLifePe rcent();
    adaptor = scePowerIsPowerOnline();

    if(battery > 50) {
    printTextScreen(10, 10,"Battery is OK ", 0xFF0000);
    if(adaptor){
    printTextScreen(10, 20,"\nAc adaptor is plugged\n", 0xFF0000);
    printTextScreen(10, 30,"Going to menu....", 0xFF0000);
    flipScreen();
    sceKernelDelayThread(5000 000);

    }
    else if(!adaptor){
    printTextScreen(10, 20,"\nWarning: Ac adaptor is not plugged in!!!!\n", 0xFF0000);
    printTextScreen(10, 30,"Going to menu....", 0xFF0000);
    flipScreen();
    sceKernelDelayThread(5000 000);

    }


    } else if(battery <50){

    printTextScreen( 10, 10,"Battery needs to be 50%% ", 0xFF0000);
    if(adaptor){
    printTextScreen(10, 20,"\nBut Ac adaptor is plugged\n", 0xFF0000);
    printTextScreen(10, 30,"Going to menu....", 0xFF0000);
    flipScreen();
    sceKernelDelayThread(5000 000);

    }
    else if(!adaptor){
    printTextScreen(10, 20,"\nWarning: Ac adaptor is not plugged in!\n",0x0000ff);
    printTextScreen(10, 30,"Exiting....", 0xFF0000);
    flipScreen();
    sceKernelDelayThread(5000 000);
    sceKernelExitGame();
    }

    flipScreen();


    }





    }
    else{

    printTextScreen(10, 10,"No battery , exiting", 0xFF0000);
    sceKernelDelayThread(5000 000);
    sceKernelExitGame();
    }

    }

    /************************* ************************* ************************* *********************/
    int main(void)
    {

    pspDebugScreenInit();
    checkpower();

    return 0;
    }

  26. #2396
    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

    Digging into the world of relativity theory can either harm or charm you, depending on your view of "reality". Really worth trying to understand though, I can just recommend reading up on it.
    What you talked about though is not really time travel, the astronauts just have a trip that takes them x.0000 seconds (by the means of a clock they carry with them), while when they return on earth x.0001 seconds have passed already (a clock on earth), so they basically are younger - which is a kind of time travel from their point of view, but that's what the relativity theory is all about - points of view.
    Real time travel is only possible through wormholes (or black holes in a selfdestructive way), at least by theory. Not without all the time-paradox mess though, so don't try it at home ;P

    To get back to topic: The graphics.c library makes spare use of GU every then and when, but not consistently and therefore lacks things like the transparent fill, where it could be possibly with a true GU implementation. The problem is that the library wasn't really layed out newb-friendly, but used in a newb tutorial. Well, anyways, someone just put together the quirks of the graphics.c library and make up a FAQ for all those starters questions :P
    I need to talk to IWN, he wanted to start an improved version of the library way back on psp-programming.com.


    @hallo007: you use redundant else if cases.
    in
    Code:
    if (adaptor) { } else { }
    the else case already contains the !adaptor case, as that's exactly what else means.
    Also, your battery check does not care for the == 50 case and will then return with a "no battery" message. Fix that.
    Also, you need to call initGraphics() before you do anything with that graphics.c library, though that will only set one stupid variable to true and nothing else. Another point for the FAQ :/ I start disliking that library more and more
    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.

  27. #2397
    QJ Gamer Bronze
    Points: 5.650, Level: 48
    Level completed: 50%, Points required for next Level: 100
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    338
    Points
    5.650
    Level
    48
    Downloads
    0
    Uploads
    0

    Question

    Using C, how would I fix issues with returning char values from a function?
    I've been using char function() w/char* returns and it hasn't worked then I've used
    char *key;
    char *function() w/return( key); and it crashes.

    But!
    char *function()
    {
    char key[99];
    return(key);
    }
    works, but I've seen many issues concerning char return values and would like to know which route really works and works best?

  28. #2398
    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 Devun_06
    Using C, how would I fix issues with returning char values from a function?
    I've been using char function() w/char* returns and it hasn't worked then I've used
    char *key;
    char *function() w/return( key); and it crashes.

    But!
    char *function()
    {
    char key[99];
    return(key);
    }

    works, but I've seen many issues concerning char return values and would like to know which route really works and works best?
    I thought you would get a warning saying returning address of local pointer or something with that, and then the content of it would be unavailable? I may be wrong, but I really think you would.

    you could do like,

    char *function(char *key)
    {
    return key;
    }

    that should work.


  29. #2399
    Developer
    Points: 14.558, Level: 78
    Level completed: 27%, Points required for next Level: 292
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    166
    Points
    14.558
    Level
    78
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Waterbottle
    I thought you would get a warning saying returning address of local pointer or something with that, and then the content of it would be unavailable? I may be wrong, but I really think you would.

    you could do like,

    char *function(char *key)
    {
    return key;
    }

    that should work.
    o_O and that makes any sense ?

    You have to allocate memory in the function dynamically via malloc (c) or new (c++)
    By now the string will be deleted when the function returns, but at the time of returning the string is still there, then if you try to access that pointer -> pang!

  30. #2400
    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 tommydanger
    o_O and that makes any sense ?

    You have to allocate memory in the function dynamically via malloc (c) or new (c++)
    By now the string will be deleted when the function returns, but at the time of returning the string is still there, then if you try to access that pointer -> pang!
    what I meant was,

    int main()
    {
    char key[20];
    function(key);
    }

    char *function(char *key)
    {
    sprintf(key, "hi");
    return key;
    }

    that works, seeing as you pass the address of key to function and then it modifies the content of it and returns the same address..

    and I'm aware that my explaining skills are horrible...



 

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

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