Last week I found on sourceforge that Dgen, an old Megadrive/Genesis Emulator from the late 90s was actually still alive and kicking after its development was stopped in the early 2000s. In fact the project had been restarted to provide an open-source, multiplatform alternative emulator since there was somehow a gap in terms of offering. I just compiled it for Pandora a couple of days ago, out of interest in performance, and I’d like to share a few observations with you on performance and how to package a command line application like this one.
First, don’t expect DGen to be the best Megadrive/Genesis Emulator for the Pandora. That place is already taken by Picodrive and you can easily see, if you compare them side by side, that Picodrive is faster. At least the different is clearly noticeable on a CC or a Rebirth. On a 1Ghz, this is a matter of discussion. I compiled DGen with all the optimizations possible for Pandora so unless I missed something this is the fastest it can get at this stage. But honestly, the speed is perfectly acceptable if you have a 1Ghz unit: it should be full speed.
The compilation was super easy. Really, it went like a breeze. There were no unmet dependencies so it was really simple and straightforward.
The funny thing is that, when I launched it right after compilation, even on 1Ghz, it ran at like 2 FPS only (or maybe less than that). My first reaction is “What the crap! It’s slow as hell. Can this shit”, making me marvel at the Picodrive performance even more.
I nevertheless packaged and released it on the repo as “an experiment”. During the PND packaging process, I made in a mistake in the run.sh file and referred to the “lib” directory instead of naming it “libs”. Of course, launching the PND gave an error “missing library”. That’s when I checked whether all the libraries were in the lib directory first… and when I realized that there was a libGL library in the libs directory.
LibGL? You mean the display may be using OpenGL, then?
A quick look at the launch parameters from the main site confirmed this assumption. OpenGL display is on by default, and since the Pandora does not support OpenGL natively, the refresh rate suffered significantly from it. Why it uses OpenGL by default, I am not sure, but I certainly did not want it to work this way on the Pandora, and rather use SDL.
I just had to add a parameter to the command line to disable OpenGL in order to use SDL at launch. And suddenly, the FPS rate went up significantly. On my Rebirth it was definitely running at like 20 fps, and on a 1Ghz it was completely smooth. Still not as good as Picodrive, that’s for sure, but definitely closer. There may be a few other ways to tweak performance a little, I need to check some details.
By the way, as I hinted above, DGen is a command line application. You may be wondering about how to package them as PNDs? Well you can always make a full GUI if you really have time and the interest of doing so (it’s not THAT hard with pygtk for example), but in my case I just wanted something simple and straightforward for launching games at first. I ended up using a Zenity line in my program.
If you have not heard of Zenity, it’s a very small scripting language that lets you display some standard windows or menus without writing much code. This way you can make very simple menus or application launchers with just a few lines in bash.
It’s actually fairly powerful and flexible, You can’t do everything with it, but you can do a lot and it’s perfect for quick & dirty prototypes.
For example, the following code can generate an information window :
zenity --info \ --text="Merge complete. Updated 3 of 10 files."
You can give user choices…
#!/bin/bash zenity --question \ --text="Are you sure you wish to proceed?"
In my case I opted for a file selection dialog, like the following:
#!/bin/sh FILE=`zenity --file-selection --title="Select a File"`
If you are interested in learning more about Zenity, you can check the excellent Zenity manual. Again, Zenity cannot replace a full fledged GUI, but it’s very practical when you need to produce something fast and release it.
If I were to work further on DGen I would probably add a pyGTK GUI to add more options and parameters, but that will depend a lot on whether there is any community interest in it. Most of the feedback I received so far was “why did you port this? PicoDrive was already perfect“. Well, so much for a community who prides itself on using alternative systems 🙂
The last tricky part regarding DGen was how to customize the controls. I was almost going to look at the code following the Arkanoid tutorial from PtitSeb, where he had to do so, until I saw that there was a separate config file that was created at start by DGen. The interesting part was that it was possible, in the arguments provided to the command line, to override that config file by pointing to another local file. Which is precisely what I did in the end.
All in all, this was a couple of days of work (in the evenings) and now we have another functional emulator in the repo. It may not be the best, but if you have a 1Ghz it should work just fine. And who knows? DGen is still in development so it might improve over time, regarding both speed or features.