PDA

View Full Version : rRootage fast porting tutorial



deniska
December 9th, 2005, 05:38
I am writing this in response to some accusations of me stealing someone else's code.
I am not gonna name names and point fingers. I just want to clear up my name... and hopefully this information will be usefull to people who want to get in to psp homebrew scene.
So you deside as to whether I needed to steal anything or could do it myself in 20 minutes, using basic C/C++ knowlege and common sense.
So here we go...

1) Get the original rRootage distribution from: www.asahi-net.or.jp/~cs8k-cyu/windows/rr_e.html (google it if the link does not work)

2) Unzip it and get the source folder. The attached readme file mentions that you'll be needing SDL, OpenGL, bulletML oggVorbis. So if you don't have those yet, get the psp versions: SDL, SDL_mixer, PSPGL, libBUletML, libTremor. Of course you'll need the latest versions of those. you'll need PSPSDK and Cygwin as well. (Read other tutorials if you need help setting up anything from the list above)

3) Ok, so you have the environment setup :-) Let's compile it:
Your basic make file should look something like this:


TARGET = rr
PSPSDK = $(shell psp-config --pspsdk-path)
PSPBIN = $(shell psp-config --psp-prefix)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
O = o
OBJS = $(TARGET).$(O) foe.$(O) foecommand.$(O) barragemanager.$(O) boss.$(O) ship.$(O) laser.$(O) \
frag.$(O) background.$(O) letterrender.$(O) shot.$(O) \
screen.$(O) vector.$(O) degutil.$(O) rand.$(O) mt19937int.$(O) \
soundmanager.$(O) attractmanager.$(O)

DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)

MORE_CFLAGS = -g -O2

CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions

LIBS = -lbulletml -lSDL_mixer -lvorbisidec -lstdc++ -lGLU -lGL -lglut -lpsprtc $(shell $(SDL_CONFIG) --libs)

EXTRA_TARGETS = EBOOT.PBP

include $(PSPSDK)/lib/build.mak


so save it as "Makefile" in the src directory and type "make"
It will do some compiling but will return with something like:

foecommand.h:30: error: conflicting return type specified for 'virtual double FoeCommand::getBulletDirection()'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/include/bulletml/bulletmlrunner.h:72: error: overriding 'virtual float BulletMLRunner::getBulletDirection()'

Note that it's complaining about type mismatch double vs float in bulletml lib.

So let's go to foecommand.h and change all "double" to "float"
(if you use "vi", :s/double/float/g 5000 will fix it for you in a blink ;-)

Now, of course, you'll have to do the same for the corresponding foecommand.cc


Let's try to "make" again.... and bingo!!! you have your firmware version1.0 executable!!!! type "make kxploit" if you need the 1.5 version folders

Well, you are done! with your working 0.01 version!!!
Test it!!! make sure you copy all the game files/folders from the original distribution.
You'll notice that it's running slow with the ms access light blinking...
Well look for new files on your ms ;-) You'll probably find log.txt in which pspgl
is dumping it's complaints about the errors it encountes... read it...
If you recall the original version - it runs at 640x480 resolution which it a bit big for PSP.. so try to see if it is hardcodded somethere in the code ;-) and fix it.. Look for key assgnments (grep -i key) and see where they defined..
Since they did not seem to work in your first version, u'll need to fix that part.. view the readme.psp in SDL distribution on details...

Obviously as you go along, you'll encounter some new problems and I don't want to spoit the fun by givving out solutions ;-)

But as you see it is very simple to get things going with out stealing someone elses code ;-) with some experience you can produce a functional port in ~60 min...

So what's the trick??? Finding easily portable free code.. You'll need some experience with that ;-)
You best bet would be to look for something that has already been ported to some other lowres console or use platform independent libraries like SDL..
Try to search thru the games at www.libsdl.org for ideas...

Also, the trick is in tweaking the game for performance.. for example, you can use same sequence to port NOIZ2SA and will be done in ~ 20 minutes.. but it took me much more time to come up with the fast & attractive tate version... I had to re-write all SDL calls (partly because psp SDL was not that well when I started codding that game.. i had to re-write most of the IO functions too and compile my own version of bulletML)

I hope this was educating..

Regards,

DENIS

PS:
Some other porting ideas:
Dodgin' Diamonds - very easy..
Rise of Triad - more advanced - I'll try to finish this one when I have time...


[Jan 3, 2006 Edit]
Ok, some people got stuck with psp libraries installation so here is some hints:
1) Install as many cygwin libraries as you can (This is kinda dumb but at least you will not be missing anything and stock with some weird build errors)
If you are pressed with HD space, you defenetely want X11 stuff (startx will give you anice xterm with copy/ paste functionality), libtool, gnu make, svn, wget, bison, etc..
2) to get the fresh source for the libs do:
svn co svn://svn.ps2dev.org/psp/trunk/SDL _this will get you the source for SDL.. Change "SDL" to libTremor, SDL_mixer, SDL_gfx and it will get you the source for those libs, creating new folders in your current directory.
NOTE: make sure your current path don't have spaces in it. This may screw up some cygwin calls...

Once you get the library, "cd" in to that directory and view README.PSP (or just README if README.PSP is not there)
README.PSP usually has the command sequence for installing the library as well as any prerequisites.
For example libTremor has following:

LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspuser" ./autogen.sh \
--host psp --prefix=`psp-config --psp-prefix`
make
make install

So just copy those lines in to cygwin prompt..
Having 2 xterm windows can be handy.. so prowided that you have X11 stuff installed, type
startx &
xterm &

Happy codding ;-)

DENIS

reakt
December 13th, 2005, 14:41
Thanks very much for your excellent porting guide!
This has inspired me to port an SDL game.
I have my first port running on PSP. Unfortunately it crashes on startup but I am working to solve that!

I have a question regarding porting of SDL games. Do you need to do some kind of mapping of the controls? If so how / where is this done? For example, if I want the X button on PSP to shoot, up button to make the sprite go up, etc, etc.

Also, could you explain for a psp-dev newbie, what each of the libraries offer you:

LIBS = -lbulletml -lSDL_mixer -lvorbisidec -lstdc++ -lGLU -lGL -lglut -lpsprtc $(shell $(SDL_CONFIG) --libs)

I know that vorbis is an audio decoder, and stdc++ is self-explanatory. Could you summarise the others so that I can judge whether or not they're needed in my own porting project?

Cheers,
Reakt

deniska
December 14th, 2005, 18:53
Sorry for a brief response, but I don't have much time now...

SDL_JoystickGetButton(stick, 2) will give you [X] event..

int btn;

btn=SDL_JoystickGetButton(stick, 2);

if (btn) {
do_something();
}

Refer to PSP SDL readme for other mappings ...

as to libraries:

SDL_mixer - SDL music/sound lib
bulletml - barrage definition lib - (unless you port some other Kenta Cho's shotter, chances are you don't need it..)

In general, there is no harm in keeping extra libs in your linker path..
You can always delete some and check if it still compiles ;-)

Good luck with your project..

reakt
December 15th, 2005, 18:05
Cheers for the pointers. Reading the docs I found you can also register to receive notification of Joystick Events, that way I can handle the joystick input at the same place the keyboard input is handled.

I got my game to start up and run. It's full screen. All the sprites are there but it looks strange - like sprites are overlapping each other. It's as if there's too much on the small screen. Any idea what I need to do to try to resolve this?

ctfreak
January 3rd, 2006, 21:06
Hi.
Very good tutorial deniska but I can´t find the psp versions of SDL, SDL_mixer, PSPGL, libBUletML and libTremor. Can someone tell me where to get these? I searched in google but I didn´t find anything.
Sry for my English but I´m German.
Thanks, ctfreak

kaneco
January 4th, 2006, 03:30
Imagine games like Resident evil and Resident evil 2 on the psp.

That would be awesome!!! :cool:

I'll try giving it a shot. :D

indstr
January 4th, 2006, 03:35
teach a man to fish...

thank you, sir. i am considering doing this even though i know SHIT ALL about coding... might be a good learning experience. :)

Zaibach333
January 4th, 2006, 05:42
I'm interested in this pspgl you speak of, I'm not quite sure what sdl is. the standard library?

correctme if that's a stupid statement. anyway I'm really interested in opengl for psp

Mr.Modem
January 4th, 2006, 09:25
PSPGL is like OpenGl for PSP and SDL (http://www.libsdl.org) is an open source cross-platform 2d graphics library.

ctfreak
January 4th, 2006, 15:19
I´m interested in trying this.
Can anyone say where to get the psp versions of SDL, SDL_mixer, PSPGL, libBUletML and libTremor?
I didn´t find them.
Sry for my English cause I´m German.

Stewie2280
January 5th, 2006, 05:52
does this only work with rrootage coz i wanna port a game called torus trooper that is on the same site that is on the first post

parsifal968
January 5th, 2006, 17:46
for the sake of God... someone try making a port of XMAME! i don't have the time, sorry :rolleyes:

Zaibach333
January 5th, 2006, 23:33
ich wünsche dass ich Ihnen ctfreak helfen könnte,

ich möchte auch wissen, wäre OpenGl gut.

Zaibach333
January 6th, 2006, 21:50
<a href="http://www.goop.org/psp/gl/">hier</a> ist pspgl für jeden

utter
January 7th, 2006, 12:13
Sorry for my English. It is not what it should be.

ok, I have read the guide and i soon understand that it was to advanced for me.
I was hopeing some one her could help me.

I wamt Heroes Of Might and Magic For my PSP, PLZ can someone help me.