My Game on Raspberry Pi


11 posts
by TheDoktor » Fri Jul 20, 2012 8:06 pm
Hi

I've been working on a Raspberry Pi version of a Dreamcast game I worked on many years ago called 'Fur Fighters'
Here is a video of it running: http://www.youtube.com/watch?v=29MNkbZfkUA
As you can see it is running but a little slow. The build you can see isn't particularly optimised and is in a 'just get it working' kind of state. It is running on the old Debian distribution and I noticed that there is a new 'Raspian' version of the OS which has much better floating point performance. Before I go delving into this new OS I'd like to know if I need to change my make files to build for this OS (I'm currently cross compiling on my Mac using code sourcery & the libs/includes for the distro) .
Some other things I need to do are:
Controls
I got a USB joypad working to a fashion by reading /dev/input/js0, seems a bit unreliable though and I couldn't get any good documentation so it was mainly stabbing in the dark. I'd like to get keyboard & mouse working instead, can anyone recommend any good resources on reading the keyboard & mouse at a fairly low level?
Audio
I'm not sure where to begin with this one. I need to be able to play multiple audio streams as well as SFX in both 2d & 3d (faked 3d would be acceptable). What libraries to people typically use for tis? Is there any support for OpenAL or OpenSLES?

Would really appreciate any help and advice as I would really like to release this into the community when it is at an acceptable level.

Cheers,
Mark.
Posts: 6
Joined: Sun Nov 06, 2011 7:12 pm
by cheery » Fri Jul 20, 2012 8:25 pm
Fun old game.. I remember having played this one.

I played with some usb, but used I pyusb to handle it. I don't know whether it's of any help therefore: https://github.com/cheery/raspberrypi-multimedia
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by Borat » Sat Jul 21, 2012 12:23 am
Lovely, nice work. I would love to port the game re-volt to raspberry pi...the source is available.
Posts: 26
Joined: Mon Jun 11, 2012 4:17 pm
by magicstix » Sat Jul 21, 2012 12:42 am
I'd suggest taking a look at libSDL for the joystick input. It handles all of the low level communication for you, and you just set up event handlers for the joysticks.
Posts: 12
Joined: Sat Jul 14, 2012 5:33 pm
by panik » Sat Jul 21, 2012 1:56 am
Sweet, looking forward to playing that!

I used the following code as a base to read the joystick. On my Raspberry Pi, it's only reliable without a USB hub. With the joystick plugged straight into the Pi's USB port, it works great: http://www.mjmwired.net/kernel/Documentation/input/joystick-api.txt

For reading a joystick, mouse or keyboard with SDL (as magicstix suggests), user jmacey coincidentally posted the minimal code to get it running just yesterday: http://www.raspberrypi.org/phpBB3/viewtopic.php?p=128327#p128327 (You need an SDL_Surface to capture the events).
Docs: http://www.libsdl.org/docs/html/guideinput.html
Posts: 267
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands
by magicstix » Sat Jul 21, 2012 2:27 am
Why would you need an SDL_Surface to be able to capture the events? That seems a little odd to me...
Posts: 12
Joined: Sat Jul 14, 2012 5:33 pm
by panik » Sat Jul 21, 2012 1:39 pm
Yes, that is odd, but I tried capturing input without an SDL window/context once, and it didn't work.
Others have tried and failed too. I found a little bit about it here: http://www.gamedev.net/topic/550062-sdl-input-only/, but it must be explained better somewhere else. I hope to be wrong though...
Posts: 267
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands
by dom » Sat Jul 21, 2012 2:11 pm
TheDoktor wrote:Hi
I've been working on a Raspberry Pi version of a Dreamcast game I worked on many years ago called 'Fur Fighters'
Here is a video of it running: http://www.youtube.com/watch?v=29MNkbZfkUA

Looks great!
TheDoktor wrote:As you can see it is running but a little slow. The build you can see isn't particularly optimised and is in a 'just get it working' kind of state. It is running on the old Debian distribution and I noticed that there is a new 'Raspian' version of the OS which has much better floating point performance. Before I go delving into this new OS I'd like to know if I need to change my make files to build for this OS (I'm currently cross compiling on my Mac using code sourcery & the libs/includes for the distro) .

You will need a hardfp specific compiler. Not sure what's available on the Mac. Running crosstool-ng to build on is not too hard. There is a hardfp linux toolchain here:
https://github.com/raspberrypi/tools
That you could use under VirtualBox.
TheDoktor wrote:Some other things I need to do are:
Controls
I got a USB joypad working to a fashion by reading /dev/input/js0, seems a bit unreliable though and I couldn't get any good documentation so it was mainly stabbing in the dark. I'd like to get keyboard & mouse working instead, can anyone recommend any good resources on reading the keyboard & mouse at a fairly low level?
Audio
I'm not sure where to begin with this one. I need to be able to play multiple audio streams as well as SFX in both 2d & 3d (faked 3d would be acceptable). What libraries to people typically use for tis? Is there any support for OpenAL or OpenSLES?

You can hack it. See /opt/vc/src/hello_pi/hello_triangle2 which reads the mouse in a hacky way. I'd still recommend SDL. Quake 3 uses SDL for mouse/keyboard, and ignores the video side of it, just using dispmanx/OpenGL directly:
https://github.com/raspberrypi/quake3
You can do real multichannel audio though OpenMAX, but that is not trivial. I'd recommend ALSA (which our driver will get real multichannel one day). I'm sure there are linux libraries that can do 3D audio effects processing, but I'm not an expert on that.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Robert » Sun Jul 22, 2012 6:24 pm
Borat wrote:Lovely, nice work. I would love to port the game re-volt to raspberry pi...the source is available.

Anyone with the skill to write or port a game, we need your help over at [url]piadventure.org :arrow:[/url]
User avatar
Posts: 2
Joined: Fri Dec 23, 2011 8:03 am
Location: England
by TheDoktor » Tue Jul 24, 2012 9:59 pm
@dom: Thanks for the info. I do have some SDL control code knocking around somewhere I can use. I have tried cross-compiling SDL code for the Pi before but ran into difficulties with not having the right libraries to link to, I'll give it another go.
I also wanted to try writing 'native' control code as a learning exercise so I might have a look at that example you mentioned.
I'll look at setting up a Linux machine and cross compiling from that, I've done this before for other devices and it was pretty straightforward from what I remember. I'd really like to try the hardfp as I know FurFighters is pretty heavy on float calculations and can't take advantage of my NEON code path on the Pi.

Cheers,
Mark.
Posts: 6
Joined: Sun Nov 06, 2011 7:12 pm
by xranby » Wed Nov 28, 2012 7:29 pm
TheDoktor wrote:Audio
I'm not sure where to begin with this one. I need to be able to play multiple audio streams as well as SFX in both 2d & 3d (faked 3d would be acceptable). What libraries to people typically use for tis? Is there any support for OpenAL or OpenSLES?


You can use OpenAL by first installing libopenal1 it can do 3D positional sounds.
I have tested using OpenAL on my Pi from Java by using the JogAmp JOAL bindings:
https://gist.github.com/4160432 - JogAmp JOAL OpenAL test.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
User avatar
Posts: 401
Joined: Sat Mar 03, 2012 10:02 pm