Archive for the ‘Programming’ Category

Geesh haven’t updated this blog in a while. I’ll do this mini update at least..

Took a new job at opencandy (some really cool stuff in the pipeline there!), still pushing out DJ mixes here and there over at my soundcloud page (caustik’s sound cloud). Create a soundcloud account if you haven’t got one already and make sure to add me =)

Every once in a while I’ve been working a bit on this app that lets you create sprites that can walk around your desktop and interact with your windows and each other. Here’s a little screenshot. It’d be cool to talk with some of the guys who run sprite repository web sites and get a bunch of characters created =)

Here’s the latest build. Just drag and drop an .spr file or any image file on the executable and it should drop on your desktop. You can drag and throw them around, and you can click the sprite/image and press left/right/up/down/space to move it around. It’s fairly basic right now, but the plan is to make them able to walk around by themselves and interact more, etc.

Share this :

There’s a pretty annoying issue that happens in windows when you are playing a game in fullscreen on one monitor, and have a second (or third, fourth) monitor with other stuff open on it. If your game is playing at a resolution that is different than your normal desktop resolution on that monitor, everything gets all moved around on the other monitors.

To fix this, I wrote a tiny utility program which you can run before you start the game, and it fixes this behavior by calculating what the correct location should be for all your windows and moving them there. It’s useful if you like having IM windows open, notes or a web browser, etc. You can’t interact with those programs while you’re in the game, but at least you can *see* them (for example, if you have a strategy guide or map, etc open)

Of course, I’m not responsible for any damage this program does to your computer. I’ve tested it a fair amount, but it’s entirely possible somebody with an unusual setup could find a situation where you may lose a program’s window due to it being positioned in the wrong place.

Let me know if this is useful, I’ll try to improve it and turn it into a proper project.

Probably the single most impactful epiphony I’ve had in my years of programming in C/C++ is discovering the ability to provide explicit scope inside a function. For snippets of code that are conceptually self-contained, but only used once in the program, they improve readability, provide optimization hints to the compiler, and are just kind of cool =)

Here’s some “before” code, like you’d expect to see throughout C source code:

What this has accomplished is your eyes immediately see that “do something” and “do something” else
are functional blocks, which you can quickly read as independent units. In addition, you can very
easily tell that the function simply “does something”, then “does something else”, then returns the result.

Each functional block has it’s variables declared only inside it’s explicit scope. So you don’t have this huge block of declarations at the top of your function, making things much easier to read. Also, the compiler now knows without ambiguity which variables are used where, which can help optimize it’s memory usage (e.g. it can re-use stack space instead of reserving it all at the top).

To me, the difference is night and day – and this is only a really simple example. Try it out on some
more complex code, and watch your code quality/readability improve. This works in both C and C++, it’s
particularly great for C since you normally are forced to declare your variables at the top of the function.
When you explicitly declare your scope, this is no longer the case! Really, C just makes you declare at the
start of {} blocks.

Since some folks have expressed interest in trying this bot for themselves, I decided to share the source code and binary

It’s not perfect, but you can tweak the source code (for example, changing how long rp_thread::sleep() is called, and where), and probably get some better performance. If you’re up for a challenge, you can also try to improve the code that decides on the next move! (if you do, it’d be great if you shared the changes!).

Typing this command will do something simple, but really nice. It will open an explorer window at the your current directory. Seems so simple and dumb, but when you tend to juggle a lot of explorer windows, and tend to use cygwin frequently, this is a nice way to help speed things up!

Share this :

When you see this line of code in your source window, how does your brain read it?

My brain says “There’s a hex number, with a couple of 1’s in it.”

Guess what? WRONG. It has one ‘1’. The end character is a secret hidden lowercase “L”. Thanks, Microsoft. Lucida console has literally a one pixel difference between it’s ‘1’ and ‘l’, which is fairly typical. These things are speckled all over mmsystem.h. Personally I never use ‘L’ at the end of a hex digit, and if I was feeling clinically insane enough to do it, I’d at least use a capital ‘L’.

Share this :

There was some amount of activity in a private branch in the Cxbx project recently..

I have been talking to a developer, Martin, who has spent some of his extra time fiddling with Cxbx. He was able to get some teaser screenshots from Battlestar Galactica. The game displays the menu, and even some in-game. I won’t get into too many details, but here are a couple screenshots.

I have not started to work on Cxbx on a regular basis — but I think this progress is very motivating, and it is tempting me to boot back up my development setup and take another look after a very long absence.

Many thanks to Martin for the contributions and for allowing me to post about his progress. Cheers.

I have had the pleasure of writing a pretty large number of apps for Windows. There are a few things that I have learned, over time, that have really helped to improve my productivity. One of those things is a basic debug console.

Typically, a debug console is handy – go figure – while you’re debugging. Once you have a release quality build, you won’t want the debug console hanging around anymore.

This is one of those snippets of code that, while brutally simple, is rather non-obvious and most people don’t know of.

Basically this code, if debug trace preprocessor is set (add MYAPP_DEBUG_TRACE to your preprocessor settings), will allocate a nice little debug console window, change the title, set the font colors, and redirect standard output to the console.

This snippet of code can be added to any Win32 application, and gives you the instant capability to spit out oodles of delicious debugging data. Typically, I combine this method with something along these lines: