%define __code_RVA_Localize__ _code_+_.text_RVA

bits 32


align 4
time_updater:
 pushad

;;;INIT: Prepare the string
;;;INIT: Prepare the string
;;;INIT: Prepare the string

;//Point to the final buffer:
;///
; $EDI=timestrbuffer;
;
;
;
;//Write the hours:
;//
; $ESI=[hour_ptr];       //take the hours time offset
; $ESI+=_timenums;       //point into the generic time string table
; asm lodsw              //read the 2 digits in AX
; asm stosw              //write the 2 digits in the string buffer!
; $AL=[_timeseparator];  //point to the string containing ':'
; asm stosb              //write :
;
;
;//Write the minutes:
;//
; $ESI=[min_ptr];        //take the minutes time offset
; $ESI+=_timenums;       //point into the generic time string table
; asm lodsw              //read the 2 digits in AX
; asm stosw              //write the 2 digits in the string buffer!
; $AL=[_timeseparator];  //point to the string containing ':'
; asm stosb              //write :
;
;
;//Write the seconds:
;//
; $ESI=[sec_ptr];        //take the seconds time offset
; $ESI+=_timenums;       //point into the generic time string table
; asm lodsw              //read the 2 digits in AX
; asm stosw              //write the 2 digits in the string buffer!
; $AL=0;                 //terminate the string with a null byte
; asm stosb              //write the null byte

mov edi,timestrbuffer
mov esi,[hour_ptr];
add esi,_timenums
lodsw
stosw
mov al,[_timeseparator];
stosb
mov esi,[min_ptr];
add esi,_timenums
lodsw
stosw
mov al,[_timeseparator];
stosb
mov esi,[sec_ptr];
add esi,_timenums
lodsw
stosw
mov al,0; //#autosolved0000
stosb


;;;END:  Prepare the string
;;;END:  Prepare the string
;;;END:  Prepare the string



;;;INIT: Paint the string with WinAPI
;;;INIT: Paint the string with WinAPI
;;;INIT: Paint the string with WinAPI


;Get a device context:
;;
 push dword[HWND.myhWnd1]     ;HWND hWnd
  call dword[GetDC@USER32.DLL]
 mov [HDC.timestrHDC],eax        ;Put it in a device context handle variable

;HDC GetDC(HWND hWnd);



      ;Get the color for the system color "handle"
      ;called COLOR_BTNFACE:
      ;;
       push dword COLOR_BTNFACE
        call dword[GetSysColor@USER32.DLL]

      ;DWORD WINAPI GetSysColor(int nIndex);


      ;Use it as background color of the text:
      ;;
       push dword eax
       push dword[HDC.timestrHDC]
        call dword[SetBkColor@GDI32.DLL]

      ;COLORREF SetBkColor(HDC hdc, COLORREF crColor);




      ;Get the color for the system color "handle"
      ;called COLOR_BTNTEXT:
      ;;
       push dword COLOR_BTNTEXT
        call dword[GetSysColor@USER32.DLL]

      ;DWORD WINAPI GetSysColor(int nIndex);


      ;Use it as the color of the text:
      ;;
       push dword eax                       ;COLORREF crColor
       push dword[HDC.timestrHDC]           ;HDC      hdc
        call dword[SetTextColor@GDI32.DLL]

      ;COLORREF SetTextColor(HDC hdc, COLORREF crColor);


      ;Erase the in-window old string by printing an all-spaces string:
      ;;
       push byte 15                   ;int ncount
       push dword timestreraser       ;LPCSTR lpszstr
       push dword[int.timestry]       ;int y
       push dword[int.timestrx]       ;int x
       push dword[HDC.timestrHDC]     ;HDC DC
        call dword[TextOutA@GDI32.DLL]



      ;Paint the new string:
      ;;
       push byte 8                    ;int    ncount
       push dword timestrbuffer       ;LPCSTR lpszstr
       push dword[int.timestry]       ;int    y
       push dword[int.timestrx]       ;int    x
       push dword[HDC.timestrHDC]     ;HDC    DC
       call dword[TextOutA@GDI32.DLL]


;Release the device context:
;;
 push dword[HDC.timestrHDC]        ;HDC hDC
 push dword[HWND.myhWnd1]          ;HWND hWnd
 call dword[ReleaseDC@USER32.DLL]

;int ReleaseDC(HWND hWnd,HDC hDC);

;;;END:  Paint the string with WinAPI
;;;END:  Paint the string with WinAPI
;;;END:  Paint the string with WinAPI



;;;INIT: Update the time (once every second)
;;;INIT: Update the time (once every second)
;;;INIT: Update the time (once every second)

;asm xor eax,eax
;$EBX=4;
;$ECX=59*4;
;$EDX=23*4;
;$ESI=sec_ptr;
;$EDI=min_ptr;
;
;dword[$ESI]+=$EBX;
;if(dword[$ESI]>$ECX)  //(59*4)
;{
; dword[$ESI]=$EAX;
; dword[$EDI]+=$EBX;
; if(dword[$EDI]>$ECX)  //(59*4)
; {
;  dword[$EDI]=$EAX;
;  $ESI=hour_ptr;
;  dword[$ESI]+=$EBX;
;  if(dword[$ESI]>$EDX)  //(23*4)
;  {
;   dword[$ESI]=$EAX;
;  }
; }
;}


xor eax,eax
xor ebx,ebx
mov bl,4
xor ecx,ecx
mov cl,59*4
xor edx,edx
mov dl,23*4
mov esi,sec_ptr
mov edi,min_ptr
add dword[esi],ebx;
.if__0.7119677875519117__14:
cmp dword[esi],ecx
jbe .if__0.7119677875519117__14__end;
mov dword[esi],eax;
add dword[edi],ebx;
.if__0.0370797211291759__64:
cmp dword[edi],ecx
jbe .if__0.0370797211291759__64__end;
mov dword[edi],eax;
mov esi,hour_ptr
add dword[esi],ebx;
.if__0.3632818071525322__114:
cmp dword[esi],edx
jbe .if__0.3632818071525322__114__end;
mov dword[esi],eax;
.if__0.3632818071525322__114__end:
.if__0.0370797211291759__64__end:
.if__0.7119677875519117__14__end:


;;;END:  Update the time (once every second)
;;;END:  Update the time (once every second)
;;;END:  Update the time (once every second)

 popad
ret




























































align 4
time_reshow:
 pushad

;;;INIT: Paint the string with WinAPI
;;;INIT: Paint the string with WinAPI
;;;INIT: Paint the string with WinAPI


;Get a device context:
;;
 push dword clockrepaintSTRUCT        ;PAINTSTRUCT FAR *lpPS
 push dword[HWND.myhWnd1]             ;HWND hwnd
  call dword[BeginPaint@USER32.DLL]
 mov [HDC.timestrreHDC],eax           ;Put it in a device context handle variable




      ;Get the color for the system color "handle"
      ;called COLOR_BTNFACE:
      ;;
       push dword COLOR_BTNFACE
        call dword[GetSysColor@USER32.DLL]

      ;DWORD WINAPI GetSysColor(int nIndex);


      ;Use it as background color of the text:
      ;;
       push eax
       push dword[HDC.timestrreHDC]
        call dword[SetBkColor@GDI32.DLL]

      ;COLORREF SetBkColor(HDC hdc, COLORREF crColor);




      ;Get the color for the system color "handle"
      ;called COLOR_BTNTEXT:
      ;;
       push dword COLOR_BTNTEXT
        call dword[GetSysColor@USER32.DLL]

      ;DWORD WINAPI GetSysColor(int nIndex);


      ;Use it as the color of the text:
      ;;
       push dword eax
       push dword[HDC.timestrreHDC]
        call dword[SetTextColor@GDI32.DLL]

      ;COLORREF SetTextColor(HDC hdc, COLORREF crColor);



      ;Repaint the current time string:
      ;;
       push byte 8                    ;int    ncount
       push dword timestrbuffer       ;LPCSTR lpszstr
       push dword[int.timestry]       ;int    y
       push dword[int.timestrx]       ;int    x
       push dword[HDC.timestrreHDC]   ;HDC    DC
        call dword[TextOutA@GDI32.DLL]


;Release the device context:
;;
 push dword clockrepaintSTRUCT   ;PAINTSTRUCT FAR *lpPS
 push dword[HWND.myhWnd1]        ;HWND hwnd
  call dword[EndPaint@USER32.DLL]

;;;END:  Paint the string with WinAPI
;;;END:  Paint the string with WinAPI
;;;END:  Paint the string with WinAPI


 popad
ret
