Friday, 20 August 2010

XAGE on Ubuntu

My relationship with Linux has traditionally been rather negative, starting some ten years ago at university. The key combination of Shift+Insert would make the desktop of whatever particular distribution I was using crash, and thus a decade of mild distrust began.

This evening, armed with a new 8GB usb stick and an installation of Lucid Lynx (Ubuntu 10.04), I've learned things have improved dramatically in that time. The OS is nippy and slick, Chrome flies and even MonoDevelop runs reasonably well. In a few short hours I've been able to get XAGE running natively from the shared codebase:

Don't apt-get too excited

This is, unfortunately, the most exciting screenshot I can currently muster up. My custom binary loader seems to be broken, and I imagine the problems with audio and video encountered previously will return, but otherwise I'm happy with the progress made. If I can get it all working then it can only be good news for Mac OS, Android and iPhone (assuming those pesky licensing hurdles can be overcome).

Saturday, 7 August 2010

Back to work

So the World Cup was a bit of a noisy disappointment, but Read Dead Redemption saved the summer hiatus by having, in inimitable Rockstar style, quite possibly the best achievement ever.

I'd been aware of MonoXna for a few years, and had always known it as a dead project, so it was with some surprise that I saw that it had been quietly resurrected with some recent code submissions. I spent a good amount of time with it and had mixed results.

The good news is that I was able to get XAGE up and running after a few days. Similar to how Silversprite works, MonoXNA allows XNA games to be run without any dependency on the original Microsoft framework, allowing you to target new platforms (most notably Mac & Linux, and bodes well for future projects like MonoDroid).

The bad news is that neither audio or Texture2Ds seem to be fully supported. I'm sure it's possible to workaround some of these issues and I'll return to MonoXna again in the future when I have more time. Silverlight continues to be the secondary focal point for development. This is because playing the games through a web browser is still compelling and novel enough to devote time and effort to, and also because it's easy for me to develop & test. I don't currently own a spare machine for a decent linux distribution (and lack the space for a dual-boot, or even a large enough usb stick for ubuntu), and also I'm too perpetually poor to afford a Mac. Also, MonoDevelop curiously runs like dirt on my netbook.

Work has now finally been resumed on XAGE proper; my evening was spent adding support for running animations backward. This was to enable the little tramp in Ben Chandler's '!' to animate correctly:

xage !

I'm using this game as a test case to help me figure out a workable design for arrays, which will help when I go back to TGP. Incidentally, Zombie Cow's game for Channel4, Privates, has been released and bucks the trend of most edutainment titles by actually being rather spiffy.

Thursday, 10 June 2010

The Holy Triumvirate of Timesinks

We are passing through a short period of History that scientists and theologians alike will later agree to describe as, "Mentally Busy". This doesn't look set to change over the next six weeks due to Red Dead Redemption, the World Cup and a long overdue house move.

I haven't completed a game since GTA4, so it is fitting that RDR is the first game in two years that has managed to sustain my attention despite the numerous obligations and distractions. It's a very pretty title that manages to be supremely well crafted and horrendously buggy at the same time. Just riding around shooting at wildlife is extremely satisfying. That probably makes me a bad person.

Here's a free tip on how to upset your significant other: Tell her that most of your happiest memories revolve around the World Cup.

Finally, by early-July I should be in a position to shave a whopping 12-15 hours off my weekly commute which will give me, amongst other things, more time to spend working on that pesky game engine thingy.

Saturday, 29 May 2010

Super-Secret Game: Revealed

As tweeted earlier today by @thezombiecow, the super-secret AGS -> XAGE conversion project is Time Gentlemen, Please. Obviously this is massively exciting for a number of reasons:
More accurately, I'm actually working on the demo as a feasibility study and it's going pretty well. The ultimate aim is to get the full game onto Xbox Live. It's a huge amount off work but I'm confident it can be done.

Zombie Cow Studios are currently venturing into the third dimension, with some hand-holding from Channel4, in Privates (read the eye-opening press release here).

Oceanspirit Dennis:

I've actively been working on a few others things that have helped development across the board (finicky things like handling GUI transparency). One is Ben304's mock RPG, Oceanspirit Dennis: Scourge of the Underworld. It's essentially a satire on JRPGs (at least, that was my interpretation). It has since spawned a number of increasingly peculiar sequels, all of which are brain-achingly canon.

An interesting diversion and XAGE's second full conversion - play it online here: http://www.clarvalon.com/XAGE/games/ODennis/

To quote the author: 'Don't play if you're looking for a rewarding experience!'

Ben has also recently open-sourced '!', his well-received comic-panelled, robotic rap-athon. You should all follow @ben_304 and ask him when he finds time to sleep.

Other Stuff:
  • Expressions are supported, in that XAGE now copes with things like cChar.Walk(cChar.X + 10, cChar.Y - 20).
  • RenderTargets are no longer used when no scaling is required, improving performance in certain instances.
  • Silverlight now uses png textures instead of xnb, improving load times and further reducing the xap filesize.
  • Internal Dictionaries are generated in-game during initialisation. This means that, if a room has 300 objects, the engine no longer needs to loop through 299 to retrieve the last object when it is referenced via scripting. Certain methods that were previously using 4-5% of all processor time now use a tiny fraction.

Monday, 26 April 2010

Awakener: Reloaded

With the recent release of Silverlight v4, Awakener has received a small but much-needed update:
  • Right Mouse Button support - One long-running gripe with Flash is that any right click will open a context menu that usually can't be disposed of without selecting an item or, if you're determined not to let the pesky menu win, alt-tabbing your way out of it. It is a relief that Microsoft has opted to allow developers to override the existing right mouse button events to their own ends. No more awkward CTRL + LMB needed.
  • Full Screen Mode - Awakener can now be scaled up and down at runtime (previously just down due to a SilverSprite bug). This means we can now use Silverlight's Full Screen mode, as XAGE will scale the game up depending on the user's resolution.
  • Performance improvements - As mentioned recently, load times in particular are more brisk, although this perhaps isn't as noticeable given Awakener's small size.
These few changes make Awakener feel less like a clunky web app and more like the original AGS incarnation. I'd argue that it's even more intuitive as you don't have to worry about installations etc. Judge for yourself:
I've got a few more ideas for optimisations specifically for Silverlight but for now it's back to adding new functionality. Next up: Expressions.

Wednesday, 21 April 2010

More Optimisations

Talking about optimisations isn't especially exciting, though recent changes have been crucially important to making larger, more complex games viable on XAGE. The super-secret game, for instance, wasn't running at all well on the 360. After a productive weekend it now performs rather admirably, which is a major relief.

Engine - Load Times

Xml serialization is great, but - cripes - it's incredibly slow on the xbox. The main game content was taking in the region of 60 to 70 seconds to load, which might be passable for a Triple-A title but very undesireable for an Indie Game with a short time period in which to make a good impression.

The Automatic XNB serialisation built into Xna Game Studio wasn't really an option, and would have added a an extra layer of complexity to the publishing process. The only remaining solution was to write all data to a binary stream, which is blazing fast and supported on all platforms, but has obvious downsides:
  • You have to write load & save code for EACH class you want persist (at 70+ classes, this is a huge job).
  • Each time you change a class, you also have you to update and test the IO code (adding a painful maintenance overhead).
The eureka moment came from realizing that I could write a routine to generate the C# IO code automatically, and use this to extend my existing classes. I've written a summary of my solution on the Xna Forums.

The load time is now down to about 10 seconds, including all the initial graphics and audio - much better!

Engine - Garbage Collection

As mentioned previously, the X360 garbage collector is also horrifically slow. The super-secret game was causing XAGE to generate 1mb of garbage a second, causing a stuttering that was particularly noticeable when moving the cursor.

Using Collection Pools for the scripting routines and removing some sloppy CopyTo commands have reduced this to about 120k per second, meaning the GCs now occur once every 8 or 9 seconds and are less noticeable. I'll return to this in the future and should be able to reduce it further still.

Editor - AGS Conversions

The scripts are now processed in smaller chunks, speeding up some of the string manipulations dramatically. The HitchHiker's demo, quite frankly, used to take an absolute age to convert to XAGE and now the whole thing takes less than half a minute.

Friday, 9 April 2010

Hodge Podge

This post was started about three weeks ago, which may give some indication of how limited time is at the moment. It's a bit of a hodge-podge of news.

Optimisations

Work has begun on the next AGS game conversion - I'm not really in a position to reveal anything other than to say that it's a super-exciting project (as well as a massively complicated challenge).

Due to its size, some frailties within both XAGE Editor and the engine itself have been exposed. I've addressed some of these accordingly: items for scripts are now selected via dropdowns & lists rather than the previous big shiny buttons, the treeview refreshes a bit more efficiently and conversions have been speeded up after ...

Profiling

Converting small games is reasonably fast, though the process involves a lot of string manipulation and lookups and so takes exponentially longer the larger the game is. This was a problem for two games inparticular, taking anything between 5-10 minutes to convert - not a particularly productive length of time when testing small tweaks and changes.

I've managed to reduce this time by profiling the application. Using a profiler to identify a bottleneck is immensely satisfying. I'd gotten into the bad habit of using ToUpper() a lot when comparing strings, when there's much better performance to be had using String.Compare and ignoring case sensitivity. Other simple changes like using String Builders instead of concatenations have helped speed up the process.

Another useful outcome from profiling is identifying where garbage collection is occurring. One of the benefits of C# is not worrying too much about memory management. The xbox360 Garbage Collector isn't great however, and forces you to be mindful of what you're instatiating within each game loop. As it turns out, some rather innocuous code can be the difference between a game that runs at 2 fps and one that runs smoothly.

There are plenty of further optimisations to be made; XAGE's scripting creates more garbage than I'd like it to. When you have certain scripts with 10+ conditional statements that run 40 times per second, the garbage can quickly add up and cause stuttering. I'm also going to run a few tests using Automatic XNB serialization to improve load times on the 360 (assuming it's possible to do this using MSBuild).

New features

Support for AGS-style custom modules has been tentatively added, albeit in a slightly clunky way (slotted into standalone rooms for now). It's not ideal but it works, and will do until I get around to implementing a more elegant solution.

Other bits and bobs have been added, some of them purely to cater for some legacy AGS design oddities (like having room co-ordinates that operate at different resolutions). I've jotted out a few designs for designs for things like Expressions & Extension Methods so they should be getting rolled out over the coming months.

iPhone Support

Apple's T&C's for iPhone/iPod Touch firmware v4 (I do find it quite odious that they charge for firmware updates!) include the following:

Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited.

Sadly, this would appear to rule out developers ever using things like Flash-to-iPhone compilers, MonoXna and MonoTouch. Consequently, it is now looking very unlikely that XAGE will ever support the iPhone. Bah.

On a happier note, Silverlight v4 should be released in a few days so Awakener will shortly be getting an update.