Frame rates.
type568

1long volatile t568=0;
2 
3void timer_ms(void)
4 {
5 t568++;
6 }
7END_OF_FUNCTION(timer_ms)
8 
9 if(settings->show_fps)
10 {
11 if((settings->cnt++)%DiSPLAY_FPS==0)
12 {
13 settings->current=settings->current1/DiSPLAY_FPS;
14 settings->current1=0;
15 }
16 if((*t-settings->fps)>0)
17 {
18 settings->current1+=1000/(*t-settings->fps);
19 settings->fps=(*t);
20 }
21 textprintf_ex(settings->sc_component,font,1,1,makecol(FPSR,FPSG,FPSB),0,"FPS %d",settings->current);
22 }

This code counts fps.. The weird things are:

When I remove the function rest, fps drops. (from 63, to 44) Also, on another PC (much faster, Intel Core duo 6600 compared to Intel P-4 2.4Ghz) It had 128 fps, after some changes in the program it again dropped to 63. After increasing the process's priority in Windows Task manager, FPS dropped to 33, while the game decently performed at the same, or higher speed.

Are there any functions that control the Process priority? Or force the OS to give more CPU time to my program?

Can some one explain me what is going on with my project?(and/or my PC/mind)

gnolam

Edit your post to use code tags and we'll help right away. It's just too much work deciphering code without them.

type568

It is done. Help please?

Kris Asick

First of all, if your program is prioritized too high, DirectX will not be able to do its thing properly and thus your framerate will suffer. (Especially if you go up into the real-time range of 15+.)

As per the framerate dropping when you remove rest() or Sleep() statements, it likely has everything to do with how you've coded your game loop and nothing to do with the code you've provided.

Plus, it would be good to tell us if the FPS is actually being accurate or not. (IE: If FPS drops, has the framerate also dropped, or is the FPS simply showing an incorrect value?)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

type568

I don't know.. In some cases the FPS seems to be correct, while in some decently not.. (when I increase the priority, the game can't run slower :/).

Here is all my project..

gnolam

... your project seems to lack any kind of working timing whatsoever. Separate logic and drawing, implement proper timing, and then come back.

type568

Sorry.. my case is different. I want FPS to improove, if possible. I have made some changes, and it had become more reasonible. 400+ (Intel core duo 6600) Though the problem now, is to adjust the game speed itself.

But thanks.. the code looks nice. (example you linked me to..)

Kibiz0r
Quote:

Sorry.. my case is different. I want FPS to improove, if possible.

I'm dumbstruck.

Kris Asick

I'm in a rush, especially since the forum logged me out before I could finish my reply to you... anyways, here's some things I noticed after looking over and testing your code:

1. I experience none of your framerate or CPU problems. You may want to try updating your drivers or trying your program on another system.

2. On my system I get roughly 100-110 FPS... which is well above the 60 my monitor can display at 1280x1024. You gotta keep in mind, FPS as high as 400 is completely unreasonable without hardware acceleration, especially at extremely high resolutions. Go download AllegroGL or OpenLayer if that's what you want.

3. Combining 32-bit colour, 1280x1024, and software rendering will kill the FPS on any system. For what you're doing, 8-bit colour should be all you need, and 1280x1024 isn't widely supported. You should design around 1024x768 and make it up-scalable.

4. You're calling LOCK_VARIABLE on the wrong variable in your main section. That might be part of your problem.

5. Your calls to acquire_bitmap() are doing nothing because you don't need to call that on regular bitmaps, only video bitmaps which you plan to call more than one drawing operation to in a frame.

6. You're calling acquire_screen() twice in your About section. I think you mean to call acquire_screen() then release_screen(). And again, you only need to do that if you plan to draw more than once to the screen in one frame.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

ImLeftFooted
Quote:

I'm in a rush, especially since the forum logged me out before I could finish my reply to you

After you've re-logged in, use the back button to go to the page after the 'new post' page where you typed your original post. Its the page that says "You must be logged in to do this".

Refresh this page. You should be prompted if you want to repost your data or resubmit it or something (depending on your browser). Select yes.

If you're too lazy to figure that out, install the allegro.cc Post Recovery Add-on.

Thread #590912. Printed from Allegro.cc