Page 2 of 99 FirstFirst 1 2 3 4 12 52 ... LastLast
Results 11 to 20 of 983

Thread: How to create Games and Apps on your PSP using OSlib

  
  1. #11
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    Yeah, I forgot to place the links there. I was going to go into more detail about each of those 2 functions in another post but i completely forgot xD Thanks for reminding me and formating my posts so that they look a lot better to the user, Zinga. I appreciate it.
    For everyone else, there is a lot this library can do to make your "homebrewing" a lot easier. I'll try to cover most of the functions in this library with lessons and demos.

    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  2. #12
    itsalldasame2me is offline -Hacks Member
    Join Date
    Mar 2006
    Location
    California
    Posts
    256
    Rep Power
    13

    Default

    PSdonkey this tutorial is great. All your tutorials are easy to understand and well organized.

  3. #13
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    Thanks. Next lesson should be up some time tomorrow.
    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  4. #14
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    Alright, here is lesson 2. I will show you how to use the PSP's buttons and I will go more into printing text onto your screen.


    Lesson 2: PSP controller inputs

    As you know, the PSP has several buttons. There are 4 buttons on the right hand side which are: cross, square, circle and triangle. There is also the L1 and R1 buttons on the top. Plus there is the analog stick which you can use in your programs. Here is a simple program which will print a text on your screen and depending on the button that you push, a different message will appear for each button. It will also show the movement of the analog stick when you move it left/right (X-axis) or up/down (Y-axis).

    Here is the Makefile for this Lesson 2:

    Code:
    TARGET = Donkey_Lesson2
    OBJS = main.o  
    
    INCDIR = 
    CFLAGS = -G4 -Wall -O2 
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBDIR =
    LDFLAGS =
    STDLIBS= -losl -lpng -lz \
      -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
    LIBS=$(STDLIBS)$(YOURLIBS)
    
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Donkey_Lesson2
    
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    Again, this Makefile is the exact same as the Makefile used in Lesson 1 except I changed the Target name to Donkey_Lesson2 and I changed the EBOOT's program title to Donkey_Lesson2.

    Now here is the source code:
    Code:
    //OSlib header file
    #include <oslib/oslib.h>
    
    //Necessary to create eboot
    PSP_MODULE_INFO("OSLib Sample", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
    
    int main()
    {
        //Initialization of the Oslib library
        oslInit(0);
    
        //Initialization of the graphics mode
        oslInitGfx(OSL_PF_8888, 1);
    
        //Initialization of the text console
        oslInitConsole();
    
        //Main loop
        while (!osl_quit)
        {
            //To be able to draw on the screen
            oslStartDrawing();
            
            //initiate the PSP's buttons
            oslReadKeys();
            
            //clears the screen
            oslCls();
      
            oslPrintf_xy(20,20,"What is your favorite psp site?");
            oslPrintf_xy(20,35,"If you like psp-hacks.com, push the X button");
    oslPrintf_xy(20,45,"If you like psp-downgrades.com, push the square button");
    oslPrintf_xy(20,55,"If you like psp-haxors.com, push the circle button");
    oslPrintf_xy(20,65,"If you like zingaburga.co.nr, push the triangle button");
    
            if (osl_keys->held.cross) oslPrintf_xy(20,85,"You voted for greg's site");
            if (osl_keys->held.square) oslPrintf_xy(20,85,"You voted for power's site");
            if (osl_keys->held.circle) oslPrintf_xy(20,85,"You voted for Chaos_Zero's site");
            if (osl_keys->held.triangle) oslPrintf_xy(20,85,"You voted for ZingaBurga's site");
    
            oslPrintf_xy(20,100,"Value of joystick X : %d",osl_keys->analogX);
            oslPrintf_xy(20,110,"Value of joystick Y : %d",osl_keys->analogY);
    
            //Ends drawing mode
            oslEndDrawing();
    
            //Synchronizes the screen 
            oslSyncFrame();        
        }
        
        //Terminate the program
        oslEndGfx();
        oslQuit();
        return 0;
    }
    Explanations:

    1) #include <oslib/oslib.h>
    You must include this in all of your programs that use OSlib.

    2) PSP_MODULE_INFO (“OSLib Sample”, 0, 1, 1);
    PSP_MAIN_THREAD_ATTR (THREAD_ATTR_USER | THREAD_ATTR_VFPU);
    This code is necessary for the PSPSDK to run the EBOOT that will be made by our program.

    3) oslInit (0);
    void oslInit(int useOwnCallbacks);
    This line of code takes care of all your PSP callbacks. Normally, without this library, you would have to setup and initialize your callbacks with every single PSP program. With this line of code, you don't need to worry about the callback initialization, as long as the value 0 is between the parenthesis (). If you want to use your own callbacks (if you do not know what that is, do not change it, of course), type 1 in the parenthesis.

    4) oslInitGfx (OSL_PF_8888, 0);
    void oslInitGfx(int pixelFormat, int bDoubleBuffer);
    This is used to initialize the graphic part, by specifying which pixelFormat you want to use on the screen, as well as if you want to use double buffering. Default 0 is used for single buffering and 1 for double buffering. With this Lesson, we are using (1) for double buffereing. Simply use OSL_PF_8888 for a 32-bit screen (2^32 = 16,777,216 colors) (-not entirely correct, but there is 16.7mil colours for 32 bit -ZiNgABuRgA) or OSL_PF_5650 for a 16-bit screen (2^16 = 65,536 colors) as an argument for pixelFormat.

    5) oslInitConsole ();
    This initialize the text part of the PSP, to be able to draw some text (the standard Sony font is loaded at this moment).

    6) while (!osl_quit)
    This is our main while loop. Everything within the two braces {} after while (!osl_quit) will keep on repeating itself until the osl_quit() command is found.
    It technically means "while the code does not osl_quit()". "!" means "does not"
    Hint: since osl_quit() is no where in between the two {} braces of the while loop, this program will loop forever unless you press the home button. You can change this by adding something like this to your code:
    if (osl_keys->pressed.start) osl_quit();
    That way, if the user wants to exit the loop/game, he would just have to press the start button.


    7) oslStartDrawing();
    You have to call this function before drawing anything onto the screen.

    8) oslReadKeys();
    Reads the input of all the buttons and stores in the total structure osl_keys. Make sure to call this function before having the user press a key (button).

    9) oslCls();
    Simply clears the screen.

    10) oslPrintf_xy(x,y,"");
    This function prints text to your screen and also lets you decide where you would like the text to be placed on the PSP's screen. X,Y are the X and Y coordinates of the text. " " are the quotations where your text is placed in between these quotations.

    11) if (osl_keys->held.cross)
    This is what you would type to read input from the cross button. To read from a different button, you would just change "cross" to another PSP button.
    Here is the list of the PSP's buttons to use with this library:
    Up > up
    Down > down
    Left > left
    Right > right
    Cross > cross
    Square > square
    Triangle > triangle
    Circle > circle
    L1 > L
    R1 > R
    Home > home
    Music note > note
    Select > select
    Start > start
    Hold > hold


    Also, you use held.cross] for when the user holds down the cross button. You would use pressed.cross for when the user just pushes the cross button once.

    12) osl_keys->analogX
    Same as #11 except this is for when the analog stick is used.
    osl_keys->analogX is the the X-axis of the analog stick and
    osl_keys->analogy is for the Y-axis of the analog stick.

    13) oslEndDrawing();
    This corresponds to oslStartDrawing. It is to be used with each frame and the end of all the drawing operations.

    14) oslSyncFrame();
    You need to call this after each frame. It will synchronize the screen, use it when you have finish all the drawings.

    15) oslEndGfx();
    This ends the graphics part of the library. You can also reset it with other parameters.

    16) oslQuit ();
    Quits the game immediately. You'll go back to the PSP game menu.

    17) return 0;
    Always used at the end of main()


    So now you have the basics of printing text to the screen, where the text can be placed, how to use the PSP's buttons, how to do something if the buttons are pushed, and more relating to controller inputs.

    In the next lesson, lesson3, I will show you how to load images onto your PSP. I will show you how to load a background image as a map and then load a sprite onto the map and move the sprite around.
    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  5. #15
    itsalldasame2me is offline -Hacks Member
    Join Date
    Mar 2006
    Location
    California
    Posts
    256
    Rep Power
    13

    Default

    wow another great lesson. thanks psdonkey.

  6. #16
    Rikus is offline -Hacks Hacker
    Join Date
    May 2006
    Location
    South Africa
    Posts
    887
    Rep Power
    12

    Default

    Hey PSdonkey!
    I want to make a program where i can actually type the text, could you please make short guide with everything that i need?
    I want to like make lets say a calculator which let me add up to numbers i type in...

    thanks in advance

  7. #17
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    Hmm, typing the text can be a bit tricky. Most apps/games just use the PSP's buttons to assign numbers and or symbols to them. Take a look at killaj's tic tac toe game in the other sticky in this section to get an understanding of moving numbers and/or letters up and down using the d-pad.
    If you really want something complicated like using the PSP's internal keyboard for use with your game/app, then use this code that i uploaded into your game/app.

    http://www.mediafire.com/?1n4zn2j4zjy

    NOTE: This code will only work if you have a 1.5 PSP. Not 3.03 oe or any se or oe edition. The reason being is that 1.5 vsh modules are not available which the code requires
    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  8. #18
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    New lesson coming soon. I will show you how to load images and move sprites on your PSP using this OSlib.
    Here is a screenshot of what we will create:

    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  9. #19
    Chernobyl is offline -Hacks Enthusiast
    Join Date
    Jan 2007
    Location
    Sydney Australia
    Posts
    453
    Rep Power
    12

    Default

    Looks pretty cool :D

  10. #20
    cor3 is offline Senior Member -Hacks Guru
    Join Date
    Sep 2006
    Location
    Cleveland
    Posts
    1,889
    Rep Power
    13

    Default

    hey i got a prob
    wen i try to make the eboots for the hello world
    i keep getting an error saying "No rule to make 'main.o', needed by "donkey_lesson.elf" , stop

    wat am i doing wrong?

Page 2 of 99 FirstFirst 1 2 3 4 12 52 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •