Subversion Repositories Kolibri OS

Rev

Rev 6196 | 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_dark        dd ?
  9.   .work_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. macro _read_file path, offset, data, count
  19. {
  20.    mov eax, dword path
  21.    mov ebx, dword data
  22.    mov ecx, dword offset
  23.    mov edx, dword count
  24.  
  25.    push 0
  26.    push 0
  27.    mov [esp+1], eax
  28.    push ebx
  29.    push edx
  30.    push 0
  31.    push ecx
  32.    push 0
  33.    mov ebx, esp
  34.    mov eax, 70
  35.    int 0x40
  36.    add esp, 28
  37. }
  38.  
  39. use32
  40.  
  41. db 'MENUET01'
  42. dd 1
  43. dd start
  44. dd i_end
  45. dd mem
  46. dd mem
  47. dd 0
  48. dd app_path
  49.  
  50. include 'pixlib.inc'
  51.  
  52. align 4
  53. start:
  54.            fix_cwd app_path
  55.  
  56.            call load_pxlib
  57.            test eax, eax
  58.            jz .fail
  59.  
  60.            mov  eax,48                      ; get system colors
  61.            mov  ebx,3
  62.            mov  ecx,sc
  63.            mov  edx,10*4
  64.            int 0x40
  65.  
  66.            CreatePixmap 640, 384, ARGB32, PX_MEM_LOCAL   ; animation
  67.            mov [pix_0], eax
  68.            test eax, eax
  69.            jz .fail
  70.  
  71.            CreatePixmap 64, 64, ARGB32, PX_MEM_LOCAL     ; saved screen
  72.            mov [pix_1], eax
  73.            test eax, eax
  74.            jz .fail
  75.  
  76.            CreatePixmap 64, 64, ARGB32, PX_MEM_LOCAL     ; back buffer
  77.            mov [pix_2], eax
  78.  
  79.            Blit [pix_1], 0,0, SCR_PIXMAP, 0,0, 64,64
  80.  
  81.            LockPixmap [pix_0]
  82.               mov ebx, eax
  83.               _read_file szfile, 128, ebx, 640*384*4
  84.            UnlockPixmap [pix_0]
  85.  
  86.  
  87. .redraw:
  88.            call draw_window
  89.  
  90. .wait_event:
  91.  
  92.            mov ebx, 2
  93.            mov eax, 23
  94.            int 0x40
  95.  
  96.  
  97.            dec eax                  ;   if event = 1
  98.            jz  .redraw              ;   jump to redraw handler
  99.            dec eax                  ;   else if event = 2
  100.            jz  .key                 ;   jump to key handler
  101.            dec eax
  102.            jz  .button
  103.  
  104.            Blit   [pix_2], 0,0, [pix_1], 0,0, 64,64
  105.  
  106.            mov eax, [count]
  107.            inc eax
  108.            cmp eax, 60
  109.            jb @F
  110.            xor eax, eax
  111. @@:
  112.            mov [count], eax
  113.  
  114.            xor edx, edx
  115.            mov ebx, 10
  116.            div ebx
  117.  
  118.            shl eax, 6
  119.            shl edx, 6
  120.  
  121.            TransparentBlit [pix_2], 0,0, [pix_0], edx,eax, 64,64 ,0xFF000000
  122.            Blit SCR_PIXMAP, 0,0, [pix_2], 0, 0, 64,64
  123.  
  124.            jmp .wait_event
  125.  
  126. .button:                               ; button event handler
  127.            mov al, 17                  ;   get button identifier
  128.            int 0x40
  129.  
  130.            cmp ah, 1
  131.            jne .wait_event             ;   return if button id != 1
  132. .exit:
  133.                                        ; restore old screen and cleanup
  134.  
  135.            Blit SCR_PIXMAP, 0,0, [pix_1], 0, 0, 64,64
  136.  
  137.            DestroyPixmap [pix_2]
  138.            DestroyPixmap [pix_1]
  139.            DestroyPixmap [pix_0]
  140. .fail:
  141.            or eax, -1                  ;   exit application
  142.            int 0x40
  143. .key:                                  ; key event handler
  144.            mov al, 2                   ;   get key code
  145.            int 0x40
  146.  
  147.            jmp .wait_event
  148.  
  149. draw_window:
  150.            mov eax, 12                 ; start drawing
  151.            mov ebx, 1
  152.            int 0x40
  153.  
  154.            xor  eax, eax               ; create and draw the window
  155.            mov  ebx, 200*65536+200     ; (window_cx)*65536+(window_sx)
  156.            mov  ecx, 200*65536+100     ; (window_cy)*65536+(window_sy)
  157.            mov  edx, [sc.work]         ; work area color
  158.            or   edx, 0x33000000        ; & window type 3
  159.            mov  edi, title             ; window title
  160.            int  0x40
  161.  
  162.            mov  eax, 12                ; finish drawing
  163.            mov  ebx, 2
  164.            int  0x40
  165.  
  166.            ret
  167.  
  168. align 4
  169.  
  170. count       dd  0
  171.  
  172. title       db  'Transparent blit',0
  173.  
  174. szfile      db  'donut.dds',0
  175.  
  176. i_end:
  177.  
  178. align 4
  179.  
  180. pix_0       rd 1
  181. pix_1       rd 1
  182. pix_2       rd 1
  183.  
  184. sc   system_colors
  185.  
  186.  
  187. align 4
  188.  
  189. app_path:
  190.  
  191. rb 2048 ; stack
  192. mem:
  193.  
  194.