Tag Archives: Cursor Lock

Cursor Lock 2.0 and Power Supply failures

I’ve been wanting to rewrite one of my VB.Net programs over in C++ recently, just to force myself to learn the language better. Since there was no way in hell I was going to tackle any program with a graphical user interface, I chose the locking portion of my Multi-Monitor Cursor Lock to port. Looking over the code for a recent feature-request update, it seemed like most of the code involved Windows API function calls and data types, which are actually easier to implement than in VB (you just have to include windows.h).

Really, the two most difficult to learn fundamentals of C (having come from a VB/Java/PHP background) are character strings and pointers. Pointers really aren’t that bad once you learn how the operators work, but you still have to stop and think about any redirections: “& returns an address, * returns a value”. The problem with strings is that there are a million types of them and getting them to play nice requires all sorts of tricks; there’s character arrays, pointers to characters, constant version of both of those (which I still don’t really get–how can something return a constant?), string class, cstring class, wide characters, ANSI characters, Unicode characters, multi-byte characters. Since I wasn’t using MFC or ATL, I decided to stick with the string class, which could be initialized from character arrays or character pointers. And although its c_str() function returns a const char *, you can use strdup() or strcpy() to easily get a char *, which many API functions require.

After trudging through the code for parsing the command line switches in and reading default values, the code for the actual locking portion just kind of rolled out (being comprised almost completely of API calls). Doing the code was fun, but the benefits that I

news241

Testing Cursor Lock compatibility required me to install Win98 in VMWare.

saw during performance testing blew me away. I ran the VB.Net and C++ versions for two minutes at 20ms poll rate to see the CPU usage. .Net used 8.6 seconds of CPU time compared to C++’s .3 seconds: a 29 times performance increase! This test couldn’t have been more definitive as the algorithms were virtually the same; remember, I said the locking portion was mostly system calls. Then, I tested memory efficiency, which was also delightful but the difference was less dramatic: ~16,000KB to ~1,500KB (~10x less memory) or ~7,000KB to ~400KB (~17x less) using the SetProcessWorkingSetSize(hProc, -1, -1) trick–not too shabby. Also, without the .Net “Just-in-Time” compiling, the C++ version doesn’t have a two to three second start and close delay.

Happy with my results, I started working on new documentation for Cursor Lock 2.0, so I could submit to some download sites. It was about complete when I decided to turn in for the night on Saturday. As I laid in bed, nearly asleep, I heard the fans in my computer spinning down, the silence cutting through my subconscious. Peering over at the tower, I noticed the power light still on, which was even odder than the system randomly powering down. I went over and tried to restart, but it wouldn’t stay on long enough to even begin to news242POST and blue smoke smell had already permeated the room. The next morning, I smelled around the tower and found the culprit to be the power supply, as I suspected. After taking the PSU apart and dissecting it on the kitchen table, I found an interestingly charred transformer coil. When I plugged the PSU in and shorted the power-on pin, a spark leapt from aforementioned transformer to a plastic insulation divider. Upon further inspection, it appeared the divider had actually melted to the transformer.

Obviously, this power supply was dead beyond anything I could repair, so I ordered a new 500W Thermaltake PSU from Newegg. I tried to get one that I could still use whenever I finally get to upgrade my core system components; the key to this was in the 20+4-pin ATX main connector that allows you to break the newest 4 pins away from it. In retrospect, I had probably been overloading the old PSU for a while now, which was leading to some system instabilities when gaming. It was rated for 350W, but most wattage calculations I had done put my usage at slightly above that. Anyways, here’s some pics of the new power supply. I should have gotten one with it inside the case, but oh well…some other time.

Luckily, after that disaster, none of my other hardware had been fried (from an over-voltage or such), and I got to finish the documentation and polish of the new Cursor Lock. I submitted it to a few download sites, but it could be weeks before they get approved. What independent developer has $1000 for their premium services? Not to mention that there are thousand of good download sites on the web. Well, until it appears on other sites, the new version can be found right where it always was here.

Posted in Hardware, Programming | Tagged , , | Leave a comment

RoL Beta, Etc.

I forgot that I’d said I was gonna weigh in on the Rise of Legends beta sometime. Since it’s been about a month from the game going gold, I figured now was a good time to do so. But seeing as I haven’t touched the beta in two months (god damn you, Oblivion!), I decided to just paste something I’d posted on the beta forums. Joe Pishgar had asked us to post our first impressions on the game. My feelings are still pretty much unchanged now, but remember that this was still in beta (though the only difference between the beta and retail is performance and bugs):

I’m having a hard time getting into this game. Maybe it’s just that some days I’ll get 10 random crashes, my computer will lock, or my monitors will turn off, and other days (like today), I’ll get no crashing whatsoever. (Maybe it’s because I left steam open; I smell a conspiracy :P)

Or maybe it’s the fantasy setting. I loved RoN cause it had some sense of realism to it. I like the vinci units well enough; they’ve got a neat art style and nearly realistic feel. But now that I’ve gotten into the alin campaign, I feel a bit out of place. The alin units, buildings, spells, etc. don’t feel as natural and easy to grasp. Just the last scenario I played, I had to read all the alin tips to figure out how to transport units. Summoning winds to carry units? Is that inventive or just nutty? At least those tips are there.

Or maybe I just feel like I’ve played this game before. I know someone or everyone will want to disagree with me, but it feels just like playing Warcraft 3 with some RoN elements tacked on. But the RoN elements are the best part! I liked Warcraft 3 well enough, but I played it all of a month. I probably quit that because I got addicted to RoN.

So a lot of the scenarios are just the same dribble that is in most rts games. And I’ve begun dreading the scenarios where you only have to take all the enemy cities. I wanna rush and get it over with, but then I have to chase the AI around to every other neutral city on the map. My favorite part of the game right now is the strategic map. Spending the points gained after a scenario is as fun as leveling in an rpg. I also like how the player can use cards in the game. But I’m also missing some conventions of ron, like having multiple armies. Although, I understand that the maps are much smaller and can’t really support multiple armies. I haven’t tried the multiplayer or quick battles yet, but I’m hoping that’s more fun than the campaigns.

Basically, I just wanted Rise of Nations 2: a killer graphics engine, more campaigns, more random map gametypes, better modular mod support, etc. But this is another game altogether. You’ll probably lose some RoN fanatics like myself but gain players from a new audience.

I also forgot to mention last post that I did a demonstration video for my MultiMonitor Cursor Lock program. You can see that here. It shows the general concept plus how to quickly setup the shortcuts. I used DivX 6 for compression, my webcam and an older version of CamStudio for recording, and VirtualDubMod and Vegas Video 5 for editing. It’s about 4MB at 1 minute in length.

Posted in Gaming | Tagged , | Leave a comment

New apps and RoL beta

Website Fonts Finder

Website Fonts Finder

I’ve done a couple new apps recently. They’ve both been in the new-to-me .NET environment. The first one I made just to do it. It searches for instances of fonts in HTML code (either HTML, CSS, or script) using regular expressions and reports the findings through three lists.

Multimonitor Cursor Lock

Multimonitor Cursor Lock

The second app was born from necessity. I was tired of games not locking the mouse cursor into the current monitor, so I made a program to watch the selected app for focus and lock the cursor accordingly. This is obviously for multiple-monitor setups. It took about a week to code altogether but functions perfectly. It even has hotkeys to get you out of sticky situations. UltraMon can lock the mouse cursor to a certain monitor on hotkey press, but I knew I could do it better. My app locks the mouse cursor to whatever monitor the selected app is on automatically. It also locks it more efficiently by using the ClipCursor API function and checking to see if the app has focus or not. You can download both of these apps from my Apps page.

Also of interest is a recent Email that I received from Joe Pishgar, PR guy at Big Huge Games. He said that “several of [our programming team] outright insisted I do my best to get you into the Rise of Legends beta!”. Of course, it’s not like I’d say no to beta testing the “sequel” to Rise of Nations. I’m not sure when to expect my beta copy, but I suppose it should be within the next month by the way they’re hyping it now. Joe also mentioned that some of the programming team were quite impressed by my Script Maker for RoN.

Posted in Programming | Tagged , , , | Leave a comment