FIXME: This is not supported anymore. I don't know where the OSLib code is and I don't know if it's maintained any more.

I recently discovered the excellent OldSchool Library, and decided to make a Python binding for it. Since on the PSP all extension modules are linked statically, I have to disable the psp2d and pspsnd modules when building OSLib or they step on each other's feet. So, the regular Python-PSP release still include psp2d and pspsnd, but now there will be parallel releases of a binary including OSLib. This can be found here:

http://fraca7.free.fr/OSLib/EBOOT.PBP

Apart from that, installation is the same as for the regular release. OSLib samples can be found here:

http://fraca7.free.fr/OSLib/samples.zip

They're ports of the C library samples, the Sprite demo and the Maps demo.

Adapting code from C to Python should be pretty straightforward. Most of OSLib functions follow the pattern 'oslFunctionName()', and they're wrapped as 'functionName' in the 'osl' module, with the 'osl' prefix stripped and the first letter in lowercase.

Two exceptions with top-level functions and global variables are the following:

  • The global 'osl_quit' variable can be fetched through the 'osl.mustQuit()' function.
  • The 'oslQuit()' function is wrapped by 'osl.doQuit()'.

Constants named 'OSL_name' are wrapped as integer values named 'name' in the osl module.

The OSLib structures OSL_IMAGE, OSL_MAP, OSL_SOUND and OSL_CONTROLLER are wrapped as Python classes. Functions acting on these objects are wrapped as methods. Here is a reference for these classes.

OSL_IMAGE

This structure is wrapped in the class osl.Image.

Constructors

__init__(filename, location=osl.IN_VRAM, pf=osl.PF_8888)

This constructor loads an image from a file (OSLib only supports PNG at the moment).

__init__((w, h), location=osl.IN_VRAM, pf=osl.PF_8888)

This constructor creates an image. Initial content is undefined. Note that the first argument is a 2-tuple of integers.

Attributes

Some members of the OSL_IMAGE structure are made available as regular properties: x, y, stretchX, stretchY, offsetX0, offsetY0, offsetX1, offsetY1, centerX, centerY, angle, autoStrip are read and write. sizeX and sizeY are read-only.

Methods

copy(img)

Copies another image into this one. They must have the same pixel format. Maps to oslCopyImage.

uncache()

Wraps oslUncacheImage().

draw()

Wraps oslDrawImage().

correctHalfBorder()

Wraps oslCorrectImageHalfBorder(). I don't event know what this is for.

lock()

oslLockImage()

unlock()

oslUnlockImage()

tile(x0, y0, x1, y1)

oslCreateImageTile()

swizzle(dst)

oslSwizzleImage(dst, self)

clear(color)

oslClearImage(self, color)

write(filename, flags=0)

Writes the image to a file

Warning!

When images are created in VRAM, the last created one must be destroyed first. This isn't handled yet, so avoid using images in VRAM, or ensure you delete the references in the right order.

OSL_SOUND

class osl.Sound.

Constructors

__init__(filename, fmt=osl.FMT_NONE)

Loads a sound file.

Methods

play(voice=0)

Plays the sound.

stop()

Stops playing.

pause(pause=1)

Pauses the playback.

loop(loop=1)

Sets looping on/off.

getChannel()

Returns the channel used for this sound.

OSL_CONTROLLER

osl.Controller. The key state is loaded upon instantiation.

Attributes

The structure members are wrapped in the following (read-only) attributes:

held_select

held_start

held_up held_right

held_down

held_left

held_L

held_R

held_triangle

held_circle

held_cross

held_square

held_home

held_hold

held_note

pressed_select

pressed_start

pressed_up

pressed_right

pressed_down

pressed_left

pressed_L

pressed_R

pressed_triangle

pressed_circle

pressed_cross

pressed_square

pressed_home

pressed_hold

pressed_note

autoRepeatInit

autoRepeatInterval

autoRepeatMask

autoRepeatCounter

analogX

analogY

OSL_MAP

osl.Map

Constructor

__init__(img, data, tileX, tileY)

'img' must be an instance of osl.Image or a subclass thereof. 'data' must be a list of list of integers. See the Maps sample.

Attributes

These are read-write.

scrollX

scrollY

Methods

draw()

Wraps oslDrawMap().

drawSimple()

Wraps oslDrawMapSimple().

OSL_FONT

osl.Font

Constructor

__init__(filename)

Loads a font from a file.

Methods

set()

Sets this font as the current font.

Related functions

drawString(x, y, string)

Draws a string using the current font

drawTextBox(x0, y0, x1, y1, string, format)

oslDrawTextBox


Pages linking to OSLIB:
OlderNews