Subversion Repositories Kolibri OS

Rev

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