Owing to those recent problems that were doing my head in, I've spent the weekend doing my best (my lovely, lazy best) to come up with a viable solution.
Tonight I re-read a reply on the BlitzMax forums regarding the frame rate troubles I've been happen. At first, I had dismissed it as technical details that I wasn't willing to get into, especially when I simply don't have enough knowledge of how BlitzMax is actually working to dare get stuck into its guts and start changing variables.
Nevertheless, at a loss for a solution, I decided to give it a go.
The result was better than I could honestly have hoped.
Remember how the problem was this unwanted delay whilst trying to find out if a key or mouse button is being pressed? Well, tracing the path through the code from that simple KeyDown() function led me into the entrails that make up BlitzMax's innards, where I found the function PollSystem.
The offending function PollSystem.
What does it do? Well, allow me to put my whole heart into this biological analogy I've got going here.
Eating food is pretty simple, yeah? You chew, swallow, and it goes into your stomach, where your body does the rest. Your conscious job, unless you've just had a dodgy chip from the local eatery and are thus doomed to spend the next four hours renacting scenes from Platoon on the ceramic, is over.
Imagine, though, if that wasn't it. Imagine that every time your stomach wanted to do something with that disgustingly fatty yet absolutely deliciously greasy burger, it sent it back to your mouth. Asked you to chew again. And again. And again. Heck, never mind the burger, eating a fucking chip would take forever.
That is how PollSystem works. Or at least that's how it works to my admittedly incomplete knowledge. Every time I ask BlitzMax "is L being pressed?", it goes off and tries to read every single key again. This is just how it works.
On Windows, this is very, very fast. Negligible, in fact, unless you really wanted to make the absolute most of your time. We're talking... (I need a calculator for this) ..... one twenty-five-millionth. Is that a real number? 0.00000004 seconds. It's fucking fast.
On OS X, it's slower. I don't know if it's a bug with BlitzMax, a "quirk" (read fucking stupid flaw) of OS X, or anything, but it's one forty-thousandth in silly named numbers, or 0.0002496 if you want accuracy. That's 624 times slower.
So, what did I do? Well, I made BlitzMax chew its damn food before swallowing, that's what I did. By tweaking a single line, I stop it from calling PollSystem every time I check a key. The proviso is that I must do it myself, once per frame, to ensure that everything works. The result? OS X runs very fast indeed. My test came back telling me it ran six times faster than an untweaked Windows, but that's not a fair comparison for various technical reasons.
The thing eating away at the back of my mind, unfortunately, is that I'm no expert on BlitzMax and I'm not sure what the repercussions are of my tweaking. It does seem strange that the system would automatically be slower than is theoretically possible - however BlitzMax, being middleware, has been built with ease of use in mind every bit as much as power.
I'm hoping that this was simply a feature to keep the system more user friendly for new users. Hopefully someone in the know will clue me in. I'm feeling kind of lucky though, after seeing Watford throw away a 2-0 lead, but still steal an equaliser in the dying minutes to seal a 3-3 draw and win me £50.
Tuesday, October 03, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment