The Interpreter:
First you need stackless python psp: http://code.google.com/p/pspstacklesspy ... p&can=2&q=
Script:
Your main application will be stored in a file called script.py, placed in the same place as eboot.pbp (the interpreter).
Psp2d:
This module provides a 2d graphics library for all your python needs. Make sure psp2d.py is in the same place as script.py. You can find it here: http://code.google.com/p/pspstacklesspy ... p&can=2&q=
Font:
Psp2d uses sfonts which you can find by google searching. Here is an example: http://code.google.com/p/pspstacklesspy ... p&can=2&q=
Hello World:
Let's start with the basics, and what better way to learn than with our typical hello world.
Code: Select all
import psp2d
font = psp2d.Font("font.png")
image = psp2d.Image(480, 272)
screen = psp2d.Screen()
CLEAR_COLOR = psp2d.Color(0,0,0)
image.clear(CLEAR_COLOR)
font.drawText(image, 0, 0, "Hello World")
screen.blit(image)
screen.swap()
Code: Select all
font = psp2d.Font("font.png")
Code: Select all
image = psp2d.Image(480, 272)
Code: Select all
image = psp2d.Image("background.png")
Code: Select all
screen = psp2d.Screen()
Code: Select all
CLEAR_COLOR = psp2d.Color(0,0,0)
Code: Select all
image.clear(CLEAR_COLOR)
Code: Select all
font.drawText(image, 0, 0, "Hello World")
Code: Select all
screen.blit(image)
Code: Select all
screen.swap()
Controller:
Psp2d has access to all the buttons on the psp except the note key, the screen key, the volume keys, and the home key. It is pretty simple to use:
Code: Select all
pad = psp2d.Controller()
Code: Select all
pad.up
pad.down
pad.left
pad.right
pad.cross
pad.circle
pad.square
pad.triangle
pad.l
pad.r
pad.start
pad.select
pad.analogX
pad.analogY
Code: Select all
if pad.cross:
do something
elif pad.circle:
do something different
Code: Select all
while True:
pad = psp2d.Controller()
if pad.cross:
do something
Code: Select all
x = True
while x == True:
pad = psp2d.Controller()
if pad.circle:
x = False
Let's put all the above into a live example:
Code: Select all
import psp2d
font = psp2d.Font("font.png")
image = psp2d.Image(480, 272)
screen = psp2d.Screen()
CLEAR_COLOR = psp2d.Color(0,0,0)
image.clear(CLEAR_COLOR)
font.drawText(image, 0, 0, "Hello World!")
font.drawText(image, 0, 30, "Press Circle to exit")
screen.blit(image)
screen.swap()
x = True
while x == True:
pad = psp2d.Controller()
if pad.circle:
font.drawText(image, 0, 60, "Goodbye!")
screen.blit(image)
screen.swap()
x = False
Running psp python homebrews on pc:
Since python is cross-platform and the psp2d.py file acts as a muck-up of pygame you can play and debug all psp homebrews written in python on a pc. To do this you need to install pygame (google it). Here is a screenshot of various psp python homebrews running on a pc: Next: viewtopic.php?f=5&t=13373&p=159645