Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. use32
  2.     org 0x0
  3.     db  'MENUET01'
  4.     dd  0x01,start,i_end,e_end,e_end,0,0
  5.  
  6. include '../../proc32.inc'
  7. include '../../macros.inc'
  8.  
  9.  
  10. NUMCOLORS = 148         ; CSS4 named colors (http://dev.w3.org/csswg/css-color/)
  11.  
  12.  
  13. start:
  14.         mcall   66, 1, 1        ; set kbd mode to scancodes
  15. still:
  16.         mcall   10
  17.         dec     eax
  18.         jz      redraw
  19.         dec     eax
  20.         jz      key
  21.  
  22. button:
  23.         mcall   17
  24.         shr     eax, 8
  25.  
  26.         cmp     eax, 1
  27.         jz      quit
  28.         jmp     still
  29.  
  30. redraw:
  31.         mcall   12, 1
  32.  
  33.         mov     ebx, [window.left]
  34.         shl     ebx, 16
  35.         add     ebx, [window.width]
  36.         mov     ecx, [window.top]
  37.         shl     ecx, 16
  38.         add     ecx, [window.height]
  39.         mcall   0, , , [window_style], , window_title
  40.         mcall   9, proc_info, -1
  41.  
  42.  
  43.         mov     eax, [current_color]
  44.         mov     ebx, [proc_info.client_box.width]
  45.         inc     ebx
  46.         mov     ecx, [proc_info.client_box.height]
  47.         inc     ecx
  48.         or      edx, [colors + eax*4]
  49.         mcall   13, , ,
  50.  
  51.         mov     eax, [current_color]
  52.         movzx   edx, byte[colors + eax*4 + 0]
  53.         add     dl, byte[colors + eax*4 + 1]
  54.         adc     dh, 0
  55.         add     dl, byte[colors + eax*4 + 2]
  56.         adc     dh, 0
  57.         xor     ecx, ecx
  58.         cmp     edx, 0x80*3
  59.         jae     @f
  60.         add     ecx, 0xffffff
  61.     @@:
  62.         movzx   edx, [names + eax*2]
  63.         movzx   esi, byte[edx]
  64.         inc     edx
  65.         lea     eax, [esi*3]
  66.         add     eax, eax
  67.  
  68.         mov     ebx, [proc_info.client_box.width]
  69.         sub     ebx, eax
  70.         inc     ebx
  71.         shr     ebx, 1
  72.         shl     ebx, 16
  73.         add     ebx, [proc_info.client_box.height]
  74.         sub     ebx, 9
  75.         shr     bx, 1
  76.  
  77.         mcall   4, , ,
  78.  
  79.         mcall   12, 2
  80.         jmp     still
  81.  
  82. key:
  83.         mcall   2
  84.         cmp     ah, 63  ; f5
  85.         jnz     @f
  86.         call    toggle_fullscreen
  87.         jmp     redraw
  88.     @@:
  89.         cmp     ah, 1   ; esc
  90.         jnz     @f
  91.         bt      [window_style], 25
  92.         jc      quit
  93.         call    toggle_fullscreen
  94.         jmp     redraw
  95.     @@:
  96.         cmp     ah, 72  ; up
  97.         jz      .prev
  98.         cmp     ah, 75  ; left
  99.         jz      .prev
  100.         cmp     ah, 73  ; page up
  101.         jz      .prev
  102.         cmp     ah, 77  ; right
  103.         jz      .next
  104.         cmp     ah, 80  ; down
  105.         jz      .next
  106.         cmp     ah, 81  ; page down
  107.         jz      .next
  108.         jmp     still
  109.  
  110. .prev:
  111.         dec     [current_color]
  112.         jns     @f
  113.         mov     [current_color], NUMCOLORS - 1
  114.     @@:
  115.         jmp     redraw
  116.  
  117. .next:
  118.         inc     [current_color]
  119.         cmp     [current_color], NUMCOLORS
  120.         jnz     @f
  121.         mov     [current_color], 0
  122.     @@:
  123.         jmp     redraw
  124.  
  125.  
  126. toggle_fullscreen:
  127.         btc     [window_style], 25
  128.         jc      .fullscreen
  129.         ; back from fullscreen
  130.         mcall   67, [window.left], [window.top], [window.width], [window.height]
  131.         jmp     .done
  132.   .fullscreen:
  133.         mov     eax, [proc_info.box.width]
  134.         mov     [window.width], eax
  135.         mov     eax, [proc_info.box.height]
  136.         mov     [window.height], eax
  137.         mov     eax, [proc_info.box.left]
  138.         mov     [window.left], eax
  139.         mov     eax, [proc_info.box.top]
  140.         mov     [window.top], eax
  141.         mcall   14
  142.         mov     edx, eax
  143.         shr     edx, 16
  144.         movzx   eax, ax
  145.         mov     esi, eax
  146.         mcall   67, 0, 0, ,
  147.   .done:
  148.         ret
  149.  
  150. quit:
  151.         mcall   -1
  152.  
  153.  
  154. window_title    db 'Rainbow',0
  155. window_style    dd 0x73000000
  156. window          BOX 300, 300, 315, 184  ; left top width height
  157. current_color   dd 0
  158.  
  159. align 4
  160. include 'colors.asm'    ; generated data
  161.  
  162. i_end:
  163. proc_info               process_information
  164. rb 0x100                                        ;stack
  165. e_end:
  166.