Monday, December 28, 2009

Well, just got back from seeing Avatar on the biggest movie screen in town and, well, yes, WOW!

***** Warning! Spoilers Below! *****

From a purely technical standpoint, I thought it was, as hyped, the best CGI movie yet.

Although I was disappointed with the previews shown earlier this year (it all looked a bit 'fake plastic blue' or something) the final product was somehow much more convincing.

I suspect this is mainly because you were bombarded with such a huge amount of gee wizziness that any cracks in the visuals were just lost in the flood, but I think there was also something else going on, and what I consider to be Avatars *real* achievement - the very convincing facial animation of the CGI actors.

This hugely helped 'sell' the characters as realistic entities, and not just CGI (erm) 'avatars' standing in for real actors. Granted, the characters aren't actually human, and if they had been it may not have worked so well. But they did successfully achieve a sense of realism I haven't seen yet in supposedly realistic CGI animation.

The 3D was fine, but not IMO particularly any better than, say, Up3D, and I still can't see myself being happy with having to watch ALL movies in 3D!

Finally, the scenery was stunning, surprisingly New Zeland-ish in fact with what look like plenty of ferns and 'koru's all over the place, and was teeming with plenty of imaginative and quite beautiful animals and plants.

As for the actual story, I actually enjoyed the first half of the movie immensely.

The story gets stuck in right from the outset, and before long our paraplegic hero has transferred into his brand new, 9 foot tall blue alien body and is hoofing it madly through the forest for the sheer hell of it.

It's an exciting, romantic moment, and the movie carries on in that spirit for quite a while. There's even a quite nicely pitched bit of human-alien romance in there which works surprisingly well.

But of course, this is an evil-humans vs virtuous-natives story, so the film has to eventually turn into a huge prolonged orgy of military violence - about an hours worth in fact.

At this point, the movie changes tone dramatically, and things start getting a bit weird. The virtuous-natives are apparently too stupid to save themselves without human help (there's some vague 'chosen one' device at work too) at which point it gets a bit (more) condescending.

But, the visuals remain strong, and the battles are pretty spectacular. It all manages to remain more or less entertaining right until the (pretty crappy) ending, although you feel like you've mostly lost touch with the characters by then.

A shame really. If this really is some kind of American Indian or Afghanistan allegory (as has been claimed) or something, I can think of far more interesting/subversive ways to end it. But hey, this is James Cameron, and he seems to be far more comfortable with characters who carry BIG SEXY guns - indeed, by the end even our hero has grabbed himself a gun and has ditched his wimpy bow and arrow/knife combo...

But bah, I liked the first half, didn't like the second - no doubt there are some people who think the opposite! A case of something for everyone, perhaps...

Saturday, December 19, 2009

Well, it's that time of year again - must be time for a Christmasy blog!

It's been an interesting if low key year, during which I managed to fail yet again to get anything substantial done, but still managed to learn a lot of things along the way.

The evolution of BlitzMax into a threaded language has been probably the most interesting/challenging thing I've done, and in particular the development of an entirely new garbage collector.

It's still not perfect though, as there are some 'pathological' situations which can still upset the GC. The solution to these problems is to make the GC 'generational', which basically means keeping track of 'old' and 'not so old' objects. Ouch.

This apparently requires the addition of nasty things called 'write barriers' - little bits of code that get called every time a pointer is written to a variable (reference counting actually involves a write barrier of sorts) . I have a feeling this can be achieved 'on the cheap' using virtual memory techniques though, and it's something I'll probably be looking into next year.

And the $64,000 question - what about 3D?

Well, the truth is, I just don't really feel that I have anything new or particularly clever to offer 3D wise right now - and haven't for a while. There are plenty of good 3d libraries out there these days (and many of them free!) and competing with them has just become more and more scary. I guess what I'm really after is some kind of dinky new approach or something that simplifies life the way Blitz3D did.

I could certainly do more to promote and support the 3rd party 3d modules for BlitzMax around these days though. My general suckiness at marketing etc issues not withstanding, I'll make an honest attempt to do something about this soon!

I'd also like to do something *I'd* use to write a game with, and to be honest my requirements for a 3D engine are pretty minimal. As much as I'd like to a do a bumpy/specularly extravaganza, the truth is I just don't have the resources to do it justice. In which case, why not do something simpler, faster etc that works on more hardware. I guess what I'm saying is, as with programming languages, my first priority is to do something I'd be comfortable using myself, and all this next-gen stuff creates a certain amount of tension in that respect.

But all power to guys like Josh Klint and his leadwerks engine which requires a reasonably high spec - they're definitely pulling the technology in a good direction as opposed to, say, Intel and their craptacular graphics cards. Honestly, we'd have been better off with GeForce 4's!

Gaming wise, I've actually had something of a gaming renaissance in 2009, although this is probably more down to my being a bit more open to trying new gaming 'forms' than any resurgence on the industries part.

I have thoroughly enjoyed games such as Mirror's Edge, Infamous, Arkham Asylum, and esp. Uncharted 2 and kind of feel that gaming is heading in interesting directions these days.

Many of these games feel almost 'mini-game-ish' in nature, with set pieces sort of strung together by sequences of 'actual game'. The 'actual game' bits can sometimes get a bit monotonous, often consisting of 'wack a mole' style combat, but the set pieces are usually very cool - certainly cool enough to keep me playing for the next one!

Mirrors edge really stuck out for me though. The actual game bit basically consists of running very fast from point A to point B - and it works really well! Keeping your speed up is key, and do so allows you to run up walls and jump over huge gaps without it all feeling too silly/impossible. But I feel it's let down a bit by having too many restart points, which basically allows you to get lazy as you can always just try again. IMO, they should have made the levels a little easier, but with fewer restart points. It would've made for the same overall difficulty, but have given it all a little more tension.

I'm also very much looking forward to 'Demons Souls':

http://www.youtube.com/watch?v=VT89mvjxudk

Not available in stores here in NZ (why?) but I've got it ordered and it should be here next week. Good too see developers being brave enough to make a game *hard* again!

Anime-wise, I must confess to having watched a lot of 'high school romance' style Anime lately. In particular, I find the Anime adaptations of the Japanese 'girl games' by Key Visual Arts (haven't played the games...though they're apparently quite raunchy!) really entertaining. Not quite sure why, perhaps because there's usually an element of the supernatural in there or something, but they're definitely skilled at building up characters and manipulating the viewers emotions.

But 'Death Note' was probably the Anime highlight of 2009 for me. A simple premise - a guy discovers a note book that will magically kill off anyone whose name he writes in it - is taken in gloriously confusing directions. The amazing thing about the show is that despite the fact things keep getting more and more complex (the book has an apparently never ending set of rules governing its usage) you're never really lost by it all. There is the odd bit of exposition here and there, but overall it's just a brilliant bit of story telling.

Movie-wise, I didn't get to see all that many movies this year (too busy watching Anime and playing games!), but I did thoroughly enjoy Star Trek, Synecdoche New York and esp. Coraline.

The thing I always liked about Star Trek was the Kirk/Spock dynamic, and I felt the movie kept this intact very nicely. Yes, it was a bit of an incoherent mess ('racist' Vulcans? Surely racism is not logical!), had too many lens flares (Well, I liked them!) and featured probably the biggest god machine coincidence in living memory (Kirk AND future Spock AND Scotty all accidentally stranded on the same minor planet?!?) but I thought the actors caught the essence of the original characters just fine.

Synecdoche New York is probably a bit of an old farts movie, concentrating as it does mostly on death and 'what have I done with my life' issues, but it's also funny, wildly imaginative and thought provoking. The main character builds a 'miniature' of his world inside a huge warehouse, and after a while what's real and what's 'acted' becomes blurred. And, of course, the ending is killer...

Coraline is...awesome. A bit goth, but if you can handle that, see it!

Music-wise...is it just me, or was 2009 a bit of a loss? Waiting for someone to kick things into gear again...

Coolest moment of 2009: Obama getting elected.

Bummer moment of 2009: Obama's Nobel peace prize acceptance speech.

Anyway, getting WAY off track. Have an excellent 2010 and code the good code!

Thursday, October 1, 2009

Just picked this up last week and…Woohoo! What a cool little (big) game!

Yes, I'm a year behind the times, but I didn't actually expect to like it at all given that: a) I've never found physics based puzzle games all that fun, and b) I'd seen it an expo when it first came out and thought it looked pretty ugly.

But now that it's hit the bargain bins, I decided to give it a blast, and I'm very glad I did.

First impressions: It's a very 'English' game: the voice-over is very similar to that used in Hitch-hikers-guide-to-the-galaxy, and I think I even recognized some music from the excellent 70's TV show 'Vision-On' in there. It's actually nice to see a game 'projecting' personality like this.

Second impressions: It's simple, but fun. There is a lot of variety in the environments/graphics, and the designers have managed to come up with a very impressive number of ways to reuse the physics elements - yet they haven't 'overcooked' the puzzles: they're generally short and to the point.

Third impressions: I was totally wrong about the graphics, they're excellent! I think I may have been put off a little by the 'sack doll' player character. In default mode, he looks a little too much like the 'maggot monster' in 'nightmare before Halloween' for my liking - just a little bit creepy. But he does grow on you and you can customize him massively (I'm currently in soothing magical girl mode!). Ultimately, I think the realistic graphics complement the realistic physics beautifully.

Fourth impressions (about a week later): It's still simple, but still fun! OK, I've probably only put 5 or 6 hours into it so far, but that's damned good for me!

Minor grumbles: A fraction too much inertia on the player for my liking; sometimes you can't see where you'd like to and there's no manual camera (although 'leaps of faith' are seldom punished); while it's primarily a 2D game, there are in fact 3 'layers', and it can sometimes be hard to work out which layer you're on - worse, the game sometimes automatically moves you to a different layer, every now and then with fatal results (but this is probably worth it, as it also increases the speed at which you can whizz around levels).

I haven't played around much with the game creation stuff yet, but it looks pretty impressive and was apparently used to create ALL the in game levels. The online user maps are less impressive, but again I haven't looked too closely at these. More later…

Monday, September 14, 2009

One of the things I was determined to implement in BlitzMax right from the start was a decent 'register allocator'.

Register allocation is the process of mapping 'local' program variables (i.e. those variables declared 'Local' in BlitzMax) to CPU registers (i.e. the finite set of 'variables' inside the actual x86 CPU).

Blitz3D and BlitzPlus largely ignored this. Instead, all local variables were simply stored in memory (on the stack), and loaded into CPU registers as required. For example, Blitz3D code like this…

Local x,y,sumx=1y=2sum=x+y

…would involve approximately the following steps:

1) Write the constant '1' into the memory location for variable 'x'.2) Write the constant '2' into the memory location for variable 'y'.3) Read the variables 'x' and 'y' from memory and add them together.4) Store the result into the memory location for variable 'sum'.

That's 2 reads and 3 writes from/to system memory, and system memory is generally slow (even with fancy caches) when compared with the CPU (but I guess it'll be catching up soon…).

BlitzMax on the other hand will try to represent the variables x,y and sum using CPU registers, so equivalent BlitzMax code might involve something like…

And, happily, this time at least, theory matches practice - BlitzMax code runs significantly faster than equivalent Blitz3D code in general, and this is almost completely due to BlitzMax's register allocator.

There is, however, one fairly major drawback to writing a register allocator - it's *@#!$^& hard! ESPECIALLY on the crappy Intel X86 which has only about 8 general purpose registers.

In particular, the trickiest thing to deal with is 'spillage' - handling the situation where there just aren't enough CPU registers to go round and some local variables MUST be 'spilled' to memory.

In this case, a spilled variable ends up behaving much like a Blitz3D/BlitzPlus variable above does - it must be constantly loaded/stored from/to memory. Therefore, the most important job of the register allocator becomes minimizing the number of spilt variables.

This is tricky because it can be hard to know precisely what effect spilling a variable will have. Spilling a variable may even cause a 'cascade' of more spills, because even though a spilled variable is stored in memory, it still needs to be moved into a CPU register at SOME point to be used for anything useful (e.g. arithmetic, memory addressing etc)!

And every now and then, someone will come up with a little piece of code in BlitzMax that causes this effect. The code will usually be small, involve about 8 or so local variables and will cause the compiler to lock up completely as the register allocator gets caught in an endless allocate/spill/allocate/spill loop...

In fact, it happened again just yesterday - hence this post!

I *think* I have it sorted now, but to be honest I seriously doubt I'll ever be able to say with 100% confidence that I know it works!

Saturday, September 5, 2009

As a software developer, I'm pretty much required to upgrade my OS's whenever the latest/greatest OS comes out. However, as a bit of an old fart, it has definitely become less a less of a thrilling experience!

The worst software upgrade experience was easily Vista. No doubt, as an early adopter, I encountered many of it's teething problems earlier than others. But these were pretty major, including: terrible support for non-MS networks; incredibly slow file management; generally dodgy network behaviour (LOTS of network timeouts); and an incredibly 'random' (if more attractive) GUI.

Some of these issues were resolved via various registry hacks, and no doubt service packs improved things, but I only lasted a few months on Vista before reverting to XP as my 'main' OS. And that is the first time I have *ever* gone backwards OS wise. I suspect Windows 7 will be better - but for the love of god, if it doesn't have a 'make all windows look like this' button I'm gonna go Joe 90 on someone!

But before all this makes me sound like too much of a Microsoft hater (I only hate them a *little* bit, honest!) I would like to stress that my favourite OS of all time is easily Windows 2000.

Perhaps it was the timing, perhaps I'd spent too long on the Win95 line, but I really, really liked Win2K: It was small, it was fast, it was stable and it was no-nonsense: All the 'options' dialogs were presented as nice tidy consistent 'key/property' dialog thingys. It rocked, and at the time I was looking forward to more of the same.

Unfortunately, I think Microsoft failed to realize they were onto a good thing, and decided instead to 'ape' the Mac: The next release was XP, with big ugly buttons and unnecessarily dumbed down dialogs, and then Vista with the window renderer. I guess they had too though...

I like the Mac, but I don't use it as my primary development machine - there are too many little annoying things about it: No 'up a folder' browse button; no full path name in browser window title bar; no ability to mess with 'hidden' files (ie: files starting with '.' - you can hack the OS to show them, but you can't modify them) - and more. Of course, at this point you're supposed to use the command shell (and the Mac shell is unix-grunty...) but stuff that - I'm a child of the GUI generation! I don't like the shell!

Which brings us to Snow Leopard, the latest MacOS update. It is apparently faster; you can apparently do 'Microsoft exchangey' things with it; and it only cost 60NZD, BUT: For what I use a computer for, there is absolutely no difference whatsoever!

And frankly, I'm disappointed - hell, if they'd forced a new desktop wallpaper on me I might even feel a bit better! From Apple, I'm a little surprised: 10.4 had the spotlight feature added (which would have required serious hacking of the file system) and 10.5 had the clever time machine feature (ditto), but 10.6...?

But perhaps I'm being a bit harsh - OS development and maintenance costs, and perhaps it's more honest of Apple to release a cheap 'tweak' update than try to pretend it's something new.

All in all though, it definitely feels like OS development (not counting sexy windows) is moving sideways much more than it's moving fowards. Perhaps we've exhausted the UNIX paradigm? Perhaps (gulp) there's nothing better?

Whatever - it's been a LONG time since I've been excited about OS technology. Which is a bit of a bummmer.

I am, howver, very much looking forward to whatever google do with Chrome...

Wednesday, September 2, 2009

Ok, a few random comments on the history and design of BlitzMax's garbage collection system - probably not for the faint of heart...

The GC system is BlitzMax has actually gone through several iterations by now. The first was, ahem, a little rough. It was basically a reference counting system that required the programmer to manually call a 'FlushMem' command every now and then. Worse than that, they couldn't just hide the FlushMem in a function somewhere, it had to be in the right place 'on the stack' as it couldn't 'flush' anything higher up the stack.

Yes, users found it a little confusing!

But it worked, and I eventually managed to get rid of the need for FlushMem entirely. This is the GC BlitzMax has used for a long time now and it has one very cool thing going for it: it's *fast*!

However, it has 2 fairly serious disadvantages - it can't handle 'cycles' of objects (this is where a chunk of memory directly or indirectly points to itself - such memory can 'leak') and it doesn't work nicely with multithreading. And EVERYONE wants multithreading these days, right?

So I decided it was time to implement a 'real' garbage collector - one that could handle both cycles and threading.

Fortunately, thanks to the wonders of open source software, there is an excellent GC available that is *almost* perfect for BlitzMax: the 'Boehm-Demers-Weiser' (BDWGC) conservative garbage collector:

http://www.hpl.hp.com/personal/Hans_Boehm/gc/

This is already in use by many pieces of software, so is well tested, and is pretty easy to 'drop into' an existing project such as BlitzMax.

And, best of it all - it just works! By using this in your software, you can allocate memory and forget about it. It is one seriously cool piece of programming...

However, there were a few things I was a little uncomfortable with about it:

* BDWGC was designed to handle any old generic code, yet I 'know' stuff about BlitzMax code that they don't - surely I could use this knowledge to make the GC more efficient? One example: C/C++ etc code can often generate 'derived' pointers. This is where a pointer points 'into the middle' of an object, not at the beginning. However, with BlitzMax code you don't have to worry about derived pointers (not coincidentally due to changes I had to make to get rid of FlushMem way back!) so the code in BDWGC to 'validate' a pointer is unnecessarily complex.

* There appears to be a bug in BDWGC to do with 'cyclic finalizers' which can cause crashes or leaks. No doubt, this will be fixed eventually, but hey, it's open source so surely I can fix it myself? Unfortunately…

* The BDWGC code is pretty hard to follow. It's designed to run on about a gazillion versions of EVERY OS ever, has a ton of optional features and is 'macro-ed' up the wazoo. After a few hours trying to hunt down the cyclic finalizer problem, I realized I was out of my depth and gave up (Actually, this may have more to do with me - I kind of suck at reading other people's code...)

So, the last effort on the GC front has been to write a 'proper' cycle/threading friendly GC on my own (MSGC), that can take advantage of the way BlitzMax works - and the results are looking good!

So far, MSGC is faster than BDWGC (although not as much as I would like!) with everything we've tested it with and appears to be very stable (although I'm sure the upcoming public release will change that).

It's been a pretty interesting experience writing it too, and I'll go into some of the details in a future posting, but that's probably enough for now.

Monday, August 31, 2009

I am Mark Sibly, computer coder extraordinaire, currently located in West Auckland, New Zealand. I'm a big fan of blogs - well, the interesting ones anyway - so thought it was time to start my own.

Actually, I did have a blog for a long time - before blogs were cool no less! - but it was located on my 'commercial' site and I ended up being uncomfortable with the professional vs personal issues that arose - eg: customer: "but you said you'd do this!"; me: "hey, I was just thinking out loud!".

Hopefully, blogging in the googlesphere will reinforce the point that none of this is to be taken too seriously, and that my thoughts, plans and opinions are highly subject to change.

A bit about me:

* I became interested in computers at around age 10 (1977 - Star Wars year!) when I discovered a TRS-80 complete with an awesome "How to program in BASIC" manual while going into work with dad one Saturday. Been hooked ever since...

* I did a bunch of games on the Vic-20, Apple2, C64 and Amiga. Some I even sold for actual money! Then things got all 'serious' with the PC and the gaming side of things sort of petered out.

* Since then, I've mostly been involved in writing 'game oriented BASIC compilers' for the PC - BlitzBasic, Blitz3D, BlitzPlus, BlitzMax...yes, I like the word 'blitz'!

* I'm a capitalist at heart, in-so-far as I believe that everyone should be able to make a living at what they're good at. However, I strongly believe this has to be balanced against a 'public good': It's not always the 'best' product that wins in the end, and just because someone is making oodles of money out of something doesn't mean 'everyone wins'.

* I *love* music. In my teens and twenties, I put considerable effort into mastering the guitar. It didn't quite work out, but I had a blast playing in several bands along the way and still like to tootle around. Current bands of choice include TV On the Radio, DeerHunter, Marnie Stern (yeah!)...

* I also *sort of* love games - by 'sort of', I mean that I'm incredibly picky when it comes to games. I'll happily buy any Nintendo machine purely to play the accompanying Mario and Zelda releases (which means I end up playing approx 500NZD a pop for those games - but it's worth it IMO), but FPS's and anything remotely resembling an RTS or RPG just leave me cold. My loss no doubt - I'd certainly like to be able to enjoy a greater range of games - but in my mind there is just this HUGE gulf between the (serious) games Shigeru Miyamoto produces and everything else. In fact, I find it kind of alarming to see Nintendo pursuing this whole 'casual gamer' thing these days...

* I have also recently become something of an Anime junky. For people of, ahem, 'my generation', this may require an explanation/definition. Anime simply means 'Japanese animation'. It's not a genre or a philosophy or anything, it's simply a technique: animation. Therefore, to put it more precisely, I have recently become somewhat addicted to Japanese entertainment, which happens to frequently present itself in animated form. Actually, I suspect the main reason for this is budgetry - a voice actor is much cheaper than a real actor. But this just ends up being liberating for the creators - you don't need a mega budget to produce an awesome story via Manga/Anime, just a GOOD IDEA!

* I like writing and would love to one day write some fiction, but years of writing technical documentation for various compilers etc have left me a bit drained...hopefully, this blog will get me back in the swing of writing.

Anyway, that's enough for now. Future blogs are likely to be highly technical as I mainly plan to use this blog to share my experiences as a software developer, but I hope to throw in an anime/movie/album 'review' here and there.