Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;   EXAMPLE APPLICATION
  3. ;
  4. ;   Compile with FASM for Menuet
  5. ;
  6. include 'macros.inc'
  7.  
  8. use32
  9.  
  10.                org    0x0
  11.  
  12.                db     'MENUET01'              ; 8 byte id
  13.                dd     0x01                    ; header version
  14.                dd     START                   ; start of code
  15.                dd     I_END                   ; size of image
  16.                dd     0x1000                  ; memory for app
  17.                dd     0x1000                  ; esp
  18.                dd     0x0 , 0x0               ; I_Param , I_Icon
  19.  
  20. START:                          ; start of execution
  21.  
  22. red:
  23.      call draw_window
  24.  
  25. still:
  26.  
  27.     push 10             ; wait here for event
  28.     pop  eax
  29.     int  0x40
  30.  
  31.     dec  eax            ; redraw request ?
  32.     jz   red
  33.     dec  eax            ; key in buffer ?
  34.     jz   key
  35.  
  36.   button:                       ; button
  37.     mov  al,17          ; get id
  38.     int  0x40
  39.  
  40.     cmp ah,2
  41.     je button2
  42.  
  43.     cmp ah,3
  44.     je button3
  45.  
  46.     cmp ah,4
  47.     je button4
  48.  
  49.     cmp ah,5
  50.     je button5
  51.  
  52.     cmp  ah,1           ; button id=1 ?
  53.     jne  noclose
  54.  
  55.     or   eax,-1                 ; close this program
  56.     int  0x40
  57.  
  58.   noclose:
  59.     jmp  still
  60.  
  61.   button2:      ;option 1
  62.    call set_optionbox
  63.   jmp still
  64.  
  65.   button3:      ;option 2
  66.    call set_optionbox
  67.   jmp still
  68.  
  69.   button4:      ;option 3
  70.    call set_optionbox
  71.   jmp still
  72.  
  73.   button5:
  74.    mov  eax,4                            ; function 4 : write text to window
  75.    mov  ebx,170*65536+35                 ; [x start] *65536 + [y start]
  76.    mov  ecx,[sc.work_button_text]  ; font 1 & color ( 0xF0RRGGBB )
  77.    mov  edx,options-1
  78.    add  dl, [optionbox_checked]    ; pointer to text beginning
  79.    mov  esi,1      ; text length
  80.    int  0x40
  81.  
  82.   jmp still
  83.  
  84. key:                                  ; key
  85.    mov  al,2                    ; just read it and ignore
  86.    int  0x40
  87.    jmp  still
  88.  
  89.  
  90. ;   *********************************************
  91. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  92. ;   *********************************************
  93.  
  94.  
  95. draw_window:
  96.  
  97.     mov  eax,48
  98.     mov  ebx,3
  99.     mov  ecx,sc
  100.     mov  edx,sizeof.system_colors
  101.     int  0x40
  102.  
  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.     xor  eax,eax                           ; function 0 : define and draw window
  110.     mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
  111.     mov  ecx,100*65536+120         ; [y start] *65536 + [y size]
  112.     mov  edx,[sc.work]           ; color of work area RRGGBB,8->color gl
  113.     or   edx,0x33000000
  114.     mov  edi,header              ; WINDOW LABEL
  115.     int  0x40
  116.  
  117.     mov  eax,8                     ; function 8 : define and draw button
  118.     mov  ebx,165*65536+15          ; [x start] *65536 + [x size]
  119.     mov  ecx,30*65536+15           ; [y start] *65536 + [y size]
  120.     mov  edx,5                     ; button id
  121.     mov  esi,[sc.work_button]      ; button color RRGGBB
  122.     int  0x40
  123.  
  124.   draw_optionboxes:
  125.     ;draw optionbox1
  126.     mov eax, 45 shl 16 + 20        ; [x start] shl 16 + [y start]
  127.     mov cl, 2                      ; button id
  128.     mov edx, optiontext1           ; pointer to text beginning
  129.     call optionbox
  130.  
  131.     ;draw optionbox2
  132.     mov eax, 45 shl 16 + 40        ; [x start] shl 16 + [y start]
  133.     mov cl, 3                      ; button id
  134.     mov edx, optiontext2           ; pointer to text beginning
  135.     call optionbox
  136.  
  137.     ;draw optionbox3
  138.     mov eax, 45 shl 16 + 60        ; [x start] shl 16 + [y start]
  139.     mov cl, 4                      ; button id
  140.     mov edx, optiontext3           ; pointer to text beginning
  141.     call optionbox
  142.  
  143.  
  144.     mov  eax,12                          ; function 12:tell os about windowdraw
  145.     mov  ebx,2                     ; 2, end of draw
  146.     int  0x40
  147.  
  148.     ret
  149.  
  150. include "optbox.inc"
  151.  
  152. ; DATA AREA
  153.  
  154. optiontext1: db 'OptionBox1',0
  155. optiontext2: db 'OptionBox2',0
  156. optiontext3: db 'OptionBox3',0
  157.  
  158. options: db '0123'
  159.  
  160. header   db   'OptionBox example',0
  161.  
  162. I_END:
  163.  
  164. sc     system_colors
  165.  
  166.