Seite 4 von 340 ErsteErste 1 2 3 4 5 6 7 8 9 10 11 12 13 14 54 104 ... LetzteLetzte
Zeige Ergebnis 91 bis 120 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; ? menu.c:88: warning: 'input.Buttons' is used uninitialized in this function SceCtrlData input; What the heck? All of a sudden I'm ...

  
  1. #91
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    ?

    menu.c:88: warning: 'input.Buttons' is used uninitialized in this function

    SceCtrlData input;

    What the heck? All of a sudden I'm getting this. It is used for controling buttons, insteaed of pad.buttons, its input. That is what I get. Any help?



    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  2. #92
    QJ Gamer Blue
    Points: 4.731, Level: 43
    Level completed: 91%, Points required for next Level: 19
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Beiträge
    95
    Points
    4.731
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    okay, two problems.

    One the "sleep(250);" doesn't seem to do anything.
    2) sceKerenelSleepThread(250 0 00); is a kernel mode thing, right, and can't be used through the photo exploit?
    3) im actually am doing the whole array+animation technique and it seems to change right, but when it gets to the last frame it displays a trail of all the other images.

    im looking at a
    frames[5]
    if right{
    clear screen
    blit(yadayada frames[current]....)
    current++
    if current is 4 go back to 1

    4) i can't count

    can anyone explain the trail problem and tell me another way to measure parts of a second?

  3. #93
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von orphan frequently
    okay, two problems.

    One the "sleep(250);" doesn't seem to do anything.
    2) sceKerenelSleepThread(250 0 00); is a kernel mode thing, right, and can't be used through the photo exploit?
    3) im actually am doing the whole array+animation technique and it seems to change right, but when it gets to the last frame it displays a trail of all the other images.

    im looking at a
    frames[5]
    if right{
    clear screen
    blit(yadayada frames[current]....)
    current++
    if current is 4 go back to 1

    4) i can't count

    can anyone explain the trail problem and tell me another way to measure parts of a second?
    1) Try sceDisplayWaitVblankStart ();. It is 1/10 of a second, so if you wanted 1 second wait time before displaying something:
    Code:
    for(x=0; x<10; x++) {
          sceDisplayWaitVblankStart();
    }
    2) Why not try? Trial and Error, the best way to learn, but me not having a 2.0+, and not wanting to update, can not try.

    3.)
    im looking at a
    frames[5]
    if right{
    clear screen
    blit(yadayada frames[current]....)
    current++
    if current is 4 go back to 1
    The trail thing, I dont know, but you can try
    Code:
    #define RGBA(r, g, b, a) ((r)|((g)<<8)|((b)<<16)|((a)>> 24 & 0xFF)//Alpha
    frames[5];
    int current = 0
    while(1) {
       blit(yada yada frame[current]);
       flipScreen();
    if(SceCtrlData.Buttons & PSP_CTRL_RIGHT) {
    
         current++;
         
         clearImage(RGBA(0, 0, 0, 255), Image* anim[current - 1]); /*Its close to that, switch the color and image if not */}
    }
    Ok, this is what I would do, but I havent done animations yet, but I have learned how to do them but very little. What that would do is blit the image not inside the if so it reduces the flashyness. So if you click 'RIGHT' then the curent integer goes up, moving the array value placement up to blit the next image in the animation, then the trail thing, I think that will clear fix it. What it will do is if right is clicked, it will increase the current value first making anew mage of the animation appear/blit, then clear the image before it with an alpha channel making it transparent, so the trail is gone.

    This is just what I think would work, it hasnt been tested.
    Geändert von SG57 (02-20-2006 um 04:51 PM Uhr)

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  4. #94
    QJ Gamer Blue
    Points: 4.731, Level: 43
    Level completed: 91%, Points required for next Level: 19
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Beiträge
    95
    Points
    4.731
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    thanks, the vblank thing is definitley what I'm looking for. as for #2, i was saying that because kernel wasn't working for me. Your solution to number three looks good and I'll have to try it later. But for now, im researching big box companies. i have to prove that walmart helps communities! any ideas?

  5. #95
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    I dunno, but I found a better way to get hte alpha color, either blit some image, or load a small 1x1 image that isnt even a byte big, and call:

    Code:
    //Load the small image with transparency and stuff
    alphacolor = getPixelImage(1, 1, smallImage);
    That will get the alpha pixel color from the small image and feed it into the color pointer alphacolor. Now, you don;t NEED a small new image, just make sure you have 1 image with n alpha channel on it so you cna get hte alpha color from it, so you would then do

    Code:
    clearScreen(alphacolor, animation image[current - 1]);
    There, tht hasnt benn tested but I think it will work.

    Anyway, Yeldarb, think you could tell me what this does?

    sceCtrlPeekBufferNegative (SceCtrlData *pad_data, int count);

    ?


    OK, SMERITY, INEED YOUR HELP!

    Rotation is being a pain. I can not get it to work. I have tried both of your ways, I am going to make the one code you posted here, not a link, into a protoype and see what happens, but in the meantime, I need to know ow to rotate an image! Im trying to test a sample program where there is a pciture thing, just a blob thing, right in the middle of the screen. I wnat the analog stick to control where it is pointing, so pointing down, woul mean the main point of the blob, is pointing down, and analog stick left, means point left:

    <- Lx = blob point left
    -> Lx = blob point right
    ^ Ly = blob point up
    DOWN Ly = blob point down

    Please help?!
    Geändert von SG57 (02-20-2006 um 06:33 PM Uhr)

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  6. #96
    Developer
    Points: 5.116, Level: 45
    Level completed: 83%, Points required for next Level: 34
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    Sydney, Australia
    Beiträge
    128
    Points
    5.116
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    SG57 -
    Rotating an image
    Sorry to say, if you need to rotate an image, and you want to program that anew, you're going to have to scratch up on your maths.

    Mainly the use of trigonometry, specifically sine and cosine.
    See http://freespace.virgin.net/hugo.eli...nes/rotate.htm and http://mathworld.wolfram.com/Trigonometry.html

    Ie, first issue, look back at my previous post for most of the details on rotating an image.
    Onto the function you want, in graphics.c they have the blitting image function atm, and it could be modified into what is needed for rotation...

    Code:
    void blitAlphaImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy)
    {
    	if (!initialized) return;
    
    	sceKernelDcacheWritebackInvalidateAll();
    	guStart();
    	sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
    	float u = 1.0f / ((float)source->textureWidth);
    	float v = 1.0f / ((float)source->textureHeight);
    	sceGuTexScale(u, v);
    	
    	int j = 0;
    	while (j < width) {
    		Vertex* vertices = (Vertex*) sceGuGetMemory(2 * sizeof(Vertex));
    		int sliceWidth = 64;
    		if (j + sliceWidth > width) sliceWidth = width - j;
    		vertices[0].u = sx + j;
    		vertices[0].v = sy;
    		vertices[0].x = dx + j;
    		vertices[0].y = dy;
    		vertices[0].z = 0;
    		vertices[1].u = sx + j + sliceWidth;
    		vertices[1].v = sy + height;
    		vertices[1].x = dx + j + sliceWidth;
    		vertices[1].y = dy + height;
    		vertices[1].z = 0;
    		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
    		j += sliceWidth;
    	}
    	
    	sceGuFinish();
    	sceGuSync(0, 0);
    }
    I'm not even going to bother with the first technique I posted. It works, but is much too slow for an interactive solution...

    Finding the Angle of Rotation

    Guess what? MORE MATH!
    You'll once again need to know trig.
    See here if you still haven't read it...
    http://mathworld.wolfram.com/Trigonometry.html

    Basically, there are three points in a triangle you'll be using.

    First point is your cannon, the image that needs to be rotated
    Second point is your cursor (or place you'll be aiming)
    Third point is your cursor, but with the same y value as your cannon

    Given these three points, a right angled triangle will be produced, which we can use trig on.

    SOH CAH TOA
    Sine = Opposite/Hypotenuse,
    Cosine= Adjacent/Hypotenuse,
    Tangent = Opposite/Adjacent

    To find the angle you need to rotate the cannon, you'll end up using one of those to find the angle based on side length.

    Read up on it, or ask your math teacher, over here in Australia trig's in the syllabus, so the teacher should be able to help, just explain what you're trying to do.
    Developer of Airstrike

  7. #97
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von Smerity
    SG57 -
    Rotating an image
    Sorry to say, if you need to rotate an image, and you want to program that anew, you're going to have to scratch up on your maths.

    Mainly the use of trigonometry, specifically sine and cosine.
    See http://freespace.virgin.net/hugo.eli...nes/rotate.htm and http://mathworld.wolfram.com/Trigonometry.html

    Ie, first issue, look back at my previous post for most of the details on rotating an image.
    Onto the function you want, in graphics.c they have the blitting image function atm, and it could be modified into what is needed for rotation...

    Code:
    void blitAlphaImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy)
    {
    	if (!initialized) return;
     
    	sceKernelDcacheWritebackInvalidateAll();
    	guStart();
    	sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
    	float u = 1.0f / ((float)source->textureWidth);
    	float v = 1.0f / ((float)source->textureHeight);
    	sceGuTexScale(u, v);
     
    	int j = 0;
    	while (j < width) {
    		Vertex* vertices = (Vertex*) sceGuGetMemory(2 * sizeof(Vertex));
    		int sliceWidth = 64;
    		if (j + sliceWidth > width) sliceWidth = width - j;
    		vertices[0].u = sx + j;
    		vertices[0].v = sy;
    		vertices[0].x = dx + j;
    		vertices[0].y = dy;
    		vertices[0].z = 0;
    		vertices[1].u = sx + j + sliceWidth;
    		vertices[1].v = sy + height;
    		vertices[1].x = dx + j + sliceWidth;
    		vertices[1].y = dy + height;
    		vertices[1].z = 0;
    		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
    		j += sliceWidth;
    	}
     
    	sceGuFinish();
    	sceGuSync(0, 0);
    }
    I'm not even going to bother with the first technique I posted. It works, but is much too slow for an interactive solution...
    So, is the code right there your first post? Or the other one that i cant use offsetts on? Also, im in 8th grade, Math Int 1, (9th grade math lamen terms), and my teacher has just today introduced us to

    MATH TIME:

    Sine and Cosine and Tangent, my homework is it matter of fact.

    ^ ---------------------'A'
    |~\ ----------------- hypotneus
    |__\ ------------------'C'

    ^'B'
    Now, the sine of this (opposite) is (when ~ is the angle thing) BC right? Now, the Cosine of this (adjacent) is AB right? Now, the tangent (sine/cosine ?) is if BC = 2 and AB = 3, 2/3? This is just an example, to get a hang of sine, cosine, and tangent.

    Smerity, you know alot (chingwyn also helped me and answerd my questions), could you tell me if my math was wrong so I can correct it and understand that rotating function of yours?

    Thanks Smerity (or anyone else if they help)
    Geändert von SG57 (02-21-2006 um 08:04 PM Uhr)

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  8. #98
    Developer
    Points: 5.116, Level: 45
    Level completed: 83%, Points required for next Level: 34
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    Sydney, Australia
    Beiträge
    128
    Points
    5.116
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    SG57 -

    I'm only just in Year 11 myself.
    When I started getting really into programming, I wasn't ready for the math side of it, and thus I had to learn a lot... It's really good to learn stuff like this by yourself. It also gives you a huge leg up over other kids in the class.

    For example, when I was interested in raytracing, I had to learn about quadratics (ax^2+bx+c), circles (x^2+y^2=r^2) and spheres (x^2+y^2+z^2=r^3) and so on.
    By the time school finally started on that, I had the easiest time in the world. So it does help you out...

    Anyway, back to the problem.
    Until you have a solid understanding of trigonometry, spec. sine and cosine, it will be quite hard for you to get a lot of this. Once again, study up mate.

    Nonetheless, I'll try to program something for you tonight on using trig to aim a little target thing at a cursor.
    Please note that it WILL NOT ROTATE AN IMAGE. I haven't worked that out fully yet myself. It will however allow you to work out the whole angle side of it et al.
    Developer of Airstrike

  9. #99
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von Smerity
    SG57 -

    I'm only just in Year 11 myself.
    When I started getting really into programming, I wasn't ready for the math side of it, and thus I had to learn a lot... It's really good to learn stuff like this by yourself. It also gives you a huge leg up over other kids in the class.

    For example, when I was interested in raytracing, I had to learn about quadratics (ax^2+bx+c), circles (x^2+y^2=r^2) and spheres (x^2+y^2+z^2=r^3) and so on.
    By the time school finally started on that, I had the easiest time in the world. So it does help you out...

    Anyway, back to the problem.
    Until you have a solid understanding of trigonometry, spec. sine and cosine, it will be quite hard for you to get a lot of this. Once again, study up mate.

    Nonetheless, I'll try to program something for you tonight on using trig to aim a little target thing at a cursor.
    Please note that it WILL NOT ROTATE AN IMAGE. I haven't worked that out fully yet myself. It will however allow you to work out the whole angle side of it et al.
    THANK YOU, Smerity, you are a life saver. I want to learn all this stuff before going to highschool and do MAth Integrated 2 (aka sophmore math or 10th grade math), that way I can have it easy like you, and after being intoduced to Sine and Cosine and Tangent today, Im willing to learn, and right now, I have math homework with Sine/Cosine and tangent, but after going to the websites about trig, im having a much easier time, thanks alot Smerity, definitly helped me out.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  10. #100
    Developer
    Points: 5.116, Level: 45
    Level completed: 83%, Points required for next Level: 34
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    Sydney, Australia
    Beiträge
    128
    Points
    5.116
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard


    That's a screenshot of the working code...
    All mine, other than the smilie by IchigoKurosaki =)
    I had to use that smilie SOMEWHERE!

    Screenshot = O
    Other than that, just use the analog stick and it shows the variables interactively...

    Full source (Makefile, C files et al) = http://www.smerity.com/psp/rotate.zip

    Code:
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <png.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "./graphics/graphics.h"
    #include "screenshot.c"
    
    #include <psppower.h>
    
    #include <math.h>
    
    #include "callback.h"
    
    #define RGB(r, g, b) ((b << 16) | (g << 8) | r)
    #define BLUE RGB(0, 0, 255)
    #define RED RGB(255, 0, 0)
    #define GREEN RGB(0, 255, 0)
    #define BLACK RGB(0, 0, 0)
    #define WHITE RGB(255, 255, 255)
    
    #define pi 3.14159265358979
    
    #define printf pspDebugScreenPrintf
    
    PSP_MODULE_INFO("Trig", 0, 1, 1);
    
    int main() {
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
    SceCtrlData pad;
    
    char buffer[200];
    char filler[100];
    pspDebugScreenInit();
    SetupCallbacks();
    initGraphics();
    int exit = 0; //cx, cy, xi, yi;
    float adj = 0.0f, adjpos = 0.0f, hyp = 0.0f, opp = 0.0f;
    float opppos = 0.0f, cos = 0.0f, angle = 0.0f, angler = 0.0f;
    
    Image* cursor;
    sprintf(buffer, "img/cursor.png");
    cursor = loadImage(buffer);
    
    Image* smile;
    sprintf(buffer, "img/smile.png");
    smile = loadImage(buffer);
    
    Image* circle;
    sprintf(buffer, "img/circ.png");
    circle = loadImage(buffer);
    
    int cursorx = 240, cursory = 136;
    
    while (!exit)
    {
    clearScreen(BLACK);
    sceCtrlReadBufferPositive(&pad, 1);
    
    sprintf(filler, "Angle = %i", (int)angle);
    printTextScreen(12, 12, filler, RGB(55, 55, 55 ));
    printTextScreen(10, 10, filler, RGB(200, 200, 200 ));
    
    sprintf(filler, "Adjacent = %i", (int)adjpos);
    printTextScreen(12, 22, filler, RGB(55, 55, 55 ));
    printTextScreen(10, 22, filler, RGB(200, 200, 200 ));
    
    sprintf(filler, "Opposite = %i", (int)opppos);
    printTextScreen(12, 32, filler, RGB(55, 55, 55 ));
    printTextScreen(10, 32, filler, RGB(200, 200, 200 ));
    
    float cx = ((pad.Lx - 125)/16);
    float cy = ((pad.Ly - 125)/16);
    cursorx = cursorx + (int)cx;
    cursory = cursory + (int)cy;
    if ( cursorx > 480 ) cursorx = 470;
    if ( cursory > 272 ) cursory = 267;
    if ( cursorx < 0 ) cursorx = 0;
    if ( cursory < 0 ) cursory = 0;
    
    // third point of triangle is x = cursorx, y = center's y (so to create right angled triangle)
    
    drawLineScreen(240, 135, (int)cursorx, (int)cursory, RGB(150, 10, 10)); // center to cursor
    drawLineScreen((int)cursorx, 135, (int)cursorx, (int)cursory, RGB(10, 10, 155)); // right angle to cursor
    drawLineScreen((int)cursorx, 135, 240, 135, RGB(10, 150, 10)); // right angle to cursor
    
    //find side length of adj and other side (opp)
    adj = (int)cursorx - 240; // only have to do x as y doesn't change
    opp = (int)cursory - 135; // only have to do y as x doesn't change
    adjpos = adj; // this is to save the info on + and -
    opppos = -1*opp; // this is to save the info on + and -
    if (adj < 0) adj = adj*-1;
    
    // hyp = a2 + b2 = c2 (Pythagoras)
    hyp = adj*adj + opp*opp; // hyp will always be + as any square is positive
    hyp = sqrt(hyp);
    
    //cos = adjacent / hyptoenuse
    cos = adj/hyp;
    angler = acosf(cos);
    // we now have the angle, but it's in radian form
    angle = angler * (180.0f/pi);
    // now we have to get it to recognise quadrants
    //-x, +y is good, no change needed
    //+x, +y is not good, need to - angle from 180
    //+x, -y is not good, need to + angle from 180
    //-x, -y is not good, need to - angle from 360
    if ( adjpos >= 0 && opppos >= 0 ) angle = 180 - angle;
    else if ( adjpos >= 0 && opppos <= 0 ) angle = 180 + angle;
    else if ( adjpos <= 0 && opppos <= 0 ) angle = 360 - angle;
    
    blitAlphaImageToScreen( 0, 0, 32, 32, smile, 240-16, 135-16); // center
    
    blitAlphaImageToScreen( 0, 0, 24, 24, cursor, (int)cursorx-12, (int)cursory-12);
    
    // original coordinates for the lil bobbly circle
    int sx = 0, sy = 24;
    int xi = sx, yi = sy;
    angler =  (angle+90) / 180.0f * pi;
    
    sx = xi*cosf(angler) - yi*sinf(angler) + 240;
    sy = xi*sinf(angler) + yi*cosf(angler) + 135;
    
    blitAlphaImageToScreen( 0, 0, 12, 12, circle, (int)sx-6, (int)sy-6);
    
    flipScreen();
    sceKernelDelayThread(10000);
    
    if (pad.Buttons & PSP_CTRL_CIRCLE)
    screenshot("screen.png");
    
    } // while(!exit)  */
    
    clearScreen(BLACK);
    sceKernelExitGame();
    return 0;
    } // main
    Developer of Airstrike

  11. #101
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Hey thanks, that helps me with homework too. I guess that will do for cos and sine and tanget for now while coding. But let me know if you get rotation right and working please thanks Smerity, you have helped alot.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  12. #102
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    87
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Ok, I have a question. It doesn't really relate to the PSP, but here goes:
    I'm currently learning C++ from a book I got at Borders, but I don't understand one thing: in the book it says to add these two lines of code before return 0 in a program to keep it from closing a split second after it opens. These two lines are:
    std::cout << "Press the enter key to exit";
    std::cin.ignore(std::cin. rdbuf()->in_avail() + 1);
    But, it doesn't seem to work with any program that requires the user to input information. Is there anyway to fix this? (for example: the program will open, ask the user to input some information and press enter, but after pressing enter the window will close. I think it might have something to do with using the enter key to exit, but I'm really a novice and I don't know how to set it to other keys.)

    Edit: Nvm, it turns out all I had to do was change it to +2 instead of +1.

  13. #103
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    well, cout is baically printf/pspDebugScreenPrintf is C for PSP, and std (not sexually transmitted disease) is a
    lib, did you include stdlib and stderror?

    My question.

    Say i have a huge text string that will go off screen from the left to right. is this something i could do about that?

    Code:
    if(char string here > 480 / 5 characters over) {
    	 char string("\n");
    }
    Since a character is about 5 when calling a simple debug printf, then every time a string type thing has over 480 (pixels over) / 5 (character width), then it will do an enter thing. In know its wrong, but it was a guyess.

    Second. How could i do soemthing like only print the 10th character starting from the beginning of the string? for example:

    Code:
    printf("123456789abcdefghijklmnopqrstuvwxyz");
    i would want the 'a, k, u' to print. How could that be done? Tahnks alot if you help (Smerity?)
    Geändert von SG57 (02-24-2006 um 03:58 PM Uhr)

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  14. #104
    QJ Gamer Green
    Points: 25.223, Level: 95
    Level completed: 88%, Points required for next Level: 127
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    4.289
    Points
    25.223
    Level
    95
    Downloads
    0
    Uploads
    0

    Standard

    Um, you could do a for loop, and make it something like:

    Code:
    for(i=0;i < strlen(text); i= i+10)
         { printf("%c", text[i]);
    }
    I think that would work.

    edit: for your first question, you could simply find out the number of characters that can be held on a line using the debug printf, then, use the loop I showed you above ^ and somehow incorporate that every, say, 200 characters a \n is injected, I htink you could do it in inside the loop, like have an additional variable, j, and start it at zero. Every time you do the printf, before the actual printf, you add one to j. Then do a simple if statement,

    Code:
    if(j==200)
       {printf("%c\n", text[i]); // adds a carriage return or whatever
       j = 0;
    }
    else { printf("%c", text[i]); //prints letter normally because its not at the end of the line
    j++;
    }
    Geändert von soccerPMN (02-27-2006 um 02:20 PM Uhr)

  15. #105
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    ya, thanks, i was looking for something of the sort. thanks.

    Smerity - I have been looking fr a rotating 'function' on thenet, and so far, its basically telling me examples of whats going on, nothing too specific towards rotating something to a specific degree. I dont mean to badger, but I was wondering fi you have found something yet?

    That geometry type shooter has kind of what im looking for, maybe ill pm the developer for how he did it?

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


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

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

    Standard

    Okay, I'm having a problem
    My code is working great, except for one thing right now.
    When I use the graphics.c/h code being printTextScreen()
    it draws the text at the coordinates I gave it, but reads the \n as a square with a circle in it.

    Is there another character group used for new lines

  17. #107
    QJ Gamer Silver
    Points: 9.457, Level: 65
    Level completed: 36%, Points required for next Level: 193
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    Canada
    Beiträge
    1.492
    Points
    9.457
    Level
    65
    Downloads
    0
    Uploads
    0

    Standard

    Since you give printtextscreen co-ords there is no need for the newline code, so I don't think it interprets it right...

    if your first line is at 10,10 then just make your second line 10,20 and so on....
    PSN: Shatterdome

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

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

    Standard

    Can anyone tell me what exactly "." & ".." mean when reading directories because sprintf(directory,"./%s/,start.item[#]);
    doesn't work
    i thought "." meant ms0:/currentdirectory
    so I added and "/" then the next name and since it was a directory I finished with an "/" but this and a few other ideas didn't work I know the string I put in though has no "/" at its end :Argh:
    Geändert von Devun_06 (03-07-2006 um 12:19 PM Uhr)

  19. #109
    Points: 4.439, Level: 42
    Level completed: 45%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Beiträge
    32
    Points
    4.439
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I don't know if this is the right thread to ask this, but is there a Windows program which extracts .ELF -files off from Kxploited .PBP's?

  20. #110
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    there is an elf2pbp, pbpExplorer, and if you have cygwin installed, along with SDL, you can use pbp-unpack and pbp-pack.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  21. #111
    QJ Gamer Blue
    Points: 4.803, Level: 44
    Level completed: 27%, Points required for next Level: 147
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    33
    Points
    4.803
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Alright, I've got a bit of a question about image display.

    Let's say I've got code that looks kind of like this:
    Code:
    while(1)
    {
       DisplayBackground();
       DisplayItem1();
       DisplayItem2();
       flipscreen();
    }
    Obviously, this will draw the background, the two items on top of it, then display it.

    What if we change the code a bit to look like this:
    Code:
    DisplayBackground();
    while(1)
    {
       MoveItem1();
       DisplayItem1();
       MoveItem2();
       DisplayItem2();
       flipScreen();
    }
    Now, since the items are moving and the background is no longer being refreshed on top of the items' previous positions, you get a trippy blur effect.

    My issue is, since the "old" images are still getting displayed, they're obviously still stored in memory, and they're staying there. This means that whether you have a refreshing background or not, if you keep redrawing images to create animation, you're going to eventually run out of memory, it's gonna overflow, and the system will likely crash.

    How do I avoid this? I'm running into a system crash with my current game that pops up every time after you've played it for a bit, and I think this is what's happening. What can I do to clear the junk out of there?
    Geändert von Andorien (03-09-2006 um 11:19 PM Uhr)

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

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

    Standard

    After I have made the psp to show my image on the screen (using the same way as in the 4th tutorial) but now can't I draw text to the screen anylonger by using the printf() command... Do I need to disable the graphics in (if so, how?) or is there an other command used to draw text on an image??

    Thanks in Advance!

  23. #113
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    #include "graphics.h"

    printTextScreen(xCo-ordinate, yCo-ordinate, "whatever", Color);

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


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

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

    Lightbulb

    I know this is crazy, but why does the following lines of code mess up my program? I'm sure these are the only lines invloved because when I temporarily comment them out the whole program works again.

    Code:
    int extention_fallback=strlen(start.item[dircount]);// only for checking if .***\0 exists for use in this function ONLY! :0
    if(start.item[dircount][(extention_fallback-4)]=='.')
    {start.type[dircount]=1;/*it's a file*/}else {start.type[dircount]=0;/*it's a folder*/}
    can you not check for a specific character? I wrapped the . in "" & '' and I've tried wrapping multiple parenthesis around all the parts of the if statement as possible... and it still crashes everything.

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

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

    Standard

    Thanks for your reply sg57 but I still can't see the text. Here is the code:

    Code:
    // INCLUDES
    
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <png.h>
    #include <stdio.h>
    #include "graphics.h" 
    
    // Using RGB-Color-Mode
    
    #define RGB(r, g, b) ((b << 16) | (g << 8) | r)
    
    // Using lazy printf
    
    #define printf pspDebugScreenPrintf
    #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
    
    // MODULE INITIALISATION
    
    PSP_MODULE_INFO("ECTTT", 0, 1, 1);
    
    //Home button function 
    
     /* Exit callback */
    int exit_callback(int arg1, int arg2, void *common) {
              sceKernelExitGame();
              return 0;
    }
    
    /* Callback thread */
    int CallbackThread(SceSize args, void *argp) {
              int cbid;
    
              cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
              sceKernelRegisterExitCallback(cbid);
    
              sceKernelSleepThreadCB();
    
              return 0;
    }
    
    /* Sets up the callback thread and returns its thread id */
    int SetupCallbacks(void) {
              int thid = 0;
    
              thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
              if(thid >= 0) {
                        sceKernelStartThread(thid, 0, 0);
              }
    
              return thid;
    }
    
    
    // Int main and choose buffer size
    
     int main() {
              char buffer[200];
              Image* backpic;
    
    // Prepares the psp to display graphics
    
              pspDebugScreenInit();
              SetupCallbacks();
              initGraphics();
    
    // 
    		  
    	    sprintf(buffer, "backpic.png");
              backpic = loadImage(buffer);
    
    // If Something should go wrong:
    
    		  if (!backpic) {
              printf("Something went wrong! Check that you have all the files needed on your memory stick.\n");
              } else {
    
    // If it boots as it should (setup for image Display) and activate use of home button:
    
              int x = 0;
              int y = 0;
              sceDisplayWaitVblankStart();
    
    // Activate fullscreen Res pic viewing (480x272) 
    
    	      while (x < 480) {
              while (y < 272) { 
    
    // Blit (display) the background (In the Memory) :
    
              blitAlphaImageToScreen(0 ,0 ,480 , 272, backpic, x, y);
              y += 272;
    		  }
    
    // Add the incrementation for the x:
    
              x += 480;
              y = 0;
              }
    
    // Display the Background on the screen:
    
              flipScreen();
              }
    
    	    printTextScreen(10, 10, "whatever", RGB(255, 0, 0));
    
    // Let the kernel sleep:
    
              sceKernelSleepThread();
              return 0;
    
    
     return 0;
    }

  26. #116
    QJ Gamer Blue
    Points: 4.803, Level: 44
    Level completed: 27%, Points required for next Level: 147
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    33
    Points
    4.803
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SodR
    Thanks for your reply sg57 but I still can't see the text. Here is the code:

    Code:
    Lots of code!
    The printTextScreen function doesn't work like the debug function. It requires a buffer exchange to get it on the screen.

    Therefore, change your last bit of code to look like this:

    Code:
    }
    
                // Display everything
    	    printTextScreen(10, 10, "whatever", RGB(255, 0, 0));
                flipScreen();
    Geändert von Andorien (03-11-2006 um 05:12 AM Uhr)

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

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

    Standard

    How stupid of me to put the flipscreen command before the text =S Anyway, thanks alot!

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

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

    Standard

    Sorry eveyone for the dubble post but now I got another problem:

    I have some code that is supposed to launch the inserted umd, but when I try to compile cygwin gives me these errors:

    Code:
    main.o: In function 'main':
    main.c: (.text+0x1fc): undefined reference to 'sceUmdCheckMedium'
    main.c: (.text+0x210): undefined reference to 'sceUmdActivate'
    main.c: (.text+0x234): undefined reference to 'sceUmdDriveStat'
    main.c: (.text+0x5c8): undefined reference to 'sceUmdCheckMedium'
    collect2: Id returned 1 exit status
    make *** [hello.elf] Error 1
    My Included libs :

    Code:
    #include <pspiofilemgr.h>
    #include <pspumd.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspgu.h>
    #include <png.h>
    #include <stdio.h>
    #include "graphics.h" 
    #include <stdlib.h>
    #include <string.h>
    Here is the UMD launch part (Most of it borrowed from UMDLoader by Ichigo):
    Code:
     	    while(1) {
              sceCtrlReadBufferPositive(&pad, 1);
              if(pad.Buttons & PSP_CTRL_CIRCLE) {
              break;
              } 
    
    	    i = sceUmdCheckMedium(0);		
              if (i == 0) { printTextScreen(10, 10, "Insert UMD", RGB(0, 0, 0)); 
    	    flipScreen(); }
              while (i == 0) {
    	    i = sceUmdCheckMedium(0);
    	    }
    	    i = sceUmdActivate(1, "disc0:");
    	    printTextScreen(10, 10, "Starting UMD, Please Wait", RGB(0, 0, 0));
    	    flipScreen();
              i = sceUmdWaitDriveStat(UMD_WAITFORINIT);
              fd = sceIoOpen("disc0:/UMD_DATA.BIN", PSP_O_RDONLY, 0777);
              if(fd >= 0)
    	    {
    	    char game_id[11];
              sceIoRead(fd, game_id, 10);
    	    sceIoClose(fd);
    	    game_id[10] = 0;
              }
              sceKernelLoadExec("disc0:/PSP_GAME/SYSDIR/BOOT.BIN",0); 
    	    }

  29. #119
    QJ Gamer Blue
    Points: 4.803, Level: 44
    Level completed: 27%, Points required for next Level: 147
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    33
    Points
    4.803
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Seems a little strange. You may have missed some libraries in your Makefile. Other than that, the only thing that comes to mind would be that you might need to do a clean compile (IE, delete all previous object, elf, and SFO files before compiling).

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

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

    Standard

    I tryed to delete every old files but no go.
    my makefile looks like this:

    Code:
    TARGET = hello
    OBJS = main.o graphics.o framebuffer.o
    
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBDIR =
    LIBS = -lpspgu -lpng -lz -lm
    LDFLAGS =
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = WorkInProgress
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    Maybe I need to download any special libs or something to use pspumd.h??


 
Seite 4 von 340 ErsteErste 1 2 3 4 5 6 7 8 9 10 11 12 13 14 54 104 ... LetzteLetzte

Tags for this Thread

Forumregeln

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





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

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