Subversion Repositories Kolibri OS

Rev

Rev 109 | 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.  
  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      0x8000                  ; required amount of memory
  16.                 dd      0x8000                  ; esp = 0x7FFF0
  17.                 dd      0x00000000              ; reserved=no extended header
  18.  
  19. include 'lang.inc'
  20. include '..\..\..\macros.inc'
  21.  
  22. begin dd 0
  23.  
  24. START:                          ; start of execution
  25.  
  26.     call open_file
  27.  
  28. red:
  29.     call draw_window            ; at first, draw the window
  30.  
  31. still:
  32.  
  33.     mov  eax,10                 ; wait here for event
  34.     mcall
  35.  
  36.     dec  eax                    ; redraw request ?
  37.     je   red
  38.     dec  eax                    ; key in buffer ?
  39.     je   key
  40.     dec  eax                    ; button in buffer ?
  41.     je   button
  42.  
  43.     jmp  still
  44.  
  45. ;  red:                          ; redraw
  46. ;    call draw_window
  47. ;    jmp  still
  48.  
  49.   key:                          ; key
  50.     mov  eax,2                  ; just read it and ignore
  51.     mcall
  52.     jmp  still
  53.  
  54.   button:                       ; button
  55.     mov  eax,17                 ; get id
  56.     mcall
  57.  
  58.     cmp  ah,3
  59.     jne  no_up
  60.     cmp  [begin],16
  61.     jb   no_up
  62.  
  63.     add  [begin],-16
  64.     jmp  red
  65.   no_up:
  66.  
  67.     cmp  ah,4
  68.     jne  no_down
  69.     add  [begin],16
  70.     jmp  red
  71.   no_down:
  72.  
  73.     dec  ah                     ; button id=1 ?
  74.      jne  still
  75.      or   eax,-1                ; close this program
  76.     mcall
  77.  
  78.  
  79. ;   *********************************************
  80. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  81. ;   *********************************************
  82.  
  83.  
  84. draw_window:
  85.  
  86.     mov  eax,12                    ; function 12:tell os about windowdraw
  87.     mov  ebx,1                     ; 1, start of draw
  88.     mcall
  89.  
  90.                                    ; DRAW WINDOW
  91.     xor  eax,eax                   ; function 0 : define and draw window
  92.     mov  ebx,100*65536+400         ; [x start] *65536 + [x size]
  93.     mov  ecx,100*65536+270         ; [y start] *65536 + [y size]
  94.     mov  edx,0x13224466            ; color of work area RRGGBB,8->c
  95.     mov  edi,title                 ; WINDOW LABEL
  96.     mcall
  97.  
  98.                                    
  99.     mov  eax,8
  100.     mov  ebx,280*65536+16*6
  101.     mov  ecx,240*65536+14
  102.     mov  edx,2
  103.     mov  esi,0x5599cc
  104.      mcall
  105.  
  106.     mov  ebx,15*65536+125
  107.      inc  edx
  108.       mcall
  109.  
  110.  
  111.     add  ebx,127*65536
  112.      inc  edx
  113.      mcall
  114.  
  115.  
  116.     mov  eax,4
  117.     mov  ebx,15*65536+243
  118.     mov  ecx,0xffffff
  119.     mov  edx,buttons
  120.     mov  esi,blen-buttons
  121.     mcall
  122.  
  123.  
  124.     mov  ebx,280*65536+35           ; draw info text with function 4
  125.     mov  ecx,0xffffff
  126.     mov  edx,text
  127.     add  edx,[begin]
  128.  
  129.     mov  esi,16
  130.      mov  edi,esi
  131.    newline:
  132.  
  133.  push ebx                          ; hext
  134.  push edx
  135. push edi
  136.  
  137.     mov  edi,16
  138.     mov  ecx,edx
  139.     mov  edx,ebx
  140.     add  edx,-265*65536
  141.  
  142.     mov  eax,47
  143.     mov  ebx,0x00020101
  144.     mov  esi,0xffff00
  145.  
  146.    newhex:
  147.  
  148.  ;   mov  ebx,0x00020101
  149.  ;   mov  esi,0xffff00
  150.     mcall
  151.  
  152.     add  edx,16*65536
  153.      inc  ecx
  154.      dec  edi
  155.     jne  newhex
  156.  
  157. ;    popa
  158. pop edi
  159. pop edx
  160. pop ebx
  161.  
  162.     mov  eax,4                     ; text
  163.     mov  esi,16
  164.     mov  ecx,0xffffff
  165.     mcall
  166.     add  ebx,12
  167.     add  edx,16
  168.     dec  edi
  169.     jnz  newline
  170.  
  171.     mov  eax,12                    ; function 12:tell os about windowdraw
  172.     mov  ebx,2                     ; 2, end of draw
  173.     mcall
  174.  
  175.     ret
  176.  
  177.  
  178.  
  179. file_name  db  'EXAMPLE.ASM   '
  180.       ;    db  'EXAMPLE       '
  181.  
  182. open_file:
  183.  
  184.     pusha
  185.  
  186.     mov  eax,6
  187.     mov  ebx,file_name
  188.     xor  ecx,ecx
  189.     mov  edx,-1
  190.     mov  esi,text
  191.     mcall
  192.  
  193.     popa
  194.  
  195.     ret
  196.  
  197.  
  198.  
  199. ; DATA AREA
  200.  
  201. title  db  'HEXVIEW',0
  202.  
  203. buttons  db  '        UP                   DOWN'
  204.          db  '              EXAMPLE      '
  205. blen:
  206.  
  207. text:
  208.  
  209. I_END:
  210.