Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;    COLOR TABLE
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6.  
  7. use32
  8.  
  9.                 org     0x0
  10.  
  11.                 db      'MENUET00'              ; 8 byte id
  12.                 dd      38                      ; required os
  13.                 dd      START                   ; program start
  14.                 dd      I_END                   ; program image size
  15.                 dd      0x1000                  ; required amount of memory
  16.                 dd      0x1000                  ; esp = 0x7FFF0
  17.                 dd      0x00000000              ; reserved=no extended header
  18.  
  19. include 'lang.inc'
  20. include 'macros.inc'
  21.  
  22.  
  23. START:                          ; start of execution
  24.  
  25.     call shape_window
  26.  
  27.     call draw_window            ; at first, draw the window
  28.  
  29. still:
  30.  
  31.     mov  eax,10                 ; wait here for event
  32.     int  0x40
  33.  
  34.     cmp  eax,1                  ; redraw request ?
  35.     jz   red
  36.     cmp  eax,2                  ; key in buffer ?
  37.     jz   key
  38.     cmp  eax,3                  ; button in buffer ?
  39.     jz   button
  40.  
  41.     jmp  still
  42.  
  43.   red:                          ; redraw
  44.     call draw_window
  45.     jmp  still
  46.  
  47.   key:                          ; key
  48.     mov  eax,2                  ; just read it and ignore
  49.     int  0x40
  50.     jmp  still
  51.  
  52.   button:                       ; button
  53.     mov  eax,17                 ; get id
  54.     int  0x40
  55.  
  56.     cmp  ah,1                   ; button id=1 ?
  57.     jnz  noclose
  58.     mov  eax,0xffffffff         ; close this program
  59.     int  0x40
  60.   noclose:
  61.  
  62.     jmp  still
  63.  
  64.  
  65. shape_window:
  66.  
  67.     pusha
  68.  
  69.     mov  eax,50      ; give the address of reference area
  70.     mov  ebx,0
  71.     mov  ecx,shape_reference
  72.     int  0x40
  73.  
  74.     mov  eax,50      ; give the scaling ( 5 -> 2^5 )
  75.     mov  ebx,1
  76.     mov  ecx,5
  77.     int  0x40
  78.  
  79.     popa
  80.  
  81.     ret
  82.  
  83.  
  84. shape_reference:
  85.  
  86.     db   1,0,1,0,1,0,1,0
  87.     db   0,1,0,1,0,1,0,1
  88.     db   1,0,1,0,1,0,1,0
  89.     db   0,1,0,1,0,1,0,1
  90.     db   1,0,1,0,1,0,1,0
  91.     db   0,1,0,1,0,1,0,1
  92.     db   1,0,1,0,1,0,1,0
  93.     db   0,1,0,1,0,1,0,1
  94.  
  95.  
  96.  
  97. ;   *********************************************
  98. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  99. ;   *********************************************
  100.  
  101.  
  102. draw_window:
  103.  
  104.     mov  eax,12                    ; function 12:tell os about windowdraw
  105.     mov  ebx,1                     ; 1, start of draw
  106.     int  0x40
  107.  
  108.                                    ; DRAW WINDOW
  109.     mov  eax,0                     ; function 0 : define and draw window
  110.     mov  ebx,100*65536+255         ; [x start] *65536 + [x size]
  111.     mov  ecx,100*65536+255         ; [y start] *65536 + [y size]
  112.     mov  edx,0x00000000
  113.     mov  esi,0x8099bbff            ; color of grab bar  RRGGBB,8->color glide
  114.     mov  edi,0x0099bbee            ; color of frames    RRGGBB
  115.     int  0x40
  116.  
  117.     call draw_colors
  118.  
  119.                                    ; CLOSE BUTTON
  120.     mov  eax,8                     ; function 8 : define and draw button
  121.     mov  ebx,5*65536+12            ; [x start] *65536 + [x size]
  122.     mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
  123.     mov  edx,1                     ; button id
  124.     mov  esi,0xccaa22              ; button color RRGGBB
  125.     int  0x40
  126.  
  127.     mov  eax,12                    ; function 12:tell os about windowdraw
  128.     mov  ebx,2                     ; 2, end of draw
  129.     int  0x40
  130.  
  131.     ret
  132.  
  133.  
  134. draw_colors:
  135.  
  136.     pusha
  137.  
  138.     mov  [bar],dword 0
  139.  
  140.     mov  eax,-1
  141.     mov  ebx,0
  142.     mov  ecx,0
  143.     mov  edx,0
  144.  
  145.     mov  edi,0
  146.  
  147.   dc1:
  148.  
  149.     add  eax,1
  150.     cmp  eax,256
  151.     jb   na1
  152.     mov  eax,0
  153.     add  ebx,1
  154.     cmp  ebx,256
  155.     jb   na1
  156.     mov  ebx,0
  157.     add  ecx,5
  158.   na1:
  159.  
  160.     mov  dl,al
  161.     shl  edx,8
  162.     mov  dl,bl
  163.     shl  edx,8
  164.     mov  dl,cl
  165.  
  166.   na2:
  167.  
  168.     pusha
  169.     push edx
  170.  
  171.     xor  edx,edx
  172.     mov  eax,edi
  173.     mov  ebx,256
  174.     div  ebx
  175.     mov  ebx,edx
  176.     mov  ecx,eax
  177.  
  178.     add  ebx,[addx]
  179.     add  ecx,[addy]
  180.  
  181.     pop  edx
  182.     mov  eax,1
  183.     int  0x40
  184.     popa
  185.  
  186.     add  edi,1
  187.  
  188.     cmp  edi,256*256
  189.     jb   dc1
  190.  
  191.     popa
  192.     ret
  193.  
  194.  
  195.  
  196. ; DATA AREA
  197.  
  198. I_END:
  199.  
  200. bar  dd  ?
  201.  
  202. add1 dd  ?
  203. add2 dd  ?
  204.  
  205. addx dd  ?
  206. addy dd  ?
  207.