News:

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

uFMOD_GetTime

Started by ragdog, February 02, 2008, 09:10:24 PM

Previous topic - Next topic

ragdog





A simple way to pack an 'HH:MM:SS' progress meter:

Function HHMMSS$()
   Local iss:Int = uFMOD_GetTime() / 1000
   Local mm$ = (iss / 60)  Mod 60
   Local hh$ = (iss / 360) Mod 24
   Local ss$ = iss         Mod 60
   If Len ss$ = 1 ss$ = "0" + ss$
   If Len mm$ = 1 mm$ = "0" + mm$
   If Len hh$ = 1 hh$ = "0" + hh$
   Return hh$ + ":" + mm$ + ":" + ss$
EndFunction




greets
ragdog

MichaelW

I took the time to answer your question, only to find when I finished that you had deleted the question. When you do this you destroy the incentive for anyone to help you. Who would want to spend a significant amount of time answering a question that might be gone by the time they reply?
eschew obfuscation

hutch--

ragdog,

Michael is correct here, many problems are common and other members can learn from the aswers so when you post a question, leave it there even if you find the solution yourself as it helps other members.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ragdog

@michael and hutch

sorry     :wink

I could not delete this post

Here is the function calc the time from ufmod in min:sec:ms


.data
szTime db '%0.2lu:%0.2lu:%0.2lu',0


.data?
hInstance     dd ?
szStatusTime db 100 dup (?)
StartTime     dd ?
_Time     dd ?



invoke SetTimer, hWnd, ID_TIMER1,1,offset CalcTime

...
...

CalcTime PROC hWnd:DWORD

invoke uFMOD_GetTime
mov ecx,StartTime                 ;Time=EndTime-StartTime

mov StartTime,eax
sub eax,ecx                     ;eax=Time

add eax,_Time
xor edx,edx
mov _Time,eax                 ;eax=ElapsedTime in miliseconds

mov ecx,1000*60                 ;convers miliseconds to minutes & seconds
xor edx,edx
div ecx                     ;eax=seconds
push eax                     ;eax=minutes, save it

mov eax,edx                     ;calc seconds
mov ecx,1000
xor edx,edx
div ecx
pop ecx                     ;restore minutes
invoke StatusTime,hWnd,ecx,eax,edx  ;ecx,eax,edx min:sec:ms
ret
CalcTime ENDP

StatusTime PROC hWnd:DWORD,Min:DWORD,Sec:DWORD,Ms:DWORD
invoke wsprintf,offset szStatus_Time,
            offset szTime,Min,Sec,Ms
invoke SetDlgItemText, hWnd,1001, addr szStatus_Time
ret
StatusTime ENDP


@michael
   
can post your solution?

greets
ragdog

MichaelW

I currently cannot do anything with uFMOD, but this code can do the conversion from milliseconds to HH:MM:SS. To format the result string without displaying it, you should be able to use wsprintf or crt_sprintf, with a similar format string.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      h dd 0
      m dd 0
      s dd 0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    H = 5
    M = 62
    S = 59
    mov eax, (H * 60 * 60 + M * 60 + S) * 1000

    ; -------------------
    ; Convert to seconds.
    ; -------------------

    mov ecx, 1000
    xor edx, edx
    div ecx

    ; ----------------------------
    ; Extract hours from seconds.
    ; ----------------------------

    mov ecx, 60*60
    xor edx, edx
    div ecx
    mov h, eax

    ; --------------------------------------------------
    ; Extract minutes and seconds from hours remainder.
    ; --------------------------------------------------

    mov eax, edx
    mov ecx, 60
    xor edx, edx
    div ecx
    mov m, eax
    mov s, edx

    invoke crt_printf, chr$("%02d:%02d:%02d%c"), h, m, s, 10

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


Displays: 06:02:59
eschew obfuscation

ragdog

   
Is basically like my source

Nevertheless thank you for your work  :U


greets
ragdog

ps:
If my project is finished, I upload it here :bg