Archive for July, 2009

More Basement Progress

drywall-repair-oops[1]The drywallers have been doing their thing for the past few days, and the basement room is looking much more like a room now.  They’ve successfully hidden my ductwork and finished up on Monday, so we’ll do trimwork this week and then we should be in good shape!

Unfortunately, they left dust all over the basement in a nice, thick layer, so we’ll have to clean that up.  They also walked off with my power bar, and almost got my extension cord and work light, but I managed to salvage them.

I must say that the drywall looks great; clean and smooth, with nice straight junction lines.  I’ll be very interested to see how everything looks once we get the electrical and trim done.

The Power-Hungry Beast

P1010530I would like to introduce my new video card, a Sapphire Radeon 4870 with 1GB.  I wish I could tell you that it was running in my machine, but it isn’t.  Not for lack of trying; I did manage to wedge it into my case last night (a tight fit), but then discovered the Achilles’ Heel of the Dell XPS 435.  The card takes two 6-pin power inputs.  My power supply provides one.

So I stared at the card for a few minutes, cursed under my breath, and reluctantly RMA-ed the card and ordered a slightly less beefy card that only requires one power plug.  Problem solved, even if I wasn’t quite as happy about it.

But then I came in this morning and talked to Matt Funk about it, and he suggested using a power cable splitter.  After some investigation, I discovered several different types of splitter and converter cables that are available.  Since I have several SATA- and IDE-type cables free, I’ll just convert one of those over to 6-pin and I should be good to go.

So the RMA is ignored, the new order cancelled, and my mood is substantially improved.  I’ll let you know if a successful installation makes that more permanent or not.

Tags: ,

Visiting Nebraska

fan_cornhead[1]We’re travelling up to Nebraska this weekend to visit my folks, so there will be no post on Sunday.  We’re going to be doing a round of birthday parties for my brother’s kids while we’re there, so there should be some fun lake pictures when we get back.

Have a good weekend!

Tags: , ,

The Meaning of “Scratch and Dent”

New Computer 003There’s the blemish on my new computer.  Right there.  No, there.  See it?  It’s the tiny little mar on the finish on the top of the case.  I looked over the whole rest of the thing and I cannot find another defect.  That one blemish is what Dell knocked $100 off the price of this machine for.

Not that I’m complaining!  I got it hooked up last night, and although I don’t have time to really get it configured the way I like it, I can tell that it’s going to be a great machine.

Except for that darned spot.  I don’t know; I may need to send it back to the factory.  I’m just not sure I can deal with the hideous  deformity on this otherwise pristine machine.

Tags:

Type-Safe Message Passing in Win32/MFC — Part 1: The Problem

Statshot-Top-Safety[1]This is the first in what should be a series of  posts about a problem I’m addressing at work.

I work on an application that is fairly old; it’s grown through accretion over the past decade.  There have been a few architectural revolutions during the process of development, but the code is still very much the Visual Studio 6-based C++ MFC application it started as.

One of the areas where we’ve made progress in the past year or so is in the introduction of smart pointers, specifically boost::shared_ptr<>.  When we upgraded to Visual Studio 2005, which has a fully standards-compliant compiler engine, we suddenly gained access to a number of modern C++ libraries, including Boost.  One of the best modules available in Boost is the smart pointer one, and the “best” (most generally useful) smart pointer in that module is boost::shared_ptr<>.

I won’t bore you with the details, but shared_ptr — a “reference-counted smart pointer” — allows you to almost completely rid yourself of the headaches of manual memory management in C++.  It wraps raw pointers in such a way that you can pass them around freely, like any other first-class object in the system, and internal logic in the shared_ptr object will track the number of references for you.  When there are no references left (all copies of the owned pointer have gone out of scope or been otherwise decomissioned) it will automatically delete the wrapped pointer.

The upshot is that this is great behavior, and very useful to us.  We’ve put them in everywhere we could do so easily, and reaped the benefits of stability by doing so.  We’d like to use them in other places, but unfortunately our architecture heavily leverages the standard Windows messaging system.

Invented for Windows 3.1 (or possibly earlier; I’m not familiar with pre-3.1 Windows) way back in the Dark Ages, the Windows messaging system is a way to modularize applications by providing a generic messaging interface.

You make calls by calling PostMessage() or SendMessage() and providing the window handle of your target, the message code you want to send, and a couple of generic parameters that carry information about what you are trying to do.  The calls look like:

LRESULT ret = ::SendMessage(hWnd, WM_MESSAGE, p1, p2);

There is then code on the receiving side that retrieves these messages and dispatches them to the appropriate handler function with the provided parameters. Voila, instant decoupled function call!

This is all great, as far as it goes.  Where the problem comes in is with the parameters.  These (in Win32) are 32-bit integers, and if what you want to send is too large to fit in two 32-bit integers you need to pass the address of the object you want to access as one of the parameters.  Once you’ve done that, you are faced with a number of problems:

  1. How do you ensure the receiver treats the pointer you’ve sent as an object of the correct type?
  2. How do you know whether or not the receiver should delete the object’s pointer after it’s done using it?
  3. How do you even know (in the case of PostMessage) that the object will even be valid by the time the receiver gets around to using it?

All of these are major issues, and unfortunately all of them are easy to get wrong and there’s no way to tell until your code hits a problem and explodes.  There are better message-passing schemes that have been invented more recently (such as signal/slot, etc.) but completely replumbing our application to support these is not an option.  We’re stuck with Windows messaging.

It would be really nice to use smart pointers for these types of calls though, wouldn’t it?  If we could properly use shared_ptr, that would eliminate issues 2 and 3.  And it would be nice to add some compile-time type safety as well to eliminate issue 1.  If you could do this, you’d have a way to pass typed arguments via the Windows messaging system without worrying about memory allocation or ownership issues, and if you made an object typing mistake, the compiler would inform you about it right away, rather than letting your users inform the customer service desk.

This is the problem I’m trying to solve.  More to come!

Update:  I may need to defer writing any more on this until I find out whether my magazine article submissions are accepted or not.  They won’t accept material that’s been previously published, even online.  I’ll keep you informed.

Tags: , ,

IFComp Update #5

writing[1]I finally got a couple hours to work on my IFComp game entry, and made some decent progress.  Of course, what it really did was to emphasize to me how much more work I need to devote to this to actually finish, let alone make it a quality product.

This week I implemented the remainder of the opening scene — well, 95% of it at least.  There’s one more transition I need to do before I can start work on the second scene.  And I’m not counting the very large amount of polish that will be required in order to make it feel clean and fleshed-out.

The significant technical progress this week included implementing a timer, as well as introducing a character (the protagonist’s father) that you can actually have a (very basic) conversation with.  I know this doesn’t sound like much, and really it’s not, but every one of these small milestones helps refine my mental model of the language and speeds me up.  I already feel like I’m making faster progress than I have in my previous efforts, and the code is cleaner and easier to maintain.

As far as the characters go, there’s no way I’m going to be able to make the conversation model as detailed as in Alabaster, but I am impressed at how easy it is to get a basic conversation wired up for a character.  And there will be an in-game reason why the conversations are short and restricted in nature, so my lack of an encyclopedic list of conversational topics shouldn’t cause too many problems.

More next week!  If I can grab some more time to work on it, I should have more substantial progress.

New Computer

dell_tat[1]It’s been 6 years since the last primary computer I bought (a Dell XPS P4) and I finally decided it was time for an upgrade, due to finally falling behind the minimum specs for some of the games coming out lately.  I’d also like to install some of Microsoft’s more modern .NET development tools, and I’d like Windows 7 and a decent system to do that with.

Since I’ve had very good luck with Dell over the years, I did what I did last time and went out to their “Dell Outlet” site, where they sell their refurbished and scratch-and-dent machines.

I was forearmed with price-performance information, and knew that I wanted an Intel Core i7-920 processor, which gives outstanding performance for the money.  I was flexible on RAM but wanted at least 4 GB, hard drive space was inconsequential, and I wanted at least a Radeon 4850 graphics card.  I was expecting to pay around $1000.

What I found after a bit of poking around was an i7-920 system with 6 GB of RAM, a moderate hard drive, and a crappy $20 video card.  It was marked as “Scratch and Dent” and cost $630.  It also comes preloaded with Vista, with a coupon for a Windows 7 upgrade when that is released.  And free shipping!

$630!  I figured I could buy the system, ditch the original video card and buy a 4850 or 4870 to put in, and still get away at under $800!

I was at work at the time and called a couple of friends over to look at the amazing deal, then clicked on the button to put it in my shopping cart.  Oops.  “System is no longer available.”

In the 30 seconds I spent talking up the deal to my co-workers, it had been snapped up by someone else.  Luckily, I knew that the deal at that Dell Outlet website is that if you don’t buy in 15 minutes, the system is returned to the list.  I clicked the “refresh” button a few hundred times over that 15 minutes, and lo and behold it finally appeared again!  This time I didn’t waste any time crowing over it; I just grabbed it.

Now I just need to order my new video card…  If you have suggestions on what you think I should get, please let me know.

Tags:

Progress on Finishing the Basement

brazil_ducts[1]I’ve now completed the work I can do in the basement without more progress from my framing and drywall contractor.  I have all the electrical run, including a double switch setup to the main light and five outlets, wired to the original basement circuit (which was almost unused before this).

I’ve now also installed the ceiling air register, and all I can say is:  Thank God for duct tape.  Duct tape is so useful for everyday projects that I hadn’t realized what a lifesaver it is for HVAC projects.  Let’s just say that without the tape, and a quarter-gun of mastic, I’d have been spending more of Saturday in the basement than I did, and probably teaching Thomas new vocabulary at that.

The only things I have left to do before finishing are to run the cable from the existing drop to the new wall, which I can’t do until Tom reframes that wall to give me crawlspace access to the basement stairs, and possibly to install an air return register.  I haven’t decided whether I’m going to do this or not, but if I decide to do so the run is pretty short and easy, and there’s good access, so I can do it at any time before or after drywall.

No photos at the moment; I’ll take some when the drywall is up.

Tags:

Magic: The Gathering — Duels of the Planeswalkers

chuck-norris-magic-the-gathering-card[1]Years and years ago, I played the original collectible card game — a game called Magic:  The Gathering.  The game involves playing cards from a deck of cards you’ve constructed, each of which has different rules that interact in different ways, and attempting to defeat your opponent, who is trying to do the same thing with his or her customized deck.

It’s a fun, well-balanced game, but there are a number of drawbacks to actually playing it:

  1. It’s expensive.
  2. You can easily accumulate a ridiculous number of the cards.
  3. It’s hard to keep everything organized.
  4. Finding other players can be a problem.

I got around issue #1 back in the day by using “proxies”, or card images scanned from the Net and printed out on a color inkjet.  Combining the proxy with a cheap, common card in a plastic sleeve allowed my friends and I to experiment with a lot of deck configurations that we never would have been willing to spend real money for.

Even with proxies, however, you still ended up with large boxes full of cards and paraphenalia, and as time wore on, finding time to get together and play was more of an issue, so I eventually stopped.

For quite a while it’s been possible to play on your computer, either solo or online — there have been at least 3 different incarnations of Magic-based computer games over the years.  Now however, there’s a fourth:  Duels of the Planeswalkers.

DotP is a very nice, very polished product for folks that might like to play Magic but aren’t about to get sucked back into the whole CCG morass.  You can play quick hands against the computer with one of a number of preconstructed, unlockable decks.  They also have online play so you can take on your friends over XBox Live (which I have not yet done).  There are also challenge modes wherein you are presented with a game scenario and asked to win in one turn, which sounds pretty easy until you see the complexity of some of the setups.  There are new cards to unlock for each deck depending on how many battles you’ve won with it, so there’s a sense of progress as you progress through the campaign.  There are even multiplayer cooperative modes.

And finally, it’s gorgeous.  Every aspect of the UI design is well-done, from the original card art to the adjustable perspective on the board.  Even the loading screens, effects, and sounds are well-done and add a lot to the experience of playing the game.

For a $10 download on XBox Live, this game is a great value if you are interested in dipping (or re-dipping) your feet into the world of Magic.

Cool Plugin — WP-Syntax

nerd-cake[1]I hope to eventually have some more programming-related updates here; I’m working on a solution at work to add compile-time type-safety to Windows message passing that will make a good article (or two) when I’m done.

In the meantime, I have my IFComp updates, although vacation and the sheer number of other projects I have at home is cutting down on the amount of time I have to code in Inform 7.

What both these types of posts need, however, is a good way to format code.  By default, WordPress does not do a good job at all with code samples.  Luckily, however, there are a wide variety of plugins available to do a better job.  The one I chose is WP-Syntax, which leverages the GeSHi highlighter engine to do formatting syntax highlighting for a wide variety of languages.

None of these languages include Inform 7, but syntax highlighting wouldn’t really do much for Inform 7 anyway. For that language I’m just happy to have a nice box and a good font, which I get by default.

Here’s a (nonsensical) example for C++, to show off the highlighter features:

template <typename T, typename U>
class Complicated <T *, U> : public ComplicatedBase
{
public:
    Complicated(const CString &szData) 
    { 
        if (szData.IsEmpty())
        {
            m_szData = "Error";
        }
        else
            m_szData = szData;
    }
    virtual ~Complicated() { /*do nothing*/ }
    void SomeFunction() const;
private:
    CString m_szData;
};

…and another for SQL:

SELECT t1.a AS Name, t2.b AS Something_or_other
FROM Table_1 t1
    INNER JOIN Table_2 t2 ON t1.t1_ID = t2.t1_id
WHERE t1.c BETWEEN 4 AND 8
-- had a GROUP BY here...

Pretty cool, eh? The drawback is that the very nice visual editor in WordPress is not compatible with the formatter, but I can live with writing in raw HTML to get results this nice.

Tags: , , ,

The Quern is Digg proof thanks to caching by WP Super Cache