Thoughts Serializer

Computer graphics, Games, Personal

Launching on the AppStore in the year 2012

No Comments »

[Also posted on AltDevBlogADay]

Today is somewhat an important day, as it is exactly 60 days since the day I can officially call myself a published indie game developer! It was February 3rd when Mr. Pop Corny rushed (actually it crawled thanks to Apple, but I will get to that below) into the AppStore after an 8 month development time, and the dream came true. So it seems now it is a good time to share some of my experiences regarding launching on the AppStore. I will try to provide some insight that I wish I had from other projects prior to launching my own. Read the rest of this entry »

Unveiling Pop Corny

No Comments »

Honestly I can’t really describe how excited I am to finally be able to announce my first game! Since the first line of code I ever typed in a programming language, all I wanted to build was a game. It turns out that only many years later the timing would be right for it to become a reality. Some of you might already knew that this was coming if you had read my last #altdevblogaday post. A few days ago I unveiled the game’s icon to the game’s Facebook page. If you like it please like the page and share it as I am certainly going to need the word of mouth in promoting it.

I will not yet go into details about what the game is about (apart from obviously being about a popcorn loving crazy looking monster!), I will save this a for few days later when the AppStore review process will be coming to an end. A teaser video will also be released so keep an eye open for it.

Also if any of you happen to write for a game review website or you know a friend who knows a friend that has a cousin that got married to a girl that reviews games, please let them know I would be glad to send then the game!

CU!

p.s. If you are not a Facebook guy you can follow the game’s twitter account for updates: @MrPopCorny

Something moving in the shadows…

1 Comment »

I have been spending quite some time the last months working on a port of the Sylphis3d game engine to the iPhone. I am now to a point that the thing works really nicely. I will not get into details about the changes that I did to the engine for the purpose (I will keep that for an other post), but I want to get the word out that it is final: WE ARE MAKING A GAME :D

I don’t think I can stress out how excited I am about this. After too much struggling we finaly have an original consept, a good game design, and the team to make it true! The game is based on a wild idea I had some time ago, based on which we created a beautiful game concept. With the help of the artistic nature of Vangelis Bobolas and the soundscapes of the out-of-this-world music composer Thanasis Lightbridge, we are on the right track!

I can’t uncover much at the moment, but I believe we have something totally original and fun cooking in the oven ;)

Orientation Film One : The AutoSleep App

2 Comments »

Ok, you must see this!

My dearest of friends, Thanasis Lightbridge, made this awesome cult retro film for AutoSleep.

It’s all there… secret laboratories, crazy vocals of rebelion, giant-reptiles-attacking-earth-style announcements, retro cinematography, wicked pyjamas, epic soundtrack, peaceful high pitch snoring … and many more! :D :D :D

AutoSleep Music Timer hits the AppStore

3 Comments »

Hello!

AutoSleep Music Timer application icon

I just released a new application on the AppStore and wanted to share the joy! :-D The application is called: “AutoSleep Music Timer” and its purpose is to help all those people (like me) that need music to fall asleep.

So what it basically does is: turn the music off automatically when you fall asleep! It does so not after a user set amount of time, but by monitoring your “sleep” state.

The application cooperates with whatever music player you use that can play in the background. So with the music playing you fire up “AutoSleep” and place the iPhone on your bed. AutoSleep then monitors your movement pattern through the accelerometer and when it detects that you are asleep it turns off the music. Simple as that.

This kind of app was missing from the AppStore and to me is a life saver. Specially when listening to internet radio stations that otherwise will go on playing forever, possibly waking you up long after you have fallen asleep, which kind of beats the purpose of using music to sleep!

The app is going to be on sale (66% off) through out the holidays for $0.99, so if you like it, it might be a good time to get it now. If you use it please be kind enough to leave a positive review on the AppStore and show your support.

Here is the link to the application

Thanks again and I will be back with a more technical article about the application! Until then have a nice Christmas!!!

Optimizing script language performance with custom memory allocators

2 Comments »

The last weekend I did some exploration on the script language execution performance. Specifically on the memory allocation side of things, and I would like to share my findings.

Script languages and memory usage

As you probably know script languages (most of them at least, like Python, Lua, etc) have the tendency to make a huge amount of small allocations on the heap. Almost everything is stored on the heap, and if you care for performance, you start to feel homesick about your beloved C stack! Anyway, nothing comes for free, and scripting languages have to take something from you in exchange for all the goods it gives you back. So the best you can do is make sure that you have the best memory allocator for the job.

Doing too many small allocations and releases on the heap can create memory fragmentation, along with all the evil that comes with this. The common approach is to create a specialized memory allocator that serves small and constant in size blocks of memory to the scripting language, taken from a bigger chunk of memory reserved from the system. This is a common in all “realtime” and intencive applications like games, and something I did many times to gain performance.

Can’t beat the standard malloc

What I discovered with my latest attempt was that it has gotten quite hard to beat the GNU implementation of malloc(). Something that used to be easy in the past when you focused on a specialized case (e.g. small blocks of memory). Not that you can’t do better if you try hard, but at this point the malloc() implementation is already super-fast for 99.9% of applications on the desktop. Rest asured that you will not be able to do much better. However that is not the case for embedded devices that don’t share the same virtual memory benefits as the desktop computers.

My hand tuned specialized memory allocator for small blocks of memory ( <= 256bytes ) was not able to be more that 1% faster that the native malloc() on the OS X 10.6. However on the iPhone the same allocator was twice as fast as the native malloc() ! Since the target was from the begining the iPhone that seemed like big win! However when I set up a small benchmark in the scripting environment that did some allocations of game engine objects and released then again in various patterns, the results were disappointing. The gain from using my specialized (and twice as fast) allocator resulted in improvement of about 5% in execution speed in a memory intensive benchmark. And at some tests even slower! That was odd and most of all not good!

Why I was failing

After some inspections and tests that made the case of me doing something really stupid less probable, I narrowed down the cause.

In most cases of using a scripting language you have some classes defined in C++ that you instatiate in the scripting language. Take for example a 3D vector class “CVector3″ defined in C++. When you instatiate this in the script language you get two allocations. One in the scripting language that allocates the “proxy” object and one in the C++ environment. When giving a new allocator to the scripting language to do its allocations you only “optimize” the first allocation. The one in C++ still goes through the system default allocator.

And since you optimize half of the allocations you expect to have half the performance boost… well… wrong. It turns out that you can even be slower this way. The secret here is the CPU cache. By doing the above, you have two memory blocks that are usually accessed together, but are far apart in memory. This can really hurt performance badly on a device with slow memory like the iPhone.

The solution

The solution was of course to use the same allocator on the C++ side by overriding the “new” operator of the class. This made the blocks of memory allocated on the script side to be close to the block allocated on the C++ side. This way access to the object only involves accessing one part of the memory and giving nice cache hits. Performance up by 30%, which was nice and expected.

One other interesting thing that I found from this is that, on the iPhone, if I just override the “new” operator of a class and make it allocate the memory with plain malloc() and don’t use my allocator at all, the system is again faster!

This is probably from the fact that “new” does not go through plain malloc() (didn’t bother to check) as the scripting language environment does. So the allocated blocks end up in differect arenas at different parts of the memory, with the result of losing performance for the same reason as above!

So, keep your related allocations close together when crossing the language barrier!

Having both Mac OSX and iPhone targets in XCODE

1 Comment »

I have a library (guess what that is!) for use in the iPhone. For the library I have an XCode project with two targets. One for the emulator and one for the actual device. Nothing wild as you can see.

However the joy came when I desided to also use the library in OSX. As one would guess I went on and created a new target for OSX, which started out as a copy of the original iPhone, target but with the “base SDK” for the specific target switched to “Mac OS X 10.6″.

When I compiled for the first time, I came to the realization that even with this option set to Mac OS X 10.6, xcode was still compiling for the iPhone! From this point on, nothing worked. I tried every option, setting, for the project and the target.. but nothing. XCode seemed locked to compile for the iPhone, totally ignoring the SDK setting. I ended up trying quiting/starting again XCode, restarting the MAC… and some other arcane spells and voodoo I can’t really confess here… nothing… Then I gave up and dreamed of the nice days of scons and even make files, when you knew what was under the hood..

All that until today when in a moment of enlightenment, I clicked on the “Overview” dropdown of XCode with the ALT key pressed. And “boom” (as Jobs would say), there is was… “the choise”! By holding ALT when selecting the “Overview dropdown, XCode allows you to choose the active SDK!  This was so overwhelming for me that I tweeted about it and also desided to make a blog post, so that no one has to go through what I did.

So bottom line for both OS X and iPhone targets:

  1. Make a new target for OS X and set it up.
  2. ALT-click the Overview to select your active SDK.
  3. Compile.
  4. Have a nice day!