Seite 313 von 340 ErsteErste ... 213 263 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 ... LetzteLetzte
Zeige Ergebnis 9.361 bis 9.390 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; I'm aware of that, my concern is with the mipmaps having to load and create multiple textures (as is my ...

  
  1. #9361
    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

    I'm aware of that, my concern is with the mipmaps having to load and create multiple textures (as is my understanding, one for each square under the image size, hence why mipmapped images actually work I believe?).

    Saying that, if I pad out the images once loaded, and not as they are being loaded, the same process can be used on each image, irrespective of it being a bmp, jpg, png or some other obscure image format. I hadn't thought of that angle.

    -Aura


    Last.fm | Deviant Art | First working OS picture

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

  2. #9362
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    it would probably make life easier for supporting multiple image formats if you only had to worry about actually loading the image
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  3. #9363
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Hey everybody. Can someone help me? I'm making something in C++ (just for myself, not a release) but I'm stuck. I have a mp3-player now but you have to put a music file named music.mp3 in the ms0:/music folder, but how can you let the player detect mp3 files automatically in a certain map or on the whole memory stick? This is my code (was included with in the psp/sdk folder, i'm just learning some things):

    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspctrl.h>
    #include <pspdisplay.h>
    #include <stdio.h>
    #include <pspaudio.h>
    #include <pspmp3.h>
    #include <psputility.h>
    
    
    PSP_MODULE_INFO("Mp3Test", 0, 0, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
    PSP_HEAP_SIZE_KB(-1024);
    
    #define MP3FILE "ms0:/MUSIC/music.mp3"
    
    #define printf  pspDebugScreenPrintf
    
    static int isrunning = 1;
    
    int exit_callback(int arg1, int arg2, void *common)
    {
        isrunning = 0;
    
    	return 0;
    }
    
    int CallbackThread(SceSize args, void *argp)
    {
        int cbid;
        cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
        sceKernelRegisterExitCallback(cbid);
        sceKernelSleepThreadCB();
    
    	return 0;
    }
    
    int SetupCallbacks(void)
    {
        int thid = 0;
        thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
        if (thid >= 0)
    	sceKernelStartThread(thid, 0, 0);
        return thid;
    }
    
    
    char	mp3Buf[16*1024]  __attribute__((aligned(64)));
    short	pcmBuf[16*(1152/2)]  __attribute__((aligned(64)));
    
    
    #define ERRORMSG(...) { char msg[128]; sprintf(msg,__VA_ARGS__); error(msg); }
    
    void error( char* msg )
    {
    	SceCtrlData pad;
    	pspDebugScreenClear();
    	pspDebugScreenSetXY(0, 0);
    	printf(msg);
    	printf("Press X to quit.\n");
    	while (isrunning)
    	{
    		sceCtrlReadBufferPositive(&pad, 1);
    		if (pad.Buttons & PSP_CTRL_CROSS)
    			break;
    		sceDisplayWaitVblankStart();
    	}
    	sceKernelExitGame();
    }
    
    int fillStreamBuffer( int fd, int handle )
    {
    	char* dst;
    	int write;
    	int pos;
    
    	int status = sceMp3GetInfoToAddStreamData( handle, &dst, &write, &pos);
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceMp3GetInfoToAddStreamData returned 0x%08X\n", status);
    	}
    
    	// Seek file to position requested
    	status = sceIoLseek32( fd, pos, SEEK_SET );
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceIoLseek32 returned 0x%08X\n", status);
    	}
    
    	// Read the amount of data
    	int read = sceIoRead( fd, dst, write );
    	if (read < 0)
    	{
    		ERRORMSG("ERROR: Could not read from file - 0x%08X\n", read);
    	}
    
    	if (read==0)
    	{
    		return 0;
    	}
    
    	status = sceMp3NotifyAddStreamData( handle, read );
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceMp3NotifyAddStreamData returned 0x%08X\n", status);
    	}
    
    	return (pos>0);
    }
    
    int main(int argc, char *argv[])
    {
        SceCtrlData pad;
    
        pspDebugScreenInit();
        pspDebugScreenClear();
        SetupCallbacks();
    
        sceCtrlSetSamplingCycle(0);
        sceCtrlSetSamplingMode(0);
    
    	int status = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC);
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC) returned 0x%08X\n", status);
    	}
    
    	status = sceUtilityLoadModule(PSP_MODULE_AV_MP3);
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceUtilityLoadModule(PSP_MODULE_AV_MP3) returned 0x%08X\n", status);
    	}
    
    	int fd = sceIoOpen( MP3FILE, PSP_O_RDONLY, 0777 );
    	if (fd<0)
    	{
    		ERRORMSG("ERROR: Could not open file '%s' - 0x%08X\n", MP3FILE, fd);
    	}
    
    	status = sceMp3InitResource();
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceMp3InitResource returned 0x%08X\n", status);
    	}
    
    	SceMp3InitArg mp3Init;
    	mp3Init.mp3StreamStart = 0;
    	mp3Init.mp3StreamEnd = sceIoLseek32( fd, 0, SEEK_END );
    	mp3Init.unk1 = 0;
    	mp3Init.unk2 = 0;
    	mp3Init.mp3Buf = mp3Buf;
    	mp3Init.mp3BufSize = sizeof(mp3Buf);
    	mp3Init.pcmBuf = pcmBuf;
    	mp3Init.pcmBufSize = sizeof(pcmBuf);
    
    	int handle = sceMp3ReserveMp3Handle( &mp3Init );
    	if (handle<0)
    	{
    		ERRORMSG("ERROR: sceMp3ReserveMp3Handle returned 0x%08X\n", handle);
    	}
    
    	fillStreamBuffer( fd, handle );
    
    	status = sceMp3Init( handle );
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceMp3Init returned 0x%08X\n", status);
    	}
    
    	int channel = -1;
    	int samplingRate = sceMp3GetSamplingRate( handle );
    	int numChannels = sceMp3GetMp3ChannelNum( handle );
    	int lastDecoded = 0;
    	int volume = PSP_AUDIO_VOLUME_MAX;
    	int numPlayed = 0;
    	int paused = 0;
    	int lastButtons = 0;
    	int loop = 0;
    	while (isrunning)
    	{
    		sceDisplayWaitVblankStart();
    		pspDebugScreenSetXY(0, 0);
    		printf("MP3-PSP By Malliet\n\n");
    		printf("Playing '%s'...\n", MP3FILE);
    		printf(" %i Hz\n", samplingRate);
    		printf(" %i kbit/s\n", sceMp3GetBitRate( handle ));
    		printf(" %s\n", numChannels==2?"Stereo":"Mono");
    		printf(" %s\n\n", loop==0?"No loop":"Loop");
    		int playTime = samplingRate>0?numPlayed / samplingRate:0;
    		printf(" Playtime: %02i:%02i\n", playTime/60, playTime%60 );
    		printf("\n\n\nPress CIRCLE to Pause/Resume playback\nPress TRIANGLE to reset playback\nPress CROSS to switch loop mode\nPress SQUARE to stop playback and quit\n");
    
    		if (!paused)
    		{
    			if (sceMp3CheckStreamDataNeeded( handle )>0)
    			{
    				fillStreamBuffer( fd, handle );
    			}
    
    			short* buf;
    			int bytesDecoded;
    			int retries = 0;
    
    			for (;retries<1;retries++)
    			{
    				bytesDecoded = sceMp3Decode( handle, &buf );
    				if (bytesDecoded>0)
    					break;
    
    				if (sceMp3CheckStreamDataNeeded( handle )<=0)
    					break;
    
    				if (!fillStreamBuffer( fd, handle ))
    				{
    					numPlayed = 0;
    				}
    			}
    			if (bytesDecoded<0 && bytesDecoded!=0x80671402)
    			{
    				ERRORMSG("ERROR: sceMp3Decode returned 0x%08X\n", bytesDecoded);
    			}
    
    			if (bytesDecoded==0 || bytesDecoded==0x80671402)
    			{
    				paused = 1;
    				sceMp3ResetPlayPosition( handle );
    				numPlayed = 0;
    			}
    			else
    			{
    				if (channel<0 || lastDecoded!=bytesDecoded)
    				{
    					if (channel>=0)
    						sceAudioSRCChRelease();
    
    					channel = sceAudioSRCChReserve( bytesDecoded/(2*numChannels), samplingRate, numChannels );
    				}
    				numPlayed += sceAudioSRCOutputBlocking( volume, buf );
    			}
    		}
    
    		sceCtrlPeekBufferPositive(&pad, 1);
    
    		if (pad.Buttons!=lastButtons)
    		{
    			if (pad.Buttons & PSP_CTRL_CIRCLE)
    			{
    				paused ^= 1;
    			}
    
    			if (pad.Buttons & PSP_CTRL_TRIANGLE)
    			{
    				sceMp3ResetPlayPosition( handle );
    				numPlayed = 0;
    			}
    
    			if (pad.Buttons & PSP_CTRL_CROSS)
    			{
    				loop = (loop==0?-1:0);
    				status = sceMp3SetLoopNum( handle, loop );
    				if (status<0)
    				{
    					ERRORMSG("ERROR: sceMp3SetLoopNum returned 0x%08X\n", status);
    				}
    			}
    
    			if (pad.Buttons & PSP_CTRL_SQUARE)
    			{
    				break;
    			}
    
    			lastButtons = pad.Buttons;
    		}
        }
    
        if (channel>=0)
    		sceAudioSRCChRelease();
    
    	status = sceMp3ReleaseMp3Handle( handle );
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceMp3ReleaseMp3Handle returned 0x%08X\n", status);
    	}
    
    	status = sceMp3TermResource();
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceMp3TermResource returned 0x%08X\n", status);
    	}
    
    	status = sceIoClose( fd );
    	if (status<0)
    	{
    		ERRORMSG("ERROR: sceIoClose returned 0x%08X\n", status);
    	}
    
        sceKernelExitGame();
    
        return 0;
    }

  4. #9364
    QJ Gamer Silver
    Points: 8.475, Level: 62
    Level completed: 9%, Points required for next Level: 275
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Perth, Scotland
    Beiträge
    1.094
    Points
    8.475
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    sceIoD* functions.

    Use them to read a folder or whatever and get the files within.

  5. #9365
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    I'm a beginner in C++ Davee so can you explain me how to use that function.

  6. #9366
    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 do a search on ps2dev's forums for dirents, you'll probably find a good example of a file browser, but instead of printing a list of files, simply feed them into a loop to check extentions and play.

    Code:
    //Psudo
    
    typedef struct
    {
       int count;
       char loc[256];
    } _fileBrowser fileBrowser;
    
    getFileList(fileBrowser);
    
    for(int loop = 0; loop < fileBrowser.count; loop++)
    {
       //code to check extention is mp3
       if(extention == mp3)
       {
          //play mp3 file
       }
       else
       {
          // check again
       }
    }
    Of course, theres more work than that, but it should give you a starting point.

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

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

  7. #9367
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    I shall check the ps2dev's forum then:P But thanks for giving me a starting point;)

  8. #9368
    xMod.
    Points: 4.576, Level: 43
    Level completed: 13%, Points required for next Level: 174
    Overall activity: 0%

    Registriert seit
    Oct 2008
    Ort
    Melbourne, Australia
    Beiträge
    675
    Points
    4.576
    Level
    43
    My Mood
    Daring
    Downloads
    0
    Uploads
    0

    Question n00b question

    ive compiled my idstorage.prx but i wanna know how to access and use the functions in it, any advice would help =D

    !~SlasheR~!

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

    Build a stub file. You've created your exports right? In bash type psp-build-exports -s [export file] and you'll recieve a stub file.

    Then, all you need to do is link your stub file into the makefile of your app and you SHOULD be able to call all those functions. You'll need to make sure you've started all the modules which are required (such as the module in question and any the functions are dependant on). If you get any errors check the SDK documentation under PSP_KERNEL_ERRORS (I think) and see if you can make sense of it, if not post back.

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

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

  10. #9370
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Never mind. It works now

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

    We can't help you if we don't know whats going wrong ;)

    Edit:

    Seriously, you should be smart enough to figure that out. I'm not going to tell you whats wrong. It tells you EXACTLY whats not right and gives you a line reference.

  12. #9372
    xMod.
    Points: 4.576, Level: 43
    Level completed: 13%, Points required for next Level: 174
    Overall activity: 0%

    Registriert seit
    Oct 2008
    Ort
    Melbourne, Australia
    Beiträge
    675
    Points
    4.576
    Level
    43
    My Mood
    Daring
    Downloads
    0
    Uploads
    0

    Question

    thx 4 replying but i cant figure out how to link it into my makefile

    i ran psp-build-exports -s test.exp and got test.S

    now how do i link that?

    srry if i sound nooby but im just a begginer

    !~SlasheR~!

  13. #9373
    QJ Gamer Green
    Points: 4.092, Level: 40
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Beiträge
    508
    Points
    4.092
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    You put the test.o in your makefile and make a test.h as a header for the functions.
    I gone and made that one power spoofer and that gay cheat device.

  14. #9374
    xMod.
    Points: 4.576, Level: 43
    Level completed: 13%, Points required for next Level: 174
    Overall activity: 0%

    Registriert seit
    Oct 2008
    Ort
    Melbourne, Australia
    Beiträge
    675
    Points
    4.576
    Level
    43
    My Mood
    Daring
    Downloads
    0
    Uploads
    0

    Standard

    no i want to link "test.S" into my MakeFile

  15. #9375
    QJ Gamer Silver
    Points: 8.475, Level: 62
    Level completed: 9%, Points required for next Level: 275
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Perth, Scotland
    Beiträge
    1.094
    Points
    8.475
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von slasher2661996 Beitrag anzeigen
    no i want to link "test.S" into my MakeFile
    As NoEffex said, add test.o to your objects line in the MakeFile ;)

  16. #9376
    xMod.
    Points: 4.576, Level: 43
    Level completed: 13%, Points required for next Level: 174
    Overall activity: 0%

    Registriert seit
    Oct 2008
    Ort
    Melbourne, Australia
    Beiträge
    675
    Points
    4.576
    Level
    43
    My Mood
    Daring
    Downloads
    0
    Uploads
    0

    Talking

    i did and

    Code:
     $ make
    psp-gcc -I. -IC:/PSP/pspdev/psp/sdk/include -O2 -G0 -Wall -lpsppower  -L. -LC:/PSP/pspdev/psp/sdk/li
    b   main.o prx\\main.o -lpsppower -lpspwlan -lpspnand_driver -lpspgu -lpng -lz -lm -lpspdebug -lpspd
    isplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpspu
    tility -lpspuser -lpspkernel -o hello.elf
    prx\main.o:(.rodata.sceModuleInfo+0x0): multiple definition of `module_info'
    main.o:(.rodata.sceModuleInfo+0x0): first defined here
    main.o: In function `check_mobo':
    main.c:(.text+0x58): undefined reference to `ReadKey'
    main.c:(.text+0x68): undefined reference to `ReadKey'
    collect2: ld returned 1 exit status
    make: *** [hello.elf] Error 1
    :Argh:



    --EDIT--

    Fixed =) didnt know you had 2 have test.S in the same dir
    -=Double Post Merge =-
    srry that worked but how do i reference them

    do i do:
    Code:
    int ReadKey();
    or:
    Code:
    extern int ReadKey();
    thanks for all your helpl so far

    !~SlasheR~!
    Geändert von slasher101 (12-23-2008 um 11:51 PM Uhr) Grund: Automerged Doublepost

  17. #9377
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Does somebody know where I can find the UMD functions such as starting the umd etc?
    [spoiler=My Releases So Far]
    PSP_Operator v2.0 Final (and earlier; stopped with this one)
    Mario's Road v2.0 (working on 2.5:D)
    UMD_Operator v0.0.2 (and earlier; stopped with this one)
    PSP-Quiz v0.1 (working on v0.2 already:D)
    [/spoiler]

  18. #9378
    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

    pspumd.h

    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

  19. #9379
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    yeah i already found that out, but thanks anyway. Btw that's the include right? So how can i start umd etc. If i press on a button?

    EDIT: Never mind; found it here: http://psp.jim.sh/pspsdk-doc/
    Geändert von malliet (12-24-2008 um 10:03 AM Uhr)

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

    Reading the header will tell you everything you need to know ...

  21. #9381
    Points: 2.052, Level: 27
    Level completed: 35%, Points required for next Level: 98
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Dec 2008
    Beiträge
    3
    Points
    2.052
    Level
    27
    Downloads
    0
    Uploads
    0

    Standard

    Help what m i doing wrong with this collision code

    #include <stdio.h>
    #include <oslib/oslib.h>
    #include <math.h>




    //necessary to create eboot
    psp_module_info("oslib sample", 0, 1, 1);
    psp_main_thread_attr(thre ad_attr_user | thread_attr_vfpu);

    //declaration of the pointers of our images
    osl_image *background,*a,*b;



    // based of ravines
    int collision(int ax, int ay, int awidth, int aheight, int bx, int by, int bwidth, int bheight)


    int hit(){

    if ((ax >= bx && ax <= (bx+bwidth)) && (ay >= by && ay <= (by+bheight)))
    {
    hit = 1;
    }

    if (((ax+awidth) >= bx && (ax+awidth) <= (bx+bwidth)) && (ay >= by && ay <= (by+bheight))) {
    hit = 1;
    }

    if ((ax >= bx && ax <= (bx+bwidth)) && ((ay+aheight) >= by && (ay+aheight) <= (by+bheight))) {
    hit = 1;
    }

    if (((ax+awidth) >= bx && (ax+awidth) <= (bx+bwidth)) && ((ay+aheight) >= by && (ay+aheight) <= (by+bheight))) {
    hit = 1;
    }

    return hit;
    }


    int main(int argc, char **argv)
    {
    //initialization of the oslib library
    oslinit(0);

    //initialization of the graphics mode
    oslinitgfx(osl_pf_8888, 1);

    oslinitconsole(); //text

    oslsettransparentcolor(rg b(255,0,255));

    //loads our images into memory
    a = oslloadimagefile("a.png", osl_in_ram, osl_pf_5551);
    b = oslloadimagefile("b.png", osl_in_ram, osl_pf_5551);
    background = oslloadimagefile("backgro und.png", osl_in_ram, osl_pf_5551);

    //stuff

    a->x =ax;
    a->y =ay;
    b->x =bx;
    b->y =by;



    //position
    a->x =100;
    a->y =249;

    b->x=300;
    b->y=245;

    //main while loop
    while (!osl_quit)
    {
    //to be able to draw on the screen
    oslstartdrawing();

    //clear the screen
    oslcls();

    //initiate the psp's buttons
    oslreadkeys();
    osldrawimage(background);
    osldrawimage(a);
    osldrawimage(b);
    if(hit==1)oslprintf_xy(10 ,10,"collision is positive");
    if(hit==0)oslprintf_xy(30 0,10,"collision is negative");
    if(osl_keys->held.right) a->x+=1;
    if(osl_keys->held.left) a->x-=1;
    if(osl_keys->held.up) a->y-=1;
    if(osl_keys->held.down) a->y+=1;

    //ends drawing mode
    oslenddrawing();

    //synchronizes the screen
    oslsyncframe();
    }
    //terminate the program
    oslendgfx();
    oslquit();
    return 0;
    }

  22. #9382
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von NEW09 Beitrag anzeigen
    Help what m i doing wrong with this collision code
    Spoiler for code:

    [code]

    //prototype here
    int collision(int ax, int ay, int awidth, int aheight, int bx, int by, int bwidth, int bheight)

    //int hit(){ here?!
    int hit(){

    //take out the last two lines and do:

    int collision(int ax, int ay, int awidth, int aheight, int bx, int by, int bwidth, int bheight){
    int hit=0;
    if ((ax >= bx && ax <= (bx+bwidth)) && (ay >= by && ay <= (by+bheight)))
    {
    hit = 1;
    }

    if (((ax+awidth) >= bx && (ax+awidth) <= (bx+bwidth)) && (ay >= by && ay <= (by+bheight))) {
    hit = 1;
    }

    if ((ax >= bx && ax <= (bx+bwidth)) && ((ay+aheight) >= by && (ay+aheight) <= (by+bheight))) {
    hit = 1;
    }

    if (((ax+awidth) >= bx && (ax+awidth) <= (bx+bwidth)) && ((ay+aheight) >= by && (ay+aheight) <= (by+bheight))) {
    hit = 1;
    }

    return hit;
    }

    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  23. #9383
    Points: 2.052, Level: 27
    Level completed: 35%, Points required for next Level: 98
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Dec 2008
    Beiträge
    3
    Points
    2.052
    Level
    27
    Downloads
    0
    Uploads
    0

    Standard

    still no use...
    i get this from the debugger.

  24. #9384
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    well, from looking at your code above, and the error's your getting, your forgetting that c++ is case sensitive...

    anywho, i'm heading off to bed
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  25. #9385
    Points: 2.052, Level: 27
    Level completed: 35%, Points required for next Level: 98
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Dec 2008
    Beiträge
    3
    Points
    2.052
    Level
    27
    Downloads
    0
    Uploads
    0

    Standard

    that happended when i pasted it here.the cases changed, must have had capslock on or something.

    OK I GOT IT TO COMPLIE..BUT STILL NO COLLISION..Y Y Y Y Y Y ?????

    #include <stdio.h>
    #include <oslib/oslib.h>
    #include <math.h>




    //Necessary to create eboot
    PSP_MODULE_INFO("OSLib Sample", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THRE AD_ATTR_USER | THREAD_ATTR_VFPU);

    //declaration of the pointers of our images
    OSL_IMAGE *background,*A,*B;

    int collided;
    int hit;
    int Ax=100, Ay = 100, Awidth = 32, Aheight = 32, Bx = 200, By = 100, Bwidth = 32, Bheight = 32;



    int collision(int Ax, int Ay, int Awidth, int Aheight, int Bx, int By, int Bwidth, int Bheight){

    int hit=0;

    if ((Ax >= Bx && Ax <= (Bx+Bwidth)) && (Ay >= By && Ay <= (By+Bheight)))
    {
    hit = 1;
    }

    if (((Ax+Awidth) >= Bx && (Ax+Awidth) <= (Bx+Bwidth)) && (Ay >= By && Ay <= (By+Bheight))) {
    hit = 1;
    }

    if ((Ax >= Bx && Ax <= (Bx+Bwidth)) && ((Ay+Aheight) >= By && (Ay+Aheight) <= (By+Bheight))) {
    hit = 1;
    }

    if (((Ax+Awidth) >= Bx && (Ax+Awidth) <= (Bx+Bwidth)) && ((Ay+Aheight) >= By && (Ay+Aheight) <= (By+Bheight))) {
    hit = 1;
    }

    return hit;
    }


    int main(int argc, char **argv)
    {
    //Initialization of the Oslib library
    oslInit(0);

    //Initialization of the graphics mode
    oslInitGfx(OSL_PF_8888, 1);

    oslInitConsole(); //Text

    oslSetTransparentColor(RG B(255,0,255));

    //loads our images into memory
    A = oslLoadImageFile("A.png", OSL_IN_RAM, OSL_PF_5551);
    B = oslLoadImageFile("B.png", OSL_IN_RAM, OSL_PF_5551);
    background = oslLoadImageFile("backgro und.png", OSL_IN_RAM, OSL_PF_5551);

    //stuff

    A->x =Ax;
    A->y =Ay;
    B->x =Bx;
    B->y =By;



    //position
    A->x =100;
    A->y =100;

    B->x=200;
    B->y=100;

    //main while loop
    while (!osl_quit)
    {
    //To be able to draw on the screen
    oslStartDrawing();

    //Clear the screen
    oslCls();

    //initiate the PSP's buttons
    oslReadKeys();
    oslDrawImage(background);
    oslDrawImage(A);
    oslDrawImage(B);
    if(hit==1)oslPrintf_xy(10 ,10,"collision is positive");

    if(collision(Ax, Ay, Awidth, Aheight, Bx, By, Bwidth, Bheight)) {
    collided = 1;}

    if(collided==1) {
    oslPrintf_xy(10,30,"colli sion is +");}

    if(osl_keys->held.right) A->x+=1;
    if(osl_keys->held.left) A->x-=1;
    if(osl_keys->held.up) A->y-=1;
    if(osl_keys->held.down) A->y+=1;

    //Ends drawing mode
    oslEndDrawing();

    //Synchronizes the screen
    oslSyncFrame();
    }
    //Terminate the program
    oslEndGfx();
    oslQuit();
    return 0;
    }
    Geändert von NEW09 (12-24-2008 um 10:04 PM Uhr)

  26. #9386
    QJ Gamer Green
    Points: 3.567, Level: 37
    Level completed: 45%, Points required for next Level: 83
    Overall activity: 0%

    Registriert seit
    May 2008
    Ort
    The Netherlands
    Beiträge
    330
    Points
    3.567
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Does somebody know how to automatically detect mp3 files on the mem stick or a map and display a list with the mp3 files?

  27. #9387
    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 NEW09 Beitrag anzeigen
    OK I GOT IT TO COMPLIE..BUT STILL NO COLLISION..Y Y Y Y Y Y ?????
    What do you expect? You effectively call the collision function with constants. You probably want to pass in A->x, A->y, and B->x, B->y as the object locations.

    Also, the collision function looks a bit convoluted. You should only need 4 equations:

    hit = (ax+aw >= bx) && (ay+ah >= by) && (bx+bw >= ax) && (by+bh >= ay)

    HTH
    Geändert von kuroneko (12-25-2008 um 01:16 AM Uhr)

  28. #9388
    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

    Zitat Zitat von Davee Beitrag anzeigen
    sceIoD* functions.

    Use them to read a folder or whatever and get the files within.
    Zitat Zitat von malliet Beitrag anzeigen
    Does somebody know how to automatically detect mp3 files on the mem stick or a map and display a list with the mp3 files?
    http://psp.jim.sh/pspsdk-doc/pspiofilemgr_8h.html ;)

  29. #9389
    xMod.
    Points: 4.576, Level: 43
    Level completed: 13%, Points required for next Level: 174
    Overall activity: 0%

    Registriert seit
    Oct 2008
    Ort
    Melbourne, Australia
    Beiträge
    675
    Points
    4.576
    Level
    43
    My Mood
    Daring
    Downloads
    0
    Uploads
    0

    Standard

    from prx?

    Code:
    extern int ReadKey();
    
    or
    
    int ReadKey();
    plz help !~SlasheR~!

  30. #9390
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    @malliet:
    look into the dirent.h library, should be what you need

    @slasher:
    test both ways and see, don't ask until you've tested
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been


 

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

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