Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;
  3. ;    CD PLAYER - Compile with fasm
  4. ;
  5.  
  6. use32
  7.  
  8.                   org      0x0
  9.                   db       'MENUET00'           ; 8 byte id
  10.                   dd       38                   ; required os
  11.                   dd       START                ; program start
  12.                   dd       I_END                ; program image size
  13.                   dd       0x1000               ; reguired amount of memory
  14.                   dd       0x1000
  15.                   dd       0x00000000           ; reserved=no extended header
  16.  
  17. include 'lang.inc'
  18. include 'macros.inc'
  19.  
  20. START:
  21.  
  22.     call draw_window
  23.  
  24. still:
  25.  
  26.     mov  eax,10
  27.     int  0x40
  28.  
  29.     cmp  eax,1
  30.     jz   red
  31.     cmp  eax,2
  32.     jz   key
  33.     cmp  eax,3
  34.     jz   button
  35.     jmp  still
  36.  
  37.   red:
  38.     call draw_window
  39.     jmp  still
  40.  
  41.   key:
  42.     mov  eax,2
  43.     int  0x40
  44.     jmp  still
  45.  
  46.   button:
  47.     mov  eax,17
  48.     int  0x40
  49.  
  50.     cmp  ah,byte 41
  51.     jnz  nostop
  52.     call stop
  53.     jmp  still
  54.   nostop:
  55.  
  56.     cmp  ah,byte 42
  57.     jnz  nogetinfo
  58.     call getinfo
  59.     jmp  still
  60.   nogetinfo:
  61.  
  62.     pusha
  63.  
  64.     cmp  ah,100
  65.     jnz  err
  66.  
  67.     jmp  noerr
  68.  
  69.   err:
  70.  
  71.     xor  ecx,ecx
  72.     mov  cl,ah
  73.     shl  ecx,3
  74.     add  ecx,cdinfo
  75.     add  ecx,1
  76.     xor  ebx,ebx
  77.     mov  ebx,[ecx]
  78.     and  ebx,0x00ffffff
  79.     mov  ecx,ebx
  80.  
  81.     mov  ebx,1
  82.     mov  eax,24
  83.     int  0x40
  84.  
  85.     cmp  eax,0
  86.     je   noerr
  87.  
  88.   error:
  89.  
  90.     mov  eax,13
  91.     mov  ebx,10*65536+215
  92.     mov  ecx,115*65536+13
  93.     mov  edx,0x0088aacc
  94.     int  0x40
  95.  
  96.     mov  eax,dword 0x00000004      ; write text
  97.     mov  ebx,12*65536+117
  98.     mov  ecx,[tcolor]
  99.     mov  edx,infotext2
  100.     mov  esi,itl2-infotext2
  101.     int  0x40
  102.  
  103.     mov  eax,5
  104.     mov  ebx,200
  105.     int  0x40
  106.  
  107.   noerr:
  108.  
  109.     popa
  110.  
  111.     shr  eax,8
  112.     and  eax,255
  113.     mov  ebx,0
  114.     mov  ecx,10
  115.  
  116.     cmp  eax,100
  117.     jnz  noend
  118.     mov  eax,-1
  119.     int  0x40
  120.    noend:
  121.  
  122.    newc:
  123.  
  124.     cmp  eax,ecx
  125.     jb   dri
  126.     inc  ebx
  127.     sub  eax,ecx
  128.  
  129.     jmp  newc
  130.  
  131.  
  132.    dri:
  133.  
  134.     mov  ecx,48
  135.     add  ebx,ecx
  136.     mov  [infotext+0],bl
  137.     add  eax,ecx
  138.     mov  [infotext+1],al
  139.     call drawinfo
  140.     jmp  still
  141.  
  142.  
  143. getinfo:
  144.  
  145.    mov  eax,24 ; get info
  146.    mov  ebx,1
  147.    mov  ecx,0x010100
  148.    int  0x40
  149.  
  150.    cmp  eax,0
  151.    jnz  gierror
  152.  
  153.    mov  eax,13
  154.    mov  ebx,10*65536+215
  155.    mov  ecx,115*65536+13
  156.    mov  edx,0x0088aacc
  157.    int  0x40
  158.    mov  eax,dword 0x00000004      ; write text
  159.    mov  ebx,12*65536+117
  160.    mov  ecx,dword 0x00ffffff      ; 8b window nro - RR GG BB color
  161.    mov  edx,infotext3             ; pointer to text beginning
  162.    mov  esi,itl3-infotext3        ; text length
  163.    int  0x40
  164.  
  165.    mov  eax,5
  166.    mov  ebx,100*10
  167.    int  0x40
  168.  
  169.    mov  eax,24 ; get info
  170.    mov  ebx,2
  171.    mov  ecx,cdinfo
  172.    mov  edx,256
  173.    int  0x40
  174.  
  175.    cmp  eax,0
  176.    jz   gi1
  177.  
  178.   gierror:
  179.  
  180.    mov  eax,13
  181.    mov  ebx,10*65536+215
  182.    mov  ecx,115*65536+13
  183.    mov  edx,0x0088aacc
  184.    int  0x40
  185.  
  186.    mov  eax,dword 0x00000004      ; write text
  187.    mov  ebx,12*65536+117
  188.    mov  ecx,dword 0x00ffffff      ; 8b window nro - RR GG BB color
  189.    mov  edx,infotext2             ; pointer to text beginning
  190.    mov  esi,itl2-infotext2        ; text length
  191.    int  0x40
  192.  
  193.    mov  eax,5
  194.    mov  ebx,200
  195.    int  0x40
  196.  
  197.  gi1:
  198.  
  199.    call drawinfo
  200.    ret
  201.  
  202.  
  203.  
  204. stop:
  205.  
  206.    mov  eax,24 ; get info
  207.    mov  ebx,3
  208.    int  0x40
  209.  
  210.    ret
  211.  
  212.  
  213.  
  214. ; info bar
  215.  
  216.  
  217. drawinfo:
  218.  
  219.  
  220.     ; end
  221.  
  222.     xor  eax,eax
  223.     xor  ebx,ebx
  224.     mov  ecx,10
  225.     mov  al,[cdinfo+3]
  226.     cld
  227.  
  228.   newco:
  229.  
  230.     cmp  eax,ecx
  231.     jb   noco
  232.  
  233.     add  ebx,1
  234.     sub  eax,ecx
  235.     jmp  newco
  236.  
  237.   noco:
  238.  
  239.     add  al,48
  240.     mov  [infotext+32],al
  241.  
  242.     add  bl,48
  243.     mov  [infotext+31],bl
  244.  
  245.  
  246.     ; start
  247.  
  248.     xor  eax,eax
  249.     xor  ebx,ebx
  250.     mov  al,[cdinfo+2]
  251.     cld
  252.  
  253.   newco2:
  254.  
  255.     cmp  eax,ecx
  256.     jb   noco2
  257.  
  258.     add  ebx,1
  259.     sub  eax,ecx
  260.     jmp  newco2
  261.  
  262.   noco2:
  263.  
  264.     add  al,48
  265.     mov  [infotext+17],al
  266.  
  267.     add  bl,48
  268.     mov  [infotext+16],bl
  269.  
  270.     mov  eax,13
  271.     mov  ebx,10*65536+219
  272.     mov  ecx,115*65536+13
  273.     mov  edx,[col]
  274.     sub  edx,0x101010
  275.     int  0x40
  276.  
  277.     mov  eax,4                     ; write text
  278.     mov  ebx,12*65536+117
  279.     mov  ecx,dword 0x00ffffff      ; 8b window nro - RR GG BB color
  280.     mov  edx,infotext              ; pointer to text beginning
  281.     mov  esi,itl-infotext          ; text length
  282.     int  0x40
  283.  
  284.     ret
  285.  
  286.  
  287. draw_window:
  288.  
  289.     pusha
  290.  
  291.     mov  eax,12                    ; tell os about redraw
  292.     mov  ebx,1
  293.     int  0x40
  294.  
  295.     mov  eax,0                     ; define and draw window
  296.     mov  ebx,170*65536+240
  297.     mov  ecx,40*65536+135
  298.     mov  edx,0x00b6aaff
  299.     mov  esi,0x80b9aaff; bbee - 0x202020
  300.     mov  edi,0x00b9aaff ;bbee
  301.     mov  edx,[col]
  302.     add  edx,0x00000000
  303.     mov  esi,[col]
  304.     add  esi,0x80000000
  305.     mov  edi,[col]
  306.     int  0x40
  307.  
  308.     mov  eax,4                          ; write text
  309.     mov  ebx,8*65536+8
  310.     mov  ecx,[tcolor]
  311.     mov  edx,labelt
  312.     mov  esi,labellen-labelt
  313.     int  0x40
  314.  
  315.     mov  eax,8                          ; CLOSE BUTTON
  316.     mov  ebx,(240-18)*65536+10
  317.     mov  ecx,6  *65536+10
  318.     mov  edx,100
  319.     mov  esi,[col]
  320.     sub  esi,0x302010
  321.     int  0x40
  322.  
  323.  
  324.     ; first row
  325.  
  326.     mov  eax,8                     ; button
  327.     mov  edx,1                     ; button number
  328.     mov  ebx,9*65536+21            ; button start x & size
  329.     mov  ecx,30*65536+13           ; button start y & size
  330.     mov  esi,[bcolor]              ; button color
  331.    newbutton1:
  332.     pusha
  333.     int  0x40
  334.     popa
  335.  
  336.     pusha
  337.     mov  eax,dword 0x00000004
  338.     and  ebx,65535*65536
  339.     shr  ecx,16
  340.     add  ebx,ecx
  341.     add  ebx,6*65536+3
  342.     mov  ecx,[tcolor]
  343.     shl  edx,1
  344.     add  edx,nro-2
  345.     mov  esi,2
  346.     int  0x40
  347.     popa
  348.  
  349.     add  ebx,22*65536
  350.     inc  edx
  351.     cmp  edx,11
  352.     jnz  newbutton1
  353.  
  354.     ; second row
  355.  
  356.     mov  eax,8                     ; button
  357.     mov  edx,11                    ; button number
  358.     mov  ebx,9*65536+21            ; button start x & size
  359.     mov  ecx,50*65536+13           ; button start y & size
  360.     mov  esi,[bcolor]              ; button color
  361.    newbutton2:
  362.     pusha
  363.     int  0x40
  364.     popa
  365.  
  366.     pusha
  367.     mov  eax,dword 0x00000004
  368.     and  ebx,65535*65536
  369.     shr  ecx,16
  370.     add  ebx,ecx
  371.     add  ebx,6*65536+3
  372.     mov  ecx,[tcolor]
  373.     shl  edx,1
  374.     add  edx,nro2-2-20
  375.     mov  esi,2
  376.     int  0x40
  377.     popa
  378.  
  379.  
  380.     add  ebx,22*65536
  381.     inc  edx
  382.     cmp  edx,21
  383.     jnz  newbutton2
  384.  
  385.     ; third row
  386.  
  387.     mov  eax,8                     ; button
  388.     mov  edx,21                    ; button number
  389.     mov  ebx,9*65536+21            ; button start x & size
  390.     mov  ecx,70*65536+13           ; button start y & size
  391.     mov  esi,[bcolor]              ; button color
  392.    newbutton3:
  393.     pusha
  394.     int  0x40
  395.     popa
  396.  
  397.     pusha
  398.     mov  eax,dword 0x00000004
  399.     and  ebx,65535*65536
  400.     shr  ecx,16
  401.     add  ebx,ecx
  402.     add  ebx,6*65536+3
  403.     mov  ecx,[tcolor]
  404.     shl  edx,1
  405.     add  edx,nro3-2-40
  406.     mov  esi,2
  407.     int  0x40
  408.     popa
  409.  
  410.     add  ebx,22*65536
  411.     inc  edx
  412.     cmp  edx,31
  413.     jnz  newbutton3
  414.  
  415.  
  416.     ; fourth row
  417.  
  418.     mov  eax,8                     ; button
  419.     mov  edx,41                    ; button number
  420.     mov  ebx,9*65536+109           ; button start x & size
  421.     mov  ecx,90*65536+13           ; button start y & size
  422.     mov  esi,0x00aabbcc            ; button color
  423.    newbutton4:
  424.     pusha
  425.     int  0x40
  426.     popa
  427.  
  428.     pusha
  429.     mov  eax,4
  430.     and  ebx,65535*65536
  431.     shr  ecx,16
  432.     add  ebx,ecx
  433.     add  ebx,9*65536+3
  434.     mov  ecx,[tcolor]
  435.     sub  edx,41
  436.     shl  edx,4
  437.     add  edx,text
  438.     mov  esi,16
  439.     int  0x40
  440.     popa
  441.  
  442.     add  ebx,110*65536
  443.     inc  edx
  444.     cmp  edx,43
  445.     jnz  newbutton4
  446.  
  447.     call drawinfo
  448.  
  449.     mov  eax,12                    ; tell os about redraw end
  450.     mov  ebx,2
  451.     int  0x40
  452.  
  453.     popa
  454.     ret
  455.  
  456.  
  457.  
  458.  
  459. ; DATA AREA
  460.  
  461. col         dd   0x7777aa
  462. tcolor      dd   0xffffff
  463. bcolor      dd   0xaabbcc
  464. labelt:     db   'CD PLAYER'
  465. labellen:
  466. infotext:   db   '01 First Track: xx Last Track: xx  '
  467. itl:
  468. infotext2:  db   'DEFINE CD ROM BASE WITH SETUP      '
  469. itl2:
  470. infotext3:  db   'READING PLAYLIST - (10 secs)       '
  471. itl3:
  472. nro:        db   '01020304050607080910'
  473. nro2:       db   '11121314151617181920'
  474. nro3:       db   '21222324252627282930'
  475. text:       db   '     STOP        READ PLAYLIST  '
  476.  
  477. cdinfo:
  478.  
  479. I_END:
  480.  
  481.  
  482.  
  483.