News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Moments of the screen content changes.

Started by matemp, November 09, 2006, 06:39:47 PM

Previous topic - Next topic

matemp

Good day!
How the asm program may exactly define the moments of beginning and finishing of physical drawing the screen content (not writing into the video memory!), i.e. the moment of the first change on the screen and the moment of the last change on the screen during any frame? For example, for the LCD display, with exactness of one microsecond (or other maximal possible)?
Thanks.

Tedd

The screen refresh is controlled by the graphics-card.
You cannot control it directly, you can only tell the graphics-card to update at a specific rate (e.g. 60Hz), if you choose a bad rate for your screen then it could cause damage or even break it.
You don't normally have direct access to this anyway, except at a low level (e.g. as a driver).
No snowflake in an avalanche feels responsible.

donkey

You may be able to access this information through the WMI event notification scheme. I am not sure it is available as an event but I suspect it is not as WMI is generally only used to provide information regarding configurations and drivers. However with a bit of research and alot of testing you might be able to come up with something. If you're willing to take on the task you might google for the following subjects:

Windows Management Instrumentation
WMI client applications
WMI event notification

However, my dabbles into the WMI (most were failures) show that it is only semi-synchronous so the actual notification of the event is occasionally out of sync with the event, this can be cause by heavy CPU usage at the time of the event. Windows is not a real-time operating system so the reliability of highly event critical data is almost always suspect and will often be less than useful.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

MichaelW

This does not determine a time, but the scan lines where vertical blank starts and ends. A similar technique could be used to get the times.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
    include \masm32\include\ddraw.inc
    includelib \masm32\lib\ddraw.lib

    DD_OK EQU 0

    DDO_GetScanLine EQU 64

    DDERR_VERTICALBLANKINPROGRESS EQU ((1 shl 31)or(876h shl 16)or(537))

    DDGetScanLine PROTO scanLine:DWORD
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      lpdd_1    dd 0
      scanLine  dd 0
      vbStart   dd 0
      vbEnd     dd 0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    ; ------------------------------------
    ; Create a default DirectDraw object.
    ; ------------------------------------

    invoke DirectDrawCreate,NULL,ADDR lpdd_1,NULL
    .IF (eax)
      print "DirectDrawCreate failed",13,10
      jmp fini
    .ENDIF

    ; ---------------------------------------------------
    ; Set HIGH_PRIORITY_CLASS to miminize interruptions.
    ; ---------------------------------------------------

    invoke GetCurrentProcess
    invoke SetPriorityClass,eax,HIGH_PRIORITY_CLASS

    ; ----------------------------------------
    ; Determine the scan lines where vertical
    ; blank starts and ends.
    ; ----------------------------------------

    invoke DDGetScanLine, ADDR scanLine
    .WHILE (eax == DDERR_VERTICALBLANKINPROGRESS)
      invoke DDGetScanLine, ADDR scanLine
    .ENDW
    .WHILE (TRUE)
      invoke DDGetScanLine, ADDR scanLine
      .IF (eax != DDERR_VERTICALBLANKINPROGRESS)
        m2m vbStart, scanLine
      .ELSE
        .WHILE (eax == DDERR_VERTICALBLANKINPROGRESS)
          invoke DDGetScanLine, ADDR scanLine
        .ENDW
        m2m vbEnd, scanLine
        .BREAK
      .ENDIF
    .ENDW
    print "vertical blank start = "
    print ustr$(vbStart),13,10
    print "vertical blank end = "
    print ustr$(vbEnd),13,10

    invoke GetCurrentProcess
    invoke SetPriorityClass,eax,NORMAL_PRIORITY_CLASS

  fini:

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
DDGetScanLine proc lpScanLine:DWORD
    push lpScanLine
    push lpdd_1
    mov eax, lpdd_1
    mov eax, [eax]
    call DWORD PTR[eax+DDO_GetScanLine]
    ret
DDGetScanLine endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
eschew obfuscation