Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. thread:
  2.         call    draw_window
  3.         call    main_loop
  4.         mov     [status], ST_EXIT
  5.         mcall   MF_EXIT
  6.  
  7. ;---------------------------------------------------------------------
  8.  
  9. main_loop:
  10.         cmp     [status], ST_PLAY
  11.         je      @f
  12.         mcall   MF_WAIT_EVENT
  13.         jmp     .handle_event
  14.      @@:
  15.         call    draw_progress_bar
  16.         mcall   MF_WAIT_EVENT_TIMEOUT, 80
  17.      .handle_event:
  18.         cmp     eax, EV_REDRAW
  19.         je      redraw
  20.         cmp     eax, EV_BUTTON
  21.         je      button
  22.         cmp     eax, EV_KEY
  23.         je      key
  24.         jmp     main_loop
  25.  
  26.  redraw:
  27.         call    draw_window
  28.         jmp     main_loop
  29.  
  30.  key:
  31.         mcall   MF_GETKEY
  32.         cmp     [textbox_active], 1
  33.         jne     main_loop
  34.         cmp     ah, 13
  35.         je      .enter
  36.         cmp     ah, 8
  37.         je      .backspace
  38.         movzx   ecx, [textbox_position]
  39.         cmp     ecx, 47
  40.         jae     .enter
  41.         mov     [textbox_string + ecx], ah
  42.         inc     [textbox_position]
  43.         call    textbox_draw
  44.         jmp     main_loop
  45.   .enter:
  46.         mov     [textbox_active], 0
  47.         call    textbox_draw
  48.         jmp     main_loop
  49.   .backspace:
  50.         movzx   ecx, [textbox_position]
  51.         test    ecx, ecx
  52.         jz      main_loop
  53.         mov     [textbox_string + ecx], byte 0
  54.         dec     [textbox_position]
  55.         call    textbox_draw
  56.         jmp     main_loop
  57.  
  58.  button:
  59.         mcall   MF_GETBUTTON
  60.         cmp     ah, 0x10
  61.         je      play_button
  62.         cmp     ah, 0x11
  63.         je      stop_button
  64.         cmp     ah, 0x12
  65.         je      decr_button
  66.         cmp     ah, 0x13
  67.         je      incr_button
  68.         cmp     ah, 0x14
  69.         je      volm_button
  70.         cmp     ah, 0x15
  71.         je      volp_button
  72.         cmp     ah, 0x20
  73.         je      activate_textbox
  74.         cmp     ah, 0x30
  75.         je      progressbar_click
  76.         cmp     ah, 1
  77.         jne     main_loop
  78.  
  79. ;        mov     [status], ST_STOP
  80. ;        mcall   MF_DELAY, 40
  81.         ret
  82.  
  83.     play_button:
  84.         xor     eax, eax
  85.         xchg    al, [textbox_active]
  86.         cmp     al, 0
  87.         je      @f
  88.         call    textbox_draw
  89.       @@:
  90.         mov     [status], ST_PLAY
  91.         jmp     main_loop
  92.     stop_button:
  93.         mov     [status], ST_STOP
  94.         jmp     main_loop
  95.  
  96.     decr_button:
  97. ;        mov     [status], ST_STOP
  98. ;       @@:
  99. ;        mcall   5, 1
  100. ;        cmp     [status], ST_DONE
  101. ;        jne     @b
  102. ;        movzx   esi, [textbox_position]
  103. ;        add     esi, textbox_string
  104. ;       @@:
  105. ;        cmp     byte [esi], '/'
  106. ;        je      @f
  107. ;        dec     esi
  108. ;        jmp     @b
  109. ;       @@:
  110. ;        mov     byte [esi+1], 0
  111. ;        mov     [fileinfo.first_block], 0
  112. ;        mov     [fileinfo.dest], WAV_BUFFER1
  113. ;        mcall   58, fileinfo
  114. ;        add     ebx, WAV_BUFFER1
  115. ;        mov     esi, WAV_BUFFER1+8
  116. ;      .next_file:
  117. ;        cmp     ebx, esi
  118. ;        jbe     .fin
  119. ;        cmp     word [esi], "WA"
  120. ;        jne     .next_file
  121. ;        cmp     byte [esi+1], "V"
  122. ;        jne     .next_file
  123. ;      .fin:
  124.  
  125.         ;mov     eax, [fileinfo.first_block]
  126.         ;cmp     eax, 1000
  127.         ;jnl     @f
  128.         ;mov     [fileinfo.first_block], 0
  129.         ;jmp     main_loop
  130.        ;@@:
  131.         ;sub     [fileinfo.first_block], 1000
  132.         ;jmp     main_loop
  133.  
  134.     incr_button:
  135.         ;add     [fileinfo.first_block], 1000
  136.         jmp     main_loop
  137.  
  138.     volm_button:
  139.         inc     byte [volume]
  140.         and     byte [volume], 0x1f
  141.         jz      volp_button
  142.         or      [volume], 0x10000000
  143.         jmp     _print_volume
  144. ;        jmp     main_loop
  145.  
  146.     volp_button:
  147.         dec     byte [volume]
  148.         and     byte [volume], 0x1f
  149.         jz      volm_button
  150.         or      [volume], 0x10000000
  151. ;        jmp     main_loop
  152.  
  153.     _print_volume:
  154.         movzx   eax, byte [volume]
  155.         neg     eax
  156.         add     eax, 31
  157.         dps     "Volume: "
  158.         dpd     eax
  159.         newline
  160.         jmp     main_loop
  161.  
  162.     activate_textbox:
  163.         cmp     [status], ST_DONE
  164.         jne     main_loop
  165.         mov     [textbox_active], 1
  166.         call    textbox_draw
  167.         jmp     main_loop
  168.  
  169.     progressbar_click:
  170.         ;print  "click on progress bar"
  171.         cmp     [status], ST_DONE
  172.         je      main_loop
  173.         mcall   MF_GETMOUSE, MS_COORDS_WINDOW
  174.         shr     eax, 16 ; get mouse.x
  175.         sub     eax, 7
  176.         test    eax, eax
  177.         jz      @f
  178.         imul    eax, [file_size]
  179.         mov     ebx, 286
  180.         cdq
  181.         div     ebx
  182.      @@:
  183.         ;dps "block: "
  184.         ;dpd eax
  185.         ;newline
  186.         mov     [fileinfo.first_block], eax
  187.         call    draw_progress_bar
  188.         jmp     main_loop
  189. ret
  190.  
  191. ;---------------------------------------------------------------------
  192.  
  193. PBAR_WIDTH = 286
  194.  
  195. draw_window:
  196.         mcall   MF_DRAWSTATUS, DS_BEGIN
  197.  
  198.         mcall   MF_WINDOW, <100,299>, <100,72>, 0x03404040
  199.  
  200.         ; create six buttons
  201.         mov     edi, 6
  202.         mpack   ebx, 7, 45
  203.         mpack   ecx, 24, 13
  204.         mov     edx, 0x10
  205.         mov     esi, 0xA0A0A0
  206.       @@:
  207.         mcall   MF_BUTTON
  208.         add     ebx, 48 shl 16
  209.         inc     edx
  210.         dec     edi
  211.         jnz     @b
  212.  
  213.         mcall   MF_TEXT, <8,8>, 0x10FFFFFF, header, header.size
  214.  
  215.         mcall   ,<13,28>, 0x404040, buttons_text, buttons_text.size
  216.         sub     ebx, 0x00010001
  217.         mov     ecx, 0xFFFFFF
  218.         mcall
  219.  
  220.         call    draw_progress_bar
  221.         call    textbox_draw
  222.  
  223.         mcall   MF_DRAWSTATUS, DS_END
  224. ret
  225.  
  226. ;---------------------------------------------------------------------
  227.  
  228. textbox_draw:
  229.         mcall   MF_BUTTON, <7,285>, <55,10>, 0x60000020
  230.  
  231.         mov     edx, 0x808080
  232.         cmp     [textbox_active], 1
  233.         jne     @f
  234.         mov     edx, 0xA0A0A0
  235.     @@:
  236.         mcall   MF_BAR, <7,286>, <55,11>
  237.  
  238.         movzx   esi, [textbox_position]
  239.         mcall   MF_TEXT, <10,56>, 0x404040, textbox_string
  240. ret
  241.  
  242. ;---------------------------------------------------------------------
  243.  
  244. draw_progress_bar:
  245.         pushad
  246.  
  247.         imul    eax, [fileinfo.first_block], PBAR_WIDTH
  248.         cdq
  249.         div     [file_size]
  250.  
  251.         push    eax
  252.         mcall   MF_BAR, <7,286>, <41,11>, 0x808080
  253.         mcall   MF_BUTTON,     ,        , 0x60000030
  254.         pop     eax
  255.  
  256.         mov     bx, ax
  257.         mov     edx, 0xA0A0A0
  258.         mcall   MF_BAR
  259.  
  260.         popad
  261. ret
  262.  
  263. ;---------------------------------------------------------------------
  264.  
  265. sz header,       "AC'97 WAV player -  all PCM audio"
  266. sz buttons_text, " Play    Stop     <<      >>     Vol-    Vol+"
  267.  
  268. textbox_active    db 0
  269. textbox_position  db textbox_string.size-1
  270. file_size dd 100
  271.