Subversion Repositories Kolibri OS

Rev

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

  1. include "lang.inc"
  2. include "../../../macros.inc"
  3.  
  4. WND_SIZE_X              = 320
  5. WND_SIZE_Y              = 200
  6.  
  7. VC_DELTA = 1
  8. HC_DELTA = 2
  9.  
  10. MEOS_APP_START
  11. CODE
  12.     fninit
  13.     call init_sinus_table
  14.     call init_background
  15.     call init_palette
  16.     mov eax,40
  17.     mov ebx,101b
  18.     mcall
  19.     jmp .paint_window
  20.  
  21. .event_loop:
  22.     mov eax,23
  23.     mov ebx,1
  24.     mcall
  25.  
  26.     test eax,eax
  27.     je .draw_screen
  28.     dec eax
  29.     je .paint_window
  30.  
  31.     or  eax,-1
  32.     mcall
  33.  
  34. .draw_screen:
  35.     test [proc_info.wnd_state], 0x04
  36.     jnz .event_loop
  37.     add word [ver_counter],VC_DELTA
  38.     add word [hor_counter],HC_DELTA
  39.     call handle_animation
  40.     xor ebp,ebp
  41.     mcall 65,virtual_screen_8,<WND_SIZE_X,WND_SIZE_Y>,<0,0>,8,_palette
  42.     jmp .event_loop
  43.  
  44. .paint_window:
  45.         mcall   9,proc_info,-1
  46.     mov eax,12
  47.     mov ebx,1
  48.     mcall
  49.  
  50.     mcall 48,4 ; get skin height
  51.     lea ecx,[eax + (100 shl 16) + WND_SIZE_Y+4]
  52.     mov edi,title
  53.     mcall 0,<100,WND_SIZE_X+9>,,0x74000000
  54.  
  55.     test [proc_info.wnd_state], 0x04
  56.     jnz @f
  57.  
  58.     xor ebp,ebp
  59.     mcall 65,virtual_screen_8,<WND_SIZE_X,WND_SIZE_Y>,<0,0>,8,_palette
  60.   @@:
  61.     mov eax,12
  62.     mov ebx,2
  63.     mcall
  64.  
  65.     jmp .event_loop
  66.  
  67. init_palette:
  68.     mov ecx,256
  69.     mov edi,_palette
  70.     xor eax,eax
  71. .next_pal:
  72.     mov al,ah
  73.     shr al,2
  74.     stosb
  75.     stosb
  76.     stosb
  77.     stosb
  78.     inc ah
  79.     loop .next_pal
  80.     ret
  81.  
  82. init_sinus_table:
  83.     sub esp,4
  84.     mov ecx,256
  85.     mov edi,sinetable
  86. .sin_loop:
  87.     fld dword [esp]
  88.     fld st0
  89.     fsin
  90.     fmul [scale_sin]
  91.     fistp word [edi]
  92.     fadd [delta_angle]
  93.     fstp dword [esp]
  94.     add edi,2
  95.     loop .sin_loop
  96.     add esp,4
  97.     ret
  98.  
  99. init_background:
  100.     mov edi,background
  101.     xor edx,edx
  102. .ib_vertical:
  103.     xor ecx,ecx
  104. .ib_horizontal:
  105.     mov eax,ecx
  106.     xor eax,edx
  107.     stosb
  108.     inc ecx
  109.     cmp ecx,256
  110.     jne .ib_horizontal
  111.     inc edx
  112.     cmp edx,256
  113.     jne .ib_vertical
  114.     ret
  115.  
  116. s_OFFX          = 0
  117. s_OFFY          = 2
  118.  
  119. handle_animation:
  120.     sub esp,4
  121.     mov ebx,[ver_counter]
  122.     and ebx,255
  123.     add ebx,ebx
  124.     mov ax,[sinetable+ebx]
  125.     mov [esp+s_OFFY],ax
  126.     mov ebx,[hor_counter]
  127.     and ebx,255
  128.     add ebx,ebx
  129.     mov ax,[sinetable+ebx]
  130.     mov [esp+s_OFFX],ax
  131.     mov edi,virtual_screen_8
  132.     mov edx,WND_SIZE_Y-1
  133. .a_ver:
  134.     mov ecx,WND_SIZE_X-1
  135.     mov bx,[esp+s_OFFY]
  136.     add bx,dx
  137.     and ebx,255
  138.     shl ebx,8
  139. .a_hor:
  140.     mov ax,[esp+s_OFFX]
  141.     add ax,cx
  142.     and eax,255
  143.     mov al,[background+ebx+eax]
  144.     stosb
  145.     dec ecx
  146.     jge .a_hor
  147.     dec edx
  148.     jge .a_ver
  149.     add esp,4
  150.     ret
  151.  
  152. DATA
  153.   delta_angle dd 0.0245436926066                ; pi/128
  154.   scale_sin dd 128.0
  155.  
  156.   title      db 'MoveBack',0
  157.  
  158. UDATA
  159.   ver_counter dd ?
  160.   hor_counter dd ?
  161.  
  162.   _palette:     rd 256
  163.  
  164.   virtual_screen_8:
  165.         rb WND_SIZE_X*WND_SIZE_Y
  166.  
  167.   background:
  168.         rb 256*256
  169.  
  170.   sinetable:
  171.         rw 256
  172.  
  173.   proc_info     process_information
  174.  
  175. MEOS_APP_END
  176.