Subversion Repositories Kolibri OS

Rev

Rev 9344 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; A unvwater demo
  3. ; Programmed by Octavio Vega Fernandez
  4. ; http://octavio.vega.fernandez.googlepages.com/CV4.HTM
  5. ; Converted to KolibriOS, By Asper
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. use32
  9.         org     0x0
  10.  
  11.         db     'MENUET01'        ; header
  12.         dd     1                 ; version
  13.         dd     STARTAPP          ; program start
  14.         dd     I_END             ; program image size
  15.         dd     MEM               ; size memory for program
  16.         dd     STACKTOP          ; pointer of stack
  17.         dd     0
  18.         dd     0
  19.  
  20. ;macro start_draw_window x,y,xsize,ysize,areacolor,caption;,capsize
  21. ;{
  22. ;        mov     eax, 12                 ; function 12:tell os about windowdraw
  23. ;        mov     ebx, 1                  ; 1, start of draw
  24. ;        int     0x40
  25. ;        ; DRAW WINDOW
  26. ;        mov     eax, 48                 ; function 48.4 : get skin height
  27. ;        mov     ebx, 4
  28. ;        int     0x40
  29. ;        push    eax
  30. ;        lea     ecx, [y*65536+ysize+eax]; [y start] *65536 + [y size] + [skin_height]
  31. ;        xor     eax, eax                ; function 0 : define and draw window
  32. ;        mov     ebx, x*65536+xsize      ; [x start] *65536 + [x size]
  33. ;        mov     edx, areacolor          ; color of work area RRGGBB
  34. ;        ;mov     esi, 0x00334455        ; color of grab bar  RRGGBB
  35. ;        mov     edi, caption;0x00ddeeff          ; color of frames    RRGGBB
  36. ;        int     0x40
  37. ;        pop     eax
  38. ;}
  39. ;
  40. ;macro end_draw_window
  41. ;{
  42. ;        mov     eax, 12                 ; end of redraw
  43. ;        mov     ebx, 2
  44. ;        int     0x40
  45. ;}
  46.  
  47. include "aspapi.inc"
  48. SCREEN_WIDTH   equ    100h
  49. SCREEN_HEIGHT  equ    100h
  50.  
  51.  
  52. STARTAPP:
  53.  
  54.   mov  eax, 18    ;Get CPU speed
  55.   mov  ebx, 5
  56.   int  0x40
  57.   shr  eax, 28
  58.   mov  dword [delay], eax
  59.  
  60. init_palette:
  61.   mov  edi, Paleta
  62.   ;xor  eax, eax
  63.   mov  eax, 0x40
  64. @@:
  65.   stosd
  66.   inc  al
  67.   jnz  @b
  68.  
  69. MAIN:
  70. l1:
  71.   xor  esi, esi
  72. l11:
  73.   xor  ebx, ebx
  74.   mov  edx, 303h
  75.   sub  esi, 101h
  76. l2:
  77.   and  esi, 0xFFFF ;esi=si
  78.   add  bl,  [esi+img]
  79.   adc  bh,  ah
  80.   inc  esi
  81.   dec  dh
  82.   jnz  l2
  83.  
  84.   mov  dh, 3
  85.   add  esi, 100h-3
  86.   dec  dl
  87.   jnz  l2
  88.   sub  esi, 1ffh
  89.   and  esi, 0xFFFF ;esi=si
  90.  
  91.   mov  al, [img+esi]
  92.   sub  bx, ax
  93.   shl  ax, 2
  94.   sub  bx, ax
  95.   shr  bx, 2
  96.  
  97.   mov  ax, bx
  98.   shr  ax, 7
  99.   sub  bx, ax
  100.   mov  [img+esi], bl
  101.   inc  si
  102.   jnz  l11
  103.  
  104.   call  copy_buffer_to_video
  105.  
  106.  
  107. still:
  108.         mov     eax, 11             ; Test if there is an event in the queue.
  109.         int     0x40
  110.  
  111.         cmp     al,1                  ; redraw request ?
  112.         jz      red
  113.         cmp     al,2                  ; key in buffer ?
  114.         jz      key
  115.         cmp     al,3                  ; button in buffer ?
  116.         jz      button
  117.  
  118.         jmp     MAIN
  119.  
  120. red:
  121.         call    draw_window
  122.         jmp     MAIN
  123.  
  124.  
  125. key:
  126.         mov     eax, 2
  127.         int     0x40
  128.         cmp     ah, 27              ; Test Esc in ASCII
  129.         je      close_app
  130.         jmp     MAIN
  131.  
  132. button:
  133.         mov     eax, 17             ; Get pressed button code
  134.         int     0x40
  135.         cmp     ah, 1               ; Test x button
  136.         je      close_app
  137.         jmp     MAIN
  138.  
  139. draw_window:
  140.         start_draw_window 100,70,SCREEN_WIDTH+9,SCREEN_HEIGHT+4,0x54224466,labelt;, 14;labellen-labelt
  141.         mov     dword [skin_h], eax
  142.         end_draw_window
  143. ret
  144.  
  145.  
  146. fail:
  147.         ; Type something here.
  148. close_app:
  149.         mov     eax, -1  ; close this program
  150.         int     0x40
  151.  
  152.  
  153.  
  154. copy_buffer_to_video:
  155.         pusha
  156.     ;    mov     eax, 18 ;@WAITVSYNC();
  157.     ;    mov     ebx, 14
  158.     ;    int     0x40
  159.         mov     eax, 5  ;delay
  160.         mov     ebx, dword [delay]
  161.         int     0x40
  162.  
  163.         mov     eax, dword [skin_h]
  164.         lea     edx, [5*65536+eax]
  165.  
  166.         mov     eax, 65
  167.         mov     ebx, img
  168.         mov     ecx, SCREEN_WIDTH*65536+SCREEN_HEIGHT ;ecx = w*65536+h
  169.        ; mov     edx, 5*65536+25 ;edx = x*65536+y
  170.         mov     esi, 8
  171.         mov     edi, Paleta
  172.         xor     ebp, ebp
  173.         int     0x40
  174.         popa
  175. ret
  176.  
  177. ; DATA AREA
  178.  
  179. ; Application Title
  180. labelt   db   'UnvWater demo',0
  181. delay    dd   0
  182. skin_h   dd   25 ; Skin height.
  183.  
  184. I_END:
  185. Paleta   rb 1024
  186. img      db 1
  187.          rb 10000h
  188.  
  189.          rb 256
  190. STACKTOP:
  191. MEM:
  192.