Subversion Repositories Kolibri OS

Rev

Rev 5093 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. include '../../../../proc32.inc'
  3.  
  4. struc system_colors
  5. {
  6.   .frame            dd ?
  7.   .grab             dd ?
  8.   .work_3d_dark      dd ?
  9.   .work_3d_light dd ?
  10.   .grab_text        dd ?
  11.   .work             dd ?
  12.   .work_button      dd ?
  13.   .work_button_text dd ?
  14.   .work_text        dd ?
  15.   .work_graph       dd ?
  16. }
  17.  
  18. use32
  19.  
  20. db 'MENUET01'
  21. dd 1
  22. dd start
  23. dd i_end
  24. dd mem
  25. dd mem
  26. dd 0
  27. dd 0
  28.  
  29. include 'pixlib.inc'
  30.  
  31. align 4
  32. start:
  33.            call load_pxlib
  34.            test eax, eax
  35.            jz .fail
  36.  
  37.            sub esp, 1024
  38.  
  39.            mov eax, 9
  40.            mov ebx, esp
  41.            mov ecx, -1
  42.            int 0x40
  43.  
  44.            movzx ecx, word [esp+0x1E]
  45.            mov eax, 18
  46.            mov ebx, 21
  47.            int 0x40
  48.  
  49.            mov [slot], eax
  50.  
  51.            add esp, 1024
  52.  
  53.            mov  eax,48                      ; get system colors
  54.            mov  ebx,3
  55.            mov  ecx,sc
  56.            mov  edx,10*4
  57.            int 0x40
  58. .redraw:
  59.            call draw_window
  60.  
  61. .wait_event:
  62.  
  63.            mov eax, 18
  64.            mov ebx, 7
  65.            int 0x40
  66.            cmp eax, [slot]
  67.            jne .skip_draw
  68.  
  69.            sub esp, 1024
  70.  
  71.            mov eax, 9
  72.            mov ebx, esp
  73.            mov ecx, -1
  74.            int 0x40
  75.  
  76.            mov edx, [esp+0x22]; xwin
  77.            mov ecx, [esp+0x26]; ywin
  78.            add edx, [esp+0x36]
  79.            add ecx, [esp+0x3A]
  80.  
  81.            mov eax, [esp+0x3E]
  82.            mov ebx, [esp+0x42]
  83.  
  84.            add esp, 1024
  85.  
  86.            test eax, eax
  87.            jle .skip_draw
  88.            test ebx, ebx
  89.            jle .skip_draw
  90.  
  91.            push ebx
  92.            push eax
  93.            push ecx
  94.            push edx
  95.            call _Draw
  96.            add esp, 16
  97.  
  98. .skip_draw:
  99.  
  100.         ;   mov ebx, 1
  101.         ;   mov eax, 23
  102.         ;   int 0x40
  103.  
  104.            mov eax, 11
  105.            int 0x40
  106.  
  107.            dec eax                     ;   if event = 1
  108.           js .wait_event
  109.  
  110.            jz  .redraw                 ;   jump to redraw handler
  111.            dec eax                     ;   else if event = 2
  112.            jz  .key                    ;   jump to key handler
  113.            dec eax
  114.            jz  .button
  115.  
  116.            jmp .wait_event
  117.  
  118. .button:                               ; button event handler
  119.            mov al, 17                  ;   get button identifier
  120.            int 0x40
  121.  
  122.            cmp ah, 1
  123.            jne .wait_event             ;   return if button id != 1
  124. .exit:
  125.                                        ; restore old screen and cleanup
  126. .fail:
  127.            or eax, -1                  ;   exit application
  128.            int 0x40
  129. .key:                                  ; key event handler
  130.            mov al, 2                   ;   get key code
  131.            int 0x40
  132.  
  133.            jmp .wait_event
  134.  
  135. draw_window:
  136.            mov eax, 12                 ; start drawing
  137.            mov ebx, 1
  138.            int 0x40
  139.  
  140.            xor  eax, eax               ; create and draw the window
  141.            mov  ebx, 100*65536+320     ; (window_cx)*65536+(window_sx)
  142.            mov  ecx, 100*65536+240     ; (window_cy)*65536+(window_sy)
  143.            mov  edx, [sc.work]         ; work area color
  144.            or   edx, 0x33000000        ; & window type 3
  145.            mov  edi, title             ; window title
  146.            int  0x40
  147.  
  148.            mov  eax, 12                ; finish drawing
  149.            mov  ebx, 2
  150.            int  0x40
  151.  
  152.            ret
  153.  
  154. DWORD equ dword
  155. PTR   equ
  156.  
  157. _Draw:
  158.         push    ebp
  159.         xor     edx, edx
  160.         push    edi
  161.         push    esi
  162.         push    ebx
  163.         sub     esp, 44
  164.         imul    eax, DWORD PTR [_glSeed], 69069
  165.         mov     ebp, DWORD PTR [esp+72]
  166.         mov     ecx, DWORD PTR [esp+76]
  167.         inc     eax
  168.         mov     DWORD PTR [esp+32], eax
  169.         imul    eax, eax, 69069
  170.         inc     eax
  171.         mov     DWORD PTR [esp+36], eax
  172.         imul    eax, eax, 69069
  173.         inc     eax
  174.         mov     DWORD PTR [esp+40], eax
  175.         imul    eax, eax, 69069
  176.         lea     ebx, [eax+1]
  177.         mov     eax, ebx
  178.         div     ebp
  179.         imul    eax, ebx, 69069
  180.         lea     ebx, [eax+1]
  181.         mov     eax, ebx
  182.         mov     edi, edx
  183.         xor     edx, edx
  184.         div     ecx
  185.         imul    eax, ebx, 69069
  186.         lea     ebx, [eax+1]
  187.         mov     eax, ebx
  188.         mov     esi, edx
  189.         xor     edx, edx
  190.         div     ebp
  191.         imul    eax, ebx, 69069
  192.         inc     eax
  193.         mov     DWORD PTR [_glSeed], eax
  194.         mov     ebp, edx
  195.         mov     DWORD PTR [esp+28], edx
  196.         xor     edx, edx
  197.         div     ecx
  198.         cmp     ebp, edi
  199.         mov     ebx, edx
  200.         jge     L2
  201.         mov     DWORD PTR [esp+28], edi
  202.         mov     edi, ebp
  203. L2:
  204.         cmp     ebx, esi
  205.         jge     L4
  206.         mov     ebx, esi
  207.         mov     esi, edx
  208. L4:
  209.         push    eax
  210.         mov     ecx, 255
  211.         push    -16777216
  212.         mov     eax, DWORD PTR [esp+40]
  213.         xor     edx, edx
  214.         div     ecx
  215.         mov     eax, DWORD PTR [esp+48]
  216.         mov     ebp, edx
  217.         xor     edx, edx
  218.         div     ecx
  219.         mov     eax, DWORD PTR [esp+44]
  220.         sal     ebp, 16
  221.         or      ebp, -16777216
  222.         mov     DWORD PTR [esp+8], edx
  223.         or      ebp, edx
  224.         xor     edx, edx
  225.         div     ecx
  226.         lea     eax, [ebx+1]
  227.         sub     eax, esi
  228.         sal     edx, 8
  229.         or      ebp, edx
  230.         push    ebp
  231.         push    eax
  232.         mov     eax, DWORD PTR [esp+44]
  233.         inc     eax
  234.         sub     eax, edi
  235.         push    eax
  236.         mov     eax, esi
  237.         add     eax, DWORD PTR [esp+88]
  238.         push    eax
  239.         mov     eax, edi
  240.         add     eax, DWORD PTR [esp+88]
  241.         push    eax
  242.         push    -1
  243.         call    [imp_DrawRect]
  244.         add     esp, 76
  245.         pop     ebx
  246.         pop     esi
  247.         pop     edi
  248.         pop     ebp
  249.         ret
  250. align 4
  251.  
  252. count       dd  0
  253. _glSeed     dd  -365387184
  254.  
  255. title       db  'Draw rect demo',0
  256.  
  257. i_end:
  258.  
  259. align 4
  260.  
  261. slot         rd 1
  262.  
  263. sc   system_colors
  264.  
  265. align 16
  266.  
  267.  
  268. rb 2048  ;stack
  269. mem:
  270.  
  271.