Subversion Repositories Kolibri OS

Rev

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