Android Emulators Update

I just made a minor update to my Android emulators for 8-bit machines (the Raspberry Pi versions have not been changed). Since I updated my HTC One X to Android 4.1.1, the sound in all three of the emulators had been really horrible and distorted (yes, even more so than usual 😉 ). So it seemed a good time to update them to use 16-bit sound output, which seems to be better supported in Android. It turns out that 8-bit samples, which I was using before, aren’t actually guaranteed to work at all on every device, so this change would have been worth making even without the sudden appearance of the distortion.

Nothing else has changed except that they’re now being built with a newer version of the Android SDK; however, they should still work on all devices back to Android 2.1, and indeed they do still work on my old Wildfire. Please let me know if you encounter any problems.

Much as I like Android and Google and HTC in some ways, they do seem to like changing things that worked perfectly well already, and not always for the better. Almost every system update for my phone seems to turn into a fresh game of hunt-the-process-that’s-draining-the-whole-battery-and-guess-how-to-make-it-stop… including the ones that claim to improve battery life. And the latest update not only broke 8-bit sound, the phone also refuses point blank to talk to my desktop PC anymore, either as a USB disk drive or for app debugging purposes – both worked fine before. Ah well… got to keep the users and developers on their toes, I guess.

 

Why I don’t like restricted computing

Sort-of-preachy, serious-ish post today, sorry.

Back in the mists of time when I first started using computers, you could basically do whatever you wanted with them, in the sense that you could run any program you wanted, whether you wrote it yourself or bought it or acquired it from some dodgy geyser down the pub or whatever. It wasn’t necessarily easy to get it to do what you wanted, but at least the computer companies didn’t go out of their way to make it particulary difficult either. Now, with systems like the iPad and iPhone gaining popularity and Windows 8 on the horizon, that’s no longer true, and I find it worrying.

For those of you that don’t know, you can’t install just any software you want on an iPhone or iPad like you can on a PC – you can only install things from the official app store. Unless you jailbreak the thing or pay to become a developer, that is. The same situation exists with Windows Phone 7 (though not, thankfully, with Android and Blackberry – they both allow you to install apps from anywhere you want, more like a traditional PC).

You could argue, though, that the iPhone is still an improvement over previous mobile phones in this regard. After all, on earlier phones you couldn’t generally install extra software at all, and at least on the iPhone you can do this, even if you are restricted in where it comes from. But locking users into one source for their software appears to be a trend that’s migrating away from phones and towards more traditional computers. The upcoming Windows 8 contains two examples of this:

1. “Metro” apps, which are a new kind of application more similar to the ones you get on Windows Phones, will only be installable from the official Microsoft store. While you’ll still be able to install traditional Windows programs from anywhere like before, the new style apps won’t allow this.

2. The new ARM version of Windows 8 is mandating locked-down boot code, preventing users from replacing the operating system with something else. Installing Linux, for example, which is generally fairly easy on current PCs, would be made much more difficult or impossible on a Windows 8 ARM system. (There were fears that this would be the case for Windows 8 on all platforms, including standard PC systems, though this thankfully seems to have fallen by the wayside for now). By the way, there is no technical reason for this difference whatsoever – it’s like a car manufacturer deciding that if you buy a blue car from them you’ll be allowed to service it yourself and get hold of spare parts and so on, but if you buy a red one, the bonnet will be welded shut to stop you doing anything to it.

So why do I think this is a bad thing? Well, several reasons, but mainly this: I got into programming and doing other more advanced (and fun!) things with computers by tinkering around with my own computer (first a Spectrum, then a PC) at home. There was nothing to stop me writing my own programs, or modifying ones other people had written to see what would happen. It’s now my career and I’m pretty convinced that without those early experiences, I wouldn’t be doing it now. At the very least I certainly wouldn’t be as good at it or as enthusiastic about it. I worry that if the trend towards locked-down systems continues, the next generation of kids won’t get this same chance. They will miss out on experimenting and having fun with technology the way I did, and everyone will miss out on the things they might have created as a result.

The argument about whether this is a good thing or not rages on in various forums online. I already know a lot of what people will say in defence of the closed systems, so I’ll pre-empt it by giving my responses first.

“Kids will still be able to learn programming at school, or on specialist teaching devices”

Yes, no-one’s suggesting that learning programming is going to become impossible, but there’s no denying that it could get difficult enough to put a lot of people off. If the trend towards closed systems continues to the point where you can’t write programs on a standard PC anymore without either paying a “developer fee” or jumping through hoops to jailbreak it, there are going to be significant extra barriers in the way. And some people who might have persisted if it was as easy as just downloading one of the many free programming environments available online (as it is today) are going to give up if they find they have to make costly purchases or risky modifications to their computers before they even get to write a line of code.

And yes, school computing departments are likely to have programmer-friendly computers of some description. But I know I would never have got into programming in such a big way if I was restricted to doing it in school classes, and I’m sure the same applies to a lot of people. I did most of my learning and experimentation on my own at home.

“This isn’t like the old 8-bit days. Computers are too complicated for anyone to be able to understand now anyway, so it doesn’t matter if you’re prevented from programming them yourself”

They’re still perfectly understandable to many of us, thank you very much. The concepts are still very much the same. It’s true that computers are a lot more complex than they were in the days of the Spectrum and C64, probably complex enough that no one person can be an expert on every area of them now… but at the same time, software has improved a lot and got much better at hiding that complexity. So most times you don’t need to think about the details of the hardware while you’re coding an app… though in some cases it is useful to know those details, and in those cases it’s nice to be able to find them without slamming into an artificial brick wall that really doesn’t need to be there.

“Haven’t you got anything better to complain about? Surely this is trivial compared to global warming/starvation in Africa/the economic crisis”

Yes, it is, but I still think it’s important enough to be worth talking about, and I’m a lot more qualified to talk about this than about any of those other issues.

“This is nothing to do with you. Companies have a right to sell locked down computers and people have a right to buy them. If you don’t like them, just don’t buy them!”

I certainly don’t intend to buy them, in fact one of the main reasons I chose an HTC phone is that their policy on this is much better than most phone manufacturers (they allow you to unlock the phone’s bootloader and replace the entire operating system with a new one of your choice if you want to). And yes, people have a right to choose whatever hardware they want for themselves. But I also have a right to say why I don’t like this trend and try to warn other people of the possible downsides before we reach the point of no return. This is especially important because the downsides may not become obvious to most people until it’s too late to do much about them.

“Only a tiny minority of geeks want to write their own apps or install a different operating system. They will be knowledgeable enough to choose hardware that doesn’t restrict them”

Until we reach the point where it’s virtually impossible to find hardware that doesn’t restrict them, that is.

In any case, I think that argument is flawed. Not everyone knows when they buy a computer that they will at some point in the future want to replace the OS. I’m typing this right now on my netbook, and when I bought it I fully intended to just use it with the operating system it came with (Windows 7). It wasn’t until after I’d had it a while and found it was quite slow that I decided to give Linux a try on it. Thankfully today it’s quite easy to install Linux on any computer, even one that wasn’t designed for it, so it worked even though I hadn’t specifically looked for a Linux-compatible machine when purchasing it. Tomorrow I might not be so lucky if current trends continue.

I’ve also installed Linux for my dad and brother at various points when they were having problems with their Windows PCs and didn’t have the recovery disk anymore. They certainly wouldn’t have specifically looked for Linux compatibility when they bought their computers, but they were very grateful for it when it saved them from having to buy a new copy of Windows or a whole new computer just to get back up and running. (Though one can see why Microsoft and the hardware manufacturers might be less keen on users having this option).

I’m not convinced that it is only a “tiny minority” that want more flexibility with their computers, anyway. I think if you looked at the percentage of people who’d used their PCs for something that might not be approved of (or even envisaged at all) by Microsoft or Apple – whether that’s using a Bittorrent client, installing a free alternative to some of the built in software of Windows/OSX, or messing around with a programming language or game creator or something similar – it would be a lot more than a tiny minority. Almost everyone I know has probably used their PC for at least one thing that is likely to become difficult or impossible in future if Windows transitions to a locked down, iPhone-like model.

It’s hard to find numbers for the percentage of iPhones that have been jailbroken, but most estimates seem to put it around 10-15% in the West and much higher (33-50%) in China. That’s hardly a tiny number of people, and it doesn’t even include the percentage who might like to jailbreak if they knew it was possible and knew what it could do, or the people who decided not to buy an iPhone at all because of the restrictions but might have if they were a bit more open.

Even if it was only a “tiny minority” of geeks that want to do this stuff, I’m still not convinced that’s a good argument for preventing them from doing it. They may be tiny in number, but they’re likely to be playing a disproportionately large part in creating the next generation of innovative software. If they’re held back from doing so, it will be bad for the majority as well in the longer term.

“Phones and tablets aren’t computers, they’re appliances, so it’s fine that you can’t modify the software on them. Would you expect to be able to modify the software in your microwave?”

This seems a completely arbitrary distinction to me. Of course a microwave is an appliance, it may technically have a computer inside to control the electrics, but you wouldn’t be able to run a word processor or browse the web on it, so it’s no big loss that you can’t install your own software on it. I’d even say the original (pre-Touch) iPod was more of an appliance because its hardware made it not particularly useful for anything other than playing music. But tablets and phones are pretty obviously just small computers. They can do a lot of the same things a full size PC can do, access the same websites, even run some of the same apps. If you add a Bluetooth keyboard to your iPad, as many people do, it’s not that much different from a small netbook – so why is one a “computer” and one an “appliance”? It’s entirely an artificial distinction intended to muddy the waters and get people to accept that it’s OK for tablet computers to be locked down and restricted because they’re somehow “different” from traditional computers with a keyboard.

“This is a good thing for most people. It means better security and higher quality software”

If you can’t install software, you can’t install buggy software or malware, right? So it must be a good thing!

I don’t really believe this argument. If (for example) Apple wanted to, they could include a checkbox in iOS like the Android one that allows you to install apps from anywhere you like, they could also include an HTC-style bootloader unlocker tool on their website, and these things would have absolutely zero impact on security or usability for most people. How could they? Most people would never use them anyway (at least that’s what we keep being told). Sure, if people really wanted to, they could then go and install malware from dodgy websites. If people really want to, there’s nothing to stop them driving the wrong way up a motorway or walking down a dark alley in a bad area at night laden with expensive jewellery either, but I don’t hear many people clamouring for rules to stop people from driving their own cars, or going out after dark without a police escort. So why this desire to stop people installing software on their own computers?

In any case, if you think locking down computer systems makes them immune to bugs and security flaws, just look at the iOS 6 maps fiasco, the alarm clock fiascos, the security hole that allowed iPhones to be jailbroken just by visiting a website, numerous games console hacks and jailbreaks, and one study that found the official App Store had more spyware in it than the unofficial, unsanctioned Cydia store (sorry, I’ve lost the link for this one).

So if security and usability isn’t the real reason for doing this, what is? I can think of at least two:

1. Money. Apple takes a 30% cut of anything you buy from the App Store, and anything (such as music, ebooks) that you buy from within apps as well. Allowing competitors to operate app stores, or allowing you to install apps from outwith the store would obviously interfere with them getting this cut. I keep hoping this will be ruled illegal under EU competition law or something – I don’t think a car manufacturer would get away with demanding a 30% cut of any accessories you buy, or a stereo manufacturer demanding 30% from all the CDs you buy, so I’m not sure why it’s considered acceptable in the computing world.

2. Control. If they can control what you can and can’t install on your computer, they can prevent you installing things they don’t approve of. For example, programs that copy DVDs and BluRays can be outlawed, as well as software that competes with one of the supplier’s own products. Bittorrent clients could be forbidden altogether, and web browsers could be made to automatically block access to sites that Apple (or the authorities) disapprove of.

“It doesn’t matter, people will just jailbreak them anyway”

Typically, jailbreaking relies on finding holes in the security that aren’t supposed to be there. Often these are fixed in future software or hardware updates, meaning that new jailbreaking methods have to be found. Often they are found quickly, but there are no guarantees – some devices haven’t been jailbroken even after months or years. Security is getting ever more sophisticated as well.

Relying on jailbreaks being available is like agreeing to live in a prison cell because you’ve found a secret tunnel in the floor that allows you to go out whenever you like. Maybe that will work for a while, but what are you going to do if the guards discover the tunnel and block it up? Maybe you’ll find another one… then another… what if one day there isn’t another one? If you value being able to go outside, the only safe option is to not agree to live in the cell in the first place.

There is also the fact that jailbreaking will likely void your warranty and may permanently damage your device if it goes wrong, so a lot of people will be hesitant to do this to their expensive phone or tablet.

“This will never happen, you’re just scaremongering and you’ve got no evidence”

Right now, I don’t know what’s going to happen. No-one does. I would love nothing more than to be proved wrong about all of this, to still be living in a world where people can do whatever they want with their computers (and indeed phones and whatever other devices are around by then) in ten or twenty years time. But currently there is a definite shift going on away from general purpose programmable systems, and that’s enough to make me very concerned. I’d rather say something now and help raise awareness even if it does seem like scaremongering than sit back and watch in silence as Apple and Microsoft attempt to flush the technology landscape that got me to where I am today down the toilet.

“Apple and Microsoft would never use their app store rules for censorship or to block competitors, only to block buggy or dangerous software”

Right now it is likely that they are treading carefully, because they won’t want to scare people away to the many open alternatives that still exist at this point. But if closed platforms become more widespread in the future, there will be nothing to stop them from being a lot more restrictive. Even so, there have already been some bad policies and decisions from both Apple and Microsoft. Many of the rules have got nothing whatsoever to do with the security or quality of software and are purely about censoring content or preventing competition. This article points out that the majority of recent popular PC games would be forbidden from the Microsoft Store due to their content. Both companies ban or severely restrict apps that compete with their own – so in future there may be no more installing Firefox or Chrome, you could be stuck with Internet Explorer whether you like it or not. Apple have already used their app store restrictions for censorship of political cartoons. They also used to have a policy against any app that allowed any sort of scripting – this prohibits (among other things) emulators for old computers and consoles, and software designed to teach kids programming.

Yes, some of these decisions were eventually reversed, others were not. But in any case, can you count on every bad decision that affects you being reversed in the future? No. That’s why the only safe option is not to give them this power in the first place.

Phew. That was longer than it was supposed to be!

 

HTC One X

Three generations of HTC smartphones:

On the left is the trusty HTC Wildfire I’ve been using since I finally entered the world of contracts and smartphones nearly two years ago. In the middle is Laura’s HTC Sensation. And on the right is the new *switches to dramatic deep, echoey voice* HTC One X.

I just upgraded from one of the least powerful Android phones available to one of the most. The Wildfire served me well, but it was getting very slow, or maybe it was always slow and I just didn’t notice before. Sending or receiving a text would freeze the whole phone up for several seconds, sometimes longer. I was starting to dread adding new music or installing new apps as it would mean deleting something else to make room for them. And various popular apps wouldn’t even install, either because of the low screen resolution (I’m looking at you, Skype… why the hell do you need a big screen anyway?) or the old processor (528MHz ARMv6). The battery also wasn’t lasting as long as it used to. But anyway… I was sufficiently impressed with HTC to want another one of theirs. (I also very much approve of their policy of making it easy to install whatever operating system you want on their phones, and felt like I should support them even if I don’t end up taking advantage of that myself).

The One X is an impressive little device, and when I logged onto Orange and found I could upgrade to one straight away for only a slightly increased monthly payment, I ordered it immediately before they changed their mind. It has a quad core 1GHz processor and NVIDIA GPU – more powerful than my netbook, and capable of emulating not just old 8-bit systems, but even PlayStations and older PCs. The screen resolution (1280×720) is massive for a phone, and actually the same as the 32 inch widescreen TV in our living room!

Things I like about it (so far): it’s blazingly fast compared to my old one, as it should be. Apps install in seconds rather than minutes. Things like sending texts happen instantaneously. Transferring my number from the old sim to the new one was a piece of cake. A couple of clicks on the Orange website and it was done. The screen is really nice – photos and videos look great on it. Most apps seem to adapt to the much higher resolution fine, although one of the ones I tried looked a bit small.

I’m enjoying being able to install as many apps as I want without worrying about space. I was also pleasantly surprised that even though I’ve jumped a number of Android versions (2.2 to 4.0.3), all the apps I use work exactly the same, including the ones I wrote. The Google store remembered which apps I’d paid for (more accurately, which app I’d paid for) and let me reinstall them (it) without having to pay again. Oh, and Dropbox gave me an extra 25GB of space just for getting this phone! (Though I’m afraid to use it because it will expire at some point or I’ll have to start paying for it).

Things I have reservations about: it’s very iPhone-esque in some ways, and not all of them are good ways. There’s no SD card slot so I’m stuck with the storage that’s built into it (though it has 32GB built in which was the size of the largest SD card I could put in the old one anyway, so it should be fine as long as I keep my music collection sufficiently tamed). It’s also not possible to easily take the battery out and replace it, so I’ll just have to hope it lasts. (Reviews seem mixed about battery life on this phone – some say it’s terrible, some say it’s quite good… I haven’t had it long enough to tell yet). It only takes micro SIM cards so I can’t put my old T-Mobile SIM in for going abroad like I did with the Wildfire (though I’m assuming the One is locked to Orange anyway).

The “menu” and “search” buttons that previous HTCs had have gone and are replaced with a “recent apps” button. I hardly ever used the search button, but I miss the menu button, even though it appears on-screen when it’s needed. I also slightly miss the optical trackball that the Wildfire had, it was handy for moving the cursor around in text, but I’m getting used to dragging the bobble thing that appears on the screen around instead.

Verdict: pretty impressed so far 🙂

 

Gapless playback on Android!

I am disproportionately happy about something geeky again today :). I finally found an Android app that supports gapless playback properly.

This has annoyed me ever since my faithful iPod provided the perfect finale to one of the worst weekends of my life back in 2010 by suddenly dying completely and leaving me music-less just before a 5 hour car journey on my own. I decided to save money by getting a big memory card for my HTC Wildfire and putting all my music on there instead of replacing the iPod. Mostly this worked ok, but two things about the default Android music player app began to irritate me quite a lot. One is the fact that once you’ve started playing a song, there doesn’t seem to be any way to go back to the track list for that album or the album list for that artist. If you decide you want a different song by them (which I do quite often), you have to go right back to the start of the process and find them in the alphabetical list of artists again, then the album list, then the track list.

The other annoyance was the lack of gapless playback. On the iPod if you ripped a CD with tracks that were supposed to run straight into each other without a gap (like the first two tracks on Sergeant Pepper to give a well known example), they would play correctly and you wouldn’t even notice the transition. On Android there was always a gap between, no matter how you ripped them. This probably wouldn’t have bothered most people but I am (a) easily irritated when technology doesn’t do what I want, (b) the sort of person who likes to immerse myself in music and that doesn’t really work when there’s suddenly a jarring silence that’s not meant to be there, and (c) a big fan of several artists (Mike Oldfield, The Arcade Fire and Evanescence to name three) that tend to use quite a few gapless tracks on their albums.

I had a hunt around online for ways of getting gapless playback on Android, but it quickly became apparent that not many other people had managed to do it either. There were several apps that claimed they would do it… something called Museek tried to simulate gapless playback by slightly overlapping each track with the next one, the effect of which was, erm, “interesting” but still quite a long way off being seamless. Others could only do gapless if you went back and re-ripped each album as one single huge file instead of individual tracks. Others I think could only do it if they were running on a version of Android that supported it, which mine (2.2) doesn’t.

I was sure it must be possible, though, and last year I started hacking together an app to do it myself. The built in Android audio decoding libraries wouldn’t do gapless properly, but there was no reason you couldn’t bypass those and do the decoding in the app code instead – it would just be more work. After a few days I had an app that was capable of playing two OGG files with no gap whatsoever between them, but I got bored of it and it slipped way down my todo list before I’d got around to making it do anything useful.

And then today I found Poweramp… which uses exactly the same approach as my little app was going to, doing the decoding itself instead of using the Android system libraries. For the last few hours I’ve been stress testing it on all the gapless albums I can find and I’m very impressed. It even makes a decent attempt at removing the gaps when playing a file format that doesn’t support gapless (like standard MP3), though it’s only completely seamless when playing formats that do (OGG, etc.). I’m still using the trial version at the moment but I think this may be the first mobile app I actually end up paying for. Highly recommended 🙂

 

My Android Apps

I’ve had my Android phone about 18 months now. As the sort of person who likes to program everything that isn’t nailed down (starting from my dad’s ZX Spectrum and eventually progressing up to supercomputers) I just had to have a go at making some apps.

Android is good for coding your own apps, which is one of the reasons I chose it. For iPhone and iPad you need to use a Mac for development (which I don’t have and have no intention of getting) and you also have to either pay a developer fee of $99 per year or jailbreak your device. Even then you can’t test your code on anyone else’s phone unless they also pay the fee or jailbreak it. Thankfully Android is more accessible for programmers… you can just download a free software development kit for Windows, Mac or Linux and get started straight away.

Most of my apps are quite boring. There’s one that backs up all my contacts and text messages to a file and puts it in my Dropbox folder automatically. That was the first one I wrote and I’ve used it a lot ever since, though I improved it and added the Dropbox integration more recently. Another keeps track of my finances, and there’s one that allows me to access the task tracker I use (without which my life would probably be frighteningly close to unravelling completely) from my phone. But the most fun ones are the emulators.

Emulators are programs that make a computer behave like a different kind of computer. They let you run old programs on hardware that didn’t even exist when they were written. There are huge numbers of emulators out there allowing you to turn your PC into any kind of old, clunky computer or console imaginable. They’ve always interested me, partly because I like old computers for nostalgic reasons and partly because of the technical intricacy that goes into making emulators work. So since I started programming on the Spectrum and could still just about remember how it works inside out, it seemed fitting that I should code a Spectrum emulator for Android.

Here it is, running one of my favourite old games (Spellbound Dizzy) on my phone. I’m quite proud of it… I think it works rather well. (If your definition of “well” encompasses turning a cutting edge smartphone into an ancient, primitive computer, that is 😉 ). It runs at full speed, which the other emulators I tested didn’t seem to quite manage on my slow-ish HTC Wildfire.

Then I decided that at this point it wouldn’t be too much work to make a Sega Master System emulator as well. I never owned a Master System (went straight from the Spectrum to Megadrive and our first PC) but I loved playing Sonic on other people’s whenever I got the chance.

It uses exactly the same main processor as the Spectrum and a lot of the other emulator code could be shared as well, so I got it up and running a lot quicker than the first one. The only hard bit was getting the Master System’s graphics working properly.

Finally (for now) I did a Gameboy emulator as well:

Tetris is even fiddlier to play with the controller on the touchscreen, though.

If you have an Android phone and feel like reliving the games of the early 90s, you can play with my emulators too. I put them online here (you will need to have the “Unknown sources” box ticked in your application settings to be able to install them). I’ve only tested them on two phones so far so it’s possible they won’t play well on all devices. If they don’t seem to work properly, please feel free to get in touch and I might be able to fix them, though I can’t promise anything. There are probably better emulators out there for all these machines, I really just made these ones for my own amusement.

(As well as installing the emulator app, you will need to put some games on your memory card. There are hundreds if not thousands of Spectrum games on World of Spectrum, which seems to be at least semi-legitimate. I don’t know of any legal sites for Gameboy and Master System ROMs but they’re pretty easy to find by googling anyway).

Have fun :).