Subversion Repositories Kolibri OS

Rev

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

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