Seite 245 von 340 ErsteErste ... 145 195 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 295 ... LetzteLetzte
Zeige Ergebnis 7.321 bis 7.350 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 Archaemic If you're using SEEK_SET and you start counting from 0, yes. Thanks for the info Archaemic :) ...

  
  1. #7321
    Banned for LIFE
    Points: 18.744, Level: 86
    Level completed: 79%, Points required for next Level: 106
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    East London, England
    Beiträge
    2
    Points
    18.744
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    If you're using SEEK_SET and you start counting from 0, yes.
    Thanks for the info Archaemic :)

    Code:
    char gameid[40];
    target = sceIoOpen("disc0:/PSP_GAME/SYSDIR/UPDATE/PARAM.SFO", PSP_O_WRONLY, 0777);
    gameid = sceIoLseek(target, 362, SEEK_SET);
    sceIoClose(target);
    Would this code work as it is?


    Geändert von eldiablov (12-30-2007 um 12:50 PM Uhr)

  2. #7322
    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 might want to actually use sceIoRead to read something too.

    Also, error check that the file is actually opened etc.

    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. #7323
    Banned for LIFE
    Points: 18.744, Level: 86
    Level completed: 79%, Points required for next Level: 106
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    East London, England
    Beiträge
    2
    Points
    18.744
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Insert_Witty_Name
    You might want to actually use sceIoRead to read something too.
    Code:
    int a;
    char gameid[40];
    target = sceIoOpen("disc0:/PSP_GAME/SYSDIR/UPDATE/PARAM.SFO", PSP_O_WRONLY, 0777);
    gameid = sceIoLseek(target, 362, SEEK_SET);
    a = sceIoRead(target, void *gameid, 40);
    sceIoClose(target);
    The check will be put in place; but is that correct for now? I just want to make sure I actually understand the functions.

  4. #7324
    Points: 2.935, Level: 33
    Level completed: 24%, Points required for next Level: 115
    Overall activity: 0%

    Registriert seit
    Nov 2007
    Ort
    PSP-Development
    Beiträge
    11
    Points
    2.935
    Level
    33
    Downloads
    0
    Uploads
    0

    Standard

    did someone ever added a png background to filebrowser.h?
    the png showed up fine but no text at all.

    also im wondering if there is a sample how to load a prx from a 3.xx app.
    obvious i need a external kmode prx with the loader funktion which i load from my usermode app. any hints?

    thanks in advance

  5. #7325
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Team-3GO
    did someone ever added a png background to filebrowser.h?
    the png showed up fine but no text at all.

    also im wondering if there is a sample how to load a prx from a 3.xx app.
    obvious i need a external kmode prx with the loader funktion which i load from my usermode app. any hints?

    thanks in advance
    That's probably because you blitted the text before the background. Try blitting the background first.
    [IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]

    Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.

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

    Zitat Zitat von eldiablov
    Code:
    int a;
    char gameid[40];
    target = sceIoOpen("disc0:/PSP_GAME/SYSDIR/UPDATE/PARAM.SFO", PSP_O_WRONLY, 0777);
    gameid = sceIoLseek(target, 362, SEEK_SET);
    a = sceIoRead(target, void *gameid, 40);
    sceIoClose(target);
    The check will be put in place; but is that correct for now? I just want to make sure I actually understand the functions.
    No, it's not.

    Code:
    char gameid[40];
    target = sceIoOpen("disc0:/PSP_GAME/SYSDIR/UPDATE/PARAM.SFO", PSP_O_RDONLY, 0777);
    sceIoLseek(target, 362, SEEK_SET);
    sceIoRead(target, (void *) gameid, 40);
    sceIoClose(target);
    Note that this code has NO checks as it is, and that I have no clue if that offset or length is correct. There is also a chance that gameid won't be NULL-terminated after the read, so be careful.

    Note! I changed PSP_O_WRONLY to PSP_O_RDONLY. This is an important change, even if it is easy to miss!
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  7. #7327
    I'm back!
    Points: 8.236, Level: 61
    Level completed: 29%, Points required for next Level: 214
    Overall activity: 99,0%

    Registriert seit
    Feb 2007
    Ort
    England
    Beiträge
    902
    Points
    8.236
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Auraomega
    I'm having some problems with Project4 that I can't understand, I'm just wondering if anyone here can help me.

    I've moved all the graphics handling (graphics.c intraFont.c) into an external prx that I load and link to. When I try loading it with pspSdkLoadStartModule it returns error 0x800000D1 which is SCE_KERNEL_ERROR_ILLEGAL_ PERM, I'm not sure what the error means, or what I've done wrong.

    My next question is how or what is flash2 when trying to access it? I'm trying to write a file to flash2 (and flash3) and read it back, but I keep getting the nodev error (0x80000321).

    Is there any way I can check what variables are being passed between modules, or is there any way I can check what heaps are currently allocated?

    How can I get things printed on the PSPLink shell when running in 3.XX on 3.52? I never had this problem in 3.40LE, but have done ever since moving to 3.52 (does this happen on 3.71?).

    How should I got about loading a PSX game? I've tried
    Code:
    sctrlKernelLoadExecVSHWithApitype(0x143, bpath, &param);
    Where param.key is game, pops, psx. I'm guessing the key is wrong but I can't work out what it is meant to be, so if anyone knows...?

    (Not sure if this is allowed or not, if its not let me know and I'll remove it) When using sctrlSEMountUmdFromFile for M33 or NP9660 it returns a nodev error, but works fine for ISOFs if its enabled in recovery, I've tried loading the modules from flash0, but no luck.
    Anyone?

    Also, I'm having a really odd problem, since I've started using intraFont I can't load games when running in VSH mode, only when running in GAME mode, which is causing obvious problems for Project4.

    -Aura
    Last.fm | Deviant Art | First working OS picture

    Zitat Zitat von nickxab Beitrag anzeigen
    I will beat myself. :p

  8. #7328
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Why isn't this working?

    Code:
    char xoptions[7];
    FILE *options;
    if ((options = fopen("./files/options.txt","rb")) == NULL)
    {
         printf("Please Check Your Options.txt");
    }
    xoptions[fread(xoptions, 1, 4, options)] = 0;
    fclose(options);
    xoptions[7]=0;
    
    //Cpu
    switch(xoptions[0]) {
        case 's': cpudisplay = 111; break;
        case 'n': cpudisplay = 222; break;
        case 'f': cpudisplay = 333; break;
        }
    CpuPower(cpudisplay, cpudisplay, cpudisplay/2);
    Calypso - Enjoy the excellent 2D space shooter:
    http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195

    "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)

  9. #7329
    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 TMNT
    Why isn't this working?

    Code:
    char xoptions[7];
    FILE *options;
    if ((options = fopen("./files/options.txt","rb")) == NULL)
    {
         printf("Please Check Your Options.txt");
    }
    xoptions[fread(xoptions, 1, 4, options)] = 0;
    fclose(options);
    xoptions[7]=0;
    
    //Cpu
    switch(xoptions[0]) {
        case 's': cpudisplay = 111; break;
        case 'n': cpudisplay = 222; break;
        case 'f': cpudisplay = 333; break;
        }
    CpuPower(cpudisplay, cpudisplay, cpudisplay/2);
    whats that for some f****d up code ?!
    if ((options = fopen("./files/options.txt","rb")) == NULL)
    {
    printf("Please Check Your Options.txt");
    }
    this will do it aswell:
    if (fopen("./files/options.txt","rb") == NULL)
    {
    printf("Please Check Your Options.txt");
    }
    but this is a better coding style:
    if (!fopen("./files/options.txt","rb"))
    {
    printf("Please Check Your Options.txt");
    }
    and please tell me what this is supposed to be:
    xoptions[fread(xoptions, 1, 4, options)] = 0;
    ?!?!
    this will in the best case equal to:
    xoptions[4] = 0;
    o_O

    next is:
    char xoptions[7];
    ..
    ..
    ..
    xoptions[7]=0;
    char array with 7 elements, yet you try to write to the 8th element, note it starts from zero ;)

    you sure what you're doing ?
    ah and to know what exactly went wrong would be good to know too as I see many possibilities why this doesn't work the way it is meant to be ;)
    robot mafia

  10. #7330
    QJ Gamer Silver
    Points: 15.527, Level: 80
    Level completed: 36%, Points required for next Level: 323
    Overall activity: 99,0%

    Registriert seit
    Sep 2006
    Ort
    In a houuuuuuuuuuse.
    Beiträge
    680
    Points
    15.527
    Level
    80
    Downloads
    0
    Uploads
    0

    Standard

    I need help, When I go to to compile in linux I get this:

    [email protected]:/usr/local/pspdev/projects/counter# make
    make: psp-config: Command not found
    Makefile:12: /lib/build.mak: No such file or directory
    make: *** No rule to make target `/lib/build.mak'. Stop.

    this is my Makefile:
    TARGET = count
    OBJS = main.o

    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)

    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Counter

    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    I followed This Tutorial.

    Can anyone help?
    PSPlay Developer

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

    echo 'export PSPDEV=/usr/local/pspdev' >> ~/.bashrc
    echo 'export PATH=$PATH:$PSPDEV/bin' >> ~/.bashrc

    Make sure to use apostrophes and not quotes.

    Also, I wouldn't follow tommydanger's advice on the fopen line--all that does is check if the file can be opened, and discard the file handle if it can be opened. What a waste. You can only have 9 or so file handles open at once, so don't waste them.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  12. #7332
    QJ Gamer Silver
    Points: 15.527, Level: 80
    Level completed: 36%, Points required for next Level: 323
    Overall activity: 99,0%

    Registriert seit
    Sep 2006
    Ort
    In a houuuuuuuuuuse.
    Beiträge
    680
    Points
    15.527
    Level
    80
    Downloads
    0
    Uploads
    0

    Standard

    thanks
    where do I add that?
    or do I put it in the terminal?
    I tried and it and nothing worked?
    What fopen line?
    PSPlay Developer

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

    You have to restart the terminal after entering that in. Paste what happens when you enter
    tail ~/.bashrc
    into the terminal

    Also, the fopen line thing was not directed at you.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  14. #7334
    QJ Gamer Silver
    Points: 15.527, Level: 80
    Level completed: 36%, Points required for next Level: 323
    Overall activity: 99,0%

    Registriert seit
    Sep 2006
    Ort
    In a houuuuuuuuuuse.
    Beiträge
    680
    Points
    15.527
    Level
    80
    Downloads
    0
    Uploads
    0

    Standard

    #alias ll='ls -l'
    #alias la='ls -A'
    #alias l='ls -CF'

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    fi





    that shows up
    -= Double Post =-
    After i did "make" I get this now:

    psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -c -o main.o main.c
    main.c: In function ‘main’:
    main.c:51: error: expected expression before ‘[’ token
    main.c:53: error: expected ‘;’ before ‘}’ token
    main.c:46: warning: unused variable ‘i’
    main.c:45: warning: unused variable ‘counter’
    main.c: At top level:
    main.c:55: error: expected identifier or ‘(’ before ‘while’
    make: *** [main.o] Error 1

    Spoiler for SOURCE:
    //w/e- By Amrcidiot

    /* random
    random
    */

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

    PSP_MODULE_INFO("Counter" , 0,1,1);
    #define printf pspDebugScreenPrintf

    int exit_callback(int arg1, int arg2, void *common) {
    sceKernelExitGame();
    return 0;
    }

    int CallbackThread(SceSize args, void *argp) {
    int cbid;

    cbid = sceKernelCreateCallback(" Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCall back(cbid);

    sceKernelSleepThreadCB();

    return 0;
    }

    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;
    }
    int main() {

    pspDebugScreenInit();
    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;
    }
    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);

    sceKernelSleepThread();
    return 0;
    }


    any ideas?
    Geändert von amrcidiot (12-30-2007 um 06:27 PM Uhr) Grund: Automerged Doublepost
    PSPlay Developer

  15. #7335
    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

    Well...then just open ~/.bashrc with your text editor and type in this as the last two lines:
    export PSPDEV=/usr/local/pspdev
    export PATH=$PATH:$PSPDEV/bin
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  16. #7336
    QJ Gamer Silver
    Points: 15.527, Level: 80
    Level completed: 36%, Points required for next Level: 323
    Overall activity: 99,0%

    Registriert seit
    Sep 2006
    Ort
    In a houuuuuuuuuuse.
    Beiträge
    680
    Points
    15.527
    Level
    80
    Downloads
    0
    Uploads
    0

    Standard

    it already was
    but ithink that no,it's just a script error
    could u take a look at it in the post above you last one?
    PSPlay Developer

  17. #7337
    QJ Gamer Blue
    Points: 4.980, Level: 45
    Level completed: 15%, Points required for next Level: 170
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    Chigasaki, Japan
    Beiträge
    226
    Points
    4.980
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    4. fprintf(options, "n"); actually puts 2 bytes into the file (strings are null terminated) not 1.
    FWIW, while strings are null terminated, fprintf does not write the terminator to the stream. Meaning only 'n' is written.

  18. #7338
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    hi i have a couple of problems with my code

    problem one is that i know it wont return how i want it too and
    problem two is that i dont think it is set out right either

    i would like to enter a scan code and then if the scan code is right i.e. it is being pressed make the function return 1 aka true but how would i do this because my code isnt doing it at the moment here is what i have

    Code:
    static int lua_irKeybInit(lua_State *L)
    {
    	if (lua_gettop(L) != 2) return luaL_error(L, "path, kernel mode");
    	const char *path = luaL_checkstring(L, 1);
    	int kernel = luaL_checkint(L, 2);
    	pspIrKeybInit(path, kernel);
    	return 0;
    }
    
    static int lua_irKeybGetKey(lua_State *L)
    {
    	if (lua_gettop(L) != 1) return luaL_error(L, "key");
    	int character = luaL_checkint(L, 1);
    	
    	pspIrKeybOutputMode(PSP_IRKBD_OUTPUT_MODE_SCANCODE);
    	unsigned char raw;
    	unsigned char buffer[255];
    	SIrKeybScanCodeData * scanData;
    	int i, length, count;
    	pspIrKeybReadinput(buffer, &length);
    	count = length / sizeof(SIrKeybScanCodeData);
    	for( i=0; i < count; i++ )
    	{
    		scanData=(SIrKeybScanCodeData*) buffer+i;
    		raw = scanData->raw;
    		if( raw == character) return 1;
    	};
    	return 0;
    }
    
    static int lua_irKeybFinish(lua_State *L)
    {
    	pspIrKeybFinish();
    	return 0;
    }
    i highlighted the section im having trouble with in bold

    thanks
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  19. #7339
    QJ Gamer Bronze
    Points: 8.045, Level: 60
    Level completed: 48%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Ort
    Australia
    Beiträge
    659
    Points
    8.045
    Level
    60
    Downloads
    0
    Uploads
    0

    Standard

    i aint seein nun highlighted bit

  20. #7340
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von tommydanger
    whats that for some f****d up code ?!

    this will do it aswell:

    but this is a better coding style:


    and please tell me what this is supposed to be:
    ?!?!
    this will in the best case equal to:
    o_O

    next is:

    char array with 7 elements, yet you try to write to the 8th element, note it starts from zero ;)

    you sure what you're doing ?
    ah and to know what exactly went wrong would be good to know too as I see many possibilities why this doesn't work the way it is meant to be ;)
    Alright, first of all, it doesn't work at all. However, the fread and all that works (it reads contents of file and stores it into an array). The problem i was having was with the "switch" part. Also, if i do it the "better coding style" one, it gives me an error that options is uninitialized. Finally, when did i say i wanted to write to the eight element? I want to READ the first element. Notice the "switch" xoptions[0], meaning read the first element and do the following actions. That's the part that i can't get working.

    Edit: OMG! I got it working!!! Yes! Lol, it's the stupidest thing that no one could figure out. To Archaemic and tommydanger, thanks for trying to help me out, and thanks Archaemic for helping me learn the switch statements (better than a bunch of else if's). Anyways, here's the full code:

    Code:
    //Open File Once
    char xoptions[4];
    FILE *options;
    if ((options = fopen("./files/options.txt","rb")) == NULL)
    {
         printf("Please Check Your Options.txt");
    }
    xoptions[fread(xoptions, 1, 4, options)] = 0;
    fclose(options);
    //xoptions[4]=0; -----This Part Was Causing the Problem
    
    //Cpu
    switch(xoptions[0]) {
        case 's': cpudisplay = 111; break;
        case 'n': cpudisplay = 222; break;
        case 'f': cpudisplay = 333; break;
        }
    CpuPower(cpudisplay, cpudisplay, cpudisplay/2);
    Geändert von SuperBatXS (12-31-2007 um 09:25 AM Uhr)
    Calypso - Enjoy the excellent 2D space shooter:
    http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195

    "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)

  21. #7341
    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 kuroneko
    FWIW, while strings are null terminated, fprintf does not write the terminator to the stream. Meaning only 'n' is written.
    It doesn't? Opps. In that case, I am not 100% sure what was causing the crash.
    -= Double Post =-
    @tommydanger: It is a matter of preference checking pointers against NULL rather then using the not operator. I much prefer the checking against NULL because that immediately tells me that the code is checking a pointer. I normally reserve the use of the not operator for bools.

    @TMNT: Of course if would cause problems:
    Code:
    char xoptions[4];
    xoptions[4]=0;
    Take a look at the size of the array and the element you are trying to write to. As tommydanger said, arrays are 0 based which means you were trying to write to the 5th element of the array which is undefined memory and therefore *may* crash or at least give undefined behaviour.
    Geändert von yaustar (12-31-2007 um 10:07 AM Uhr) Grund: Automerged Doublepost

  22. #7342
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    @TMNT: Of course if would cause problems:
    Code:
    char xoptions[4];
    xoptions[4]=0;
    Take a look at the size of the array and the element you are trying to write to. As tommydanger said, arrays are 0 based which means you were trying to write to the 5th element of the array which is undefined memory and therefore *may* crash or at least give undefined behaviour.
    Exactly. I need to embrace and utilize my knowledge of arrays more. I was so worried at that time that i couldn't solve the more basic problems...
    Well, glad that's over. :)
    I have already found a way to encrypt my txt files for extra security (already tested and working without problems)!


    -Thanks everyone for helping me out! ;)
    Calypso - Enjoy the excellent 2D space shooter:
    http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195

    "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)

  23. #7343
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Xsjado7
    i aint seein nun highlighted bit
    this bit

    Code:
    static int lua_irKeybGetKey(lua_State *L)
    {
    	if (lua_gettop(L) != 1) return luaL_error(L, "key");
    	int character = luaL_checkint(L, 1);
    	
    	pspIrKeybOutputMode(PSP_IRKBD_OUTPUT_MODE_SCANCODE);
    	unsigned char raw;
    	unsigned char buffer[255];
    	SIrKeybScanCodeData * scanData;
    	int i, length, count;
    	pspIrKeybReadinput(buffer, &length);
    	count = length / sizeof(SIrKeybScanCodeData);
    	for( i=0; i < count; i++ )
    	{
    		scanData=(SIrKeybScanCodeData*) buffer+i;
    		raw = scanData->raw;
    		if( raw == character) return 1;
    	};
    	return 0;
    }
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  24. #7344
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    As for the configuration files, I wrote a configuration parser that someone can use if they want. The configuration file format is '.jpc'. They look like this:

    # A Comment
    # Another Comment

    option "aconfigoption" 'i'
    {
    7
    }

    option "aconfigoption2" 's'
    {
    "seven"
    }
    It's in C++, but all the i/o is in C, so it should be easy to convert it from a class to something more C worthy.
    Angehängte Dateien Angehängte Dateien

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

    Zitat Zitat von _dysfunctional
    As for the configuration files, I wrote a configuration parser that someone can use if they want. The configuration file format is '.jpc'. They look like this:



    It's in C++, but all the i/o is in C, so it should be easy to convert it from a class to something more C worthy.
    does this support floats?
    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.

  26. #7346
    QJ Gamer Bronze
    Points: 5.402, Level: 47
    Level completed: 26%, Points required for next Level: 148
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    468
    Points
    5.402
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von amrcidiot

    that shows up
    -= Double Post =-
    After i did "make" I get this now:

    psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -c -o main.o main.c
    main.c: In function ‘main’:
    main.c:51: error: expected expression before ‘[’ token
    main.c:53: error: expected ‘;’ before ‘}’ token
    main.c:46: warning: unused variable ‘i’
    main.c:45: warning: unused variable ‘counter’
    main.c: At top level:
    main.c:55: error: expected identifier or ‘(’ before ‘while’
    make: *** [main.o] Error 1

    Spoiler for SOURCE:
    //w/e- By Amrcidiot

    /* random
    random
    */

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

    PSP_MODULE_INFO("Counter" , 0,1,1);
    #define printf pspDebugScreenPrintf

    int exit_callback(int arg1, int arg2, void *common) {
    sceKernelExitGame();
    return 0;
    }

    int CallbackThread(SceSize args, void *argp) {
    int cbid;

    cbid = sceKernelCreateCallback(" Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCall back(cbid);

    sceKernelSleepThreadCB();

    return 0;
    }

    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;
    }
    int main() {

    pspDebugScreenInit();
    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) [ /* whats this [?, looks like a typo */
    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);

    sceKernelSleepThread();
    return 0;
    }


    any ideas?
    you see how it says

    main.c:51: error: expected expression before ‘[’ token

    that means check line 51 in file main.c. if you check the spoiler you'll see the problem. After you fix that problem try compiling it again

  27. #7347
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von BlackShark
    does this support floats?
    No, but it would more than easy to add them. I wrote it for a mini http server I made, so I had no need for floats, it would work the same as how the integers are loaded, except you would change the fscanf call to load a float, and change the type to 'f'.

  28. #7348
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von _dysfunctional
    No, but it would more than easy to add them. I wrote it for a mini http server I made, so I had no need for floats, it would work the same as how the integers are loaded, except you would change the fscanf call to load a float, and change the type to 'f'.
    Could you post the code to that, or send me a copy? I'd like to see it.
    [IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]

    Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.

  29. #7349
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    To miniHttp or the configuration loader with floats implemented?

  30. #7350
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von _dysfunctional
    To miniHttp or the configuration loader with floats implemented?
    Sorry, but looks like you already posted it. I feel retarded for not noticing it. Nevermind.
    [IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]

    Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.


 

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 .