Subversion Repositories Kolibri OS

Rev

Rev 3337 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
  4. ;; Distributed under terms of the GNU General Public License       ;;
  5. ;;                                                                 ;;
  6. ;;                                                                 ;;
  7. ;;         GNU GENERAL PUBLIC LICENSE                              ;;
  8. ;;          Version 2, June 1991                                   ;;
  9. ;;                                                                 ;;
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11.  
  12.  
  13. window_create:
  14.  
  15. ; allocate the window data block
  16.         mcall   68, 12, sizeof.window_data
  17.         test    eax, eax
  18.         jz      .fail
  19.  
  20. ; fill it with all zeros
  21.         push    eax
  22.         mov     edi, eax
  23.         mov     ecx, (sizeof.window_data+3)/4
  24.         xor     eax, eax
  25.         rep     stosd
  26.         pop     eax
  27.  
  28.   .fail:
  29.         ret
  30.  
  31.  
  32. window_set_name:    ; esi = ptr to name, ebx = window ptr
  33.  
  34.         pusha
  35.  
  36. ; Skip heading spaces
  37.   .spaceloop:
  38.         cmp     byte[esi], ' '
  39.         jne     .done
  40.         inc     esi
  41.         jmp     .spaceloop
  42.   .done:
  43.  
  44. ; Now copy it
  45.         lea     edi, [ebx + window.name]
  46.         mov     ecx, MAX_WINDOWNAME_LEN
  47.   .loop:
  48.         lodsb
  49.         cmp     al, 0x21
  50.         jbe     .addzero
  51.         stosb
  52.         dec     ecx
  53.         jnz     .loop
  54.   .addzero:
  55.         xor     al, al
  56.         stosb
  57.  
  58.         call    draw_windownames        ; redraw it
  59.  
  60.         popa
  61.  
  62.         ret
  63.  
  64.  
  65.  
  66. window_refresh:
  67.  
  68. ; set the correct buffer pointers       ; FIXME: what is it good for?
  69.         mov     eax, [textbox_width]    ;
  70.         imul    eax, 11                 ;
  71.         mov     [pos], eax              ;
  72.  
  73.         mov     eax, [window_print]
  74.         mov     eax, [eax + window.data_ptr]
  75.         add     eax, window_data.text
  76.         mov     [text_start], eax
  77.  
  78.         ret
  79.  
  80.  
  81. window_updated:
  82.  
  83.         mov     edi, [window_print]
  84.         test    [edi + window.flags], FLAG_UPDATED
  85.         jnz     .skip
  86.  
  87.         or      [edi + window.flags], FLAG_UPDATED
  88.  
  89. ; now play a sound :)
  90.  
  91.   .skip:
  92.  
  93.         ret
  94.  
  95.  
  96. print_text:                             ; eax = start ptr
  97.                                         ; dl = end char
  98.         pusha
  99.   ptr2:
  100.         mov     bl, [eax]
  101.  
  102.         cmp     bl, dl
  103.         je      ptr_ret
  104.         cmp     bl, 0
  105.         je      ptr_ret
  106.         call    print_character
  107.  
  108.         inc     eax
  109.         jmp     ptr2
  110.  
  111.   ptr_ret:
  112.         popa
  113.         ret
  114.  
  115.  
  116. print_text2:                            ; esi = ptr to ASCIIZ string
  117.  
  118.         pusha
  119.   .loop:
  120.         lodsb
  121.         test    al, al
  122.         jz      .done
  123.         mov     bl, al
  124.         call    print_character
  125.         jmp     .loop
  126.  
  127.   .done:
  128.         popa
  129.         ret
  130.  
  131.  
  132. if TIMESTAMP
  133. print_timestamp:
  134.  
  135.         pusha
  136.         mcall   3                       ; get system time
  137.  
  138.         mov     bl, '['
  139.         call    print_character
  140.         mov     ecx, TIMESTAMP
  141.   .loop:
  142.         mov     bl, al
  143.         shr     bl, 4
  144.         add     bl, '0'
  145.         call    print_character
  146.  
  147.         mov     bl, al
  148.         and     bl, 0x0f
  149.         add     bl, '0'
  150.         call    print_character
  151.  
  152.         dec     ecx
  153.         jz      .done
  154.  
  155.         mov     bl, ':'
  156.         call    print_character
  157.         shr     eax, 8
  158.         jmp     .loop
  159.   .done:
  160.         mov     bl, ']'
  161.         call    print_character
  162.         mov     bl, ' '
  163.         call    print_character
  164.  
  165.         popa
  166.         ret
  167. end if