Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / sync trouble

Author
Message
Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 15th Sep 2007 13:58
I've been working on an engine for an old school rpg(FF), and things were going OK until I found that the screen was only being pushed to about 6-9 fps. I retrofitted the code to use sync, but even with the sync rate set to 0, The game does the same thing on both of my computers; I'd appreciate it if someone could look the code over and tell me if I'm using sync correctly. Thanks.

Attachments

Login to view attachments
Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 15th Sep 2007 17:36 Edited at: 15th Sep 2007 18:30
I commented out the GET IMAGE block and any instances of SYNC except the one in the draw_screen() function, but it was still pretty slow, so I commented out the entire draw_screen function(except print fps and sync), and it ran up to about 21 fps. I guess the graphics function is just a resource hog. I'm gonna try to split draw_screen into two functions, draw_menu and move cursor. hopefully I'll be able to cut down on the number of draw commands per frame.

Attachments

Login to view attachments
Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 15th Sep 2007 20:17
Well, i broke up draw_screen() and put most of it into game_math() and put check variables in front of the rest, so as to only draw things that have changed since the last frame, and now I get the framerate I want. Thanks for pointing me in the right direction.
Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 15th Sep 2007 23:16
Get this, though. While simplifying everything, I figured out that the print command also seems to take up a solid bit of resources. In the source I have here, commenting out a set cursor command, and ink command, and one print command (lines 383,384,385)in a loop pentuples the frame rate during that loop. Is it because I'm printing over another printed line? Most of what I did to Speed up the game was change things like this


to things like this




or can print be that resource intense? I hope not...

Attachments

Login to view attachments
Jeff032
17
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 16th Sep 2007 19:55
For one thing, I do believe that INK is a rather slow command, I'm not 100% sure though...

-Jeff

Space Game WIP
Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 17th Sep 2007 01:57
is there another, faster way to set color?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Sep 2007 03:05
Quote: "is there another, faster way to set color?"


Only using the colour value directly rather than using the RGB function every time you use the Ink or Color Object commands.

Ink RGB(255,0,0),0

...is slower than using:

Ink 16711680,0

It's one less calculation - not a big speed optimization on it's own I know, but can be considerable in big loops.

(Likewise, Ink 0,0 should always be used instead of Ink RGB(0,0,0),0).

Most IDE's will let you calculate and insert a colour value rather than using the RGB function (where it isn't required of course).

TDK_Man

Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 17th Sep 2007 10:02
that's not hex, is it?

Just changing all instances of rgb(0,0,0) to 0 was increase the f/s rate from 6 to 14-17, so naturally I'd like to switch out all the other rgb calls I can, but when I put 150,150,150(grey) into a rgb/hex converter, it returned 969696, which darkbasic compiles as a lovely shade of blue...

can the standard dbpro ide accept hex color values?
Jeff032
17
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 17th Sep 2007 14:08
Its not hex values, just do
print rgb(150, 150, 150)
and write down the value

-Jeff

Space Game WIP
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Sep 2007 15:57
The biggest fps killer in your program is the line;

set text font "Mufferaw"

Unfortunately DBPro does not cache loaded fonts and so re-reads whole font every frame. You should never change font in main loop. Set it once before main loop and frame rate will rocket.

Boo!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Sep 2007 20:37
If you want to use hex, you can. 969696 is decimal, but 0x969696 is hex and will give you the shade of grey you are after.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Miles Prower
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: U.S.A.
Posted: 18th Sep 2007 01:19
Thanks everybody, the code rarely runs lower than 14 f/s now.

Login to post a reply

Server time is: 2024-09-27 05:09:22
Your offset time is: 2024-09-27 05:09:22