Lab

October 20, 2010 at 11:29AM

PSP 2D Racer Game

A few months ago I found a funny nice tutorial on XNA 2D racing games and decided to port it to the PSP. The game is not exactly the same since the PSP screen is smaller than a normal PC, so I pan the track based on the player position. It is a shame that it doesn't work properly on the jpcsp emulator but works great on the psp.

spout for the PSP

"Spout" is a small, abstract shooting game from Japanese developer kuni. It plays somewhat like Finnish cavefliers, except you have to erode your surroundings with your ship’s exhuast. It’s great fun :-) Your goal is to fly upwards as long as you possibly can, without crashing or your time running out.

PSP J++

In the last weeks I've been busy working to improve my very rusty C skills. I've thought about what kind of application I'd like to code and since I'm not totally familiar with the full API of the PSP Homebrew SDK I've decided to keep it simple and do something that can compile and link with just the C lib and the C99 standard. This means that the title is kind of a cheat because my application can run both on my host environment and the PSP. I've decided that I'd try to make a simple JVM, wait, not the SUN JVM but a subset in case you're looking for a full fledge JVM to write your games on. No this is a tiny JVM that only supports data types until 32 bits (no long, no double), it has no threading support (except using external libraries) and Exceptions seem not to work either. The whole JVM code is around 90kb of C code and 100Kb of java code. In case you ask why java code if you don't have a JM yet, the answer is that i wrote a simple pre compiler that optimizes the bytecode and transforms it to a middle representation before linking with the VM code. This approach sound strange and breaks the code once run everywhere slogan but helps alot. First the VM code doesn't need to worry about pre-verification as required by the SUN specs, there is no need to use class loaders since all code is already on the data segment of your binary. (Yes on the data segment not on the code segment). So lets do an example, (since my classpath is limited to the String, System, OutputStream and Printwriter Objects) we can't do much but it's a start.

  • First you code your HelloWorld in java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World from the pspVM");
    }
}
  • Second you compile it the normal way (i've used JDK 1.6). This compilation step is very usefull because it is easier to parse the bytecode than write a full parser and compiler to the java language.
javac HelloWorld.java
  • Now you run the java code of the VM to translate it to a intermediate representation embeded on the VM C code.
psp-j++ HelloWorld
  • You now have a file called HelloWorld.c, so you only need to compile and link it to the VM static lib
psp-gcc -c HelloWorld.c
psp-gcc -o HelloWorld HelloWorld.o -lpspVM

Now you have a HelloWorld.elf that you can transform to an EBOOT using the psp-pack. Once you do this you can execute it on your psp, the screen will go black and a couple of seconds after the PSP will return to the XMB menu. It may seem strange because nothing got printed on the screen but this is the correct behavior. We need to notice that there is no stdout on the PSP so because of that the VM will generate a file in your memory stick on the same folder as your EBOOT called stdout.txt if you open it you'll see the magic string:

Hello World from the pspVM

If there are this was a proof of concept, to make it workable it is needed to port the PSP api to the classpath, if there are volunteers maybe we can start another cool project.

RAJAX

RAJAX is an approach to remove the repetitive code that coders need to add for simple AJAX applications. The main goal is to create a library that at runtime will generate a proxy JavaScript class to a server side Java class allowing the web programmer to invoke remote methods in the local JavaScript object. The project is composed by an network abstraction layer and other sub components such as a Model-View-Controller Framework totally based in AJAX and JavaScript. Since this the project is quite dynamic other components will be added from research experiences or user requests.