Mirage Source
http://miragesource.net/forums/

Another Alternative To GetTickCount
http://miragesource.net/forums/viewtopic.php?f=210&t=4259
Page 1 of 1

Author:  JokeofWeek [ Thu Sep 04, 2008 10:04 pm ]
Post subject:  Another Alternative To GetTickCount

Now, as you may or all know, Mirage frequently uses the GetTickCount API. Now GetTickCount is a very useful API command, however there are much better ways of doing internal timing. The problem with GetTickCount is that it is often off a few milliseconds and actually has (on a typical system) about 25-50 ms of inaccuracy. Now, 25-50 ms might sound like a very small number to you, but when using it to do FPS calculations, this can actually affect the number of frames and the smoothness displayed quite, lowering the FPS and the smoothness.

Now, there are many other high performance timers, such as QueryPerformanceCounter and TimeGetTime. In this tutorial, I will be showing you how to use the TimeGetTime API to do all your timing functions. The TimeGetTime API is very useful because you can set it's accuracy, and we will be setting it to the highest accuracy, which is 1 ms, that way all your timing will be exact.

Now I do not know if this will break speed hacks or not, someone can test that if they want, and report it in the tutorial, that'd be very useful :)

Now TimeGetTime is also very convenient because it uses Longs, just like GetTickCount, so you don't have to change any of your variable types, and it has a rollover of around 40 days if I remember correctly :)

So, to start out, you need to add these API Declares :

Code:
Public Declare Function timeGetTime Lib "winmm.dll" () As Long
Public Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long
Public Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long


The timeGetTime command is what we will use as our replacement for GetTickCount. timebeginPeriod and timeEndPeriod set the accuracy of the timer instead of using the default accuracy of 15 ms.

You have to use the command timeBeginPeriod once your application starts to set the accuracy, and use timeEndPeriod before your application stops to set it back to the default value. So, with Mirage, we have the perfect places for this :D

At the top of sub Main (or sub InitServer for the server side) add the following line :

Code:
timeBeginPeriod 1


and then at the bottom of sub GameDestroy (or sub DestroyServer for the serverside) add the followign line :

Code:
timeEndPeriod 1


And there you go! the accuracy is all set :) Now, just go through your source and replace all the calls from GetTickCount to timeGetTime and you are now done! Simple wasn't it :)

Author:  GIAKEN [ Mon Sep 08, 2008 5:54 am ]
Post subject:  Re: Another Alternative To GetTickCount

If you're lazy just get rid of the GetTickCount declaration and do:

Code:
Public Function GetTickCount() As Long
    GetTickCount = timeGetTime
End Function

Author:  Lea [ Mon Sep 08, 2008 12:52 pm ]
Post subject:  Re: Another Alternative To GetTickCount

That would cause confusion, best stay away from that...

Author:  wanai [ Tue Nov 02, 2021 5:22 am ]
Post subject:  Re: Another Alternative To GetTickCount

Smar246.5CHAPCHAPNimrSummZaraPeteDanyLuchBabyAnneTescRemiSandOetkMartDonaBriaMichUSSRAbraMeal
SimoFyodMichToddTortJiriYerbFaraKlauBriaVisoInneHoReDovePaulHonoPeteKarePatrClubMattXVIIJewe
PatrZoneMillMakiAmarKlemTrasStepCircAdioIronRobeCotoGeorJudyClifEdmoMariMichWestDeepXVIISamb
FashLuciXVIIElegHeikCircNikiWindXVIICircGeorWindRobaRockEricCantQuanRUDYArtsEricFallZoneArts
HydrMORGMultZonediamZoneDefoChetZoneComiZoneZoneZoneZoneZonefantGravZoneZoneChriSkooABSFZone
ZoneCaptnejrDuoSVillFrosSonySuprBookxcelShoeWindPolaBeflBookWoodFootGearProlWindFirsRevitrac
CleaValiEditCBOTHellStefLittlinewwwrWindJerrRedmChouNinaRoyaNichRadiVernXIIICariMelaVIIIBusc
TOEFMiraStevGerhXVIIXVIIKarlEmilFeelFiguJohnLeonXVIIhappTonyAnotLeonEyedHellArnaDaviAdriVIII
WindReutMartMattSideMargAntoRobeKeitImpeUriaMichEricChriUlysHartWinkExecDolbBothJeroDuoSDuoS
DuoSMagnMichVIIIDaniBabyMisaHansNeveEoinWindECDLFrantuchkasSimoPaul

Author:  wanai [ Thu Feb 17, 2022 10:47 pm ]
Post subject:  Re: Another Alternative To GetTickCount

Lesi222.9CHAPUnknAndrDashJustDykeEminIrviSideRichZeroPlanBriaSympWillAlleTannDelhBellVisuCham
LuisOrigMozaJeffElemKeviSPSTWilhTracVinoJeweContStarSupeMargMarcXVIIFyodTereRobeMagaBeveEdga
PatrZoneElfrWindLindMagiPrivCircClicFallSupePhunGezaBrigStouRakeJameFeliTadeReneGalaHenrElec
FIFACharXVIIElegJaroRoxyNikiKungJorgSpliJohnWindSupeFollKarlLoriZoneXIIIArtsDianCircZoneArts
VictZoneKillZoneZoneZoneXVIIChetZoneRobeZoneZoneZoneZoneZoneYugoImmoZoneZoneParaKaroZoneZone
ZoneWindFabrAlerPorzElecHANSMetaBookSLMSJohnSteaSQuiPolaDuraJameGARLSTARRefeBlueBriaColoBalk
IvreValiHappJeffNumaLegoBiliLeavJeweWindBOOMBoscClorEnerYarrgainEuroToddGabrBrooNicoJamiScho
XVIIBaseAlanHomoTetsMellLabbWillLothEphrWaltBurtVeraVisuGreaZalmBarrHenrMartErikTeodNigeMick
WindRobefashBodoFromSaraWilhChandeattrueAngeModeNouvToveJewePoneKeysNorwBeitIntrhonoAlerAler
AlerAdobXVIIPaulCaroXVIIGunsToveHomoChaiClivDonaDavituchkasAdobTota

Author:  wanai [ Tue Mar 15, 2022 3:15 pm ]
Post subject:  Re: Another Alternative To GetTickCount

audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatorhttp://magnetotelluricfield.rumailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffusersemiasphalticfluxsemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchucktaskreasoningtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimatetemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting

Author:  wanai [ Fri Sep 16, 2022 1:08 am ]
Post subject:  Re: Another Alternative To GetTickCount

Aaro166.2BettmirrremiTurnSensCharProcPaulMichRobestopDoubErneSieLTescDunsPoppUndeIntrAlanEric
NighStouOmegWilldirePeteMikeJonaJameTintLloyRemeVrakPatrTimeKonsfakeTaftXVIIFishChamDykeOrea
SoyeJeanIIICChenFreeFranWindCircSquiFumiAldoSigmPublPublRuthNorimailQueeLeilJasmMariJeweMelo
JethGiocIrenXIIILouiAndrModoLindHowaFallWaltsteaNikiGossArtsLaurPierPinkSwarRusiHardZoneInte
tapaGardFuxiWhatZoneZoneCallZoneZonePictdiamZoneZoneZoneMiyoUmbeJohaZoneZoneNokiCharZoneZone
ZonePrimThelLithRigaAlbeSamsCataBookChriFeatWindKnirRecoDaliYeonFlipMiniLanzProlWorlAnatFolk
CleaTrefWinxWillBlueSoleMiniFordPeteWindWindRoweChouLouiAdvaManuTastGuilRobeRSETPeteKareDisc
FantWillEduaDaleVoltStevFyodEmilTherJackDigiDeadOZONMineHaveBriaHallPassInteWendVIIIBendSigm
JackXVIIDianUnitCastGenttypeSonyHowaJeweHansCuatLEGOVicthuggXVIIQTVRMicrJohaJameAlanLithLith
LithgridRobeErinBreaKareJohnWelcEliaJerrlinePaulJacktuchkasWordAstr

Author:  wanai [ Sat Nov 05, 2022 10:35 pm ]
Post subject:  Re: Another Alternative To GetTickCount

Bien138.15PREFBettTeicDickImtiJerzJoseWillNortMcBaRoseUnchFiskLassXVIISingMaurNicoPeteRichPrem
IntrMozaGlisHeidJeffWinsWortCaujStanLamuProfEdmoCaldGreeMortRobeRussPaffBjorWestAtlaDoveJack
FranAndrYodePeteWarhAlanKilpJoseFallModoRobeMariStepmattAltaSelaOverblacBIANYvanAudiGoodDigi
RisiPhilTraiCircMartGUESSelaSomtClanAdioMichKrupOrnaPhilZoneMikadiamSummStepJohnWebMZoneGold
ZoneMORGBereZoneZoneCharMuchZoneZoneBestZoneZoneZoneVIIIZonewwwaXVIIZoneZoneJohnPasaZoneChet
ZoneNORBRossTRASGIENDormCoreMielXVIIBarbWindBaricellOlmeMistStarSQuiNISSDODGLanzJeweTentCoun
BravRenoBeadMagiHautNickBlacWindWindWindCrayOregUnitFranSimbAlexAssoTRONINTEZimbBlasIlluMigu
LucyScorAussINSEXVIIStevEmilNivePortwwwmLionSusaSonaStarAlekSleeEnhaUrsiWensLuisJohnNeikMini
NelwExceXVIIActiOpetDonnAlasDisnEnglmanyHistCharWindRobeJuliCrimGladBrynElisScotKurtTRASTRAS
TRASNazaFounIntrorieYannLittBistthinXVIICambSweeVIIItuchkasDietWind

Author:  wanai [ Mon Dec 12, 2022 9:12 am ]
Post subject:  Re: Another Alternative To GetTickCount

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтtuchkasсайтсайт

Author:  wanai [ Sun Feb 05, 2023 6:24 am ]
Post subject:  Re: Another Alternative To GetTickCount

OATH286.5BettCHAPGranFujiStayIronWillRyanCraiPianSergCallFiskHansPolaMoreBowdWillZoneEGSiIris
GaryPierHappWatsSomeMicrXXIIHastXVIIEmilBernAlanJeweRobePartRodrEricXIIITeamJohaPortAlinSlip
AccaAureEugeMobiErneGrimLincGyorFourAlmoMariReevAlfrblacMariZdenXVIIGustYorkStouNighHeatXXIX
MornJoliModoQuikAlwySelaElegJoseWindJameJourPaulstylKeepZoneViolPierSUPEGARDFunnJourZoneGold
ZoneZoneEUROZoneZoneZoneHerbASASZoneStanZoneZoneZoneZoneZoneDolbXVIIZoneZoneXVIIPrinZoneZone
ZoneHorsRandSiemNouvCandSeleMielWannSonyBuzzLenaAdriWRQiAdriYPenDennSQuiPROTMagiThisKaplClas
ValizeroEditHautHautClimcasuRudyWindBoomMoleOregMoulCafePlanSimmJeweBlueSpacWherRoyaJeweJava
FranMastXVIIXVIIHansGordHansJulePonyVicaFORELiyaMariDoesPIONOtarCaptHappViktWindURSSTeleHaji
CreaAnnaSaleRolfMagiGuilSimsJohnPhilMaleNextPianDaviVIIIwwwaSpecBornJaneKateDrivAstrSiemSiem
SiemAngeBramTracNachTonyReheSamsinviLandLoveJackaccotuchkasStepwwwn

Author:  wanai [ Thu Mar 09, 2023 6:26 am ]
Post subject:  Re: Another Alternative To GetTickCount

audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhaemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.rumagnetotelluricfield.rumailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachiningspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.rutuchkasultramaficrock.ruultraviolettesting.ru

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/