Seite 241 von 340 ErsteErste ... 141 191 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 291 ... LetzteLetzte
Zeige Ergebnis 7.201 bis 7.230 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 Auraomega Surely Code: if(pad.Buttons & (PSP_CTRL_CIRCLE & PSP_CTRL_CROSS)) will only work if both buttons are pressed, which makes ...

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

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

    Standard

    Zitat Zitat von Auraomega
    Surely
    Code:
    if(pad.Buttons & (PSP_CTRL_CIRCLE & PSP_CTRL_CROSS))
    will only work if both buttons are pressed, which makes the code smaller again.

    -Aura
    No, that will never evaluate to true, because PSP_CTRL_CIRCLE and PSP_CTRL_CROSS have distinct bits set, so the logical AND of both will evaluate to 0 and any value AND 0 is 0 = FALSE.


    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.

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

    *Looks in pspctrl.h*

    PSP_CTRL_CROSS = 0100000000000000
    PSP_CTRL_CIRCLE = 0010000000000000

    Surely if they were AND'ed together they would become 0110000000000000? Would that still not work? Bit 14 and bit 15 are both set, so surely that would be correct, even if only in this case? (I think my electronics is conflicting here).

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

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

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

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

    Standard

    Zitat Zitat von Auraomega
    *Looks in pspctrl.h*

    PSP_CTRL_CROSS = 0100000000000000
    PSP_CTRL_CIRCLE = 0010000000000000

    Surely if they were AND'ed together they would become 0110000000000000? Would that still not work? Bit 14 and bit 15 are both set, so surely that would be correct, even if only in this case? (I think my electronics is conflicting here).

    -Aura
    You're confusing logical AND with logical OR. That's why I used OR in my code snippet.
    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.

  4. #7204
    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 Auraomega
    *Looks in pspctrl.h*

    PSP_CTRL_CROSS = 0100000000000000
    PSP_CTRL_CIRCLE = 0010000000000000

    Surely if they were AND'ed together they would become 0110000000000000? Would that still not work? Bit 14 and bit 15 are both set, so surely that would be correct, even if only in this case? (I think my electronics is conflicting here).

    -Aura
    &
    0 & 0 = 0
    1 & 0 = 0
    0 & 1 = 0
    1 & 1 = 1

    |
    0 | 0 = 0
    0 | 1 = 1
    1 | 0 = 1
    1 | 1 = 1

    hope that helps:)

  5. #7205
    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

    Hmm, is there an XOR function, or would I have to do something like:

    if ( (!( a & b )) & ( a | b ) );

    I think thats right... lord help me I have an exam on this sort of thing very soon and I'm getting mighty confused

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

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

  6. #7206
    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 was just wondering i know of the

    sceKernelLoadExec(); command

    i just wanted to know how i would use this to load an eboot from inside another eboot

    - if it is not the right command to do this could you please direct me to somewhere i could lean how to do this please or just tell me i dont mind as long as i find out
    ------ 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).

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

    If you mean 2 seperate EBOOT files, and are running in 1.50 kernel:

    Code:
         struct SceKernelLoadExecParam param;
         memset(&param, 0, sizeof(param));
         param.size = sizeof(param);
         param.key  = "game";
    
         sceKernelLoadExec(FILEPATH, &param);
    for 3.XX:

    Code:
         struct SceKernelLoadExecVSHParam param;
         memset(&param, 0, sizeof(param));
         param.size = sizeof(param);
         param.key  = "game";
    
         sctrlKernelLoadExecVSHMs2(FILEPATH, &param);
    for loading an EBOOT that is hard coded into another EBOOT:

    Code:
         struct SceKernelLoadExecParam param;
         memset(&param, 0, sizeof(param));
         param.size = sizeof(param);
         param.key  = "game";
    
         sceKernelLoadExecBufferPlain(sizeof(BUFFER), BUFFER, &param); //might need to be strlen(BUFFER) depending on your storage type.
    
    //Not sure if the above will work as I've never actually loaded from a buffer before.
    In any case, unless you are making a loader, you are best to load .prx files. Loading EBOOTs is best left for something like a shell, where as an app that requires plugins is best suited to .prx files.

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

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

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

    thanks man great response

    - did you get them from the samples ?????
    ------ 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).

  9. #7209
    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

    Nope, just dragged them out of the Project4 source code (except the buffer one which I pulled from thin air and a header file )

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

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

  10. #7210
    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 Auraomega
    Hmm, is there an XOR function, or would I have to do something like:

    if ( (!( a & b )) & ( a | b ) );

    I think thats right... lord help me I have an exam on this sort of thing very soon and I'm getting mighty confused

    -Aura
    exclusive or ^

    ^
    0 ^ 0 = 0
    1 ^ 0 = 1
    0 ^ 1 = 1
    1 ^ 1 = 0

    there you go:)

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

    Well that certainly explains a lot, tried doing power with ^ the other day and my code went all weird, now I know why... incidently, is there a function for powers in c?

    You know what, I think I'm gonna use Google and see what operators there are, its something I've neglected so nows a good time to check I guess.

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

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

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

    pow/powf
    There are no other operators in C for mathematical functions.
    arithmetic:
    +, -, *, /, %
    boolean:
    binary: &&, ||, !
    logical: &, |, ~, ^

    In C++ you can overload those operators so you can do power with ^ for example.
    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.

  13. #7213
    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 relating to what i asked yesterday and what aura replied with i added it into the code and set the variable but i get this error

    error: 'memset' was not declared in this scope

    do i have to include a certain lib or do i have to set that as an int or something sorry im new to coding in c for the psp
    ------ 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).

  14. #7214
    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

    you need to include the proper header files
    #include <string.h>
    next time ask google, as it will give you the answer within milliseconds :P
    robot mafia

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

    thanks man - i didn't realize because in my other source that is already included so i haven't actually checked the commands

    thanks again

    THE RESULT OF YOUR HELP
    Geändert von FaT3oYCG (12-23-2007 um 08:46 AM Uhr)
    ------ 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).

  16. #7216
    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 Raphael
    pow/powf
    There are no other operators in C for mathematical functions.
    arithmetic:
    +, -, *, /, %
    boolean:
    binary: &&, ||, !
    logical: &, |, ~, ^

    In C++ you can overload those operators so you can do power with ^ for example.
    You forgot the ternary operator, which is perfect for obfuscating code.

    boolean ? value-if-true : value-if-false

    e.g.:

    Code:
    printf("%s",0?"true":"false"); //prints false
    printf("%s",1?"true":"false"); //prints true
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

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

    Well, I don't consider that an operator in the same category as the above, as as you said it's a ternary operator (meaning it has three operands) :P But oh well... if you so insist, yeah, that one exists too ;)
    Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
    Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
    Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
    Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.

  18. #7218
    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're right, it is different from the other operators, but I always see it listed alongside the other operators, whether they're binary or unary.
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  19. #7219
    QJ Gamer Blue
    Points: 4.239, Level: 41
    Level completed: 45%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    somewhere
    Beiträge
    119
    Points
    4.239
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Can someone link me too the pre-complied toolchain thanx :)

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

    on my guide

    it is the pspdev folder

    PSPDEV FOLDER - (precompiled by me) - THE PSPTOOLCHAIN


    EDIT 1:

    hi sorry for double posting but i have a problem

    i have added umd functions into lua player but i am struggling adding the command to activate the umd as disc0: it all compiles fine but whenever i use the command in luaplayer it says a nil value ???? anyone know why

    it is probably something with the code but i dont know what

    i tried multiple different ways but none seem to work

    here is the current code at the moment i just put the example code in to see if that worked but no luck

    here it is

    Code:
    static int lua_UmdActivate(lua_State *L)
    {
    	if (lua_gettop(L) != 0) return luaL_error(L, "no arguments expected");
    	sceUmdWaitDriveStat(UMD_WAITFORDISC);
    	int i;
    	i = sceUmdCheckMedium(0);
    	if(i == 0)
    	{
    		sceUmdWaitDriveStat(UMD_WAITFORDISC);
    	}
    	sceUmdActivate(1, "disc0:");
    	sceUmdWaitDriveStat(UMD_WAITFORINIT);
    	return 0;
    }
    EDIT 2:

    ok nevermind i figured out why it wasnt working now what i want to know is if i wanted to load the umd and play the game

    how would i do that because i tried loading the boot.bin and the eboot.bin and then both and neither worked so could i have some help please

    thanks

    EDIT 3:

    ok it has come to my attention that i will need to use

    sceKernelLoadModule and sceKernelStartModule

    but i cant seem to get it to work

    if a specific lib is needed could you please tell me which one and give me a short example of just loading and starting a module i looked at the sample in the svn but i had no luck and just found that it confused me more

    here is the code that i am using

    Code:
    static int lua_ExecModule(lua_State *L)
    {
    	if (lua_gettop(L) != 1) return luaL_error(L, "one argument expected");
    
    	struct SceKernelLMOption option;
    	memset(&option, 0, sizeof(option));
    	option.size = sizeof(option);
    	option.position = 0;
    	option.access = 1;
    
    	const char *FILEPATH = "";
    
    	FILEPATH = luaL_checkstring(L, 1);
    
    	int moduleid = sceKernelLoadModule(FILEPATH, 0, &option);
    	sceKernelStartModule(moduleid, 0, NULL, 0, NULL);
    	return 0;
    }
    thanks
    Geändert von FaT3oYCG (12-23-2007 um 06:16 PM Uhr) Grund: Automerged Doublepost
    ------ 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).

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

    Hey, i was just wondering how i would go about storing a bmp image in an array for access later. Thanks

  22. #7222
    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 Raphael
    pow/powf
    There are no other operators in C for mathematical functions.
    arithmetic:
    +, -, *, /, %
    boolean:
    binary: &&, ||, !
    logical: &, |, ~, ^

    In C++ you can overload those operators so you can do power with ^ for example.
    How about << and >>? Those seem pretty mathematical to me, and they also seem like operators.

    @Xsjado, here's a class for bmp loading I wrote a while back. If you want to understand it I'd recommend you to use google, there's plenty of sites there regarding bmps.

    loadBMP() allocates the necessary memory and makes data point to the bmp, and stores the bmp's size in the width and height variables.

    Code:
    class Image
    {
         public:
             Image(){}
             ~Image();
             
             bool loadBMP( const char *path );
             
             unsigned char *data;
             unsigned int width;
             unsigned int height;
    };
    
    Image::~Image()
    {
          free( data );         
    }
    
    unsigned int getUINT( const unsigned char *p )
    {
        return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24);
    }
    
    bool Image::loadBMP( const char *path )
    {
         FILE *fp = fopen( path, "r" );
         if( fp == NULL ) return false;
         unsigned char header[54];
         fread( header, 54, 1, fp );
         // BM
         if( *(short*)header != 19778 )
         {
             fclose( fp );
             return false;
         }
         width = getUINT( &header[18] );
         height = getUINT( &header[22] );
         data = (unsigned char*)malloc( width*height*3 );
         
         fseek( fp, getUINT( &header[10] ), SEEK_SET );
         fread( data, width, height*3, fp );
         fclose( fp );
         // Convert from BGR to RGB
         for( UINT i = 0; i < width*height*3; i += 3 )
         {
              data[i] ^= data[i+2];
              data[i+2] ^= data[i];
              data[i] ^= data[i+2];
         }
         return true;
    }


  23. #7223
    QJ Gamer Silver
    Points: 8.717, Level: 62
    Level completed: 89%, Points required for next Level: 33
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Ort
    Melbourne, Australia
    Beiträge
    1.773
    Points
    8.717
    Level
    62
    My Mood
    Amused
    Downloads
    0
    Uploads
    0

    Standard

    Gar!!! I was trying to make a basic sfx program but it keeps looping, any idea why?
    Spoiler for code:
    Code:
    int main() {
              pspDebugScreenInit();
              SetupCallbacks();
    
              pspAudioInit();
              SceCtrlData pad;
    
    	  printf("Press [O] to play/pause the music\nPress [X] to exit the program\n");
              while(1) {
                      sceCtrlReadBufferPositive(&pad, 1);
                      if(pad.Buttons & PSP_CTRL_CROSS) {
    			MP3_Init(1);
    			MP3_Load("./sounds/sound26.mp3");
    			MP3_Play();
                        if (MP3_EndOfStream() == 1) {
                                  MP3_Stop();
                                  break;
                        }
                      }
              }
              MP3_Stop();
              MP3_FreeTune();
    
              sceKernelSleepThread();
    
              return 0;
    }
    WHA!?

  24. #7224
    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:
    int main() {
              pspDebugScreenInit();
              SetupCallbacks();
    
              pspAudioInit();
              SceCtrlData pad;
    
    	  printf("Press [O] to play/pause the music\nPress [X] to exit the program\n");
              while(1) {
                      sceCtrlReadBufferPositive(&pad, 1);
                      if(pad.Buttons & PSP_CTRL_CROSS) {
    			MP3_Init(1);
    			MP3_Load("./sounds/sound26.mp3");
    			MP3_Play();
                            break;
                      }
              }
                        while(!MP3_EndOfStream()) {
                                  //do nothing
                        }
              MP3_Stop();
              MP3_FreeTune();
    
              sceKernelSleepThread();
    
              return 0;
    }
    simpel it will only check once or the mp3 has stoped or not

  25. #7225
    QJ Gamer Silver
    Points: 8.717, Level: 62
    Level completed: 89%, Points required for next Level: 33
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Ort
    Melbourne, Australia
    Beiträge
    1.773
    Points
    8.717
    Level
    62
    My Mood
    Amused
    Downloads
    0
    Uploads
    0

    Standard

    that didn't work, still continues
    WHA!?

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

    is your problem that it plays a few times when you press tyhe button for the sound? If so, just add a waitvblank to it. One thing you should change is where your sound is loaded and where you initialize the channel. Do:

    Code:
    int main() {
              pspDebugScreenInit();
              SetupCallbacks();
    
              pspAudioInit();
              SceCtrlData pad;
    
              MP3_Init(1);
    	  MP3_Load("./sounds/sound26.mp3");
    
    	  printf("Press [O] to play/pause the music\nPress [X] to exit the program\n");
              while(1) {
                      sceCtrlReadBufferPositive(&pad, 1);
                      if(pad.Buttons & PSP_CTRL_CROSS) {
    			MP3_Play();
                            sceDisplayWaitVBlankStart();
                            }
                        if (MP3_EndOfStream() == 1) break;
              }
              MP3_Stop();
              MP3_FreeTune();
    
              sceKernelSleepThread();
    
              return 0;
    }
    Load them before the loop. The way you were doing it if the user kept pressing it would load the sound a million times and kill the psp. That code also includes the waitvblank

  27. #7227
    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

    ok i have a problem while using the

    sceKernelLoadModule command in my code it throws out an error and says something to do with memory not being able to be allocated

    does anyone know how to solve this problem thanks

    video
    Geändert von FaT3oYCG (12-24-2007 um 06:29 AM Uhr)
    ------ 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).

  28. #7228
    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 Waterbottle
    Code:
    class Image
    {
         public:
             Image(){}
             ~Image();
             
             bool loadBMP( const char *path );
             
             unsigned char *data;
             unsigned int width;
             unsigned int height;
    };
    
    Image::~Image()
    {
          free( data );         
    }
    
    unsigned int getUINT( const unsigned char *p )
    {
        return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24);
    }
    
    bool Image::loadBMP( const char *path )
    {
         FILE *fp = fopen( path, "r" );
         if( fp == NULL ) return false;
         unsigned char header[54];
         fread( header, 54, 1, fp );
         // BM
         if( *(short*)header != 19778 )
         {
             fclose( fp );
             return false;
         }
         width = getUINT( &header[18] );
         height = getUINT( &header[22] );
         data = (unsigned char*)malloc( width*height*3 );
         
         fseek( fp, getUINT( &header[10] ), SEEK_SET );
         fread( data, width, height*3, fp );
         fclose( fp );
         // Convert from BGR to RGB
         for( UINT i = 0; i < width*height*3; i += 3 )
         {
              data[i] ^= data[i+2];
              data[i+2] ^= data[i];
              data[i] ^= data[i+2];
         }
         return true;
    }
    Surely I'm not the only person who sees problems with this class? Even assuming that the loader works fine (which it won't--it'll crash if it's given a BMP with a malformed header. Also, a bitmap that's too big will cause problems, too). If an Image falls out of scope or if an Image* is deleted before it's loaded, instant crash.

    Here's a fixed version. Of course, it assumed UINT and NULL are defined in the scope of the class.

    Code:
    class Image
    {
         public:
             Image(){ data = NULL; }
             ~Image();
             
             bool loadBMP( const char *path );
             
             unsigned char *data;
             unsigned int width;
             unsigned int height;
    };
    
    Image::~Image()
    {
          if( data != NULL ) free( data );
    }
    
    unsigned int getUINT( const unsigned char *p )
    {
        return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24);
    }
    
    bool Image::loadBMP( const char *path )
    {
         if( data != NULL ) free( data );
         FILE *fp = fopen( path, "r" );
         if( fp == NULL ) return false;
         unsigned char header[54];
         if( ( fread( header, 54, 1, fp ) != 54 ) ||
             ( *(short*)header != 19778 ) )
         {
             fclose( fp );
             return false;
         }
         width = getUINT( &header[18] );
         height = getUINT( &header[22] );
         data = (unsigned char*)malloc( width*height*3 );
         if( data == NULL )
         {
             fclose( fp );
             return false;
         }
         
         fseek( fp, getUINT( &header[10] ), SEEK_SET );
         fread( data, width, height*3, fp );
         fclose( fp );
         // Convert from BGR to RGB
         for( UINT i = 0; i < width*height*3; i += 3 )
         {
              data[i] ^= data[i+2];
              data[i+2] ^= data[i];
              data[i] ^= data[i+2];
         }
         return true;
    }
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

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

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

    Standard

    That still will have problems with <= 8bit BMP files as well as with bmp files who's width(*3) is NOT a multiple of four. Rows in a BMP are always padded to have a multiple of four number of bytes. It works for power of two sized images though, so probably that's why it never came to the OP's attention.
    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.

  30. #7230
    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

    *doesn't know anything about the Windows bitmap format, hence I just corrected the mistakes I could identify*
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ


 

Tags for this Thread

Forumregeln

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





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

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