Author Topic: Fast Multimedia Timer for Games and Demos  (Read 1626 times)

caballero

  • Member
  • *****
  • Posts: 1099
    • abre ojos ensamblador
Re: Fast Multimedia Timer for Games and Demos
« Reply #15 on: April 15, 2018, 10:21:42 PM »
I believe that the stutter in the floor demo is due to the stretching mixing one colors with others. If you increases the size of the window it runs smoothly. Please, if you have time, check it out and tell me.

Most of flickers dissapear using a double buffer, but bearing in mind that what you do between to frames has to be finished before the next starts. Another flickers appear because in two consecutive frames don't join.

If you try this version of floor demo with rigid frames, doesn't appear the flickering
En un lugar de la Mancha de cuyo nombre no quiero acordarme

- There are 10 kind of people: those who know binary numbers and those who don't -

Siekmanski

  • Member
  • *****
  • Posts: 1709
Re: Fast Multimedia Timer for Games and Demos
« Reply #16 on: April 15, 2018, 10:37:08 PM »
The colors are stable now, but there are still stutters.
Creative coders use backward thinking techniques as a strategy.

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Fast Multimedia Timer for Games and Demos
« Reply #17 on: April 16, 2018, 04:22:30 AM »
I am doing my game in GDI with plans to port it to something else in the future.
But with all the Dx talk I'm getting munchies to do it sooner.

I'm basically just blitting to back buffer and them to the window. I guess it wouldn't be too hard to implement it, would it?

First I thought of Opengl, but what the hack, I would not be able to port the masm anyway, so that wouldn't make sense.

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Fast Multimedia Timer for Games and Demos
« Reply #18 on: April 17, 2018, 04:34:43 AM »
Hi Marinus,

What's the unit for your timers and how can I output it to console?

Further, would it be possible to return the milliseconds taken by the loop and the FPS? Usually I'd like to know the milliseconds, and put it to sleep the remaining milliseconds in order to keep the FPS/milliseconds constant.

By the way, do you deal with Sleep granularity with TimeBeginTime?

Siekmanski

  • Member
  • *****
  • Posts: 1709
Re: Fast Multimedia Timer for Games and Demos
« Reply #19 on: April 17, 2018, 07:03:52 AM »
The unit is in seconds.

A way to print floats in a console application:
( Possibly there are routines for this in the masm lib? )

Code: [Select]
includelib  \masm32\lib\msvcrt.lib

sprintf proto C :vararg ; from msvcrt.lib

TEXT_ MACRO your_text:VARARG
    LOCAL text_string
    .data
     text_string db your_text,0
    .code
    EXITM <addr text_string>
ENDM

.data?
szString_buffer db 512 dup (?)

fp8value real8 ?

.code

align 4
StdOut proc lpszText:DWORD

    LOCAL hOutPut  :DWORD
    LOCAL bWritten :DWORD
    LOCAL sl       :DWORD

    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hOutPut, eax

    invoke  lstrlen,lpszText
    mov sl, eax

    invoke WriteFile,hOutPut,lpszText,sl,ADDR bWritten,NULL

    mov eax, bWritten
    ret

StdOut endp

PrintTimer proc
fld Timers.Timer1 ; Real4 format -> convert to real8 format
fstp fp8value ; save as Real8 format for use with sprintf function

invoke sprintf,addr szString_buffer,TEXT_("Timer: %0.06f",13,10),fp8value
invoke StdOut,addr szString_buffer
PrintTimer endp

TimeBeginTime is just wrapper code, better deal directly with,
QueryPerformanceFrequency and QueryPerformanceCounter
NtQueryTimerResolution
NtSetTimerResolution
NtDelayExecution ( 500 microseconds delay )

No, I use Sleep with the standard granularity for normal occasions
But for threaded interrupt timers ( 100 nanosecond units ) I use the 500 microseconds Sleep version to do fast synchronizations.
Which I will use in the vertical blank routine I'm writing  ( hope to show it next week or a week later )
Creative coders use backward thinking techniques as a strategy.

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Fast Multimedia Timer for Games and Demos
« Reply #20 on: May 26, 2018, 03:53:55 AM »
Hi Marinus!
So, I modified your first timing routine into a multi-timer for code profiling. It's still your original code,I simply made a structure from all globals so I could save individual timings in various part of the code. I intend to plot them later.
Would you review and polish it for me?

Siekmanski

  • Member
  • *****
  • Posts: 1709
Re: Fast Multimedia Timer for Games and Demos
« Reply #21 on: May 26, 2018, 04:10:00 AM »
 :t
Creative coders use backward thinking techniques as a strategy.

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Fast Multimedia Timer for Games and Demos
« Reply #22 on: May 27, 2018, 09:52:07 PM »
:t
I sent you my modded code for you through MP, so we can save forum space.

felipe

  • Member
  • *****
  • Posts: 1011
  • Eagles are just great!
Re: Fast Multimedia Timer for Games and Demos
« Reply #23 on: May 28, 2018, 04:43:36 AM »
:t
I sent you my modded code for you through MP, so we can save forum space.

Sounds like a "don't want to share" thing... :(  Shouldn't be PM? (is MP some kind of code obfuscation tactic?).


 Please don't take it too personal...I was just kidding...  :icon_mrgreen:
Felipe.

Siekmanski

  • Member
  • *****
  • Posts: 1709
Re: Fast Multimedia Timer for Games and Demos
« Reply #24 on: May 28, 2018, 05:10:18 AM »
We are on a secret mission.  :badgrin:
Creative coders use backward thinking techniques as a strategy.

daydreamer

  • Member
  • ****
  • Posts: 563
  • reach for the stars
Re: Fast Multimedia Timer for Games and Demos
« Reply #25 on: May 29, 2018, 12:57:06 AM »
We are on a secret mission.  :badgrin:
...to rule the world :badgrin:
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Fast Multimedia Timer for Games and Demos
« Reply #26 on: May 29, 2018, 01:41:27 AM »
We are on a secret mission.  :badgrin:
Yep, Brazil and Holland joining to take over!

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Fast Multimedia Timer for Games and Demos
« Reply #27 on: May 29, 2018, 01:43:11 AM »
:t
I sent you my modded code for you through MP, so we can save forum space.

Sounds like a "don't want to share" thing... :(  Shouldn't be PM? (is MP some kind of code obfuscation tactic?).


 Please don't take it too personal...I was just kidding...  :icon_mrgreen:
Hi Felipe, MP is Portuguese for PM, I mixed up.The code will be shared of course! And hopefully very useful

felipe

  • Member
  • *****
  • Posts: 1011
  • Eagles are just great!
Re: Fast Multimedia Timer for Games and Demos
« Reply #28 on: May 29, 2018, 11:25:26 AM »
Thanks LordAdef.  :t

Felipe.