Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;                                                           ;
  3. ;    Audio CD player; code by Dmitry Yushko - dma@bn.by     ;
  4. ;                                                           ;
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6.  
  7. include "..\..\..\macros.inc"
  8. include "lang.inc"
  9.  
  10. FALSE  equ 0
  11. TRUE   equ 1
  12.  
  13. ESC_KEY   equ 27
  14. LEFT_KEY  equ 176
  15. RIGHT_KEY equ 179
  16.  
  17. NORMAL_PLAY  equ 0
  18. REPEAT_TRACK equ 1
  19. REPEAT_DISK  equ 2
  20. SHUFFLE_DISK equ 3
  21.  
  22. COLOR_FUNC_BUTS equ 0x00dddddd
  23.  
  24. use32
  25.  
  26.                   org    0x0
  27.                   db     'MENUET01'              ; 8 byte id
  28.                   dd     0x01                      ; required os
  29.                   dd     START                   ; program start
  30.                   dd     I_END                   ; program image size
  31.                   dd     0x2000                  ; required amount of memory
  32.                   dd     0x2000                  ; esp = 0x7fff0
  33.                   dd     0x0, 0x0              ; reserved=no extended header
  34.  
  35. START:
  36.     call chk_cdrom                      ; start of execution
  37.     call read_cd
  38.  
  39.   red:                          ; redraw
  40.     call draw_window            ; at first, draw the window
  41. still:
  42.  
  43.     mov  eax,23
  44.     mov  ebx,10                 ; wait here for event
  45.     mcall
  46.  
  47.     cmp  eax,1                  ; redraw request ?
  48.     jz   red
  49.     cmp  eax,2                  ; key in buffer ?
  50.     jz   key
  51.     cmp  eax,3                  ; button in buffer ?
  52.     jz   button
  53.  
  54.     call draw_info
  55.     cmp  [curr_trk],0
  56.     je   @f
  57.     call current_trk_time
  58.    @@:
  59.     jmp  still
  60.  
  61.  
  62.   key:                          ; key
  63.     mov  eax,2                  ; just read it and ignore
  64.     mcall
  65.  
  66. ;======  hotkeys:
  67.     cmp  ah,0x61
  68.     jb   @f
  69.     cmp  ah,0x7a
  70.     ja   @f
  71.     and  ah,11011111b
  72.    @@:
  73.  
  74.     cmp  ah,'P' ;PLAY
  75.     jne  no_key_play
  76.     call play_acd
  77.     jmp still
  78.  no_key_play:
  79.  
  80.     cmp ah,'S' ;STOP
  81.     jne no_key_stop
  82.     mov [if_paused],FALSE
  83.     call stop_playing
  84.     jmp still
  85.  no_key_stop:
  86.  
  87.     cmp ah,'N' ;NEXT
  88.     jne no_key_next
  89.     call play_next_trk
  90.     jmp still
  91.  no_key_next:
  92.  
  93.     cmp ah,'B' ;BACK
  94.     jne no_key_back
  95.     call play_back_trk
  96.     jmp still
  97.  no_key_back:
  98.  
  99.     cmp  ah,'F' ;FORWARD
  100.     jne  no_key_fwd
  101.     call fast_forward
  102.     jmp still
  103.  no_key_fwd:
  104.  
  105.     cmp ah,'R' ;REWIND
  106.     jne no_key_rewind
  107.     call fast_rewind
  108.     jmp still
  109.  no_key_rewind:
  110.  
  111.     cmp ah,'M' ;MODE
  112.     jne no_key_mode
  113.     call change_mode
  114.     jmp still
  115.  no_key_mode:
  116.  
  117.  
  118.     cmp ah,'L' ;READ PLAYLIST
  119.     jne no_key_list
  120.     mov [if_paused],FALSE
  121.     mov [curr_trk],0
  122.     call stop_playing
  123.     call chk_cdrom
  124.     call read_cd
  125.     jmp still
  126.  no_key_list:
  127.  
  128.     cmp ah,50      ;F1 key
  129.     jz  itsahelpkey
  130.  
  131.     cmp ah,'H' ;HELP
  132.     jne no_key_help
  133.    itsahelpkey:
  134.     cmp [flag],4
  135.     je  still
  136.     cmp [flag],1
  137.     jne was_it_ok_false
  138.     mov [was_it_ok],TRUE
  139.     jmp flag4_done
  140.    was_it_ok_false:
  141.     mov [was_it_ok],FALSE
  142.    flag4_done:
  143.     mov [flag],4
  144.     mov [help_screen],1
  145.     call draw_window
  146.     jmp still
  147.  no_key_help:
  148.  
  149.  
  150.     cmp ah,ESC_KEY
  151.     jne no_esc_key
  152.     cmp [flag],4
  153.     jne still
  154.     cmp [was_it_ok],FALSE
  155.     jne was_it_ok_true
  156.     mov [flag],0
  157.     jmp end_esc_key
  158.    was_it_ok_true:
  159.     mov [flag],1
  160.    end_esc_key:
  161.     call draw_window
  162.  no_esc_key:
  163.  
  164.     cmp ah,LEFT_KEY
  165.     jne no_left_key
  166.     cmp [flag],4
  167.     jne still
  168.     cmp [help_screen],1
  169.     jz  still
  170.     dec [help_screen]
  171.     call draw_window
  172.    no_left_key:
  173.  
  174.     cmp ah,RIGHT_KEY
  175.     jne no_right_key
  176.     cmp [flag],4
  177.     jne still
  178.     cmp [help_screen],3
  179.     jz  still
  180.     inc [help_screen]
  181.     call draw_window
  182.    no_right_key:
  183.  
  184.  
  185.     jmp  still
  186.  
  187.  
  188.   button:                       ; button
  189.     mov  eax,17
  190.     mcall
  191.  
  192.     cmp  ah,1                   ; button id=1 ?
  193.     jnz  no_but_close
  194.     mov  eax,24
  195.     mov  ebx,3
  196.     mcall
  197.     mov  eax,0xffffffff         ; close this program
  198.     mcall
  199.   no_but_close:
  200.  
  201.     cmp  ah,2
  202.     jne  no_but_play
  203.     call play_acd
  204.     jmp still
  205.  no_but_play:
  206.  
  207.     cmp ah,3
  208.     jne no_but_stop
  209.     mov [if_paused],FALSE
  210.     call stop_playing
  211.     jmp still
  212.  no_but_stop:
  213.  
  214.     cmp ah,4
  215.     jne no_but_reread
  216.     mov [curr_trk],0
  217.     call chk_cdrom
  218.     call read_cd
  219.     mov [if_paused],FALSE
  220.     call stop_playing
  221.     jmp still
  222.  no_but_reread:
  223.  
  224.     cmp ah,5
  225.     jne no_but_next
  226.     call play_next_trk
  227.     jmp still
  228.    no_but_next:
  229.  
  230.     cmp ah,6
  231.     jne no_but_back
  232.     call play_back_trk
  233.     jmp still
  234.    no_but_back:
  235.  
  236.     cmp ah,7
  237.     jne no_but_mode
  238.     call change_mode
  239.     jmp still
  240.    no_but_mode:
  241.  
  242.     cmp ah,8
  243.     jne no_but_frew
  244.     call fast_rewind
  245.     jmp still
  246.    no_but_frew:
  247.  
  248.     cmp ah,9
  249.     jne no_but_ffwd
  250.     call fast_forward
  251.     jmp still
  252.    no_but_ffwd:
  253.  
  254.     cmp  ah,10
  255.     jb   no_but_track
  256.     cmp  ah,40
  257.     ja   no_but_track
  258.     call read_cd
  259.     cmp  [flag],1
  260.     jne  no_but_track
  261.     mov  cl,ah
  262.     sub  cl,10
  263.     mov  [curr_trk],cl
  264.     mov  cl,[max_trk]
  265.     mov  [shuftab],cl
  266.     call stop_playing
  267.     call renew_shuftab
  268.     call play_n_track
  269.     call rem_time_trk
  270.     jmp still
  271.   no_but_track:
  272.  
  273.     jmp  still
  274.  
  275.  
  276. change_mode:
  277.     cmp [mode],3
  278.     jne inc_mode
  279.     mov [mode],0
  280.     jmp end_but_mode
  281.    inc_mode:
  282.     inc [mode]
  283.    end_but_mode:
  284.     call draw_info
  285. ret
  286.  
  287. play_next_trk:
  288.     cmp [curr_trk],0
  289.     je  @play_next_trk
  290.     cmp [if_paused],TRUE
  291.     je  @play_next_trk
  292.     cmp [mode],NORMAL_PLAY
  293.     jne play_next_mode1
  294.     xor eax,eax
  295.     mov al,[curr_trk]
  296.     cmp [max_trk],al
  297.     je  @play_next_trk
  298.     inc [curr_trk]
  299.     cmp [if_stopped],TRUE
  300.     je @play_next_trk
  301.     call play_n_track
  302.     jmp  @play_next_trk
  303.    play_next_mode1:
  304.     cmp [mode],REPEAT_TRACK
  305.     jne play_next_mode2
  306.     cmp [if_stopped],TRUE
  307.     je @play_next_trk
  308.     call play_n_track
  309.     jmp  @play_next_trk
  310.    play_next_mode2:
  311.     cmp [mode],REPEAT_DISK
  312.     jne play_next_mode3
  313.     xor eax,eax
  314.     mov al,[curr_trk]
  315.     cmp [max_trk],al
  316.     jne  play_next_mode2_go
  317.     mov [curr_trk],1
  318.     cmp [if_stopped],TRUE
  319.     je @play_next_trk
  320.     call play_n_track
  321.     jmp  @play_next_trk
  322.    play_next_mode2_go:
  323.     inc  [curr_trk]
  324.     cmp [if_stopped],TRUE
  325.     je @play_next_trk
  326.     call play_n_track
  327.     jmp  @play_next_trk
  328.    play_next_mode3:
  329.     cmp  [mode],SHUFFLE_DISK
  330.     jne  @play_next_trk
  331.    call shuffle_track
  332.    @play_next_trk:
  333. ret
  334.  
  335. play_back_trk:
  336.     cmp [curr_trk],0
  337.     je  @play_back_trk
  338.     cmp [if_paused],TRUE
  339.     je  @play_back_trk
  340.     cmp [mode],NORMAL_PLAY
  341.     jne play_back_mode1
  342.     xor eax,eax
  343.     mov al,[curr_trk]
  344.     cmp al,1
  345.     je  @play_back_trk
  346.     dec [curr_trk]
  347.     cmp [if_stopped],TRUE
  348.     je @play_next_trk
  349.     call play_n_track
  350.     jmp  @play_back_trk
  351.    play_back_mode1:
  352.     cmp [mode],REPEAT_TRACK
  353.     jne play_back_mode2
  354.     cmp [if_stopped],TRUE
  355.     je @play_next_trk
  356.     call play_n_track
  357.     jmp  @play_back_trk
  358.    play_back_mode2:
  359.     cmp [mode],REPEAT_DISK
  360.     jne play_back_mode3
  361.     xor eax,eax
  362.     mov al,[curr_trk]
  363.     cmp al,1
  364.     jne  play_back_mode2_go
  365.     mov al,[max_trk]
  366.     mov [curr_trk],al
  367.     cmp [if_stopped],TRUE
  368.     je @play_next_trk
  369.     call play_n_track
  370.     jmp  @play_back_trk
  371.    play_back_mode2_go:
  372.     dec  [curr_trk]
  373.     cmp [if_stopped],TRUE
  374.     je @play_next_trk
  375.     call play_n_track
  376.     jmp  @play_back_trk
  377.    play_back_mode3: ;(shuffle)
  378. ;   call shuffle_track
  379.    @play_back_trk:
  380. ret
  381.  
  382.  
  383. current_trk_time:
  384.     cmp [if_stopped],TRUE
  385.     je  menshe
  386.     call get_uptime
  387.     mov ebx,[stimtrk]
  388.     sub eax,ebx
  389.    ; eax now is seconds from track start * 100
  390.     xor edx,edx
  391.     mov ecx,100
  392.     div ecx
  393.     mov [curr_trk_pg_time],eax
  394.     mov ebx,[curr_trk_length]
  395. ;    add eax,1 ;{inc curr time on 1 sec)
  396.     cmp eax,ebx
  397.     jb  menshe
  398.     call stop_playing
  399.     cmp [mode],SHUFFLE_DISK
  400.     jne @f
  401.     call shuffle_track
  402.    @@:
  403.     cmp [mode],REPEAT_TRACK
  404.     je  @@mode_repeat_1
  405.     mov al,[max_trk]
  406.     cmp [curr_trk],al
  407.     jb  @@next_trk_ok
  408.     cmp [mode],REPEAT_DISK
  409.     jne menshe
  410.     mov [curr_trk],0
  411.    @@next_trk_ok:
  412.     inc [curr_trk]
  413.    @@mode_repeat_1:
  414.     call play_n_track
  415.    menshe:
  416. ret
  417.  
  418.  
  419. rem_time_trk:
  420.     call get_uptime
  421.     mov  [stimtrk],eax
  422.     ret
  423.  
  424. fast_forward:
  425.     cmp [if_stopped],TRUE
  426.     je end_ffwd
  427.     mov eax,[curr_trk_pg_time]
  428.     add eax,5
  429.     cmp eax,[curr_trk_length]
  430.     jae end_ffwd
  431.     cmp [stimtrk],500
  432.     jbe end_ffwd
  433.     sub [stimtrk],500
  434.     call current_trk_time
  435.     call play_from_x_time
  436.    end_ffwd:
  437. ret
  438.  
  439. fast_rewind:
  440.     cmp [if_stopped],TRUE
  441.     je end_frew
  442.     cmp [curr_trk_pg_time],5
  443.     jbe end_frew
  444.     add [stimtrk],500
  445.     call current_trk_time
  446.     call play_from_x_time
  447.    end_frew:
  448. ret
  449.  
  450. renew_shuftab:
  451.     mov  ecx,40
  452.    @rn:
  453.     mov  [shuftab+ecx],cl
  454.     loop @rn
  455.     mov  cl,[max_trk]
  456.     mov  [shuftab],cl
  457. ret
  458.  
  459.  
  460. shuffle_track:
  461.    call get_uptime
  462.    ror  eax,16
  463.    cmp  eax,0
  464.    je   shuffle_track
  465.    xor  ecx,ecx
  466.    mov  cl,[shuftab]
  467.    cmp  ecx,1
  468.    je   @enddsk
  469.    xor  edx,edx
  470.    div  ecx
  471.    cmp  edx,0
  472.    je   shuffle_track
  473.    xor  ecx,ecx
  474.    mov  cl,[max_trk]
  475.  @main_loop:
  476.    xor  eax,eax
  477.    mov  al,[shuftab+ecx]
  478.    cmp  al,0
  479.    je   @f
  480.    dec  edx
  481.    cmp  edx,0
  482.    jne  @f
  483.    mov  cl,[shuftab]
  484.    dec  cl
  485.    mov  [shuftab],cl
  486.    mov  [shuftab+eax],0
  487.    mov  [curr_trk],al
  488.    call play_n_track
  489.    jmp  @endofshuffle
  490.  @@:
  491.    loop @main_loop
  492.    jmp  @endofshuffle
  493.  @enddsk:
  494.    call stop_playing
  495.  @endofshuffle:
  496.  
  497. ret
  498.  
  499.  
  500.  
  501.  
  502. play_from_x_time:
  503.     xor  ecx,ecx
  504.     mov  cl,[curr_trk]
  505.     shl  cl,3
  506.     add  cl,1
  507.     add  ecx,cdp
  508.     mov  ebx,[ecx]
  509.     mov  ecx,ebx
  510.     and  ecx,0x00ffffff
  511.  
  512.     mov  eax,[curr_trk_pg_time]
  513.     xor  edx,edx
  514.     mov  ebx,60
  515.     div  ebx
  516.     add  cl,al ;mins
  517.     add  dl,ch
  518.     xor eax,eax
  519.     mov al,dl
  520.     xor edx,edx
  521.     div ebx
  522.     add cl,al   ;real min
  523.     mov ch,dl   ;real sec
  524.  
  525.     mov  eax,24
  526.     mov  ebx,1
  527.     mcall
  528.     ret
  529.  
  530. play_n_track:
  531.     mov  [if_paused],FALSE
  532.     mov  [if_stopped],FALSE
  533.     mov  [curr_trk_pg_time],0
  534.     call draw_window
  535. ;    mov  eax,26
  536. ;    mov  ebx,9
  537. ;    mcall
  538.     call get_uptime
  539.     mov  [stimtrk],eax
  540.     xor  ebx,ebx
  541.     xor  ecx,ecx
  542.     mov  cl,[curr_trk]
  543.     inc  cl
  544.     shl  cl,3
  545.     add  cl,1
  546.     add  ecx,cdp
  547.     mov  ebx,[ecx]
  548.     and  ecx,0x00ffffff
  549.     mov  ecx,ebx
  550.    ;get_minutes:
  551.    and  ecx,0x000000ff
  552.    mov  eax,ecx
  553.    imul eax,60
  554.    ;get_seconds:
  555.    mov ecx,ebx
  556.    and ecx,0x0000ff00
  557.    shr ecx,8
  558.    add eax,ecx
  559.    ;eax now is next pos in secs
  560.    mov [next_pos_sec],eax
  561.  ;eax now is current pos in secs
  562.     xor  ebx,ebx
  563.     xor  ecx,ecx
  564.     mov  cl,[curr_trk]
  565.     shl  cl,3
  566.     add  cl,1
  567.     add  ecx,cdp
  568.     mov  ebx,[ecx]
  569.     and  ecx,0x00ffffff
  570.     mov  ecx,ebx
  571.    ;get_minutes:
  572.    and  ecx,0x000000ff
  573.    mov  eax,ecx
  574.    imul eax,60
  575.    ;get_seconds:
  576.    mov ecx,ebx
  577.    and ecx,0x0000ff00
  578.    shr ecx,8
  579.    add eax,ecx
  580.    ;eax now is current pos in secs
  581.    mov ecx,[next_pos_sec]
  582.    sub ecx,eax
  583.    ;eax now is length of trk in sec
  584.    mov [curr_trk_length],ecx
  585. ;now play that!
  586.     mov ecx,ebx
  587.     mov  eax,24
  588.     mov  ebx,1
  589.     mcall
  590.     ret
  591.  
  592.  
  593. play_acd:
  594.     call chk_cdrom
  595.     call read_cd
  596.     call draw_window
  597.     call renew_shuftab
  598.     mov  cl,[curr_trk]
  599.     cmp  cl,0
  600.     jnz  play_acd_trk_ok
  601.     mov  cl,[max_trk]
  602.     mov  [shuftab],cl
  603.     mov  [curr_trk],1
  604.     jmp  playing_no_pause
  605.    play_acd_trk_ok:
  606. ;   start_chk_on_pause:
  607.     cmp  [if_paused],TRUE
  608.     jne   pause_playing
  609.     mov  [if_stopped],FALSE
  610.     mov  [if_paused],FALSE
  611.     call current_trk_time
  612.     mov  eax,[curr_trk_pg_time]
  613.     mov  ebx,[paused_time]
  614.     sub  eax,ebx
  615.     imul eax,100
  616.     add  [stimtrk],eax
  617.     call current_trk_time
  618.     call play_from_x_time
  619.     call draw_window
  620.     jmp  end_play_acd
  621.    pause_playing:
  622.     cmp  [curr_trk_pg_time],0
  623.     je   playing_no_pause
  624.     mov  eax,[curr_trk_pg_time]
  625.     mov  [paused_time],eax
  626.     mov  [if_paused],TRUE
  627.     call stop_playing
  628.     call draw_window
  629.     jmp  end_play_acd
  630.    playing_no_pause:
  631.     mov  [if_paused],FALSE
  632.     call rem_time_trk
  633.     call  play_n_track
  634.     call  draw_window
  635.    end_play_acd:
  636.     ret
  637.  
  638. stop_playing:
  639.     mov eax, 24
  640.     mov ebx,3
  641.     mcall
  642.     mov  cl,[max_trk]
  643.     mov  [shuftab],cl
  644.     mov [if_stopped],TRUE
  645.     cmp [if_paused],TRUE
  646.     je  end_stop_playing
  647.     mov [curr_trk_pg_time],0
  648.    end_stop_playing:
  649.     call draw_window
  650. ret
  651.  
  652. ;   *********************************************
  653. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  654. ;   *********************************************
  655.  
  656. draw_info:
  657.     ;bar->
  658.     mov eax,13
  659.     mov ebx, 10 shl 16 + 41
  660.     mov ecx,120 shl 16 + 9
  661.     mov edx,0x00ffffff
  662.     mcall
  663.     mov ebx, 96 shl 16 + 11
  664.     mcall
  665.     mov ebx, 185 shl 16 + 11
  666.     mcall
  667.     mov ebx, 200 shl 16 + 11
  668.     mcall
  669.     mov ebx, 150 shl 16 + 11
  670.     mcall
  671.     mov ebx, 165 shl 16 + 11
  672.     mcall
  673.    ;bar<-
  674.  
  675.     mov  eax,4
  676.     mov  ebx,10 shl 16 +120
  677.     mov  ecx,0x00111111
  678.     cmp  [mode],NORMAL_PLAY
  679.     jne  info_mode_1
  680.     mov  edx,mode_normal
  681.     jmp  info_mode_end
  682.    info_mode_1:
  683.     cmp  [mode],REPEAT_TRACK
  684.     jne  info_mode_2
  685.     mov  edx,mode_repeat_1
  686.     jmp  info_mode_end
  687.    info_mode_2:
  688.     cmp  [mode],REPEAT_DISK
  689.     jne  info_mode_3
  690.     mov  edx,mode_repeat_all
  691.     jmp  info_mode_end
  692.    info_mode_3:
  693.     cmp  [mode],SHUFFLE_DISK
  694.     jne  info_mode_end
  695.     mov  edx,mode_shuffle
  696. ;    mov  ecx,0x00aaaaaa
  697. ;    mov  cl,[max_trk]
  698. ;    mov  [shuftab],cl
  699.     jmp  info_mode_end
  700.    info_mode_end:
  701.     mov  esi,7
  702.     mcall
  703.  
  704.   ;num info ->
  705.     mov  eax,47
  706.     xor  ebx,ebx
  707.     mov  bl,0
  708.     mov  bh,0
  709.     or   ebx,0x20000            ;X0000 - number of digits to draw
  710.     xor  ecx,ecx
  711.     mov  cl, [curr_trk]            ;number to draw
  712.     mov  edx,96 shl 16 + 120
  713.     mov  esi,0x111111
  714.     mcall
  715.     mov  eax,[curr_trk_pg_time]
  716.     xor  edx,edx
  717.     mov  ecx,60
  718.     div  ecx
  719.     push edx
  720.     mov  ecx,eax
  721.     mov  eax,47
  722.     mov  edx,150 shl 16 + 120
  723.     mcall
  724.     pop ecx
  725.     mov  edx,165 shl 16 + 120
  726.     mcall
  727.     mov  eax,[curr_trk_length]
  728.     xor  edx,edx
  729.     mov  ecx,60
  730.     div  ecx
  731.     push edx
  732.     mov  ecx,eax
  733.     mov  eax,47
  734.     mov  edx,185 shl 16 + 120
  735.     mcall
  736.     pop  ecx
  737.     mov  edx,200 shl 16 + 120
  738.     mcall
  739.    ;num info <-
  740. ret
  741.  
  742.  
  743. draw_window:
  744.  
  745.     mov  eax,12                    ; function 12:tell os about windowdraw
  746.     mov  ebx,1                     ; 1, start of draw
  747.     mcall
  748.                                    ; DRAW WINDOW
  749.     mov  eax,0                     ; function 0 : define and draw window
  750.     mov  ebx, 50*65536+219         ; [x start] *65536 + [x size]
  751.     mov  ecx,100*65536+168         ; [y start] *65536 + [y size]
  752.     mov  edx,0x04ffffff            ; color of work area RRGGBB
  753.     mov  esi,0x8099bbff            ; color of grab bar  RRGGBB,8->color glide
  754.     mov  edi,0x0099bbee            ; color of frames    RRGGBB
  755.     mcall
  756.                                    ; WINDOW LABEL
  757.     mov  eax,4                     ; function 4 : write text to window
  758.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  759.     mov  ecx,0x1000ffff            ; color of text RRGGBB
  760.     mov  edx,labelt                ; pointer to text beginning
  761.     mov  esi,labellen-labelt       ; text length
  762.     mcall
  763.  
  764.     mov  eax,13                    ;bar
  765.     mov  ebx,8 shl 16 + 204
  766.     mov  ecx,28 shl 16 + 84
  767.     mov  edx,0x000fe6f5
  768.     mcall
  769.  
  770.     ;info ->
  771.     mov  eax,4
  772.     mov  ebx,63 shl 16 + 120
  773.     mov  ecx,0x00111111
  774.     mov  edx,playing_trk_info
  775.     mov  esi,6
  776.     mcall
  777.     mov  ebx,120 shl 16 + 120
  778.     mov  edx,playing_time_info
  779. ;    mov  esi,5
  780.     dec  esi
  781.     mcall
  782.     mov  ebx,178 shl 16 + 120
  783.     mov  edx,slash
  784.     mov  esi,1
  785.     mcall
  786.     mov  ebx,196 shl 16 + 120
  787.     mov  edx,column
  788. ;    mov  esi,1
  789.     mcall
  790.     mov  ebx,161 shl 16 + 120
  791.     mov  edx,column
  792. ;    mov  esi,1
  793.     mcall
  794.     ;info <-
  795.  
  796. ; button  MODE
  797.     mov  eax,8
  798.     mov  ebx,12*65536+20
  799.     mov  ecx,135*65536+20
  800.     mov  edx,7
  801.     mov  esi,COLOR_FUNC_BUTS
  802.     mcall
  803.    ; text
  804.     mov  eax,4
  805.     mov  ebx,19*65536+142
  806.     mov  ecx,0x100f73f5;ffff0f
  807.     mov  edx,but_mode_lab
  808.     mov  esi,1
  809.     mcall
  810.  
  811. ; button  BACK
  812.     mov  eax,8
  813.     mov  ebx,37*65536+20
  814.     mov  ecx,135*65536+20
  815.     mov  edx,6
  816.     mov  esi,COLOR_FUNC_BUTS
  817.     mcall
  818.     mov [coord_x],51
  819.     mov [coord_y],141
  820.     call draw_left_triangle
  821.     mov [coord_x],44
  822.     call draw_vertical_line
  823.  
  824. ; button  NEXT
  825.     mov  eax,8
  826.     mov  ebx,62*65536+20
  827.     mov  ecx,135*65536+20
  828.     mov  edx,5
  829.     mov  esi,COLOR_FUNC_BUTS
  830.     mcall
  831.     mov [coord_x],68
  832.     mov [coord_y],141
  833.     call draw_right_triangle
  834.     mov [coord_x],74
  835.     call draw_vertical_line
  836.  
  837. ; button  REWIND
  838.     mov  eax,8
  839.     mov  ebx,87*65536+20
  840.     mov  ecx,135*65536+20
  841.     mov  edx,8
  842.     mov  esi,COLOR_FUNC_BUTS
  843.     mcall
  844.     mov [coord_x],102
  845.     mov [coord_y],141
  846.     call draw_left_triangle
  847.     mov [coord_x],97
  848.     call draw_left_triangle
  849.  
  850. ; button   STOP
  851.     mov  eax,8
  852.     mov  ebx,112*65536+20
  853.     mov  ecx,135*65536+20
  854.     mov  edx,3
  855.     mov  esi,COLOR_FUNC_BUTS
  856.     mcall
  857.     mov [coord_x],118
  858.     mov [coord_y],142
  859.     call draw_square
  860.  
  861.  
  862. ; button  PLAY
  863.     mov  eax,8
  864.     mov  ebx,137*65536+20
  865.     mov  ecx,135*65536+20
  866.     mov  edx,2
  867.     mov  esi,COLOR_FUNC_BUTS
  868.     mcall
  869.     cmp [if_stopped],TRUE
  870.     je  playing_paused
  871.     cmp [if_paused],TRUE
  872.     je  playing_paused
  873.     mov [coord_x],144
  874.     mov [coord_y],141
  875.     call draw_vertical_line
  876.     mov [coord_x],149
  877.     call draw_vertical_line
  878.     jmp end_draw_play
  879.    playing_paused:
  880.     mov [coord_x],144
  881.     mov [coord_y],141
  882.     call draw_right_triangle
  883.    end_draw_play:
  884.  
  885.  
  886. ; button   FORWARD
  887.     mov  eax,8
  888.     mov  ebx,162*65536+20
  889.     mov  ecx,135*65536+20
  890.     mov  edx,9
  891.     mov  esi,COLOR_FUNC_BUTS
  892.     mcall
  893.     mov [coord_x],167
  894.     mov [coord_y],141
  895.     call draw_right_triangle
  896.     mov [coord_x],172
  897.     call draw_right_triangle
  898.  
  899. ; button  RE-READ PLAYLIST
  900.     mov  eax,8
  901.     mov  ebx,187*65536+20
  902.     mov  ecx,135*65536+20
  903.     mov  edx,4
  904.     mov  esi,COLOR_FUNC_BUTS
  905.     mcall
  906.     mov  [coord_x],192
  907.     mov  [coord_y],140
  908.     call draw_vert_list_line
  909.     dec  [coord_y]
  910.     call draw_hor_list_line
  911.     mov  [coord_y], 151
  912.     call draw_hor_list_line
  913.     mov  [coord_x],202
  914.     mov  [coord_y],140
  915.     call draw_vert_list_line
  916.     mov  [coord_x],195
  917.     mov  [coord_y], 142
  918.     call draw_str_list_line
  919.     mov  [coord_y],145
  920.     call draw_str_list_line
  921.     mov  [coord_y],148
  922.     call draw_str_list_line
  923.  
  924.     cmp  [flag],1
  925.     jne  flag2
  926. ;Draw tracs buttons
  927.     xor  eax,eax
  928.     xor  ebx,ebx
  929.     mov  ecx,10
  930.     mov  al,[cdp+3]
  931.     mov  [max_trk],al
  932.     xor  edi,edi
  933.     mov  di,ax
  934.     mov  [posx],12
  935.     mov  [posy],32
  936.     mov  [tracs],1
  937.  draw_tracs_buttons:
  938.     mov  eax,8
  939.     xor  ebx,ebx
  940.     mov  bl,[posx]
  941.     shl  ebx,16
  942.     add  ebx,15
  943.     xor  ecx,ecx
  944.     mov  cl,[posy]
  945.     shl  ecx,16
  946.     add  ecx,15
  947.     xor  edx,edx
  948.     mov  dx,[tracs]
  949.     add  edx,10
  950.     mov  esi,0xaaaaaa
  951.     add  esi,edi
  952.     mcall
  953.    ;---draw tracs numbers
  954.     mov  eax,47
  955.     xor  ebx,ebx
  956.     mov  bl,0
  957.     or   ebx,0x20000            ;number of digits to draw
  958.     xor  ecx,ecx
  959.     mov  cx, [tracs]            ;number to draw
  960.     xor  edx,edx
  961.     mov  dl,[posx]
  962.     add  dl,3
  963.     shl  edx,16
  964.     add  dl,[posy]
  965.     add  dl,5
  966.     mov  esi,0xffffff
  967.     mcall
  968.    ;---
  969.     mov  al,[posx]
  970.     add  al,20
  971.     mov  [posx],al
  972.     xor  eax,eax
  973.     mov  ax,[tracs]
  974.     mov  bl,10
  975.     div  bl
  976.     cmp  ah,0
  977.     jnz  no_new_str
  978.     mov  al,[posxstart]
  979.     mov  [posx], al
  980.     mov  al,[posy]
  981.     add  al,20
  982.     mov  [posy],al
  983.   no_new_str:
  984.     inc  [tracs]
  985.     cmp  [tracs],41
  986.     je   flag2
  987.     dec  edi
  988.     cmp  edi,0
  989.     jnz  draw_tracs_buttons
  990.  
  991.   flag2:
  992.     cmp [flag],2
  993.     jne flag3
  994.     mov eax,4
  995.     mov ebx, 20 shl 16 +67
  996.     mov ecx,0x10ffff00
  997.     mov edx,define_cdrom
  998.     mov esi,define_cdrom_len-define_cdrom
  999.     mcall
  1000.   flag3:
  1001.     cmp [flag],3
  1002.     jne flag4
  1003.     mov eax,4
  1004.     mov ebx, 47 shl 16 +67
  1005.     mov ecx,0x10ffff00
  1006.     mov edx,no_cda
  1007.     mov esi,no_cda_len-no_cda
  1008.     mcall
  1009.   flag4:
  1010.     cmp [flag],4
  1011.     jne flag5
  1012.    ;help screen
  1013.    cmp [help_screen],1
  1014.    jnz @hs2
  1015.    mov edx,help1
  1016.    jmp @ehs
  1017.   @hs2:
  1018.    cmp [help_screen],2
  1019.    jnz @hs3
  1020.    mov edx,help2
  1021.    jmp @ehs
  1022.   @hs3:
  1023.    mov edx,help3
  1024.   @ehs:
  1025.    xor edi,edi
  1026.    mov ebx,25*65536+30
  1027.   new_line:
  1028.    mov eax,4
  1029.    mov ecx,0x111111
  1030.    mov esi,31
  1031.    mcall
  1032.   noline:
  1033.    add ebx,10
  1034.    add edx,31
  1035.    inc edi
  1036.    cmp [edx],byte 'x'
  1037.    jnz new_line
  1038.   flag5:
  1039.   call draw_info
  1040.  
  1041.     mov  eax,12                    ; function 12:tell os about windowdraw
  1042.     mov  ebx,2                     ; 2, end of draw
  1043.     mcall
  1044.  
  1045. ret
  1046.  
  1047. draw_right_triangle:
  1048.     mov ebx,[coord_x]
  1049.     mov ecx,[coord_y]
  1050.     mov edx,0x00111111
  1051.     mov esi,5
  1052.     mov eax,9
  1053.    start_draw_pixel:
  1054.     push ebx
  1055.     cmp  eax,5
  1056.     jb   y_menshe_5
  1057.     mov  esi,10
  1058.     sub  esi,eax
  1059.     jmp  draw_pixel
  1060.    y_menshe_5:
  1061.     mov  esi,eax
  1062.    draw_pixel:
  1063.     dec  esi
  1064.     inc  ebx
  1065.     push eax
  1066.     mov  eax,1
  1067.     mcall
  1068.     pop  eax
  1069.     cmp  esi,0
  1070.     jne  draw_pixel
  1071.     pop  ebx
  1072.     dec  eax
  1073.     inc  ecx
  1074.     cmp  eax,0
  1075.     jne  start_draw_pixel
  1076. ret
  1077.  
  1078. draw_square:
  1079.     mov ebx,[coord_x]
  1080.     mov ecx,[coord_y]
  1081.     mov edx,0x00111111
  1082.     mov eax,7
  1083.    q_start_draw_pixel:
  1084.     push ebx
  1085.     mov  esi,7
  1086.    q_draw_pixel:
  1087.     dec  esi
  1088.     inc  ebx
  1089.     push eax
  1090.     mov  eax,1
  1091.     mcall
  1092.     pop  eax
  1093.     cmp  esi,0
  1094.     jne  q_draw_pixel
  1095.     pop  ebx
  1096.     dec  eax
  1097.     inc  ecx
  1098.     cmp  eax,0
  1099.     jne  q_start_draw_pixel
  1100. ret
  1101.  
  1102. draw_left_triangle:
  1103.     mov ebx,[coord_x]
  1104.     mov ecx,[coord_y]
  1105.     mov edx,0x00111111
  1106.     mov esi,5
  1107.     mov eax,9
  1108.    l_start_draw_pixel:
  1109.     push ebx
  1110.     cmp  eax,5
  1111.     jb   l_y_menshe_5
  1112.     mov  esi,10
  1113.     sub  esi,eax
  1114.     jmp  l_draw_pixel
  1115.    l_y_menshe_5:
  1116.     mov  esi,eax
  1117.    l_draw_pixel:
  1118.     dec  esi
  1119.     dec  ebx
  1120.     push eax
  1121.     mov  eax,1
  1122.     mcall
  1123.     pop  eax
  1124.     cmp  esi,0
  1125.     jne  l_draw_pixel
  1126.     pop  ebx
  1127.     dec  eax
  1128.     inc  ecx
  1129.     cmp  eax,0
  1130.     jne  l_start_draw_pixel
  1131. ret
  1132.  
  1133. draw_vertical_line:
  1134.     mov  eax,2
  1135.     mov  ebx,[coord_x]
  1136.     mov  edx,0x00111111
  1137.   @@draw_2_line:
  1138.     mov  ecx,[coord_y]
  1139.     dec  ecx
  1140.     mov  esi,9
  1141.    start_draw_vline:
  1142.     inc  ecx
  1143.     push eax
  1144.     mov  eax,1
  1145.     mcall
  1146.     pop  eax
  1147.     dec  esi
  1148.     cmp  esi,0
  1149.     jne  start_draw_vline
  1150.     dec  eax
  1151.     inc ebx
  1152.     cmp  eax,0
  1153.     jne  @@draw_2_line
  1154. ret
  1155.  
  1156. draw_vert_list_line:
  1157.     mov  eax,1
  1158.     mov  ebx,[coord_x]
  1159.     mov  edx,0x00111111
  1160.     mov  ecx,[coord_y]
  1161.     dec  ecx
  1162.     mov  esi,11
  1163.    vlstart_draw_vline:
  1164.     inc  ecx
  1165.     mcall
  1166.     dec  esi
  1167.     cmp  esi,0
  1168.     jne  vlstart_draw_vline
  1169.     dec  eax
  1170.     inc ebx
  1171. ret
  1172.  
  1173. draw_hor_list_line:
  1174.     mov  eax,1
  1175.     mov  ebx,[coord_x]
  1176.     mov  edx,0x00111111
  1177.     mov  ecx,[coord_y]
  1178.     dec  ebx
  1179.     mov  esi,11
  1180.    hlstart_draw_vline:
  1181.     inc  ebx
  1182.     mcall
  1183.     dec  esi
  1184.     cmp  esi,0
  1185.     jne  hlstart_draw_vline
  1186.     dec  eax
  1187.     inc ebx
  1188. ret
  1189.  
  1190. draw_str_list_line:
  1191.     mov  eax,1
  1192.     mov  ebx,[coord_x]
  1193.     mov  edx,0x00111111
  1194.     mov  ecx,[coord_y]
  1195.     dec  ebx
  1196.     mov  esi,5
  1197.    slstart_draw_vline:
  1198.     inc  ebx
  1199.     mcall
  1200.     dec  esi
  1201.     cmp  esi,0
  1202.     jne  slstart_draw_vline
  1203.     dec  eax
  1204.     inc ebx
  1205. ret
  1206.  
  1207.  
  1208.  chk_cdrom:
  1209.     mov eax,24
  1210.     mov ebx,1
  1211.     mcall
  1212.     cmp eax,0
  1213.     je chk_cdrom_ok
  1214.     mov [flag],2
  1215.     call draw_window
  1216.     jmp  chk_cdrom_end
  1217.    chk_cdrom_ok:
  1218.     mov [flag],0
  1219.    chk_cdrom_end:
  1220. ret
  1221.  
  1222. read_cd:
  1223.     mov [if_stopped],TRUE
  1224.     push ax
  1225.     cmp [flag],2
  1226.     je  read_cd_end
  1227.     mov al,101
  1228.     mov [cdp+3],al
  1229.     mov eax,24
  1230.     mov ebx,2
  1231.     mov ecx, cdp
  1232.     mov edx,321
  1233.     mcall
  1234.     mov [flag],1
  1235.     mov al,100
  1236.     cmp [cdp+3],al
  1237.     jb  read_cd_end
  1238.     mov [flag],3
  1239.     call draw_window
  1240.  read_cd_end:
  1241.     pop ax
  1242. ret
  1243.  
  1244. get_uptime:
  1245.     push ebx
  1246.     mov  eax,26
  1247.     mov  ebx,9
  1248.     mcall
  1249.     pop  ebx
  1250. ret
  1251.  
  1252. ; DATA AREA
  1253.  
  1254. paused_time dd 0
  1255. if_paused db FALSE
  1256. coord_x dd 0
  1257. coord_y dd 0
  1258. flag db 0
  1259. tracs dw 1
  1260. posx db 12
  1261. posy db 32
  1262. posxstart db 12
  1263. curr_trk db 0
  1264. max_trk db 0
  1265. stimtrk dd 0
  1266. help_screen db 0
  1267. next_pos_sec dd 0
  1268. curr_trk_length dd 0
  1269. curr_trk_pg_time dd 0
  1270. was_it_ok db FALSE
  1271. if_stopped db FALSE
  1272. mode db NORMAL_PLAY
  1273.  
  1274. shuftab  db 00,01,02,03,04,05,06,07,08,09
  1275.          db 10,11,12,13,14,15,16,17,18,19
  1276.          db 20,21,22,23,24,25,26,27,28,29
  1277.          db 30,31,32,33,34,35,36,37,38,39
  1278.          db 40
  1279.  
  1280. but_mode_lab: db 'M'
  1281.  
  1282. playing_time_info: db 'Time '
  1283. slash  db '/'
  1284. column db ':'
  1285. mode_normal db     'Normal '
  1286. mode_repeat_1 db   'Rep trk'
  1287. mode_repeat_all db 'Rep all'
  1288. mode_shuffle db    'Shuffle'
  1289. playing_trk_info: db 'Track '
  1290.  
  1291. define_cdrom: db 'Please, define your CD-ROM'
  1292. define_cdrom_len:
  1293.  
  1294. no_cda: db 'Audio CD not found'
  1295. no_cda_len:
  1296.  
  1297. labelt:
  1298.    db   'CD player'
  1299. labellen:
  1300.  
  1301. help1: db 'HotKeys:                       '
  1302.        db 'H - this screen (Help)         '
  1303.        db 'P - Play/Pause current track   '
  1304.        db 'S - Stop playing               '
  1305.        db 'L - re-read playList           '
  1306.        db 'N - play Next track            '
  1307.        db 'B - play previous track (Back) '
  1308.        db '                        next ->'
  1309.        db 'x'
  1310. help2: db 'HotKeys:                       '
  1311.        db 'F - fast Forward track         '
  1312.        db 'R - fast Rewind track          '
  1313.        db 'M - change Mode                '
  1314.        db '                               '
  1315.        db '                               '
  1316.        db '                               '
  1317.        db '<- prev                 next ->'
  1318.        db 'x'
  1319. help3: db 'About:                         '
  1320.        db 'Audio CD Player ver 1.1beta-2  '
  1321.        db 'All questions, wishes and      '
  1322.        db 'advices please send to:        '
  1323.        db '       E-mail:  dma@bn.by      '
  1324.        db '       FidoNet: 2:450/258.75   '
  1325.        db '                               '
  1326.        db '<- prev                        '
  1327.        db 'x'
  1328. cdp:
  1329.  
  1330.  I_END:
  1331.