Showing posts with label Elite. Show all posts
Showing posts with label Elite. Show all posts

Tuesday, November 01, 2011

3D Space Game Bug Fixes

Back in July I wrote that I was working on getting rid of the bugs in 3D Space Game. It has certainly taken me a while to get most of them squashed, but I've just uploaded a new version to the Android Market [edit - no longer available] that fixes many crashes (hopefully!). You can also view the source code on the googlecode site [edit - no longer available].

One of the nasty side effects of the old version was it's battery hogging behaviour. This was caused by my dreadfully inefficient Game Boy Advance-like emulation layer that was baked into the game. Over the last few months I've also improved my android-ndk-profiler so it works a lot better on older devices, and I've used it here to try and get better performance. Even with that I still did most of my tuning and debugging on the SDL and Linux port - Android is still missing something like valgrind for native code and GDB doesn't work prior to 2.3.

For the umpteenth time I learned the following lesson: if an (Android) application crashes, chances are it is because I am writing past the end of a buffer into something important! Let's see if the lesson sticks this time :-)

Monday, June 13, 2011

3D Space Game Source Code Release

I've received a few emails recently asking about the source code for the ahem Elite port that's in the Android Market [edit - no longer on the Android Market]. The TL;DR summary: the source is now available [edit - no longer available due to copyright concerns] and it includes updates to the DS and GBA versions with all core bug fixes that have gone into the Android version too.

The game began life on the Game Boy Advance and the source was always available in tar-ball form from my now-defunct Geocities remakes site (later moved to a new home). From there I ported the same code to the DS, though I didn't really make the most of the platform. There was no touch input and no use of the 2nd screen at all. The source was in a svn repository now though, on Google Code.

When I ported to the DS I did it the wrong way really: I ripped out the GBA parts and added in the DS bits instead. This meant that the Android port had to at least rip out the DS bits. I knew I didn't want to abandon the DS and GBA just yet, so as well as taking out the platform-specific code in the core part of the game, I added in hooks that each platform would have to implement in its own way. At first I only did the Android, Linux/SDL and DS parts of these hooks, but in the end I've re-done the GBA part too.

There's not a lot of documentation on building the source yet, I'll update that later this week if I get time. If you're interested in compiling all this, you'll need the Android development kits as well as devkitARM. The devkitARM dependency is for grit, so if you get that some other way and don't want to build the DS/GBA versions then you can do that too. Run "scons --help-variables" from the top level directory to see what things you can alter about the build. Or you can just browse the source code and marvel at the hideousness of it all.

As I've pretty much moved on from DS and GBA coding these versions are probably not as well tested as they ought to be. Let me know of any problems you encounter and I'll see what I can do. Patches are welcome :-) Also: saves are, sadly, not backwards compatible with previous releases. This is due to the addition of a new flag that stores the type of game - "Classic" or "Elite-A" mode. Elite-A is also know as "difficultly turned up to 11 mode".

Friday, May 20, 2011

Black screen of death on HTC Desire

It seems that my version of Elite [edit - no longer available] on Android is not behaving very well on the HTC Desire. The comments speak for themselves:
Black screen on start up, freezes phone, have to remove battery on HTC desire. I loved this game back in the day too.
by starbuck (May 20, 2011)
Don't download this app, this app has crashed my f*cking htc desire
by Marco (May 19, 2011)
I am giving it a 4 , but it has crashed a few times and clearer instructions would help. Desire hd
by Thomas (May 7, 2011)
Intro music played but black screen and phone locked. Had to remove battery. Desire
by Robert (May 6, 2011)
Black screen lock-up on starting. Had to remove battery to recover. Not good. Desire.
by Grampian (April 26, 2011)

If there are any HTC Desire owners who want to help fix this problem then please get in touch. I'm obviously doing something wrong, but the platform shouldn't crash to such an extent that you have to take the battery out! Especially when the game does run on some HTC Desires as well as on many other types of phone.

I don't know which is more frustrating: the crashes themselves or the attitude of the people leaving these drive-by 1 star reviews. Writing such a comment may make them feel better (hey! my free stuff doesn't work!) but in the long term it doesn't help anybody.

So if you have a Desire and are experiencing crashes, please, please try and send me a "logcat" of the crash so I can work out what's going on and fix it. There's an application in the Market called aLogcat that lets you capture the log and email it out. Check that no personal information is in there (there shouldn't be any) and send me the info if you can. Otherwise there is nothing I can do, short of blacklisting Desires.

On a happier note: A new version of Chaos is out that fixes all the bugs that were reported, except one. The Nintendo DS and GBA versions are based on this same code. Fixes on all platforms are:
  • Make sound fx volume more consistent
  • Fix dismount wizard bug
  • Speed up magic bolt
  • Add a message when Meditate's side effect kicks in (it freezes the wizard)
The one bug that I can't reproduce is (surprise) Android only, and seems like another "Android hates me" oddity:
  • black screen after pause/resume
I've made a change that may help, but who can tell. Interestingly, a lot of commercial games seem to just kill the activity when you move away from it instead of dealing with this issue.

Saturday, April 09, 2011

Why are my textures not showing up on Android?

What a disaster the initial week of "3D Space Game" has been! I recieved lots of 1 star reviews with vague hints about what the problem was - "doesn't work", "goofed up". When I realised there was a problem and added a note on the market asking people to email their problems before "down voting" I got a couple of very helpful bug reports.

It turns out that on the Galaxy S and other larger-screened devices all of the textures I created from PNG images were not showing up. This meant that the control buttons and menu icons just show as white rectangles, completely unusable.

The usual reason for the white rectangle effect is that the size of the texture you're trying to use is not a power of 2. Textures have to be 32x32, 64x32, 128x512, etc - you can't have a 257x123 sized texture (unless it's on the Android emulator, which doesn't care about texture size). I even mentioned this in my "lessons learned" post in January. The code I use creates a texture straight from the PNG like this:

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.my_image);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);

The size of the texture is taken from the PNG, which I had carefully made sure was a power of 2. On my HTC Magic the textures show up fine, so I thought everything was working correctly.

Well, it turns out that the BitmapFactory uses a default set of options that includes a "resize" flag. The flag is by default set to true, or "resize the image to screw up Open GL textures", as it should be known. The fix for this was to create my own set of Options and set the flag to false like this:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
Bitmap bmp = BitmapFactory.decodeResource(getResources(),
                R.drawable.my_image, opts); /* pass in opts */
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);

Problem solved. Let's hope for a reversal of the 1-star trend, eh readers?

Saturday, April 02, 2011

3D Space Game for Android

This is pretty much "Elite for Android" [edit - no longer available due to copyright concerns]. It's a port of a port of a remake of a fan-tweaked version of Elite. I first wrote this as a remake of Angus Duggans's Elite A for the GBA (Elite A being a tweaked version of the original Elite on the BBC Micro), ported that to the DS and now here it is on Android. It's not been without problems due to a severe lack of buttons on a phone. This version adds in "classic mode" to play the game without the Elite A modifications.



I started the Android port back in October 2010 and it was more or less complete by December 2010. I've spent the months since then squashing bugs and refining the controls. Hopefully it will work on a lot of devices - I've been testing on 2009 vintage hardware - but there's no way to know for sure. Try it and let me know. In particular Samsung really threw a spanner in the works by not supplying a d-pad or trackball on the Galaxy S.

There are still some known problems in this first release:
  • Yellow line under title is not always shown
  • Sprite text still shown on panels
  • Long press should show route to planet (bit flakey, ditto Galactic Hyperspace)
  • Text occasionally does not update
Most of these are due to the GBA/DS heritage, but none are show stoppers. I'll be updating with fixes as people complain :-) Also, the Nintendo DS and GBA "backports" of this code are not ready, so this is Android-only for now. There are still some outstanding problems that I need to fix on the DS, and the GBA code is further off, but I'm starting to get project fatigue here and need a change.

This video shows the gameplay, it's a little choppy - if anyone knows a good way to video off an Android device I'd love to know. I used droid@screen for this, which seems to be the best option out there, but it doesn't record video. I had to record the X11 window separately using xvidcap and this made things slightly worse. Anyway, on with the show:

Tuesday, April 07, 2009

Elite DS version 0.6

I've just cooked up a new release of Elite DS. This adds the music back in that I had to take out when my own GBA XM library proved too tricky/time consuming to port to the DS. I've updated the code so that it compiles with devkitARM r25 and the sound now uses devkitpro's default ARM7 core.

From a technical POV the changes aren't very interesting, but I'll waffle on about them anyway!

Prior to this release, I was using the DS's PSG sound system. This is the bleep-bleep-bleep square/triangle wave sound system that Nintendo has used in its handhelds since the dawn of time. I think it is pretty much unchanged since the original Gameboy ;-) The good thing about this "format" is that it is small - you can say "use this pitch", "play it!", "hold it!" in just a few bytes and the sound lasts ages. You just change the pitch after a given length of time to add new exciting effects. The bad part is that it sounds terrible! Also, the sound format is completely arbitrary/homegrown as you have to just poke registers with values to make the DS go BEEP.

Additional amusement creeps in as you have to poke the sound registers on the ARM7, but the sound events trigger on the ARM9. Like when you get shot or fire a laser. I used the inter-processor FIFO to pass the "bleep now dammit!" messages from the '9 to the '7. Most of the sounds were taken from running Elite under emulation in pocket beeb, capturing the sound values that were written to the BBC sound registers, converting them into the equivalent values for the DS registers and then using these values in Elite DS. They sound more or less like the original BBC sounds this way. This is not necessarily a good thing :-)

The new sound effects were easier to create. I used this simple (to use) sound generator. I spent a pleasant afternoon creating random sounds, some of which may be slightly above the "terrible" level. I forget where I stole the Elite music files from, I think they are nabbed from the NES version. Of course on the DS these all use the fantastic maxmod library. I wish this had been available years ago, it is very easy to use and works exceptionally well.

Ah, there was one random bug that had me scratching my head for a while - I used to use a bit of assembler to clear the screen. This sets all the ARM registers to zero and creates an unrolled loop to blit these zeroes to the video RAM. For some reason it caused crashes on hardware when I started using maxmod. The only thing I can think of is that somehow registers were getting clobbered that maxmod uses in an interrrupt, or vice versa. My fix was to replace that clear screen routine with a DMA fill. Speed is not an issue on the DS compared to the GBA :-) It's a bit cargo-culty but I was desperate and with that register-clobbering explanation I sort of convinced myself. Anyway, I've been playing 0.6 all afternoon and it hasn't shown any more crashes (of the game; there have been colisions between myself and a few Cobra Mk IIIs). Enjoy!

Monday, December 31, 2007

Another Elite AGB/DS Update

A hectic few weeks in RL (I'm now a dad) have meant that I have not been able to dedicate much time to coding. However, I've ironed out the last few DS specific bugs in my port of Elite AGB and it is now playable. The only major issue left to resolve is the sound. The XM player that I wrote for the GBA version is incompatible with the DS by design, due to the hardware differences. I have integrated libntxm but it has a problem that causes notes to be cut short. The GBA sound effects use the GB sound hardware, which can be emulated on the DS using its PSG sound system. I got this working without too much hassle, but I get the feeling that it doesn't play nicely with libntxm either. The sound effects work when libntxm is not activated in the build, but adding it in causes the sounds to break.

I think the best option at this point is to remove XM playback - remove the crappy music ;-) - until I port my own XM player to the DS. This way I can make a release soon-ish before I get really sick of the whole thing.

Sunday, November 25, 2007

WIP update - Elite DS

I got side tracked with grit, adding the ability to share a palette between various images. Now that this problem is solved (Cearn sent me an interesting program to merge image palettes after I sent him a patch against grit to do something similar) Elite AGB compiles for the DS. All that's left is to get it working! :-)

At the minute the NDS file just shows 2 white screens; a familiar situation for anyone who has coded anything on the DS. So now to start debugging...

EDIT: heh. here's a screenshot of the first build running in desmume. Yes, it is a straight GBA port.

Sunday, January 22, 2006

Updated Elite AGB

I've put the updates to Elite AGB on my site now. These additions are some of the changes made by Thomas Metz to TNK plus a couple of extras. In detail then:

Quick saving - so you can save anywhere. This is really handy when you are going for a monster special cargo run and have to hop between several planets sun-scooping fuel. Doesn't solve the problem of being crap and getting killed though, sadly.

Different "star field" effect. I really liked the dust field effect added to TNK, but after making similar changes here, I'm not sure. I might make it optional at some point.

A few more planets on the short range chart - I've not added the big change made to TNK since I think it looks too cluttered with all the stars present. It's fine around Lave, but some of the planet patterns near the top of galaxy 1 are much more packed.

Galactic Chart path finder. This was one thing I fancied doing since I saw this website with Elite Trade Routes a couple of years ago. Now you can press Select to get a line plotting the "best" route to a planet from your current location. Best here means the shortest route with least jumps flying to the safest planets. A bit cheaty perhaps but I feel Elite AGB pilots need all the help they can get!

Friday, December 30, 2005

"The New Kind" updated

I've uploaded the fixes to Elite TNK. These sort out the problem found with the star chart - a stray planet appeared at times - and also the mostly harmless save game memory bug. Other source code changes fix a few compiler warnings, but nothing else.

Wednesday, December 28, 2005

Elite WIP

A couple of bugs have been spotted in the Elite code Thomas sent me. I've sorted them out now but haven't uploaded the new files. I'm still testing to see if the fixes break anything else. If anyone's desperate then let me know and I'll post them.

I've also incorporated some of TM's changes into Elite AGB. The Quick Save is especially handy. More testing here. One thing I'm going to have to add to EAGB is proper Z clipped polygons. A Mr Harris wrote me an email complaining about the docking and the fact that just before you enter the station, the whole thing disappears. He's right of course. This was OK in the wireframe Elite, since everything was see through anyway, but it is unsettling when you have solid space ships. Not an easy one to fix, but I'm on it.

Finally, my move to coding DS game seems more likely as some bright spark has figured out how to wireless multiboot DS code from Linux using ralink wireless cards. Which is just the type of card I have. All I need now is a DS.