Terrarium for Vista, whoops…

My bad. I don’t run Vista. Really. I don’t like it, it’s glacially slow, and doesn’t give me anything as a developer (except more flashy looking Explorer screens and maybe a Start menu I can search). So I’m an XP boy, however that was a bad mistake on my part with the release of Terrarium.

Vista users were getting an exception message and it was pretty quick to see that it was a DirectX problem. The problem was a) Vista doesn’t support DirectX 7 which Terrarium requires and b) Bil is an idiot for not thinking about this. Again, my bad and I apologize.

So first off there’s a quick fix (which I can’t test myself, but according to comments on Scott’s blog it works).

  1. Find an XP machine and grab the following older DirectX DLLs:
  2. d3drm.dll
    dx7vb.dll
    dx8vb.dll

  3. Run regsvr32.exe against the dx7vb.dll and dx8vb.dll
  4. Drop everything in the %SYSDIR%\system32 folder

That should fix you up in the interim. Unfortunately I cannot redistribute the files to you as they’re MS property and all that jazz.

For longer term, I’m ripping out the DirectX COM calls (which are actually wrappers to wrappers) that are in the current codebase and calling the DirectX managed ones provided in DirectX 9. This will probably result in not only a more readable codebase (and one that works on Vista) but it might even gain a little performance along the way.

The managed DirectX classes Microsoft provides in DirectX 9 are pretty nice and rather than a bevy of cryptic constants, enums and ref objects everywhere they’re all wrapped up in a nice OO-like package for you.

For example here’s the old DX7 code (ugly COM and DirectX goo):

   1: /// <summary>
   2: ///  Determines if the surface is in video memory
   3: ///  or system memory.
   4: /// </summary>
   5: public bool InVideo
   6: {
   7:     get
   8:     {
   9:         if (surface != null)
  10:         {
  11:             DDSCAPS2 ddsc = new DDSCAPS2();
  12:             surface.GetCaps(ref ddsc);
  13:             if ((ddsc.lCaps & CONST_DDSURFACECAPSFLAGS.DDSCAPS_VIDEOMEMORY) > 0)
  14:             {
  15:                 return true;
  16:             }
  17:         }
  18:         return false;
  19:     }
  20: }

As with most DirectX code you come across, it’s rather cryptic and ugly. Here’s what this method will look like after the conversion to use the DirectX managed classes:

   1: public bool InVideo
   2: {
   3:     get
   4:     {
   5:         if (surface != null)
   6:         {
   7:             SurfaceCaps ddsc = surface.SurfaceDescription.SurfaceCaps;
   8:             return ddsc.VideoMemory;
   9:         }
  10:         return false;
  11:     }
  12: }

Much nicer and more readable (well, as readable as DirectX code can ever be).

In any case, this is a better place to be but it’ll be awhile before I can commit all this work (and I’m flying without unit tests which is killing me here). I’m now re-living my past life when I knew what DDSCAPS_VIDEOMEMORY was (and regretting it as it all comes flashing back to me now). This probably won’t get us much closer to an XNA implementation of Terrarium but it’ll cause me to pull out less of my hair when we do (I think).

This fix will be in a 2.1 release that I’ll pump out when I get back from vanishing into the backwoods of British Columbia next week (sorry, but we geeks do need our downtime once in awhile).

I really need to sit down with Kyle Baley and Donald Belcham at ALT.NET Canada and have a few beers over this Brownfield effort for sure.

6 Comments

  • BTW: You can run on x64 machines just fine if you change your compiler options (Project Properties) from “AnyCPU” to x86. Then it’ll just work.

  • Man, I'm so there. This looks awesome and the only thing that is stopping me from joining up is my lackluster contributions to TreeSurgeon.

  • So, given that this is a 2D engine, how high up on the list is a migration to WPF? ;)

    Serious question moment (as if that last one wasn't serious. ;) ):

    Though I wanted to mess with Terrarium way back in the early days, I never really was able to set aside the time to. I don't exactly have time now either, but this resurgence is definitely piquing my interest all over again. I've never had a chance to look at the client code, and am curious how tightly its presentation-specifics are wound into the rest of the client logic. Can anyone who has looked into it post up something brief about how twisty the client is?

    PS - I wonder how much Terrarium is going to take over alt.net Canada next month. :)

  • @Jeremy: WPF isn't high on the priority list but might make the client a little nicer looking (I know, low value).

    The client code isn't fabulous and there are some narly parts. There's a lot of request/response stuff in there and using a supervising controller and applying a MVP pattern to it would go far.

    Hopefully we can get something more testable because right now I hate having to make changes since there's no safety net.

    Hey, if someone wants to talk about Terrarium at ALT.NET Canada I'll be there!

  • @Bil - Thanks for touching base on the state of the code. I'm certainly not expert enough with WPF to jump in and say "I'll take care of that." but it does interest me from more than just the "nicer looking" perspective. To even get to the point where one could replace the DX UI the client code would need to be factored well enough to separate out presentation, and that refactoring would help address a tonne of other issues also, including the testability that you mention. It wouldn't address it all on its own, of course ;), but every bit helps.

    It'll be interesting to see how much interest can be generated around Terrarium. Bringing it up to date with all of the latest in .net tech and alt.net style would be a pretty cool thing to see happen, and perhaps even to help out a bit.

    I'd love to help out a lot, in fact, as I honestly haven't been giving enough back to the community in recent years, but it always seems like I have too much on my plate and too many ideas in the backlog as it is. :( We'll see.

    In any case, if you, Kyle, Donald, etc. end up chatting about it during some part of alt.net Canada, I'd love to at least be a fly on the wall for it.

  • @Jeremy: Thanks for the comments. The UI is all WinForms except there are DirectX wrappers that provide DX paint surfaces to paint the world screen. Everything else is GDI+ so you could change just the WinForms code to WPF and not touch the DirectX (or alternately, replace the DX code with XNA calls which you could bake into WinForms then later move it to WPF).

Comments have been disabled for this content.