General
[Main]


Defines

#define OSL_VERSION   "MOD 1.1.1"
#define oslSetQuitOnLoadFailure(enabled)   (osl_noFail = (enabled))
#define oslSetQuitOnLoadFailureCallback(function)   (osl_noFailCallback = function)
#define oslSetExitCallback(function)   (osl_exitCallback = function)

Enumerations

enum  OSL_INITFLAGS { OSL_IF_USEOWNCALLBACKS = 1, OSL_IF_NOVBLANKIRQ = 2 }

Functions

void oslInit (int flags)
void oslQuit ()

Detailed Description

Contains general routines to initialize and terminate the library.

Define Documentation

#define OSL_VERSION   "MOD 1.1.1"

OSLib version

#define oslSetQuitOnLoadFailure ( enabled   )     (osl_noFail = (enabled))

Sets the "no fail" mode. In this mode, if OSLib can't load a file (for example an image) it will display a gentleful message indicating to the user the name of the missing file, and quit immediately.

//Our objects (will be loaded)
OSL_IMAGE *img;
OSL_FONT *font;
OSL_SOUND *sound;

//Initialize OSLib
oslInit(0);
//Set-up drawing on a 5650 (16-bit) screen
oslInitGfx(OSL_PF_5650, 1);
//Enable the no-fail feature
oslSetQuitOnLoadFailure(1);

//An error will be displayed if any of these files could not be loaded properly.
image = oslLoadImageFilePNG("test.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5551);
font = oslLoadFontFile("font.oft");
sound = oslLoadSoundFileWAV("noise.wav", OSL_FMT_NONE);

//Here, we are sure everything is okay, we don't even need checking if they are NULL.
oslSetFont(font);
oslDrawImage(img);
oslPlaySound(sound, 0);

#define oslSetQuitOnLoadFailureCallback ( function   )     (osl_noFailCallback = function)

Sets the function to call in case of failure to load something. Default displays a message box.

//Our own function called when a loading has failed
void MyNoFailCallback(const char *filename, u32 reserved)               {
        //Display an error
        myDisplayMessage("Unable to locate the following file: %s\nPlease reinstall the application.", filename);
        //Always quit because we can't continue without these precious files
        oslQuit();
}

//Set-up no-fail.
oslSetQuitOnLoadFailure(1);
oslSetQuitOnLoadFailureCallback(MyNoFailCallback);
//This function will call MyNoFailCallback  because the specified file doesn't exist
oslLoadImageFileJPG("void:/notexisting.xyz", OSL_IN_RAM, OSL_PF_4BIT);

#define oslSetExitCallback ( function   )     (osl_exitCallback = function)

Sets an exit callback. This function is executed when the user chooses "Exit" from the HOME menu. By default, all what OSLib does is set osl_quit to True, so that you know that you should quit (all your game loops should watch out for osl_quit). A typical but dirty callback may be to force quitting immediately using oslQuit. Example:

int myExitCallback(int arg1, int arg2, void *common)
{
        oslQuit();
        return 0;
}

void main()                     {
        oslSetExitCallback(myExitCallback);
        while(1);
}


Enumeration Type Documentation

Flags for oslInit.

Enumerator:
OSL_IF_USEOWNCALLBACKS  Does not set up the standard callbacks. You'll have to provide them by yourself as shown in almost all PSPSDK samples.
OSL_IF_NOVBLANKIRQ  Does not reserve the VBLANK IRQ. You should set up your own VBL handler, which should call oslVblankNextFrame() if osl_vblankCounterActive is TRUE, else oslSyncFrame(Ex) will not work properly.


Function Documentation

void oslInit ( int  flags  ) 

Initializes the library. The options for the flags parameters are for advanced users only, let it to zero if you're beginning.

Parameters:
flags Can be formed of one or more of the values from the OSL_INITFLAGS enumeration (ORed together).

void oslQuit (  ) 

Exits the application immediately, returning to the XMB (PSP main menu) or to the calling application (e.g. IRShell).


Generated on Wed Feb 24 10:25:29 2010 by  doxygen 1.5.9