JustinSD Posted July 3, 2012 Author Share Posted July 3, 2012 1) if this thread is in the incorrect place, please move2) i will do at least 1 daily update (probably not)64-Bit timer (replacement for GetTickCount) | Original Author: Spodi of http://netgore.com>! in any module of your choosing (preferably where your declarations are located)```'Used for the 64-bit timerPrivate GetSystemTimeOffset As CurrencyPrivate Declare Sub GetSystemTime Lib "kernel32.dll" Alias "GetSystemTimeAsFileTime" (ByRef lpSystemTimeAsFileTime As Currency)Public Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long>! ```somewhere at your entry point routine (probably sub main)```>! 'Set the high-resolution timer timeBeginPeriod 1 'This MUST be called before any timeGetTime calls because it states what the 'values of timeGetTime will be. InitTimeGetTime>! ```>! Place in a module with general code of the program```>! Public Sub InitTimeGetTime()'*****************************************************************'Gets the offset time for the timer so we can start at 0 instead of'the returned system time, allowing us to not have a time roll-over until'the program is running for 25 days'*****************************************************************>! 'Get the initial time GetSystemTime GetSystemTimeOffset>! End Sub>! Public Function timeGetTime() As Long'*****************************************************************'Grabs the time from the 64-bit system timer and returns it in 32-bit'after calculating it with the offset - allows us to have the'"no roll-over" advantage of 64-bit timers with the RAM usage of 32-bit'though we limit things slightly, so the rollover still happens, but after 25 days'*****************************************************************Dim CurrentTime As Currency>! 'Grab the current time (we have to pass a variable ByRef instead of a function return like the other timers) GetSystemTime CurrentTime 'Calculate the difference between the 64-bit times, return as a 32-bit time timeGetTime = CurrentTime - GetSystemTimeOffset>! End Function>! ``` Link to comment Share on other sites More sharing options...
Stein Posted July 3, 2012 Share Posted July 3, 2012 Note that TimeGetTime is MORE accurate than GetTickCount, so this will cause a few oddities with the values of your old time system. Or it can rather, animations might suddenly animate a bit faster and whatnot.. Link to comment Share on other sites More sharing options...
Yxxe Posted July 3, 2012 Share Posted July 3, 2012 Can't you just save yourself the hassle and use GetTickCount64 instead? Link to comment Share on other sites More sharing options...
JustinSD Posted July 3, 2012 Author Share Posted July 3, 2012 @Stein:> Note that TimeGetTime is MORE accurate than GetTickCount, so this will cause a few oddities with the values of your old time system. Or it can rather, animations might suddenly animate a bit faster and whatnot..Skideria games discourages improperly coded graphic engines that would be affected by higher performance timers.Which obviously leads to…Frame based motion vs Time based motion.An example time based motion coding would be what you see in ms4/eo2Original Author: tiggilyboo of eclipse``` Case MOVING_WALKING: MovementSpeed = ((ElapsedTime / 1000) * (RUN_SPEED * SIZE_X)) Case MOVING_RUNNING: MovementSpeed = ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))```+ associated variables, just search through the codeif you'd like, compare the same code in older versions of eclipse to see the frame based variation Link to comment Share on other sites More sharing options...
Stein Posted July 3, 2012 Share Posted July 3, 2012 Doesn't mean it won't cause a few oddities here and there in EO ;] Link to comment Share on other sites More sharing options...
JustinSD Posted July 3, 2012 Author Share Posted July 3, 2012 eek, quit posting in my thread, or i wont post any more codesthis was done by request. leave the "notes" or whatever to me. if i wish to leave information out, then that means i want the user to find out on their own Link to comment Share on other sites More sharing options...
Murdoc Posted July 3, 2012 Share Posted July 3, 2012 you have a star in your butt o.O Link to comment Share on other sites More sharing options...
Likestodraw Posted July 4, 2012 Share Posted July 4, 2012 So are you going to have this be a get started on VB6, noobie VB6 applications, or random EO tutorials? Link to comment Share on other sites More sharing options...
jcsnider Posted July 5, 2012 Share Posted July 5, 2012 No. These are not newbie tutorials. These are code snippets. That I guess will attempt to improve eclipse for those who use them :/… Link to comment Share on other sites More sharing options...
Stein Posted July 5, 2012 Share Posted July 5, 2012 @jcsnider:> No. These are not newbie tutorials. These are code snippets. That I guess will attempt to improve eclipse for those who use them :/…It has the most impact on CS:DE from what I've been told, It boosted the FPS client side about 5 times for some people. I personally haven't found much use for it in EO, aside from the fact that GetTickCount will break a after your computer has been on for a long amount of time, and it will eventually reset and start over, resulting in it breaking every loop based function we have in EO. Link to comment Share on other sites More sharing options...
Robin Posted July 6, 2012 Share Posted July 6, 2012 @Just:> It has the most impact on CS:DE from what I've been told, It boosted the FPS client side about 5 times for some people. I personally haven't found much use for it in EO, aside from the fact that GetTickCount will break a after your computer has been on for a long amount of time, and it will eventually reset and start over, resulting in it breaking every loop based function we have in EO.You can fix that by simply doing a differential check and running the timers off an unsigned data type. The rollback won't damage anything then. Link to comment Share on other sites More sharing options...
erkro1 Posted July 6, 2012 Share Posted July 6, 2012 @Robin:> You can fix that by simply doing a differential check and running the timers off an unsigned data type. The rollback won't damage anything then.How do you do that? Link to comment Share on other sites More sharing options...
Robin Posted July 8, 2012 Share Posted July 8, 2012 @Erwin:> How do you do that?Mark the boot tick in a variable. For any timer calls return the boot tick substracted from the current tick count. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now