Archived

This topic is now archived and is closed to further replies.

random application slowdown

This topic is 6600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Well, the first thing that I'd do is ditch Fastgraph. I dont' like it, and I never will, mainly because I'm a code freak who writes all his libraries himself as much as he can, especially for DOS work. That will very probably deal with several problems, and it's not really all that hard to do the graphics work yourself.

In terms of experiencing random slow down, are you keeping your frame rate constant with some sort of a timer wait system? That might help. Otherwise, the more sprites that you display, the more CPU time will be taken up, hence your framerate will wobble poorly (plus, your game will run faster on different machines than others... eww)

Sample corruption is usually caused by some routine writing data where it shouldn't go. Make sure that you have all your pointers initializing properly.

That's unfortunately the best I can suggest. If you wanted to send me your sources (my e-mail is vining@pacificcoast.net), I'd be more than happy to take a poke around.

- Nicholas

Share this post


Link to post
Share on other sites
I don't recommend waiting at the end of each frame because that's still going to yield bad results during the slow down.

Instead, I recommend using syncing the game objects to time itself, rather than the frame rate, to get the best results.

For instance:

code:

ULONG oldtime, newtime;
FLOAT timedelta;
...

// Initialize the oldtime.
oldtime = GetTickCount();

while (inGameLoop)
{

// win API call, get tick count in ms.
newtime = GetTickCount();
timedelta = FLOAT(newtime - oldtime) / 1000.0f;
oldtime = newtime;

...

// calculate the new x velocity from the acceleration.
object.vel_x += object.accel_x * timedelta;

// Calculate the new x position from the velocity.
object.x += object.vel_x * timedelta;

... Do other stuff
}


Note that the object's x acceleration, x velocity, and x position are all in floating point.

The acceleration is in number pixels or game unit's per second per second. The velocity is in number of pixels or game units per second.

Acceleration can be derived from the equation:

F=ma.

F is the force in newtons, m is the mass in kilograms, and a is the acceleration. With some simple algebra, we can rearrange the equation.

a=F/m;

Well, you can preset the mass of an object, which is simple enough. You can calculate the force from user input (or from what your AI is doing) and some other equations to get a realistic force happening.

Note that the above equation is for worlds that want to simulate the gravity of earth. If you want to be able to change the gravity, you'll have to use some more complex equations.

[This message has been edited by CodeDemon (edited November 22, 1999).]

Share this post


Link to post
Share on other sites
we are developing a protected mode app with watcom c/c++ for drdos with the
dos4gw extender. we also use fastgraf 5.0 graphics lib. we randomly
encounter the slow down of our application displaying a graphic images.
once past the initial program choke, the app returns to the previous
consistent speed without any distortion to the graphic images (we have done
checksums on the loaded images and they come out ok). we have also noted,
when we are also playing sounds, the sound play back may or may not become
corrupted. we have also done checksums on the load sound files and they too
come up ok. we have two types of sound card we use in our target systems,
one requires the driver to be loaded via the command line, ie via
autoexec.bat, but our second card has the driver on the board itself. one
difference we have noticed is that when the slowdown occurs with the board
that has the driver built into the board the sound play back is never
corrupt post slowdown where as with the command line loaded driver the sound
playback may/may not be corrupted.

We are unsure what to make of the relationship between the graphics slowdown
and the corruption of sound playback and are at a loss for what causes these
slowdowns in the first place. any ideas or suggestions would be of great
help

-ben

Share this post


Link to post
Share on other sites