Dedicated arcade project in Java


21 posts
by mike_bike_kite » Wed Sep 19, 2012 2:55 pm
I'm still waiting for my Pi (ordered in May! thanks RS) but my intention is to build it into a dedicated arcade machine. I have a particular Java arcade program I want to run but wondered if the Pi is fast enough to run it? Does it produce sound on the Pi? Is it running full screen with no task bar etc?

It would also be helpful to know how long the Pi takes to boot up and whether it's possible to have custom boot up screens ie a picture or a some matrix (the film) like screen. If it doesn't work then it's not a big issue as I have other project to try.

The aim is to move the cabinet into the garage - it's dry but the temp fluctuates - would the Pi survive?

Thanks for any help.

Mike
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by tonywaite » Wed Sep 19, 2012 5:36 pm
Hi,

Re. temperature range: which country are you in?

If UK - no problem!

Regards,

T o n y
Posts: 5
Joined: Sat Sep 15, 2012 10:13 am
by xranby » Wed Sep 19, 2012 11:19 pm
mike_bike_kite wrote:I have a particular Java arcade program I want to run but wondered if the Pi is fast enough to run it?

I am able to run it using OpenJDK 6+ JamVM + IcedTea-web using the Raspbian image.
Code: Select all
sudo apt-get install icedtea-plugin
javaws -J-jamvm http://www.checkmypages.com/swarm/AlienSwarm.jnlp

Please add some shortcut to a fps benchmark and i can then produce some concrete numbers. My gut feeling is that it now runs around 15fps using software rendering.
Profiling indicates that it is spending most of its time in AlienSwarm.paint() sun.java2d.SunGraphics2D.drawImage();
You should consider to use OpenGL ES on the Pi through JogAmp JOGL or LWJGL by doing so then you can perform these image updates accelerated on the GPU.

mike_bike_kite wrote:Does it produce sound on the Pi?

No your code currently triggers an exception:
javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.
com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:539)
...
at SoundEffect.<init>(AlienSwarm.java:5234)
at SoundEffect.<clinit>(AlienSwarm.java:5208)
at AlienSwarm.main(AlienSwarm.java:868)

mike_bike_kite wrote:Is it running full screen with no task bar etc?

It is not running fullscreen. It is running inside an undecorated window at the top left corner of the screen.
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
by xranby » Thu Sep 20, 2012 12:23 am
mike_bike_kite wrote:It would also be helpful to know how long the Pi takes to boot up

from power on to init 7 sec
from power on to console login using a full Raspbian install takes about 15 seconds
start of X11 xorg xserver running lxde takes about 7 seconds
start of your game using javaws takes about 35 seconds
total startup time would then be about one minute.
Remember that javaws performs some quite time consuming certificate verification process of the application.

compare it to the startup time of a standalone OpenGL ES enabled java application from console takes only about 7 seconds. You should be able to start your application using OpenGL ES from power-on to running in about 22 sec.

If you trim the startup and start your application directly from init then you should land around 14 sec.

mike_bike_kite wrote:and whether it's possible to have custom boot up screens ie a picture or a some matrix (the film) like screen. If it doesn't work then it's not a big issue as I have other project to try.

You will have to tweak the kernel in order to display something custom during the first 7sec of the startup... hard.
Running some fast starting native OpenGL es shader application is possible to do after init to cover the remaining seconds of the startup. When your game is initialized completly then send a kill to the fist running OpenGL ES shader application . easy. I would try implement this using pishadertoy viewtopic.php?f=68&t=10246
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
by mike_bike_kite » Thu Sep 20, 2012 7:28 am
Fantastic response ! that told me everything I need to know. You can view the FPS etc by pressing P - this brings up a pause screen with some options and one of them is to turn testing on - this shows FPS. It looks like the Pi isn't going to go into this project though - shame but not a big issue.

Many thanks for looking into this for me.

Mike
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by xranby » Thu Sep 20, 2012 9:51 am
First a quick correction, you need to use OpenJDK *7* and icedtea-web to run this arcade game.
Code: Select all
sudo apt-get install icedtea-7-plugin
javaws -J-showversion http://www.checkmypages.com/swarm/AlienSwarm.jnlp


I ran a quick test of the fps measurements using the test mode and Java2D software rendering accessible from the P pause menu using a pandaboard that i happened to have in front of me at work.

ubuntu@panda:~$ javaws -J-showversion -J-server http://www.checkmypages.com/swarm/AlienSwarm.jnlp
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-0ubuntu1)
OpenJDK Zero VM (build 22.0-b10, mixed mode)
javaws startup time about 15sec
in game FPS = 38 MPS = 21 sound = ok.

ubuntu@panda:~$ javaws -J-showversion -J-jamvm http://www.checkmypages.com/swarm/AlienSwarm.jnlp
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-0ubuntu1)
JamVM (build 1.6.0-devel, inline-threaded interpreter with stack-caching)
javaws startuptime about 18sec
in game FPS = 45 MPS = 22 sound = ok.

ubuntu@panda:~$ javaws -J-showversion -J-avian http://www.checkmypages.com/swarm/AlienSwarm.jnlp
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-0ubuntu1)
Avian (build 0.6, package 0.6+20120911-0ubuntu1)
java.security.cert.CertificateParsingException: java.io.IOException: No data available in passed DER encoded value.
at sun.security.x509.X509CertInfo.<init>(X509CertInfo.java:171)
this is a avian JVM bug.

All in all JamVM gives the best in game experience using OpenJDK 7
i will update this post later this evening using the pi.
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
by mike_bike_kite » Thu Sep 20, 2012 1:02 pm
Perhaps you can advise ... I'm going to build a dedicated arcade machine around that little game (a bit like one of the old galaxian arcade machines). For this to look ok it must be running in full screen ie no task bar etc. It also obviously has to be fast enough to be playable and would require sound. The Pi sounded like a neat solution as it was small, cheap and might survive in a garage environment. I have some ancient PC's hanging around so I could just cut the boards out of them and build everything that way but it obviously wouldn't have the kudos of using the Pi. Any other options I could try?

Mike

PS the MPS is just a figure showing number of moves made per second - it tries to keep it to around 22 MPS for the game to look smooth.
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by xranby » Thu Sep 20, 2012 1:53 pm
mike_bike_kite wrote:Perhaps you can advise ... I'm going to build a dedicated arcade machine around that little game (a bit like one of the old galaxian arcade machines). For this to look ok it must be running in full screen ie no task bar etc. It also obviously has to be fast enough to be playable and would require sound.

The Pi sounded like a neat solution as it was small, cheap and might survive in a garage environment. I have some ancient PC's hanging around so I could just cut the boards out of them and build everything that way but it obviously wouldn't have the kudos of using the Pi. Any other options I could try?

Mike


I can list options to make it working using the Pi:
I think you can make this project run smooth on the Pi by simply take advantage of the GPU during rendering. Your game is nice and i would be happy to assist you in this porting if the source-code would be available. To get sound working on the Pi i think its a simple matter of selecting a supported frequency.

A) You may today use JogAmp JOGL directly and can enter fullscreen using a "NEWT" window.
By using the GL2ES2 profile you can make the code work on both desktop and embedded devices http://jogamp.org/deployment/jogamp-cur ... plets.html
Demo of JogAmp JOGL running on the RaspberryPi: http://labb.zafena.se/?p=547
By using JOGL you can render using hardware acceleration outside the xorg server.

B) If you still want to use Java2D then i can recommend to collaborate with
http://brandonborkholder.github.com/glg2d/ that provide an OpenGL accelerated version of Java2D.
basically issue 1 needs to get fixed to make GLG2D running on the Pi.
https://github.com/brandonborkholder/glg2d/issues/1
GLG2D uses JogAmp JOGL internally for OpenGL ES access.

C) Oracle *may* release an Pi optimized JavaFX 2 version during next Java One.
If so then this JavaFX 2 would most likely contain a new "Prism" back-end that can use JOGL or they may use their own binding to OpenGL ES and OpenVG directly. This would provide hardware acceleration using the new JavaFX 2 API. Keep an eye on what happens at Java One!
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
by xranby » Fri Sep 21, 2012 12:31 am
Alien Swarm running fullscreen 28fps on the Rasperry Pi using JamVM + OpenJDK 7 on Rasbian armhf.
https://twitter.com/xranby/status/24893 ... 68/photo/1
Image

I reconfigured my Pi to use the composite pal video out signal to get the game running in "fullscreen".
I configured the LXDE tarskbar to stay hidden on the left side of the screen and used a black background for the x11 session , it looks great! The Pi bootup configuration file contain overscan settings that may be used to tweak and center the video screen to perfection.

When i switched the sound setting from "full" to "low" i started to hear "compressed" click sounds when the shots hit the aliens.

I tested two OpenJDK 7 compatible JVM on my Rasbian armhf system using IcedTea-web.
Zero Mixed Mode gave 21fps in game and JamVM, used in this screenshot, gave a steady 28fps!

I have not been able to test Alien Swarm using the Oracle Java 7u6 JDK on Debian armel because the Oracle ARM binary JDK release do not contain the javaws JNLP launcher tool that is used to launch the Alien Swarm jnlp file.

Cheers
Xerxes
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
by mike_bike_kite » Fri Sep 21, 2012 8:33 am
I'll admit I'm amazed your helping me so much with this but it's definitely appreciated!

Yesterday I thought I'd have to abandon the idea of using the Pi and now it's looking quite hopeful. The only issue currently appears to be the sound. There is normally a full range of arcade sound effects being pumped out - explosions, heart beats etc etc. I have a low sound setting in the menu to simply switch out most of the sounds and keep the "clicks". I did this because I often work on my programs at night and the wife might (wrongly) think I'm playing if she hears all the explosions :)

What would I need to do to get the sound working on the Pi? You're welcome to have a play with the code but I'll admit I'm not a Java programmer by trade so the code can be ugly.

Mike

PS what scores do you get?
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by xranby » Fri Sep 21, 2012 8:50 am
mike_bike_kite wrote:I'll admit I'm amazed your helping me so much with this but it's definitely appreciated!

Yesterday I thought I'd have to abandon the idea of using the Pi and now it's looking quite hopeful. The only issue currently appears to be the sound. There is normally a full range of arcade sound effects being pumped out - explosions, heart beats etc etc. I have a low sound setting in the menu to simply switch out most of the sounds and keep the "clicks". I did this because I often work on my programs at night and the wife might (wrongly) think I'm playing if she hears all the explosions :)

What would I need to do to get the sound working on the Pi?

I will earmark and investigate how to best playback sound using Java on the Pi and then post a solution in the forum.

mike_bike_kite wrote:You're welcome to have a play with the code but I'll admit I'm not a Java programmer by trade so the code can be ugly.

Mike

Thank you, i look forward to it, If possible i recommenced using the github source-code hosting that is free to use for open source licensed projects.

mike_bike_kite wrote:PS what scores do you get?

I did enter the online High Score list while playing this on the Pi! :)
4 XRANBY__ 171597
http://www.checkmypages.com/swarm/hs.php?game=1
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
by xranby » Fri Sep 21, 2012 10:53 am
While investigating the various sound playback options, i highly recommend to take a look at the
Amiga MOD playback on RasPi with Java thread:
viewtopic.php?f=38&t=13661
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
by xranby » Wed Sep 26, 2012 10:47 am
I managed to test this game using Debian Wheezy armel + Oracle JDK 7u6 by downloading the jar manually.

Code: Select all
wget http://www.checkmypages.com/swarm/AlienSwarm.jar
java -jar AlienSwarm.jar


Oracle JDK 7u6 gave 23fps in game.

Thus to get the best performance on the Pi for Java2D and other realtime applications like games i recommend the use of JamVM + OpenJDK 7 + Raspbian armhf where i get 28fps in game.

fps in game measured by first enable the Alien Swarm test mode 1 inside the P pause menu and then check the measured fps when reaching the first green alien boss ship at level 4.
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
by mike_bike_kite » Wed Sep 26, 2012 6:03 pm
171k - that's quite a good score, I'm quite impressed. Every 200k you get special power up options (Nukes, a more powerful canon and automatic shields). It can be quite difficult trying to manoeuvre to get the correct power up without loosing the opportunity.

Did any combination you tried work with sound, full screen and a reasonable frame rate?

I had a look at programming the graphics chip direct but sadly my computer at home is very old and doesn't have a graphics chip (as far as I know) - anyway none of the examples would run.

Sorry for delay in replying but I'm trying to get a checkers program completed and I became a little absorbed by a few small issues.

Mike

PS I've noticed that Maplins is now selling a RasPi kit for £69
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by xranby » Thu Nov 29, 2012 11:31 am
xranby wrote:
mike_bike_kite wrote:I'll admit I'm amazed your helping me so much with this but it's definitely appreciated!

Yesterday I thought I'd have to abandon the idea of using the Pi and now it's looking quite hopeful. The only issue currently appears to be the sound. There is normally a full range of arcade sound effects being pumped out - explosions, heart beats etc etc. I have a low sound setting in the menu to simply switch out most of the sounds and keep the "clicks". I did this because I often work on my programs at night and the wife might (wrongly) think I'm playing if she hears all the explosions :)

What would I need to do to get the sound working on the Pi?

I will earmark and investigate how to best playback sound using Java on the Pi and then post a solution in the forum.


I have picked up maintenance of the JogAmp JOAL OpenAL Java bindings.
It is possible to use JOAL to play multiple simultaneous samples on the Pi without having pops when new sounds start. JOAL also enable use of 3D positioned sound.
https://gist.github.com/4160432 - JOAL test for Raspberry Pi
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
by mike_bike_kite » Thu Dec 13, 2012 8:15 pm
I've put out a new version of the game which has a bunch of improvements. I haven't had the time yet to put in your suggestions - I think it's just the fear of trying new stuff. I did send you a message via the java gaming site but you might of missed it. If you have the time (and know how to use these libraries) and want to have a go then I'm happy to share the code with you.

In any case, do try out the new version of the game if you get a bit of time.

Mike
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by xranby » Fri Dec 14, 2012 1:22 pm
I am not interested in working on secret code projects so i will only try run your application inside tweaked openjdk setups.

Today i managed to run AlienSwarm using caciocavallo and cacio-web.
Caciocavallo is a pluggable "awt" peer framework found in OpenJDK 7 that allows easy porting of AWT and Swing to new platforms. Here i use the "web"-peer that sends all AWT/Swing output to a Html5 web-browser across the network: https://twitter.com/xranby/status/27957 ... 33/photo/1
I will run the same test using the Pi later this evening.

Quick Cacio-Web howto: http://rkennke.wordpress.com/2012/12/12 ... web-howto/
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
by mike_bike_kite » Fri Dec 14, 2012 3:02 pm
It's a difficult thing releasing a project you've worked on in private for a couple of years - they become like children. To be honest I find it a difficult concept writing code for others to use for free but that's the nature of the world these days and I'll admit the game isn't good enough to sell. On the flip side I do enjoy seeing people play the game. I did have a graphic artist on the Java Gaming forum help me with the game images, his input transformed the game and I give him credit on the title page of the game. Have you open sourced any of your own projects?

I have considered releasing other projects I developed into the public domain simply because they are in an early stage and could easily benefit from fresh input. The most recent one was a language for writing platform games - 20 lines of code could produce a playable screen and the idea was to weave different peoples screens together depending on user feedback. I also have a small project, which could easily grow, for quizzes which I'd be interested in making open source.

I built the control panel for the game last night (the part of the arcade cabinet that has all the buttons on the front and all the delicate electronics underneath. The next stage will be to build the cabinet for the game so it looks like a real arcade game from the 80's but that's the part I'm not so good at (can you open source woodwork?).

I much appreciate your efforts to get the game working in full screen and with sound. Having a smaller computer would certainly make the cabinet easier to build!

Mike

PS I'm reading the Cathedral and the Bizarre to try and understand the open source movement :)
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by Jim Manley » Sat Dec 15, 2012 5:48 am
mike_bike_kite wrote:PS I'm reading the Cathedral and the Bizarre to try and understand the open source movement :)

I don't know if you intended it, but I busted out ROTFL when I read "the Cathedral and the Bizarre" which is actually titled, "The Cathedral and the Bazaar". However, if your spelling wasn't intentional, you actually managed to capture another aspect of open-source software development which can truly seem bizarre since it so completely contradicts traditional thinking from the commercial perspective. In any case, I start laughing again every time I think about your wording :)
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!
User avatar
Posts: 1357
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, USA
by mike_bike_kite » Sat Dec 15, 2012 5:49 pm
All credit to my spell checker, it has a much better sense of humour than me ;)
Posts: 17
Joined: Wed Sep 19, 2012 2:39 pm
by jocfer » Fri Jun 07, 2013 2:32 am
As far as my idea, it can... we use Pi when we also made our own version of arcades.. check it here... http://www.izombiegames.com
Posts: 1
Joined: Fri Jun 07, 2013 2:29 am