PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Cross-platform development for mobile devices

People,

Next Monday (estimated release date), there will be a new article on Gamasutra titled 'Cross-platform development of games for mobile devices'. The accompanying library has been added to SourceForge, the project is named 'MobileCore'.

MobileCore is a very small library that sits between the hardware (and libraries that sit directly on top of the hardware, like GAPI or PocketHAL) and the game application. It lets you develop games once, and compile them for many platforms. Right now MobileCore supports PocketPC and Symbian (and of course Win9x for easy 'emulation'). It abstracts the application entry point, display, buttons, stylus and sound system for the supported devices. More platforms can easily be added; a platform expert should be able to add support in a day. I am hoping that the Zodiac, GP32 and Tungsten-T will join in soon, as these devices have similar characteristics (as PPC & Symbian). MobileCore is thus NOT a game library; it's more 'EasyCE' for multiple platforms; game libraries could be build on top of this thing.

I hope this will help to get a broader audience for mobile games, and that it will free us all of the platform details that get in the way of cool game coding.

Check it out at http://www.sourceforge.net/mobilecore .
You'll want to read the article before diving in too deep; there's no documentation yet (although using it is not exactly rocket science).

The article is out early next week, but you heard it right here first. ;)

Greets
Jacco.
So.. Um.. When it comes to the graphics part of the MobileCore API.. Does the API allow surface memory to be allocated on either sysmem or vidmem, or is it just another frame-buffer access layer where surfaces have to be allocated in sysmem and copied directly to the framebuffer? The reason I'm asking is that I believe most devices will provide some sort of usable HW acceleration with enough video memory next year (we are already seeing it with the 8mb vidmem Zodiac)...

By the way, if you need references in your article to similar libraries, you have GD who is also available for Win9x, PPC, Symbian and soon also Palm (the main difference being GD is a game library)... I guess it could be interesting to highlight why MobileCore is not a game library instead of just mentioning it (there are lots of reasons I can think of)...
Johan,

Let me first answer the second question: MobileCore is different from GD because it is as small as possible. It provides a common interface to the hardware (stylus, audio stream, buttons, screen buffer) that looks the same to the app for every supported platform. It provides a common way of starting the application. Applications using MobileCore do not need to use #ifdef's to take care of all the supported platforms. This means that you will want to add a game library for sprite support, fonts, mod playback and so on; however, such a library could be build ON TOP OF MobileCore. That game library does not need to worry about platform differences either. Adding a platform means that such a game library AUTOMATICALLY works.

I looked at some examples of GD and I noticed that sample projects are clearly different for all suported platforms. You have to deal with the way the OS expects an application to start, for example. MobileCore does not need that. Your game code is 100% the same on all platforms.

MobileCore is most of all a framework that is generic enough to plug in new platforms or new ways to access the same platform. For example, there's a GDI implementation of MobileCore for Windows right now, but you could add a DirectX implementation. There's a GAPI implementation for PocketPC, but you could add a PocketHAL version (wich would be better, in fact). And since the framework is so simple, writing a new implementation requires implementing only 10 methods or so, most of wich are quite trivial. That's the advantage of keeping things simple.

BTW, MobileCore offers access to the device frame buffer using a Surface class that encapsulates the device frame buffer. If the device is capable of offering direct access to the screen frame buffer, so does MobileCore. Or rather: An implementation of the MobileCore framework for a device may offer direct access, without violating the restrictions of the MobileCore framework (and thus the assumptions of the client application).

About hardware 3D acceleration: This is NOT part of the framework, as it would require considerable effort on most of the platforms (software emulation of the hardware features of one platform). This would violate the principle that MobileCore is simple and requires little effort to implement for new platforms.

I hope it's a bit more clear now. :)

- Jacco.
Thanks! Looking forward to both the library and the article.. :)
cannot find this on Gamasutra
I'm working on something similar at the moment... but it's in it's very early stages as I keep redesigning it in my head...

I hope to eventually support support PocketPC, Smartphone, Series 60 phones, GP32, and possibly the newer Palm devices - basically anything ARM with a reasonable 12/16bpp screen.

My framework will include:
- (Double-buffered) frame buffer access
- Key and stylus input
- File System (generic interface to the target OS)
- Basic debugging functions (at least displaying assert messages)
- ARM CPU emulation for the PC build!
- Audio, eventually....

The PocketPC version may be built on top of PocketHAL, depending on it's licence, as it looks like VSyncing works :)

I'm currently working on a file system class (and its subclasses), which is quite essential to keep game code portable between some of the very different OS's (or devices like the GBA where data is a ROM image, and there is no native filesystem)

One big feature that I'm planning, though, is ARM CPU emulation in the Win32 build, with an ARM debugger. This will allow far easier testing and debugging of assembler routines than is currently possible.

There are obviously some limitations/issues integrating an ARM cpu emulator with an x86 application. But current tests indicate that it will work nicely for most rendering/data processing where you pass a pointer to the input data and a pointer to the output data...

I've done some tests with the ARM core from VisualBoy Advance, which worked well, but I can't use that without violating the GPL, so I'm looking for alternatives, or GPL workarounds such as making the ARM emulator/debugger a separate GPL'd program, so the GPL won't 'infect' the game/engine I'm developing with it...

Currently, Symbian is proving to be a bit of a pain, though, forcing everything to be 'cleanly' encapsulated by not allowing globals... resulting in almost every object needing to be passed a pointer to a CPlatformBase or CFileSys object when constructed...

But it's forcing me to improve my C++, I suppose...
Why don't you join MobileCore? Sounds like you have some excellent ideas, the file system stuff sounds cool. And I've worked out a lot of the other issues, including getting Symbian to work. :)
BTW I deliberately didn't include double buffering, as some apps can perform better without it. Forcing users to use double buffering would in some cases mean a loss of performance.

MobileCore is NOT a game engine btw. It's meant to be a 'meeting point' of different platforms; at it's core it's just a class, some methods, and a description of the functionality of these methods.

MobileCore sits between the application (or game library) and the platform/OS: At the application end, MobileCore offers just enough to build a game (library) upon, while at the other end, it is easy to implement for lots of platforms.

That being said, the common hardware/OS functionality that it aims to expose to applications is clearly aimed at game development.
(Couldn't seem to download the build from SF, so I've not been able to look what's there yet... Probably my dogdy dial-up....)

So how have you 'got Symbian to work'?

Have you managed to get Symbian using globals and libc? (an exe instead of a dll?). Or just designed around it? Are you planning to use libc for file access (fopen, fread, etc), or wrap up the 'proper' (excessively complex) Symbian ways of doing it?

Is the PPC build using GAPI at the moment? (PocketHAL is looking very promising...)

How are you handling screen orientations? Or is that left up to the application?

Have you done anything clever to automate the build process for all platforms? It's always a pain when new files are added, adding them to the Visual Studio projects for the Win32 and PC builds, and also adding them to the Symbian .mmp file (and getting all the data in the right places - one reason I'm supporting 'wad-type' data files which can contain loads of files)

(Edit: Selected a different mirror and got the file from SF. Will have a look at it tonight)
A bit more about my file system:

Each platform implements a basic set of functions (basically fopen, fread, fseek, ftell, fclose),defined in CFileSys (abstract class)

The 'wad file'* system is a subclass of CFileSys works with a file from another CFileSys. So nested wads work:

Code:

CWadFileSys *pWFS=new CWadFileSys(pPlatformFileSys,"data1.wad");
CWadFileSys *pWFSNested=new CWadFileSys(pWFS,"fileindata1.wad");

int handle=pWFSNested.FileOpen("FileInAWadInAWad.dat");


To make it work on the GBA, implement just fread/fseek/ftell as a simple pointer on a block of memory (where the wad file is in ROM), and ignore fopen/fclose (actually, reset the file pointer to the start of the memory block). Then use the wad file class (which is 100% platform-independent) on this extremely-minimal single-file CFileSys....

Ok, so it's not as clean as it could be, but is simple to implement, and allows the wad file code to be used with a block of ROM, a wad file loaded completely into RAM, or a file on disk/flash/RAM.

Did any of that make any sense?....

(* it's not actually a Quake .wad, it's a really simple format, and created with a little command line tool)
'Got Symbian to work': I worked around globals (there's a way to have something like globals), and I indeed got 'libc' to work (fopen etc.). Basically using MobileCore you're completely shielded from the weird Symbian datatypes and other peculiarities that I have come to hate so much. ;) Allas, I could not solve the globals problem without switching to the 'exe' apptype, wich is not an option for us (Overloaded) as we develop for OTA distribution wich means that the telco's are our storefront. And telco's don't like call-blocking games. :)

The PPC version is build using GAPI and takes care of screen orientation (but not of resolution differences between Symbian and PocketPC). There's no reason why you couldn't add a PocketHAL implementation of the MobileCore interface though; in fact I already contacted Thierry about that, as I think PocketHAL is currently the fastest way to get graphics to the PocketPC display. Besides, I like it simple. :)

Build process: You will have to compile for the separate platforms individually; using EVC for PPC, Visual C++ for PC, and the command line stuff for Symbian (although you can at least check syntax from the Visual Studio IDE). Starting a new project is done using a batch file that sets everything up for you; Symbian requires many steps for setting up new projects so basically I copy a 'template' directory and perform a series of search&replace; operations. Once the batchfile is executed, you have your fresh project for all three platforms. There are some issues with that (Symbian wants to know where your project is located beforehand, and the Symbian SDK must be on the same drive) but all in all it works much quicker than the stuff you get with the Symbian SDK. And to add files you'll indeed have to edit the mmp file. I'm currently looking into that, but I doubt that it can be solved completely.

Let's hope the candidate platforms don't bring as much problems as Symbian. :)

About your file system: It's similar to something we're using at Overloaded. Fine idea; having lots of small files is a problem in (again) Symbian, as each file adds approximately 500 bytes to the installer, on top if it's real size.

Side note: Overloaded is not involved in the MobileCore initiative btw other than that they allow it.
The article just went online on Gamasutra.