OpenMSX for Android

Last updated on: Apr 22 2013
This page is a blog about the migration of openMSX to Android.

Monday 22 Apr 2013

I have been rather quiet on this blog lately. This message is just to share with you that since a while openMSX for Android build has been integrated in the nightly build environment on the Fixato openMSX build site. It means that you can now always download the latest build of openMSX for Android from that site and it is always functionally in line with the latest build for other platforms (like MacOS, Dingux and Windows) on that same site.

Monday 17 Dec 2012

Today I have published a new build of openMSX for Android with following improvements

Click here to download the APK and install it on your Android device.

Saturday 8 Dec 2012, at the end of the day

I have some good news for all Android and openMSX fans; after several weeks of alpha testing amongst a small audience and improving the code, the Android port of openMSX is now available for public beta testing.

Click here to download the APK and install it on your Android device.

By default, the emulator comes with C-BIOS bundled with it. See the latest edition of the openMSX setup guide on sourceforge for instructions on where to install your own MSX system roms.

The on screen menu, which can be used to change some openMSX settings or to insert disk images or cartridge rom images, is bound to the Android menu button. Once you have opened the menu, you can navigate through it with the virtual joystick and select entries with the virtual firebuttons (the two bottom ones).

You can provide feedback on the openMSX port for Android topic on the MSX resource centre.

Sunday 11 Nov 2012, very late in the evening

Metal gear running on openMSX on Android, with on screen controls

Today has been a very good day. I managed to get openMSX working.

This morning I copied the MSX firmware files into the openMSX directory on my nexus.

Despite that, openMSX was in first instance still complaining that it could not find the firmware files. I had to adapt the firmware search routine for the Android environment; Android uses a different convention for where to install application files then Linux, Windows or the Macintosh.

Once I had adapted the code, openMSX started succesfully :-)

At the moment, I have only bundled the free so-called C-Bios firmware with the emulator. This firmware can be freely distributed (it is not copyrighted by Microsoft, unlike the firmware in the real MSX machines) but it is rather limited. It can basically only be used to start games on cartridges.

As a next step, I transferred the ROM file of metal gear onto the android device and tried to launch it using the openMSX console.

This worked. Metal gear succesfully started!

However, it was impossible to control solid snake. OpenMSX was ignoring all the events from the virtual joystick build into the Android SDL port.

After some more debugging and with the help of my fellow openMSX developers on the IRC forum, I eventually managed to get the joystick support working. Furthermore, I adapted the virtual on-screen menu and keyboard that are part of openMSX to support joystick input; until today they could only be controlled with the cursor keys but I don't have cursor keys on my Android device. Only the virtual joystick.

It has been a long day to get everything working, especially because during the afternoon I had to work for a few hours in my garden to prepare the pond for the winter; it was a sunny day today so it would have been a waste not to prepare the pond today.

As you can see in the video, the port still requires some fine-tuning. Currently I must touch the virtual joystick keys only very briefly in the on screen menu and keyboard; otherwise the cursor runs too fast through the menu or the keyboard.

The further fine tuning is for next week. Now I'm simply very happy that I already got this far. I was expecting to only get to this stage by the Nijmegen MSX fair coming January.

PS: sorry that the video sometimes gets out-of-focus; the autofocus of my fotocamera has issues with the screen transitions on an object so nearby. I will see if I can make a new video with a fixed focus setting. I hope my camera supports a fixed focus setting for the video mode.

Saturday 10 Nov 2012, late in the evening

Today I have been debugging openMSX.

I managed to build the shared library and to install openMSX on my nexus. I could start it, the app showed the standard SDL settings menu but as soon as that got closed and the control was handed over from the SDL settings menu to the openMSX main code, the program would abort without any error message.

That was absolutely not good.

According to the documentation that is part of the SDL android port, I should get a so-called stack-trace when the program crashes and based on that stack-trace it is possible to find the exact line in the code where it is going wrong. But openMSX did not make such a stack-trace.

In order to find the problem cause I started to re-compile openMSX but then with all kind of debug settings enabled. However, that compilation attempt failed. I ran into a subtle bug in the cross-compiler for Android. I googled around, noticed that several other people had also run into that same issue but I could not find a satisfactory solution. The only way to get around that issue was by tryall and error; each time change one compiler setting, recompile everything and then hope that the compilation succeeds. Such a re-compilation takes something like 15 minutes so it was a lenghty session, testing my patient to the limit.

Eventually I managed to compile with several debug settings but alas, still no stack-trace :-(

I had to change to switch to plan B and that was to start printing debug statements to a log file so that I could then analyze it after the crash. Fortunately, openMSX by default already prints some log messages but they normally go to the text terminal (also known as the dosbox or command prompt under windows) from which you start openMSX. However, under Android, openMSX does not get launched from a text terminal. It gets launched from the graphical interface and there is no such text terminal, with as a result that those messages get lost.

However, after asking some help from my fellow openMSX developers on the IRC forum, I managed to redirect the terminal output to a file, so that all those messages get written to a debug file.

Finally I could find out why openMSX was crashing. It turned out that openMSX was aborted with an error message that it could not read any MSX firmware files for any MSX machine. Which makes perfect sense because I had not yet installed the MSX firmware files.

However, it is too late now to still install the firmware and related configuration files. That is for tomorrow.

Sunday 4 Nov 2012, end of the day

The last couple of days I have puzzling a lot to figure out the openMSX build system.

Finally, after many attempts, weeding through build scripts, adding debug statements and after having asked many questions on the openmsx IRC forum to the other developers, I have managed to cross-compile the entire openMSX source code using the Android build tools.

This is a major milestone. I'm very happy now :-)

The next step is to link all the object code into a shared library, package it together with the other openMSX resources (like the configuration files describing all the MSX machines) into an Android package file, install it on my nexus, cross my fingers and then launch openMSX.

But that is all for next week.

Saturday 27 Oct 2012, end of the day

As mentioned last week, the next step in the project was to study the SDL port for Android.

After having read the documentation, I have started experimenting with a small demo program that is included with the source code of the SDL port. The documentation mentions that the SDL library contains a virtual keyboard with a control-pad and up to six customizable buttons, which can all be rendered transparently over the screen of the application. This is especially useful for games, so that the virtual control-pad does not take away too much screen space

The SDL library has three different themes for the virtual keyboard, as can be seen in following three photos

Furthermore, the SDL library can also integrate with the standard virtual keyboard of Android in order to have full keyboard support. This is useful for example in BASIC or in a word processor when you want to enter text into the emulated MSX. Though, the android keyboard can not be rendered transparently. It completely covers a part of the screen:

Another aspect that I experimented with was to bundle "own" resources into the APK package file. In order to stay with the openMSX theme, I used some graphics from openMSX to replace and complement the graphics that were originally bundled with the demo program.

Next week I'll experiment with the build and compilation system in order to find out how the openMSX build can integrate with the Android NDK tool-chain and with the Android port of SDL and several other required libraries.

Sunday 21 Oct 2012, late in the evening

Today I have learned a lot about working with the Android SDK, the Android application life cycle and event model and how to build native apps in C/C++ using the NDK. I have however not had the time anymore to look at the SDL port for Android. I'll study that one in the week to come.

Sunday 21 Oct 2012, early in the morning

Yesterday I received my Samsung Galaxy Nexus smartphone, which I ordered a week ago. After having played with it for a while I started working on the openMSX port for Android; I promised to make such a port last week on the openMSX IRC channel.

Obviously, porting a complex emulator like openMSX to a platform that I know almost nothing about is a daunting task. Hence, my first baby steps yesterday where to install the Android Software Developers Kit (SDK) on my PC under linux and follow the online tutorial to make a simple 'hello world' app in Java, which I managed to install and run on my shiny new toy.

As some of you may know, Android applications are by default written in Java, so that they can run on any Android device, regardless of the CPU architecture. This is a great idea. There is however one small catch; openMSX has been entirely written in C++ and migrating it to Java would be a momentous task of epic proportions. Fortunately, google has anticipated this and in order to help people with porting existing C or C++ programs to Android, they have made the so-called Native Developers Kit (NDK). I plan to use this NDK in order to port openMSX to Android.

My next steps for today are directed at further exploring and learning the Android development core concepts. I will first experiment more with some simple Java programs, using the SDK, in order to start understanding the Android user interface and application life cycle paradigms. After that, I'll follow the NDK tutorial with some simple program written in C or C++, in order to learn how to bridge from a Java frontend to a C or C++ backend. As a last step, if time still permits today, I plan to make a simple app using the SDL library for Android; the SDL library is a set of functions for graphics operations, audio operations, keyboard interactions and all other kind of low-level interface interactions. The SDL library has several implementations, for example one for windows, another for linux and yet another one for mac. This library is used by openMSX for all the low-level interface operations. It is one of the reasons that openMSX is portable to multiple platforms, despite being written in C++. The SDL developers have made an Android flavour of it, based on the forementioned NDK. This is actually what makes me hopefull that it is possible to port openMSX to Android within a reasonable timeframe and effort. My objective is to have a first version of openMSX for Android ready by the Nijmegen MSX fair coming January.