Subversion Repositories Kolibri OS

Rev

Rev 2027 | 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. include "aspapi.inc"
  19. SCREEN_WIDTH   equ    100h
  20. SCREEN_HEIGHT  equ    100h
  21.  
  22.  
  23. STARTAPP:
  24.  
  25.   mov  eax, 18    ;Get CPU speed
  26.   mov  ebx, 5
  27.   int  0x40
  28.   shr  eax, 28
  29.   mov  dword [delay], eax
  30.  
  31. init_palette:
  32.   mov  edi, Paleta
  33.   ;xor  eax, eax
  34.   mov  eax, 0x40
  35. @@:
  36.   stosd
  37.   inc  al
  38.   jnz  @b
  39.  
  40. MAIN:
  41. l1:
  42.   xor  esi, esi
  43. l11:
  44.   xor  ebx, ebx
  45.   mov  edx, 303h
  46.   sub  esi, 101h
  47. l2:
  48.   and  esi, 0xFFFF ;esi=si
  49.   add  bl,  [esi+img]
  50.   adc  bh,  ah
  51.   inc  esi
  52.   dec  dh
  53.   jnz  l2
  54.  
  55.   mov  dh, 3
  56.   add  esi, 100h-3
  57.   dec  dl
  58.   jnz  l2
  59.   sub  esi, 1ffh
  60.   and  esi, 0xFFFF ;esi=si
  61.  
  62.   mov  al, [img+esi]
  63.   sub  bx, ax
  64.   shl  ax, 2
  65.   sub  bx, ax
  66.   shr  bx, 2
  67.  
  68.   mov  ax, bx
  69.   shr  ax, 7
  70.   sub  bx, ax
  71.   mov  [img+esi], bl
  72.   inc  si
  73.   jnz  l11
  74.  
  75.   call  copy_buffer_to_video
  76.  
  77.  
  78. still:
  79.         mov     eax, 11             ; Test if there is an event in the queue.
  80.         int     0x40
  81.  
  82.         cmp     al,1                  ; redraw request ?
  83.         jz      red
  84.         cmp     al,2                  ; key in buffer ?
  85.         jz      key
  86.         cmp     al,3                  ; button in buffer ?
  87.         jz      button
  88.  
  89.         jmp     MAIN
  90.  
  91. red:
  92.         call    draw_window
  93.         jmp     MAIN
  94.  
  95.  
  96. key:
  97.         mov     eax, 2
  98.         int     0x40
  99.         cmp     ah, 27              ; Test Esc in ASCII
  100.         je      close_app
  101.         jmp     MAIN
  102.  
  103. button:
  104.         mov     eax, 17             ; Get pressed button code
  105.         int     0x40
  106.         cmp     ah, 1               ; Test x button
  107.         je      close_app
  108.         jmp     MAIN
  109.  
  110. draw_window:
  111.         start_draw_window 100,70,SCREEN_WIDTH+9,SCREEN_HEIGHT+4,0x54224466,labelt;, 14;labellen-labelt
  112.         mov     dword [skin_h], eax
  113.         end_draw_window
  114. ret
  115.  
  116.  
  117. fail:
  118.         ; Type something here.
  119. close_app:
  120.         mov     eax, -1  ; close this program
  121.         int     0x40
  122.  
  123.  
  124.  
  125. copy_buffer_to_video:
  126.         pusha
  127.     ;    mov     eax, 18 ;@WAITVSYNC();
  128.     ;    mov     ebx, 14
  129.     ;    int     0x40
  130.         mov     eax, 5  ;delay
  131.         mov     ebx, dword [delay]
  132.         int     0x40
  133.  
  134.         mov     eax, dword [skin_h]
  135.         lea     edx, [5*65536+eax]
  136.  
  137.         mov     eax, 65
  138.         mov     ebx, img
  139.         mov     ecx, SCREEN_WIDTH*65536+SCREEN_HEIGHT ;ecx = w*65536+h
  140.        ; mov     edx, 5*65536+25 ;edx = x*65536+y
  141.         mov     esi, 8
  142.         mov     edi, Paleta
  143.         xor     ebp, ebp
  144.         int     0x40
  145.         popa
  146. ret
  147.  
  148. ; DATA AREA
  149.  
  150. ; Application Title
  151. labelt   db   'UnvWater demo',0
  152. delay    dd   0
  153. skin_h   dd   25 ; Skin height.
  154.  
  155. I_END:
  156. Paleta   rb 1024
  157. img      db 1
  158.          rb 10000h
  159.  
  160.