Forum rules: Forum rule Nº 15 is strictly enforced in this subforum.
#243825 by hgoel0974
Tue Mar 05, 2013 9:20 pm
SifJar wrote:Can anyone give me some pointers on running the code on PC? I have installed PyGame, and tried importing pygame as psp2d, but that didn't work (pygame has no Screen() function), so I'm not sure what I need to do. Or am I meant to import both pygame and psp2d (in which case, where do I get the psp2d module for PC)? Any advice would be great, would make it much easier to mess around with this rather than having to transfer py scripts back and forth between my PC and PSP for editing.

EDIT: Well I figured that out, needed to download this: https://code.google.com/p/pspstacklessp ... p&can=2&q=

But I do have another question; what would be the correct way to exit a program? For example I have this script:

Code: Select all#! /usr/bin/env python
import pygame, psp2d
scr = psp2d.Screen()
fnt = psp2d.Font("font.png")
img = psp2d.Image(480, 272)
img.clear(psp2d.Color(0,0,0))
fnt.drawText(img, 0, 0, "Hello World!")
fnt.drawText(img, 0, 20, "Press X to change the screen")
scr.blit(img)
scr.swap()
while True:
    pad = psp2d.Controller()
    if pad.cross:
        img.clear(psp2d.Color(255,0,0))
        fnt.drawText(img, 0, 0, "Now it's RED!")
        fnt.drawText(img, 0, 20, "Triangle to quit, Circle to change again!")
        scr.blit(img)
        scr.swap()
        while True:
            pad = psp2d.Controller()
            if pad.triangle: exit() #HERE
            elif pad.circle:
                img.clear(psp2d.Color(0,255,0))
                fnt.drawText(img, 0, 0, "GREEN!")
                fnt.drawText(img, 0, 20, "Square to exit now")
                scr.blit(img)
                scr.swap()
                while True:
                    pad = psp2d.Controller()
                    if pad.square: exit() #HERE


which works great apart from exiting the program (the lines commented with "#HERE"), which crashes both then PSP and when it is run on the PC. Is there some better way to do this? If so, could someone please tell me it? I've tried looking at samples, but I can't seem to find what I'm looking for...

EDIT: Actually, this does work on PC. But not on the PSP. And obviously the PSP is the more important factor here (although ideally the solution would work on both)


You don't need to have the pygame import, that is automatic in psp2d ;) The PSP can't run it because of that, also, if you ever have any problem, you should take a look at the pytrace.txt that is created in the same folder, it contains a detailed description of the error
Advertising
#243909 by SifJar
Wed Mar 06, 2013 10:39 am
hgoel0974 wrote:You don't need to have the pygame import, that is automatic in psp2d ;) The PSP can't run it because of that, also, if you ever have any problem, you should take a look at the pytrace.txt that is created in the same folder, it contains a detailed description of the error

Yeah, I figured out how to make psp2d work on the PC, I just had the pygame import there while I was using it on PC. I had it removed for the PSP; the script worked fine on the PSP, except for exiting. I should probably specify that it didn't "crash" as such, it would just hang whenever I called "exit()", and stop responding to any button other than Home, which would allow me to choose to exit to the XMB, but would not actually load the XMB, but would also hang on the "Please Wait" screen, forcing me to hold the power button to turn off the PSP and then turn it back on again.

Also, you do need the pygame import on PC, at least with the psp2d.py module I have. I personally found a script called "runner.py" that will import pygame and then load the script, so you can load the script unmodified from the PSP version. But pygame is imported by runner.py, not by psp2d.
Advertising
#244009 by hgoel0974
Wed Mar 06, 2013 7:21 pm
SifJar wrote:
hgoel0974 wrote:You don't need to have the pygame import, that is automatic in psp2d ;) The PSP can't run it because of that, also, if you ever have any problem, you should take a look at the pytrace.txt that is created in the same folder, it contains a detailed description of the error

Yeah, I figured out how to make psp2d work on the PC, I just had the pygame import there while I was using it on PC. I had it removed for the PSP; the script worked fine on the PSP, except for exiting. I should probably specify that it didn't "crash" as such, it would just hang whenever I called "exit()", and stop responding to any button other than Home, which would allow me to choose to exit to the XMB, but would not actually load the XMB, but would also hang on the "Please Wait" screen, forcing me to hold the power button to turn off the PSP and then turn it back on again.

Also, you do need the pygame import on PC, at least with the psp2d.py module I have. I personally found a script called "runner.py" that will import pygame and then load the script, so you can load the script unmodified from the PSP version. But pygame is imported by runner.py, not by psp2d.

That is weird, you shouldn't need to add an import pygame thing
#244038 by SifJar
Wed Mar 06, 2013 9:45 pm
hgoel0974 wrote:That is weird, you shouldn't need to add an import pygame thing
I have downloaded two versions of the psp2d.py wrapper, neither have had a pygame import in them, so in both cases it had to be imported manually. It's not a big deal, it all works just fine.
#311958 by hgoel0974
Wed Dec 11, 2013 12:09 am
grief3r wrote:how many threads can the psp processor handle?

I don't think there's a limit but you wouldn't want to do too many, it's just one core ;)
#321771 by m0skit0
Thu Dec 26, 2013 1:58 pm
grief3r wrote:so multiple threads = multiple pc registers?

Yes, operating system takes care of saving each thread CPU state and restoring it. This is called context-switching.
#343646 by alevisawesom
Fri Apr 04, 2014 12:01 am
I am kind of a noob to python (know a lot of C though), and am having trouble with the first exercise. It just exits to the XMB after about 5 seconds.
Code:
Code: Select allimport 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

Using Python 2.7.3.
Directory structure:
Documents
PSP
Hello
EBOOT.PBP
font.png
psp2d.py
pspmp3.py
pspnet.py
pspogg.py
pspos.py
pspsnd.py
python.zip
script.py
sfont.py

Anybody have anything? I'm using this as a basis for making a clone of "2048", as I need to learn some PSP programming basics before I jump in. Very skilled with C (NOT python), but there's probably a problem with my dir structure...
#343647 by Acid_Snake
Fri Apr 04, 2014 12:05 am
well the best step to solve it without breaking your head too much is to look for a file named pytrace.txt, which contains python's generated traceback for debugging.
When it comes to python there's two types of errors: syntax error (this would equate to C's compilation-time errors) and runtime errors (which equate to C's runtime errors). Both of which python tells you what the error is about and where it happened. On PC this is done by printing on the terminal, on PSP we gotta look at the file pytrace.txt

Who is online

Users browsing this forum: No registered users and 1 guest